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


PHP LimeExpressionManager::UpgradeConditionsToRelevance方法代码示例

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


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

示例1: fixNumbering

/**
* fixes the numbering of questions
* This can happen if question 1 have subquestion code 1 and have question 11 in same survey and group (then same SGQA)
* @param int $fixnumbering
* @todo can call this function (no $_GET, but getParam) AND do it with Yii
*/
function fixNumbering($iQuestionID, $iSurveyID)
{
    Yii::app()->loadHelper("database");
    LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
    //Fix a question id - requires renumbering a question
    $iQuestionID = (int) $iQuestionID;
    $iMaxQID = Question::model()->getMaxId('qid', true);
    // Always refresh as we insert new qid's
    $iNewQID = $iMaxQID + 1;
    // Not sure we can do this in MSSQL ?
    $sQuery = "UPDATE {{questions}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    // Update subquestions
    $sQuery = "UPDATE {{questions}} SET parent_qid={$iNewQID} WHERE parent_qid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    //Update conditions.. firstly conditions FOR this question
    $sQuery = "UPDATE {{conditions}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    //Update default values
    $sQuery = "UPDATE {{defaultvalues}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    $sQuery = "UPDATE {{defaultvalues}} SET sqid={$iNewQID} WHERE sqid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    //Update quotas
    $sQuery = "UPDATE {{quota_members}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    //Update url params
    $sQuery = "UPDATE {{survey_url_parameters}} SET targetqid={$iNewQID} WHERE targetqid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    $sQuery = "UPDATE {{survey_url_parameters}} SET targetsqid={$iNewQID} WHERE targetsqid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    //Now conditions based upon this question
    $sQuery = "SELECT cqid, cfieldname FROM {{conditions}} WHERE cqid={$iQuestionID}";
    $sResult = Yii::app()->db->createCommand($sQuery)->query();
    foreach ($sResult->readAll() as $row) {
        $aSwitcher[] = array("cqid" => $row['cqid'], "cfieldname" => $row['cfieldname']);
    }
    if (isset($aSwitcher)) {
        foreach ($aSwitcher as $aSwitch) {
            $sQuery = "UPDATE {{conditions}}\n            SET cqid={$iNewQID},\n            cfieldname='" . str_replace("X" . $iQuestionID, "X" . $iNewQID, $aSwitch['cfieldname']) . "'\n            WHERE cqid={$iQuestionID}";
            $sResult = db_execute_assosc($sQuery);
        }
    }
    //Now question_attributes
    $sQuery = "UPDATE {{question_attributes}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    //Now answers
    $sQuery = "UPDATE {{answers}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
    Yii::app()->db->createCommand($sQuery)->query();
    LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
}
开发者ID:jordan095,项目名称:pemiluweb-iadel,代码行数:57,代码来源:activate_helper.php

示例2: fixNumbering

/**
* fixes the numbering of questions
* @param <type> $fixnumbering
*/
function fixNumbering($fixnumbering, $iSurveyID)
{
    Yii::app()->loadHelper("database");
    LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
    //Fix a question id - requires renumbering a question
    $oldqid = $fixnumbering;
    $query = "SELECT qid FROM {{questions}} ORDER BY qid DESC";
    $result = dbSelectLimitAssoc($query, 1);
    foreach ($result->readAll() as $row) {
        $lastqid = $row['qid'];
    }
    $newqid = $lastqid + 1;
    $query = "UPDATE {{questions}} SET qid={$newqid} WHERE qid={$oldqid}";
    $result = db_execute_assosc($query);
    // Update subquestions
    $query = "UPDATE {{questions}} SET parent_qid={$newqid} WHERE parent_qid={$oldqid}";
    $result = db_execute_assosc($query);
    //Update conditions.. firstly conditions FOR this question
    $query = "UPDATE {{conditions}} SET qid={$newqid} WHERE qid={$oldqid}";
    $result = db_execute_assosc($query);
    //Now conditions based upon this question
    $query = "SELECT cqid, cfieldname FROM {{conditions}} WHERE cqid={$oldqid}";
    $result = dbExecuteAssoc($query);
    foreach ($result->readAll() as $row) {
        $switcher[] = array("cqid" => $row['cqid'], "cfieldname" => $row['cfieldname']);
    }
    if (isset($switcher)) {
        foreach ($switcher as $switch) {
            $query = "UPDATE {{conditions}}\n            SET cqid={$newqid},\n            cfieldname='" . str_replace("X" . $oldqid, "X" . $newqid, $switch['cfieldname']) . "'\n            WHERE cqid={$oldqid}";
            $result = db_execute_assosc($query);
        }
    }
    // TMSW Conditions->Relevance:  (1) Call LEM->ConvertConditionsToRelevance()when done. (2) Should relevance for old conditions be removed first?
    //Now question_attributes
    $query = "UPDATE {{question_attributes}} SET qid={$newqid} WHERE qid={$oldqid}";
    $result = db_execute_assosc($query);
    //Now answers
    $query = "UPDATE {{answers}} SET qid={$newqid} WHERE qid={$oldqid}";
    $result = db_execute_assosc($query);
    LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
}
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:45,代码来源:activate_helper.php

