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


PHP UserForm类代码示例

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


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

示例1: editAction

 /**
  * Allows users to edit another users' data
  * (should be reserved for administrators)
  *
  * @access public
  * @return void
  */
 public function editAction()
 {
     $this->title = 'Edit this user';
     $form = new UserForm();
     $userModel = new BackofficeUser();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $userModel->save($form->getValues());
             $this->_helper->FlashMessenger(array('msg-success' => 'The user was successfully updated'));
             App_FlagFlippers_Manager::save();
             $this->_redirect('/users/');
         }
     } else {
         $id = $this->_getParam('id');
         if (!is_numeric($id)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The user id you provided is invalid'));
             $this->_redirect('/users/');
         }
         if ($id == 1) {
             $this->_helper->FlashMessenger(array('msg-error' => 'It is forbidden to mess with the admin account in this release.'));
             $this->_redirect('/users/');
         }
         $row = $userModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The requested user could not be found'));
             $this->_redirect('/users/');
         }
         $data = $row->toArray();
         $data['groups'] = $row->groupIds;
         $form->populate($data);
         $this->view->item = $row;
     }
     $this->view->form = $form;
 }
开发者ID:nic162,项目名称:Zend-Framework-Skeleton,代码行数:41,代码来源:UsersController.php

示例2: run

 public function run()
 {
     $model = new UserForm();
     if (($post = $this->request->getPost('UserForm', false)) !== false) {
         $model->attributes = $post;
         if ($model->save()) {
             $this->response(200, '更新用户成功');
         } else {
             $this->response(500, '更新用户失败');
         }
         $this->app->end();
     } else {
         if (($id = $this->request->getQuery('id', 0)) != false) {
             if (($user = User::model()->findByPk($id)) != false) {
                 $model->attributes = ['id' => $user->id, 'username' => $user->username, 'realname' => $user->realname, 'nickname' => $user->nickname, 'email' => $user->email, 'state' => $user->state];
                 $auth = $this->app->getAuthManager();
                 $roles = $auth->getRoleByUserId($id);
                 $role = [];
                 foreach ($roles as $item) {
                     $role[] = $item->getId();
                 }
                 $groups = $auth->getGroupByUserId($id);
                 $group = [];
                 foreach ($groups as $item) {
                     $group[] = $item->getId();
                 }
                 $this->render('edit', ['model' => $model, 'role' => $role, 'group' => $group, 'roleList' => Role::model()->findAll(), 'groupList' => Group::model()->findAll()]);
                 $this->app->end();
             }
         }
     }
     $this->response(404, '参数错误');
 }
开发者ID:syxoasis,项目名称:wakfu-sae,代码行数:33,代码来源:EditAction.php

示例3: actionUser

 public function actionUser()
 {
     $model = new UserForm();
     if ($model->load(Yii::$app->request->post()) && $model->valideate()) {
     } else {
         return $this->render('userForm', ['model' => $model]);
     }
 }
开发者ID:smiyka,项目名称:Yii2-HW,代码行数:8,代码来源:SiteController.php

示例4: register

 /**
  * 用户注册服务
  * 
  *@param UserForm $userInfo
  *@return boolean
  */
 public function register($userInfo)
 {
     $db = $this->_getConnecion();
     $stmt = $db->createStatement('SELECT * FROM user WHERE username=:username');
     if ($stmt->getOne(array(':username' => $userInfo->getUsername()))) {
         $this->showMessage('该用户已经注册.');
     }
     return $db->execute("INSERT INTO user SET " . $db->sqlSingle(array('username' => $userInfo->getUsername(), 'password' => $userInfo->getPassword())));
 }
开发者ID:jellycheng,项目名称:windframework,代码行数:15,代码来源:UserService.php

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

示例6: signupAction

 public function signupAction()
 {
     $account = new Account();
     $accountForm = new AccountForm($account);
     $this->view->accountForm = $accountForm;
     $user = new User();
     $userForm = new UserForm($user);
     $this->view->userForm = $userForm;
     $this->view->setVar("tab", 0);
     if ($this->request->isPost()) {
         try {
             $this->db->begin();
             $accountForm->bind($this->request->getPost(), $account);
             $userForm->bind($this->request->getPost(), $user);
             $idAccountplan = $accountForm->getValue('idAccountplan');
             $idAccounttype = $accountForm->getValue('idAccounttype');
             $city = $accountForm->getValue('city');
             $pass1 = $userForm->getValue('pass1');
             $pass2 = $userForm->getValue('pass2');
             $email = $this->request->getPost('email');
             $this->validateEqualsPassword($pass1, $pass2);
             $this->validateFields(array($idAccounttype, $idAccountplan, $city), array("Debes seleccionar un tipo de cuenta", "Debes seleccionar un plan de pago, recuerda que tenemos algunos gratuitos", "Debes seleccionar una ciudad"));
             if ($this->saveAccount($account, $accountForm, $userForm)) {
                 if ($this->saveUser($user, $account)) {
                     $file = $_FILES['avatar'];
                     $ext = explode("/", $file['type']);
                     $file['newName'] = "{$user->idUser}.{$ext[1]}";
                     $dir = $this->uploader->user_avatar_dir . "/" . $user->idUser . "/images/avatar/";
                     $uploader = new \Sayvot\Misc\Uploader();
                     $uploader->setExtensionsAllowed(array("png", "jpg", "jpeg"));
                     $uploader->setFile($file);
                     $uploader->setMaxSizeSupported($this->uploader->images_max_size);
                     $uploader->setDir($dir);
                     $uploader->validate();
                     $uploader->upload();
                     if ($this->saveCredential($user, $email, $pass1)) {
                         $this->db->commit();
                         $pe = new \Sayvot\Misc\ParametersEncoder();
                         $link = $pe->encodeLink("account/verify", array($account->idAccount, $user->idUser));
                         $this->flashSession->warning($link);
                         return $this->response->redirect("session/login");
                     }
                 }
             }
         } catch (InvalidArgumentException $ex) {
             $this->flashSession->error($ex->getMessage());
             $this->db->rollback();
         } catch (Exception $ex) {
             $this->db->rollback();
             $this->flashSession->error("Ha ocurrido un error, por favor contacta al administrador");
             $this->logger->log("Exception while creating account: " . $ex->getMessage());
             $this->logger->log($ex->getTraceAsString());
         }
     }
 }
