getWhere() публичный Метод

Events: AfterGet.
public getWhere ( array $Where = [], string $orderFields = '', string $orderDirection = '', integer | boolean $Limit = false, integer | boolean $Offset = false ) : Gdn_DataSet
$Where array A filter suitable for passing to Gdn_SQLDriver::Where().
$orderFields string A comma delimited string to order the data.
$orderDirection string One of **asc** or **desc**.
$Limit integer | boolean The database limit.
$Offset integer | boolean The database offset.
Результат Gdn_DataSet SQL results.
 /**
  * Grabs all new notifications and adds them to the sender's inform queue.
  *
  * This method gets called by dashboard's hooks file to display new
  * notifications on every pageload.
  *
  * @since 2.0.18
  * @access public
  *
  * @param Gdn_Controller $Sender The object calling this method.
  */
 public static function informNotifications($Sender)
 {
     $Session = Gdn::session();
     if (!$Session->isValid()) {
         return;
     }
     $ActivityModel = new ActivityModel();
     // Get five pending notifications.
     $Where = array('NotifyUserID' => Gdn::session()->UserID, 'Notified' => ActivityModel::SENT_PENDING);
     // If we're in the middle of a visit only get very recent notifications.
     $Where['DateUpdated >'] = Gdn_Format::toDateTime(strtotime('-5 minutes'));
     $Activities = $ActivityModel->getWhere($Where, 0, 5)->resultArray();
     $ActivityIDs = array_column($Activities, 'ActivityID');
     $ActivityModel->setNotified($ActivityIDs);
     $Sender->EventArguments['Activities'] =& $Activities;
     $Sender->fireEvent('InformNotifications');
     foreach ($Activities as $Activity) {
         if ($Activity['Photo']) {
             $UserPhoto = anchor(img($Activity['Photo'], array('class' => 'ProfilePhotoMedium')), $Activity['Url'], 'Icon');
         } else {
             $UserPhoto = '';
         }
         $Excerpt = Gdn_Format::plainText($Activity['Story']);
         $ActivityClass = ' Activity-' . $Activity['ActivityType'];
         $Sender->informMessage($UserPhoto . Wrap($Activity['Headline'], 'div', array('class' => 'Title')) . Wrap($Excerpt, 'div', array('class' => 'Excerpt')), 'Dismissable AutoDismiss' . $ActivityClass . ($UserPhoto == '' ? '' : ' HasIcon'));
     }
 }
Пример #2
0
 public function getData($Limit = false)
 {
     if (!$Limit) {
         $Limit = $this->Limit;
     }
     $ActivityModel = new ActivityModel();
     $Data = $ActivityModel->getWhere(array('NotifyUserID' => ActivityModel::NOTIFY_PUBLIC), '', '', $Limit, 0);
     $this->ActivityData = $Data;
 }
Пример #3
0
 /**
  * Default activity stream.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $Offset Number of activity items to skip.
  */
 public function index($Filter = false, $Page = false)
 {
     switch (strtolower($Filter)) {
         case 'mods':
             $this->title(t('Recent Moderator Activity'));
             $this->permission('Garden.Moderation.Manage');
             $NotifyUserID = ActivityModel::NOTIFY_MODS;
             break;
         case 'admins':
             $this->title(t('Recent Admin Activity'));
             $this->permission('Garden.Settings.Manage');
             $NotifyUserID = ActivityModel::NOTIFY_ADMINS;
             break;
         case '':
         case 'feed':
             // rss feed
             $Filter = 'public';
             $this->title(t('Recent Activity'));
             $this->permission('Garden.Activity.View');
             $NotifyUserID = ActivityModel::NOTIFY_PUBLIC;
             break;
         default:
             throw notFoundException();
     }
     // Which page to load
     list($Offset, $Limit) = offsetLimit($Page, c('Garden.Activities.PerPage', 30));
     $Offset = is_numeric($Offset) ? $Offset : 0;
     if ($Offset < 0) {
         $Offset = 0;
     }
     // Page meta.
     $this->addJsFile('activity.js');
     $this->addJsFile('spoilers.js');
     $this->addCssFile('spoilers.css');
     if ($this->Head) {
         $this->Head->addRss(url('/activity/feed.rss', true), $this->Head->title());
     }
     // Comment submission
     $Session = Gdn::session();
     $Comment = $this->Form->getFormValue('Comment');
     $Activities = $this->ActivityModel->getWhere(array('NotifyUserID' => $NotifyUserID), '', '', $Limit, $Offset)->resultArray();
     $this->ActivityModel->joinComments($Activities);
     $this->setData('Filter', strtolower($Filter));
     $this->setData('Activities', $Activities);
     $this->addModule('ActivityFilterModule');
     $this->View = 'all';
     $this->render();
 }