summaryrefslogtreecommitdiff
path: root/_darcs/patches/unrevert
blob: f112ac9a51d022cdd6a905c12e2d1ccc1c735a78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367

New patches:

[unrevert
anonymous**20090106212613] {
hunk ./actions/profilesettings.php 57
             return;
         }
 
+v v v v v v v
 		if ($this->arg('save')) {
 			$this->save_profile();
 		} else if ($this->arg('upload')) {
hunk ./actions/profilesettings.php 62
 			$this->upload_avatar();
+		} else if ($this->arg('crop')) {
+			$this->crop_avatar();
 		} else if ($this->arg('changepass')) {
 			$this->change_password();
hunk ./actions/profilesettings.php 66
+		} else {
+			$this->show_form(_('Unexpected form submission.'));
 		}
hunk ./actions/profilesettings.php 69
+*************
+        if ($this->arg('save')) {
+            $this->save_profile();
+        } else if ($this->arg('upload')) {
+            $this->upload_avatar();
+        } else if ($this->arg('changepass')) {
+            $this->change_password();
+        }
+^ ^ ^ ^ ^ ^ ^
 
     }
 
hunk ./actions/profilesettings.php 164
 
         $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
 
+v v v v v v v
 		if ($avatar) {
hunk ./actions/profilesettings.php 166
-			common_element('img', array('src' => $avatar->url,
+			common_element_start('div', array('id'=>'avatar_preview', 'class'=>'avatar_view'));
+			common_element('h3', null, _("Preview:"));
+			common_element_start('div', array('id'=>'avatar_preview_view'));
+			common_element('img', array('src' => $original->url,//$avatar->url,
 										'class' => 'avatar profile',
 										'width' => AVATAR_PROFILE_SIZE,
 										'height' => AVATAR_PROFILE_SIZE,
hunk ./actions/profilesettings.php 174
 										'alt' => $user->nickname));
+			common_element_end('div');
+			common_element_end('div');
+
+			foreach(array('avatar_crop_x', 'avatar_crop_y', 'avatar_crop_w', 'avatar_crop_h') as $crop_info) {
+				common_element('input', array('name' => $crop_info,
+											  'type' => 'hidden',
+											  'id' => $crop_info));
+			}
+			common_submit('crop', _('Crop'));
 		}
hunk ./actions/profilesettings.php 184
+*************
+        if ($avatar) {
+            common_element('img', array('src' => $avatar->url,
+                                        'class' => 'avatar profile',
+                                        'width' => AVATAR_PROFILE_SIZE,
+                                        'height' => AVATAR_PROFILE_SIZE,
+                                        'alt' => $user->nickname));
+        }
+^ ^ ^ ^ ^ ^ ^
 
 
         common_element('input', array('name' => 'MAX_FILE_SIZE',
hunk ./actions/profilesettings.php 429
             $this->show_form(_('Failed updating avatar.'));
         }
 
+v v v v v v v
 		@unlink($_FILES['avatarfile']['tmp_name']);
 	}
 
hunk ./actions/profilesettings.php 433
+	function crop_avatar() {
+
+		$user = common_current_user();
+		$profile = $user->getProfile();
+
+		$x = $this->arg('avatar_crop_x');
+		$y = $this->arg('avatar_crop_y');
+		$w = $this->arg('avatar_crop_w');
+		$h = $this->arg('avatar_crop_h');
+
+		if ($profile->crop_avatars($x, $y, $w, $h)) {
+			$this->show_form(_('Avatar updated.'), true);
+		} else {
+			$this->show_form(_('Failed updating avatar.'));
+		}
+	}
+*************
+        @unlink($_FILES['avatarfile']['tmp_name']);
+    }
+^ ^ ^ ^ ^ ^ ^
+
     function nickname_exists($nickname)
     {
         $user = common_current_user();
hunk ./classes/Avatar.php 82
         }
     }
 
