From 1221faae6218bd2586891512b4a799c81097de85 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Wed, 2 Jul 2014 18:07:54 +1000 Subject: [PATCH] Session key fix to relation manager My Settings context now uses correct breadcrumb --- modules/backend/behaviors/RelationController.php | 15 +++++++++++++-- .../assets/js/october.relation.js | 10 ++++++---- modules/backend/lang/en/lang.php | 3 --- modules/system/controllers/Settings.php | 11 ++++++++++- modules/system/controllers/settings/update.htm | 4 ++-- 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/modules/backend/behaviors/RelationController.php b/modules/backend/behaviors/RelationController.php index 82a820161..643d0ba10 100644 --- a/modules/backend/behaviors/RelationController.php +++ b/modules/backend/behaviors/RelationController.php @@ -285,6 +285,17 @@ class RelationController extends ControllerBehavior } } + /** + * Refreshes the relation container only, useful for returning in custom AJAX requests. + * @param string $field Relation definition. + * @return array The relation element selector as the key, and the relation view contents are the value. + */ + public function relationRefresh($field) + { + $field = $this->validateField($field); + return ['#'.$this->relationGetId('view') => $this->relationRenderView()]; + } + /** * Renders the toolbar only. * @param string $field The relationship field. @@ -567,7 +578,7 @@ class RelationController extends ControllerBehavior $config = $this->makeConfig($this->config->list); $config->model = $this->relationModel; $config->alias = $this->alias . 'ViewList'; - $config->recordOnClick = sprintf("$.oc.relationBehavior.clickManageListRecord('%s', :id)", $this->field); + $config->recordOnClick = sprintf("$.oc.relationBehavior.clickManageListRecord(:id, '%s', '%s')", $this->field, $this->relationGetSessionKey()); $config->showCheckboxes = true; if ($emptyMessage = $this->getConfig('emptyMessage')) @@ -611,7 +622,7 @@ class RelationController extends ControllerBehavior $config->model = $this->relationModel; $config->alias = $this->alias . 'ManagePivotList'; $config->showSetup = false; - $config->recordOnClick = sprintf("$.oc.relationBehavior.clickManagePivotListRecord('%s', :id)", $this->field); + $config->recordOnClick = sprintf("$.oc.relationBehavior.clickManagePivotListRecord(:id, '%s', '%s')", $this->field, $this->relationGetSessionKey()); $widget = $this->makeWidget('Backend\Widgets\Lists', $config); } /* diff --git a/modules/backend/behaviors/relationcontroller/assets/js/october.relation.js b/modules/backend/behaviors/relationcontroller/assets/js/october.relation.js index b39afc588..e6d768ddf 100644 --- a/modules/backend/behaviors/relationcontroller/assets/js/october.relation.js +++ b/modules/backend/behaviors/relationcontroller/assets/js/october.relation.js @@ -5,19 +5,20 @@ var RelationBehavior = function() { - this.clickManageListRecord = function(relationField, recordId) { + this.clickManageListRecord = function(recordId, relationField, sessionKey) { var newPopup = $('') newPopup.popup({ handler: 'onRelationManageForm', extraData: { + 'manage_id': recordId, '_relation_field': relationField, - 'manage_id': recordId + '_session_key': sessionKey } }) } - this.clickManagePivotListRecord = function(relationField, foreignId) { + this.clickManagePivotListRecord = function(foreignId, relationField, sessionKey) { var oldPopup = $('#relationManagePivotPopup'), newPopup = $('') @@ -26,8 +27,9 @@ newPopup.popup({ handler: 'onRelationManagePivotForm', extraData: { + 'foreign_id': foreignId, '_relation_field': relationField, - 'foreign_id': foreignId + '_session_key': sessionKey } }) } diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index e29f83f33..28f721349 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -171,9 +171,6 @@ return [ 'tooltips' => [ 'preview_website' => 'Preview the website' ], - 'settings' => [ - 'menu_label' => 'Settings', - ], 'mysettings' => [ 'menu_label' => 'My Settings', 'menu_description' => 'Settings relate to your administration account', diff --git a/modules/system/controllers/Settings.php b/modules/system/controllers/Settings.php index 9d2a68b15..75b7ac617 100644 --- a/modules/system/controllers/Settings.php +++ b/modules/system/controllers/Settings.php @@ -38,7 +38,7 @@ class Settings extends Controller public function index() { - $this->pageTitle = Lang::get('backend::lang.settings.menu_label'); + $this->pageTitle = Lang::get('system::lang.settings.menu_label'); $this->vars['items'] = SettingsManager::instance()->listItems('system'); $this->bodyClass = 'compact-container'; } @@ -61,6 +61,15 @@ class Settings extends Controller $item = $this->findSettingItem($author, $plugin, $code); $this->pageTitle = $item->label; + if ($item->context == 'mysettings') { + $this->vars['parentLink'] = Backend::url('system/settings/mysettings'); + $this->vars['parentLabel'] = Lang::get('backend::lang.mysettings.menu_label'); + } + else { + $this->vars['parentLink'] = Backend::url('system/settings'); + $this->vars['parentLabel'] = Lang::get('system::lang.settings.menu_label'); + } + $model = $this->createModel($item); $this->initWidgets($model); } diff --git a/modules/system/controllers/settings/update.htm b/modules/system/controllers/settings/update.htm index e6781bcef..4005714ff 100644 --- a/modules/system/controllers/settings/update.htm +++ b/modules/system/controllers/settings/update.htm @@ -1,6 +1,6 @@ @@ -33,5 +33,5 @@

fatalError) ?>

-

+

\ No newline at end of file