/** * Signed in users can change their password */ public function changePasswordAction() { $user = $this->auth->getUser(); if ($user === false) { $this->flash->success($this->translate->gettext('You must be signed in to change the password')); return $this->dispatcher->forward(['controller' => 'index', 'action' => 'notification']); } $form = new ChangePasswordForm(); $form->setDI($this->getDI()); if ($this->request->isPost()) { if ($form->isValid($this->request->getPost()) !== false) { $user->password = $this->request->getPost('password'); $user->mustChangePassword = '******'; $passwordChange = new PasswordChanges(); $passwordChange->user = $user; $passwordChange->ipAddress = $this->request->getClientAddress(); $passwordChange->userAgent = $this->request->getUserAgent(); if ($passwordChange->save()) { $this->auth->clearNeedToChangePassword(); $this->flash->success($this->translate->gettext('Your password was successfully changed')); Tag::resetInput(); } else { $this->flash->error($passwordChange->getMessages()); } } } $this->view->form = $form; }
public function editAction($id) { $fileStore = FileStore::findFirst($id); if ($fileStore == false) { $this->flash->error(_("Document was not found")); return $this->dispatcher->forward(array('action' => 'index')); } $request = $this->request; $userId = $this->auth->getIdentity(); $form = new FileStoreForm($fileStore, array('edit' => true)); if ($request->isPost()) { if ($form->isValid($request->getPost()) == true && $request->hasFiles() == true) { $fileStore = new FileStore(); foreach ($request->getUploadedFiles() as $file) { $fileStore->assign(array('id' => $id, 'fileName' => $file->getName(), 'fileCaption' => $request->getPost('fileCaption'), 'description' => $request->getPost('description'), 'categoriesId' => $request->getPost('categoriesId'), 'userId' => $userId['id'], 'mimeType' => $file->getType(), 'fileData' => file_get_contents($file->getTempName()))); if ($fileStore->update() == true) { $this->flash->success(_("Update Document success")); Tag::resetInput(); return $this->dispatcher->forward(array('action' => 'index')); } $this->flash->error($fileStore->getMessages()); } } } $this->view->form = $form; }
/** * Creates a User */ public function createAction() { if ($this->request->isPost()) { $user = new Users(); $user->assign(array('name' => $this->request->getPost('name', 'striptags'), 'email' => $this->request->getPost('email', 'email'))); if (!$user->save()) { $this->flash->error($user->getMessages()); } else { $this->flash->success("User was created successfully"); Tag::resetInput(); } } $this->view->form = new UsersForm(null); }
/** * Creates a new Profile * */ public function createAction() { Tag::displayTo("active", "Y"); if ($this->request->isPost()) { $model = new Roles(); $model->assign(array('name' => $this->request->getPost('name', 'striptags'), 'active' => $this->request->getPost('active'))); if (!$model->save()) { $this->flash->error($model->getMessages()); } else { $this->flashSession->success("Новая роль добавлена"); Tag::resetInput(); return $this->response->redirect("backend/roles"); } } }
/** * Creates a User * */ public function createAction() { Tag::displayTo("role_id", 3); if ($this->request->isPost()) { $model = new Users(); $model->assign(array('name' => $this->request->getPost('name', 'striptags'), 'role_id' => $this->request->getPost('role_id', 'int'), 'email' => $this->request->getPost('email', 'email'))); if (!$model->save()) { $this->flash->error($model->getMessages()); } else { $this->flashSession->success("Новый пользователь добавлен"); Tag::resetInput(); return $this->response->redirect("backend/users"); } } }
public function editAction($id) { $categories = Categories::findFirst($id); if ($categories == false) { $this->flash->error("categories was not found"); return $this->dispatcher->forward(array('action' => 'index')); } $request = $this->request; $form = new CategoriesForm($categories, array('edit' => true)); if ($request->isPost()) { if ($form->isValid($request->getPost()) == true) { $categories->assign(array('id' => $id, 'name' => $request->getPost('name'), 'slug' => $request->getPost('slug'))); if ($categories->update() == true) { $this->flash->success(_("Update sucess post")); Tag::resetInput(); return $this->dispatcher->forward(array('action' => 'index')); } $this->flash->error($categories->getMessages()); } } $this->view->form = $form; }
/** * Runs the test for a Tag::$function with $options * * @param string $function * @param mixed $options * @param string $expected * @param boolean $xhtml * @param string $set */ public function testFieldParameter($function, $options, $expected, $xhtml, $set = '') { Tag::resetInput(); if ($xhtml) { Tag::setDocType(Tag::XHTML10_STRICT); $expected .= ' />'; } else { Tag::setDocType(Tag::HTML5); $expected .= '>'; } if ($set) { Tag::displayTo('x_name', 'x_value'); } $actual = Tag::$function($options); if ($set) { Tag::$set('x_name', ''); } $this->assertEquals($expected, $actual); }
/** * Saves the user from the 'edit' action */ public function editAction($id) { $user = Users::findFirstById($id); if (!$user) { $this->flash->error($this->translate->gettext('User was not found')); return $this->dispatcher->forward(['action' => 'index']); } $this->view->user = $user; $form = new UsersForm($user, ['edit' => true]); $form->setDI($this->getDI()); $this->view->form = $form; if ($this->request->isPost()) { if ($form->isValid($this->request->getPost()) !== false) { $user->assign(['name' => $this->request->getPost('name', 'striptags'), 'rolesId' => $this->request->getPost('rolesId', 'int'), 'email' => $this->request->getPost('email', 'email'), 'banned' => $this->request->getPost('banned'), 'active' => $this->request->getPost('active')]); if (!$user->save()) { $this->flash->error($user->getMessages()); } else { $this->flash->success($this->translate->gettext('User was updated successfully')); Tag::resetInput(); } } } }
public static function resetInput() { parent::resetInput(); }
/** * Tests resetInput (after a displayTo) * * @issue 53 * @author Nikos Dimopoulos <*****@*****.**> * @since 2012-10-26 */ public function testResetInputDisplayToXHTMLT53() { \Phalcon\Tag::setDoctype(\Phalcon\Tag::XHTML10_STRICT); $options = 'some_field_name'; $expected = '<input type="text" id="some_field_name" name="some_field_name" value="Wall-E" />'; \Phalcon\Tag::displayTo('some_field_name', 'Wall-E'); $actual = \Phalcon\Tag::textField($options); $this->assertEquals($expected, $actual, sprintf($this->message, 'XHTML resetInput before contains a value')); \Phalcon\Tag::resetInput(); $expected = '<input type="text" id="some_field_name" name="some_field_name" value="" />'; $actual = \Phalcon\Tag::textField($options); \Phalcon\Tag::setDoctype(''); $this->assertEquals($expected, $actual, sprintf($this->message, 'XHTML resetInput after contains a value')); }
/** * @issue 11319 */ public function testResetInput() { Tag::resetInput(); }
/** * Edits an existing Role * * @param int $id */ public function editAction($id) { $role = Roles::findFirstById($id); if (!$role) { $this->flash->error($this->translate->gettext('Role was not found')); return $this->dispatcher->forward(['action' => 'index']); } $this->view->role = $role; $form = new RolesForm($role, ['edit' => true]); $form->setDI($this->getDI()); $this->view->form = $form; if ($this->request->isPost()) { if ($form->isValid($this->request->getPost()) !== false) { $role->assign(['name' => $this->request->getPost('name', 'striptags'), 'active' => $this->request->getPost('active')]); if (!$role->save()) { $this->flash->error($role->getMessages()); } else { $this->flash->success($this->translate->gettext('Role was updated successfully')); } Tag::resetInput(); } } }
public function changePasswordAction() { // get the user resetting password and then log them out so they can't navigate // to other protected parts of the site // rewrite comment,idea has changed /** @var \Talon\Models\Users\Users $user */ $user = $this->auth->getUser(); if (!$user) { $this->flashSession->error(Users::USER_DOES_NOT_EXIST); $this->redirect('session', 'login'); } $form = new ChangePasswordForm(); $code = $this->dispatcher->getParam('code'); if ($code) { $resetPasswords = ResetPasswords::findFirstByCode($code); if ($resetPasswords->reset === 1) { $this->auth->unregisterIdentity(); } } if ($this->request->isPost()) { if ($form->isValid($this->request->getPost()) !== false) { $passwordChange = new PasswordChanges(); $passwordChange->usersId = $user->id; $passwordChange->ipAddress = $this->request->getClientAddress(); $passwordChange->userAgent = $this->request->getUserAgent(); if (!$passwordChange->save()) { $this->flashSession->error($passwordChange->getMessages()); } else { $user->setPassword($this->request->getPost('password')); if ($user->save() === false) { // log user back in so they can get to the form // in case they were resetting password and were logged out $this->auth->authUserById($user->id); foreach ($user->getMessages() as $message) { $this->flashSession->error($message); } } else { $this->flashSession->success('Password changed successfully.'); return $this->redirect('session', 'login'); } } } } Tag::resetInput(); $this->view->setVar('form', $form); }
public function editAction($id) { $post = Posts::findFirst($id); if ($post == false) { $this->flash->error(_("Post was not found")); return $this->dispatcher->forward(array('action' => 'index')); } $request = $this->request; $form = new PostsForm($post, array('edit' => true)); if ($request->isPost()) { if ($form->isValid($request->getPost()) == true) { $userId = $this->auth->getIdentity(); $content = Markdown::defaultTransform($request->getPost('content')); $title = $request->getPost('title'); $post->assign(array('id' => $id, 'title' => $title, 'categoriesId' => $request->getPost('categoriesId'), 'tags' => $request->getPost('tags'), 'slug' => $this->tag->friendlyTitle($this->normalizeChars($title)), 'content' => $content, 'userPost' => $userId['username'], 'numberViews' => $post->numberViews)); if ($post->update() == true) { $this->flash->success(_("Update success")); Tag::resetInput(); return $this->dispatcher->forward(array('action' => 'index')); } $this->flash->error($post->getMessages()); } } $this->view->form = $form; }
/** * Edits an existing Profile * * @param int $id */ public function editAction($id) { $profile = Profiles::findFirstById($id); if (!$profile) { $this->flash->error("Profile was not found"); return $this->dispatcher->forward(array('action' => 'index')); } if ($this->request->isPost()) { $profile->assign(array('name' => $this->request->getPost('name', 'striptags'), 'active' => $this->request->getPost('active'))); if (!$profile->save()) { $this->flash->error($profile->getMessages()); } else { $this->flash->success("Profile was updated successfully"); } Tag::resetInput(); } $this->view->form = new ProfilesForm($profile, array('edit' => true)); $this->view->profile = $profile; }
/** * Users must use this action to change its password */ public function changePasswordAction() { $form = new ChangePasswordForm(); if ($this->request->isPost()) { if (!$form->isValid($this->request->getPost())) { foreach ($form->getMessages() as $message) { $this->flash->error($message); } } else { $user = $this->auth->getUser(); $user->password = $this->security->hash($this->request->getPost('password')); $user->mustChangePassword = '******'; $passwordChange = new PasswordChanges(); $passwordChange->user = $user; $passwordChange->ipAddress = $this->request->getClientAddress(); $passwordChange->userAgent = $this->request->getUserAgent(); if (!$passwordChange->save()) { $this->flash->error($passwordChange->getMessages()); } else { $this->flash->success('Your password was successfully changed'); Tag::resetInput(); } } } $this->view->form = $form; }
/** * Executed before each test * * @param IntegrationTester $I */ public function _before(IntegrationTester $I) { Tag::resetInput(); Tag::setDocType(Tag::HTML5); }