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


PHP Validation::generatePassword方法代码示例

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


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

示例1: execute

 /**
  * Save new password.
  * @return boolean success
  */
 function execute()
 {
     $userDao =& DAORegistry::getDAO('UserDAO');
     $user =& $userDao->getUserByUsername($this->getData('username'), false);
     echo $user->getUsername();
     echo $this->getData('password');
     if ($user != null) {
         if ($user->getAuthId()) {
             $authDao =& DAORegistry::getDAO('AuthSourceDAO');
             $auth =& $authDao->getPlugin($user->getAuthId());
         }
         if (isset($auth)) {
             $auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
             $user->setPassword(Validation::encryptCredentials($user->getUserId(), Validation::generatePassword()));
             // Used for PW reset hash only
         } else {
             echo $user->getUsername();
             echo $this->getData('password');
             $user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
         }
         $user->setMustChangePassword(0);
         $userDao->updateUser($user);
         return true;
     } else {
         return false;
     }
 }
开发者ID:LiteratimBi,项目名称:jupitertfn,代码行数:31,代码来源:LoginChangePasswordForm.inc.php

示例2: execute

 /**
  * Save review assignment
  * @param $args array
  * @param $request PKPRequest
  */
 function execute($args, $request)
 {
     $userDao = DAORegistry::getDAO('UserDAO');
     $user = $userDao->newDataObject();
     $user->setFirstName($this->getData('firstName'));
     $user->setMiddleName($this->getData('middleName'));
     $user->setLastName($this->getData('lastName'));
     $user->setEmail($this->getData('email'));
     $authDao = DAORegistry::getDAO('AuthSourceDAO');
     $auth = $authDao->getDefaultPlugin();
     $user->setAuthId($auth ? $auth->getAuthId() : 0);
     $user->setInlineHelp(1);
     // default new reviewers to having inline help visible
     $user->setUsername($this->getData('username'));
     $password = Validation::generatePassword();
     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(true);
     // Emailed P/W not safe
     $user->setDateRegistered(Core::getCurrentDate());
     $reviewerId = $userDao->insertObject($user);
     // Set the reviewerId in the Form for the parent class to use
     $this->setData('reviewerId', $reviewerId);
     // Insert the user interests
     import('lib.pkp.classes.user.InterestManager');
     $interestManager = new InterestManager();
     $interestManager->setInterestsForUser($user, $this->getData('interests'));
     // Assign the selected user group ID to the user
     $userGroupDao = DAORegistry::getDAO('UserGroupDAO');
     /* @var $userGroupDao UserGroupDAO */
     $userGroupId = (int) $this->getData('userGroupId');
     $userGroupDao->assignUserToGroup($reviewerId, $userGroupId);
     if (!$this->getData('skipEmail')) {
         // Send welcome email to user
         import('lib.pkp.classes.mail.MailTemplate');
         $mail = new MailTemplate('REVIEWER_REGISTER');
         if ($mail->isEnabled()) {
             $context = $request->getContext();
             $mail->setReplyTo($context->getSetting('contactEmail'), $context->getSetting('contactName'));
             $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName()));
             $mail->addRecipient($user->getEmail(), $user->getFullName());
             $mail->send($request);
         }
     }
     return parent::execute($args, $request);
 }
开发者ID:jprk,项目名称:pkp-lib,代码行数:59,代码来源:CreateReviewerForm.inc.php

示例3: createKey

 /**
  * Create an access key with the given information.
  * @param $context string The context of the access key
  * @param $userId int The ID of the effective user for this access key
  * @param $assocId int The associated ID of the key
  * @param $expiryDays int The number of days before this key expires
  * @return accessKey string The generated passkey
  */
 function createKey($context, $userId, $assocId, $expiryDays)
 {
     $accessKey = new AccessKey();
     $accessKey->setContext($context);
     $accessKey->setUserId($userId);
     $accessKey->setAssocId($assocId);
     $accessKey->setExpiryDate(Core::getCurrentDate(time() + 60 * 60 * 24 * $expiryDays));
     $key = Validation::generatePassword();
     $accessKey->setKeyHash($this->generateKeyHash($key));
     $this->accessKeyDao->insertObject($accessKey);
     return $key;
 }
