From a4819191603aadeee183b9d5bc17c0a4297f08d5 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Sun, 16 Dec 2012 12:02:35 -0500
Subject: [PATCH] Add system notification bar - admin/staff panel warnings

---
 include/class.osticket.php   | 34 ++++++++++++++++++++--------------
 include/staff/header.inc.php |  8 ++++++++
 scp/admin.inc.php            |  4 ++++
 scp/css/scp.css              | 10 ++++++++--
 scp/staff.inc.php            |  3 ++-
 scp/tickets.php              |  4 ++--
 6 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/include/class.osticket.php b/include/class.osticket.php
index bef678239..fd300184a 100644
--- a/include/class.osticket.php
+++ b/include/class.osticket.php
@@ -26,7 +26,16 @@ define('LOG_WARN',LOG_WARNING);
 class osTicket {
 
     var $loglevel=array(1=>'Error','Warning','Debug');
+    
+    //Page errors.
     var $errors;
+
+    //System 
+    var $system;
+
+
+
+
     var $warning;
     var $message;
 
@@ -187,18 +196,15 @@ class osTicket {
     }
 
     function setErrors($errors) {
-        if(!is_array($errors))
-            return  $this->setError($errors);
-
         $this->errors = $errors;
     }
 
     function getError() {
-        return $this->errors['err'];
+        return $this->system['err'];
     }
 
     function setError($error) {
-        $this->errors['err'] = $error;
+        $this->system['error'] = $error;
     }
 
     function clearError() {
@@ -206,11 +212,11 @@ class osTicket {
     }
 
     function getWarning() {
-        return $this->warning;
+        return $this->system['warning'];
     }
 
-    function setWarning($warn) {
-        $this->warning = $warn;
+    function setWarning($warning) {
+        $this->system['warning'] = $warning;
     }
 
     function clearWarning() {
@@ -218,16 +224,16 @@ class osTicket {
     }
 
 
-    function getMessage() {
-        return $this->message;
+    function getNotice() {
+        return $this->system['notice'];
     }
 
-    function setMessage($msg) {
-        $this->message = $msg;
+    function setNotice($notice) {
+        $this->system['notice'] = $notice;
     }
 
-    function clearMessage() {
-        $this->setMessage('');
+    function clearNotice() {
+        $this->setNotice('');
     }
 
 
diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php
index a349cb3c6..8475f3286 100644
--- a/include/staff/header.inc.php
+++ b/include/staff/header.inc.php
@@ -31,6 +31,14 @@
 </head>
 <body>
 <div id="container">
+    <?php
+    if($ost->getError())
+        echo sprintf('<div id="error_bar">%s</div>', $ost->getError());
+    elseif($ost->getWarning())
+        echo sprintf('<div id="warning_bar">%s</div>', $ost->getWarning());
+    elseif($ost->getNotice())
+        echo sprintf('<div id="notice_bar">%s</div>', $ost->getNotice());
+    ?>
     <div id="header">
         <a href="index.php" id="logo">osTicket - Customer Support System</a>
         <p id="info">Howdy, <strong><?php echo $thisstaff->getUserName(); ?></strong>
diff --git a/scp/admin.inc.php b/scp/admin.inc.php
index 8a41c54db..66fca5d97 100644
--- a/scp/admin.inc.php
+++ b/scp/admin.inc.php
@@ -25,6 +25,7 @@ define('OSTADMININC',TRUE); //checked by admin include files
 define('ADMINPAGE',TRUE);   //Used by the header to swap menus.
 
 //Some security related warnings - bitch until fixed!!! :)
+$sysnotice= '';
 if($ost->isUpgradePending()) {
     $errors['err']=$sysnotice='System upgrade is pending <a href="upgrade.php">Upgrade Now</a>';
     if(!in_array(basename($_SERVER['SCRIPT_NAME']), array('upgrade.php', 'logs.php'))) {
@@ -57,6 +58,9 @@ if($ost->isUpgradePending()) {
         $sysnotice='Please consider turning off register globals if possible';
 }
 
+//System notice displayed as a warning (if any).
+$ost->setWarning($sysnotice);
+
 //Admin navigation - overwrites what was set in staff.inc.php
 $nav = new AdminNav($thisstaff);
 
diff --git a/scp/css/scp.css b/scp/css/scp.css
index c345799ba..04bd90d60 100644
--- a/scp/css/scp.css
+++ b/scp/css/scp.css
@@ -43,12 +43,18 @@ a {
     color: #555;
 }
 
-#msg_notice { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; margin-bottom: 10px; border: 1px solid #0a0; background: url('../images/icons/ok.png?1300763726') 10px 50% no-repeat #e0ffe0; }
+#msg_notice { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; margin-bottom: 10px; border: 1px solid #0a0; background: url('../images/icons/ok.png') 10px 50% no-repeat #e0ffe0; }
 
-#msg_warning { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; margin-bottom: 10px; border: 1px solid #f26522; background: url('../images/icons/alert.png?1307823786') 10px 50% no-repeat #ffffdd; }
+#msg_warning { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; margin-bottom: 10px; border: 1px solid #f26522; background: url('../images/icons/alert.png') 10px 50% no-repeat #ffffdd; }
 
 #msg_error { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; margin-bottom: 10px; border: 1px solid #a00; background: url('../images/icons/error.png') 10px 50% no-repeat #fff0f0; }
 
+#notice_bar { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; border: 1px solid #0a0; background: url('../images/icons/ok.png') 10px 50% no-repeat #e0ffe0; }
+
+#warning_bar { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; border: 1px solid #f26522; background: url('../images/icons/alert.png') 10px 50% no-repeat #ffffdd; }
+
+#error_bar { margin: 0; padding: 5px 10px 5px 36px; height: 16px; line-height: 16px; border: 1px solid #a00; background: url('../images/icons/error.png') 10px 50% no-repeat #fff0f0; }
+
 
 #container {
     width:960px;
diff --git a/scp/staff.inc.php b/scp/staff.inc.php
index 8553a8bac..8a91e4774 100644
--- a/scp/staff.inc.php
+++ b/scp/staff.inc.php
@@ -119,10 +119,11 @@ $nav = new StaffNav($thisstaff);
 if($thisstaff->forcePasswdChange() && !$exempt) {
     # XXX: Call staffLoginPage() for AJAX and API requests _not_ to honor
     #      the request
+    $sysnotice = 'Password change required to continue';
     require('profile.php'); //profile.php must request this file as require_once to avoid problems.
     exit;
 }
-
+$ost->setWarning($sysnotice);
 $ost->setPageTitle('osTicket :: Staff Control Panel');
 
 ?>
diff --git a/scp/tickets.php b/scp/tickets.php
index 47395d592..32c1cab50 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -470,8 +470,8 @@ if($cfg->showAnsweredTickets()) {
 }
 
 if($stats['assigned']) {
-    if(!$sysnotice && $stats['assigned']>10)
-        $sysnotice=$stats['assigned'].' assigned to you!';
+    if(!$ost->getWarning() && $stats['assigned']>3)
+        $ost->setWarning($stats['assigned'].' tickets assigned to you! Do something about it!');
 
     $nav->addSubMenu(array('desc'=>'My Tickets ('.$stats['assigned'].')',
                            'title'=>'Assigned Tickets',
-- 
GitLab