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

Lack of Interest Show Actionbuttons even if user have no permission

Discussion in 'Closed Suggestions' started by xf_phantom, Aug 22, 2013.

  1. xf_phantom

    xf_phantom Well-Known Member

    Sometimes, it would be really usefull, if i could show "post a new thread", "start a new conversation" and the "post reply" button, even if the user have no permission, just to be able to show him custom error messages, e.g. that he would be able to do this, if he would join the premium usergroup.

    The accentuation is on "SOMETIMES" ;) If i don't sell premiumaccounts or anything else, i don't care if they see the buttons or not, then i would even prefer to hide it
    Maybe as option?!
     
  2. xf_phantom

    xf_phantom Well-Known Member

    Just an idea without any big code changes, without new methods and without backward incompability :)

    Code:
    public function canPostThreadInForum(array $forum, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null, $for=null)
       {
         $this->standardizeViewingUserReferenceForNode($forum['node_id'], $viewingUser, $nodePermissions);
    
         if (empty($forum['allow_posting']))
         {
           $errorPhraseKey = 'you_may_not_perform_this_action_because_forum_does_not_allow_posting';
           return false;
         }
    
         return XenForo_Permission::hasContentPermission($nodePermissions, 'postThread');
       }
    
    
    controller:
    Code:
    'canPostThread' => $forumModel->canPostThreadInForum($forum,'',null,null,'createThreadButton'),
    

    Code:
    My_Model extends XFCP_My_Model{
    public function canPostThreadInForum(array $forum, &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null, $for=null)
       {
        if (isset($for) && $for == 'createThreadButton')
    
    {
    return true;
    }
    return parent::canPostThreadInForum............
    }
    

    ATM I would have to use the registry or $GLOBALS, set the value in the controller, test in the model if it's set, but it could couse conflicts between addons from different coders, because of the different methods.
    This would be much easier with an "official" extraparameter
     

Share This Page