public function ban($UserID, $Options)
{
$User = $this->getID($UserID);
$Banned = val('Banned', $User, 0);
$this->setField($UserID, 'Banned', BanModel::setBanned($Banned, true, BanModel::BAN_MANUAL));
$LogID = false;
if (val('DeleteContent', $Options)) {
$Options['Log'] = 'Ban';
$LogID = $this->deleteContent($UserID, $Options);
}
if ($LogID) {
$this->saveAttribute($UserID, 'BanLogID', $LogID);
}
$this->EventArguments['UserID'] = $UserID;
$this->EventArguments['Options'] = $Options;
$this->fireEvent('Ban');
if (val('AddActivity', $Options, true)) {
switch (val('Reason', $Options, '')) {
case '':
$Story = null;
break;
case 'Spam':
$Story = t('Banned for spamming.');
break;
case 'Abuse':
$Story = t('Banned for being abusive.');
break;
default:
$Story = $Options['Reason'];
break;
}
$Activity = ['ActivityType' => 'Ban', 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'ActivityUserID' => $UserID, 'RegardingUserID' => Gdn::session()->UserID, 'HeadlineFormat' => t('HeadlineFormat.Ban', '{RegardingUserID,You} banned {ActivityUserID,you}.'), 'Story' => $Story, 'Data' => ['LogID' => $LogID]];
$ActivityModel = new ActivityModel();
$ActivityModel->save($Activity);
}
}