<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][8421] trunk/src/bp-groups/bp-groups-admin.php: Group Admin: Updates to `bp_groups_admin_edit_metabox_members()`:</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/8421">8421</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2014-05-16 09:32:19 +0000 (Fri, 16 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Group Admin: Updates to `bp_groups_admin_edit_metabox_members()`:

* Separate member roles and actions into option groups.
* Add a bit more intelligence to Ban action VS Banned role.
* Escape for JS and Gettext output where appropriate.
* General whitespace clean-up.

See <a href="http://buddypress.trac.wordpress.org/ticket/5645">#5645</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcbpgroupsbpgroupsadminphp">trunk/src/bp-groups/bp-groups-admin.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcbpgroupsbpgroupsadminphp"></a>
<div class="modfile"><h4>Modified: trunk/src/bp-groups/bp-groups-admin.php (8420 => 8421)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/bp-groups/bp-groups-admin.php  2014-05-16 08:55:43 UTC (rev 8420)
+++ trunk/src/bp-groups/bp-groups-admin.php     2014-05-16 09:32:19 UTC (rev 8421)
</span><span class="lines">@@ -731,7 +731,6 @@
</span><span class="cx">  *        group.
</span><span class="cx">  */
</span><span class="cx"> function bp_groups_admin_edit_metabox_members( $item ) {
</span><del>-       global $members_template;
</del><span class="cx"> 
</span><span class="cx">  // Pull up a list of group members, so we can separate out the types
</span><span class="cx">  // We'll also keep track of group members here to place them into a
</span><span class="lines">@@ -751,7 +750,7 @@
</span><span class="cx">  );
</span><span class="cx"> 
</span><span class="cx">  foreach ( $members as $type => &$member_type_users ) {
</span><del>-               $page_qs_key = $type . '_page';
</del><ins>+                $page_qs_key       = $type . '_page';
</ins><span class="cx">           $current_type_page = isset( $_GET[ $page_qs_key ] ) ? absint( $_GET[ $page_qs_key ] ) : 1;
</span><span class="cx">          $member_type_query = new BP_Group_Member_Query( array(
</span><span class="cx">                  'group_id'   => $item->id,
</span><span class="lines">@@ -761,27 +760,24 @@
</span><span class="cx">                  'page'       => $current_type_page,
</span><span class="cx">          ) );
</span><span class="cx"> 
</span><del>-               $member_type_users = $member_type_query->results;
-
</del><ins>+                $member_type_users   = $member_type_query->results;
</ins><span class="cx">           $pagination[ $type ] = bp_groups_admin_create_pagination_links( $member_type_query, $type );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  // Echo out the javascript variable
</span><del>-       echo '<script type="text/javascript">var group_id = "' . $item->id . '";</script>';
</del><ins>+        echo '<script type="text/javascript">var group_id = "' . esc_js( $item->id ) . '";</script>';
</ins><span class="cx"> 
</span><span class="cx">  // Loop through each member type
</span><span class="cx">  foreach ( $members as $member_type => $type_users ) : ?>
</span><span class="cx"> 
</span><span class="cx">          <div class="bp-groups-member-type" id="bp-groups-member-type-<?php echo esc_attr( $member_type ) ?>">
</span><span class="cx"> 
</span><del>-                       <h4>
-                               <?php switch ( $member_type ) :
-                                       case 'admin'  : _e( 'Administrators', 'buddypress' ); break;
-                                       case 'mod'    : _e( 'Moderators',     'buddypress' ); break;
-                                       case 'member' : _e( 'Members',        'buddypress' ); break;
-                                       case 'banned' : _e( 'Banned Users',   'buddypress' ); break;
-                               endswitch; ?>
-                       </h4>
</del><ins>+                        <h4><?php switch ( $member_type ) :
+                                       case 'admin'  : esc_html_e( 'Administrators', 'buddypress' ); break;
+                                       case 'mod'    : esc_html_e( 'Moderators',     'buddypress' ); break;
+                                       case 'member' : esc_html_e( 'Members',        'buddypress' ); break;
+                                       case 'banned' : esc_html_e( 'Banned Members', 'buddypress' ); break;
+                       endswitch; ?></h4>
</ins><span class="cx"> 
</span><span class="cx">                  <div class="bp-group-admin-pagination table-top">
</span><span class="cx">                          <?php echo $pagination[ $member_type ] ?>
</span><span class="lines">@@ -791,11 +787,11 @@
</span><span class="cx"> 
</span><span class="cx">                  <table class="widefat bp-group-members">
</span><span class="cx">                          <thead>
</span><del>-                               <tr>
-                                       <th scope="col" class="uid-column"><?php _ex( 'ID', 'Group member user_id in group admin', 'buddypress' ) ?></th>
-                                       <th scope="col" class="uname-column"><?php _ex( 'Name', 'Group member name in group admin', 'buddypress' ) ?></th>
-                                       <th scope="col" class="urole-column"><?php _ex( 'Group Role', 'Group member role in group admin', 'buddypress' ) ?></th>
-                               </tr>
</del><ins>+                                        <tr>
+                                               <th scope="col" class="uid-column"><?php _ex( 'ID', 'Group member user_id in group admin', 'buddypress' ); ?></th>
+                                               <th scope="col" class="uname-column"><?php _ex( 'Name', 'Group member name in group admin', 'buddypress' ); ?></th>
+                                               <th scope="col" class="urole-column"><?php _ex( 'Group Role', 'Group member role in group admin', 'buddypress' ); ?></th>
+                                       </tr>
</ins><span class="cx">                           </thead>
</span><span class="cx"> 
</span><span class="cx">                          <tbody>
</span><span class="lines">@@ -811,16 +807,25 @@
</span><span class="cx">                                                          'height'  => '32'
</span><span class="cx">                                                  ) ); ?></a>
</span><span class="cx"> 
</span><del>-                                                       <span style="margin: 8px; float: left;"><?php echo bp_core_get_userlink( $type_user->ID ) ?></span>
</del><ins>+                                                        <span style="margin: 8px; float: left;"><?php echo bp_core_get_userlink( $type_user->ID ); ?></span>
</ins><span class="cx">                                           </td>
</span><span class="cx"> 
</span><span class="cx">                                          <td class="urole-column">
</span><span class="cx">                                                  <select class="bp-groups-role" id="bp-groups-role-<?php echo esc_attr( $type_user->ID ); ?>" name="bp-groups-role[<?php echo esc_attr( $type_user->ID ); ?>]">
</span><del>-                                                               <option value="admin" <?php selected( 'admin', $member_type ) ?>><?php _e( 'Administrator', 'buddypress' ) ?></option>
-                                                               <option value="mod" <?php selected( 'mod', $member_type ) ?>><?php _e( 'Moderator', 'buddypress' ) ?></option>
-                                                               <option value="member" <?php selected( 'member', $member_type ) ?>><?php _e( 'Member', 'buddypress' ) ?></option>
-                                                               <option class="banned" value="banned" <?php selected( 'banned', $member_type ) ?>><?php _e( 'Banned', 'buddypress' ) ?></option>
-                                                               <option class="remove" value="remove"><?php _e( 'Remove From Group', 'buddypress' ) ?></option>
</del><ins>+                                                                <optgroup label="<?php esc_attr_e( 'Roles', 'buddypress' ); ?>">
+                                                                       <option class="admin"  value="admin"  <?php selected( 'admin',  $member_type ); ?>><?php esc_html_e( 'Administrator', 'buddypress' ); ?></option>
+                                                                       <option class="mod"    value="mod"    <?php selected( 'mod',    $member_type ); ?>><?php esc_html_e( 'Moderator',     'buddypress' ); ?></option>
+                                                                       <option class="member" value="member" <?php selected( 'member', $member_type ); ?>><?php esc_html_e( 'Member',        'buddypress' ); ?></option>
+                                                                       <?php if ( 'banned' === $member_type ) : ?>
+                                                                       <option class="banned" value="banned" <?php selected( 'banned', $member_type ); ?>><?php esc_html_e( 'Banned',        'buddypress' ); ?></option>
+                                                                       <?php endif; ?>
+                                                               </optgroup>
+                                                               <optgroup label="<?php esc_attr_e( 'Actions', 'buddypress' ); ?>">
+                                                                       <option class="remove" value="remove"><?php esc_html_e( 'Remove', 'buddypress' ); ?></option>
+                                                                       <?php if ( 'banned' !== $member_type ) : ?>
+                                                                               <option class="banned" value="banned"><?php esc_html_e( 'Ban', 'buddypress' ); ?></option>
+                                                                       <?php endif; ?>
+                                                               </optgroup>
</ins><span class="cx">                                                   </select>
</span><span class="cx"> 
</span><span class="cx">                                                  <?php
</span><span class="lines">@@ -829,7 +834,8 @@
</span><span class="cx">                                                   * so we can easily detect changes.
</span><span class="cx">                                                   *
</span><span class="cx">                                                   * @todo remove this, and do database detection on save
</span><del>-                                                        */ ?>
</del><ins>+                                                         */
+                                                       ?>
</ins><span class="cx">                                                   <input type="hidden" name="bp-groups-existing-role[<?php echo esc_attr( $type_user->ID ); ?>]" value="<?php echo esc_attr( $member_type ); ?>" />
</span><span class="cx">                                          </td>
</span><span class="cx">                                  </tr>
</span><span class="lines">@@ -848,19 +854,18 @@
</span><span class="cx">                  </table>
</span><span class="cx"> 
</span><span class="cx">                  <div class="bp-group-admin-pagination table-bottom">
</span><del>-                               <?php echo $pagination[ $member_type ] ?>
</del><ins>+                                <?php echo $pagination[ $member_type ]; ?>
</ins><span class="cx">                   </div>
</span><span class="cx"> 
</span><span class="cx">          <?php else : ?>
</span><span class="cx"> 
</span><del>-                       <p class="bp-groups-no-members description"><?php _e( 'No members of this type', 'buddypress' ) ?></p>
</del><ins>+                        <p class="bp-groups-no-members description"><?php esc_html_e( 'No members of this type', 'buddypress' ); ?></p>
</ins><span class="cx"> 
</span><span class="cx">          <?php endif; ?>
</span><span class="cx"> 
</span><span class="cx">          </div><!-- .bp-groups-member-type -->
</span><span class="cx"> 
</span><span class="cx">  <?php endforeach;
</span><del>-
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>

</body>
</html>