where("name", $name)->find(); if ($group->loaded) { throw new Exception("@todo GROUP_ALREADY_EXISTS $name"); } $group->name = $name; $group->save(); return $group; } /** * @see Identity_Driver::everbody. */ static function everybody() { return model_cache::get("group", 1); } /** * @see Identity_Driver::registered_users. */ static function registered_users() { return model_cache::get("group", 2); } /** * Look up a group by id. * @param integer $id the user id * @return Group_Definition the group object, or null if the id was invalid. */ static function lookup($id) { return self::lookup_by_field("id", $id); } /** * Look up a group by name. * @param integer $id the group name * @return Group_Definition the group object, or null if the name was invalid. */ static function lookup_by_name($name) { return self::lookup_by_field("name", $name); } /** * @see Identity_Driver::get_group_list. */ static function lookup_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; } }