Skip to content

Commit 99c4e37

Browse files
stonebuzzflegastelois
authored andcommitted
fix CS
1 parent ed0d324 commit 99c4e37

10 files changed

Lines changed: 49 additions & 64 deletions

front/config.form.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
$_SERVER['PHP_SELF'],
4545
"plugins",
4646
"plugintreeviewpreference",
47-
"config"); $config->showForm(1);
47+
"config");
48+
$config->showForm(1);
4849

4950
} else {
5051

@@ -62,5 +63,4 @@
6263
}
6364
}
6465

65-
Html::footer();
66-
?>
66+
Html::footer();

front/preference.form.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@
3535
if (isset($_POST['plugin_treeview_user_preferences_save'])) {
3636
$pref->update($_POST);
3737
Html::back();
38-
}
39-
?>
38+
}

front/preference.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@
3535
include ('../../../inc/includes.php');
3636

3737
if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
38-
Html::header("TITRE", $_SERVER['PHP_SELF'],"plugins","pluginexampleexample","");
38+
Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins", "pluginexampleexample", "");
3939
} else {
4040
Html::helpHeader("TITRE", $_SERVER['PHP_SELF']);
4141
}
4242

43-
4443
//checkTypeRight('PluginExampleExample',"r");
4544

4645
Search::show('PluginExampleExample');
4746

48-
Html::footer();
49-
?>
47+
Html::footer();

front/profile.form.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@
3636
if (isset($_POST['update_user_profile'])) {
3737
$prof->update($_POST);
3838
Html::back();
39-
}
40-
?>
39+
}

inc/config.class.php

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public static function getTypeName($nb = 0) {
4949
return __('Tree view', 'treeview');
5050
}
5151

52-
5352
/**
5453
* Configuration form
5554
**/
@@ -156,7 +155,6 @@ function showForm($id, $options=array()) {
156155
Html::closeForm();
157156
}
158157

