@@ -212,15 +212,6 @@ function prepareInputForUpdate($input) {
212
212
if (isset ($ input ["is_active " ]) && $ input ["is_active " ]) {
213
213
self ::registerOneType ($ this ->fields ['itemtype ' ]);
214
214
}
215
-
216
- if (isset ($ input ['use_plugin_geninventorynumber ' ])) {
217
- switch ($ input ['use_plugin_geninventorynumber ' ]) {
218
- case 0 :
219
-
220
- break ;
221
- case 1 :
222
- }
223
- }
224
215
return $ input ;
225
216
}
226
217
@@ -245,7 +236,7 @@ function pre_deleteItem() {
245
236
246
237
//Delete loans associated with this type
247
238
self ::deleteUnicity ($ itemtype );
248
-
239
+
249
240
//Delete reservations with this tyoe
250
241
self ::deleteReservations ($ itemtype );
251
242
self ::deleteReservationItems ($ itemtype );
@@ -257,7 +248,7 @@ function pre_deleteItem() {
257
248
PluginGenericobjectProfile::deleteTypeFromProfile ($ itemtype );
258
249
259
250
self ::deleteTicketAssignation ($ itemtype );
260
-
251
+
261
252
//Remove associations to simcards with this type
262
253
self ::deleteSimcardAssignation ($ itemtype );
263
254
@@ -270,8 +261,8 @@ function pre_deleteItem() {
270
261
self ::deleteItemtypeReferencesInGLPI ($ itemtype );
271
262
272
263
self ::deleteItemTypeFilesAndClasses ($ name , $ this ->getTable (), $ itemtype );
273
-
274
- self ::deleteNotepad ($ itemtype );
264
+
265
+ // self::deleteNotepad($itemtype);
275
266
276
267
if (preg_match ("/PluginGenericobject(.*)/ " , $ itemtype , $ results )) {
277
268
$ newrightname = 'plugin_genericobject_ ' .strtolower ($ results [1 ]).'s ' ;
@@ -363,6 +354,18 @@ function getSearchOptions() {
363
354
$ sopt [20 ]['name ' ] = _n ('Project ' , 'Projects ' , 2 );
364
355
$ sopt [20 ]['datatype ' ] = 'bool ' ;
365
356
357
+ $ sopt [21 ]['table ' ] = $ this ->getTable ();
358
+ $ sopt [21 ]['field ' ] = 'date_mod ' ;
359
+ $ sopt [21 ]['name ' ] = __ ('Last update ' );
360
+ $ sopt [21 ]['datatype ' ] = 'datetime ' ;
361
+ $ sopt [21 ]['massiveaction ' ] = false ;
362
+
363
+ $ sopt [121 ]['table ' ] = $ this ->getTable ();
364
+ $ sopt [121 ]['field ' ] = 'date_creation ' ;
365
+ $ sopt [121 ]['name ' ] = __ ('Creation date ' );
366
+ $ sopt [121 ]['datatype ' ] = 'datetime ' ;
367
+ $ sopt [121 ]['massiveaction ' ] = false ;
368
+
366
369
return $ sopt ;
367
370
}
368
371
@@ -490,8 +493,8 @@ function showBehaviorForm($ID, $options=array()) {
490
493
"use_contracts " => _n ("Contract " , "Contracts " , 2 ),
491
494
"use_documents " => _n ("Document " , "Documents " , 2 ),
492
495
"use_loans " => _n ("Reservation " , "Reservations " , 2 ),
493
- // Disable unicity feature; see #16
494
- // Related code : search for #16
496
+ // Disable unicity feature; see #16
497
+ // Related code : search for #16
495
498
// "use_unicity" => __("Fields unicity"),
496
499
"use_global_search " => __ ("Global search " ),
497
500
"use_projects " => _n ("Project " , "Projects " , 2 ),
@@ -516,27 +519,27 @@ function showBehaviorForm($ID, $options=array()) {
516
519
517
520
switch ($ right ) {
518
521
case 'use_deleted ' :
519
- Html::showCheckbox (array ('name ' => $ right ,
522
+ Html::showCheckbox (array ('name ' => $ right ,
520
523
'checked ' => $ this ->canBeDeleted ()));
521
524
break ;
522
525
523
526
case 'use_recursivity ' :
524
- Html::showCheckbox (array ('name ' => $ right , 'value ' => $ this ->canBeRecursive (),
527
+ Html::showCheckbox (array ('name ' => $ right , 'value ' => $ this ->canBeRecursive (),
525
528
'checked ' => $ this ->canBeRecursive ()));
526
529
break ;
527
530
528
531
case 'use_notes ' :
529
- Html::showCheckbox (array ('name ' => $ right ,
532
+ Html::showCheckbox (array ('name ' => $ right ,
530
533
'checked ' => $ this ->canUseNotepad ()));
531
534
break ;
532
535
533
536
case 'use_template ' :
534
- Html::showCheckbox (array ('name ' => $ right ,
537
+ Html::showCheckbox (array ('name ' => $ right ,
535
538
'checked ' => $ this ->canUseTemplate ()));
536
539
break ;
537
540
538
541
default :
539
- Html::showCheckbox (array ('name ' => $ right ,
542
+ Html::showCheckbox (array ('name ' => $ right ,
540
543
'checked ' => $ this ->fields [$ right ]));
541
544
break ;
542
545
}
@@ -565,7 +568,7 @@ function showBehaviorForm($ID, $options=array()) {
565
568
switch ($ right ) {
566
569
case 'use_plugin_datainjection ' :
567
570
if ($ plugin ->isActivated ('datainjection ' )) {
568
- Html::showCheckbox (array ('name ' => $ right ,
571
+ Html::showCheckbox (array ('name ' => $ right ,
569
572
'checked ' => $ this ->fields [$ right ]));
570
573
} else {
571
574
echo Dropdown::EMPTY_VALUE ;
@@ -575,7 +578,7 @@ function showBehaviorForm($ID, $options=array()) {
575
578
576
579
case 'use_plugin_pdf ' :
577
580
if ($ plugin ->isActivated ('pdf ' )) {
578
- Html::showCheckbox (array ('name ' => $ right ,
581
+ Html::showCheckbox (array ('name ' => $ right ,
579
582
'checked ' => $ this ->fields [$ right ]));
580
583
} else {
581
584
echo Dropdown::EMPTY_VALUE ;
@@ -585,7 +588,7 @@ function showBehaviorForm($ID, $options=array()) {
585
588
586
589
case 'use_plugin_order ' :
587
590
if ($ plugin ->isActivated ('order ' )) {
588
- Html::showCheckbox (array ('name ' => $ right ,
591
+ Html::showCheckbox (array ('name ' => $ right ,
589
592
'checked ' => $ this ->fields [$ right ]));
590
593
} else {
591
594
echo Dropdown::EMPTY_VALUE ;
@@ -595,7 +598,7 @@ function showBehaviorForm($ID, $options=array()) {
595
598
596
599
case 'use_plugin_uninstall ' :
597
600
if ($ plugin ->isActivated ('uninstall ' )) {
598
- Html::showCheckbox (array ('name ' => $ right ,
601
+ Html::showCheckbox (array ('name ' => $ right ,
599
602
'checked ' => $ this ->fields [$ right ]));
600
603
} else {
601
604
echo Dropdown::EMPTY_VALUE ;
@@ -605,7 +608,7 @@ function showBehaviorForm($ID, $options=array()) {
605
608
606
609
case 'use_plugin_simcard ' :
607
610
if ($ plugin ->isActivated ('simcard ' )) {
608
- Html::showCheckbox (array ('name ' => $ right ,
611
+ Html::showCheckbox (array ('name ' => $ right ,
609
612
'checked ' => $ this ->fields [$ right ]));
610
613
} else {
611
614
echo Dropdown::EMPTY_VALUE ;
@@ -732,7 +735,7 @@ static function addNewObject($name, $itemtype, $options = array()) {
732
735
733
736
if ($ params ['overwrite_locales ' ]) {
734
737
//Add language file
735
- self ::addLocales ($ name , $ itemtype );
738
+ self ::addLocales ($ name , $ itemtype );
736
739
}
737
740
738
741
//Add file needed by datainjectin plugin
@@ -890,8 +893,11 @@ public static function addTable($itemtype) {
890
893
`name` VARCHAR( 255 ) collate utf8_unicode_ci NOT NULL DEFAULT '',
891
894
`comment` text COLLATE utf8_unicode_ci,
892
895
`notepad` text COLLATE utf8_unicode_ci,
893
- `date_mod` DATETIME NULL ,
894
- PRIMARY KEY ( `id` )
896
+ `date_mod` DATETIME DEFAULT NULL,
897
+ `date_creation` DATETIME DEFAULT NULL,
898
+ PRIMARY KEY ( `id` ),
899
+ KEY `date_mod` (`date_mod`),
900
+ KEY `date_creation` (`date_creation`)
895
901
) ENGINE = MYISAM COMMENT = ' $ itemtype' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; " ;
896
902
$ DB ->query ($ query );
897
903
@@ -913,10 +919,14 @@ public static function addItemsTable($itemtype) {
913
919
$ query = "CREATE TABLE IF NOT EXISTS ` " .getTableForItemType ($ itemtype )."_items` (
914
920
`id` int(11) NOT NULL AUTO_INCREMENT,
915
921
`items_id` int(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to various table, according to itemtype (ID)',
922
+ `date_mod` DATETIME DEFAULT NULL,
923
+ `date_creation` DATETIME DEFAULT NULL,
916
924
` $ fk` int(11) NOT NULL DEFAULT '0',
917
925
`itemtype` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
918
926
PRIMARY KEY (`id`),
919
927
KEY ` $ fk` (` $ fk`),
928
+ KEY `date_mod` (`date_mod`),
929
+ KEY `date_creation` (`date_creation`),
920
930
KEY `item` (`itemtype`,`items_id`)
921
931
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; " ;
922
932
$ DB ->query ($ query );
@@ -1291,7 +1301,11 @@ public static function addDropdownTable($table, $options = array()) {
1291
1301
`id` int(11) NOT NULL auto_increment,
1292
1302
`name` varchar(255) collate utf8_unicode_ci default NULL,
1293
1303
`comment` text collate utf8_unicode_ci,
1304
+ `date_mod` DATETIME DEFAULT NULL,
1305
+ `date_creation` DATETIME NOT NULL,
1294
1306
PRIMARY KEY (`id`),
1307
+ KEY `date_mod` (`date_mod`),
1308
+ KEY `date_creation` (`date_creation`),
1295
1309
KEY `name` (`name`)
1296
1310
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; " ;
1297
1311
$ DB ->query ($ query );
@@ -1381,7 +1395,7 @@ public static function deleteTicketAssignation($itemtype) {
1381
1395
*/
1382
1396
public static function deleteSimcardAssignation ($ itemtype ) {
1383
1397
global $ DB ;
1384
-
1398
+
1385
1399
$ plugin = new Plugin ();
1386
1400
if ($ plugin ->isActivated ('simcard ' ) && $ plugin ->isActivated ('simcard ' )) {
1387
1401
$ types = array ('PluginSimcardSimcard_Item ' );
@@ -1457,25 +1471,25 @@ static function deleteNetworking($itemtype) {
1457
1471
$ networkport ->delete ($ port );
1458
1472
}
1459
1473
}
1460
-
1474
+
1461
1475
/**
1462
1476
* Delete reservations for an itemtype
1463
1477
* @param $itemtype
1464
1478
* @return nothing
1465
1479
*/
1466
1480
static function deleteReservations ($ itemtype ) {
1467
1481
global $ DB ;
1468
-
1482
+
1469
1483
$ reservation = new Reservation ();
1470
- $ query = "DELETE FROM
1471
- `glpi_reservations`
1484
+ $ query = "DELETE FROM
1485
+ `glpi_reservations`
1472
1486
WHERE `reservationitems_id` in (
1473
1487
SELECT `id` from `glpi_reservationitems` WHERE `itemtype`=' $ itemtype'
1474
1488
) " ;
1475
1489
$ DB ->query ($ query );
1476
1490
}
1477
-
1478
- /**
1491
+
1492
+ /**
1479
1493
* Delete reservations for an itemtype
1480
1494
* @param $itemtype
1481
1495
* @return nothing
@@ -1788,7 +1802,7 @@ function canUsePluginSimcard() {
1788
1802
}
1789
1803
return $ this ->fields ['use_plugin_simcard ' ];
1790
1804
}
1791
-
1805
+
1792
1806
function canUsePluginGeninventoryNumber () {
1793
1807
$ plugin = new Plugin ();
1794
1808
if (!$ plugin ->isInstalled ("geninventorynumber " )
@@ -1846,7 +1860,8 @@ static function install(Migration $migration) {
1846
1860
`is_active` tinyint(1) NOT NULL default '0',
1847
1861
`name` varchar(255) collate utf8_unicode_ci default NULL,
1848
1862
`comment` text NULL,
1849
- `date_mod` datetime NOT NULL default '0000-00-00 00:00:00',
1863
+ `date_mod` datetime DEFAULT NULL,
1864
+ `date_creation` datetime DEFAULT NULL,
1850
1865
`use_global_search` tinyint(1) NOT NULL default '0',
1851
1866
`use_unicity` tinyint(1) NOT NULL default '0',
1852
1867
`use_history` tinyint(1) NOT NULL default '0',
@@ -1881,15 +1896,18 @@ static function install(Migration $migration) {
1881
1896
$ migration ->addField ($ table , "use_projects " , "bool " );
1882
1897
$ migration ->addField ($ table , "use_notepad " , "bool " );
1883
1898
$ migration ->addField ($ table , "comment " , "text " );
1884
- $ migration ->addField ($ table , "date_mod " , "datetime " );
1899
+ if (!$ migration ->addField ($ table , "date_mod " , "datetime " )) {
1900
+ $ migration ->changeField ($ table , "date_mod " , "date_mod " , "datetime " );
1901
+ }
1902
+ $ migration ->addField ($ table , "date_creation " , "datetime " );
1885
1903
$ migration ->addField ($ table , "linked_itemtypes " , "text " );
1886
1904
$ migration ->addField ($ table , "plugin_genericobject_typefamilies_id " , "integer " );
1887
1905
$ migration ->addField ($ table , "use_plugin_simcard " , "bool " );
1888
1906
$ migration ->migrationOneTable ($ table );
1889
1907
1890
1908
// Migrate notepad data
1891
1909
$ allGenericObjectTypes = PluginGenericobjectType::getTypes (true );
1892
-
1910
+
1893
1911
$ notepad = new Notepad ();
1894
1912
foreach ($ allGenericObjectTypes as $ genericObjectType => $ genericObjectData ) {
1895
1913
$ genericObjectTypeInstance = new $ genericObjectType ();
@@ -1916,7 +1934,7 @@ static function install(Migration $migration) {
1916
1934
$ migration ->dropField ($ genericObjectTypeInstance ->getTable (), "notepad " );
1917
1935
$ migration ->migrationOneTable ($ genericObjectTypeInstance ->getTable ());
1918
1936
}
1919
-
1937
+
1920
1938
//Displayprefs
1921
1939
$ prefs = array (10 => 6 , 9 => 5 , 8 => 4 , 7 => 3 , 6 => 2 , 2 => 1 , 4 => 1 , 11 => 7 , 12 => 8 ,
1922
1940
14 => 10 , 15 => 11 );
0 commit comments