--- /dev/null
+<?php
+
+/**
+ * user actions.
+ *
+ * @package mobiads
+ * @subpackage user
+ * @author Gustavo Martin Morcuende
+ * @version
+ */
+class userActions extends sfActions
+{
+ public function executeIndex(sfWebRequest $request)
+ {
+ //Get user Id
+ $userId = $this->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());
+ }
+ }
+}
--- /dev/null
+<?php use_stylesheets_for_form($form) ?>
+<?php use_javascripts_for_form($form) ?>
+
+<form action="<?php echo url_for('user/update?id='.$form->getObject()->getId()) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+<?php if (!$form->getObject()->isNew()): ?>
+<input type="hidden" name="sf_method" value="put" />
+<?php endif; ?>
+ <table>
+ <tfoot>
+ <tr>
+ <td colspan="2">
+ <?php echo $form->renderHiddenFields(false) ?>
+ <a href="<?php echo url_for('user/index') ?>"><?php echo __('Back') ?></a>
+ <input type="submit" value="<?php echo __('Save') ?>" />
+ </td>
+ </tr>
+ </tfoot>
+ <tbody>
+ <?php echo $form->renderGlobalErrors() ?>
+ <tr>
+ <?php echo $form ?>
+ </tr>
+ </tbody>
+ </table>
+</form>
--- /dev/null
+<h2><?php echo __('Edit Your Personal Data') ?></h2>
+
+
+<?php include_partial('form', array('form' => $form)) ?>
--- /dev/null
+<h2><?php echo __('Your Personal Data') ?></h2>
+
+<table id="rounded-corner">
+ <tbody>
+ <tr>
+ <td><?php echo __('First Name: ') ?></td>
+ <td><?php echo $sf_guard_user->getFirstName() ?></td>
+ </tr>
+ <tr>
+ <td><?php echo __('Last Name: ') ?></td>
+ <td><?php echo $sf_guard_user->getLastName() ?></td>
+ </tr>
+ <tr>
+ <td><?php echo __('Email Address: ') ?></td>
+ <td><?php echo $sf_guard_user->getEmailAddress() ?></td>
+ </tr>
+ <tr>
+ <td><?php echo __('Last Login') ?></td>
+ <td><?php echo $sf_guard_user->getLastLogin() ?></td>
+ </tr>
+ <tr>
+ <td><?php echo __('Language') ?></td>
+ <td><?php echo $sf_guard_user->getLanguage()->getLanguageName() ?></td>
+ </tr>
+ </tbody>
+</table>
+
+ <a href="<?php echo url_for('user/edit') ?>" class="bt_green"><span class="bt_green_lft"></span><strong><?php echo __('Edit Your Data') ?></strong><span class="bt_green_r"></span></a>
+
--- /dev/null
+<h1>New Sf guard user</h1>
+
+<?php include_partial('form', array('form' => $form)) ?>
--- /dev/null
+<table>
+ <tbody>
+ <tr>
+ <th>Id:</th>
+ <td><?php echo $sf_guard_user->getId() ?></td>
+ </tr>
+ <tr>
+ <th>First name:</th>
+ <td><?php echo $sf_guard_user->getFirstName() ?></td>
+ </tr>
+ <tr>
+ <th>Last name:</th>
+ <td><?php echo $sf_guard_user->getLastName() ?></td>
+ </tr>
+ <tr>
+ <th>Email address:</th>
+ <td><?php echo $sf_guard_user->getEmailAddress() ?></td>
+ </tr>
+ <tr>
+ <th>Username:</th>
+ <td><?php echo $sf_guard_user->getUsername() ?></td>
+ </tr>
+ <tr>
+ <th>Algorithm:</th>
+ <td><?php echo $sf_guard_user->getAlgorithm() ?></td>
+ </tr>
+ <tr>
+ <th>Salt:</th>
+ <td><?php echo $sf_guard_user->getSalt() ?></td>
+ </tr>
+ <tr>
+ <th>Password:</th>
+ <td><?php echo $sf_guard_user->getPassword() ?></td>
+ </tr>
+ <tr>
+ <th>Is active:</th>
+ <td><?php echo $sf_guard_user->getIsActive() ?></td>
+ </tr>
+ <tr>
+ <th>Is super admin:</th>
+ <td><?php echo $sf_guard_user->getIsSuperAdmin() ?></td>
+ </tr>
+ <tr>
+ <th>Last login:</th>
+ <td><?php echo $sf_guard_user->getLastLogin() ?></td>
+ </tr>
+ <tr>
+ <th>Language:</th>
+ <td><?php echo $sf_guard_user->getLanguageId() ?></td>
+ </tr>
+ <tr>
+ <th>Created at:</th>
+ <td><?php echo $sf_guard_user->getCreatedAt() ?></td>
+ </tr>
+ <tr>
+ <th>Updated at:</th>
+ <td><?php echo $sf_guard_user->getUpdatedAt() ?></td>
+ </tr>
+ </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('user/edit?id='.$sf_guard_user->getId()) ?>">Edit</a>
+
+<a href="<?php echo url_for('user/index') ?>">List</a>
<ul>
<li><a class="current" href="<?php echo url_for('homepage') ?>"><?php echo __('Home') ?></a></li>
<li><a>Manage Categories<!--[if IE 7]><!--></a><!--<![endif]-->
- <!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
- <li><a href="<?php echo url_for('category/new') ?>" title=""><?php echo __('Create New Category') ?></a></li>
+ <li><a href="<?php echo url_for('category/index') ?>" title=""><?php echo __('Categories Index') ?></a></li>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
- <li><a>Manage Offices<!--[if IE 7]><!--></a><!--<![endif]-->
- <!--[if lte IE 6]><table><tr><td><![endif]-->
- <ul>
- <li><a href="<?php echo url_for('office/new') ?>" title=""><?php echo __('Create New Office') ?></a></li>
- </ul>
- <!--[if lte IE 6]></td></tr></table></a><![endif]-->
- </li>
- <li><a>Manage Ads<!--[if IE 7]><!--></a><!--<![endif]-->
- <!--[if lte IE 6]><table><tr><td><![endif]-->
- <ul>
- <li><a href="<?php echo url_for('ad/new') ?>" title=""><?php echo __('Create New Add') ?></a></li>
- </ul>
- <!--[if lte IE 6]></td></tr></table></a><![endif]-->
- </li>
- <li><a href="http://gumartinm.name" title=""><?php echo __('Contact') ?><!--[if IE 7]><!--></a><!--<![endif]--></li>
</ul>
</div>
<div class="center_content">
</div>
<div class="sidebarmenu">
- <a class="menuitem submenuheader" href="<?php echo url_for('office/index') ?>" ><?php echo __('Offices') ?></a>
- <div class="submenu">
- <ul>
- <li><a href="<?php echo url_for('office/index') ?>"><?php echo __('Offices Index') ?></a></li>
- <li><a href="<?php echo url_for('office/new') ?>"><?php echo __('Create New Office') ?></a></li>
- </ul>
- </div>
- <a class="menuitem submenuheader" href=""><?php echo __('Company Categories') ?></a>
- <div class="submenu">
- <ul>
- <li><a href="<?php echo url_for('category/index') ?>"><?php echo __('Company Categories Index') ?></a></li>
- <li><a href="<?php echo url_for('category/new') ?>"><?php echo __('Create New Category') ?></a></li>
- </ul>
- </div>
- <a class="menuitem submenuheader" href=""><?php echo __('Ads Index') ?></a>
+ <a class="menuitem submenuheader" href=""><?php echo __('Categories') ?></a>
<div class="submenu">
<ul>
- <li><a href="<?php echo url_for('ad/index') ?>"><?php echo __('Ads Index') ?></a></li>
- <li><a href="<?php echo url_for('ad/new') ?>"><?php echo __('Create New Ad') ?></a></li>
+ <li><a href="<?php echo url_for('category/index') ?>"><?php echo __('Categories Index') ?></a></li>
</ul>
</div>
- <a class="menuitem_green" href="<?php echo url_for('company/index') ?>"><?php echo __('Your Personal Data') ?></a>
+ <a class="menuitem_green" href="<?php echo url_for('user/index') ?>"><?php echo __('Your Personal Data') ?></a>
- <a class="menuitem_red" href="<?php echo url_for('company/index') ?>"><?php echo __('Your Company') ?></a>
-
</div>
</div>
--- /dev/null
+<?php
+
+include(dirname(__FILE__).'/../../bootstrap/functional.php');
+
+$browser = new sfTestFunctional(new sfBrowser());
+
+$browser->
+ 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()
+;