Esempio n. 1
0
 function showCompileRes()
 {
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     $displaySysAdmin = new DisplaySysAdmin();
     $compile = loadvar("compile");
     $components = loadvar("components");
     if ($compile == "") {
         return $displaySysAdmin->showCompile($displaySysAdmin->displayWarning(Language::messageToolsCompileSelectSurvey()));
     }
     if ($components == "") {
         return $displaySysAdmin->showCompile($displaySysAdmin->displayWarning(Language::messageToolsCompileSelectComponent()));
     }
     set_time_limit(0);
     $messages = array();
     foreach ($compile as $comp) {
         $survey = new Survey($comp);
         $compiler = new Compiler($comp, getSurveyVersion($survey));
         if (inArray(SURVEY_COMPONENT_SECTION, $components)) {
             $sections = $survey->getSections();
             foreach ($sections as $section) {
                 $mess = $compiler->generateEngine($section->getSeid());
                 if (sizeof($mess) > 0) {
                     $messages[] = $mess;
                 }
                 $mess = $compiler->generateProgressBar($section->getSeid());
                 if (sizeof($mess) > 0) {
                     $messages[] = $mess;
                 }
             }
             $mess = $compiler->generateSections();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_VARIABLE, $components)) {
             $mess = $compiler->generateVariableDescriptives();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_TYPE, $components)) {
             $mess = $compiler->generateTypes();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_SETTING, $components)) {
             $mess = $compiler->generateSurveySettings();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_FILL, $components)) {
             $mess = $compiler->generateGetFills();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
             $mess = $compiler->generateSetFills();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_INLINEFIELDS, $components)) {
             $mess = $compiler->generateInlineFields();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
         if (inArray(SURVEY_COMPONENT_GROUP, $components)) {
             $mess = $compiler->generateGroups();
             if (sizeof($mess) > 0) {
                 $messages[] = $mess;
             }
         }
     }
     if (sizeof($messages) == 0) {
         $content = $displaySysAdmin->displaySuccess(Language::messageToolsCompileOk());
     } else {
         $content = $displaySysAdmin->displayError(Language::messageToolsCompileNotOk());
     }
     return $displaySysAdmin->showCompile($content);
 }
