Ejemplo n.º 1
0
 /**
  * @inheritDoc
  */
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $this->setRsoAgreement($this->foreignOrganizations ? self::RSO_AGREEMENT_IN_PROCESS : self::RSO_AGREEMENT_NO_NEED, new RsoNotificationStrategy());
         $rsoFiles = $this->rsoFiles;
         foreach ($this->rsoUploadedFiles as $rsoUploadedFile) {
             $file = new File(['filename' => $rsoUploadedFile->name, 'mimeType' => $rsoUploadedFile->type, 'file' => $rsoUploadedFile]);
             if ($file->save()) {
                 $rsoFiles[] = ['id' => $file->primaryKey, 'name' => $file->filename];
             }
         }
         $this->rsoFiles = $rsoFiles;
         if ($insert) {
             $this->status = self::STATUS_OSKR_CONSIDERATION;
             foreach ($this->participants as $participant) {
                 if ($participant->ahuConfirmation) {
                     $this->status = self::STATUS_ROOMS_CONSIDIRATION;
                 }
             }
         } elseif (!\Yii::$app->user->can(SystemPermission::APPROVE_REQUEST) && $this->status !== self::STATUS_ROOMS_CONSIDIRATION) {
             $this->status = self::STATUS_OSKR_CONSIDERATION;
             $this->trigger(self::EVENT_STATUS_CHANGED, new RequestStatusChangedEvent(['request' => $this]));
         }
         return true;
     } else {
         return false;
     }
 }
Ejemplo n.º 2
0
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         $fileIds = ArrayHelper::getColumn($this->rsoFiles, 'id');
         File::deleteAll(['_id' => ['$in' => $fileIds]]);
         return true;
     } else {
         return false;
     }
 }