Author: jablko
Date: Fri Oct 2 16:11:53 2009
New Revision: 3652
Log:
Quard against actually deleting anything unless the request method is DELETE,
like revision 2956
Added:
trunk/apps/qubit/modules/physicalobject/templates/deleteSuccess.php
- copied, changed from r3651,
trunk/apps/qubit/modules/informationobject/templates/deleteSuccess.php
Modified:
trunk/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
trunk/apps/qubit/modules/physicalobject/config/view.yml
Modified: trunk/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
Fri Oct 2 15:24:09 2009 (r3651)
+++ trunk/apps/qubit/modules/physicalobject/actions/deleteAction.class.php
Fri Oct 2 16:11:53 2009 (r3652)
@@ -29,18 +29,25 @@
{
public function execute($request)
{
- $physicalObject =
QubitPhysicalObject::getById($this->getRequestParameter('id'));
- $this->forward404Unless($physicalObject);
+ $this->form = new sfForm;
- $this->forward404Unless($this->hasRequestParameter('next'));
+ $this->physicalObject = QubitPhysicalObject::getById($request->id);
- // Get related information objects (if any)
- $informationObjects =
QubitRelation::getRelatedObjectsBySubjectId('QubitInformationObject',
$physicalObject->getId(),
- array('typeId'=>QubitTerm::HAS_PHYSICAL_OBJECT_ID));
+ if (!isset($this->physicalObject))
+ {
+ $this->forward404();
+ }
- // Delete physical object record from the database
- $physicalObject->delete();
+ $criteria = new Criteria;
+ $criteria->add(QubitRelation::SUBJECT_ID, $this->physicalObject->id);
+ $criteria->addJoin(QubitRelation::OBJECT_ID, QubitInformationObject::ID);
+ $this->informationObjects = QubitInformationObject::get($criteria);
- $this->redirect($request->next);
+ if ($request->isMethod('delete'))
+ {
+ $this->physicalObject->delete();
+
+ $this->redirect($request->next);
+ }
}
}
Modified: trunk/apps/qubit/modules/physicalobject/config/view.yml
==============================================================================
--- trunk/apps/qubit/modules/physicalobject/config/view.yml Fri Oct 2
15:24:09 2009 (r3651)
+++ trunk/apps/qubit/modules/physicalobject/config/view.yml Fri Oct 2
16:11:53 2009 (r3652)
@@ -1,2 +1,8 @@
+deleteSuccess:
+ components:
+ BrowseBox: []
+ MainMenu: []
+ SearchBox: []
+
editSuccess:
javascripts: [/sfDrupalPlugin/vendor/drupal/misc/collapse]
Copied and modified:
trunk/apps/qubit/modules/physicalobject/templates/deleteSuccess.php (from
r3651, trunk/apps/qubit/modules/informationobject/templates/deleteSuccess.php)
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/deleteSuccess.php
Fri Oct 2 15:24:09 2009 (r3651, copy source)
+++ trunk/apps/qubit/modules/physicalobject/templates/deleteSuccess.php Fri Oct
2 16:11:53 2009 (r3652)
@@ -1,16 +1,16 @@
-<h1><?php echo __('Are you sure you want to delete %1%?', array('%1%' =>
render_title($informationObject))) ?></h1>
+<h1><?php echo __('Are you sure you want to delete %1%?', array('%1%' =>
render_title($physicalObject))) ?></h1>
-<?php if (0 < count($informationObject->descendants)): ?>
+<?php if (0 < count($informationObjects)): ?>
<ul>
- <?php foreach ($informationObject->descendants as $descendant): ?>
- <li><?php echo link_to(render_title($descendant), array('module' =>
'informationobject', 'action' => 'show', 'id' => $descendant->id)) ?></li>
+ <?php foreach ($informationObjects as $informationObject): ?>
+ <li><?php echo link_to(render_title($informationObject), array('module'
=> 'informationobject', 'action' => 'show', 'id' => $informationObject->id))
?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
-<?php echo $form->renderFormTag(url_for(array('module' => 'informationobject',
'action' => 'delete', 'id' => $informationObject->id)), array('method' =>
'delete')) ?>
+<?php echo $form->renderFormTag(url_for(array('module' => 'physicalobject',
'action' => 'delete', 'id' => $physicalObject->id)), array('method' =>
'delete')) ?>
<ul class="actions">
- <li><?php echo link_to(__('Cancel'), array('module' =>
'informationobject', 'action' => 'show', 'id' => $informationObject->id))
?></li>
+ <li><?php echo link_to(__('Cancel'), array('module' => 'physicalobject',
'action' => 'edit', 'id' => $physicalObject->id)) ?></li>
<li><?php echo submit_tag(__('Confirm')) ?></li>
</ul>
</form>
--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---