// fix retrieving of the fields value 'shop' and 'group_shop' dynamically (PSFV-94)

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10130 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2011-11-15 12:19:39 +00:00
parent 45a3f8d33a
commit b9ee33bdcb
13 changed files with 24 additions and 103 deletions
@@ -108,7 +108,7 @@
{/if}
{/block}
{if $input.type == 'hidden'}
<input type="hidden" name="{$input.name}" value="{$fields_value[$input.name]}" />
<input type="hidden" name="{$input.name}" id="{$input.name}" value="{$fields_value[$input.name]}" />
{else}
{block name="start_field_block"}
<div class="margin-form">
@@ -320,7 +320,7 @@
<input type="submit"
id="{$table}_form_submit_btn"
value="{$field.title}"
name="{$submit_action}{if isset($field.stay) && $field.stay}AndStay{/if}"
name="{if isset($field.name)}{$field.name}{else}{$submit_action}{/if}{if isset($field.stay) && $field.stay}AndStay{/if}"
{if isset($field.class)}class="{$field.class}"{/if} />
</div>
{elseif $key == 'p'}
@@ -51,8 +51,7 @@
</div>
{assign var=home_is_selected value=false}
{foreach $categories.selected_cat AS $cat}
{if is_array($cat)}
{if $cat.id_category != 1}
@@ -74,11 +74,11 @@ function check_all_shop() {ldelim}
<div class="assoShop">
<table class="table" cellpadding="0" cellspacing="0" width="100%">
<tr>
<th>{l s='Shop'}</th>
<th>{if $input.type == 'group_shop'}{l s='Group shop'}{else}{l s='Shop'}{/if}</th>
</tr>
<tr {if $input.type == 'group_shop'}class="alt_row"{/if}>
<td>
<label class="t"><input class="input_all_shop" type="checkbox" /> {l s='All shops'}</label>
<label class="t"><input class="input_all_shop" type="checkbox" /> {if $input.type == 'group_shop'}{l s='All group shops'}{else}{l s='All shops'}{/if}</label>
</td>
</tr>
{foreach $input.values as $groupID => $groupData}
+13 -2
View File
@@ -369,7 +369,6 @@ class AdminControllerCore extends Controller
// Sub included tab postProcessing
$this->includeSubTab('postProcess', array('status', 'submitAdd1', 'submitDel', 'delete', 'submitFilter', 'submitReset'));
if (!empty($this->action) && method_exists($this, 'process'.ucfirst(Tools::toCamelCase($this->action))))
$this->{'process'.Tools::toCamelCase($this->action)}($token);
else if (method_exists($this, $this->action))
@@ -1870,7 +1869,19 @@ class AdminControllerCore extends Controller
if (isset($fieldset['form']['input']))
foreach ($fieldset['form']['input'] as $input)
if (empty($this->fields_value[$input['name']]))
if (isset($input['lang']) && $input['lang'])
if ($input['type'] == 'group_shop' || $input['type'] == 'shop')
{
if ($obj->id)
{
$assos = array();
$sql = 'SELECT `id_'.$input['type'].'`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_'.$input['type'].'`
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_'.$input['type']]][] = $row[$this->identifier];
}
}
else if (isset($input['lang']) && $input['lang'])
foreach ($this->_languages as $language)
$this->fields_value[$input['name']][$language['id_lang']] = $this->getFieldValue($obj, $input['name'], $language['id_lang']);
else
+5 -4
View File
@@ -166,10 +166,11 @@ class HelperFormCore extends Helper
*/
public function getFieldsRequired()
{
if (isset($this->fields_form['input']))
foreach ($this->fields_form['input'] as $input)
if (array_key_exists('required', $input) && $input['required'])
return true;
foreach ($this->fields_form as $fieldset)
if (isset($fieldset['form']['input']))
foreach ($fieldset['form']['input'] as $input)
if (array_key_exists('required', $input) && $input['required'])
return true;
return false;
}
@@ -231,17 +231,6 @@ class AdminAttributesGroupsControllerCore extends AdminController
if (!($obj = $this->loadObject(true)))
return;
//Added values of object Shop
if ($obj->id)
{
$assos = array();
$sql = 'SELECT `id_group_shop`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_group_shop`
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_group_shop']][] = $row[$this->identifier];
}
return parent::initForm();
}
@@ -339,17 +328,6 @@ class AdminAttributesGroupsControllerCore extends AdminController
'id_attribute' => $this->getFieldValue($obj, 'id'),
);
// Added values of object GroupShop
if ($obj->id)
{
$assos = array();
$sql = 'SELECT `id_group_shop`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_group_shop`
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_group_shop']][] = $row[$this->identifier];
}
$str_attributes_groups = '';
foreach ($attributes_groups as $attribute_group)
$str_attributes_groups .= '"'.$attribute_group['id_attribute_group'].'" : '.($attribute_group['group_type'] == 'color' ? '1' : '0' ) .', ';
@@ -540,17 +540,6 @@ class AdminCarriersControllerCore extends AdminController
$groups = Group::getGroups($this->context->language->id);
foreach ($groups as $group)
$this->fields_value['groupBox_'.$group['id_group']] = Tools::getValue('groupBox_'.$group['id_group'], (in_array($group['id_group'], $carrier_groups_ids)));
//Added values of object Shop
if ($obj->id)
{
$assos = array();
$sql = 'SELECT `id_shop`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier];
}
}
public function beforeDelete($object)
@@ -335,17 +335,6 @@ class AdminCountriesControllerCore extends AdminController
'name' => 'checkBoxShopAsso',
'values' => Shop::getTree()
);
//Added values of object Shop
if ($obj->id)
{
$assos = array();
$sql = 'SELECT `id_shop`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier];
}
}
$this->fields_form['submit'] = array(
@@ -282,17 +282,6 @@ class AdminEmployeesControllerCore extends AdminController
$this->fields_value['passwd'] = false;
//Added values of object Shop
if ($obj->id)
{
$assos = array();
$sql = 'SELECT `id_shop`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier];
}
return parent::initForm();
}
@@ -288,17 +288,6 @@ class AdminLanguagesControllerCore extends AdminController
'ps_version' => _PS_VERSION_
);
//Added values of object Shop
if ($obj->id)
{
$assos = array();
$sql = 'SELECT `id_shop`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier];
}
$this->addJS(_PS_JS_DIR_.'checkLangPack.js');
return parent::initForm();
@@ -326,7 +326,7 @@ class AdminManufacturersControllerCore extends AdminController
{
$this->fields_form['input'][] = array(
'type' => 'group_shop',
'label' => $this->l('Shop association:'),
'label' => $this->l('GroupShop association:'),
'name' => 'checkBoxShopAsso',
'values' => Shop::getTree()
);
@@ -359,17 +359,6 @@ class AdminManufacturersControllerCore extends AdminController
)), ENT_COMPAT, 'UTF-8');
}
//Added values of object Shop
if ($manufacturer->id)
{
$assos = array();
$sql = 'SELECT `id_group_shop`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_group_shop`
WHERE `'.pSQL($this->identifier).'` = '.(int)$manufacturer->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_group_shop']][] = $row[$this->identifier];
}
return parent::initForm();
}
@@ -360,17 +360,6 @@ class AdminReferrersControllerCore extends AdminController
'request_uri_like_not' => str_replace('\\', '\\\\', htmlentities($this->getFieldValue($obj, 'request_uri_like_not'), ENT_COMPAT, 'UTF-8'))
);
//Added values of object Shop
if ($obj->id)
{
$assos = array();
$sql = 'SELECT `id_shop`, `'.pSQL($this->identifier).'`
FROM `'._DB_PREFIX_.pSQL($this->table).'_shop`
WHERE `'.pSQL($this->identifier).'` = '.(int)$obj->id;
foreach (Db::getInstance()->executeS($sql) as $row)
$this->fields_value['shop'][$row['id_shop']][] = $row[$this->identifier];
}
$this->tpl_form_vars = array('uri' => $uri);
return parent::initForm();
@@ -235,8 +235,6 @@ abstract class AdminStatsTabControllerCore extends AdminPreferencesControllerCor
else
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
}
if (count($this->_errors))
AdminTab::displayErrors();
}
protected function getDate()