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


PHP UserForm::getValues方法代码示例

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


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

 public function editAction()
 {
     $record = null;
     $photoFilename = null;
     $userId = $this->_request->getParam('id');
     if (!empty($userId)) {
         $record = My_Model::get('Users')->getById($userId);
         if (!$record) {
             throw new Zend_Controller_Action_Exception('The requested page does not exist', 404);
         }
         $this->view->userId = $userId;
     }
     $form = new UserForm();
     $form->setAction($this->_helper->url->url());
     if ($record === null) {
         $this->view->title = 'Add User';
     } else {
         $this->view->title = 'Edit User';
         $form->setModifyMode();
     }
     $this->view->form = $form;
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $formValues = $form->getValues();
             $foundUser = My_Model::get('Users')->fetchRow(array("username = ?" => $formValues["username"]));
             if ($foundUser != null && $foundUser->getId() != $userId) {
                 $form->getElement('username')->addError('This username is taken');
                 $form->markAsError();
                 return;
             }
             //XXX: Je to dobytčárna
             if ($form->photo->receive()) {
                 $photo = $form->photo;
                 $oldFullPath = $photo->getFileName();
                 $path_parts = pathinfo($oldFullPath);
                 if ($path_parts) {
                     $photoFilename = $photo->getHash('md5') . '.' . $path_parts['extension'];
                     $newFullPath = $path_parts['dirname'] . '/' . $photoFilename;
                     rename($oldFullPath, $newFullPath);
                 }
             }
             if ($record === null) {
                 $record = My_Model::get('Users')->createRow();
                 if ($photoFilename) {
                     $record->setPhotoFilename($photoFilename);
                 }
                 $record->updateFromArray($formValues, true);
             } else {
                 if ($photoFilename) {
                     $record->setPhotoFilename($photoFilename);
                 }
                 $record->updateFromArray($formValues, false);
                 //do not update created on value
             }
             //Zend_Debug::dump($formValues);
             //echo '================================================================<br />';
             //Zend_Debug::dump($formValues);
             //echo '========================PHOTO=========================<br />';
             //$var = file_get_contents($form->photo);
             //Zend_Debug::dump($var);
             $this->_helper->flashMessenger->setNamespace("success")->addMessage("Your changes have been saved!");
             $this->_helper->redirector->gotoRoute(array('controller' => 'user'), 'default', true);
         }
     } else {
         if ($record !== null) {
             $form->populate($record->toArray());
         }
     }
 }
开发者ID:cngroupdk,项目名称:InterviewMe_Tym3,代码行数:69,代码来源:UserController.php

示例3: editAction

 public function editAction()
 {
     $this->view->title = 'Edit user profile';
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $form = new UserForm();
     $this->view->form = $form;
     $userId = $this->_request->getParam('id');
     if ($this->getUser()->getid_uzivatel() !== $userId && !$this->getUser()->isAdmin()) {
         // Redirects
         $this->_helper->redirector->gotoRoute(array('controller' => 'candidate', 'action' => 'index'), 'default', true);
         return;
     }
     if (!empty($userId)) {
         $user = My_Model::get('Users')->getById($userId);
         if ($user !== NULL) {
             $form->setDefaults($user->get_data());
             $avatar = $user->getFoto();
             if ($avatar !== NULL) {
                 $base64 = base64_encode($avatar->getfoto());
                 $form->avatar->setAttrib('src', "data:image/gif;base64," . $base64);
             }
         }
     }
     // ########################### POST ###########################
     // Handles form submission
     if ($this->_request->isPost()) {
         if ($this->_request->getPost('saveButton', false)) {
             if ($form->isValid($this->_request->getPost())) {
                 $formValues = $form->getValues();
                 // Profile photo
                 $photo;
                 if ($form->profilePhoto->isUploaded()) {
                     if (!$form->profilePhoto->receive()) {
                         print "Error receiving the file";
                     }
                     // Reads location and creates blob
                     $profilePhotoLocation = $form->profilePhoto->getFileName();
                     $profilePhotoBlob = file_get_contents($profilePhotoLocation);
                     if (!empty($profilePhotoBlob)) {
                         // Creates photo object
                         $photo = My_Model::get('Photos')->createRow();
                         $photo->foto = $profilePhotoBlob;
                         $photo->nazev = array_pop(explode("/", $profilePhotoLocation));
                         $photo->save();
                     }
                     // Deletes file from directory (is already in DB)
                     unlink($profilePhotoLocation);
                 }
                 // Adds photo id
                 if (!empty($photo)) {
                     $formValues['id_fotografie'] = $photo->getid_foto();
                 }
                 if ($user === NULL) {
                     $user = My_Model::get('Users')->createRow();
                 }
                 if (!empty($formValues["heslo"])) {
                     $formValues["heslo"] = sha1("interview" . $formValues["heslo"]);
                 } else {
                     unset($formValues["heslo"]);
                 }
                 $user->updateFromArray($formValues);
                 $this->_helper->redirector->gotoRoute(array('controller' => 'user', 'action' => 'detail', 'id' => $userId), 'default', true);
             }
         } else {
             if ($this->_request->getPost('closeButton', false)) {
                 if (!empty($userId)) {
                     $this->_helper->redirector->gotoRoute(array('controller' => 'user', 'action' => 'detail', 'id' => $userId), 'default', true);
                 } else {
                     $this->_helper->redirector->gotoRoute(array('controller' => 'user', 'action' => 'index'), 'default', true);
                 }
             } else {
                 if ($this->_request->getPost('deleteButton', false)) {
                     if (!empty($userId)) {
                         My_Model::get('Users')->getById($userId)->delete();
                     }
                     $this->_helper->redirector->gotoRoute(array('controller' => 'user', 'action' => 'index'), 'default', true);
                 }
             }
         }
     }
 }
