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'; } } }
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { global $CFG_GLPI; if (PluginSimcardSimcard::canView()) { switch ($item->getType()) { case 'PluginSimcardSimcard': if ($_SESSION['glpishow_count_on_tabs']) { return self::createTabEntry(_n('Associated item', 'Associated items', 2), self::countForSimcard($item)); } return _n('Associated item', 'Associated items', 2); default: if ($_SESSION['glpishow_count_on_tabs']) { return self::createTabEntry(PluginSimcardSimcard::getTypeName(2), self::countForItemByItemtype($item)); } return _n('SIM card', 'SIM cards', 2); } } return ''; }
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"; PluginSimcardSimcard::canView(); if (!isset($_GET["id"])) { $_GET["id"] = ""; } if (!isset($_GET["sort"])) { $_GET["sort"] = ""; } if (!isset($_GET["order"])) { $_GET["order"] = ""; } if (!isset($_GET["withtemplate"])) { $_GET["withtemplate"] = ""; } $simcard = new PluginSimcardSimcard(); //Add a new simcard if (isset($_POST["add"])) {
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();
function plugin_simcard_getAddSearchOptions($itemtype) { global $LANG; $sopt = array(); $reservedTypeIndex = PluginSimcardConfig::RESERVED_TYPE_RANGE_MIN; if (in_array($itemtype, PluginSimcardSimcard_Item::getClasses())) { if (PluginSimcardSimcard::canView()) { $sopt[$reservedTypeIndex]['table'] = 'glpi_plugin_simcard_simcards'; $sopt[$reservedTypeIndex]['field'] = 'name'; $sopt[$reservedTypeIndex]['name'] = _sn('SIM card', 'SIM cards', 2, 'simcard') . " - " . __s('Name'); $sopt[$reservedTypeIndex]['forcegroupby'] = true; $sopt[$reservedTypeIndex]['massiveaction'] = false; $sopt[$reservedTypeIndex]['datatype'] = 'itemlink'; $sopt[$reservedTypeIndex]['itemlink_type'] = 'PluginSimcardSimcard'; $sopt[$reservedTypeIndex]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_simcard_simcards_items', 'joinparams' => array('jointype' => 'itemtype_item'))); $reservedTypeIndex++; $sopt[$reservedTypeIndex]['table'] = 'glpi_plugin_simcard_simcards'; $sopt[$reservedTypeIndex]['field'] = 'phonenumber'; $sopt[$reservedTypeIndex]['name'] = _sn('SIM card', 'SIM cards', 2, 'simcard') . " - " . __s('Phone number', 'simcard'); $sopt[$reservedTypeIndex]['massiveaction'] = false; $sopt[$reservedTypeIndex]['forcegroupby'] = true; $sopt[$reservedTypeIndex]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_simcard_simcards_items', 'joinparams' => array('jointype' => 'itemtype_item'))); $reservedTypeIndex++; $sopt[$reservedTypeIndex]['table'] = 'glpi_plugin_simcard_simcards'; $sopt[$reservedTypeIndex]['field'] = 'serial'; $sopt[$reservedTypeIndex]['name'] = _sn('SIM card', 'SIM cards', 2, 'simcard') . " - " . __s('IMSI', 'simcard'); $sopt[$reservedTypeIndex]['massiveaction'] = false; $sopt[$reservedTypeIndex]['forcegroupby'] = true; $sopt[$reservedTypeIndex]['joinparams'] = array('beforejoin' => array('table' => 'glpi_plugin_simcard_simcards_items', 'joinparams' => array('jointype' => 'itemtype_item'))); } } return $sopt; }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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://forge.indepnet.net/projects/simcard @link http://www.glpi-project.org/ @since 2009 ---------------------------------------------------------------------- */ define('GLPI_ROOT', '../../..'); include GLPI_ROOT . "/inc/includes.php"; Html::header($LANG['plugin_simcard']['profile'][1], '', "plugins", "simcard", "simcard"); $simcard = new PluginSimcardSimcard(); if ($simcard->canView() || Session::haveRight("simcard", "w")) { 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>" . $LANG['login'][5] . "</b></div>"; } Html::footer();
static function showForSimcard(PluginSimcardSimcard $simcard) { global $DB, $LANG; //if (!$simcard->can($simcard->getID(), 'r')) { if (!$simcard->canView()) { return false; } $results = getAllDatasFromTable(getTableForItemType(__CLASS__), "`plugin_simcard_simcards_id` = '" . $simcard->getID() . "'"); 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'>" . __("Associated item") . "</th></tr>"; if (!empty($results)) { echo "<tr><th></th>"; echo "<th>" . __s("Type") . "</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) { $item = new $data['itemtype'](); $item->getFromDB($data['items_id']); echo "<tr>"; echo "<td>"; //if (Session::haveRight('simcard', 'w')) { if (PluginSimcardSimcard::canUpdate()) { echo "<input type='checkbox' name='todelete[" . $data['id'] . "]'>"; } echo "</td>"; echo "<td>"; echo call_user_func(array($data['itemtype'], 'getTypeName')); echo "</td>"; echo "<td>"; echo Dropdown::getDropdownName('glpi_entities', $item->fields['entities_id']); echo "</td>"; echo "<td>"; echo $item->getLink(); echo "</td>"; echo "<td>"; echo $item->fields['serial']; echo "</td>"; echo "<td>"; echo $item->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'>"; if (empty($results)) { echo "<input type='hidden' name='plugin_simcard_simcards_id' value='" . $simcard->getID() . "'>"; // TODO : Dropdown::showAllItems is deprecated, use Dropdown::showSelectItemFromItemtypes instead Dropdown::showAllItems("items_id", 0, 0, $simcard->fields['entities_id'], self::getClasses()); echo "</td>"; echo "<td colspan='2' class='center' class='tab_bg_2'>"; echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Add') . "\" 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>"; }