-
Notifications
You must be signed in to change notification settings - Fork 0
/
asciotools.php
246 lines (225 loc) · 8.41 KB
/
asciotools.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
/**
* WHMCS SDK Sample Addon Module
*
* An addon module allows you to add additional functionality to WHMCS. It
* can provide both client and admin facing user interfaces, as well as
* utilise hook functionality within WHMCS.
*
* This sample file demonstrates how an addon module for WHMCS should be
* structured and exercises all supported functionality.
*
* Addon Modules are stored in the /modules/addons/ directory. The module
* name you choose must be unique, and should be all lowercase, containing
* only letters & numbers, always starting with a letter.
*
* Within the module itself, all functions must be prefixed with the module
* filename, followed by an underscore, and then the function name. For this
* example file, the filename is "addonmodule" and therefore all functions
* begin "asciotools_".
*
* For more information, please refer to the online documentation.
*
* @see https://developers.whmcs.com/addon-modules/
*
* @copyright Copyright (c) WHMCS Limited 2017
* @license http://www.whmcs.com/license/ WHMCS Eula
*/
if (!defined("WHMCS")) {
die("This file cannot be accessed directly");
}
// Require any libraries needed for the module to function.
// require_once __DIR__ . '/path/to/library/loader.php';
//
// Also, perform any initialization required by the service's library.
require_once(__DIR__."/lib/Admin/AdminDispatcher.php");
require_once(__DIR__."/lib/Admin/Controller.php");
use WHMCS\Module\Addon\AddonModule\Admin\AdminDispatcher;
use WHMCS\Module\Addon\AddonModule\Client\ClientDispatcher;
use Illuminate\Database\Capsule\Manager as Capsule;
/**
* Define addon module configuration parameters.
*
* Includes a number of required system fields including name, description,
* author, language and version.
*
* Also allows you to define any configuration parameters that should be
* presented to the user when activating and configuring the module. These
* values are then made available in all module function calls.
*
* Examples of each and their possible configuration parameters are provided in
* the fields parameter below.
*
* @return array
*/
function asciotools_config()
{
return array(
'name' => 'AscioTools', // Display name for your module
'description' => 'Modules to install and update products/prices.', // Description displayed within the admin interface
'author' => 'Ascio', // Module author name
'language' => 'english', // Default language
'version' => '1.0', // Version number
'fields' => array()
);
}
/**
* Activate.
*
* Called upon activation of the module for the first time.
* Use this function to perform any database and schema modifications
* required by your module.
*
* This function is optional.
*
* @return array Optional success/failure message
*/
function asciotools_activate()
{
// Create custom tables and schema required by your module
$query = "CREATE TABLE `mod_asciotools` (`id` INT( 1 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,`demo` TEXT NOT NULL )";
full_query($query);
return array(
'status' => 'success', // Supported values here include: success, error or info
'description' => 'This is a demo module only. In a real module you might report an error/failure or instruct a user how to get started with it here.',
);
}
/**
* Deactivate.
*
* Called upon deactivation of the module.
* Use this function to undo any database and schema modifications
* performed by your module.
*
* This function is optional.
*
* @return array Optional success/failure message
*/
function asciotools_deactivate()
{
// Undo any database and schema modifications made by your module here
$query = "DROP TABLE `mod_asciotools`";
full_query($query);
return array(
'status' => 'success', // Supported values here include: success, error or info
'description' => 'This is a demo module only. In a real module you might report an error/failure here.',
);
}
/**
* Upgrade.
*
* Called the first time the module is accessed following an update.
* Use this function to perform any required database and schema modifications.
*
* This function is optional.
*
* @return void
*/
function asciotools_upgrade($vars)
{
$currentlyInstalledVersion = $vars['version'];
/// Perform SQL schema changes required by the upgrade to version 1.1 of your module
//if ($currentlyInstalledVersion < 1.1) {
// $query = "ALTER `mod_asciotools` ADD `demo2` TEXT NOT NULL ";
// full_query($query);
//}
/// Perform SQL schema changes required by the upgrade to version 1.2 of your module
//if ($currentlyInstalledVersion < 1.2) {
// $query = "ALTER `mod_asciotools` ADD `demo3` TEXT NOT NULL ";
// full_query($query);
//}
}
/**
* Admin Area Output.
*
* Called when the addon module is accessed via the admin area.
* Should return HTML output for display to the admin user.
*
* This function is optional.
*
* @see AddonModule\Admin\Controller@index
*
* @return string
*/
function asciotools_output($vars)
{
// Get common module parameters
$modulelink = $vars['modulelink']; // eg. addonmodules.php?module=addonmodule
$version = $vars['version']; // eg. 1.0
$_lang = $vars['_lang']; // an array of the currently loaded language variables
// Get module configuration parameters
$configTextField = $vars['Text Field Name'];
$configPasswordField = $vars['Password Field Name'];
$configCheckboxField = $vars['Checkbox Field Name'];
$configDropdownField = $vars['Dropdown Field Name'];
$configRadioField = $vars['Radio Field Name'];
$configTextareaField = $vars['Textarea Field Name'];
// Dispatch and handle request here. What follows is a demonstration of one
// possible way of handling this using a very basic dispatcher implementation.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$dispatcher = new AdminDispatcher();
$response = $dispatcher->dispatch($action, $vars);
$script = '<script type="text/javascript" src="../modules/addons/asciotools/resources/js/asciotools.js"></script>';
echo $script . $response;
}
/**
* Admin Area Sidebar Output.
*
* Used to render output in the admin area sidebar.
* This function is optional.
*
* @param array $vars
*
* @return string
*/
function asciotools_sidebar($vars)
{
// Get common module parameters
$modulelink = $vars['modulelink'];
$version = $vars['version'];
$_lang = $vars['_lang'];
$sidebar = '<span class="header"><img src="images/icons/addonmodules.png" class="absmiddle" width="16" height="16"> SSL</span>';
try {
Capsule::table("mod_asciossl_settings")->exists();
$class = "";
} catch (PDOException $e) {
$style =' style="display:none"';
}
$items = '<li class="ascio-tools-links"><a href="'.$modulelink.'&action=install">Install/Update</a></li>
<li class="ascio-tools-links"'.$style.'><a href="'.$modulelink.'&action=settings">Settings</a></li>
<li class="ascio-tools-links"'.$style.'><a href="'.$modulelink.'&action=showUpload">Import Products</a></li>
<li class="ascio-tools-links"'.$style.'><a href="'.$modulelink.'&action=displayFailedSslOrders">Failed Orders</a></li>';
$sidebar .='<ul class="menu">'.$items.'</ul>';
return $sidebar;
}
/**
* Client Area Output.
*
* Called when the addon module is accessed via the client area.
* Should return an array of output parameters.
*
* This function is optional.
*
* @see AddonModule\Client\Controller@index
*
* @return array
*/
function asciotools_clientarea($vars)
{
// Get common module parameters
$modulelink = $vars['modulelink']; // eg. index.php?m=addonmodule
$version = $vars['version']; // eg. 1.0
$_lang = $vars['_lang']; // an array of the currently loaded language variables
// Get module configuration parameters
$configTextField = $vars['Text Field Name'];
$configPasswordField = $vars['Password Field Name'];
$configCheckboxField = $vars['Checkbox Field Name'];
$configDropdownField = $vars['Dropdown Field Name'];
$configRadioField = $vars['Radio Field Name'];
$configTextareaField = $vars['Textarea Field Name'];
// Dispatch and handle request here. What follows is a demonstration of one
// possible way of handling this using a very basic dispatcher implementation.
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$dispatcher = new ClientDispatcher();
return $dispatcher->dispatch($action, $vars);
}