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


PHP UserForm::execute方法代码示例

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


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

示例1: execute

 /**
  * Update user's roles.
  * @param $args array
  * @param $request PKPRequest
  */
 function execute($args, $request)
 {
     parent::execute($request);
     // Role management handled by parent form, just return user.
     $userDao = DAORegistry::getDAO('UserDAO');
     return $userDao->getById($this->userId);
 }
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:12,代码来源:UserRoleForm.inc.php

示例2: 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

示例3: updateUser

 /**
  * Update an existing user
  * @param $args array
  * @param $request PKPRequest
  * @return string Serialized JSON object
  */
 function updateUser($args, &$request)
 {
     // Identify the press
     $press =& $request->getPress();
     // Identify the user Id
     $userId = $request->getUserVar('userId');
     if ($userId !== null && !Validation::canAdminister($press->getId(), $userId)) {
         // We don't have administrative rights over this user.
         $json = new JSON('false', Locale::translate('grid.user.cannotAdminister'));
     } else {
         // Form handling
         import('controllers.grid.users.user.form.UserForm');
         $userForm = new UserForm($userId);
         $userForm->readInputData();
         if ($userForm->validate()) {
             $user =& $userForm->execute($args, $request);
             // If this is a newly created user, show role management form
             if (!$userId) {
                 import('controllers.grid.users.user.form.UserRoleForm');
                 $userRoleForm = new UserRoleForm($user->getId());
                 $userRoleForm->initData($args, $request);
                 $json = new JSON('false', $userRoleForm->display($args, $request));
             } else {
                 // Successful edit of an existing user
                 // Prepare the grid row data
                 $row =& $this->getRowInstance();
                 $row->setGridId($this->getId());
                 $row->setId($user->getId());
                 $row->setData($user);
                 $row->initialize($request);
                 $json = new JSON('true', $this->_renderRowInternally($request, $row));
             }
         } else {
             $json = new JSON('false', $userForm->display($args, $request));
         }
     }
     return $json->getString();
 }
开发者ID:ramonsodoma,项目名称:omp,代码行数:44,代码来源:UserGridHandler.inc.php


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