contact.inc.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <?php
  2. class Contact {
  3. private $id = NULL;
  4. private $organization = NULL;
  5. private $department = NULL;
  6. private $title = NULL;
  7. private $degree = NULL;
  8. private $forename = NULL;
  9. private $surname = NULL;
  10. private $street = NULL;
  11. private $streetNumber = NULL;
  12. private $postalCode = NULL;
  13. private $city = NULL;
  14. public static $FIELD_TEL = 0;
  15. public static $FIELD_MAIL = 1;
  16. public static $FIELD_WEB = 2;
  17. public function __construct($id, $organization, $department, $title, $degree, $forename, $surname, $street, $streetNumber, $postalCode, $city) {
  18. $this->id = $id;
  19. $this->organization = $organization;
  20. $this->department = $department;
  21. $this->title = $title;
  22. $this->degree = $degree;
  23. $this->forename = $forename;
  24. $this->surname = $surname;
  25. $this->street = $street;
  26. $this->streetNumber = $streetNumber;
  27. $this->postalCode = $postalCode;
  28. $this->city = $city;
  29. }
  30. /**
  31. * Get the value of Id
  32. *
  33. *
  34. * @return int
  35. *
  36. */
  37. public function getID() {
  38. return $this->id;
  39. }
  40. /**
  41. * Set the value of Id
  42. *
  43. *
  44. * @param int id
  45. *
  46. */
  47. public function setID($id) {
  48. $this->id = $id;
  49. }
  50. /**
  51. * Get the value of Organization
  52. *
  53. *
  54. * @return string
  55. *
  56. */
  57. public function getOrganization() {
  58. return $this->organization;
  59. }
  60. /**
  61. * Set the value of Organization
  62. *
  63. *
  64. * @param string organization
  65. *
  66. */
  67. public function setOrganization($organization) {
  68. $this->organization = $organization;
  69. }
  70. /**
  71. * Get the string of Department
  72. *
  73. *
  74. * @return mixed
  75. *
  76. */
  77. public function getDepartment() {
  78. return $this->department;
  79. }
  80. /**
  81. * Set the value of Department
  82. *
  83. *
  84. * @param string department
  85. *
  86. */
  87. public function setDepartment($department) {
  88. $this->department = $department;
  89. }
  90. /**
  91. * Get the value of Title
  92. *
  93. *
  94. * @return string
  95. *
  96. */
  97. public function getTitle() {
  98. return $this->title;
  99. }
  100. /**
  101. * Set the value of Title
  102. *
  103. *
  104. * @param string title
  105. *
  106. */
  107. public function setTitle($title) {
  108. $this->title = $title;
  109. }
  110. /**
  111. * Get the value of Degree
  112. *
  113. *
  114. * @return string
  115. *
  116. */
  117. public function getDegree() {
  118. return $this->degree;
  119. }
  120. /**
  121. * Set the value of Degree
  122. *
  123. *
  124. * @param mixed degree
  125. *
  126. */
  127. public function setDegree($degree) {
  128. $this->degree = $degree;
  129. }
  130. /**
  131. * Get the value of Forename
  132. *
  133. *
  134. * @return string
  135. *
  136. */
  137. public function getForename() {
  138. return $this->forename;
  139. }
  140. /**
  141. * Set the value of Forename
  142. *
  143. *
  144. * @param string forename
  145. *
  146. */
  147. public function setForename($forename) {
  148. $this->forename = $forename;
  149. }
  150. /**
  151. * Get the value of Surname
  152. *
  153. *
  154. * @return string
  155. *
  156. */
  157. public function getSurname() {
  158. return $this->surname;
  159. }
  160. /**
  161. * Set the value of Surname
  162. *
  163. *
  164. * @param string surname
  165. *
  166. */
  167. public function setSurname($surname) {
  168. $this->surname = $surname;
  169. }
  170. /**
  171. * Get the value of Street
  172. *
  173. *
  174. * @return string
  175. *
  176. */
  177. public function getStreet() {
  178. return $this->street;
  179. }
  180. /**
  181. * Set the value of Street
  182. *
  183. *
  184. * @param string street
  185. *
  186. */
  187. public function setStreet($street) {
  188. $this->street = $street;
  189. }
  190. /**
  191. * Get the value of Street Number
  192. *
  193. *
  194. * @return string
  195. *
  196. */
  197. public function getStreetNumber() {
  198. return $this->streetNumber;
  199. }
  200. /**
  201. * Set the value of Street Number
  202. *
  203. *
  204. * @param string streetNumber
  205. *
  206. */
  207. public function setStreetNumber($streetNumber) {
  208. $this->streetNumber = $streetNumber;
  209. }
  210. /**
  211. * Get the value of Postal Code
  212. *
  213. *
  214. * @return string
  215. *
  216. */
  217. public function getPostalCode() {
  218. return $this->postalCode;
  219. }
  220. /**
  221. * Set the value of Postal Code
  222. *
  223. *
  224. * @param string postalCode
  225. *
  226. */
  227. public function setPostalCode($postalCode) {
  228. $this->postalCode = $postalCode;
  229. }
  230. /**
  231. * Get the value of City
  232. *
  233. *
  234. * @return string
  235. *
  236. */
  237. public function getCity() {
  238. return $this->city;
  239. }
  240. /**
  241. * Set the value of City
  242. *
  243. *
  244. * @param string city
  245. *
  246. */
  247. public function setCity($city) {
  248. $this->city = $city;
  249. }
  250. /**
  251. * Get All Contacts by User ID
  252. *
  253. * @param int userID ID of User
  254. *
  255. * @return Array(Contact) Array with selected Contacts
  256. *
  257. */
  258. public static function getAllContactsByUserID($userID) {
  259. global $db;
  260. $contacts = $db->selectQuery("SELECT * FROM `contacts` WHERE `user_id` = " . $userID . ";");
  261. $return = array();
  262. if(!$contacts) {
  263. return false;
  264. }
  265. foreach($contacts as $contact) {
  266. $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);
  267. }
  268. return $return;
  269. }
  270. /**
  271. * Get Contact by Contact ID
  272. *
  273. * @param int contactID ID of Contact
  274. *
  275. * @return Contact Selected Contact
  276. *
  277. */
  278. public static function getContactByID($contactID) {
  279. global $db;
  280. $contacts = $db->selectQuery("SELECT * FROM `contacts` WHERE `id` = " . $contactID . ";");
  281. $return = array();
  282. if(!$contacts) {
  283. return false;
  284. }
  285. foreach($contacts as $contact) {
  286. $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);
  287. }
  288. return $return[0];
  289. }
  290. /**
  291. * Get communications by Contact ID
  292. *
  293. * @param int contactID ID of Contact
  294. *
  295. * @return Array Selected communications
  296. *
  297. */
  298. public static function getCommunicationsByContactID($contactID) {
  299. global $db;
  300. $communications = $db->selectQuery("SELECT * FROM `contacts_fields` WHERE `contact_id` = " . $contactID . " ORDER BY `type` ASC;");
  301. $return = array();
  302. if(!$communications) {
  303. return false;
  304. }
  305. foreach($communications as $communication) {
  306. $return[] = array("id" => $communication->id, "type" => $communication->type, "name" => $communication->name, "value" => $communication->value);
  307. }
  308. return $return;
  309. }
  310. }
  311. ?>