public function subscribe() { $email = Input::get('email'); $subscribe = new Subscribe(); $subscribe->email = $email; $subscribe->save(); return 'true'; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Subscribe(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Subscribe'])) { $model->attributes = $_POST['Subscribe']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function subscribe() { $email = Input::get('email'); $subscribe = new Subscribe(); $subscribe->email = $email; try { $subscribe->save(); $data = Citrus::response('data', 'You have been successfully subscribed'); } catch (Exception $e) { //$e->setMessage('You are already subscribed!'); $data = Citrus::response('error', $e); } return $data; }
function actionSubscribe() { 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 = new Subscribe(); $subscribe->author_id = $userid; $subscribe->prod_id = $prod_id; $subscribe->create_date = new CDbExpression('NOW()'); $subscribe->save(); } IjoyPlusServiceUtils::exportServiceError(Constants::SUCC); } catch (Exception $e) { IjoyPlusServiceUtils::exportServiceError(Constants::SYSTEM_ERROR); } }