1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Permission logic

Discussion in 'XenForo Development Discussions' started by Brogan, Nov 6, 2013.

  1. Brogan

    Brogan XenForo Moderator Staff Member

    My first dev' question so go easy.

    The add-on I'm working on has three basic permissions: can feature a thread, can edit a featured thread, can unfeature a thread.

    These permission options/links will be added to the thread tools dropdown.

    So far I have this*:
    <xen:if is="!{$FeaturedThread}">
        <xen:if is="{$canFeatureThread}">
            <li><a href="{xen:link 'threads/feature-thread', $thread}" class="OverlayTrigger">{xen:phrase cta_featured_threads_feature_thread}</a></li>
    <xen:else />
        <xen:if is="{$canEditFeaturedThread}">
            <li><a href="{xen:link 'threads/edit-featured-thread', $thread}" class="OverlayTrigger">{xen:phrase cta_featured_threads_edit_featured_thread}</a></li>
        <xen:if is="{$canUnfeatureThread}">
            <li><a href="{xen:link 'threads/unfeature-thread', $thread}" class="OverlayTrigger">{xen:phrase cta_featured_threads_unfeature_thread}</a></li>
    Does that look OK?

    Obviously only threads which are currently featured can be edited or unfeatured.

    I can't decide whether the initial check should be positive or negative, but I guess it doesn't really make a lot of difference.

    Is that the most efficient method?

    I should add that there are actually separate permissions for own thread and any thread, but that will be handled within php.

    *Thanks to Chris for his input.
    Last edited: Nov 6, 2013
  2. Jeremy

    Jeremy Well-Known Member

    Well, $canEditThread -- probably want it to be $canEditFeaturedThread.

    However, have you attached these variables to the template? Other than that, looks good.
    Brogan likes this.
  3. Brogan

    Brogan XenForo Moderator Staff Member

    Nice spot J, I have edited that accordingly.
    This is just related to the template mod for the thread_view template so the rest will follow.
  4. Jeremy

    Jeremy Well-Known Member

    Well, you'll need to attach them via PHP in your listeners (when extending the controller). As long as you've done that / know you have to do that, it looks correct to me.
  5. Chris D

    Chris D XenForo Developer Staff Member

    Yep. I still concur it looks good :)

    Seeing Brogan begin to get into add-ons makes me happy :) You'll do a grand job, Paul.
    Amaury, Brogan and Jeremy like this.
  6. Jeremy

    Jeremy Well-Known Member

    Pretty soon he'll be writing circles around all of us...! Paul also picks up stuff faster than I think I've seen anybody pick it up recently.
    Amaury likes this.

Share This Page