开发者ID:jprk,项目名称:pkp-lib,代码行数:20,代码来源:AccessKeyManager.inc.php

示例4: Captcha

 /**
  * Create a CAPTCHA object.
  * @param $length int The length, in characters, of the CAPTCHA test to create
  * @return object Captcha
  */
 function &createCaptcha($length = 6)
 {
     $captchaDao =& DAORegistry::getDAO('CaptchaDAO');
     $session =& Request::getSession();
     if ($session && $this->isEnabled()) {
         $captcha = new Captcha();
         $captcha->setSessionId($session->getId());
         $captcha->setValue(Validation::generatePassword($length));
         $captchaDao->insertCaptcha($captcha);
     } else {
         $captcha = null;
     }
     return $captcha;
 }
开发者ID:ingmarschuster,项目名称:MindResearchRepository,代码行数:19,代码来源:CaptchaManager.inc.php

示例5: execute

 /**
  * Save new password.
  */
 function execute()
 {
     $user = $this->getUser();
     if ($user->getAuthId()) {
         $authDao = DAORegistry::getDAO('AuthSourceDAO');
         $auth = $authDao->getPlugin($user->getAuthId());
     }
     if (isset($auth)) {
         $auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
         $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
         // Used for PW reset hash only
     } else {
         $user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
     }
     $userDao = DAORegistry::getDAO('UserDAO');
     $userDao->updateObject($user);
 }
开发者ID:selwyntcy,项目名称:pkp-lib,代码行数:20,代码来源:ChangePasswordForm.inc.php

示例6: generatePassword

 /**
  * Generate a random password for a user.
  * @param $user ImportedUser the user to be modified by this function
  */
 function generatePassword(&$user)
 {
     $password = Validation::generatePassword();
     $user->setUnencryptedPassword($password);
     $user->setPassword(Validation::encryptCredentials($user->getUsername(), $password));
 }
开发者ID:EreminDm,项目名称:water-cao,代码行数:10,代码来源:UserXMLParser.inc.php

