diff --git a/admin/assessments.php b/admin/assessments.php index 2b99d8b2ff5..0e8fe10c296 100644 --- a/admin/assessments.php +++ b/admin/assessments.php @@ -25,18 +25,12 @@ $js_admin_includes[]= $rooturl.'/scripts/jquery/jquery-ui.js'; // . "\n"; - -$actsurquery = "SELECT edit_survey_property FROM {$dbprefix}surveys_rights WHERE sid=$surveyid AND uid = ".$_SESSION['loginID']; //Getting rights for this survey -$actsurresult = $connect->Execute($actsurquery) or safe_die($connect->ErrorMsg()); -$actsurrows = $actsurresult->FetchRow(); - - $assessmentlangs = GetAdditionalLanguagesFromSurveyID($surveyid); $baselang = GetBaseLanguageFromSurveyID($surveyid); array_unshift($assessmentlangs,$baselang); // makes an array with ALL the languages supported by the survey -> $assessmentlangs -if($_SESSION['USER_RIGHT_SUPERADMIN'] == 1 || $actsurrows['edit_survey_property']){ +if(bHasRight($surveyid, 'edit_survey_property')){ if ($action == "assessmentadd") { $inserttable=$dbprefix."assessments"; diff --git a/admin/browse.php b/admin/browse.php index ac566a1fa67..41296f84615 100644 --- a/admin/browse.php +++ b/admin/browse.php @@ -28,10 +28,6 @@ if (tableExists('survey_'.$surveyid)==false) die("Your results table is missing!"); $surveyinfo=getSurveyInfo($surveyid); -$sumquery5 = "SELECT b.* FROM {$dbprefix}surveys AS a INNER JOIN {$dbprefix}surveys_rights AS b ON a.sid = b.sid WHERE a.sid=$surveyid AND b.uid = ".$_SESSION['loginID']; //Getting rights for this survey and user -$sumresult5 = db_execute_assoc($sumquery5); -$sumrows5 = $sumresult5->FetchRow(); - require_once(dirname(__FILE__).'/sessioncontrol.php'); // Set language for questions and labels to base language of this survey @@ -151,7 +147,7 @@ $fncount = 0; - $fieldmap=createFieldMap($surveyid,'full'); + $fieldmap=createFieldMap($surveyid,'full',false,false,$language); //add token to top of list if survey is not private if ($surveyinfo['private'] == "N") @@ -226,7 +222,7 @@ while ($idrow = $idresult->FetchRow()) { $id=$idrow['id']; - $rlangauge=$idrow['startlanguage']; + $rlanguage=$idrow['startlanguage']; } $next=$id+1; $last=$id-1; @@ -236,13 +232,13 @@ ."\t"; + $browsemenubar .= ""; } // Display last 50 responses diff --git a/admin/htmleditor-functions.php b/admin/htmleditor-functions.php index b425dbfdead..be746eb3d0b 100644 --- a/admin/htmleditor-functions.php +++ b/admin/htmleditor-functions.php @@ -226,7 +226,7 @@ function getPopupEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=nu function getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=null,$qID=null,$action=null) { - global $clang, $imagefiles, $homeurl, $rooturl, $sFCKEditorURL, $fckeditexpandtoolbar; + global $clang, $imagefiles, $homeurl, $rooturl, $sFCKEditorURL, $fckeditexpandtoolbar, $uploadurl; $htmlcode = ''; $imgopts = ''; @@ -274,7 +274,7 @@ function getInlineEditor($fieldtype,$fieldname,$fieldtext, $surveyID=null,$gID=n . "$oFCKeditorVarName.Config[\"LimeReplacementFieldsQID\"] = \"".$qID."\";\n" . "$oFCKeditorVarName.Config[\"LimeReplacementFieldsType\"] = \"".$fieldtype."\";\n" . "$oFCKeditorVarName.Config[\"LimeReplacementFieldsAction\"] = \"".$action."\";\n" - . "$oFCKeditorVarName.Config[\"SmileyPath\"] = \"".$rooturl."/upload/images/smiley/msn/\";\n" + . "$oFCKeditorVarName.Config[\"SmileyPath\"] = \"".$uploadurl."/images/smiley/msn/\";\n" . $htmlformatoption . $toolbaroption; diff --git a/admin/http_importsurvey.php b/admin/http_importsurvey.php index c2a1635d991..3c1ebd1002a 100644 --- a/admin/http_importsurvey.php +++ b/admin/http_importsurvey.php @@ -51,13 +51,18 @@ $importsurvey .= "

