__('Everyone', 'aniga'), 1 => __('Userlevel', 'aniga') . ' >= 1', 2 => __('Userlevel', 'aniga') . ' >= 2', 3 => __('Userlevel', 'aniga') . ' >= 3', 4 => __('Userlevel', 'aniga') . ' >= 4', 5 => __('Userlevel', 'aniga') . ' >= 5', 6 => __('Userlevel', 'aniga') . ' >= 6', 7 => __('Userlevel', 'aniga') . ' >= 7', 8 => __('Userlevel', 'aniga') . ' >= 8', 9 => __('Userlevel', 'aniga') . ' >= 9', 10 => __('Administrator', 'aniga')); // table names $wpdb->aniga_alb = $wpdb->prefix . 'aniga_albums'; $wpdb->aniga_pic = $wpdb->prefix . 'aniga_picture'; $wpdb->aniga_rel = $wpdb->prefix . 'aniga_relations'; //function to create the tables on plugin activation //######################################################################## function aniga_install () { global $wpdb; require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); $table_alb = $wpdb->aniga_alb; if($wpdb->get_var("show tables like '$table_alb'") != $table_alb) { $sql = "CREATE TABLE `".$table_alb."` ( `id` BIGINT( 20 ) NOT NULL DEFAULT '0', `name` TEXT NOT NULL , `desc` TEXT NOT NULL , `level` VARCHAR( 2 ) NOT NULL DEFAULT '0', `order` MEDIUMINT NOT NULL DEFAULT '0', `count` MEDIUMINT NOT NULL , PRIMARY KEY (`id`) );"; dbDelta($sql); } $table_rel = $wpdb->aniga_rel; if($wpdb->get_var("show tables like '$table_rel'") != $table_rel) { $sql = "CREATE TABLE `".$table_rel."` ( `id` BIGINT( 20 ) NOT NULL , `parent_id` BIGINT( 20 ) NOT NULL );"; dbDelta($sql); } $table_pic = $wpdb->aniga_pic; if($wpdb->get_var("show tables like '$table_pic'") != $table_pic) { $sql = "CREATE TABLE `".$table_pic."` ( `pid` BIGINT( 20 ) NOT NULL auto_increment, `parent_id` BIGINT( 20 ) NOT NULL default '0', `path` VARCHAR( 200 ) NOT NULL default '', `filename` VARCHAR( 200 ) NOT NULL default '', `hits` BIGINT( 20 ) NOT NULL default '0', `width` SMALLINT( 6 ) NOT NULL default '0', `height` SMALLINT( 6 ) NOT NULL default '0', `pic_date` DATETIME NOT NULL, `caption` TEXT NOT NULL, `level` VARCHAR( 2 ) NOT NULL default '0', PRIMARY KEY (`pid`) );"; dbDelta($sql); } $column_name = 'comment_pid_ID'; $create_ddl = "ALTER TABLE `".$wpdb->comments."` ADD `".$column_name."` VARCHAR( 20 ) NOT NULL DEFAULT '';"; maybe_add_column($wpdb->comments, $column_name, $create_ddl); if (get_option('aniga_base-id') == '') { $post_author = 1; $post_content = 'Photo gallery'; $post_title = 'photography'; $post_date = gmdate('Y-m-d H:i:s'); $post_date_gmt = gmdate('Y-m-d H:i:s'); $post_category = 1; $post_status = 'publish'; $comment_status = 'closed'; $ping_status = 'closed'; $post_parent = 0; $post_type = 'page'; $page_template = 'gallery-index.php'; $post_data = compact('post_content','post_title','post_date','post_date_gmt','post_author','post_category', 'post_status', 'comment_status', 'ping_status', 'post_status', 'post_parent', 'post_type', 'page_template'); $post_data = add_magic_quotes($post_data); $post_ID = wp_insert_post($post_data); add_option('aniga_base-id', $post_ID, 'base wp ID for ANIga'); } $urlpath = get_bloginfo('url'); add_option('aniga_dirpath', $urlpath.'/wp-content/gallery/', 'dir path'); $abspath = str_replace("\\", "/", ABSPATH); add_option('aniga_abspath', $abspath.'wp-content/gallery/', 'absolute path'); add_option('aniga_thumb_size', '100', 'max Thumbnail size'); add_option('aniga_thumb_csize', '150', 'max Thumbnail size'); add_option('aniga_thumb_square', 'yes', 'Create square thumbnails'); add_option('aniga_caimg_size', '100', 'max Cat/Alb size'); add_option('aniga_norm_size', '400', 'max normal Image size'); add_option('aniga_resize', 'yes', 'resize Images'); add_option('aniga_resize_qual', '100', 'resize Quality'); add_option('aniga_thumb_reflection', 'yes', 'create an Apple like reflection on thumbnails'); add_option('aniga_thumb_reflection_b', 'a4a4a4', 'border for reflection'); add_option('aniga_rolemgr', 'no', 'Use Role Manager Plugin'); add_option('aniga_colums', '3', 'colums in thumbnail page'); add_option('aniga_css', 'yes', 'external CSS style'); add_option('aniga_slds_prefetch', '12', 'ANIga slideshow prefetch'); add_option('aniga_slds_time', '4000', 'ANIga slideshow time'); add_option('aniga_slds_filter', 'no', 'ANIga slideshow filter'); add_option('aniga_delete', 'yes', 'ANIga delete pictures from filesystem'); add_option('aniga_trackback_sent', 'no', 'ANIga trackback sent'); add_option('aniga_img_mode', 'link', 'ANIga Picture link mode'); add_option('aniga_img_sort', 'filename', 'Picture sort mode'); add_option('aniga_img_order', 'ASC', 'Picture order mode'); if (ini_get('safe_mode') || ini_get('safe_mode') == 'on') $zip_mode = "none"; else { if (function_exists('zip_open')) { $zip_mode = "zip"; } else { if (function_exists('exec')) { $zip_mode = "mzip"; } else { $zip_mode = "mzipx"; } } } add_option('aniga_zip_mode', $zip_mode, 'zip mode'); } add_action('activate_aniga_gallery.php','aniga_install'); load_plugin_textdomain('aniga', 'wp-content/plugins/ANIga/language'); // load functions if needed //######################################################################## function aniga_start_gallery() { require_once("ANIga/functions.php"); } //adds the pid to comments for pictures //######################################################################## function aniga_comment_add_pid($comment_ID) { global $wpdb; $ppid = $_GET['pid']; if ($ppid != '') $dopid = $wpdb->query("UPDATE $wpdb->comments SET comment_pid_ID = '$ppid' WHERE comment_ID = '$comment_ID' LIMIT 1"); return $comment_ID; } add_action('comment_post','aniga_comment_add_pid'); add_action('trackback_post','aniga_comment_add_pid'); add_action('pingback_post','aniga_comment_add_pid'); // adds the gallery-css link to the HEAD and the javascript code // to slideshow pages //######################################################################## function aniga_add_css() { ?> ID; $pagestruct = $wp_rewrite->get_page_permastruct(); if ( !$nav ) $do_nav = ''; else $do_nav = '#picture_nav'; if ( '' != $pagestruct ) { $link = get_page_uri($id); $link = str_replace('%pagename%', $link, $pagestruct); $link = get_settings('home') . "/".$link."/?".$do."=".$go_id.$do_nav; } else { $link = get_settings('home') . "/?page_id=".$id."&".$do."=".$go_id.$do_nav; //maybe the '&' will get screwed up? } return apply_filters('page_link', $link, $id); } function aniga_get_userinfo() { global $userdata; get_currentuserinfo(); if ($userdata->user_level == '') $user = 0; else $user = $userdata->user_level; return $user; } //RANDOM IMAGE FUNCTION //######################################################################## function aniga_show_rand_img($before = '

