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 plugin_simcard_uninstall() { include_once GLPI_ROOT . "/plugins/simcard/inc/profile.class.php"; include_once GLPI_ROOT . "/plugins/simcard/inc/simcard.class.php"; include_once GLPI_ROOT . "/plugins/simcard/inc/simcardsize.class.php"; include_once GLPI_ROOT . "/plugins/simcard/inc/simcardvoltage.class.php"; include_once GLPI_ROOT . "/plugins/simcard/inc/phoneoperator.class.php"; include_once GLPI_ROOT . "/plugins/simcard/inc/simcard_item.class.php"; PluginSimcardProfile::uninstall(); PluginSimcardSimcard::uninstall(); PluginSimcardSimcardSize::uninstall(); PluginSimcardSimcardVoltage::uninstall(); PluginSimcardPhoneOperator::uninstall(); PluginSimcardSimcard_Item::uninstall(); return true; }
/** * * Count the number of associated items for a simcard item * * @param $item Simcard object **/ static function countForSimcard(PluginSimcardSimcard $item) { $restrict = "`glpi_plugin_simcard_simcards_items`.`plugin_simcard_simcards_id` = '" . $item->getField('id') . "'"; return countElementsInTable(array('glpi_plugin_simcard_simcards_items'), $restrict); }
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)); } } }
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"])) { $simcard->check(-1, CREATE, $_POST); if ($newID = $simcard->add($_POST)) { Event::log($newID, "simcard", 4, "inventory", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"])); } Html::back(); // delete a simcard } else { if (isset($_POST["delete"])) { $simcard->check($_POST['id'], DELETE); $ok = $simcard->delete($_POST); if ($ok) { Event::log($_POST["id"], "simcard", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"])); }
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();
define('GLPI_ROOT', '../../..'); include GLPI_ROOT . "/inc/includes.php"; Session::checkRight("simcard", "r"); 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 computer if (isset($_POST["add"])) { $simcard->check(-1, 'w', $_POST); if ($newID = $simcard->add($_POST)) { } Html::back(); // delete a computer } else { if (isset($_POST["delete"])) { $simcard->check($_POST['id'], 'd'); $ok = $simcard->delete($_POST); if ($ok) { } Html::redirect(getItemTypeSearchURL('PluginSimcardSimcard')); } else {
function getAllRights() { $rights = array(array('itemtype' => 'PluginSimcardSimcard', 'label' => PluginSimcardSimcard::getTypeName(2), 'field' => 'simcard:simcard')); return $rights; }
static function showForItem(CommonDBTM $item) { global $DB, $LANG; if (!$item->can($item->getID(), 'r')) { return false; } if (Session::haveRight('simcard', 'w')) { $url = Toolbox::getItemTypeFormURL('PluginSimcardSimcard'); $url .= "?itemtype=" . $item->getType() . "&items_id=" . $item->getID() . "&id=-1"; echo "<div class='center'><a href='{$url}'>" . $LANG['plugin_simcard'][10] . "</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'>" . $LANG['document'][19] . "</th></tr>"; if (!empty($results)) { echo "<tr><th></th>"; echo "<th>" . $LANG['entity'][0] . "</th>"; echo "<th>" . $LANG['common'][16] . "</th>"; echo "<th>" . $LANG['common'][19] . "</th>"; echo "<th>" . $LANG['common'][20] . "</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')) { 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')) { 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=\"" . $LANG['buttons'][8] . "\" class='submit'>"; echo "</td></tr>"; if (!empty($results)) { Html::openArrowMassives('items'); Html::closeArrowMassives(array('delete_items' => $LANG['buttons'][10])); } } echo "</table>"; Html::closeForm(); echo "</div>"; }
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; }