示例3: fixNumbering

/**
* fixes the numbering of questions
* @global $dbprefix $dbprefix
* @global $connect $connect
* @global $clang $clang
* @param <type> $fixnumbering
*/
function fixNumbering($fixnumbering)
{
    global $dbprefix, $connect, $clang, $surveyid;
    LimeExpressionManager::RevertUpgradeConditionsToRelevance($surveyid);
    //Fix a question id - requires renumbering a question
    $oldqid = sanitize_int($fixnumbering);
    $query = "SELECT qid FROM {$dbprefix}questions ORDER BY qid DESC";
    $result = db_select_limit_assoc($query, 1) or safe_die($query . "<br />" . $connect->ErrorMsg());
    while ($row = $result->FetchRow()) {
        $lastqid = $row['qid'];
    }
    $newqid = $lastqid + 1;
    $query = "UPDATE {$dbprefix}questions SET qid={$newqid} WHERE qid={$oldqid}";
    $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
    // Update subquestions
    $query = "UPDATE {$dbprefix}questions SET parent_qid={$newqid} WHERE parent_qid={$oldqid}";
    $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
    //Update conditions.. firstly conditions FOR this question
    $query = "UPDATE {$dbprefix}conditions SET qid={$newqid} WHERE qid={$oldqid}";
    $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
    //Now conditions based upon this question
    $query = "SELECT cqid, cfieldname FROM {$dbprefix}conditions WHERE cqid={$oldqid}";
    $result = db_execute_assoc($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
    while ($row = $result->FetchRow()) {
        $switcher[] = array("cqid" => $row['cqid'], "cfieldname" => $row['cfieldname']);
    }
    if (isset($switcher)) {
        foreach ($switcher as $switch) {
            $query = "UPDATE {$dbprefix}conditions\n            SET cqid={$newqid},\n            cfieldname='" . str_replace("X" . $oldqid, "X" . $newqid, $switch['cfieldname']) . "'\n            WHERE cqid={$oldqid}";
            $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
        }
    }
    //Now question_attributes
    $query = "UPDATE {$dbprefix}question_attributes SET qid={$newqid} WHERE qid={$oldqid}";
    $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
    //Now answers
    $query = "UPDATE {$dbprefix}answers SET qid={$newqid} WHERE qid={$oldqid}";
    $result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
    LimeExpressionManager::UpgradeConditionsToRelevance($surveyid);
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:47,代码来源:activate_functions.php

示例4: delete

 /**
  * Action to delete a question group.
  *
  * @access public
  * @return void
  */
 public function delete($iSurveyId, $iGroupId)
 {
     $iSurveyId = sanitize_int($iSurveyId);
     if (Permission::model()->hasSurveyPermission($iSurveyId, 'surveycontent', 'delete')) {
         LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyId);
         $iGroupId = sanitize_int($iGroupId);
         $iGroupsDeleted = QuestionGroup::deleteWithDependency($iGroupId, $iSurveyId);
         if ($iGroupsDeleted > 0) {
             fixSortOrderGroups($iSurveyId);
             Yii::app()->setFlashMessage(gT('The question group was deleted.'));
         } else {
             Yii::app()->setFlashMessage(gT('Group could not be deleted'), 'error');
         }
         LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyId);
         $this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyId));
     }
 }
开发者ID:venurasasanka,项目名称:LimeSurvey,代码行数:23,代码来源:questiongroups.php

示例5: delete

 /**
  * Action to delete a question group.
  *
  * @access public
  * @return void
  */
 public function delete($iSurveyId, $iGroupId)
 {
     $iSurveyId = sanitize_int($iSurveyId);
     if (hasSurveyPermission($iSurveyId, 'surveycontent', 'delete')) {
         LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyId);
         $iGroupId = sanitize_int($iGroupId);
         $clang = $this->getController()->lang;
         $iGroupsDeleted = Groups::deleteWithDependency($iGroupId, $iSurveyId);
         if ($iGroupsDeleted !== 1) {
             fixSortOrderGroups($iSurveyId);
             Yii::app()->user->setFlash('flashmessage', $clang->gT('The question group was deleted.'));
         } else {
             Yii::app()->user->setFlash('flashmessage', $clang->gT('Group could not be deleted'));
         }
         $this->getController()->redirect($this->getController()->createUrl('admin/survey/sa/view/surveyid/' . $iSurveyId));
         LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyId);
     }
 }
