function ass_admin_notice() { if (bp_is_groups_component() && bp_is_current_action('admin') && bp_is_action_variable('notifications', 0)) { // Make sure the user is an admin if (!groups_is_user_admin(bp_loggedin_user_id(), bp_get_current_group_id()) && !is_super_admin()) { return; } if (get_option('ass-admin-can-send-email') == 'no') { return; } // make sure the correct form variables are here if (!isset($_POST['ass_admin_notice_send'])) { return; } if (empty($_POST['ass_admin_notice'])) { bp_core_add_message(__('The email notice was sent not sent. Please enter email content.', 'bp-ass'), 'error'); } else { $group = groups_get_current_group(); $group_id = $group->id; $group_name = bp_get_current_group_name(); $group_link = bp_get_group_permalink($group); if ($group->status != 'public') { $group_link = ass_get_login_redirect_url($group_link, 'admin_notice'); } $blogname = '[' . get_blog_option(BP_ROOT_BLOG, 'blogname') . ']'; $subject = $_POST['ass_admin_notice_subject']; $subject .= __(' - sent from the group ', 'bp-ass') . $group_name . ' ' . $blogname; $subject = apply_filters('ass_admin_notice_subject', $subject, $_POST['ass_admin_notice_subject'], $group_name, $blogname); $subject = ass_clean_subject($subject, false); $notice = apply_filters('ass_admin_notice_message', $_POST['ass_admin_notice']); $notice = ass_clean_content($notice); $message = sprintf(__('This is a notice from the group \'%s\': "%s" To view this group log in and follow the link below: %s --------------------- ', 'bp-ass'), $group_name, $notice, $group_link); $message .= __('Please note: admin notices are sent to everyone in the group and cannot be disabled. If you feel this service is being misused please speak to the website administrator.', 'bp-ass'); $user_ids = BP_Groups_Member::get_group_member_ids($group_id); // allow others to perform an action when this type of email is sent, like adding to the activity feed do_action('ass_admin_notice', $group_id, $subject, $notice); // cycle through all group members foreach ((array) $user_ids as $user_id) { $user = bp_core_get_core_userdata($user_id); // Get the details for the user if ($user->user_email) { wp_mail($user->user_email, $subject, $message); } // Send the email //echo '<br>Email: ' . $user->user_email; } bp_core_add_message(__('The email notice was sent successfully.', 'bp-ass')); //echo '<p>Subject: ' . $subject; //echo '<pre>'; print_r( $message ); echo '</pre>'; } bp_core_redirect(bp_get_group_permalink(groups_get_current_group()) . 'admin/notifications/'); } }
/** * Displays the introduction for the group and loops through each item * * I've chosen to cache on an individual-activity basis, instead of a group-by-group basis. This * requires just a touch more overhead (in terms of looping through individual activity_ids), and * doesn't really have any added effect at the moment (since an activity item can only be associated * with a single group). But it provides the greatest amount of flexibility going forward, both in * terms of the possibility that activity items could be associated with more than one group, and * the possibility that users within a single group would want more highly-filtered digests. */ function ass_digest_format_item_group($group_id, $activity_ids, $type, $group_name, $group_slug, $user_id) { global $bp, $ass_email_css; $group_permalink = apply_filters('bp_get_group_permalink', bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/' . $group_slug . '/'); $group_name_link = '<a href="' . $group_permalink . '" name="' . $group_slug . '">' . $group_name . '</a>'; $userdomain = ass_digest_get_user_domain($user_id); $unsubscribe_link = "{$userdomain}?bpass-action=unsubscribe&group={$group_id}&access_key=" . md5("{$group_id}{$user_id}unsubscribe" . wp_salt()); $gnotifications_link = ass_get_login_redirect_url($group_permalink . 'notifications/'); // add the group title bar if ($type == 'dig') { $group_message = "\n<div {$ass_email_css['group_title']}>" . sprintf(__('Group: %s', 'bp-ass'), $group_name_link) . "</div>\n\n"; } elseif ($type == 'sum') { $group_message = "\n<div {$ass_email_css['group_title']}>" . sprintf(__('Group: %s weekly summary', 'bp-ass'), $group_name_link) . "</div>\n"; } // add change email settings link $group_message .= "\n<div {$ass_email_css['change_email']}>"; $group_message .= __('To disable these notifications for this group click ', 'bp-ass') . " <a href=\"{$unsubscribe_link}\">" . __('unsubscribe', 'bp-ass') . '</a> - '; $group_message .= __('change ', 'bp-ass') . '<a href="' . $gnotifications_link . '">' . __('email options', 'bp-ass') . '</a>'; $group_message .= "</div>\n\n"; $group_message = apply_filters('ass_digest_group_message_title', $group_message, $group_id, $type); // Finally, add the markup to the digest foreach ($activity_ids as $activity_id) { // Cache is set earlier in ass_digest_fire() $activity_item = !empty($bp->ass->items[$activity_id]) ? $bp->ass->items[$activity_id] : false; if (!empty($activity_item)) { $group_message .= ass_digest_format_item($activity_item, $type); } //$group_message .= '<pre>'. $item->id .'</pre>'; } return apply_filters('ass_digest_format_item_group', $group_message, $group_id, $type); }
/** * BPGES: Use HTML for group activity item email blasts. * * @param string $retval The original email message. * @param BP_Activity_Activity $activity The activity item. * @param string $action The activity action. * @param BP_Groups_Group $group The group object. * @return string The modified email content containing HTML if available. */ function use_html_for_ges_activity_content($retval, $activity, $action, $group) { $activity_permalink = isset($activity->primary_link) && $activity->primary_link != bp_core_get_user_domain($activity->user_id) ? $activity->primary_link : bp_get_group_permalink($group); // if group is not public, use login URL to verify authentication and for // easier redirection after logging in if ($group->status != 'public') { $activity_permalink = ass_get_login_redirect_url($activity_permalink); } // no content, so only print the activity action if (empty($retval)) { $content = sprintf(__('%1$s %2$s', 'buddypress'), $action, sprintf('<a href="%s">%s</a>', $activity_permalink, __('View/Reply', 'buddypress'))); // print content as well } else { $content = sprintf(__('%1$s <blockquote>%2$s</blockquote> %3$s', 'buddypress'), $action, $retval, sprintf('<a href="%s">%s</a>', $activity_permalink, __('View/Reply', 'buddypress'))); } // Don't let GES strip goodies remove_filter('ass_clean_content', 'strip_tags', 4); remove_filter('ass_clean_content', 'ass_convert_links', 6); remove_filter('ass_clean_content', 'ass_html_entity_decode', 8); return $content; }