Can users have their own product edit permissions in OpenCart? - permissions

I am completely new to OpenCart. I have created two users - user1 and user2 and both have the product add/edit permission. user1 add a product. But both user1 and user2 can edit the same product. What I am looking for is only user1 and superadmin can edit the product.
Likely if user2 adds another product then only superadmin and user2 can edit that product. Is it possible in OpenCart? If the situation is not possible in OpenCart, can anyone suggest an alternative to do the same?

Unfortunately, there is no such a thing in OC!
You have two options to accomplish that:
Find a plugin here that makes that (if any)
Code it manually
Step 1: you must keep track of the user who created the product, so you will need to add a new column to the <DB_PREFIX>_product table and save the id of the user who created the product in it, this is a simple step you will just need to modify the model function that saves the product details
Step 2: modify the get product model function and make it returns the id of the creator along with other data
Step 3: modify the edit product page controller index function in such a way that if the logged in user id does not equal the creator of the product, then display some error message

Related

Giving Employee usergroup access to custom module - Odoo

I have created a module named Purchases containing menu item: Purchasesand views: Received purchases, Pending purchases and want to give access to this module to only the Employees\Employee.
I have created a new user with email emp1#gmail.com from the Settings and added it to user group Employees\Employee. I have given the Employees\Employee group access rights to the Purchases, Received purchases and Pending purchases views.
When I log in as the employee emp1#gmail.com I still do not get the Menu Item Purchases. I only get the Settings and Discuss menu items.
I got it wrong. It seems that I should have added that model to the access rights first and give permission to view,read,write,delete. Thanks.

How to give edit rights to own records for a user in openerp 7?

I would like to implement the following scenario.
User must be able to see all the records and should be able to edit only his own records
Is it possible to do it in openerp 7 and if possible how to do it?
You need to create Record rule so User can see only his records and create Access Control List so User can edit those records.
Record rule --> Settings/Technical/Security/Record Rules
Create a Record rule for your object and add a specific domain so user
can see only his record.
Access Control List --> Settings/Technical/Security/Access Control List
Create a Access Control List and add name, object,
Access(Read/Edit/Delete/Create) and save it. As per your need, you
need to tick Write Access, Save it and Check it.
Add a functional field which returns false if the record is created by the logged in user else true and in the view add a group with attributes readonly if the functional field's value is true and move all the fields to this group and also add the functional field invisible as invisible in the view

Getting user profile data in Silverlight 4

I am fairly new to Silverlight and RIA services, and I am trying to build a small project to understand it. So basically I created a Business Application, and I have the normal Login screen where I can add a user. That is fine and I can add a user and get him into the aspnet_Users table. Now I have created some extra fields, like Mob No, Tel No, DOB, Locality etc, which I have put in a table I have created called the UserProfile, and my idea is to get the username that was registered, and insert it into my UserProfile table with the other relevant data.
So I created a page called Profile.xaml, I created a UserProfileDomainService.cs where I have just one query, to get the user profile data from the table, and then created a Details DataGrid on my page, and the QueryName in my case is GetUserProfilesQuery(). Now what i wish to do is, get the user logged in, get his username, and check in my table to see if there is already data in the table. If there is populate the fields on the DataGrid with data, so that the user can modify this data, and if not, allow the user to insert data into the table.
So I have created a UserProfileViewModel class, and I want to create the query to get the data relevant to this user. However I got stuck on how to do all this, and how to get the user logged in.
Can anybody give me some advice or point me to some tutorials on how I can achieve this?
Thanks a lot and your help is very much appreciated.
In your domain service query you can use ServiceContext.User.Identity.Name to get the information specific to that user to include in your db query. I do something similar in our project.
We use entity framework so the LINQ to Entities query looks like:
return this.ObjectContext.UserSnapins
.Include("Snapin.EvolutionModule")
.Where(si => si.User.UserName == ServiceContext.User.Identity.Name)
.OrderBy(si => si.PageOrder);

MySQL joins for friend feed

I'm currently logging all actions of users and want to display their actions for the people following them to see - kind of like Facebook does it for friends.
I'm logging all these actions in a table with the following structure:
id - PK
userid - id of the user whose action gets logged
actiondate - when the action happened
actiontypeid - id of the type of action (actiontypes stored in a different table - i.e. following other users, writing on people's profiles, creating new content, commenting on existing content, etc.)
objectid - id of the object they just created (i.e. comment id)
onobjectid - id of the object they did the action to (i.e. id of the content that they commented on)
Now the problem is there are several types of actions that get logged (actiontypeid).
What would be the best way of retrieving the data to display to the user?
The easiest way out would be gabbing the people the user follows dataset and then just go from there and grab all other info from the other tables (i.e. the names of the users the people you're following just started following, names of the user profiles they wrote on, etc.). This however would create a a huge amount of small queries and trips to the database in a while loop. Not a good idea.
I could use joins to retrieve everything in one massive data set, but how would I know where to grab the data from in just one query? - there's different types of actions that require me to look into several different tables to retrieve data, based on the actiontypeid...
i.e. To get User X is now following User Y I'd have to get my data (User Y's username) from the followers table, whereas User X commented on content Y would need me to look in the content table to get the content's title and URL.
Any tips are welcome, thanks!
Consider creating several views for different actiontypeids. Union them to have one full history.

What is the best way to lay out nested data in SQL Server Reporting Services 2005?

I am attempting to create a report that contains a list nested within another list to produce the following layout:
User name: Bob
User info: Interesting stuff about Bob
Permissions: Administrator
SuperUser
User
User name: Next user
etc...
The data looks like this:
UserName Details PermissionName
Bob Interes... Administrator
Bob Interes... SuperUser
Bob Interes... User
NextUser More stuff User
In my example I am trying to display the user details using a list and then to display the permissions using a second list embedded within the first list. I decided to do this because there are a variable number of permissions that can be assigned to a user. However this approach doesn't seem to work.
Is there a better way or am I just missing something really obvious?
how about using a sub report for the 2nd set?
You can also use a table control and group your data on "UserName" with the detail grouped on "Permission".