本文整理汇总了PHP中Plugin类的典型用法代码示例。如果您正苦于以下问题:PHP Plugin类的具体用法?PHP Plugin怎么用?PHP Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showAllItems
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}'> </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: testPlugin
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: plugin_init_uninstall
/**
* 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: plugin_init_customfields
/**
* 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: plugin_fields_checkFiles
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);
}
}
}
}
示例6: plugin_init_certificates
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: getItemtypes
/**
* 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: showSummary
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>";
}
示例9: override_templates
/**
* 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: flush_rewrites
/**
* 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();
}
示例11: get_plugin
/**
* 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: plugin_init_pdf
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';
}
}
示例13: plugin_init_surveyticket
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';
}
}
示例14: plugin_init_formcreator
/**
* 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');
}
示例15: enablePluginBasedService
public function enablePluginBasedService(Plugin $plugin)
{
$plugin_based_service = $plugin->getServiceShortname();
if ($plugin_based_service) {
$this->list_of_plugin_based_services[] = $plugin_based_service;
}
}