Index: branches/RC/core/install/upgrades.php =================================================================== diff -u -N -r11610 -r11623 --- branches/RC/core/install/upgrades.php (.../upgrades.php) (revision 11610) +++ branches/RC/core/install/upgrades.php (.../upgrades.php) (revision 11623) @@ -677,15 +677,79 @@ if ($mode == 'before') { $this->_removeDuplicatePhrases(); // because In-Commerce & In-Link share some phrases with Proj-CMS $this->_createProjCMSTables(); + $this->_addMissingConfigurationVariables(); } if ($mode == 'after') { $this->_fixSkinColors(); $this->_restructureCatalog(); + +// $this->_sortConfigurationVariables('In-Portal', 'in-portal:configure_general'); +// $this->_sortConfigurationVariables('In-Portal', 'in-portal:configure_advanced'); } } + function _sortConfigurationVariables($module, $section) + { + $sql = 'SELECT ca.heading, cv.VariableName + FROM ' . TABLE_PREFIX . 'ConfigurationAdmin ca + LEFT JOIN ' . TABLE_PREFIX . 'ConfigurationValues cv USING(VariableName) + WHERE (cv.ModuleOwner = ' . $this->Conn->qstr($module) . ') AND (cv.Section = ' . $this->Conn->qstr($section) . ') + ORDER BY ca.DisplayOrder asc, ca.GroupDisplayOrder asc'; + $variables = $this->Conn->GetCol($sql, 'VariableName'); + + if (!$variables) { + return ; + } + + $variables = $this->_groupRecords($variables); + + $group_number = 0; + $variable_order = 1; + + $prev_heading = ''; + + foreach ($variables as $variable_name => $variable_heading) { + if ($prev_heading != $variable_heading) { + $group_number++; + $variable_order = 1; + } + + $sql = 'UPDATE ' . TABLE_PREFIX . 'ConfigurationAdmin + SET DisplayOrder = ' . $this->Conn->qstr($group_number * 10 + $variable_order / 100) . ' + WHERE VariableName = ' . $this->Conn->qstr($variable_name); + $this->Conn->Query($sql); + + $variable_order++; + $prev_heading = $variable_heading; + } + } + /** + * Group list records by header, saves internal order in group + * + * @param Array $records + * @param string $heading_field + */ + function _groupRecords($variables) + { + $sorted = Array(); + + foreach ($variables as $variable_name => $variable_heading) { + $sorted[$variable_heading][] = $variable_name; + } + + $variables = Array(); + foreach ($sorted as $heading => $heading_records) { + foreach ($heading_records as $variable_name) { + $variables[$variable_name] = $heading; + } + } + + return $variables; + } + + /** * Returns module root category * * @param string $module_name @@ -930,6 +994,12 @@ $this->Conn->Query($sql); } } + else { + $this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:forms.view', 11, 1, 1, 0)"); + $this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:forms.add', 11, 1, 1, 0)"); + $this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:forms.edit', 11, 1, 1, 0)"); + $this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:forms.delete', 11, 1, 1, 0)"); + } // 4. process "FormSubmissions" table if ($this->Conn->TableFound(TABLE_PREFIX . 'FormSubmissions')) { @@ -940,6 +1010,9 @@ $this->Conn->Query($sql); } } + else { + $this->Conn->Query("INSERT INTO " . TABLE_PREFIX . "Permissions VALUES (DEFAULT, 'in-portal:submissions.view', 11, 1, 1, 0)"); + } // 5. add missing event $sql = 'SELECT EventId @@ -948,7 +1021,7 @@ $event_id = $this->Conn->GetOne($sql); if (!$event_id) { - $sql = "INSERT INTO " . TABLE_PREFIX . "Events VALUES (DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, 'Core:Category', 'la_CMS_FormSubmitted', 1)"; + $sql = "INSERT INTO " . TABLE_PREFIX . "Events VALUES (DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, 'Core:Category', 'la_event_FormSubmitted', 1)"; $this->Conn->Query($sql); } @@ -958,22 +1031,58 @@ $event_id = $this->Conn->GetOne($sql); if (!$event_id) { - $sql = "INSERT INTO " . TABLE_PREFIX . "Events VALUES (DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, 'Core:Category', 'la_CMS_FormSubmitted', 0)"; + $sql = "INSERT INTO " . TABLE_PREFIX . "Events VALUES (DEFAULT, 'FORM.SUBMITTED', NULL, 1, 0, 'Core:Category', 'la_event_FormSubmitted', 0)"; $this->Conn->Query($sql); } + } - // 6. add missing variable - $sql = 'SELECT VariableId - FROM ' . TABLE_PREFIX . 'ConfigurationValues - WHERE VariableName = "cms_DefaultDesign"'; - $variable_id = $this->Conn->GetOne($sql); + function _addMissingConfigurationVariables() + { + $variables = Array ( + 'cms_DefaultDesign' => Array ( + "INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('cms_DefaultDesign', 'la_Text_General', 'la_prompt_DefaultDesignTemplate', 'text', NULL, NULL, 10.15, 0, 0)", + "INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'cms_DefaultDesign', '/platform/designs/general', 'In-Portal', 'in-portal:configure_categories')", + ), - if (!$variable_id) { - $sql = "INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('cms_DefaultDesign', 'la_Text_General', 'la_prompt_DefaultDesignTemplate', 'text', NULL, NULL, 10.29, 0, 0)"; - $this->Conn->Query($sql); + 'Require_AdminSSL' => Array ( + "INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('Require_AdminSSL', 'la_Text_Website', 'la_config_RequireSSLAdmin', 'checkbox', '', '', 10.105, 0, 1)", + "INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'Require_AdminSSL', '', 'In-Portal', 'in-portal:configure_advanced')", + ), - $sql = "INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'cms_DefaultDesign', '/platform/designs/general', 'In-Portal', 'in-portal:configure_categories')"; - $this->Conn->Query($sql); + 'UsePopups' => Array ( + "INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('UsePopups', 'la_Text_Website', 'la_config_UsePopups', 'radio', '', '1=la_Yes,0=la_No', 10.221, 0, 0)", + "INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'UsePopups', '1', 'In-Portal', 'in-portal:configure_advanced')", + ), + + 'UseDoubleSorting' => Array ( + "INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('UseDoubleSorting', 'la_Text_Website', 'la_config_UseDoubleSorting', 'radio', '', '1=la_Yes,0=la_No', 10.222, 0, 0)", + "INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'UseDoubleSorting', '0', 'In-Portal', 'in-portal:configure_advanced')", + ), + + 'MenuFrameWidth' => Array ( + "INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('MenuFrameWidth', 'la_title_General', 'la_prompt_MenuFrameWidth', 'text', NULL, NULL, 10.31, 0, 0)", + "INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'MenuFrameWidth', 200, 'In-Portal', 'in-portal:configure_advanced')", + ), + + 'DefaultSettingsUserId' => Array ( + "INSERT INTO " . TABLE_PREFIX . "ConfigurationAdmin VALUES ('DefaultSettingsUserId', 'la_title_General', 'la_prompt_DefaultUserId', 'text', NULL, NULL, '10.06', '0', '0')", + "INSERT INTO " . TABLE_PREFIX . "ConfigurationValues VALUES (DEFAULT, 'DefaultSettingsUserId', -1, 'In-Portal:Users', 'in-portal:configure_users')", + ), + ); + + foreach ($variables as $variable_name => $variable_sqls) { + $sql = 'SELECT VariableId + FROM ' . TABLE_PREFIX . 'ConfigurationValues + WHERE VariableName = ' . $this->Conn->qstr($variable_name); + $variable_id = $this->Conn->GetOne($sql); + + if ($variable_id) { + continue; + } + + foreach ($variable_sqls as $variable_sql) { + $this->Conn->Query($variable_sql); + } } }