예제 #1
0
 public function actionEdit()
 {
     $this->loadContentAddon(Comment::className(), Yii::$app->request->get('id'));
     if (!$this->contentAddon->canWrite()) {
         throw new HttpException(403, Yii::t('CommentModule.controllers_CommentController', 'Access denied!'));
     }
     if ($this->contentAddon->load(Yii::$app->request->post()) && $this->contentAddon->validate() && $this->contentAddon->save()) {
         // Reload comment to get populated updated_at field
         $this->contentAddon = Comment::findOne(['id' => $this->contentAddon->id]);
         return $this->renderAjaxContent(\humhub\modules\comment\widgets\Comment::widget(['comment' => $this->contentAddon, 'justEdited' => true]));
     }
     return $this->renderAjax('edit', array('comment' => $this->contentAddon, 'contentModel' => $this->contentAddon->object_model, 'contentId' => $this->contentAddon->object_id));
 }
예제 #2
0
 /**
  * Get the post the file is connected to.
  */
 public static function getBasePost($file = null)
 {
     if ($file === null) {
         return null;
     }
     $searchItem = $file;
     // if the item is connected to a Comment, we have to search for the corresponding Post
     if ($file->object_model === Comment::className()) {
         $searchItem = Comment::findOne(['id' => $file->object_id]);
     }
     $query = Content::find();
     $query->andWhere(['content.object_id' => $searchItem->object_id, 'content.object_model' => $searchItem->object_model]);
     return $query->one();
 }
 /**
  * Action to list all posted files from the content container.
  * @return string
  */
 public function actionAllPostedFiles()
 {
     $items = $this->getAllPostedFiles();
     $content_file_wrapper = [];
     foreach ($items as $file) {
         $searchItem = $file;
         // if the item is connected to a Comment, we have to search for the corresponding Post
         if ($file->object_model === Comment::className()) {
             $searchItem = Comment::findOne(['id' => $file->object_id]);
         }
         $query = Content::find();
         $query->andWhere(['content.object_id' => $searchItem->object_id, 'content.object_model' => $searchItem->object_model]);
         $content_file_wrapper[] = ['file' => $file, 'content' => $query->one()];
     }
     return $this->render('allPostedFiles', ['contentContainer' => $this->contentContainer, 'items' => $content_file_wrapper]);
 }
예제 #4
0
 /**
  * Get the post the file is connected to.
  * @param File $basefile the file.
  */
 public static function getBasePost($file = null)
 {
     if ($file === null) {
         return null;
     }
     $searchItem = $file;
     // if the item is connected to a Comment, we have to search for the corresponding Post
     if ($file->object_model === Comment::className()) {
         $searchItem = Comment::findOne(['id' => $file->object_id]);
     }
     $return = Post::findOne(['id' => $searchItem->object_id]);
 }