public static function getUpdateSqlParams($p) { $rez = parent::getUpdateSqlParams($p); $passIdx = array_search('password', $rez['fields']); if ($passIdx !== false) { $a = explode('=', $rez['assignments'][$passIdx]); $rez['assignments'][$passIdx] = $a[0] . '= MD5(CONCAT(\'aero\', ' . $a[1] . '))'; } return $rez; }
/** * covering code * @return void */ public function testCovering() { $rez = DM\UsersGroups::getAvailableGroups(); $this->assertTrue(!empty($rez), 'Empty groups'); $rez = DM\UsersGroups::getAvailableUsers(); $this->assertTrue(!empty($rez), 'Empty users'); $rez = DM\UsersGroups::getMemberGroupIds(1); $this->assertTrue(empty($rez), 'Empty member groups'); $rez = DM\UsersGroups::getGroupUserIds(2); $this->assertTrue(empty($rez), '!Empty group users for everyone'); $rez = DM\UsersGroups::getDisplayData(); $this->assertTrue(!empty($rez), 'Display data'); }
/** * Get the list of active users with basic data * @return array */ public static function getActiveUsers() { $rez = array('success' => true, 'data' => array()); // $photosPath = Config::get('photos_path'); $users = DM\UsersGroups::getAvailableUsers(); foreach ($users as $r) { $r['user'] = $r['name']; $r['name'] = User::getDisplayName($r); $r['photo'] = User::getPhotoParam($r); $rez['data'][] = $r; } return $rez; }
/** * get display data for given ids * @param varchar|array $ids * @return associative array of users display data */ public static function getDisplayData($ids) { $rez = array(); $ids = Util\toNumericArray($ids); if (!empty($ids)) { $cdd = array(); if (Cache::exist('UsersGroupsDisplayData')) { $cdd = Cache::get('UsersGroupsDisplayData'); } else { $cdd = DataModel\UsersGroups::getDisplayData(); Cache::set('UsersGroupsDisplayData', $cdd); } $rez = array_intersect_key($cdd, array_flip($ids)); } return $rez; }
/** * Get the child list to be displayed in user management window in left tree */ public function getChildren($p) { if (!User::isVerified()) { return array('success' => false, 'verify' => true); } $rez = array(); if (!Security::canManage()) { throw new \Exception(L\get('Access_denied')); } $path = explode('/', $p['path']); $id = array_pop($path); $nodeType = null; if (is_numeric($id)) { $r = DM\UsersGroups::read($id); if (!empty($r)) { $nodeType = $r['type']; } } // users out of a group if ($id == -1) { $res = DB\dbQuery('SELECT id ,u.cid ,name ,first_name ,last_name ,sex ,`enabled` FROM users_groups u LEFT JOIN users_groups_association a ON u.id = a.user_id WHERE u.`type` = 2 AND u.`system` = 0 AND u.did IS NULL AND a.group_id IS NULL ORDER BY 3, 2'); while ($r = $res->fetch_assoc()) { $r['loaded'] = true; $rez[] = $r; } $res->close(); } elseif (is_null($nodeType)) { /* root node childs*/ $res = DB\dbQuery('SELECT id ,name ,`type` ,`system` ,(SELECT count(*) FROM users_groups_association a JOIN users_groups u ON a.user_id = u.id AND u.did IS NULL WHERE group_id = g.id) `loaded` FROM users_groups g WHERE `type` = 1 AND `system` = 0 ORDER BY 3, 2'); while ($r = $res->fetch_assoc()) { $r['iconCls'] = 'icon-users'; $r['expanded'] = true; $r['loaded'] = empty($r['loaded']); $rez[] = $r; } $res->close(); $rez[] = array('nid' => -1, 'name' => L\get('Users_without_group'), 'iconCls' => 'icon-users', 'type' => 1, 'expanded' => true); } else { // group users $res = DB\dbQuery('SELECT u.id ,u.cid ,u.name ,first_name ,last_name ,sex ,enabled FROM users_groups_association a JOIN users_groups u ON a.user_id = u.id WHERE a.group_id = $1 AND u.did IS NULL ORDER BY 4, 5, 3', $id); while ($r = $res->fetch_assoc()) { $r['loaded'] = true; $rez[] = $r; } $res->close(); } /* collapse first and last names into title */ for ($i = 0; $i < sizeof($rez); $i++) { $rez[$i]['title'] = User::getDisplayName($rez[$i]); unset($rez[$i]['first_name']); unset($rez[$i]['last_name']); if (isset($rez[$i]['id'])) { $rez[$i]['nid'] = $rez[$i]['id']; unset($rez[$i]['id']); } } /* end of collapse first and last names into title */ return $rez; }