[-] BO : fixed ajax in permissions tab #PSCFV-7442

This commit is contained in:
Damien Metzger
2013-06-14 11:20:38 +02:00
parent 2ae0e4f844
commit 12e13e275f
3 changed files with 24 additions and 30 deletions
@@ -49,8 +49,10 @@
if (perm == 'all' && $(this).parent().parent().hasClass('parent'))
{
checked = enabled ? 'checked': '';
$(this).parent().parent().parent().find('.child-'+id_tab+' input[type=checkbox]').attr('checked', checked);
if (enabled)
$(this).parent().parent().parent().find('.child-'+id_tab+' input[type=checkbox]').attr('checked', 'checked');
else
$(this).parent().parent().parent().find('.child-'+id_tab+' input[type=checkbox]').removeAttr('checked');
$.ajax({
url: "{$link->getAdminLink('AdminAccess')|addslashes}",
cache: false,
@@ -68,15 +70,12 @@
},
success : function(res,textStatus,jqXHR)
{
try
{
try {
if (res == 'ok')
showSuccessMessage("{l s='Update successful'}");
else
showErrorMessage("{l s='Update error'}");
}
catch(e)
{
} catch(e) {
jAlert('Technical error');
}
}
+18 -21
View File
@@ -153,35 +153,32 @@ class AdminAccessControllerCore extends AdminController
$join = 'LEFT JOIN `'._DB_PREFIX_.'tab` t ON (t.`id_tab` = a.`id_tab`)';
}
if ($id_tab == -1 && $perm == 'all' && $enabled == 0)
$sql = '
if ($id_tab == -1)
{
if ($perm == 'all')
$sql = '
UPDATE `'._DB_PREFIX_.'access` a
SET `view` = '.(int)$enabled.', `add` = '.(int)$enabled.', `edit` = '.(int)$enabled.', `delete` = '.(int)$enabled.'
WHERE `id_profile` = '.(int)$id_profile;
else if ($id_tab == -1 && $perm == 'all')
$sql = '
UPDATE `'._DB_PREFIX_.'access` a
SET `view` = '.(int)$enabled.', `add` = '.(int)$enabled.', `edit` = '.(int)$enabled.', `delete` = '.(int)$enabled.'
WHERE `id_profile` = '.(int)$id_profile;
else if ($id_tab == -1)
$sql = '
else
$sql = '
UPDATE `'._DB_PREFIX_.'access` a
SET `'.bqSQL($perm).'` = '.(int)$enabled.'
WHERE `id_profile` = '.(int)$id_profile;
else if ($perm == 'all')
$sql = '
UPDATE `'._DB_PREFIX_.'access` a
'.$join.'
SET `view` = '.(int)$enabled.', `add` = '.(int)$enabled.', `edit` = '.(int)$enabled.', `delete` = '.(int)$enabled.'
WHERE '.$where.' = '.(int)$id_tab.'
AND `id_profile` = '.(int)$id_profile;
}
else
$sql = '
UPDATE `'._DB_PREFIX_.'access` a
'.$join.'
{
if ($perm == 'all')
$sql = '
UPDATE `'._DB_PREFIX_.'access` a '.$join.'
SET `view` = '.(int)$enabled.', `add` = '.(int)$enabled.', `edit` = '.(int)$enabled.', `delete` = '.(int)$enabled.'
WHERE '.$where.' = '.(int)$id_tab.' AND `id_profile` = '.(int)$id_profile;
else
$sql = '
UPDATE `'._DB_PREFIX_.'access` a '.$join.'
SET `'.bqSQL($perm).'` = '.(int)$enabled.'
WHERE '.$where.' = '.(int)$id_tab.'
AND `id_profile` = '.(int)$id_profile;
WHERE '.$where.' = '.(int)$id_tab.' AND `id_profile` = '.(int)$id_profile;
}
$res = Db::getInstance()->execute($sql) ? 'ok' : 'error';
@@ -154,8 +154,6 @@ class AdminTrackingControllerCore extends AdminController
$this->tpl_list_vars = array('sub_title' => $this->l('List of products with attributes but without available quantities for sale:'));
return $this->renderList();
}