Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Application\Controllers;
- /**
- * Flex Web PHP Development Framework V1
- * @author: matix
- * @version: 1
- */
- use Application\Plugins\UserManagement\Application\Controllers;
- final class Users extends Controllers\Users
- {
- public function __construct()
- {
- parent::__construct();
- $this->getUser()->geti18n()->setSource('user');
- }
- public function executeIndex()
- {
- $this->users = \User::doSelectLikeUsername($this->getResponse()->getParameter('start'));
- }
- public function executeShow()
- {
- $this->throw404Unless($this->user = \Doctrine_Core::getTable('User')->findOneBySlug($this->getResponse()->getParameter('slug')));
- }
- public function executeLocale()
- {
- if (in_array($this->getResponse()->getParameter('locale'), \Flex\Config\Yml::getAttribute('settings#locales')))
- {
- $locale = $this->getResponse()->getParameter('locale') . '_' . strtoupper($this->getResponse()->getParameter('locale'));
- $this->getUser()->setLocale($locale);
- $this->getUser()->setFlash('notice', $this->getUser()->geti18n()->changed_locale);
- }
- return $this->getResponse()->setLocation($this->getUrl()->getReferer());
- }
- public function executeSettings()
- {
- $this->redirectUnlessLogged();
- // ...
- }
- public function executeEdit()
- {
- $this->redirectUnlessLogged();
- $this->user = $user = $this->getUser()->getUserInfo();
- $this->form = $form = new \Application\Forms\Profile\User;
- $this->interests = $interests = \Flex\Config\Php::getAttribute('user_interests');
- $form->bind($form->convertToFormData($user->toArray()));
- if($form->postAndValid())
- {
- if($this->getResponse()->getParameter('t') == 5)
- {
- $c = new \Experience;
- $c->fromArray($form->asArray());
- $user->Experience->add($c);
- }else{
- $user->fromArray($form->asArray());
- }
- $user->save();
- $this->getUser()->setFlash('notice', __('successfully_updated_data'));
- $this->getResponse()->setLocation($this->getUrl()->getReferer());
- }
- }
- public function executeDestroy()
- {
- $this->redirectUnlessLogged();
- $user_data = $this->getUser()->getUserInfo();
- if($this->getResponse()->isPost())
- {
- if(sha1($this->getResponse()->getPost('password')) == $user_data->password)
- {
- $user_data->delete();
- $this->getUser()->destroy();
- $this->getUser()->setFlash('notice', __('successfully_deleted_account'));
- return $this->getResponse()->setLocation($this->getUrl()->generateUrl('root'));
- }else{
- $this->getUser()->setFlash('error', __('invalid_password'));
- return $this->getResponse()->setLocation($this->getUrl()->getReferer());
- }
- }
- }
- public function executePassword()
- {
- $this->redirectUnlessLogged();
- $user = $this->getUser()->getUserInfo();
- $form = $this->form = new \Application\Forms\Profile\Password;
- if($form->postAndValid())
- {
- $user->password = sha1($form->new_password);
- $user->save();
- $this->getUser()->destroy();
- $this->getUser()->setFlash('notice', __('successfully_updated_data'));
- return $this->getResponse()->setLocation($this->getUrl()->getReferer());
- }
- }
- public function executeMail()
- {
- $this->redirectUnlessLogged();
- $user = $this->getUser()->getUserInfo();
- $form = $this->form = new \Application\Forms\Profile\Email;
- if($form->postAndValid())
- {
- $user->mail = $form->new_mail;
- $user->save();
- $this->getUser()->setFlash('notice', __('successfully_updated_data'));
- return $this->getResponse()->setLocation($this->getUrl()->getReferer());
- }
- }
- public function executePrivacy()
- {
- $this->redirectUnlessLogged();
- $user = $this->getUser()->getUserInfo();
- $form = $this->form = new \Application\Forms\Profile\Email;
- if($form->postAndValid())
- {
- $user->mail = $form->new_mail;
- $user->save();
- $this->getUser()->setFlash('notice', __('successfully_updated_data'));
- return $this->getResponse()->setLocation($this->getUrl()->getReferer());
- }
- }
- public function executeDeletePhoto()
- {
- $this->redirectUnlessLogged();
- $userData = $this->getUser()->getUserInfo();
- $userData->photo = NULL;
- $userData->save();
- $this->getUser()->setFlash('notice', __('successfully_updated_data'));
- return $this->getResponse()->setLocation($this->getUrl()->getReferer());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement