/** * Load multiple ContactDBO's from database * * @param string $filter A WHERE clause * @param string $sortby Field name to sort results by * @param string $sortdir Direction to sort in (ASEC or DESC) * @param int $limit Limit the number of results * @param int $start Record number to start the results at * @return array Array of ContactDBO's */ function &ContactDBO_loadArray($filter = null, $sortby = null, $sortdir = null, $limit = null, $start = null) { $DB = DBConnection::getDBConnection(); // Build query $sql = $DB->build_select_sql("contact", "*", $filter, $sortby, $sortdir, $limit, $start); // Run query if (!($result = @mysql_query($sql, $DB->handle()))) { // Query error throw new DBException(mysql_error($DB->handle())); } if (mysql_num_rows($result) == 0) { // No rows found throw new DBNoRowsFoundException(); } // Build an array of DBOs from the result set $dbo_array = array(); while ($data = mysql_fetch_array($result)) { // Create and initialize a new DBO with the data from the DB $dbo = new ContactDBO(); $dbo->load($data); // Add OrderDBO to array $dbo_array[] = $dbo; } return $dbo_array; }
/** * Add or Edit a Reseller Club Contact Record * * Add a new contact record at Reseller Club, or if it already exists, update it. * * @param integer $customer_id The customer who this contact belongs to * @param ContactDBO $contactDBO Contact DBO * @return integer Directi Contact ID */ function addOrEditContact($customerID, $contactDBO) { if (empty($contactDBO->getBusinessName)) { // If no company is provided, set company field to contact name $contactDBO->setBusinessName($contactDBO->getName()); } // Find out if this contact already exists $contactID = -1; $contacts = $this->domContact->listNames($this->getUsername(), $this->getPassword(), $this->getRole(), $this->getLangPref(), $this->getParentID(), $customerID); if ($contacts != null) { foreach ($contacts as $key => $data) { if (is_numeric($key)) { if ($data['company'] == $contactDBO->getBusinessName() && $data['name'] == $contactDBO->getName()) { // Contact already exists $contactID = $data['contactid']; break; } } } } if ($contactID > 0) { // Update contact $phone = $this->parse_phone_number($contactDBO->getPhone()); $fax = $this->parse_phone_number($contactDBO->getFax()); $result = $this->domContact->mod($this->getUsername(), $this->getPassword(), $this->getRole(), $this->getLangPref(), $this->getParentID(), $contactID, $contactDBO->getName(), $contactDBO->getBusinessName(), $contactDBO->getEmail(), $contactDBO->getAddress1(), $contactDBO->getAddress2(), $contactDBO->getAddress3(), $contactDBO->getCity(), $contactDBO->getState(), $contactDBO->getCountry(), $contactDBO->getPostalCode(), $phone['cc'], $phone['number'], $fax['cc'], $fax['number']); if ($result['status'] != "Success") { print_r($result); fatal_error("ResellerClub::addOrEditContact()", "could not modify contact for domain registration at Reseller Club!"); } } else { // Add contact $phone = $this->parse_phone_number($contactDBO->getPhone()); $fax = $this->parse_phone_number($contactDBO->getFax()); $contact_id = $this->domContact->addContact($this->getUsername(), $this->getPassword(), $this->getRole(), $this->getLangPref(), $this->getParentID(), $contactDBO->getName(), $contactDBO->getBusinessName(), $contactDBO->getEmail(), $contactDBO->getAddress1(), $contactDBO->getAddress2(), $contactDBO->getAddress3(), $contactDBO->getCity(), $contactDBO->getState(), $contactDBO->getCountry(), $contactDBO->getPostalCode(), $phone['cc'], $phone['number'], $fax['cc'], $fax['number'], $customerID); if (!is_numeric($contactID)) { fatal_error("RegistrarDirecti::add_edit_contact()", "could not add contact for domain registration at Directi!"); } } return $contactID; }