Skip to content
Snippets Groups Projects
Commit 7c267cad authored by Peter Rotich's avatar Peter Rotich
Browse files

Add ability to set active sub-menu by href. Redo settings page/target handling

parent 3ffee52c
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ class StaffNav {
return (!$this->isAdminPanel());
}
function setTabActive($tab){
function setTabActive($tab, $menu=''){
if($this->tabs[$tab]){
$this->tabs[$tab]['active']=true;
......@@ -51,6 +51,7 @@ class StaffNav {
$this->tabs[$this->activetab]['active']=false;
$this->activetab=$tab;
if($menu) $this->setActiveSubMenu($menu, $tab);
return true;
}
......@@ -58,16 +59,25 @@ class StaffNav {
return false;
}
function setActiveTab($tab){
return $this->setTabActive($tab);
function setActiveTab($tab, $menu=''){
return $this->setTabActive($tab, $menu);
}
function getActiveTab(){
return $this->activetab;
}
function setActiveSubMenu($mid) {
$this->activeMenu = $mid;
function setActiveSubMenu($mid, $tab='') {
if(is_numeric($mid))
$this->activeMenu = $mid;
elseif($mid && $tab && ($subNav=$this->getSubNav($tab))) {
foreach($subNav as $k => $menu) {
if(strcasecmp($mid, $menu['href'])) continue;
$this->activeMenu = $k+1;
break;
}
}
}
function getActiveMenu() {
......@@ -183,12 +193,12 @@ class AdminNav extends StaffNav{
$subnav[]=array('desc'=>'System Logs','href'=>'logs.php','iconclass'=>'logs');
break;
case 'settings':
$subnav[]=array('desc'=>'System Preferences','href'=>'settings.php','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Tickets','href'=>'settings.php','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Emails','href'=>'settings.php','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Knowledgebase','href'=>'settings.php','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Autoresponder','href'=>'autoresponder.php','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Alerts Notices','href'=>'alerts.php','iconclass'=>'preferences');
$subnav[]=array('desc'=>'System Preferences','href'=>'settings.php?t=system','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Tickets','href'=>'settings.php?t=tickets','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Emails','href'=>'settings.php?t=emails','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Knowledgebase','href'=>'settings.php?t=kb','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Autoresponder','href'=>'settings.php?t=autoresp','iconclass'=>'preferences');
$subnav[]=array('desc'=>'Alerts & Notices','href'=>'settings.php?t=alerts','iconclass'=>'preferences');
break;
case 'manage':
$subnav[]=array('desc'=>'Help Topics','href'=>'helptopics.php','iconclass'=>'helpTopics');
......
......@@ -15,49 +15,28 @@
**********************************************************************/
require('admin.inc.php');
$errors=array();
$SettingOptions=array('general'=>'General Settings',
'dates'=>'Date and Time Options',
'tickets'=>'Ticket Settings and Options',
'emails'=>'Email Settings',
'attachments'=>'Attachments Settings',
'kb'=>'Knowledgebase Settings',
'autoresponders'=>'Autoresponder Settings',
'alerts'=>'Alerts and Notices Settings');
$settingOptions=array(
'system' => 'System Settings',
'tickets' => 'Ticket Settings and Options',
'emails' => 'Email Settings',
'kb' => 'Knowledgebase Settings',
'autoresp' => 'Autoresponder Settings',
'alerts' => 'Alerts and Notices Settings');
//Handle a POST.
if($_POST && !$errors){
$errors=array();
if($cfg && $cfg->updateSettings($_POST,$errors)){
$msg=Format::htmlchars($SettingOptions[$_POST['t']]).' Updated Successfully';
if($_POST && !$errors) {
if($cfg && $cfg->updateSettings($_POST,$errors)) {
$msg=Format::htmlchars($settingOptions[$_POST['t']]).' Updated Successfully';
$cfg->reload();
}elseif(!$errors['err']){
$errors['err']='Unable to update system settings - correct any errors below and try again';
} elseif(!$errors['err']) {
$errors['err']='Unable to update settings - correct errors below and try again';
}
}
$target=($_REQUEST['t'] && $SettingOptions[$_REQUEST['t']])?$_REQUEST['t']:'general';
$nav->setTabActive('settings');
require(STAFFINC_DIR.'header.inc.php');
?>
<h2>System Preferences and Settings - <span>osTicket (v<?php echo $cfg->getVersion(); ?>)</span></h2>
<div style="padding-top:10px;padding-bottom:5px;">
<form method="get" action="settings.php">
Setting Option:
<select id="setting_options" name="t" style="width:300px;">
<option value="">&mdash; Select Setting Group &mdash;</option>
<?php
foreach($SettingOptions as $k=>$v) {
$sel=($target==$k)?'selected="selected"':'';
echo sprintf('<option value="%s" %s>%s</option>',$k,$sel,$v);
}
?>
</select>
<input type="submit" value="Go">
</form>
</div>
<?php
$target=($_REQUEST['t'] && $settingOptions[$_REQUEST['t']])?$_REQUEST['t']:'system';
$config=($errors && $_POST)?Format::input($_POST):Format::htmlchars($cfg->getConfigInfo());
$nav->setTabActive('settings', ('settings.php?t='.$target));
require_once(STAFFINC_DIR.'header.inc.php');
include_once(STAFFINC_DIR."settings-$target.inc.php");
include_once(STAFFINC_DIR.'footer.inc.php');
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment