Наследование: extends CI_Controller
Пример #1
1
 static function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1, $types, $locations_id = -1, $action = 'showItem')
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $plugin = new Plugin();
     echo "<table border='0'><tr><td>\n";
     if ($myname == 'type') {
         $newtypes = array_flip($types);
         unset($newtypes['Location']);
         unset($newtypes['Netpoint']);
         if ($plugin->isActivated("resources")) {
             unset($newtypes['PluginResourcesResource']);
         }
         $types = array_flip($newtypes);
     }
     $rand = Dropdown::showItemTypes($myname, $types, array('emptylabel' => Dropdown::EMPTY_VALUE, 'width' => 150));
     $params = array('type' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'action' => $action, 'entity_restrict' => $entity_restrict, 'locations_id' => $locations_id);
     Ajax::updateItemOnSelectEvent("dropdown_{$myname}{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
     echo "</td><td>\n";
     echo "<span id='show_{$myname}{$rand}'>&nbsp;</span>\n";
     echo "</td></tr></table>\n";
     if ($value > 0) {
         echo "<script type='text/javascript' >\n";
         echo "document.getElementById('item_type{$rand}').value='" . $value_type . "';";
         echo "</script>\n";
         $params["typetable"] = $value_type;
         Ajax::updateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
     }
     return $rand;
 }
Пример #2
0
 public function testPlugin()
 {
     $pl = new Plugin(123, 'A Plugin', true);
     $this->assertEquals(123, $pl->getID());
     $this->assertEquals('A Plugin', $pl->getName());
     $this->assertEquals(true, $pl->isActive());
 }
Пример #3
0
/**
 * Function Init
 */
function plugin_init_uninstall()
{
    global $PLUGIN_HOOKS, $CFG_GLPI, $UNINSTALL_TYPES, $UNINSTALL_DIRECT_CONNECTIONS_TYPE;
    $PLUGIN_HOOKS['csrf_compliant']['uninstall'] = true;
    Plugin::registerClass('PluginUninstallPreference', array('addtabon' => array('Preference')));
    Plugin::registerClass('PluginUninstallProfile', array('addtabon' => array('Profile')));
    $plugin = new Plugin();
    if ($plugin->isActivated('uninstall')) {
        $UNINSTALL_TYPES = array('Computer', 'Monitor', 'NetworkEquipment', 'Peripheral', 'Phone', 'Printer');
        $UNINSTALL_DIRECT_CONNECTIONS_TYPE = array('Monitor', 'Peripheral', 'Phone', 'Printer');
        if (Session::getLoginUserID()) {
            if (Session::haveRight(PluginUninstallProfile::$rightname, READ)) {
                $PLUGIN_HOOKS['use_massive_action']['uninstall'] = true;
                if (Session::haveRight('uninstall:profile', READ)) {
                    // Add link in GLPI plugins list :
                    $PLUGIN_HOOKS["menu_toadd"]['uninstall'] = array('admin' => 'PluginUninstallModel');
                    // add to 'Admin' menu :
                    $PLUGIN_HOOKS['config_page']['uninstall'] = "front/model.php";
                }
                //Item actions
                $PLUGIN_HOOKS['item_update']['uninstall'] = array('PluginUninstallModel' => array('PluginUninstallPreference', 'afterUpdateModel'));
                $PLUGIN_HOOKS['item_delete']['uninstall'] = array('PluginUninstallModel' => array('PluginUninstallPreference', 'beforeItemPurge'));
                $PLUGIN_HOOKS['pre_item_purge']['uninstall'] = array('User' => array('PluginUninstallPreference', 'beforeItemPurge'));
            }
        }
        $PLUGIN_HOOKS['post_init']['uninstall'] = 'plugin_uninstall_postinit';
    }
}
Пример #4
0
/**
 * Initialize the plugin's hooks
 */
