public function actionRespond()
 {
     $calendarEntry = $this->getCalendarEntry(Yii::$app->request->get('id'));
     if ($calendarEntry == null) {
         throw new HttpException('404', Yii::t('CalendarModule.base', "Event not found!"));
     }
     if ($calendarEntry->canRespond()) {
         $calendarEntryParticipant = CalendarEntryParticipant::findOne(['calendar_entry_id' => $calendarEntry->id, 'user_id' => Yii::$app->user->id]);
         if ($calendarEntryParticipant == null) {
             $calendarEntryParticipant = new CalendarEntryParticipant();
             $calendarEntryParticipant->user_id = Yii::$app->user->id;
             $calendarEntryParticipant->calendar_entry_id = $calendarEntry->id;
         }
         $calendarEntryParticipant->participation_state = (int) Yii::$app->request->get('type');
         $calendarEntryParticipant->save();
     }
     return $this->redirect($this->contentContainer->createUrl('view', array('id' => $calendarEntry->id)));
 }
Ejemplo n.º 2
0
 public function run()
 {
     // Not supported yet
     if (Yii::$app->user->isGuest) {
         return;
     }
     $calendarEntryParticipant = CalendarEntryParticipant::find()->where(array('user_id' => Yii::$app->user->id, 'calendar_entry_id' => $this->contentObject->id))->one();
     return $this->render('wallEntry', array('calendarEntry' => $this->contentObject, 'calendarEntryParticipant' => $calendarEntryParticipant));
 }
 public function up()
 {
     // Namespace Classes
     $this->renameClass('CalendarEntry', CalendarEntry::className());
     $this->renameClass('CalendarEntryParticipant', CalendarEntryParticipant::className());
     // Merge EntryCreated to ContentCreated Activity
     $this->update('activity', ['class' => 'humhub\\modules\\content\\activities\\ContentCreated'], ['class' => 'EntryCreated']);
     $this->update('activity', ['class' => \humhub\modules\calendar\activities\ResponseAttend::className()], ['class' => 'EntryResponseAttend']);
     $this->update('activity', ['class' => \humhub\modules\calendar\activities\ResponseDeclined::className()], ['class' => 'EntryResponseDeclined']);
     $this->update('activity', ['class' => \humhub\modules\calendar\activities\ResponseMaybe::className()], ['class' => 'EntryResponseMaybe']);
 }
 public function run()
 {
     // Count statitics of participants
     $countAttending = CalendarEntryParticipant::find()->where(array('calendar_entry_id' => $this->calendarEntry->id, 'participation_state' => CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED))->count();
     $countMaybe = CalendarEntryParticipant::find()->where(array('calendar_entry_id' => $this->calendarEntry->id, 'participation_state' => CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE))->count();
     $countDeclined = CalendarEntryParticipant::find()->where(array('calendar_entry_id' => $this->calendarEntry->id, 'participation_state' => CalendarEntryParticipant::PARTICIPATION_STATE_DECLINED))->count();
     /*        $participants = User::find();
             $participants->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' => $this->calendarEntry->id
             ]);
             $participants->where('calendar_entry_participant.id IS NOT NULL');*/
     return $this->render('participants', array('calendarEntry' => $this->calendarEntry, 'countAttending' => $countAttending, 'countMaybe' => $countMaybe, 'countDeclined' => $countDeclined));
 }
 public function getParticipationState(User $user = null)
 {
     if ($user == null) {
         $user = Yii::$app->user->getIdentity();
     }
     $participant = CalendarEntryParticipant::findOne(['user_id' => $user->id, 'calendar_entry_id' => $this->id]);
     if ($participant !== null) {
         return $participant->participation_state;
     }
     return 0;
 }