}
return false;
}
+
+ // migrateLegacyRole makes changes to user database record and assigns a user to
+ // one of pre-defined roles, which are created if necessary.
+ // No changes to $this instance are done.
+ function migrateLegacyRole() {
+ // Do nothing if we already have a role_id.
+ if ($this->role_id) return false;
+
+ // Create default roles if necessary.
+ import ('ttRoleHelper');
+ if (!ttRoleHelper::rolesExist()) ttRoleHelper::createDefaultRoles(); // TODO: refactor or remove after roles revamp.
+
+ // Obtain new role id based on legacy role.
+ $role_id = ttRoleHelper::getRoleByRank($this->role);
+ if (!$role_id) return false; // Role not found, nothing to do.
+
+ $mdb2 = getConnection();
+ $sql = "update tt_users set role_id = $role_id where id = $this->id and team_id = $this->team_id";
+ $affected = $mdb2->exec($sql);
+ if (is_a($affected, 'PEAR_Error'))
+ return false;
+
+ return true;
+ }
}
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.37.4053 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.37.4054 | Copyright © <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>
// Create an instance of ttUser class. This gets us most of user details.
import('ttUser');
$user = new ttUser(null, $auth->getUserId());
+// Temporary code to assign role_id to users who don't yet have it.
+if ($user->login && !$user->role_id) {
+ $user->migrateLegacyRole();
+ // Recycle User object, now with proper role_id.
+ $user = new ttUser(null, $auth->getUserId());
+}
if ($user->custom_logo) {
$smarty->assign('custom_logo', 'images/'.$user->team_id.'.png');
$smarty->assign('mobile_custom_logo', '../images/'.$user->team_id.'.png');
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','value'=>$cl_email));
$active_roles = ttTeamHelper::getActiveRolesForUser();
-//$roles[ROLE_USER] = $i18n->getKey('label.user');
-//$roles[ROLE_COMANAGER] = $i18n->getKey('form.users.comanager');
-//if ($user->isPluginEnabled('cl'))
-// $roles[ROLE_CLIENT] = $i18n->getKey('label.client');
$form->addInput(array('type'=>'combobox','onchange'=>'handleClientControl()','name'=>'role','value'=>$cl_role,'data'=>$active_roles,'datakeys'=>array('id', 'name')));
if ($user->isPluginEnabled('cl'))
$form->addInput(array('type'=>'combobox','name'=>'client','value'=>$cl_client_id,'data'=>$clients,'datakeys'=>array('id', 'name'),'empty'=>array(''=>$i18n->getKey('dropdown.select'))));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','style'=>'width: 300px;','value'=>$cl_email));
$active_roles = ttTeamHelper::getActiveRolesForUser();
-//$roles[ROLE_USER] = $i18n->getKey('label.user');
-//$roles[ROLE_COMANAGER] = $i18n->getKey('form.users.comanager');
-//if ($user->isPluginEnabled('cl'))
-// $roles[ROLE_CLIENT] = $i18n->getKey('label.client');
$form->addInput(array('type'=>'combobox','onchange'=>'handleClientControl()','name'=>'role','value'=>$cl_role,'data'=>$active_roles, 'datakeys'=>array('id', 'name')));
if ($user->isPluginEnabled('cl'))
$form->addInput(array('type'=>'combobox','name'=>'client','value'=>$cl_client_id,'data'=>$clients,'datakeys'=>array('id', 'name'),'empty'=>array(''=>$i18n->getKey('dropdown.select'))));