function actionUnSubscribe() { header('Content-type: application/json'); if (!Yii::app()->request->isPostRequest) { IjoyPlusServiceUtils::exportServiceError(Constants::METHOD_NOT_SUPPORT); return; } if (!IjoyPlusServiceUtils::validateAPPKey()) { IjoyPlusServiceUtils::exportServiceError(Constants::APP_KEY_INVALID); return; } $prod_id = Yii::app()->request->getParam("prod_id"); if (!isset($prod_id) || is_null($prod_id)) { IjoyPlusServiceUtils::exportServiceError(Constants::PARAM_IS_INVALID); return; } if (IjoyPlusServiceUtils::validateUserID()) { IjoyPlusServiceUtils::exportServiceError(Constants::USER_ID_INVALID); return; } try { $userid = Yii::app()->user->id; $subscribe = Subscribe::model()->getSubscribeByProd($userid, $prod_id); if ($subscribe !== null) { $subscribe->delete(); } IjoyPlusServiceUtils::exportServiceError(Constants::SUCC); } catch (Exception $e) { IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR); } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Subscribe the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Subscribe::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }