Add application dirver
authorDuck (Jakob Munih) <duck@obala.net>
Sun, 15 Feb 2009 17:00:45 +0000 (18:00 +0100)
committerDuck (Jakob Munih) <duck@obala.net>
Sun, 15 Feb 2009 17:00:45 +0000 (18:00 +0100)
folks/lib/Friends/application.php [new file with mode: 0644]

diff --git a/folks/lib/Friends/application.php b/folks/lib/Friends/application.php
new file mode 100644 (file)
index 0000000..9f4b660
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+/**
+ * Folks external application firends implementaton
+ *
+ * $Horde: incubator/letter/lib/Friends/application.php,v 1.4 2009/01/28 19:13:56 duck Exp $
+ *
+ * Copyright 2008-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Duck <duck@obala.net>
+ * @package Folks
+ */
+class Folks_Friends_application extends Folks_Friends {
+
+    /**
+     * Add user to a friend list
+     *
+     * @param string $friend   Friend's usersame
+     */
+    protected function _addFriend($friend)
+    {
+        if (!$GLOBALS['registry']->hasMethod('addFriend', $this->_params['app'])) {
+            return PEAR::raiseError(_("Unsupported"));
+        }
+
+        return $GLOBALS['registry']->callByPackage(
+            $this->_params['app'], 'addFriend', array($friend));
+    }
+
+    /**
+     * Remove user from a fiend list
+     *
+     * @param string $friend   Friend's usersame
+     */
+    public function removeFriend($friend)
+    {
+        if (!$GLOBALS['registry']->hasMethod('removeFriend', $this->_params['app'])) {
+            return PEAR::raiseError(_("Unsupported"));
+        }
+
+        return $GLOBALS['registry']->callByPackage(
+            $this->_params['app'], 'removeFriend', array($friend));
+    }
+
+    /**
+     * Get user friends
+     *
+     * @return array of users
+     */
+    public function getFriends()
+    {
+        if (!$GLOBALS['registry']->hasMethod('getFriends', $this->_params['app'])) {
+            return PEAR::raiseError(_("Unsupported"));
+        }
+
+        return $GLOBALS['registry']->callByPackage(
+            $this->_params['app'], 'getFriends', array($this->_user));
+    }
+
+    /**
+     * Get user blacklist
+     *
+     * @return array of users blacklist
+     */
+    public function getBlacklist()
+    {
+        if (!$GLOBALS['registry']->hasMethod('getBlacklist', $this->_params['app'])) {
+            return PEAR::raiseError(_("Unsupported"));
+        }
+
+        return $GLOBALS['registry']->callByPackage(
+            $this->_params['app'], 'getBlacklist', array($this->_user));
+    }
+
+    /**
+     * Add user to a blacklist list
+     *
+     * @param string $user   Usersame
+     */
+    protected function _addBlacklisted($user)
+    {
+        if (!$GLOBALS['registry']->hasMethod('addBlacklisted', $this->_params['app'])) {
+            return PEAR::raiseError(_("Unsupported"));
+        }
+
+        return $GLOBALS['registry']->callByPackage(
+            $this->_params['app'], 'addBlacklisted', array($user));
+    }
+
+    /**
+     * Add user to a blacklist list
+     *
+     * @param string $user   Usersame
+     */
+    public function removeBlacklisted($user)
+    {
+        if (!$GLOBALS['registry']->hasMethod('removeBlacklisted', $this->_params['app'])) {
+            return PEAR::raiseError(_("Unsupported"));
+        }
+
+        return $GLOBALS['registry']->callByPackage(
+            $this->_params['app'], 'removeBlacklisted', array($user));
+    }
+
+    /**
+     * Get avaiable groups
+     */
+    public function getGroups()
+    {
+        if (!$GLOBALS['registry']->hasMethod('getGroups', $this->_params['app'])) {
+            return array();
+        }
+
+        return $GLOBALS['registry']->callByPackage(
+            $this->_params['app'], 'getGroups');
+    }
+}
\ No newline at end of file