Alteran Ancient
Well-known member
Heya!
So basically, I wanted to modify my Ignore facility so that users are unable to ignore people considered as extended members of staff, because one or two of my members see fit to abuse the facility to ignore those that are "in power", purely for their rank within the community.
So, I set about making this impossible. What I wanted to do was modify the XenForo_Model_UserIgnore::canIgnoreUser method, but haven't found a way to override this feature with the add-on way to get it to do what I want it to do. I was able to directly edit the method to add my checks, but I'd rather do it via an add-on if I can.
Long story short, this is the re-written method:
How might I extend or override the default method so I can avoid directly tinkering with the source in future?
So basically, I wanted to modify my Ignore facility so that users are unable to ignore people considered as extended members of staff, because one or two of my members see fit to abuse the facility to ignore those that are "in power", purely for their rank within the community.
So, I set about making this impossible. What I wanted to do was modify the XenForo_Model_UserIgnore::canIgnoreUser method, but haven't found a way to override this feature with the add-on way to get it to do what I want it to do. I was able to directly edit the method to add my checks, but I'd rather do it via an add-on if I can.
Long story short, this is the re-written method:
PHP:
public function canIgnoreUser($userId, array $user, &$error = '')
{
$setError = (func_num_args() >= 3);
if (!$userId)
{
return false;
}
if ($user['is_moderator'] || $user['is_admin'])
{
if ($setError)
{
$error = new XenForo_Phrase('staff_members_may_not_be_ignored');
}
return false;
}
//Check against all staff...
$groups = array($user['user_group_id']);
$sGroups = explode(",", $user['secondary_group_ids']);
$groups = array_merge($groups, $sGroups);
if(in_array("6", $groups) || in_array("11", $groups) || in_array("13", $groups) || in_array("15", $groups)){
if ($setError)
{
$error = new XenForo_Phrase('staff_members_may_not_be_ignored');
}
return false;
}
//END Check against all staff...
if ($userId == $user['user_id'])
{
if ($setError)
{
$error = new XenForo_Phrase('you_may_not_ignore_yourself');
}
return false;
}
return true;
}
How might I extend or override the default method so I can avoid directly tinkering with the source in future?