LogModel::getIDs PHP Method

getIDs() public method

Get the log rows by array of IDs.
public getIDs ( int[] | string $IDs ) : array
$IDs int[] | string And array or CSV of IDs.
return array Returns an array of log rows.
    public function getIDs($IDs)
    {
        if (is_string($IDs)) {
            $IDs = explode(',', $IDs);
        }
        $Logs = Gdn::sql()->select('*')->from('Log')->whereIn('LogID', $IDs)->get()->resultArray();
        foreach ($Logs as &$Log) {
            $Log['Data'] = dbdecode($Log['Data']);
            if (!is_array($Log['Data'])) {
                $Log['Data'] = [];
            }
        }
        return $Logs;
    }

Usage Example

 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');
 }