', $after = '

', $limit = 3) { //show random images on the sidebar with one random comment (if there is one for this picture) global $wpdb; $i=1; $level = aniga_get_userinfo(); $rand_img_req = "SELECT pid, path, filename, parent_id FROM $wpdb->aniga_pic WHERE level <= $level ORDER BY RAND() LIMIT $limit"; $rand_img_ret = $wpdb->get_results($rand_img_req); if ($rand_img_ret) { foreach ($rand_img_ret as $rand_img) { $rand_com_req = "SELECT comment_ID, comment_content FROM $wpdb->comments WHERE comment_pid_ID=$rand_img->pid ORDER BY RAND() LIMIT 1"; $rand_com_ret = $wpdb->get_results($rand_com_req); if ($wpdb->num_rows == 1 ) { foreach ($rand_com_ret as $rand_com) { $com_lenth = 7; $com_trans = array("
" => " "); $com_content_br = strtr($rand_com->comment_content, $com_trans); $com_content = strip_tags($com_content_br); $com_content = stripslashes($com_content); $com_words=split(" ",$com_content); $com_excerpt_long = join(" ",array_slice($com_words,0,$com_lenth)); $com_excerpt = wordwrap($com_excerpt_long, 25, "\n", 1); if ($com_excerpt == "") $com_excerpt = "[...]"; else $com_excerpt = '"' . $com_excerpt . '"'; } } //else $com_excerpt = __('no comments', 'aniga'); //if you want "no comments" below picture else $com_excerpt =''; //if you dont want any text below picture if therre is no commment.. echo $before; ?> <?php _e('Random Picture', 'aniga')?> without:
*/ ?>
', $after = '

