Earl
Well-known member
I'm trying to add a custom inline mod option
@Snog helped me with this code
https://xenforo.com/community/threa...core-methods-with-addons.119132/#post-1086469
but when the code gets executed, I get the error
( ! ) Fatal error: Call to undefined method MyAddon_Model_Post::canDeleteRating() in /var/www/html/library/MyAddon/Model/Post.php on line 15
so the problem in this line:
and its looking for a method in my addon, which has defined in the original post ratings addon:
I need to run the check : "$this->canDeleteRating($post, $thread, $forum, $null, $nodePermissions, $viewingUser"
before I add the option.
Please help..
@Snog helped me with this code
https://xenforo.com/community/threa...core-methods-with-addons.119132/#post-1086469
Extend the library/XenForo/Model/Post.php class and use something like this to extend the function...
Code:public function addInlineModOptionToPost(array &$post, array $thread, array $forum, array $nodePermissions = null, array $viewingUser = null) { $parentResponse = parent::addInlineModOptionToPost($post, $thread, $forum, $nodePermissions, $viewingUser) $parentResponse['delete_rating'] = false; if ($this->canDeleteRating($post, $thread, $forum, $null, $nodePermissions, $viewingUser)) { $parentResponse['delete_rating'] = true; } return $parentResponse; }
but when the code gets executed, I get the error
( ! ) Fatal error: Call to undefined method MyAddon_Model_Post::canDeleteRating() in /var/www/html/library/MyAddon/Model/Post.php on line 15
so the problem in this line:
Code:
if ($this->canDeleteRating($post, $thread, $forum, $null, $nodePermissions, $viewingUser))
Code:
class Dark_PostRating_Model extends XenForo_Model
{
public function canDeleteRating(array $post, array $thread, array $forum = array(), &$errorPhraseKey = '', array $nodePermissions = null, array $viewingUser = null)
{
$this->standardizeViewingUserReferenceForNode($thread['node_id'], $viewingUser, $nodePermissions);
if (!$viewingUser['user_id'])
{
$errorPhraseKey = 'login_required';
return false;
}
if ($post['message_state'] != 'visible')
{
return false;
}
return XenForo_Permission::hasContentPermission($nodePermissions, 'deleteRating');
}
}
I need to run the check : "$this->canDeleteRating($post, $thread, $forum, $null, $nodePermissions, $viewingUser"
before I add the option.
Please help..
Last edited: