Fixed populating created_by for user created by admin.
authorNik Okuntseff <support@anuko.com>
Fri, 9 Nov 2018 17:36:29 +0000 (17:36 +0000)
committerNik Okuntseff <support@anuko.com>
Fri, 9 Nov 2018 17:36:29 +0000 (17:36 +0000)
WEB-INF/lib/ttRegistrator.class.php
WEB-INF/templates/footer.tpl
admin_group_add.php

index 44841f5..c206881 100644 (file)
@@ -86,7 +86,7 @@ class ttRegistrator {
     global $i18n;
     global $user;
 
-    // Protection fom too many recent bot registrations from user IP.
+    // Protection from too many recent bot registrations from user IP.
     if (!$user->can('administer_site')) { // No problems for site admin.
       if ($this->registeredRecently()) {
         $this->err->add($i18n->get('error.access_denied'));
@@ -121,7 +121,9 @@ class ttRegistrator {
       return false;
     }
 
-    if (!$this->setCreatedBy($this->user_id))
+    // Set created_by appropriately (admin or self).
+    $created_by = $user->can('administer_site') ? $user->id : $this->user_id;
+    if (!$this->setCreatedBy($created_by))
       return false;
 
     return true;
@@ -189,7 +191,7 @@ class ttRegistrator {
     }
 
     // Update top manager.
-    $sql = "update tt_users set created_by = $user_id where id = $user_id and group_id = $this->group_id";
+    $sql = "update tt_users set created_by = $user_id where id = $this->user_id and group_id = $this->group_id";
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error')) {
       $this->err->add($i18n->get('error.db'));
index 848425e..67fbea4 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.12.4396 | 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.12.4397 | 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 21570a9..71dde8a 100644 (file)
@@ -106,7 +106,8 @@ if ($request->isPost()) {
   import('ttRegistrator');
   $registrator = new ttRegistrator($fields, $err);
   $registrator->register();
-  $registrator->setCreatedBy($user->id); // Override created_by to admin account.
+  // $registrator->setCreatedBy($user->id); // Override created_by to admin account.
+  // TODO: redo ttRegistrator class by passing in created_by_id in $fields to keep code straightforward.
   if ($err->no()) {
     header('Location: admin_groups.php');
     exit();