Refactoring in ttAdmin class.
authorNik Okuntseff <support@anuko.com>
Wed, 28 Nov 2018 20:00:35 +0000 (20:00 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 28 Nov 2018 20:00:35 +0000 (20:00 +0000)
WEB-INF/lib/ttAdmin.class.php
WEB-INF/templates/footer.tpl
admin_group_delete.php

index 747274f..3b6b008 100644 (file)
@@ -344,7 +344,7 @@ class ttAdmin {
   }
 
   // getGroupDetails obtains group name and its top manager details.
-  function getGroupDetails($group_id) {
+  static function getGroupDetails($group_id) {
     $result = array();
     $mdb2 = getConnection();
 
index ae1e68c..0cafe7e 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.28.4534 | 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.28.4535 | 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 7c7df61..fea5736 100644 (file)
@@ -35,13 +35,13 @@ if (!ttAccessAllowed('administer_site')) {
   header('Location: access_denied.php');
   exit();
 }
-// End of access checks.
-
 $group_id = (int)$request->getParameter('id');
-
-$admin = new ttAdmin();
-$group_details = $admin->getGroupDetails($group_id);
-$group_name = $group_details['group_name'];
+$group_details = ttAdmin::getGroupDetails($group_id);
+if (!($group_id && $group_details)) {
+  header('Location: access_denied.php');
+  exit();
+}
+// End of access checks.
 
 $form = new Form('groupForm');
 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$group_id));
@@ -50,8 +50,7 @@ $form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get(
 
 if ($request->isPost()) {
   if ($request->getParameter('btn_delete')) {
-    $result = $admin->markGroupDeleted($group_id);
-    if ($result) {
+    if (ttAdmin::markGroupDeleted($group_id)) {
       header('Location: admin_groups.php');
       exit();
     } else
@@ -64,7 +63,7 @@ if ($request->isPost()) {
   }
 } // isPost
 
-$smarty->assign('group_to_delete', $group_name);
+$smarty->assign('group_to_delete', $group_details['group_name']);
 $smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('title', $i18n->get('title.delete_group'));
 $smarty->assign('content_page_name', 'admin_group_delete.tpl');