Example #1
0
 public function actionPost()
 {
     $this->forcePostRequest();
     $_POST = Yii::app()->input->stripClean($_POST);
     $post = new Post();
     $post->content->populateByForm();
     $post->message = Yii::app()->request->getParam('message');
     if ($post->validate()) {
         $post->save();
         // Experimental: Auto attach found images urls in message as files
         if (isset(Yii::app()->params['attachFilesByUrlsToContent']) && Yii::app()->params['attachFilesByUrlsToContent'] == true) {
             File::attachFilesByUrlsToContent($post, $post->message);
         }
         $this->renderJson(array('wallEntryId' => $post->content->getFirstWallEntryId()));
     } else {
         $this->renderJson(array('errors' => $post->getErrors()), false);
     }
 }