\n"; $surveyid = sanitize_int($_POST['copysurveylist']); $exclude = array(); + if (get_magic_quotes_gpc()) {$sNewSurveyName = stripslashes($_POST['copysurveyname']);} + else{ + $sNewSurveyName=$_POST['copysurveyname']; + } + require_once("../classes/inputfilter/class.inputfilter_clean.php"); $myFilter = new InputFilter('','',1,1,1); if ($filterxsshtml) { - $sNewSurveyName = $myFilter->process($_POST['copysurveyname']); + $sNewSurveyName = $myFilter->process($sNewSurveyName); } else { - $sNewSurveyName = html_entity_decode($_POST['copysurveyname'], ENT_QUOTES, "UTF-8"); + $sNewSurveyName = html_entity_decode($sNewSurveyName, ENT_QUOTES, "UTF-8"); } if (isset($_POST['copysurveyexcludequotas']) && $_POST['copysurveyexcludequotas'] == "on") { diff --git a/admin/importquestion.php b/admin/importquestion.php index cad39b61cde..60f34398ae3 100644 --- a/admin/importquestion.php +++ b/admin/importquestion.php @@ -783,6 +783,9 @@ function XMLImportQuestion($sFullFilepath, $newsid, $newgid) } // Import subquestions -------------------------------------------------------------- + if (isset($xml->subquestions)) + { + foreach ($xml->subquestions->rows->row as $row) { $insertdata=array(); @@ -838,6 +841,7 @@ function XMLImportQuestion($sFullFilepath, $newsid, $newgid) $results['answers']++; } } + } // Import questionattributes -------------------------------------------------------------- if(isset($xml->question_attributes)) diff --git a/admin/install/create-mysql.sql b/admin/install/create-mysql.sql index 2265954ed27..98d1cd9118e 100644 --- a/admin/install/create-mysql.sql +++ b/admin/install/create-mysql.sql @@ -258,8 +258,7 @@ CREATE TABLE `prefix_surveys_languagesettings` ( `surveyls_dateformat` INT UNSIGNED NOT NULL DEFAULT 1, PRIMARY KEY (`surveyls_survey_id`, `surveyls_language`) -) -TYPE = $databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; +) ENGINE = $databasetabletype CHARACTER SET utf8 COLLATE utf8_unicode_ci; diff --git a/admin/integritycheck.php b/admin/integritycheck.php index c44a86815bd..f4dc0c6dccb 100644 --- a/admin/integritycheck.php +++ b/admin/integritycheck.php @@ -34,6 +34,74 @@ $connect->query("delete FROM {$dbprefix}surveys_rights where sid not in (select sid from {$dbprefix}surveys)"); $connect->query("delete FROM {$dbprefix}surveys_rights where uid not in (select uid from {$dbprefix}users)"); + /***** Check for activate survey tables with missing survey entry **/ + + $sQuery = "show tables like '{$dbprefix}survey\_%'"; + $aResult = db_execute_num($sQuery) or safe_die("Couldn't get list of conditions from database
$query
".$connect->ErrorMsg()); + while ($aRow=$aResult->FetchRow()) + { + $tablename=substr($aRow[0],strlen($dbprefix)); + $iSurveyID=substr($tablename,strpos($tablename,'_')+1); + $qquery="SELECT sid FROM {$dbprefix}surveys WHERE sid='{$iSurveyID}'"; + $qresult=$connect->Execute($qquery) or safe_die ("Couldn't check questions table for qids
$qquery
".$connect->ErrorMsg()); + $qcount=$qresult->RecordCount(); + if ($qcount==0) + { + $date = date('YmdHis').rand(1,1000); + $sOldTable = "survey_{$iSurveyID}"; + $sNewTable = "old_survey_{$iSurveyID}_$date"; + + $deactivatequery = db_rename_table(db_table_name_nq($sOldTable),db_table_name_nq($sNewTable)); + $deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't make backup of the survey table. Please try again. The database reported the following error:
".htmlspecialchars($connect->ErrorMsg())."
"); + + if ($databasetype=='postgres') + { + // If you deactivate a postgres table you have to rename the according sequence too and alter the id field to point to the changed sequence + $deactivatequery = db_rename_table($sOldTable.'_id_seq',$sNewTable.'_id_seq'); + $deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't make backup of the survey table. Please try again. The database reported the following error:
".htmlspecialchars($connect->ErrorMsg())."

