function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if ($item->getType() == 'Profile') { return PluginCertificatesCertificate::getTypeName(2); } return ''; }
function plugin_init_certificates() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['certificates'] = true; $PLUGIN_HOOKS['change_profile']['certificates'] = array('PluginCertificatesProfile', 'changeProfile'); $PLUGIN_HOOKS['assign_to_ticket']['certificates'] = true; if (Session::getLoginUserID()) { // Params : plugin name - string type - number - attributes Plugin::registerClass('PluginCertificatesCertificate', array('linkgroup_tech_types' => true, 'linkuser_tech_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'contract_types' => true, 'notificationtemplates_types' => true)); Plugin::registerClass('PluginCertificatesConfig', array('addtabon' => 'CronTask')); Plugin::registerClass('PluginCertificatesProfile', array('addtabon' => 'Profile')); if (class_exists('PluginAccountsAccount')) { PluginAccountsAccount::registerType('PluginCertificatesCertificate'); } if (isset($_SESSION["glpi_plugin_environment_installed"]) && $_SESSION["glpi_plugin_environment_installed"] == 1) { $_SESSION["glpi_plugin_environment_certificates"] = 1; // Display a menu entry ? if (plugin_certificates_haveRight("certificates", "r")) { $PLUGIN_HOOKS['submenu_entry']['environment']['options']['certificates']['title'] = PluginCertificatesCertificate::getTypeName(2); $PLUGIN_HOOKS['submenu_entry']['environment']['options']['certificates']['page'] = '/plugins/certificates/front/certificate.php'; $PLUGIN_HOOKS['submenu_entry']['environment']['options']['certificates']['links']['search'] = '/plugins/certificates/front/certificate.php'; } if (plugin_certificates_haveRight("certificates", "w")) { $PLUGIN_HOOKS['submenu_entry']['environment']['options']['certificates']['links']['add'] = '/plugins/certificates/front/certificate.form.php'; $PLUGIN_HOOKS['use_massive_action']['certificates'] = 1; } } else { // Display a menu entry ? if (plugin_certificates_haveRight("certificates", "r")) { $PLUGIN_HOOKS['menu_entry']['certificates'] = 'front/certificate.php'; $PLUGIN_HOOKS['submenu_entry']['certificates']['search'] = 'front/certificate.php'; } if (plugin_certificates_haveRight("certificates", "w")) { $PLUGIN_HOOKS['submenu_entry']['certificates']['add'] = 'front/certificate.form.php?new=1'; $PLUGIN_HOOKS['use_massive_action']['certificates'] = 1; } } if (class_exists('PluginCertificatesCertificate_Item')) { // only if plugin activated $PLUGIN_HOOKS['pre_item_purge']['certificates'] = array('Profile' => array('PluginCertificatesProfile', 'purgeProfiles')); } // End init, when all types are registered $PLUGIN_HOOKS['post_init']['certificates'] = 'plugin_certificates_postinit'; } }
This file is part of certificates. Certificates is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Certificates is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Certificates. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $plugin = new Plugin(); if ($plugin->isActivated("environment")) { Html::header(PluginCertificatesCertificate::getTypeName(2), '', "plugins", "environment", "certificates"); } else { Html::header(PluginCertificatesCertificate::getTypeName(2), '', "plugins", "certificates"); } $certif = new PluginCertificatesCertificate(); if ($certif->canView() || Session::haveRight("config", "w")) { Search::show("PluginCertificatesCertificate"); } else { Html::displayRightError(); } Html::footer();
function plugin_certificates_getAddSearchOptions($itemtype) { $sopt=array(); if (in_array($itemtype,PluginCertificatesCertificate::getTypes(true))) { if (Session::haveRight("plugin_certificates", READ)) { $sopt[1710]['table']='glpi_plugin_certificates_certificates'; $sopt[1710]['field']='name'; $sopt[1710]['name']= PluginCertificatesCertificate::getTypeName(2) ." - ".__('Name'); $sopt[1710]['forcegroupby']='1'; $sopt[1710]['datatype']='itemlink'; $sopt[1710]['massiveaction'] = false; $sopt[1710]['itemlink_type']='PluginCertificatesCertificate'; $sopt[1710]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_certificates_certificates_items', 'joinparams' => array('jointype' => 'itemtype_item'))); $sopt[1711]['table']='glpi_plugin_certificates_certificatetypes'; $sopt[1711]['field']='name'; $sopt[1711]['name']= PluginCertificatesCertificate::getTypeName(2)." - ".__('Type'); $sopt[1711]['forcegroupby']=true; $sopt[1711]['joinparams'] = array('beforejoin' => array( array('table' => 'glpi_plugin_certificates_certificates', 'joinparams' => $sopt[1710]['joinparams']))); $sopt[1711]['datatype'] = 'dropdown'; $sopt[1711]['massiveaction'] = false; } } return $sopt; }
/** * Show items links to a certificate * * @since version 0.84 * * @param $certificate PluginCertificatesCertificate object * * @return nothing (HTML display) **/ public static function showForCertificate(PluginCertificatesCertificate $certificate) { global $DB,$CFG_GLPI; // $certif=new PluginCertificatesCertificate(); $instID = $certificate->fields['id']; if (!$certificate->can($instID, READ)){ return false; } $canedit=$certificate->can($instID, UPDATE); $rand=mt_rand(); $query = "SELECT DISTINCT `itemtype` FROM `glpi_plugin_certificates_certificates_items` WHERE `plugin_certificates_certificates_id` = '".$instID."' ORDER BY `itemtype` LIMIT ".count(PluginCertificatesCertificate::getTypes(true)); $result = $DB->query($query); $number = $DB->numrows($result); if (Session::isMultiEntitiesMode()) { $colsup=1; } else { $colsup=0; } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form method='post' name='certificates_form$rand' id='certificates_form$rand' action='".Toolbox::getItemTypeFormURL("PluginCertificatesCertificate")."'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='".($canedit?(5+$colsup):(4+$colsup))."'>". __('Add an item')."</th></tr>"; echo "<tr class='tab_bg_1'><td colspan='".(3+$colsup)."' class='center'>"; Dropdown::showAllItems("items_id",0,0,($certificate->fields['is_recursive']?-1:$certificate->fields['entities_id']), PluginCertificatesCertificate::getTypes()); echo "</td><td colspan='2' class='center' class='tab_bg_1'>"; echo "<input type='hidden' name='plugin_certificates_certificates_id' value='$instID'>"; echo "<input type='submit' name='additem' value=\""._sx('button','Add')."\" class='submit'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>" ; } echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass'.__CLASS__.$rand); $massiveactionparams = array(); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; if ($canedit && $number) { echo "<th width='10'>".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand)."</th>"; } echo "<th>".__('Type')."</th>"; echo "<th>".__('Name')."</th>"; if (Session::isMultiEntitiesMode()) echo "<th>".__('Entity')."</th>"; echo "<th>".__('Serial number')."</th>"; echo "<th>".__('Inventory number')."</th>"; echo "</tr>"; for ($i=0 ; $i < $number ; $i++) { $itemtype=$DB->result($result, $i, "itemtype"); if (!($item = getItemForItemtype($itemtype))) { continue; } if ($item->canView()) { $column="name"; $itemTable = getTableForItemType($itemtype); $query = " SELECT `".$itemTable."`.*, `glpi_plugin_certificates_certificates_items`.`id` AS items_id, `glpi_entities`.id AS entity " ." FROM `glpi_plugin_certificates_certificates_items`, `".$itemTable ."` LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `".$itemTable."`.`entities_id`) " ." WHERE `".$itemTable."`.`id` = `glpi_plugin_certificates_certificates_items`.`items_id` AND `glpi_plugin_certificates_certificates_items`.`itemtype` = '$itemtype' AND `glpi_plugin_certificates_certificates_items`.`plugin_certificates_certificates_id` = '$instID' " . getEntitiesRestrictRequest(" AND ",$itemTable,'','',$item->maybeRecursive()); if ($item->maybeTemplate()) { $query.=" AND ".$itemTable.".is_template='0'"; } $query.=" ORDER BY `glpi_entities`.`completename`, `".$itemTable."`.`$column` "; if ($result_linked=$DB->query($query)){ if ($DB->numrows($result_linked)) { Session::initNavigateListItems($itemtype,PluginCertificatesCertificate::getTypeName(2)." = ".$certificate->fields['name']); while ($data=$DB->fetch_assoc($result_linked)) { $item->getFromDB($data["id"]); Session::addToNavigateListItems($itemtype,$data["id"]); $ID=""; if ($_SESSION["glpiis_ids_visible"]||empty($data["name"])) $ID= " (".$data["id"].")"; $link=Toolbox::getItemTypeFormURL($itemtype); $name= "<a href=\"".$link."?id=".$data["id"]."\">" .$data["name"]."$ID</a>"; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["items_id"]); echo "</td>"; } echo "<td class='center'>".$item->getTypeName(1)."</td>"; echo "<td class='center' ".(isset($data['is_deleted'])&&$data['is_deleted']?"class='tab_bg_2_2'":""). ">".$name."</td>"; if (Session::isMultiEntitiesMode()) echo "<td class='center'>".Dropdown::getDropdownName("glpi_entities",$data['entity'])."</td>"; echo "<td class='center'>".(isset($data["serial"])? "".$data["serial"]."" :"-")."</td>"; echo "<td class='center'>".(isset($data["otherserial"])? "".$data["otherserial"]."" :"-")."</td>"; echo "</tr>"; } } } } } echo "</table>"; if ($canedit && $number) { $paramsma['ontop'] =false; Html::showMassiveActions($paramsma); Html::closeForm(); } echo "</div>"; }
This file is part of certificates. Certificates is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Certificates is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Certificates. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ include '../../../inc/includes.php'; $plugin = new Plugin(); if ($plugin->isActivated("environment")) { Html::header(PluginCertificatesCertificate::getTypeName(2), '', "assets", "pluginenvironmentdisplay", "certificates"); } else { Html::header(PluginCertificatesCertificate::getTypeName(2), '', "assets", "plugincertificatesmenu"); } $certif = new PluginCertificatesCertificate(); $certif->checkGlobal(READ); if ($certif->canView()) { Search::show("PluginCertificatesCertificate"); } else { Html::displayRightError(); } Html::footer();
function showForm($ID, $options = array()) { if (!Session::haveRight("profile", "r")) { return false; } $prof = new Profile(); if ($ID) { $this->getFromDBByProfile($ID); $prof->getFromDB($ID); } $this->showFormHeader($options); echo "<tr class='tab_bg_2'>"; echo "<th colspan='4' class='center b'>" . sprintf(__('%1$s - %2$s'), __('Rights management', 'certificates'), $prof->fields["name"]) . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_2'>"; echo "<td>" . PluginCertificatesCertificate::getTypeName(2) . "</td><td>"; if ($prof->fields['interface'] != 'helpdesk') { Profile::dropdownNoneReadWrite("certificates", $this->fields["certificates"], 1, 1, 1); } else { _e('No access'); // No access; } echo "</td>"; echo "<td>" . __('Associable items to a ticket') . " - " . PluginCertificatesCertificate::getTypeName(2) . "</td><td>"; if ($prof->fields['create_ticket']) { Dropdown::showYesNo("open_ticket", $this->fields["open_ticket"]); } else { echo Dropdown::getYesNo(0); } echo "</td>"; echo "</tr>"; echo "<input type='hidden' name='id' value=" . $this->fields["id"] . ">"; $options['candel'] = false; $this->showFormButtons($options); }