Пример #1
0
 public function run($id)
 {
     $formModel = new EventCommentPublisherFormModel();
     $profile = Yii::app()->params->profile;
     $model = $this->controller->lookUpModel($id, 'Events');
     $this->controller->dataUrl = Yii::app()->request->url;
     if ($model->checkPermissions('view')) {
         if (isset($_POST['EventCommentPublisherFormModel'])) {
             $formModel->setAttributes($_POST['EventCommentPublisherFormModel']);
             if (isset($_FILES['EventCommentPublisherFormModel'])) {
                 $model->photo = CUploadedFile::getInstance($model, 'photo');
             }
             if ($formModel->validate()) {
                 $event = new Events();
                 $event->setAttributes(array('visibility' => X2PermissionsBehavior::VISIBILITY_PUBLIC, 'user' => $profile->username, 'type' => 'structured-feed', 'associationType' => 'Events', 'associationId' => $id, 'text' => $formModel->text, 'photo' => $formModel->photo), false);
                 if ($event->save()) {
                     $formModel->text = '';
                     if (!isset($_FILES['EventCommentPublisherFormModel'])) {
                     } else {
                         Yii::app()->end();
                     }
                 } else {
                     throw new CHttpException(500, implode(';', $event->getAllErrorMessages()));
                 }
             }
         }
         $dataProvider = new CActiveDataProvider('Events', array('criteria' => array('order' => 'timestamp ASC', 'condition' => "type in ('comment', 'structured-feed') AND \n                         associationType='Events' AND associationId={$id}"), 'pagination' => array('pageSize' => 30)));
         $this->controller->render($this->pathAliasBase . 'views.mobile.viewEvent', array('model' => $model, 'dataProvider' => $dataProvider, 'formModel' => $formModel));
     } else {
         $this->controller->denied();
     }
 }
Пример #2
0
 public function addEvent($attr, $image)
 {
     $model = new Events();
     $model->setAttributes($attr);
     $model->created_at = time();
     $model->updated_at = time();
     $model->status = 1;
     $model->images = $image;
     if ($model->save(FALSE)) {
         return TRUE;
     }
     return FALSE;
 }
Пример #3
0
 public function run()
 {
     $model = new EventPublisherFormModel();
     $profile = Yii::app()->params->profile;
     if (isset($_POST['EventPublisherFormModel'])) {
         $model->setAttributes($_POST['EventPublisherFormModel']);
         if (isset($_FILES['EventPublisherFormModel'])) {
             $model->photo = CUploadedFile::getInstance($model, 'photo');
         }
         //AuxLib::debugLogR ('validating');
         if ($model->validate()) {
             //AuxLib::debugLogR ('valid');
             $event = new Events();
             $event->setAttributes(array('visibility' => X2PermissionsBehavior::VISIBILITY_PUBLIC, 'user' => $profile->username, 'type' => 'structured-feed', 'text' => $model->text, 'photo' => $model->photo), false);
             if ($event->save()) {
                 if (!isset($_FILES['EventPublisherFormModel'])) {
                     //AuxLib::debugLogR ('saved');
                     $this->controller->redirect($this->controller->createAbsoluteUrl('/profile/mobileActivity'));
                 } else {
                     echo CJSON::encode(array('redirectUrl' => $this->controller->createAbsoluteUrl('/profile/mobileActivity')));
                     Yii::app()->end();
                 }
             } else {
                 //AuxLib::debugLogR ('invalid');
                 throw new CHttpException(500, implode(';', $event->getAllErrorMessages()));
             }
         } else {
             if (isset($_FILES['EventPublisherFormModel'])) {
                 throw new CHttpException(500, implode(';', $event->getAllErrorMessages()));
             }
             //AuxLib::debugLogR ('invalid model');
             //AuxLib::debugLogR ($model->getErrors ());
         }
     }
     $this->controller->render($this->pathAliasBase . 'views.mobile.eventPublisher', array('profile' => $profile, 'model' => $model));
 }