1 | <?php
|
---|
2 |
|
---|
3 | /***************************************************************************
|
---|
4 | * Dolphin Smart Community Builder
|
---|
5 | * -----------------
|
---|
6 | * begin : Mon Mar 23 2006
|
---|
7 | * copyright : (C) 2006 BoonEx Group
|
---|
8 | * website : http://www.boonex.com/
|
---|
9 | * This file is part of Dolphin - Smart Community Builder
|
---|
10 | *
|
---|
11 | * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
|
---|
12 | * http://creativecommons.org/licenses/by/3.0/
|
---|
13 | *
|
---|
14 | * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
---|
15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
16 | * See the Creative Commons Attribution 3.0 License for more details.
|
---|
17 | * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
|
---|
18 | * see license.txt file; if not, write to marketing@boonex.com
|
---|
19 | ***************************************************************************/
|
---|
20 |
|
---|
21 | require_once( '../inc/header.inc.php' );
|
---|
22 | require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
|
---|
23 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
24 | require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
|
---|
25 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
|
---|
26 | require_once( BX_DIRECTORY_PATH_PLUGINS . 'Services_JSON.php' );
|
---|
27 | bx_import('BxDolAdminSettings');
|
---|
28 | bx_import('BxTemplSearchResult');
|
---|
29 |
|
---|
30 | $logged['admin'] = member_auth( 1, true, true );
|
---|
31 |
|
---|
32 | $oSettings = new BxDolAdminSettings(5);
|
---|
33 |
|
---|
34 | //--- Process submit ---//
|
---|
35 | $mixedResultSettings = '';
|
---|
36 | $mixedResultAvailable = '';
|
---|
37 | $mixedResultActions = '';
|
---|
38 | $mixedResultAction = '';
|
---|
39 | $mixedResultPrices = '';
|
---|
40 | if(isset($_POST['save']) && isset($_POST['cat'])) {
|
---|
41 | $mixedResultSettings = $oSettings->saveChanges($_POST);
|
---|
42 | } else if((isset($_POST['adm-mlevels-enable']) || isset($_POST['adm-mlevels-disable'])) && !empty($_POST['levels'])) {
|
---|
43 | if(isset($_POST['adm-mlevels-enable']))
|
---|
44 | $sValue = 'yes';
|
---|
45 | else if(isset($_POST['adm-mlevels-disable']))
|
---|
46 | $sValue = 'no';
|
---|
47 |
|
---|
48 | $GLOBALS['MySQL']->query("UPDATE `sys_acl_levels` SET `Active`='" . $sValue . "' WHERE `ID` IN ('" . implode("','", $_POST['levels']) . "')");
|
---|
49 | } else if(isset($_POST['adm-mlevels-delete']) && !empty($_POST['levels'])) {
|
---|
50 | foreach($_POST['levels'] as $iId)
|
---|
51 | if(($mixedResultAvailable = deleteMembership($iId)) !== true)
|
---|
52 | break;
|
---|
53 | } else if(isset($_POST['adm-mlevels-actions-enable']) || isset($_POST['adm-mlevels-actions-disable'])) {
|
---|
54 | $iLevelId = (int)$_POST['level'];
|
---|
55 |
|
---|
56 | foreach($_POST['actions'] as $iId) {
|
---|
57 | if(isset($_POST['adm-mlevels-actions-enable']))
|
---|
58 | $sQuery = "REPLACE INTO `sys_acl_matrix` SET `IDLevel`='" . $iLevelId . "', `IDAction`='" . $iId . "'";
|
---|
59 | else
|
---|
60 | $sQuery = "DELETE FROM `sys_acl_matrix` WHERE `IDLevel`='" . $iLevelId . "' AND `IDAction`='" . $iId . "'";
|
---|
61 |
|
---|
62 | $GLOBALS['MySQL']->query($sQuery);
|
---|
63 | }
|
---|
64 | } else if(isset($_POST['adm-mlevels-prices-add'])) {
|
---|
65 | $iLevelId = (int)$_POST['level'];
|
---|
66 | $iDays = (int)$_POST['days'];
|
---|
67 | $iPrice = (float)trim($_POST['price'], " $");
|
---|
68 |
|
---|
69 | $GLOBALS['MySQL']->query("INSERT INTO `sys_acl_level_prices`(`IDLevel`, `Days`, `Price`) VALUES('" . $iLevelId . "', '" . $iDays . "', '" . $iPrice . "')");
|
---|
70 | } else if(isset($_POST['adm-mlevels-prices-delete'])) {
|
---|
71 | $GLOBALS['MySQL']->query("DELETE FROM `sys_acl_level_prices` WHERE `id` IN ('" . implode("','", $_POST['prices']) . "')");
|
---|
72 | } else if(isset($_POST['adm-mlevels-action-save'])) {
|
---|
73 | $sQuery = "REPLACE INTO `sys_acl_matrix` SET `IDLevel`='" . $_POST['levelId'] . "', `IDAction`='" . $_POST['actionId'] . "'";
|
---|
74 | $sQuery .= !empty($_POST['allowedCnt']) ? ", `AllowedCount`='" . $_POST['allowedCnt'] . "'" : "";
|
---|
75 | $sQuery .= !empty($_POST['period']) ? ", `AllowedPeriodLen`='" . $_POST['period'] . "'" : "";
|
---|
76 | $sQuery .= !empty($_POST['dateStart']) ? ", `AllowedPeriodStart`=FROM_UNIXTIME(" . d2i($_POST['dateStart']) . ")" : "";
|
---|
77 | $sQuery .= !empty($_POST['dateEnd']) ? ", `AllowedPeriodEnd`=FROM_UNIXTIME(" . d2i($_POST['dateEnd']) . ")" : "";
|
---|
78 | $aResult = $GLOBALS['MySQL']->query($sQuery) > 0 ? array('code' => 0, 'message' => MsgBox(_t('_adm_txt_mlevels_action_saved'))) : array('code' => 1, 'message' => MsgBox(_t('_adm_txt_mlevels_action_cannot_save')));
|
---|
79 |
|
---|
80 | $oJson = new Services_JSON();
|
---|
81 | echo "<script>parent.onResult(" . $oJson->encode($aResult) . ");</script>";
|
---|
82 | exit;
|
---|
83 | } else if(isset($_POST['action']) && $_POST['action'] == 'get_edit_form_action') {
|
---|
84 | $oJson = new Services_JSON();
|
---|
85 | echo $oJson->encode(array('code' => PageCodeAction((int)$_POST['level_id'], (int)$_POST['action_id'], $mixedResultAction)));
|
---|
86 | exit;
|
---|
87 | }
|
---|
88 |
|
---|
89 | $iLevelId = (isset($_REQUEST['level'])) ? (int)$_GET['level'] : 0;
|
---|
90 |
|
---|
91 | $iNameIndex = 6;
|
---|
92 | $_page = array(
|
---|
93 | 'name_index' => $iNameIndex,
|
---|
94 | 'css_name' => array('forms_adv.css', 'settings.css', 'memb_levels.css', 'plugins/jquery/themes/|ui.datepicker.css'),
|
---|
95 | 'js_name' => array('ui.datepicker.js', 'memb_levels.js'),
|
---|
96 | 'header' => _t('_adm_page_cpt_memb_levels'),
|
---|
97 | );
|
---|
98 | $_page_cont[$iNameIndex] = array(
|
---|
99 | 'page_code_settings' => PageCodeSettings($mixedResultSettings),
|
---|
100 | 'page_code_create' => PageCodeCreate(),
|
---|
101 | 'page_code_available' => PageCodeAvailable($mixedResultAvailable),
|
---|
102 | 'page_code_actions' => isset($_REQUEST['action']) && $_REQUEST['action'] == 'actions' && $iLevelId > 0 ? PageCodeActions($iLevelId, $mixedResultActions) : "",
|
---|
103 | 'page_code_prices' => isset($_REQUEST['action']) && $_REQUEST['action'] == 'prices' && $iLevelId > 0 ? PageCodePrices($iLevelId, $mixedResultPrices) : "",
|
---|
104 | );
|
---|
105 |
|
---|
106 | PageCodeAdmin();
|
---|
107 |
|
---|
108 | function PageCodeSettings($mixedResult) {
|
---|
109 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $GLOBALS['oSettings']->getForm()));
|
---|
110 | if($mixedResult !== true && !empty($mixedResult))
|
---|
111 | $sResult = $mixedResult . $sResult;
|
---|
112 |
|
---|
113 | return DesignBoxAdmin(_t('_adm_box_cpt_mlevel_settings'), $sResult);
|
---|
114 | }
|
---|
115 | function PageCodeCreate() {
|
---|
116 | $aForm = array(
|
---|
117 | 'form_attrs' => array(
|
---|
118 | 'id' => 'adm-mlevels-create',
|
---|
119 | 'action' => $_SERVER['PHP_SELF'],
|
---|
120 | 'method' => 'post',
|
---|
121 | 'enctype' => 'multipart/form-data',
|
---|
122 | ),
|
---|
123 | 'params' => array (
|
---|
124 | 'db' => array(
|
---|
125 | 'table' => 'sys_acl_levels',
|
---|
126 | 'key' => 'ID',
|
---|
127 | 'uri' => '',
|
---|
128 | 'uri_title' => '',
|
---|
129 | 'submit_name' => 'submit'
|
---|
130 | ),
|
---|
131 | ),
|
---|
132 | 'inputs' => array (
|
---|
133 | 'Active' => array(
|
---|
134 | 'type' => 'hidden',
|
---|
135 | 'name' => 'Active',
|
---|
136 | 'value' => 'no',
|
---|
137 | 'db' => array (
|
---|
138 | 'pass' => 'Xss',
|
---|
139 | ),
|
---|
140 | ),
|
---|
141 | 'Purchasable' => array(
|
---|
142 | 'type' => 'hidden',
|
---|
143 | 'name' => 'Purchasable',
|
---|
144 | 'value' => 'yes',
|
---|
145 | 'db' => array (
|
---|
146 | 'pass' => 'Xss',
|
---|
147 | ),
|
---|
148 | ),
|
---|
149 | 'Removable' => array(
|
---|
150 | 'type' => 'hidden',
|
---|
151 | 'name' => 'Removable',
|
---|
152 | 'value' => 'yes',
|
---|
153 | 'db' => array (
|
---|
154 | 'pass' => 'Xss',
|
---|
155 | ),
|
---|
156 | ),
|
---|
157 | 'Name' => array(
|
---|
158 | 'type' => 'text',
|
---|
159 | 'name' => 'name',
|
---|
160 | 'caption' => _t('_adm_txt_mlevels_name'),
|
---|
161 | 'value' => '',
|
---|
162 | 'db' => array (
|
---|
163 | 'pass' => 'Xss',
|
---|
164 | ),
|
---|
165 | 'checker' => array (
|
---|
166 | 'func' => 'length',
|
---|
167 | 'params' => array(3,100),
|
---|
168 | 'error' => _t('_adm_txt_mlevels_name_err'),
|
---|
169 | ),
|
---|
170 | ),
|
---|
171 | 'Icon' => array(
|
---|
172 | 'type' => 'file',
|
---|
173 | 'name' => 'Icon',
|
---|
174 | 'caption' => _t('_adm_txt_mlevels_icon'),
|
---|
175 | 'value' => '',
|
---|
176 | 'checker' => array (
|
---|
177 | 'func' => '',
|
---|
178 | 'params' => '',
|
---|
179 | 'error' => _t('_adm_txt_mlevels_icon_err'),
|
---|
180 | ),
|
---|
181 | ),
|
---|
182 | 'Description' => array(
|
---|
183 | 'type' => 'textarea',
|
---|
184 | 'name' => 'description',
|
---|
185 | 'caption' => _t('_adm_txt_mlevels_description'),
|
---|
186 | 'value' => '',
|
---|
187 | 'db' => array (
|
---|
188 | 'pass' => 'XssHtml',
|
---|
189 | ),
|
---|
190 | ),
|
---|
191 | 'submit' => array(
|
---|
192 | 'type' => 'submit',
|
---|
193 | 'name' => 'submit',
|
---|
194 | 'value' => _t('_adm_btn_mlevels_add'),
|
---|
195 | ),
|
---|
196 | )
|
---|
197 | );
|
---|
198 | $oForm = new BxTemplFormView($aForm);
|
---|
199 | $oForm->initChecker();
|
---|
200 |
|
---|
201 | $bFile = true;
|
---|
202 | $sFilePath = BX_DIRECTORY_PATH_ROOT . 'media/images/membership/';
|
---|
203 | $sFileName = time();
|
---|
204 | $sFileExt = '';
|
---|
205 | if($oForm->isSubmittedAndValid() && $bFile = (isImage($_FILES['Icon']['type'], $sFileExt) && !empty($_FILES['Icon']['tmp_name']) && move_uploaded_file($_FILES['Icon']['tmp_name'], $sFilePath . $sFileName . '.' . $sFileExt))) {
|
---|
206 | $sPath = $sFilePath . $sFileName . '.' . $sFileExt;
|
---|
207 | imageResize($sPath, $sPath, 110, 110);
|
---|
208 |
|
---|
209 | $iId = (int)$oForm->insert(array('Icon' => $sFileName . '.' . $sFileExt));
|
---|
210 | if($iId != 0)
|
---|
211 | addStringToLanguage("_adm_txt_mp_" . strtolower($_REQUEST['name']), $_REQUEST['name']);
|
---|
212 |
|
---|
213 | header('Location: ' . $oForm->aFormAttrs['action']);
|
---|
214 | } else {
|
---|
215 | if(!$bFile)
|
---|
216 | $oForm->aInputs['Icon']['error'] = $oForm->aInputs['Icon']['checker']['error'];
|
---|
217 |
|
---|
218 | return DesignBoxAdmin(_t('_adm_box_cpt_mlevel_create'), $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode())));
|
---|
219 | }
|
---|
220 | }
|
---|
221 | function PageCodeAvailable($mixedResult) {
|
---|
222 | //--- Get Items ---//
|
---|
223 | $aItems = array();
|
---|
224 |
|
---|
225 | $aLevels = $GLOBALS['MySQL']->getAll("SELECT `ID` AS `id`, `Name` AS `title`, `Active` AS `active`, `Purchasable` AS `purchasable`, `Removable` AS `removable` FROM `sys_acl_levels` ORDER BY `ID`");
|
---|
226 | foreach($aLevels as $aLevel)
|
---|
227 | $aItems[] = array(
|
---|
228 | 'bx_if:system' => array(
|
---|
229 | 'condition' => $aLevel['purchasable'] == 'no' && $aLevel['removable'] == 'no',
|
---|
230 | 'content' => array()
|
---|
231 | ),
|
---|
232 | 'id' => $aLevel['id'],
|
---|
233 | 'title' => $aLevel['title'],
|
---|
234 | 'class' => $aLevel['active'] == 'yes' ? 'adm-mlevels-enabled' : 'adm-mlevels-disabled',
|
---|
235 | 'bx_if:enabled' => array(
|
---|
236 | 'condition' => $aLevel['active'] == 'yes',
|
---|
237 | 'content' => array(
|
---|
238 | 'title' => $aLevel['title'],
|
---|
239 | 'edit_link' => $GLOBALS['site']['url_admin'] . 'memb_levels.php?action=actions&level=' . $aLevel['id'] . '#actions' . $aLevel['id'],
|
---|
240 | 'bx_if:purchasable' => array(
|
---|
241 | 'condition' => $aLevel['purchasable'] == 'yes',
|
---|
242 | 'content' => array(
|
---|
243 | 'price_link' => $GLOBALS['site']['url_admin'] . 'memb_levels.php?action=prices&level=' . $aLevel['id'] . '#prices' . $aLevel['id'],
|
---|
244 | )
|
---|
245 | )
|
---|
246 | )
|
---|
247 | ),
|
---|
248 | 'bx_if:disabled' => array(
|
---|
249 | 'condition' => $aLevel['active'] != 'yes',
|
---|
250 | 'content' => array(
|
---|
251 | 'id' => $aLevel['id'],
|
---|
252 | 'title' => $aLevel['title']
|
---|
253 | )
|
---|
254 | ),
|
---|
255 | );
|
---|
256 |
|
---|
257 | //--- Get Controls ---//
|
---|
258 | $aButtons = array(
|
---|
259 | 'adm-mlevels-enable' => _t('_adm_btn_mlevels_enable'),
|
---|
260 | 'adm-mlevels-disable' => _t('_adm_btn_mlevels_disable'),
|
---|
261 | 'adm-mlevels-delete' => _t('_adm_btn_mlevels_delete')
|
---|
262 | );
|
---|
263 | $sControls = BxTemplSearchResult::showAdminActionsPanel('adm-mlevels-list-form', $aButtons, 'levels');
|
---|
264 |
|
---|
265 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('mlevels_list.html', array('bx_repeat:items' => $aItems, 'controls' => $sControls));
|
---|
266 |
|
---|
267 | if($mixedResult !== true && !empty($mixedResult))
|
---|
268 | $sResult = MsgBox(_t($mixedResult), 3) . $sResult;
|
---|
269 |
|
---|
270 | return DesignBoxAdmin(_t('_adm_box_cpt_mlevel_levels'), $sResult);
|
---|
271 | }
|
---|
272 | function PageCodeActions($iId, $mixedResult) {
|
---|
273 | $sTitle = $GLOBALS['MySQL']->getOne("SELECT `Name` FROM `sys_acl_levels` WHERE `ID`='" . $iId . "' LIMIT 1");
|
---|
274 |
|
---|
275 | //--- Get Items ---//
|
---|
276 | $aItems = array();
|
---|
277 |
|
---|
278 | $aActions = $GLOBALS['MySQL']->getAll("SELECT `ta`.`ID` AS `id`, `ta`.`Name` AS `title` FROM `sys_acl_actions` AS `ta` ORDER BY `ta`.`Name`");
|
---|
279 | $aActionsActive = $GLOBALS['MySQL']->getAllWithKey("SELECT `ta`.`ID` AS `id`, `ta`.`Name` AS `title` FROM `sys_acl_actions` AS `ta` LEFT JOIN `sys_acl_matrix` AS `tm` ON `ta`.`ID`=`tm`.`IDAction` LEFT JOIN `sys_acl_levels` AS `tl` ON `tm`.`IDLevel`=`tl`.`ID` WHERE `tl`.`ID`='" . $iId . "' ORDER BY `ta`.`Name`", "id");
|
---|
280 | foreach($aActions as $aAction) {
|
---|
281 | $bEnabled = array_key_exists($aAction['id'], $aActionsActive);
|
---|
282 | $aItems[] = array(
|
---|
283 | 'action_id' => $aAction['id'],
|
---|
284 | 'title' => $aAction['title'],
|
---|
285 | 'class' => $bEnabled ? 'adm-mlevels-enabled' : 'adm-mlevels-disabled',
|
---|
286 | 'bx_if:enabled' => array(
|
---|
287 | 'condition' => $bEnabled,
|
---|
288 | 'content' => array(
|
---|
289 | 'level_id' => $iId,
|
---|
290 | 'action_id' => $aAction['id'],
|
---|
291 | 'title' => $aAction['title']
|
---|
292 | )
|
---|
293 | ),
|
---|
294 | 'bx_if:disabled' => array(
|
---|
295 | 'condition' => !$bEnabled,
|
---|
296 | 'content' => array(
|
---|
297 | 'action_id' => $aAction['id'],
|
---|
298 | 'title' => $aAction['title']
|
---|
299 | )
|
---|
300 | ),
|
---|
301 | );
|
---|
302 | }
|
---|
303 |
|
---|
304 | //--- Get Controls ---//
|
---|
305 | $aButtons = array(
|
---|
306 | 'adm-mlevels-actions-enable' => _t('_adm_btn_mlevels_enable'),
|
---|
307 | 'adm-mlevels-actions-disable' => _t('_adm_btn_mlevels_disable')
|
---|
308 | );
|
---|
309 | $sControls = BxTemplSearchResult::showAdminActionsPanel('adm-mlevels-actions-form', $aButtons, 'actions');
|
---|
310 |
|
---|
311 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('mlevels_actions.html', array(
|
---|
312 | 'id' => $iId,
|
---|
313 | 'bx_repeat:items' => $aItems,
|
---|
314 | 'controls' => $sControls,
|
---|
315 | 'url_admin' => $GLOBALS['site']['url_admin']
|
---|
316 | ));
|
---|
317 |
|
---|
318 | if($mixedResult !== true && !empty($mixedResult))
|
---|
319 | $sResult = MsgBox(_t($mixedResult), 3) . $sResult;
|
---|
320 |
|
---|
321 | return DesignBoxAdmin(_t('_adm_box_cpt_mlevel_actions', $sTitle), $sResult);
|
---|
322 | }
|
---|
323 | function PageCodeAction($iLevelId, $iActionId, $mixedResult) {
|
---|
324 | $aAction = $GLOBALS['MySQL']->getRow("SELECT * FROM `sys_acl_matrix` WHERE `IDLevel`='" . $iLevelId . "' AND `IDAction`='" . $iActionId . "'");
|
---|
325 |
|
---|
326 | $aForm = array(
|
---|
327 | 'form_attrs' => array(
|
---|
328 | 'id' => 'adm-mlevels-action-form',
|
---|
329 | 'target' => 'adm-mlevels-action-iframe',
|
---|
330 | 'action' => $_SERVER['PHP_SELF'],
|
---|
331 | 'method' => 'post',
|
---|
332 | 'enctype' => 'multipart/form-data'
|
---|
333 | ),
|
---|
334 | 'params' => array (),
|
---|
335 | 'inputs' => array (
|
---|
336 | 'levelId' => array(
|
---|
337 | 'type' => 'hidden',
|
---|
338 | 'name' => 'levelId',
|
---|
339 | 'value' => $iLevelId
|
---|
340 | ),
|
---|
341 | 'actionId' => array(
|
---|
342 | 'type' => 'hidden',
|
---|
343 | 'name' => 'actionId',
|
---|
344 | 'value' => $iActionId
|
---|
345 | ),
|
---|
346 | 'allowedCnt' => array(
|
---|
347 | 'type' => 'text',
|
---|
348 | 'name' => 'allowedCnt',
|
---|
349 | 'caption' => _t('_adm_txt_mlevels_actions_number'),
|
---|
350 | 'info' => _t('_adm_txt_mlevels_actions_number_desc'),
|
---|
351 | 'value' => isset($aAction['AllowedCount']) ? (int)$aAction['AllowedCount'] : ""
|
---|
352 | ),
|
---|
353 | 'period' => array(
|
---|
354 | 'type' => 'text',
|
---|
355 | 'name' => 'period',
|
---|
356 | 'caption' => _t('_adm_txt_mlevels_actions_reset'),
|
---|
357 | 'info' => _t('_adm_txt_mlevels_actions_reset_desc'),
|
---|
358 | 'value' => isset($aAction['AllowedPeriodLen']) ? (int)$aAction['AllowedPeriodLen'] : ""
|
---|
359 | ),
|
---|
360 | 'dateStart' => array(
|
---|
361 | 'type' => 'datetime',
|
---|
362 | 'name' => 'dateStart',
|
---|
363 | 'caption' => _t('_adm_txt_mlevels_actions_avail_start'),
|
---|
364 | 'info' => _t('_adm_txt_mlevels_actions_avail_desc'),
|
---|
365 | 'value' => isset($aAction['AllowedPeriodStart']) ? (int)$aAction['AllowedPeriodStart'] : "",
|
---|
366 | 'display' => 'filterDate',
|
---|
367 | ),
|
---|
368 | 'dateEnd' => array(
|
---|
369 | 'type' => 'datetime',
|
---|
370 | 'name' => 'dateEnd',
|
---|
371 | 'caption' => _t('_adm_txt_mlevels_actions_avail_end'),
|
---|
372 | 'info' => _t('_adm_txt_mlevels_actions_avail_desc'),
|
---|
373 | 'value' => isset($aAction['AllowedPeriodEnd']) ? (int)$aAction['AllowedPeriodEnd'] : "",
|
---|
374 | 'display' => 'filterDate',
|
---|
375 | ),
|
---|
376 | 'adm-mlevels-action-save' => array(
|
---|
377 | 'type' => 'submit',
|
---|
378 | 'name' => 'adm-mlevels-action-save',
|
---|
379 | 'value' => _t('_adm_btn_mlevels_save'),
|
---|
380 | ),
|
---|
381 | )
|
---|
382 | );
|
---|
383 | $oForm = new BxTemplFormView($aForm);
|
---|
384 |
|
---|
385 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('mlevels_action.html', array(
|
---|
386 | 'content' => $oForm->getCode()
|
---|
387 | ));
|
---|
388 |
|
---|
389 | if($mixedResult !== true && !empty($mixedResult))
|
---|
390 | $sResult = MsgBox(_t($mixedResult), 3) . $sResult;
|
---|
391 |
|
---|
392 | return $sResult;
|
---|
393 | }
|
---|
394 | function PageCodePrices($iId, $mixedResult) {
|
---|
395 | $sTitle = $GLOBALS['MySQL']->getOne("SELECT `Name` FROM `sys_acl_levels` WHERE `ID`='" . $iId . "' LIMIT 1");
|
---|
396 |
|
---|
397 | //--- Get Items ---//
|
---|
398 | $aItems = array();
|
---|
399 | $sCurrencyCode = getParam('currency_sign');
|
---|
400 |
|
---|
401 | $aPrices = $GLOBALS['MySQL']->getAll("SELECT `id` AS `id`, `Days` AS `days`, `Price` AS `price` FROM `sys_acl_level_prices` WHERE `IDLevel`='" . $iId . "' ORDER BY `id`");
|
---|
402 | foreach($aPrices as $aPrice)
|
---|
403 | $aItems[] = array(
|
---|
404 | 'id' => $aPrice['id'],
|
---|
405 | 'title' => _t('_adm_txt_mlevels_price_info', $aPrice['days'], $sCurrencyCode, $aPrice['price']),
|
---|
406 | );
|
---|
407 |
|
---|
408 | //--- Get Controls ---//
|
---|
409 | $aButtons = array(
|
---|
410 | 'adm-mlevels-prices-delete' => _t('_adm_btn_mlevels_delete')
|
---|
411 | );
|
---|
412 | $sControls = BxTemplSearchResult::showAdminActionsPanel('adm-mlevels-prices-form', $aButtons, 'prices');
|
---|
413 |
|
---|
414 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('mlevels_prices.html', array(
|
---|
415 | 'id' => $iId,
|
---|
416 | 'bx_repeat:items' => $aItems,
|
---|
417 | 'controls' => $sControls
|
---|
418 | ));
|
---|
419 |
|
---|
420 | if($mixedResult !== true && !empty($mixedResult))
|
---|
421 | $sResult = MsgBox(_t($mixedResult), 3) . $sResult;
|
---|
422 |
|
---|
423 | return DesignBoxAdmin(_t('_adm_box_cpt_mlevel_prices', $sTitle), $sResult);
|
---|
424 | }
|
---|
425 | function isImage($sMimeType, &$sFileExtension) {
|
---|
426 | $bResult = true;
|
---|
427 | switch($sMimeType) {
|
---|
428 | case 'image/jpeg':
|
---|
429 | case 'image/pjpeg':
|
---|
430 | $sFileExtension = 'jpg';
|
---|
431 | break;
|
---|
432 | case 'image/png':
|
---|
433 | case 'image/x-png':
|
---|
434 | $sFileExtension = 'png';
|
---|
435 | break;
|
---|
436 | case 'image/gif':
|
---|
437 | $sFileExtension = 'gif';
|
---|
438 | break;
|
---|
439 | default:
|
---|
440 | $bResult = false;
|
---|
441 | }
|
---|
442 | return $bResult;
|
---|
443 | }
|
---|
444 | function deleteMembership($iId) {
|
---|
445 | $iId = (int)$iId;
|
---|
446 |
|
---|
447 | $aLevel = $GLOBALS['MySQL']->getRow("SELECT `Icon` AS `icon`, `Removable` AS `removable` FROM `sys_acl_levels` WHERE `ID`='" . $iId . "'");
|
---|
448 | if(empty($aLevel))
|
---|
449 | return "_adm_txt_mlevels_not_found";
|
---|
450 |
|
---|
451 | //Check if membership can be removed
|
---|
452 | if($aLevel['removable'] != 'yes')
|
---|
453 | return '_adm_txt_mlevels_cannot_remove';
|
---|
454 |
|
---|
455 | //Check if there are still members using this membership
|
---|
456 | $iDateExpires = $GLOBALS['MySQL']->getOne("SELECT UNIX_TIMESTAMP(MAX(`DateExpires`)) as `MaxDateExpires` FROM `sys_acl_levels_members` WHERE `IDLevel`='" . $iId . "'");
|
---|
457 | if($iDateExpires > time())
|
---|
458 | return "_adm_txt_mlevels_is_used";
|
---|
459 |
|
---|
460 | @unlink(BX_DIRECTORY_PATH_ROOT . 'media/images/membership/' . $aLevel['icon']);
|
---|
461 | db_res("DELETE FROM `sys_acl_level_prices` WHERE `IDLevel`='" . $iId . "'");
|
---|
462 | db_res("DELETE FROM `sys_acl_matrix` WHERE `IDLevel`='" . $iId . "'");
|
---|
463 | db_res("DELETE FROM `sys_acl_levels` WHERE `ID`='" . $iId . "'");
|
---|
464 |
|
---|
465 | return true;
|
---|
466 | }
|
---|
467 | function d2i($sDate) {
|
---|
468 | $iResult = 0;
|
---|
469 |
|
---|
470 | $aMatch = array();
|
---|
471 | if(preg_match('#(\d+)/(\d+)/(\d+)#', $sDate, $aMatch)) {
|
---|
472 | $iDay = $aMatch[1];
|
---|
473 | $iMonth = $aMatch[2];
|
---|
474 | $iYear = $aMatch[3];
|
---|
475 | $iResult = mktime (0, 0, 0, $iMonth, $iDay, $iYear);
|
---|
476 | $iResult = $iResult > 0 ? $iResult : 0;
|
---|
477 | }
|
---|
478 |
|
---|
479 | return $iResult;
|
---|
480 | }
|
---|
481 |
|
---|
482 | ?> |
---|