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


PHP UserForm::validate方法代码示例

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


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

示例1: actionUserForm

 public function actionUserForm()
 {
     $model = new UserForm();
     if ($model->load(yii::$app->request->post()) && $model->validate()) {
         // alguma coisa
     } else {
         return $this->render('userForm', array('model' => $model));
     }
 }
开发者ID:Thaiiz,项目名称:TogetherSchool,代码行数:9,代码来源:SiteController.php

示例2: actionAdd

 /**
  * 添加用户
  */
 public function actionAdd()
 {
     $userForm = new UserForm('add');
     if (Yii::app()->request->getIsPostRequest()) {
         $post = Yii::app()->request->getPost('UserForm');
         $userForm->setAttributes($post, false);
         if ($userForm->validate() && UserModel::instance()->insert($post)) {
             $this->redirect(array('/user'));
         }
     }
     $this->setTitle('添加用户');
     $this->render('add', array('userForm' => $userForm));
 }
开发者ID:xiaoxiaochengxyuan,项目名称:kshenghuo,代码行数:16,代码来源:UserController.php

示例3: newUserAction

 public function newUserAction()
 {
     $request = $this->get('request');
     $user = new User();
     $userForm = new UserForm($user);
     if ($request->getMethod() === 'POST') {
         $userForm->bind($request);
         if ($userForm->validate()) {
             $user->save();
             return $this->redirect($this->generateUrl('login'));
         }
     }
     $context = array('form' => $userForm);
     return $this->render('', $context);
 }
开发者ID:Everus,项目名称:wbf.test,代码行数:15,代码来源:userController.php

示例4: actionLogin

 public function actionLogin()
 {
     $model = new UserForm('login');
     if (!empty($_POST['UserForm'])) {
         $model->attributes = $_POST['UserForm'];
         if ($model->validate() && $model->login()) {
             $this->redirect(['cabinet/']);
         }
     }
     if (Yii::app()->request->isAjaxRequest) {
         $this->renderPartial('login', ['model' => $model]);
     } else {
         $this->render('login', ['model' => $model]);
     }
 }
开发者ID:snipesn,项目名称:pravoved,代码行数:15,代码来源:AccessController.php

示例5: actionForget

 public function actionForget()
 {
     $model = new UserForm('foget');
     $msg = '';
     if (!empty($_POST['UserForm'])) {
         $model->attributes = $_POST['UserForm'];
         if ($model->validate()) {
             $user = new UserModel();
             $user->password = UserModel::model()->cryptPass($pass = UserModel::model()->genPassword());
             $user->save();
             Yii::app()->email->send($model->email, 'Новый пароль', 'Ваш новый пароль:' . $pass);
             $msg = 'Новый пароль отправлен Вам на почту.';
         }
     }
     $this->render('forget', ['model' => $model, 'msg' => $msg]);
 }
开发者ID:Alamast,项目名称:pravoved,代码行数:16,代码来源:AccessController.php

示例6: actionEdit

 public function actionEdit()
 {
     $request = Yii::$app->request;
     $user = User::findOne($request->get('id'));
     $model = new UserForm();
     $model->attributes = $user->attributes;
     if ($model->load($request->post()) && $model->validate()) {
         //Overall assignment the attributes of $user must be safe attributes
         $user->attributes = $model->attributes;
         // var_dump($model->attributes);
         // var_dump($user->attributes);exit();
         if ($user->save()) {
             $this->redirect(array('index'));
         } else {
         }
     } else {
         if ($model->hasErrors()) {
             // foreach($model->getErrors() as $error){
             // 	var_dump($error,false);
             // }
         }
     }
     return $this->render('edit', ['model' => $model]);
 }
开发者ID:xitengfei,项目名称:cycling,代码行数:24,代码来源:ItemsController.php

示例7: UserForm

