The Forum Framework


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. /**
  4. /**
  5.  *
  6.  * file : $file: class_tff.member.php,v $
  7.  * copyright : (c) 2010, Dechesnes
  8.  * support : http://www.theforumframework.com
  9.  *
  10.  */
  11.  
  12. /**
  13.  *
  14.  * This program is free software; you can redistribute it and/or
  15.  * modify it under the terms of the GNU Lesser General Public License
  16.  * as published by the Free Software Foundation; either version 2.1
  17.  * of the License, or (at your option) any later version.
  18.  *
  19.  * This program is distributed in the hope that it will be useful,
  20.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22.  * GNU Lesser General Public License for more details.
  23.  *
  24.  * You should have received a copy of the GNU Lesser General Public License
  25.  * along with this program; if not, write to the Free Software
  26.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  27.  *
  28.  * Or visit http://www.gnu.org/copyleft/gpl.html
  29.  *
  30.  */
  31.  
  32. if ( !defined( 'LOAD_TFF' ) )
  33. {
  34.  
  35. exit ( 'Error: Unauthorized viewing attempted' );
  36.  
  37. }
  38.  
  39. /**
  40.  * @brief The Tff_Member class represents the attributes and behaviors of a
  41.  * single member of the bulletin board.
  42.  *
  43.  * @author Dechesnes
  44.  */
  45. class Tff_Member implements Tff_IObserver, Tff_IStorable
  46. {
  47.  
  48. /**
  49.   * String - the Member's AOL Instant Messenger screen name.
  50.   */
  51. private $_memberAim = '';
  52.  
  53. /**
  54.   * Integer - the Member's avatar id.
  55.   */
  56. private $_memberAvatarId = 0;
  57.  
  58. /**
  59.   * Integer - the Member's birthday as a UNIX timestamp.
  60.   * @since v0.1.1
  61.   */
  62. private $_memberBirthday = 0;
  63.  
  64. /**
  65.   * String - the Member's preferred date formatting (for the PHP date
  66.   * function).
  67.   */
  68. private $_memberDateformat = '';
  69.  
  70. /**
  71.   * String - the Member's email address.
  72.   */
  73. private $_memberEmail = '';
  74.  
  75. /**
  76.   * Boolean - the Member's enabled flag.
  77.   */
  78. private $_memberEnabled = false;
  79.  
  80. /**
  81.   * Integer - the number of the Member's failed logins.
  82.   */
  83. private $_memberFailedLoginCount = 0;
  84.  
  85. /**
  86.   * Integer - the date of the Member's last failed login as a UNIX timestamp.
  87.   */
  88. private $_memberFailedLoginDate = 0;
  89.  
  90. /**
  91.   * String - the Member's home page URL.
  92.   */
  93. private $_memberHomepage = '';
  94.  
  95. /**
  96.   * String - the Member's ICQ UIN number.
  97.   */
  98. private $_memberIcq = '';
  99.  
  100. /**
  101.   * Integer - the Member's unique id.
  102.   */
  103. private $_memberId = 0;
  104.  
  105. /**
  106.   * String - the Member's interests.
  107.   */
  108. private $_memberInterests = '';
  109.  
  110. /**
  111.   * String - the Member's IP address at the time of registration.
  112.   */
  113. private $_memberIp = '';
  114.  
  115. /**
  116.   * Integer - the Member's join date as a UNIX timestamp.
  117.   */
  118. private $_memberJoinDate = 0;
  119.  
  120. /**
  121.   * String - the Member's default display language.
  122.   */
  123. private $_memberLanguage = '';
  124.  
  125. /**
  126.   * Integer - the Member's last visit date as a UNIX timestamp.
  127.   */
  128. private $_memberLastVisit = 0;
  129.  
  130. /**
  131.   * String - the Member's geographic location.
  132.   */
  133. private $_memberLocation = '';
  134.  
  135. /**
  136.   * String - the Member's login username.
  137.   */
  138. private $_memberLogin = '';
  139.  
  140. /**
  141.   * String - the Member's MSN Messenger screen name.
  142.   */
  143. private $_memberMsnm = '';
  144.  
  145. /**
  146.   * String - the Member's real life occupation.
  147.   */
  148. private $_memberOccupation = '';
  149.  
  150. /**
  151.   * String - the Member's encrypted password.
  152.   */
  153. private $_memberPassword = '';
  154.  
  155. /**
  156.   * Integer - the Member's total number of posts in the board.
  157.   */
  158. private $_memberPosts = 0;
  159.  
  160. /**
  161.   * Integer - the Member's rank id
  162.   */
  163. private $_memberRankId = 0;
  164.  
  165. /**
  166.   * String - the Member's screen name to display instead of the login.
  167.   */
  168. private $_memberScreenname = '';
  169.  
  170. /**
  171.   * String - the Member's signature for posting.
  172.   */
  173. private $_memberSig = '';
  174.  
  175. /**
  176.   * String - the Member's default board template.
  177.   */
  178. private $_memberTemplate = '';
  179.  
  180. /**
  181.   * Integer - the Member's time zone offset from GMT (UTC).
  182.   */
  183. private $_memberTimezone = 0;
  184.  
  185. /**
  186.   * String - the Member's title.
  187.   */
  188. private $_memberTitle = '';
  189.  
  190. /**
  191.   * String - the Member's Yahoo! Messenger screen name.
  192.   */
  193. private $_memberYim = '';
  194.  
  195. /**
  196.   * Tff_ObservableImpl - the Member's observer handler
  197.   */
  198. private $_observable = null;
  199.  
  200. /**
  201.   * Boolean - the Member's option to allow incoming and outgoing instant
  202.   * messages.
  203.   */
  204. private $_optAllowPm = false;
  205.  
  206. /**
  207.   * Boolean - the Member's option to always attach the signature to a Post.
  208.   */
  209. private $_optAlwaysAttachSig = false;
  210.  
  211. /**
  212.   * Boolean - the Member's option to receive an email when a new private
  213.   * message arrives.
  214.   */
  215. private $_optEmailPm = false;
  216.  
  217. /**
  218.   * Boolean - the Member's option to not show up in the board's active users
  219.   * list.
  220.   */
  221. private $_optInvisMode = false;
  222.  
  223. /**
  224.   * Boolean - the Member's option to show HTML in any board post.
  225.   */
  226. private $_optShowHtml = true;
  227.  
  228. /**
  229.   * Boolean - the Member's option to show the email address for public
  230.   * access
  231.   */
  232. private $_optShowEmail = false;
  233.  
  234. /**
  235.   * Boolean - the Member's option to show emoticons in any board post.
  236.   */
  237. private $_optShowEmoticons = true;
  238.  
  239. /**
  240.   * Boolean - the Member's option to show the profile for public access
  241.   */
  242. private $_optShowProfile = true;
  243.  
  244. /**
  245.   * Boolean - the Member's option to show other Members' signatures in any
  246.   * board post.
  247.   */
  248. private $_optShowSigs = true;
  249.  
  250. /**
  251.   * Tff_PM_Manager - the Member's private message manager.
  252.   */
  253. private $_pmManager = null;
  254.  
  255. /**
  256.   * String - the action to display the Member profile.
  257.   */
  258. const MEM_DISPLAY_PROFILE = 'viewprofile';
  259.  
  260. /**
  261.   * String - the URL to ICQ's Web Pager API.
  262.   */
  263. const MEM_IM_URL_ICQ = 'http://wwp.icq.com/';
  264.  
  265. /**
  266.   * String - the URL to Yahoo! Messenger's Web messaging API.
  267.   */
  268. const MEM_IM_URL_YIM = 'http://messenger.yahoo.com/edit/send/?.target=';
  269.  
  270. /**
  271.   * String - the code for the default Member sorting criteria.
  272.   */
  273. const MEM_SORT_DEFAULT = 'screenname';
  274.  
  275. /**
  276.   * String - the code for sorting Members by their join date field.
  277.   */
  278. const MEM_SORT_JOIN_DATE = 'join_date';
  279.  
  280. /**
  281.   * String - the code for sorting Members by their string field.
  282.   */
  283. const MEM_SORT_NAME = 'screenname';
  284.  
  285. /**
  286.   * String - the code for sorting Members by their posts field.
  287.   */
  288. const MEM_SORT_POSTS = 'posts';
  289.  
  290. /**
  291.   * String - the code for sorting Members by their posts field, and limiting
  292. * to the top ten positives.
  293.   */
  294. const MEM_SORT_TOP_TEN_POSTS = 'top_ten';
  295.  
  296. /**
  297.   * String - the code for sorting Members by their last visit date field.
  298.   */
  299. const MEM_SORT_VISIT_DATE = 'last_visit';
  300.  
  301. /**
  302.   * String - the name for the Member object cookie
  303.   */
  304. const MEMBER_COOKIE_NAME = 'member_object';
  305.  
  306. /**
  307.   * Integer - the code for the default registration mode
  308.   */
  309. const REG_DEFAULT = 0;
  310.  
  311. /**
  312.   * Integer - the code for the save registration mode
  313.   */
  314. const REG_SAVE = 1;
  315.  
  316. /**
  317.   * Integer - the code for an unknown registration mode
  318.   */
  319. const REG_UNKNOWN = -1;
  320.  
  321. /**
  322.   * Constructor.
  323.   *
  324.   * @param $taintedIdIn Integer - Optional. The unique id of this object.
  325.   */
  326. public function __construct( $taintedIdIn = 0 )
  327. {
  328.  
  329. $this->setObservable( new Tff_ObservableImpl() );
  330. $this->setPmManager( new Tff_PM_Manager() );
  331.  
  332. $cleanId = intval( $taintedIdIn );
  333.  
  334. if ( 0 < $cleanId )
  335. {
  336.  
  337. $this->setId( $cleanId );
  338.  
  339. $this->getPmManager()->setMemberId( $this->getId() );
  340.  
  341. }
  342.  
  343. }
  344.  
  345. /**
  346.   * Saves the current object to the persistence layer.
  347.   *
  348.   * @return Boolean - status of the operation. <code>true</code> is success,
  349.   * <code>false</code> is failure.
  350.   * @throws Tff_BBException If any operation fails
  351.   */
  352. public function add()
  353. {
  354.  
  355. $selfClass = new ReflectionClass( get_class( $this ) );
  356.  
  357. $allProperties = $selfClass->getProperties();
  358.  
  359. ksort( $allProperties );
  360.  
  361. $sqlCmd = 'INSERT INTO ' . TFF_DS_PREFIX . 'member ( ';
  362.  
  363. foreach ( $allProperties as $currentProperty )
  364. {
  365.  
  366. $memberProperty = $currentProperty->getName();
  367.  
  368. if ( '_memberid' == strtolower( $memberProperty ) ||
  369. !( preg_match( "/^(_member)|(_opt)/", $memberProperty ) ) )
  370. {
  371.  
  372. continue;
  373.  
  374. }
  375.  
  376. // Drop the preceding _member or _ (for _opt)
  377. $memberProperty = preg_replace( "/(^_member)|(^_)/", '', $memberProperty );
  378.  
  379. // Insert _ in front of all upper case characters
  380. $memberProperty = preg_replace( "/([A-Z])/", "_\$1", $memberProperty );
  381.  
  382. // Drop the preceding _
  383. $memberProperty = preg_replace( "/^_/", '', $memberProperty );
  384.  
  385. if ( false === strpos( $memberProperty, 'opt' ) )
  386. {
  387.  
  388. $sqlCmd .= 'member_' . strtolower( $memberProperty ) . ', ';
  389.  
  390. }
  391. else
  392. {
  393.  
  394. $sqlCmd .= strtolower( $memberProperty ) . ', ';
  395.  
  396. }
  397.  
  398. }
  399.  
  400. $sqlCmd = preg_replace( "/, $/", ' ) ', $sqlCmd );
  401.  
  402. $sqlCmd .= 'VALUES ( ';
  403.  
  404. foreach ( $allProperties as $currentProperty )
  405. {
  406.  
  407. $memberProperty = $currentProperty->getName();
  408.  
  409. if ( '_memberid' == strtolower( $memberProperty ) ||
  410. !( preg_match( "/^(_member)|(_opt)/", $memberProperty ) ) )
  411. {
  412.  
  413. continue;
  414.  
  415. }
  416.  
  417. // Drop the preceding _member or _ (for _opt)
  418. $memberProperty = preg_replace( "/(^_member)|(^_)/", '', $memberProperty );
  419.  
  420. $getterMethod = 'get' . ucfirst( $memberProperty );
  421.  
  422. if ( is_bool( $this->$getterMethod() ) )
  423. {
  424.  
  425. $sqlCmd .= intval( $this->$getterMethod() ) . ', ';
  426. continue;
  427.  
  428. }
  429. else if ( is_string( $this->$getterMethod() ) )
  430. {
  431.  
  432. $sqlCmd .= "'" . $this->$getterMethod() . "', ";
  433. continue;
  434.  
  435. }
  436. else
  437. {
  438.  
  439. $sqlCmd .= $this->$getterMethod() . ', ';
  440. continue;
  441.  
  442. }
  443.  
  444. }
  445.  
  446. $sqlCmd = preg_replace( "/, $/", ' );', $sqlCmd );
  447.  
  448. /**
  449.   * @TODO Check if the PLI is null?
  450.   */
  451. Tff_Board::getInstance()->getPLI()->query( $sqlCmd );
  452.  
  453. $this->setId( Tff_Board::getInstance()->getPLI()->insertId() );
  454.  
  455. Tff_Board::getInstance()->getPLI()->freeResult();
  456. Tff_Board::getInstance()->getPLI()->close();
  457.  
  458. $this->getObservable()->notifyObservers(
  459. new Tff_Message_Memberadd(
  460. $this->getId(),
  461. $this->getDisplayName()
  462. )
  463. );
  464.  
  465. return true;
  466.  
  467. }
  468.  
  469. /**
  470.   * Authenticates the current Member object login and password using the
  471.   * chosen Login adapter. If login is successful, the Member will be loaded
  472.   * from the persistence layer.
  473.   *
  474.   * @throws Tff_BBException - If any operation fails.
  475.   */
  476. public function authenticate()
  477. {
  478.  
  479. $loginAdapterInstance = null;
  480.  
  481. $loginAdapterClassPath = Tff_ROOT . '/login';
  482.  
  483. ini_set( 'include_path', ini_get( 'include_path' ) . PATH_SEPARATOR . $loginAdapterClassPath );
  484.  
  485. require_once(
  486. 'class_tff.login.' .
  487. strtolower( Tff_Board::getInstance()->getConfigValue( 'bb_authentication' ) ) .
  488. 'adapter.php'
  489. );
  490.  
  491. $loginAdapterClassName = 'Tff_Login_' .
  492. ucfirst( strtolower( Tff_Board::getInstance()->getConfigValue( 'bb_authentication' ) ) ) .
  493. 'Adapter';
  494.  
  495. if ( class_exists( $loginAdapterClassName ) )
  496. {
  497.  
  498. $loginAdapterClass = new ReflectionClass( $loginAdapterClassName );
  499. $factoryMethod = $loginAdapterClass->getMethod( 'getInstance' );
  500. $loginAdapterInstance =& $factoryMethod->invoke( null );
  501.  
  502. $factoryMethod = null;
  503. $loginAdapterClass = null;
  504.  
  505. }
  506.  
  507. if ( null != $loginAdapterInstance )
  508. {
  509.  
  510. $loginAdapterInstance->login( $this->getLogin(), $this->getPassword() );
  511.  
  512. $this->loadByLogin( $this->getLogin() );
  513.  
  514. $this->updateLastVisit();
  515.  
  516. }
  517.  
  518. }
  519.  
  520. /**
  521.   * Authenticates the current Member object login and password for admin
  522.   * access using the chosen Login adapter. If login is successful, the
  523.   * Member will be loaded from the persistence layer.
  524.   *
  525.   * @throws Tff_BBException - If any operation fails.
  526.   */
  527. public function authenticateAdmin()
  528. {
  529.  
  530. $this->authenticate();
  531.  
  532. }
  533.  
  534. /**
  535.   * Gets the Member's AOL Instant Messenger screen name
  536.   *
  537.   * @return String - The <code>$_memberAim</code> property
  538.   */
  539. public function getAim()
  540. {
  541.  
  542. return $this->_memberAim;
  543.  
  544. }
  545.  
  546. /**
  547.   * Gets the Member's avatar id.
  548.   * @todo add notes about avatar objects when the class is written ;-)
  549.   *
  550.   * @return Integer - The <code>$_memberAvatarId</code> property
  551.   */
  552. public function getAvatarId()
  553. {
  554.  
  555. return $this->_memberAvatarId;
  556.  
  557. }
  558.  
  559. /**
  560.   * Gets the Member's birthday as a UNIX timestamp
  561.   *
  562.   * @return Integer - The <code>$_memberBirthday</code> property
  563.   */
  564. public function getBirthday()
  565. {
  566.  
  567. return $this->_memberBirthday;
  568.  
  569. }
  570.  
  571. /**
  572.   * Gets the Member's preferred date formatting (for the PHP date function)
  573.   *
  574.   * @return String - The <code>$_memberDateformat</code> property
  575.   */
  576. public function getDateformat()
  577. {
  578.  
  579. return $this->_memberDateformat;
  580.  
  581. }
  582.  
  583. /**
  584.   * Gets the Member's screen name, or login if screen name is blank. For security
  585.   * reasons, the Member's login should never be displayed, which is why the member
  586.   * has the option to create a screen name as well. Whenever a front-end board script
  587.   * needs to display the member's 'name' this method should be called.
  588.   *
  589.   * @return String - The Member name to display, <code>$_memberScreenname</code> or
  590.   * if that is blank, then <code>$_memberLogin</code>
  591.   */
  592. public function getDisplayName()
  593. {
  594.  
  595. $displayName = $this->getScreenname();
  596.  
  597. if ( null == $displayName || '' == trim( $displayName ) )
  598. {
  599.  
  600. $displayName = $this->getLogin();
  601.  
  602. }
  603.  
  604. return $displayName;
  605.  
  606. }
  607.  
  608. /**
  609.   * Gets the Member's email address
  610.   *
  611.   * @return String - The <code>$_memberEmail</code> property
  612.   */
  613. public function getEmail()
  614. {
  615.  
  616. return $this->_memberEmail;
  617.  
  618. }
  619.  
  620. /**
  621.   * Gets the Member's enabled flag. <code>true</code> indicates
  622.   * the Member is enabled and can login, post, etc. Otherwise returns
  623.   * <code>false</code>
  624.   *
  625.   * @return Boolean - The <code>$_memberEnabled</code> property
  626.   */
  627. public function getEnabled()
  628. {
  629.  
  630. return ( boolean )( $this->_memberEnabled );
  631.  
  632. }
  633.  
  634. /**
  635.   * Gets the number of the Member's failed logins.
  636.   *
  637.   * @return Integer - The <code>$_memberFailedLoginCount</code> property
  638.   */
  639. public function getFailedLoginCount()
  640. {
  641.  
  642. return $this->_memberFailedLoginCount;
  643.  
  644. }
  645.  
  646. /**
  647.   * Gets the date of the Member's last failed login as a UNIX timestamp.
  648.   *
  649.   * @return Integer - The <code>$_memberFailedLoginDate</code> property
  650.   */
  651. public function getFailedLoginDate()
  652. {
  653.  
  654. return $this->_memberFailedLoginDate;
  655.  
  656. }
  657.  
  658. /**
  659.   * Gets the Member's home page URL
  660.   *
  661.   * @return String - The <code>$_memberHomepage</code> property
  662.   */
  663. public function getHomepage()
  664. {
  665.  
  666. return $this->_memberHomepage;
  667.  
  668. }
  669.  
  670. /**
  671.   * Gets the Member's ICQ UIN number
  672.   *
  673.   * @return String - The <code>$_memberIcq</code> property
  674.   */
  675. public function getIcq()
  676. {
  677.  
  678. return $this->_memberIcq;
  679.  
  680. }
  681.  
  682. /**
  683.   * Gets the Member's unique id
  684.   *
  685.   * @return Integer - The <code>$_memberId</code> property
  686.   */
  687. public function getId()
  688. {
  689.  
  690. return $this->_memberId;
  691.  
  692. }
  693.  
  694. /**
  695.   * Gets the Member's interests
  696.   *
  697.   * @return String - The <code>$_memberInterests</code> property
  698.   */
  699. public function getInterests()
  700. {
  701.  
  702. return $this->_memberInterests;
  703.  
  704. }
  705.  
  706. /**
  707.   * Gets the Member's IP address at the time of registration
  708.   *
  709.   * @return String - The <code>$_memberIp</code> property
  710.   */
  711. public function getIp()
  712. {
  713.  
  714. return $this->_memberIp;
  715.  
  716. }
  717.  
  718. /**
  719.   * Gets the Member's join date as a UNIX timestamp
  720.   *
  721.   * @return Integer - The <code>$_memberJoinDate</code> property
  722.   */
  723. public function getJoinDate()
  724. {
  725.  
  726. return $this->_memberJoinDate;
  727.  
  728. }
  729.  
  730. /**
  731.   * Gets the Member's chosen display language
  732.   *
  733.   * @return String - The <code>$_memberLanguage</code> property
  734.   */
  735. public function getLanguage()
  736. {
  737.  
  738. return $this->_memberLanguage;
  739.  
  740. }
  741.  
  742. /**
  743.   * Gets the Member's last visit date as a UNIX timestamp
  744.   *
  745.   * @return Integer - The <code>$_memberLastVisit</code> property
  746.   */
  747. public function getLastVisit()
  748. {
  749.  
  750. return $this->_memberLastVisit;
  751.  
  752. }
  753.  
  754. /**
  755.   * Gets the Member's geographic location
  756.   *
  757.   * @return String - The <code>$_memberLocation</code> property
  758.   */
  759. public function getLocation()
  760. {
  761.  
  762. return $this->_memberLocation;
  763.  
  764. }
  765.  
  766. /**
  767.   * Gets the Member's login username
  768.   *
  769.   * @return String - The <code>$_memberLogin</code> property
  770.   */
  771. public function getLogin()
  772. {
  773.  
  774. return $this->_memberLogin;
  775.  
  776. }
  777.  
  778. /**
  779.   * Gets the Member's MSN Messenger screen name
  780.   *
  781.   * @return String - The <code>$_memberMsnm</code> property
  782.   */
  783. public function getMsnm()
  784. {
  785.  
  786. return $this->_memberMsnm;
  787.  
  788. }
  789.  
  790. /**
  791.   * Gets the Member's observer handler.
  792.   *
  793.   * @return Tff_IObservable - the <code>$_observable</code> property
  794.   */
  795. public function getObservable()
  796. {
  797.  
  798. return $this->_observable;
  799.  
  800. }
  801.  
  802. /**
  803.   * Gets the Member's real life occupation
  804.   *
  805.   * @return String - The <code>$_memberOccupation</code> property
  806.   */
  807. public function getOccupation()
  808. {
  809.  
  810. return $this->_memberOccupation;
  811.  
  812. }
  813.  
  814. /**
  815.   * Gets the Member's option to allow incoming and outgoing instant messages.
  816.   * This will be <code>true</code> or <code>false</code>
  817.   *
  818.   * @return Boolean - The <code>$_optAllowPm</code> property
  819.   */
  820. public function getOptAllowPm()
  821. {
  822.  
  823. return ( boolean )( $this->_optAllowPm );
  824.  
  825. }
  826.  
  827. /**
  828.   * Gets the Member's option to always attach the signature to a Post.
  829.   * This will be <code>true</code> or <code>false</code>
  830.   *
  831.   * @return Boolean - The <code>$_optAlwaysAttachSig</code> property
  832.   */
  833. public function getOptAlwaysAttachSig()
  834. {
  835.  
  836. return ( boolean )( $this->_optAlwaysAttachSig );
  837.  
  838. }
  839.  
  840. /**
  841.   * Gets the Member's option to receive an email when a new private message arrives.
  842.   * This will be <code>true</code> or <code>false</code>
  843.   *
  844.   * @return Boolean - The <code>$_optEmailPm</code> property
  845.   */
  846. public function getOptEmailPm()
  847. {
  848.  
  849. return ( boolean )( $this->_optEmailPm );
  850.  
  851. }
  852.  
  853. /**
  854.   * Gets the Member's option to not show up in the board's active users list.
  855.   * This will be <code>true</code> or <code>false</code>
  856.   *
  857.   * @return Boolean - The <code>$_optInvisMode</code> property
  858.   */
  859. public function getOptInvisMode()
  860. {
  861.  
  862. return ( boolean )( $this->_optInvisMode );
  863.  
  864. }
  865.  
  866. /**
  867.   * Gets the Member's option to show BBML in any board post.
  868.   * This will be <code>true</code> or <code>false</code>
  869.   *
  870.   * @return Boolean - The <code>$_optShowBbml</code> property
  871.   */
  872. public function getOptShowHtml()
  873. {
  874.  
  875. return ( boolean )( $this->_optShowHtml );
  876.  
  877. }
  878.  
  879. /**
  880.   * Gets the Member's option to show the email address for public access.
  881.   * This will be <code>true</code> or <code>false</code>
  882.   *
  883.   * @return Boolean - The <code>$_optShowEmail</code> property
  884.   */
  885. public function getOptShowEmail()
  886. {
  887.  
  888. return ( boolean )( $this->_optShowEmail );
  889.  
  890. }
  891.  
  892. /**
  893.   * Gets the Member's option to show emoticons in any board post.
  894.   * This will be <code>true</code> or <code>false</code>
  895.   *
  896.   * @return Boolean - The <code>$_optShowEmoticons</code> property
  897.   */
  898. public function getOptShowEmoticons()
  899. {
  900.  
  901. return ( boolean )( $this->_optShowEmoticons );
  902.  
  903. }
  904.  
  905. /**
  906.   * Gets the Member's option to show the profile for public access.
  907.   * This will be <code>true</code> or <code>false</code>
  908.   *
  909.   * @return Boolean - The <code>$_optShowProfile</code> property
  910.   */
  911. public function getOptShowProfile()
  912. {
  913.  
  914. return ( boolean )( $this->_optShowProfile );
  915.  
  916. }
  917.  
  918. /**
  919.   * Gets the Member's option to show other Members' signatures in any board post.
  920.   * This will be <code>true</code> or <code>false</code>
  921.   *
  922.   * @return Boolean - The <code>$_optShowSigs</code> property
  923.   */
  924. public function getOptShowSigs()
  925. {
  926.  
  927. return ( boolean )( $this->_optShowSigs );
  928.  
  929. }
  930.  
  931. /**
  932.   * Gets the Member's encrypted password
  933.   *
  934.   * @return String - The <code>$_memberPassword</code> property
  935.   */
  936. public function getPassword()
  937. {
  938.  
  939. return $this->_memberPassword;
  940.  
  941. }
  942.  
  943. /**
  944.   * Gets the Member's percentage of total posts for the Board.
  945.   *
  946.   * @return Float - The Member's percentage of total posts for the Board.
  947.   */
  948. public function getPercentageOfTotalPosts()
  949. {
  950.  
  951. $percentPosts = 0;
  952.  
  953. /**
  954.   * Temp variable to decrease line length and make it more readable...
  955.   * So sue me =P
  956.   */
  957. $totalBoardPosts = Tff_Board::getInstance()->getConfigValue( 'total_posts' );
  958.  
  959. if ( 0 < $this->getPosts() )
  960. {
  961.  
  962. /**
  963.   * 100 is for percentage, not a magic number
  964.   */
  965. $percentPosts = $totalBoardPosts ?
  966. min( 100, ( $this->getPosts() / $totalBoardPosts ) * 100 ) : 0;
  967.  
  968. }
  969.  
  970. return $percentPosts;
  971.  
  972. }
  973.  
  974. /**
  975.   * Gets the Member's private message manager.
  976.   *
  977.   * @return Tff_PM_Manager - the <code>$_pmManager</code> property
  978.   */
  979. public function getPmManager()
  980. {
  981.  
  982. return $this->_pmManager;
  983.  
  984. }
  985.  
  986. /**
  987.   * Gets the Member's posting rate per day for the board
  988.   *
  989.   * @param $adjustedTimeIn - Integer - The current timestamp, pre-adjusted
  990.   * for timezone, as a UNIX timestamp.
  991.   * @return Float - The Member's posting rate per day for the board
  992.   */
  993. public function getPostRatePerDay( $adjustedTimeIn )
  994. {
  995.  
  996. $daysOld = max( 1, round( ( intval( $adjustedTimeIn ) - $this->getJoinDate() ) /
  997. ( Tff_BBUtil::NUM_HOURS_IN_DAY * Tff_BBUtil::NUM_SECS_IN_HOUR ) ) );
  998.  
  999. return ( $this->getPosts() / $daysOld );
  1000.  
  1001. }
  1002.  
  1003. /**
  1004.   * Gets the Member's total number of posts in the board
  1005.   *
  1006.   * @return Integer - The <code>$_memberPosts</code> property
  1007.   */
  1008. public function getPosts()
  1009. {
  1010.  
  1011. return $this->_memberPosts;
  1012.  
  1013. }
  1014.  
  1015. /**
  1016.   * Gets the Member's rank id
  1017.   * @todo Tie this in with the Rank class when it exists ;-)
  1018.   *
  1019.   * @return Integer - The <code>$_memberRankId</code> property
  1020.   */
  1021. public function getRankId()
  1022. {
  1023.  
  1024. return $this->_memberRankId;
  1025.  
  1026. }
  1027.  
  1028. /**
  1029.   * Gets the Member's screen name
  1030.   *
  1031.   * @return String - The <code>$_memberScreenname</code> property
  1032.   */
  1033. public function getScreenname()
  1034. {
  1035.  
  1036. return $this->_memberScreenname;
  1037.  
  1038. }
  1039.  
  1040. /**
  1041.   * Gets the Member's signature for posting
  1042.   *
  1043.   * @return String - The <code>$_memberSig</code> property
  1044.   */
  1045. public function getSig()
  1046. {
  1047.  
  1048. return $this->_memberSig;
  1049.  
  1050. }
  1051.  
  1052. /**
  1053.   * Gets the Member's chosen board display template.
  1054.   *
  1055.   * @return String - The <code>$_memberTemplate</code> property
  1056.   */
  1057. public function getTemplate()
  1058. {
  1059.  
  1060. return $this->_memberTemplate;
  1061.  
  1062. }
  1063.  
  1064. /**
  1065.   * Gets the Member's time zone offset from GMT (UTC)
  1066.   *
  1067.   * @return Integer - The <code>$_memberTimezone</code> property
  1068.   */
  1069. public function getTimezone()
  1070. {
  1071.  
  1072. return $this->_memberTimezone;
  1073.  
  1074. }
  1075.  
  1076. /**
  1077.   * Gets the Member's title
  1078.   *
  1079.   * @return String - The <code>$_memberTitle</code> property
  1080.   */
  1081. public function getTitle()
  1082. {
  1083.  
  1084. return $this->_memberTitle;
  1085.  
  1086. }
  1087.  
  1088. /**
  1089.   * Gets the Member's Yahoo! Messenger screen name
  1090.   *
  1091.   * @return String - The <code>$_memberYim</code> property
  1092.   */
  1093. public function getYim()
  1094. {
  1095.  
  1096. return $this->_memberYim;
  1097.  
  1098. }
  1099.  
  1100. /**
  1101.   * Updates the current object based on the message received.
  1102.   *
  1103.   * @param $msgIn - Tff_IMessage - the message to handle
  1104.   * @throws Tff_BBException If any operation fails
  1105.   */
  1106. public function handleMessage( Tff_IMessage $msgIn )
  1107. {
  1108.  
  1109. switch ( $msgIn->getMsgType() )
  1110. {
  1111.  
  1112. case Tff_Message_Replyadd::MSG_TYPE:
  1113.  
  1114. $sqlCmd = 'UPDATE ' . TFF_DS_PREFIX . 'member SET ';
  1115. $sqlCmd .= 'member_posts = member_posts + 1, ';
  1116. $sqlCmd .= 'member_last_visit = ' . $msgIn->getTimeStamp() . ' ';
  1117. $sqlCmd .= 'WHERE ( member_id = ' . $msgIn->getAuthorId() . ' );';
  1118.  
  1119. Tff_Board::getInstance()->getPLI()->query( $sqlCmd );
  1120.  
  1121. break;
  1122.  
  1123. case Tff_Message_Threadadd::MSG_TYPE:
  1124.  
  1125. $sqlCmd = 'UPDATE ' . TFF_DS_PREFIX . 'member SET ';
  1126. $sqlCmd .= 'member_posts = member_posts + 1, ';
  1127. $sqlCmd .= 'member_last_visit = ' . $msgIn->getTimeStamp() . ' ';
  1128. $sqlCmd .= 'WHERE ( member_id = ' . $msgIn->getAuthorId() . ' );';
  1129.  
  1130. Tff_Board::getInstance()->getPLI()->query( $sqlCmd );
  1131.  
  1132. break;
  1133.  
  1134. }
  1135.  
  1136. }
  1137.  
  1138. /**
  1139.   * Retrieves an object from the persistence layer based on the given object
  1140.   * id and loads it into memory.
  1141.   * The parameter must greater than zero.
  1142.   *
  1143.   * @param $taintedId Integer - The unique id of the object to load.
  1144.   * @return Boolean - status of the operation. <code>true</code> is success,
  1145.   * <code>false</code> is failure.
  1146.   * @throws Tff_BBException If any operation fails
  1147.   */
  1148. public function load( $taintedId )
  1149. {
  1150.  
  1151. $cleanId = intval( $taintedId );
  1152.  
  1153. $sqlCmd = 'SELECT * ';
  1154. $sqlCmd .= 'FROM ' . TFF_DS_PREFIX . 'member ';
  1155. $sqlCmd .= 'WHERE ( member_id = ' . $cleanId . ' );';
  1156.  
  1157. if ( !( is_numeric( $cleanId ) ) || 0 >= $cleanId )
  1158. {
  1159.  
  1160. throw new Tff_BBException( LANG_TFF_MEM_ERROR_NO_MEM . $cleanId );
  1161.  
  1162. }
  1163.  
  1164. $retrievedObject = Tff_Board::getInstance()->getPLI()->queryFirst( $sqlCmd );
  1165.  
  1166. if ( null == $retrievedObject || !( $retrievedObject ) )
  1167. {
  1168.  
  1169. Tff_Board::getInstance()->getPLI()->close();
  1170.  
  1171. throw new Tff_BBException( LANG_TFF_MEM_ERROR_NO_MEM . $cleanId );
  1172.  
  1173. }
  1174.  
  1175. Tff_Board::getInstance()->getPLI()->freeResult();
  1176. Tff_Board::getInstance()->getPLI()->close();
  1177.  
  1178. foreach ( array_keys( get_object_vars( $retrievedObject ) ) as $memberProperty )
  1179. {
  1180.  
  1181. // Drop the preceding member_
  1182. $parsedMemberProperty = preg_replace( "/(^member_)/", '', $memberProperty );
  1183.  
  1184. // Replace underscores with blank spaces and upper case the first letter of each 'word'
  1185. $parsedMemberProperty = ucwords( strtolower( str_replace( '_', ' ', $parsedMemberProperty ) ) );
  1186.  
  1187. // Strip out the spaces
  1188. $parsedMemberProperty = str_replace( ' ', '', $parsedMemberProperty );
  1189.  
  1190. $setterMethod = 'set' . $parsedMemberProperty;
  1191.  
  1192. $this->$setterMethod( $retrievedObject->$memberProperty );
  1193.  
  1194. }
  1195.  
  1196. $this->getPmManager()->setMemberId( $this->getId() );
  1197.  
  1198. $retrivedObject = null;
  1199.  
  1200. return true;
  1201.  
  1202. }
  1203.  
  1204. /**
  1205.   * Retrieves an object from the persistence layer based on the given object
  1206.   * id and loads it into memory.
  1207.   * The parameter must greater than zero.
  1208.   *
  1209.   * @param $taintedLogin String - The login of the Member to load.
  1210.   * @return Boolean - status of the operation. <code>true</code> is success,
  1211.   * <code>false</code> is failure.
  1212.   * @throws Tff_BBException If any operation fails
  1213.   */
  1214. public function loadByLogin( $taintedLogin )
  1215. {
  1216.  
  1217. /**
  1218.   * @TODO CLEANSE THIS!!!
  1219.   */
  1220. $cleanLogin = strip_tags( $taintedLogin );
  1221.  
  1222. $sqlCmd = 'SELECT * ';
  1223. $sqlCmd .= 'FROM ' . TFF_DS_PREFIX . 'member ';
  1224. $sqlCmd .= "WHERE ( member_login = '" . $cleanLogin . "' );";
  1225.  
  1226. $retrievedObject = Tff_Board::getInstance()->getPLI()->queryFirst( $sqlCmd );
  1227.  
  1228. if ( null == $retrievedObject || !( $retrievedObject ) )
  1229. {
  1230.  
  1231. Tff_Board::getInstance()->getPLI()->close();
  1232.  
  1233. throw new Tff_BBException( LANG_TFF_MEM_ERROR_NO_MEM . $cleanLogin );
  1234.  
  1235. }
  1236.  
  1237. Tff_Board::getInstance()->getPLI()->freeResult();
  1238. Tff_Board::getInstance()->getPLI()->close();
  1239.  
  1240. foreach ( array_keys( get_object_vars( $retrievedObject ) ) as $memberProperty )
  1241. {
  1242.  
  1243. // Drop the preceding member_
  1244. $parsedMemberProperty = preg_replace( "/(^member_)/", '', $memberProperty );
  1245.  
  1246. // Replace underscores with blank spaces and upper case the first letter of each 'word'
  1247. $parsedMemberProperty = ucwords( strtolower( str_replace( '_', ' ', $parsedMemberProperty ) ) );
  1248.  
  1249. // Strip out the spaces
  1250. $parsedMemberProperty = str_replace( ' ', '', $parsedMemberProperty );
  1251.  
  1252. $setterMethod = 'set' . $parsedMemberProperty;
  1253.  
  1254. $this->$setterMethod( $retrievedObject->$memberProperty );
  1255.  
  1256. }
  1257.  
  1258. $this->getPmManager()->setMemberId( $this->getId() );
  1259.  
  1260. $retrivedObject = null;
  1261.  
  1262. return true;
  1263.  
  1264. }
  1265.  
  1266. /**
  1267.   * Permanently removes the object from the persistence layer based on its
  1268.   * id.
  1269.   *
  1270.   * @return Boolean - status of the operation. <code>true</code> is success,
  1271.   * <code>false</code> is failure.
  1272.   * @throws Tff_BBException If any operation fails
  1273.   */
  1274. public function remove()
  1275. {
  1276.  
  1277. /**
  1278.   * @TODO decide if it's worth it to properly clean up all the member
  1279.   * posts, etc. or just orphan everything
  1280.   */
  1281. return true;
  1282.  
  1283. }
  1284.  
  1285. /**
  1286.   * Sets the Member's AOL Instant Messenger screen name
  1287.   *
  1288.   * @param $taintedValue String - the AOL Instant Messenger screen name
  1289.   */
  1290. public function setAim( $taintedValue )
  1291. {
  1292.  
  1293. $this->_memberAim = trim( $taintedValue );
  1294.  
  1295. }
  1296.  
  1297. /**
  1298.   * Sets the Member's avatar id.
  1299.   * This must not be null, must be numeric and greater than zero
  1300.   *
  1301.   * @param $taintedValue Integer - the avatar id
  1302.   * @throws Tff_BBException If value is invalid
  1303.   */
  1304. public function setAvatarId( $taintedValue )
  1305. {
  1306.  
  1307. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) || 0 > $taintedValue )
  1308. {
  1309.  
  1310. throw new Tff_BBException( LANG_TFF_MEM_BAD_AVATAR_ID . $taintedValue );
  1311.  
  1312. }
  1313.  
  1314. $this->_memberAvatarId = intval( $taintedValue );
  1315.  
  1316. }
  1317.  
  1318. /**
  1319.   * Sets the Member's birthday as a UNIX timestamp.
  1320.   * This must not be null, must be numeric and greater than zero
  1321.   *
  1322.   * @param $taintedValue Integer - the birthday timestamp
  1323.   * @throws Tff_BBException If value is invalid
  1324.   */
  1325. public function setBirthday( $taintedValue )
  1326. {
  1327.  
  1328. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) || 0 > $taintedValue )
  1329. {
  1330.  
  1331. throw new Tff_BBException( LANG_TFF_MEM_BAD_BIRTHDAY . $taintedValue );
  1332.  
  1333. }
  1334.  
  1335. $this->_memberBirthday = intval( $taintedValue );
  1336.  
  1337. }
  1338.  
  1339. /**
  1340.   * Sets the Member's preferred date formatting (for the PHP date function).
  1341.   * This must not be null and must be a non-empty string
  1342.   *
  1343.   * @param $taintedValue String - the date format
  1344.   * @throws Tff_BBException If value is invalid
  1345.   */
  1346. public function setDateformat( $taintedValue )
  1347. {
  1348.  
  1349. $taintedValue = trim( $taintedValue );
  1350.  
  1351. if ( is_null( $taintedValue ) || !( is_string( $taintedValue ) ) )
  1352. {
  1353.  
  1354. throw new Tff_BBException( LANG_TFF_MEM_BAD_DATE_FORMAT . $taintedValue );
  1355.  
  1356. }
  1357.  
  1358. $this->_memberDateformat = $taintedValue;
  1359.  
  1360. }
  1361.  
  1362. /**
  1363.   * Sets the Member's email address.
  1364.   * This must not be null and must be a non-empty string
  1365.   *
  1366.   * @param $taintedValue String - the email address
  1367.   * @throws Tff_BBException If value is invalid
  1368.   */
  1369. public function setEmail( $taintedValue )
  1370. {
  1371.  
  1372. $taintedValue = trim( $taintedValue );
  1373.  
  1374. if ( is_null( $taintedValue ) || !( is_string( $taintedValue ) ) || '' == $taintedValue )
  1375. {
  1376.  
  1377. throw new Tff_BBException( LANG_TFF_MEM_BAD_EMAIL . $taintedValue );
  1378.  
  1379. }
  1380.  
  1381. $this->_memberEmail = $taintedValue;
  1382.  
  1383. }
  1384.  
  1385. /**
  1386.   * Sets the Member's enabled flag. <code>true</code> indicates
  1387.   * the Member is enabled and can login, post, etc. Otherwise returns
  1388.   * <code>false</code>.
  1389.   * This must not be null, and must be numeric or must be a boolean value
  1390.   *
  1391.   * @param $taintedValue Boolean - the enabled flag
  1392.   * @throws Tff_BBException If value is invalid
  1393.   */
  1394. public function setEnabled( $taintedValue )
  1395. {
  1396.  
  1397. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1398. {
  1399.  
  1400. throw new Tff_BBException( LANG_TFF_MEM_BAD_ENABLED_OPT . $taintedValue );
  1401.  
  1402. }
  1403.  
  1404. $this->_memberEnabled = ( boolean )( $taintedValue );
  1405.  
  1406. }
  1407.  
  1408. /**
  1409.   * Sets the number of the Member's failed logins.
  1410.   * This must not be null, must be numeric and greater than zero
  1411.   *
  1412.   * @param $taintedValue Integer - the number of failed logins
  1413.   * @throws BuBOL_BBException If value is invalid
  1414.   * @since v0.1.2
  1415.   */
  1416. public function setFailedLoginCount( $taintedValue )
  1417. {
  1418.  
  1419. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) || 0 > $taintedValue )
  1420. {
  1421.  
  1422. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_FAILED_LOGIN_COUNT . $taintedValue );
  1423.  
  1424. }
  1425.  
  1426. $this->_memberFailedLoginCount = intval( $taintedValue );
  1427.  
  1428. }
  1429.  
  1430. /**
  1431.   * Sets the date of the Member's last failed login as a UNIX timestamp.
  1432.   * This must not be null, must be numeric and greater than zero
  1433.   *
  1434.   * @param $taintedValue Integer - the last failed login date
  1435.   * @throws BuBOL_BBException If value is invalid
  1436.   * @since v0.1.2
  1437.   */
  1438. public function setFailedLoginDate( $taintedValue )
  1439. {
  1440.  
  1441. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) || 0 > $taintedValue )
  1442. {
  1443.  
  1444. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_FAILED_LOGIN_DATE . $taintedValue );
  1445.  
  1446. }
  1447.  
  1448. $this->_memberFailedLoginDate = intval( $taintedValue );
  1449.  
  1450. }
  1451.  
  1452. /**
  1453.   * Sets the Member's home page URL
  1454.   *
  1455.   * @param $taintedValue String - the home page URL
  1456.   */
  1457. public function setHomepage( $taintedValue )
  1458. {
  1459.  
  1460. if ( null != $taintedValue && '' != trim( $taintedValue ) )
  1461. {
  1462.  
  1463. if ( 0 !== strpos( $taintedValue, 'http://' ) )
  1464. {
  1465.  
  1466. $taintedValue = "http://$taintedValue";
  1467.  
  1468. }
  1469.  
  1470. }
  1471.  
  1472. $this->_memberHomepage = trim( $taintedValue );
  1473.  
  1474. }
  1475.  
  1476. /**
  1477.   * Sets the Member's ICQ UIN number
  1478.   *
  1479.   * @param $taintedValue String - the ICQ UIN number
  1480.   */
  1481. public function setIcq( $taintedValue )
  1482. {
  1483.  
  1484. $this->_memberIcq = trim( $taintedValue );
  1485.  
  1486. }
  1487.  
  1488. /**
  1489.   * Sets the Member's unique id.
  1490.   * This must not be null, must be numeric and greater than zero
  1491.   *
  1492.   * @param $taintedValue Integer - the unique id
  1493.   * @throws BuBOL_BBException If value is invalid
  1494.   */
  1495. public function setId( $taintedValue )
  1496. {
  1497.  
  1498. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) || 0 >= $taintedValue )
  1499. {
  1500.  
  1501. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_ID . $taintedValue );
  1502.  
  1503. }
  1504.  
  1505. $this->_memberId = intval( $taintedValue );
  1506.  
  1507. }
  1508.  
  1509. /**
  1510.   * Sets the Member's IP address at the time of registration
  1511.   *
  1512.   * @param $taintedValue String - the IP address
  1513.   */
  1514. public function setIp( $taintedValue )
  1515. {
  1516.  
  1517. $this->_memberIp = trim( $taintedValue );
  1518.  
  1519. }
  1520.  
  1521. /**
  1522.   * Sets the Member's interests
  1523.   *
  1524.   * @param $taintedValue String - the interests
  1525.   */
  1526. public function setInterests( $taintedValue )
  1527. {
  1528.  
  1529. $this->_memberInterests = trim( $taintedValue );
  1530.  
  1531. }
  1532.  
  1533. /**
  1534.   * Sets the Member's join date as a UNIX timestamp.
  1535.   * This must not be null, must be numeric and greater than zero
  1536.   *
  1537.   * @param $taintedValue Integer - the join date
  1538.   * @throws BuBOL_BBException If value is invalid
  1539.   */
  1540. public function setJoinDate( $taintedValue )
  1541. {
  1542.  
  1543. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) || 0 > $taintedValue )
  1544. {
  1545.  
  1546. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_JOIN_DATE . $taintedValue );
  1547.  
  1548. }
  1549.  
  1550. $this->_memberJoinDate = intval( $taintedValue );
  1551.  
  1552. }
  1553.  
  1554. /**
  1555.   * Sets the Member's chosen language.
  1556.   *
  1557.   * @param $taintedValue String - the language
  1558.   * @since v0.1.2
  1559.   */
  1560. public function setLanguage( $taintedValue )
  1561. {
  1562.  
  1563. $this->_memberLanguage = trim( $taintedValue );
  1564.  
  1565. }
  1566.  
  1567. /**
  1568.   * Sets the Member's last visit date as a UNIX timestamp.
  1569.   * This must not be null, must be numeric and greater than zero
  1570.   *
  1571.   * @param $taintedValue Integer - the last visit date
  1572.   * @throws BuBOL_BBException If value is invalid
  1573.   */
  1574. public function setLastVisit( $taintedValue )
  1575. {
  1576.  
  1577. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) || 0 > $taintedValue )
  1578. {
  1579.  
  1580. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_LAST_VISIT . $taintedValue );
  1581.  
  1582. }
  1583.  
  1584. $this->_memberLastVisit = intval( $taintedValue );
  1585.  
  1586. }
  1587.  
  1588. /**
  1589.   * Sets the Member's geographic location
  1590.   *
  1591.   * @param $taintedValue String - the location
  1592.   */
  1593. public function setLocation( $taintedValue )
  1594. {
  1595.  
  1596. $this->_memberLocation = trim( $taintedValue );
  1597.  
  1598. }
  1599.  
  1600. /**
  1601.   * Sets the Member's login username.
  1602.   * This must not be null and must be a non-empty string
  1603.   *
  1604.   * @param $taintedValue String - the login
  1605.   * @throws BuBOL_BBException If value is invalid
  1606.   */
  1607. public function setLogin( $taintedValue )
  1608. {
  1609.  
  1610. $taintedValue = trim( $taintedValue );
  1611.  
  1612. if ( is_null( $taintedValue ) || !( is_string( $taintedValue ) ) || '' == $taintedValue )
  1613. {
  1614.  
  1615. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_LOGIN . $taintedValue );
  1616.  
  1617. }
  1618.  
  1619. $this->_memberLogin = $taintedValue;
  1620.  
  1621. }
  1622.  
  1623. /**
  1624.   * Sets the Member's MSN Messenger screen name
  1625.   *
  1626.   * @param $taintedValue String - the MSN Messenger screen name
  1627.   */
  1628. public function setMsnm( $taintedValue )
  1629. {
  1630.  
  1631. $this->_memberMsnm = trim( $taintedValue );
  1632.  
  1633. }
  1634.  
  1635. /**
  1636.   * Sets the Member's observer handle.
  1637.   *
  1638.   * @param $observableIn BuBOL_IObservable - the observer handle
  1639.   */
  1640. public function setObservable( $observableIn )
  1641. {
  1642.  
  1643. $this->_observable = $observableIn;
  1644.  
  1645. }
  1646.  
  1647. /**
  1648.   * Sets the Member's real life occupation
  1649.   *
  1650.   * @param $taintedValue String - the real life occupation
  1651.   */
  1652. public function setOccupation( $taintedValue )
  1653. {
  1654.  
  1655. $this->_memberOccupation = trim( $taintedValue );
  1656.  
  1657. }
  1658.  
  1659. /**
  1660.   * Sets the Member's option to allow incoming and outgoing instant messages.
  1661.   * This must not be null, and must be numeric or must be a boolean value
  1662.   *
  1663.   * @param $taintedValue Boolean - the allow pm option
  1664.   * @throws BuBOL_BBException If value is invalid
  1665.   */
  1666. public function setOptAllowPm( $taintedValue )
  1667. {
  1668.  
  1669. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1670. {
  1671.  
  1672. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_ALLOW_PM_OPT . $taintedValue );
  1673.  
  1674. }
  1675.  
  1676. $this->_optAllowPm = ( boolean )( $taintedValue );
  1677.  
  1678. }
  1679.  
  1680. /**
  1681.   * Sets the Member's option to always attach the signature to a Post.
  1682.   * This must not be null, and must be numeric or must be a boolean value
  1683.   *
  1684.   * @param $taintedValue Boolean - the always attach signatures option
  1685.   * @throws BuBOL_BBException If value is invalid
  1686.   * @since v0.1.3
  1687.   */
  1688. public function setOptAlwaysAttachSig( $taintedValue )
  1689. {
  1690.  
  1691. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1692. {
  1693.  
  1694. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_ALWAYS_ATT_SIG_OPT . $taintedValue );
  1695.  
  1696. }
  1697.  
  1698. $this->_optAlwaysAttachSig = ( boolean )( $taintedValue );
  1699.  
  1700. }
  1701.  
  1702. /**
  1703.   * Sets the Member's option to receive an email when a new private message arrives.
  1704.   * This must not be null, and must be numeric or must be a boolean value
  1705.   *
  1706.   * @param $taintedValue Boolean - the email on new pm option
  1707.   * @throws BuBOL_BBException If value is invalid
  1708.   */
  1709. public function setOptEmailPm( $taintedValue )
  1710. {
  1711.  
  1712. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1713. {
  1714.  
  1715. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_EMAIL_ON_PM_OPT . $taintedValue );
  1716.  
  1717. }
  1718.  
  1719. $this->_optEmailPm = ( boolean )( $taintedValue );
  1720.  
  1721. }
  1722.  
  1723. /**
  1724.   * Sets the Member's option to not show up in the board's active users list.
  1725.   * This must not be null, and must be numeric or must be a boolean value
  1726.   *
  1727.   * @param $taintedValue Boolean - the invisible mode option
  1728.   * @throws BuBOL_BBException If value is invalid
  1729.   */
  1730. public function setOptInvisMode( $taintedValue )
  1731. {
  1732.  
  1733. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1734. {
  1735.  
  1736. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_INVIS_MODE_OPT . $taintedValue );
  1737.  
  1738. }
  1739.  
  1740. $this->_optInvisMode = ( boolean )( $taintedValue );
  1741.  
  1742. }
  1743.  
  1744. /**
  1745.   * Sets the Member's option to show BBML in any board post.
  1746.   * This must not be null, and must be numeric or must be a boolean value
  1747.   *
  1748.   * @param $taintedValue Boolean - the show BBML option
  1749.   * @throws BuBOL_BBException If value is invalid
  1750.   */
  1751. public function setOptShowBbml( $taintedValue )
  1752. {
  1753.  
  1754. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1755. {
  1756.  
  1757. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_BBML_OPT . $taintedValue );
  1758.  
  1759. }
  1760.  
  1761. $this->_optShowBbml = ( boolean )( $taintedValue );
  1762.  
  1763. }
  1764.  
  1765. /**
  1766.   * Sets the Member's option to show the email address for public access.
  1767.   * This must not be null, and must be numeric or must be a boolean value
  1768.   *
  1769.   * @param $taintedValue Boolean - the show email option
  1770.   * @throws BuBOL_BBException If value is invalid
  1771.   */
  1772. public function setOptShowEmail( $taintedValue )
  1773. {
  1774.  
  1775. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1776. {
  1777.  
  1778. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_EMAIL_OPT . $taintedValue );
  1779.  
  1780. }
  1781.  
  1782. $this->_optShowEmail = ( boolean )( $taintedValue );
  1783.  
  1784. }
  1785.  
  1786. /**
  1787.   * Sets the Member's option to show emoticons in any board post.
  1788.   * This must not be null, and must be numeric or must be a boolean value
  1789.   *
  1790.   * @param $taintedValue Boolean - the show emoticons option
  1791.   * @throws BuBOL_BBException If value is invalid
  1792.   */
  1793. public function setOptShowEmoticons( $taintedValue )
  1794. {
  1795.  
  1796. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1797. {
  1798.  
  1799. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_EMOT_OPT . $taintedValue );
  1800.  
  1801. }
  1802.  
  1803. $this->_optShowEmoticons = ( boolean )( $taintedValue );
  1804.  
  1805. }
  1806.  
  1807. /**
  1808.   * Sets the Member's option to show the profile for public access.
  1809.   * This must not be null, and must be numeric or must be a boolean value
  1810.   *
  1811.   * @param $taintedValue Boolean - the show profile option
  1812.   * @throws BuBOL_BBException If value is invalid
  1813.   * @since v0.1.3
  1814.   */
  1815. public function setOptShowProfile( $taintedValue )
  1816. {
  1817.  
  1818. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1819. {
  1820.  
  1821. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_PROFILE_OPT . $taintedValue );
  1822.  
  1823. }
  1824.  
  1825. $this->_optShowProfile = ( boolean )( $taintedValue );
  1826.  
  1827. }
  1828.  
  1829. /**
  1830.   * Sets the Member's option to show other Members' signatures in any board post.
  1831.   * This must not be null, and must be numeric or must be a boolean value
  1832.   *
  1833.   * @param $taintedValue Boolean - the show sigs option
  1834.   * @throws BuBOL_BBException If value is invalid
  1835.   */
  1836. public function setOptShowSigs( $taintedValue )
  1837. {
  1838.  
  1839. if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) )
  1840. {
  1841.  
  1842. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_SIGS_OPT . $taintedValue );
  1843.  
  1844. }
  1845.  
  1846. $this->_optShowSigs = ( boolean )( $taintedValue );
  1847.  
  1848. }
  1849.  
  1850. /**
  1851.   * Sets the Member's encrypted password
  1852.   * This must not be null and must be a non-empty string
  1853.   *
  1854.   * @param $taintedValue String - the encrypted password
  1855.   * @throws BuBOL_BBException If value is invalid
  1856.   */
  1857. public function setPassword( $taintedValue )
  1858. {
  1859.  
  1860. $taintedValue = trim( $taintedValue );
  1861.  
  1862. if ( is_null( $taintedValue ) || !( is_string( $taintedValue ) ) || '' == $taintedValue )
  1863. {
  1864.  
  1865. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_PASSWORD . $taintedValue );
  1866.  
  1867. }
  1868.  
  1869. $this->_memberPassword = $taintedValue;
  1870.  
  1871. }
  1872.  
  1873. /**
  1874.   * Sets the Member's private message manager.
  1875.   *
  1876.   * @param $pmManagerIn BuBOL_PM_Manager - the private message manager.
  1877.   * @since v0.1.3
  1878.   */
  1879. public function setPmManager( $pmManagerIn )
  1880. {
  1881.  
  1882. $this->_pmManager = $pmManagerIn;
  1883.  
  1884. }
  1885.  
  1886. /**
  1887.   * Sets the Member's total number of posts in the board.
  1888.   * This must not be null, must be numeric and greater than zero
  1889.   *
  1890.   * @param $taintedValue Integer - the number of member posts
  1891.   * @throws BuBOL_BBException If value is invalid
  1892.   */
  1893. public function setPosts( $taintedValue )
  1894. {
  1895.  
  1896. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) || 0 > $taintedValue )
  1897. {
  1898.  
  1899. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_POSTS . $taintedValue );
  1900.  
  1901. }
  1902.  
  1903. $this->_memberPosts = intval( $taintedValue );
  1904.  
  1905. }
  1906.  
  1907. /**
  1908.   * Sets the Member's rank id.
  1909.   * This must not be null, must be numeric and greater than zero
  1910.   *
  1911.   * @param $taintedValue Integer - the rank id
  1912.   * @throws BuBOL_BBException If value is invalid
  1913.   */
  1914. public function setRankId( $taintedValue )
  1915. {
  1916.  
  1917. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) || 0 > $taintedValue )
  1918. {
  1919.  
  1920. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_RANK_ID . $taintedValue );
  1921.  
  1922. }
  1923.  
  1924. $this->_memberRankId = intval( $taintedValue );
  1925.  
  1926. }
  1927.  
  1928. /**
  1929.   * Sets the Member's screen name to display instead of the login
  1930.   *
  1931.   * @param $taintedValue String - the screen name
  1932.   */
  1933. public function setScreenname( $taintedValue )
  1934. {
  1935.  
  1936. $this->_memberScreenname = trim( $taintedValue );
  1937.  
  1938. }
  1939.  
  1940. /**
  1941.   * Sets the Member's signature for posting
  1942.   *
  1943.   * @param $taintedValue String - the signature
  1944.   */
  1945. public function setSig( $taintedValue )
  1946. {
  1947.  
  1948. $this->_memberSig = trim( $taintedValue );
  1949.  
  1950. }
  1951.  
  1952. /**
  1953.   * Sets the Member's chosen board display template.
  1954.   *
  1955.   * @param $taintedValue String - the display template name
  1956.   * @since v0.1.2
  1957.   */
  1958. public function setTemplate( $taintedValue )
  1959. {
  1960.  
  1961. $this->_memberTemplate = trim( $taintedValue );
  1962.  
  1963. }
  1964.  
  1965. /**
  1966.   * Sets the Member's time zone offset from GMT (UTC).
  1967.   * This must not be null and must be numeric.
  1968.   *
  1969.   * @param $taintedValue Integer - the timezone offset from GMT
  1970.   * @throws Tff_BBException If value is invalid
  1971.   */
  1972. public function setTimezone( $taintedValue )
  1973. {
  1974.  
  1975. if ( is_null( $taintedValue ) || !( is_numeric( $taintedValue ) ) )
  1976. {
  1977.  
  1978. throw new BuBOL_BBException( LANG_TFF_MEM_BAD_TIMEZONE . $taintedValue );
  1979.  
  1980. }
  1981.  
  1982. $this->_memberTimezone = intval( $taintedValue );
  1983.  
  1984. }
  1985.  
  1986. /**
  1987.   * Sets the Member's title
  1988.   *
  1989.   * @param $taintedValue String - the title
  1990.   */
  1991. public function setTitle( $taintedValue )
  1992. {
  1993.  
  1994. $this->_memberTitle = trim( $taintedValue );
  1995.  
  1996. }
  1997.  
  1998. /**
  1999.   * Sets the Member's Yahoo! Messenger screen name
  2000.   *
  2001.   * @param $taintedValue String - the Yahoo! Messenger screen name
  2002.   */
  2003. public function setYim( $taintedValue )
  2004. {
  2005.  
  2006. $this->_memberYim = trim( $taintedValue );
  2007.  
  2008. }
  2009.  
  2010. /**
  2011.   * Logs the Member in by setting _SESSION and optionally, _COOKIE
  2012.   * variables.
  2013.   *
  2014.   * @param $setCookies Boolean - true or false for whether or not to use
  2015.   * cookies.
  2016.   * @param $salt String - A string used to further secure the cookie
  2017.   * data
  2018.   * @return Boolean - Always true unless $setCookies is true, then it will
  2019.   * return the status of setting the cookie.
  2020.   */
  2021. public function signIn( $setCookies, $salt )
  2022. {
  2023.  
  2024. /**
  2025.   * @TODO This should throw an Exception, not boolean return values >=/
  2026.   */
  2027. $cookieSuccess = true;
  2028.  
  2029. $_SESSION[ 'member_auth' ] = true;
  2030. $_SESSION[ self::MEMBER_COOKIE_NAME ] = base64_encode( serialize( $this ) );
  2031.  
  2032. if ( $setCookies )
  2033. {
  2034.  
  2035. $cookieExpiry = Tff_BBUtil::getGmtTimestamp();
  2036. $cookieExpiry += ( $this->getTimezone() * Tff_BBUtil::NUM_SECS_IN_HOUR );
  2037. $cookieExpiry += (
  2038. Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_expire' ) *
  2039. Tff_BBUtil::NUM_HOURS_IN_DAY *
  2040. Tff_BBUtil::NUM_SECS_IN_HOUR
  2041. );
  2042.  
  2043. /**
  2044.   * Extra security here. Found this on a php.net user comment
  2045.   * at: http://www.php.net/manual/en/function.setcookie.php
  2046.   *
  2047.   * 1. Serialize and encode the Member object
  2048.   */
  2049. $cookieData = base64_encode( serialize( $this ) );
  2050.  
  2051. /**
  2052.   * 2. Generate a checksum of the serialized Member object
  2053.   * and salt the checksum with the board token constant
  2054.   */
  2055. $checkSum = Tff_BBUtil::generateDataChecksum( $cookieData, $salt );
  2056.  
  2057. /**
  2058.   * 3. Wrap up the data and the checksum
  2059.   */
  2060. $strongCookieData = serialize( array( $cookieData, $checkSum ) );
  2061.  
  2062. $cookieSuccess = @setcookie(
  2063. self::MEMBER_COOKIE_NAME,
  2064. $strongCookieData,
  2065. $cookieExpiry,
  2066. Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_path' ),
  2067. Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_domain' )
  2068. );
  2069.  
  2070. }
  2071.  
  2072. return $cookieSuccess;
  2073.  
  2074. }
  2075.  
  2076. /**
  2077.   * Logs the Member out by destroying _SESSION and _COOKIE variables.
  2078.   *
  2079.   * @return Boolean - Always true unless cookies are detected, then it will
  2080.   * return the status of setting the cookie.
  2081.   */
  2082. public static function signOut()
  2083. {
  2084.  
  2085. /**
  2086.   * Normally I'd want to default to false, but in this case we don't know
  2087.   * if cookies are even being used.
  2088.   * @TODO This should throw an Exception, not boolean return values >=/
  2089.   */
  2090. $cookieSuccess = true;
  2091.  
  2092. $_SESSION = array();
  2093.  
  2094.  
  2095. /**
  2096.   * Set expiration to 24 hours ago, GMT
  2097.   */
  2098. $cookieExpiry = Tff_BBUtil::getGmtTimestamp() -
  2099. ( Tff_BBUtil::NUM_HOURS_IN_DAY * Tff_BBUtil::NUM_SECS_IN_HOUR );
  2100.  
  2101. if ( isset( $_COOKIE[ session_name() ] ) )
  2102. {
  2103.  
  2104. '',
  2105. $cookieExpiry,
  2106. '/'
  2107. );
  2108.  
  2109. }
  2110.  
  2111.  
  2112. if ( isset( $_COOKIE[ self::MEMBER_COOKIE_NAME ] ) )
  2113. {
  2114.  
  2115. /**
  2116.   * Attempt to destroy cookie
  2117.   */
  2118. $cookieSuccess = @setcookie(
  2119. self::MEMBER_COOKIE_NAME,
  2120. '',
  2121. $cookieExpiry,
  2122. Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_path' ),
  2123. Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_domain' )
  2124. );
  2125.  
  2126. }
  2127.  
  2128. return $cookieSuccess;
  2129.  
  2130. }
  2131.  
  2132. /**
  2133.   * Updates the current object in the persistence layer.
  2134.   *
  2135.   * @return Boolean - status of the operation. <code>true</code> is success,
  2136.   * <code>false</code> is failure.
  2137.   * @throws Tff_BBException If any operation fails
  2138.   */
  2139. public function update()
  2140. {
  2141.  
  2142. $selfClass = new ReflectionClass( get_class( $this ) );
  2143.  
  2144. $allProperties = $selfClass->getProperties();
  2145.  
  2146. ksort( $allProperties );
  2147.  
  2148. $sqlCmd = 'UPDATE ' . TFF_DS_PREFIX . 'member SET ';
  2149.  
  2150. foreach ( $allProperties as $currentProperty )
  2151. {
  2152.  
  2153. $memberProperty = $currentProperty->getName();
  2154.  
  2155. /**
  2156.   * The member_ip field should never be updated
  2157.   * as it is stored only on member sign-up to be used
  2158.   * as a counter-measure against member sign up flood attacks
  2159.   * if you feel it must be updated... just comment-out the line below
  2160.   */
  2161. if ( '_memberid' == strtolower( $memberProperty ) ||
  2162. '_memberip' == strtolower( $memberProperty ) ||
  2163. !( preg_match( "/^(_member)|(_opt)/", $memberProperty ) ) )
  2164. {
  2165.  
  2166. continue;
  2167.  
  2168. }
  2169.  
  2170. // Drop the preceding _member or _ (for _opt)
  2171. $memberProperty = preg_replace( "/(^_member)|(^_)/", '', $memberProperty );
  2172.  
  2173. $getterMethod = 'get' . ucfirst( $memberProperty );
  2174.  
  2175. // Insert _ in front of all upper case characters
  2176. $memberProperty = preg_replace( "/([A-Z])/", "_\$1", $memberProperty );
  2177.  
  2178. // Drop the preceding _
  2179. $memberProperty = preg_replace( "/^_/", '', $memberProperty );
  2180.  
  2181. if ( false === strpos( $memberProperty, 'opt' ) )
  2182. {
  2183.  
  2184. $sqlCmd .= 'member_' . strtolower( $memberProperty ) . ' = ';
  2185.  
  2186. }
  2187. else
  2188. {
  2189.  
  2190. $sqlCmd .= strtolower( $memberProperty ) . ' = ';
  2191.  
  2192. }
  2193.  
  2194. if ( is_bool( $this->$getterMethod() ) )
  2195. {
  2196.  
  2197. $sqlCmd .= intval( $this->$getterMethod() ) . ', ';
  2198. continue;
  2199.  
  2200. }
  2201. else if ( is_string( $this->$getterMethod() ) )
  2202. {
  2203.  
  2204. $sqlCmd .= "'" . $this->$getterMethod() . "', ";
  2205. continue;
  2206.  
  2207. }
  2208. else
  2209. {
  2210.  
  2211. $sqlCmd .= $this->$getterMethod() . ', ';
  2212. continue;
  2213.  
  2214. }
  2215.  
  2216. }
  2217.  
  2218. $sqlCmd = preg_replace( "/, $/", '', $sqlCmd );
  2219.  
  2220. $sqlCmd .= ' WHERE ( member_id = ' . $this->getId() . ' );';
  2221.  
  2222. /**
  2223.   * @TODO Check if the PLI is null?
  2224.   */
  2225. Tff_Board::getInstance()->getPLI()->query( $sqlCmd );
  2226. Tff_Board::getInstance()->getPLI()->freeResult();
  2227. Tff_Board::getInstance()->getPLI()->close();
  2228.  
  2229. /**
  2230.   * @TODO A little notifyObserver action here? =D
  2231.   * Does anything really care if a Member updates itself?
  2232.   * Logging maybe?
  2233.   */
  2234. return true;
  2235.  
  2236. }
  2237.  
  2238. /**
  2239.   * Incremends the current Thread's view count in memory and in the
  2240.   * persistence layer by the given number of views, default increment by 1.
  2241.   *
  2242.   * @throws Tff_BBException If persistence layer operation fails.
  2243.   */
  2244. public function updateLastVisit()
  2245. {
  2246.  
  2247. $rightNow = Tff_BBUtil::getGmtTimestamp();
  2248.  
  2249. $sqlCmd = 'UPDATE ' . Tff_DS_PREFIX . 'member SET ';
  2250. $sqlCmd .= 'member_last_visit = ' . $rightNow . ' ';
  2251. $sqlCmd .= 'WHERE ( member_id = ' . $this->getId() . ' );';
  2252.  
  2253. Tff_Board::getInstance()->getPLI()->query( $sqlCmd );
  2254.  
  2255. $this->setLastVisit( $rightNow );
  2256.  
  2257. }
  2258.  
  2259. /**
  2260.   * Dumps out the name and value of each property, for debugging purposes.
  2261.   */
  2262. public function debugDumpProperties()
  2263. {
  2264.  
  2265. $selfClass = new ReflectionClass( get_class( $this ) );
  2266.  
  2267. $properties = "Current " . get_class( $this ) . " properties: \n";
  2268.  
  2269. foreach ( $selfClass->getProperties() as $reflectedProperty )
  2270. {
  2271.  
  2272. if ( '_observable' == $reflectedProperty->getName() ||
  2273. '_pmManager' == $reflectedProperty->getName() )
  2274. {
  2275.  
  2276. continue;
  2277.  
  2278. }
  2279.  
  2280. $property = preg_replace( "/(^_member)|(^_)/", '', $reflectedProperty->getName() );
  2281.  
  2282. $getterMethod = 'get' . ucfirst( $property );
  2283.  
  2284. $properties .= $property . ': ';
  2285.  
  2286. /**
  2287.   * If the value is false, get the integer value so something printable will be returned!
  2288.   * @TODO Replace this dynamic method crap with Reflection?
  2289.   */
  2290. if ( false === $this->$getterMethod() )
  2291. {
  2292.  
  2293. $properties .= intval( $this->$getterMethod() );
  2294.  
  2295. }
  2296. else
  2297. {
  2298.  
  2299. $properties .= $this->$getterMethod();
  2300.  
  2301. }
  2302.  
  2303. $properties .= "\n";
  2304.  
  2305. }
  2306.  
  2307. return $properties;
  2308.  
  2309. }
  2310.  
  2311. }
  2312.  
  2313. /* EOF */

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.