当前位置: 首页>>代码示例>>PHP>>正文


PHP Role::setJournalId方法代码示例

本文整理汇总了PHP中Role::setJournalId方法的典型用法代码示例。如果您正苦于以下问题:PHP Role::setJournalId方法的具体用法?PHP Role::setJournalId怎么用?PHP Role::setJournalId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Role的用法示例。


在下文中一共展示了Role::setJournalId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Role

 /**
  * Internal function to return a Role object from a row.
  * @param $row array
  * @return Role
  */
 function &_returnRoleFromRow(&$row)
 {
     $role = new Role();
     $role->setJournalId($row['journal_id']);
     $role->setUserId($row['user_id']);
     $role->setRoleId($row['role_id']);
     HookRegistry::call('RoleDAO::_returnRoleFromRow', array(&$role, &$row));
     return $role;
 }
开发者ID:philschatz,项目名称:ojs,代码行数:14,代码来源:RoleDAO.inc.php

示例2: createData

 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     // Add initial site data
     $locale = $this->getParam('locale');
     $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
     $site = new Site();
     $site->setRedirect(0);
     $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
     $site->setPrimaryLocale($locale);
     $site->setInstalledLocales($this->installedLocales);
     $site->setSupportedLocales($this->installedLocales);
     if (!$siteDao->insertSite($site)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
     $siteSettingsDao->updateSetting('title', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
     $siteSettingsDao->updateSetting('contactName', array($locale => __(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
     $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
     // Add initial site administrator user
     $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
     $user = new User();
     $user->setUsername($this->getParam('adminUsername'));
     $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
     $user->setFirstName($user->getUsername());
     $user->setLastName('');
     $user->setEmail($this->getParam('adminEmail'));
     if (!$userDao->insertUser($user)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
     $role = new Role();
     $role->setJournalId(0);
     $role->setUserId($user->getId());
     $role->setRoleId(ROLE_ID_SITE_ADMIN);
     if (!$roleDao->insertRole($role)) {
         $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
         return false;
     }
     // Install email template list and data for each locale
     $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
     $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
     foreach ($this->installedLocales as $locale) {
         $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
     }
     // Install filters and filter templates.
     $this->installFilterTemplates();
     return true;
 }
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:54,代码来源:Install.inc.php

示例3: execute

 /**
  * Register a new user.
  */
 function execute()
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     if (isset($this->userId)) {
         $user =& $userDao->getById($this->userId);
     }
     if (!isset($user)) {
         $user = new User();
     }
     $user->setSalutation($this->getData('salutation'));
     $user->setFirstName($this->getData('firstName'));
     $user->setMiddleName($this->getData('middleName'));
     $user->setLastName($this->getData('lastName'));
     $user->setInitials($this->getData('initials'));
     $user->setGender($this->getData('gender'));
     $user->setAffiliation($this->getData('affiliation'), null);
     // Localized
     $user->setSignature($this->getData('signature'), null);
     // Localized
     $user->setEmail($this->getData('email'));
     $user->setData('orcid', $this->getData('orcid'));
     $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->setBiography($this->getData('biography'), null);
     // Localized
     $user->setGossip($this->getData('gossip'), null);
     // Localized
     $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0);
     $user->setAuthId((int) $this->getData('authId'));
     $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 ($user->getAuthId()) {
         $authDao =& DAORegistry::getDAO('AuthSourceDAO');
         $auth =& $authDao->getPlugin($user->getAuthId());
     }
     if ($user->getId() != null) {
         $userId = $user->getId();
         if ($this->getData('password') !== '') {
             if (isset($auth)) {
                 $auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
                 $user->setPassword(Validation::encryptCredentials($userId, Validation::generatePassword()));
                 // Used for PW reset hash only
             } else {
                 $user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
             }
         }
         if (isset($auth)) {
             // FIXME Should try to create user here too?
             $auth->doSetUserInfo($user);
         }
         $userDao->updateObject($user);
     } else {
         $user->setUsername($this->getData('username'));
         if ($this->getData('generatePassword')) {
             $password = Validation::generatePassword();
             $sendNotify = true;
         } else {
             $password = $this->getData('password');
             $sendNotify = $this->getData('sendNotify');
         }
         if (isset($auth)) {
             $user->setPassword($password);
             // FIXME Check result and handle failures
             $auth->doCreateUser($user);
             $user->setAuthId($auth->authId);
             $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
             // Used for PW reset hash only
         } else {
             $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password));
         }
         $user->setDateRegistered(Core::getCurrentDate());
         $userId = $userDao->insertUser($user);
         $isManager = Validation::isJournalManager();
         if (!empty($this->_data['enrollAs'])) {
             foreach ($this->getData('enrollAs') as $roleName) {
                 // Enroll new user into an initial role
                 $roleDao =& DAORegistry::getDAO('RoleDAO');
                 $roleId = $roleDao->getRoleIdFromPath($roleName);
                 if (!$isManager && $roleId != ROLE_ID_READER) {
                     continue;
                 }
                 if ($roleId != null) {
                     $role = new Role();
                     $role->setJournalId($journal->getId());
                     $role->setUserId($userId);
                     $role->setRoleId($roleId);
//.........这里部分代码省略.........
开发者ID:EreminDm,项目名称:water-cao,代码行数:101,代码来源:UserManagementForm.inc.php

示例4: execute

 /**
  * Register a new user.
  */
 function execute()
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $journal =& Request::getJournal();
     if (isset($this->userId)) {
         $user =& $userDao->getUser($this->userId);
     }
     if (!isset($user)) {
         $user = new User();
     }
     $user->setSalutation($this->getData('salutation'));
     $user->setFirstName($this->getData('firstName'));
     $user->setMiddleName($this->getData('middleName'));
     $user->setLastName($this->getData('lastName'));
     $user->setInitials($this->getData('initials'));
     $user->setGender($this->getData('gender'));
     $user->setAffiliation($this->getData('affiliation'), null);
     // Localized
     $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->setBiography($this->getData('biography'), null);
     // Localized
     $user->setGossip($this->getData('gossip'), null);
     // Localized
     $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0);
     $user->setAuthId((int) $this->getData('authId'));
     $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);
     if ($user->getAuthId()) {
         $authDao =& DAORegistry::getDAO('AuthSourceDAO');
         $auth =& $authDao->getPlugin($user->getAuthId());
     }
     if ($user->getId() != null) {
         $userId = $user->getId();
         if ($this->getData('password') !== '') {
             if (isset($auth)) {
                 $auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
                 $user->setPassword(Validation::encryptCredentials($userId, Validation::generatePassword()));
                 // Used for PW reset hash only
             } else {
                 $user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
             }
         }
         if (isset($auth)) {
             // FIXME Should try to create user here too?
             $auth->doSetUserInfo($user);
         }
         $userDao->updateObject($user);
     } else {
         $user->setUsername($this->getData('username'));
         if ($this->getData('generatePassword')) {
             $password = Validation::generatePassword();
             $sendNotify = true;
         } else {
             $password = $this->getData('password');
             $sendNotify = $this->getData('sendNotify');
         }
         if (isset($auth)) {
             $user->setPassword($password);
             // FIXME Check result and handle failures
             $auth->doCreateUser($user);
             $user->setAuthId($auth->authId);
             $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
             // Used for PW reset hash only
         } else {
             $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password));
         }
         $user->setDateRegistered(Core::getCurrentDate());
         $userId = $userDao->insertUser($user);
         $isManager = Validation::isJournalManager();
         // EL on March 13th 2013
         // If this is used, it should be totally modified
         if (!empty($this->_data['enrollAs'])) {
             foreach ($this->getData('enrollAs') as $roleName) {
                 // Enroll new user into an initial role
                 $roleDao =& DAORegistry::getDAO('RoleDAO');
                 $roleId = $roleDao->getRoleIdFromPath($roleName);
                 if (!$isManager && $roleId != ROLE_ID_READER) {
                     continue;
                 }
                 if ($roleId != null) {
                     $role = new Role();
                     $role->setJournalId($journal->getId());
                     $role->setUserId($userId);
//.........这里部分代码省略.........
开发者ID:elavaud,项目名称:hrp_ct,代码行数:101,代码来源:UserManagementForm.inc.php

示例5: execute

 /**
  * Save journal settings.
  */
 function execute()
 {
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     if (isset($this->journalId)) {
         $journal =& $journalDao->getJournal($this->journalId);
     }
     if (!isset($journal)) {
         $journal = new Journal();
     }
     $journal->setPath($this->getData('journalPath'));
     $journal->setEnabled($this->getData('enabled'));
     if ($journal->getId() != null) {
         $isNewJournal = false;
         $journalDao->updateJournal($journal);
         $section = null;
     } else {
         $isNewJournal = true;
         $site =& Request::getSite();
         // Give it a default primary locale
         $journal->setPrimaryLocale($site->getPrimaryLocale());
         $journalId = $journalDao->insertJournal($journal);
         $journalDao->resequenceJournals();
         // Make the site administrator the journal manager of newly created journals
         $sessionManager =& SessionManager::getManager();
         $userSession =& $sessionManager->getUserSession();
         if ($userSession->getUserId() != null && $userSession->getUserId() != 0 && !empty($journalId)) {
             $role = new Role();
             $role->setJournalId($journalId);
             $role->setUserId($userSession->getUserId());
             $role->setRoleId(ROLE_ID_JOURNAL_MANAGER);
             $roleDao =& DAORegistry::getDAO('RoleDAO');
             $roleDao->insertRole($role);
         }
         // Make the file directories for the journal
         import('lib.pkp.classes.file.FileManager');
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId);
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/articles');
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/journals/' . $journalId . '/issues');
         FileManager::mkdir(Config::getVar('files', 'public_files_dir') . '/journals/' . $journalId);
         // Install default journal settings
         $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
         $titles = $this->getData('title');
         AppLocale::requireComponents(array(LOCALE_COMPONENT_OJS_DEFAULT, LOCALE_COMPONENT_APPLICATION_COMMON));
         $journalSettingsDao->installSettings($journalId, 'registry/journalSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'journalPath' => $this->getData('journalPath'), 'primaryLocale' => $site->getPrimaryLocale(), 'journalName' => $titles[$site->getPrimaryLocale()]));
         // Install the default RT versions.
         import('classes.rt.ojs.JournalRTAdmin');
         $journalRtAdmin = new JournalRTAdmin($journalId);
         $journalRtAdmin->restoreVersions(false);
         // Create a default "Articles" section
         $sectionDao =& DAORegistry::getDAO('SectionDAO');
         $section = new Section();
         $section->setJournalId($journal->getId());
         $section->setTitle(__('section.default.title'), $journal->getPrimaryLocale());
         $section->setAbbrev(__('section.default.abbrev'), $journal->getPrimaryLocale());
         $section->setMetaIndexed(true);
         $section->setMetaReviewed(true);
         $section->setPolicy(__('section.default.policy'), $journal->getPrimaryLocale());
         $section->setEditorRestricted(false);
         $section->setHideTitle(false);
         $sectionDao->insertSection($section);
     }
     $journal->updateSetting('title', $this->getData('title'), 'string', true);
     $journal->updateSetting('description', $this->getData('description'), 'string', true);
     // Make sure all plugins are loaded for settings preload
     PluginRegistry::loadAllPlugins();
     HookRegistry::call('JournalSiteSettingsForm::execute', array(&$this, &$journal, &$section, &$isNewJournal));
 }
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:70,代码来源:JournalSiteSettingsForm.inc.php

示例6: implicitAuthAdmin

 function implicitAuthAdmin($userID, $authStr)
 {
     $adminstr = Config::getVar('security', "implicit_auth_admin_list");
     $adminlist = explode(" ", $adminstr);
     $key = array_search($authStr, $adminlist);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     // If they are in the list of users who should be admins
     if ($key !== false) {
         // and if they are not already an admin
         if (!$roleDao->userHasRole(0, $userID, ROLE_ID_SITE_ADMIN)) {
             syslog(LOG_ERR, "Implicit Auth - Making Admin: " . $userID);
             // make them an admin
             $role = new Role();
             $role->setJournalId(0);
             $role->setUserId($userID);
             $role->setRoleId(ROLE_ID_SITE_ADMIN);
             $roleDao->insertRole($role);
         }
     } else {
         // If they are not in the admin list - then be sure they are not an admin in the role table
         syslog(LOG_ERR, "removing admin for: " . $userID);
         $roleDao->deleteRoleByUserId($userID, 0, ROLE_ID_SITE_ADMIN);
     }
 }
开发者ID:EreminDm,项目名称:water-cao,代码行数:24,代码来源:ShibAuthPlugin.inc.php

示例7: importUsers

 function importUsers()
 {
     assert($this->xml->name == 'users');
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $userDAO =& DAORegistry::getDAO('UserDAO');
     $publicFileManager =& new PublicFileManager();
     $site =& Request::getSite();
     $siteSupportedLocales = $site->getSupportedLocales();
     $this->nextElement();
     while ($this->xml->name == 'user') {
         $userXML = $this->getCurrentElementAsDom();
         $username = (string) $userXML->username;
         $email = (string) $userXML->email;
         $userByEmail = $userDAO->getUserByEmail($email);
         $user = null;
         if (!empty($userByEmail)) {
             $user = $userByEmail;
         } else {
             $user = new User();
             $user->setUsername((string) $userXML->username);
             $user->setPassword((string) $userXML->password);
             $user->setSalutation((string) $userXML->salutation);
             $user->setFirstName((string) $userXML->firstName);
             $user->setMiddleName((string) $userXML->middleName);
             $user->setInitials((string) $userXML->initials);
             $user->setLastName((string) $userXML->lastName);
             $user->setSuffix((string) $userXML->suffix);
             $user->setGender((string) $userXML->gender);
             $user->setEmail((string) $userXML->email);
             $user->setUrl((string) $userXML->url);
             $user->setPhone((string) $userXML->phone);
             $user->setFax((string) $userXML->fax);
             $user->setMailingAddress((string) $userXML->mailingAddress);
             $user->setBillingAddress((string) $userXML->billingAddress);
             $user->setCountry((string) $userXML->country);
             $locales = array();
             foreach (explode(':', (string) $userXML->locales) as $locale) {
                 if (AppLocale::isLocaleValid($locale) && in_array($locale, $siteSupportedLocales)) {
                     array_push($locales, $locale);
                 }
             }
             $user->setLocales($locales);
             $user->setDateLastEmail((string) $userXML->dateLastEmail);
             $user->setDateRegistered((string) $userXML->dateRegistered);
             $user->setDateValidated((string) $userXML->dateValidated);
             $user->setDateLastLogin((string) $userXML->dateLastLogin);
             $user->setMustChangePassword((int) $userXML->mustChangePassword);
             $user->setDisabled((int) $userXML->disabled);
             $user->setDisabledReason((string) $userXML->disabledReason);
             $user->setAuthId((int) $userXML->authId);
             $user->setAuthStr((string) $userXML->authStr);
             $user->setInlineHelp((int) $userXML->inlineHelp);
             $this->generateUsername($user);
             $userDAO->insertUser($user);
             $this->restoreDataObjectSettings($userDAO, $userXML->settings, 'user_settings', 'user_id', $user->getId());
             $user = $userDAO->getById($user->getId());
             $profileImage =& $user->getSetting('profileImage');
             if ($profileImage) {
                 $oldProfileImage = $profileImage['uploadName'];
                 $extension = $publicFileManager->getExtension($oldProfileImage);
                 $newProfileImage = 'profileImage-' . $user->getId() . "." . $extension;
                 $sourceFile = $this->siteFolderPath . '/' . $oldProfileImage;
                 $publicFileManager->copyFile($sourceFile, $publicFileManager->getSiteFilesPath() . "/" . $newProfileImage);
                 unlink($sourceFile);
                 $profileImage['uploadName'] = $newProfileImage;
                 $user->updateSetting('profileImage', $profileImage);
             }
             $interests = array();
             foreach ($userXML->interest as $interest) {
                 $interests[] = (string) $interest;
             }
             $interestManager->setInterestsForUser($user, $interests);
         }
         $this->idTranslationTable->register(INTERNAL_TRANSFER_OBJECT_USER, (int) $userXML->oldId, $user->getId());
         foreach ($userXML->role as $roleXML) {
             $role = new Role();
             $role->setRoleId((int) $roleXML);
             $role->setUserId($user->getId());
             $role->setJournalId($this->journal->getId());
             $roleDao->insertRole($role);
         }
         $this->nextElement();
     }
 }
开发者ID:ulsdevteam,项目名称:fullJournalTransfer,代码行数:86,代码来源:XMLDisassembler.inc.php

示例8: enroll

 /**
  * Enroll a user in a role.
  * Last update: EL on February 14th 2013
  */
 function enroll($args)
 {
     $this->validate();
     $roleId = (int) (isset($args[0]) ? $args[0] : Request::getUserVar('roleId'));
     // Get a list of users to enroll -- either from the
     // submitted array 'users', or the single user ID in
     // 'userId'
     $users = Request::getUserVar('users');
     if (!isset($users) && Request::getUserVar('userId') != null) {
         $users = array(Request::getUserVar('userId'));
     }
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     $journal =& $journalDao->getJournalByPath(Request::getRequestedJournalPath());
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $rolePath = $roleDao->getRolePath($roleId);
     // Added by EL on April 24, 2012
     // Management of the ERC Member Status
     $sectionEditorsDAO =& DAORegistry::getDAO('SectionEditorsDAO');
     // Added by EL on February 13th 2013
     // Management of the erc for the reviewers
     $ercReviewersDAO =& DAORegistry::getDAO('ErcReviewersDAO');
     $ercMemberStatus =& Request::getUserVar('ercMemberStatus');
     $ethicsCommitteeId =& Request::getUserVar('ethicsCommittee');
     // the role path "reviewer" includes all the erc members but also the secretaries
     // if the enrollment concern secretaries, the role path and the role id is further modified
     if ($users != null && is_array($users) && $rolePath == 'reviewer') {
         // Check if info provided
         if (!empty($ethicsCommitteeId) && !empty($ercMemberStatus) && $ethicsCommitteeId != "NA" && $ercMemberStatus != "NA") {
             if ($ercMemberStatus == "Chair" or $ercMemberStatus == "Vice-Chair" or $ercMemberStatus == "Member") {
                 $reviewers = $ercReviewersDAO->getReviewersBySectionId($journal->getId(), $ethicsCommitteeId);
                 $chairs = $ercReviewersDAO->getReviewersBySectionIdByStatus($journal->getId(), $ethicsCommitteeId, 1);
                 $viceChairs = $ercReviewersDAO->getReviewersBySectionIdByStatus($journal->getId(), $ethicsCommitteeId, 2);
                 // Here the number of members per committee is set to 20,
                 // and of chair or vice-chair to 1
                 if (count($reviewers) + count($users) < 21 && $ercMemberStatus == "Member" || count($chairs) + count($users) < 2 && $ercMemberStatus == "Chair" || count($viceChairs) + count($users) < 2 && $ercMemberStatus == "Vice-Chair") {
                     for ($i = 0; $i < count($users); $i++) {
                         if (!$ercReviewersDAO->ercReviewerExists($journal->getId(), $ethicsCommitteeId, $users[$i])) {
                             if (!$roleDao->roleExists($journal->getId(), $users[$i], $roleId)) {
                                 // Create the role and insert it
                                 $role = new Role();
                                 $role->setJournalId($journal->getId());
                                 $role->setUserId($users[$i]);
                                 $role->setRoleId($roleId);
                                 $roleDao->insertRole($role);
                             }
                             // Assign the reviewer to the specified committee
                             if ($ercMemberStatus == "Chair") {
                                 $status = 1;
                             } elseif ($ercMemberStatus == "Vice-Chair") {
                                 $status = 2;
                             } elseif ($ercMemberStatus == "Member") {
                                 $status = 3;
                             }
                             $ercReviewersDAO->insertReviewer($journal->getId(), $ethicsCommitteeId, $users[$i], $status);
                         }
                     }
                 }
             } elseif ($ercMemberStatus == "Secretary") {
                 //Get all the secretaries already enrolled in this particular committee
                 $secretaries = $sectionEditorsDAO->getEditorsBySectionId($journal->getId(), $ethicsCommitteeId);
                 // The role id and the role path is modified
                 $roleId = ROLE_ID_SECTION_EDITOR;
                 $rolePath = $roleDao->getRolePath($roleId);
                 //Here, the number of secretaries per committee is limited to 5
                 if (count($secretaries) + count($users) < 6) {
                     for ($i = 0; $i < count($users); $i++) {
                         if (!$roleDao->roleExists($journal->getId(), $users[$i], $roleId) && !$sectionEditorsDAO->ercSecretaryExists($ethicsCommitteeId, $users[$i])) {
                             // Create the role and insert it
                             $role = new Role();
                             $role->setJournalId($journal->getId());
                             $role->setUserId($users[$i]);
                             $role->setRoleId($roleId);
                             $roleDao->insertRole($role);
                             // Assign the secretary to the specified committee
                             $sectionEditorsDAO->insertEditor($journal->getId(), $ethicsCommitteeId, $users[$i], 1, 1);
                         }
                     }
                 }
             }
         } else {
             Request::redirect(null, null, 'enrollSearch');
         }
     } else {
         if ($users != null && is_array($users) && $roleId == 'ExtReviewer') {
             $roleId = '4096';
             $rolePath = 'extReviewer';
             $userDAO =& DAORegistry::getDAO('UserDAO');
             for ($i = 0; $i < count($users); $i++) {
                 if (!$ercReviewersDAO->ercReviewerExists($journal->getId(), 0, $users[$i])) {
                     if (!$roleDao->roleExists($journal->getId(), $users[$i], $roleId)) {
                         $role = new Role();
                         $role->setJournalId($journal->getId());
                         $role->setUserId($users[$i]);
                         $role->setRoleId($roleId);
                         $roleDao->insertRole($role);
                     }
//.........这里部分代码省略.........
开发者ID:JovanyJeff,项目名称:hrp,代码行数:101,代码来源:PeopleHandler.inc.php

示例9: execute

 /**
  * 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'), null);
     // Localized
     $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->setBiography($this->getData('biography'), null);
     // Localized
     $userId = $user->getId();
     // Insert the user interests
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $interestManager->insertInterests($userId, $this->getData('interestsKeywords'), $this->getData('interests'));
     $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');
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     // Roles
     $journal =& Request::getJournal();
     if ($journal) {
         $role = new Role();
         $role->setUserId($user->getId());
         $role->setJournalId($journal->getId());
         if ($journal->getSetting('allowRegReviewer')) {
             $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 ($journal->getSetting('allowRegAuthor')) {
             $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 ($journal->getSetting('allowRegReader')) {
             $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');
     $journals =& $journalDao->getEnabledJournals();
     $journals =& $journals->toArray();
     foreach ($journals as $thisJournal) {
         if ($thisJournal->getSetting('publishingMode') == PUBLISHING_MODE_SUBSCRIPTION && $thisJournal->getSetting('enableOpenAccessNotification')) {
             $currentlyReceives = $user->getSetting('openAccessNotification', $thisJournal->getJournalId());
             $shouldReceive = !empty($openAccessNotify) && in_array($thisJournal->getJournalId(), $openAccessNotify);
             if ($currentlyReceives != $shouldReceive) {
                 $userSettingsDao->updateSetting($user->getId(), 'openAccessNotification', $shouldReceive, 'bool', $thisJournal->getJournalId());
             }
         }
     }
     if ($user->getAuthId()) {
         $authDao =& DAORegistry::getDAO('AuthSourceDAO');
         $auth =& $authDao->getPlugin($user->getAuthId());
     }
     if (isset($auth)) {
//.........这里部分代码省略.........
开发者ID:master3395,项目名称:CBPPlatform,代码行数:101,代码来源:ProfileForm.inc.php

示例10: execute


//.........这里部分代码省略.........
             }
         }
         $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(Locale::translate('user.login.accountNotValidated'));
         }
         $userDao =& DAORegistry::getDAO('UserDAO');
         $userDao->insertUser($user);
         $userId = $user->getId();
         if (!$userId) {
             return false;
         }
         // Add reviewing interests to interests table
         $interestDao =& DAORegistry::getDAO('InterestDAO');
         $interests = Request::getUserVar('interestsKeywords');
         if (is_array($interests)) {
             $interests = array_map('urldecode', $interests);
             // The interests are coming in encoded -- Decode them for DB storage
             $interestTextOnly = Request::getUserVar('interests');
             if (!empty($interestsTextOnly)) {
                 // If JS is disabled, this will be the input to read
                 $interestsTextOnly = explode(",", $interestTextOnly);
             } else {
                 $interestsTextOnly = null;
             }
             if ($interestsTextOnly && !isset($interests)) {
                 $interests = $interestsTextOnly;
             } elseif (isset($interests) && !is_array($interests)) {
                 $interests = array($interests);
             }
             $interestDao->insertInterests($interests, $user->getId(), true);
         }
         $sessionManager =& SessionManager::getManager();
         $session =& $sessionManager->getUserSession();
         $session->setSessionVar('username', $user->getUsername());
     }
     $journal =& Request::getJournal();
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     // Roles users are allowed to register themselves in
     $allowedRoles = array('reader' => 'registerAsReader', 'author' => 'registerAsAuthor', 'reviewer' => 'registerAsReviewer');
     $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
     if (!$journalSettingsDao->getSetting($journal->getId(), 'allowRegReader')) {
         unset($allowedRoles['reader']);
     }
     if (!$journalSettingsDao->getSetting($journal->getId(), 'allowRegAuthor')) {
         unset($allowedRoles['author']);
     }
     if (!$journalSettingsDao->getSetting($journal->getId(), 'allowRegReviewer')) {
         unset($allowedRoles['reviewer']);
     }
     foreach ($allowedRoles as $k => $v) {
         $roleId = $roleDao->getRoleIdFromPath($k);
         if ($this->getData($v) && !$roleDao->roleExists($journal->getId(), $userId, $roleId)) {
             $role = new Role();
             $role->setJournalId($journal->getId());
             $role->setUserId($userId);
             $role->setRoleId($roleId);
             $roleDao->insertRole($role);
         }
     }
     if (!$this->existingUser) {
         import('classes.mail.MailTemplate');
         if ($requireValidation) {
             // Create an access key
             import('lib.pkp.classes.security.AccessKeyManager');
             $accessKeyManager = new AccessKeyManager();
             $accessKey = $accessKeyManager->createKey('RegisterContext', $user->getId(), null, Config::getVar('email', 'validation_timeout'));
             // Send email validation request to user
             $mail = new MailTemplate('USER_VALIDATE');
             $mail->setFrom($journal->getSetting('contactEmail'), $journal->getSetting('contactName'));
             $mail->assignParams(array('userFullName' => $user->getFullName(), 'supportName' => $journal->getSetting('supportName'), 'activateUrl' => Request::url($journal->getPath(), 'user', 'activateUser', array($this->getData('username'), $accessKey))));
             $mail->addRecipient($user->getEmail(), $user->getFullName());
             $mail->send();
             unset($mail);
         }
         if ($this->getData('sendPassword')) {
             // Send welcome email to user
             $mail = new MailTemplate('USER_REGISTER');
             $mail->setFrom($journal->getSetting('supportEmail'), $journal->getSetting('supportName'));
             $mail->assignParams(array('username' => $this->getData('username'), 'password' => String::substr($this->getData('password'), 0, 30), 'supportName' => $journal->getSetting('supportName'), 'userFullName' => $user->getFullName()));
             $mail->addRecipient($user->getEmail(), $user->getFullName());
             $mail->send();
             unset($mail);
         }
     }
     if (isset($allowedRoles['reader']) && $this->getData('openAccessNotification')) {
         $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
         $userSettingsDao->updateSetting($userId, 'openAccessNotification', true, 'bool', $journal->getId());
     }
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:101,代码来源:RegistrationForm.inc.php

示例11: enroll

 /**
  * Enrollment of a new committee member
  * Last modified: EL on February 17th 2013
  * Originally comming from SubmissionEditHandler
  * (just doing the redirection after the enrollment)
  * Which is not anymore the case
  */
 function enroll($args)
 {
     $sectionId = isset($args[0]) ? (int) $args[0] : 0;
     $journal =& Request::getJournal();
     // For security purposes
     $thisUser =& Request::getUser();
     if ($thisUser->getSecretaryCommitteeId() == $sectionId) {
         $roleDao =& DAORegistry::getDAO('RoleDAO');
         $roleId = $roleDao->getRoleIdFromPath('reviewer');
         // Get all the secretaries enrolled in this specific erc
         $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
         $secretaries = $sectionEditorsDao->getEditorsBySectionId($journal->getId(), $sectionId);
         // Get all the different members enrolled in this specific erc
         $ercReviewersDao =& DAORegistry::getDAO('ErcReviewersDAO');
         $reviewers = $ercReviewersDao->getReviewersBySectionId($journal->getId(), $sectionId);
         $chairs = $ercReviewersDao->getReviewersBySectionIdByStatus($journal->getId(), $sectionId, 1);
         $viceChairs = $ercReviewersDao->getReviewersBySectionIdByStatus($journal->getId(), $sectionId, 2);
         $users = Request::getUserVar('users');
         if (!is_array($users) && Request::getUserVar('userId') != null) {
             $users = array(Request::getUserVar('userId'));
         }
         $ercMemberStatus =& Request::getUserVar('ercStatus');
         // Enroll secretaries
         if ($ercMemberStatus == "Secretary" && count($secretaries) + count($users) < 6) {
             $roleId = $roleDao->getRoleIdFromPath('sectionEditor');
             for ($i = 0; $i < count($users); $i++) {
                 if (!$roleDao->roleExists($journal->getId(), $users[$i], $roleId) && !$sectionEditorsDao->ercSecretaryExists($sectionId, $users[$i])) {
                     $role = new Role();
                     $role->setJournalId($journal->getId());
                     $role->setUserId($users[$i]);
                     $role->setRoleId($roleId);
                     $roleDao->insertRole($role);
                     $sectionEditorsDao->insertEditor($journal->getId(), $sectionId, $users[$i], 1, 1);
                 }
             }
             Request::redirect(null, null, 'section', $sectionId);
         } elseif ($ercMemberStatus == "Chair" && count($chairs) + count($users) < 2 || $ercMemberStatus == "Member" && count($reviewers) + count($users) < 21 || $ercMemberStatus == "Vice-Chair" && count($viceChairs) + count($users) < 2) {
             for ($i = 0; $i < count($users); $i++) {
                 if (!$ercReviewersDao->ercReviewerExists($journal->getId(), $sectionId, $users[$i])) {
                     // Create the role and insert it
                     if (!$roleDao->roleExists($journal->getId(), $users[$i], $roleId)) {
                         $role = new Role();
                         $role->setJournalId($journal->getId());
                         $role->setUserId($users[$i]);
                         $role->setRoleId($roleId);
                         $roleDao->insertRole($role);
                     }
                     // Assign the reviewer to the specified committee
                     if ($ercMemberStatus == "Chair") {
                         $status = 1;
                     } elseif ($ercMemberStatus == "Vice-Chair") {
                         $status = 2;
                     } elseif ($ercMemberStatus == "Member") {
                         $status = 3;
                     }
                     $ercReviewersDao->insertReviewer($journal->getId(), $sectionId, $users[$i], $status);
                 }
             }
             Request::redirect(null, null, 'section', $sectionId);
         }
         Request::redirect(null, null, 'enrollSearch', $sectionId);
     } else {
         Request::redirect(null, 'user');
     }
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:72,代码来源:SectionEditorHandler.inc.php

示例12: execute

 /**
  * Register a new user.
  * @return userId int
  */
 function execute()
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $user = new User();
     $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'), null);
     // Localized
     $user->setEmail($this->getData('email'));
     $user->setData('orcid', $this->getData('orcid'));
     $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->setBiography($this->getData('biography'), null);
     // Localized
     $user->setGossip($this->getData('gossip'), null);
     // Localized
     $authDao =& DAORegistry::getDAO('AuthSourceDAO');
     $auth =& $authDao->getDefaultPlugin();
     $user->setAuthId($auth ? $auth->getAuthId() : 0);
     $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);
     $user->setUsername($this->getData('username'));
     $password = Validation::generatePassword();
     $sendNotify = $this->getData('sendNotify');
     if (isset($auth)) {
         $user->setPassword($password);
         // FIXME Check result and handle failures
         $auth->doCreateUser($user);
         $user->setAuthId($auth->authId);
         $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
         // Used for PW reset hash only
     } else {
         $user->setPassword(Validation::encryptCredentials($this->getData('username'), $password));
     }
     $user->setMustChangePassword(isset($auth) ? 0 : 1);
     $user->setDateRegistered(Core::getCurrentDate());
     parent::execute($user);
     $userId = $userDao->insertUser($user);
     // Insert the user interests
     $interests = $this->getData('interestsKeywords') ? $this->getData('interestsKeywords') : $this->getData('interestsTextOnly');
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $interestManager->setInterestsForUser($user, $interests);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $journal =& Request::getJournal();
     $role = new Role();
     $role->setJournalId($journal->getId());
     $role->setUserId($userId);
     $role->setRoleId(ROLE_ID_REVIEWER);
     $roleDao->insertRole($role);
     if ($sendNotify) {
         // Send welcome email to user
         import('classes.mail.MailTemplate');
         $mail = new MailTemplate('REVIEWER_REGISTER');
         $mail->setReplyTo(null);
         $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName()));
         $mail->addRecipient($user->getEmail(), $user->getFullName());
         $mail->send();
     }
     return $userId;
 }
开发者ID:farhanabbas1983,项目名称:ojs-1,代码行数:79,代码来源:CreateReviewerForm.inc.php

示例13: createData

 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     if ($this->getParam('manualInstall')) {
         // Add insert statements for default data
         // FIXME use ADODB data dictionary?
         $this->executeSQL(sprintf('INSERT INTO site (primary_locale, installed_locales) VALUES (\'%s\', \'%s\')', $this->getParam('locale'), join(':', $this->installedLocales)));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'title', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactName', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactEmail', 'string', addslashes($this->getParam('adminEmail')), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO users (username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', $this->getParam('adminUsername'), $this->getParam('adminUsername'), $this->getParam('adminUsername'), Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')), $this->getParam('adminEmail'), Core::getCurrentDate(), Core::getCurrentDate()));
         $this->executeSQL(sprintf('INSERT INTO roles (journal_id, user_id, role_id) VALUES (%d, (SELECT user_id FROM users WHERE username = \'%s\'), %d)', 0, $this->getParam('adminUsername'), ROLE_ID_SITE_ADMIN));
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         foreach ($emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename(), true) as $sql) {
             $this->executeSQL($sql);
         }
         foreach ($this->installedLocales as $locale) {
             foreach ($emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale), true) as $sql) {
                 $this->executeSQL($sql);
             }
         }
     } else {
         // Add initial site data
         $locale = $this->getParam('locale');
         $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
         $site = new Site();
         $site->setRedirect(0);
         $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
         $site->setPrimaryLocale($locale);
         $site->setInstalledLocales($this->installedLocales);
         $site->setSupportedLocales($this->installedLocales);
         if (!$siteDao->insertSite($site)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
         $siteSettingsDao->updateSetting('title', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactName', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
         // Add initial site administrator user
         $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
         $user = new User();
         $user->setUsername($this->getParam('adminUsername'));
         $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
         $user->setFirstName($user->getUsername());
         $user->setLastName('');
         $user->setEmail($this->getParam('adminEmail'));
         if (!$userDao->insertUser($user)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
         $role = new Role();
         $role->setJournalId(0);
         $role->setUserId($user->getId());
         $role->setRoleId(ROLE_ID_SITE_ADMIN);
         if (!$roleDao->insertRole($role)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
         foreach ($this->installedLocales as $locale) {
             $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
         }
         // Add initial plugin data to versions table
         $versionDao =& DAORegistry::getDAO('VersionDAO');
         import('site.VersionCheck');
         $categories = PluginRegistry::getCategories();
         foreach ($categories as $category) {
             PluginRegistry::loadCategory($category, true);
             $plugins = PluginRegistry::getPlugins($category);
             foreach ($plugins as $plugin) {
                 $versionFile = $plugin->getPluginPath() . '/version.xml';
                 if (FileManager::fileExists($versionFile)) {
                     $versionInfo =& VersionCheck::parseVersionXML($versionFile);
                     $pluginVersion = $versionInfo['version'];
                     $pluginVersion->setCurrent(1);
                     $versionDao->insertVersion($pluginVersion);
                 } else {
                     $pluginVersion = new Version();
                     $pluginVersion->setMajor(1);
                     $pluginVersion->setMinor(0);
                     $pluginVersion->setRevision(0);
                     $pluginVersion->setBuild(0);
                     $pluginVersion->setDateInstalled(Core::getCurrentDate());
                     $pluginVersion->setCurrent(1);
                     $pluginVersion->setProductType('plugins.' . $category);
                     $pluginVersion->setProduct(basename($plugin->getPluginPath()));
                     $versionDao->insertVersion($pluginVersion);
                 }
             }
         }
     }
     return true;
//.........这里部分代码省略.........
开发者ID:philschatz,项目名称:ojs,代码行数:101,代码来源:Install.inc.php

示例14: createData

 /**
  * Create initial required data.
  * @return boolean
  */
 function createData()
 {
     if ($this->getParam('manualInstall')) {
         // Add insert statements for default data
         // FIXME use ADODB data dictionary?
         $this->executeSQL(sprintf('INSERT INTO site (primary_locale, installed_locales) VALUES (\'%s\', \'%s\')', $this->getParam('locale'), join(':', $this->installedLocales)));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'title', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactName', 'string', addslashes(Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO site_settings (setting_name, setting_type, setting_value, locale) VALUES (\'%s\', \'%s\', \'%s\', \'%s\')', 'contactEmail', 'string', addslashes($this->getParam('adminEmail')), $this->getParam('locale')));
         $this->executeSQL(sprintf('INSERT INTO users (username, first_name, last_name, password, email, date_registered, date_last_login) VALUES (\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\', \'%s\')', $this->getParam('adminUsername'), $this->getParam('adminUsername'), $this->getParam('adminUsername'), Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')), $this->getParam('adminEmail'), Core::getCurrentDate(), Core::getCurrentDate()));
         $this->executeSQL(sprintf('INSERT INTO roles (journal_id, user_id, role_id) VALUES (%d, (SELECT user_id FROM users WHERE username = \'%s\'), %d)', 0, $this->getParam('adminUsername'), ROLE_ID_SITE_ADMIN));
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         foreach ($emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename(), true) as $sql) {
             $this->executeSQL($sql);
         }
         foreach ($this->installedLocales as $locale) {
             foreach ($emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale), true) as $sql) {
                 $this->executeSQL($sql);
             }
         }
     } else {
         // Add initial site data
         $locale = $this->getParam('locale');
         $siteDao =& DAORegistry::getDAO('SiteDAO', $this->dbconn);
         $site = new Site();
         $site->setRedirect(0);
         $site->setMinPasswordLength(INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH);
         $site->setPrimaryLocale($locale);
         $site->setInstalledLocales($this->installedLocales);
         $site->setSupportedLocales($this->installedLocales);
         if (!$siteDao->insertSite($site)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         $siteSettingsDao =& DAORegistry::getDAO('SiteSettingsDAO');
         $siteSettingsDao->updateSetting('title', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactName', array($locale => Locale::translate(INSTALLER_DEFAULT_SITE_TITLE)), null, true);
         $siteSettingsDao->updateSetting('contactEmail', array($locale => $this->getParam('adminEmail')), null, true);
         // Add initial site administrator user
         $userDao =& DAORegistry::getDAO('UserDAO', $this->dbconn);
         $user = new User();
         $user->setUsername($this->getParam('adminUsername'));
         $user->setPassword(Validation::encryptCredentials($this->getParam('adminUsername'), $this->getParam('adminPassword'), $this->getParam('encryption')));
         $user->setFirstName($user->getUsername());
         $user->setLastName('');
         $user->setEmail($this->getParam('adminEmail'));
         if (!$userDao->insertUser($user)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         $roleDao =& DAORegistry::getDao('RoleDAO', $this->dbconn);
         $role = new Role();
         $role->setJournalId(0);
         $role->setUserId($user->getId());
         $role->setRoleId(ROLE_ID_SITE_ADMIN);
         if (!$roleDao->insertRole($role)) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
         // Install email template list and data for each locale
         $emailTemplateDao =& DAORegistry::getDAO('EmailTemplateDAO');
         $emailTemplateDao->installEmailTemplates($emailTemplateDao->getMainEmailTemplatesFilename());
         foreach ($this->installedLocales as $locale) {
             $emailTemplateDao->installEmailTemplateData($emailTemplateDao->getMainEmailTemplateDataFilename($locale));
         }
         // Install filters and filter templates.
         $this->installFilterTemplates();
     }
     return true;
 }
开发者ID:JovanyJeff,项目名称:hrp,代码行数:75,代码来源:Install.inc.php

示例15: enroll

 /**
  * Enroll a user in a role.
  */
 function enroll($args)
 {
     $this->validate();
     $roleId = (int) (isset($args[0]) ? $args[0] : Request::getUserVar('roleId'));
     // Get a list of users to enroll -- either from the
     // submitted array 'users', or the single user ID in
     // 'userId'
     $users = Request::getUserVar('users');
     if (!isset($users) && Request::getUserVar('userId') != null) {
         $users = array(Request::getUserVar('userId'));
     }
     $journalDao =& DAORegistry::getDAO('JournalDAO');
     $journal =& $journalDao->getJournalByPath(Request::getRequestedJournalPath());
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $rolePath = $roleDao->getRolePath($roleId);
     if ($users != null && is_array($users) && $rolePath != '' && $rolePath != 'admin') {
         for ($i = 0; $i < count($users); $i++) {
             if (!$roleDao->userHasRole($journal->getId(), $users[$i], $roleId)) {
                 $role = new Role();
                 $role->setJournalId($journal->getId());
                 $role->setUserId($users[$i]);
                 $role->setRoleId($roleId);
                 $roleDao->insertRole($role);
             }
         }
     }
     Request::redirect(null, null, 'people', empty($rolePath) ? null : $rolePath . 's');
 }
开发者ID:yuricampos,项目名称:ojs,代码行数:31,代码来源:PeopleHandler.inc.php


注:本文中的Role::setJournalId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。