diff --git a/.gitignore b/.gitignore index 283db0a..1b50875 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ dist/ vendor/ .gh_token *.min.* +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index d97e91d..3eabbd8 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,10 @@ * [Synopsis](#synopsis) * [Build Status](#build-status) +* [Updates Roadmap for version 3.0](#updates-roadmap-for-version-3) +* [New TelegramBot Commands](#new-telegramBot-commands) * [Installation](#installation) +* [Installation and Configuration step by step](#installation-and-configuration-step-by-step) * [Documentation](#documentation) * [Versioning](#versioning) * [Contact](#contact) @@ -31,12 +34,212 @@ This Bot for GLPI allows you to get notifications on Telegram when a ticket is c |:---:|:---:| |[![Travis CI build](https://api.travis-ci.org/pluginsGLPI/telegrambot.svg?branch=master)](https://travis-ci.org/pluginsGLPI/telegrambot/)|[![Travis CI build](https://api.travis-ci.org/pluginsGLPI/telegrambot.svg?branch=develop)](https://travis-ci.org/pluginsGLPI/telegrambot/)| +## Updates Roadmap for version 3.0 + + - [x] New Ticket. + - [x] Search ticket. + - [x] New followup. + - [x] Support group notification. + - [x] Login. + +## New TelegramBot Commands: +**Commands List:** +``` +/help - Show bot commands help. +/login - Login via Telegrambot for GLPI. The login command will only work on private chat. +Group chat Login Command is forbidden. +/newfollowup - Add a new followup to a ticket on GLPI via TelegramBot. +/newticket - Add a new ticket on GLPI via TelegramBot. +/searchticket - Search for a ticket on GLPI via TelegramBot. + +For exact command help type: /help +Or just type the command name: / +``` + ## Installation Click on the image to view the video preview. [![Everything Is AWESOME](http://img.youtube.com/vi/TKqIpIaAIAE/0.jpg)](https://youtu.be/TKqIpIaAIAE) +## Installation and Configuration step by step + +Here is a step by step of the video above: + +- Create your Telegram BOT on Telegram App: + - Search for BotFather on Telegram. + - Start a new chat with it. + - Type /newbot and send. + - BotFather will reply: + > Alright, a new bot. How are we going to call it? Please choose a name for your bot. + - Type the name of your bot and send. Ex.: GLPI Telegrambot Demo. + - BotFather will reply again: + > Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot. + - Type the username of your bot and send. Ex.: glpi_telegrambot_demo_bot. + - Finally BotFather replies with: + > Done! Congratulations on your new bot. You will find it at t.me/glpi_telegrambot_demo_bot. + > You can now add a description, about section and profile picture for your bot, see /help for a + > list of commands. By the way, when you've finished creating your cool bot, ping our Bot Support + > if you want a better username for it. Just make sure the bot is fully operational before you do this. + > + > Use this token to access the HTTP API: + > 872970295:AAFsALgD0WH9BOp-ZU282JVN_lW3l56GZEA + > Keep your token secure and store it safely, it can be used by anyone to control your bot. + > + > For a description of the Bot API, see this page: https://core.telegram.org/bots/api + - Save the token to access and the bot username to use it late. + +- Config your bot to group messages: + - Now type /setprivacy to BotFather. This command can be executed any time. + - BotFather replies with: + > Choose a bot to change group messages settings. + - Type (or select) @ + (change to the username you set at step 5 above, but start it with @) Ex.: glpi_telegrambot_demo_bot. + - BotFather replies with: + > 'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username. + > 'Disable' - your bot will receive all messages that people send to groups. + > Current status is: ENABLED + - Type (or select) Disable to let your bot receive all messages sent to a group. This step is up to you actually. + - BotFather replies with: + > Success! The new status is: DISABLED. /help + +- Download: + - Go to the [download page](https://plugins.glpi-project.org/#/plugin/telegrambot) and get the latest version (3.0) of our plugin. + - Unpack the file and put the folder /telegrambot under: //glpi/plugins + - The final path must be: //glpi/plugins/telegrambot + +- Installation: + - On your GLPI application open the menu: Setup -> Plugins. + - You will see the catalog of plugins. + - Our TelegramBot for GLPI will be there on the list. + - On the column Action, click on the Install icon. + - After the installation click on the Enable icon. + - If your plugin installation didn't work, we have to make some workarounds: + **Unfortunately we have to make some changes on GLPI 9.4.x core to Telegrambot work properly:** + **Attention:** If all your Plugins folder name starts with lowercase letter, this modification has no impact at all on your GLPI Aplication. + - Go to file: **/glpi/inc/plugin.class.php** + + **Plugin::load() - line 161 (GLPI 9.4.2)** + ```php + static function load($name, $withhook = false) { + global $LOADED_PLUGINS; + $name = strtolower($name); //-> Add this line + ... + } + ``` + + **Plugin::loadLang() - line 193 (GLPI 9.4.2)** + ```php + static function loadLang($name, $forcelang = '', $coretrytoload = '') { + // $LANG needed : used when include lang file + global $CFG_GLPI, $LANG, $TRANSLATE; + $name = strtolower($name); //-> Add this line + ... + } + ``` + + **Plugin::doHook() - line 1105 and 1124 (GLPI 9.4.2)** + ```php + static function doHook ($name, $param = null) { + ... + if (isset($PLUGIN_HOOKS[$name]) && is_array($PLUGIN_HOOKS[$name])) { + foreach ($PLUGIN_HOOKS[$name] as $plug => $tab) { + $plug = strtolower($plug); //-> Add this line + ... + } else { // Standard hook call + if (isset($PLUGIN_HOOKS[$name]) && is_array($PLUGIN_HOOKS[$name])) { + foreach ($PLUGIN_HOOKS[$name] as $plug => $function) { + $plug = strtolower($plug); //-> Add this line + ... + } + ``` + + **Plugin::doHookFunction() - line 1158 (GLPI 9.4.2)** + ```php + static function doHookFunction($name, $parm = null) { + global $PLUGIN_HOOKS; + + $ret = $parm; + if (isset($PLUGIN_HOOKS[$name]) && is_array($PLUGIN_HOOKS[$name])) { + foreach ($PLUGIN_HOOKS[$name] as $plug => $function) { + $plug = strtolower($plug); //-> Add this line + ... + } + ``` + +- Setup the Notifications: + - On your GLPI application open the menu: Setup -> Notifications. + - A 'Notifications configuration' table will be displayed. + - You will see a 'Enable followup' option, change to Yes. + - You will see a 'Enable followups via Telegram' option, change to Yes. + - Click on Save button. + - A new table with the title 'Notifications' will appear. + - Click on 'Telegram followups configuration'. + - On 'Bot token' field PASTE the token to access the HTTP API given by BotFather. Ex.: 872970295:AAFsALgD0WH9BOp-ZU282JVN_lW3l56GZEA + - On 'Bot username' field PASTE the username of your bot on Telegram. Ex.: glpi_telegrambot_demo_bot. + - Click on 'Save' button. + +- Setup the Automatic actions: + - Open the menu: Setup -> Automatic actions. + - A list with the 'Automatic actions' will be displayed. + - Search for 'messagelistener' and click on it. + - A log page will be displayed. Click the menu button 'Automatic actions' on the left. + +- Configure the GLPI user: + - On your GLPI application open the menu: Administration -> Users. + - Select the user. Ex.: glpi. + - On the bottom of the form displayed, you will see a 'Telegram username' field. + - On this field put the Telegram username and save. + +- Setup the notification: + - On your GLPI application open the menu: Setup -> Notifications. + - On the Notification table, click on 'Notification templates'. + - Click on 'Add' icon and the 'New item - Notification template' form will be displayed. + - Choose a name for your template and the 'Type' choose 'ticket'. + - Click on 'Add' button. + - A 'New item - Template translation' form will be displayed. + - On 'Subject' field put the message that will be send to your Bot. + - On 'Email text body' field put the text: + ``` + New Ticket + ID: ##ticket.id## + Title: ##ticket.title## + ``` + - Click on 'Add' button. + - Go back to Setup -> Notifications -> Notifications. + - Click on 'Add' button. + - A 'New item - Notification' form will be displayed. + - Choose a name to your item notification. + - Change 'Active' field to 'Yes'. + - Change 'Type' field to 'Ticket'. + - Change 'Event' field to 'New ticket'. + - Click on 'Add' button. + - The notification page will be displayed. Click the menu button 'Templates' on the left. + - Click on 'Add a template' button. + - Change the 'Mode' field to 'Telegram'. + - Change the 'Notification template' to the name you choose before to your template. + - Click on 'Add' button. + - Go back to Setup -> Notifications -> Notifications. + - Search for the Notification you just added and click on it. + - The notification page will be displayed. Click the menu button 'Recipients' on the left. + - On the blank field, choose the options 'Administrator' and 'Requester' + - Click on 'Update' button. + +- Test your Bot: + - Go to your Telegram App and start a chat with your Bot. Ex.: glpi_telegrambot_demo_bot. + - Send a message: Ex.: Hello + - Go back to 'Automatic actions' page on GLPI and click on the button 'Execute' + - Click the menu button 'Logs' on the left. + - You will see a new entry. Thats our 'listener'. + +- Setup the Ticket: + - On your GLPI application open the menu: Assistance -> Create Ticket. + - Choose a 'Title' and a 'Description' to your Ticket. + - Click on 'Add' button. + +- Test your Bot result: + - After you Setup the Ticket, the user will receive a Notification Ticket on Telegram. + ## Documentation We maintain a detailed documentation of the project on the website, see our [How-tos](https://pluginsGLPI.github.io/telegrambot/howtos) and [Development](https://pluginsGLPI.github.io/telegrambot/) sections. diff --git a/composer.json b/composer.json index f2a34ce..fe09a75 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require-dev": { - "glpi-project/tools": "^0.1.2" + "glpi-project/tools": "^0.1.7" }, "require": { "longman/telegram-bot": "*" diff --git a/composer.lock b/composer.lock index d50b0c9..d156555 100644 --- a/composer.lock +++ b/composer.lock @@ -1,23 +1,23 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "85174c57096d21b24ec10c0e74aacf5d", + "content-hash": "7fde7abdaf94ce64da37f53c4f6412cb", "packages": [ { "name": "guzzlehttp/guzzle", - "version": "6.3.0", + "version": "6.3.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699" + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/f4db5a78a5ea468d4831de7f0bf9d9415e348699", - "reference": "f4db5a78a5ea468d4831de7f0bf9d9415e348699", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", "shasum": "" }, "require": { @@ -27,7 +27,7 @@ }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "^4.0 || ^5.0", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", "psr/log": "^1.0" }, "suggest": { @@ -36,7 +36,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.2-dev" + "dev-master": "6.3-dev" } }, "autoload": { @@ -69,7 +69,7 @@ "rest", "web service" ], - "time": "2017-06-22T18:50:49+00:00" + "time": "2018-04-22T15:46:56+00:00" }, { "name": "guzzlehttp/promises", @@ -124,32 +124,33 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.4.2", + "version": "1.5.2", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + "reference": "9f83dded91781a01c63574e387eaa769be769115" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115", + "reference": "9f83dded91781a01c63574e387eaa769be769115", "shasum": "" }, "require": { "php": ">=5.4.0", - "psr/http-message": "~1.0" + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5" }, "provide": { "psr/http-message-implementation": "1.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.5-dev" } }, "autoload": { @@ -179,39 +180,41 @@ "keywords": [ "http", "message", + "psr-7", "request", "response", "stream", "uri", "url" ], - "time": "2017-03-20T17:10:46+00:00" + "time": "2018-12-04T20:46:45+00:00" }, { "name": "longman/telegram-bot", - "version": "0.50.0", + "version": "0.57.0", "source": { "type": "git", "url": "https://github.com/php-telegram-bot/core.git", - "reference": "54823db1306a791830a7915072f03ff84fd7c4f3" + "reference": "f2fe6e322d961153b82c39f699edbedb5311d328" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-telegram-bot/core/zipball/54823db1306a791830a7915072f03ff84fd7c4f3", - "reference": "54823db1306a791830a7915072f03ff84fd7c4f3", + "url": "https://api.github.com/repos/php-telegram-bot/core/zipball/f2fe6e322d961153b82c39f699edbedb5311d328", + "reference": "f2fe6e322d961153b82c39f699edbedb5311d328", "shasum": "" }, "require": { "ext-curl": "*", + "ext-json": "*", "ext-mbstring": "*", "ext-pdo": "*", - "guzzlehttp/guzzle": "^6.2", - "monolog/monolog": "^1.22", + "guzzlehttp/guzzle": "^6.3", + "monolog/monolog": "^1.24", "php": "^5.5|^7.0" }, "require-dev": { - "phpunit/phpunit": "^4.8|^5.7|^6.1", - "squizlabs/php_codesniffer": "^2.8" + "phpunit/phpunit": "^4.8|^5.7|^6.5|^7.5|^8.1", + "squizlabs/php_codesniffer": "^3.4" }, "type": "library", "autoload": { @@ -229,6 +232,11 @@ "email": "akalongman@gmail.com", "homepage": "http://longman.me", "role": "Developer" + }, + { + "name": "PHP Telegram Bot Team", + "homepage": "https://github.com/php-telegram-bot/core/graphs/contributors", + "role": "Developer" } ], "description": "PHP Telegram bot", @@ -238,20 +246,20 @@ "bot", "telegram" ], - "time": "2017-10-17T12:09:43+00:00" + "time": "2019-06-01T09:42:08+00:00" }, { "name": "monolog/monolog", - "version": "1.23.0", + "version": "1.24.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4" + "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4", - "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", + "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", "shasum": "" }, "require": { @@ -316,7 +324,7 @@ "logging", "psr-3" ], - "time": "2017-06-19T01:22:40+00:00" + "time": "2018-11-05T09:00:11+00:00" }, { "name": "psr/http-message", @@ -370,16 +378,16 @@ }, { "name": "psr/log", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "shasum": "" }, "require": { @@ -413,39 +421,124 @@ "psr", "psr-3" ], - "time": "2016-10-10T12:19:37+00:00" + "time": "2018-11-20T15:27:04+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7.0", + "satooshi/php-coveralls": ">=1.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2016-02-11T07:05:27+00:00" } ], "packages-dev": [ { "name": "consolidation/annotated-command", - "version": "2.8.1", + "version": "2.12.0", "source": { "type": "git", "url": "https://github.com/consolidation/annotated-command.git", - "reference": "7f94009d732922d61408536f9228aca8f22e9135" + "reference": "512a2e54c98f3af377589de76c43b24652bcb789" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/7f94009d732922d61408536f9228aca8f22e9135", - "reference": "7f94009d732922d61408536f9228aca8f22e9135", + "url": "https://api.github.com/repos/consolidation/annotated-command/zipball/512a2e54c98f3af377589de76c43b24652bcb789", + "reference": "512a2e54c98f3af377589de76c43b24652bcb789", "shasum": "" }, "require": { - "consolidation/output-formatters": "^3.1.12", - "php": ">=5.4.0", + "consolidation/output-formatters": "^3.4", + "php": ">=5.4.5", "psr/log": "^1", - "symfony/console": "^2.8|~3", - "symfony/event-dispatcher": "^2.5|^3", - "symfony/finder": "^2.5|^3" + "symfony/console": "^2.8|^3|^4", + "symfony/event-dispatcher": "^2.5|^3|^4", + "symfony/finder": "^2.5|^3|^4" }, "require-dev": { - "phpunit/phpunit": "^4.8", - "satooshi/php-coveralls": "^1.0", + "g1a/composer-test-scenarios": "^3", + "php-coveralls/php-coveralls": "^1", + "phpunit/phpunit": "^6", "squizlabs/php_codesniffer": "^2.7" }, "type": "library", "extra": { + "scenarios": { + "symfony4": { + "require": { + "symfony/console": "^4.0" + }, + "config": { + "platform": { + "php": "7.1.3" + } + } + }, + "symfony2": { + "require": { + "symfony/console": "^2.8" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36" + }, + "remove": [ + "php-coveralls/php-coveralls" + ], + "config": { + "platform": { + "php": "5.4.8" + } + }, + "scenario-options": { + "create-lockfile": "false" + } + }, + "phpunit4": { + "require-dev": { + "phpunit/phpunit": "^4.8.36" + }, + "remove": [ + "php-coveralls/php-coveralls" + ], + "config": { + "platform": { + "php": "5.4.8" + } + } + } + }, "branch-alias": { "dev-master": "2.x-dev" } @@ -466,35 +559,67 @@ } ], "description": "Initialize Symfony Console commands from annotated command class methods.", - "time": "2017-10-17T01:48:51+00:00" + "time": "2019-03-08T16:55:03+00:00" }, { "name": "consolidation/config", - "version": "1.0.6", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/consolidation/config.git", - "reference": "a57ff3a302aac6f7e6fc0d81fe0778550a0fe9aa" + "reference": "cac1279bae7efb5c7fb2ca4c3ba4b8eb741a96c1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/config/zipball/a57ff3a302aac6f7e6fc0d81fe0778550a0fe9aa", - "reference": "a57ff3a302aac6f7e6fc0d81fe0778550a0fe9aa", + "url": "https://api.github.com/repos/consolidation/config/zipball/cac1279bae7efb5c7fb2ca4c3ba4b8eb741a96c1", + "reference": "cac1279bae7efb5c7fb2ca4c3ba4b8eb741a96c1", "shasum": "" }, "require": { "dflydev/dot-access-data": "^1.1.0", - "grasmash/yaml-expander": "^1.1", + "grasmash/expander": "^1", "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4", - "satooshi/php-coveralls": "^1.0", + "g1a/composer-test-scenarios": "^3", + "php-coveralls/php-coveralls": "^1", + "phpunit/phpunit": "^5", "squizlabs/php_codesniffer": "2.*", - "symfony/console": "^2.5|^3" + "symfony/console": "^2.5|^3|^4", + "symfony/yaml": "^2.8.11|^3|^4" + }, + "suggest": { + "symfony/yaml": "Required to use Consolidation\\Config\\Loader\\YamlConfigLoader" }, "type": "library", "extra": { + "scenarios": { + "symfony4": { + "require-dev": { + "symfony/console": "^4.0" + }, + "config": { + "platform": { + "php": "7.1.3" + } + } + }, + "symfony2": { + "require-dev": { + "symfony/console": "^2.8", + "symfony/event-dispatcher": "^2.8", + "phpunit/phpunit": "^4.8.36" + }, + "remove": [ + "php-coveralls/php-coveralls" + ], + "config": { + "platform": { + "php": "5.4.8" + } + } + } + }, "branch-alias": { "dev-master": "1.x-dev" } @@ -515,33 +640,76 @@ } ], "description": "Provide configuration services for a commandline tool.", - "time": "2017-10-17T17:09:36+00:00" + "time": "2019-03-03T19:37:04+00:00" }, { "name": "consolidation/log", - "version": "1.0.3", + "version": "1.1.1", "source": { "type": "git", "url": "https://github.com/consolidation/log.git", - "reference": "74ba81b4edc585616747cc5c5309ce56fec41254" + "reference": "b2e887325ee90abc96b0a8b7b474cd9e7c896e3a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/log/zipball/74ba81b4edc585616747cc5c5309ce56fec41254", - "reference": "74ba81b4edc585616747cc5c5309ce56fec41254", + "url": "https://api.github.com/repos/consolidation/log/zipball/b2e887325ee90abc96b0a8b7b474cd9e7c896e3a", + "reference": "b2e887325ee90abc96b0a8b7b474cd9e7c896e3a", "shasum": "" }, "require": { - "php": ">=5.5.0", - "psr/log": "~1.0", - "symfony/console": "~2.5|~3.0" + "php": ">=5.4.5", + "psr/log": "^1.0", + "symfony/console": "^2.8|^3|^4" }, "require-dev": { - "phpunit/phpunit": "4.*", - "squizlabs/php_codesniffer": "2.*" + "g1a/composer-test-scenarios": "^3", + "php-coveralls/php-coveralls": "^1", + "phpunit/phpunit": "^6", + "squizlabs/php_codesniffer": "^2" }, "type": "library", "extra": { + "scenarios": { + "symfony4": { + "require": { + "symfony/console": "^4.0" + }, + "config": { + "platform": { + "php": "7.1.3" + } + } + }, + "symfony2": { + "require": { + "symfony/console": "^2.8" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36" + }, + "remove": [ + "php-coveralls/php-coveralls" + ], + "config": { + "platform": { + "php": "5.4.8" + } + } + }, + "phpunit4": { + "require-dev": { + "phpunit/phpunit": "^4.8.36" + }, + "remove": [ + "php-coveralls/php-coveralls" + ], + "config": { + "platform": { + "php": "5.4.8" + } + } + } + }, "branch-alias": { "dev-master": "1.x-dev" } @@ -562,35 +730,87 @@ } ], "description": "Improved Psr-3 / Psr\\Log logger based on Symfony Console components.", - "time": "2016-03-23T23:46:42+00:00" + "time": "2019-01-01T17:30:51+00:00" }, { "name": "consolidation/output-formatters", - "version": "3.1.12", + "version": "3.5.0", "source": { "type": "git", "url": "https://github.com/consolidation/output-formatters.git", - "reference": "88ef346a1cefb92aab8b57a3214a6d5fc63f5d2a" + "reference": "99ec998ffb697e0eada5aacf81feebfb13023605" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/88ef346a1cefb92aab8b57a3214a6d5fc63f5d2a", - "reference": "88ef346a1cefb92aab8b57a3214a6d5fc63f5d2a", + "url": "https://api.github.com/repos/consolidation/output-formatters/zipball/99ec998ffb697e0eada5aacf81feebfb13023605", + "reference": "99ec998ffb697e0eada5aacf81feebfb13023605", "shasum": "" }, "require": { + "dflydev/dot-access-data": "^1.1.0", "php": ">=5.4.0", - "symfony/console": "^2.8|~3", - "symfony/finder": "~2.5|~3.0" + "symfony/console": "^2.8|^3|^4", + "symfony/finder": "^2.5|^3|^4" }, "require-dev": { - "phpunit/phpunit": "^4.8", - "satooshi/php-coveralls": "^1.0", + "g1a/composer-test-scenarios": "^3", + "php-coveralls/php-coveralls": "^1", + "phpunit/phpunit": "^5.7.27", "squizlabs/php_codesniffer": "^2.7", + "symfony/var-dumper": "^2.8|^3|^4", "victorjonsson/markdowndocs": "^1.3" }, + "suggest": { + "symfony/var-dumper": "For using the var_dump formatter" + }, "type": "library", "extra": { + "scenarios": { + "symfony4": { + "require": { + "symfony/console": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^6" + }, + "config": { + "platform": { + "php": "7.1.3" + } + } + }, + "symfony3": { + "require": { + "symfony/console": "^3.4", + "symfony/finder": "^3.4", + "symfony/var-dumper": "^3.4" + }, + "config": { + "platform": { + "php": "5.6.32" + } + } + }, + "symfony2": { + "require": { + "symfony/console": "^2.8" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.36" + }, + "remove": [ + "php-coveralls/php-coveralls" + ], + "config": { + "platform": { + "php": "5.4.8" + } + }, + "scenario-options": { + "create-lockfile": "false" + } + } + }, "branch-alias": { "dev-master": "3.x-dev" } @@ -611,48 +831,53 @@ } ], "description": "Format text by applying transformations provided by plug-in formatters.", - "time": "2017-10-12T19:38:03+00:00" + "time": "2019-05-30T23:16:01+00:00" }, { "name": "consolidation/robo", - "version": "dev-master", + "version": "1.4.9", "source": { "type": "git", "url": "https://github.com/consolidation/Robo.git", - "reference": "7eea0d3cf92ef0d76dbf0917b172b12054007621" + "reference": "5c6b3840a45afda1cbffbb3bb1f94dd5f9f83345" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/consolidation/Robo/zipball/7eea0d3cf92ef0d76dbf0917b172b12054007621", - "reference": "7eea0d3cf92ef0d76dbf0917b172b12054007621", + "url": "https://api.github.com/repos/consolidation/Robo/zipball/5c6b3840a45afda1cbffbb3bb1f94dd5f9f83345", + "reference": "5c6b3840a45afda1cbffbb3bb1f94dd5f9f83345", "shasum": "" }, "require": { - "consolidation/annotated-command": "^2.8.1", - "consolidation/config": "^1.0.1", + "consolidation/annotated-command": "^2.10.2", + "consolidation/config": "^1.2", "consolidation/log": "~1", - "consolidation/output-formatters": "^3.1.5", + "consolidation/output-formatters": "^3.1.13", + "consolidation/self-update": "^1", + "grasmash/yaml-expander": "^1.3", "league/container": "^2.2", "php": ">=5.5.0", - "symfony/console": "~2.8|~3.0", - "symfony/event-dispatcher": "~2.5|~3.0", - "symfony/filesystem": "~2.5|~3.0", - "symfony/finder": "~2.5|~3.0", - "symfony/process": "~2.5|~3.0" + "symfony/console": "^2.8|^3|^4", + "symfony/event-dispatcher": "^2.5|^3|^4", + "symfony/filesystem": "^2.5|^3|^4", + "symfony/finder": "^2.5|^3|^4", + "symfony/process": "^2.5|^3|^4" }, "replace": { "codegyre/robo": "< 1.0" }, "require-dev": { - "codeception/aspect-mock": "~1", - "codeception/base": "^2.2.6", + "codeception/aspect-mock": "^1|^2.1.1", + "codeception/base": "^2.3.7", "codeception/verify": "^0.3.2", - "henrikbjorn/lurker": "~1", + "g1a/composer-test-scenarios": "^3", + "goaop/framework": "~2.1.2", + "goaop/parser-reflection": "^1.1.0", "natxet/cssmin": "3.0.4", + "nikic/php-parser": "^3.1.5", "patchwork/jsqueeze": "~2", - "pear/archive_tar": "^1.4.2", + "pear/archive_tar": "^1.4.4", + "php-coveralls/php-coveralls": "^1", "phpunit/php-code-coverage": "~2|~4", - "satooshi/php-coveralls": "~1", "squizlabs/php_codesniffer": "^2.8" }, "suggest": { @@ -666,15 +891,39 @@ ], "type": "library", "extra": { + "scenarios": { + "symfony4": { + "require": { + "symfony/console": "^4" + }, + "config": { + "platform": { + "php": "7.1.3" + } + } + }, + "symfony2": { + "require": { + "symfony/console": "^2.8" + }, + "remove": [ + "goaop/framework" + ], + "config": { + "platform": { + "php": "5.5.9" + } + }, + "scenario-options": { + "create-lockfile": "false" + } + } + }, "branch-alias": { - "dev-master": "1.x-dev", - "dev-state": "1.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { - "classmap": [ - "scripts/composer/ScriptHandler.php" - ], "psr-4": { "Robo\\": "src" } @@ -690,7 +939,57 @@ } ], "description": "Modern task runner", - "time": "2017-10-19T18:38:53+00:00" + "time": "2019-03-19T18:07:19+00:00" + }, + { + "name": "consolidation/self-update", + "version": "1.1.5", + "source": { + "type": "git", + "url": "https://github.com/consolidation/self-update.git", + "reference": "a1c273b14ce334789825a09d06d4c87c0a02ad54" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/consolidation/self-update/zipball/a1c273b14ce334789825a09d06d4c87c0a02ad54", + "reference": "a1c273b14ce334789825a09d06d4c87c0a02ad54", + "shasum": "" + }, + "require": { + "php": ">=5.5.0", + "symfony/console": "^2.8|^3|^4", + "symfony/filesystem": "^2.5|^3|^4" + }, + "bin": [ + "scripts/release" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "SelfUpdate\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Greg Anderson", + "email": "greg.1.anderson@greenknowe.org" + }, + { + "name": "Alexander Menk", + "email": "menk@mestrona.net" + } + ], + "description": "Provides a self:update command for Symfony Console applications.", + "time": "2018-10-28T01:52:03+00:00" }, { "name": "container-interop/container-interop", @@ -784,30 +1083,30 @@ }, { "name": "glpi-project/coding-standard", - "version": "0.5", + "version": "0.7.1", "source": { "type": "git", "url": "https://github.com/glpi-project/coding-standard.git", - "reference": "e19495c896a01199a2fec2e65b7613310598cf96" + "reference": "1cef37d764aecf8fd7d5d167db25da97e289cb03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/glpi-project/coding-standard/zipball/e19495c896a01199a2fec2e65b7613310598cf96", - "reference": "e19495c896a01199a2fec2e65b7613310598cf96", + "url": "https://api.github.com/repos/glpi-project/coding-standard/zipball/1cef37d764aecf8fd7d5d167db25da97e289cb03", + "reference": "1cef37d764aecf8fd7d5d167db25da97e289cb03", "shasum": "" }, "require": { - "squizlabs/php_codesniffer": "~2.0" + "squizlabs/php_codesniffer": "^3.3" }, "type": "library", "notification-url": "https://packagist.org/downloads/", "license": [ - "GPLv3" + "GPL-2.0-or-later" ], "authors": [ { "name": "Teclib'", - "email": "contact@teclib.com", + "email": "glpi@teclib.com", "homepage": "https://teclib.com" } ], @@ -817,27 +1116,27 @@ "glpi", "phpcs" ], - "time": "2017-01-06T11:10:46+00:00" + "time": "2018-06-07T08:45:05+00:00" }, { "name": "glpi-project/tools", - "version": "0.1.2", + "version": "0.1.8", "source": { "type": "git", "url": "https://github.com/glpi-project/tools.git", - "reference": "55b3ba30c9c7f32acf5d9e8d6747e1e369809b13" + "reference": "39ca503a00454e6c5d7d97bd8baff358d262a897" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/glpi-project/tools/zipball/55b3ba30c9c7f32acf5d9e8d6747e1e369809b13", - "reference": "55b3ba30c9c7f32acf5d9e8d6747e1e369809b13", + "url": "https://api.github.com/repos/glpi-project/tools/zipball/39ca503a00454e6c5d7d97bd8baff358d262a897", + "reference": "39ca503a00454e6c5d7d97bd8baff358d262a897", "shasum": "" }, "require": { - "consolidation/robo": "dev-master@dev", - "glpi-project/coding-standard": "0.5", - "natxet/cssmin": "~3.0", - "patchwork/jsqueeze": "~1.0" + "consolidation/robo": "^1.3", + "glpi-project/coding-standard": "^0.7", + "natxet/cssmin": "^3.0", + "patchwork/jsqueeze": "^1.0" }, "bin": [ "tools/plugin-release", @@ -852,13 +1151,13 @@ }, "notification-url": "https://packagist.org/downloads/", "license": [ - "GPLv3" + "GPL-3.0-or-later" ], "authors": [ { "name": "Teclib'", "email": "glpi@teclib.com", - "homepage": "https://teclib.com" + "homepage": "http://teclib-group.com" } ], "description": "Various tools for GLPI and its plugins", @@ -867,30 +1166,78 @@ "plugins", "tools" ], - "time": "2017-03-03T14:40:45+00:00" + "time": "2019-06-07T09:46:17+00:00" + }, + { + "name": "grasmash/expander", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/grasmash/expander.git", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/grasmash/expander/zipball/95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "reference": "95d6037344a4be1dd5f8e0b0b2571a28c397578f", + "shasum": "" + }, + "require": { + "dflydev/dot-access-data": "^1.1.0", + "php": ">=5.4" + }, + "require-dev": { + "greg-1-anderson/composer-test-scenarios": "^1", + "phpunit/phpunit": "^4|^5.5.4", + "satooshi/php-coveralls": "^1.0.2|dev-master", + "squizlabs/php_codesniffer": "^2.7" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Grasmash\\Expander\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Matthew Grasmick" + } + ], + "description": "Expands internal property references in PHP arrays file.", + "time": "2017-12-21T22:14:55+00:00" }, { "name": "grasmash/yaml-expander", - "version": "1.2.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/grasmash/yaml-expander.git", - "reference": "9ec59ccc7a630eb2637639e8214e70d27675456b" + "reference": "3f0f6001ae707a24f4d9733958d77d92bf9693b1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/grasmash/yaml-expander/zipball/9ec59ccc7a630eb2637639e8214e70d27675456b", - "reference": "9ec59ccc7a630eb2637639e8214e70d27675456b", + "url": "https://api.github.com/repos/grasmash/yaml-expander/zipball/3f0f6001ae707a24f4d9733958d77d92bf9693b1", + "reference": "3f0f6001ae707a24f4d9733958d77d92bf9693b1", "shasum": "" }, "require": { "dflydev/dot-access-data": "^1.1.0", "php": ">=5.4", - "symfony/yaml": "^2.8.11|^3" + "symfony/yaml": "^2.8.11|^3|^4" }, "require-dev": { + "greg-1-anderson/composer-test-scenarios": "^1", "phpunit/phpunit": "^4.8|^5.5.4", - "satooshi/php-coveralls": "^1.0", + "satooshi/php-coveralls": "^1.0.2|dev-master", "squizlabs/php_codesniffer": "^2.7" }, "type": "library", @@ -914,7 +1261,7 @@ } ], "description": "Expands internal property references in a yaml file.", - "time": "2017-09-26T16:57:45+00:00" + "time": "2017-12-16T16:06:03+00:00" }, { "name": "league/container", @@ -982,17 +1329,17 @@ "time": "2017-05-10T09:20:27+00:00" }, { - "name": "natxet/CssMin", - "version": "v3.0.5", + "name": "natxet/cssmin", + "version": "v3.0.6", "source": { "type": "git", "url": "https://github.com/natxet/CssMin.git", - "reference": "9580f5448f05a82c96cfe6c7063a77807d8ec56d" + "reference": "d5d9f4c3e5cedb1ae96a95a21731f8790e38f1dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/natxet/CssMin/zipball/9580f5448f05a82c96cfe6c7063a77807d8ec56d", - "reference": "9580f5448f05a82c96cfe6c7063a77807d8ec56d", + "url": "https://api.github.com/repos/natxet/CssMin/zipball/d5d9f4c3e5cedb1ae96a95a21731f8790e38f1dd", + "reference": "d5d9f4c3e5cedb1ae96a95a21731f8790e38f1dd", "shasum": "" }, "require": { @@ -1026,7 +1373,7 @@ "css", "minify" ], - "time": "2017-10-04T16:54:00+00:00" + "time": "2018-01-09T11:15:01+00:00" }, { "name": "patchwork/jsqueeze", @@ -1121,64 +1468,37 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.9.1", + "version": "3.4.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62" + "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62", - "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", + "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", "shasum": "" }, "require": { "ext-simplexml": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": ">=5.1.2" + "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "bin": [ - "scripts/phpcs", - "scripts/phpcbf" + "bin/phpcs", + "bin/phpcbf" ], "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "3.x-dev" } }, - "autoload": { - "classmap": [ - "CodeSniffer.php", - "CodeSniffer/CLI.php", - "CodeSniffer/Exception.php", - "CodeSniffer/File.php", - "CodeSniffer/Fixer.php", - "CodeSniffer/Report.php", - "CodeSniffer/Reporting.php", - "CodeSniffer/Sniff.php", - "CodeSniffer/Tokens.php", - "CodeSniffer/Reports/", - "CodeSniffer/Tokenizers/", - "CodeSniffer/DocGenerators/", - "CodeSniffer/Standards/AbstractPatternSniff.php", - "CodeSniffer/Standards/AbstractScopeSniff.php", - "CodeSniffer/Standards/AbstractVariableSniff.php", - "CodeSniffer/Standards/IncorrectPatternException.php", - "CodeSniffer/Standards/Generic/Sniffs/", - "CodeSniffer/Standards/MySource/Sniffs/", - "CodeSniffer/Standards/PEAR/Sniffs/", - "CodeSniffer/Standards/PSR1/Sniffs/", - "CodeSniffer/Standards/PSR2/Sniffs/", - "CodeSniffer/Standards/Squiz/Sniffs/", - "CodeSniffer/Standards/Zend/Sniffs/" - ] - }, "notification-url": "https://packagist.org/downloads/", "license": [ "BSD-3-Clause" @@ -1190,53 +1510,60 @@ } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "http://www.squizlabs.com/php-codesniffer", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", "standards" ], - "time": "2017-05-22T02:43:20+00:00" + "time": "2019-04-10T23:49:02+00:00" }, { "name": "symfony/console", - "version": "v3.3.10", + "version": "v4.3.1", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "116bc56e45a8e5572e51eb43ab58c769a352366c" + "reference": "d50bbeeb0e17e6dd4124ea391eff235e932cbf64" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/116bc56e45a8e5572e51eb43ab58c769a352366c", - "reference": "116bc56e45a8e5572e51eb43ab58c769a352366c", + "url": "https://api.github.com/repos/symfony/console/zipball/d50bbeeb0e17e6dd4124ea391eff235e932cbf64", + "reference": "d50bbeeb0e17e6dd4124ea391eff235e932cbf64", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/debug": "~2.8|~3.0", - "symfony/polyfill-mbstring": "~1.0" + "php": "^7.1.3", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php73": "^1.8", + "symfony/service-contracts": "^1.1" }, "conflict": { - "symfony/dependency-injection": "<3.3" + "symfony/dependency-injection": "<3.4", + "symfony/event-dispatcher": "<4.3", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3", - "symfony/dependency-injection": "~3.3", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/filesystem": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "^4.3", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.4|~4.0", + "symfony/var-dumper": "^4.3" }, "suggest": { "psr/log": "For using the console logger", "symfony/event-dispatcher": "", - "symfony/filesystem": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -1263,41 +1590,55 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2019-06-05T13:25:51+00:00" }, { - "name": "symfony/debug", - "version": "v3.3.10", + "name": "symfony/event-dispatcher", + "version": "v4.3.1", "source": { "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "eb95d9ce8f18dcc1b3dfff00cb624c402be78ffd" + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "4e6c670af81c4fb0b6c08b035530a9915d0b691f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/eb95d9ce8f18dcc1b3dfff00cb624c402be78ffd", - "reference": "eb95d9ce8f18dcc1b3dfff00cb624c402be78ffd", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4e6c670af81c4fb0b6c08b035530a9915d0b691f", + "reference": "4e6c670af81c4fb0b6c08b035530a9915d0b691f", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "psr/log": "~1.0" + "php": "^7.1.3", + "symfony/event-dispatcher-contracts": "^1.1" }, "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + "symfony/dependency-injection": "<3.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "1.1" }, "require-dev": { - "symfony/http-kernel": "~2.8|~3.0" + "psr/log": "~1.0", + "symfony/config": "~3.4|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/expression-language": "~3.4|~4.0", + "symfony/http-foundation": "^3.4|^4.0", + "symfony/service-contracts": "^1.1", + "symfony/stopwatch": "~3.4|~4.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "4.3-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\Debug\\": "" + "Symfony\\Component\\EventDispatcher\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -1317,54 +1658,41 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Debug Component", + "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2019-05-30T16:10:05+00:00" }, { - "name": "symfony/event-dispatcher", - "version": "v3.3.10", + "name": "symfony/event-dispatcher-contracts", + "version": "v1.1.1", "source": { "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d7ba037e4b8221956ab1e221c73c9e27e05dd423" + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "8fa2cf2177083dd59cf8e44ea4b6541764fbda69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d7ba037e4b8221956ab1e221c73c9e27e05dd423", - "reference": "d7ba037e4b8221956ab1e221c73c9e27e05dd423", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/8fa2cf2177083dd59cf8e44ea4b6541764fbda69", + "reference": "8fa2cf2177083dd59cf8e44ea4b6541764fbda69", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" - }, - "conflict": { - "symfony/dependency-injection": "<3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~3.3", - "symfony/expression-language": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0" + "php": "^7.1.3" }, "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" + "psr/event-dispatcher": "", + "symfony/event-dispatcher-implementation": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "1.1-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] + "Symfony\\Contracts\\EventDispatcher\\": "" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1372,39 +1700,48 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony EventDispatcher Component", + "description": "Generic abstractions related to dispatching event", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-05-22T12:23:29+00:00" }, { "name": "symfony/filesystem", - "version": "v3.3.10", + "version": "v4.3.1", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "90bc45abf02ae6b7deb43895c1052cb0038506f1" + "reference": "bf2af40d738dec5e433faea7b00daa4431d0a4cf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/90bc45abf02ae6b7deb43895c1052cb0038506f1", - "reference": "90bc45abf02ae6b7deb43895c1052cb0038506f1", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/bf2af40d738dec5e433faea7b00daa4431d0a4cf", + "reference": "bf2af40d738dec5e433faea7b00daa4431d0a4cf", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -1431,29 +1768,29 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2017-10-03T13:33:10+00:00" + "time": "2019-06-03T20:27:40+00:00" }, { "name": "symfony/finder", - "version": "v3.3.10", + "version": "v4.3.1", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "773e19a491d97926f236942484cb541560ce862d" + "reference": "b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/773e19a491d97926f236942484cb541560ce862d", - "reference": "773e19a491d97926f236942484cb541560ce862d", + "url": "https://api.github.com/repos/symfony/finder/zipball/b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176", + "reference": "b3d4f4c0e4eadfdd8b296af9ca637cfbf51d8176", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -1480,20 +1817,78 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2019-05-26T20:47:49+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "82ebae02209c21113908c229e9883c419720738a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.6.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", - "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", "shasum": "" }, "require": { @@ -1505,7 +1900,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -1539,29 +1934,87 @@ "portable", "shim" ], - "time": "2017-10-11T12:05:26+00:00" + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/process", - "version": "v3.3.10", + "version": "v4.3.1", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "fdf89e57a723a29baf536e288d6e232c059697b1" + "reference": "856d35814cf287480465bb7a6c413bb7f5f5e69c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/fdf89e57a723a29baf536e288d6e232c059697b1", - "reference": "fdf89e57a723a29baf536e288d6e232c059697b1", + "url": "https://api.github.com/repos/symfony/process/zipball/856d35814cf287480465bb7a6c413bb7f5f5e69c", + "reference": "856d35814cf287480465bb7a6c413bb7f5f5e69c", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^7.1.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -1588,27 +2041,89 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2017-10-02T06:42:24+00:00" + "time": "2019-05-30T16:10:05+00:00" + }, + { + "name": "symfony/service-contracts", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "suggest": { + "psr/container": "", + "symfony/service-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "time": "2019-05-28T07:50:59+00:00" }, { "name": "symfony/yaml", - "version": "v3.3.10", + "version": "v4.3.1", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "8c7bf1e7d5d6b05a690b715729cb4cd0c0a99c46" + "reference": "c60ecf5ba842324433b46f58dc7afc4487dbab99" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/8c7bf1e7d5d6b05a690b715729cb4cd0c0a99c46", - "reference": "8c7bf1e7d5d6b05a690b715729cb4cd0c0a99c46", + "url": "https://api.github.com/repos/symfony/yaml/zipball/c60ecf5ba842324433b46f58dc7afc4487dbab99", + "reference": "c60ecf5ba842324433b46f58dc7afc4487dbab99", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8" + "php": "^7.1.3", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" }, "require-dev": { - "symfony/console": "~2.8|~3.0" + "symfony/console": "~3.4|~4.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -1616,7 +2131,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "4.3-dev" } }, "autoload": { @@ -1643,7 +2158,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-10-05T14:43:42+00:00" + "time": "2019-04-06T14:04:46+00:00" } ], "aliases": [], diff --git a/db/install.sql b/db/install.sql index 098838f..426ce8c 100644 --- a/db/install.sql +++ b/db/install.sql @@ -5,24 +5,26 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_users` ( ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_user` ( - `id` bigint COMMENT 'Unique user identifier', - `is_bot` tinyint(1) DEFAULT 0 COMMENT 'True if this user is a bot', - `first_name` CHAR(255) NOT NULL DEFAULT '' COMMENT 'User''s first name', - `last_name` CHAR(255) DEFAULT NULL COMMENT 'User''s last name', - `username` CHAR(191) DEFAULT NULL COMMENT 'User''s username', - `language_code` CHAR(10) DEFAULT NULL COMMENT 'User''s system language', + `id` bigint COMMENT 'Unique identifier for this user or bot', + `is_bot` tinyint(1) DEFAULT 0 COMMENT 'True, if this user is a bot', + `first_name` CHAR(255) NOT NULL DEFAULT '' COMMENT 'User''s or bot''s first name', + `last_name` CHAR(255) DEFAULT NULL COMMENT 'User''s or bot''s last name', + `username` CHAR(191) DEFAULT NULL COMMENT 'User''s or bot''s username', + `language_code` CHAR(10) DEFAULT NULL COMMENT 'IETF language tag of the user''s language', `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update', PRIMARY KEY (`id`), KEY `username` (`username`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_chat` ( - `id` bigint COMMENT 'Unique user or chat identifier', - `type` ENUM('private', 'group', 'supergroup', 'channel') NOT NULL COMMENT 'Chat type, either private, group, supergroup or channel', - `title` CHAR(255) DEFAULT '' COMMENT 'Chat (group) title, is null if chat type is private', + `id` bigint COMMENT 'Unique identifier for this chat', + `type` ENUM('private', 'group', 'supergroup', 'channel') NOT NULL COMMENT 'Type of chat, can be either private, group, supergroup or channel', + `title` CHAR(255) DEFAULT '' COMMENT 'Title, for supergroups, channels and group chats', `username` CHAR(255) DEFAULT NULL COMMENT 'Username, for private chats, supergroups and channels if available', + `first_name` CHAR(255) DEFAULT NULL COMMENT 'First name of the other party in a private chat', + `last_name` CHAR(255) DEFAULT NULL COMMENT 'Last name of the other party in a private chat', `all_members_are_administrators` tinyint(1) DEFAULT 0 COMMENT 'True if a all members of this group are admins', `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date update', @@ -30,7 +32,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_chat` ( PRIMARY KEY (`id`), KEY `old_id` (`old_id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_user_chat` ( `user_id` bigint COMMENT 'Unique user identifier', @@ -40,7 +42,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_user_chat` ( FOREIGN KEY (`user_id`) REFERENCES `glpi_plugin_telegrambot_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (`chat_id`) REFERENCES `glpi_plugin_telegrambot_chat` (`id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_inline_query` ( `id` bigint UNSIGNED COMMENT 'Unique identifier for this query', @@ -54,13 +56,13 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_inline_query` ( KEY `user_id` (`user_id`), FOREIGN KEY (`user_id`) REFERENCES `glpi_plugin_telegrambot_user` (`id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_chosen_inline_result` ( `id` bigint UNSIGNED AUTO_INCREMENT COMMENT 'Unique identifier for this entry', - `result_id` CHAR(255) NOT NULL DEFAULT '' COMMENT 'Identifier for this result', - `user_id` bigint NULL COMMENT 'Unique user identifier', - `location` CHAR(255) NULL DEFAULT NULL COMMENT 'Location object, user''s location', + `result_id` CHAR(255) NOT NULL DEFAULT '' COMMENT 'The unique identifier for the result that was chosen', + `user_id` bigint NULL COMMENT 'The user that chose the result', + `location` CHAR(255) NULL DEFAULT NULL COMMENT 'Sender location, only for bots that require user location', `inline_message_id` CHAR(255) NULL DEFAULT NULL COMMENT 'Identifier of the sent inline message', `query` TEXT NOT NULL COMMENT 'The query that was used to obtain the result', `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', @@ -69,7 +71,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_chosen_inline_result` ( KEY `user_id` (`user_id`), FOREIGN KEY (`user_id`) REFERENCES `glpi_plugin_telegrambot_user` (`id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_message` ( `chat_id` bigint COMMENT 'Unique chat identifier', @@ -79,22 +81,31 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_message` ( `forward_from` bigint NULL DEFAULT NULL COMMENT 'Unique user identifier, sender of the original message', `forward_from_chat` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier, chat the original message belongs to', `forward_from_message_id` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier of the original message in the channel', + `forward_signature` TEXT NULL DEFAULT NULL COMMENT 'For messages forwarded from channels, signature of the post author if present', + `forward_sender_name` TEXT NULL DEFAULT NULL COMMENT 'Sender''s name for messages forwarded from users who disallow adding a link to their account in forwarded messages', `forward_date` timestamp NULL DEFAULT NULL COMMENT 'date the original message was sent in timestamp format', `reply_to_chat` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier', `reply_to_message` bigint UNSIGNED DEFAULT NULL COMMENT 'Message that this message is reply to', + `edit_date` bigint UNSIGNED DEFAULT NULL COMMENT 'Date the message was last edited in Unix time', + `media_group_id` TEXT COMMENT 'The unique identifier of a media message group this message belongs to', + `author_signature` TEXT COMMENT 'Signature of the post author for messages in channels', `text` TEXT COMMENT 'For text messages, the actual UTF-8 text of the message max message length 4096 char utf8mb4', `entities` TEXT COMMENT 'For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text', + `caption_entities` TEXT COMMENT 'For messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption', `audio` TEXT COMMENT 'Audio object. Message is an audio file, information about the file', `document` TEXT COMMENT 'Document object. Message is a general file, information about the file', + `animation` TEXT COMMENT 'Message is an animation, information about the animation', + `game` TEXT COMMENT 'Game object. Message is a game, information about the game', `photo` TEXT COMMENT 'Array of PhotoSize objects. Message is a photo, available sizes of the photo', `sticker` TEXT COMMENT 'Sticker object. Message is a sticker, information about the sticker', `video` TEXT COMMENT 'Video object. Message is a video, information about the video', `voice` TEXT COMMENT 'Voice Object. Message is a Voice, information about the Voice', `video_note` TEXT COMMENT 'VoiceNote Object. Message is a Video Note, information about the Video Note', + `caption` TEXT COMMENT 'For message with caption, the actual UTF-8 text of the caption', `contact` TEXT COMMENT 'Contact object. Message is a shared contact, information about the contact', `location` TEXT COMMENT 'Location object. Message is a shared location, information about the location', `venue` TEXT COMMENT 'Venue object. Message is a Venue, information about the Venue', - `caption` TEXT COMMENT 'For message with caption, the actual UTF-8 text of the caption', + `poll` TEXT COMMENT 'Poll object. Message is a native poll, information about the poll', `new_chat_members` TEXT COMMENT 'List of unique user identifiers, new member(s) were added to the group, information about them (one of these members may be the bot itself)', `left_chat_member` bigint NULL DEFAULT NULL COMMENT 'Unique user identifier, a member was removed from the group, information about them (this member may be the bot itself)', `new_chat_title` CHAR(255) DEFAULT NULL COMMENT 'A chat title was changed to this value', @@ -106,6 +117,10 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_message` ( `migrate_to_chat_id` bigint NULL DEFAULT NULL COMMENT 'Migrate to chat identifier. The group has been migrated to a supergroup with the specified identifier', `migrate_from_chat_id` bigint NULL DEFAULT NULL COMMENT 'Migrate from chat identifier. The supergroup has been migrated from a group with the specified identifier', `pinned_message` TEXT NULL COMMENT 'Message object. Specified message was pinned', + `invoice` TEXT NULL COMMENT 'Message is an invoice for a payment, information about the invoice', + `successful_payment` TEXT NULL COMMENT 'Message is a service message about a successful payment, information about the payment', + `connected_website` TEXT NULL COMMENT 'The domain name of the website on which the user has logged in.', + `passport_data` TEXT NULL COMMENT 'Telegram Passport data', PRIMARY KEY (`chat_id`, `id`), KEY `user_id` (`user_id`), @@ -124,7 +139,27 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_message` ( FOREIGN KEY (`reply_to_chat`, `reply_to_message`) REFERENCES `glpi_plugin_telegrambot_message` (`chat_id`, `id`), FOREIGN KEY (`forward_from`) REFERENCES `glpi_plugin_telegrambot_user` (`id`), FOREIGN KEY (`left_chat_member`) REFERENCES `glpi_plugin_telegrambot_user` (`id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; + +CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_edited_message` ( + `id` bigint UNSIGNED AUTO_INCREMENT COMMENT 'Unique identifier for this entry', + `chat_id` bigint COMMENT 'Unique chat identifier', + `message_id` bigint UNSIGNED COMMENT 'Unique message identifier', + `user_id` bigint NULL COMMENT 'Unique user identifier', + `edit_date` timestamp NULL DEFAULT NULL COMMENT 'Date the message was edited in timestamp format', + `text` TEXT COMMENT 'For text messages, the actual UTF-8 text of the message max message length 4096 char utf8', + `entities` TEXT COMMENT 'For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text', + `caption` TEXT COMMENT 'For message with caption, the actual UTF-8 text of the caption', + + PRIMARY KEY (`id`), + KEY `chat_id` (`chat_id`), + KEY `message_id` (`message_id`), + KEY `user_id` (`user_id`), + + FOREIGN KEY (`chat_id`) REFERENCES `glpi_plugin_telegrambot_chat` (`id`), + FOREIGN KEY (`chat_id`, `message_id`) REFERENCES `glpi_plugin_telegrambot_message` (`chat_id`, `id`), + FOREIGN KEY (`user_id`) REFERENCES `glpi_plugin_telegrambot_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_callback_query` ( `id` bigint UNSIGNED COMMENT 'Unique identifier for this query', @@ -132,7 +167,9 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_callback_query` ( `chat_id` bigint NULL COMMENT 'Unique chat identifier', `message_id` bigint UNSIGNED COMMENT 'Unique message identifier', `inline_message_id` CHAR(255) NULL DEFAULT NULL COMMENT 'Identifier of the message sent via the bot in inline mode, that originated the query', + `chat_instance` CHAR(255) NOT NULL DEFAULT '' COMMENT 'Global identifier, uniquely corresponding to the chat to which the message with the callback button was sent', `data` CHAR(255) NOT NULL DEFAULT '' COMMENT 'Data associated with the callback button', + `game_short_name` CHAR(255) NOT NULL DEFAULT '' COMMENT 'Short name of a Game to be returned, serves as the unique identifier for the game', `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', PRIMARY KEY (`id`), @@ -142,50 +179,84 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_callback_query` ( FOREIGN KEY (`user_id`) REFERENCES `glpi_plugin_telegrambot_user` (`id`), FOREIGN KEY (`chat_id`, `message_id`) REFERENCES `glpi_plugin_telegrambot_message` (`chat_id`, `id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; -CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_edited_message` ( - `id` bigint UNSIGNED AUTO_INCREMENT COMMENT 'Unique identifier for this entry', - `chat_id` bigint COMMENT 'Unique chat identifier', - `message_id` bigint UNSIGNED COMMENT 'Unique message identifier', - `user_id` bigint NULL COMMENT 'Unique user identifier', - `edit_date` timestamp NULL DEFAULT NULL COMMENT 'Date the message was edited in timestamp format', - `text` TEXT COMMENT 'For text messages, the actual UTF-8 text of the message max message length 4096 char utf8', - `entities` TEXT COMMENT 'For text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text', - `caption` TEXT COMMENT 'For message with caption, the actual UTF-8 text of the caption', +CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_shipping_query` ( + `id` bigint UNSIGNED COMMENT 'Unique query identifier', + `user_id` bigint COMMENT 'User who sent the query', + `invoice_payload` CHAR(255) NOT NULL DEFAULT '' COMMENT 'Bot specified invoice payload', + `shipping_address` CHAR(255) NOT NULL DEFAULT '' COMMENT 'User specified shipping address', + `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', PRIMARY KEY (`id`), - KEY `chat_id` (`chat_id`), - KEY `message_id` (`message_id`), KEY `user_id` (`user_id`), - FOREIGN KEY (`chat_id`) REFERENCES `glpi_plugin_telegrambot_chat` (`id`), - FOREIGN KEY (`chat_id`, `message_id`) REFERENCES `glpi_plugin_telegrambot_message` (`chat_id`, `id`), FOREIGN KEY (`user_id`) REFERENCES `glpi_plugin_telegrambot_user` (`id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; + +CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_pre_checkout_query` ( + `id` bigint UNSIGNED COMMENT 'Unique query identifier', + `user_id` bigint COMMENT 'User who sent the query', + `currency` CHAR(3) COMMENT 'Three-letter ISO 4217 currency code', + `total_amount` bigint COMMENT 'Total price in the smallest units of the currency', + `invoice_payload` CHAR(255) NOT NULL DEFAULT '' COMMENT 'Bot specified invoice payload', + `shipping_option_id` CHAR(255) NULL COMMENT 'Identifier of the shipping option chosen by the user', + `order_info` TEXT NULL COMMENT 'Order info provided by the user', + `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', + + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`), + + FOREIGN KEY (`user_id`) REFERENCES `glpi_plugin_telegrambot_user` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; + +CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_poll` ( + `id` bigint UNSIGNED COMMENT 'Unique poll identifier', + `question` char(255) NOT NULL COMMENT 'Poll question', + `options` text NOT NULL COMMENT 'List of poll options', + `is_closed` tinyint(1) DEFAULT 0 COMMENT 'True, if the poll is closed', + `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', + + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_telegram_update` ( `id` bigint UNSIGNED COMMENT 'Update''s unique identifier', `chat_id` bigint NULL DEFAULT NULL COMMENT 'Unique chat identifier', - `message_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Unique message identifier', - `inline_query_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Unique inline query identifier', - `chosen_inline_result_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Local chosen inline result identifier', - `callback_query_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Unique callback query identifier', - `edited_message_id` bigint UNSIGNED DEFAULT NULL COMMENT 'Local edited message identifier', + `message_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New incoming message of any kind - text, photo, sticker, etc.', + `edited_message_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New version of a message that is known to the bot and was edited', + `channel_post_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New incoming channel post of any kind - text, photo, sticker, etc.', + `edited_channel_post_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New version of a channel post that is known to the bot and was edited', + `inline_query_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New incoming inline query', + `chosen_inline_result_id` bigint UNSIGNED DEFAULT NULL COMMENT 'The result of an inline query that was chosen by a user and sent to their chat partner', + `callback_query_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New incoming callback query', + `shipping_query_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New incoming shipping query. Only for invoices with flexible price', + `pre_checkout_query_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New incoming pre-checkout query. Contains full information about checkout', + `poll_id` bigint UNSIGNED DEFAULT NULL COMMENT 'New poll state. Bots receive only updates about polls, which are sent or stopped by the bot', PRIMARY KEY (`id`), KEY `message_id` (`chat_id`, `message_id`), + KEY `edited_message_id` (`edited_message_id`), + KEY `channel_post_id` (`channel_post_id`), + KEY `edited_channel_post_id` (`edited_channel_post_id`), KEY `inline_query_id` (`inline_query_id`), KEY `chosen_inline_result_id` (`chosen_inline_result_id`), KEY `callback_query_id` (`callback_query_id`), - KEY `edited_message_id` (`edited_message_id`), + KEY `shipping_query_id` (`shipping_query_id`), + KEY `pre_checkout_query_id` (`pre_checkout_query_id`), + KEY `poll_id` (`poll_id`), FOREIGN KEY (`chat_id`, `message_id`) REFERENCES `glpi_plugin_telegrambot_message` (`chat_id`, `id`), + FOREIGN KEY (`edited_message_id`) REFERENCES `glpi_plugin_telegrambot_edited_message` (`id`), + FOREIGN KEY (`chat_id`, `channel_post_id`) REFERENCES `glpi_plugin_telegrambot_message` (`chat_id`, `id`), + FOREIGN KEY (`edited_channel_post_id`) REFERENCES `glpi_plugin_telegrambot_edited_message` (`id`), FOREIGN KEY (`inline_query_id`) REFERENCES `glpi_plugin_telegrambot_inline_query` (`id`), FOREIGN KEY (`chosen_inline_result_id`) REFERENCES `glpi_plugin_telegrambot_chosen_inline_result` (`id`), FOREIGN KEY (`callback_query_id`) REFERENCES `glpi_plugin_telegrambot_callback_query` (`id`), - FOREIGN KEY (`edited_message_id`) REFERENCES `glpi_plugin_telegrambot_edited_message` (`id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; + FOREIGN KEY (`shipping_query_id`) REFERENCES `glpi_plugin_telegrambot_shipping_query` (`id`), + FOREIGN KEY (`pre_checkout_query_id`) REFERENCES `glpi_plugin_telegrambot_pre_checkout_query` (`id`), + FOREIGN KEY (`poll_id`) REFERENCES `glpi_plugin_telegrambot_poll` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_conversation` ( `id` bigint(20) unsigned AUTO_INCREMENT COMMENT 'Unique identifier for this entry', @@ -204,7 +275,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_conversation` ( FOREIGN KEY (`user_id`) REFERENCES `glpi_plugin_telegrambot_user` (`id`), FOREIGN KEY (`chat_id`) REFERENCES `glpi_plugin_telegrambot_chat` (`id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_botan_shortener` ( `id` bigint UNSIGNED AUTO_INCREMENT COMMENT 'Unique identifier for this entry', @@ -216,7 +287,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_botan_shortener` ( PRIMARY KEY (`id`), FOREIGN KEY (`user_id`) REFERENCES `glpi_plugin_telegrambot_user` (`id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_request_limiter` ( `id` bigint UNSIGNED AUTO_INCREMENT COMMENT 'Unique identifier for this entry', @@ -226,4 +297,4 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_telegrambot_request_limiter` ( `created_at` timestamp NULL DEFAULT NULL COMMENT 'Entry date creation', PRIMARY KEY (`id`) -) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; diff --git a/db/uninstall.sql b/db/uninstall.sql index d680364..836d4f4 100644 --- a/db/uninstall.sql +++ b/db/uninstall.sql @@ -8,6 +8,9 @@ DROP TABLE IF EXISTS `glpi_plugin_telegrambot_callback_query`; DROP TABLE IF EXISTS `glpi_plugin_telegrambot_message`; DROP TABLE IF EXISTS `glpi_plugin_telegrambot_chosen_inline_result`; DROP TABLE IF EXISTS `glpi_plugin_telegrambot_inline_query`; +DROP TABLE IF EXISTS `glpi_plugin_telegrambot_shipping_query`; +DROP TABLE IF EXISTS `glpi_plugin_telegrambot_pre_checkout_query`; DROP TABLE IF EXISTS `glpi_plugin_telegrambot_user_chat`; DROP TABLE IF EXISTS `glpi_plugin_telegrambot_chat`; DROP TABLE IF EXISTS `glpi_plugin_telegrambot_user`; +DROP TABLE IF EXISTS `glpi_plugin_telegrambot_poll`; \ No newline at end of file diff --git a/front/telegrambot_hook.php b/front/telegrambot_hook.php new file mode 100644 index 0000000..f9c9476 --- /dev/null +++ b/front/telegrambot_hook.php @@ -0,0 +1,55 @@ +. + -------------------------------------------------------------------------- + * + */ + +$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://'; + +if($protocol == 'http://'){ + echo '

ATTENTION: For this webhook work properly you must use HTTPS protocol.

'; + die; +} + +include ('../../../inc/includes.php'); + +require GLPI_ROOT . '/plugins/telegrambot/vendor/autoload.php'; + +$bot_api_key = PluginTelegrambotBot::getConfig('token'); +$bot_username = PluginTelegrambotBot::getConfig('bot_username'); +$hook_url = 'https://' . $_SERVER['SERVER_NAME'] . '/plugins/telegrambot/front/telegrambot_hook.php'; + +try { + // Create Telegram API object + $telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username); + + // Handle telegram webhook request + $telegram->handle(); +} catch (Longman\TelegramBot\Exception\TelegramException $e) { + // Silence is golden! + // Log telegram errors + Longman\TelegramBot\TelegramLog::error($e); +} \ No newline at end of file diff --git a/front/telegrambot_login.php b/front/telegrambot_login.php new file mode 100644 index 0000000..3648dbd --- /dev/null +++ b/front/telegrambot_login.php @@ -0,0 +1,57 @@ +. + -------------------------------------------------------------------------- + * + */ + +$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://'; + +include ('../../../inc/includes.php'); + +$token_login_data = PluginTelegrambotUser::validateTemporaryAccessToken(); + +if(!is_array($token_login_data)){ + // Redirect to login page + echo $token_login_data; + $url = $protocol . $_SERVER['SERVER_NAME'] . '/index.php'; + header('Location: '.$url); +} + +$auth = new Auth(); + +// now we can continue with the process... +if ($auth->login($token_login_data['user'], $token_login_data['pass'], false, false, 'local')) { + Auth::redirectIfAuthenticated(); +} else { + // we have done at least a good login? No, we exit. + Html::nullHeader("Login", $CFG_GLPI["root_doc"] . '/index.php'); + echo '
' . $auth->getErr() . '

'; + // Logout whit noAUto to manage auto_login with errors + echo '' .__('Log in again') . '
'; + Html::nullFooter(); + exit(); +} \ No newline at end of file diff --git a/hook.php b/hook.php index c8c921c..4cdb2f0 100644 --- a/hook.php +++ b/hook.php @@ -27,11 +27,12 @@ */ /** - * Plugin install process + * Install hook * * @return boolean */ -function plugin_telegrambot_install() { +function plugin_telegrambot_install() +{ global $DB; $DB->runFile(GLPI_ROOT . '/plugins/telegrambot/db/install.sql'); @@ -40,22 +41,24 @@ function plugin_telegrambot_install() { Config::setConfigurationValues('plugin:telegrambot', ['token' => '', 'bot_username' => '']); CronTask::register( - 'PluginTelegrambotCron', - 'messagelistener', - 5 * MINUTE_TIMESTAMP, - array('comment' => '', 'mode' => CronTask::MODE_EXTERNAL) + 'PluginTelegrambotCron', + 'messagelistener', + 3 * MINUTE_TIMESTAMP, + ['comment' => '', 'mode' => CronTask::MODE_EXTERNAL] ); return true; } /** - * Plugin uninstall process + * Uninstall hook * * @return boolean */ -function plugin_telegrambot_uninstall() { +function plugin_Telegrambot_uninstall() +{ global $DB; + $DB->runFile(GLPI_ROOT . '/plugins/telegrambot/db/uninstall.sql'); $config = new Config(); @@ -65,10 +68,11 @@ function plugin_telegrambot_uninstall() { return true; } -function add_username_field(array $params) { +function add_username_field(array $params) +{ $item = $params['item']; if ($item->getType() == 'User') { - PluginTelegrambotUser::showUsernameField($item); + PluginTelegrambotUser::showUsernameField($item); } } diff --git a/hook.php.tpl b/hook.php.tpl index d320574..4cdb2f0 100644 --- a/hook.php.tpl +++ b/hook.php.tpl @@ -27,19 +27,52 @@ */ /** - * Plugin install process + * Install hook * * @return boolean */ -function plugin_telegrambot_install() { +function plugin_telegrambot_install() +{ + global $DB; + + $DB->runFile(GLPI_ROOT . '/plugins/telegrambot/db/install.sql'); + + Config::setConfigurationValues('core', ['notifications_websocket' => 0]); + Config::setConfigurationValues('plugin:telegrambot', ['token' => '', 'bot_username' => '']); + + CronTask::register( + 'PluginTelegrambotCron', + 'messagelistener', + 3 * MINUTE_TIMESTAMP, + ['comment' => '', 'mode' => CronTask::MODE_EXTERNAL] + ); + return true; } /** - * Plugin uninstall process + * Uninstall hook * * @return boolean */ -function plugin_telegrambot_uninstall() { +function plugin_Telegrambot_uninstall() +{ + global $DB; + + $DB->runFile(GLPI_ROOT . '/plugins/telegrambot/db/uninstall.sql'); + + $config = new Config(); + $config->deleteConfigurationValues('core', ['notifications_websocket']); + $config->deleteConfigurationValues('plugin:telegrambot', ['token', 'bot_username']); + return true; } + +function add_username_field(array $params) +{ + $item = $params['item']; + + if ($item->getType() == 'User') { + PluginTelegrambotUser::showUsernameField($item); + } +} diff --git a/inc/Commands/HelpCommand.php b/inc/Commands/HelpCommand.php new file mode 100644 index 0000000..d7ef2b0 --- /dev/null +++ b/inc/Commands/HelpCommand.php @@ -0,0 +1,133 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Longman\TelegramBot\Commands\UserCommands; + +use Longman\TelegramBot\Commands\Command; +use Longman\TelegramBot\Commands\UserCommand; +use Longman\TelegramBot\Request; + +/** + * User "/help" command + * + * Command that lists all available commands and displays them in User and Admin sections. + */ +class HelpCommand extends UserCommand +{ + /** + * @var string + */ + protected $name = 'help'; + + /** + * @var string + */ + protected $description = 'Show bot commands help.'; + + /** + * @var string + */ + protected $usage = '/help or /help '; + + /** + * @var string + */ + protected $version = '1.3.0'; + + /** + * @inheritdoc + */ + public function execute() + { + $message = $this->getMessage(); + $chat_id = $message->getChat()->getId(); + $command_str = trim($message->getText(true)); + + // Admin commands shouldn't be shown in group chats + $safe_to_show = $message->getChat()->isPrivateChat(); + + $data = [ + 'chat_id' => $chat_id, + 'parse_mode' => 'markdown', + ]; + + list($all_commands, $user_commands, $admin_commands) = $this->getUserAdminCommands(); + + // If no command parameter is passed, show the list. + if ($command_str === '') { + $data['text'] = '*Commands List*:' . PHP_EOL; + foreach ($user_commands as $user_command) { + $data['text'] .= '/' . $user_command->getName() . ' - ' . $user_command->getDescription() . PHP_EOL; + } + + if ($safe_to_show && count($admin_commands) > 0) { + $data['text'] .= PHP_EOL . '*Admin Commands List*:' . PHP_EOL; + foreach ($admin_commands as $admin_command) { + $data['text'] .= '/' . $admin_command->getName() . ' - ' . $admin_command->getDescription() . PHP_EOL; + } + } + + $data['text'] .= PHP_EOL . 'For exact command help type: /help '; + + return Request::sendMessage($data); + } + + $command_str = str_replace('/', '', $command_str); + if (isset($all_commands[$command_str]) && ($safe_to_show || !$all_commands[$command_str]->isAdminCommand())) { + $command = $all_commands[$command_str]; + $data['text'] = sprintf( + 'Command: %s (v%s)' . PHP_EOL . + 'Description: %s' . PHP_EOL . + 'Usage: %s', + $command->getName(), + $command->getVersion(), + $command->getDescription(), + $command->getUsage() + ); + + return Request::sendMessage($data); + } + + $data['text'] = 'No help available: Command /' . $command_str . ' not found'; + + return Request::sendMessage($data); + } + + /** + * Get all available User and Admin commands to display in the help list. + * + * @return Command[][] + */ + protected function getUserAdminCommands() + { + // Only get enabled Admin and User commands that are allowed to be shown. + /** @var Command[] $commands */ + $commands = array_filter($this->telegram->getCommandsList(), function ($command) { + /** @var Command $command */ + return !$command->isSystemCommand() && $command->showInHelp() && $command->isEnabled(); + }); + + $user_commands = array_filter($commands, function ($command) { + /** @var Command $command */ + return $command->isUserCommand(); + }); + + $admin_commands = array_filter($commands, function ($command) { + /** @var Command $command */ + return $command->isAdminCommand(); + }); + + ksort($commands); + ksort($user_commands); + ksort($admin_commands); + + return [$commands, $user_commands, $admin_commands]; + } +} \ No newline at end of file diff --git a/inc/Commands/LoginCommand.php b/inc/Commands/LoginCommand.php new file mode 100644 index 0000000..f745267 --- /dev/null +++ b/inc/Commands/LoginCommand.php @@ -0,0 +1,87 @@ +. + -------------------------------------------------------------------------- + */ + +namespace Longman\TelegramBot\Commands\UserCommands; + +use Longman\TelegramBot\Commands\UserCommand; +use Longman\TelegramBot\Request; + +/** + * User "/echo" command + * + * Simply echo the input back to the user. + */ +class LoginCommand extends UserCommand +{ + /** + * @var string + */ + protected $name = 'login'; + + /** + * @var string + */ + protected $description = 'Login via Telegrambot for GLPI. The login command will only work on private chat. Group chat Login Command is forbidden.'; + + /** + * @var string + */ + protected $usage = '/login '; + + /** + * @var string + */ + protected $version = '1.0.0'; + + /** + * Command execute method + * + * @return \Longman\TelegramBot\Entities\ServerResponse + * @throws \Longman\TelegramBot\Exception\TelegramException + */ + public function execute() + { + $message = $this->getMessage(); + $chat_id = $message->getChat()->getId(); + $user_chat = $message->getFrom()->getUsername(); + $text = trim($message->getText(true)); + + if($message->getChat()->getType() == 'group'){ + $response = 'The login command will only work on private chat. Group chat Login Command is forbidden.'; + }else{ + $response = \PluginTelegrambotUser::userLoginViaTelegrambot($user_chat, $text); + } + + $data = [ + 'chat_id' => $chat_id, + 'text' => $response, + ]; + + return Request::sendMessage($data); + } +} \ No newline at end of file diff --git a/inc/Commands/NewfollowupCommand.php b/inc/Commands/NewfollowupCommand.php new file mode 100644 index 0000000..b2cfd3f --- /dev/null +++ b/inc/Commands/NewfollowupCommand.php @@ -0,0 +1,85 @@ +. + -------------------------------------------------------------------------- + */ + +namespace Longman\TelegramBot\Commands\UserCommands; + +use Longman\TelegramBot\Commands\UserCommand; +use Longman\TelegramBot\Request; + +/** + * User "/newfollowup" command + */ +class NewfollowupCommand extends UserCommand +{ + /** + * @var string + */ + protected $name = 'newfollowup'; + + /** + * @var string + */ + protected $description = 'Add a new followup to a ticket on GLPI via TelegramBot.'; + + /** + * @var string + */ + protected $usage = '/newfollowup **'; + + /** + * @var string + */ + protected $version = '1.0.0'; + + /** + * Command execute method + * + * @return \Longman\TelegramBot\Entities\ServerResponse + * @throws \Longman\TelegramBot\Exception\TelegramException + */ + public function execute() + { + $message = $this->getMessage(); + $chat_id = $message->getChat()->getId(); + $user_chat = $message->getFrom()->getUsername(); + $text = trim($message->getText(true)); + + $response = \PluginTelegrambotTicket::newFollowup($chat_id, $user_chat, $text); + + if(!$response){ + $response = 'Command usage: ' . $this->getUsage(); + } + + $data = [ + 'chat_id' => $chat_id, + 'text' => $response, + ]; + + return Request::sendMessage($data); + } +} \ No newline at end of file diff --git a/inc/Commands/NewticketCommand.php b/inc/Commands/NewticketCommand.php new file mode 100644 index 0000000..f7c8ea3 --- /dev/null +++ b/inc/Commands/NewticketCommand.php @@ -0,0 +1,85 @@ +. + -------------------------------------------------------------------------- + */ + +namespace Longman\TelegramBot\Commands\UserCommands; + +use Longman\TelegramBot\Commands\UserCommand; +use Longman\TelegramBot\Request; + +/** + * User "/newticket" command + */ +class NewticketCommand extends UserCommand +{ + /** + * @var string + */ + protected $name = 'newticket'; + + /** + * @var string + */ + protected $description = 'Add a new ticket on GLPI via TelegramBot.'; + + /** + * @var string + */ + protected $usage = '/newticket {"title": "", "description": ""}'; + + /** + * @var string + */ + protected $version = '1.0.0'; + + /** + * Command execute method + * + * @return \Longman\TelegramBot\Entities\ServerResponse + * @throws \Longman\TelegramBot\Exception\TelegramException + */ + public function execute() + { + $message = $this->getMessage(); + $chat_id = $message->getChat()->getId(); + $user_chat = $message->getFrom()->getUsername(); + $text = trim($message->getText(true)); + + $response = \PluginTelegrambotTicket::newTicket($chat_id, $user_chat, $text); + + if(!$response){ + $response = 'Command usage: ' . $this->getUsage(); + } + + $data = [ + 'chat_id' => $chat_id, + 'text' => $response, + ]; + + return Request::sendMessage($data); + } +} \ No newline at end of file diff --git a/inc/Commands/SearchticketCommand.php b/inc/Commands/SearchticketCommand.php new file mode 100644 index 0000000..9b33e78 --- /dev/null +++ b/inc/Commands/SearchticketCommand.php @@ -0,0 +1,84 @@ +. + -------------------------------------------------------------------------- + */ + +namespace Longman\TelegramBot\Commands\UserCommands; + +use Longman\TelegramBot\Commands\UserCommand; +use Longman\TelegramBot\Request; + +/** + * User "/searchticket" command + */ +class SearchticketCommand extends UserCommand +{ + /** + * @var string + */ + protected $name = 'searchticket'; + + /** + * @var string + */ + protected $description = 'Search for a ticket on GLPI via TelegramBot.'; + + /** + * @var string + */ + protected $usage = '/searchticket '; + + /** + * @var string + */ + protected $version = '1.0.0'; + + /** + * Command execute method + * + * @return \Longman\TelegramBot\Entities\ServerResponse + * @throws \Longman\TelegramBot\Exception\TelegramException + */ + public function execute() + { + $message = $this->getMessage(); + $chat_id = $message->getChat()->getId(); + $text = trim($message->getText(true)); + + $response = \PluginTelegrambotTicket::searchTicket($text); + + if(!$response){ + $response = 'Command usage: ' . $this->getUsage(); + } + + $data = [ + 'chat_id' => $chat_id, + 'text' => $response, + ]; + + return Request::sendMessage($data); + } +} \ No newline at end of file diff --git a/inc/bot.class.php b/inc/bot.class.php index 8410aeb..4347e09 100644 --- a/inc/bot.class.php +++ b/inc/bot.class.php @@ -27,79 +27,183 @@ */ require GLPI_ROOT . '/plugins/telegrambot/vendor/autoload.php'; -use Longman\TelegramBot\Request; -class PluginTelegrambotBot { +use Longman\TelegramBot\Request; - static public function getConfig($key) { - return Config::getConfigurationValues('plugin:telegrambot')[$key]; +class PluginTelegrambotBot +{ + + /** + * @var array Commands list + */ + static $commands_list = [ + '/newticket', + '/searchticket', + '/newfollowup', + '/login', + '/help', + '/echo', + ]; + + /** + * @var array Path to Commands classes folder + */ + static $commands_paths = [ + __DIR__ . '/Commands/', + ]; + + static public function getConfig($key) + { + return Config::getConfigurationValues('plugin:telegrambot')[$key]; } - static public function setConfig($key, $value) { - Config::setConfigurationValues('plugin:telegrambot', [$key => $value]); + static public function setConfig($key, $value) + { + Config::setConfigurationValues('plugin:telegrambot', [$key => $value]); } - static public function sendMessage($to, $content) { - $chat_id = self::getChatID($to); - $telegram = self::getTelegramInstance(); - $result = Request::sendMessage(['chat_id' => $chat_id, 'text' => $content]); + static public function sendMessage($to, $content) + { + $chat_id = self::getChatID($to); + $telegram = self::getTelegramInstance(); + $result = Request::sendMessage(['chat_id' => $chat_id, 'text' => $content]); } - static public function getUpdates() { - $response = 'ok'; + static public function getUpdates() + { + + try { + $telegram = self::getTelegramInstance(); + $telegram->enableMySql(self::getDBCredentials(), 'glpi_plugin_telegrambot_'); + $response = $telegram->handleGetUpdates(); - try { - $telegram = self::getTelegramInstance(); - $telegram->enableMySql(self::getDBCredentials(), 'glpi_plugin_telegrambot_'); - $telegram->handleGetUpdates(); - } catch (Longman\TelegramBot\Exception\TelegramException $e) { - $response = $e->getMessage(); - } + $response = 'ok'; + } catch (Longman\TelegramBot\Exception\TelegramException $e) { + $response = $e->getMessage(); + // self::printException($e); + } - return $response; + return $response; } - static public function getChatID($user_id) { - global $DB; + static public function getChatID($user_id) + { + global $DB; - $chat_id = null; + $chat_id = null; - $result = $DB->request([ - 'FROM' => 'glpi_plugin_telegrambot_users', - 'INNER JOIN' => [ - 'glpi_plugin_telegrambot_user' => [ - 'FKEY' => [ - 'glpi_plugin_telegrambot_users' => 'username', - 'glpi_plugin_telegrambot_user' => 'username' + $result = $DB->request([ + 'FROM' => 'glpi_plugin_telegrambot_users', + 'INNER JOIN' => [ + 'glpi_plugin_telegrambot_user' => [ + 'FKEY' => [ + 'glpi_plugin_telegrambot_users' => 'username', + 'glpi_plugin_telegrambot_user' => 'username' + ] ] - ] - ], - 'WHERE' => ['glpi_plugin_telegrambot_users.id' => $user_id] - ]); + ], + 'WHERE' => ['glpi_plugin_telegrambot_users.id' => $user_id] + ]); - if ($row = $result->next()) { - $chat_id = $row['id']; - } + if ($row = $result->next()) { + $chat_id = $row['id']; + } - return $chat_id; + return $chat_id; } - static private function getTelegramInstance() { - $bot_api_key = self::getConfig('token'); - $bot_username = self::getConfig('bot_username'); + static private function getTelegramInstance() + { + + $bot_api_key = self::getConfig('token'); + $bot_username = self::getConfig('bot_username'); + + try { + + // Create Telegram API object + $telegram = new Longman\TelegramBot\Telegram($bot_api_key, $bot_username); + + // Add commands paths containing our custom commands + $telegram->addCommandsPaths(self::$commands_paths); + + self::setTelegrambotWebhook($telegram); + + return $telegram; + } catch (Longman\TelegramBot\Exception\TelegramException $e) { + // Log telegram errors + Longman\TelegramBot\TelegramLog::error($e); + // self::printException($e); + } catch (Longman\TelegramBot\Exception\TelegramLogException $e) { + // Silence is golden! + // self::printException($e); + } + } + + /** + * Configure webhook to respond to the user without having to go through CronTask. + * @todo Set local server to work with HTTPS and SSL. + * @see: + * Simpler solution: https://gist.github.com/jfloff/5138826 + * Harder solution: https://really-simple-ssl.com/knowledge-base/how-to-install-an-ssl-certificate-on-mamp/ + */ + static private function setTelegrambotWebhook(&$telegram) + { + + $protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://'; + + if($protocol == 'http://'){ + //'ATTENTION: For this webhook work properly you must use HTTPS protocol.' + return false; + } + + $hook_url = 'https://' . $_SERVER['SERVER_NAME'] . '/plugins/telegrambot/front/telegrambot_hook.php'; + + try { + + $result = $telegram->setWebhook($hook_url); + if ($result->isOk()) { + //echo $result->getDescription(); + return true; + } + } catch (Longman\TelegramBot\Exception\TelegramException $e) { + // Silence is golden! + // log telegram errors + Longman\TelegramBot\TelegramLog::error($e); + return false; + // self::printException($e); + + } - return new Longman\TelegramBot\Telegram($bot_api_key, $bot_username); } - static private function getDBCredentials() { - global $DB; + static private function getDBCredentials() + { + global $DB; - return array( - 'host' => $DB->dbhost, - 'user' => $DB->dbuser, - 'password' => $DB->dbpassword, - 'database' => $DB->dbdefault, - ); + return [ + 'host' => $DB->dbhost, + 'user' => $DB->dbuser, + 'password' => $DB->dbpassword, + 'database' => $DB->dbdefault, + ]; + } + + /** + * Just print the Exception. + * Only for Developer use!!! + * + * @param object $e Exception + */ + static private function printException($e) + { + echo '
';
+        echo 'Error code: '.$e->getCode();
+        echo '
'; + echo 'Error Message: '.$e->getMessage(); + echo '
'; + var_dump($e); + die; + } -} +} \ No newline at end of file diff --git a/inc/ticket.class.php b/inc/ticket.class.php new file mode 100644 index 0000000..d21dcbf --- /dev/null +++ b/inc/ticket.class.php @@ -0,0 +1,248 @@ +. + -------------------------------------------------------------------------- + */ + +class PluginTelegrambotTicket extends CommonDBTM +{ + + /** + * Add a new Ticket via Telegrambot. + * + * @param string $text + * @return boolean|string + */ + static public function newTicket($chat_id, $user_chat, $text) + { + if ($text === '') { + return false; + } + + $new_ticket_data = json_decode($text); + + if (json_last_error() !== JSON_ERROR_NONE) { + return <<", "description": ""} +TXT; + } + + $glpi_user = PluginTelegrambotUser::getGlpiUserByTelegramUsername($user_chat); + $glpi_user_id = $glpi_user['id']; + if (!$glpi_user_id) { + return 'Your user was not found. You can\'t create a new ticket.'; + } + + global $DB; + + try { + + $DB->beginTransaction(); + + $table = 'glpi.glpi_tickets'; + + $params = [ + 'name' => $new_ticket_data->title, + 'date' => date("Y-m-d H:i:s"), + 'date_mod' => date("Y-m-d H:i:s"), + 'users_id_lastupdater' => $glpi_user_id, + 'status' => 2, + 'users_id_recipient' => $glpi_user_id, + 'requesttypes_id' => 1, + 'content' => $new_ticket_data->description, + 'urgency' => 3, + 'impact' => 3, + 'priority' => 3, + 'date_creation' => date("Y-m-d H:i:s"), + ]; + + $result = $DB->insert($table, $params); + + if (!$result) { + throw new Exception("Your Ticket could not be saved to the database. Error to insert Ticket data."); + } + + $ticket_id = $DB->insert_id(); + + $table = 'glpi.glpi_tickets_users'; + + $params = [ + 'tickets_id' => $ticket_id, + 'users_id' => $glpi_user_id, + 'type' => 1 + ]; + + $result = $DB->insert($table, $params); + if (!$result) { + throw new Exception("Your Ticket could not be saved to the database. Error to insert Ticket user data."); + } + + $params = [ + 'tickets_id' => $ticket_id, + 'users_id' => $glpi_user_id, + 'type' => 2 + ]; + + $result = $DB->insert($table, $params); + if (!$result) { + throw new Exception("Your Ticket could not be saved to the database. Error to insert Ticket user data."); + } + + $DB->commit(); + + return "Your Ticket was successfully saved. Ticket ID: $ticket_id."; + } catch (Exception $ex) { + $DB->rollBack(); + return $ex->getMessage(); + } + } + + /** + * Search for a ticket via Telegrambot. + * + * @param string $text + * @return boolean|string + */ + static public function searchTicket($text) + { + $ticket_id = (int) $text; + + if ($text === '' || $ticket_id == 0) { + return false; + } + + $response = 'Ticket not found.'; + + $ticket_data = self::getTicketData($ticket_id); + + if ($ticket_data) { + $ticket_id = $ticket_data['id']; + $ticket_title = $ticket_data['name']; + $ticket_description = strip_tags(html_entity_decode($ticket_data['content'])); + + $response = << 'Ticket', + 'items_id' => $ticket_id, + 'date' => date("Y-m-d H:i:s"), + 'users_id' => $glpi_user_id, + 'content' => htmlentities($followup_text), + 'requesttypes_id' => 1, + 'date_mod' => date("Y-m-d H:i:s"), + 'date_creation' => date("Y-m-d H:i:s"), + 'timeline_position' => 1, + 'sourceitems_id' => 0, + 'sourceof_items_id' => 0 + ]; + + $result = $DB->insert($table, $params); + + if (!$result) { + return "Your followup could not be saved to the database."; + } + + return "Your followup was successfully saved to the Ticket $ticket_id."; + } + + /** + * Return the ticket data. + * + * @global object $DB + * @param int $ticket_id + * @return boolean|array + */ + static private function getTicketData($ticket_id) + { + global $DB; + + $iterator = $DB->request([ + 'FROM' => 'glpi.glpi_tickets', + 'WHERE' => [ + 'glpi.glpi_tickets.id' => $ticket_id + ], + 'LIMIT' => 1 + ]); + + if ($ticket_data = $iterator->next()) { + return $ticket_data; + } + + return false; + } + +} diff --git a/inc/user.class.php b/inc/user.class.php index efe7cd2..32d7979 100644 --- a/inc/user.class.php +++ b/inc/user.class.php @@ -1,72 +1,172 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with TelegramBot. If not, see . + -------------------------------------------------------------------------- */ -class PluginTelegrambotUser extends CommonDBTM { - - static public function showUsernameField($item) { - $username = null; - - if ($item->fields['id']) { - $user = new self(); - $user->getFromDB($item->fields['id']); - - if (!$user->isNewItem()) { - $username = $user->fields['username']; - } - } - - $out = ""; - $out .= " " . __('Telegram username') . ""; - $out .= ""; - $out .= ""; - - echo $out; +class PluginTelegrambotUser extends CommonDBTM +{ + + static public function showUsernameField($item) + { + $username = null; + + if ($item->fields['id']) { + $user = new self(); + $user->getFromDB($item->fields['id']); + + if (!$user->isNewItem()) { + $username = $user->fields['username']; + } + } + + $telegram_username_translation = __('Telegram username'); + + $out = << + {$telegram_username_translation} + + +HTML; + + echo $out; + } - static public function item_add_user(User $item) { - if ($item->input['telegram_username']) { - $user = new self; - $user->fields['id'] = $item->fields['id']; - $user->fields['username'] = $item->input['telegram_username']; - $user->addToDB(); - } + static public function item_add_user(User $item) + { + if (isset($item->input['telegram_username'])) { + $user = new self; + $user->fields['id'] = $item->fields['id']; + $user->fields['username'] = $item->input['telegram_username']; + $user->addToDB(); + } } - static public function item_update_user(User $item) { - $user = new self; - $user->getFromDB($item->fields['id']); - - if ($user->isNewItem()) { - self::item_add_user($item); - } else { - $user->fields['username'] = $item->input['telegram_username']; - $user->updateInDB(array('username')); - } + static public function item_update_user(User $item) + { + $user = new self; + $user->getFromDB($item->fields['id']); + + if ($user->isNewItem()) { + self::item_add_user($item); + } else { + $user->fields['username'] = $item->input['telegram_username']; + $user->updateInDB(['username']); + } + } + + static public function userLoginViaTelegrambot($user_chat, $password) + { + $token = self::generateTemporaryAccessToken($user_chat, $password); + $url_access = 'http://' . $_SERVER['SERVER_NAME'] . '/plugins/telegrambot/front/telegrambot_login.php?t=' . $token; + $access = 'To access GLPI click on this link: ' . $url_access; + return $access; + } + + static private function generateTemporaryAccessToken($user_chat, $password) + { + + $valid_until = [ 'valid_until' => time() + 3600 ]; + + $user = self::getGlpiUserByTelegramUsername($user_chat); + + $data_to_token = [ + 'tu' => $user_chat, // Telegram username + 'gu' => $user['name'], // GLPI username + 'p' => $password // GLPI password + ]; + + $payload_data = \json_encode($data_to_token); + $valid_time_data = \json_encode($valid_until); + + $hash = \sha1($payload_data . $valid_time_data . $user['id']); + + $token = \base64_encode($valid_time_data) . '.' . \base64_encode($payload_data) . '.' . \base64_encode($hash); + + return $token; + + } + + static public function validateTemporaryAccessToken() + { + + $split_token_parts = \explode('.', $_GET['t']); + + $token_valid_time = \json_decode(\base64_decode($split_token_parts[0]), true); + $token_payload_data = \json_decode(\base64_decode($split_token_parts[1]), true); + $token_hash = \base64_decode($split_token_parts[2], true); + + // Expired Token + if($token_valid_time['valid_until'] < time()){ + return 'Expired Token!'; + } + + $user = self::getGlpiUserByTelegramUsername($token_payload_data['tu']); + + $hash_to_test = sha1(\base64_decode($split_token_parts[1]) . \base64_decode($split_token_parts[0]) . $user['id']); + + if($token_hash != $hash_to_test){ + return 'Wrong Hash validation!'; + } + + $user_data = [ + 'user' => $token_payload_data['gu'], + 'pass' => $token_payload_data['p'] + ]; + + return $user_data; + } + + static public function getGlpiUserByTelegramUsername($user_chat) + { + global $DB; + + $user = $DB->request([ + 'FIELDS' => ['glpi.glpi_users.id', 'glpi.glpi_users.name'], + 'FROM' => 'glpi.glpi_users', + 'INNER JOIN' => [ + 'glpi_plugin_telegrambot_users' => [ + 'FKEY' => [ + 'glpi_plugin_telegrambot_users' => 'id', + 'glpi_users' => 'id' + ] + ] + ], + 'WHERE' => [ + 'glpi.glpi_plugin_telegrambot_users.username' => $user_chat + ], + 'LIMIT' => 1 + ])->next(); + + if ($user) { + return $user; + } + + return []; + } } diff --git a/setup.php b/setup.php index 3f49d3b..fd9925d 100644 --- a/setup.php +++ b/setup.php @@ -1,108 +1,140 @@ . - -------------------------------------------------------------------------- + You should have received a copy of the GNU General Public License + along with TelegramBot. If not, see . + -------------------------------------------------------------------------- */ -define('PLUGIN_TELEGRAMBOT_VERSION', '2.0.0'); +define('PLUGIN_TELEGRAMBOT_VERSION', '3.0.0'); /** - * Init hooks of the plugin. - * REQUIRED + * Init the hooks of the plugins. * * @return void */ -function plugin_init_telegrambot() { +function plugin_init_telegrambot() +{ global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['telegrambot'] = true; $PLUGIN_HOOKS['post_item_form']['telegrambot'] = 'add_username_field'; - $PLUGIN_HOOKS['item_add']['telegrambot'] = array('User' => array('PluginTelegrambotUser', 'item_add_user')); - $PLUGIN_HOOKS['pre_item_update']['telegrambot'] = array('User' => array('PluginTelegrambotUser', 'item_update_user')); + $PLUGIN_HOOKS['item_add']['telegrambot'] = [ + 'User' => ['PluginTelegrambotUser', 'item_add_user'] + ]; + $PLUGIN_HOOKS['pre_item_update']['telegrambot'] = [ + 'User' => ['PluginTelegrambotUser', 'item_update_user'] + ]; $plugin = new Plugin(); if ($plugin->isActivated('telegrambot')) { - Notification_NotificationTemplate::registerMode( - Notification_NotificationTemplate::MODE_WEBSOCKET, - __('Telegram', 'plugin_telegrambot'), - 'telegrambot' - ); + Notification_NotificationTemplate::registerMode( + Notification_NotificationTemplate::MODE_WEBSOCKET, + __('telegram', 'plugin_telegrambot'), + 'telegrambot' + ); } } /** - * Get the name and the version of the plugin - * REQUIRED + * Get the name and the version of the plugin. * * @return array */ -function plugin_version_telegrambot() { +function plugin_version_telegrambot() +{ return [ - 'name' => 'TelegramBot', - 'version' => PLUGIN_TELEGRAMBOT_VERSION, - 'author' => 'Truly Systems', - 'license' => 'GPLv2+', - 'homepage' => 'https://github.com/pluginsGLPI/telegrambot', - 'minGlpiVersion' => '9.2' + 'name' => 'TelegramBot', + 'version' => PLUGIN_TELEGRAMBOT_VERSION, + 'author' => 'Truly Systems', + 'license' => 'GLPv3', + 'homepage' => 'https://github.com/pluginsGLPI/telegrambot', + 'requirements' => [ + 'glpi' => [ + 'min' => '9.4' + // params: an array of GLPI parameters names that must be set (not empty, not null, not false), + // 'params' => [] + ], + 'php' => [ + 'min' => '7.0', + 'exts' => [ + 'mysqli' => [ + 'required' => true + ], + 'fileinfo' => [ + 'required' => true, + 'class' => 'finfo' + ], + 'json' => [ + 'required' => true, + 'function' => 'json_encode' + ] + ] + // params: an array of parameters name that must be set (retrieved from ini_get()) + //'params' => [] + ], + ] ]; } /** - * Check pre-requisites before install - * OPTIONNAL, but recommanded + * Optional : check prerequisites before install : may print errors or add to message after redirect * * @return boolean */ -function plugin_telegrambot_check_prerequisites() { - // Strict version check (could be less strict, or could allow various version) - if (version_compare(GLPI_VERSION, '9.2', 'lt')) { - if (method_exists('Plugin', 'messageIncompatible')) { - echo Plugin::messageIncompatible('core', '9.2'); - } else { - echo "This plugin requires GLPI >= 9.2"; - } - return false; +function plugin_telegrambot_check_prerequisites() +{ + if (version_compare(GLPI_VERSION, '9.4', 'lt')) { + if (method_exists('Plugin', 'messageIncompatible')) { + echo Plugin::messageIncompatible('core', '9.4'); + } else { + echo "This plugin requires GLPI >= 9.4"; + } + return false; } return true; } /** - * Check configuration process + * Check configuration process for plugin : need to return true if succeeded + * Can display a message only if failure and $verbose is true * - * @param boolean $verbose Whether to display message on failure. Defaults to false + * @param boolean $verbose Enable verbosity. Default to false * * @return boolean + * + * @param boolean $verbose + * @return boolean */ -function plugin_telegrambot_check_config($verbose = false) { +function plugin_telegrambot_check_config($verbose = false) +{ if (true) { // Your configuration check - return true; + return true; } if ($verbose) { - _e('Installed / not configured', 'telegrambot'); + echo "Installed, but not configured"; } return false; -} +} \ No newline at end of file diff --git a/setup.php.tpl b/setup.php.tpl index f6dfa83..e37e008 100644 --- a/setup.php.tpl +++ b/setup.php.tpl @@ -26,71 +26,115 @@ -------------------------------------------------------------------------- */ -define('PLUGIN_TELEGRAMBOT_VERSION', '2.0.0'); +define('PLUGIN_TELEGRAMBOT_VERSION', '3.0.0'); /** - * Init hooks of the plugin. - * REQUIRED + * Init the hooks of the plugins. * * @return void */ -function plugin_init_telegrambot() { +function plugin_init_telegrambot() +{ global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['telegrambot'] = true; -} + $PLUGIN_HOOKS['post_item_form']['telegrambot'] = 'add_username_field'; + $PLUGIN_HOOKS['item_add']['telegrambot'] = [ + 'User' => ['PluginTelegrambotUser', 'item_add_user'] + ]; + $PLUGIN_HOOKS['pre_item_update']['telegrambot'] = [ + 'User' => ['PluginTelegrambotUser', 'item_update_user'] + ]; + + $plugin = new Plugin(); + if ($plugin->isActivated('telegrambot')) { + Notification_NotificationTemplate::registerMode( + Notification_NotificationTemplate::MODE_WEBSOCKET, + __('telegram', 'plugin_telegrambot'), + 'telegrambot' + ); + } +} /** - * Get the name and the version of the plugin - * REQUIRED + * Get the name and the version of the plugin. * * @return array */ -function plugin_version_telegrambot() { +function plugin_version_telegrambot() +{ return [ - 'name' => 'TelegramBot', - 'version' => PLUGIN_TELEGRAMBOT_VERSION, - 'author' => 'Teclib\'', - 'license' => '', - 'homepage' => '', - 'minGlpiVersion' => '9.1' + 'name' => 'TelegramBot', + 'version' => PLUGIN_TELEGRAMBOT_VERSION, + 'author' => 'Truly Systems', + 'license' => 'GLPv3', + 'homepage' => 'https://github.com/pluginsGLPI/telegrambot', + 'requirements' => [ + 'glpi' => [ + 'min' => '9.4' + // params: an array of GLPI parameters names that must be set (not empty, not null, not false), + // 'params' => [] + ], + 'php' => [ + 'min' => '7.0', + 'exts' => [ + 'mysqli' => [ + 'required' => true + ], + 'fileinfo' => [ + 'required' => true, + 'class' => 'finfo' + ], + 'json' => [ + 'required' => true, + 'function' => 'json_encode' + ] + ] + // params: an array of parameters name that must be set (retrieved from ini_get()) + //'params' => [] + ], + ] ]; } /** - * Check pre-requisites before install - * OPTIONNAL, but recommanded + * Optional : check prerequisites before install : may print errors or add to message after redirect * * @return boolean */ -function plugin_telegrambot_check_prerequisites() { - // Strict version check (could be less strict, or could allow various version) - if (version_compare(GLPI_VERSION, '9.1', 'lt')) { - if (method_exists('Plugin', 'messageIncompatible')) { - echo Plugin::messageIncompatible('core', '9.1'); - } else { - echo "This plugin requires GLPI >= 9.1"; - } - return false; +function plugin_telegrambot_check_prerequisites() +{ + if (version_compare(GLPI_VERSION, '9.4', 'lt')) { + if (method_exists('Plugin', 'messageIncompatible')) { + echo Plugin::messageIncompatible('core', '9.4'); + } else { + echo "This plugin requires GLPI >= 9.4"; + } + return false; } return true; } /** - * Check configuration process + * Check configuration process for plugin : need to return true if succeeded + * Can display a message only if failure and $verbose is true * - * @param boolean $verbose Whether to display message on failure. Defaults to false + * @param boolean $verbose Enable verbosity. Default to false * * @return boolean + * + * @param boolean $verbose + * @return boolean */ -function plugin_telegrambot_check_config($verbose = false) { +function plugin_telegrambot_check_config($verbose = false) +{ if (true) { // Your configuration check - return true; + return true; } if ($verbose) { - _e('Installed / not configured', 'telegrambot'); + echo "Installed, but not configured"; } return false; -} +} \ No newline at end of file diff --git a/telegrambot.xml b/telegrambot.xml index 86673ad..c2d8c49 100644 --- a/telegrambot.xml +++ b/telegrambot.xml @@ -7,12 +7,12 @@ - TelegramBot GLPI plugin. + TelegramBot 3.0 GLPI plugin. - Telegram bot for GLPI. + Telegram bot 3.0 for GLPI. Video Preview -------- @@ -31,9 +31,9 @@ - 2.0.0 + 3.0.0 - 9.2 + 9.4