varrcan /
telegram.send
| 1 | <?php |
||||||
| 2 | defined('B_PROLOG_INCLUDED') and (B_PROLOG_INCLUDED === true) or die(); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 3 | |||||||
| 4 | use Bitrix\Main\Application; |
||||||
|
0 ignored issues
–
show
The type
Bitrix\Main\Application was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 5 | use Bitrix\Main\EventManager; |
||||||
|
0 ignored issues
–
show
The type
Bitrix\Main\EventManager was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 6 | use Bitrix\Main\ModuleManager; |
||||||
|
0 ignored issues
–
show
The type
Bitrix\Main\ModuleManager was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 7 | |||||||
| 8 | /** |
||||||
| 9 | * Class telegram_send |
||||||
| 10 | */ |
||||||
| 11 | Class telegram_send extends CModule |
||||||
|
0 ignored issues
–
show
The type
CModule was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||||
| 12 | { |
||||||
| 13 | const MODULE_ID = 'telegram.send'; |
||||||
| 14 | public $MODULE_ID; |
||||||
| 15 | public $MODULE_VERSION; |
||||||
| 16 | public $MODULE_VERSION_DATE; |
||||||
| 17 | public $MODULE_NAME; |
||||||
| 18 | public $MODULE_DESCRIPTION; |
||||||
| 19 | public $MODULE_GROUP_RIGHTS; |
||||||
| 20 | public $PARTNER_NAME; |
||||||
| 21 | public $PARTNER_URI; |
||||||
| 22 | private $errors; |
||||||
| 23 | |||||||
| 24 | /** |
||||||
| 25 | * telegram_send constructor. |
||||||
| 26 | */ |
||||||
| 27 | public function __construct() |
||||||
| 28 | { |
||||||
| 29 | $arModuleVersion = []; |
||||||
| 30 | include __DIR__ . '/version.php'; |
||||||
| 31 | $this->MODULE_NAME = 'Телеграм'; |
||||||
| 32 | $this->MODULE_DESCRIPTION = 'Отправка почтовых сообщений в телеграм'; |
||||||
| 33 | $this->MODULE_ID = 'telegram.send'; |
||||||
| 34 | $this->MODULE_VERSION = $arModuleVersion['VERSION']; |
||||||
| 35 | $this->MODULE_VERSION_DATE = $arModuleVersion['VERSION_DATE']; |
||||||
| 36 | $this->MODULE_GROUP_RIGHTS = 'N'; |
||||||
| 37 | $this->PARTNER_NAME = 'Varrcan'; |
||||||
| 38 | $this->PARTNER_URI = 'https://varrcan.me'; |
||||||
| 39 | } |
||||||
| 40 | |||||||
| 41 | /** |
||||||
| 42 | * Действия при установке модуля |
||||||
| 43 | * @return bool|void |
||||||
| 44 | */ |
||||||
| 45 | public function doInstall() |
||||||
| 46 | { |
||||||
| 47 | global $USER; |
||||||
| 48 | if ($USER->IsAdmin()) { |
||||||
| 49 | ModuleManager::registerModule($this->MODULE_ID); |
||||||
| 50 | $this->InstallEvents(); |
||||||
| 51 | $this->InstallFiles(); |
||||||
| 52 | } |
||||||
| 53 | } |
||||||
| 54 | |||||||
| 55 | /** |
||||||
| 56 | * Регистрация событий |
||||||
| 57 | * @return bool|void |
||||||
| 58 | */ |
||||||
| 59 | public function InstallEvents() |
||||||
| 60 | { |
||||||
| 61 | $eventManager = EventManager::getInstance(); |
||||||
| 62 | $eventManager->registerEventHandler( |
||||||
| 63 | 'main', |
||||||
| 64 | 'OnBeforeEventSend', |
||||||
| 65 | $this->MODULE_ID, |
||||||
| 66 | 'Telegram\\Send\\Main', |
||||||
| 67 | 'getEventSend' |
||||||
| 68 | ); |
||||||
| 69 | } |
||||||
| 70 | |||||||
| 71 | /** |
||||||
| 72 | * Копирование файлов |
||||||
| 73 | * |
||||||
| 74 | * @param array $arParams |
||||||
| 75 | */ |
||||||
| 76 | public function InstallFiles($arParams = []) |
||||||
| 77 | { |
||||||
| 78 | if (!is_dir($_SERVER['DOCUMENT_ROOT'] . '/bitrix/js/' . self::MODULE_ID) && !mkdir($concurrentDirectory = |
||||||
| 79 | $_SERVER['DOCUMENT_ROOT'] . '/bitrix/js/' . self::MODULE_ID) && !is_dir($concurrentDirectory)) { |
||||||
| 80 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); |
||||||
| 81 | } |
||||||
| 82 | CopyDirFiles( |
||||||
|
0 ignored issues
–
show
The function
CopyDirFiles was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 83 | $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . self::MODULE_ID . '/install/admin', |
||||||
| 84 | $_SERVER['DOCUMENT_ROOT'] . '/bitrix/admin', |
||||||
| 85 | true, |
||||||
| 86 | true |
||||||
| 87 | ); |
||||||
| 88 | CopyDirFiles( |
||||||
| 89 | $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . self::MODULE_ID . '/install/js/', |
||||||
| 90 | $_SERVER['DOCUMENT_ROOT'] . '/bitrix/js/', |
||||||
| 91 | true, |
||||||
| 92 | true |
||||||
| 93 | ); |
||||||
| 94 | } |
||||||
| 95 | |||||||
| 96 | /** |
||||||
| 97 | * Действия при удалении модуля |
||||||
| 98 | */ |
||||||
| 99 | public function doUninstall() |
||||||
| 100 | { |
||||||
| 101 | $this->UnInstallEvents(); |
||||||
| 102 | $this->UnInstallFiles(); |
||||||
| 103 | $this->UnInstallDB(); |
||||||
| 104 | ModuleManager::unregisterModule($this->MODULE_ID); |
||||||
| 105 | } |
||||||
| 106 | |||||||
| 107 | /** |
||||||
| 108 | * Удаление событий |
||||||
| 109 | * @return bool|void |
||||||
| 110 | */ |
||||||
| 111 | public function UnInstallEvents() |
||||||
| 112 | { |
||||||
| 113 | |||||||
| 114 | $eventManager = EventManager::getInstance(); |
||||||
| 115 | $eventManager->unRegisterEventHandler( |
||||||
| 116 | 'main', |
||||||
| 117 | 'OnBeforeEventSend', |
||||||
| 118 | $this->MODULE_ID, |
||||||
| 119 | 'Telegram\\Send\\Main', |
||||||
| 120 | 'getEventSend' |
||||||
| 121 | ); |
||||||
| 122 | } |
||||||
| 123 | |||||||
| 124 | /** |
||||||
| 125 | * Удаление файлов |
||||||
| 126 | * @return bool|void |
||||||
| 127 | */ |
||||||
| 128 | public function UnInstallFiles() |
||||||
| 129 | { |
||||||
| 130 | DeleteDirFilesEx("/bitrix/admin/telegram_main.php"); |
||||||
|
0 ignored issues
–
show
The function
DeleteDirFilesEx was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 131 | DeleteDirFilesEx("/bitrix/js/telegram.send/"); |
||||||
| 132 | } |
||||||
| 133 | |||||||
| 134 | /** |
||||||
| 135 | * Удаление таблицы настроек |
||||||
| 136 | * |
||||||
| 137 | * @param array $arParams |
||||||
| 138 | * |
||||||
| 139 | * @return bool|void |
||||||
| 140 | * @throws \Bitrix\Main\Db\SqlQueryException |
||||||
| 141 | */ |
||||||
| 142 | public function UnInstallDB($arParams = []) |
||||||
| 143 | { |
||||||
| 144 | Application::getConnection()->query("DELETE FROM b_option WHERE `MODULE_ID`='{$this->MODULE_ID}'"); |
||||||
| 145 | } |
||||||
| 146 | } |
||||||
| 147 |