Survey was not deactivated either.

".$clang->gT("Main Admin Screen").""); + $setsequence="ALTER TABLE $sNewTable ALTER COLUMN id SET DEFAULT nextval('{$sNewTable}_id_seq'::regclass);"; + $deactivateresult = $connect->Execute($setsequence) or die ("Couldn't make backup of the survey table. Please try again. The database reported the following error:
".htmlspecialchars($connect->ErrorMsg())."

Survey was not deactivated either.

".$clang->gT("Main Admin Screen").""); + } + + } + } + + /***** Check for activate token tables with missing survey entry **/ + + $sQuery = "show tables like '{$dbprefix}tokens\_%'"; + $aResult = db_execute_num($sQuery) or safe_die("Couldn't get list of token tables from database
$query
".$connect->ErrorMsg()); + while ($aRow=$aResult->FetchRow()) + { + $tablename=substr($aRow[0],strlen($dbprefix)); + $iSurveyID=substr($tablename,strpos($tablename,'_')+1); + $qquery="SELECT sid FROM {$dbprefix}surveys WHERE sid='{$iSurveyID}'"; + $qresult=$connect->Execute($qquery) or safe_die ("Couldn't check survey table for sid
$qquery
".$connect->ErrorMsg()); + $qcount=$qresult->RecordCount(); + if ($qcount==0) + { + $date = date('YmdHis').rand(1,1000); + $sOldTable = "tokens_{$iSurveyID}"; + $sNewTable = "old_tokens_{$iSurveyID}_$date"; + $deactivatequery = db_rename_table( db_table_name_nq($sOldTable), db_table_name_nq($sNewTable)); + + if ($databasetype=='postgres') + { + // If you deactivate a postgres table you have to rename the according sequence too and alter the id field to point to the changed sequence + $sOldTableJur = db_table_name_nq($sOldTable); + $deactivatequery = db_rename_table(db_table_name_nq($sOldTable),db_table_name_nq($sNewTable).'_tid_seq'); + $deactivateresult = $connect->Execute($deactivatequery) or die ("oldtable : ".$sOldTable. " / oldtableJur : ". $sOldTableJur . " / ".htmlspecialchars($deactivatequery)." / Could not rename the old sequence for this token table. The database reported the following error:
".htmlspecialchars($connect->ErrorMsg())."

".$clang->gT("Main Admin Screen").""); + $setsequence="ALTER TABLE ".db_table_name_nq($sNewTable)."_tid_seq ALTER COLUMN tid SET DEFAULT nextval('".db_table_name_nq($sNewTable)."_tid_seq'::regclass);"; + $deactivateresult = $connect->Execute($setsequence) or die (htmlspecialchars($setsequence)." Could not alter the field tid to point to the new sequence name for this token table. The database reported the following error:
".htmlspecialchars($connect->ErrorMsg())."

Survey was not deactivated either.

".$clang->gT("Main Admin Screen").""); + $setidx="ALTER INDEX ".db_table_name_nq($sOldTable)."_idx RENAME TO ".db_table_name_nq($sNewTable)."_idx;"; + $deactivateresult = $connect->Execute($setidx) or die (htmlspecialchars($setidx)." Could not alter the index for this token table. The database reported the following error:
".htmlspecialchars($connect->ErrorMsg())."

Survey was not deactivated either.

".$clang->gT("Main Admin Screen").""); + } else { + $deactivateresult = $connect->Execute($deactivatequery) or die ("Couldn't deactivate because:
\n".htmlspecialchars($connect->ErrorMsg())." - Query: ".htmlspecialchars($deactivatequery)."