Esempio n. 2
0
             return $this->importNubis();
         case IMPORT_TYPE_MMIC:
             return $this->importMMIC();
         case IMPORT_TYPE_BLAISE:
             break;
     }
 }
 function importNubis()
 {
     $arr = $_FILES[SETTING_IMPORT_TEXT];
     if (sizeof($arr) == 0) {
         return Language::messageImportNoFile();
     }
     $name = $arr["name"];
     if (!endsWith($name, EXPORT_FILE_NUBIS)) {
         return Language::messageImportInvalidFile();
     }
     $str = file_get_contents($arr["tmp_name"]);
     if ($str == "") {
         return Language::messageImportInvalidFile();
     }
     $urid = $_SESSION['URID'];
     $user = new User($urid);
     if (loadvar(SETTING_IMPORT_AS) == IMPORT_TARGET_ADD) {
         $surveys = new Surveys();
         $this->addtosuid = $surveys->getMaximumSuid() + 1;
     } else {
         if (loadvar(SETTING_IMPORT_AS) == IMPORT_TARGET_REPLACE) {
             $this->addtosuid = 1;
             /* delete existing content */
             $tables = Common::surveyTables();
             foreach ($tables as $table) {
                 $query = "delete from " . Config::dbSurvey() . $table;
                 $this->db->executeQuery($query);
             }
             /* delete existing data */
             $tables = Common::surveyDataTables();
             foreach ($tables as $table) {
                 if ($table == "_actions") {
                     $query = "delete from " . Config::dbSurvey() . $table . " where suid != ''";
                 } else {
                     $query = "delete from " . Config::dbSurvey() . $table;
                 }
                 $this->db->executeQuery($query);
             }
             /* delete test data */
             $tables = Common::surveyTestDataTables();
             foreach ($tables as $table) {
                 if ($table == "_actions") {
                     $query = "delete from " . Config::dbSurvey() . $table . " where suid != ''";
                 } else {
                     $query = "delete from " . Config::dbSurvey() . $table;
                 }
                 $this->db->executeQuery($query);
             }
         }
     }
     // add suid and urid
     $str = str_ireplace(EXPORT_PLACEHOLDER_URID, $urid, $str);
     $str = str_ireplace(EXPORT_PLACEHOLDER_SUID, $this->addtosuid, $str);
     $queries = explode("\r\n", $str);
     $tables = Common::surveyExportTables();
     foreach ($queries as $q) {
         $q = explode(EXPORT_DELIMITER, trim($q));
         if (sizeof($q) != 3) {
             continue;
         }
         if (!inArray($q[0], $tables)) {
             continue;
         }
         //echo $q[1];
         $fields = sizeof(explode(",", $q[1]));
         $f = "";
         for ($i = 0; $i < $fields; $i++) {
             if ($f != "") {
                 $f .= ",";
             }
             $f .= "?";
         }
         $query = IMPORT_STATEMENT_INSERT . ' ' . Config::dbSurvey() . $q[0] . " (" . $q[1] . ") " . IMPORT_STATEMENT_INSERT_VALUES . " (" . $f . ")";
         $bp = new BindParam();
         $fields2 = sizeof(explode(",", $q[2]));
         if ($fields != $fields2) {
             continue;
             // mismatch column count and value count
         }
         $it = explode(",", $q[2]);
         for ($i = 0; $i < $fields2; $i++) {
             $val =& prepareImportString($it[$i]);
             $bp->add(MYSQL_BINDING_STRING, $val);
             //echo 'adding: ' . $val . '----';
         }
         //echo print_r($bp->get()) . "<br/>";
         $this->db->executeBoundQuery($query, $bp->get());
     }
     // prepare
     set_time_limit(0);
     // compile
     $survey = new Survey($this->addtosuid);
     $compiler = new Compiler($this->addtosuid, getSurveyVersion($survey));
     // sections
     $sections = $survey->getSections();
     foreach ($sections as $section) {
         $mess = $compiler->generateEngine($section->getSeid());
     }
     $mess = $compiler->generateSections();
     $mess = $compiler->generateVariableDescriptives();
     $mess = $compiler->generateTypes();
     $mess = $compiler->generateGetFills();
     $mess = $compiler->generateSetFills();
     $mess = $compiler->generateInlineFields();
     $mess = $compiler->generateGroups();
     $user = new User($_SESSION['URID']);
     $mods = explode("~", $survey->getAllowedModes());
Esempio n. 3
0
 function showTranslateGroupAssistanceRes()
 {
     $displayTranslator = new DisplayTranslator();
     $survey = new Survey($_SESSION['SUID']);
     $gid = getFromSessionParams('gid');
     $group = $survey->getGroup($gid);
     $_SESSION['GID'] = $gid;
     $group->setEmptyMessage(loadvarAllowHTML(SETTING_EMPTY_MESSAGE));
     $group->setErrorMessageExactRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_EXACT_REQUIRED));
     $group->setErrorMessageMinimumRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MINIMUM_REQUIRED));
     $group->setErrorMessageMaximumRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_MAXIMUM_REQUIRED));
     $group->setErrorMessageExclusive(loadvarAllowHTML(SETTING_ERROR_MESSAGE_EXCLUSIVE));
     $group->setErrorMessageInclusive(loadvarAllowHTML(SETTING_ERROR_MESSAGE_INCLUSIVE));
     $group->SetErrorMessageUniqueRequired(loadvarAllowHTML(SETTING_ERROR_MESSAGE_UNIQUE_REQUIRED));
     $content = $displayTranslator->displaySuccess(Language::messageGroupChanged($group->getName()));
     $group->save();
     /* compile */
     $compiler = new Compiler($_SESSION['SUID'], getSurveyVersion($survey));
     $mess = $compiler->generateGroups(array($group));
     $mess = $compiler->generateGetFillsGroups(array($group));
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     /* return result */
     return $displayTranslator->showTranslateGroup($_SESSION['GID'], $content);
 }