diff -r 0944c9354e9c -r 7c6e2e97aa08 plugins/gallery/sidebar.php --- 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 = '
- - <thumbnail> - ' . htmlspecialchars($my_image) . ' - -
'; - } - 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 = '
+ + <thumbnail> + ' . htmlspecialchars($my_image) . ' + +
'; + } + else + { + $image_link = 'No images in the gallery.'; + } + $template->sidebar_widget('Random image', $image_link); } $plugins->attachHook('compile_template', 'gal_sidebar_block();');