/** * Deletes a content object * * Returns a JSON list of affected wallEntryIds. */ public function actionDelete() { Yii::$app->response->format = 'json'; $this->forcePostRequest(); $json = ['success' => 'false']; $model = Yii::$app->request->get('model'); $id = (int) Yii::$app->request->get('id'); $contentObj = Content::get($model, $id); if ($contentObj !== null && $contentObj->content->canDelete() && $contentObj->delete()) { $json = ['success' => true, 'uniqueId' => $contentObj->getUniqueId(), 'model' => $model, 'pk' => $id]; } return $json; }
public function actionDeleteContent() { $this->forcePostRequest(); $model = Yii::$app->request->get('model'); $id = Yii::$app->request->get('id'); $content = Content::get($model, $id); if ($content->content->canDelete()) { $content->delete(); } if (!$content->content->space_id) { return $this->htmlRedirect(Url::to(['/reportcontent/admin'])); } else { $space = Space::findOne(['id' => $content->content->space_id]); return $this->htmlRedirect($space->createUrl('/reportcontent/space-admin')); } }