-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathhook.php
716 lines (588 loc) · 24 KB
/
hook.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
<?php
/**
* -------------------------------------------------------------------------
* Example plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of Example.
*
* Example is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Example is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Example. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @copyright Copyright (C) 2006-2022 by Example plugin team.
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
* @link https://github.com/pluginsGLPI/example
* -------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// ----------------------------------------------------------------------
use GlpiPlugin\Example\Dropdown;
use GlpiPlugin\Example\Example;
use Dropdown as GlpiDropdown;
function plugin_change_profile_example() {
// Some logic that runs when the profile is changed
}
// Define dropdown relations
function plugin_example_getDatabaseRelations() {
return ["glpi_plugin_example_dropdowns" => ["glpi_plugin_example" => "plugin_example_dropdowns_id"]];
}
// Define Dropdown tables to be manage in GLPI :
function plugin_example_getDropdown() {
// Table => Name
return [Dropdown::class => __("Plugin Example Dropdown", 'example')];
}
////// SEARCH FUNCTIONS ///////(){
// Define Additionnal search options for types (other than the plugin ones)
function plugin_example_getAddSearchOptions($itemtype) {
$sopt = [];
if ($itemtype == 'Computer') {
// Just for example, not working...
$sopt[1001]['table'] = 'glpi_plugin_example_dropdowns';
$sopt[1001]['field'] = 'name';
$sopt[1001]['linkfield'] = 'plugin_example_dropdowns_id';
$sopt[1001]['name'] = __('Example plugin', 'example');
}
return $sopt;
}
function plugin_example_getAddSearchOptionsNew($itemtype) {
$options = [];
if ($itemtype == 'Computer') {
//Just for example, not working
$options[] = [
'id' => '1002',
'table' => 'glpi_plugin_example_dropdowns',
'field' => 'name',
'linkfield' => 'plugin_example_dropdowns_id',
'name' => __('Example plugin new', 'example')
];
}
return $options;
}
// See also GlpiPlugin\Example\Example::getSpecificValueToDisplay()
function plugin_example_giveItem($type, $ID, $data, $num) {
$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
switch ($table.'.'.$field) {
case "glpi_plugin_example_examples.name" :
$out = "<a href='".Toolbox::getItemTypeFormURL(Example::class)."?id=".$data['id']."'>";
$out .= $data[$num][0]['name'];
if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][0]['name'])) {
$out .= " (".$data["id"].")";
}
$out .= "</a>";
return $out;
}
return "";
}
function plugin_example_displayConfigItem($type, $ID, $data, $num) {
$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
// Example of specific style options
// No need of the function if you do not have specific cases
switch ($table.'.'.$field) {
case "glpi_plugin_example_examples.name" :
return " style=\"background-color:#DDDDDD;\" ";
}
return "";
}
function plugin_example_addDefaultJoin($type, $ref_table, &$already_link_tables) {
// Example of default JOIN clause
// No need of the function if you do not have specific cases
switch ($type) {
// case Example::class :
case "MyType" :
return Search::addLeftJoin($type, $ref_table, $already_link_tables,
"newtable", "linkfield");
}
return "";
}
function plugin_example_addDefaultSelect($type) {
// Example of default SELECT item to be added
// No need of the function if you do not have specific cases
switch ($type) {
// case Example::class :
case "MyType" :
return "`mytable`.`myfield` = 'myvalue' AS MYNAME, ";
}
return "";
}
function plugin_example_addDefaultWhere($type) {
// Example of default WHERE item to be added
// No need of the function if you do not have specific cases
switch ($type) {
// case Example::class :
case "MyType" :
return " `mytable`.`myfield` = 'myvalue' ";
}
return "";
}
function plugin_example_addLeftJoin($type, $ref_table, $new_table, $linkfield) {
// Example of standard LEFT JOIN clause but use it ONLY for specific LEFT JOIN
// No need of the function if you do not have specific cases
switch ($new_table) {
case "glpi_plugin_example_dropdowns" :
return " LEFT JOIN `$new_table` ON (`$ref_table`.`$linkfield` = `$new_table`.`id`) ";
}
return "";
}
function plugin_example_forceGroupBy($type) {
switch ($type) {
case Example::class :
// Force add GROUP BY IN REQUEST
return true;
}
return false;
}
function plugin_example_addWhere($link, $nott, $type, $ID, $val, $searchtype) {
$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
$SEARCH = Search::makeTextSearch($val, $nott);
// Example of standard Where clause but use it ONLY for specific Where
// No need of the function if you do not have specific cases
switch ($table.".".$field) {
/*case "glpi_plugin_example.name" :
$ADD = "";
if ($nott && $val!="NULL") {
$ADD = " OR `$table`.`$field` IS NULL";
}
return $link." (`$table`.`$field` $SEARCH ".$ADD." ) ";*/
case "glpi_plugin_example_examples.serial" :
return $link." `$table`.`$field` = '$val' ";
}
return "";
}
// This is not a real example because the use of Having condition in this case is not suitable
function plugin_example_addHaving($link, $nott, $type, $ID, $val, $num) {
$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
$SEARCH = Search::makeTextSearch($val, $nott);
// Example of standard Having clause but use it ONLY for specific Having
// No need of the function if you do not have specific cases
switch ($table.".".$field) {
case "glpi_plugin_example.serial" :
$ADD = "";
if (($nott && $val!="NULL")
|| $val == '^$') {
$ADD = " OR ITEM_$num IS NULL";
}
return " $LINK ( ITEM_".$num.$SEARCH." $ADD ) ";
}
return "";
}
function plugin_example_addSelect($type, $ID, $num) {
$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
// Example of standard Select clause but use it ONLY for specific Select
// No need of the function if you do not have specific cases
// switch ($table.".".$field) {
// case "glpi_plugin_example.name" :
// return $table.".".$field." AS ITEM_$num, ";
// }
return "";
}
function plugin_example_addOrderBy($type, $ID, $order, $key = 0) {
$searchopt = &Search::getOptions($type);
$table = $searchopt[$ID]["table"];
$field = $searchopt[$ID]["field"];
// Example of standard OrderBy clause but use it ONLY for specific order by
// No need of the function if you do not have specific cases
// switch ($table.".".$field) {
// case "glpi_plugin_example.name" :
// return " ORDER BY $table.$field $order ";
// }
return "";
}
//////////////////////////////
////// SPECIFIC MODIF MASSIVE FUNCTIONS ///////
// Define actions :
function plugin_example_MassiveActions($type) {
switch ($type) {
// New action for core and other plugin types : name = plugin_PLUGINNAME_actionname
case 'Computer' :
return [Example::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'DoIt' =>
__("plugin_example_DoIt", 'example')];
// Actions for types provided by the plugin are included inside the classes
}
return [];
}
// How to display specific update fields ?
// options must contain at least itemtype and options array
function plugin_example_MassiveActionsFieldsDisplay($options = []) {
//$type,$table,$field,$linkfield
$table = $options['options']['table'];
$field = $options['options']['field'];
$linkfield = $options['options']['linkfield'];
if ($table == getTableForItemType($options['itemtype'])) {
// Table fields
switch ($table.".".$field) {
case 'glpi_plugin_example_examples.serial' :
echo __("Not really specific - Just for example", 'example');
// Dropdown::showYesNo($linkfield);
// Need to return true if specific display
return true;
}
} else {
// Linked Fields
switch ($table.".".$field) {
case "glpi_plugin_example_dropdowns.name" :
echo __("Not really specific - Just for example", 'example');
// Need to return true if specific display
return true;
}
}
// Need to return false on non display item
return false;
}
// How to display specific search fields or dropdown ?
// options must contain at least itemtype and options array
// MUST Use a specific AddWhere & $tab[X]['searchtype'] = 'equals'; declaration
function plugin_example_searchOptionsValues($options = []) {
$table = $options['searchoption']['table'];
$field = $options['searchoption']['field'];
// Table fields
switch ($table.".".$field) {
case "glpi_plugin_example_examples.serial" :
echo __("Not really specific - Use your own dropdown - Just for example", 'example');
GlpiDropdown::show(getItemTypeForTable($options['searchoption']['table']),
['value' => $options['value'],
'name' => $options['name'],
'comments' => 0]);
// Need to return true if specific display
return true;
}
return false;
}
//////////////////////////////
// Hook done on before update item case
function plugin_pre_item_update_example($item) {
/* Manipulate data if needed
if (!isset($item->input['comment'])) {
$item->input['comment'] = addslashes($item->fields['comment']);
}
$item->input['comment'] .= addslashes("\nUpdate: ".date('r'));
*/
Session::addMessageAfterRedirect(__("Pre Update Computer Hook", 'example'), true);
}
// Hook done on update item case
function plugin_item_update_example($item) {
Session::addMessageAfterRedirect(sprintf(__("Update Computer Hook (%s)", 'example'), implode(',', $item->updates)), true);
return true;
}
// Hook done on get empty item case
function plugin_item_empty_example($item) {
if (empty($_SESSION['Already displayed "Empty Computer Hook"'])) {
Session::addMessageAfterRedirect(__("Empty Computer Hook", 'example'), true);
$_SESSION['Already displayed "Empty Computer Hook"'] = true;
}
return true;
}
// Hook done on before delete item case
function plugin_pre_item_delete_example($object) {
// Manipulate data if needed
Session::addMessageAfterRedirect(__("Pre Delete Computer Hook", 'example'), true);
}
// Hook done on delete item case
function plugin_item_delete_example($object) {
Session::addMessageAfterRedirect(__("Delete Computer Hook", 'example'), true);
return true;
}
// Hook done on before purge item case
function plugin_pre_item_purge_example($object) {
// Manipulate data if needed
Session::addMessageAfterRedirect(__("Pre Purge Computer Hook", 'example'), true);
}
// Hook done on purge item case
function plugin_item_purge_example($object) {
Session::addMessageAfterRedirect(__("Purge Computer Hook", 'example'), true);
return true;
}
// Hook done on before restore item case
function plugin_pre_item_restore_example($item) {
// Manipulate data if needed
Session::addMessageAfterRedirect(__("Pre Restore Computer Hook", 'example'));
}
// Hook done on before restore item case
function plugin_pre_item_restore_example2($item) {
// Manipulate data if needed
Session::addMessageAfterRedirect(__("Pre Restore Phone Hook", 'example'));
}
// Hook done on restore item case
function plugin_item_restore_example($item) {
Session::addMessageAfterRedirect(__("Restore Computer Hook", 'example'));
return true;
}
// Hook done on restore item case
function plugin_item_transfer_example($parm) {
//TRANS: %1$s is the source type, %2$d is the source ID, %3$d is the destination ID
Session::addMessageAfterRedirect(sprintf(__('Transfer Computer Hook %1$s %2$d -> %3$d', 'example'), $parm['type'], $parm['id'],
$parm['newID']));
return false;
}
// Do special actions for dynamic report
function plugin_example_dynamicReport($parm) {
if ($parm["item_type"] == Example::class) {
// Do all what you want for export depending on $parm
echo "Personalized export for type ".$parm["display_type"];
echo 'with additional datas : <br>';
echo "Single data : add1 <br>";
print $parm['add1'].'<br>';
echo "Array data : add2 <br>";
Html::printCleanArray($parm['add2']);
// Return true if personalized display is done
return true;
}
// Return false if no specific display is done, then use standard display
return false;
}
// Add parameters to Html::printPager in search system
function plugin_example_addParamFordynamicReport($itemtype) {
if ($itemtype == Example::class) {
// Return array data containing all params to add : may be single data or array data
// Search config are available from session variable
return ['add1' => $_SESSION['glpisearch'][$itemtype]['order'],
'add2' => ['tutu' => 'Second Add',
'Other Data']];
}
// Return false or a non array data if not needed
return false;
}
/**
* Plugin install process
*
* @return boolean
*/
function plugin_example_install() {
global $DB;
$migration = new Migration(PLUGIN_EXAMPLE_VERSION);
Config::setConfigurationValues('plugin:Example', ['configuration' => false]);
// Adds the right(s) to all pre-existing profiles with no access by default
ProfileRight::addProfileRights([Example::$rightname]);
// Grants full access to profiles that can update the Config (super-admins)
$migration->addRight(Example::$rightname, ALLSTANDARDRIGHT, [Config::$rightname => UPDATE]);
$default_charset = DBConnection::getDefaultCharset();
$default_collation = DBConnection::getDefaultCollation();
$default_key_sign = DBConnection::getDefaultPrimaryKeySignOption();
if (!$DB->tableExists("glpi_plugin_example_examples")) {
$query = "CREATE TABLE `glpi_plugin_example_examples` (
`id` int {$default_key_sign} NOT NULL auto_increment,
`name` varchar(255) default NULL,
`serial` varchar(255) NOT NULL,
`plugin_example_dropdowns_id` int {$default_key_sign} NOT NULL default '0',
`is_deleted` tinyint NOT NULL default '0',
`is_template` tinyint NOT NULL default '0',
`template_name` varchar(255) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
$query = "INSERT INTO `glpi_plugin_example_examples`
(`id`, `name`, `serial`, `plugin_example_dropdowns_id`, `is_deleted`,
`is_template`, `template_name`)
VALUES (1, 'example 1', 'serial 1', 1, 0, 0, NULL),
(2, 'example 2', 'serial 2', 2, 0, 0, NULL),
(3, 'example 3', 'serial 3', 1, 0, 0, NULL)";
$DB->query($query) or die("error populate glpi_plugin_example ". $DB->error());
}
if (!$DB->tableExists("glpi_plugin_example_dropdowns")) {
$query = "CREATE TABLE `glpi_plugin_example_dropdowns` (
`id` int {$default_key_sign} NOT NULL auto_increment,
`name` varchar(255) default NULL,
`comment` text,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->query($query) or die("error creating glpi_plugin_example_dropdowns". $DB->error());
$query = "INSERT INTO `glpi_plugin_example_dropdowns`
(`id`, `name`, `comment`)
VALUES (1, 'dp 1', 'comment 1'),
(2, 'dp2', 'comment 2')";
$DB->query($query) or die("error populate glpi_plugin_example_dropdowns". $DB->error());
}
if (!$DB->tableExists('glpi_plugin_example_devicecameras')) {
$query = "CREATE TABLE `glpi_plugin_example_devicecameras` (
`id` int {$default_key_sign} NOT NULL AUTO_INCREMENT,
`designation` varchar(255) DEFAULT NULL,
`comment` text,
`manufacturers_id` int {$default_key_sign} NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `designation` (`designation`),
KEY `manufacturers_id` (`manufacturers_id`)
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
}
if (!$DB->tableExists('glpi_plugin_example_items_devicecameras')) {
$query = "CREATE TABLE `glpi_plugin_example_items_devicecameras` (
`id` int {$default_key_sign} NOT NULL AUTO_INCREMENT,
`items_id` int {$default_key_sign} NOT NULL DEFAULT '0',
`itemtype` varchar(255) DEFAULT NULL,
`plugin_example_devicecameras_id` int {$default_key_sign} NOT NULL DEFAULT '0',
`is_deleted` tinyint NOT NULL DEFAULT '0',
`is_dynamic` tinyint NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `computers_id` (`items_id`),
KEY `plugin_example_devicecameras_id` (`plugin_example_devicecameras_id`),
KEY `is_deleted` (`is_deleted`),
KEY `is_dynamic` (`is_dynamic`)
) ENGINE=InnoDB DEFAULT CHARSET={$default_charset} COLLATE={$default_collation} ROW_FORMAT=DYNAMIC;";
$DB->query($query) or die("error creating glpi_plugin_example_examples ". $DB->error());
}
// To be called for each task the plugin manage
// task in class
CronTask::Register(Example::class, 'Sample', DAY_TIMESTAMP, ['param' => 50]);
return true;
}
/**
* Plugin uninstall process
*
* @return boolean
*/
function plugin_example_uninstall() {
global $DB;
$config = new Config();
$config->deleteConfigurationValues('plugin:Example', ['configuration' => false]);
ProfileRight::deleteProfileRights([Example::$rightname]);
$notif = new Notification();
$options = ['itemtype' => 'Ticket',
'event' => 'plugin_example',
'FIELDS' => 'id'];
foreach ($DB->request('glpi_notifications', $options) as $data) {
$notif->delete($data);
}
// Old version tables
if ($DB->tableExists("glpi_dropdown_plugin_example")) {
$query = "DROP TABLE `glpi_dropdown_plugin_example`";
$DB->query($query) or die("error deleting glpi_dropdown_plugin_example");
}
if ($DB->tableExists("glpi_plugin_example")) {
$query = "DROP TABLE `glpi_plugin_example`";
$DB->query($query) or die("error deleting glpi_plugin_example");
}
// Current version tables
if ($DB->tableExists("glpi_plugin_example_example")) {
$query = "DROP TABLE `glpi_plugin_example_example`";
$DB->query($query) or die("error deleting glpi_plugin_example_example");
}
if ($DB->tableExists("glpi_plugin_example_dropdowns")) {
$query = "DROP TABLE `glpi_plugin_example_dropdowns`;";
$DB->query($query) or die("error deleting glpi_plugin_example_dropdowns");
}
if ($DB->tableExists("glpi_plugin_example_devicecameras")) {
$query = "DROP TABLE `glpi_plugin_example_devicecameras`;";
$DB->query($query) or die("error deleting glpi_plugin_example_devicecameras");
}
if ($DB->tableExists("glpi_plugin_example_items_devicecameras")) {
$query = "DROP TABLE `glpi_plugin_example_items_devicecameras`;";
$DB->query($query) or die("error deleting glpi_plugin_example_items_devicecameras");
}
return true;
}
function plugin_example_AssignToTicket($types) {
$types[Example::class] = "Example";
return $types;
}
function plugin_example_get_events(NotificationTargetTicket $target) {
$target->events['plugin_example'] = __("Example event", 'example');
}
function plugin_example_get_datas(NotificationTargetTicket $target) {
$target->data['##ticket.example##'] = __("Example datas", 'example');
}
function plugin_example_postinit() {
global $CFG_GLPI;
// All plugins are initialized, so all types are registered
//foreach (Infocom::getItemtypesThatCanHave() as $type) {
// do something
//}
}
/**
* Hook to add more data from ldap
* fields from plugin_retrieve_more_field_from_ldap_example
*
* @param $datas array
*
* @return un tableau
**/
function plugin_retrieve_more_data_from_ldap_example(array $datas) {
return $datas;
}
/**
* Hook to add more fields from LDAP
*
* @param $fields array
*
* @return un tableau
**/
function plugin_retrieve_more_field_from_ldap_example($fields) {
return $fields;
}
// Check to add to status page
function plugin_example_Status($param) {
// Do checks (no check for example)
$ok = true;
echo "example plugin: example";
if ($ok) {
echo "_OK";
} else {
echo "_PROBLEM";
// Only set ok to false if trouble (global status)
$param['ok'] = false;
}
echo "\n";
return $param;
}
function plugin_example_display_central() {
echo "<tr><th colspan='2'>";
echo "<div style='text-align:center; font-size:2em'>";
echo __("Plugin example displays on central page", "example");
echo "</div>";
echo "</th></tr>";
}
function plugin_example_display_login() {
echo "<div style='text-align:center; font-size:2em'>";
echo __("Plugin example displays on login page", "example");
echo "</div>";
}
function plugin_example_infocom_hook($params) {
echo "<tr><th colspan='4'>";
echo __("Plugin example displays on central page", "example");
echo "</th></tr>";
}
function plugin_example_filter_actors(array $params = []): array {
$itemtype = $params['params']['itemtype'];
$items_id = $params['params']['items_id'];
// remove users_id = 1 for assignee list
if ($itemtype == 'Ticket' && $params['params']['actortype'] == 'assign') {
foreach ($params['actors'] as $index => &$actor) {
if ($actor['type'] == 'user' && $actor['items_id'] == 1) {
unset($params['actors'][$index]);
}
}
}
return $params;
}
function plugin_example_set_impact_icon(array $params) {
$itemtype = $params['itemtype'];
$items_id = $params['items_id'];
$item = getItemForItemtype($itemtype);
if ($item instanceof Computer && $item->getFromDB($items_id)) {
return Plugin::getWebDir('example', true, false) . '/public/computer_icon.svg';
}
return null;
}