]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/actions/ostatusgroup.php
Debugging log fix.
[quix0rs-gnu-social.git] / plugins / OStatus / actions / ostatusgroup.php
index 4fcd0eb39a31a305f229a755ed66d19152636a19..c6010c6aec993f91dfd3bd8bdb1172e759d99ea0 100644 (file)
@@ -22,7 +22,9 @@
  * @maintainer Brion Vibber <brion@status.net>
  */
 
-if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET')) {
+    exit(1);
+}
 
 /**
  * Key UI methods:
@@ -56,10 +58,6 @@ class OStatusGroupAction extends OStatusSubAction
      */
     function showInputForm()
     {
-        $user = common_current_user();
-
-        $profile = $user->getProfile();
-
         $this->elementStart('form', array('method' => 'post',
                                           'id' => 'form_ostatus_sub',
                                           'class' => 'form_settings',
@@ -72,13 +70,17 @@ class OStatusGroupAction extends OStatusSubAction
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
         $this->input('profile',
-                     _m('Group profile URL'),
+                     // TRANS: Field label.
+                     _m('Join group'),
                      $this->profile_uri,
-                     _m('Enter the profile URL of a group on another StatusNet site'));
+                     // TRANS: Tooltip for field label "Join group". Do not translate the "example.net"
+                     // TRANS: domain name in the URL, as it is an official standard domain name for examples.
+                     _m("OStatus group's address, like http://example.net/group/nickname."));
         $this->elementEnd('li');
         $this->elementEnd('ul');
 
-        $this->submit('validate', _m('Continue'));
+        // TRANS: Button text.
+        $this->submit('validate', _m('BUTTON','Continue'));
 
         $this->elementEnd('fieldset');
 
@@ -91,20 +93,19 @@ class OStatusGroupAction extends OStatusSubAction
      */
     function preview()
     {
-        $oprofile = $this->oprofile;
-        $group = $oprofile->localGroup();
+        $group = $this->oprofile->localGroup();
 
-        $cur = common_current_user();
-        if ($cur->isMember($group)) {
+        if ($this->scoped->isMember($group)) {
             $this->element('div', array('class' => 'error'),
-                           _m("You are already a member of this group."));
+                           // TRANS: Error text displayed when trying to join a remote group the user is already a member of.
+                           _m('You are already a member of this group.'));
             $ok = false;
         } else {
             $ok = true;
         }
 
         $this->showEntity($group,
-                          $group->getProfileUrl(),
+                          $group->homeUrl(),
                           $group->homepage_logo,
                           $group->description);
         return $ok;
@@ -115,8 +116,7 @@ class OStatusGroupAction extends OStatusSubAction
      */
     function success()
     {
-        $cur = common_current_user();
-        $url = common_local_url('usergroups', array('nickname' => $cur->nickname));
+        $url = common_local_url('usergroups', array('nickname' => $this->scoped->getNickname()));
         common_redirect($url, 303);
     }
 
@@ -128,27 +128,24 @@ class OStatusGroupAction extends OStatusSubAction
      */
     function saveFeed()
     {
-        $user = common_current_user();
         $group = $this->oprofile->localGroup();
-        if ($user->isMember($group)) {
+        if ($this->scoped->isMember($group)) {
             // TRANS: OStatus remote group subscription dialog error.
             $this->showForm(_m('Already a member!'));
             return;
         }
 
-        if (Event::handle('StartJoinGroup', array($group, $user))) {
-            $ok = Group_member::join($this->oprofile->group_id, $user->id);
-            if ($ok) {
-                Event::handle('EndJoinGroup', array($group, $user));
-                $this->success();
-            } else {
-                // TRANS: OStatus remote group subscription dialog error.
-                $this->showForm(_m('Remote group join failed!'));
-            }
-        } else {
+        try {
+            $this->scoped->joinGroup($group);
+        } catch (Exception $e) {
+            common_log(LOG_ERR, "Exception on remote group join: " . $e->getMessage());
+            common_log(LOG_ERR, $e->getTraceAsString());
             // TRANS: OStatus remote group subscription dialog error.
-            $this->showForm(_m('Remote group join aborted!'));
+            $this->showForm(_m('Remote group join failed!'));
+            return;
         }
+
+        $this->success();
     }
 
     /**
@@ -156,7 +153,6 @@ class OStatusGroupAction extends OStatusSubAction
      *
      * @return string Title of the page
      */
-
     function title()
     {
         // TRANS: Page title for OStatus remote group join form
@@ -168,9 +164,9 @@ class OStatusGroupAction extends OStatusSubAction
      *
      * @return instructions for use
      */
-
     function getInstructions()
     {
+        // TRANS: Form instructions.
         return _m('You can subscribe to groups from other supported sites. Paste the group\'s profile URI below:');
     }