本文整理汇总了PHP中Condition::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Condition::model方法的具体用法?PHP Condition::model怎么用?PHP Condition::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Condition
的用法示例。
在下文中一共展示了Condition::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 {
$aSurveyInfo = getSurveyInfo($surveyid, $lang);
if (!$aSurveyInfo) {
$this->getController()->error('Invalid survey ID');
}
SetSurveyLanguage($surveyid, $lang);
$sLanguageCode = App()->language;
$templatename = $aSurveyInfo['template'];
$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 = '{$sLanguageCode}'";
$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, $sLanguageCode);
// =========================================================
// START doin the business:
foreach ($degresult->readAll() as $degrow) {
// ---------------------------------------------------
// START doing groups
$deqresult = Question::model()->getQuestions($surveyid, $degrow['gid'], $sLanguageCode, 0, '"I"');
$deqrows = array();
//Create an empty array in case FetchRow does not return any rows
foreach ($deqresult->readAll() as $deqrow) {
$deqrows[] = $deqrow;
}
// Get table output into array
// Perform a case insensitive natural sort on group name then question title of a multidimensional array
usort($deqrows, 'groupOrderThenQuestionOrder');
if ($degrow['description']) {
//.........这里部分代码省略.........
示例2: deleteAllById
public static function deleteAllById($questionsIds)
{
if (!is_array($questionsIds)) {
$questionsIds = array($questionsIds);
}
Yii::app()->db->createCommand()->delete(Condition::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(QuestionAttribute::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(Answer::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(Question::model()->tableName(), array('in', 'parent_qid', $questionsIds));
Yii::app()->db->createCommand()->delete(Question::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(DefaultValue::model()->tableName(), array('in', 'qid', $questionsIds));
Yii::app()->db->createCommand()->delete(QuotaMember::model()->tableName(), array('in', 'qid', $questionsIds));
}
示例3: index
/**
* Database::index()
*
* @param mixed $sa
* @return
*/
function index($sa = null)
{
$sAction = Yii::app()->request->getPost('action');
$iSurveyID = isset($_POST['sid']) ? $_POST['sid'] : returnGlobal('sid');
$iQuestionGroupID = returnGlobal('gid');
$iQuestionID = returnGlobal('qid');
// TODO: This variable seems to be never set or used in any function call?
$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 {
if (Yii::app()->request->getPost('close-after-save') === 'true') {
$this->getController()->redirect(array('admin/questions/sa/view/surveyid/' . $iSurveyID . '/gid/' . $iQuestionGroupID . '/qid/' . $iQuestionID));
}
$this->getController()->redirect(array('admin/questions/sa/editdefaultvalues/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));
//.........这里部分代码省略.........
示例4: 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) . "}}");
}
$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);
}
}
示例5: _surveybar
/**
* Shows admin menu for surveys
* @param int Survey id
*/
function _surveybar($aData)
{
if (isset($aData['surveybar'])) {
$iSurveyID = $aData['surveyid'];
$oSurvey = $aData['oSurvey'];
$gid = isset($aData['gid']) ? $aData['gid'] : null;
$surveyinfo = isset($aData['surveyinfo']) ? $aData['surveyinfo'] : $oSurvey->surveyinfo;
$baselang = $surveyinfo['language'];
$activated = $surveyinfo['active'] == 'Y';
App()->getClientScript()->registerPackage('jquery-cookie');
//Parse data to send to view
$aData['surveyinfo'] = $surveyinfo;
// ACTIVATE SURVEY BUTTON
$aData['activated'] = $activated;
$condition = array('sid' => $iSurveyID, 'parent_qid' => 0, 'language' => $baselang);
$sumcount3 = Question::model()->countByAttributes($condition);
//Checked
$aData['canactivate'] = $sumcount3 > 0 && Permission::model()->hasSurveyPermission($iSurveyID, 'surveyactivation', 'update');
$aData['candeactivate'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveyactivation', 'update');
$aData['expired'] = $surveyinfo['expires'] != '' && $surveyinfo['expires'] < dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
$aData['notstarted'] = $surveyinfo['startdate'] != '' && $surveyinfo['startdate'] > dateShift(date("Y-m-d H:i:s"), "Y-m-d H:i", Yii::app()->getConfig('timeadjust'));
// Start of suckerfish menu
// TEST BUTTON
if (!$activated) {
$aData['icontext'] = gT("Preview survey");
} else {
$aData['icontext'] = gT("Execute survey");
}
$aData['baselang'] = $oSurvey->language;
$aData['additionallanguages'] = $oSurvey->getAdditionalLanguages();
$aData['languagelist'] = $oSurvey->getAllLanguages();
$aData['onelanguage'] = count($aData['languagelist']) == 1;
$aData['hasadditionallanguages'] = count($aData['additionallanguages']) > 0;
// EDIT SURVEY TEXT ELEMENTS BUTTON
$aData['surveylocale'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveylocale', 'read');
// EDIT SURVEY SETTINGS BUTTON
$aData['surveysettings'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'read');
// Survey permission item
$aData['surveysecurity'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveysecurity', 'read');
// CHANGE QUESTION GROUP ORDER BUTTON
$aData['surveycontentread'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'read');
$aData['groupsum'] = getGroupSum($iSurveyID, $surveyinfo['language']) > 1;
// SET SURVEY QUOTAS BUTTON
$aData['quotas'] = Permission::model()->hasSurveyPermission($iSurveyID, 'quotas', 'read');
// Assessment menu item
$aData['assessments'] = Permission::model()->hasSurveyPermission($iSurveyID, 'assessments', 'read');
// EDIT SURVEY TEXT ELEMENTS BUTTON
// End if survey properties
// Tools menu item
// Delete survey item
$aData['surveydelete'] = Permission::model()->hasSurveyPermission($iSurveyID, 'survey', 'delete');
// Translate survey item
$aData['surveytranslate'] = Permission::model()->hasSurveyPermission($iSurveyID, 'translations', 'read');
// RESET SURVEY LOGIC BUTTON
//$sumquery6 = "SELECT count(*) FROM ".db_table_name('conditions')." as c, ".db_table_name('questions')."
// as q WHERE c.qid = q.qid AND q.sid=$iSurveyID"; //Getting a count of conditions for this survey
// TMSW Condition->Relevance: How is conditionscount used? Should Relevance do the same?
// Only show survey properties menu if at least one item is permitted
$aData['showSurveyPropertiesMenu'] = $aData['surveylocale'] || $aData['surveysettings'] || $aData['surveysecurity'] || $aData['surveycontentread'] || $aData['quotas'] || $aData['assessments'];
$event = new PluginEvent('beforeToolsMenuRender', $this);
$event->set('surveyId', $iSurveyID);
App()->getPluginManager()->dispatchEvent($event);
$extraToolsMenuItems = $event->get('menuItems');
$aData['extraToolsMenuItems'] = $extraToolsMenuItems;
// Only show tools menu if at least one item is permitted
$aData['showToolsMenu'] = $aData['surveydelete'] || $aData['surveytranslate'] || Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update') || !is_null($extraToolsMenuItems);
$iConditionCount = Condition::model()->with(array('questions' => array('condition' => 'sid =' . $iSurveyID)))->count();
$aData['surveycontent'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update');
$aData['conditionscount'] = $iConditionCount > 0;
// Eport menu item
$aData['surveyexport'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'export');
// PRINTABLE VERSION OF SURVEY BUTTON
// SHOW PRINTABLE AND SCANNABLE VERSION OF SURVEY BUTTON
//browse responses menu item
$aData['respstatsread'] = Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read') || Permission::model()->hasSurveyPermission($iSurveyID, 'statistics', 'read') || Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'export');
// Data entry screen menu item
$aData['responsescreate'] = Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'create');
$aData['responsesread'] = Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read');
// TOKEN MANAGEMENT BUTTON
$bTokenExists = tableExists('{{tokens_' . $iSurveyID . '}}');
if (!$bTokenExists) {
$aData['tokenmanagement'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'update') || Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'create');
} else {
$aData['tokenmanagement'] = Permission::model()->hasSurveyPermission($iSurveyID, 'surveysettings', 'update') || Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'create') || Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'read') || Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'export') || Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'import');
// and export / import ?
}
$aData['gid'] = $gid;
// = $this->input->post('gid');
if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'read')) {
$aData['permission'] = true;
} else {
$aData['gid'] = $gid = null;
$qid = null;
$aData['permission'] = false;
}
if (getGroupListLang($gid, $baselang, $iSurveyID)) {
//.........这里部分代码省略.........
示例6: 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++) {
//.........这里部分代码省略.........
示例7: set_question_sub_questions
public function set_question_sub_questions($sSessionKey, $iSurveyID, $iQuestionID, $data)
{
$data_array = unserialize($data);
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]['subquestions'];
//$clang = $this->getController()->lang;
// First delete any deleted ids
//$aDeletedQIDs = explode(' ', trim($data));
$aDeletedQIDs = explode('+', $data_array['deletedqids']);
$iQuestionGroupID = $data_array['gid'];
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
$aDeletedQIDs = array_unique($aDeletedQIDs, SORT_NUMERIC);
foreach ($aDeletedQIDs as $iDeletedQID) {
$iDeletedQID = (int) $iDeletedQID;
if ($iDeletedQID > 0) {
// don't remove undefined
$iInsertCount = Question::model()->deleteAllByAttributes(array('qid' => $iDeletedQID));
if (!$iInsertCount) {
return "Failed to delete answer";
}
}
}
//Determine ids by evaluating the hidden field
$aRows = array();
$aCodes = array();
$aOldCodes = array();
foreach ($data_array as $key => $value) {
$key = explode('_', $key);
if ($key[0] == 'answer') {
$aRows[$key[3]][$key[1]][$key[2]] = $value;
}
if ($key[0] == 'code') {
$aCodes[$key[2]][] = $value;
}
if ($key[0] == 'oldcode') {
$aOldCodes[$key[2]][] = $value;
}
}
$aInsertQID = array();
for ($iScaleID = 0; $iScaleID < $iScaleCount; $iScaleID++) {
foreach ($aSurveyLanguages as $sLanguage) {
$iPosition = 0;
$test = '';
foreach ($aRows[$iScaleID][$sLanguage] as $subquestionkey => $subquestionvalue) {
$test .= $subquestionvalue . ', ';
// create a new sub question
if (substr($subquestionkey, 0, 3) != 'new') {
$oSubQuestion = Question::model()->find("qid=:qid AND language=:language", array(":qid" => $subquestionkey, ':language' => $sLanguage));
$oSubQuestion->question_order = $iPosition + 1;
$oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
$oSubQuestion->question = $subquestionvalue;
$oSubQuestion->scale_id = $iScaleID;
// update the old sub questions
} else {
if (!isset($aInsertQID[$iScaleID][$iPosition])) {
$oSubQuestion = new Question();
$oSubQuestion->sid = $iSurveyID;
$oSubQuestion->gid = $iQuestionGroupID;
$oSubQuestion->question_order = $iPosition + 1;
$oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
$oSubQuestion->question = $subquestionvalue;
$oSubQuestion->parent_qid = $iQuestionID;
$oSubQuestion->language = $sLanguage;
$oSubQuestion->scale_id = $iScaleID;
// update old sub questions
} else {
$oSubQuestion = Question::model()->find("qid=:qid AND language=:language", array(":qid" => $aInsertQID[$iScaleID][$iPosition], ':language' => $sLanguage));
if (!$oSubQuestion) {
$oSubQuestion = new Question();
}
$oSubQuestion->sid = $iSurveyID;
$oSubQuestion->gid = $iQuestionGroupID;
$oSubQuestion->question_order = $iPosition + 1;
$oSubQuestion->title = $aCodes[$iScaleID][$iPosition];
$oSubQuestion->question = $subquestionvalue;
$oSubQuestion->parent_qid = $iQuestionID;
$oSubQuestion->language = $sLanguage;
$oSubQuestion->scale_id = $iScaleID;
}
}
$bSubQuestionResult = $oSubQuestion->save();
if ($bSubQuestionResult) {
if (substr($subquestionkey, 0, 3) != 'new' && isset($aOldCodes[$iScaleID][$iPosition]) && $aCodes[$iScaleID][$iPosition] !== $aOldCodes[$iScaleID][$iPosition]) {
Condition::model()->updateAll(array('cfieldname' => '+' . $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID . $aCodes[$iScaleID][$iPosition], 'value' => $aCodes[$iScaleID][$iPosition]), 'cqid=:cqid AND cfieldname=:cfieldname AND value=:value', array(':cqid' => $iQuestionID, ':cfieldname' => $iSurveyID . 'X' . $iQuestionGroupID . 'X' . $iQuestionID, ':value' => $aOldCodes[$iScaleID][$iPosition]));
}
if (!isset($aInsertQID[$iScaleID][$iPosition])) {
$aInsertQID[$iScaleID][$iPosition] = $oSubQuestion->qid;
}
} else {
$aErrors = $oSubQuestion->getErrors();
if (count($aErrors)) {
foreach ($aErrors as $sAttribute => $aStringErrors) {
foreach ($aStringErrors as $sStringErrors) {
//.........这里部分代码省略.........
示例8: delete_question
/**
* RPC Routine to delete a question of a survey .
* Returns the id of the deleted question.
*
* @access public
* @param string $sSessionKey Auth credentials
* @param int iQuestionID Id of the question to delete
* @return array|int Id of the deleted Question or status
*/
public function delete_question($sSessionKey, $iQuestionID)
{
if ($this->_checkSessionKey($sSessionKey)) {
$oQuestion = Question::model()->findByAttributes(array('qid' => $iQuestionID));
if (!isset($oQuestion)) {
return array('status' => 'Error: Invalid question ID');
}
$iSurveyID = $oQuestion['sid'];
if (Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'delete')) {
$oSurvey = Survey::model()->findByPk($iSurveyID);
if ($oSurvey['active'] == 'Y') {
return array('status' => 'Survey is active and not editable');
}
$iGroupID = $oQuestion['gid'];
$oCondition = Condition::model()->findAllByAttributes(array('cqid' => $iQuestionID));
if (count($oCondition) > 0) {
return array('status' => 'Cannot delete Question. Others rely on this question');
}
LimeExpressionManager::RevertUpgradeConditionsToRelevance(NULL, $iQuestionID);
try {
Condition::model()->deleteAllByAttributes(array('qid' => $iQuestionID));
QuestionAttribute::model()->deleteAllByAttributes(array('qid' => $iQuestionID));
Answer::model()->deleteAllByAttributes(array('qid' => $iQuestionID));
$sCriteria = new CDbCriteria();
$sCriteria->addCondition('qid = :qid or parent_qid = :qid');
$sCriteria->params[':qid'] = $iQuestionID;
Question::model()->deleteAll($sCriteria);
DefaultValue::model()->deleteAllByAttributes(array('qid' => $iQuestionID));
QuotaMember::model()->deleteAllByAttributes(array('qid' => $iQuestionID));
Question::updateSortOrder($iGroupID, $iSurveyID);
return (int) $iQuestionID;
} catch (Exception $e) {
return array('status' => 'Error');
}
} else {
return array('status' => 'No permission');
}
} else {
return array('status' => 'Invalid session key');
}
}
示例9: _deleteConditions
private function _deleteConditions(array $conditions, array $aData, Limesurvey_lang $clang)
{
$cids = array();
foreach ($conditions as $condition) {
$cids[] = $condition['cid'];
}
Condition::model()->deleteByPk($cids);
if (Condition::model()->hasErrors()) {
safeDie(Condition::model()->getError());
}
$aData['messages'][] = sprintf($clang->gT('Deleting conditions: %u conditions deleted'), count($condition));
return $aData;
}
示例10: 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);
}
}
示例11: delete
/**
* Function responsible for deleting a question.
*
* @access public
* @param string $action
* @param int $surveyid
* @param int $gid
* @param int $qid
* @return void
*/
public function delete($surveyid, $gid, $qid, $ajax = false)
{
$surveyid = sanitize_int($surveyid);
$gid = sanitize_int($gid);
$qid = sanitize_int($qid);
$rqid = $qid;
if (Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'delete')) {
if (!isset($qid)) {
$qid = returnGlobal('qid');
}
LimeExpressionManager::RevertUpgradeConditionsToRelevance(NULL, $qid);
// Check if any other questions have conditions which rely on this question. Don't delete if there are.
// TMSW Condition->Relevance: Allow such deletes - can warn about missing relevance separately.
$ccresult = Condition::model()->findAllByAttributes(array('cqid' => $qid));
$cccount = count($ccresult);
// There are conditions dependent on this question
if ($cccount) {
foreach ($ccresult as $ccr) {
$qidarray[] = $ccr->qid;
}
if (isset($qidarray)) {
$qidlist = implode(", ", $qidarray);
}
$sMessage = gT("Question could not be deleted. There are conditions for other questions that rely on this question. You cannot delete this question until those conditions are removed.");
if (!$ajax) {
Yii::app()->setFlashMessage($sMessage, 'error');
$this->getController()->redirect(array('admin/survey/sa/listquestions/surveyid/' . $surveyid));
} else {
return array('status' => false, 'message' => $sMessage);
}
} else {
$row = Question::model()->findByAttributes(array('qid' => $qid))->attributes;
$gid = $row['gid'];
// See if there are any conditions/attributes/answers/defaultvalues for this question,
// and delete them now as well
Condition::model()->deleteAllByAttributes(array('qid' => $qid));
QuestionAttribute::model()->deleteAllByAttributes(array('qid' => $qid));
Answer::model()->deleteAllByAttributes(array('qid' => $qid));
$criteria = new CDbCriteria();
$criteria->addCondition('qid = :qid1 or parent_qid = :qid2');
$criteria->params[':qid1'] = $qid;
$criteria->params[':qid2'] = $qid;
Question::model()->deleteAll($criteria);
DefaultValue::model()->deleteAllByAttributes(array('qid' => $qid));
QuotaMember::model()->deleteAllByAttributes(array('qid' => $qid));
Question::model()->updateQuestionOrder($gid, $surveyid);
$qid = "";
$postqid = "";
$_GET['qid'] = "";
}
$sMessage = gT("Question was successfully deleted.");
// remove question from lastVisited
$oCriteria = new CDbCriteria();
$oCriteria->compare('stg_name', 'last_question_%', true, 'AND', false);
$oCriteria->compare('stg_value', $rqid, false, 'AND');
SettingGlobal::model()->deleteAll($oCriteria);
if (!$ajax) {
Yii::app()->session['flashmessage'] = $sMessage;
$this->getController()->redirect(array('admin/survey/sa/listquestions/surveyid/' . $surveyid));
} else {
return array('status' => true, 'message' => $sMessage);
}
} else {
$sMessage = gT("You are not authorized to delete questions.");
if (!$ajax) {
Yii::app()->session['flashmessage'] = $sMessage;
$this->getController()->redirect(array('admin/survey/sa/listquestions/surveyid/' . $surveyid));
} else {
return array('status' => false, 'message' => $sMessage);
}
}
}
示例12: fixMovedQuestionConditions
function fixMovedQuestionConditions($qid, $oldgid, $newgid)
{
//Function rewrites the cfieldname for a question after group change
$surveyid = Yii::app()->getConfig('sid');
$qid = sanitize_int($qid);
$oldgid = sanitize_int($oldgid);
$newgid = sanitize_int($newgid);
Condition::model()->updateCFieldName($surveyid, $qid, $oldgid, $newgid);
// TMSW Condition->Relevance: Call LEM->ConvertConditionsToRelevance() when done
}
示例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'];
}
$criteria = new CDbCriteria();
$criteria->addNotInCondition('uid', $uids, 'OR');
$surveys = Survey::model()->findAll();
$sids = array();
foreach ($surveys as $survey) {
$sids[] = $survey['sid'];
}
$criteria->addNotInCondition('entity_id', $sids, 'OR');
$criteria->addCondition("entity='survey'");
Permission::model()->deleteAll($criteria);
// 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'));
}
}
// 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) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
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}}\\_%')) or safeDie("Couldn't get list of conditions from database<br />{$sQuery}<br />");
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 */
/**********************************************************************/
// TMSW Condition->Relevance: Replace this with analysis of relevance
$conditions = Condition::model()->findAll();
if (Condition::model()->hasErrors()) {
safeDie(Condition::model()->getError());
}
$okQuestion = array();
foreach ($conditions 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']);
//.........这里部分代码省略.........
示例14: index
//.........这里部分代码省略.........
}
}
if (isset($_POST['newscenarionum'])) {
$p_newscenarionum = sanitize_int($_POST['newscenarionum']);
}
//END Sanitizing POSTed data
//include_once("login_check.php");
include_once "database.php";
// Caution (lemeur): database.php uses autoUnescape on all entries in $_POST
// Take care to not use autoUnescape on $_POST variables after this
$br = CHtml::openTag('br /');
//MAKE SURE THAT THERE IS A SID
if (!isset($iSurveyID) || !$iSurveyID) {
$conditionsoutput = $clang->gT("You have not selected a survey") . str_repeat($br, 2);
$conditionsoutput .= CHtml::submitButton($clang->gT("Main admin screen"), array('onclick' => "window.open('" . $this->getController()->createUrl("admin/") . "', '_top')")) . $br;
safeDie($conditionsoutput);
return;
}
if (isset($p_subaction) && $p_subaction == "resetsurveylogic") {
$clang = $this->getController()->lang;
$resetsurveylogicoutput = $br;
$resetsurveylogicoutput .= CHtml::openTag('table', array('class' => 'alertbox'));
$resetsurveylogicoutput .= CHtml::openTag('tr') . CHtml::openTag('td', array('colspan' => '2'));
$resetsurveylogicoutput .= CHtml::tag('font', array('size' => '1'), CHtml::tag('strong', array(), $clang->gT("Reset Survey Logic")));
$resetsurveylogicoutput .= CHtml::closeTag('td') . CHtml::closeTag('tr');
if (!isset($_GET['ok'])) {
$button_yes = CHtml::submitButton($clang->gT("Yes"), array('onclick' => "window.open('" . $this->getController()->createUrl("admin/conditions/sa/index/subaction/resetsurveylogic/surveyid/{$iSurveyID}") . "?ok=Y" . "', '_top')"));
$button_cancel = CHtml::submitButton($clang->gT("Cancel"), array('onclick' => "window.open('" . $this->getController()->createUrl("admin/survey/sa/view/surveyid/{$iSurveyID}") . "', '_top')"));
$messagebox_content = $clang->gT("You are about to delete all conditions on this survey's questions") . "({$iSurveyID})" . $br . $clang->gT("We recommend that before you proceed, you export the entire survey from the main administration screen.") . $br . $clang->gT("Continue?") . $br . $button_yes . $button_cancel;
$this->_renderWrappedTemplate('conditions', array('message' => array('title' => $clang->gT("Warning"), 'message' => $messagebox_content)));
exit;
} else {
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
Condition::model()->deleteRecords("qid in (select qid from {{questions}} where sid={$iSurveyID})");
Yii::app()->session['flashmessage'] = $clang->gT("All conditions in this survey have been deleted.");
$this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyID));
}
}
// MAKE SURE THAT THERE IS A QID
if (!isset($qid) || !$qid) {
$conditionsoutput = $clang->gT("You have not selected a question") . str_repeat($br, 2);
$conditionsoutput .= CHtml::submitButton($clang->gT("Main admin screen"), array('onclick' => "window.open('" . $this->getController()->createUrl("admin/") . "', '_top')")) . $br;
safeDie($conditionsoutput);
return;
}
// If we made it this far, then lets develop the menu items
// add the conditions container table
$extraGetParams = "";
if (isset($qid) && isset($gid)) {
$extraGetParams = "/gid/{$gid}/qid/{$qid}";
}
$conditionsoutput_action_error = "";
// defined during the actions
$markcidarray = array();
if (isset($_GET['markcid'])) {
$markcidarray = explode("-", $_GET['markcid']);
}
//BEGIN PROCESS ACTIONS
// ADD NEW ENTRY IF THIS IS AN ADD
if (isset($p_subaction) && $p_subaction == "insertcondition") {
if (!isset($p_canswers) && !isset($_POST['ConditionConst']) && !isset($_POST['prevQuestionSGQA']) && !isset($_POST['tokenAttr']) && !isset($_POST['ConditionRegexp']) || !isset($p_cquestions) && !isset($p_csrctoken)) {
$conditionsoutput_action_error .= CHtml::script("\n<!--\n alert(\"" . $clang->gT("Your condition could not be added! It did not include the question and/or answer upon which the condition was based. Please ensure you have selected a question and an answer.", "js") . "\")\n //-->\n");
} else {
if (isset($p_cquestions) && $p_cquestions != '') {
$conditionCfieldname = $p_cquestions;
} elseif (isset($p_csrctoken) && $p_csrctoken != '') {
示例15: delete
/**
* Function responsible for deleting a question.
*
* @access public
* @param string $action
* @param int $surveyid
* @param int $gid
* @param int $qid
* @return void
*/
public function delete($surveyid, $gid, $qid)
{
$surveyid = sanitize_int($surveyid);
$gid = sanitize_int($gid);
$qid = sanitize_int($qid);
$rqid = $qid;
if (Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'delete')) {
if (!isset($qid)) {
$qid = returnGlobal('qid');
}
LimeExpressionManager::RevertUpgradeConditionsToRelevance(NULL, $qid);
// Check if any other questions have conditions which rely on this question. Don't delete if there are.
// TMSW Condition->Relevance: Allow such deletes - can warn about missing relevance separately.
$ccresult = Condition::model()->findAllByAttributes(array('cqid' => $qid));
$cccount = count($ccresult);
// There are conditions dependent on this question
if ($cccount) {
foreach ($ccresult as $ccr) {
$qidarray[] = $ccr->qid;
}
if (isset($qidarray)) {
$qidlist = implode(", ", $qidarray);
}
$message = gT("Question could not be deleted. There are conditions for other questions that rely on this question. You cannot delete this question until those conditions are removed.");
$message .= "<br /><a href='" . $this->getController()->createUrl("admin/expressions/sa/survey_logic_file/sid/{$surveyid}") . "' >" . gT("Look at survey logic files") . "</a>.";
$this->getController()->error($message, $this->getController()->createUrl("admin/survey/sa/view/surveyid/{$surveyid}/gid/{$gid}/qid/{$qid}"));
} else {
$row = Question::model()->findByAttributes(array('qid' => $qid))->attributes;
$gid = $row['gid'];
// See if there are any conditions/attributes/answers/defaultvalues for this question,
// and delete them now as well
Condition::model()->deleteAllByAttributes(array('qid' => $qid));
QuestionAttribute::model()->deleteAllByAttributes(array('qid' => $qid));
Answer::model()->deleteAllByAttributes(array('qid' => $qid));
$criteria = new CDbCriteria();
$criteria->addCondition('qid = :qid1 or parent_qid = :qid2');
$criteria->params[':qid1'] = $qid;
$criteria->params[':qid2'] = $qid;
Question::model()->deleteAll($criteria);
DefaultValue::model()->deleteAllByAttributes(array('qid' => $qid));
QuotaMember::model()->deleteAllByAttributes(array('qid' => $qid));
Question::model()->updateQuestionOrder($gid, $surveyid);
$qid = "";
$postqid = "";
$_GET['qid'] = "";
}
Yii::app()->session['flashmessage'] = gT("Question was successfully deleted.");
// remove question from lastVisited
SettingGlobal::model()->deleteAll("stg_value = :stg_value", array(':stg_value' => $rqid));
$this->getController()->redirect(array('admin/survey/sa/listquestions/surveyid/' . $surveyid));
} else {
Yii::app()->session['flashmessage'] = gT("You are not authorized to delete questions.");
$this->getController()->redirect(array('admin/survey/sa/listquestions/surveyid/' . $surveyid));
}
}