/** * Return a PN array strcuture for the PN user dropdown box. * * @param string $name The selector name. * @param integer $gid The group ID to get users for (optional) (default=null). * @param integer $selectedValue The currently selected value of the selector (optional) (default=0). * @param integer $defaultValue The default value of the selector (optional) (default=0). * @param string $defaultText The text of the default value (optional) (default=''). * @param integer $allValue The value to assign for the "All" choice (optional) (default=''). * @param string $allText The text to display for the "All" choice (optional) (default=''). * @param string $excludeList A (string) list of IDs to exclude (optional) (default=null). * @param boolean $submit Whether or not to auto-submit the selector (optional) (default=false). * @param boolean $disabled Whether or not to disable selector (optional) (default=false). * @param integer $multipleSize The size to use for a multiple selector, 1 produces a normal/single selector (optional (default=1). * * @return The string for the user group selector. */ public static function getSelector_User($name = 'userid', $gid = null, $selectedValue = 0, $defaultValue = 0, $defaultText = '', $allValue = 0, $allText = '', $excludeList = '', $submit = false, $disabled = false, $multipleSize = 1) { $where = ''; if ($excludeList) { $where = "WHERE uid NOT IN ({$excludeList})"; } if ($gid) { $users = UserUtil::getUsersForGroup($gid); if ($users) { $and = $where ? ' AND ' : ''; $where .= $and . 'uid IN (' . implode(',', $users) . ')'; } } $data = array(); $userlist = UserUtil::getUsers($where, 'ORDER BY uname'); foreach ($userlist as $k => $v) { $data[$k] = $v['uname']; } return self::getSelector_Generic($name, $data, $selectedValue, $defaultValue, $defaultText, $allValue, $allText, $submit, $disabled, $multipleSize); }
public function getForumsNews($args) { $result = array(); $dateTimeFrom = $args['dateTimeFrom']; $dateTimeTo = $args['dateTimeTo']; //Checking IWforums module $modinfo = ModUtil::getInfo(ModUtil::getIdFromName('IWforums')); if ($modinfo['state'] != 3) return $result; if ($modinfo['version'] >= '3.1.0') { $result = ModUtil::apiFunc('IWforums', 'user', 'getAllUnreadedMessages', array('dateTimeFrom' => $dateTimeFrom, 'dateTimeTo' => $dateTimeTo)); } else { $messages = array(); if (!is_null($dateTimeFrom)) { $pntable = DBUtil::getTables(); $f = $pntable['IWforums_definition_column']; $t = $pntable['IWforums_temes_column']; $m = $pntable['IWforums_msg_column']; // Get all the messages posted after $dateTimeFrom in subscribibles forums $sql = "SELECT F.$f[fid] AS fid, M.$m[ftid] AS ftid, M.$m[fmid] AS fmid, M.$m[titol] AS msgTitle, M.$m[usuari] AS user, M.$m[data] AS date, M.$m[llegit] AS readers, T.$t[titol] AS topic, T.$t[order], "; $sql .= "F.$f[nom_forum] AS forum, F.subscriptionMode, F.subscribers, F.noSubscribers, F.$f[grup] AS grup, F.$f[mod] AS moderators "; $sql .= "FROM `IWforums_msg` AS M, `IWforums_temes` AS T, `IWforums_definition` AS F "; $sql .= "WHERE M.$m[ftid] = T.$t[ftid] AND T.$t[fid] = F.$f[fid] AND F.$f[actiu] = 1 AND M.$m[data] >= ".$dateTimeFrom." AND M.$m[data] < ".$dateTimeTo." AND F.subscriptionMode > 0 "; $sql .= "ORDER BY F.$f[fid], T.$t[order], M.$m[data]"; $query = DBUtil::executeSQL($sql); $messages = DBUtil::marshallObjects($query); foreach ($messages as $key => $message) { // Extract forum moderators $moderators = explode('$$', substr($message['moderators'], 0, strlen($message['moderators']) -1)); unset($moderators[0]); //Extract message readers $readers = explode('$$', substr($message['readers'], 0, strlen($message['readers']) -1)); unset($readers[0]); // Extract grups $auxGroups = explode('$$', substr($message['grup'], 0, strlen($message['grup']) -1)); unset($auxGroups[0]); $groups = array(); foreach ($auxGroups as $ag){ $g = explode ('|', $ag); $groups[] = $g[0]; } // Construct a unique list with the users that have read access to a forum $members = array(); foreach ($groups as $group){ // Get group members $users = UserUtil::getUsersForGroup($group); foreach ($users as $user){ // Avoid duplicated users if (!in_array($user, $members)) $members[$user] = $user; } } // Add moderators foreach ($moderators as $moderator){ if (!in_array($moderator, $members)) $members[$moderator] = $moderator; } // Remove readers foreach ($readers as $reader) { if (in_array($reader, $members)) unset($members[$reader]); } $messages[$key]['receivers'] = $members; } // At this point, every message has a list of receivers // Let's construct an array with the associated information to send $information = array(); foreach ($messages as $message){ if (isset($message['receivers'])) { foreach($message['receivers'] as $receiver){ $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $information[$receiver][$message['fid']]['nom_forum'] = $message['forum']; $information[$receiver][$message['fid']]['subscriptionMode'] = $message['subscriptionMode']; $information[$receiver][$message['fid']]['fid'] = $message['fid']; $information[$receiver][$message['fid']]['topics'][$message['ftid']]['titol'] = $message['topic']; $information[$receiver][$message['fid']]['topics'][$message['ftid']]['messages'][$message['fmid']]['title'] = $message['msgTitle']; $information[$receiver][$message['fid']]['topics'][$message['ftid']]['messages'][$message['fmid']]['author'] = ModUtil::func('IWmain', 'user', 'getUserInfo', array('sv' => $sv, 'info' => 'ncc', 'uid' => $message['user'])); $information[$receiver][$message['fid']]['topics'][$message['ftid']]['messages'][$message['fmid']]['date'] = strtolower(DateUtil::getDatetime($message['date'], 'datetimelong', true)); } } } foreach ($information as $key => $userReport){ $view = Zikula_View::getInstance($this->name, false); $view->assign('info', $userReport); $result[$key]['IWforums'] = $view->fetch('reports/IWforums_user_report.tpl'); } } } return $result; }
/** * Funció per l'obtenció de la informació d'una entitat-gtaf * * > Obté un array amb la informació de l'entitat-gtaf * * @return array *gtafEntity* amb tota la informació de la entitat */ public function getGtafGroups($gtafgid) { $gtafInfo = array(); if (isset($gtafgid)){ $gtafInfo['group'] = DBUtil::selectObject('cataleg_gtafGroups','gtafGroupId="'.$gtafgid.'"'); } $gtafInfo['groups'] = DBUtil::selectFieldArray('cataleg_gtafGroups','gtafGroupId'); $grupsZikula = ModUtil::getVar("Cataleg", "grupsZikula"); $usercatlist = UserUtil::getUsersForGroup($grupsZikula['Sirius']); $users = UserUtil::getUsers('', 'uname', -1, -1, 'uid'); foreach ($users as $key => $user) { if (in_array($key, $usercatlist)) { $gtafInfo['catusers'][$key] = array('zk' => $user, 'iw' => DBUtil::selectObject('IWusers', 'where iw_uid =' . $key)); } } return $gtafInfo; }
/** * Gestiona-Informa dels usuaris d'un grup de zikula del catàleg * * > Retorna la informació de tots els membres del grup triat.\n * > Depenent del grup, permetrà la seva edició o només mostrarà la informació.\n * > Per als grups generals (Catàleg, Excatàleg, Personals, Genèrics) i pel grup Editors obtindrem la informació.\n * > El grup Gestors només podrà ser editat per el Gestor-Administrador. * * ### Paràmetres rebuts per GET: * * numeric **gid** gid del grup de zikula a gestionar. * * @return void Plantilla *Cataleg_admin_membersGroupview.tpl* o *Cataleg_admin_membersGroupgest.tpl* */ public function membersGroupgest() { //Comprovacions de seguretat. Només els gestors poden crear i editar usuaris if (!SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $gid = FormUtil::getPassedValue('gid', null, 'GET'); $grup = UserUtil::getGroup($gid); //Només es poden gestionar els membres dels grups del catàleg $grupsUnitats = ModUtil::getVar('Cataleg', 'grupsUnitats'); $grupsZikula = ModUtil::getVar('Cataleg', 'grupsZikula'); if (!in_array($gid, $grupsUnitats) && !in_array($gid, $grupsZikula)) { LogUtil::registerError($this->__('No es poden gestionar els membres del grup indicat.')); return system::redirect(ModUtil::url('Cataleg', 'admin', 'groupsgest')); } $users = UserUtil::getUsers('', 'uname', -1, -1, 'uid'); foreach ($users as $key => $user) { $users[$key]['iw'] = DBUtil::selectObject('IWusers', 'where iw_uid =' . $key); } $catUsersList = UserUtil::getUsersForGroup($grupsZikula['Sirius']); $groupUsersList = UserUtil::getUsersForGroup($gid); foreach ($users as $user) { if (in_array($user['uid'], $catUsersList)) { if (in_array($user['uid'], $groupUsersList)) { $usuaris[1][] = $user; } else { $usuaris[0][] = $user; } } else { if (in_array($user['uid'], $groupUsersList)) { $usuaris[2][] = $user; } } } $this->view->assign('usuaris', $usuaris); $this->view->assign('grup', $grup); if ((!SecurityUtil::checkPermission('CatalegAdmin::', '::', ACCESS_ADMIN) && $gid == $grupsZikula['Gestors']) || $gid == $grupsZikula['UNI'] || $gid == $grupsZikula['ST'] || $gid == $grupsZikula['SE'] || $gid == $grupsZikula['Gestform'] || $gid == $grupsZikula['LectorsCat'] || $gid == $grupsZikula['EditorsCat'] || $gid == $grupsZikula['Personals'] || $gid == $grupsZikula['Generics'] || $gid == $grupsZikula['Sirius'] || $gid == $grupsZikula['ExSirius']) { return $this->view->fetch('admin/Cataleg_admin_membersGroupview.tpl'); } else { return $this->view->fetch('admin/Cataleg_admin_membersGroupgest.tpl'); } }
/** * Find users. * * Parameters passed in the $args array: * ------------------------------------- * string $args['uname'] A fragment of a user name on which to search using an SQL * LIKE clause. The user name will be surrounded by wildcards. * int $args['ugroup'] A group id in which to search (only users who are members of * the specified group are returned). * string $args['email'] A fragment of an e-mail address on which to search using an * SQL LIKE clause. The e-mail address will be surrounded by * wildcards. * string $args['regdateafter'] An SQL date-time (in the form '1970-01-01 00:00:00'); only * user accounts with a registration date after the date * specified will be returned. * string $args['regdatebefore'] An SQL date-time (in the form '1970-01-01 00:00:00'); only * user accounts with a registration date before the date * specified will be returned. * array $args['dynadata'] An array of search values to be passed to the designated * profile module. Only those user records also satisfying the * profile module's search of its data are returned. * string $args['condition'] An SQL condition for finding users; overrides all other * parameters. * * @param array $args All parameters passed to this function. * * @return mixed array of items if succcessful, false otherwise */ public function findUsers($args) { // Need read access to call this function if (!SecurityUtil::checkPermission("{$this->name}::", '::', ACCESS_READ)) { return false; } $profileModule = System::getVar('profilemodule', ''); $useProfileMod = (!empty($profileModule) && ModUtil::available($profileModule)); $dbtable = DBUtil::getTables(); $userstable = $dbtable['users']; $userscolumn = $dbtable['users_column']; // Set query conditions (unless some one else sends a hardcoded one) $where = array(); if (!isset($args['condition']) || !$args['condition']) { // Do not include anonymous user $where[] = "({$userscolumn['uid']} != 1)"; foreach ($args as $arg => $value) { if ($value) { switch ($arg) { case 'uname': // Fall through to next on purpose--no break case 'email': $where[] = "({$userscolumn[$arg]} LIKE '%".DataUtil::formatForStore($value)."%')"; break; case 'ugroup': $uidList = UserUtil::getUsersForGroup($value); if (is_array($uidList) && !empty($uidList)) { $where[] = "({$userscolumn['uid']} IN (" . implode(', ', $uidList) . "))"; } break; case 'regdateafter': $where[] = "({$userscolumn['user_regdate']} > '" . DataUtil::formatForStore($value) . "')"; break; case 'regdatebefore': $where[] = "({$userscolumn['user_regdate']} < '" . DataUtil::formatForStore($value) . "')"; break; case 'dynadata': if ($useProfileMod) { $uidList = ModUtil::apiFunc($profileModule, 'user', 'searchDynadata', array( 'dynadata' => $value )); if (is_array($uidList) && !empty($uidList)) { $where[] = "({$userscolumn['uid']} IN (" . implode(', ', $uidList) . "))"; } } break; default: // Skip unknown values--do nothing, and no error--might be other legitimate arguments. } } } } // TODO - Should this exclude pending delete too? $where[] = "({$userscolumn['activated']} != " . Users_Constant::ACTIVATED_PENDING_REG . ")"; $where = 'WHERE ' . implode(' AND ', $where); $permFilter = array(); $permFilter[] = array( 'realm' => 0, 'component_left' => $this->name, 'component_middle' => '', 'component_right' => '', 'instance_left' => 'uname', 'instance_middle' => '', 'instance_right' => 'uid', 'level' => ACCESS_READ, ); $objArray = DBUtil::selectObjectArray('users', $where, 'uname', null, null, null, $permFilter); return $objArray; }