Author: sevein
Date: Wed Oct 27 01:30:29 2010
New Revision: 8531

Log:
Use $resource. Fixes issue 1833.

Modified:
   trunk/apps/qubit/modules/default/actions/moveAction.class.php
   trunk/apps/qubit/modules/default/templates/moveSuccess.php

Modified: trunk/apps/qubit/modules/default/actions/moveAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/default/actions/moveAction.class.php       Wed Oct 
27 00:02:20 2010        (r8530)
+++ trunk/apps/qubit/modules/default/actions/moveAction.class.php       Wed Oct 
27 01:30:29 2010        (r8531)
@@ -29,16 +29,16 @@
 
     $this->form = new sfForm;
 
-    $this->object = QubitObject::getById($request->id);
+    $this->resource = $this->getRoute()->resource;
 
-    // Check that object exists and that it is not the root
-    if (!isset($this->object) || !isset($this->object->parent))
+    // Check that the object exists and that it is not the root
+    if (!isset($this->resource) || !isset($this->resource->parent))
     {
       $this->forward404();
     }
 
     // Check authorization
-    if (!QubitAcl::check($this->object, 'update'))
+    if (!QubitAcl::check($this->resource, 'update'))
     {
       QubitAcl::forwardUnauthorized();
     }
@@ -48,11 +48,11 @@
     $this->form->setWidget('parent', new sfWidgetFormInputHidden);
 
     // Root is default parent
-    if ($this->object instanceof QubitInformationObject)
+    if ($this->resource instanceof QubitInformationObject)
     {
       $this->form->bind($request->getGetParameters() + array('parent' => 
$this->context->routing->generate(null, 
array(QubitInformationObject::getById(QubitInformationObject::ROOT_ID), 
'module' => 'informationobject'))));
     }
-    else if ($this->object instanceof QubitTerm)
+    else if ($this->resource instanceof QubitTerm)
     {
       $this->form->bind($request->getGetParameters() + array('parent' => 
$this->context->routing->generate(null, 
array(QubitTerm::getById(QubitTerm::ROOT_ID), 'module' => 'term'))));
     }
@@ -66,16 +66,16 @@
         $params = 
$this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue()));
 
         // In term treeview, root node links (href) to taxonomy, but it 
represents the term root object
-        if ($this->object instanceOf QubitTerm && 
QubitObject::getById($params['id']) instanceof QubitTaxonomy)
+        if ($this->resource instanceOf QubitTerm && 
QubitObject::getById($params['_sf_route']->resource->id) instanceof 
QubitTaxonomy)
         {
-          $this->object->parentId = QubitTerm::ROOT_ID;
+          $this->resource->parentId = QubitTerm::ROOT_ID;
         }
         else
         {
-          $this->object->parentId = $params['id'];
+          $this->resource->parentId = $params['_sf_route']->resource->id;
         }
 
-        $this->object->save();
+        $this->resource->save();
 
         if ($request->isXmlHttpRequest())
         {
@@ -83,20 +83,20 @@
         }
         else
         {
-          if ($this->object instanceof QubitInformationObject)
+          if ($this->resource instanceof QubitInformationObject)
           {
-            $this->redirect(array($this->object, 'module' => 
'informationobject'));
+            $this->redirect(array($this->resource, 'module' => 
'informationobject'));
           }
-          else if ($this->object instanceof QubitTerm)
+          else if ($this->resource instanceof QubitTerm)
           {
-            $this->redirect(array($this->object, 'module' => 'term'));
+            $this->redirect(array($this->resource, 'module' => 'term'));
           }
         }
       }
     }
 
     $params = 
$this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue()));
-    $this->parent = QubitObject::getById($params['id']);
+    $this->parent = QubitObject::getById($params['_sf_route']->resource->id);
 
     $search = new QubitSearch;
     $query = new Zend_Search_Lucene_Search_Query_Term(new 
Zend_Search_Lucene_Index_Term($this->parent->id, 'parentId'));

Modified: trunk/apps/qubit/modules/default/templates/moveSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/default/templates/moveSuccess.php  Wed Oct 27 
00:02:20 2010        (r8530)
+++ trunk/apps/qubit/modules/default/templates/moveSuccess.php  Wed Oct 27 
01:30:29 2010        (r8531)
@@ -1,7 +1,7 @@
-<h1><?php echo __('Move %1%', array('%1%' => render_title($object))) ?></h1>
+<h1><?php echo __('Move %1%', array('%1%' => render_title($resource))) ?></h1>
 
 <div class="search">
-  <form action="<?php echo url_for(array($object, 'action' => 'move')) ?>">
+  <form action="<?php echo url_for(array($resource, 'action' => 'move')) ?>">
     <input name="query" value="<?php echo $sf_request->query ?>"/>
     <input class="form-submit" type="submit" value="<?php echo __('Search') 
?>"/>
   </form>
@@ -16,7 +16,7 @@
 
       <?php foreach ($parent->ancestors as $item): ?>
         <?php if (isset($item->parent)): ?>
-          <li><?php echo link_to(render_title($item), array($object, 'action' 
=> 'move', 'parent' => url_for(array($item, 'module' => 'informationobject')))) 
?></li>
+          <li><?php echo link_to(render_title($item), array($resource, 
'action' => 'move', 'parent' => url_for(array($item, 'module' => 
'informationobject')))) ?></li>
         <?php endif; ?>
       <?php endforeach; ?>
 
@@ -40,7 +40,7 @@
     <?php foreach ($results as $item): ?>
       <tr class="<?php echo 0 == ++$row % 2 ? 'even' : 'odd' ?>">
         <td>
-          <?php echo link_to_if($object->lft > $item->lft || $object->rgt < 
$item->rgt, render_title($item), array($object, 'action' => 'move', 'parent' => 
url_for(array($item, 'module' => 'informationobject')))) ?>
+          <?php echo link_to_if($resource->lft > $item->lft || $resource->rgt 
< $item->rgt, render_title($item), array($resource, 'action' => 'move', 
'parent' => url_for(array($item, 'module' => 'informationobject')))) ?>
         </td>
       </tr>
     <?php endforeach; ?>
@@ -49,7 +49,7 @@
 
 <?php echo get_partial('default/pager', array('pager' => $pager)) ?>
 
-<?php echo $form->renderFormTag(url_for(array($object, 'action' => 'move'))) ?>
+<?php echo $form->renderFormTag(url_for(array($resource, 'action' => 'move'))) 
?>
 
   <?php echo $form->renderHiddenFields() ?>
 
@@ -60,7 +60,7 @@
     <div class="content">
       <ul class="clearfix links">
         <li><input class="form-submit" type="submit" value="<?php echo 
__('Move here') ?>"/></li>
-        <li><?php echo link_to(__('Cancel'), array($object, 'module' => 
'informationobject')) ?></li>
+        <li><?php echo link_to(__('Cancel'), array($resource, 'module' => 
'informationobject')) ?></li>
       </ul>
     </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