Skip to content

Commit a5403a9

Browse files
committed
NameSpace Migration
Twig for config & profile
1 parent 07a922a commit a5403a9

14 files changed

Lines changed: 348 additions & 225 deletions

ajax/getEntitiesRights.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
* --------------------------------------------------------------------------
3030
*/
3131

32+
use GlpiPlugin\Transferticketentity\Entity;
33+
3234
include("../../../inc/includes.php");
3335

3436
header("Content-Type: text/html; charset=UTF-8");
3537
Html::header_nocache();
3638

3739
Session::checkLoginUser();
3840

39-
$getEntitiesRights = PluginTransferticketentityEntity::getEntitiesRights();
41+
$getEntitiesRights = Entity::getEntitiesRights();
4042

4143
echo json_encode($getEntitiesRights);

ajax/showentitygroups.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
* -------------------------------------------------------------------------
3232
*/
3333

34+
use GlpiPlugin\Transferticketentity\Ticket;
35+
3436
if (strpos($_SERVER['PHP_SELF'], "showentitygroups.php")) {
3537
include('../../../inc/includes.php');
3638
header("Content-Type: text/html; charset=UTF-8");
@@ -42,7 +44,7 @@
4244
if (isset($_POST['entity_selection'])) {
4345
$entitites_id = $_POST['entity_selection'];
4446

45-
$getGroupEntities = PluginTransferticketentityTicket::getGroupEntities($entitites_id);
47+
$getGroupEntities = Ticket::getGroupEntities($entitites_id);
4648

4749
$groups[0] = Dropdown::EMPTY_VALUE;
4850
foreach ($getGroupEntities as $key => $group) {

ajax/showentitymandatorygroup.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
* -------------------------------------------------------------------------
3232
*/
3333

34+
use GlpiPlugin\Transferticketentity\Entity;
35+
3436
if (strpos($_SERVER['PHP_SELF'], "showentitymandatorygroup.php")) {
3537
include('../../../inc/includes.php');
3638
header("Content-Type: text/html; charset=UTF-8");
@@ -43,7 +45,7 @@
4345
$entitites_id = $_POST['entity_selection'];
4446

4547
$params['entity_choice'] = $entitites_id;
46-
$getEntitiesRights = PluginTransferticketentityEntity::checkEntityRight($params);
48+
$getEntitiesRights = Entity::checkEntityRight($params);
4749

4850
if ($getEntitiesRights['allow_entity_only_transfer'] == 1) {
4951
echo "<span class='text-danger'>";

ajax/showentitymandatoryjustification.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
* -------------------------------------------------------------------------
3232
*/
3333

34+
use GlpiPlugin\Transferticketentity\Entity;
35+
3436
if (strpos($_SERVER['PHP_SELF'], "showentitymandatoryjustification.php")) {
3537
include('../../../inc/includes.php');
3638
header("Content-Type: text/html; charset=UTF-8");
@@ -43,7 +45,7 @@
4345
$entitites_id = $_POST['entity_selection'];
4446

4547
$params['entity_choice'] = $entitites_id;
46-
$getEntitiesRights = PluginTransferticketentityEntity::checkEntityRight($params);
48+
$getEntitiesRights = Entity::checkEntityRight($params);
4749

4850
if ($getEntitiesRights['justification_transfer'] == 1) {
4951
echo "<span class='text-danger'>";

front/entity.form.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131

3232
include('../../../inc/includes.php');
3333

34+
use GlpiPlugin\Transferticketentity\Entity;
35+
use GlpiPlugin\Transferticketentity\Ticket;
36+
37+
3438
Session::checkRight("entity", UPDATE);
3539

36-
$config = new PluginTransferticketentityEntity();
40+
$config = new Entity();
3741

3842
if (isset($_POST["update"])) {
3943
$config_data = $config::getInstance($_POST['entities_id']);
@@ -44,14 +48,12 @@
4448
if ($_POST['allow_transfer'] == 0) {
4549
$config->delete(['id' => $_POST['id']]);
4650
} else {
47-
4851
$params['entity_choice'] = $_POST['entities_id'];
49-
$checkMandatoryCategory = PluginTransferticketentityTicket::checkMandatoryCategory($params);
52+
$checkMandatoryCategory = Ticket::checkMandatoryCategory($params);
5053

5154
if ($checkMandatoryCategory
5255
&& $_POST['keep_category'] == 0
5356
&& $_POST['itilcategories_id'] == 0) {
54-
5557
Session::addMessageAfterRedirect(
5658
__(
5759
"The category is mandatory in the ticket template assigned to the entity",

front/ticket.form.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,27 @@
2929
* --------------------------------------------------------------------------
3030
*/
3131

32+
3233
include('../../../inc/includes.php');
3334

34-
$ticket = new PluginTransferticketentityTicket();
35+
use GlpiPlugin\Transferticketentity\Ticket;
36+
37+
Session::checkRight("plugin_transferticketentity_use", READ);
38+
39+
$ticket = new Ticket();
3540

3641
if (isset($_POST['transfertticket'])) {
37-
if (isset($_POST['entity_choice']) && $_POST['entity_choice'] > 0) {
42+
if (isset($_POST['entity_choice'])
43+
&& $_POST['entity_choice'] > 0) {
3844
$ticket->launchTicketTransfer($_POST);
3945
} else {
4046
Session::addMessageAfterRedirect(
4147
__("Please select a valid entity", 'transferticketentity'),
4248
true,
4349
ERROR
4450
);
51+
Html::back();
4552
}
4653
}
54+
4755
Html::back();

hook.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
--------------------------------------------------------------------------
3030
*/
3131

32+
use GlpiPlugin\Transferticketentity\Profile;
33+
3234
/**
3335
* Install hook
3436
*
@@ -38,7 +40,7 @@ function plugin_transferticketentity_install()
3840
{
3941
global $DB;
4042

41-
PluginTransferticketentityProfile::createFirstAccess($_SESSION["glpiactiveprofile"]["id"]);
43+
Profile::createFirstAccess($_SESSION["glpiactiveprofile"]["id"]);
4244

4345
$default_charset = DBConnection::getDefaultCharset();
4446
$default_collation = DBConnection::getDefaultCollation();
@@ -81,7 +83,7 @@ function plugin_transferticketentity_uninstall()
8183

8284
//Delete rights associated with the plugin
8385
$profileRight = new ProfileRight();
84-
foreach (PluginTransferticketentityProfile::getAllRights() as $right) {
86+
foreach (Profile::getAllRights() as $right) {
8587
$profileRight->deleteByCriteria(['name' => $right['field']]);
8688
}
8789
return true;

js/entitySettings.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

setup.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
--------------------------------------------------------------------------
3030
*/
3131

32+
use GlpiPlugin\Transferticketentity\Entity;
33+
use GlpiPlugin\Transferticketentity\Profile;
34+
use GlpiPlugin\Transferticketentity\Ticket;
35+
36+
3237
define('TRANSFERTICKETENTITY_VERSION', '1.1.4');
3338

3439
if (!defined("PLUGIN_TRANSFERTICKETENTITY_DIR")) {
@@ -40,12 +45,12 @@ function plugin_init_transferticketentity()
4045
global $PLUGIN_HOOKS;
4146

4247
// Add a tab for profiles and tickets
43-
Plugin::registerClass('PluginTransferticketentityTicket', ['addtabon' => 'Ticket']);
44-
Plugin::registerClass('PluginTransferticketentityEntity', ['addtabon' => 'Entity']);
48+
Plugin::registerClass(Ticket::class, ['addtabon' => 'Ticket']);
49+
Plugin::registerClass(Entity::class, ['addtabon' => 'Entity']);
4550

46-
$PLUGIN_HOOKS['change_profile']['transferticketentity'] = ['PluginTransferticketentityProfile', 'initProfile'];
51+
$PLUGIN_HOOKS['change_profile']['transferticketentity'] = [Profile::class, 'initProfile'];
4752

48-
Plugin::registerClass('PluginTransferticketentityProfile', ['addtabon' => ['Profile']]);
53+
Plugin::registerClass(Profile::class, ['addtabon' => ['Profile']]);
4954

5055
$PLUGIN_HOOKS['add_css']['transferticketentity'][] = "css/style.css";
5156

0 commit comments

Comments
 (0)