X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttUser.class.php;h=36d7136333cb0bb3684ef943e203929712539e60;hb=2bd9983978cf8d6263e27a531aeb33f365667e37;hp=2560417f82b55d054faeb174d381db7e519696bb;hpb=3d6b6fb758fd7e0befbdd497013d33264b9111e5;p=timetracker.git diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index 2560417f..36d71363 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -150,20 +150,6 @@ class ttUser { return in_array($do_something, $this->rights); } - // isManager - determines whether current user is group manager. - // This is a legacy function that we are getting rid of by replacing with rights check. - function isManager() { - return $this->can('export_data'); // By default this is assigned to managers but not co-managers. - // Which is sufficient for now until we refactor all calls - // to this function and then remove it. - } - - // isCoManager - determines whether current user is group comanager. - // This is a legacy function that we are getting rid of by replacing with rights check. - function isCoManager() { - return ($this->can('manage_users') && !$this->can('export_data')); - } - // isClient - determines whether current user is a client. function isClient() { return $this->is_client; @@ -367,7 +353,7 @@ class ttUser { $mdb2 = getConnection(); - $sql = "select u.id, u.name, u.login, u.role_id, u.status, u.rate, u.email from tt_users u". + $sql = "select u.id, u.name, u.login, u.role_id, u.client_id, u.status, u.rate, u.email from tt_users u". " left join tt_roles r on (u.role_id = r.id)". " where u.id = $user_id and u.group_id = $this->group_id and u.status is not null". " and (r.rank < $this->rank or (r.rank = $this->rank and u.id = $this->id))"; // Users with lesser roles or self. @@ -451,6 +437,38 @@ class ttUser { return true; } + // markUserDeleted marks a user in group as deleted. + function markUserDeleted($user_id) { + if (!$this->can('manage_users') || $this->id == $user_id) + return false; + + // Make sure we operate on a legit user. + $user_details = $this->getUser($user_id); + if (!$user_details) return false; + + $mdb2 = getConnection(); + + // Mark user to project binds as deleted. + $sql = "update tt_user_project_binds set status = NULL where user_id = $user_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + return false; + + // Mark user favorite reports as deleted. + $sql = "update tt_fav_reports set status = NULL where user_id = $user_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + return false; + + // Mark user as deleted. + $sql = "update tt_users set status = NULL where id = $user_id and group_id = ".$this->group_id; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + return false; + + return true; + } + // enablePlugin either enables or disables a specific plugin for group. function enablePlugin($plugin, $enable = true) {