function plugin_init_customfields()
{
    global $PLUGIN_HOOKS, $DB, $ACTIVE_CUSTOMFIELDS_TYPES, $ALL_CUSTOMFIELDS_TYPES;
    $PLUGIN_HOOKS['csrf_compliant']['customfields'] = true;
    $PLUGIN_HOOKS['change_profile']['customfields'] = array('PluginCustomfieldsProfile', 'changeprofile');
    // Register classes
    Plugin::registerClass('PluginCustomfieldsDropdowns');
    Plugin::registerClass('PluginCustomfieldsFields');
    if (isset($_SESSION['glpiID'])) {
        $plugin = new Plugin();
        if ($plugin->isInstalled("customfields") && $plugin->isActivated("customfields")) {
            // enable a tab for reading / setting access rights for the plugin
            Plugin::registerClass('PluginCustomfieldsProfile', array('addtabon' => 'Profile'));
            // Display a menu entry in the main menu if the user has
            // configuration rights
            if (Session::haveRight('config', UPDATE)) {
                //             $PLUGIN_HOOKS['menu_entry']['customfields'] = true;
                $PLUGIN_HOOKS["menu_toadd"]['customfields'] = array('plugins' => 'PluginCustomfieldsConfig');
            }
            // initiate empty dropdowns
            $PLUGIN_HOOKS['item_empty']['customfields'] = array('PluginCustomfieldsDropdownsItem' => 'PluginCustomfieldsDropdownsItem::item_empty');
        }
        // Indicate where the configuration page can be found
        if (Session::haveRight('config', UPDATE)) {
            $PLUGIN_HOOKS['config_page']['customfields'] = 'front/config.form.php';
        }
        // Hook for initialization after initialization of all other plugins
        $PLUGIN_HOOKS['post_init']['customfields'] = 'plugin_customfields_postinit';
    }
}
Пример #5
0
function plugin_fields_checkFiles()
{
    $plugin = new Plugin();
    if (isset($_SESSION['glpiactiveentities']) && $plugin->isInstalled('fields') && $plugin->isActivated('fields')) {
        Plugin::registerClass('PluginFieldsContainer');
        Plugin::registerClass('PluginFieldsDropdown');
        Plugin::registerClass('PluginFieldsField');
        if (TableExists("glpi_plugin_fields_containers")) {
            $container_obj = new PluginFieldsContainer();
            $containers = $container_obj->find();
            foreach ($containers as $container) {
                $classname = "PluginFields" . ucfirst($container['itemtype'] . preg_replace('/s$/', '', $container['name']));
                if (!class_exists($classname)) {
                    PluginFieldsContainer::generateTemplate($container);
                }
            }
        }
        if (TableExists("glpi_plugin_fields_fields")) {
            $fields_obj = new PluginFieldsField();
            $fields = $fields_obj->find("`type` = 'dropdown'");
            foreach ($fields as $field) {
                PluginFieldsDropdown::create($field);
            }
        }
    }
}
function plugin_init_certificates()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['certificates'] = true;
    $PLUGIN_HOOKS['change_profile']['certificates'] = array('PluginCertificatesProfile', 'initProfile');
    $PLUGIN_HOOKS['assign_to_ticket']['certificates'] = true;
    if (Session::getLoginUserID()) {
        // Params : plugin name - string type - number - attributes
        Plugin::registerClass('PluginCertificatesCertificate', array('linkgroup_tech_types' => true, 'linkuser_tech_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'contract_types' => true, 'notificationtemplates_types' => true));
        Plugin::registerClass('PluginCertificatesConfig', array('addtabon' => 'CronTask'));
        Plugin::registerClass('PluginCertificatesProfile', array('addtabon' => 'Profile'));
        if (class_exists('PluginAccountsAccount')) {
            PluginAccountsAccount::registerType('PluginCertificatesCertificate');
        }
        $plugin = new Plugin();
        if (!$plugin->isActivated('environment') && Session::haveRight("plugin_certificates", READ)) {
            $PLUGIN_HOOKS['menu_toadd']['certificates'] = array('assets' => 'PluginCertificatesMenu');
        }
        if (Session::haveRight("plugin_certificates", UPDATE)) {
            $PLUGIN_HOOKS['use_massive_action']['certificates'] = 1;
        }
        // End init, when all types are registered
        $PLUGIN_HOOKS['post_init']['certificates'] = 'plugin_certificates_postinit';
    }
}
Пример #7
0
 /**
  * Return all injectable types
  *
  * @param $only_primary    return only primary types (false by default)
  *
  * @return an array which contains array(itemtype => itemtype name)
  **/
 static function getItemtypes($only_primary = false)
 {
     global $INJECTABLE_TYPES;
     getTypesToInject();
     $plugin = new Plugin();
     $values = array();
     foreach ($INJECTABLE_TYPES as $type => $from) {
         $injectionclass = new $type();
         if (class_exists($type) && (!$only_primary || $only_primary && $injectionclass->isPrimaryType())) {
             $instance = new $type();
             //If user has no right to create an object of this type, do not display type in the list
             if (!$instance->canCreate()) {
                 continue;
             }
             $typename = get_parent_class($type);
             $name = '';
             if ($from != 'datainjection') {
                 $plugin->getFromDBbyDir($from);
                 $name = $plugin->getName() . ': ';
             }
             $name .= call_user_func(array($type, 'getTypeName'));
             $values[$typename] = $name;
         }
     }
     asort($values);
     return $values;
 }
Пример #8
0
 static function showSummary()
 {
     echo "<div class='center'><table class='tab_cadre' cellpadding='5' width='50%'>";
     echo "<tr><th>" . __('Summary') . "</th></tr>";
     if (countElementsInTable('glpi_plugin_archires_views', "`entities_id`='" . $_SESSION["glpiactive_entity"] . "'") > 0) {
         echo "<tr class='tab_bg_1'><td>";
         echo "<a href='view.php'>" . PluginArchiresView::getTypeName(2) . "</a>";
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>";
         echo "<a href='locationquery.php'>" . sprintf(__('%1$s - %2$s'), self::getTypeName(1), PluginArchiresLocationQuery::getTypeName(1)) . "</a>";
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>";
         echo "<a href='networkequipmentquery.php'>" . sprintf(__('%1$s - %2$s'), self::getTypeName(1), PluginArchiresNetworkEquipmentQuery::getTypeName(1)) . "</a>";
         echo "</td></tr>";
         $plugin = new Plugin();
         if ($plugin->isActivated("appliances")) {
             echo "<tr class='tab_bg_1'><td>";
             echo "<a href='appliancequery.php'>" . sprintf(__('%1$s - %2$s'), self::getTypeName(1), PluginAppliancesAppliance::getTypeName(1)) . "</a>";
             echo "</td></tr>";
         }
     } else {
         echo "<tr class='tab_bg_1'><td>";
         echo "<a href='view.form.php?new=1'>" . __('Add view', 'archires') . "</a>";
         echo "</td></tr>";
     }
     echo "</table></div>";
 }
 /**
  * Decide which template file to load
  */
 public function override_templates()
 {
     $this->queried_object = get_queried_object();
     if (is_post_type_archive(Plugin::POST_TYPE_NAME)) {
         // load template for a single page
         $custom_archive_page_id = $this->wpkb->get_option('custom_archive_page_id');
         if ($custom_archive_page_id > 0) {
             // if we're using a custom archive page, that one should be used
             $archive_link = get_permalink($custom_archive_page_id);
             if ($archive_link !== get_post_type_archive_link(Plugin::POST_TYPE_NAME)) {
                 wp_redirect($archive_link);
                 exit;
             }
         } else {
             add_filter('archive_template', array($this, 'set_archive_template'));
         }
     } elseif (is_tax(Plugin::TAXONOMY_CATEGORY_NAME)) {
         // choose "category" archive template to load
         add_filter('taxonomy_template', array($this, 'set_taxonomy_category_template'));
     } elseif (is_tax(Plugin::TAXONOMY_KEYWORD_NAME)) {
         // choose "keyword" archive template to load
         add_filter('taxonomy_template', array($this, 'set_taxonomy_keyword_template'));
     } elseif (is_singular(Plugin::POST_TYPE_NAME)) {
         // choose template to load for singular docs
         add_filter('single_template', array($this, 'set_single_template'));
         add_filter('wp_footer', array($this, 'print_js_helpers'));
         add_filter('wp_head', array($this, 'print_css_helpers'));
     }
 }
Пример #10
0
/**
 * Plugin activation callback function.
 *
 * On plugin registration check is Woocommerce is active ( If not disable shop by look plugin because its Woocommerce dependent ).
 * Instantiate Plugin class to boot all base plugin hooks, also do flush of rewrite rules in order to have proper url rewrite for custom post type.
 *
 * @return void
 */
function flush_rewrites()
{
    check_is_woocommerce_is_active();
    $plugin = new Plugin();
    $plugin->register_post_type();
    flush_rewrite_rules();
}
/**
 * Returns the main plugin container or a specific property within
 *
 * @param string $plugin_part the part of the plugin to return
 *
 * @throws \Exception when the requested property cannot be found
 *
 * @return mixed Returns the requested property, or the main plugin if nothing more specific requested
 */
function get_plugin($plugin_part = null)
{
    static $plugin;
    if (empty($plugin)) {
        $plugin = new Plugin();
        $plugin->setup(__FILE__);
    }
    if (!is_null($plugin_part)) {
        $current_class = $plugin;
        $classes = explode('.', $plugin_part);
        $property = array_pop($classes);
        // Find the innermost class
        if (!empty($classes)) {
            foreach ($classes as $class) {
                if (property_exists($current_class, $class)) {
                    if (!is_object($current_class->{$class})) {
                        $current_class_name = get_class($current_class);
                        throw new \Exception("{$class} is not an object within {$current_class_name}");
                    }
                    $current_class = $current_class->{$class};
                }
            }
        }
        // Get the property, now that we have the innermost class
        if (!property_exists($current_class, $property)) {
            $current_class_name = get_class($current_class);
            throw new \Exception("{$property} is not a part of {$current_class_name}");
        }
        return $current_class->{$property};
    }
    return $plugin;
}
Пример #12
0
 public function requirements()
 {
     if (!$this->meetsRequirements()) {
         add_action('all_admin_notices', array($this, 'notice'));
         deactivate_plugins($this->plugin->getBasename());
     }
 }
Пример #13
0
function plugin_init_pdf()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['pdf'] = true;
    Plugin::registerClass('PluginPdfProfile', array('addtabon' => 'Profile'));
    Plugin::registerClass('PluginPdfPreference', array('addtabon' => 'Preference'));
    $PLUGIN_HOOKS['change_profile']['pdf'] = array('PluginPdfProfile', 'changeprofile');
    $PLUGIN_HOOKS['pre_item_purge']['pdf'] = array('Profile' => array('PluginPdfProfile', 'cleanProfile'));
    $PLUGIN_HOOKS['item_clone']['pdf'] = array('Profile' => array('PluginPdfProfile', 'cloneProfile'));
    $plugin = new Plugin();
    if ($plugin->isActivated("datainjection")) {
        $PLUGIN_HOOKS['menu_entry']['pdf'] = 'front/preference.form.php';
    }
    if (isset($_SESSION["glpi_plugin_pdf_profile"]) && $_SESSION["glpi_plugin_pdf_profile"]["use"]) {
        $PLUGIN_HOOKS['use_massive_action']['pdf'] = 1;
        // Define the type for which we know how to generate PDF :
        $PLUGIN_HOOKS['plugin_pdf']['Computer'] = 'PluginPdfComputer';
        $PLUGIN_HOOKS['plugin_pdf']['Group'] = 'PluginPdfGroup';
        $PLUGIN_HOOKS['plugin_pdf']['KnowbaseItem'] = 'PluginPdfKnowbaseItem';
        $PLUGIN_HOOKS['plugin_pdf']['Monitor'] = 'PluginPdfMonitor';
        $PLUGIN_HOOKS['plugin_pdf']['NetworkEquipment'] = 'PluginPdfNetworkEquipment';
        $PLUGIN_HOOKS['plugin_pdf']['Peripheral'] = 'PluginPdfPeripheral';
        $PLUGIN_HOOKS['plugin_pdf']['Phone'] = 'PluginPdfPhone';
        $PLUGIN_HOOKS['plugin_pdf']['Printer'] = 'PluginPdfPrinter';
        $PLUGIN_HOOKS['plugin_pdf']['Software'] = 'PluginPdfSoftware';
        $PLUGIN_HOOKS['plugin_pdf']['SoftwareLicense'] = 'PluginPdfSoftwareLicense';
        $PLUGIN_HOOKS['plugin_pdf']['SoftwareVersion'] = 'PluginPdfSoftwareVersion';
        $PLUGIN_HOOKS['plugin_pdf']['Ticket'] = 'PluginPdfTicket';
        // End init, when all types are registered by all plugins
        $PLUGIN_HOOKS['post_init']['pdf'] = 'plugin_pdf_postinit';
    }
}
Пример #14
0
function plugin_init_surveyticket()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['surveyticket'] = true;
    if (isset($_SESSION["glpiID"])) {
        $plugin = new Plugin();
        if ($plugin->isActivated('surveyticket')) {
            Plugin::registerClass('PluginSurveyticketProfile', array('addtabon' => array('Profile')));
            $PLUGIN_HOOKS['change_profile']['surveyticket'] = array('PluginSurveyticketProfile', 'changeprofile');
            PluginSurveyticketProfile::changeprofile();
            if (PluginSurveyticketProfile::haveRight("config", 'r')) {
                $PLUGIN_HOOKS['menu_entry']['surveyticket'] = true;
                $PLUGIN_HOOKS['config_page']['surveyticket'] = 'front/menu.php';
            }
            $PLUGIN_HOOKS['post_init']['surveyticket'] = 'plugin_surveyticket_post_init';
        }
        // Icons add, search...
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['add']['questions'] = 'front/question.form.php?add=1';
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['search']['questions'] = 'front/question.php';
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['add']['survey'] = 'front/survey.form.php?add=1';
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['search']['survey'] = 'front/survey.php';
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['add']['answers'] = 'front/answer.form.php?add=1';
        // Fil ariane
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['options']['questions']['title'] = "Questions";
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['options']['questions']['page'] = '/plugins/surveyticket/front/question.php';
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['options']['answers']['title'] = "Answers";
        //         $PLUGIN_HOOKS['submenu_entry']['surveyticket']['options']['answers']['page']  = '/plugins/surveyticket/front/answer.php';
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['options']['survey']['title'] = "Surveys";
        $PLUGIN_HOOKS['submenu_entry']['surveyticket']['options']['survey']['page'] = '/plugins/surveyticket/front/survey.php';
    }
}
Пример #15
0
/**
 * Initialize all classes and generic variables of the plugin
 */
