Index: branches/5.2.x/core/admin_templates/incs/config_blocks.tpl
===================================================================
diff -u -N -r15437 -r15471
--- branches/5.2.x/core/admin_templates/incs/config_blocks.tpl (.../config_blocks.tpl) (revision 15437)
+++ branches/5.2.x/core/admin_templates/incs/config_blocks.tpl (.../config_blocks.tpl) (revision 15471)
@@ -61,10 +61,10 @@
- *:
+ *:
- []
+ [] [', this.href);">]
|
Index: branches/5.2.x/core/admin_templates/config/config_edit.tpl
===================================================================
diff -u -N
--- branches/5.2.x/core/admin_templates/config/config_edit.tpl (revision 0)
+++ branches/5.2.x/core/admin_templates/config/config_edit.tpl (revision 15471)
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: branches/5.2.x/core/install/install_data.sql
===================================================================
diff -u -N -r15458 -r15471
--- branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 15458)
+++ branches/5.2.x/core/install/install_data.sql (.../install_data.sql) (revision 15471)
@@ -532,6 +532,7 @@
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:website_setting_folder.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:user_setting_folder.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_advanced.view', 11, 1, 1, 0);
+INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_advanced.add', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_advanced.edit', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:user_list.view', 11, 1, 1, 0);
@@ -600,6 +601,7 @@
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:advanced_view.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:reviews.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_categories.view', 11, 1, 1, 0);
+INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_categories.add', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_categories.edit', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configuration_search.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configuration_search.edit', 11, 1, 1, 0);
@@ -618,6 +620,7 @@
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:user_groups.advanced:send_email', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:user_groups.advanced:manage_permissions', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_users.view', 11, 1, 1, 0);
+INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_users.add', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_users.edit', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:user_custom.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:user_custom.add', 11, 1, 1, 0);
@@ -643,6 +646,7 @@
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:spam_reports.delete', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_general.view', 11, 1, 1, 0);
+INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_general.add', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:configure_general.edit', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:modules.view', 11, 1, 1, 0);
INSERT INTO Permissions VALUES (DEFAULT, 'in-portal:mod_status.view', 11, 1, 1, 0);
Index: branches/5.2.x/core/admin_templates/config/config_general.tpl
===================================================================
diff -u -N -r15267 -r15471
--- branches/5.2.x/core/admin_templates/config/config_general.tpl (.../config_general.tpl) (revision 15267)
+++ branches/5.2.x/core/admin_templates/config/config_general.tpl (.../config_general.tpl) (revision 15471)
@@ -86,6 +86,20 @@
)
);
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton(
+ new ToolBarButton(
+ 'new_item',
+ '::',
+ function() {
+ std_precreate_item('conf', 'config/config_edit');
+ }
+ )
+ );
+
+
a_toolbar.Render();
Index: branches/5.2.x/core/units/configuration/configuration_tag_processor.php
===================================================================
diff -u -N -r15274 -r15471
--- branches/5.2.x/core/units/configuration/configuration_tag_processor.php (.../configuration_tag_processor.php) (revision 15274)
+++ branches/5.2.x/core/units/configuration/configuration_tag_processor.php (.../configuration_tag_processor.php) (revision 15471)
@@ -1,6 +1,6 @@
getObject($params);;
- /* @var $object kDBList */
+ $object = $this->getObject($params);
+ /* @var $object kDBItem */
- $field_options = $object->GetDBField('Validation');
- $field_options = $field_options ? unserialize($field_options) : Array ();
+ $field = $params['field'];
+ $field_options = $object->GetFieldOptions($field);
+ if ( $field == 'VariableValue' ) {
+ $custom_options = $object->GetDBField('Validation');
+
+ if ( $custom_options ) {
+ $field_options = array_merge($field_options, unserialize($custom_options));
+ }
+ }
+
return isset($field_options['required']) && $field_options['required'];
}
@@ -171,8 +179,11 @@
$object = $this->getObject($params);
/* @var $object kDBList */
- $field = $object->GetDBField($params['id_field']);
+ if ( !($object instanceof kDBList) ) {
+ return parent::Error($params);
+ }
+ $field = $object->GetDBField($params['id_field']);
$errors = $this->Application->GetVar('errors_' . $this->getPrefixSpecial(), Array ());
return array_key_exists($field, $errors) ? $errors[$field] : '';
@@ -261,4 +272,26 @@
return $cached_sections[$var_name];
}
+
+ /**
+ * Returns system setting editing link
+ *
+ * @param Array $params
+ * @return string
+ * @access protected
+ */
+ protected function ItemEditLink($params)
+ {
+ $object = $this->getObject($params);
+ /* @var $object kDBItem */
+
+ $params['m_opener'] = 'd';
+ $params[$object->Prefix . '_mode'] = 't';
+ $params[$object->Prefix . '_event'] = 'OnEdit';
+ $params[$object->Prefix . '_id'] = $object->GetID();
+ $params['pass'] = 'all,' . $object->Prefix;
+
+ return $this->Application->ProcessParsedTag('m', 'Link', $params);
+
+ }
}
\ No newline at end of file
Index: branches/5.2.x/core/admin_templates/config/config_universal.tpl
===================================================================
diff -u -N -r14965 -r15471
--- branches/5.2.x/core/admin_templates/config/config_universal.tpl (.../config_universal.tpl) (revision 14965)
+++ branches/5.2.x/core/admin_templates/config/config_universal.tpl (.../config_universal.tpl) (revision 15471)
@@ -87,6 +87,20 @@
)
);
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+
+ a_toolbar.AddButton(
+ new ToolBarButton(
+ 'new_item',
+ '::',
+ function() {
+ std_precreate_item('conf', 'config/config_edit');
+ }
+ )
+ );
+
+
a_toolbar.Render();
Index: branches/5.2.x/core/units/configuration/configuration.php
===================================================================
diff -u -N -r14628 -r15471
--- branches/5.2.x/core/units/configuration/configuration.php (.../configuration.php) (revision 14628)
+++ branches/5.2.x/core/units/configuration/configuration.php (.../configuration.php) (revision 15471)
@@ -1,6 +1,6 @@
don't overwrite it
- return false;
- }
-
- $list_errors = $this->Application->GetVar('errors_' . $this->getPrefixSpecial(), Array ());
- $list_errors[ $this->GetDBField('VariableName') ] = $this->GetErrorMsg($field);
- $this->Application->SetVar('errors_' . $this->getPrefixSpecial(), $list_errors);
-
- return true;
- }
}
\ No newline at end of file
Index: branches/5.2.x/core/units/users/users_config.php
===================================================================
diff -u -N -r15433 -r15471
--- branches/5.2.x/core/units/users/users_config.php (.../users_config.php) (revision 15433)
+++ branches/5.2.x/core/units/users/users_config.php (.../users_config.php) (revision 15471)
@@ -1,6 +1,6 @@
'conf_users_general',
'label' => 'la_tab_ConfigSettings',
'url' => Array ('t' => 'config/config_universal', 'module' => 'In-Portal:Users', 'pass_section' => true, 'pass' => 'm'),
- 'permissions' => Array ('view', 'edit'),
+ 'permissions' => Array ('view', 'add', 'edit'),
'priority' => 1,
'type' => stTREE,
),
Index: branches/5.2.x/core/install/upgrades.sql
===================================================================
diff -u -N -r15461 -r15471
--- branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 15461)
+++ branches/5.2.x/core/install/upgrades.sql (.../upgrades.sql) (revision 15471)
@@ -2793,3 +2793,8 @@
ALTER TABLE EmailQueue CHANGE LogData LogData LONGTEXT NULL DEFAULT NULL;
DELETE FROM UserPersistentSessionData WHERE VariableName = 'mailing-list[Default]columns_.';
+
+INSERT INTO Permissions VALUES(DEFAULT, 'in-portal:configure_general.add', 11, 1, 1, 0);
+INSERT INTO Permissions VALUES(DEFAULT, 'in-portal:configure_advanced.add', 11, 1, 1, 0);
+INSERT INTO Permissions VALUES(DEFAULT, 'in-portal:configure_categories.add', 11, 1, 1, 0);
+INSERT INTO Permissions VALUES(DEFAULT, 'in-portal:configure_users.add', 11, 1, 1, 0);
Index: branches/5.2.x/core/units/categories/categories_config.php
===================================================================
diff -u -N -r15390 -r15471
--- branches/5.2.x/core/units/categories/categories_config.php (.../categories_config.php) (revision 15390)
+++ branches/5.2.x/core/units/categories/categories_config.php (.../categories_config.php) (revision 15471)
@@ -1,6 +1,6 @@
'conf_output',
'label' => 'la_tab_ConfigOutput',
'url' => Array ('t' => 'config/config_universal', 'pass_section' => true, 'pass' => 'm'),
- 'permissions' => Array ('view', 'edit'),
+ 'permissions' => Array ('view', 'add', 'edit'),
'priority' => 11.1,
'type' => stTREE,
),
Index: branches/5.2.x/core/units/configuration/configuration_validator.php
===================================================================
diff -u -N
--- branches/5.2.x/core/units/configuration/configuration_validator.php (revision 0)
+++ branches/5.2.x/core/units/configuration/configuration_validator.php (revision 15471)
@@ -0,0 +1,48 @@
+ don't overwrite it
+ return false;
+ }
+
+ if ( $field == 'VariableValue' ) {
+ $item_prefix = $this->dataSource->getPrefixSpecial();
+
+ $list_errors = $this->Application->GetVar('errors_' . $item_prefix, Array ());
+ $list_errors[$this->dataSource->GetDBField('VariableName')] = $this->GetErrorMsg($field);
+ $this->Application->SetVar('errors_' . $item_prefix, $list_errors);
+ }
+
+ return true;
+ }
+}
Index: branches/5.2.x/core/units/sections/sections_config.php
===================================================================
diff -u -N -r14585 -r15471
--- branches/5.2.x/core/units/sections/sections_config.php (.../sections_config.php) (revision 14585)
+++ branches/5.2.x/core/units/sections/sections_config.php (.../sections_config.php) (revision 15471)
@@ -1,6 +1,6 @@
'conf_general',
'label' => 'la_tab_General',
'url' => Array ('t' => 'config/config_universal', 'pass_section' => true, 'pass' => 'm'),
- 'permissions' => Array ('view', 'edit'),
+ 'permissions' => Array ('view', 'add', 'edit'),
'priority' => 1,
'type' => stTREE,
),
@@ -177,7 +177,7 @@
'icon' => 'conf_advanced',
'label' => 'la_title_Advanced',
'url' => Array ('t' => 'config/config_universal', 'pass_section' => true, 'pass' => 'm'),
- 'permissions' => Array ('view', 'edit'),
+ 'permissions' => Array ('view', 'add', 'edit'),
'priority' => 2,
'type' => stTREE,
),
Index: branches/5.2.x/core/units/configuration/configuration_config.php
===================================================================
diff -u -N -r15012 -r15471
--- branches/5.2.x/core/units/configuration/configuration_config.php (.../configuration_config.php) (revision 15012)
+++ branches/5.2.x/core/units/configuration/configuration_config.php (.../configuration_config.php) (revision 15471)
@@ -1,6 +1,6 @@
Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
'EventHandlerClass' => Array ('class' => 'ConfigurationEventHandler', 'file' => 'configuration_event_handler.php', 'build_event' => 'OnBuild'),
'TagProcessorClass' => Array ('class' => 'ConfigurationTagProcessor', 'file' => 'configuration_tag_processor.php', 'build_event' => 'OnBuild'),
+ 'ValidatorClass' => 'ConfigurationValidator',
'AutoLoad' => true,
+ 'RegisterClasses' => Array (
+ Array ('pseudo' => 'ConfigurationValidator', 'class' => 'ConfigurationValidator', 'file' => 'configuration_validator.php', 'build_event' => ''),
+ ),
+
'QueryString' => Array (
1 => 'id',
2 => 'Page',
@@ -45,6 +50,12 @@
'config_list_users' => Array ('prefixes' => Array ('conf_List'), 'format' => "!la_updating_config!"),
'section_label' => Array ('prefixes' => Array ('conf_List'), 'format' => "#section_label#"),
+
+ 'config_edit' => Array (
+ 'new_status_labels' => Array ('conf' => '!la_title_AddingSystemSetting!'),
+ 'edit_status_labels' => Array ('conf' => '!la_title_EditingSystemSetting!'),
+ 'prefixes' => Array ('conf'), 'format' => "#conf_status# '#conf_titlefield#'",
+ ),
),
'TableName' => TABLE_PREFIX . 'SystemSettings',
@@ -61,17 +72,49 @@
'Fields' => Array (
'VariableId' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0),
- 'VariableName' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'VariableName' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kFormatter', 'regexp' => '/^[a-z0-9_]+$/i',
+ 'not_null' => 1, 'required' => 1, 'default' => ''
+ ),
'VariableValue' => Array ('type' => 'string', 'default' => NULL),
- 'ModuleOwner' => Array ('type' => 'string', 'default' => 'In-Portal'),
- 'Section' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
- 'Heading' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
- 'Prompt' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
- 'ElementType' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''),
+ 'ModuleOwner' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array (),
+ 'required' => 1, 'default' => 'In-Portal'
+ ),
+ 'Section' => Array (
+ 'type' => 'string',
+ 'error_msgs' => Array ('unknown_section' => '!la_error_UnknownSection!'),
+ 'not_null' => 1, 'required' => 1, 'default' => ''
+ ),
+ 'Heading' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kFormatter', 'regexp' => '/^la_section_[A-Z\d:_\-\.]+$/i',
+ 'not_null' => 1, 'required' => 1, 'default' => ''
+ ),
+ 'Prompt' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kFormatter', 'regexp' => '/^la_config_[A-Z\d:_\-\.]+$/i',
+ 'not_null' => 1, 'required' => 1, 'default' => ''
+ ),
+ 'ElementType' => Array (
+ 'type' => 'string',
+ 'formatter' => 'kOptionsFormatter', 'options' => Array ('text' => 'la_type_text', 'select' => 'la_type_select', 'multiselect' => 'la_type_multiselect', 'radio' => 'la_type_radio', 'checkbox' => 'la_type_checkbox', 'password' => 'la_type_password', 'textarea' => 'la_type_textarea'), 'use_phrases' => 1,
+ 'not_null' => 1, 'required' => 1, 'default' => ''
+ ),
'Validation' => Array ('type' => 'string', 'default' => NULL),
'ValueList' => Array ('type' => 'string', 'default' => NULL),
- 'DisplayOrder' => Array ('type' => 'float', 'not_null' => 1, 'default' => 0),
- 'GroupDisplayOrder' => Array ('type' => 'float', 'not_null' => 1, 'default' => 0),
+ 'DisplayOrder' => Array (
+ 'type' => 'float',
+ 'unique' => Array ('ModuleOwner', 'Section', 'GroupDisplayOrder'),
+ 'not_null' => 1, 'required' => 1, 'default' => 0
+ ),
+ 'GroupDisplayOrder' => Array (
+ 'type' => 'float',
+ 'unique' => Array ('ModuleOwner', 'Section', 'DisplayOrder'),
+ 'not_null' => 1, 'required' => 1, 'default' => 0
+ ),
'Install' => Array ('type' => 'int', 'not_null' => 1, 'default' => 1),
'HintLabel' => Array ('type' => 'string', 'max_len' => 255, 'default' => NULL),
),
Index: branches/5.2.x/core/units/configuration/configuration_event_handler.php
===================================================================
diff -u -N -r15460 -r15471
--- branches/5.2.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 15460)
+++ branches/5.2.x/core/units/configuration/configuration_event_handler.php (.../configuration_event_handler.php) (revision 15471)
@@ -1,6 +1,6 @@
getObject();
+ /* @var $object kDBItem */
+
+ $object->SetDBField('Section', $this->Application->GetVar('section'));
+ $object->SetDBField('ModuleOwner', $this->Application->GetVar('module'));
+ }
+
+ /**
* Sets custom validation
*
* @param kEvent $event
@@ -113,66 +131,31 @@
}
/**
- * Performs validation of configuration variable value
+ * Performs custom validation
*
* @param kEvent $event
* @return void
* @access protected
*/
- protected function OnBeforeItemUpdate(kEvent $event)
+ protected function OnBeforeItemValidate(kEvent $event)
{
- parent::OnBeforeItemUpdate($event);
+ parent::OnBeforeItemValidate($event);
$object = $event->getObject();
/* @var $object kDBItem */
// if password field is empty, then don't update
if ( $object->GetDBField('ElementType') == 'password' ) {
- if ( trim($object->GetDBField('VariableValue')) == '' ) {
- $field_options = $object->GetFieldOptions('VariableValue');
- $field_options['skip_empty'] = 1;
- $object->SetFieldOptions('VariableValue', $field_options);
- }
- else {
+ if ( trim($object->GetDBField('VariableValue')) != '' ) {
$password_formatter = $this->Application->recallObject('kPasswordFormatter');
/* @var $password_formatter kPasswordFormatter */
$object->SetDBField('VariableValue', $password_formatter->EncryptPassword($object->GetDBField('VariableValue'), 'b38'));
}
}
- $field_name = $object->GetDBField('VariableName');
- $field_values = $this->Application->GetVar($event->getPrefixSpecial(true));
- $state_country_hash = Array ('Comm_State' => 'Comm_Country', 'Comm_Shipping_State' => 'Comm_Shipping_Country');
+ $this->_processCountryState($event);
- if ( array_key_exists($field_name, $state_country_hash) ) {
- // if this is state field
- $sql = 'SELECT VariableId
- FROM ' . $this->Application->getUnitOption('conf', 'TableName') . '
- WHERE VariableName = "' . $state_country_hash[$field_name] . '"';
- $country_variable_id = $this->Conn->GetOne($sql);
-
- $check_state = $object->GetDBField('VariableValue');
- $check_country = $field_values[$country_variable_id]['VariableValue'];
-
- if ( !$check_country || !$check_state ) {
- return;
- }
-
- $cs_helper = $this->Application->recallObject('CountryStatesHelper');
- /* @var $cs_helper kCountryStatesHelper */
-
- $state_iso = $cs_helper->getStateIso($check_state, $check_country);
-
- if ( $state_iso !== false ) {
- $object->SetDBField('VariableValue', $state_iso);
- }
- else {
- // selected state doesn't belong to selected country
- $object->SetError('VariableValue', 'invalid_state', 'la_InvalidState');
- }
- }
-
$variable_name = $object->GetDBField('VariableName');
$new_value = $object->GetDBField('VariableValue');
@@ -187,17 +170,111 @@
$compile = $event->MasterEvent->getEventParam('compile_maintenance_template');
$compile = $compile || $new_value != $object->GetOriginalField('VariableValue');
- if ( $compile && !$this->generateMaintenancePage($new_value) ) {
+ if ( $compile && !$this->_generateMaintenancePage($new_value) ) {
$object->SetError('VariableValue', 'template_file_missing', 'la_error_TemplateFileMissing');
}
}
elseif ( $variable_name == 'DefaultEmailRecipients' ) {
$email_event_data = $this->Application->GetVar('emailevents_' . $event->Prefix);
$object->SetDBField('VariableValue', $email_event_data[0]['Recipients']);
}
+
+ $sections_helper = $this->Application->recallObject('SectionsHelper');
+ /* @var $sections_helper kSectionsHelper */
+
+ $section = $object->GetDBField('Section');
+
+ if ( $section && !$sections_helper->getSectionData($section) ) {
+ $object->SetError('Section', 'unknown_section');
+ }
}
/**
+ * Checks, that state belongs to selected country
+ *
+ * @param kEvent $event
+ * @access protected
+ */
+ protected function _processCountryState(kEvent $event)
+ {
+ $object = $event->getObject();
+ /* @var $object kDBItem */
+
+ $country_iso = $this->_getCountryByState($event);
+ $state_name = $object->GetDBField('VariableValue');
+
+ if ( !$country_iso || !$state_name ) {
+ return;
+ }
+
+ $cs_helper = $this->Application->recallObject('CountryStatesHelper');
+ /* @var $cs_helper kCountryStatesHelper */
+
+ $state_iso = $cs_helper->getStateIso($state_name, $country_iso);
+
+ if ( $state_iso !== false ) {
+ $object->SetDBField('VariableValue', $state_iso);
+ }
+ else {
+ // selected state doesn't belong to selected country
+ $object->SetError('VariableValue', 'invalid_state', 'la_InvalidState');
+ }
+ }
+
+ /**
+ * Returns country iso code, that matches current state variable name
+ *
+ * @param kEvent $event
+ * @return bool
+ * @access protected
+ */
+ protected function _getCountryByState(kEvent $event)
+ {
+ $object = $event->getObject();
+ /* @var $object kDBItem */
+
+ $variable_name = $object->GetDBField('VariableName');
+
+ $state_country_hash = Array (
+ 'Comm_State' => 'Comm_Country',
+ 'Comm_Shipping_State' => 'Comm_Shipping_Country'
+ );
+
+ if ( !array_key_exists($variable_name, $state_country_hash) ) {
+ return false;
+ }
+
+ $field_values = $this->Application->GetVar($event->getPrefixSpecial(true));
+
+ $sql = 'SELECT VariableId
+ FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ WHERE VariableName = ' . $this->Conn->qstr($state_country_hash[$variable_name]);
+ $country_variable_id = $this->Conn->GetOne($sql);
+
+ return $field_values[$country_variable_id]['VariableValue'];
+ }
+
+ /**
+ * Does custom password setting processong
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnBeforeItemUpdate(kEvent $event)
+ {
+ parent::OnBeforeItemUpdate($event);
+
+ $object = $event->getObject();
+ /* @var $object kDBItem */
+
+ // if password field is empty, then don't update
+ if ( $object->GetDBField('ElementType') == 'password' && trim($object->GetDBField('VariableValue')) == '' ) {
+ $object->SetFieldOption('VariableValue', 'skip_empty', 1);
+ }
+ }
+
+ /**
* Occurs after updating item
*
* @param kEvent $event
@@ -213,12 +290,8 @@
$object = $event->getObject();
/* @var $object kDBItem */
- if ( $object->GetDBField('ElementType') == 'password' ) {
- if ( trim($object->GetDBField('VariableValue')) == '' ) {
- $field_options = $object->GetFieldOptions('VariableValue');
- unset($field_options['skip_empty']);
- $object->SetFieldOptions('VariableValue', $field_options);
- }
+ if ( $object->GetDBField('ElementType') == 'password' && trim($object->GetDBField('VariableValue')) == '' ) {
+ $object->SetFieldOption('VariableValue', 'skip_empty', 0);
}
// allows to check if variable's value was changed now
@@ -371,7 +444,7 @@
* @return bool
* @access protected
*/
- protected function generateMaintenancePage($template = null)
+ protected function _generateMaintenancePage($template = null)
{
if ( !isset($template) ) {
$template = $this->Application->ConfigValue('HardMaintenanceTemplate');
@@ -390,4 +463,100 @@
return false;
}
+
+ /**
+ * Returns auto-complete values for ajax-dropdown
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnSuggestValues(kEvent $event)
+ {
+ if ( !$this->Application->isAdminUser ) {
+ // very careful here, because this event allows to
+ // view every object field -> limit only to logged-in admins
+ return;
+ }
+
+ $event->status = kEvent::erSTOP;
+
+ $field = $this->Application->GetVar('field');
+ $cur_value = $this->Application->GetVar('cur_value');
+
+ $object = $event->getObject();
+ /* @var $object kDBItem */
+
+ if ( !$field || !$cur_value || !$object->isField($field) ) {
+ return;
+ }
+
+ $limit = $this->Application->GetVar('limit');
+ if ( !$limit ) {
+ $limit = 20;
+ }
+
+ $sql = 'SELECT DISTINCT ' . $field . ', ModuleOwner
+ FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ WHERE ' . $field . ' LIKE ' . $this->Conn->qstr('%' . $cur_value . '%') . '
+ ORDER BY ' . $field . ' ASC';
+ $raw_suggestions = $this->Conn->Query($sql);
+
+ $suggestions = Array ();
+ $this->Application->XMLHeader();
+
+ foreach ($raw_suggestions as $raw_suggestion) {
+ $suggestion = $raw_suggestion[$field];
+
+ if ( !isset($suggestions[$suggestion]) ) {
+ $suggestions[$suggestion] = Array ();
+ }
+
+ $suggestions[$suggestion][] = $raw_suggestion['ModuleOwner'];
+ }
+
+ array_splice($suggestions, $limit);
+
+ echo '';
+ $of_label = $this->Application->Phrase('la_From', false);
+
+ foreach ($suggestions as $suggestion_value => $suggestion_modules) {
+ $suggestion_module = in_array('In-Portal', $suggestion_modules) ? 'In-Portal' : implode(', ', $suggestion_modules);
+ $suggestion_title = $suggestion_value . ' ' . $of_label . ' ' . $suggestion_module . '';
+
+ echo '- ' . htmlspecialchars($suggestion_title) . '
';
+ }
+
+ echo '';
+ }
+
+ /**
+ * Prefills module dropdown
+ *
+ * @param kEvent $event
+ * @return void
+ * @access protected
+ */
+ protected function OnAfterConfigRead(kEvent $event)
+ {
+ parent::OnAfterConfigRead($event);
+
+ $options = Array ();
+
+ foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
+ if ( $module_name == 'Core' ) {
+ continue;
+ }
+
+ $options[$module_name] = $module_name;
+
+ if ( $module_name == 'In-Portal' ) {
+ $options['In-Portal:Users'] = 'In-Portal:Users';
+ }
+ }
+
+ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $fields['ModuleOwner']['options'] = $options;
+ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ }
}
\ No newline at end of file
Index: branches/5.2.x/core/install/english.lang
===================================================================
diff -u -N -r15445 -r15471
--- branches/5.2.x/core/install/english.lang (.../english.lang) (revision 15445)
+++ branches/5.2.x/core/install/english.lang (.../english.lang) (revision 15471)
@@ -283,6 +283,7 @@
Q29weWluZyBvcGVyYXRpb24gaW4gVGVtcG9yYXJ5IHRhYmxlcyBoYXMgZmFpbGVkLiBQbGVhc2UgY29udGFjdCB3ZWJzaXRlIGFkbWluaXN0cmF0b3Iu
UmVjb3JkIGlzIG5vdCB1bmlxdWU=
U2VjdGlvbiBmaWVsZCBub3QgdW5pcXVl
+ VW5rbm93biBzZWN0aW9u
VW5rbm93biBzZWN0aW9u
VXNlciBCYW5uZWQ=
dXNlciBub3QgZm91bmQ=
@@ -456,6 +457,7 @@
QWxsb3cgUmVnaXN0cmF0aW9uIG9uIEZyb250LWVuZA==
RnVsbCBOYW1l
VXNlciBHcm91cA==
+ R3JvdXAgRGlzcGxheSBPcmRlcg==
SUQ=
R3JvdXAgTmFtZQ==
SGVpZ2h0
@@ -648,6 +650,11 @@
UG9pbnRzIHRvIFNlY3Rpb24=
U3luY2hyb25pemUgTGFuZ3VhZ2U=
U3lzdGVtIEV2ZW50
+ U2V0dGluZyBIaW50IExhYmVs
+ U2V0dGluZyBOYW1l
+ U2VjdGlvbg==
+ VmFsaWRhdGlvbiBMb2dpYw==
+ U2V0dGluZyBWYWx1ZQ==
VGFibGUgTmFtZSBpbiBEYXRhYmFzZSA=
VGFn
SXRlbQ==
@@ -1339,6 +1346,7 @@
QWRkaW5nIFNwZWxsaW5nIERpY3Rpb25hcnk=
QWRkaW5nIFN0b3AgV29yZA==
QWRkaW5nIFN5c3RlbSBFdmVudCBTdWJzY3JpcHRpb24=
+ QWRkaW5nIFN5c3RlbSBTZXR0aW5n
QWRkaW5nIFRoZW1lIFRlbXBsYXRl
QWRkaW5nIFRoZXNhdXJ1cw==
QWRkaW5nIEJhc2UgU3R5bGU=
@@ -1395,6 +1403,7 @@
RWRpdGluZyBTdG9wIFdvcmQ=
RWRpdGluZyBTdHlsZQ==
RWRpdGluZyBTeXN0ZW0gRXZlbnQgU3Vic2NyaXB0aW9u
+ RWRpdGluZyBTeXN0ZW0gU2V0dGluZw==
RWRpdGluZyBUaGVtZSBGaWxl
RWRpdGluZyBUaGVzYXVydXM=
RWRpdGluZyBUcmFuc2xhdGlvbg==
@@ -1559,6 +1568,7 @@
TmV3IFNlYXJjaCBGaWVsZA==
TmV3IFNpdGUgRG9tYWlu
TmV3IFN0b3AgV29yZA==
+ TmV3IFN5c3RlbSBTZXR0aW5n
TmV3IFRlcm0=
TmV3IFRoZW1l
TmV3IFVzZXI=