. * * You can get complete code of ProjeQtOr, other resource, help and information * about contributors at http://www.projeqtor.org * * ** DO NOT REMOVE THIS NOTICE *********************************************** * * * * * ** instalation steps **** * reportAttachment * mkavurcic@gmail.com * * *** rename to 'php' and copy this file to ../report **** * * *** sql - insert report data into database -- Miscellaneous report group **** INSERT INTO report (`id`, `name`, `idReportCategory`, `file`, `sortOrder`, `hasPdf`) VALUES (1000, 'reportAttachment', 9, 'attachment.php', 950, 1); INSERT INTO reportparameter (`idReport`, `name`, `paramType`, `sortOrder`, `defaultValue`) VALUES (1000, 'idUser', 'userList', 10, null); INSERT INTO projeqtor.reportparameter (idReport, `name`, paramType, sortOrder, idle, defaultValue, multiple) VALUES (1000, 'Idle', 'boolean', 20, 0, true, 0); * * *** Adjust report access rights to your needs **** * * *** add new lines in ../tool/i18n/nls/en/lang.js - translate into other languages, if needed, and add to corresponding lang.js files **** sumOfAccessibleFiles: "Sum of accessible files", sumOfFiles: "Sum of attached files", reportAttachment: "Attachments", * * ** */ include_once '../tool/projeqtor.php'; //header $paramActive = ''; $paramUser = ''; $headerParameters = ''; if (array_key_exists('idUser', $_REQUEST) and trim($_REQUEST['idUser']) != "") { $paramUser = trim($_REQUEST['idUser']); Security::checkValidId($paramUser); $headerParameters .= i18n("colIdUser") . ' : ' . htmlEncode(SqlList::getNameFromId('user', $paramUser)) . '
'; } else { $headerParameters .= i18n("colIdUser") . ': ' . i18n("allUsers") . '
'; } if (array_key_exists('Idle',$_REQUEST)) { $paramActive=true; $headerParameters .= i18n('labelShowIdle') . ' = ' . i18n('displayYes') . '
'; } else { $paramActive = FALSE; $headerParameters .= i18n('labelShowIdle') . ' = ' . i18n('displayNo') . '
'; } $headerParameters .= i18n('colCreateDateTime') . ', ' . i18n("sortDesc"); //where $where = ''; if ($paramUser) { $where = 'idUser=' . $paramUser; } //attachment fetch $att = new Attachment(); $res_att = $att->getSqlElementsFromCriteria(null, null, $where, 'creationDate desc'); include "header.php"; // Headers echo ''; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ''; //rows $nr = 0; $nr1 = 0; $fs = 0; foreach ($res_att as $att) { $nr += 1; //access rights check - "project is in active user's visible projects list" and ("file is not private" or "file idUser equals active user" or "active user is admin") if (in_array( SqlList::getNameFromId( 'Project' , implode( null, SqlList::getListWithCrit( $att->refType, array('id' => $att->refId), 'idProject', NULL, $paramActive) ) ) , getUserVisibleObjectsList('Project', $paramActive) ) and ( $att->idPrivacy != SqlList::getIdFromTranslatableName('privacy', 'private') or $user->id == $att->idUser or $user->name == 'admin' ) ) { $nr1 += 1; $fs += $att->fileSize; echo ''; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ' '; echo ''; } } //summary row echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
' . '' . i18n('colFileName') . '' . i18n('colDescription') . '' . i18n('colFileSize') . '' . i18n('colIsPrivate') . '' . i18n('colIdProject') . '' . i18n('colRefType') . '' . i18n('colRefId') . '' . i18n('colDescription') . '' . i18n('colUserName') . '' . i18n('colCreateDateTime') . '
'; if ($att->fileName and $att->subDirectory) { echo'' . formatSmallButton('Download'); echo ''; } if ($att->link) { echo '
' . ''; echo '
'; } echo '
' . $att->fileName . '' . $att->description . '' . htmlGetFileSize($att->fileSize) . ''; switch ($att->idPrivacy) { case SqlList::getIdFromTranslatableName('privacy', 'private') : echo ' '; echo SqlList::getNameFromId('privacy', $att->idPrivacy); break; default: echo SqlList::getNameFromId('privacy', $att->idPrivacy); } echo '' . SqlList::getNameFromId('Project', array_values(SqlList::getListWithCrit($att->refType, array('id' => $att->refId), 'idProject', NULL, $paramActive))[0]) . ' ' . i18n($att->refType) . '' . $att->refId . '' . SqlList::getNameFromId($att->refType, $att->refId) . '' . SqlList::getNameFromId('user', $att->idUser) . '' . $att->creationDate . '
' . i18n('sumOfFiles') . ': ' . $nr . '' . i18n('sumOfAccessibleFiles') . ': ' . $nr1 . '' . htmlGetFileSize($fs) . '
'; echo "
"; echo "
";