Skip to content

Commit

Permalink
Dev Merged changes from dev branch up to 9210
Browse files Browse the repository at this point in the history
New feature #4588: Allow to reverse iteration order in Array (Numbers). This allows to reverse the iteration order of the generated numbers when setting "Minimum value" "Maximum value" and "Step" in "Array (Numbers)" question type. Reverse ordering can be achieved by putting a _max value lower than _min. The loop will iterate in reverse (you don't need to put a negative step value). Requested for questions where ordering could introduce bias. Patch kindly provided by wavexx


git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9213 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Oct 11, 2010
2 parents bbb16a8 + 82afe29 commit d9398aa
Show file tree
Hide file tree
Showing 107 changed files with 114,618 additions and 56,000 deletions.
8 changes: 1 addition & 7 deletions admin/assessments.php
Expand Up @@ -25,18 +25,12 @@
$js_admin_includes[]= $rooturl.'/scripts/jquery/jquery-ui.js';
// . "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"styles/default/jquery-ui.css\" />\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";
Expand Down
149 changes: 48 additions & 101 deletions admin/browse.php
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -226,7 +222,7 @@
while ($idrow = $idresult->FetchRow())
{
$id=$idrow['id'];
$rlangauge=$idrow['startlanguage'];
$rlanguage=$idrow['startlanguage'];
}
$next=$id+1;
$last=$id-1;
Expand All @@ -236,13 +232,13 @@
."\t</div><div class='menubar-main'>\n"
."<img src='$imagefiles/blank.gif' width='31' height='20' border='0' hspace='0' align='left' alt='' />\n"
."<img src='$imagefiles/seperator.gif' border='0' hspace='0' align='left' alt='' />\n";
if (isset($rlangauge))
if (isset($rlanguage))
{
$browseoutput .="<a href='$scriptname?action=dataentry&amp;subaction=edit&amp;id=$id&amp;sid=$surveyid&amp;language=$rlangauge' "
$browseoutput .="<a href='$scriptname?action=dataentry&amp;subaction=edit&amp;id=$id&amp;sid=$surveyid&amp;language=$rlanguage' "
."title='".$clang->gTview("Edit this entry")."'>"
."<img align='left' src='$imagefiles/edit.png' alt='".$clang->gT("Edit this entry")."' /></a>\n";
}
if (($sumrows5['delete_survey'] || $_SESSION['USER_RIGHT_SUPERADMIN'] == 1) && isset($rlangauge))
if (bHasRight($surveyid,'delete_survey') && isset($rlanguage))
{

$browseoutput .= "<a href='#' title='".$clang->gTview("Delete this entry")."' onclick=\"if (confirm('".$clang->gT("Are you sure you want to delete this entry?","js")."')) {".get2post($scriptname.'?action=dataentry&amp;subaction=delete&amp;id='.$id.'&amp;sid='.$surveyid)."}\" >"
Expand Down Expand Up @@ -348,7 +344,7 @@
}

//Delete Individual answer using inrow delete buttons/links - checked
if (isset($_POST['deleteanswer']) && $_POST['deleteanswer'] != '' && $_POST['deleteanswer'] != 'marked')
if (isset($_POST['deleteanswer']) && $_POST['deleteanswer'] != '' && $_POST['deleteanswer'] != 'marked' && bHasRight($surveyid,'delete_survey'))
{
$_POST['deleteanswer']=(int) $_POST['deleteanswer']; // sanitize the value

Expand Down Expand Up @@ -385,16 +381,16 @@
$connect->execute($query) or safe_die("Could not delete response<br />$dtquery<br />".$connect->ErrorMsg()); // checked
}
// Marked responses -> deal with the whole batch of marked responses
else if (isset($_POST['markedresponses']) && count($_POST['markedresponses'])>0)
if (isset($_POST['markedresponses']) && count($_POST['markedresponses'])>0 && bHasRight($surveyid,'delete_survey'))
{
// Delete the marked responses - checked
if (isset($_POST['deleteanswer']) && $_POST['deleteanswer'] === 'marked')
{
foreach ($_POST['markedresponses'] as $iResponseID)
{
$iResponseID = (int)$iResponseID; // sanitize the value
$query="delete FROM $surveytable where id={$iResponseID}";
$connect->execute($query) or safe_die("Could not delete response<br />$dtquery<br />".$connect->ErrorMsg()); // checked
$query="delete FROM {$surveytable} where id={$iResponseID}";
$connect->execute($query) or safe_die("Could not delete response<br />{$dtquery}<br />".$connect->ErrorMsg()); // checked
}
}
// Download all files for all marked responses - checked
Expand Down Expand Up @@ -603,7 +599,7 @@
$fnames[] = array("lastname", "Last Name", $clang->gT("Last Name"), 0);
$fnames[] = array("email", "Email", $clang->gT("Email"), 0);
}
$fnames[] = array("submitdate", "Completed", $clang->gT("Completed"), "0", 'D');
$fnames[] = array("submitdate", $clang->gT("Completed"), $clang->gT("Completed"), "0", 'D');
$fields = createFieldMap($surveyid, 'full', false, false, $language);

foreach ($fields as $fielddetails)
Expand Down Expand Up @@ -658,7 +654,7 @@
else {$tableheader .= "<table class='browsetable'>\n";}
$tableheader .= "\t<thead><tr valign='top'>\n"
. "<th><input type='checkbox' id='selectall'></th>\n"
. "<th>Actions</th>\n";
. "<th>".$clang->gT('Actions')."</th>\n";
foreach ($fnames as $fn)
{
if (!isset($currentgroup)) {$currentgroup = $fn[1]; $gbc = "oddrow";}
Expand All @@ -673,103 +669,53 @@
. "</strong></th>\n";
}
$tableheader .= "\t</tr></thead>\n\n";
if (bHasRight($surveyid,'delete_survey'))
{
$tableheader .= "\t<tfoot><tr><td colspan=".($fncount+2).">"
."<img id='imgDeleteMarkedResponses' src='$imagefiles/token_delete.png' alt='".$clang->gT('Delete marked responses')."' />"
."<img id='imgDownloadMarkedFiles' src='$imagefiles/down.png' alt='".$clang->gT('Download Marked Files')."' />"
."</td></tr></tfoot>\n\n";
}


$start=returnglobal('start');
$limit=returnglobal('limit');
if (!isset($limit) || $limit== '') {$limit = 50;}
if (!isset($start) || $start =='') {$start = 0;}

//LETS COUNT THE DATA
//Create the query
if ($surveyinfo['private'] == "N" && db_tables_exist($tokentable))
{
$dtquery = "SELECT count(*) FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token ";
} else
{
$dtquery = "SELECT count(*) FROM $surveytable ";
$sql_from = "$surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token";
} else {
$sql_from = $surveytable;
}

$sql_where = "";
if (incompleteAnsFilterstate() == "inc")
{
$dtquery .= "WHERE submitdate IS NULL ";
$sql_where .= "submitdate IS NULL";
}
elseif (incompleteAnsFilterstate() == "filter")
{
$dtquery .= " WHERE submitdate IS NOT NULL ";
$sql_where .= "submitdate IS NOT NULL";
}
if (isset($_POST['sql']) && stripcslashes($_POST['sql']) !== "" && $_POST['sql'] !== "NULL")
{
if (!empty($sql_where)) $sql_where .= " AND ";
$sql_where .= stripcslashes($_POST['sql']);
}
if (!empty($sql_where)) $sql_where = " WHERE " . $sql_where;

//LETS COUNT THE DATA
$dtquery = "SELECT count(*) FROM $sql_from $sql_where";
$dtresult=db_execute_num($dtquery) or safe_die("Couldn't get response data<br />$dtquery<br />".$connect->ErrorMsg());
while ($dtrow=$dtresult->FetchRow()) {$dtcount=$dtrow[0];}

if ($limit > $dtcount) {$limit=$dtcount;}

//NOW LETS SHOW THE DATA
if (isset($_POST['sql']))
{
if ($_POST['sql'] == "NULL" )
{
if ($surveyinfo['private'] == "N" && db_tables_exist($tokentable))
$dtquery = "SELECT * FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token ";
else
$dtquery = "SELECT * FROM $surveytable ";
if (incompleteAnsFilterstate() == "inc")
{
$dtquery .= "WHERE submitdate IS NULL";
}
elseif (incompleteAnsFilterstate() == "filter")
{
$dtquery .= " WHERE submitdate IS NOT NULL ";
}
$dtquery .= " ORDER BY id";
}
else
{
if ($surveytable['private'] == "N" && db_tables_exist($tokentable))
$dtquery = "SELECT * FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token ";
else
$dtquery = "SELECT * FROM $surveytable ";
if (incompleteAnsFilterstate() == "inc")
{
$dtquery .= "submitdate IS NULL ";
if (stripcslashes($_POST['sql']) !== "")
{
$dtquery .= " AND ";
}
}
elseif (incompleteAnsFilterstate() == "filter")
{
$dtquery .= " submitdate IS NOT NULL ";
if (stripcslashes($_POST['sql']) !== "")
{
$dtquery .= " AND ";
}
}
if (stripcslashes($_POST['sql']) !== "")
{
$dtquery .= stripcslashes($_POST['sql'])." ";
}
$dtquery .= " ORDER BY id";
}
}
else
{
if ($surveyinfo['private'] == "N" && db_tables_exist($tokentable))
$dtquery = "SELECT * FROM $surveytable LEFT JOIN $tokentable ON $surveytable.token = $tokentable.token ";
else
$dtquery = "SELECT * FROM $surveytable ";

if (incompleteAnsFilterstate() == "inc")
{
$dtquery .= " WHERE submitdate IS NULL ";
}
elseif (incompleteAnsFilterstate() == "filter")
{
$dtquery .= " WHERE submitdate IS NOT NULL ";
}
$dtquery .= " ORDER BY id";
}
$dtquery = "SELECT * FROM $sql_from $sql_where ORDER BY id";
if ($order == "desc") {$dtquery .= " DESC";}

if (isset($limit))
Expand Down Expand Up @@ -864,27 +810,28 @@
<a><img id='downloadfile_{$dtrow['id']}' src='$imagefiles/down.png' alt='".$clang->gT('Download all files in this response as a zip file')."' class='downloadfile'/></a>
<a><img id='deleteresponse_{$dtrow['id']}' src='$imagefiles/token_delete.png' alt='".$clang->gT('Delete this response')."' class='deleteresponse'/></a></td>\n";

if (bHasRight($surveyid,'delete_survey'))
{
$browseoutput .= "<a><img id='deleteresponse_{$dtrow['id']}' src='$imagefiles/token_delete.png' alt='".$clang->gT('Delete this response')."' class='deleteresponse'/></a>\n";
}
$browseoutput .= "</td>";
$i = 0;
//If not private, display the token info and link to the token screen
if ($surveyinfo['private'] == "N" && $dtrow['token'] && db_tables_exist($tokentable))
{
$SQL = "Select * FROM ".db_table_name('tokens_'.$surveyid)." WHERE token=?";
if ( db_tables_exist(db_table_name_nq('tokens_'.$surveyid)) &&
$SQLResult = db_execute_assoc($SQL, $dtrow['token']))
{
$TokenRow = $SQLResult->FetchRow();
}
$browseoutput .= "<td align='center'>\n";
if (isset($TokenRow) && $TokenRow)
if (isset($dtrow['tid']) && !empty($dtrow['tid']))
{
$browseoutput .= "<a href='$scriptname?action=tokens&amp;sid=$surveyid&amp;subaction=edit&amp;tid={$TokenRow['tid']}' title='".$clang->gT("Edit this token")."'>";
//If we have a token, create a link to edit it
$browsedatafield = "<a href='$scriptname?action=tokens&amp;sid=$surveyid&amp;subaction=edit&amp;tid={$dtrow['tid']}' title='".$clang->gT("Edit this token")."'>";
$browsedatafield .= "{$dtrow['token']}";
$browsedatafield .= "</a>";
} else {
//No corresponding token in the token tabel, just display the token
$browsedatafield .= "{$dtrow['token']}";
}
$browseoutput .= "{$dtrow['token']}";
if (isset($TokenRow) && $TokenRow)
{
$browseoutput .= "</a>\n";
$browseoutput .= "<td align='center'>$browsedatafield</td>\n";
$i++; //We skip the first record (=token) as we just outputted that one
}
$i++;
}

for ($i; $i<$fncount; $i++)
{
Expand Down
6 changes: 5 additions & 1 deletion admin/conditionshandling.php
Expand Up @@ -32,7 +32,11 @@
if (!isset($qid)) {$qid=returnglobal('qid');}
if (!isset($gid)) {$gid=returnglobal('gid');}
if (!isset($p_scenario)) {$p_scenario=returnglobal('scenario');}
if (!isset($p_cqid)) {$p_cqid=returnglobal('cqid');}
if (!isset($p_cqid))
{
$p_cqid=returnglobal('cqid');
if ($p_cqid == '') $p_cqid=0; // we are not using another question as source of condition
}
if (!isset($p_cid)) {$p_cid=returnglobal('cid');}
if (!isset($p_subaction)) {$p_subaction=returnglobal('subaction');}
if (!isset($p_cquestions)) {$p_cquestions=returnglobal('cquestions');}
Expand Down

0 comments on commit d9398aa

Please sign in to comment.