本文整理汇总了PHP中SurveyLanguageSetting::model方法的典型用法代码示例。如果您正苦于以下问题:PHP SurveyLanguageSetting::model方法的具体用法?PHP SurveyLanguageSetting::model怎么用?PHP SurveyLanguageSetting::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SurveyLanguageSetting
的用法示例。
在下文中一共展示了SurveyLanguageSetting::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
private function query($type, $action, $iSurveyID, $tolang, $baselang, $id1 = "", $id2 = "", $iScaleID = "", $new = "")
{
$amTypeOptions = array();
switch ($action) {
case "queryto":
$baselang = $tolang;
case "querybase":
switch ($type) {
case 'title':
case 'description':
case 'welcome':
case 'end':
case 'emailinvite':
case 'emailinvitebody':
case 'emailreminder':
case 'emailreminderbody':
case 'emailconfirmation':
case 'emailconfirmationbody':
case 'emailregistration':
case 'emailregistrationbody':
case 'email_confirm':
case 'email_confirmbody':
return SurveyLanguageSetting::model()->findAllByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $baselang));
case 'group':
case 'group_desc':
return QuestionGroup::model()->findAllByAttributes(array('sid' => $iSurveyID, 'language' => $baselang), array('order' => 'gid'));
case 'question':
case 'question_help':
return Question::model()->with('parents', 'groups')->findAllByAttributes(array('sid' => $iSurveyID, 'language' => $baselang, 'parent_qid' => 0), array('order' => 'groups.group_order, t.question_order, t.scale_id'));
case 'subquestion':
return Question::model()->with('parents', 'groups')->findAllByAttributes(array('sid' => $iSurveyID, 'language' => $baselang), array('order' => 'groups.group_order, parents.question_order, t.scale_id, t.question_order', 'condition' => 'parents.language=:baselang1 AND groups.language=:baselang2 AND t.parent_qid>0', 'params' => array(':baselang1' => $baselang, ':baselang2' => $baselang)));
case 'answer':
return Answer::model()->with('questions', 'groups')->findAllByAttributes(array('language' => $baselang), array('order' => 'groups.group_order, questions.question_order, t.scale_id, t.sortorder', 'condition' => 'questions.sid=:sid AND questions.language=:baselang1 AND groups.language=:baselang2', 'params' => array(':baselang1' => $baselang, ':baselang2' => $baselang, ':sid' => $iSurveyID)));
}
case "queryupdate":
switch ($type) {
case 'title':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_title' => $new));
case 'description':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_description' => $new));
case 'welcome':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_welcometext' => $new));
case 'end':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_endtext' => $new));
case 'emailinvite':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_invite_subj' => $new));
case 'emailinvitebody':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_invite' => $new));
case 'emailreminder':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_remind_subj' => $new));
case 'emailreminderbody':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_remind' => $new));
case 'emailconfirmation':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_confirm_subj' => $new));
case 'emailconfirmationbody':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_confirm' => $new));
case 'emailregistration':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_register_subj' => $new));
case 'emailregistrationbody':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_register' => $new));
case 'email_confirm':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_confirm_subject' => $new));
case 'email_confirmbody':
return SurveyLanguageSetting::model()->updateByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $tolang), array('surveyls_email_confirm' => $new));
case 'group':
return QuestionGroup::model()->updateByPk(array('gid' => $id1, 'language' => $tolang), array('group_name' => $new), 'sid=:sid', array(':sid' => $iSurveyID));
case 'group_desc':
return QuestionGroup::model()->updateByPk(array('gid' => $id1, 'language' => $tolang), array('description' => $new), 'sid=:sid', array(':sid' => $iSurveyID));
case 'question':
return Question::model()->updateByPk(array('qid' => $id1, 'language' => $tolang), array('question' => $new), 'sid=:sid AND parent_qid=0', array(':sid' => $iSurveyID));
case 'question_help':
return Question::model()->updateByPk(array('qid' => $id1, 'language' => $tolang), array('help' => $new), 'sid=:sid AND parent_qid=0', array(':sid' => $iSurveyID));
case 'subquestion':
return Question::model()->updateByPk(array('qid' => $id1, 'language' => $tolang), array('question' => $new), 'sid=:sid', array(':sid' => $iSurveyID));
case 'answer':
return Answer::model()->updateByPk(array('qid' => $id1, 'code' => $id2, 'language' => $tolang, 'scale_id' => $iScaleID), array('answer' => $new));
}
}
}
示例2: TSVImportSurvey
//.........这里部分代码省略.........
// these aren't used here, but are needed to avoid errors in post-import display
$results['assessments'] = 0;
$results['quota'] = 0;
$results['quotamembers'] = 0;
$results['quotals'] = 0;
// collect information about survey and its language settings
$surveyinfo = array();
$surveyls = array();
foreach ($adata as $row) {
switch ($row['class']) {
case 'S':
if (isset($row['text']) && $row['name'] != 'datecreated') {
$surveyinfo[$row['name']] = $row['text'];
}
break;
case 'SL':
if (!isset($surveyls[$row['language']])) {
$surveyls[$row['language']] = array();
}
if (isset($row['text'])) {
$surveyls[$row['language']][$row['name']] = $row['text'];
}
break;
}
}
$iOldSID = 1;
if (isset($surveyinfo['sid'])) {
$iOldSID = (int) $surveyinfo['sid'];
}
// Create the survey entry
$surveyinfo['startdate'] = NULL;
$surveyinfo['active'] = 'N';
// unset($surveyinfo['datecreated']);
$iNewSID = Survey::model()->insertNewSurvey($surveyinfo);
//or safeDie($clang->gT("Error").": Failed to insert survey<br />");
if (!$iNewSID) {
$results['error'] = Survey::model()->getErrors();
$results['bFailed'] = true;
return $results;
}
$surveyinfo['sid'] = $iNewSID;
$results['surveys']++;
$results['newsid'] = $iNewSID;
$gid = 0;
$gseq = 0;
// group_order
$qid = 0;
$qseq = 0;
// question_order
$qtype = 'T';
$aseq = 0;
// answer sortorder
// set the language for the survey
$_title = 'Missing Title';
foreach ($surveyls as $_lang => $insertdata) {
$insertdata['surveyls_survey_id'] = $iNewSID;
$insertdata['surveyls_language'] = $_lang;
if (isset($insertdata['surveyls_title'])) {
$_title = $insertdata['surveyls_title'];
} else {
$insertdata['surveyls_title'] = $_title;
}
$result = SurveyLanguageSetting::model()->insertNewSurvey($insertdata);
//
if (!$result) {
$results['error'][] = $clang->gT("Error") . " : " . $clang->gT("Failed to insert survey language");
示例3: upgradeSurveys156
function upgradeSurveys156()
{
$sSurveyQuery = "SELECT * FROM {{surveys_languagesettings}}";
$oSurveyResult = Yii::app()->getDb()->createCommand($sSurveyQuery)->queryAll();
foreach ($oSurveyResult as $aSurveyRow) {
$aDefaultTexts = templateDefaultTexts($aSurveyRow['surveyls_language'], 'unescaped');
if (trim(strip_tags($aSurveyRow['surveyls_email_confirm'])) == '') {
$sSurveyUpdateQuery = "update {{surveys}} set sendconfirmation='N' where sid=" . $aSurveyRow['surveyls_survey_id'];
Yii::app()->getDb()->createCommand($sSurveyUpdateQuery)->execute();
$aValues = array('surveyls_email_confirm_subj' => $aDefaultTexts['confirmation_subject'], 'surveyls_email_confirm' => $aDefaultTexts['confirmation']);
SurveyLanguageSetting::model()->updateAll($aValues, 'surveyls_survey_id=:sid', array(':sid' => $aSurveyRow['surveyls_survey_id']));
}
}
}
示例4: update
/**
* Function responsible to process any change in email template.
* @return
*/
function update($iSurveyId)
{
$uploadUrl = Yii::app()->getBaseUrl(true) . substr(Yii::app()->getConfig('uploadurl'), strlen(Yii::app()->getConfig('publicurl')) - 1);
// We need the real path since we check that the resolved file name starts with this path.
$uploadDir = realpath(Yii::app()->getConfig('uploaddir'));
$sSaveMethod = Yii::app()->request->getPost('save', '');
$clang = $this->getController()->lang;
if (Permission::model()->hasSurveyPermission($iSurveyId, 'surveylocale', 'update') && $sSaveMethod != '') {
$languagelist = Survey::model()->findByPk($iSurveyId)->additionalLanguages;
$languagelist[] = Survey::model()->findByPk($iSurveyId)->language;
array_filter($languagelist);
foreach ($languagelist as $langname) {
if (isset($_POST['attachments'][$langname])) {
foreach ($_POST['attachments'][$langname] as $template => &$attachments) {
foreach ($attachments as $index => &$attachment) {
// We again take the real path.
$localName = realpath(urldecode(str_replace($uploadUrl, $uploadDir, $attachment['url'])));
if ($localName !== false) {
if (strpos($localName, $uploadDir) === 0) {
$attachment['url'] = $localName;
$attachment['size'] = filesize($localName);
} else {
unset($attachments[$index]);
}
} else {
unset($attachments[$index]);
}
}
unset($attachments);
}
} else {
$_POST['attachments'][$langname] = array();
}
$attributes = array('surveyls_email_invite_subj' => $_POST['email_invitation_subj_' . $langname], 'surveyls_email_invite' => $_POST['email_invitation_' . $langname], 'surveyls_email_remind_subj' => $_POST['email_reminder_subj_' . $langname], 'surveyls_email_remind' => $_POST['email_reminder_' . $langname], 'surveyls_email_register_subj' => $_POST['email_registration_subj_' . $langname], 'surveyls_email_register' => $_POST['email_registration_' . $langname], 'surveyls_email_confirm_subj' => $_POST['email_confirmation_subj_' . $langname], 'surveyls_email_confirm' => $_POST['email_confirmation_' . $langname], 'email_admin_notification_subj' => $_POST['email_admin_notification_subj_' . $langname], 'email_admin_notification' => $_POST['email_admin_notification_' . $langname], 'email_admin_responses_subj' => $_POST['email_admin_detailed_notification_subj_' . $langname], 'email_admin_responses' => $_POST['email_admin_detailed_notification_' . $langname], 'attachments' => serialize($_POST['attachments'][$langname]));
$usquery = SurveyLanguageSetting::model()->updateAll($attributes, 'surveyls_survey_id = :ssid AND surveyls_language = :sl', array(':ssid' => $iSurveyId, ':sl' => $langname));
}
Yii::app()->session['flashmessage'] = $clang->gT("Email templates successfully saved.");
$this->getController()->redirect(array('admin/emailtemplates/sa/index/surveyid/' . $iSurveyId));
}
if ($sSaveMethod == 'saveclose') {
$this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyId));
} else {
self::index($iSurveyId);
}
}
示例5: emailTokens
/**
* Sends email to tokens - invitation and reminders
*
* @param mixed $iSurveyID
* @param array $aResultTokens
* @param string $sType type of notification invite|register|remind
* @return array of results
*/
function emailTokens($iSurveyID, $aResultTokens, $sType)
{
Yii::app()->loadHelper('common');
$oSurvey = Survey::model()->findByPk($iSurveyID);
if (getEmailFormat($iSurveyID) == 'html') {
$bHtml = true;
} else {
$bHtml = false;
}
$attributes = array_keys(getTokenFieldsAndNames($iSurveyID));
$oSurveyLocale = SurveyLanguageSetting::model()->findAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
$oTokens = Token::model($iSurveyID);
$aSurveyLangs = $oSurvey->additionalLanguages;
array_unshift($aSurveyLangs, $oSurvey->language);
//Convert result to associative array to minimize SurveyLocale access attempts
foreach ($oSurveyLocale as $rows) {
$oTempObject = array();
foreach ($rows as $k => $v) {
$oTempObject[$k] = $v;
}
$aSurveyLocaleData[$rows['surveyls_language']] = $oTempObject;
}
foreach ($aResultTokens as $aTokenRow) {
//Select language
$aTokenRow['language'] = trim($aTokenRow['language']);
$found = array_search($aTokenRow['language'], $aSurveyLangs);
if ($aTokenRow['language'] == '' || $found == false) {
$aTokenRow['language'] = $oSurvey['language'];
}
$sTokenLanguage = $aTokenRow['language'];
//Build recipient
$to = array();
$aEmailaddresses = explode(';', $aTokenRow['email']);
foreach ($aEmailaddresses as $sEmailaddress) {
$to[] = $aTokenRow['firstname'] . " " . $aTokenRow['lastname'] . " <{$sEmailaddress}>";
}
//Populate attributes
$fieldsarray["{SURVEYNAME}"] = $aSurveyLocaleData[$sTokenLanguage]['surveyls_title'];
if ($fieldsarray["{SURVEYNAME}"] == '') {
$fieldsarray["{SURVEYNAME}"] = $aSurveyLocaleData[$oSurvey['language']]['surveyls_title'];
}
$fieldsarray["{SURVEYDESCRIPTION}"] = $aSurveyLocaleData[$sTokenLanguage]['surveyls_description'];
if ($fieldsarray["{SURVEYDESCRIPTION}"] == '') {
$fieldsarray["{SURVEYDESCRIPTION}"] = $aSurveyLocaleData[$oSurvey['language']]['surveyls_description'];
}
$fieldsarray["{ADMINNAME}"] = $oSurvey['admin'];
$fieldsarray["{ADMINEMAIL}"] = $oSurvey['adminemail'];
$from = $fieldsarray["{ADMINNAME}"] . ' <' . $fieldsarray["{ADMINEMAIL}"] . '>';
if ($from == '') {
$from = Yii::app()->getConfig('siteadminemail');
}
foreach ($attributes as $attributefield) {
$fieldsarray['{' . strtoupper($attributefield) . '}'] = $aTokenRow[$attributefield];
$fieldsarray['{TOKEN:' . strtoupper($attributefield) . '}'] = $aTokenRow[$attributefield];
}
//create urls
$fieldsarray["{OPTOUTURL}"] = Yii::app()->getController()->createAbsoluteUrl("/optout/tokens/langcode/" . trim($aTokenRow['language']) . "/surveyid/{$iSurveyID}/token/{$aTokenRow['token']}");
$fieldsarray["{OPTINURL}"] = Yii::app()->getController()->createAbsoluteUrl("/optin/tokens/langcode/" . trim($aTokenRow['language']) . "/surveyid/{$iSurveyID}/token/{$aTokenRow['token']}");
$fieldsarray["{SURVEYURL}"] = Yii::app()->getController()->createAbsoluteUrl("/survey/index/sid/{$iSurveyID}/token/{$aTokenRow['token']}/lang/" . trim($aTokenRow['language']) . "/");
if ($bHtml) {
foreach (array('OPTOUT', 'OPTIN', 'SURVEY') as $key) {
$url = $fieldsarray["{{$key}URL}"];
$fieldsarray["{{$key}URL}"] = "<a href='{$url}'>" . htmlspecialchars($url) . '</a>';
if ($key == 'SURVEY') {
$barebone_link = $url;
}
}
}
//mail headers
$customheaders = array('1' => "X-surveyid: " . $iSurveyID, '2' => "X-tokenid: " . $fieldsarray["{TOKEN}"]);
global $maildebug;
//choose appriopriate email message
if ($sType == 'invite') {
$sSubject = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_invite_subj'];
$sMessage = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_invite'];
} else {
if ($sType == 'register') {
$sSubject = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_register_subj'];
$sMessage = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_register'];
} else {
$sSubject = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_remind_subj'];
$sMessage = $aSurveyLocaleData[$sTokenLanguage]['surveyls_email_remind'];
}
}
$modsubject = Replacefields($sSubject, $fieldsarray);
$modmessage = Replacefields($sMessage, $fieldsarray);
if (isset($barebone_link)) {
$modsubject = str_replace("@@SURVEYURL@@", $barebone_link, $modsubject);
$modmessage = str_replace("@@SURVEYURL@@", $barebone_link, $modmessage);
}
if (isset($aTokenRow['validfrom']) && trim($aTokenRow['validfrom']) != '' && convertDateTimeFormat($aTokenRow['validfrom'], 'Y-m-d H:i:s', 'U') * 1 > date('U') * 1) {
$aResult[$aTokenRow['tid']] = array('name' => $fieldsarray["{FIRSTNAME}"] . " " . $fieldsarray["{LASTNAME}"], 'email' => $fieldsarray["{EMAIL}"], 'status' => 'fail', 'error' => 'Token not valid yet');
//.........这里部分代码省略.........
示例6: index
/**
* Database::index()
*
* @param mixed $sa
* @return
*/
function index($sa = null)
{
$sAction = Yii::app()->request->getPost('action');
$clang = $this->getController()->lang;
$iSurveyID = returnGlobal('sid');
$iQuestionGroupID = returnGlobal('gid');
$iQuestionID = returnGlobal('qid');
$sDBOutput = '';
if (Yii::app()->getConfig('filterxsshtml') && !Permission::model()->hasGlobalPermission('superadmin', 'read')) {
$oPurifier = new CHtmlPurifier();
$oPurifier->options = array('URI.AllowedSchemes' => array('http' => true, 'https' => true));
$bXSSFilter = true;
} else {
$bXSSFilter = false;
}
if ($sAction == "updatedefaultvalues" && Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update')) {
$aSurveyLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($aSurveyLanguages, $sBaseLanguage);
Question::model()->updateAll(array('same_default' => Yii::app()->request->getPost('samedefault') ? 1 : 0), 'sid=:sid ANd qid=:qid', array(':sid' => $iSurveyID, ':qid' => $iQuestionID));
$arQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
$sQuestionType = $arQuestion['type'];
$aQuestionTypeList = getQuestionTypeList('', 'array');
if ($aQuestionTypeList[$sQuestionType]['answerscales'] > 0 && $aQuestionTypeList[$sQuestionType]['subquestions'] == 0) {
for ($iScaleID = 0; $iScaleID < $aQuestionTypeList[$sQuestionType]['answerscales']; $iScaleID++) {
foreach ($aSurveyLanguages as $sLanguage) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage))) {
$this->_updateDefaultValues($iQuestionID, 0, $iScaleID, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage), true);
}
if (!is_null(Yii::app()->request->getPost('other_' . $iScaleID . '_' . $sLanguage))) {
$this->_updateDefaultValues($iQuestionID, 0, $iScaleID, 'other', $sLanguage, Yii::app()->request->getPost('other_' . $iScaleID . '_' . $sLanguage), true);
}
}
}
}
if ($aQuestionTypeList[$sQuestionType]['subquestions'] > 0) {
foreach ($aSurveyLanguages as $sLanguage) {
$arQuestions = Question::model()->findAllByAttributes(array('sid' => $iSurveyID, 'gid' => $iQuestionGroupID, 'parent_qid' => $iQuestionID, 'language' => $sLanguage, 'scale_id' => 0));
for ($iScaleID = 0; $iScaleID < $aQuestionTypeList[$sQuestionType]['subquestions']; $iScaleID++) {
foreach ($arQuestions as $aSubquestionrow) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage . '_' . $aSubquestionrow['qid']))) {
$this->_updateDefaultValues($iQuestionID, $aSubquestionrow['qid'], $iScaleID, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage . '_' . $aSubquestionrow['qid']), true);
}
}
}
}
}
if ($aQuestionTypeList[$sQuestionType]['answerscales'] == 0 && $aQuestionTypeList[$sQuestionType]['subquestions'] == 0) {
foreach ($aSurveyLanguages as $sLanguage) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage . '_0'))) {
$this->_updateDefaultValues($iQuestionID, 0, 0, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage . '_0'), true);
}
}
}
Yii::app()->session['flashmessage'] = $clang->gT("Default value settings were successfully saved.");
LimeExpressionManager::SetDirtyFlag();
if ($sDBOutput != '') {
echo $sDBOutput;
} else {
$this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyID . '/gid/' . $iQuestionGroupID . '/qid/' . $iQuestionID));
}
}
if ($sAction == "updateansweroptions" && Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update')) {
Yii::app()->loadHelper('database');
$aSurveyLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($aSurveyLanguages, $sBaseLanguage);
$arQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
$sQuestionType = $arQuestion['type'];
// Checked)
$aQuestionTypeList = getQuestionTypeList('', 'array');
$iScaleCount = $aQuestionTypeList[$sQuestionType]['answerscales'];
//First delete all answers
Answer::model()->deleteAllByAttributes(array('qid' => $iQuestionID));
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
for ($iScaleID = 0; $iScaleID < $iScaleCount; $iScaleID++) {
$iMaxCount = (int) Yii::app()->request->getPost('answercount_' . $iScaleID);
for ($iSortOrderID = 1; $iSortOrderID < $iMaxCount; $iSortOrderID++) {
$sCode = sanitize_paranoid_string(Yii::app()->request->getPost('code_' . $iSortOrderID . '_' . $iScaleID));
if (Yii::app()->request->getPost('oldcode_' . $iSortOrderID . '_' . $iScaleID)) {
$sOldCode = sanitize_paranoid_string(Yii::app()->request->getPost('oldcode_' . $iSortOrderID . '_' . $iScaleID));
if ($sCode !== $sOldCode) {
Condition::model()->updateAll(array('value' => $sCode), 'cqid=:cqid AND value=:value', array(':cqid' => $iQuestionID, ':value' => $sOldCode));
}
}
$iAssessmentValue = (int) Yii::app()->request->getPost('assessment_' . $iSortOrderID . '_' . $iScaleID);
foreach ($aSurveyLanguages as $sLanguage) {
$sAnswerText = Yii::app()->request->getPost('answer_' . $sLanguage . '_' . $iSortOrderID . '_' . $iScaleID);
if ($bXSSFilter) {
$sAnswerText = $oPurifier->purify($sAnswerText);
} else {
$sAnswerText = html_entity_decode($sAnswerText, ENT_QUOTES, "UTF-8");
}
// Fix bug with FCKEditor saving strange BR types
//.........这里部分代码省略.........
示例7: editlocalsettings
/**
* Load editing of local settings of a survey screen.
*
* @access public
* @param int $iSurveyID
* @return void
*/
public function editlocalsettings($iSurveyID)
{
$clang = $this->getController()->lang;
$aData['surveyid'] = $iSurveyID = sanitize_int($iSurveyID);
$aViewUrls = array();
if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveylocale', 'read')) {
if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveylocale', 'update')) {
Yii::app()->session['FileManagerContext'] = "edit:survey:{$iSurveyID}";
}
$grplangs = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$baselang = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($grplangs, $baselang);
Yii::app()->loadHelper("admin/htmleditor");
$aViewUrls['output'] = PrepareEditorScript(false, $this->getController());
foreach ($grplangs as $sLang) {
// this one is created to get the right default texts fo each language
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('surveytranslator');
$bplang = $this->getController()->lang;
//new lang($grouplang);
$esrow = SurveyLanguageSetting::model()->findByPk(array('surveyls_survey_id' => $iSurveyID, 'surveyls_language' => $sLang))->getAttributes();
$aTabTitles[$sLang] = getLanguageNameFromCode($esrow['surveyls_language'], false);
if ($esrow['surveyls_language'] == Survey::model()->findByPk($iSurveyID)->language) {
$aTabTitles[$sLang] .= '(' . $clang->gT("Base language") . ')';
}
$esrow = array_map('htmlspecialchars', $esrow);
$aData['esrow'] = $esrow;
$aData['action'] = "editsurveylocalesettings";
$aData['clang'] = $clang;
$aTabContents[$sLang] = $this->getController()->renderPartial('/admin/survey/editLocalSettings_view', $aData, true);
}
$aData['has_permissions'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveylocale', 'update');
$aData['surveyls_language'] = $esrow["surveyls_language"];
$aData['aTabContents'] = $aTabContents;
$aData['aTabTitles'] = $aTabTitles;
$aViewUrls[] = 'editLocalSettings_main_view';
} else {
$this->getController()->error('Access denied');
}
$this->_renderWrappedTemplate('survey', $aViewUrls, $aData);
}
示例8: updatetokenattributedescriptions
/**
* updatetokenattributedescriptions action
*/
function updatetokenattributedescriptions($iSurveyId)
{
$clang = $this->getController()->lang;
$iSurveyId = sanitize_int($iSurveyId);
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'update')) {
Yii::app()->session['flashmessage'] = $clang->gT("You do not have sufficient rights to access this page.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
$bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
if (!$bTokenExists) {
self::_newtokentable($iSurveyId);
}
// find out the existing token attribute fieldnames
$tokenattributefieldnames = getAttributeFieldNames($iSurveyId);
$languages = array_merge((array) Survey::model()->findByPk($iSurveyId)->language, Survey::model()->findByPk($iSurveyId)->additionalLanguages);
$fieldcontents = array();
$captions = array();
foreach ($tokenattributefieldnames as $fieldname) {
$fieldcontents[$fieldname] = array('description' => strip_tags(Yii::app()->request->getPost('description_' . $fieldname)), 'mandatory' => Yii::app()->request->getPost('mandatory_' . $fieldname) == 'Y' ? 'Y' : 'N', 'show_register' => Yii::app()->request->getPost('show_register_' . $fieldname) == 'Y' ? 'Y' : 'N', 'cpdbmap' => Yii::app()->request->getPost('cpdbmap_' . $fieldname));
foreach ($languages as $language) {
$captions[$language][$fieldname] = $_POST["caption_{$fieldname}_{$language}"];
}
}
Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => serialize($fieldcontents)));
foreach ($languages as $language) {
$ls = SurveyLanguageSetting::model()->findByAttributes(array('surveyls_survey_id' => $iSurveyId, 'surveyls_language' => $language));
$ls->surveyls_attributecaptions = json_encode($captions[$language]);
$ls->save();
}
$aData['thissurvey'] = getSurveyInfo($iSurveyId);
$aData['surveyid'] = $iSurveyId;
$this->_renderWrappedTemplate('token', array('tokenbar', 'message' => array('title' => $clang->gT('Token attribute descriptions were successfully updated.'), 'message' => "<br /><input type='button' value='" . $clang->gT('Back to attribute field management.') . "' onclick=\"window.open('" . $this->getController()->createUrl("/admin/tokens/sa/managetokenattributes/surveyid/{$iSurveyId}") . "', '_top')\" />")), $aData);
}
示例9: getDateFormatForSID
/**
* Get the date format for a specified survey
*
* @param $surveyid integer Survey id
* @param $languagecode string Survey language code (optional)
* @returns integer
*
*/
function getDateFormatForSID($surveyid, $languagecode = '')
{
if (!isset($languagecode) || $languagecode == '') {
$languagecode = Survey::model()->findByPk($surveyid)->language;
}
$data = SurveyLanguageSetting::model()->getDateFormat($surveyid, $languagecode);
if (empty($data)) {
$dateformat = 0;
} else {
$dateformat = (int) $data;
}
return (int) $dateformat;
}
示例10: updatetokenattributedescriptions
/**
* updatetokenattributedescriptions action
*/
public function updatetokenattributedescriptions($iSurveyId)
{
$iSurveyId = sanitize_int($iSurveyId);
if (!Permission::model()->hasSurveyPermission($iSurveyId, 'tokens', 'update') && !Permission::model()->hasSurveyPermission($iSurveyId, 'surveysettings', 'update')) {
Yii::app()->session['flashmessage'] = gT("You do not have permission to access this page.");
$this->getController()->redirect(array("/admin/survey/sa/view/surveyid/{$iSurveyId}"));
}
// CHECK TO SEE IF A TOKEN TABLE EXISTS FOR THIS SURVEY
$bTokenExists = tableExists('{{tokens_' . $iSurveyId . '}}');
if (!$bTokenExists) {
self::_newtokentable($iSurveyId);
}
// find out the existing token attribute fieldnames
$tokenattributefieldnames = getAttributeFieldNames($iSurveyId);
$languages = array_merge((array) Survey::model()->findByPk($iSurveyId)->language, Survey::model()->findByPk($iSurveyId)->additionalLanguages);
$fieldcontents = array();
$captions = array();
foreach ($tokenattributefieldnames as $fieldname) {
$fieldcontents[$fieldname] = array('description' => strip_tags(Yii::app()->request->getPost('description_' . $fieldname)), 'mandatory' => Yii::app()->request->getPost('mandatory_' . $fieldname) == '1' ? 'Y' : 'N', 'show_register' => Yii::app()->request->getPost('show_register_' . $fieldname) == '1' ? 'Y' : 'N', 'cpdbmap' => Yii::app()->request->getPost('cpdbmap_' . $fieldname));
foreach ($languages as $language) {
$captions[$language][$fieldname] = Yii::app()->request->getPost("caption_{$fieldname}_{$language}");
}
}
Survey::model()->updateByPk($iSurveyId, array('attributedescriptions' => json_encode($fieldcontents)));
foreach ($languages as $language) {
$ls = SurveyLanguageSetting::model()->findByAttributes(array('surveyls_survey_id' => $iSurveyId, 'surveyls_language' => $language));
$ls->surveyls_attributecaptions = json_encode($captions[$language]);
$ls->save();
}
Yii::app()->session['flashmessage'] = gT('Token attribute descriptions were successfully updated.');
//admin/tokens/sa/browse/surveyid/652779//
$this->getController()->redirect(array("/admin/tokens/sa/managetokenattributes/surveyid/{$iSurveyId}"));
}
示例11: list_surveys
/**
* RPC Routine to list the ids and info of surveys belonging to a user.
* Returns array of ids and info.
* If user is admin he can get surveys of every user (parameter sUser) or all surveys (sUser=null)
* Else only the syrveys belonging to the user requesting will be shown.
*
* @access public
* @param string $sSessionKey Auth credentials
* @param string $sUser Optional username to get list of surveys
* @return array The list of surveys
*/
public function list_surveys($sSessionKey, $sUser = NULL)
{
if ($this->_checkSessionKey($sSessionKey)) {
$sCurrentUser = Yii::app()->session['user'];
if (Permission::model()->hasGlobalPermission('surveys', 'read')) {
if ($sUser == null) {
$aUserSurveys = Survey::model()->findAll();
} else {
$aUserData = User::model()->findByAttributes(array('users_name' => $sUser));
if (!isset($aUserData)) {
return array('status' => 'Invalid user');
} else {
$sUid = $aUserData->attributes['uid'];
}
}
} else {
if ($sCurrentUser == $sUser || $sUser == null) {
$sUid = User::model()->findByAttributes(array('users_name' => $sCurrentUser))->uid;
} else {
return array('status' => 'No permission');
}
}
if ($sUid != null) {
//we request user and not admin surveys
$surveyPermissions = Permission::model()->findAllByAttributes(array('entity' => 'survey', 'uid' => $sUid));
foreach ($surveyPermissions as $row) {
$ids[] = $row['entity_id'];
}
$ids = array_unique($ids);
$aUserSurveys = Survey::model()->findAllByAttributes(array("sid" => $ids));
}
if (count($aUserSurveys) == 0) {
return array('status' => 'No surveys found');
}
foreach ($aUserSurveys as $oSurvey) {
$oSurveyLanguageSettings = SurveyLanguageSetting::model()->findByAttributes(array('surveyls_survey_id' => $oSurvey->primaryKey, 'surveyls_language' => $oSurvey->language));
if (!isset($oSurveyLanguageSettings)) {
$aSurveyTitle = '';
} else {
$aSurveyTitle = $oSurveyLanguageSettings->attributes['surveyls_title'];
}
// AUTHOR: AJ
// DATE: 27/08/15 & 04/11/15
// CHANGE: added owner_id and datecreated
$aData[] = array('sid' => $oSurvey->primaryKey, 'surveyls_title' => $aSurveyTitle, 'startdate' => $oSurvey->attributes['startdate'], 'expires' => $oSurvey->attributes['expires'], 'active' => $oSurvey->attributes['active'], 'created' => $oSurvey->attributes['datecreated'], 'owner_id' => $oSurvey->attributes['owner_id']);
}
return $aData;
} else {
return array('status' => 'Invalid session key');
}
}
示例12: deleteSurvey
/**
* Deletes a survey and all its data
*
* @access public
* @param int $iSurveyID
* @param bool @recursive
* @return void
*/
public function deleteSurvey($iSurveyID, $recursive = true)
{
Survey::model()->deleteByPk($iSurveyID);
if ($recursive == true) {
if (tableExists("{{survey_" . intval($iSurveyID) . "}}")) {
Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "}}");
}
if (tableExists("{{survey_" . intval($iSurveyID) . "_timings}}")) {
Yii::app()->db->createCommand()->dropTable("{{survey_" . intval($iSurveyID) . "_timings}}");
}
if (tableExists("{{tokens_" . intval($iSurveyID) . "}}")) {
Yii::app()->db->createCommand()->dropTable("{{tokens_" . intval($iSurveyID) . "}}");
}
/* Remove User/global settings part : need Question and QuestionGroup*/
// Settings specific for this survey
$oCriteria = new CDbCriteria();
$oCriteria->compare('stg_name', 'last_%', true, 'AND', false);
$oCriteria->compare('stg_value', $iSurveyID, false, 'AND');
SettingGlobal::model()->deleteAll($oCriteria);
// Settings specific for this survey, 2nd part
$oCriteria = new CDbCriteria();
$oCriteria->compare('stg_name', 'last_%' . $iSurveyID . '%', true, 'AND', false);
SettingGlobal::model()->deleteAll($oCriteria);
// All Group id from this survey for ALL users
$aGroupId = CHtml::listData(QuestionGroup::model()->findAll(array('select' => 'gid', 'condition' => 'sid=:sid', 'params' => array(':sid' => $iSurveyID))), 'gid', 'gid');
$oCriteria = new CDbCriteria();
$oCriteria->compare('stg_name', 'last_question_gid_%', true, 'AND', false);
if (Yii::app()->db->getDriverName() == 'pgsql') {
$oCriteria->addInCondition('CAST(stg_value as ' . App()->db->schema->getColumnType("integer") . ')', $aGroupId);
} else {
$oCriteria->addInCondition('stg_value', $aGroupId);
}
SettingGlobal::model()->deleteAll($oCriteria);
// All Question id from this survey for ALL users
$aQuestionId = CHtml::listData(Question::model()->findAll(array('select' => 'qid', 'condition' => 'sid=:sid', 'params' => array(':sid' => $iSurveyID))), 'qid', 'qid');
$oCriteria = new CDbCriteria();
$oCriteria->compare('stg_name', 'last_question_%', true, 'OR', false);
if (Yii::app()->db->getDriverName() == 'pgsql') {
$oCriteria->addInCondition('CAST(stg_value as ' . App()->db->schema->getColumnType("integer") . ')', $aQuestionId);
} else {
$oCriteria->addInCondition('stg_value', $aQuestionId);
}
SettingGlobal::model()->deleteAll($oCriteria);
$oResult = Question::model()->findAllByAttributes(array('sid' => $iSurveyID));
foreach ($oResult as $aRow) {
Answer::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
Condition::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
QuestionAttribute::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
DefaultValue::model()->deleteAllByAttributes(array('qid' => $aRow['qid']));
}
Question::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
Assessment::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
QuestionGroup::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
SurveyLanguageSetting::model()->deleteAllByAttributes(array('surveyls_survey_id' => $iSurveyID));
Permission::model()->deleteAllByAttributes(array('entity_id' => $iSurveyID, 'entity' => 'survey'));
SavedControl::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
SurveyURLParameter::model()->deleteAllByAttributes(array('sid' => $iSurveyID));
//Remove any survey_links to the CPDB
SurveyLink::model()->deleteLinksBySurvey($iSurveyID);
Quota::model()->deleteQuota(array('sid' => $iSurveyID), true);
}
}
示例13: _checkintegrity
/**
* This function checks the LimeSurvey database for logical consistency and returns an according array
* containing all issues in the particular tables.
* @returns Array with all found issues.
*/
protected function _checkintegrity()
{
$clang = Yii::app()->lang;
/*** Plainly delete survey permissions if the survey or user does not exist ***/
$users = User::model()->findAll();
$uids = array();
foreach ($users as $user) {
$uids[] = $user['uid'];
}
$oCriteria = new CDbCriteria();
$oCriteria->addNotInCondition('uid', $uids, 'OR');
$surveys = Survey::model()->findAll();
$sids = array();
foreach ($surveys as $survey) {
$sids[] = $survey['sid'];
}
$oCriteria->addNotInCondition('entity_id', $sids, 'OR');
$oCriteria->addCondition("entity='survey'");
Permission::model()->deleteAll($oCriteria);
// Deactivate surveys that have a missing response table
foreach ($surveys as $survey) {
if ($survey['active'] == 'Y' && !tableExists("{{survey_{$survey['sid']}}}")) {
Survey::model()->updateByPk($survey['sid'], array('active' => 'N'));
}
}
unset($surveys);
// Fix subquestions
fixSubquestions();
/*** Check for active survey tables with missing survey entry and rename them ***/
$sDBPrefix = Yii::app()->db->tablePrefix;
$sQuery = dbSelectTablesLike('{{survey}}\\_%');
$aResult = dbQueryOrFalse($sQuery);
foreach ($aResult->readAll() as $aRow) {
$sTableName = substr(reset($aRow), strlen($sDBPrefix));
if ($sTableName == 'survey_links' || $sTableName == 'survey_url_parameters') {
continue;
}
$aTableName = explode('_', $sTableName);
if (isset($aTableName[1]) && ctype_digit($aTableName[1])) {
$iSurveyID = $aTableName[1];
if (!in_array($iSurveyID, $sids)) {
$sDate = date('YmdHis') . rand(1, 1000);
$sOldTable = "survey_{$iSurveyID}";
$sNewTable = "old_survey_{$iSurveyID}_{$sDate}";
try {
$deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
} catch (CDbException $e) {
die('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:<br />' . htmlspecialchars($e) . '<br />');
}
}
}
}
/*** Check for active token tables with missing survey entry ***/
$aResult = dbQueryOrFalse(dbSelectTablesLike('{{tokens}}\\_%'));
foreach ($aResult->readAll() as $aRow) {
$sTableName = substr(reset($aRow), strlen($sDBPrefix));
$iSurveyID = substr($sTableName, strpos($sTableName, '_') + 1);
if (!in_array($iSurveyID, $sids)) {
$sDate = date('YmdHis') . rand(1, 1000);
$sOldTable = "tokens_{$iSurveyID}";
$sNewTable = "old_tokens_{$iSurveyID}_{$sDate}";
try {
$deactivateresult = Yii::app()->db->createCommand()->renameTable("{{{$sOldTable}}}", "{{{$sNewTable}}}");
} catch (CDbException $e) {
die('Couldn\'t make backup of the survey table. Please try again. The database reported the following error:<br />' . htmlspecialchars($e) . '<br />');
}
}
}
/**********************************************************************/
/* Check conditions */
/**********************************************************************/
$okQuestion = array();
$sQuery = 'SELECT cqid,cid,cfieldname FROM {{conditions}}';
$aConditions = Yii::app()->db->createCommand($sQuery)->queryAll();
foreach ($aConditions as $condition) {
if ($condition['cqid'] != 0) {
// skip case with cqid=0 for codnitions on {TOKEN:EMAIL} for instance
if (!array_key_exists($condition['cqid'], $okQuestion)) {
$iRowCount = Question::model()->countByAttributes(array('qid' => $condition['cqid']));
if (Question::model()->hasErrors()) {
safeDie(Question::model()->getError());
}
if (!$iRowCount) {
$aDelete['conditions'][] = array('cid' => $condition['cid'], 'reason' => $clang->gT('No matching CQID'));
} else {
$okQuestion[$condition['cqid']] = $condition['cqid'];
}
}
}
if ($condition['cfieldname']) {
if (preg_match('/^\\+{0,1}[0-9]+X[0-9]+X*$/', $condition['cfieldname'])) {
// only if cfieldname isn't Tag such as {TOKEN:EMAIL} or any other token
list($surveyid, $gid, $rest) = explode('X', $condition['cfieldname']);
$iRowCount = count(QuestionGroup::model()->findAllByAttributes(array('gid' => $gid)));
if (QuestionGroup::model()->hasErrors()) {
//.........这里部分代码省略.........
示例14: list_surveys
/**
* RPC Routine to list the ids and info of surveys belonging to a user.
* Returns array of ids and info.
* If user is admin he can get surveys of every user (parameter sUser) or all surveys (sUser=null)
* Else only the syrveys belonging to the user requesting will be shown.
*
* @access public
* @param string $sSessionKey Auth credentials
* @param string $sUser Optional username to get list of surveys
* @return array The list of surveys
*/
public function list_surveys($sSessionKey, $sUsername = NULL)
{
if ($this->_checkSessionKey($sSessionKey)) {
$oSurvey = new Survey();
if (!Permission::model()->hasGlobalPermission('superadmin', 'read') && $sUsername == null) {
$oSurvey->permission(Yii::app()->user->getId());
} elseif ($sUsername != null) {
$aUserData = User::model()->findByAttributes(array('users_name' => $sUsername));
if (!isset($aUserData)) {
return array('status' => 'Invalid user');
} else {
$sUid = $aUserData->attributes['uid'];
}
$oSurvey->permission($sUid);
}
$aUserSurveys = $oSurvey->with(array('languagesettings' => array('condition' => 'surveyls_language=language'), 'owner'))->findAll();
if (count($aUserSurveys) == 0) {
return array('status' => 'No surveys found');
}
foreach ($aUserSurveys as $oSurvey) {
$oSurveyLanguageSettings = SurveyLanguageSetting::model()->findByAttributes(array('surveyls_survey_id' => $oSurvey->primaryKey, 'surveyls_language' => $oSurvey->language));
if (!isset($oSurveyLanguageSettings)) {
$aSurveyTitle = '';
} else {
$aSurveyTitle = $oSurveyLanguageSettings->attributes['surveyls_title'];
}
$aData[] = array('sid' => $oSurvey->primaryKey, 'surveyls_title' => $aSurveyTitle, 'startdate' => $oSurvey->attributes['startdate'], 'expires' => $oSurvey->attributes['expires'], 'active' => $oSurvey->attributes['active']);
}
return $aData;
} else {
return array('status' => 'Invalid session key');
}
}
示例15: index
/**
* Database::index()
*
* @param mixed $sa
* @return
*/
function index($sa = null)
{
$sAction = Yii::app()->request->getPost('action');
$iSurveyID = returnGlobal('sid');
$iQuestionGroupID = returnGlobal('gid');
$iQuestionID = returnGlobal('qid');
$sDBOutput = '';
$oFixCKeditor = new LSYii_Validators();
$oFixCKeditor->fixCKeditor = true;
$oFixCKeditor->xssfilter = false;
if ($sAction == "updatedefaultvalues" && Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update')) {
$aSurveyLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($aSurveyLanguages, $sBaseLanguage);
Question::model()->updateAll(array('same_default' => Yii::app()->request->getPost('samedefault') ? 1 : 0), 'sid=:sid ANd qid=:qid', array(':sid' => $iSurveyID, ':qid' => $iQuestionID));
$arQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
$sQuestionType = $arQuestion['type'];
$aQuestionTypeList = getQuestionTypeList('', 'array');
if ($aQuestionTypeList[$sQuestionType]['answerscales'] > 0 && $aQuestionTypeList[$sQuestionType]['subquestions'] == 0) {
for ($iScaleID = 0; $iScaleID < $aQuestionTypeList[$sQuestionType]['answerscales']; $iScaleID++) {
foreach ($aSurveyLanguages as $sLanguage) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage))) {
$this->_updateDefaultValues($iQuestionID, 0, $iScaleID, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage), true);
}
if (!is_null(Yii::app()->request->getPost('other_' . $iScaleID . '_' . $sLanguage))) {
$this->_updateDefaultValues($iQuestionID, 0, $iScaleID, 'other', $sLanguage, Yii::app()->request->getPost('other_' . $iScaleID . '_' . $sLanguage), true);
}
}
}
}
if ($aQuestionTypeList[$sQuestionType]['subquestions'] > 0) {
foreach ($aSurveyLanguages as $sLanguage) {
$arQuestions = Question::model()->findAllByAttributes(array('sid' => $iSurveyID, 'gid' => $iQuestionGroupID, 'parent_qid' => $iQuestionID, 'language' => $sLanguage, 'scale_id' => 0));
for ($iScaleID = 0; $iScaleID < $aQuestionTypeList[$sQuestionType]['subquestions']; $iScaleID++) {
foreach ($arQuestions as $aSubquestionrow) {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage . '_' . $aSubquestionrow['qid']))) {
$this->_updateDefaultValues($iQuestionID, $aSubquestionrow['qid'], $iScaleID, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_' . $iScaleID . '_' . $sLanguage . '_' . $aSubquestionrow['qid']), true);
}
}
}
}
}
if ($aQuestionTypeList[$sQuestionType]['answerscales'] == 0 && $aQuestionTypeList[$sQuestionType]['subquestions'] == 0) {
foreach ($aSurveyLanguages as $sLanguage) {
// Qick and dirty insert for yes/no defaul value
// write the the selectbox option, or if "EM" is slected, this value to table
if ($sQuestionType == 'Y') {
/// value for all langs
if (Yii::app()->request->getPost('samedefault') == 1) {
$sLanguage = $aSurveyLanguages[0];
// turn
} else {
$sCurrentLang = $sLanguage;
// edit the next lines
}
if (Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage) == 'EM') {
// Case EM, write expression to database
$this->_updateDefaultValues($iQuestionID, 0, 0, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage . '_EM'), true);
} else {
// Case "other", write list value to database
$this->_updateDefaultValues($iQuestionID, 0, 0, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage), true);
}
///// end yes/no
} else {
if (!is_null(Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage . '_0'))) {
$this->_updateDefaultValues($iQuestionID, 0, 0, '', $sLanguage, Yii::app()->request->getPost('defaultanswerscale_0_' . $sLanguage . '_0'), true);
}
}
}
}
Yii::app()->session['flashmessage'] = gT("Default value settings were successfully saved.");
LimeExpressionManager::SetDirtyFlag();
if ($sDBOutput != '') {
echo $sDBOutput;
} else {
$this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyID . '/gid/' . $iQuestionGroupID . '/qid/' . $iQuestionID));
}
}
if ($sAction == "updateansweroptions" && Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update')) {
Yii::app()->loadHelper('database');
$aSurveyLanguages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
array_unshift($aSurveyLanguages, $sBaseLanguage);
$arQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
$sQuestionType = $arQuestion['type'];
// Checked)
$aQuestionTypeList = getQuestionTypeList('', 'array');
$iScaleCount = $aQuestionTypeList[$sQuestionType]['answerscales'];
//First delete all answers
Answer::model()->deleteAllByAttributes(array('qid' => $iQuestionID));
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
for ($iScaleID = 0; $iScaleID < $iScaleCount; $iScaleID++) {
$iMaxCount = (int) Yii::app()->request->getPost('answercount_' . $iScaleID);
for ($iSortOrderID = 1; $iSortOrderID < $iMaxCount; $iSortOrderID++) {
//.........这里部分代码省略.........