Ejemplo n.º 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!'));
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function afterDelete()
 {
     $content = Content::findOne(['object_id' => $this->id, 'object_model' => $this->className()]);
     if ($content !== null) {
         $content->delete();
     }
     parent::afterDelete();
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 public function getCreator()
 {
     $content = Content::findOne(['object_model' => $this->className(), 'object_id' => $this->id]);
     return User::findOne(['id' => $content->created_by]);
 }