开发者ID:ryu1inaba,项目名称:LimeSurvey,代码行数:24,代码来源:questiongroup.php

示例6: index


//.........这里部分代码省略.........
                         $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));
         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));
                 $iAssessmentValue = (int) Yii::app()->request->getPost('assessment_' . $iSortOrderID . '_' . $iScaleID);
                 foreach ($aSurveyLanguages as $sLanguage) {
                     $sAnswerText = Yii::app()->request->getPost('answer_' . $sLanguage . '_' . $iSortOrderID . '_' . $iScaleID);
                     // Fix bug with FCKEditor saving strange BR types
                     $sAnswerText = $oFixCKeditor->fixCKeditor($sAnswerText);
                     // Now we insert the answers
                     $iInsertCount = Answer::model()->insertRecords(array('code' => $sCode, 'answer' => $sAnswerText, 'qid' => $iQuestionID, 'sortorder' => $iSortOrderID, 'language' => $sLanguage, 'assessment_value' => $iAssessmentValue, 'scale_id' => $iScaleID));
                     if (!$iInsertCount) {
                         Yii::app()->setFlashMessage(gT("Failed to update answers"), 'error');
                     }
                 }
                 // Updating code (oldcode!==null) => update condition with the new code
                 $sOldCode = Yii::app()->request->getPost('oldcode_' . $iSortOrderID . '_' . $iScaleID);
                 if (isset($sOldCode) && $sCode !== $sOldCode) {
                     Condition::model()->updateAll(array('value' => $sCode), 'cqid=:cqid AND value=:value', array(':cqid' => $iQuestionID, ':value' => $sOldCode));
                 }
             }
             // for ($sortorderid=0;$sortorderid<$maxcount;$sortorderid++)
         }
         //  for ($scale_id=0;
         LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
         if (!Yii::app()->request->getPost('bFullPOST')) {
             Yii::app()->setFlashMessage(gT("Not all answer options were saved. This usually happens due to server limitations ( PHP setting max_input_vars) - please contact your system administrator."));
         } else {
             Yii::app()->session['flashmessage'] = gT("Answer options were successfully saved.");
         }
         LimeExpressionManager::SetDirtyFlag();
         if ($sDBOutput != '') {
开发者ID:joaocc,项目名称:LimeSurvey--LimeSurvey,代码行数:67,代码来源:database.php

示例7: 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
//.........这里部分代码省略.........
开发者ID:jdbaltazar,项目名称:survey-office,代码行数:101,代码来源:database.php

示例8: 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;
}
开发者ID:rawaludin,项目名称:LimeSurvey,代码行数:101,代码来源:import_helper.php

示例9: count

<?php

$data = LimeExpressionManager::UpgradeConditionsToRelevance();
if (is_null($data)) {
    echo "No conditions found in database";
} else {
    echo "Found and converted conditions for " . count($data) . " question(s)<br/>";
    echo "<pre>";
    print_r($data);
    echo "</pre>";
}
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:11,代码来源:upgrade_conditions2relevance.php

示例10: XMLImportGroup


