diff -r ad3b061a1c76 -r c0c324f0eeb5 plugins/gallery/sidebar.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/gallery/sidebar.php Thu Jul 26 10:37:10 2007 -0400 @@ -0,0 +1,67 @@ +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 ( $acl->get_permissions('read') ) + { + $my_image = $image; + break; + } + unset($images[$rand]); + } + if ( $my_image ) + { + // Generate sidebar HTML + $image_link = '
'; + } + else + { + $image_link = 'No images in the gallery.'; + } + $template->sidebar_widget('Random image', $image_link); +} + +$plugins->attachHook('compile_template', 'gal_sidebar_block();'); + +?>