PageRenderTime 35ms CodeModel.GetById 10ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/pkp/classes/user/PKPUser.inc.php

https://github.com/lib-uoguelph-ca/ocs
PHP | 596 lines | 234 code | 77 blank | 285 comment | 14 complexity | 16bc91da058dd31082b98158cb488dcd MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /**
  3. * @defgroup user
  4. */
  5. /**
  6. * @file classes/user/PKPUser.inc.php
  7. *
  8. * Copyright (c) 2000-2012 John Willinsky
  9. * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
  10. *
  11. * @class PKPUser
  12. * @ingroup user
  13. * @see UserDAO
  14. *
  15. * @brief Basic class describing users existing in the system.
  16. */
  17. // $Id$
  18. class PKPUser extends DataObject {
  19. function PKPUser() {
  20. parent::DataObject();
  21. }
  22. //
  23. // Get/set methods
  24. //
  25. /**
  26. * Get the ID of the user. DEPRECATED in favour of getId.
  27. * @return int
  28. */
  29. function getUserId() {
  30. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  31. return $this->getId();
  32. }
  33. /**
  34. * Set the ID of the user. DEPRECATED in favour of setId.
  35. * @param $userId int
  36. */
  37. function setUserId($userId) {
  38. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  39. return $this->setId($userId);
  40. }
  41. /**
  42. * Get username.
  43. * @return string
  44. */
  45. function getUsername() {
  46. return $this->getData('username');
  47. }
  48. /**
  49. * Set username.
  50. * @param $username string
  51. */
  52. function setUsername($username) {
  53. return $this->setData('username', $username);
  54. }
  55. /**
  56. * Get implicit auth ID string.
  57. * @return String
  58. */
  59. function getAuthStr() {
  60. return $this->getData('authStr');
  61. }
  62. /**
  63. * Set Shib ID string for this user.
  64. * @param $authStr string
  65. */
  66. function setAuthStr($authStr) {
  67. return $this->setData('authStr', $authStr);
  68. }
  69. /**
  70. * Get localized user signature.
  71. */
  72. function getLocalizedSignature() {
  73. return $this->getLocalizedData('signature');
  74. }
  75. function getUserSignature() {
  76. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  77. return $this->getLocalizedSignature();
  78. }
  79. /**
  80. * Get email signature.
  81. * @param $locale string
  82. * @return string
  83. */
  84. function getSignature($locale) {
  85. return $this->getData('signature', $locale);
  86. }
  87. /**
  88. * Set signature.
  89. * @param $signature string
  90. * @param $locale string
  91. */
  92. function setSignature($signature, $locale) {
  93. return $this->setData('signature', $signature, $locale);
  94. }
  95. /**
  96. * Get password (encrypted).
  97. * @return string
  98. */
  99. function getPassword() {
  100. return $this->getData('password');
  101. }
  102. /**
  103. * Set password (assumed to be already encrypted).
  104. * @param $password string
  105. */
  106. function setPassword($password) {
  107. return $this->setData('password', $password);
  108. }
  109. /**
  110. * Get first name.
  111. * @return string
  112. */
  113. function getFirstName() {
  114. return $this->getData('firstName');
  115. }
  116. /**
  117. * Set first name.
  118. * @param $firstName string
  119. */
  120. function setFirstName($firstName)
  121. {
  122. return $this->setData('firstName', $firstName);
  123. }
  124. /**
  125. * Get middle name.
  126. * @return string
  127. */
  128. function getMiddleName() {
  129. return $this->getData('middleName');
  130. }
  131. /**
  132. * Set middle name.
  133. * @param $middleName string
  134. */
  135. function setMiddleName($middleName) {
  136. return $this->setData('middleName', $middleName);
  137. }
  138. /**
  139. * Get initials.
  140. * @return string
  141. */
  142. function getInitials() {
  143. return $this->getData('initials');
  144. }
  145. /**
  146. * Set initials.
  147. * @param $initials string
  148. */
  149. function setInitials($initials) {
  150. return $this->setData('initials', $initials);
  151. }
  152. /**
  153. * Get last name.
  154. * @return string
  155. */
  156. function getLastName() {
  157. return $this->getData('lastName');
  158. }
  159. /**
  160. * Set last name.
  161. * @param $lastName string
  162. */
  163. function setLastName($lastName) {
  164. return $this->setData('lastName', $lastName);
  165. }
  166. /**
  167. * Get user salutation.
  168. * @return string
  169. */
  170. function getSalutation() {
  171. return $this->getData('salutation');
  172. }
  173. /**
  174. * Set user salutation.
  175. * @param $salutation string
  176. */
  177. function setSalutation($salutation) {
  178. return $this->setData('salutation', $salutation);
  179. }
  180. /**
  181. * Get user gender.
  182. * @return string
  183. */
  184. function getGender() {
  185. return $this->getData('gender');
  186. }
  187. /**
  188. * Set user gender.
  189. * @param $gender string
  190. */
  191. function setGender($gender) {
  192. return $this->setData('gender', $gender);
  193. }
  194. /**
  195. * Get affiliation (position, institution, etc.).
  196. * @return string
  197. */
  198. function getAffiliation() {
  199. return $this->getData('affiliation');
  200. }
  201. /**
  202. * Set affiliation.
  203. * @param $affiliation string
  204. */
  205. function setAffiliation($affiliation) {
  206. return $this->setData('affiliation', $affiliation);
  207. }
  208. /**
  209. * Get email address.
  210. * @return string
  211. */
  212. function getEmail() {
  213. return $this->getData('email');
  214. }
  215. /**
  216. * Set email address.
  217. * @param $email string
  218. */
  219. function setEmail($email) {
  220. return $this->setData('email', $email);
  221. }
  222. /**
  223. * Get URL.
  224. * @return string
  225. */
  226. function getUrl() {
  227. return $this->getData('url');
  228. }
  229. /**
  230. * Set URL.
  231. * @param $url string
  232. */
  233. function setUrl($url) {
  234. return $this->setData('url', $url);
  235. }
  236. /**
  237. * Get phone number.
  238. * @return string
  239. */
  240. function getPhone() {
  241. return $this->getData('phone');
  242. }
  243. /**
  244. * Set phone number.
  245. * @param $phone string
  246. */
  247. function setPhone($phone) {
  248. return $this->setData('phone', $phone);
  249. }
  250. /**
  251. * Get fax number.
  252. * @return string
  253. */
  254. function getFax() {
  255. return $this->getData('fax');
  256. }
  257. /**
  258. * Set fax number.
  259. * @param $fax string
  260. */
  261. function setFax($fax) {
  262. return $this->setData('fax', $fax);
  263. }
  264. /**
  265. * Get mailing address.
  266. * @return string
  267. */
  268. function getMailingAddress() {
  269. return $this->getData('mailingAddress');
  270. }
  271. /**
  272. * Set mailing address.
  273. * @param $mailingAddress string
  274. */
  275. function setMailingAddress($mailingAddress) {
  276. return $this->setData('mailingAddress', $mailingAddress);
  277. }
  278. /**
  279. * Get country.
  280. * @return string
  281. */
  282. function getCountry() {
  283. return $this->getData('country');
  284. }
  285. /**
  286. * Set country.
  287. * @param $country string
  288. */
  289. function setCountry($country) {
  290. return $this->setData('country', $country);
  291. }
  292. /**
  293. * Get localized user biography.
  294. */
  295. function getLocalizedBiography() {
  296. return $this->getLocalizedData('biography');
  297. }
  298. function getUserBiography() {
  299. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  300. return $this->getLocalizedBiography();
  301. }
  302. /**
  303. * Get user biography.
  304. * @param $locale string
  305. * @return string
  306. */
  307. function getBiography($locale) {
  308. return $this->getData('biography', $locale);
  309. }
  310. /**
  311. * Set user biography.
  312. * @param $biography string
  313. * @param $locale string
  314. */
  315. function setBiography($biography, $locale) {
  316. return $this->setData('biography', $biography, $locale);
  317. }
  318. /**
  319. * Get localized user interests.
  320. */
  321. function getLocalizedInterests() {
  322. return $this->getLocalizedData('interests');
  323. }
  324. function getUserInterests() {
  325. if (Config::getVar('debug', 'deprecation_warnings')) trigger_error('Deprecated function.');
  326. return $this->getLocalizedInterests();
  327. }
  328. /**
  329. * Get user reviewing interests.
  330. * @param $locale string
  331. * @return string
  332. */
  333. function getInterests($locale) {
  334. return $this->getData('interests', $locale);
  335. }
  336. /**
  337. * Set user reviewing interests.
  338. * @param $interests string
  339. * @param $locale string
  340. */
  341. function setInterests($interests, $locale) {
  342. return $this->setData('interests', $interests, $locale);
  343. }
  344. /**
  345. * Get localized user gossip.
  346. */
  347. function getLocalizedGossip() {
  348. return $this->getLocalizedData('gossip');
  349. }
  350. /**
  351. * Get user gossip.
  352. * @param $locale string
  353. * @return string
  354. */
  355. function getGossip($locale) {
  356. return $this->getData('gossip', $locale);
  357. }
  358. /**
  359. * Set user gossip.
  360. * @param $gossip string
  361. * @param $locale string
  362. */
  363. function setGossip($gossip, $locale) {
  364. return $this->setData('gossip', $gossip, $locale);
  365. }
  366. /**
  367. * Get user's working languages.
  368. * @return array
  369. */
  370. function getLocales() {
  371. $locales = $this->getData('locales');
  372. return isset($locales) ? $locales : array();
  373. }
  374. /**
  375. * Set user's working languages.
  376. * @param $locales array
  377. */
  378. function setLocales($locales) {
  379. return $this->setData('locales', $locales);
  380. }
  381. /**
  382. * Get date user last sent an email.
  383. * @return datestamp (YYYY-MM-DD HH:MM:SS)
  384. */
  385. function getDateLastEmail() {
  386. return $this->getData('dateLastEmail');
  387. }
  388. /**
  389. * Set date user last sent an email.
  390. * @param $dateLastEmail datestamp (YYYY-MM-DD HH:MM:SS)
  391. */
  392. function setDateLastEmail($dateLastEmail) {
  393. return $this->setData('dateLastEmail', $dateLastEmail);
  394. }
  395. /**
  396. * Get date user registered with the site.
  397. * @return datestamp (YYYY-MM-DD HH:MM:SS)
  398. */
  399. function getDateRegistered() {
  400. return $this->getData('dateRegistered');
  401. }
  402. /**
  403. * Set date user registered with the site.
  404. * @param $dateRegistered datestamp (YYYY-MM-DD HH:MM:SS)
  405. */
  406. function setDateRegistered($dateRegistered) {
  407. return $this->setData('dateRegistered', $dateRegistered);
  408. }
  409. /**
  410. * Get date user email was validated with the site.
  411. * @return datestamp (YYYY-MM-DD HH:MM:SS)
  412. */
  413. function getDateValidated() {
  414. return $this->getData('dateValidated');
  415. }
  416. /**
  417. * Set date user email was validated with the site.
  418. * @param $dateValidated datestamp (YYYY-MM-DD HH:MM:SS)
  419. */
  420. function setDateValidated($dateValidated) {
  421. return $this->setData('dateValidated', $dateValidated);
  422. }
  423. /**
  424. * Get date user last logged in to the site.
  425. * @return datestamp
  426. */
  427. function getDateLastLogin() {
  428. return $this->getData('dateLastLogin');
  429. }
  430. /**
  431. * Set date user last logged in to the site.
  432. * @param $dateLastLogin datestamp
  433. */
  434. function setDateLastLogin($dateLastLogin) {
  435. return $this->setData('dateLastLogin', $dateLastLogin);
  436. }
  437. /**
  438. * Check if user must change their password on their next login.
  439. * @return boolean
  440. */
  441. function getMustChangePassword() {
  442. return $this->getData('mustChangePassword');
  443. }
  444. /**
  445. * Set whether or not user must change their password on their next login.
  446. * @param $mustChangePassword boolean
  447. */
  448. function setMustChangePassword($mustChangePassword) {
  449. return $this->setData('mustChangePassword', $mustChangePassword);
  450. }
  451. /**
  452. * Check if user is disabled.
  453. * @return boolean
  454. */
  455. function getDisabled() {
  456. return $this->getData('disabled');
  457. }
  458. /**
  459. * Set whether or not user is disabled.
  460. * @param $disabled boolean
  461. */
  462. function setDisabled($disabled) {
  463. return $this->setData('disabled', $disabled);
  464. }
  465. /**
  466. * Get the reason the user was disabled.
  467. * @return string
  468. */
  469. function getDisabledReason() {
  470. return $this->getData('disabled_reason');
  471. }
  472. /**
  473. * Set the reason the user is disabled.
  474. * @param $reasonDisabled string
  475. */
  476. function setDisabledReason($reasonDisabled) {
  477. return $this->setData('disabled_reason', $reasonDisabled);
  478. }
  479. /**
  480. * Get ID of authentication source for this user.
  481. * @return int
  482. */
  483. function getAuthId() {
  484. return $this->getData('authId');
  485. }
  486. /**
  487. * Set ID of authentication source for this user.
  488. * @param $authId int
  489. */
  490. function setAuthId($authId) {
  491. return $this->setData('authId', $authId);
  492. }
  493. /**
  494. * Get the user's complete name.
  495. * Includes first name, middle name (if applicable), and last name.
  496. * @param $lastFirst boolean return in "LastName, FirstName" format
  497. * @return string
  498. */
  499. function getFullName($lastFirst = false) {
  500. $salutation = $this->getData('salutation');
  501. $firstName = $this->getData('firstName');
  502. $middleName = $this->getData('middleName');
  503. $lastName = $this->getData('lastName');
  504. if ($lastFirst) {
  505. return "$lastName, " . ($salutation != ''?"$salutation ":'') . "$firstName" . ($middleName != ''?" $middleName":'');
  506. } else {
  507. return ($salutation != ''?"$salutation ":'') . "$firstName " . ($middleName != ''?"$middleName ":'') . $lastName;
  508. }
  509. }
  510. function getContactSignature() {
  511. $signature = $this->getFullName();
  512. if ($this->getAffiliation()) $signature .= "\n" . $this->getAffiliation();
  513. if ($this->getPhone()) $signature .= "\n" . __('user.phone') . ' ' . $this->getPhone();
  514. if ($this->getFax()) $signature .= "\n" . __('user.fax') . ' ' . $this->getFax();
  515. $signature .= "\n" . $this->getEmail();
  516. return $signature;
  517. }
  518. }
  519. ?>