Overview

Packages

  • Folks
  • None

Classes

  • Folks
  • Folks_Activity_Form
  • Folks_Api
  • Folks_Application
  • Folks_Block_Activities
  • Folks_Block_Friends
  • Folks_Block_Know
  • Folks_Block_New
  • Folks_Block_Random
  • Folks_Block_Recent
  • Folks_Driver
  • Folks_Driver_sql
  • Folks_Friends
  • Folks_Friends_application
  • Folks_Friends_facebook
  • Folks_Friends_prefs
  • Folks_Friends_shared
  • Folks_Friends_sql
  • Folks_Login_Form
  • Folks_Notification
  • Folks_Notification_facebook
  • Folks_Notification_letter
  • Folks_Notification_mail
  • Folks_Notification_tickets
  • Folks_Search_Form
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Folks application API.
  4:  *
  5:  * See the enclosed file LICENSE for license information (BSD). If you
  6:  * did not receive this file, see http://cvs.horde.org/co.php/folks/LICENSE.
  7:  *
  8:  * @package Folks
  9:  */
 10: class Folks_Application extends Horde_Registry_Application
 11: {
 12:     /**
 13:      */
 14:     public $auth = array(
 15:         'add',
 16:         'authenticate',
 17:         'exists',
 18:         'list',
 19:         'remove',
 20:         'resetpassword',
 21:         'transparent'
 22:     );
 23: 
 24:     /**
 25:      */
 26:     public $version = 'H4 (0.1-git)';
 27: 
 28:     /**
 29:      * Global variables defined:
 30:      * - $linkTags: <link> tags for common-header.inc.
 31:      */
 32:     protected function _init()
 33:     {
 34:         $links = array(Folks::getUrlFor('feed', 'online') => _("Online users"));
 35:         if ($GLOBALS['registry']->isAuthenticated()) {
 36:             $links[Folks::getUrlFor('feed', 'friends')] = _("Online friends");
 37:             $links[Folks::getUrlFor('feed', 'activity')] = _("Friends activity");
 38:             $links[Folks::getUrlFor('feed', 'know')] = _("People you might know");
 39:         }
 40: 
 41:         $GLOBALS['linkTags'] = array();
 42:         foreach ($links as $url => $label) {
 43:             $GLOBALS['linkTags'][] = '<link rel="alternate" type="application/rss+xml" href="' . $url . '" title="' . $label . '" />';
 44:         }
 45:     }
 46: 
 47:     /**
 48:      */
 49:     public function menu($menu)
 50:     {
 51:         return Folks::getMenu();
 52:     }
 53: 
 54:     /**
 55:      * @param array $credentials  Array of criedentials (password requied)
 56:      */
 57:     public function authAuthenticate($userID, $credentials)
 58:     {
 59:         require_once dirname(__FILE__) . '/base.php';
 60: 
 61:         $result = $GLOBALS['folks_driver']->comparePassword($userID, $credentials['password']);
 62:         if ($result !== true) {
 63:             throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN);
 64:         }
 65:     }
 66: 
 67:     /**
 68:      */
 69:     public function authTransparent($auth_ob)
 70:     {
 71:         if (empty($_COOKIE['folks_login_code']) ||
 72:             empty($_COOKIE['folks_login_user'])) {
 73:             return false;
 74:         }
 75: 
 76:         require_once dirname(__FILE__) . '/base.php';
 77:         $GLOBALS['folks_driver'] = Folks_Driver::factory();
 78:         if ($_COOKIE['folks_login_code'] == $GLOBALS['folks_driver']->getCookie($_COOKIE['folks_login_user'])) {
 79:             $GLOBALS['registry']->setAuth($_COOKIE['folks_login_user']);
 80:             $auth_ob->setCredential('userId', $_COOKIE['folks_login_user']);
 81:             $GLOBALS['folks_driver']->resetOnlineUsers();
 82:             return true;
 83:         }  else {
 84:             return false;
 85:         }
 86:     }
 87: 
 88:     /**
 89:      */
 90:     public function authUserExists($userId)
 91:     {
 92:         require_once dirname(__FILE__) . '/base.php';
 93: 
 94:         return $GLOBALS['folks_driver']->userExists($userId);
 95:     }
 96: 
 97:     /**
 98:      */
 99:     public function authUserList()
100:     {
101:         require_once dirname(__FILE__) . '/base.php';
102: 
103:         $users = array();
104:         foreach ($GLOBALS['folks_driver']->getUsers() as $user) {
105:             $users[] = $user['user_uid'];
106:         }
107: 
108:         return $users;
109:     }
110: 
111:     /**
112:      */
113:     public function authAddUser($userId, $credentials)
114:     {
115:         require_once dirname(__FILE__) . '/base.php';
116: 
117:         $result = $GLOBALS['folks_driver']->addUser($userId, $credentials);
118:         if ($result instanceof PEAR_Error) {
119:             throw new Horde_Exception_Wrapped($result);
120:         }
121:     }
122: 
123:     /**
124:      */
125:     public function authResetPassword($userId)
126:     {
127:         /* Get a new random password. */
128:         $password = Horde_Auth::genRandomPassword();
129: 
130:         /* Update password in DB. */
131:         require_once dirname(__FILE__) . '/base.php';
132:         $result = $GLOBALS['folks_driver']->changePassword($password, $userId);
133:         if ($result instanceof PEAR_Error) {
134:             throw new Horde_Auth_Exception($result);
135:         }
136: 
137:         return $password;
138:     }
139: 
140:     /**
141:      */
142:     public function authRemoveUser($userId)
143:     {
144:         require_once dirname(__FILE__) . '/base.php';
145: 
146:         return $GLOBALS['folks_driver']->deleteUser($userId);
147:     }
148: 
149:     /**
150:      */
151:     public function removeUserData($user = null)
152:     {
153:         return $this->authRemoveUser($user);
154:     }
155: 
156: }
157: 
API documentation generated by ApiGen