query("DELETE FROM ".$table_prefix."forum_usergroups WHERE id = {$delete_usrgrp[$i]}"); $wpdb->query("DELETE FROM ".$table_prefix."forum_usergroup2user WHERE `group` = {$delete_usrgrp[$i]}"); } } return true; } return false; } function add_usergroup(){ if(isset($_GET['do']) && $_GET['do'] == "addusergroup" && !isset($_POST['add_usergroup'])){ include("wpf-add-usergroup.php"); return false; } global $wpdb, $table_prefix; $name = isset($_POST['group_name'])?$wpdb->escape($_POST['group_name']):""; $desc = isset($_POST['group_description'])?$wpdb->escape($_POST['group_description']):""; if (isset($_POST['add_usergroup'])){ if($_POST['group_name'] == null || $_POST['group_name'] == "") return __("You must specify a user group name.", "mingleforum"); else if($wpdb->get_var("SELECT id FROM ".$table_prefix."forum_usergroups WHERE name = '$name'")) return __("You have choosen a name that already exists in the database, please specify another", "mingleforum"); $wpdb->query("INSERT INTO ".$table_prefix."forum_usergroups (name, description) VALUES('$name', '$desc')"); return __("User Group successfully added.", "mingleforum"); } return false; } function add_user_togroup(){ global $wpdb, $table_prefix, $mingleforum; if(isset($_GET['do']) && $_GET['do'] == "add_user_togroup" && !isset($_POST['add_user_togroup'])){ include("wpf-addusers.php"); return false; } $warnings = 0; $errors = 0; $added = 0; if (isset($_POST['add_user_togroup'])){ $users = explode(",", $_POST['togroupusers']); if($_POST['togroupusers'] == ""){ return __("You haven't specified any user to add:", "mingleforum"); } $group = (is_numeric($_POST['usergroup']))?$_POST['usergroup']:"add_user_null"; if($group == "add_user_null") return __("You must choose a user group", "mingleforum"); foreach($users as $user){ if($user){ trim($user); $id = username_exists($user); if(!$id){ $user = htmlentities($user, ENT_QUOTES); $msg = "".__("Error", "mingleforum")." - ".__("No such user:", "mingleforum")." \"{$user}\"
"; ++$errors; } elseif($mingleforum->is_user_ingroup($id, $group)){ $user = htmlentities($user, ENT_QUOTES); $msg = "".__("Warning", "mingleforum")." - ".__("User", "mingleforum")." \"{$user}\" ".__("is already in this group", "mingleforum")."
"; ++$warnings; } else{ $user = htmlentities($user, ENT_QUOTES); $msg = __("User", "mingleforum")." \"{$user}\" ".__("added successfully", "mingleforum")."
"; $sql = "INSERT INTO ".$table_prefix."forum_usergroup2user (user_id, `group`) VALUES('$id', '$group')"; $wpdb->query($sql); ++$added; } } } return __("Errors:","mingleforum")." $errors, ".__("Warnings:", "mingleforum")." $warnings, ".__("Users added:", "mingleforum")." $added
-------------------------------
$msg"; } return false; } function usergroups(){ global $wpdb, $mingleforum, $table_prefix; echo "
"; if($this->delete_usergroups()) echo '

' . __('User Group(s) successfully deleted.', 'mingleforum') . '

'; if($msg = $this->add_usergroup()) echo "

$msg

"; if($msg = $this->add_user_togroup()) echo "

$msg

"; if(isset($_GET['do']) && $_GET['do'] == "removemember" && is_numeric($_GET['memberid']) && is_numeric($_GET['groupid'])){ $wpdb->query("DELETE FROM ".$table_prefix."forum_usergroup2user WHERE user_id = {$_GET['memberid']} AND `group` = {$_GET['groupid']}"); echo "

" . __("Member successfully removed.", "mingleforum") . "

"; } if(isset($_GET['do']) && $_GET['do'] == "edit_usergroup"){ include("wpf-usergroup-edit.php"); } $image = WPFURL."images/user.png"; echo "

".__("Mingle Forum >> Manage User Groups", "mingleforum")." ".__("add new", "mingleforum")."

"; $usergroups = $mingleforum->get_usergroups(); /*****************************************/ if($usergroups){ echo "
"; echo "


"; foreach($usergroups as $usergroup){ echo ""; $members = $mingleforum->get_members($usergroup->id); if($members){ echo ""; } else{ echo ""; echo ""; } echo "
".stripslashes($usergroup->name)." ".stripslashes($usergroup->description)."
"; foreach($members as $member){ $user = get_userdata($member->user_id); echo ""; } echo "
".__("Members", "mingleforum")." Name Info
".$user->user_login." (".__("Remove", "mingleforum").") ".get_user_meta($member->user_id, "first_name", true)." ".get_user_meta($member->user_id, "last_name", true)." ".__("View profile", "mingleforum")."
".__("Add members", "mingleforum")."
". __("No members in this group", "mingleforum")."
".__("Add members", "mingleforum")."


"; } echo "
"; } echo "
"; } function activate_skin(){ if (isset($_GET['action']) && $_GET['action'] == "activateskin"){ $op = get_option('mingleforum_options'); $options = array( 'wp_posts_to_forum' => $op['wp_posts_to_forum'], 'forum_posts_per_page' => $op['forum_posts_per_page'], 'forum_threads_per_page' => $op['forum_threads_per_page'], 'forum_require_registration' => $op['forum_require_registration'], 'forum_show_login_form' => $op['forum_show_login_form'], 'forum_date_format' => $op['forum_date_format'], 'forum_use_gravatar' => $op['forum_use_gravatar'], 'forum_show_bio' => $op['forum_show_bio'], 'forum_skin' => $_GET['skin'], 'forum_use_rss' => $op['forum_use_rss'], 'forum_use_seo_friendly_urls' => $op['forum_use_seo_friendly_urls'], 'forum_allow_image_uploads' => $op['forum_allow_image_uploads'], 'notify_admin_on_new_posts' => $op['notify_admin_on_new_posts'], 'set_sort' => $op['set_sort'], 'forum_use_spam' => $op['forum_use_spam'], 'forum_use_bbcode' => $op['forum_use_bbcode'], 'forum_captcha' => $op['forum_captcha'], 'hot_topic' => $op['hot_topic'], 'veryhot_topic' => $op['veryhot_topic'], 'forum_display_name' => $op['forum_display_name'], 'level_one' => $op['level_one'], 'level_two' => $op['level_two'], 'level_three' => $op['level_three'], 'level_newb_name' => $op['level_newb_name'], 'level_one_name' => $op['level_one_name'], 'level_two_name' => $op['level_two_name'], 'level_three_name' => $op['level_three_name'], 'forum_db_version' => $op['forum_db_version'], 'forum_disabled_cats' => $op['forum_disabled_cats'], 'allow_user_replies_locked_cats' => $op['allow_user_replies_locked_cats'], 'forum_posting_time_limit' => $op['forum_posting_time_limit'], 'forum_hide_branding' => $op['forum_hide_branding'], 'forum_last_posts' => $op['forum_last_posts'] ); update_option('mingleforum_options', $options); return true; } return false; } function skins(){ $class = ""; // Find all skins within directory // Open a known directory, and proceed to read its contents if($this->activate_skin()) echo '

' . __('Skin successfully activated.', 'mingleforum') . '

'; $op = get_option('mingleforum_options'); if (is_dir(SKINDIR)) { if ($dh = opendir(SKINDIR)) { $image = WPFURL."images/logomain.png"; echo "

".__("Mingle Forum >> Skin options", "mingleforum")."


".__("Get More Skins", "mingleforum")."

"; while (($file = readdir($dh)) !== false) { if(filetype(SKINDIR . $file) == "dir" && $file != ".." && $file != "." && substr($file, 0, 1) != "."){ $p = file_get_contents(SKINDIR.$file."/style.css"); $class = ($class == "alternate")?"":"alternate"; echo ""; if($op['forum_skin'] == $file) echo ""; else echo ""; } } } } echo "
".__("Screenshot", "mingleforum")." ".__("Name", "mingleforum")." ".__("Version", "mingleforum")." ".__("Description", "mingleforum")." ".__("Action", "mingleforum")."
".$this->get_skinscreenshot($file)." ".$this->get_skinmeta('Name', $p)." ".$this->get_skinmeta('Version', $p)." ".$this->get_skinmeta('Description', $p)."".__("In Use", "mingleforum")."
".__("Activate", "mingleforum")."
"; } // PNG | JPG | GIF | only function get_skinscreenshot($file){ $exts = array("png", "jpg", "gif"); foreach($exts as $ext){ if(file_exists(SKINDIR."$file/screenshot.$ext")){ $image = SKINURL."$file/screenshot.$ext"; return ""; } } return ""; } function get_skinmeta($field, $data){ $match = ''; if (preg_match("|$field:(.*)|i", $data, $match)) { $match = $match[1]; } return $match; } function about(){ $image = WPFURL."images/logomain.png"; echo "

".__("About Mingle Forum", "mingleforum")."

".__("Current Version: ", "mingleforum")."".$this->get_version()."

".__("Mingle Forum has one simple mission; to 'KEEP IT SIMPLE!' It was taken over from WP Forum and has been improved upon GREATLY. It now fully supports integration with or without the Mingle plugin (by Blair Williams). Also I want to give a big thanks to Eric Hamby for his previous work on the forum script.", "mingleforum")."

"; } function get_usercount(){ global $wpdb, $table_prefix; return $wpdb->get_var("SELECT count(*) from ".$table_prefix."users"); } function get_dbsize(){ global $wpdb; $size = ''; $res = $wpdb->get_results("SHOW TABLE STATUS"); foreach($res as $r) $size += $r->Data_length + $r->Index_length; return $this->formatfilesize($size); } function formatfilesize( $data ) { // bytes if( $data < 1024 ) { return $data . " bytes"; } // kilobytes else if( $data < 1024000 ) { return round( ( $data / 1024 ), 1 ) . "k"; } // megabytes else { return round( ( $data / 1024000 ), 1 ) . " MB"; } } function get_version(){ $plugin_data = implode('', file(ABSPATH."wp-content/plugins/".WPFPLUGIN."/wpf-main.php")); $version = ''; if (preg_match("|Version:(.*)|i", $plugin_data, $version)) { $version = $version[1]; } return $version; } function options(){ if ($this->option_save()) echo '

' . __('Options successfully saved.', 'mingleforum') . '

'; global $mingleforum; $op = get_option('mingleforum_options'); $image = WPFURL."images/chart.png"; echo '

'.__("Mingle Forum", "mingleforum").'


'.__("Statistic", "mingleforum").' '.__("Value", "mingleforum").'
'.__("Number of posts:", "mingleforum").' '.$mingleforum->num_posts_total().'
'.__("Number of threads:", "mingleforum").' '.$mingleforum->num_threads_total().'
'.__("Number of users:", "mingleforum").' '.$this->get_usercount().'
'.__("Total database size:", "mingleforum").' '.$this->get_dbsize().'
'.__("Database server:", "mingleforum").' '.mysql_get_server_info().'
'.__("Mingle Forum version:", "mingleforum").' '.$this->get_version().'
'; $image = WPFURL."images/logomain.png"; echo '

'.__("Mingle Forum >> General Options", "mingleforum").'

'; echo '
'; if (function_exists('wp_nonce_field')) wp_nonce_field('mingleforum-manage_option'); $defStr = __("default ", "mingleforum"); echo ""; if (function_exists("gd_info")){ $gd = gd_info(); $status = ""; $lib = "
".__("Installed version:", "mingleforum")." {$gd['GD Version']}"; } else { $status = "disabled"; $lib = "
".__("GD Library is not installed", "mingleforum").""; } echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
".__("Option Name", "mingleforum")." ".__("Option Input", "mingleforum")."
".__("Integrate WordPress Posts with Forum:", "mingleforum")." ($defStr = ".__('Off', 'mingleforum').")
".__("Posts per page:", "mingleforum")." ($defStr = 10)
".__("Threads per page:", "mingleforum")." ($defStr = 20)
".__("Number of posts for Hot Topic:", "mingleforum")." ($defStr = 15)
".__("Number of posts for Very Hot Topic:", "mingleforum")." ($defStr = 25)
".__("Username Display:", "mingleforum")." ($defStr = user_login)
".__("New User's Title:", "mingleforum")." ($defStr = ".__('Newbie', 'mingleforum').")
".__("User Level 1 Title:", "mingleforum")." ($defStr = ".__('Beginner', 'mingleforum').")
".__("User Level 1 Count:", "mingleforum")." ($defStr = ".__('25', 'mingleforum').")
".__("User Level 2 Title:", "mingleforum")." ($defStr = ".__('Advanced', 'mingleforum').")
".__("User Level 2 Count:", "mingleforum")." ($defStr = ".__('50', 'mingleforum').")
".__("User Level 3 Title:", "mingleforum")." ($defStr = ".__('Pro', 'mingleforum').")
".__("User Level 3 Count:", "mingleforum")." ($defStr = ".__('100', 'mingleforum').")
".__("Notify Admin on new posts:", "mingleforum")." ($defStr = ".__('Off', 'mingleforum').")
".__("Show Forum Login Form:", "mingleforum")." ($defStr = ".__('On', 'mingleforum').")
".__("Show Avatars in the forum:", "mingleforum")." ($defStr = ".__('On', 'mingleforum').")
".__("Allow Images to be uploaded:", "mingleforum")." ($defStr = ".__('Off', 'mingleforum').")
".__("Show users Signature at the bottom of posts:", "mingleforum")." ($defStr = ".__('On', 'mingleforum').")
".__("Use Forum RSS:", "mingleforum")." ($defStr = ".__('On', 'mingleforum').")
".__("Use SEO friendly URLs:", "mingleforum")."
".__("IMPORTANT: Leave this option off if your permalinks are set to 'default'", "mingleforum")."
($defStr = ".__('Off', 'mingleforum').")
".__("Registration required to post:", "mingleforum")." ($defStr = ".__('On', 'mingleforum').")
".__("Use Captcha for unregistered users:", "mingleforum")." (".__("Requires ", "mingleforum")."GD library - ".__("If you have 'Registration required to post' above enabled, leave this off", "mingleforum").") $lib
".__("Date format:", "mingleforum")."

".__("Default date:", "mingleforum")." \"F j, Y, H:i\".
".__("Check ", "mingleforum")."http://www.php.net ".__("for date formatting.", "mingleforum")."

" .__("Closed Categories (Admin posting only):", "mingleforum")."
".__("Comma separated list of Category ID's (Ex: 1, 2, 3)", "mingleforum")."
".__("Users can reply in locked categories", "mingleforum")." ($defStr = ".__('Off', 'mingleforum').")
".__("Time limit between posting:", "mingleforum")."
".__("Prevent lots of SPAM by making users wait a time period between posts.", "mingleforum")."
".__('seconds', 'mingleforum')."
".__("Number of last posts on home:", "mingleforum")."
".__("0 to disable", "mingleforum")."
".__("Disable Branding:", "mingleforum")." ($defStr = ".__('Off', 'mingleforum').")
cartpauj.com
"; } function option_save(){ if (isset($_POST['mingleforum_option_save'])) { $op = get_option('mingleforum_options'); global $wpdb; $options = array( 'wp_posts_to_forum' => $_POST['wp_posts_to_forum'], 'forum_posts_per_page' => $wpdb->escape($_POST['forum_posts_per_page']), 'forum_threads_per_page' => $wpdb->escape($_POST['forum_threads_per_page']), 'forum_require_registration' => $_POST['forum_require_registration'], 'forum_show_login_form' => $_POST['forum_show_login_form'], 'forum_date_format' => $wpdb->escape($_POST['forum_date_format']), 'forum_use_gravatar' => $_POST['forum_use_gravatar'], 'forum_show_bio' => $_POST['forum_show_bio'], 'forum_skin' => $op['forum_skin'], 'forum_use_rss' => $_POST['forum_use_rss'], 'forum_use_seo_friendly_urls' => $_POST['forum_use_seo_friendly_urls'], 'forum_allow_image_uploads' => $_POST['forum_allow_image_uploads'], 'notify_admin_on_new_posts' => $_POST['notify_admin_on_new_posts'], 'set_sort' => $op['set_sort'], 'forum_use_spam' => $_POST['forum_use_spam'], 'forum_use_bbcode' => $_POST['forum_use_bbcode'], 'forum_captcha' => $_POST['forum_captcha'], 'hot_topic' => $wpdb->escape($_POST['hot_topic']), 'veryhot_topic' => $wpdb->escape($_POST['veryhot_topic']), 'forum_display_name' => $_POST['forum_display_name'], 'level_one' => $wpdb->escape($_POST['level_one']), 'level_two' => $wpdb->escape($_POST['level_two']), 'level_three' => $wpdb->escape($_POST['level_three']), 'level_newb_name' => $wpdb->escape($_POST['level_newb_name']), 'level_one_name' => $wpdb->escape($_POST['level_one_name']), 'level_two_name' => $wpdb->escape($_POST['level_two_name']), 'level_three_name' => $wpdb->escape($_POST['level_three_name']), 'forum_db_version' => $op['forum_db_version'], 'forum_disabled_cats' => explode(",",$wpdb->escape($_POST['forum_disabled_cats'])), 'allow_user_replies_locked_cats' => $_POST['allow_user_replies_locked_cats'], 'forum_posting_time_limit' => $wpdb->escape($_POST['forum_posting_time_limit']), 'forum_hide_branding' => $_POST['forum_hide_branding'], 'forum_last_posts' => $wpdb->escape($_POST['forum_last_posts']) ); update_option('mingleforum_options', $options); return true; } return false; } function delete_forum_group(){ if(isset($_POST['delete_forum_groups'])){ global $wpdb, $table_prefix; $msg = ""; $table_forums = $table_prefix."forum_forums"; $table_threads = $table_prefix."forum_threads"; $table_posts = $table_prefix."forum_posts"; $thread_count = 0; $post_count = 0; $forum_count = 0; $groups = $_POST['delete_groups']; $group_num = count($groups); // Delete marked groups for($i = 0; $i < $group_num; $i++){ // Get all forums $forumsb = $wpdb->get_results("select id from $table_forums where parent_id = {$groups[$i]}"); // Loop trough the forums foreach($forumsb as $forum){ // Get all threads $threads = $wpdb->get_results("select id from $table_threads where parent_id = $forum->id"); // Delete threads $thread_count += $wpdb->query("DELETE FROM $table_threads WHERE parent_id = $forum->id"); // Loop through the threads foreach($threads as $thread){ // Delete posts $post_count += $wpdb->query("DELETE FROM $table_posts WHERE parent_id = $thread->id"); } // Delete forums $forum_count += $wpdb->query("DELETE FROM $table_forums WHERE parent_id = {$groups[$i]}"); } // Delete the group $forum_count += $wpdb->query("DELETE FROM $table_forums WHERE id = {$groups[$i]}"); } $msg .= __("Forums deleted:", "mingleforum")." ".$forum_count."
" .__("Threads deleted:", "mingleforum")." ".$thread_count."
" .__("Posts deleted:", "mingleforum")." ".$post_count."
"; return $msg; } return false; } function edit_forum_group(){ if(isset($_GET['do']) && $_GET['do'] == "editgroup"){ include("wpf-edit-forum-group.php"); } } function add_group(){ if(isset($_POST['add_group_submit'])){ global $wpdb, $table_prefix; $add_group_description = $wpdb->escape($_POST['add_group_description']); $add_group_name = $wpdb->escape($_POST['add_group_name']); if($add_group_name == "") return __("You must enter a name", "mingleforum"); if($wpdb->get_var("SELECT id FROM ".$table_prefix."forum_forums WHERE name = '$add_group_name'")) return __("You have choosen a name that already exists in the database, please specify another", "mingleforum"); $max = $wpdb->get_var("SELECT MAX(sort) from ".$table_prefix."forum_forums") + 1; $wpdb->query("INSERT INTO ".$table_prefix."forum_forums (name, description, sort) VALUES('$add_group_name', '$add_group_description', '$max')"); return __("Category added successfully", "mingleforum"); } return false; } function add_forum(){ if(isset($_POST['add_forum_submit'])){ global $wpdb, $table_prefix; $add_forum_description = $wpdb->escape(strip_tags($_POST['add_forum_description'])); $add_forum_name = $wpdb->escape(strip_tags($_POST['add_forum_name'])); $add_forum_group_id = $wpdb->escape($_POST['add_forum_group_id']); if($_POST['add_forum_group_id'] == "add_forum_null") return __("You must select a category", "mingleforum"); if($_POST['add_forum_name'] == "") return __("You must enter a name", "mingleforum"); if($wpdb->get_var("select id from ".$table_prefix."forum_forums where name = '$add_forum_name' and parent_id = $add_forum_group_id")) return __("You have choosen a forum name that already exists in this group, please specify another", "mingleforum"); $max = $wpdb->get_var("SELECT MAX(sort) from ".$table_prefix."forum_forums WHERE parent_id = $add_forum_group_id") + 1; $wpdb->query("INSERT INTO ".$table_prefix."forum_forums (name, description, parent_id, sort) VALUES('$add_forum_name', '$add_forum_description', '$add_forum_group_id', '$max')"); return __("Forum added successfully", "mingleforum"); } return false; } function subforums($forumid, $level = 0) { global $mingleforum; $forums = $mingleforum->get_forums($forumid); if($forums){ foreach($forums as $forum){ $up_link = "admin.php?page=mfstructure&mingleforum_action=structure&do=forum_up&id=$forum->id"; $down_link = "admin.php?page=mfstructure&mingleforum_action=structure&do=forum_down&id=$forum->id"; $edit_link = "admin.php?page=mfstructure&mingleforum_action=structure&do=editgroup&groupid=$forum->id"; $sub_link = "admin.php?page=mfstructure&mingleforum_action=structure&do=addforum&groupid=$forum->id"; echo " "; for ($i = 0; $i < $level; $i++) { echo " -- "; } echo " -- ".stripslashes($forum->name)." | ".stripslashes($forum->description)." ".__("Modify", "mingleforum")." | ".__("Add forum", "mingleforum")." "; $this->subforums($forum->id, ++$level); $level = 0; } // foreach($forums as $forum) } // if($forums) } function structure(){ global $mingleforum; if($msg = $this->delete_forum_group()) echo "

$msg

"; if($msg = $this->move_up_down()) echo "

$msg

"; if($msg = $this->add_group()) echo "

$msg

"; if($msg = $this->add_forum()) echo "

$msg

"; if(isset($_GET['do']) && $_GET['do'] == "addforum") include('wpf-add-forum.php'); // Check if group/forum update is nessesrary $image = WPFURL."images/table.png"; $this->edit_forum_group(); echo "
"; echo "

".__("Mingle Forum >> Categories and Forums ", "mingleforum")."

"; $groups = $mingleforum->get_forums(); echo "".__("add new", "mingleforum").""; echo "
"; foreach($groups as $group){ $up_link = "admin.php?page=mfstructure&mingleforum_action=structure&do=group_up&id=$group->id"; $down_link = "admin.php?page=mfstructure&mingleforum_action=structure&do=group_down&id=$group->id"; $edit_link = "admin.php?page=mfstructure&mingleforum_action=structure&do=editgroup&groupid=$group->id"; echo ""; echo ""; $this->subforums($group->id); echo "
".stripslashes($group->name)." ".__("Modify", "mingleforum")." |
".__("Add forum", "mingleforum")."

"; } // foreach($groups as $group) echo "
"; } function move_up_down(){ global $wpdb, $table_prefix; $msg = ""; if(isset($_GET['do'], $_GET['id']) && is_numeric($_GET['id'])){ switch($_GET['do']){ /*------------------------------------------------------------------------------------------------------------------------*/ case "group_down": $ginfo = $wpdb->get_row("SELECT * FROM {$table_prefix}forum_forums WHERE id = '".($_GET['id']*1)."'", ARRAY_A); $above = $wpdb->get_row("SELECT * FROM {$table_prefix}forum_forums WHERE sort < '".$ginfo['sort']."' ORDER BY sort DESC", ARRAY_A); if ($above['id']>0){ $wpdb->query("UPDATE {$table_prefix}forum_forums SET sort = '".$above['sort']."' WHERE id = '".($_GET['id']*1)."'"); $wpdb->query("UPDATE {$table_prefix}forum_forums SET sort = '".$ginfo['sort']."' WHERE id = '".$above['id']."'"); } $msg = __("Group Moved Down", "mingleforum"); break; /*------------------------------------------------------------------------------------------------------------------------*/ case "forum_down": $ginfo = $wpdb->get_row("SELECT * FROM {$table_prefix}forum_forums WHERE id = '".($_GET['id']*1)."'", ARRAY_A); $above = $wpdb->get_row("SELECT * FROM {$table_prefix}forum_forums WHERE parent_id = '".$ginfo['parent_id']."' && sort < '".$ginfo['sort']."' ORDER BY sort DESC", ARRAY_A); if ($above['id']>0){ $wpdb->query("UPDATE {$table_prefix}forum_forums SET sort = '".$above['sort']."' WHERE id = '".($_GET['id']*1)."'"); $wpdb->query("UPDATE {$table_prefix}forum_forums SET sort = '".$ginfo['sort']."' WHERE id = '".$above['id']."'"); } $msg = __("Forum Moved Down", "mingleforum"); break; /*------------------------------------------------------------------------------------------------------------------------*/ case "group_up": $ginfo = $wpdb->get_row("SELECT * FROM {$table_prefix}forum_forums WHERE id = '".($_GET['id']*1)."'", ARRAY_A); $above = $wpdb->get_row("SELECT * FROM {$table_prefix}forum_forums WHERE sort > '".$ginfo['sort']."' ORDER BY sort ASC", ARRAY_A); if ($above['id']>0){ $wpdb->query("UPDATE {$table_prefix}forum_forums SET sort = '".$above['sort']."' WHERE id = '".($_GET['id']*1)."'"); $wpdb->query("UPDATE {$table_prefix}forum_forums SET sort = '".$ginfo['sort']."' WHERE id = '".$above['id']."'"); } $msg = __("Group Moved Up", "mingleforum"); break; /*------------------------------------------------------------------------------------------------------------------------*/ case "forum_up": $ginfo = $wpdb->get_row("SELECT * FROM {$table_prefix}forum_forums WHERE id = '".($_GET['id']*1)."'", ARRAY_A); $above = $wpdb->get_row("SELECT * FROM {$table_prefix}forum_forums WHERE parent_id = '".$ginfo['parent_id']."' && sort > '".$ginfo['sort']."' ORDER BY sort ASC", ARRAY_A); if ($above['id']>0){ $wpdb->query("UPDATE {$table_prefix}forum_forums SET sort = '".$above['sort']."' WHERE id = '".($_GET['id']*1)."'"); $wpdb->query("UPDATE {$table_prefix}forum_forums SET sort = '".$ginfo['sort']."' WHERE id = '".$above['id']."'"); } $msg = __("Forum Moved Up", "mingleforum"); break; /*------------------------------------------------------------------------------------------------------------------------*/ } return $msg; } return false; } function update_usergroups($new_groups, $group_id){ global $wpdb, $table_prefix; $new_groups = maybe_serialize($new_groups); $wpdb->query("UPDATE ".$table_prefix."forum_forums SET usergroups = '$new_groups' WHERE id = $group_id"); } function update_usercanpost($new_groups, $group_id){ global $wpdb, $table_prefix; $new_groups = maybe_serialize($new_groups); $wpdb->query("UPDATE ".$table_prefix."forum_forums SET usercanpost = '$new_groups' WHERE id = $group_id"); } function get_usersgroups_with_access_to_group($groupid){ global $wpdb, $table_prefix; $string = $wpdb->get_var("select usergroups from ".$table_prefix."forum_forums where id = $groupid"); return maybe_unserialize( $string ); } function get_usersgroups_with_access_to_post($groupid){ global $wpdb, $table_prefix; $string = $wpdb->get_var("select usercanpost from ".$table_prefix."forum_forums where id = $groupid"); return maybe_unserialize( $string ); } function edit_moderator(){ if(isset($_POST['update_mod'])){ $forums = (isset($_POST['mod_forum_id']))?$_POST['mod_forum_id']:array(); $forums = maybe_unserialize($forums); $global = (isset($_POST['mod_global']))?true:false; $user_id = $_POST['update_mod_user_id']; if($global){ update_user_meta($user_id, "wpf_moderator", "mod_global"); } else update_user_meta($user_id, "wpf_moderator", $forums); if(empty($forums)) return __('Moderator successfully removed.', 'mingleforum'); else return __('Moderator successfully saved.', 'mingleforum'); } if(isset($_POST['delete_mod'])){ $user_id = $_POST['update_mod_user_id']; if(delete_user_meta($user_id, "wpf_moderator")) return __('Moderator successfully removed.', 'mingleforum'); else return __('Moderator NOT removed.', 'mingleforum'); } return false; } function add_moderator(){ if(isset($_POST['add_mod_submit'])){ $user_id = $_POST['addmod_user_id']; $forums = (isset($_POST['mod_forum_id']))?$_POST['mod_forum_id']:array(); $forums = maybe_unserialize($forums); $global = (isset($_POST['mod_global']))?true:false; if($user_id == "add_mod_null") return __("You must select a user", "mingleforum"); if($global){ update_user_meta($user_id, "wpf_moderator", "mod_global"); return __("Global Moderator added successfully", "mingleforum"); } else update_user_meta($user_id, "wpf_moderator", $forums); return __("Moderator added successfully", "mingleforum"); } return false; } function moderators(){ global $mingleforum; $groups = $mingleforum->get_forums(); if($msg = $this->edit_moderator()) echo "

$msg

"; if($msg = $this->add_moderator()) echo "

$msg

"; echo "
"; if(isset($_GET['do']) && $_GET['do'] == "add_moderator"){ include('wpf-moderator.php'); } $mods = $mingleforum->get_moderators(); $image = WPFURL."images/user.png"; echo "

".__("Mingle Forum >> Manage Moderators", "mingleforum")." (".__("add new", "mingleforum").")

"; if($mods){ foreach($mods as $mod){ echo "
$mod->user_login ".__("Currently moderating", "mingleforum")."

"; if(get_user_meta($mod->user_id, "wpf_moderator", true) == "mod_global") $global_checked = "checked='checked'"; else $global_checked = ""; echo "

".__("Global moderator: (User can moderate all forums)", "mingleforum")."

"; foreach($groups as $group){ $forums = $mingleforum->get_forums($group->id); echo "

".stripslashes($group->name)."

"; foreach($forums as $forum){ if($mingleforum->is_moderator($mod->user_id, $forum->id)) $checked = "checked='checked'"; else $checked = ""; echo "

$forum->name

"; } } echo "

"; } } else echo "

".__("No moderators yet", "mingleforum")."

"; echo "
"; } function convert_moderators(){ global $wpdb; if(!get_option('wpf_mod_option_vers')){ $mods = $wpdb->get_results("SELECT user_id, user_login, meta_value FROM $wpdb->usermeta INNER JOIN $wpdb->users ON $wpdb->usermeta.user_id=$wpdb->users.ID WHERE meta_key = 'moderator' AND meta_value <> ''"); foreach($mods as $mod){ $string = explode(",", substr_replace($mod->meta_value, "", 0, 1)); update_user_meta($mod->user_id, 'wpf_moderator', maybe_serialize($string)); update_option('wpf_mod_option_vers', '2'); } } else echo "Moderators updated"; } function ads(){ global $mingleforum; $image = WPFURL."images/logomain.png"; if($this->save_mf_ads()) { ?>

> options", "mingleforum"); ?>

ads_options['mf_ad_above_forum_on']){echo 'checked="checked"';} ?> />

div.mf-ad-above-forum
ads_options['mf_ad_below_forum_on']){echo 'checked="checked"';} ?> />

div.mf-ad-below-forum
ads_options['mf_ad_above_branding_on']){echo 'checked="checked"';} ?> />

div.mf-ad-above-branding
ads_options['mf_ad_above_info_center_on']){echo 'checked="checked"';} ?> />

div.mf-ad-above-info-center
ads_options['mf_ad_above_breadcrumbs_on']){echo 'checked="checked"';} ?> />

