Elxis CMS Forum

Support => Technical support => Topic started by: StefanSultanov on March 11, 2011, 16:30:34

Title: Restricted access to eShop new product form?
Post by: StefanSultanov on March 11, 2011, 16:30:34
Can I give restricted access to eShop new product form?
How to make the form for creating new products in eShop available to certain users?
Front end or Backend restricted access?
Is there some workaround?
Title: Re: Restricted access to eShop new product form?
Post by: webgift on March 11, 2011, 17:41:46
You can create a menu item on which you will give a preferred access level.
Analytically :
[Administrator area] Menu -> [Select Menu Type] for example : Main Menu -> [at Top Right are ] click : New -> Link/Url -> Name: New Products , Link : http://www.yourdomainname.com/eshop/new-products.html
Access Level : [Select whatever you want] like : Registered.
Title: Re: Restricted access to eShop new product form?
Post by: rentasite on March 12, 2011, 11:28:55
You can create a menu item on which you will give a preferred access level.

Ok, from that menu item.... if someone clicks on a restricted product & after that he clicks on an internal link of eShop? He will be able to see all products!
Title: Re: Restricted access to eShop new product form?
Post by: webgift on March 12, 2011, 12:49:47
This requires to hide the internal links from eShop. ;).
Title: Re: Restricted access to eShop new product form?
Post by: datahell on March 13, 2011, 11:54:34
It is easy and you dont need to edit eshop to do this.
It is the same technique we use for accessing only certain areas of the administration area.

You need to block the following tasks: new, edit, editA for all users except the admin (userid = 62).

So, in administration's template index.php and before echoing anything OR in elxis' index2.php and index3.php files you write something like this:
Code: [Select]
global $my;
if (($my->id != 62) && isset($_REQUEST['option']) && ($_REQUEST['option'] == 'com_eshop')) {
if (isset($_REQUEST['task']) && in_array($_REQUEST['task'], array('new', 'edit', 'editA'))) {
mosRedirect('index2.php?option=com_eshop', 'You are not allowed to add or edit products');
}
}

If you also want to block him from seeing the products list add the task "products" into the above array.
Title: Re: Restricted access to eShop new product form?
Post by: webgift on March 13, 2011, 12:44:16
I think that i misunderstood the question  ::)
Title: Re: Restricted access to eShop new product form?
Post by: babis1 on March 13, 2011, 12:53:32


So, in administration's template index.php
john are you sure in administrator template or in administrator folder index.php  index1.php index2.php?
Title: Re: Restricted access to eShop new product form?
Post by: datahell on March 14, 2011, 08:21:33
So, in administration's template index.php and before echoing anything OR in elxis' index2.php and index3.php files you write something like this:
Title: Re: Restricted access to eShop new product form?
Post by: StefanSultanov on April 19, 2011, 09:44:17
Thanks for the replies!
I basically want to create a user group that I can assign users to.
This group of users should be able to submit new eshop product and to view and edit their own products.
From what I read so far I should place this piece of code in 3 different files. Administrator/template/index.php, index2.php and index3.php.
To watch out for the "echoes" and place the code before them.

Userid is the username. Am I correct?
Please note:
I'm a designer. I don't have any php experience and I'll paste the code blindfolded. Changing the userid with my own to keep full access to the component.

I'm not sure that I can pull this off safely. So please stop me if I got something wrong.
If someone wants to help me with this I'll be glad to help in return.
Title: Re: Restricted access to eShop new product form?
Post by: datahell on April 19, 2011, 13:42:48
This code is for restricting or providing access to specific users. It will not do this:
Quote from: StefanSultanov
...view and edit their own products.
Title: Re: Restricted access to eShop new product form?
Post by: StefanSultanov on July 02, 2011, 01:10:22
I see
Title: Re: Restricted access to eShop new product form?
Post by: StefanSultanov on July 06, 2011, 19:32:55
If this code does not do this. Is there a way to do this thing?
Title: Re: Restricted access to eShop new product form?
Post by: datahell on July 06, 2011, 20:28:25
Is there a way to do this thing?
Be more detailed, your question is confusing. What do you mean by saying this thing?

I have replied and show you have to use restrict/provide access to certain users.

If you wish to allow users edit only there own products you need first to add this information in the database. Currently IOS Eshop does not marks who added the product. So you must add a new db column in table elx_products named uid - INTERGER(11). uid will be the author's user id. You must modify the shop's administration pages in order to store this information to db.

After this modification you can limit access to products only to the creators of the products by modifying the queries like this:

$sql = "SELECT * FROM #__products WHERE .... AND uid=".$my->id;
Title: Re: Restricted access to eShop new product form?
Post by: StefanSultanov on July 13, 2011, 03:54:56
Got it!