-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmsapi.php
104 lines (89 loc) · 3.2 KB
/
smsapi.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
defined("BASEPATH") or exit("No direct script access allowed");
/*
Module Name: SMSAPI
Description: Send SMS by SMSAPI
Author: ISCODE
Author URI: https://iscode.pl
Version: 1.0.1
Requires at least: 2.9.0
*/
define('SMSAPI_MODULE_NAME', "smsapi");
/**
* Loads the SMSAPI module helper file and assigns it to the CodeIgniter instance.
* @param object $CI The CodeIgniter instance.
* @return void
*/
$CI = &get_instance();
$CI->load->helper(SMSAPI_MODULE_NAME. '/'. SMSAPI_MODULE_NAME);
/*
* Register activation
*/
register_activation_hook(SMSAPI_MODULE_NAME, function() {
$CI = &get_instance();
require __DIR__ . '/install.php';
});
/**
* Register language files, must be registered if the module is using languages
*/
register_language_files(SMSAPI_MODULE_NAME, [SMSAPI_MODULE_NAME]);
/**
* Module permissions
*/
hooks()->add_action('admin_init', function() {
$capabilities = [];
$capabilities['capabilities'] = [
'view' => _l('permission_view') . '(' . _l('permission_global') . ')',
'delete' => _l('permission_delete'),
];
register_staff_capabilities(SMSAPI_MODULE_NAME, $capabilities, _l(SMSAPI_MODULE_NAME.'_log2'));
});
/**
* Adds the SMS SMSAPI module to the list of SMS gateways.
*
* @param array $gateways The array of SMS gateways.
* @return array The updated array of SMS gateways.
*/
hooks()->add_filter('sms_gateways', function($gateways) {
if( isset($gateways) && is_array($gateways) && SMSAPI_MODULE_NAME )
array_push($gateways, SMSAPI_MODULE_NAME.DIRECTORY_SEPARATOR.'Sms_'.SMSAPI_MODULE_NAME);
return $gateways;
});
/**
* Add additional settings for this module in the module list area
* @param array $actions current actions
* @return array
*/
hooks()->add_filter('module_'.SMSAPI_MODULE_NAME.'_action_links', function($actions) {
$CI = &get_instance();
$support = [
'styled' => '1',
'with_logo' => '1',
'col' => 'col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2',
'subject' => 'Perfex CRM Module::'.$CI->app_modules->get_headers(__FILE__)['module_name'],
'email' => get_staff()->email ?? '',
'name' => get_staff_full_name() ?? '',
];
$support = array_filter($support, function($value) {
return !empty($value);
});
$actions[] = '<a href="'.admin_url('settings?group=sms').'">' . _l('settings') . '</a>';
$actions[] = '<a href="https://panel.iscode.pl/forms/ticket?'.http_build_query($support).'" target="_blank" data-toggle="tooltip" title="Contact with the developer"><i class="fa-envelope fa-solid"></i></a>';
$actions[] = '<a href="https://github.com/rzietkowski/Perfex-CRM-SMSAPI-Module/issues" target="_blank">' . _l('support') . '</a>';
return $actions;
});
/**
* Init SMSAPI menu items in setup in admin_init hook
* @return null
*/
hooks()->add_action('admin_init', function() {
if (staff_can('view', SMSAPI_MODULE_NAME) && is_smsapi_save_messages() ) {
$CI = &get_instance();
$CI->app_menu->add_sidebar_children_item('utilities', [
'slug' => SMSAPI_MODULE_NAME.'-log',
'name' => _l('smsapi_log'),
'href' => admin_url(SMSAPI_MODULE_NAME),
'position' => 30,
]);
}
});