summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r--modules/gallery/helpers/group.php127
-rw-r--r--modules/gallery/helpers/user.php103
2 files changed, 0 insertions, 230 deletions
diff --git a/modules/gallery/helpers/group.php b/modules/gallery/helpers/group.php
index 3369b5ab..295e5f50 100644
--- a/modules/gallery/helpers/group.php
+++ b/modules/gallery/helpers/group.php
@@ -25,133 +25,6 @@
*/
class group_Core {
/**
- * Create a new group.
- *
- * @param string $name
- * @return Group_Model
- */
- static function create($name) {
- $group = ORM::factory("group")->where("name", $name)->find();
- if ($group->loaded) {
- throw new Exception("@todo GROUP_ALREADY_EXISTS $name");
- }
-
- $group->name = $name;
- $group->save();
-
- return $group;
- }
-
- /**
- * The group of all possible visitors. This includes the guest user.
- *
- * @return Group_Model
- */
- static function everybody() {
- return model_cache::get("group", 1);
- }
-
- /**
- * The group of all logged-in visitors. This does not include guest users.
- *
- * @return Group_Model
- */
- static function registered_users() {
- return model_cache::get("group", 2);
- }
-
- /**
- * Look up a user by id.
- * @param integer $id the user id
- * @return User_Model the user object, or null if the id was invalid.
- */
- static function lookup($id) {
- return self::_lookup_group_by_field("id", $id);
- }
-
- /**
- * Look up a group by name.
- * @param integer $id the group name
- * @return Group_Model the group object, or null if the name was invalid.
- */
- static function lookup_by_name($name) {
- return self::_lookup_group_by_field("name", $name);
- }
-
- /**
- * Look up a user by field value.
- * @param string search field
- * @param string search value
- * @return Group_Model the user object, or null if the name was invalid.
- */
- private static function _lookup_group_by_field($field_name, $value) {
- try {
- $user = model_cache::get("group", $value, $field_name);
- if ($user->loaded) {
- return $user;
- }
- } catch (Exception $e) {
- if (strpos($e->getMessage(), "MISSING_MODEL") === false) {
- throw $e;
- }
- }
- return null;
- }
-
- /**
- * List the users
- * @param mixed filters (@see Database.php
- * @return array the group list.
- */
- static function get_group_list($filter=array()) {
- $group = ORM::factory("group");
-
- foreach($filter as $method => $args) {
- switch ($method) {
- case "in":
- $group->in($args[0], $args[1]);
- break;
- default:
- $group->$method($args);
- }
- }
- return $group->find_all();
- }
-
- static function get_edit_form_admin($group) {
- $form = new Forge("admin/users/edit_group/$group->id", "", "post", array("id" => "g-edit-group-form"));
- $form_group = $form->group("edit_group")->label(t("Edit Group"));
- $form_group->input("name")->label(t("Name"))->id("g-name")->value($group->name);
- $form_group->inputs["name"]->error_messages(
- "in_use", t("There is already a group with that name"));
- $form_group->submit("")->value(t("Save"));
- $form->add_rules_from(self::get_edit_rules());
- return $form;
- }
-
- static function get_add_form_admin() {
- $form = new Forge("admin/users/add_group", "", "post", array("id" => "g-add-group-form"));
- $form->set_attr('class', "g-narrow");
- $form_group = $form->group("add_group")->label(t("Add Group"));
- $form_group->input("name")->label(t("Name"))->id("g-name");
- $form_group->inputs["name"]->error_messages(
- "in_use", t("There is already a group with that name"));
- $form_group->submit("")->value(t("Add Group"));
- $group = ORM::factory("group");
- $form->add_rules_from(self::get_edit_rules());
- return $form;
- }
-
- static function get_delete_form_admin($group) {
- $form = new Forge("admin/users/delete_group/$group->id", "", "post",
- array("id" => "g-delete-group-form"));
- $form_group = $form->group("delete_group")->label(
- t("Are you sure you want to delete group %group_name?", array("group_name" => $group->name)));
- $form_group->submit("")->value(t("Delete"));
- return $form;
- }
-
- /**
* @see Identity_Driver::create.
*/
static function create($name) {
diff --git a/modules/gallery/helpers/user.php b/modules/gallery/helpers/user.php
index 9052e932..efe08830 100644
--- a/modules/gallery/helpers/user.php
+++ b/modules/gallery/helpers/user.php
@@ -24,109 +24,6 @@
* Note: by design, this class does not do any permission checking.
*/
class user_Core {
- static function get_edit_form($user) {
- $writable = self::is_writable();
- $form = new Forge("users/update/$user->id", "", "post", array("id" => "g-edit-user-form"));
- $form->set_attr("class", "g-narrow");
- $group = $form->group("edit_user")->label(t("Edit User: %name", array("name" => $user->name)));
- $group->input("full_name")->label(t("Full Name"))->id("g-fullname")->value($user->full_name);
- self::_add_locale_dropdown($group, $user);
- if ($writable) {
- $group->password("password")->label(t("Password"))->id("g-password");
- $group->password("password2")->label(t("Confirm Password"))->id("g-password2")
- ->matches($group->password);
- }
- $group->input("email")->label(t("Email"))->id("g-email")->value($user->email);
- $group->input("url")->label(t("URL"))->id("g-url")->value($user->url);
- $form->add_rules_from(self::get_edit_rules());
-
- module::event("user_edit_form", $user, $form);
- $group->submit("")->value(t("Save"));
-
- if (!$writable) {
- foreach ($group->inputs as $input) {
- $input->disabled("disabled");
- }
- }
- return $form;
- }
-
- static function get_edit_form_admin($user) {
- $writable = self::is_writable();
- $form = new Forge(
- "admin/users/edit_user/$user->id", "", "post", array("id" => "g-edit-user-form"));
- $group = $form->group("edit_user")->label(t("Edit User"));
- $group->input("name")->label(t("Username"))->id("g-username")->value($user->name);
- $group->inputs["name"]->error_messages(
- "in_use", t("There is already a user with that username"));
- $group->input("full_name")->label(t("Full Name"))->id("g-fullname")->value($user->full_name);
- self::_add_locale_dropdown($group, $user);
- if ($writable) {
- $group->password("password")->label(t("Password"))->id("g-password");
- $group->password("password2")->label(t("Confirm Password"))->id("g-password2")
- ->matches($group->password);
- }
- $group->input("email")->label(t("Email"))->id("g-email")->value($user->email);
- $group->input("url")->label(t("URL"))->id("g-url")->value($user->url);
- $group->checkbox("admin")->label(t("Admin"))->id("g-admin")->checked($user->admin);
- $form->add_rules_from(self::get_edit_rules());
-
- module::event("user_edit_form_admin", $user, $form);
- $group->submit("")->value(t("Modify User"));
- if (!$writable) {
- foreach ($group->inputs as $input) {
- $input->disabled("disabled");
- }
- }
- return $form;
- }
-
- static function get_add_form_admin() {
- $form = new Forge("admin/users/add_user", "", "post", array("id" => "g-add-user-form"));
- $form->set_attr('class', "g-narrow");
- $group = $form->group("add_user")->label(t("Add User"));
- $group->input("name")->label(t("Username"))->id("g-username")
- ->error_messages("in_use", t("There is already a user with that username"));
- $group->input("full_name")->label(t("Full Name"))->id("g-fullname");
- $group->password("password")->label(t("Password"))->id("g-password");
- $group->password("password2")->label(t("Confirm Password"))->id("g-password2")
- ->matches($group->password);
- $group->input("email")->label(t("Email"))->id("g-email");
- $group->input("url")->label(t("URL"))->id("g-url");
- self::_add_locale_dropdown($group);
- $group->checkbox("admin")->label(t("Admin"))->id("g-admin");
- $form->add_rules_from(self::get_edit_rules());
-
- module::event("user_add_form_admin", $user, $form);
- $group->submit("")->value(t("Add User"));
- return $form;
- }
-
- private static function _add_locale_dropdown(&$form, $user=null) {
- $locales = locales::installed();
- foreach ($locales as $locale => $display_name) {
- $locales[$locale] = SafeString::of_safe_html($display_name);
- }
- if (count($locales) > 1) {
- // Put "none" at the first position in the array
- $locales = array_merge(array("" => t("« none »")), $locales);
- $selected_locale = ($user && $user->locale) ? $user->locale : "";
- $form->dropdown("locale")
- ->label(t("Language Preference"))
- ->options($locales)
- ->selected($selected_locale);
- }
- }
-
- static function get_delete_form_admin($user) {
- $form = new Forge("admin/users/delete_user/$user->id", "", "post",
- array("id" => "g-delete-user-form"));
- $group = $form->group("delete_user")->label(
- t("Are you sure you want to delete user %name?", array("name" => $user->name)));
- $group->submit("")->value(t("Delete user %name", array("name" => $user->name)));
- return $form;
- }
-
static function get_login_form($url) {
$form = new Forge($url, "", "post", array("id" => "g-login-form"));
$form->set_attr('class', "g-narrow");