A bit more work in progress on roles.
authorNik Okuntseff <support@anuko.com>
Mon, 26 Feb 2018 22:24:10 +0000 (22:24 +0000)
committerNik Okuntseff <support@anuko.com>
Mon, 26 Feb 2018 22:24:10 +0000 (22:24 +0000)
WEB-INF/templates/footer.tpl
WEB-INF/templates/role_edit.tpl
role_add.php
role_edit.php

index 0589a0c..a3b7707 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.17.32.4030 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.32.4031 | 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 6ba4ddc..3ad9e6c 100644 (file)
           <td align = "right">{$i18n.label.description}:</td>
           <td>{$forms.roleForm.description.control}</td>
         </tr>
+        <tr>
+          <td align = "right">{$i18n.form.roles.rank}:</td>
+          <td>{$forms.roleForm.rank.control} <a href="https://www.anuko.com/lp/tt_20.htm" target="_blank">{$i18n.label.what_is_it}</a></td>
+        </tr>
         <tr>
           <td align = "right">{$i18n.label.status}:</td>
           <td>{$forms.roleForm.status.control}</td>
index 7122008..b44304b 100644 (file)
@@ -61,12 +61,13 @@ if ($request->isPost()) {
   if ($err->no()) {
     $existing_role = ttRoleHelper::getRoleByRank($cl_rank);
     if (!$existing_role) {
-        // Update role information.
+        // Insert a role with default user rights.
         if (ttRoleHelper::insert(array(
           'team_id' => $user->team_id,
           'name' => $cl_name,
           'rank' => $cl_rank,
           'description' => $cl_description,
+          'rights' => 'data_entry,view_own_data,manage_own_settings,view_users', // Default user rights.
           'status' => ACTIVE))) {
           header('Location: roles.php');
           exit();
index 21ed258..b665e6d 100644 (file)
@@ -49,10 +49,12 @@ $available_rights = array_diff($user->rights_array, $assigned_rights);
 if ($request->isPost()) {
   $cl_name = trim($request->getParameter('name'));
   $cl_description = trim($request->getParameter('description'));
+  $cl_rank = $request->getParameter('rank');
   $cl_status = $request->getParameter('status');
 } else {
   $cl_name = $role['name'];
   $cl_description = $role['description'];
+  $cl_rank = $role['rank'];
   $cl_status = $role['status'];
 }
 
@@ -60,6 +62,14 @@ $form = new Form('roleForm');
 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_role_id));
 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','style'=>'width: 250px;','value'=>$cl_name));
 $form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description));
+for ($i = 0; $i < $user->role; $i++) {
+  $existing_role_name = null;
+  $rank_data[] = $i;
+}
+$form->addInput(array('type'=>'combobox','name'=>'rank','data'=>$rank_data,'value'=>$cl_rank));
+$form->addInput(array('type'=>'combobox','name'=>'status','value'=>$cl_status,
+  'data'=>array(ACTIVE=>$i18n->getKey('dropdown.status_active'),INACTIVE=>$i18n->getKey('dropdown.status_inactive'))));
+$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
 
 // Multiple select controls for assigned and available rights.
 $form->addInput(array('type'=>'combobox','name'=>'assigned_rights','style'=>'width: 250px;','multiple'=>true,'data'=>$assigned_rights));
@@ -67,11 +77,6 @@ $form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getK
 $form->addInput(array('type'=>'combobox','name'=>'available_rights','style'=>'width: 250px;','multiple'=>true,'data'=>$available_rights));
 $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
 
-
-$form->addInput(array('type'=>'combobox','name'=>'status','value'=>$cl_status,
-  'data'=>array(ACTIVE=>$i18n->getKey('dropdown.status_active'),INACTIVE=>$i18n->getKey('dropdown.status_inactive'))));
-$form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
-
 if ($request->isPost()) {
     if ($request->getParameter('btn_save')) {
     // Validate user input.