]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add returnto information to the block form
authorEvan Prodromou <evan@controlyourself.ca>
Mon, 8 Dec 2008 17:09:31 +0000 (12:09 -0500)
committerEvan Prodromou <evan@controlyourself.ca>
Mon, 8 Dec 2008 17:09:31 +0000 (12:09 -0500)
darcs-hash:20081208170931-5ed1f-e7c5853e6a222b04723f20c01ebaae15eeab3687.gz

actions/block.php
actions/showstream.php
lib/util.php

index b507af3249cf39e6867b5fa22c37318a9e18e746..8956b79ba5795dc0444f3475e4a1b8fc037c218d 100644 (file)
@@ -95,6 +95,12 @@ class BlockAction extends Action {
                                       'type' => 'hidden',
                                       'value' => $id));
 
+        foreach ($this->args as $k => $v) {
+            if (substr($k, 0, 9) == 'returnto-') {
+                common_hidden($k, $v);
+            }
+        }
+
         common_submit('no', _('No'));
         common_submit('yes', _('Yes'));
 
@@ -147,7 +153,21 @@ class BlockAction extends Action {
 
         $block->query('COMMIT');
 
-        common_redirect(common_local_url('subscribers',
-                                         array('nickname' => $cur->nickname)));
+        # Now, gotta figure where we go back to
+
+        foreach ($this->args as $k => $v) {
+            if ($k == 'returnto-action') {
+                $action = $v;
+            } else if (substr($k, 0, 9) == 'returnto-') {
+                $args[$k] = substr($k, 9);
+            }
+        }
+
+        if ($action) {
+            common_redirect(common_local_url($action, $args));
+        } else {
+            common_redirect(common_local_url('subscriptions',
+                                             array('nickname' => $cur->nickname)));
+        }
     }
 }
index e12a227e3bdef339ff7dbcf6da7d10bdaeb47a6d..0fc3978110b072eaef33569f3d672ca345906fd6 100644 (file)
@@ -203,8 +203,15 @@ class ShowstreamAction extends StreamAction {
                common_profile_new_message_nudge($cur, $user, $profile);
 
         if ($cur) {
-            common_element_start('li', array('id' => 'profile_block'));
-            common_block_form($profile);
+            $blocked = $cur->hasBlocked($profile);
+            common_element_start('li', array('id' => ($blocked) ? 'profile_unblock' : 'profile_block'));
+            if ($blocked) {
+#                common_unblock_form($profile, array('action' => 'showstream',
+#                                                    'nickname' => $profile->nickname));
+            } else {
+                common_block_form($profile, array('action' => 'showstream',
+                                                  'nickname' => $profile->nickname));
+            }
             common_element_end('li');
         }
 
index fa8248dba49f5e76e8a522b7423f4540a87e95d2..4d670edcc157a059aa84edcc67247e9529b3fde4 100644 (file)
@@ -2185,7 +2185,7 @@ function common_compatible_license($from, $to) {
        return ($from == $to);
 }
 
-function common_block_form($profile) {
+function common_block_form($profile, $args=NULL) {
     common_element_start('form', array('id' => 'block-' . $profile->id,
                                        'method' => 'post',
                                        'class' => 'block',
@@ -2199,6 +2199,11 @@ function common_block_form($profile) {
                                   'class' => 'submit',
                                   'name' => 'block',
                                   'value' => _('Block')));
+    if ($args) {
+        foreach ($args as $k => $v) {
+            common_hidden('returnto-' . $k, $v);
+        }
+    }
     common_element_end('form');
     return;
 }