\nAdmin\n"); + } + + } + } + + /**********************************************************************/ /* CHECK CONDITIONS */ /**********************************************************************/ @@ -87,25 +155,88 @@ /**********************************************************************/ $query = "SELECT * FROM {$dbprefix}question_attributes ORDER BY qid"; $result = db_execute_assoc($query) or safe_die($connect->ErrorMsg()); + $countQuestionAttributes=0; while($row = $result->FetchRow()) { $aquery = "SELECT * FROM {$dbprefix}questions WHERE qid = {$row['qid']}"; $aresult = $connect->Execute($aquery) or safe_die($connect->ErrorMsg()); $qacount = $aresult->RecordCount(); if (!$qacount) { - $qadelete[]=array("qaid"=>$row['qaid'], "attribute"=>$row['attribute'], "reason"=>$clang->gT("No matching qid")); + $countQuestionAttributes++; } } // while if (isset($qadelete) && $qadelete) { - $integritycheck .= "
  • ".$clang->gT("The following question attributes should be deleted").":

  • \n"; - foreach ($qadelete as $qad) {$integritycheck .= "QAID `{$qad['qaid']}` ATTRIBUTE `{$qad['attribute']}` ".$clang->gT("because")." `{$qad['reason']}`
    \n";} - $integritycheck .= "

    \n"; + $integritycheck .= "
  • ".sprintf($clang->gT("There are %s orphaned question attributes."),$countQuestionAttributes)."
  • "; } else { $integritycheck .= "
  • ".$clang->gT("All question attributes meet consistency standards")."
  • \n"; } + /**********************************************************************/ + /* Check default values */ + /**********************************************************************/ + $sQuery = "SELECT * FROM {$dbprefix}defaultvalues where qid not in (select qid from {$dbprefix}questions)"; + $result = db_execute_assoc($sQuery) or safe_die($connect->ErrorMsg()); + $iCountDefaultValues=$result->RecordCount(); + + if ($iCountDefaultValues>0) { + $integritycheck .= "
  • ".sprintf($clang->gT("There are %s orphaned default value entries which can be deleted."),$iCountDefaultValues)."
  • "; + } + else + { + $integritycheck .= "
  • ".$clang->gT("All default values meet consistency standards")."
  • \n"; + } + + /**********************************************************************/ + /* Check quotas */ + /**********************************************************************/ + $sQuery = "SELECT * FROM {$dbprefix}quota where sid not in (select sid from {$dbprefix}surveys)"; + $result = db_execute_assoc($sQuery) or safe_die($connect->ErrorMsg()); + $iCountQuotas=$result->RecordCount(); + + if ($iCountQuotas>0) { + $integritycheck .= "
  • ".sprintf($clang->gT("There are %s orphaned quota entries which can be deleted."),$iCountQuotas)."
  • "; + } + else + { + $integritycheck .= "
  • ".$clang->gT("All quotas meet consistency standards")."
  • \n"; + } + + + /**********************************************************************/ + /* Check quota languagesettings */ + /**********************************************************************/ + $sQuery = "SELECT * FROM {$dbprefix}quota_languagesettings where quotals_quota_id not in (select id from {$dbprefix}quota)"; + $result = db_execute_assoc($sQuery) or safe_die($connect->ErrorMsg()); + $iCountQuotaLanguageSettings=$result->RecordCount(); + + if ($iCountQuotaLanguageSettings>0) { + $integritycheck .= "
  • ".sprintf($clang->gT("There are %s orphaned quota language settings which can be deleted."),$iCountQuotaLanguageSettings)."
  • "; + } + else + { + $integritycheck .= "
  • ".$clang->gT("All quota language settings meet consistency standards")."
  • \n"; + } + + /**********************************************************************/ + /* Check quota members */ + /**********************************************************************/ + $sQuery = "SELECT * FROM {$dbprefix}quota_members where quota_id not in (select id from {$dbprefix}quota) or qid not in (select qid from {$dbprefix}questions) or sid not in (select sid from {$dbprefix}surveys)"; + $result = db_execute_assoc($sQuery) or safe_die($connect->ErrorMsg()); + $iCountQuotaMembers=$result->RecordCount(); + + + if ($iCountQuotaMembers>0) { + $integritycheck .= "
  • ".sprintf($clang->gT("There are %s orphaned quota members which can be deleted."),$iCountQuotaMembers)."
  • "; + } + else + { + $integritycheck .= "
  • ".$clang->gT("All quota members meet consistency standards")."
  • \n"; + } + + + /**********************************************************************/ /* CHECK ASSESSMENTS */ /**********************************************************************/ @@ -284,6 +415,7 @@ //3: If it doesn't offer it for deletion $tables=$connect->MetaTables(false, false, "{$dbprefix}%old%survey%"); $oldsids=array(); + $sids=array(); foreach($tables as $table) { list($one, $two, $three, $sid, $date)=explode("_", $table); @@ -347,11 +479,12 @@ //3: If it doesn't offer it for deletion $tables=$connect->MetaTables(false, false, "{$dbprefix}%old%token%"); $oldtsids=array(); + $tsids=array(); $folloldtsids=array(); foreach($tables as $table) { - list($one, $two, $three, $sid, $date)=explode("_", $table); + list($one, $two, $sid, $date)=explode("_", substr($table,strlen($dbprefix))); $oldtsids[]=$sid; $fulloldtsids[$sid][]=$table; } @@ -415,12 +548,33 @@ if (!isset($cdelete) && !isset($adelete) && !isset($qdelete) && !isset($gdelete) && !isset($asgdelete) && !isset($sdelete) && !isset($assdelete) && !isset($qadelete) && !isset($oldsdelete) && - !isset($oldtdelete) && !isset($sldelete)) { + !isset($oldtdelete) && !isset($sldelete)&& $iCountDefaultValues==0 && + $iCountQuotas==0 && $iCountQuotaLanguageSettings==0 && $iCountQuotaMembers==0) { $integritycheck .= "
    ".$clang->gT("No database action required"); } else { $integritycheck .= "
    ".$clang->gT("Should we proceed with the delete?")."
    \n"; $integritycheck .= "
    \n"; + if ($iCountQuotaMembers>0) + { + $integritycheck .= "\n"; + } + + if ($iCountQuotaLanguageSettings>0) + { + $integritycheck .= "\n"; + } + + if ($iCountQuotas>0) + { + $integritycheck .= "\n"; + } + + if ($iCountDefaultValues>0) + { + $integritycheck .= "\n"; + } + if (isset($oldsdelete)) { foreach($oldsdelete as $olds) { $integritycheck .= "\n"; @@ -558,8 +712,40 @@ $sldelete=returnglobal('sldelete'); $oldsdelete=returnglobal('oldsdelete'); $oldtdelete=returnglobal('oldtdelete'); + $bDefaultValueDelete=returnglobal('defaultvalue_delete'); + $bQuotaDelete=returnglobal('quota_delete'); + $bQuotaLanguageSettingsDelete=returnglobal('quotalanguagesettings_delete'); + $bQuotaMembersDelete=returnglobal('quotamembers_delete'); + if (isset($bDefaultValueDelete) && $bDefaultValueDelete==1) + { + $integritycheck .= $clang->gT("Deleting orphaned default values.")."
    \n"; + $sSQL = "delete FROM {$dbprefix}defaultvalues where qid not in (select qid from {$dbprefix}questions)"; + $result = $connect->Execute($sSQL) or safe_die ("Couldn't delete default values ($sSQL)
    ".$connect->ErrorMsg()); + } + + if (isset($bQuotaMembersDelete) && $bQuotaMembersDelete==1) + { + $integritycheck .= $clang->gT("Deleting orphaned quotas.")."
    \n"; + $sSQL = "delete FROM {$dbprefix}quota_members where quota_id not in (select id from {$dbprefix}quota) or qid not in (select qid from {$dbprefix}questions) or sid not in (select sid from {$dbprefix}surveys)"; + $result = $connect->Execute($sSQL) or safe_die ("Couldn't delete quota members ($sSQL)
    ".$connect->ErrorMsg()); + } + if (isset($bQuotaDelete) && $bQuotaDelete==1) + { + $integritycheck .= $clang->gT("Deleting orphaned quotas.")."
    \n"; + $sSQL = "delete FROM {$dbprefix}quota where sid not in (select sid from {$dbprefix}surveys)"; + $result = $connect->Execute($sSQL) or safe_die ("Couldn't delete quotas ($sSQL)
    ".$connect->ErrorMsg()); + } + + + if (isset($bQuotaLanguageSettingsDelete) && $bQuotaLanguageSettingsDelete==1) + { + $integritycheck .= $clang->gT("Deleting orphaned language settings.")."
    \n"; + $sSQL = "delete FROM {$dbprefix}quota_languagesettings where quotals_quota_id not in (select id from {$dbprefix}quota)"; + $result = $connect->Execute($sSQL) or safe_die ("Couldn't delete quotas ($sSQL)
    ".$connect->ErrorMsg()); + } + if (isset($oldsdelete)) { $integritycheck .= $clang->gT("Deleting old survey result tables").":
    \n"; foreach ($oldsdelete as $olds) { diff --git a/admin/iterate_survey.php b/admin/iterate_survey.php index 74674e08abe..1d87611c5d2 100644 --- a/admin/iterate_survey.php +++ b/admin/iterate_survey.php @@ -51,7 +51,7 @@ //error_log("TIBO query = $updateqr"); $updateres = $connect->Execute($updateqr) or safe_die("Delete incomplete answers with duplicate tokens failed:
    \n" . $connect->ErrorMsg() . "
    $updateqr"); // Then set all remaining answers to incomplete state - $updateqr = "UPDATE $surveytable SET submitdate=NULL;\n"; + $updateqr = "UPDATE $surveytable SET submitdate=NULL, lastpage=NULL;\n"; $updateres = $connect->Execute($updateqr) or safe_die("UnFinilize answers failed:
    \n" . $connect->ErrorMsg() . "
    $updateqr"); // Finally, reset the token completed and sent status $updateqr="UPDATE ".db_table_name("tokens_$surveyid")." SET sent='N', remindersent='N', remindercount=0, completed='N'"; diff --git a/admin/preview.php b/admin/preview.php index 32dd2d8ffdc..e630821bbab 100644 --- a/admin/preview.php +++ b/admin/preview.php @@ -76,15 +76,14 @@ function noop_checkconditions(value, name, type) } /* ]]> */ - '; $answer=$answers[0][1]; $help=$answers[0][2]; -$questioncode=$answers[0][5]; $question = $answers[0][0]; +$question['code']=$answers[0][5]; $question['class'] = question_class($qrows['type']); $question['essentials'] = 'id="question'.$qrows['qid'].'"'; if ($qrows['mandatory'] == 'Y') @@ -97,24 +96,24 @@ function noop_checkconditions(value, name, type) }; $content = templatereplace(file_get_contents("$thistpl/startpage.pstpl")); +$content .=''; $content .= templatereplace(file_get_contents("$thistpl/startgroup.pstpl")); $question_template = file_get_contents("$thistpl/question.pstpl"); if(substr_count($question_template , '{QUESTION_ESSENTIALS}') > 0 ) // the following has been added for backwards compatiblity. {// LS 1.87 and newer templates -$content .= ''; $content .= "\n".templatereplace($question_template)."\n"; -$content .= ''; } else {// LS 1.86 and older templates -$content .= '
    -
    '; +$content .= '
    '; $content .= "\n".templatereplace($question_template)."\n"; -$content .= "\n\t
    \n"; +$content .= "\n\t
    \n"; }; $content .= templatereplace(file_get_contents("$thistpl/endgroup.pstpl")).$dummy_js; +$content .= '

     '; +$content .= templatereplace(file_get_contents("$thistpl/endpage.pstpl")); echo $content; echo "\n"; diff --git a/admin/printablesurvey.php b/admin/printablesurvey.php index 6bf30a31242..09c46b82873 100644 --- a/admin/printablesurvey.php +++ b/admin/printablesurvey.php @@ -70,35 +70,10 @@ function try_debug($line) } if(isset($_POST['printableexport'])){$pdf->titleintopdf($surveyname,$surveydesc);} -switch($dateformattype) -{ - case 1: $dformat = 'd.m.Y'; // dd.mm.yyyy - break; - case 2: $dformat = 'd-m-Y'; // dd-mm-yyyy - break; - case 5: $dformat = 'd/m/Y'; // dd/mm/yyyy - break; - case 3: $dformat = 'Y.m.d'; // yyyy.mm.dd - break; - case 7: $dformat = 'Y/m/d'; // yyyy/mm/dd - break; - case 6: $dbformat = 'Y-m-d'; // yyyy-mm-dd - break; - case 4: $dformat = 'j.n.Y'; // d.m.yyyy - break; - case 8: $dformat = 'j/n/y'; // d/m/yyyy - break; - case 12: $dbformat = 'j-n-Y'; // d-m-yyyy - break; - case 9: $dformat = 'm-d-Y'; // mm-dd-yyyy - break; - case 10: $dbformat = 'm.d.Y'; // mm.dd.yyyy - break; - case 11: $dbformat = 'm/d/Y'; // mm/dd/yyyy - break; - default: $dformat = 'Y-m-d'; // yyyy-mm-dd - break; -}; + +$dformat=getDateFormatData($dateformattype); +$dformat=$dformat['phpdate']; + $expirytimestamp = strtotime($surveyexpirydate); $expirytimeofday_h = date('H',$expirytimestamp); $expirytimeofday_m = date('i',$expirytimestamp); @@ -871,7 +846,6 @@ function star_replace($input) } if ($deqrow['other'] == 'Y') { - $qidattributes = getQuestionAttributes($deqrow['qid'],$deqrow['type']); if(trim($qidattributes["other_replace_text"])=='') {$qidattributes["other_replace_text"]="Other";} // $printablesurveyoutput .="\t".$wrapper['item-start']."\t\t".input_type_image('radio' , $clang->gT("Other"))."\n\t\t\t".$clang->gT("Other")."\n\t\t\t\n".$wrapper['item-end']; diff --git a/admin/questionhandling.php b/admin/questionhandling.php index 8f00cc860ea..bc14b773063 100644 --- a/admin/questionhandling.php +++ b/admin/questionhandling.php @@ -119,7 +119,7 @@ $baselang = GetBaseLanguageFromSurveyID($surveyid); array_unshift($questlangs,$baselang); - $questionrow=$connect->GetRow("SELECT type, other, title, question FROM ".db_table_name('questions')." WHERE sid=$surveyid AND gid=$gid AND qid=$qid AND language='$baselang'"); + $questionrow=$connect->GetRow("SELECT type, other, title, question, same_default FROM ".db_table_name('questions')." WHERE sid=$surveyid AND gid=$gid AND qid=$qid AND language='$baselang'"); $qtproperties=getqtypelist('','array'); $editdefvalues="

    ".$clang->gT('Edit default answer values')."
    " @@ -128,11 +128,10 @@ foreach ($questlangs as $language) { $editdefvalues .= '

    '.getLanguageNameFromCode($language,false).'

    '; - + $editdefvalues.="
      "; // If there are answerscales if ($qtproperties[$questionrow['type']]['answerscales']>0) { - $editdefvalues.="
        "; for ($scale_id=0;$scale_id<$qtproperties[$questionrow['type']]['answerscales'];$scale_id++) { $editdefvalues.="
      • "; } } - + } if ($language==$baselang && count($questlangs)>1) { - $editdefvalues.="
      • "; + $editdefvalues.="
    \n" ."
    ".$clang->gT("Warning")."
    \n" ."
    ".$clang->gT("Tokens have not been initialised for this survey.")."

    \n"; - if ($sumrows5['edit_survey_property'] || - $sumrows5['activate_survey'] || - $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) + if (bHasRight($surveyid, 'edit_survey_property') || bHasRight($surveyid, 'activate_survey')) { $tokenoutput .= "".$clang->gT("If you initialise tokens for this survey then this survey will only be accessible to users who provide a token either smanually or by URL.") ."

    \n"; @@ -417,9 +406,7 @@ .$clang->gT("No, thanks.")."' onclick=\"window.open('{$scriptname}?sid=$surveyid', '_top')\" />
    \n"; // Do not offer old postgres token tables for restore since these are having an issue with missing index if ($tcount>0 && $databasetype!='postgres' && - ($sumrows5['edit_survey_property'] || - $sumrows5['activate_survey'] || - $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) + (bHasRight($surveyid, 'edit_survey_property') || bHasRight($surveyid, 'activate_survey')) ) { $tokenoutput .= "
    ".$clang->gT("Restore options")."
    \n" @@ -466,9 +453,7 @@ ."" ."".$clang->gT("Display tokens")."\n"; -if ($sumrows5['edit_survey_property'] || -$sumrows5['activate_survey'] || -$_SESSION['USER_RIGHT_SUPERADMIN'] == 1) +if (bHasRight($surveyid, 'edit_survey_property') || bHasRight($surveyid, 'activate_survey')) { $tokenoutput .= "" @@ -485,16 +470,13 @@ ."title='".$clang->gTview("Import tokens from LDAP query")."'> ".$clang->gT("Import tokens from LDAP query").""; } -if ($sumrows5['export'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) +if (bHasRight($surveyid, 'export')) { $tokenoutput .= "". "".$clang->gT("Export tokens to CSV file")."\n"; } - -if ($sumrows5['edit_survey_property'] || -$sumrows5['activate_survey'] || -$_SESSION['USER_RIGHT_SUPERADMIN'] == 1) +if (bHasRight($surveyid, 'edit_survey_property') || bHasRight($surveyid, 'activate_survey')) { $tokenoutput .= "\n" ."gT("Token database administration options")."
    \n" ."