本文整理汇总了PHP中LogModel::restore方法的典型用法代码示例。如果您正苦于以下问题:PHP LogModel::restore方法的具体用法?PHP LogModel::restore怎么用?PHP LogModel::restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogModel
的用法示例。
在下文中一共展示了LogModel::restore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notSpam
public function notSpam($LogIDs)
{
$this->permission(array('Garden.Moderation.Manage', 'Moderation.Spam.Manage'), false);
if (!$this->Request->isPostBack()) {
throw permissionException('Javascript');
}
$Logs = array();
// Verify the appropriate users.
$UserIDs = $this->Form->getFormValue('UserID', array());
if (!is_array($UserIDs)) {
$UserIDs = array();
}
foreach ($UserIDs as $UserID) {
Gdn::userModel()->setField($UserID, 'Verified', true);
$Logs = array_merge($Logs, $this->LogModel->getWhere(array('Operation' => 'Spam', 'RecordUserID' => $UserID)));
}
// Grab the logs.
$Logs = array_merge($Logs, $this->LogModel->getIDs($LogIDs));
// try {
foreach ($Logs as $Log) {
$this->LogModel->restore($Log);
}
// } catch (Exception $Ex) {
// $this->Form->addError($Ex->getMessage());
// }
$this->LogModel->recalculate();
$this->setData('Complete');
$this->setData('Count', count($Logs));
$this->render('Blank', 'Utility');
}
示例2: unBan
/**
* Unban a user.
*
* @param int $UserID The user to unban.
* @param array $Options Options for the unban.
* @since 2.1
*/
public function unBan($UserID, $Options = [])
{
$User = $this->getID($UserID, DATASET_TYPE_ARRAY);
if (!$User) {
throw notFoundException();
}
$Banned = $User['Banned'];
if (!BanModel::isBanned($Banned, BanModel::BAN_AUTOMATIC | BanModel::BAN_MANUAL)) {
throw new Gdn_UserException(t("The user isn't banned.", "The user isn't banned or is banned by some other function."));
}
// Unban the user.
$NewBanned = BanModel::setBanned($Banned, false, BanModel::BAN_AUTOMATIC | BanModel::BAN_MANUAL);
$this->setField($UserID, 'Banned', $NewBanned);
// Restore the user's content.
if (val('RestoreContent', $Options)) {
$BanLogID = $this->getAttribute($UserID, 'BanLogID');
if ($BanLogID) {
$LogModel = new LogModel();
try {
$LogModel->restore($BanLogID);
} catch (Exception $Ex) {
if ($Ex->getCode() != 404) {
throw $Ex;
}
}
$this->saveAttribute($UserID, 'BanLogID', null);
}
}
// Add an activity for the unbanning.
if (val('AddActivity', $Options, true)) {
$ActivityModel = new ActivityModel();
$Story = val('Story', $Options, null);
// Notify the moderators of the unban.
$Activity = ['ActivityType' => 'Ban', 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'ActivityUserID' => $UserID, 'RegardingUserID' => Gdn::session()->UserID, 'HeadlineFormat' => t('HeadlineFormat.Unban', '{RegardingUserID,You} unbanned {ActivityUserID,you}.'), 'Story' => $Story, 'Data' => ['Unban' => true]];
$ActivityModel->queue($Activity);
// Notify the user of the unban.
$Activity['NotifyUserID'] = $UserID;
$Activity['Emailed'] = ActivityModel::SENT_PENDING;
$Activity['HeadlineFormat'] = t('HeadlineFormat.Unban.Notification', "You've been unbanned.");
$ActivityModel->queue($Activity, false, ['Force' => true]);
$ActivityModel->saveQueue();
}
}