//.........这里部分代码省略.........
            $results['answers']++;
        }
    }
    // Import questionattributes --------------------------------------------------------------
    if (isset($xml->question_attributes)) {
        $tablename = $dbprefix . 'question_attributes';
        foreach ($xml->question_attributes->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            unset($insertdata['qaid']);
            if (!isset($aQIDReplacements[(int) $insertdata['qid']])) {
                continue;
            }
            // Skip questions with invalid group id
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the parent_qid
            // 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['question_attributes']++;
        }
    }
    // Import defaultvalues --------------------------------------------------------------
    if (isset($xml->defaultvalues)) {
        $tablename = $dbprefix . 'defaultvalues';
        $results['defaultvalues'] = 0;
        foreach ($xml->defaultvalues->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            $insertdata['qid'] = $aQIDReplacements[(int) $insertdata['qid']];
            // remap the qid
            if (!isset($aQIDReplacements[(int) $insertdata['sqid']]) || is_null($aQIDReplacements[(int) $insertdata['sqid']])) {
                $insertdata['sqid'] = 0;
                // defaults for non-array types
            } else {
                $insertdata['sqid'] = $aQIDReplacements[(int) $insertdata['sqid']];
                // remap the subqeustion 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['defaultvalues']++;
        }
    }
    // Import conditions --------------------------------------------------------------
    if (isset($xml->conditions)) {
        $tablename = $dbprefix . 'conditions';
        foreach ($xml->conditions->rows->row as $row) {
            $insertdata = array();
            foreach ($row as $key => $value) {
                $insertdata[(string) $key] = (string) $value;
            }
            // replace the qid for the new one (if there is no new qid in the $aQIDReplacements array it mean that this condition is orphan -> error, skip this record)
            if (isset($aQIDReplacements[$insertdata['qid']])) {
                $insertdata['qid'] = $aQIDReplacements[$insertdata['qid']];
                // remap the qid
            } else {
                continue;
            }
            // a problem with this answer record -> don't consider
            if (isset($aQIDReplacements[$insertdata['cqid']])) {
                $insertdata['cqid'] = $aQIDReplacements[$insertdata['cqid']];
                // remap the qid
            } else {
                continue;
            }
            // a problem with this answer record -> don't consider
            list($oldcsid, $oldcgid, $oldqidanscode) = explode("X", $insertdata["cfieldname"], 3);
            if ($oldcgid != $oldgid) {
                // this means that the condition is in another group (so it should not have to be been exported -> skip it
                continue;
            }
            unset($insertdata["cid"]);
            // recreate the cfieldname with the new IDs
            if (preg_match("/^\\+/", $oldcsid)) {
                $newcfieldname = '+' . $newsid . "X" . $newgid . "X" . $insertdata["cqid"] . substr($oldqidanscode, strlen($oldqid));
            } else {
                $newcfieldname = $newsid . "X" . $newgid . "X" . $insertdata["cqid"] . substr($oldqidanscode, strlen($oldqid));
            }
            $insertdata["cfieldname"] = $newcfieldname;
            if (trim($insertdata["method"]) == '') {
                $insertdata["method"] = '==';
            }
            // 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']++;
        }
    }
    LimeExpressionManager::RevertUpgradeConditionsToRelevance($newsid);
    LimeExpressionManager::UpgradeConditionsToRelevance($newsid);
    $results['newgid'] = $newgid;
    $results['labelsets'] = 0;
    $results['labels'] = 0;
    return $results;
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:101,代码来源:importgroup.php

示例11: 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;
}
开发者ID:ddrmoscow,项目名称:queXS,代码行数:101,代码来源:import_functions.php

示例12: db_upgrade_all


