├── certificates.png ├── locales ├── cs_CZ.mo ├── da_DK.mo ├── de_DE.mo ├── en_GB.mo ├── es_ES.mo ├── fr_FR.mo ├── pl_PL.mo ├── pt_BR.mo ├── ro_RO.mo ├── ru_RU.mo ├── tr_TR.mo ├── glpi.pot ├── tr_TR.po ├── da_DK.po ├── pt_BR.po ├── de_DE.po ├── pl_PL.po ├── en_GB.po ├── es_ES.po ├── ro_RO.po ├── cs_CZ.po ├── fr_FR.po └── ru_RU.po ├── sql ├── update-1.4.sql ├── update-1.5.1.sql ├── update-1.8.0.sql ├── update-1.5.0.sql ├── empty-1.3.sql ├── empty-1.4.sql ├── empty-1.5.0.sql ├── update-1.6.0.sql ├── empty-1.5.1.sql ├── empty-2.2.0.sql ├── empty-2.0.0.sql ├── empty-1.6.0.sql ├── empty-1.7.0.sql └── empty-1.8.0.sql ├── ISSUE_TEMPLATE.md ├── tools ├── extract_template.sh ├── update_mo.pl ├── update_po.pl └── move_to_po.php ├── README.md ├── front ├── certificatestate.php ├── certificatetype.php ├── certificatestate.form.php ├── certificatetype.form.php ├── notification.state.php ├── certificate.form.php └── certificate.php ├── ajax └── dropdownTypeCertificates.php ├── inc ├── menu.class.php ├── certificatestate.class.php ├── certificatetype.class.php ├── notificationtargetcertificate.class.php ├── config.class.php ├── notificationstate.class.php └── profile.class.php ├── setup.php └── certificates.xml /certificates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/certificates.png -------------------------------------------------------------------------------- /locales/cs_CZ.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/cs_CZ.mo -------------------------------------------------------------------------------- /locales/da_DK.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/da_DK.mo -------------------------------------------------------------------------------- /locales/de_DE.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/de_DE.mo -------------------------------------------------------------------------------- /locales/en_GB.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/en_GB.mo -------------------------------------------------------------------------------- /locales/es_ES.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/es_ES.mo -------------------------------------------------------------------------------- /locales/fr_FR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/fr_FR.mo -------------------------------------------------------------------------------- /locales/pl_PL.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/pl_PL.mo -------------------------------------------------------------------------------- /locales/pt_BR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/pt_BR.mo -------------------------------------------------------------------------------- /locales/ro_RO.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/ro_RO.mo -------------------------------------------------------------------------------- /locales/ru_RU.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/ru_RU.mo -------------------------------------------------------------------------------- /locales/tr_TR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/certificates/master/locales/tr_TR.mo -------------------------------------------------------------------------------- /sql/update-1.4.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `glpi_plugin_certificates` 2 | ADD `recursive` TINYINT(1) NOT NULL DEFAULT '0' 3 | AFTER `FK_entities`; -------------------------------------------------------------------------------- /sql/update-1.5.1.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `glpi_plugin_certificates` 2 | ADD `helpdesk_visible` INT(11) NOT NULL DEFAULT '1', 3 | ADD `date_mod` DATETIME DEFAULT NULL; -------------------------------------------------------------------------------- /sql/update-1.8.0.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `glpi_plugin_certificates_certificates` 2 | CHANGE `groups_id` `groups_id_tech` INT(11) NOT NULL DEFAULT '0', 3 | CHANGE `users_id` `users_id_tech` INT(11) NOT NULL DEFAULT '0'; -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Dear GLPi user. 2 | 3 | For bug reports, you can open an issue here, provide us : 4 | - The version of the plugin. 5 | - The version of your GLPI. 6 | - The steps to reproduce your issue. 7 | 8 | Delete this text to submit your issue. 9 | 10 | The Plugin team. 11 | -------------------------------------------------------------------------------- /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='Certificates Development Team' --package-name='GLPI - Certificates plugin' --package-version='1.9.0' -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 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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_certificates/resource/glpi/translation/$lang/?file=$_`; 22 | } 23 | } 24 | 25 | } 26 | } 27 | closedir DIRHANDLE; 28 | 29 | # 30 | # 31 | -------------------------------------------------------------------------------- /sql/update-1.5.0.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `glpi_plugin_certificates` 2 | CHANGE `query_date` `query_date` DATE NULL DEFAULT NULL; 3 | UPDATE `glpi_plugin_certificates` 4 | SET `query_date` = NULL 5 | WHERE `query_date` = '0000-00-00'; 6 | ALTER TABLE `glpi_plugin_certificates` 7 | CHANGE `expiration_date` `expiration_date` DATE NULL DEFAULT NULL; 8 | UPDATE `glpi_plugin_certificates` 9 | SET `expiration_date` = NULL 10 | WHERE `expiration_date` = '0000-00-00'; 11 | 12 | ALTER TABLE `glpi_plugin_certificates_profiles` 13 | ADD `open_ticket` CHAR(1) DEFAULT NULL; 14 | 15 | DROP TABLE IF EXISTS `glpi_plugin_certificates_default`; 16 | CREATE TABLE `glpi_plugin_certificates_default` ( 17 | `ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, 18 | `status` INT(11) NOT NULL 19 | ) 20 | ENGINE = MyISAM 21 | DEFAULT CHARSET = utf8 22 | COLLATE = utf8_unicode_ci; 23 | 24 | ALTER TABLE `glpi_plugin_certificates_profiles` 25 | DROP COLUMN `interface`, 26 | DROP COLUMN `is_default`; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # certificates 2 | Plugin certificates pour GLPI 3 | 4 | Attention, ce plugin est migré dans le coeur de GLPI à partir de la version 9.2. 5 | 6 | 7 | Ce plugin est sur Transifex - Aidez-nous à le traduire : 8 | https://www.transifex.com/tsmr/GLPI_certificates/ 9 | 10 | This plugin is on Transifex - Help us to translate : 11 | https://www.transifex.com/tsmr/GLPI_certificates/ 12 | 13 | Ce plugin vous permet de gérer les certificats de votre réseau et de les associer à des éléments de l'inventaire 14 | > * Un système d'alertes mail permet de vérifier les certificats qui vont ou qui ont expirés. 15 | > * Utilisable depuis le helpdesk 16 | > * Peut être intégré au plugin "environment":https://github.com/InfotelGLPI/environment. 17 | 18 | 19 | This plugin enables you to manage your certificates into your network and associate them with elements of the inventory. 20 | > * A mailing system allow to verify already expired or soon expired certificates. 21 | > * Can be used with helpdesk 22 | > * Can be integrated into "environment":https://github.com/InfotelGLPI/environment plugin. 23 | -------------------------------------------------------------------------------- /front/certificatestate.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | include('../../../inc/includes.php'); 31 | 32 | $dropdown = new PluginCertificatesCertificateState(); 33 | include(GLPI_ROOT . "/front/dropdown.common.php"); -------------------------------------------------------------------------------- /front/certificatetype.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | include('../../../inc/includes.php'); 31 | 32 | $dropdown = new PluginCertificatesCertificateType(); 33 | include(GLPI_ROOT . "/front/dropdown.common.php"); -------------------------------------------------------------------------------- /front/certificatestate.form.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | include('../../../inc/includes.php'); 30 | 31 | $dropdown = new PluginCertificatesCertificateState(); 32 | include(GLPI_ROOT . "/front/dropdown.common.form.php"); -------------------------------------------------------------------------------- /front/certificatetype.form.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | include('../../../inc/includes.php'); 31 | 32 | $dropdown = new PluginCertificatesCertificateType(); 33 | include(GLPI_ROOT . "/front/dropdown.common.form.php"); -------------------------------------------------------------------------------- /front/notification.state.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | include('../../../inc/includes.php'); 31 | 32 | Session::checkRight("config", UPDATE); 33 | 34 | $config = new PluginCertificatesConfig(); 35 | $notif = new PluginCertificatesNotificationState(); 36 | 37 | if (isset($_POST["add"])) { 38 | 39 | $notif->addNotificationState($_POST['plugin_certificates_certificatestates_id']); 40 | Html::back(); 41 | 42 | } else if (isset($_POST["delete"])) { 43 | 44 | foreach ($_POST["item"] as $key => $val) { 45 | if ($val == 1) { 46 | $notif->delete(array('id' => $key)); 47 | } 48 | } 49 | Html::back(); 50 | 51 | } else if (isset($_POST["update"])) { 52 | 53 | $config->update($_POST); 54 | Html::back(); 55 | 56 | } -------------------------------------------------------------------------------- /ajax/dropdownTypeCertificates.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | if (strpos($_SERVER['PHP_SELF'], "dropdownTypeCertificates.php")) { 31 | $AJAX_INCLUDE = 1; 32 | include('../../../inc/includes.php'); 33 | header("Content-Type: text/html; charset=UTF-8"); 34 | Html::header_nocache(); 35 | } 36 | 37 | 38 | Session::checkCentralAccess(); 39 | 40 | // Make a select box 41 | if (isset($_POST["certificatetype"])) { 42 | $used = array(); 43 | 44 | // Clean used array 45 | if (isset($_POST['used']) && is_array($_POST['used']) && (count($_POST['used']) > 0)) { 46 | $query = "SELECT `id` 47 | FROM `glpi_plugin_certificates_certificates` 48 | WHERE `id` IN (" . implode(',', $_POST['used']) . ") 49 | AND `plugin_certificates_certificatetypes_id` = '" . $_POST["certificatetype"] . "'"; 50 | 51 | foreach ($DB->request($query) AS $data) { 52 | $used[$data['id']] = $data['id']; 53 | } 54 | } 55 | 56 | Dropdown::show('PluginCertificatesCertificate', 57 | array('name' => $_POST['myname'], 58 | 'used' => $used, 59 | 'width' => '50%', 60 | 'entity' => $_POST['entity'], 61 | 'rand' => $_POST['rand'], 62 | 'condition' => "glpi_plugin_certificates_certificates.plugin_certificates_certificatetypes_id='" . $_POST["certificatetype"] . "'")); 63 | 64 | } -------------------------------------------------------------------------------- /inc/menu.class.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | /** 31 | * Class PluginCertificatesMenu 32 | */ 33 | class PluginCertificatesMenu extends CommonGLPI 34 | { 35 | static $rightname = 'plugin_certificates'; 36 | 37 | /** 38 | * @return translated 39 | */ 40 | static function getMenuName() 41 | { 42 | return _n('Certificate', 'Certificates', 2, 'certificates'); 43 | } 44 | 45 | /** 46 | * @return array 47 | */ 48 | static function getMenuContent() 49 | { 50 | 51 | $menu = array(); 52 | $menu['title'] = self::getMenuName(); 53 | $menu['page'] = "/plugins/certificates/front/certificate.php"; 54 | $menu['links']['search'] = PluginCertificatesCertificate::getSearchURL(false); 55 | if (PluginCertificatesCertificate::canCreate()) { 56 | $menu['links']['add'] = PluginCertificatesCertificate::getFormURL(false); 57 | } 58 | 59 | return $menu; 60 | } 61 | 62 | static function removeRightsFromSession() 63 | { 64 | if (isset($_SESSION['glpimenu']['assets']['types']['PluginCertificatesMenu'])) { 65 | unset($_SESSION['glpimenu']['assets']['types']['PluginCertificatesMenu']); 66 | } 67 | if (isset($_SESSION['glpimenu']['assets']['content']['plugincertificatesmenu'])) { 68 | unset($_SESSION['glpimenu']['assets']['content']['plugincertificatesmenu']); 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /inc/certificatestate.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 PluginCertificatesCertificateState 36 | */ 37 | class PluginCertificatesCertificateState extends CommonDropdown 38 | { 39 | 40 | static $rightname = "dropdown"; 41 | var $can_be_translated = true; 42 | 43 | /** 44 | * @param int $nb 45 | * @return string|translated 46 | */ 47 | static function getTypeName($nb = 0) 48 | { 49 | 50 | return _n('Certificate status', 'Certificate statuses', $nb, 'certificates'); 51 | } 52 | 53 | /** 54 | * @param $ID 55 | * @param $entity 56 | * @return ID|int|the 57 | */ 58 | static function transfer($ID, $entity) 59 | { 60 | global $DB; 61 | 62 | if ($ID > 0) { 63 | // Not already transfer 64 | // Search init item 65 | $query = "SELECT * 66 | FROM `glpi_plugin_certificates_certificatestates` 67 | WHERE `id` = '$ID'"; 68 | 69 | if ($result = $DB->query($query)) { 70 | if ($DB->numrows($result)) { 71 | $data = $DB->fetch_assoc($result); 72 | $data = Toolbox::addslashes_deep($data); 73 | $input['name'] = $data['name']; 74 | $input['entities_id'] = $entity; 75 | $temp = new self(); 76 | $newID = $temp->getID(); 77 | 78 | if ($newID < 0) { 79 | $newID = $temp->import($input); 80 | } 81 | 82 | return $newID; 83 | } 84 | } 85 | } 86 | return 0; 87 | } 88 | } -------------------------------------------------------------------------------- /inc/certificatetype.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 for a Dropdown 35 | /** 36 | * Class PluginCertificatesCertificateType 37 | */ 38 | class PluginCertificatesCertificateType extends CommonDropdown 39 | { 40 | 41 | static $rightname = "dropdown"; 42 | var $can_be_translated = true; 43 | 44 | /** 45 | * @param int $nb 46 | * @return string|translated 47 | */ 48 | static function getTypeName($nb = 0) 49 | { 50 | 51 | return _n('Certificate type', 'Certificate types', $nb, 'certificates'); 52 | } 53 | 54 | /** 55 | * @param $ID 56 | * @param $entity 57 | * @return ID|int|the 58 | */ 59 | static function transfer($ID, $entity) 60 | { 61 | global $DB; 62 | 63 | if ($ID > 0) { 64 | // Not already transfer 65 | // Search init item 66 | $query = "SELECT * 67 | FROM `glpi_plugin_certificates_certificatetypes` 68 | WHERE `id` = '$ID'"; 69 | 70 | if ($result = $DB->query($query)) { 71 | if ($DB->numrows($result)) { 72 | $data = $DB->fetch_assoc($result); 73 | $data = Toolbox::addslashes_deep($data); 74 | $input['name'] = $data['name']; 75 | $input['entities_id'] = $entity; 76 | $temp = new self(); 77 | $newID = $temp->getID(); 78 | 79 | if ($newID < 0) { 80 | $newID = $temp->import($input); 81 | } 82 | 83 | return $newID; 84 | } 85 | } 86 | } 87 | return 0; 88 | } 89 | } -------------------------------------------------------------------------------- /inc/notificationtargetcertificate.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 NotificationTarget 35 | /** 36 | * Class PluginCertificatesNotificationTargetCertificate 37 | */ 38 | class PluginCertificatesNotificationTargetCertificate extends NotificationTarget 39 | { 40 | 41 | /** 42 | * @return array 43 | */ 44 | function getEvents() 45 | { 46 | return array('ExpiredCertificates' => __('Expired certificates', 'certificates'), 47 | 'CertificatesWhichExpire' => __('Expiring certificates', 'certificates')); 48 | } 49 | 50 | /** 51 | * @param $event 52 | * @param array $options 53 | */ 54 | function getDatasForTemplate($event, $options = array()) 55 | { 56 | 57 | $this->datas['##certificate.entity##'] = 58 | Dropdown::getDropdownName('glpi_entities', 59 | $options['entities_id']); 60 | $this->datas['##lang.certificate.entity##'] = __('Entity'); 61 | $this->datas['##certificate.action##'] = ($event == "ExpiredCertificates" ? __('Expired certificates', 'certificates') : 62 | __('Expiring certificates', 'certificates')); 63 | 64 | $this->datas['##lang.certificate.name##'] = __('Name'); 65 | $this->datas['##lang.certificate.dateexpiration##'] = __('Expiration date'); 66 | 67 | foreach ($options['certificates'] as $id => $certificate) { 68 | $tmp = array(); 69 | 70 | $tmp['##certificate.name##'] = $certificate['name']; 71 | $tmp['##certificate.dateexpiration##'] = Html::convDate($certificate['date_expiration']); 72 | 73 | $this->datas['certificates'][] = $tmp; 74 | } 75 | } 76 | 77 | /** 78 | * 79 | */ 80 | function getTags() 81 | { 82 | 83 | $tags = array('certificate.name' => __('Name'), 84 | 'certificate.dateexpiration' => __('Expiration date')); 85 | foreach ($tags as $tag => $label) { 86 | $this->addTagToList(array('tag' => $tag, 'label' => $label, 87 | 'value' => true)); 88 | } 89 | 90 | $this->addTagToList(array('tag' => 'certificates', 91 | 'label' => __('Expired or expiring certificates', 'certificates'), 92 | 'value' => false, 93 | 'foreach' => true, 94 | 'events' => array('CertificatesWhichExpire', 'ExpiredCertificates'))); 95 | 96 | asort($this->tag_descriptions); 97 | } 98 | } -------------------------------------------------------------------------------- /front/certificate.form.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | include('../../../inc/includes.php'); 31 | 32 | if (!isset($_GET["id"])) $_GET["id"] = ""; 33 | if (!isset($_GET["withtemplate"])) $_GET["withtemplate"] = ""; 34 | 35 | $certif = new PluginCertificatesCertificate(); 36 | $certif_item = new PluginCertificatesCertificate_Item(); 37 | 38 | if (isset($_POST["add"])) { 39 | $certif->check(-1, CREATE, $_POST); 40 | $newID = $certif->add($_POST); 41 | if ($_SESSION['glpibackcreated']) { 42 | Html::redirect($certif->getFormURL() . "?id=" . $newID); 43 | } 44 | Html::back(); 45 | 46 | } else if (isset($_POST["delete"])) { 47 | 48 | $certif->check($_POST['id'], DELETE); 49 | $certif->delete($_POST); 50 | $certif->redirectToList(); 51 | 52 | } else if (isset($_POST["restore"])) { 53 | 54 | $certif->check($_POST['id'], PURGE); 55 | $certif->restore($_POST); 56 | $certif->redirectToList(); 57 | 58 | } else if (isset($_POST["purge"])) { 59 | 60 | $certif->check($_POST['id'], PURGE); 61 | $certif->delete($_POST, 1); 62 | $certif->redirectToList(); 63 | 64 | } else if (isset($_POST["update"])) { 65 | 66 | $certif->check($_POST['id'], UPDATE); 67 | $certif->update($_POST); 68 | Html::back(); 69 | 70 | } else if (isset($_POST["additem"])) { 71 | 72 | if (!empty($_POST['itemtype']) && $_POST['items_id'] > 0) { 73 | $certif_item->check(-1, UPDATE, $_POST); 74 | $certif_item->addItem($_POST); 75 | } 76 | Html::back(); 77 | 78 | } else if (isset($_POST["deleteitem"])) { 79 | 80 | foreach ($_POST["item"] as $key => $val) { 81 | $input = array('id' => $key); 82 | if ($val == 1) { 83 | $certif_item->check($key, UPDATE); 84 | $certif_item->delete($input); 85 | } 86 | } 87 | Html::back(); 88 | 89 | } else if (isset($_POST["deletecertificates"])) { 90 | 91 | $input = array('id' => $_POST["id"]); 92 | $certif_item->check($_POST["id"], UPDATE); 93 | $certif_item->delete($input); 94 | Html::back(); 95 | 96 | } else { 97 | 98 | $certif->checkGlobal(READ); 99 | 100 | $plugin = new Plugin(); 101 | if ($plugin->isActivated("environment")) { 102 | Html::header(PluginCertificatesCertificate::getTypeName(2), '', "assets", "pluginenvironmentdisplay", "certificates"); 103 | } else { 104 | Html::header(PluginCertificatesCertificate::getTypeName(2), '', "assets", "plugincertificatesmenu"); 105 | } 106 | $certif->display($_GET); 107 | 108 | Html::footer(); 109 | } -------------------------------------------------------------------------------- /setup.php: -------------------------------------------------------------------------------- 1 | . 27 | -------------------------------------------------------------------------- 28 | */ 29 | 30 | // Init the hooks of the plugins -Needed 31 | function plugin_init_certificates() 32 | { 33 | global $PLUGIN_HOOKS; 34 | 35 | $PLUGIN_HOOKS['csrf_compliant']['certificates'] = true; 36 | $PLUGIN_HOOKS['change_profile']['certificates'] = array('PluginCertificatesProfile', 'initProfile'); 37 | $PLUGIN_HOOKS['assign_to_ticket']['certificates'] = true; 38 | 39 | 40 | if (Session::getLoginUserID()) { 41 | 42 | // Params : plugin name - string type - number - attributes 43 | Plugin::registerClass('PluginCertificatesCertificate', array( 44 | 'linkgroup_tech_types' => true, 45 | 'linkuser_tech_types' => true, 46 | 'document_types' => true, 47 | 'helpdesk_visible_types' => true, 48 | 'ticket_types' => true, 49 | 'contract_types' => true, 50 | 'notificationtemplates_types' => true 51 | )); 52 | 53 | Plugin::registerClass('PluginCertificatesConfig', 54 | array('addtabon' => 'CronTask')); 55 | 56 | Plugin::registerClass('PluginCertificatesProfile', 57 | array('addtabon' => 'Profile')); 58 | 59 | if (class_exists('PluginAccountsAccount')) { 60 | PluginAccountsAccount::registerType('PluginCertificatesCertificate'); 61 | } 62 | 63 | $plugin = new Plugin(); 64 | if (!$plugin->isActivated('environment') 65 | && Session::haveRight("plugin_certificates", READ) 66 | ) { 67 | 68 | $PLUGIN_HOOKS['menu_toadd']['certificates'] = array('assets' => 'PluginCertificatesMenu'); 69 | } 70 | if (Session::haveRight("plugin_certificates", UPDATE)) { 71 | $PLUGIN_HOOKS['use_massive_action']['certificates'] = 1; 72 | } 73 | 74 | // End init, when all types are registered 75 | $PLUGIN_HOOKS['post_init']['certificates'] = 'plugin_certificates_postinit'; 76 | } 77 | } 78 | 79 | // Get the name and the version of the plugin - Needed 80 | /** 81 | * @return array 82 | */ 83 | function plugin_version_certificates() 84 | { 85 | 86 | return array( 87 | 'name' => _n('Certificate', 'Certificates', 2, 'certificates'), 88 | 'version' => '2.3.0', 89 | 'license' => 'GPLv2+', 90 | 'author' => "Infotel", 91 | 'homepage' => 'https://github.com/InfotelGLPI/certificates', 92 | 'minGlpiVersion' => '9.2', 93 | ); 94 | } 95 | 96 | // Optional : check prerequisites before install : may print errors or add to message after redirect 97 | /** 98 | * @return bool 99 | */ 100 | function plugin_certificates_check_prerequisites() 101 | { 102 | if (version_compare(GLPI_VERSION, '9.2', 'lt') || version_compare(GLPI_VERSION, '9.3', 'ge')) { 103 | echo __('This plugin requires GLPI >= 9.2', 'certificates'); 104 | return false; 105 | } 106 | return true; 107 | } 108 | 109 | // Uninstall process for plugin : need to return true if succeeded : may display messages or add to message after redirect 110 | /** 111 | * @return bool 112 | */ 113 | function plugin_certificates_check_config() 114 | { 115 | return true; 116 | } -------------------------------------------------------------------------------- /inc/config.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 PluginCertificatesConfig 36 | */ 37 | class PluginCertificatesConfig extends CommonDBTM 38 | { 39 | 40 | /** 41 | * @param CommonGLPI $item 42 | * @param int $withtemplate 43 | * @return string|translated 44 | */ 45 | function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) 46 | { 47 | 48 | if ($item->getType() == 'CronTask' && $item->getField('name') == "CertificatesAlert") { 49 | return __('Plugin Setup', 'certificates'); 50 | } 51 | return ''; 52 | } 53 | 54 | 55 | /** 56 | * @param CommonGLPI $item 57 | * @param int $tabnum 58 | * @param int $withtemplate 59 | * @return bool 60 | */ 61 | static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) 62 | { 63 | global $CFG_GLPI; 64 | 65 | if ($item->getType() == 'CronTask') { 66 | 67 | $target = $CFG_GLPI["root_doc"] . "/plugins/certificates/front/notification.state.php"; 68 | PluginCertificatesCertificate::configCron($target); 69 | } 70 | return true; 71 | } 72 | 73 | /** 74 | * @param $target 75 | * @param $ID 76 | */ 77 | function showForm($target, $ID) 78 | { 79 | 80 | $this->getFromDB($ID); 81 | $delay_expired = $this->fields["delay_expired"]; 82 | $delay_whichexpire = $this->fields["delay_whichexpire"]; 83 | echo "
| "; 40 | 41 | Html::showSimpleForm($_SERVER['PHP_SELF'], 'migration', __('Core migration', 'certificates'), 42 | array('do_migration' => '1'), '', '', 43 | array(__('Are you sure you want to do core migration ??', 'certificates'), 44 | __('Warning existants Certificates will be migrated !!', 'certificates'))); 45 | 46 | echo " |