Exemple #1
0
 /**
  * Callback to validate module database records.
  *
  * @param Event $event
  */
 public static function onIntegrityCheck($event)
 {
     $integrityController = $event->sender;
     $integrityController->showTestHeadline("Content Module - Wall Entries " . models\WallEntry::find()->count() . " entries)");
     foreach (models\WallEntry::find()->joinWith('content')->each() as $w) {
         if ($w->content === null) {
             if ($integrityController->showFix("Deleting wall entry id " . $w->id . " without assigned wall entry!")) {
                 $w->delete();
             }
         }
     }
     $integrityController->showTestHeadline("Content Objects (" . Content::find()->count() . " entries)");
     foreach (Content::find()->all() as $content) {
         if ($content->user == null) {
             if ($integrityController->showFix("Deleting content id " . $content->id . " of type " . $content->object_model . " without valid user!")) {
                 $content->delete();
             }
         }
         if ($content->getPolymorphicRelation() == null) {
             if ($integrityController->showFix("Deleting content id " . $content->id . " of type " . $content->object_model . " without valid content object!")) {
                 $content->delete();
             }
         }
         if ($content->space_id != "" && $content->space == null) {
             if ($integrityController->showFix("Deleting content id " . $content->id . " without valid space!")) {
                 $content->delete();
             }
         }
     }
 }
 /**
  * Counts all new Items for this membership
  */
 public function countNewItems($since = "")
 {
     $query = WallEntry::find()->joinWith('content');
     $query->where(['!=', 'content.object_model', Activity::className()]);
     $query->andWhere(['wall_entry.wall_id' => $this->space->wall_id]);
     $query->andWhere(['>', 'wall_entry.created_at', $this->last_visit]);
     $count = $query->count();
     $count += Comment::find()->where(['space_id' => $this->space_id])->andWhere(['>', 'created_at', $this->last_visit])->count();
     return $count;
 }
 /**
  * On given WallEntryId redirect the user to the corresponding content object.
  *
  * This is mainly used by ActivityStream or Permalinks.
  */
 public function actionWallEntry()
 {
     // Id of wall entry
     $id = Yii::$app->request->get('id', "");
     $wallEntry = WallEntry::find()->joinWith('content')->where(['wall_entry.id' => $id])->one();
     if ($wallEntry != null) {
         $obj = $wallEntry->content;
         // Type of IContent
         if ($obj) {
             return $this->redirect($obj->container->createUrl(null, array('wallEntryId' => $id)));
         }
     }
     throw new HttpException(404, Yii::t('ContentModule.controllers_PermaController', 'Could not find requested permalink!'));
 }
Exemple #4
0
 public function init()
 {
     $this->activeQuery = WallEntry::find();
     // If no user is set, take current if logged in
     if (!Yii::$app->user->isGuest && $this->user == null) {
         $this->user = Yii::$app->user->getIdentity();
     }
     // Read parameters
     if (!Yii::$app->request->isConsoleRequest) {
         $from = Yii::$app->getRequest()->get('from', 0);
         if ($from != 0) {
             $this->from = (int) $from;
         }
         /**
          * Sorting
          */
         $sort = Yii::$app->getRequest()->get('sort', Yii::$app->getModule('content')->settings->get('stream.defaultSort'));
         if ($sort === static::SORT_CREATED_AT || $sort === static::SORT_UPDATED_AT) {
             $this->sort = $sort;
         } else {
             $this->sort = static::SORT_CREATED_AT;
         }
         $limit = Yii::$app->getRequest()->get('limit', '');
         if ($limit != "" && $limit <= self::MAX_LIMIT) {
             $this->limit = $limit;
         }
         $mode = Yii::$app->getRequest()->get('mode', '');
         if ($mode != "" && ($mode == self::MODE_ACTIVITY || $mode == self::MODE_NORMAL)) {
             $this->mode = $mode;
         }
         foreach (explode(',', Yii::$app->getRequest()->get('filters', "")) as $filter) {
             $this->filters[] = trim($filter);
         }
     }
     $this->setupCriteria();
     $this->setupFilters();
 }
Exemple #5
0
 public function init()
 {
     $this->activeQuery = WallEntry::find();
     // If no user is set, take current if logged in
     if (!Yii::$app->user->isGuest && $this->user == null) {
         $this->user = Yii::$app->user->getIdentity();
     }
     // Read parameters
     if (!Yii::$app->request->isConsoleRequest) {
         $from = Yii::$app->getRequest()->get('from', 0);
         if ($from != 0) {
             $this->from = $from;
         }
         $sort = Yii::$app->getRequest()->get('sort', '');
         if ($sort != "") {
             $this->sort = $sort;
         }
         $limit = Yii::$app->getRequest()->get('limit', '');
         if ($limit != "" && $limit <= self::MAX_LIMIT) {
             $this->limit = $limit;
         }
         $mode = Yii::$app->getRequest()->get('mode', '');
         if ($mode != "" && ($mode == self::MODE_ACTIVITY || $mode == self::MODE_NORMAL)) {
             $this->mode = $mode;
         }
         foreach (explode(',', Yii::$app->getRequest()->get('filters', "")) as $filter) {
             $this->filters[] = trim($filter);
         }
     }
     $this->setupCriteria();
     $this->setupFilters();
 }
Exemple #6
0
 /**
  * Creates a list of sticked content objects of the wall
  *
  * @return Int
  */
 public function countStickedItems()
 {
     $wallId = $this->container->wall_id;
     return WallEntry::find()->joinWith('content')->where(['wall_entry.wall_id' => $wallId, 'content.sticked' => 1])->count();
 }