diff --git a/fields/field.constant.php b/fields/field.constant.php
index 7f35a685..d3ff3a57 100644
--- a/fields/field.constant.php
+++ b/fields/field.constant.php
@@ -24,7 +24,7 @@
@link http://www.glpi-project.org/
@since 2009
---------------------------------------------------------------------- */
-
+
global $GO_FIELDS;
$GO_FIELDS['id']['name'] = __("ID");
@@ -61,6 +61,9 @@
$GO_FIELDS['date_mod']['name'] = __("Last update");
$GO_FIELDS['date_mod']['input_type'] = 'datetime';
+$GO_FIELDS['date_creation']['name'] = __('Creation date');
+$GO_FIELDS['date_creation']['input_type'] = 'datetime';
+
$GO_FIELDS['url']['name'] = __("URL");
$GO_FIELDS['url']['field'] = 'url';
$GO_FIELDS['url']['input_type'] = 'text';
diff --git a/hook.php b/hook.php
index 7afd0e7e..2e32fca8 100644
--- a/hook.php
+++ b/hook.php
@@ -95,8 +95,8 @@ function plugin_genericobject_install() {
include_once(GLPI_ROOT."/plugins/genericobject/inc/object.class.php");
include_once(GLPI_ROOT."/plugins/genericobject/inc/type.class.php");
- $migration = new Migration('2.4.0');
-
+ $migration = new Migration('0.85+1.1');
+
foreach (
array(
'PluginGenericobjectField',
@@ -119,7 +119,7 @@ function plugin_genericobject_install() {
}
}
}
-
+
if (!is_dir(GENERICOBJECT_CLASS_PATH)) {
@ mkdir(GENERICOBJECT_CLASS_PATH, 0777, true)
or die("Can't create folder " . GENERICOBJECT_CLASS_PATH);
@@ -149,9 +149,9 @@ function plugin_genericobject_uninstall() {
foreach (
array(
- 'PluginGenericobjectType',
+ 'PluginGenericobjectType',
'PluginGenericobjectProfile',
- 'PluginGenericobjectField',
+ 'PluginGenericobjectField',
'PluginGenericobjectTypeFamily'
) as $itemtype
) {
@@ -198,4 +198,4 @@ function plugin_genericobject_MassiveActions($type) {
} else {
return array();
}
-}
\ No newline at end of file
+}
diff --git a/inc/autoload.php b/inc/autoload.php
index 399420ff..8b179577 100644
--- a/inc/autoload.php
+++ b/inc/autoload.php
@@ -72,4 +72,3 @@ public function register()
spl_autoload_register(array($this, 'autoload'));
}
}
-
diff --git a/inc/object.class.php b/inc/object.class.php
index 1cb676ad..0150a109 100644
--- a/inc/object.class.php
+++ b/inc/object.class.php
@@ -464,7 +464,6 @@ function showForm($id, $options=array(), $previsualisation = false) {
}
$this->fields['id'] = $id;
- $options['colspan'] = 4;
$this->initForm($id,$options);
$this->showFormHeader($options);
@@ -512,7 +511,7 @@ function showForm($id, $options=array(), $previsualisation = false) {
static function getFieldsToHide() {
return array('id', 'is_recursive', 'is_template', 'template_name', 'is_deleted',
- 'entities_id', 'notepad', 'date_mod');
+ 'entities_id', 'notepad', 'date_mod', 'date_creation');
}
@@ -746,9 +745,10 @@ function getSearchOptions() {
function getObjectSearchOptions($with_linkfield = false) {
global $DB, $GO_FIELDS, $GO_BLACKLIST_FIELDS;
- $datainjection_blacklisted = array('id', 'date_mod', 'entities_id');
+ $datainjection_blacklisted = array('id', 'date_mod', 'entities_id', 'date_creation');
$index_exceptions = array('name' => 1, 'id' => 2, 'comment' => 16, 'date_mod' => 19,
- 'entities_id' => 80, 'is_recursive' => 86, 'notepad' => 90);
+ 'entities_id' => 80, 'is_recursive' => 86, 'notepad' => 90,
+ 'date_creation' => 121);
$index = 3;
$options = array();
$options['common'] = __('Characteristics');
diff --git a/inc/type.class.php b/inc/type.class.php
index 9819f214..20f434be 100644
--- a/inc/type.class.php
+++ b/inc/type.class.php
@@ -212,15 +212,6 @@ function prepareInputForUpdate($input) {
if (isset ($input["is_active"]) && $input["is_active"]) {
self::registerOneType($this->fields['itemtype']);
}
-
- if (isset($input['use_plugin_geninventorynumber'])) {
- switch ($input['use_plugin_geninventorynumber']) {
- case 0:
-
- break;
- case 1:
- }
- }
return $input;
}
@@ -245,7 +236,7 @@ function pre_deleteItem() {
//Delete loans associated with this type
self::deleteUnicity($itemtype);
-
+
//Delete reservations with this tyoe
self::deleteReservations($itemtype);
self::deleteReservationItems($itemtype);
@@ -257,7 +248,7 @@ function pre_deleteItem() {
PluginGenericobjectProfile::deleteTypeFromProfile($itemtype);
self::deleteTicketAssignation($itemtype);
-
+
//Remove associations to simcards with this type
self::deleteSimcardAssignation($itemtype);
@@ -270,8 +261,8 @@ function pre_deleteItem() {
self::deleteItemtypeReferencesInGLPI($itemtype);
self::deleteItemTypeFilesAndClasses($name, $this->getTable(), $itemtype);
-
- self::deleteNotepad($itemtype);
+
+ //self::deleteNotepad($itemtype);
if (preg_match("/PluginGenericobject(.*)/", $itemtype, $results)) {
$newrightname = 'plugin_genericobject_'.strtolower($results[1]).'s';
@@ -363,6 +354,18 @@ function getSearchOptions() {
$sopt[20]['name'] = _n('Project', 'Projects', 2);
$sopt[20]['datatype'] = 'bool';
+ $sopt[21]['table'] = $this->getTable();
+ $sopt[21]['field'] = 'date_mod';
+ $sopt[21]['name'] = __('Last update');
+ $sopt[21]['datatype'] = 'datetime';
+ $sopt[21]['massiveaction'] = false;
+
+ $sopt[121]['table'] = $this->getTable();
+ $sopt[121]['field'] = 'date_creation';
+ $sopt[121]['name'] = __('Creation date');
+ $sopt[121]['datatype'] = 'datetime';
+ $sopt[121]['massiveaction'] = false;
+
return $sopt;
}
@@ -490,8 +493,8 @@ function showBehaviorForm($ID, $options=array()) {
"use_contracts" => _n("Contract", "Contracts", 2),
"use_documents" => _n("Document", "Documents", 2),
"use_loans" => _n("Reservation", "Reservations", 2),
- // Disable unicity feature; see #16
- // Related code : search for #16
+ // Disable unicity feature; see #16
+ // Related code : search for #16
// "use_unicity" => __("Fields unicity"),
"use_global_search" => __("Global search"),
"use_projects" => _n("Project", "Projects", 2),
@@ -516,27 +519,27 @@ function showBehaviorForm($ID, $options=array()) {
switch ($right) {
case 'use_deleted':
- Html::showCheckbox(array('name' => $right,
+ Html::showCheckbox(array('name' => $right,
'checked' => $this->canBeDeleted()));
break;
case 'use_recursivity':
- Html::showCheckbox(array('name' => $right, 'value' => $this->canBeRecursive(),
+ Html::showCheckbox(array('name' => $right, 'value' => $this->canBeRecursive(),
'checked' => $this->canBeRecursive()));
break;
case 'use_notes':
- Html::showCheckbox(array('name' => $right,
+ Html::showCheckbox(array('name' => $right,
'checked' => $this->canUseNotepad()));
break;
case 'use_template':
- Html::showCheckbox(array('name' => $right,
+ Html::showCheckbox(array('name' => $right,
'checked' => $this->canUseTemplate()));
break;
default :
- Html::showCheckbox(array('name' => $right,
+ Html::showCheckbox(array('name' => $right,
'checked' => $this->fields[$right]));
break;
}
@@ -565,7 +568,7 @@ function showBehaviorForm($ID, $options=array()) {
switch ($right) {
case 'use_plugin_datainjection' :
if ($plugin->isActivated('datainjection')) {
- Html::showCheckbox(array('name' => $right,
+ Html::showCheckbox(array('name' => $right,
'checked' => $this->fields[$right]));
} else {
echo Dropdown::EMPTY_VALUE;
@@ -575,7 +578,7 @@ function showBehaviorForm($ID, $options=array()) {
case 'use_plugin_pdf' :
if ($plugin->isActivated('pdf')) {
- Html::showCheckbox(array('name' => $right,
+ Html::showCheckbox(array('name' => $right,
'checked' => $this->fields[$right]));
} else {
echo Dropdown::EMPTY_VALUE;
@@ -585,7 +588,7 @@ function showBehaviorForm($ID, $options=array()) {
case 'use_plugin_order' :
if ($plugin->isActivated('order')) {
- Html::showCheckbox(array('name' => $right,
+ Html::showCheckbox(array('name' => $right,
'checked' => $this->fields[$right]));
} else {
echo Dropdown::EMPTY_VALUE;
@@ -595,7 +598,7 @@ function showBehaviorForm($ID, $options=array()) {
case 'use_plugin_uninstall' :
if ($plugin->isActivated('uninstall')) {
- Html::showCheckbox(array('name' => $right,
+ Html::showCheckbox(array('name' => $right,
'checked' => $this->fields[$right]));
} else {
echo Dropdown::EMPTY_VALUE;
@@ -605,7 +608,7 @@ function showBehaviorForm($ID, $options=array()) {
case 'use_plugin_simcard' :
if ($plugin->isActivated('simcard')) {
- Html::showCheckbox(array('name' => $right,
+ Html::showCheckbox(array('name' => $right,
'checked' => $this->fields[$right]));
} else {
echo Dropdown::EMPTY_VALUE;
@@ -732,7 +735,7 @@ static function addNewObject($name, $itemtype, $options = array()) {
if ($params['overwrite_locales']) {
//Add language file
- self::addLocales($name, $itemtype);
+ self::addLocales($name, $itemtype);
}
//Add file needed by datainjectin plugin
@@ -890,8 +893,11 @@ public static function addTable($itemtype) {
`name` VARCHAR( 255 ) collate utf8_unicode_ci NOT NULL DEFAULT '',
`comment` text COLLATE utf8_unicode_ci,
`notepad` text COLLATE utf8_unicode_ci,
- `date_mod` DATETIME NULL ,
- PRIMARY KEY ( `id` )
+ `date_mod` DATETIME DEFAULT NULL,
+ `date_creation` DATETIME DEFAULT NULL,
+ PRIMARY KEY ( `id` ),
+ KEY `date_mod` (`date_mod`),
+ KEY `date_creation` (`date_creation`)
) ENGINE = MYISAM COMMENT = '$itemtype' DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
@@ -913,10 +919,14 @@ public static function addItemsTable($itemtype) {
$query = "CREATE TABLE IF NOT EXISTS `".getTableForItemType($itemtype)."_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`items_id` int(11) NOT NULL DEFAULT '0' COMMENT 'RELATION to various table, according to itemtype (ID)',
+ `date_mod` DATETIME DEFAULT NULL,
+ `date_creation` DATETIME DEFAULT NULL,
`$fk` int(11) NOT NULL DEFAULT '0',
`itemtype` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `$fk` (`$fk`),
+ KEY `date_mod` (`date_mod`),
+ KEY `date_creation` (`date_creation`),
KEY `item` (`itemtype`,`items_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
@@ -1291,7 +1301,11 @@ public static function addDropdownTable($table, $options = array()) {
`id` int(11) NOT NULL auto_increment,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`comment` text collate utf8_unicode_ci,
+ `date_mod` DATETIME DEFAULT NULL,
+ `date_creation` DATETIME NOT NULL,
PRIMARY KEY (`id`),
+ KEY `date_mod` (`date_mod`),
+ KEY `date_creation` (`date_creation`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query);
@@ -1381,7 +1395,7 @@ public static function deleteTicketAssignation($itemtype) {
*/
public static function deleteSimcardAssignation($itemtype) {
global $DB;
-
+
$plugin = new Plugin();
if ($plugin->isActivated('simcard') && $plugin->isActivated('simcard')) {
$types = array('PluginSimcardSimcard_Item');
@@ -1457,7 +1471,7 @@ static function deleteNetworking($itemtype) {
$networkport->delete($port);
}
}
-
+
/**
* Delete reservations for an itemtype
* @param $itemtype
@@ -1465,17 +1479,17 @@ static function deleteNetworking($itemtype) {
*/
static function deleteReservations($itemtype) {
global $DB;
-
+
$reservation = new Reservation();
- $query = "DELETE FROM
- `glpi_reservations`
+ $query = "DELETE FROM
+ `glpi_reservations`
WHERE `reservationitems_id` in (
SELECT `id` from `glpi_reservationitems` WHERE `itemtype`='$itemtype'
)";
$DB->query($query);
}
-
- /**
+
+ /**
* Delete reservations for an itemtype
* @param $itemtype
* @return nothing
@@ -1788,7 +1802,7 @@ function canUsePluginSimcard() {
}
return $this->fields['use_plugin_simcard'];
}
-
+
function canUsePluginGeninventoryNumber() {
$plugin = new Plugin();
if (!$plugin->isInstalled("geninventorynumber")
@@ -1846,7 +1860,8 @@ static function install(Migration $migration) {
`is_active` tinyint(1) NOT NULL default '0',
`name` varchar(255) collate utf8_unicode_ci default NULL,
`comment` text NULL,
- `date_mod` datetime NOT NULL default '0000-00-00 00:00:00',
+ `date_mod` datetime DEFAULT NULL,
+ `date_creation` datetime DEFAULT NULL,
`use_global_search` tinyint(1) NOT NULL default '0',
`use_unicity` tinyint(1) NOT NULL default '0',
`use_history` tinyint(1) NOT NULL default '0',
@@ -1881,7 +1896,10 @@ static function install(Migration $migration) {
$migration->addField($table, "use_projects", "bool");
$migration->addField($table, "use_notepad", "bool");
$migration->addField($table, "comment", "text");
- $migration->addField($table, "date_mod", "datetime");
+ if (!$migration->addField($table, "date_mod", "datetime")) {
+ $migration->changeField($table, "date_mod", "date_mod", "datetime");
+ }
+ $migration->addField($table, "date_creation", "datetime");
$migration->addField($table, "linked_itemtypes", "text");
$migration->addField($table, "plugin_genericobject_typefamilies_id", "integer");
$migration->addField($table, "use_plugin_simcard", "bool");
@@ -1889,7 +1907,7 @@ static function install(Migration $migration) {
// Migrate notepad data
$allGenericObjectTypes = PluginGenericobjectType::getTypes(true);
-
+
$notepad = new Notepad();
foreach ($allGenericObjectTypes as $genericObjectType => $genericObjectData) {
$genericObjectTypeInstance = new $genericObjectType();
@@ -1916,7 +1934,7 @@ static function install(Migration $migration) {
$migration->dropField($genericObjectTypeInstance->getTable(), "notepad");
$migration->migrationOneTable($genericObjectTypeInstance->getTable());
}
-
+
//Displayprefs
$prefs = array(10 => 6, 9 => 5, 8 => 4, 7 => 3, 6 => 2, 2 => 1, 4 => 1, 11 => 7, 12 => 8,
14 => 10, 15 => 11);
diff --git a/inc/typefamily.class.php b/inc/typefamily.class.php
index b5b3a03c..2793c86c 100644
--- a/inc/typefamily.class.php
+++ b/inc/typefamily.class.php
@@ -45,7 +45,11 @@ static function install(Migration $migration) {
`id` INT( 11 ) NOT NULL AUTO_INCREMENT,
`name` varchar(255) collate utf8_unicode_ci default NULL,
`comment` text NULL,
- PRIMARY KEY ( `id` )
+ `date_mod` DATETIME DEFAULT NULL,
+ `date_creation` DATETIME DEFAULT NULL,
+ PRIMARY KEY (`id`),
+ KEY `date_mod` (`date_mod`),
+ KEY `date_creation` (`date_creation`)
) ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$DB->query($query) or die($DB->error());
}
@@ -64,18 +68,18 @@ static function uninstall() {
static function getFamilies() {
global $DB;
- $query = "SELECT f.id as id, f.name as name, t.itemtype as itemtype
- FROM glpi_plugin_genericobject_typefamilies as f
- LEFT JOIN glpi_plugin_genericobject_types AS t
- ON (f.id = t.plugin_genericobject_typefamilies_id)
- WHERE t.id IN (SELECT DISTINCT `id`
- FROM glpi_plugin_genericobject_types
+ $query = "SELECT f.id as id, f.name as name, t.itemtype as itemtype
+ FROM glpi_plugin_genericobject_typefamilies as f
+ LEFT JOIN glpi_plugin_genericobject_types AS t
+ ON (f.id = t.plugin_genericobject_typefamilies_id)
+ WHERE t.id IN (SELECT DISTINCT `id`
+ FROM glpi_plugin_genericobject_types
WHERE is_active=1)";
$families = array();
foreach($DB->request($query) as $fam) {
$itemtype = $fam['itemtype'];
if ($itemtype::canCreate()) {
- $families[$fam['id']] = $fam['name'];
+ $families[$fam['id']] = $fam['name'];
}
}
return $families;
@@ -83,8 +87,8 @@ static function getFamilies() {
static function getItemtypesByFamily($families_id) {
- return getAllDatasFromTable('glpi_plugin_genericobject_types',
- "plugin_genericobject_typefamilies_id='$families_id'
+ return getAllDatasFromTable('glpi_plugin_genericobject_types',
+ "plugin_genericobject_typefamilies_id='$families_id'
AND is_active='1'");
}
}
diff --git a/setup.php b/setup.php
index bcf85597..78097794 100644
--- a/setup.php
+++ b/setup.php
@@ -94,13 +94,12 @@ function plugin_init_genericobject() {
global $PLUGIN_HOOKS, $CFG_GLPI, $GO_BLACKLIST_FIELDS, $GO_FIELDS,
$GENERICOBJECT_PDF_TYPES, $GO_LINKED_TYPES, $GO_READONLY_FIELDS, $LOADED_PLUGINS;
-
-
$GO_READONLY_FIELDS = array ("is_helpdesk_visible", "comment");
$GO_BLACKLIST_FIELDS = array ("itemtype", "table", "is_deleted", "id", "entities_id",
- "is_recursive", "is_template", "notepad", "template_name", "date_mod", "name",
- "is_helpdesk_visible", "comment");
+ "is_recursive", "is_template", "notepad", "template_name",
+ "date_mod", "name", "is_helpdesk_visible", "comment",
+ "date_creation");
$GO_LINKED_TYPES = array ('Computer', 'Phone', 'Peripheral', 'Software', 'Monitor',
'Printer', 'NetworkEquipment');
@@ -109,16 +108,15 @@ function plugin_init_genericobject() {
$GENERICOBJECT_PDF_TYPES = array ();
$plugin = new Plugin();
- if ($plugin->isInstalled("genericobject")
- && $plugin->isActivated("genericobject")
+ if ($plugin->isInstalled("genericobject")
+ && $plugin->isActivated("genericobject")
&& isset($_SESSION['glpiactiveprofile'])) {
-// include_once(GLPI_ROOT.'/plugins/genericobject/inc/profile.class.php');
-// PluginGenericobjectProfile::reloadProfileRights();
+
$PLUGIN_HOOKS['change_profile']['genericobject'] = array(
'PluginGenericobjectProfile',
'changeProfile'
);
-
+
plugin_genericobject_includeCommonFields();
$PLUGIN_HOOKS['use_massive_action']['genericobject'] = 1;
@@ -168,7 +166,7 @@ function plugin_post_init_genericobject() {
// Get the name and the version of the plugin - Needed
function plugin_version_genericobject() {
return array ('name' => __("Objects management", "genericobject"),
- 'version' => '0.85-1.0',
+ 'version' => '0.85-1.1',
'author' => "Teclib' & siprossii",
'homepage' => 'https://github.com/teclib/genericobject',
'license' => 'GPLv2+',
@@ -230,4 +228,3 @@ function plugin_genericobject_haveRight($class,$right) {
return Session::haveRight($right_name, $right);
}
-