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'; } } }
static function showForItem(CommonDBTM $item) { global $DB, $LANG; if (!$item->canView()) { return false; } // if (PluginSimcardSimcard::canCreate()) { // if ($item->canEdit($item->getField('id'))) { // $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('IMSI') . "</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 (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 (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']; } 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>"; }
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 ---------------------------------------------------------------------- */ include '../../../inc/includes.php'; PluginSimcardSimcard::canUpdate(); $simcard_item = new PluginSimcardSimcard_Item(); if (isset($_POST["additem"])) { $simcard_item->can(-1, CREATE, $_POST); if ($newID = $simcard_item->add($_POST)) { } } else { if (isset($_POST["delete_items"])) { if (isset($_POST['todelete'])) { foreach ($_POST['todelete'] as $id => $val) { if ($val == 'on') { $simcard_item->can($id, DELETE, $_POST); $ok = $simcard_item->delete(array('id' => $id)); } } }
function getSearchOptions() { global $CFG_GLPI, $LANG; $tab = array(); $tab['common'] = __s('SIM card', 'simcard'); $tab[1]['table'] = $this->getTable(); $tab[1]['field'] = 'name'; $tab[1]['name'] = __('Name'); $tab[1]['datatype'] = 'itemlink'; $tab[1]['itemlink_type'] = $this->getType(); $tab[1]['massiveaction'] = false; // implicit key==1 $tab[1]['injectable'] = true; $tab[1]['checktype'] = 'text'; $tab[1]['displaytype'] = 'text'; $tab[2]['table'] = $this->getTable(); $tab[2]['field'] = 'id'; $tab[2]['name'] = __('ID'); $tab[2]['massiveaction'] = false; // implicit field is id $tab[2]['injectable'] = false; $tab[4]['table'] = 'glpi_plugin_simcard_simcardtypes'; $tab[4]['field'] = 'name'; $tab[4]['name'] = __('Type'); $tab[4]['datatype'] = 'dropdown'; $tab[4]['massiveaction'] = true; $tab[4]['checktype'] = 'text'; $tab[4]['displaytype'] = 'dropdown'; $tab[4]['injectable'] = true; $tab[5]['table'] = $this->getTable(); $tab[5]['field'] = 'serial'; $tab[5]['name'] = __('IMSI', 'simcard'); $tab[5]['datatype'] = 'string'; $tab[5]['checktype'] = 'text'; $tab[5]['displaytype'] = 'text'; $tab[5]['injectable'] = true; $tab[6]['table'] = $this->getTable(); $tab[6]['field'] = 'otherserial'; $tab[6]['name'] = __('Inventory number'); $tab[6]['datatype'] = 'string'; $tab[6]['checktype'] = 'text'; $tab[6]['displaytype'] = 'text'; $tab[6]['injectable'] = true; $tab[16]['table'] = $this->getTable(); $tab[16]['field'] = 'comment'; $tab[16]['name'] = __('Comments'); $tab[16]['datatype'] = 'text'; $tab[16]['linkfield'] = 'comment'; $tab[16]['checktype'] = 'text'; $tab[16]['displaytype'] = 'multiline_text'; $tab[16]['injectable'] = true; $tab += Location::getSearchOptionsToAdd(); $tab[3]['checktype'] = 'text'; $tab[3]['displaytype'] = 'dropdown'; $tab[3]['injectable'] = true; $tab[91]['injectable'] = false; $tab[93]['injectable'] = false; $tab[19]['table'] = $this->getTable(); $tab[19]['field'] = 'date_mod'; $tab[19]['name'] = __('Last update'); $tab[19]['datatype'] = 'datetime'; $tab[19]['massiveaction'] = false; $tab[19]['injectable'] = false; // TODO : This index has not any similar in GLPI, should find an other index $tab[23]['table'] = 'glpi_plugin_simcard_simcardvoltages'; $tab[23]['field'] = 'name'; $tab[23]['name'] = __('Voltage', 'simcard'); $tab[23]['datatype'] = 'dropdown'; $tab[23]['checktype'] = 'text'; $tab[23]['displaytype'] = 'dropdown'; $tab[23]['injectable'] = true; $tab[24]['table'] = 'glpi_users'; $tab[24]['field'] = 'name'; $tab[24]['linkfield'] = 'users_id_tech'; $tab[24]['name'] = __('Technician in charge of the hardware'); $tab[24]['datatype'] = 'dropdown'; $tab[24]['right'] = 'own_ticket'; $tab[24]['checktype'] = 'text'; $tab[24]['displaytype'] = 'dropdown'; $tab[24]['injectable'] = true; $tab[25]['table'] = 'glpi_plugin_simcard_simcardsizes'; $tab[25]['field'] = 'name'; $tab[25]['name'] = __('Size', 'simcard'); $tab[25]['datatype'] = 'dropdown'; $tab[25]['checktype'] = 'text'; $tab[25]['displaytype'] = 'dropdown'; $tab[25]['injectable'] = true; $tab[26]['table'] = 'glpi_plugin_simcard_phoneoperators'; $tab[26]['field'] = 'name'; $tab[26]['name'] = __('Provider', 'simcard'); $tab[26]['datatype'] = 'dropdown'; $tab[26]['checktype'] = 'text'; $tab[26]['displaytype'] = 'dropdown'; $tab[26]['injectable'] = true; $tab[27]['table'] = $this->getTable(); $tab[27]['field'] = 'phonenumber'; $tab[27]['name'] = __('Phone number', 'simcard'); $tab[27]['datatype'] = 'string'; $tab[27]['checktype'] = 'text'; $tab[27]['displaytype'] = 'text'; $tab[27]['injectable'] = true; if (PluginSimcardSimcard::canUpdate()) { $tab[28]['table'] = $this->getTable(); $tab[28]['field'] = 'pin'; $tab[28]['name'] = __('Pin 1', 'simcard'); $tab[28]['datatype'] = 'string'; $tab[28]['checktype'] = 'text'; $tab[28]['displaytype'] = 'text'; $tab[28]['injectable'] = true; $tab[29]['table'] = $this->getTable(); $tab[29]['field'] = 'puk'; $tab[29]['name'] = __('Puk 1', 'simcard'); $tab[29]['datatype'] = 'string'; $tab[29]['checktype'] = 'text'; $tab[29]['displaytype'] = 'text'; $tab[29]['injectable'] = true; $tab[30]['table'] = $this->getTable(); $tab[30]['field'] = 'pin2'; $tab[30]['name'] = __('Pin 2', 'simcard'); $tab[30]['datatype'] = 'string'; $tab[30]['checktype'] = 'text'; $tab[30]['displaytype'] = 'text'; $tab[30]['injectable'] = true; $tab[32]['table'] = $this->getTable(); $tab[32]['field'] = 'puk2'; $tab[32]['name'] = __('Puk 2', 'simcard'); $tab[32]['datatype'] = 'string'; $tab[32]['checktype'] = 'text'; $tab[32]['displaytype'] = 'text'; $tab[32]['injectable'] = true; } $tab[31]['table'] = 'glpi_states'; $tab[31]['field'] = 'name'; $tab[31]['name'] = __('Status'); $tab[31]['datatype'] = 'dropdown'; $tab[31]['checktype'] = 'text'; $tab[31]['displaytype'] = 'dropdown'; $tab[31]['injectable'] = true; $tab[71]['table'] = 'glpi_groups'; $tab[71]['field'] = 'completename'; $tab[71]['name'] = __('Group'); $tab[71]['datatype'] = 'dropdown'; $tab[71]['checktype'] = 'text'; $tab[71]['displaytype'] = 'dropdown'; $tab[71]['injectable'] = true; $tab[49]['table'] = 'glpi_groups'; $tab[49]['field'] = 'name'; $tab[49]['linkfield'] = 'groups_id_tech'; $tab[49]['condition'] = '`is_assign`'; $tab[49]['name'] = __('Group in charge of the hardware'); $tab[49]['datatype'] = 'dropdown'; $tab[49]['checktype'] = 'text'; $tab[49]['displaytype'] = 'dropdown'; $tab[49]['injectable'] = true; $tab[70]['table'] = 'glpi_users'; $tab[70]['field'] = 'name'; $tab[70]['name'] = __('User'); $tab[70]['datatype'] = 'dropdown'; $tab[70]['right'] = 'all'; $tab[70]['checktype'] = 'text'; $tab[70]['displaytype'] = 'dropdown'; $tab[70]['injectable'] = true; $tab[80]['table'] = 'glpi_entities'; $tab[80]['field'] = 'completename'; $tab[80]['name'] = __('Entity'); $tab[80]['injectable'] = false; $tab[90]['table'] = $this->getTable(); $tab[90]['field'] = 'notepad'; $tab[90]['name'] = __('Notes'); $tab[90]['massiveaction'] = false; $tab[90]['linkfield'] = 'notepad'; $tab[90]['checktype'] = 'text'; $tab[90]['displaytype'] = 'multiline_text'; $tab[90]['injectable'] = true; return $tab; }