id, self::$mb_group_type); $t = array("s"); $insert_result = db_prep_query($sql_group_create, $v, $t); if(!$insert_result) { return false; } return true; } public function load() { $sql_group = <<id); $t = array("i", "i"); $res_group = db_prep_query($sql_group,$v,$t); if ($row = db_fetch_array($res_group)) { $this->name = $row['mb_group_name']; //FIXME: needs checking $tmpuser = new User($row['mb_group_owner']); $this->owner = $tmpuser->name; $this->description = $row['mb_group_description']; $this->title = $row["mb_group_title"]; $this->address = $row["mb_group_address"]; $this->postcode = $row["mb_group_postcode"]; $this->city = $row["mb_group_city"]; $this->stateorprovince = $row["mb_group_stateorprovince"]; $this->country = $row["mb_group_country"]; $this->voicetelephone = $row["mb_group_voicetelephone"]; $this->facsimiletelephone = $row["mb_group_facsimiletelephone"]; $this->email = $row["mb_group_email"]; $this->logo_path = $row["mb_group_logo_path"]; } else { new mb_warning("Group with ID " . $this->id . " is not a registration office group."); } return true; } public static function getList ($aFilter) { $sql = "SELECT mb_group_id from mb_group JOIN mb_group_mb_group_types ON group_id = mb_group_id"; $filter = new Filter("AND", array( new Filter("=", "type_id", self::$mb_group_type), is_a($aFilter, "Filter") ? $aFilter : new Filter() )); $sqlObject = $filter->toSql(); $where = $sqlObject->sql; $sql = trim($where) !== "" ? trim($sql . " WHERE " . $where) : $sql; $v = $sqlObject->v; $t = $sqlObject->t; $res = db_prep_query($sql, $v, $t); $groupArray = array(); while ($row = db_fetch_assoc($res)) { $id = $row["mb_group_id"]; $group = new self($id); if ($group->isValid()) { $groupArray[]= $group; } } return $groupArray; } /* * tries to initialize a Groupobject by Name * @return A group Object * @param $name the name of the group to find */ public static function byName($name) { if($name == null) { return new Group(null); } $sql_group = <<id; } else { $user = new User($id); } if (!$user->isValid()) { new mb_exception("User ID " . $id . " invalid."); return array(); } $groups = $user->getGroupsByUser(); if (!is_array($groups)) { new mb_notice("User " . $id . " is not member in any group."); return array(); } new mb_notice("User " . $id . " is member of " . count($groups) . " groups."); $registrars = array(); for ($i = count($groups) - 1; $i >= 0; $i--) { $registrar = new self($groups[$i]); if ($registrar->isValid()) { $registrars[]= $registrar; } } return $registrars; } } require_once dirname(__FILE__) . "/../../lib/class_Filter.php"; ?>