diff --git a/modules/displaytags/views/displaytags_block.html.php b/modules/displaytags/views/displaytags_block.html.php index 21fe8d6e..a0b392f3 100644 --- a/modules/displaytags/views/displaytags_block.html.php +++ b/modules/displaytags/views/displaytags_block.html.php @@ -3,6 +3,6 @@ $not_first = 0; ?> foreach ($tags as $tag): ?> = ($not_first++) ? "," : "" ?> - name}") ?>">= html::clean($tag->name) ?> + = html::clean($tag->name) ?> endforeach ?> diff --git a/modules/gwtorganise/controllers/json_album.php b/modules/gwtorganise/controllers/json_album.php index 85cf1128..da36fd98 100644 --- a/modules/gwtorganise/controllers/json_album.php +++ b/modules/gwtorganise/controllers/json_album.php @@ -34,7 +34,7 @@ class Json_Album_Controller extends Controller { $item = ORM::factory("item", $item_id); access::required("view", $item); - $children = $item->children(null, 0, $where); + $children = $item->children(null, null, $where); $encoded = array(); foreach ($children as $id => $child){ $encoded[$id] = self::child_json_encode($child); @@ -44,7 +44,7 @@ class Json_Album_Controller extends Controller { } function is_admin() { - if (user::active()->admin) { + if (identity::active_user()->admin) { print json_encode(array("result" => "success", "csrf" => access::csrf_token())); return; } @@ -54,7 +54,7 @@ class Json_Album_Controller extends Controller { function albums($item_id) { - print $this->child_elements($item_id,array("type" => "album")); + print $this->child_elements($item_id, array(array("type", "=", "album"))); } function children($item_id){ diff --git a/modules/ldap/helpers/ldap_installer.php b/modules/ldap/helpers/ldap_installer.php index c68ac6b6..dbdfb048 100644 --- a/modules/ldap/helpers/ldap_installer.php +++ b/modules/ldap/helpers/ldap_installer.php @@ -18,15 +18,19 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class ldap_installer { - static function install() { - module::set_version("ldap", 1); - $root = item::root(); - $ldap_provider = new IdentityProvider("ldap"); - foreach ($ldap_provider->groups() as $group) { - module::event("group_created", $group); - access::allow($group, "view", $root); - access::allow($group, "view_full", $root); + static function can_activate() { + $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() { + IdentityProvider::change_provider("ldap"); } static function uninstall() { @@ -36,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 diff --git a/modules/ldap/libraries/drivers/IdentityProvider/Ldap.php b/modules/ldap/libraries/drivers/IdentityProvider/Ldap.php index c3eb1dd1..69440199 100644 --- a/modules/ldap/libraries/drivers/IdentityProvider/Ldap.php +++ b/modules/ldap/libraries/drivers/IdentityProvider/Ldap.php @@ -239,9 +239,6 @@ class Ldap_User implements User_Definition { case "id": return $this->ldap_entry["uidnumber"][0]; - case "groups": - return IdentityProvider_Ldap_Driver::groups_for($this); - case "locale": // @todo return null; @@ -266,6 +263,10 @@ class Ldap_User implements User_Definition { } } + public function groups() { + return IdentityProvider_Ldap_Driver::groups_for($this); + } + public function avatar_url($size=80, $default=null) { return sprintf("http://www.gravatar.com/avatar/%s.jpg?s=%d&r=pg%s", md5($this->email), $size, $default ? "&d=" . urlencode($default) : ""); 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 diff --git a/modules/register/controllers/admin_register.php b/modules/register/controllers/admin_register.php index d93d9ad1..6e1e4155 100755 --- a/modules/register/controllers/admin_register.php +++ b/modules/register/controllers/admin_register.php @@ -32,6 +32,9 @@ class Admin_register_Controller extends Admin_Controller { access::verify_csrf(); $post = new Validation($_POST); + $post->add_rules("policy", "required"); + $post->add_rules("group", array($this, "passthru")); + $post->add_rules("email_verification", array($this, "passthru")); $group_list = array(); if ($post->validate()) { module::set_var("registration", "policy", $post->policy); @@ -49,6 +52,12 @@ class Admin_register_Controller extends Admin_Controller { } } + // We need this validation callback in order to have the optional fields copied to + // validation array. + public function passthru($field) { + return true; + } + public function activate() { access::verify_csrf(); diff --git a/modules/register/controllers/register.php b/modules/register/controllers/register.php index 66d420c6..ec50d646 100755 --- a/modules/register/controllers/register.php +++ b/modules/register/controllers/register.php @@ -37,13 +37,13 @@ class register_Controller extends Controller { $policy = module::get_var("registration", "policy"); if ($policy == "visitor") { if ($pending_user->state == 1) { - Session::instance()->set("registration_first_usage"); $user = register::create_new_user($pending_user->id); + Session::instance()->set("registration_first_usage"); auth::login($user); Session::instance()->set("registration_first_usage", true); $pending_user->delete(); } else { - register::send_confirmation($pending_user); + $user = register::create_new_user($pending_user->id, true); message::success(t("A confirmation email has been sent to your email address.")); } } else if ($pending_user->state == 1) { diff --git a/modules/register/helpers/register.php b/modules/register/helpers/register.php index 159f3237..d46b381c 100644 --- a/modules/register/helpers/register.php +++ b/modules/register/helpers/register.php @@ -21,8 +21,13 @@ class register_Core { private static $_states; static function format_registration_state($state) { - if (empty(self::$_state)) { - self::$_states = array(t("Unconfirmed"), t("Confirmed"), t("Activated")); + if (empty(self::$_states)) { + $policy = module::get_var("registration", "policy"); + $email_verification = module::get_var("registration", "email_verification"); + $pending = $policy == "admin_only" || ($policy == "admin_approval" && !$email_verification); + self::$_states = array(t("Unconfirmed"), + $pending ? t("Pending") : t("Confirmed"), + t("Activated")); } return self::$_states[$state]; } @@ -37,10 +42,11 @@ class register_Core { return $user->loaded(); } - static function send_user_created_confirmation($user) { + static function send_user_created_confirmation($user, $requires_first=false) { $message = new View("register_welcome.html"); $message->user = $user; - $message->site_url = url::abs_site("register/first/{$user->hash}"); + $message->site_url = $requires_first ? url::abs_site("register/first/{$user->hash}") : + url::abs_site(""); self::_sendemail($user->email, t("Your userid has been created"), $message); } diff --git a/modules/register/views/admin_register.html.php b/modules/register/views/admin_register.html.php index 865a8e56..d624865c 100644 --- a/modules/register/views/admin_register.html.php +++ b/modules/register/views/admin_register.html.php @@ -31,6 +31,8 @@ if (!empty($group_list)): ?> = form::dropdown(array("name" => "group"), $group_list, $form["group"]) ?> + else: ?> + = form::hidden("group", $form["group"]) ?> endif ?>