} } else { if (DB_count($_TABLES['nxfile_files'], 'fid', $fid)) { $validfile = true; $sql = "SELECT file.fid,file.cid,file.title,file.fname,file.date,file.size,file.version,file.submitter,u.username, "; $sql .= "file.status,detail.description,category.pid,category.name as folder,v.notes as version_note,file.status_changedby_uid "; $sql .= "FROM {$_TABLES['nxfile_files']} file "; $sql .= "LEFT JOIN {$_TABLES['nxfile_filedetail']} detail ON file.fid=detail.fid "; $sql .= "LEFT JOIN {$_TABLES['nxfile_categories']} category ON file.cid=category.cid "; $sql .= "LEFT JOIN {$_TABLES['nxfile_fileversions']} v ON v.fid=file.fid "; $sql .= "LEFT JOIN {$_TABLES['users']} u ON u.uid=file.submitter "; $sql .= "WHERE file.fid={$fid} ORDER BY v.version DESC"; $res = DB_fetchArray(DB_query($sql), false); $data = array_merge($data, $res); $tagcloud = new nexfileTagCloud(); $data['tags'] = $tagcloud->get_itemtags($fid); // Check if file is locked if ($data['status'] == lockedstatus) { $data['locked'] = true; } else { $data['locked'] = false; } // Check and see if user has subscribed to this file $direct = false; $ignorefilechanges = false; // Check if user has an ignore file changes record or a subscribe to changes record for this file $query = DB_query("SELECT fid,ignore_filechanges FROM {$_TABLES['nxfile_notifications']} WHERE fid={$fid} and uid={$uid}"); if (DB_numRows($query) == 1) { $A = DB_fetchArray($query); if ($A['ignore_filechanges'] == 1) { $ignorefilechanges = true;
function nexdoc_displayTagSearchListing($query, &$data) { global $_CONF, $_TABLES, $_FMCONF, $allowableViewFoldersSql, $paddingsize, $filedescriptionOffset; $tpl = new Template($_CONF['path_layout'] . 'nexfile'); $tpl->set_file(array('filedetails' => 'filedetails.thtml', 'subfolder' => 'filelisting_subfolder_record.thtml', 'emptyfolder' => 'filelisting_emptyfolder.thtml', 'filelisting_rec' => 'filelisting_record.thtml', 'folderlisting_rec' => 'leftnav_folder_record.thtml', 'movefolder' => 'folder_onhover_move.thtml', 'tag_link' => 'taglink_record.thtml', 'tag_rec' => 'tagdesc_record.thtml', 'download_action' => 'download_link.thtml', 'editfile_action' => 'editfile_link.thtml')); $tpl->set_var('layout_url', $_CONF['layout_url']); $tpl->set_var('imgset', "{$_CONF['layout_url']}/nexfile/images"); $sql = "SELECT file.fid as fid,file.cid,file.title,file.fname,file.date,file.version,file.submitter,file.status,"; $sql .= "detail.description,category.name,category.pid "; $sql .= "FROM {$_TABLES['nxfile_files']} file "; $sql .= "LEFT JOIN {$_TABLES['nxfile_filedetail']} detail ON detail.fid=file.fid "; $sql .= "LEFT JOIN {$_TABLES['nxfile_categories']} category ON file.cid=category.cid "; $sql .= "WHERE 1=1 "; if (!empty($allowableViewFoldersSql)) { $sql .= "AND file.cid in ({$allowableViewFoldersSql}) "; } $tagcloud = new nexfileTagCloud(); $itemids = $tagcloud->search($query); if ($itemids !== FALSE) { $itemids = implode(',', $itemids); } if (!empty($itemids)) { $sql .= "AND file.fid in ({$itemids}) "; } else { $sql .= "AND 1 = 2"; // No tags match query - return 0 records } $sql .= "ORDER BY file.date DESC "; $resFiles = DB_query($sql); if (DB_numRows($resFiles) > 0) { // Show any files in this directory $i = 1; $query = stripslashes($query); while (list($fid, $subfolderId, $title, $fname, $date, $version, $submitter, $status, $description, $category, $pid) = DB_fetchARRAY($resFiles)) { $tpl->set_var('padding_left', 2 * $paddingsize); $tpl->set_var('file_desc_padding_left', $filedescriptionOffset); if ($status == 2) { $tpl->set_var('showlock', ''); } else { $tpl->set_var('showlock', 'none'); } $tpl->set_var('details_link_parms', "?fid={$fid}"); $tpl->set_var('fid', $fid); $tpl->set_var('file_name', $title); $tpl->set_var('modified_date', strftime($_CONF['shortdate'], $date)); $tpl->set_var('folder_link', "{$_CONF['site_url']}/nexfile/index.php?cid={$subfolderId}"); $tpl->set_var('folder_name', $category); $tpl->set_var('subfolder_id', $subfolderId); $tags = $tagcloud->get_itemtags($fid); nexdoc_formatfiletags($tpl, $tags, $query); nexdoc_formatFavoriteImage($tpl, $fid); $tpl->set_var('file_description', nl2br($description)); $tpl->set_var('download_link', "{$_CONF['site_url']}/nexfile/download.php?op=download&fid={$fid}"); $tpl->parse('download_action_link', 'download_action'); if ($uid > 1) { $tpl->set_var('edit_link', "{$_CONF['site_url']}/nexfile/download.php?op=editfile&fid={$fid}"); $tpl->parse('edit_action_link', 'editfile_action'); } else { $tpl->set_var('edit_action_link', ''); } $pos = strrpos($fname, '.') + 1; $ext = strtolower(substr($fname, $pos)); if (array_key_exists($ext, $_FMCONF['iconlib'])) { $icon = $_FMCONF['imagesurl'] . key($_FMCONF['iconlib'][$ext]); } else { $icon = $_FMCONF['imagesurl'] . key($_FMCONF['iconlib']['none']); } $tpl->set_var('extension_icon', $icon); if ($i == 1) { $tpl->parse('filelisting', 'filelisting_rec'); } else { $tpl->parse('filelisting', 'filelisting_rec', true); } $i++; } } else { $tpl->set_var('folder_desc_padding_left', $filedescriptionOffset); // Version 3.0 - not presently used $tpl->parse('filelisting', 'emptyfolder'); } $data['displayhtml'] = $tpl->finish($tpl->get_var('filelisting')); $data['tagcloud'] = $tagcloud->displaycloud(); }