* @var array $_params
*/
var $_params = array();
+ var $contexts = array();
// }}}
// {{{ Shout_Driver constructor
* 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.
$superadminPermName = "shout:superadmin";
if ($perms->exists($superadminPermName)) {
$superadmin = $perms->getPermissions($superadminPermName) &
- (PERMS_SHOW|PERMS_READ);
+ ($filterperms);
} else {
$superadmin = 0;
}
$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;
}
// }}}
/**
* 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 " .
$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'];
}
// }}}
+ // {{{
+ /**
+ * 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
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);
}
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.