How To Make An Addon Availabe For A User-Group

Hi,

I have a custom addon that was developed for our website, but I need to make it used by a specific user-group.

The addon is not listed within the privileges list that can be added to a user-group; What code I need to create for achieving that?

Thanks

All depends on what the addon does.

You can make any UI pages conditional by surrounding with:

{assign var="usergroup " val="[usergroup_id of group you want} }
{if $auth.user_id && $usergroup|in_array:auth.usergroup_ids}
  UI page here
{/if}

Or something similar within the controller that supplies the data (assuming it's a data driven addon).

All depends on what the addon does.

You can make any UI pages conditional by surrounding with:

{assign var="usergroup " val="[usergroup_id of group you want} }
{if $auth.user_id && $usergroup|in_array:auth.usergroup_ids}
  UI page here
{/if}

Or something similar within the controller that supplies the data (assuming it's a data driven addon).

Many thanks Tony for your help.

I will check how can I apply this to the addon ..

You can add queries to the addon.xml file to insert the new privilege in the privileges table. That will be the easiest thing to do.

You can add queries to the addon.xml file to insert the new privilege in the privileges table. That will be the easiest thing to do.

You can use Gift Certificates module as example. It adds the "Manage gift certificates" privilege

You can add queries to the addon.xml file to insert the new privilege in the privileges table. That will be the easiest thing to do.

I believe privileges are only applied to Administrator groups.

It's unclear whether you are talking about customer usergroups or admin usergroups (I thought you were asking about customer usergroups). The two above responses apply to admin usergroups. But if you want customer, then you will probably have to do as I suggested.

This is why it's hard to give specific answers. CSC is very flexible and some things apply in customer/admin only while others apply to both. Also details of what the addon is supposed to do are important. And there's always more than one way to skin a cat.....

Yes, looking forward for the clarification

You can add queries to the addon.xml file to insert the new privilege in the privileges table. That will be the easiest thing to do.

You can use Gift Certificates module as example. It adds the "Manage gift certificates" privilege

Thanks pradeesh and eComLabs for the replies; would please elaborate more .. that well help me alots.

Yes Tony, its Admin User-Group ..

Okay, my confusion. The tags to add to your addon xml would then be:




INSERT INTO ?:privileges (privilege, is_default, section_id) VALUES (‘manage_[YOUR_ADDON_NAME]’, ‘Y’, ‘addons’)

DELETE FROM ?:privileges WHERE privilege='manage_[YOUR_ADDON_NAME]'

Many Thanks Tony.

These addition to the addon.xml file should be done before installing the addon, correct? I mean if the addon is already installed the new entries to the privileges table will not be done.?

Many Thanks Tony.

These addition to the addon.xml file should be done before installing the addon, correct? I mean if the addon is already installed the new entries to the privileges table will not be done.?

Right, you should add these queries and re-install the module. Do not forget that if the development mode is off, addon templates will be deleted from the active theme

Which syntax is better:


REPLACE INTO  ?:privileges (privilege, is_default, section_id) VALUES ('manage_[addon_id_name]', 'Y', 'addons');

DELETE FROM ?:privileges WHERE privilege LIKE ‘manage_[addon_id_name]’

OR

  REPLACE INTO ?:privileges (privilege, is_default, section_id) VALUES ('[addon_id_name]', 'Y', 'addons');

DELETE FROM ?:privileges WHERE privilege IN ('[addon_id_name]');

The first one does not have (for="install"); and the second does not have (editions="MULTIVENDOR,ULTIMATE"). Also the second one does not have (manage_[addon_id_name])

We are using MVE 6.4.2

If the for parameter is not set, install action is used by the system.

Editions can be defined on your own

As for privilege name, I suggest you to use manage_[addon_id_name] as it is more clear from developer point of view

Many Thanks :)

And yeah, Don't forget to add manage_[addon_id_name] to your .po file ;-) ;-) ;-)

And yeah, Don't forget to add manage_[addon_id_name] to your .po file ;-) ;-) ;-)

Thanks alot .. I am really grateful ..

I was wondering if there is any other way to do this without using the addon.xml ..

Let's say that the addon is already installed and not easy to be reinstalled ..

Just update the dB directly and add the language variable.

Thanks all for your help and support ^_^

You can create .sql file in the var/backups directory and restore it from the Administration -> Backup/Restore page