diff options
| author | Christian Fowler <spider@viovio.com> | 2006-01-13 04:50:30 +0000 |
|---|---|---|
| committer | Christian Fowler <spider@viovio.com> | 2006-01-13 04:50:30 +0000 |
| commit | 16d4c05f6fbc4d1ab041d8f18a88f41db06a04b2 (patch) | |
| tree | ac636a5287c8277c4d16ee58a35ade3acc4cb473 | |
| parent | 8f91fe81288ed278bc9ba9b4cd1a53a0dfdf9da2 (diff) | |
| download | users-16d4c05f6fbc4d1ab041d8f18a88f41db06a04b2.tar.gz users-16d4c05f6fbc4d1ab041d8f18a88f41db06a04b2.tar.bz2 users-16d4c05f6fbc4d1ab041d8f18a88f41db06a04b2.zip | |
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
| -rw-r--r-- | BitUser.php | 45 | ||||
| -rw-r--r-- | preferences.php | 6 | ||||
| -rw-r--r-- | templates/user_preferences.tpl | 4 |
3 files changed, 34 insertions, 21 deletions
diff --git a/BitUser.php b/BitUser.php index 5f917fe..cc26145 100644 --- a/BitUser.php +++ b/BitUser.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_users/BitUser.php,v 1.2.2.61 2006/01/12 21:19:13 lsces Exp $ + * $Header: /cvsroot/bitweaver/_bit_users/BitUser.php,v 1.2.2.62 2006/01/13 04:50:29 spiderr Exp $ * * Lib for user administration, groups and permissions * This lib uses pear so the constructor requieres @@ -12,7 +12,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: BitUser.php,v 1.2.2.61 2006/01/12 21:19:13 lsces Exp $ + * $Id: BitUser.php,v 1.2.2.62 2006/01/13 04:50:29 spiderr Exp $ * @package users */ @@ -41,7 +41,7 @@ define("ACCOUNT_DISABLED", -6); * Class that holds all information for a given user * * @author spider <spider@steelsun.com> - * @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<br>"; 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<br>"; $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"]); diff --git a/preferences.php b/preferences.php index ea96990..d93f3b7 100644 --- a/preferences.php +++ b/preferences.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_users/preferences.php,v 1.2.2.8 2006/01/03 10:05:43 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_users/preferences.php,v 1.2.2.9 2006/01/13 04:50:30 spiderr Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: preferences.php,v 1.2.2.8 2006/01/03 10:05:43 squareing Exp $ + * $Id: preferences.php,v 1.2.2.9 2006/01/13 04:50:30 spiderr Exp $ * @package users * @subpackage functions */ @@ -190,11 +190,11 @@ while ($file = readdir($h)) { } closedir ($h); sort ($flags); +$gBitSmarty->assign('flags', $flags); $editUser->mInfo['userbreadCrumb'] = $editUser->getPreference( 'userbreadCrumb', $gBitSystem->getPreference('userbreadCrumb', 4) ); $editUser->mInfo['homePage'] = $editUser->getPreference( 'homePage', ''); -$gBitSmarty->assign('flags', $flags); $gBitSmarty->assign( 'editUser', $editUser->mInfo ); // Get preferences diff --git a/templates/user_preferences.tpl b/templates/user_preferences.tpl index 5b7ca57..7e5d927 100644 --- a/templates/user_preferences.tpl +++ b/templates/user_preferences.tpl @@ -62,8 +62,8 @@ <select name="country" id="country"> <option value="" /> {sortlinks} - {section name=ix loop=$flags} - <option value="{$flags[ix]|escape}" {if $userPrefs.flag eq $flags[ix]}selected="selected"{/if}>{tr}{$flags[ix]}{/tr}</option> + {section name=ix loop=$flags} + <option value="{$flags[ix]|escape}" {if $userPrefs.flag eq $flags[ix]}selected="selected"{/if}>{tr}{$flags[ix]|replace:'_':' '}{/tr}</option> {/section} {/sortlinks} </select> |
