Example #1
0
 /**
  * Redirects to given HActiveRecordContent or HActiveRecordContentAddon
  */
 public function actionIndex()
 {
     $id = (int) Yii::$app->request->get('id', "");
     $content = Content::findOne(['id' => $id]);
     if ($content !== null) {
         return $this->redirect($content->getUrl());
     }
     throw new HttpException(404, Yii::t('ContentModule.controllers_PermaController', 'Could not find requested content!'));
 }
 /**
  * UnArchives an wall entry & corresponding content object.
  *
  * Returns JSON Output.
  */
 public function actionUnarchive()
 {
     Yii::$app->response->format = 'json';
     $this->forcePostRequest();
     $json = array();
     $json['success'] = false;
     // default
     $id = (int) Yii::$app->request->getParam('id', "");
     $content = Content::findOne(['id' => $id]);
     if ($content !== null && $content->canArchive()) {
         $content->unarchive();
         $json['success'] = true;
         $json['wallEntryIds'] = $content->getWallEntryIds();
     }
     return $json;
 }
 /**
  * @inheritdoc
  */
 public function afterDelete()
 {
     $content = Content::findOne(['object_id' => $this->id, 'object_model' => $this->className()]);
     if ($content !== null) {
         $content->delete();
     }
     parent::afterDelete();
 }
 public function actionNotificationSwitch()
 {
     Yii::$app->response->format = 'json';
     $this->forcePostRequest();
     $json = array();
     $json['success'] = false;
     // default
     $content = Content::findOne(['id' => Yii::$app->request->get('id', "")]);
     if ($content !== null) {
         $switch = Yii::$app->request->get('switch', true) == 1 ? true : false;
         $obj = $content->getPolymorphicRelation();
         $obj->follow(Yii::$app->user->id, $switch);
         $json['success'] = true;
     }
     return $json;
 }
 public function getCreator()
 {
     $content = Content::findOne(['object_model' => $this->className(), 'object_id' => $this->id]);
     return User::findOne(['id' => $content->created_by]);
 }