本文整理汇总了PHP中LimeExpressionManager::SetSurveyId方法的典型用法代码示例。如果您正苦于以下问题:PHP LimeExpressionManager::SetSurveyId方法的具体用法?PHP LimeExpressionManager::SetSurveyId怎么用?PHP LimeExpressionManager::SetSurveyId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LimeExpressionManager
的用法示例。
在下文中一共展示了LimeExpressionManager::SetSurveyId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runWithParams
/**
* Override runWithParams() implementation in CAction to help us parse
* requests with subactions.
*
* @param array $params URL Parameters
*/
public function runWithParams($params)
{
// Default method that would be called if the subaction and run() do not exist
$sDefault = 'index';
// Check for a subaction
if (empty($params['sa'])) {
$sSubAction = $sDefault;
// default
} else {
$sSubAction = $params['sa'];
}
// Check if the class has the method
$oClass = new ReflectionClass($this);
if (!$oClass->hasMethod($sSubAction)) {
// If it doesn't, revert to default Yii method, that is run() which should reroute us somewhere else
$sSubAction = 'run';
}
// Populate the params. eg. surveyid -> iSurveyId
$params = $this->_addPseudoParams($params);
if (!empty($params['iSurveyId'])) {
if (!Survey::model()->findByPk($params['iSurveyId'])) {
Yii::app()->setFlashMessage(gT("Invalid survey ID"), 'error');
$this->getController()->redirect(array("admin/index"));
} elseif (!Permission::model()->hasSurveyPermission($params['iSurveyId'], 'survey', 'read')) {
Yii::app()->setFlashMessage(gT("No permission"), 'error');
$this->getController()->redirect(array("admin/index"));
} else {
LimeExpressionManager::SetSurveyId($params['iSurveyId']);
// must be called early - it clears internal cache if a new survey is being used
}
}
// Check if the method is public and of the action class, not its parents
// ReflectionClass gets us the methods of the class and parent class
// If the above method existence check passed, it might not be neceessary that it is of the action class
$oMethod = new ReflectionMethod($this, $sSubAction);
// Get the action classes from the admin controller as the urls necessarily do not equal the class names. Eg. survey -> surveyaction
$aActions = Yii::app()->getController()->getActionClasses();
if (empty($aActions[$this->getId()]) || strtolower($oMethod->getDeclaringClass()->name) != strtolower($aActions[$this->getId()]) || !$oMethod->isPublic()) {
// Either action doesn't exist in our whitelist, or the method class doesn't equal the action class or the method isn't public
// So let us get the last possible default method, ie. index
$oMethod = new ReflectionMethod($this, $sDefault);
}
// We're all good to go, let's execute it
// runWithParamsInternal would automatically get the parameters of the method and populate them as required with the params
return parent::runWithParamsInternal($this, $oMethod, $params);
}
示例2: XMLImportSurvey
//.........这里部分代码省略.........
// Import assessments --------------------------------------------------------
if (isset($xml->assessments)) {
foreach ($xml->assessments->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
if ($insertdata['gid'] > 0) {
$insertdata['gid'] = $aGIDReplacements[(int) $insertdata['gid']];
// remap the qid
}
$insertdata['sid'] = $iNewSID;
// remap the survey id
// now translate any links
$result = Assessment::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
$results['assessments']++;
}
}
// Import quota --------------------------------------------------------------
if (isset($xml->quota)) {
foreach ($xml->quota->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['sid'] = $iNewSID;
// remap the survey id
$oldid = $insertdata['id'];
unset($insertdata['id']);
// now translate any links
$result = Quota::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
$aQuotaReplacements[$oldid] = Yii::app()->db->getCommandBuilder()->getLastInsertID('{{quota}}');
$results['quota']++;
}
}
// Import quota_members ------------------------------------------------------
if (isset($xml->quota_members)) {
foreach ($xml->quota_members->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['sid'] = $iNewSID;
// remap the survey id
$insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
// remap the qid
$insertdata['quota_id'] = $aQuotaReplacements[(int) $insertdata['quota_id']];
// remap the qid
unset($insertdata['id']);
// now translate any links
$result = Quota_members::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
$results['quotamembers']++;
}
}
// Import quota_languagesettings----------------------------------------------
if (isset($xml->quota_languagesettings)) {
foreach ($xml->quota_languagesettings->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['quotals_quota_id'] = $aQuotaReplacements[(int) $insertdata['quotals_quota_id']];
// remap the qid
unset($insertdata['quotals_id']);
$result = Quota_languagesettings::model()->insertRecords($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
$results['quotals']++;
}
}
// Import survey_url_parameters ----------------------------------------------
if (isset($xml->survey_url_parameters)) {
foreach ($xml->survey_url_parameters->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['sid'] = $iNewSID;
// remap the survey id
if (isset($insertdata['targetsqid']) && $insertdata['targetsqid'] != '') {
$insertdata['targetsqid'] = $aSQIDReplacements[(int) $insertdata['targetsqid']];
// remap the qid
}
if (isset($insertdata['targetqid']) && $insertdata['targetqid'] != '') {
$insertdata['targetqid'] = $aQIDReplacements[(int) $insertdata['targetqid']];
// remap the qid
}
unset($insertdata['id']);
$result = Survey_url_parameters::model()->insertRecord($insertdata) or safeDie($clang->gT("Error") . ": Failed to insert data<br />");
$results['survey_url_parameters']++;
}
}
// Set survey rights
Survey_permissions::model()->giveAllSurveyPermissions(Yii::app()->session['loginID'], $iNewSID);
$aOldNewFieldmap = reverseTranslateFieldNames($iOldSID, $iNewSID, $aGIDReplacements, $aQIDReplacements);
$results['FieldReMap'] = $aOldNewFieldmap;
LimeExpressionManager::SetSurveyId($iNewSID);
translateInsertansTags($iNewSID, $iOldSID, $aOldNewFieldmap);
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iNewSID);
LimeExpressionManager::UpgradeConditionsToRelevance($iNewSID);
return $results;
}
示例3: view
/**
* Load complete view of survey properties and actions specified by $iSurveyID
*
* @access public
* @param mixed $iSurveyID
* @param mixed $gid
* @param mixed $qid
* @return void
*/
public function view($iSurveyID, $gid = null, $qid = null)
{
$iSurveyID = sanitize_int($iSurveyID);
if (isset($gid)) {
$gid = sanitize_int($gid);
}
if (isset($qid)) {
$qid = sanitize_int($qid);
}
// Reinit LEMlang and LEMsid: ensure LEMlang are set to default lang, surveyid are set to this survey id
// Ensure Last GetLastPrettyPrintExpression get info from this sid and default lang
LimeExpressionManager::SetEMLanguage(Survey::model()->findByPk($iSurveyID)->language);
LimeExpressionManager::SetSurveyId($iSurveyID);
LimeExpressionManager::StartProcessingPage(false, true);
$aData['surveyid'] = $iSurveyID;
$aData['gid'] = $gid;
$aData['qid'] = $qid;
$aData['display']['menu_bars']['surveysummary'] = true;
$this->_renderWrappedTemplate('survey', array(), $aData);
}
示例4: TSVImportSurvey
//.........这里部分代码省略.........
} elseif ($sqname == 'other' && $lastother == "Y") {
if ($qtype == "!" || $qtype == "L") {
// only used to set default value for 'other' in these cases
if (isset($row['default'])) {
$insertdata = array();
$insertdata['qid'] = $qid;
$insertdata['specialtype'] = 'other';
$insertdata['language'] = isset($row['language']) ? $row['language'] : $baselang;
$insertdata['defaultvalue'] = $row['default'];
$result = DefaultValue::model()->insertRecords($insertdata);
if (!$result) {
$results['importwarnings'][] = $clang->gT("Warning") . " : " . $clang->gT("Failed to insert default value") . ". " . $clang->gT("Text file row number ") . $rownumber;
break;
}
$results['defaultvalues']++;
}
}
} else {
$insertdata = array();
$scale_id = isset($row['type/scale']) ? $row['type/scale'] : 0;
$insertdata['sid'] = $iNewSID;
$insertdata['gid'] = $gid;
$insertdata['parent_qid'] = $qid;
$insertdata['type'] = $qtype;
$insertdata['title'] = $sqname;
$insertdata['question'] = isset($row['text']) ? $row['text'] : '';
$insertdata['relevance'] = isset($row['relevance']) ? $row['relevance'] : '';
$insertdata['preg'] = isset($row['validation']) ? $row['validation'] : '';
$insertdata['help'] = isset($row['help']) ? $row['help'] : '';
$insertdata['language'] = isset($row['language']) ? $row['language'] : $baselang;
$insertdata['mandatory'] = isset($row['mandatory']) ? $row['mandatory'] : '';
$insertdata['scale_id'] = $scale_id;
// For multi nueric language, qid is needed, why not gid. name is not unique.
$fullsqname = "G{$gid}Q{$qid}_{$scale_id}_{$sqname}";
if (isset($sqinfo[$fullsqname])) {
$qseq = $sqinfo[$fullsqname]['question_order'];
$sqid = $sqinfo[$fullsqname]['sqid'];
$insertdata['question_order'] = $qseq;
$insertdata['qid'] = $sqid;
} else {
$insertdata['question_order'] = $qseq;
}
// Insert sub question and keep the sqid for multi language survey
$newsqid = Question::model()->insertRecords($insertdata);
if (!$newsqid) {
$results['error'][] = $clang->gT("Error") . " : " . $clang->gT("Could not insert subquestion") . ". " . $clang->gT("Text file row number ") . $rownumber . " (" . $qname . ")";
break;
}
if (!isset($sqinfo[$fullsqname])) {
$sqinfo[$fullsqname]['question_order'] = $qseq++;
$sqid = $newsqid;
// save this for later
$sqinfo[$fullsqname]['sqid'] = $sqid;
$results['subquestions']++;
}
// insert default value
if (isset($row['default'])) {
$insertdata = array();
$insertdata['qid'] = $qid;
$insertdata['sqid'] = $sqid;
$insertdata['scale_id'] = $scale_id;
$insertdata['language'] = isset($row['language']) ? $row['language'] : $baselang;
$insertdata['defaultvalue'] = $row['default'];
$result = DefaultValue::model()->insertRecords($insertdata);
if (!$result) {
$results['importwarnings'][] = $clang->gT("Warning") . " : " . $clang->gT("Failed to insert default value") . ". " . $clang->gT("Text file row number ") . $rownumber;
break;
}
$results['defaultvalues']++;
}
}
break;
case 'A':
$insertdata = array();
$insertdata['qid'] = $qid;
$insertdata['code'] = isset($row['name']) ? $row['name'] : 'A' . $aseq;
$insertdata['answer'] = isset($row['text']) ? $row['text'] : '';
$insertdata['scale_id'] = isset($row['type/scale']) ? $row['type/scale'] : 0;
$insertdata['language'] = isset($row['language']) ? $row['language'] : $baselang;
$insertdata['assessment_value'] = (int) (isset($row['relevance']) ? $row['relevance'] : '');
$insertdata['sortorder'] = ++$aseq;
$result = Answer::model()->insertRecords($insertdata);
// or safeDie("Error: Failed to insert answer<br />");
if (!$result) {
$results['error'][] = $clang->gT("Error") . " : " . $clang->gT("Could not insert answer") . ". " . $clang->gT("Text file row number ") . $rownumber;
}
$results['answers']++;
break;
}
}
// Delete the survey if error found
if (is_array($results['error'])) {
$result = Survey::model()->deleteSurvey($iNewSID);
} else {
LimeExpressionManager::SetSurveyId($iNewSID);
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iNewSID);
LimeExpressionManager::UpgradeConditionsToRelevance($iNewSID);
}
return $results;
}
示例5: action
function action()
{
global $surveyid;
global $thissurvey, $thisstep;
global $clienttoken, $tokensexist, $token;
// only attempt to change session lifetime if using a DB backend
// with file based sessions, it's up to the admin to configure maxlifetime
if (isset(Yii::app()->session->connectionID)) {
@ini_set('session.gc_maxlifetime', Yii::app()->getConfig('iSessionExpirationTime'));
}
$this->_loadRequiredHelpersAndLibraries();
$param = $this->_getParameters(func_get_args(), $_POST);
$surveyid = $param['sid'];
Yii::app()->setConfig('surveyID', $surveyid);
$thisstep = $param['thisstep'];
$move = getMove();
Yii::app()->setConfig('move', $move);
$clienttoken = trim($param['token']);
$standardtemplaterootdir = Yii::app()->getConfig('standardtemplaterootdir');
if (is_null($thissurvey) && !is_null($surveyid)) {
$thissurvey = getSurveyInfo($surveyid);
}
// unused vars in this method (used in methods using compacted method vars)
@($loadname = $param['loadname']);
@($loadpass = $param['loadpass']);
$sitename = Yii::app()->getConfig('sitename');
if (isset($param['newtest']) && $param['newtest'] == "Y") {
killSurveySession($surveyid);
}
$surveyExists = $surveyid && Survey::model()->findByPk($surveyid);
$isSurveyActive = $surveyExists && Survey::model()->findByPk($surveyid)->active == "Y";
// collect all data in this method to pass on later
$redata = compact(array_keys(get_defined_vars()));
$this->_loadLimesurveyLang($surveyid);
if ($this->_isClientTokenDifferentFromSessionToken($clienttoken, $surveyid)) {
$sReloadUrl = $this->getController()->createUrl("/survey/index/sid/{$surveyid}", array('token' => $clienttoken, 'lang' => App()->language, 'newtest' => 'Y'));
$asMessage = array(gT('Token mismatch'), gT('The token you provided doesn\'t match the one in your session.'), "<a class='reloadlink newsurvey' href={$sReloadUrl}>" . gT("Click here to start the survey.") . "</a>");
$this->_createNewUserSessionAndRedirect($surveyid, $redata, __LINE__, $asMessage);
}
if ($this->_isSurveyFinished($surveyid) && ($thissurvey['alloweditaftercompletion'] != 'Y' || $thissurvey['tokenanswerspersistence'] != 'Y')) {
$aReloadUrlParam = array('lang' => App()->language, 'newtest' => 'Y');
if ($clienttoken) {
$aReloadUrlParam['token'] = $clienttoken;
}
$sReloadUrl = $this->getController()->createUrl("/survey/index/sid/{$surveyid}", $aReloadUrlParam);
$asMessage = array(gT('Previous session is set to be finished.'), gT('Your browser reports that it was used previously to answer this survey. We are resetting the session so that you can start from the beginning.'), "<a class='reloadlink newsurvey' href={$sReloadUrl}>" . gT("Click here to start the survey.") . "</a>");
$this->_createNewUserSessionAndRedirect($surveyid, $redata, __LINE__, $asMessage);
}
$previewmode = false;
if (isset($param['action']) && in_array($param['action'], array('previewgroup', 'previewquestion'))) {
if (!$this->_canUserPreviewSurvey($surveyid)) {
$asMessage = array(gT('Error'), gT("We are sorry but you don't have permissions to do this."));
$this->_niceExit($redata, __LINE__, null, $asMessage);
} else {
if (intval($param['qid']) && $param['action'] == 'previewquestion') {
$previewmode = 'question';
}
if (intval($param['gid']) && $param['action'] == 'previewgroup') {
$previewmode = 'group';
}
}
}
Yii::app()->setConfig('previewmode', $previewmode);
if ($this->_surveyCantBeViewedWithCurrentPreviewAccess($surveyid, $isSurveyActive, $surveyExists)) {
$bPreviewRight = $this->_userHasPreviewAccessSession($surveyid);
if ($bPreviewRight === false) {
$asMessage = array(gT("Error"), gT("We are sorry but you don't have permissions to do this."), sprintf(gT("Please contact %s ( %s ) for further assistance."), $thissurvey['adminname'], $thissurvey['adminemail']));
$this->_niceExit($redata, __LINE__, null, $asMessage);
}
}
// TODO can this be moved to the top?
// (Used to be global, used in ExpressionManager, merged into amVars. If not filled in === '')
// can this be added in the first computation of $redata?
if (isset($_SESSION['survey_' . $surveyid]['srid'])) {
$saved_id = $_SESSION['survey_' . $surveyid]['srid'];
}
// recompute $redata since $saved_id used to be a global
$redata = compact(array_keys(get_defined_vars()));
if ($this->_didSessionTimeOut($surveyid)) {
// @TODO is this still required ?
$asMessage = array(gT("Error"), gT("We are sorry but your session has expired."), gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection."), sprintf(gT("Please contact %s ( %s ) for further assistance."), $thissurvey['adminname'], $thissurvey['adminemail']));
$this->_niceExit($redata, __LINE__, null, $asMessage);
}
// Set the language of the survey, either from POST, GET parameter of session var
// Keep the old value, because SetSurveyLanguage update $_SESSION
$sOldLang = isset($_SESSION['survey_' . $surveyid]['s_lang']) ? $_SESSION['survey_' . $surveyid]['s_lang'] : "";
// Keep the old value, because SetSurveyLanguage update $_SESSION
if (!empty($param['lang'])) {
$sDisplayLanguage = $param['lang'];
// $param take lang from returnGlobal and returnGlobal sanitize langagecode
} elseif (isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
$sDisplayLanguage = $_SESSION['survey_' . $surveyid]['s_lang'];
} elseif (Survey::model()->findByPk($surveyid)) {
$sDisplayLanguage = Survey::model()->findByPk($surveyid)->language;
} else {
$sDisplayLanguage = Yii::app()->getConfig('defaultlang');
}
//CHECK FOR REQUIRED INFORMATION (sid)
if ($surveyid && $surveyExists) {
LimeExpressionManager::SetSurveyId($surveyid);
//.........这里部分代码省略.........
示例6: aTemplateDefaultTexts
$aDefaultTexts = aTemplateDefaultTexts($bplang, 'unescaped');
$is_html_email = false;
if (isset($_POST['htmlemail']) && $_POST['htmlemail'] == "Y") {
$is_html_email = true;
$aDefaultTexts['admin_detailed_notification'] = $aDefaultTexts['admin_detailed_notification_css'] . conditional_nl2br($aDefaultTexts['admin_detailed_notification'], $is_html_email, 'unescaped');
}
$insertarray = array('surveyls_survey_id' => $surveyid, 'surveyls_language' => $_POST['language'], 'surveyls_title' => $_POST['surveyls_title'], 'surveyls_description' => $_POST['description'], 'surveyls_welcometext' => $_POST['welcome'], 'surveyls_urldescription' => $_POST['urldescrip'], 'surveyls_endtext' => $_POST['endtext'], 'surveyls_url' => $_POST['url'], 'surveyls_email_invite_subj' => $aDefaultTexts['invitation_subject'], 'surveyls_email_invite' => conditional_nl2br($aDefaultTexts['invitation'], $is_html_email, 'unescaped'), 'surveyls_email_remind_subj' => $aDefaultTexts['reminder_subject'], 'surveyls_email_remind' => conditional_nl2br($aDefaultTexts['reminder'], $is_html_email, 'unescaped'), 'surveyls_email_confirm_subj' => $aDefaultTexts['confirmation_subject'], 'surveyls_email_confirm' => conditional_nl2br($aDefaultTexts['confirmation'], $is_html_email, 'unescaped'), 'surveyls_email_register_subj' => $aDefaultTexts['registration_subject'], 'surveyls_email_register' => conditional_nl2br($aDefaultTexts['registration'], $is_html_email, 'unescaped'), 'email_admin_notification_subj' => $aDefaultTexts['admin_notification_subject'], 'email_admin_notification' => conditional_nl2br($aDefaultTexts['admin_notification'], $is_html_email, 'unescaped'), 'email_admin_responses_subj' => $aDefaultTexts['admin_detailed_notification_subject'], 'email_admin_responses' => $aDefaultTexts['admin_detailed_notification'], 'surveyls_dateformat' => $_POST['dateformat'], 'surveyls_numberformat' => $numberformatid);
$dbtablename = db_table_name_nq('surveys_languagesettings');
$isquery = $connect->GetInsertSQL($dbtablename, $insertarray);
$isresult = $connect->Execute($isquery) or safe_die($isquery . "<br />" . $connect->ErrorMsg());
// Checked
unset($bplang);
$_SESSION['flashmessage'] = $clang->gT("Survey was successfully added.");
// Update survey permissions
GiveAllSurveyPermissions($_SESSION['loginID'], $surveyid);
LimeExpressionManager::SetSurveyId($surveyid);
$surveyselect = getsurveylist();
// Create initial Survey table
//include("surveytable_functions.php");
//$creationResult = surveyCreateTable($surveyid);
// Survey table could not be created
//if ($creationResult !== true)
//{
// safe_die ("Initial survey table could not be created, please report this as a bug."."<br />".$creationResult);
//}
}
} elseif ($action == "savepersonalsettings") {
$_POST = array_map('db_quote', $_POST);
$uquery = "UPDATE {$dbprefix}users SET lang='{$_POST['lang']}', dateformat='{$_POST['dateformat']}', htmleditormode= '{$_POST['htmleditormode']}', questionselectormode= '{$_POST['questionselectormode']}', templateeditormode= '{$_POST['templateeditormode']}'\n WHERE uid={$_SESSION['loginID']}";
$uresult = $connect->Execute($uquery) or safe_die($uquery . "<br />" . $connect->ErrorMsg());
// Checked
示例7: action
function action()
{
global $surveyid;
global $thissurvey, $thisstep;
global $clienttoken, $tokensexist, $token;
global $clang;
$clang = Yii::app()->lang;
@ini_set('session.gc_maxlifetime', Yii::app()->getConfig('iSessionExpirationTime'));
$this->_loadRequiredHelpersAndLibraries();
$param = $this->_getParameters(func_get_args(), $_POST);
$surveyid = $param['sid'];
Yii::app()->setConfig('surveyID', $surveyid);
$thisstep = $param['thisstep'];
$move = $param['move'];
$clienttoken = $param['token'];
$standardtemplaterootdir = Yii::app()->getConfig('standardtemplaterootdir');
// unused vars in this method (used in methods using compacted method vars)
@($loadname = $param['loadname']);
@($loadpass = $param['loadpass']);
$sitename = Yii::app()->getConfig('sitename');
if (isset($param['newtest']) && $param['newtest'] == "Y") {
killSurveySession($surveyid);
}
list($surveyExists, $isSurveyActive) = $this->_surveyExistsAndIsActive($surveyid);
// collect all data in this method to pass on later
$redata = compact(array_keys(get_defined_vars()));
$clang = $this->_loadLimesurveyLang($surveyid);
if ($this->_isClientTokenDifferentFromSessionToken($clienttoken, $surveyid)) {
$asMessage = array($clang->gT('Token mismatch'), $clang->gT('The token you provided doesn\'t match the one in your session.'), $clang->gT('Please wait to begin with a new session.'));
$this->_createNewUserSessionAndRedirect($surveyid, $redata, __LINE__, $asMessage);
}
if ($this->_isSurveyFinished($surveyid)) {
$asMessage = array($clang->gT('Previous session is set to be finished.'), $clang->gT('Your browser reports that it was used previously to answer this survey. We are resetting the session so that you can start from the beginning.'), $clang->gT('Please wait to begin with a new session.'));
$this->_createNewUserSessionAndRedirect($surveyid, $redata, __LINE__, $asMessage);
}
if ($this->_isPreviewAction($param) && !$this->_canUserPreviewSurvey($surveyid)) {
$asMessage = array($clang->gT('Error'), $clang->gT('We are sorry but you don\'t have permissions to do this.'));
$this->_niceExit($redata, __LINE__, null, $asMessage);
}
if ($this->_surveyCantBeViewedWithCurrentPreviewAccess($surveyid, $isSurveyActive, $surveyExists)) {
$bPreviewRight = $this->_userHasPreviewAccessSession($surveyid);
if ($bPreviewRight === false) {
$asMessage = array($clang->gT("Error"), $clang->gT("We are sorry but you don't have permissions to do this."), sprintf($clang->gT("Please contact %s ( %s ) for further assistance."), $thissurvey['adminname'], $thissurvey['adminemail']));
$this->_niceExit($redata, __LINE__, null, $asMessage);
}
}
// TODO can this be moved to the top?
// (Used to be global, used in ExpressionManager, merged into amVars. If not filled in === '')
// can this be added in the first computation of $redata?
if (isset($_SESSION['survey_' . $surveyid]['srid'])) {
$saved_id = $_SESSION['survey_' . $surveyid]['srid'];
}
// recompute $redata since $saved_id used to be a global
$redata = compact(array_keys(get_defined_vars()));
/*if ( $this->_didSessionTimeOut() )
{
// @TODO is this still required ?
$asMessage = array(
$clang->gT("Error"),
$clang->gT("We are sorry but your session has expired."),
$clang->gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection."),
sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),$thissurvey['adminname'],$thissurvey['adminemail'])
);
$this->_niceExit($redata, __LINE__, null, $asMessage);
};*/
// Set the language of the survey, either from POST, GET parameter of session var
if (!empty($_REQUEST['lang'])) {
$sTempLanguage = sanitize_languagecode($_REQUEST['lang']);
} elseif (!empty($param['lang'])) {
$sTempLanguage = sanitize_languagecode($param['lang']);
} elseif (isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
$sTempLanguage = $_SESSION['survey_' . $surveyid]['s_lang'];
} else {
$sTempLanguage = '';
}
//CHECK FOR REQUIRED INFORMATION (sid)
if ($surveyid && $surveyExists) {
LimeExpressionManager::SetSurveyId($surveyid);
// must be called early - it clears internal cache if a new survey is being used
$clang = SetSurveyLanguage($surveyid, $sTempLanguage);
UpdateSessionGroupList($surveyid, $sTempLanguage);
// to refresh the language strings in the group list session variable
UpdateFieldArray();
// to refresh question titles and question text
} else {
if (!is_null($param['lang'])) {
$sDisplayLanguage = $param['lang'];
} else {
$sDisplayLanguage = Yii::app()->getConfig('defaultlang');
}
$clang = $this->_loadLimesurveyLang($sDisplayLanguage);
$languagechanger = makeLanguageChanger($sDisplayLanguage);
//Find out if there are any publicly available surveys
$query = "SELECT sid, surveyls_title, publicstatistics, language\n FROM {{surveys}}\n INNER JOIN {{surveys_languagesettings}}\n ON ( surveyls_survey_id = sid )\n AND (surveyls_language=language)\n WHERE\n active='Y'\n AND listpublic='Y'\n AND ((expires >= '" . date("Y-m-d H:i") . "') OR (expires is null))\n AND ((startdate <= '" . date("Y-m-d H:i") . "') OR (startdate is null))\n ORDER BY surveyls_title";
$result = dbExecuteAssoc($query, false, true) or safeDie("Could not connect to database. If you try to install LimeSurvey please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage.");
//Checked
$list = array();
foreach ($result->readAll() as $rows) {
$querylang = "SELECT surveyls_title\n FROM {{surveys_languagesettings}}\n WHERE surveyls_survey_id={$rows['sid']}\n AND surveyls_language='{$sDisplayLanguage}'";
$resultlang = Yii::app()->db->createCommand($querylang)->queryRow();
//.........这里部分代码省略.........
示例8: XMLImportSurvey
//.........这里部分代码省略.........
if (preg_match("/^@(.*)@\$/", $insertdata["value"], $cfieldnameInCondValue)) {
if (isset($aOldNewFieldmap[$cfieldnameInCondValue[1]])) {
$newvalue = '@' . $aOldNewFieldmap[$cfieldnameInCondValue[1]] . '@';
$insertdata["value"] = $newvalue;
}
}
// now translate any links
$query = $connect->GetInsertSQL($tablename, $insertdata);
$result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
$results['conditions']++;
}
}
// Import assessments --------------------------------------------------------------
if (isset($xml->assessments)) {
$tablename = $dbprefix . 'assessments';
foreach ($xml->assessments->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
if ($insertdata['gid'] > 0) {
$insertdata['gid'] = $aGIDReplacements[(int) $insertdata['gid']];
// remap the qid
}
$insertdata['sid'] = $newsid;
// remap the survey id
unset($insertdata['id']);
// now translate any links
$query = $connect->GetInsertSQL($tablename, $insertdata);
$result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
$results['assessments']++;
}
}
// Import quota --------------------------------------------------------------
if (isset($xml->quota)) {
$tablename = $dbprefix . 'quota';
foreach ($xml->quota->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['sid'] = $newsid;
// remap the survey id
$oldid = $insertdata['id'];
unset($insertdata['id']);
// now translate any links
$query = $connect->GetInsertSQL($tablename, $insertdata);
$result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
$aQuotaReplacements[$oldid] = $connect->Insert_ID(db_table_name_nq('quota'), "id");
$results['quota']++;
}
}
// Import quota_members --------------------------------------------------------------
if (isset($xml->quota_members)) {
$tablename = $dbprefix . 'quota_members';
foreach ($xml->quota_members->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['sid'] = $newsid;
// remap the survey id
$insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
// remap the qid
$insertdata['quota_id'] = $aQuotaReplacements[(int) $insertdata['quota_id']];
// remap the qid
unset($insertdata['id']);
// now translate any links
$query = $connect->GetInsertSQL($tablename, $insertdata);
$result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
$results['quotamembers']++;
}
}
// Import quota_languagesettings --------------------------------------------------------------
if (isset($xml->quota_languagesettings)) {
$tablename = $dbprefix . 'quota_languagesettings';
foreach ($xml->quota_languagesettings->rows->row as $row) {
$insertdata = array();
foreach ($row as $key => $value) {
$insertdata[(string) $key] = (string) $value;
}
$insertdata['quotals_quota_id'] = $aQuotaReplacements[(int) $insertdata['quotals_quota_id']];
// remap the qid
unset($insertdata['quotals_id']);
// now translate any links
$query = $connect->GetInsertSQL($tablename, $insertdata);
$result = $connect->Execute($query) or safe_die($clang->gT("Error") . ": Failed to insert data<br />{$query}<br />\n" . $connect->ErrorMsg());
$results['quotals']++;
}
}
// Set survey rights
GiveAllSurveyPermissions($_SESSION['loginID'], $newsid);
if ($bTranslateInsertansTags) {
TranslateInsertansTags($newsid, $oldsid, $aOldNewFieldmap);
}
LimeExpressionManager::RevertUpgradeConditionsToRelevance($newsid);
LimeExpressionManager::UpgradeConditionsToRelevance($newsid);
LimeExpressionManager::SetSurveyId($newsid);
return $results;
}
示例9: listquestions
/**
* Load list questions view for a specified survey by $iSurveyID
*
* @access public
* @param mixed $iSurveyID
* @param mixed $gid
* @param mixed $qid
* @return void
*/
public function listquestions($surveyid)
{
$iSurveyID = sanitize_int($surveyid);
// Reinit LEMlang and LEMsid: ensure LEMlang are set to default lang, surveyid are set to this survey id
// Ensure Last GetLastPrettyPrintExpression get info from this sid and default lang
LimeExpressionManager::SetEMLanguage(Survey::model()->findByPk($iSurveyID)->language);
LimeExpressionManager::SetSurveyId($iSurveyID);
LimeExpressionManager::StartProcessingPage(false, true);
$survey = Survey::model()->findByPk($iSurveyID);
$aData['surveyid'] = $iSurveyID;
$aData['display']['menu_bars']['listquestions'] = true;
$aData['sidemenu']['listquestions'] = true;
$aData['surveybar']['returnbutton']['url'] = $this->getController()->createUrl("admin/survey/sa/listsurveys");
$aData['surveybar']['returnbutton']['text'] = gT('Return to survey list');
$aData['surveybar']['buttons']['newquestion'] = true;
$surveyinfo = $survey->surveyinfo;
$aData["surveyinfo"] = $surveyinfo;
$aData["surveyHasGroup"] = $survey->groups;
$aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $iSurveyID . ")";
$this->_renderWrappedTemplate('survey', array(), $aData);
}
示例10: index
/**
* Show printable survey
*/
function index($surveyid, $lang = null)
{
$surveyid = sanitize_int($surveyid);
if (!Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
$aData['surveyid'] = $surveyid;
App()->getClientScript()->registerPackage('jquery-superfish');
$message['title'] = gT('Access denied!');
$message['message'] = gT('You do not have sufficient rights to access this page.');
$message['class'] = "error";
$this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
} else {
$oSurvey = Survey::model()->findByPk($surveyid);
if (!$oSurvey) {
$this->getController()->error('Invalid survey ID');
}
//Language
if (!in_array($lang, $oSurvey->getAllLanguages())) {
$lang = $oSurvey->language;
}
// Start EM fore expression
LimeExpressionManager::SetSurveyId($surveyid);
SetSurveyLanguage($surveyid, $lang);
$aSurveyInfo = getSurveyInfo($surveyid, $lang);
$templatename = validateTemplateDir($aSurveyInfo['templatedir']);
$welcome = $aSurveyInfo['surveyls_welcometext'];
$end = $aSurveyInfo['surveyls_endtext'];
$surveyname = $aSurveyInfo['surveyls_title'];
$surveydesc = $aSurveyInfo['surveyls_description'];
$surveyactive = $aSurveyInfo['active'];
$surveytable = "{{survey_" . $aSurveyInfo['sid'] . "}}";
$surveyexpirydate = $aSurveyInfo['expires'];
$surveyfaxto = $aSurveyInfo['faxto'];
$dateformattype = $aSurveyInfo['surveyls_dateformat'];
Yii::app()->loadHelper('surveytranslator');
if (!is_null($surveyexpirydate)) {
$dformat = getDateFormatData($dateformattype);
$dformat = $dformat['phpdate'];
$expirytimestamp = strtotime($surveyexpirydate);
$expirytimeofday_h = date('H', $expirytimestamp);
$expirytimeofday_m = date('i', $expirytimestamp);
$surveyexpirydate = date($dformat, $expirytimestamp);
if (!empty($expirytimeofday_h) || !empty($expirytimeofday_m)) {
$surveyexpirydate .= ' – ' . $expirytimeofday_h . ':' . $expirytimeofday_m;
}
sprintf(gT("Please submit by %s"), $surveyexpirydate);
} else {
$surveyexpirydate = '';
}
//Fix $templatename : control if print_survey.pstpl exist
if (is_file(getTemplatePath($templatename) . DIRECTORY_SEPARATOR . 'print_survey.pstpl')) {
$templatename = $templatename;
// Change nothing
} elseif (is_file(getTemplatePath(Yii::app()->getConfig("defaulttemplate")) . DIRECTORY_SEPARATOR . 'print_survey.pstpl')) {
$templatename = Yii::app()->getConfig("defaulttemplate");
} else {
$templatename = "default";
}
$sFullTemplatePath = getTemplatePath($templatename) . DIRECTORY_SEPARATOR;
$sFullTemplateUrl = getTemplateURL($templatename) . "/";
define('PRINT_TEMPLATE_DIR', $sFullTemplatePath, true);
define('PRINT_TEMPLATE_URL', $sFullTemplateUrl, true);
LimeExpressionManager::StartSurvey($surveyid, 'survey', NULL, false, LEM_PRETTY_PRINT_ALL_SYNTAX);
$moveResult = LimeExpressionManager::NavigateForwards();
$condition = "sid = '{$surveyid}' AND language = '{$lang}'";
$degresult = QuestionGroup::model()->getAllGroups($condition, array('group_order'));
//xiao,
if (!isset($surveyfaxto) || !$surveyfaxto and isset($surveyfaxnumber)) {
$surveyfaxto = $surveyfaxnumber;
//Use system fax number if none is set in survey.
}
$headelements = getPrintableHeader();
//if $showsgqacode is enabled at config.php show table name for reference
$showsgqacode = Yii::app()->getConfig("showsgqacode");
if (isset($showsgqacode) && $showsgqacode == true) {
$surveyname = $surveyname . "<br />[" . gT('Database') . " " . gT('table') . ": {$surveytable}]";
} else {
$surveyname = $surveyname;
}
$survey_output = array('SITENAME' => Yii::app()->getConfig("sitename"), 'SURVEYNAME' => $surveyname, 'SURVEYDESCRIPTION' => $surveydesc, 'WELCOME' => $welcome, 'END' => $end, 'THEREAREXQUESTIONS' => 0, 'SUBMIT_TEXT' => gT("Submit Your Survey."), 'SUBMIT_BY' => $surveyexpirydate, 'THANKS' => gT("Thank you for completing this survey."), 'HEADELEMENTS' => $headelements, 'TEMPLATEURL' => PRINT_TEMPLATE_URL, 'FAXTO' => $surveyfaxto, 'PRIVACY' => '', 'GROUPS' => '');
$survey_output['FAX_TO'] = '';
if (!empty($surveyfaxto) && $surveyfaxto != '000-00000000') {
$survey_output['FAX_TO'] = gT("Please fax your completed survey to:") . " {$surveyfaxto}";
}
$total_questions = 0;
$mapquestionsNumbers = array();
$answertext = '';
// otherwise can throw an error on line 1617
$fieldmap = createFieldMap($surveyid, 'full', false, false, $lang);
// =========================================================
// START doin the business:
foreach ($degresult->readAll() as $degrow) {
// ---------------------------------------------------
// START doing groups
$deqresult = Question::model()->getQuestions($surveyid, $degrow['gid'], $lang, 0, '"I"');
$deqrows = array();
//Create an empty array in case FetchRow does not return any rows
foreach ($deqresult->readAll() as $deqrow) {
//.........这里部分代码省略.........