So one day I'm gonna get through an extension without referring back to mark for help...
Is there actually a method at the moment to allow extensions to add permissions per role or just user preferences? I'm sure one of jazzmans extensions used one but I cant seem to find it.. Otherwise i'll just make my own way.
Yep and it is very simple: $Context->Configuration['PERMISSION_WHATEVER'] = '0'; //Can't do it by default
$Context->Dictionary['PERMISSION_WHATEVER'] = 'Can do it';
...
if ( $Context->Session->User->Permission("PERMISSION_WHATEVER") ) Do_It();
Hmm. For some reason i get this:
Fatal error: Call to a member function on a non-object in C:\Program Files\xampp\htdocs\Vanilla\extensions\ForcedWhispers\default.php on line 19
when trying to access that if statement. (i changed the values obviously). i cant work out why though - i must have the context object instansiated surely?
Just a guest, if you have to add the "if.." inside the DiscussionForm_ForceWhisper fonction, it should look like this:if ( $DiscussionForm->Context->Session->User->Permission("PERMISSION_WHATEVER") ) Do_It();
Right. I have it so that you can set each role with whether or not they can whisper to other people and it seems to be working fine. I'm just trying to make the whisper box disappear altogether if they dont have the ability but I'll have to keep kicking it for a while.
Is there anything else it needs to do?
Comments
I've just added a delegate parameter to GetDiscussionForm so you can do it...
$this->DelegateParameters['Discussion'] = &$Discussion;
So, now your function should be something like:
function DiscussionForm_WhisperToMyself(&$DiscussionForm) { $d = &$DiscussionForm->DelegateParameters['Discussion']; $d->WhisperUsername = $DiscussionForm->Context->Session->User->Name; } $Context->AddToDelegate('DiscussionForm', 'DiscussionForm_PreRender', 'DiscussionForm_WhisperToMyself');
I've committed that delegate parameter to svn.
$Context->Configuration['PERMISSION_WHATEVER'] = '0'; //Can't do it by default $Context->Dictionary['PERMISSION_WHATEVER'] = 'Can do it'; ... if ( $Context->Session->User->Permission("PERMISSION_WHATEVER") ) Do_It();
if ( $DiscussionForm->Context->Session->User->Permission("PERMISSION_WHATEVER") ) Do_It();