+v v v v v v v
+	function scale_and_crop($size, $x, $y, $w, $h) {
+
+		$image_s = imagecreatetruecolor($size, $size);
+		$image_a = $this->to_image();
+
+		# Retain alpha channel info if possible for .pngs
+		$background = imagecolorallocate($image_s, 0, 0, 0);
+		ImageColorTransparent($image_s, $background);
+		imagealphablending($image_s, false);
+
+		imagecopyresized($image_s, $image_a, 0, 0, $x, $y, $size, $size, $w, $h);
+
+		$ext = ($this->mediattype == 'image/jpeg') ? ".jpeg" : ".png";
+
+		$filename = common_avatar_filename($this->profile_id, $ext, $size, common_timestamp());
+
+		if ($this->mediatype == 'image/jpeg') {
+			imagejpeg($image_s, common_avatar_path($filename));
+		} else {
+			imagepng($image_s, common_avatar_path($filename));
+		}
+
+		$cropped = DB_DataObject::factory('avatar');
+		$cropped->profile_id = $this->profile_id;
+		$cropped->width = $size;
+		$cropped->height = $size;
+		$cropped->original = false;
+		$cropped->mediatype = ($this->mediattype == 'image/jpeg') ? 'image/jpeg' : 'image/png';
+		$cropped->filename = $filename;
+		$cropped->url = common_avatar_url($filename);
+		$cropped->created = DB_DataObject_Cast::dateTime(); # current time
+
+		if ($cropped->insert()) {
+			return $cropped;
+		} else {
+			return NULL;
+		}
+	}
+
 	function to_image() {
 		$filepath = common_avatar_path($this->filename);
 		if ($this->mediatype == 'image/gif') {
hunk ./classes/Avatar.php 138
 	function &pkeyGet($kv) {
 		return Memcached_DataObject::pkeyGet('Avatar', $kv);
 	}
+*************
+    function to_image()
+    {
+        $filepath = common_avatar_path($this->filename);
+        if ($this->mediatype == 'image/gif') {
+            return imagecreatefromgif($filepath);
+        } else if ($this->mediatype == 'image/jpeg') {
+            return imagecreatefromjpeg($filepath);
+        } else if ($this->mediatype == 'image/png') {
+            return imagecreatefrompng($filepath);
+        } else {
+            return null;
+        }
+    }
+    
+    function &pkeyGet($kv)
+    {
+        return Memcached_DataObject::pkeyGet('Avatar', $kv);
+    }
+^ ^ ^ ^ ^ ^ ^
 }
hunk ./classes/Profile.php 124
         return $avatar;
     }
 
-	function delete_avatars() {
+v v v v v v v
+	function crop_avatars($x, $y, $w, $h) {
+
+		$avatar = $this->getOriginalAvatar();
+		$this->delete_avatars(false); # don't delete original
+
+		foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
+			# We don't do a scaled one if original is our scaled size
+			if (!($avatar->width == $size && $avatar->height == $size)) {
+				$s = $avatar->scale_and_crop($size, $x, $y, $w, $h);
+				if (!$s) {
+					return NULL;
+				}
+			}
+		}
+		return true;
+	}
+
+	function delete_avatars($original=true) {
 		$avatar = new Avatar();
 		$avatar->profile_id = $this->id;
 		$avatar->find();
hunk ./classes/Profile.php 147
 		while ($avatar->fetch()) {
+			if ($avatar->original) {
+				if ($original == false) {
+					continue;
+				}
+			}
 			$avatar->delete();
 		}
 		return true;
hunk ./classes/Profile.php 156
 	}
+*************
+    function delete_avatars()
+    {
+        $avatar = new Avatar();
+        $avatar->profile_id = $this->id;
+        $avatar->find();
+        while ($avatar->fetch()) {
+            $avatar->delete();
+        }
+        return true;
+    }
+^ ^ ^ ^ ^ ^ ^
 
     function getBestName()
     {
}

Context:

