From: Michael M Slusarz Date: Tue, 11 Aug 2009 21:07:49 +0000 (-0600) Subject: Move perms() into Horde_Registry_Application X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6e74ba4cc5c33562bd227d08be7c7709522b6763;p=horde.git Move perms() into Horde_Registry_Application --- diff --git a/ansel/lib/Api.php b/ansel/lib/Api.php index 51fa72816..8fcd2fc1d 100644 --- a/ansel/lib/Api.php +++ b/ansel/lib/Api.php @@ -15,20 +15,6 @@ class Ansel_Api extends Horde_Registry_Api { /** - * Returns a list of available permissions. - * - * @return array An array describing all available permissions. - */ - public function perms() - { - $perms = array(); - $perms['tree']['ansel']['admin'] = false; - $perms['title']['ansel:admin'] = _("Administrators"); - - return $perms; - } - - /** * Browse through Ansel's gallery tree. * * @param string $path The level of the tree to browse. diff --git a/ansel/lib/Application.php b/ansel/lib/Application.php index 9b521a54e..ebe2d9799 100644 --- a/ansel/lib/Application.php +++ b/ansel/lib/Application.php @@ -17,6 +17,20 @@ class Ansel_Application extends Horde_Registry_Application public $version = 'H4 (2.0-git)'; /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + $perms = array(); + $perms['tree']['ansel']['admin'] = false; + $perms['title']['ansel:admin'] = _("Administrators"); + + return $perms; + } + + /** * Special preferences handling on update. * * @param string $item The preference name. diff --git a/babel/lib/Api.php b/babel/lib/Api.php deleted file mode 100644 index 6e7cb5b07..000000000 --- a/babel/lib/Api.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @package Babel - */ -class Babel_Api extends Horde_Registry_Api -{ - public function perms() - { - global $registry; - - static $perms = array(); - if (!empty($perms)) { - return $perms; - } - - $perms['tree']['babel']['language'] = array(); - $perms['title']['babel:language'] = _("Languages"); - $perms['type']['babel:language'] = 'none'; - - foreach(Horde_Nls::$config['languages'] as $langcode => $langdesc) { - $perms['tree']['babel']['language'][$langcode] = false; - $perms['title']['babel:language:' . $langcode] = sprintf("%s (%s)", $langdesc, $langcode); - $perms['type']['babel:language:' . $langcode] = 'boolean'; - } - - $perms['tree']['babel']['module'] = array(); - $perms['title']['babel:module'] = _("Modules"); - $perms['type']['babel:module'] = 'none'; - - foreach ($registry->applications as $app => $params) { - if ($params['status'] == 'heading' || $params['status'] == 'block') { - continue; - } - - if (isset($params['fileroot']) && !is_dir($params['fileroot'])) { - continue; - } - - if (preg_match('/_reports$/', $app) || preg_match('/_tools$/', $app)) { - continue; - } - - $perms['tree']['babel']['module'][$app] = false; - $perms['title']['babel:module:' . $app] = sprintf("%s (%s)", $params['name'], $app); - $perms['type']['babel:module:' . $app] = 'boolean'; - } - - $tabdesc['download'] = _("Download"); - $tabdesc['upload'] = _("Upload"); - $tabdesc['stats'] = _("Statistics"); - $tabdesc['view'] = _("View/Edit"); - $tabdesc['viewsource'] = _("View Source"); - $tabdesc['extract'] = _("Extract"); - $tabdesc['make'] = _("Make"); - $tabdesc['commit'] = _("Commit"); - $tabdesc['reset'] = _("Reset"); - - foreach ($tabdesc as $cat => $desc) { - $perms['tree']['babel'][$cat] = array(); - $perms['title']['babel:' . $cat] = $desc; - } - - return $perms; - } - -} diff --git a/babel/lib/Application.php b/babel/lib/Application.php index c288dc9cf..9eb88961b 100644 --- a/babel/lib/Application.php +++ b/babel/lib/Application.php @@ -10,4 +10,69 @@ class Babel_Application extends Horde_Registry_Application { public $version = 'H4 (0.1-git)'; + + /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + global $registry; + + static $perms = array(); + if (!empty($perms)) { + return $perms; + } + + $perms['tree']['babel']['language'] = array(); + $perms['title']['babel:language'] = _("Languages"); + $perms['type']['babel:language'] = 'none'; + + foreach(Horde_Nls::$config['languages'] as $langcode => $langdesc) { + $perms['tree']['babel']['language'][$langcode] = false; + $perms['title']['babel:language:' . $langcode] = sprintf("%s (%s)", $langdesc, $langcode); + $perms['type']['babel:language:' . $langcode] = 'boolean'; + } + + $perms['tree']['babel']['module'] = array(); + $perms['title']['babel:module'] = _("Modules"); + $perms['type']['babel:module'] = 'none'; + + foreach ($registry->applications as $app => $params) { + if ($params['status'] == 'heading' || $params['status'] == 'block') { + continue; + } + + if (isset($params['fileroot']) && !is_dir($params['fileroot'])) { + continue; + } + + if (preg_match('/_reports$/', $app) || preg_match('/_tools$/', $app)) { + continue; + } + + $perms['tree']['babel']['module'][$app] = false; + $perms['title']['babel:module:' . $app] = sprintf("%s (%s)", $params['name'], $app); + $perms['type']['babel:module:' . $app] = 'boolean'; + } + + $tabdesc['download'] = _("Download"); + $tabdesc['upload'] = _("Upload"); + $tabdesc['stats'] = _("Statistics"); + $tabdesc['view'] = _("View/Edit"); + $tabdesc['viewsource'] = _("View Source"); + $tabdesc['extract'] = _("Extract"); + $tabdesc['make'] = _("Make"); + $tabdesc['commit'] = _("Commit"); + $tabdesc['reset'] = _("Reset"); + + foreach ($tabdesc as $cat => $desc) { + $perms['tree']['babel'][$cat] = array(); + $perms['title']['babel:' . $cat] = $desc; + } + + return $perms; + } + } diff --git a/chora/lib/Api.php b/chora/lib/Api.php deleted file mode 100644 index 25a764fdf..000000000 --- a/chora/lib/Api.php +++ /dev/null @@ -1,34 +0,0 @@ - $srconfig) { - $perms['tree']['chora']['sourceroots'][$sourceroot] = false; - $perms['title']['chora:sourceroots:' . $sourceroot] = $srconfig['name']; - } - - return $perms; - } - -} diff --git a/chora/lib/Application.php b/chora/lib/Application.php index 8eee94307..7a9309ee1 100644 --- a/chora/lib/Application.php +++ b/chora/lib/Application.php @@ -17,6 +17,33 @@ class Chora_Application extends Horde_Registry_Application public $version = 'H4 (3.0-git)'; /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + static $perms = array(); + + if (!empty($perms)) { + return $perms; + } + + require_once dirname(__FILE__) . '/../config/sourceroots.php'; + + $perms['tree']['chora']['sourceroots'] = false; + $perms['title']['chora:sourceroots'] = _("Repositories"); + + // Run through every source repository + foreach ($sourceroots as $sourceroot => $srconfig) { + $perms['tree']['chora']['sourceroots'][$sourceroot] = false; + $perms['title']['chora:sourceroots:' . $sourceroot] = $srconfig['name']; + } + + return $perms; + } + + /** * Generate the menu to use on the prefs page. * * @return Horde_Menu A Horde_Menu object. diff --git a/gollem/lib/Api.php b/gollem/lib/Api.php index d1e1849f6..d3a5377f7 100644 --- a/gollem/lib/Api.php +++ b/gollem/lib/Api.php @@ -13,31 +13,6 @@ class Gollem_Api extends Horde_Registry_Api { /** - * TODO - */ - public function perms() - { - static $perms = array(); - if (!empty($perms)) { - return $perms; - } - - require_once dirname(__FILE__) . '/base.load.php'; - require GOLLEM_BASE . '/config/backends.php'; - - $perms['tree']['gollem']['backends'] = false; - $perms['title']['gollem:backends'] = _("Backends"); - - // Run through every backend. - foreach ($backends as $backend => $curBackend) { - $perms['tree']['gollem']['backends'][$backend] = false; - $perms['title']['gollem:backends:' . $backend] = $curBackend['name']; - } - - return $perms; - } - - /** * Browses through the VFS tree. * * Each VFS backend is listed as a directory at the top level. No modify diff --git a/gollem/lib/Application.php b/gollem/lib/Application.php index 1fd3fd594..c7649a166 100644 --- a/gollem/lib/Application.php +++ b/gollem/lib/Application.php @@ -20,6 +20,33 @@ class Gollem_Application extends Horde_Registry_Application public $version = 'H4 (2.0-git)'; /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + static $perms = array(); + if (!empty($perms)) { + return $perms; + } + + require_once dirname(__FILE__) . '/base.load.php'; + require GOLLEM_BASE . '/config/backends.php'; + + $perms['tree']['gollem']['backends'] = false; + $perms['title']['gollem:backends'] = _("Backends"); + + // Run through every backend. + foreach ($backends as $backend => $curBackend) { + $perms['tree']['gollem']['backends'][$backend] = false; + $perms['title']['gollem:backends:' . $backend] = $curBackend['name']; + } + + return $perms; + } + + /** * Special preferences handling on update. * * @param string $item The preference name. diff --git a/imp/lib/Api.php b/imp/lib/Api.php index f90dd63c1..4153b8d4e 100644 --- a/imp/lib/Api.php +++ b/imp/lib/Api.php @@ -12,41 +12,6 @@ */ class IMP_Api extends Horde_Registry_Api { - /* Horde-defined functions. */ - - /** - * Returns a list of available permissions. - * - * @return array The permissions list. - */ - public function perms() - { - return array( - 'tree' => array( - 'imp' => array( - 'create_folders' => false, - 'max_folders' => false, - 'max_recipients' => false, - 'max_timelimit' => false, - ), - ), - 'title' => array( - 'imp:create_folders' => _("Allow Folder Creation?"), - 'imp:max_folders' => _("Maximum Number of Folders"), - 'imp:max_recipients' => _("Maximum Number of Recipients per Message"), - 'imp:max_timelimit' => _("Maximum Number of Recipients per Time Period"), - ), - 'type' => array( - 'imp:create_folders' => 'boolean', - 'imp:max_folders' => 'int', - 'imp:max_recipients' => 'int', - 'imp:max_timelimit' => 'int', - ) - ); - } - - /* IMP-specific functions. */ - /** * Returns a compose window link. * diff --git a/imp/lib/Application.php b/imp/lib/Application.php index ef3842c0c..1cc52bb8c 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -162,6 +162,39 @@ class IMP_Application extends Horde_Registry_Application IMP::initialize(); } + /* Horde permissions. */ + + /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + return array( + 'tree' => array( + 'imp' => array( + 'create_folders' => false, + 'max_folders' => false, + 'max_recipients' => false, + 'max_timelimit' => false, + ), + ), + 'title' => array( + 'imp:create_folders' => _("Allow Folder Creation?"), + 'imp:max_folders' => _("Maximum Number of Folders"), + 'imp:max_recipients' => _("Maximum Number of Recipients per Message"), + 'imp:max_timelimit' => _("Maximum Number of Recipients per Time Period"), + ), + 'type' => array( + 'imp:create_folders' => 'boolean', + 'imp:max_folders' => 'int', + 'imp:max_recipients' => 'int', + 'imp:max_timelimit' => 'int', + ) + ); + } + /* Horde_Auth_Application methods. */ /** diff --git a/ingo/lib/Api.php b/ingo/lib/Api.php index b874ccfe0..0724132d0 100644 --- a/ingo/lib/Api.php +++ b/ingo/lib/Api.php @@ -23,31 +23,6 @@ class Ingo_Api extends Horde_Registry_Api ); /** - * Returns a list of available permissions. - * - * @return array An array describing all available permissions. - */ - public function perms() - { - return array( - 'title' => array( - 'ingo:allow_rules' => _("Allow Rules"), - 'ingo:max_rules' => _("Maximum Number of Rules") - ), - 'tree' => array( - 'ingo' => array( - 'allow_rules' => false, - 'max_rules' => false - ) - ), - 'type' => array( - 'ingo:allow_rules' => 'boolean', - 'ingo:max_rules' => 'int' - ) - ); - } - - /** * Removes user data. * * @param string $user Name of user to remove data for. diff --git a/ingo/lib/Application.php b/ingo/lib/Application.php index 5411618a1..7191ba2ae 100644 --- a/ingo/lib/Application.php +++ b/ingo/lib/Application.php @@ -15,6 +15,31 @@ class Ingo_Application extends Horde_Registry_Application public $version = 'H4 (2.0-git)'; /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + return array( + 'title' => array( + 'ingo:allow_rules' => _("Allow Rules"), + 'ingo:max_rules' => _("Maximum Number of Rules") + ), + 'tree' => array( + 'ingo' => array( + 'allow_rules' => false, + 'max_rules' => false + ) + ), + 'type' => array( + 'ingo:allow_rules' => 'boolean', + 'ingo:max_rules' => 'int' + ) + ); + } + + /** * Generate the menu to use on the prefs page. * * @return Horde_Menu A Horde_Menu object. diff --git a/kronolith/lib/Api.php b/kronolith/lib/Api.php index e35755b8e..2e104abff 100644 --- a/kronolith/lib/Api.php +++ b/kronolith/lib/Api.php @@ -19,21 +19,6 @@ class Kronolith_Api extends Horde_Registry_Api ); /** - * Returns a list of available permissions. - * - * @return array An array describing all available permissions. - */ - public function perms() - { - $perms = array(); - $perms['tree']['kronolith']['max_events'] = false; - $perms['title']['kronolith:max_events'] = _("Maximum Number of Events"); - $perms['type']['kronolith:max_events'] = 'int'; - - return $perms; - } - - /** * Removes user data. * * @param string $user Name of user to remove data for. diff --git a/kronolith/lib/Application.php b/kronolith/lib/Application.php index 4d8a527b0..1152fe2c2 100644 --- a/kronolith/lib/Application.php +++ b/kronolith/lib/Application.php @@ -9,6 +9,21 @@ class Kronolith_Application extends Horde_Registry_Application public $version = 'H3 (3.0-git)'; /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + $perms = array(); + $perms['tree']['kronolith']['max_events'] = false; + $perms['title']['kronolith:max_events'] = _("Maximum Number of Events"); + $perms['type']['kronolith:max_events'] = 'int'; + + return $perms; + } + + /** * Code to run when viewing prefs for this application. * * @param string $group The prefGroup name. diff --git a/nag/lib/Api.php b/nag/lib/Api.php index cbafad121..cb74fde11 100644 --- a/nag/lib/Api.php +++ b/nag/lib/Api.php @@ -19,21 +19,6 @@ class Nag_Api extends Horde_Registry_Api ); /** - * Returns a list of available permissions. - * - * @return array An array describing all available permissions. - */ - public function perms() - { - $perms = array(); - $perms['tree']['nag']['max_tasks'] = false; - $perms['title']['nag:max_tasks'] = _("Maximum Number of Tasks"); - $perms['type']['nag:max_tasks'] = 'int'; - - return $perms; - } - - /** * Removes user data. * * @param string $user Name of user to remove data for. diff --git a/nag/lib/Application.php b/nag/lib/Application.php index b0fbc0a71..526eb94f8 100644 --- a/nag/lib/Application.php +++ b/nag/lib/Application.php @@ -14,6 +14,21 @@ class Nag_Application extends Horde_Registry_Application public $version = 'H4 (3.0-git)'; /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + $perms = array(); + $perms['tree']['nag']['max_tasks'] = false; + $perms['title']['nag:max_tasks'] = _("Maximum Number of Tasks"); + $perms['type']['nag:max_tasks'] = 'int'; + + return $perms; + } + + /** * Special preferences handling on update. * * @param string $item The preference name. diff --git a/news/lib/Api.php b/news/lib/Api.php index da84576fb..491cdd49f 100644 --- a/news/lib/Api.php +++ b/news/lib/Api.php @@ -13,34 +13,6 @@ class News_Api extends Horde_Registry_Api { /** - * Categories/Permissions - */ - public function perms() - { - static $perms = array(); - if (!empty($perms)) { - return $perms; - } - - $perms['tree']['news']['admin'] = true; - $perms['title']['news:admin'] = _("Admin"); - - $perms['tree']['news']['editors'] = true; - $perms['title']['news:editors'] = _("Editors"); - - require_once dirname(__FILE__) . '/base.php'; - $tree = $GLOBALS['news_cat']->getEnum(); - - $perms['title']['news:categories'] = _("Categories"); - foreach ($tree as $cat_id => $cat_name) { - $perms['tree']['news']['categories'][$cat_id] = false; - $perms['title']['news:categories:' . $cat_id] = $cat_name; - } - - return $perms; - } - - /** * Callback for comment API * * @param int $id Internal data identifier diff --git a/news/lib/Application.php b/news/lib/Application.php index f109d93b5..7ec790f47 100644 --- a/news/lib/Application.php +++ b/news/lib/Application.php @@ -15,6 +15,36 @@ class News_Application extends Horde_Registry_Application public $version = 'H4 (0.1-git)'; /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + static $perms = array(); + if (!empty($perms)) { + return $perms; + } + + $perms['tree']['news']['admin'] = true; + $perms['title']['news:admin'] = _("Admin"); + + $perms['tree']['news']['editors'] = true; + $perms['title']['news:editors'] = _("Editors"); + + require_once dirname(__FILE__) . '/base.php'; + $tree = $GLOBALS['news_cat']->getEnum(); + + $perms['title']['news:categories'] = _("Categories"); + foreach ($tree as $cat_id => $cat_name) { + $perms['tree']['news']['categories'][$cat_id] = false; + $perms['title']['news:categories:' . $cat_id] = $cat_name; + } + + return $perms; + } + + /** * Generate the menu to use on the prefs page. * * @return Horde_Menu A Horde_Menu object. diff --git a/turba/lib/Api.php b/turba/lib/Api.php index caf558edb..21dffdba2 100644 --- a/turba/lib/Api.php +++ b/turba/lib/Api.php @@ -28,36 +28,6 @@ class Turba_Api extends Horde_Registry_Api ); /** - * Returns a list of available permissions. - * - * @return array An array describing all available permissions. - */ - public function perms() - { - static $perms = array(); - if (!empty($perms)) { - return $perms; - } - - require_once dirname(__FILE__) . '/base.php'; - require TURBA_BASE . '/config/sources.php'; - - $perms['tree']['turba']['sources'] = false; - $perms['title']['turba:sources'] = _("Sources"); - - // Run through every contact source. - foreach ($cfgSources as $source => $curSource) { - $perms['tree']['turba']['sources'][$source] = false; - $perms['title']['turba:sources:' . $source] = $curSource['title']; - $perms['tree']['turba']['sources'][$source]['max_contacts'] = false; - $perms['title']['turba:sources:' . $source . ':max_contacts'] = _("Maximum Number of Contacts"); - $perms['type']['turba:sources:' . $source . ':max_contacts'] = 'int'; - } - - return $perms; - } - - /** * Removes user data. * * @param string $user Name of user to remove data for. diff --git a/turba/lib/Application.php b/turba/lib/Application.php index d176fc957..de2d8cde0 100644 --- a/turba/lib/Application.php +++ b/turba/lib/Application.php @@ -14,6 +14,36 @@ class Turba_Application extends Horde_Registry_Application public $version = 'H3 (3.0-git)'; /** + * Returns a list of available permissions. + * + * @return array An array describing all available permissions. + */ + public function perms() + { + static $perms = array(); + if (!empty($perms)) { + return $perms; + } + + require_once dirname(__FILE__) . '/base.php'; + require TURBA_BASE . '/config/sources.php'; + + $perms['tree']['turba']['sources'] = false; + $perms['title']['turba:sources'] = _("Sources"); + + // Run through every contact source. + foreach ($cfgSources as $source => $curSource) { + $perms['tree']['turba']['sources'][$source] = false; + $perms['title']['turba:sources:' . $source] = $curSource['title']; + $perms['tree']['turba']['sources'][$source]['max_contacts'] = false; + $perms['title']['turba:sources:' . $source . ':max_contacts'] = _("Maximum Number of Contacts"); + $perms['type']['turba:sources:' . $source . ':max_contacts'] = 'int'; + } + + return $perms; + } + + /** * Code to run when viewing prefs for this application. * * @param string $group The prefGroup name.