Index: trunk/kernel/units/configuration/configuration_event_handler.php
===================================================================
diff -u -r4625 -r4653
--- trunk/kernel/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 4625)
+++ trunk/kernel/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 4653)
@@ -2,7 +2,20 @@
class ConfigurationEventHandler extends InpDBEventHandler {
+
/**
+ * Changes permission section to one from REQUEST, not from config
+ *
+ * @param kEvent $event
+ */
+ function CheckPermission(&$event)
+ {
+ $event->setEventParam('PermSection', $this->Application->GetVar('section'));
+ return parent::CheckPermission($event);
+ }
+
+
+ /**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
@@ -101,36 +114,48 @@
function OnUpdate(&$event)
{
if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
+
+ // 1. save user selected module root category
+ $items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
+ $new_category_id = getArrayValue($items_info, 'ModuleRootCategory', 'VariableValue');
+ if ($new_category_id) {
+ unset($items_info['ModuleRootCategory']);
+ $this->Application->SetVar($event->getPrefixSpecial(true), $items_info);
+ }
+
parent::OnUpdate($event);
+
+ if ($event->status == erSUCCESS && $new_category_id !== false) {
+ // root category was submitted
+ $module = $this->Application->GetVar('module');
+ $root_category_id = $this->Application->findModule('Name', $module, 'RootCat');
+
+ if ($root_category_id != $new_category_id) {
+ // root category differs from one in db
+ $fields_hash = Array('RootCat' => $new_category_id);
+ $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Modules', 'Name = '.$this->Conn->qstr($module));
+ }
+ }
}
- $event->SetRedirectParam('opener', 's');
-
if ($this->Application->GetVar('errormsgs')) {
// because we have list out there, and this is item
$this->Application->removeObject($event->getPrefixSpecial());
$event->redirect = false;
}
}
-
- function OnCancel(&$event)
- {
- parent::OnCancel($event);
- $event->SetRedirectParam('opener', 's');
- }
/**
* Enter description here...
*
* @param kEvent $event
*/
- function OnChangeCountry(&$event)
+ /*function OnChangeCountry(&$event)
{
$event->setPseudoClass('_List');
$object = &$event->getObject( Array('per_page'=>-1) );
$object->Query();
- //$object->SetDBField('');
- $array_records = &$object->Records;
+ $array_records =& $object->Records;
foreach($array_records as $i=>$record){
if ($record['VariableName']=='Comm_Country'){
$values = $this->Application->GetVar('conf');
@@ -140,6 +165,28 @@
$event->redirect_params = Array('opener' => 's', 'pass'=>'all,conf'); //stay!
$event->redirect = false;
+ }*/
+
+ /**
+ * Allows to process module root category selection
+ *
+ * @param kEvent $event
+ */
+ function OnSelectItems(&$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $items_info = $this->Application->GetVar('c');
+ list($resource_id, $field_values) = each($items_info);
+
+ if ($resource_id) {
+ $sql = 'SELECT CategoryId
+ FROM '.TABLE_PREFIX.'Category
+ WHERE ResourceId = '.$resource_id;
+ $category_id = $this->Conn->GetOne($sql);
+ $this->Application->StoreVar('ModuleRootCategory', $category_id);
+ }
+ $this->finalizePopup($event);
}
}
Index: trunk/core/units/configuration/configuration_event_handler.php
===================================================================
diff -u -r4625 -r4653
--- trunk/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 4625)
+++ trunk/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 4653)
@@ -2,7 +2,20 @@
class ConfigurationEventHandler extends InpDBEventHandler {
+
/**
+ * Changes permission section to one from REQUEST, not from config
+ *
+ * @param kEvent $event
+ */
+ function CheckPermission(&$event)
+ {
+ $event->setEventParam('PermSection', $this->Application->GetVar('section'));
+ return parent::CheckPermission($event);
+ }
+
+
+ /**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
@@ -101,36 +114,48 @@
function OnUpdate(&$event)
{
if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
+
+ // 1. save user selected module root category
+ $items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
+ $new_category_id = getArrayValue($items_info, 'ModuleRootCategory', 'VariableValue');
+ if ($new_category_id) {
+ unset($items_info['ModuleRootCategory']);
+ $this->Application->SetVar($event->getPrefixSpecial(true), $items_info);
+ }
+
parent::OnUpdate($event);
+
+ if ($event->status == erSUCCESS && $new_category_id !== false) {
+ // root category was submitted
+ $module = $this->Application->GetVar('module');
+ $root_category_id = $this->Application->findModule('Name', $module, 'RootCat');
+
+ if ($root_category_id != $new_category_id) {
+ // root category differs from one in db
+ $fields_hash = Array('RootCat' => $new_category_id);
+ $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Modules', 'Name = '.$this->Conn->qstr($module));
+ }
+ }
}
- $event->SetRedirectParam('opener', 's');
-
if ($this->Application->GetVar('errormsgs')) {
// because we have list out there, and this is item
$this->Application->removeObject($event->getPrefixSpecial());
$event->redirect = false;
}
}
-
- function OnCancel(&$event)
- {
- parent::OnCancel($event);
- $event->SetRedirectParam('opener', 's');
- }
/**
* Enter description here...
*
* @param kEvent $event
*/
- function OnChangeCountry(&$event)
+ /*function OnChangeCountry(&$event)
{
$event->setPseudoClass('_List');
$object = &$event->getObject( Array('per_page'=>-1) );
$object->Query();
- //$object->SetDBField('');
- $array_records = &$object->Records;
+ $array_records =& $object->Records;
foreach($array_records as $i=>$record){
if ($record['VariableName']=='Comm_Country'){
$values = $this->Application->GetVar('conf');
@@ -140,6 +165,28 @@
$event->redirect_params = Array('opener' => 's', 'pass'=>'all,conf'); //stay!
$event->redirect = false;
+ }*/
+
+ /**
+ * Allows to process module root category selection
+ *
+ * @param kEvent $event
+ */
+ function OnSelectItems(&$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $items_info = $this->Application->GetVar('c');
+ list($resource_id, $field_values) = each($items_info);
+
+ if ($resource_id) {
+ $sql = 'SELECT CategoryId
+ FROM '.TABLE_PREFIX.'Category
+ WHERE ResourceId = '.$resource_id;
+ $category_id = $this->Conn->GetOne($sql);
+ $this->Application->StoreVar('ModuleRootCategory', $category_id);
+ }
+ $this->finalizePopup($event);
}
}
Index: trunk/core/kernel/application.php
===================================================================
diff -u -r4645 -r4653
--- trunk/core/kernel/application.php (.../application.php) (revision 4645)
+++ trunk/core/kernel/application.php (.../application.php) (revision 4653)
@@ -537,6 +537,9 @@
$this->Debugger->appendMemoryUsage('Application before Run:');
}
+ $this->LinkVar('module');
+ $this->LinkVar('section');
+
if (!$this->RequestProcessed) $this->ProcessRequest();
$this->InitParser();
Index: trunk/kernel/admin_templates/incs/header.tpl
===================================================================
diff -u -r4490 -r4653
--- trunk/kernel/admin_templates/incs/header.tpl (.../header.tpl) (revision 4490)
+++ trunk/kernel/admin_templates/incs/header.tpl (.../header.tpl) (revision 4653)
@@ -48,6 +48,4 @@
-
-
-
\ No newline at end of file
+
\ No newline at end of file
Index: trunk/kernel/units/configuration/configuration_tag_processor.php
===================================================================
diff -u -r4446 -r4653
--- trunk/kernel/units/configuration/configuration_tag_processor.php (.../configuration_tag_processor.php) (revision 4446)
+++ trunk/kernel/units/configuration/configuration_tag_processor.php (.../configuration_tag_processor.php) (revision 4653)
@@ -58,7 +58,8 @@
$prev_heading = $list->GetDBField('heading');
$list->GoNext();
}
-
+
+ $this->Application->RemoveVar('ModuleRootCategory');
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
return $o;
}
@@ -127,6 +128,68 @@
return $msg;
}
+
+ /**
+ * Allows to show category path of selected module
+ *
+ * @param Array $params
+ * @return string
+ */
+ function CategoryPath($params)
+ {
+ if (!isset($params['cat_id'])) {
+ $params['cat_id'] = $this->ModuleRootCategory( Array() );
+ }
+
+ $block_params['current'] = 1;
+ $block_params['separator'] = $params['separator'];
+ if ($params['cat_id'] == 0) {
+ $block_params['name'] = $params['rootcatblock'];
+ return $this->Application->ParseBlock($block_params);
+ }
+ else {
+ $cat_object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List' );
+ $sql = 'SELECT CategoryId, ParentId, Name FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$params['cat_id'];
+ $res = $this->Conn->GetRow($sql);
+ if ($res === false) {
+ // in case if category is deleted
+ return '';
+ }
+ $block_params['name'] = $params['block'];
+ $block_params['cat_name'] = $res['Name'];
+ $block_params['separator'] = $params['separator'];
+ $block_params['cat_id'] = $res['CategoryId'];
+ $next_params['separator'] = $params['separator'];
+ $next_params['rootcatblock'] = $params['rootcatblock'];
+ $next_params['block'] = $params['block'];
+ $next_params['cat_id'] = $res['ParentId'];
+ return $this->CategoryPath($next_params).$this->Application->ParseBlock($block_params);
+ }
+ }
+
+ /**
+ * Shows edit warning in case if module root category changed but not saved
+ *
+ * @param Array $params
+ * @return string
+ */
+ function SaveWarning($params)
+ {
+ $temp_category_id = $this->Application->RecallVar('ModuleRootCategory');
+ if ($temp_category_id !== false) {
+ return $this->Application->ParseBlock($params);
+ }
+ return '';
+ }
+
+ function ModuleRootCategory($params)
+ {
+ $category_id = $this->Application->RecallVar('ModuleRootCategory');
+ if ($category_id === false) {
+ $category_id = $this->Application->findModule('Name', $this->Application->GetVar('module'), 'RootCat');
+ }
+ return $category_id;
+ }
}
?>
\ No newline at end of file
Fisheye: Tag 4653 refers to a dead (removed) revision in file `trunk/kernel/units/config_general/config_general_event_handler.php'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 4653 refers to a dead (removed) revision in file `trunk/kernel/units/config_general/config_general_config.php'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 4653 refers to a dead (removed) revision in file `trunk/kernel/units/config_general/config_general_tag_processor.php'.
Fisheye: No comparison available. Pass `N' to diff?
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r4640 -r4653
--- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 4640)
+++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 4653)
@@ -80,6 +80,7 @@
$permissions = Array(
'OnNew' => Array('self' => 'add', 'subitem' => 'add'),
'OnCreate' => Array('self' => 'add', 'subitem' => 'add|edit'),
+ 'OnUpdate' => Array('self' => 'edit', 'subitem' => 'add|edit'),
'OnDelete' => Array('self' => 'delete', 'subitem' => 'edit|add'),
'OnMassDelete' => Array('self' => 'delete', 'subitem' => 'edit|add'),
'OnSelectItems' => Array('self' => 'add|edit', 'subitem' => 'add|edit'),
Index: trunk/core/units/configuration/configuration_config.php
===================================================================
diff -u -r4644 -r4653
--- trunk/core/units/configuration/configuration_config.php (.../configuration_config.php) (revision 4644)
+++ trunk/core/units/configuration/configuration_config.php (.../configuration_config.php) (revision 4653)
@@ -19,11 +19,11 @@
'TitlePresets' => Array(
'default' => Array('tag_params' => Array('conf' => Array('per_page' => -1))),
- 'config_list_general' => Array('prefixes' => Array('conf_List','confg_List'), 'format' => "!la_updating_config!"),
- 'config_list_output' => Array('prefixes' => Array('conf_List','confg_List'), 'format' => "!la_updating_config!"),
- 'config_list_contacts' => Array('prefixes' => Array('conf_List','confg_List'), 'format' => "!la_updating_config!"),
+ 'config_list_general' => Array('prefixes' => Array('conf_List'), 'format' => "!la_updating_config!"),
+ 'config_list_output' => Array('prefixes' => Array('conf_List'), 'format' => "!la_updating_config!"),
+ 'config_list_contacts' => Array('prefixes' => Array('conf_List'), 'format' => "!la_updating_config!"),
),
-
+
'TableName' => TABLE_PREFIX.'ConfigurationValues',
'ListSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'ConfigurationAdmin LEFT JOIN '.TABLE_PREFIX.'ConfigurationValues Using(VariableName) '),
Index: trunk/core/units/configuration/configuration_tag_processor.php
===================================================================
diff -u -r4446 -r4653
--- trunk/core/units/configuration/configuration_tag_processor.php (.../configuration_tag_processor.php) (revision 4446)
+++ trunk/core/units/configuration/configuration_tag_processor.php (.../configuration_tag_processor.php) (revision 4653)
@@ -58,7 +58,8 @@
$prev_heading = $list->GetDBField('heading');
$list->GoNext();
}
-
+
+ $this->Application->RemoveVar('ModuleRootCategory');
$this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
return $o;
}
@@ -127,6 +128,68 @@
return $msg;
}
+
+ /**
+ * Allows to show category path of selected module
+ *
+ * @param Array $params
+ * @return string
+ */
+ function CategoryPath($params)
+ {
+ if (!isset($params['cat_id'])) {
+ $params['cat_id'] = $this->ModuleRootCategory( Array() );
+ }
+
+ $block_params['current'] = 1;
+ $block_params['separator'] = $params['separator'];
+ if ($params['cat_id'] == 0) {
+ $block_params['name'] = $params['rootcatblock'];
+ return $this->Application->ParseBlock($block_params);
+ }
+ else {
+ $cat_object =& $this->Application->recallObject( $this->getPrefixSpecial(), $this->Prefix.'_List' );
+ $sql = 'SELECT CategoryId, ParentId, Name FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$params['cat_id'];
+ $res = $this->Conn->GetRow($sql);
+ if ($res === false) {
+ // in case if category is deleted
+ return '';
+ }
+ $block_params['name'] = $params['block'];
+ $block_params['cat_name'] = $res['Name'];
+ $block_params['separator'] = $params['separator'];
+ $block_params['cat_id'] = $res['CategoryId'];
+ $next_params['separator'] = $params['separator'];
+ $next_params['rootcatblock'] = $params['rootcatblock'];
+ $next_params['block'] = $params['block'];
+ $next_params['cat_id'] = $res['ParentId'];
+ return $this->CategoryPath($next_params).$this->Application->ParseBlock($block_params);
+ }
+ }
+
+ /**
+ * Shows edit warning in case if module root category changed but not saved
+ *
+ * @param Array $params
+ * @return string
+ */
+ function SaveWarning($params)
+ {
+ $temp_category_id = $this->Application->RecallVar('ModuleRootCategory');
+ if ($temp_category_id !== false) {
+ return $this->Application->ParseBlock($params);
+ }
+ return '';
+ }
+
+ function ModuleRootCategory($params)
+ {
+ $category_id = $this->Application->RecallVar('ModuleRootCategory');
+ if ($category_id === false) {
+ $category_id = $this->Application->findModule('Name', $this->Application->GetVar('module'), 'RootCat');
+ }
+ return $category_id;
+ }
}
?>
\ No newline at end of file
Index: trunk/core/kernel/utility/event.php
===================================================================
diff -u -r4636 -r4653
--- trunk/core/kernel/utility/event.php (.../event.php) (revision 4636)
+++ trunk/core/kernel/utility/event.php (.../event.php) (revision 4653)
@@ -282,6 +282,11 @@
*/
function getSection()
{
+ $perm_section = $this->getEventParam('PermSection');
+ if ($perm_section) {
+ return $perm_section;
+ }
+
$main_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
$section = $this->Application->getUnitOption($main_prefix, 'PermSection');
Index: trunk/kernel/units/admin/admin_tag_processor.php
===================================================================
diff -u -r4610 -r4653
--- trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4610)
+++ trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4653)
@@ -47,18 +47,6 @@
}
/**
- * Save module & section once passed in REQUEST for future use
- *
- * @param Array $params
- */
- function StoreSystemVars($params)
- {
- // save theese variables to session, because they are useful for most configuration templates
- $this->Application->LinkVar('module');
- $this->Application->LinkVar('section');
- }
-
- /**
* Saves all required data for popups to return to it's parent window
*
* @param Array $params
Index: trunk/kernel/units/configuration/configuration_config.php
===================================================================
diff -u -r4644 -r4653
--- trunk/kernel/units/configuration/configuration_config.php (.../configuration_config.php) (revision 4644)
+++ trunk/kernel/units/configuration/configuration_config.php (.../configuration_config.php) (revision 4653)
@@ -19,11 +19,11 @@
'TitlePresets' => Array(
'default' => Array('tag_params' => Array('conf' => Array('per_page' => -1))),
- 'config_list_general' => Array('prefixes' => Array('conf_List','confg_List'), 'format' => "!la_updating_config!"),
- 'config_list_output' => Array('prefixes' => Array('conf_List','confg_List'), 'format' => "!la_updating_config!"),
- 'config_list_contacts' => Array('prefixes' => Array('conf_List','confg_List'), 'format' => "!la_updating_config!"),
+ 'config_list_general' => Array('prefixes' => Array('conf_List'), 'format' => "!la_updating_config!"),
+ 'config_list_output' => Array('prefixes' => Array('conf_List'), 'format' => "!la_updating_config!"),
+ 'config_list_contacts' => Array('prefixes' => Array('conf_List'), 'format' => "!la_updating_config!"),
),
-
+
'TableName' => TABLE_PREFIX.'ConfigurationValues',
'ListSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'ConfigurationAdmin LEFT JOIN '.TABLE_PREFIX.'ConfigurationValues Using(VariableName) '),
Index: trunk/core/units/admin/admin_tag_processor.php
===================================================================
diff -u -r4610 -r4653
--- trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4610)
+++ trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4653)
@@ -47,18 +47,6 @@
}
/**
- * Save module & section once passed in REQUEST for future use
- *
- * @param Array $params
- */
- function StoreSystemVars($params)
- {
- // save theese variables to session, because they are useful for most configuration templates
- $this->Application->LinkVar('module');
- $this->Application->LinkVar('section');
- }
-
- /**
* Saves all required data for popups to return to it's parent window
*
* @param Array $params