Skip to content

Commit

Permalink
refactor: plugin activation check
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Feb 15, 2021
1 parent 84b463a commit 2aa2c29
Show file tree
Hide file tree
Showing 21 changed files with 50 additions and 67 deletions.
6 changes: 5 additions & 1 deletion front/entityconfig.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@

Session::checkRight("entity", UPDATE);

// Check if plugin is activated...
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

if (isset($_POST['update'])) {
$entityConfig = new PluginFormcreatorEntityconfig();
$entityConfig->update($_POST);
}

Html::back();
3 changes: 1 addition & 2 deletions front/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
include ('../../../inc/includes.php');

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/form.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
include ("../../../inc/includes.php");

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated("formcreator")) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
Session::checkRight("entity", UPDATE);

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/form_profile.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
Session::checkRight('entity', UPDATE);

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/formanswer.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
Session::redirectIfNotLoggedIn();

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated("formcreator")) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/formanswer.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
require_once ('../../../inc/includes.php');

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
4 changes: 2 additions & 2 deletions front/formlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

Session::checkLoginUser();

$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
// Check if plugin is activated...
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/issue.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
require_once ('../../../inc/includes.php');

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
require_once ('../../../inc/includes.php');

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
20 changes: 10 additions & 10 deletions front/item_targetticket.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@

Session::checkRight('entity', UPDATE);

$plugin = new Plugin();
if ($plugin->isActivated('formcreator')) {
if (isset($_POST['purge'])) {
$item_targetTicket = new PluginFormcreatorItem_TargetTicket();
$item_targetTicket->delete($_POST, 1);
Html::back();
}
Html::displayErrorAndDie("lost");
} else {
// Or display a "Not found" error
// Check if plugin is activated...
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

if (isset($_POST['purge'])) {
$item_targetTicket = new PluginFormcreatorItem_TargetTicket();
$item_targetTicket->delete($_POST, 1);
Html::back();
}
Html::displayErrorAndDie("lost");

3 changes: 1 addition & 2 deletions front/knowbaseitem.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
include ("../../../inc/includes.php");

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/question.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
Session::checkRight('entity', UPDATE);

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/reservation.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
Session::checkRight("reservation", ReservationItem::RESERVEANITEM);

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/reservation.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
Session::checkLoginUser();

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/reservationitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
Session::checkRightsOr('reservation', [READ, ReservationItem::RESERVEANITEM]);

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
36 changes: 16 additions & 20 deletions front/section.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,24 @@
Session::checkRight('entity', UPDATE);

// Check if plugin is activated...
$plugin = new Plugin();
if ($plugin->isActivated('formcreator')) {
$section = new PluginFormcreatorSection();

if (isset($_POST['add'])) {
// Add a new Section
Session::checkRight('entity', UPDATE);
$section->add($_POST);
Html::back();
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}
$section = new PluginFormcreatorSection();

} else if (isset($_POST['update'])) {
// Edit an existing section
Session::checkRight('entity', UPDATE);
$section->update($_POST);
Html::back();
if (isset($_POST['add'])) {
// Add a new Section
Session::checkRight('entity', UPDATE);
$section->add($_POST);
Html::back();

} else {
// Return to form list
Html::redirect(FORMCREATOR_ROOTDOC . '/front/form.php');
}
} else if (isset($_POST['update'])) {
// Edit an existing section
Session::checkRight('entity', UPDATE);
$section->update($_POST);
Html::back();

// Or display a "Not found" error
} else {
Html::displayNotFoundError();
// Return to form list
Html::redirect(FORMCREATOR_ROOTDOC . '/front/form.php');
}
3 changes: 1 addition & 2 deletions front/targetchange.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
Session::checkRight("entity", UPDATE);

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}
$targetchange = new PluginFormcreatorTargetChange();
Expand Down
3 changes: 1 addition & 2 deletions front/targetticket.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
Session::checkRight('entity', UPDATE);

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}
$targetticket = new PluginFormcreatorTargetTicket();
Expand Down
3 changes: 1 addition & 2 deletions front/wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
include ('../../../inc/includes.php');

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down
3 changes: 1 addition & 2 deletions front/wizardfeeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
include ("../../../inc/includes.php");

// Check if plugin is activated...
$plugin = new Plugin();
if (!$plugin->isActivated('formcreator')) {
if (!(new Plugin())->isActivated('formcreator')) {
Html::displayNotFoundError();
}

Expand Down

0 comments on commit 2aa2c29

Please sign in to comment.