-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathawards_plugin_class.php
More file actions
273 lines (237 loc) · 8.45 KB
/
awards_plugin_class.php
File metadata and controls
273 lines (237 loc) · 8.45 KB
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
<?php
/* Project: EQdkp-Plus
* Package: Awards Plugin
* Link: http://eqdkp-plus.eu
*
* Copyright (C) 2006-2015 EQdkp-Plus Developer Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('EQDKP_INC')){
header('HTTP/1.0 404 Not Found');exit;
}
/*+------ NOTES - FOR - DEVELOPMENT -------------------------------------------
|
| Wichtige Variablen werden zusammen gesetzt aus:
| $strAchName(s)____kleines 's' am Ende wenn array()
| | | |____Element (ID, Name, GroupKey, IconColors)
| | |____Objekt (Ach, Adj, Ass) => Achievement, Adjustment, ...
| |____Typ (int, flt, str, arr, bln) => integer, float, string, ...
|
| System (EqDKP Core) Variablen sind verschieden, doch häufig mit
| '_' geschrieben somit sollte diese Schreibweise vermieden werden
| um eine bessere Sicht zuhaben was stammt vom Core und was von uns.
|
| Unwichtige Variablen sollten vollständig klein geschrieben werden ...
| zB.: Variablen für den einmaligen Gebruach, oder
| Variablen die als Verbindung zwischen 2 direkt aufeinander folgenden
| Methoden dienen (Methoden nur zur leserlichkeit getrennt),
| Variablen die nicht explizit mit dem Verwendungszweck im
| zusammenhang stehen
|
| Diese Grundsätze gelten aber nur als Richtlinien und Hilfestellungen,
| da es immer auf den Code ankommt ;)
+--------------------------------------------------------------------------*/
/*+----------------------------------------------------------------------------
| awards
+--------------------------------------------------------------------------*/
class awards extends plugin_generic
{
public $version = '0.1.0';
public $build = '';
public $copyright = 'Asitara';
public $vstatus = 'Beta';
protected static $apiLevel = 20;
/**
* Constructor
* Initialize all informations for installing/uninstalling plugin
*/
public function __construct(){
parent::__construct();
$this->add_data(array (
'name' => 'Awards',
'code' => 'awards',
'path' => 'awards',
'contact' => 'support@assasinen.5cz.de',
'template_path' => 'plugins/awards/templates/',
'icon' => 'fa fa-list-alt',
'version' => $this->version,
'author' => $this->copyright,
'description' => $this->user->lang('awards_short_desc'),
'long_description' => $this->user->lang('awards_long_desc'),
'homepage' => 'https://eqdkp-plus.eu/',
'manuallink' => 'https://eqdkp-plus.eu/wiki/Plugin:_Awards',
'plus_version' => '2.0',
'build' => $this->build,
));
$this->add_dependency(array(
'plus_version' => '2.0'
));
// -- Register our permissions ------------------------
// permissions: 'a'=admins, 'u'=user
// ('a'/'u', Permission-Name, Enable? 'Y'/'N', Language string, array of user-group-ids that should have this permission)
// Groups: 1 = Guests, 2 = Super-Admin, 3 = Admin, 4 = Member
$this->add_permission('u', 'view', 'Y', $this->user->lang('view'), array(2,3,4));
$this->add_permission('a', 'add', 'N', $this->user->lang('add'), array(2,3));
$this->add_permission('a', 'manage', 'N', $this->user->lang('manage'), array(2,3));
// -- PDH Modules -------------------------------------
$this->add_pdh_read_module('awards_achievements');
$this->add_pdh_read_module('awards_assignments');
$this->add_pdh_read_module('awards_library');
$this->add_pdh_write_module('awards_achievements');
$this->add_pdh_write_module('awards_assignments');
// -- Classes -----------------------------------------
registry::add_class('awards_plugin', 'plugins/awards/classes/', 'awards');
// -- Routing -----------------------------------------
$this->routing->addRoute('Awards', 'awards', 'plugins/awards/pageobjects');
// -- Hooks -------------------------------------------
$this->add_hook('portal', 'awards_portal_hook', 'portal');
$this->add_hook('userprofile_customtabs', 'awards_userprofile_customtabs_hook', 'userprofile_customtabs');
// -- Menu --------------------------------------------
$this->add_menu('admin', $this->gen_admin_menu());
$this->add_menu('main', $this->gen_main_menu());
$this->add_menu('settings', $this->usersettings());
}
/**
* pre_install
* Define Pre Installation
*/
public function pre_install(){
// include SQL and default configuration data for installation
include($this->root_path.'plugins/awards/includes/sql.php');
// define installation
for ($i = 1; $i <= count($awardsSQL['install']); $i++)
$this->add_sql(SQL_INSTALL, $awardsSQL['install'][$i]);
}
/**
* post_install
* Define Post Installation
*/
public function post_install(){
// install ntfy and cron
$this->ntfy->addNotificationType('awards_new_award', 'notification_awards_new_award', 'awards', 0, 1, 0, NULL, 3, 'fa-gift');
$this->timekeeper->add_cron(
'awards', array(
'extern' => true,
'ajax' => true,
'delay' => false,
'repeat' => true,
'repeat_type' => 'daily',
'active' => true,
'path' => '/plugins/awards/cronjob/',
'editable' => true,
'description' => 'Plugin: Awards'
)
);
}
/**
* pre_uninstall
* Define Pre Uninstall
*/
public function pre_uninstall(){
$arrAssignmentIDs = $this->pdh->get('awards_assignments', 'id_list');
foreach($arrAssignmentIDs as $intAssignmentID){
$intAdjID = $this->pdh->get('awards_assignments', 'adj_id', array($intAssignmentID));
$this->pdh->put('adjustment', 'delete_adjustment', array($intAdjID));
}
$this->ntfy->deleteNotificationType(array('awards_new_award'));
$this->timekeeper->del_cron('awards');
}
/**
* post_uninstall
* Define Post Uninstall
*/
public function post_uninstall(){
// include SQL data for uninstallation
include($this->root_path.'plugins/awards/includes/sql.php');
// define uninstallation
for ($i = 1; $i <= count($awardsSQL['uninstall']); $i++)
$this->db->query($awardsSQL['uninstall'][$i]);
}
/**
* gen_admin_menu
* Generate the Admin Menu
*/
private function gen_admin_menu(){
$admin_menu = array (array(
'name' => $this->user->lang('awards'),
'icon' => 'fa fa-mortar-board',
1 => array (
'link' => 'plugins/awards/admin/manage_achievements.php'.$this->SID,
'text' => $this->user->lang('aw_manage_achievements'),
'check' => 'a_awards_manage',
'icon' => 'fa-gift'
),
2 => array (
'link' => 'plugins/awards/admin/manage_assignments.php'.$this->SID,
'text' => $this->user->lang('aw_manage_assignments'),
'check' => 'a_awards_manage',
'icon' => 'fa-list'
),
));
return $admin_menu;
}
/**
* gen_main_menu
* Generate the Main Menu
*/
private function gen_main_menu(){
$main_menu = array(
1 => array (
'link' => $this->routing->build('Awards', false, false, true, true),
'text' => $this->user->lang('awards'),
'check' => 'u_awards_view',
),
);
return $main_menu;
}
private function usersettings(){
if (!$this->user->check_auth('u_awards_view', false)) return array();
$settings = array(
'awards' => array(
'awards' => array(
'aw_show_hook' => array(
'type' => 'radio',
),
'aw_layout' => array(
'type' => 'dropdown',
'tolang' => true,
'options' => array(
'default' => 'user_sett_f_aw_layout_default',
'minimalist' => 'user_sett_f_aw_layout_minimalist',
),
),
'aw_pagination' => array(
'type' => 'spinner',
'check' => 'u_awards_view',
'size' => 5,
'min' => 5,
'step' => 5,
'default' => 25
),
'aw_admin_pagination' => array(
'type' => 'spinner',
'check' => 'a_awards_manage',
'size' => 5,
'min' => 10,
'step' => 10,
'default' => 100
),
)
),
);
return $settings;
}
}
?>