LogController::deleteSpam PHP Method

deleteSpam() public method

Delete spam and optionally delete the users.
public deleteSpam ( )
    public function deleteSpam()
    {
        if (!Gdn::request()->isAuthenticatedPostBack(true)) {
            throw new Exception('Requires POST', 405);
        }
        $this->permission(array('Garden.Moderation.Manage', 'Moderation.Spam.Manage'), false);
        $LogIDs = Gdn::request()->post('LogIDs');
        $LogIDs = explode(',', $LogIDs);
        // Ban the appropriate users.
        $UserIDs = $this->Form->getFormValue('UserID', array());
        if (!is_array($UserIDs)) {
            $UserIDs = array();
        }
        if (!empty($UserIDs)) {
            // Grab the rest of the log entries.
            $OtherLogIDs = $this->LogModel->getWhere(array('Operation' => 'Spam', 'RecordUserID' => $UserIDs));
            $OtherLogIDs = array_column($OtherLogIDs, 'LogID');
            $LogIDs = array_merge($LogIDs, $OtherLogIDs);
            foreach ($UserIDs as $UserID) {
                Gdn::userModel()->ban($UserID, array('Reason' => 'Spam', 'DeleteContent' => true, 'Log' => true));
            }
        }
        // Grab the logs.
        $this->LogModel->delete($LogIDs);
        $this->render('Blank', 'Utility');
    }