Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Thu, Jun 26, 11:23 PM

in-portal

Index: branches/RC/core/units/configuration/configuration_event_handler.php
===================================================================
--- branches/RC/core/units/configuration/configuration_event_handler.php (revision 11199)
+++ branches/RC/core/units/configuration/configuration_event_handler.php (revision 11200)
@@ -1,202 +1,215 @@
<?php
class ConfigurationEventHandler extends kDBEventHandler {
/**
* 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
* @access protected
* @see OnListBuild
*/
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
/* @var $object kDBList */
$module = $this->Application->GetVar('module');
$section = $this->Application->GetVar('section');
$object->addFilter('module_filter', '%1$s.ModuleOwner = '.$this->Conn->qstr($module));
$object->addFilter('section_filter', '%1$s.Section = '.$this->Conn->qstr($section));
if (defined('IS_INSTALL') && IS_INSTALL) {
$object->addFilter('install_filter', 'ca.Install = 1');
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnBeforeItemUpdate(&$event)
{
$object =& $event->getObject();
// if password field is empty, then don't update
if ($object->GetDBField('element_type') == 'password') {
if (trim($object->GetDBField('VariableValue')) == '') {
$field_options = $object->GetFieldOptions('VariableValue');
$field_options['skip_empty'] = 1;
$object->SetFieldOptions('VariableValue', $field_options);
}else {
$password_formatter =& $this->Application->recallObject('kPasswordFormatter');
$object->SetDBField('VariableValue', $password_formatter->EncryptPassword($object->GetDBField('VariableValue'), 'b38'));
}
}
$field_values = $this->Application->GetVar($event->getPrefixSpecial(true));
$state_country_hash = Array(
'Comm_State' => 'Comm_Country',
'Comm_Shipping_State' => 'Comm_Shipping_Country'
);
$field_name = $object->GetDBField('VariableName');
if (isset($state_country_hash[$field_name])) {
// if this is state field
$check_state = $object->GetDBField('VariableValue');
$check_country = $field_values[ $state_country_hash[$field_name] ]['VariableValue'];
if (!($check_country && $check_state)) {
return true;
}
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
$state_iso = $cs_helper->CheckState($check_state, $check_country);
if ($state_iso !== false) {
$object->SetDBField('VariableValue', $state_iso);
}
else
{
$errormsgs = $this->Application->GetVar('errormsgs');
$errors = !$errormsgs || !isset($errormsgs[$event->Prefix_Special]) ? Array() : $errormsgs[$event->Prefix_Special];
$errors[$field_name] = 'la_InvalidState';
$errormsgs[$event->Prefix_Special] = $errors;
$this->Application->SetVar('errormsgs', $errormsgs);
$event->status = erFAIL;
}
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnAfterItemUpdate(&$event)
{
$object =& $event->getObject();
if ($object->GetDBField('element_type') == 'password') {
if (trim($object->GetDBField('VariableValue')) == '') {
$field_options = $object->GetFieldOptions('VariableValue');
unset($field_options['skip_empty']);
$object->SetFieldOptions('VariableValue', $field_options);
}
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
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 !== false) {
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));
}
}
- if ($event->status == erSUCCESS) { // reset cache
- $this->Application->UnitConfigReader->ResetParsedData();
+ if ($event->status == erSUCCESS && $items_info) { // reset cache
+ $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+
+ $sql = 'SELECT ' . $id_field . '
+ FROM ' . $table_name . '
+ WHERE ' . $id_field . ' IN (' . implode(',', array_keys($items_info)) . ') AND (VariableName = "AdvancedUserManagement")';
+ $refresh_sections = $this->Conn->GetCol($sql);
+
+ if ($refresh_sections) {
+ // reset sections too, because of AdvancedUserManagement
+ $event->SetRedirectParam('refresh_tree', 1);
+ }
+
+ $this->Application->UnitConfigReader->ResetParsedData($refresh_sections ? true : false);
}
}
if ($this->Application->GetVar('errormsgs')) {
// because we have list out there, and this is item
$this->Application->removeObject($event->getPrefixSpecial());
$event->redirect = false;
}
// 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'));
}
/**
* Enter description here...
*
* @param kEvent $event
*/
/*function OnChangeCountry(&$event)
{
$event->setPseudoClass('_List');
$object = &$event->getObject( Array('per_page'=>-1) );
$object->Query();
$array_records =& $object->Records;
foreach($array_records as $i=>$record){
if ($record['VariableName']=='Comm_Country'){
$values = $this->Application->GetVar('conf');
$array_records[$i]['VariableValue'] = $values['Comm_Country']['VariableValue'];
}
}
$event->redirect_params = Array('opener' => 's', 'pass'=>'all,conf'); //stay!
$event->redirect = false;
}*/
/**
* Process items from selector (selected_ids var, key - prefix, value - comma separated ids)
*
* @param kEvent $event
*/
function OnProcessSelected(&$event)
{
$selected_ids = $this->Application->GetVar('selected_ids');
$this->Application->StoreVar('ModuleRootCategory', $selected_ids['c']);
$event->SetRedirectParam('opener', 'u');
}
}
?>
\ No newline at end of file
Property changes on: branches/RC/core/units/configuration/configuration_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.18.2.4
\ No newline at end of property
+1.18.2.5
\ No newline at end of property
Index: branches/RC/core/admin_templates/config/config_universal.tpl
===================================================================
--- branches/RC/core/admin_templates/config/config_universal.tpl (revision 11199)
+++ branches/RC/core/admin_templates/config/config_universal.tpl (revision 11200)
@@ -1,92 +1,98 @@
<inp2:m_RequireLogin perm_event="conf:OnLoad" system="1"/>
<inp2:m_include t="incs/header"/>
<inp2:m_Get var="section" result_to_var="section"/> <!-- was #section# before, don't know were it was replaced -->
<inp2:conf_InitList name="default" per_page="-1" />
<inp2:m_RenderElement name="combined_header" section="$section" module="in-portal" prefix="conf" title_preset=""/>
<!-- ToolBar --->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
<tr>
<td>
<script type="text/javascript">
function ValidatePassFld(fieldId){
var passFld=document.getElementById(fieldId);
var passVerifyFld=document.getElementById('verify_'+fieldId);
if (passFld && passVerifyFld && passFld.value == passVerifyFld.value) {
return true;
}
else {
var passErrorCell=document.getElementById('error_'+fieldId);
if (passErrorCell){
passErrorCell.innerHTML='<inp2:m_phrase name="la_error_PasswordMatch" />';
}
return false;
}
}
function ValidatePassFields(){
var el=false;
var validated=true;
for (var i=0; i<document.forms.kernel_form.elements.length; i++){
el=document.forms.kernel_form.elements[i];
if (el.getAttribute('primarytype')=='password'){
if (!ValidatePassFld(el.id)){
validated=false;
}
}
}
return validated;
}
function toggle_section($label) {
var $table = document.getElementById('config_table');
var $row = null;
var $is_visible = false;
for (var $i = 0; $i < $table.rows.length; $i++) {
$row = $table.rows[$i];
if ($row.getAttribute('header_label') != $label) {
continue;
}
if (!$row.style.display) {
$row.style.display = document.all ? 'block' : 'table-row';
}
$is_visible = !($row.style.display == 'none');
$row.style.display = $is_visible ? 'none' : (document.all ? 'block' : 'table-row');
document.getElementById('toggle_mark['+$label+']').innerHTML = '[' + ($is_visible ? '+' : '-') + ']';
}
}
var a_toolbar = new ToolBar();
a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
if (ValidatePassFields()){
submit_event('conf','<inp2:conf_SaveEvent/>');
}
}
) );
a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
submit_event('conf','OnCancel');
}
) );
a_toolbar.Render();
</script>
</td>
</tr>
</tbody>
</table>
<inp2:m_include t="incs/config_blocks"/>
<inp2:conf_SaveWarning name="grid_save_warning"/>
<table width="100%" border="0" cellspacing="0" cellpadding="4" class="bordered" id="config_table">
<inp2:conf_PrintList list_name="default" block="config_block" full_block="config_block" half_block1="config_block1" half_block2="config_block2"/>
</table>
+<script type="text/javascript">
+<inp2:m_if check="m_Get" name="refresh_tree">
+ getFrame('menu').location.reload();
+</inp2:m_if>
+</script>
+
<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Property changes on: branches/RC/core/admin_templates/config/config_universal.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.5.2.1
\ No newline at end of property
+1.5.2.2
\ No newline at end of property

Event Timeline