--- a/plugins/gallery/sidebar.php Sat Aug 21 23:25:41 2010 -0400
+++ b/plugins/gallery/sidebar.php Sat Aug 21 23:32:06 2010 -0400
@@ -18,48 +18,48 @@
function gal_sidebar_block()
{
- global $db, $session, $paths, $template, $plugins; // Common objects
-
- $q = $db->sql_query('SELECT img_id,img_title FROM '.table_prefix.'gallery WHERE is_folder=0;');
- if ( !$q )
- $db->_die();
-
- $images = array();
- while ( $row = $db->fetchrow() )
- {
- $id = intval($row['img_id']);
- $images[$id] = $row['img_title'];
- }
-
- // Loop through all gallery images until we find one we can read (typically on the first try, but you never know...)
- $my_image = false;
- while ( count($images) > 0 )
- {
- $rand = array_rand($images);
- $image = $images[$rand];
- $acl = $session->fetch_page_acl(strval($rand), 'Gallery');
- if ( is_object($acl) && $acl->get_permissions('read') )
- {
- $my_image = $image;
- break;
- }
- unset($images[$rand]);
- }
- if ( $my_image )
- {
- // Generate sidebar HTML
- $image_link = '<div style="padding: 5px; text-align: center;">
- <a href="' . makeUrlNS('Gallery', $rand) . '">
- <img alt="<thumbnail>" src="' . makeUrlNS('Special', 'GalleryFetcher/thumb/' . $rand) . '" style="border-width: 0; display: block; margin: 0 auto 5px auto;" />
- <span style="color: black;">' . htmlspecialchars($my_image) . '</span>
- </a>
- </div>';
- }
- else
- {
- $image_link = 'No images in the gallery.';
- }
- $template->sidebar_widget('Random image', $image_link);
+ global $db, $session, $paths, $template, $plugins; // Common objects
+
+ $q = $db->sql_query('SELECT img_id,img_title FROM '.table_prefix.'gallery WHERE is_folder=0;');
+ if ( !$q )
+ $db->_die();
+
+ $images = array();
+ while ( $row = $db->fetchrow() )
+ {
+ $id = intval($row['img_id']);
+ $images[$id] = $row['img_title'];
+ }
+
+ // Loop through all gallery images until we find one we can read (typically on the first try, but you never know...)
+ $my_image = false;
+ while ( count($images) > 0 )
+ {
+ $rand = array_rand($images);
+ $image = $images[$rand];
+ $acl = $session->fetch_page_acl(strval($rand), 'Gallery');
+ if ( is_object($acl) && $acl->get_permissions('read') )
+ {
+ $my_image = $image;
+ break;
+ }
+ unset($images[$rand]);
+ }
+ if ( $my_image )
+ {
+ // Generate sidebar HTML
+ $image_link = '<div style="padding: 5px; text-align: center;">
+ <a href="' . makeUrlNS('Gallery', $rand) . '">
+ <img alt="<thumbnail>" src="' . makeUrlNS('Special', 'GalleryFetcher/thumb/' . $rand) . '" style="border-width: 0; display: block; margin: 0 auto 5px auto;" />
+ <span style="color: black;">' . htmlspecialchars($my_image) . '</span>
+ </a>
+ </div>';
+ }
+ else
+ {
+ $image_link = 'No images in the gallery.';
+ }
+ $template->sidebar_widget('Random image', $image_link);
}
$plugins->attachHook('compile_template', 'gal_sidebar_block();');