当前位置: 首页>>代码示例>>PHP>>正文


PHP SurveyLanguageSetting::insertNewSurvey方法代码示例

本文整理汇总了PHP中SurveyLanguageSetting::insertNewSurvey方法的典型用法代码示例。如果您正苦于以下问题:PHP SurveyLanguageSetting::insertNewSurvey方法的具体用法?PHP SurveyLanguageSetting::insertNewSurvey怎么用?PHP SurveyLanguageSetting::insertNewSurvey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SurveyLanguageSetting的用法示例。


在下文中一共展示了SurveyLanguageSetting::insertNewSurvey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: insert

 /**
  * Saves the new survey after the creation screen is submitted
  *
  * @param $iSurveyID  The survey id to be used for the new survey. If already taken a new random one will be used.
  */
 function insert($iSurveyID = null)
 {
     if (Permission::model()->hasGlobalPermission('surveys', 'create')) {
         // Check if survey title was set
         if (!$_POST['surveyls_title']) {
             Yii::app()->session['flashmessage'] = gT("Survey could not be created because it did not have a title");
             redirect($this->getController()->createUrl('admin'));
             return;
         }
         Yii::app()->loadHelper("surveytranslator");
         // If start date supplied convert it to the right format
         $aDateFormatData = getDateFormatData(Yii::app()->session['dateformat']);
         $sStartDate = $_POST['startdate'];
         if (trim($sStartDate) != '') {
             Yii::import('application.libraries.Date_Time_Converter');
             $converter = new Date_Time_Converter($sStartDate, $aDateFormatData['phpdate'] . ' H:i:s');
             $sStartDate = $converter->convert("Y-m-d H:i:s");
         }
         // If expiry date supplied convert it to the right format
         $sExpiryDate = $_POST['expires'];
         if (trim($sExpiryDate) != '') {
             Yii::import('application.libraries.Date_Time_Converter');
             $converter = new Date_Time_Converter($sExpiryDate, $aDateFormatData['phpdate'] . ' H:i:s');
             $sExpiryDate = $converter->convert("Y-m-d H:i:s");
         }
         $iTokenLength = $_POST['tokenlength'];
         //token length has to be at least 5, otherwise set it to default (15)
         if ($iTokenLength < 5) {
             $iTokenLength = 15;
         }
         if ($iTokenLength > 36) {
             $iTokenLength = 36;
         }
         // Insert base settings into surveys table
         $aInsertData = array('expires' => $sExpiryDate, 'startdate' => $sStartDate, 'template' => App()->request->getPost('template'), 'owner_id' => Yii::app()->session['loginID'], 'admin' => App()->request->getPost('admin'), 'active' => 'N', 'anonymized' => App()->request->getPost('anonymized'), 'faxto' => App()->request->getPost('faxto'), 'format' => App()->request->getPost('format'), 'savetimings' => App()->request->getPost('savetimings'), 'language' => App()->request->getPost('language'), 'datestamp' => App()->request->getPost('datestamp'), 'ipaddr' => App()->request->getPost('ipaddr'), 'refurl' => App()->request->getPost('refurl'), 'usecookie' => App()->request->getPost('usecookie'), 'emailnotificationto' => App()->request->getPost('emailnotificationto'), 'allowregister' => App()->request->getPost('allowregister'), 'allowsave' => App()->request->getPost('allowsave'), 'navigationdelay' => App()->request->getPost('navigationdelay'), 'autoredirect' => App()->request->getPost('autoredirect'), 'showxquestions' => App()->request->getPost('showxquestions'), 'showgroupinfo' => App()->request->getPost('showgroupinfo'), 'showqnumcode' => App()->request->getPost('showqnumcode'), 'shownoanswer' => App()->request->getPost('shownoanswer'), 'showwelcome' => App()->request->getPost('showwelcome'), 'allowprev' => App()->request->getPost('allowprev'), 'questionindex' => App()->request->getPost('questionindex'), 'nokeyboard' => App()->request->getPost('nokeyboard'), 'showprogress' => App()->request->getPost('showprogress'), 'printanswers' => App()->request->getPost('printanswers'), 'listpublic' => App()->request->getPost('public'), 'htmlemail' => App()->request->getPost('htmlemail'), 'sendconfirmation' => App()->request->getPost('sendconfirmation'), 'tokenanswerspersistence' => App()->request->getPost('tokenanswerspersistence'), 'alloweditaftercompletion' => App()->request->getPost('alloweditaftercompletion'), 'usecaptcha' => App()->request->getPost('usecaptcha'), 'publicstatistics' => App()->request->getPost('publicstatistics'), 'publicgraphs' => App()->request->getPost('publicgraphs'), 'assessments' => App()->request->getPost('assessments'), 'emailresponseto' => App()->request->getPost('emailresponseto'), 'tokenlength' => $iTokenLength);
         $warning = '';
         // make sure we only update emails if they are valid
         if (Yii::app()->request->getPost('adminemail', '') == '' || validateEmailAddress(Yii::app()->request->getPost('adminemail'))) {
             $aInsertData['adminemail'] = Yii::app()->request->getPost('adminemail');
         } else {
             $aInsertData['adminemail'] = '';
             $warning .= gT("Warning! Notification email was not updated because it was not valid.") . '<br/>';
         }
         if (Yii::app()->request->getPost('bounce_email', '') == '' || validateEmailAddress(Yii::app()->request->getPost('bounce_email'))) {
             $aInsertData['bounce_email'] = Yii::app()->request->getPost('bounce_email');
         } else {
             $aInsertData['bounce_email'] = '';
             $warning .= gT("Warning! Bounce email was not updated because it was not valid.") . '<br/>';
         }
         if (!is_null($iSurveyID)) {
             $aInsertData['wishSID'] = $iSurveyID;
         }
         $iNewSurveyid = Survey::model()->insertNewSurvey($aInsertData);
         if (!$iNewSurveyid) {
             die('Survey could not be created.');
         }
         // Prepare locale data for surveys_language_settings table
         $sTitle = $_POST['surveyls_title'];
         $sDescription = $_POST['description'];
         $sWelcome = $_POST['welcome'];
         $sURLDescription = $_POST['urldescrip'];
         $sTitle = html_entity_decode($sTitle, ENT_QUOTES, "UTF-8");
         $sDescription = html_entity_decode($sDescription, ENT_QUOTES, "UTF-8");
         $sWelcome = html_entity_decode($sWelcome, ENT_QUOTES, "UTF-8");
         $sURLDescription = html_entity_decode($sURLDescription, ENT_QUOTES, "UTF-8");
         // Fix bug with FCKEditor saving strange BR types
         $sTitle = fixCKeditorText($sTitle);
         $sDescription = fixCKeditorText($sDescription);
         $sWelcome = fixCKeditorText($sWelcome);
         // Insert base language into surveys_language_settings table
         $aInsertData = array('surveyls_survey_id' => $iNewSurveyid, 'surveyls_title' => $sTitle, 'surveyls_description' => $sDescription, 'surveyls_welcometext' => $sWelcome, 'surveyls_language' => $_POST['language'], 'surveyls_urldescription' => $_POST['urldescrip'], 'surveyls_endtext' => $_POST['endtext'], 'surveyls_url' => $_POST['url'], 'surveyls_dateformat' => (int) $_POST['dateformat'], 'surveyls_numberformat' => (int) $_POST['numberformat']);
         $langsettings = new SurveyLanguageSetting();
         $langsettings->insertNewSurvey($aInsertData);
         Yii::app()->session['flashmessage'] = $warning . gT("Survey was successfully added.");
         // Update survey permissions
         Permission::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'], $iNewSurveyid);
         $this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iNewSurveyid));
     }
 }
