SugarClub
SugarClub
  • User
  • Site
  • Search
  • User
SugarClub
SugarClub
  • User
  • Site
  • Search
  • User
  • Groups & Discussions
    Groups & Discussions
    • Product Forums
    • User Groups
      Professional, Industry, Language
    • Get Involved
      Learn how to become a Raving Fan
    • Social Club
      Live, interactive, virtual meetups with other Sugar customers and Sugar’s Subject Matter experts!
    • Leadership Lounge
    • Adoption
    • Developers
      Visit DevClub, the SugarClub group for Sugar Developers
      Developers
      • DevClub
      • Mobile Developers
      • Developer Builds
        Supplemental access level required. Inquiries: developers@sugarcrm.com
  • Product Information
    Product Information
    • Release Central
    • Product Documentation »
    • Product Update Blogs
    • Customer Stories »
  • Training & Certification
    Training & Certification
    • Training & Certification Home
      Live & On-Demand classes, Quick Videos, Sugar Certifications, and more!
    • Quick Videos
    • My SugarU Dashboard »
    • SugarU News & Updates
  • Calendar
  • News
    News
    • Sugar News
    • SugarCRM.com News »
    • Dev Blog
    • SugarOutfitters Blog
  • Help
    Help
    • Contact Us
    • Case Portal »
    • Working with Sugar Support »
    • SugarClub Help & Instructions
  • New to SugarClub?
  • More from Sugar
    More from Sugar
    • DevClub
    • PartnerClub
    • Support
    • SugarOutfitters Marketplace
    • sugarcrm.com
  • DevClub
  • PartnerClub
  • Support
  • SugarOutfitters Marketplace
  • sugarcrm.com
DevClub
DevClub
Dev Tutorials HOW TO: enforce ACL on Tags
  • Dev Blog
  • Answers & Best Practices
  • Developer On-boarding
  • Dev Tutorials
  • Developer Events
  • Event Recaps
  • Members
  • Developer Suggestions
  • Sub-Groups
  • More
  • Cancel
  • New
Click here to join this group and curate your SugarClub experience.
  • +On-Boarding Framework
  • +Customization Guides
  • +UI Redesign Technical Guide
  • +Automated PHP Compatibility Tool
  • Did you know? Copying related records is a breeze!
  • How to write code for SugarCloud webinar Q&A
  • HOW TO: enforce ACL on Tags
  • Programatically manage Dropdown List
  • Remove custom fields created via package installation
  • Sugar Developer Tools
  • Tutorial:  How to register custom platforms in Sugar instances via Platform extension
  • Adding a google reCAPTCHA in a Web-to-Lead form
  • Sugar Developer Blog Style Guide

HOW TO: enforce ACL on Tags

As some may have noticed the Tags module in 7.7.x can be locked down via ACL but users whose Roles deny them Edit permissions on that module can still create tags. I am told this is as intended in the design.

What if you want to avoid tag overload and control WHO can create new tags while allowing everyone to use those tags? Simple: set your permissions in ACL, and enforce them in the tag field type by extending it.

Note the if statement added at the comment line: //CUSTOM: check ACL

custom/clients/base/fields/tag/tag.js

({
    extendsFrom: 'TagField',
    initialize: function(options) {
        this._super('initialize', [options]);
    },
    _createSearchChoice: function(term, results) {
        this._super('_createSearchChoice', [term, results]);
        // If tag is for filter, don't allow new choices to be selected
        if (this.view.action === 'filter-rows') {
            return false;
        }

        // Trim up the term for sanity sake
        term = $.trim(term);

        // Check previously found results to see tag exists with different casing
        if (results && results.length) {
            if (_.find(results, function(tag) {
                return tag.text.toLowerCase() === term.toLowerCase();
            })) {
                return false;
            }
        }

        // Check if input is empty after trim
        if (term === '') {
            return false;
        }

        // Check for existence amongst tags that exist but haven't been saved yet
        if (this.checkExistingTags(term)) {
            return false;
        }
        //CUSTOM: check ACL
        if(app.acl.hasAccess('edit','Tags')){
          return {
            id: term,
            text: term + ' ' + app.lang.get('LBL_TAG_NEW_TAG'),
            locked: false,
            newTag: true
          };
        }else{
          return false;
        }
    },
})

 hope you find this useful.

FrancescaS

  • tag
  • acl
  • sugar 7.x
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
Parents
  • Frédéric Rinaldi
    Frédéric Rinaldi over 1 year ago

    Hi Francesca Shiekh

    this is definitely a must to have for many of my customers.

    Many thanks.

    Fred

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More Actions
    • Cancel
Comment
  • Frédéric Rinaldi
    Frédéric Rinaldi over 1 year ago

    Hi Francesca Shiekh

    this is definitely a must to have for many of my customers.

    Many thanks.

    Fred

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More Actions
    • Cancel
Children
No Data
Related
Recommended