Skip to content

Commit

Permalink
codingstandard with phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
amma35 committed Aug 7, 2018
1 parent c80e456 commit 432be64
Show file tree
Hide file tree
Showing 22 changed files with 807 additions and 806 deletions.
4 changes: 2 additions & 2 deletions ajax/loadscripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
$urgency_ids = $config->getUrgency_ids();
$use_duration_solution = $config->useDurationSolution();

$params = array('root_doc' => $CFG_GLPI['root_doc'],
$params = ['root_doc' => $CFG_GLPI['root_doc'],
'waiting' => CommonITILObject::WAITING,
'closed' => CommonITILObject::CLOSED,
'use_waiting' => $use_waiting,
Expand All @@ -56,7 +56,7 @@
'glpilayout' => $_SESSION['glpilayout'],
'use_urgency' => $use_urgency,
'urgency_ids' => $urgency_ids,
'div_kb' => Session::haveRight('knowbase', UPDATE));
'div_kb' => Session::haveRight('knowbase', UPDATE)];

echo "<script type='text/javascript'>";
echo "var moreticket = $(document).moreticket(" . json_encode($params) . ");";
Expand Down
2 changes: 1 addition & 1 deletion ajax/ticket.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@
}
break;
}
}
}
6 changes: 3 additions & 3 deletions front/closeticket.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
$doc->check(-1, CREATE, $_POST);
$DocId = $doc->add($_POST);

$test = $closeTicket->add(array('requesters_id' => $_POST['requesters_id'],
$test = $closeTicket->add(['requesters_id' => $_POST['requesters_id'],
'tickets_id' => $_POST['tickets_id'],
'date' => $_POST['date'],
'comment' => $_POST['comment'],
'documents_id' => $DocId));
'documents_id' => $DocId]);
Html::back();
}
}
4 changes: 2 additions & 2 deletions front/config.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
if (isset($_POST['urgency_ids'])) {
$_POST['urgency_ids'] = $dbu->exportArrayToDB($_POST['urgency_ids']);
} else {
$_POST['urgency_ids'] = $dbu->exportArrayToDB(array());
$_POST['urgency_ids'] = $dbu->exportArrayToDB([]);
}

$config->update($_POST);
Expand All @@ -65,4 +65,4 @@
echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt='warning'><br><br>";
echo "<b>" . __('Please activate the plugin', 'moreticket') . "</b></div>";
Html::footer();
}
}
2 changes: 1 addition & 1 deletion front/waitingtype.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
include('../../../inc/includes.php');

$dropdown = new PluginMoreticketWaitingType();
include(GLPI_ROOT . "/front/dropdown.common.form.php");
include(GLPI_ROOT . "/front/dropdown.common.form.php");
2 changes: 1 addition & 1 deletion front/waitingtype.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
include('../../../inc/includes.php');

$dropdown = new PluginMoreticketWaitingType();
include(GLPI_ROOT . "/front/dropdown.common.php");
include(GLPI_ROOT . "/front/dropdown.common.php");
75 changes: 39 additions & 36 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
-------------------------------------------------------------------------
LICENSE
This file is part of moreticket.
moreticket is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -85,7 +85,7 @@ function plugin_moreticket_install() {
$DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.3.4.sql");
}

CronTask::Register('PluginMoreticketWaitingTicket', 'MoreticketWaitingTicket', DAY_TIMESTAMP, array('state' => 0));
CronTask::Register('PluginMoreticketWaitingTicket', 'MoreticketWaitingTicket', DAY_TIMESTAMP, ['state' => 0]);

