From b8bce53b8f19e869762e9405693bad5aa377a5f4 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Jan 2010 09:42:41 -0800 Subject: [PATCH 1/4] Use the admin module to install and switch to the LDAP identity provider. --- modules/ldap/helpers/ldap_installer.php | 19 ++++++++++++++++++- modules/ldap/module.info | 3 --- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/ldap/helpers/ldap_installer.php b/modules/ldap/helpers/ldap_installer.php index c68ac6b6..f8180eba 100644 --- a/modules/ldap/helpers/ldap_installer.php +++ b/modules/ldap/helpers/ldap_installer.php @@ -18,15 +18,32 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class ldap_installer { + static function check_environment() { + return array(); + } + static function install() { + $current_provider = module::get_var("gallery", "identity_provider"); + if (!empty($current_provider)) { + module::uninstall($current_provider); + } + + IdentityProvider::reset(); + module::set_var("gallery", "identity_provider", "ldap"); + module::set_version("ldap", 1); $root = item::root(); - $ldap_provider = new IdentityProvider("ldap"); + $ldap_provider = IdentityProvider::instance(); foreach ($ldap_provider->groups() as $group) { module::event("group_created", $group); access::allow($group, "view", $root); access::allow($group, "view_full", $root); } + + module::event("identity_provider_changed", $current_provider, "ldap"); + + auth::login($ldap_provider->admin_user()); + Session::instance()->regenerate(); } static function uninstall() { diff --git a/modules/ldap/module.info b/modules/ldap/module.info index 1b7bef08..06fa311b 100644 --- a/modules/ldap/module.info +++ b/modules/ldap/module.info @@ -1,6 +1,3 @@ name = "LDAP" description = "Use LDAP for authentication" version = 1 - -; Don't show this module on the module administration screen -no_module_admin = 1 From b0270cf722e2ab95ea4e2f94c6b904e45b3c30c3 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Jan 2010 12:09:46 -0800 Subject: [PATCH 2/4] Refactor the identity provider installation in to a common helper method (change_provider) with an initialization callback. --- modules/ldap/helpers/ldap_installer.php | 41 ++++++++++++------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/modules/ldap/helpers/ldap_installer.php b/modules/ldap/helpers/ldap_installer.php index f8180eba..1179fa4a 100644 --- a/modules/ldap/helpers/ldap_installer.php +++ b/modules/ldap/helpers/ldap_installer.php @@ -19,31 +19,18 @@ */ class ldap_installer { static function check_environment() { - return array(); + $messages = array(); + if (array_search("ldap", get_loaded_extensions()) === false) { + $messages["error"][] = + t("Cannot install LDAP identity provider as the PHP LDAP extension module is not enabled."); + } else { + $messages["warn"][] = IdentityProvider::confirmation_message(); + } + return $messages; } static function install() { - $current_provider = module::get_var("gallery", "identity_provider"); - if (!empty($current_provider)) { - module::uninstall($current_provider); - } - - IdentityProvider::reset(); - module::set_var("gallery", "identity_provider", "ldap"); - - module::set_version("ldap", 1); - $root = item::root(); - $ldap_provider = IdentityProvider::instance(); - foreach ($ldap_provider->groups() as $group) { - module::event("group_created", $group); - access::allow($group, "view", $root); - access::allow($group, "view_full", $root); - } - - module::event("identity_provider_changed", $current_provider, "ldap"); - - auth::login($ldap_provider->admin_user()); - Session::instance()->regenerate(); + IdentityProvider::change_provider("ldap"); } static function uninstall() { @@ -53,4 +40,14 @@ class ldap_installer { module::event("group_deleted", $group); } } + + static function initialize() { + module::set_version("ldap", 1); + $root = item::root(); + foreach (IdentityProvider::instance()->groups() as $group) { + module::event("group_created", $group); + access::allow($group, "view", $root); + access::allow($group, "view_full", $root); + } + } } \ No newline at end of file From 68b290be514106d1b95e63db72caa14da3e02a67 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 22 Jan 2010 12:30:53 -0800 Subject: [PATCH 3/4] Change the check_environment method in the module helper and the module installers to can_activate to reflect that it is doing more than just checking the environment. --- modules/ldap/helpers/ldap_installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ldap/helpers/ldap_installer.php b/modules/ldap/helpers/ldap_installer.php index 1179fa4a..dbdfb048 100644 --- a/modules/ldap/helpers/ldap_installer.php +++ b/modules/ldap/helpers/ldap_installer.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class ldap_installer { - static function check_environment() { + static function can_activate() { $messages = array(); if (array_search("ldap", get_loaded_extensions()) === false) { $messages["error"][] = From c7d1baab70185800f932b087c38ab99f8de443d4 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 24 Jan 2010 20:43:02 -0800 Subject: [PATCH 4/4] Add the user home home directory to the user profile page. --- modules/user_homes/helpers/user_homes_event.php | 13 +++++++++++++ modules/user_homes/views/user_profile_home.html.php | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 modules/user_homes/views/user_profile_home.html.php diff --git a/modules/user_homes/helpers/user_homes_event.php b/modules/user_homes/helpers/user_homes_event.php index 561666df..a866de52 100644 --- a/modules/user_homes/helpers/user_homes_event.php +++ b/modules/user_homes/helpers/user_homes_event.php @@ -161,4 +161,17 @@ class user_homes_event_Core { } return; } + + static function show_user_profile($data) { + $home = ORM::factory("user_home")->where("id", "=", $data->user->id)->find(); + + if ($home->loaded()) { + $view = new View("user_profile_home.html"); + $item = ORM::factory("item")->where("id", "=", $home->home)->find(); + if ($item->loaded()) { + $view->item = $item; + $data->content[] = (object)array("title" => t("Home album"), "view" => $view); + } + } + } } diff --git a/modules/user_homes/views/user_profile_home.html.php b/modules/user_homes/views/user_profile_home.html.php new file mode 100644 index 00000000..33e8c5c2 --- /dev/null +++ b/modules/user_homes/views/user_profile_home.html.php @@ -0,0 +1,10 @@ + +
+ +