/** * Show a form for some user configurable parameters * @author Albert Pérez Monfort (aperezm@xtec.cat) * @return: Show the form with the configurable parameters */ public function main() { // Security check if (!SecurityUtil::checkPermission('IWmain::', "::", ACCESS_READ) || !UserUtil::isLoggedIn()) { throw new Zikula_Exception_Forbidden(); } $uid = UserUtil::getVar('uid'); $crAc_UserReports =$this->getVar('crAc_UserReports'); $everybodySubscribed = $this->getVar('everybodySubscribed'); $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $blockFlaggedDetails = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'blockFlaggedDetails', 'module' => 'IWmain_block_news', 'uid' => $uid, 'sv' => $sv)); //get the headlines saved in the user vars. It is renovate every 10 minutes $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $subscribeNews = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'subscribeNews', 'module' => 'IWmain_cron', 'uid' => $uid, 'sv' => $sv)); //get user mail $userInfo = UserUtil::getVars($uid); $userMail = $userInfo['email']; return $this->view->assign('cronNotWorks', $cronNotWorks) ->assign('blockFlaggedDetails', $blockFlaggedDetails) ->assign('subscribeNews', $subscribeNews) ->assign('userMail', $userMail) ->assign('everybodySubscribed', $everybodySubscribed) ->assign('crAc_UserReports', $crAc_UserReports) ->fetch('IWmain_user_main.tpl'); }
public function getResponse(Request $request) { $admin = \UserUtil::getVars(2); if ($this->sendEmailToAdmin($request, $admin)) { $request->getSession()->getFlashBag()->add('success', __('Congratulations! Zikula has been successfully installed.')); return new RedirectResponse($this->container->get('router')->generate('zikulaadminmodule_admin_adminpanel', array(), RouterInterface::ABSOLUTE_URL)); } else { $request->getSession()->getFlashBag()->add('warning', __('Email settings are not yet configured. Please configure them below.')); return new RedirectResponse($this->container->get('router')->generate('zikulamailermodule_admin_modifyconfig', array(), RouterInterface::ABSOLUTE_URL)); } }
/** * Update phpBB user account from Zikula account by given Id * @return boolean */ public static function phpBBupdateAccountById($user_id) { $dom = ZLanguage::getModuleDomain('ZphpBB2'); $userObj = UserUtil::getVars($user_id); if ($userObj) { $class = 'ZphpBB2_Listener_UsersSynch'; if (!class_exists($class)) { include_once 'modules/ZphpBB2/lib/ZphpBB2/Listener/UsersSynch.php'; } return ZphpBB2_Listener_UsersSynch::updateAccount($userObj); } else { return LogUtil::registerError(__('Error: Could not obtain user information, Id ' . $user_id, $dom)); } }
public function addContact($args) { if (!SecurityUtil::checkPermission('IWusers::', '::', ACCESS_READ)) { throw new Zikula_Exception_Forbidden(); } $gid = FormUtil::getPassedValue('gid', -2, 'GET'); if ($gid == -2) { AjaxUtil::error('no group id'); } $fuid = FormUtil::getPassedValue('fuid', -1, 'GET'); if ($fuid == -1) { AjaxUtil::error('no user id'); } $action = FormUtil::getPassedValue('action', -1, 'GET'); if ($action == -1) { AjaxUtil::error('no action defined'); } $view = Zikula_View::getInstance('IWusers', false); if ($action == 'add') { if (!ModUtil::apiFunc('IWusers', 'user', 'addContant', array('fuid' => $fuid))) { AjaxUtil::error('error'); } $view->assign('add', true); } if ($action == 'delete') { if (!ModUtil::apiFunc('IWusers', 'user', 'deleteContant', array('fuid' => $fuid))) { AjaxUtil::error('error'); } $view->assign('add', false); } $view->assign('fuid', $fuid); $view->assign('gid', $gid); $vars = UserUtil::getVars($fuid); $view->assign('uname', $vars['uname']); $content = $view->fetch('IWusers_user_members_optionsContent.htm'); AjaxUtil::output(array('fuid' => $fuid, 'content' => $content, 'gid' => $gid)); }
// // Again this will be handled by the templating // code at some point // // Begin PNphpBB2 Module // $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; // $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; $row_color = !($i % 2) ? $phpbb_theme['td_color1'] : $phpbb_theme['td_color2']; $row_class = !($i % 2) ? $phpbb_theme['td_class1'] : $phpbb_theme['td_class2']; // End PNphpBB2 Module // Begin PNphpBB2 Module (Online/Offline user status) $status = online_offline_status($postrow[$i], in_array($postrow[$i]['user_id'], $forum_mods)); // End PNphpBB2 Module (Online/Offline user status) // RNG if ($poster_id) { $userVars = UserUtil::getVars($poster_id); $location = $userVars['_YLOCATION']; } // RNG End $template->assign_block_vars('postrow', array('POSTER_STATUS' => $status['text'], 'POSTER_STATUS_IMG' => $status['image'], 'ROW_COLOR' => '#' . $row_color, 'ROW_CLASS' => $row_class, 'POSTER_NAME' => $poster_profile, 'POSTER_RANK' => $poster_rank, 'RANK_IMAGE' => $rank_image, 'POSTER_FIRSTLASTNAMES' => $poster_firstlastnames, 'POSTER_JOINED' => $poster_joined, 'POSTER_POSTS' => $poster_posts, 'POSTER_FROM' => $poster_from, 'POSTER_AVATAR' => $poster_avatar, 'POST_DATE' => $post_date, 'POST_SUBJECT' => $post_subject, 'MESSAGE' => $message, 'SIGNATURE' => $user_sig, 'EDITED_MESSAGE' => $l_edited_by, 'MINI_POST_IMG' => $mini_post_img, 'PROFILE_IMG' => $profile_img, 'PROFILE' => $profile, 'SEARCH_IMG' => $search_img, 'SEARCH' => $search, 'PM_IMG' => $pm_img, 'PM' => $pm, 'EMAIL_IMG' => $email_img, 'EMAIL' => $email, 'WWW_IMG' => $www_img, 'WWW' => $www, 'ICQ_STATUS_IMG' => $icq_status_img, 'ICQ_IMG' => $icq_img, 'ICQ' => $icq, 'AIM_IMG' => $aim_img, 'AIM' => $aim, 'MSN_IMG' => $msn_img, 'MSN' => $msn, 'YIM_IMG' => $yim_img, 'YIM' => $yim, 'EDIT_IMG' => $edit_img, 'EDIT' => $edit, 'QUOTE_IMG' => $quote_img, 'QUOTE' => $quote, 'IP_IMG' => $ip_img, 'IP' => $ip, 'DELETE_IMG' => $delpost_img, 'ICON_UP' => $images['icon_up'], 'DELETE' => $delpost, 'L_MINI_POST_ALT' => $mini_post_alt, 'U_MINI_POST' => $mini_post_url, 'U_POST_ID' => $postrow[$i]['post_id'], 'LOCATION' => $location)); // Begin PNphpBB2 Module if ($postrow[$i]['post_icon'] > 0) { $template->assign_block_vars('postrow.posticon', array('ICON' => "<img " . $board_config['posticons_size'] . " src=\"" . $board_config['path_posticons'] . "/image_" . $postrow[$i]['post_icon'] . ".gif\" alt=\"" . $postrow[$i]['post_icon'] . "\" border=\"0\">")); } // End PNphpBB2 Module /* -- mod : File Attachment Mod v2 Version 2.4.3 ---------------------------------------------------- */ if (!intval($attach_config['disable_mod'])) { display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment']); } /* -- fin : File Attachment Mod v2 Version 2.4.3 ---------------------------------------------------- */ }
/** * Display a form to confirm the deletion of one user, and then process the deletion. * * Parameters passed via GET: * -------------------------- * numeric userid The user id of the user to be deleted. * string uname The user name of the user to be deleted. * * Parameters passed via POST: * --------------------------- * array userid The array of user ids of the users to be deleted. * boolean process_delete True to process the posted userid list, and delete the corresponding accounts; false or null to confirm first. * * Parameters passed via SESSION: * ------------------------------ * None. * * @return string HTML string containing the rendered template. * * @throws Zikula_Exception_Forbidden Thrown if the current user does not have delete access, or if the method of accessing this function is improper. */ public function deleteUsers() { // check permissions $this->throwForbiddenUnless(SecurityUtil::checkPermission('IWusers::', '::', ACCESS_DELETE)); $proceedToForm = false; $processDelete = false; if ($this->request->isPost()) { $userid = $this->request->request->get('userId', null); $processDelete = $this->request->request->get('process_delete', false); $proceedToForm = !$processDelete; } elseif ($this->request->isGet()) { $userid = $this->request->query->get('uid', null); $uname = $this->request->query->get('uname', null); // retreive userid from uname if (empty($userid) && !empty($uname)) { $userid = UserUtil::getIdFromName($users); } $proceedToForm = true; } else { throw new Zikula_Exception_Forbidden(); } if (empty($userid)) { $this->registerError($this->__('No users have chosen')); $proceedToForm = false; $userid = array(); } elseif (!is_array($userid)) { $userid = array($userid); } $currentUser = UserUtil::getVar('uid'); $users = array(); foreach ($userid as $key => $uid) { if ($uid == 1) { $this->registerError($this->__("Error! You can't delete the guest account.")); $proceedToForm = false; $processDelete = false; } elseif ($uid == 2) { $this->registerError($this->__("Error! You can't delete the primary administrator account.")); $proceedToForm = false; $processDelete = false; } elseif ($uid == $currentUser) { $this->registerError($this->__("Error! You can't delete the account you are currently logged into.")); $proceedToForm = false; $processDelete = false; } // get the user vars $users[$key] = UserUtil::getVars($uid); if (empty($users[$key])) { $this->registerError($this->__('Sorry! No such user found.')); $proceedToForm = false; $processDelete = false; } } if ($processDelete) { $this->checkCsrfToken(); $valid = true; foreach ($userid as $uid) { $event = new Zikula_Event('module.users.ui.validate_delete', null, array('id' => $uid), new Zikula_Hook_ValidationProviders()); $validators = $this->eventManager->notify($event)->getData(); $hook = new Zikula_ValidationHook('users.ui_hooks.user.validate_delete', $validators); $this->notifyHooks($hook); $validators = $hook->getValidators(); if ($validators->hasErrors()) { $valid = false; } } $proceedToForm = false; if ($valid) { $deleted = ModUtil::apiFunc($this->name, 'admin', 'deleteUser', array('uid' => $userid)); if ($deleted) { foreach ($userid as $uid) { $event = new Zikula_Event('module.users.ui.process_delete', null, array('id' => $uid)); $this->eventManager->notify($event); $hook = new Zikula_ProcessHook('users.ui_hooks.user.process_delete', $uid); $this->notifyHooks($hook); } $count = count($userid); $this->registerStatus($this->_fn('Done! Deleted %1$d user account.', 'Done! Deleted %1$d user accounts.', $count, array($count))); } } } if ($proceedToForm) { return $this->view->assign('users', $users) ->fetch('IWusers_admin_deleteusers.tpl'); } else { $this->redirect(ModUtil::url($this->name, 'admin', 'main')); } }
/** * Add core data to the template. * * This function adds some basic data to the template depending on the * current user and the Zikula settings. There is no need to call this as it's * invoked automatically on instanciation. * * In legacy mode 'coredata' will contain the module vars, but not when disabled. * This is just for BC legacy - to access module vars there is a 'modvars' property * assigned to all templates. * * @return Zikula_View */ public function add_core_data() { if (!isset($this->serviceManager['zikula_view.coredata'])) { $this->serviceManager['zikula_view.coredata'] = new ArrayObject(array()); } $core = $this->serviceManager['zikula_view.coredata']; $core['version_num'] = Zikula_Core::VERSION_NUM; $core['version_id'] = Zikula_Core::VERSION_ID; $core['version_sub'] = Zikula_Core::VERSION_SUB; $core['logged_in'] = UserUtil::isLoggedIn(); $core['language'] = $this->language; // add userdata $core['user'] = UserUtil::getVars(SessionUtil::getVar('uid')); if (System::isLegacyMode()) { // add modvars of current modules foreach ($this->module as $module => $dummy) { if (!empty($module)) { $core[$module] = ModUtil::getVar($module); } } // add mod vars of all modules supplied as parameter $modulenames = func_get_args(); foreach ($modulenames as $modulename) { // if the modulename is empty do nothing if (!empty($modulename) && !is_array($modulename) && !array_key_exists($modulename, $this->module)) { // check if user wants to have config if ($modulename == ModUtil::CONFIG_MODULE) { $ZConfig = ModUtil::getVar(ModUtil::CONFIG_MODULE); foreach ($ZConfig as $key => $value) { // gather all config vars $core['ZConfig'][$key] = $value; } } else { $core[$modulename] = ModUtil::getVar($modulename); } } } $this->assign('pncore', $core); } // Module vars parent::assign('coredata', $core); return $this; }
/** * Sets or resets a user's need to changed his password on his next attempt at logging ing. * * Parameters passed via GET: * -------------------------- * numeric userid The uid of the user for whom a change of password should be forced (or canceled). * * Parameters passed via POST: * --------------------------- * numeric userid The uid of the user for whom a change of password should be forced (or canceled). * boolean user_must_change_password True to force the user to change his password at his next log-in attempt, otherwise false. * * Parameters passed via SESSION: * ------------------------------ * None. * * @return string The rendered output from either the template for confirmation. * * @throws Zikula_Exception_Fatal Thrown if a user id is not specified, is invalid, or does not point to a valid account record, * or the account record is not in a consistent state. * @throws Zikula_Exception_Forbidden Thrown if the current user does not have edit access for the account record. */ public function toggleForcedPasswordChange() { if ($this->request->isGet()) { $uid = $this->request->query->get('userid', false); if (!$uid || !is_numeric($uid) || ((int)$uid != $uid)) { throw new Zikula_Exception_Fatal(LogUtil::getErrorMsgArgs()); } $userObj = UserUtil::getVars($uid); if (!isset($userObj) || !$userObj || !is_array($userObj) || empty($userObj)) { throw new Zikula_Exception_Fatal(LogUtil::getErrorMsgArgs()); } if (!SecurityUtil::checkPermission('Users::', "{$userObj['uname']}::{$uid}", ACCESS_EDIT)) { throw new Zikula_Exception_Forbidden(); } $userMustChangePassword = UserUtil::getVar('_Users_mustChangePassword', $uid, false); return $this->view->assign('user_obj', $userObj) ->assign('user_must_change_password', $userMustChangePassword) ->fetch('users_admin_toggleforcedpasswordchange.tpl'); } elseif ($this->request->isPost()) { $this->checkCsrfToken(); $uid = $this->request->request->get('userid', false); $userMustChangePassword = $this->request->request->get('user_must_change_password', false); if (!$uid || !is_numeric($uid) || ((int)$uid != $uid)) { throw new Zikula_Exception_Fatal(LogUtil::getErrorMsgArgs()); } // Force reload of User object into cache. $userObj = UserUtil::getVars($uid); if (!SecurityUtil::checkPermission('Users::', "{$userObj['uname']}::{$uid}", ACCESS_EDIT)) { throw new Zikula_Exception_Forbidden(); } if ($userMustChangePassword) { UserUtil::setVar('_Users_mustChangePassword', $userMustChangePassword, $uid); } else { UserUtil::delVar('_Users_mustChangePassword', $uid); } // Force reload of User object into cache. $userObj = UserUtil::getVars($uid, true); if ($userMustChangePassword) { if (isset($userObj['__ATTRIBUTES__']) && isset($userObj['__ATTRIBUTES__']['_Users_mustChangePassword'])) { $this->registerStatus($this->__f('Done! A password change will be required the next time %1$s logs in.', array($userObj['uname']))); } else { throw new Zikula_Exception_Fatal(); } } else { if (isset($userObj['__ATTRIBUTES__']) && isset($userObj['__ATTRIBUTES__']['_Users_mustChangePassword'])) { throw new Zikula_Exception_Fatal(); } else { $this->registerStatus($this->__f('Done! A password change will no longer be required for %1$s.', array($userObj['uname']))); } } $this->redirect(ModUtil::url($this->name, 'admin', 'view')); } else { throw new Zikula_Exception_Forbidden(); } }
/** * display the membership of a group * */ public function memberslist() { $gid = (int)FormUtil::getPassedValue('gid', null, 'GET'); $startnum = (int)FormUtil::getPassedValue('startnum', 1, 'GET'); if (!is_numeric($startnum)) { return LogUtil::registerArgsError(); } $itemsperpage = $this->getVar('itemsperpage'); $this->throwForbiddenUnless(SecurityUtil::checkPermission('Groups::memberslist', '::', ACCESS_OVERVIEW)); $group = ModUtil::apiFunc('Groups', 'user', 'get', array('gid' => $gid, 'numitems' => $itemsperpage, 'startnum' => $startnum)); if (!$group) { return DataUtil::formatForDisplay($this->__('Error! Could not load data.')); } $uid = UserUtil::getVar('uid'); $typelabel = array(); $statelabel = array(); $groupsCommon = new Groups_Helper_Common(); $typelabel = $groupsCommon->gtypeLabels(); $statelabel = $groupsCommon->stateLabels(); $group['typelbl'] = $typelabel[$group['gtype']]; $group['statelbl'] = $statelabel[$group['state']]; $this->view->assign('mainpage', false); $this->view->assign('group', $group); if ($group['members']) { $onlines = ModUtil::apiFunc('Groups', 'user', 'whosonline', array()); $members = array(); foreach ($group['members'] as $userid) { $userinfo = UserUtil::getVars($userid['uid']); $isonline = false; if (is_array($onlines)) { foreach ($onlines as $online) { if ($online['uid'] == $userid['uid']) { $isonline = true; } } } if ($isonline) { $userinfo['isonline'] = 'greenled.png'; $userinfo['isonlinelbl'] = $this->__('on-line'); } else { $userinfo['isonline'] = 'redled.png'; $userinfo['isonlinelbl'] = $this->__('off-line'); } $members[] = $userinfo; } // test of sorting data if (!empty($members)) { foreach ($members as $res) { $sortAarr[] = strtolower($res['uname']); } array_multisort($sortAarr, SORT_ASC, $members); } $this->view->assign('members', $members); } else { $this->view->assign('members', false); } if (UserUtil::isLoggedIn()) { $this->view->assign('ismember', ModUtil::apiFunc('Groups', 'user', 'isgroupmember', array('gid' => $gid, 'uid' => $uid))); } else { $this->view->assign('ismember', false); } $this->view->assign('pager', array('numitems' => ModUtil::apiFunc('Groups', 'user', 'countgroupmembers', array('gid' => $gid)), 'itemsperpage' => $itemsperpage)); $profileModule = System::getVar('profilemodule', ''); $this->view->assign('useProfileModule', (!empty($profileModule) && $profileModule == 'Profile' && ModUtil::available($profileModule))); return $this->view->fetch('groups_user_memberslist.tpl'); }
/** * Add core data to the template. * * This function adds some basic data to the template depending on the * current user and the Zikula settings. There is no need to call this as it's * invoked automatically on instanciation. * * @return Zikula_View */ public function add_core_data() { if (!isset($this->container['zikula_view.coredata'])) { $this->container['zikula_view.coredata'] = new ArrayObject(array()); } $core = $this->container['zikula_view.coredata']; $core['version_num'] = \Zikula\Core\Core::VERSION_NUM; $core['version_id'] = \Zikula\Core\Core::VERSION_ID; $core['version_sub'] = \Zikula\Core\Core::VERSION_SUB; $core['logged_in'] = UserUtil::isLoggedIn(); $core['language'] = $this->language; // add userdata $core['user'] = UserUtil::getVars($this->request->getSession()->get('uid')); // Module vars parent::assign('coredata', $core); return $this; }
/** * Display the block. * * @param array $blockinfo A blockinfo structure. * * @return string The rendered block. */ public function display($blockinfo) { // Check if the Profile module is available. if (!ModUtil::available('Profile')) { return false; } // Security check if (!SecurityUtil::checkPermission('Profile:FeaturedUserblock:', "$blockinfo[bid]::", ACCESS_READ)) { return false; } // Get variables from content block $vars = BlockUtil::varsFromContent($blockinfo['content']); // If there's no user to show, nothing to do if (!isset($vars['username']) || empty($vars['username'])) { return false; } // Defaults if (!isset($vars['fieldstoshow']) || !is_array($vars['fieldstoshow']) || empty($vars['fieldstoshow'])) { $vars['fieldstoshow'] = array(); } if (!isset($vars['showregdate']) || empty($vars['showregdate'])) { $vars['showregdate'] = ''; } $userinfo = UserUtil::getVars(UserUtil::getIdFromName($vars['username'])); // Check if the user is watching its own profile or if he is admin $currentuser = UserUtil::getVar('uid'); $ismember = ($currentuser >= 2); $sameuser = ($currentuser == $userinfo['uid']); $isadmin = false; if (SecurityUtil::checkPermission('Profile::', '::', ACCESS_ADMIN)) { $isadmin = true; } // get all active profile fields $activeduds = ModUtil::apiFunc('Profile', 'user', 'getallactive', array('index' => 'prop_label')); foreach ($activeduds as $dudlabel => $activedud) { // check if the attribute is set to be shown in the block if (!in_array($activedud['prop_attribute_name'], $vars['fieldstoshow'])) { continue; } // discard empty fields if (empty($userinfo['__ATTRIBUTES__'][$activedud['prop_attribute_name']])) { continue; } // check the access to this field if ($activedud['prop_viewby'] != 0) { // not to everyone, checks members only or higher if (!($activedud['prop_viewby'] == 1 && $ismember)) { // lastly check for the same user or admin if (!($activedud['prop_viewby'] == 2 && ($sameuser || $isadmin))) { continue; } } } // add it to the viewable properties $dudarray[$dudlabel] = $userinfo['__ATTRIBUTES__'][$activedud['prop_attribute_name']]; } unset($activeduds); // build the output $this->view->setCacheId('featured'.$vars['username']); $this->view->assign('userinfo', $userinfo); $this->view->assign('showregdate', $vars['showregdate']); $this->view->assign('dudarray', $dudarray); $blockinfo['content'] = $this->view->fetch('profile_block_featureduser.tpl'); return BlockUtil::themeBlock($blockinfo); }
/** * Check a lost password confirmation code. * * Parameters passed in the $args array: * ------------------------------------- * string $args['idfield'] Either 'uname' or 'email'. * string $args['id'] The user's user name or e-mail address, depending on the value of idfield. * string $args['code'] The confirmation code. * * @param array $args All parameters passed to this function. * * @return bool True if the new password was sent; otherwise false. */ public function checkConfirmationCode($args) { $codeIsGood = false; if (!isset($args['id']) || empty($args['id']) || !isset($args['idfield']) || empty($args['idfield']) || !isset($args['code']) || empty($args['code']) || (($args['idfield'] != 'uname') && ($args['idfield'] != 'email'))) { $this->registerError(LogUtil::getErrorMsgArgs()); return false; } $user = UserUtil::getVars($args['id'], true, $args['idfield']); if (!$user) { $this->registerError(LogUtil::getErrorMsgArgs()); return false; } else { // delete all the records for password reset confirmation that have expired $tables = DBUtil::getTables(); $verifychgColumn = $tables['users_verifychg_column']; $chgPassExpireDays = $this->getVar(Users_Constant::MODVAR_EXPIRE_DAYS_CHANGE_PASSWORD, Users_Constant::DEFAULT_EXPIRE_DAYS_CHANGE_PASSWORD); if ($chgPassExpireDays > 0) { $staleRecordUTC = new DateTime(null, new DateTimeZone('UTC')); $staleRecordUTC->modify("-{$chgPassExpireDays} days"); $staleRecordUTCStr = $staleRecordUTC->format(Users_Constant::DATETIME_FORMAT); $where = "({$verifychgColumn['created_dt']} < '{$staleRecordUTCStr}') AND ({$verifychgColumn['changetype']} = " . Users_Constant::VERIFYCHGTYPE_PWD . ")"; DBUtil::deleteWhere ('users_verifychg', $where); } $verifychgObj = DBUtil::selectObject('users_verifychg', "({$verifychgColumn['uid']} = {$user['uid']}) AND ({$verifychgColumn['changetype']} = " . Users_Constant::VERIFYCHGTYPE_PWD . ")"); if ($verifychgObj) { $codeIsGood = UserUtil::passwordsMatch($args['code'], $verifychgObj['verifycode']); } else { $this->registerError('Sorry! Could not retrieve a confirmation code for that account.'); } } return $codeIsGood; }
/** * Retrieve the account recovery information for the specified user. * * The array returned by this function should be an empty array (not null) if the specified user does not have any * authentication methods registered with the authentication module that are enabled for log-in. * * If the specified user does have one or more authentication methods, then the array should contain one or more elements * indexed numerically. Each element should be an associative array containing the following: * * - 'modname' The authentication module name. * - 'short_description' A brief (a few words) description or name of the authentication method. * - 'long_description' A longer description or name of the authentication method. * - 'uname' The user name _equivalent_ for the authentication method (e.g., the claimed OpenID). * - 'link' If the authentication method is for an external service, then a link to the user's account on that service, or a general link to the service, * otherwise, an empty string (not null). * * For example: * * <code> * $accountRecoveryInfo[] = array( * 'modname' => $this->name, * 'short_description' => $this->__('E-mail Address'), * 'long_description' => $this->__('E-mail Address'), * 'uname' => $userObj['email'], * 'link' => '', * ) * </code> * * Parameters passed in the $arg array: * ------------------------------------ * numeric 'uid' The user id of the user for which account recovery information should be retrieved. * * @param array $args All parameters passed to this function. * * @return An array of account recovery information. * * @throws Zikula_Exception_Fatal Thrown if an invalid arguments array or an invalid user id is received by the method. */ public function getAccountRecoveryInfoForUid(array $args) { if (!isset($args) || empty($args)) { throw new Zikula_Exception_Fatal($this->__('An invalid parameter array was received.')); } $uid = isset($args['uid']) ? $args['uid'] : false; if (!isset($uid) || !is_numeric($uid) || ((string)((int)$uid) != $uid)) { throw new Zikula_Exception_Fatal($this->__('An invalid user id was received.')); } $userObj = UserUtil::getVars($uid); $lostUserNames = array(); if ($userObj) { if (!empty($userObj['pass']) && ($userObj['pass'] != Users_Constant::PWD_NO_USERS_AUTHENTICATION)) { $loginOption = $this->getVar(Users_Constant::MODVAR_LOGIN_METHOD, Users_Constant::DEFAULT_LOGIN_METHOD); if (($loginOption == Users_Constant::LOGIN_METHOD_UNAME) || ($loginOption == Users_Constant::LOGIN_METHOD_ANY)) { $lostUserNames[] = array( 'modname' => $this->name, 'short_description' => $this->__('User name'), 'long_description' => $this->__('User name'), 'uname' => $userObj['uname'], 'link' => '', ); } if (($loginOption == Users_Constant::LOGIN_METHOD_EMAIL) || ($loginOption == Users_Constant::LOGIN_METHOD_ANY)) { $lostUserNames[] = array( 'modname' => $this->name, 'short_description' => $this->__('E-mail Address'), 'long_description' => $this->__('E-mail Address'), 'uname' => $userObj['email'], 'link' => '', ); } } } return $lostUserNames; }
/** * Update the user's password. * * Parameters passed via GET: * -------------------------- * None. * * Parameters passed via POST: * --------------------------- * string oldpassword The original password. * string newpassword The new password to be stored for the user. * string newpasswordconfirm Verification of the new password to be stored for the user. * * Parameters passed via SESSION: * ------------------------------ * Namespace: Zikula_Users * Variable: Users_Controller_User_updatePassword * Type: array * Contents: An array containing the information saved from the log-in attempt in order to re-enter it, including: * 'authentication_method', an array containing the selected authentication module name and method name, * 'authentication_info', an array containing the authentication information entered by the user, * 'user_obj', a user record containing the user information found during the log-in attempt, * 'password_errors', errors that have occurred during a previous pass through this function. * * @return bool True on success, otherwise false. */ public function updatePassword() { $sessionVars = $this->request->getSession()->get('Users_Controller_User_updatePassword', null, 'Zikula_Users'); $this->request->getSession()->del('Users_Controller_User_updatePassword', 'Zikula_Users'); if (!$this->request->isPost()) { throw new Zikula_Exception_Forbidden(); } $this->checkCsrfToken(); if (isset($sessionVars) && !empty($sessionVars)) { $login = true; $userObj = $sessionVars['user_obj']; } else { $login = false; $userObj = UserUtil::getVars(UserUtil::getVar('uid'), true); } $uid = $userObj['uid']; if (!$login && !UserUtil::isLoggedIn()) { throw new Zikula_Exception_Forbidden(); } elseif ($login && UserUtil::isLoggedIn()) { throw new Zikula_Exception_Fatal(); } $passwordChanged = false; $currentPassword = $this->request->request->get('oldpassword', ''); $newPassword = $this->request->request->get('newpassword', ''); $newPasswordAgain = $this->request->request->get('newpasswordconfirm', ''); $newPasswordReminder= $this->request->request->get('passreminder', ''); $passwordErrors = array(); if (empty($currentPassword) || !UserUtil::passwordsMatch($currentPassword, $userObj['pass'])) { $passwordErrors['oldpass'][] = $this->__('The current password you entered is not correct. Please correct your entry and try again.'); } else { $passwordErrors = ModUtil::apiFunc($this->name, 'registration', 'getPasswordErrors', array( 'uname' => $userObj['uname'], 'pass' => $newPassword, 'passagain' => $newPasswordAgain, 'passreminder' => $newPasswordReminder )); if ($login && ($currentPassword == $newPassword)) { $passwordErrors['reginfo_pass'][] = $this->__('Your new password cannot match your current password.'); } } if (empty($passwordErrors)) { if (UserUtil::setPassword($newPassword, $uid)) { // no user.update event for password chagnes. $passwordChanged = true; // Clear the forced change of password flag, if it exists. UserUtil::delVar('_Users_mustChangePassword', $uid); if (!UserUtil::setVar('passreminder', $newPasswordReminder, $uid)) { $this->registerError($this->__('Warning! Your new password was saved, however there was a problem saving your new password reminder.')); } else { $this->registerStatus($this->__('Done! Saved your new password.')); } $userObj = UserUtil::getVars(UserUtil::getVar('uid'), true); if ($login) { $sessionVars['user_obj'] = $userObj; if ($sessionVars['authentication_method']['modname'] == $this->name) { // The password for Users module authentication was just changed. // In order to successfully log in the user, we need to change it on the authentication_info. $sessionVars['authentication_info']['pass'] = $newPassword; } } } else { throw new Zikula_Exception_Fatal($this->__('Sorry! There was a problem saving your new password.')); } } if ($passwordChanged) { if ($login) { $loginArgs = $this->request->getSession()->get('Users_Controller_User_login', array(), 'Zikula_Users'); $loginArgs['authentication_method'] = $sessionVars['authentication_method']; $loginArgs['authentication_info'] = $sessionVars['authentication_info']; $loginArgs['rememberme'] = $sessionVars['rememberme']; return ModUtil::func($this->name, 'user', 'login', $loginArgs); } else { return $this->redirect(ModUtil::url($this->name, 'user', 'main')); } } else { $sessionVars['password_errors'] = $passwordErrors; SessionUtil::requireSession(); $this->request->getSession()->set('Users_Controller_User_changePassword', $sessionVars, 'Zikula_Users'); $this->redirect(ModUtil::url($this->name, 'user', 'changePassword', array('login' => $login))); } }
/** * Return registered users online. * * @return array Registered users who are online. */ public function whosonline() { // Get database setup $dbtable = DBUtil::getTables(); // define the array to hold the resultant items $items = array(); // It's good practice to name the table and column definitions you are // getting - $table and $column don't cut it in more complex modules $sessioninfocolumn = $dbtable['session_info_column']; $sessioninfotable = $dbtable['session_info']; // get active time based on security settings $activetime = date('Y-m-d H:i:s', time() - (System::getVar('secinactivemins') * 60)); $where = "WHERE {$sessioninfocolumn['uid']} != 1 AND {$sessioninfocolumn['lastused']} > '{$activetime}' "; $result = DBUtil::selectObjectArray('session_info', $where, '', -1, -1, '', null, null, array('uid'), true); if ($result === false) { return LogUtil::registerError($this->__('Error! Could not load data.')); } foreach ($result as $key => $user) { $result[$key] = UserUtil::getVars($user['uid']); } // Return the items return $result; }
public function UserReports($args) { $dateTimeTo = $args['dateTimeTo']; $dateTimeFrom = $args['dateTimeFrom']; $cronURfreq = $this->getVar('cronURfreq'); if (($dateTimeTo - $dateTimeFrom) < ($cronURfreq*60*60)) { $msg = '<div>'.__('User reports enabled, but executed too recently').'</div>'; $exit = -3; return array('cronResponse' => $msg, 'exit' => $exit); } $everybodySubscribed = $this->getVar('everybodySubscribed'); $msg = '<h3>'.__('User reports').'</h3>'; //Checking Mailer $modid = ModUtil::getIdFromName('Mailer'); $modinfo = ModUtil::getInfo($modid); $IWforums = ModUtil::getVar('IWmain','crAc_UR_IWforums'); $IWmessages = ModUtil::getVar('IWmain','crAc_UR_IWmessages'); $IWforms = ModUtil::getVar('IWmain','crAc_UR_IWforms'); $IWnoteboard = ModUtil::getVar('IWmain','crAc_UR_IWnoteboard'); if ($modinfo['state'] != 3) { $exit = '-1'; $msg .= '<div>'.__('The Mailer module is not active. The cron can not send emails to users.').'</div>'; }elseif (!$IWforums && !$IWmessages && !$IWforms && !$IWnoteboard){ $exit = '0'; $msg .= '<div>'.__('There is no module connected to User Reports').'</div>'; }else { $msg .= '<div>'.__('Modules connected:').' '; $msg .= $IWforums ? '- IWforums ' : ''; $msg .= $IWmessages ? '- IWmessages ' : ''; $msg .= $IWforms ? '- IWforms ' : ''; $msg .= $IWnoteboard ? '- IWnoteboard ' : ''; $msg .= '</div><br>'; //Getting News from modules $forumsNews = $IWforums ? ModUtil::apiFunc('IWmain', 'cron', 'getForumsNews', array('dateTimeTo' => $dateTimeTo, 'dateTimeFrom' => $dateTimeFrom)) : array(); $messagesNews = $IWmessages ? ModUtil::apiFunc('IWmain', 'cron', 'getMessagesNews', array('dateTimeTo' => $dateTimeTo, 'dateTimeFrom' => $dateTimeFrom)) : array(); $formsNews = $IWforms ? ModUtil::apiFunc('IWmain', 'cron', 'getFormsNews', array('dateTimeTo' => $dateTimeTo, 'dateTimeFrom' => $dateTimeFrom)) : array(); $noteboardNews = $IWnoteboard ? ModUtil::apiFunc('IWmain', 'cron', 'getNoteboardNews', array('dateTimeTo' => $dateTimeTo, 'dateTimeFrom' => $dateTimeFrom)) : array(); //News construction $forumsNews = array_combine(array_map(function($a) {return '_' . $a;}, array_keys($forumsNews)), $forumsNews); $messagesNews = array_combine(array_map(function($a) {return '_' . $a;}, array_keys($messagesNews)), $messagesNews); $formsNews = array_combine(array_map(function($a) {return '_' . $a;}, array_keys($formsNews)), $formsNews); $noteboardNews = array_combine(array_map(function($a) {return '_' . $a;}, array_keys($noteboardNews)), $noteboardNews); $news = array_merge_recursive($forumsNews , $messagesNews , $formsNews , $noteboardNews); $news = array_combine(array_map(function($a) {return substr($a, 1);}, array_keys($news)), $news); //Case no news if (empty($news)) { $exit = '1'; $msg .= '<div>'.__('No news').'</div>'; return array('cronResponse' => $msg, 'exit' => $exit); } $subject = $this->getVar('cronSubjectText'); $HeaderText = $this->getVar('cronHeaderText'); $FooterText = $this->getVar('cronFooterText'); $IWforumsHd = $this->getVar('crAc_UR_IWforums_hd'); $IWmessagesHd = $this->getVar('crAc_UR_IWmessages_hd'); $IWformsHd = $this->getVar('crAc_UR_IWforms_hd'); $IWnoteboardHd = $this->getVar('crAc_UR_IWnoteboard_hd'); $uSub = 0; $uEmail = 0; $uOk = 0; foreach ($news as $userId => $userNews) { //get subscriber info $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $subscribeNews = ModUtil::apiFunc('IWmain', 'user', 'userVarExists', array('name' => 'subscribeNews', 'module' => 'IWmain_cron', 'uid' => $userId, 'sv' => $sv)); //get user mail $userInfo = UserUtil::getVars($userId); $userMail = $userInfo['email']; if ($everybodySubscribed || $subscribeNews) { $uSub++; if ($userMail != '') { $uEmail++; $view = Zikula_View::getInstance($this->name, false); $view->assign('cronHeaderText', $cronHeaderText) ->assign('FooterText',$FooterText) ->assign('HeaderText',$HeaderText) ->assign('IWforums',$IWforums) ->assign('IWmessages',$IWmessages) ->assign('IWforms',$IWforms) ->assign('IWnoteboard',$IWnoteboard) ->assign('IWforumsHd',$IWforumsHd) ->assign('IWmessagesHd',$IWmessagesHd) ->assign('IWformsHd',$IWformsHd) ->assign('IWnoteboardHd',$IWnoteboardHd) ->assign('userNews',$userNews); $newsText = $view->fetch('IWmain_cron_mail.tpl'); $sendResult = ModUtil::apiFunc('Mailer', 'user', 'sendmessage', array('toname' => $userMail, 'toaddress' => $userMail, 'subject' => $subject, 'body' => $newsText, 'html' => 1)); if ($sendResult) $uOk++; } } } $msg .= '<ul><li>'.count($news).' '.__('users with news.').'</li>'; $msg .= '<li>'.$uSub.' '.__('of them subscribed.').'</li>'; $msg .= '<li>'.$uEmail.' '.__('subscribers with email.').'</li>'; $msg .= '<li>'.$uOk.' '.__('emails sended.').'</li></ul>'; //Checking sending $exit = ($uEmail == $uOk) ? 1 : -1; } return array('cronResponse' => $msg, 'exit' => $exit); }
/** * Delete one or more user account records, or mark one or more account records for deletion. * * If records are marked for deletion, they remain in the system and accessible by the system, but are given an * 'activated' status that prevents the user from logging in. Records marked for deletion will not appear on the * regular users list. The delete hook and delete events are not triggered if the records are only marked for * deletion. * * Parameters passed in the $args array: * ------------------------------------- * numeric|array $args['uid'] A single (numeric integer) user id, or an array of user ids to delete. * boolean $args['mark'] If true, then mark for deletion, but do not actually delete. * defaults to false. * * @param array $args All parameters passed to this function. * * @return bool True if successful, false otherwise. */ public function deleteUser($args) { if (!SecurityUtil::checkPermission("{$this->name}::", 'ANY', ACCESS_DELETE)) { return false; } if (!isset($args['uid']) || (!is_numeric($args['uid']) && !is_array($args['uid']))) { $this->registerError("Error! Illegal argument were passed to 'deleteuser'"); return false; } if (isset($args['mark']) && is_bool($args['mark'])) { $markOnly = $args['mark']; } else { $markOnly = false; } // ensure we always have an array if (!is_array($args['uid'])) { $args['uid'] = array($args['uid']); } $curUserUid = UserUtil::getVar('uid'); $userList = array(); foreach ($args['uid'] as $uid) { if (!is_numeric($uid) || ((int)$uid != $uid) || ($uid == $curUserUid)) { return false; } $userObj = UserUtil::getVars($uid); if (!$userObj) { return false; } elseif (!SecurityUtil::checkPermission("{$this->name}::", "{$userObj['uname']}::{$userObj['uid']}", ACCESS_DELETE)) { return false; } $userList[] = $userObj; } foreach ($userList as $userObj) { if ($markOnly) { UserUtil::setVar('activated', Users_Constant::ACTIVATED_PENDING_DELETE, $userObj['uid']); } else { // TODO - This should be in the Groups module, and happen as a result of an event. if (!DBUtil::deleteObjectByID('group_membership', $userObj['uid'], 'uid')) { return false; } ModUtil::apiFunc($this->name, 'admin', 'resetVerifyChgFor', array('uid' => $userObj['uid'])); DBUtil::deleteObjectByID('session_info', $userObj['uid'], 'uid'); if (!DBUtil::deleteObject($userObj, 'users', '', 'uid')) { return false; } // Let other modules know we have deleted an item $deleteEvent = new Zikula_Event('user.account.delete', $userObj); $this->eventManager->notify($deleteEvent); } } return $args['uid']; }
/** * display block * * @author Erik Spaan [espaan] * @param array $blockinfo a blockinfo structure * @return output the rendered bock */ public function display($blockinfo) { if (!SecurityUtil::checkPermission('Storiesextblock::', "$blockinfo[bid]::", ACCESS_OVERVIEW)) { return; } // Break out options from our content field $vars = BlockUtil::varsFromContent($blockinfo['content']); // Get the News categorization setting $enablecategorization = ModUtil::getVar('News', 'enablecategorization'); $lang = ZLanguage::getLanguageCode(); $topicProperty = ModUtil::getVar('News', 'topicproperty'); $topicField = empty($topicProperty) ? 'Main' : $topicProperty; $catimagepath = ModUtil::getVar('News', 'catimagepath'); // --- Setting of the Defaults if (!isset($vars['category'])) { $vars['category'] = null; } if (!isset($vars['show'])) { $vars['show'] = 1; } if (!isset($vars['status'])) { $vars['status'] = 0; } if (!isset($vars['order'])) { $vars['order'] = 0; } if (!isset($vars['limit'])) { $vars['limit'] = 5; } // Maximum article age in days if (!isset($vars['dayslimit'])) { $vars['dayslimit'] = 0; } // Maximum title length if (!isset($vars['maxtitlelength'])) { $vars['maxtitlelength'] = 0; } if (!isset($vars['titlewraptxt'])) { $vars['titlewraptxt'] = '...'; } // Show 'No News' message instead of empty block if (!isset($vars['showemptyresult'])) { $vars['showemptyresult'] = 0; } // Override templates for the block and row display if (!isset($vars['blocktemplate'])) { $vars['blocktemplate'] = ''; } if (!isset($vars['rowtemplate'])) { $vars['rowtemplate'] = ''; } // Display optional article information $vars['dispuname'] = (!isset($vars['dispuname'])) ? false : !empty($vars['dispuname']); $vars['dispdate'] = (!isset($vars['dispdate'])) ? true : !empty($vars['dispdate']); if (!isset($vars['dateformat'])) { $vars['dateformat'] = '%x'; } $vars['dispreads'] = (!isset($vars['dispreads'])) ? false : !empty($vars['dispreads']); $vars['dispcomments'] = (!isset($vars['dispcomments'])) ? false : !empty($vars['dispcomments']); if (!isset($vars['dispsplitchar'])) { $vars['dispsplitchar'] = ', '; } // Display (part of) the hometext of the article $vars['disphometext'] = (!isset($vars['disphometext'])) ? false : !empty($vars['disphometext']); if (!isset($vars['maxhometextlength'])) { $vars['maxhometextlength'] = 0; } if (!isset($vars['hometextwraptxt'])) { $vars['hometextwraptxt'] = '...'; } // Display of a new story image $vars['dispnewimage'] = (!isset($vars['dispnewimage'])) ? false : !empty($vars['dispnewimage']); if (!isset($vars['newimagelimit'])) { $vars['newimagelimit'] = 3; } if (!isset($vars['newimageset'])) { $vars['newimageset'] = 'icons/extrasmall/'; } if (!isset($vars['newimagesrc'])) { $vars['newimagesrc'] = 'favorites.png'; } // display the items in a scrolling box, pausing, fading or marquee if (!isset($vars['scrolling'])) { $vars['scrolling'] = 1; } if (!isset($vars['scrollstyle'])) { $vars['scrollstyle'] = '%DIVID% { width:inherit; overflow:hidden; position:relative; padding:2px; border:0px solid black; background:transparent; /* IE: Height + 2*padding + 2*border */ height:54px; voice-family: "\"}\""; voice-family:inherit; /* regular height */ height:50px; } /* Opera browser */ html>body %DIVID% { height:50px; }'; } if (!isset($vars['scrolldelay'])) { $vars['scrolldelay'] = 3000; } if (!isset($vars['scrollmspeed'])) { $vars['scrollmspeed'] = 2; } $scrollfilterduration = 1.0; // --- Work out the parameters for the News api call, fill the apiargs array with the necessary fields $apiargs = array(); switch ($vars['show']) { case 3: // non index page articles $apiargs['displayonindex'] = 0; break; case 2: // index page articles $apiargs['displayonindex'] = 1; break; // all - doesn't need displayonindex } $apiargs['numitems'] = $vars['limit']; // Nr of articles to obtain $apiargs['status'] = $vars['status']; // Published status // Make a category filter only if categorization is enabled in News module if ($enablecategorization) { // Get the registrered categories for the News module $catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news'); $apiargs['catregistry'] = $catregistry; $apiargs['category'] = $vars['category']; } // Limit the shown articles in days using DateUtil if ((int)$vars['dayslimit'] > 0 && $vars['order'] == 0) { $apiargs['from'] = DateUtil::getDatetime_NextDay(-$vars['dayslimit']); $apiargs['to'] = DateUtil::getDatetime(); } // Handle the sorting order switch ($vars['order']) { case 2: $apiargs['order'] = 'weight'; break; case 3: $apiargs['order'] = 'random'; break; case 1: $apiargs['order'] = 'counter'; break; case 0: default: // Use News module setting, so don't set apiargs[order] } // Make sure datefiltering is done. Solves #12 $apiargs['filterbydate'] = true; // Call the News api and get the requested articles with the above arguments $items = ModUtil::apiFunc('News', 'user', 'getall', $apiargs); // check for an empty return if (empty($items)) { if ($vars['showemptyresult']) { // Show empty result message instead of empty block if variable is set $blockinfo['content'] = $this->__('No articles.'); return BlockUtil::themeBlock($blockinfo); } else { return; } } // UserUtil is not automatically loaded, so load it now if needed and set anonymous if ($vars['dispuname']) { $anonymous = System::getVar('anonymous'); } // --- Select the configurable row template or the default. The row templates is cached with its sid (storyid) $storiesoutput = array(); if (!empty($vars['rowtemplate'])) { $rowtemplate = $vars['rowtemplate']; } else { $rowtemplate = 'block/storiesext/row.tpl'; } // --- loop through the items and prepare every News item for display foreach ($items as $item) { // Get specific information from the article. It was a choice not to use the pnuserapi functions // GetArticleInfo, GetArticleLinks and getArticlesPreformat because of speed etc. // --- Check for Topic related properties like topicimage, topicsearchurl etc. if ($enablecategorization && !empty($item['__CATEGORIES__']) && isset($item['__CATEGORIES__'][$topicField])) { $item['topicid'] = $item['__CATEGORIES__'][$topicField]['id']; $item['topicname'] = isset($item['__CATEGORIES__'][$topicField]['display_name'][$lang]) ? $item['__CATEGORIES__'][$topicField]['display_name'][$lang] : $item['__CATEGORIES__'][$topicField]['name']; // set the topic image if topic_image category property exists $item['topicimage'] = (isset($item['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']) && isset($item['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'])) ? $item['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'] : ''; // set the topic description if exists $item['topictext'] = isset($item['__CATEGORIES__'][$topicField]['display_desc'][$lang]) ? $item['__CATEGORIES__'][$topicField]['display_desc'][$lang] : ''; // set the path of the topic $item['topicpath'] = $item['__CATEGORIES__'][$topicField]['path_relative']; // set the url to search for this topic if (System::getVar('shorturls', false)) { $item['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $item['topicpath']))); } else { $item['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $item['topicid']))); } } else { $item['topicid'] = null; $item['topicname'] = ''; $item['topicimage'] = ''; $item['topictext'] = ''; $item['topicpath'] = ''; $item['topicsearchurl'] = ''; } // Optional new image if the difference in days from the publishing date and now < the limit $item['itemnewimage'] = ($vars['dispnewimage'] && DateUtil::getDatetimeDiff_AsField($item['from'], DateUtil::getDatetime(), 3) < (int)$vars['newimagelimit']); // Wrap the title if needed $item['titlewrapped'] = false; if ($vars['maxtitlelength'] > 0 && strlen($item['title']) > (int)$vars['maxtitlelength']) { // wrap the title with wordwrap (instead of substr) $a = explode('[[[wrap]]]', wordwrap($item['title'], (int)$vars['maxtitlelength'], '[[[wrap]]]')); $item['title'] = $a[0]; $item['titlewrapped'] = true; } if ($vars['dispuname']) { // Get the user information from the author id if ($item['cr_uid'] == 0) { $this->view->assign('uname', $anonymous); $this->view->assign('aid_name', $anonymous); } else { $user = UserUtil::getVars($item['cr_uid']); $this->view->assign('uname', $user['uname']); $this->view->assign('aid_name', $user['name']); } } // Check for EZComments if ($vars['dispcomments'] && ModUtil::available('EZComments')) { $item['comments'] = ModUtil::apiFunc('EZComments', 'user', 'countitems', array('mod' => 'News', 'objectid' => $item['sid'], 'status' => 0)); } if ($vars['disphometext']) { if ($vars['maxhometextlength'] > 0 && strlen(strip_tags($item['hometext'])) > (int)$vars['maxhometextlength']) { $item['hometextwrapped'] = true; } } if ($vars['dispuname']||$vars['dispdate']||$vars['dispreads']||$vars['dispcomments']) { $this->view->assign('dispinfo', true); } $this->view->assign('readperm',(bool)SecurityUtil::checkPermission('News::', "$item[cr_uid]::$item[sid]", ACCESS_READ)); $this->view->assign($vars); $this->view->assign($item); // Get the cached output per row $storiesoutput[] = $this->view->fetch($rowtemplate, $item['sid']); } // Turn of caching for the block display $this->view->setCaching(false); // Use the configured template if set, otherwise use the default static/scrolling ones. if (!empty($vars['blocktemplate'])) { $blocktemplate = $vars['blocktemplate']; } else { $blocktemplate = 'block/storiesext/main.tpl'; if ((int)$vars['scrolling']>1) { switch ((int)$vars['scrolling']) { case 2: $blocktemplate = 'block/storiesext/scrollpause.tpl'; break; case 3: $blocktemplate = 'block/storiesext/scrollfade.tpl'; // Add the IE fading effect to the existing scrollstyle $vars['scrollstyle'] .= '%DIVID% {filter: progid:DXImageTransform.Microsoft.GradientWipe(GradientSize=1.0 Duration=' . $scrollfilterduration . ')}'; break; case 4: $blocktemplate = 'block/storiesext/scrollmarquee.tpl'; $this->view->assign('scrollmspeed', $vars['scrollmspeed']); break; } $this->view->assign('scrollstyle', $vars['scrollstyle']); $this->view->assign('scrolldelay', $vars['scrolldelay']); } } $this->view->assign('catimagepath', $catimagepath); $this->view->assign('bid', $blockinfo['bid']); $this->view->assign('stories', $storiesoutput); $blockinfo['content'] = $this->view->fetch($blocktemplate); return BlockUtil::themeBlock($blockinfo); }
/** * Display the data to the containing Content page */ public function display() { // Parameters for category related items properties like topicimage $lang = ZLanguage::getLanguageCode(); $topicProperty = ModUtil::getVar('News', 'topicproperty'); $topicField = empty($topicProperty) ? 'Main' : $topicProperty; // work out the parameters for the News api call $apiargs = array(); switch ($this->show) { case 3: // non index page articles $apiargs['displayonindex'] = 0; break; case 2: // index page articles $apiargs['displayonindex'] = 1; break; // all - doesn't need displayonindex } $apiargs['numitems'] = $this->limit; // Nr of articles to obtain $apiargs['status'] = (int) $this->status; // Published status // Handle the sorting order switch ($this->orderoptions) { case 2: $apiargs['order'] = 'weight'; break; case 3: $apiargs['order'] = 'random'; break; case 1: $apiargs['order'] = 'counter'; break; case 0: default: // Use News module setting, so don't set apiargs[order] } $enablecategorization = ModUtil::getVar('News', 'enablecategorization'); // Make a category filter only if categorization is enabled in News module if ($enablecategorization && $this->categories != null) { // Get the registrered categories for the News module $catregistry = CategoryRegistryUtil::getRegisteredModuleCategories('News', 'news'); $apiargs['catregistry'] = $catregistry; $apiargs['category'] = $this->categories; } // Limit the shown articles in days using DateUtil if ((int) $this->dayslimit > 0 && $vars['order'] == 0) { $apiargs['from'] = DateUtil::getDatetime_NextDay(-$this->dayslimit); $apiargs['to'] = DateUtil::getDatetime(); } // Apply datefiltering $apiargs['filterbydate'] = true; // call the News api and get the requested articles with the above arguments $items = ModUtil::apiFunc('News', 'user', 'getall', $apiargs); // UserUtil is not automatically loaded, so load it now if needed and set anonymous if ($this->dispuname) { $anonymous = System::getVar('anonymous'); } // check for an empty return if (!empty($items)) { // loop through the items and prepare for display foreach (array_keys($items) as $k) { // Get specific information from the article. It was a choice not to use the pnuserapi functions // GetArticleInfo, GetArticleLinks and getArticlesPreformat because of speed etc. // --- Check for Topic related properties like topicimage, topicsearchurl etc. if ($enablecategorization && !empty($items[$k]['__CATEGORIES__']) && isset($items[$k]['__CATEGORIES__'][$topicField])) { $items[$k]['topicid'] = $items[$k]['__CATEGORIES__'][$topicField]['id']; $items[$k]['topicname'] = isset($items[$k]['__CATEGORIES__'][$topicField]['display_name'][$lang]) ? $items[$k]['__CATEGORIES__'][$topicField]['display_name'][$lang] : $items[$k]['__CATEGORIES__'][$topicField]['name']; // set the topic image if topic_image category property exists $items[$k]['topicimage'] = (isset($items[$k]['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']) && isset($items[$k]['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'])) ? $items[$k]['__CATEGORIES__'][$topicField]['__ATTRIBUTES__']['topic_image'] : ''; // set the topic description if exists $items[$k]['topictext'] = isset($items[$k]['__CATEGORIES__'][$topicField]['display_desc'][$lang]) ? $items[$k]['__CATEGORIES__'][$topicField]['display_desc'][$lang] : ''; // set the path of the topic $items[$k]['topicpath'] = isset($items[$k]['__CATEGORIES__'][$topicField]['path_relative']) ? $items[$k]['__CATEGORIES__'][$topicField]['path_relative'] : ''; // set the url to search for this topic if (System::getVar('shorturls', false)) { $items[$k]['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $items[$k]['topicpath']))); } else { $items[$k]['topicsearchurl'] = DataUtil::formatForDisplay(ModUtil::url('News', 'user', 'view', array('prop' => $topicField, 'cat' => $items[$k]['topicid']))); } } else { $items[$k]['topicid'] = null; $items[$k]['topicname'] = ''; $items[$k]['topicimage'] = ''; $items[$k]['topictext'] = ''; $items[$k]['topicpath'] = ''; $items[$k]['topicsearchurl'] = ''; } // Optional new image if the difference in days from the publishing date and now < the specified limit $items[$k]['dispnewimage'] = ($this->dispnewimage && DateUtil::getDatetimeDiff_AsField($items[$k]['from'], DateUtil::getDatetime(), 3) < (int) $this->newimagelimit); // Wrap the title if needed $items[$k]['titlewrapped'] = false; if ((int) $this->maxtitlelength > 0 && strlen($items[$k]['title']) > (int) $this->maxtitlelength) { // wrap the title $items[$k]['title'] = substr($items[$k]['title'], 0, (int) $this->maxtitlelength); $items[$k]['titlewrapped'] = true; //$items[$k]['title'] .= $this->titlewraptext; } // Get the user information from the author id if ($this->dispuname) { if ($items[$k]['cr_uid'] == 0) { $items[$k]['uname'] = $anonymous; $items[$k]['aid_name'] = $anonymous; } else { $user = UserUtil::getVars($items[$k]['cr_uid']); $items[$k]['uname'] = $user['uname']; $items[$k]['aid_name'] = $user['uname']; } } // Get the optional commentcount if EZComments is available if ($this->dispcomments && ModUtil::available('EZComments')) { $items[$k]['comments'] = ModUtil::apiFunc('EZComments', 'user', 'countitems', array('mod' => 'News', 'objectid' => $items[$k]['sid'], 'status' => 0)); } // Optional display of the hometext (frontpage teaser) if ($this->disphometext) { if ($this->maxhometextlength > 0 && strlen(strip_tags($items[$k]['hometext'])) > (int) $this->maxhometextlength) { $items[$k]['hometextwrapped'] = true; } } $items[$k]['readperm'] = (SecurityUtil::checkPermission('News::', "$items[$k][cr_uid]::$items[$k][sid]", ACCESS_READ)); } if ($this->dispuname || $this->dispdate || $this->dispreads || $this->dispcomments) { $this->view->assign('dispinfo', true); $this->view->assign('dispuname', $this->dispuname); $this->view->assign('dispdate', $this->dispdate); $this->view->assign('dispreads', $this->dispreads); $this->view->assign('dispcomments', $this->dispcomments); $this->view->assign('dispsplitchar', $this->dispsplitchar); } else { $this->view->assign('dispinfo', false); } if ($this->dispnewimage) { $this->view->assign('newimageset', $this->newimageset); $this->view->assign('newimagesrc', $this->newimagesrc); } $this->view->assign('disphometext', $this->disphometext); if ($this->disphometext) { $this->view->assign('hometextwraptext', $this->hometextwraptext); $this->view->assign('maxhometextlength', $this->maxhometextlength); } $this->view->assign('titlewraptext', $this->titlewraptext); } $this->view->assign('News', ModUtil::getVar('News')); $this->view->assign('dateformat', $this->dateformat); $this->view->assign('linktosubmit', $this->linktosubmit); $this->view->assign('stories', $items); $this->view->assign('title', $this->title); $this->view->assign('displayStoryImage', $this->displayStoryImage); $this->view->assign('useshorturls', System::getVar('shorturls', false)); return $this->view->fetch($this->getTemplate()); }
/** * Smarty function to display an editable dynamic user data field. * * Example * {duditemmodify propattribute='avatar'} * * Example * {duditemmodify propattribute='realname' uid=$uid} * * Example * {duditemmodify item=$item} * * Parameters passed in via the $params array: * ------------------------------------------- * string item The Profile DUD item. * string uid User ID to display the field value for (-1 = do not load). * string class CSS class to assign to the table row/form row div (optional). * string proplabel Property label to display (optional overrides the preformated dud item $item). * string propattribute Property attribute to display. * string error Property error message. * * @param array $params All attributes passed to this function from the template. * @param object &$smarty Reference to the Zikula_View/Smarty object. * * @return string|boolean The results of the module function; empty string if the Profile module is not available; false if error. */ function smarty_function_duditemmodify($params, &$smarty) { extract($params); unset($params); if (!ModUtil::available('Profile')) { return ''; } if (!isset($item)) { if (isset($proplabel)) { $item = ModUtil::apiFunc('Profile', 'user', 'get', array('proplabel' => $proplabel)); } else if (isset($propattribute)) { $item = ModUtil::apiFunc('Profile', 'user', 'get', array('propattribute' => $propattribute)); } else { return false; } } if (!isset($item) || empty ($item)) { return false; } // detect if we are in the registration form $onregistrationform = false; // TODO - will these globals always be available? Is there a utility method out there somewhere to get these? global $module, $func; if (strtolower($module) == 'users' && strtolower($func) == 'register') { $onregistrationform = true; } // skip the field if not configured to be on the registration form if ($onregistrationform && !$item['prop_required']) { $dudregshow = ModUtil::getVar('Profile', 'dudregshow', array()); if (!in_array($item['prop_id'], $dudregshow)) { return ''; } } $dom = ZLanguage::getModuleDomain('Profile'); if (!isset($uid)) { $uid = UserUtil::getVar('uid'); } if (!isset($class) || !is_string($class)) { $class = ''; } if (isset($item['temp_propdata'])) { $uservalue = $item['temp_propdata']; } elseif ($uid >= 0) { // TODO - This is a bit of a hack for admin editing. Need to know if it is a reg. $user = UserUtil::getVars($uid); $isRegistration = UserUtil::isRegistration($uid); $uservalue = UserUtil::getVar($item['prop_attribute_name'], $uid, false, $isRegistration); // ($alias, $uid); } // try to get the DUD output if it's Third Party if ($item['prop_dtype'] != 1) { $output = ModUtil::apiFunc($item['prop_modname'], 'dud', 'edit', array('item' => $item, 'uservalue' => $uservalue, 'class' => $class)); if ($output) { return $output; } } $render = $smarty;//Zikula_View::getInstance('Profile', false, null, true); // assign the default values for the control $render->assign('class', $class); $render->assign('value', DataUtil::formatForDisplay($uservalue)); $render->assign('attributename', $item['prop_attribute_name']); $render->assign('proplabeltext', $item['prop_label']); $render->assign('note', $item['prop_note']); $render->assign('required', (bool)$item['prop_required']); $render->assign('error', isset($error) ? $error : ''); // Excluding Timezone of the generics if ($item['prop_attribute_name'] == 'tzoffset') { if (empty($uservalue)) { $uservalue = UserUtil::getVar('tzoffset') ? UserUtil::getVar('tzoffset') : System::getVar('timezone_offset'); } $tzinfo = DateUtil::getTimezones(); $render->assign('value', isset($tzinfo["$uservalue"]) ? "$uservalue" : null); $render->assign('selectmultiple', ''); $render->assign('listoptions', array_keys($tzinfo)); $render->assign('listoutput', array_values($tzinfo)); return $render->fetch('profile_dudedit_select.tpl'); } if ($item['prop_attribute_name'] == 'avatar') { // detect if it's the registration form to skip this if ($onregistrationform) { return ''; } // only shows a link to the Avatar module if available if (ModUtil::available('Avatar')) { // TODO Add a change-link to the admins // only shows the link for the own user if (UserUtil::getVar('uid') != $uid) { return ''; } $render->assign('linktext', __('Go to the Avatar manager', $dom)); $render->assign('linkurl', ModUtil::url('Avatar', 'user', 'main')); $output = $render->fetch('profile_dudedit_link.tpl'); // add a hidden input if this is required if ($item['prop_required']) { $output .= $render->fetch('profile_dudedit_hidden.tpl'); } return $output; } // display the avatar selector if (empty($uservalue)) { $uservalue = 'gravatar.gif'; } $render->assign('value', DataUtil::formatForDisplay($uservalue)); $avatarPath = ModUtil::getVar(Users_Constant::MODNAME, Users_Constant::MODVAR_AVATAR_IMAGE_PATH, Users_Constant::DEFAULT_AVATAR_IMAGE_PATH); $filelist = FileUtil::getFiles($avatarPath, false, true, array('gif', 'jpg', 'png'), 'f'); asort($filelist); $listoutput = $listoptions = $filelist; // strip the extension of the output list foreach ($listoutput as $k => $output) { $listoutput[$k] = $output;//substr($output, 0, strrpos($output, '.')); } $selectedvalue = $uservalue; // if (in_array($uservalue, $filelist)) { // $selectedvalue = $uservalue; // } $render->assign('value', $selectedvalue); $render->assign('selectmultiple', ''); $render->assign('listoptions', $listoptions); $render->assign('listoutput', $listoutput); return $render->fetch('profile_dudedit_select.tpl'); } switch ($item['prop_displaytype']) { case 0: // TEXT $type = 'text'; break; case 1: // TEXTAREA $type = 'textarea'; break; case 2: // CHECKBOX $type = 'checkbox'; $editlabel = array_splice(explode('@@', $item['prop_listoptions']), 0, 1); if (!empty($editlabel[0])) { $render->assign('proplabeltext', __($editlabel[0], $dom)); } break; case 3: // RADIO $type = 'radio'; $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); $render->assign('listoptions', array_keys($options)); $render->assign('listoutput', array_values($options)); break; case 4: // SELECT $type = 'select'; if (DataUtil::is_serialized($uservalue)) { $render->assign('value', unserialize($uservalue)); } // multiple flag is the first field $options = explode('@@', $item['prop_listoptions'], 2); $selectmultiple = $options[0] ? ' multiple="multiple"' : ''; $render->assign('selectmultiple', $selectmultiple); $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); $render->assign('listoptions', array_keys($options)); $render->assign('listoutput', array_values($options)); break; case 5: // DATE $type = 'date'; // gets the format to use $format = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); switch (trim(strtolower($format))) { case 'datelong': //! This is from the core domain (datelong) $format = __('%A, %B %d, %Y'); break; case 'datebrief': //! This is from the core domain (datebrief) $format = __('%b %d, %Y'); break; case 'datestring': //! This is from the core domain (datestring) $format = __('%A, %B %d @ %H:%M:%S'); break; case 'datestring2': //! This is from the core domain (datestring2) $format = __('%A, %B %d'); break; case 'datetimebrief': //! This is from the core domain (datetimebrief) $format = __('%b %d, %Y - %I:%M %p'); break; case 'datetimelong': //! This is from the core domain (datetimelong) $format = __('%A, %B %d, %Y - %I:%M %p'); break; case 'timebrief': //! This is from the core domain (timebrief) $format = __('%I:%M %p'); break; case 'timelong': //! This is from the core domain (timelong) $format = __('%T %p'); break; } //! This is from the core domain (datebrief) $format = !empty($format) ? $format : __('%b %d, %Y'); // process the temporal data if any $timestamp = null; if (isset($item['temp_propdata'])) { $timestamp = DateUtil::parseUIDate($item['temp_propdata']); $uservalue = DateUtil::transformInternalDate($timestamp); } elseif (!empty($uservalue)) { $timestamp = DateUtil::makeTimestamp($uservalue); } $render->assign('value', $uservalue); $render->assign('timestamp', $timestamp); $render->assign('dudformat', $format); break; case 6: // EXTDATE (deprecated) // TODO [deprecate completely] $type = 'hidden'; break; case 7: // MULTICHECKBOX $type = 'multicheckbox'; $render->assign('value', (array)unserialize($uservalue)); $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); $render->assign('fields', $options); break; default: // TEXT $type = 'text'; break; } return $render->fetch('profile_dudedit_'.$type.'.tpl'); }
/** * Smarty function to display an editable dynamic user data field. * * Example * {duditemdisplay propattribute='avatar'} * * Example * {duditemdisplay propattribute='realname' uid=$uid} * * Example * {duditemdisplay item=$item} * * Parameters passed in the $params array: * --------------------------------------- * string item The Profile DUD item. * string userinfo The userinfo information [if not set uid must be specified]. * string uid User ID to display the field value for (-1 = do not load). * string proplabel Property label to display (optional overrides the preformated dud item $item). * string propattribute Property attribute to display. * string default Default content for an empty DUD. * boolean showlabel Show the label? default = true. * * @param array $params All attributes passed to this function from the template. * @param object &$smarty Reference to the Zikula_View/Smarty object. * * @return string|boolean The results of the module function; empty string if the Profile module is not available; false if error. */ function smarty_function_duditemdisplay($params, &$smarty) { extract($params); unset($params); if (!ModUtil::available('Profile')) { return ''; } if (!isset($item)) { if (isset($proplabel)) { $item = ModUtil::apiFunc('Profile', 'user', 'get', array('proplabel' => $proplabel)); } else if (isset($propattribute)) { $item = ModUtil::apiFunc('Profile', 'user', 'get', array('propattribute' => $propattribute)); } else { return false; } } if (!isset($item) || empty ($item)) { return false; } $dom = ZLanguage::getModuleDomain('Profile'); // check for a template set if (!isset($tplset)) { $tplset = 'profile_duddisplay'; } // a default value if the user data is empty if (!isset($default)) { $default = ''; } if (!isset($uid)) { $uid = UserUtil::getVar('uid'); } if (!isset($userinfo)) { $userinfo = UserUtil::getVars($uid); } // get the value of this field from the userinfo array if (isset($userinfo['__ATTRIBUTES__'][$item['prop_attribute_name']])) { $uservalue = $userinfo['__ATTRIBUTES__'][$item['prop_attribute_name']]; } elseif (isset($userinfo[$item['prop_attribute_name']])) { // user's temp view for non-approved users needs this $uservalue = $userinfo[$item['prop_attribute_name']]; } else { // can be a non-marked checkbox in the user temp data $uservalue = ''; } // try to get the DUD output if it's Third Party if ($item['prop_dtype'] != 1) { $output = ModUtil::apiFunc($item['prop_modname'], 'dud', 'edit', array('item' => $item, 'userinfo' => $userinfo, 'uservalue' => $uservalue, 'default' => $default)); if ($output) { return $output; } } // build the output $output = ''; $render = Zikula_View::getInstance('Profile', false, null, true); $render->assign('item', $item); $render->assign('userinfo', $userinfo); $render->assign('uservalue', $uservalue); // detects the template to use $template = $tplset.'_'.$item['prop_id'].'.tpl'; if (!$render->template_exists($template)) { $template = $tplset.'_generic.tpl'; } $output = ''; // checks the different attributes and types // avatar if ($item['prop_attribute_name'] == 'avatar') { $baseurl = System::getBaseUrl(); $avatarpath = ModUtil::getVar(Users_Constant::MODNAME, Users_Constant::MODVAR_AVATAR_IMAGE_PATH, Users_Constant::DEFAULT_AVATAR_IMAGE_PATH); if (empty($uservalue)) { $uservalue = 'blank.png'; } $output = "<img alt=\"\" src=\"{$baseurl}{$avatarpath}/{$uservalue}\" />"; } elseif ($item['prop_attribute_name'] == 'tzoffset') { // timezone if (empty($uservalue)) { $uservalue = UserUtil::getVar('tzoffset') ? UserUtil::getVar('tzoffset') : System::getVar('timezone_offset'); } $output = DateUtil::getTimezoneText($uservalue); if (!$output) { return ''; } } elseif ($item['prop_displaytype'] == 2) { // checkbox $default = array('No', 'Yes'); $output = array_splice(explode('@@', $item['prop_listoptions']), 1); if (!is_array($output) || count($output) < 2) { $output = $default; } $output = isset($output[(int)$uservalue]) && !empty($output[(int)$uservalue]) ? __($output[(int)$uservalue], $dom) : __($default[(int)$uservalue], $dom); } elseif ($item['prop_displaytype'] == 3) { // radio $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); // process the user value and get the translated label $output = isset($options[$uservalue]) ? $options[$uservalue] : $default; } elseif ($item['prop_displaytype'] == 4) { // select $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); // process the user values and get the translated label $uservalue = @unserialize($uservalue); $output = array(); foreach ((array)$uservalue as $id) { if (isset($options[$id])) { $output[] = $options[$id]; } } } elseif (!empty($uservalue) && $item['prop_displaytype'] == 5) { // date $format = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); //! This is from the core domain (datebrief) $format = !empty($format) ? $format : __('%b %d, %Y'); $output = DateUtil::getDatetime(strtotime($uservalue), $format); } elseif ($item['prop_displaytype'] == 7) { // multicheckbox $options = ModUtil::apiFunc('Profile', 'dud', 'getoptions', array('item' => $item)); // process the user values and get the translated label $uservalue = @unserialize($uservalue); $output = array(); foreach ((array)$uservalue as $id) { if (isset($options[$id])) { $output[] = $options[$id]; } } } elseif ($item['prop_attribute_name'] == 'url') { // url if (!empty($uservalue) && $uservalue != 'http://') { //! string to describe the user's site $output = '<a href="'.DataUtil::formatForDisplay($uservalue).'" title="'.__f("%s's site", $userinfo['uname'], $dom).'" rel="nofollow">'.DataUtil::formatForDisplay($uservalue).'</a>'; } } elseif (empty($uservalue)) { // process the generics $output = $default; } elseif (DataUtil::is_serialized($uservalue) || is_array($uservalue)) { // serialized data $uservalue = !is_array($uservalue) ? unserialize($uservalue) : $uservalue; $output = array(); foreach ((array)$uservalue as $option) { $output[] = __($option, $dom); } } else { // a string $output .= __($uservalue, $dom); } // omit this field if is empty after the process if (empty($output)) { return ''; } return $render->assign('output', is_array($output) ? $output : array($output)) ->fetch($template); }
* * ***************************************************************************/ if (!defined('IN_PHPBB')) { die("Hacking attempt"); exit; } if (empty($_GET[POST_USERS_URL]) || $_GET[POST_USERS_URL] == ANONYMOUS) { message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']); } // Begin PNphpBB2 Module // $profiledata = get_userdata($_GET[POST_USERS_URL]); $profiledata = phpbb_get_userdata($_GET[POST_USERS_URL]); $uid = $_GET['u']; if ($uid) { $userVars = UserUtil::getVars($uid); if (!$profiledata['user_from']) { $profiledata['user_from'] = $userVars['_YLOCATION']; } if (!$profiledata['url']) { $profiledata['url'] = $userVars['_YOURHOMEPAGE']; } if (!$profiledata['user_avatar']) { $profiledata['user_avatar'] = $userVars['_YOURAVATAR']; } if (!$profiledata['user_icq']) { $profiledata['user_icq'] = $userVars['_YICQ']; } if (!$profiledata['user_aim']) { $profiledata['user_aim'] = $userVars['_YAIM']; }
/** * Prepare comments to be displayed * * We loop through the "raw data" returned from the API to prepare these data * to be displayed. * We check for necessary rights, and derive additional information (e.g. user * data) drom other modules. * * @param $items An array of comment items as returned from the API * @return array An array to display (augmented information / perm. check) * @since 0.2 */ public function prepareCommentsForDisplay($items) { $itemKeys = array_keys($items); foreach ($itemKeys as $k) { if ($items[$k]['uid'] > 0) { // get the user vars and merge into the comment array $userinfo = UserUtil::getVars($items[$k]['uid']); // the users url will clash with the comment url so lets move it out of the way $userinfo['website'] = isset($userinfo['__ATTRIBUTES__']['url']) ? $userinfo['__ATTRIBUTES__']['url'] : ''; // work out if the user is online $userinfo['online'] = false; if (ModUtil::available('Profile')) { if (ModUtil::apiFunc('Profile', 'memberslist', 'isonline', array('userid' => $userinfo['uid']))) { $userinfo['online'] = true; } } $items[$k] = array_merge($items[$k], $userinfo); $items[$k]['anonname'] = ''; } else { // put the generic name if anonymous, uname is empty $items[$k]['uname'] = ''; $items[$k]['anonname'] = !empty($items[$k]['anonname']) ? $items[$k]['anonname'] : System::getVar('anonymous'); } $items[$k]['del'] = $this->checkPermission( array('module' => $items[$k]['modname'], 'objectid' => $items[$k]['objectid'], 'commentid' => $items[$k]['id'], 'uid' => $items[$k]['uid'], 'level' => ACCESS_DELETE)); } return $items; }
/** * Edició d'un usuari del catàleg * * > Obre el formulari per a editar l'usuari triat amb les dades que tenia. * * ### Paràmetres rebuts per GET: * * integer **uid** uid de l'usuari triat. * * @return void Plantilla *Cataleg_admin_addeditUser.tpl* per a editar les dades */ public function editUser() { if (!SecurityUtil::checkPermission('Cataleg::', '::', ACCESS_ADMIN)) { return LogUtil::registerPermissionError(); } $gestor = (SecurityUtil::checkPermission('CatalegAdmin::', '::', ACCESS_ADMIN)) ? true : false; $uid = FormUtil::getPassedValue('uid', null, 'GET'); $grupCat = ModUtil::apiFunc('Cataleg', 'admin', 'getgrupsZikula'); $allGroupsUnits = ModUtil::apiFunc('Cataleg', 'admin', 'getAllGroupsUnits'); $catUsersList = UserUtil::getUsersForGroup($grupCat['Sirius']); if (!in_array($uid, $catUsersList)) { LogUtil::registerError($this->__('No existeix cap usuari del catàleg amb l\'identificador indicat.')); return system::redirect(ModUtil::url('Cataleg', 'admin', 'usersgest')); } //Només els gestors-administradors poden editar altres gestors if (!SecurityUtil::checkPermission('CatalegAdmin::', '::', ACCESS_ADMIN)) { $gestorUsersList = UserUtil::getUsersForGroup($grupCat['Gestors']); if (in_array($uid, $gestorUsersList)) { LogUtil::registerError($this->__('Només els gestors-administradors poden editar altres gestors.')); return system::redirect(ModUtil::url('Cataleg', 'admin', 'usersgest')); } } $user = UserUtil::getVars($uid); $user['iw'] = DBUtil::selectObject('IWusers', 'iw_uid = ' . $uid); $user['pw'] = (DBUtil::selectField('users','pass','uid = '.$uid) != '' ? true: false); $grups = UserUtil::getGroupsForUser($uid); $uni = array(); foreach ($grups as $grup) { ($grupCat['Generics'] == $grup) ? $gr['Generics'] = 1 : false; ($grupCat['Personals'] == $grup) ? $gr['Personals'] = 1 : false; ($grupCat['Gestform'] == $grup) ? $gr['Gestform'] = 1 : false; ($grupCat['LectorsCat'] == $grup) ? $gr['LectorsCat'] = 1 : false; ($grupCat['EditorsCat'] == $grup) ? $gr['EditorsCat'] = 1 : false; ($grupCat['Gestors'] == $grup) ? $gr['Gestors'] = 1 : false; ($grupCat['Odissea'] == $grup) ? $gr['Odissea'] = 1 : false; ($grupCat['Cert'] == $grup) ? $gr['Cert'] = 1 : false; ($grupCat['gA'] == $grup) ? $gr['gA'] = 1 : false; ($grupCat['gB'] == $grup) ? $gr['gB'] = 1 : false; if (isset($allGroupsUnits[$grup])) { $uni[$grup]['gid'] = $grup; $uni[$grup]['name'] = $allGroupsUnits[$grup]['name']; } } $user['gr'] = $gr; $user['uni'] = $uni; $minpass = ModUtil::getVar('Users', 'minpass'); $gtafInfo = ModUtil::apiFunc($this->name,'admin','getGtafInfo'); $this->view->assign('gtafInfo',$gtafInfo); $this->view->assign('edit', true); $this->view->assign('minpass', $minpass); $this->view->assign('gestor', $gestor); $this->view->assign('user', $user); $this->view->assign('grupCat', $grupCat); $this->view->assign('allGroupsUnits', $allGroupsUnits); return $this->view->fetch('admin/Cataleg_admin_addeditUser.tpl'); }
/** * Display item. * * Parameters passed via the $args array, or via GET: * -------------------------------------------------- * numeric uid The user account id (uid) of the user for whom to display profile information; optional, ignored if uname is supplied, if not provided * and if uname is not supplied then defaults to the current user. * string uname The user name of the user for whom to display profile information; optional, if not supplied, then uid is used to determine the user. * string page The name of the Profile "page" (view template) to display; optional, if not provided then the standard view template is used. * * @param array $args All parameters passed to this function via an internal call. * * @return string The rendered template output. */ public function view($args) { // Security check if (!SecurityUtil::checkPermission('Profile::view', '::', ACCESS_READ)) { return LogUtil::registerPermissionError(); } // Get parameters from whatever input we need. $uid = (int)$this->request->getGet()->get('uid', isset($args['uid']) ? $args['uid'] : null); $uname = $this->request->getGet()->get('uname', isset($args['uname']) ? $args['uname'] : null); $page = $this->request->getGet()->get('page', isset($args['page']) ? $args['page'] : null); // Getting uid by uname if (!empty($uname)) { $uid = UserUtil::getIdFromName($uname); } elseif (empty($uid)) { $uid = UserUtil::getVar('uid'); } // Check for an invalid uid (uid = 1 is the anonymous user) if ($uid < 2) { return LogUtil::registerError($this->__('Error! Could not find this user.'), 404); } // Get all the user data $userinfo = UserUtil::getVars($uid); if (!$userinfo) { return LogUtil::registerError($this->__('Error! Could not find this user.'), 404); } // Check if the user is watching its own profile or if he is admin // TODO maybe remove the four lines below $currentuser = UserUtil::getVar('uid'); $ismember = ($currentuser >= 2); $isowner = ($currentuser == $uid); $isadmin = SecurityUtil::checkPermission('Profile::', '::', ACCESS_ADMIN); // Get all active profile fields $activeduds = ModUtil::apiFunc('Profile', 'user', 'getallactive', array('get' => 'viewable', 'uid' => $uid)); // Fill the DUD values array $dudarray = array(); foreach (array_keys($activeduds) as $dudattr) { $dudarray[$dudattr] = isset($userinfo['__ATTRIBUTES__'][$dudattr]) ? $userinfo['__ATTRIBUTES__'][$dudattr] : ''; } // Create output object $this->view->setCaching(false)->add_core_data(); $this->view->assign('dudarray', $dudarray) ->assign('fields', $activeduds) ->assign('uid', $userinfo['uid']) ->assign('uname', $userinfo['uname']) ->assign('userinfo', $userinfo) ->assign('ismember', $ismember) ->assign('isadmin', $isadmin) ->assign('sameuser', $isowner); // Return the output that has been generated by this function if (!empty($page)) { if ($this->view->template_exists("profile_user_view_{$page}.tpl")) { return $this->view->fetch("profile_user_view_{$page}.tpl", $uid); } else { return LogUtil::registerError($this->__f('Error! Could not find profile page [%s].', DataUtil::formatForDisplay($page)), 404); } } return $this->view->fetch('profile_user_view.tpl', $uid); }
/** * Get all the headlines of the notes * @author: Albert Pérez Monfort (aperezm@xtec.cat) * @return: An array with the headlines information */ public function getalltitulars() { // Security check if (!SecurityUtil::checkPermission('IWnoteboard::', '::', ACCESS_READ)) { return LogUtil::registerPermissionError(); } $pntable = DBUtil::getTables(); $c = $pntable['IWnoteboard_column']; $time = time(); $where = "$c[titulin]<$time AND $c[titulout]>$time AND $c[titular]<>'' AND $c[caduca]>$time"; $orderby = "$c[titulin] desc"; if (ModUtil::getVar('IWnoteboard', 'multiLanguage') == 1) { $userdata = UserUtil::getVars(UserUtil::getVar('uid')); $locale = $userdata['locale']; $where .= " AND $c[lang]='$locale' OR $c[lang] = ''"; } $items = DBUtil::selectObjectArray('IWnoteboard', $where, $orderby, '-1', '-1', 'nid'); // Check for an error with the database code, and if so set an appropriate // error message and return if ($items === false) { return LogUtil::registerError($this->__('Error! Could not load items.')); } // Return the items return $items; }
/** * Responds to process_edit hook-like event notifications. * * @param Zikula_Event $event The event that triggered this function call. * * @return void * * @throws Zikula_Exception_Fatal Thrown if a user account does not exist for the uid specified by the event. */ public function processEdit(Zikula_Event $event) { $activePolicies = $this->helper->getActivePolicies(); $eventName = $event->getName(); if (isset($this->validation) && !$this->validation->hasErrors()) { $user = $event->getSubject(); $uid = $user['uid']; if (!UserUtil::isLoggedIn()) { if (($eventName == 'module.users.ui.process_edit.login_screen') || ($eventName == 'module.users.ui.process_edit.login_block')) { $policiesAcceptedAtLogin = $this->validation->getObject(); $nowUTC = new DateTime('now', new DateTimeZone('UTC')); $nowUTCStr = $nowUTC->format(DateTime::ISO8601); if ($activePolicies['termsOfUse'] && $policiesAcceptedAtLogin['termsOfUse']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $nowUTCStr, $uid); } if ($activePolicies['privacyPolicy'] && $policiesAcceptedAtLogin['privacyPolicy']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $nowUTCStr, $uid); } if ($activePolicies['agePolicy'] && $policiesAcceptedAtLogin['agePolicy']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $nowUTCStr, $uid); } if ($activePolicies['cancellationRightPolicy'] && $policiesAcceptedAtLogin['cancellationRightPolicy']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $nowUTCStr, $uid); } if ($activePolicies['tradeConditions'] && $policiesAcceptedAtLogin['tradeConditions']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $nowUTCStr, $uid); } // Force the reload of the user record $user = UserUtil::getVars($uid, true); } else { $isRegistration = UserUtil::isRegistration($uid); $user = UserUtil::getVars($uid, false, 'uid', $isRegistration); if (!$user) { throw new Zikula_Exception_Fatal(__('A user account or registration does not exist for the specified uid.', $this->domain)); } $policiesAcceptedAtRegistration = $this->validation->getObject(); $nowUTC = new DateTime('now', new DateTimeZone('UTC')); $nowUTCStr = $nowUTC->format(DateTime::ISO8601); if ($activePolicies['termsOfUse'] && $policiesAcceptedAtRegistration['termsOfUse']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $nowUTCStr, $uid); } if ($activePolicies['privacyPolicy'] && $policiesAcceptedAtRegistration['privacyPolicy']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $nowUTCStr, $uid); } if ($activePolicies['agePolicy'] && $policiesAcceptedAtRegistration['agePolicy']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $nowUTCStr, $uid); } if ($activePolicies['cancellationRightPolicy'] && $policiesAcceptedAtRegistration['cancellationRightPolicy']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $nowUTCStr, $uid); } if ($activePolicies['tradeConditions'] && $policiesAcceptedAtRegistration['tradeConditions']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $nowUTCStr, $uid); } // Force the reload of the user record $user = UserUtil::getVars($uid, true, 'uid', $isRegistration); } } else { $isRegistration = UserUtil::isRegistration($uid); $user = UserUtil::getVars($uid, false, 'uid', $isRegistration); if (!$user) { throw new Zikula_Exception_Fatal(__('A user account or registration does not exist for the specified uid.', $this->domain)); } $policiesAcceptedAtRegistration = $this->validation->getObject(); $editablePolicies = $this->helper->getEditablePolicies(); $nowUTC = new DateTime('now', new DateTimeZone('UTC')); $nowUTCStr = $nowUTC->format(DateTime::ISO8601); if ($activePolicies['termsOfUse'] && $editablePolicies['termsOfUse']) { if ($policiesAcceptedAtRegistration['termsOfUse']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $nowUTCStr, $uid); } elseif (($policiesAcceptedAtRegistration['termsOfUse'] === 0) || ($policiesAcceptedAtRegistration['termsOfUse'] === "0")) { UserUtil::delVar(Legal_Constant::ATTRIBUTE_TERMSOFUSE_ACCEPTED, $uid); } } if ($activePolicies['privacyPolicy'] && $editablePolicies['privacyPolicy']) { if ($policiesAcceptedAtRegistration['privacyPolicy']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $nowUTCStr, $uid); } elseif (($policiesAcceptedAtRegistration['privacyPolicy'] === 0) || ($policiesAcceptedAtRegistration['termsOfUse'] === "0")) { UserUtil::delVar(Legal_Constant::ATTRIBUTE_PRIVACYPOLICY_ACCEPTED, $uid); } } if ($activePolicies['agePolicy'] && $editablePolicies['agePolicy']) { if ($policiesAcceptedAtRegistration['agePolicy']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $nowUTCStr, $uid); } elseif (($policiesAcceptedAtRegistration['agePolicy'] === 0) || ($policiesAcceptedAtRegistration['termsOfUse'] === "0")) { UserUtil::delVar(Legal_Constant::ATTRIBUTE_AGEPOLICY_CONFIRMED, $uid); } } if ($activePolicies['cancellationRightPolicy'] && $editablePolicies['cancellationRightPolicy']) { if ($policiesAcceptedAtRegistration['cancellationRightPolicy']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $nowUTCStr, $uid); } elseif (($policiesAcceptedAtRegistration['cancellationRightPolicy'] === 0) || ($policiesAcceptedAtRegistration['cancellationRightPolicy'] === "0")) { UserUtil::delVar(Legal_Constant::ATTRIBUTE_CANCELLATIONRIGHTPOLICY_ACCEPTED, $uid); } } if ($activePolicies['tradeConditions'] && $editablePolicies['tradeConditions']) { if ($policiesAcceptedAtRegistration['tradeConditions']) { UserUtil::setVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $nowUTCStr, $uid); } elseif (($policiesAcceptedAtRegistration['tradeConditions'] === 0) || ($policiesAcceptedAtRegistration['tradeConditions'] === "0")) { UserUtil::delVar(Legal_Constant::ATTRIBUTE_TRADECONDITIONS_ACCEPTED, $uid); } } // Force the reload of the user record $user = UserUtil::getVars($uid, true, 'uid', $isRegistration); } } }
/** * Approves a registration. * * If the registration is also verified (or does not need it) then a new users table record * is created. * * Parameters passed in the $args array: * ------------------------------------- * array $args['reginfo'] An array of registration information containing a valid uid pointing to the registration * record to be approved; optional; if not set, then $args['uid'] should be set. * numeric $args['uid'] The uid of the registration record to be set; optional, used only if $args['reginfo'] not set; if not * set then $args['reginfo'] must be set and have a valid uid. * boolean $args['force'] Force the approval of the registration record; optional; only effective if the current user * is an administrator. * * @param array $args All parameters passed to this function. * * @return bool True on success; otherwise false. * * @throws Zikula_Exception_Forbidden Thrown if the user does not have add access. */ public function approve($args) { if (!SecurityUtil::checkPermission('Users::', '::', ACCESS_ADD)) { throw new Zikula_Exception_Forbidden(); } if (isset($args['reginfo'])) { // Got a full reginfo record if (!is_array($args['reginfo'])) { $this->registerError(LogUtil::getErrorMsgArgs()); return false; } $reginfo = $args['reginfo']; if (!$reginfo || !is_array($reginfo) || !isset($reginfo['uid']) || !is_numeric($reginfo['uid'])) { $this->registerError($this->__('Error! Invalid registration record.')); return false; } } elseif (!isset($args['uid']) || !is_numeric($args['uid']) || ((int)$args['uid'] != $args['uid'])) { $this->registerError(LogUtil::getErrorMsgArgs()); return false; } else { // Got just an id. $reginfo = ModUtil::apiFunc($this->name, 'registration', 'get', array('uid' => $args['uid'])); if (!$reginfo) { $this->registerError($this->__f('Error! Unable to retrieve registration record with id \'%1$s\'', $id)); return false; } } $nowUTC = new DateTime(null, new DateTimeZone('UTC')); $reginfo['approved_by'] = UserUtil::getVar('uid'); UserUtil::setVar('approved_by', $reginfo['approved_by'], $reginfo['uid']); $reginfo['approved_date'] = $nowUTC->format(Users_Constant::DATETIME_FORMAT); UserUtil::setVar('approved_date', $reginfo['approved_date'], $reginfo['uid']); $reginfo = UserUtil::getVars($reginfo['uid'], true, 'uid', true); if (isset($args['force']) && $args['force']) { if (!isset($reginfo['email']) || empty($reginfo['email'])) { $this->registerError($this->__f('Error: Unable to force registration for \'%1$s\' to be verified during approval. No e-mail address.', array($reginfo['uname']))); return false; } $reginfo['isverified'] = true; ModUtil::apiFunc($this->name, 'user', 'resetVerifyChgFor', array( 'uid' => $reginfo['uid'], 'changetype'=> Users_Constant::VERIFYCHGTYPE_REGEMAIL, )); } if ($reginfo['isverified']) { $reginfo = $this->createUser($reginfo); } return $reginfo; }
/** * compose a message * * @author The PostNuke Development Team * @param integer $tid the ID of the item to display * @return output The item detail page */ public function compose($args) { $reply = FormUtil::getPassedValue('reply', isset($args['reply']) ? $args['reply'] : 0, 'GETPOST'); $replied = FormUtil::getPassedValue('replied', isset($args['replied']) ? $args['replied'] : 0, 'POST'); $send = FormUtil::getPassedValue('send', isset($args['send']) ? $args['send'] : null, 'POST'); $msg_id = FormUtil::getPassedValue('msg_id', isset($args['msg_id']) ? $args['msg_id'] : null, 'REQUEST'); $uname = FormUtil::getPassedValue('uname', isset($args['uname']) ? $args['uname'] : null, 'REQUEST'); $message = FormUtil::getPassedValue('message', isset($args['message']) ? $args['message'] : null, 'POST'); $touser = FormUtil::getPassedValue('touser', isset($args['touser']) ? $args['touser'] : null, 'POST'); $to_group = FormUtil::getPassedValue('to_group', isset($args['to_group']) ? $args['to_group'] : null, 'POST'); $image = FormUtil::getPassedValue('image', isset($args['image']) ? $args['image'] : null, 'POST'); $inici = FormUtil::getPassedValue('inici', isset($args['inici']) ? $args['inici'] : null, 'REQUEST'); $rpp = FormUtil::getPassedValue('rpp', isset($args['rpp']) ? $args['rpp'] : null, 'REQUEST'); $inicisend = FormUtil::getPassedValue('inicisend', isset($args['inicisend']) ? $args['inicisend'] : null, 'REQUEST'); $rppsend = FormUtil::getPassedValue('rppsend', isset($args['rppsend']) ? $args['rppsend'] : null, 'REQUEST'); $filtersend = FormUtil::getPassedValue('filtersend', isset($args['filtersend']) ? $args['filtersend'] : null, 'REQUEST'); $filter = FormUtil::getPassedValue('filter', isset($args['filter']) ? $args['filter'] : null, 'REQUEST'); if (!SecurityUtil::checkPermission('IWmessages::', $uname . '::', ACCESS_COMMENT)) { throw new Zikula_Exception_Forbidden(); } $groupsMulti_array = array(); $canUpdate = ''; $subject = ''; $icons = false; $touser = ''; $toUserFixed = false; $fromuser = ''; if (isset($uname) && $uname != '') $touser = $uname; $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $groupsInfo = ModUtil::func('IWmain', 'user', 'getAllGroupsInfo', array('sv' => $sv)); $month_long = explode(' ', $this->__('January February March April May June July August September October November December')); if ($reply == 1) { $replied = $msg_id; // The API function is called. The arguments to the function are passed in // as their own arguments array $item = ModUtil::apiFunc('IWmessages', 'user', 'get', array('uid' => UserUtil::getVar('uid'), 'msgid' => $msg_id)); $fromuserdata = UserUtil::getVars($item['from_userid']); $touserdata = UserUtil::getVars($item['to_userid']); $user_id = UserUtil::getVar('uid'); if (UserUtil::isLoggedIn() && ($user_id != $touserdata['uid'])) { LogUtil::registerError($this->__('You can\'t reply to that message. It wasn\'t sent to you.')); return System::redirect(ModUtil::url('IWmessages', 'user', 'view')); } $fromuser = $fromuserdata['uname']; if (strpos($item['subject'], 'Re:') === false) { $reText = $this->__('Re') . ': '; } $subject = $reText . $item['subject']; if (!empty($uname)) { $view->assign('touser', $uname); } $text = preg_replace('/(<br[ \/]*?>)/i', '', $item['msg_text']); $text = DataUtil::formatForDisplayHTML($text); $text = eregi_replace('\[addsig]', '', $text); $text = nl2br($text); $row['msg_time'] = mktime(substr($item['msg_time'], 11, 2), // hour substr($item['msg_time'], 14, 2), // minute '0', // second substr($item['msg_time'], 5, 2), // month substr($item['msg_time'], 8, 2), // day substr($item['msg_time'], 0, 4)); // year $userTime = $row['msg_time']; $reply = "[quote=$fromuserdata[uname] " . $this->__('wrote') . ' ' . $this->__('on') . ' ' . date('d/', $userTime) . $month_long[date('m', $userTime) - 1] . date('/Y - H.i', $userTime) . "]<br />" . '<div class="messageBody">' . $text . "</div><br />[/quote]<br />" . $item['reply']; } else { $reply = false; } if ($this->getVar('smiliesActive')) { $icons = ModUtil::apiFunc('IWmain', 'user', 'getAllIcons'); } // assign the username if both present and valid if (!empty($uname)) { // we call the API to check if the uname is valid $uid = UserUtil::getIdFromName($uname); if (isset($uid)) { $toUserFixed = true; $touser = $uname; } } if (empty($msg_id)) { $msg_id = ''; } //Check if the user can upload files $groupsCanUpdate = ModUtil::getVar('IWmessages', 'groupsCanUpdate'); $multiMail = ModUtil::getVar('IWmessages', 'multiMail'); $groupsUpdate = explode('$$', substr($groupsCanUpdate, 0, -1)); array_shift($groupsUpdate); foreach ($groupsUpdate as $update) { $names = explode('|', $update); $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $isMember = ModUtil::func('IWmain', 'user', 'isMember', array('uid' => UserUtil::getVar('uid'), 'gid' => $names[0], 'sgid' => $names[1], 'sv' => $sv)); if ($isMember) { $canUpdate = true; break; } } //Check if the user can send mails to multi users $multiMail = explode('$$', substr($multiMail, 0, -1)); array_shift($multiMail); sort($multiMail); $allGroups = false; foreach ($multiMail as $multi) { $names = explode('-', $multi); $names1 = explode('|', $names[0]); $names2 = explode('|', $names[1]); $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $isMember = ModUtil::func('IWmain', 'user', 'isMember', array('uid' => UserUtil::getVar('uid'), 'gid' => $names1[0], 'sgid' => $names1[1], 'sv' => $sv)); if ($isMember) { if ($names2[0] == 0 && $names2[1] == 0) { $allGroups = true; break; } $gn2 = $groupsInfo[$names2[0]]; $groupsMulti_array[] = array('id' => $names2[0] . '|' . $names2[1], 'name' => $gn2); } } if ($allGroups) { $sv = ModUtil::func('IWmain', 'user', 'genSecurityValue'); $grups = ModUtil::func('IWmain', 'user', 'getAllGroups', array('sv' => $sv)); $groupsMulti_array = array(); $groupsMulti_array[] = array('id' => "0|0", 'name' => $this->__('To all users')); foreach ($grups as $grup) { $groupsMulti_array[] = array('id' => $grup['id'] . '|0', 'name' => $grup['name']); } } $canMulti = (count($groupsMulti_array) > 0) ? true : false; $photosFolder = ModUtil::getVar('IWmessages', 'photosFolder'); $multiMail = ModUtil::getVar('IWmessages', 'multiMail'); return $this->view->assign('replied', $replied) ->assign('groupsMulti', $groupsMulti_array) ->assign('canUpdate', $canUpdate) ->assign('canMulti', $canMulti) ->assign('msgid', $msg_id) ->assign('extensions', ModUtil::getVar('IWmain', 'extensions')) ->assign('message', $message) ->assign('touser', $touser) ->assign('to_group', $to_group) ->assign('image', $image) ->assign('inici', $inici) ->assign('inicisend', $inicisend) ->assign('filter', $filter) ->assign('filtersend', $filtersend) ->assign('rpp', $rpp) ->assign('subject', $subject) ->assign('rppsend', $rppsend) ->assign('dissableSuggest', ModUtil::getVar('IWmessages', 'dissableSuggest')) ->assign('reply', $reply) ->assign('reply1', htmlspecialchars($reply)) ->assign('icons', $icons) ->assign('touser', $touser) ->assign('toUserFixed', $toUserFixed) ->assign('fromuser', $fromuser) ->fetch('IWmessages_user_new.tpl'); }
/** * Get all user variables, maps new style attributes to old style user data. * * @deprecated * @see UserUtil::getVars() * * @param uid $ the user id of the user * @return array an associative array with all variables for a user */ function pnUserGetVars($id, $force = false, $idfield = '') { LogUtil::log(__f('Warning! Function %1$s is deprecated. Please use %2$s instead.', array(__FUNCTION__, 'UserUtil::getVars()')), E_USER_DEPRECATED); return UserUtil::getVars($id, $force, $idfield); }