$is_platform_admin = api_is_platform_admin();
$is_course_admin = api_is_allowed_to_edit();
//load data for category, evaluation and links
if (!isset($_GET['selectcat']) || empty($_GET['selectcat'])) {
    $category = 0;
} else {
    $category = Security::remove_XSS($_GET['selectcat']);
}
// search form
$simple_search_form = new UserForm(UserForm::TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' . $selectcat);
$values = $simple_search_form->exportValues();
$keyword = '';
if (isset($_GET['search']) && !empty($_GET['search'])) {
    $keyword = Security::remove_XSS($_GET['search']);
}
if ($simple_search_form->validate() && empty($keyword)) {
    $keyword = $values['keyword'];
}
if (!empty($keyword)) {
    $cats = Category::load($category);
    $allcat = array();
    if (isset($_GET['selectcat']) && $_GET['selectcat'] == 0 && isset($_GET['search'])) {
        $allcat = $cats[0]->get_subcategories(null);
        $allcat_info = Category::find_category($keyword, $allcat);
        $alleval = array();
        $alllink = array();
    } else {
        $alleval = Evaluation::find_evaluations($keyword, $cats[0]->get_id());
        $alllink = LinkFactory::find_links($keyword, $cats[0]->get_id());
    }
} elseif (isset($_GET['studentoverview'])) {
开发者ID:secuencia24,项目名称:chamilo-lms,代码行数:31,代码来源:gradebook.php

示例8: actionCreate

 public function actionCreate()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect($this->createUrl("/account"));
         return;
     }
     $error = array();
     $model = new UserForm();
     if (Yii::app()->request->isPostRequest) {
         $model->attributes = $_POST['UserForm'];
         if ($model->validate()) {
             $post = $_POST['UserForm'];
             $ret = $model->updateUser();
             if ($ret) {
                 Yii::app()->session['user_phone'] = Formatter::formatPhone($post['phone']);
                 $this->redirect(Yii::app()->createUrl('/account/ActiveOtp', array('action' => 'register')));
             } else {
                 $error[] = Yii::t("wap", "Có lỗi xảy ra, vui lòng thử lại sau");
             }
         } else {
             $error[] = Yii::t("wap", "Có lỗi xảy ra, vui lòng thử lại sau");
         }
     }
     $this->render('create', compact('model', 'error'));
 }
开发者ID:giangnh264,项目名称:mobileplus,代码行数:25,代码来源:AccountController.php

示例9: define

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
// change the following paths if necessary
$yii = dirname(__FILE__) . '/_framework/yii.php';
$config = dirname(__FILE__) . '/protected/config/main.php';
require_once $yii;
Yii::createWebApplication($config);
$user = Users::model()->getRecordById(WebUser::ADMIN_ID);
$dirname = dirname(__FILE__);
if (!empty($user)) {
    completeInstallation('warning', 'Admin already created');
}
$model = new UserForm('create_admin');
$model->username = 'admin';
if (isset($_POST['UserForm'])) {
    $model->attributes = $_POST['UserForm'];
    if ($model->validate()) {
        $user = new Users();
        $user->id = 1;
        $user->username = $model->username;
        $user->password = CPasswordHelper::hashPassword($model->password);
        $user->email = $model->email;
        $user->email_verified = 1;
        if ($user->save()) {
            MailHelper::sendUserCredentials($model->username, $model->email, $model->password);
            completeInstallation('success', 'Admin user successfully created');
        }
    }
}
?>

<!DOCTYPE html>
开发者ID:xunicorn,项目名称:ebay-simple-watching,代码行数:31,代码来源:install.php

示例10: UserForm

