public function saveUser($User, $BannedValue, $Ban = false)
{
$BannedValue = (bool) $BannedValue;
$Banned = $User['Banned'];
if (static::isBanned($Banned, self::BAN_AUTOMATIC) === $BannedValue) {
return;
}
$NewBanned = static::setBanned($Banned, $BannedValue, self::BAN_AUTOMATIC);
Gdn::userModel()->setField($User['UserID'], 'Banned', $NewBanned);
$BanningUserID = Gdn::session()->UserID;
// This is true when a session is started and the session user has a new ip address and it matches a banning rule ip address
if ($User['UserID'] == $BanningUserID) {
$BanningUserID = val('InsertUserID', $Ban, Gdn::userModel()->GetSystemUserID());
}
// Add the activity.
$ActivityModel = new ActivityModel();
$Activity = array('ActivityType' => 'Ban', 'ActivityUserID' => $User['UserID'], 'RegardingUserID' => $BanningUserID, 'NotifyUserID' => ActivityModel::NOTIFY_MODS);
$BannedString = $BannedValue ? 'banned' : 'unbanned';
if ($Ban) {
$Activity['HeadlineFormat'] = '{ActivityUserID,user} was ' . $BannedString . ' (based on {Data.BanType}: {Data.BanValue}).';
$Activity['Data'] = arrayTranslate($Ban, array('BanType', 'BanValue'));
$Activity['Story'] = $Ban['Notes'];
$Activity['RecordType'] = 'Ban';
if (isset($Ban['BanID'])) {
$Activity['BanID'] = $Ban['BanID'];
}
} else {
$Activity['HeadlineFormat'] = '{ActivityUserID,user} was ' . $BannedString . '.';
}
$ActivityModel->save($Activity);
}