Author: jablko
Date: Mon Oct 25 14:07:54 2010
New Revision: 8484

Log:
Use $route->resource

Modified:
   trunk/apps/qubit/modules/term/actions/deleteAction.class.php

Modified: trunk/apps/qubit/modules/term/actions/deleteAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/term/actions/deleteAction.class.php        Mon Oct 
25 14:06:15 2010        (r8483)
+++ trunk/apps/qubit/modules/term/actions/deleteAction.class.php        Mon Oct 
25 14:07:54 2010        (r8484)
@@ -23,34 +23,33 @@
   {
     $this->form = new sfForm;
 
-    $this->resource = QubitTerm::getById($request->id);
+    $this->resource = $this->getRoute()->resource;
 
-    if (!isset($this->resource))
+    // Check that this isn't the root
+    if (!isset($this->resource->parent))
     {
       $this->forward404();
     }
 
+    // Don't delete protected terms
+    if ($this->resource->isProtected())
+    {
+      $this->forward('admin', 'termPermission');
+    }
+
     // Check user authorization
     if (!QubitAcl::check($this->resource, 'delete'))
     {
       QubitAcl::forwardUnauthorized();
     }
 
-    $request->setAttribute('term', $this->resource);
-
     if ($request->isMethod('delete'))
     {
-      // Don't delete protected terms
-      if ($this->resource->isProtected())
-      {
-        $this->forward('admin', 'termPermission');
-      }
-
-      foreach ($this->resource->descendants->andSelf()->orderBy('rgt') as 
$descendant)
+      foreach ($this->resource->descendants->andSelf()->orderBy('rgt') as 
$item)
       {
-        if (QubitAcl::check($descendant, 'delete'))
+        if (QubitAcl::check($item, 'delete'))
         {
-          $descendant->delete();
+          $item->delete();
         }
       }
 

-- 
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