开发者ID:willmontiel,项目名称:sayvot,代码行数:55,代码来源:SessionController.php

示例7: actionDatagrid

 public function actionDatagrid()
 {
     $a = Yii::$app;
     $b = $a->params;
     Yii::$app->params['status'];
     $UserForm = new UserForm();
     $UserForm->scenario = 'search';
     $query = $UserForm->search(Yii::$app->request->queryParams);
     $pages = new Pagination(['pageParam' => 'pageCurrent', 'pageSizeParam' => 'pageSize', 'totalCount' => $query->count(), 'defaultPageSize' => 10]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('datagrid', ['models' => $models, 'pages' => $pages]);
 }
开发者ID:171906502,项目名称:wetM2.0,代码行数:12,代码来源:LogmanagerController.php

示例8: actionAccount

 public function actionAccount()
 {
     $model = new UserForm();
     if (($post = $this->request->getPost('UserForm', false)) != false) {
         $model->attributes = $post;
         if ($model->save()) {
             $this->user->logout();
             $this->redirect($this->createUrl('index'));
         }
     }
     $this->render('account', ['model' => $model, 'service' => Service::model()->findByPk($this->user->getId())]);
 }
开发者ID:syxoasis,项目名称:wakfu-sae,代码行数:12,代码来源:IndexController.php

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

示例10: addAction

 public function addAction()
 {
     $form = new UserForm();
     if ($form->isPosted()) {
         if ($form->isValidForAdd()) {
             $id = User::create(["email" => Input::get("email"), "password" => Hash::make(Input::get("password"))])->id;
             $this->defaultGroup($id, 2);
             return Redirect::route("user/profile");
         }
         return Redirect::route("user/add")->withInput(["email" => Input::get("email"), "errors" => $form->getErrors()]);
     }
     return View::make("user/add", ["form" => $form, "HeaderTitle" => "ADD USER"]);
 }
开发者ID:alejandromorg,项目名称:Inventario,代码行数:13,代码来源:UserController.php

示例11: getInstance

 public static function getInstance($id = NULL)
 {
     $form = new UserForm();
     if ($id) {
         $user = User::model()->findByPk($id);
         if ($user) {
             $form->attributes = $user->attributes;
             $form->unsetAttributes(array('password'));
             $form->_userModel = $user;
         }
     }
     return $form;
 }
开发者ID:andrelinoge,项目名称:rezydent,代码行数:13,代码来源:UserForm.php

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

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

示例14: saveUsers

 static function saveUsers($sql, $filename, $how = 'csv')
 {
     $exclude = array('name', 'email');
     $form = UserForm::getUserForm();
     $fields = $form->getExportableFields($exclude);
     // Field selection callback
     $fname = function ($f) {
         return 'cdata.`' . $f->getSelectName() . '` AS __field_' . $f->get('id');
     };
     $sql = substr_replace($sql, ',' . implode(',', array_map($fname, $fields)) . ' ', strpos($sql, 'FROM '), 0);
     $sql = substr_replace($sql, 'LEFT JOIN (' . $form->getCrossTabQuery($form->type, 'user_id', $exclude) . ') cdata
                 ON (cdata.user_id = user.id) ', strpos($sql, 'WHERE '), 0);
     $cdata = array_combine(array_keys($fields), array_values(array_map(function ($f) {
         return $f->get('label');
     }, $fields)));
     ob_start();
     echo self::dumpQuery($sql, array('name' => 'Name', 'organization' => 'Organization', 'email' => 'Email') + $cdata, $how, array('modify' => function (&$record, $keys) use($fields) {
         foreach ($fields as $k => $f) {
             if ($f && ($i = array_search($k, $keys)) !== false) {
                 $record[$i] = $f->export($f->to_php($record[$i]));
             }
         }
         return $record;
     }));
     $stuff = ob_get_contents();
     ob_end_clean();
     if ($stuff) {
         Http::download($filename, "text/{$how}", $stuff);
     }
     return false;
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:31,代码来源:class.export.php

示例15: validationForm

 public function validationForm($table, $value)
 {
     $message = "";
     switch ($table) {
         case 'poste':
             # code...
             $message = PostForm::validation($value);
             break;
         case 'guard':
             # code...
             $message = GuardForm::validation($value);
             break;
         case 'guardtours':
             # code...
             $message = GuardToursForm::validation($value);
             break;
         case 'admin':
             # code...
             $message = UserForm::validation($value);
             break;
         case 'tours':
             # code...
             $message = array('error' => 0);
             break;
         default:
             # code...
             break;
     }
     return $message;
 }
开发者ID:Esdras1995,项目名称:Guardtour,代码行数:30,代码来源:form.php


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