/[drupal]/contributions/modules/unique_avatar/unique_avatar.module
ViewVC logotype

Contents of /contributions/modules/unique_avatar/unique_avatar.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Tue Jan 29 18:54:38 2008 UTC (21 months, 3 weeks ago) by jscheel
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5, DRUPAL-6--1
Changes since 1.1: +9 -3 lines
File MIME type: text/x-php
added doc block
1 <?php
2 // $Id: unique_avatar.module,v 1.1 2008/01/29 18:08:51 jscheel Exp $
3
4 /**
5 * @file unique_avatar.module
6 *
7 * Full module implementation, creates unique user picture filenames
8 */
9
10 /**
11 * Implementation of hook_user()
12 */
13 function unique_avatar_user($type, &$edit, &$user, $category = NULL) {
14 if ($type == 'submit' && $category == 'account') {
15
16 //Is the user picture being modified?
17 $file = file_check_upload('picture_upload');
18 if ($file) {
19 $info = image_get_info($file->filepath);
20
21 //Rename picture with unique id
22 $dest = variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid . '-' . md5(time()) . '.' . $info['extension'];
23 if (file_move($file->filepath, $dest)) {
24
25 //Clean up existing picture
26 if (module_exists('imagecache')) {
27 imagecache_image_flush($user->picture);
28 }
29 file_delete($user->picture);
30
31 //Assign new picture
32 $edit['picture'] = file_directory_path() . '/' . $dest;
33 $user->picture = file_directory_path() . '/' . $dest;
34 }
35 }
36 }
37 }

  ViewVC Help
Powered by ViewVC 1.1.2