summaryrefslogtreecommitdiff
path: root/modules/user/helpers/group.php
diff options
context:
space:
mode:
authorFelix Rabinovich <virshu@users.sourceforge.net>2008-12-25 02:16:41 +0000
committerFelix Rabinovich <virshu@users.sourceforge.net>2008-12-25 02:16:41 +0000
commit481352c382d769d9074223ae9c7b6d969f0f6e58 (patch)
tree875b7fce601549950cc0f5561d778fb99472cda1 /modules/user/helpers/group.php
parentfd49c7460705c4334efb0f943191c80540f3f629 (diff)
User administration: 1. Add users; 2. Group administration; 3. General cleanup
Diffstat (limited to 'modules/user/helpers/group.php')
-rw-r--r--modules/user/helpers/group.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/modules/user/helpers/group.php b/modules/user/helpers/group.php
index 98947794..f32e37dc 100644
--- a/modules/user/helpers/group.php
+++ b/modules/user/helpers/group.php
@@ -31,7 +31,7 @@ class group_Core {
* @return Group_Model
*/
static function create($name) {
- $group = ORM::factory("group")->where("name", $name);
+ $group = ORM::factory("group")->where("name", $name)->find();
if ($group->loaded) {
throw new Exception("@todo GROUP_ALREADY_EXISTS $name");
}
@@ -64,4 +64,37 @@ class group_Core {
static function registered_users() {
return ORM::factory("group", 2);
}
+
+ /**
+ * This is the API for handling groups.
+ * @TODO incorporate rules!
+ */
+ public static function get_edit_form($group, $action = NULL) {
+ $form = new Forge($action);
+ $form_group = $form->group("edit_group")->label(_("Edit Group"));
+ $form_group->input("gname")->label(_("Name"))->id("gName")->value($group->name);
+ $form_group->submit(_("Modify"));
+ $form->add_rules_from($group);
+ $form->edit_group->gname->rules($group->rules["name"]);
+ return $form;
+ }
+
+ public static function get_add_form($action = NULL) {
+ $form = new Forge($action);
+ $form_group = $form->group("add_group")->label(_("Add Group"));
+ $form_group->input("gname")->label(_("Name"))->id("gName");
+ $form_group->submit(_("Create"));
+ $group = ORM::factory("group");
+ $form->add_rules_from($group);
+ $form->add_group->gname->rules($group->rules["name"]);
+ return $form;
+ }
+
+ public static function get_delete_form($group, $action = NULL) {
+ $form = new Forge($action);
+ $form_group = $form->group("delete_group")->label(_("Delete Group"));
+ $form_group->label(_("Are you sure you want to delete " . $group->name . "?"));
+ $form_group->submit(_("Delete"));
+ return $form;
+ }
} \ No newline at end of file