From: Gustavo Martin Morcuende Date: Sun, 27 May 2012 12:42:30 +0000 (+0200) Subject: Users: edit user's data web page and new layout. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=2e9c0c76f469494c131e0a9d130984bc53e334ef;p=mobi%2F.git Users: edit user's data web page and new layout. --- diff --git a/apps/userfront/modules/user/actions/actions.class.php b/apps/userfront/modules/user/actions/actions.class.php new file mode 100644 index 0000000..35158f6 --- /dev/null +++ b/apps/userfront/modules/user/actions/actions.class.php @@ -0,0 +1,90 @@ +getUser()->getGuardUser()->getId(); + + $this->sf_guard_user = sfGuardUserTable::getInstance()->findOneById($userId); + } + + public function executeShow(sfWebRequest $request) + { + $this->sf_guard_user = Doctrine_Core::getTable('sfGuardUser')->find(array($request->getParameter('id'))); + $this->forward404Unless($this->sf_guard_user); + } + + public function executeNew(sfWebRequest $request) + { + $this->form = new sfGuardUserForm(); + } + + public function executeCreate(sfWebRequest $request) + { + $this->forward404Unless($request->isMethod(sfRequest::POST)); + + $this->form = new sfGuardUserForm(); + + $this->processForm($request, $this->form); + + $this->setTemplate('new'); + } + + public function executeEdit(sfWebRequest $request) + { + //Get user Id + $userId = $this->getUser()->getGuardUser()->getId(); + + $sf_guard_user = sfGuardUserTable::getInstance()->findOneById($userId); + + $this->form = new sfGuardUserForm($sf_guard_user); + } + + public function executeUpdate(sfWebRequest $request) + { + $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT)); + $this->forward404Unless($sf_guard_user = Doctrine_Core::getTable('sfGuardUser')->find(array($request->getParameter('id'))), sprintf('Object sf_guard_user does not exist (%s).', $request->getParameter('id'))); + + //Get user Id + $userId = $this->getUser()->getGuardUser()->getId(); + //Never trust data coming from users + $this->forward404Unless($userId == $sf_guard_user->getId(), sprintf('User does not exist')); + + $this->form = new sfGuardUserForm($sf_guard_user); + + $this->processForm($request, $this->form); + + $this->setTemplate('edit'); + } + + public function executeDelete(sfWebRequest $request) + { + $request->checkCSRFProtection(); + + $this->forward404Unless($sf_guard_user = Doctrine_Core::getTable('sfGuardUser')->find(array($request->getParameter('id'))), sprintf('Object sf_guard_user does not exist (%s).', $request->getParameter('id'))); + $sf_guard_user->delete(); + + $this->redirect('user/index'); + } + + protected function processForm(sfWebRequest $request, sfForm $form) + { + $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName())); + if ($form->isValid()) + { + $sf_guard_user = $form->save(); + + $this->redirect('user/edit?id='.$sf_guard_user->getId()); + } + } +} diff --git a/apps/userfront/modules/user/templates/_form.php b/apps/userfront/modules/user/templates/_form.php new file mode 100644 index 0000000..926b112 --- /dev/null +++ b/apps/userfront/modules/user/templates/_form.php @@ -0,0 +1,25 @@ + + + +
isMultipart() and print 'enctype="multipart/form-data" ' ?>> +getObject()->isNew()): ?> + + + + + + + + + + renderGlobalErrors() ?> + + + + +
+ renderHiddenFields(false) ?> +   + +
+
diff --git a/apps/userfront/modules/user/templates/editSuccess.php b/apps/userfront/modules/user/templates/editSuccess.php new file mode 100644 index 0000000..ac23570 --- /dev/null +++ b/apps/userfront/modules/user/templates/editSuccess.php @@ -0,0 +1,4 @@ +

+ + + $form)) ?> diff --git a/apps/userfront/modules/user/templates/indexSuccess.php b/apps/userfront/modules/user/templates/indexSuccess.php new file mode 100644 index 0000000..28249a8 --- /dev/null +++ b/apps/userfront/modules/user/templates/indexSuccess.php @@ -0,0 +1,29 @@ +

+ + + + + + + + + + + + + + + + + + + + + + + + +
getFirstName() ?>
getLastName() ?>
getEmailAddress() ?>
getLastLogin() ?>
getLanguage()->getLanguageName() ?>
+ + + diff --git a/apps/userfront/modules/user/templates/newSuccess.php b/apps/userfront/modules/user/templates/newSuccess.php new file mode 100644 index 0000000..480f447 --- /dev/null +++ b/apps/userfront/modules/user/templates/newSuccess.php @@ -0,0 +1,3 @@ +

New Sf guard user

+ + $form)) ?> diff --git a/apps/userfront/modules/user/templates/showSuccess.php b/apps/userfront/modules/user/templates/showSuccess.php new file mode 100644 index 0000000..d85fee1 --- /dev/null +++ b/apps/userfront/modules/user/templates/showSuccess.php @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Id:getId() ?>
First name:getFirstName() ?>
Last name:getLastName() ?>
Email address:getEmailAddress() ?>
Username:getUsername() ?>
Algorithm:getAlgorithm() ?>
Salt:getSalt() ?>
Password:getPassword() ?>
Is active:getIsActive() ?>
Is super admin:getIsSuperAdmin() ?>
Last login:getLastLogin() ?>
Language:getLanguageId() ?>
Created at:getCreatedAt() ?>
Updated at:getUpdatedAt() ?>
+ +
+ +Edit +  +List diff --git a/apps/userfront/templates/layout.php b/apps/userfront/templates/layout.php index f62cac1..8b39ba5 100644 --- a/apps/userfront/templates/layout.php +++ b/apps/userfront/templates/layout.php @@ -43,27 +43,11 @@
@@ -76,32 +60,15 @@
- - - - - + - + - -
diff --git a/test/functional/userfront/userActionsTest.php b/test/functional/userfront/userActionsTest.php new file mode 100644 index 0000000..a8156ff --- /dev/null +++ b/test/functional/userfront/userActionsTest.php @@ -0,0 +1,19 @@ + + get('/user/index')-> + + with('request')->begin()-> + isParameter('module', 'user')-> + isParameter('action', 'index')-> + end()-> + + with('response')->begin()-> + isStatusCode(200)-> + checkElement('body', '!/This is a temporary page/')-> + end() +;