api_block_anonymous_users();
if (isset($_GET['userid'])) {
    $user_id = Security::remove_XSS($_GET['userid']);
    $user = UserManager::get_user_info_by_id($user_id);
    if (!$user) {
        api_not_allowed();
    }
} else {
    api_not_allowed();
}
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/userform.class.php';
block_students();
$form = new UserForm(UserForm::TYPE_USER_INFO, $user, 'user_info_form', null, api_get_self() . '?userid=' . $user_id . '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
if ($form->validate()) {
    header('Location: user_stats.php?selectcat=' . Security::remove_XSS($_GET['selectcat']) . '&userid=' . $user_id);
    exit;
}
$interbreadcrumb[] = array('url' => $_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook'));
Display::display_header(get_lang('UserInfo'));
//User picture size is calculated from SYSTEM path
$image_syspath = UserManager::get_user_picture_path_by_id($user_id, 'system', false, true);
$image_size = getimagesize($image_syspath['dir'] . $image_syspath['file']);
//Web path
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$image_file = $image_path['dir'] . $image_path['file'];
$img_attributes = 'src="' . $image_file . '?rand=' . time() . '" ' . 'alt="' . api_get_person_name($user_data['firstname'], $user_data['lastname']) . '" ' . 'style="float:left; padding:5px;" ';
if ($image_size[0] > 300) {
    //limit display width to 300px
    $img_attributes .= 'width="300" ';
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:31,代码来源:user_info.php

示例11: actionEdit

 public function actionEdit()
 {
     $uid = urlGETParams('id', VARIABLE_NUMBER);
     $record = $this->getRow($uid);
     if (empty($record)) {
         createMessage('Hệ thống không tìm thấy nội dung bạn yêu cầu', 'danger');
         $this->redirect($this->createUrl('index'));
     }
     $data = array();
     $data['user'] = $record;
     $form = new UserForm();
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $form->attributes = $_POST['UserForm'];
         if ($form->validate()) {
             $values = array();
             foreach ($form->attributes as $key => $vl) {
                 if ($key == 're_password') {
                     continue;
                 }
                 if ($key == 'password') {
                     if (empty($vl)) {
                         continue;
                     }
                     $vl = md5(trim($vl));
                 }
                 $values[$key] = trim($vl);
             }
             yii_update_row($this->_table, $values, 'id = ' . $uid);
             //user rule
             //xoa rule hien tai
             $query = "DELETE FROM {{user_rule}} WHERE uid = " . $uid;
             $this->db->createCommand($query)->execute();
             $user_rule = formPostParams('rule', VARIABLE_ARRAY);
             if (!empty($user_rule)) {
                 $params = array();
                 foreach ($user_rule as $rule_id) {
                     $params[] = array('uid' => $uid, 'rule_id' => $rule_id);
                 }
                 yii_insert_multiple('user_rule', $params);
             }
             createMessage('Sửa thông tin người dùng thành công');
             $this->redirect($this->createUrl('index'));
         }
     } else {
         $form->attributes = $record;
         $form->password = '';
     }
     $data['rule'] = $this->getListRule();
     //lay danh sach quyen
     $query = "SELECT rule_id FROM {{user_rule}} WHERE uid = " . $uid;
     $data['listRole'] = $this->db->createCommand($query)->queryColumn();
     $data['form'] = $form;
     $this->render('add', array('data' => $data));
 }
开发者ID:haanhman,项目名称:rateapp,代码行数:54,代码来源:UserController.php

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

示例13: applyAction

 /**
  * 贷款申请
  */
 public function applyAction($uid = 0)
 {
     $uid = $this->urlParam();
     if ($this->isAjax()) {
         $data = $this->request->getPost();
         $data['oid'] = $this->getOperatorId();
         $data['bid'] = $this->getOperatorBid();
         $User = new User();
         $modelForm = new UserForm('apply');
         if ($modelForm->validate($data)) {
             if ($uid = $modelForm->apply($uid)) {
                 $modelForm = new LoanSketchForm('apply');
                 if ($modelForm->validate($data) and $modelForm->apply($uid)) {
                     Log::add($uid, $data['oid'], \App\Config\Log::loanOperate('apply'));
                     $this->success('操作成功');
                 } else {
                     $this->error('操作失败');
                 }
             } else {
                 $this->error('操作失败');
             }
         } else {
             $this->error('操作失败');
         }
         exit;
     }
     if ($uid) {
         $user = $this->detail($uid, ['user', 'loansketch']);
         $this->view->setVars(array_merge($user['user'], $user['loansketch']));
     }
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:34,代码来源:LoanController.php

示例14: actionLogin

 public function actionLogin()
 {
     $LoginForm = Request::getVar("LoginForm");
     if (Request::getVar("LoginForm") and $LoginForm['username'] == "" || $LoginForm['password'] == "") {
         YiiMessage::raseWarning("Type your username and password");
         $this->redirect(Router::buildLink("users", array("view" => "user", 'layout' => 'login')));
         return;
     }
     $model = new UserForm();
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $model->attributes = $_POST['LoginForm'];
         $session_id = session_id();
         // validate user input and redirect to the previous page if valid
         if ($model->validate() && $model->login()) {
             $this->afterLogin($session_id, session_id());
             $this->redirect(Router::buildLink("cpanel"));
             //                    $this->redirect("/backend/");
         } else {
             YiiMessage::raseWarning("Invalid your usename or password");
         }
     }
     $this->layout = "//login";
     $this->pageTitle = "Page login";
     $this->render('login');
 }
开发者ID:ducdm87,项目名称:gamelienminh,代码行数:26,代码来源:PlayersController.php

示例15: actionAddUser

 public function actionAddUser()
 {
     $model = new UserForm();
     if (isset($_POST['UserForm'])) {
         $model->attributes = $_POST['UserForm'];
         if ($model->validate() && $model->register()) {
             Yii::app()->user->setFlash('notify', array('type' => 'success', 'message' => Yii::t('admin', 'User added')));
             $this->redirect(array('users'));
         } else {
             Yii::app()->user->setFlash('notify', array('type' => 'danger', 'message' => Yii::t('admin', 'User not added')));
         }
     }
     $this->render('users/edit', array('model' => $model));
 }
开发者ID:mrtos,项目名称:OpenNVR,代码行数:14,代码来源:AdminController.php


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