开发者ID:cngroupdk,项目名称:InterviewMe_Tym1,代码行数:81,代码来源:UserController.php

示例4: executeUpdate

 public function executeUpdate($request)
 {
     $object = $this->getRequestParameter('object');
     $user = User::getByApiKey($request->getParameter('login_id'), $request->getParameter('api_key'));
     if (!$user) {
         $output = '<rsp stat="fail"><err code="2" msg="login_id and api_key do not match" /></rsp>';
     } elseif ($object == 'application') {
         $form = new ApplicationForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'description' => $request->getParameter('description'), 'source_url' => $request->getParameter('source_url')));
         if ($form->isValid()) {
             $application = Application::update($form->getValues(), $user);
             if ($application) {
                 $output = '<rsp stat="ok">' . $application->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="4" msg="Unable to update application." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="4" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'comment') {
         $form = new CommentForm();
         $application_id = $module_id = $theme_id = null;
         if ($request->getParameter('application_id')) {
             $application_id = $request->getParameter('application_id');
         }
         if ($request->getParameter('module_id')) {
             $module_id = $request->getParameter('module_id');
         }
         if ($request->getParameter('theme_id')) {
             $theme_id = $request->getParameter('theme_id');
         }
         $form->bind(array('comment' => $request->getParameter('comment'), 'application_id' => $application_id, 'module_id' => $module_id, 'theme_id' => $theme_id));
         if ($form->isValid()) {
             $comment = Comment::update($form->getValues(), $user);
             $output = '<rsp stat="ok">' . $comment->getXML() . '</rsp>';
         } else {
             $output = '<rsp stat="fail"><err code="3" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'module') {
         $form = new ModuleForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'description' => $request->getParameter('description'), 'source_url' => $request->getParameter('source_url'), 'application_id' => $request->getParameter('application_id')));
         if ($form->isValid()) {
             $module = Madule::update($form->getValues(), $user);
             if ($module) {
                 $output = '<rsp stat="ok">' . $module->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="4" msg="Unable to update module." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="4" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'theme') {
         $form = new ThemeForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'description' => $request->getParameter('description')), $request->getFiles());
         if ($form->isValid()) {
             $theme = Theme::update($form->getValues(), $user);
             if ($theme) {
                 $output = '<rsp stat="ok">' . $theme->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="5" msg="Unable to update theme." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="5" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     } elseif ($object == 'theme_group') {
         $output = '<rsp stat="fail"><err code="6" msg="This object is not supported for update" /></rsp>';
     } elseif ($object == 'user') {
         $form = new UserForm();
         $form->bind(array('id' => $request->getParameter('id'), 'name' => $request->getParameter('name'), 'password' => $request->getParameter('password'), 'password2' => $request->getParameter('password'), 'email' => $request->getParameter('email'), 'role' => null));
         if ($form->isValid()) {
             $update_user = User::update($form->getValues(), $user);
             if ($update_user) {
                 $output = '<rsp stat="ok">' . $update_user->getXML() . '</rsp>';
             } else {
                 $output = '<rsp stat="fail"><err code="7" msg="Unable to update user." /></rsp>';
             }
         } else {
             $output = '<rsp stat="fail"><err code="7" msg="' . $form->getErrorSchema() . '" /></rsp>';
         }
     }
     $this->output = $output;
     $this->setTemplate('index');
 }
开发者ID:amitesh-singh,项目名称:Enlightenment,代码行数:83,代码来源:actions.class.php


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