Changeset 473
- Timestamp:
- 07/16/07 12:22:59 (1 year ago)
- Files:
-
- avatar-upload/trunk/avatar-upload.php (modified) (3 diffs)
- avatar-upload/trunk/my-plugins/_identicon.php (added)
- avatar-upload/trunk/my-plugins/bb-avatar-upload.php (modified) (5 diffs)
- avatar-upload/trunk/my-templates/avatar.php (modified) (2 diffs)
- avatar-upload/trunk/readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
avatar-upload/trunk/avatar-upload.php
r462 r473 3 3 Plugin Name: Avatar Upload 4 4 Plugin URI: http://bbpress.org/plugins/topic/46 5 Version: 0. 55 Version: 0.6 6 6 Description: Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. 7 7 Author: Louise Dade … … 113 113 } 114 114 115 // Add avatar to database as usermeta data .116 $meta_avatar = $user_filename . " |" . $img_w . "|" . $img_h . "|avatar-upload";115 // Add avatar to database as usermeta data (append unix time to help browser caching probs). 116 $meta_avatar = $user_filename . "?" . time() . "|" . $img_w . "|" . $img_h . "|avatar-upload"; 117 117 bb_update_usermeta( $user_id, 'avatar_file', $meta_avatar ); 118 118 $success_message = "Your avatar has been uploaded."; … … 161 161 } 162 162 } 163 } 164 165 // Has user checked the "Use Identicon" option? 166 if( $_POST['identicon'] ) 167 { 168 felapplyidenticon( $user_id ); // create an identicon 163 169 } 164 170 avatar-upload/trunk/my-plugins/bb-avatar-upload.php
r462 r473 3 3 Plugin Name: Avatar Upload 4 4 Plugin URI: http://bbpress.org/plugins/topic/46 5 Version: 0. 55 Version: 0.6 6 6 Description: Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. 7 7 Author: Louise Dade … … 23 23 $this->max_bytes = 1048576; // filesize (1024 bytes = 1 KB / 1048576 bytes = MB) 24 24 25 // Default avatar - set 'use_default' to '0' to display no imageinstead of default25 // Default avatar - set 'use_default' to '0' to display Identicon instead of default 26 26 // The default URI is in the '$this->avatar_dir' folder. 27 27 $this->default_avatar = array( 28 'use_default' => 1,28 'use_default' => 0, 29 29 'uri' => bb_get_option('uri') . $this->avatar_dir . 'default.png', 30 30 'width' => 80, … … 43 43 44 44 // Display the avatar image 45 function avatarupload_display($id , $status='')45 function avatarupload_display($id) 46 46 { 47 47 if ($a = avatarupload_get_avatar($id)) 48 48 { 49 echo '<img src="'.$a[0]; 50 echo ($status == 'new') ? '?'.time() : ''; 51 echo'" width="'.$a[1].'" height="'.$a[2].'" alt="'.$a[4].'" />'; 49 echo '<img src="'.$a[0].'" width="'.$a[1].'" height="'.$a[2].'" alt="'.$a[4].'" />'; 52 50 } else { 53 51 $config = new avatarupload_config(); … … 55 53 if ($config->default_avatar['use_default'] == 1) 56 54 { 55 // Use a "genric" default avatar 57 56 echo '<img src="'.$config->default_avatar['uri'].'" width="'.$config->default_avatar['width'] 58 57 .'" height="'.$config->default_avatar['height'].'" alt="'.$config->default_avatar['alt'].'" />'; 58 } else { 59 // Or use Identicons instead. New users will have an identicon automatically 60 // created when they join, but this is for existing users with no avatar. 61 62 felapplyidenticon($id); // create identicon 63 64 // now fetch it from the database 65 if ($a = avatarupload_get_avatar($id)) 66 { 67 echo '<img src="'.$a[0].'" width="'.$a[1].'" height="'.$a[2].'" alt="'.$a[4].'" />'; 68 } 59 69 } 60 70 } … … 110 120 add_action( 'bb_profile_menu', 'add_avatar_tab' ); 111 121 122 123 // bbPress Identicon function by Fel64 124 function felapplyidenticon( $felID ) 125 { 126 $config = new avatarupload_config(); 127 $user = bb_get_user( $felID ); 128 129 $ifilename = strtolower($user->user_login) . "." . 'png'; 130 $ifilepath = BBPATH . $config->avatar_dir . $ifilename; 131 132 if (class_exists("identicon")) { $identicon = new identicon; } 133 134 if( $identicon ) 135 { 136 $felidenticon = $identicon->identicon_build( $user->user_login, '', false, '', false ); 137 138 if( imagepng( $felidenticon, $ifilepath ) ) 139 { 140 $ioptions = identicon_get_options(); 141 $meta_avatar = $ifilename."?".time().'|'.$ioptions['size'].'|'.$ioptions['size'].'|identicon'; 142 bb_update_usermeta( $felID, 'avatar_file', $meta_avatar ); 143 $success_message = "Your identicon has been made."; 144 } 145 } 146 } 147 148 // Is user using an Identicon? 149 function usingidenticon($id) 150 { 151 if ($a = avatarupload_get_avatar($id, 0, 1)) 152 { 153 return ($a[3] == "identicon") ? true : false; 154 } else { 155 return false; 156 } 157 } 158 112 159 ?> avatar-upload/trunk/my-templates/avatar.php
r462 r473 7 7 <?php 8 8 echo (!empty($error_message)) ? '<div class="infobox"><strong>'.__("OOPS! ".$error_message).'</strong></div>' : ""; 9 10 if (!empty($success_message)) { 11 echo '<div class="notice">'.__($success_message).'<br /><br />If your avatar does not appear to ' 12 . 'have changed on the forums, it is because your browser has cached (stored a copy of) your old ' 13 . 'avatar - refreshing the page a few times should download the new image.</div>'; 14 } 9 echo (!empty($success_message)) ? '<div class="notice">'.__($success_message).'</div>' : ""; 15 10 ?> 16 11 … … 33 28 34 29 <h3><?php _e('Current Avatar'); ?></h3> 35 <p><?php echo avatarupload_display($user->ID, 'new'); ?></p> 30 <p><?php echo avatarupload_display($user->ID); ?></p> 31 32 <?php if (!usingidenticon($user->ID)) { ?> 33 <form method="POST" action="<?php profile_tab_link($user->ID, 'avatar'); ?>"> 34 <p><label for"useidenticon"><input type="checkbox" name="identicon" value="1" id="useidenticon" /> <?php _e('Use your Identicon instead?'); ?></label></p> 35 <p><input type="submit" name="submit" id="submit" value="Use Identicon" /></p> 36 </form> 37 <?php 38 } else { 39 _e('<p>You are currently using your Identicon.</p>'); 40 } // end if not using identicon 41 42 if ($config->default_avatar['use_default'] == 0) { 43 _e("<p>The forum Admin has selected Identicons for user's default avatar. You can change it by uploading your own avatar image (you can always revert back to your Identicon if you wish).</p>"); 44 } 45 ?> 36 46 37 47 <?php } ?> avatar-upload/trunk/readme.txt
r462 r473 2 2 Tags: avatars, avatar, uploads, profile 3 3 Contributors: LouiseDade 4 Requires at least: 0.8 4 Requires at least: 0.8.2 5 5 Tested up to: 0.8.2.1 6 Stable Tag: 0. 56 Stable Tag: 0.6 7 7 8 Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. Admins can configure maximum allowed file size and image dimensions. 8 Allows users to upload an avatar (gif, jpeg/jpg or png) image to bbPress. Admins can configure maximum allowed file size and image dimensions. Includes fel64's code enabling 'Identicons' - default avatars made of abstract patterns unique to each user. 9 9 10 10 == Description == … … 34 34 * Option to display a default avatar for users who do not upload their own. 35 35 36 * Can be extended with fel64's "Identicons" plugin to give users the option of displaying an identicon instead of uploading an image (becomes their 'default' avatar). Identicons are currently a branch of this plugin. http://bbpress.org/forums/topic/1027?replies=25#post-6759 36 * fel64's "Identicons" plugin gives users the option of displaying an identicon instead of uploading an image (becomes their 'default' avatar). http://bbpress.org/forums/topic/1027?replies=25#post-6759 37 38 Credit to fel64 for providing the bbPress interface for Identicons and Scott Sherrill-Mix for writing the Identicon code at http://scott.sherrillmix.com/blog/blogger/wp_identicon/ 37 39 38 40 == Installation == … … 41 43 42 44 1. Open up the `my-plugins/bb-avatar-upload.php` file and configure the "Configuration Settings". At least make sure the `$avatar_dir` variable is correct. 45 46 IMPORTANT: to use Identicons, you must leave the 'use_default' (avatar) option as '0' so that 47 the user's automatically created identicon is displayed and not the generic default image. 48 Obviously, to go back to using a generic default set the option to '1' again. 43 49 44 50 2. The avatar upload page should appear as a tab ("Avatar") on the user's Profile menu. If you'd prefer the link to be elsewhere, insert the following "Upload Avatar" link wherever you wish: … … 80 86 `my-plugins/bb-avatar-upload.php` - your `my-plugins/` dir (and activated). 81 87 88 `my-plugins/_identicon.php` - your `my-plugins/` dir (it is automatically activated). 89 82 90 That's it, the 'Avatar Upload' plugin should now be working. 83 91 … … 100 108 == Change Log == 101 109 110 2007-07-16 Ver. 0.6 Integrated Identicons into the core plugin. Added Unix timestamp to filename 111 in DB (updated when user updates avatar) to combat browser caching problems. 112 102 113 2007-07-15 Ver. 0.5 added image resizing function, better mime-type checking and a couple of 103 114 performance improvements.
