@@ 37-58 (lines=22) @@ | ||
34 | // get the images and save their file handlers into an array |
|
35 | // so we can do clean up if one fails. |
|
36 | $files = array(); |
|
37 | foreach ($icon_sizes as $name => $size_info) { |
|
38 | $resized = get_resized_image_from_existing_file($filename, $size_info['w'], $size_info['h'], $size_info['square'], $x1, $y1, $x2, $y2, $size_info['upscale']); |
|
39 | ||
40 | if ($resized) { |
|
41 | //@todo Make these actual entities. See exts #348. |
|
42 | $file = new ElggFile(); |
|
43 | $file->owner_guid = $guid; |
|
44 | $file->setFilename("profile/{$guid}{$name}.jpg"); |
|
45 | $file->open('write'); |
|
46 | $file->write($resized); |
|
47 | $file->close(); |
|
48 | $files[] = $file; |
|
49 | } else { |
|
50 | // cleanup on fail |
|
51 | foreach ($files as $file) { |
|
52 | $file->delete(); |
|
53 | } |
|
54 | ||
55 | register_error(elgg_echo('avatar:resize:fail')); |
|
56 | forward(REFERER); |
|
57 | } |
|
58 | } |
|
59 | ||
60 | $owner->icontime = time(); |
|
61 |
@@ 57-78 (lines=22) @@ | ||
54 | // get the images and save their file handlers into an array |
|
55 | // so we can do clean up if one fails. |
|
56 | $files = array(); |
|
57 | foreach ($icon_sizes as $name => $size_info) { |
|
58 | $resized = get_resized_image_from_existing_file($filename, $size_info['w'], $size_info['h'], $size_info['square'], $x1, $y1, $x2, $y2, $size_info['upscale']); |
|
59 | ||
60 | if ($resized) { |
|
61 | //@todo Make these actual entities. See exts #348. |
|
62 | $file = new ElggFile(); |
|
63 | $file->owner_guid = $guid; |
|
64 | $file->setFilename("profile/{$guid}{$name}.jpg"); |
|
65 | $file->open('write'); |
|
66 | $file->write($resized); |
|
67 | $file->close(); |
|
68 | $files[] = $file; |
|
69 | } else { |
|
70 | // cleanup on fail |
|
71 | foreach ($files as $file) { |
|
72 | $file->delete(); |
|
73 | } |
|
74 | ||
75 | register_error(elgg_echo('avatar:resize:fail')); |
|
76 | forward(REFERER); |
|
77 | } |
|
78 | } |
|
79 | ||
80 | $owner->icontime = time(); |
|
81 |
@@ 84-106 (lines=23) @@ | ||
81 | // so we can do clean up if one fails. |
|
82 | $files = array(); |
|
83 | $image = file_get_contents($tag_values); |
|
84 | foreach ($icon_sizes as $name => $size_info) { |
|
85 | $resized = resizeImage($image, $size_info['w'], $size_info['h'], $size_info['square'], $size_info['upscale']); |
|
86 | ||
87 | if ($resized) { |
|
88 | //@todo Make these actual entities. See exts #348. |
|
89 | $guid = $user->guid; |
|
90 | $file = new ElggFile(); |
|
91 | $file->owner_guid = $guid; |
|
92 | $file->setFilename("profile/{$guid}{$name}.jpg"); |
|
93 | $file->open('write'); |
|
94 | $file->write($resized); |
|
95 | $file->close(); |
|
96 | $files[] = $file; |
|
97 | } else { |
|
98 | // cleanup on fail |
|
99 | foreach ($files as $file) { |
|
100 | $file->delete(); |
|
101 | } |
|
102 | ||
103 | register_error(elgg_echo('avatar:resize:fail')); |
|
104 | forward(REFERER); |
|
105 | } |
|
106 | } |
|
107 | ||
108 | $user->icontime = time(); |
|
109 | if (elgg_trigger_event('profileiconupdate', $user->type, $user)) { |