/** * Display user index page. */ function index() { $this->validate(); $user =& Request::getUser(); $userId = $user->getId(); $setupIncomplete = array(); $submissionsCount = array(); $isValid = array(); $schedConfsToDisplay = array(); $conferencesToDisplay = array(); $roleDao =& DAORegistry::getDAO('RoleDAO'); $schedConfDao =& DAORegistry::getDAO('SchedConfDAO'); $this->setupTemplate(); $templateMgr =& TemplateManager::getManager(); $conference =& Request::getConference(); $templateMgr->assign('helpTopicId', 'user.userHome'); $allConferences = $allSchedConfs = array(); if ($conference == null) { // Curently at site level unset($conference); // Show roles for all conferences $conferenceDao =& DAORegistry::getDAO('ConferenceDAO'); $conferences =& $conferenceDao->getConferences(); // Fetch the user's roles for each conference while ($conference =& $conferences->next()) { $conferenceId = $conference->getId(); $schedConfId = 0; // First, the generic roles for this conference $roles =& $roleDao->getRolesByUserId($userId, $conferenceId, 0); if (!empty($roles)) { $conferencesToDisplay[$conferenceId] =& $conference; $rolesToDisplay[$conferenceId] =& $roles; } // Determine if conference setup is incomplete, to provide a message for JM $setupIncomplete[$conferenceId] = $this->checkIncompleteSetup($conference); $this->getRoleDataForConference($userId, $conferenceId, $schedConfId, $submissionsCount, $isValid); // Second, scheduled conference-specific roles // TODO: don't display scheduled conference roles if granted at conference level too? $schedConfs =& $schedConfDao->getSchedConfsByConferenceId($conferenceId); while ($schedConf =& $schedConfs->next()) { $schedConfId = $schedConf->getId(); $schedConfRoles =& $roleDao->getRolesByUserId($userId, $conferenceId, $schedConfId); if (!empty($schedConfRoles)) { $schedConfsToDisplay[$conferenceId][$schedConfId] =& $schedConf; $this->getRoleDataForConference($userId, $conferenceId, $schedConfId, $submissionsCount, $isValid); } $allSchedConfs[$conference->getId()][$schedConf->getId()] =& $schedConf; unset($schedConf); } // If the user has Sched. Conf. roles and no Conf. roles, push the conf. object // into the conference array so it gets shown if (empty($roles) && !empty($schedConfsToDisplay[$conferenceId])) { $conferencesToDisplay[$conferenceId] =& $conference; } $allConferences[$conference->getId()] =& $conference; unset($schedConfs); unset($conference); } $templateMgr->assign('showAllConferences', 1); $templateMgr->assign_by_ref('userConferences', $conferencesToDisplay); } else { // Currently within a conference's context $conferenceId = $conference->getId(); $userConferences = array($conference); $this->getRoleDataForConference($userId, $conferenceId, 0, $submissionsCount, $isValid); $schedConfs =& $schedConfDao->getSchedConfsByConferenceId($conferenceId); while ($schedConf =& $schedConfs->next()) { $schedConfId = $schedConf->getId(); $schedConfRoles =& $roleDao->getRolesByUserId($userId, $conferenceId, $schedConfId); if (!empty($schedConfRoles)) { $this->getRoleDataForConference($userId, $conferenceId, $schedConfId, $submissionsCount, $isValid); $schedConfsToDisplay[$conferenceId][$schedConfId] =& $schedConf; } unset($schedConf); } $schedConf =& Request::getSchedConf(); if ($schedConf) { import('schedConf.SchedConfAction'); $templateMgr->assign('allowRegAuthor', SchedConfAction::allowRegAuthor($schedConf)); $templateMgr->assign('allowRegReviewer', SchedConfAction::allowRegReviewer($schedConf)); $templateMgr->assign('submissionsOpen', SchedConfAction::submissionsOpen($schedConf)); } $templateMgr->assign_by_ref('userConferences', $userConferences); } $templateMgr->assign('isSiteAdmin', $roleDao->getRole(0, 0, $userId, ROLE_ID_SITE_ADMIN)); $templateMgr->assign('allConferences', $allConferences); $templateMgr->assign('allSchedConfs', $allSchedConfs); $templateMgr->assign('userSchedConfs', $schedConfsToDisplay); $templateMgr->assign('isValid', $isValid); $templateMgr->assign('submissionsCount', $submissionsCount); $templateMgr->assign('setupIncomplete', $setupIncomplete); $templateMgr->display('user/index.tpl'); }
/** * Save profile settings. */ function execute() { $user =& Request::getUser(); $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setLastName($this->getData('lastName')); $user->setGender($this->getData('gender')); $user->setInitials($this->getData('initials')); $user->setAffiliation($this->getData('affiliation')); $user->setSignature($this->getData('signature'), null); // Localized $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setCountry($this->getData('country')); $user->setTimeZone($this->getData('timeZone')); $user->setBiography($this->getData('biography'), null); // Localized $user->setInterests($this->getData('interests'), null); // Localized $site =& Request::getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (Locale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); $userDao =& DAORegistry::getDAO('UserDAO'); $userDao->updateObject($user); $roleDao =& DAORegistry::getDAO('RoleDAO'); $schedConfDao =& DAORegistry::getDAO('SchedConfDAO'); // Roles $schedConf =& Request::getSchedConf(); if ($schedConf) { import('schedConf.SchedConfAction'); $role = new Role(); $role->setUserId($user->getId()); $role->setConferenceId($schedConf->getConferenceId()); $role->setSchedConfId($schedConf->getId()); if (SchedConfAction::allowRegReviewer($schedConf)) { $role->setRoleId(ROLE_ID_REVIEWER); $hasRole = Validation::isReviewer(); $wantsRole = Request::getUserVar('reviewerRole'); if ($hasRole && !$wantsRole) { $roleDao->deleteRole($role); } if (!$hasRole && $wantsRole) { $roleDao->insertRole($role); } } if (SchedConfAction::allowRegAuthor($schedConf)) { $role->setRoleId(ROLE_ID_AUTHOR); $hasRole = Validation::isAuthor(); $wantsRole = Request::getUserVar('authorRole'); if ($hasRole && !$wantsRole) { $roleDao->deleteRole($role); } if (!$hasRole && $wantsRole) { $roleDao->insertRole($role); } } if (SchedConfAction::allowRegReader($schedConf)) { $role->setRoleId(ROLE_ID_READER); $hasRole = Validation::isReader(); $wantsRole = Request::getUserVar('readerRole'); if ($hasRole && !$wantsRole) { $roleDao->deleteRole($role); } if (!$hasRole && $wantsRole) { $roleDao->insertRole($role); } } } $openAccessNotify = Request::getUserVar('openAccessNotify'); $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO'); $schedConfs =& $schedConfDao->getSchedConfs(); $schedConfs =& $schedConfs->toArray(); foreach ($schedConfs as $thisSchedConf) { if ($thisSchedConf->getSetting('enableOpenAccessNotification') == true) { $currentlyReceives = $user->getSetting('openAccessNotification', $thisSchedConf->getId()); $shouldReceive = !empty($openAccessNotify) && in_array($thisSchedConf->getId(), $openAccessNotify); if ($currentlyReceives != $shouldReceive) { $userSettingsDao->updateSetting($user->getId(), 'openAccessNotification', $shouldReceive, 'bool', $thisSchedConf->getId()); } } } if ($user->getAuthId()) { $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $auth =& $authDao->getPlugin($user->getAuthId()); } if (isset($auth)) { $auth->doSetUserInfo($user); } }
/** * Register a new user. */ function execute() { $requireValidation = Config::getVar('email', 'require_validation'); if ($this->existingUser) { // Existing user in the system $userDao =& DAORegistry::getDAO('UserDAO'); $user =& $userDao->getUserByUsername($this->getData('username')); if ($user == null) { return false; } $userId = $user->getId(); } else { // New user $user = new User(); $user->setUsername($this->getData('username')); $user->setSalutation($this->getData('salutation')); $user->setFirstName($this->getData('firstName')); $user->setMiddleName($this->getData('middleName')); $user->setInitials($this->getData('initials')); $user->setLastName($this->getData('lastName')); $user->setGender($this->getData('gender')); $user->setAffiliation($this->getData('affiliation')); $user->setSignature($this->getData('signature'), null); // Localized $user->setEmail($this->getData('email')); $user->setUrl($this->getData('userUrl')); $user->setPhone($this->getData('phone')); $user->setFax($this->getData('fax')); $user->setMailingAddress($this->getData('mailingAddress')); $user->setBiography($this->getData('biography'), null); // Localized $user->setInterests($this->getData('interests'), null); // Localized $user->setDateRegistered(Core::getCurrentDate()); $user->setCountry($this->getData('country')); $site =& Request::getSite(); $availableLocales = $site->getSupportedLocales(); $locales = array(); foreach ($this->getData('userLocales') as $locale) { if (AppLocale::isLocaleValid($locale) && in_array($locale, $availableLocales)) { array_push($locales, $locale); } } $user->setLocales($locales); if (isset($this->defaultAuth)) { $user->setPassword($this->getData('password')); // FIXME Check result and handle failures $this->defaultAuth->doCreateUser($user); $user->setAuthId($this->defaultAuth->authId); } $user->setPassword(Validation::encryptCredentials($this->getData('username'), $this->getData('password'))); if ($requireValidation) { // The account should be created in a disabled // state. $user->setDisabled(true); $user->setDisabledReason(__('user.login.accountNotValidated')); } $userDao =& DAORegistry::getDAO('UserDAO'); $userDao->insertUser($user); $userId = $user->getId(); if (!$userId) { return false; } $sessionManager =& SessionManager::getManager(); $session =& $sessionManager->getUserSession(); $session->setSessionVar('username', $user->getUsername()); } $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); $roleDao =& DAORegistry::getDAO('RoleDAO'); // Roles users are allowed to register themselves in $allowedRoles = array('reader' => 'createAsReader', 'author' => 'createAsAuthor', 'reviewer' => 'createAsReviewer'); import('schedConf.SchedConfAction'); if (!SchedConfAction::allowRegReader($schedConf)) { unset($allowedRoles['reader']); } if (!SchedConfAction::allowRegAuthor($schedConf)) { unset($allowedRoles['author']); } if (!SchedConfAction::allowRegReviewer($schedConf)) { unset($allowedRoles['reviewer']); } foreach ($allowedRoles as $k => $v) { $roleId = $roleDao->getRoleIdFromPath($k); if ($this->getData($v) && !$roleDao->roleExists($conference->getId(), $schedConf->getId(), $userId, $roleId)) { $role = new Role(); $role->setConferenceId($conference->getId()); $role->setSchedConfId($schedConf->getId()); $role->setUserId($userId); $role->setRoleId($roleId); $roleDao->insertRole($role); } } if (!$this->existingUser) { $this->sendConfirmationEmail($user, $this->getData('password'), $this->getData('sendPassword')); } if (isset($allowedRoles['reader']) && $this->getData('openAccessNotification')) { $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO'); $userSettingsDao->updateSetting($userId, 'openAccessNotification', true, 'bool', $conference->getId()); } }
/** * Save profile settings. */ function execute($request) { $user = $this->getUser(); $user->setTimeZone($this->getData('timeZone')); $roleDao = DAORegistry::getDAO('RoleDAO'); $schedConfDao = DAORegistry::getDAO('SchedConfDAO'); // Roles $schedConf = Request::getSchedConf(); if ($schedConf) { import('classes.schedConf.SchedConfAction'); $role = new Role(); $role->setUserId($user->getId()); $role->setConferenceId($schedConf->getConferenceId()); $role->setSchedConfId($schedConf->getId()); if (SchedConfAction::allowRegReviewer($schedConf)) { $role->setRoleId(ROLE_ID_REVIEWER); $hasRole = Validation::isReviewer(); $wantsRole = Request::getUserVar('reviewerRole'); if ($hasRole && !$wantsRole) { $roleDao->deleteRole($role); } if (!$hasRole && $wantsRole) { $roleDao->insertRole($role); } } if (SchedConfAction::allowRegAuthor($schedConf)) { $role->setRoleId(ROLE_ID_AUTHOR); $hasRole = Validation::isAuthor(); $wantsRole = Request::getUserVar('authorRole'); if ($hasRole && !$wantsRole) { $roleDao->deleteRole($role); } if (!$hasRole && $wantsRole) { $roleDao->insertRole($role); } } if (SchedConfAction::allowRegReader($schedConf)) { $role->setRoleId(ROLE_ID_READER); $hasRole = Validation::isReader(); $wantsRole = Request::getUserVar('readerRole'); if ($hasRole && !$wantsRole) { $roleDao->deleteRole($role); } if (!$hasRole && $wantsRole) { $roleDao->insertRole($role); } } } $openAccessNotify = Request::getUserVar('openAccessNotify'); $userSettingsDao = DAORegistry::getDAO('UserSettingsDAO'); $schedConfs = $schedConfDao->getAll(); $schedConfs = $schedConfs->toArray(); foreach ($schedConfs as $thisSchedConf) { if ($thisSchedConf->getSetting('enableOpenAccessNotification') == true) { $currentlyReceives = $user->getSetting('openAccessNotification', $thisSchedConf->getId()); $shouldReceive = !empty($openAccessNotify) && in_array($thisSchedConf->getId(), $openAccessNotify); if ($currentlyReceives != $shouldReceive) { $userSettingsDao->updateSetting($user->getId(), 'openAccessNotification', $shouldReceive, 'bool', $thisSchedConf->getId()); } } } parent::execute($request); }