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 | define ('BX_SECURITY_EXCEPTIONS', true);
|
---|
22 | $aBxSecurityExceptions = array ();
|
---|
23 | if (isset($_REQUEST['pathes']) && is_array($_REQUEST['pathes'])) {
|
---|
24 | for ($i=0;$i<count($_REQUEST['pathes']);++$i) {
|
---|
25 | $aBxSecurityExceptions[] = 'POST.pathes.'.$i;
|
---|
26 | $aBxSecurityExceptions[] = 'REQUEST.pathes.'.$i;
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | require_once( '../inc/header.inc.php' );
|
---|
31 | require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
|
---|
32 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
33 | require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
|
---|
34 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
|
---|
35 | bx_import('BxDolDb');
|
---|
36 | bx_import('BxTemplSearchResult');
|
---|
37 | bx_import('BxDolCategories');
|
---|
38 | bx_import('BxDolAdminSettings');
|
---|
39 |
|
---|
40 | $logged['admin'] = member_auth( 1, true, true );
|
---|
41 |
|
---|
42 | function actionAllCategories()
|
---|
43 | {
|
---|
44 | $oDb = new BxDolDb();
|
---|
45 |
|
---|
46 | // check actions
|
---|
47 | if(isset($_REQUEST['pathes']) && is_array($_POST['pathes']) && !empty($_POST['pathes']))
|
---|
48 | {
|
---|
49 | foreach($_POST['pathes'] as $sValue)
|
---|
50 | {
|
---|
51 | list($sCategory, $sId, $sType) = split('%%', $sValue);
|
---|
52 |
|
---|
53 | if (isset($_REQUEST['action_disable']))
|
---|
54 | $oDb->query("UPDATE `sys_categories` SET `Status` = 'passive' WHERE
|
---|
55 | `Category` = '$sCategory' AND `ID` = $sId AND `Type` = '$sType'");
|
---|
56 | else if (isset($_REQUEST['action_delete']))
|
---|
57 | $oDb->query("DELETE FROM `sys_categories` WHERE
|
---|
58 | `Category` = '$sCategory' AND `ID` = $sId AND `Type` = '$sType'");
|
---|
59 | }
|
---|
60 | }
|
---|
61 |
|
---|
62 | $sContent = MsgBox(_t('_Empty'));
|
---|
63 | $aModules = array();
|
---|
64 | $oCategories = new BxDolCategories();
|
---|
65 | $oCategories->getTagObjectConfig();
|
---|
66 |
|
---|
67 | if (!empty($oCategories->aTagObjects))
|
---|
68 | {
|
---|
69 | $sModule = isset($_REQUEST['module']) ? $_REQUEST['module'] : '';
|
---|
70 | foreach ($oCategories->aTagObjects as $sKey => $aValue)
|
---|
71 | {
|
---|
72 | if (!$sModule)
|
---|
73 | $sModule = $sKey;
|
---|
74 |
|
---|
75 | $aModules[] = array(
|
---|
76 | 'value' => $sKey,
|
---|
77 | 'caption' => _t($aValue['LangKey']),
|
---|
78 | 'selected' => $sKey == $sModule ? 'selected="selected"' : ''
|
---|
79 | );
|
---|
80 | }
|
---|
81 |
|
---|
82 | $sContent = $GLOBALS['oAdmTemplate']->parseHtmlByName('top_block_select.html', array(
|
---|
83 | 'name' => _t('_categ_modules'),
|
---|
84 | 'bx_repeat:items' => $aModules,
|
---|
85 | 'location_href' => BX_DOL_URL_ADMIN . 'categories.php?action=all&module='
|
---|
86 | ));
|
---|
87 |
|
---|
88 | $aCategories = $oDb->getAll("SELECT * FROM `sys_categories` WHERE `Status` = 'active' AND `Owner` = 0 AND `Type` = '$sModule'");
|
---|
89 |
|
---|
90 | if (!empty($aCategories))
|
---|
91 | {
|
---|
92 | $aItems = array();
|
---|
93 | $sFormName = 'categories_form';
|
---|
94 |
|
---|
95 | foreach($aCategories as $aCategory)
|
---|
96 | {
|
---|
97 | $aItems[] = array(
|
---|
98 | 'name' => $aCategory['Category'],
|
---|
99 | 'value' => $aCategory['Category'] . '%%' . $aCategory['ID'] . '%%' . $aCategory['Type'],
|
---|
100 | 'title'=> $aCategory['Category'],
|
---|
101 | );
|
---|
102 | }
|
---|
103 |
|
---|
104 | $sControls = $sControls = BxTemplSearchResult::showAdminActionsPanel($sFormName, array(
|
---|
105 | 'action_disable' => _t('_categ_btn_disable'),
|
---|
106 | 'action_delete' => _t('_categ_btn_delete')
|
---|
107 | ), 'pathes');
|
---|
108 |
|
---|
109 | $sContent .= $GLOBALS['oAdmTemplate']->parseHtmlByName('categories_list.html', array(
|
---|
110 | 'form_name' => $sFormName,
|
---|
111 | 'bx_repeat:items' => $aItems,
|
---|
112 | 'controls' => $sControls
|
---|
113 | ));
|
---|
114 | }
|
---|
115 | else
|
---|
116 | $sContent .= MsgBox(_t('_Empty'));
|
---|
117 | }
|
---|
118 |
|
---|
119 | return $sContent;
|
---|
120 | }
|
---|
121 |
|
---|
122 | function actionPending()
|
---|
123 | {
|
---|
124 | $oDb = new BxDolDb();
|
---|
125 | $sFormName = 'categories_aprove_form';
|
---|
126 | $aItems = array();
|
---|
127 |
|
---|
128 | if(is_array($_POST['pathes']) && !empty($_POST['pathes']))
|
---|
129 | {
|
---|
130 | foreach($_POST['pathes'] as $sValue)
|
---|
131 | {
|
---|
132 | list($sCategory, $sId, $sType) = split('%%', $sValue);
|
---|
133 | $oDb->query("UPDATE `sys_categories` SET `Status` = 'active' WHERE
|
---|
134 | `Category` = '$sCategory' AND `ID` = $sId AND `Type` = '$sType'");
|
---|
135 | }
|
---|
136 | }
|
---|
137 |
|
---|
138 | $aCategories = $oDb->getAll("SELECT * FROM `sys_categories` WHERE `Status` = 'passive'");
|
---|
139 |
|
---|
140 | if (!empty($aCategories))
|
---|
141 | {
|
---|
142 | foreach($aCategories as $aCategory)
|
---|
143 | {
|
---|
144 | $aItems[] = array(
|
---|
145 | 'name' => $aCategory['Category'],
|
---|
146 | 'value' => $aCategory['Category'] . '%%' . $aCategory['ID'] . '%%' . $aCategory['Type'],
|
---|
147 | 'title'=> $aCategory['Category'] . '(' . $aCategory['Type'] . ')',
|
---|
148 | );
|
---|
149 | }
|
---|
150 |
|
---|
151 | $aButtons = array(
|
---|
152 | 'action_activate' => _t('_categ_btn_activate'),
|
---|
153 | );
|
---|
154 | $sControls = BxTemplSearchResult::showAdminActionsPanel($sFormName, $aButtons, 'pathes');
|
---|
155 |
|
---|
156 | return $GLOBALS['oAdmTemplate']->parseHtmlByName('categories_list.html', array(
|
---|
157 | 'form_name' => $sFormName,
|
---|
158 | 'bx_repeat:items' => $aItems,
|
---|
159 | 'controls' => $sControls
|
---|
160 | ));
|
---|
161 | }
|
---|
162 | else
|
---|
163 | return MsgBox(_t('_Empty'));
|
---|
164 | }
|
---|
165 |
|
---|
166 | function actionSettings()
|
---|
167 | {
|
---|
168 | $oDb = new BxDolDb();
|
---|
169 | $iId = $oDb->getOne("SELECT `ID` FROM `sys_options_cats` WHERE `name` = 'Categories' LIMIT 1");
|
---|
170 |
|
---|
171 | if(!empty($iId))
|
---|
172 | {
|
---|
173 | $oSettings = new BxDolAdminSettings($iId);
|
---|
174 |
|
---|
175 | $mixedResult = '';
|
---|
176 | if(isset($_POST['save']) && isset($_POST['cat']))
|
---|
177 | $mixedResult = $oSettings->saveChanges($_POST);
|
---|
178 |
|
---|
179 | $sResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oSettings->getForm()));
|
---|
180 |
|
---|
181 | if($mixedResult !== true && !empty($mixedResult))
|
---|
182 | $sResult = $mixedResult . $sResult;
|
---|
183 |
|
---|
184 | return $sResult;
|
---|
185 | }
|
---|
186 | else
|
---|
187 | return MsgBox(_t('_Empty'));
|
---|
188 | }
|
---|
189 |
|
---|
190 | function getCategoryForm()
|
---|
191 | {
|
---|
192 | $oCateg = new BxDolCategories();
|
---|
193 | $aTypes = array();
|
---|
194 | $oCateg->getTagObjectConfig();
|
---|
195 |
|
---|
196 | foreach ($oCateg->aTagObjects as $sKey => $aValue)
|
---|
197 | $aTypes[$sKey] = _t($aValue[$oCateg->aObjFields['lang_key']]);
|
---|
198 |
|
---|
199 | $aForm = array(
|
---|
200 |
|
---|
201 | 'form_attrs' => array(
|
---|
202 | 'name' => 'category_form',
|
---|
203 | 'action' => $_SERVER['REQUEST_URI'],
|
---|
204 | 'method' => 'post',
|
---|
205 | 'enctype' => 'multipart/form-data',
|
---|
206 | ),
|
---|
207 |
|
---|
208 | 'params' => array (
|
---|
209 | 'db' => array(
|
---|
210 | 'table' => 'sys_categories',
|
---|
211 | 'submit_name' => 'submit_form'
|
---|
212 | ),
|
---|
213 | ),
|
---|
214 |
|
---|
215 | 'inputs' => array(
|
---|
216 |
|
---|
217 | 'name' => array(
|
---|
218 | 'type' => 'text',
|
---|
219 | 'name' => 'Category',
|
---|
220 | 'value' => isset($aUnit['name']) ? $aUnit['name'] : '',
|
---|
221 | 'caption' => _t('_categ_form_name'),
|
---|
222 | 'required' => true,
|
---|
223 | 'checker' => array (
|
---|
224 | 'func' => 'length',
|
---|
225 | 'params' => array(3, 100),
|
---|
226 | 'error' => _t('_categ_form_field_name_err'),
|
---|
227 | ),
|
---|
228 | 'db' => array(
|
---|
229 | 'pass' => 'Xss'
|
---|
230 | ),
|
---|
231 | 'display' => true,
|
---|
232 | ),
|
---|
233 | 'type' => array(
|
---|
234 | 'type' => 'select',
|
---|
235 | 'name' => 'Type',
|
---|
236 | 'required' => true,
|
---|
237 | 'values' => $aTypes,
|
---|
238 | 'value' => isset($_REQUEST['module']) ? $_REQUEST['module'] : '',
|
---|
239 | 'caption' => _t('_categ_form_type'),
|
---|
240 | 'attrs' => array(
|
---|
241 | 'multiplyable' => false
|
---|
242 | ),
|
---|
243 | 'display' => true,
|
---|
244 | 'db' => array(
|
---|
245 | 'pass' => 'Xss'
|
---|
246 | ),
|
---|
247 | ),
|
---|
248 | 'submit' => array (
|
---|
249 | 'type' => 'submit',
|
---|
250 | 'name' => 'submit_form',
|
---|
251 | 'value' => _t('_Submit'),
|
---|
252 | 'colspan' => false,
|
---|
253 | ),
|
---|
254 | )
|
---|
255 | );
|
---|
256 |
|
---|
257 | return new BxTemplFormView($aForm);
|
---|
258 | }
|
---|
259 |
|
---|
260 | function getAddCategoryForm()
|
---|
261 | {
|
---|
262 | $oForm = getCategoryForm();
|
---|
263 | $oForm->initChecker();
|
---|
264 | $sResult = '';
|
---|
265 |
|
---|
266 | if ($oForm->isSubmittedAndValid())
|
---|
267 | {
|
---|
268 | $oDb = new BxDolDb();
|
---|
269 | if ($oDb->getOne("SELECT COUNT(*) FROM `sys_categories` WHERE `Category` = '" .
|
---|
270 | $oForm->getCleanValue('Category') . "' AND `ID` = 0 AND `Type` = '" .
|
---|
271 | $oForm->getCleanValue('Type') . "'") == 0)
|
---|
272 | {
|
---|
273 | $aValsAdd = array (
|
---|
274 | 'ID' => 0,
|
---|
275 | 'Owner' => 0,
|
---|
276 | 'Status' => 'active',
|
---|
277 | );
|
---|
278 |
|
---|
279 | $oForm->insert($aValsAdd);
|
---|
280 | header('Location:' . BX_DOL_URL_ADMIN . 'categories.php?action=all&module=' . $oForm->getCleanValue('Type'));
|
---|
281 | }
|
---|
282 | else
|
---|
283 | $sResult = sprintf(_t('_categ_exist_err'), $oForm->getCleanValue('Category'));
|
---|
284 | }
|
---|
285 |
|
---|
286 | return (strlen($sResult) > 0 ? MsgBox($sResult) : '') .
|
---|
287 | $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html', array('content' => $oForm->getCode()));
|
---|
288 | }
|
---|
289 |
|
---|
290 | $iNameIndex = 9;
|
---|
291 | $aMenu = array(
|
---|
292 | 'all' => array(
|
---|
293 | 'title' => _t('_categ_all'),
|
---|
294 | 'href' => $_SERVER['PHP_SELF'] . '?action=all',
|
---|
295 | '_func' => array ('name' => 'actionAllCategories', 'params' => array()),
|
---|
296 | ),
|
---|
297 | 'pending' => array(
|
---|
298 | 'title' => _t('_categ_admin_pending'),
|
---|
299 | 'href' => $_SERVER['PHP_SELF'] . '?action=pending',
|
---|
300 | '_func' => array ('name' => 'actionPending', 'params' => array()),
|
---|
301 | ),
|
---|
302 | 'settings' => array(
|
---|
303 | 'title' => _t('_categ_admin_settings'),
|
---|
304 | 'href' => $_SERVER['PHP_SELF'] . '?action=settings',
|
---|
305 | '_func' => array ('name' => 'actionSettings', 'params' => array()),
|
---|
306 | ),
|
---|
307 | );
|
---|
308 | $sAction = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'all';
|
---|
309 | $aMenu[$sAction]['active'] = 1;
|
---|
310 | $sContent = call_user_func_array($aMenu[$sAction]['_func']['name'], $aMenu[$sAction]['_func']['params']);
|
---|
311 |
|
---|
312 | $_page = array(
|
---|
313 | 'name_index' => $iNameIndex,
|
---|
314 | 'css_name' => array('forms_adv.css', 'settings.css', 'modules.css'),
|
---|
315 | 'header' => _t('_Categories'),
|
---|
316 | 'header_text' => 'Test title'
|
---|
317 | );
|
---|
318 |
|
---|
319 | $_page_cont[$iNameIndex]['page_main_code'] = DesignBoxAdmin(_t('_categ_form_add'), getAddCategoryForm()) .
|
---|
320 | DesignBoxAdmin($aMenu[$sAction]['title'], $sContent, $aMenu);
|
---|
321 |
|
---|
322 | PageCodeAdmin();
|
---|
323 | ?>
|
---|