]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apigroupjoin.php
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
[quix0rs-gnu-social.git] / actions / apigroupjoin.php
index 345fed2215e7587d582a46605f2df578fd9c2721..6f3df0d8cd17a7274921c1f14cf65964b5654e28 100644 (file)
@@ -125,26 +125,14 @@ class ApiGroupJoinAction extends ApiAuthAction
             return;
         }
 
-        $member = new Group_member();
-
-        $member->group_id   = $this->group->id;
-        $member->profile_id = $this->user->id;
-        $member->created    = common_sql_now();
-
-        $result = $member->insert();
-
-        if (!$result) {
-            common_log_db_error($member, 'INSERT', __FILE__);
-            $this->serverError(
-                sprintf(
-                    // TRANS: Server error displayed when joining a group fails.
-                    // TRANS: %1$s is a user nickname, $2$s is a group nickname.
-                    _('Could not join user %1$s to group %2$s.'),
-                    $this->user->nickname,
-                    $this->group->nickname
-                )
-            );
-            return;
+        try {
+            $this->user->joinGroup($this->group);
+        } catch (Exception $e) {
+            // TRANS: Server error displayed when joining a group failed in the database.
+            // TRANS: %1$s is the joining user's nickname, $2$s is the group nickname for which the join failed.
+            $this->serverError(sprintf(_('Could not join user %1$s to group %2$s.'),
+                                       $cur->nickname, $this->group->nickname));
+                       return;
         }
 
         switch($this->format) {
@@ -156,7 +144,7 @@ class ApiGroupJoinAction extends ApiAuthAction
             break;
         default:
             $this->clientError(
-                // TRANS: Client error displayed trying to execute an unknown API method joining a group.
+                // TRANS: Client error displayed when coming across a non-supported API method.
                 _('API method not found.'),
                 404,
                 $this->format