当前位置: 首页>>代码示例>>PHP>>正文


PHP Events::getFilteredEventsDataProvider方法代码示例

本文整理汇总了PHP中Events::getFilteredEventsDataProvider方法的典型用法代码示例。如果您正苦于以下问题:PHP Events::getFilteredEventsDataProvider方法的具体用法?PHP Events::getFilteredEventsDataProvider怎么用?PHP Events::getFilteredEventsDataProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Events的用法示例。


在下文中一共展示了Events::getFilteredEventsDataProvider方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetFilteredEventsDataProvider

 public function testGetFilteredEventsDataProvider()
 {
     /*
      * This test is marked as skipped until it can be refactored. The test 
      * assumes that Events::getEvents and Events::getFilteredEventsDataProvider
      * return the same data, which may be true in some circumstances but depends
      * on the parameters passed to getEvents, which are currently incorrect. 
      */
     $this->markTestSkipped('Test requires refactor');
     TestingAuxLib::loadX2NonWebUser();
     $testUser = $this->users('testUser');
     TestingAuxLib::suLogin($testUser->username);
     Yii::app()->settings->historyPrivacy = null;
     $profile = Profile::model()->findByAttributes(array('username' => $testUser->username));
     $retVal = Events::getFilteredEventsDataProvider($profile, true, null, false);
     $dataProvider = $retVal['dataProvider'];
     $events = $dataProvider->getData();
     $expectedEvents = Events::getEvents(0, 0, count($events), $profile);
     // I'm not sure this assert is necessary, at the very least it needs
     // more thorough conditions
     // verify events from getData
     $this->assertEquals(Yii::app()->db->createCommand("\n                select id\n                from x2_events\n                where user='testuser' or visibility or (\n                    associationType='User' and associationId=:userId)\n                order by timestamp desc, id desc\n            ")->queryColumn(array(':userId' => $testUser->id)), array_map(function ($event) {
         return $event->id;
     }, $expectedEvents['events']));
     // ensure that getFilteredEventsDataProvider returns same events as getData
     $this->assertEquals(array_map(function ($event) {
         return $event->id;
     }, $expectedEvents['events']), array_map(function ($event) {
         return $event->id;
     }, $events));
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:31,代码来源:EventsTest.php

示例2: actionGet

 /**
  * Obtain all current notifications/events for the current web user.
  */
 public function actionGet()
 {
     if (Yii::app()->user->isGuest) {
         header('Content-type: application/json');
         echo CJSON::encode(array('sessionError' => Yii::t('app', 'Your X2Engine session has expired. You may select "cancel" to ignore this message and recover unsaved data from the current page. Otherwise, you will be redirected to the login page.')));
         Yii::app()->end();
     }
     if (!isset($_GET['lastNotifId'])) {
         // if the client doesn't specify the last
         $_GET['lastNotifId'] = 0;
     }
     // message ID received, send everything
     $notifications = $this->getNotifications($_GET['lastNotifId']);
     $notifCount = 0;
     if (count($notifications)) {
         $notifCount = X2Model::model('Notification')->countByAttributes(array('user' => Yii::app()->user->name), 'createDate < ' . time());
     }
     $chatMessages = array();
     $lastEventId = 0;
     $lastTimestamp = 0;
     // if the client specifies the last message ID received,
     if (isset($_GET['lastEventId']) && is_numeric($_GET['lastEventId'])) {
         // only send newer messages
         $lastEventId = $_GET['lastEventId'];
     }
     if (isset($_GET['lastTimestamp']) && is_numeric($_GET['lastTimestamp'])) {
         $lastTimestamp = $_GET['lastTimestamp'];
     }
     if ($lastEventId == 0) {
         // get page of newest events
         $retVal = Events::getFilteredEventsDataProvider(null, true, null, isset($_SESSSION['filters']));
         $dataProvider = $retVal['dataProvider'];
         $events = $dataProvider->getData();
     } else {
         // get new events
         $limit = null;
         $result = Events::getEvents($lastEventId, $lastTimestamp, $limit);
         $events = $result['events'];
     }
     $i = count($events) - 1;
     for ($i; $i > -1; --$i) {
         if (isset($events[$i])) {
             $userLink = '<span class="widget-event">' . $events[$i]->user . '</span>';
             $chatMessages[] = array((int) $events[$i]->id, (int) $events[$i]->timestamp, $userLink, $events[$i]->getText(array('truncated' => true)), Formatter::formatFeedTimestamp($events[$i]->timestamp));
         }
     }
     if (!empty($notifications) || !empty($chatMessages)) {
         header('Content-type: application/json');
         echo CJSON::encode(array('notifCount' => $notifCount, 'notifData' => $notifications, 'chatData' => $chatMessages));
     }
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:54,代码来源:NotificationsController.php

示例3: testGetFilteredEventsDataProvider

 public function testGetFilteredEventsDataProvider()
 {
     TestingAuxLib::loadX2NonWebUser();
     $testUser = $this->users('testUser');
     TestingAuxLib::suLogin($testUser->username);
     Yii::app()->settings->historyPrivacy = null;
     $profile = Profile::model()->findByAttributes(array('username' => $testUser->username));
     $retVal = Events::getFilteredEventsDataProvider($profile, true, null, false);
     $dataProvider = $retVal['dataProvider'];
     $events = $dataProvider->getData();
     $expectedEvents = Events::getEvents(0, 0, count($events), $profile);
     // verify events from getData
     $this->assertEquals(Yii::app()->db->createCommand("\n                select id\n                from x2_events\n                where user='testuser' or visibility or (\n                    associationType='User' and associationId=:userId)\n                order by timestamp desc, id desc\n            ")->queryColumn(array(':userId' => $testUser->id)), array_map(function ($event) {
         return $event->id;
     }, $expectedEvents['events']));
     // ensure that getFilteredEventsDataProvider returns same events as getData
     $this->assertEquals(array_map(function ($event) {
         return $event->id;
     }, $expectedEvents['events']), array_map(function ($event) {
         return $event->id;
     }, $events));
 }
开发者ID:shayanyi,项目名称:CRM,代码行数:22,代码来源:EventsTest.php

示例4: getActivityFeedViewParams

 public function getActivityFeedViewParams($id, $publicProfile)
 {
     Events::deleteOldEvents();
     $isMyProfile = !$publicProfile && $id === Yii::app()->params->profile->id;
     $profile = $this->loadModel($id);
     if (!Yii::app()->request->isAjaxRequest || Yii::app()->params->isMobileApp) {
         $_SESSION['lastDate'] = 0;
         unset($_SESSION['lastEventId']);
     }
     unset($_SESSION['feed-condition']);
     unset($_SESSION['feed-condition-params']);
     if (!isset($_GET['filters'])) {
         unset($_SESSION['filters']);
     }
     if (isset(Yii::app()->params->profile->defaultFeedFilters)) {
         $_SESSION['filters'] = json_decode(Yii::app()->params->profile->defaultFeedFilters, true);
     }
     $filters = null;
     $filtersOn = false;
     if (isset($_GET['filters'])) {
         $filters = $_GET;
         if ($_GET['filters']) {
             $filtersOn = true;
         }
     }
     $retVal = Events::getFilteredEventsDataProvider($profile, $isMyProfile, $filters, $filtersOn);
     $dataProvider = $retVal['dataProvider'];
     $lastTimestamp = $retVal['lastTimestamp'];
     $lastId = $retVal['lastId'];
     $data = $dataProvider->getData();
     if (isset($data[count($data) - 1])) {
         $firstId = $data[count($data) - 1]->id;
     } else {
         $firstId = 0;
     }
     if ($isMyProfile) {
         $users = User::getUserIds();
     } else {
         $users = array($profile->id => $profile->fullName);
     }
     $_SESSION['firstFlag'] = true;
     $stickyDataProvider = new CActiveDataProvider('Events', array('criteria' => array('condition' => 'sticky=1', 'order' => 'timestamp DESC, id DESC'), 'pagination' => array('pageSize' => 20)));
     $_SESSION['stickyFlag'] = false;
     $userModels = User::model()->active()->findAll();
     return array('model' => $profile, 'profileId' => $profile->id, 'isMyProfile' => $isMyProfile, 'dataProvider' => $dataProvider, 'users' => $users, 'lastEventId' => !empty($lastId) ? $lastId : 0, 'firstEventId' => !empty($firstId) ? $firstId : 0, 'lastTimestamp' => $lastTimestamp, 'stickyDataProvider' => $stickyDataProvider, 'userModels' => $userModels);
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:46,代码来源:ProfileController.php


注:本文中的Events::getFilteredEventsDataProvider方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。