Permission logic

Paul B

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*:
Code:
<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:if>
<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>
    <xen:if is="{$canUnfeatureThread}">
        <li><a href="{xen:link 'threads/unfeature-thread', $thread}" class="OverlayTrigger">{xen:phrase cta_featured_threads_unfeature_thread}</a></li>
    </xen:if>
</xen:if>
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:
Well, $canEditThread -- probably want it to be $canEditFeaturedThread.

However, have you attached these variables to the template? Other than that, looks good.
 
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.
 
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.
 
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.
 
Back
Top Bottom