]> wagnertech.de Git - timetracker.git/commitdiff
Refactored ttNotificationHelper class for subgroups.
authorNik Okuntseff <support@anuko.com>
Fri, 7 Dec 2018 17:48:04 +0000 (17:48 +0000)
committerNik Okuntseff <support@anuko.com>
Fri, 7 Dec 2018 17:48:04 +0000 (17:48 +0000)
WEB-INF/lib/ttGroupHelper.class.php
WEB-INF/lib/ttNotificationHelper.class.php
WEB-INF/lib/ttTeamHelper.class.php
WEB-INF/templates/footer.tpl
notification_edit.php
notifications.php

index 3ae408af9889111a5cf20a16763bfb537ceb3c6c..4ba7805e462293e82585972adbac92e473abca34 100644 (file)
@@ -423,4 +423,27 @@ class ttGroupHelper {
     }
     return $result;
   }
+
+  // getNotifications - obtains notification descriptions for a group.
+  static function getNotifications() {
+    global $user;
+    $mdb2 = getConnection();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
+    $result = array();
+    $sql = "select c.id, c.cron_spec, c.email, c.report_condition, fr.name from tt_cron c".
+      " left join tt_fav_reports fr on (fr.id = c.report_id)".
+      " where c.group_id = $group_id and c.org_id = $org_id and c.status = 1 and fr.status = 1";
+    $res = $mdb2->query($sql);
+    $result = array();
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $result[] = $val;
+      }
+      return $result;
+    }
+    return false;
+  }
 }
index c9f0a1e9c364677bfb89ff96dc0c34889d240815..8e5cb8affa9c7a2df7596d8b96592a0152c6ca54 100644 (file)
 class ttNotificationHelper {
        
   // get - gets notification details. 
-  static function get($id)
-  {
+  static function get($id) {
     global $user;
     $mdb2 = getConnection();
 
-    $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.cc, c.subject, c.report_condition, c.status, fr.name from tt_cron c
-      left join tt_fav_reports fr on (fr.id = c.report_id)
-      where c.id = $id and c.group_id = ".$user->getGroup();
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
+    $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.cc, c.subject, c.report_condition, c.status, fr.name from tt_cron c".
+      " left join tt_fav_reports fr on (fr.id = c.report_id)".
+      " where c.id = $id and c.group_id = $group_id and c.org_id = $org_id";
     $res = $mdb2->query($sql);
     if (!is_a($res, 'PEAR_Error')) {
       $val = $res->fetchRow();
@@ -51,25 +52,27 @@ class ttNotificationHelper {
   // delete - deletes a notification from tt_cron table. 
   static function delete($id) {
     global $user;
-           
     $mdb2 = getConnection();
-    
-    $sql = "delete from tt_cron where id = $id and group_id = ".$user->getGroup();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
+    $sql = "delete from tt_cron where id = $id and group_id = $group_id and org_id = $org_id";
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-       return true;
+    return true;
   }
   
   // insert function inserts a new notification into database.
-  static function insert($fields)
-  {
+  static function insert($fields) {
     global $user;
     $mdb2 = getConnection();
 
     $group_id = $user->getGroup();
     $org_id = $user->org_id;
+
     $cron_spec = $fields['cron_spec'];
     $next = (int) $fields['next'];
     $report_id = (int) $fields['report_id'];
@@ -89,12 +92,14 @@ class ttNotificationHelper {
   } 
   
   // update function - updates a notification in database.
-  static function update($fields)
-  {
+  static function update($fields) {
+    global $user;
     $mdb2 = getConnection();
-    
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
     $notification_id = (int) $fields['id'];
-    $group_id = (int) $fields['group_id'];
     $cron_spec = $fields['cron_spec'];
     $next = (int) $fields['next'];
     $report_id = (int) $fields['report_id'];
@@ -104,8 +109,11 @@ class ttNotificationHelper {
     $report_condition = $fields['report_condition'];
     $status = $fields['status'];
     
-    $sql = "update tt_cron set cron_spec = ".$mdb2->quote($cron_spec).", next = $next, report_id = $report_id, email = ".$mdb2->quote($email).", cc = ".$mdb2->quote($cc).", subject = ".$mdb2->quote($subject).", report_condition = ".$mdb2->quote($report_condition).", status = ".$mdb2->quote($status).
-      " where id = $notification_id and group_id = $group_id";
+    $sql = "update tt_cron".
+      " set cron_spec = ".$mdb2->quote($cron_spec).", next = $next, report_id = $report_id".
+      ",  email = ".$mdb2->quote($email).", cc = ".$mdb2->quote($cc).", subject = ".$mdb2->quote($subject).
+      ", report_condition = ".$mdb2->quote($report_condition).", status = ".$mdb2->quote($status).
+      " where id = $notification_id and group_id = $group_id and org_id = $org_id";
     $affected = $mdb2->exec($sql);
     return (!is_a($affected, 'PEAR_Error'));
   }
index 16896ac58104301232a9610845653ebf96404bf1..cf455405bbd5b97ca0407d348d0a1c93826b597e 100644 (file)
@@ -508,25 +508,6 @@ class ttTeamHelper {
     return false;
   }
 
-  // getNotifications - obtains notification descriptions for a group.
-  static function getNotifications($group_id) {
-    $mdb2 = getConnection();
-
-    $result = array();
-    $sql = "select c.id, c.cron_spec, c.email, c.report_condition, fr.name from tt_cron c
-      left join tt_fav_reports fr on (fr.id = c.report_id)
-      where c.group_id = $group_id and c.status = 1 and fr.status = 1";
-    $res = $mdb2->query($sql);
-    $result = array();
-    if (!is_a($res, 'PEAR_Error')) {
-      while ($val = $res->fetchRow()) {
-        $result[] = $val;
-      }
-      return $result;
-    }
-    return false;
-  }
-
   // getMonthlyQuotas - obtains monthly quotas for a group.
   static function getMonthlyQuotas($group_id) {
     $mdb2 = getConnection();
index cd126f2c863198328607bc5cdd469ce560f2249a..bdd2fd617216f89b1540a8fa46d07af79069682e 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.29.4608 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.29.4609 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index 69535815dd6bdf316753bb409a154c305b29a62a..7442305a84c5a2236f02780834d0051414573225 100644 (file)
@@ -94,7 +94,6 @@ if ($request->isPost()) {
 
     if (ttNotificationHelper::update(array(
         'id' => $notification_id,
-        'group_id' => $user->group_id,
         'cron_spec' => $cl_cron_spec,
         'next' => $next,
         'report_id' => $cl_fav_report,
index 23400beb428aedb94687f0b25d24d84fb4f1ff6f..d70f5b48bdca2165614aea26918052d3c62f4318 100644 (file)
@@ -28,7 +28,7 @@
 
 require_once('initialize.php');
 import('form.Form');
-import('ttTeamHelper');
+import('ttGroupHelper');
 
 // Access checks.
 if (!ttAccessAllowed('manage_advanced_settings')) {
@@ -50,7 +50,7 @@ if ($request->isPost()) {
   }
 } else {
   $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add')));
-  $notifications = ttTeamHelper::getNotifications($user->group_id);
+  $notifications = ttGroupHelper::getNotifications();
 }
 
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));