本文整理汇总了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));
}
}
示例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));
}
示例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);
}
示例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]);
}
}
示例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]);
}
示例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]);
}
示例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'])) {
示例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'));
}
示例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>
示例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" ';
示例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));
}
示例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();
}
示例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']));
}
}
示例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');
}
示例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));
}