function membership_activation_notify($group_id, $user_id, $is_update = false)
 {
     global $scoper;
     $group = ScoperAdminLib::get_group($group_id);
     $user = new WP_User($user_id);
     $title = sprintf(__('[%s] Group Membership Activated'), get_option('blogname'));
     $site_url = site_url('');
     $admin_url = admin_url('');
     $message = sprintf(__('An administrator has activated the membership of %1$s in the "%2$s" access group.'), $user->display_name, $group->display_name) . "\r\n\r\n";
     // If group has moderator(s), notify them.
     $manager_ids = array();
     if ($managers = $scoper->users_who_can("manage_groups", COLS_ALL_RS, 'group', $group_id)) {
         foreach ($managers as $row) {
             $manager_ids[$row->ID] = true;
         }
     }
     if ($moderators = $scoper->users_who_can("recommend_group_membership", COLS_ALL_RS, 'group', $group_id)) {
         foreach ($moderators as $row) {
             $moderator_ids[$row->ID] = true;
         }
     } else {
         $moderator_ids = array();
     }
     if (array_diff_key($moderator_ids, $manager_ids)) {
         foreach ($moderators as $_user) {
             if (!isset($manager_ids[$_user->ID])) {
                 awp_mail($_user->user_email, $title, $message);
             }
         }
     }
     // Also notify the newly activated group member.
     $message .= sprintf(__('To view the site, follow this link: %1$s'), $site_url) . "\r\n";
     $message .= sprintf(__('To log in with your new: %1$s'), $admin_url) . "\r\n\r\n";
     awp_mail($user->user_email, $title, $message);
 }
            echo "</td><td " . $style . ">";
            if (!$result->meta_id) {
                echo "<a class='edit' href='admin.php?page=rs-group_members&amp;mode=edit&amp;id={$result->ID}'>" . __awp('Edit') . "</a>";
            }
            echo "</td></tr>";
        }
        echo "\n</table>";
    } else {
        echo "<p><strong>" . __('No groups available.', 'scoper') . "</strong></p>";
    }
}
switch ($mode) {
    case "edit":
        if (isset($_REQUEST['id'])) {
            $groupID = $_REQUEST['id'];
            $group = ScoperAdminLib::get_group($groupID);
            if ($group->meta_id && !strpos($group->meta_id, '_ed_')) {
                die(__('This meta group is automatically populated. You cannot manually add members to it.', 'scoper'));
            }
            echo "<h2>";
            printf(__('Edit members of %s group', 'scoper'), $group->display_name);
            echo "</h2>";
            echo '<form id="readWrite" name="readWrite" action="' . 'admin.php?page=rs-group_members&amp;mode=update&amp;id=' . $groupID . '" method="post">';
            wp_nonce_field('scoper-edit-group-members_' . $groupID);
            echo '<script type="text/javascript"><!--
			      function select_all(name, value) {
			        formblock = document.getElementById("readWrite");
			        forminputs = formblock.getElementsByTagName("input");
			        for (i = 0; i < forminputs.length; i++) {
			          // regex here to check name attribute
			          var regex = new RegExp(name, "i");
Ejemplo n.º 3
0
             UserGroups_tp::write(__("Invalid group. No groups were deleted.", 'scoper'), false);
         }
         $_REQUEST['id'] = "";
     }
     break;
 case "approve":
     if (awp_ver('2.8') && scoper_get_option('group_ajax')) {
         if ($can_manage_all_groups || current_user_can('manage_groups', $_GET['id'])) {
             $status = 'active';
         } elseif (current_user_can('recommend_group_membership', $_GET['id'])) {
             $status = 'recommended';
         } else {
             break;
         }
         $update_user = new WP_User($_GET['user']);
         $update_group = ScoperAdminLib::get_group($_GET['id']);
         if ($update_user->ID && $update_group->ID) {
             ScoperAdminLib::update_group_user($_GET['id'], $_GET['user'], $status);
             $success_msg = __("Group members updated successfuly.", 'scoper');
         } else {
             $errorMessage = __("Error updating group membership.", 'scoper');
         }
     }
     break;
 default:
     switch ($cancel) {
         case 1:
             UserGroups_tp::write(__("Group edit cancelled.", 'scoper'));
             break;
         default:
             break;
 function group_members_checklist($group_id, $user_class = 'member', $all_users = '')
 {
     global $scoper;
     if (!$all_users) {
         $all_users = $scoper->users_who_can('', COLS_ID_NAME_RS);
     }
     if ($group_id) {
         $group = ScoperAdminLib::get_group($group_id);
     }
     if ('member' == $user_class) {
         $current_ids = $group_id ? array_flip(ScoperAdminLib::get_group_members($group_id, COL_ID_RS)) : array();
         if (!empty($group) && in_array($group->meta_id, array('rv_pending_rev_notice_ed_nr_', 'rv_scheduled_rev_notice_ed_nr_'))) {
             $args = array('any_object' => true);
             $eligible_ids = array();
             foreach (get_post_types(array('public' => true), 'object') as $_type => $_type_obj) {
                 $args['object_type'] = $_type;
                 $type_eligible_ids = $scoper->users_who_can(array($_type_obj->cap->edit_published_posts, $_type_obj->cap->edit_others_posts), COL_ID_RS, 'post', 0, $args);
                 $eligible_ids = array_merge($eligible_ids, $type_eligible_ids);
             }
             $eligible_ids = array_unique($eligible_ids);
         } else {
             // force_all_users arg is a temporary measure to ensure that any user can be viewed / added to a sitewide MU group regardless of what blog backend it's edited through
             $_args = IS_MU_RS && scoper_get_option('mu_sitewide_groups', true) ? array('force_all_users' => true) : array();
             $eligible_ids = $scoper->users_who_can('', COL_ID_RS, '', '', $_args);
         }
         $admin_ids = array();
     } else {
         $group_role_defs = 'moderator' == $user_class ? array('rs_group_moderator') : array('rs_group_manager');
         if ($group_id) {
             require_once dirname(__FILE__) . '/role_assignment_lib_rs.php';
             $current_roles = ScoperRoleAssignments::organize_assigned_roles(OBJECT_SCOPE_RS, 'group', $group_id, $group_role_defs, ROLE_BASIS_USER);
             $current_roles = agp_array_flatten($current_roles, false);
             $current_ids = isset($current_roles['assigned']) ? $current_roles['assigned'] : array();
         } else {
             $current_ids = array();
         }
         $cap_name = defined('SCOPER_USER_ADMIN_CAP') ? constant('SCOPER_USER_ADMIN_CAP') : 'edit_users';
         $admin_ids = $scoper->users_who_can($cap_name, COL_ID_RS);
         // optionally, limit available group managers according to role_admin_blogwide_editor_only option
         if ('manager' == $user_class) {
             $require_blogwide_editor = false;
             if (!empty($group)) {
                 if (!strpos($group->meta_id, '_nr_')) {
                     // don't limit manager selection for groups that don't have role assignments
                     $require_blogwide_editor = scoper_get_option('role_admin_blogwide_editor_only');
                 }
             }
             if ('admin' == $require_blogwide_editor) {
                 $eligible_ids = $admin_ids;
             } elseif ('admin_content' == $require_blogwide_editor) {
                 $cap_name = defined('SCOPER_CONTENT_ADMIN_CAP') ? constant('SCOPER_CONTENT_ADMIN_CAP') : 'activate_plugins';
                 $eligible_ids = array_unique(array_merge($admin_ids, $scoper->users_who_can($cap_name, COL_ID_RS)));
             } elseif ($require_blogwide_editor) {
                 $post_editors = $scoper->users_who_can('edit_others_posts', COL_ID_RS);
                 $page_editors = $scoper->users_who_can('edit_others_pages', COL_ID_RS);
                 $eligible_ids = array_unique(array_merge($post_editors, $page_editors, $admin_ids));
             } else {
                 $eligible_ids = '';
             }
         } else {
             $eligible_ids = '';
         }
     }
     // endif user class is not "member"
     $css_id = $user_class;
     $args = array('eligible_ids' => $eligible_ids, 'via_other_scope_ids' => $admin_ids, 'suppress_extra_prefix' => true);
     require_once dirname(__FILE__) . '/agents_checklist_rs.php';
     ScoperAgentsChecklist::agents_checklist(ROLE_BASIS_USER, $all_users, $css_id, $current_ids, $args);
 }
 function display_ui_group_roles($group_id)
 {
     $users = ScoperAdminLib::get_group_members($group_id, COL_ID_RS);
     $args = array('disable_user_roles' => true, 'filter_usergroups' => array($group_id => true), 'disable_wp_roles' => true);
     $user_id = $users ? $users[0] : 0;
     $user = new WP_Scoped_User($user_id, '', $args);
     if (!$users) {
         $user->groups = array($group_id => true);
     }
     if ($group = ScoperAdminLib::get_group($group_id)) {
         if (!strpos($group->meta_id, '_nr_')) {
             global $wpdb;
             echo '<div class="rs-group-profile">';
             if (IS_MU_RS && scoper_get_option('mu_sitewide_groups')) {
                 global $blog_id;
                 $blog_ids = scoper_get_col("SELECT blog_id FROM {$wpdb->blogs} ORDER BY blog_id");
                 $orig_blog_id = $blog_id;
             } else {
                 $blog_ids = array('1');
             }
             foreach ($blog_ids as $id) {
                 if (count($blog_ids) > 1) {
                     switch_to_blog($id);
                 }
                 if (!$wpdb->get_results("SHOW TABLES LIKE '{$wpdb->user2role2object_rs}'")) {
                     continue;
                 }
                 ScoperProfileUI::display_ui_user_roles($user, true);
                 //arg: groups only
             }
             echo '</div>';
             if (count($blog_ids) > 1) {
                 switch_to_blog($orig_blog_id);
             }
         }
     }
 }
Ejemplo n.º 6
0
         $_REQUEST['id'] = "";
     }
     break;
 case "approve":
     if (awp_ver('2.8') && scoper_get_option('group_ajax')) {
         $group_id = (int) $_GET['id'];
         $user_id = (int) $_GET['user'];
         if ($can_manage_all_groups || current_user_can('manage_groups', $group_id)) {
             $status = 'active';
         } elseif (current_user_can('recommend_group_membership', $group_id)) {
             $status = 'recommended';
         } else {
             break;
         }
         $update_user = new WP_User($user_id);
         $update_group = ScoperAdminLib::get_group($group_id);
         if ($update_user->ID && $update_group->ID) {
             ScoperAdminLib::update_group_user($group_id, $user_id, $status);
             $success_msg = __("Group members updated successfuly.", 'scoper');
         } else {
             $errorMessage = __("Error updating group membership.", 'scoper');
         }
     }
     break;
 default:
     switch ($cancel) {
         case 1:
             UserGroups_tp::write(__("Group edit cancelled.", 'scoper'));
             break;
         default:
             break;