]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/atompubshowmembership.php
Email notify-on-fave moved to Profile_prefs (run upgrade.php)
[quix0rs-gnu-social.git] / actions / atompubshowmembership.php
index 6d848a2290e36e8890307b022cbcac97e23316cd..ad6aa6c1d05db3bf00bf0ec3bff912a01a27235a 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2010, StatusNet, Inc.
  *
  * Show a single membership as an Activity Streams entry
- * 
+ *
  * PHP version 5
  *
  * This program is free software: you can redistribute it and/or modify
@@ -34,8 +34,6 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR . '/lib/apiauth.php';
-
 /**
  * Show (or delete) a single membership event as an ActivityStreams entry
  *
@@ -46,7 +44,6 @@ require_once INSTALLDIR . '/lib/apiauth.php';
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  * @link      http://status.net/
  */
-
 class AtompubshowmembershipAction extends ApiAuthAction
 {
     private $_profile    = null;
@@ -60,25 +57,26 @@ class AtompubshowmembershipAction extends ApiAuthAction
      *
      * @return boolean true
      */
-
     function prepare($argarray)
     {
         parent::prepare($argarray);
 
         $profileId = $this->trimmed('profile');
 
-        $this->_profile = Profile::staticGet('id', $profileId);
-        
+        $this->_profile = Profile::getKV('id', $profileId);
+
         if (empty($this->_profile)) {
+            // TRANS: Client exception.
             throw new ClientException(_('No such profile.'), 404);
         }
 
         $groupId = $this->trimmed('group');
 
-        $this->_group = User_group::staticGet('id', $groupId);
+        $this->_group = User_group::getKV('id', $groupId);
 
         if (empty($this->_group)) {
-            throw new ClientException(_('No such group'), 404);
+            // TRANS: Client exception thrown when referencing a non-existing group.
+            throw new ClientException(_('No such group.'), 404);
         }
 
         $kv = array('group_id' => $groupId,
@@ -87,7 +85,8 @@ class AtompubshowmembershipAction extends ApiAuthAction
         $this->_membership = Group_member::pkeyGet($kv);
 
         if (empty($this->_membership)) {
-            throw new ClientException(_('Not a member'), 404);
+            // TRANS: Client exception thrown when trying to show membership of a non-subscribed group
+            throw new ClientException(_('Not a member.'), 404);
         }
 
         return true;
@@ -100,7 +99,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
      *
      * @return void
      */
-
     function handle($argarray=null)
     {
         switch ($_SERVER['REQUEST_METHOD']) {
@@ -112,7 +110,8 @@ class AtompubshowmembershipAction extends ApiAuthAction
             $this->deleteMembership();
             break;
         default:
-            throw new ClientException(_('Method not supported'), 405);
+            // TRANS: Client exception thrown when using an unsupported HTTP method.
+            throw new ClientException(_('HTTP method not supported.'), 405);
             break;
         }
         return;
@@ -123,7 +122,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
      *
      * @return void
      */
-
     function showMembership()
     {
         $activity = $this->_membership->asActivity();
@@ -142,19 +140,16 @@ class AtompubshowmembershipAction extends ApiAuthAction
      *
      * @return void
      */
-
     function deleteMembership()
     {
         if (empty($this->auth_user) ||
             $this->auth_user->id != $this->_profile->id) {
-            throw new ClientException(_("Can't delete someone else's".
-                                        " membership"), 403);
+            // TRANS: Client exception thrown when deleting someone else's membership.
+            throw new ClientException(_("Cannot delete someone else's".
+                                        " membership."), 403);
         }
 
-        if (Event::handle('StartLeaveGroup', array($this->_group, $this->auth_user))) {
-            Group_member::leave($this->_group->id, $this->auth_user->id);
-            Event::handle('EndLeaveGroup', array($this->_group, $this->auth_user));
-        }
+        $this->auth_user->leaveGroup($this->_group);
 
         return;
     }
@@ -168,7 +163,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
      *
      * @return boolean is read only action?
      */
-
     function isReadOnly($args)
     {
         if ($_SERVER['REQUEST_METHOD'] == 'GET' ||
@@ -203,7 +197,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
      *
      * @return string etag http header
      */
-
     function etag()
     {
         $ctime = strtotime($this->_membership->created);
@@ -222,7 +215,6 @@ class AtompubshowmembershipAction extends ApiAuthAction
      *
      * @return boolean true if delete, else false
      */
-
     function requiresAuth()
     {
         if ($_SERVER['REQUEST_METHOD'] == 'GET' ||