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';
        }
    }
}
Пример #2
0
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     if (in_array(get_class($item), PluginSimcardSimcard_Item::getClasses())) {
         self::showForItem($item);
     } elseif (get_class($item) == 'PluginSimcardSimcard') {
         self::showForSimcard($item);
     }
     return true;
 }
Пример #3
0
 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));
                }
            }
        }
    }
Пример #4
0
 static function registerType()
 {
     global $DB, $PLUGIN_HOOKS, $UNINSTALL_TYPES, $ORDER_TYPES, $CFG_GLPI, $GO_LINKED_TYPES, $GENINVENTORYNUMBER_TYPES;
     $class = get_called_class();
     $item = new $class();
     $fields = PluginGenericobjectSingletonObjectField::getInstance($class);
     $plugin = new Plugin();
     PluginGenericobjectType::includeLocales($item->getObjectTypeName());
     PluginGenericobjectType::includeConstants($item->getObjectTypeName());
     $options = array("document_types" => $item->canUseDocuments(), "helpdesk_visible_types" => $item->canUseTickets(), "linkgroup_types" => isset($fields["groups_id"]), "linkuser_types" => isset($fields["users_id"]), "linkgroup_tech_types" => isset($fields["groups_id_tech"]), "linkuser_tech_types" => isset($fields["users_id_tech"]), "ticket_types" => $item->canUseTickets(), "infocom_types" => $item->canUseInfocoms(), "networkport_types" => $item->canUseNetworkPorts(), "reservation_types" => $item->canBeReserved(), "contract_types" => $item->canUseContracts(), "unicity_types" => $item->canUseUnicity(), "location_types" => isset($fields['locations_id']));
     Plugin::registerClass($class, $options);
     if (plugin_genericobject_haveRight($class, READ)) {
         //Change url for adding a new object, depending on template management activation
         if ($item->canUseTemplate()) {
             //Template management is active
             $add_url = "/front/setup.templates.php?itemtype={$class}&amp;add=1";
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['template'] = "/front/setup.templates.php?itemtype={$class}&amp;add=0";
         } else {
             //Template management is not active
             $add_url = Toolbox::getItemTypeFormURL($class, false);
         }
         //Menu management
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['title'] = $class::getTypeName();
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['page'] = Toolbox::getItemTypeSearchURL($class, false);
         $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['search'] = Toolbox::getItemTypeSearchURL($class, false);
         if (plugin_genericobject_haveRight($class, UPDATE)) {
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['add'] = $add_url;
         }
         //Add configuration icon, if user has right
         if (Session::haveRight('config', UPDATE)) {
             $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['config'] = Toolbox::getItemTypeSearchURL('PluginGenericobjectType', false) . "?itemtype={$class}";
         }
         if ($item->canUsePluginUninstall()) {
             if (!in_array($class, $UNINSTALL_TYPES)) {
                 array_push($UNINSTALL_TYPES, $class);
             }
         }
         if ($item->canUsePluginSimcard()) {
             if ($plugin->isActivated('simcard') && $plugin->isActivated('simcard')) {
                 PluginSimcardSimcard_Item::registerItemtype($class);
             }
         }
         if ($item->canUsePluginOrder()) {
             if (!in_array($class, $ORDER_TYPES)) {
                 array_push($ORDER_TYPES, $class);
             }
         }
         if ($item->canUseGlobalSearch()) {
             if (!in_array($class, $CFG_GLPI['asset_types'])) {
                 array_push($CFG_GLPI['asset_types'], $class);
             }
             if (!in_array($class, $CFG_GLPI['globalsearch_types'])) {
                 array_push($CFG_GLPI['globalsearch_types'], $class);
             }
             if (!in_array($class, $CFG_GLPI['state_types'])) {
                 array_push($CFG_GLPI['state_types'], $class);
                 array_push($CFG_GLPI['globalsearch_types'], $class);
             }
         }
         if ($item->canUseDirectConnections()) {
             if (!in_array($class, $GO_LINKED_TYPES)) {
                 array_push($GO_LINKED_TYPES, $class);
             }
             $items_class = $class . "_Item";
             //if (class_exists($items_class)) {
             $items_class::registerType();
             //}
         }
         if ($item->canUseProjects()) {
             if (!in_array($class, $CFG_GLPI['project_asset_types'])) {
                 array_push($CFG_GLPI['project_asset_types'], $class);
             }
         }
         if ($item->canUsePluginGeninventorynumber()) {
             if (!in_array($class, $GENINVENTORYNUMBER_TYPES)) {
                 include_once GLPI_ROOT . '/plugins/geninventorynumber/inc/profile.class.php';
                 PluginGeninventorynumberConfigField::registerNewItemType($class);
                 array_push($GENINVENTORYNUMBER_TYPES, $class);
             }
         } elseif ($plugin->isActivated('geninventorynumber')) {
             include_once GLPI_ROOT . '/plugins/geninventorynumber/inc/profile.class.php';
             PluginGeninventorynumberConfigField::unregisterNewItemType($class);
         }
     }
     foreach (PluginGenericobjectType::getDropdownForItemtype($class) as $table) {
         $itemtype = getItemTypeForTable($table);
         if (class_exists($itemtype)) {
             $item = new $itemtype();
             //If entity dropdown, check rights to view & create
             if ($itemtype::canView()) {
                 $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$itemtype]['links']['search'] = Toolbox::getItemTypeSearchURL($itemtype, false);
                 if ($itemtype::canCreate()) {
                     $PLUGIN_HOOKS['submenu_entry']['genericobject']['options'][$class]['links']['add'] = Toolbox::getItemTypeFormURL($class, false);
                 }
             }
         }
     }
 }
Пример #5
0
function plugin_item_purge_simcard($item)
{
    $temp = new PluginSimcardSimcard_Item();
    $temp->deleteByCriteria(array('itemtype' => get_class($item), 'items_id' => $item->getField('id')));
    return true;
}
Пример #6
0
 /**
  * Actions done when item is deleted from the database
  *
  * @return nothing
  * */
 function cleanDBonPurge()
 {
     $link = new PluginSimcardSimcard_Item();
     $link->cleanDBonItemDelete($this->getType(), $this->getID());
 }
Пример #7
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     global $LANG;
     if (in_array(get_class($item), PluginSimcardSimcard_Item::getClasses()) || get_class($item) == 'Profile') {
         return array(1 => $LANG['plugin_simcard']['profile'][1]);
     } elseif (get_class($item) == __CLASS__) {
         return $LANG['plugin_simcard']['profile'][1];
     }
     return '';
 }
Пример #8
0
 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";
Session::checkRight("simcard", "w");
$simcard_item = new PluginSimcardSimcard_Item();
if (isset($_POST["additem"])) {
    $simcard_item->check(-1, 'w', $_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->check($id, 'd', $_POST);
                    $ok = $simcard_item->delete(array('id' => $id));
                }
            }
        }
    }