summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-10-18 09:21:34 -0700
committerTim Almdal <tnalmdal@shaw.ca>2009-10-18 09:21:34 -0700
commitc9a030dd08711f89a985504ce26378a315d7ff1f (patch)
tree4014ed3eeba41c7f96efc3202c0e221ecb028ebf
parent6d5c12e13e6f1199a96180e69cac69d77ecbbcc2 (diff)
Add a menu item to manage the Identity drivers if there is more than one installed
-rw-r--r--modules/gallery/helpers/gallery_event.php18
-rw-r--r--modules/gallery/libraries/Identity.php22
-rw-r--r--modules/user/helpers/user_event.php15
3 files changed, 45 insertions, 10 deletions
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index a6aa0657..84b84f7d 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -190,11 +190,19 @@ class gallery_event_Core {
->append(Menu::factory("link")
->id("sidebar")
->label(t("Manage Sidebar"))
- ->url(url::site("admin/sidebar"))))
- ->append(Menu::factory("link")
- ->id("users_groups")
- ->label(t("Users/Groups"))
- ->url(url::site("admin/users")))
+ ->url(url::site("admin/sidebar"))));
+ if (count(Identity::active()) > 1) {
+ $menu
+ ->append(Menu::factory("submenu")
+ ->id("identity_menu")
+ ->label(t("Identity Management"))
+ ->append(Menu::factory("link")
+ ->id("identity_drivers")
+ ->label(t("Identity Drivers"))
+ ->url(url::site("admin/identity"))));
+ }
+
+ $menu
->append(Menu::factory("submenu")
->id("statistics_menu")
->label(t("Statistics")))
diff --git a/modules/gallery/libraries/Identity.php b/modules/gallery/libraries/Identity.php
index 9eb4b83b..9e5f0bb5 100644
--- a/modules/gallery/libraries/Identity.php
+++ b/modules/gallery/libraries/Identity.php
@@ -24,6 +24,8 @@
class Identity_Core {
protected static $instance;
+ protected static $active;
+
// Configuration
protected $config;
@@ -81,6 +83,26 @@ class Identity_Core {
}
/**
+ * Return a list of installed and activated Identity Drivers.
+ *
+ * @return boolean true if the driver supports updates; false if read only
+ */
+ static function active() {
+ if (empty(self::$active)) {
+ $drivers = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
+ foreach (module::active() as $module) {
+ $module_name = $module->name;
+ if (file_exists(MODPATH . "{$module->name}/config/identity.php") &&
+ ($info = module::info($module_name))) {
+ $drivers->$module_name = $info->description;
+ }
+ }
+ self::$active = $drivers;
+ }
+ return self::$active;
+ }
+
+ /**
* Determine if if the current driver supports updates.
*
* @return boolean true if the driver supports updates; false if read only
diff --git a/modules/user/helpers/user_event.php b/modules/user/helpers/user_event.php
index 78b009eb..00ccbb29 100644
--- a/modules/user/helpers/user_event.php
+++ b/modules/user/helpers/user_event.php
@@ -20,11 +20,16 @@
class user_event_Core {
static function admin_menu($menu, $theme) {
- $menu->add_after("appearance_menu",
- Menu::factory("link")
- ->id("users_groups")
- ->label(t("Users/Groups"))
- ->url(url::site("admin/users")));
+ $user_group_menu = Menu::factory("link")
+ ->id("users_groups")
+ ->label(t("Users/Groups"))
+ ->url(url::site("admin/users"));
+ $identity_menu = $menu->get("identity_menu");
+ if (empty($identity_menu)) {
+ $menu->add_after("appearance_menu", $user_group_menu);
+ }else {
+ $identity_menu->append($user_group_menu);
+ }
return $menu;
}
}