Skip to content

Commit

Permalink
Fixed Issue #04694: File download icon in browse screen appearing always
Browse files Browse the repository at this point in the history
Now, We're displaying the download icon only when the survey has a file upload question type.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9335 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Amit Shanker committed Oct 25, 2010
1 parent 797c0b5 commit fed69b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 15 additions & 0 deletions admin/admin_functions.php
Expand Up @@ -96,6 +96,21 @@ function bHasSurveyPermission($iSID, $sPermission, $sCRUD, $iUID=null)
return $aSurveyPermissionCache[$iSID][$iUID][$sPermission][$sCRUD];
}

/**
* Returns true if the given survey has a File Upload Question Type
* @param $surveyid The survey ID
* @return bool
*/
function bHasFileUploadQuestion($surveyid) {
$fieldmap = createFieldMap($surveyid);

foreach ($fieldmap as $field) {
foreach ($field as $key => $value) {
if ($value == "|")
return true;
}
}
}

/**
* Returns true if a user has global permission for a certain action. Available permissions are
Expand Down
10 changes: 7 additions & 3 deletions admin/browse.php
Expand Up @@ -691,8 +691,10 @@
{
$tableheader .= "<img id='imgDeleteMarkedResponses' src='{$imagefiles}/token_delete.png' alt='".$clang->gT('Delete marked responses')."' />";
}
$tableheader .="<img id='imgDownloadMarkedFiles' src='{$imagefiles}/down_all.png' alt='".$clang->gT('Download marked files')."' />"
."</td></tr></tfoot>\n\n";
if (bHasFileUploadQuestion($surveyid))
$tableheader .="<img id='imgDownloadMarkedFiles' src='{$imagefiles}/down_all.png' alt='".$clang->gT('Download marked files')."' />";

$tableheader .="</td></tr></tfoot>\n\n";

$start=returnglobal('start');
$limit=returnglobal('limit');
Expand Down Expand Up @@ -992,7 +994,9 @@
$browseoutput .= " <a href='{$scriptname}?action=dataentry&amp;sid={$surveyid}&amp;subaction=edit&amp;id={$dtrow['id']}'><img src='$imagefiles/token_edit.png' alt='".$clang->gT('Edit this response')."'/></a>";
}

$browseoutput .=" <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>";
// Do not show the download image if the question doesn't contain the File Upload Question Type
if (bHasFileUploadQuestion($surveyid))
$browseoutput .=" <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>";

if (bHasSurveyPermission($surveyid,'responses','delete'))
{
Expand Down

0 comments on commit fed69b5

Please sign in to comment.