PluginMoreticketProfile::initProfile();
PluginMoreticketProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
Expand All @@ -104,19 +104,20 @@ function plugin_moreticket_uninstall() {
include_once(GLPI_ROOT . "/plugins/moreticket/inc/profile.class.php");

// Plugin tables deletion
$tables = array("glpi_plugin_moreticket_configs",
$tables = ["glpi_plugin_moreticket_configs",
"glpi_plugin_moreticket_waitingtickets",
"glpi_plugin_moreticket_waitingtypes",
"glpi_plugin_moreticket_closetickets",
"glpi_plugin_moreticket_urgencytickets");
"glpi_plugin_moreticket_urgencytickets"];

foreach ($tables as $table)
foreach ($tables as $table) {
$DB->query("DROP TABLE IF EXISTS `$table`;");
}

//Delete rights associated with the plugin
$profileRight = new ProfileRight();
foreach (PluginMoreticketProfile::getAllRights() as $right) {
$profileRight->deleteByCriteria(array('name' => $right['field']));
$profileRight->deleteByCriteria(['name' => $right['field']]);
}

CronTask::Unregister('moreticket');
Expand All @@ -127,8 +128,8 @@ function plugin_moreticket_uninstall() {
function plugin_moreticket_postinit() {
global $PLUGIN_HOOKS;

$PLUGIN_HOOKS['item_purge']['moreticket'] = array();
$PLUGIN_HOOKS['item_add']['moreticket'] = array();
$PLUGIN_HOOKS['item_purge']['moreticket'] = [];
$PLUGIN_HOOKS['item_add']['moreticket'] = [];
}

// Define dropdown relations
Expand All @@ -138,12 +139,13 @@ function plugin_moreticket_postinit() {
function plugin_moreticket_getDatabaseRelations() {

$plugin = new Plugin();
if ($plugin->isActivated("moreticket"))
return array("glpi_tickets" => array("glpi_plugin_moreticket_waitingtickets" => "tickets_id"),
"glpi_plugin_moreticket_waitingtypes" => array("glpi_plugin_moreticket_waitingtickets" => "plugin_moreticket_waitingtypes_id"),
"glpi_tickets" => array("glpi_plugin_moreticket_closetickets" => "tickets_id"));
else
return array();
if ($plugin->isActivated("moreticket")) {
return ["glpi_tickets" => ["glpi_plugin_moreticket_waitingtickets" => "tickets_id"],
"glpi_plugin_moreticket_waitingtypes" => ["glpi_plugin_moreticket_waitingtickets" => "plugin_moreticket_waitingtypes_id"],
"glpi_tickets" => ["glpi_plugin_moreticket_closetickets" => "tickets_id"]];
} else {
return [];
}
}

// Define Dropdown tables to be manage in GLPI :
Expand All @@ -154,10 +156,11 @@ function plugin_moreticket_getDropdown() {

$plugin = new Plugin();

if ($plugin->isActivated("moreticket"))
return array('PluginMoreticketWaitingType' => PluginMoreticketWaitingType::getTypeName(2));
else
return array();
if ($plugin->isActivated("moreticket")) {
return ['PluginMoreticketWaitingType' => PluginMoreticketWaitingType::getTypeName(2)];
} else {
return [];
}
}

// Hook done on purge item case
Expand All @@ -169,7 +172,7 @@ function plugin_pre_item_purge_moreticket($item) {
switch (get_class($item)) {
case 'Ticket' :
$temp = new PluginMoreticketWaitingTicket();
$temp->deleteByCriteria(array('tickets_id' => $item->getField('id')));
$temp->deleteByCriteria(['tickets_id' => $item->getField('id')]);
break;
}
}
Expand All @@ -185,7 +188,7 @@ function plugin_pre_item_purge_moreticket($item) {
*/
function plugin_moreticket_getAddSearchOptions($itemtype) {

$sopt = array();
$sopt = [];

if ($itemtype == "Ticket") {
if (Session::haveRight("plugin_moreticket", READ)) {
Expand All @@ -196,49 +199,49 @@ function plugin_moreticket_getAddSearchOptions($itemtype) {
$sopt[3450]['field'] = 'reason';
$sopt[3450]['name'] = __('Reason', 'moreticket');
$sopt[3450]['datatype'] = "text";
$sopt[3450]['joinparams'] = array('jointype' => 'child',
'condition' => "AND `NEWTABLE`.`date_end_suspension` IS NULL");
$sopt[3450]['joinparams'] = ['jointype' => 'child',
'condition' => "AND `NEWTABLE`.`date_end_suspension` IS NULL"];
$sopt[3450]['massiveaction'] = false;

$sopt[3451]['table'] = 'glpi_plugin_moreticket_waitingtickets';
$sopt[3451]['field'] = 'date_report';
$sopt[3451]['name'] = __('Postponement date', 'moreticket');
$sopt[3451]['datatype'] = "datetime";
$sopt[3451]['joinparams'] = array('jointype' => 'child',
'condition' => "AND `NEWTABLE`.`date_end_suspension` IS NULL");
$sopt[3451]['joinparams'] = ['jointype' => 'child',
'condition' => "AND `NEWTABLE`.`date_end_suspension` IS NULL"];
$sopt[3451]['massiveaction'] = false;

$sopt[3452]['table'] = 'glpi_plugin_moreticket_waitingtypes';
$sopt[3452]['field'] = 'name';
$sopt[3452]['name'] = PluginMoreticketWaitingType::getTypeName(1);
$sopt[3452]['datatype'] = "dropdown";
$condition = "AND (`NEWTABLE`.`date_end_suspension` IS NULL)";
$sopt[3452]['joinparams'] = array('beforejoin'
=> array('table' => 'glpi_plugin_moreticket_waitingtickets',
'joinparams' => array('jointype' => 'child',
'condition' => $condition)));
$sopt[3452]['joinparams'] = ['beforejoin'
=> ['table' => 'glpi_plugin_moreticket_waitingtickets',
'joinparams' => ['jointype' => 'child',
'condition' => $condition]]];
$sopt[3452]['massiveaction'] = false;

if ($config->closeInformations()) {
$sopt[3453]['table'] = 'glpi_plugin_moreticket_closetickets';
$sopt[3453]['field'] = 'date';
$sopt[3453]['name'] = __('Close ticket informations', 'moreticket') . " : " . __('Date');
$sopt[3453]['datatype'] = "datetime";
$sopt[3453]['joinparams'] = array('jointype' => 'child');
$sopt[3453]['joinparams'] = ['jointype' => 'child'];
$sopt[3453]['massiveaction'] = false;

$sopt[3454]['table'] = 'glpi_plugin_moreticket_closetickets';
$sopt[3454]['field'] = 'comment';
$sopt[3454]['name'] = __('Close ticket informations', 'moreticket') . " : " . __('Comments');
$sopt[3454]['datatype'] = "text";
$sopt[3454]['joinparams'] = array('jointype' => 'child');
$sopt[3454]['joinparams'] = ['jointype' => 'child'];
$sopt[3454]['massiveaction'] = false;

$sopt[3455]['table'] = 'glpi_plugin_moreticket_closetickets';
$sopt[3455]['field'] = 'requesters_id';
$sopt[3455]['name'] = __('Close ticket informations', 'moreticket') . " : " . __('Writer');
$sopt[3455]['datatype'] = "dropdown";
$sopt[3455]['joinparams'] = array('jointype' => 'child');
$sopt[3455]['joinparams'] = ['jointype' => 'child'];
$sopt[3455]['massiveaction'] = false;

$sopt[3486]['table'] = 'glpi_documents';
Expand All @@ -248,11 +251,11 @@ function plugin_moreticket_getAddSearchOptions($itemtype) {
$sopt[3486]['usehaving'] = true;
$sopt[3486]['datatype'] = 'dropdown';
$sopt[3486]['massiveaction'] = false;
$sopt[3486]['joinparams'] = array('beforejoin' => array('table' => 'glpi_documents_items',
'joinparams' => array('jointype' => 'itemtype_item',
$sopt[3486]['joinparams'] = ['beforejoin' => ['table' => 'glpi_documents_items',
'joinparams' => ['jointype' => 'itemtype_item',
'specific_itemtype' => 'PluginMoreticketCloseTicket',
'beforejoin' => array('table' => 'glpi_plugin_moreticket_closetickets',
'joinparams' => array()))));
'beforejoin' => ['table' => 'glpi_plugin_moreticket_closetickets',
'joinparams' => []]]]];
}
}
}
Expand Down Expand Up @@ -318,4 +321,4 @@ function plugin_moreticket_addWhere($link, $nott, $type, $ID, $val, $searchtype)
}

return "";
}
}
Loading

0 comments on commit 432be64

Please sign in to comment.