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 | $aBxSecurityExceptions[] = 'POST.Link';
|
---|
24 | $aBxSecurityExceptions[] = 'REQUEST.Link';
|
---|
25 |
|
---|
26 | require_once( '../inc/header.inc.php' );
|
---|
27 | require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
|
---|
28 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
29 | require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
|
---|
30 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
|
---|
31 | require_once( BX_DIRECTORY_PATH_INC . 'languages.inc.php' );
|
---|
32 |
|
---|
33 | require_once( BX_DIRECTORY_PATH_PLUGINS . 'Services_JSON.php' );
|
---|
34 |
|
---|
35 | bx_import('BxDolMemberMenu');
|
---|
36 |
|
---|
37 | // Check if administrator is logged in. If not display login form.
|
---|
38 | $logged['admin'] = member_auth(1, true, true);
|
---|
39 |
|
---|
40 | $GLOBALS['oAdmTemplate']->addJsTranslation(array(
|
---|
41 | '_adm_mbuilder_Sorry_could_not_insert_object',
|
---|
42 | '_adm_mbuilder_This_items_are_non_editable'
|
---|
43 | ));
|
---|
44 |
|
---|
45 | $oMemeberMenu = new BxDolMemberMenu();
|
---|
46 |
|
---|
47 | $aMenuSection = array (
|
---|
48 | 'top', 'top_extra'
|
---|
49 | );
|
---|
50 |
|
---|
51 | $sResponce = null;
|
---|
52 |
|
---|
53 | // top is default position ;
|
---|
54 |
|
---|
55 | $sMenuSection = $aMenuSection[0];
|
---|
56 |
|
---|
57 | if ( isset($_GET['menu_position']) ) {
|
---|
58 | foreach( $aMenuSection AS $sValue ) {
|
---|
59 | if ( $sValue == $_GET['menu_position'] ) {
|
---|
60 | $sMenuSection = $sValue;
|
---|
61 | break;
|
---|
62 | }
|
---|
63 | }
|
---|
64 | }
|
---|
65 |
|
---|
66 | // ** FOR 'AJAX' REQUESTS ;
|
---|
67 | if( $_REQUEST['action'] ) {
|
---|
68 | switch( $_REQUEST['action'] ) {
|
---|
69 | case 'edit_form':
|
---|
70 | $id = (int)$_REQUEST['id'];
|
---|
71 |
|
---|
72 | $aItem = db_assoc_arr( "SELECT * FROM `sys_menu_member` WHERE `ID` = $id", 0 );
|
---|
73 | $sResponce = ($aItem) ? showEditForm($aItem, $sMenuSection) : echoMenuEditMsg('Error', 'red');
|
---|
74 | break;
|
---|
75 | case 'create_item':
|
---|
76 | $newID = createNewElement( $_REQUEST['type'], (int)$_REQUEST['source'], $sMenuSection);
|
---|
77 | $sResponce = $newID;
|
---|
78 | break;
|
---|
79 | case 'deactivate_item':
|
---|
80 | $res = db_res( "UPDATE `sys_menu_member` SET `Active`='0' WHERE `ID`=" . (int)$_REQUEST['id'] );
|
---|
81 | $sResponce = db_affected_rows();
|
---|
82 | break;
|
---|
83 | case 'save_item':
|
---|
84 | $id = (int)$_REQUEST['id'];
|
---|
85 | if( !$id ) {
|
---|
86 | $sResponce = echoMenuEditMsg( 'Error', 'red' );
|
---|
87 | } else {
|
---|
88 | $aItemFields = array( 'Name', 'Caption', 'Link', 'Target', 'Icon', 'Script' );
|
---|
89 | $aItem = array();
|
---|
90 |
|
---|
91 | foreach( $aItemFields as $field ) {
|
---|
92 | $aItem[$field] = ( isset($_REQUEST[$field]) ) ? $_REQUEST[$field] : null ;
|
---|
93 | }
|
---|
94 |
|
---|
95 | if ( !$aItem['Icon'] ) {
|
---|
96 | $aItem['Icon'] = 'member_menu_default.png';
|
---|
97 | }
|
---|
98 |
|
---|
99 | $res = saveItem( $id, $aItem, $sMenuSection );
|
---|
100 | updateLangFile( $_REQUEST['Caption'], $_REQUEST['LangCaption'] );
|
---|
101 |
|
---|
102 | $res['message'] = MsgBox($res['message']);
|
---|
103 | $oJson = new Services_JSON();
|
---|
104 | echo $oJson->encode($res);
|
---|
105 | exit;
|
---|
106 | }
|
---|
107 | break;
|
---|
108 |
|
---|
109 | case 'delete_item':
|
---|
110 | $id = (int)$_REQUEST['id'];
|
---|
111 | if( !$id ) {
|
---|
112 | $sResponce = 'Item ID is not specified';
|
---|
113 | } else {
|
---|
114 | $aItem = db_arr( "SELECT `Deletable` FROM `sys_menu_member` WHERE `ID` = $id" );
|
---|
115 | if( !$aItem ) {
|
---|
116 | $sResponce = 'Item not found';
|
---|
117 | } else if( !(int)$aItem['Deletable'] ) {
|
---|
118 | $sResponce = 'Item is non-deletable';
|
---|
119 | } else {
|
---|
120 | db_res( "DELETE FROM `sys_menu_member` WHERE `ID` = $id" );
|
---|
121 | $sResponce = ( db_affected_rows() ) ? 'OK' : 'Couldn\'t delete the item';
|
---|
122 | }
|
---|
123 | }
|
---|
124 | break;
|
---|
125 |
|
---|
126 | case 'save_orders':
|
---|
127 | $sTop = $_REQUEST['top'];
|
---|
128 | $aCustom = $_REQUEST['custom'];
|
---|
129 | saveOrders( $sTop, $aCustom, $sMenuSection );
|
---|
130 | $sResponce = 'OK';
|
---|
131 | break;
|
---|
132 | }
|
---|
133 |
|
---|
134 | // return script's response and recompile the menu cache ;
|
---|
135 | $oMemeberMenu -> createMemberMenuCache( $sMenuSection );
|
---|
136 | echo $sResponce;
|
---|
137 | exit;
|
---|
138 | }
|
---|
139 |
|
---|
140 | // generate all active menu items ;
|
---|
141 |
|
---|
142 | $sTopQuery = "
|
---|
143 | SELECT `ID`, `Name`
|
---|
144 | FROM `sys_menu_member`
|
---|
145 | WHERE
|
---|
146 | `Active`='1'
|
---|
147 | AND
|
---|
148 | `Position`='{$sMenuSection}'
|
---|
149 | AND
|
---|
150 | `Type` <> 'linked_item'
|
---|
151 | ORDER BY
|
---|
152 | `Order`
|
---|
153 | ";
|
---|
154 | $rTopItems = db_res( $sTopQuery );
|
---|
155 |
|
---|
156 | $sAllQuery = "
|
---|
157 | SELECT
|
---|
158 | `ID`, `Name`
|
---|
159 | FROM
|
---|
160 | `sys_menu_member`
|
---|
161 | WHERE
|
---|
162 | `Type` <> 'linked_item'
|
---|
163 | ORDER BY
|
---|
164 | `Position` , `ID`
|
---|
165 | ";
|
---|
166 |
|
---|
167 | $rAllItems = db_res( $sAllQuery );
|
---|
168 |
|
---|
169 | $sComposerInit = "
|
---|
170 | <script type=\"text/javascript\">
|
---|
171 | topParentID = 'menu_app_wrapper';
|
---|
172 | urlIconLoading = '{$site['url_admin']}images/loading.gif';
|
---|
173 | parserUrl = '{$_SERVER['PHP_SELF']}?menu_position={$sMenuSection}';
|
---|
174 |
|
---|
175 | allowNewItem = true;
|
---|
176 | allowAddToTop = true;
|
---|
177 | allowAddToCustom = false;
|
---|
178 | iInactivePerRow = 5;
|
---|
179 | sendSystemOrder = false;
|
---|
180 |
|
---|
181 | aCoords = {};
|
---|
182 | aCoords['startX'] = 270;
|
---|
183 | aCoords['startY'] = 235;
|
---|
184 | aCoords['width'] = 92;
|
---|
185 | aCoords['height'] = 21;
|
---|
186 | aCoords['diffX'] = 122;
|
---|
187 | aCoords['diffY'] = 32;
|
---|
188 |
|
---|
189 | aTopItems = {};
|
---|
190 | aCustomItems = {};
|
---|
191 | aSystemItems = {};
|
---|
192 | aAllItems = {};
|
---|
193 | ";
|
---|
194 |
|
---|
195 | while( $aTopItem = mysql_fetch_assoc( $rTopItems ) ) {
|
---|
196 | $sComposerInit .= "aTopItems[{$aTopItem['ID']}] = '" . addslashes( $aTopItem['Name'] ) . "';
|
---|
197 | aCustomItems[{$aTopItem['ID']}] = {};";
|
---|
198 | }
|
---|
199 |
|
---|
200 | $sComposerInit .= "\n";
|
---|
201 | while( $aAllItem = mysql_fetch_assoc( $rAllItems ) ) {
|
---|
202 | $sComposerInit .= "
|
---|
203 | aAllItems[{$aAllItem['ID']}] = '" . addslashes( $aAllItem['Name'] ) . "';";
|
---|
204 | }
|
---|
205 | $sComposerInit .= "
|
---|
206 | </script>
|
---|
207 | ";
|
---|
208 |
|
---|
209 | $iNameIndex = 12;
|
---|
210 | $_page = array(
|
---|
211 | 'name_index' => $iNameIndex,
|
---|
212 | 'css_name' => array('menu_compose.css', 'forms_adv.css'),
|
---|
213 | 'js_name' => array('menu_compose.js', 'BxDolMenu.js'),
|
---|
214 | 'header' => _t('_mmbuilder_page_title'),
|
---|
215 | 'header_text' => _t('_mmbuilder_box_title'),
|
---|
216 | );
|
---|
217 |
|
---|
218 | $_page_cont[$iNameIndex]['controls'] = getSwitcherBlock();
|
---|
219 | $_page_cont[$iNameIndex]['page_main_code'] = $GLOBALS['oAdmTemplate']->parseHtmlByName('menu_compose.html', array(
|
---|
220 | 'extra_js' => $sComposerInit
|
---|
221 | ));
|
---|
222 |
|
---|
223 |
|
---|
224 | PageCodeAdmin();
|
---|
225 |
|
---|
226 | // Functions
|
---|
227 | function getSwitcherBlock()
|
---|
228 | {
|
---|
229 | global $aMenuSection;
|
---|
230 |
|
---|
231 | $sOutputCode = '<div class="dbTopMenu">';
|
---|
232 | foreach($aMenuSection as $sKey)
|
---|
233 | {
|
---|
234 | $sElCaption =_t('_' . $sKey);
|
---|
235 |
|
---|
236 | // set default value;
|
---|
237 | if(!$_GET['menu_position'] && $sKey == 'top') {
|
---|
238 | $sClassName = 'active';
|
---|
239 | }
|
---|
240 | else {
|
---|
241 | $sClassName = ( isset($_GET['menu_position']) && $_GET['menu_position'] == $sKey)
|
---|
242 | ? 'active'
|
---|
243 | : 'notActive';
|
---|
244 | }
|
---|
245 |
|
---|
246 | switch($sClassName) {
|
---|
247 | case 'active' :
|
---|
248 | $sOutputCode .=
|
---|
249 | '
|
---|
250 | <div class="' . $sClassName . '">
|
---|
251 | <span>' . $sElCaption. '</span>
|
---|
252 | </div>
|
---|
253 | ';
|
---|
254 | break;
|
---|
255 |
|
---|
256 | case 'notActive' :
|
---|
257 | $sOutputCode .=
|
---|
258 | '
|
---|
259 | <div class="' . $sClassName . '">
|
---|
260 | <a href="member_menu_compose.php?menu_position=' . $sKey . '">' . $sElCaption. '</a>
|
---|
261 | </div>
|
---|
262 | ';
|
---|
263 | break;
|
---|
264 | }
|
---|
265 | }
|
---|
266 | $sOutputCode .= '</div>';
|
---|
267 |
|
---|
268 | return $sOutputCode;
|
---|
269 | }
|
---|
270 |
|
---|
271 | function showEditForm( $aItem, $sMenuSection ) {
|
---|
272 | $aForm = array(
|
---|
273 | 'form_attrs' => array(
|
---|
274 | 'id' => 'formItemEdit',
|
---|
275 | 'name' => 'formItemEdit',
|
---|
276 | 'action' => $_SERVER['PHP_SELF'],
|
---|
277 | 'method' => 'post',
|
---|
278 | 'enctype' => 'multipart/form-data',
|
---|
279 | ),
|
---|
280 | 'inputs' => array (
|
---|
281 | 'Name' => array(
|
---|
282 | 'type' => 'text',
|
---|
283 | 'name' => 'Name',
|
---|
284 | 'caption' => _t('_adm_mbuilder_System_Name'),
|
---|
285 | 'value' => $aItem['Name'],
|
---|
286 | 'attrs' => array()
|
---|
287 | ),
|
---|
288 | 'Caption' => array(
|
---|
289 | 'type' => 'text',
|
---|
290 | 'name' => 'Caption',
|
---|
291 | 'caption' => _t('_adm_mbuilder_Language_Key'),
|
---|
292 | 'value' => $aItem['Caption'],
|
---|
293 | 'attrs' => array()
|
---|
294 | ),
|
---|
295 | 'LangCaption' => array(
|
---|
296 | 'type' => 'text',
|
---|
297 | 'name' => 'LangCaption',
|
---|
298 | 'caption' => _t('_adm_mbuilder_Default_Name'),
|
---|
299 | 'value' => _t( $aItem['Caption'] ),
|
---|
300 | 'attrs' => array()
|
---|
301 | ),
|
---|
302 | 'Link' => array(
|
---|
303 | 'type' => 'text',
|
---|
304 | 'name' => 'Link',
|
---|
305 | 'caption' => _t('_URL'),
|
---|
306 | 'value' => htmlspecialchars_adv( $aItem['Link'] ),
|
---|
307 | 'attrs' => array()
|
---|
308 | ),
|
---|
309 | 'Script' => array(
|
---|
310 | 'type' => 'text',
|
---|
311 | 'name' => 'Script',
|
---|
312 | 'caption' => _t('_adm_mbuilder_script'),
|
---|
313 | 'value' => htmlspecialchars_adv( $aItem['Script'] ),
|
---|
314 | 'attrs' => array()
|
---|
315 | ),
|
---|
316 | 'Icon' => array(
|
---|
317 | 'type' => 'text',
|
---|
318 | 'name' => 'Icon',
|
---|
319 | 'caption' => _t('_adm_mbuilder_icon'),
|
---|
320 | 'value' => htmlspecialchars_adv( $aItem['Icon'] ),
|
---|
321 | 'attrs' => array()
|
---|
322 | ),
|
---|
323 | 'Target' => array(
|
---|
324 | 'type' => 'radio_set',
|
---|
325 | 'name' => 'Target',
|
---|
326 | 'caption' => _t('_adm_mbuilder_Target_Window'),
|
---|
327 | 'value' => $aItem['Target'] == '_blank' ? '_blank' : '_self',
|
---|
328 | 'values' => array(
|
---|
329 | '_self' => _t('_adm_mbuilder_Same'),
|
---|
330 | '_blank' => _t('_adm_mbuilder_New')
|
---|
331 | ),
|
---|
332 | 'attrs' => array()
|
---|
333 | ),
|
---|
334 | 'submit' => array(
|
---|
335 | 'type' => 'input_set',
|
---|
336 | array(
|
---|
337 | 'type' => 'button',
|
---|
338 | 'name' => 'save',
|
---|
339 | 'value' => _t('_Save Changes'), //if( $aItem['Editable'] )
|
---|
340 | 'attrs' => array(
|
---|
341 | 'onclick' => 'javascript:saveItem(' . $aItem['ID'] . ');'
|
---|
342 | )
|
---|
343 | ),
|
---|
344 | array(
|
---|
345 | 'type' => 'button',
|
---|
346 | 'name' => 'delete',
|
---|
347 | 'value' => _t('_Delete'), //if( $aItem['Deletable'] )
|
---|
348 | 'attrs' => array(
|
---|
349 | 'onclick' => 'javascript:deleteItem(' . $aItem['ID'] . ');'
|
---|
350 | )
|
---|
351 | )
|
---|
352 | ),
|
---|
353 | )
|
---|
354 | );
|
---|
355 |
|
---|
356 | foreach($aForm['inputs'] as $sKey => $aInput)
|
---|
357 | if(in_array($aInput['type'], array('text', 'checkbox')) && !$aItem['Editable'])
|
---|
358 | $aForm['inputs'][$sKey]['attrs']['disabled'] = "disabled";
|
---|
359 |
|
---|
360 | if(strpos($aItem['Visible'], 'non') !== false)
|
---|
361 | $aForm['inputs']['Visible']['value'][] = 'non';
|
---|
362 | if(strpos($aItem['Visible'], 'memb') !== false)
|
---|
363 | $aForm['inputs']['Visible']['value'][] = 'memb';
|
---|
364 |
|
---|
365 | $oForm = new BxTemplFormView($aForm);
|
---|
366 | return PopupBox('mmc_edit_popup', _t('_adm_mbuilder_edit_item')
|
---|
367 | , $GLOBALS['oAdmTemplate']->parseHtmlByName('design_box_content.html'
|
---|
368 | , array('content' => $oForm->getCode() . LoadingBox('formItemEditLoading'))));
|
---|
369 | }
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * @description : function will create new menu items ;
|
---|
373 | * @param : $type (string) - type of ellement ;
|
---|
374 | * @param : $source (integer) - menu's ID;
|
---|
375 | * @return : ID of created menu item ;
|
---|
376 | */
|
---|
377 | function createNewElement( $type, $source, $sMenuSection = 'top' ) {
|
---|
378 | global $oMenu;
|
---|
379 |
|
---|
380 | if( $source ) {
|
---|
381 | $sourceActive = db_value( "SELECT `Active` FROM `sys_menu_member` WHERE `ID`=$source" );
|
---|
382 | if( !$sourceActive ) {
|
---|
383 | //convert to active
|
---|
384 | db_res( "UPDATE `sys_menu_member` SET `Active`='1', `Position`='$type' WHERE `ID`=$source" );
|
---|
385 | $newID = $source;
|
---|
386 | } else {
|
---|
387 | //create from source
|
---|
388 | db_res( "INSERT INTO `sys_menu_member`
|
---|
389 | ( `Name`, `Caption`, `Link`, `Target`, `Script`, `Position`, `Eval`, `Icon`, `Type`, `Bubble`, `Description`, `PopupMenu`)
|
---|
390 | SELECT
|
---|
391 | `Name`, `Caption`, `Link`, `Target`, `Script`, '$type', `Eval`, `Icon`, `Type`, `Bubble`, `Description`, `PopupMenu`
|
---|
392 | FROM `sys_menu_member`
|
---|
393 | WHERE `ID`=$source" );
|
---|
394 | $newID = db_last_id();
|
---|
395 | }
|
---|
396 | } else {
|
---|
397 | //create new
|
---|
398 | db_res( "INSERT INTO `sys_menu_member` ( `Name`, `Position` ) VALUES ( 'NEW ITEM', '$type' )" );
|
---|
399 | $newID = db_last_id();
|
---|
400 | }
|
---|
401 |
|
---|
402 | return $newID;
|
---|
403 | }
|
---|
404 |
|
---|
405 | function echoMenuEditMsg( $text, $color = 'black' ) {
|
---|
406 | return <<<HTML
|
---|
407 | <div style="color:{$color};text-align:center;">{$text}</div>
|
---|
408 | HTML;
|
---|
409 | }
|
---|
410 |
|
---|
411 | /**
|
---|
412 | * @description : function will save all changes into menu items ;
|
---|
413 | * @param : $id (integer) - ID of menu items ;
|
---|
414 | * @param : $aItem (array) - all needed POST variables ;
|
---|
415 | * @param : $sMenuSection (string) - position of menu ;
|
---|
416 | * @return : Html presentation data (Answer code);
|
---|
417 | */
|
---|
418 | function saveItem( $id, $aItem, $sMenuSection ) {
|
---|
419 | global $oMenu, $sMenuSection, $oMemeberMenu;
|
---|
420 |
|
---|
421 | $aOldItem = db_arr( "SELECT * FROM `sys_menu_member` WHERE `ID` = $id" );
|
---|
422 |
|
---|
423 | if(!$aOldItem) {
|
---|
424 | return array( 'code' => 2, 'message' => _t('_adm_mbuilder_Item_not_found') );
|
---|
425 | }
|
---|
426 |
|
---|
427 | if( (int) $aOldItem['Editable'] != 1 ) {
|
---|
428 | return array('code' => 3, 'message' => _t('_adm_mbuilder_Item_is_non_editable') );
|
---|
429 | }
|
---|
430 |
|
---|
431 | $sQuerySet = '';
|
---|
432 | foreach( $aItem as $field => $value )
|
---|
433 | $sQuerySet .= ", `$field`='" . process_db_input( $value ) ."'";
|
---|
434 |
|
---|
435 | $sQuerySet = substr( $sQuerySet, 1 );
|
---|
436 |
|
---|
437 | $sQuery = "UPDATE `sys_menu_member` SET $sQuerySet WHERE `ID` = $id";
|
---|
438 | db_res( $sQuery );
|
---|
439 |
|
---|
440 | // return script's response and recompile the menu cache ;
|
---|
441 | $oMemeberMenu -> createMemberMenuCache( $sMenuSection );
|
---|
442 |
|
---|
443 | return array('code' => 0, 'message' => _t('_Saved'), 'timer' => 3);
|
---|
444 | }
|
---|
445 |
|
---|
446 | function updateLangFile( $key, $string ) {
|
---|
447 | // clear from special chars ;
|
---|
448 |
|
---|
449 | $key = preg_replace( '|\{([^\}]+)\}|', '', $key);
|
---|
450 |
|
---|
451 | $langName = getParam( 'lang_default' );
|
---|
452 | $langID = db_value( "SELECT `ID` FROM `sys_localization_languages` WHERE `Name` = '" . addslashes( $langName ) . "'" );
|
---|
453 |
|
---|
454 | $keyID = db_value( "SELECT `ID` FROM `sys_localization_keys` WHERE `Key` = '" . process_db_input( $key ) . "'" );
|
---|
455 | if( $keyID ) {
|
---|
456 | db_res( "UPDATE `sys_localization_strings` SET `String` = '" .process_db_input( $string ) . "' WHERE `IDKey`=$keyID AND `IDLanguage`=$langID" );
|
---|
457 | } else {
|
---|
458 | db_res( "INSERT INTO `sys_localization_keys` SET `IDCategory` = 2, `Key` = '" . process_db_input( $key ) . "'" );
|
---|
459 | db_res( "INSERT INTO `sys_localization_strings` SET `IDKey` = " . db_last_id() . ", `IDLanguage` = $langID, `String` = '" .process_db_input( $string ) . "'" );
|
---|
460 | }
|
---|
461 |
|
---|
462 | compileLanguage($langID);
|
---|
463 | }
|
---|
464 |
|
---|
465 | /**
|
---|
466 | * @description : function will save menu orders ;
|
---|
467 | * @param : $sTop ( string ) - current menu ellement ;
|
---|
468 | * @param : $aCustom ( array ) - all mrnu items ;
|
---|
469 | * @param : $sMenuSection (string) - position of menu ;
|
---|
470 | */
|
---|
471 | function saveOrders( $sTop, $aCustom, $sMenuSection ) {
|
---|
472 | db_res( "UPDATE `sys_menu_member` SET `Order` = 0 WHERE `Position` = '{$sMenuSection}' " );
|
---|
473 |
|
---|
474 | $sTop = trim( $sTop, ' ,' );
|
---|
475 | $aTopIDs = explode( ',', $sTop );
|
---|
476 |
|
---|
477 | foreach( $aTopIDs as $iOrd => $iID ) {
|
---|
478 | $iID = trim( $iID, ' ,' );
|
---|
479 | $iID = (int)$iID;
|
---|
480 |
|
---|
481 | if( !$iID )
|
---|
482 | continue;
|
---|
483 |
|
---|
484 | db_res( "UPDATE `sys_menu_member` SET `Order` = $iOrd, `Position` = '{$sMenuSection}' WHERE `ID` = $iID" );
|
---|
485 | }
|
---|
486 | }
|
---|
487 |
|
---|
488 | ?>
|
---|