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


PHP UsersPeer::usernameExists方法代码示例

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


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

示例1: executeCreate

 /**
  * Create a new account.
  * 
  * @return 
  */
 public function executeCreate($request)
 {
     if ($request->getMethod() != coreRequest::POST) {
         // setup form
         // development
         /*
               if (CORE_ENVIRONMENT==='dev')
               {
                 $request->getParameterHolder()->add(array(
                   'username' => '...' . rand(1,1000),
                   'email' => '...',
                   'password'=>'xxxxx',
                   'password2'=>'xxxxx',
                   'location'=>'Foo Bar')
                 );
               }*/
     } else {
         $validator = new coreValidator($this->getActionName());
         if ($validator->validate($request->getParameterHolder()->getAll())) {
             $this->username = trim($request->getParameter('username'));
             $raw_password = trim($request->getParameter('password'));
             if (UsersPeer::usernameExists($this->username)) {
                 $request->setError('username_duplicate', 'Sorry, that username is already taken, please pick another one.');
                 return coreView::SUCCESS;
             }
             $userinfo = array('username' => trim($request->getParameter('username')), 'password' => $this->getUser()->getSaltyHashedPassword($raw_password), 'email' => trim($request->getParameter('email')), 'location' => trim($request->getParameter('location', '')));
             // username is available, create user
             UsersPeer::createUser($userinfo);
             // create user on the PunBB forum with same username and password
             // NOT IN STAGING -- staging does not have a "test" forum database
             if (coreContext::getInstance()->getConfiguration()->getEnvironment() !== 'staging' && coreConfig::get('app_path_to_punbb') !== null) {
                 try {
                     $forumAccountSuccess = PunBBUsersPeer::createAccount($userinfo);
                 } catch (coreException $e) {
                     $forumAccountSuccess = false;
                 }
                 if (!$forumAccountSuccess) {
                     $url = $this->getController()->genUrl('@contact');
                     $request->setError('forum_account', 'Oops, there was a problem while accessing the forum database.<br/>' . 'Please <a href="' . $url . '">contact the webmaster</a> with your username and password,<br/>' . 'and we will create your forum account as soon as possible.');
                 }
             } else {
                 // STAGING
                 $forumAccountSuccess = false;
                 $request->setError('forum_account', '(Forum account NOT created in test environment)');
             }
             // send email confirmation
             $mailer = new rtkMail();
             $mailer->sendNewAccountConfirmation($userinfo['email'], $userinfo['username'], $raw_password);
             return 'Done';
         }
     }
 }
开发者ID:nikitakit,项目名称:RevTK,代码行数:57,代码来源:actions.php

示例2: init

 public function init()
 {
     parent::init();
     // Verify we're on the correct database
     //print_r(coreConfig::get('database_connection'));exit;
     $connectionInfo = coreConfig::get('database_connection');
     $this->verbose("Using database: %s", $connectionInfo['database']);
     $username = trim($this->getOption('username'));
     $raw_password = trim($this->getOption('password'));
     if (empty($username) || empty($raw_password)) {
         $this->throwError('Username or password is empty.');
     }
     if (UsersPeer::usernameExists($username)) {
         $this->throwError('That username already exists, foo!');
     }
     $this->createUser($username, $raw_password);
     $this->verbose('Success!');
 }
开发者ID:nikitakit,项目名称:RevTK,代码行数:18,代码来源:createUser.php


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