function showForm($ID, $options = array()) { $relation = new PluginRelationRelation(); $this->initForm($ID, $options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; //Nombre de la clase echo "<td>" . __('Nombre de la clase', 'Nombre de la clase') . ": </td><td>"; $relation->dropdownClase("classname", $this->fields["classname"]); echo "</td>"; //Clase con las que se relaciona echo "<td>" . __('Clase con la que se relaciona', 'Clase con la que se relaciona') . ": </td>"; echo "<td>"; $relation->dropdownClase("classlist", $this->fields["classlist"]); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; //Descripción echo "<td>" . __('Descripción', 'Descripción') . ": </td><td>"; Html::autocompletionTextField($this, "comment", array('size' => "15")); echo "</td>"; echo "</tr>"; $this->showFormButtons($options); return true; }
public static function relationGraphviz($id, $itemtype) { /* $graph = "digraph structs { size=\"8,5\" ". PluginRelationsRelation::mostrarArbol($itemtype,$id). "}"; */ $graph = "digraph structs {\n\t\t" . PluginRelationRelation::mostrarArbol($itemtype, $id) . "}"; return self::dotIt('dot', $graph, 'png'); }
function plugin_init_relation() { global $PLUGIN_HOOKS, $LANG, $CFG_GLPI, $GO_CLASS_RELATIONS; //CRI $PLUGIN_HOOKS['csrf_compliant']['relation'] = true; //CRI $GO_CLASS_RELATIONS = array('CommonDBConnexity', 'CommonDBRelation', 'PluginWebapplicationsWebapplication_Item', 'PluginAccountsAccount', 'PluginCertificatesCertificate', 'PluginServiciosServicio_Item', 'PluginMreportingCommon', 'PluginMreportingBaseclass', 'PluginMreportingHelpdesk', 'PluginMreportingHelpdeskplus', 'PluginMreportingInventory', 'PluginMreportingOther', 'PluginTalkTicket', 'PluginAccountsAccount_Item', 'PluginEscaladeConfig', 'CommonDropdown', 'CommonDevice', 'PluginOcsinventoryngDeviceBiosdata', 'Item_Devices', 'PluginOcsinventoryngItem_DeviceBiosdata', 'Profile', 'PluginGenericobjectProfile', 'CommonDBChild', 'ProfileRight', 'Search', 'Dropdown', 'CommonTreeDropdown', 'Entity', 'PluginWebapplicationsProfile', 'PluginServiciosProfile', 'PluginMreportingProfile', 'PluginTalkProfile', 'PluginTalkUserpref', 'PluginCertificatesProfile', 'PluginAccountsProfile', 'PluginReportsProfile', 'PluginOcsinventoryngProfile', 'PluginAdditionalalertsProfile', 'PluginMobileProfile', 'PluginDatabasesDatabase_Item', 'PluginRelationRelation', 'Computer', 'Monitor', 'PluginFormcreatorForm', 'Software', 'User', 'PluginWebapplicationsWebapplication', 'PluginServiciosServicio', 'PluginBehaviorsCommon', 'PluginBehaviorsTicket', 'PluginCustomfieldsField', 'PluginOcsinventoryngOcsServer', 'PluginGenericobjectType', 'PluginGenericobjectObject', 'PluginGenericobjectSingletonObjectField', 'PluginGenericobjectField', 'PluginAddressingPing_Equipment', 'PluginFinancialreportsDisposalItem', 'PluginRacksItemSpecification', 'ComputerModel', 'NetworkEquipmentModel', 'PeripheralModel', 'PluginRacksOtherModel', 'PluginDatabasesDatabase', 'PluginBondsBond', 'Preference', 'NetworkEquipment', 'NetworkPort', 'Peripheral', 'Printer', 'CartridgeItem', 'Cartridge', 'ConsumableItem', 'Consumable', 'Phone', 'PluginWebapplicationsMenu', 'PluginServiciosMenu', 'PluginCertificatesMenu', 'PluginRacksMenu', 'PluginRacksConfig', 'PluginRacksRackModel', 'PluginDatabasesMenu', 'PluginVehiculeVehicule', 'CommonITILObject', 'Ticket', 'TicketTemplate', 'CommonITILValidation', 'TicketValidation', 'Problem', 'Change', 'Planning', 'Stat', 'TicketRecurrent', 'PluginFormcreatorFormlist', 'PluginFormcreatorFormanswer', 'Budget', 'Supplier', 'Contact', 'Contract', 'Document', 'Project', 'ProjectTask', 'Reminder', 'RSSFeed', 'KnowbaseItem', 'ReservationItem', 'Log', 'Reservation', 'Report', 'MigrationCleaner', 'PluginMreportingDashboard', 'PluginMreportingConfig', 'PluginOcsinventoryngMenu', 'PluginOcsinventoryngConfig', 'PluginAddressingMenu', 'PluginAddressingAddressing', 'PluginDatainjectionMenu', 'PluginDatainjectionModel', 'PluginCustomfieldsConfig', 'AuthLDAP', 'Group', 'Rule', 'RuleCollection', 'RuleImportEntityCollection', 'RuleImportEntity', 'RuleImportComputerCollection', 'RuleImportComputer', 'RuleMailCollectorCollection', 'MailCollector', 'RuleRightCollection', 'RuleRight', 'RuleSoftwareCategoryCollection', 'RuleSoftwareCategory', 'RuleTicketCollection', 'RuleTicket', 'Transfer', 'RuleDictionnaryDropdown', 'RuleDictionnarySoftware', 'RuleDictionnaryPrinter', 'QueuedMail', 'Backup', 'Event', 'PluginAccountsMenu', 'PluginAccountsHash', 'PluginRenamerMenu', 'PluginWebapplicationsWebapplicationType', 'PluginWebapplicationsWebapplicationServerType', 'PluginWebapplicationsWebapplicationTechnic', 'PluginServiciosServicioType', 'PluginServiciosServicioServerType', 'PluginServiciosServicioTechnic', 'PluginServiciosOrientado', 'PluginServiciosEnsnivel', 'PluginServiciosCriticidad', 'PluginTagTag', 'PluginCertificatesCertificateType', 'PluginCertificatesCertificateState', 'PluginAccountsAccountType', 'PluginAccountsAccountState', 'PluginOcsinventoryngNetworkPortType', 'NetworkPortInstantiation', 'PluginOcsinventoryngNetworkPort', 'PluginDatabasesDatabaseType', 'PluginDatabasesDatabaseCategory', 'PluginDatabasesServerType', 'PluginDatabasesScriptType', 'Location', 'State', 'Manufacturer', 'Blacklist', 'BlacklistedMailContent', 'ITILCategory', 'TaskCategory', 'SolutionType', 'RequestType', 'SolutionTemplate', 'ProjectState', 'ProjectType', 'ProjectTaskType', 'ComputerType', 'NetworkEquipmentType', 'PrinterType', 'MonitorType', 'PeripheralType', 'PhoneType', 'SoftwareLicenseType', 'CartridgeItemType', 'ConsumableItemType', 'ContractType', 'ContactType', 'DeviceMemoryType', 'SupplierType', 'InterfaceType', 'DeviceCaseType', 'PhonePowerSupply', 'Filesystem', 'PrinterModel', 'MonitorModel', 'PhoneModel', 'VirtualMachineType', 'VirtualMachineSystem', 'VirtualMachineState', 'DocumentCategory', 'DocumentType', 'KnowbaseItemCategory', 'Calendar', 'Holiday', 'OperatingSystem', 'OperatingSystemVersion', 'OperatingSystemServicePack', 'AutoUpdateSystem', 'NetworkInterface', 'NetworkEquipmentFirmware', 'Netpoint', 'Domain', 'Network', 'Vlan', 'CommonImplicitTreeDropdown', 'IPNetwork', 'FQDN', 'WifiNetwork', 'FQDNLabel', 'NetworkName', 'SoftwareCategory', 'UserTitle', 'UserCategory', 'RuleRightParameter', 'Fieldblacklist', 'SsoVariable', 'PluginFormcreatorHeader', 'PluginFormcreatorCategory', 'PluginRacksRoomLocation', 'PluginRacksConnection', 'PluginRacksRackType', 'PluginRacksRackState', 'DeviceMotherboard', 'DeviceProcessor', 'DeviceMemory', 'DeviceHardDrive', 'DeviceNetworkCard', 'DeviceDrive', 'DeviceControl', 'DeviceGraphicCard', 'DeviceSoundCard', 'DevicePci', 'DeviceCase', 'DevicePowerSupply', 'Notification', 'SLA', 'Control', 'Crontask', 'Auth', 'AuthMail', 'Link', 'PluginCustomConfig', 'PluginCustomTab', 'PluginCustomDefaulttab', 'PluginAdditionalalertsMenu', 'PluginAdditionalalertsAdditionalalert', 'PluginWebservicesClient', 'PluginRelationConfig', 'Ajax', 'DisplayPreference', 'PluginMreportingPreference', 'InfoCom'); // Params : plugin name - string type - ID - Array of attributes Plugin::registerClass('PluginRelationProfile', array('addtabon' => array('Profile'))); Plugin::registerClass('PluginRelationRelation'); Plugin::registerClass('PluginRelationTyperelation'); Plugin::registerClass('PluginRelationRelationclase'); // Display a menu entry ? // plugin enabled if (class_exists('PluginRelationRelation')) { $PLUGIN_HOOKS['pre_item_purge']['relation'] = array('Profile' => array('PluginRelationProfile', 'cleanProfiles')); $PLUGIN_HOOKS['item_purge']['relation'] = array(); foreach (PluginRelationRelation::getTypes(true) as $type) { $PLUGIN_HOOKS['item_purge']['relation'][$type] = 'plugin_item_purge_anything'; } } //$PLUGIN_HOOKS['pre_item_purge']['relation'] = array('Profile' => array('PluginRelationProfile','cleanProfiles')); // Massive Action definition $PLUGIN_HOOKS['use_massive_action']['relation'] = 1; // Config page if (Session::haveRight('config', UPDATE)) { $PLUGIN_HOOKS['config_page']['relation'] = 'front/config.php'; } $PLUGIN_HOOKS['submenu_entry']['relation']['options']['typerelation'] = array('title' => __('Tipos relaciones', 'relation'), 'page' => '/plugins/relation/front/typerelation.php', 'links' => array('search' => '/plugins/relation/front/typerelation.php', 'add' => '/plugins/relation/front/typerelation.form.php')); $PLUGIN_HOOKS['submenu_entry']['relation']['options']['clase'] = array('title' => __('Clases', 'relation'), 'page' => '/plugins/relation/front/clase.php', 'links' => array('search' => '/plugins/relation/front/clase.php', 'add' => '/plugins/relation/front/clase.form.php')); $PLUGIN_HOOKS['submenu_entry']['relation']['options']['relationclase'] = array('title' => __('Relaciones clase', 'relation'), 'page' => '/plugins/relation/front/relationclase.form.php', 'links' => array('search' => '/plugins/relation/front/relationclase.php', 'add' => '/plugins/relation/front/relationclase.form.php')); //redirect appel http://localhost/glpi/index.php?redirect=plugin_example_2 (ID 2 du form) $PLUGIN_HOOKS['redirect_page']['relation'] = 'relation.form.php'; $PLUGIN_HOOKS['menu_toadd']['relation'] = array('config' => 'PluginRelationConfig'); $PLUGIN_HOOKS['add_css']['relation'] = array('dd.css'); $PLUGIN_HOOKS['add_javascript']['relation'] = array('jquery.dd.min.js'); $PLUGIN_HOOKS['post_init']['relation'] = 'plugin_relation_postinit'; //Iniciar los items de para registrar los tabs. }
public function showForm($ID, $options = array()) { global $CFG_GLPI; $this->initForm($ID, $options); $this->showFormHeader($options); $relation = new PluginRelationRelation(); echo "<tr class='tab_bg_1'>"; //Nombre de la clase en GLPI echo "<td>" . __('Nombre de la clase', 'Nombre de la clase') . ": </td><td>"; //Html::autocompletionTextField($this,"name",array('size' => "15")); $relation->dropdownType("name", $relation->getIdDropdown($this->fields["name"])); echo "</td>"; //Nombre a mostrar en los desplegables para la clase echo "<td>" . __('Nombre a mostrar para la clase', 'Nombre a mostrar para la clase') . ": </td>"; echo "<td>"; Html::autocompletionTextField($this, "viewname", array('size' => "15")); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; //Descripción echo "<td>" . __('Descripción', 'Descripción') . ": </td><td>"; Html::autocompletionTextField($this, "comment", array('size' => "15")); echo "</td>"; //Imagen echo "<td>" . __('Imagen', 'Imagen') . ": </td>"; echo "<td>"; //file //$rep = "../plugins/relation/pics/"; $rep = '../plugins/relation/pics/'; $dir = opendir($rep); echo "<select name=\"img\" id=\"img\">"; $sel = ""; while ($f = readdir($dir)) { if (is_file($rep . $f)) { if ($f == rtrim($this->fields["img"])) { $sel = "selected"; } else { $sel = ""; } echo "<option value='" . $f . "' data-image='" . $_SESSION["glpiroot"] . "/plugins/relation/pics/" . $f . "' " . $sel . ">" . $f . "</option>"; } } echo "</select> "; closedir($dir); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; //Nombre de la clase en GLPI echo "<td>" . __('Es visible', 'Es visible') . "</td><td>"; //Html::autocompletionTextField($this,"name",array('size' => "15")); Dropdown::showYesNo('is_visible', $this->fields['is_visible']); echo "</td>"; //Nombre a mostrar en los desplegables para la clase echo "<td></td>"; echo "<td></td>"; echo "</tr>"; $this->showFormButtons($options); Html::scriptStart(); echo "\$(document).ready(function(e){\n\t\t\ttry {\n\t\t\t\$('#img').msDropDown();\n\t\t\t} catch(e) {\n\t\t\talert(e.message);\n\t\t\t}\n\t\t\t});"; echo Html::scriptEnd(); return true; }
-------------------------------------------------------------------------- // ---------------------------------------------------------------------- // Original Author of file: CAILLAUD Xavier // Purpose of file: plugin Example v1.6.0 - GLPI 0.78 // ---------------------------------------------------------------------- */ include "../../../inc/includes.php"; if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["withtemplate"])) { $_GET["withtemplate"] = ""; } //echo realpath (dirname(__FILE__)); $tipoRelaciones = new PluginRelationClase(); $relation = new PluginRelationRelation(); /* if (isset($_POST['is_recursive'])) { $_POST['is_recursive'] = ($_POST['is_recursive'] ? 1 : 0); } */ $array = $relation->getListClaseHelpDesk(); if (isset($_POST["add"])) { $_POST['name'] = $relation->getNameDropdown($array, $_POST['name']); $newID = $tipoRelaciones->add($_POST); Html::redirect($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["delete"])) { $tipoRelaciones->delete($_POST); Html::redirect(Toolbox::getItemTypeSearchURL('PluginRelationClase')); } else {
-------------------------------------------------------------------------- // ---------------------------------------------------------------------- // Original Author of file: CAILLAUD Xavier // Purpose of file: plugin Example v1.6.0 - GLPI 0.78 // ---------------------------------------------------------------------- */ include "../../../inc/includes.php"; if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["withtemplate"])) { $_GET["withtemplate"] = ""; } //echo realpath (dirname(__FILE__)); $tipoRelaciones = new PluginRelationRelationclase(); $relation = new PluginRelationRelation(); $array = $relation->getListClaseHelpDesk(); if (isset($_POST["add"])) { if ($_POST["classname"] == "-1") { Session::addMessageAfterRedirect("Debe Seleccionar Clase Origen", true); } else { if ($_POST["classlist"] == "-1") { Session::addMessageAfterRedirect("Debe Seleccionar Clase con que se Relaciona", true); } else { $newID = $tipoRelaciones->add($_POST); } } Html::redirect($_SERVER['HTTP_REFERER']); } else { if (isset($_POST["delete"])) { $tipoRelaciones->delete($_POST);
} */ Session::checkCentralAccess(); // Make a select box if (isset($_POST['type_relations'])) { $rand = $_POST['rand']; $itemtype = $_POST['itemtype']; if (!class_exists($itemtype)) { $table = ""; } else { $objeto = new $itemtype(); $table = $objeto->getTable(); } //$use_ajax=$CFG_GLPI['use_ajax']; //echo $CFG_GLPI['use_ajax']; $tabletype = PluginRelationRelation::getNombreClaseRelacionada($_POST['type_relations']); /* switch ($tabletype){ case "Group" : $use_ajax=0; break; case "User" : $use_ajax=0; break; default: $use_ajax=$CFG_GLPI['use_ajax']; break; } */ //echo $tabletype."-".$use_ajax; //$params = array();
@package Plugin Relation @author David Durieux @co-author @copyright Copyright (c) 2009-2014 Relation plugin Development team @license AGPL License 3.0 or (at your option) any later version http://www.gnu.org/licenses/agpl-3.0-standalone.html @link https://forge.indepnet.net/projects/barscode @since 2009 ------------------------------------------------------------------------ */ include '../../../inc/includes.php'; if (!isset($_GET['id'])) { $_GET['id'] = ''; } $PluginRelation = new PluginRelationRelation(); if (isset($_POST['additem']) && isset($_POST['type']) && isset($_POST['items_id']) > 0) { if (Session::haveRight('plugin_relation', CREATE)) { if (PluginRelationRelation::isAncestor($_POST['items_id'], $_POST['id'], $_POST['type'])) { Session::addMessageAfterRedirect(__('Sorry. You cannot add an ancestor as a child!', 'Sorry. You cannot add an ancestor as a child!'), true); } else { PluginRelationRelation::addParent($_POST['id'], $_POST['items_id'], $_POST['itemtype'], $_POST['type'], $_POST['_nombresrelaciones']); // Logging here $child = PluginRelationRelation::getDeviceName($_POST['itemtype'], $_POST['items_id']); $parent = PluginRelationRelation::getDeviceName($_POST['type'], $_POST['id']); PluginRelationRelation::logChange($_POST['type'], $_POST['items_id'], $_POST['id'], $child, $parent, RELATIONS_LINK, $_POST['itemtype'], $_POST['_nombresrelaciones']); } } Html::redirect($_SERVER['HTTP_REFERER']); } else { if (isset($_GET['deleterelation'])) {
function plugin_relation_giveItem($type, $ID, $data, $num) { global $DB; $searchopt =& Search::getOptions($type); if (isset($searchopt[$ID]["itemlink_type"])) { $form = Toolbox::getItemTypeFormURL($searchopt[$ID]["itemlink_type"]); } $separator = "<br/>"; $dataraw = $data['raw']; $split = explode("\$\$\$\$", $dataraw['ITEM_' . $num]); $count = 0; $string = ""; //print_r($split); for ($i = 0; $i < count($split); $i++) { if (strlen(trim($split[$i])) > 0) { $item = explode("\$\$", $split[$i]); if (isset($item[0]) && isset($item[1]) && $item[1] > 0) { if ($count) { $string .= $separator; } $count++; if (!class_exists($item[0])) { continue; } $objeto = new $item[0](); if ($objeto->getFromDB($item[1])) { $nombre_objeto = $objeto->getNameID(); //if ( $objeto->canView() ) { $form = Toolbox::getItemTypeFormURL($item[0]); $string .= "<a id='PluginRelationRelation' href='"; $string .= $form . "?id=" . $item[1] . "'>"; switch ($ID) { case 2250: $string .= $nombre_objeto . "</a>" . " Clase: " . $item[0] . " Tipo Relacion: " . PluginRelationRelation::getNombreTiporelacion($item[2], 1); break; case 2251: $string .= $nombre_objeto . "</a>" . " Clase: " . $item[0] . " Tipo Relacion: " . PluginRelationRelation::getNombreTiporelacion($item[2], 0); break; } //} } unset($objeto); } } } return $string; }
public static function expandirarriba($id, $itemtype, $pivot, $oldpivot = 0) { $cadenaarriba = ""; $a = PluginRelationRelation::getParentsItem($itemtype, $id); $resulup = PluginRelationRelation::checkArrayExpande($_SESSION['glpi_expandearriba'], $id, $itemtype); if ($resulup == true) { $registroup = array('source' => $pivot, 'target' => $oldpivot, 'id' => $id, 'itemtype' => $itemtype); array_push($_SESSION['glpi_expandearriba'], $registroup); } $npivot = 0; $i = 1; /* sólo para efectos ilustrativos */ $struct = ""; $direction = ""; $ramas = ""; foreach ($a as $v) { //echo $v["id"]."/".$v["name"]."/".$v["name_relation"]."/".$v["itemtype"]; $rst = PluginRelationRelation::checkArrayExpande($_SESSION['glpi_expandearriba'], $v['id'], $v['itemtype']); if ($rst == true) { $struct .= "struct" . $pivot . $i . " [margin=0 shape=ellipse, style=filled, fillcolor=white, color=blue, label=<<TABLE border=\"0\" cellborder=\"0\">\n\t\t\t\t\t\t\t\t\t\t<TR><TD width=\"35\" height=\"25\" fixedsize=\"true\"><IMG SRC='" . PluginRelationRelation::getIconItem($v["itemtype"], $v["id"]) . "' scale=\"true\"/></TD><td><font face=\"Arial\" point-size=\"7\">" . $v["name"] . "</font></td></TR>\n\t\t\t\t\t\t\t\t\t\t<TR><TD colspan=\"2\" fixedsize=\"true\"><font face=\"Arial\" point-size=\"7\">" . PluginRelationRelation::getViewNameClass($v["itemtype"]) . "</font></TD></TR>\n\t\t\t\t\t\t\t </TABLE>>];\n\t\t\t\t\t\t\t\t"; $direction .= "struct" . $pivot . $i . " -> struct" . $pivot . " [ label = \"" . $v["name_relation"] . "\" penwidth = 1 fontname=Arial fontsize = 7 fontcolor = \"black\"];\n\t\t\t\t\t\t\t\t"; } else { $existe = PluginRelationRelation::checkUpExists($pivot); if ($existe == 1) { $recurpivot = PluginRelationRelation::getTargetStructUp($_SESSION['glpi_expandearriba'], $v['id'], $v['itemtype']); $direction .= "struct" . $recurpivot . " -> struct" . $pivot . " [ label = \"" . $v["name_relation"] . "\" penwidth = 1 fontname=Arial fontsize = 7 fontcolor = \"black\"];\n\t\t\t\t\t\t"; } } $npivot = $pivot . $i; $ramas .= PluginRelationRelation::expandirarriba($v["id"], $v["itemtype"], $npivot, $pivot); $i++; } $cadenaarriba = $struct . $direction . $ramas; return $cadenaarriba; }
// Direct access to file if (strpos($_SERVER['PHP_SELF'], "dropdownValue.php")) { $AJAX_INCLUDE = 1; include '../../../inc/includes.php'; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); } Session::checkCentralAccess(); // Make a select box with all glpi users //$type es el índice del elemento seleccionado en el desplegable de clase $type = $_POST['type_relations']; //echo "<input type='hidden' size='30' name='type2' value='".$type."'>"; $field_isdel = ""; $itemtype = $_POST['itemtype']; //Obtengo la clase seleccionada $tabletype = PluginRelationRelation::getNombreClaseRelacionada($type); switch ($tabletype) { case "Group": $field_isdel = "1=1 "; break; default: $field_isdel = "is_deleted = 0 "; break; } $where = " WHERE " . $field_isdel; //echo $tabletype; if (!class_exists($tabletype)) { $datatable = ""; } else { $objeto = new $tabletype(); $datatable = $objeto->getTable();