/** * Plugin Name: Auto Add Favorites * Plugin Description: Subscribe to thread whenever you have posted a comment * Author: Olaf Lederer * Author URI: http://www.finalwebsites.com/portal * Plugin URI: http://www.finalwebsites.com/bbpress/auto-add-member-favorites.php * Version: 1.0 */ function auto_add_favorit() { global $topic_id, $bb_current_user; if (!empty($bb_current_user->data->auto_add_favorit)) { if (!empty($_POST['add_to_my_favorites'])) { if (is_user_favorite($bb_current_user->ID, $topic_id)) { return; } else { bb_add_user_favorite($bb_current_user->ID, $topic_id); return; } } else { return; } } else { return; } }
case 'dim-favorite': $user_id = bb_get_current_user_info('id'); if (!($topic = get_topic($id))) { die('0'); } if (!bb_current_user_can('edit_favorites_of', $user_id)) { die('-1'); } bb_check_ajax_referer("toggle-favorite_{$topic->topic_id}"); $is_fav = is_user_favorite($user_id, $topic->topic_id); if (1 == $is_fav) { if (bb_remove_user_favorite($user_id, $topic->topic_id)) { die('1'); } } elseif (false === $is_fav) { if (bb_add_user_favorite($user_id, $topic->topic_id)) { die('1'); } } break; case 'delete-post': // $id is post_id if (!bb_current_user_can('delete_post', $id)) { die('-1'); } bb_check_ajax_referer("delete-post_{$id}"); $status = (int) $_POST['status']; if (!($bb_post = bb_get_post($id))) { die('0'); } if ($status == $bb_post->post_status) {
require_once './bb-load.php'; if (isset($_GET['fav']) && isset($_GET['topic_id'])) { bb_auth('logged_in'); if (!bb_current_user_can('edit_favorites_of', $user_id)) { bb_die(__('You cannot edit those favorites. How did you get here?')); } $fav = (int) $_GET['fav']; $topic_id = (int) $_GET['topic_id']; bb_check_admin_referer('toggle-favorite_' . $topic_id); $topic = get_topic($topic_id); if (!$topic || 0 != $topic->topic_status) { exit; } if ($fav) { bb_add_user_favorite($user_id, $topic_id); } else { bb_remove_user_favorite($user_id, $topic_id); } $ref = wp_get_referer(); if (false !== strpos($ref, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT))) { bb_safe_redirect($ref); } else { wp_redirect(get_topic_link($topic_id)); } exit; } if (!bb_is_profile()) { $sendto = get_profile_tab_link($user->ID, 'favorites'); wp_redirect($sendto); exit;