Ejemplo n.º 1
0
 public function NotSpam($LogIDs)
 {
     $this->Permission('Garden.Moderation.Manage');
     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');
 }
   public function Restore($LogIDs) {
      $this->Permission('Garden.Moderation.Manage');

      // Grab the logs.
      $Logs = $this->LogModel->GetIDs($LogIDs);
      foreach ($Logs as $Log) {
         $this->LogModel->Restore($Log);
      }
      $this->LogModel->Recalculate();
   }
 /**
  * Unban a user.
  * @since 2.1
  * @param int $UserID
  * @param array $Options 
  */
 public function UnBan($UserID, $Options = array())
 {
     $User = $this->GetID($UserID, DATASET_TYPE_ARRAY);
     if (!$User) {
         throw NotFoundException();
     }
     if (!$User['Banned']) {
         throw new Gdn_UserException(T("The user isn't banned."));
     }
     // Unban the user.
     $this->SetField($UserID, 'Banned', FALSE);
     // Restore the user's content.
     if (GetValue('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 (GetValue('AddActivity', $Options, TRUE)) {
         $ActivityModel = new ActivityModel();
         $Story = GetValue('Story', $Options, NULL);
         // Notify the moderators of the unban.
         $Activity = array('ActivityType' => 'Ban', 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'ActivityUserID' => $UserID, 'RegardingUserID' => Gdn::Session()->UserID, 'HeadlineFormat' => T('HeadlineFormat.Unban', '{RegardingUserID,You} unbanned {ActivityUserID,you}.'), 'Story' => $Story);
         $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, array('Force' => TRUE));
         $ActivityModel->SaveQueue();
     }
 }
Ejemplo n.º 4
0
 /**
  * Unban a user.
  *
  * @since 2.1
  *
  * @param int $UserID
  * @param array $Options
  */
 public function unBan($UserID, $Options = array())
 {
     $User = $this->getID($UserID, DATASET_TYPE_ARRAY);
     if (!$User) {
         throw notFoundException();
     }
     $Banned = $User['Banned'];
     if (!BanModel::isBanned($Banned, 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_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 = array('ActivityType' => 'Ban', 'NotifyUserID' => ActivityModel::NOTIFY_MODS, 'ActivityUserID' => $UserID, 'RegardingUserID' => Gdn::session()->UserID, 'HeadlineFormat' => t('HeadlineFormat.Unban', '{RegardingUserID,You} unbanned {ActivityUserID,you}.'), 'Story' => $Story, 'Data' => array('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, array('Force' => true));
         $ActivityModel->SaveQueue();
     }
 }