From 16d4c05f6fbc4d1ab041d8f18a88f41db06a04b2 Mon Sep 17 00:00:00 2001 From: Christian Fowler Date: Fri, 13 Jan 2006 04:50:30 +0000 Subject: use avatar.jpg and portrait.jpg for respective _url's, update ::register to auto-save any preferences that were passed in off the login form. add a bit of user preference validation for homePage --- BitUser.php | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'BitUser.php') diff --git a/BitUser.php b/BitUser.php index 5f917fe..cc26145 100644 --- a/BitUser.php +++ b/BitUser.php @@ -1,6 +1,6 @@ - * @version $Revision: 1.2.2.61 $ + * @version $Revision: 1.2.2.62 $ * @package users * @subpackage BitUser */ @@ -137,8 +137,8 @@ class BitUser extends LibertyAttachable { $this->mContentId = $result->fields['content_id']; $this->mUsername = $result->fields['login']; $this->mInfo['is_registered'] = $this->isRegistered(); - $this->mInfo['avatar_url'] = (!empty($this->mInfo['avatar_storage_path']) ? BIT_ROOT_URL.$this->mInfo['avatar_storage_path'] : NULL); - $this->mInfo['portrait_url'] = (!empty($this->mInfo['portrait_storage_path']) ? BIT_ROOT_URL.$this->mInfo['portrait_storage_path']: NULL); + $this->mInfo['avatar_url'] = (!empty($this->mInfo['avatar_storage_path']) ? BIT_ROOT_URL . dirname( $this->mInfo['avatar_storage_path'] ).'/avatar.jpg' : NULL); + $this->mInfo['portrait_url'] = (!empty($this->mInfo['portrait_storage_path']) ? BIT_ROOT_URL . dirname( $this->mInfo['portrait_storage_path'] ).'/medium.jpg' : NULL); $this->mInfo['logo_url'] = (!empty($this->mInfo['logo_storage_path']) ? BIT_ROOT_URL.$this->mInfo['logo_storage_path'] : NULL); $this->mInfo['avatar_path'] = (!empty($this->mInfo['avatar_storage_path']) ? BIT_ROOT_PATH.$this->mInfo['avatar_storage_path'] : NULL); $this->mInfo['avatar_path'] = (!empty($this->mInfo['portrait_storage_path']) ? BIT_ROOT_PATH.$this->mInfo['portrait_storage_path']: NULL); @@ -174,6 +174,10 @@ class BitUser extends LibertyAttachable { function storePreference( $pPrefName, $pPrefValue ) { $ret = FALSE; if( $this->isValid() ) { + // validate any preferences + if( $pPrefName == 'homePage' && !preg_match( '/^http:\/\//', $pPrefValue ) ) { + $pPrefValue = 'http://'.$pPrefValue; + } $this->mUserPrefs[$pPrefName] = $pPrefValue; $query = "delete from `".BIT_DB_PREFIX."tiki_user_preferences` where `user_id`=? and `pref_name`=?"; $bindvars=array( $this->mUserId, $pPrefName ); @@ -400,17 +404,15 @@ class BitUser extends LibertyAttachable { } function get_SMTP_response ( &$pConnect ) { - - $Out = ""; - while (1) { - $work = fgets ( $pConnect, 1024 ); - $Out .= $work; - if (!preg_match('/^\d\d\d-/',$work)) { - break; - } - } - - return $Out; + $Out = ""; + while (1) { + $work = fgets ( $pConnect, 1024 ); + $Out .= $work; + if (!preg_match('/^\d\d\d-/',$work)) { + break; + } + } + return $Out; } @@ -512,6 +514,9 @@ if ($gDebug) echo "Run : QUIT
"; function register( &$pParamHash ) { global $notificationlib, $gBitSmarty, $gBitSystem; $ret = FALSE; + if( !empty( $_FILES['fPortraitFile'] ) && empty( $_FILES['fAvatarFile'] ) ) { + $pParamHash['fAutoAvatar'] = TRUE; + } if( $this->store( $pParamHash ) ) { require_once( KERNEL_PKG_PATH.'notification_lib.php' ); $notificationlib->post_new_user_event( $pParamHash['login'] ); @@ -525,6 +530,14 @@ if ($gDebug) echo "Run : QUIT
"; $this->storePreference( $field, $value ); } } + + // Handle optional user preferences that may be collected during registration + if( !empty( $pParamHash['prefs'] ) ) { + foreach( array_keys( $pParamHash['prefs'] ) as $key ) { + $newUser->storePreference( $key, $pParamHash['prefs'][$key] ); + } + } + $siteName = $gBitSystem->getPreference('siteTitle', $_SERVER['HTTP_HOST'] ); $gBitSmarty->assign('siteName',$_SERVER["SERVER_NAME"]); $gBitSmarty->assign('mail_site',$_SERVER["SERVER_NAME"]); -- cgit v1.3