示例7: importPapers

 /**
  * Import papers (including metadata and files).
  */
 function importPapers()
 {
     if ($this->hasOption('verbose')) {
         printf("Importing papers\n");
     }
     import('classes.file.PaperFileManager');
     import('classes.search.PaperSearchIndex');
     $userDao =& DAORegistry::getDAO('UserDAO');
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $trackDao =& DAORegistry::getDAO('TrackDAO');
     $paperDao =& DAORegistry::getDAO('PaperDAO');
     $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
     $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
     $unassignedTrackId = null;
     $result =& $this->importDao->retrieve('SELECT * FROM papers ORDER by id');
     while (!$result->EOF) {
         $row =& $result->fields;
         $schedConf =& $this->schedConfMap[$row['cf']];
         $schedConfId = $schedConf->getId();
         // Bring in the primary user for this paper.
         $user = $userDao->getUserByUsername(Core::cleanVar($row['login']));
         if (!$user) {
             unset($user);
             $user = new User();
             $user->setUsername(Core::cleanVar($row['login']));
             $user->setFirstName(Core::cleanVar($row['first_name']));
             $user->setLastName(Core::cleanVar($row['surname']));
             $user->setAffiliation(Core::cleanVar($row['affiliation']), Locale::getLocale());
             $user->setEmail(Core::cleanVar($row['email']));
             $user->setUrl(Core::cleanVar($row['url']));
             $user->setBiography(Core::cleanVar($row['bio']), Locale::getLocale());
             $user->setLocales(array());
             $user->setDateRegistered($row['created']);
             $user->setDateLastLogin($row['created']);
             $user->setMustChangePassword(1);
             $password = Validation::generatePassword();
             $user->setPassword(Validation::encryptCredentials($user->getUsername(), $password));
             if ($this->hasOption('emailUsers')) {
                 import('classes.mail.MailTemplate');
                 $mail = new MailTemplate('USER_REGISTER');
                 $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
                 $mail->assignParams(array('username' => $user->getUsername(), 'password' => $password, 'conferenceName' => $schedConf->getFullTitle()));
                 $mail->addRecipient($user->getEmail(), $user->getFullName());
                 $mail->send();
             }
             $user->setDisabled(0);
             $otherUser =& $userDao->getUserByEmail(Core::cleanVar($row['email']));
             if ($otherUser !== null) {
                 // User exists with this email -- munge it to make unique
                 $user->setEmail('ocs-' . Core::cleanVar($row['login']) . '+' . Core::cleanVar($row['email']));
                 $this->conflicts[] = array(&$otherUser, &$user);
             }
             unset($otherUser);
             $userDao->insertUser($user);
             // Make this user a author
             $role = new Role();
             $role->setSchedConfId($schedConf->getId());
             $role->setConferenceId($schedConf->getConferenceId());
             $role->setUserId($user->getId());
             $role->setRoleId(ROLE_ID_AUTHOR);
             $roleDao->insertRole($role);
             unset($role);
         }
         $userId = $user->getId();
         // Bring in the basic entry for the paper
         $paper = new Paper();
         $paper->setUserId($userId);
         $paper->setLocale(Locale::getPrimaryLocale());
         $paper->setSchedConfId($schedConfId);
         $oldTrackId = $row['primary_track_id'];
         if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) {
             $oldTrackId = $row['secondary_track_id'];
         }
         if (!$oldTrackId || !isset($this->trackMap[$oldTrackId])) {
             if (!$unassignedTrackId) {
                 // Create an "Unassigned" track to use for submissions
                 // that didn't have a track in OCS 1.x.
                 $track = new Track();
                 $track->setSchedConfId($schedConf->getId());
                 $track->setTitle('UNASSIGNED', Locale::getLocale());
                 $track->setSequence(REALLY_BIG_NUMBER);
                 $track->setDirectorRestricted(1);
                 $track->setMetaReviewed(1);
                 $unassignedTrackId = $trackDao->insertTrack($track);
             }
             $newTrackId = $unassignedTrackId;
         } else {
             $newTrackId = $this->trackMap[$oldTrackId];
         }
         $paper->setTrackId($newTrackId);
         $paper->setTitle(Core::cleanVar($row['title']), Locale::getLocale());
         $paper->setAbstract(Core::cleanVar($row['abstract']), Locale::getLocale());
         $paper->setDiscipline(Core::cleanVar($row['discipline']), Locale::getLocale());
         $paper->setSponsor(Core::cleanVar($row['sponsor']), Locale::getLocale());
         $paper->setSubject(Core::cleanVar($row['topic']), Locale::getLocale());
         $paper->setLanguage(Core::cleanVar($row['language']));
         $paper->setDateSubmitted($row['created']);
//.........这里部分代码省略.........
开发者ID:ramonsodoma,项目名称:ocs,代码行数:101,代码来源:ImportOCS1.inc.php

示例8: execute

 /**
  * Register a new user.
  * @return userId int
  * Last modified: EL on February 22th 2013
  */
 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->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);
     $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 (Locale::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->setDateRegistered(Core::getCurrentDate());
     $userId = $userDao->insertUser($user);
     // Add reviewing interests to interests table
     $interestDao =& DAORegistry::getDAO('InterestDAO');
     $interests = is_array(Request::getUserVar('interestsKeywords')) ? Request::getUserVar('interestsKeywords') : array();
     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);
     }
     $interestDao->insertInterests($interests, $user->getId(), true);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $journal =& Request::getJournal();
     $ercStatus = $this->getData('ercStatus');
     if ($ercStatus == "Secretary") {
         $role = new Role();
         $role->setJournalId($journal->getId());
         $role->setUserId($userId);
         $role->setRoleId(ROLE_ID_SECTION_EDITOR);
         $roleDao->insertRole($role);
         $sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
         $sectionEditorsDao->insertEditor($journal->getId(), $this->sectionId, $userId, 1, 1);
     } elseif ($ercStatus == "Chair" || $ercStatus == "Vice-Chair" || $ercStatus == "Member") {
         $role = new Role();
         $role->setJournalId($journal->getId());
         $role->setUserId($userId);
         $role->setRoleId(ROLE_ID_REVIEWER);
         $roleDao->insertRole($role);
         $ercReviewersDao =& DAORegistry::getDAO('ErcReviewersDAO');
         if ($ercStatus == "Chair") {
             $ercReviewersDao->insertReviewer($journal->getId(), $this->sectionId, $userId, 1);
         } elseif ($ercStatus == "Vice-Chair") {
             $ercReviewersDao->insertReviewer($journal->getId(), $this->sectionId, $userId, 2);
         }
         if ($ercStatus == "Member") {
//.........这里部分代码省略.........
开发者ID:JovanyJeff,项目名称:hrp,代码行数:101,代码来源:CreateReviewerForm.inc.php

示例9: _doUserRequest


//.........这里部分代码省略.........
        curl_setopt($curlCh, CURLOPT_HTTPHEADER, $extraHeaders);
        curl_setopt($curlCh, CURLOPT_POSTFIELDS, $soapMessage);
        $result = true;
        $response = curl_exec($curlCh);
        // We do not localize our error messages as they are all
        // fatal errors anyway and must be analyzed by technical staff.
        if ($response === false) {
            $result = 'OJS-OFR: Expected string response.';
        }
        if ($result === true && ($status = curl_getinfo($curlCh, CURLINFO_HTTP_CODE)) != OFR_WS_RESPONSE_OK) {
            $result = 'OJS-OFR: Expected ' . OFR_WS_RESPONSE_OK . ' response code, got ' . $status . ' instead.';
        }
        curl_close($curlCh);
        // Check SOAP response by simple string manipulation rather
        // than instantiating a DOM.
        if (is_string($response)) {
            $request = Application::getRequest();
            /**
             * The XML returned looks something like this:
             *
             * <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
             * 		<soap:Header><AuthorizationToken xmlns="http://www.avectra.com/2005/"><Token>2a51ca85-d490-4444-802c-d247259d674a</Token></AuthorizationToken></soap:Header>
             * 		<soap:Body>
             * 			<BNEGetIndividualInformationResponse xmlns="http://www.avectra.com/2005/">
             * 				<BNEGetIndividualInformationResult>
             * 					<Individual xmlns="">
             * 						<ind_cst_key>2a51ca85-d490-9999-802c-d24XX59d674a</ind_cst_key>
             * 						<cst_recno>000001</cst_recno>
             * 						<ind_first_name>John</ind_first_name>
             * 						<ind_last_name>Public</ind_last_name>
             * 						<cst_eml_address_dn>user@email.com</cst_eml_address_dn>
             * 						<InterestCodes>&lt;InterestCode&gt;Art and Material Culture&lt;/InterestCode&gt;</InterestCodes>
             * 					</Individual>
             * 				</BNEGetIndividualInformationResult>
             * 			</BNEGetIndividualInformationResponse>
             * 		</soap:Body>
             * </soap:Envelope>
             */
            $matches = array();
            if (!preg_match('#<faultstring>([^<]*)</faultstring>#', $response)) {
                // Ensure that the user is logged into the AnthroNet portal.
                if (preg_match('#<ind_cst_key>00000000\\-0000\\-0000\\-0000\\-000000000000</ind_cst_key>#', $response)) {
                    $request->redirect(null, 'user');
                } else {
                    $email = $firstName = $lastName = $interestCodes = null;
                    $interestCodesArray = array();
                    if (preg_match('#<cst_eml_address_dn>(.*?)</cst_eml_address_dn>#', $response, $matches)) {
                        $email = $matches[1];
                    }
                    if (preg_match('#<ind_first_name>(.*?)</ind_first_name>#', $response, $matches)) {
                        $firstName = $matches[1];
                    }
                    if (preg_match('#<ind_last_name>(.*?)</ind_last_name>#', $response, $matches)) {
                        $lastName = $matches[1];
                    }
                    if (preg_match('#<InterestCodes>(.*?)</InterestCodes>#', $response, $matches)) {
                        $interestCodes = $matches[1];
                        preg_match_all('#&lt;InterestCode&gt;(.*?)&lt;/InterestCode&gt;#', $interestCodes, $matches, PREG_PATTERN_ORDER);
                        if (is_array($matches[1])) {
                            $interestCodesArray = $matches[1];
                        }
                    }
                    $userDao =& DAORegistry::getDAO('UserDAO');
                    // see if this user exists already.
                    $user = $userDao->getUserByEmail($email);
                    if (!$user) {
                        $user = new User();
                        $userName = Validation::suggestUsername($firstName, $lastName);
                        $user->setUsername($userName);
                        $user->setFirstName($firstName);
                        $user->setLastName($lastName);
                        $user->setEmail($email);
                        $user->setDateRegistered(Core::getCurrentDate());
                        $locales = array('en_US');
                        $user->setLocales($locales);
                        $user->setPassword(Validation::encryptCredentials($userName, Validation::generatePassword()));
                        $userDao->insertUser($user);
                    }
                    import('lib.pkp.classes.user.InterestManager');
                    $interestManager = new InterestManager();
                    $interestManager->setInterestsForUser($user, $interestCodesArray);
                    // enroll as Author, if not already.
                    $roleDao =& DAORegistry::getDAO('RoleDAO');
                    if (!$roleDao->userHasRole($journal->getId(), $user->getId(), ROLE_ID_AUTHOR)) {
                        $role = new Role();
                        $role->setJournalId($journal->getId());
                        $role->setUserId($user->getId());
                        $role->setRoleId(ROLE_ID_AUTHOR);
                        $roleDao->insertRole($role);
                    }
                    return $user;
                }
            } else {
                $result = 'OFR: ' . $status . ' - ' . $matches[1];
            }
        } else {
            $result = 'OJS-OFR: Expected string response.';
        }
        return false;
    }
开发者ID:justinshaffner,项目名称:AAAObjectsForReview,代码行数:101,代码来源:ObjectsForReviewAuthorHandler.inc.php

示例10: 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'));
     $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->setInterests($this->getData('interests'), null);
     // Localized
     $user->setGossip($this->getData('gossip'), null);
     // Localized
     $user->setMustChangePassword($this->getData('mustChangePassword') ? 1 : 0);
     $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->setDateRegistered(Core::getCurrentDate());
     $userId = $userDao->insertUser($user);
     $roleDao =& DAORegistry::getDAO('RoleDAO');
     $schedConf =& Request::getSchedConf();
     $role = new Role();
     $role->setConferenceId($schedConf->getConferenceId());
     $role->setSchedConfId($schedConf->getId());
     $role->setUserId($userId);
     $role->setRoleId(ROLE_ID_REVIEWER);
     $roleDao->insertRole($role);
     if ($sendNotify) {
         // Send welcome email to user
         import('mail.MailTemplate');
         $mail = new MailTemplate('USER_REGISTER');
         $mail->setFrom($schedConf->getSetting('contactEmail'), $schedConf->getSetting('contactName'));
         $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password));
         $mail->addRecipient($user->getEmail(), $user->getFullName());
         $mail->send();
     }
     return $userId;
 }
