/** * Populates the collection of business objects from raw data * * @return bool * @param MySqlRawData $result */ protected function BuildItems(MySqlRawData $result) { $this->Clear(); # use CollectionBuilder to handle duplicates $user_builder = new CollectionBuilder(); $roles = new CollectionBuilder(); $role_class_loaded = false; $user = null; while ($row = $result->fetch()) { # check whether this is a new person if (!$user_builder->IsDone($row->user_id)) { # store any exisiting person if ($user != null) { $this->Add($user); $roles->Reset(); } # create the new person $user = new User(); $user->SetId($row->user_id); $user->SetName($row->known_as); if (isset($row->name_first)) { $user->SetFirstName($row->name_first); } if (isset($row->name_last)) { $user->SetLastName($row->name_last); } if (isset($row->email)) { $user->SetEmail($row->email); } if (isset($row->gender)) { $user->SetGender($row->gender); } if (isset($row->occupation)) { $user->SetOccupation($row->occupation); } if (isset($row->interests)) { $user->SetInterests($row->interests); } if (isset($row->location)) { $user->SetLocation($row->location); } if (isset($row->sign_up_date)) { $user->SetSignUpDate($row->sign_up_date); } if (isset($row->total_messages)) { $user->SetTotalMessages($row->total_messages); } if (isset($row->disabled)) { $user->SetAccountDisabled($row->disabled); } } # Add security roles if (isset($row->role_id) and !$roles->IsDone($row->role_id)) { if (!$role_class_loaded) { require_once "authentication/role.class.php"; $role_class_loaded = true; } $role = new Role($row->role_id, $row->role); $user->Roles()->Add($role); } } # store final person if ($user != null) { $this->Add($user); } }