Index: club-lu/filemgmt/functions.inc
diff -u club-lu/filemgmt/functions.inc:1.2 club-lu/filemgmt/functions.inc:1.2.2.1
--- club-lu/filemgmt/functions.inc:1.2 Tue Apr 6 23:44:42 2004
+++ club-lu/filemgmt/functions.inc Fri Apr 9 20:51:57 2004
@@ -583,7 +583,7 @@
*/
function plugin_getwhatsnew_filemgmt() {
global $_TABLES, $_FM_TABLES, $_CONF, $LANG_FILEMGMT, $LANG01;
- global $filemgmtWhatsNewTitleLength,$filemgmtWhatsNewPeriodDays,$filemgmt_showWhatsNewComments;
+ global $filemgmtWhatsNewTitleLength,$filemgmtWhatsNewPeriodDays;
// Search for new files
$items = array();
@@ -592,11 +592,11 @@
WHERE date >= UNIX_TIMESTAMP( DATE_SUB(NOW(), INTERVAL $filemgmtWhatsNewPeriodDays DAY ) )
ORDER BY date DESC LIMIT 15 ";
$result = DB_query( $sql );
- $nrows1 = DB_numRows( $result );
- if( $nrows1 == 0 ) {
+ $nrows = DB_numRows( $result );
+ if( $nrows == 0 ) {
$retval .= $LANG_FILEMGMT['no_new_files'] . '
' . LB;
} else {
- for( $i = 0; $i < $nrows1; $i++ ) {
+ for( $i = 0; $i < $nrows; $i++ ) {
list($lid, $title) = DB_fetchArray( $result );
$str = "";
$str .= stripslashes(substr($title,0,$filemgmtWhatsNewTitleLength));
@@ -605,34 +605,40 @@
$items[] = $str;
}
}
- if ($filemgmt_showWhatsNewComments) {
- // Search for new comments
- $sql = "SELECT DISTINCT sid, title
- FROM {$_TABLES['comments']}
- WHERE date >= DATE_SUB(NOW(), INTERVAL $filemgmtWhatsNewPeriodDays DAY ) AND type='filemgmt'
- GROUP BY sid ORDER BY date DESC LIMIT 15 ";
- $result = DB_query( $sql );
- $nrows2 = DB_numRows( $result );
- if( $nrows2 == 0 ) {
- $retval .= $LANG_FILEMGMT['no_comments'] . '
' . LB;
- } else {
- for( $i = 0; $i < $nrows2; $i++ ) {
- list($sid, $title) = DB_fetchArray( $result );
- $titleLength = $filemgmtWhatsNewTitleLength + 13; // Compensate for the added HTML
- $title = "C: ".$title;
- $str = "";
- $str .= stripslashes(substr($title,0,$titleLength));
- $str .= '';
- $items[] = $str;
- }
- }
- }
- if ($nrows1 == 0 and $nrows2 == 0) {
+ if ($nrows == 0) {
return $retval;
} else {
return $items;
}
+}
+
+/**
+ * API function provides the title and URL of a file which has new comments.
+ *
+ * @param $file_id The unique id of the file that has new comments
+ *
+ * @return array The file name and URL of the file, or false if the file should
+ * not be shown
+ */
+function plugin_getnewcommentsinfo_filemgmt($file_id)
+{
+ global $_FM_TABLES, $_CONF;
+ global $filemgmt_showWhatsNewComments;
+
+ if ( ! $filemgmt_showWhatsNewComments) { return false; }
+
+ $sql = "SELECT lid, title
+ FROM {$_FM_TABLES['filemgmt_filedetail']}
+ WHERE lid=$file_id";
+ $result = DB_query( $sql );
+ $nrows = DB_numRows( $result );
+
+ if( $nrows == 0 ) { return false; }
+
+ list($sid, $title) = DB_fetchArray( $result );
+ return array(stripslashes($title),
+ "{$_CONF['site_url']}/comment.php?type=filemgmt&cid=$sid");
}