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


PHP UserModel::validate方法代码示例

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


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

示例1: testValidation

 public function testValidation()
 {
     $obj = new UserModel();
     $obj->email = 'zzzzzzzz@ya.ru';
     $v = $obj->validate();
     $this->assertCount(0, $v, validationErrorsToString($v));
 }
开发者ID:buldezir,项目名称:dja_orm,代码行数:7,代码来源:ModelTest.php

示例2: registerAction

 /**
  * registering the new user
  */
 public function registerAction()
 {
     parent::render('signup');
     if (isset($_POST['submit'])) {
         session_start();
         $_SESSION['user'] = $_POST['username'];
         $reg = new UserModel();
         if ($reg->validate() === true) {
             if ($reg->insertUser() === true) {
                 parent::redirect("User", "userPage");
             } else {
                 parent::redirect("User", "fail");
             }
         }
     }
 }
开发者ID:kapsi44,项目名称:Gangouts,代码行数:19,代码来源:UserController.php

示例3: actionUserCreate

 public function actionUserCreate()
 {
     $model = new UserModel();
     $group = GroupModel::model()->findall();
     foreach ($group as $v) {
         $groupList[$v->group_id] = $v->name;
     }
     if (isset($_POST['UserModel'])) {
         // 收集用户输入的数据
         $model->attributes = $_POST['UserModel'];
         $model->scenario = 'create';
         if ($model->validate()) {
             //检查用户是否重复
             $model->pswd = md5($_POST['UserModel']['pswd']);
             $model->repswd = md5($_POST['UserModel']['repswd']);
             $model->save();
             $this->redirect(array('group/user'));
         }
     }
     $this->render('userCreate', array('model' => $model, 'group' => $groupList));
 }
开发者ID:00606,项目名称:wechat,代码行数:21,代码来源:GroupController.php

示例4: actionIndex

 public function actionIndex()
 {
     $model = new UserModel();
     if (isset($_POST['UserModel'])) {
         $model->attributes = $_POST['UserModel'];
         $model->username = $model->email;
         if ($model->validate()) {
             $record = UserModel::model()->findByAttributes(array('email' => $model->email));
             if ($record !== null) {
                 $this->render('error', array('type' => 'repeate'));
                 exit;
             } else {
                 if ($model->save()) {
                     //$this->redirect(array('style/index','id'=>$model->_id));
                     $this->redirect(array('login/index'));
                 }
                 $this->refresh();
             }
         }
     }
     $this->render('index', array('model' => $model));
 }
开发者ID:dalinhuang,项目名称:styleshop,代码行数:22,代码来源:RegisterController.php

示例5: loginAction

 public function loginAction()
 {
     $name = $this->getRequest()->getParam('account');
     $password = $this->getRequest()->getParam('password');
     $check = $this->getRequest()->getParam('check');
     if ($check == 1) {
         setcookie("account", $name, time() + 86400, "/");
         setcookie("password", $password, time() + 86400, "/");
     } else {
         setcookie("account", "null", time() + 86400, "/");
         setcookie("password", "null", time() + 86400, "/");
     }
     $User = new UserModel();
     $res = $User->validate($name, $password);
     if (count($res) == 1) {
         $_SESSION["userinfo"] = $res;
         $this->view->info = $res;
         $this->view->cookie = $_COOKIE;
         $this->_forward('home', 'Home');
     } else {
         $this->_forward('index', 'Index');
     }
 }
开发者ID:WebBigDoLeaf,项目名称:WebOne,代码行数:23,代码来源:LoginController.php

示例6: _importAuthor

 /**
  * Import WP Author into users
  *
  * @param mixed $author Author data from WP XML
  * 
  * @return Null
  */
 protected function _importAuthor($author)
 {
     if (!craft()->users->getUserByEmail($author['author_email'])) {
         if (empty(trim($author['author_first_name']) . trim($author['author_last_name']))) {
             $author['author_first_name'] = $author['author_login'];
         }
         $user = new UserModel();
         $user->username = $author['author_login'];
         $user->firstName = $author['author_first_name'];
         $user->lastName = $author['author_last_name'];
         $user->email = $author['author_email'];
         if (!$user->validate()) {
             $emailParts = explode('@', $author['author_email']);
             $user->username = $emailParts[0];
         }
         if (!craft()->users->saveUser($user)) {
             Craft::log('Couldn’t save the user "' . $author['author_login'] . '"', LogLevel::Warning, true, 'application', 'InstaBlog');
         }
     } else {
         Craft::log('A User already exists with the email: "' . $author['author_email'] . '"', LogLevel::Info, false, 'application', 'InstaBlog');
     }
 }
开发者ID:lukeholder,项目名称:craft-instablog,代码行数:29,代码来源:InstaBlog_ImportService.php

