Changeset 15967
- Timestamp:
- 02/09/12 00:41:43 (4 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
inc/classes/BxDolAcl.php (modified) (1 diff)
-
inc/classes/BxDolAclQuery.php (modified) (3 diffs)
-
modules/boonex/english/install/data/langs/en.xml (modified) (4 diffs)
-
studio/classes/BxDolStudioUtils.php (modified) (3 diffs)
-
studio/js/builder_page.js (modified) (1 diff)
-
studio/templates/base/scripts/BxBaseStudioBuilderPage.php (modified) (6 diffs)
-
studio/templates/base/scripts/BxBaseStudioNavigationItems.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/inc/classes/BxDolAcl.php
r15942 r15967 316 316 * @return array( membershipID_1 => membershipName_1, membershipID_2 => membershipName_2, ...) if no such memberships, then just array() 317 317 */ 318 function getMemberships($bPurchasableOnly = false) { 318 function getMemberships($bPurchasableOnly = false, $bActiveOnly = false) { 319 $sType = 'all_pair'; 320 if($bPurchasableOnly) 321 $sType = 'all_active_purchasble_pair'; 322 else if($bActiveOnly) 323 $sType = 'all_active_pair'; 324 319 325 $aLevels = array(); 320 $this->oDb->getLevels(array('type' => ($bPurchasableOnly ? 'all_active_purchasble_pair' : 'all_pair')), $aLevels, false);326 $this->oDb->getLevels(array('type' => $sType), $aLevels, false); 321 327 return $aLevels; 322 328 } -
trunk/inc/classes/BxDolAclQuery.php
r15915 r15967 57 57 $sWhereClause .= "AND `tal`.`Active`='yes' AND `tal`.`Purchasable`='yes'"; 58 58 break; 59 case 'all_active_pair': 60 $aMethod['name'] = "getPairs"; 61 $aMethod['params'][1] = 'id'; 62 $aMethod['params'][2] = 'name'; 63 $sWhereClause .= "AND `tal`.`Active`='yes'"; 64 break; 59 65 case 'all_pair': 60 66 $aMethod['name'] = "getPairs"; … … 69 75 } 70 76 71 $aMethod['params'][0] = "SELECT 77 $aMethod['params'][0] = "SELECT SQL_CALC_FOUND_ROWS 72 78 `tal`.`ID` AS `id`, 73 79 `tal`.`Name` AS `name`, … … 88 94 return count($aItems) > 0; 89 95 90 $sQuery = "SELECT 91 COUNT(`tal`.`ID`) 92 FROM `sys_acl_levels` AS `tal`" . $sJoinClause . " 93 WHERE 1 " . $sWhereClause . " 94 LIMIT 1"; 95 return $this->getOne($sQuery); 96 return (int)$this->getOne("SELECT FOUND_ROWS()"); 96 97 } 97 98 -
trunk/modules/boonex/english/install/data/langs/en.xml
r15966 r15967 2473 2473 <string name="_adm_bp_txt_block_selected"><![CDATA[blocks selected]]></string> 2474 2474 <string name="_adm_bp_scs_block_added"><![CDATA[The blocks were successfully added.]]></string> 2475 <string name="_adm_bp_err_block_added"><![CDATA[Cannot add block s.]]></string>2475 <string name="_adm_bp_err_block_added"><![CDATA[Cannot add block(s)]]></string> 2476 2476 <string name="_adm_bp_txt_edit_block_popup"><![CDATA[Edit "{0}" Block]]></string> 2477 2477 <string name="_adm_bp_err_block_edit"><![CDATA[Cannot update block]]></string> 2478 <string name="_adm_bp_err_block_delete"><![CDATA[Cannot delete block]]></string> 2478 2479 <string name="_adm_bp_err_block_not_found"><![CDATA[The requested block cannot be found.]]></string> 2479 2480 <string name="_adm_bp_err_block_remove_old_image"><![CDATA[Cannot remove an old image]]></string> … … 2491 2492 <string name="_adm_bp_btn_block_save"><![CDATA[Save]]></string> 2492 2493 <string name="_adm_bp_btn_block_cancel"><![CDATA[Cancel]]></string> 2494 <string name="_adm_bp_btn_block_delete"><![CDATA[Delete]]></string> 2493 2495 <string name="_adm_bp_txt_block_content_raw"><![CDATA[Content]]></string> 2494 2496 <string name="_adm_bp_dsc_block_content_raw"><![CDATA[Enter HTML content here]]></string> … … 2512 2514 <string name="_adm_bp_txt_block_content_service_module"><![CDATA[Module]]></string> 2513 2515 <string name="_adm_bp_txt_block_content_service_method"><![CDATA[Method]]></string> 2514 2515 2516 <string name=""><![CDATA[]]></string> 2516 2517 <string name=""><![CDATA[]]></string> … … 2529 2530 <string name="_adm_bp_err_page_layout"><![CDATA[Please, select a page layout.]]></string> 2530 2531 <string name="_adm_bp_txt_page_layout_empty"><![CDATA[Select Layout...]]></string> 2531 <string name="_adm_bp_txt_page_visible_for_levels"><![CDATA[ UserLevels]]></string>2532 <string name="_adm_bp_txt_page_visible_for_levels"><![CDATA[Select Levels]]></string> 2532 2533 <string name="_adm_bp_dsc_page_visible_for_levels"><![CDATA[Select user levels that can see this page]]></string> 2533 2534 <string name="_adm_bp_err_page_visible_for_levels"><![CDATA[Visibility setting are determined by custom code or not applicable here.]]></string> -
trunk/studio/classes/BxDolStudioUtils.php
r15966 r15967 76 76 } 77 77 78 public static function getVisibilityCount($iValue , $aLevels) {78 public static function getVisibilityCount($iValue) { 79 79 $iResult = 0; 80 80 … … 84 84 else if($iValue == BX_DOL_INT_MAX) 85 85 return -1; 86 87 bx_import('BxDolAcl'); 88 $aLevels = BxDolAcl::getInstance()->getMemberships(false, true); 86 89 87 90 $iIndex = 1; … … 107 110 public static function getVisibilityValues($iValue, &$aValuesAll, &$aValuesSelected) { 108 111 bx_import('BxDolAcl'); 109 $aLevels = BxDolAcl::getInstance()->getMemberships( );112 $aLevels = BxDolAcl::getInstance()->getMemberships(false, true); 110 113 foreach($aLevels as $iKey => $sValue) { 111 114 if(((int)$iValue & pow(2, (int)$iKey - 1)) != 0) -
trunk/studio/js/builder_page.js
r15963 r15967 139 139 }; 140 140 141 BxDolStudioBuilderPage.prototype.onDeleteBlock = function(oData) { 142 143 }; 144 141 145 /** 142 146 * "Settings" popup methods. -
trunk/studio/templates/base/scripts/BxBaseStudioBuilderPage.php
r15966 r15967 386 386 } 387 387 388 protected function actionPageEdit() { 389 $sJsObject = $this->getPageJsObject(); 390 $oTemplate = BxDolStudioTemplate::getInstance(); 391 392 $aForm = array( 393 'form_attrs' => array( 394 'id' => 'adm-bp-page-edit', 395 'action' => BX_DOL_URL_STUDIO . 'builder_page.php?bp_action=' . $this->sActionPageEdit . '&type=' . $this->sType . '&page=' . $this->sPage, 396 'method' => 'post' 397 ), 398 'params' => array ( 399 'db' => array( 400 'table' => 'sys_objects_page', 401 'key' => 'object', 402 'uri' => '', 403 'uri_title' => '', 404 'submit_name' => 'do_submit' 405 ), 406 ), 407 'inputs' => array ( 408 'settings' => array( 409 'type' => 'custom', 410 'name' => 'settings', 411 'content' => '', 412 ), 413 ) 414 ); 415 416 $aSettings = array( 417 array('name' => 'options', 'title' => '_adm_bp_mi_page_options', 'active' => 1), 418 array('name' => 'layout', 'title' => '_adm_bp_mi_page_layout', 'active' => 0), 419 array('name' => 'visibility', 'title' => '_adm_bp_mi_page_visibility', 'active' => 0), 420 array('name' => 'cache', 'title' => '_adm_bp_mi_page_cache', 'active' => 0), 421 array('name' => 'seo', 'title' => '_adm_bp_mi_page_seo', 'active' => 0) 422 ); 423 424 $aTmplParams = array( 425 'bx_repeat:menus' => array(), 426 'html_settings_groups_id' => $this->aHtmlIds['settings_groups_id'], 427 'bx_repeat:settings_groups' => array() 428 ); 429 foreach($aSettings as $aSetting) { 430 //--- get menu items 431 $aTmplParams['bx_repeat:menus'][] = array( 432 'bx_if:caption' => array( 433 'condition' => false, 434 'content' => array() 435 ), 436 'bx_if:item' => array( 437 'condition' => true, 438 'content' => array( 439 'name' => $aSetting['name'], 440 'bx_if:active' => array( 441 'condition' => isset($aSetting['active']) && (int)$aSetting['active'] == 1, 442 'content' => array() 443 ), 444 'icon' => '', 445 'url' => 'javascript:void(0)', 446 'bx_if:show_onclick' => array( 447 'condition' => true, 448 'content' => array( 449 'onclick' => 'javascript:' . $sJsObject . '.onChangeSettingGroup(\'' . $aSetting['name'] . '\', this);', 450 ) 451 ), 452 'caption' => _t($aSetting['title']) 453 ) 454 ), 455 ); 456 457 //--- get settings 458 $aTmplParams['bx_repeat:settings_groups'][] = array( 459 'html_settings_group_id' => $this->aHtmlIds['settings_group_id'] . $aSetting['name'], 460 'bx_if:hidden' => array( 461 'condition' => $aSetting['active'] != 1, 462 'content' => array() 463 ), 464 'content' => $this->{'getSettings' . $this->getClassName($aSetting['name'])}() 465 ); 466 } 467 468 $aForm['inputs']['settings']['content'] = $oTemplate->parseHtmlByName('bp_edit_page_form.html', $aTmplParams); 469 470 $oForm = new BxTemplStudioFormView($aForm); 471 $oForm->initChecker(); 472 473 $sContent = ""; 474 if($oForm->isSubmittedAndValid()) { 475 $aKeys = array_keys($this->aPageRebuild); 476 477 $aFields = array(); 478 foreach($aKeys as $sKey) 479 if(($sValue = bx_get($sKey)) !== false) 480 $aFields[$sKey] = bx_process_input($sValue); 481 482 $sTitleValue = ''; 483 if(isset($aFields['title'])) { 484 $sTitleValue = $aFields['title']; 485 $aFields['title'] = $this->aPageRebuild['title']; 486 } 487 488 if(isset($aFields['visible_for_levels'])) 489 $aFields['visible_for_levels'] = BxDolStudioUtils::getVisibilityValue(bx_process_input(bx_get('visible_for')), $aFields['visible_for_levels']); 490 491 if($this->oDb->updatePage($this->aPageRebuild['id'], $aFields) !== false) { 492 bx_import('BxDolStudioLanguagesUtils'); 493 BxDolStudioLanguagesUtils::getInstance()->updateLanguageString($this->aPageRebuild['title'], $sTitleValue); 494 495 if(isset($aFields['layout_id']) && $aFields['layout_id'] != $this->aPageRebuild['layout_id'] && $this->oDb->resetBlocksByPage($this->sPage) !== false) 496 return array('eval' => $sJsObject . '.onSaveSettings()'); 497 498 return array(); 499 } 500 else 501 return array('msg' => _t('_adm_bp_err_save')); 502 } 503 504 bx_import('BxTemplStudioFunctions'); 505 $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_popup_id'], _t('_adm_bp_txt_settings_popup'), $oTemplate->parseHtmlByName('bp_edit_page.html', array( 506 'form_id' => $aForm['form_attrs']['id'], 507 'form' => $oForm->getCode() 508 ))); 509 510 return array('popup' => $sContent); 511 } 512 388 513 protected function actionPageDelete() { 389 514 bx_import('BxDolStudioLanguagesUtils'); … … 413 538 414 539 return $aResult; 415 }416 417 protected function actionPageEdit() {418 $sJsObject = $this->getPageJsObject();419 $oTemplate = BxDolStudioTemplate::getInstance();420 421 $aForm = array(422 'form_attrs' => array(423 'id' => 'adm-bp-page-edit',424 'action' => BX_DOL_URL_STUDIO . 'builder_page.php?bp_action=' . $this->sActionPageEdit . '&type=' . $this->sType . '&page=' . $this->sPage,425 'method' => 'post'426 ),427 'params' => array (428 'db' => array(429 'table' => 'sys_objects_page',430 'key' => 'object',431 'uri' => '',432 'uri_title' => '',433 'submit_name' => 'do_submit'434 ),435 ),436 'inputs' => array (437 'settings' => array(438 'type' => 'custom',439 'name' => 'settings',440 'content' => '',441 ),442 )443 );444 445 $aSettings = array(446 array('name' => 'options', 'title' => '_adm_bp_mi_page_options', 'active' => 1),447 array('name' => 'layout', 'title' => '_adm_bp_mi_page_layout', 'active' => 0),448 array('name' => 'visibility', 'title' => '_adm_bp_mi_page_visibility', 'active' => 0),449 array('name' => 'cache', 'title' => '_adm_bp_mi_page_cache', 'active' => 0),450 array('name' => 'seo', 'title' => '_adm_bp_mi_page_seo', 'active' => 0)451 );452 453 $aTmplParams = array(454 'bx_repeat:menus' => array(),455 'html_settings_groups_id' => $this->aHtmlIds['settings_groups_id'],456 'bx_repeat:settings_groups' => array()457 );458 foreach($aSettings as $aSetting) {459 //--- get menu items460 $aTmplParams['bx_repeat:menus'][] = array(461 'bx_if:caption' => array(462 'condition' => false,463 'content' => array()464 ),465 'bx_if:item' => array(466 'condition' => true,467 'content' => array(468 'name' => $aSetting['name'],469 'bx_if:active' => array(470 'condition' => isset($aSetting['active']) && (int)$aSetting['active'] == 1,471 'content' => array()472 ),473 'icon' => '',474 'url' => 'javascript:void(0)',475 'bx_if:show_onclick' => array(476 'condition' => true,477 'content' => array(478 'onclick' => 'javascript:' . $sJsObject . '.onChangeSettingGroup(\'' . $aSetting['name'] . '\', this);',479 )480 ),481 'caption' => _t($aSetting['title'])482 )483 ),484 );485 486 //--- get settings487 $aTmplParams['bx_repeat:settings_groups'][] = array(488 'html_settings_group_id' => $this->aHtmlIds['settings_group_id'] . $aSetting['name'],489 'bx_if:hidden' => array(490 'condition' => $aSetting['active'] != 1,491 'content' => array()492 ),493 'content' => $this->{'getSettings' . $this->getClassName($aSetting['name'])}()494 );495 }496 497 $aForm['inputs']['settings']['content'] = $oTemplate->parseHtmlByName('bp_edit_page_form.html', $aTmplParams);498 499 $oForm = new BxTemplStudioFormView($aForm);500 $oForm->initChecker();501 502 $sContent = "";503 if($oForm->isSubmittedAndValid()) {504 $aKeys = array_keys($this->aPageRebuild);505 506 $aFields = array();507 foreach($aKeys as $sKey)508 if(($sValue = bx_get($sKey)) !== false)509 $aFields[$sKey] = bx_process_input($sValue);510 511 $sTitleValue = '';512 if(isset($aFields['title'])) {513 $sTitleValue = $aFields['title'];514 $aFields['title'] = $this->aPageRebuild['title'];515 }516 517 if(isset($aFields['visible_for_levels']) && is_array($aFields['visible_for_levels'])) {518 $iHideFrom = 0;519 foreach($aFields['visible_for_levels'] as $iLevelId)520 $iHideFrom += pow(2, (int)$iLevelId - 1);521 $aFields['visible_for_levels'] = $iHideFrom;522 }523 524 if($this->oDb->updatePage($this->aPageRebuild['id'], $aFields) !== false) {525 bx_import('BxDolStudioLanguagesUtils');526 BxDolStudioLanguagesUtils::getInstance()->updateLanguageString($this->aPageRebuild['title'], $sTitleValue);527 528 if(isset($aFields['layout_id']) && $aFields['layout_id'] != $this->aPageRebuild['layout_id'] && $this->oDb->resetBlocksByPage($this->sPage) !== false)529 return array('eval' => $sJsObject . '.onSaveSettings()');530 531 return array();532 }533 else534 return array('msg' => _t('_adm_bp_err_save'));535 }536 537 bx_import('BxTemplStudioFunctions');538 $sContent = BxTemplStudioFunctions::getInstance()->popupBox($this->aHtmlIds['edit_popup_id'], _t('_adm_bp_txt_settings_popup'), $oTemplate->parseHtmlByName('bp_edit_page.html', array(539 'form_id' => $aForm['form_attrs']['id'],540 'form' => $oForm->getCode()541 )));542 543 return array('popup' => $sContent);544 540 } 545 541 … … 813 809 'attrs' => array( 814 810 'onclick' => "$('.bx-popup-applied:visible').dolPopupHide()", 811 'class' => 'bx-def-margin-sec-left', 812 ), 813 ), 814 array ( 815 'type' => 'reset', 816 'name' => 'close', 817 'value' => _t('_adm_bp_btn_block_delete'), 818 'attrs' => array( 819 'onclick' => $this->getPageJsObject() . ".performAction('block_delete', {id:" . $aBlock['id'] . "})", 815 820 'class' => 'bx-def-margin-sec-left', 816 821 ), … … 1072 1077 } 1073 1078 1079 protected function actionBlockDelete() { 1080 $sJsObject = $this->getPageJsObject(); 1081 1082 $iId = (int)bx_get('id'); 1083 if(!$this->oDb->deleteBlocks(array('type' => 'by_id', 'value' => $iId))) 1084 return array('msg' => _t('_adm_bp_err_block_delete')); 1085 1086 return array('eval' => $sJsObject . '.onDeleteBlock(' . $iId . ', oData)'); 1087 } 1088 1074 1089 protected function getSettingsOptions() { 1075 1090 $aForm = array( … … 1170 1185 protected function getSettingsVisibility() { 1171 1186 if((int)$this->aPageRebuild['visible_for_levels_editable'] == 0) 1172 $aInput = array( 1173 'type' => 'custom', 1174 'name' => 'visible_for_levels', 1175 'content' => MsgBox(_t('_adm_bp_err_page_visible_for_levels')) 1187 $aInputs = array( 1188 'visible_for_levels' => array( 1189 'type' => 'custom', 1190 'name' => 'visible_for_levels', 1191 'content' => MsgBox(_t('_adm_bp_err_page_visible_for_levels')) 1192 ) 1176 1193 ); 1177 1194 else 1178 $aInput = array( 1179 'type' => 'checkbox_set', 1180 'name' => 'visible_for_levels', 1181 'caption' => _t('_adm_bp_txt_page_visible_for_levels'), 1182 'info' => _t('_adm_bp_dsc_page_visible_for_levels'), 1183 'value' => '', 1184 'values' => array(), 1185 'db' => array ( 1186 'pass' => 'Int', 1195 $aInputs = array( 1196 'visible_for' => array( 1197 'type' => 'select', 1198 'name' => 'visible_for', 1199 'caption' => _t('_adm_bp_txt_block_visible_for'), 1200 'info' => '', 1201 'value' => $this->aPageRebuild['visible_for_levels'] == BX_DOL_INT_MAX ? BX_DOL_STUDIO_VISIBLE_ALL : BX_DOL_STUDIO_VISIBLE_SELECTED, 1202 'values' => array( 1203 array('key' => BX_DOL_STUDIO_VISIBLE_ALL, 'value' => _t('_adm_bp_txt_block_visible_for_all')), 1204 array('key' => BX_DOL_STUDIO_VISIBLE_SELECTED, 'value' => _t('_adm_bp_txt_block_visible_for_selected')), 1205 ), 1206 'required' => '0', 1207 'attrs' => array( 1208 'onchange' => $this->getPageJsObject() . '.onChangeVisibleFor(this)' 1209 ), 1210 'db' => array ( 1211 'pass' => 'Xss', 1212 ) 1213 ), 1214 'visible_for_levels' => array( 1215 'type' => 'checkbox_set', 1216 'name' => 'visible_for_levels', 1217 'caption' => _t('_adm_bp_txt_page_visible_for_levels'), 1218 'info' => _t('_adm_bp_dsc_page_visible_for_levels'), 1219 'value' => '', 1220 'values' => array(), 1221 'tr_attrs' => array( 1222 'style' => $this->aPageRebuild['visible_for_levels'] == BX_DOL_INT_MAX ? 'display:none' : '' 1223 ), 1224 'db' => array ( 1225 'pass' => 'Int', 1226 ) 1187 1227 ) 1188 1228 ); … … 1198 1238 ) 1199 1239 ), 1200 'inputs' => array ( 1201 'visible_for_levels' => $aInput 1202 ) 1203 ); 1204 1205 bx_import('BxDolAcl'); 1206 $aLevels = BxDolAcl::getInstance()->getMemberships(); 1207 foreach($aLevels as $iKey => $sValue) { 1208 if(((int)$this->aPageRebuild['visible_for_levels'] & pow(2, (int)$iKey - 1)) != 0) 1209 $aForm['inputs']['visible_for_levels']['value'][] = $iKey; 1210 1211 $aForm['inputs']['visible_for_levels']['values'][$iKey] = _t($sValue); 1212 } 1240 'inputs' => $aInputs 1241 ); 1242 1243 BxDolStudioUtils::getVisibilityValues($this->aPageRebuild['visible_for_levels'], $aForm['inputs']['visible_for_levels']['values'], $aForm['inputs']['visible_for_levels']['value']); 1213 1244 1214 1245 $oForm = new BxTemplStudioFormView($aForm); -
trunk/studio/templates/base/scripts/BxBaseStudioNavigationItems.php
r15966 r15967 13 13 14 14 class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems { 15 private $aMemberships;16 17 15 function __construct($aOptions, $oTemplate = false) { 18 16 parent::__construct($aOptions, $oTemplate); 19 20 bx_import('BxDolAcl');21 $this->aMemberships = BxDolAcl::getInstance()->getMemberships();22 17 } 23 18 … … 669 664 670 665 protected function _getCellVisibleForLevels ($mixedValue, $sKey, $aField, $aRow) { 671 $iCount = BxDolStudioUtils::getVisibilityCount($aRow['visible_for_levels'] , $this->aMemberships);666 $iCount = BxDolStudioUtils::getVisibilityCount($aRow['visible_for_levels']); 672 667 673 668 $mixedValue = $this->_oTemplate->parseHtmlByName('bx_a.html', array(
Note: See TracChangeset
for help on using the changeset viewer.