function plugin_init_formcreator()
{
    global $PLUGIN_HOOKS;
    // Add specific CSS
    $PLUGIN_HOOKS['add_css']['formcreator'][] = "css/styles.css";
    if (strpos($_SERVER['REQUEST_URI'], "front/helpdesk.public.php") !== false) {
        $PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/helpdesk.js';
    } elseif (strpos($_SERVER['REQUEST_URI'], "front/central.php") !== false) {
        $PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/homepage.js';
    }
    if (isset($_SESSION['glpiactiveprofile'])) {
        if ($_SESSION['glpiactiveprofile']['interface'] == 'helpdesk') {
            $PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/helpdesk-menu.js';
        }
    }
    $PLUGIN_HOOKS['add_javascript']['formcreator'][] = 'scripts/forms-validation.js.php';
    // Set the plugin CSRF compliance (required in GLPI 0.84)
    $PLUGIN_HOOKS['csrf_compliant']['formcreator'] = true;
    // Add a link in the main menu plugins for technician and admin panel
    $PLUGIN_HOOKS['menu_entry']['formcreator'] = 'front/formlist.php';
    // Config page
    $plugin = new Plugin();
    $links = array();
    if (Session::haveRight('config', 'w') && $plugin->isActivated("formcreator")) {
        $PLUGIN_HOOKS['config_page']['formcreator'] = 'front/form.php';
        $links['config'] = '/plugins/formcreator/front/form.php';
        $links['add'] = '/plugins/formcreator/front/form.form.php';
    }
    // Set options for pages (title, links, buttons...)
    $links['search'] = '/plugins/formcreator/front/formlist.php';
    $PLUGIN_HOOKS['submenu_entry']['formcreator']['options'] = array('config' => array('title' => __('Setup'), 'page' => '/plugins/formcreator/front/form.php', 'links' => $links), 'options' => array('title' => _n('Form', 'Forms', 2, 'formcreator'), 'links' => $links));
    // Load field class and all its method to manage fields
    Plugin::registerClass('PluginFormcreatorFields');
}
 public function enablePluginBasedService(Plugin $plugin)
 {
     $plugin_based_service = $plugin->getServiceShortname();
     if ($plugin_based_service) {
         $this->list_of_plugin_based_services[] = $plugin_based_service;
     }
 }
 private function getPluginName($pid)
 {
     require_once 'plugin.class.php';
     $currentPlugin = new Plugin();
     $currentPlugin->pid = $pid;
     return json_decode($currentPlugin->getData(), true)['name'];
 }
