public function actionDelete($id) { if (Yii::app()->user->isGuest) { throw new CHttpException(403, 'You are not authorized.'); } $requirement = RequirementApi::getRequirementById($id); if ($requirement->user_id !== Yii::app()->user->id) { throw new CHttpException(403, 'You are not authorized.'); } if (RequirementApi::deleteRequirementById($requirement->id)) { Yii::app()->user->setFlash('success', 'The requirment was removed successfully'); } else { Yii::app()->user->setFlash('error', 'The requirment could not be removed. Please contact the admin.'); } $this->redirect('/requirements'); }