| Server IP : 195.130.67.5 / Your IP : 216.73.216.231 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/icd/administrator/components/com_staffmaster/ |
Upload File : |
<?php
/**
* File: controller.php
*
* Staff Master 0.7.5.5
*
* Staff Master - Staff Members and Departments Manager
*
* @version 0.7.5.5
* @package StaffMaster_0_7_5_5
* @subpackage admin
* @copyright (C) 2007-2008 Travis Hubbard
* @license http://www.gnu.org/licenses/ GNU/GPL v3
* @link http://www.systemsunited.net/
**/
defined( '_JEXEC' ) or die( 'Restricted access' );
/**
* Import Joomla's Controller
*/
jimport( 'joomla.application.component.controller' );
/**
* Import Joomla's Language Helper Functions
*/
jimport( 'joomla.language.helper' );
/**
* Load Staffmaster Stylesheets and jscripts
*/
JHTML::stylesheet('staffmaster_admin_default.css' , 'administrator/components/'. $option .'/css/');
JHTML::script( 'jquery-1.2.6.min.js' , 'components/'. $option .'/js/', false );
JHTML::script( 'staffmaster_jquery_noconflict.js' , 'components/'. $option .'/js/', false );
/**
* Require Staff Master's external functions file
*/
require_once( JApplicationHelper::getPath('admin_functions') );
/**
* Get component parameters
*/
$cparams = JComponentHelper::getParams( $option );
$sm_version = $cparams ->get( 'version' );
require_once( 'files' . DS . 'staffmaster_paths.php' );
$user =& JFactory::getUser();
$access = allowComponentAccess( $user );
$passkey = md5( JText::_("SM_ACCESS_TOKEN") );
if( $access != $passkey ) {
switch( $access ) {
case 'noauth':
$this->notAuth();
break;
case 'nologin':
$this->notLoggedIn();
break;
}
}
/**
* HTML_staffmaster: the html output view class in staffmaster's admin area
*/
class StaffController extends JController {
/**
* Default Constructor
*/
function __construct( $default = array() ) {
parent::__construct( $default );
$this->registerTask( 'staff' , 'showStaff' );
$this->registerTask( 'add' , 'edit' );
$this->registerTask( 'apply' , 'save' );
$this->registerTask( 'unpublish' , 'publish' );
$this->registerTask( 'departments' , 'departments' );
$this->registerTask( 'adddepartment' , 'editDepartment' );
$this->registerTask( 'editdepartment' , 'editDepartment' );
$this->registerTask( 'applydepartment' , 'saveDepartment' );
$this->registerTask( 'savedepartment' , 'saveDepartment' );
$this->registerTask( 'removedepartment' , 'removeDepartment' );
$this->registerTask( 'publishdept' , 'publishDepartment' );
$this->registerTask( 'unpublishdept' , 'publishDepartment' );
$this->registerTask( 'settings' , 'editSettings' );
$this->registerTask( 'savesettings' , 'saveSettings' );
$this->registerTask( 'applysettings' , 'saveSettings' );
$this->registerTask( 'updatedb' , 'updateDB' );
$this->registerTask( 'select_css' , 'selectTemplateCSS' );
$this->registerTask( 'edit_css' , 'editTemplateCSS' );
$this->registerTask( 'save_css' , 'saveTemplateCSS' );
$this->registerTask( 'apply_css' , 'saveTemplateCSS' );
$this->registerTask( 'changegroup' , 'changegroup' );
$this->registerTask( 'getdefaultimageloc' , 'getdefaultimageloc' );
$this->registerTask( 'defaultcolors' , 'getDefaultColors' );
$this->registerTask( 'checkupdates' , 'newUpdate' );
$this->registerTask( 'disabletodo' , 'disableTodo' );
$this->registerTask( 'loadfile' , 'loadFile' );
}
/**
* staffMain
*/
function staffMain() {
global $option;
jimport( 'joomla.utilities.date' );
jimport( 'joomla.filesystem.file' );
JHTML::stylesheet('staffmaster_jquery_tabs.css' , 'administrator/components/'. $option .'/css/' );
JHTML::script( 'jquery-ui-core-1.6rc2.packed.js', 'administrator/components/'. $option .'/js/', false );
JHTML::script( 'jquery-ui-tabs.min.js' , 'administrator/components/'. $option .'/js/', false );
JHTML::script( 'staffmaster_staffmain.js' , 'administrator/components/'. $option .'/js/', false );
require_once( JApplicationHelper::getPath( 'toolbar_html' ) );
//Get Params from #__staff_settings
$params = getStaffParams();
$sm_version = $params->version;
$need_to_update_db = checkDB( );
$com_check_html = null;
/**
* @name $todo
*/
$todo = $params->show_todo;
if( $params->show_com_check ) {
$staff = getAllStaffList();
$departments = getAllDepartmentList();
$com_check_html = doComCheck( $option , $staff , $departments , $params , $sm_version );
}
HTML_staffmaster::staffMain( $option , $todo , $com_check_html , $need_to_update_db );
}
/**
* showShow : lists all staff members in the admin table
*/
function showStaff() {
global $option, $mainframe;
$limit = JRequest::getVar( 'limit' , $mainframe->getCfg( 'list_limit' ) );
$limitstart = JRequest::getVar( 'limitstart' , 0 );
//Department Filtering
$filter_dept = JRequest::getVar( 'filter_dept' , 0 );
// Published Filtering
$filter_published = JRequest::getVar( 'filter_pub' , 0 );
$filtered_query_string = "WHERE ";
$filtered_query = 0;
if( $filter_dept ) {
$filtered_query_string .= "dept_id = $filter_dept ";
$filtered_query++;
}
if( $filter_published ) {
if( $filtered_query )
$filtered_query_string .= "AND ";
if( $filter_published == 2 )
$filtered_query_string .= "published = 0 ";
else
$filtered_query_string .= "published = $filter_published ";
$filtered_query++;
}
$db =& JFactory::getDBO();
$query_ct = "SELECT count(*) FROM #__staff";
$db->setQuery( $query_ct );
$total = $db->loadResult();
// Build Staff Query
$query_getStaff = "SELECT * "
. "FROM #__staff ";
if( $filtered_query )
$query_getStaff .= $filtered_query_string;
$query_getStaff .= "ORDER BY dept_id , ordering ";
$db->setQuery( $query_getStaff , $limitstart , $limit );
$rows = $db->loadObjectList();
if ($db->getErrorNum()) {
echo $db->stderr();
return false;
}
$query_getDepts = "SELECT id, name "
. "FROM #__staff_departments "
. "ORDER BY ordering ";
$db->setQuery( $query_getDepts , $limitstart, $limit );
$departments = $db->loadObjectList();
if ($db->getErrorNum()) {
echo $db->stderr();
return false;
}
$params = getStaffParams();
$i = 1;
foreach($departments as $useless => $dept ) {
$department_names_arr[ $dept->name ] = $dept->id;
if( $i == 1 ) {
$filter_dept_data[] = JHTML::_( 'select.option' , '0' , JText::_( 'OPTION_BYDEPT' ) );
}
$filter_dept_data[] = JHTML::_( 'select.option' , $dept->id , $dept->name );
$i++;
}
$filter_published_data[] = JHTML::_( 'select.option' , '0' , JText::_( 'OPTION_BYPUB' ) );
$filter_published_data[] = JHTML::_( 'select.option' , '1' , JText::_( 'PUBLISHED' ) );
$filter_published_data[] = JHTML::_( 'select.option' , '2' , JText::_( 'UNPUBLISHED' ) );
$lists['published'] = JHTML::_('select.genericList', $filter_published_data , 'filter_pub' ,
'class="inputbox" onchange="document.adminForm.submit( );"' , 'value' , 'text' , $filter_published );
$lists['department_names'] = JHTML::_('select.genericList', $filter_dept_data , 'filter_dept' ,
'class="inputbox" onchange="document.adminForm.submit( );"' , 'value' , 'text' , $filter_dept );
jimport('joomla.html.pagination');
$pageNav = new JPagination($total, $limitstart, $limit);
HTML_staffmaster::showStaff( $option , $rows , $department_names_arr , $pageNav , $params , $lists );
}
/**
* edit : Edit a Staff Member
*/
function edit() {
global $option;
// Adds an extra jQuery js file for changing departments behind the scenes
JHTML::script('staffmaster_staff_department.js', 'administrator/components/'. $option .'/js/', false );
$task = $this->_task;
$db =& JFactory::getDBO();
$row =& JTable::getInstance('staff', 'Table');
$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
$id = $cid[0];
$row->load($id);
// If this is a new employee, automatically set published to 1
if( $task == 'add' ) {
$row->published = 1;
$row->dept_id = 1;
}
$query_getStaff = "SELECT id , name , dept_id , ordering "
. "FROM #__staff "
. "WHERE published = 1 AND dept_id = {$row->dept_id} "
. "ORDER BY dept_id , ordering ";
$db->setQuery( $query_getStaff );
$staff_order = $db->loadObjectList();
$query_getDepts = "SELECT id , name , ordering "
. "FROM #__staff_departments "
. "WHERE published = 1 "
. "ORDER BY ordering ";
$db->setQuery( $query_getDepts );
$departments = $db->loadObjectList();
//Create Ordering Select List
$ordering_html = createOrderingHtml( $staff_order , $row->name );
//Create dept Select List
$department_html = createDepartmentHtml( $departments , $row );
$published_html = createPublishedHtml( $row->published );
//Get Params from #__staff_settings
$params = getStaffParams();
$auto_alias = $params->auto_alias;
$lists = array();
$lists['ordering'] = $ordering_html;
$lists['departments'] = $department_html;
$lists['department_names'] = JHTML::_('select.genericList', $departments , 'dept_id' , 'class="inputbox" '. '', 'id', 'name', $row->dept_id );
$lists['published'] = $published_html;
$lists['image'] = JHTML::_('list.images', 'image_file_name', $row->image_file_name, null, $params->staff_image_path );
HTML_staffmaster::editStaff( $row , $lists , $option , $auto_alias );
}
/**
* save : Save a staff member
*/
function save() {
jimport('joomla.filter.filteroutput');
JRequest::checkToken() or jexit( 'Invalid Token' );
global $option;
$data = JRequest::get('post' , JREQUEST_ALLOWRAW );
$row =& JTable::getInstance('staff', 'Table');
if (!$row->bind( $data ) ) {
echo "<script> alert('".$row->getError()."');
window.history.go(-1); </script>\n";
exit();
}
// If there is no alias, or cfg was set to automatically parse alias...
if( $data['auto_alias'] || empty( $row->alias ) ) {
$this->makeAlias( $row );
}
if( $row->ordering == 'first' ) {
$row->ordering = setFirstReorder( $row->dept_id , $row->id );
}
elseif( $row->ordering == 'last' ) {
$row->ordering = setLastReorder( $row->dept_id , $row->id );
}
else {
$row->ordering = setOtherReorder( $row->dept_id , $row->id , $row->ordering );
}
if (!$row->store()) {
echo "<script> alert('".$row->getError()."'); window.history.
go(-1); </script>\n";
exit();
}
//Set message and link and redirect back
switch ($this->_task) {
case 'apply':
$msg = JText::_('ST_STAFF_MEMBER') . ' ' . $row->name . ' ' . JText::_('SS_ST_UPDATE');
$link = 'index.php?option=' . $option . '&task=edit&cid[]='. $row->id;
break;
case 'save':
default:
$msg = JText::_('ST_STAFF_MEMBER') . ' ' . $row->name . ' ' . JText::_('SS_ST_UPDATE');
$link = 'index.php?option=' . $option . '&task=staff' ;
break;
}
$this->setRedirect($link, $msg);
}
/**
* remove : Remove staff member from database
*/
function remove() {
global $option;
$db =& JFactory::getDBO();
$cid = JRequest::getVar( 'cid', array(), '', 'array' );
if(count($cid)) {
$cids = implode( ',' , $cid );
$query_reorder = "SELECT dept_id "
. "FROM #__staff "
. "WHERE id IN ( $cids ) ";
$db->setQuery( $query_reorder );
$dept_ids = $db->loadObjectList();
reorderDepartmentsAfterDelete( $dept_ids , $cids );
$query_delStaff = "DELETE FROM #__staff "
. "WHERE id IN ( $cids )";
$db->setQuery( $query_delStaff );
if (!$db->query()) {
echo "<script> alert('".$db->getErrorMsg()."'); window.
history.go(-1); </script>\n";
}
}
$this->setRedirect( 'index.php?option=' . $option . '&task=staff' );
}
/**
* publish : dual-purpose function, to Publish or Unpublish a staff member from view
*/
function publish() {
global $option;
$cid = JRequest::getVar( 'cid', array(), '', 'array' );
if( $this->_task == 'publish') {
$publish = 1;
$msg = JText::_("ST_SM_PUB");
}
else {
$publish = 0;
$msg = JText::_("ST_SM_UNPUB");
}
$staffTable =& JTable::getInstance('staff', 'Table');
$staffTable->publish($cid, $publish);
$this->setRedirect( 'index.php?option=' . $option . '&task=staff' , $msg );
}
/**
* departments : Show All Staff depts
*/
function departments() {
global $mainframe, $option;
$db =& JFactory::getDBO();
$limit = JRequest::getVar( 'limit' , $mainframe->getCfg( 'list_limit' ) );
$limitstart = JRequest::getVar( 'limitstart' , 0 );
$data = JRequest::get('post' , JREQUEST_ALLOWRAW );
$query_ct = "SELECT count(*) "
. "FROM #__staff_departments ";
$db->setQuery( $query_ct );
$total = $db->loadResult();
if ($db->getErrorNum()) {
echo $db->stderr();
return false;
}
$query_getDepts = "SELECT * FROM #__staff_departments "
. "ORDER BY ordering ";
$db->setQuery( $query_getDepts , $limitstart, $limit );
$rows = $db->loadObjectList();
if ($db->getErrorNum()) {
echo $db->stderr();
return false;
}
jimport('joomla.html.pagination');
$pageNav = new JPagination($total, $limitstart, $limit);
HTML_staffmaster::showDepartments( $option, $rows , $pageNav );
}
/**
* editDepartment : Edit a dept
*/
function editDepartment() {
global $option;
// Adds an extra jQuery js file for changing departments behind the scenes
JHTML::script('staffmaster_edit_department.js', 'administrator/components/'. $option .'/js/', false );
$row =& JTable::getInstance('departments', 'Table');
$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
$id = $cid[0];
$row->load($id);
$db =& JFactory::getDBO();
$query_getDept = "SELECT id , name , ordering "
. "FROM #__staff_departments "
. "WHERE published = 1 "
. "ORDER BY ordering ";
$db->setQuery( $query_getDept );
$dept_order = $db->loadObjectList();
//Get Params from #__staff_settings
$params = getStaffParams();
$auto_alias = $params->auto_alias;
//Create Ordering Select List
$ordering_html = createOrderingHtml( $dept_order , $row->name );
$published_html = createPublishedHtml( $row->published );
$lists['ordering'] = $ordering_html;
$lists['published'] = $published_html;
HTML_staffmaster::editDepartment( $option, $row , $lists , $auto_alias );
}
/**
* saveDepartment : Save a dept
*/
function saveDepartment() {
JRequest::checkToken() or jexit( 'Invalid Token' );
global $option;
$data = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
$row =& JTable::getInstance('departments', 'Table');
if (!$row->bind( $data ) ) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
// If there is no alias, or cfg was set to automatically parse alias...
if( $data['auto_alias'] || empty( $row->alias ) ) {
$this->makeAlias( $row );
}
if( strlen( $data['name'] ) < 2 ) {
$link = 'index.php?option=' . $option . '&task=editdepartment&cid[]='. $row->id ;
$msg = JText::_("ER_NO_DEPT_TITLE");
$this->setRedirect($link, $msg);
}
if( $row->ordering == 'first' ) {
$row->ordering = setFirstReorder( 0 , $row->id , true );
}
elseif( $row->ordering == 'last' ) {
$row->ordering = setLastReorder( 0 , $row->id , true );
}
else {
$row->ordering = setOtherReorder( 0 , $row->id , $row->ordering , true );
}
if (!$row->store()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
//Set message for setRedirect
if( $data['last_task'] == 'adddepartment' ) {
$msg = JText::_('ST_DEPARTMENT') . ' ' . $row->name . ' ' . JText::_('SS_ST_ADDED');
}
else {
$msg = JText::_('ST_DEPARTMENT') . ' ' . $row->name . ' ' . JText::_('SS_ST_UPDATE');
}
//Set link for setRedirect
if( $this->_task == 'applydepartment' ) {
$link = 'index.php?option=' . $option . '&task=editdepartment&cid[]='. $row->id;
}
else {
$link = 'index.php?option=' . $option . '&task=departments';
}
$this->setRedirect($link, $msg);
}
/**
* removeDepartment : Remove one or many departments from DB
*/
function removeDepartment() {
global $option;
$cid = JRequest::getVar( 'cid', array(), '', 'array' );
$db =& JFactory::getDBO();
if( count($cid) ) {
$cids = implode( ',', $cid );
$query_delDept = "DELETE FROM #__staff_departments "
. "WHERE id IN ( $cids )";
$db->setQuery( $query_delDept );
if (!$db->query()) {
echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n";
}
}
$msg = JText::_("SS_DEL_DEPT");
$this->setRedirect( 'index.php?option=' . $option . '&task=departments' , $msg );
}
/**
* publishDepartment : Publish or Unpublish a staff member from view
*/
function publishDepartment() {
global $option;
$cid = JRequest::getVar( 'cid', array(), '', 'array' );
if( $this->_task == 'publishdept') {
$publish = 1;
$msg = JText::_( "ST_DEPT_PUB" );
}
else {
$publish = 0;
$msg = JText::_( "ST_DEPT_PUB" );
}
$staffTable =& JTable::getInstance('departments', 'Table');
$staffTable->publish($cid, $publish);
$this->setRedirect( 'index.php?option=' . $option . '&task=departments' , $msg );
}
/**
* publishedDeptIcon : create custom publish/unpublish department icon
*
* @param stdObj $row
* @param string $i
* @param string $imgY
* @param string $imgX
* @param string $prefix
* @return string $href
*/
function publishedDeptIcon ( $row, $i, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix='' )
{
$img = $row->published ? $imgY : $imgX;
$task = $row->published ? 'unpublishdept' : 'publishdept';
$alt = $row->published ? JText::_( 'Published' ) : JText::_( 'Unpublished' );
$action = $row->published ? JText::_( 'Unpublish Item' ) : JText::_( 'Publish item' );
$href = '
<a href="javascript:void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $prefix.$task .'\')" title="'. $action .'">
<img src="images/'. $img .'" border="0" alt="'. $alt .'" /></a>'
;
return $href;
}
/**
* editSettings : Show/Edit Settings
*/
function editSettings() {
global $option;
jimport( 'joomla.environment.browser' );
$browser = new JBrowser();
$currentBrowser = $browser->getBrowser();
$row =& JTable::getInstance('settings', 'Table');
// settings stored in id = 1
$row->load( 1 );
// **** Handle Stylesheets and Javascript ****
// stylesheet included for color chooser written by: Stefan Petre www.eyecon.ro
JHTML::stylesheet( 'colorpicker.css' , 'administrator/components/' . $option . '/css/');
if( $currentBrowser == "msie" ) {
JHTML::stylesheet('colorpicker_IE.css' , 'administrator/components/' . $option . '/css/');
}
// jQuery Plugin Script Included for color chooser written by: Stefan Petre www.eyecon.ro
JHTML::script( 'colorpicker.js' , 'administrator/components/' . $option . '/js/', false );
// Staff Master implementation of colorpicker.js
JHTML::script( 'staffmaster_colorpicker.js' , 'administrator/components/' . $option . '/js/', false );
// stylesheet included for preview view
JHTML::stylesheet( 'staffmaster_preview_default.css' , 'administrator/components/' . $option . '/css/');
// If View All uses the Clean style, make the preview in the Clean style
if( $row->view_all == 'clean' )
JHTML::stylesheet( 'staffmaster_preview_clean.css' , 'administrator/components/' . $option . '/css/');
jimport('joomla.html.pane');
JHTML::_('behavior.mootools');
$cparams = JComponentHelper::getParams( $option );
$show_sm_link = $cparams->get( 'show_sm_link' );
$show_sm_link_html = doRadioHtml( 'show_sm_link' , $show_sm_link );
$lists = array();
// Create HTML Radiolist for show dept footer
$show_all_dept_footers_html = doShowDeptFooterHtml( $row->show_dept_footer );
$show_dept_footer1_html = doShowDeptFooterHtml( $row->show_dept_footer , 1 );
$show_dept_footer2_html = doShowDeptFooterHtml( $row->show_dept_footer , 2 );
$show_dept_footer3_html = doShowDeptFooterHtml( $row->show_dept_footer , 3 );
// Create Yes/No HTML for using Custom Colors
$use_custom_colors_html = doUseCustomColorHtml( $row->use_custom_colors );
// Create Yes/No HTML for making the Staff Member Name into a Link
$link_staff_name_html = doRadioHtml( 'linkable_staff_name' , $row->linkable_staff_name );
// Create Yes/No HTML for making View Contact Details a clickable Link
$link_contact_details_html = doRadioHtml( 'linkable_contact_details' , $row->linkable_contact_details );
// Create Yes/No HTML for making Departments into a clickable link to that department
$link_department_html = doRadioHtml( 'linkable_department' , $row->linkable_department );
// Create Yes/No HTML for showing the To-Do in the main Staff Master Control Panel
$show_todo_html = doRadioHtml( 'show_todo' , $row->show_todo );
// Create Yes/No HTML for using staff images in List View Only
$list_images_html = doRadioHtml( 'list_use_image' , $row->list_use_image );
// Create Yes/No HTML for checking the version
$check_ver_html = doRadioHtml( 'check_version' , $row->check_version );
// Create Yes/No HTML for using Javascript on the front end
$js_frontend_html = doRadioHtml( 'use_js_frontend' , $row->use_js_frontend );
// Create Yes/No HTML for using Javascript to show contact details
$js_contact_html = doRadioHtml( 'use_js_contact' , $row->use_js_contact );
// Create Yes/No HTML for using Javascript to show rounded borders around staff
$js_corners_html = doRadioHtml( 'use_js_corners' , $row->use_js_corners );
// Create Yes/No HTML for placing the staff member's Title/Position in the Bio or next to Name
$title_bio_html = doRadioHtml( 'title_in_bio' , $row->title_in_bio , true );
// Create Yes/No HTML for automatically making an alias of staff Names when Editing Staff Members
$auto_alias_html = doRadioHtml( 'auto_alias' , $row->auto_alias );
// Create Left/Right HTML for where staff images will go
$image_pos_html = doRadioLeftRightHtml( 'staff_image_pos' , $row->staff_image_pos );
// Create Yes/No HTML for alternating staff images
// Not Implemented Yet
//$image_pos_alt_html = doRadioHtml( 'staff_image_pos_alt' , $row->staff_image_pos_alt );
// Create default/clean HTML for which stylesheet to use by default in this view
$view_all_html = doStylesheetHtml( 'view_all' , $row->view_all );
// Create default/clean HTML for which stylesheet to use by default in this view
$view_department_html = doStylesheetHtml( 'view_department' , $row->view_department );
// Create default/clean HTML for which stylesheet to use by default in this view
$view_staff_html = doStylesheetHtml( 'view_staff' , $row->view_staff );
// Create default/clean HTML for which stylesheet to use by default in this view
$view_listall_html = doStylesheetHtml( 'view_list' , $row->view_list );
//create custom color fields array
$temp_custom_colors = explode( ';' , $row->custom_colors );
$custom_colors = array();
foreach( $temp_custom_colors as $tcc ) {
$tcc = explode( '=' , $tcc );
$custom_colors[ trim( $tcc[ 0 ] ) ] = $tcc[ 1 ];
}
$TT_BG_COLOR = makeToolTip( JText::_( 'TT_BG_COLOR' ) , 'left' , 'warning.png' );
$staff_colors_html = doStaffColorsHtml( $custom_colors , $TT_BG_COLOR );
$com_check_html = doComCheckHtml( $row->show_com_check );
$lists['show_sm_link'] = $show_sm_link_html;
$lists['show_todo'] = $show_todo_html;
$lists['title_bio'] = $title_bio_html;
// Not Implemented Yet
//$lists['image_pos_alt'] = $image_pos_alt_html;
$lists['auto_alias'] = $auto_alias_html;
$lists['js_frontend'] = $js_frontend_html;
$lists['js_contact'] = $js_contact_html;
$lists['js_corners'] = $js_corners_html;
$lists['check_ver'] = $check_ver_html;
$lists['view_all'] = $view_all_html;
$lists['view_department'] = $view_department_html;
$lists['view_staff'] = $view_staff_html;
$lists['view_listall'] = $view_listall_html;
$lists['list_images'] = $list_images_html;
$lists['image_pos'] = $image_pos_html;
$lists['link_staff_name'] = $link_staff_name_html;
$lists['link_contact_details'] = $link_contact_details_html;
$lists['link_department'] = $link_department_html;
$lists['staff_colors'] = $staff_colors_html;
$lists['use_custom_colors'] = $use_custom_colors_html;
$lists['com_check'] = $com_check_html;
$lists['show_dept_footer'] = $show_all_dept_footers_html;
$lists['show_dept_footer_text1'] = $show_dept_footer1_html;
$lists['show_dept_footer_text2'] = $show_dept_footer2_html;
$lists['show_dept_footer_text3'] = $show_dept_footer3_html;
HTML_staffmaster::editSettings( $option, $row , $lists );
}
/**
* saveSettings : Save those settings you just masterfully editted
*/
function saveSettings() {
JRequest::checkToken() or jexit( 'Invalid Token' );
global $option;
$row =& JTable::getInstance('settings', 'Table');
$data = JRequest::get('post' , JREQUEST_ALLOWHTML );
if (!$row->bind( $data ) ) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
$db =& JFactory::getDBO();
$show_sm_link = $data['show_sm_link'];
$db->setQuery("UPDATE #__components SET params = 'show_sm_link={$show_sm_link}' WHERE name = 'Staff Master' ");
$db->query();
$page_title_color = "page_title_color=" . $data['page_title_color'];
$dept_name_color = "dept_name_color=" . $data['dept_name_color'];
$dept_desc_color = "dept_desc_color=" . $data['dept_desc_color'];
$staff_name_color = "staff_name_color=" . $data['staff_name_color'];
$staff_title_color = "staff_title_color=" . $data['staff_title_color'];
$staff_bio_color = "staff_bio_color=" . $data['staff_bio_color'];
$dept_unique_foot_color = "dept_unique_foot_color=" . $data['dept_unique_foot_color'];
$dept_general_foot_color = "dept_general_foot_color=" . $data['dept_general_foot_color'];
$contact_details = "contact_details=" . $data['contact_details'];
$contact_details_link = "contact_details_link=" . $data['contact_details_link'];
$custom_colors = array();
array_push($custom_colors , $page_title_color);
array_push($custom_colors , $dept_name_color);
array_push($custom_colors , $dept_desc_color);
array_push($custom_colors , $staff_name_color);
array_push($custom_colors , $staff_title_color);
array_push($custom_colors , $staff_bio_color);
array_push($custom_colors , $dept_unique_foot_color);
array_push($custom_colors , $dept_general_foot_color);
array_push($custom_colors , $contact_details);
array_push($custom_colors , $contact_details_link);
$row->custom_colors = implode( ';' , $custom_colors );
// Checking to make sure there is a '/' at the end of teh image path, if not, add it!
if( substr( $row->staff_image_path , -1 , 1 ) != "/" )
$row->staff_image_path .= '/';
if (!$row->store()) {
echo "<script> alert('".$row->getError()."'); window.history.go(-1); </script>\n";
exit();
}
switch( $this->getTask() ) {
case 'applysettings':
$link = 'index.php?option=' . $option . '&task=settings';
break;
case 'savesettings':
$link = 'index.php?option=' . $option;
break;
}
$msg = JText::_('ST_SS_CFG');
$this->setRedirect( $link , $msg );
}
/**
* updateDB : initiates the process that begins updating the database
*
*/
function updateDB() {
global $option;
updateDatabase();
$link = JRoute::_( 'index.php?option=' . $option );
$msg = JText::_( 'TH_UPDATE_COMPLETE' );
$this->setRedirect( $link , $msg );
}
/**
* selectTemplateCSS : displays all the .css files from Staff Master's front-end
*
*/
function selectTemplateCSS() {
global $option;
jimport('joomla.filesystem.file');
$template = JRequest::getVar('id', '', 'method', 'cmd');
$client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
$dir = JPATH_SITE . DS . 'components' . DS . $option . DS . 'css' . DS;
$files = JFolder::files($dir, '\.css$', false, false);
HTML_staffmaster::selectCSS( $files , $option , $dir , $template , $client );
}
/**
* editTemplateCSS : allows you to edit a .css file chosen in the previous funciton
*
*/
function editTemplateCSS() {
global $mainframe, $option;
jimport('joomla.filesystem.file');
$option = JRequest::getCmd('option');
$client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
$template = JRequest::getVar('id', '', 'method', 'cmd');
$filename = JRequest::getVar('filename', '', 'method', 'cmd');
$dir = JPATH_SITE . DS . 'components' . DS . $option . DS . 'css' . DS;
if ( JFile::getExt($filename) !== 'css' ) {
$msg = JText::_('ER_WRONG_FILE_TYPE') . $filename;
$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=choose_css&id='.$template, $msg, 'error');
}
$content = JFile::read( $dir . $filename );
if ($content !== false) {
// Set FTP credentials, if given
jimport('joomla.client.helper');
$content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');
HTML_staffmaster::editCSS( $dir , $template, $filename, $content, $option, $client);
}
else
{
$msg = JText::sprintf('Operation Failed Could not open', $client->path.$filename);
$mainframe->redirect('index.php?option='.$option.'&task=settings&client='.$client->id, $msg);
}
}
/**
* saveTemplateCSS : saves the .css file
*
*/
function saveTemplateCSS( ) {
global $mainframe;
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
// Initialize some variables
$option = JRequest::getCmd('option');
$client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int'));
$template = JRequest::getVar('id', '', 'post', 'cmd');
$filename = JRequest::getVar('filename', '', 'post', 'cmd');
$filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW);
$dir = JRequest::getVar('dir', '', 'post', 'string', JREQUEST_ALLOWRAW);
if (!$template) {
$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.'));
}
if (!$filecontent) {
$mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.'));
}
// Set FTP credentials, if given
// jimport('joomla.client.helper');
$file = $dir . $filename;
jimport('joomla.filesystem.file');
$return = JFile::write($file, $filecontent);
if ($return)
{
$task = JRequest::getCmd('task');
switch($task)
{
case 'apply_css':
$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_css&id='.$template.'&filename='.$filename, JText::_('File Saved'));
break;
case 'save_css':
default:
$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=select_css&id='.$template.'&filename='.$filename, JText::_('File Saved'));
break;
}
}
else {
$mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&id='.$template.'&task=choose_css', JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file));
}
}
/**
* changegroup : a function called via $().post , jQuery's method, in staffmaster_staff_department.js
*
* handles all the shuffling around and re-ordering of moving a staff member from one department to another
*
*/
function changegroup() {
$user_id = (int)JRequest::getVar( 'user_id' );
$dept_id = (int)JRequest::getVar( 'dept_id' );
$db =& JFactory::getDBO();
$query_order = "SELECT dept_id "
. "FROM #__staff "
. "WHERE id = $user_id ";
$db->setQuery( $query_order );
$old_dept = $db->loadObject();
$query_max = "SELECT MAX(ordering) as max_ordering "
. "FROM #__staff "
. "WHERE dept_id = {$dept_id} ";
$db->setQuery( $query_max );
$result = $db->loadObject();
$new_order = $result->max_ordering;
$new_order++;
$query_setOrder = "UPDATE #__staff "
. "SET ordering = {$new_order} , "
. "dept_id = {$dept_id} "
. "WHERE id = {$user_id} ";
$db->setQuery( $query_setOrder );
$db->query();
$query_getStaff = "SELECT * "
. "FROM #__staff "
. "WHERE dept_id = $dept_id ";
$db->setQuery( $query_getStaff );
$rows = $db->loadObjectList();
$a = createOrderingHtml( $rows , $user_id );
if( !is_null( $old_dept ) )
reorderLastDepartment( $old_dept->dept_id );
echo $a;
}
/**
* Enter description here...
*
*/
function getdefaultimageloc() {
$db =& JFactory::getDBO();
$query_imageloc = "SELECT staff_image_path "
. "FROM #__staff_settings ";
$result = $db->getOne( $query_imageloc );
echo "your website root dir. / <strong> $result </strong>";
}
/**
* Enter description here...
*
*/
function getShowComCheck() {
$db =& JFactory::getDBO();
$query_comcheck = "SELECT show_com_check "
. "FROM #__staff_settings ";
return $db->getOne( $query_comcheck );
}
/**
* Enter description here...
*
*/
function getShowToDo() {
$db =& JFactory::getDBO();
$query_todo = "SELECT show_todo "
. "FROM #__staff_settings ";
return $db->getOne( $query_todo );
}
/**
* Enter description here...
*
*/
function getDefaultColors() {
$db =& JFactory::getDBO();
$query_todo = "SELECT custom_colors "
. "FROM #__staff_settings ";
$results = $db->getOne( $query_todo );
$results = explode( ';' , $results );
$return_arr = array();
foreach( $results as $result ) {
$colors = explode( '=' , $result );
$return_arr[ trim( $colors[ 0 ] ) ] = $colors[ 1 ];
}
print json_encode($return_arr);
}
/**
* Enter description here...
*
*/
function notLoggedIn( ) {
$msg = JText::_('ERROR_NOLOGIN');
$home_link = '<a href="'.JPATH_BASE.'/index.php" >' . ST_HOME . '</a>';
HTML_support::supportError($home_link, $msg);
}
/**
* Enter description here...
*
*/
function notAuth( ) {
$msg = JText::_('ERROR_NOAUTH');
$home_link = '<a href="'.JPATH_BASE.'/index.php" >Back to Home</a>';
HTML_support::supportError($home_link, $msg);
}
/**
* Takes a Staff Member stdObj "row" and creates the proper alias field
*
* @param stdObj $row Passed in By Reference, changing the actual data
*/
function makeAlias( &$row ) {
// Import Joomla's Output Filter Class
jimport('joomla.filter.filteroutput');
$temp_alias = strtolower( $row->name );
$temp_alias = JFilterOutput::stringURLSafe( $temp_alias );
$row->alias = $temp_alias;
}
/**
* Checks to see if it is time to check the version and checks if yes
*
*/
function newUpdate() {
$db =& JFactory::getDBO();
$query_update = "SELECT version , last_checked , check_version , check_version_frequency "
. "FROM #__staff_settings "
. "WHERE id = 1 ";
$db->setQuery( $query_update );
$cfg = $db->loadObject();
if( $cfg->check_version ) {
$now = time();
$time_to_check = $cfg->check_version_frequency * 86400;
$time_since_last_check = $now - $cfg->last_checked;
if( $time_since_last_check > $time_to_check || empty( $cfg->last_checked ) ) {
$newUpdate = checkLatestVersion( $cfg->version ) ;
echo $newUpdate;
$db->setQuery( "UPDATE #__staff_settings SET last_checked = $now WHERE id = 1 " );
$db->query();
}
else {
echo $cfg->version . " " .JText::_("ST_NOT_TIME_YET") . ' ' . date( "m-d-Y h:i a" , $cfg->last_checked );
}
}
else {
echo JText::_("ST_CHECK_VER_OFF");
}
}
/**
* disableTodo : function that's called via ajax when
*
* the user clicks to disable showing the Todo Instructions in the
*
* main Staff Master Control Panel
*
*/
function disableTodo( ) {
$db =& JFactory::getDBO();
$query_todo = "UPDATE #__staff_settings "
. "SET show_todo = 0 "
. "WHERE id = 1 ";
$db->setQuery( $query_todo );
$db->query();
}
/**
* loadFile : loads a file with proper language code via javascript
*
*/
function loadFile() {
//$lang_prefix = JLanguageHelper::detectLanguage();
$lang_prefix = 'en-GB';
jimport('joomla.filesystem.file');
$file = JRequest::getVar( 'file' );
$filename = JPATH_COMPONENT . DS . 'files' . DS . $lang_prefix . DS . $file . '.html.php';
echo JFile::read( $filename );
}
}
?>