<!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][4842] trunk: Global/slug review in Settings and Messages component.</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, #logmsg > ol { margin-left: 0; 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/4842">4842</a></dd>
<dt>Author</dt> <dd>boonebgorges</dd>
<dt>Date</dt> <dd>2011-07-24 22:51:38 +0000 (Sun, 24 Jul 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Global/slug review in Settings and Messages component. See <a href="http://buddypress.trac.wordpress.org/ticket/3325">#3325</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpmessagesbpmessagesactionsphp">trunk/bp-messages/bp-messages-actions.php</a></li>
<li><a href="#trunkbpmessagesbpmessagesscreensphp">trunk/bp-messages/bp-messages-screens.php</a></li>
<li><a href="#trunkbpmessagesbpmessagestemplatephp">trunk/bp-messages/bp-messages-template.php</a></li>
<li><a href="#trunkbpsettingsbpsettingsactionsphp">trunk/bp-settings/bp-settings-actions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpmessagesbpmessagesactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-messages/bp-messages-actions.php (4841 => 4842)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages/bp-messages-actions.php        2011-07-24 22:30:53 UTC (rev 4841)
+++ trunk/bp-messages/bp-messages-actions.php        2011-07-24 22:51:38 UTC (rev 4842)
</span><span class="lines">@@ -9,18 +9,16 @@
</span><span class="cx"> if ( !defined( 'ABSPATH' ) ) exit;
</span><span class="cx"> 
</span><span class="cx"> function messages_action_view_message() {
</span><del>-        global $bp, $thread_id;
</del><ins>+        global $thread_id;
</ins><span class="cx"> 
</span><del>-        if ( $bp-&gt;current_component != $bp-&gt;messages-&gt;slug || $bp-&gt;current_action != 'view' )
</del><ins>+        if ( !bp_is_messages_component() || !bp_is_current_action( 'view' ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        $thread_id = 0;
-        if ( !empty( $bp-&gt;action_variables[0] ) )
-                $thread_id = $bp-&gt;action_variables[0];
</del><ins>+        $thread_id = (int)bp_action_variable( 0 );
+        
+        if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access( $thread_id ) &amp;&amp; !is_super_admin() ) )
+                bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() );
</ins><span class="cx"> 
</span><del>-        if ( !$thread_id || !messages_is_valid_thread( $thread_id ) || ( !messages_check_thread_access($thread_id) &amp;&amp; !is_super_admin() ) )
-                bp_core_redirect( $bp-&gt;displayed_user-&gt;domain . $bp-&gt;current_component );
-
</del><span class="cx">         // Check if a new reply has been submitted
</span><span class="cx">         if ( isset( $_POST['send'] ) ) {
</span><span class="cx"> 
</span><span class="lines">@@ -33,7 +31,7 @@
</span><span class="cx">                 else
</span><span class="cx">                         bp_core_add_message( __( 'There was a problem sending your reply, please try again', 'buddypress' ), 'error' );
</span><span class="cx"> 
</span><del>-                bp_core_redirect( $bp-&gt;displayed_user-&gt;domain . $bp-&gt;current_component . '/view/' . $thread_id . '/' );
</del><ins>+                bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . $thread_id . '/' );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Mark message read
</span><span class="lines">@@ -49,12 +47,12 @@
</span><span class="cx">         bp_core_new_subnav_item( array(
</span><span class="cx">                 'name'            =&gt; sprintf( __( 'From: %s', 'buddypress' ), BP_Messages_Thread::get_last_sender( $thread_id ) ),
</span><span class="cx">                 'slug'            =&gt; 'view',
</span><del>-                'parent_url'      =&gt; $bp-&gt;loggedin_user-&gt;domain . $bp-&gt;messages-&gt;slug . '/',
-                'parent_slug'     =&gt; $bp-&gt;messages-&gt;slug,
</del><ins>+                'parent_url'      =&gt; trailingslashit( bp_displayed_user_domain() . bp_get_messages_slug() ),
+                'parent_slug'     =&gt; bp_get_messages_slug(),
</ins><span class="cx">                 'screen_function' =&gt; true,
</span><span class="cx">                 'position'        =&gt; 40,
</span><span class="cx">                 'user_has_access' =&gt; bp_is_my_profile(),
</span><del>-                'link'            =&gt; $bp-&gt;loggedin_user-&gt;domain . $bp-&gt;messages-&gt;slug . '/view/' . (int) $thread_id
</del><ins>+                'link'            =&gt; bp_displayed_user_domain() . bp_get_messages_slug() . '/view/' . (int) $thread_id
</ins><span class="cx">         ) );
</span><span class="cx"> 
</span><span class="cx">         bp_core_load_template( apply_filters( 'messages_template_view_message', 'members/single/home' ) );
</span><span class="lines">@@ -62,40 +60,40 @@
</span><span class="cx"> add_action( 'bp_actions', 'messages_action_view_message' );
</span><span class="cx"> 
</span><span class="cx"> function messages_action_delete_message() {
</span><del>-        global $bp, $thread_id;
</del><ins>+        global $thread_id;
</ins><span class="cx"> 
</span><del>-        if ( $bp-&gt;current_component != $bp-&gt;messages-&gt;slug || 'notices' == $bp-&gt;current_action || empty( $bp-&gt;action_variables[0] ) || 'delete' != $bp-&gt;action_variables[0] )
</del><ins>+        if ( !bp_is_messages_component() || bp_is_current_action( 'notices' ) || !bp_is_action_variable( 'delete', 0 ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        $thread_id = $bp-&gt;action_variables[1];
-
-        if ( !$thread_id || !is_numeric($thread_id) || !messages_check_thread_access($thread_id) ) {
-                bp_core_redirect( $bp-&gt;displayed_user-&gt;domain . $bp-&gt;current_component . '/' . $bp-&gt;current_action );
</del><ins>+        $thread_id = bp_action_variable( 1 );
+        
+        if ( !$thread_id || !is_numeric( $thread_id ) || !messages_check_thread_access( $thread_id ) ) {
+                bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
</ins><span class="cx">         } else {
</span><span class="cx">                 if ( !check_admin_referer( 'messages_delete_thread' ) )
</span><span class="cx">                         return false;
</span><span class="cx"> 
</span><span class="cx">                 // Delete message
</span><del>-                if ( !messages_delete_thread($thread_id) ) {
</del><ins>+                if ( !messages_delete_thread( $thread_id ) ) {
</ins><span class="cx">                         bp_core_add_message( __('There was an error deleting that message.', 'buddypress'), 'error' );
</span><span class="cx">                 } else {
</span><span class="cx">                         bp_core_add_message( __('Message deleted.', 'buddypress') );
</span><span class="cx">                 }
</span><del>-                bp_core_redirect( $bp-&gt;loggedin_user-&gt;domain . $bp-&gt;current_component . '/' . $bp-&gt;current_action );
</del><ins>+                bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_actions', 'messages_action_delete_message' );
</span><span class="cx"> 
</span><span class="cx"> function messages_action_bulk_delete() {
</span><del>-        global $bp, $thread_ids;
</del><ins>+        global $thread_ids;
</ins><span class="cx"> 
</span><del>-        if ( $bp-&gt;current_component != $bp-&gt;messages-&gt;slug || empty( $bp-&gt;action_variables[0] ) || 'bulk-delete' != $bp-&gt;action_variables[0] )
</del><ins>+        if ( !bp_is_messages_component() || !bp_is_action_variable( 'bulk-delete', 0 ) )
</ins><span class="cx">                 return false;
</span><span class="cx"> 
</span><span class="cx">         $thread_ids = $_POST['thread_ids'];
</span><span class="cx"> 
</span><del>-        if ( !$thread_ids || !messages_check_thread_access($thread_ids) ) {
-                bp_core_redirect( $bp-&gt;displayed_user-&gt;domain . $bp-&gt;current_component . '/' . $bp-&gt;current_action );
</del><ins>+        if ( !$thread_ids || !messages_check_thread_access( $thread_ids ) ) {
+                bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
</ins><span class="cx">         } else {
</span><span class="cx">                 if ( !check_admin_referer( 'messages_delete_thread' ) )
</span><span class="cx">                         return false;
</span><span class="lines">@@ -105,7 +103,7 @@
</span><span class="cx">                 else
</span><span class="cx">                         bp_core_add_message( __('Messages deleted.', 'buddypress') );
</span><span class="cx"> 
</span><del>-                bp_core_redirect( $bp-&gt;loggedin_user-&gt;domain . $bp-&gt;current_component . '/' . $bp-&gt;current_action );
</del><ins>+                bp_core_redirect( bp_displayed_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> add_action( 'bp_actions', 'messages_action_bulk_delete' );
</span></span></pre></div>
<a id="trunkbpmessagesbpmessagesscreensphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-messages/bp-messages-screens.php (4841 => 4842)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages/bp-messages-screens.php        2011-07-24 22:30:53 UTC (rev 4841)
+++ trunk/bp-messages/bp-messages-screens.php        2011-07-24 22:51:38 UTC (rev 4842)
</span><span class="lines">@@ -11,7 +11,7 @@
</span><span class="cx"> function messages_screen_inbox() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !empty( $bp-&gt;action_variables ) ) {
</del><ins>+        if ( bp_action_variables() ) {
</ins><span class="cx">                 bp_do_404();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx"> function messages_screen_sentbox() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !empty( $bp-&gt;action_variables ) ) {
</del><ins>+        if ( bp_action_variables() ) {
</ins><span class="cx">                 bp_do_404();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> function messages_screen_compose() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !empty( $bp-&gt;action_variables ) ) {
</del><ins>+        if ( bp_action_variables() ) {
</ins><span class="cx">                 bp_do_404();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -85,39 +85,39 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function messages_screen_notices() {
</span><del>-        global $bp, $notice_id;
</del><ins>+        global $notice_id;
</ins><span class="cx"> 
</span><span class="cx">         if ( !is_super_admin() )
</span><span class="cx">                 return false;
</span><span class="cx"> 
</span><del>-        $notice_id = isset( $bp-&gt;action_variables[1] ) ? $bp-&gt;action_variables[1] : 0;
-
</del><ins>+        $notice_id = (int)bp_action_variable( 1 );
+        
</ins><span class="cx">         if ( !empty( $notice_id ) &amp;&amp; is_numeric( $notice_id ) ) {
</span><span class="cx">                 $notice = new BP_Messages_Notice( $notice_id );
</span><span class="cx"> 
</span><del>-                if ( 'deactivate' == $bp-&gt;action_variables[0] ) {
</del><ins>+                if ( bp_is_action_variable( 'deactivate', 0 ) ) {
</ins><span class="cx">                         if ( !$notice-&gt;deactivate() ) {
</span><span class="cx">                                 bp_core_add_message( __('There was a problem deactivating that notice.', 'buddypress'), 'error' );
</span><span class="cx">                         } else {
</span><span class="cx">                                 bp_core_add_message( __('Notice deactivated.', 'buddypress') );
</span><span class="cx">                         }
</span><del>-                } else if ( 'activate' == $bp-&gt;action_variables[0] ) {
</del><ins>+                } else if ( bp_is_action_variable( 'activate', 0 ) ) {
</ins><span class="cx">                         if ( !$notice-&gt;activate() ) {
</span><span class="cx">                                 bp_core_add_message( __('There was a problem activating that notice.', 'buddypress'), 'error' );
</span><span class="cx">                         } else {
</span><span class="cx">                                 bp_core_add_message( __('Notice activated.', 'buddypress') );
</span><span class="cx">                         }
</span><del>-                } else if ( 'delete' == $bp-&gt;action_variables[0] ) {
</del><ins>+                } else if ( bp_is_action_variable( 'delete' ) ) {
</ins><span class="cx">                         if ( !$notice-&gt;delete() ) {
</span><span class="cx">                                 bp_core_add_message( __('There was a problem deleting that notice.', 'buddypress'), 'buddypress' );
</span><span class="cx">                         } else {
</span><span class="cx">                                 bp_core_add_message( __('Notice deleted.', 'buddypress') );
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                bp_core_redirect( $bp-&gt;loggedin_user-&gt;domain . $bp-&gt;messages-&gt;slug . '/notices' );
</del><ins>+                bp_core_redirect( bp_loggedin_user_domain() . bp_get_messages_slug() . '/notices' );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if ( !empty( $bp-&gt;action_variables ) ) {
</del><ins>+        if ( bp_action_variables() ) {
</ins><span class="cx">                 bp_do_404();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -130,7 +130,7 @@
</span><span class="cx"> function messages_screen_notification_settings() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !empty( $bp-&gt;action_variables ) ) {
</del><ins>+        if ( bp_action_variables() ) {
</ins><span class="cx">                 bp_do_404();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkbpmessagesbpmessagestemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/bp-messages/bp-messages-template.php (4841 => 4842)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-messages/bp-messages-template.php        2011-07-24 22:30:53 UTC (rev 4841)
+++ trunk/bp-messages/bp-messages-template.php        2011-07-24 22:51:38 UTC (rev 4842)
</span><span class="lines">@@ -343,18 +343,23 @@
</span><span class="cx">         echo sprintf( __( 'Viewing message %1$s to %2$s (of %3$s messages)', 'buddypress' ), $from_num, $to_num, $total ); ?&gt;&lt;?php
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * Echoes the form action for Messages HTML forms
+ *
+ * @package BuddyPress
+ */
</ins><span class="cx"> function bp_messages_form_action() {
</span><span class="cx">         echo bp_get_messages_form_action();
</span><span class="cx"> }
</span><ins>+        /**
+         * Returns the form action for Messages HTML forms
+         *
+         * @package BuddyPress
+         *
+         * @return str The form action
+         */
</ins><span class="cx">         function bp_get_messages_form_action() {
</span><del>-                global $bp;
-
-                if ( isset( $bp-&gt;action_variables[0] ) )
-                        $av = $bp-&gt;action_variables[0];
-                else
-                        $av = '';
-
-                return apply_filters( 'bp_get_messages_form_action', trailingslashit( $bp-&gt;loggedin_user-&gt;domain . $bp-&gt;messages-&gt;slug . '/' . $bp-&gt;current_action . '/' . $av . '/' ) );
</del><ins>+                return apply_filters( 'bp_get_messages_form_action', trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/' . bp_current_action() . '/' . bp_action_variable( 0 ) ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_messages_username_value() {
</span><span class="lines">@@ -718,7 +723,7 @@
</span><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx"> 
</span><span class="cx">         if ( !$thread_id &amp;&amp; bp_is_current_component( 'messages' ) &amp;&amp; bp_is_current_action( 'view' ) )
</span><del>-                $thread_id = (int)$bp-&gt;action_variables[0];
</del><ins>+                $thread_id = (int)bp_action_variable( 0 );
</ins><span class="cx"> 
</span><span class="cx">         $thread_template = new BP_Messages_Thread_Template( $thread_id, $order );
</span><span class="cx">         return $thread_template-&gt;has_messages();
</span></span></pre></div>
<a id="trunkbpsettingsbpsettingsactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-settings/bp-settings-actions.php (4841 => 4842)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-settings/bp-settings-actions.php        2011-07-24 22:30:53 UTC (rev 4841)
+++ trunk/bp-settings/bp-settings-actions.php        2011-07-24 22:51:38 UTC (rev 4842)
</span><span class="lines">@@ -7,7 +7,7 @@
</span><span class="cx"> function bp_core_screen_general_settings() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !empty( $bp-&gt;action_variables ) ) {
</del><ins>+        if ( bp_action_variables() ) {
</ins><span class="cx">                 bp_do_404();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -117,7 +117,7 @@
</span><span class="cx"> function bp_core_screen_notification_settings() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !empty( $bp-&gt;action_variables ) ) {
</del><ins>+        if ( bp_action_variables() ) {
</ins><span class="cx">                 bp_do_404();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -145,7 +145,7 @@
</span><span class="cx"> function bp_core_screen_delete_account() {
</span><span class="cx">         global $bp;
</span><span class="cx"> 
</span><del>-        if ( !empty( $bp-&gt;action_variables ) ) {
</del><ins>+        if ( bp_action_variables() ) {
</ins><span class="cx">                 bp_do_404();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span></span></pre>
</div>
</div>

</body>
</html>