Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 11 |
CRAP | |
0.00% |
0 / 400 |
| CronController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 11 |
3422.00 | |
0.00% |
0 / 400 |
| behaviors | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 15 |
|||
| actionDo | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 22 |
|||
| taskNewMeetingSurveyReminder | |
0.00% |
0 / 1 |
210.00 | |
0.00% |
0 / 67 |
|||
| taskNewAccompanyingEventSurveyReminder | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 48 |
|||
| taskNewEventSurveyReminder | |
0.00% |
0 / 1 |
42.00 | |
0.00% |
0 / 47 |
|||
| taskRefusedMeetingCleaner | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 44 |
|||
| taskInvitationToConfirmRemainder | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 24 |
|||
| taskInvitationToConfirmCleaner | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 26 |
|||
| taskMeetingToConfirmRemainder | |
0.00% |
0 / 1 |
12.00 | |
0.00% |
0 / 27 |
|||
| taskMeetingToConfirmCleaner | |
0.00% |
0 / 1 |
30.00 | |
0.00% |
0 / 44 |
|||
| taskUserToActivateCleaner | |
0.00% |
0 / 1 |
90.00 | |
0.00% |
0 / 36 |
|||
| <?php | |
| namespace frontend\controllers; | |
| use Yii; | |
| use common\models\AccompanyingEventSurvey; | |
| use common\models\EventSurvey; | |
| use common\models\Meeting; | |
| use common\models\MeetingSurvey; | |
| use common\models\NotificationHistory; | |
| use common\models\User; | |
| use yii\web\ForbiddenHttpException; | |
| use yii\web\Controller; | |
| use yii\filters\AccessControl; | |
| /** | |
| * Cron controller | |
| */ | |
| class CronController extends Controller | |
| { | |
| /** | |
| * @inheritdoc | |
| */ | |
| public function behaviors() | |
| { | |
| return [ | |
| 'access' => [ | |
| 'class' => AccessControl::className(), | |
| 'rules' => [ | |
| [ | |
| 'actions' => ['do'], | |
| 'allow' => true, | |
| 'roles' => ['?'], | |
| 'ips' => ['*'], | |
| ], | |
| ], | |
| ], | |
| ]; | |
| } | |
| /** | |
| * Execute cron tasks. | |
| * @return mixed | |
| */ | |
| public function actionDo() | |
| { | |
| $this->taskUserToActivateCleaner(); | |
| $this->taskRefusedMeetingCleaner(); | |
| // Przypomnienie o zaproszeniu na spotkanie B2B | |
| $this->taskInvitationToConfirmRemainder(); | |
| // Powiadomienie o anulowaniu zaproszenia przez system z powodu braku akceptacji w określonym terminie B2B | |
| $this->taskInvitationToConfirmCleaner(); | |
| // Przypomnienie o zaproszeniu na spotkanie B2B | |
| $this->taskMeetingToConfirmRemainder(); | |
| // Powiadomienie o anulowaniu zaproszenia przez system z powodu braku akceptacji w określonym terminie B2B | |
| $this->taskMeetingToConfirmCleaner(); | |
| // Powiadomienie o dostępnych ankietach (Event) | |
| $this->taskNewEventSurveyReminder(); | |
| // Powiadomienie o dostępnych ankietach (AccompanyingEvent) | |
| $this->taskNewAccompanyingEventSurveyReminder(); | |
| // Powiadomienie o dostępnych ankietach (Meeting) | |
| $this->taskNewMeetingSurveyReminder(); | |
| if(array_key_exists('debug', Yii::$app->modules)){ | |
| $debug = Yii::$app->modules['debug']; | |
| echo(\yii\helpers\Html::a('Cron debug', | |
| \yii\helpers\Url::toRoute(['/' . $debug->id . '/default/view', | |
| 'tag' => $debug->logTarget->tag, | |
| ]) | |
| )); | |
| exit(); | |
| }else{ | |
| return $this->goHome(); | |
| } | |
| } | |
| /** | |
| * Send new meeting survey notification. | |
| */ | |
| protected function taskNewMeetingSurveyReminder() | |
| { | |
| Yii::trace('Start sending meeting survey remainders', __METHOD__); | |
| $query = MeetingSurvey::find() | |
| ->joinWith(['survey', 'event']) | |
| ->active(); | |
| foreach ($query->each() as $meetingSurvey) { | |
| foreach ($meetingSurvey->event->getEventSpans()->each() as $eventSpan) { | |
| $eventSpanDate = strtotime($eventSpan->date, 0); //TODO: AVOID strtotime | |
| if($eventSpanDate <= time()) { | |
| foreach ($eventSpan->getMeetings()->each() as $meeting) { | |
| $meetingDateTime = $meeting->time + $eventSpanDate; | |
| if($meetingDateTime <= time()) { | |
| $participants = [$meeting->guestParticipant, $meeting->hostParticipant]; | |
| foreach ($participants as $isHost => $participant) { | |
| if(($isHost && $meeting->is_confirmed_host) || (!$isHost && $meeting->is_confirmed_guest)) { | |
| if($meetingSurvey->getMeetingSurveyLocks()->where([ | |
| 'meeting_id' => $meeting->id, | |
| 'participant_id' => $participant->id, | |
| ])->count() == 0) { | |
| $notification = [ | |
| 'subject_table' => $meetingSurvey::tableName(), | |
| 'subject_id' => $meetingSurvey->id, | |
| 'reciver_table' => $participant::tableName(), | |
| 'reciver_id' => $participant->id, | |
| 'mediator_table' => $meeting::tableName(), | |
| 'mediator_id' => $meeting->id, | |
| ]; | |
| $secondParticipant = $participants[$isHost ^ 1]; | |
| if(NotificationHistory::find()->where($notification)->count() == 0) { | |
| $notification = new NotificationHistory($notification); | |
| $notification->load($notification); | |
| $notification->save(); | |
| Yii::trace(sprintf('Meeting survey %s notification for participant %s sent', $meetingSurvey->id, $participant->id), __METHOD__); | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingMeetingSurveyRemaider', [ | |
| 'meetingSurvey' => $meetingSurvey, | |
| 'meeting' => $meeting, | |
| 'eventSpan' => $eventSpan, | |
| 'event' => $meetingSurvey->event, | |
| 'isHost' => $isHost, | |
| 'participant' => $participant, | |
| 'user' => $participant->user, | |
| 'secondParticipant' => $secondParticipant, | |
| 'secondUser' => $secondParticipant->user, | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$participant->user->email => $participant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Remainder: New survey for meeting')) | |
| ->send(); | |
| }else{ | |
| Yii::trace(sprintf('Participant %s was notified about meeting survey %s for meeting %s', $participant->id, $meetingSurvey->id, $meeting->id), __METHOD__); | |
| } | |
| }else{ | |
| Yii::trace(sprintf('Meeting survey %s is not available for participant %s, meeting %s', $meetingSurvey->id, $participant->id, $meeting->id), __METHOD__); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * Send new accompanying event survey notification. | |
| */ | |
| protected function taskNewAccompanyingEventSurveyReminder() | |
| { | |
| Yii::trace('Start sending new accompanying event survey remainders', __METHOD__); | |
| $query = AccompanyingEventSurvey::find() | |
| ->joinWith(['survey', 'accompanyingEvent']) | |
| ->active(); | |
| foreach ($query->each() as $accompanyingEventSurvey) { | |
| foreach ($accompanyingEventSurvey->accompanyingEvent->getParticipants()->each() as $participant) { | |
| if($accompanyingEventSurvey->getAccompanyingEventSurveyLocks()->where([ | |
| 'participant_id' => $participant->id, | |
| ])->count() == 0){ | |
| if(NotificationHistory::find()->where([ | |
| 'subject_table' => $accompanyingEventSurvey::tableName(), | |
| 'subject_id' => $accompanyingEventSurvey->id, | |
| 'reciver_table' => $participant::tableName(), | |
| 'reciver_id' => $participant->id, | |
| ])->count() == 0){ | |
| $notification = new NotificationHistory(); | |
| $notification->subject_table = $accompanyingEventSurvey::tableName(); | |
| $notification->subject_id = $accompanyingEventSurvey->id; | |
| $notification->reciver_table = $participant::tableName(); | |
| $notification->reciver_id = $participant->id; | |
| $notification->save(); | |
| Yii::trace(sprintf('Accompanying event survey %s notification for participant %s sent', $accompanyingEventSurvey->id, $participant->id), __METHOD__); | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingAccompanyingEventSurveyRemaider', [ | |
| 'accompanyingEventSurvey' => $accompanyingEventSurvey, | |
| 'accompanyingEvent' => $accompanyingEventSurvey->accompanyingEvent, | |
| 'event' => $accompanyingEventSurvey->accompanyingEvent->parentEvent, | |
| 'participant' => $participant, | |
| 'user' => $participant->user | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$participant->user->email => $participant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Remainder: New survey for accompanying event')) | |
| ->send(); | |
| }else{ | |
| Yii::trace(sprintf('Participant %s was notified about accompanying event survey %s', $participant->id, $accompanyingEventSurvey->id), __METHOD__); | |
| } | |
| }else{ | |
| Yii::trace(sprintf('Accompanying event survey %s is not available for participant %s', $accompanyingEventSurvey->id, $participant->id), __METHOD__); | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * Send new event survey notification. | |
| */ | |
| protected function taskNewEventSurveyReminder() | |
| { | |
| Yii::trace('Start sending new event survey remainders', __METHOD__); | |
| $query = EventSurvey::find() | |
| ->joinWith(['survey', 'event']) | |
| ->active(); | |
| foreach ($query->each() as $eventSurvey) { | |
| foreach ($eventSurvey->event->getParticipants()->each() as $participant) { | |
| if($eventSurvey->getEventSurveyLocks()->where([ | |
| 'participant_id' => $participant->id, | |
| ])->count() == 0){ | |
| if(NotificationHistory::find()->where([ | |
| 'subject_table' => $eventSurvey::tableName(), | |
| 'subject_id' => $eventSurvey->id, | |
| 'reciver_table' => $participant::tableName(), | |
| 'reciver_id' => $participant->id, | |
| ])->count() == 0){ | |
| $notification = new NotificationHistory(); | |
| $notification->subject_table = $eventSurvey::tableName(); | |
| $notification->subject_id = $eventSurvey->id; | |
| $notification->reciver_table = $participant::tableName(); | |
| $notification->reciver_id = $participant->id; | |
| $notification->save(); | |
| Yii::trace(sprintf('Event survey %s notification for participant %s sent', $eventSurvey->id, $participant->id), __METHOD__); | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingEventSurveyRemaider', [ | |
| 'eventSurvey' => $eventSurvey, | |
| 'event' => $eventSurvey->event, | |
| 'participant' => $participant, | |
| 'user' => $participant->user | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$participant->user->email => $participant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Remainder: New survey for event')) | |
| ->send(); | |
| }else{ | |
| Yii::trace(sprintf('Participant %s was notified about event survey %s', $participant->id, $eventSurvey->id), __METHOD__); | |
| } | |
| }else{ | |
| Yii::trace(sprintf('Event survey %s is not available for participant %s', $eventSurvey->id, $participant->id), __METHOD__); | |
| } | |
| } | |
| } | |
| } | |
| /** | |
| * Delete all existing refused by guest meetings. | |
| */ | |
| protected function taskRefusedMeetingCleaner() | |
| { | |
| Yii::trace('Start cleaning refused meetings', __METHOD__); | |
| $delta = Yii::$app->params['meeting.cron.refusedExpire']; | |
| $query = Meeting::find() | |
| ->where([ | |
| 'is_confirmed_host' => true, | |
| 'is_confirmed_guest' => false, | |
| ]) | |
| ->andWhere(['>=', time() . ' - ' . Meeting::tablename() . '.[[created_at]]', $delta]) | |
| ->with(['hostParticipant.user', 'guestParticipant.user']); | |
| foreach ($query->each() as $meeting) { | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingWasCanceledBySystem', [ | |
| 'meeting' => $meeting, | |
| 'participant' => $meeting->guestParticipant, | |
| 'user' => $meeting->hostParticipant->user | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $hostEmail = $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$meeting->hostParticipant->user->email => $meeting->hostParticipant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Meeting was canceled by system')); | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingWasCanceledBySystem', [ | |
| 'meeting' => $meeting, | |
| 'participant' => $meeting->hostParticipant, | |
| 'user' => $meeting->guestParticipant->user | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $guestEmail = $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$meeting->guestParticipant->user->email => $meeting->guestParticipant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Meeting was canceled by system')); | |
| if($meeting->delete()) { | |
| Yii::trace(sprintf('Meeting %s removed', $meeting->id), __METHOD__); | |
| $hostEmail->send(); | |
| $guestEmail->send(); | |
| } | |
| } | |
| } | |
| /** | |
| * Send remainders to host about meeting invitations. | |
| */ | |
| protected function taskInvitationToConfirmRemainder() | |
| { | |
| Yii::trace('Start sending meeting remainders', __METHOD__); | |
| $delta = Yii::$app->params['meeting.confirm.hostTokenExpire']; | |
| $query = Meeting::find() | |
| ->where(['is_confirmed_host' => null]) | |
| ->andWhere(['<', time() . ' - ' . Meeting::tablename() . '.[[created_at]]', $delta]) | |
| ->with(['hostParticipant.user', 'guestParticipant.user']); | |
| foreach ($query->each() as $meeting) { | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingConfirmationRemaider', [ | |
| 'meeting' => $meeting, | |
| 'participant' => $meeting->guestParticipant, | |
| 'user' => $meeting->hostParticipant->user | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$meeting->hostParticipant->user->email => $meeting->hostParticipant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Remainder: Meeting to confirm')) | |
| ->send(); | |
| } | |
| } | |
| /** | |
| * Delete all existing unconfirmed by host invitations. | |
| */ | |
| protected function taskInvitationToConfirmCleaner() | |
| { | |
| Yii::trace('Start cleaning unconfirmed invitations', __METHOD__); | |
| $delta = Yii::$app->params['meeting.confirm.hostTokenExpire']; | |
| $query = Meeting::find() | |
| ->where(['is_confirmed_host' => null]) | |
| ->andWhere(['>=', time() . ' - ' . Meeting::tablename() . '.[[created_at]]', $delta]) | |
| ->with(['hostParticipant.user', 'guestParticipant.user']); | |
| foreach ($query->each() as $meeting) { | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingWasCanceledBySystem', [ | |
| 'meeting' => $meeting, | |
| 'participant' => $meeting->guestParticipant, | |
| 'user' => $meeting->hostParticipant->user | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $hostEmail = $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$meeting->hostParticipant->user->email => $meeting->hostParticipant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Meeting was canceled by system')); | |
| if($meeting->delete()) { | |
| $hostEmail->send(); | |
| } | |
| } | |
| } | |
| /** | |
| * Send remainders to guests about meeting confirmation. | |
| */ | |
| protected function taskMeetingToConfirmRemainder() | |
| { | |
| Yii::trace('Start sending meeting remainders', __METHOD__); | |
| $delta = Yii::$app->params['meeting.confirm.guestTokenExpire']; | |
| $query = Meeting::find() | |
| ->where([ | |
| 'is_confirmed_host' => true, | |
| 'is_confirmed_guest' => null, | |
| ]) | |
| ->andWhere(['<', time() . ' - ' . Meeting::tablename() . '.[[created_at]]', $delta]) | |
| ->with(['hostParticipant.user', 'guestParticipant.user']); | |
| foreach ($query->each() as $meeting) { | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingConfirmationRemaider', [ | |
| 'meeting' => $meeting, | |
| 'participant' => $meeting->hostParticipant, | |
| 'user' => $meeting->guestParticipant->user | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$meeting->guestParticipant->user->email => $meeting->guestParticipant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Remainder: Meeting to confirm')) | |
| ->send(); | |
| } | |
| } | |
| /** | |
| * Delete all existing unconfirmed by guest meetings. | |
| */ | |
| protected function taskMeetingToConfirmCleaner() | |
| { | |
| Yii::trace('Start cleaning unconfirmed meetings', __METHOD__); | |
| $delta = Yii::$app->params['meeting.confirm.guestTokenExpire']; | |
| $query = Meeting::find() | |
| ->where([ | |
| 'is_confirmed_host' => true, | |
| 'is_confirmed_guest' => null, | |
| ]) | |
| ->andWhere(['>=', time() . ' - ' . Meeting::tablename() . '.[[created_at]]', $delta]) | |
| ->with(['hostParticipant.user', 'guestParticipant.user']); | |
| foreach ($query->each() as $meeting) { | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingWasCanceledBySystem', [ | |
| 'meeting' => $meeting, | |
| 'participant' => $meeting->guestParticipant, | |
| 'user' => $meeting->hostParticipant->user | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $hostEmail = $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$meeting->hostParticipant->user->email => $meeting->hostParticipant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Meeting was canceled by system')); | |
| $message = Yii::$app->mailer | |
| ->compose('infoMeetingWasCanceledBySystem', [ | |
| 'meeting' => $meeting, | |
| 'participant' => $meeting->hostParticipant, | |
| 'user' => $meeting->guestParticipant->user | |
| ]); | |
| $fromEmail = \Yii::$app->params['supportEmail']; | |
| $sourceEmail = $message->getFrom(); | |
| if (!empty($sourceEmail)) $fromEmail = key($sourceEmail); | |
| $guestEmail = $message->setFrom([$fromEmail => \Yii::$app->name . ' robot']) | |
| ->setReplyTo([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) | |
| ->setTo([$meeting->guestParticipant->user->email => $meeting->guestParticipant->user->fullname]) | |
| ->setSubject(Yii::t('app', 'Meeting was canceled by system')); | |
| if($meeting->delete()) { | |
| Yii::trace(sprintf('Meeting %s removed', $meeting->id), __METHOD__); | |
| $hostEmail->send(); | |
| $guestEmail->send(); | |
| } | |
| } | |
| } | |
| /** | |
| * Delete all existing not activated users. | |
| */ | |
| protected function taskUserToActivateCleaner() | |
| { | |
| Yii::trace('Start cleaning not activated users', __METHOD__); | |
| $delta = Yii::$app->params['user.emailConfirmTokenExpire']; | |
| $query = User::find() | |
| ->where([ | |
| 'status' => User::STATUS_INACTIVE, | |
| ]) | |
| ->andWhere('[[email_confirm_token]] IS NOT NULL') | |
| ->andWhere(['>=', time() . ' - ' . User::tablename() . '.[[created_at]]', $delta]) | |
| ->with(['participant', 'participant.organization']); | |
| foreach ($query->each() as $user) { | |
| $participant = $user->participant; | |
| $organization = null; | |
| if(!empty($participant)) { | |
| $organization = $participant->organization; | |
| if($participant->delete()) { | |
| Yii::trace(sprintf('Participant %s removed', $participant->id), __METHOD__); | |
| $participant = null; | |
| } | |
| } | |
| if(!empty($organization)) { | |
| $participants = $organization->getParticipants()->count(); | |
| if(empty($participants)) { | |
| if($organization->delete()) { | |
| Yii::trace(sprintf('Organization %s removed', $organization->id), __METHOD__); | |
| $organization = null; | |
| } | |
| } | |
| } | |
| if(empty($participant)) { | |
| if($user->delete()) { | |
| Yii::trace(sprintf('User %s removed', $user->id), __METHOD__); | |
| } | |
| } | |
| } | |
| } | |
| } |