]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/util.php
add returnto information to the block form
[quix0rs-gnu-social.git] / lib / util.php
index ab683d1a2a0f6d4a4709df3fd5213871d0d254f4..4d670edcc157a059aa84edcc67247e9529b3fde4 100644 (file)
@@ -1081,6 +1081,7 @@ function common_fancy_url($action, $args=NULL) {
                 }
         case 'doc':
                return common_path('doc/'.$args['title']);
+     case 'block':
         case 'login':
         case 'logout':
         case 'subscribe':
@@ -1401,6 +1402,11 @@ function common_save_replies($notice) {
                                $notice->update($orig);
                        }
                }
+        # Don't save replies from blocked profile to local user
+        $recipient_user = User::staticGet('id', $recipient->id);
+        if ($recipient_user && $recipient_user->hasBlocked($sender)) {
+            continue;
+        }
                $reply = new Reply();
                $reply->notice_id = $notice->id;
                $reply->profile_id = $recipient->id;
@@ -1422,6 +1428,11 @@ function common_save_replies($notice) {
                        $tagged = Profile_tag::getTagged($sender->id, $tag);
                        foreach ($tagged as $t) {
                                if (!$replied[$t->id]) {
+                    # Don't save replies from blocked profile to local user
+                    $t_user = User::staticGet('id', $t->id);
+                    if ($t_user && $t_user->hasBlocked($sender)) {
+                        continue;
+                    }
                                        $reply = new Reply();
                                        $reply->notice_id = $notice->id;
                                        $reply->profile_id = $t->id;
@@ -2050,15 +2061,15 @@ function common_nudge_response() {
 }
 
 function common_subscribe_form($profile) {
-       common_element_start('form', array('id' => 'subscribe-' . $profile->nickname,
+       common_element_start('form', array('id' => 'subscribe-' . $profile->id,
                                                                           'method' => 'post',
                                                                           'class' => 'subscribe',
                                                                           'action' => common_local_url('subscribe')));
        common_hidden('token', common_session_token());
-       common_element('input', array('id' => 'subscribeto-' . $profile->nickname,
+       common_element('input', array('id' => 'subscribeto-' . $profile->id,
                                                                  'name' => 'subscribeto',
                                                                  'type' => 'hidden',
-                                                                 'value' => $profile->nickname));
+                                                                 'value' => $profile->id));
        common_element('input', array('type' => 'submit',
                                                                  'class' => 'submit',
                                                                  'value' => _('Subscribe')));
@@ -2173,3 +2184,26 @@ function common_compatible_license($from, $to) {
        # XXX: better compatibility check needed here!
        return ($from == $to);
 }
+
+function common_block_form($profile, $args=NULL) {
+    common_element_start('form', array('id' => 'block-' . $profile->id,
+                                       'method' => 'post',
+                                       'class' => 'block',
+                                       'action' => common_local_url('block')));
+    common_hidden('token', common_session_token());
+    common_element('input', array('id' => 'blockto-' . $profile->id,
+                                  'name' => 'blockto',
+                                  'type' => 'hidden',
+                                  'value' => $profile->id));
+    common_element('input', array('type' => 'submit',
+                                  'class' => 'submit',
+                                  'name' => 'block',
+                                  'value' => _('Block')));
+    if ($args) {
+        foreach ($args as $k => $v) {
+            common_hidden('returnto-' . $k, $v);
+        }
+    }
+    common_element_end('form');
+    return;
+}