diff -u -r filemgmt/functions.inc filemgmt-patched/functions.inc --- filemgmt/functions.inc Sat Jan 15 03:24:16 2005 +++ filemgmt-patched/functions.inc Sat Jan 15 03:22:49 2005 @@ -583,56 +583,63 @@ */ 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(); $sql = "SELECT lid, title FROM {$_FM_TABLES['filemgmt_filedetail']} - WHERE date >= UNIX_TIMESTAMP( DATE_SUB(NOW(), INTERVAL $filemgmtWhatsNewPeriodDays DAY ) ) + WHERE date >= UNIX_TIMESTAMP( DATE_SUB(NOW(), INTERVAL $filemgmtWhatsNewPeriodDays DAY ) ) AND status > 0 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)); + if (strlen($title) > $filemgmtWhatsNewTitleLength) { $str .= '…'; } $str .= ''; $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"); +} + -?> \ No newline at end of file +?>