//.........这里部分代码省略.........
                } catch (Exception $e) {
                    rollBackToTransactionBookmark();
                }
                try {
                    setTransactionBookmark();
                    Yii::app()->db->createCommand("ALTER TABLE ONLY {{users}} ADD PRIMARY KEY (uid); ")->execute;
                } catch (Exception $e) {
                    rollBackToTransactionBookmark();
                }
            }
            // Additional corrections for MSSQL
            alterColumn('{{answers}}', 'answer', "text", false);
            alterColumn('{{assessments}}', 'name', "text", false);
            alterColumn('{{assessments}}', 'message', "text", false);
            alterColumn('{{defaultvalues}}', 'defaultvalue', "text");
            alterColumn('{{expression_errors}}', 'eqn', "text");
            alterColumn('{{expression_errors}}', 'prettyprint', "text");
            alterColumn('{{groups}}', 'description', "text");
            alterColumn('{{groups}}', 'grelevance', "text");
            alterColumn('{{labels}}', 'title', "text");
            alterColumn('{{question_attributes}}', 'value', "text");
            alterColumn('{{questions}}', 'preg', "text");
            alterColumn('{{questions}}', 'help', "text");
            alterColumn('{{questions}}', 'relevance', "text");
            alterColumn('{{questions}}', 'question', "text", false);
            alterColumn('{{quota_languagesettings}}', 'quotals_quota_id', "integer", false);
            alterColumn('{{quota_languagesettings}}', 'quotals_message', "text", false);
            alterColumn('{{saved_control}}', 'refurl', "text");
            alterColumn('{{saved_control}}', 'access_code', "text", false);
            alterColumn('{{saved_control}}', 'ip', "text", false);
            alterColumn('{{saved_control}}', 'saved_thisstep', "text", false);
            alterColumn('{{saved_control}}', 'saved_date', "datetime", false);
            alterColumn('{{surveys}}', 'attributedescriptions', "text");
            alterColumn('{{surveys}}', 'emailresponseto', "text");
            alterColumn('{{surveys}}', 'emailnotificationto', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_description', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_welcometext', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_email_invite', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_email_remind', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_email_register', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_email_confirm', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_attributecaptions', "text");
            alterColumn('{{surveys_languagesettings}}', 'email_admin_notification', "text");
            alterColumn('{{surveys_languagesettings}}', 'email_admin_responses', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_endtext', "text");
            alterColumn('{{user_groups}}', 'description', "text", false);
            alterColumn('{{conditions}}', 'value', 'string', false, '');
            alterColumn('{{participant_shares}}', 'can_edit', "{$sVarchar}(5)", false);
            alterColumn('{{users}}', 'password', "binary", false);
            dropColumn('{{users}}', 'one_time_pw');
            addColumn('{{users}}', 'one_time_pw', 'binary');
            Yii::app()->db->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'random_order' and value = '2'");
            Yii::app()->db->createCommand()->update('{{settings_global}}', array('stg_value' => 157), "stg_name='DBVersion'");
        }
        if ($oldversion < 158) {
            LimeExpressionManager::UpgradeConditionsToRelevance();
            Yii::app()->db->createCommand()->update('{{settings_global}}', array('stg_value' => 158), "stg_name='DBVersion'");
        }
        if ($oldversion < 159) {
            alterColumn('{{failed_login_attempts}}', 'ip', "{$sVarchar}(40)", false);
            Yii::app()->db->createCommand()->update('{{settings_global}}', array('stg_value' => 159), "stg_name='DBVersion'");
        }
        if ($oldversion < 160) {
            alterLanguageCode('it', 'it-informal');
            alterLanguageCode('it-formal', 'it');
            Yii::app()->db->createCommand()->update('{{settings_global}}', array('stg_value' => 160), "stg_name='DBVersion'");
        }
        if ($oldversion < 161) {
            addColumn('{{survey_links}}', 'date_invited', 'datetime NULL default NULL');
            addColumn('{{survey_links}}', 'date_completed', 'datetime NULL default NULL');
            Yii::app()->db->createCommand()->update('{{settings_global}}', array('stg_value' => 161), "stg_name='DBVersion'");
        }
        if ($oldversion < 162) {
            /* Fix participant db types */
            alterColumn('{{participant_attribute}}', 'value', "text", false);
            alterColumn('{{participant_attribute_names_lang}}', 'attribute_name', "{$sVarchar}(255)", false);
            alterColumn('{{participant_attribute_values}}', 'value', "text", false);
            Yii::app()->db->createCommand()->update('{{settings_global}}', array('stg_value' => 162), "stg_name='DBVersion'");
        }
        if ($oldversion < 163) {
            //Replace  by <script type="text/javascript" src="{TEMPLATEURL}template.js"></script> by {TEMPLATEJS}
            $replacedTemplate = replaceTemplateJS();
            Yii::app()->db->createCommand()->update('{{settings_global}}', array('stg_value' => 163), "stg_name='DBVersion'");
        }
        if ($oldversion < 164) {
            // fix survey tables for missing or incorrect token field
            upgradeSurveyTables164();
            Yii::app()->db->createCommand()->update('{{settings_global}}', array('stg_value' => 164), "stg_name='DBVersion'");
            // Not updating settings table as upgrade process takes care of that step now
        }
        $oTransaction->commit();
    } catch (Exception $e) {
        $oTransaction->rollback();
        echo '<br /><br />' . $clang->gT('An non-recoverable error happened during the update. Error details:') . "<p>" . htmlspecialchars($e->getMessage()) . '</p><br />';
        return false;
    }
    fixLanguageConsistencyAllSurveys();
    echo '<br /><br />' . sprintf($clang->gT('Database update finished (%s)'), date('Y-m-d H:i:s')) . '<br /><br />';
    return true;
}
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:101,代码来源:updatedb_helper.php