示例7: syncCustomer

 public function syncCustomer($xml)
 {
     craft()->requireEdition(Craft::Pro);
     if (!$this->ssoEnabled) {
         return false;
     }
     if (!craft()->systemSettings->getSetting('users', 'allowPublicRegistration')) {
         FoxyCartPlugin::log('[sso] Unable to save user as allowPublicRegistration is set to false', LogLevel::Error);
         return false;
     }
     foreach ($xml->transactions->transaction as $transaction) {
         $customerId = (string) $transaction->customer_id;
         $customerFirstName = (string) $transaction->customer_first_name;
         $customerLastName = (string) $transaction->customer_last_name;
         $customerEmail = (string) $transaction->customer_email;
         $customerPassword = (string) $transaction->customer_password;
         $customerPasswordHashType = (string) $transaction->customer_password_hash_type;
         $customerPasswordHashConfig = (string) $transaction->customer_password_hash_config;
         // Make sure they have the right password algorithm
         if ($customerPasswordHashType !== "craftcms") {
             FoxyCartPlugin::log(sprintf('[sso] Unable to save user as FoxyCart password hashing method is set to "%s", needs to be "Craft CMS"', $customerPasswordHashType), LogLevel::Error);
             return false;
         }
         if ($customerPasswordHashConfig != craft()->config->get('blowfishHashCost')) {
             FoxyCartPlugin::log(sprintf('[sso] Unable to save user due to password encryption algorithm config mismatch. FoxyCart: "%s" - Craft: "%s"', $customerPasswordHashConfig, craft()->config->get('blowfishHashCost')), LogLevel::Error);
             return false;
         }
         // Ignore them if they checked out as a guest
         if ($customerId != '0') {
             $isNewUser = false;
             $user = craft()->users->getUserByUsernameOrEmail($customerEmail);
             if (!$user) {
                 $user = new UserModel();
                 $isNewUser = true;
             }
             $user->firstName = $customerFirstName;
             $user->lastName = $customerLastName;
             if ($isNewUser) {
                 $user->email = $customerEmail;
                 $user->username = $customerEmail;
                 $user->status = UserStatus::Active;
             }
             // ToDo: Do we need to raise an onSyncUser event here, or will users.onSaveUser cover it?
             if ($user->validate(null, false) && craft()->users->saveUser($user)) {
                 // Save their password directly, as there isn't an API to save an already hashed password in Craft
                 $sql = craft()->db->createCommand();
                 $sql->update('users', array('password' => $customerPassword), 'id=:id', array(':id' => $user->id));
                 // Save their FoxyCart customer ID
                 $this->saveCustomerId($user, $customerId);
                 // Assign them to a group
                 if ($this->ssoGroup) {
                     craft()->userGroups->assignUserToGroups($user->id, array($this->ssoGroup));
                 }
                 return true;
             } else {
                 FoxyCartPlugin::log('[sso] Couldn’t save user from webhook', LogLevel::Error);
                 return false;
             }
         }
     }
 }
开发者ID:digitaldevelopers,项目名称:foxycart-craft,代码行数:61,代码来源:FoxyCartService.php

示例8: ResourceModel

$ResourceModel = new ResourceModel();
$BuildingModel = new BuildingModel();
$LanternModel = new LanternModel();
$GiftModel = new GiftModel();
/*
 * Main path
 */
$app->get('/', function (Request $request) use($app, $UsersController) {
    return $app->redirect('doc/index.html');
});
/*
 * Users
 */
$app->get($basePath . '/userInfos', function (Request $request) use($app, $UsersController, $UserModel) {
    $params = $request->query->all();
    $errorMessage = $UserModel->validate($params, "index");
    if ($errorMessage) {
        return Utils::formatErrorMessage(ERROR_BAD_MODEL, $errorMessage);
    } else {
        return $UsersController->index($params);
    }
});
$app->get($basePath . '/users/login', function (Request $request) use($app, $UsersController, $UserModel) {
    $params = $request->query->all();
    $errorMessage = $UserModel->validate($params, 'login');
    if ($errorMessage) {
        return Utils::formatErrorMessage(ERROR_BAD_MODEL, $errorMessage);
    } else {
        return $UsersController->login($params);
    }
});
开发者ID:Mystraht,项目名称:builder,代码行数:31,代码来源:routes.php

示例9: actionRegister

 /**
  * 注册后台处理方法
  */
 public function actionRegister()
 {
     $user = new UserModel();
     $user->ts_u_phone = $_POST['phone'];
     $user->ts_u_password = Utils::getUserPassword($_POST['pwd']);
     $user->ts_u_username = $_POST['username'] ? $_POST['username'] : $_POST['phone'];
     $user->ts_u_type = 3;
     $info = array();
     if (!$user->validate()) {
         var_dump($user->getErrors());
         exit;
         $info = array('status' => 2, 'info' => $this->getErrorMessage($user->getErrors()));
     } else {
         $user->save();
         //$message['id'] = $user->attributes['ts_u_id'];
         $info = array('status' => 1, 'info' => "注册成功");
     }
     echo json_encode($info);
     die;
 }
开发者ID:uwitec,项目名称:hckp,代码行数:23,代码来源:SiteController.php


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