-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsetup.php
More file actions
executable file
·559 lines (515 loc) · 21.7 KB
/
setup.php
File metadata and controls
executable file
·559 lines (515 loc) · 21.7 KB
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
<?php
/*
-------------------------------------------------------------------------
Statecheck plugin for GLPI
Copyright (C) 2009-2018 by Eric Feron.
-------------------------------------------------------------------------
LICENSE
This file is part of Statecheck.
Statecheck 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.
Statecheck 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 Statecheck. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
define('PLUGIN_STATECHECK_VERSION', '2.4.7');
// Minimal GLPI version, inclusive
define('PLUGIN_STATECHECK_MIN_GLPI', '10.0.17');
// Maximum GLPI version, exclusive
define('PLUGIN_STATECHECK_MAX_GLPI', '11.0.99');
// Init the hooks of the plugins -Needed
function plugin_init_statecheck() {
global $PLUGIN_HOOKS, $DB;
$PLUGIN_HOOKS['csrf_compliant']['statecheck'] = true;
$PLUGIN_HOOKS['change_profile']['statecheck'] = ['PluginStatecheckProfile', 'initProfile'];
// $PLUGIN_HOOKS['assign_to_ticket']['statecheck'] = true;
// display a warning message, before item display on form : highlighted fields are controlled
$PLUGIN_HOOKS['pre_item_form']['statecheck'] = 'hook_pre_item_form';
// highlight controlled fields, after item display on form
$PLUGIN_HOOKS['post_item_form']['statecheck'] = 'hook_post_item_form';
//$PLUGIN_HOOKS['assign_to_ticket_dropdown']['statecheck'] = true;
//$PLUGIN_HOOKS['assign_to_ticket_itemtype']['statecheck'] = ['PluginStatecheckRule_Item'];
Plugin::registerClass('PluginStatecheckRule', [
// 'linkgroup_tech_types' => true,
// 'linkuser_tech_types' => true,
'notificationtemplates_types' => true,
'document_types' => true,
// 'ticket_types' => true,
'helpdesk_visible_types' => true//,
// 'addtabon' => 'Supplier'
]);
Plugin::registerClass('PluginStatecheckProfile',
['addtabon' => 'Profile']);
if ($DB->TableExists("glpi_plugin_statecheck_tables")) {
$query = "select * from glpi_plugin_statecheck_tables";
if ($result=$DB->doQuery($query)) {
$checkitems = [];
while ($data=$DB->fetchAssoc($result)) {
$itemtype = $data['class'];
if (substr($data['name'],0,12) == "glpi_plugin_") {
$type = substr($data['name'],12,strrpos($data['name'],"_")-12);
} else {
$type = substr($data['name'],5);
}
$checkitems[$itemtype] = 'plugin_pre_item_statecheck';
}
$PLUGIN_HOOKS['pre_item_update']['statecheck'] = $checkitems;
$PLUGIN_HOOKS['pre_item_add']['statecheck'] = $checkitems;
}
}
if (Session::getLoginUserID()) {
if (Session::haveRight("plugin_statecheck", READ)) {
$PLUGIN_HOOKS['menu_toadd']['statecheck'] = ['admin' => 'PluginStatecheckMenu'];
}
if (Session::haveRight("plugin_statecheck", UPDATE)) {
$PLUGIN_HOOKS['use_massive_action']['statecheck']=1;
}
if (class_exists('PluginStatecheckRule_Item')) { // only if plugin activated
$PLUGIN_HOOKS['plugin_datainjection_populate']['statecheck'] = 'plugin_datainjection_populate_statecheck';
}
// End init, when all types are registered
$PLUGIN_HOOKS['post_init']['statecheck'] = 'plugin_statecheck_postinit';
// Import from Data_Injection plugin
$PLUGIN_HOOKS['migratetypes']['statecheck'] = 'plugin_datainjection_migratetypes_statecheck';
}
}
// Get the name and the version of the plugin - Needed
function plugin_version_statecheck() {
return [
'name' => _n('Statecheck Rule', 'Statecheck Rules', 2, 'statecheck'),
'version' => PLUGIN_STATECHECK_VERSION,
'author' => "Eric Feron",
'license' => 'GPLv2+',
'homepage'=> 'https://github.com/ericferon/glpi-statecheck',
'requirements' => [
'glpi' => [
'min' => PLUGIN_STATECHECK_MIN_GLPI,
'max' => PLUGIN_STATECHECK_MAX_GLPI
]
]
];
}
// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_statecheck_check_prerequisites() {
return true;
}
// Uninstall process for plugin : need to return true if succeeded : may display messages or add to message after redirect
/*function plugin_statecheck_check_config() {
return true;
}
function plugin_datainjection_migratetypes_statecheck($types) {
$types[2400] = 'PluginStatecheckRule';
return $types;
}
*/
function hook_pre_item_form(array $params) {
global $DB, $_SERVER;
$plugin = new Plugin();
// check that the current form is listed for statecheck
if (isset($_SERVER['HTTP_REFERER'])) {
$start = strpos($_SERVER['HTTP_REFERER'],'/front') + 7;
$end = strpos($_SERVER['HTTP_REFERER'],'.',$start);
$frontname = substr($_SERVER['HTTP_REFERER'],$start,$end-$start);
if ($plugin->isInstalled('genericobject') && $plugin->isActivated('genericobject')) {
if($frontname == 'object') {
parse_str(parse_url($_SERVER['HTTP_REFERER'])['query'], $output);
$classname = $output['itemtype'];
if (isset($classname)) {
$frontname = $classname;
}
}
}
$dbu = new DbUtils();
if ($dbu->countElementsInTable('glpi_plugin_statecheck_tables', ['frontname' => $frontname])) {
// get current state (or 0 if new record)
$targetstates_id = 0;
$query = "SELECT `statetable` FROM `glpi_plugin_statecheck_tables` WHERE `frontname` = '$frontname'";
if ($resultstate=$DB->doQuery($query)) {
while ($datastate=$DB->fetchAssoc($resultstate)) {
$statefield = empty($datastate['statetable'])?'':substr($datastate['statetable'], 5).'_id';
}
}
if(!empty($statefield) && isset($params['item']) && isset($params['item']->fields) && !empty($params['item']->fields[$statefield]))
$targetstates_id = $params['item']->fields[$statefield];
$query = "SELECT `glpi_plugin_statecheck_tables`.`id`, `glpi_plugin_statecheck_rules`.`plugin_statecheck_tables_id`, `glpi_plugin_statecheck_rules`.`is_active_warn_popup` as isActiveWarnPopup FROM `glpi_plugin_statecheck_tables`, `glpi_plugin_statecheck_rules` WHERE `glpi_plugin_statecheck_tables`.`id` = `glpi_plugin_statecheck_rules`.`plugin_statecheck_tables_id` AND `glpi_plugin_statecheck_tables`.`frontname` = '".$frontname."' AND `glpi_plugin_statecheck_rules`.`plugin_statecheck_targetstates_id` = '$targetstates_id'";
if ($resultstate=$DB->doQuery($query)) {
$isActiveWarnPopup = FALSE;
while ($datastate=$DB->fetchAssoc($resultstate)) {
$isActiveWarnPopup = $isActiveWarnPopup || $datastate['isActiveWarnPopup'];
}
if ($isActiveWarnPopup) {
Session::addMessageAfterRedirect('<font color="red"><b>'.__('!! Highlighted fields are controlled !!').'</b></font>');
Html::displayMessageAfterRedirect();
}
}
}
}
}
function hook_post_item_form(array $params) {
global $DB, $_SERVER;
$plugin = new Plugin();
if ($params['item']->canCreate())
{
// check that the current form is listed for statecheck
if (isset($_SERVER['HTTP_REFERER'])) {
$start = strpos($_SERVER['HTTP_REFERER'],'/front') + 7;
$end = strpos($_SERVER['HTTP_REFERER'],'.',$start);
$frontname = substr($_SERVER['HTTP_REFERER'],$start,$end-$start);
$classname = get_class($params['item']);
if ($plugin->isInstalled('genericobject') && $plugin->isActivated('genericobject')) {
if ($frontname == 'object') {
$frontname = $classname;
}
}
$query = "select * from glpi_plugin_statecheck_tables where frontname = '".$frontname."'";
if ($result=$DB->doQuery($query)) {
if ($DB->fetchAssoc($result)) {
//$classname = get_class($params['item']);
$statecheckrule = new PluginStatecheckRule;
$statecheckrule->plugin_statecheck_renderfields($classname);
}
}
}
}
}
function plugin_pre_item_statecheck($item)
{
global $CFG_GLPI, $DB, $_SESSION;
$plugin = new Plugin();
// $table_id = 3;
$actioncheck = true;
// if (isset($item['id'])) $item_id = $item['id'];
if (!isset($_SERVER['HTTP_REFERER'])) return $item;
$start = strpos($_SERVER['HTTP_REFERER'],'/front') + 7;
$end = strpos($_SERVER['HTTP_REFERER'],'.',$start);//"glpi_plugin_dataflows_dataflows";
$frontname = substr($_SERVER['HTTP_REFERER'],$start,$end-$start);
if ($plugin->isInstalled('genericobject') && $plugin->isActivated('genericobject')) {
if($frontname == 'object') {
parse_str(parse_url($_SERVER['HTTP_REFERER'])['query'], $output);
$classname = $output['itemtype'];
if (isset($classname)) {
$frontname = $classname;
}
}
}
// retrieve the value of item's state
$targetstates_id = 0;
$querystate = "select statetable from glpi_plugin_statecheck_tables";
if ($resultstate=$DB->doQuery($querystate)) {
while ($datastate=$DB->fetchAssoc($resultstate)) {
$statefield = substr($datastate['statetable'],5)."_id";
if (is_array($item)) {
if (isset($item[$statefield])) {
$targetstates_id = $item[$statefield];
}
} else {
if (isset($item->input[$statefield])) {
$targetstates_id = $item->input[$statefield];
}
else if (isset($item->fields[$statefield]))
$targetstates_id = $item->fields[$statefield];
}
}
}
/* if ($targetstates_id == 0) {
return $item;
}
*/
// retrieve the rules that apply
$queryrule = "select glpi_plugin_statecheck_rules.id, glpi_plugin_statecheck_rules.name as rulename, glpi_plugin_statecheck_tables.id as tableid, glpi_plugin_statecheck_tables.name as tablename, glpi_plugin_statecheck_tables.class ".
"from glpi_plugin_statecheck_rules,glpi_plugin_statecheck_tables ".
"where glpi_plugin_statecheck_rules.plugin_statecheck_tables_id = glpi_plugin_statecheck_tables.id ".
"and frontname = '$frontname' ".
"and (plugin_statecheck_targetstates_id = $targetstates_id or plugin_statecheck_targetstates_id = 0)".
"and is_active = true";
if ($resultrule=$DB->doQuery($queryrule)) {
if (is_array($item)) {
$item['hookerror'] = false;
if (isset($item['hookmessage']))
unset($item['hookmessage']);
} else {
$item->hookerror = false;
if (isset($item->hookmessage))
unset($item->hookmessage);
}
$itemtype = "";
while ($datarule=$DB->fetchAssoc($resultrule)) {
$rules_id = $datarule['id'];
$rules_name = $datarule['rulename'];
$table_name = $datarule['tablename'];
$table_id = $datarule['tableid'];
$itemtype = $datarule['class'];
// for each rule, retrieve the pre-conditions to apply the rule
$criteriacheck = true;
$querycriteria = "select * from glpi_plugin_statecheck_rulecriterias ".
"where plugin_statecheck_rules_id = $rules_id ";
if ($resultcriteria=$DB->doQuery($querycriteria)) {
while ($datacriteria=$DB->fetchAssoc($resultcriteria)) {
switch ($datacriteria['condition']) {
case Rule::PATTERN_IS :
if (is_array($item)) {
$criteriacheck &= ($item[$datacriteria['criteria']]==$datacriteria['pattern']?true:false);
} else if (isset($item->input[$datacriteria['criteria']]))
{
$criteriacheck &= ($item->input[$datacriteria['criteria']]==$datacriteria['pattern']?true:false);
}
else
{
$criteriacheck &= ($item->fields[$datacriteria['criteria']]==$datacriteria['pattern']?true:false);
}
break 1;
case Rule::PATTERN_IS_NOT :
if (is_array($item)) {
$criteriacheck &= ($item[$datacriteria['criteria']]!=$datacriteria['pattern']?true:false);
} else if (isset($item->input[$datacriteria['criteria']]))
{
$criteriacheck &= ($item->input[$datacriteria['criteria']]!=$datacriteria['pattern']?true:false);
}
else
{
$criteriacheck &= ($item->fields[$datacriteria['criteria']]!=$datacriteria['pattern']?true:false);
}
break 1;
case Rule::PATTERN_CONTAIN :
break 1;
case Rule::PATTERN_NOT_CONTAIN :
break 1;
case Rule::PATTERN_BEGIN :
break 1;
case Rule::PATTERN_END :
break 1;
case Rule::REGEX_MATCH :
if (is_array($item)) {
$criteriacheck &= preg_match($datacriteria['pattern'],unclean_cross_side_scripting_deep($item[$datacriteria['criteria']]));
} else if (isset($item->input[$datacriteria['criteria']]))
{
$criteriacheck &= preg_match($datacriteria['pattern'],unclean_cross_side_scripting_deep($item->input[$datacriteria['criteria']]));
}
else
{
$criteriacheck &= preg_match($datacriteria['pattern'],unclean_cross_side_scripting_deep($item->fields[$datacriteria['criteria']]));
}
break 1;
case Rule::REGEX_NOT_MATCH :
if (is_array($item)) {
$criteriacheck &= (preg_match($datacriteria['pattern'],unclean_cross_side_scripting_deep($item[$datacriteria['criteria']]))?false:true);
} else if (isset($item->input[$datacriteria['criteria']]))
{
$criteriacheck &= (preg_match($datacriteria['pattern'],unclean_cross_side_scripting_deep($item->input[$datacriteria['criteria']]))?false:true);
}
else
{
$criteriacheck &= (preg_match($datacriteria['pattern'],unclean_cross_side_scripting_deep($item->fields[$datacriteria['criteria']]))?false:true);
}
break 1;
case Rule::PATTERN_EXISTS :
if (substr($datacriteria['criteria'],-3) == '_id') {
if (is_array($item)) {
$criteriacheck &= ($item[$datacriteria['criteria']]!=0?true:false);
} else if (isset($item->input[$datacriteria['criteria']]))
{
$criteriacheck &= ($item->input[$datacriteria['criteria']]!=0?true:false);
}
else
{
$criteriacheck &= ($item->fields[$datacriteria['criteria']]!=0?true:false);
}
} else {
if (is_array($item)) {
$criteriacheck &= ($item[$datacriteria['criteria']]!=""?true:false);
} else if (isset($item->input[$datacriteria['criteria']]))
{
$criteriacheck &= ($item->input[$datacriteria['criteria']]!=""?true:false);
}
else
{
$criteriacheck &= ($item->fields[$datacriteria['criteria']]!=""?true:false);
}
}
break 1;
case Rule::PATTERN_DOES_NOT_EXISTS :
if (substr($datacriteria['criteria'],-3) == '_id') {
if (is_array($item)) {
$criteriacheck &= ($item[$datacriteria['criteria']]==0?true:false);
} else if (isset($item->input[$datacriteria['criteria']]))
{
$criteriacheck &= ($item->input[$datacriteria['criteria']]==0?true:false);
}
else
{
$criteriacheck &= ($item->fields[$datacriteria['criteria']]==0?true:false);
}
} else {
if (is_array($item)) {
$criteriacheck &= ($item[$datacriteria['criteria']]==""?true:false);
} else if (isset($item->input[$datacriteria['criteria']]))
{
$criteriacheck &= ($item->input[$datacriteria['criteria']]==""?true:false);
}
else
{
$criteriacheck &= ($item->fields[$datacriteria['criteria']]==""?true:false);
}
}
break 1;
default:
break 1;
}
}
}
// if rule applies
if ($criteriacheck) {
// retrieve the fields to check on behalf of this rule and check the condition of the current field value
$queryaction = "select * from glpi_plugin_statecheck_ruleactions ".
"where plugin_statecheck_rules_id = $rules_id ";
if ($resultaction=$DB->doQuery($queryaction)) {
// get field name and label
$ruleaction = new PluginStatecheckRuleAction;
$fields = $ruleaction->getActionFields($table_id);
// check values against rules
while ($dataaction=$DB->fetchAssoc($resultaction)) {
if (substr($dataaction['field'],0,8) == 'session_') {
switch ($dataaction['field']) {
case "session_users_id":
$valuetocheck = $_SESSION['glpiID'];
$comparisonoperation = $dataaction['action_type'];
break 1;
case "session_groups_id":
$arraytocheck = [];
$arraytocheck = $_SESSION['glpigroups'];
$comparisonoperation = $dataaction['action_type']."inarray";
break 1;
}
$fieldtocheck = substr($dataaction['field'],8);
} else {
if (is_array($item)) {
$valuetocheck = $item[$dataaction['field']];
} else if (isset($item->input[$dataaction['field']]))
{
$valuetocheck = $item->input[$dataaction['field']];
}
else
{
$valuetocheck = $item->fields[$dataaction['field']];
}
$fieldtocheck = $dataaction['field'];
$comparisonoperation = $dataaction['action_type'];
}
switch ($comparisonoperation) {
case "isempty":
if (substr($dataaction['field'],-3) == '_id') {
$actioncheck = ($valuetocheck==0?true:false);
} else {
$actioncheck = ($valuetocheck==""?true:false);
}
break 1;
case "isnotempty":
if (substr($dataaction['field'],-3) == '_id') {
$actioncheck = ($valuetocheck!=0?true:false);
} else {
$actioncheck = ($valuetocheck!=""?true:false);
}
break 1;
case "is":
$actioncheck = ($valuetocheck==html_entity_decode($dataaction['value'])?true:false);
break 1;
case "isnot":
$actioncheck = ($valuetocheck!=html_entity_decode($dataaction['value'])?true:false);
break 1;
case "isinarray":
$actioncheck = in_array(html_entity_decode($dataaction['value']),$arraytocheck);
break 1;
case "isnotinarray":
$actioncheck = !in_array(html_entity_decode($dataaction['value']),$arraytocheck);
break 1;
case "regex_check":
$actioncheck = preg_match(html_entity_decode($dataaction['value']),$valuetocheck);
break 1;
default:
break 1;
}
if (!$actioncheck) {
if (is_array($item)) {
$item['hookerror'] = true;
if (substr($fieldtocheck,-3) == '_id') {
$ruleactions_value = trim(strip_tags(html_entity_decode(Dropdown::getDropdownName('glpi_'.substr($fieldtocheck,0,strlen($fieldtocheck)-3),$dataaction['value']))));
}
else {
$ruleactions_value = $dataaction['value'];
}
$ruleactions_label = $fields[$dataaction['field']]['name'];
if (isset($item['hookmessage'])) {
$item['hookmessage'] .= ";".__("Rule")." '$rules_name' ($rules_id) : ".__("Field")." '".$ruleactions_label."' ".__("is not compliant with the rule")." : ".$dataaction['action_type']." ".$ruleactions_value;
}
else {
$item['hookmessage'] = __("StateCheck Rules")." :;".__("Rule")." '$rules_name' ($rules_id) : ".__("Field")." '".$ruleactions_label."' ".__("is not compliant with the rule")." : ".$dataaction['action_type']." ".$ruleactions_value;
}
} else {
$item->hookerror = true;
if (substr($fieldtocheck,-3) == '_id') {
$ruleactions_value = strip_tags(html_entity_decode(Dropdown::getDropdownName('glpi_'.substr($fieldtocheck,0,strlen($fieldtocheck)-3),$dataaction['value'])));
}
else {
$ruleactions_value = $dataaction['value'];
}
$ruleactions_label = $fields[$dataaction['field']]['name'];
if (isset($item->hookmessage)) {
$item->hookmessage .= ";".__("Rule")." '$rules_name' ($rules_id) : ".__("Field")." '".$ruleactions_label."' ".__("is not compliant with the rule")." : ".$dataaction['action_type']." ".$ruleactions_value;
}
else {
$item->hookmessage = __("StateCheck Rules")." :;".__("Rule")." '$rules_name' ($rules_id) : ".__("Field")." '".$ruleactions_label."' ".__("is not compliant with the rule")." : ".$dataaction['action_type']." ".$ruleactions_value;
}
}
}
}
}
}
}
if (isset($CFG_GLPI["use_notifications"])) {
if (is_object($item)) {
if ($item->hookerror)
$eventtype = "_failure";
else
$eventtype = "_success";
$itemobj = new PluginStatecheckRule;
$itemobj->fields = $item->input;
$itemobj->hookerror = $item->hookerror;
// cast($item,get_class($itemobj));
NotificationEvent::raiseEvent($itemtype."_".$targetstates_id.$eventtype,$itemobj);
} else {
if ($item[hookerror])
$eventtype = "_failure";
else
$eventtype = "_success";
$itemobj = new PluginStatecheckRule;
$itemobj->fields = $item;
$itemobj->hookerror = $item['hookerror'];
if (!$actioncheck) $itemobj->hookmessage = $item['hookmessage'];
NotificationEvent::raiseEvent($itemtype."_".$targetstates_id.$eventtype,$itemobj);
}
}
if (is_array($item)) {
if($item['hookerror']) {
Session::addMessageAfterRedirect(str_replace(";","<br/>",$item['hookmessage'])."<br/><font color='red'>".__(" Record not inserted or updated")."</font>", false, ERROR);
$item['input'] = false; // do not insert or update
} else {
unset ($item['hookerror'],$item['hookmessage']);
}
} else {
if($item->hookerror) {
Session::addMessageAfterRedirect(str_replace(";","<br/>",$item->hookmessage)."<br/><font color='red'>".__(" Record not inserted or updated")."</font>", false, ERROR);
$item->input = false; // do not insert or update
} else {
unset ($item->hookerror,$item->hookmessage);
}
}
}
return $item;
}
?>