示例13: index

 /**
  * Database::index()
  *
  * @param mixed $action
  * @return
  */
 function index($sa = null)
 {
     $action = Yii::app()->request->getPost('action');
     $clang = $this->getController()->lang;
     $postsid = returnGlobal('sid');
     $postgid = returnGlobal('gid');
     $postqid = returnGlobal('qid');
     $postqaid = returnGlobal('qaid');
     $databaseoutput = '';
     $surveyid = returnGlobal('sid');
     $gid = returnGlobal('gid');
     $qid = returnGlobal('qid');
     // if $action is not passed, check post data.
     if (Yii::app()->getConfig('filterxsshtml') && Yii::app()->session['USER_RIGHT_SUPERADMIN'] != 1) {
         $filter = new CHtmlPurifier();
         $filter->options = array('URI.AllowedSchemes' => array('http' => true, 'https' => true));
         $xssfilter = true;
     } else {
         $xssfilter = false;
     }
     if ($action == "updatedefaultvalues" && hasSurveyPermission($surveyid, 'surveycontent', 'update')) {
         $questlangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
         $baselang = Survey::model()->findByPk($surveyid)->language;
         array_unshift($questlangs, $baselang);
         Questions::model()->updateAll(array('same_default' => Yii::app()->request->getPost('samedefault') ? 1 : 0), 'sid=:sid ANd qid=:qid', array(':sid' => $surveyid, ':qid' => $qid));
         $resrow = Questions::model()->findByAttributes(array('qid' => $qid));
         $questiontype = $resrow['type'];
         $qtproperties = getQuestionTypeList('', 'array');
         if ($qtproperties[$questiontype]['answerscales'] > 0 && $qtproperties[$questiontype]['subquestions'] == 0) {
             for ($scale_id = 0; $scale_id < $qtproperties[$questiontype]['answerscales']; $scale_id++) {
                 foreach ($questlangs as $language) {
                     if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $scale_id . '_' . $language))) {
                         $this->_updateDefaultValues($qid, 0, $scale_id, '', $language, Yii::app()->request->getPost('defaultanswerscale_' . $scale_id . '_' . $language), true);
                     }
                     if (!is_null(Yii::app()->request->getPost('other_' . $scale_id . '_' . $language))) {
                         $this->_updateDefaultValues($qid, 0, $scale_id, 'other', $language, Yii::app()->request->getPost('other_' . $scale_id . '_' . $language), true);
                     }
                 }
             }
         }
         if ($qtproperties[$questiontype]['subquestions'] > 0) {
             foreach ($questlangs as $language) {
                 $sqresult = Questions::model()->findAllByAttributes(array('sid' => $surveyid, 'gid' => $gid, 'parent_qid' => $qid, 'language' => $language, 'scale_id' => 0));
                 for ($scale_id = 0; $scale_id < $qtproperties[$questiontype]['subquestions']; $scale_id++) {
                     foreach ($sqresult as $aSubquestionrow) {
                         if (!is_null(Yii::app()->request->getPost('defaultanswerscale_' . $scale_id . '_' . $language . '_' . $aSubquestionrow['qid']))) {
                             $this->_updateDefaultValues($qid, $aSubquestionrow['qid'], $scale_id, '', $language, Yii::app()->request->getPost('defaultanswerscale_' . $scale_id . '_' . $language . '_' . $aSubquestionrow['qid']), true);
                         }
                     }
                 }
             }
         }
         if ($qtproperties[$questiontype]['answerscales'] == 0 && $qtproperties[$questiontype]['subquestions'] == 0) {
             foreach ($questlangs as $language) {
                 if (!is_null(Yii::app()->request->getPost('defaultanswerscale_0_' . $language . '_0'))) {
                     $this->_updateDefaultValues($postqid, 0, 0, '', $language, Yii::app()->request->getPost('defaultanswerscale_0_' . $language . '_0'), true);
                 }
             }
         }
         Yii::app()->session['flashmessage'] = $clang->gT("Default value settings were successfully saved.");
         LimeExpressionManager::SetDirtyFlag();
         if ($databaseoutput != '') {
             echo $databaseoutput;
         } else {
             $this->getController()->redirect($this->getController()->createUrl('admin/survey/sa/view/surveyid/' . $surveyid . '/gid/' . $gid . '/qid/' . $qid));
         }
     }
     if ($action == "updateansweroptions" && hasSurveyPermission($surveyid, 'surveycontent', 'update')) {
         Yii::app()->loadHelper('database');
         $anslangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
         $baselang = Survey::model()->findByPk($surveyid)->language;
         $alllanguages = $anslangs;
         array_unshift($alllanguages, $baselang);
         $resrow = Questions::model()->findByAttributes(array('qid' => $qid));
         $questiontype = $resrow['type'];
         // Checked)
         $qtypes = getQuestionTypeList('', 'array');
         $scalecount = $qtypes[$questiontype]['answerscales'];
         $count = 0;
         $invalidCode = 0;
         $duplicateCode = 0;
         //require_once("../classes/inputfilter/class.inputfilter_clean.php");
         //$myFilter = new InputFilter('','',1,1,1);
         //First delete all answers
         Answers::model()->deleteAllByAttributes(array('qid' => $qid));
         LimeExpressionManager::RevertUpgradeConditionsToRelevance($surveyid);
         for ($scale_id = 0; $scale_id < $scalecount; $scale_id++) {
             $maxcount = (int) Yii::app()->request->getPost('answercount_' . $scale_id);
             for ($sortorderid = 1; $sortorderid < $maxcount; $sortorderid++) {
                 $code = sanitize_paranoid_string(Yii::app()->request->getPost('code_' . $sortorderid . '_' . $scale_id));
                 if (Yii::app()->request->getPost('oldcode_' . $sortorderid . '_' . $scale_id)) {
                     $oldcode = sanitize_paranoid_string(Yii::app()->request->getPost('oldcode_' . $sortorderid . '_' . $scale_id));
                     if ($code !== $oldcode) {
                         Conditions::model()->updateAll(array('value' => $code), 'cqid=:cqid AND value=:value', array(':cqid' => $qid, ':value' => $oldcode));
//.........这里部分代码省略.........
开发者ID:pmaonline,项目名称:limesurvey-quickstart,代码行数:101,代码来源:database.php

示例14: db_upgrade


//.........这里部分代码省略.........
        @ob_flush();
        modify_database("", "CREATE TABLE `prefix_survey_links` (\r\n        `participant_id` varchar(50) NOT NULL,\r\n        `token_id` int(11) NOT NULL,\r\n        `survey_id` int(11) NOT NULL,\r\n        `date_created` datetime NOT NULL,\r\n        PRIMARY KEY  (`participant_id`,`token_id`,`survey_id`)\r\n        )   CHARACTER SET utf8 COLLATE utf8_unicode_ci;");
        echo $modifyoutput;
        flush();
        @ob_flush();
        // add question_attributes field to assessment table
        modify_database("", "ALTER TABLE `prefix_question_attributes` ADD `language` varchar(20)");
        echo $modifyoutput;
        flush();
        @ob_flush();
        upgrade_question_attributes148();
        fixSubquestions();
        modify_database("", "UPDATE `prefix_settings_global` SET `stg_value`='148' WHERE stg_name='DBVersion'");
        echo $modifyoutput;
        flush();
        @ob_flush();
    }
    if ($oldversion < 149) {
        modify_database("", "CREATE TABLE `prefix_survey_url_parameters` (\r\n        `id` int(9) NOT NULL AUTO_INCREMENT,\r\n        `sid` int(10) NOT NULL,\r\n        `parameter` varchar(50) NOT NULL,\r\n        `targetqid` int(10) NULL,\r\n        `targetsqid` int(10) NULL,\r\n        PRIMARY KEY (`id`)\r\n        ) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;");
        echo $modifyoutput;
        flush();
        @ob_flush();
        modify_database("", "update `prefix_settings_global` set `stg_value`='149' where stg_name='DBVersion'");
        echo $modifyoutput;
        flush();
        @ob_flush();
    }
    if ($oldversion < 150) {
        modify_database("", "ALTER TABLE `prefix_questions` ADD `relevance` TEXT;");
        echo $modifyoutput;
        flush();
        @ob_flush();
        modify_database("", "update `prefix_settings_global` set `stg_value`='150' where stg_name='DBVersion'");
        echo $modifyoutput;
        flush();
        @ob_flush();
    }
    if ($oldversion < 151) {
        modify_database("", "ALTER TABLE `prefix_groups` ADD `randomization_group` VARCHAR(20) NOT NULL DEFAULT '';");
        echo $modifyoutput;
        flush();
        @ob_flush();
        modify_database("", "update `prefix_settings_global` set `stg_value`='151' where stg_name='DBVersion'");
        echo $modifyoutput;
        flush();
        @ob_flush();
    }
    if ($oldversion < 152) {
        modify_database("", "CREATE INDEX `question_attributes_idx3` ON `prefix_question_attributes` (`attribute`);");
        echo $modifyoutput;
        flush();
        @ob_flush();
        modify_database("", "update `prefix_settings_global` set `stg_value`='152' where stg_name='DBVersion'");
        echo $modifyoutput;
        flush();
        @ob_flush();
    }
    if ($oldversion < 153) {
        modify_database("", "CREATE TABLE `prefix_expression_errors` (\r\n        `id` int(9) NOT NULL AUTO_INCREMENT,\r\n        `errortime` varchar(50) DEFAULT NULL,\r\n        `sid` int(11) DEFAULT NULL,\r\n        `gid` int(11) DEFAULT NULL,\r\n        `qid` int(11) DEFAULT NULL,\r\n        `gseq` int(11) DEFAULT NULL,\r\n        `qseq` int(11) DEFAULT NULL,\r\n        `type` varchar(50) ,\r\n        `eqn` text,\r\n        `prettyprint` text,\r\n        PRIMARY KEY (`id`)\r\n        ) ENGINE=MYISAM CHARACTER SET utf8 COLLATE utf8_unicode_ci;");
        echo $modifyoutput;
        flush();
        @ob_flush();
        modify_database("", "update `prefix_settings_global` set `stg_value`='153' where stg_name='DBVersion'");
        echo $modifyoutput;
        flush();
        @ob_flush();
    }
    if ($oldversion < 154) {
        modify_database("", "ALTER TABLE `prefix_groups` ADD `grelevance` text DEFAULT NULL;");
        echo $modifyoutput;
        flush();
        @ob_flush();
        LimeExpressionManager::UpgradeConditionsToRelevance();
        modify_database("", "update `prefix_settings_global` set `stg_value`='154' where stg_name='DBVersion'");
        echo $modifyoutput;
        flush();
        @ob_flush();
    }
    if ($oldversion < 155) {
        modify_database("", "ALTER TABLE `prefix_surveys` ADD `googleanalyticsstyle` char(1) DEFAULT NULL;");
        echo $modifyoutput;
        flush();
        @ob_flush();
        modify_database("", "ALTER TABLE `prefix_surveys` ADD `googleanalyticsapikey` varchar(25) DEFAULT NULL;");
        echo $modifyoutput;
        flush();
        @ob_flush();
        modify_database("", "ALTER TABLE `prefix_surveys` CHANGE `showXquestions` `showxquestions` char(1) collate utf8_unicode_ci NOT NULL default 'Y';");
        echo $modifyoutput;
        flush();
        @ob_flush();
        modify_database("", "UPDATE `prefix_settings_global` SET stg_value='155' WHERE stg_name='DBVersion'");
        echo $modifyoutput;
        flush();
        ob_flush();
    }
    fixLanguageConsistencyAllSurveys();
    echo '<br /><br />' . sprintf($clang->gT('Database update finished (%s)'), date('Y-m-d H:i:s')) . '<br />';
    return true;
}
开发者ID:rkaldung,项目名称:LimeSurvey,代码行数:101,代码来源:upgrade-mysql.php

示例15: db_upgrade_all


//.........这里部分代码省略.........
            alterColumn('{{questions}}', 'help', "text");
            alterColumn('{{questions}}', 'relevance', "text");
            alterColumn('{{questions}}', 'question', "text", false);
            alterColumn('{{quota_languagesettings}}', 'quotals_quota_id', "integer", false);
            alterColumn('{{quota_languagesettings}}', 'quotals_message', "text", false);
            alterColumn('{{saved_control}}', 'refurl', "text");
            alterColumn('{{saved_control}}', 'access_code', "text", false);
            alterColumn('{{saved_control}}', 'ip', "text", false);
            alterColumn('{{saved_control}}', 'saved_thisstep', "text", false);
            alterColumn('{{saved_control}}', 'saved_date', "datetime", false);
            alterColumn('{{surveys}}', 'attributedescriptions', "text");
            alterColumn('{{surveys}}', 'emailresponseto', "text");
            alterColumn('{{surveys}}', 'emailnotificationto', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_description', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_welcometext', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_email_invite', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_email_remind', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_email_register', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_email_confirm', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_attributecaptions', "text");
            alterColumn('{{surveys_languagesettings}}', 'email_admin_notification', "text");
            alterColumn('{{surveys_languagesettings}}', 'email_admin_responses', "text");
            alterColumn('{{surveys_languagesettings}}', 'surveyls_endtext', "text");
            alterColumn('{{user_groups}}', 'description', "text", false);
            alterColumn('{{conditions}}', 'value', 'string', false, '');
            alterColumn('{{participant_shares}}', 'can_edit', "string(5)", false);
            alterColumn('{{users}}', 'password', "binary", false);
            dropColumn('{{users}}', 'one_time_pw');
            addColumn('{{users}}', 'one_time_pw', 'binary');
            $oDB->createCommand()->update('{{question_attributes}}', array('value' => '1'), "attribute = 'random_order' and value = '2'");
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 157), "stg_name='DBVersion'");
        }
        if ($iOldDBVersion < 158) {
            LimeExpressionManager::UpgradeConditionsToRelevance();
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 158), "stg_name='DBVersion'");
        }
        if ($iOldDBVersion < 159) {
            alterColumn('{{failed_login_attempts}}', 'ip', "string(40)", false);
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 159), "stg_name='DBVersion'");
        }
        if ($iOldDBVersion < 160) {
            alterLanguageCode('it', 'it-informal');
            alterLanguageCode('it-formal', 'it');
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 160), "stg_name='DBVersion'");
        }
        if ($iOldDBVersion < 161) {
            addColumn('{{survey_links}}', 'date_invited', 'datetime NULL default NULL');
            addColumn('{{survey_links}}', 'date_completed', 'datetime NULL default NULL');
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 161), "stg_name='DBVersion'");
        }
        if ($iOldDBVersion < 162) {
            /* Fix participant db types */
            alterColumn('{{participant_attribute}}', 'value', "text", false);
            alterColumn('{{participant_attribute_names_lang}}', 'attribute_name', "string(255)", false);
            alterColumn('{{participant_attribute_values}}', 'value', "text", false);
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 162), "stg_name='DBVersion'");
        }
        if ($iOldDBVersion < 163) {
            //Replace  by <script type="text/javascript" src="{TEMPLATEURL}template.js"></script> by {TEMPLATEJS}
            $replacedTemplate = replaceTemplateJS();
            $oDB->createCommand()->update('{{settings_global}}', array('stg_value' => 163), "stg_name='DBVersion'");
        }
        if ($iOldDBVersion < 164) {
            upgradeTokens148();
            // this should have bee done in 148 - that's why it is named this way
            // fix survey tables for missing or incorrect token field
开发者ID:CSCI-462-01-2016,项目名称:LimeSurvey,代码行数:67,代码来源:updatedb_helper.php


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