Skip to content

Commit

Permalink
fix(form): forbid purge of a form when there are answers
Browse files Browse the repository at this point in the history
Signed-off-by: btry <tbugier@teclib.com>
  • Loading branch information
btry committed Jul 10, 2018
1 parent 576c891 commit f84b353
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function canCreate() {
* @return boolean True if he can read requests
*/
public static function canView() {
return Session::haveRight("entity", UPDATE);
return Session::haveRight('entity', UPDATE);
}

/**
Expand All @@ -69,7 +69,19 @@ public static function canView() {
* @return boolean True if he can read requests
*/
public static function canDelete() {
return Session::haveRight("entity", UPDATE);
return Session::haveRight('entity', UPDATE);
}

public function canPurgeItem() {
$DbUtil = new DbUtils();

$criteria = [
PluginFormcreatorForm::getForeignKeyField() => $this->getID(),
];
if ($DbUtil->countElementsInTable(PluginFormcreatorForm_Answer::getTable(), $criteria) > 0) {
return false;
}
return Session::haveRight('entity', UPDATE);
}

/**
Expand Down

0 comments on commit f84b353

Please sign in to comment.