Пример #18
0
function plugin_init_databases()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['databases'] = true;
    $PLUGIN_HOOKS['change_profile']['databases'] = array('PluginDatabasesProfile', 'initProfile');
    $PLUGIN_HOOKS['assign_to_ticket']['databases'] = true;
    //$PLUGIN_HOOKS['assign_to_ticket_dropdown']['databases'] = true;
    //$PLUGIN_HOOKS['assign_to_ticket_itemtype']['databases'] = array('PluginDatabasesDatabase_Item');
    Plugin::registerClass('PluginDatabasesDatabase', array('linkgroup_tech_types' => true, 'linkuser_tech_types' => true, 'document_types' => true, 'ticket_types' => true, 'helpdesk_visible_types' => true, 'addtabon' => 'Supplier'));
    Plugin::registerClass('PluginDatabasesProfile', array('addtabon' => 'Profile'));
    //Plugin::registerClass('PluginDatabasesDatabase_Item',
    //                      array('ticket_types' => true));
    if (class_exists('PluginAccountsAccount')) {
        PluginAccountsAccount::registerType('PluginDatabasesDatabase');
    }
    if (Session::getLoginUserID()) {
        $plugin = new Plugin();
        if (!$plugin->isActivated('environment') && Session::haveRight("plugin_databases", READ)) {
            $PLUGIN_HOOKS['menu_toadd']['databases'] = array('assets' => 'PluginDatabasesMenu');
        }
        if (Session::haveRight("plugin_databases", UPDATE)) {
            $PLUGIN_HOOKS['use_massive_action']['databases'] = 1;
        }
        if (class_exists('PluginDatabasesDatabase_Item')) {
            // only if plugin activated
            $PLUGIN_HOOKS['plugin_datainjection_populate']['databases'] = 'plugin_datainjection_populate_databases';
        }
        // End init, when all types are registered
        $PLUGIN_HOOKS['post_init']['databases'] = 'plugin_databases_postinit';
        // Import from Data_Injection plugin
        $PLUGIN_HOOKS['migratetypes']['databases'] = 'plugin_datainjection_migratetypes_databases';
    }
}
Пример #19
0
function plugin_init_badges()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['badges'] = true;
    $PLUGIN_HOOKS['assign_to_ticket']['badges'] = true;
    $PLUGIN_HOOKS['change_profile']['badges'] = array('PluginBadgesProfile', 'initProfile');
    if (Session::getLoginUserID()) {
        Plugin::registerClass('PluginBadgesBadge', array('linkuser_types' => true, 'document_types' => true, 'helpdesk_visible_types' => true, 'ticket_types' => true, 'notificationtemplates_types' => true));
        Plugin::registerClass('PluginBadgesProfile', array('addtabon' => 'Profile'));
        Plugin::registerClass('PluginBadgesConfig', array('addtabon' => 'CronTask'));
        if (class_exists('PluginResourcesResource')) {
            PluginResourcesResource::registerType('PluginBadgesBadge');
        }
        $plugin = new Plugin();
        if (!$plugin->isActivated('environment') && Session::haveRight("plugin_badges", READ)) {
            $PLUGIN_HOOKS['menu_toadd']['badges'] = array('assets' => 'PluginBadgesMenu');
        }
        if (Session::haveRight("plugin_badges", UPDATE)) {
            $PLUGIN_HOOKS['use_massive_action']['badges'] = 1;
        }
        if (class_exists('PluginBadgesBadge')) {
            // only if plugin activated
            $PLUGIN_HOOKS['plugin_datainjection_populate']['badges'] = 'plugin_datainjection_populate_badges';
        }
        // Import from Data_Injection plugin
        $PLUGIN_HOOKS['migratetypes']['badges'] = 'plugin_datainjection_migratetypes_badges';
    }
}
Пример #20
0
function plugin_fields_install()
{
    global $CFG_GLPI;
    set_time_limit(900);
    ini_set('memory_limit', '2048M');
    $plugin_fields = new Plugin();
    $plugin_fields->getFromDBbyDir('fields');
    $version = $plugin_fields->fields['version'];
    $classesToInstall = array('PluginFieldsDropdown', 'PluginFieldsField', 'PluginFieldsContainer', 'PluginFieldsContainer_Field', 'PluginFieldsValue', 'PluginFieldsProfile', 'PluginFieldsMigration');
    $migration = new Migration($version);
    echo "<center>";
    echo "<table class='tab_cadre_fixe'>";
    echo "<tr><th>" . __("MySQL tables installation", "fields") . "<th></tr>";
    echo "<tr class='tab_bg_1'>";
    echo "<td align='center'>";
    foreach ($classesToInstall as $class) {
        if ($plug = isPluginItemType($class)) {
            $dir = GLPI_ROOT . "/plugins/fields/inc/";
            $item = strtolower($plug['class']);
            if (file_exists("{$dir}{$item}.class.php")) {
                include_once "{$dir}{$item}.class.php";
                if (!call_user_func(array($class, 'install'), $migration, $version)) {
                    return false;
                }
            }
        }
    }
    echo "</td>";
    echo "</tr>";
    echo "</table></center>";
    return true;
}
Пример #21
0
 /**
  * Load script & styles required for WP Docs search
  */
 public function load_assets()
 {
     $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     wp_register_script('wpkb-search', $this->plugin->url('/assets/js/search' . $min . '.js'), array('jquery'), $this->plugin->version(), true);
     $data = array('ajaxurl' => admin_url('admin-ajax.php'));
     wp_localize_script('wpkb-search', 'wpkb_search_vars', $data);
 }
