| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383 |
- <?php
- class Contact {
- private $id = NULL;
- private $organization = NULL;
- private $department = NULL;
- private $title = NULL;
- private $degree = NULL;
- private $forename = NULL;
- private $surname = NULL;
- private $street = NULL;
- private $streetNumber = NULL;
- private $postalCode = NULL;
- private $city = NULL;
- public static $FIELD_TEL = 0;
- public static $FIELD_MAIL = 1;
- public static $FIELD_WEB = 2;
- public function __construct($id, $organization, $department, $title, $degree, $forename, $surname, $street, $streetNumber, $postalCode, $city) {
- $this->id = $id;
- $this->organization = $organization;
- $this->department = $department;
- $this->title = $title;
- $this->degree = $degree;
- $this->forename = $forename;
- $this->surname = $surname;
- $this->street = $street;
- $this->streetNumber = $streetNumber;
- $this->postalCode = $postalCode;
- $this->city = $city;
- }
- /**
- * Get the value of Id
- *
- *
- * @return int
- *
- */
- public function getID() {
- return $this->id;
- }
- /**
- * Set the value of Id
- *
- *
- * @param int id
- *
- */
- public function setID($id) {
- $this->id = $id;
- }
- /**
- * Get the value of Organization
- *
- *
- * @return string
- *
- */
- public function getOrganization() {
- return $this->organization;
- }
- /**
- * Set the value of Organization
- *
- *
- * @param string organization
- *
- */
- public function setOrganization($organization) {
- $this->organization = $organization;
- }
- /**
- * Get the string of Department
- *
- *
- * @return mixed
- *
- */
- public function getDepartment() {
- return $this->department;
- }
- /**
- * Set the value of Department
- *
- *
- * @param string department
- *
- */
- public function setDepartment($department) {
- $this->department = $department;
- }
- /**
- * Get the value of Title
- *
- *
- * @return string
- *
- */
- public function getTitle() {
- return $this->title;
- }
- /**
- * Set the value of Title
- *
- *
- * @param string title
- *
- */
- public function setTitle($title) {
- $this->title = $title;
- }
- /**
- * Get the value of Degree
- *
- *
- * @return string
- *
- */
- public function getDegree() {
- return $this->degree;
- }
- /**
- * Set the value of Degree
- *
- *
- * @param mixed degree
- *
- */
- public function setDegree($degree) {
- $this->degree = $degree;
- }
- /**
- * Get the value of Forename
- *
- *
- * @return string
- *
- */
- public function getForename() {
- return $this->forename;
- }
- /**
- * Set the value of Forename
- *
- *
- * @param string forename
- *
- */
- public function setForename($forename) {
- $this->forename = $forename;
- }
- /**
- * Get the value of Surname
- *
- *
- * @return string
- *
- */
- public function getSurname() {
- return $this->surname;
- }
- /**
- * Set the value of Surname
- *
- *
- * @param string surname
- *
- */
- public function setSurname($surname) {
- $this->surname = $surname;
- }
- /**
- * Get the value of Street
- *
- *
- * @return string
- *
- */
- public function getStreet() {
- return $this->street;
- }
- /**
- * Set the value of Street
- *
- *
- * @param string street
- *
- */
- public function setStreet($street) {
- $this->street = $street;
- }
- /**
- * Get the value of Street Number
- *
- *
- * @return string
- *
- */
- public function getStreetNumber() {
- return $this->streetNumber;
- }
- /**
- * Set the value of Street Number
- *
- *
- * @param string streetNumber
- *
- */
- public function setStreetNumber($streetNumber) {
- $this->streetNumber = $streetNumber;
- }
- /**
- * Get the value of Postal Code
- *
- *
- * @return string
- *
- */
- public function getPostalCode() {
- return $this->postalCode;
- }
- /**
- * Set the value of Postal Code
- *
- *
- * @param string postalCode
- *
- */
- public function setPostalCode($postalCode) {
- $this->postalCode = $postalCode;
- }
- /**
- * Get the value of City
- *
- *
- * @return string
- *
- */
- public function getCity() {
- return $this->city;
- }
- /**
- * Set the value of City
- *
- *
- * @param string city
- *
- */
- public function setCity($city) {
- $this->city = $city;
- }
- /**
- * Get All Contacts by User ID
- *
- * @param int userID ID of User
- *
- * @return Array(Contact) Array with selected Contacts
- *
- */
- public static function getAllContactsByUserID($userID) {
- global $db;
- $contacts = $db->selectQuery("SELECT * FROM `contacts` WHERE `user_id` = " . $userID . ";");
- $return = array();
- if(!$contacts) {
- return false;
- }
- foreach($contacts as $contact) {
- $return[] = new Contact($contact->id, $contact->organization, $contact->department, $contact->title, $contact->degree, $contact->forename, $contact->surname, $contact->street, $contact->street_number, $contact->postal_code, $contact->city);
- }
- return $return;
- }
- /**
- * Get Contact by Contact ID
- *
- * @param int contactID ID of Contact
- *
- * @return Contact Selected Contact
- *
- */
- public static function getContactByID($contactID) {
- global $db;
- $contacts = $db->selectQuery("SELECT * FROM `contacts` WHERE `id` = " . $contactID . ";");
- $return = array();
- if(!$contacts) {
- return false;
- }
- foreach($contacts as $contact) {
- $return[] = new Contact($contact->id, $contact->organization, $contact->department, $contact->title, $contact->degree, $contact->forename, $contact->surname, $contact->street, $contact->street_number, $contact->postal_code, $contact->city);
- }
- return $return[0];
- }
- /**
- * Get communications by Contact ID
- *
- * @param int contactID ID of Contact
- *
- * @return Array Selected communications
- *
- */
- public static function getCommunicationsByContactID($contactID) {
- global $db;
- $communications = $db->selectQuery("SELECT * FROM `contacts_fields` WHERE `contact_id` = " . $contactID . " ORDER BY `type` ASC;");
- $return = array();
- if(!$communications) {
- return false;
- }
- foreach($communications as $communication) {
- $return[] = array("id" => $communication->id, "type" => $communication->type, "name" => $communication->name, "value" => $communication->value);
- }
- return $return;
- }
- }
- ?>
|