Beispiel #1
0
 function save($data = array())
 {
     if (!$data || count($data) == 0) {
         $data = $_POST;
     }
     $db = Loader::db();
     if (intval($this->bID) > 0) {
         $q = "select count(*) as total from {$this->btTable} where bID = " . intval($this->bID);
         $total = $db->getOne($q);
     } else {
         $total = 0;
     }
     $v = array($data['qsID'], $data['surveyName'], intval($data['notifyMeOnSubmission']), $data['recipientEmail'], intval($this->bID));
     $q = $total > 0 ? "update {$this->btTable} set questionSetId = ?, surveyName=?, notifyMeOnSubmission=?, recipientEmail=? where bID = ?" : "insert into {$this->btTable} (questionSetId,surveyName, notifyMeOnSubmission, recipientEmail, bID) values (?, ?, ?, ?, ?)";
     $rs = $db->query($q, $v);
     //Add Questions (for programmatically creating forms, such as during the site install)
     if (count($data['questions']) > 0) {
         $miniSurvey = new MiniSurvey();
         foreach ($data['questions'] as $questionData) {
             $miniSurvey->addEditQuestion($questionData, 0);
         }
     }
     return true;
 }
Beispiel #2
0
 function save($data = array())
 {
     if (!$data || count($data) == 0) {
         $data = $_POST;
     }
     $b = $this->getBlockObject();
     $c = $b->getBlockCollectionObject();
     $db = Loader::db();
     if (intval($this->bID) > 0) {
         $q = "select count(*) as total from {$this->btTable} where bID = " . intval($this->bID);
         $total = $db->getOne($q);
     } else {
         $total = 0;
     }
     if ($_POST['qsID']) {
         $data['qsID'] = $_POST['qsID'];
     }
     if (!$data['qsID']) {
         $data['qsID'] = time();
     }
     if (!$data['oldQsID']) {
         $data['oldQsID'] = $data['qsID'];
     }
     $data['bID'] = intval($this->bID);
     if (!empty($data['redirectCID'])) {
         $data['redirect'] = 1;
     } else {
         $data['redirect'] = 0;
         $data['redirectCID'] = 0;
     }
     if (empty($data['addFilesToSet'])) {
         $data['addFilesToSet'] = 0;
     }
     $v = array($data['qsID'], $data['surveyName'], intval($data['notifyMeOnSubmission']), $data['recipientEmail'], $data['thankyouMsg'], intval($data['displayCaptcha']), intval($data['redirectCID']), intval($data['addFilesToSet']), intval($this->bID));
     //is it new?
     if (intval($total) == 0) {
         $q = "insert into {$this->btTable} (questionSetId, surveyName, notifyMeOnSubmission, recipientEmail, thankyouMsg, displayCaptcha, redirectCID, addFilesToSet, bID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)";
     } else {
         $q = "update {$this->btTable} set questionSetId = ?, surveyName=?, notifyMeOnSubmission=?, recipientEmail=?, thankyouMsg=?, displayCaptcha=?, redirectCID=?, addFilesToSet=? where bID = ? AND questionSetId=" . $data['qsID'];
     }
     $rs = $db->query($q, $v);
     //Add Questions (for programmatically creating forms, such as during the site install)
     if (count($data['questions']) > 0) {
         $miniSurvey = new MiniSurvey();
         foreach ($data['questions'] as $questionData) {
             $miniSurvey->addEditQuestion($questionData, 0);
         }
     }
     $this->questionVersioning($data);
     return true;
 }