div.mf-ad-above-breadcrumbs
ads_options['mf_ad_above_quick_reply_on']){echo 'checked="checked"';} ?> />

div.mf-ad-above-quick-reply
ads_options['mf_ad_below_first_post_on']){echo 'checked="checked"';} ?> />

div.mf-ad-below-first-post


ads_options = array( 'mf_ad_above_forum_on' => $_POST['mf_ad_above_forum_on'], 'mf_ad_above_forum' => $_POST['mf_ad_above_forum_text'], 'mf_ad_below_forum_on' => $_POST['mf_ad_below_forum_on'], 'mf_ad_below_forum' => $_POST['mf_ad_below_forum_text'], 'mf_ad_above_branding_on' => $_POST['mf_ad_above_branding_on'], 'mf_ad_above_branding' => $_POST['mf_ad_above_branding_text'], 'mf_ad_above_info_center_on' => $_POST['mf_ad_above_info_center_on'], 'mf_ad_above_info_center' => $_POST['mf_ad_above_info_center_text'], 'mf_ad_above_quick_reply_on' => $_POST['mf_ad_above_quick_reply_on'], 'mf_ad_above_quick_reply' => $_POST['mf_ad_above_quick_reply_text'], 'mf_ad_above_breadcrumbs_on' => $_POST['mf_ad_above_breadcrumbs_on'], 'mf_ad_above_breadcrumbs' => $_POST['mf_ad_above_breadcrumbs_text'], 'mf_ad_below_first_post_on' => $_POST['mf_ad_below_first_post_on'], 'mf_ad_below_first_post' => $_POST['mf_ad_below_first_post_text'], 'mf_ad_custom_css' => strip_tags($_POST['mf_ad_custom_css']) ); update_option('mingleforum_ads_options', $mingleforum->ads_options); return true; } return false; } }// End class