Пример #22
0
 static function index()
 {
     $plugin = new Plugin();
     global $cfg_rewrite;
     $plugin->assign('cfg_rewrite', $cfg_rewrite);
     $plugin->assign('rewritefile', is_file('.htaccess'));
     return $plugin->display('admin.html');
 }
 /**
  * @see Plugin_Base::is_wpcom_vip_prod()
  */
 function test_is_wpcom_vip_prod()
 {
     if (!defined('WPCOM_IS_VIP_ENV')) {
         $this->assertFalse($this->plugin->is_wpcom_vip_prod());
         define('WPCOM_IS_VIP_ENV', true);
     }
     $this->assertEquals(WPCOM_IS_VIP_ENV, $this->plugin->is_wpcom_vip_prod());
 }
Пример #24
0
 public function testAroundHasOptionsForProductWithoutRecurringPayment()
 {
     $this->product->expects($this->once())->method('getIsRecurring')->will($this->returnValue(false));
     $closure = function ($product) {
         return $product;
     };
     $this->assertSame($this->product, $this->object->aroundHasOptions($this->subject, $closure, $this->product));
 }
Пример #25
0
/**
 * Initializes the plugin.
 *
 * @wp-hook plugins_loaded
 *
 * @return void
 */
function initialize()
{
    if (file_exists(__DIR__ . '/vendor/autoload.php')) {
        require_once __DIR__ . '/vendor/autoload.php';
    }
    $plugin = new Plugin(__FILE__);
    $plugin->initialize();
}
Пример #26
0
 public function factory($id = NULL)
 {
     $obj = new Plugin();
     if (!empty($id)) {
         $obj->get_by_id($id);
     }
     return $obj;
 }
 /**
  * Load script & styles required for WP Docs search
  */
 public function load_assets()
 {
     $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     wp_register_style('wpkb-code-highlighting', $this->wpkb->url('/assets/css/code-highlighting' . $min . '.css'));
     wp_register_script('wpkb-code-highlighting', '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js', array(), false, true);
     wp_enqueue_style('wpkb-code-highlighting');
     wp_enqueue_script('wpkb-code-highlighting');
 }
