]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttRoleHelper.class.php
Ongoing refactoring on decoupling import.
[timetracker.git] / WEB-INF / lib / ttRoleHelper.class.php
index 35374469932c15b7a8a2a3732fb70e93477a1aae..0686b1cdf78b98739f7604ccdca36279e631fca4 100644 (file)
@@ -156,10 +156,11 @@ class ttRoleHelper {
   // insert - inserts an entry into tt_roles table.
   static function insert($fields)
   {
+    global $user;
     $mdb2 = getConnection();
 
-    $group_id = (int) $fields['group_id'];
-    $org_id = (int) $fields['org_id'];
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
     $name = $fields['name'];
     $rank = (int) $fields['rank'];
     $description = $fields['description'];
@@ -172,10 +173,7 @@ class ttRoleHelper {
     if (is_a($affected, 'PEAR_Error'))
       return false;
 
-    $sql = "SELECT LAST_INSERT_ID() AS last_id";
-    $res = $mdb2->query($sql);
-    $val = $res->fetchRow();
-    $last_id = $val['last_id'];
+    $last_id = $mdb2->lastInsertID('tt_roles', 'id');
     return $last_id;
   }