Working on the userfront application.
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Tue, 22 May 2012 06:25:41 +0000 (08:25 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Tue, 22 May 2012 06:25:41 +0000 (08:25 +0200)
Layout, javascript to update chosen categories.

33 files changed:
apps/companyfront/templates/layout.php
apps/companyfront/templates/layoutsfGuardAuth.php
apps/userfront/config/app.yml [new file with mode: 0644]
apps/userfront/config/cache.yml [new file with mode: 0644]
apps/userfront/config/factories.yml [new file with mode: 0644]
apps/userfront/config/filters.yml [new file with mode: 0644]
apps/userfront/config/routing.yml [new file with mode: 0644]
apps/userfront/config/security.yml [new file with mode: 0644]
apps/userfront/config/settings.yml [new file with mode: 0644]
apps/userfront/config/userfrontConfiguration.class.php [new file with mode: 0644]
apps/userfront/config/view.yml [new file with mode: 0644]
apps/userfront/lib/myUser.class.php [new file with mode: 0644]
apps/userfront/modules/api/actions/actions.class.php [new file with mode: 0644]
apps/userfront/modules/api/config/security.yml [new file with mode: 0644]
apps/userfront/modules/api/templates/getadsbygpsSuccess.json.php [new file with mode: 0644]
apps/userfront/modules/api/templates/indexSuccess.php [new file with mode: 0644]
apps/userfront/modules/api/templates/loginauthSuccess.json.php [new file with mode: 0644]
apps/userfront/modules/api/templates/logoutauthSuccess.json.php [new file with mode: 0644]
apps/userfront/modules/api/templates/signinSuccess.php [new file with mode: 0644]
apps/userfront/modules/category/actions/actions.class.php [new file with mode: 0644]
apps/userfront/modules/category/templates/_form.php [new file with mode: 0644]
apps/userfront/modules/category/templates/editSuccess.php [new file with mode: 0644]
apps/userfront/modules/category/templates/indexSuccess.php [new file with mode: 0644]
apps/userfront/modules/category/templates/newSuccess.php [new file with mode: 0644]
apps/userfront/modules/category/templates/showSuccess.php [new file with mode: 0644]
apps/userfront/modules/sfGuardAuth/config/view.yml [new file with mode: 0644]
apps/userfront/modules/sfGuardAuth/templates/_signin_form.php [new file with mode: 0644]
apps/userfront/templates/layout.php [new file with mode: 0644]
apps/userfront/templates/layoutsfGuardAuth.php [new file with mode: 0644]
lib/model/doctrine/GeneralCategoryTable.class.php
test/functional/userfront/categoryActionsTest.php [new file with mode: 0644]
web/userfront.php [new file with mode: 0644]
web/userfront_dev.php [new file with mode: 0644]

index 286dfe5..f62cac1 100644 (file)
                     <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>
+                <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>
+                    </ul>
+                </div>
                 
-                <a class="menuitem_green" href="<?php echo url_for('ad/index') ?>"><?php echo __('Ads Index') ?></a>
+                <a class="menuitem_green" href="<?php echo url_for('company/index') ?>"><?php echo __('Your Personal Data') ?></a>
                 
                 <a class="menuitem_red" href="<?php echo url_for('company/index') ?>"><?php echo __('Your Company') ?></a>
                     
index 5b89487..296f96c 100644 (file)
@@ -4,7 +4,7 @@
     <?php include_http_metas() ?>
     <?php include_metas() ?>
     <link rel="shortcut icon" href="/favicon.ico" />
-    <title>Mobi - Mobile Ads</title>
+    <title><?php echo __('Mobi - Mobile Ads') ?></title>
     <?php include_stylesheets() ?>
   </head>
   <body>
@@ -16,7 +16,7 @@
                <?php echo $sf_content ?>
     </div>  
        <div class="footer_login">
-        <div class="left_footer_login">MOBI ADS | Powered by <a href="http://uah.es">UAH</a></div>
+        <div class="left_footer_login">MOBILE ADS | Powered by <a href="http://uah.es">UAH</a></div>
         <div class="right_footer_login"><a href="http://uah.es"><img src="" alt="" title="" border="0" /></a></div>
     </div>
    </div>              
diff --git a/apps/userfront/config/app.yml b/apps/userfront/config/app.yml
new file mode 100644 (file)
index 0000000..e5ccf79
--- /dev/null
@@ -0,0 +1,18 @@
+# You can find more information about this file on the symfony website:
+# http://www.symfony-project.org/reference/1_4/en/11-App
+
+# default values
+all:
+  default_language: eng                              # Everything must exist at least with this language
+  # Using meters for the radius parameter in PostGIS
+  radius: 100
+
+  sf_guard_plugin:
+     remember_key_expiration_age: 2592000            # 30 days in seconds
+     remember_cookie_name:        mobiuserRemember   # used by sfGuardSecurityUser.class.php
+     success_signin_url:          @homepage          # the plugin uses the referer as default
+     success_signout_url:         @sf_guard_signin   # used by BasesfGuardAuthActions.class.php. After logout we are redirected to this page
+     signin_url_path:             login              # used by sfGuardRememberMeFilter.class.php. The Remember cookie must not be used when using the login page
+     remember_cookie_path:        /userfront.php     # used by sfGuardSecurityUser.class.php. The scope of the Remeber cookie
+     remember_cookie_domain:      .localhost
+
diff --git a/apps/userfront/config/cache.yml b/apps/userfront/config/cache.yml
new file mode 100644 (file)
index 0000000..4eecbf7
--- /dev/null
@@ -0,0 +1,7 @@
+# You can find more information about this file on the symfony website:
+# http://www.symfony-project.org/reference/1_4/en/09-Cache
+
+default:
+  enabled:     false
+  with_layout: false
+  lifetime:    86400
diff --git a/apps/userfront/config/factories.yml b/apps/userfront/config/factories.yml
new file mode 100644 (file)
index 0000000..dda50c6
--- /dev/null
@@ -0,0 +1,49 @@
+# You can find more information about this file on the symfony website:
+# http://www.symfony-project.org/reference/1_4/en/05-Factories
+
+prod:
+  logger:
+    class:   sfNoLogger
+    param:
+      level:   err
+      loggers: ~
+
+  storage:
+    class: sfSessionStorage
+    param:
+      session_name:            mobiuser
+      session_cookie_path:     /userfront.php
+      session_cookie_lifetime: 0  # The cookie will be deleted in the browser when it is closed
+
+test:
+  storage:
+    class: sfSessionTestStorage
+    param:
+      session_path: %SF_TEST_CACHE_DIR%/sessions
+
+  response:
+    class: sfWebResponse
+    param:
+      send_http_headers: false
+
+  mailer:
+    param:
+      delivery_strategy: none
+
+dev:
+  mailer:
+    param:
+      delivery_strategy: none
+
+all:
+  routing:
+    class: sfPatternRouting
+    param:
+      generate_shortest_url:            true
+      extra_parameters_as_query_string: true
+
+  view_cache_manager:
+    class: sfViewCacheManager
+    param:
+      cache_key_use_vary_headers: true
+      cache_key_use_host_name:    true
diff --git a/apps/userfront/config/filters.yml b/apps/userfront/config/filters.yml
new file mode 100644 (file)
index 0000000..cc999d0
--- /dev/null
@@ -0,0 +1,12 @@
+# You can find more information about this file on the symfony website:
+# http://www.symfony-project.org/reference/1_4/en/12-Filters
+
+rendering: ~
+remember_me:
+  class: sfGuardRememberMeFilter
+security:  ~
+
+# insert your own filters here
+
+cache:     ~
+execution: ~
diff --git a/apps/userfront/config/routing.yml b/apps/userfront/config/routing.yml
new file mode 100644 (file)
index 0000000..9e69288
--- /dev/null
@@ -0,0 +1,61 @@
+# You can find more information about this file on the symfony website:
+# http://www.symfony-project.org/reference/1_4/en/10-Routing
+
+# default rules
+homepage:
+  url:     /
+  class:   sfDoctrineRoute
+  param:   { module: category, action: index }
+  options: { model: GeneralCategory, type: object }
+
+categories_index:
+  url:     /category/index
+  class:   sfDoctrineRoute 
+  param:   { module: category, action: index }
+  options: { model: GeneralCategory, type: object }
+
+
+# http://localhost/userfront.php/api/51,32/0,5/gpsads.xml   latitude/longitude
+api_getadsbygps:
+  url:     /api/:latitude/:longitude/gpsads.:sf_format
+#  class:   sfDoctrineRoute
+  class:   sfRequestRoute
+  param:   { module: api, action: getadsbygps }
+#  options: { model: Anuncio, type: list, method: getAdsByGPS } I can not use this one because I can not pass the userId to this method in AnuncioTable.
+  requirements:
+   sf_format: (?:json)
+   #sf_format: (?:xml|json|yaml)
+   sf_method: [GET]
+
+api_loginauth:
+  url:     /api/login/auth.:sf_format
+  class:   sfRequestRoute
+  param:   { module: api, action: loginauth }
+  requirements:
+   sf_format: (?:json)
+   sf_method: [POST]
+
+api_logoutauth:
+  url:     /api/logout/auth.:sf_format
+  class:   sfRequestRoute
+  param:   { module: api, action: logoutauth }
+  requirements:
+   sf_format: (?:json)
+   sf_method: [GET]
+
+# generic rules
+# please, remove them by adding more specific rules
+default_index:
+  url:   /:module
+  param: { action: index }
+
+default:
+  url:   /:module/:action/*
+
+sf_guard_signin:
+  url:   /login
+  param: { module: sfGuardAuth, action: signin }
+
+sf_guard_signout:
+  url:   /logout
+  param: { module: sfGuardAuth, action: signout }
diff --git a/apps/userfront/config/security.yml b/apps/userfront/config/security.yml
new file mode 100644 (file)
index 0000000..3b12e8d
--- /dev/null
@@ -0,0 +1,6 @@
+# You can find more information about this file on the symfony website:
+# http://www.symfony-project.org/reference/1_4/en/08-Security
+
+default:
+  is_secure: true
+  credentials: users
diff --git a/apps/userfront/config/settings.yml b/apps/userfront/config/settings.yml
new file mode 100644 (file)
index 0000000..57a00ba
--- /dev/null
@@ -0,0 +1,44 @@
+# You can find more information about this file on the symfony website:
+# http://www.symfony-project.org/reference/1_4/en/04-Settings
+
+prod:
+  .settings:
+    no_script_name:         false
+    logging_enabled:        false
+
+dev:
+  .settings:
+    error_reporting:        <?php echo (E_ALL | E_STRICT)."\n" ?>
+    web_debug:              true
+    cache:                  false
+    no_script_name:         false
+    etag:                   false
+
+test:
+  .settings:
+    error_reporting:        <?php echo ((E_ALL | E_STRICT) ^ E_NOTICE)."\n" ?>
+    cache:                  false
+    web_debug:              false
+    no_script_name:         false
+    etag:                   false
+
+all:
+  .settings:
+    # Form security secret (CSRF protection)
+    csrf_secret:            ca31cbfa36656b0e00f28967e0960b6ba8b993fe
+    enabled_modules:        [default, sfGuardAuth]
+    standard_helpers:       [Partial, Cache, I18N]
+
+    # Output escaping settings
+    escaping_strategy:      true
+    escaping_method:        ESC_SPECIALCHARS
+
+    # Enable the database manager
+    use_database:           true
+
+  .actions:
+    login_module:           sfGuardAuth
+    login_action:           signin
+
+    secure_module:          sfGuardAuth
+    secure_action:          secure
diff --git a/apps/userfront/config/userfrontConfiguration.class.php b/apps/userfront/config/userfrontConfiguration.class.php
new file mode 100644 (file)
index 0000000..4b9f817
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+
+class userfrontConfiguration extends sfApplicationConfiguration
+{
+  public function configure()
+  {
+  }
+}
diff --git a/apps/userfront/config/view.yml b/apps/userfront/config/view.yml
new file mode 100644 (file)
index 0000000..5db0828
--- /dev/null
@@ -0,0 +1,20 @@
+# You can find more information about this file on the symfony website:
+# http://www.symfony-project.org/reference/1_4/en/13-View
+
+default:
+  http_metas:
+    content-type: text/html
+
+  metas:
+    #title:        symfony project
+    #description:  symfony project
+    #keywords:     symfony, project
+    #language:     en
+    #robots:       index, follow
+
+  stylesheets:    [inadminpanel/style.css, inadminpanel/niceforms-default.css, jquery.treeTable.css]
+
+  javascripts:    [jquery-1.6.2.min.js, jquery.treeTable.js, inadminpanel/ddaccordion.js]
+
+  has_layout:     true
+  layout:         layout
diff --git a/apps/userfront/lib/myUser.class.php b/apps/userfront/lib/myUser.class.php
new file mode 100644 (file)
index 0000000..c417075
--- /dev/null
@@ -0,0 +1,6 @@
+<?php
+
+//class myUser extends sfBasicSecurityUser
+class myUser extends sfGuardSecurityUser
+{
+}
diff --git a/apps/userfront/modules/api/actions/actions.class.php b/apps/userfront/modules/api/actions/actions.class.php
new file mode 100644 (file)
index 0000000..a41f588
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+
+/**
+ * api actions.
+ *
+ * @package    mobileadvertising
+ * @subpackage api
+ * @author     Your name here
+ * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
+ */
+class apiActions extends sfActions
+{
+ /**
+  * Executes index action
+  *
+  * @param sfRequest $request A request object
+  */
+  public function executeIndex(sfWebRequest $request)
+  {
+    $this->forward('default', 'module');
+  }
+
+ /**
+  * RESTful Web Service: receiving latitude and longitude, it sends a response with the found ads on thoses coordinates.
+  * 
+  * We will try to reduce as much as we can the number of methods and queries. While the tables in the data base do not have many rows 
+  * we will try to make the queries directly in the data base. When the tables get bigger than now probably we are going to need
+  * a solution based on queries to data base and php code. Right now and with this size, the fastest solution (IMHO) is to make the queries
+  * directly on the data base.
+  *
+  * TODO: Take measures about the performance using queries directly to the data base and using Doctrine Objects with PHP
+  *       Choose this or the other one solution. I got no time to make this profiling before. But to be serious I should do it.  
+  *       Now I am using queries directly to the data base because I am making the supposition that this is the best to achieve high performance. 
+  *
+  * TODO: C-programmed dedicated server to make this stuff without using PHP should be the best to achieve the max performance.
+  * 
+  * @param sfRequest $request A request object
+  */
+  public function executeGetadsbygps(sfWebRequest $request)
+  {
+       //With RESTFUL is allowed to use cookies to get authentication (user / password)
+       $this->ads = AdTable::getInstance()->getAdsByGPSandUserId($this->getRoute()->getParameters(), $this->getUser()->getGuardUser()->getId());
+       if (!$this->ads)
+       {
+               //If there are not results.
+               //In production replace this line by a die command (trying to stop wasting TCP bandwidth)
+               throw new sfError404Exception(sprintf('
+                       There are not offices with GPS coordinates: longitude "%s" and 
+                       latitude "%s".', $request->getParameter('longitude'), $request->getParameter('latitude')));
+               //die;
+       }
+  }
+
+ /**
+  * RESTful Web Service: authentication by username/email and password.
+  * 
+  * This service checks the username and password. It must response with OK or NOK and the user's cookie
+  * See in this module the config/security.yml file. This action must not be executed under security conditions
+  *
+  * @param sfRequest $request A request object
+  */
+  public function executeLoginauth(sfWebRequest $request)
+  {
+    //If everything goes alright the mobile will receive HTTP 200 OK, otherwise HTTP 401 Unauthorized or 400 Bad Request
+    $this->getResponse()->setStatusCode(401);
+
+    if ($this->getUser()->isAuthenticated())
+    {
+      //If the mobile is authenticated, why the heck it is reaching this code? It must log in just once, when launching the application
+      $this->getResponse()->setStatusCode(400);
+    }
+    else
+    {
+         $form = new WebServiceSigninForm();
+      //TODO: JSON instead of signin array as container to send the data from the mobile to this Web Service (I have no time right now...)
+      $form->bind($request->getParameter('signin'));
+      if ($form->isValid())
+      {
+        $values = $form->getValues();
+        $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false);
+        $this->getResponse()->setStatusCode(200);
+      }
+    }
+
+    //Returning from this function with the StatusCode with its right value
+
+  }    
+
+ /** 
+  * RESTful Web Service: log out from the web application
+  *
+  * This service checks the cookie sent by the user. If the user is authenticated it removes his/her permissions.
+  * See in this module the config/security.yml file. This action must not be executed under security conditions
+  *
+  * @param sfRequest $request A request object
+  */
+  public function executeLogoutauth($request)
+  {
+    //If everything goes alright the mobile will receive HTTP 200 OK, otherwise HTTP 500 Internal Server Error
+    $this->getResponse()->setStatusCode(500);
+    $this->getUser()->signOut();
+    $this->getResponse()->setStatusCode(200);
+  }
+}
diff --git a/apps/userfront/modules/api/config/security.yml b/apps/userfront/modules/api/config/security.yml
new file mode 100644 (file)
index 0000000..b63a388
--- /dev/null
@@ -0,0 +1,7 @@
+
+
+loginauth:
+  is_secure: false
+
+logoutauth:
+  is_secure: false
diff --git a/apps/userfront/modules/api/templates/getadsbygpsSuccess.json.php b/apps/userfront/modules/api/templates/getadsbygpsSuccess.json.php
new file mode 100644 (file)
index 0000000..b951d93
--- /dev/null
@@ -0,0 +1,5 @@
+[
+<?php foreach ($ads as $ad): ?>
+  { "id" : "<?php echo $ad->getId()?>", "domain" : "<?php echo $ad->getDomain()?>", "link" : "<?php echo $ad->getLinks()?>" },
+<?php endforeach ?>
+]
diff --git a/apps/userfront/modules/api/templates/indexSuccess.php b/apps/userfront/modules/api/templates/indexSuccess.php
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/apps/userfront/modules/api/templates/loginauthSuccess.json.php b/apps/userfront/modules/api/templates/loginauthSuccess.json.php
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/apps/userfront/modules/api/templates/logoutauthSuccess.json.php b/apps/userfront/modules/api/templates/logoutauthSuccess.json.php
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/apps/userfront/modules/api/templates/signinSuccess.php b/apps/userfront/modules/api/templates/signinSuccess.php
new file mode 100644 (file)
index 0000000..54d0b25
--- /dev/null
@@ -0,0 +1,5 @@
+<?php use_helper('I18N') ?>
+
+<h1><center><?php echo __('Mobi-Ads Login', null, 'sf_guard') ?></center></h1>
+
+<?php echo get_partial('sfGuardAuth/signin_form', array('form' => $form)) ?>
diff --git a/apps/userfront/modules/category/actions/actions.class.php b/apps/userfront/modules/category/actions/actions.class.php
new file mode 100644 (file)
index 0000000..aedc677
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+
+/**
+ * category actions.
+ *
+ * @package    mobiads
+ * @subpackage category
+ * @author     Gustavo Martin Morcuende
+ * @version
+ */
+class categoryActions extends sfActions
+{
+  public function executeIndex(sfWebRequest $request)
+  {
+    $this->userId = $this->getUser()->getGuardUser()->getId();
+
+    //Doctrine Query used to show a list with the General Categories (execute returns a Doctrine Collection of Doctrine Records)
+    $this->generalCategories = $query=GeneralCategoryTable::getInstance()->getGeneralCategoriesByLftQuery()->execute();
+  }
+
+  public function executeShow(sfWebRequest $request)
+  {
+    $this->general_category = Doctrine_Core::getTable('GeneralCategory')->find(array($request->getParameter('id')));
+    $this->forward404Unless($this->general_category);
+  }
+
+  public function executeNew(sfWebRequest $request)
+  {
+    $this->form = new GeneralCategoryForm();
+  }
+
+  public function executeCreate(sfWebRequest $request)
+  {
+    $this->forward404Unless($request->isMethod(sfRequest::POST));
+
+    $this->form = new GeneralCategoryForm();
+
+    $this->processForm($request, $this->form);
+
+    $this->setTemplate('new');
+  }
+
+  public function executeEdit(sfWebRequest $request)
+  {
+    $this->forward404Unless($general_category = Doctrine_Core::getTable('GeneralCategory')->find(array($request->getParameter('id'))), sprintf('Object general_category does not exist (%s).', $request->getParameter('id')));
+    $this->form = new GeneralCategoryForm($general_category);
+  }
+
+  public function executeUpdate(sfWebRequest $request)
+  {
+    $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
+    $this->forward404Unless($general_category = Doctrine_Core::getTable('GeneralCategory')->find(array($request->getParameter('id'))), sprintf('Object general_category does not exist (%s).', $request->getParameter('id')));
+    $this->form = new GeneralCategoryForm($general_category);
+
+    $this->processForm($request, $this->form);
+
+    $this->setTemplate('edit');
+  }
+
+  public function executeDelete(sfWebRequest $request)
+  {
+    $request->checkCSRFProtection();
+
+    $this->forward404Unless($general_category = Doctrine_Core::getTable('GeneralCategory')->find(array($request->getParameter('id'))), sprintf('Object general_category does not exist (%s).', $request->getParameter('id')));
+    $general_category->delete();
+
+    $this->redirect('category/index');
+  }
+
+  protected function processForm(sfWebRequest $request, sfForm $form)
+  {
+    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
+    if ($form->isValid())
+    {
+      $general_category = $form->save();
+
+      $this->redirect('category/edit?id='.$general_category->getId());
+    }
+  }
+}
diff --git a/apps/userfront/modules/category/templates/_form.php b/apps/userfront/modules/category/templates/_form.php
new file mode 100644 (file)
index 0000000..2c0b213
--- /dev/null
@@ -0,0 +1,67 @@
+<?php use_stylesheets_for_form($form) ?>
+<?php use_javascripts_for_form($form) ?>
+
+<form action="<?php echo url_for('category/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?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) ?>
+          &nbsp;<a href="<?php echo url_for('category/index') ?>">Back to list</a>
+          <?php if (!$form->getObject()->isNew()): ?>
+            &nbsp;<?php echo link_to('Delete', 'category/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
+          <?php endif; ?>
+          <input type="submit" value="Save" />
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr>
+        <th><?php echo $form['created_at']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['created_at']->renderError() ?>
+          <?php echo $form['created_at'] ?>
+        </td>
+      </tr>
+      <tr>
+        <th><?php echo $form['updated_at']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['updated_at']->renderError() ?>
+          <?php echo $form['updated_at'] ?>
+        </td>
+      </tr>
+      <tr>
+        <th><?php echo $form['root_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['root_id']->renderError() ?>
+          <?php echo $form['root_id'] ?>
+        </td>
+      </tr>
+      <tr>
+        <th><?php echo $form['lft']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['lft']->renderError() ?>
+          <?php echo $form['lft'] ?>
+        </td>
+      </tr>
+      <tr>
+        <th><?php echo $form['rgt']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['rgt']->renderError() ?>
+          <?php echo $form['rgt'] ?>
+        </td>
+      </tr>
+      <tr>
+        <th><?php echo $form['level']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['level']->renderError() ?>
+          <?php echo $form['level'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>
diff --git a/apps/userfront/modules/category/templates/editSuccess.php b/apps/userfront/modules/category/templates/editSuccess.php
new file mode 100644 (file)
index 0000000..375523c
--- /dev/null
@@ -0,0 +1,3 @@
+<h1>Edit General category</h1>
+
+<?php include_partial('form', array('form' => $form)) ?>
diff --git a/apps/userfront/modules/category/templates/indexSuccess.php b/apps/userfront/modules/category/templates/indexSuccess.php
new file mode 100644 (file)
index 0000000..7475768
--- /dev/null
@@ -0,0 +1,54 @@
+<h2><?php echo __('General Categories') ?></h2>
+
+
+<script type="text/javascript">
+        $(document).ready(function()  {
+            $("#rounded-corner").treeTable();
+        });
+</script>
+<script type="text/javascript">
+    $.fn.UpdateCategories = function() {
+        var allVals = [];
+        $('#rounded-corner :checked').each(function() {
+                allVals.push($(this).val());
+               });
+        alert(allVals);
+        $.post('prueba.html', {'choices': allVals}, function(data){ alert(data);} ,"json");
+    };
+</script>
+
+
+
+<table id="rounded-corner">
+  <thead>
+    <tr>
+      <th scope="col" class="rounded-company"><?php echo __('General Category Name') ?></th>
+      <th scope="col" class="rounded"><?php echo __('Selected') ?></th>
+      <th scope="col" class="rounded-q4"></th>
+    </tr>
+  </thead>
+  <tbody>
+    <?php foreach ($generalCategories as $category): ?>
+    <tr id="node-<?php echo $category->getId()?>" <?php
+      // insert hierarchical info
+      $node = $category->getNode();
+      if ($node->isValidNode() && $node->hasParent() && ($node->getParent()->getId() != '1'))
+      {
+        echo 'class="child-of-node-'.$node->getParent()->getId().'"';
+      }
+      ?>>
+      <td><a><?php echo $category ?></a></td>
+      <td><input type="checkbox" id="chosen" value="<?php echo $category->getId() ?>"
+      <?php foreach ($category->getUserBaskets() as $userBasket): ?>
+        <?php if ($userBasket->getUserId() == $userId): ?>
+            checked
+            <?php break ?>
+        <?php endif; ?>
+      <?php endforeach; ?>
+      ></td>
+    </tr>
+    <?php endforeach; ?>
+  </tbody>
+</table>
+
+<input type="button" value="Update" onClick="$(this).UpdateCategories();"/>
diff --git a/apps/userfront/modules/category/templates/newSuccess.php b/apps/userfront/modules/category/templates/newSuccess.php
new file mode 100644 (file)
index 0000000..236934d
--- /dev/null
@@ -0,0 +1,3 @@
+<h1>New General category</h1>
+
+<?php include_partial('form', array('form' => $form)) ?>
diff --git a/apps/userfront/modules/category/templates/showSuccess.php b/apps/userfront/modules/category/templates/showSuccess.php
new file mode 100644 (file)
index 0000000..a68d8a1
--- /dev/null
@@ -0,0 +1,38 @@
+<table>
+  <tbody>
+    <tr>
+      <th>Id:</th>
+      <td><?php echo $general_category->getId() ?></td>
+    </tr>
+    <tr>
+      <th>Created at:</th>
+      <td><?php echo $general_category->getCreatedAt() ?></td>
+    </tr>
+    <tr>
+      <th>Updated at:</th>
+      <td><?php echo $general_category->getUpdatedAt() ?></td>
+    </tr>
+    <tr>
+      <th>Root:</th>
+      <td><?php echo $general_category->getRootId() ?></td>
+    </tr>
+    <tr>
+      <th>Lft:</th>
+      <td><?php echo $general_category->getLft() ?></td>
+    </tr>
+    <tr>
+      <th>Rgt:</th>
+      <td><?php echo $general_category->getRgt() ?></td>
+    </tr>
+    <tr>
+      <th>Level:</th>
+      <td><?php echo $general_category->getLevel() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('category/edit?id='.$general_category->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('category/index') ?>">List</a>
diff --git a/apps/userfront/modules/sfGuardAuth/config/view.yml b/apps/userfront/modules/sfGuardAuth/config/view.yml
new file mode 100644 (file)
index 0000000..4084c6e
--- /dev/null
@@ -0,0 +1,20 @@
+# You can find more information about this file on the symfony website:
+# http://www.symfony-project.org/reference/1_4/en/13-View
+
+default:
+  http_metas:
+    content-type: text/html
+
+  metas:
+    #title:        symfony project
+    #description:  symfony project
+    #keywords:     symfony, project
+    #language:     en
+    #robots:       index, follow
+
+  stylesheets:    [inadminpanel/style.css, inadminpanel/niceforms-default.css]
+
+  javascripts:    [jquery-1.6.2.min.js, inadminpanel/ddaccordion.js]
+
+  has_layout:     true
+  layout:         layoutsfGuardAuth
diff --git a/apps/userfront/modules/sfGuardAuth/templates/_signin_form.php b/apps/userfront/modules/sfGuardAuth/templates/_signin_form.php
new file mode 100644 (file)
index 0000000..924a8c7
--- /dev/null
@@ -0,0 +1,25 @@
+<?php use_helper('I18N') ?>
+
+<form action="<?php echo url_for('@sf_guard_signin') ?>" method="post" class="niceform">
+  <table>
+    <tbody>
+      <?php echo $form ?>
+    </tbody>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <input type="submit" value="<?php echo __('Log In', null, 'sf_guard') ?>" />
+          
+          <?php $routes = $sf_context->getRouting()->getRoutes() ?>
+          <?php if (isset($routes['sf_guard_forgot_password'])): ?>
+            <a href="<?php echo url_for('@sf_guard_forgot_password') ?>"><?php echo __('Forgot your password?', null, 'sf_guard') ?></a>
+          <?php endif; ?>
+
+          <?php if (isset($routes['sf_guard_register'])): ?>
+            &nbsp; <a href="<?php echo url_for('@sf_guard_register') ?>"><?php echo __('Want to register?', null, 'sf_guard') ?></a>
+          <?php endif; ?>
+        </td>
+      </tr>
+    </tfoot>
+  </table>
+</form>
diff --git a/apps/userfront/templates/layout.php b/apps/userfront/templates/layout.php
new file mode 100644 (file)
index 0000000..f62cac1
--- /dev/null
@@ -0,0 +1,123 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <?php include_http_metas() ?>
+    <?php include_metas() ?>
+    <?php //include_title() ?>
+       <title><?php echo __('Mobi - Mobile Ads') ?></title>
+    <link rel="shortcut icon" href="/favicon.ico" />
+    <?php include_stylesheets() ?>
+    <?php include_javascripts() ?>
+
+       <script type="text/javascript">
+       ddaccordion.init({
+       headerclass: "submenuheader", //Shared CSS class name of headers group
+       contentclass: "submenu", //Shared CSS class name of contents group
+       revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
+       mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
+       collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
+       defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
+       onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
+       animatedefault: false, //Should contents open by default be animated into view?
+       persiststate: true, //persist state of opened contents within browser session?
+       toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
+       togglehtml: ["suffix", "<img src='/images/inadminpanel/images/plus.gif' class='statusicon' />", "<img src='/images/inadminpanel/images/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
+       animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
+       oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
+               //do nothing
+       },
+       onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
+               //do nothing
+       }
+})
+  </script>
+  </head>
+  <body>
+  <div id="main_container">
+       <div class="header">
+       <div class="logo"><a href="#"><img src="" alt="" title="" border="0" /></a></div>
+        <div class="right_header"><?php echo __('Welcome')." ".$sf_user->getGuardUser()->getFirstName() ?> | <a href="<?php echo url_for('sf_guard_signout') ?>" class="logout"><?php echo __('Logout') ?></a></div>
+       </div>
+       <div class="main_content">
+               <div class="menu">
+        <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>
+            </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 class="left_content">
+               <div class="sidebar_search">
+            <form>
+            <input type="text" name="" class="search_input" value="search keyword" onclick="this.value=''" />
+            <input type="image" class="search_submit" src="/images/inadminpanel/images/search.png" />
+            </form>            
+            </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>
+                <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>
+                    </ul>
+                </div>
+                
+                <a class="menuitem_green" href="<?php echo url_for('company/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>
+       
+                <div class="right_content"> 
+
+                       <?php echo $sf_content ?>
+
+                </div>
+      </div>
+       <div class="clear"></div>
+       </div> <!--end of main content-->
+
+       <div class="footer">
+               <div class="left_footer">MOBILE ADS | Powered by <a href="http://uah.es">UAH</a></div>
+       <div class="right_footer"><a href="http://uah.es"><img src="" alt="" title="" border="0" /></a></div>
+    </div>
+</div>
+  </body>
+</html>
diff --git a/apps/userfront/templates/layoutsfGuardAuth.php b/apps/userfront/templates/layoutsfGuardAuth.php
new file mode 100644 (file)
index 0000000..e3d5827
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+  <head>
+    <?php include_http_metas() ?>
+    <?php include_metas() ?>
+    <link rel="shortcut icon" href="/favicon.ico" />
+    <title><?php echo __('Mobi - Mobile Ads') ?></title>
+    <title>Mobi - Mobile Ads</title>
+    <?php include_stylesheets() ?>
+  </head>
+  <body>
+  <div id="main_container">
+       <div class="header_login">
+       <div class="logo"><a href="#"><img src="" alt="" title="" border="0" /></a></div>
+    </div>
+    <div class="login_form">
+               <?php echo $sf_content ?>
+    </div>  
+       <div class="footer_login">
+        <div class="left_footer_login">MOBILE ADS | Powered by <a href="http://uah.es">UAH</a></div>
+        <div class="right_footer_login"><a href="http://uah.es"><img src="" alt="" title="" border="0" /></a></div>
+    </div>
+   </div>              
+   </body>
+</html>
index b5722a4..864b0ae 100644 (file)
@@ -16,4 +16,15 @@ class GeneralCategoryTable extends Doctrine_Table
     {
         return Doctrine_Core::getTable('GeneralCategory');
     }
-}
\ No newline at end of file
+
+
+   /**
+    * Returns general categories, ordered by lft field.
+    *
+    * @return Doctrine Query
+    */
+    public function getGeneralCategoriesByLftQuery()
+    {
+        return $this->createQuery('gc')->orderBy('gc.lft');
+    }
+}
diff --git a/test/functional/userfront/categoryActionsTest.php b/test/functional/userfront/categoryActionsTest.php
new file mode 100644 (file)
index 0000000..3372571
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+include(dirname(__FILE__).'/../../bootstrap/functional.php');
+
+$browser = new sfTestFunctional(new sfBrowser());
+
+$browser->
+  get('/category/index')->
+
+  with('request')->begin()->
+    isParameter('module', 'category')->
+    isParameter('action', 'index')->
+  end()->
+
+  with('response')->begin()->
+    isStatusCode(200)->
+    checkElement('body', '!/This is a temporary page/')->
+  end()
+;
diff --git a/web/userfront.php b/web/userfront.php
new file mode 100644 (file)
index 0000000..a653d46
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+
+
+require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
+
+$configuration = ProjectConfiguration::getApplicationConfiguration('userfront', 'prod', false);
+sfContext::createInstance($configuration)->dispatch();
diff --git a/web/userfront_dev.php b/web/userfront_dev.php
new file mode 100644 (file)
index 0000000..12c3339
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+
+// this check prevents access to debug front controllers that are deployed by accident to production servers.
+// feel free to remove this, extend it or make something more sophisticated.
+if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))
+{
+  die('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
+}
+
+require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php');
+
+$configuration = ProjectConfiguration::getApplicationConfiguration('userfront', 'dev', true);
+sfContext::createInstance($configuration)->dispatch();