开发者ID:sedici,项目名称:ocs,代码行数:74,代码来源:CreateReviewerForm.inc.php

示例11: array

 /**
  * Create or update a user.
  * @param $args array
  * @param $request PKPRequest
  */
 function &execute($args, $request)
 {
     parent::execute($request);
     $userDao = DAORegistry::getDAO('UserDAO');
     $context = $request->getContext();
     if (isset($this->userId)) {
         $userId = $this->userId;
         $user = $userDao->getById($userId);
     }
     if (!isset($user)) {
         $user = $userDao->newDataObject();
         $user->setInlineHelp(1);
         // default new users to having inline help visible
     }
     $user->setSalutation($this->getData('salutation'));
     $user->setFirstName($this->getData('firstName'));
     $user->setMiddleName($this->getData('middleName'));
     $user->setLastName($this->getData('lastName'));
     $user->setSuffix($this->getData('suffix'));
     $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->setOrcid($this->getData('orcid'));
     $user->setMailingAddress($this->getData('mailingAddress'));
     $user->setCountry($this->getData('country'));
     $user->setBiography($this->getData('biography'), 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) {
         if ($this->getData('password') !== '') {
             if (isset($auth)) {
                 $auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
                 $user->setPassword(Validation::encryptCredentials($user->getId(), 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->insertObject($user);
         if ($sendNotify) {
             // Send welcome email to user
             import('lib.pkp.classes.mail.MailTemplate');
             $mail = new MailTemplate('USER_REGISTER');
             $mail->setReplyTo($context->getSetting('contactEmail'), $context->getSetting('contactName'));
             $mail->assignParams(array('username' => $this->getData('username'), 'password' => $password, 'userFullName' => $user->getFullName()));
             $mail->addRecipient($user->getEmail(), $user->getFullName());
             $mail->send();
         }
     }
     import('lib.pkp.classes.user.InterestManager');
//.........这里部分代码省略.........
开发者ID:selwyntcy,项目名称:pkp-lib,代码行数:101,代码来源:UserDetailsForm.inc.php

示例12: resetPassword

 /**
  * Generates and inserts a new password for a mailing list user
  * @param $email string
  * @return string
  */
 function resetPassword($email)
 {
     $application =& PKPApplication::getApplication();
     $productName = $application->getName();
     $context =& Request::getContext();
     $contextId = $context->getId();
     $result =& $this->retrieve('SELECT setting_id FROM notification_settings WHERE setting_name = ? AND setting_value = ? AND product = ? AND context = ?', array('mailList', $email, $productName, (int) $contextId));
     $row = $result->GetRowAssoc(false);
     $settingId = $row['setting_id'];
     $result->Close();
     unset($result);
     $accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
     $accessKey = $accessKeyDao->getAccessKeyByUserId('MailListContext', $settingId);
     if ($accessKey) {
         $key = Validation::generatePassword();
         $accessKey->setKeyHash(md5($key));
         $accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
         $accessKeyDao->updateObject($accessKey);
         return $key;
     } else {
         return false;
     }
 }
开发者ID:master3395,项目名称:CBPPlatform,代码行数:28,代码来源:NotificationSettingsDAO.inc.php

示例13: resetPassword

 /**
  * Reset a user's password
  * @param $args array first param contains the username of the user whose password is to be reset
  */
 function resetPassword($args)
 {
     $this->validate();
     $this->setupTemplate();
     $username = isset($args[0]) ? $args[0] : null;
     $userDao =& DAORegistry::getDAO('UserDAO');
     $confirmHash = Request::getUserVar('confirm');
     if ($username == null || ($user =& $userDao->getUserByUsername($username)) == null) {
         PKPRequest::redirect(null, null, 'lostPassword');
         return;
     }
     $templateMgr =& TemplateManager::getManager();
     $hash = Validation::generatePasswordResetHash($user->getId());
     if ($hash == false || $confirmHash != $hash) {
         $templateMgr->assign('errorMsg', 'user.login.lostPassword.invalidHash');
         $templateMgr->assign('backLink', PKPRequest::url(null, null, 'lostPassword'));
         $templateMgr->assign('backLinkLabel', 'user.login.resetPassword');
         $templateMgr->display('common/error.tpl');
     } else {
         // Reset password
         $newPassword = Validation::generatePassword();
         if ($user->getAuthId()) {
             $authDao =& DAORegistry::getDAO('AuthSourceDAO');
             $auth =& $authDao->getPlugin($user->getAuthId());
         }
         if (isset($auth)) {
             $auth->doSetUserPassword($user->getUsername(), $newPassword);
             $user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword()));
             // Used for PW reset hash only
         } else {
             $user->setPassword(Validation::encryptCredentials($user->getUsername(), $newPassword));
         }
         $user->setMustChangePassword(1);
         $userDao->updateObject($user);
         // Send email with new password
         $site =& Request::getSite();
         import('classes.mail.MailTemplate');
         $mail = new MailTemplate('PASSWORD_RESET');
         $this->_setMailFrom($mail);
         $mail->assignParams(array('username' => $user->getUsername(), 'password' => $newPassword, 'siteTitle' => $site->getLocalizedTitle()));
         $mail->addRecipient($user->getEmail(), $user->getFullName());
         $mail->send();
         $templateMgr->assign('pageTitle', 'user.login.resetPassword');
         $templateMgr->assign('message', 'user.login.lostPassword.passwordSent');
         $templateMgr->assign('backLink', PKPRequest::url(null, Request::getRequestedPage()));
         $templateMgr->assign('backLinkLabel', 'user.login');
         $templateMgr->display('common/message.tpl');
     }
 }
开发者ID:ramonsodoma,项目名称:pkp-lib,代码行数:53,代码来源:PKPLoginHandler.inc.php

示例14: registerUserFromShib

 /**
  * Register a new user. See classes/user/form/RegistrationForm.inc.php - for how this is done for registering a user in a non-shib environment.
  */
 function registerUserFromShib()
 {
     // Grab the names of the header fields from the config file
     $uin = Config::getVar('security', 'implicit_auth_header_uin');
     // For TDL this is HTTP_TDL_TDLUID
     $first_name = Config::getVar('security', 'implicit_auth_header_first_name');
     $last_name = Config::getVar('security', 'implicit_auth_header_last_name');
     $email = Config::getVar('security', 'implicit_auth_header_email');
     $phone = Config::getVar('security', 'implicit_auth_header_phone');
     $initials = Config::getVar('security', 'implicit_auth_header_initials');
     $mailing_address = Config::getVar('security', 'implicit_auth_header_mailing_address');
     $uin = Config::getVar('security', 'implicit_auth_header_uin');
     // Create a new user object and set it's fields from the header variables
     $user = new User();
     $user->setAuthStr($_SERVER[$uin]);
     $user->setUsername($_SERVER[$email]);
     # Mail is userid
     $user->setFirstName($_SERVER[$first_name]);
     $user->setLastName($_SERVER[$last_name]);
     $user->setEmail($_SERVER[$email]);
     $user->setPhone($_SERVER[$phone]);
     $user->setMailingAddress($_SERVER[$mailing_address]);
     $user->setDateRegistered(Core::getCurrentDate());
     // Randomly genearate the user's password, using a randomly generated salt
     // Salting with a value other than the authStr/UIN prevents password-based login
     // (eg in the case that implicit auth is disabled later)
     $user->setPassword(Validation::encryptCredentials(Validation::generatePassword(40), Validation::generatePassword(40)));
     // Now go insert the user in the db
     $userDao =& DAORegistry::getDAO('UserDAO');
     $userDao->insertUser($user);
     $userId = $user->getId();
     if (!$userId) {
         return false;
     }
     // Go put the user into the session and return it.
     $sessionManager =& SessionManager::getManager();
     $session =& $sessionManager->getUserSession();
     $session->setSessionVar('username', $user->getUsername());
     return $user;
 }
开发者ID:farhanabbas1983,项目名称:ojs-1,代码行数:43,代码来源:ShibAuthPlugin.inc.php

示例15: 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'));
     $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->setInterests($this->getData('interests'), 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->getUserId() != null) {
         if ($this->getData('password') !== '') {
             if (isset($auth)) {
                 $auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
                 $user->setPassword(Validation::encryptCredentials($user->getUserId(), 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->updateUser($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->getUserId(), 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->getJournalId());
                     $role->setUserId($userId);
                     $role->setRoleId($roleId);
                     $roleDao->insertRole($role);
                 }
             }
//.........这里部分代码省略.........
开发者ID:LiteratimBi,项目名称:jupitertfn,代码行数:101,代码来源:UserManagementForm.inc.php


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