コード例 #1
0
ファイル: ProfileForm.inc.php プロジェクト: jmacgreg/ocs
 /**
  * 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);
     }
 }
コード例 #2
0
 /**
  * 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());
     }
 }
コード例 #3
0
ファイル: ProfileForm.inc.php プロジェクト: artkuo/ocs
 /**
  * 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);
 }