', $limit = 3) { global $wpdb; $i=1; $level = aniga_get_userinfo(); $rand_img_req = "SELECT pid, path, filename, parent_id FROM $wpdb->aniga_pic WHERE level <= $level ORDER BY RAND() LIMIT $limit"; $rand_img_ret = $wpdb->get_results($rand_img_req); if ($rand_img_ret) { foreach ($rand_img_ret as $rand_img) { echo $before; ?> <?php _e('Random Picture', 'aniga')?> ', $after = '', $show_pass_post = false) { // based on the recent_comments plugin. global $wpdb; // this query does not show comments for pictures wirh higher Level, but is really slow, when there are thousends of pics :( /* $level = aniga_get_userinfo(); $request = "SELECT DISTINCT $wpdb->posts.ID, $wpdb->comments.comment_ID, $wpdb->comments.comment_content, $wpdb->comments.comment_author, $wpdb->comments.comment_author_url, $wpdb->posts.post_title, $wpdb->comments.comment_pid_ID "; $request .= "FROM $wpdb->comments, $wpdb->posts, $wpdb->anigal_pic "; $request .= "WHERE $wpdb->posts.ID = $wpdb->comments.comment_post_ID "; $request .= "AND $wpdb->posts.post_status IN ('publish','static') "; if(!$show_pass_post) $request .= "AND $wpdb->posts.post_password = '' "; $request .= "AND ($wpdb->comments.comment_pid_ID = '' OR $wpdb->comments.comment_pid_ID IS NULL OR ($wpdb->comments.comment_pid_ID = $wpdb->anigal_pic.pid AND $wpdb->anigal_pic.level <= $level)) "; $request .= "AND $wpdb->comments.comment_approved = '1' "; $request .= "ORDER BY $wpdb->comments.comment_ID DESC LIMIT $no_comments";*/ $request = "SELECT ID, comment_ID, comment_content, comment_author, comment_author_url, post_title, comment_pid_ID FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID WHERE post_status IN ('publish','static') "; if(!$show_pass_post) $request .= "AND post_password ='' "; $request .= "AND comment_approved = '1' ORDER BY comment_ID DESC LIMIT $no_comments"; $comments = $wpdb->get_results($request); $comments = $wpdb->get_results($request); if ($comments) { foreach ($comments as $comment) { $comment_author = stripslashes($comment->comment_author); if ($comment_author == "") $comment_author = "anonymous"; $trans = array("
" => " "); $comment_content_br = strtr($comment->comment_content, $trans); $comment_content = strip_tags($comment_content_br); $comment_content = stripslashes($comment_content); $words=split(" ",$comment_content); $comment_excerpt_long = join(" ",array_slice($words,0,$comment_lenth)); $comment_excerpt = wordwrap($comment_excerpt_long, 50, "\n", 1); if ($comment_excerpt == "") $comment_excerpt = "[...]"; $comment_excerpt = convert_smilies($comment_excerpt); if (!empty($comment->comment_pid_ID)) $permalink = aniga_get_permalink($comment->ID, $comment->comment_pid_ID, 'pid', false); else $permalink = get_permalink($comment->ID); $permalink = $permalink."#comment-".$comment->comment_ID; $url = $comment->comment_author_url; echo $before; if (empty($url)) { echo $comment_author; } else { ?> : ', $after = '', $limit = 3) { global $wpdb; $level = aniga_get_userinfo(); $last_pic_req = "SELECT pid, parent_id, filename FROM $wpdb->aniga_pic WHERE level <= $level ORDER BY pic_date DESC LIMIT $limit"; $last_pic_ret = $wpdb->get_results($last_pic_req); if ($last_pic_ret) { foreach ($last_pic_ret as $last_pic) { echo $before; ?> filename; ?> ', $after = '', $limit = 3) { global $wpdb; $level = aniga_get_userinfo(); $last_gal_req = "SELECT id, name FROM $wpdb->aniga_alb WHERE level <= $level ORDER BY id DESC LIMIT 3"; $last_gal_ret = $wpdb->get_results($last_gal_req); if ($last_gal_ret) { foreach ($last_gal_ret as $last_gal) { echo $before; ?> name; ?>