Hi, all i want to hide the Edit and delete button if user(other then admin) is logged in the admin section. user can add products but can not modify the products of other. admin can add or modify all products of other.
Attachments
products page - Products_1352626801516.png (232.32 KiB) Viewed 427 times
Edit admin/controller/catalog/product.php
At line 11 add:
At line 350 change:
Into:
Edit admin/view/template/catalog/product_list.tpl
At line 17 change:
Into:
Show the button Delete and link Edit only if username = admin
But if user is clever and edits the url and changes the route to route=catalog/product/update and adds product_id=1 he is able to edit product 1
To prevent that add some logic to function update()
At line 11 add:
Code: Select all
$this->data['user_can_add'] = ($this->user->getUserName() == 'admin');
Code: Select all
$action[] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL')
);
Code: Select all
if( $this->data['user_can_add'] ) {
$action[] = array(
'text' => $this->language->get('text_edit'),
'href' => $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . $result['product_id'] . $url, 'SSL')
);}
At line 17 change:
Code: Select all
<a onclick="$('form').submit();" class="button"><?php echo $button_delete; ?></a>
Code: Select all
<?php if( $user_can_add ) {;?><a onclick="$('form').submit();" class="button"><?php echo $button_delete; ?></a><?php }?>
But if user is clever and edits the url and changes the route to route=catalog/product/update and adds product_id=1 he is able to edit product 1
To prevent that add some logic to function update()
Thanks,@pprmkr
Edit button is gone. But delete button is still there. when i am attempting to delete something. its shows a warning. snapshot attached.
I am also attaching the both files where the code is overwritten.
Once again thanks PPrmkr. You are amazing
Edit button is gone. But delete button is still there. when i am attempting to delete something. its shows a warning. snapshot attached.
I am also attaching the both files where the code is overwritten.
Once again thanks PPrmkr. You are amazing
Attachments
whenclicking on deltet - Products_1352631831155.png (183.43 KiB) Viewed 422 times
Checked the files and works OK.
Little change: second delete button removed from tpl-file.
Little change: second delete button removed from tpl-file.
Attachments
Who is online
Users browsing this forum: jkitz and 45 guests