5 public function filters()
11 public function accessRules()
23 public function actionInit()
26 $response[
'assetsPath'] = $this->module->assetsPath;
27 FGHelper::sendJSON($response);
30 public function actionLoadLibrary()
32 $templatesModel =
FGTemplates::model()->findAll(
'user=:uid OR global = 1', array(
':uid'=>Yii::app()->user->id));
37 foreach($templatesModel as $tpl) {
38 $templates[ $tpl->global?
'global' :
'user' ][] = array(
43 FGHelper::sendJSON(array(
44 'templates' => $templates
48 public function actionLoadForm()
50 if(isset($_POST[
'id']))
54 $model->json = str_replace(
'"id": 0,',
'"id": '.$model->id.
',', $model->json);
57 FGHelper::sendJSON(array(
64 throw new CHttpException(404,
"No Form found");
69 throw new CHttpException(500,
"No Form id provided");
73 public function actionLoadTemplate()
75 if(isset($_POST[
'id']))
77 $model =
FGTemplates::model()->findByPk((
int)$_POST[
'id'],
'user=:uid OR global = 1', array(
':uid'=>Yii::app()->user->id));
79 FGHelper::sendJSON(array(
84 throw new CHttpException(404,
"No template found");
89 throw new CHttpException(500,
"No template id provided");
98 if(isset($_POST[
'json']))
101 $model->setAttributes($_POST);
102 $model->user = Yii::app()->user->id;
105 FGHelper::sendJSON(array(
112 throw new CHttpException(500, CActiveForm::validate($model));
117 throw new CHttpException(500,
"No JSON provided");
130 $model->setAttributes($_POST);
131 $model->user = Yii::app()->user->id;
132 $model->thankyoupage = $_POST[
'thankyoupage'];
133 $model->nextpage = $_POST[
'nextpage'];
134 $model->prevpage = $_POST[
'prevpage'];
136 if (!empty($_POST[
'id']) && $_POST[
'id'] !=
"" && $_POST[
'id'] !=
"0"){
137 if($model->updateByPk((
int)$_POST[
'id'],
138 array(
"name" => $_POST[
'name'],
139 "json" => $_POST[
'json'],
140 "html" => $_POST[
'html'],
141 "thankyoupage" => $_POST[
'thankyoupage'],
142 "nextpage" => $_POST[
'nextpage'],
143 "prevpage" => $_POST[
'prevpage']
147 $response[
'status'] =
true;
148 $response[
'id'] = $_POST[
'id'];
152 $response[
'status'] =
false;
153 $response[
'errors'] = $model->getErrors();
159 $response[
'status'] =
true;
160 $response[
'id'] = $model->id;
164 $response[
'status'] =
false;
165 $response[
'errors'] = $model->getErrors();
171 throw new CHttpException(500,
"No JSON provided");
173 FGHelper::sendJSON($response);