public function __construct() { $class = get_called_class(); $this->table = getTableForItemType($class); if (class_exists($class)) { $this->objecttype = PluginGenericobjectType::getInstance($class); } $this->dohistory = $this->canUseHistory(); if (preg_match("/PluginGenericobject(.*)/", $class, $results)) { self::$rightname = 'plugin_genericobject_' . strtolower($results[1]) . 's'; } if ($this->canUseNotepad()) { // For GLPI 0.85.x $this->usenotepadrights = true; // For GLPI 0.90.x $this->usenotepad = true; } }
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { if ($item->getType() == __CLASS__) { switch ($tabnum) { case 1: $item->showBehaviorForm($item->getID()); break; case 3: PluginGenericobjectField::showObjectFieldsForm($item->getID()); break; case 5: PluginGenericobjectObject::showPrevisualisationForm($item); break; case 6: PluginGenericobjectProfile::showForItemtype($item); break; case 7: $item->showLinkedTypesForm(); break; } } return true; }
@since 2009 ---------------------------------------------------------------------- */ include "../../../inc/includes.php"; if (!isset($_GET["id"])) { $_GET["id"] = ''; } $type = new PluginGenericobjectType(); $extraparams = array(); if (isset($_POST["select"]) && $_POST["select"] == "all") { $extraparams["selected"] = "checked"; } //Change fields order if (isset($_GET["action"])) { $type->getFromDB($_REQUEST["id"]); PluginGenericobjectType::registerOneType($type); PluginGenericobjectObject::changeFieldOrder($_GET["field"], $type->fields["itemtype"], $_GET["action"]); Html::back(); //Add a new itemtype } elseif (isset($_POST["add"])) { $new_id = $type->add($_POST); Html::redirect(Toolbox::getItemTypeFormURL('PluginGenericobjectType') . "?id={$new_id}"); //Update an existing itemtype } elseif (isset($_POST["update"])) { if (isset($_POST['itemtypes']) && is_array($_POST['itemtypes'])) { $_POST['linked_itemtypes'] = json_encode($_POST['itemtypes']); } $type->update($_POST); Html::back(); //Delete an itemtype } elseif (isset($_POST["purge"])) { $type->delete($_POST);
function showBehaviorForm($ID, $options=array()) { if ($ID > 0) { $this->check($ID, READ); } else { // Create item $this->check($ID, CREATE); $use_cache = false; $this->getEmpty(); } $this->fields['id'] = $ID; $right_name = PluginGenericobjectProfile::getProfileNameForItemtype( __CLASS__ ); $canedit = Session::haveRight($right_name, UPDATE); self::includeLocales($this->fields["name"]); self::includeConstants($this->fields["name"]); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . __("Internal identifier", "genericobject") . "</td>"; echo "<td>"; if (!$ID) { Html::autocompletionTextField($this, 'name', array('value' => $this->fields["name"])); } else { echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>"; echo $this->fields["name"]; } echo "</td>"; echo "<td class='middle right'>".__('Icon')."</td>"; echo "<td class='icon_preview'>".PluginGenericobjectObject::getMenuIcon($this->fields['itemtype'])."</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __("Label") . "</td>"; echo "<td>"; if ($ID) { $itemtype = $this->fields["itemtype"]; echo $itemtype::getTypeName(); } echo "</td>"; echo "<td rowspan='3' class='middle right'>".__("Comments")." : </td>"; echo "<td class='center middle' rowspan='3'><textarea cols='45' rows='4' name='comment' >".$this->fields["comment"]."</textarea></td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>".__("Active")."</td>"; echo "<td>"; if (!$ID) { echo __("No"); } else { Dropdown::showYesNo("is_active", $this->fields["is_active"]); } echo "</td></td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>".__("Family of type of objects",'genericobject')."</td>"; echo "<td>"; PluginGenericobjectTypeFamily::dropdown( array('value' => $this->fields["plugin_genericobject_typefamilies_id"])); echo "</td></td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td colspan='2'></td>"; echo "</tr>"; if (!$this->isNewID($ID)) { $canedit = $this->can($ID, CREATE); echo "<tr class='tab_bg_1'><th colspan='4'>"; echo __("Behaviour", "genericobject"); echo "</th></tr>"; $use = array ("use_recursivity" => __("Child entities"), "use_tickets" => __("Assistance"), "use_deleted" => __("Item in the dustbin"), "use_notes" => _n('Note', 'Notes', 2), "use_history" => __("Historical"), "use_template" => __("Templates"), "use_infocoms" => __("Financial and administratives information"), "use_contracts" => _n("Contract", "Contracts", 2), "use_documents" => _n("Document", "Documents", 2), "use_loans" => _n("Reservation", "Reservations", 2), "use_unicity" => __("Fields unicity"), "use_global_search" => __("Global search"), // "use_direct_connections" => __("Link to other objects", "genericobject"), "use_network_ports" => __("Network connections", "genericobject"), "use_plugin_datainjection" => __("injection file plugin", "genericobject"), // "use_plugin_pdf" => __("PDF plugin", "genericobject"), "use_plugin_order" => __("order plugin", "genericobject"), "use_plugin_uninstall" => __("item's uninstallation plugin", "genericobject")); $plugin = new Plugin(); $odd=0; foreach ($use as $right => $label) { if (!$odd) { echo "<tr class='tab_bg_2'>"; } echo "<td>" . _sx('button','Use') . " " . $label . "</td>"; echo "<td>"; switch ($right) { case 'use_deleted': Dropdown::showYesno('use_deleted', $this->canBeDeleted()); break; case 'use_recursivity': Dropdown::showYesno('use_recursivity', $this->canBeRecursive()); break; case 'use_notes': Dropdown::showYesno('use_notes', $this->canUseNotepad()); break; case 'use_template': Dropdown::showYesno('use_template', $this->canUseTemplate()); break; case 'use_plugin_datainjection' : if ($plugin->isActivated('datainjection')) { Dropdown::showYesNo($right, $this->fields[$right]); } else { echo Dropdown::EMPTY_VALUE; echo "<input type='hidden' name='use_plugin_datainjection' value='0'>\n"; } break; case 'use_plugin_pdf' : if ($plugin->isActivated('pdf')) { Dropdown::showYesNo($right, $this->fields[$right]); } else { echo Dropdown::EMPTY_VALUE; echo "<input type='hidden' name='use_plugin_pdf' value='0'>\n"; } break; case 'use_plugin_order' : if ($plugin->isActivated('order')) { Dropdown::showYesNo($right, $this->fields[$right]); } else { echo Dropdown::EMPTY_VALUE; echo "<input type='hidden' name='use_plugin_order' value='0'>\n"; } break; case 'use_plugin_uninstall' : if ($plugin->isActivated('uninstall')) { Dropdown::showYesNo($right, $this->fields[$right]); } else { echo Dropdown::EMPTY_VALUE; echo "<input type='hidden' name='use_plugin_uninstall' value='0'>\n"; } break; default : Dropdown::showYesNo($right, $this->fields[$right]); break; } echo "</td>"; if ($odd == 1) { $odd = 0; echo "</tr>"; } else { $odd++; } } if ($odd != 0) { echo "<td></td></tr>"; } } $this->showFormButtons($options); }