Page MenuHomeIn-Portal Phabricator

D486.diff
No OneTemporary

File Metadata

Created
Fri, Jul 18, 6:45 PM

D486.diff

Index: core/units/configuration/configuration_event_handler.php
===================================================================
--- core/units/configuration/configuration_event_handler.php
+++ core/units/configuration/configuration_event_handler.php
@@ -373,7 +373,17 @@
return;
}
- $items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
+ /*
+ * This is Linked Var coming from Session. The same
+ * section variable is used also during permission
+ * checking.
+ */
+ $section = $this->Application->GetVar('section');
+
+ $items_info = $this->filterBySection(
+ $this->Application->GetVar($event->getPrefixSpecial(true)),
+ $section
+ );
// 1. save user selected module root category
$new_category_id = getArrayValue($items_info, 'ModuleRootCategory', 'VariableValue');
@@ -450,7 +460,42 @@
// keeps module and section in REQUEST to ensure, that last admin template will work
$event->SetRedirectParam('module', $this->Application->GetVar('module'));
- $event->SetRedirectParam('section', $this->Application->GetVar('section'));
+ $event->SetRedirectParam('section', $section);
+ }
+
+ /**
+ * Filters system settings by section.
+ *
+ * @param array $items_info Items info.
+ * @param string $section Section.
+ *
+ * @return array
+ * @throws RuntimeException When given section doesn't have any settings.
+ */
+ protected function filterBySection(array $items_info, $section)
+ {
+ $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+
+ $sql = 'SELECT ' . $id_field . '
+ FROM ' . $table_name . '
+ WHERE `Section` = ' . $this->Conn->qstr($section);
+ $section_system_setting_ids = $this->Conn->GetCol($sql);
+
+ if ( !$section_system_setting_ids ) {
+ throw new RuntimeException('The "' . $section . '" section does not have any settings.');
+ }
+
+ $ret = array();
+ $section_system_setting_ids[] = 'ModuleRootCategory';
+
+ foreach ( $section_system_setting_ids as $system_setting_id ) {
+ if ( array_key_exists($system_setting_id, $items_info) ) {
+ $ret[$system_setting_id] = $items_info[$system_setting_id];
+ }
+ }
+
+ return $ret;
}
/**

Event Timeline