]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
Logic to have group joins turn into pending joins automatically when group is set...
[quix0rs-gnu-social.git] / classes / Profile.php
index d4b288fa7a67e48c1bc3feefeba1cf6cdc25478d..57522d28dc98f4cab849385c0fa35173550f4a22 100644 (file)
@@ -313,6 +313,13 @@ class Profile extends Memcached_DataObject
         }
     }
 
+    function isPendingMember($group)
+    {
+        $request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
+                                                   'group_id' => $group->id));
+        return !empty($request);
+    }
+
     function getGroups($offset=0, $limit=null)
     {
         $qry =
@@ -360,6 +367,23 @@ class Profile extends Memcached_DataObject
         return $ok;
     }
 
+    /**
+     * Cancel a pending group join...
+     *
+     * @param User_group $group
+     */
+    function cancelJoinGroup(User_group $group)
+    {
+        $request = Group_join_queue::pkeyGet(array('profile_id' => $this->id,
+                                                   'group_id' => $group->id));
+        if ($request) {
+            if (Event::handle('StartCancelJoinGroup', array($group, $this))) {
+                $request->delete();
+                Event::handle('EndCancelJoinGroup', array($group, $this));
+            }
+        }
+    }
+
     /**
      * Leave a group that this profile is a member of.
      *