Ejemplo n.º 1
0
 public function _edit_user_form()
 {
     $groups_array = null;
     $user_group_id = "NONE";
     $user_id = Event::$data;
     //check and see if the person doing the editing is a group user
     $current_user = new User_Model($_SESSION['auth_user']->id);
     $group_id = groups::get_user_group($current_user);
     if ($group_id) {
         $group = ORM::factory("simplegroups_groups")->where("id", $group_id)->find();
         $groups_array = array($group->id => $group->name);
     } else {
         //get a list of all the groups
         $groups = ORM::factory("simplegroups_groups")->find_all();
         $groups_array = array("NONE" => "--No Group--");
         foreach ($groups as $group) {
             $groups_array[$group->id] = $group->name;
         }
         //find out if our user in question is a group members
         $users_groups = ORM::factory("simplegroups_groups")->join('simplegroups_groups_users', 'simplegroups_groups_users.simplegroups_groups_id', 'simplegroups_groups.id')->where('simplegroups_groups_users.users_id', $user_id)->find_all();
         foreach ($users_groups as $users_group) {
             $user_group_id = $users_group->id;
         }
     }
     //get list of group roles
     $roles = groups::get_group_roles();
     //get list of roles for this particular user
     $users_roles = groups::get_roles_for_user($user_id);
     $view = new View('simplegroups/edit_user');
     $view->groups = $groups_array;
     $view->roles = $roles;
     $view->users_roles = $users_roles;
     $view->user_group_id = $user_group_id;
     $view->render(TRUE);
 }