public function activate() { access::verify_csrf(); $post = new Validation($_POST); $post->add_rules("activate_users", "required"); $post->add_rules("activate", "alpha_numeric"); if ($post->validate()) { $names = array(); if (!empty($post->activate)) { foreach ($post->activate as $id) { $user = register::create_new_user($id); $names[] = $user->name; } message::success(t("Activated %users.", array("users" => implode(", ", $names)))); } $count = ORM::factory("pending_user")->where("state", "!=", 2)->count_all(); if ($count == 0) { site_status::clear("pending_user_registrations"); } url::redirect("admin/register"); } list($form, $errors) = $this->_get_form(); $form = array_merge($form, $post->as_array()); $errors = array_merge($errors, $post->errors()); print $this->_get_admin_view($form, $errors); }
public function confirm($hash) { $pending_user = ORM::factory("pending_user")->where("hash", "=", $hash)->where("state", "=", 0)->find(); if ($pending_user->loaded()) { // @todo add a request date to the pending user table and check that it hasn't expired $policy = module::get_var("registration", "policy"); $pending_user->state = 1; $pending_user->save(); if ($policy == "vistor") { $user = register::create_new_user($pending_user->id); message::success(t("Your registration request has been approved")); auth::login($user); Session::instance()->set("registration_first_usage", true); $pending_user->delete(); } else { site_status::warning(t("There are pending user registration. <a href=\"%url\">Review now!</a>", array("url" => html::mark_clean(url::site("admin/register")), "locale" => module::get_var("gallery", "default_locale"))), "pending_user_registrations"); message::success(t("Your registration request is awaiting administrator approval")); // added by Shad Laws, v2 if (module::get_var("registration", "admin_notify") == 1) { register::send_admin_notify($pending_user); } } } else { message::error(t("Your registration request is no longer valid, Please re-register.")); } url::redirect(item::root()->abs_url()); }