__('Cron description for example'), 'parameter' => __('Cron parameter for example')); } return array(); } /** * Execute 1 task manage by the plugin * * @param $task Object of CronTask class for log / stat * * @return interger * >0 : done * <0 : to be run again (not finished) * 0 : nothing to do */ static function cronSample($task) { $task->log("Example log message from class"); $task->setVolume(mt_rand(0,$task->fields['param'])); return 1; } // Hook done on before add item case (data from form, not altered) static function pre_item_add_computer(Computer $item) { Session::addMessageAfterRedirect("Pre Add Computer Hook", true); } // Hook done on before add item case (data altered by object prepareInputForAdd) static function post_prepareadd_computer(Computer$item) { Session::addMessageAfterRedirect("Post prepareAdd Computer Hook", true); } // Hook done on add item case static function item_add_computer(Computer$item) { Session::addMessageAfterRedirect("Add Computer Hook, ID=".$item->getID(), true); return true; } function getTabNameForItem(CommonGLPI $item, $withtemplate=0) { if (!$withtemplate) { switch ($item->getType()) { case 'Phone' : if ($_SESSION['glpishow_count_on_tabs']) { return self::createTabEntry(__('Example'), countElementsInTable($this->getTable())); } return __('Example'); } } return ''; } static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) { if ($item->getType()=='Phone') { echo "Plugin Example on Phone"; } return true; } static function getSpecificValueToDisplay($field, $values, array $options=array()) { if (!is_array($values)) { $values = array($field => $values); } switch ($field) { case 'serial' : return "S/N: ".$values[$field]; } return ''; } // Parm contains begin, end and who // Create data to be displayed in the planning of $parm["who"] or $parm["who_group"] between $parm["begin"] and $parm["end"] static function populatePlanning($parm) { // Add items in the output array // Items need to have an unique index beginning by the begin date of the item to display // needed to be correcly displayed $output = array(); $output[$parm["begin"]."$$$"."plugin_example1"]["plugin"] = "example"; $output[$parm["begin"]."$$$"."plugin_example1"]["begin"] = date("Y-m-d 17:00:00"); $output[$parm["begin"]."$$$"."plugin_example1"]["end"] = date("Y-m-d 18:00:00"); $output[$parm["begin"]."$$$"."plugin_example1"]["name"] = __("test planning example 1"); // Set the ID using the ID of the item in the database to have unique ID $ID = date("Ymd"); // Current date for example $output[$parm["begin"]."$$$"."plugin_example1"]["planningID"] = "plugin_example".$ID; return $output; } } ?>