<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.17.44.4078 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.17.44.4079 | 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>
require_once('initialize.php');
import('ttUserHelper');
import('ttTaskHelper');
+import('ttUser');
// setChange - executes an sql statement. TODO: rename this function to something better.
// Better yet, redo the entire thing and make an installer.
setChange("UPDATE `tt_site_config` SET `param_value` = '1.17.44' where param_name = 'version_db'");
}
+ // The update_role_id function assigns a role_id to users, who don't have it.
+ if ($_POST['update_role_id']) {
+ import('I18n');
+
+ $mdb2 = getConnection();
+
+ $sql = "select u.id, u.status from tt_users u inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.44') where u.role_id is NULL and u.status is NOT NULL";
+ $res = $mdb2->query($sql);
+ if (is_a($res, 'PEAR_Error')) {
+ die($res->getMessage());
+ }
+
+ $users_updated = 0;
+ // Iterate through users.
+ while ($val = $res->fetchRow()) {
+
+ $user_id = $val['id'];
+
+ // Code only works on active users. Temporarily activate a user.
+ $deactivate = false;
+ if ($val['status'] == 0) {
+ $deactivate = true; // To deactivate later.
+ $sql = "update tt_users set status = 1 where id = $user_id";
+ $mdb2->exec($sql);
+ }
+
+ $user = new ttUser(null, $user_id);
+ $i18n = new I18n();
+ $i18n->load($val['lang']);
+ if ($user->login)
+ $user->migrateLegacyRole();
+
+ if ($deactivate) {
+ // Deactivate temporarily activated user back.
+ $sql = "update tt_users set status = 0 where id = $user_id";
+ $mdb2->exec($sql);
+ }
+
+ unset($user);
+ unset($i18n);
+ $users_updated++;
+ // if ($users_updated >= 1000) break; // TODO: uncomment for large user sets to run multiple times.
+ }
+ print "Updated $users_updated users...<br>\n";
+ }
+
if ($_POST["cleanup"]) {
$mdb2 = getConnection();
</tr>
<tr valign="top">
<td>Update database structure (v1.14 to v1.17.44)</td>
- <td><input type="submit" name="convert11400to11744" value="Update"><br></td>
+ <td><input type="submit" name="convert11400to11744" value="Update"><br><input type="submit" name="update_role_id" value="Update role_id"></td>
</tr>
</table>
// Elements of weekTimeForm.
$form = new Form('weekTimeForm');
-if ($user->canManageTeam()) {
+if ($user->can('track_time')) {
$user_list = ttTeamHelper::getActiveUsers(array('putSelfFirst'=>true));
if (count($user_list) > 1) {
$form->addInput(array('type'=>'combobox',
}
}
elseif ($request->getParameter('onBehalfUser')) {
- if($user->canManageTeam()) {
+ if($user->can('track_time')) {
unset($_SESSION['behalf_id']);
unset($_SESSION['behalf_name']);