开发者ID:nicbon,项目名称:LimeSurvey,代码行数:84,代码来源:surveyadmin.php

示例2: add_survey

 /**
  * RPC Routine to add an empty survey with minimum details.
  * Used as a placeholder for importing groups and/or questions.
  *
  * @access public
  * @param string $sSessionKey Auth credentials
  * @param int $iSurveyID The wish id of the Survey to add
  * @param string $sSurveyTitle Title of the new Survey
  * @param string $sSurveyLanguage    Default language of the Survey
  * @param string $sformat Question appearance format
  * @return array|string|int
  */
 public function add_survey($sSessionKey, $iSurveyID, $sSurveyTitle, $sSurveyLanguage, $sformat = 'G')
 {
     Yii::app()->loadHelper("surveytranslator");
     if ($this->_checkSessionKey($sSessionKey)) {
         if (Permission::model()->hasGlobalPermission('surveys', 'create')) {
             if ($sSurveyTitle == '' || $sSurveyLanguage == '' || !array_key_exists($sSurveyLanguage, getLanguageDataRestricted()) || !in_array($sformat, array('A', 'G', 'S'))) {
                 return array('status' => 'Faulty parameters');
             }
             $aInsertData = array('template' => 'default', 'owner_id' => Yii::app()->session['loginID'], 'active' => 'N', 'language' => $sSurveyLanguage, 'format' => $sformat);
             if (!is_null($iSurveyID)) {
                 $aInsertData['wishSID'] = $iSurveyID;
             }
             try {
                 $iNewSurveyid = Survey::model()->insertNewSurvey($aInsertData);
                 if (!$iNewSurveyid) {
                     return array('status' => 'Creation Failed');
                 }
                 $sTitle = html_entity_decode($sSurveyTitle, ENT_QUOTES, "UTF-8");
                 // Load default email templates for the chosen language
                 $oLanguage = new Limesurvey_lang($sSurveyLanguage);
                 $aDefaultTexts = templateDefaultTexts($oLanguage, 'unescaped');
                 unset($oLanguage);
                 $bIsHTMLEmail = false;
                 $aInsertData = array('surveyls_survey_id' => $iNewSurveyid, 'surveyls_title' => $sTitle, 'surveyls_language' => $sSurveyLanguage);
                 $langsettings = new SurveyLanguageSetting();
                 $langsettings->insertNewSurvey($aInsertData);
                 Permission::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'], $iNewSurveyid);
                 return (int) $iNewSurveyid;
             } catch (Exception $e) {
                 return array('status' => $e->getmessage());
             }
         } else {
             return array('status' => 'No permission');
         }
     } else {
         return array('status' => 'Invalid session key');
     }
 }
开发者ID:kasutori,项目名称:LimeSurvey,代码行数:50,代码来源:remotecontrol_handle.php


注:本文中的SurveyLanguageSetting::insertNewSurvey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。