Example #1
0
 /**
  * Returns a user list which contains all users who likes it
  */
 public function actionUserList()
 {
     $query = \humhub\modules\user\models\User::find();
     $query->leftJoin('like', 'like.created_by=user.id');
     $query->where(['like.object_id' => $this->contentId, 'like.object_model' => $this->contentModel]);
     $query->orderBy('like.created_at DESC');
     $title = Yii::t('LikeModule.controllers_LikeController', "<strong>Users</strong> who like this");
     return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title]));
 }
Example #2
0
 /**
  * Returns an list of all friends of a user
  */
 public function actionPopup()
 {
     $user = User::findOne(['id' => Yii::$app->request->get('userId')]);
     if ($user === null) {
         throw new \yii\web\HttpException(404, 'Could not find user!');
     }
     $query = Friendship::getFriendsQuery($user);
     $title = '<strong>' . Yii::t('FriendshipModule.base', "Friends") . '</strong>';
     return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title]));
 }
 public function actionUserList()
 {
     $calendarEntry = $this->getCalendarEntry(Yii::$app->request->get('id'));
     if ($calendarEntry == null) {
         throw new HttpException('404', Yii::t('CalendarModule.base', "Event not found!"));
     }
     $state = Yii::$app->request->get('state');
     $query = User::find();
     $query->leftJoin('calendar_entry_participant', 'user.id=calendar_entry_participant.user_id AND calendar_entry_participant.calendar_entry_id=:calendar_entry_id AND calendar_entry_participant.participation_state=:state', [':calendar_entry_id' => $calendarEntry->id, ':state' => $state]);
     $query->where('calendar_entry_participant.id IS NOT NULL');
     $title = "";
     if ($state == CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED) {
         $title = Yii::t('CalendarModule.base', 'Attending users');
     } elseif ($state == CalendarEntryParticipant::PARTICIPATION_STATE_DECLINED) {
         $title = Yii::t('CalendarModule.base', 'Declining users');
     } elseif ($state == CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE) {
         $title = Yii::t('CalendarModule.base', 'Maybe attending users');
     }
     return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title]));
 }
 /**
  * Returns an user list which are space members
  */
 public function actionMembersList()
 {
     $title = Yii::t('SpaceModule.controllers_MembershipController', "<strong>Members</strong>");
     return $this->renderAjaxContent(UserListBox::widget(['query' => Membership::getSpaceMembersQuery($this->getSpace()), 'title' => $title]));
 }
 /**
  * Returns an user list which are space members
  */
 public function actionMembersList()
 {
     $query = User::find();
     $query->join('LEFT JOIN', 'space_membership', 'space_membership.user_id=user.id');
     $query->andWhere(['space_membership.status' => Membership::STATUS_MEMBER]);
     $query->andWhere(['user.status' => User::STATUS_ENABLED]);
     $query->andWhere(['space_id' => $this->getSpace()->id]);
     $query->orderBy(['space_membership.group_id' => SORT_DESC]);
     $title = Yii::t('SpaceModule.controllers_MembershipController', "<strong>Members</strong>");
     return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title]));
 }
 public function actionFollowedUsersList()
 {
     $query = User::find();
     $query->leftJoin('user_follow', 'user.id=user_follow.object_id and object_model=:userClass and user_follow.user_id=:userId', [':userClass' => User::className(), ':userId' => $this->getUser()->id]);
     $query->orderBy(['user_follow.id' => SORT_DESC]);
     $query->andWhere(['IS NOT', 'user_follow.id', new \yii\db\Expression('NULL')]);
     $query->active();
     $title = Yii::t('UserModule.widgets_views_userFollower', '<strong>Following</strong> user');
     return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title]));
 }
 /**
  * Returns a user list including the pagination which contains all results
  * for an answer
  */
 public function actionUserListResults()
 {
     $poll = $this->getPollByParameter();
     $answerId = (int) Yii::$app->request->get('answerId', '');
     $answer = PollAnswer::findOne(['id' => $answerId]);
     if ($answer == null || $poll->id != $answer->poll_id) {
         throw new HttpException(401, Yii::t('PollsModule.controllers_PollController', 'Invalid answer!'));
     }
     $query = User::find();
     $query->leftJoin('poll_answer_user', 'poll_answer_user.created_by=user.id');
     $query->andWhere('poll_answer_user.poll_id IS NOT NULL');
     $query->andWhere('poll_answer_user.poll_answer_id = ' . $answerId);
     $query->orderBy('poll_answer_user.created_at DESC');
     $title = Yii::t('PollsModule.controllers_PollController', "Users voted for: <strong>{answer}</strong>", array('{answer}' => Html::encode($answer->answer)));
     return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title]));
 }