<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[BuddyPress] [3472] trunk:
  Fixes a whole bunch of WP_DEBUG problems with groups and especially group creation
 .</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>3472</dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2010-11-21 23:30:57 +0000 (Sun, 21 Nov 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fixes a whole bunch of WP_DEBUG problems with groups and especially group creation.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoretemplatetagsphp">trunk/bp-core/bp-core-templatetags.php</a></li>
<li><a href="#trunkbpgroupsbpgroupstemplatetagsphp">trunk/bp-groups/bp-groups-templatetags.php</a></li>
<li><a href="#trunkbpgroupsphp">trunk/bp-groups.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoretemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-templatetags.php (3471 => 3472)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-templatetags.php        2010-11-21 23:12:33 UTC (rev 3471)
+++ trunk/bp-core/bp-core-templatetags.php        2010-11-21 23:30:57 UTC (rev 3472)
</span><span class="lines">@@ -704,8 +704,13 @@
</span><span class="cx"> }
</span><span class="cx">         function bp_get_avatar_admin_step() {
</span><span class="cx">                 global $bp;
</span><ins>+                
+                if ( isset( $bp-&gt;avatar_admin-&gt;step ) )
+                        $step = $bp-&gt;avatar_admin-&gt;step;
+                else
+                        $step = '';
</ins><span class="cx"> 
</span><del>-                return apply_filters( 'bp_get_avatar_admin_step', $bp-&gt;avatar_admin-&gt;step );
</del><ins>+                return apply_filters( 'bp_get_avatar_admin_step', $step );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_avatar_to_crop() {
</span><span class="lines">@@ -713,8 +718,13 @@
</span><span class="cx"> }
</span><span class="cx">         function bp_get_avatar_to_crop() {
</span><span class="cx">                 global $bp;
</span><ins>+                
+                if ( isset( $bp-&gt;avatar_admin-&gt;image-&gt;url ) )
+                        $url = $bp-&gt;avatar_admin-&gt;image-&gt;url;
+                else
+                        $url = '';
</ins><span class="cx"> 
</span><del>-                return apply_filters( 'bp_get_avatar_to_crop', $bp-&gt;avatar_admin-&gt;image-&gt;url );
</del><ins>+                return apply_filters( 'bp_get_avatar_to_crop', $url );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_avatar_to_crop_src() {
</span><span class="lines">@@ -1026,7 +1036,7 @@
</span><span class="cx">         if ( bp_is_active( 'groups' ) )
</span><span class="cx">                 $options['groups'] = __( 'Groups', 'buddypress' );
</span><span class="cx"> 
</span><del>-        if ( function_exists( 'bp_forums_is_installed_correctly' ) &amp;&amp; bp_forums_is_installed_correctly() &amp;&amp; !(int) $bp-&gt;site_options['bp-disable-forum-directory'] )
</del><ins>+        if ( function_exists( 'bp_forums_is_installed_correctly' ) &amp;&amp; bp_forums_is_installed_correctly() &amp;&amp; !isset( $bp-&gt;site_options['bp-disable-forum-directory'] ) )
</ins><span class="cx">                 $options['forums'] = __( 'Forums', 'buddypress' );
</span><span class="cx"> 
</span><span class="cx">         if ( bp_is_active( 'blogs' ) &amp;&amp; is_multisite() )
</span></span></pre></div>
<a id="trunkbpgroupsbpgroupstemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups/bp-groups-templatetags.php (3471 => 3472)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups/bp-groups-templatetags.php        2010-11-21 23:12:33 UTC (rev 3471)
+++ trunk/bp-groups/bp-groups-templatetags.php        2010-11-21 23:30:57 UTC (rev 3472)
</span><span class="lines">@@ -1129,7 +1129,7 @@
</span><span class="cx">                         $group =&amp; $groups_template-&gt;group;
</span><span class="cx"> 
</span><span class="cx">                 // If they're not logged in or are banned from the group, no join button.
</span><del>-                if ( !is_user_logged_in() || $group-&gt;is_banned )
</del><ins>+                if ( !is_user_logged_in() || isset( $group-&gt;is_banned ) )
</ins><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 // Group creation was not completed or status is unknown
</span><span class="lines">@@ -1632,7 +1632,7 @@
</span><span class="cx"> function bp_is_group_creation_step_complete( $step_slugs ) {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !$bp-&gt;groups-&gt;completed_create_steps )
</del><ins>+        if ( !isset( $bp-&gt;groups-&gt;completed_create_steps ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         if ( is_array( $step_slugs ) ) {
</span><span class="lines">@@ -1677,7 +1677,13 @@
</span><span class="cx"> }
</span><span class="cx">         function bp_get_new_group_id() {
</span><span class="cx">                 global $bp;
</span><del>-                return apply_filters( 'bp_get_new_group_id', $bp-&gt;groups-&gt;new_group_id );
</del><ins>+                
+                if ( isset( $bp-&gt;groups-&gt;new_group_id ) )
+                        $new_group_id = $bp-&gt;groups-&gt;new_group_id;
+                else
+                        $new_group_id = 0;
+                
+                return apply_filters( 'bp_get_new_group_id', $new_group_id );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_new_group_name() {
</span><span class="lines">@@ -1685,7 +1691,13 @@
</span><span class="cx"> }
</span><span class="cx">         function bp_get_new_group_name() {
</span><span class="cx">                 global $bp;
</span><del>-                return apply_filters( 'bp_get_new_group_name', $bp-&gt;groups-&gt;current_group-&gt;name );
</del><ins>+                
+                if ( isset( $bp-&gt;groups-&gt;current_group-&gt;name ) )
+                        $name = $bp-&gt;groups-&gt;current_group-&gt;name;
+                else
+                        $name = '';
+                
+                return apply_filters( 'bp_get_new_group_name', $name );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_new_group_description() {
</span><span class="lines">@@ -1693,7 +1705,13 @@
</span><span class="cx"> }
</span><span class="cx">         function bp_get_new_group_description() {
</span><span class="cx">                 global $bp;
</span><del>-                return apply_filters( 'bp_get_new_group_description', $bp-&gt;groups-&gt;current_group-&gt;description );
</del><ins>+                
+                if ( isset( $bp-&gt;groups-&gt;current_group-&gt;description ) )
+                        $description = $bp-&gt;groups-&gt;current_group-&gt;description;
+                else
+                        $description = '';
+                        
+                return apply_filters( 'bp_get_new_group_description', $description );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_new_group_enable_forum() {
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (3471 => 3472)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2010-11-21 23:12:33 UTC (rev 3471)
+++ trunk/bp-groups.php        2010-11-21 23:30:57 UTC (rev 3472)
</span><span class="lines">@@ -96,8 +96,8 @@
</span><span class="cx"> 
</span><span class="cx">                         /* When in a single group, the first action is bumped down one because of the
</span><span class="cx">                            group name, so we need to adjust this and set the group name to current_item. */
</span><del>-                        $bp-&gt;current_item = $bp-&gt;current_action;
-                        $bp-&gt;current_action = $bp-&gt;action_variables[0];
</del><ins>+                        $bp-&gt;current_item = isset( $bp-&gt;current_action ) ? $bp-&gt;current_action : false;
+                        $bp-&gt;current_action = isset( $bp-&gt;action_variables[0] ) ? $bp-&gt;action_variables[0] : false;
</ins><span class="cx">                         array_shift($bp-&gt;action_variables);
</span><span class="cx"> 
</span><span class="cx">                         $bp-&gt;bp_options_title = $bp-&gt;groups-&gt;current_group-&gt;name;
</span><span class="lines">@@ -989,7 +989,7 @@
</span><span class="cx">         groups_action_sort_creation_steps();
</span><span class="cx"> 
</span><span class="cx">         /* If no current step is set, reset everything so we can start a fresh group creation */
</span><del>-        if ( !$bp-&gt;groups-&gt;current_create_step = $bp-&gt;action_variables[1] ) {
</del><ins>+        if ( !isset( $bp-&gt;action_variables[1] ) || !$bp-&gt;groups-&gt;current_create_step = $bp-&gt;action_variables[1] ) {
</ins><span class="cx"> 
</span><span class="cx">                 unset( $bp-&gt;groups-&gt;current_create_step );
</span><span class="cx">                 unset( $bp-&gt;groups-&gt;completed_create_steps );
</span><span class="lines">@@ -1008,7 +1008,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /* Fetch the currently completed steps variable */
</span><del>-        if ( isset( $_COOKIE['bp_completed_create_steps'] ) &amp;&amp; !$reset_steps )
</del><ins>+        if ( isset( $_COOKIE['bp_completed_create_steps'] ) &amp;&amp; !isset( $reset_steps ) )
</ins><span class="cx">                 $bp-&gt;groups-&gt;completed_create_steps = unserialize( stripslashes( $_COOKIE['bp_completed_create_steps'] ) );
</span><span class="cx"> 
</span><span class="cx">         /* Set the ID of the new group, if it has already been created in a previous step */
</span><span class="lines">@@ -1028,8 +1028,10 @@
</span><span class="cx">                                 bp_core_add_message( __( 'Please fill in all of the required fields', 'buddypress' ), 'error' );
</span><span class="cx">                                 bp_core_redirect( $bp-&gt;root_domain . '/' . $bp-&gt;groups-&gt;slug . '/create/step/' . $bp-&gt;groups-&gt;current_create_step . '/' );
</span><span class="cx">                         }
</span><ins>+                        
+                        $new_group_id = isset( $bp-&gt;groups-&gt;new_group_id ) ? $bp-&gt;groups-&gt;new_group_id : 0;
</ins><span class="cx"> 
</span><del>-                        if ( !$bp-&gt;groups-&gt;new_group_id = groups_create_group( array( 'group_id' =&gt; $bp-&gt;groups-&gt;new_group_id, 'name' =&gt; $_POST['group-name'], 'description' =&gt; $_POST['group-desc'], 'slug' =&gt; groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' =&gt; bp_core_current_time(), 'status' =&gt; 'public' ) ) ) {
</del><ins>+                        if ( !$bp-&gt;groups-&gt;new_group_id = groups_create_group( array( 'group_id' =&gt; $new_group_id, 'name' =&gt; $_POST['group-name'], 'description' =&gt; $_POST['group-desc'], 'slug' =&gt; groups_check_slug( sanitize_title( esc_attr( $_POST['group-name'] ) ) ), 'date_created' =&gt; bp_core_current_time(), 'status' =&gt; 'public' ) ) ) {
</ins><span class="cx">                                 bp_core_add_message( __( 'There was an error saving group details, please try again.', 'buddypress' ), 'error' );
</span><span class="cx">                                 bp_core_redirect( $bp-&gt;root_domain . '/' . $bp-&gt;groups-&gt;slug . '/create/step/' . $bp-&gt;groups-&gt;current_create_step . '/' );
</span><span class="cx">                         }
</span><span class="lines">@@ -1074,7 +1076,8 @@
</span><span class="cx">                  * we need to add the current step to the array of completed steps, then update the cookies
</span><span class="cx">                  * holding the information
</span><span class="cx">                  */
</span><del>-                if ( !in_array( $bp-&gt;groups-&gt;current_create_step, (array)$bp-&gt;groups-&gt;completed_create_steps ) )
</del><ins>+                $completed_create_steps = isset( $bp-&gt;groups-&gt;completed_create_steps ) ? $bp-&gt;groups-&gt;completed_create_steps : array();
+                if ( !in_array( $bp-&gt;groups-&gt;current_create_step, $completed_create_steps ) )
</ins><span class="cx">                         $bp-&gt;groups-&gt;completed_create_steps[] = $bp-&gt;groups-&gt;current_create_step;
</span><span class="cx"> 
</span><span class="cx">                 /* Reset cookie info */
</span><span class="lines">@@ -1107,7 +1110,7 @@
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><del>-                                if ( $next ) {
</del><ins>+                                if ( isset( $next ) ) {
</ins><span class="cx">                                         $next_step = $key;
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="lines">@@ -1464,12 +1467,12 @@
</span><span class="cx">          *        'date_created'
</span><span class="cx">          */
</span><span class="cx"> 
</span><del>-        if ( $group_id )
</del><ins>+        if ( isset( $group_id ) &amp;&amp; $group_id )
</ins><span class="cx">                 $group = new BP_Groups_Group( $group_id );
</span><span class="cx">         else
</span><span class="cx">                 $group = new BP_Groups_Group;
</span><span class="cx"> 
</span><del>-        if ( $creator_id )
</del><ins>+        if ( isset( $creator_id ) &amp;&amp; $creator_id )
</ins><span class="cx">                 $group-&gt;creator_id = $creator_id;
</span><span class="cx">         else
</span><span class="cx">                 $group-&gt;creator_id = $bp-&gt;loggedin_user-&gt;id;
</span></span></pre>
</div>
</div>

</body>
</html>