/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /** /** * * file : $file: class_tff.member.php,v $ * copyright : (c) 2010, Dechesnes * support : http://www.theforumframework.com * */ /** * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Or visit http://www.gnu.org/copyleft/gpl.html * */ { } /** * @brief The Tff_Member class represents the attributes and behaviors of a * single member of the bulletin board. * * @author Dechesnes */ class Tff_Member implements Tff_IObserver, Tff_IStorable { /** * String - the Member's AOL Instant Messenger screen name. */ private $_memberAim = ''; /** * Integer - the Member's avatar id. */ private $_memberAvatarId = 0; /** * Integer - the Member's birthday as a UNIX timestamp. * @since v0.1.1 */ private $_memberBirthday = 0; /** * String - the Member's preferred date formatting (for the PHP date * function). */ private $_memberDateformat = ''; /** * String - the Member's email address. */ private $_memberEmail = ''; /** * Boolean - the Member's enabled flag. */ private $_memberEnabled = false; /** * Integer - the number of the Member's failed logins. */ private $_memberFailedLoginCount = 0; /** * Integer - the date of the Member's last failed login as a UNIX timestamp. */ private $_memberFailedLoginDate = 0; /** * String - the Member's home page URL. */ private $_memberHomepage = ''; /** * String - the Member's ICQ UIN number. */ private $_memberIcq = ''; /** * Integer - the Member's unique id. */ private $_memberId = 0; /** * String - the Member's interests. */ private $_memberInterests = ''; /** * String - the Member's IP address at the time of registration. */ private $_memberIp = ''; /** * Integer - the Member's join date as a UNIX timestamp. */ private $_memberJoinDate = 0; /** * String - the Member's default display language. */ private $_memberLanguage = ''; /** * Integer - the Member's last visit date as a UNIX timestamp. */ private $_memberLastVisit = 0; /** * String - the Member's geographic location. */ private $_memberLocation = ''; /** * String - the Member's login username. */ private $_memberLogin = ''; /** * String - the Member's MSN Messenger screen name. */ private $_memberMsnm = ''; /** * String - the Member's real life occupation. */ private $_memberOccupation = ''; /** * String - the Member's encrypted password. */ private $_memberPassword = ''; /** * Integer - the Member's total number of posts in the board. */ private $_memberPosts = 0; /** * Integer - the Member's rank id */ private $_memberRankId = 0; /** * String - the Member's screen name to display instead of the login. */ private $_memberScreenname = ''; /** * String - the Member's signature for posting. */ private $_memberSig = ''; /** * String - the Member's default board template. */ private $_memberTemplate = ''; /** * Integer - the Member's time zone offset from GMT (UTC). */ private $_memberTimezone = 0; /** * String - the Member's title. */ private $_memberTitle = ''; /** * String - the Member's Yahoo! Messenger screen name. */ private $_memberYim = ''; /** * Tff_ObservableImpl - the Member's observer handler */ private $_observable = null; /** * Boolean - the Member's option to allow incoming and outgoing instant * messages. */ private $_optAllowPm = false; /** * Boolean - the Member's option to always attach the signature to a Post. */ private $_optAlwaysAttachSig = false; /** * Boolean - the Member's option to receive an email when a new private * message arrives. */ private $_optEmailPm = false; /** * Boolean - the Member's option to not show up in the board's active users * list. */ private $_optInvisMode = false; /** * Boolean - the Member's option to show HTML in any board post. */ private $_optShowHtml = true; /** * Boolean - the Member's option to show the email address for public * access */ private $_optShowEmail = false; /** * Boolean - the Member's option to show emoticons in any board post. */ private $_optShowEmoticons = true; /** * Boolean - the Member's option to show the profile for public access */ private $_optShowProfile = true; /** * Boolean - the Member's option to show other Members' signatures in any * board post. */ private $_optShowSigs = true; /** * Tff_PM_Manager - the Member's private message manager. */ private $_pmManager = null; /** * String - the action to display the Member profile. */ const MEM_DISPLAY_PROFILE = 'viewprofile'; /** * String - the URL to ICQ's Web Pager API. */ const MEM_IM_URL_ICQ = 'http://wwp.icq.com/'; /** * String - the URL to Yahoo! Messenger's Web messaging API. */ const MEM_IM_URL_YIM = 'http://messenger.yahoo.com/edit/send/?.target='; /** * String - the code for the default Member sorting criteria. */ const MEM_SORT_DEFAULT = 'screenname'; /** * String - the code for sorting Members by their join date field. */ const MEM_SORT_JOIN_DATE = 'join_date'; /** * String - the code for sorting Members by their string field. */ const MEM_SORT_NAME = 'screenname'; /** * String - the code for sorting Members by their posts field. */ const MEM_SORT_POSTS = 'posts'; /** * String - the code for sorting Members by their posts field, and limiting * to the top ten positives. */ const MEM_SORT_TOP_TEN_POSTS = 'top_ten'; /** * String - the code for sorting Members by their last visit date field. */ const MEM_SORT_VISIT_DATE = 'last_visit'; /** * String - the name for the Member object cookie */ const MEMBER_COOKIE_NAME = 'member_object'; /** * Integer - the code for the default registration mode */ const REG_DEFAULT = 0; /** * Integer - the code for the save registration mode */ const REG_SAVE = 1; /** * Integer - the code for an unknown registration mode */ const REG_UNKNOWN = -1; /** * Constructor. * * @param $taintedIdIn Integer - Optional. The unique id of this object. */ public function __construct( $taintedIdIn = 0 ) { $this->setObservable( new Tff_ObservableImpl() ); $this->setPmManager( new Tff_PM_Manager() ); if ( 0 < $cleanId ) { $this->setId( $cleanId ); $this->getPmManager()->setMemberId( $this->getId() ); } } /** * Saves the current object to the persistence layer. * * @return Boolean - status of the operation. <code>true</code> is success, * <code>false</code> is failure. * @throws Tff_BBException If any operation fails */ public function add() { $allProperties = $selfClass->getProperties(); $sqlCmd = 'INSERT INTO ' . TFF_DS_PREFIX . 'member ( '; foreach ( $allProperties as $currentProperty ) { $memberProperty = $currentProperty->getName(); { continue; } // Drop the preceding _member or _ (for _opt) // Insert _ in front of all upper case characters // Drop the preceding _ { } else { } } $sqlCmd .= 'VALUES ( '; foreach ( $allProperties as $currentProperty ) { $memberProperty = $currentProperty->getName(); { continue; } // Drop the preceding _member or _ (for _opt) { continue; } { $sqlCmd .= "'" . $this->$getterMethod() . "', "; continue; } else { $sqlCmd .= $this->$getterMethod() . ', '; continue; } } /** * @TODO Check if the PLI is null? */ Tff_Board::getInstance()->getPLI()->query( $sqlCmd ); $this->setId( Tff_Board::getInstance()->getPLI()->insertId() ); Tff_Board::getInstance()->getPLI()->freeResult(); Tff_Board::getInstance()->getPLI()->close(); $this->getObservable()->notifyObservers( new Tff_Message_Memberadd( $this->getId(), $this->getDisplayName() ) ); return true; } /** * Authenticates the current Member object login and password using the * chosen Login adapter. If login is successful, the Member will be loaded * from the persistence layer. * * @throws Tff_BBException - If any operation fails. */ public function authenticate() { $loginAdapterInstance = null; $loginAdapterClassPath = Tff_ROOT . '/login'; require_once( 'class_tff.login.' . 'adapter.php' ); $loginAdapterClassName = 'Tff_Login_' . 'Adapter'; { $loginAdapterClass = new ReflectionClass( $loginAdapterClassName ); $factoryMethod = $loginAdapterClass->getMethod( 'getInstance' ); $loginAdapterInstance =& $factoryMethod->invoke( null ); $factoryMethod = null; $loginAdapterClass = null; } if ( null != $loginAdapterInstance ) { $loginAdapterInstance->login( $this->getLogin(), $this->getPassword() ); $this->loadByLogin( $this->getLogin() ); $this->updateLastVisit(); } } /** * Authenticates the current Member object login and password for admin * access using the chosen Login adapter. If login is successful, the * Member will be loaded from the persistence layer. * * @throws Tff_BBException - If any operation fails. */ public function authenticateAdmin() { $this->authenticate(); } /** * Gets the Member's AOL Instant Messenger screen name * * @return String - The <code>$_memberAim</code> property */ public function getAim() { return $this->_memberAim; } /** * Gets the Member's avatar id. * @todo add notes about avatar objects when the class is written ;-) * * @return Integer - The <code>$_memberAvatarId</code> property */ public function getAvatarId() { return $this->_memberAvatarId; } /** * Gets the Member's birthday as a UNIX timestamp * * @return Integer - The <code>$_memberBirthday</code> property */ public function getBirthday() { return $this->_memberBirthday; } /** * Gets the Member's preferred date formatting (for the PHP date function) * * @return String - The <code>$_memberDateformat</code> property */ public function getDateformat() { return $this->_memberDateformat; } /** * Gets the Member's screen name, or login if screen name is blank. For security * reasons, the Member's login should never be displayed, which is why the member * has the option to create a screen name as well. Whenever a front-end board script * needs to display the member's 'name' this method should be called. * * @return String - The Member name to display, <code>$_memberScreenname</code> or * if that is blank, then <code>$_memberLogin</code> */ public function getDisplayName() { $displayName = $this->getScreenname(); { $displayName = $this->getLogin(); } return $displayName; } /** * Gets the Member's email address * * @return String - The <code>$_memberEmail</code> property */ public function getEmail() { return $this->_memberEmail; } /** * Gets the Member's enabled flag. <code>true</code> indicates * the Member is enabled and can login, post, etc. Otherwise returns * <code>false</code> * * @return Boolean - The <code>$_memberEnabled</code> property */ public function getEnabled() { return ( boolean )( $this->_memberEnabled ); } /** * Gets the number of the Member's failed logins. * * @return Integer - The <code>$_memberFailedLoginCount</code> property */ public function getFailedLoginCount() { return $this->_memberFailedLoginCount; } /** * Gets the date of the Member's last failed login as a UNIX timestamp. * * @return Integer - The <code>$_memberFailedLoginDate</code> property */ public function getFailedLoginDate() { return $this->_memberFailedLoginDate; } /** * Gets the Member's home page URL * * @return String - The <code>$_memberHomepage</code> property */ public function getHomepage() { return $this->_memberHomepage; } /** * Gets the Member's ICQ UIN number * * @return String - The <code>$_memberIcq</code> property */ public function getIcq() { return $this->_memberIcq; } /** * Gets the Member's unique id * * @return Integer - The <code>$_memberId</code> property */ public function getId() { return $this->_memberId; } /** * Gets the Member's interests * * @return String - The <code>$_memberInterests</code> property */ public function getInterests() { return $this->_memberInterests; } /** * Gets the Member's IP address at the time of registration * * @return String - The <code>$_memberIp</code> property */ public function getIp() { return $this->_memberIp; } /** * Gets the Member's join date as a UNIX timestamp * * @return Integer - The <code>$_memberJoinDate</code> property */ public function getJoinDate() { return $this->_memberJoinDate; } /** * Gets the Member's chosen display language * * @return String - The <code>$_memberLanguage</code> property */ public function getLanguage() { return $this->_memberLanguage; } /** * Gets the Member's last visit date as a UNIX timestamp * * @return Integer - The <code>$_memberLastVisit</code> property */ public function getLastVisit() { return $this->_memberLastVisit; } /** * Gets the Member's geographic location * * @return String - The <code>$_memberLocation</code> property */ public function getLocation() { return $this->_memberLocation; } /** * Gets the Member's login username * * @return String - The <code>$_memberLogin</code> property */ public function getLogin() { return $this->_memberLogin; } /** * Gets the Member's MSN Messenger screen name * * @return String - The <code>$_memberMsnm</code> property */ public function getMsnm() { return $this->_memberMsnm; } /** * Gets the Member's observer handler. * * @return Tff_IObservable - the <code>$_observable</code> property */ public function getObservable() { return $this->_observable; } /** * Gets the Member's real life occupation * * @return String - The <code>$_memberOccupation</code> property */ public function getOccupation() { return $this->_memberOccupation; } /** * Gets the Member's option to allow incoming and outgoing instant messages. * This will be <code>true</code> or <code>false</code> * * @return Boolean - The <code>$_optAllowPm</code> property */ public function getOptAllowPm() { return ( boolean )( $this->_optAllowPm ); } /** * Gets the Member's option to always attach the signature to a Post. * This will be <code>true</code> or <code>false</code> * * @return Boolean - The <code>$_optAlwaysAttachSig</code> property */ public function getOptAlwaysAttachSig() { return ( boolean )( $this->_optAlwaysAttachSig ); } /** * Gets the Member's option to receive an email when a new private message arrives. * This will be <code>true</code> or <code>false</code> * * @return Boolean - The <code>$_optEmailPm</code> property */ public function getOptEmailPm() { return ( boolean )( $this->_optEmailPm ); } /** * Gets the Member's option to not show up in the board's active users list. * This will be <code>true</code> or <code>false</code> * * @return Boolean - The <code>$_optInvisMode</code> property */ public function getOptInvisMode() { return ( boolean )( $this->_optInvisMode ); } /** * Gets the Member's option to show BBML in any board post. * This will be <code>true</code> or <code>false</code> * * @return Boolean - The <code>$_optShowBbml</code> property */ public function getOptShowHtml() { return ( boolean )( $this->_optShowHtml ); } /** * Gets the Member's option to show the email address for public access. * This will be <code>true</code> or <code>false</code> * * @return Boolean - The <code>$_optShowEmail</code> property */ public function getOptShowEmail() { return ( boolean )( $this->_optShowEmail ); } /** * Gets the Member's option to show emoticons in any board post. * This will be <code>true</code> or <code>false</code> * * @return Boolean - The <code>$_optShowEmoticons</code> property */ public function getOptShowEmoticons() { return ( boolean )( $this->_optShowEmoticons ); } /** * Gets the Member's option to show the profile for public access. * This will be <code>true</code> or <code>false</code> * * @return Boolean - The <code>$_optShowProfile</code> property */ public function getOptShowProfile() { return ( boolean )( $this->_optShowProfile ); } /** * Gets the Member's option to show other Members' signatures in any board post. * This will be <code>true</code> or <code>false</code> * * @return Boolean - The <code>$_optShowSigs</code> property */ public function getOptShowSigs() { return ( boolean )( $this->_optShowSigs ); } /** * Gets the Member's encrypted password * * @return String - The <code>$_memberPassword</code> property */ public function getPassword() { return $this->_memberPassword; } /** * Gets the Member's percentage of total posts for the Board. * * @return Float - The Member's percentage of total posts for the Board. */ public function getPercentageOfTotalPosts() { $percentPosts = 0; /** * Temp variable to decrease line length and make it more readable... * So sue me =P */ $totalBoardPosts = Tff_Board::getInstance()->getConfigValue( 'total_posts' ); if ( 0 < $this->getPosts() ) { /** * 100 is for percentage, not a magic number */ $percentPosts = $totalBoardPosts ? } return $percentPosts; } /** * Gets the Member's private message manager. * * @return Tff_PM_Manager - the <code>$_pmManager</code> property */ public function getPmManager() { return $this->_pmManager; } /** * Gets the Member's posting rate per day for the board * * @param $adjustedTimeIn - Integer - The current timestamp, pre-adjusted * for timezone, as a UNIX timestamp. * @return Float - The Member's posting rate per day for the board */ public function getPostRatePerDay( $adjustedTimeIn ) { ( Tff_BBUtil::NUM_HOURS_IN_DAY * Tff_BBUtil::NUM_SECS_IN_HOUR ) ) ); return ( $this->getPosts() / $daysOld ); } /** * Gets the Member's total number of posts in the board * * @return Integer - The <code>$_memberPosts</code> property */ public function getPosts() { return $this->_memberPosts; } /** * Gets the Member's rank id * @todo Tie this in with the Rank class when it exists ;-) * * @return Integer - The <code>$_memberRankId</code> property */ public function getRankId() { return $this->_memberRankId; } /** * Gets the Member's screen name * * @return String - The <code>$_memberScreenname</code> property */ public function getScreenname() { return $this->_memberScreenname; } /** * Gets the Member's signature for posting * * @return String - The <code>$_memberSig</code> property */ public function getSig() { return $this->_memberSig; } /** * Gets the Member's chosen board display template. * * @return String - The <code>$_memberTemplate</code> property */ public function getTemplate() { return $this->_memberTemplate; } /** * Gets the Member's time zone offset from GMT (UTC) * * @return Integer - The <code>$_memberTimezone</code> property */ public function getTimezone() { return $this->_memberTimezone; } /** * Gets the Member's title * * @return String - The <code>$_memberTitle</code> property */ public function getTitle() { return $this->_memberTitle; } /** * Gets the Member's Yahoo! Messenger screen name * * @return String - The <code>$_memberYim</code> property */ public function getYim() { return $this->_memberYim; } /** * Updates the current object based on the message received. * * @param $msgIn - Tff_IMessage - the message to handle * @throws Tff_BBException If any operation fails */ public function handleMessage( Tff_IMessage $msgIn ) { switch ( $msgIn->getMsgType() ) { case Tff_Message_Replyadd::MSG_TYPE: $sqlCmd = 'UPDATE ' . TFF_DS_PREFIX . 'member SET '; $sqlCmd .= 'member_posts = member_posts + 1, '; $sqlCmd .= 'member_last_visit = ' . $msgIn->getTimeStamp() . ' '; $sqlCmd .= 'WHERE ( member_id = ' . $msgIn->getAuthorId() . ' );'; Tff_Board::getInstance()->getPLI()->query( $sqlCmd ); break; case Tff_Message_Threadadd::MSG_TYPE: $sqlCmd = 'UPDATE ' . TFF_DS_PREFIX . 'member SET '; $sqlCmd .= 'member_posts = member_posts + 1, '; $sqlCmd .= 'member_last_visit = ' . $msgIn->getTimeStamp() . ' '; $sqlCmd .= 'WHERE ( member_id = ' . $msgIn->getAuthorId() . ' );'; Tff_Board::getInstance()->getPLI()->query( $sqlCmd ); break; } } /** * Retrieves an object from the persistence layer based on the given object * id and loads it into memory. * The parameter must greater than zero. * * @param $taintedId Integer - The unique id of the object to load. * @return Boolean - status of the operation. <code>true</code> is success, * <code>false</code> is failure. * @throws Tff_BBException If any operation fails */ public function load( $taintedId ) { $sqlCmd = 'SELECT * '; $sqlCmd .= 'FROM ' . TFF_DS_PREFIX . 'member '; $sqlCmd .= 'WHERE ( member_id = ' . $cleanId . ' );'; { throw new Tff_BBException( LANG_TFF_MEM_ERROR_NO_MEM . $cleanId ); } $retrievedObject = Tff_Board::getInstance()->getPLI()->queryFirst( $sqlCmd ); if ( null == $retrievedObject || !( $retrievedObject ) ) { Tff_Board::getInstance()->getPLI()->close(); throw new Tff_BBException( LANG_TFF_MEM_ERROR_NO_MEM . $cleanId ); } Tff_Board::getInstance()->getPLI()->freeResult(); Tff_Board::getInstance()->getPLI()->close(); { // Drop the preceding member_ // Replace underscores with blank spaces and upper case the first letter of each 'word' // Strip out the spaces $setterMethod = 'set' . $parsedMemberProperty; $this->$setterMethod( $retrievedObject->$memberProperty ); } $this->getPmManager()->setMemberId( $this->getId() ); $retrivedObject = null; return true; } /** * Retrieves an object from the persistence layer based on the given object * id and loads it into memory. * The parameter must greater than zero. * * @param $taintedLogin String - The login of the Member to load. * @return Boolean - status of the operation. <code>true</code> is success, * <code>false</code> is failure. * @throws Tff_BBException If any operation fails */ public function loadByLogin( $taintedLogin ) { /** * @TODO CLEANSE THIS!!! */ $sqlCmd = 'SELECT * '; $sqlCmd .= 'FROM ' . TFF_DS_PREFIX . 'member '; $sqlCmd .= "WHERE ( member_login = '" . $cleanLogin . "' );"; $retrievedObject = Tff_Board::getInstance()->getPLI()->queryFirst( $sqlCmd ); if ( null == $retrievedObject || !( $retrievedObject ) ) { Tff_Board::getInstance()->getPLI()->close(); throw new Tff_BBException( LANG_TFF_MEM_ERROR_NO_MEM . $cleanLogin ); } Tff_Board::getInstance()->getPLI()->freeResult(); Tff_Board::getInstance()->getPLI()->close(); { // Drop the preceding member_ // Replace underscores with blank spaces and upper case the first letter of each 'word' // Strip out the spaces $setterMethod = 'set' . $parsedMemberProperty; $this->$setterMethod( $retrievedObject->$memberProperty ); } $this->getPmManager()->setMemberId( $this->getId() ); $retrivedObject = null; return true; } /** * Permanently removes the object from the persistence layer based on its * id. * * @return Boolean - status of the operation. <code>true</code> is success, * <code>false</code> is failure. * @throws Tff_BBException If any operation fails */ public function remove() { /** * @TODO decide if it's worth it to properly clean up all the member * posts, etc. or just orphan everything */ return true; } /** * Sets the Member's AOL Instant Messenger screen name * * @param $taintedValue String - the AOL Instant Messenger screen name */ public function setAim( $taintedValue ) { } /** * Sets the Member's avatar id. * This must not be null, must be numeric and greater than zero * * @param $taintedValue Integer - the avatar id * @throws Tff_BBException If value is invalid */ public function setAvatarId( $taintedValue ) { { throw new Tff_BBException( LANG_TFF_MEM_BAD_AVATAR_ID . $taintedValue ); } } /** * Sets the Member's birthday as a UNIX timestamp. * This must not be null, must be numeric and greater than zero * * @param $taintedValue Integer - the birthday timestamp * @throws Tff_BBException If value is invalid */ public function setBirthday( $taintedValue ) { { throw new Tff_BBException( LANG_TFF_MEM_BAD_BIRTHDAY . $taintedValue ); } } /** * Sets the Member's preferred date formatting (for the PHP date function). * This must not be null and must be a non-empty string * * @param $taintedValue String - the date format * @throws Tff_BBException If value is invalid */ public function setDateformat( $taintedValue ) { { throw new Tff_BBException( LANG_TFF_MEM_BAD_DATE_FORMAT . $taintedValue ); } $this->_memberDateformat = $taintedValue; } /** * Sets the Member's email address. * This must not be null and must be a non-empty string * * @param $taintedValue String - the email address * @throws Tff_BBException If value is invalid */ public function setEmail( $taintedValue ) { { throw new Tff_BBException( LANG_TFF_MEM_BAD_EMAIL . $taintedValue ); } $this->_memberEmail = $taintedValue; } /** * Sets the Member's enabled flag. <code>true</code> indicates * the Member is enabled and can login, post, etc. Otherwise returns * <code>false</code>. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the enabled flag * @throws Tff_BBException If value is invalid */ public function setEnabled( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new Tff_BBException( LANG_TFF_MEM_BAD_ENABLED_OPT . $taintedValue ); } $this->_memberEnabled = ( boolean )( $taintedValue ); } /** * Sets the number of the Member's failed logins. * This must not be null, must be numeric and greater than zero * * @param $taintedValue Integer - the number of failed logins * @throws BuBOL_BBException If value is invalid * @since v0.1.2 */ public function setFailedLoginCount( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_FAILED_LOGIN_COUNT . $taintedValue ); } } /** * Sets the date of the Member's last failed login as a UNIX timestamp. * This must not be null, must be numeric and greater than zero * * @param $taintedValue Integer - the last failed login date * @throws BuBOL_BBException If value is invalid * @since v0.1.2 */ public function setFailedLoginDate( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_FAILED_LOGIN_DATE . $taintedValue ); } } /** * Sets the Member's home page URL * * @param $taintedValue String - the home page URL */ public function setHomepage( $taintedValue ) { { { $taintedValue = "http://$taintedValue"; } } } /** * Sets the Member's ICQ UIN number * * @param $taintedValue String - the ICQ UIN number */ public function setIcq( $taintedValue ) { } /** * Sets the Member's unique id. * This must not be null, must be numeric and greater than zero * * @param $taintedValue Integer - the unique id * @throws BuBOL_BBException If value is invalid */ public function setId( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_ID . $taintedValue ); } } /** * Sets the Member's IP address at the time of registration * * @param $taintedValue String - the IP address */ public function setIp( $taintedValue ) { } /** * Sets the Member's interests * * @param $taintedValue String - the interests */ public function setInterests( $taintedValue ) { } /** * Sets the Member's join date as a UNIX timestamp. * This must not be null, must be numeric and greater than zero * * @param $taintedValue Integer - the join date * @throws BuBOL_BBException If value is invalid */ public function setJoinDate( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_JOIN_DATE . $taintedValue ); } } /** * Sets the Member's chosen language. * * @param $taintedValue String - the language * @since v0.1.2 */ public function setLanguage( $taintedValue ) { } /** * Sets the Member's last visit date as a UNIX timestamp. * This must not be null, must be numeric and greater than zero * * @param $taintedValue Integer - the last visit date * @throws BuBOL_BBException If value is invalid */ public function setLastVisit( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_LAST_VISIT . $taintedValue ); } } /** * Sets the Member's geographic location * * @param $taintedValue String - the location */ public function setLocation( $taintedValue ) { } /** * Sets the Member's login username. * This must not be null and must be a non-empty string * * @param $taintedValue String - the login * @throws BuBOL_BBException If value is invalid */ public function setLogin( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_LOGIN . $taintedValue ); } $this->_memberLogin = $taintedValue; } /** * Sets the Member's MSN Messenger screen name * * @param $taintedValue String - the MSN Messenger screen name */ public function setMsnm( $taintedValue ) { } /** * Sets the Member's observer handle. * * @param $observableIn BuBOL_IObservable - the observer handle */ public function setObservable( $observableIn ) { $this->_observable = $observableIn; } /** * Sets the Member's real life occupation * * @param $taintedValue String - the real life occupation */ public function setOccupation( $taintedValue ) { } /** * Sets the Member's option to allow incoming and outgoing instant messages. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the allow pm option * @throws BuBOL_BBException If value is invalid */ public function setOptAllowPm( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_ALLOW_PM_OPT . $taintedValue ); } $this->_optAllowPm = ( boolean )( $taintedValue ); } /** * Sets the Member's option to always attach the signature to a Post. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the always attach signatures option * @throws BuBOL_BBException If value is invalid * @since v0.1.3 */ public function setOptAlwaysAttachSig( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_ALWAYS_ATT_SIG_OPT . $taintedValue ); } $this->_optAlwaysAttachSig = ( boolean )( $taintedValue ); } /** * Sets the Member's option to receive an email when a new private message arrives. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the email on new pm option * @throws BuBOL_BBException If value is invalid */ public function setOptEmailPm( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_EMAIL_ON_PM_OPT . $taintedValue ); } $this->_optEmailPm = ( boolean )( $taintedValue ); } /** * Sets the Member's option to not show up in the board's active users list. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the invisible mode option * @throws BuBOL_BBException If value is invalid */ public function setOptInvisMode( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_INVIS_MODE_OPT . $taintedValue ); } $this->_optInvisMode = ( boolean )( $taintedValue ); } /** * Sets the Member's option to show BBML in any board post. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the show BBML option * @throws BuBOL_BBException If value is invalid */ public function setOptShowBbml( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_BBML_OPT . $taintedValue ); } $this->_optShowBbml = ( boolean )( $taintedValue ); } /** * Sets the Member's option to show the email address for public access. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the show email option * @throws BuBOL_BBException If value is invalid */ public function setOptShowEmail( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_EMAIL_OPT . $taintedValue ); } $this->_optShowEmail = ( boolean )( $taintedValue ); } /** * Sets the Member's option to show emoticons in any board post. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the show emoticons option * @throws BuBOL_BBException If value is invalid */ public function setOptShowEmoticons( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_EMOT_OPT . $taintedValue ); } $this->_optShowEmoticons = ( boolean )( $taintedValue ); } /** * Sets the Member's option to show the profile for public access. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the show profile option * @throws BuBOL_BBException If value is invalid * @since v0.1.3 */ public function setOptShowProfile( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_PROFILE_OPT . $taintedValue ); } $this->_optShowProfile = ( boolean )( $taintedValue ); } /** * Sets the Member's option to show other Members' signatures in any board post. * This must not be null, and must be numeric or must be a boolean value * * @param $taintedValue Boolean - the show sigs option * @throws BuBOL_BBException If value is invalid */ public function setOptShowSigs( $taintedValue ) { if ( is_null( $taintedValue ) || ( !( is_numeric( $taintedValue ) ) && !( is_bool( $taintedValue ) ) ) ) { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_SHOW_SIGS_OPT . $taintedValue ); } $this->_optShowSigs = ( boolean )( $taintedValue ); } /** * Sets the Member's encrypted password * This must not be null and must be a non-empty string * * @param $taintedValue String - the encrypted password * @throws BuBOL_BBException If value is invalid */ public function setPassword( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_PASSWORD . $taintedValue ); } $this->_memberPassword = $taintedValue; } /** * Sets the Member's private message manager. * * @param $pmManagerIn BuBOL_PM_Manager - the private message manager. * @since v0.1.3 */ public function setPmManager( $pmManagerIn ) { $this->_pmManager = $pmManagerIn; } /** * Sets the Member's total number of posts in the board. * This must not be null, must be numeric and greater than zero * * @param $taintedValue Integer - the number of member posts * @throws BuBOL_BBException If value is invalid */ public function setPosts( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_POSTS . $taintedValue ); } } /** * Sets the Member's rank id. * This must not be null, must be numeric and greater than zero * * @param $taintedValue Integer - the rank id * @throws BuBOL_BBException If value is invalid */ public function setRankId( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_RANK_ID . $taintedValue ); } } /** * Sets the Member's screen name to display instead of the login * * @param $taintedValue String - the screen name */ public function setScreenname( $taintedValue ) { } /** * Sets the Member's signature for posting * * @param $taintedValue String - the signature */ public function setSig( $taintedValue ) { } /** * Sets the Member's chosen board display template. * * @param $taintedValue String - the display template name * @since v0.1.2 */ public function setTemplate( $taintedValue ) { } /** * Sets the Member's time zone offset from GMT (UTC). * This must not be null and must be numeric. * * @param $taintedValue Integer - the timezone offset from GMT * @throws Tff_BBException If value is invalid */ public function setTimezone( $taintedValue ) { { throw new BuBOL_BBException( LANG_TFF_MEM_BAD_TIMEZONE . $taintedValue ); } } /** * Sets the Member's title * * @param $taintedValue String - the title */ public function setTitle( $taintedValue ) { } /** * Sets the Member's Yahoo! Messenger screen name * * @param $taintedValue String - the Yahoo! Messenger screen name */ public function setYim( $taintedValue ) { } /** * Logs the Member in by setting _SESSION and optionally, _COOKIE * variables. * * @param $setCookies Boolean - true or false for whether or not to use * cookies. * @param $salt String - A string used to further secure the cookie * data * @return Boolean - Always true unless $setCookies is true, then it will * return the status of setting the cookie. */ public function signIn( $setCookies, $salt ) { /** * @TODO This should throw an Exception, not boolean return values >=/ */ $cookieSuccess = true; $_SESSION[ 'member_auth' ] = true; if ( $setCookies ) { $cookieExpiry = Tff_BBUtil::getGmtTimestamp(); $cookieExpiry += ( $this->getTimezone() * Tff_BBUtil::NUM_SECS_IN_HOUR ); $cookieExpiry += ( Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_expire' ) * Tff_BBUtil::NUM_HOURS_IN_DAY * Tff_BBUtil::NUM_SECS_IN_HOUR ); /** * Extra security here. Found this on a php.net user comment * at: http://www.php.net/manual/en/function.setcookie.php * * 1. Serialize and encode the Member object */ /** * 2. Generate a checksum of the serialized Member object * and salt the checksum with the board token constant */ $checkSum = Tff_BBUtil::generateDataChecksum( $cookieData, $salt ); /** * 3. Wrap up the data and the checksum */ self::MEMBER_COOKIE_NAME, $strongCookieData, $cookieExpiry, Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_path' ), Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_domain' ) ); } return $cookieSuccess; } /** * Logs the Member out by destroying _SESSION and _COOKIE variables. * * @return Boolean - Always true unless cookies are detected, then it will * return the status of setting the cookie. */ public static function signOut() { /** * Normally I'd want to default to false, but in this case we don't know * if cookies are even being used. * @TODO This should throw an Exception, not boolean return values >=/ */ $cookieSuccess = true; /** * Set expiration to 24 hours ago, GMT */ $cookieExpiry = Tff_BBUtil::getGmtTimestamp() - ( Tff_BBUtil::NUM_HOURS_IN_DAY * Tff_BBUtil::NUM_SECS_IN_HOUR ); { '', $cookieExpiry, '/' ); } { /** * Attempt to destroy cookie */ self::MEMBER_COOKIE_NAME, '', $cookieExpiry, Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_path' ), Tff_Board::getInstance()->getConfigValue( 'visitor_cookie_domain' ) ); } return $cookieSuccess; } /** * Updates the current object in the persistence layer. * * @return Boolean - status of the operation. <code>true</code> is success, * <code>false</code> is failure. * @throws Tff_BBException If any operation fails */ public function update() { $allProperties = $selfClass->getProperties(); $sqlCmd = 'UPDATE ' . TFF_DS_PREFIX . 'member SET '; foreach ( $allProperties as $currentProperty ) { $memberProperty = $currentProperty->getName(); /** * The member_ip field should never be updated * as it is stored only on member sign-up to be used * as a counter-measure against member sign up flood attacks * if you feel it must be updated... just comment-out the line below */ { continue; } // Drop the preceding _member or _ (for _opt) // Insert _ in front of all upper case characters // Drop the preceding _ { } else { } { continue; } { $sqlCmd .= "'" . $this->$getterMethod() . "', "; continue; } else { $sqlCmd .= $this->$getterMethod() . ', '; continue; } } $sqlCmd .= ' WHERE ( member_id = ' . $this->getId() . ' );'; /** * @TODO Check if the PLI is null? */ Tff_Board::getInstance()->getPLI()->query( $sqlCmd ); Tff_Board::getInstance()->getPLI()->freeResult(); Tff_Board::getInstance()->getPLI()->close(); /** * @TODO A little notifyObserver action here? =D * Does anything really care if a Member updates itself? * Logging maybe? */ return true; } /** * Incremends the current Thread's view count in memory and in the * persistence layer by the given number of views, default increment by 1. * * @throws Tff_BBException If persistence layer operation fails. */ public function updateLastVisit() { $rightNow = Tff_BBUtil::getGmtTimestamp(); $sqlCmd = 'UPDATE ' . Tff_DS_PREFIX . 'member SET '; $sqlCmd .= 'member_last_visit = ' . $rightNow . ' '; $sqlCmd .= 'WHERE ( member_id = ' . $this->getId() . ' );'; Tff_Board::getInstance()->getPLI()->query( $sqlCmd ); $this->setLastVisit( $rightNow ); } /** * Dumps out the name and value of each property, for debugging purposes. */ public function debugDumpProperties() { foreach ( $selfClass->getProperties() as $reflectedProperty ) { if ( '_observable' == $reflectedProperty->getName() || '_pmManager' == $reflectedProperty->getName() ) { continue; } $properties .= $property . ': '; /** * If the value is false, get the integer value so something printable will be returned! * @TODO Replace this dynamic method crap with Reflection? */ if ( false === $this->$getterMethod() ) { } else { $properties .= $this->$getterMethod(); } $properties .= "\n"; } return $properties; } } /* EOF */