function template_preprocess_filedepot_filedetail in filedepot 7
Same name and namespace in other branches
- 6 lib-theme.php \template_preprocess_filedepot_filedetail()
File
- ./
lib-theme.php, line 530 - lib-theme.php Theme support functions for the module
Code
function template_preprocess_filedepot_filedetail(&$variables) {
$filedepot = filedepot_filedepot();
$nexcloud = filedepot_nexcloud();
$fid = $variables['fid'];
$variables['site_url'] = base_path();
$variables['ajax_server_url'] = url('filedepot_ajax');
$variables['LANG_download'] = t('Download File');
$variables['LANG_lastupated'] = t('Last Updated');
$variables['show_statusmsg'] = 'none';
$limit = FALSE;
if ($variables['reportmode'] == 'approvals') {
$sql = "SELECT file.cid,file.title,file.fname,file.date,file.version,file.size, ";
$sql .= "file.description,file.submitter,file.status,file.version_note as notes,tags ";
$sql .= "FROM {filedepot_filesubmissions} file ";
$sql .= "WHERE file.id=:fid";
}
elseif ($variables['reportmode'] == 'incoming') {
$sql = "SELECT 0,file.orig_filename as title,file.orig_filename as fname,file.timestamp,1,file.size, ";
$sql .= "file.description,file.uid,9,file.version_note,'' ";
$sql .= "FROM {filedepot_import_queue} file ";
$sql .= "WHERE file.id=:fid";
}
else {
$sql = "SELECT file.cid, file.title, v.fname, file.date, file.version, file.size, ";
$sql .= "file.description, file.submitter, file.status, v.notes, '' as tags ";
$sql .= "FROM {filedepot_files} file ";
$sql .= "LEFT JOIN {filedepot_fileversions} v ON v.fid=file.fid ";
$sql .= "WHERE file.fid=:fid ORDER BY v.version DESC ";
$limit = 1;
}
$filedetail = FALSE;
if ($limit !== FALSE) {
$query = db_query_range($sql, 0, 1, array(
':fid' => $fid,
));
}
else {
$query = db_query($sql, array(
':fid' => $fid,
));
}
$A = $query
->fetchAssoc();
if ($A != NULL) {
list($cid, $title, $fname, $date, $cur_version, $size, $description, $submitter, $status, $cur_notes, $tags) = array_values($A);
$variables['cid'] = $cid;
$variables['shortdate'] = strftime($filedepot->shortdate, $date);
$variables['size'] = filedepot_formatFileSize($size);
$icon = $filedepot
->getFileIcon($fname);
$variables['fileicon'] = "{$variables['layout_url']}/css/images/{$icon}";
$author = db_query("SELECT name FROM {users} WHERE uid=:uid", array(
':uid' => $submitter,
))
->fetchField();
$catname = db_query("SELECT name FROM {filedepot_categories} WHERE cid=:cid", array(
':cid' => $cid,
))
->fetchField();
$nid = db_query("SELECT nid FROM {filedepot_categories} WHERE cid=:cid", array(
':cid' => $cid,
))
->fetchField();
$variables['fname'] = filter_xss($fname);
$variables['current_version'] = "(V{$cur_version})";
$variables['filetitle'] = filter_xss($title);
$variables['real_filename'] = filter_xss($fname);
$variables['author'] = $author;
$variables['description'] = nl2br(filter_xss($description));
$variables['foldername'] = filter_xss($catname);
$variables['current_ver_note'] = nl2br(filter_xss($cur_notes));
$variables['tags'] = $nexcloud
->get_itemtags($fid);
$variables['disable_download'] = '';
if ($status == FILEDEPOT_UNAPPROVED_STATUS) {
$variables['show_statusmsg'] = '';
$variables['status_image'] = '<img src="' . $variables['layout_url'] . '/css/images/padlock.gif">';
$variables['statusmessage'] = '* ' . t('File Submission to Approve');
}
elseif ($status == FILEDEPOT_INCOMING_STATUS) {
$variables['show_statusmsg'] = '';
$variables['status_image'] = ' ';
$variables['statusmessage'] = '* ' . t('Incoming File - needs to be moved or deleted');
$variables['disable_download'] = 'onClick="return false;"';
}
elseif ($status == FILEDEPOT_LOCKED_STATUS) {
$variables['show_statusmsg'] = '';
$stat_userid = db_query("SELECT status_changedby_uid FROM {filedepot_files} WHERE fid=:fid", array(
':fid' => $fid,
))
->fetchField();
$stat_user = db_query("SELECT name FROM {users} WHERE uid=:uid", array(
':uid' => $stat_userid,
))
->fetchField();
$variables['status_image'] = '<img src="' . $variables['layout_url'] . '/css/images/padlock.gif">';
$variables['statusmessage'] = '* ' . t('Locked by %name', array(
'%name' => $stat_user,
));
$variables['LANG_DOWNLOAD_MESSAGE'] = t('File Locked by: %name', array(
'%name' => $stat_user,
));
$variables['disable_download'] = 'onClick="return FALSE;"';
}
else {
$variables['status_image'] = ' ';
$variables['statusmessage'] = ' ';
}
if (function_exists('spaces_get_space')) {
$space = spaces_get_space();
if ($space && $space->type === 'og') {
$urlprefix = '';
switch (variable_get('purl_method_spaces_og', 'path')) {
case 'path':
$urlprefix = "{$space->group->purl}";
break;
case 'pair':
$urlprefix = "{$key}/{$space->id}";
break;
}
}
}
$clean_urls_on = variable_get('clean_url', 0);
if ($clean_urls_on == 1) {
$url_separator = "/";
}
else {
$url_separator = "?q=";
}
if (isset($urlprefix) and !empty($urlprefix)) {
$variables['download_url'] = base_path() . "index.php{$url_separator}{$urlprefix}/filedepot&cid={$cid}&fid={$fid}";
}
else {
$variables['download_url'] = base_path() . "index.php{$url_separator}filedepot&cid={$cid}&fid={$fid}";
}
// Retrieve file versions
$sql = "SELECT fid,fname,version,notes,size,date,uid FROM {filedepot_fileversions} " . "WHERE fid=:fid AND version < :version ORDER by version DESC";
$query = db_query($sql, array(
':fid' => $fid,
':version' => $cur_version,
));
$version_records = '';
if ($query) {
while ($rec = $query
->fetchAssoc()) {
$rec['nid'] = $nid;
$version_records .= theme('filedepot_fileversion', array(
'versionRec' => $rec,
));
}
}
$variables['version_records'] = $version_records;
}
}