Overview

Packages

  • Agora
  • None

Classes

  • Agora_Application
  • Agora_Block_Forums
  • Agora_Block_Thread
  • Agora_Block_Threads
  • Agora_Tree_Flat
  • Agora_ViewComments

Functions

  • handle_avatarselect
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Agora external API interface.
  4:  *
  5:  * This file defines Horde's core API interface. Other core Horde libraries
  6:  * can interact with Agora through this API.
  7:  *
  8:  * Copyright 2003-2012 Horde LLC (http://www.horde.org/)
  9:  *
 10:  * See the enclosed file COPYING for license information (GPL). If you
 11:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 12:  *
 13:  * @author  Marko Djukic <marko@oblo.com>
 14:  * @author  Duck <duck@obala.net>
 15:  * @package Agora
 16:  */
 17: 
 18: /* Determine the base directories. */
 19: if (!defined('AGORA_BASE')) {
 20:     define('AGORA_BASE', dirname(__FILE__) . '/..');
 21: }
 22: 
 23: if (!defined('HORDE_BASE')) {
 24:     /* If Horde does not live directly under the app directory, the HORDE_BASE
 25:      * constant should be defined in config/horde.local.php. */
 26:     if (file_exists(AGORA_BASE . '/config/horde.local.php')) {
 27:         include AGORA_BASE . '/config/horde.local.php';
 28:     } else {
 29:         define('HORDE_BASE', AGORA_BASE . '/..');
 30:     }
 31: }
 32: 
 33: /* Load the Horde Framework core (needed to autoload
 34:  * Horde_Registry_Application::). */
 35: require_once HORDE_BASE . '/lib/core.php';
 36: 
 37: class Agora_Application extends Horde_Registry_Application
 38: {
 39:     /**
 40:      */
 41:     public $version = 'H4 (1.0-git)';
 42: 
 43:     /**
 44:      */
 45:     public function perms()
 46:     {
 47:         $perms = array(
 48:             'admin' => array(
 49:                 'title' => _("Admin")
 50:             ),
 51:             'forums' => array(
 52:                 'title' => _("Forums")
 53:             )
 54:         );
 55:         foreach ($GLOBALS['registry']->listApps() as $scope) {
 56:             $perms['forums:' . $scope] = array(
 57:                 'title' => $GLOBALS['registry']->get('name', $scope)
 58:             );
 59: 
 60:             $forums = $GLOBALS['injector']->getInstance('Agora_Factory_Driver')->create($scope);
 61:             try {
 62:                 $forums_list = $forums->getBareForums();
 63:                 foreach ($forums_list as $id => $title) {
 64:                     $perms['forums:' . $scope . ':' . $id] = array(
 65:                         'title' => $title
 66:                     );
 67:                 }
 68:             } catch (Horde_Db_Exception $e) {
 69:                 throw new Agora_Exception($e->getMessage());
 70:             }
 71:         }
 72: 
 73:         return $perms;
 74:     }
 75: 
 76:     /**
 77:      */
 78:     public function menu($menu)
 79:     {
 80:         $scope = Horde_Util::getGet('scope', 'agora');
 81: 
 82:         /* Agora Home. */
 83:         $url = Horde::url('forums.php')->add('scope', $scope);
 84:         $menu->add($url, _("_Forums"), 'forums.png', null, null, null,
 85:                    dirname($_SERVER['PHP_SELF']) == $GLOBALS['registry']->get('webroot') && basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
 86: 
 87:         /* Thread list, if applicable. */
 88:         if (isset($GLOBALS['forum_id'])) {
 89:             $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('threads.php')), _("_Threads"), 'threads.png');
 90:             if ($scope == 'agora' && $GLOBALS['registry']->getAuth()) {
 91:                 $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('messages/edit.php')), _("New Thread"), 'newmessage.png');
 92:             }
 93:         }
 94: 
 95:         if ($scope == 'agora' &&
 96:             Agora_Driver::hasPermission(Horde_Perms::DELETE, 0, $scope)) {
 97:             $menu->add(Horde::url('editforum.php'), _("_New Forum"), 'newforum.png', null, null, null, Horde_Util::getFormData('agora') ? '__noselection' : null);
 98:         }
 99: 
100:         if (Agora_Driver::hasPermission(Horde_Perms::DELETE, 0, $scope)) {
101:             $url = Horde::url('moderate.php')->add('scope', $scope);
102:             $menu->add($url, _("_Moderate"), 'moderate.png');
103:         }
104: 
105:         if ($GLOBALS['registry']->isAdmin()) {
106:             $menu->add(Horde::url('moderators.php'), _("_Moderators"), 'hot.png');
107:         }
108: 
109:         $url = Horde::url('search.php')->add('scope', $scope);
110:         $menu->add($url, _("_Search"), 'search.png');
111:     }
112: 
113:     /**
114:      */
115:     public function prefsInit($ui)
116:     {
117:         /* Hide prefGroups. */
118:         if (!$GLOBALS['conf']['avatar']['allow_avatars']) {
119:             $ui->suppressGroups[] = 'display_avatar';
120:         }
121:     }
122: 
123:     /**
124:      */
125:     public function prefsGroup($ui)
126:     {
127:         foreach ($ui->getChangeablePrefs() as $val) {
128:             switch ($val) {
129:             case 'avatar_link':
130:                 $vfs = Agora::getVFS();
131:                 if (($vfs instanceof PEAR_Error) ||
132:                     !$GLOBALS['conf']['avatar']['enable_gallery'] ||
133:                     !$vfs->isFolder(Agora::AVATAR_PATH, 'gallery')) {
134:                     $ui->suppress[] = 'avatar_link';
135:                 } else {
136:                     Horde::addScriptFile('popup.js', 'horde', true);
137:                 }
138:                 break;
139:             }
140:         }
141:     }
142: 
143:     /**
144:      */
145:     public function prefsSpecial($ui, $item)
146:     {
147:         switch ($item) {
148:         case 'avatarselect':
149:             return $this->_accountsManagement($ui);
150:         }
151: 
152:         return '';
153:     }
154: 
155: }
156: 
API documentation generated by ApiGen