/** * @param object $model * @param string $name */ private function handleFeedTypeUpload($model, $name) { $event = new Events(); $event->user = Yii::app()->user->getName(); if (isset($_POST['attachmentText']) && !empty($_POST['attachmentText'])) { $event->text = $_POST['attachmentText']; } else { $event->text = Yii::t('app', 'Attached file: '); } $event->type = 'media'; $event->timestamp = time(); $event->lastUpdated = time(); $event->associationId = $model->id; $event->associationType = 'Media'; if ($event->save()) { //$this->redirect('profile'); } else { unlink('uploads/' . $name); } if (AuxLib::isMobile()) { $this->redirect(array('/mobile/site/activity')); } else { if (isset($_POST['profileId'])) { $this->redirect(array('/profile/view', 'id' => $_POST['profileId'])); } else { $this->redirect(array('/profile/view', 'id' => Yii::app()->user->getId())); } } }