Skip to content

Commit

Permalink
Get confirmation before deleting right, refs #7650
Browse files Browse the repository at this point in the history
Get confirmation from the user before deleting a right.
  • Loading branch information
mcantelon committed Aug 12, 2018
1 parent 158e343 commit c7a15e3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 30 deletions.
1 change: 0 additions & 1 deletion apps/qubit/modules/digitalobject/config/view.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ editSuccess:
/plugins/sfDrupalPlugin/vendor/drupal/misc/collapse:
/plugins/sfDrupalPlugin/vendor/drupal/misc/form:
description:
deleteBasisRight.js:
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ public function execute($request)

$this->dispatcher->notify(new sfEvent($this, 'access_log.view', array('object' => $this->resource)));

// Specified here instead of view.yml so plugins calling
// calling inheriting and calling parent::execute also
// automatically load the file(s)
$this->getResponse()->addJavascript('deleteBasisRight.js', 'last');

if (sfConfig::get('app_treeview_type__source', 'sidebar') == 'fullWidth')
{
$this->getResponse()->addStylesheet('fullWidthTreeView', 'last');
Expand Down
13 changes: 9 additions & 4 deletions apps/qubit/modules/right/actions/deleteAction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ class RightDeleteAction extends sfAction
public function execute($request)
{
$this->right = $this->getRoute()->resource;
$relatedObject = $this->right->relationsRelatedByobjectId[0]->subject;
$this->relatedObject = $this->right->relationsRelatedByobjectId[0]->subject;

// Check user authorization against the related object
if (!QubitAcl::check($relatedObject, 'delete'))
if (!QubitAcl::check($this->relatedObject, 'delete'))
{
QubitAcl::forwardUnauthorized();
}

$this->right->delete();
if ($request->isMethod('delete'))
{
$this->right->delete();

return $this->redirect(array($this->relatedObject));
}

return $this->redirect(array($relatedObject));
$this->form = new sfForm;
}
}
2 changes: 1 addition & 1 deletion apps/qubit/modules/right/templates/_right.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h3><?php echo __('Related right') ?></h3>
<?php if (QubitAcl::check($relatedObject, 'update')): ?>
<a href="<?php echo url_for(array('module' => 'right', 'action' => 'edit', 'slug' => $resource->slug)) ?>">&nbsp;Edit</a> |
<a href="<?php echo url_for(array('module' => 'right', 'action' => 'delete', 'slug' => $resource->slug)) ?>" class="deleteRightBasis">Delete</a>
<a href="<?php echo url_for(array('module' => 'right', 'action' => 'delete', 'slug' => $resource->slug)) ?>">Delete</a>
<?php endif; ?>

<div>
Expand Down
20 changes: 20 additions & 0 deletions apps/qubit/modules/right/templates/deleteSuccess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php decorate_with('layout_1col.php') ?>

<?php slot('title') ?>
<h1><?php echo __('Are you sure you want to delete this right?') ?></h1>
<?php end_slot() ?>

<?php slot('content') ?>

<?php echo $form->renderFormTag(url_for(array($right, 'module' => 'right', 'action' => 'delete')), array('method' => 'delete')) ?>

<section class="actions">
<ul>
<li><?php echo link_to(__('Cancel'), $relatedObject, array('class' => 'c-btn')) ?></li>
<li><input class="c-btn c-btn-delete" type="submit" value="<?php echo __('Delete') ?>"/></li>
</ul>
</section>

</form>

<?php end_slot() ?>
19 changes: 0 additions & 19 deletions js/deleteBasisRight.js

This file was deleted.

0 comments on commit c7a15e3

Please sign in to comment.