function plugin_init_simcard() { global $PLUGIN_HOOKS, $CFG_GLPI, $LANG; $PLUGIN_HOOKS['csrf_compliant']['simcard'] = true; $plugin = new Plugin(); if ($plugin->isInstalled('simcard') && $plugin->isActivated('simcard')) { //load changeprofile function $PLUGIN_HOOKS['change_profile']['simcard'] = array('PluginSimcardProfile', 'changeProfile'); $PLUGIN_HOOKS['assign_to_ticket']['simcard'] = true; $PLUGIN_HOOKS['pre_item_purge']['simcard'] = array('Profile' => array('PluginSimcardsProfile', 'purgeProfiles')); $PLUGIN_HOOKS['plugin_datainjection_populate']['simcard'] = 'plugin_datainjection_populate_simcard'; $PLUGIN_HOOKS['item_purge']['simcard'] = array(); foreach (PluginSimcardSimcard_Item::getClasses() as $type) { $PLUGIN_HOOKS['item_purge']['simcard'][$type] = 'plugin_item_purge_simcard'; } Plugin::registerClass('PluginSimcardSimcard_Item', array('addtabon' => PluginSimcardSimcard_Item::getClasses())); Plugin::registerClass('PluginSimcardProfile', array('addtabon' => 'Profile')); // Params : plugin name - string type - number - class - table - form page Plugin::registerClass('PluginSimcardSimcard', array('linkgroup_types' => true, 'linkuser_types' => true, 'document_types' => true, 'contract_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true, 'infocom_types' => true, 'unicity_types' => true, 'reservation_types' => true)); array_push($CFG_GLPI['state_types'], 'PluginSimcardSimcard'); //if glpi is loaded if (Session::getLoginUserID()) { // Display a menu entry ? //if (Session::haveRight("simcard", "r")) { if (PluginSimcardSimcard::canCreate() || PluginSimcardSimcard::canUpdate() || PluginSimcardSimcard::canDelete() || PluginSimcardSimcard::canView()) { //menu entry //$PLUGIN_HOOKS['menu_entry']['simcard'] = 'front/simcard.php'; $PLUGIN_HOOKS['menu_toadd']['simcard'] = array('assets' => 'PluginSimcardSimcard'); //search link //$PLUGIN_HOOKS['submenu_entry']['simcard']['options']['simcard']['links']['search'] // = '/plugins/simcard/front/simcard.php'; //add simcard to items details $PLUGIN_HOOKS['headings']['simcard'] = 'plugin_get_headings_simcard'; $PLUGIN_HOOKS['headings_action']['simcard'] = 'plugin_headings_actions_simcard'; $PLUGIN_HOOKS['headings_actionpdf']['simcard'] = 'plugin_headings_actionpdf_simcard'; } //if (Session::haveRight("simcard", "w")) { if (PluginSimcardSimcard::canCreate()) { //add link // $PLUGIN_HOOKS['submenu_entry']['simcard']['options']['simcard']['links']['add'] // = '/front/setup.templates.php?itemtype=PluginSimcardSimcard&add=1'; // $PLUGIN_HOOKS['submenu_entry']['simcard']['options']['simcard']['links']['template'] // = '/front/setup.templates.php?itemtype=PluginSimcardSimcard&add=0'; //use massiveaction in the plugin $PLUGIN_HOOKS['use_massive_action']['simcard'] = 1; } // Import from Data_Injection plugin $PLUGIN_HOOKS['migratetypes']['simcard'] = 'plugin_datainjection_migratetypes_simcard'; $PLUGIN_HOOKS['menu']['simcard'] = true; $PLUGIN_HOOKS['post_init']['simcard'] = 'plugin_simcard_postinit'; } } }
Order plugin 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 GLPI; along with Simcard. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- @package simcard @author the simcard plugin team @copyright Copyright (c) 2010-2011 Simcard plugin team @license GPLv2+ http://www.gnu.org/licenses/gpl.txt @link https://github.com/pluginsglpi/simcard @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ define('GLPI_ROOT', '../../..'); include GLPI_ROOT . "/inc/includes.php"; // Affichage du fil d'Ariane Html::header(PluginSimcardSimcard::getTypeName(2), '', "assets", "pluginsimcardsimcard", "simcard"); $simcard = new PluginSimcardSimcard(); // TODO Is Checking canCreate useful before showing a list ? if (PluginSimcardSimcard::canView() || PluginSimcardSimcard::canCreate()) { Search::show("PluginSimcardSimcard"); } else { echo "<div align='center'><br><br><img src=\"" . $CFG_GLPI["root_doc"] . "/pics/warning.png\" alt=\"warning\"><br><br>"; echo "<b>" . __s('Access denied') . "</b></div>"; } Html::footer();
static function showForItem(CommonDBTM $item) { global $DB, $LANG; if (!$item->canView()) { return false; } //if (Session::haveRight('simcard', 'w')) { if (PluginSimcardSimcard::canCreate()) { $url = Toolbox::getItemTypeFormURL('PluginSimcardSimcard'); $url .= "?itemtype=" . $item->getType() . "&items_id=" . $item->getID() . "&id=-1"; echo "<div class='center'><a href='{$url}'>" . __s('New SIM card', 'simcard') . "</a></div><br>"; } $results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`items_id` = '" . $item->getID() . "' AND `itemtype`='" . get_class($item) . "'"); echo "<div class='spaced'>"; echo "<form id='items' name='items' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='6'>" . __s('Associated item') . "</th></tr>"; if (!empty($results)) { echo "<tr><th></th>"; echo "<th>" . __s('Entity') . "</th>"; echo "<th>" . __s('Name') . "</th>"; echo "<th>" . __s('Serial Number') . "</th>"; echo "<th>" . __s('Inventory number') . "</th>"; echo "</tr>"; foreach ($results as $data) { $tmp = new PluginSimcardSimcard(); $tmp->getFromDB($data['plugin_simcard_simcards_id']); echo "<tr>"; echo "<td>"; //if (Session::haveRight('simcard', 'w')) { if (PluginSimcardSimcard::canDelete()) { echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>"; } echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_entities', $tmp->fields['entities_id']); echo "</td>"; echo "<td>"; echo $tmp->getLink(); echo "</td>"; echo "<td>"; echo $tmp->fields['serial']; echo "</td>"; echo "<td>"; echo $tmp->fields['otherserial']; echo "</td>"; echo "</tr>"; } } //if (Session::haveRight('simcard', 'w')) { if (PluginSimcardSimcard::canUpdate()) { echo "<tr class='tab_bg_1'><td colspan='4' class='center'>"; echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>"; echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>"; $used = array(); $query = "SELECT `id`\n FROM `glpi_plugin_simcard_simcards`\n WHERE `is_template`='0'\n AND `id` IN (SELECT `plugin_simcard_simcards_id`\n FROM `glpi_plugin_simcard_simcards_items`)"; foreach ($DB->request($query) as $use) { $used[$use['id']] = $use['id']; } Dropdown::show('PluginSimcardSimcard', array('name' => "plugin_simcard_simcards_id", 'entity' => $item->fields['entities_id'], 'used' => $used)); echo "</td>"; echo "<td colspan='2' class='center' class='tab_bg_2'>"; echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Save') . "\" class='submit'>"; echo "</td></tr>"; if (!empty($results)) { Html::openArrowMassives('items', true); Html::closeArrowMassives(array('delete_items' => _sx('button', 'Disconnect'))); } } echo "</table>"; Html::closeForm(); echo "</div>"; }