return ($this->behalfUser ? $this->behalfUser->id : $this->id);
}
+ // getName returns user name on behalf of whom the current user is operating.
+ function getName() {
+ return ($this->behalfUser ? $this->behalfUser->name : $this->name);
+ }
+
// getQuotaPercent returns quota percent for active user.
function getQuotaPercent() {
return ($this->behalfUser ? $this->behalfUser->quota_percent : $this->quota_percent);
$includeSelf = isset($options['include_self']);
$select_part = 'select u.id, u.group_id, u.name';
- if (isset($options['include_login'])) $select_part .= ', u.login';
+ if (isset($options['include_login'])) {
+ $select_part .= ', u.login';
+ // Piggy-back on include_login to see if we must also include quota_percent.
+ $include_quota = $this->isPluginEnabled('mq');
+ if ($include_quota) {
+ $decimal_mark = $this->getDecimalMark();
+ $replaceDecimalMark = ('.' != $decimal_mark);
+ $select_part .= ', u.quota_percent';
+ }
+ }
if (!isset($options['include_clients'])) $select_part .= ', r.rights';
if (isset($options['include_role'])) $select_part .= ', r.name as role_name, r.rank';
if ($isClient)
continue; // Skip adding clients.
}
+ if ($include_quota) {
+ $quota = $val['quota_percent'];
+ if (ttEndsWith($quota, '.00'))
+ $quota = substr($quota, 0, strlen($quota)-3); // Trim trailing ".00";
+ elseif ($replaceDecimalMark)
+ $quota = str_replace('.', $decimal_mark, $quota);
+ $val['quota_percent'] = $quota.'%';
+ }
$user_list[] = $val;
}
// then rank restriction does not apply.
$max_rank = $this->behalfGroup ? MAX_RANK : $this->rank;
- $sql = "select u.id, u.name, u.login, u.role_id, u.client_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.quota_percent, 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 = $group_id and u.org_id = $org_id and u.status is not null".
" and (r.rank < $max_rank or (r.rank = $max_rank and u.id = $this->id))"; // Users with lesser roles or self.
return false;
// So far, so good. Check user now.
- $options = array('group_id'=>$group_id,'status'=>ACTIVE,'max_rank'=>MAX_RANK);
+ $options = array('status'=>ACTIVE,'max_rank'=>MAX_RANK);
$users = $this->getUsers($options);
foreach($users as $one_user) {
if ($one_user['id'] == $this->behalf_id)
return false;
// Mark user as deleted.
- $sql = "update tt_users set status = NULL where id = $user_id".
+ $modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$mdb2->quote($this->id);
+ $sql = "update tt_users set status = null $modified_part where id = $user_id".
" and group_id = $group_id and org_id = $org_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))