Example #1
0
 public function actionVerify($id, $hash)
 {
     $request = $this->loadModel($id);
     if ($hash == $request->hash) {
         $mglist = Mglist::model()->findByPk($request->mglist_id);
         // insert new Member
         $member_id = $request->insertMember($request->name, $request->address);
         // add member to this list
         Member::model()->addToList($member_id, $request->mglist_id);
         // add member at Mailgun
         $yg = new Yiigun();
         $yg->memberAdd($mglist->address, $request->address, $request->name);
         $this->render('verify', array('model' => $this->loadModel($id), 'mglist' => $mglist));
     } else {
         echo 'Sorry, your request is invalid.';
         yexit();
     }
 }
Example #2
0
 /**
  * Creates a new member.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     $model = new Member();
     $mglist_id = $id;
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Member'])) {
         $model->attributes = $_POST['Member'];
         $model->status = 1;
         $model->created_at = new CDbExpression('NOW()');
         $model->modified_at = new CDbExpression('NOW()');
         if ($model->save()) {
             $model->addToList($model->id, $mglist_id);
         }
         $lookup_list = Mglist::model()->findByPk($mglist_id);
         // to do fetch list address
         $yg = new Yiigun();
         $yg->memberAdd($lookup_list['address'], $model->address, $model->name);
         $this->redirect('/mglist/' . $mglist_id);
     }
     $this->render('create', array('model' => $model));
 }