Пример #28
0
 static function index()
 {
     $plugin = new Plugin();
     $model = M('arctype');
     $list = $model->field("id,typename,concat(path,'-',id) as bpath")->order('bpath')->select();
     $plugin->assign('list', $list);
     return $plugin->display('admin.html');
 }
Пример #29
0
function plugin_init_escalade()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['escalade'] = true;
    $plugin = new Plugin();
    if (isset($_SESSION['glpiID']) && $plugin->isInstalled('escalade') && $plugin->isActivated('escalade')) {
        //load config in session
        if (TableExists("glpi_plugin_escalade_configs")) {
            PluginEscaladeConfig::loadInSession();
            // == Load js scripts ==
            if (isset($_SESSION['plugins']['escalade']['config'])) {
                $escalade_config = $_SESSION['plugins']['escalade']['config'];
                $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/function.js';
                // on central page
                if (strpos($_SERVER['REQUEST_URI'], "central.php") !== false) {
                    //history and climb feature
                    if ($escalade_config['show_history']) {
                        $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/central.js.php';
                    }
                }
                // on ticket page (in edition)
                if (strpos($_SERVER['REQUEST_URI'], "ticket.form.php") !== false && isset($_GET['id'])) {
                    //history and climb feature
                    if ($escalade_config['show_history']) {
                        $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/escalade.js.php';
                    }
                    //remove btn feature
                    if (!$escalade_config['remove_delete_group_btn'] || !$escalade_config['remove_delete_user_btn']) {
                        $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/remove_btn.js.php';
                    }
                    //clone ticket feature
                    if ($escalade_config['cloneandlink_ticket']) {
                        $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/cloneandlink_ticket.js.php';
                    }
                    //filter group feature
                    if ($escalade_config['use_filter_assign_group']) {
                        $PLUGIN_HOOKS['add_javascript']['escalade'][] = 'scripts/filtergroup.js.php';
                    }
                }
                Plugin::registerClass('PluginEscaladeGroup_Group', array('addtabon' => 'Group'));
                Plugin::registerClass('PluginEscaladeUser', array('addtabon' => array('User')));
            }
        }
        $PLUGIN_HOOKS['add_css']['escalade'][] = 'escalade.css';
        // == Ticket modifications
        $PLUGIN_HOOKS['item_update']['escalade'] = array('Ticket' => 'plugin_escalade_item_update');
        $PLUGIN_HOOKS['item_add']['escalade'] = array('Group_Ticket' => 'plugin_escalade_item_add_group_ticket', 'Ticket_User' => 'plugin_escalade_item_add_user', 'Ticket' => 'plugin_escalade_item_add_ticket');
        $PLUGIN_HOOKS['pre_item_add']['escalade'] = array('Group_Ticket' => 'plugin_escalade_pre_item_add_group_ticket', 'Ticket' => 'plugin_escalade_pre_item_add_ticket');
        $PLUGIN_HOOKS['post_prepareadd']['escalade'] = array('Ticket' => 'plugin_escalade_post_prepareadd_ticket');
        $PLUGIN_HOOKS['item_purge']['escalade'] = array('User' => 'plugin_escalade_item_purge');
        $PLUGIN_HOOKS['item_add']['escalade']['User'] = '******';
        // == Interface links ==
        if (Session::haveRight('config', UPDATE)) {
            $PLUGIN_HOOKS['config_page']['escalade'] = 'front/config.form.php';
        }
        $PLUGIN_HOOKS['use_massive_action']['escalade'] = 1;
    }
}
Пример #30
0
 static function index()
 {
     $plugin = new Plugin();
     $config = $plugin->config();
     $width = empty($config['erweima_width']) ? 300 : (int) $config['erweima_width'];
     $height = empty($config['erweima_height']) ? 300 : (int) $config['erweima_height'];
     $url = self::curPageURL();
     return "http://chart.apis.google.com/chart?cht=qr&chs={$width}x{$height}&chl={$url}";
 }