[Actually crop your avatar when hitting 'crop' button on profile
Zach Copley <zach@controlyourself.ca>**20081212043018] 
[Jcrop CSS updates to original/preview views
csarven@controlyourself.ca**20081210025922] 
[Jcrop v2 (POST cropping to be completed)
csarven@controlyourself.ca**20081210021607] 
[trac750 added some output to the facebook_update.php script
Zach Copley <zach@controlyourself.ca>**20090105045603] 
[trac750 configurable sync flags for Facebook app (noticesync, replysync)
Zach Copley <zach@controlyourself.ca>**20090105040212] 
[trac750 Automatically update linked Facebook users' statuses
Zach Copley <zach@controlyourself.ca>**20090105010407] 
[wrapper element for config.xml
Evan Prodromou <evan@prodromou.name>**20081230212202] 
[better serialization of arrays and booleans in config output
Evan Prodromou <evan@prodromou.name>**20081230211957] 
[implement the api/laconica/config method
Evan Prodromou <evan@prodromou.name>**20081230211444] 
[add some breaks so that switch statement works
Evan Prodromou <evan@prodromou.name>**20081230210114] 
[implement api/laconica/version method
Evan Prodromou <evan@prodromou.name>**20081230205939] 
[add laconica methods to unauthed ones
Evan Prodromou <evan@prodromou.name>**20081230203747] 
[add laconica-specific methods to htaccess.sample
Evan Prodromou <evan@prodromou.name>**20081230202513] 
[Laconica-specific extensions for Twitter API
Evan Prodromou <evan@prodromou.name>**20081230202019] 
[whitespace changes in actions/register.php after global search-and-replace
Evan Prodromou <evan@prodromou.name>**20081223195722] 
[Twitter-bridge: fix for Twitter's new strict policy of rejecting HTTP POSTs with invalid "expect" headers
Zach Copley <zach@controlyourself.ca>**20081225152207] 
[move opening brace of class declaration to next line
Evan Prodromou <evan@prodromou.name>**20081223194923
 
 Another gigantor PEAR coding standards patch. Here, I've moved the
 opening curly bracket on a class statement to the following line.
 
] 
[TRUE => true, FALSE => false
Evan Prodromou <evan@prodromou.name>**20081223194428
 
 More PEAR coding standards global changes. Here, I've changed all
 instances of TRUE to true and FALSE to false.
 
] 
[change function headers to K&R style
Evan Prodromou <evan@prodromou.name>**20081223193323
 
 Another huge change, for PEAR code standards compliance. Function
 headers have to be in K&R style (opening brace on its own line),
 instead of having the opening brace on the same line as the function
 and parameters. So, a little perl magic found all the function
 definitions and move the opening brace to the next line (properly
 indented... usually).
 
] 
[replace NULL with null
Evan Prodromou <evan@prodromou.name>**20081223192129
 
 Another global search-and-replace update. Here, I've replaced the PHP
 keyword 'NULL' with its lowercase version. This is another PEAR code
 standards change.
 
] 
[replace all tabs with four spaces
Evan Prodromou <evan@prodromou.name>**20081223191907
 
 The PEAR coding standards decree: no tabs, but indent by four spaces.
 I've done a global search-and-replace on all tabs, replacing them by
 four spaces. This is a huge change, but it will go a long way to
 getting us towards phpcs-compliance. And that means better code
 readability, and that means more participation.
 
] 
[incorrect label on notice list file comment
Evan Prodromou <evan@prodromou.name>**20081223191430] 
[bring lib/noticelist.php into line with PEAR code standards
Evan Prodromou <evan@prodromou.name>**20081223190851] 
[reformat and document lib/mail.php for phpcs conformance
Evan Prodromou <evan@prodromou.name>**20081223173330] 
[bring messaging section (inbox, outbox, mailbox) into PEAR Code Standards compliance
Evan Prodromou <evan@prodromou.name>**20081222201304
 
 Actually refactored the method names on these classes to come into
 complete compliance with the code standards. Untested; maybe there are
 some bad method names now.
 
] 
[bring mailbox.php into line with PEAR Coding Standards (mostly)
Evan Prodromou <evan@prodromou.name>**20081222195041] 
[reformat lib/language.php for PEAR Coding Standards
Evan Prodromou <evan@prodromou.name>**20081222193029] 
[reformat lib/jabber.php for phpcs, including doc comments
Evan Prodromou <evan@prodromou.name>**20081222173249] 
[reformat for phpcs
Evan Prodromou <evan@prodromou.name>**20081221005837] 
[reformat lib/daemon.php for phpcs
Evan Prodromou <evan@prodromou.name>**20081221004607] 
[some modifications to assuage phpcs
Evan Prodromou <evan@prodromou.name>**20081221003955] 
[reformatting for phpcs in lib/util.php
Evan Prodromou <evan@prodromou.name>**20081221003016] 
[first step of phpcs-cleanup of index.php
Evan Prodromou <evan@prodromou.name>**20081221002332] 
[more information in subscription notices
Evan Prodromou <evan@prodromou.name>**20081212171135] 
[identica badge by Kent Brewster. For more information see:
Sarven Capadisli <csarven@controlyourself.ca>**20081218003302
 http://kentbrewster.com/identica-badge/
 
 Copy and paste the following wherever you want the badge to show up:
 
 <script type="text/javascript" src="http://identi.ca/js/identica-badge.js">
 {
    "user":"kentbrew",
    "server":"identi.ca",
    "headerText":" and friends"
 }
 </script>
 	 
 Substitute your own ID in the user parameter.
 
] 
[TAG 0.6.4.1
Evan Prodromou <evan@controlezvous.ca>**20081220204906] 
Patch bundle hash:
316173068f974bea2f9537d45d347f45c12050bc