Index: club-lu/geekary/config.php diff -u club-lu/geekary/config.php:1.2 club-lu/geekary/config.php:1.3 --- club-lu/geekary/config.php:1.2 Thu Jan 1 04:34:47 2004 +++ club-lu/geekary/config.php Tue Apr 6 23:45:07 2004 @@ -63,6 +63,12 @@ publictemps => $_CONF['path'] . 'plugins/geekary/templates/public', geekards_admin_email=>'admin@club-lu.net', - geekards_email=>'admin@club-lu.net' + geekards_email=>'admin@club-lu.net', + +// Show new pictures in the What's New block + whatsnew_supported=>1, + whatsnew_showcomments=>1, + whatsnew_days=>7, + whatsnew_titlelength=>20, ); ?> Index: club-lu/geekary/functions.inc diff -u club-lu/geekary/functions.inc:1.1.1.1 club-lu/geekary/functions.inc:1.2.2.2 --- club-lu/geekary/functions.inc:1.1.1.1 Thu Jan 1 04:12:19 2004 +++ club-lu/geekary/functions.inc Fri Apr 9 20:51:57 2004 @@ -391,5 +391,85 @@ return true; } +/** + * Whats New Block API Support + * Return the Headline and Byline for the new section in the Whatsnew Block + */ +function plugin_whatsnewsupported_geekary() +{ + global $LANG_GEEKARY, $_GKCONST; + + if ($_GKCONST['whatsnew_supported'] == 1) { + return array($LANG_GEEKARY['whatsnewlabel'],sprintf($LANG_GEEKARY['whatsnewperiod'], $_GKCONST['whatsnew_days'])); + } else { + return ''; + } +} + + +/** + * API function provides the content of our "What's New" feed + */ +function plugin_getwhatsnew_geekary() +{ + global $_TABLES, $_CONF, $LANG_GEEKARY, $_GKCONST; + + // Search for new files + $items = array(); + $sql = "SELECT {$_TABLES['geekary_images']}.id, cat_id, name + FROM {$_TABLES['geekary_images']} LEFT JOIN {$_TABLES['geekary_cat']} + ON {$_TABLES['geekary_images']}.cat_id = {$_TABLES['geekary_cat']}.id + WHERE uploaded >= DATE_SUB(NOW(), INTERVAL {$_GKCONST['whatsnew_days']} DAY) " . + COM_getPermSQL('AND', 0, 2, $_TABLES['geekary_cat']) . + " ORDER BY uploaded DESC LIMIT 15"; + $result = DB_query( $sql ); + $nrows = DB_numRows( $result ); + if( $nrows == 0 ) { + $retval .= $LANG_GEEKARY['nopictures'] . '
' . LB; + } else { + for( $i = 0; $i < $nrows; $i++ ) { + list($id, $cat_id, $name) = DB_fetchArray( $result ); + $str = ""; + $str .= stripslashes(substr($name,0,$_GKCONST['whatsnew_titlelength'])); + if (strlen($name) > $_GKCONST['whatsnew_titlelength']) { $str .= '…'; } + $str .= ''; + $items[] = $str; + } + } + + if ($nrows == 0) { + return $retval; + } else { + return $items; + } +} + +/** + * API function provides What's New block with information on images that have + * new comments. + * + * @param string $img_id The image id + * + * @return array The image name and raw URL + */ +function plugin_getnewcommentsinfo_geekary($img_id) +{ + global $_TABLES, $_CONF, $_GKCONST; + if ($_GKCONST['whatsnew_showcomments'] == 0) { return false; } + + $sql = "SELECT {$_TABLES['geekary_images']}.id as img_id, cat_id, name + FROM {$_TABLES['geekary_images']} LEFT JOIN {$_TABLES['geekary_cat']} + ON {$_TABLES['geekary_images']}.cat_id = {$_TABLES['geekary_cat']}.id + WHERE {$_TABLES['geekary_images']}.id='$img_id' " . + COM_getPermSQL('AND', 0, 2, $_TABLES['geekary_cat']) ; + $result = DB_query( $sql ); + + if (DB_numRows( $result ) == 0) { + return false; + } + + $A = DB_fetchArray($result); + return array($A['name'], "{$_CONF['site_url']}/geekary/geekage.php?id={$A['img_id']}"); +} -?> \ No newline at end of file +?>