Skip to content

Commit 9f75ccf

Browse files
committed
Merge tag '2.5.0' into develop
2.5.0
2 parents 1bf08e3 + 8a5251d commit 9f75ccf

30 files changed

+1311
-1013
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"minimum-stability": "dev",
33
"prefer-stable": true,
44
"require-dev": {
5-
"glpi-project/tools": "^0.1.0"
65
},
76
"require": {
8-
"zendframework/zend-loader": "^2.5"
7+
"zendframework/zend-loader": "^2.5",
8+
"glpi-project/tools": "^0.1.2"
99
}
1010
}

composer.lock

Lines changed: 376 additions & 297 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front/object.form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
$types = array_keys(PluginGenericobjectType::getTypes());
3737

3838
$requested_type = $_REQUEST['itemtype'];
39-
$error = array();
39+
$error = [];
4040

4141
if (!in_array($requested_type, $types)) {
4242
$error[] = __('The requested type has not been defined yet!');
@@ -101,7 +101,7 @@
101101
Html::header($itemtype::getTypeName(), $_SERVER['PHP_SELF'],
102102
"assets", ($menu!==false?$menu:$itemtype), strtolower($itemtype));
103103

104-
$item->display($_GET, array( 'withtemplate' => $_GET["withtemplate"]));
104+
$item->display($_GET, ['withtemplate' => $_GET["withtemplate"]]);
105105

106106
Html::footer();
107107
} else {

front/profile.form.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333

3434
/* save profile */
3535
if (isset($_POST['update_all_rights']) && isset($_POST['itemtype'])) {
36-
$profiles = array();
36+
$profiles = [];
3737
foreach ($_POST as $key => $val) {
3838
if (preg_match("/^profile_/", $key)) {
3939
$id = preg_replace("/^profile_/", "", $key);
40-
$profiles[$id] = array(
40+
$profiles[$id] = [
4141
"id" => $id,
4242
"_".PluginGenericobjectProfile::getProfileNameForItemtype($_POST['itemtype']) => $val
43-
);
43+
];
4444
}
4545
}
4646
_log($profiles);

front/type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
$type->getFromDBByType($_GET['itemtype']);
3535
Html::redirect(Toolbox::getItemTypeFormURL('PluginGenericobjectType').'?id='.$type->getID());
3636

37-
} else if (Session::haveRightsOr('plugin_genericobject_types', array(READ, CREATE, UPDATE, PURGE))) {
37+
} else if (Session::haveRightsOr('plugin_genericobject_types', [READ, CREATE, UPDATE, PURGE])) {
3838
Html::header(__("Type of objects", "genericobject"), $_SERVER['PHP_SELF'], "config",
3939
"PluginGenericobjectType");
4040
Search::Show('PluginGenericobjectType');

hook.php

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function plugin_genericobject_AssignToTicket($types) {
5252
// Define Dropdown tables to be manage in GLPI :
5353
function plugin_genericobject_getDropdown() {
5454

55-
$dropdowns = array('PluginGenericobjectTypeFamily' => PluginGenericobjectTypeFamily::getTypeName(2));
55+
$dropdowns = ['PluginGenericobjectTypeFamily' => PluginGenericobjectTypeFamily::getTypeName(2)];
5656

5757
$plugin = new Plugin();
5858
if ($plugin->isActivated("genericobject")) {
@@ -72,7 +72,7 @@ function plugin_genericobject_getDropdown() {
7272

7373
// Define dropdown relations
7474
function plugin_genericobject_getDatabaseRelations() {
75-
$dropdowns = array();
75+
$dropdowns = [];
7676

7777
//TODO : purt here relations
7878
/*
@@ -81,15 +81,15 @@ function plugin_genericobject_getDatabaseRelations() {
8181
foreach(getAllDatasFromTable(getTableForItemType('PluginGenericobjectType'),
8282
"`is_active`='1'") as $itemtype) {
8383
foreach(PluginGenericobjectType::getDropdownForItemtype($itemtype) as $table) {
84-
$dropdowns[$table][] = array()
84+
$dropdowns[$table][] = []
8585
}
8686
}
8787
}
8888
*/
8989
return $dropdowns;
9090
}
9191

92-
function plugin_uninstall_addUninstallTypes($uninstal_types = array()) {
92+
function plugin_uninstall_addUninstallTypes($uninstal_types = []) {
9393
foreach (PluginGenericobjectType::getTypes() as $tmp => $type) {
9494
if ($type["use_plugin_uninstall"]) {
9595
$uninstal_types[] = $type["itemtype"];
@@ -113,15 +113,14 @@ function plugin_genericobject_install() {
113113

114114
$migration = new Migration(PLUGIN_GENERICOBJECT_VERSION);
115115

116-
foreach (array(
117-
'PluginGenericobjectField',
118-
'PluginGenericobjectCommonDropdown',
119-
'PluginGenericobjectCommonTreeDropdown',
120-
'PluginGenericobjectProfile',
121-
'PluginGenericobjectType',
122-
'PluginGenericobjectTypeFamily'
123-
) as $itemtype
124-
) {
116+
foreach ([
117+
'PluginGenericobjectField',
118+
'PluginGenericobjectCommonDropdown',
119+
'PluginGenericobjectCommonTreeDropdown',
120+
'PluginGenericobjectProfile',
121+
'PluginGenericobjectType',
122+
'PluginGenericobjectTypeFamily'
123+
] as $itemtype) {
125124
if ($plug=isPluginItemType($itemtype)) {
126125
$plugname = strtolower($plug['plugin']);
127126
$dir = GLPI_ROOT . "/plugins/$plugname/inc/";
@@ -167,13 +166,12 @@ function plugin_genericobject_uninstall() {
167166
}
168167
}
169168

170-
foreach (array(
171-
'PluginGenericobjectType',
172-
'PluginGenericobjectProfile',
173-
'PluginGenericobjectField',
174-
'PluginGenericobjectTypeFamily'
175-
) as $itemtype
176-
) {
169+
foreach ([
170+
'PluginGenericobjectType',
171+
'PluginGenericobjectProfile',
172+
'PluginGenericobjectField',
173+
'PluginGenericobjectTypeFamily'
174+
] as $itemtype) {
177175
if ($plug=isPluginItemType($itemtype)) {
178176
$plugname = strtolower($plug['plugin']);
179177
$dir = GLPI_ROOT . "/plugins/$plugname/inc/";
@@ -212,12 +210,12 @@ function plugin_genericobject_MassiveActions($type) {
212210
if (isset($types[$type])) {
213211
$objecttype = PluginGenericobjectType::getInstance($type);
214212
if ($objecttype->isTransferable()) {
215-
return array('PluginGenericobjectObject'.
216-
MassiveAction::CLASS_ACTION_SEPARATOR.'plugin_genericobject_transfer' => __("Transfer"));
213+
return ['PluginGenericobjectObject'.
214+
MassiveAction::CLASS_ACTION_SEPARATOR.'plugin_genericobject_transfer' => __("Transfer")];
217215
} else {
218-
return array();
216+
return [];
219217
}
220218
} else {
221-
return array();
219+
return [];
222220
}
223221
}

inc/autoload.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class PluginGenericobjectAutoloader implements SplAutoloader
66
{
7-
protected $paths = array();
7+
protected $paths = [];
88

99
public function __construct($options = null) {
1010
if (null !== $options) {
@@ -47,11 +47,11 @@ public function autoload($classname) {
4747
return false;
4848
}
4949

50-
$filename = implode(".", array(
50+
$filename = implode(".", [
5151
$class_name,
5252
"class",
5353
"php"
54-
));
54+
]);
5555

5656
foreach ($this->paths as $path) {
5757
$test = $path . DIRECTORY_SEPARATOR . $filename;
@@ -64,6 +64,6 @@ public function autoload($classname) {
6464
}
6565

6666
public function register() {
67-
spl_autoload_register(array($this, 'autoload'));
67+
spl_autoload_register([$this, 'autoload']);
6868
}
6969
}

inc/field.class.php

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ public static function showObjectFieldsForm($id) {
4040
$object_type->getFromDB($id);
4141
$itemtype = $object_type->fields['itemtype'];
4242
$fields_in_db = PluginGenericobjectSingletonObjectField::getInstance($itemtype);
43-
$used_fields = array();
43+
$used_fields = [];
4444

4545
//Reset fields definition only to keep the itemtype ones
46-
$GO_FIELDS = array();
46+
$GO_FIELDS = [];
4747
plugin_genericobject_includeCommonFields(true);
4848

4949
PluginGenericobjectType::includeConstants($object_type->fields['name'], true);
@@ -98,13 +98,29 @@ public static function showObjectFieldsForm($id) {
9898
}
9999
echo "</table>";
100100
if ($haveCheckbox) {
101-
Html::openArrowMassives('fieldslist', true);
102-
Html::closeArrowMassives(array('delete' => __("Delete permanently")));
101+
echo "<table class='tab_glpi' width='950px'>";
102+
echo "<tr>";
103+
echo "<td><img src='".$CFG_GLPI["root_doc"]."/pics/arrow-left.png'
104+
alt=''></td>";
105+
echo "<td class='center' style='white-space:nowrap;'>";
106+
echo "<a onclick= \"if ( markCheckboxes('fieldslist') ) return false;\"
107+
href='#'>".__('Check all')."</a></td>";
108+
echo "<td>/</td>";
109+
echo "<td class='center' style='white-space:nowrap;'>";
110+
echo "<a onclick= \"if ( unMarkCheckboxes('fieldslist') ) return false;\"
111+
href='#'>".__('Uncheck all')."</a></td>";
112+
echo "<td class='left' width='80%'>";
113+
echo Html::submit(__("Delete permanently"), [
114+
'name' => 'delete',
115+
]);
116+
echo "</td></tr>";
117+
echo "</table>";
103118
}
104119

105120
$dropdownFields = self::dropdownFields("new_field", $itemtype, $used_fields);
106121

107122
if ($dropdownFields) {
123+
echo "<br>";
108124
echo "<table class='tab_cadre genericobject_fields add_new'>";
109125
echo "<tr class='tab_bg_1'>";
110126
echo "<td class='label'>" . __("Add new field", "genericobject") . "</td>";
@@ -202,13 +218,13 @@ static function getFieldName($field, $itemtype, $options, $remove_prefix = false
202218
*
203219
* @return the dropdown random ID
204220
*/
205-
static function dropdownFields($name,$itemtype, $used = array()) {
221+
static function dropdownFields($name,$itemtype, $used = []) {
206222
global $GO_FIELDS;
207223

208-
$dropdown_types = array();
224+
$dropdown_types = [];
209225
foreach ($GO_FIELDS as $field => $values) {
210226
$message = "";
211-
$field_options = array();
227+
$field_options = [];
212228
$field = self::getFieldName($field, $itemtype, $values, false);
213229
if (!in_array($field, $used)) {
214230
if (!isset($dropdown_types[$field])) {
@@ -250,7 +266,7 @@ static function dropdownFields($name,$itemtype, $used = array()) {
250266
}
251267

252268
ksort($dropdown_types);
253-
return Dropdown::showFromArray($name, $dropdown_types, array('display' => false));
269+
return Dropdown::showFromArray($name, $dropdown_types, ['display' => false]);
254270
}
255271

256272
/**
@@ -271,10 +287,10 @@ static function getFieldOptions($field, $itemtype="") {
271287
// This field has been dynamically defined because it's an isolated dropdown
272288
$tmpfield = self::getFieldName(
273289
$field, $itemtype,
274-
array(
290+
[
275291
'dropdown_type' => 'isolated',
276-
'input_type' => 'dropdown'
277-
),
292+
'input_type' => 'dropdown'
293+
],
278294
true
279295
);
280296
$options = $GO_FIELDS[$tmpfield];
@@ -294,11 +310,11 @@ public static function displayFieldDefinition($target, $itemtype, $field, $index
294310
$options = self::getFieldOptions($field, $itemtype);
295311

296312
echo "<tr class='tab_bg_".(($index%2)+1)."' align='center'>";
297-
$sel ="";
298-
299313
echo "<td width='10'>";
300314
if (!$blacklist && !$readonly) {
301-
echo "<input type='checkbox' name='fields[" .$field. "]' value='1' $sel>";
315+
echo "<input type='checkbox' name='fields[" .$field. "]' value='1'>";
316+
} else {
317+
echo "<i class='fa fa-lock' title='".__("Read-only field", 'genericobject')."'>";
302318
}
303319
echo "</td>";
304320
echo "<td>" . __($options['name'], 'genericobject') . "</td>";
@@ -307,16 +323,16 @@ public static function displayFieldDefinition($target, $itemtype, $field, $index
307323
echo "<td width='10'>";
308324
if ((!$blacklist || $readonly) && $index > 1) {
309325
Html::showSimpleForm($target, $CFG_GLPI["root_doc"] . "/pics/deplier_up.png", 'up',
310-
array('field' => $field, 'action' => 'up', 'itemtype' => $itemtype),
311-
$CFG_GLPI["root_doc"] . "/pics/deplier_up.png");
326+
['field' => $field, 'action' => 'up', 'itemtype' => $itemtype],
327+
$CFG_GLPI["root_doc"] . "/pics/deplier_up.png");
312328
}
313329
echo "</td>";
314330

315331
echo "<td width='10'>";
316332
if ((!$blacklist || $readonly) && !$last) {
317333
Html::showSimpleForm($target, $CFG_GLPI["root_doc"] . "/pics/deplier_down.png", 'down',
318-
array('field' => $field, 'action' => 'down', 'itemtype' => $itemtype),
319-
$CFG_GLPI["root_doc"] . "/pics/deplier_down.png");
334+
['field' => $field, 'action' => 'down', 'itemtype' => $itemtype],
335+
$CFG_GLPI["root_doc"] . "/pics/deplier_down.png");
320336
}
321337
echo "</td>";
322338

@@ -435,8 +451,10 @@ static function deleteDisplayPreferences($table, $field) {
435451
foreach ($searchopt as $num => $option) {
436452
if ((isset($option['field']) && ($option['field'] == $field))
437453
|| (isset($option['field']) && $option['linkfield'] == $field)) {
438-
$criteria = array('itemtype' => $itemtype, 'num' => $num);
439-
$pref->deleteByCriteria($criteria);
454+
$pref->deleteByCriteria([
455+
'itemtype' => $itemtype,
456+
'num' => $num
457+
]);
440458
break;
441459
}
442460
}
@@ -447,7 +465,7 @@ static function deleteDisplayPreferences($table, $field) {
447465
* @params an array which contains the itemtype, the field to move and the action (up/down)
448466
* @return nothing
449467
*/
450-
static function changeFieldOrder($params = array()) {
468+
static function changeFieldOrder($params = []) {
451469
global $DB;
452470
$itemtype = $params['itemtype'];
453471
$field = $params['field'];
@@ -492,7 +510,7 @@ public static function checkNecessaryFieldsDelete($itemtype,$field) {
492510
}
493511
/*
494512
if ($type->fields['use_direct_connections']) {
495-
foreach(array('users_id','groups_id',' states_id','locations_id') as $tmp_field) {
513+
foreach(['users_id','groups_id',' states_id','locations_id'] as $tmp_field) {
496514
if ($tmp_field == $field) {
497515
return false;
498516
}

inc/functions.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function dropdown_getTypeName($class,$nb=0) {
2626
}
2727
}
2828
global $LOG_FILTER;
29-
$LOG_FILTER = array();
29+
$LOG_FILTER = [];
3030
/*
3131
* a simple logger function
3232
* You can disable logging by using the global $LOG_FILTER
@@ -35,12 +35,10 @@ function dropdown_getTypeName($class,$nb=0) {
3535
function _log() {
3636
global $LOG_FILTER;
3737
$trace = debug_backtrace();
38-
//call_user_func_array("Toolbox::logInFile", array('generic-object', print_r($trace,true) . "\n", true));
3938
if (count($trace)>0) {
4039
$glpi_root = str_replace( "\\", "/", GLPI_ROOT );
4140
$trace_file = str_replace( "\\", "/", $trace[0]['file'] );
4241
$filename = preg_replace("|^".$glpi_root."/plugins/genericobject/|", "", $trace_file);
43-
//call_user_func_array("Toolbox::logInFile", array('generic-object', $filename . "\n", true));
4442
}
4543
if (count($trace) > 1) {
4644
$caller = $trace[1];
@@ -61,7 +59,7 @@ function _log() {
6159
$show_log = true;
6260
}
6361
if ($show_log) {
64-
call_user_func_array("Toolbox::logInFile", array('generic-object', $msg, true));
62+
call_user_func_array("Toolbox::logInFile", ['generic-object', $msg, true]);
6563
}
6664
}
6765

0 commit comments

Comments
 (0)