Author: sevein
Date: Sat Oct 30 06:38:54 2010
New Revision: 8709

Log:
Use $resource, DefaultEditAction, cosmetic changes.

Modified:
   
trunk/apps/qubit/modules/user/actions/editInformationObjectAclAction.class.php
   trunk/apps/qubit/modules/user/templates/editInformationObjectAclSuccess.php

Modified: 
trunk/apps/qubit/modules/user/actions/editInformationObjectAclAction.class.php
==============================================================================
--- 
trunk/apps/qubit/modules/user/actions/editInformationObjectAclAction.class.php  
    Sat Oct 30 05:33:34 2010        (r8708)
+++ 
trunk/apps/qubit/modules/user/actions/editInformationObjectAclAction.class.php  
    Sat Oct 30 06:38:54 2010        (r8709)
@@ -17,11 +17,14 @@
  * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-class UserEditInformationObjectAclAction extends sfAction
+class UserEditInformationObjectAclAction extends DefaultEditAction
 {
-  public function execute($request)
+  public static
+    $NAMES = array();
+
+  protected function earlyExecute()
   {
-    $this->form = new sfForm;
+    $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
 
     $this->resource = new QubitUser;
     if (isset($this->getRoute()->resource))
@@ -29,8 +32,6 @@
       $this->resource = $this->getRoute()->resource;
     }
 
-    $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
-
     // Build separate list of permissions by repository and by object
     $this->repositories = array();
     $this->informationObjects = array();
@@ -54,9 +55,9 @@
       {
         foreach ($permissions as $item)
         {
-          if (null != ($repoId = $item->getConstants(array('name' => 
'repositoryId'))))
+          if (null != ($repositoryId = $item->getConstants(array('name' => 
'repositoryId'))))
           {
-            $this->repositories[$repoId][$item->action] = $item;
+            $this->repositories[$repositoryId][$item->action] = $item;
           }
           else if (null != $item->objectId && QubitInformationObject::ROOT_ID 
!= $item->objectId)
           {
@@ -79,18 +80,6 @@
     {
       $this->isAdministrator = true;
     }
-
-    if ($request->isMethod('post'))
-    {
-      $this->form->bind($request->getPostParameters());
-
-      if ($this->form->isValid())
-      {
-        $this->processForm();
-
-        $this->redirect(array($this->resource, 'module' => 'user', 'action' => 
'indexInformationObjectAcl'));
-      }
-    }
   }
 
   protected function processForm()
@@ -103,15 +92,7 @@
         $obj = null;
         list ($action, $uri) = array_slice($matches, 1, 2);
         $params = $this->context->routing->parse(Qubit::pathInfo($uri));
-        if (isset($params['id']))
-        {
-          $obj = QubitObject::getById($params['id']);
-        }
-
-        if (null === $obj)
-        {
-          continue;
-        }
+        $resource = $params['_sf_route']->resource;
 
         if (QubitAcl::INHERIT != $value && 
isset(QubitInformationObjectAcl::$ACTIONS[$action]))
         {
@@ -119,16 +100,16 @@
           $aclPermission->action = $action;
           $aclPermission->grantDeny = (QubitAcl::GRANT == $value) ? 1 : 0;
 
-          switch ($obj->className)
+          switch ($resource->className)
           {
             case 'QubitInformationObject':
-              $aclPermission->objectId = $obj->id;
+              $aclPermission->objectId = $resource->id;
 
               break;
 
             case 'QubitRepository':
               $aclPermission->objectId = QubitInformationObject::ROOT_ID;
-              
$aclPermission->setRepository(QubitRepository::getById($obj->id));
+              $aclPermission->setRepository($resource);
 
               break;
 
@@ -139,7 +120,7 @@
           $this->resource->aclPermissions[] = $aclPermission;
         }
       }
-
+      
       // Otherwise, update an existing permission
       else if (null !== $aclPermission = QubitAclPermission::getById($key))
       {
@@ -155,8 +136,24 @@
         }
       }
     }
+  }
+
+  public function execute($request)
+  {
+    parent::execute($request);
 
-    // Save changes
-    $this->resource->save();
+    if ($request->isMethod('post'))
+    {
+      $this->form->bind($request->getPostParameters());
+
+      if ($this->form->isValid())
+      {
+        $this->processForm();
+
+        $this->resource->save();
+
+        $this->redirect(array($this->resource, 'module' => 'user', 'action' => 
'indexInformationObjectAcl'));
+      }
+    }
   }
 }

Modified: 
trunk/apps/qubit/modules/user/templates/editInformationObjectAclSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/user/templates/editInformationObjectAclSuccess.php 
Sat Oct 30 05:33:34 2010        (r8708)
+++ trunk/apps/qubit/modules/user/templates/editInformationObjectAclSuccess.php 
Sat Oct 30 06:38:54 2010        (r8709)
@@ -45,14 +45,14 @@
       $tableTemplate .= '<tbody>';
 
       $row = 0;
-      foreach ($basicActions as $action => $label)
+      foreach ($basicActions as $key => $value)
       {
         $tableTemplate .= '<tr class="'.((0 == $row++ % 2) ? 'even' : 
'odd').'">';
-        $tableTemplate .= '<td>'.__($label).'</th>';
+        $tableTemplate .= '<td>'.__($value).'</th>';
         $tableTemplate .= '<td><ul class="radio inline">';
-        $tableTemplate .= '<li><input type="radio" 
name="acl['.$action.'_{objectId}]" 
value="'.QubitAcl::GRANT.'"/>'.__('Grant').'</li>';
-        $tableTemplate .= '<li><input type="radio" 
name="acl['.$action.'_{objectId}]" 
value="'.QubitAcl::DENY.'"/>'.__('Deny').'</li>';
-        $tableTemplate .= '<li><input type="radio" 
name="acl['.$action.'_{objectId}]" value="'.QubitAcl::INHERIT.'" 
checked/>'.__('Inherit').'</li>';
+        $tableTemplate .= '<li><input type="radio" 
name="acl['.$key.'_{objectId}]" 
value="'.QubitAcl::GRANT.'"/>'.__('Grant').'</li>';
+        $tableTemplate .= '<li><input type="radio" 
name="acl['.$key.'_{objectId}]" 
value="'.QubitAcl::DENY.'"/>'.__('Deny').'</li>';
+        $tableTemplate .= '<li><input type="radio" 
name="acl['.$key.'_{objectId}]" value="'.QubitAcl::INHERIT.'" 
checked/>'.__('Inherit').'</li>';
         $tableTemplate .= '</ul></td>';
         $tableTemplate .= "</tr>";
         $tableTemplate .= "</div>";

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to