Masetrix
Well-known member
Hi,
I have to adapt an addon and would like to check in the code below whether the current user, who already has the group right to change the topic title, is also the owner of the topic that he wants to work on ... If not, "Exit - Not your thread ".
Any help is welcome
I have to adapt an addon and would like to check in the code below whether the current user, who already has the group right to change the topic title, is also the owner of the topic that he wants to work on ... If not, "Exit - Not your thread ".
Code:
class Thread extends XFCP_Thread
{
public function actionEditThreadTitle(ParameterBag $params)
{
// get visitor
$visitor = \XF::visitor();
// check for user group permission
if (!$visitor->hasPermission('editThreadTitle', 'view'))
{
return $parent;
}
// get thread
$thread = $this->assertViewableThread($params->thread_id);
// get title
$title = $thread['title'];
// prepare viewParams
$viewParams = [
'thread' => $thread,
'title' => $title
];
// send to template
return $this->view('My\EditThreadTitle:EditThreadTitle', 'My_edit_thread_title', $viewParams);
}
Any help is welcome