function gf_showattachments($topic, $mode = '') { global $_TABLES, $_CONF, $CONF_FORUM, $_FM_TABLES; $retval = ''; $sql = "SELECT id,repository_id,filename FROM {$_TABLES['gf_attachments']} WHERE topic_id={$topic} "; if ($mode != 'edit') { $sql .= "AND show_inline=0 "; } $sql .= "ORDER BY id"; $query = DB_query($sql); $i = 1; while (list($id, $lid, $field_value) = DB_fetchArray($query)) { $retval .= '<div class="forum_attachment">'; if ($mode == 'edit') { $retval .= ' ' . $i . ' '; } $filename = explode(':', $field_value); // Check and see if the file is in the File Mgmt plugin and if user has access if ($CONF_FORUM['filestorage_plugin'] == 'filemgmt' and $lid > 0) { $groupsql = filemgmt_buildAccessSql(); $sql = "SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_filedetail']} a "; $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON a.cid=b.cid "; $sql .= "WHERE a.lid='{$lid}' {$groupsql}"; list($testaccess_cnt) = DB_fetchArray(DB_query($sql)); } elseif ($CONF_FORUM['filestorage_plugin'] == 'nexfile' and $lid > 0) { $cid = DB_getItem($_TABLES['nxfile_files'], 'cid', "fid={$lid}"); if (fm_getPermission($cid, 'view')) { $testaccess_cnt = 1; } else { $testaccess_cnt = 0; } } if ($lid > 0 and $testaccess_cnt == 0) { $retval .= "<img src=\"{$CONF_FORUM['imgset']}/document_sm.gif\" border=\"0\">Insufficent Access"; } elseif (!empty($field_value)) { $retval .= "<img src=\"{$CONF_FORUM['imgset']}/document_sm.gif\" border=\"0\">"; $retval .= "<a href=\"{$_CONF['site_url']}/forum/getattachment.php?id={$id}\" target=\"_new\">"; $retval .= "{$filename[1]}</a> "; if ($mode == 'edit') { $retval .= "<a href=\"#\" onClick='ajaxDeleteFile({$topic},{$id});'>"; $retval .= "<img src=\"{$CONF_FORUM['imgset']}/delete.gif\" border=\"0\"></a>"; } } else { $retval .= 'N/A '; } $retval .= '</div>'; $i++; } return $retval; }
} else { $p = new Template($_CONF['path'] . 'plugins/filemgmt/templates'); $p->set_file(array('page' => 'filelisting.thtml', 'records' => 'filelisting_record.thtml', 'category' => 'filelisting_category.thtml')); $p->set_var('layout_url', $_CONF['layout_url']); $p->set_var('site_url', $_CONF['site_url']); $p->set_var('site_admin_url', $_CONF['site_admin_url']); $p->set_var('xhtml', XHTML); $p->set_var('target', $CONF_FM['ignore_target'] ? '' : 'target="_blank"'); $p->set_var('imgset', $_CONF['layout_url'] . '/nexflow/images'); $p->set_var('tablewidth', $mydownloads_shotwidth + 10); $page = COM_applyFilter($_GET['page'], true); if (!isset($page) or $page == 0) { $page = 1; } $show = $mydownloads_perpage; $groupsql = filemgmt_buildAccessSql(); $sql = "SELECT cid, title, imgurl, grp_access " . "FROM {$_FM_TABLES['filemgmt_cat']} WHERE pid = 0 " . $groupsql . " ORDER BY cid"; $result = DB_query($sql); $nrows = DB_numRows($result); // Need to use a SQL stmt that does a join on groups user has access to - for file count $sql = "SELECT count(*) FROM {$_FM_TABLES['filemgmt_filedetail']} a "; $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON a.cid=b.cid WHERE status > 0 "; $sql .= $groupsql; $countsql = DB_query($sql); list($maxrows) = DB_fetchArray($countsql); $numpages = ceil($maxrows / $show); $p->set_var('block_header', COM_startBlock(sprintf(_MD_LISTINGHEADING, $maxrows))); $p->set_var('block_footer', COM_endBlock()); $count = 0; if ($nrows > 0) { // Display the categories - Top Level (plus #files) with links to sub categories
function _ff_showattachments($topic, $mode = '') { global $_TABLES, $_CONF, $_FF_CONF; $retval = ''; $sql = "SELECT id,repository_id,filename FROM {$_TABLES['ff_attachments']} WHERE topic_id=" . (int) $topic . " "; if ($mode != 'edit') { $sql .= "AND show_inline=0 "; } $sql .= "ORDER BY id"; $query = DB_query($sql); // Check and see if the filemgmt plugin is installed and enabled if (function_exists('filemgmt_buildAccessSql')) { $filemgmtSupport = true; } else { $filemgmtSupport = false; } while (list($id, $lid, $field_value) = DB_fetchArray($query)) { $retval .= '<div class="tblforumfile">'; $filename = explode(':', $field_value); if ($filemgmtSupport and $lid > 0) { // Check and see if user has access to file $groupsql = filemgmt_buildAccessSql(); $sql = "SELECT COUNT(*) FROM {$_TABLES['filemgmt_filedetail']} a "; $sql .= "LEFT JOIN {$_TABLES['filemgmt_cat']} b ON a.cid=b.cid "; $sql .= "WHERE a.lid='{$lid}' {$groupsql}"; list($testaccess_cnt) = DB_fetchArray(DB_query($sql)); } if ($lid > 0 and (!$filemgmtSupport or $testaccess_cnt == 0 or DB_count($_TABLES['filemgmt_filedetail'], "lid", $lid) == 0)) { $retval .= "<img src=\"{$_CONF['site_url']}/forum/images/document_sm.gif\" border=\"0\" alt=\"\"/>Insufficent Access"; } elseif (!empty($field_value)) { $retval .= "<img src=\"{$_CONF['site_url']}/forum/images/document_sm.gif\" border=\"0\" alt=\"\"/>"; $retval .= "<a href=\"{$_CONF['site_url']}/forum/getattachment.php?id={$id}\" target=\"_new\">"; $retval .= "{$filename[1]}</a> "; if ($mode == 'edit') { $retval .= "<a href=\"#\" onclick='ajaxDeleteFile({$topic},{$id});'>"; $retval .= "<img src=\"{$_CONF['site_url']}/forum/images/delete.gif\" border=\"0\" alt=\"\"/></a>"; } } else { $retval .= 'N/A '; } $retval .= '</div>'; } return $retval; }