diff --git a/LISEZMOI.txt b/LISEZMOI.txt index 9e7824c..a200966 100755 --- a/LISEZMOI.txt +++ b/LISEZMOI.txt @@ -72,7 +72,7 @@ avec l'une des ressources techniques --- Dépendances (uniquement testé avec ces configurations) ************************************************************************************************************* -1) Apache 1.3.>6 avec PHP 4 ou PHP 5 +1) Apache 1.3.>6 avec PHP 5.3.0 2) MySQL 4.2 et supérieures 3) Javascript activé diff --git a/inc/child.class.php b/inc/child.class.php new file mode 100644 index 0000000..9c779fa --- /dev/null +++ b/inc/child.class.php @@ -0,0 +1,102 @@ +. + -------------------------------------------------------------------------- + */ + +// ---------------------------------------------------------------------- +// Original Author of file: +// Purpose of file: +// ---------------------------------------------------------------------- + +// Sample of class that inherit from CommonDBChild. The behaviour of CommonRelation is similar. +// The main evolution introduced by 0.84 version of GLPI is a stronger control and log of +// interactions. We suggest you to refer to the header of CommonDBConnexity class to see these +// enhancements. +// For CommonDBRelation, the variable are quiet equivalent, but they use _1 and _2 for each side +// parent +class PluginExampleChild extends CommonDBChild { + + // A child rely on an item. If $itemtype=='itemtype', then that is a variable item. + static public $itemtype = 'itemtype'; + static public $items_id = 'items_id'; + + + // With 0.84, you have to specify each right (create, view, update and delete), because + // CommonDBChild(s) and CommonDBRelation(s) mainly depend on the rights on the parent item + // All these methods rely on parent:can*. Two attributs are usefull : + // * $checkParentRights: define what to check regarding the parent : + // - CommonDBConnexity::DONT_CHECK_ITEM_RIGHTS don't eaven relly on parents rights + // - CommonDBConnexity::HAVE_VIEW_RIGHT_ON_ITEM view right on the item is enough + // - CommonDBConnexity::HAVE_SAME_RIGHT_ON_ITEM we must have at least update right + // on the item + // * $mustBeAttached: some CommonDBChild can be free, without any parent. + static function canCreate() { + + return (Session::haveRight('internet', 'w') + && parent::canCreate()); + } + + + static function canView() { + + return (Session::haveRight('internet', 'r') + && parent::canView()); + } + + + static function canUpdate() { + + return (Session::haveRight('internet', 'w') + && parent::canUpdate()); + } + + + static function canDelete() { + + return (Session::haveRight('internet', 'w') + && parent::canDelete()); + } + + + // By default, post_addItem, post_updateItem and post_deleteFromDB are defined. + // They define the history to add to the parents + // This method define the name to set inside the history of the parent. + // All these methods use $log_history_add, $log_history_update and $log_history_delete to + // define the level of log (Log::HISTORY_ADD_DEVICE, Log::HISTORY_UPDATE_DEVICE ...) + function getHistoryName_for_item($case) { + } + + // CommonDBChild also check if we can add or updatethe item regarding the new item + // ($input[static::$itemtype] and $input[static::$items_id]). + // But don't forget to call parent::prepareInputForAdd() + function prepareInputForAdd($input) { + // My preparation on $input + return parent::prepareInputForAdd($input); + } + +} +?> \ No newline at end of file