├── pics └── vip.png ├── locales ├── en_GB.mo ├── fr_FR.mo ├── en_GB.po ├── glpi.pot └── fr_FR.po ├── README.md ├── install ├── sql │ ├── update-1.7.3.sql │ ├── update-1.8.0.sql │ ├── empty-1.1.2.sql │ ├── empty-1.5.0.sql │ ├── empty-1.7.3.sql │ ├── empty-1.8.0.sql │ └── empty-1.0.0.sql └── index.php ├── tools ├── extract_template.sh ├── update_mo.pl └── update_po.pl ├── .github └── workflows │ ├── updatepot.yml │ ├── generatemo.yml │ └── release.yml ├── vip_load_scripts.js.php ├── index.php ├── ajax ├── index.php ├── loadscripts.php ├── ticket.php └── getDropdownUsers.php ├── front ├── index.php ├── rulevip.php ├── rulevip.form.php ├── group.form.php ├── rulesengine.test.php └── rule.test.php ├── inc ├── index.php ├── rulevipcollection.class.php ├── rulevip.class.php ├── vip.class.php ├── ticket.class.php ├── dashboard.class.php ├── profile.class.php └── group.class.php ├── setup.php ├── vip.xml ├── vip.js.php ├── hook.php └── LICENSE /pics/vip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/vip/master/pics/vip.png -------------------------------------------------------------------------------- /locales/en_GB.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/vip/master/locales/en_GB.mo -------------------------------------------------------------------------------- /locales/fr_FR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/vip/master/locales/fr_FR.mo -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vip 2 | VIP Plugin for GLPI 3 | 4 | Plugin migrated to https://github.com/pluginsGLPI/vip 5 | -------------------------------------------------------------------------------- /install/sql/update-1.7.3.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `glpi_plugin_vip_groups` ADD 2 | `vip_color` varchar(10) DEFAULT '#ff0000' NOT NULL; -------------------------------------------------------------------------------- /install/sql/update-1.8.0.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `glpi_plugin_vip_groups` ADD `vip_icon` varchar(100) DEFAULT 'fa-exclamation-triangle'; 2 | ALTER TABLE `glpi_plugin_vip_groups` ADD `name` varchar(100) DEFAULT 'VIP'; 3 | -------------------------------------------------------------------------------- /tools/extract_template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Only strings with domain specified are extracted (use Xt args of keyword param to set number of args needed) 4 | 5 | xgettext *.php */*.php --copyright-holder='VIP Development Team' --package-name='GLPI - VIP plugin' -o locales/glpi.pot -L PHP --add-comments=TRANS --from-code=UTF-8 --force-po \ 6 | --keyword=_n:1,2,4t --keyword=__s:1,2t --keyword=__:1,2t --keyword=_e:1,2t --keyword=_x:1c,2,3t \ 7 | --keyword=_ex:1c,2,3t --keyword=_nx:1c,2,3,5t --keyword=_sx:1c,2,3t -------------------------------------------------------------------------------- /install/sql/empty-1.1.2.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Structure de la table 'glpi_plugin_vip_groups' 3 | -- -------------------------------------------------------- 4 | CREATE TABLE `glpi_plugin_vip_groups` ( 5 | `id` int(11) NOT NULL default 0 COMMENT 'RELATION to glpi_groups(id)', 6 | `isvip` tinyint(1) default '0', 7 | PRIMARY KEY (`id`) 8 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 9 | 10 | INSERT INTO `glpi_plugin_vip_groups` (`id`, `isvip`) VALUES ('0', '0'); 11 | -------------------------------------------------------------------------------- /install/sql/empty-1.5.0.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Structure de la table 'glpi_plugin_vip_groups' 3 | -- -------------------------------------------------------- 4 | CREATE TABLE `glpi_plugin_vip_groups` ( 5 | `id` int(11) NOT NULL default 0 COMMENT 'RELATION to glpi_groups(id)', 6 | `isvip` tinyint(1) default '0', 7 | PRIMARY KEY (`id`) 8 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 9 | 10 | INSERT INTO `glpi_plugin_vip_groups` (`id`, `isvip`) VALUES ('0', '0'); 11 | -------------------------------------------------------------------------------- /install/sql/empty-1.7.3.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Structure de la table 'glpi_plugin_vip_groups' 3 | -- -------------------------------------------------------- 4 | CREATE TABLE `glpi_plugin_vip_groups` ( 5 | `id` int(11) NOT NULL default 0 COMMENT 'RELATION to glpi_groups(id)', 6 | `isvip` tinyint(1) default '0', 7 | `vip_color` varchar(10) DEFAULT '#ff0000' NOT NULL, 8 | PRIMARY KEY (`id`) 9 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 10 | 11 | INSERT INTO `glpi_plugin_vip_groups` (`id`, `isvip`) VALUES ('0', '0'); 12 | -------------------------------------------------------------------------------- /tools/update_mo.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | #!/usr/bin/perl -w 3 | 4 | if (@ARGV!=0){ 5 | print "USAGE update_mo.pl\n\n"; 6 | 7 | exit(); 8 | } 9 | 10 | 11 | opendir(DIRHANDLE,'locales')||die "ERROR: can not read current directory\n"; 12 | foreach (readdir(DIRHANDLE)){ 13 | if ($_ ne '..' && $_ ne '.'){ 14 | 15 | if(!(-l "$dir/$_")){ 16 | if (index($_,".po",0)==length($_)-3) { 17 | $lang=$_; 18 | $lang=~s/\.po//; 19 | 20 | `msgfmt locales/$_ -o locales/$lang.mo`; 21 | } 22 | } 23 | 24 | } 25 | } 26 | closedir DIRHANDLE; 27 | 28 | # 29 | # 30 | -------------------------------------------------------------------------------- /install/sql/empty-1.8.0.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Structure de la table 'glpi_plugin_vip_groups' 3 | -- -------------------------------------------------------- 4 | CREATE TABLE `glpi_plugin_vip_groups` ( 5 | `id` int unsigned NOT NULL default 0 COMMENT 'RELATION to glpi_groups(id)', 6 | `name` varchar(100) DEFAULT 'VIP', 7 | `isvip` tinyint default '0', 8 | `vip_color` varchar(10) DEFAULT '#ff0000' NOT NULL, 9 | `vip_icon` varchar(100) DEFAULT 'fa-exclamation-triangle', 10 | PRIMARY KEY (`id`) 11 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC; 12 | 13 | INSERT INTO `glpi_plugin_vip_groups` (`id`, `isvip`) VALUES ('0', '0'); 14 | -------------------------------------------------------------------------------- /.github/workflows/updatepot.yml: -------------------------------------------------------------------------------- 1 | name: Update POT 2 | on: 3 | push: 4 | branches: [ master ] 5 | paths-ignore: 6 | - 'locales/**' 7 | 8 | env: 9 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 10 | jobs: 11 | run: 12 | 13 | name: Update POT 14 | 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout repo 18 | uses: actions/checkout@v2 19 | 20 | - name: install xgettext 21 | 22 | run: sudo apt-get install gettext; 23 | - name: Update POT 24 | run: sh tools/extract_template.sh; 25 | 26 | 27 | - name: Commit changes 28 | uses: EndBug/add-and-commit@v5.1.0 29 | with: 30 | message: "Update POT" 31 | - name: Push changes 32 | 33 | uses: actions-go/push@v1 34 | 35 | -------------------------------------------------------------------------------- /tools/update_po.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | #!/usr/bin/perl -w 3 | 4 | if (@ARGV!=2){ 5 | print "USAGE update_po.pl transifex_login transifex_password\n\n"; 6 | 7 | exit(); 8 | } 9 | $user = $ARGV[0]; 10 | $password = $ARGV[1]; 11 | 12 | opendir(DIRHANDLE,'locales')||die "ERROR: can not read current directory\n"; 13 | foreach (readdir(DIRHANDLE)){ 14 | if ($_ ne '..' && $_ ne '.'){ 15 | 16 | if(!(-l "$dir/$_")){ 17 | if (index($_,".po",0)==length($_)-3) { 18 | $lang=$_; 19 | $lang=~s/\.po//; 20 | 21 | `wget --user=$user --password=$password --output-document=locales/$_ http://www.transifex.com/api/2/project/GLPI_vip/resource/glpipot/translation/$lang/?file=$_`; 22 | } 23 | } 24 | 25 | } 26 | } 27 | closedir DIRHANDLE; 28 | 29 | # 30 | # 31 | -------------------------------------------------------------------------------- /vip_load_scripts.js.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | var root_vip_doc = ""; 9 | (function ($) { 10 | 11 | $.fn.vip_load_scripts = function () { 12 | 13 | init(); 14 | // Start the plugin 15 | function init() { 16 | // Send data 17 | $.ajax({ 18 | url: root_vip_doc +'/ajax/loadscripts.php', 19 | type: "POST", 20 | dataType: "html", 21 | data: 'action=load', 22 | success: function (response, opts) { 23 | var scripts, scriptsFinder = /]*>([\s\S]+?)<\/script>/gi; 24 | while (scripts = scriptsFinder.exec(response)) { 25 | eval(scripts[1]); 26 | } 27 | } 28 | }); 29 | } 30 | 31 | return this; 32 | }; 33 | }(jQuery)); 34 | 35 | $(document).vip_load_scripts(); 36 | -------------------------------------------------------------------------------- /.github/workflows/generatemo.yml: -------------------------------------------------------------------------------- 1 | name: Generate MO 2 | on: 3 | push: 4 | branches: [ master ] 5 | paths: 6 | - '**.po' 7 | env: 8 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 9 | jobs: 10 | run: 11 | 12 | name: Generate mo 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout repo 16 | uses: actions/checkout@v2 17 | 18 | - name: Setup Perl environment 19 | # You may pin to the exact commit or the version. 20 | # uses: shogo82148/actions-setup-perl@8d2e3d59a9516b785ed32169d48a4888eaa9b514 21 | uses: shogo82148/actions-setup-perl@v1.7.2 22 | - name: msgfmt 23 | # You may pin to the exact commit or the version. 24 | # uses: whtsky/msgfmt-action@6b2181f051b002182d01a1e1f1aff216230c5a4d 25 | uses: whtsky/msgfmt-action@20190305 26 | - name: Generate mo 27 | run: perl tools/update_mo.pl; 28 | 29 | - name: Commit changes 30 | uses: EndBug/add-and-commit@v5.1.0 31 | with: 32 | 33 | message: "Generate mo" 34 | - name: Push changes 35 | 36 | uses: actions-go/push@v1 37 | 38 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | -------------------------------------------------------------------------------- /ajax/index.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | -------------------------------------------------------------------------------- /front/index.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | -------------------------------------------------------------------------------- /inc/index.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | -------------------------------------------------------------------------------- /install/index.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | -------------------------------------------------------------------------------- /locales/en_GB.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR VIP Development Team 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: GLPI - VIP plugin 1.4.0\n" 9 | "Report-Msgid-Bugs-To: \n" 10 | "POT-Creation-Date: 2017-10-24 09:15+0200\n" 11 | "PO-Revision-Date: 2019-02-25 10:00+0100\n" 12 | "MIME-Version: 1.0\n" 13 | "Content-Type: text/plain; charset=UTF-8\n" 14 | "Content-Transfer-Encoding: 8bit\n" 15 | "Language: en_GB\n" 16 | "Last-Translator: \n" 17 | "Language-Team: \n" 18 | "X-Generator: Poedit 2.0.9\n" 19 | 20 | #: inc/dashboard.class.php:42 inc/dashboard.class.php:196 21 | msgid "Tickets VIP" 22 | msgstr "Tickets VIP" 23 | 24 | #: inc/group.class.php:62 25 | msgid "VIP management" 26 | msgstr "VIP management" 27 | 28 | #: inc/group.class.php:66 inc/group.class.php:135 29 | msgid "VIP group" 30 | msgstr "VIP group" 31 | 32 | #: inc/group.class.php:86 inc/profile.class.php:53 inc/profile.class.php:132 33 | #: inc/vip.class.php:46 34 | msgid "VIP" 35 | msgstr "VIP" 36 | 37 | #: inc/rulevipcollection.class.php:48 38 | msgid "Rules for assigning a group" 39 | msgstr "Rules for assigning a group" 40 | -------------------------------------------------------------------------------- /front/rulevip.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | include('../../../inc/includes.php'); 31 | 32 | $rulecollection = new PluginVipRuleVipCollection($_SESSION['glpiactive_entity']); 33 | 34 | include(GLPI_ROOT . "/front/rule.common.php"); 35 | -------------------------------------------------------------------------------- /front/rulevip.form.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | include('../../../inc/includes.php'); 31 | 32 | $rulecollection = new PluginVipRuleVipCollection($_SESSION['glpiactive_entity']); 33 | 34 | include(GLPI_ROOT . "/front/rule.common.form.php"); 35 | -------------------------------------------------------------------------------- /front/group.form.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | include("../../../inc/includes.php"); 31 | 32 | Session::checkRight("plugin_vip", UPDATE); 33 | 34 | $grp = new PluginVipGroup(); 35 | 36 | if (isset($_POST['update_vip_group'])) { 37 | $grp->update($_POST); 38 | Html::back(); 39 | } 40 | -------------------------------------------------------------------------------- /install/sql/empty-1.0.0.sql: -------------------------------------------------------------------------------- 1 | -- -------------------------------------------------------- 2 | -- Structure de la table 'glpi_plugin_vip_profiles' 3 | -- -------------------------------------------------------- 4 | CREATE TABLE `glpi_plugin_vip_profiles` ( 5 | `id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)', 6 | `show_vip_tab` tinyint(1) collate utf8_unicode_ci default NULL, 7 | PRIMARY KEY (`id`) 8 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 9 | 10 | -- -------------------------------------------------------- 11 | -- Structure de la table 'glpi_plugin_vip_groups' 12 | -- -------------------------------------------------------- 13 | CREATE TABLE `glpi_plugin_vip_groups` ( 14 | `id` int(11) NOT NULL default 0 COMMENT 'RELATION to glpi_groups(id)', 15 | `isvip` tinyint(1) default '0', 16 | PRIMARY KEY (`id`) 17 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 18 | 19 | 20 | INSERT INTO `glpi_plugin_vip_groups` (`id`, `isvip`) VALUES ('0', '0'); 21 | 22 | -- -------------------------------------------------------- 23 | -- Structure de la table 'glpi_plugin_vip_tickets' 24 | -- -------------------------------------------------------- 25 | CREATE TABLE glpi_plugin_vip_tickets ( 26 | `id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_tickets (id)', 27 | `isvip` tinyint(1) default '0', 28 | PRIMARY KEY (`id`) 29 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -------------------------------------------------------------------------------- /locales/glpi.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR VIP Development Team 3 | # This file is distributed under the same license as the GLPI - VIP plugin package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: GLPI - VIP plugin\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2022-07-26 14:11+0000\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=CHARSET\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: inc/dashboard.class.php:43 21 | msgid "Tables" 22 | msgstr "" 23 | 24 | #: inc/dashboard.class.php:44 inc/dashboard.class.php:189 25 | msgid "Tickets VIP" 26 | msgstr "" 27 | 28 | #: inc/group.class.php:62 29 | msgid "VIP management" 30 | msgstr "" 31 | 32 | #: inc/group.class.php:71 inc/group.class.php:228 33 | msgid "VIP group" 34 | msgstr "" 35 | 36 | #: inc/group.class.php:76 37 | msgid "VIP color" 38 | msgstr "" 39 | 40 | #: inc/group.class.php:84 41 | msgid "VIP Icon" 42 | msgstr "" 43 | 44 | #: inc/group.class.php:141 inc/profile.class.php:53 inc/profile.class.php:132 45 | #: inc/vip.class.php:46 46 | msgid "VIP" 47 | msgstr "" 48 | 49 | #: inc/rulevipcollection.class.php:51 50 | msgid "Rules for assigning a group" 51 | msgstr "" 52 | 53 | #: inc/ticket.class.php:158 54 | msgid "This ticket concerns at least one" 55 | msgstr "" 56 | 57 | #: inc/ticket.class.php:168 58 | msgid "This computer is used by a" 59 | msgstr "" 60 | 61 | #: inc/ticket.class.php:173 62 | msgid "This printer is used by a" 63 | msgstr "" 64 | -------------------------------------------------------------------------------- /inc/rulevipcollection.class.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | if (!defined('GLPI_ROOT')) { 31 | die("Sorry. You can't access directly to this file"); 32 | } 33 | 34 | /** 35 | * Class PluginVipRuleVipCollection 36 | */ 37 | class PluginVipRuleVipCollection extends RuleCollection { 38 | 39 | // From RuleCollection 40 | public static $rightname = 'plugin_vip'; 41 | public $menu_option = 'vip'; 42 | 43 | static function canView() { 44 | return Session::haveRight(self::$rightname, UPDATE); 45 | } 46 | /** 47 | * @return translated 48 | */ 49 | function getTitle() { 50 | 51 | return __('Rules for assigning a group', 'vip'); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /locales/fr_FR.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR VIP Development Team 3 | # This file is distributed under the same license as the GLPI - VIP plugin package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | # Translators: 7 | # Xavier CAILLAUD , 2021 8 | # 9 | #, fuzzy 10 | msgid "" 11 | msgstr "" 12 | "Project-Id-Version: GLPI - VIP plugin\n" 13 | "Report-Msgid-Bugs-To: \n" 14 | "POT-Creation-Date: 2021-12-08 10:46+0000\n" 15 | "PO-Revision-Date: 2020-11-02 16:30+0000\n" 16 | "Last-Translator: Xavier CAILLAUD , 2021\n" 17 | "Language-Team: French (France) (https://www.transifex.com/infotelGLPI/teams/79828/fr_FR/)\n" 18 | "MIME-Version: 1.0\n" 19 | "Content-Type: text/plain; charset=UTF-8\n" 20 | "Content-Transfer-Encoding: 8bit\n" 21 | "Language: fr_FR\n" 22 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 23 | 24 | #: inc/dashboard.class.php:43 25 | msgid "Tables" 26 | msgstr "Tableaux" 27 | 28 | #: inc/dashboard.class.php:44 inc/dashboard.class.php:189 29 | msgid "Tickets VIP" 30 | msgstr "Tickets VIP" 31 | 32 | #: inc/group.class.php:62 33 | msgid "VIP management" 34 | msgstr "Gestion VIP" 35 | 36 | #: inc/group.class.php:71 inc/group.class.php:228 37 | msgid "VIP group" 38 | msgstr "Groupe VIP" 39 | 40 | #: inc/group.class.php:76 41 | msgid "VIP color" 42 | msgstr "Couleur VIP" 43 | 44 | #: inc/group.class.php:84 45 | msgid "VIP Icon" 46 | msgstr "Icône VIP" 47 | 48 | #: inc/group.class.php:141 inc/profile.class.php:53 inc/profile.class.php:132 49 | #: inc/vip.class.php:46 50 | msgid "VIP" 51 | msgstr "VIP" 52 | 53 | #: inc/rulevipcollection.class.php:51 54 | msgid "Rules for assigning a group" 55 | msgstr "Règles d'attribution d'un groupe" 56 | 57 | #: inc/ticket.class.php:146 58 | msgid "This ticket concerns at least one" 59 | msgstr "Ce ticket concerne au moins un" 60 | 61 | #: inc/ticket.class.php:156 62 | msgid "This computer is used by a" 63 | msgstr "Cet ordinateur est utilisé par un" 64 | 65 | #: inc/ticket.class.php:161 66 | msgid "This printer is used by a" 67 | msgstr "Cette imprimante est utilisée par un" 68 | -------------------------------------------------------------------------------- /ajax/loadscripts.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | include('../../../inc/includes.php'); 31 | 32 | Html::header_nocache(); 33 | Session::checkLoginUser(); 34 | header("Content-Type: text/html; charset=UTF-8"); 35 | 36 | switch ($_POST['action']) { 37 | case "load" : 38 | $vip_group = new PluginVipGroup(); 39 | $vip = $vip_group->getVipUsers(); 40 | 41 | $params = []; 42 | $params['page_limit'] = $CFG_GLPI['dropdown_max']; 43 | $params['root_doc'] = $CFG_GLPI['root_doc']; 44 | $params['minimumResultsForSearch'] = $CFG_GLPI['ajax_limit_count']; 45 | $params['emptyValue'] = Dropdown::EMPTY_VALUE; 46 | 47 | echo ""; 51 | break; 52 | } 53 | -------------------------------------------------------------------------------- /front/rulesengine.test.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | if (!defined('GLPI_ROOT')) { 31 | include('../../../inc/includes.php'); 32 | } 33 | 34 | Session::checkCentralAccess(); 35 | 36 | if (isset($_POST["sub_type"])) { 37 | $sub_type = $_POST["sub_type"]; 38 | } else if (isset($_GET["sub_type"])) { 39 | $sub_type = $_GET["sub_type"]; 40 | } else { 41 | $sub_type = 0; 42 | } 43 | 44 | if (isset($_POST["condition"])) { 45 | $condition = $_POST["condition"]; 46 | } else if (isset($_GET["condition"])) { 47 | $condition = $_GET["condition"]; 48 | } else { 49 | $condition = 0; 50 | } 51 | 52 | $rulecollection = RuleCollection::getClassByType($sub_type); 53 | if ($rulecollection->isRuleRecursive()) { 54 | $rulecollection->setEntity($_SESSION['glpiactive_entity']); 55 | } 56 | $rulecollection->checkGlobal(READ); 57 | 58 | Html::popHeader(__('Setup'), $_SERVER['PHP_SELF']); 59 | 60 | // Need for RuleEngines 61 | foreach ($_POST as $key => $val) { 62 | $_POST[$key] = stripslashes($_POST[$key]); 63 | } 64 | $input = $rulecollection->showRulesEnginePreviewCriteriasForm($_SERVER['PHP_SELF'], $_POST, $condition); 65 | 66 | if (isset($_POST["test_all_rules"])) { 67 | //Unset values that must not be processed by the rule 68 | unset($_POST["sub_type"]); 69 | unset($_POST["test_all_rules"]); 70 | 71 | echo "
"; 72 | $rulecollection->showRulesEnginePreviewResultsForm($_SERVER['PHP_SELF'], $_POST, $condition); 73 | } 74 | 75 | Html::popFooter(); 76 | -------------------------------------------------------------------------------- /front/rule.test.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | if (!defined('GLPI_ROOT')) { 31 | include('../../../inc/includes.php'); 32 | } 33 | 34 | Session::checkCentralAccess(); 35 | 36 | if (isset($_POST["sub_type"])) { 37 | $sub_type = $_POST["sub_type"]; 38 | } else if (isset($_GET["sub_type"])) { 39 | $sub_type = $_GET["sub_type"]; 40 | } else { 41 | $sub_type = 0; 42 | } 43 | 44 | if (isset($_POST["rules_id"])) { 45 | $rules_id = $_POST["rules_id"]; 46 | } else if (isset($_GET["rules_id"])) { 47 | $rules_id = $_GET["rules_id"]; 48 | } else { 49 | $rules_id = 0; 50 | } 51 | 52 | $dbu = new DbUtils(); 53 | 54 | if (!$rule = $dbu->getItemForItemtype($sub_type)) { 55 | exit; 56 | } 57 | $rule->checkGlobal(READ); 58 | 59 | $test_rule_output = null; 60 | 61 | Html::popHeader(__('Setup'), $_SERVER['PHP_SELF']); 62 | 63 | $rule->showRulePreviewCriteriasForm($_SERVER['PHP_SELF'], $rules_id); 64 | 65 | if (isset($_POST["test_rule"])) { 66 | $params = []; 67 | //Unset values that must not be processed by the rule 68 | unset($_POST["test_rule"]); 69 | unset($_POST["rules_id"]); 70 | unset($_POST["sub_type"]); 71 | $rule->getRuleWithCriteriasAndActions($rules_id, 1, 1); 72 | 73 | // Need for RuleEngines 74 | foreach ($_POST as $key => $val) { 75 | $_POST[$key] = stripslashes($_POST[$key]); 76 | } 77 | //Add rules specific POST fields to the param array 78 | $params = $rule->addSpecificParamsForPreview($params); 79 | 80 | $input = $rule->prepareAllInputDataForProcess($_POST, $params); 81 | //$rule->regex_results = []; 82 | echo "
"; 83 | $rule->showRulePreviewResultsForm($_SERVER['PHP_SELF'], $input, $params); 84 | } 85 | 86 | Html::popFooter(); 87 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | 2 | on: 3 | push: 4 | # Sequence of patterns matched against refs/tags 5 | tags: 6 | - '*.*.*' # Push events to matching ex:20.15.10 7 | 8 | name: Create release with tag 9 | env: 10 | TAG_VALUE: ${GITHUB_REF/refs\/tags\//} 11 | jobs: 12 | build: 13 | name: Upload Release Asset 14 | runs-on: ubuntu-latest 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v2 18 | - name: Build project # This would actually build your project, using zip for an example artifact 19 | id: build_ 20 | env: 21 | GITHUB_NAME: ${{ github.event.repository.name }} 22 | 23 | 24 | run: sudo apt-get install libxml-xpath-perl;echo $(xpath -e '/root/versions/version[num="'${GITHUB_REF/refs\/tags\//}'"]/compatibility/text()' $GITHUB_NAME.xml);echo ::set-output name=version_glpi::$(xpath -e '/root/versions/version[num="'${GITHUB_REF/refs\/tags\//}'"]/compatibility/text()' $GITHUB_NAME.xml); rm -rf $GITHUB_NAME.xml tools wiki screenshots test .git .github ISSUE_TEMPLATE.md TODO.txt $GITHUB_NAME.png;cd ..; tar jcvf glpi-$GITHUB_NAME-${GITHUB_REF/refs\/tags\//}.tar.bz2 $GITHUB_NAME;ls -al;echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//};echo ${{ steps.getxml.outputs.info }}; 25 | # run: rm -rf $GITHUB_NAME.xml tools wiki screenshots test ISSUE_TEMPLATE.md TODO.txt $GITHUB_NAME.png; tar -zcvf glpi-$GITHUB_NAME-$GITHUB_TAG.tar.gz $GITHUB_NAME 26 | - name: Create Release 27 | id: create_release 28 | uses: actions/create-release@v1 29 | env: 30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 31 | with: 32 | tag_name: ${{ github.ref }} 33 | release_name: | 34 | GLPI ${{ steps.build_.outputs.version_glpi }} : Version ${{ github.ref }} disponible / available 35 | body : Version ${{ steps.build_.outputs.tag }} released for GLPI ${{ steps.build_.outputs.version_glpi }} 36 | draft: false 37 | prerelease: true 38 | - name: Upload Release Asset 39 | id: upload-release-asset 40 | uses: actions/upload-release-asset@v1 41 | env: 42 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 43 | GITHUB_NAME: ${{ github.event.repository.name }} 44 | with: 45 | upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 46 | asset_path: /home/runner/work/${{ github.event.repository.name }}/glpi-${{ github.event.repository.name }}-${{ steps.build_.outputs.tag }}.tar.bz2 47 | asset_name: glpi-${{ github.event.repository.name }}-${{ steps.build_.outputs.tag }}.tar.bz2 48 | asset_content_type: application/zip 49 | 50 | -------------------------------------------------------------------------------- /setup.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | define('PLUGIN_VIP_VERSION', '1.8.1'); 31 | 32 | if (!defined("PLUGIN_VIP_DIR")) { 33 | define("PLUGIN_VIP_DIR", Plugin::getPhpDir("vip")); 34 | define("PLUGIN_VIP_NOTFULL_DIR", Plugin::getPhpDir("vip",false)); 35 | define("PLUGIN_VIP_WEBDIR", Plugin::getWebDir("vip")); 36 | } 37 | 38 | // Init the hooks of the plugins -Needed 39 | function plugin_init_vip() { 40 | 41 | global $PLUGIN_HOOKS; 42 | 43 | $PLUGIN_HOOKS['csrf_compliant']['vip'] = true; 44 | 45 | Plugin::registerClass('PluginVipProfile', ['addtabon' => ['Profile']]); 46 | $PLUGIN_HOOKS['change_profile']['vip'] = ['PluginVipProfile', 'changeProfile']; 47 | 48 | if (Session::haveRight('plugin_vip', UPDATE)) { 49 | Plugin::registerClass('PluginVipGroup', ['addtabon' => ['Group']]); 50 | $PLUGIN_HOOKS['use_massive_action']['vip'] = 1; 51 | Plugin::registerClass('PluginVipTicket'); 52 | } 53 | 54 | if (class_exists('PluginMydashboardMenu')) { 55 | $PLUGIN_HOOKS['mydashboard']['vip'] = ["PluginVipDashboard"]; 56 | } 57 | 58 | if (Session::haveRight('plugin_vip', READ) 59 | && isset($_SESSION["glpiactiveprofile"]["interface"]) 60 | && $_SESSION["glpiactiveprofile"]["interface"] != "helpdesk") { 61 | 62 | $PLUGIN_HOOKS['add_javascript']['vip'][] = 'vip.js.php'; 63 | $PLUGIN_HOOKS["javascript"]['vip'] = [PLUGIN_VIP_NOTFULL_DIR."/vip.js.php"]; 64 | 65 | if (class_exists('PluginVipTicket')) { 66 | foreach (PluginVipTicket::$types as $item) { 67 | if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], strtolower($item) . ".form.php") !== false) { 68 | $PLUGIN_HOOKS['add_javascript']['vip'][] = 'vip_load_scripts.js.php'; 69 | $PLUGIN_HOOKS['javascript']['vip'] = [ 70 | PLUGIN_VIP_NOTFULL_DIR. "/vip_load_scripts.js.php", 71 | ]; 72 | } 73 | } 74 | } 75 | } 76 | if (isset($_SESSION["glpiactiveprofile"]["interface"]) 77 | && $_SESSION["glpiactiveprofile"]["interface"] != "helpdesk") { 78 | $PLUGIN_HOOKS['pre_show_item']['vip'] = ['PluginVipTicket', 'showVIPInfos']; 79 | } 80 | $PLUGIN_HOOKS['item_add']['vip'] = ['User' => ['PluginVipVip', 'afterAdd']]; 81 | $PLUGIN_HOOKS['item_update']['vip'] = ['User' => ['PluginVipVip', 'afterUpdate']]; 82 | 83 | Plugin::registerClass('PluginVipRuleVipCollection', [ 84 | 'rulecollections_types' => true 85 | ]); 86 | } 87 | 88 | function plugin_version_vip() { 89 | 90 | return ['name' => "VIP", 91 | 'version' => PLUGIN_VIP_VERSION, 92 | 'author' => 'Probesys & Infotel', 93 | 'license' => 'GPLv2+', 94 | 'homepage' => 'https://github.com/InfotelGLPI/vip', 95 | 'requirements' => [ 96 | 'glpi' => [ 97 | 'min' => '10.0', 98 | 'max' => '11.0', 99 | 'dev' => false 100 | ] 101 | ] 102 | ]; 103 | } 104 | -------------------------------------------------------------------------------- /ajax/ticket.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | define('GLPI_ROOT', '../../..'); 31 | 32 | include(GLPI_ROOT . "/inc/includes.php"); 33 | 34 | Session::checkLoginUser(); 35 | //Html::header_nocache(); 36 | 37 | switch ($_POST['action']) { 38 | case 'getTicket': 39 | header('Content-Type: application/json; charset=UTF-8"'); 40 | 41 | $params = ['entities_id' => (is_array($_SESSION['glpiactiveentities']) ? json_encode(array_values($_SESSION['glpiactiveentities'])) : $_SESSION['glpiactiveentities']), 42 | 'used' => []]; 43 | 44 | if (isset($_POST['items_id'])) { 45 | $ticket = new Ticket(); 46 | $actor = new Ticket_User(); 47 | if($ticket->getFromDB($_POST['items_id'])) { 48 | $actors = $actor->getActors($_POST['items_id']); 49 | 50 | $used = []; 51 | if (isset($actors[CommonITILActor::REQUESTER])) { 52 | foreach ($actors[CommonITILActor::REQUESTER] as $requesters) { 53 | $used[] = $requesters['users_id']; 54 | } 55 | } 56 | 57 | $params = ['used' => $used, 58 | 'entities_id' => $ticket->fields['entities_id']]; 59 | } 60 | } 61 | 62 | echo json_encode($params); 63 | break; 64 | case 'getVIP': 65 | header('Content-Type: application/json; charset=UTF-8"'); 66 | 67 | $params = ['entities_id' => (is_array($_SESSION['glpiactiveentities']) ? json_encode(array_values($_SESSION['glpiactiveentities'])) : $_SESSION['glpiactiveentities']), 68 | 'used' => []]; 69 | 70 | $used = PluginVipTicket::getUserVipList($params['entities_id']); 71 | 72 | if (count($used) > 0) { 73 | $params = ['used' => $used]; 74 | } 75 | 76 | echo json_encode($params); 77 | break; 78 | case 'getPrinter': 79 | header('Content-Type: application/json; charset=UTF-8"'); 80 | 81 | $params = ['entities_id' => (is_array($_SESSION['glpiactiveentities']) ? json_encode(array_values($_SESSION['glpiactiveentities'])) : $_SESSION['glpiactiveentities']), 82 | 'used' => []]; 83 | 84 | if (isset($_POST['items_id'])) { 85 | $printer = new Printer(); 86 | $printer->getFromDB($_POST['items_id']); 87 | 88 | $used = []; 89 | $used[] = $printer->fields['users_id']; 90 | 91 | 92 | $params = ['used' => $used, 93 | 'entities_id' => $printer->fields['entities_id']]; 94 | } 95 | 96 | echo json_encode($params); 97 | break; 98 | case 'getComputer': 99 | header('Content-Type: application/json; charset=UTF-8"'); 100 | 101 | $params = ['entities_id' => (is_array($_SESSION['glpiactiveentities']) ? json_encode(array_values($_SESSION['glpiactiveentities'])) : $_SESSION['glpiactiveentities']), 102 | 'used' => []]; 103 | 104 | if (isset($_POST['items_id'])) { 105 | $computer = new Computer(); 106 | $computer->getFromDB($_POST['items_id']); 107 | 108 | $used = []; 109 | $used[] = $computer->fields['users_id']; 110 | 111 | 112 | $params = ['used' => $used, 113 | 'entities_id' => $computer->fields['entities_id']]; 114 | } 115 | echo json_encode($params); 116 | break; 117 | } 118 | -------------------------------------------------------------------------------- /vip.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VIP Infotel 4 | vip 5 | stable 6 | https://raw.githubusercontent.com/InfotelGLPI/vip/master/pics/vip.png 7 | 8 | 9 | 10 | 11 | 12 | 13 | * Paramétrage dans l'interface du groupe :
- Création d'un groupe, indication dans l'onget "VIP" du paramètre si oui ou non "Groupe VIP"
* Indication dans l'interface du ticket par un logo "VIP" et colorisation du nom de l'utilisateur en rouge si le demandeur du ticket fait partie d'un groupe VIP]]>
14 | * Parameter setting in the group interface:
- Creation of a group, indication in the "VIP" window of the parameter if yes or no "VIP Group".
* Indication in the ticket interface by a "VIP" logo and colouring of the user's name in red if the ticket requester belongs to a VIP group]]>
15 |
16 |
17 | https://github.com/InfotelGLPI/vip 18 | https://github.com/InfotelGLPI/vip/releases 19 | https://github.com/InfotelGLPI/vip/issues 20 | https://raw.githubusercontent.com/InfotelGLPI/vip/master/README.md 21 | 22 | Infotel 23 | 24 | 25 | 26 | 1.8.1 27 | ~10.0 28 | https://github.com/InfotelGLPI/vip/releases/download/1.8.1/glpi-vip-1.8.1.tar.bz2 29 | 30 | 31 | 1.8.0 32 | ~10.0 33 | https://github.com/InfotelGLPI/vip/releases/download/1.8.0/glpi-vip-1.8.0.tar.bz2 34 | 35 | 36 | 1.8.0-rc2 37 | ~10.0 38 | https://github.com/InfotelGLPI/vip/releases/download/1.8.0-rc2/glpi-vip-1.8.0-rc2.tar.bz2 39 | 40 | 41 | 1.8.0-rc1 42 | ~10.0 43 | https://github.com/InfotelGLPI/vip/releases/download/1.8.0-rc1/glpi-vip-1.8.0-rc1.tar.bz2 44 | 45 | 46 | 1.7.2 47 | ~9.5.0 48 | https://github.com/InfotelGLPI/vip/releases/download/1.7.2/glpi-vip-1.7.2.tar.gz 49 | 50 | 51 | 1.7.1 52 | ~9.5.0 53 | 54 | 55 | 1.7.0 56 | ~9.5.0 57 | 58 | 59 | 1.6.0 60 | 9.4 61 | 62 | 63 | 1.5.2 64 | 9.3 65 | 66 | 67 | 1.5.1 68 | 9.3 69 | 70 | 71 | 1.5.0 72 | 9.3 73 | 74 | 75 | 1.4.0 76 | 9.2 77 | 78 | 79 | 80 | en_GB 81 | fr_FR 82 | 83 | 84 | 85 | 86 | Groupes 87 | Ticket 88 | Helpdesk 89 | 90 | 91 | Groups 92 | Ticket 93 | Assistance 94 | 95 | 96 |
97 | -------------------------------------------------------------------------------- /inc/rulevip.class.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | if (!defined('GLPI_ROOT')) { 31 | die("Sorry. You can't access directly to this file"); 32 | } 33 | 34 | /** 35 | * Rule class store all informations about a GLPI rule : 36 | * - description 37 | * - criterias 38 | * - actions 39 | * 40 | * */ 41 | class PluginVipRuleVip extends Rule { 42 | 43 | // From Rule 44 | public static $rightname = 'plugin_vip'; 45 | public $can_sort = true; 46 | 47 | /** 48 | * @return translated 49 | */ 50 | function getTitle() { 51 | 52 | return PluginVipVip::getTypeName(1); 53 | } 54 | 55 | /** 56 | * @return int 57 | */ 58 | function maxActionsCount() { 59 | return count($this->getActions()); 60 | } 61 | 62 | /** 63 | * @param parameters $params 64 | * 65 | * @return parameters 66 | */ 67 | function addSpecificParamsForPreview($params) { 68 | 69 | if (!isset($params["entities_id"])) { 70 | $params["entities_id"] = $_SESSION["glpiactive_entity"]; 71 | } 72 | return $params; 73 | } 74 | 75 | /** 76 | * Function used to display type specific criterias during rule's preview 77 | * 78 | * @param $fields fields values 79 | * */ 80 | function showSpecificCriteriasForPreview($fields) { 81 | 82 | $entity_as_criteria = false; 83 | foreach ($this->criterias as $criteria) { 84 | if ($criteria->fields['criteria'] == 'entities_id') { 85 | $entity_as_criteria = true; 86 | break; 87 | } 88 | } 89 | if (!$entity_as_criteria) { 90 | echo Html::hidden('entities_id', ['value' => $_SESSION["glpiactive_entity"]]); 91 | } 92 | } 93 | 94 | /** 95 | * @return array 96 | */ 97 | function getCriterias() { 98 | 99 | $dbu = new DbUtils(); 100 | $criterias = []; 101 | $criterias['ldap'] = __('LDAP criteria'); 102 | foreach ($dbu->getAllDataFromTable('glpi_rulerightparameters', [], true) as $datas) { 103 | $criterias[$datas["value"]]['name'] = $datas["name"]; 104 | $criterias[$datas["value"]]['field'] = $datas["value"]; 105 | $criterias[$datas["value"]]['linkfield'] = ''; 106 | $criterias[$datas["value"]]['table'] = ''; 107 | } 108 | 109 | return $criterias; 110 | } 111 | 112 | 113 | /** 114 | * @return array 115 | */ 116 | function getActions() { 117 | $actions = []; 118 | 119 | $actions['groups_id']['name'] = __('Group'); 120 | $actions['groups_id']['type'] = 'dropdown'; 121 | $actions['groups_id']['table'] = 'glpi_groups'; 122 | 123 | return $actions; 124 | } 125 | 126 | /** 127 | * @see Rule::executeActions() 128 | * 129 | * @param the $output 130 | * @param parameters $params 131 | * 132 | * @return the 133 | */ 134 | function executeActions($output, $params, array $input = []) { 135 | if (count($this->actions)) { 136 | foreach ($this->actions as $action) { 137 | switch ($action->fields["action_type"]) { 138 | default : 139 | $output[$action->fields["field"]] = $action->fields["value"]; 140 | break; 141 | case "assign" : 142 | switch ($action->fields["field"]) { 143 | case "groups_id" : 144 | $output["groups_id"] = $action->fields["value"]; 145 | break; 146 | } 147 | }// end switch (field) 148 | } 149 | } 150 | return $output; 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /ajax/getDropdownUsers.php: -------------------------------------------------------------------------------- 1 | . 30 | * --------------------------------------------------------------------- 31 | */ 32 | 33 | /** @file 34 | * @brief 35 | * @since version 0.85 36 | */ 37 | 38 | // Direct access to file 39 | if (strpos($_SERVER['PHP_SELF'], "getDropdownUsers.php")) { 40 | $AJAX_INCLUDE = 1; 41 | include ('../../../inc/includes.php'); 42 | header("Content-Type: text/html; charset=UTF-8"); 43 | Html::header_nocache(); 44 | } else if (!defined('GLPI_ROOT')) { 45 | die("Sorry. You can't access this file directly"); 46 | } 47 | Session::checkLoginUser(); 48 | 49 | if (!isset($_POST['right'])) { 50 | $_POST['right'] = "all"; 51 | } 52 | 53 | // Default view : Nobody 54 | if (!isset($_POST['all'])) { 55 | $_POST['all'] = 0; 56 | } 57 | 58 | $used = []; 59 | 60 | if (isset($_POST['used'])) { 61 | $used = $_POST['used']; 62 | } 63 | 64 | if (!isset($_POST['value'])) { 65 | $_POST['value'] = 0; 66 | } 67 | 68 | $one_item = -1; 69 | if (isset($_POST['_one_id'])) { 70 | $one_item = $_POST['_one_id']; 71 | } 72 | 73 | if (!isset($_POST['page'])) { 74 | $_POST['page'] = 1; 75 | $_POST['page_limit'] = $CFG_GLPI['dropdown_max']; 76 | } 77 | 78 | $entity_restrict = -1; 79 | if (isset($_POST['entity_restrict'])) { 80 | $entity_restrict = Toolbox::jsonDecode($_POST['entity_restrict']); 81 | } 82 | 83 | $iterator = []; 84 | if ($one_item < 0) { 85 | $start = intval(($_POST['page']-1)*$_POST['page_limit']); 86 | $searchText = (isset($_POST['searchText']) ? $_POST['searchText'] : null); 87 | $iterator = User::getSqlSearchResult(false, $_POST['right'], $entity_restrict, 88 | $_POST['value'], $used, $searchText, $start, 89 | intval($_POST['page_limit'])); 90 | } else { 91 | $iterator = $DB->request([ 92 | 'FROM' => 'glpi_users', 93 | 'WHERE' => [ 94 | 'id' => $one_item, 95 | ], 96 | ]); 97 | //$query = "SELECT DISTINCT `glpi_users`.* 98 | // FROM `glpi_users` 99 | // WHERE `glpi_users`.`id` = '$one_item';"; 100 | //$result = $DB->query($query); 101 | } 102 | $users = []; 103 | 104 | // Count real items returned 105 | $count = 0; 106 | if (count($iterator)) { 107 | foreach ($iterator as $data) { 108 | $users[$data["id"]] = formatUserName($data["id"], $data["name"], $data["realname"], 109 | $data["firstname"]); 110 | $logins[$data["id"]] = $data["name"]; 111 | } 112 | } 113 | 114 | /* 115 | if (!function_exists('dpuser_cmp')) { 116 | function dpuser_cmp($a, $b) { 117 | return strcasecmp($a, $b); 118 | } 119 | } 120 | 121 | // Sort non case sensitive 122 | uasort($users, 'dpuser_cmp'); 123 | */ 124 | 125 | $datas = []; 126 | 127 | // Display first if empty search 128 | if ($_POST['page'] == 1 && empty($_POST['searchText'])) { 129 | if (($one_item < 0) || ($one_item == 0)) { 130 | if ($_POST['all'] == 0) { 131 | array_push($datas, ['id' => 0, 132 | 'text' => Dropdown::EMPTY_VALUE]); 133 | } else if ($_POST['all'] == 1) { 134 | array_push($datas, ['id' => 0, 135 | 'text' => __('All')]); 136 | } 137 | } 138 | } 139 | 140 | if (count($users)) { 141 | foreach ($users as $ID => $output) { 142 | $title = sprintf(__('%1$s - %2$s'), $output, $logins[$ID]); 143 | 144 | array_push($datas, ['id' => $ID, 145 | 'text' => $output, 146 | 'title' => $title]); 147 | $count++; 148 | } 149 | } 150 | 151 | if (($one_item >= 0) 152 | && isset($datas[0])) { 153 | echo json_encode($datas[0]); 154 | } else { 155 | $ret['results'] = $datas; 156 | $ret['count'] = $count; 157 | echo json_encode($ret); 158 | } 159 | -------------------------------------------------------------------------------- /inc/vip.class.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | if (!defined('GLPI_ROOT')) { 31 | die("Sorry. You can't access directly to this file"); 32 | } 33 | 34 | /** 35 | * Class PluginVipVip 36 | */ 37 | class PluginVipVip extends CommonDBTM { 38 | public static $rightname = 'plugin_vip'; 39 | 40 | /** 41 | * @param int $nb 42 | * 43 | * @return translated 44 | */ 45 | static function getTypeName($nb = 0) { 46 | return __('VIP', 'vip'); 47 | 48 | } 49 | 50 | static function afterAdd(User $user) { 51 | $rulevip = new PluginVipRuleVip(); 52 | $criterias = $rulevip->getCriterias(); 53 | 54 | if (isset($user->fields["authtype"]) 55 | && (($user->fields["authtype"] == Auth::LDAP) 56 | || Auth::isAlternateAuth($user->fields['authtype']))) { 57 | 58 | $config_ldap = new AuthLDAP(); 59 | $ds = false; 60 | 61 | if ($config_ldap->getFromDB($user->fields['auths_id'])) { 62 | $ds = $config_ldap->connect(); 63 | } 64 | 65 | if ($ds) { 66 | $info = AuthLdap::getUserByDn($ds, $user->fields['user_dn'], []); 67 | 68 | } 69 | 70 | $input = []; 71 | foreach ($criterias as $criteria) { 72 | if (isset($criteria['field']) && isset($info[$criteria['field']]) && isset($info[$criteria['field']][0])) { 73 | $input[$criteria['field']] = $info[$criteria['field']][0]; 74 | } 75 | if (isset($info["dn"])) { 76 | $input["dn"] = $info["dn"]; 77 | } 78 | } 79 | 80 | $ruleCollection = new PluginVipRuleVipCollection($user->fields['entities_id']); 81 | $fields = []; 82 | 83 | $fields = $ruleCollection->processAllRules($input, $fields, []); 84 | 85 | //Store rule that matched 86 | if (isset($fields['groups_id'])) { 87 | $groupuser = new Group_User(); 88 | 89 | if (!$groupuser->find(["`users_id` = " . $user->getID() . " AND `groups_id` =" . $fields['groups_id']])) { 90 | $groupuser->add(['users_id' => $user->getID(), 91 | 'groups_id' => $fields['groups_id']]); 92 | } 93 | } 94 | } 95 | } 96 | 97 | static function afterUpdate(User $user) { 98 | $rulevip = new PluginVipRuleVip(); 99 | $criterias = $rulevip->getCriterias(); 100 | 101 | if (isset($user->fields["authtype"]) 102 | && (($user->fields["authtype"] == Auth::LDAP) 103 | || Auth::isAlternateAuth($user->fields['authtype']))) { 104 | 105 | $config_ldap = new AuthLDAP(); 106 | $ds = false; 107 | 108 | if ($config_ldap->getFromDB($user->fields['auths_id'])) { 109 | $ds = $config_ldap->connect(); 110 | } 111 | 112 | if ($ds) { 113 | $info = AuthLdap::getUserByDn($ds, $user->fields['user_dn'], []); 114 | 115 | } 116 | 117 | $input = []; 118 | foreach ($criterias as $criteria) { 119 | if (isset($criteria['field']) && isset($info[$criteria['field']]) && isset($info[$criteria['field']][0])) { 120 | $input[$criteria['field']] = $info[$criteria['field']][0]; 121 | } 122 | if (isset($info["dn"])) { 123 | $input["dn"] = $info["dn"]; 124 | } 125 | } 126 | 127 | $ruleCollection = new PluginVipRuleVipCollection($user->fields['entities_id']); 128 | $fields = []; 129 | 130 | $fields = $ruleCollection->processAllRules($input, $fields, []); 131 | 132 | //Store rule that matched 133 | if (isset($fields['groups_id'])) { 134 | $groupuser = new Group_User(); 135 | 136 | if (!$groupuser->find(["`users_id` = " . $user->getID() . " AND `groups_id` =" . $fields['groups_id']])) { 137 | $groupuser->add(['users_id' => $user->getID(), 138 | 'groups_id' => $fields['groups_id']]); 139 | } 140 | } 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /inc/ticket.class.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | if (!defined('GLPI_ROOT')) { 31 | die("Sorry. You can't access directly to this file"); 32 | } 33 | 34 | class PluginVipTicket extends CommonDBTM { 35 | 36 | static $types = ['Ticket', 'Printer', 'Computer']; 37 | 38 | /** 39 | * @param $uid 40 | * 41 | * @return bool 42 | */ 43 | static function isUserVip($uid) { 44 | global $DB; 45 | 46 | if ($uid) { 47 | $vipquery = "SELECT `glpi_plugin_vip_groups`.`id` 48 | FROM `glpi_groups_users` 49 | LEFT JOIN `glpi_plugin_vip_groups` 50 | ON `glpi_plugin_vip_groups`.`id` = `glpi_groups_users`.`groups_id` 51 | WHERE `glpi_plugin_vip_groups`.`isvip` = 1 52 | AND `glpi_groups_users`.`users_id` = " . $uid; 53 | 54 | $result = $DB->query($vipquery); 55 | $nb = $DB->numrows($result); 56 | if ($nb > 0) { 57 | while ($uids = $DB->fetchArray($result)) { 58 | return $uids['id']; 59 | } 60 | } 61 | } 62 | 63 | return false; 64 | } 65 | 66 | /** 67 | * @param $entities 68 | * 69 | * @return array 70 | */ 71 | static function getUserVipList($entities) { 72 | global $DB; 73 | 74 | $vip = []; 75 | $vipquery = "SELECT `glpi_groups_users`.`users_id` 76 | FROM `glpi_groups_users` 77 | LEFT JOIN `glpi_plugin_vip_groups` 78 | ON `glpi_plugin_vip_groups`.`id` = `glpi_groups_users`.`groups_id` 79 | WHERE `glpi_plugin_vip_groups`.`isvip` = 1"; 80 | 81 | $result = $DB->query($vipquery); 82 | $nb = $DB->numrows($result); 83 | if ($nb > 0) { 84 | while ($uids = $DB->fetchArray($result)) { 85 | $vip[] = $uids['users_id']; 86 | } 87 | } 88 | return $vip; 89 | } 90 | 91 | /** 92 | * @param $ticketid 93 | * 94 | * @return bool 95 | */ 96 | static function isTicketVip($ticketid) { 97 | global $DB; 98 | 99 | if ($ticketid > 0) { 100 | $userquery = "SELECT `users_id` 101 | FROM `glpi_tickets_users` 102 | WHERE `type` = " . CommonITILActor::REQUESTER . " 103 | AND `tickets_id` = " . $ticketid; 104 | $userresult = $DB->query($userquery); 105 | $nb = $DB->numrows($userresult); 106 | if ($nb > 0) { 107 | while ($uids = $DB->fetchArray($userresult)) { 108 | $isuservip = self::isUserVip($uids['users_id']); 109 | if ($isuservip > 0) { 110 | return $isuservip; 111 | } 112 | 113 | } 114 | } 115 | } 116 | return false; 117 | } 118 | 119 | /** 120 | * @param $printers_id 121 | * 122 | * @return bool 123 | */ 124 | static function isPrinterVip($printers_id) { 125 | 126 | $printer = new Printer(); 127 | $printer->getFromDB($printers_id); 128 | return self::isUserVip($printer->getField('users_id')); 129 | } 130 | 131 | /** 132 | * @param $computers_id 133 | * 134 | * @return bool 135 | */ 136 | static function isComputerVip($computers_id) { 137 | 138 | $computer = new Computer(); 139 | $computer->getFromDB($computers_id); 140 | return self::isUserVip($computer->getField('users_id')); 141 | } 142 | 143 | /** 144 | * @param $params 145 | * 146 | * @return void 147 | */ 148 | public static function showVIPInfos($params) { 149 | $item = $params['item']; 150 | 151 | if (in_array($item->getType(), self::$types)) { 152 | if ($item->getType() == 'Ticket') { 153 | if ($id = self::isTicketVip($item->getID())) { 154 | $name = PluginVipGroup::getVipName($id); 155 | $icon = PluginVipGroup::getVipIcon($id); 156 | echo "
"; 157 | echo " "; 158 | echo sprintf(__('%1$s %2$s'), __('This ticket concerns at least one', 'vip'), $name); 159 | echo "
"; 160 | } 161 | } else { 162 | if ($id = self::isUserVip($item->getField('users_id'))) { 163 | echo "
"; 164 | if ($item->getType() == 'Computer') { 165 | $name = PluginVipGroup::getVipName($id); 166 | $icon = PluginVipGroup::getVipIcon($id); 167 | echo " "; 168 | echo sprintf(__('%1$s %2$s'), __('This computer is used by a', 'vip'), $name); 169 | } else if ($item->getType() == 'Printer') { 170 | $name = PluginVipGroup::getVipName($id); 171 | $icon = PluginVipGroup::getVipIcon($id); 172 | echo " "; 173 | echo sprintf(__('%1$s %2$s'), __('This printer is used by a', 'vip'), $name); 174 | } 175 | echo "
"; 176 | } 177 | } 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /inc/dashboard.class.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | class PluginVipDashboard extends CommonGLPI { 31 | 32 | public $widgets = []; 33 | private $options; 34 | private $datas, $form; 35 | 36 | public function __construct($_options = []) { 37 | $this->options = $_options; 38 | } 39 | 40 | function getWidgetsForItem() { 41 | 42 | $widgets = [ 43 | __('Tables', "mydashboard") => [ 44 | $this->getType() . "1" => ["title" => __("Tickets VIP", "mydashboard"), 45 | "icon" => "ti ti-table", 46 | "comment" => ""], 47 | ], 48 | ]; 49 | return $widgets; 50 | 51 | } 52 | 53 | public function getWidgetContentForItem($widgetId) { 54 | global $DB; 55 | 56 | $dbu = new DbUtils(); 57 | switch ($widgetId) { 58 | 59 | case $this->getType() . "1": 60 | 61 | $widget = new PluginMydashboardHtml(); 62 | 63 | $link_ticket = Toolbox::getItemTypeFormURL("Ticket"); 64 | 65 | $mygroups = Group_User::getUserGroups(Session::getLoginUserID(), ["is_assign" => 1]); 66 | $groups = []; 67 | foreach ($mygroups as $mygroup) { 68 | $groups[] = $mygroup["id"]; 69 | } 70 | 71 | $query = "SELECT `glpi_tickets`.`id` AS tickets_id, 72 | `glpi_tickets`.`status` AS status, 73 | `glpi_tickets`.`time_to_resolve` AS time_to_resolve 74 | FROM `glpi_tickets` 75 | LEFT JOIN `glpi_entities` ON (`glpi_tickets`.`entities_id` = `glpi_entities`.`id`) 76 | LEFT JOIN `glpi_groups_tickets` ON (`glpi_tickets`.`id` = `glpi_groups_tickets`.`tickets_id` 77 | AND `glpi_groups_tickets`.`type` = " . CommonITILActor::ASSIGN . ") 78 | WHERE `glpi_tickets`.`is_deleted` = '0' 79 | AND `glpi_tickets`.`status` NOT IN (" . CommonITILObject::INCOMING . "," . CommonITILObject::SOLVED . "," . CommonITILObject::CLOSED . ") "; 80 | if (count($groups) > 0) { 81 | $query .= "AND `glpi_groups_tickets`.`groups_id` IN (" . implode(",", $groups) . ")"; 82 | } 83 | $query .= "ORDER BY `glpi_tickets`.`time_to_resolve` DESC";// 84 | 85 | $widget = PluginMydashboardHelper::getWidgetsFromDBQuery('table', $query); 86 | $headers = [__('ID'), 87 | _n('Requester', 'Requesters', 2), 88 | __('Status'), 89 | __('Time to resolve'), 90 | __('Assigned to technicians')]; 91 | $widget->setTabNames($headers); 92 | 93 | $result = $DB->query($query); 94 | $nb = $DB->numrows($result); 95 | 96 | $datas = []; 97 | $tickets = []; 98 | 99 | if ($nb) { 100 | while ($data = $DB->fetchAssoc($result)) { 101 | 102 | $ticket = new Ticket(); 103 | $ticket->getFromDB($data['tickets_id']); 104 | if ($ticket->countUsers(CommonITILActor::REQUESTER)) { 105 | $users = []; 106 | foreach ($ticket->getUsers(CommonITILActor::REQUESTER) as $u) { 107 | $users[] = $u['users_id']; 108 | } 109 | foreach ($users as $key => $val) { 110 | if (PluginVipTicket::isUserVip($val) !== false) { 111 | $tickets[] = $data; 112 | } 113 | } 114 | } 115 | } 116 | $i = 0; 117 | 118 | foreach ($tickets as $key => $val) { 119 | 120 | $ticket = new Ticket(); 121 | $ticket->getFromDB($val['tickets_id']); 122 | 123 | $bgcolor = $_SESSION["glpipriority_" . $ticket->fields["priority"]]; 124 | 125 | $name_ticket = ""; 130 | 131 | 132 | $datas[$i]["tickets_id"] = $name_ticket; 133 | 134 | 135 | $userdata = ''; 136 | if ($ticket->countUsers(CommonITILActor::REQUESTER)) { 137 | 138 | foreach ($ticket->getUsers(CommonITILActor::REQUESTER) as $u) { 139 | $k = $u['users_id']; 140 | if ($k) { 141 | $userdata .= $dbu->getUserName($k); 142 | } 143 | 144 | 145 | if ($ticket->countUsers(CommonITILActor::REQUESTER) > 1) { 146 | $userdata .= "
"; 147 | } 148 | } 149 | } 150 | $datas[$i]["users_id"] = $userdata; 151 | 152 | $datas[$i]["status"] = Ticket::getStatus($val['status']); 153 | 154 | $time_to_resolve = ''; 155 | $due = strtotime(date('Y-m-d H:i:s')) - strtotime($val['time_to_resolve']); 156 | if ($due > 0) { 157 | $time_to_resolve .= "
"; 158 | } 159 | $time_to_resolve .= Html::convDateTime($val['time_to_resolve']); 160 | if ($due > 0) { 161 | $time_to_resolve .= "
"; 162 | } 163 | $datas[$i]["time_to_resolve"] = $time_to_resolve; 164 | 165 | $techdata = ''; 166 | if ($ticket->countUsers(CommonITILActor::ASSIGN)) { 167 | 168 | foreach ($ticket->getUsers(CommonITILActor::ASSIGN) as $u) { 169 | $k = $u['users_id']; 170 | if ($k) { 171 | $techdata .= $dbu->getUserName($k); 172 | } 173 | 174 | 175 | if ($ticket->countUsers(CommonITILActor::ASSIGN) > 1) { 176 | $techdata .= "
"; 177 | } 178 | } 179 | } 180 | $datas[$i]["techs_id"] = $techdata; 181 | $i++; 182 | } 183 | } 184 | 185 | $widget->setTabDatas($datas); 186 | // $widget->setOption("bSort", false); 187 | $widget->toggleWidgetRefresh(); 188 | 189 | $widget->setWidgetTitle(__("Tickets VIP", "mydashboard")); 190 | 191 | return $widget; 192 | break; 193 | } 194 | } 195 | } 196 | -------------------------------------------------------------------------------- /inc/profile.class.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | if (!defined('GLPI_ROOT')) { 31 | die("Sorry. You can't access directly to this file"); 32 | } 33 | 34 | /** 35 | * Class PluginVipProfile 36 | * 37 | * This class manages the profile rights of the plugin 38 | */ 39 | class PluginVipProfile extends Profile { 40 | 41 | /** 42 | * Get tab name for item 43 | * 44 | * @param CommonGLPI $item 45 | * @param type $withtemplate 46 | * 47 | * @return string 48 | */ 49 | function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { 50 | 51 | if ($item->getType() == 'Profile' 52 | && $item->getField('interface') != 'helpdesk') { 53 | return __('VIP', 'vip'); 54 | } 55 | return ''; 56 | } 57 | 58 | /** 59 | * display tab content for item 60 | * 61 | * @global type $CFG_GLPI 62 | * 63 | * @param CommonGLPI $item 64 | * @param type $tabnum 65 | * @param type $withtemplate 66 | * 67 | * @return boolean 68 | */ 69 | static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { 70 | global $CFG_GLPI; 71 | 72 | if ($item->getType() == 'Profile') { 73 | $ID = $item->getID(); 74 | $prof = new self(); 75 | 76 | self::addDefaultProfileInfos($ID, 77 | ['plugin_vip' => 0]); 78 | $prof->showForm($ID); 79 | } 80 | 81 | return true; 82 | } 83 | 84 | /** 85 | * show profile form 86 | * 87 | * @param type $ID 88 | * @param type $options 89 | * 90 | * @return boolean 91 | */ 92 | function showForm($profiles_id = 0, $openform = TRUE, $closeform = TRUE) { 93 | 94 | echo "
"; 95 | if (($canedit = Session::haveRightsOr(self::$rightname, [CREATE, UPDATE, PURGE])) 96 | && $openform) { 97 | $profile = new Profile(); 98 | echo "
"; 99 | } 100 | 101 | $profile = new Profile(); 102 | $profile->getFromDB($profiles_id); 103 | 104 | $rights = $this->getAllRights(); 105 | $profile->displayRightsChoiceMatrix($rights, ['canedit' => $canedit, 106 | 'default_class' => 'tab_bg_2', 107 | 'title' => __('General')]); 108 | if ($canedit 109 | && $closeform) { 110 | echo "
"; 111 | echo Html::hidden('id', ['value' => $profiles_id]); 112 | echo Html::submit(_sx('button', 'Save'), ['name' => 'update', 'class' => 'btn btn-primary']); 113 | echo "
\n"; 114 | Html::closeForm(); 115 | } 116 | echo "
"; 117 | 118 | $this->showLegend(); 119 | } 120 | 121 | /** 122 | * Get all rights 123 | * 124 | * @param type $all 125 | * 126 | * @return array 127 | */ 128 | static function getAllRights($all = false) { 129 | 130 | $rights = [ 131 | ['itemtype' => 'PluginVipGroup', 132 | 'label' => __('VIP', 'vip'), 133 | 'field' => 'plugin_vip' 134 | ] 135 | ]; 136 | 137 | return $rights; 138 | } 139 | 140 | /** 141 | * Init profiles 142 | * 143 | **/ 144 | 145 | static function translateARight($old_right) { 146 | switch ($old_right) { 147 | case '': 148 | return 0; 149 | case 'r' : 150 | return READ; 151 | case 'w': 152 | return ALLSTANDARDRIGHT; 153 | case '0': 154 | case '1': 155 | return $old_right; 156 | 157 | default : 158 | return 0; 159 | } 160 | } 161 | 162 | 163 | /** 164 | * @since 0.85 165 | * Migration rights from old system to the new one for one profile 166 | * 167 | * @param $profiles_id the profile ID 168 | */ 169 | static function migrateOneProfile($profiles_id) { 170 | global $DB; 171 | //Cannot launch migration if there's nothing to migrate... 172 | if (!$DB->tableExists('glpi_plugin_vip_profiles')) { 173 | return true; 174 | } 175 | 176 | foreach ($DB->request('glpi_plugin_vip_profiles', 177 | "`profiles_id`='$profiles_id'") as $profile_data) { 178 | 179 | $matching = ['show_vip_tab' => 'plugin_vip']; 180 | $current_rights = ProfileRight::getProfileRights($profiles_id, array_values($matching)); 181 | foreach ($matching as $old => $new) { 182 | if (!isset($current_rights[$old])) { 183 | $right = self::translateARight($profile_data[$old]); 184 | switch ($new) { 185 | case 'plugin_vip' : 186 | $right = 0; 187 | if ($profile_data[$old] == '1') { 188 | $right = ALLSTANDARDRIGHT; 189 | } 190 | break; 191 | } 192 | 193 | $query = "UPDATE `glpi_profilerights` 194 | SET `rights`='" . $right . "' 195 | WHERE `name`='$new' AND `profiles_id`='$profiles_id'"; 196 | $DB->query($query); 197 | } 198 | } 199 | } 200 | } 201 | 202 | /** 203 | * Initialize profiles, and migrate it necessary 204 | */ 205 | static function initProfile() { 206 | global $DB; 207 | $profile = new self(); 208 | $dbu = new DbUtils(); 209 | //Add new rights in glpi_profilerights table 210 | foreach ($profile->getAllRights(true) as $data) { 211 | if ($dbu->countElementsInTable("glpi_profilerights", 212 | ["name" => $data['field']]) == 0) { 213 | ProfileRight::addProfileRights([$data['field']]); 214 | } 215 | } 216 | 217 | //Migration old rights in new ones 218 | foreach ($DB->request("SELECT `id` FROM `glpi_profiles`") as $prof) { 219 | self::migrateOneProfile($prof['id']); 220 | } 221 | foreach ($DB->request("SELECT * 222 | FROM `glpi_profilerights` 223 | WHERE `profiles_id`='" . $_SESSION['glpiactiveprofile']['id'] . "' 224 | AND `name` LIKE '%plugin_vip%'") as $prof) { 225 | $_SESSION['glpiactiveprofile'][$prof['name']] = $prof['rights']; 226 | } 227 | } 228 | 229 | /** 230 | * Initialize profiles, and migrate it necessary 231 | */ 232 | static function changeProfile() { 233 | global $DB; 234 | 235 | foreach ($DB->request("SELECT * 236 | FROM `glpi_profilerights` 237 | WHERE `profiles_id`='" . $_SESSION['glpiactiveprofile']['id'] . "' 238 | AND `name` LIKE '%plugin_vip%'") as $prof) { 239 | $_SESSION['glpiactiveprofile'][$prof['name']] = $prof['rights']; 240 | } 241 | 242 | } 243 | 244 | static function createFirstAccess($profiles_id) { 245 | 246 | $rights = ['plugin_vip' => ALLSTANDARDRIGHT]; 247 | 248 | self::addDefaultProfileInfos($profiles_id, 249 | $rights, true); 250 | 251 | } 252 | 253 | /** 254 | * @param $profile 255 | **/ 256 | static function addDefaultProfileInfos($profiles_id, $rights, $drop_existing = false) { 257 | 258 | $profileRight = new ProfileRight(); 259 | $dbu = new DbUtils(); 260 | foreach ($rights as $right => $value) { 261 | if ($dbu->countElementsInTable('glpi_profilerights', 262 | ["profiles_id" => $profiles_id, 263 | "name" => $right]) && $drop_existing) { 264 | $profileRight->deleteByCriteria(['profiles_id' => $profiles_id, 'name' => $right]); 265 | } 266 | if (!$dbu->countElementsInTable('glpi_profilerights', 267 | ["profiles_id" => $profiles_id, 268 | "name" => $right])) { 269 | $myright['profiles_id'] = $profiles_id; 270 | $myright['name'] = $right; 271 | $myright['rights'] = $value; 272 | $profileRight->add($myright); 273 | 274 | //Add right to the current session 275 | $_SESSION['glpiactiveprofile'][$right] = $value; 276 | } 277 | } 278 | } 279 | 280 | static function removeRightsFromSession() { 281 | foreach (self::getAllRights(true) as $right) { 282 | if (isset($_SESSION['glpiactiveprofile'][$right['field']])) { 283 | unset($_SESSION['glpiactiveprofile'][$right['field']]); 284 | } 285 | } 286 | } 287 | 288 | } 289 | -------------------------------------------------------------------------------- /vip.js.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | var root_vip_doc = ""; 9 | 10 | (function ($) { 11 | $.fn.initVipPlugin = function (options) { 12 | 13 | var object = this; 14 | init(); 15 | 16 | // Start the plugin 17 | function init() { 18 | object.params = new Array(); 19 | object.params['entities_id'] = 0; 20 | object.params['page_limit'] = 0; 21 | object.params['minimumResultsForSearch'] = 0; 22 | object.params['root_doc'] = null; 23 | object.params['emptyValue'] = null; 24 | 25 | if (options != undefined) { 26 | $.each(options, function (index, val) { 27 | if (val != undefined && val != null) { 28 | object.params[index] = val; 29 | } 30 | }); 31 | } 32 | } 33 | 34 | this.changeRequesterColor = function (vip) { 35 | $(document).ready(function () { 36 | 37 | // only in ticket form 38 | if (location.pathname.indexOf('ticket.form.php') > 0) { 39 | $.urlParam = function (url, name) { 40 | var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url); 41 | if (results != null) { 42 | return results[1] || 0; 43 | } 44 | }; 45 | 46 | // get item id 47 | var items_id = $.urlParam(window.location.href, 'id'); 48 | 49 | // Launched on each complete Ajax load 50 | $(document).ajaxComplete(function (event, xhr, option) { 51 | 52 | if (option.url !== undefined 53 | && (option.url.indexOf('vip/ajax/loadscripts.php') > 0 || option.url.indexOf('common.tabs.php') > 0)) { 54 | 55 | setTimeout(function () { 56 | 57 | if (items_id > 0) { 58 | $.ajax({ 59 | url: root_vip_doc + '/ajax/ticket.php', 60 | type: "POST", 61 | dataType: "json", 62 | data: { 63 | 'items_id': items_id, 64 | 'action': 'getTicket' 65 | }, 66 | success: function (response, opts) { 67 | var ticketVip = false; 68 | $.each(vip, function (index, val) { 69 | $.each(response.used, function (index2, val2) { 70 | var userid = val.id; 71 | 72 | if (val.id == val2 73 | ) { 74 | var userid = val.id; 75 | $("span[data-items-id='" + userid + "']").css("color", val.color); 76 | $("span[data-items-id='" + userid + "']").after("  "); 77 | } 78 | }); 79 | }); 80 | }, 81 | }); 82 | } else { 83 | $.ajax({ 84 | url: root_vip_doc + '/ajax/ticket.php', 85 | type: "POST", 86 | dataType: "json", 87 | data: { 88 | 'action': 'getVIP' 89 | }, 90 | success: function (response, opts) { 91 | var ticketVip = false; 92 | $.each(vip, function (index, val) { 93 | $.each(response.used, function (index2, val2) { 94 | var userid = val.id; 95 | 96 | if (val.id == val2 97 | ) { 98 | var userid = val.id; 99 | $("span[data-items-id='" + userid + "']").css("color", val.color); 100 | $("span[data-items-id='" + userid + "']").after("  "); 101 | } 102 | }); 103 | }); 104 | }, 105 | }); 106 | } 107 | }, 500); 108 | } 109 | // }, 500); 110 | }, this); 111 | } 112 | inputName = 'users_id'; 113 | if (location.pathname.indexOf('printer.form.php') > 0) { 114 | $.urlParam = function (url, name) { 115 | var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url); 116 | if (results != null) { 117 | return results[1] || 0; 118 | } 119 | }; 120 | // get item id 121 | var items_id = $.urlParam(window.location.href, 'id'); 122 | 123 | setTimeout(function () { 124 | $.ajax({ 125 | url: root_vip_doc + '/ajax/ticket.php', 126 | type: "POST", 127 | dataType: "json", 128 | data: { 129 | 'items_id': items_id, 130 | 'action': 'getPrinter' 131 | }, 132 | success: function (response, opts) { 133 | $.each(vip, function (index, val) { 134 | $.each(response.used, function (index2, val2) { 135 | var userid = val.id; 136 | 137 | if (val.id == val2 138 | ) { 139 | var userid = val.id; 140 | $("span[id^='select2-dropdown_users_id']").each(function () { 141 | //not select2-dropdown_users_id_tech 142 | selectname = $(this).attr('id'); 143 | if (selectname.indexOf('select2-dropdown_users_id_tech') == -1) { 144 | $(this).css("color", val.color); 145 | } 146 | 147 | }); 148 | // $("span[id^='select2-dropdown_users_id']").css("color", val.color); 149 | $("select[name='" + inputName + "']").before("  "); 150 | } 151 | }); 152 | }); 153 | } 154 | }); 155 | }, 500); 156 | } 157 | inputName = 'users_id'; 158 | if (location.pathname.indexOf('computer.form.php') > 0) { 159 | $.urlParam = function (url, name) { 160 | var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url); 161 | if (results != null) { 162 | return results[1] || 0; 163 | } 164 | }; 165 | // get item id 166 | var items_id = $.urlParam(window.location.href, 'id'); 167 | 168 | setTimeout(function () { 169 | $.ajax({ 170 | url: root_vip_doc + '/ajax/ticket.php', 171 | type: "POST", 172 | dataType: "json", 173 | data: { 174 | 'items_id': items_id, 175 | 'action': 'getComputer' 176 | }, 177 | success: function (response, opts) { 178 | $.each(vip, function (index, val) { 179 | $.each(response.used, function (index2, val2) { 180 | var userid = val.id; 181 | 182 | if (val.id == val2 183 | ) { 184 | var userid = val.id; 185 | $("span[id^='select2-dropdown_users_id']").each(function () { 186 | //not select2-dropdown_users_id_tech 187 | selectname = $(this).attr('id'); 188 | if (selectname.indexOf('select2-dropdown_users_id_tech') == -1) { 189 | $(this).css("color", val.color); 190 | } 191 | 192 | }); 193 | // $("span[id^='select2-dropdown_users_id']").css("color", val.color); 194 | $("select[name='" + inputName + "']").before("  "); 195 | } 196 | }); 197 | }); 198 | } 199 | }); 200 | }, 500); 201 | } 202 | }); 203 | }; 204 | 205 | return this; 206 | }; 207 | }(jQuery)); 208 | -------------------------------------------------------------------------------- /inc/group.class.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | if (!defined('GLPI_ROOT')) { 31 | die("Sorry. You can't access directly to this file"); 32 | } 33 | 34 | class PluginVipGroup extends CommonDBTM { 35 | 36 | static $rightname = "plugin_vip"; 37 | 38 | /** 39 | * Configuration form 40 | * */ 41 | function showForm($id, $options = []) { 42 | 43 | $target = $this->getFormURL(); 44 | if (isset($options['target'])) { 45 | $target = $options['target']; 46 | } 47 | 48 | if (!Session::haveRight("plugin_vip", READ)) { 49 | return false; 50 | } 51 | 52 | $canedit = Session::haveRight("plugin_vip", UPDATE); 53 | $prof = new Profile(); 54 | 55 | if ($id) { 56 | $this->getFromDB($id); 57 | $prof->getFromDB($id); 58 | } 59 | 60 | echo ""; 61 | echo ""; 62 | echo ""; 64 | 65 | echo ""; 66 | echo ""; 69 | 70 | echo ""; 71 | echo ""; 74 | 75 | echo ""; 76 | echo ""; 77 | echo ""; 82 | 83 | echo ""; 86 | echo ""; 111 | 112 | if ($canedit) { 113 | echo ""; 114 | echo ""; 118 | } 119 | echo "
" . __('VIP management', 'vip') . " : " . Dropdown::getDropdownName("glpi_groups", $this->fields["id"]); 63 | echo "
" . __('Name') . ""; 67 | echo Html::input('name', ['value' => $this->fields['name'], 'size' => 40]); 68 | echo "
" . __('VIP group', 'vip') . ""; 72 | Dropdown::showYesNo("isvip", $this->fields["isvip"]); 73 | echo "
" . __('VIP color', 'vip') . ""; 78 | $rand = mt_rand(); 79 | Html::showColorField('vip_color', ['value' => $this->fields["vip_color"], 'rand' => $rand]); 80 | 81 | echo "
"; 84 | echo __('VIP Icon', 'vip'); 85 | echo ""; 87 | $icon_selector_id = 'icon_' . mt_rand(); 88 | echo Html::select( 89 | 'vip_icon', 90 | [$this->fields['vip_icon'] => $this->fields['vip_icon']], 91 | [ 92 | 'id' => $icon_selector_id, 93 | 'selected' => $this->fields['vip_icon'], 94 | 'style' => 'width:175px;' 95 | ] 96 | ); 97 | 98 | echo Html::script('js/Forms/FaIconSelector.js'); 99 | echo Html::scriptBlock(<<"; 110 | echo "
"; 115 | echo Html::hidden('id', ['value' => $id]); 116 | echo Html::submit(_sx('button', 'Update'), ['name' => 'update_vip_group', 'class' => 'btn btn-primary']); 117 | echo "
"; 120 | 121 | Html::closeForm(); 122 | } 123 | 124 | /** 125 | * Get Tab Name used for itemtype 126 | * 127 | * NB : Only called for existing object 128 | * Must check right on what will be displayed + template 129 | * 130 | * @param CommonGLPI $item Item on which the tab need to be displayed 131 | * @param boolean $withtemplate is a template object ? (default 0) 132 | * 133 | * @return string tab name 134 | **@since 0.83 135 | * 136 | */ 137 | function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { 138 | 139 | if ($item->getType() == 'Group' 140 | && Session::haveRight("plugin_vip", UPDATE)) { 141 | return __('VIP', 'vip'); 142 | } 143 | return ''; 144 | } 145 | 146 | /** 147 | * show Tab content 148 | * 149 | * @param CommonGLPI $item Item on which the tab need to be displayed 150 | * @param integer $tabnum tab number (default 1) 151 | * @param boolean $withtemplate is a template object ? (default 0) 152 | * 153 | * @return boolean 154 | **@since 0.83 155 | * 156 | */ 157 | static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { 158 | 159 | if ($item->getType() == 'Group') { 160 | $grp = new self(); 161 | $ID = $item->getField('id'); 162 | if (!$grp->getFromDB($ID)) { 163 | $grp->add(['id' => $ID]); 164 | } 165 | $grp->showForm($ID); 166 | } 167 | return true; 168 | } 169 | 170 | /** 171 | * @return array 172 | */ 173 | function getVipUsers() { 174 | $dbu = new DbUtils(); 175 | 176 | $groups = $this->find(['isvip' => 1]); 177 | 178 | if (isset($groups[0])) { 179 | unset($groups[0]); 180 | } 181 | 182 | $vip = []; 183 | if (count($groups) > 0) { 184 | $restrict = ["groups_id" => array_keys($groups)]; 185 | $managers = $dbu->getAllDataFromTable('glpi_groups_users', $restrict); 186 | 187 | foreach ($managers as $manager) { 188 | $vip[$manager['users_id']]['id'] = $manager['users_id']; 189 | $vip[$manager['users_id']]['name'] = $groups[$manager['groups_id']]['name']; 190 | $vip[$manager['users_id']]['color'] = $groups[$manager['groups_id']]['vip_color']; 191 | $vip[$manager['users_id']]['icon'] = $groups[$manager['groups_id']]['vip_icon']; 192 | } 193 | } 194 | 195 | return $vip; 196 | } 197 | 198 | static function getVipName($id) { 199 | $grp = new self(); 200 | if ($grp->getFromDB($id)) { 201 | return $grp->fields["name"]; 202 | } 203 | return "VIP"; 204 | } 205 | 206 | static function getVipColor($id) { 207 | 208 | $grp = new self(); 209 | if ($grp->getFromDB($id)) { 210 | return $grp->fields["vip_color"]; 211 | } 212 | return "darkred"; 213 | } 214 | 215 | static function getVipIcon($id) { 216 | $grp = new self(); 217 | if ($grp->getFromDB($id)) { 218 | return $grp->fields["vip_icon"]; 219 | } 220 | return "fa-exclamation-triangle"; 221 | } 222 | 223 | /** 224 | * Massive actions available for infocom types 225 | * @return type 226 | */ 227 | function massiveActions() { 228 | return ["PluginVipGroup:isvip" => __('Update') . " " . __('VIP group', 'vip')]; 229 | } 230 | 231 | /** 232 | * @return array 233 | */ 234 | function getAddSearchOptions() { 235 | 236 | $sopt = []; 237 | 238 | if (Session::getCurrentInterface() == 'central' && Session::haveRight('plugin_vip', READ)) { 239 | $rng1 = 150; 240 | $sopt[$rng1]['table'] = 'glpi_plugin_vip_groups'; 241 | $sopt[$rng1]['field'] = 'isvip'; 242 | $sopt[$rng1]['linkfield'] = 'id'; 243 | $sopt[$rng1]['name'] = 'Vip'; 244 | $sopt[$rng1]['datatype'] = 'bool'; 245 | $sopt[$rng1]['massiveaction'] = false; 246 | } 247 | 248 | return $sopt; 249 | } 250 | 251 | /** 252 | * @see CommonDBTM::showMassiveActionsSubForm() 253 | * */ 254 | static function showMassiveActionsSubForm(MassiveAction $ma) { 255 | Dropdown::showYesNo('isvip'); 256 | echo "

" . Html::submit(_x('button', 'Save'), ['name' => 'massiveaction']); 257 | return true; 258 | } 259 | 260 | /** 261 | * @since version 0.85 262 | * 263 | * @see CommonDBTM::processMassiveActionsForOneItemtype() 264 | **/ 265 | static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, 266 | array $ids) { 267 | $vip = new self(); 268 | //We check if it's really a massive action of vip 269 | if (strpos($ma->getAction(), "plugin_vip_update") == -1) { 270 | $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO); 271 | } else { 272 | if ($vip->canCreate()) { 273 | $input = $ma->getInput(); 274 | foreach ($ids as $id) { 275 | //Item has alreaddy 276 | if ($vip->getFromDB($id)) { 277 | $update = [ 278 | "id" => $id, 279 | "isvip" => $input['isvip'] 280 | ]; 281 | $vip->update($update); 282 | $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); 283 | } else { //Item has no vip yet 284 | $update = [ 285 | "isvip" => $input['isvip'] 286 | ]; 287 | $vip->add($update); 288 | $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK); 289 | } 290 | } 291 | } else { 292 | $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT); 293 | } 294 | } 295 | return $ma; 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /hook.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | function plugin_vip_install() { 31 | global $DB; 32 | // Création de la table uniquement lors de la première installation 33 | if (!$DB->tableExists("glpi_plugin_vip_groups")) { 34 | $DB->runFile(PLUGIN_VIP_DIR. "/install/sql/empty-1.8.0.sql"); 35 | } 36 | 37 | if ($DB->tableExists('glpi_plugin_vip_tickets')) { 38 | $tables = ["glpi_plugin_vip_tickets"]; 39 | 40 | foreach ($tables as $table) { 41 | $DB->query("DROP TABLE IF EXISTS `$table`;"); 42 | } 43 | } 44 | 45 | if (!$DB->fieldExists("glpi_plugin_vip_groups","vip_color")) { 46 | $DB->runFile(PLUGIN_VIP_DIR. "/install/sql/update-1.7.3.sql"); 47 | } 48 | 49 | if (!$DB->fieldExists("glpi_plugin_vip_groups","vip_icon")) { 50 | $DB->runFile(PLUGIN_VIP_DIR. "/install/sql/update-1.8.0.sql"); 51 | } 52 | 53 | include_once(PLUGIN_VIP_DIR."/inc/profile.class.php"); 54 | PluginVipProfile::initProfile(); 55 | PluginVipProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']); 56 | 57 | return true; 58 | } 59 | 60 | function plugin_vip_uninstall() { 61 | global $DB; 62 | 63 | $tables = ["glpi_plugin_vip_profiles", 64 | "glpi_plugin_vip_groups", 65 | "glpi_plugin_vip_tickets"]; 66 | 67 | foreach ($tables as $table) 68 | $DB->query("DROP TABLE IF EXISTS `$table`;"); 69 | 70 | $tables_glpi = ["glpi_displaypreferences", 71 | "glpi_documents_items", 72 | "glpi_savedsearches", 73 | "glpi_logs", 74 | "glpi_items_tickets", 75 | "glpi_contracts_items", 76 | "glpi_notepads", 77 | "glpi_dropdowntranslations"]; 78 | 79 | foreach ($tables_glpi as $table_glpi) 80 | $DB->query("DELETE FROM `$table_glpi` WHERE `itemtype` LIKE 'PluginVip%';"); 81 | 82 | //drop rules 83 | $Rule = new Rule(); 84 | $a_rules = $Rule->find(['sub_type' => 'PluginVipRuleVip']); 85 | foreach ($a_rules as $data) { 86 | $Rule->delete($data); 87 | } 88 | 89 | //Delete rights associated with the plugin 90 | $profileRight = new ProfileRight(); 91 | foreach (PluginVipProfile::getAllRights() as $right) { 92 | $profileRight->deleteByCriteria(['name' => $right['field']]); 93 | } 94 | 95 | PluginVipProfile::removeRightsFromSession(); 96 | return true; 97 | } 98 | 99 | function plugin_vip_getPluginsDatabaseRelations() { 100 | 101 | if (Plugin::isPluginActive("vip")) 102 | return [ 103 | "glpi_groups" => ["glpi_plugin_vip_groups" => "id"] 104 | ]; 105 | else 106 | return []; 107 | } 108 | 109 | function plugin_vip_getAddSearchOptions($itemtype) { 110 | 111 | $sopt = []; 112 | 113 | if (Session::getCurrentInterface() == 'central' 114 | && Session::haveRight('plugin_vip', READ)) { 115 | switch ($itemtype) { 116 | case 'Ticket': 117 | case 'Computer': 118 | case 'Printer': 119 | $rng1 = 10100; 120 | $sopt[$rng1]['table'] = 'glpi_plugin_vip_groups'; 121 | $sopt[$rng1]['field'] = 'isvip'; 122 | $sopt[$rng1]['name'] = 'Vip'; 123 | $sopt[$rng1]['datatype'] = 'bool'; 124 | $sopt[$rng1]['massiveaction'] = false; 125 | break; 126 | case 'Group': 127 | $rng1 = 150; 128 | $sopt[$rng1]['table'] = 'glpi_plugin_vip_groups'; 129 | $sopt[$rng1]['field'] = 'isvip'; 130 | $sopt[$rng1]['linkfield'] = 'id'; 131 | $sopt[$rng1]['name'] = 'Vip'; 132 | $sopt[$rng1]['datatype'] = 'bool'; 133 | $sopt[$rng1]['massiveaction'] = false; 134 | break; 135 | } 136 | } 137 | 138 | return $sopt; 139 | } 140 | 141 | function plugin_vip_MassiveActions($type) { 142 | if ($type == 'Group') { 143 | $vip = new PluginVipGroup(); 144 | return $vip->massiveActions(); 145 | } 146 | return []; 147 | } 148 | 149 | function plugin_vip_addLeftJoin($type, $ref_table, $new_table, $linkfield, &$already_link_tables) { 150 | if ($ref_table == 'glpi_tickets') { 151 | switch ($new_table) { 152 | case "glpi_plugin_vip_groups" : 153 | $out = " LEFT JOIN `glpi_tickets_users` ON (`glpi_tickets`.`id` = `glpi_tickets_users`.`tickets_id` AND `glpi_tickets_users`.`type` = " . CommonITILActor::REQUESTER . ") "; 154 | $out .= " LEFT JOIN `glpi_groups_users` ON (`glpi_tickets_users`.`users_id` = `glpi_groups_users`.`users_id`)"; 155 | $out .= " LEFT JOIN `glpi_plugin_vip_groups` ON (`glpi_groups_users`.`groups_id` = `glpi_plugin_vip_groups`.`id`)"; 156 | 157 | return $out; 158 | } 159 | } else if ($ref_table == 'glpi_printers') { 160 | switch ($new_table) { 161 | case "glpi_plugin_vip_groups" : 162 | // $out = " LEFT JOIN `glpi_users` `glpi_users_VIP` ON (`glpi_printers`.`users_id` = `glpi_users_VIP`.`id`) "; 163 | $out = " LEFT JOIN `glpi_groups_users` ON (`glpi_printers`.`users_id` = `glpi_groups_users`.`users_id`)"; 164 | $out .= " LEFT JOIN `glpi_plugin_vip_groups` ON (`glpi_groups_users`.`groups_id` = `glpi_plugin_vip_groups`.`id`)"; 165 | 166 | return $out; 167 | } 168 | } else if ($ref_table == 'glpi_computers') { 169 | switch ($new_table) { 170 | case "glpi_plugin_vip_groups" : 171 | // $out = " LEFT JOIN `glpi_users` `glpi_users_VIP` ON (`glpi_printers`.`users_id` = `glpi_users_VIP`.`id`) "; 172 | $out = " LEFT JOIN `glpi_groups_users` ON (`glpi_computers`.`users_id` = `glpi_groups_users`.`users_id`)"; 173 | $out .= " LEFT JOIN `glpi_plugin_vip_groups` ON (`glpi_groups_users`.`groups_id` = `glpi_plugin_vip_groups`.`id`)"; 174 | 175 | return $out; 176 | } 177 | } 178 | 179 | return ""; 180 | } 181 | 182 | function plugin_vip_giveItem($type, $ID, $data, $num) { 183 | global $CFG_GLPI, $DB; 184 | 185 | $searchopt = &Search::getOptions($type); 186 | $table = $searchopt[$ID]["table"]; 187 | $field = $searchopt[$ID]["field"]; 188 | switch ($type) { 189 | case 'Ticket': 190 | switch ($table . '.' . $field) { 191 | case "glpi_plugin_vip_groups.isvip" : 192 | if ($id = PluginVipTicket::isTicketVip($data["id"])) { 193 | $name = PluginVipGroup::getVipName($id); 194 | $color = PluginVipGroup::getVipColor($id); 195 | $icon = PluginVipGroup::getVipIcon($id); 196 | return "

1

"; 197 | } 198 | break; 199 | } 200 | break; 201 | case 'Printer': 202 | switch ($table . '.' . $field) { 203 | case "glpi_plugin_vip_groups.isvip" : 204 | if ($id = PluginVipTicket::isPrinterVip($data["id"])) { 205 | $name = PluginVipGroup::getVipName($id); 206 | $color = PluginVipGroup::getVipColor($id); 207 | $icon = PluginVipGroup::getVipIcon($id); 208 | return "

1

"; 209 | } 210 | break; 211 | } 212 | break; 213 | case 'Computer': 214 | switch ($table . '.' . $field) { 215 | case "glpi_plugin_vip_groups.isvip" : 216 | if ($id = PluginVipTicket::isComputerVip($data["id"])) { 217 | $name = PluginVipGroup::getVipName($id); 218 | $color = PluginVipGroup::getVipColor($id); 219 | $icon = PluginVipGroup::getVipIcon($id); 220 | return "

1

"; 221 | } 222 | break; 223 | } 224 | break; 225 | case 'Group': 226 | switch ($table . '.' . $field) { 227 | case "glpi_plugin_vip_groups.isvip" : 228 | if ($data[$num][0]['name']) { 229 | $name = PluginVipGroup::getVipName($data["id"]); 230 | $color = PluginVipGroup::getVipColor($data["id"]); 231 | $icon = PluginVipGroup::getVipIcon($data["id"]); 232 | return "

1

"; 233 | } 234 | break; 235 | } 236 | break; 237 | } 238 | 239 | return " "; 240 | } 241 | 242 | function plugin_vip_executeActions($options) { 243 | $vip = new PluginVipRuleVip(); 244 | return $vip->executeActions($options['action'], $options['output'], $options['params']); 245 | } 246 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------