159-
160158
/**
161159
* For other plugins, add a type to the linkable types
162160
*
@@ -197,10 +195,9 @@ static function getTypes($all=false) {
197195
}
198196
return $types;
199197
}
200-
198+
201199
static function getPicbyType($type) {
202200
global $PLUGIN_HOOKS;
203-
204201
$pic = '';
205202
switch ($type) {
206203
case 'Computer' :
@@ -226,14 +223,11 @@ static function getPicbyType($type) {
226223
break;
227224
}
228225
//Like $PLUGIN_HOOKS['treeview']['PluginExampleExample'] = '../example/pics/mypic.png';
229-
if (in_array($type, self::$types)
230-
&& isPluginItemtype($type)) {
231-
if (isset($PLUGIN_HOOKS['treeview'][$type])) {
232-
return $PLUGIN_HOOKS['treeview'][$type];
233-
}
234-
226+
if (in_array($type, self::$types) && isPluginItemtype($type)) {
227+
if (isset($PLUGIN_HOOKS['treeview'][$type])) {
228+
return $PLUGIN_HOOKS['treeview'][$type];
229+
}
235230
}
236-
237231
return $pic;
238232
}
239233

@@ -296,7 +290,7 @@ function hideTreeview() {
296290
function buildTreeview() {
297291
global $CFG_GLPI;
298292

299-
# necessary files needed for the tree to work.
293+
//necessary files needed for the tree to work.
300294
echo "<link rel='stylesheet' type='text/css' href='".
301295
$CFG_GLPI["root_doc"]."/plugins/treeview/dtree.css' type=\"text/css\" >\n";
302296
echo "<script type='text/javascript' src='".$CFG_GLPI["root_doc"].
@@ -327,15 +321,13 @@ function getNodesFromDb() {
327321

328322
$itemName = $this->fields["itemName"];
329323
$locationName = $this->fields["locationName"];
330-
331324
$target = $this->fields["target"];
332325
$folderLinks = $this->fields["folderLinks"];
333326
$useSelection = $this->fields["useSelection"];
334327
$useLines = $this->fields["useLines"];
335328
$useIcons = $this->fields["useIcons"];
336329
$closeSameLevel = $this->fields["closeSameLevel"];
337330

338-
339331
// Load the settings in JavaSript so that dTree script can apply them
340332
echo "d.config.target = '" .$target. "';\n";
341333
echo "d.config.folderLinks = " .$folderLinks. ";\n";
@@ -350,9 +342,9 @@ function getNodesFromDb() {
350342
$query = " SELECT MAX(`id`) AS `max_id`,
351343
MAX(`level`) AS `max_level`
352344
FROM `glpi_locations` ";
353-
354-
$query.= getEntitiesRestrictRequest(" WHERE ","glpi_locations",'','',true);
355-
345+
346+
$query.= getEntitiesRestrictRequest(" WHERE ", "glpi_locations", '', '', true);
347+
356348
$result = $DB->query($query);
357349

358350
$max_level = $DB->result($result, 0, "max_level");
@@ -380,16 +372,16 @@ function getNodesFromDb() {
380372
"\r" =>" ",
381373
"\n" =>" ");
382374

383-
for ($n=1 ; $n<=count($nodes) ; $n++) {
375+
for ($n=1; $n<=count($nodes); $n++) {
384376
if ($nodes[$n-1] <= $max_id && $n <= $max_level) {
385377
$query = "SELECT *
386378
FROM `glpi_locations`
387379
WHERE `level` = '$n'
388380
AND `locations_id` = '". $nodes[$n-1] ."'";
389-
390-
$query.= getEntitiesRestrictRequest(" AND ","glpi_locations",'','',true);
381+
382+
$query.= getEntitiesRestrictRequest(" AND ", "glpi_locations", '', '', true);
391383
$query.= "ORDER BY `completename` ASC";
392-
384+
393385
$result = $DB->query($query);
394386

395387
while ($r = $DB->fetch_assoc($result)) {
@@ -415,7 +407,7 @@ function getNodesFromDb() {
415407

416408
// Is this location requested by the user to be opened
417409
if (in_array($r['id'], $nodes)) {
418-
echo "d.add(".$r['id'].", ".$r['locations_id'].", \"".strtr($l_name,$trans).
410+
echo "d.add(".$r['id'].", ".$r['locations_id'].", \"".strtr($l_name, $trans).
419411
"\", true, -1,'');\n";
420412
$dontLoad = 'true';
421413
// Then add aloso its items
@@ -426,20 +418,20 @@ function getNodesFromDb() {
426418
$query = "SELECT *
427419
FROM `$itemtable`
428420
WHERE `locations_id` = '".$r['id']."'";
429-
421+
430422
if ($item->maybeTemplate()) {
431423
$query .= " AND `$itemtable`.`is_template` = '0'";
432424
}
433425
if ($item->maybeDeleted()) {
434426
$query .= " AND `$itemtable`.`is_deleted` = '0'";
435427
}
436-
428+
437429
if ($this->isEntityAssign()) {
438430
$query .= " AND `$itemtable`.`entities_id` = '".$_SESSION["glpiactive_entity"]."'";
439431
}
440-
432+
441433
$query .= " ORDER BY `$itemtable`.`name`";
442-
434+
443435
$result_1 = $DB->query($query);
444436
if ($DB->numrows($result_1)) {
445437
$pid = $tv_id;
@@ -497,32 +489,32 @@ function getNodesFromDb() {
497489
$i_name = $r_1['name'];
498490
}
499491
}
500-
492+
501493
$url = Toolbox::getItemTypeFormURL($type). "?id=" .$r_1['id'];
502494
$pic = "pics/node.gif";
503-
$name = strtr($i_name,$trans);
495+
$name = strtr($i_name, $trans);
504496
$opt = array('url' => $url,
505497
'pic' => $pic,
506498
'name' => $name);
507-
499+
508500
$params = array('itemtype' => $type,
509501
'id' => $r_1['id'],
510502
'url' => $url,
511503
'pic' => $pic,
512504
'name' => $name);
513-
505+
514506
$opt = Plugin::doHookFunction('treeview_params', $params);
515507

516508
// Add the item
517509
echo "d.add(".$tv_id++.", $pid, \"" . $opt['name'] . "\", true, -1, '" .
518510
$opt['url']."', '', '', '".$opt['pic']."','".$opt['pic']."');\n";
519-
511+
520512
}
521513
}
522514

523-
// Add only the location without its items
515+
// Add only the location without its items
524516
} else {
525-
echo "d.add(".$r['id'].",".$r['locations_id'].",\"".strtr($l_name,$trans).
517+
echo "d.add(".$r['id'].",".$r['locations_id'].",\"".strtr($l_name, $trans).
526518
"\", false, -1,'', '', '', '', '', false, true);\n";
527519
}
528520
}
@@ -539,5 +531,4 @@ function getNodesFromDb() {
539531
echo "d.openTo(" .$nodes[count($nodes)-1]. ");\n";
540532
}
541533
}
542-
}
543-
?>
534+
}

inc/preference.class.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function showFormUserPreference($target, $id) {
5757
echo "<tr class='tab_bg_1 center'>";
5858
echo "<td>".__('Launch the plugin Treeview with GLPI launching', 'treeview')."</td>";
5959
echo "<td>";
60-
Dropdown::showYesNo("show_on_load",$this->fields["show_on_load"]);
60+
Dropdown::showYesNo("show_on_load", $this->fields["show_on_load"]);
6161
echo "</td></tr>";
6262

6363
echo "<tr class='tab_bg_1 center'><td colspan='2'>";
@@ -66,7 +66,7 @@ function showFormUserPreference($target, $id) {
6666
echo "<input type='hidden' name='id' value='$id'></td></tr>";
6767

6868
echo "<tr class='tab_bg_1 center'>";
69-
echo "<td colspan='2'>".__('Warning: If there are more than one plugin which be loaded at startup, then only the first will be used','treeview');
69+
echo "<td colspan='2'>".__('Warning: If there are more than one plugin which be loaded at startup, then only the first will be used', 'treeview');
7070
echo "</td></tr>";
7171

7272
echo "</table>";
@@ -130,5 +130,4 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtempl
130130
}
131131
return true;
132132
}
133-
}
134-
?>
133+
}

inc/profile.class.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ static function changeProfile() {
6565
unset($_SESSION["glpi_plugin_treeview_profile"]);
6666
}
6767

68-
// require 'preference.class.php';
69-
68+
//require 'preference.class.php';
7069
$Pref = new PluginTreeviewPreference();
7170
$pref_value = $Pref->checkPreferenceValue(Session::getLoginUserID());
7271
if ($pref_value==1) {
@@ -84,15 +83,15 @@ function showForm($id, $options=array()) {
8483

8584
$target = $this->getFormURL();
8685
if (isset($options['target'])) {
87-
$target = $options['target'];
86+
$target = $options['target'];
8887
}
8988

90-
if (!Session::haveRight("profile",READ)) {
89+
if (!Session::haveRight("profile", READ)) {
9190
return false;
9291
}
9392
$canedit = Session::haveRight("profile", UPDATE);
9493
$prof = new Profile();
95-
if ($id){
94+
if ($id) {
9695
$this->getFromDB($id);
9796
$prof->getFromDB($id);
9897
}
@@ -149,5 +148,4 @@ static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtempl
149148
}
150149
return true;
151150
}
152-
}
153-
?>
151+
}

index.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,4 @@
3333

3434
$_SESSION["glpi_plugin_treeview_loaded"] = 1;
3535
$config = new PluginTreeviewConfig();
36-
$config->seeTreeview();
37-
?>
36+
$config->seeTreeview();

left.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,4 @@
6969
$config->buildTreeview();
7070

7171
echo "</body>";
72-
echo "</html>";
73-
?>
72+
echo "</html>";

setup.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,14 @@ function plugin_version_treeview() {
112112

113113

114114
function plugin_treeview_check_prerequisites() {
115-
return true;
115+
if (version_compare(GLPI_VERSION, '9.1', 'lt') || version_compare(GLPI_VERSION, '9.2', 'ge')) {
116+
echo 'This plugin requires GLPI >= 9.1';
117+
return false;
118+
}
119+
return true;
116120
}
117121

118122

119123
function plugin_treeview_check_config() {
120124
return true;
121-
}
122-
?>
125+
}

0 commit comments

Comments
 (0)