From: Ben Klang Date: Fri, 1 Jul 2005 14:34:27 +0000 (+0000) Subject: Missed these files. Does cervisia suck or what? X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8d76011220f1638487ede64c72732ca4a9310d04;p=horde.git Missed these files. Does cervisia suck or what? git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@42 06cd67b6-e706-0410-b29e-9de616bca6e9 --- diff --git a/lib/Driver.php b/lib/Driver.php index 8e567c15a..dedafe841 100644 --- a/lib/Driver.php +++ b/lib/Driver.php @@ -25,6 +25,7 @@ class Shout_Driver { * @var array $_params */ var $_params = array(); + var $contexts = array(); // }}} // {{{ Shout_Driver constructor @@ -39,17 +40,26 @@ class Shout_Driver { * Get a list of contexts from the instantiated driver and filter * the returned contexts for those which the current user can see/edit * + * @param optional string $filter Filter for types of contexts to return. + * One of "system" "customer" or "all" + * + * @param optional string $filterperms Filter contexts for given permissions + * * @return array Contexts valid for this user * * @access public */ - function getContexts() + function getContexts($filter = "all", $filterperms = null) { # Initialize array to be returned $retcontexts = array(); + if ($filterperms == null) { + $filterperms = PERMS_SHOW|PERMS_READ; + } + # Collect the master list of contexts from the backend - $contexts = $this->_getContexts(); + $contexts = $this->_getContexts($filter); # Narrow down the list of contexts to those valid for this user. @@ -58,7 +68,7 @@ class Shout_Driver { $superadminPermName = "shout:superadmin"; if ($perms->exists($superadminPermName)) { $superadmin = $perms->getPermissions($superadminPermName) & - (PERMS_SHOW|PERMS_READ); + ($filterperms); } else { $superadmin = 0; } @@ -67,16 +77,16 @@ class Shout_Driver { $permName = "shout:contexts:".$context; if ($perms->exists($permName)) { $userperms = $perms->getPermissions($permName) & - (PERMS_SHOW|PERMS_READ); + ($filterperms); } else { $userperms = 0; } - if ((($userperms | $superadmin) ^ (PERMS_SHOW|PERMS_READ)) == 0) { - $retcontexts[] = $context; + if ((($userperms | $superadmin) ^ ($filterperms)) == 0) { + $this->contexts[] = $context; } } - return $retcontexts; + return $this->contexts; } // }}} diff --git a/lib/Driver/ldap.php b/lib/Driver/ldap.php index 0b8b6b96a..31f91b8f1 100644 --- a/lib/Driver/ldap.php +++ b/lib/Driver/ldap.php @@ -36,16 +36,31 @@ class Shout_Driver_ldap extends Shout_Driver /** * Get a list of contexts from the backend * + * @param string $filter Search filter + * * @return array Contexts valid for this system * * @access private */ - function _getContexts() + function _getContexts($filter = "both") { + switch ($filter) { + case "customer": + $searchfilter="(objectClass=vofficeCustomer)"; + break; + case "system": + $searchfilter="(!(objectClass=vofficeCustomer))"; + break; + case "all": + default: + $searchfilter=""; + break; + } + # Collect all the possible contexts from the backend $res = ldap_search($this->_LDAP, SHOUT_ASTERISK_BRANCH.','.$this->_params['basedn'], - '(&(objectClass=asteriskObject))', + "(&(objectClass=asteriskObject))", array('context')); if (!$res) { return PEAR::raiseError("Unable to locate any customers " . @@ -89,37 +104,20 @@ class Shout_Driver_ldap extends Shout_Driver $entries = array(); $i = 0; while ($i < $res['count']) { - # FIXME Add method to handle this ldap silliness $extension = $res[$i]['voicemailbox'][0]; $entries[$extension] = array(); - if ($res[$i]['asteriskuserdialoptions']['count'] > 0) { - $entries[$extension]['dialopts'] = - $res[$i]['asteriskuserdialoptions']; - } else { - $entries[$extension]['dialopts'] = null; - } + $entries[$extension]['dialopts'] = + $res[$i]['asteriskuserdialoptions']; - if ($res[$i]['asteriskvoicemailboxoptions']['count'] > 0) { - $entries[$extension]['mailboxopts'] = - $res[$i]['asteriskvoicemailboxoptions']; - } else { - $entries[$extension]['mailboxopts'] = null; - } + $entries[$extension]['mailboxopts'] = + $res[$i]['asteriskvoicemailboxoptions']; - if ($res[$i]['voicemailboxpin']['count'] > 0) { - $entries[$extension]['mailboxpin'] = - $res[$i]['voicemailboxpin'][0]; - } else { - $entries[$extension]['mailboxpin'] = null; - } + $entries[$extension]['mailboxpin'] = + $res[$i]['voicemailboxpin'][0]; - if ($res[$i]['cn']['count'] > 0) { - $entries[$extension]['name'] = - $res[$i]['cn'][0]; - } else { - $entries[$extension]['name'] = null; - } + $entries[$extension]['name'] = + $res[$i]['cn'][0]; $entries[$extension]['phonenumbers'] = $res[$i]['telephonenumber']; diff --git a/lib/Shout.php b/lib/Shout.php index b2bdbb36c..bd9bae709 100644 --- a/lib/Shout.php +++ b/lib/Shout.php @@ -56,5 +56,38 @@ null, $cellclass); } // }}} + // {{{ + /** + * Generate the tabs at the top of each Shout pages + * + * @param &$vars Reference to the passed in variables + * + * @return object Horde_UI_Tabs + */ + function &getTabs(&$vars) + { + global $shout; + if (!Auth::isAdmin("shout", PERMS_SHOW|PERMS_READ)) { + return false; + } + $tabs = &new Horde_UI_Tabs('section', $vars); + if (count($shout->contexts) > 1 || + Auth::isAdmin("shout:superadmin", PERMS_SHOW|PERMS_READ)) { + $tabs->addTab(_("Contexts"), + Horde::applicationUrl('index.php'), 'contexts'); + } + $tabs->addTab(_("Users"), + Horde::applicationUrl('index.php'), 'users'); + $tabs->addTab(_("Music on Hold"), + Horde::applicationUrl('index.php'), 'moh'); + // $tabs->addTab(_("Watch"), Horde::applicationUrl('ticket/watch.php')); + if (Auth::isAdmin('shout:superadmin', PERMS_READ|PERMS_SHOW)) { + $tabs->addTab(_("Global Settings"), + Horde::applicationUrl('index.php'), 'global'); + } + + return $tabs; + } + } // }}} \ No newline at end of file diff --git a/lib/base.php b/lib/base.php index 6d968e25a..0e1c3d6ec 100644 --- a/lib/base.php +++ b/lib/base.php @@ -21,7 +21,7 @@ $registry = &Registry::singleton(); if (is_a(($pushed = $registry->pushApp('shout', !defined('AUTH_HANDLER'))), 'PEAR_Error')) { if ($pushed->getCode() == 'permission_denied') { - Horde::authenticationFailureRedirect(); + Horde::authenticationFailureRedirect(); } Horde::fatal($pushed, __FILE__, __LINE__, false); } @@ -39,6 +39,13 @@ $notification->attach('status'); require_once SHOUT_BASE . '/lib/Shout.php'; require_once SHOUT_BASE . '/lib/Driver.php'; +// Form libraries. +require_once 'Horde/Form.php'; +require_once 'Horde/Form/Renderer.php'; + +// UI classes. +require_once 'Horde/UI/Tabs.php'; + $GLOBALS['shout'] = &Shout_Driver::singleton(); // Horde libraries.