Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How To Make An Addon Availabe For A User-Group Rate Topic   - - - - -

 
  • Jamalla
  • Advanced Member
  • Members
  • Join Date: 23-Sep 17
  • 117 posts

Posted 03 December 2017 - 02:21 PM #1

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



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10551 posts

Posted 03 December 2017 - 08:49 PM #2

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).


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Jamalla
  • Advanced Member
  • Members
  • Join Date: 23-Sep 17
  • 117 posts

Posted 04 December 2017 - 07:36 AM #3

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 ..



 
  • pradeesh_72
  • Member
  • Trial users
  • Join Date: 15-Nov 17
  • 35 posts

Posted 04 December 2017 - 10:05 AM #4

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.



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 17267 posts

Posted 04 December 2017 - 01:40 PM #5

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 


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10551 posts

Posted 05 December 2017 - 01:27 AM #6

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.....


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 17267 posts

Posted 05 December 2017 - 06:13 AM #7

Yes, looking forward for the clarification 


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Jamalla
  • Advanced Member
  • Members
  • Join Date: 23-Sep 17
  • 117 posts

Posted 05 December 2017 - 03:01 PM #8

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 ..



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10551 posts

Posted 05 December 2017 - 06:47 PM #9

Okay, my confusion.  The tags to add to your addon xml would then be:
 
<queries>
  <item for="install">
    INSERT INTO ?:privileges (privilege, is_default, section_id) VALUES ('manage_[YOUR_ADDON_NAME]', 'Y', 'addons')
  </item>
 
  <item for="uninstall">
    DELETE FROM ?:privileges WHERE privilege='manage_[YOUR_ADDON_NAME]'
  </item>
</queries>

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Jamalla
  • Advanced Member
  • Members
  • Join Date: 23-Sep 17
  • 117 posts

Posted 06 December 2017 - 02:33 AM #10

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.?



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 17267 posts

Posted 06 December 2017 - 05:30 AM #11

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Jamalla
  • Advanced Member
  • Members
  • Join Date: 23-Sep 17
  • 117 posts

Posted 06 December 2017 - 07:07 AM #12

Which syntax is better:


<item editions="MULTIVENDOR,ULTIMATE">REPLACE INTO  ?:privileges (privilege, is_default, section_id) VALUES ('manage_[addon_id_name]', 'Y', 'addons');</item>

<item for="uninstall" editions="MULTIVENDOR,ULTIMATE">DELETE FROM ?:privileges WHERE privilege LIKE 'manage_[addon_id_name]'</item>

OR

<item for="install">
  REPLACE INTO ?:privileges (privilege, is_default, section_id) VALUES ('[addon_id_name]', 'Y', 'addons');
</item>
<item for="uninstall">DELETE FROM ?:privileges WHERE privilege IN ('[addon_id_name]');</item>

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



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 17267 posts

Posted 06 December 2017 - 12:49 PM #13

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • Jamalla
  • Advanced Member
  • Members
  • Join Date: 23-Sep 17
  • 117 posts

Posted 07 December 2017 - 01:59 AM #14

Many Thanks :)



 
  • pradeesh_72
  • Member
  • Trial users
  • Join Date: 15-Nov 17
  • 35 posts

Posted 07 December 2017 - 06:06 AM #15

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



 
  • Jamalla
  • Advanced Member
  • Members
  • Join Date: 23-Sep 17
  • 117 posts

Posted 09 December 2017 - 06:08 AM #16

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 ..



 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 10551 posts

Posted 09 December 2017 - 07:41 AM #17

Just update the dB directly and add the language variable.

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • Jamalla
  • Advanced Member
  • Members
  • Join Date: 23-Sep 17
  • 117 posts

Posted 09 December 2017 - 02:23 PM #18

Thanks all for your help and support ^_^



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 17267 posts

Posted 11 December 2017 - 07:03 AM #19

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


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.