]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - _darcs/tentative_pristine
ffadf4b715a5a535453bd807d81f9f2e81f06054
[quix0rs-gnu-social.git] / _darcs / tentative_pristine
1 hunk ./actions/accesstoken.php 25
2 -       function handle($args) {
3 -               parent::handle($args);
4 -               try {
5 -                       common_debug('getting request from env variables', __FILE__);
6 -                       common_remove_magic_from_request();
7 -                       $req = OAuthRequest::from_request();
8 -                       common_debug('getting a server', __FILE__);
9 -                       $server = omb_oauth_server();
10 -                       common_debug('fetching the access token', __FILE__);
11 -                       $token = $server->fetch_access_token($req);
12 -                       common_debug('got this token: "'.print_r($token,TRUE).'"', __FILE__);
13 -                       common_debug('printing the access token', __FILE__);
14 -                       print $token;
15 -               } catch (OAuthException $e) {
16 -                       common_server_error($e->getMessage());
17 -               }
18 -       }
19 +    function handle($args) {
20 +        parent::handle($args);
21 +        try {
22 +            common_debug('getting request from env variables', __FILE__);
23 +            common_remove_magic_from_request();
24 +            $req = OAuthRequest::from_request();
25 +            common_debug('getting a server', __FILE__);
26 +            $server = omb_oauth_server();
27 +            common_debug('fetching the access token', __FILE__);
28 +            $token = $server->fetch_access_token($req);
29 +            common_debug('got this token: "'.print_r($token,TRUE).'"', __FILE__);
30 +            common_debug('printing the access token', __FILE__);
31 +            print $token;
32 +        } catch (OAuthException $e) {
33 +            common_server_error($e->getMessage());
34 +        }
35 +    }
36 hunk ./actions/all.php 26
37 -       function handle($args) {
38 +    function handle($args) {
39 hunk ./actions/all.php 28
40 -               parent::handle($args);
41 +        parent::handle($args);
42 hunk ./actions/all.php 30
43 -               $nickname = common_canonical_nickname($this->arg('nickname'));
44 -               $user = User::staticGet('nickname', $nickname);
45 +        $nickname = common_canonical_nickname($this->arg('nickname'));
46 +        $user = User::staticGet('nickname', $nickname);
47 hunk ./actions/all.php 33
48 -               if (!$user) {
49 -                       $this->client_error(_('No such user.'));
50 -                       return;
51 -               }
52 +        if (!$user) {
53 +            $this->client_error(_('No such user.'));
54 +            return;
55 +        }
56 hunk ./actions/all.php 38
57 -               $profile = $user->getProfile();
58 +        $profile = $user->getProfile();
59 hunk ./actions/all.php 40
60 -               if (!$profile) {
61 -                       common_server_error(_('User has no profile.'));
62 -                       return;
63 -               }
64 +        if (!$profile) {
65 +            common_server_error(_('User has no profile.'));
66 +            return;
67 +        }
68 hunk ./actions/all.php 45
69 -               # Looks like we're good; show the header
70 +        # Looks like we're good; show the header
71 hunk ./actions/all.php 47
72 -               common_show_header(sprintf(_("%s and friends"), $profile->nickname),
73 -                                                  array($this, 'show_header'), $user,
74 -                                                  array($this, 'show_top'));
75 +        common_show_header(sprintf(_("%s and friends"), $profile->nickname),
76 +                           array($this, 'show_header'), $user,
77 +                           array($this, 'show_top'));
78 hunk ./actions/all.php 51
79 -               $this->show_notices($user);
80 +        $this->show_notices($user);
81 hunk ./actions/all.php 53
82 -               common_show_footer();
83 -       }
84 +        common_show_footer();
85 +    }
86 hunk ./actions/all.php 56
87 -       function show_header($user) {
88 -               common_element('link', array('rel' => 'alternate',
89 -                                                                        'href' => common_local_url('allrss', array('nickname' =>
90 -                                                                                                                                                          $user->nickname)),
91 -                                                                        'type' => 'application/rss+xml',
92 -                                                                        'title' => sprintf(_('Feed for friends of %s'), $user->nickname)));
93 -       }
94 +    function show_header($user) {
95 +        common_element('link', array('rel' => 'alternate',
96 +                                     'href' => common_local_url('allrss', array('nickname' =>
97 +                                                                               $user->nickname)),
98 +                                     'type' => 'application/rss+xml',
99 +                                     'title' => sprintf(_('Feed for friends of %s'), $user->nickname)));
100 +    }
101 hunk ./actions/all.php 64
102 -       function show_top($user) {
103 -               $cur = common_current_user();
104 +    function show_top($user) {
105 +        $cur = common_current_user();
106 hunk ./actions/all.php 67
107 -               if ($cur && $cur->id == $user->id) {
108 -                       common_notice_form('all');
109 -               }
110 +        if ($cur && $cur->id == $user->id) {
111 +            common_notice_form('all');
112 +        }
113 hunk ./actions/all.php 71
114 -               $this->views_menu();
115 +        $this->views_menu();
116 hunk ./actions/all.php 73
117 -               $this->show_feeds_list(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $user->nickname)),
118 -                                                                                         'type' => 'rss',
119 -                                                                                         'version' => 'RSS 1.0',
120 -                                                                                         'item' => 'allrss')));
121 -       }
122 +        $this->show_feeds_list(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $user->nickname)),
123 +                                              'type' => 'rss',
124 +                                              'version' => 'RSS 1.0',
125 +                                              'item' => 'allrss')));
126 +    }
127 hunk ./actions/all.php 79
128 -       function show_notices($user) {
129 +    function show_notices($user) {
130 hunk ./actions/all.php 81
131 -               $page = $this->trimmed('page');
132 -               if (!$page) {
133 -                       $page = 1;
134 -               }
135 +        $page = $this->trimmed('page');
136 +        if (!$page) {
137 +            $page = 1;
138 +        }
139 hunk ./actions/all.php 86
140 -               $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
141 +        $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
142 hunk ./actions/all.php 90
143 -               common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
144 -                                                 $page, 'all', array('nickname' => $user->nickname));
145 -       }
146 +        common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
147 +                          $page, 'all', array('nickname' => $user->nickname));
148 +    }
149 hunk ./actions/allrss.php 28
150 -       var $user = NULL;
151 +    var $user = NULL;
152 hunk ./actions/allrss.php 30
153 -       function init() {
154 -               $nickname = $this->trimmed('nickname');
155 -               $this->user = User::staticGet('nickname', $nickname);
156 +    function init() {
157 +        $nickname = $this->trimmed('nickname');
158 +        $this->user = User::staticGet('nickname', $nickname);
159 hunk ./actions/allrss.php 34
160 -               if (!$this->user) {
161 -                       common_user_error(_('No such user.'));
162 -                       return false;
163 -               } else {
164 -                       return true;
165 -               }
166 -       }
167 +        if (!$this->user) {
168 +            common_user_error(_('No such user.'));
169 +            return false;
170 +        } else {
171 +            return true;
172 +        }
173 +    }
174 hunk ./actions/allrss.php 42
175 -       function get_notices($limit=0) {
176 +    function get_notices($limit=0) {
177 hunk ./actions/allrss.php 44
178 -               $user = $this->user;
179 -               
180 -               $notice = $user->noticesWithFriends(0, $limit);
181 -                                                                                       
182 -               while ($notice->fetch()) {
183 -                       $notices[] = clone($notice);
184 -               }
185 +        $user = $this->user;
186 +        
187 +        $notice = $user->noticesWithFriends(0, $limit);
188 +                                            
189 +        while ($notice->fetch()) {
190 +            $notices[] = clone($notice);
191 +        }
192 hunk ./actions/allrss.php 52
193 -               return $notices;
194 -       }
195 +        return $notices;
196 +    }
197 hunk ./actions/allrss.php 55
198 -       function get_channel() {
199 -               $user = $this->user;
200 -               $c = array('url' => common_local_url('allrss',
201 -                                                                                        array('nickname' =>
202 -                                                                                                  $user->nickname)),
203 -                                  'title' => sprintf(_('%s and friends'), $user->nickname),
204 -                                  'link' => common_local_url('all',
205 -                                                                                        array('nickname' =>
206 -                                                                                                  $user->nickname)),
207 -                                  'description' => sprintf(_('Feed for friends of %s'), $user->nickname));
208 -               return $c;
209 -       }
210 +    function get_channel() {
211 +        $user = $this->user;
212 +        $c = array('url' => common_local_url('allrss',
213 +                                             array('nickname' =>
214 +                                                   $user->nickname)),
215 +                   'title' => sprintf(_('%s and friends'), $user->nickname),
216 +                   'link' => common_local_url('all',
217 +                                             array('nickname' =>
218 +                                                   $user->nickname)),
219 +                   'description' => sprintf(_('Feed for friends of %s'), $user->nickname));
220 +        return $c;
221 +    }
222 hunk ./actions/allrss.php 68
223 -       function get_image() {
224 -               $user = $this->user;
225 -               $profile = $user->getProfile();
226 -               if (!$profile) {
227 -                       return NULL;
228 -               }
229 -               $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
230 -               return ($avatar) ? $avatar->url : NULL;
231 -       }
232 +    function get_image() {
233 +        $user = $this->user;
234 +        $profile = $user->getProfile();
235 +        if (!$profile) {
236 +            return NULL;
237 +        }
238 +        $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
239 +        return ($avatar) ? $avatar->url : NULL;
240 +    }
241 hunk ./actions/api.php 13
242 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
243 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
244 hunk ./actions/api.php 17
245 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
246 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
247 hunk ./actions/api.php 24
248 -       var $user;
249 -       var $content_type;
250 -       var $api_arg;
251 -       var $api_method;
252 -       var $api_action;
253 +    var $user;
254 +    var $content_type;
255 +    var $api_arg;
256 +    var $api_method;
257 +    var $api_action;
258 hunk ./actions/api.php 30
259 -       function handle($args) {
260 -               parent::handle($args);
261 +    function handle($args) {
262 +        parent::handle($args);
263 hunk ./actions/api.php 33
264 -               $this->api_action = $this->arg('apiaction');
265 -               $method = $this->arg('method');
266 -               $argument = $this->arg('argument');
267 +        $this->api_action = $this->arg('apiaction');
268 +        $method = $this->arg('method');
269 +        $argument = $this->arg('argument');
270 hunk ./actions/api.php 37
271 -               if (isset($argument)) {
272 -                       $cmdext = explode('.', $argument);
273 -                       $this->api_arg =  $cmdext[0];
274 -                       $this->api_method = $method;
275 -                       $this->content_type = strtolower($cmdext[1]);
276 -               } else {
277 +        if (isset($argument)) {
278 +            $cmdext = explode('.', $argument);
279 +            $this->api_arg =  $cmdext[0];
280 +            $this->api_method = $method;
281 +            $this->content_type = strtolower($cmdext[1]);
282 +        } else {
283 hunk ./actions/api.php 44
284 -                       # Requested format / content-type will be an extension on the method
285 -                       $cmdext = explode('.', $method);
286 -                       $this->api_method = $cmdext[0];
287 -                       $this->content_type = strtolower($cmdext[1]);
288 -               }
289 +            # Requested format / content-type will be an extension on the method
290 +            $cmdext = explode('.', $method);
291 +            $this->api_method = $cmdext[0];
292 +            $this->content_type = strtolower($cmdext[1]);
293 +        }
294 hunk ./actions/api.php 50
295 -               if ($this->requires_auth()) {
296 -                       if (!isset($_SERVER['PHP_AUTH_USER'])) {
297 +        if ($this->requires_auth()) {
298 +            if (!isset($_SERVER['PHP_AUTH_USER'])) {
299 hunk ./actions/api.php 53
300 -                               # This header makes basic auth go
301 -                               header('WWW-Authenticate: Basic realm="Laconica API"');
302 +                # This header makes basic auth go
303 +                header('WWW-Authenticate: Basic realm="Laconica API"');
304 hunk ./actions/api.php 56
305 -                               # If the user hits cancel -- bam!
306 -                               $this->show_basic_auth_error();
307 -                       } else {
308 -                               $nickname = $_SERVER['PHP_AUTH_USER'];
309 -                               $password = $_SERVER['PHP_AUTH_PW'];
310 -                               $user = common_check_user($nickname, $password);
311 +                # If the user hits cancel -- bam!
312 +                $this->show_basic_auth_error();
313 +            } else {
314 +                $nickname = $_SERVER['PHP_AUTH_USER'];
315 +                $password = $_SERVER['PHP_AUTH_PW'];
316 +                $user = common_check_user($nickname, $password);
317 hunk ./actions/api.php 63
318 -                               if ($user) {
319 -                                       $this->user = $user;
320 -                                       $this->process_command();
321 -                               } else {
322 -                                       # basic authentication failed
323 -                                       $this->show_basic_auth_error();
324 -                               }
325 -                       }
326 -               } else {
327 +                if ($user) {
328 +                    $this->user = $user;
329 +                    $this->process_command();
330 +                } else {
331 +                    # basic authentication failed
332 +                    $this->show_basic_auth_error();
333 +                }
334 +            }
335 +        } else {
336 hunk ./actions/api.php 73
337 -                       # Look for the user in the session
338 -                       if (common_logged_in()) {
339 -                               $this->user = common_current_user();
340 -                       }
341 +            # Look for the user in the session
342 +            if (common_logged_in()) {
343 +                 $this->user = common_current_user();
344 +            }
345 hunk ./actions/api.php 78
346 -                       $this->process_command();
347 -               }
348 -       }
349 +            $this->process_command();
350 +        }
351 +    }
352 hunk ./actions/api.php 82
353 -       function process_command() {
354 -               $action = "twitapi$this->api_action";
355 -               $actionfile = INSTALLDIR."/actions/$action.php";
356 +    function process_command() {
357 +        $action = "twitapi$this->api_action";
358 +        $actionfile = INSTALLDIR."/actions/$action.php";
359 hunk ./actions/api.php 86
360 -               if (file_exists($actionfile)) {
361 -                       require_once($actionfile);
362 -                       $action_class = ucfirst($action)."Action";
363 -                       $action_obj = new $action_class();
364 +        if (file_exists($actionfile)) {
365 +            require_once($actionfile);
366 +            $action_class = ucfirst($action)."Action";
367 +            $action_obj = new $action_class();
368 hunk ./actions/api.php 95
369 -                       if (method_exists($action_obj, $this->api_method)) {
370 -                               $apidata = array(       'content-type' => $this->content_type,
371 -                                                                       'api_method' => $this->api_method,
372 -                                                                       'api_arg' => $this->api_arg,
373 -                                                                       'user' => $this->user);
374 +            if (method_exists($action_obj, $this->api_method)) {
375 +                $apidata = array(    'content-type' => $this->content_type,
376 +                                    'api_method' => $this->api_method,
377 +                                    'api_arg' => $this->api_arg,
378 +                                    'user' => $this->user);
379 hunk ./actions/api.php 101
380 -                               call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata);
381 -                       } else {
382 -                               common_user_error("API method not found!", $code=404);
383 -                       }
384 -               } else {
385 -                       common_user_error("API method not found!", $code=404);
386 -               }
387 -       }
388 +                call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata);
389 +            } else {
390 +                common_user_error("API method not found!", $code=404);
391 +            }
392 +        } else {
393 +            common_user_error("API method not found!", $code=404);
394 +        }
395 +    }
396 hunk ./actions/api.php 110
397 -       # Whitelist of API methods that don't need authentication
398 -       function requires_auth() {
399 -               static $noauth = array( 'statuses/public_timeline',
400 -                                                               'statuses/show',
401 -                                                               'users/show',
402 -                                                               'help/test',
403 -                                                               'help/downtime_schedule');
404 +    # Whitelist of API methods that don't need authentication
405 +    function requires_auth() {
406 +        static $noauth = array( 'statuses/public_timeline',
407 +                                'statuses/show',
408 +                                'users/show',
409 +                                'help/test',
410 +                                'help/downtime_schedule');
411 hunk ./actions/api.php 118
412 -               static $bareauth = array('statuses/user_timeline',
413 -                                                                'statuses/friends',
414 -                                                                'statuses/followers',
415 -                                                                'favorites/favorites');
416 +        static $bareauth = array('statuses/user_timeline',
417 +                                 'statuses/friends',
418 +                                 'statuses/followers',
419 +                                 'favorites/favorites');
420 hunk ./actions/api.php 129
421 -               $fullname = "$this->api_action/$this->api_method";
422 +        $fullname = "$this->api_action/$this->api_method";
423 hunk ./actions/api.php 131
424 -               if (in_array($fullname, $bareauth)) {
425 -                       # bareauth: only needs auth if without an argument
426 -                       if ($this->api_arg) {
427 -                               return false;
428 -                       } else {
429 -                               return true;
430 -                       }
431 -               } else if (in_array($fullname, $noauth)) {
432 -                       # noauth: never needs auth
433 -                       return false;
434 -               } else {
435 -                       # everybody else needs auth
436 -                       return true;
437 -               }
438 -       }
439 +        if (in_array($fullname, $bareauth)) {
440 +            # bareauth: only needs auth if without an argument
441 +            if ($this->api_arg) {
442 +                return false;
443 +            } else {
444 +                return true;
445 +            }
446 +        } else if (in_array($fullname, $noauth)) {
447 +            # noauth: never needs auth
448 +            return false;
449 +        } else {
450 +            # everybody else needs auth
451 +            return true;
452 +        }
453 +    }
454 hunk ./actions/api.php 147
455 -       function show_basic_auth_error() {
456 -               header('HTTP/1.1 401 Unauthorized');
457 -               $msg = 'Could not authenticate you.';
458 +    function show_basic_auth_error() {
459 +        header('HTTP/1.1 401 Unauthorized');
460 +        $msg = 'Could not authenticate you.';
461 hunk ./actions/api.php 151
462 -               if ($this->content_type == 'xml') {
463 -                       header('Content-Type: application/xml; charset=utf-8');
464 -                       common_start_xml();
465 -                       common_element_start('hash');
466 -                       common_element('error', NULL, $msg);
467 -                       common_element('request', NULL, $_SERVER['REQUEST_URI']);
468 -                       common_element_end('hash');
469 -                       common_end_xml();
470 -               } else if ($this->content_type == 'json')  {
471 -                       header('Content-Type: application/json; charset=utf-8');
472 -                       $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
473 -                       print(json_encode($error_array));
474 -               } else {
475 -                       header('Content-type: text/plain');
476 -                       print "$msg\n";
477 -               }
478 -       }
479 +        if ($this->content_type == 'xml') {
480 +            header('Content-Type: application/xml; charset=utf-8');
481 +            common_start_xml();
482 +            common_element_start('hash');
483 +            common_element('error', NULL, $msg);
484 +            common_element('request', NULL, $_SERVER['REQUEST_URI']);
485 +            common_element_end('hash');
486 +            common_end_xml();
487 +        } else if ($this->content_type == 'json')  {
488 +            header('Content-Type: application/json; charset=utf-8');
489 +            $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
490 +            print(json_encode($error_array));
491 +        } else {
492 +            header('Content-type: text/plain');
493 +            print "$msg\n";
494 +        }
495 +    }
496 hunk ./actions/api.php 169
497 -       function is_readonly() {
498 -               # NOTE: before handle(), can't use $this->arg
499 -               $apiaction = $_REQUEST['apiaction'];
500 -               $method = $_REQUEST['method'];
501 -               list($cmdtext, $fmt) = explode('.', $method);
502 +    function is_readonly() {
503 +        # NOTE: before handle(), can't use $this->arg
504 +        $apiaction = $_REQUEST['apiaction'];
505 +        $method = $_REQUEST['method'];
506 +        list($cmdtext, $fmt) = explode('.', $method);
507 hunk ./actions/api.php 175
508 -               static $write_methods = array(
509 -                       'account' => array('update_location', 'update_delivery_device', 'end_session'),
510 -                       'blocks' => array('create', 'destroy'),
511 -                       'direct_messages' => array('create', 'destroy'),
512 -                       'favorites' => array('create', 'destroy'),
513 -                       'friendships' => array('create', 'destroy'),
514 -                       'help' => array(),
515 -                       'notifications' => array('follow', 'leave'),
516 -                       'statuses' => array('update', 'destroy'),
517 -                       'users' => array()
518 -               );
519 +        static $write_methods = array(
520 +            'account' => array('update_location', 'update_delivery_device', 'end_session'),
521 +            'blocks' => array('create', 'destroy'),
522 +            'direct_messages' => array('create', 'destroy'),
523 +            'favorites' => array('create', 'destroy'),
524 +            'friendships' => array('create', 'destroy'),
525 +            'help' => array(),
526 +            'notifications' => array('follow', 'leave'),
527 +            'statuses' => array('update', 'destroy'),
528 +            'users' => array()
529 +        );
530 hunk ./actions/api.php 187
531 -               if (array_key_exists($apiaction, $write_methods)) {
532 -                       if (!in_array($cmdtext, $write_methods[$apiaction])) {
533 -                               return true;
534 -                       }
535 -               }
536 +        if (array_key_exists($apiaction, $write_methods)) {
537 +            if (!in_array($cmdtext, $write_methods[$apiaction])) {
538 +                return true;
539 +            }
540 +        }
541 hunk ./actions/api.php 193
542 -               return false;
543 -       }
544 +        return false;
545 +    }
546 hunk ./actions/avatarbynickname.php 27
547 -               $this->client_error(_('No nickname.'));
548 -                       return;
549 -               }
550 -               $size = $this->trimmed('size');
551 +            $this->client_error(_('No nickname.'));
552 +            return;
553 +        }
554 +        $size = $this->trimmed('size');
555 hunk ./actions/avatarbynickname.php 32
556 -               $this->client_error(_('No size.'));
557 -                       return;
558 -               }
559 -               $size = strtolower($size);
560 -               if (!in_array($size, array('original', '96', '48', '24'))) {
561 -               $this->client_error(_('Invalid size.'));
562 -                       return;
563 -               }
564 +            $this->client_error(_('No size.'));
565 +            return;
566 +        }
567 +        $size = strtolower($size);
568 +        if (!in_array($size, array('original', '96', '48', '24'))) {
569 +            $this->client_error(_('Invalid size.'));
570 +            return;
571 +        }
572 hunk ./actions/avatarbynickname.php 41
573 -               $user = User::staticGet('nickname', $nickname);
574 -               if (!$user) {
575 -               $this->client_error(_('No such user.'));
576 -                       return;
577 -               }
578 -               $profile = $user->getProfile();
579 -               if (!$profile) {
580 -               $this->client_error(_('User has no profile.'));
581 -                       return;
582 -               }
583 -               if ($size == 'original') {
584 -                       $avatar = $profile->getOriginal();
585 -               } else {
586 -                       $avatar = $profile->getAvatar($size+0);
587 -               }
588 +        $user = User::staticGet('nickname', $nickname);
589 +        if (!$user) {
590 +            $this->client_error(_('No such user.'));
591 +            return;
592 +        }
593 +        $profile = $user->getProfile();
594 +        if (!$profile) {
595 +            $this->client_error(_('User has no profile.'));
596 +            return;
597 +        }
598 +        if ($size == 'original') {
599 +            $avatar = $profile->getOriginal();
600 +        } else {
601 +            $avatar = $profile->getAvatar($size+0);
602 +        }
603 hunk ./actions/avatarbynickname.php 57
604 -               if ($avatar) {
605 -                       $url = $avatar->url;
606 -               } else {
607 -                       if ($size == 'original') {
608 -                               $url = common_default_avatar(AVATAR_PROFILE_SIZE);
609 -                       } else {
610 -                               $url = common_default_avatar($size+0);
611 -                       }
612 -               }
613 -               common_redirect($url, 302);
614 -       }
615 +        if ($avatar) {
616 +            $url = $avatar->url;
617 +        } else {
618 +            if ($size == 'original') {
619 +                $url = common_default_avatar(AVATAR_PROFILE_SIZE);
620 +            } else {
621 +                $url = common_default_avatar($size+0);
622 +            }
623 +        }
624 +        common_redirect($url, 302);
625 +    }
626 hunk ./actions/block.php 35
627 -               $token = $this->trimmed('token');
628 +        $token = $this->trimmed('token');
629 hunk ./actions/block.php 37
630 -               if (!$token || $token != common_session_token()) {
631 -                       $this->client_error(_('There was a problem with your session token. Try again, please.'));
632 -                       return;
633 -               }
634 +        if (!$token || $token != common_session_token()) {
635 +            $this->client_error(_('There was a problem with your session token. Try again, please.'));
636 +            return;
637 +        }
638 hunk ./actions/block.php 78
639 -               common_show_header(_('Block user'));
640 +        common_show_header(_('Block user'));
641 hunk ./actions/confirmaddress.php 46
642 -               $type = $confirm->address_type;
643 -               if (!in_array($type, array('email', 'jabber', 'sms'))) {
644 -                       $this->server_error(sprintf(_('Unrecognized address type %s'), $type));
645 -                       return;
646 -               }
647 +        $type = $confirm->address_type;
648 +        if (!in_array($type, array('email', 'jabber', 'sms'))) {
649 +            $this->server_error(sprintf(_('Unrecognized address type %s'), $type));
650 +            return;
651 +        }
652 hunk ./actions/confirmaddress.php 53
653 -                       return;
654 -               }
655 +            return;
656 +        }
657 hunk ./actions/confirmaddress.php 60
658 -               $cur->$type = $confirm->address;
659 +        $cur->$type = $confirm->address;
660 hunk ./actions/confirmaddress.php 62
661 -               if ($type == 'sms') {
662 -                       $cur->carrier = ($confirm->address_extra)+0;
663 -                       $carrier = Sms_carrier::staticGet($cur->carrier);
664 -                       $cur->smsemail = $carrier->toEmailAddress($cur->sms);
665 -               }
666 +        if ($type == 'sms') {
667 +            $cur->carrier = ($confirm->address_extra)+0;
668 +            $carrier = Sms_carrier::staticGet($cur->carrier);
669 +            $cur->smsemail = $carrier->toEmailAddress($cur->sms);
670 +        }
671 hunk ./actions/confirmaddress.php 68
672 -               $result = $cur->updateKeys($orig_user);
673 +        $result = $cur->updateKeys($orig_user);
674 hunk ./actions/confirmaddress.php 71
675 -                       common_log_db_error($cur, 'UPDATE', __FILE__);
676 +            common_log_db_error($cur, 'UPDATE', __FILE__);
677 hunk ./actions/confirmaddress.php 76
678 -               if ($type == 'email') {
679 -                   $cur->emailChanged();
680 -               }
681 +        if ($type == 'email') {
682 +            $cur->emailChanged();
683 +        }
684 hunk ./actions/confirmaddress.php 83
685 -                       common_log_db_error($confirm, 'DELETE', __FILE__);
686 +            common_log_db_error($confirm, 'DELETE', __FILE__);
687 hunk ./actions/deletenotice.php 25
688 -       function handle($args) {
689 -               parent::handle($args);
690 -               # XXX: Ajax!
691 +    function handle($args) {
692 +        parent::handle($args);
693 +        # XXX: Ajax!
694 hunk ./actions/deletenotice.php 29
695 -               if ($_SERVER['REQUEST_METHOD'] == 'POST') {
696 -                       $this->delete_notice();
697 -               } else if ($_SERVER['REQUEST_METHOD'] == 'GET') {
698 -                       $this->show_form();
699 -               }
700 -       }
701 +        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
702 +            $this->delete_notice();
703 +        } else if ($_SERVER['REQUEST_METHOD'] == 'GET') {
704 +            $this->show_form();
705 +        }
706 +    }
707 hunk ./actions/deletenotice.php 36
708 -       function get_instructions() {
709 -               return _('You are about to permanently delete a notice.  Once this is done, it cannot be undone.');
710 -       }
711 +    function get_instructions() {
712 +        return _('You are about to permanently delete a notice.  Once this is done, it cannot be undone.');
713 +    }
714 hunk ./actions/deletenotice.php 40
715 -       function get_title() {
716 -               return _('Delete notice');
717 -       }
718 +    function get_title() {
719 +        return _('Delete notice');
720 +    }
721 hunk ./actions/deletenotice.php 44
722 -       function show_form($error=NULL) {
723 -               $user = common_current_user();
724 +    function show_form($error=NULL) {
725 +        $user = common_current_user();
726 hunk ./actions/deletenotice.php 47
727 -               common_show_header($this->get_title(), array($this, 'show_header'), $error,
728 -                                                  array($this, 'show_top'));
729 -               common_element_start('form', array('id' => 'notice_delete_form',
730 -                                                                  'method' => 'post',
731 -                                                                  'action' => common_local_url('deletenotice')));
732 -               common_hidden('token', common_session_token());
733 -               common_hidden('notice', $this->trimmed('notice'));
734 -               common_element_start('p');
735 -               common_element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?'));
736 +        common_show_header($this->get_title(), array($this, 'show_header'), $error,
737 +                           array($this, 'show_top'));
738 +        common_element_start('form', array('id' => 'notice_delete_form',
739 +                                   'method' => 'post',
740 +                                   'action' => common_local_url('deletenotice')));
741 +        common_hidden('token', common_session_token());
742 +        common_hidden('notice', $this->trimmed('notice'));
743 +        common_element_start('p');
744 +        common_element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?'));
745 hunk ./actions/deletenotice.php 57
746 -               common_element('input', array('id' => 'submit_no',
747 -                                                 'name' => 'submit',
748 -                                                 'type' => 'submit',
749 -                                                 'value' => _('No')));
750 -               common_element('input', array('id' => 'submit_yes',
751 -                                                 'name' => 'submit',
752 -                                                 'type' => 'submit',
753 -                                                 'value' => _('Yes')));
754 -               common_element_end('p');
755 -               common_element_end('form');
756 -               common_show_footer();
757 -       }
758 +        common_element('input', array('id' => 'submit_no',
759 +                          'name' => 'submit',
760 +                          'type' => 'submit',
761 +                          'value' => _('No')));
762 +        common_element('input', array('id' => 'submit_yes',
763 +                          'name' => 'submit',
764 +                          'type' => 'submit',
765 +                          'value' => _('Yes')));
766 +        common_element_end('p');
767 +        common_element_end('form');
768 +        common_show_footer();
769 +    }
770 hunk ./actions/deletenotice.php 70
771 -       function delete_notice() {
772 -               # CSRF protection
773 -               $token = $this->trimmed('token');
774 -               if (!$token || $token != common_session_token()) {
775 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
776 -                       return;
777 -               }
778 -               $url = common_get_returnto();
779 -               $confirmed = $this->trimmed('submit');
780 -               if ($confirmed == _('Yes')) {
781 -                       $user = common_current_user();
782 -                       $notice_id = $this->trimmed('notice');
783 -                       $notice = Notice::staticGet($notice_id);
784 -                       $replies = new Reply;
785 -                       $replies->get('notice_id', $notice_id);
786 +    function delete_notice() {
787 +        # CSRF protection
788 +        $token = $this->trimmed('token');
789 +        if (!$token || $token != common_session_token()) {
790 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
791 +            return;
792 +        }
793 +        $url = common_get_returnto();
794 +        $confirmed = $this->trimmed('submit');
795 +        if ($confirmed == _('Yes')) {
796 +            $user = common_current_user();
797 +            $notice_id = $this->trimmed('notice');
798 +            $notice = Notice::staticGet($notice_id);
799 +            $replies = new Reply;
800 +            $replies->get('notice_id', $notice_id);
801 hunk ./actions/deletenotice.php 86
802 -                       common_dequeue_notice($notice);
803 -                       if (common_config('memcached', 'enabled')) {
804 -                               $notice->blowSubsCache();
805 -                       }
806 -                       $replies->delete();
807 -                       $notice->delete();
808 -               } else {
809 -                       if ($url) {
810 -                               common_set_returnto(NULL);
811 -                       } else {
812 -                               $url = common_local_url('public');
813 -                       }
814 -               }
815 -               common_redirect($url);
816 -       }
817 +            common_dequeue_notice($notice);
818 +            if (common_config('memcached', 'enabled')) {
819 +                $notice->blowSubsCache();
820 +            }
821 +            $replies->delete();
822 +            $notice->delete();
823 +        } else {
824 +            if ($url) {
825 +                common_set_returnto(NULL);
826 +            } else {
827 +                $url = common_local_url('public');
828 +            }
829 +        }
830 +        common_redirect($url);
831 +    }
832 hunk ./actions/deleteprofile.php 35
833 -       function get_instructions() {
834 -               return _('Export and delete your user information.');
835 -       }
836 +    function get_instructions() {
837 +        return _('Export and delete your user information.');
838 +    }
839 hunk ./actions/deleteprofile.php 39
840 -       function form_header($title, $msg=NULL, $success=false) {
841 -               common_show_header($title,
842 -                                  NULL,
843 -                                  array($msg, $success),
844 -                                                  array($this, 'show_top'));
845 -       }
846 +    function form_header($title, $msg=NULL, $success=false) {
847 +        common_show_header($title,
848 +                           NULL,
849 +                           array($msg, $success),
850 +                           array($this, 'show_top'));
851 +    }
852 hunk ./actions/deleteprofile.php 46
853 -       function show_feeds_list($feeds) {
854 -               common_element_start('div', array('class' => 'feedsdel'));
855 -               common_element('p', null, 'Feeds:');
856 -               common_element_start('ul', array('class' => 'xoxo'));
857 +    function show_feeds_list($feeds) {
858 +        common_element_start('div', array('class' => 'feedsdel'));
859 +        common_element('p', null, 'Feeds:');
860 +        common_element_start('ul', array('class' => 'xoxo'));
861 hunk ./actions/deleteprofile.php 51
862 -               foreach ($feeds as $key => $value) {
863 -                       $this->common_feed_item($feeds[$key]);
864 -               }
865 -               common_element_end('ul');
866 -               common_element_end('div');
867 -       }
868 +        foreach ($feeds as $key => $value) {
869 +            $this->common_feed_item($feeds[$key]);
870 +        }
871 +        common_element_end('ul');
872 +        common_element_end('div');
873 +    }
874 hunk ./actions/deleteprofile.php 59
875 -       function common_feed_item($feed) {
876 +    function common_feed_item($feed) {
877 hunk ./actions/deleteprofile.php 61
878 -               $nickname = $user->nickname;
879 +        $nickname = $user->nickname;
880 hunk ./actions/deleteprofile.php 63
881 -               switch($feed['item']) {
882 -                       case 'notices': default:
883 -                               $feed_classname = $feed['type'];
884 -                               $feed_mimetype = "application/".$feed['type']."+xml";
885 -                               $feed_title = "$nickname's ".$feed['version']." notice feed";
886 -                               $feed['textContent'] = "RSS";
887 -                               break;
888 +        switch($feed['item']) {
889 +            case 'notices': default:
890 +                $feed_classname = $feed['type'];
891 +                $feed_mimetype = "application/".$feed['type']."+xml";
892 +                $feed_title = "$nickname's ".$feed['version']." notice feed";
893 +                $feed['textContent'] = "RSS";
894 +                break;
895 hunk ./actions/deleteprofile.php 71
896 -                       case 'foaf':
897 -                               $feed_classname = "foaf";
898 -                               $feed_mimetype = "application/".$feed['type']."+xml";
899 -                               $feed_title = "$nickname's FOAF file";
900 -                               $feed['textContent'] = "FOAF";
901 -                               break;
902 -               }
903 -               common_element_start('li');
904 -               common_element('a', array('href' => $feed['href'],
905 -                                                                 'class' => $feed_classname,
906 -                                                                 'type' => $feed_mimetype,
907 -                                                                 'title' => $feed_title),
908 -                                                       $feed['textContent']);
909 -               common_element_end('li');
910 -       }
911 +            case 'foaf':
912 +                $feed_classname = "foaf";
913 +                $feed_mimetype = "application/".$feed['type']."+xml";
914 +                $feed_title = "$nickname's FOAF file";
915 +                $feed['textContent'] = "FOAF";
916 +                break;
917 +        }
918 +        common_element_start('li');
919 +        common_element('a', array('href' => $feed['href'],
920 +                                  'class' => $feed_classname,
921 +                                  'type' => $feed_mimetype,
922 +                                  'title' => $feed_title),
923 +                            $feed['textContent']);
924 +        common_element_end('li');
925 +    }
926 hunk ./actions/deleteprofile.php 87
927 -       function show_form($msg=NULL, $success=false) {
928 -               $this->form_header(_('Delete my account'), $msg, $success);
929 -               common_element('h2', NULL, _('Delete my account confirmation'));
930 -               $this->show_confirm_delete_form();
931 -               common_show_footer();
932 -       }
933 +    function show_form($msg=NULL, $success=false) {
934 +        $this->form_header(_('Delete my account'), $msg, $success);
935 +        common_element('h2', NULL, _('Delete my account confirmation'));
936 +        $this->show_confirm_delete_form();
937 +        common_show_footer();
938 +    }
939 hunk ./actions/deleteprofile.php 94
940 -       function show_confirm_delete_form() {
941 -               $user = common_current_user();
942 +    function show_confirm_delete_form() {
943 +        $user = common_current_user();
944 hunk ./actions/deleteprofile.php 100
945 -               common_element_start('form', array('method' => 'POST',
946 -                                                                                  'id' => 'delete',
947 -                                                                                  'action' =>
948 -                                                                                  common_local_url('deleteprofile')));
949 +        common_element_start('form', array('method' => 'POST',
950 +                                           'id' => 'delete',
951 +                                           'action' =>
952 +                                           common_local_url('deleteprofile')));
953 hunk ./actions/deleteprofile.php 105
954 -               common_hidden('token', common_session_token());
955 +        common_hidden('token', common_session_token());
956 hunk ./actions/deleteprofile.php 108
957 -               $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)),
958 -                                                                                         'type' => 'rss',
959 -                                                                                         'version' => 'RSS 1.0',
960 -                                                                                         'item' => 'notices'),
961 -                                                                        1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
962 -                                                                                         'type' => 'rdf',
963 -                                                                                         'version' => 'FOAF',
964 -                                                                                         'item' => 'foaf')));
965 +        $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)),
966 +                                              'type' => 'rss',
967 +                                              'version' => 'RSS 1.0',
968 +                                              'item' => 'notices'),
969 +                                     1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
970 +                                              'type' => 'rdf',
971 +                                              'version' => 'FOAF',
972 +                                              'item' => 'foaf')));
973 hunk ./actions/deleteprofile.php 119
974 -               common_submit('deleteaccount', _('Delete my account'));
975 -               common_element_end('form');
976 +        common_submit('deleteaccount', _('Delete my account'));
977 +        common_element_end('form');
978 hunk ./actions/deleteprofile.php 123
979 -       function handle_post() {
980 -               # CSRF protection
981 -               $token = $this->trimmed('token');
982 -               if (!$token || $token != common_session_token()) {
983 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
984 -                       return;
985 -               }
986 +    function handle_post() {
987 +        # CSRF protection
988 +        $token = $this->trimmed('token');
989 +        if (!$token || $token != common_session_token()) {
990 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
991 +            return;
992 +        }
993 hunk ./actions/deleteprofile.php 137
994 -       function delete_account() {
995 -               $user = common_current_user();
996 -               assert(!is_null($user)); # should already be checked
997 +    function delete_account() {
998 +        $user = common_current_user();
999 +        assert(!is_null($user)); # should already be checked
1000 hunk ./actions/deleteprofile.php 222
1001 -       function show_top($arr) {
1002 -               $msg = $arr[0];
1003 -               $success = $arr[1];
1004 -               if ($msg) {
1005 -                       $this->message($msg, $success);
1006 -               } else {
1007 -                       $inst = $this->get_instructions();
1008 -                       $output = common_markup_to_html($inst);
1009 -                       common_element_start('div', 'instructions');
1010 -                       common_raw($output);
1011 -                       common_element_end('div');
1012 -               }
1013 -               $this->settings_menu();
1014 -       }
1015 +    function show_top($arr) {
1016 +        $msg = $arr[0];
1017 +        $success = $arr[1];
1018 +        if ($msg) {
1019 +            $this->message($msg, $success);
1020 +        } else {
1021 +            $inst = $this->get_instructions();
1022 +            $output = common_markup_to_html($inst);
1023 +            common_element_start('div', 'instructions');
1024 +            common_raw($output);
1025 +            common_element_end('div');
1026 +        }
1027 +        $this->settings_menu();
1028 +    }
1029 hunk ./actions/deleteprofile.php 239
1030 -               $menu =
1031 -                 array('profilesettings' =>
1032 -                               array(_('Profile'),
1033 -                                         _('Change your profile settings')),
1034 -                               'emailsettings' =>
1035 -                               array(_('Email'),
1036 -                                         _('Change email handling')),
1037 -                               'openidsettings' =>
1038 -                               array(_('OpenID'),
1039 -                                         _('Add or remove OpenIDs')),
1040 -                               'smssettings' =>
1041 -                               array(_('SMS'),
1042 -                                         _('Updates by SMS')),
1043 -                               'imsettings' =>
1044 -                               array(_('IM'),
1045 -                                         _('Updates by instant messenger (IM)')),
1046 -                               'twittersettings' =>
1047 -                               array(_('Twitter'),
1048 -                                         _('Twitter integration options')),
1049 -                               'othersettings' =>
1050 -                               array(_('Other'),
1051 -                                         _('Other options')));
1052 +        $menu =
1053 +          array('profilesettings' =>
1054 +                array(_('Profile'),
1055 +                      _('Change your profile settings')),
1056 +                'emailsettings' =>
1057 +                array(_('Email'),
1058 +                      _('Change email handling')),
1059 +                'openidsettings' =>
1060 +                array(_('OpenID'),
1061 +                      _('Add or remove OpenIDs')),
1062 +                'smssettings' =>
1063 +                array(_('SMS'),
1064 +                      _('Updates by SMS')),
1065 +                'imsettings' =>
1066 +                array(_('IM'),
1067 +                      _('Updates by instant messenger (IM)')),
1068 +                'twittersettings' =>
1069 +                array(_('Twitter'),
1070 +                      _('Twitter integration options')),
1071 +                'othersettings' =>
1072 +                array(_('Other'),
1073 +                      _('Other options')));
1074 hunk ./actions/deleteprofile.php 265
1075 -                       if ($menuaction == 'imsettings' &&
1076 -                               !common_config('xmpp', 'enabled')) {
1077 -                               continue;
1078 -                       }
1079 +            if ($menuaction == 'imsettings' &&
1080 +                !common_config('xmpp', 'enabled')) {
1081 +                continue;
1082 +            }
1083 hunk ./actions/disfavor.php 24
1084 -       function handle($args) {
1085 +    function handle($args) {
1086 hunk ./actions/disfavor.php 26
1087 -               parent::handle($args);
1088 +        parent::handle($args);
1089 hunk ./actions/disfavor.php 28
1090 -               if (!common_logged_in()) {
1091 -                       common_user_error(_('Not logged in.'));
1092 -                       return;
1093 -               }
1094 +        if (!common_logged_in()) {
1095 +            common_user_error(_('Not logged in.'));
1096 +            return;
1097 +        }
1098 hunk ./actions/disfavor.php 33
1099 -               $user = common_current_user();
1100 +        $user = common_current_user();
1101 hunk ./actions/disfavor.php 35
1102 -               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
1103 -                       common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
1104 -                       return;
1105 -               }
1106 +        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
1107 +            common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
1108 +            return;
1109 +        }
1110 hunk ./actions/disfavor.php 40
1111 -               $id = $this->trimmed('notice');
1112 +        $id = $this->trimmed('notice');
1113 hunk ./actions/disfavor.php 42
1114 -               $notice = Notice::staticGet($id);
1115 +        $notice = Notice::staticGet($id);
1116 hunk ./actions/disfavor.php 44
1117 -               $token = $this->trimmed('token-'.$notice->id);
1118 +        $token = $this->trimmed('token-'.$notice->id);
1119 hunk ./actions/disfavor.php 46
1120 -               if (!$token || $token != common_session_token()) {
1121 -                       $this->client_error(_("There was a problem with your session token. Try again, please."));
1122 -                       return;
1123 -               }
1124 +        if (!$token || $token != common_session_token()) {
1125 +            $this->client_error(_("There was a problem with your session token. Try again, please."));
1126 +            return;
1127 +        }
1128 hunk ./actions/disfavor.php 51
1129 -               $fave = new Fave();
1130 -               $fave->user_id = $this->id;
1131 -               $fave->notice_id = $notice->id;
1132 -               if (!$fave->find(true)) {
1133 -                       $this->client_error(_('This notice is not a favorite!'));
1134 -                       return;
1135 -               }
1136 +        $fave = new Fave();
1137 +        $fave->user_id = $this->id;
1138 +        $fave->notice_id = $notice->id;
1139 +        if (!$fave->find(true)) {
1140 +            $this->client_error(_('This notice is not a favorite!'));
1141 +            return;
1142 +        }
1143 hunk ./actions/disfavor.php 59
1144 -               $result = $fave->delete();
1145 +        $result = $fave->delete();
1146 hunk ./actions/disfavor.php 61
1147 -               if (!$result) {
1148 -                       common_log_db_error($fave, 'DELETE', __FILE__);
1149 -                       $this->server_error(_('Could not delete favorite.'));
1150 -                       return;
1151 -               }
1152 -               
1153 -               $user->blowFavesCache();
1154 +        if (!$result) {
1155 +            common_log_db_error($fave, 'DELETE', __FILE__);
1156 +            $this->server_error(_('Could not delete favorite.'));
1157 +            return;
1158 +        }
1159 +        
1160 +        $user->blowFavesCache();
1161 hunk ./actions/disfavor.php 69
1162 -               if ($this->boolean('ajax')) {
1163 -                       common_start_html('text/xml;charset=utf-8', true);
1164 -                       common_element_start('head');
1165 -                       common_element('title', null, _('Add to favorites'));
1166 -                       common_element_end('head');
1167 -                       common_element_start('body');
1168 -                       common_favor_form($notice);
1169 -                       common_element_end('body');
1170 -                       common_element_end('html');
1171 -               } else {
1172 -                       common_redirect(common_local_url('showfavorites',
1173 -                                                                                        array('nickname' => $user->nickname)));
1174 -               }
1175 -       }
1176 +        if ($this->boolean('ajax')) {
1177 +            common_start_html('text/xml;charset=utf-8', true);
1178 +            common_element_start('head');
1179 +            common_element('title', null, _('Add to favorites'));
1180 +            common_element_end('head');
1181 +            common_element_start('body');
1182 +            common_favor_form($notice);
1183 +            common_element_end('body');
1184 +            common_element_end('html');
1185 +        } else {
1186 +            common_redirect(common_local_url('showfavorites',
1187 +                                             array('nickname' => $user->nickname)));
1188 +        }
1189 +    }
1190 hunk ./actions/doc.php 24
1191 -       function handle($args) {
1192 -               parent::handle($args);
1193 -               $title = $this->trimmed('title');
1194 -               $filename = INSTALLDIR.'/doc/'.$title;
1195 -               if (!file_exists($filename)) {
1196 -                       common_user_error(_('No such document.'));
1197 -                       return;
1198 -               }
1199 -               $c = file_get_contents($filename);
1200 -               $output = common_markup_to_html($c);
1201 -               common_show_header(_(ucfirst($title)));
1202 -               common_raw($output);
1203 -               common_show_footer();
1204 -       }
1205 +    function handle($args) {
1206 +        parent::handle($args);
1207 +        $title = $this->trimmed('title');
1208 +        $filename = INSTALLDIR.'/doc/'.$title;
1209 +        if (!file_exists($filename)) {
1210 +            common_user_error(_('No such document.'));
1211 +            return;
1212 +        }
1213 +        $c = file_get_contents($filename);
1214 +        $output = common_markup_to_html($c);
1215 +        common_show_header(_(ucfirst($title)));
1216 +        common_raw($output);
1217 +        common_show_footer();
1218 +    }
1219 hunk ./actions/emailsettings.php 26
1220 -       function get_instructions() {
1221 -               return _('Manage how you get email from %%site.name%%.');
1222 -       }
1223 +    function get_instructions() {
1224 +        return _('Manage how you get email from %%site.name%%.');
1225 +    }
1226 hunk ./actions/emailsettings.php 30
1227 -       function show_form($msg=NULL, $success=false) {
1228 -               $user = common_current_user();
1229 -               $this->form_header(_('Email Settings'), $msg, $success);
1230 -               common_element_start('form', array('method' => 'post',
1231 -                                                                                  'id' => 'emailsettings',
1232 -                                                                                  'action' =>
1233 -                                                                                  common_local_url('emailsettings')));
1234 -               common_hidden('token', common_session_token());
1235 +    function show_form($msg=NULL, $success=false) {
1236 +        $user = common_current_user();
1237 +        $this->form_header(_('Email Settings'), $msg, $success);
1238 +        common_element_start('form', array('method' => 'post',
1239 +                                           'id' => 'emailsettings',
1240 +                                           'action' =>
1241 +                                           common_local_url('emailsettings')));
1242 +        common_hidden('token', common_session_token());
1243 hunk ./actions/emailsettings.php 39
1244 -               common_element('h2', NULL, _('Address'));
1245 +        common_element('h2', NULL, _('Address'));
1246 hunk ./actions/emailsettings.php 41
1247 -               if ($user->email) {
1248 -                       common_element_start('p');
1249 -                       common_element('span', 'address confirmed', $user->email);
1250 -                       common_element('span', 'input_instructions',
1251 -                                      _('Current confirmed email address.'));
1252 -                       common_hidden('email', $user->email);
1253 -                       common_element_end('p');
1254 -                       common_submit('remove', _('Remove'));
1255 -               } else {
1256 -                       $confirm = $this->get_confirmation();
1257 -                       if ($confirm) {
1258 -                               common_element_start('p');
1259 -                               common_element('span', 'address unconfirmed', $confirm->address);
1260 -                               common_element('span', 'input_instructions',
1261 -                                                          _('Awaiting confirmation on this address. Check your inbox (and spam box!) for a message with further instructions.'));
1262 -                               common_hidden('email', $confirm->address);
1263 -                               common_element_end('p');
1264 -                               common_submit('cancel', _('Cancel'));
1265 -                       } else {
1266 -                               common_input('email', _('Email Address'),
1267 -                                                        ($this->arg('email')) ? $this->arg('email') : NULL,
1268 -                                                        _('Email address, like "UserName@example.org"'));
1269 -                               common_submit('add', _('Add'));
1270 -                       }
1271 -               }
1272 +        if ($user->email) {
1273 +            common_element_start('p');
1274 +            common_element('span', 'address confirmed', $user->email);
1275 +            common_element('span', 'input_instructions',
1276 +                           _('Current confirmed email address.'));
1277 +            common_hidden('email', $user->email);
1278 +            common_element_end('p');
1279 +            common_submit('remove', _('Remove'));
1280 +        } else {
1281 +            $confirm = $this->get_confirmation();
1282 +            if ($confirm) {
1283 +                common_element_start('p');
1284 +                common_element('span', 'address unconfirmed', $confirm->address);
1285 +                common_element('span', 'input_instructions',
1286 +                               _('Awaiting confirmation on this address. Check your inbox (and spam box!) for a message with further instructions.'));
1287 +                common_hidden('email', $confirm->address);
1288 +                common_element_end('p');
1289 +                common_submit('cancel', _('Cancel'));
1290 +            } else {
1291 +                common_input('email', _('Email Address'),
1292 +                             ($this->arg('email')) ? $this->arg('email') : NULL,
1293 +                             _('Email address, like "UserName@example.org"'));
1294 +                common_submit('add', _('Add'));
1295 +            }
1296 +        }
1297 hunk ./actions/emailsettings.php 67
1298 -               if ($user->email) {
1299 -                       common_element('h2', NULL, _('Incoming email'));
1300 -                       
1301 -                       if ($user->incomingemail) {
1302 -                               common_element_start('p');
1303 -                               common_element('span', 'address', $user->incomingemail);
1304 -                               common_element('span', 'input_instructions',
1305 -                                                          _('Send email to this address to post new notices.'));
1306 -                               common_element_end('p');
1307 -                               common_submit('removeincoming', _('Remove'));
1308 -                       }
1309 -                       
1310 -                       common_element_start('p');
1311 -                       common_element('span', 'input_instructions',
1312 -                                                  _('Make a new email address for posting to; cancels the old one.'));
1313 -                       common_element_end('p');
1314 -                       common_submit('newincoming', _('New'));
1315 -               }
1316 -               
1317 -               common_element('h2', NULL, _('Preferences'));
1318 +        if ($user->email) {
1319 +            common_element('h2', NULL, _('Incoming email'));
1320 +            
1321 +            if ($user->incomingemail) {
1322 +                common_element_start('p');
1323 +                common_element('span', 'address', $user->incomingemail);
1324 +                common_element('span', 'input_instructions',
1325 +                               _('Send email to this address to post new notices.'));
1326 +                common_element_end('p');
1327 +                common_submit('removeincoming', _('Remove'));
1328 +            }
1329 +            
1330 +            common_element_start('p');
1331 +            common_element('span', 'input_instructions',
1332 +                           _('Make a new email address for posting to; cancels the old one.'));
1333 +            common_element_end('p');
1334 +            common_submit('newincoming', _('New'));
1335 +        }
1336 +        
1337 +        common_element('h2', NULL, _('Preferences'));
1338 hunk ./actions/emailsettings.php 88
1339 -               common_checkbox('emailnotifysub',
1340 -                               _('Send me notices of new subscriptions through email.'),
1341 -                               $user->emailnotifysub);
1342 -               common_checkbox('emailnotifyfav',
1343 -                               _('Send me email when someone adds my notice as a favorite.'),
1344 -                               $user->emailnotifyfav);
1345 -               common_checkbox('emailnotifymsg',
1346 -                               _('Send me email when someone sends me a private message.'),
1347 -                               $user->emailnotifymsg);
1348 -               common_checkbox('emailnotifynudge',
1349 -                               _('Allow friends to nudge me and send me an email.'),
1350 -                               $user->emailnotifynudge);
1351 -               common_checkbox('emailpost',
1352 -                                               _('I want to post notices by email.'),
1353 -                                               $user->emailpost);
1354 -               common_checkbox('emailmicroid',
1355 -                               _('Publish a MicroID for my email address.'),
1356 -                               $user->emailmicroid);
1357 +        common_checkbox('emailnotifysub',
1358 +                        _('Send me notices of new subscriptions through email.'),
1359 +                        $user->emailnotifysub);
1360 +        common_checkbox('emailnotifyfav',
1361 +                        _('Send me email when someone adds my notice as a favorite.'),
1362 +                        $user->emailnotifyfav);
1363 +        common_checkbox('emailnotifymsg',
1364 +                        _('Send me email when someone sends me a private message.'),
1365 +                        $user->emailnotifymsg);
1366 +        common_checkbox('emailnotifynudge',
1367 +                        _('Allow friends to nudge me and send me an email.'),
1368 +                        $user->emailnotifynudge);
1369 +        common_checkbox('emailpost',
1370 +                        _('I want to post notices by email.'),
1371 +                        $user->emailpost);
1372 +        common_checkbox('emailmicroid',
1373 +                        _('Publish a MicroID for my email address.'),
1374 +                        $user->emailmicroid);
1375 hunk ./actions/emailsettings.php 107
1376 -               common_submit('save', _('Save'));
1377 -               
1378 -               common_element_end('form');
1379 -               common_show_footer();
1380 -       }
1381 +        common_submit('save', _('Save'));
1382 +        
1383 +        common_element_end('form');
1384 +        common_show_footer();
1385 +    }
1386 hunk ./actions/emailsettings.php 113
1387 -       function get_confirmation() {
1388 -               $user = common_current_user();
1389 -               $confirm = new Confirm_address();
1390 -               $confirm->user_id = $user->id;
1391 -               $confirm->address_type = 'email';
1392 -               if ($confirm->find(TRUE)) {
1393 -                       return $confirm;
1394 -               } else {
1395 -                       return NULL;
1396 -               }
1397 -       }
1398 +    function get_confirmation() {
1399 +        $user = common_current_user();
1400 +        $confirm = new Confirm_address();
1401 +        $confirm->user_id = $user->id;
1402 +        $confirm->address_type = 'email';
1403 +        if ($confirm->find(TRUE)) {
1404 +            return $confirm;
1405 +        } else {
1406 +            return NULL;
1407 +        }
1408 +    }
1409 hunk ./actions/emailsettings.php 125
1410 -       function handle_post() {
1411 +    function handle_post() {
1412 hunk ./actions/emailsettings.php 127
1413 -               # CSRF protection
1414 -               $token = $this->trimmed('token');
1415 -               if (!$token || $token != common_session_token()) {
1416 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
1417 -                       return;
1418 -               }
1419 +        # CSRF protection
1420 +        $token = $this->trimmed('token');
1421 +        if (!$token || $token != common_session_token()) {
1422 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
1423 +            return;
1424 +        }
1425 hunk ./actions/emailsettings.php 134
1426 -               if ($this->arg('save')) {
1427 -                       $this->save_preferences();
1428 -               } else if ($this->arg('add')) {
1429 -                       $this->add_address();
1430 -               } else if ($this->arg('cancel')) {
1431 -                       $this->cancel_confirmation();
1432 -               } else if ($this->arg('remove')) {
1433 -                       $this->remove_address();
1434 -               } else if ($this->arg('removeincoming')) {
1435 -                       $this->remove_incoming();
1436 -               } else if ($this->arg('newincoming')) {
1437 -                       $this->new_incoming();
1438 -               } else {
1439 -                       $this->show_form(_('Unexpected form submission.'));
1440 -               }
1441 -       }
1442 +        if ($this->arg('save')) {
1443 +            $this->save_preferences();
1444 +        } else if ($this->arg('add')) {
1445 +            $this->add_address();
1446 +        } else if ($this->arg('cancel')) {
1447 +            $this->cancel_confirmation();
1448 +        } else if ($this->arg('remove')) {
1449 +            $this->remove_address();
1450 +        } else if ($this->arg('removeincoming')) {
1451 +            $this->remove_incoming();
1452 +        } else if ($this->arg('newincoming')) {
1453 +            $this->new_incoming();
1454 +        } else {
1455 +            $this->show_form(_('Unexpected form submission.'));
1456 +        }
1457 +    }
1458 hunk ./actions/emailsettings.php 151
1459 -       function save_preferences() {
1460 +    function save_preferences() {
1461 hunk ./actions/emailsettings.php 153
1462 -               $emailnotifysub = $this->boolean('emailnotifysub');
1463 -               $emailnotifyfav = $this->boolean('emailnotifyfav');
1464 -               $emailnotifymsg = $this->boolean('emailnotifymsg');
1465 -               $emailnotifynudge = $this->boolean('emailnotifynudge');
1466 -               $emailmicroid = $this->boolean('emailmicroid');
1467 -               $emailpost = $this->boolean('emailpost');
1468 +        $emailnotifysub = $this->boolean('emailnotifysub');
1469 +        $emailnotifyfav = $this->boolean('emailnotifyfav');
1470 +        $emailnotifymsg = $this->boolean('emailnotifymsg');
1471 +        $emailnotifynudge = $this->boolean('emailnotifynudge');
1472 +        $emailmicroid = $this->boolean('emailmicroid');
1473 +        $emailpost = $this->boolean('emailpost');
1474 hunk ./actions/emailsettings.php 160
1475 -               $user = common_current_user();
1476 +        $user = common_current_user();
1477 hunk ./actions/emailsettings.php 162
1478 -               assert(!is_null($user)); # should already be checked
1479 +        assert(!is_null($user)); # should already be checked
1480 hunk ./actions/emailsettings.php 164
1481 -               $user->query('BEGIN');
1482 +        $user->query('BEGIN');
1483 hunk ./actions/emailsettings.php 166
1484 -               $original = clone($user);
1485 +        $original = clone($user);
1486 hunk ./actions/emailsettings.php 168
1487 -               $user->emailnotifysub = $emailnotifysub;
1488 -               $user->emailnotifyfav = $emailnotifyfav;
1489 -               $user->emailnotifymsg = $emailnotifymsg;
1490 -               $user->emailnotifynudge = $emailnotifynudge;
1491 -               $user->emailmicroid = $emailmicroid;
1492 -               $user->emailpost = $emailpost;
1493 +        $user->emailnotifysub = $emailnotifysub;
1494 +        $user->emailnotifyfav = $emailnotifyfav;
1495 +        $user->emailnotifymsg = $emailnotifymsg;
1496 +        $user->emailnotifynudge = $emailnotifynudge;
1497 +        $user->emailmicroid = $emailmicroid;
1498 +        $user->emailpost = $emailpost;
1499 hunk ./actions/emailsettings.php 175
1500 -               $result = $user->update($original);
1501 +        $result = $user->update($original);
1502 hunk ./actions/emailsettings.php 177
1503 -               if ($result === FALSE) {
1504 -                       common_log_db_error($user, 'UPDATE', __FILE__);
1505 -                       common_server_error(_('Couldn\'t update user.'));
1506 -                       return;
1507 -               }
1508 +        if ($result === FALSE) {
1509 +            common_log_db_error($user, 'UPDATE', __FILE__);
1510 +            common_server_error(_('Couldn\'t update user.'));
1511 +            return;
1512 +        }
1513 hunk ./actions/emailsettings.php 183
1514 -               $user->query('COMMIT');
1515 +        $user->query('COMMIT');
1516 hunk ./actions/emailsettings.php 185
1517 -               $this->show_form(_('Preferences saved.'), true);
1518 -       }
1519 +        $this->show_form(_('Preferences saved.'), true);
1520 +    }
1521 hunk ./actions/emailsettings.php 188
1522 -       function add_address() {
1523 +    function add_address() {
1524 hunk ./actions/emailsettings.php 190
1525 -               $user = common_current_user();
1526 +        $user = common_current_user();
1527 hunk ./actions/emailsettings.php 192
1528 -               $email = $this->trimmed('email');
1529 +        $email = $this->trimmed('email');
1530 hunk ./actions/emailsettings.php 194
1531 -               # Some validation
1532 +        # Some validation
1533 hunk ./actions/emailsettings.php 196
1534 -               if (!$email) {
1535 -                       $this->show_form(_('No email address.'));
1536 -                       return;
1537 -               }
1538 +        if (!$email) {
1539 +            $this->show_form(_('No email address.'));
1540 +            return;
1541 +        }
1542 hunk ./actions/emailsettings.php 201
1543 -               $email = common_canonical_email($email);
1544 +        $email = common_canonical_email($email);
1545 hunk ./actions/emailsettings.php 203
1546 -               if (!$email) {
1547 -                   $this->show_form(_('Cannot normalize that email address'));
1548 -                   return;
1549 -               }
1550 -               if (!Validate::email($email, true)) {
1551 -                   $this->show_form(_('Not a valid email address'));
1552 -                   return;
1553 -               } else if ($user->email == $email) {
1554 -                   $this->show_form(_('That is already your email address.'));
1555 -                   return;
1556 -               } else if ($this->email_exists($email)) {
1557 -                   $this->show_form(_('That email address already belongs to another user.'));
1558 -                   return;
1559 -               }
1560 +        if (!$email) {
1561 +            $this->show_form(_('Cannot normalize that email address'));
1562 +            return;
1563 +        }
1564 +        if (!Validate::email($email, true)) {
1565 +            $this->show_form(_('Not a valid email address'));
1566 +            return;
1567 +        } else if ($user->email == $email) {
1568 +            $this->show_form(_('That is already your email address.'));
1569 +            return;
1570 +        } else if ($this->email_exists($email)) {
1571 +            $this->show_form(_('That email address already belongs to another user.'));
1572 +            return;
1573 +        }
1574 hunk ./actions/emailsettings.php 218
1575 -               $confirm = new Confirm_address();
1576 -               $confirm->address = $email;
1577 -               $confirm->address_type = 'email';
1578 -               $confirm->user_id = $user->id;
1579 -               $confirm->code = common_confirmation_code(64);
1580 +          $confirm = new Confirm_address();
1581 +           $confirm->address = $email;
1582 +           $confirm->address_type = 'email';
1583 +           $confirm->user_id = $user->id;
1584 +           $confirm->code = common_confirmation_code(64);
1585 hunk ./actions/emailsettings.php 224
1586 -               $result = $confirm->insert();
1587 +        $result = $confirm->insert();
1588 hunk ./actions/emailsettings.php 226
1589 -               if ($result === FALSE) {
1590 -                       common_log_db_error($confirm, 'INSERT', __FILE__);
1591 -                       common_server_error(_('Couldn\'t insert confirmation code.'));
1592 -                       return;
1593 -               }
1594 +        if ($result === FALSE) {
1595 +            common_log_db_error($confirm, 'INSERT', __FILE__);
1596 +            common_server_error(_('Couldn\'t insert confirmation code.'));
1597 +            return;
1598 +        }
1599 hunk ./actions/emailsettings.php 232
1600 -               mail_confirm_address($user, $confirm->code, $user->nickname, $email);
1601 +        mail_confirm_address($user, $confirm->code, $user->nickname, $email);
1602 hunk ./actions/emailsettings.php 234
1603 -               $msg = _('A confirmation code was sent to the email address you added. Check your inbox (and spam box!) for the code and instructions on how to use it.');
1604 +        $msg = _('A confirmation code was sent to the email address you added. Check your inbox (and spam box!) for the code and instructions on how to use it.');
1605 hunk ./actions/emailsettings.php 236
1606 -               $this->show_form($msg, TRUE);
1607 -       }
1608 +        $this->show_form($msg, TRUE);
1609 +    }
1610 hunk ./actions/emailsettings.php 239
1611 -       function cancel_confirmation() {
1612 -               $email = $this->arg('email');
1613 -               $confirm = $this->get_confirmation();
1614 -               if (!$confirm) {
1615 -                       $this->show_form(_('No pending confirmation to cancel.'));
1616 -                       return;
1617 -               }
1618 -               if ($confirm->address != $email) {
1619 -                       $this->show_form(_('That is the wrong IM address.'));
1620 -                       return;
1621 -               }
1622 +    function cancel_confirmation() {
1623 +        $email = $this->arg('email');
1624 +        $confirm = $this->get_confirmation();
1625 +        if (!$confirm) {
1626 +            $this->show_form(_('No pending confirmation to cancel.'));
1627 +            return;
1628 +        }
1629 +        if ($confirm->address != $email) {
1630 +            $this->show_form(_('That is the wrong IM address.'));
1631 +            return;
1632 +        }
1633 hunk ./actions/emailsettings.php 254
1634 -                       common_log_db_error($confirm, 'DELETE', __FILE__);
1635 +            common_log_db_error($confirm, 'DELETE', __FILE__);
1636 hunk ./actions/emailsettings.php 260
1637 -       }
1638 +    }
1639 hunk ./actions/emailsettings.php 262
1640 -       function remove_address() {
1641 +    function remove_address() {
1642 hunk ./actions/emailsettings.php 264
1643 -               $user = common_current_user();
1644 -               $email = $this->arg('email');
1645 +        $user = common_current_user();
1646 +        $email = $this->arg('email');
1647 hunk ./actions/emailsettings.php 267
1648 -               # Maybe an old tab open...?
1649 +        # Maybe an old tab open...?
1650 hunk ./actions/emailsettings.php 269
1651 -               if ($user->email != $email) {
1652 -                   $this->show_form(_('That is not your email address.'));
1653 -                   return;
1654 -               }
1655 +        if ($user->email != $email) {
1656 +            $this->show_form(_('That is not your email address.'));
1657 +            return;
1658 +        }
1659 hunk ./actions/emailsettings.php 274
1660 -               $user->query('BEGIN');
1661 -               $original = clone($user);
1662 -               $user->email = NULL;
1663 -               $result = $user->updateKeys($original);
1664 -               if (!$result) {
1665 -                       common_log_db_error($user, 'UPDATE', __FILE__);
1666 -                       common_server_error(_('Couldn\'t update user.'));
1667 -                       return;
1668 -               }
1669 -               $user->query('COMMIT');
1670 +        $user->query('BEGIN');
1671 +        $original = clone($user);
1672 +        $user->email = NULL;
1673 +        $result = $user->updateKeys($original);
1674 +        if (!$result) {
1675 +            common_log_db_error($user, 'UPDATE', __FILE__);
1676 +            common_server_error(_('Couldn\'t update user.'));
1677 +            return;
1678 +        }
1679 +        $user->query('COMMIT');
1680 hunk ./actions/emailsettings.php 285
1681 -               $this->show_form(_('The address was removed.'), TRUE);
1682 -       }
1683 +        $this->show_form(_('The address was removed.'), TRUE);
1684 +    }
1685 hunk ./actions/emailsettings.php 288
1686 -       function remove_incoming() {
1687 -               $user = common_current_user();
1688 -               
1689 -               if (!$user->incomingemail) {
1690 -                       $this->show_form(_('No incoming email address.'));
1691 -                       return;
1692 -               }
1693 -               
1694 -               $orig = clone($user);
1695 -               $user->incomingemail = NULL;
1696 +    function remove_incoming() {
1697 +        $user = common_current_user();
1698 +        
1699 +        if (!$user->incomingemail) {
1700 +            $this->show_form(_('No incoming email address.'));
1701 +            return;
1702 +        }
1703 +        
1704 +        $orig = clone($user);
1705 +        $user->incomingemail = NULL;
1706 hunk ./actions/emailsettings.php 299
1707 -               if (!$user->updateKeys($orig)) {
1708 -                       common_log_db_error($user, 'UPDATE', __FILE__);
1709 -                       $this->server_error(_("Couldn't update user record."));
1710 -               }
1711 -               
1712 -               $this->show_form(_('Incoming email address removed.'), TRUE);
1713 -       }
1714 +        if (!$user->updateKeys($orig)) {
1715 +            common_log_db_error($user, 'UPDATE', __FILE__);
1716 +            $this->server_error(_("Couldn't update user record."));
1717 +        }
1718 +        
1719 +        $this->show_form(_('Incoming email address removed.'), TRUE);
1720 +    }
1721 hunk ./actions/emailsettings.php 307
1722 -       function new_incoming() {
1723 -               $user = common_current_user();
1724 -               
1725 -               $orig = clone($user);
1726 -               $user->incomingemail = mail_new_incoming_address();
1727 -               
1728 -               if (!$user->updateKeys($orig)) {
1729 -                       common_log_db_error($user, 'UPDATE', __FILE__);
1730 -                       $this->server_error(_("Couldn't update user record."));
1731 -               }
1732 +    function new_incoming() {
1733 +        $user = common_current_user();
1734 +        
1735 +        $orig = clone($user);
1736 +        $user->incomingemail = mail_new_incoming_address();
1737 +        
1738 +        if (!$user->updateKeys($orig)) {
1739 +            common_log_db_error($user, 'UPDATE', __FILE__);
1740 +            $this->server_error(_("Couldn't update user record."));
1741 +        }
1742 hunk ./actions/emailsettings.php 318
1743 -               $this->show_form(_('New incoming email address added.'), TRUE);
1744 -       }
1745 -       
1746 -       function email_exists($email) {
1747 -               $user = common_current_user();
1748 -               $other = User::staticGet('email', $email);
1749 -               if (!$other) {
1750 -                       return false;
1751 -               } else {
1752 -                       return $other->id != $user->id;
1753 -               }
1754 -       }
1755 +        $this->show_form(_('New incoming email address added.'), TRUE);
1756 +    }
1757 +    
1758 +    function email_exists($email) {
1759 +        $user = common_current_user();
1760 +        $other = User::staticGet('email', $email);
1761 +        if (!$other) {
1762 +            return false;
1763 +        } else {
1764 +            return $other->id != $user->id;
1765 +        }
1766 +    }
1767 hunk ./actions/facebookhome.php 13
1768 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
1769 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
1770 hunk ./actions/facebookhome.php 17
1771 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
1772 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
1773 hunk ./actions/facebookhome.php 26
1774 -       function handle($args) {
1775 -               parent::handle($args);
1776 +    function handle($args) {
1777 +        parent::handle($args);
1778 hunk ./actions/facebookhome.php 29
1779 -               $this->login();
1780 -       }
1781 +        $this->login();
1782 +    }
1783 hunk ./actions/facebookhome.php 32
1784 -       function login() {
1785 +    function login() {
1786 hunk ./actions/facebookhome.php 34
1787 -               $user = null;
1788 +        $user = null;
1789 hunk ./actions/facebookhome.php 36
1790 -               $facebook = $this->get_facebook();
1791 -               $fbuid = $facebook->require_login();
1792 +        $facebook = $this->get_facebook();
1793 +        $fbuid = $facebook->require_login();
1794 hunk ./actions/facebookhome.php 39
1795 -               # check to see whether there's already a Facebook link for this user
1796 -               $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook
1797 +        # check to see whether there's already a Facebook link for this user
1798 +        $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook
1799 hunk ./actions/facebookhome.php 42
1800 -               if ($flink) {
1801 +        if ($flink) {
1802 hunk ./actions/facebookhome.php 44
1803 -                       $user = $flink->getUser();
1804 -                       $this->show_home($facebook, $fbuid, $user);
1805 +            $user = $flink->getUser();
1806 +            $this->show_home($facebook, $fbuid, $user);
1807 hunk ./actions/facebookhome.php 47
1808 -               } else {
1809 +        } else {
1810 hunk ./actions/facebookhome.php 49
1811 -                       # Make the user put in her Laconica creds
1812 -                       $nickname = common_canonical_nickname($this->trimmed('nickname'));
1813 -                       $password = $this->arg('password');
1814 +            # Make the user put in her Laconica creds
1815 +            $nickname = common_canonical_nickname($this->trimmed('nickname'));
1816 +            $password = $this->arg('password');
1817 hunk ./actions/facebookhome.php 53
1818 -                       if ($nickname) {
1819 +            if ($nickname) {
1820 hunk ./actions/facebookhome.php 55
1821 -                               if (common_check_user($nickname, $password)) {
1822 +                if (common_check_user($nickname, $password)) {
1823 hunk ./actions/facebookhome.php 58
1824 -                                       $user = User::staticGet('nickname', $nickname);
1825 +                    $user = User::staticGet('nickname', $nickname);
1826 hunk ./actions/facebookhome.php 60
1827 -                                       if (!$user) {
1828 -                                               echo '<fb:error message="Coudln\'t get user!" />';
1829 -                                               $this->show_login_form();
1830 -                                       }
1831 +                    if (!$user) {
1832 +                        echo '<fb:error message="Coudln\'t get user!" />';
1833 +                        $this->show_login_form();
1834 +                    }
1835 hunk ./actions/facebookhome.php 65
1836 -                                       $flink = DB_DataObject::factory('foreign_link');
1837 -                                       $flink->user_id = $user->id;
1838 -                                       $flink->foreign_id = $fbuid;
1839 -                                       $flink->service = 2; # Facebook
1840 -                                       $flink->created = common_sql_now();
1841 +                    $flink = DB_DataObject::factory('foreign_link');
1842 +                    $flink->user_id = $user->id;
1843 +                    $flink->foreign_id = $fbuid;
1844 +                    $flink->service = 2; # Facebook
1845 +                    $flink->created = common_sql_now();
1846 hunk ./actions/facebookhome.php 71
1847 -                                       # $this->set_flags($flink, $noticesync, $replysync, $friendsync);
1848 +                    # $this->set_flags($flink, $noticesync, $replysync, $friendsync);
1849 hunk ./actions/facebookhome.php 73
1850 -                                       $flink_id = $flink->insert();
1851 +                    $flink_id = $flink->insert();
1852 hunk ./actions/facebookhome.php 75
1853 -                                       if ($flink_id) {
1854 -                                               echo '<fb:success message="You can now use the Identi.ca from Facebook!" />';
1855 -                                       }
1856 +                    if ($flink_id) {
1857 +                        echo '<fb:success message="You can now use the Identi.ca from Facebook!" />';
1858 +                    }
1859 hunk ./actions/facebookhome.php 79
1860 -                                       $this->show_home($facebook, $fbuid, $user);
1861 +                    $this->show_home($facebook, $fbuid, $user);
1862 hunk ./actions/facebookhome.php 81
1863 -                                       return;
1864 -                               } else {
1865 -                                       echo '<fb:error message="Incorrect username or password." />';
1866 -                               }
1867 -                       }
1868 +                    return;
1869 +                } else {
1870 +                    echo '<fb:error message="Incorrect username or password." />';
1871 +                }
1872 +            }
1873 hunk ./actions/facebookhome.php 87
1874 -                       $this->show_login_form();
1875 -               }
1876 +            $this->show_login_form();
1877 +        }
1878 hunk ./actions/facebookhome.php 90
1879 -       }
1880 +    }
1881 hunk ./actions/facebookhome.php 92
1882 -       function show_home($facebook, $fbuid, $user) {
1883 +    function show_home($facebook, $fbuid, $user) {
1884 hunk ./actions/facebookhome.php 94
1885 -               $this->show_header('Home');
1886 +        $this->show_header('Home');
1887 hunk ./actions/facebookhome.php 96
1888 -               echo $this->show_notices($user);
1889 -               $this->update_profile_box($facebook, $fbuid, $user);
1890 +        echo $this->show_notices($user);
1891 +        $this->update_profile_box($facebook, $fbuid, $user);
1892 hunk ./actions/facebookhome.php 99
1893 -               $this->show_footer();
1894 -       }
1895 +        $this->show_footer();
1896 +    }
1897 hunk ./actions/facebookhome.php 102
1898 -       function show_notices($user) {
1899 +    function show_notices($user) {
1900 hunk ./actions/facebookhome.php 104
1901 -               $page = $this->trimmed('page');
1902 -               if (!$page) {
1903 -                       $page = 1;
1904 -               }
1905 +        $page = $this->trimmed('page');
1906 +        if (!$page) {
1907 +            $page = 1;
1908 +        }
1909 hunk ./actions/facebookhome.php 109
1910 -               $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
1911 +        $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
1912 hunk ./actions/facebookhome.php 111
1913 -               echo '<ul id="notices">';
1914 +        echo '<ul id="notices">';
1915 hunk ./actions/facebookhome.php 113
1916 -               $cnt = 0;
1917 +        $cnt = 0;
1918 hunk ./actions/facebookhome.php 115
1919 -               while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
1920 -                       $cnt++;
1921 +        while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
1922 +            $cnt++;
1923 hunk ./actions/facebookhome.php 118
1924 -                       if ($cnt > NOTICES_PER_PAGE) {
1925 -                               break;
1926 -                       }
1927 +            if ($cnt > NOTICES_PER_PAGE) {
1928 +                break;
1929 +            }
1930 hunk ./actions/facebookhome.php 122
1931 -                       echo $this->render_notice($notice);
1932 -               }
1933 +            echo $this->render_notice($notice);
1934 +        }
1935 hunk ./actions/facebookhome.php 125
1936 -               echo '<ul>';
1937 +        echo '<ul>';
1938 hunk ./actions/facebookhome.php 127
1939 -               $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE,
1940 -                                                 $page, 'index.php', array('nickname' => $user->nickname));
1941 +        $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE,
1942 +                          $page, 'index.php', array('nickname' => $user->nickname));
1943 hunk ./actions/facebookhome.php 130
1944 -       }
1945 +    }
1946 hunk ./actions/facebookinvite.php 13
1947 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
1948 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
1949 hunk ./actions/facebookinvite.php 17
1950 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
1951 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
1952 hunk ./actions/facebookinvite.php 26
1953 -       function handle($args) {
1954 -               parent::handle($args);
1955 +    function handle($args) {
1956 +        parent::handle($args);
1957 hunk ./actions/facebookinvite.php 29
1958 -               $this->display();
1959 -       }
1960 +        $this->display();
1961 +    }
1962 hunk ./actions/facebookinvite.php 32
1963 -       function display() {
1964 +    function display() {
1965 hunk ./actions/facebookinvite.php 34
1966 -               $facebook = $this->get_facebook();
1967 +        $facebook = $this->get_facebook();
1968 hunk ./actions/facebookinvite.php 36
1969 -               $fbuid = $facebook->require_login();
1970 +        $fbuid = $facebook->require_login();
1971 hunk ./actions/facebookinvite.php 38
1972 -               $this->show_header('Invite');
1973 +        $this->show_header('Invite');
1974 hunk ./actions/facebookinvite.php 40
1975 -               echo '<h2>Coming soon...</h2>';
1976 +        echo '<h2>Coming soon...</h2>';
1977 hunk ./actions/facebookinvite.php 42
1978 -               $this->show_footer();
1979 +        $this->show_footer();
1980 hunk ./actions/facebookinvite.php 44
1981 -       }
1982 +    }
1983 hunk ./actions/facebookremove.php 13
1984 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
1985 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
1986 hunk ./actions/facebookremove.php 17
1987 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
1988 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
1989 hunk ./actions/facebookremove.php 26
1990 -       function handle($args) {
1991 -               parent::handle($args);
1992 +    function handle($args) {
1993 +        parent::handle($args);
1994 hunk ./actions/facebookremove.php 29
1995 -               $secret = common_config('facebook', 'secret');
1996 +        $secret = common_config('facebook', 'secret');
1997 hunk ./actions/facebookremove.php 31
1998 -               $sig = '';
1999 +        $sig = '';
2000 hunk ./actions/facebookremove.php 33
2001 -               ksort($_POST);
2002 +        ksort($_POST);
2003 hunk ./actions/facebookremove.php 35
2004 -               foreach ($_POST as $key => $val) {
2005 -                       if (substr($key, 0, 7) == 'fb_sig_') {
2006 -                               $sig .= substr($key, 7) . '=' . $val;
2007 -                       }
2008 -                }
2009 +        foreach ($_POST as $key => $val) {
2010 +            if (substr($key, 0, 7) == 'fb_sig_') {
2011 +                $sig .= substr($key, 7) . '=' . $val;
2012 +            }
2013 +         }
2014 hunk ./actions/facebookremove.php 41
2015 -               $sig .= $secret;
2016 -               $verify = md5($sig);
2017 +        $sig .= $secret;
2018 +        $verify = md5($sig);
2019 hunk ./actions/facebookremove.php 44
2020 -               if ($verify == $this->arg('fb_sig')) {
2021 +        if ($verify == $this->arg('fb_sig')) {
2022 hunk ./actions/facebookremove.php 46
2023 -                       $flink = Foreign_link::getByForeignID($this->arg('fb_sig_user'), 2);
2024 +            $flink = Foreign_link::getByForeignID($this->arg('fb_sig_user'), 2);
2025 hunk ./actions/facebookremove.php 48
2026 -                       common_debug("Removing foreign link to Facebook - local user ID: $flink->user_id, Facebook ID: $flink->foreign_id");
2027 +            common_debug("Removing foreign link to Facebook - local user ID: $flink->user_id, Facebook ID: $flink->foreign_id");
2028 hunk ./actions/facebookremove.php 50
2029 -                       $result = $flink->delete();
2030 +            $result = $flink->delete();
2031 hunk ./actions/facebookremove.php 52
2032 -                       if (!$result) {
2033 -                               common_log_db_error($flink, 'DELETE', __FILE__);
2034 -                               common_server_error(_('Couldn\'t remove Facebook user.'));
2035 -                               return;
2036 -                       }
2037 +            if (!$result) {
2038 +                common_log_db_error($flink, 'DELETE', __FILE__);
2039 +                common_server_error(_('Couldn\'t remove Facebook user.'));
2040 +                return;
2041 +            }
2042 hunk ./actions/facebookremove.php 58
2043 -               } else {
2044 -                       # Someone bad tried to remove facebook link?
2045 -                       common_log(LOG_ERR, "Someone from $_SERVER[REMOTE_ADDR] " .
2046 -                               'unsuccessfully tried to remove a foreign link to Facebook!');
2047 -               }
2048 -       }
2049 +        } else {
2050 +            # Someone bad tried to remove facebook link?
2051 +            common_log(LOG_ERR, "Someone from $_SERVER[REMOTE_ADDR] " .
2052 +                'unsuccessfully tried to remove a foreign link to Facebook!');
2053 +        }
2054 +    }
2055 hunk ./actions/facebooksettings.php 13
2056 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
2057 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
2058 hunk ./actions/facebooksettings.php 17
2059 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
2060 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
2061 hunk ./actions/facebooksettings.php 26
2062 -       function handle($args) {
2063 -               parent::handle($args);
2064 +    function handle($args) {
2065 +        parent::handle($args);
2066 hunk ./actions/facebooksettings.php 29
2067 -               $this->display();
2068 -       }
2069 +        $this->display();
2070 +    }
2071 hunk ./actions/facebooksettings.php 32
2072 -       function display() {
2073 +    function display() {
2074 hunk ./actions/facebooksettings.php 34
2075 -               $facebook = $this->get_facebook();
2076 +        $facebook = $this->get_facebook();
2077 hunk ./actions/facebooksettings.php 36
2078 -               $fbuid = $facebook->require_login();
2079 +        $fbuid = $facebook->require_login();
2080 hunk ./actions/facebooksettings.php 38
2081 -               $fbml = '<fb:if-section-not-added section="profile">'
2082 -                       .'<h2>Add an Identi.ca box to your profile!</h2>'
2083 -                       .'<fb:add-section-button section="profile"/>'
2084 -                       .'</fb:if-section-not-added>';
2085 +        $fbml = '<fb:if-section-not-added section="profile">'
2086 +            .'<h2>Add an Identi.ca box to your profile!</h2>'
2087 +            .'<fb:add-section-button section="profile"/>'
2088 +            .'</fb:if-section-not-added>';
2089 hunk ./actions/facebooksettings.php 44
2090 -               $this->show_header('Settings');
2091 +        $this->show_header('Settings');
2092 hunk ./actions/facebooksettings.php 46
2093 -               echo $fbml;
2094 +        echo $fbml;
2095 hunk ./actions/facebooksettings.php 48
2096 -               $this->show_footer();
2097 +        $this->show_footer();
2098 hunk ./actions/facebooksettings.php 50
2099 -       }
2100 +    }
2101 hunk ./actions/favor.php 26
2102 -       function handle($args) {
2103 -               parent::handle($args);
2104 +    function handle($args) {
2105 +        parent::handle($args);
2106 hunk ./actions/favor.php 29
2107 -               if (!common_logged_in()) {
2108 -                       common_user_error(_('Not logged in.'));
2109 -                       return;
2110 -               }
2111 +        if (!common_logged_in()) {
2112 +            common_user_error(_('Not logged in.'));
2113 +            return;
2114 +        }
2115 hunk ./actions/favor.php 34
2116 -               $user = common_current_user();
2117 +        $user = common_current_user();
2118 hunk ./actions/favor.php 36
2119 -               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
2120 -                       common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
2121 -                       return;
2122 -               }
2123 +        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
2124 +            common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname)));
2125 +            return;
2126 +        }
2127 hunk ./actions/favor.php 41
2128 -               $id = $this->trimmed('notice');
2129 +        $id = $this->trimmed('notice');
2130 hunk ./actions/favor.php 43
2131 -               $notice = Notice::staticGet($id);
2132 +        $notice = Notice::staticGet($id);
2133 hunk ./actions/favor.php 45
2134 -               # CSRF protection
2135 +        # CSRF protection
2136 hunk ./actions/favor.php 47
2137 -               $token = $this->trimmed('token-'.$notice->id);
2138 -               if (!$token || $token != common_session_token()) {
2139 -                       $this->client_error(_("There was a problem with your session token. Try again, please."));
2140 -                       return;
2141 -               }
2142 +        $token = $this->trimmed('token-'.$notice->id);
2143 +        if (!$token || $token != common_session_token()) {
2144 +            $this->client_error(_("There was a problem with your session token. Try again, please."));
2145 +            return;
2146 +        }
2147 hunk ./actions/favor.php 53
2148 -               if ($user->hasFave($notice)) {
2149 -                       $this->client_error(_('This notice is already a favorite!'));
2150 -                       return;
2151 -               }
2152 +        if ($user->hasFave($notice)) {
2153 +            $this->client_error(_('This notice is already a favorite!'));
2154 +            return;
2155 +        }
2156 hunk ./actions/favor.php 58
2157 -               $fave = Fave::addNew($user, $notice);
2158 +        $fave = Fave::addNew($user, $notice);
2159 hunk ./actions/favor.php 60
2160 -               if (!$fave) {
2161 -                       $this->server_error(_('Could not create favorite.'));
2162 -                       return;
2163 -               }
2164 +        if (!$fave) {
2165 +            $this->server_error(_('Could not create favorite.'));
2166 +            return;
2167 +        }
2168 hunk ./actions/favor.php 65
2169 -               $this->notify($fave, $notice, $user);
2170 -               $user->blowFavesCache();
2171 -               
2172 -               if ($this->boolean('ajax')) {
2173 -                       common_start_html('text/xml;charset=utf-8', true);
2174 -                       common_element_start('head');
2175 -                       common_element('title', null, _('Disfavor favorite'));
2176 -                       common_element_end('head');
2177 -                       common_element_start('body');
2178 -                       common_disfavor_form($notice);
2179 -                       common_element_end('body');
2180 -                       common_element_end('html');
2181 -               } else {
2182 -                       common_redirect(common_local_url('showfavorites',
2183 -                                                                                        array('nickname' => $user->nickname)));
2184 -               }
2185 -       }
2186 +        $this->notify($fave, $notice, $user);
2187 +        $user->blowFavesCache();
2188 +        
2189 +        if ($this->boolean('ajax')) {
2190 +            common_start_html('text/xml;charset=utf-8', true);
2191 +            common_element_start('head');
2192 +            common_element('title', null, _('Disfavor favorite'));
2193 +            common_element_end('head');
2194 +            common_element_start('body');
2195 +            common_disfavor_form($notice);
2196 +            common_element_end('body');
2197 +            common_element_end('html');
2198 +        } else {
2199 +            common_redirect(common_local_url('showfavorites',
2200 +                                             array('nickname' => $user->nickname)));
2201 +        }
2202 +    }
2203 hunk ./actions/favor.php 83
2204 -       function notify($fave, $notice, $user) {
2205 -           $other = User::staticGet('id', $notice->profile_id);
2206 -               if ($other && $other->id != $user->id) {
2207 -                       if ($other->email && $other->emailnotifyfav) {
2208 -                               mail_notify_fave($other, $user, $notice);
2209 -                       }
2210 -                       # XXX: notify by IM
2211 -                       # XXX: notify by SMS
2212 -               }
2213 -       }
2214 +    function notify($fave, $notice, $user) {
2215 +        $other = User::staticGet('id', $notice->profile_id);
2216 +        if ($other && $other->id != $user->id) {
2217 +            if ($other->email && $other->emailnotifyfav) {
2218 +                mail_notify_fave($other, $user, $notice);
2219 +            }
2220 +            # XXX: notify by IM
2221 +            # XXX: notify by SMS
2222 +        }
2223 +    }
2224 hunk ./actions/favorited.php 13
2225 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
2226 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
2227 hunk ./actions/favorited.php 17
2228 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
2229 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
2230 hunk ./actions/favorited.php 26
2231 -       function handle($args) {
2232 -               parent::handle($args);
2233 +    function handle($args) {
2234 +        parent::handle($args);
2235 hunk ./actions/favorited.php 29
2236 -               $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
2237 +        $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
2238 hunk ./actions/favorited.php 31
2239 -               common_show_header(_('Popular notices'),
2240 -                                                  array($this, 'show_header'), NULL,
2241 -                                                  array($this, 'show_top'));
2242 +        common_show_header(_('Popular notices'),
2243 +                           array($this, 'show_header'), NULL,
2244 +                           array($this, 'show_top'));
2245 hunk ./actions/favorited.php 35
2246 -               $this->show_notices($page);
2247 +        $this->show_notices($page);
2248 hunk ./actions/favorited.php 37
2249 -               common_show_footer();
2250 -       }
2251 +        common_show_footer();
2252 +    }
2253 hunk ./actions/favorited.php 40
2254 -       function show_top() {
2255 -               $instr = $this->get_instructions();
2256 -               $output = common_markup_to_html($instr);
2257 -               common_element_start('div', 'instructions');
2258 -               common_raw($output);
2259 -               common_element_end('div');
2260 -               $this->public_views_menu();
2261 -       }
2262 +    function show_top() {
2263 +        $instr = $this->get_instructions();
2264 +        $output = common_markup_to_html($instr);
2265 +        common_element_start('div', 'instructions');
2266 +        common_raw($output);
2267 +        common_element_end('div');
2268 +        $this->public_views_menu();
2269 +    }
2270 hunk ./actions/favorited.php 49
2271 -       function show_header() {
2272 +    function show_header() {
2273 hunk ./actions/favorited.php 51
2274 -       }
2275 +    }
2276 hunk ./actions/favorited.php 53
2277 -       function get_instructions() {
2278 -               return _('Showing recently popular notices');
2279 -       }
2280 +    function get_instructions() {
2281 +        return _('Showing recently popular notices');
2282 +    }
2283 hunk ./actions/favorited.php 57
2284 -       function show_notices($page) {
2285 +    function show_notices($page) {
2286 hunk ./actions/favorited.php 59
2287 -               $qry = 'SELECT notice.*, sum(exp(-(now() - fave.modified) / %s)) as weight ' .
2288 -                               'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
2289 -                               'GROUP BY fave.notice_id ' .
2290 -                               'ORDER BY weight DESC';
2291 +        $qry = 'SELECT notice.*, sum(exp(-(now() - fave.modified) / %s)) as weight ' .
2292 +                'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
2293 +                'GROUP BY fave.notice_id ' .
2294 +                'ORDER BY weight DESC';
2295 hunk ./actions/favorited.php 64
2296 -               $offset = ($page - 1) * NOTICES_PER_PAGE;
2297 -               $limit = NOTICES_PER_PAGE + 1;
2298 +        $offset = ($page - 1) * NOTICES_PER_PAGE;
2299 +        $limit = NOTICES_PER_PAGE + 1;
2300 hunk ./actions/favorited.php 67
2301 -               if (common_config('db','type') == 'pgsql') {
2302 -                       $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
2303 -               } else {
2304 -                       $qry .= ' LIMIT ' . $offset . ', ' . $limit;
2305 -               }
2306 +        if (common_config('db','type') == 'pgsql') {
2307 +            $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
2308 +        } else {
2309 +            $qry .= ' LIMIT ' . $offset . ', ' . $limit;
2310 +        }
2311 hunk ./actions/favorited.php 73
2312 -               # Figure out how to cache this query
2313 +        # Figure out how to cache this query
2314 hunk ./actions/favorited.php 75
2315 -               $notice = new Notice;
2316 -               $notice->query(sprintf($qry, common_config('popular', 'dropoff')));
2317 +        $notice = new Notice;
2318 +        $notice->query(sprintf($qry, common_config('popular', 'dropoff')));
2319 hunk ./actions/favorited.php 78
2320 -               common_element_start('ul', array('id' => 'notices'));
2321 +        common_element_start('ul', array('id' => 'notices'));
2322 hunk ./actions/favorited.php 80
2323 -               $cnt = 0;
2324 +        $cnt = 0;
2325 hunk ./actions/favorited.php 82
2326 -               while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
2327 -                       $cnt++;
2328 +        while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
2329 +            $cnt++;
2330 hunk ./actions/favorited.php 85
2331 -                       if ($cnt > NOTICES_PER_PAGE) {
2332 -                               break;
2333 -                       }
2334 +            if ($cnt > NOTICES_PER_PAGE) {
2335 +                break;
2336 +            }
2337 hunk ./actions/favorited.php 91
2338 -               }
2339 +        }
2340 hunk ./actions/favorited.php 93
2341 -               common_element_end('ul');
2342 +        common_element_end('ul');
2343 hunk ./actions/favorited.php 95
2344 -               common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
2345 -                                                 $page, 'favorited');
2346 -       }
2347 +        common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
2348 +                          $page, 'favorited');
2349 +    }
2350 hunk ./actions/favoritesrss.php 28
2351 -       var $user = NULL;
2352 -       
2353 -       function init() {
2354 -               $nickname = $this->trimmed('nickname');
2355 -               $this->user = User::staticGet('nickname', $nickname);
2356 +    var $user = NULL;
2357 +    
2358 +    function init() {
2359 +        $nickname = $this->trimmed('nickname');
2360 +        $this->user = User::staticGet('nickname', $nickname);
2361 hunk ./actions/favoritesrss.php 34
2362 -               if (!$this->user) {
2363 -                       common_user_error(_('No such user.'));
2364 -                       return false;
2365 -               } else {
2366 -                       return true;
2367 -               }
2368 -       }
2369 +        if (!$this->user) {
2370 +            common_user_error(_('No such user.'));
2371 +            return false;
2372 +        } else {
2373 +            return true;
2374 +        }
2375 +    }
2376 hunk ./actions/favoritesrss.php 42
2377 -       function get_notices($limit=0) {
2378 +    function get_notices($limit=0) {
2379 hunk ./actions/favoritesrss.php 44
2380 -               $user = $this->user;
2381 +        $user = $this->user;
2382 hunk ./actions/favoritesrss.php 46
2383 -               $notice = $user->favoriteNotices(0, $limit);
2384 +        $notice = $user->favoriteNotices(0, $limit);
2385 hunk ./actions/favoritesrss.php 48
2386 -               $notices = array();
2387 +        $notices = array();
2388 hunk ./actions/favoritesrss.php 50
2389 -               while ($notice->fetch()) {
2390 -                       $notices[] = clone($notice);
2391 -               }
2392 +        while ($notice->fetch()) {
2393 +            $notices[] = clone($notice);
2394 +        }
2395 hunk ./actions/favoritesrss.php 54
2396 -               return $notices;
2397 -       }
2398 +        return $notices;
2399 +    }
2400 hunk ./actions/favoritesrss.php 57
2401 -       function get_channel() {
2402 -               $user = $this->user;
2403 -               $c = array('url' => common_local_url('favoritesrss',
2404 -                                                                                        array('nickname' =>
2405 -                                                                                                  $user->nickname)),
2406 -                                  'title' => sprintf(_("%s favorite notices"), $user->nickname),
2407 -                                  'link' => common_local_url('showfavorites',
2408 -                                                                                        array('nickname' =>
2409 -                                                                                                  $user->nickname)),
2410 -                                  'description' => sprintf(_('Feed of favorite notices of %s'), $user->nickname));
2411 -               return $c;
2412 -       }
2413 +    function get_channel() {
2414 +        $user = $this->user;
2415 +        $c = array('url' => common_local_url('favoritesrss',
2416 +                                             array('nickname' =>
2417 +                                                   $user->nickname)),
2418 +                   'title' => sprintf(_("%s favorite notices"), $user->nickname),
2419 +                   'link' => common_local_url('showfavorites',
2420 +                                             array('nickname' =>
2421 +                                                   $user->nickname)),
2422 +                   'description' => sprintf(_('Feed of favorite notices of %s'), $user->nickname));
2423 +        return $c;
2424 +    }
2425 hunk ./actions/favoritesrss.php 70
2426 -       function get_image() {
2427 -               return NULL;
2428 -       }
2429 +    function get_image() {
2430 +        return NULL;
2431 +    }
2432 hunk ./actions/featured.php 13
2433 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
2434 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
2435 hunk ./actions/featured.php 17
2436 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
2437 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
2438 hunk ./actions/featured.php 27
2439 -       function handle($args) {
2440 -               parent::handle($args);
2441 +    function handle($args) {
2442 +        parent::handle($args);
2443 hunk ./actions/featured.php 30
2444 -               $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
2445 +        $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
2446 hunk ./actions/featured.php 32
2447 -               common_show_header(_('Featured users'),
2448 -                                                  array($this, 'show_header'), NULL,
2449 -                                                  array($this, 'show_top'));
2450 +        common_show_header(_('Featured users'),
2451 +                           array($this, 'show_header'), NULL,
2452 +                           array($this, 'show_top'));
2453 hunk ./actions/featured.php 36
2454 -               $this->show_notices($page);
2455 +        $this->show_notices($page);
2456 hunk ./actions/featured.php 38
2457 -               common_show_footer();
2458 -       }
2459 +        common_show_footer();
2460 +    }
2461 hunk ./actions/featured.php 41
2462 -       function show_top() {
2463 -               $instr = $this->get_instructions();
2464 -               $output = common_markup_to_html($instr);
2465 -               common_element_start('div', 'instructions');
2466 -               common_raw($output);
2467 -               common_element_end('div');
2468 -               $this->public_views_menu();
2469 -       }
2470 +    function show_top() {
2471 +        $instr = $this->get_instructions();
2472 +        $output = common_markup_to_html($instr);
2473 +        common_element_start('div', 'instructions');
2474 +        common_raw($output);
2475 +        common_element_end('div');
2476 +        $this->public_views_menu();
2477 +    }
2478 hunk ./actions/featured.php 50
2479 -       function show_header() {
2480 -       }
2481 +    function show_header() {
2482 +    }
2483 hunk ./actions/featured.php 53
2484 -       function get_instructions() {
2485 -               return _('Featured users');
2486 -       }
2487 +    function get_instructions() {
2488 +        return _('Featured users');
2489 +    }
2490 hunk ./actions/featured.php 57
2491 -       function show_notices($page) {
2492 +    function show_notices($page) {
2493 hunk ./actions/featured.php 59
2494 -               // XXX: Note I'm doing it this two-stage way because a raw query
2495 -               // with a JOIN was *not* working. --Zach
2496 +        // XXX: Note I'm doing it this two-stage way because a raw query
2497 +        // with a JOIN was *not* working. --Zach
2498 hunk ./actions/featured.php 62
2499 -               $featured_nicks = common_config('nickname', 'featured');
2500 +        $featured_nicks = common_config('nickname', 'featured');
2501 hunk ./actions/featured.php 64
2502 -               if (count($featured_nicks) > 0) {
2503 +        if (count($featured_nicks) > 0) {
2504 hunk ./actions/featured.php 66
2505 -                       $quoted = array();
2506 +            $quoted = array();
2507 hunk ./actions/featured.php 68
2508 -                       foreach ($featured_nicks as $nick) {
2509 -                               $quoted[] = "'$nick'";
2510 -                       }
2511 +            foreach ($featured_nicks as $nick) {
2512 +                $quoted[] = "'$nick'";
2513 +            }
2514 hunk ./actions/featured.php 72
2515 -                       $user = new User;
2516 -                       $user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted)));
2517 -                       $user->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
2518 -                       $user->orderBy('user.nickname ASC');
2519 +            $user = new User;
2520 +            $user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted)));
2521 +            $user->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1);
2522 +            $user->orderBy('user.nickname ASC');
2523 hunk ./actions/featured.php 77
2524 -                       $user->find();
2525 +            $user->find();
2526 hunk ./actions/featured.php 79
2527 -                       $profile_ids = array();
2528 +            $profile_ids = array();
2529 hunk ./actions/featured.php 81
2530 -                       while ($user->fetch()) {
2531 -                               $profile_ids[] = $user->id;
2532 -                       }
2533 +            while ($user->fetch()) {
2534 +                $profile_ids[] = $user->id;
2535 +            }
2536 hunk ./actions/featured.php 85
2537 -                       $profile = new Profile;
2538 -                       $profile->whereAdd(sprintf('profile.id IN (%s)', implode(',', $profile_ids)));
2539 -                       $profile->orderBy('nickname ASC');
2540 +            $profile = new Profile;
2541 +            $profile->whereAdd(sprintf('profile.id IN (%s)', implode(',', $profile_ids)));
2542 +            $profile->orderBy('nickname ASC');
2543 hunk ./actions/featured.php 89
2544 -                       $cnt = $profile->find();
2545 +            $cnt = $profile->find();
2546 hunk ./actions/featured.php 91
2547 -                       if ($cnt > 0) {
2548 -                               $featured = new ProfileList($profile);
2549 -                               $featured->show_list();
2550 -                       }
2551 +            if ($cnt > 0) {
2552 +                $featured = new ProfileList($profile);
2553 +                $featured->show_list();
2554 +            }
2555 hunk ./actions/featured.php 96
2556 -                       $profile->free();
2557 +            $profile->free();
2558 hunk ./actions/featured.php 98
2559 -                       common_pagination($page > 1, $cnt > PROFILES_PER_PAGE, $page, 'featured');
2560 -               }
2561 -       }
2562 +            common_pagination($page > 1, $cnt > PROFILES_PER_PAGE, $page, 'featured');
2563 +        }
2564 +    }
2565 hunk ./actions/finishaddopenid.php 26
2566 -       function handle($args) {
2567 -               parent::handle($args);
2568 -               if (!common_logged_in()) {
2569 -                       common_user_error(_('Not logged in.'));
2570 -               } else {
2571 -                       $this->try_login();
2572 -               }
2573 -       }
2574 -       
2575 -       function try_login() {
2576 +    function handle($args) {
2577 +        parent::handle($args);
2578 +        if (!common_logged_in()) {
2579 +            common_user_error(_('Not logged in.'));
2580 +        } else {
2581 +            $this->try_login();
2582 +        }
2583 +    }
2584 +    
2585 +    function try_login() {
2586 hunk ./actions/finishaddopenid.php 37
2587 -               $consumer =& oid_consumer();
2588 +        $consumer =& oid_consumer();
2589 hunk ./actions/finishaddopenid.php 39
2590 -               $response = $consumer->complete(common_local_url('finishaddopenid'));
2591 +        $response = $consumer->complete(common_local_url('finishaddopenid'));
2592 hunk ./actions/finishaddopenid.php 41
2593 -               if ($response->status == Auth_OpenID_CANCEL) {
2594 -                       $this->message(_('OpenID authentication cancelled.'));
2595 -                       return;
2596 -               } else if ($response->status == Auth_OpenID_FAILURE) {
2597 -                       // Authentication failed; display the error message.
2598 -                       $this->message(sprintf(_('OpenID authentication failed: %s'), $response->message));
2599 -               } else if ($response->status == Auth_OpenID_SUCCESS) {
2600 +        if ($response->status == Auth_OpenID_CANCEL) {
2601 +            $this->message(_('OpenID authentication cancelled.'));
2602 +            return;
2603 +        } else if ($response->status == Auth_OpenID_FAILURE) {
2604 +            // Authentication failed; display the error message.
2605 +            $this->message(sprintf(_('OpenID authentication failed: %s'), $response->message));
2606 +        } else if ($response->status == Auth_OpenID_SUCCESS) {
2607 hunk ./actions/finishaddopenid.php 49
2608 -                       $display = $response->getDisplayIdentifier();
2609 -                       $canonical = ($response->endpoint && $response->endpoint->canonicalID) ?
2610 -                         $response->endpoint->canonicalID : $display;
2611 +            $display = $response->getDisplayIdentifier();
2612 +            $canonical = ($response->endpoint && $response->endpoint->canonicalID) ?
2613 +              $response->endpoint->canonicalID : $display;
2614 hunk ./actions/finishaddopenid.php 53
2615 -                       $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
2616 +            $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
2617 hunk ./actions/finishaddopenid.php 55
2618 -                       if ($sreg_resp) {
2619 -                               $sreg = $sreg_resp->contents();
2620 -                       }
2621 +            if ($sreg_resp) {
2622 +                $sreg = $sreg_resp->contents();
2623 +            }
2624 hunk ./actions/finishaddopenid.php 59
2625 -                       $cur =& common_current_user();
2626 -                       $other = oid_get_user($canonical);
2627 +            $cur =& common_current_user();
2628 +            $other = oid_get_user($canonical);
2629 hunk ./actions/finishaddopenid.php 62
2630 -                       if ($other) {
2631 -                               if ($other->id == $cur->id) {
2632 -                                       $this->message(_('You already have this OpenID!'));
2633 -                               } else {
2634 -                                       $this->message(_('Someone else already has this OpenID.'));
2635 -                               }
2636 -                               return;
2637 -                       }
2638 +            if ($other) {
2639 +                if ($other->id == $cur->id) {
2640 +                    $this->message(_('You already have this OpenID!'));
2641 +                } else {
2642 +                    $this->message(_('Someone else already has this OpenID.'));
2643 +                }
2644 +                return;
2645 +            }
2646 hunk ./actions/finishaddopenid.php 71
2647 -                       # start a transaction
2648 +            # start a transaction
2649 hunk ./actions/finishaddopenid.php 73
2650 -                       $cur->query('BEGIN');
2651 +            $cur->query('BEGIN');
2652 hunk ./actions/finishaddopenid.php 75
2653 -                       $result = oid_link_user($cur->id, $canonical, $display);
2654 +            $result = oid_link_user($cur->id, $canonical, $display);
2655 hunk ./actions/finishaddopenid.php 77
2656 -                       if (!$result) {
2657 -                               $this->message(_('Error connecting user.'));
2658 -                               return;
2659 -                       }
2660 -                       if ($sreg) {
2661 -                               if (!oid_update_user($cur, $sreg)) {
2662 -                                       $this->message(_('Error updating profile'));
2663 -                                       return;
2664 -                               }
2665 -                       }
2666 +            if (!$result) {
2667 +                $this->message(_('Error connecting user.'));
2668 +                return;
2669 +            }
2670 +            if ($sreg) {
2671 +                if (!oid_update_user($cur, $sreg)) {
2672 +                    $this->message(_('Error updating profile'));
2673 +                    return;
2674 +                }
2675 +            }
2676 hunk ./actions/finishaddopenid.php 88
2677 -                       # success!
2678 +            # success!
2679 hunk ./actions/finishaddopenid.php 90
2680 -                       $cur->query('COMMIT');
2681 +            $cur->query('COMMIT');
2682 hunk ./actions/finishaddopenid.php 92
2683 -                       oid_set_last($display);
2684 +            oid_set_last($display);
2685 hunk ./actions/finishaddopenid.php 94
2686 -                       common_redirect(common_local_url('openidsettings'));
2687 -               }
2688 -       }
2689 +            common_redirect(common_local_url('openidsettings'));
2690 +        }
2691 +    }
2692 hunk ./actions/finishaddopenid.php 98
2693 -       function message($msg) {
2694 -               common_show_header(_('OpenID Login'));
2695 -               common_element('p', NULL, $msg);
2696 -               common_show_footer();
2697 -       }
2698 +    function message($msg) {
2699 +        common_show_header(_('OpenID Login'));
2700 +        common_element('p', NULL, $msg);
2701 +        common_show_footer();
2702 +    }
2703 hunk ./actions/finishimmediate.php 26
2704 -       function handle($args) {
2705 -               parent::handle($args);
2706 +    function handle($args) {
2707 +        parent::handle($args);
2708 hunk ./actions/finishimmediate.php 29
2709 -               $consumer = oid_consumer();
2710 +        $consumer = oid_consumer();
2711 hunk ./actions/finishimmediate.php 31
2712 -               $response = $consumer->complete(common_local_url('finishimmediate'));
2713 +        $response = $consumer->complete(common_local_url('finishimmediate'));
2714 hunk ./actions/finishimmediate.php 33
2715 -               if ($response->status == Auth_OpenID_SUCCESS) {
2716 -                       $display = $response->getDisplayIdentifier();
2717 -                       $canonical = ($response->endpoint->canonicalID) ?
2718 -                         $response->endpoint->canonicalID : $response->getDisplayIdentifier();
2719 +        if ($response->status == Auth_OpenID_SUCCESS) {
2720 +            $display = $response->getDisplayIdentifier();
2721 +            $canonical = ($response->endpoint->canonicalID) ?
2722 +              $response->endpoint->canonicalID : $response->getDisplayIdentifier();
2723 hunk ./actions/finishimmediate.php 38
2724 -                       $user = oid_get_user($canonical);
2725 +            $user = oid_get_user($canonical);
2726 hunk ./actions/finishimmediate.php 40
2727 -                       if ($user) {
2728 -                               oid_update_user($user, $sreg);
2729 -                               oid_set_last($display); # refresh for another year
2730 -                               common_set_user($user->nickname);
2731 -                               $this->go_backto();
2732 -                               return;
2733 -                       }
2734 -               }
2735 +            if ($user) {
2736 +                oid_update_user($user, $sreg);
2737 +                oid_set_last($display); # refresh for another year
2738 +                common_set_user($user->nickname);
2739 +                $this->go_backto();
2740 +                return;
2741 +            }
2742 +        }
2743 hunk ./actions/finishimmediate.php 49
2744 -               # Failure! Clear openid so we don't try it again
2745 +        # Failure! Clear openid so we don't try it again
2746 hunk ./actions/finishimmediate.php 51
2747 -               oid_clear_last();
2748 -               $this->go_backto();
2749 -               return;
2750 -       }
2751 +        oid_clear_last();
2752 +        $this->go_backto();
2753 +        return;
2754 +    }
2755 hunk ./actions/finishimmediate.php 56
2756 -       function go_backto() {
2757 -               common_ensure_session();
2758 -               $backto = $_SESSION['openid_immediate_backto'];
2759 -               if (!$backto) {
2760 -                       # gar. Well, push them to the public page
2761 -                       $backto = common_local_url('public');
2762 -               }
2763 -               common_redirect($backto);
2764 -       }
2765 +    function go_backto() {
2766 +        common_ensure_session();
2767 +        $backto = $_SESSION['openid_immediate_backto'];
2768 +        if (!$backto) {
2769 +            # gar. Well, push them to the public page
2770 +            $backto = common_local_url('public');
2771 +        }
2772 +        common_redirect($backto);
2773 +    }
2774 hunk ./actions/finishopenidlogin.php 26
2775 -       function handle($args) {
2776 -               parent::handle($args);
2777 -               if (common_logged_in()) {
2778 -                       common_user_error(_('Already logged in.'));
2779 -               } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2780 -                       $token = $this->trimmed('token');
2781 -                       if (!$token || $token != common_session_token()) {
2782 -                               $this->show_form(_('There was a problem with your session token. Try again, please.'));
2783 -                               return;
2784 -                       }
2785 -                       if ($this->arg('create')) {
2786 -                               if (!$this->boolean('license')) {
2787 -                                       $this->show_form(_('You can\'t register if you don\'t agree to the license.'),
2788 -                                                                        $this->trimmed('newname'));
2789 -                                       return;
2790 -                               }
2791 -                               $this->create_new_user();
2792 -                       } else if ($this->arg('connect')) {
2793 -                               $this->connect_user();
2794 -                       } else {
2795 -                               common_debug(print_r($this->args, true), __FILE__);
2796 -                               $this->show_form(_('Something weird happened.'),
2797 -                                                                $this->trimmed('newname'));
2798 -                       }
2799 -               } else {
2800 -                       $this->try_login();
2801 -               }
2802 -       }
2803 +    function handle($args) {
2804 +        parent::handle($args);
2805 +        if (common_logged_in()) {
2806 +            common_user_error(_('Already logged in.'));
2807 +        } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2808 +            $token = $this->trimmed('token');
2809 +            if (!$token || $token != common_session_token()) {
2810 +                $this->show_form(_('There was a problem with your session token. Try again, please.'));
2811 +                return;
2812 +            }
2813 +            if ($this->arg('create')) {
2814 +                if (!$this->boolean('license')) {
2815 +                    $this->show_form(_('You can\'t register if you don\'t agree to the license.'),
2816 +                                     $this->trimmed('newname'));
2817 +                    return;
2818 +                }
2819 +                $this->create_new_user();
2820 +            } else if ($this->arg('connect')) {
2821 +                $this->connect_user();
2822 +            } else {
2823 +                common_debug(print_r($this->args, true), __FILE__);
2824 +                $this->show_form(_('Something weird happened.'),
2825 +                                 $this->trimmed('newname'));
2826 +            }
2827 +        } else {
2828 +            $this->try_login();
2829 +        }
2830 +    }
2831 hunk ./actions/finishopenidlogin.php 55
2832 -       function show_top($error=NULL) {
2833 -               if ($error) {
2834 -                       common_element('div', array('class' => 'error'), $error);
2835 -               } else {
2836 -                       global $config;
2837 -                       common_element('div', 'instructions',
2838 -                                                  sprintf(_('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), $config['site']['name']));
2839 -               }
2840 -       }
2841 +    function show_top($error=NULL) {
2842 +        if ($error) {
2843 +            common_element('div', array('class' => 'error'), $error);
2844 +        } else {
2845 +            global $config;
2846 +            common_element('div', 'instructions',
2847 +                           sprintf(_('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), $config['site']['name']));
2848 +        }
2849 +    }
2850 hunk ./actions/finishopenidlogin.php 65
2851 -       function show_form($error=NULL, $username=NULL) {
2852 -               common_show_header(_('OpenID Account Setup'), NULL, $error,
2853 -                                                  array($this, 'show_top'));
2854 +    function show_form($error=NULL, $username=NULL) {
2855 +        common_show_header(_('OpenID Account Setup'), NULL, $error,
2856 +                           array($this, 'show_top'));
2857 hunk ./actions/finishopenidlogin.php 69
2858 -               common_element_start('form', array('method' => 'post',
2859 -                                                                                  'id' => 'account_connect',
2860 -                                                                                  'action' => common_local_url('finishopenidlogin')));
2861 -               common_hidden('token', common_session_token());
2862 -               common_element('h2', NULL,
2863 -                                          _('Create new account'));
2864 -               common_element('p', NULL,
2865 -                                          _('Create a new user with this nickname.'));
2866 -               common_input('newname', _('New nickname'),
2867 -                                        ($username) ? $username : '',
2868 -                                        _('1-64 lowercase letters or numbers, no punctuation or spaces'));
2869 -               common_element_start('p');
2870 -               common_element('input', array('type' => 'checkbox',
2871 -                                                                         'id' => 'license',
2872 -                                                                         'name' => 'license',
2873 -                                                                         'value' => 'true'));
2874 -               common_text(_('My text and files are available under '));
2875 -               common_element('a', array(href => common_config('license', 'url')),
2876 -                                          common_config('license', 'title'));
2877 -               common_text(_(' except this private data: password, email address, IM address, phone number.'));
2878 -               common_element_end('p');
2879 -               common_submit('create', _('Create'));
2880 -               common_element('h2', NULL,
2881 -                                          _('Connect existing account'));
2882 -               common_element('p', NULL,
2883 -                                          _('If you already have an account, login with your username and password to connect it to your OpenID.'));
2884 -               common_input('nickname', _('Existing nickname'));
2885 -               common_password('password', _('Password'));
2886 -               common_submit('connect', _('Connect'));
2887 -               common_element_end('form');
2888 -               common_show_footer();
2889 -       }
2890 +        common_element_start('form', array('method' => 'post',
2891 +                                           'id' => 'account_connect',
2892 +                                           'action' => common_local_url('finishopenidlogin')));
2893 +        common_hidden('token', common_session_token());
2894 +        common_element('h2', NULL,
2895 +                       _('Create new account'));
2896 +        common_element('p', NULL,
2897 +                       _('Create a new user with this nickname.'));
2898 +        common_input('newname', _('New nickname'),
2899 +                     ($username) ? $username : '',
2900 +                     _('1-64 lowercase letters or numbers, no punctuation or spaces'));
2901 +        common_element_start('p');
2902 +        common_element('input', array('type' => 'checkbox',
2903 +                                      'id' => 'license',
2904 +                                      'name' => 'license',
2905 +                                      'value' => 'true'));
2906 +        common_text(_('My text and files are available under '));
2907 +        common_element('a', array(href => common_config('license', 'url')),
2908 +                       common_config('license', 'title'));
2909 +        common_text(_(' except this private data: password, email address, IM address, phone number.'));
2910 +        common_element_end('p');
2911 +        common_submit('create', _('Create'));
2912 +        common_element('h2', NULL,
2913 +                       _('Connect existing account'));
2914 +        common_element('p', NULL,
2915 +                       _('If you already have an account, login with your username and password to connect it to your OpenID.'));
2916 +        common_input('nickname', _('Existing nickname'));
2917 +        common_password('password', _('Password'));
2918 +        common_submit('connect', _('Connect'));
2919 +        common_element_end('form');
2920 +        common_show_footer();
2921 +    }
2922 hunk ./actions/finishopenidlogin.php 102
2923 -       function try_login() {
2924 +    function try_login() {
2925 hunk ./actions/finishopenidlogin.php 104
2926 -               $consumer = oid_consumer();
2927 +        $consumer = oid_consumer();
2928 hunk ./actions/finishopenidlogin.php 106
2929 -               $response = $consumer->complete(common_local_url('finishopenidlogin'));
2930 +        $response = $consumer->complete(common_local_url('finishopenidlogin'));
2931 hunk ./actions/finishopenidlogin.php 108
2932 -               if ($response->status == Auth_OpenID_CANCEL) {
2933 -                       $this->message(_('OpenID authentication cancelled.'));
2934 -                       return;
2935 -               } else if ($response->status == Auth_OpenID_FAILURE) {
2936 -                       // Authentication failed; display the error message.
2937 -                       $this->message(sprintf(_('OpenID authentication failed: %s'), $response->message));
2938 -               } else if ($response->status == Auth_OpenID_SUCCESS) {
2939 -                       // This means the authentication succeeded; extract the
2940 -                       // identity URL and Simple Registration data (if it was
2941 -                       // returned).
2942 -                       $display = $response->getDisplayIdentifier();
2943 -                       $canonical = ($response->endpoint->canonicalID) ?
2944 -                         $response->endpoint->canonicalID : $response->getDisplayIdentifier();
2945 +        if ($response->status == Auth_OpenID_CANCEL) {
2946 +            $this->message(_('OpenID authentication cancelled.'));
2947 +            return;
2948 +        } else if ($response->status == Auth_OpenID_FAILURE) {
2949 +            // Authentication failed; display the error message.
2950 +            $this->message(sprintf(_('OpenID authentication failed: %s'), $response->message));
2951 +        } else if ($response->status == Auth_OpenID_SUCCESS) {
2952 +            // This means the authentication succeeded; extract the
2953 +            // identity URL and Simple Registration data (if it was
2954 +            // returned).
2955 +            $display = $response->getDisplayIdentifier();
2956 +            $canonical = ($response->endpoint->canonicalID) ?
2957 +              $response->endpoint->canonicalID : $response->getDisplayIdentifier();
2958 hunk ./actions/finishopenidlogin.php 122
2959 -                       $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
2960 +            $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
2961 hunk ./actions/finishopenidlogin.php 124
2962 -                       if ($sreg_resp) {
2963 -                               $sreg = $sreg_resp->contents();
2964 -                       }
2965 +            if ($sreg_resp) {
2966 +                $sreg = $sreg_resp->contents();
2967 +            }
2968 hunk ./actions/finishopenidlogin.php 128
2969 -                       $user = oid_get_user($canonical);
2970 +            $user = oid_get_user($canonical);
2971 hunk ./actions/finishopenidlogin.php 130
2972 -                       if ($user) {
2973 -                               oid_set_last($display);
2974 -                               # XXX: commented out at @edd's request until better
2975 -                               # control over how data flows from OpenID provider.
2976 -                               # oid_update_user($user, $sreg);
2977 -                               common_set_user($user);
2978 -                               common_real_login(true);
2979 -                               if (isset($_SESSION['openid_rememberme']) && $_SESSION['openid_rememberme']) {
2980 -                                       common_rememberme($user);
2981 -                               }
2982 +            if ($user) {
2983 +                oid_set_last($display);
2984 +                # XXX: commented out at @edd's request until better
2985 +                # control over how data flows from OpenID provider.
2986 +                # oid_update_user($user, $sreg);
2987 +                common_set_user($user);
2988 +                common_real_login(true);
2989 +                if (isset($_SESSION['openid_rememberme']) && $_SESSION['openid_rememberme']) {
2990 +                    common_rememberme($user);
2991 +                }
2992 hunk ./actions/finishopenidlogin.php 141
2993 -                               $this->go_home($user->nickname);
2994 -                       } else {
2995 -                               $this->save_values($display, $canonical, $sreg);
2996 -                               $this->show_form(NULL, $this->best_new_nickname($display, $sreg));
2997 -                       }
2998 -               }
2999 -       }
3000 +                $this->go_home($user->nickname);
3001 +            } else {
3002 +                $this->save_values($display, $canonical, $sreg);
3003 +                $this->show_form(NULL, $this->best_new_nickname($display, $sreg));
3004 +            }
3005 +        }
3006 +    }
3007 hunk ./actions/finishopenidlogin.php 149
3008 -       function message($msg) {
3009 -               common_show_header(_('OpenID Login'));
3010 -               common_element('p', NULL, $msg);
3011 -               common_show_footer();
3012 -       }
3013 +    function message($msg) {
3014 +        common_show_header(_('OpenID Login'));
3015 +        common_element('p', NULL, $msg);
3016 +        common_show_footer();
3017 +    }
3018 hunk ./actions/finishopenidlogin.php 155
3019 -       function save_values($display, $canonical, $sreg) {
3020 -               common_ensure_session();
3021 -               $_SESSION['openid_display'] = $display;
3022 -               $_SESSION['openid_canonical'] = $canonical;
3023 -               $_SESSION['openid_sreg'] = $sreg;
3024 -       }
3025 +    function save_values($display, $canonical, $sreg) {
3026 +        common_ensure_session();
3027 +        $_SESSION['openid_display'] = $display;
3028 +        $_SESSION['openid_canonical'] = $canonical;
3029 +        $_SESSION['openid_sreg'] = $sreg;
3030 +    }
3031 hunk ./actions/finishopenidlogin.php 162
3032 -       function get_saved_values() {
3033 -               return array($_SESSION['openid_display'],
3034 -                                        $_SESSION['openid_canonical'],
3035 -                                        $_SESSION['openid_sreg']);
3036 -       }
3037 +    function get_saved_values() {
3038 +        return array($_SESSION['openid_display'],
3039 +                     $_SESSION['openid_canonical'],
3040 +                     $_SESSION['openid_sreg']);
3041 +    }
3042 hunk ./actions/finishopenidlogin.php 168
3043 -       function create_new_user() {
3044 +    function create_new_user() {
3045 hunk ./actions/finishopenidlogin.php 172
3046 -               if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
3047 -                       common_user_error(_('Registration not allowed.'));
3048 +        if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
3049 +            common_user_error(_('Registration not allowed.'));
3050 hunk ./actions/finishopenidlogin.php 177
3051 -               $nickname = $this->trimmed('newname');
3052 +        $nickname = $this->trimmed('newname');
3053 hunk ./actions/finishopenidlogin.php 179
3054 -               if (!Validate::string($nickname, array('min_length' => 1,
3055 -                                                                                          'max_length' => 64,
3056 -                                                                                          'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
3057 -                       $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.'));
3058 -                       return;
3059 -               }
3060 +        if (!Validate::string($nickname, array('min_length' => 1,
3061 +                                               'max_length' => 64,
3062 +                                               'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
3063 +            $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.'));
3064 +            return;
3065 +        }
3066 hunk ./actions/finishopenidlogin.php 186
3067 -               if (!User::allowed_nickname($nickname)) {
3068 -                       $this->show_form(_('Nickname not allowed.'));
3069 -                       return;
3070 -               }
3071 +        if (!User::allowed_nickname($nickname)) {
3072 +            $this->show_form(_('Nickname not allowed.'));
3073 +            return;
3074 +        }
3075 hunk ./actions/finishopenidlogin.php 191
3076 -               if (User::staticGet('nickname', $nickname)) {
3077 -                       $this->show_form(_('Nickname already in use. Try another one.'));
3078 -                       return;
3079 -               }
3080 +        if (User::staticGet('nickname', $nickname)) {
3081 +            $this->show_form(_('Nickname already in use. Try another one.'));
3082 +            return;
3083 +        }
3084 hunk ./actions/finishopenidlogin.php 196
3085 -               list($display, $canonical, $sreg) = $this->get_saved_values();
3086 +        list($display, $canonical, $sreg) = $this->get_saved_values();
3087 hunk ./actions/finishopenidlogin.php 198
3088 -               if (!$display || !$canonical) {
3089 -                       common_server_error(_('Stored OpenID not found.'));
3090 -                       return;
3091 -               }
3092 +        if (!$display || !$canonical) {
3093 +            common_server_error(_('Stored OpenID not found.'));
3094 +            return;
3095 +        }
3096 hunk ./actions/finishopenidlogin.php 203
3097 -               # Possible race condition... let's be paranoid
3098 +        # Possible race condition... let's be paranoid
3099 hunk ./actions/finishopenidlogin.php 205
3100 -               $other = oid_get_user($canonical);
3101 +        $other = oid_get_user($canonical);
3102 hunk ./actions/finishopenidlogin.php 207
3103 -               if ($other) {
3104 -                       common_server_error(_('Creating new account for OpenID that already has a user.'));
3105 -                       return;
3106 -               }
3107 +        if ($other) {
3108 +            common_server_error(_('Creating new account for OpenID that already has a user.'));
3109 +            return;
3110 +        }
3111 hunk ./actions/finishopenidlogin.php 212
3112 -               if ($sreg['country']) {
3113 -                       if ($sreg['postcode']) {
3114 -                               # XXX: use postcode to get city and region
3115 -                               # XXX: also, store postcode somewhere -- it's valuable!
3116 -                               $location = $sreg['postcode'] . ', ' . $sreg['country'];
3117 -                       } else {
3118 -                               $location = $sreg['country'];
3119 -                       }
3120 -               }
3121 +        if ($sreg['country']) {
3122 +            if ($sreg['postcode']) {
3123 +                # XXX: use postcode to get city and region
3124 +                # XXX: also, store postcode somewhere -- it's valuable!
3125 +                $location = $sreg['postcode'] . ', ' . $sreg['country'];
3126 +            } else {
3127 +                $location = $sreg['country'];
3128 +            }
3129 +        }
3130 hunk ./actions/finishopenidlogin.php 222
3131 -               if ($sreg['fullname'] && strlen($sreg['fullname']) <= 255) {
3132 -                       $fullname = $sreg['fullname'];
3133 -               }
3134 +        if ($sreg['fullname'] && strlen($sreg['fullname']) <= 255) {
3135 +            $fullname = $sreg['fullname'];
3136 +        }
3137 hunk ./actions/finishopenidlogin.php 226
3138 -               if ($sreg['email'] && Validate::email($sreg['email'], true)) {
3139 -                       $email = $sreg['email'];
3140 -               }
3141 +        if ($sreg['email'] && Validate::email($sreg['email'], true)) {
3142 +            $email = $sreg['email'];
3143 +        }
3144 hunk ./actions/finishopenidlogin.php 230
3145 -               # XXX: add language
3146 -               # XXX: add timezone
3147 +        # XXX: add language
3148 +        # XXX: add timezone
3149 hunk ./actions/finishopenidlogin.php 233
3150 -               $user = User::register(array('nickname' => $nickname,
3151 -                                                                        'email' => $email,
3152 -                                                                        'fullname' => $fullname,
3153 -                                                                        'location' => $location));
3154 +        $user = User::register(array('nickname' => $nickname,
3155 +                                     'email' => $email,
3156 +                                     'fullname' => $fullname,
3157 +                                     'location' => $location));
3158 hunk ./actions/finishopenidlogin.php 238
3159 -               $result = oid_link_user($user->id, $canonical, $display);
3160 +        $result = oid_link_user($user->id, $canonical, $display);
3161 hunk ./actions/finishopenidlogin.php 240
3162 -               oid_set_last($display);
3163 -               common_set_user($user);
3164 -               common_real_login(true);
3165 +        oid_set_last($display);
3166 +        common_set_user($user);
3167 +        common_real_login(true);
3168 hunk ./actions/finishopenidlogin.php 244
3169 -                       common_rememberme($user);
3170 -               }
3171 +            common_rememberme($user);
3172 +        }
3173 hunk ./actions/finishopenidlogin.php 247
3174 -               common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
3175 -       }
3176 +        common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
3177 +    }
3178 hunk ./actions/finishopenidlogin.php 250
3179 -       function connect_user() {
3180 +    function connect_user() {
3181 hunk ./actions/finishopenidlogin.php 252
3182 -               $nickname = $this->trimmed('nickname');
3183 -               $password = $this->trimmed('password');
3184 +        $nickname = $this->trimmed('nickname');
3185 +        $password = $this->trimmed('password');
3186 hunk ./actions/finishopenidlogin.php 255
3187 -               if (!common_check_user($nickname, $password)) {
3188 -                       $this->show_form(_('Invalid username or password.'));
3189 -                       return;
3190 -               }
3191 +        if (!common_check_user($nickname, $password)) {
3192 +            $this->show_form(_('Invalid username or password.'));
3193 +            return;
3194 +        }
3195 hunk ./actions/finishopenidlogin.php 260
3196 -               # They're legit!
3197 +        # They're legit!
3198 hunk ./actions/finishopenidlogin.php 262
3199 -               $user = User::staticGet('nickname', $nickname);
3200 +        $user = User::staticGet('nickname', $nickname);
3201 hunk ./actions/finishopenidlogin.php 264
3202 -               list($display, $canonical, $sreg) = $this->get_saved_values();
3203 +        list($display, $canonical, $sreg) = $this->get_saved_values();
3204 hunk ./actions/finishopenidlogin.php 266
3205 -               if (!$display || !$canonical) {
3206 -                       common_server_error(_('Stored OpenID not found.'));
3207 -                       return;
3208 -               }
3209 +        if (!$display || !$canonical) {
3210 +            common_server_error(_('Stored OpenID not found.'));
3211 +            return;
3212 +        }
3213 hunk ./actions/finishopenidlogin.php 271
3214 -               $result = oid_link_user($user->id, $canonical, $display);
3215 +        $result = oid_link_user($user->id, $canonical, $display);
3216 hunk ./actions/finishopenidlogin.php 273
3217 -               if (!$result) {
3218 -                       common_server_error(_('Error connecting user to OpenID.'));
3219 -                       return;
3220 -               }
3221 +        if (!$result) {
3222 +            common_server_error(_('Error connecting user to OpenID.'));
3223 +            return;
3224 +        }
3225 hunk ./actions/finishopenidlogin.php 278
3226 -               oid_update_user($user, $sreg);
3227 -               oid_set_last($display);
3228 -               common_set_user($user);
3229 -               common_real_login(true);
3230 +        oid_update_user($user, $sreg);
3231 +        oid_set_last($display);
3232 +        common_set_user($user);
3233 +        common_real_login(true);
3234 hunk ./actions/finishopenidlogin.php 283
3235 -                       common_rememberme($user);
3236 -               }
3237 -               unset($_SESSION['openid_rememberme']);
3238 -               $this->go_home($user->nickname);
3239 -       }
3240 +            common_rememberme($user);
3241 +        }
3242 +        unset($_SESSION['openid_rememberme']);
3243 +        $this->go_home($user->nickname);
3244 +    }
3245 hunk ./actions/finishopenidlogin.php 289
3246 -       function go_home($nickname) {
3247 -               $url = common_get_returnto();
3248 -               if ($url) {
3249 -                       # We don't have to return to it again
3250 -                       common_set_returnto(NULL);
3251 -               } else {
3252 -                       $url = common_local_url('all',
3253 -                                                                       array('nickname' =>
3254 -                                                                                 $nickname));
3255 -               }
3256 -               common_redirect($url);
3257 -       }
3258 +    function go_home($nickname) {
3259 +        $url = common_get_returnto();
3260 +        if ($url) {
3261 +            # We don't have to return to it again
3262 +            common_set_returnto(NULL);
3263 +        } else {
3264 +            $url = common_local_url('all',
3265 +                                    array('nickname' =>
3266 +                                          $nickname));
3267 +        }
3268 +        common_redirect($url);
3269 +    }
3270 hunk ./actions/finishopenidlogin.php 302
3271 -       function best_new_nickname($display, $sreg) {
3272 +    function best_new_nickname($display, $sreg) {
3273 hunk ./actions/finishopenidlogin.php 304
3274 -               # Try the passed-in nickname
3275 +        # Try the passed-in nickname
3276 hunk ./actions/finishopenidlogin.php 306
3277 -               if ($sreg['nickname']) {
3278 -                       $nickname = $this->nicknamize($sreg['nickname']);
3279 -                       if ($this->is_new_nickname($nickname)) {
3280 -                               return $nickname;
3281 -                       }
3282 -               }
3283 +        if ($sreg['nickname']) {
3284 +            $nickname = $this->nicknamize($sreg['nickname']);
3285 +            if ($this->is_new_nickname($nickname)) {
3286 +                return $nickname;
3287 +            }
3288 +        }
3289 hunk ./actions/finishopenidlogin.php 313
3290 -               # Try the full name
3291 +        # Try the full name
3292 hunk ./actions/finishopenidlogin.php 315
3293 -               if ($sreg['fullname']) {
3294 -                       $fullname = $this->nicknamize($sreg['fullname']);
3295 -                       if ($this->is_new_nickname($fullname)) {
3296 -                               return $fullname;
3297 -                       }
3298 -               }
3299 +        if ($sreg['fullname']) {
3300 +            $fullname = $this->nicknamize($sreg['fullname']);
3301 +            if ($this->is_new_nickname($fullname)) {
3302 +                return $fullname;
3303 +            }
3304 +        }
3305 hunk ./actions/finishopenidlogin.php 322
3306 -               # Try the URL
3307 +        # Try the URL
3308 hunk ./actions/finishopenidlogin.php 324
3309 -               $from_url = $this->openid_to_nickname($display);
3310 +        $from_url = $this->openid_to_nickname($display);
3311 hunk ./actions/finishopenidlogin.php 326
3312 -               if ($from_url && $this->is_new_nickname($from_url)) {
3313 -                       return $from_url;
3314 -               }
3315 +        if ($from_url && $this->is_new_nickname($from_url)) {
3316 +            return $from_url;
3317 +        }
3318 hunk ./actions/finishopenidlogin.php 330
3319 -               # XXX: others?
3320 +        # XXX: others?
3321 hunk ./actions/finishopenidlogin.php 332
3322 -               return NULL;
3323 -       }
3324 +        return NULL;
3325 +    }
3326 hunk ./actions/finishopenidlogin.php 335
3327 -       function is_new_nickname($str) {
3328 -               if (!Validate::string($str, array('min_length' => 1,
3329 -                                                                                 'max_length' => 64,
3330 -                                                                                 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
3331 -                       return false;
3332 -               }
3333 -       if (!User::allowed_nickname($str)) {
3334 -                       return false;
3335 -               }
3336 -               if (User::staticGet('nickname', $str)) {
3337 -                       return false;
3338 -               }
3339 -               return true;
3340 -       }
3341 +    function is_new_nickname($str) {
3342 +        if (!Validate::string($str, array('min_length' => 1,
3343 +                                          'max_length' => 64,
3344 +                                          'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
3345 +            return false;
3346 +        }
3347 +    if (!User::allowed_nickname($str)) {
3348 +            return false;
3349 +        }
3350 +        if (User::staticGet('nickname', $str)) {
3351 +            return false;
3352 +        }
3353 +        return true;
3354 +    }
3355 hunk ./actions/finishopenidlogin.php 350
3356 -       function openid_to_nickname($openid) {
3357 +    function openid_to_nickname($openid) {
3358 hunk ./actions/finishopenidlogin.php 352
3359 -                       return $this->xri_to_nickname($openid);
3360 -               } else {
3361 -                       return $this->url_to_nickname($openid);
3362 -               }
3363 -       }
3364 +            return $this->xri_to_nickname($openid);
3365 +        } else {
3366 +            return $this->url_to_nickname($openid);
3367 +        }
3368 +    }
3369 hunk ./actions/finishopenidlogin.php 358
3370 -       # We try to use an OpenID URL as a legal Laconica user name in this order
3371 -       # 1. Plain hostname, like http://evanp.myopenid.com/
3372 -       # 2. One element in path, like http://profile.typekey.com/EvanProdromou/
3373 -       #    or http://getopenid.com/evanprodromou
3374 +    # We try to use an OpenID URL as a legal Laconica user name in this order
3375 +    # 1. Plain hostname, like http://evanp.myopenid.com/
3376 +    # 2. One element in path, like http://profile.typekey.com/EvanProdromou/
3377 +    #    or http://getopenid.com/evanprodromou
3378 hunk ./actions/finishopenidlogin.php 364
3379 -               static $bad = array('query', 'user', 'password', 'port', 'fragment');
3380 +        static $bad = array('query', 'user', 'password', 'port', 'fragment');
3381 hunk ./actions/finishopenidlogin.php 366
3382 -           $parts = parse_url($openid);
3383 +        $parts = parse_url($openid);
3384 hunk ./actions/finishopenidlogin.php 368
3385 -               # If any of these parts exist, this won't work
3386 +        # If any of these parts exist, this won't work
3387 hunk ./actions/finishopenidlogin.php 370
3388 -               foreach ($bad as $badpart) {
3389 -                       if (array_key_exists($badpart, $parts)) {
3390 -                               return NULL;
3391 -                       }
3392 -               }
3393 +        foreach ($bad as $badpart) {
3394 +            if (array_key_exists($badpart, $parts)) {
3395 +                return NULL;
3396 +            }
3397 +        }
3398 hunk ./actions/finishopenidlogin.php 376
3399 -               # We just have host and/or path
3400 +        # We just have host and/or path
3401 hunk ./actions/finishopenidlogin.php 378
3402 -               # If it's just a host...
3403 -               if (array_key_exists('host', $parts) &&
3404 -                       (!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0))
3405 -               {
3406 -                       $hostparts = explode('.', $parts['host']);
3407 +        # If it's just a host...
3408 +        if (array_key_exists('host', $parts) &&
3409 +            (!array_key_exists('path', $parts) || strcmp($parts['path'], '/') == 0))
3410 +        {
3411 +            $hostparts = explode('.', $parts['host']);
3412 hunk ./actions/finishopenidlogin.php 384
3413 -                       # Try to catch common idiom of nickname.service.tld
3414 +            # Try to catch common idiom of nickname.service.tld
3415 hunk ./actions/finishopenidlogin.php 386
3416 -                       if ((count($hostparts) > 2) &&
3417 -                               (strlen($hostparts[count($hostparts) - 2]) > 3) && # try to skip .co.uk, .com.au
3418 -                               (strcmp($hostparts[0], 'www') != 0))
3419 -                       {
3420 -                               return $this->nicknamize($hostparts[0]);
3421 -                       } else {
3422 -                               # Do the whole hostname
3423 -                               return $this->nicknamize($parts['host']);
3424 -                       }
3425 -               } else {
3426 -                       if (array_key_exists('path', $parts)) {
3427 -                               # Strip starting, ending slashes
3428 -                               $path = preg_replace('@/$@', '', $parts['path']);
3429 -                               $path = preg_replace('@^/@', '', $path);
3430 -                               if (strpos($path, '/') === false) {
3431 -                                       return $this->nicknamize($path);
3432 -                               }
3433 -                       }
3434 -               }
3435 +            if ((count($hostparts) > 2) &&
3436 +                (strlen($hostparts[count($hostparts) - 2]) > 3) && # try to skip .co.uk, .com.au
3437 +                (strcmp($hostparts[0], 'www') != 0))
3438 +            {
3439 +                return $this->nicknamize($hostparts[0]);
3440 +            } else {
3441 +                # Do the whole hostname
3442 +                return $this->nicknamize($parts['host']);
3443 +            }
3444 +        } else {
3445 +            if (array_key_exists('path', $parts)) {
3446 +                # Strip starting, ending slashes
3447 +                $path = preg_replace('@/$@', '', $parts['path']);
3448 +                $path = preg_replace('@^/@', '', $path);
3449 +                if (strpos($path, '/') === false) {
3450 +                    return $this->nicknamize($path);
3451 +                }
3452 +            }
3453 +        }
3454 hunk ./actions/finishopenidlogin.php 406
3455 -               return NULL;
3456 -       }
3457 +        return NULL;
3458 +    }
3459 hunk ./actions/finishopenidlogin.php 409
3460 -       function xri_to_nickname($xri) {
3461 -               $base = $this->xri_base($xri);
3462 +    function xri_to_nickname($xri) {
3463 +        $base = $this->xri_base($xri);
3464 hunk ./actions/finishopenidlogin.php 412
3465 -               if (!$base) {
3466 -                       return NULL;
3467 -               } else {
3468 -                       # =evan.prodromou
3469 -                       # or @gratis*evan.prodromou
3470 -                       $parts = explode('*', substr($base, 1));
3471 -                       return $this->nicknamize(array_pop($parts));
3472 -               }
3473 -       }
3474 +        if (!$base) {
3475 +            return NULL;
3476 +        } else {
3477 +            # =evan.prodromou
3478 +            # or @gratis*evan.prodromou
3479 +            $parts = explode('*', substr($base, 1));
3480 +            return $this->nicknamize(array_pop($parts));
3481 +        }
3482 +    }
3483 hunk ./actions/finishopenidlogin.php 422
3484 -       function xri_base($xri) {
3485 -               if (substr($xri, 0, 6) == 'xri://') {
3486 -                       return substr($xri, 6);
3487 -               } else {
3488 -                       return $xri;
3489 -               }
3490 -       }
3491 +    function xri_base($xri) {
3492 +        if (substr($xri, 0, 6) == 'xri://') {
3493 +            return substr($xri, 6);
3494 +        } else {
3495 +            return $xri;
3496 +        }
3497 +    }
3498 hunk ./actions/finishopenidlogin.php 430
3499 -       # Given a string, try to make it work as a nickname
3500 +    # Given a string, try to make it work as a nickname
3501 hunk ./actions/finishopenidlogin.php 432
3502 -       function nicknamize($str) {
3503 -               $str = preg_replace('/\W/', '', $str);
3504 -               return strtolower($str);
3505 -       }
3506 +    function nicknamize($str) {
3507 +        $str = preg_replace('/\W/', '', $str);
3508 +        return strtolower($str);
3509 +    }
3510 hunk ./actions/finishremotesubscribe.php 26
3511 -       function handle($args) {
3512 +    function handle($args) {
3513 hunk ./actions/finishremotesubscribe.php 28
3514 -               parent::handle($args);
3515 +        parent::handle($args);
3516 hunk ./actions/finishremotesubscribe.php 30
3517 -               if (common_logged_in()) {
3518 -                       common_user_error(_('You can use the local subscription!'));
3519 -                   return;
3520 -               }
3521 +        if (common_logged_in()) {
3522 +            common_user_error(_('You can use the local subscription!'));
3523 +            return;
3524 +        }
3525 hunk ./actions/finishremotesubscribe.php 35
3526 -               $omb = $_SESSION['oauth_authorization_request'];
3527 +        $omb = $_SESSION['oauth_authorization_request'];
3528 hunk ./actions/finishremotesubscribe.php 37
3529 -               if (!$omb) {
3530 -                       common_user_error(_('Not expecting this response!'));
3531 -                       return;
3532 -               }
3533 +        if (!$omb) {
3534 +            common_user_error(_('Not expecting this response!'));
3535 +            return;
3536 +        }
3537 hunk ./actions/finishremotesubscribe.php 42
3538 -               common_debug('stored request: '.print_r($omb,true), __FILE__);
3539 +        common_debug('stored request: '.print_r($omb,true), __FILE__);
3540 hunk ./actions/finishremotesubscribe.php 44
3541 -               common_remove_magic_from_request();
3542 -               $req = OAuthRequest::from_request();
3543 +        common_remove_magic_from_request();
3544 +        $req = OAuthRequest::from_request();
3545 hunk ./actions/finishremotesubscribe.php 47
3546 -               $token = $req->get_parameter('oauth_token');
3547 +        $token = $req->get_parameter('oauth_token');
3548 hunk ./actions/finishremotesubscribe.php 49
3549 -               # I think this is the success metric
3550 +        # I think this is the success metric
3551 hunk ./actions/finishremotesubscribe.php 51
3552 -               if ($token != $omb['token']) {
3553 -                       common_user_error(_('Not authorized.'));
3554 -                       return;
3555 -               }
3556 +        if ($token != $omb['token']) {
3557 +            common_user_error(_('Not authorized.'));
3558 +            return;
3559 +        }
3560 hunk ./actions/finishremotesubscribe.php 56
3561 -               $version = $req->get_parameter('omb_version');
3562 +        $version = $req->get_parameter('omb_version');
3563 hunk ./actions/finishremotesubscribe.php 58
3564 -               if ($version != OMB_VERSION_01) {
3565 -                       common_user_error(_('Unknown version of OMB protocol.'));
3566 -                       return;
3567 -               }
3568 +        if ($version != OMB_VERSION_01) {
3569 +            common_user_error(_('Unknown version of OMB protocol.'));
3570 +            return;
3571 +        }
3572 hunk ./actions/finishremotesubscribe.php 63
3573 -               $nickname = $req->get_parameter('omb_listener_nickname');
3574 +        $nickname = $req->get_parameter('omb_listener_nickname');
3575 hunk ./actions/finishremotesubscribe.php 65
3576 -               if (!$nickname) {
3577 -                       common_user_error(_('No nickname provided by remote server.'));
3578 -                       return;
3579 -               }
3580 +        if (!$nickname) {
3581 +            common_user_error(_('No nickname provided by remote server.'));
3582 +            return;
3583 +        }
3584 hunk ./actions/finishremotesubscribe.php 70
3585 -               $profile_url = $req->get_parameter('omb_listener_profile');
3586 +        $profile_url = $req->get_parameter('omb_listener_profile');
3587 hunk ./actions/finishremotesubscribe.php 72
3588 -               if (!$profile_url) {
3589 -                       common_user_error(_('No profile URL returned by server.'));
3590 -                       return;
3591 -               }
3592 +        if (!$profile_url) {
3593 +            common_user_error(_('No profile URL returned by server.'));
3594 +            return;
3595 +        }
3596 hunk ./actions/finishremotesubscribe.php 77
3597 -               if (!Validate::uri($profile_url, array('allowed_schemes' => array('http', 'https')))) {
3598 -                       common_user_error(_('Invalid profile URL returned by server.'));
3599 -                       return;
3600 -               }
3601 +        if (!Validate::uri($profile_url, array('allowed_schemes' => array('http', 'https')))) {
3602 +            common_user_error(_('Invalid profile URL returned by server.'));
3603 +            return;
3604 +        }
3605 hunk ./actions/finishremotesubscribe.php 82
3606 -               if ($profile_url == common_local_url('showstream', array('nickname' => $nickname))) {
3607 -                       common_user_error(_('You can use the local subscription!'));
3608 -                   return;
3609 -               }
3610 +        if ($profile_url == common_local_url('showstream', array('nickname' => $nickname))) {
3611 +            common_user_error(_('You can use the local subscription!'));
3612 +            return;
3613 +        }
3614 hunk ./actions/finishremotesubscribe.php 87
3615 -               common_debug('listenee: "'.$omb['listenee'].'"', __FILE__);
3616 +        common_debug('listenee: "'.$omb['listenee'].'"', __FILE__);
3617 hunk ./actions/finishremotesubscribe.php 89
3618 -               $user = User::staticGet('nickname', $omb['listenee']);
3619 +        $user = User::staticGet('nickname', $omb['listenee']);
3620 hunk ./actions/finishremotesubscribe.php 91
3621 -               if (!$user) {
3622 -                       common_user_error(_('User being listened to doesn\'t exist.'));
3623 -                       return;
3624 -               }
3625 +        if (!$user) {
3626 +            common_user_error(_('User being listened to doesn\'t exist.'));
3627 +            return;
3628 +        }
3629 hunk ./actions/finishremotesubscribe.php 96
3630 -               $other = User::staticGet('uri', $omb['listener']);
3631 +        $other = User::staticGet('uri', $omb['listener']);
3632 hunk ./actions/finishremotesubscribe.php 98
3633 -               if ($other) {
3634 -                       common_user_error(_('You can use the local subscription!'));
3635 -                       return;
3636 -               }
3637 +        if ($other) {
3638 +            common_user_error(_('You can use the local subscription!'));
3639 +            return;
3640 +        }
3641 hunk ./actions/finishremotesubscribe.php 103
3642 -               $fullname = $req->get_parameter('omb_listener_fullname');
3643 -               $homepage = $req->get_parameter('omb_listener_homepage');
3644 -               $bio = $req->get_parameter('omb_listener_bio');
3645 -               $location = $req->get_parameter('omb_listener_location');
3646 -               $avatar_url = $req->get_parameter('omb_listener_avatar');
3647 +        $fullname = $req->get_parameter('omb_listener_fullname');
3648 +        $homepage = $req->get_parameter('omb_listener_homepage');
3649 +        $bio = $req->get_parameter('omb_listener_bio');
3650 +        $location = $req->get_parameter('omb_listener_location');
3651 +        $avatar_url = $req->get_parameter('omb_listener_avatar');
3652 hunk ./actions/finishremotesubscribe.php 109
3653 -               list($newtok, $newsecret) = $this->access_token($omb);
3654 +        list($newtok, $newsecret) = $this->access_token($omb);
3655 hunk ./actions/finishremotesubscribe.php 111
3656 -               if (!$newtok || !$newsecret) {
3657 -                       common_user_error(_('Couldn\'t convert request tokens to access tokens.'));
3658 -                       return;
3659 -               }
3660 +        if (!$newtok || !$newsecret) {
3661 +            common_user_error(_('Couldn\'t convert request tokens to access tokens.'));
3662 +            return;
3663 +        }
3664 hunk ./actions/finishremotesubscribe.php 116
3665 -               # XXX: possible attack point; subscribe and return someone else's profile URI
3666 +        # XXX: possible attack point; subscribe and return someone else's profile URI
3667 hunk ./actions/finishremotesubscribe.php 118
3668 -               $remote = Remote_profile::staticGet('uri', $omb['listener']);
3669 +        $remote = Remote_profile::staticGet('uri', $omb['listener']);
3670 hunk ./actions/finishremotesubscribe.php 120
3671 -               if ($remote) {
3672 -                       $exists = true;
3673 -                       $profile = Profile::staticGet($remote->id);
3674 -                       $orig_remote = clone($remote);
3675 -                       $orig_profile = clone($profile);
3676 -                       # XXX: compare current postNotice and updateProfile URLs to the ones
3677 -                       # stored in the DB to avoid (possibly...) above attack
3678 -               } else {
3679 -                       $exists = false;
3680 -                       $remote = new Remote_profile();
3681 -                       $remote->uri = $omb['listener'];
3682 -                       $profile = new Profile();
3683 -               }
3684 +        if ($remote) {
3685 +            $exists = true;
3686 +            $profile = Profile::staticGet($remote->id);
3687 +            $orig_remote = clone($remote);
3688 +            $orig_profile = clone($profile);
3689 +            # XXX: compare current postNotice and updateProfile URLs to the ones
3690 +            # stored in the DB to avoid (possibly...) above attack
3691 +        } else {
3692 +            $exists = false;
3693 +            $remote = new Remote_profile();
3694 +            $remote->uri = $omb['listener'];
3695 +            $profile = new Profile();
3696 +        }
3697 hunk ./actions/finishremotesubscribe.php 134
3698 -               $profile->nickname = $nickname;
3699 -               $profile->profileurl = $profile_url;
3700 +        $profile->nickname = $nickname;
3701 +        $profile->profileurl = $profile_url;
3702 hunk ./actions/finishremotesubscribe.php 137
3703 -               if ($fullname) {
3704 -                       $profile->fullname = $fullname;
3705 -               }
3706 -               if ($homepage) {
3707 -                       $profile->homepage = $homepage;
3708 -               }
3709 -               if ($bio) {
3710 -                       $profile->bio = $bio;
3711 -               }
3712 -               if ($location) {
3713 -                       $profile->location = $location;
3714 -               }
3715 +        if ($fullname) {
3716 +            $profile->fullname = $fullname;
3717 +        }
3718 +        if ($homepage) {
3719 +            $profile->homepage = $homepage;
3720 +        }
3721 +        if ($bio) {
3722 +            $profile->bio = $bio;
3723 +        }
3724 +        if ($location) {
3725 +            $profile->location = $location;
3726 +        }
3727 hunk ./actions/finishremotesubscribe.php 150
3728 -               if ($exists) {
3729 -                       $profile->update($orig_profile);
3730 -               } else {
3731 -                       $profile->created = DB_DataObject_Cast::dateTime(); # current time
3732 -                       $id = $profile->insert();
3733 -                       if (!$id) {
3734 -                               common_server_error(_('Error inserting new profile'));
3735 -                               return;
3736 -                       }
3737 -                       $remote->id = $id;
3738 -               }
3739 +        if ($exists) {
3740 +            $profile->update($orig_profile);
3741 +        } else {
3742 +            $profile->created = DB_DataObject_Cast::dateTime(); # current time
3743 +            $id = $profile->insert();
3744 +            if (!$id) {
3745 +                common_server_error(_('Error inserting new profile'));
3746 +                return;
3747 +            }
3748 +            $remote->id = $id;
3749 +        }
3750 hunk ./actions/finishremotesubscribe.php 162
3751 -               if ($avatar_url) {
3752 -                       if (!$this->add_avatar($profile, $avatar_url)) {
3753 -                               common_server_error(_('Error inserting avatar'));
3754 -                               return;
3755 -                       }
3756 -               }
3757 +        if ($avatar_url) {
3758 +            if (!$this->add_avatar($profile, $avatar_url)) {
3759 +                common_server_error(_('Error inserting avatar'));
3760 +                return;
3761 +            }
3762 +        }
3763 hunk ./actions/finishremotesubscribe.php 169
3764 -               $remote->postnoticeurl = $omb['post_notice_url'];
3765 -               $remote->updateprofileurl = $omb['update_profile_url'];
3766 +        $remote->postnoticeurl = $omb['post_notice_url'];
3767 +        $remote->updateprofileurl = $omb['update_profile_url'];
3768 hunk ./actions/finishremotesubscribe.php 172
3769 -               if ($exists) {
3770 -                       if (!$remote->update($orig_remote)) {
3771 -                               common_server_error(_('Error updating remote profile'));
3772 -                               return;
3773 -                       }
3774 -               } else {
3775 -                       $remote->created = DB_DataObject_Cast::dateTime(); # current time
3776 -                       if (!$remote->insert()) {
3777 -                               common_server_error(_('Error inserting remote profile'));
3778 -                               return;
3779 -                       }
3780 -               }
3781 +        if ($exists) {
3782 +            if (!$remote->update($orig_remote)) {
3783 +                common_server_error(_('Error updating remote profile'));
3784 +                return;
3785 +            }
3786 +        } else {
3787 +            $remote->created = DB_DataObject_Cast::dateTime(); # current time
3788 +            if (!$remote->insert()) {
3789 +                common_server_error(_('Error inserting remote profile'));
3790 +                return;
3791 +            }
3792 +        }
3793 hunk ./actions/finishremotesubscribe.php 190
3794 -               $sub = new Subscription();
3795 +        $sub = new Subscription();
3796 hunk ./actions/finishremotesubscribe.php 192
3797 -               $sub->subscriber = $remote->id;
3798 -               $sub->subscribed = $user->id;
3799 +        $sub->subscriber = $remote->id;
3800 +        $sub->subscribed = $user->id;
3801 hunk ./actions/finishremotesubscribe.php 205
3802 -               $sub->token = $newtok;
3803 -               $sub->secret = $newsecret;
3804 +        $sub->token = $newtok;
3805 +        $sub->secret = $newsecret;
3806 hunk ./actions/finishremotesubscribe.php 214
3807 -               if (!$result) {
3808 +        if (!$result) {
3809 hunk ./actions/finishremotesubscribe.php 216
3810 -                       common_user_error(_('Couldn\'t insert new subscription.'));
3811 -                       return;
3812 -               }
3813 +            common_user_error(_('Couldn\'t insert new subscription.'));
3814 +            return;
3815 +        }
3816 hunk ./actions/finishremotesubscribe.php 220
3817 -               # Notify user, if necessary
3818 +        # Notify user, if necessary
3819 hunk ./actions/finishremotesubscribe.php 222
3820 -               mail_subscribe_notify_profile($user, $profile);
3821 +        mail_subscribe_notify_profile($user, $profile);
3822 hunk ./actions/finishremotesubscribe.php 224
3823 -               # Clear the data
3824 -               unset($_SESSION['oauth_authorization_request']);
3825 +        # Clear the data
3826 +        unset($_SESSION['oauth_authorization_request']);
3827 hunk ./actions/finishremotesubscribe.php 227
3828 -               # If we show subscriptions in reverse chron order, this should
3829 -               # show up close to the top of the page
3830 +        # If we show subscriptions in reverse chron order, this should
3831 +        # show up close to the top of the page
3832 hunk ./actions/finishremotesubscribe.php 230
3833 -               common_redirect(common_local_url('subscribers', array('nickname' =>
3834 -                                                                                                                        $user->nickname)));
3835 -       }
3836 +        common_redirect(common_local_url('subscribers', array('nickname' =>
3837 +                                                             $user->nickname)));
3838 +    }
3839 hunk ./actions/finishremotesubscribe.php 234
3840 -       function add_avatar($profile, $url) {
3841 -               $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
3842 -               copy($url, $temp_filename);
3843 -               return $profile->setOriginal($temp_filename);
3844 -       }
3845 +    function add_avatar($profile, $url) {
3846 +        $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
3847 +        copy($url, $temp_filename);
3848 +        return $profile->setOriginal($temp_filename);
3849 +    }
3850 hunk ./actions/finishremotesubscribe.php 240
3851 -       function access_token($omb) {
3852 +    function access_token($omb) {
3853 hunk ./actions/finishremotesubscribe.php 242
3854 -               common_debug('starting request for access token', __FILE__);
3855 +        common_debug('starting request for access token', __FILE__);
3856 hunk ./actions/finishremotesubscribe.php 244
3857 -               $con = omb_oauth_consumer();
3858 -               $tok = new OAuthToken($omb['token'], $omb['secret']);
3859 +        $con = omb_oauth_consumer();
3860 +        $tok = new OAuthToken($omb['token'], $omb['secret']);
3861 hunk ./actions/finishremotesubscribe.php 247
3862 -               common_debug('using request token "'.$tok.'"', __FILE__);
3863 +        common_debug('using request token "'.$tok.'"', __FILE__);
3864 hunk ./actions/finishremotesubscribe.php 249
3865 -               $url = $omb['access_token_url'];
3866 +        $url = $omb['access_token_url'];
3867 hunk ./actions/finishremotesubscribe.php 251
3868 -               common_debug('using access token url "'.$url.'"', __FILE__);
3869 +        common_debug('using access token url "'.$url.'"', __FILE__);
3870 hunk ./actions/finishremotesubscribe.php 253
3871 -               # XXX: Is this the right thing to do? Strip off GET params and make them
3872 -               # POST params? Seems wrong to me.
3873 +        # XXX: Is this the right thing to do? Strip off GET params and make them
3874 +        # POST params? Seems wrong to me.
3875 hunk ./actions/finishremotesubscribe.php 256
3876 -               $parsed = parse_url($url);
3877 -               $params = array();
3878 -               parse_str($parsed['query'], $params);
3879 +        $parsed = parse_url($url);
3880 +        $params = array();
3881 +        parse_str($parsed['query'], $params);
3882 hunk ./actions/finishremotesubscribe.php 260
3883 -               $req = OAuthRequest::from_consumer_and_token($con, $tok, "POST", $url, $params);
3884 +        $req = OAuthRequest::from_consumer_and_token($con, $tok, "POST", $url, $params);
3885 hunk ./actions/finishremotesubscribe.php 262
3886 -               $req->set_parameter('omb_version', OMB_VERSION_01);
3887 +        $req->set_parameter('omb_version', OMB_VERSION_01);
3888 hunk ./actions/finishremotesubscribe.php 264
3889 -               # XXX: test to see if endpoint accepts this signature method
3890 +        # XXX: test to see if endpoint accepts this signature method
3891 hunk ./actions/finishremotesubscribe.php 266
3892 -               $req->sign_request(omb_hmac_sha1(), $con, $tok);
3893 +        $req->sign_request(omb_hmac_sha1(), $con, $tok);
3894 hunk ./actions/finishremotesubscribe.php 268
3895 -               # We re-use this tool's fetcher, since it's pretty good
3896 +        # We re-use this tool's fetcher, since it's pretty good
3897 hunk ./actions/finishremotesubscribe.php 270
3898 -               common_debug('posting to access token url "'.$req->get_normalized_http_url().'"', __FILE__);
3899 -               common_debug('posting request data "'.$req->to_postdata().'"', __FILE__);
3900 +        common_debug('posting to access token url "'.$req->get_normalized_http_url().'"', __FILE__);
3901 +        common_debug('posting request data "'.$req->to_postdata().'"', __FILE__);
3902 hunk ./actions/finishremotesubscribe.php 273
3903 -               $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
3904 -               $result = $fetcher->post($req->get_normalized_http_url(),
3905 -                                                                $req->to_postdata(),
3906 +        $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
3907 +        $result = $fetcher->post($req->get_normalized_http_url(),
3908 +                                 $req->to_postdata(),
3909 hunk ./actions/finishremotesubscribe.php 278
3910 -               common_debug('got result: "'.print_r($result,TRUE).'"', __FILE__);
3911 +        common_debug('got result: "'.print_r($result,TRUE).'"', __FILE__);
3912 hunk ./actions/finishremotesubscribe.php 280
3913 -               if ($result->status != 200) {
3914 -                       return NULL;
3915 -               }
3916 +        if ($result->status != 200) {
3917 +            return NULL;
3918 +        }
3919 hunk ./actions/finishremotesubscribe.php 284
3920 -               parse_str($result->body, $return);
3921 +        parse_str($result->body, $return);
3922 hunk ./actions/finishremotesubscribe.php 286
3923 -               return array($return['oauth_token'], $return['oauth_token_secret']);
3924 -       }
3925 +        return array($return['oauth_token'], $return['oauth_token_secret']);
3926 +    }
3927 hunk ./actions/foaf.php 28
3928 -       function is_readonly() {
3929 -               return true;
3930 -       }
3931 +    function is_readonly() {
3932 +        return true;
3933 +    }
3934 hunk ./actions/foaf.php 32
3935 -       function handle($args) {
3936 -               parent::handle($args);
3937 +    function handle($args) {
3938 +        parent::handle($args);
3939 hunk ./actions/foaf.php 35
3940 -               $nickname = $this->trimmed('nickname');
3941 +        $nickname = $this->trimmed('nickname');
3942 hunk ./actions/foaf.php 37
3943 -               $user = User::staticGet('nickname', $nickname);
3944 +        $user = User::staticGet('nickname', $nickname);
3945 hunk ./actions/foaf.php 39
3946 -               if (!$user) {
3947 -                       common_user_error(_('No such user.'), 404);
3948 -                       return;
3949 -               }
3950 +        if (!$user) {
3951 +            common_user_error(_('No such user.'), 404);
3952 +            return;
3953 +        }
3954 hunk ./actions/foaf.php 44
3955 -               $profile = $user->getProfile();
3956 +        $profile = $user->getProfile();
3957 hunk ./actions/foaf.php 46
3958 -               if (!$profile) {
3959 -                       common_server_error(_('User has no profile.'), 500);
3960 -                       return;
3961 -               }
3962 +        if (!$profile) {
3963 +            common_server_error(_('User has no profile.'), 500);
3964 +            return;
3965 +        }
3966 hunk ./actions/foaf.php 51
3967 -               header('Content-Type: application/rdf+xml');
3968 +        header('Content-Type: application/rdf+xml');
3969 hunk ./actions/foaf.php 53
3970 -               common_start_xml();
3971 -               common_element_start('rdf:RDF', array('xmlns:rdf' =>
3972 -                                                                                         'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
3973 -                                                                                         'xmlns:rdfs' =>
3974 -                                                                                         'http://www.w3.org/2000/01/rdf-schema#',
3975 -                                                                                         'xmlns:geo' =>
3976 -                                                                                         'http://www.w3.org/2003/01/geo/wgs84_pos#',
3977 -                                                                                         'xmlns' => 'http://xmlns.com/foaf/0.1/'));
3978 +        common_start_xml();
3979 +        common_element_start('rdf:RDF', array('xmlns:rdf' =>
3980 +                                              'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
3981 +                                              'xmlns:rdfs' =>
3982 +                                              'http://www.w3.org/2000/01/rdf-schema#',
3983 +                                              'xmlns:geo' =>
3984 +                                              'http://www.w3.org/2003/01/geo/wgs84_pos#',
3985 +                                              'xmlns' => 'http://xmlns.com/foaf/0.1/'));
3986 hunk ./actions/foaf.php 62
3987 -               # This is the document about the user
3988 +        # This is the document about the user
3989 hunk ./actions/foaf.php 64
3990 -               $this->show_ppd('', $user->uri);
3991 +        $this->show_ppd('', $user->uri);
3992 hunk ./actions/foaf.php 66
3993 -               # XXX: might not be a person
3994 -               common_element_start('Person', array('rdf:about' =>
3995 -                                                                                        $user->uri));
3996 -               common_element('mbox_sha1sum', NULL, sha1('mailto:' . $user->email));
3997 -               if ($profile->fullname) {
3998 -                       common_element('name', NULL, $profile->fullname);
3999 -               }
4000 -               if ($profile->homepage) {
4001 -                       common_element('homepage', array('rdf:resource' => $profile->homepage));
4002 -               }
4003 -               if ($profile->bio) {
4004 -                       common_element('rdfs:comment', NULL, $profile->bio);
4005 -               }
4006 -               # XXX: more structured location data
4007 -               if ($profile->location) {
4008 -                       common_element_start('based_near');
4009 -                       common_element_start('geo:SpatialThing');
4010 -                       common_element('name', NULL, $profile->location);
4011 -                       common_element_end('geo:SpatialThing');
4012 -                       common_element_end('based_near');
4013 -               }
4014 +        # XXX: might not be a person
4015 +        common_element_start('Person', array('rdf:about' =>
4016 +                                             $user->uri));
4017 +        common_element('mbox_sha1sum', NULL, sha1('mailto:' . $user->email));
4018 +        if ($profile->fullname) {
4019 +            common_element('name', NULL, $profile->fullname);
4020 +        }
4021 +        if ($profile->homepage) {
4022 +            common_element('homepage', array('rdf:resource' => $profile->homepage));
4023 +        }
4024 +        if ($profile->bio) {
4025 +            common_element('rdfs:comment', NULL, $profile->bio);
4026 +        }
4027 +        # XXX: more structured location data
4028 +        if ($profile->location) {
4029 +            common_element_start('based_near');
4030 +            common_element_start('geo:SpatialThing');
4031 +            common_element('name', NULL, $profile->location);
4032 +            common_element_end('geo:SpatialThing');
4033 +            common_element_end('based_near');
4034 +        }
4035 hunk ./actions/foaf.php 88
4036 -               $this->show_microblogging_account($profile, common_root_url());
4037 +        $this->show_microblogging_account($profile, common_root_url());
4038 hunk ./actions/foaf.php 90
4039 -               $avatar = $profile->getOriginalAvatar();
4040 +        $avatar = $profile->getOriginalAvatar();
4041 hunk ./actions/foaf.php 92
4042 -               if ($avatar) {
4043 -                       common_element_start('img');
4044 -                       common_element_start('Image', array('rdf:about' => $avatar->url));
4045 -                       foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
4046 -                               $scaled = $profile->getAvatar($size);
4047 -                               if (!$scaled->original) { # sometimes the original has one of our scaled sizes
4048 -                                       common_element_start('thumbnail');
4049 -                                       common_element('Image', array('rdf:about' => $scaled->url));
4050 -                                       common_element_end('thumbnail');
4051 -                               }
4052 -                       }
4053 -                       common_element_end('Image');
4054 -                       common_element_end('img');
4055 -               }
4056 +        if ($avatar) {
4057 +            common_element_start('img');
4058 +            common_element_start('Image', array('rdf:about' => $avatar->url));
4059 +            foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
4060 +                $scaled = $profile->getAvatar($size);
4061 +                if (!$scaled->original) { # sometimes the original has one of our scaled sizes
4062 +                    common_element_start('thumbnail');
4063 +                    common_element('Image', array('rdf:about' => $scaled->url));
4064 +                    common_element_end('thumbnail');
4065 +                }
4066 +            }
4067 +            common_element_end('Image');
4068 +            common_element_end('img');
4069 +        }
4070 hunk ./actions/foaf.php 107
4071 -               # Get people user is subscribed to
4072 +        # Get people user is subscribed to
4073 hunk ./actions/foaf.php 109
4074 -               $person = array();
4075 +        $person = array();
4076 hunk ./actions/foaf.php 111
4077 -               $sub = new Subscription();
4078 -               $sub->subscriber = $profile->id;
4079 -               $sub->whereAdd('subscriber != subscribed');
4080 -               
4081 -               if ($sub->find()) {
4082 -                       while ($sub->fetch()) {
4083 -                               if ($sub->token) {
4084 -                                       $other = Remote_profile::staticGet('id', $sub->subscribed);
4085 -                               } else {
4086 -                                       $other = User::staticGet('id', $sub->subscribed);
4087 -                               }
4088 -                               if (!$other) {
4089 -                                       common_debug('Got a bad subscription: '.print_r($sub,TRUE));
4090 -                                       continue;
4091 -                               }
4092 -                               common_element('knows', array('rdf:resource' => $other->uri));
4093 -                               $person[$other->uri] = array(LISTENEE, $other);
4094 -                       }
4095 -               }
4096 +        $sub = new Subscription();
4097 +        $sub->subscriber = $profile->id;
4098 +        $sub->whereAdd('subscriber != subscribed');
4099 +        
4100 +        if ($sub->find()) {
4101 +            while ($sub->fetch()) {
4102 +                if ($sub->token) {
4103 +                    $other = Remote_profile::staticGet('id', $sub->subscribed);
4104 +                } else {
4105 +                    $other = User::staticGet('id', $sub->subscribed);
4106 +                }
4107 +                if (!$other) {
4108 +                    common_debug('Got a bad subscription: '.print_r($sub,TRUE));
4109 +                    continue;
4110 +                }
4111 +                common_element('knows', array('rdf:resource' => $other->uri));
4112 +                $person[$other->uri] = array(LISTENEE, $other);
4113 +            }
4114 +        }
4115 hunk ./actions/foaf.php 131
4116 -               # Get people who subscribe to user
4117 +        # Get people who subscribe to user
4118 hunk ./actions/foaf.php 133
4119 -               $sub = new Subscription();
4120 -               $sub->subscribed = $profile->id;
4121 -               $sub->whereAdd('subscriber != subscribed');
4122 +        $sub = new Subscription();
4123 +        $sub->subscribed = $profile->id;
4124 +        $sub->whereAdd('subscriber != subscribed');
4125 hunk ./actions/foaf.php 137
4126 -               if ($sub->find()) {
4127 -                       while ($sub->fetch()) {
4128 -                               if ($sub->token) {
4129 -                                       $other = Remote_profile::staticGet('id', $sub->subscriber);
4130 -                               } else {
4131 -                                       $other = User::staticGet('id', $sub->subscriber);
4132 -                               }
4133 -                               if (!$other) {
4134 -                                       common_debug('Got a bad subscription: '.print_r($sub,TRUE));
4135 -                                       continue;
4136 -                               }
4137 -                               if (array_key_exists($other->uri, $person)) {
4138 -                                       $person[$other->uri][0] = BOTH;
4139 -                               } else {
4140 -                                       $person[$other->uri] = array(LISTENER, $other);
4141 -                               }
4142 -                       }
4143 -               }
4144 +        if ($sub->find()) {
4145 +            while ($sub->fetch()) {
4146 +                if ($sub->token) {
4147 +                    $other = Remote_profile::staticGet('id', $sub->subscriber);
4148 +                } else {
4149 +                    $other = User::staticGet('id', $sub->subscriber);
4150 +                }
4151 +                if (!$other) {
4152 +                    common_debug('Got a bad subscription: '.print_r($sub,TRUE));
4153 +                    continue;
4154 +                }
4155 +                if (array_key_exists($other->uri, $person)) {
4156 +                    $person[$other->uri][0] = BOTH;
4157 +                } else {
4158 +                    $person[$other->uri] = array(LISTENER, $other);
4159 +                }
4160 +            }
4161 +        }
4162 hunk ./actions/foaf.php 156
4163 -               common_element_end('Person');
4164 +        common_element_end('Person');
4165 hunk ./actions/foaf.php 158
4166 -               foreach ($person as $uri => $p) {
4167 -                       $foaf_url = NULL;
4168 -                       if ($p[1] instanceof User) {
4169 -                               $foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname));
4170 -                       }
4171 -                       $profile = Profile::staticGet($p[1]->id);
4172 -                       common_element_start('Person', array('rdf:about' => $uri));
4173 -                       if ($p[0] == LISTENER || $p[0] == BOTH) {
4174 -                               common_element('knows', array('rdf:resource' => $user->uri));
4175 -                       }
4176 -                       $this->show_microblogging_account($profile, ($p[1] instanceof User) ?
4177 -                                                                                         common_root_url() : NULL);
4178 -                       if ($foaf_url) {
4179 -                               common_element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
4180 -                       }
4181 -                       common_element_end('Person');
4182 -                       if ($foaf_url) {
4183 -                               $this->show_ppd($foaf_url, $uri);
4184 -                       }
4185 -               }
4186 +        foreach ($person as $uri => $p) {
4187 +            $foaf_url = NULL;
4188 +            if ($p[1] instanceof User) {
4189 +                $foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname));
4190 +            }
4191 +            $profile = Profile::staticGet($p[1]->id);
4192 +            common_element_start('Person', array('rdf:about' => $uri));
4193 +            if ($p[0] == LISTENER || $p[0] == BOTH) {
4194 +                common_element('knows', array('rdf:resource' => $user->uri));
4195 +            }
4196 +            $this->show_microblogging_account($profile, ($p[1] instanceof User) ?
4197 +                                              common_root_url() : NULL);
4198 +            if ($foaf_url) {
4199 +                common_element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
4200 +            }
4201 +            common_element_end('Person');
4202 +            if ($foaf_url) {
4203 +                $this->show_ppd($foaf_url, $uri);
4204 +            }
4205 +        }
4206 hunk ./actions/foaf.php 179
4207 -               common_element_end('rdf:RDF');
4208 -       }
4209 +        common_element_end('rdf:RDF');
4210 +    }
4211 hunk ./actions/foaf.php 182
4212 -       function show_ppd($foaf_url, $person_uri) {
4213 -               common_element_start('PersonalProfileDocument', array('rdf:about' => $foaf_url));
4214 -               common_element('maker', array('rdf:resource' => $person_uri));
4215 -               common_element('primaryTopic', array('rdf:resource' => $person_uri));
4216 -               common_element_end('PersonalProfileDocument');
4217 -       }
4218 +    function show_ppd($foaf_url, $person_uri) {
4219 +        common_element_start('PersonalProfileDocument', array('rdf:about' => $foaf_url));
4220 +        common_element('maker', array('rdf:resource' => $person_uri));
4221 +        common_element('primaryTopic', array('rdf:resource' => $person_uri));
4222 +        common_element_end('PersonalProfileDocument');
4223 +    }
4224 hunk ./actions/foaf.php 189
4225 -       function show_microblogging_account($profile, $service=NULL) {
4226 -               # Their account
4227 -               common_element_start('holdsAccount');
4228 -               common_element_start('OnlineAccount');
4229 -               if ($service) {
4230 -                       common_element('accountServiceHomepage', array('rdf:resource' =>
4231 -                                                                                                                  $service));
4232 -               }
4233 -               common_element('accountName', NULL, $profile->nickname);
4234 -               common_element('homepage', array('rdf:resource' => $profile->profileurl));
4235 -               common_element_end('OnlineAccount');
4236 -               common_element_end('holdsAccount');
4237 -       }
4238 +    function show_microblogging_account($profile, $service=NULL) {
4239 +        # Their account
4240 +        common_element_start('holdsAccount');
4241 +        common_element_start('OnlineAccount');
4242 +        if ($service) {
4243 +            common_element('accountServiceHomepage', array('rdf:resource' =>
4244 +                                                           $service));
4245 +        }
4246 +        common_element('accountName', NULL, $profile->nickname);
4247 +        common_element('homepage', array('rdf:resource' => $profile->profileurl));
4248 +        common_element_end('OnlineAccount');
4249 +        common_element_end('holdsAccount');
4250 +    }
4251 hunk ./actions/imsettings.php 27
4252 -       function get_instructions() {
4253 -               return _('You can send and receive notices through Jabber/GTalk [instant messages](%%doc.im%%). Configure your address and settings below.');
4254 -       }
4255 +    function get_instructions() {
4256 +        return _('You can send and receive notices through Jabber/GTalk [instant messages](%%doc.im%%). Configure your address and settings below.');
4257 +    }
4258 hunk ./actions/imsettings.php 31
4259 -       function show_form($msg=NULL, $success=false) {
4260 -               $user = common_current_user();
4261 -               $this->form_header(_('IM Settings'), $msg, $success);
4262 -               common_element_start('form', array('method' => 'post',
4263 -                                                                                  'id' => 'imsettings',
4264 -                                                                                  'action' =>
4265 -                                                                                  common_local_url('imsettings')));
4266 -               common_hidden('token', common_session_token());
4267 +    function show_form($msg=NULL, $success=false) {
4268 +        $user = common_current_user();
4269 +        $this->form_header(_('IM Settings'), $msg, $success);
4270 +        common_element_start('form', array('method' => 'post',
4271 +                                           'id' => 'imsettings',
4272 +                                           'action' =>
4273 +                                           common_local_url('imsettings')));
4274 +        common_hidden('token', common_session_token());
4275 hunk ./actions/imsettings.php 40
4276 -               common_element('h2', NULL, _('Address'));
4277 +        common_element('h2', NULL, _('Address'));
4278 hunk ./actions/imsettings.php 42
4279 -               if ($user->jabber) {
4280 -                       common_element_start('p');
4281 -                       common_element('span', 'address confirmed', $user->jabber);
4282 -                       common_element('span', 'input_instructions',
4283 -                                      _('Current confirmed Jabber/GTalk address.'));
4284 -                       common_hidden('jabber', $user->jabber);
4285 -                       common_element_end('p');
4286 -                       common_submit('remove', _('Remove'));
4287 -               } else {
4288 -                       $confirm = $this->get_confirmation();
4289 -                       if ($confirm) {
4290 -                               common_element_start('p');
4291 -                               common_element('span', 'address unconfirmed', $confirm->address);
4292 -                               common_element('span', 'input_instructions',
4293 -                                             sprintf(_('Awaiting confirmation on this address. Check your Jabber/GTalk account for a message with further instructions. (Did you add %s to your buddy list?)'), jabber_daemon_address()));
4294 -                               common_hidden('jabber', $confirm->address);
4295 -                               common_element_end('p');
4296 -                               common_submit('cancel', _('Cancel'));
4297 -                       } else {
4298 -                               common_input('jabber', _('IM Address'),
4299 -                                                       ($this->arg('jabber')) ? $this->arg('jabber') : NULL,
4300 -                                                sprintf(_('Jabber or GTalk address, like "UserName@example.org". First, make sure to add %s to your buddy list in your IM client or on GTalk.'), jabber_daemon_address()));
4301 -                               common_submit('add', _('Add'));
4302 -                       }
4303 -               }
4304 +        if ($user->jabber) {
4305 +            common_element_start('p');
4306 +            common_element('span', 'address confirmed', $user->jabber);
4307 +            common_element('span', 'input_instructions',
4308 +                           _('Current confirmed Jabber/GTalk address.'));
4309 +            common_hidden('jabber', $user->jabber);
4310 +            common_element_end('p');
4311 +            common_submit('remove', _('Remove'));
4312 +        } else {
4313 +            $confirm = $this->get_confirmation();
4314 +            if ($confirm) {
4315 +                common_element_start('p');
4316 +                common_element('span', 'address unconfirmed', $confirm->address);
4317 +                common_element('span', 'input_instructions',
4318 +                                sprintf(_('Awaiting confirmation on this address. Check your Jabber/GTalk account for a message with further instructions. (Did you add %s to your buddy list?)'), jabber_daemon_address()));
4319 +                common_hidden('jabber', $confirm->address);
4320 +                common_element_end('p');
4321 +                common_submit('cancel', _('Cancel'));
4322 +            } else {
4323 +                common_input('jabber', _('IM Address'),
4324 +                             ($this->arg('jabber')) ? $this->arg('jabber') : NULL,
4325 +                         sprintf(_('Jabber or GTalk address, like "UserName@example.org". First, make sure to add %s to your buddy list in your IM client or on GTalk.'), jabber_daemon_address()));
4326 +                common_submit('add', _('Add'));
4327 +            }
4328 +        }
4329 hunk ./actions/imsettings.php 68
4330 -               common_element('h2', NULL, _('Preferences'));
4331 +        common_element('h2', NULL, _('Preferences'));
4332 hunk ./actions/imsettings.php 70
4333 -               common_checkbox('jabbernotify',
4334 -                               _('Send me notices through Jabber/GTalk.'),
4335 -                               $user->jabbernotify);
4336 -               common_checkbox('updatefrompresence',
4337 -                               _('Post a notice when my Jabber/GTalk status changes.'),
4338 -                               $user->updatefrompresence);
4339 -               common_checkbox('jabberreplies',
4340 -                               _('Send me replies through Jabber/GTalk from people I\'m not subscribed to.'),
4341 -                               $user->jabberreplies);
4342 -               common_checkbox('jabbermicroid',
4343 -                               _('Publish a MicroID for my Jabber/GTalk address.'),
4344 -                               $user->jabbermicroid);
4345 -               common_submit('save', _('Save'));
4346 +        common_checkbox('jabbernotify',
4347 +                        _('Send me notices through Jabber/GTalk.'),
4348 +                        $user->jabbernotify);
4349 +        common_checkbox('updatefrompresence',
4350 +                        _('Post a notice when my Jabber/GTalk status changes.'),
4351 +                        $user->updatefrompresence);
4352 +        common_checkbox('jabberreplies',
4353 +                        _('Send me replies through Jabber/GTalk from people I\'m not subscribed to.'),
4354 +                        $user->jabberreplies);
4355 +        common_checkbox('jabbermicroid',
4356 +                        _('Publish a MicroID for my Jabber/GTalk address.'),
4357 +                        $user->jabbermicroid);
4358 +        common_submit('save', _('Save'));
4359 hunk ./actions/imsettings.php 84
4360 -               common_element_end('form');
4361 -               common_show_footer();
4362 -       }
4363 +        common_element_end('form');
4364 +        common_show_footer();
4365 +    }
4366 hunk ./actions/imsettings.php 88
4367 -       function get_confirmation() {
4368 -               $user = common_current_user();
4369 -               $confirm = new Confirm_address();
4370 -               $confirm->user_id = $user->id;
4371 -               $confirm->address_type = 'jabber';
4372 -               if ($confirm->find(TRUE)) {
4373 -                       return $confirm;
4374 -               } else {
4375 -                       return NULL;
4376 -               }
4377 -       }
4378 +    function get_confirmation() {
4379 +        $user = common_current_user();
4380 +        $confirm = new Confirm_address();
4381 +        $confirm->user_id = $user->id;
4382 +        $confirm->address_type = 'jabber';
4383 +        if ($confirm->find(TRUE)) {
4384 +            return $confirm;
4385 +        } else {
4386 +            return NULL;
4387 +        }
4388 +    }
4389 hunk ./actions/imsettings.php 100
4390 -       function handle_post() {
4391 +    function handle_post() {
4392 hunk ./actions/imsettings.php 102
4393 -               # CSRF protection
4394 -               $token = $this->trimmed('token');
4395 -               if (!$token || $token != common_session_token()) {
4396 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
4397 -                       return;
4398 -               }
4399 +        # CSRF protection
4400 +        $token = $this->trimmed('token');
4401 +        if (!$token || $token != common_session_token()) {
4402 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
4403 +            return;
4404 +        }
4405 hunk ./actions/imsettings.php 109
4406 -               if ($this->arg('save')) {
4407 -                       $this->save_preferences();
4408 -               } else if ($this->arg('add')) {
4409 -                       $this->add_address();
4410 -               } else if ($this->arg('cancel')) {
4411 -                       $this->cancel_confirmation();
4412 -               } else if ($this->arg('remove')) {
4413 -                       $this->remove_address();
4414 -               } else {
4415 -                       $this->show_form(_('Unexpected form submission.'));
4416 -               }
4417 -       }
4418 +        if ($this->arg('save')) {
4419 +            $this->save_preferences();
4420 +        } else if ($this->arg('add')) {
4421 +            $this->add_address();
4422 +        } else if ($this->arg('cancel')) {
4423 +            $this->cancel_confirmation();
4424 +        } else if ($this->arg('remove')) {
4425 +            $this->remove_address();
4426 +        } else {
4427 +            $this->show_form(_('Unexpected form submission.'));
4428 +        }
4429 +    }
4430 hunk ./actions/imsettings.php 122
4431 -       function save_preferences() {
4432 +    function save_preferences() {
4433 hunk ./actions/imsettings.php 124
4434 -               $jabbernotify = $this->boolean('jabbernotify');
4435 -               $updatefrompresence = $this->boolean('updatefrompresence');
4436 -               $jabberreplies = $this->boolean('jabberreplies');
4437 -               $jabbermicroid = $this->boolean('jabbermicroid');
4438 +        $jabbernotify = $this->boolean('jabbernotify');
4439 +        $updatefrompresence = $this->boolean('updatefrompresence');
4440 +        $jabberreplies = $this->boolean('jabberreplies');
4441 +        $jabbermicroid = $this->boolean('jabbermicroid');
4442 hunk ./actions/imsettings.php 129
4443 -               $user = common_current_user();
4444 +        $user = common_current_user();
4445 hunk ./actions/imsettings.php 131
4446 -               assert(!is_null($user)); # should already be checked
4447 +        assert(!is_null($user)); # should already be checked
4448 hunk ./actions/imsettings.php 133
4449 -               $user->query('BEGIN');
4450 +        $user->query('BEGIN');
4451 hunk ./actions/imsettings.php 135
4452 -               $original = clone($user);
4453 +        $original = clone($user);
4454 hunk ./actions/imsettings.php 137
4455 -               $user->jabbernotify = $jabbernotify;
4456 -               $user->updatefrompresence = $updatefrompresence;
4457 -               $user->jabberreplies = $jabberreplies;
4458 -               $user->jabbermicroid = $jabbermicroid;
4459 +        $user->jabbernotify = $jabbernotify;
4460 +        $user->updatefrompresence = $updatefrompresence;
4461 +        $user->jabberreplies = $jabberreplies;
4462 +        $user->jabbermicroid = $jabbermicroid;
4463 hunk ./actions/imsettings.php 142
4464 -               $result = $user->update($original);
4465 +        $result = $user->update($original);
4466 hunk ./actions/imsettings.php 144
4467 -               if ($result === FALSE) {
4468 -                       common_log_db_error($user, 'UPDATE', __FILE__);
4469 -                       common_server_error(_('Couldn\'t update user.'));
4470 -                       return;
4471 -               }
4472 +        if ($result === FALSE) {
4473 +            common_log_db_error($user, 'UPDATE', __FILE__);
4474 +            common_server_error(_('Couldn\'t update user.'));
4475 +            return;
4476 +        }
4477 hunk ./actions/imsettings.php 150
4478 -               $user->query('COMMIT');
4479 +        $user->query('COMMIT');
4480 hunk ./actions/imsettings.php 152
4481 -               $this->show_form(_('Preferences saved.'), true);
4482 -       }
4483 +        $this->show_form(_('Preferences saved.'), true);
4484 +    }
4485 hunk ./actions/imsettings.php 155
4486 -       function add_address() {
4487 +    function add_address() {
4488 hunk ./actions/imsettings.php 157
4489 -               $user = common_current_user();
4490 +        $user = common_current_user();
4491 hunk ./actions/imsettings.php 159
4492 -               $jabber = $this->trimmed('jabber');
4493 +        $jabber = $this->trimmed('jabber');
4494 hunk ./actions/imsettings.php 161
4495 -               # Some validation
4496 +        # Some validation
4497 hunk ./actions/imsettings.php 163
4498 -               if (!$jabber) {
4499 -                       $this->show_form(_('No Jabber ID.'));
4500 -                       return;
4501 -               }
4502 +        if (!$jabber) {
4503 +            $this->show_form(_('No Jabber ID.'));
4504 +            return;
4505 +        }
4506 hunk ./actions/imsettings.php 168
4507 -               $jabber = jabber_normalize_jid($jabber);
4508 +        $jabber = jabber_normalize_jid($jabber);
4509 hunk ./actions/imsettings.php 170
4510 -               if (!$jabber) {
4511 -                   $this->show_form(_('Cannot normalize that Jabber ID'));
4512 -                   return;
4513 -               }
4514 -               if (!jabber_valid_base_jid($jabber)) {
4515 -                   $this->show_form(_('Not a valid Jabber ID'));
4516 -                   return;
4517 -               } else if ($user->jabber == $jabber) {
4518 -                   $this->show_form(_('That is already your Jabber ID.'));
4519 -                   return;
4520 -               } else if ($this->jabber_exists($jabber)) {
4521 -                   $this->show_form(_('Jabber ID already belongs to another user.'));
4522 -                   return;
4523 -               }
4524 +        if (!$jabber) {
4525 +            $this->show_form(_('Cannot normalize that Jabber ID'));
4526 +            return;
4527 +        }
4528 +        if (!jabber_valid_base_jid($jabber)) {
4529 +            $this->show_form(_('Not a valid Jabber ID'));
4530 +            return;
4531 +        } else if ($user->jabber == $jabber) {
4532 +            $this->show_form(_('That is already your Jabber ID.'));
4533 +            return;
4534 +        } else if ($this->jabber_exists($jabber)) {
4535 +            $this->show_form(_('Jabber ID already belongs to another user.'));
4536 +            return;
4537 +        }
4538 hunk ./actions/imsettings.php 185
4539 -               $confirm = new Confirm_address();
4540 -               $confirm->address = $jabber;
4541 -               $confirm->address_type = 'jabber';
4542 -               $confirm->user_id = $user->id;
4543 -               $confirm->code = common_confirmation_code(64);
4544 +          $confirm = new Confirm_address();
4545 +           $confirm->address = $jabber;
4546 +           $confirm->address_type = 'jabber';
4547 +           $confirm->user_id = $user->id;
4548 +           $confirm->code = common_confirmation_code(64);
4549 hunk ./actions/imsettings.php 191
4550 -               $result = $confirm->insert();
4551 +        $result = $confirm->insert();
4552 hunk ./actions/imsettings.php 193
4553 -               if ($result === FALSE) {
4554 -                       common_log_db_error($confirm, 'INSERT', __FILE__);
4555 -                       common_server_error(_('Couldn\'t insert confirmation code.'));
4556 -                       return;
4557 -               }
4558 +        if ($result === FALSE) {
4559 +            common_log_db_error($confirm, 'INSERT', __FILE__);
4560 +            common_server_error(_('Couldn\'t insert confirmation code.'));
4561 +            return;
4562 +        }
4563 hunk ./actions/imsettings.php 199
4564 -               if (!common_config('queue', 'enabled')) {
4565 -                       jabber_confirm_address($confirm->code,
4566 -                                                                  $user->nickname,
4567 -                                                                  $jabber);
4568 -               }
4569 +        if (!common_config('queue', 'enabled')) {
4570 +            jabber_confirm_address($confirm->code,
4571 +                                   $user->nickname,
4572 +                                   $jabber);
4573 +        }
4574 hunk ./actions/imsettings.php 205
4575 -               $msg = sprintf(_('A confirmation code was sent to the IM address you added. You must approve %s for sending messages to you.'), jabber_daemon_address());
4576 +        $msg = sprintf(_('A confirmation code was sent to the IM address you added. You must approve %s for sending messages to you.'), jabber_daemon_address());
4577 hunk ./actions/imsettings.php 207
4578 -               $this->show_form($msg, TRUE);
4579 -       }
4580 +        $this->show_form($msg, TRUE);
4581 +    }
4582 hunk ./actions/imsettings.php 210
4583 -       function cancel_confirmation() {
4584 -               $jabber = $this->arg('jabber');
4585 -               $confirm = $this->get_confirmation();
4586 -               if (!$confirm) {
4587 -                       $this->show_form(_('No pending confirmation to cancel.'));
4588 -                       return;
4589 -               }
4590 -               if ($confirm->address != $jabber) {
4591 -                       $this->show_form(_('That is the wrong IM address.'));
4592 -                       return;
4593 -               }
4594 +    function cancel_confirmation() {
4595 +        $jabber = $this->arg('jabber');
4596 +        $confirm = $this->get_confirmation();
4597 +        if (!$confirm) {
4598 +            $this->show_form(_('No pending confirmation to cancel.'));
4599 +            return;
4600 +        }
4601 +        if ($confirm->address != $jabber) {
4602 +            $this->show_form(_('That is the wrong IM address.'));
4603 +            return;
4604 +        }
4605 hunk ./actions/imsettings.php 225
4606 -                       common_log_db_error($confirm, 'DELETE', __FILE__);
4607 +            common_log_db_error($confirm, 'DELETE', __FILE__);
4608 hunk ./actions/imsettings.php 231
4609 -       }
4610 +    }
4611 hunk ./actions/imsettings.php 233
4612 -       function remove_address() {
4613 +    function remove_address() {
4614 hunk ./actions/imsettings.php 235
4615 -               $user = common_current_user();
4616 -               $jabber = $this->arg('jabber');
4617 +        $user = common_current_user();
4618 +        $jabber = $this->arg('jabber');
4619 hunk ./actions/imsettings.php 238
4620 -               # Maybe an old tab open...?
4621 +        # Maybe an old tab open...?
4622 hunk ./actions/imsettings.php 240
4623 -               if ($user->jabber != $jabber) {
4624 -                   $this->show_form(_('That is not your Jabber ID.'));
4625 -                   return;
4626 -               }
4627 +        if ($user->jabber != $jabber) {
4628 +            $this->show_form(_('That is not your Jabber ID.'));
4629 +            return;
4630 +        }
4631 hunk ./actions/imsettings.php 245
4632 -               $user->query('BEGIN');
4633 -               $original = clone($user);
4634 -               $user->jabber = NULL;
4635 -               $result = $user->updateKeys($original);
4636 -               if (!$result) {
4637 -                       common_log_db_error($user, 'UPDATE', __FILE__);
4638 -                       common_server_error(_('Couldn\'t update user.'));
4639 -                       return;
4640 -               }
4641 -               $user->query('COMMIT');
4642 +        $user->query('BEGIN');
4643 +        $original = clone($user);
4644 +        $user->jabber = NULL;
4645 +        $result = $user->updateKeys($original);
4646 +        if (!$result) {
4647 +            common_log_db_error($user, 'UPDATE', __FILE__);
4648 +            common_server_error(_('Couldn\'t update user.'));
4649 +            return;
4650 +        }
4651 +        $user->query('COMMIT');
4652 hunk ./actions/imsettings.php 256
4653 -               # XXX: unsubscribe to the old address
4654 +        # XXX: unsubscribe to the old address
4655 hunk ./actions/imsettings.php 258
4656 -               $this->show_form(_('The address was removed.'), TRUE);
4657 -       }
4658 +        $this->show_form(_('The address was removed.'), TRUE);
4659 +    }
4660 hunk ./actions/imsettings.php 261
4661 -       function jabber_exists($jabber) {
4662 -               $user = common_current_user();
4663 -               $other = User::staticGet('jabber', $jabber);
4664 -               if (!$other) {
4665 -                       return false;
4666 -               } else {
4667 -                       return $other->id != $user->id;
4668 -               }
4669 -       }
4670 +    function jabber_exists($jabber) {
4671 +        $user = common_current_user();
4672 +        $other = User::staticGet('jabber', $jabber);
4673 +        if (!$other) {
4674 +            return false;
4675 +        } else {
4676 +            return $other->id != $user->id;
4677 +        }
4678 +    }
4679 hunk ./actions/invite.php 24
4680 -       function is_readonly() {
4681 -               return false;
4682 -       }
4683 +    function is_readonly() {
4684 +        return false;
4685 +    }
4686 hunk ./actions/invite.php 30
4687 -               if (!common_logged_in()) {
4688 -                       $this->client_error(sprintf(_('You must be logged in to invite other users to use %s'),
4689 -                                                                               common_config('site', 'name')));
4690 -                       return;
4691 -               } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
4692 -                       $this->send_invitations();
4693 -               } else {
4694 -                       $this->show_form();
4695 -               }
4696 -       }
4697 +        if (!common_logged_in()) {
4698 +            $this->client_error(sprintf(_('You must be logged in to invite other users to use %s'),
4699 +                                        common_config('site', 'name')));
4700 +            return;
4701 +        } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
4702 +            $this->send_invitations();
4703 +        } else {
4704 +            $this->show_form();
4705 +        }
4706 +    }
4707 hunk ./actions/invite.php 41
4708 -       function send_invitations() {
4709 +    function send_invitations() {
4710 hunk ./actions/invite.php 43
4711 -               # CSRF protection
4712 -               $token = $this->trimmed('token');
4713 -               if (!$token || $token != common_session_token()) {
4714 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
4715 -                       return;
4716 -               }
4717 +        # CSRF protection
4718 +        $token = $this->trimmed('token');
4719 +        if (!$token || $token != common_session_token()) {
4720 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
4721 +            return;
4722 +        }
4723 hunk ./actions/invite.php 50
4724 -               $user = common_current_user();
4725 -               $profile = $user->getProfile();
4726 +        $user = common_current_user();
4727 +        $profile = $user->getProfile();
4728 hunk ./actions/invite.php 53
4729 -               $bestname = $profile->getBestName();
4730 -               $sitename = common_config('site', 'name');
4731 -               $personal = $this->trimmed('personal');
4732 +        $bestname = $profile->getBestName();
4733 +        $sitename = common_config('site', 'name');
4734 +        $personal = $this->trimmed('personal');
4735 hunk ./actions/invite.php 57
4736 -               $addresses = explode("\n", $this->trimmed('addresses'));
4737 +        $addresses = explode("\n", $this->trimmed('addresses'));
4738 hunk ./actions/invite.php 59
4739 -               foreach ($addresses as $email) {
4740 -                       $email = trim($email);
4741 -                       if (!Validate::email($email, true)) {
4742 -                               $this->show_form(sprintf(_('Invalid email address: %s'), $email));
4743 -                               return;
4744 -                       }
4745 -               }
4746 +        foreach ($addresses as $email) {
4747 +            $email = trim($email);
4748 +            if (!Validate::email($email, true)) {
4749 +                $this->show_form(sprintf(_('Invalid email address: %s'), $email));
4750 +                return;
4751 +            }
4752 +        }
4753 hunk ./actions/invite.php 67
4754 -               $already = array();
4755 -               $subbed = array();
4756 +        $already = array();
4757 +        $subbed = array();
4758 hunk ./actions/invite.php 70
4759 -               foreach ($addresses as $email) {
4760 -                       $email = common_canonical_email($email);
4761 -                       $other = User::staticGet('email', $email);
4762 -                       if ($other) {
4763 -                               if ($user->isSubscribed($other)) {
4764 -                                       $already[] = $other;
4765 -                               } else {
4766 -                                       subs_subscribe_to($user, $other);
4767 -                                       $subbed[] = $other;
4768 -                               }
4769 -                       } else {
4770 -                               $sent[] = $email;
4771 -                               $this->send_invitation($email, $user, $personal);
4772 -                       }
4773 -               }
4774 +        foreach ($addresses as $email) {
4775 +            $email = common_canonical_email($email);
4776 +            $other = User::staticGet('email', $email);
4777 +            if ($other) {
4778 +                if ($user->isSubscribed($other)) {
4779 +                    $already[] = $other;
4780 +                } else {
4781 +                    subs_subscribe_to($user, $other);
4782 +                    $subbed[] = $other;
4783 +                }
4784 +            } else {
4785 +                $sent[] = $email;
4786 +                $this->send_invitation($email, $user, $personal);
4787 +            }
4788 +        }
4789 hunk ./actions/invite.php 86
4790 -               common_show_header(_('Invitation(s) sent'));
4791 -               if ($already) {
4792 -                       common_element('p', NULL, _('You are already subscribed to these users:'));
4793 -                       common_element_start('ul');
4794 -                       foreach ($already as $other) {
4795 -                               common_element('li', NULL, sprintf(_('%s (%s)'), $other->nickname, $other->email));
4796 -                       }
4797 -                       common_element_end('ul');
4798 -               }
4799 -               if ($subbed) {
4800 -                       common_element('p', NULL, _('These people are already users and you were automatically subscribed to them:'));
4801 -                       common_element_start('ul');
4802 -                       foreach ($subbed as $other) {
4803 -                               common_element('li', NULL, sprintf(_('%s (%s)'), $other->nickname, $other->email));
4804 -                       }
4805 -                       common_element_end('ul');
4806 -               }
4807 -               if ($sent) {
4808 -                       common_element('p', NULL, _('Invitation(s) sent to the following people:'));
4809 -                       common_element_start('ul');
4810 -                       foreach ($sent as $other) {
4811 -                               common_element('li', NULL, $other);
4812 -                       }
4813 -                       common_element_end('ul');
4814 -                       common_element('p', NULL, _('You will be notified when your invitees accept the invitation and register on the site. Thanks for growing the community!'));
4815 -               }
4816 -               common_show_footer();
4817 -       }
4818 +        common_show_header(_('Invitation(s) sent'));
4819 +        if ($already) {
4820 +            common_element('p', NULL, _('You are already subscribed to these users:'));
4821 +            common_element_start('ul');
4822 +            foreach ($already as $other) {
4823 +                common_element('li', NULL, sprintf(_('%s (%s)'), $other->nickname, $other->email));
4824 +            }
4825 +            common_element_end('ul');
4826 +        }
4827 +        if ($subbed) {
4828 +            common_element('p', NULL, _('These people are already users and you were automatically subscribed to them:'));
4829 +            common_element_start('ul');
4830 +            foreach ($subbed as $other) {
4831 +                common_element('li', NULL, sprintf(_('%s (%s)'), $other->nickname, $other->email));
4832 +            }
4833 +            common_element_end('ul');
4834 +        }
4835 +        if ($sent) {
4836 +            common_element('p', NULL, _('Invitation(s) sent to the following people:'));
4837 +            common_element_start('ul');
4838 +            foreach ($sent as $other) {
4839 +                common_element('li', NULL, $other);
4840 +            }
4841 +            common_element_end('ul');
4842 +            common_element('p', NULL, _('You will be notified when your invitees accept the invitation and register on the site. Thanks for growing the community!'));
4843 +        }
4844 +        common_show_footer();
4845 +    }
4846 hunk ./actions/invite.php 115
4847 -       function show_top($error=NULL) {
4848 -               if ($error) {
4849 -                       common_element('p', 'error', $error);
4850 -               } else {
4851 -                       common_element_start('div', 'instructions');
4852 -                       common_element('p', NULL,
4853 -                                                  _('Use this form to invite your friends and colleagues to use this service.'));
4854 -                       common_element_end('div');
4855 -               }
4856 -       }
4857 +    function show_top($error=NULL) {
4858 +        if ($error) {
4859 +            common_element('p', 'error', $error);
4860 +        } else {
4861 +            common_element_start('div', 'instructions');
4862 +            common_element('p', NULL,
4863 +                           _('Use this form to invite your friends and colleagues to use this service.'));
4864 +            common_element_end('div');
4865 +        }
4866 +    }
4867 hunk ./actions/invite.php 126
4868 -       function show_form($error=NULL) {
4869 +    function show_form($error=NULL) {
4870 hunk ./actions/invite.php 128
4871 -               global $config;
4872 +        global $config;
4873 hunk ./actions/invite.php 130
4874 -               common_show_header(_('Invite new users'), NULL, $error, array($this, 'show_top'));
4875 +        common_show_header(_('Invite new users'), NULL, $error, array($this, 'show_top'));
4876 hunk ./actions/invite.php 132
4877 -               common_element_start('form', array('method' => 'post',
4878 -                                                                                  'id' => 'invite',
4879 -                                                                                  'action' => common_local_url('invite')));
4880 -               common_hidden('token', common_session_token());
4881 +        common_element_start('form', array('method' => 'post',
4882 +                                           'id' => 'invite',
4883 +                                           'action' => common_local_url('invite')));
4884 +        common_hidden('token', common_session_token());
4885 hunk ./actions/invite.php 137
4886 -               common_textarea('addresses', _('Email addresses'),
4887 -                                               $this->trimmed('addresses'),
4888 -                                               _('Addresses of friends to invite (one per line)'));
4889 +        common_textarea('addresses', _('Email addresses'),
4890 +                        $this->trimmed('addresses'),
4891 +                        _('Addresses of friends to invite (one per line)'));
4892 hunk ./actions/invite.php 141
4893 -               common_textarea('personal', _('Personal message'),
4894 -                                               $this->trimmed('personal'),
4895 -                                               _('Optionally add a personal message to the invitation.'));
4896 +        common_textarea('personal', _('Personal message'),
4897 +                        $this->trimmed('personal'),
4898 +                        _('Optionally add a personal message to the invitation.'));
4899 hunk ./actions/invite.php 145
4900 -               common_submit('send', _('Send'));
4901 +        common_submit('send', _('Send'));
4902 hunk ./actions/invite.php 147
4903 -               common_element_end('form');
4904 +        common_element_end('form');
4905 hunk ./actions/invite.php 149
4906 -               common_show_footer();
4907 -       }
4908 +        common_show_footer();
4909 +    }
4910 hunk ./actions/invite.php 152
4911 -       function send_invitation($email, $user, $personal) {
4912 +    function send_invitation($email, $user, $personal) {
4913 hunk ./actions/invite.php 154
4914 -               $profile = $user->getProfile();
4915 -               $bestname = $profile->getBestName();
4916 +        $profile = $user->getProfile();
4917 +        $bestname = $profile->getBestName();
4918 hunk ./actions/invite.php 157
4919 -               $sitename = common_config('site', 'name');
4920 +        $sitename = common_config('site', 'name');
4921 hunk ./actions/invite.php 159
4922 -               $invite = new Invitation();
4923 +        $invite = new Invitation();
4924 hunk ./actions/invite.php 161
4925 -               $invite->address = $email;
4926 -               $invite->address_type = 'email';
4927 -               $invite->code = common_confirmation_code(128);
4928 -               $invite->user_id = $user->id;
4929 -               $invite->created = common_sql_now();
4930 +        $invite->address = $email;
4931 +        $invite->address_type = 'email';
4932 +        $invite->code = common_confirmation_code(128);
4933 +        $invite->user_id = $user->id;
4934 +        $invite->created = common_sql_now();
4935 hunk ./actions/invite.php 167
4936 -               if (!$invite->insert()) {
4937 -                       common_log_db_error($invite, 'INSERT', __FILE__);
4938 -                       return false;
4939 -               }
4940 +        if (!$invite->insert()) {
4941 +            common_log_db_error($invite, 'INSERT', __FILE__);
4942 +            return false;
4943 +        }
4944 hunk ./actions/invite.php 172
4945 -               $recipients = array($email);
4946 +        $recipients = array($email);
4947 hunk ./actions/invite.php 174
4948 -               $headers['From'] = mail_notify_from();
4949 -               $headers['To'] = $email;
4950 -               $headers['Subject'] = sprintf(_('%1$s has invited you to join them on %2$s'), $bestname, $sitename);
4951 +        $headers['From'] = mail_notify_from();
4952 +        $headers['To'] = $email;
4953 +        $headers['Subject'] = sprintf(_('%1$s has invited you to join them on %2$s'), $bestname, $sitename);
4954 hunk ./actions/invite.php 178
4955 -               $body = sprintf(_("%1\$s has invited you to join them on %2\$s (%3\$s).\n\n".
4956 -                                                 "%2\$s is a micro-blogging service that lets you keep up-to-date with people you know and people who interest you.\n\n".
4957 -                                                 "You can also share news about yourself, your thoughts, or your life online with people who know about you. ".
4958 -                                                 "It's also great for meeting new people who share your interests.\n\n".
4959 -                                                 "%1\$s said:\n\n%4\$s\n\n".
4960 -                                                 "You can see %1\$s's profile page on %2\$s here:\n\n".
4961 -                                                 "%5\$s\n\n".
4962 -                                                 "If you'd like to try the service, click on the link below to accept the invitation.\n\n".
4963 -                                                 "%6\$s\n\n".
4964 -                                                 "If not, you can ignore this message. Thanks for your patience and your time.\n\n".
4965 -                                                 "Sincerely, %2\$s\n"),
4966 -                                               $bestname,
4967 -                                               $sitename,
4968 -                                               common_root_url(),
4969 -                                               $personal,
4970 -                                               common_local_url('showstream', array('nickname' => $user->nickname)),
4971 -                                               common_local_url('register', array('code' => $invite->code)));
4972 +        $body = sprintf(_("%1\$s has invited you to join them on %2\$s (%3\$s).\n\n".
4973 +                          "%2\$s is a micro-blogging service that lets you keep up-to-date with people you know and people who interest you.\n\n".
4974 +                          "You can also share news about yourself, your thoughts, or your life online with people who know about you. ".
4975 +                          "It's also great for meeting new people who share your interests.\n\n".
4976 +                          "%1\$s said:\n\n%4\$s\n\n".
4977 +                          "You can see %1\$s's profile page on %2\$s here:\n\n".
4978 +                          "%5\$s\n\n".
4979 +                          "If you'd like to try the service, click on the link below to accept the invitation.\n\n".
4980 +                          "%6\$s\n\n".
4981 +                          "If not, you can ignore this message. Thanks for your patience and your time.\n\n".
4982 +                          "Sincerely, %2\$s\n"),
4983 +                        $bestname,
4984 +                        $sitename,
4985 +                        common_root_url(),
4986 +                        $personal,
4987 +                        common_local_url('showstream', array('nickname' => $user->nickname)),
4988 +                        common_local_url('register', array('code' => $invite->code)));
4989 hunk ./actions/invite.php 196
4990 -               mail_send($recipients, $headers, $body);
4991 -       }
4992 +        mail_send($recipients, $headers, $body);
4993 +    }
4994 hunk ./actions/login.php 24
4995 -       function is_readonly() {
4996 -               return true;
4997 -       }
4998 +    function is_readonly() {
4999 +        return true;
5000 +    }
5001 hunk ./actions/login.php 28
5002 -       function handle($args) {
5003 -               parent::handle($args);
5004 -               if (common_is_real_login()) {
5005 -                       common_user_error(_('Already logged in.'));
5006 -               } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
5007 -                       $this->check_login();
5008 -               } else {
5009 -                       $this->show_form();
5010 -               }
5011 -       }
5012 +    function handle($args) {
5013 +        parent::handle($args);
5014 +        if (common_is_real_login()) {
5015 +            common_user_error(_('Already logged in.'));
5016 +        } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
5017 +            $this->check_login();
5018 +        } else {
5019 +            $this->show_form();
5020 +        }
5021 +    }
5022 hunk ./actions/login.php 39
5023 -       function check_login() {
5024 -               # XXX: login throttle
5025 +    function check_login() {
5026 +        # XXX: login throttle
5027 hunk ./actions/login.php 42
5028 -               # CSRF protection - token set in common_notice_form()
5029 -               $token = $this->trimmed('token');
5030 -               if (!$token || $token != common_session_token()) {
5031 -                       $this->client_error(_('There was a problem with your session token. Try again, please.'));
5032 -                       return;
5033 -               }
5034 +        # CSRF protection - token set in common_notice_form()
5035 +        $token = $this->trimmed('token');
5036 +        if (!$token || $token != common_session_token()) {
5037 +            $this->client_error(_('There was a problem with your session token. Try again, please.'));
5038 +            return;
5039 +        }
5040 hunk ./actions/login.php 49
5041 -               $nickname = common_canonical_nickname($this->trimmed('nickname'));
5042 -               $password = $this->arg('password');
5043 -               if (common_check_user($nickname, $password)) {
5044 -                       # success!
5045 -                       if (!common_set_user($nickname)) {
5046 -                               common_server_error(_('Error setting user.'));
5047 -                               return;
5048 -                       }
5049 -                       common_real_login(true);
5050 -                       if ($this->boolean('rememberme')) {
5051 -                               common_debug('Adding rememberme cookie for ' . $nickname);
5052 -                               common_rememberme();
5053 -                       }
5054 -                       # success!
5055 -                       $url = common_get_returnto();
5056 -                       if ($url) {
5057 -                               # We don't have to return to it again
5058 -                               common_set_returnto(NULL);
5059 -                       } else {
5060 -                               $url = common_local_url('all',
5061 -                                                                               array('nickname' =>
5062 -                                                                                         $nickname));
5063 -                       }
5064 -                       common_redirect($url);
5065 -               } else {
5066 -                       $this->show_form(_('Incorrect username or password.'));
5067 -                       return;
5068 -               }
5069 +        $nickname = common_canonical_nickname($this->trimmed('nickname'));
5070 +        $password = $this->arg('password');
5071 +        if (common_check_user($nickname, $password)) {
5072 +            # success!
5073 +            if (!common_set_user($nickname)) {
5074 +                common_server_error(_('Error setting user.'));
5075 +                return;
5076 +            }
5077 +            common_real_login(true);
5078 +            if ($this->boolean('rememberme')) {
5079 +                common_debug('Adding rememberme cookie for ' . $nickname);
5080 +                common_rememberme();
5081 +            }
5082 +            # success!
5083 +            $url = common_get_returnto();
5084 +            if ($url) {
5085 +                # We don't have to return to it again
5086 +                common_set_returnto(NULL);
5087 +            } else {
5088 +                $url = common_local_url('all',
5089 +                                        array('nickname' =>
5090 +                                              $nickname));
5091 +            }
5092 +            common_redirect($url);
5093 +        } else {
5094 +            $this->show_form(_('Incorrect username or password.'));
5095 +            return;
5096 +        }
5097 hunk ./actions/login.php 78
5098 -               # success!
5099 -               if (!common_set_user($user)) {
5100 -                       common_server_error(_('Error setting user.'));
5101 -                       return;
5102 -               }
5103 +        # success!
5104 +        if (!common_set_user($user)) {
5105 +            common_server_error(_('Error setting user.'));
5106 +            return;
5107 +        }
5108 hunk ./actions/login.php 84
5109 -               common_real_login(true);
5110 +        common_real_login(true);
5111 hunk ./actions/login.php 86
5112 -               if ($this->boolean('rememberme')) {
5113 -                       common_debug('Adding rememberme cookie for ' . $nickname);
5114 -                       common_rememberme($user);
5115 -               }
5116 -               # success!
5117 -               $url = common_get_returnto();
5118 -               if ($url) {
5119 -                       # We don't have to return to it again
5120 -                       common_set_returnto(NULL);
5121 -               } else {
5122 -                       $url = common_local_url('all',
5123 -                                                                       array('nickname' =>
5124 -                                                                                 $nickname));
5125 -               }
5126 -               common_redirect($url);
5127 -       }
5128 +        if ($this->boolean('rememberme')) {
5129 +            common_debug('Adding rememberme cookie for ' . $nickname);
5130 +            common_rememberme($user);
5131 +        }
5132 +        # success!
5133 +        $url = common_get_returnto();
5134 +        if ($url) {
5135 +            # We don't have to return to it again
5136 +            common_set_returnto(NULL);
5137 +        } else {
5138 +            $url = common_local_url('all',
5139 +                                    array('nickname' =>
5140 +                                          $nickname));
5141 +        }
5142 +        common_redirect($url);
5143 +    }
5144 hunk ./actions/login.php 103
5145 -       function show_form($error=NULL) {
5146 -               common_show_header(_('Login'), NULL, $error, array($this, 'show_top'));
5147 -               common_element_start('form', array('method' => 'post',
5148 -                                                                                  'id' => 'login',
5149 -                                                                                  'action' => common_local_url('login')));
5150 -               common_input('nickname', _('Nickname'));
5151 -               common_password('password', _('Password'));
5152 -               common_checkbox('rememberme', _('Remember me'), false,
5153 -                               _('Automatically login in the future; ' .
5154 -                                  'not for shared computers!'));
5155 -               common_submit('submit', _('Login'));
5156 -               common_hidden('token', common_session_token());
5157 -               common_element_end('form');
5158 -               common_element_start('p');
5159 -               common_element('a', array('href' => common_local_url('recoverpassword')),
5160 -                                          _('Lost or forgotten password?'));
5161 -               common_element_end('p');
5162 -               common_show_footer();
5163 -       }
5164 +    function show_form($error=NULL) {
5165 +        common_show_header(_('Login'), NULL, $error, array($this, 'show_top'));
5166 +        common_element_start('form', array('method' => 'post',
5167 +                                           'id' => 'login',
5168 +                                           'action' => common_local_url('login')));
5169 +        common_input('nickname', _('Nickname'));
5170 +        common_password('password', _('Password'));
5171 +        common_checkbox('rememberme', _('Remember me'), false,
5172 +                        _('Automatically login in the future; ' .
5173 +                           'not for shared computers!'));
5174 +        common_submit('submit', _('Login'));
5175 +        common_hidden('token', common_session_token());
5176 +        common_element_end('form');
5177 +        common_element_start('p');
5178 +        common_element('a', array('href' => common_local_url('recoverpassword')),
5179 +                       _('Lost or forgotten password?'));
5180 +        common_element_end('p');
5181 +        common_show_footer();
5182 +    }
5183 hunk ./actions/login.php 123
5184 -       function get_instructions() {
5185 -               if (common_logged_in() &&
5186 -                       !common_is_real_login() &&
5187 -                       common_get_returnto())
5188 -               {
5189 -                       # rememberme logins have to reauthenticate before
5190 -                       # changing any profile settings (cookie-stealing protection)
5191 -                       return _('For security reasons, please re-enter your ' .
5192 -                                        'user name and password ' .
5193 -                                        'before changing your settings.');
5194 -               } else {
5195 -                       return _('Login with your username and password. ' .
5196 -                                        'Don\'t have a username yet? ' .
5197 -                                        '[Register](%%action.register%%) a new account, or ' .
5198 -                                        'try [OpenID](%%action.openidlogin%%). ');
5199 -               }
5200 -       }
5201 +    function get_instructions() {
5202 +        if (common_logged_in() &&
5203 +            !common_is_real_login() &&
5204 +            common_get_returnto())
5205 +        {
5206 +            # rememberme logins have to reauthenticate before
5207 +            # changing any profile settings (cookie-stealing protection)
5208 +            return _('For security reasons, please re-enter your ' .
5209 +                     'user name and password ' .
5210 +                     'before changing your settings.');
5211 +        } else {
5212 +            return _('Login with your username and password. ' .
5213 +                     'Don\'t have a username yet? ' .
5214 +                     '[Register](%%action.register%%) a new account, or ' .
5215 +                     'try [OpenID](%%action.openidlogin%%). ');
5216 +        }
5217 +    }
5218 hunk ./actions/login.php 141
5219 -       function show_top($error=NULL) {
5220 -               if ($error) {
5221 -                       common_element('p', 'error', $error);
5222 -               } else {
5223 -                       $instr = $this->get_instructions();
5224 -                       $output = common_markup_to_html($instr);
5225 -                       common_element_start('div', 'instructions');
5226 -                       common_raw($output);
5227 -                       common_element_end('div');
5228 -               }
5229 -       }
5230 +    function show_top($error=NULL) {
5231 +        if ($error) {
5232 +            common_element('p', 'error', $error);
5233 +        } else {
5234 +            $instr = $this->get_instructions();
5235 +            $output = common_markup_to_html($instr);
5236 +            common_element_start('div', 'instructions');
5237 +            common_raw($output);
5238 +            common_element_end('div');
5239 +        }
5240 +    }
5241 hunk ./actions/logout.php 25
5242 -       
5243 -       function is_readonly() {
5244 -               return true;
5245 -       }
5246 -       
5247 -       function handle($args) {
5248 -               parent::handle($args);
5249 -               if (!common_logged_in()) {
5250 -                       common_user_error(_('Not logged in.'));
5251 -               } else {
5252 -                       common_set_user(NULL);
5253 -                       common_real_login(false); # not logged in
5254 -                       common_forgetme(); # don't log back in!
5255 -                       common_redirect(common_local_url('public'));
5256 -               }
5257 -       }
5258 +    
5259 +    function is_readonly() {
5260 +        return true;
5261 +    }
5262 +    
5263 +    function handle($args) {
5264 +        parent::handle($args);
5265 +        if (!common_logged_in()) {
5266 +            common_user_error(_('Not logged in.'));
5267 +        } else {
5268 +            common_set_user(NULL);
5269 +            common_real_login(false); # not logged in
5270 +            common_forgetme(); # don't log back in!
5271 +            common_redirect(common_local_url('public'));
5272 +        }
5273 +    }
5274 hunk ./actions/microsummary.php 24
5275 -       function handle($args) {
5276 +    function handle($args) {
5277 hunk ./actions/microsummary.php 26
5278 -               parent::handle($args);
5279 +        parent::handle($args);
5280 hunk ./actions/microsummary.php 28
5281 -               $nickname = common_canonical_nickname($this->arg('nickname'));
5282 -               $user = User::staticGet('nickname', $nickname);
5283 +        $nickname = common_canonical_nickname($this->arg('nickname'));
5284 +        $user = User::staticGet('nickname', $nickname);
5285 hunk ./actions/microsummary.php 31
5286 -               if (!$user) {
5287 -                       $this->client_error(_('No such user'), 404);
5288 -                       return;
5289 -               }
5290 -               
5291 -               $notice = $user->getCurrentNotice();
5292 -               
5293 -               if (!$notice) {
5294 -                       $this->client_error(_('No current status'), 404);
5295 -               }
5296 -               
5297 -               header('Content-Type: text/plain');
5298 -               
5299 -               print $user->nickname . ': ' . $notice->content;
5300 -       }
5301 +        if (!$user) {
5302 +            $this->client_error(_('No such user'), 404);
5303 +            return;
5304 +        }
5305 +        
5306 +        $notice = $user->getCurrentNotice();
5307 +        
5308 +        if (!$notice) {
5309 +            $this->client_error(_('No current status'), 404);
5310 +        }
5311 +        
5312 +        header('Content-Type: text/plain');
5313 +        
5314 +        print $user->nickname . ': ' . $notice->content;
5315 +    }
5316 hunk ./actions/newmessage.php 23
5317 -       
5318 -       function handle($args) {
5319 -               parent::handle($args);
5320 +    
5321 +    function handle($args) {
5322 +        parent::handle($args);
5323 hunk ./actions/newmessage.php 27
5324 -               if (!common_logged_in()) {
5325 -                       $this->client_error(_('Not logged in.'), 403);
5326 -               } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
5327 -                       $this->save_new_message();
5328 -               } else {
5329 -                       $this->show_form();
5330 -               }
5331 -       }
5332 +        if (!common_logged_in()) {
5333 +            $this->client_error(_('Not logged in.'), 403);
5334 +        } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
5335 +            $this->save_new_message();
5336 +        } else {
5337 +            $this->show_form();
5338 +        }
5339 +    }
5340 hunk ./actions/newmessage.php 36
5341 -       function save_new_message() {
5342 -               $user = common_current_user();
5343 -               assert($user); # XXX: maybe an error instead...
5344 +    function save_new_message() {
5345 +        $user = common_current_user();
5346 +        assert($user); # XXX: maybe an error instead...
5347 hunk ./actions/newmessage.php 40
5348 -               # CSRF protection
5349 -               
5350 -               $token = $this->trimmed('token');
5351 -               if (!$token || $token != common_session_token()) {
5352 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
5353 -                       return;
5354 -               }
5355 -               
5356 -               $content = $this->trimmed('content');
5357 -               $to = $this->trimmed('to');
5358 -               
5359 -               if (!$content) {
5360 -                       $this->show_form(_('No content!'));
5361 -                       return;
5362 -               } else {
5363 -                       $content_shortened = common_shorten_links($content);
5364 +        # CSRF protection
5365 +        
5366 +        $token = $this->trimmed('token');
5367 +        if (!$token || $token != common_session_token()) {
5368 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
5369 +            return;
5370 +        }
5371 +        
5372 +        $content = $this->trimmed('content');
5373 +        $to = $this->trimmed('to');
5374 +        
5375 +        if (!$content) {
5376 +            $this->show_form(_('No content!'));
5377 +            return;
5378 +        } else {
5379 +            $content_shortened = common_shorten_links($content);
5380 hunk ./actions/newmessage.php 57
5381 -                       if (mb_strlen($content_shortened) > 140) {
5382 -                               common_debug("Content = '$content_shortened'", __FILE__);
5383 -                               common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
5384 -                               $this->show_form(_('That\'s too long. Max message size is 140 chars.'));
5385 -                               return;
5386 -                       }
5387 -               }
5388 +            if (mb_strlen($content_shortened) > 140) {
5389 +                common_debug("Content = '$content_shortened'", __FILE__);
5390 +                common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
5391 +                $this->show_form(_('That\'s too long. Max message size is 140 chars.'));
5392 +                return;
5393 +            }
5394 +        }
5395 hunk ./actions/newmessage.php 65
5396 -               $other = User::staticGet('id', $to);
5397 -               
5398 -               if (!$other) {
5399 -                       $this->show_form(_('No recipient specified.'));
5400 -                       return;
5401 -               } else if (!$user->mutuallySubscribed($other)) {
5402 -                       $this->client_error(_('You can\'t send a message to this user.'), 404);
5403 -                       return;
5404 -               } else if ($user->id == $other->id) {
5405 -                       $this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), 403);
5406 -                       return;
5407 -               }
5408 -               
5409 -               $message = Message::saveNew($user->id, $other->id, $content, 'web');
5410 -               
5411 -               if (is_string($message)) {
5412 -                       $this->show_form($message);
5413 -                       return;
5414 -               }
5415 +        $other = User::staticGet('id', $to);
5416 +        
5417 +        if (!$other) {
5418 +            $this->show_form(_('No recipient specified.'));
5419 +            return;
5420 +        } else if (!$user->mutuallySubscribed($other)) {
5421 +            $this->client_error(_('You can\'t send a message to this user.'), 404);
5422 +            return;
5423 +        } else if ($user->id == $other->id) {
5424 +            $this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), 403);
5425 +            return;
5426 +        }
5427 +        
5428 +        $message = Message::saveNew($user->id, $other->id, $content, 'web');
5429 +        
5430 +        if (is_string($message)) {
5431 +            $this->show_form($message);
5432 +            return;
5433 +        }
5434 hunk ./actions/newmessage.php 85
5435 -               $this->notify($user, $other, $message);
5436 +        $this->notify($user, $other, $message);
5437 hunk ./actions/newmessage.php 87
5438 -               $url = common_local_url('outbox', array('nickname' => $user->nickname));
5439 +        $url = common_local_url('outbox', array('nickname' => $user->nickname));
5440 hunk ./actions/newmessage.php 89
5441 -               common_redirect($url, 303);
5442 -       }
5443 +        common_redirect($url, 303);
5444 +    }
5445 hunk ./actions/newmessage.php 92
5446 -       function show_top($params) {
5447 +    function show_top($params) {
5448 hunk ./actions/newmessage.php 94
5449 -               list($content, $user, $to) = $params;
5450 -               
5451 -               assert(!is_null($user));
5452 +        list($content, $user, $to) = $params;
5453 +        
5454 +        assert(!is_null($user));
5455 hunk ./actions/newmessage.php 98
5456 -               common_message_form($content, $user, $to);
5457 -       }
5458 +        common_message_form($content, $user, $to);
5459 +    }
5460 hunk ./actions/newmessage.php 101
5461 -       function show_form($msg=NULL) {
5462 -               
5463 -               $content = $this->trimmed('content');
5464 -               $user = common_current_user();
5465 +    function show_form($msg=NULL) {
5466 +        
5467 +        $content = $this->trimmed('content');
5468 +        $user = common_current_user();
5469 hunk ./actions/newmessage.php 106
5470 -               $to = $this->trimmed('to');
5471 -               
5472 -               $other = User::staticGet('id', $to);
5473 +        $to = $this->trimmed('to');
5474 +        
5475 +        $other = User::staticGet('id', $to);
5476 hunk ./actions/newmessage.php 110
5477 -               if (!$other) {
5478 -                       $this->client_error(_('No such user'), 404);
5479 -                       return;
5480 -               }
5481 +        if (!$other) {
5482 +            $this->client_error(_('No such user'), 404);
5483 +            return;
5484 +        }
5485 hunk ./actions/newmessage.php 115
5486 -               if (!$user->mutuallySubscribed($other)) {
5487 -                       $this->client_error(_('You can\'t send a message to this user.'), 404);
5488 -                       return;
5489 -               }
5490 -               
5491 -               common_show_header(_('New message'), NULL,
5492 -                                                  array($content, $user, $other),
5493 -                                  array($this, 'show_top'));
5494 -               
5495 -               if ($msg) {
5496 -                       common_element('p', array('id'=>'error'), $msg);
5497 -               }
5498 -               
5499 -               common_show_footer();
5500 -       }
5501 -       
5502 -       function notify($from, $to, $message) {
5503 -               mail_notify_message($message, $from, $to);
5504 -               # XXX: Jabber, SMS notifications... probably queued
5505 -       }
5506 +        if (!$user->mutuallySubscribed($other)) {
5507 +            $this->client_error(_('You can\'t send a message to this user.'), 404);
5508 +            return;
5509 +        }
5510 +        
5511 +        common_show_header(_('New message'), NULL,
5512 +                           array($content, $user, $other),
5513 +                           array($this, 'show_top'));
5514 +        
5515 +        if ($msg) {
5516 +            common_element('p', array('id'=>'error'), $msg);
5517 +        }
5518 +        
5519 +        common_show_footer();
5520 +    }
5521 +    
5522 +    function notify($from, $to, $message) {
5523 +        mail_notify_message($message, $from, $to);
5524 +        # XXX: Jabber, SMS notifications... probably queued
5525 +    }
5526 hunk ./actions/newnotice.php 13
5527 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
5528 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
5529 hunk ./actions/newnotice.php 17
5530 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
5531 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
5532 hunk ./actions/newnotice.php 26
5533 -       function handle($args) {
5534 -               parent::handle($args);
5535 +    function handle($args) {
5536 +        parent::handle($args);
5537 hunk ./actions/newnotice.php 29
5538 -               if (!common_logged_in()) {
5539 -                       common_user_error(_('Not logged in.'));
5540 -               } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
5541 +        if (!common_logged_in()) {
5542 +            common_user_error(_('Not logged in.'));
5543 +        } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
5544 hunk ./actions/newnotice.php 33
5545 -                       # CSRF protection - token set in common_notice_form()
5546 -                       $token = $this->trimmed('token');
5547 -                       if (!$token || $token != common_session_token()) {
5548 -                               $this->client_error(_('There was a problem with your session token. Try again, please.'));
5549 -                               return;
5550 -                       }
5551 +            # CSRF protection - token set in common_notice_form()
5552 +            $token = $this->trimmed('token');
5553 +            if (!$token || $token != common_session_token()) {
5554 +                $this->client_error(_('There was a problem with your session token. Try again, please.'));
5555 +                return;
5556 +            }
5557 hunk ./actions/newnotice.php 40
5558 -                       $this->save_new_notice();
5559 -               } else {
5560 -                       $this->show_form();
5561 -               }
5562 -       }
5563 +            $this->save_new_notice();
5564 +        } else {
5565 +            $this->show_form();
5566 +        }
5567 +    }
5568 hunk ./actions/newnotice.php 46
5569 -       function save_new_notice() {
5570 +    function save_new_notice() {
5571 hunk ./actions/newnotice.php 48
5572 -               $user = common_current_user();
5573 -               assert($user); # XXX: maybe an error instead...
5574 -               $content = $this->trimmed('status_textarea');
5575 +        $user = common_current_user();
5576 +        assert($user); # XXX: maybe an error instead...
5577 +        $content = $this->trimmed('status_textarea');
5578 hunk ./actions/newnotice.php 52
5579 -               if (!$content) {
5580 -                       $this->show_form(_('No content!'));
5581 -                       return;
5582 -               } else {
5583 -                       $content_shortened = common_shorten_links($content);
5584 +        if (!$content) {
5585 +            $this->show_form(_('No content!'));
5586 +            return;
5587 +        } else {
5588 +            $content_shortened = common_shorten_links($content);
5589 hunk ./actions/newnotice.php 58
5590 -                       if (mb_strlen($content_shortened) > 140) {
5591 -                               common_debug("Content = '$content_shortened'", __FILE__);
5592 -                               common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
5593 -                               $this->show_form(_('That\'s too long. Max notice size is 140 chars.'));
5594 -                               return;
5595 -                       }
5596 -               }
5597 +            if (mb_strlen($content_shortened) > 140) {
5598 +                common_debug("Content = '$content_shortened'", __FILE__);
5599 +                common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__);
5600 +                $this->show_form(_('That\'s too long. Max notice size is 140 chars.'));
5601 +                return;
5602 +            }
5603 +        }
5604 hunk ./actions/newnotice.php 66
5605 -               $inter = new CommandInterpreter();
5606 +        $inter = new CommandInterpreter();
5607 hunk ./actions/newnotice.php 68
5608 -               $cmd = $inter->handle_command($user, $content_shortened);
5609 +        $cmd = $inter->handle_command($user, $content_shortened);
5610 hunk ./actions/newnotice.php 70
5611 -               if ($cmd) {
5612 -                       if ($this->boolean('ajax')) {
5613 -                               $cmd->execute(new AjaxWebChannel());
5614 -                       } else {
5615 -                               $cmd->execute(new WebChannel());
5616 -                       }
5617 -                       return;
5618 -               }
5619 +        if ($cmd) {
5620 +            if ($this->boolean('ajax')) {
5621 +                $cmd->execute(new AjaxWebChannel());
5622 +            } else {
5623 +                $cmd->execute(new WebChannel());
5624 +            }
5625 +            return;
5626 +        }
5627 hunk ./actions/newnotice.php 79
5628 -               $replyto = $this->trimmed('inreplyto');
5629 +        $replyto = $this->trimmed('inreplyto');
5630 hunk ./actions/newnotice.php 81
5631 -               $notice = Notice::saveNew($user->id, $content, 'web', 1, ($replyto == 'false') ? NULL : $replyto);
5632 +        $notice = Notice::saveNew($user->id, $content, 'web', 1, ($replyto == 'false') ? NULL : $replyto);
5633 hunk ./actions/newnotice.php 83
5634 -               if (is_string($notice)) {
5635 -                       $this->show_form($notice);
5636 -                       return;
5637 -               }
5638 +        if (is_string($notice)) {
5639 +            $this->show_form($notice);
5640 +            return;
5641 +        }
5642 hunk ./actions/newnotice.php 88
5643 -               common_broadcast_notice($notice);
5644 +        common_broadcast_notice($notice);
5645 hunk ./actions/newnotice.php 90
5646 -               if ($this->boolean('ajax')) {
5647 -                       common_start_html('text/xml;charset=utf-8', true);
5648 -                       common_element_start('head');
5649 -                       common_element('title', null, _('Notice posted'));
5650 -                       common_element_end('head');
5651 -                       common_element_start('body');
5652 -                       $this->show_notice($notice);
5653 -                       common_element_end('body');
5654 -                       common_element_end('html');
5655 -               } else {
5656 -                       $returnto = $this->trimmed('returnto');
5657 +        if ($this->boolean('ajax')) {
5658 +            common_start_html('text/xml;charset=utf-8', true);
5659 +            common_element_start('head');
5660 +            common_element('title', null, _('Notice posted'));
5661 +            common_element_end('head');
5662 +            common_element_start('body');
5663 +            $this->show_notice($notice);
5664 +            common_element_end('body');
5665 +            common_element_end('html');
5666 +        } else {
5667 +            $returnto = $this->trimmed('returnto');
5668 hunk ./actions/newnotice.php 102
5669 -                       if ($returnto) {
5670 -                               $url = common_local_url($returnto,
5671 -                                                                               array('nickname' => $user->nickname));
5672 -                       } else {
5673 -                               $url = common_local_url('shownotice',
5674 -                                                                               array('notice' => $notice->id));
5675 -                       }
5676 -                       common_redirect($url, 303);
5677 -               }
5678 -       }
5679 +            if ($returnto) {
5680 +                $url = common_local_url($returnto,
5681 +                                        array('nickname' => $user->nickname));
5682 +            } else {
5683 +                $url = common_local_url('shownotice',
5684 +                                        array('notice' => $notice->id));
5685 +            }
5686 +            common_redirect($url, 303);
5687 +        }
5688 +    }
5689 hunk ./actions/newnotice.php 113
5690 -       function ajax_error_msg($msg) {
5691 -               common_start_html('text/xml;charset=utf-8', true);
5692 -               common_element_start('head');
5693 -               common_element('title', null, _('Ajax Error'));
5694 -               common_element_end('head');
5695 -               common_element_start('body');
5696 -               common_element('p', array('id' => 'error'), $msg);
5697 -               common_element_end('body');
5698 -               common_element_end('html');
5699 -       }
5700 +    function ajax_error_msg($msg) {
5701 +        common_start_html('text/xml;charset=utf-8', true);
5702 +        common_element_start('head');
5703 +        common_element('title', null, _('Ajax Error'));
5704 +        common_element_end('head');
5705 +        common_element_start('body');
5706 +        common_element('p', array('id' => 'error'), $msg);
5707 +        common_element_end('body');
5708 +        common_element_end('html');
5709 +    }
5710 hunk ./actions/newnotice.php 124
5711 -       function show_top($content=NULL) {
5712 -               common_notice_form(NULL, $content);
5713 -       }
5714 +    function show_top($content=NULL) {
5715 +        common_notice_form(NULL, $content);
5716 +    }
5717 hunk ./actions/newnotice.php 128
5718 -       function show_form($msg=NULL) {
5719 -               if ($msg && $this->boolean('ajax')) {
5720 -                       $this->ajax_error_msg($msg);
5721 -                       return;
5722 -               }
5723 -               $content = $this->trimmed('status_textarea');
5724 -               if (!$content) {
5725 -                       $replyto = $this->trimmed('replyto');
5726 -                       $profile = Profile::staticGet('nickname', $replyto);
5727 -                       if ($profile) {
5728 -                               $content = '@' . $profile->nickname . ' ';
5729 -                       }
5730 -               }
5731 -               common_show_header(_('New notice'), NULL, $content,
5732 -                                                  array($this, 'show_top'));
5733 -               if ($msg) {
5734 -                       common_element('p', array('id' => 'error'), $msg);
5735 -               }
5736 -               common_show_footer();
5737 -       }
5738 +    function show_form($msg=NULL) {
5739 +        if ($msg && $this->boolean('ajax')) {
5740 +            $this->ajax_error_msg($msg);
5741 +            return;
5742 +        }
5743 +        $content = $this->trimmed('status_textarea');
5744 +        if (!$content) {
5745 +            $replyto = $this->trimmed('replyto');
5746 +            $profile = Profile::staticGet('nickname', $replyto);
5747 +            if ($profile) {
5748 +                $content = '@' . $profile->nickname . ' ';
5749 +            }
5750 +        }
5751 +        common_show_header(_('New notice'), NULL, $content,
5752 +                           array($this, 'show_top'));
5753 +        if ($msg) {
5754 +            common_element('p', array('id' => 'error'), $msg);
5755 +        }
5756 +        common_show_footer();
5757 +    }
5758 hunk ./actions/newnotice.php 149
5759 -       function show_notice($notice) {
5760 +    function show_notice($notice) {
5761 hunk ./actions/newnotice.php 152
5762 -       }
5763 +    }
5764 hunk ./actions/noticesearch.php 28
5765 -       function get_instructions() {
5766 -               return _('Search for notices on %%site.name%% by their contents. Separate search terms by spaces; they must be 3 characters or more.');
5767 -       }
5768 +    function get_instructions() {
5769 +        return _('Search for notices on %%site.name%% by their contents. Separate search terms by spaces; they must be 3 characters or more.');
5770 +    }
5771 hunk ./actions/noticesearch.php 32
5772 -       function get_title() {
5773 -               return _('Text search');
5774 -       }
5775 +    function get_title() {
5776 +        return _('Text search');
5777 +    }
5778 hunk ./actions/noticesearch.php 36
5779 -       function show_results($q, $page) {
5780 +    function show_results($q, $page) {
5781 hunk ./actions/noticesearch.php 38
5782 -               $notice = new Notice();
5783 +        $notice = new Notice();
5784 hunk ./actions/noticesearch.php 40
5785 -               # lcase it for comparison
5786 -               $q = strtolower($q);
5787 +        # lcase it for comparison
5788 +        $q = strtolower($q);
5789 hunk ./actions/noticesearch.php 46
5790 -               # Ask for an extra to see if there's more.
5791 -               $search_engine->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
5792 +        # Ask for an extra to see if there's more.
5793 +        $search_engine->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
5794 hunk ./actions/noticesearch.php 53
5795 -               $cnt = $notice->find();
5796 +            $cnt = $notice->find();
5797 +        }
5798 +        if ($cnt > 0) {
5799 +            $terms = preg_split('/[\s,]+/', $q);
5800 +            common_element_start('ul', array('id' => 'notices'));
5801 +            for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
5802 +                if ($notice->fetch()) {
5803 +                    $this->show_notice($notice, $terms);
5804 +                } else {
5805 +                    // shouldn't happen!
5806 +                    break;
5807 +                }
5808 +            }
5809 +            common_element_end('ul');
5810 +        } else {
5811 +            common_element('p', 'error', _('No results'));
5812 hunk ./actions/noticesearch.php 70
5813 -               if ($cnt > 0) {
5814 -                       $terms = preg_split('/[\s,]+/', $q);
5815 -                       common_element_start('ul', array('id' => 'notices'));
5816 -                       for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) {
5817 -                               if ($notice->fetch()) {
5818 -                                       $this->show_notice($notice, $terms);
5819 -                               } else {
5820 -                                       // shouldn't happen!
5821 -                                       break;
5822 -                               }
5823 -                       }
5824 -                       common_element_end('ul');
5825 -               } else {
5826 -                       common_element('p', 'error', _('No results'));
5827 -               }
5828 hunk ./actions/noticesearch.php 71
5829 -               common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
5830 -                                                 $page, 'noticesearch', array('q' => $q));
5831 -       }
5832 +        common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
5833 +                          $page, 'noticesearch', array('q' => $q));
5834 +    }
5835 hunk ./actions/noticesearch.php 75
5836 -       function show_header($arr) {
5837 -               if ($arr) {
5838 -                       $q = $arr[0];
5839 -               }
5840 -               if ($q) {
5841 -                       common_element('link', array('rel' => 'alternate',
5842 -                                                                                'href' => common_local_url('noticesearchrss',
5843 -                                                                                                                                       array('q' => $q)),
5844 -                                                                                'type' => 'application/rss+xml',
5845 -                                                                                'title' => _('Search Stream Feed')));
5846 -               }
5847 -       }
5848 +    function show_header($arr) {
5849 +        if ($arr) {
5850 +            $q = $arr[0];
5851 +        }
5852 +        if ($q) {
5853 +            common_element('link', array('rel' => 'alternate',
5854 +                                         'href' => common_local_url('noticesearchrss',
5855 +                                                                    array('q' => $q)),
5856 +                                         'type' => 'application/rss+xml',
5857 +                                         'title' => _('Search Stream Feed')));
5858 +        }
5859 +    }
5860 hunk ./actions/noticesearch.php 88
5861 -       # XXX: refactor and combine with StreamAction::show_notice()
5862 +    # XXX: refactor and combine with StreamAction::show_notice()
5863 hunk ./actions/noticesearch.php 90
5864 -       function show_notice($notice, $terms) {
5865 -               $profile = $notice->getProfile();
5866 -               if (!$profile) {
5867 -                       common_log_db_error($notice, 'SELECT', __FILE__);
5868 -                       $this->server_error(_('Notice without matching profile'));
5869 -                       return;
5870 -               }
5871 -               # XXX: RDFa
5872 -               common_element_start('li', array('class' => 'notice_single',
5873 -                                                                                 'id' => 'notice-' . $notice->id));
5874 -               $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
5875 -               common_element_start('a', array('href' => $profile->profileurl));
5876 -               common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
5877 -                                                                       'class' => 'avatar stream',
5878 -                                                                       'width' => AVATAR_STREAM_SIZE,
5879 -                                                                       'height' => AVATAR_STREAM_SIZE,
5880 -                                                                       'alt' =>
5881 -                                                                       ($profile->fullname) ? $profile->fullname :
5882 -                                                                       $profile->nickname));
5883 -               common_element_end('a');
5884 -               common_element('a', array('href' => $profile->profileurl,
5885 -                                                                 'class' => 'nickname'),
5886 -                                          $profile->nickname);
5887 -               # FIXME: URL, image, video, audio
5888 -               common_element_start('p', array('class' => 'content'));
5889 -               if ($notice->rendered) {
5890 -                       common_raw($this->highlight($notice->rendered, $terms));
5891 -               } else {
5892 -                       # XXX: may be some uncooked notices in the DB,
5893 -                       # we cook them right now. This should probably disappear in future
5894 -                       # versions (>> 0.4.x)
5895 -                       common_raw($this->highlight(common_render_content($notice->content, $notice), $terms));
5896 -               }
5897 -               common_element_end('p');
5898 -               $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
5899 -               common_element_start('p', 'time');
5900 -               common_element('a', array('class' => 'permalink',
5901 -                                                                 'href' => $noticeurl,
5902 -                                                                 'title' => common_exact_date($notice->created)),
5903 -                                          common_date_string($notice->created));
5904 -               if ($notice->reply_to) {
5905 -                       $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
5906 -                       common_text(' (');
5907 -                       common_element('a', array('class' => 'inreplyto',
5908 -                                                                         'href' => $replyurl),
5909 -                                                  _('in reply to...'));
5910 -                       common_text(')');
5911 -               }
5912 -               common_element_start('a',
5913 -                                                        array('href' => common_local_url('newnotice',
5914 -                                                                                                                         array('replyto' => $profile->nickname)),
5915 -                                                                  'onclick' => 'doreply("'.$profile->nickname.'"); return false',
5916 -                                                                  'title' => _('reply'),
5917 -                                                                  'class' => 'replybutton'));
5918 -               common_hidden('posttoken', common_session_token());
5919 -               
5920 -               common_raw('&rarr;');
5921 -               common_element_end('a');
5922 -               common_element_end('p');
5923 -               common_element_end('li');
5924 -       }
5925 +    function show_notice($notice, $terms) {
5926 +        $profile = $notice->getProfile();
5927 +        if (!$profile) {
5928 +            common_log_db_error($notice, 'SELECT', __FILE__);
5929 +            $this->server_error(_('Notice without matching profile'));
5930 +            return;
5931 +        }
5932 +        # XXX: RDFa
5933 +        common_element_start('li', array('class' => 'notice_single',
5934 +                                          'id' => 'notice-' . $notice->id));
5935 +        $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
5936 +        common_element_start('a', array('href' => $profile->profileurl));
5937 +        common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
5938 +                                    'class' => 'avatar stream',
5939 +                                    'width' => AVATAR_STREAM_SIZE,
5940 +                                    'height' => AVATAR_STREAM_SIZE,
5941 +                                    'alt' =>
5942 +                                    ($profile->fullname) ? $profile->fullname :
5943 +                                    $profile->nickname));
5944 +        common_element_end('a');
5945 +        common_element('a', array('href' => $profile->profileurl,
5946 +                                  'class' => 'nickname'),
5947 +                       $profile->nickname);
5948 +        # FIXME: URL, image, video, audio
5949 +        common_element_start('p', array('class' => 'content'));
5950 +        if ($notice->rendered) {
5951 +            common_raw($this->highlight($notice->rendered, $terms));
5952 +        } else {
5953 +            # XXX: may be some uncooked notices in the DB,
5954 +            # we cook them right now. This should probably disappear in future
5955 +            # versions (>> 0.4.x)
5956 +            common_raw($this->highlight(common_render_content($notice->content, $notice), $terms));
5957 +        }
5958 +        common_element_end('p');
5959 +        $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
5960 +        common_element_start('p', 'time');
5961 +        common_element('a', array('class' => 'permalink',
5962 +                                  'href' => $noticeurl,
5963 +                                  'title' => common_exact_date($notice->created)),
5964 +                       common_date_string($notice->created));
5965 +        if ($notice->reply_to) {
5966 +            $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
5967 +            common_text(' (');
5968 +            common_element('a', array('class' => 'inreplyto',
5969 +                                      'href' => $replyurl),
5970 +                           _('in reply to...'));
5971 +            common_text(')');
5972 +        }
5973 +        common_element_start('a',
5974 +                             array('href' => common_local_url('newnotice',
5975 +                                                              array('replyto' => $profile->nickname)),
5976 +                                   'onclick' => 'doreply("'.$profile->nickname.'"); return false',
5977 +                                   'title' => _('reply'),
5978 +                                   'class' => 'replybutton'));
5979 +        common_hidden('posttoken', common_session_token());
5980 +        
5981 +        common_raw('&rarr;');
5982 +        common_element_end('a');
5983 +        common_element_end('p');
5984 +        common_element_end('li');
5985 +    }
5986 hunk ./actions/noticesearch.php 152
5987 -       function highlight($text, $terms) {
5988 -               /* Highligh serach terms */
5989 -               $pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i';
5990 -               $result = preg_replace($pattern, '<strong>\\1</strong>', $text);
5991 +    function highlight($text, $terms) {
5992 +        /* Highligh serach terms */
5993 +        $pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i';
5994 +        $result = preg_replace($pattern, '<strong>\\1</strong>', $text);
5995 hunk ./actions/noticesearch.php 157
5996 -               /* Remove highlighting from inside links, loop incase multiple highlights in links */
5997 -               $pattern = '/(href="[^"]*)<strong>('.implode('|',array_map('htmlspecialchars', $terms)).')<\/strong>([^"]*")/iU';
5998 -               do {
5999 -                       $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count);
6000 -               } while ($count);
6001 -               return $result;
6002 -       }
6003 +        /* Remove highlighting from inside links, loop incase multiple highlights in links */
6004 +        $pattern = '/(href="[^"]*)<strong>('.implode('|',array_map('htmlspecialchars', $terms)).')<\/strong>([^"]*")/iU';
6005 +        do {
6006 +            $result = preg_replace($pattern, '\\1\\2\\3', $result, -1, $count);
6007 +        } while ($count);
6008 +        return $result;
6009 +    }
6010 hunk ./actions/noticesearchrss.php 28
6011 -       function init() {
6012 -               return true;
6013 -       }
6014 +    function init() {
6015 +        return true;
6016 +    }
6017 hunk ./actions/noticesearchrss.php 32
6018 -       function get_notices($limit=0) {
6019 +    function get_notices($limit=0) {
6020 hunk ./actions/noticesearchrss.php 34
6021 -               $q = $this->trimmed('q');
6022 -               $notices = array();
6023 +        $q = $this->trimmed('q');
6024 +        $notices = array();
6025 hunk ./actions/noticesearchrss.php 37
6026 -               $notice = new Notice();
6027 +        $notice = new Notice();
6028 hunk ./actions/noticesearchrss.php 39
6029 -               # lcase it for comparison
6030 -               $q = strtolower($q);
6031 +        # lcase it for comparison
6032 +        $q = strtolower($q);
6033 hunk ./actions/noticesearchrss.php 45
6034 -               if (!$limit) $limit = 20;
6035 +        if (!$limit) $limit = 20;
6036 hunk ./actions/noticesearchrss.php 48
6037 -               $notice->find();
6038 +        $notice->find();
6039 hunk ./actions/noticesearchrss.php 50
6040 -               while ($notice->fetch()) {
6041 -                       $notices[] = clone($notice);
6042 -               }
6043 +        while ($notice->fetch()) {
6044 +            $notices[] = clone($notice);
6045 +        }
6046 hunk ./actions/noticesearchrss.php 54
6047 -               return $notices;
6048 -       }
6049 +        return $notices;
6050 +    }
6051 hunk ./actions/noticesearchrss.php 57
6052 -       function get_channel() {
6053 -               global $config;
6054 -               $q = $this->trimmed('q');
6055 -               $c = array('url' => common_local_url('noticesearchrss', array('q' => $q)),
6056 -                                  'title' => $config['site']['name'] . sprintf(_(' Search Stream for "%s"'), $q),
6057 -                                  'link' => common_local_url('noticesearch', array('q' => $q)),
6058 -                                  'description' => sprintf(_('All updates matching search term "%s"'), $q));
6059 -               return $c;
6060 -       }
6061 +    function get_channel() {
6062 +        global $config;
6063 +        $q = $this->trimmed('q');
6064 +        $c = array('url' => common_local_url('noticesearchrss', array('q' => $q)),
6065 +                   'title' => $config['site']['name'] . sprintf(_(' Search Stream for "%s"'), $q),
6066 +                   'link' => common_local_url('noticesearch', array('q' => $q)),
6067 +                   'description' => sprintf(_('All updates matching search term "%s"'), $q));
6068 +        return $c;
6069 +    }
6070 hunk ./actions/noticesearchrss.php 67
6071 -       function get_image() {
6072 -               return NULL;
6073 -       }
6074 +    function get_image() {
6075 +        return NULL;
6076 +    }
6077 hunk ./actions/nudge.php 26
6078 -       function handle($args) {
6079 -               parent::handle($args);
6080 +    function handle($args) {
6081 +        parent::handle($args);
6082 hunk ./actions/nudge.php 29
6083 -               if (!common_logged_in()) {
6084 -                       $this->client_error(_('Not logged in.'));
6085 -                       return;
6086 -               }
6087 +        if (!common_logged_in()) {
6088 +            $this->client_error(_('Not logged in.'));
6089 +            return;
6090 +        }
6091 hunk ./actions/nudge.php 34
6092 -               $user = common_current_user();
6093 -               $other = User::staticGet('nickname', $this->arg('nickname'));
6094 +        $user = common_current_user();
6095 +        $other = User::staticGet('nickname', $this->arg('nickname'));
6096 hunk ./actions/nudge.php 37
6097 -               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
6098 -                       common_redirect(common_local_url('showstream', array('nickname' => $other->nickname)));
6099 -                       return;
6100 -               }
6101 +        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
6102 +            common_redirect(common_local_url('showstream', array('nickname' => $other->nickname)));
6103 +            return;
6104 +        }
6105 hunk ./actions/nudge.php 42
6106 -               # CSRF protection
6107 +        # CSRF protection
6108 hunk ./actions/nudge.php 44
6109 -               $token = $this->trimmed('token');
6110 -               
6111 -               if (!$token || $token != common_session_token()) {
6112 -                       $this->client_error(_('There was a problem with your session token. Try again, please.'));
6113 -                       return;
6114 -               }
6115 +        $token = $this->trimmed('token');
6116 +        
6117 +        if (!$token || $token != common_session_token()) {
6118 +            $this->client_error(_('There was a problem with your session token. Try again, please.'));
6119 +            return;
6120 +        }
6121 hunk ./actions/nudge.php 56
6122 -               $this->notify($user, $other);
6123 +        $this->notify($user, $other);
6124 hunk ./actions/nudge.php 58
6125 -               if ($this->boolean('ajax')) {
6126 -                       common_start_html('text/xml;charset=utf-8', true);
6127 -                       common_element_start('head');
6128 -                       common_element('title', null, _('Nudge sent'));
6129 -                       common_element_end('head');
6130 -                       common_element_start('body');
6131 -                       common_nudge_response();
6132 -                       common_element_end('body');
6133 -                       common_element_end('html');
6134 -               } else {
6135 +        if ($this->boolean('ajax')) {
6136 +            common_start_html('text/xml;charset=utf-8', true);
6137 +            common_element_start('head');
6138 +            common_element('title', null, _('Nudge sent'));
6139 +            common_element_end('head');
6140 +            common_element_start('body');
6141 +            common_nudge_response();
6142 +            common_element_end('body');
6143 +            common_element_end('html');
6144 +        } else {
6145 hunk ./actions/nudge.php 69
6146 -                       common_redirect(common_local_url('showstream',
6147 -                                                                                        array('nickname' => $other->nickname)));
6148 -               }
6149 -       }
6150 +            common_redirect(common_local_url('showstream',
6151 +                                             array('nickname' => $other->nickname)));
6152 +        }
6153 +    }
6154 hunk ./actions/nudge.php 74
6155 -       function notify($user, $other) {
6156 -               if ($other->id != $user->id) {
6157 -                       if ($other->email && $other->emailnotifynudge) {
6158 -                               mail_notify_nudge($user, $other);
6159 -                       }
6160 -                       # XXX: notify by IM
6161 -                       # XXX: notify by SMS
6162 -               }
6163 -       }
6164 +    function notify($user, $other) {
6165 +        if ($other->id != $user->id) {
6166 +            if ($other->email && $other->emailnotifynudge) {
6167 +                mail_notify_nudge($user, $other);
6168 +            }
6169 +            # XXX: notify by IM
6170 +            # XXX: notify by SMS
6171 +        }
6172 +    }
6173 hunk ./actions/openidlogin.php 26
6174 -       function handle($args) {
6175 -               parent::handle($args);
6176 -               if (common_logged_in()) {
6177 -                       common_user_error(_('Already logged in.'));
6178 -               } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
6179 -                       $openid_url = $this->trimmed('openid_url');
6180 +    function handle($args) {
6181 +        parent::handle($args);
6182 +        if (common_logged_in()) {
6183 +            common_user_error(_('Already logged in.'));
6184 +        } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
6185 +            $openid_url = $this->trimmed('openid_url');
6186 hunk ./actions/openidlogin.php 33
6187 -                       # CSRF protection
6188 -                       $token = $this->trimmed('token');
6189 -                       if (!$token || $token != common_session_token()) {
6190 -                               $this->show_form(_('There was a problem with your session token. Try again, please.'), $openid_url);
6191 -                               return;
6192 -                       }
6193 +            # CSRF protection
6194 +            $token = $this->trimmed('token');
6195 +            if (!$token || $token != common_session_token()) {
6196 +                $this->show_form(_('There was a problem with your session token. Try again, please.'), $openid_url);
6197 +                return;
6198 +            }
6199 hunk ./actions/openidlogin.php 40
6200 -                       $rememberme = $this->boolean('rememberme');
6201 -                       
6202 -                       common_ensure_session();
6203 -                       
6204 -                       $_SESSION['openid_rememberme'] = $rememberme;
6205 -                       
6206 -                       $result = oid_authenticate($openid_url,
6207 -                                                                          'finishopenidlogin');
6208 -                       
6209 -                       if (is_string($result)) { # error message
6210 -                               unset($_SESSION['openid_rememberme']);
6211 -                               $this->show_form($result, $openid_url);
6212 -                       }
6213 -               } else {
6214 -                       $openid_url = oid_get_last();
6215 -                       $this->show_form(NULL, $openid_url);
6216 -               }
6217 -       }
6218 +            $rememberme = $this->boolean('rememberme');
6219 +            
6220 +            common_ensure_session();
6221 +            
6222 +            $_SESSION['openid_rememberme'] = $rememberme;
6223 +            
6224 +            $result = oid_authenticate($openid_url,
6225 +                                       'finishopenidlogin');
6226 +            
6227 +            if (is_string($result)) { # error message
6228 +                unset($_SESSION['openid_rememberme']);
6229 +                $this->show_form($result, $openid_url);
6230 +            }
6231 +        } else {
6232 +            $openid_url = oid_get_last();
6233 +            $this->show_form(NULL, $openid_url);
6234 +        }
6235 +    }
6236 hunk ./actions/openidlogin.php 59
6237 -       function get_instructions() {
6238 -               return _('Login with an [OpenID](%%doc.openid%%) account.');
6239 -       }
6240 +    function get_instructions() {
6241 +        return _('Login with an [OpenID](%%doc.openid%%) account.');
6242 +    }
6243 hunk ./actions/openidlogin.php 63
6244 -       function show_top($error=NULL) {
6245 -               if ($error) {
6246 -                       common_element('div', array('class' => 'error'), $error);
6247 -               } else {
6248 -                       $instr = $this->get_instructions();
6249 -                       $output = common_markup_to_html($instr);
6250 -                       common_element_start('div', 'instructions');
6251 -                       common_raw($output);
6252 -                       common_element_end('div');
6253 -               }
6254 -       }
6255 +    function show_top($error=NULL) {
6256 +        if ($error) {
6257 +            common_element('div', array('class' => 'error'), $error);
6258 +        } else {
6259 +            $instr = $this->get_instructions();
6260 +            $output = common_markup_to_html($instr);
6261 +            common_element_start('div', 'instructions');
6262 +            common_raw($output);
6263 +            common_element_end('div');
6264 +        }
6265 +    }
6266 hunk ./actions/openidlogin.php 75
6267 -       function show_form($error=NULL, $openid_url) {
6268 -               common_show_header(_('OpenID Login'), NULL, $error, array($this, 'show_top'));
6269 -               $formaction = common_local_url('openidlogin');
6270 -               common_element_start('form', array('method' => 'post',
6271 -                                                                                  'id' => 'openidlogin',
6272 -                                                                                  'action' => $formaction));
6273 -               common_hidden('token', common_session_token());
6274 -               common_input('openid_url', _('OpenID URL'),
6275 -                                        $openid_url,
6276 -                                        _('Your OpenID URL'));
6277 -               common_checkbox('rememberme', _('Remember me'), false,
6278 -                               _('Automatically login in the future; ' .
6279 -                                  'not for shared computers!'));
6280 -               common_submit('submit', _('Login'));
6281 -               common_element_end('form');
6282 -               common_show_footer();
6283 -       }
6284 +    function show_form($error=NULL, $openid_url) {
6285 +        common_show_header(_('OpenID Login'), NULL, $error, array($this, 'show_top'));
6286 +        $formaction = common_local_url('openidlogin');
6287 +        common_element_start('form', array('method' => 'post',
6288 +                                           'id' => 'openidlogin',
6289 +                                           'action' => $formaction));
6290 +        common_hidden('token', common_session_token());
6291 +        common_input('openid_url', _('OpenID URL'),
6292 +                     $openid_url,
6293 +                     _('Your OpenID URL'));
6294 +        common_checkbox('rememberme', _('Remember me'), false,
6295 +                        _('Automatically login in the future; ' .
6296 +                           'not for shared computers!'));
6297 +        common_submit('submit', _('Login'));
6298 +        common_element_end('form');
6299 +        common_show_footer();
6300 +    }
6301 hunk ./actions/openidsettings.php 27
6302 -       function get_instructions() {
6303 -               return _('[OpenID](%%doc.openid%%) lets you log into many sites ' .
6304 -                         ' with the same user account. '.
6305 -                         ' Manage your associated OpenIDs from here.');
6306 -       }
6307 +    function get_instructions() {
6308 +        return _('[OpenID](%%doc.openid%%) lets you log into many sites ' .
6309 +                  ' with the same user account. '.
6310 +                  ' Manage your associated OpenIDs from here.');
6311 +    }
6312 hunk ./actions/openidsettings.php 33
6313 -       function show_form($msg=NULL, $success=false) {
6314 +    function show_form($msg=NULL, $success=false) {
6315 hunk ./actions/openidsettings.php 35
6316 -               $user = common_current_user();
6317 +        $user = common_current_user();
6318 hunk ./actions/openidsettings.php 37
6319 -               $this->form_header(_('OpenID settings'), $msg, $success);
6320 +        $this->form_header(_('OpenID settings'), $msg, $success);
6321 hunk ./actions/openidsettings.php 39
6322 -               common_element_start('form', array('method' => 'post',
6323 -                                                                                  'id' => 'openidadd',
6324 -                                                                                  'action' =>
6325 -                                                                                  common_local_url('openidsettings')));
6326 -               common_hidden('token', common_session_token());
6327 -               common_element('h2', NULL, _('Add OpenID'));
6328 -               common_element('p', NULL,
6329 -                                          _('If you want to add an OpenID to your account, ' .
6330 -                                                 'enter it in the box below and click "Add".'));
6331 -               common_element_start('p');
6332 -               common_element('label', array('for' => 'openid_url'),
6333 -                                          _('OpenID URL'));
6334 -               common_element('input', array('name' => 'openid_url',
6335 -                                                                         'type' => 'text',
6336 -                                                                         'id' => 'openid_url'));
6337 -               common_element('input', array('type' => 'submit',
6338 -                                                                         'id' => 'add',
6339 -                                                                         'name' => 'add',
6340 -                                                                         'class' => 'submit',
6341 -                                                                         'value' => _('Add')));
6342 -               common_element_end('p');
6343 -               common_element_end('form');
6344 +        common_element_start('form', array('method' => 'post',
6345 +                                           'id' => 'openidadd',
6346 +                                           'action' =>
6347 +                                           common_local_url('openidsettings')));
6348 +        common_hidden('token', common_session_token());
6349 +        common_element('h2', NULL, _('Add OpenID'));
6350 +        common_element('p', NULL,
6351 +                       _('If you want to add an OpenID to your account, ' .
6352 +                          'enter it in the box below and click "Add".'));
6353 +        common_element_start('p');
6354 +        common_element('label', array('for' => 'openid_url'),
6355 +                       _('OpenID URL'));
6356 +        common_element('input', array('name' => 'openid_url',
6357 +                                      'type' => 'text',
6358 +                                      'id' => 'openid_url'));
6359 +        common_element('input', array('type' => 'submit',
6360 +                                      'id' => 'add',
6361 +                                      'name' => 'add',
6362 +                                      'class' => 'submit',
6363 +                                      'value' => _('Add')));
6364 +        common_element_end('p');
6365 +        common_element_end('form');
6366 hunk ./actions/openidsettings.php 62
6367 -               $oid = new User_openid();
6368 -               $oid->user_id = $user->id;
6369 +        $oid = new User_openid();
6370 +        $oid->user_id = $user->id;
6371 hunk ./actions/openidsettings.php 65
6372 -               $cnt = $oid->find();
6373 +        $cnt = $oid->find();
6374 hunk ./actions/openidsettings.php 67
6375 -               if ($cnt > 0) {
6376 +        if ($cnt > 0) {
6377 hunk ./actions/openidsettings.php 69
6378 -                       common_element('h2', NULL, _('Remove OpenID'));
6379 +            common_element('h2', NULL, _('Remove OpenID'));
6380 hunk ./actions/openidsettings.php 71
6381 -                       if ($cnt == 1 && !$user->password) {
6382 +            if ($cnt == 1 && !$user->password) {
6383 hunk ./actions/openidsettings.php 73
6384 -                               common_element('p', NULL,
6385 -                                                          _('Removing your only OpenID would make it impossible to log in! ' .
6386 -                                                                 'If you need to remove it, add another OpenID first.'));
6387 +                common_element('p', NULL,
6388 +                               _('Removing your only OpenID would make it impossible to log in! ' .
6389 +                                  'If you need to remove it, add another OpenID first.'));
6390 hunk ./actions/openidsettings.php 77
6391 -                               if ($oid->fetch()) {
6392 -                                       common_element_start('p');
6393 -                                       common_element('a', array('href' => $oid->canonical),
6394 -                                                                  $oid->display);
6395 -                                       common_element_end('p');
6396 -                               }
6397 +                if ($oid->fetch()) {
6398 +                    common_element_start('p');
6399 +                    common_element('a', array('href' => $oid->canonical),
6400 +                                   $oid->display);
6401 +                    common_element_end('p');
6402 +                }
6403 hunk ./actions/openidsettings.php 84
6404 -                       } else {
6405 +            } else {
6406 hunk ./actions/openidsettings.php 86
6407 -                               common_element('p', NULL,
6408 -                                                          _('You can remove an OpenID from your account '.
6409 -                                                                 'by clicking the button marked "Remove".'));
6410 -                               $idx = 0;
6411 +                common_element('p', NULL,
6412 +                               _('You can remove an OpenID from your account '.
6413 +                                  'by clicking the button marked "Remove".'));
6414 +                $idx = 0;
6415 hunk ./actions/openidsettings.php 91
6416 -                               while ($oid->fetch()) {
6417 -                                       common_element_start('form', array('method' => 'POST',
6418 -                                                                                                          'id' => 'openiddelete' . $idx,
6419 -                                                                                                          'action' =>
6420 -                                                                                                          common_local_url('openidsettings')));
6421 -                                       common_element_start('p');
6422 -                                       common_hidden('token', common_session_token());
6423 -                                       common_element('a', array('href' => $oid->canonical),
6424 -                                                                  $oid->display);
6425 -                                       common_element('input', array('type' => 'hidden',
6426 -                                                                                                 'id' => 'openid_url'.$idx,
6427 -                                                                                                 'name' => 'openid_url',
6428 -                                                                                                 'value' => $oid->canonical));
6429 -                                       common_element('input', array('type' => 'submit',
6430 -                                                                                                 'id' => 'remove'.$idx,
6431 -                                                                                                 'name' => 'remove',
6432 -                                                                                                 'class' => 'submit',
6433 -                                                                                                 'value' => _('Remove')));
6434 -                                       common_element_end('p');
6435 -                                       common_element_end('form');
6436 -                                       $idx++;
6437 -                               }
6438 -                       }
6439 -               }
6440 +                while ($oid->fetch()) {
6441 +                    common_element_start('form', array('method' => 'POST',
6442 +                                                       'id' => 'openiddelete' . $idx,
6443 +                                                       'action' =>
6444 +                                                       common_local_url('openidsettings')));
6445 +                    common_element_start('p');
6446 +                    common_hidden('token', common_session_token());
6447 +                    common_element('a', array('href' => $oid->canonical),
6448 +                                   $oid->display);
6449 +                    common_element('input', array('type' => 'hidden',
6450 +                                                  'id' => 'openid_url'.$idx,
6451 +                                                  'name' => 'openid_url',
6452 +                                                  'value' => $oid->canonical));
6453 +                    common_element('input', array('type' => 'submit',
6454 +                                                  'id' => 'remove'.$idx,
6455 +                                                  'name' => 'remove',
6456 +                                                  'class' => 'submit',
6457 +                                                  'value' => _('Remove')));
6458 +                    common_element_end('p');
6459 +                    common_element_end('form');
6460 +                    $idx++;
6461 +                }
6462 +            }
6463 +        }
6464 hunk ./actions/openidsettings.php 116
6465 -               common_show_footer();
6466 -       }
6467 +        common_show_footer();
6468 +    }
6469 hunk ./actions/openidsettings.php 119
6470 -       function handle_post() {
6471 -               # CSRF protection
6472 -               $token = $this->trimmed('token');
6473 -               if (!$token || $token != common_session_token()) {
6474 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
6475 -                       return;
6476 -               }
6477 +    function handle_post() {
6478 +        # CSRF protection
6479 +        $token = $this->trimmed('token');
6480 +        if (!$token || $token != common_session_token()) {
6481 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
6482 +            return;
6483 +        }
6484 hunk ./actions/openidsettings.php 127
6485 -               if ($this->arg('add')) {
6486 -                       $result = oid_authenticate($this->trimmed('openid_url'), 'finishaddopenid');
6487 -                       if (is_string($result)) { # error message
6488 -                               $this->show_form($result);
6489 -                       }
6490 -               } else if ($this->arg('remove')) {
6491 -                       $this->remove_openid();
6492 -               } else {
6493 -                       $this->show_form(_('Something weird happened.'));
6494 -               }
6495 -       }
6496 +        if ($this->arg('add')) {
6497 +            $result = oid_authenticate($this->trimmed('openid_url'), 'finishaddopenid');
6498 +            if (is_string($result)) { # error message
6499 +                $this->show_form($result);
6500 +            }
6501 +        } else if ($this->arg('remove')) {
6502 +            $this->remove_openid();
6503 +        } else {
6504 +            $this->show_form(_('Something weird happened.'));
6505 +        }
6506 +    }
6507 hunk ./actions/openidsettings.php 139
6508 -       function remove_openid() {
6509 +    function remove_openid() {
6510 hunk ./actions/openidsettings.php 141
6511 -               $openid_url = $this->trimmed('openid_url');
6512 -               $oid = User_openid::staticGet('canonical', $openid_url);
6513 -               if (!$oid) {
6514 -                       $this->show_form(_('No such OpenID.'));
6515 -                       return;
6516 -               }
6517 -               $cur = common_current_user();
6518 -               if (!$cur || $oid->user_id != $cur->id) {
6519 -                       $this->show_form(_('That OpenID does not belong to you.'));
6520 -                       return;
6521 -               }
6522 -               $oid->delete();
6523 -               $this->show_form(_('OpenID removed.'), true);
6524 -               return;
6525 -       }
6526 +        $openid_url = $this->trimmed('openid_url');
6527 +        $oid = User_openid::staticGet('canonical', $openid_url);
6528 +        if (!$oid) {
6529 +            $this->show_form(_('No such OpenID.'));
6530 +            return;
6531 +        }
6532 +        $cur = common_current_user();
6533 +        if (!$cur || $oid->user_id != $cur->id) {
6534 +            $this->show_form(_('That OpenID does not belong to you.'));
6535 +            return;
6536 +        }
6537 +        $oid->delete();
6538 +        $this->show_form(_('OpenID removed.'), true);
6539 +        return;
6540 +    }
6541 hunk ./actions/opensearch.php 24
6542 -       function handle($args) {
6543 +    function handle($args) {
6544 hunk ./actions/opensearch.php 26
6545 -               parent::handle($args);
6546 +        parent::handle($args);
6547 hunk ./actions/opensearch.php 28
6548 -               $type = $this->trimmed('type');
6549 +        $type = $this->trimmed('type');
6550 hunk ./actions/opensearch.php 30
6551 -               $short_name = '';
6552 -               if ($type == 'people') {
6553 -                       $type = 'peoplesearch';
6554 -                       $short_name = _('People Search');
6555 -               } else {
6556 -                       $short_name = _('Notice Search');
6557 -                       $type = 'noticesearch';
6558 -               }
6559 +        $short_name = '';
6560 +        if ($type == 'people') {
6561 +            $type = 'peoplesearch';
6562 +            $short_name = _('People Search');
6563 +        } else {
6564 +            $short_name = _('Notice Search');
6565 +            $type = 'noticesearch';
6566 +        }
6567 hunk ./actions/opensearch.php 39
6568 -               header('Content-Type: text/html');
6569 +        header('Content-Type: text/html');
6570 hunk ./actions/opensearch.php 41
6571 -               common_start_xml();
6572 -               common_element_start('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/'));
6573 +        common_start_xml();
6574 +        common_element_start('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/'));
6575 hunk ./actions/opensearch.php 44
6576 -               $short_name =  common_config('site', 'name').' '.$short_name;
6577 -               common_element('ShortName', NULL, $short_name);
6578 -               common_element('Contact', NULL, common_config('site', 'email'));
6579 -               common_element('Url', array('type' => 'text/html', 'method' => 'get',
6580 -                                          'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---')))));
6581 -               common_element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico'));
6582 -               common_element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), theme_path('logo.png'));
6583 -               common_element('AdultContent', NULL, 'false');
6584 -               common_element('Language', NULL, common_language());
6585 -               common_element('OutputEncoding', NULL, 'UTF-8');
6586 -               common_element('InputEncoding', NULL, 'UTF-8');
6587 +        $short_name =  common_config('site', 'name').' '.$short_name;
6588 +        common_element('ShortName', NULL, $short_name);
6589 +        common_element('Contact', NULL, common_config('site', 'email'));
6590 +        common_element('Url', array('type' => 'text/html', 'method' => 'get',
6591 +                       'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---')))));
6592 +        common_element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico'));
6593 +        common_element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), theme_path('logo.png'));
6594 +        common_element('AdultContent', NULL, 'false');
6595 +        common_element('Language', NULL, common_language());
6596 +        common_element('OutputEncoding', NULL, 'UTF-8');
6597 +        common_element('InputEncoding', NULL, 'UTF-8');
6598 hunk ./actions/opensearch.php 56
6599 -               common_element_end('OpenSearchDescription');
6600 -               common_end_xml();
6601 -       }
6602 +        common_element_end('OpenSearchDescription');
6603 +        common_end_xml();
6604 +    }
6605 hunk ./actions/othersettings.php 26
6606 -       function get_instructions() {
6607 -               return _('Manage various other options.');
6608 -       }
6609 +    function get_instructions() {
6610 +        return _('Manage various other options.');
6611 +    }
6612 hunk ./actions/othersettings.php 30
6613 -       function show_form($msg=NULL, $success=false) {
6614 -               $user = common_current_user();
6615 +    function show_form($msg=NULL, $success=false) {
6616 +        $user = common_current_user();
6617 hunk ./actions/othersettings.php 33
6618 -               $this->form_header(_('Other Settings'), $msg, $success);
6619 +        $this->form_header(_('Other Settings'), $msg, $success);
6620 hunk ./actions/othersettings.php 35
6621 -               common_element('h2', NULL, _('URL Auto-shortening'));
6622 -               common_element_start('form', array('method' => 'post',
6623 -                                                                                  'id' => 'othersettings',
6624 -                                                                                  'action' =>
6625 -                                                                                  common_local_url('othersettings')));
6626 -               common_hidden('token', common_session_token());
6627 +        common_element('h2', NULL, _('URL Auto-shortening'));
6628 +        common_element_start('form', array('method' => 'post',
6629 +                                           'id' => 'othersettings',
6630 +                                           'action' =>
6631 +                                           common_local_url('othersettings')));
6632 +        common_hidden('token', common_session_token());
6633 hunk ./actions/othersettings.php 42
6634 -               $services = array(
6635 -                       '' => 'None',
6636 +        $services = array(
6637 +            '' => 'None',
6638 hunk ./actions/othersettings.php 48
6639 -                       'tinyurl.com' => 'tinyurl.com',
6640 -                       'is.gd' => 'is.gd',
6641 -                       'snipr.com' => 'snipr.com',
6642 -                       'metamark.net' => 'metamark.net'
6643 -               );
6644 +            'tinyurl.com' => 'tinyurl.com',
6645 +            'is.gd' => 'is.gd',
6646 +            'snipr.com' => 'snipr.com',
6647 +            'metamark.net' => 'metamark.net'
6648 +        );
6649 hunk ./actions/othersettings.php 54
6650 -               common_dropdown('urlshorteningservice', _('Service'), $services, _('Automatic shortening service to use.'), FALSE, $user->urlshorteningservice);
6651 +        common_dropdown('urlshorteningservice', _('Service'), $services, _('Automatic shortening service to use.'), FALSE, $user->urlshorteningservice);
6652 hunk ./actions/othersettings.php 56
6653 -               common_submit('save', _('Save'));
6654 +        common_submit('save', _('Save'));
6655 hunk ./actions/othersettings.php 58
6656 -               common_element_end('form');
6657 +        common_element_end('form');
6658 hunk ./actions/othersettings.php 60
6659 -//             common_element('h2', NULL, _('Delete my account'));
6660 -//             $this->show_delete_form();
6661 +//        common_element('h2', NULL, _('Delete my account'));
6662 +//        $this->show_delete_form();
6663 hunk ./actions/othersettings.php 63
6664 -               common_show_footer();
6665 -       }
6666 +        common_show_footer();
6667 +    }
6668 hunk ./actions/othersettings.php 66
6669 -       function show_feeds_list($feeds) {
6670 -               common_element_start('div', array('class' => 'feedsdel'));
6671 -               common_element('p', null, 'Feeds:');
6672 -               common_element_start('ul', array('class' => 'xoxo'));
6673 +    function show_feeds_list($feeds) {
6674 +        common_element_start('div', array('class' => 'feedsdel'));
6675 +        common_element('p', null, 'Feeds:');
6676 +        common_element_start('ul', array('class' => 'xoxo'));
6677 hunk ./actions/othersettings.php 71
6678 -               foreach ($feeds as $key => $value) {
6679 -                       $this->common_feed_item($feeds[$key]);
6680 -               }
6681 -               common_element_end('ul');
6682 -               common_element_end('div');
6683 -       }
6684 +        foreach ($feeds as $key => $value) {
6685 +            $this->common_feed_item($feeds[$key]);
6686 +        }
6687 +        common_element_end('ul');
6688 +        common_element_end('div');
6689 +    }
6690 hunk ./actions/othersettings.php 79
6691 -       function common_feed_item($feed) {
6692 +    function common_feed_item($feed) {
6693 hunk ./actions/othersettings.php 81
6694 -               $nickname = $user->nickname;
6695 +        $nickname = $user->nickname;
6696 hunk ./actions/othersettings.php 83
6697 -               switch($feed['item']) {
6698 -                       case 'notices': default:
6699 -                               $feed_classname = $feed['type'];
6700 -                               $feed_mimetype = "application/".$feed['type']."+xml";
6701 -                               $feed_title = "$nickname's ".$feed['version']." notice feed";
6702 -                               $feed['textContent'] = "RSS";
6703 -                               break;
6704 +        switch($feed['item']) {
6705 +            case 'notices': default:
6706 +                $feed_classname = $feed['type'];
6707 +                $feed_mimetype = "application/".$feed['type']."+xml";
6708 +                $feed_title = "$nickname's ".$feed['version']." notice feed";
6709 +                $feed['textContent'] = "RSS";
6710 +                break;
6711 hunk ./actions/othersettings.php 91
6712 -                       case 'foaf':
6713 -                               $feed_classname = "foaf";
6714 -                               $feed_mimetype = "application/".$feed['type']."+xml";
6715 -                               $feed_title = "$nickname's FOAF file";
6716 -                               $feed['textContent'] = "FOAF";
6717 -                               break;
6718 -               }
6719 -               common_element_start('li');
6720 -               common_element('a', array('href' => $feed['href'],
6721 -                                                                 'class' => $feed_classname,
6722 -                                                                 'type' => $feed_mimetype,
6723 -                                                                 'title' => $feed_title),
6724 -                                                       $feed['textContent']);
6725 -               common_element_end('li');
6726 -       }
6727 +            case 'foaf':
6728 +                $feed_classname = "foaf";
6729 +                $feed_mimetype = "application/".$feed['type']."+xml";
6730 +                $feed_title = "$nickname's FOAF file";
6731 +                $feed['textContent'] = "FOAF";
6732 +                break;
6733 +        }
6734 +        common_element_start('li');
6735 +        common_element('a', array('href' => $feed['href'],
6736 +                                  'class' => $feed_classname,
6737 +                                  'type' => $feed_mimetype,
6738 +                                  'title' => $feed_title),
6739 +                            $feed['textContent']);
6740 +        common_element_end('li');
6741 +    }
6742 hunk ./actions/othersettings.php 107
6743 -//     function show_delete_form() {
6744 -//             $user = common_current_user();
6745 +//    function show_delete_form() {
6746 +//        $user = common_current_user();
6747 hunk ./actions/othersettings.php 113
6748 -//             common_element_start('form', array('method' => 'POST',
6749 -//                                                                                'id' => 'delete',
6750 -//                                                                                'action' =>
6751 -//                                                                                common_local_url('deleteprofile')));
6752 +//        common_element_start('form', array('method' => 'POST',
6753 +//                                           'id' => 'delete',
6754 +//                                           'action' =>
6755 +//                                           common_local_url('deleteprofile')));
6756 hunk ./actions/othersettings.php 118
6757 -//             common_hidden('token', common_session_token());
6758 +//        common_hidden('token', common_session_token());
6759 hunk ./actions/othersettings.php 121
6760 -//             $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)),
6761 -//                                                                                       'type' => 'rss',
6762 -//                                                                                       'version' => 'RSS 1.0',
6763 -//                                                                                       'item' => 'notices'),
6764 -//                                                                      1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
6765 -//                                                                                       'type' => 'rdf',
6766 -//                                                                                       'version' => 'FOAF',
6767 -//                                                                                       'item' => 'foaf')));
6768 +//        $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)),
6769 +//                                              'type' => 'rss',
6770 +//                                              'version' => 'RSS 1.0',
6771 +//                                              'item' => 'notices'),
6772 +//                                     1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
6773 +//                                              'type' => 'rdf',
6774 +//                                              'version' => 'FOAF',
6775 +//                                              'item' => 'foaf')));
6776 hunk ./actions/othersettings.php 130
6777 -//             common_submit('deleteaccount', _('Delete my account'));
6778 -//             common_element_end('form');
6779 -//     }
6780 +//        common_submit('deleteaccount', _('Delete my account'));
6781 +//        common_element_end('form');
6782 +//    }
6783 hunk ./actions/othersettings.php 134
6784 -       function handle_post() {
6785 +    function handle_post() {
6786 hunk ./actions/othersettings.php 136
6787 -               # CSRF protection
6788 -               $token = $this->trimmed('token');
6789 -               if (!$token || $token != common_session_token()) {
6790 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
6791 -                       return;
6792 -               }
6793 +        # CSRF protection
6794 +        $token = $this->trimmed('token');
6795 +        if (!$token || $token != common_session_token()) {
6796 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
6797 +            return;
6798 +        }
6799 hunk ./actions/othersettings.php 143
6800 -               if ($this->arg('save')) {
6801 -                       $this->save_preferences();
6802 -               }else {
6803 -                       $this->show_form(_('Unexpected form submission.'));
6804 -               }
6805 -       }
6806 +        if ($this->arg('save')) {
6807 +            $this->save_preferences();
6808 +        }else {
6809 +            $this->show_form(_('Unexpected form submission.'));
6810 +        }
6811 +    }
6812 hunk ./actions/othersettings.php 150
6813 -       function save_preferences() {
6814 +    function save_preferences() {
6815 hunk ./actions/othersettings.php 152
6816 -               $urlshorteningservice = $this->trimmed('urlshorteningservice');
6817 +        $urlshorteningservice = $this->trimmed('urlshorteningservice');
6818 hunk ./actions/othersettings.php 154
6819 -               if (!is_null($urlshorteningservice) && strlen($urlshorteningservice) > 50) {
6820 -                       $this->show_form(_('URL shortening service is too long (max 50 chars).'));
6821 -                       return;
6822 -               }
6823 +        if (!is_null($urlshorteningservice) && strlen($urlshorteningservice) > 50) {
6824 +            $this->show_form(_('URL shortening service is too long (max 50 chars).'));
6825 +            return;
6826 +        }
6827 hunk ./actions/othersettings.php 159
6828 -               $user = common_current_user();
6829 +        $user = common_current_user();
6830 hunk ./actions/othersettings.php 161
6831 -               assert(!is_null($user)); # should already be checked
6832 +        assert(!is_null($user)); # should already be checked
6833 hunk ./actions/othersettings.php 163
6834 -               $user->query('BEGIN');
6835 +        $user->query('BEGIN');
6836 hunk ./actions/othersettings.php 165
6837 -               $original = clone($user);
6838 +        $original = clone($user);
6839 hunk ./actions/othersettings.php 167
6840 -               $user->urlshorteningservice = $urlshorteningservice;
6841 +        $user->urlshorteningservice = $urlshorteningservice;
6842 hunk ./actions/othersettings.php 169
6843 -               $result = $user->update($original);
6844 +        $result = $user->update($original);
6845 hunk ./actions/othersettings.php 171
6846 -               if ($result === FALSE) {
6847 -                       common_log_db_error($user, 'UPDATE', __FILE__);
6848 -                       common_server_error(_('Couldn\'t update user.'));
6849 -                       return;
6850 -               }
6851 +        if ($result === FALSE) {
6852 +            common_log_db_error($user, 'UPDATE', __FILE__);
6853 +            common_server_error(_('Couldn\'t update user.'));
6854 +            return;
6855 +        }
6856 hunk ./actions/othersettings.php 177
6857 -               $user->query('COMMIT');
6858 +        $user->query('COMMIT');
6859 hunk ./actions/othersettings.php 179
6860 -               $this->show_form(_('Preferences saved.'), true);
6861 -       }
6862 +        $this->show_form(_('Preferences saved.'), true);
6863 +    }
6864 hunk ./actions/peoplesearch.php 27
6865 -       function get_instructions() {
6866 -               return _('Search for people on %%site.name%% by their name, location, or interests. ' .
6867 -                                 'Separate the terms by spaces; they must be 3 characters or more.');
6868 -       }
6869 +    function get_instructions() {
6870 +        return _('Search for people on %%site.name%% by their name, location, or interests. ' .
6871 +                  'Separate the terms by spaces; they must be 3 characters or more.');
6872 +    }
6873 hunk ./actions/peoplesearch.php 32
6874 -       function get_title() {
6875 -               return _('People search');
6876 -       }
6877 +    function get_title() {
6878 +        return _('People search');
6879 +    }
6880 hunk ./actions/peoplesearch.php 36
6881 -       function show_results($q, $page) {
6882 +    function show_results($q, $page) {
6883 hunk ./actions/peoplesearch.php 38
6884 -               $profile = new Profile();
6885 +        $profile = new Profile();
6886 hunk ./actions/peoplesearch.php 40
6887 -               # lcase it for comparison
6888 -               $q = strtolower($q);
6889 +        # lcase it for comparison
6890 +        $q = strtolower($q);
6891 hunk ./actions/peoplesearch.php 46
6892 -               # Ask for an extra to see if there's more.
6893 +        # Ask for an extra to see if there's more.
6894 hunk ./actions/peoplesearch.php 52
6895 -                   $cnt = $profile->find();
6896 +            $cnt = $profile->find();
6897 +        }
6898 +        if ($cnt > 0) {
6899 +            $terms = preg_split('/[\s,]+/', $q);
6900 +            $results = new PeopleSearchResults($profile, $terms);
6901 +            $results->show_list();
6902 +        } else {
6903 +            common_element('p', 'error', _('No results'));
6904 hunk ./actions/peoplesearch.php 61
6905 -               if ($cnt > 0) {
6906 -                       $terms = preg_split('/[\s,]+/', $q);
6907 -                       $results = new PeopleSearchResults($profile, $terms);
6908 -                       $results->show_list();
6909 -               } else {
6910 -                       common_element('p', 'error', _('No results'));
6911 -               }
6912 hunk ./actions/peoplesearch.php 62
6913 -               $profile->free();
6914 -               
6915 -               common_pagination($page > 1, $cnt > PROFILES_PER_PAGE,
6916 -                                                 $page, 'peoplesearch', array('q' => $q));
6917 -       }
6918 +        $profile->free();
6919 +        
6920 +        common_pagination($page > 1, $cnt > PROFILES_PER_PAGE,
6921 +                          $page, 'peoplesearch', array('q' => $q));
6922 +    }
6923 hunk ./actions/peoplesearch.php 71
6924 -       var $terms = NULL;
6925 -       var $pattern = NULL;
6926 -       
6927 -       function __construct($profile, $terms) {
6928 -               parent::__construct($profile);
6929 -               $this->terms = array_map('preg_quote', 
6930 -                                                                array_map('htmlspecialchars', $terms));
6931 -               $this->pattern = '/('.implode('|',$terms).')/i';
6932 -       }
6933 -       
6934 -       function highlight($text) {
6935 -               return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text));
6936 -       }
6937 +    var $terms = NULL;
6938 +    var $pattern = NULL;
6939 +    
6940 +    function __construct($profile, $terms) {
6941 +        parent::__construct($profile);
6942 +        $this->terms = array_map('preg_quote', 
6943 +                                 array_map('htmlspecialchars', $terms));
6944 +        $this->pattern = '/('.implode('|',$terms).')/i';
6945 +    }
6946 +    
6947 +    function highlight($text) {
6948 +        return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text));
6949 +    }
6950 hunk ./actions/peopletag.php 25
6951 -       
6952 -       function handle($args) {
6953 +    
6954 +    function handle($args) {
6955 hunk ./actions/peopletag.php 28
6956 -               parent::handle($args);
6957 +        parent::handle($args);
6958 hunk ./actions/peopletag.php 30
6959 -               $tag = $this->trimmed('tag');
6960 -               
6961 -               if (!common_valid_profile_tag($tag)) {
6962 -                       $this->client_error(sprintf(_('Not a valid people tag: %s'), $tag));
6963 -                       return;
6964 -               }
6965 +        $tag = $this->trimmed('tag');
6966 +        
6967 +        if (!common_valid_profile_tag($tag)) {
6968 +            $this->client_error(sprintf(_('Not a valid people tag: %s'), $tag));
6969 +            return;
6970 +        }
6971 hunk ./actions/peopletag.php 37
6972 -               $page = $this->trimmed('page');
6973 -               
6974 -               if (!$page) {
6975 -                       $page = 1;
6976 -               }
6977 -               
6978 -               # Looks like we're good; show the header
6979 +        $page = $this->trimmed('page');
6980 +        
6981 +        if (!$page) {
6982 +            $page = 1;
6983 +        }
6984 +        
6985 +        # Looks like we're good; show the header
6986 hunk ./actions/peopletag.php 45
6987 -               common_show_header(sprintf(_('Users self-tagged with %s - page %d'), $tag, $page),
6988 -                                                  NULL, $tag, array($this, 'show_top'));
6989 +        common_show_header(sprintf(_('Users self-tagged with %s - page %d'), $tag, $page),
6990 +                           NULL, $tag, array($this, 'show_top'));
6991 hunk ./actions/peopletag.php 48
6992 -               $this->show_people($tag, $page);
6993 +        $this->show_people($tag, $page);
6994 hunk ./actions/peopletag.php 50
6995 -               common_show_footer();
6996 -       }
6997 +        common_show_footer();
6998 +    }
6999 hunk ./actions/peopletag.php 53
7000 -       function show_people($tag, $page) {
7001 -               
7002 -               $profile = new Profile();
7003 +    function show_people($tag, $page) {
7004 +        
7005 +        $profile = new Profile();
7006 hunk ./actions/peopletag.php 57
7007 -               $offset = ($page-1)*PROFILES_PER_PAGE;
7008 -               $limit = PROFILES_PER_PAGE + 1;
7009 -               
7010 -               if (common_config('db','type') == 'pgsql') {
7011 -                       $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
7012 -               } else {
7013 -                       $lim = ' LIMIT ' . $offset . ', ' . $limit;
7014 -               }
7015 +        $offset = ($page-1)*PROFILES_PER_PAGE;
7016 +        $limit = PROFILES_PER_PAGE + 1;
7017 +        
7018 +        if (common_config('db','type') == 'pgsql') {
7019 +            $lim = ' LIMIT ' . $limit . ' OFFSET ' . $offset;
7020 +        } else {
7021 +            $lim = ' LIMIT ' . $offset . ', ' . $limit;
7022 +        }
7023 hunk ./actions/peopletag.php 66
7024 -               # XXX: memcached this
7025 -               
7026 -               $profile->query(sprintf('SELECT profile.* ' .
7027 -                                                               'FROM profile JOIN profile_tag ' .
7028 -                                                               'ON profile.id = profile_tag.tagger ' .
7029 -                                                               'WHERE profile_tag.tagger = profile_tag.tagged ' .
7030 -                                                               'AND tag = "%s" ' .
7031 -                                                               'ORDER BY profile_tag.modified DESC ' . 
7032 -                                                               $lim, $tag));
7033 +        # XXX: memcached this
7034 +        
7035 +        $profile->query(sprintf('SELECT profile.* ' .
7036 +                                'FROM profile JOIN profile_tag ' .
7037 +                                'ON profile.id = profile_tag.tagger ' .
7038 +                                'WHERE profile_tag.tagger = profile_tag.tagged ' .
7039 +                                'AND tag = "%s" ' .
7040 +                                'ORDER BY profile_tag.modified DESC ' . 
7041 +                                $lim, $tag));
7042 hunk ./actions/peopletag.php 76
7043 -               $pl = new ProfileList($profile);
7044 -               $cnt = $pl->show_list();
7045 -               
7046 -               common_pagination($page > 1,
7047 -                                                 $cnt > PROFILES_PER_PAGE,
7048 -                                                 $page,
7049 -                                                 $this->trimmed('action'),
7050 -                                                 array('tag' => $tag));
7051 -       }
7052 -       
7053 -       function show_top($tag) {
7054 -               $instr = sprintf(_('These are users who have tagged themselves "%s" ' .
7055 -                                                  'to show a common interest, characteristic, hobby or job.'), $tag);
7056 -               common_element_start('div', 'instructions');
7057 -               common_element_start('p');
7058 -               common_text($instr);
7059 -               common_element_end('p');
7060 -               common_element_end('div');
7061 -       }
7062 +        $pl = new ProfileList($profile);
7063 +        $cnt = $pl->show_list();
7064 +        
7065 +        common_pagination($page > 1,
7066 +                          $cnt > PROFILES_PER_PAGE,
7067 +                          $page,
7068 +                          $this->trimmed('action'),
7069 +                          array('tag' => $tag));
7070 +    }
7071 +    
7072 +    function show_top($tag) {
7073 +        $instr = sprintf(_('These are users who have tagged themselves "%s" ' .
7074 +                           'to show a common interest, characteristic, hobby or job.'), $tag);
7075 +        common_element_start('div', 'instructions');
7076 +        common_element_start('p');
7077 +        common_text($instr);
7078 +        common_element_end('p');
7079 +        common_element_end('div');
7080 +    }
7081 hunk ./actions/peopletag.php 96
7082 -       function get_title() {
7083 -               return NULL;
7084 -       }
7085 +    function get_title() {
7086 +        return NULL;
7087 +    }
7088 hunk ./actions/peopletag.php 100
7089 -       function show_header($arr) {
7090 -               return;
7091 -       }
7092 +    function show_header($arr) {
7093 +        return;
7094 +    }
7095 hunk ./actions/postnotice.php 25
7096 -       function handle($args) {
7097 -               parent::handle($args);
7098 -               try {
7099 -                       common_remove_magic_from_request();
7100 -                       $req = OAuthRequest::from_request();
7101 -                       # Note: server-to-server function!
7102 -                       $server = omb_oauth_server();
7103 -                       list($consumer, $token) = $server->verify_request($req);
7104 -                       if ($this->save_notice($req, $consumer, $token)) {
7105 -                               print "omb_version=".OMB_VERSION_01;
7106 -                       }
7107 -               } catch (OAuthException $e) {
7108 -                       common_server_error($e->getMessage());
7109 -                       return;
7110 -               }
7111 -       }
7112 +    function handle($args) {
7113 +        parent::handle($args);
7114 +        try {
7115 +            common_remove_magic_from_request();
7116 +            $req = OAuthRequest::from_request();
7117 +            # Note: server-to-server function!
7118 +            $server = omb_oauth_server();
7119 +            list($consumer, $token) = $server->verify_request($req);
7120 +            if ($this->save_notice($req, $consumer, $token)) {
7121 +                print "omb_version=".OMB_VERSION_01;
7122 +            }
7123 +        } catch (OAuthException $e) {
7124 +            common_server_error($e->getMessage());
7125 +            return;
7126 +        }
7127 +    }
7128 hunk ./actions/postnotice.php 42
7129 -       function save_notice(&$req, &$consumer, &$token) {
7130 -               $version = $req->get_parameter('omb_version');
7131 -               if ($version != OMB_VERSION_01) {
7132 -                       common_user_error(_('Unsupported OMB version'), 400);
7133 -                       return false;
7134 -               }
7135 -               # First, check to see
7136 -               $listenee =  $req->get_parameter('omb_listenee');
7137 -               $remote_profile = Remote_profile::staticGet('uri', $listenee);
7138 -               if (!$remote_profile) {
7139 -                       common_user_error(_('Profile unknown'), 403);
7140 -                       return false;
7141 -               }
7142 -               $sub = Subscription::staticGet('token', $token->key);
7143 -               if (!$sub) {
7144 -                       common_user_error(_('No such subscription'), 403);
7145 -                       return false;
7146 -               }
7147 -               $content = $req->get_parameter('omb_notice_content');
7148 +    function save_notice(&$req, &$consumer, &$token) {
7149 +        $version = $req->get_parameter('omb_version');
7150 +        if ($version != OMB_VERSION_01) {
7151 +            common_user_error(_('Unsupported OMB version'), 400);
7152 +            return false;
7153 +        }
7154 +        # First, check to see
7155 +        $listenee =  $req->get_parameter('omb_listenee');
7156 +        $remote_profile = Remote_profile::staticGet('uri', $listenee);
7157 +        if (!$remote_profile) {
7158 +            common_user_error(_('Profile unknown'), 403);
7159 +            return false;
7160 +        }
7161 +        $sub = Subscription::staticGet('token', $token->key);
7162 +        if (!$sub) {
7163 +            common_user_error(_('No such subscription'), 403);
7164 +            return false;
7165 +        }
7166 +        $content = $req->get_parameter('omb_notice_content');
7167 hunk ./actions/postnotice.php 66
7168 -               $notice_uri = $req->get_parameter('omb_notice');
7169 -               if (!Validate::uri($notice_uri) &&
7170 -                       !common_valid_tag($notice_uri)) {
7171 -                       common_user_error(_('Invalid notice uri'), 400);
7172 -                       return false;
7173 -               }
7174 -               $notice_url = $req->get_parameter('omb_notice_url');
7175 -               if ($notice_url && !common_valid_http_url($notice_url)) {
7176 -                       common_user_error(_('Invalid notice url'), 400);
7177 -                       return false;
7178 -               }
7179 -               $notice = Notice::staticGet('uri', $notice_uri);
7180 -               if (!$notice) {
7181 -                       $notice = Notice::saveNew($remote_profile->id, $content, 'omb', false, 0, $notice_uri);
7182 -                       if (is_string($notice)) {
7183 -                               common_server_serror($notice, 500);
7184 -                               return false;
7185 -                       }
7186 -                       common_broadcast_notice($notice, true);
7187 -               }
7188 -               return true;
7189 -       }
7190 +        $notice_uri = $req->get_parameter('omb_notice');
7191 +        if (!Validate::uri($notice_uri) &&
7192 +            !common_valid_tag($notice_uri)) {
7193 +            common_user_error(_('Invalid notice uri'), 400);
7194 +            return false;
7195 +        }
7196 +        $notice_url = $req->get_parameter('omb_notice_url');
7197 +        if ($notice_url && !common_valid_http_url($notice_url)) {
7198 +            common_user_error(_('Invalid notice url'), 400);
7199 +            return false;
7200 +        }
7201 +        $notice = Notice::staticGet('uri', $notice_uri);
7202 +        if (!$notice) {
7203 +            $notice = Notice::saveNew($remote_profile->id, $content, 'omb', false, 0, $notice_uri);
7204 +            if (is_string($notice)) {
7205 +                common_server_serror($notice, 500);
7206 +                return false;
7207 +            }
7208 +            common_broadcast_notice($notice, true);
7209 +        }
7210 +        return true;
7211 +    }
7212 hunk ./actions/profilesettings.php 26
7213 -       function get_instructions() {
7214 -               return _('You can update your personal profile info here '.
7215 -                                 'so people know more about you.');
7216 -       }
7217 +    function get_instructions() {
7218 +        return _('You can update your personal profile info here '.
7219 +                  'so people know more about you.');
7220 +    }
7221 hunk ./actions/profilesettings.php 31
7222 -       function show_form($msg=NULL, $success=false) {
7223 -               $this->form_header(_('Profile settings'), $msg, $success);
7224 -               $this->show_settings_form();
7225 -               common_element('h2', NULL, _('Avatar'));
7226 -               $this->show_avatar_form();
7227 -               common_element('h2', NULL, _('Change password'));
7228 -               $this->show_password_form();
7229 -//             common_element('h2', NULL, _('Delete my account'));
7230 -//             $this->show_delete_form();
7231 -               common_show_footer();
7232 -       }
7233 +    function show_form($msg=NULL, $success=false) {
7234 +        $this->form_header(_('Profile settings'), $msg, $success);
7235 +        $this->show_settings_form();
7236 +        common_element('h2', NULL, _('Avatar'));
7237 +        $this->show_avatar_form();
7238 +        common_element('h2', NULL, _('Change password'));
7239 +        $this->show_password_form();
7240 +//        common_element('h2', NULL, _('Delete my account'));
7241 +//        $this->show_delete_form();
7242 +        common_show_footer();
7243 +    }
7244 hunk ./actions/profilesettings.php 43
7245 -       function handle_post() {
7246 +    function handle_post() {
7247 hunk ./actions/profilesettings.php 45
7248 -               # CSRF protection
7249 +        # CSRF protection
7250 hunk ./actions/profilesettings.php 47
7251 -               $token = $this->trimmed('token');
7252 -               if (!$token || $token != common_session_token()) {
7253 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
7254 -                       return;
7255 -               }
7256 +        $token = $this->trimmed('token');
7257 +        if (!$token || $token != common_session_token()) {
7258 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
7259 +            return;
7260 +        }
7261 hunk ./actions/profilesettings.php 53
7262 -               if ($this->arg('save')) {
7263 -                       $this->save_profile();
7264 -               } else if ($this->arg('upload')) {
7265 -                       $this->upload_avatar();
7266 -               } else if ($this->arg('changepass')) {
7267 -                       $this->change_password();
7268 -               }
7269 +        if ($this->arg('save')) {
7270 +            $this->save_profile();
7271 +        } else if ($this->arg('upload')) {
7272 +            $this->upload_avatar();
7273 +        } else if ($this->arg('changepass')) {
7274 +            $this->change_password();
7275 +        }
7276 hunk ./actions/profilesettings.php 61
7277 -       }
7278 +    }
7279 hunk ./actions/profilesettings.php 63
7280 -       function show_settings_form() {
7281 +    function show_settings_form() {
7282 hunk ./actions/profilesettings.php 65
7283 -               $user = common_current_user();
7284 -               $profile = $user->getProfile();
7285 +        $user = common_current_user();
7286 +        $profile = $user->getProfile();
7287 hunk ./actions/profilesettings.php 68
7288 -               common_element_start('form', array('method' => 'POST',
7289 -                                                                                  'id' => 'profilesettings',
7290 -                                                                                  'action' =>
7291 -                                                                                  common_local_url('profilesettings')));
7292 -               common_hidden('token', common_session_token());
7293 -               
7294 -               # too much common patterns here... abstractable?
7295 -               
7296 -               common_input('nickname', _('Nickname'),
7297 -                                        ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname,
7298 -                                        _('1-64 lowercase letters or numbers, no punctuation or spaces'));
7299 -               common_input('fullname', _('Full name'),
7300 -                                        ($this->arg('fullname')) ? $this->arg('fullname') : $profile->fullname);
7301 -               common_input('homepage', _('Homepage'),
7302 -                                        ($this->arg('homepage')) ? $this->arg('homepage') : $profile->homepage,
7303 -                                        _('URL of your homepage, blog, or profile on another site'));
7304 -               common_textarea('bio', _('Bio'),
7305 -                                               ($this->arg('bio')) ? $this->arg('bio') : $profile->bio,
7306 -                                               _('Describe yourself and your interests in 140 chars'));
7307 -               common_input('location', _('Location'),
7308 -                                        ($this->arg('location')) ? $this->arg('location') : $profile->location,
7309 -                                        _('Where you are, like "City, State (or Region), Country"'));
7310 -               common_input('tags', _('Tags'),
7311 -                                        ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $user->getSelfTags()),
7312 -                                        _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated'));
7313 +        common_element_start('form', array('method' => 'POST',
7314 +                                           'id' => 'profilesettings',
7315 +                                           'action' =>
7316 +                                           common_local_url('profilesettings')));
7317 +        common_hidden('token', common_session_token());
7318 +        
7319 +        # too much common patterns here... abstractable?
7320 +        
7321 +        common_input('nickname', _('Nickname'),
7322 +                     ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname,
7323 +                     _('1-64 lowercase letters or numbers, no punctuation or spaces'));
7324 +        common_input('fullname', _('Full name'),
7325 +                     ($this->arg('fullname')) ? $this->arg('fullname') : $profile->fullname);
7326 +        common_input('homepage', _('Homepage'),
7327 +                     ($this->arg('homepage')) ? $this->arg('homepage') : $profile->homepage,
7328 +                     _('URL of your homepage, blog, or profile on another site'));
7329 +        common_textarea('bio', _('Bio'),
7330 +                        ($this->arg('bio')) ? $this->arg('bio') : $profile->bio,
7331 +                        _('Describe yourself and your interests in 140 chars'));
7332 +        common_input('location', _('Location'),
7333 +                     ($this->arg('location')) ? $this->arg('location') : $profile->location,
7334 +                     _('Where you are, like "City, State (or Region), Country"'));
7335 +        common_input('tags', _('Tags'),
7336 +                     ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $user->getSelfTags()),
7337 +                     _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated'));
7338 hunk ./actions/profilesettings.php 94
7339 -               $language = common_language();
7340 -               common_dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), TRUE, $language);
7341 -               $timezone = common_timezone();
7342 -               $timezones = array();
7343 -               foreach(DateTimeZone::listIdentifiers() as $k => $v) {
7344 -                       $timezones[$v] = $v;
7345 -               }
7346 -               common_dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), TRUE, $timezone);
7347 +        $language = common_language();
7348 +        common_dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), TRUE, $language);
7349 +        $timezone = common_timezone();
7350 +        $timezones = array();
7351 +        foreach(DateTimeZone::listIdentifiers() as $k => $v) {
7352 +            $timezones[$v] = $v;
7353 +        }
7354 +        common_dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), TRUE, $timezone);
7355 hunk ./actions/profilesettings.php 103
7356 -               common_checkbox('autosubscribe', _('Automatically subscribe to whoever subscribes to me (best for non-humans)'),
7357 -                                               ($this->arg('autosubscribe')) ? $this->boolean('autosubscribe') : $user->autosubscribe);
7358 +        common_checkbox('autosubscribe', _('Automatically subscribe to whoever subscribes to me (best for non-humans)'),
7359 +                        ($this->arg('autosubscribe')) ? $this->boolean('autosubscribe') : $user->autosubscribe);
7360 hunk ./actions/profilesettings.php 106
7361 -               common_submit('save', _('Save'));
7362 +        common_submit('save', _('Save'));
7363 hunk ./actions/profilesettings.php 108
7364 -               common_element_end('form');
7365 +        common_element_end('form');
7366 hunk ./actions/profilesettings.php 111
7367 -       }
7368 +    }
7369 hunk ./actions/profilesettings.php 113
7370 -       function show_avatar_form() {
7371 +    function show_avatar_form() {
7372 hunk ./actions/profilesettings.php 115
7373 -               $user = common_current_user();
7374 -               $profile = $user->getProfile();
7375 +        $user = common_current_user();
7376 +        $profile = $user->getProfile();
7377 hunk ./actions/profilesettings.php 118
7378 -               if (!$profile) {
7379 -                       common_log_db_error($user, 'SELECT', __FILE__);
7380 -                       $this->server_error(_('User without matching profile'));
7381 -                       return;
7382 -               }
7383 -               
7384 -               $original = $profile->getOriginalAvatar();
7385 +        if (!$profile) {
7386 +            common_log_db_error($user, 'SELECT', __FILE__);
7387 +            $this->server_error(_('User without matching profile'));
7388 +            return;
7389 +        }
7390 +        
7391 +        $original = $profile->getOriginalAvatar();
7392 hunk ./actions/profilesettings.php 127
7393 -               common_element_start('form', array('enctype' => 'multipart/form-data',
7394 -                                                                                  'method' => 'POST',
7395 -                                                                                  'id' => 'avatar',
7396 -                                                                                  'action' =>
7397 -                                                                                  common_local_url('profilesettings')));
7398 -               common_hidden('token', common_session_token());
7399 +        common_element_start('form', array('enctype' => 'multipart/form-data',
7400 +                                           'method' => 'POST',
7401 +                                           'id' => 'avatar',
7402 +                                           'action' =>
7403 +                                           common_local_url('profilesettings')));
7404 +        common_hidden('token', common_session_token());
7405 hunk ./actions/profilesettings.php 134
7406 -               if ($original) {
7407 -                       common_element('img', array('src' => $original->url,
7408 -                                                                               'class' => 'avatar original',
7409 -                                                                               'width' => $original->width,
7410 -                                                                               'height' => $original->height,
7411 -                                                                               'alt' => $user->nickname));
7412 -               }
7413 +        if ($original) {
7414 +            common_element('img', array('src' => $original->url,
7415 +                                        'class' => 'avatar original',
7416 +                                        'width' => $original->width,
7417 +                                        'height' => $original->height,
7418 +                                        'alt' => $user->nickname));
7419 +        }
7420 hunk ./actions/profilesettings.php 142
7421 -               $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
7422 +        $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
7423 hunk ./actions/profilesettings.php 144
7424 -               if ($avatar) {
7425 -                       common_element('img', array('src' => $avatar->url,
7426 -                                                                               'class' => 'avatar profile',
7427 -                                                                               'width' => AVATAR_PROFILE_SIZE,
7428 -                                                                               'height' => AVATAR_PROFILE_SIZE,
7429 -                                                                               'alt' => $user->nickname));
7430 -               }
7431 +        if ($avatar) {
7432 +            common_element('img', array('src' => $avatar->url,
7433 +                                        'class' => 'avatar profile',
7434 +                                        'width' => AVATAR_PROFILE_SIZE,
7435 +                                        'height' => AVATAR_PROFILE_SIZE,
7436 +                                        'alt' => $user->nickname));
7437 +        }
7438 hunk ./actions/profilesettings.php 153
7439 -               common_element('input', array('name' => 'MAX_FILE_SIZE',
7440 -                                                                         'type' => 'hidden',
7441 -                                                                         'id' => 'MAX_FILE_SIZE',
7442 -                                                                         'value' => MAX_AVATAR_SIZE));
7443 +        common_element('input', array('name' => 'MAX_FILE_SIZE',
7444 +                                      'type' => 'hidden',
7445 +                                      'id' => 'MAX_FILE_SIZE',
7446 +                                      'value' => MAX_AVATAR_SIZE));
7447 hunk ./actions/profilesettings.php 158
7448 -               common_element_start('p');
7449 +        common_element_start('p');
7450 hunk ./actions/profilesettings.php 161
7451 -               common_element('input', array('name' => 'avatarfile',
7452 -                                                                         'type' => 'file',
7453 -                                                                         'id' => 'avatarfile'));
7454 -               common_element_end('p');
7455 +        common_element('input', array('name' => 'avatarfile',
7456 +                                      'type' => 'file',
7457 +                                      'id' => 'avatarfile'));
7458 +        common_element_end('p');
7459 hunk ./actions/profilesettings.php 166
7460 -               common_submit('upload', _('Upload'));
7461 -               common_element_end('form');
7462 +        common_submit('upload', _('Upload'));
7463 +        common_element_end('form');
7464 hunk ./actions/profilesettings.php 169
7465 -       }
7466 +    }
7467 hunk ./actions/profilesettings.php 171
7468 -       function show_password_form() {
7469 +    function show_password_form() {
7470 hunk ./actions/profilesettings.php 173
7471 -               $user = common_current_user();
7472 -               common_element_start('form', array('method' => 'POST',
7473 -                                                                                  'id' => 'password',
7474 -                                                                                  'action' =>
7475 -                                                                                  common_local_url('profilesettings')));
7476 +        $user = common_current_user();
7477 +        common_element_start('form', array('method' => 'POST',
7478 +                                           'id' => 'password',
7479 +                                           'action' =>
7480 +                                           common_local_url('profilesettings')));
7481 hunk ./actions/profilesettings.php 179
7482 -               common_hidden('token', common_session_token());
7483 +        common_hidden('token', common_session_token());
7484 hunk ./actions/profilesettings.php 181
7485 -               # Users who logged in with OpenID won't have a pwd
7486 -               if ($user->password) {
7487 -                       common_password('oldpassword', _('Old password'));
7488 -               }
7489 -               common_password('newpassword', _('New password'),
7490 -                                               _('6 or more characters'));
7491 -               common_password('confirm', _('Confirm'),
7492 -                                               _('same as password above'));
7493 -               common_submit('changepass', _('Change'));
7494 -               common_element_end('form');
7495 -       }
7496 +        # Users who logged in with OpenID won't have a pwd
7497 +        if ($user->password) {
7498 +            common_password('oldpassword', _('Old password'));
7499 +        }
7500 +        common_password('newpassword', _('New password'),
7501 +                        _('6 or more characters'));
7502 +        common_password('confirm', _('Confirm'),
7503 +                        _('same as password above'));
7504 +        common_submit('changepass', _('Change'));
7505 +        common_element_end('form');
7506 +    }
7507 hunk ./actions/profilesettings.php 193
7508 -       function save_profile() {
7509 -               $nickname = $this->trimmed('nickname');
7510 -               $fullname = $this->trimmed('fullname');
7511 -               $homepage = $this->trimmed('homepage');
7512 -               $bio = $this->trimmed('bio');
7513 -               $location = $this->trimmed('location');
7514 -               $autosubscribe = $this->boolean('autosubscribe');
7515 -               $language = $this->trimmed('language');
7516 -               $timezone = $this->trimmed('timezone');
7517 -               $tagstring = $this->trimmed('tags');
7518 -               
7519 -               # Some validation
7520 +    function save_profile() {
7521 +        $nickname = $this->trimmed('nickname');
7522 +        $fullname = $this->trimmed('fullname');
7523 +        $homepage = $this->trimmed('homepage');
7524 +        $bio = $this->trimmed('bio');
7525 +        $location = $this->trimmed('location');
7526 +        $autosubscribe = $this->boolean('autosubscribe');
7527 +        $language = $this->trimmed('language');
7528 +        $timezone = $this->trimmed('timezone');
7529 +        $tagstring = $this->trimmed('tags');
7530 +        
7531 +        # Some validation
7532 hunk ./actions/profilesettings.php 206
7533 -               if (!Validate::string($nickname, array('min_length' => 1,
7534 -                                                                                          'max_length' => 64,
7535 -                                                                                          'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
7536 -                       $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.'));
7537 -                       return;
7538 -               } else if (!User::allowed_nickname($nickname)) {
7539 -                       $this->show_form(_('Not a valid nickname.'));
7540 -                       return;
7541 -               } else if (!is_null($homepage) && (strlen($homepage) > 0) &&
7542 -                                  !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
7543 -                       $this->show_form(_('Homepage is not a valid URL.'));
7544 -                       return;
7545 -               } else if (!is_null($fullname) && strlen($fullname) > 255) {
7546 -                       $this->show_form(_('Full name is too long (max 255 chars).'));
7547 -                       return;
7548 -               } else if (!is_null($bio) && strlen($bio) > 140) {
7549 -                       $this->show_form(_('Bio is too long (max 140 chars).'));
7550 -                       return;
7551 -               } else if (!is_null($location) && strlen($location) > 255) {
7552 -                       $this->show_form(_('Location is too long (max 255 chars).'));
7553 -                       return;
7554 -               }  else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
7555 -                       $this->show_form(_('Timezone not selected.'));
7556 -                       return;
7557 -               } else if ($this->nickname_exists($nickname)) {
7558 -                       $this->show_form(_('Nickname already in use. Try another one.'));
7559 -                       return;
7560 +        if (!Validate::string($nickname, array('min_length' => 1,
7561 +                                               'max_length' => 64,
7562 +                                               'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
7563 +            $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.'));
7564 +            return;
7565 +        } else if (!User::allowed_nickname($nickname)) {
7566 +            $this->show_form(_('Not a valid nickname.'));
7567 +            return;
7568 +        } else if (!is_null($homepage) && (strlen($homepage) > 0) &&
7569 +                   !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
7570 +            $this->show_form(_('Homepage is not a valid URL.'));
7571 +            return;
7572 +        } else if (!is_null($fullname) && strlen($fullname) > 255) {
7573 +            $this->show_form(_('Full name is too long (max 255 chars).'));
7574 +            return;
7575 +        } else if (!is_null($bio) && strlen($bio) > 140) {
7576 +            $this->show_form(_('Bio is too long (max 140 chars).'));
7577 +            return;
7578 +        } else if (!is_null($location) && strlen($location) > 255) {
7579 +            $this->show_form(_('Location is too long (max 255 chars).'));
7580 +            return;
7581 +        }  else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
7582 +            $this->show_form(_('Timezone not selected.'));
7583 +            return;
7584 +        } else if ($this->nickname_exists($nickname)) {
7585 +            $this->show_form(_('Nickname already in use. Try another one.'));
7586 +            return;
7587 hunk ./actions/profilesettings.php 234
7588 -               $this->show_form(_('Language is too long (max 50 chars).'));
7589 -                       return;
7590 -               }
7591 +            $this->show_form(_('Language is too long (max 50 chars).'));
7592 +            return;
7593 +        }
7594 hunk ./actions/profilesettings.php 238
7595 -               if ($tagstring) {
7596 -                       $tags = array_map('common_canonical_tag', preg_split('/[\s,]+/', $tagstring));
7597 -               } else {
7598 -                       $tags = array();
7599 -               }
7600 -                       
7601 -               foreach ($tags as $tag) {
7602 -                       if (!common_valid_profile_tag($tag)) {
7603 -                               $this->show_form(sprintf(_('Invalid tag: "%s"'), $tag));
7604 -                               return;
7605 -                       }
7606 -               }
7607 -               
7608 -               $user = common_current_user();
7609 +        if ($tagstring) {
7610 +            $tags = array_map('common_canonical_tag', preg_split('/[\s,]+/', $tagstring));
7611 +        } else {
7612 +            $tags = array();
7613 +        }
7614 +            
7615 +        foreach ($tags as $tag) {
7616 +            if (!common_valid_profile_tag($tag)) {
7617 +                $this->show_form(sprintf(_('Invalid tag: "%s"'), $tag));
7618 +                return;
7619 +            }
7620 +        }
7621 +        
7622 +        $user = common_current_user();
7623 hunk ./actions/profilesettings.php 253
7624 -               $user->query('BEGIN');
7625 +        $user->query('BEGIN');
7626 hunk ./actions/profilesettings.php 255
7627 -               if ($user->nickname != $nickname ||
7628 -                       $user->language != $language ||
7629 -                       $user->timezone != $timezone) {
7630 +        if ($user->nickname != $nickname ||
7631 +            $user->language != $language ||
7632 +            $user->timezone != $timezone) {
7633 hunk ./actions/profilesettings.php 259
7634 -                       common_debug('Updating user nickname from ' . $user->nickname . ' to ' . $nickname,
7635 -                                                __FILE__);
7636 -                       common_debug('Updating user language from ' . $user->language . ' to ' . $language,
7637 -                                                __FILE__);
7638 -                       common_debug('Updating user timezone from ' . $user->timezone . ' to ' . $timezone,
7639 -                                                __FILE__);
7640 +            common_debug('Updating user nickname from ' . $user->nickname . ' to ' . $nickname,
7641 +                         __FILE__);
7642 +            common_debug('Updating user language from ' . $user->language . ' to ' . $language,
7643 +                         __FILE__);
7644 +            common_debug('Updating user timezone from ' . $user->timezone . ' to ' . $timezone,
7645 +                         __FILE__);
7646 hunk ./actions/profilesettings.php 266
7647 -                       $original = clone($user);
7648 +            $original = clone($user);
7649 hunk ./actions/profilesettings.php 268
7650 -                       $user->nickname = $nickname;
7651 -                       $user->language = $language;
7652 -                       $user->timezone = $timezone;
7653 +            $user->nickname = $nickname;
7654 +            $user->language = $language;
7655 +            $user->timezone = $timezone;
7656 hunk ./actions/profilesettings.php 272
7657 -                       $result = $user->updateKeys($original);
7658 +            $result = $user->updateKeys($original);
7659 hunk ./actions/profilesettings.php 274
7660 -                       if ($result === FALSE) {
7661 -                               common_log_db_error($user, 'UPDATE', __FILE__);
7662 -                               common_server_error(_('Couldn\'t update user.'));
7663 -                               return;
7664 -                       } else {
7665 -                               # Re-initialize language environment if it changed
7666 -                               common_init_language();
7667 -                       }
7668 -               }
7669 +            if ($result === FALSE) {
7670 +                common_log_db_error($user, 'UPDATE', __FILE__);
7671 +                common_server_error(_('Couldn\'t update user.'));
7672 +                return;
7673 +            } else {
7674 +                # Re-initialize language environment if it changed
7675 +                common_init_language();
7676 +            }
7677 +        }
7678 hunk ./actions/profilesettings.php 284
7679 -               # XXX: XOR
7680 +        # XXX: XOR
7681 hunk ./actions/profilesettings.php 286
7682 -               if ($user->autosubscribe ^ $autosubscribe) {
7683 +        if ($user->autosubscribe ^ $autosubscribe) {
7684 hunk ./actions/profilesettings.php 288
7685 -                       $original = clone($user);
7686 +            $original = clone($user);
7687 hunk ./actions/profilesettings.php 290
7688 -                       $user->autosubscribe = $autosubscribe;
7689 +            $user->autosubscribe = $autosubscribe;
7690 hunk ./actions/profilesettings.php 292
7691 -                       $result = $user->update($original);
7692 +            $result = $user->update($original);
7693 hunk ./actions/profilesettings.php 294
7694 -                       if ($result === FALSE) {
7695 -                               common_log_db_error($user, 'UPDATE', __FILE__);
7696 -                               common_server_error(_('Couldn\'t update user for autosubscribe.'));
7697 -                               return;
7698 -                       }
7699 -               }
7700 +            if ($result === FALSE) {
7701 +                common_log_db_error($user, 'UPDATE', __FILE__);
7702 +                common_server_error(_('Couldn\'t update user for autosubscribe.'));
7703 +                return;
7704 +            }
7705 +        }
7706 hunk ./actions/profilesettings.php 301
7707 -               $profile = $user->getProfile();
7708 +        $profile = $user->getProfile();
7709 hunk ./actions/profilesettings.php 303
7710 -               $orig_profile = clone($profile);
7711 +        $orig_profile = clone($profile);
7712 hunk ./actions/profilesettings.php 305
7713 -               $profile->nickname = $user->nickname;
7714 -               $profile->fullname = $fullname;
7715 -               $profile->homepage = $homepage;
7716 -               $profile->bio = $bio;
7717 -               $profile->location = $location;
7718 -               $profile->profileurl = common_profile_url($nickname);
7719 +        $profile->nickname = $user->nickname;
7720 +        $profile->fullname = $fullname;
7721 +        $profile->homepage = $homepage;
7722 +        $profile->bio = $bio;
7723 +        $profile->location = $location;
7724 +        $profile->profileurl = common_profile_url($nickname);
7725 hunk ./actions/profilesettings.php 312
7726 -               common_debug('Old profile: ' . common_log_objstring($orig_profile), __FILE__);
7727 -               common_debug('New profile: ' . common_log_objstring($profile), __FILE__);
7728 +        common_debug('Old profile: ' . common_log_objstring($orig_profile), __FILE__);
7729 +        common_debug('New profile: ' . common_log_objstring($profile), __FILE__);
7730 hunk ./actions/profilesettings.php 315
7731 -               $result = $profile->update($orig_profile);
7732 +        $result = $profile->update($orig_profile);
7733 hunk ./actions/profilesettings.php 317
7734 -               if (!$result) {
7735 -                       common_log_db_error($profile, 'UPDATE', __FILE__);
7736 -                       common_server_error(_('Couldn\'t save profile.'));
7737 -                       return;
7738 -               }
7739 +        if (!$result) {
7740 +            common_log_db_error($profile, 'UPDATE', __FILE__);
7741 +            common_server_error(_('Couldn\'t save profile.'));
7742 +            return;
7743 +        }
7744 hunk ./actions/profilesettings.php 323
7745 -               # Set the user tags
7746 -               
7747 -               $result = $user->setSelfTags($tags);
7748 +        # Set the user tags
7749 +        
7750 +        $result = $user->setSelfTags($tags);
7751 hunk ./actions/profilesettings.php 327
7752 -               if (!$result) {
7753 -                       common_server_error(_('Couldn\'t save tags.'));
7754 -                       return;
7755 -               }
7756 -               
7757 -               $user->query('COMMIT');
7758 +        if (!$result) {
7759 +            common_server_error(_('Couldn\'t save tags.'));
7760 +            return;
7761 +        }
7762 +        
7763 +        $user->query('COMMIT');
7764 hunk ./actions/profilesettings.php 334
7765 -               common_broadcast_profile($profile);
7766 +        common_broadcast_profile($profile);
7767 hunk ./actions/profilesettings.php 336
7768 -               $this->show_form(_('Settings saved.'), TRUE);
7769 -       }
7770 +        $this->show_form(_('Settings saved.'), TRUE);
7771 +    }
7772 hunk ./actions/profilesettings.php 340
7773 -       function upload_avatar() {
7774 -               switch ($_FILES['avatarfile']['error']) {
7775 -                case UPLOAD_ERR_OK: # success, jump out
7776 -                       break;
7777 -                case UPLOAD_ERR_INI_SIZE:
7778 -                case UPLOAD_ERR_FORM_SIZE:
7779 -                       $this->show_form(_('That file is too big.'));
7780 -                       return;
7781 -                case UPLOAD_ERR_PARTIAL:
7782 -                       @unlink($_FILES['avatarfile']['tmp_name']);
7783 -                       $this->show_form(_('Partial upload.'));
7784 -                       return;
7785 -                default:
7786 -                       $this->show_form(_('System error uploading file.'));
7787 -                       return;
7788 -               }
7789 +    function upload_avatar() {
7790 +        switch ($_FILES['avatarfile']['error']) {
7791 +         case UPLOAD_ERR_OK: # success, jump out
7792 +            break;
7793 +         case UPLOAD_ERR_INI_SIZE:
7794 +         case UPLOAD_ERR_FORM_SIZE:
7795 +            $this->show_form(_('That file is too big.'));
7796 +            return;
7797 +         case UPLOAD_ERR_PARTIAL:
7798 +            @unlink($_FILES['avatarfile']['tmp_name']);
7799 +            $this->show_form(_('Partial upload.'));
7800 +            return;
7801 +         default:
7802 +            $this->show_form(_('System error uploading file.'));
7803 +            return;
7804 +        }
7805 hunk ./actions/profilesettings.php 357
7806 -               $info = @getimagesize($_FILES['avatarfile']['tmp_name']);
7807 +        $info = @getimagesize($_FILES['avatarfile']['tmp_name']);
7808 hunk ./actions/profilesettings.php 359
7809 -               if (!$info) {
7810 -                       @unlink($_FILES['avatarfile']['tmp_name']);
7811 -                       $this->show_form(_('Not an image or corrupt file.'));
7812 -                       return;
7813 -               }
7814 +        if (!$info) {
7815 +            @unlink($_FILES['avatarfile']['tmp_name']);
7816 +            $this->show_form(_('Not an image or corrupt file.'));
7817 +            return;
7818 +        }
7819 hunk ./actions/profilesettings.php 365
7820 -               switch ($info[2]) {
7821 -                case IMAGETYPE_GIF:
7822 -                case IMAGETYPE_JPEG:
7823 -                case IMAGETYPE_PNG:
7824 -                       break;
7825 -                default:
7826 -                       $this->show_form(_('Unsupported image file format.'));
7827 -                       return;
7828 -               }
7829 +        switch ($info[2]) {
7830 +         case IMAGETYPE_GIF:
7831 +         case IMAGETYPE_JPEG:
7832 +         case IMAGETYPE_PNG:
7833 +            break;
7834 +         default:
7835 +            $this->show_form(_('Unsupported image file format.'));
7836 +            return;
7837 +        }
7838 hunk ./actions/profilesettings.php 375
7839 -               $user = common_current_user();
7840 -               $profile = $user->getProfile();
7841 +        $user = common_current_user();
7842 +        $profile = $user->getProfile();
7843 hunk ./actions/profilesettings.php 378
7844 -               if ($profile->setOriginal($_FILES['avatarfile']['tmp_name'])) {
7845 -                       $this->show_form(_('Avatar updated.'), true);
7846 -               } else {
7847 -                       $this->show_form(_('Failed updating avatar.'));
7848 -               }
7849 +        if ($profile->setOriginal($_FILES['avatarfile']['tmp_name'])) {
7850 +            $this->show_form(_('Avatar updated.'), true);
7851 +        } else {
7852 +            $this->show_form(_('Failed updating avatar.'));
7853 +        }
7854 hunk ./actions/profilesettings.php 384
7855 -               @unlink($_FILES['avatarfile']['tmp_name']);
7856 -       }
7857 +        @unlink($_FILES['avatarfile']['tmp_name']);
7858 +    }
7859 hunk ./actions/profilesettings.php 387
7860 -       function nickname_exists($nickname) {
7861 -               $user = common_current_user();
7862 -               $other = User::staticGet('nickname', $nickname);
7863 -               if (!$other) {
7864 -                       return false;
7865 -               } else {
7866 -                       return $other->id != $user->id;
7867 -               }
7868 -       }
7869 +    function nickname_exists($nickname) {
7870 +        $user = common_current_user();
7871 +        $other = User::staticGet('nickname', $nickname);
7872 +        if (!$other) {
7873 +            return false;
7874 +        } else {
7875 +            return $other->id != $user->id;
7876 +        }
7877 +    }
7878 hunk ./actions/profilesettings.php 397
7879 -       function change_password() {
7880 +    function change_password() {
7881 hunk ./actions/profilesettings.php 399
7882 -               $user = common_current_user();
7883 -               assert(!is_null($user)); # should already be checked
7884 +        $user = common_current_user();
7885 +        assert(!is_null($user)); # should already be checked
7886 hunk ./actions/profilesettings.php 402
7887 -               # FIXME: scrub input
7888 +        # FIXME: scrub input
7889 hunk ./actions/profilesettings.php 404
7890 -               $newpassword = $this->arg('newpassword');
7891 -               $confirm = $this->arg('confirm');
7892 -               $token = $this->arg('token');
7893 +        $newpassword = $this->arg('newpassword');
7894 +        $confirm = $this->arg('confirm');
7895 +        $token = $this->arg('token');
7896 hunk ./actions/profilesettings.php 408
7897 -               if (0 != strcmp($newpassword, $confirm)) {
7898 -                       $this->show_form(_('Passwords don\'t match.'));
7899 -                       return;
7900 -               }
7901 +        if (0 != strcmp($newpassword, $confirm)) {
7902 +            $this->show_form(_('Passwords don\'t match.'));
7903 +            return;
7904 +        }
7905 hunk ./actions/profilesettings.php 413
7906 -               if ($user->password) {
7907 -                       $oldpassword = $this->arg('oldpassword');
7908 +        if ($user->password) {
7909 +            $oldpassword = $this->arg('oldpassword');
7910 hunk ./actions/profilesettings.php 416
7911 -                       if (!common_check_user($user->nickname, $oldpassword)) {
7912 -                               $this->show_form(_('Incorrect old password'));
7913 -                               return;
7914 -                       }
7915 -               }
7916 +            if (!common_check_user($user->nickname, $oldpassword)) {
7917 +                $this->show_form(_('Incorrect old password'));
7918 +                return;
7919 +            }
7920 +        }
7921 hunk ./actions/profilesettings.php 422
7922 -               $original = clone($user);
7923 +        $original = clone($user);
7924 hunk ./actions/profilesettings.php 424
7925 -               $user->password = common_munge_password($newpassword, $user->id);
7926 +        $user->password = common_munge_password($newpassword, $user->id);
7927 hunk ./actions/profilesettings.php 426
7928 -               $val = $user->validate();
7929 -               if ($val !== TRUE) {
7930 -                       $this->show_form(_('Error saving user; invalid.'));
7931 -                       return;
7932 -               }
7933 +        $val = $user->validate();
7934 +        if ($val !== TRUE) {
7935 +            $this->show_form(_('Error saving user; invalid.'));
7936 +            return;
7937 +        }
7938 hunk ./actions/profilesettings.php 432
7939 -               if (!$user->update($original)) {
7940 -                       common_server_error(_('Can\'t save new password.'));
7941 -                       return;
7942 -               }
7943 +        if (!$user->update($original)) {
7944 +            common_server_error(_('Can\'t save new password.'));
7945 +            return;
7946 +        }
7947 hunk ./actions/profilesettings.php 437
7948 -               $this->show_form(_('Password saved.'), true);
7949 -       }
7950 +        $this->show_form(_('Password saved.'), true);
7951 +    }
7952 hunk ./actions/public.php 26
7953 -       function handle($args) {
7954 -               parent::handle($args);
7955 +    function handle($args) {
7956 +        parent::handle($args);
7957 hunk ./actions/public.php 29
7958 -               $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
7959 +        $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
7960 hunk ./actions/public.php 31
7961 -               header('X-XRDS-Location: '. common_local_url('publicxrds'));
7962 +        header('X-XRDS-Location: '. common_local_url('publicxrds'));
7963 hunk ./actions/public.php 33
7964 -               common_show_header(_('Public timeline'),
7965 -                                                  array($this, 'show_header'), NULL,
7966 -                                                  array($this, 'show_top'));
7967 +        common_show_header(_('Public timeline'),
7968 +                           array($this, 'show_header'), NULL,
7969 +                           array($this, 'show_top'));
7970 hunk ./actions/public.php 37
7971 -               # XXX: Public sidebar here?
7972 +        # XXX: Public sidebar here?
7973 hunk ./actions/public.php 39
7974 -               $this->show_notices($page);
7975 +        $this->show_notices($page);
7976 hunk ./actions/public.php 41
7977 -               common_show_footer();
7978 -       }
7979 +        common_show_footer();
7980 +    }
7981 hunk ./actions/public.php 44
7982 -       function show_top() {
7983 -               if (common_logged_in()) {
7984 -                       common_notice_form('public');
7985 -               } else {
7986 -                       $instr = $this->get_instructions();
7987 -                       $output = common_markup_to_html($instr);
7988 -                       common_element_start('div', 'instructions');
7989 -                       common_raw($output);
7990 -                       common_element_end('div');
7991 -               }
7992 +    function show_top() {
7993 +        if (common_logged_in()) {
7994 +            common_notice_form('public');
7995 +        } else {
7996 +            $instr = $this->get_instructions();
7997 +            $output = common_markup_to_html($instr);
7998 +            common_element_start('div', 'instructions');
7999 +            common_raw($output);
8000 +            common_element_end('div');
8001 +        }
8002 hunk ./actions/public.php 55
8003 -               $this->public_views_menu();
8004 +        $this->public_views_menu();
8005 hunk ./actions/public.php 57
8006 -               $this->show_feeds_list(array(0=>array('href'=>common_local_url('publicrss'),
8007 -                                                                                         'type' => 'rss',
8008 -                                                                                         'version' => 'RSS 1.0',
8009 -                                                                                         'item' => 'publicrss'),
8010 -                                                                        1=>array('href'=>common_local_url('publicatom'),
8011 -                                                                                         'type' => 'atom',
8012 -                                                                                         'version' => 'Atom 1.0',
8013 -                                                                                         'item' => 'publicatom')));
8014 -       }
8015 +        $this->show_feeds_list(array(0=>array('href'=>common_local_url('publicrss'),
8016 +                                              'type' => 'rss',
8017 +                                              'version' => 'RSS 1.0',
8018 +                                              'item' => 'publicrss'),
8019 +                                     1=>array('href'=>common_local_url('publicatom'),
8020 +                                              'type' => 'atom',
8021 +                                              'version' => 'Atom 1.0',
8022 +                                              'item' => 'publicatom')));
8023 +    }
8024 hunk ./actions/public.php 67
8025 -       function get_instructions() {
8026 -               return _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
8027 -                                'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
8028 -                                '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))');
8029 -       }
8030 +    function get_instructions() {
8031 +        return _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
8032 +                 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
8033 +                 '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))');
8034 +    }
8035 hunk ./actions/public.php 73
8036 -       function show_header() {
8037 -               common_element('link', array('rel' => 'alternate',
8038 -                                                                        'href' => common_local_url('publicrss'),
8039 -                                                                        'type' => 'application/rss+xml',
8040 -                                                                        'title' => _('Public Stream Feed')));
8041 -               # for client side of OpenID authentication
8042 -               common_element('meta', array('http-equiv' => 'X-XRDS-Location',
8043 -                                                                        'content' => common_local_url('publicxrds')));
8044 -       }
8045 +    function show_header() {
8046 +        common_element('link', array('rel' => 'alternate',
8047 +                                     'href' => common_local_url('publicrss'),
8048 +                                     'type' => 'application/rss+xml',
8049 +                                     'title' => _('Public Stream Feed')));
8050 +        # for client side of OpenID authentication
8051 +        common_element('meta', array('http-equiv' => 'X-XRDS-Location',
8052 +                                     'content' => common_local_url('publicxrds')));
8053 +    }
8054 hunk ./actions/public.php 83
8055 -       function show_notices($page) {
8056 +    function show_notices($page) {
8057 hunk ./actions/public.php 85
8058 -               $cnt = 0;
8059 -               $notice = Notice::publicStream(($page-1)*NOTICES_PER_PAGE,
8060 -                                                                          NOTICES_PER_PAGE + 1);
8061 +        $cnt = 0;
8062 +        $notice = Notice::publicStream(($page-1)*NOTICES_PER_PAGE,
8063 +                                       NOTICES_PER_PAGE + 1);
8064 hunk ./actions/public.php 89
8065 -               if (!$notice) {
8066 +        if (!$notice) {
8067 hunk ./actions/public.php 92
8068 -               }
8069 +        }
8070 hunk ./actions/public.php 96
8071 -               common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
8072 -                                                 $page, 'public');
8073 -       }
8074 +        common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
8075 +                          $page, 'public');
8076 +    }
8077 hunk ./actions/publicrss.php 28
8078 -       function init() {
8079 -               return true;
8080 -       }
8081 +    function init() {
8082 +        return true;
8083 +    }
8084 hunk ./actions/publicrss.php 32
8085 -       function get_notices($limit=0) {
8086 -               
8087 -               $notices = array();
8088 -               
8089 -               $notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit);
8090 -               
8091 -               while ($notice->fetch()) {
8092 -                       $notices[] = clone($notice);
8093 -               }
8094 -               
8095 -               return $notices;
8096 -       }
8097 +    function get_notices($limit=0) {
8098 +        
8099 +        $notices = array();
8100 +        
8101 +        $notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit);
8102 +        
8103 +        while ($notice->fetch()) {
8104 +            $notices[] = clone($notice);
8105 +        }
8106 +        
8107 +        return $notices;
8108 +    }
8109 hunk ./actions/publicrss.php 45
8110 -       function get_channel() {
8111 -               global $config;
8112 -               $c = array('url' => common_local_url('publicrss'),
8113 -                                  'title' => sprintf(_('%s Public Stream'), $config['site']['name']),
8114 -                                  'link' => common_local_url('public'),
8115 -                                  'description' => sprintf(_('All updates for %s'), $config['site']['name']));
8116 -               return $c;
8117 -       }
8118 +    function get_channel() {
8119 +        global $config;
8120 +        $c = array('url' => common_local_url('publicrss'),
8121 +                   'title' => sprintf(_('%s Public Stream'), $config['site']['name']),
8122 +                   'link' => common_local_url('public'),
8123 +                   'description' => sprintf(_('All updates for %s'), $config['site']['name']));
8124 +        return $c;
8125 +    }
8126 hunk ./actions/publicrss.php 54
8127 -       function get_image() {
8128 -               return NULL;
8129 -       }
8130 +    function get_image() {
8131 +        return NULL;
8132 +    }
8133 hunk ./actions/publicxrds.php 28
8134 -       function is_readonly() {
8135 -               return true;
8136 -       }
8137 +    function is_readonly() {
8138 +        return true;
8139 +    }
8140 hunk ./actions/publicxrds.php 32
8141 -       function handle($args) {
8142 +    function handle($args) {
8143 hunk ./actions/publicxrds.php 34
8144 -               parent::handle($args);
8145 +        parent::handle($args);
8146 hunk ./actions/publicxrds.php 36
8147 -               header('Content-Type: application/xrds+xml');
8148 +        header('Content-Type: application/xrds+xml');
8149 hunk ./actions/publicxrds.php 38
8150 -               common_start_xml();
8151 -               common_element_start('XRDS', array('xmlns' => 'xri://$xrds'));
8152 +        common_start_xml();
8153 +        common_element_start('XRDS', array('xmlns' => 'xri://$xrds'));
8154 hunk ./actions/publicxrds.php 41
8155 -               common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
8156 -                                                                                 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
8157 -                                                                                 'version' => '2.0'));
8158 +        common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
8159 +                                          'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
8160 +                                          'version' => '2.0'));
8161 hunk ./actions/publicxrds.php 45
8162 -               common_element('Type', NULL, 'xri://$xrds*simple');
8163 +        common_element('Type', NULL, 'xri://$xrds*simple');
8164 hunk ./actions/publicxrds.php 47
8165 -               foreach (array('finishopenidlogin', 'finishaddopenid', 'finishimmediate') as $finish) {
8166 -                       $this->show_service(Auth_OpenID_RP_RETURN_TO_URL_TYPE,
8167 -                                                               common_local_url($finish));
8168 -               }
8169 +        foreach (array('finishopenidlogin', 'finishaddopenid', 'finishimmediate') as $finish) {
8170 +            $this->show_service(Auth_OpenID_RP_RETURN_TO_URL_TYPE,
8171 +                                common_local_url($finish));
8172 +        }
8173 hunk ./actions/publicxrds.php 52
8174 -               common_element_end('XRD');
8175 +        common_element_end('XRD');
8176 hunk ./actions/publicxrds.php 54
8177 -               common_element_end('XRDS');
8178 -               common_end_xml();
8179 -       }
8180 +        common_element_end('XRDS');
8181 +        common_end_xml();
8182 +    }
8183 hunk ./actions/publicxrds.php 58
8184 -       function show_service($type, $uri, $params=NULL, $sigs=NULL, $localId=NULL) {
8185 -               common_element_start('Service');
8186 -               if ($uri) {
8187 -                       common_element('URI', NULL, $uri);
8188 -               }
8189 -               common_element('Type', NULL, $type);
8190 -               if ($params) {
8191 -                       foreach ($params as $param) {
8192 -                               common_element('Type', NULL, $param);
8193 -                       }
8194 -               }
8195 -               if ($sigs) {
8196 -                       foreach ($sigs as $sig) {
8197 -                               common_element('Type', NULL, $sig);
8198 -                       }
8199 -               }
8200 -               if ($localId) {
8201 -                       common_element('LocalID', NULL, $localId);
8202 -               }
8203 -               common_element_end('Service');
8204 -       }
8205 +    function show_service($type, $uri, $params=NULL, $sigs=NULL, $localId=NULL) {
8206 +        common_element_start('Service');
8207 +        if ($uri) {
8208 +            common_element('URI', NULL, $uri);
8209 +        }
8210 +        common_element('Type', NULL, $type);
8211 +        if ($params) {
8212 +            foreach ($params as $param) {
8213 +                common_element('Type', NULL, $param);
8214 +            }
8215 +        }
8216 +        if ($sigs) {
8217 +            foreach ($sigs as $sig) {
8218 +                common_element('Type', NULL, $sig);
8219 +            }
8220 +        }
8221 +        if ($localId) {
8222 +            common_element('LocalID', NULL, $localId);
8223 +        }
8224 +        common_element_end('Service');
8225 +    }
8226 hunk ./actions/recoverpassword.php 31
8227 -                       $this->client_error(_('You are already logged in!'));
8228 +            $this->client_error(_('You are already logged in!'));
8229 hunk ./actions/recoverpassword.php 34
8230 -               if ($this->arg('recover')) {
8231 -               $this->recover_password();
8232 +            if ($this->arg('recover')) {
8233 +                $this->recover_password();
8234 hunk ./actions/recoverpassword.php 37
8235 -               $this->reset_password();
8236 -                       } else {
8237 -                               $this->client_error(_('Unexpected form submission.'));
8238 -                       }
8239 -               } else {
8240 -                       if ($this->trimmed('code')) {
8241 -                       $this->check_code();
8242 -               } else {
8243 -                       $this->show_form();
8244 -                       }
8245 -               }
8246 -       }
8247 +                $this->reset_password();
8248 +            } else {
8249 +                $this->client_error(_('Unexpected form submission.'));
8250 +            }
8251 +        } else {
8252 +            if ($this->trimmed('code')) {
8253 +                $this->check_code();
8254 +            } else {
8255 +                $this->show_form();
8256 +            }
8257 +        }
8258 +    }
8259 hunk ./actions/recoverpassword.php 50
8260 -       function check_code() {
8261 +    function check_code() {
8262 hunk ./actions/recoverpassword.php 52
8263 -               $code = $this->trimmed('code');
8264 -               $confirm = Confirm_address::staticGet('code', $code);
8265 +        $code = $this->trimmed('code');
8266 +        $confirm = Confirm_address::staticGet('code', $code);
8267 hunk ./actions/recoverpassword.php 55
8268 -               if (!$confirm) {
8269 -                       $this->client_error(_('No such recovery code.'));
8270 -                       return;
8271 -               }
8272 -               if ($confirm->address_type != 'recover') {
8273 -                       $this->client_error(_('Not a recovery code.'));
8274 -                       return;
8275 -               }
8276 +        if (!$confirm) {
8277 +            $this->client_error(_('No such recovery code.'));
8278 +            return;
8279 +        }
8280 +        if ($confirm->address_type != 'recover') {
8281 +            $this->client_error(_('Not a recovery code.'));
8282 +            return;
8283 +        }
8284 hunk ./actions/recoverpassword.php 64
8285 -               $user = User::staticGet($confirm->user_id);
8286 +        $user = User::staticGet($confirm->user_id);
8287 hunk ./actions/recoverpassword.php 66
8288 -               if (!$user) {
8289 -                       $this->server_error(_('Recovery code for unknown user.'));
8290 -                       return;
8291 -               }
8292 +        if (!$user) {
8293 +            $this->server_error(_('Recovery code for unknown user.'));
8294 +            return;
8295 +        }
8296 hunk ./actions/recoverpassword.php 71
8297 -               $touched = strtotime($confirm->modified);
8298 -               $email = $confirm->address;
8299 +        $touched = strtotime($confirm->modified);
8300 +        $email = $confirm->address;
8301 hunk ./actions/recoverpassword.php 74
8302 -               # Burn this code
8303 +        # Burn this code
8304 hunk ./actions/recoverpassword.php 76
8305 -               $result = $confirm->delete();
8306 +        $result = $confirm->delete();
8307 hunk ./actions/recoverpassword.php 78
8308 -               if (!$result) {
8309 -                       common_log_db_error($confirm, 'DELETE', __FILE__);
8310 -                       common_server_error(_('Error with confirmation code.'));
8311 -                       return;
8312 -               }
8313 +        if (!$result) {
8314 +            common_log_db_error($confirm, 'DELETE', __FILE__);
8315 +            common_server_error(_('Error with confirmation code.'));
8316 +            return;
8317 +        }
8318 hunk ./actions/recoverpassword.php 84
8319 -               # These should be reaped, but for now we just check mod time
8320 -               # Note: it's still deleted; let's avoid a second attempt!
8321 +        # These should be reaped, but for now we just check mod time
8322 +        # Note: it's still deleted; let's avoid a second attempt!
8323 hunk ./actions/recoverpassword.php 87
8324 -               if ((time() - $touched) > MAX_RECOVERY_TIME) {
8325 -                       common_log(LOG_WARNING, 
8326 -                                          'Attempted redemption on recovery code ' .
8327 -                                          'that is ' . $touched . ' seconds old. ');
8328 -                       $this->client_error(_('This confirmation code is too old. ' .
8329 -                                              'Please start again.'));
8330 -                       return;
8331 -               }
8332 +        if ((time() - $touched) > MAX_RECOVERY_TIME) {
8333 +            common_log(LOG_WARNING, 
8334 +                       'Attempted redemption on recovery code ' .
8335 +                       'that is ' . $touched . ' seconds old. ');
8336 +            $this->client_error(_('This confirmation code is too old. ' .
8337 +                                   'Please start again.'));
8338 +            return;
8339 +        }
8340 hunk ./actions/recoverpassword.php 96
8341 -               # If we used an outstanding confirmation to send the email,
8342 -               # it's been confirmed at this point.
8343 +        # If we used an outstanding confirmation to send the email,
8344 +        # it's been confirmed at this point.
8345 hunk ./actions/recoverpassword.php 99
8346 -               if (!$user->email) {
8347 -                       $orig = clone($user);
8348 -                       $user->email = $email;
8349 -                       $result = $user->updateKeys($orig);
8350 -                       if (!$result) {
8351 -                               common_log_db_error($user, 'UPDATE', __FILE__);
8352 -                               $this->server_error(_('Could not update user with confirmed email address.'));
8353 -                               return;
8354 -                       }
8355 -               }
8356 +        if (!$user->email) {
8357 +            $orig = clone($user);
8358 +            $user->email = $email;
8359 +            $result = $user->updateKeys($orig);
8360 +            if (!$result) {
8361 +                common_log_db_error($user, 'UPDATE', __FILE__);
8362 +                $this->server_error(_('Could not update user with confirmed email address.'));
8363 +                return;
8364 +            }
8365 +        }
8366 hunk ./actions/recoverpassword.php 110
8367 -               # Success!
8368 +        # Success!
8369 hunk ./actions/recoverpassword.php 112
8370 -               $this->set_temp_user($user);
8371 -               $this->show_password_form();
8372 -       }
8373 +        $this->set_temp_user($user);
8374 +        $this->show_password_form();
8375 +    }
8376 hunk ./actions/recoverpassword.php 116
8377 -       function set_temp_user(&$user) {
8378 -               common_ensure_session();
8379 -               $_SESSION['tempuser'] = $user->id;
8380 -       }
8381 +    function set_temp_user(&$user) {
8382 +        common_ensure_session();
8383 +        $_SESSION['tempuser'] = $user->id;
8384 +    }
8385 hunk ./actions/recoverpassword.php 121
8386 -       function get_temp_user() {
8387 -               common_ensure_session();
8388 -               $user_id = $_SESSION['tempuser'];
8389 -               if ($user_id) {
8390 -                       $user = User::staticGet($user_id);
8391 -               }
8392 -               return $user;
8393 -       }
8394 +    function get_temp_user() {
8395 +        common_ensure_session();
8396 +        $user_id = $_SESSION['tempuser'];
8397 +        if ($user_id) {
8398 +            $user = User::staticGet($user_id);
8399 +        }
8400 +        return $user;
8401 +    }
8402 hunk ./actions/recoverpassword.php 130
8403 -       function clear_temp_user() {
8404 -               common_ensure_session();
8405 -               unset($_SESSION['tempuser']);
8406 -       }
8407 +    function clear_temp_user() {
8408 +        common_ensure_session();
8409 +        unset($_SESSION['tempuser']);
8410 +    }
8411 hunk ./actions/recoverpassword.php 135
8412 -       function show_top($msg=NULL) {
8413 -               if ($msg) {
8414 +    function show_top($msg=NULL) {
8415 +        if ($msg) {
8416 hunk ./actions/recoverpassword.php 138
8417 -               } else {
8418 -                       common_element_start('div', 'instructions');
8419 -                       common_element('p', NULL, 
8420 -                                                  _('If you\'ve forgotten or lost your' .
8421 -                                                     ' password, you can get a new one sent to' .
8422 -                                                     ' the email address you have stored ' .
8423 -                                                     ' in your account.'));
8424 -                       common_element_end('div');
8425 -               }
8426 -       }
8427 +        } else {
8428 +            common_element_start('div', 'instructions');
8429 +            common_element('p', NULL, 
8430 +                           _('If you\'ve forgotten or lost your' .
8431 +                              ' password, you can get a new one sent to' .
8432 +                              ' the email address you have stored ' .
8433 +                              ' in your account.'));
8434 +            common_element_end('div');
8435 +        }
8436 +    }
8437 hunk ./actions/recoverpassword.php 149
8438 -       function show_password_top($msg=NULL) {
8439 -               if ($msg) {
8440 +    function show_password_top($msg=NULL) {
8441 +        if ($msg) {
8442 hunk ./actions/recoverpassword.php 152
8443 -               } else {
8444 -                       common_element('div', 'instructions',
8445 -                                                  _('You\'ve been identified. Enter a ' .
8446 -                                                     ' new password below. '));
8447 -               }
8448 -       }
8449 +        } else {
8450 +            common_element('div', 'instructions',
8451 +                           _('You\'ve been identified. Enter a ' .
8452 +                              ' new password below. '));
8453 +        }
8454 +    }
8455 hunk ./actions/recoverpassword.php 159
8456 -       function show_form($msg=NULL) {
8457 +    function show_form($msg=NULL) {
8458 hunk ./actions/recoverpassword.php 161
8459 -               common_show_header(_('Recover password'), NULL,
8460 -               $msg, array($this, 'show_top'));
8461 +        common_show_header(_('Recover password'), NULL,
8462 +        $msg, array($this, 'show_top'));
8463 hunk ./actions/recoverpassword.php 164
8464 -               common_element_start('form', array('method' => 'post',
8465 -                                                                                  'id' => 'recoverpassword',
8466 -                                                                                  'action' => common_local_url('recoverpassword')));
8467 -               common_input('nicknameoremail', _('Nickname or email'),
8468 -                                        $this->trimmed('nicknameoremail'),
8469 -                            _('Your nickname on this server, ' .
8470 -                               'or your registered email address.'));
8471 -               common_submit('recover', _('Recover'));
8472 -               common_element_end('form');
8473 -               common_show_footer();
8474 -       }
8475 +        common_element_start('form', array('method' => 'post',
8476 +                                           'id' => 'recoverpassword',
8477 +                                           'action' => common_local_url('recoverpassword')));
8478 +        common_input('nicknameoremail', _('Nickname or email'),
8479 +                     $this->trimmed('nicknameoremail'),
8480 +                     _('Your nickname on this server, ' .
8481 +                        'or your registered email address.'));
8482 +        common_submit('recover', _('Recover'));
8483 +        common_element_end('form');
8484 +        common_show_footer();
8485 +    }
8486 hunk ./actions/recoverpassword.php 176
8487 -       function show_password_form($msg=NULL) {
8488 +    function show_password_form($msg=NULL) {
8489 hunk ./actions/recoverpassword.php 178
8490 -               common_show_header(_('Reset password'), NULL,
8491 -               $msg, array($this, 'show_password_top'));
8492 +        common_show_header(_('Reset password'), NULL,
8493 +        $msg, array($this, 'show_password_top'));
8494 hunk ./actions/recoverpassword.php 181
8495 -               common_element_start('form', array('method' => 'post',
8496 -                                                                                  'id' => 'recoverpassword',
8497 -                                                                                  'action' => common_local_url('recoverpassword')));
8498 -               common_hidden('token', common_session_token());
8499 -               common_password('newpassword', _('New password'),
8500 -                                               _('6 or more characters, and don\'t forget it!'));
8501 -               common_password('confirm', _('Confirm'),
8502 -                                               _('Same as password above'));
8503 -               common_submit('reset', _('Reset'));
8504 -               common_element_end('form');
8505 -               common_show_footer();
8506 -       }
8507 +        common_element_start('form', array('method' => 'post',
8508 +                                           'id' => 'recoverpassword',
8509 +                                           'action' => common_local_url('recoverpassword')));
8510 +        common_hidden('token', common_session_token());
8511 +        common_password('newpassword', _('New password'),
8512 +                        _('6 or more characters, and don\'t forget it!'));
8513 +        common_password('confirm', _('Confirm'),
8514 +                        _('Same as password above'));
8515 +        common_submit('reset', _('Reset'));
8516 +        common_element_end('form');
8517 +        common_show_footer();
8518 +    }
8519 hunk ./actions/recoverpassword.php 194
8520 -       function recover_password() {
8521 -               $nore = $this->trimmed('nicknameoremail');
8522 -               if (!$nore) {
8523 -                       $this->show_form(_('Enter a nickname or email address.'));
8524 -                       return;
8525 -               }
8526 +    function recover_password() {
8527 +        $nore = $this->trimmed('nicknameoremail');
8528 +        if (!$nore) {
8529 +            $this->show_form(_('Enter a nickname or email address.'));
8530 +            return;
8531 +        }
8532 hunk ./actions/recoverpassword.php 201
8533 -               $user = User::staticGet('email', common_canonical_email($nore));
8534 +        $user = User::staticGet('email', common_canonical_email($nore));
8535 hunk ./actions/recoverpassword.php 203
8536 -               if (!$user) {
8537 -                       $user = User::staticGet('nickname', common_canonical_nickname($nore));
8538 -               }
8539 +        if (!$user) {
8540 +            $user = User::staticGet('nickname', common_canonical_nickname($nore));
8541 +        }
8542 hunk ./actions/recoverpassword.php 207
8543 -               # See if it's an unconfirmed email address
8544 +        # See if it's an unconfirmed email address
8545 hunk ./actions/recoverpassword.php 209
8546 -               if (!$user) {
8547 -                       $confirm_email = Confirm_address::staticGet('address', common_canonical_email($nore));
8548 -                       if ($confirm_email && $confirm_email->address_type == 'email') {
8549 -                               $user = User::staticGet($confirm_email->user_id);
8550 -                       }
8551 -               }
8552 +        if (!$user) {
8553 +            $confirm_email = Confirm_address::staticGet('address', common_canonical_email($nore));
8554 +            if ($confirm_email && $confirm_email->address_type == 'email') {
8555 +                $user = User::staticGet($confirm_email->user_id);
8556 +            }
8557 +        }
8558 hunk ./actions/recoverpassword.php 216
8559 -               if (!$user) {
8560 -                       $this->show_form(_('No user with that email address or username.'));
8561 -                       return;
8562 -               }
8563 +        if (!$user) {
8564 +            $this->show_form(_('No user with that email address or username.'));
8565 +            return;
8566 +        }
8567 hunk ./actions/recoverpassword.php 221
8568 -               # Try to get an unconfirmed email address if they used a user name
8569 +        # Try to get an unconfirmed email address if they used a user name
8570 hunk ./actions/recoverpassword.php 223
8571 -               if (!$user->email && !$confirm_email) {
8572 -                       $confirm_email = Confirm_address::staticGet('user_id', $user->id);
8573 -                       if ($confirm_email && $confirm_email->address_type != 'email') {
8574 -                               # Skip non-email confirmations
8575 -                               $confirm_email = NULL;
8576 -                       }
8577 -               }
8578 +        if (!$user->email && !$confirm_email) {
8579 +            $confirm_email = Confirm_address::staticGet('user_id', $user->id);
8580 +            if ($confirm_email && $confirm_email->address_type != 'email') {
8581 +                # Skip non-email confirmations
8582 +                $confirm_email = NULL;
8583 +            }
8584 +        }
8585 hunk ./actions/recoverpassword.php 231
8586 -               if (!$user->email && !$confirm_email) {
8587 -                       $this->client_error(_('No registered email address for that user.'));
8588 -                       return;
8589 -               }
8590 +        if (!$user->email && !$confirm_email) {
8591 +            $this->client_error(_('No registered email address for that user.'));
8592 +            return;
8593 +        }
8594 hunk ./actions/recoverpassword.php 236
8595 -               # Success! We have a valid user and a confirmed or unconfirmed email address
8596 +        # Success! We have a valid user and a confirmed or unconfirmed email address
8597 hunk ./actions/recoverpassword.php 238
8598 -               $confirm = new Confirm_address();
8599 -               $confirm->code = common_confirmation_code(128);
8600 -               $confirm->address_type = 'recover';
8601 -               $confirm->user_id = $user->id;
8602 -               $confirm->address = (isset($user->email)) ? $user->email : $confirm_email->address;
8603 +        $confirm = new Confirm_address();
8604 +        $confirm->code = common_confirmation_code(128);
8605 +        $confirm->address_type = 'recover';
8606 +        $confirm->user_id = $user->id;
8607 +        $confirm->address = (isset($user->email)) ? $user->email : $confirm_email->address;
8608 hunk ./actions/recoverpassword.php 244
8609 -               if (!$confirm->insert()) {
8610 -                       common_log_db_error($confirm, 'INSERT', __FILE__);
8611 -                       $this->server_error(_('Error saving address confirmation.'));
8612 -                       return;
8613 -               }
8614 +        if (!$confirm->insert()) {
8615 +            common_log_db_error($confirm, 'INSERT', __FILE__);
8616 +            $this->server_error(_('Error saving address confirmation.'));
8617 +            return;
8618 +        }
8619 hunk ./actions/recoverpassword.php 250
8620 -               $body = "Hey, $user->nickname.";
8621 -               $body .= "\n\n";
8622 -               $body .= 'Someone just asked for a new password ' .
8623 -                        'for this account on ' . common_config('site', 'name') . '.';
8624 -               $body .= "\n\n";
8625 -               $body .= 'If it was you, and you want to confirm, use the URL below:';
8626 -               $body .= "\n\n";
8627 -               $body .= "\t".common_local_url('recoverpassword',
8628 -                                                                  array('code' => $confirm->code));
8629 -               $body .= "\n\n";
8630 -               $body .= 'If not, just ignore this message.';
8631 -               $body .= "\n\n";
8632 -               $body .= 'Thanks for your time, ';
8633 -               $body .= "\n";
8634 -               $body .= common_config('site', 'name');
8635 -               $body .= "\n";
8636 +        $body = "Hey, $user->nickname.";
8637 +        $body .= "\n\n";
8638 +        $body .= 'Someone just asked for a new password ' .
8639 +                 'for this account on ' . common_config('site', 'name') . '.';
8640 +        $body .= "\n\n";
8641 +        $body .= 'If it was you, and you want to confirm, use the URL below:';
8642 +        $body .= "\n\n";
8643 +        $body .= "\t".common_local_url('recoverpassword',
8644 +                                   array('code' => $confirm->code));
8645 +        $body .= "\n\n";
8646 +        $body .= 'If not, just ignore this message.';
8647 +        $body .= "\n\n";
8648 +        $body .= 'Thanks for your time, ';
8649 +        $body .= "\n";
8650 +        $body .= common_config('site', 'name');
8651 +        $body .= "\n";
8652 hunk ./actions/recoverpassword.php 267
8653 -               mail_to_user($user, _('Password recovery requested'), $body, $confirm->address);
8654 +        mail_to_user($user, _('Password recovery requested'), $body, $confirm->address);
8655 hunk ./actions/recoverpassword.php 269
8656 -               common_show_header(_('Password recovery requested'));
8657 -               common_element('p', NULL,
8658 -                              _('Instructions for recovering your password ' .
8659 -                                 'have been sent to the email address registered to your ' .
8660 -                                 'account.'));
8661 -               common_show_footer();
8662 -       }
8663 +        common_show_header(_('Password recovery requested'));
8664 +        common_element('p', NULL,
8665 +                       _('Instructions for recovering your password ' .
8666 +                          'have been sent to the email address registered to your ' .
8667 +                          'account.'));
8668 +        common_show_footer();
8669 +    }
8670 hunk ./actions/recoverpassword.php 277
8671 -       function reset_password() {
8672 +    function reset_password() {
8673 hunk ./actions/recoverpassword.php 279
8674 -               # CSRF protection
8675 -               $token = $this->trimmed('token');
8676 -               if (!$token || $token != common_session_token()) {
8677 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
8678 -                       return;
8679 -               }
8680 +        # CSRF protection
8681 +        $token = $this->trimmed('token');
8682 +        if (!$token || $token != common_session_token()) {
8683 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
8684 +            return;
8685 +        }
8686 hunk ./actions/recoverpassword.php 286
8687 -               $user = $this->get_temp_user();
8688 +        $user = $this->get_temp_user();
8689 hunk ./actions/recoverpassword.php 288
8690 -               if (!$user) {
8691 -                       $this->client_error(_('Unexpected password reset.'));
8692 -                       return;
8693 -               }
8694 +        if (!$user) {
8695 +            $this->client_error(_('Unexpected password reset.'));
8696 +            return;
8697 +        }
8698 hunk ./actions/recoverpassword.php 293
8699 -               $newpassword = $this->trimmed('newpassword');
8700 -               $confirm = $this->trimmed('confirm');
8701 +        $newpassword = $this->trimmed('newpassword');
8702 +        $confirm = $this->trimmed('confirm');
8703 hunk ./actions/recoverpassword.php 296
8704 -               if (!$newpassword || strlen($newpassword) < 6) {
8705 -                       $this->show_password_form(_('Password must be 6 chars or more.'));
8706 -                       return;
8707 -               }
8708 -               if ($newpassword != $confirm) {
8709 -                       $this->show_password_form(_('Password and confirmation do not match.'));
8710 -                       return;
8711 -               }
8712 +        if (!$newpassword || strlen($newpassword) < 6) {
8713 +            $this->show_password_form(_('Password must be 6 chars or more.'));
8714 +            return;
8715 +        }
8716 +        if ($newpassword != $confirm) {
8717 +            $this->show_password_form(_('Password and confirmation do not match.'));
8718 +            return;
8719 +        }
8720 hunk ./actions/recoverpassword.php 305
8721 -               # OK, we're ready to go
8722 +        # OK, we're ready to go
8723 hunk ./actions/recoverpassword.php 307
8724 -               $original = clone($user);
8725 +        $original = clone($user);
8726 hunk ./actions/recoverpassword.php 309
8727 -               $user->password = common_munge_password($newpassword, $user->id);
8728 +        $user->password = common_munge_password($newpassword, $user->id);
8729 hunk ./actions/recoverpassword.php 311
8730 -               if (!$user->update($original)) {
8731 -                       common_log_db_error($user, 'UPDATE', __FILE__);
8732 -                       common_server_error(_('Can\'t save new password.'));
8733 -                       return;
8734 -               }
8735 +        if (!$user->update($original)) {
8736 +            common_log_db_error($user, 'UPDATE', __FILE__);
8737 +            common_server_error(_('Can\'t save new password.'));
8738 +            return;
8739 +        }
8740 hunk ./actions/recoverpassword.php 317
8741 -               $this->clear_temp_user();
8742 +        $this->clear_temp_user();
8743 hunk ./actions/recoverpassword.php 319
8744 -               if (!common_set_user($user->nickname)) {
8745 -                       common_server_error(_('Error setting user.'));
8746 -                       return;
8747 -               }
8748 +        if (!common_set_user($user->nickname)) {
8749 +            common_server_error(_('Error setting user.'));
8750 +            return;
8751 +        }
8752 hunk ./actions/recoverpassword.php 324
8753 -               common_real_login(true);
8754 +        common_real_login(true);
8755 hunk ./actions/recoverpassword.php 326
8756 -               common_show_header(_('Password saved.'));
8757 -               common_element('p', NULL, _('New password successfully saved. ' .
8758 -                                            'You are now logged in.'));
8759 -               common_show_footer();
8760 -       }
8761 +        common_show_header(_('Password saved.'));
8762 +        common_element('p', NULL, _('New password successfully saved. ' .
8763 +                                     'You are now logged in.'));
8764 +        common_show_footer();
8765 +    }
8766 hunk ./actions/register.php 24
8767 -       function handle($args) {
8768 -               parent::handle($args);
8769 +    function handle($args) {
8770 +        parent::handle($args);
8771 hunk ./actions/register.php 27
8772 -               if (common_config('site', 'closed')) {
8773 -                       common_user_error(_('Registration not allowed.'));
8774 -               } else if (common_logged_in()) {
8775 -                       common_user_error(_('Already logged in.'));
8776 -               } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
8777 -                       $this->try_register();
8778 -               } else {
8779 -                       $this->show_form();
8780 -               }
8781 -       }
8782 +        if (common_config('site', 'closed')) {
8783 +            common_user_error(_('Registration not allowed.'));
8784 +        } else if (common_logged_in()) {
8785 +            common_user_error(_('Already logged in.'));
8786 +        } else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
8787 +            $this->try_register();
8788 +        } else {
8789 +            $this->show_form();
8790 +        }
8791 +    }
8792 hunk ./actions/register.php 38
8793 -       function try_register() {
8794 +    function try_register() {
8795 hunk ./actions/register.php 40
8796 -               $token = $this->trimmed('token');
8797 -               if (!$token || $token != common_session_token()) {
8798 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
8799 -                       return;
8800 -               }
8801 +        $token = $this->trimmed('token');
8802 +        if (!$token || $token != common_session_token()) {
8803 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
8804 +            return;
8805 +        }
8806 hunk ./actions/register.php 46
8807 -               $nickname = $this->trimmed('nickname');
8808 -               $email = $this->trimmed('email');
8809 -               $fullname = $this->trimmed('fullname');
8810 -               $homepage = $this->trimmed('homepage');
8811 -               $bio = $this->trimmed('bio');
8812 -               $location = $this->trimmed('location');
8813 +        $nickname = $this->trimmed('nickname');
8814 +        $email = $this->trimmed('email');
8815 +        $fullname = $this->trimmed('fullname');
8816 +        $homepage = $this->trimmed('homepage');
8817 +        $bio = $this->trimmed('bio');
8818 +        $location = $this->trimmed('location');
8819 hunk ./actions/register.php 53
8820 -               # We don't trim these... whitespace is OK in a password!
8821 +        # We don't trim these... whitespace is OK in a password!
8822 hunk ./actions/register.php 55
8823 -               $password = $this->arg('password');
8824 -               $confirm = $this->arg('confirm');
8825 +        $password = $this->arg('password');
8826 +        $confirm = $this->arg('confirm');
8827 hunk ./actions/register.php 58
8828 -               # invitation code, if any
8829 +        # invitation code, if any
8830 hunk ./actions/register.php 60
8831 -               $code = $this->trimmed('code');
8832 +        $code = $this->trimmed('code');
8833 hunk ./actions/register.php 62
8834 -               if ($code) {
8835 -                       $invite = Invitation::staticGet($code);
8836 -               }
8837 +        if ($code) {
8838 +            $invite = Invitation::staticGet($code);
8839 +        }
8840 hunk ./actions/register.php 66
8841 -               if (common_config('site', 'inviteonly') && !($code && $invite)) {
8842 -                       $this->client_error(_('Sorry, only invited people can register.'));
8843 -                       return;
8844 -               }
8845 +        if (common_config('site', 'inviteonly') && !($code && $invite)) {
8846 +            $this->client_error(_('Sorry, only invited people can register.'));
8847 +            return;
8848 +        }
8849 hunk ./actions/register.php 71
8850 -               # Input scrubbing
8851 +        # Input scrubbing
8852 hunk ./actions/register.php 73
8853 -               $nickname = common_canonical_nickname($nickname);
8854 -               $email = common_canonical_email($email);
8855 +        $nickname = common_canonical_nickname($nickname);
8856 +        $email = common_canonical_email($email);
8857 hunk ./actions/register.php 76
8858 -               if (!$this->boolean('license')) {
8859 -                       $this->show_form(_('You can\'t register if you don\'t agree to the license.'));
8860 -               } else if ($email && !Validate::email($email, true)) {
8861 -                       $this->show_form(_('Not a valid email address.'));
8862 -               } else if (!Validate::string($nickname, array('min_length' => 1,
8863 -                                                                                                         'max_length' => 64,
8864 -                                                                                                         'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
8865 -                       $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.'));
8866 -               } else if ($this->nickname_exists($nickname)) {
8867 -                       $this->show_form(_('Nickname already in use. Try another one.'));
8868 -               } else if (!User::allowed_nickname($nickname)) {
8869 -                       $this->show_form(_('Not a valid nickname.'));
8870 -               } else if ($this->email_exists($email)) {
8871 -                       $this->show_form(_('Email address already exists.'));
8872 -               } else if (!is_null($homepage) && (strlen($homepage) > 0) &&
8873 -                                  !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
8874 -                       $this->show_form(_('Homepage is not a valid URL.'));
8875 -                       return;
8876 -               } else if (!is_null($fullname) && strlen($fullname) > 255) {
8877 -                       $this->show_form(_('Full name is too long (max 255 chars).'));
8878 -                       return;
8879 -               } else if (!is_null($bio) && strlen($bio) > 140) {
8880 -                       $this->show_form(_('Bio is too long (max 140 chars).'));
8881 -                       return;
8882 -               } else if (!is_null($location) && strlen($location) > 255) {
8883 -                       $this->show_form(_('Location is too long (max 255 chars).'));
8884 -                       return;
8885 -               } else if (strlen($password) < 6) {
8886 -                       $this->show_form(_('Password must be 6 or more characters.'));
8887 -                       return;
8888 -               } else if ($password != $confirm) {
8889 -                       $this->show_form(_('Passwords don\'t match.'));
8890 -               } else if ($user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email,
8891 -                                                                                               'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio,
8892 -                                                                                               'location' => $location, 'code' => $code))) {
8893 -                       if (!$user) {
8894 -                               $this->show_form(_('Invalid username or password.'));
8895 -                               return;
8896 -                       }
8897 -                       # success!
8898 -                       if (!common_set_user($user)) {
8899 -                               common_server_error(_('Error setting user.'));
8900 -                               return;
8901 -                       }
8902 -                       # this is a real login
8903 -                       common_real_login(true);
8904 -                       if ($this->boolean('rememberme')) {
8905 -                               common_debug('Adding rememberme cookie for ' . $nickname);
8906 -                               common_rememberme($user);
8907 -                       }
8908 -                       # Re-init language env in case it changed (not yet, but soon)
8909 -                       common_init_language();
8910 -                       $this->show_success();
8911 -               } else {
8912 -                       $this->show_form(_('Invalid username or password.'));
8913 -               }
8914 -       }
8915 +        if (!$this->boolean('license')) {
8916 +            $this->show_form(_('You can\'t register if you don\'t agree to the license.'));
8917 +        } else if ($email && !Validate::email($email, true)) {
8918 +            $this->show_form(_('Not a valid email address.'));
8919 +        } else if (!Validate::string($nickname, array('min_length' => 1,
8920 +                                                      'max_length' => 64,
8921 +                                                      'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
8922 +            $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.'));
8923 +        } else if ($this->nickname_exists($nickname)) {
8924 +            $this->show_form(_('Nickname already in use. Try another one.'));
8925 +        } else if (!User::allowed_nickname($nickname)) {
8926 +            $this->show_form(_('Not a valid nickname.'));
8927 +        } else if ($this->email_exists($email)) {
8928 +            $this->show_form(_('Email address already exists.'));
8929 +        } else if (!is_null($homepage) && (strlen($homepage) > 0) &&
8930 +                   !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
8931 +            $this->show_form(_('Homepage is not a valid URL.'));
8932 +            return;
8933 +        } else if (!is_null($fullname) && strlen($fullname) > 255) {
8934 +            $this->show_form(_('Full name is too long (max 255 chars).'));
8935 +            return;
8936 +        } else if (!is_null($bio) && strlen($bio) > 140) {
8937 +            $this->show_form(_('Bio is too long (max 140 chars).'));
8938 +            return;
8939 +        } else if (!is_null($location) && strlen($location) > 255) {
8940 +            $this->show_form(_('Location is too long (max 255 chars).'));
8941 +            return;
8942 +        } else if (strlen($password) < 6) {
8943 +            $this->show_form(_('Password must be 6 or more characters.'));
8944 +            return;
8945 +        } else if ($password != $confirm) {
8946 +            $this->show_form(_('Passwords don\'t match.'));
8947 +        } else if ($user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email,
8948 +                                                'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio,
8949 +                                                'location' => $location, 'code' => $code))) {
8950 +            if (!$user) {
8951 +                $this->show_form(_('Invalid username or password.'));
8952 +                return;
8953 +            }
8954 +            # success!
8955 +            if (!common_set_user($user)) {
8956 +                common_server_error(_('Error setting user.'));
8957 +                return;
8958 +            }
8959 +            # this is a real login
8960 +            common_real_login(true);
8961 +            if ($this->boolean('rememberme')) {
8962 +                common_debug('Adding rememberme cookie for ' . $nickname);
8963 +                common_rememberme($user);
8964 +            }
8965 +            # Re-init language env in case it changed (not yet, but soon)
8966 +            common_init_language();
8967 +            $this->show_success();
8968 +        } else {
8969 +            $this->show_form(_('Invalid username or password.'));
8970 +        }
8971 +    }
8972 hunk ./actions/register.php 134
8973 -       # checks if *CANONICAL* nickname exists
8974 +    # checks if *CANONICAL* nickname exists
8975 hunk ./actions/register.php 136
8976 -       function nickname_exists($nickname) {
8977 -               $user = User::staticGet('nickname', $nickname);
8978 -               return ($user !== false);
8979 -       }
8980 +    function nickname_exists($nickname) {
8981 +        $user = User::staticGet('nickname', $nickname);
8982 +        return ($user !== false);
8983 +    }
8984 hunk ./actions/register.php 141
8985 -       # checks if *CANONICAL* email exists
8986 +    # checks if *CANONICAL* email exists
8987 hunk ./actions/register.php 143
8988 -       function email_exists($email) {
8989 -               $email = common_canonical_email($email);
8990 -               if (!$email || strlen($email) == 0) {
8991 -                       return false;
8992 -               }
8993 -               $user = User::staticGet('email', $email);
8994 -               return ($user !== false);
8995 -       }
8996 +    function email_exists($email) {
8997 +        $email = common_canonical_email($email);
8998 +        if (!$email || strlen($email) == 0) {
8999 +            return false;
9000 +        }
9001 +        $user = User::staticGet('email', $email);
9002 +        return ($user !== false);
9003 +    }
9004 hunk ./actions/register.php 152
9005 -       function show_top($error=NULL) {
9006 -               if ($error) {
9007 -                       common_element('p', 'error', $error);
9008 -               } else {
9009 -                       $instr = common_markup_to_html(_('With this form you can create a new account. ' .
9010 -                                                                                        'You can then post notices and link up to friends and colleagues. '.
9011 -                                                                                        '(Have an [OpenID](http://openid.net/)? ' .
9012 -                                                                                        'Try our [OpenID registration](%%action.openidlogin%%)!)'));
9013 +    function show_top($error=NULL) {
9014 +        if ($error) {
9015 +            common_element('p', 'error', $error);
9016 +        } else {
9017 +            $instr = common_markup_to_html(_('With this form you can create a new account. ' .
9018 +                                             'You can then post notices and link up to friends and colleagues. '.
9019 +                                             '(Have an [OpenID](http://openid.net/)? ' .
9020 +                                             'Try our [OpenID registration](%%action.openidlogin%%)!)'));
9021 hunk ./actions/register.php 161
9022 -                       common_element_start('div', 'instructions');
9023 -                       common_raw($instr);
9024 -                       common_element_end('div');
9025 -               }
9026 -       }
9027 +            common_element_start('div', 'instructions');
9028 +            common_raw($instr);
9029 +            common_element_end('div');
9030 +        }
9031 +    }
9032 hunk ./actions/register.php 167
9033 -       function show_form($error=NULL) {
9034 -               global $config;
9035 +    function show_form($error=NULL) {
9036 +        global $config;
9037 hunk ./actions/register.php 170
9038 -               $code = $this->trimmed('code');
9039 +        $code = $this->trimmed('code');
9040 hunk ./actions/register.php 172
9041 -               if ($code) {
9042 -                       $invite = Invitation::staticGet($code);
9043 -               }
9044 +        if ($code) {
9045 +            $invite = Invitation::staticGet($code);
9046 +        }
9047 hunk ./actions/register.php 176
9048 -               if (common_config('site', 'inviteonly') && !($code && $invite)) {
9049 -                       $this->client_error(_('Sorry, only invited people can register.'));
9050 -                       return;
9051 -               }
9052 +        if (common_config('site', 'inviteonly') && !($code && $invite)) {
9053 +            $this->client_error(_('Sorry, only invited people can register.'));
9054 +            return;
9055 +        }
9056 hunk ./actions/register.php 181
9057 -               common_show_header(_('Register'), NULL, $error, array($this, 'show_top'));
9058 -               common_element_start('form', array('method' => 'post',
9059 -                                                                                  'id' => 'login',
9060 -                                                                                  'action' => common_local_url('register')));
9061 +        common_show_header(_('Register'), NULL, $error, array($this, 'show_top'));
9062 +        common_element_start('form', array('method' => 'post',
9063 +                                           'id' => 'login',
9064 +                                           'action' => common_local_url('register')));
9065 hunk ./actions/register.php 186
9066 -               common_hidden('token', common_session_token());
9067 +        common_hidden('token', common_session_token());
9068 hunk ./actions/register.php 188
9069 -               if ($code) {
9070 -                       common_hidden('code', $code);
9071 -               }
9072 +        if ($code) {
9073 +            common_hidden('code', $code);
9074 +        }
9075 hunk ./actions/register.php 192
9076 -               common_input('nickname', _('Nickname'), $this->trimmed('nickname'),
9077 -                                        _('1-64 lowercase letters or numbers, no punctuation or spaces. Required.'));
9078 -               common_password('password', _('Password'),
9079 -                                               _('6 or more characters. Required.'));
9080 -               common_password('confirm', _('Confirm'),
9081 -                                               _('Same as password above. Required.'));
9082 -               if ($invite && $invite->address_type == 'email') {
9083 -                       common_input('email', _('Email'), $invite->address,
9084 -                                        _('Used only for updates, announcements, and password recovery'));
9085 -               } else {
9086 -                       common_input('email', _('Email'), $this->trimmed('email'),
9087 -                                                _('Used only for updates, announcements, and password recovery'));
9088 -               }
9089 -               common_input('fullname', _('Full name'),
9090 -                                        $this->trimmed('fullname'),
9091 -                                         _('Longer name, preferably your "real" name'));
9092 -               common_input('homepage', _('Homepage'),
9093 -                                        $this->trimmed('homepage'),
9094 -                                        _('URL of your homepage, blog, or profile on another site'));
9095 -               common_textarea('bio', _('Bio'),
9096 -                                               $this->trimmed('bio'),
9097 -                                                _('Describe yourself and your interests in 140 chars'));
9098 -               common_input('location', _('Location'),
9099 -                                        $this->trimmed('location'),
9100 -                                        _('Where you are, like "City, State (or Region), Country"'));
9101 -               common_checkbox('rememberme', _('Remember me'),
9102 -                                               $this->boolean('rememberme'),
9103 -                               _('Automatically login in the future; not for shared computers!'));
9104 -               common_element_start('p');
9105 -               $attrs = array('type' => 'checkbox',
9106 -                                          'id' => 'license',
9107 -                                          'name' => 'license',
9108 -                                          'value' => 'true');
9109 -               if ($this->boolean('license')) {
9110 -                       $attrs['checked'] = 'checked';
9111 -               }
9112 -               common_element('input', $attrs);
9113 -           common_text(_('My text and files are available under '));
9114 -               common_element('a', array('href' => $config['license']['url']),
9115 -                                          $config['license']['title']);
9116 -               common_text(_(' except this private data: password, email address, IM address, phone number.'));
9117 -               common_element_end('p');
9118 -               common_submit('submit', _('Register'));
9119 -               common_element_end('form');
9120 -               common_show_footer();
9121 -       }
9122 +        common_input('nickname', _('Nickname'), $this->trimmed('nickname'),
9123 +                     _('1-64 lowercase letters or numbers, no punctuation or spaces. Required.'));
9124 +        common_password('password', _('Password'),
9125 +                        _('6 or more characters. Required.'));
9126 +        common_password('confirm', _('Confirm'),
9127 +                        _('Same as password above. Required.'));
9128 +        if ($invite && $invite->address_type == 'email') {
9129 +            common_input('email', _('Email'), $invite->address,
9130 +                     _('Used only for updates, announcements, and password recovery'));
9131 +        } else {
9132 +            common_input('email', _('Email'), $this->trimmed('email'),
9133 +                         _('Used only for updates, announcements, and password recovery'));
9134 +        }
9135 +        common_input('fullname', _('Full name'),
9136 +                     $this->trimmed('fullname'),
9137 +                      _('Longer name, preferably your "real" name'));
9138 +        common_input('homepage', _('Homepage'),
9139 +                     $this->trimmed('homepage'),
9140 +                     _('URL of your homepage, blog, or profile on another site'));
9141 +        common_textarea('bio', _('Bio'),
9142 +                        $this->trimmed('bio'),
9143 +                         _('Describe yourself and your interests in 140 chars'));
9144 +        common_input('location', _('Location'),
9145 +                     $this->trimmed('location'),
9146 +                     _('Where you are, like "City, State (or Region), Country"'));
9147 +        common_checkbox('rememberme', _('Remember me'),
9148 +                        $this->boolean('rememberme'),
9149 +                        _('Automatically login in the future; not for shared computers!'));
9150 +        common_element_start('p');
9151 +        $attrs = array('type' => 'checkbox',
9152 +                       'id' => 'license',
9153 +                       'name' => 'license',
9154 +                       'value' => 'true');
9155 +        if ($this->boolean('license')) {
9156 +            $attrs['checked'] = 'checked';
9157 +        }
9158 +        common_element('input', $attrs);
9159 +        common_text(_('My text and files are available under '));
9160 +        common_element('a', array('href' => $config['license']['url']),
9161 +                       $config['license']['title']);
9162 +        common_text(_(' except this private data: password, email address, IM address, phone number.'));
9163 +        common_element_end('p');
9164 +        common_submit('submit', _('Register'));
9165 +        common_element_end('form');
9166 +        common_show_footer();
9167 +    }
9168 hunk ./actions/register.php 239
9169 -       function show_success() {
9170 -               $nickname = $this->arg('nickname');
9171 -               common_show_header(_('Registration successful'));
9172 -               common_element_start('div', 'success');
9173 -               $instr = sprintf(_('Congratulations, %s! And welcome to %%%%site.name%%%%. From here, you may want to...'. "\n\n" .
9174 -                                                  '* Go to [your profile](%s) and post your first message.' .  "\n" .
9175 -                                                  '* Add a [Jabber/GTalk address](%%%%action.imsettings%%%%) so you can send notices through instant messages.' . "\n" .
9176 -                                                  '* [Search for people](%%%%action.peoplesearch%%%%) that you may know or that share your interests. ' . "\n" .
9177 -                                                  '* Update your [profile settings](%%%%action.profilesettings%%%%) to tell others more about you. ' . "\n" .
9178 -                                                  '* Read over the [online docs](%%%%doc.help%%%%) for features you may have missed. ' . "\n\n" .
9179 -                                                  'Thanks for signing up and we hope you enjoy using this service.'),
9180 -                                                $nickname, common_local_url('showstream', array('nickname' => $nickname)));
9181 -               common_raw(common_markup_to_html($instr));
9182 -               $have_email = $this->trimmed('email');
9183 -               if ($have_email) {
9184 -                       $emailinstr = _('(You should receive a message by email momentarily, with ' .
9185 -                                                       'instructions on how to confirm your email address.)');
9186 -                       common_raw(common_markup_to_html($emailinstr));
9187 -               }
9188 -               common_element_end('div');
9189 -               common_show_footer();
9190 -       }
9191 +    function show_success() {
9192 +        $nickname = $this->arg('nickname');
9193 +        common_show_header(_('Registration successful'));
9194 +        common_element_start('div', 'success');
9195 +        $instr = sprintf(_('Congratulations, %s! And welcome to %%%%site.name%%%%. From here, you may want to...'. "\n\n" .
9196 +                           '* Go to [your profile](%s) and post your first message.' .  "\n" .
9197 +                           '* Add a [Jabber/GTalk address](%%%%action.imsettings%%%%) so you can send notices through instant messages.' . "\n" .
9198 +                           '* [Search for people](%%%%action.peoplesearch%%%%) that you may know or that share your interests. ' . "\n" .
9199 +                           '* Update your [profile settings](%%%%action.profilesettings%%%%) to tell others more about you. ' . "\n" .
9200 +                           '* Read over the [online docs](%%%%doc.help%%%%) for features you may have missed. ' . "\n\n" .
9201 +                           'Thanks for signing up and we hope you enjoy using this service.'),
9202 +                         $nickname, common_local_url('showstream', array('nickname' => $nickname)));
9203 +        common_raw(common_markup_to_html($instr));
9204 +        $have_email = $this->trimmed('email');
9205 +        if ($have_email) {
9206 +            $emailinstr = _('(You should receive a message by email momentarily, with ' .
9207 +                            'instructions on how to confirm your email address.)');
9208 +            common_raw(common_markup_to_html($emailinstr));
9209 +        }
9210 +        common_element_end('div');
9211 +        common_show_footer();
9212 +    }
9213 hunk ./actions/remotesubscribe.php 26
9214 -       function handle($args) {
9215 +    function handle($args) {
9216 hunk ./actions/remotesubscribe.php 28
9217 -               parent::handle($args);
9218 +        parent::handle($args);
9219 hunk ./actions/remotesubscribe.php 30
9220 -               if (common_logged_in()) {
9221 -                       common_user_error(_('You can use the local subscription!'));
9222 -                   return;
9223 -               }
9224 +        if (common_logged_in()) {
9225 +            common_user_error(_('You can use the local subscription!'));
9226 +            return;
9227 +        }
9228 hunk ./actions/remotesubscribe.php 35
9229 -               if ($_SERVER['REQUEST_METHOD'] == 'POST') {
9230 +        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
9231 hunk ./actions/remotesubscribe.php 37
9232 -                       # CSRF protection
9233 -                       $token = $this->trimmed('token');
9234 -                       if (!$token || $token != common_session_token()) {
9235 -                               $this->show_form(_('There was a problem with your session token. Try again, please.'));
9236 -                               return;
9237 -                       }
9238 +            # CSRF protection
9239 +            $token = $this->trimmed('token');
9240 +            if (!$token || $token != common_session_token()) {
9241 +                $this->show_form(_('There was a problem with your session token. Try again, please.'));
9242 +                return;
9243 +            }
9244 hunk ./actions/remotesubscribe.php 44
9245 -                       $this->remote_subscription();
9246 -               } else {
9247 -                       $this->show_form();
9248 -               }
9249 -       }
9250 +            $this->remote_subscription();
9251 +        } else {
9252 +            $this->show_form();
9253 +        }
9254 +    }
9255 hunk ./actions/remotesubscribe.php 50
9256 -       function get_instructions() {
9257 -               return _('To subscribe, you can [login](%%action.login%%),' .
9258 -                         ' or [register](%%action.register%%) a new ' .
9259 -                         ' account. If you already have an account ' .
9260 -                         ' on a [compatible microblogging site](%%doc.openmublog%%), ' .
9261 -                         ' enter your profile URL below.');
9262 -       }
9263 +    function get_instructions() {
9264 +        return _('To subscribe, you can [login](%%action.login%%),' .
9265 +                  ' or [register](%%action.register%%) a new ' .
9266 +                  ' account. If you already have an account ' .
9267 +                  ' on a [compatible microblogging site](%%doc.openmublog%%), ' .
9268 +                  ' enter your profile URL below.');
9269 +    }
9270 hunk ./actions/remotesubscribe.php 58
9271 -       function show_top($err=NULL) {
9272 -               if ($err) {
9273 -                       common_element('div', 'error', $err);
9274 -               } else {
9275 -                       $instructions = $this->get_instructions();
9276 -                       $output = common_markup_to_html($instructions);
9277 -                       common_element_start('div', 'instructions');
9278 -                       common_raw($output);
9279 -                       common_element_end('p');
9280 -               }
9281 -       }
9282 +    function show_top($err=NULL) {
9283 +        if ($err) {
9284 +            common_element('div', 'error', $err);
9285 +        } else {
9286 +            $instructions = $this->get_instructions();
9287 +            $output = common_markup_to_html($instructions);
9288 +            common_element_start('div', 'instructions');
9289 +            common_raw($output);
9290 +            common_element_end('p');
9291 +        }
9292 +    }
9293 hunk ./actions/remotesubscribe.php 70
9294 -       function show_form($err=NULL) {
9295 -               $nickname = $this->trimmed('nickname');
9296 -               $profile = $this->trimmed('profile_url');
9297 -               common_show_header(_('Remote subscribe'), NULL, $err,
9298 -                                                  array($this, 'show_top'));
9299 -               # id = remotesubscribe conflicts with the
9300 -               # button on profile page
9301 -               common_element_start('form', array('id' => 'remsub', 'method' => 'post',
9302 -                                                                                  'action' => common_local_url('remotesubscribe')));
9303 -               common_hidden('token', common_session_token());
9304 -               common_input('nickname', _('User nickname'), $nickname,
9305 -                                        _('Nickname of the user you want to follow'));
9306 -               common_input('profile_url', _('Profile URL'), $profile,
9307 -                                        _('URL of your profile on another compatible microblogging service'));
9308 -               common_submit('submit', _('Subscribe'));
9309 -               common_element_end('form');
9310 -               common_show_footer();
9311 -       }
9312 +    function show_form($err=NULL) {
9313 +        $nickname = $this->trimmed('nickname');
9314 +        $profile = $this->trimmed('profile_url');
9315 +        common_show_header(_('Remote subscribe'), NULL, $err,
9316 +                           array($this, 'show_top'));
9317 +        # id = remotesubscribe conflicts with the
9318 +        # button on profile page
9319 +        common_element_start('form', array('id' => 'remsub', 'method' => 'post',
9320 +                                           'action' => common_local_url('remotesubscribe')));
9321 +        common_hidden('token', common_session_token());
9322 +        common_input('nickname', _('User nickname'), $nickname,
9323 +                     _('Nickname of the user you want to follow'));
9324 +        common_input('profile_url', _('Profile URL'), $profile,
9325 +                     _('URL of your profile on another compatible microblogging service'));
9326 +        common_submit('submit', _('Subscribe'));
9327 +        common_element_end('form');
9328 +        common_show_footer();
9329 +    }
9330 hunk ./actions/remotesubscribe.php 89
9331 -       function remote_subscription() {
9332 -               $user = $this->get_user();
9333 +    function remote_subscription() {
9334 +        $user = $this->get_user();
9335 hunk ./actions/remotesubscribe.php 92
9336 -               if (!$user) {
9337 -                       $this->show_form(_('No such user.'));
9338 -                       return;
9339 -               }
9340 +        if (!$user) {
9341 +            $this->show_form(_('No such user.'));
9342 +            return;
9343 +        }
9344 hunk ./actions/remotesubscribe.php 97
9345 -               $profile = $this->trimmed('profile_url');
9346 +        $profile = $this->trimmed('profile_url');
9347 hunk ./actions/remotesubscribe.php 99
9348 -               if (!$profile) {
9349 -                       $this->show_form(_('No such user.'));
9350 -                       return;
9351 -               }
9352 +        if (!$profile) {
9353 +            $this->show_form(_('No such user.'));
9354 +            return;
9355 +        }
9356 hunk ./actions/remotesubscribe.php 104
9357 -               if (!Validate::uri($profile, array('allowed_schemes' => array('http', 'https')))) {
9358 -                       $this->show_form(_('Invalid profile URL (bad format)'));
9359 -                       return;
9360 -               }
9361 +        if (!Validate::uri($profile, array('allowed_schemes' => array('http', 'https')))) {
9362 +            $this->show_form(_('Invalid profile URL (bad format)'));
9363 +            return;
9364 +        }
9365 hunk ./actions/remotesubscribe.php 109
9366 -               $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
9367 -               $yadis = Auth_Yadis_Yadis::discover($profile, $fetcher);
9368 +        $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
9369 +        $yadis = Auth_Yadis_Yadis::discover($profile, $fetcher);
9370 hunk ./actions/remotesubscribe.php 112
9371 -               if (!$yadis || $yadis->failed) {
9372 -                       $this->show_form(_('Not a valid profile URL (no YADIS document).'));
9373 -                       return;
9374 -               }
9375 +        if (!$yadis || $yadis->failed) {
9376 +            $this->show_form(_('Not a valid profile URL (no YADIS document).'));
9377 +            return;
9378 +        }
9379 hunk ./actions/remotesubscribe.php 117
9380 -               # XXX: a little liberal for sites that accidentally put whitespace before the xml declaration
9381 +        # XXX: a little liberal for sites that accidentally put whitespace before the xml declaration
9382 hunk ./actions/remotesubscribe.php 121
9383 -               if (!$xrds) {
9384 -                       $this->show_form(_('Not a valid profile URL (no XRDS defined).'));
9385 -                       return;
9386 -               }
9387 +        if (!$xrds) {
9388 +            $this->show_form(_('Not a valid profile URL (no XRDS defined).'));
9389 +            return;
9390 +        }
9391 hunk ./actions/remotesubscribe.php 126
9392 -               $omb = $this->getOmb($xrds);
9393 +        $omb = $this->getOmb($xrds);
9394 hunk ./actions/remotesubscribe.php 128
9395 -               if (!$omb) {
9396 -                       $this->show_form(_('Not a valid profile URL (incorrect services).'));
9397 -                       return;
9398 -               }
9399 +        if (!$omb) {
9400 +            $this->show_form(_('Not a valid profile URL (incorrect services).'));
9401 +            return;
9402 +        }
9403 hunk ./actions/remotesubscribe.php 133
9404 -               if (omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]) ==
9405 -                       common_local_url('requesttoken'))
9406 -               {
9407 -                       $this->show_form(_('That\'s a local profile! Login to subscribe.'));
9408 -                       return;
9409 -               }
9410 +        if (omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]) ==
9411 +            common_local_url('requesttoken'))
9412 +        {
9413 +            $this->show_form(_('That\'s a local profile! Login to subscribe.'));
9414 +            return;
9415 +        }
9416 hunk ./actions/remotesubscribe.php 140
9417 -               if (User::staticGet('uri', omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]))) {
9418 -                       $this->show_form(_('That\'s a local profile! Login to subscribe.'));
9419 -                       return;
9420 -               }
9421 +        if (User::staticGet('uri', omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]))) {
9422 +            $this->show_form(_('That\'s a local profile! Login to subscribe.'));
9423 +            return;
9424 +        }
9425 hunk ./actions/remotesubscribe.php 145
9426 -               list($token, $secret) = $this->request_token($omb);
9427 +        list($token, $secret) = $this->request_token($omb);
9428 hunk ./actions/remotesubscribe.php 147
9429 -               if (!$token || !$secret) {
9430 -                       $this->show_form(_('Couldn\'t get a request token.'));
9431 -                       return;
9432 -               }
9433 +        if (!$token || !$secret) {
9434 +            $this->show_form(_('Couldn\'t get a request token.'));
9435 +            return;
9436 +        }
9437 hunk ./actions/remotesubscribe.php 152
9438 -               $this->request_authorization($user, $omb, $token, $secret);
9439 -       }
9440 +        $this->request_authorization($user, $omb, $token, $secret);
9441 +    }
9442 hunk ./actions/remotesubscribe.php 155
9443 -       function get_user() {
9444 -               $user = NULL;
9445 -               $nickname = $this->trimmed('nickname');
9446 -               if ($nickname) {
9447 -                       $user = User::staticGet('nickname', $nickname);
9448 -               }
9449 -               return $user;
9450 -       }
9451 +    function get_user() {
9452 +        $user = NULL;
9453 +        $nickname = $this->trimmed('nickname');
9454 +        if ($nickname) {
9455 +            $user = User::staticGet('nickname', $nickname);
9456 +        }
9457 +        return $user;
9458 +    }
9459 hunk ./actions/remotesubscribe.php 164
9460 -       function getOmb($xrds) {
9461 +    function getOmb($xrds) {
9462 hunk ./actions/remotesubscribe.php 166
9463 -           static $omb_endpoints = array(OMB_ENDPOINT_UPDATEPROFILE, OMB_ENDPOINT_POSTNOTICE);
9464 -               static $oauth_endpoints = array(OAUTH_ENDPOINT_REQUEST, OAUTH_ENDPOINT_AUTHORIZE,
9465 -                                                                               OAUTH_ENDPOINT_ACCESS);
9466 -               $omb = array();
9467 +        static $omb_endpoints = array(OMB_ENDPOINT_UPDATEPROFILE, OMB_ENDPOINT_POSTNOTICE);
9468 +        static $oauth_endpoints = array(OAUTH_ENDPOINT_REQUEST, OAUTH_ENDPOINT_AUTHORIZE,
9469 +                                        OAUTH_ENDPOINT_ACCESS);
9470 +        $omb = array();
9471 hunk ./actions/remotesubscribe.php 171
9472 -               # XXX: the following code could probably be refactored to eliminate dupes
9473 +        # XXX: the following code could probably be refactored to eliminate dupes
9474 hunk ./actions/remotesubscribe.php 173
9475 -               $oauth_services = omb_get_services($xrds, OAUTH_DISCOVERY);
9476 +        $oauth_services = omb_get_services($xrds, OAUTH_DISCOVERY);
9477 hunk ./actions/remotesubscribe.php 175
9478 -               if (!$oauth_services) {
9479 -                       return NULL;
9480 -               }
9481 +        if (!$oauth_services) {
9482 +            return NULL;
9483 +        }
9484 hunk ./actions/remotesubscribe.php 179
9485 -               $oauth_service = $oauth_services[0];
9486 +        $oauth_service = $oauth_services[0];
9487 hunk ./actions/remotesubscribe.php 181
9488 -               $oauth_xrd = $this->getXRD($oauth_service, $xrds);
9489 +        $oauth_xrd = $this->getXRD($oauth_service, $xrds);
9490 hunk ./actions/remotesubscribe.php 183
9491 -               if (!$oauth_xrd) {
9492 -                       return NULL;
9493 -               }
9494 +        if (!$oauth_xrd) {
9495 +            return NULL;
9496 +        }
9497 hunk ./actions/remotesubscribe.php 187
9498 -               if (!$this->addServices($oauth_xrd, $oauth_endpoints, $omb)) {
9499 -                       return NULL;
9500 -               }
9501 +        if (!$this->addServices($oauth_xrd, $oauth_endpoints, $omb)) {
9502 +            return NULL;
9503 +        }
9504 hunk ./actions/remotesubscribe.php 191
9505 -               $omb_services = omb_get_services($xrds, OMB_NAMESPACE);
9506 +        $omb_services = omb_get_services($xrds, OMB_NAMESPACE);
9507 hunk ./actions/remotesubscribe.php 193
9508 -               if (!$omb_services) {
9509 -                       return NULL;
9510 -               }
9511 +        if (!$omb_services) {
9512 +            return NULL;
9513 +        }
9514 hunk ./actions/remotesubscribe.php 197
9515 -               $omb_service = $omb_services[0];
9516 +        $omb_service = $omb_services[0];
9517 hunk ./actions/remotesubscribe.php 199
9518 -               $omb_xrd = $this->getXRD($omb_service, $xrds);
9519 +        $omb_xrd = $this->getXRD($omb_service, $xrds);
9520 hunk ./actions/remotesubscribe.php 201
9521 -               if (!$omb_xrd) {
9522 -                       return NULL;
9523 -               }
9524 +        if (!$omb_xrd) {
9525 +            return NULL;
9526 +        }
9527 hunk ./actions/remotesubscribe.php 205
9528 -               if (!$this->addServices($omb_xrd, $omb_endpoints, $omb)) {
9529 -                       return NULL;
9530 -               }
9531 +        if (!$this->addServices($omb_xrd, $omb_endpoints, $omb)) {
9532 +            return NULL;
9533 +        }
9534 hunk ./actions/remotesubscribe.php 209
9535 -               # XXX: check that we got all the services we needed
9536 +        # XXX: check that we got all the services we needed
9537 hunk ./actions/remotesubscribe.php 211
9538 -               foreach (array_merge($omb_endpoints, $oauth_endpoints) as $type) {
9539 -                       if (!array_key_exists($type, $omb) || !$omb[$type]) {
9540 -                               return NULL;
9541 -                       }
9542 -               }
9543 +        foreach (array_merge($omb_endpoints, $oauth_endpoints) as $type) {
9544 +            if (!array_key_exists($type, $omb) || !$omb[$type]) {
9545 +                return NULL;
9546 +            }
9547 +        }
9548 hunk ./actions/remotesubscribe.php 217
9549 -               if (!omb_local_id($omb[OAUTH_ENDPOINT_REQUEST])) {
9550 -                       return NULL;
9551 -               }
9552 +        if (!omb_local_id($omb[OAUTH_ENDPOINT_REQUEST])) {
9553 +            return NULL;
9554 +        }
9555 hunk ./actions/remotesubscribe.php 221
9556 -               return $omb;
9557 -       }
9558 +        return $omb;
9559 +    }
9560 hunk ./actions/remotesubscribe.php 224
9561 -       function getXRD($main_service, $main_xrds) {
9562 -               $uri = omb_service_uri($main_service);
9563 -               if (strpos($uri, "#") !== 0) {
9564 -                       # FIXME: more rigorous handling of external service definitions
9565 -                       return NULL;
9566 -               }
9567 -               $id = substr($uri, 1);
9568 -               $nodes = $main_xrds->allXrdNodes;
9569 -               $parser = $main_xrds->parser;
9570 -               foreach ($nodes as $node) {
9571 -                       $attrs = $parser->attributes($node);
9572 -                       if (array_key_exists('xml:id', $attrs) &&
9573 -                               $attrs['xml:id'] == $id) {
9574 -                               # XXX: trick the constructor into thinking this is the only node
9575 -                               $bogus_nodes = array($node);
9576 -                               return new Auth_Yadis_XRDS($parser, $bogus_nodes);
9577 -                       }
9578 -               }
9579 -               return NULL;
9580 -       }
9581 +    function getXRD($main_service, $main_xrds) {
9582 +        $uri = omb_service_uri($main_service);
9583 +        if (strpos($uri, "#") !== 0) {
9584 +            # FIXME: more rigorous handling of external service definitions
9585 +            return NULL;
9586 +        }
9587 +        $id = substr($uri, 1);
9588 +        $nodes = $main_xrds->allXrdNodes;
9589 +        $parser = $main_xrds->parser;
9590 +        foreach ($nodes as $node) {
9591 +            $attrs = $parser->attributes($node);
9592 +            if (array_key_exists('xml:id', $attrs) &&
9593 +                $attrs['xml:id'] == $id) {
9594 +                # XXX: trick the constructor into thinking this is the only node
9595 +                $bogus_nodes = array($node);
9596 +                return new Auth_Yadis_XRDS($parser, $bogus_nodes);
9597 +            }
9598 +        }
9599 +        return NULL;
9600 +    }
9601 hunk ./actions/remotesubscribe.php 245
9602 -       function addServices($xrd, $types, &$omb) {
9603 -               foreach ($types as $type) {
9604 -                       $matches = omb_get_services($xrd, $type);
9605 -                       if ($matches) {
9606 -                               $omb[$type] = $matches[0];
9607 -                       } else {
9608 -                               # no match for type
9609 -                               return false;
9610 -                       }
9611 -               }
9612 -               return true;
9613 -       }
9614 +    function addServices($xrd, $types, &$omb) {
9615 +        foreach ($types as $type) {
9616 +            $matches = omb_get_services($xrd, $type);
9617 +            if ($matches) {
9618 +                $omb[$type] = $matches[0];
9619 +            } else {
9620 +                # no match for type
9621 +                return false;
9622 +            }
9623 +        }
9624 +        return true;
9625 +    }
9626 hunk ./actions/remotesubscribe.php 258
9627 -       function request_token($omb) {
9628 -               $con = omb_oauth_consumer();
9629 +    function request_token($omb) {
9630 +        $con = omb_oauth_consumer();
9631 hunk ./actions/remotesubscribe.php 261
9632 -               $url = omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]);
9633 +        $url = omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]);
9634 hunk ./actions/remotesubscribe.php 263
9635 -               # XXX: Is this the right thing to do? Strip off GET params and make them
9636 -               # POST params? Seems wrong to me.
9637 +        # XXX: Is this the right thing to do? Strip off GET params and make them
9638 +        # POST params? Seems wrong to me.
9639 hunk ./actions/remotesubscribe.php 266
9640 -               $parsed = parse_url($url);
9641 -               $params = array();
9642 -               parse_str($parsed['query'], $params);
9643 +        $parsed = parse_url($url);
9644 +        $params = array();
9645 +        parse_str($parsed['query'], $params);
9646 hunk ./actions/remotesubscribe.php 270
9647 -               $req = OAuthRequest::from_consumer_and_token($con, NULL, "POST", $url, $params);
9648 +        $req = OAuthRequest::from_consumer_and_token($con, NULL, "POST", $url, $params);
9649 hunk ./actions/remotesubscribe.php 272
9650 -               $listener = omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]);
9651 +        $listener = omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]);
9652 hunk ./actions/remotesubscribe.php 274
9653 -               if (!$listener) {
9654 -                       return NULL;
9655 -               }
9656 +        if (!$listener) {
9657 +            return NULL;
9658 +        }
9659 hunk ./actions/remotesubscribe.php 278
9660 -               $req->set_parameter('omb_listener', $listener);
9661 -               $req->set_parameter('omb_version', OMB_VERSION_01);
9662 +        $req->set_parameter('omb_listener', $listener);
9663 +        $req->set_parameter('omb_version', OMB_VERSION_01);
9664 hunk ./actions/remotesubscribe.php 281
9665 -               # XXX: test to see if endpoint accepts this signature method
9666 +        # XXX: test to see if endpoint accepts this signature method
9667 hunk ./actions/remotesubscribe.php 283
9668 -               $req->sign_request(omb_hmac_sha1(), $con, NULL);
9669 +        $req->sign_request(omb_hmac_sha1(), $con, NULL);
9670 hunk ./actions/remotesubscribe.php 285
9671 -               # We re-use this tool's fetcher, since it's pretty good
9672 +        # We re-use this tool's fetcher, since it's pretty good
9673 hunk ./actions/remotesubscribe.php 287
9674 -               $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
9675 +        $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
9676 hunk ./actions/remotesubscribe.php 289
9677 -               $result = $fetcher->post($req->get_normalized_http_url(),
9678 -                                                                $req->to_postdata(),
9679 +        $result = $fetcher->post($req->get_normalized_http_url(),
9680 +                                 $req->to_postdata(),
9681 hunk ./actions/remotesubscribe.php 293
9682 -               if ($result->status != 200) {
9683 -                       return NULL;
9684 -               }
9685 +        if ($result->status != 200) {
9686 +            return NULL;
9687 +        }
9688 hunk ./actions/remotesubscribe.php 297
9689 -               parse_str($result->body, $return);
9690 +        parse_str($result->body, $return);
9691 hunk ./actions/remotesubscribe.php 299
9692 -               return array($return['oauth_token'], $return['oauth_token_secret']);
9693 -       }
9694 +        return array($return['oauth_token'], $return['oauth_token_secret']);
9695 +    }
9696 hunk ./actions/remotesubscribe.php 302
9697 -       function request_authorization($user, $omb, $token, $secret) {
9698 -               global $config; # for license URL
9699 +    function request_authorization($user, $omb, $token, $secret) {
9700 +        global $config; # for license URL
9701 hunk ./actions/remotesubscribe.php 305
9702 -               $con = omb_oauth_consumer();
9703 -               $tok = new OAuthToken($token, $secret);
9704 +        $con = omb_oauth_consumer();
9705 +        $tok = new OAuthToken($token, $secret);
9706 hunk ./actions/remotesubscribe.php 308
9707 -               $url = omb_service_uri($omb[OAUTH_ENDPOINT_AUTHORIZE]);
9708 +        $url = omb_service_uri($omb[OAUTH_ENDPOINT_AUTHORIZE]);
9709 hunk ./actions/remotesubscribe.php 310
9710 -               # XXX: Is this the right thing to do? Strip off GET params and make them
9711 -               # POST params? Seems wrong to me.
9712 +        # XXX: Is this the right thing to do? Strip off GET params and make them
9713 +        # POST params? Seems wrong to me.
9714 hunk ./actions/remotesubscribe.php 313
9715 -               $parsed = parse_url($url);
9716 -               $params = array();
9717 -               parse_str($parsed['query'], $params);
9718 +        $parsed = parse_url($url);
9719 +        $params = array();
9720 +        parse_str($parsed['query'], $params);
9721 hunk ./actions/remotesubscribe.php 317
9722 -               $req = OAuthRequest::from_consumer_and_token($con, $tok, 'GET', $url, $params);
9723 +        $req = OAuthRequest::from_consumer_and_token($con, $tok, 'GET', $url, $params);
9724 hunk ./actions/remotesubscribe.php 319
9725 -               # We send over a ton of information. This lets the other
9726 -               # server store info about our user, and it lets the current
9727 -               # user decide if they really want to authorize the subscription.
9728 +        # We send over a ton of information. This lets the other
9729 +        # server store info about our user, and it lets the current
9730 +        # user decide if they really want to authorize the subscription.
9731 hunk ./actions/remotesubscribe.php 323
9732 -               $req->set_parameter('omb_version', OMB_VERSION_01);
9733 -               $req->set_parameter('omb_listener', omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]));
9734 -               $req->set_parameter('omb_listenee', $user->uri);
9735 -               $req->set_parameter('omb_listenee_profile', common_profile_url($user->nickname));
9736 -               $req->set_parameter('omb_listenee_nickname', $user->nickname);
9737 -               $req->set_parameter('omb_listenee_license', $config['license']['url']);
9738 +        $req->set_parameter('omb_version', OMB_VERSION_01);
9739 +        $req->set_parameter('omb_listener', omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]));
9740 +        $req->set_parameter('omb_listenee', $user->uri);
9741 +        $req->set_parameter('omb_listenee_profile', common_profile_url($user->nickname));
9742 +        $req->set_parameter('omb_listenee_nickname', $user->nickname);
9743 +        $req->set_parameter('omb_listenee_license', $config['license']['url']);
9744 hunk ./actions/remotesubscribe.php 330
9745 -               $profile = $user->getProfile();
9746 -               if (!$profile) {
9747 -                       common_log_db_error($user, 'SELECT', __FILE__);
9748 -                       $this->server_error(_('User without matching profile'));
9749 -                       return;
9750 -               }
9751 +        $profile = $user->getProfile();
9752 +        if (!$profile) {
9753 +            common_log_db_error($user, 'SELECT', __FILE__);
9754 +            $this->server_error(_('User without matching profile'));
9755 +            return;
9756 +        }
9757 hunk ./actions/remotesubscribe.php 337
9758 -               if ($profile->fullname) {
9759 -                       $req->set_parameter('omb_listenee_fullname', $profile->fullname);
9760 -               }
9761 -               if ($profile->homepage) {
9762 -                       $req->set_parameter('omb_listenee_homepage', $profile->homepage);
9763 -               }
9764 -               if ($profile->bio) {
9765 -                       $req->set_parameter('omb_listenee_bio', $profile->bio);
9766 -               }
9767 -               if ($profile->location) {
9768 -                       $req->set_parameter('omb_listenee_location', $profile->location);
9769 -               }
9770 -               $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
9771 -               if ($avatar) {
9772 -                       $req->set_parameter('omb_listenee_avatar', $avatar->url);
9773 -               }
9774 +        if ($profile->fullname) {
9775 +            $req->set_parameter('omb_listenee_fullname', $profile->fullname);
9776 +        }
9777 +        if ($profile->homepage) {
9778 +            $req->set_parameter('omb_listenee_homepage', $profile->homepage);
9779 +        }
9780 +        if ($profile->bio) {
9781 +            $req->set_parameter('omb_listenee_bio', $profile->bio);
9782 +        }
9783 +        if ($profile->location) {
9784 +            $req->set_parameter('omb_listenee_location', $profile->location);
9785 +        }
9786 +        $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
9787 +        if ($avatar) {
9788 +            $req->set_parameter('omb_listenee_avatar', $avatar->url);
9789 +        }
9790 hunk ./actions/remotesubscribe.php 354
9791 -               # XXX: add a nonce to prevent replay attacks
9792 +        # XXX: add a nonce to prevent replay attacks
9793 hunk ./actions/remotesubscribe.php 356
9794 -               $req->set_parameter('oauth_callback', common_local_url('finishremotesubscribe'));
9795 +        $req->set_parameter('oauth_callback', common_local_url('finishremotesubscribe'));
9796 hunk ./actions/remotesubscribe.php 358
9797 -               # XXX: test to see if endpoint accepts this signature method
9798 +        # XXX: test to see if endpoint accepts this signature method
9799 hunk ./actions/remotesubscribe.php 360
9800 -               $req->sign_request(omb_hmac_sha1(), $con, $tok);
9801 +        $req->sign_request(omb_hmac_sha1(), $con, $tok);
9802 hunk ./actions/remotesubscribe.php 362
9803 -               # store all our info here
9804 +        # store all our info here
9805 hunk ./actions/remotesubscribe.php 364
9806 -               $omb['listenee'] = $user->nickname;
9807 -               $omb['listener'] = omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]);
9808 -               $omb['token'] = $token;
9809 -               $omb['secret'] = $secret;
9810 -               # call doesn't work after bounce back so we cache; maybe serialization issue...?
9811 -               $omb['access_token_url'] = omb_service_uri($omb[OAUTH_ENDPOINT_ACCESS]);
9812 -               $omb['post_notice_url'] = omb_service_uri($omb[OMB_ENDPOINT_POSTNOTICE]);
9813 -               $omb['update_profile_url'] = omb_service_uri($omb[OMB_ENDPOINT_UPDATEPROFILE]);
9814 +        $omb['listenee'] = $user->nickname;
9815 +        $omb['listener'] = omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]);
9816 +        $omb['token'] = $token;
9817 +        $omb['secret'] = $secret;
9818 +        # call doesn't work after bounce back so we cache; maybe serialization issue...?
9819 +        $omb['access_token_url'] = omb_service_uri($omb[OAUTH_ENDPOINT_ACCESS]);
9820 +        $omb['post_notice_url'] = omb_service_uri($omb[OMB_ENDPOINT_POSTNOTICE]);
9821 +        $omb['update_profile_url'] = omb_service_uri($omb[OMB_ENDPOINT_UPDATEPROFILE]);
9822 hunk ./actions/remotesubscribe.php 373
9823 -               common_ensure_session();
9824 +        common_ensure_session();
9825 hunk ./actions/remotesubscribe.php 375
9826 -               $_SESSION['oauth_authorization_request'] = $omb;
9827 +        $_SESSION['oauth_authorization_request'] = $omb;
9828 hunk ./actions/remotesubscribe.php 377
9829 -               # Redirect to authorization service
9830 +        # Redirect to authorization service
9831 hunk ./actions/remotesubscribe.php 379
9832 -               common_redirect($req->to_url());
9833 -               return;
9834 -       }
9835 +        common_redirect($req->to_url());
9836 +        return;
9837 +    }
9838 hunk ./actions/remotesubscribe.php 383
9839 -       function make_nonce() {
9840 -               return common_good_rand(16);
9841 -       }
9842 +    function make_nonce() {
9843 +        return common_good_rand(16);
9844 +    }
9845 hunk ./actions/replies.php 26
9846 -       function handle($args) {
9847 +    function handle($args) {
9848 hunk ./actions/replies.php 28
9849 -               parent::handle($args);
9850 +        parent::handle($args);
9851 hunk ./actions/replies.php 30
9852 -               $nickname = common_canonical_nickname($this->arg('nickname'));
9853 -               $user = User::staticGet('nickname', $nickname);
9854 +        $nickname = common_canonical_nickname($this->arg('nickname'));
9855 +        $user = User::staticGet('nickname', $nickname);
9856 hunk ./actions/replies.php 33
9857 -               if (!$user) {
9858 -                       $this->no_such_user();
9859 -                       return;
9860 -               }
9861 +        if (!$user) {
9862 +            $this->no_such_user();
9863 +            return;
9864 +        }
9865 hunk ./actions/replies.php 38
9866 -               $profile = $user->getProfile();
9867 +        $profile = $user->getProfile();
9868 hunk ./actions/replies.php 40
9869 -               if (!$profile) {
9870 -                       common_server_error(_('User has no profile.'));
9871 -                       return;
9872 -               }
9873 +        if (!$profile) {
9874 +            common_server_error(_('User has no profile.'));
9875 +            return;
9876 +        }
9877 hunk ./actions/replies.php 45
9878 -               # Looks like we're good; show the header
9879 +        # Looks like we're good; show the header
9880 hunk ./actions/replies.php 47
9881 -               common_show_header(sprintf(_("Replies to %s"), $profile->nickname),
9882 -                                                  array($this, 'show_header'), $user,
9883 -                                                  array($this, 'show_top'));
9884 +        common_show_header(sprintf(_("Replies to %s"), $profile->nickname),
9885 +                           array($this, 'show_header'), $user,
9886 +                           array($this, 'show_top'));
9887 hunk ./actions/replies.php 51
9888 -               $this->show_replies($user);
9889 +        $this->show_replies($user);
9890 hunk ./actions/replies.php 53
9891 -               common_show_footer();
9892 -       }
9893 +        common_show_footer();
9894 +    }
9895 hunk ./actions/replies.php 56
9896 -       function no_such_user() {
9897 -               common_user_error(_('No such user.'));
9898 -       }
9899 +    function no_such_user() {
9900 +        common_user_error(_('No such user.'));
9901 +    }
9902 hunk ./actions/replies.php 60
9903 -       function show_header($user) {
9904 -               common_element('link', array('rel' => 'alternate',
9905 -                                                                        'href' => common_local_url('repliesrss', array('nickname' =>
9906 -                                                                                                                                                                       $user->nickname)),
9907 -                                                                        'type' => 'application/rss+xml',
9908 -                                                                        'title' => sprintf(_('Feed for replies to %s'), $user->nickname)));
9909 -       }
9910 +    function show_header($user) {
9911 +        common_element('link', array('rel' => 'alternate',
9912 +                                     'href' => common_local_url('repliesrss', array('nickname' =>
9913 +                                                                                    $user->nickname)),
9914 +                                     'type' => 'application/rss+xml',
9915 +                                     'title' => sprintf(_('Feed for replies to %s'), $user->nickname)));
9916 +    }
9917 hunk ./actions/replies.php 68
9918 -       function show_top($user) {
9919 -               $cur = common_current_user();
9920 +    function show_top($user) {
9921 +        $cur = common_current_user();
9922 hunk ./actions/replies.php 71
9923 -               if ($cur && $cur->id == $user->id) {
9924 -                       common_notice_form('replies');
9925 -               }
9926 +        if ($cur && $cur->id == $user->id) {
9927 +            common_notice_form('replies');
9928 +        }
9929 hunk ./actions/replies.php 75
9930 -               $this->views_menu();
9931 +        $this->views_menu();
9932 hunk ./actions/replies.php 77
9933 -               $this->show_feeds_list(array(0=>array('href'=>common_local_url('repliesrss', array('nickname' => $user->nickname)),
9934 -                                                                                         'type' => 'rss',
9935 -                                                                                         'version' => 'RSS 1.0',
9936 -                                                                                         'item' => 'repliesrss')));
9937 -       }
9938 +        $this->show_feeds_list(array(0=>array('href'=>common_local_url('repliesrss', array('nickname' => $user->nickname)),
9939 +                                              'type' => 'rss',
9940 +                                              'version' => 'RSS 1.0',
9941 +                                              'item' => 'repliesrss')));
9942 +    }
9943 hunk ./actions/replies.php 83
9944 -       function show_replies($user) {
9945 +    function show_replies($user) {
9946 hunk ./actions/replies.php 85
9947 -               $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
9948 +        $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
9949 hunk ./actions/replies.php 87
9950 -               $notice = $user->getReplies(($page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
9951 +        $notice = $user->getReplies(($page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
9952 hunk ./actions/replies.php 89
9953 -               $cnt = $this->show_notice_list($notice);
9954 +        $cnt = $this->show_notice_list($notice);
9955 hunk ./actions/replies.php 91
9956 -               common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
9957 -                                                 $page, 'replies', array('nickname' => $user->nickname));
9958 -       }
9959 +        common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
9960 +                          $page, 'replies', array('nickname' => $user->nickname));
9961 +    }
9962 hunk ./actions/repliesrss.php 28
9963 -       var $user = NULL;
9964 +    var $user = NULL;
9965 hunk ./actions/repliesrss.php 30
9966 -       function init() {
9967 -               $nickname = $this->trimmed('nickname');
9968 -               $this->user = User::staticGet('nickname', $nickname);
9969 +    function init() {
9970 +        $nickname = $this->trimmed('nickname');
9971 +        $this->user = User::staticGet('nickname', $nickname);
9972 hunk ./actions/repliesrss.php 34
9973 -               if (!$this->user) {
9974 -                       common_user_error(_('No such user.'));
9975 -                       return false;
9976 -               } else {
9977 -                       return true;
9978 -               }
9979 -       }
9980 +        if (!$this->user) {
9981 +            common_user_error(_('No such user.'));
9982 +            return false;
9983 +        } else {
9984 +            return true;
9985 +        }
9986 +    }
9987 hunk ./actions/repliesrss.php 42
9988 -       function get_notices($limit=0) {
9989 +    function get_notices($limit=0) {
9990 hunk ./actions/repliesrss.php 44
9991 -               $user = $this->user;
9992 +        $user = $this->user;
9993 hunk ./actions/repliesrss.php 46
9994 -               $notice = $user->getReplies(0, ($limit == 0) ? 48 : $limit);
9995 +        $notice = $user->getReplies(0, ($limit == 0) ? 48 : $limit);
9996 hunk ./actions/repliesrss.php 48
9997 -               $notices = array();
9998 -               
9999 -               while ($notice->fetch()) {
10000 -                       $notices[] = clone($notice);
10001 -               }
10002 +        $notices = array();
10003 +        
10004 +        while ($notice->fetch()) {
10005 +            $notices[] = clone($notice);
10006 +        }
10007 hunk ./actions/repliesrss.php 54
10008 -               return $notices;
10009 -       }
10010 +        return $notices;
10011 +    }
10012 hunk ./actions/repliesrss.php 57
10013 -       function get_channel() {
10014 -               $user = $this->user;
10015 -               $c = array('url' => common_local_url('repliesrss',
10016 -                                                                                        array('nickname' =>
10017 -                                                                                                  $user->nickname)),
10018 -                                  'title' => sprintf(_("Replies to %s"), $user->nickname),
10019 -                                  'link' => common_local_url('replies',
10020 -                                                                                         array('nickname' =>
10021 -                                                                                                       $user->nickname)),
10022 -                                  'description' => sprintf(_('Feed for replies to %s'), $user->nickname));
10023 -               return $c;
10024 -       }
10025 +    function get_channel() {
10026 +        $user = $this->user;
10027 +        $c = array('url' => common_local_url('repliesrss',
10028 +                                             array('nickname' =>
10029 +                                                   $user->nickname)),
10030 +                   'title' => sprintf(_("Replies to %s"), $user->nickname),
10031 +                   'link' => common_local_url('replies',
10032 +                                              array('nickname' =>
10033 +                                                    $user->nickname)),
10034 +                   'description' => sprintf(_('Feed for replies to %s'), $user->nickname));
10035 +        return $c;
10036 +    }
10037 hunk ./actions/repliesrss.php 70
10038 -       function get_image() {
10039 -               $user = $this->user;
10040 -               $profile = $user->getProfile();
10041 -               if (!$profile) {
10042 -                       return NULL;
10043 -               }
10044 -               $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
10045 -               return ($avatar) ? $avatar->url : NULL;
10046 -       }
10047 +    function get_image() {
10048 +        $user = $this->user;
10049 +        $profile = $user->getProfile();
10050 +        if (!$profile) {
10051 +            return NULL;
10052 +        }
10053 +        $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
10054 +        return ($avatar) ? $avatar->url : NULL;
10055 +    }
10056 hunk ./actions/requesttoken.php 25
10057 -       
10058 -       function is_readonly() {
10059 -               return false;
10060 -       }
10061 -       
10062 -       function handle($args) {
10063 -               parent::handle($args);
10064 -               try {
10065 -                       common_remove_magic_from_request();
10066 -                       $req = OAuthRequest::from_request();
10067 -                       $server = omb_oauth_server();
10068 -                       $token = $server->fetch_request_token($req);
10069 -                       print $token;
10070 -               } catch (OAuthException $e) {
10071 -                       common_server_error($e->getMessage());
10072 -               }
10073 -       }
10074 +    
10075 +    function is_readonly() {
10076 +        return false;
10077 +    }
10078 +    
10079 +    function handle($args) {
10080 +        parent::handle($args);
10081 +        try {
10082 +            common_remove_magic_from_request();
10083 +            $req = OAuthRequest::from_request();
10084 +            $server = omb_oauth_server();
10085 +            $token = $server->fetch_request_token($req);
10086 +            print $token;
10087 +        } catch (OAuthException $e) {
10088 +            common_server_error($e->getMessage());
10089 +        }
10090 +    }
10091 hunk ./actions/showfavorites.php 26
10092 -       function handle($args) {
10093 +    function handle($args) {
10094 hunk ./actions/showfavorites.php 28
10095 -               parent::handle($args);
10096 +        parent::handle($args);
10097 hunk ./actions/showfavorites.php 30
10098 -               $nickname = common_canonical_nickname($this->arg('nickname'));
10099 -               $user = User::staticGet('nickname', $nickname);
10100 +        $nickname = common_canonical_nickname($this->arg('nickname'));
10101 +        $user = User::staticGet('nickname', $nickname);
10102 hunk ./actions/showfavorites.php 33
10103 -               if (!$user) {
10104 -                       $this->client_error(_('No such user.'));
10105 -                       return;
10106 -               }
10107 +        if (!$user) {
10108 +            $this->client_error(_('No such user.'));
10109 +            return;
10110 +        }
10111 hunk ./actions/showfavorites.php 38
10112 -               $profile = $user->getProfile();
10113 +        $profile = $user->getProfile();
10114 hunk ./actions/showfavorites.php 40
10115 -               if (!$profile) {
10116 -                       common_server_error(_('User has no profile.'));
10117 -                       return;
10118 -               }
10119 +        if (!$profile) {
10120 +            common_server_error(_('User has no profile.'));
10121 +            return;
10122 +        }
10123 hunk ./actions/showfavorites.php 45
10124 -               # Looks like we're good; show the header
10125 +        # Looks like we're good; show the header
10126 hunk ./actions/showfavorites.php 47
10127 -               common_show_header(sprintf(_("%s favorite notices"), $profile->nickname),
10128 -                                                  array($this, 'show_header'), $user,
10129 -                                                  array($this, 'show_top'));
10130 +        common_show_header(sprintf(_("%s favorite notices"), $profile->nickname),
10131 +                           array($this, 'show_header'), $user,
10132 +                           array($this, 'show_top'));
10133 hunk ./actions/showfavorites.php 51
10134 -               $this->show_notices($user);
10135 +        $this->show_notices($user);
10136 hunk ./actions/showfavorites.php 53
10137 -               common_show_footer();
10138 -       }
10139 +        common_show_footer();
10140 +    }
10141 hunk ./actions/showfavorites.php 56
10142 -       function show_header($user) {
10143 -               common_element('link', array('rel' => 'alternate',
10144 -                                                                        'href' => common_local_url('favoritesrss', array('nickname' =>
10145 -                                                                                                                                                                         $user->nickname)),
10146 -                                                                        'type' => 'application/rss+xml',
10147 -                                                                        'title' => sprintf(_('Feed for favorites of %s'), $user->nickname)));
10148 -       }
10149 +    function show_header($user) {
10150 +        common_element('link', array('rel' => 'alternate',
10151 +                                     'href' => common_local_url('favoritesrss', array('nickname' =>
10152 +                                                                                      $user->nickname)),
10153 +                                     'type' => 'application/rss+xml',
10154 +                                     'title' => sprintf(_('Feed for favorites of %s'), $user->nickname)));
10155 +    }
10156 hunk ./actions/showfavorites.php 64
10157 -       function show_top($user) {
10158 -               $cur = common_current_user();
10159 +    function show_top($user) {
10160 +        $cur = common_current_user();
10161 hunk ./actions/showfavorites.php 67
10162 -               if ($cur && $cur->id == $user->id) {
10163 -                       common_notice_form('all');
10164 -               }
10165 +        if ($cur && $cur->id == $user->id) {
10166 +            common_notice_form('all');
10167 +        }
10168 hunk ./actions/showfavorites.php 71
10169 -               $this->show_feeds_list(array(0=>array('href'=>common_local_url('favoritesrss', array('nickname' => $user->nickname)),
10170 -                                                                                         'type' => 'rss',
10171 -                                                                                         'version' => 'RSS 1.0',
10172 -                                                                                         'item' => 'Favorites')));
10173 -               $this->views_menu();
10174 -       }
10175 +        $this->show_feeds_list(array(0=>array('href'=>common_local_url('favoritesrss', array('nickname' => $user->nickname)),
10176 +                                              'type' => 'rss',
10177 +                                              'version' => 'RSS 1.0',
10178 +                                              'item' => 'Favorites')));
10179 +        $this->views_menu();
10180 +    }
10181 hunk ./actions/showfavorites.php 78
10182 -       function show_notices($user) {
10183 +    function show_notices($user) {
10184 hunk ./actions/showfavorites.php 80
10185 -               $page = $this->trimmed('page');
10186 -               if (!$page) {
10187 -                       $page = 1;
10188 -               }
10189 +        $page = $this->trimmed('page');
10190 +        if (!$page) {
10191 +            $page = 1;
10192 +        }
10193 hunk ./actions/showfavorites.php 85
10194 -               $notice = $user->favoriteNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
10195 +        $notice = $user->favoriteNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
10196 hunk ./actions/showfavorites.php 87
10197 -               if (!$notice) {
10198 -                       $this->server_error(_('Could not retrieve favorite notices.'));
10199 -                       return;
10200 -               }
10201 +        if (!$notice) {
10202 +            $this->server_error(_('Could not retrieve favorite notices.'));
10203 +            return;
10204 +        }
10205 hunk ./actions/showfavorites.php 94
10206 -               common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
10207 -                                                 $page, 'showfavorites', array('nickname' => $user->nickname));
10208 -       }
10209 +        common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
10210 +                          $page, 'showfavorites', array('nickname' => $user->nickname));
10211 +    }
10212 hunk ./actions/showmessage.php 26
10213 -       function handle($args) {
10214 +    function handle($args) {
10215 hunk ./actions/showmessage.php 28
10216 -               Action::handle($args);
10217 +        Action::handle($args);
10218 hunk ./actions/showmessage.php 30
10219 -               $message = $this->get_message();
10220 +        $message = $this->get_message();
10221 hunk ./actions/showmessage.php 32
10222 -               if (!$message) {
10223 -                       $this->client_error(_('No such message.'), 404);
10224 -                       return;
10225 -               }
10226 -               
10227 -               $cur = common_current_user();
10228 -               
10229 -               if ($cur && ($cur->id == $message->from_profile || $cur->id == $message->to_profile)) {
10230 -                       $this->show_page($cur, 1);
10231 -               } else {
10232 -                       $this->client_error(_('Only the sender and recipient may read this message.'), 403);
10233 -                       return;
10234 -               }
10235 -       }
10236 -       
10237 -       function get_message() {
10238 -               $id = $this->trimmed('message');
10239 -               $message = Message::staticGet('id', $id);
10240 -               return $message;
10241 -       }
10242 -       
10243 -       function get_title($user, $page) {
10244 -               $message = $this->get_message();
10245 -               if (!$message) {
10246 -                       return NULL;
10247 -               }
10248 -               
10249 -               if ($user->id == $message->from_profile) {
10250 -                       $to = $message->getTo();
10251 -                       $title = sprintf(_("Message to %1\$s on %2\$s"),
10252 -                                                        $to->nickname,
10253 -                                                        common_exact_date($message->created));
10254 -               } else if ($user->id == $message->to_profile) {
10255 -                       $from = $message->getFrom();
10256 -                       $title = sprintf(_("Message from %1\$s on %2\$s"),
10257 -                                                        $from->nickname,
10258 -                                                        common_exact_date($message->created));
10259 -               }
10260 -               return $title;
10261 -       }
10262 +        if (!$message) {
10263 +            $this->client_error(_('No such message.'), 404);
10264 +            return;
10265 +        }
10266 +        
10267 +        $cur = common_current_user();
10268 +        
10269 +        if ($cur && ($cur->id == $message->from_profile || $cur->id == $message->to_profile)) {
10270 +            $this->show_page($cur, 1);
10271 +        } else {
10272 +            $this->client_error(_('Only the sender and recipient may read this message.'), 403);
10273 +            return;
10274 +        }
10275 +    }
10276 +    
10277 +    function get_message() {
10278 +        $id = $this->trimmed('message');
10279 +        $message = Message::staticGet('id', $id);
10280 +        return $message;
10281 +    }
10282 +    
10283 +    function get_title($user, $page) {
10284 +        $message = $this->get_message();
10285 +        if (!$message) {
10286 +            return NULL;
10287 +        }
10288 +        
10289 +        if ($user->id == $message->from_profile) {
10290 +            $to = $message->getTo();
10291 +            $title = sprintf(_("Message to %1\$s on %2\$s"),
10292 +                             $to->nickname,
10293 +                             common_exact_date($message->created));
10294 +        } else if ($user->id == $message->to_profile) {
10295 +            $from = $message->getFrom();
10296 +            $title = sprintf(_("Message from %1\$s on %2\$s"),
10297 +                             $from->nickname,
10298 +                             common_exact_date($message->created));
10299 +        }
10300 +        return $title;
10301 +    }
10302 hunk ./actions/showmessage.php 73
10303 -       function get_messages($user, $page) {
10304 -               $message = new Message();
10305 -               $message->id = $this->trimmed('message');
10306 -               $message->find();
10307 -               return $message;
10308 -       }
10309 -       
10310 -       function get_message_profile($message) {
10311 -               $user = common_current_user();
10312 -               if ($user->id == $message->from_profile) {
10313 -                       return $message->getTo();
10314 -               } else if ($user->id == $message->to_profile) {
10315 -                       return $message->getFrom();
10316 -               } else {
10317 -                       # This shouldn't happen
10318 -                       return NULL;
10319 -               }
10320 -       }
10321 -       
10322 -       function get_instructions() {
10323 -               return '';
10324 -       }
10325 -       
10326 -       function views_menu() {
10327 -               return;
10328 -       }
10329 +    function get_messages($user, $page) {
10330 +        $message = new Message();
10331 +        $message->id = $this->trimmed('message');
10332 +        $message->find();
10333 +        return $message;
10334 +    }
10335 +    
10336 +    function get_message_profile($message) {
10337 +        $user = common_current_user();
10338 +        if ($user->id == $message->from_profile) {
10339 +            return $message->getTo();
10340 +        } else if ($user->id == $message->to_profile) {
10341 +            return $message->getFrom();
10342 +        } else {
10343 +            # This shouldn't happen
10344 +            return NULL;
10345 +        }
10346 +    }
10347 +    
10348 +    function get_instructions() {
10349 +        return '';
10350 +    }
10351 +    
10352 +    function views_menu() {
10353 +        return;
10354 +    }
10355 hunk ./actions/showmessage.php 100
10356 -       
10357 +    
10358 hunk ./actions/shownotice.php 26
10359 -       var $notice = NULL;
10360 -       var $profile = NULL;
10361 -       var $avatar = NULL;
10362 +    var $notice = NULL;
10363 +    var $profile = NULL;
10364 +    var $avatar = NULL;
10365 hunk ./actions/shownotice.php 30
10366 -       function prepare($args) {
10367 +    function prepare($args) {
10368 hunk ./actions/shownotice.php 32
10369 -               parent::prepare($args);
10370 +        parent::prepare($args);
10371 hunk ./actions/shownotice.php 34
10372 -               $id = $this->arg('notice');
10373 -               $this->notice = Notice::staticGet($id);
10374 +        $id = $this->arg('notice');
10375 +        $this->notice = Notice::staticGet($id);
10376 hunk ./actions/shownotice.php 37
10377 -               if (!$this->notice) {
10378 -                       $this->client_error(_('No such notice.'), 404);
10379 -                       return false;
10380 -               }
10381 +        if (!$this->notice) {
10382 +            $this->client_error(_('No such notice.'), 404);
10383 +            return false;
10384 +        }
10385 hunk ./actions/shownotice.php 42
10386 -               $this->profile = $this->notice->getProfile();
10387 +        $this->profile = $this->notice->getProfile();
10388 hunk ./actions/shownotice.php 44
10389 -               if (!$this->profile) {
10390 -                       $this->server_error(_('Notice has no profile'), 500);
10391 -                       return false;
10392 -               }
10393 +        if (!$this->profile) {
10394 +            $this->server_error(_('Notice has no profile'), 500);
10395 +            return false;
10396 +        }
10397 hunk ./actions/shownotice.php 49
10398 -               $this->avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
10399 +        $this->avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
10400 hunk ./actions/shownotice.php 51
10401 -               return true;
10402 -       }
10403 +        return true;
10404 +    }
10405 hunk ./actions/shownotice.php 54
10406 -       function last_modified() {
10407 -               return max(strtotime($this->notice->created),
10408 -                                  strtotime($this->profile->modified),
10409 -                                  ($this->avatar) ? strtotime($this->avatar->modified) : 0);
10410 -       }
10411 +    function last_modified() {
10412 +        return max(strtotime($this->notice->created),
10413 +                   strtotime($this->profile->modified),
10414 +                   ($this->avatar) ? strtotime($this->avatar->modified) : 0);
10415 +    }
10416 hunk ./actions/shownotice.php 60
10417 -       function etag() {
10418 -               return 'W/"' . implode(':', array($this->arg('action'),
10419 -                                                                                 common_language(),
10420 -                                                                                 $this->notice->id,
10421 -                                                                                 strtotime($this->notice->created),
10422 -                                                                                 strtotime($this->profile->modified),
10423 -                                                                                 ($this->avatar) ? strtotime($this->avatar->modified) : 0)) . '"';
10424 -       }
10425 +    function etag() {
10426 +        return 'W/"' . implode(':', array($this->arg('action'),
10427 +                                          common_language(),
10428 +                                          $this->notice->id,
10429 +                                          strtotime($this->notice->created),
10430 +                                          strtotime($this->profile->modified),
10431 +                                          ($this->avatar) ? strtotime($this->avatar->modified) : 0)) . '"';
10432 +    }
10433 hunk ./actions/shownotice.php 69
10434 -       function handle($args) {
10435 +    function handle($args) {
10436 hunk ./actions/shownotice.php 71
10437 -               parent::handle($args);
10438 +        parent::handle($args);
10439 hunk ./actions/shownotice.php 73
10440 -               common_show_header(sprintf(_('%1$s\'s status on %2$s'),
10441 -                                                                  $this->profile->nickname,
10442 -                                                                  common_exact_date($this->notice->created)),
10443 -                                                  array($this, 'show_header'), NULL,
10444 -                                                  array($this, 'show_top'));
10445 +        common_show_header(sprintf(_('%1$s\'s status on %2$s'),
10446 +                                   $this->profile->nickname,
10447 +                                   common_exact_date($this->notice->created)),
10448 +                           array($this, 'show_header'), NULL,
10449 +                           array($this, 'show_top'));
10450 hunk ./actions/shownotice.php 79
10451 -               common_element_start('ul', array('id' => 'notices'));
10452 +        common_element_start('ul', array('id' => 'notices'));
10453 hunk ./actions/shownotice.php 82
10454 -               common_element_end('ul');
10455 +        common_element_end('ul');
10456 hunk ./actions/shownotice.php 84
10457 -               common_show_footer();
10458 -       }
10459 +        common_show_footer();
10460 +    }
10461 hunk ./actions/shownotice.php 87
10462 -       function show_header() {
10463 +    function show_header() {
10464 hunk ./actions/shownotice.php 89
10465 -               $user = User::staticGet($this->profile->id);
10466 +        $user = User::staticGet($this->profile->id);
10467 hunk ./actions/shownotice.php 91
10468 -               if (!$user) {
10469 -                       return;
10470 -               }
10471 +        if (!$user) {
10472 +            return;
10473 +        }
10474 hunk ./actions/shownotice.php 95
10475 -               if ($user->emailmicroid && $user->email && $this->notice->uri) {
10476 -                       common_element('meta', array('name' => 'microid',
10477 -                                                                                'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($this->notice->uri))));
10478 -               }
10479 +        if ($user->emailmicroid && $user->email && $this->notice->uri) {
10480 +            common_element('meta', array('name' => 'microid',
10481 +                                         'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($this->notice->uri))));
10482 +        }
10483 hunk ./actions/shownotice.php 100
10484 -               if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
10485 -                       common_element('meta', array('name' => 'microid',
10486 -                                                                                'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($this->notice->uri))));
10487 -               }
10488 -       }
10489 +        if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
10490 +            common_element('meta', array('name' => 'microid',
10491 +                                         'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($this->notice->uri))));
10492 +        }
10493 +    }
10494 hunk ./actions/shownotice.php 106
10495 -       function show_top() {
10496 -               $cur = common_current_user();
10497 -               if ($cur && $cur->id == $this->profile->id) {
10498 -                       common_notice_form();
10499 -               }
10500 -       }
10501 +    function show_top() {
10502 +        $cur = common_current_user();
10503 +        if ($cur && $cur->id == $this->profile->id) {
10504 +            common_notice_form();
10505 +        }
10506 +    }
10507 hunk ./actions/shownotice.php 113
10508 -       function no_such_notice() {
10509 -               common_user_error(_('No such notice.'));
10510 -       }
10511 +    function no_such_notice() {
10512 +        common_user_error(_('No such notice.'));
10513 +    }
10514 hunk ./actions/showstream.php 29
10515 -       function handle($args) {
10516 +    function handle($args) {
10517 hunk ./actions/showstream.php 31
10518 -               parent::handle($args);
10519 +        parent::handle($args);
10520 hunk ./actions/showstream.php 34
10521 -               $nickname = common_canonical_nickname($nickname_arg);
10522 +        $nickname = common_canonical_nickname($nickname_arg);
10523 hunk ./actions/showstream.php 47
10524 -               $user = User::staticGet('nickname', $nickname);
10525 +        $user = User::staticGet('nickname', $nickname);
10526 hunk ./actions/showstream.php 49
10527 -               if (!$user) {
10528 -                       $this->no_such_user();
10529 -                       return;
10530 -               }
10531 +        if (!$user) {
10532 +            $this->no_such_user();
10533 +            return;
10534 +        }
10535 hunk ./actions/showstream.php 54
10536 -               $profile = $user->getProfile();
10537 +        $profile = $user->getProfile();
10538 hunk ./actions/showstream.php 56
10539 -               if (!$profile) {
10540 -                       common_server_error(_('User has no profile.'));
10541 -                       return;
10542 -               }
10543 +        if (!$profile) {
10544 +            common_server_error(_('User has no profile.'));
10545 +            return;
10546 +        }
10547 hunk ./actions/showstream.php 61
10548 -               # Looks like we're good; start output
10549 +        # Looks like we're good; start output
10550 hunk ./actions/showstream.php 63
10551 -               # For YADIS discovery, we also have a <meta> tag
10552 +        # For YADIS discovery, we also have a <meta> tag
10553 hunk ./actions/showstream.php 65
10554 -               header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
10555 -                                                                                                                                  $user->nickname)));
10556 +        header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
10557 +                                                                   $user->nickname)));
10558 hunk ./actions/showstream.php 68
10559 -               common_show_header($profile->nickname,
10560 -                                                  array($this, 'show_header'), $user,
10561 -                                                  array($this, 'show_top'));
10562 +        common_show_header($profile->nickname,
10563 +                           array($this, 'show_header'), $user,
10564 +                           array($this, 'show_top'));
10565 hunk ./actions/showstream.php 72
10566 -               $this->show_profile($profile);
10567 +        $this->show_profile($profile);
10568 hunk ./actions/showstream.php 74
10569 -               $this->show_notices($user);
10570 +        $this->show_notices($user);
10571 hunk ./actions/showstream.php 76
10572 -               common_show_footer();
10573 -       }
10574 +        common_show_footer();
10575 +    }
10576 hunk ./actions/showstream.php 79
10577 -       function show_top($user) {
10578 -               $cur = common_current_user();
10579 +    function show_top($user) {
10580 +        $cur = common_current_user();
10581 hunk ./actions/showstream.php 82
10582 -               if ($cur && $cur->id == $user->id) {
10583 -                       common_notice_form('showstream');
10584 -               }
10585 +        if ($cur && $cur->id == $user->id) {
10586 +            common_notice_form('showstream');
10587 +        }
10588 hunk ./actions/showstream.php 86
10589 -               $this->views_menu();
10590 +        $this->views_menu();
10591 hunk ./actions/showstream.php 88
10592 -               $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('nickname' => $user->nickname)),
10593 -                                                                                         'type' => 'rss',
10594 -                                                                                         'version' => 'RSS 1.0',
10595 -                                                                                         'item' => 'notices'),
10596 -                                                                        1=>array('href'=>common_local_url('usertimeline', array('nickname' => $user->nickname)),
10597 -                                                                                         'type' => 'atom',
10598 -                                                                                         'version' => 'Atom 1.0',
10599 -                                                                                         'item' => 'usertimeline'),
10600 +        $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('nickname' => $user->nickname)),
10601 +                                              'type' => 'rss',
10602 +                                              'version' => 'RSS 1.0',
10603 +                                              'item' => 'notices'),
10604 +                                     1=>array('href'=>common_local_url('usertimeline', array('nickname' => $user->nickname)),
10605 +                                              'type' => 'atom',
10606 +                                              'version' => 'Atom 1.0',
10607 +                                              'item' => 'usertimeline'),
10608 hunk ./actions/showstream.php 97
10609 -                                                                        2=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
10610 -                                                                                         'type' => 'rdf',
10611 -                                                                                         'version' => 'FOAF',
10612 -                                                                                         'item' => 'foaf')));
10613 -       }
10614 +                                     2=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)),
10615 +                                              'type' => 'rdf',
10616 +                                              'version' => 'FOAF',
10617 +                                              'item' => 'foaf')));
10618 +    }
10619 hunk ./actions/showstream.php 103
10620 -       function show_header($user) {
10621 -               # Feeds
10622 -               common_element('link', array('rel' => 'alternate',
10623 -                                                                        'href' => common_local_url('api',
10624 -                                                                                                                               array('apiaction' => 'statuses',
10625 -                                                                                                                                         'method' => 'user_timeline.rss',
10626 -                                                                                                                                         'argument' => $user->nickname)),
10627 -                                                                        'type' => 'application/rss+xml',
10628 -                                                                        'title' => sprintf(_('Notice feed for %s'), $user->nickname)));
10629 -               common_element('link', array('rel' => 'alternate feed',
10630 -                                                                        'href' => common_local_url('api',
10631 -                                                                                                                               array('apiaction' => 'statuses',
10632 -                                                                                                                                         'method' => 'user_timeline.atom',
10633 -                                                                                                                                         'argument' => $user->nickname)),
10634 -                                                                        'type' => 'application/atom+xml',
10635 -                                                                        'title' => sprintf(_('Notice feed for %s'), $user->nickname)));
10636 -               common_element('link', array('rel' => 'alternate',
10637 -                                                                        'href' => common_local_url('userrss', array('nickname' =>
10638 -                                                                                                                                                          $user->nickname)),
10639 -                                                                        'type' => 'application/rdf+xml',
10640 -                                                                        'title' => sprintf(_('Notice feed for %s'), $user->nickname)));
10641 -               # FOAF
10642 -               common_element('link', array('rel' => 'meta',
10643 -                                                                        'href' => common_local_url('foaf', array('nickname' =>
10644 -                                                                                                                                                         $user->nickname)),
10645 -                                                                        'type' => 'application/rdf+xml',
10646 -                                                                        'title' => 'FOAF'));
10647 -               # for remote subscriptions etc.
10648 -               common_element('meta', array('http-equiv' => 'X-XRDS-Location',
10649 -                                                                        'content' => common_local_url('xrds', array('nickname' =>
10650 -                                                                                                                                                          $user->nickname))));
10651 -               $profile = $user->getProfile();
10652 -               if ($profile->bio) {
10653 -                       common_element('meta', array('name' => 'description',
10654 -                                                                                'content' => $profile->bio));
10655 -               }
10656 +    function show_header($user) {
10657 +        # Feeds
10658 +        common_element('link', array('rel' => 'alternate',
10659 +                                     'href' => common_local_url('api',
10660 +                                                                array('apiaction' => 'statuses',
10661 +                                                                      'method' => 'user_timeline.rss',
10662 +                                                                      'argument' => $user->nickname)),
10663 +                                     'type' => 'application/rss+xml',
10664 +                                     'title' => sprintf(_('Notice feed for %s'), $user->nickname)));
10665 +        common_element('link', array('rel' => 'alternate feed',
10666 +                                     'href' => common_local_url('api',
10667 +                                                                array('apiaction' => 'statuses',
10668 +                                                                      'method' => 'user_timeline.atom',
10669 +                                                                      'argument' => $user->nickname)),
10670 +                                     'type' => 'application/atom+xml',
10671 +                                     'title' => sprintf(_('Notice feed for %s'), $user->nickname)));
10672 +        common_element('link', array('rel' => 'alternate',
10673 +                                     'href' => common_local_url('userrss', array('nickname' =>
10674 +                                                                               $user->nickname)),
10675 +                                     'type' => 'application/rdf+xml',
10676 +                                     'title' => sprintf(_('Notice feed for %s'), $user->nickname)));
10677 +        # FOAF
10678 +        common_element('link', array('rel' => 'meta',
10679 +                                     'href' => common_local_url('foaf', array('nickname' =>
10680 +                                                                              $user->nickname)),
10681 +                                     'type' => 'application/rdf+xml',
10682 +                                     'title' => 'FOAF'));
10683 +        # for remote subscriptions etc.
10684 +        common_element('meta', array('http-equiv' => 'X-XRDS-Location',
10685 +                                     'content' => common_local_url('xrds', array('nickname' =>
10686 +                                                                               $user->nickname))));
10687 +        $profile = $user->getProfile();
10688 +        if ($profile->bio) {
10689 +            common_element('meta', array('name' => 'description',
10690 +                                         'content' => $profile->bio));
10691 +        }
10692 hunk ./actions/showstream.php 140
10693 -               if ($user->emailmicroid && $user->email && $profile->profileurl) {
10694 -                       common_element('meta', array('name' => 'microid',
10695 -                                                                                'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($profile->profileurl))));
10696 -               }
10697 -               if ($user->jabbermicroid && $user->jabber && $profile->profileurl) {
10698 -                       common_element('meta', array('name' => 'microid',
10699 -                                                                                'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($profile->profileurl))));
10700 -               }
10701 +        if ($user->emailmicroid && $user->email && $profile->profileurl) {
10702 +            common_element('meta', array('name' => 'microid',
10703 +                                         'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($profile->profileurl))));
10704 +        }
10705 +        if ($user->jabbermicroid && $user->jabber && $profile->profileurl) {
10706 +            common_element('meta', array('name' => 'microid',
10707 +                                         'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($profile->profileurl))));
10708 +        }
10709 hunk ./actions/showstream.php 149
10710 -               # See https://wiki.mozilla.org/Microsummaries
10711 +        # See https://wiki.mozilla.org/Microsummaries
10712 hunk ./actions/showstream.php 151
10713 -               common_element('link', array('rel' => 'microsummary',
10714 -                                                                        'href' => common_local_url('microsummary',
10715 -                                                                                                                               array('nickname' => $profile->nickname))));
10716 -       }
10717 +        common_element('link', array('rel' => 'microsummary',
10718 +                                     'href' => common_local_url('microsummary',
10719 +                                                                array('nickname' => $profile->nickname))));
10720 +    }
10721 hunk ./actions/showstream.php 156
10722 -       function no_such_user() {
10723 -               $this->client_error(_('No such user.'), 404);
10724 -       }
10725 +    function no_such_user() {
10726 +        $this->client_error(_('No such user.'), 404);
10727 +    }
10728 hunk ./actions/showstream.php 160
10729 -       function show_profile($profile) {
10730 +    function show_profile($profile) {
10731 hunk ./actions/showstream.php 162
10732 -               common_element_start('div', array('id' => 'profile', 'class' => 'vcard'));
10733 +        common_element_start('div', array('id' => 'profile', 'class' => 'vcard'));
10734 hunk ./actions/showstream.php 164
10735 -               $this->show_personal($profile);
10736 +        $this->show_personal($profile);
10737 hunk ./actions/showstream.php 166
10738 -               $this->show_last_notice($profile);
10739 +        $this->show_last_notice($profile);
10740 hunk ./actions/showstream.php 168
10741 -               $cur = common_current_user();
10742 +        $cur = common_current_user();
10743 hunk ./actions/showstream.php 170
10744 -               $this->show_subscriptions($profile);
10745 +        $this->show_subscriptions($profile);
10746 hunk ./actions/showstream.php 172
10747 -               common_element_end('div');
10748 -       }
10749 +        common_element_end('div');
10750 +    }
10751 hunk ./actions/showstream.php 175
10752 -       function show_personal($profile) {
10753 +    function show_personal($profile) {
10754 hunk ./actions/showstream.php 177
10755 -               $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
10756 -               common_element_start('div', array('id' => 'profile_avatar'));
10757 -               common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
10758 -                                                                       'class' => 'avatar profile photo',
10759 -                                                                       'width' => AVATAR_PROFILE_SIZE,
10760 -                                                                       'height' => AVATAR_PROFILE_SIZE,
10761 -                                                                       'alt' => $profile->nickname));
10762 +        $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
10763 +        common_element_start('div', array('id' => 'profile_avatar'));
10764 +        common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
10765 +                                    'class' => 'avatar profile photo',
10766 +                                    'width' => AVATAR_PROFILE_SIZE,
10767 +                                    'height' => AVATAR_PROFILE_SIZE,
10768 +                                    'alt' => $profile->nickname));
10769 hunk ./actions/showstream.php 188
10770 -               $cur = common_current_user();
10771 -               if ($cur) {
10772 -                       if ($cur->id != $profile->id) {
10773 -                               if ($cur->isSubscribed($profile)) {
10774 -                                       common_unsubscribe_form($profile);
10775 -                               } else {
10776 -                                       common_subscribe_form($profile);
10777 -                               }
10778 -                       }
10779 -               } else {
10780 -                       $this->show_remote_subscribe_link($profile);
10781 -               }
10782 +        $cur = common_current_user();
10783 +        if ($cur) {
10784 +            if ($cur->id != $profile->id) {
10785 +                if ($cur->isSubscribed($profile)) {
10786 +                    common_unsubscribe_form($profile);
10787 +                } else {
10788 +                    common_subscribe_form($profile);
10789 +                }
10790 +            }
10791 +        } else {
10792 +            $this->show_remote_subscribe_link($profile);
10793 +        }
10794 hunk ./actions/showstream.php 202
10795 -               $user = User::staticGet('id', $profile->id);
10796 -               common_profile_new_message_nudge($cur, $user, $profile);
10797 +        $user = User::staticGet('id', $profile->id);
10798 +        common_profile_new_message_nudge($cur, $user, $profile);
10799 hunk ./actions/showstream.php 218
10800 -               common_element_end('ul');
10801 +        common_element_end('ul');
10802 hunk ./actions/showstream.php 220
10803 -               common_element_end('div');
10804 +        common_element_end('div');
10805 hunk ./actions/showstream.php 222
10806 -               common_element_start('div', array('id' => 'profile_information'));
10807 +        common_element_start('div', array('id' => 'profile_information'));
10808 hunk ./actions/showstream.php 224
10809 -               if ($profile->fullname) {
10810 -                       common_element('h1', array('class' => 'fn'), $profile->fullname . ' (' . $profile->nickname . ')');
10811 -               } else {
10812 -                       common_element('h1', array('class' => 'fn nickname'), $profile->nickname);
10813 -               }
10814 +        if ($profile->fullname) {
10815 +            common_element('h1', array('class' => 'fn'), $profile->fullname . ' (' . $profile->nickname . ')');
10816 +        } else {
10817 +            common_element('h1', array('class' => 'fn nickname'), $profile->nickname);
10818 +        }
10819 hunk ./actions/showstream.php 230
10820 -               if ($profile->location) {
10821 -                       common_element('p', 'location', $profile->location);
10822 -               }
10823 -               if ($profile->bio) {
10824 -                       common_element('p', 'description note', $profile->bio);
10825 -               }
10826 -               if ($profile->homepage) {
10827 -                       common_element_start('p', 'website');
10828 -                       common_element('a', array('href' => $profile->homepage,
10829 -                                                                         'rel' => 'me', 'class' => 'url'),
10830 -                                                  $profile->homepage);
10831 -                       common_element_end('p');
10832 -               }
10833 +        if ($profile->location) {
10834 +            common_element('p', 'location', $profile->location);
10835 +        }
10836 +        if ($profile->bio) {
10837 +            common_element('p', 'description note', $profile->bio);
10838 +        }
10839 +        if ($profile->homepage) {
10840 +            common_element_start('p', 'website');
10841 +            common_element('a', array('href' => $profile->homepage,
10842 +                                      'rel' => 'me', 'class' => 'url'),
10843 +                           $profile->homepage);
10844 +            common_element_end('p');
10845 +        }
10846 hunk ./actions/showstream.php 244
10847 -               $this->show_statistics($profile);
10848 +        $this->show_statistics($profile);
10849 hunk ./actions/showstream.php 246
10850 -               common_element_end('div');
10851 -       }
10852 +        common_element_end('div');
10853 +    }
10854 hunk ./actions/showstream.php 249
10855 -       function show_remote_subscribe_link($profile) {
10856 -               $url = common_local_url('remotesubscribe',
10857 -                                       array('nickname' => $profile->nickname));
10858 -               common_element('a', array('href' => $url,
10859 -                                                                 'id' => 'remotesubscribe'),
10860 -                                          _('Subscribe'));
10861 -       }
10862 +    function show_remote_subscribe_link($profile) {
10863 +        $url = common_local_url('remotesubscribe',
10864 +                                array('nickname' => $profile->nickname));
10865 +        common_element('a', array('href' => $url,
10866 +                                  'id' => 'remotesubscribe'),
10867 +                       _('Subscribe'));
10868 +    }
10869 hunk ./actions/showstream.php 257
10870 -       function show_unsubscribe_form($profile) {
10871 -               common_element_start('form', array('id' => 'unsubscribe', 'method' => 'post',
10872 -                                                                                  'action' => common_local_url('unsubscribe')));
10873 -               common_hidden('token', common_session_token());
10874 -               common_element('input', array('id' => 'unsubscribeto',
10875 -                                                                         'name' => 'unsubscribeto',
10876 -                                                                         'type' => 'hidden',
10877 -                                                                         'value' => $profile->nickname));
10878 -               common_element('input', array('type' => 'submit',
10879 -                                                                         'class' => 'submit',
10880 -                                                                         'value' => _('Unsubscribe')));
10881 -               common_element_end('form');
10882 -       }
10883 +    function show_unsubscribe_form($profile) {
10884 +        common_element_start('form', array('id' => 'unsubscribe', 'method' => 'post',
10885 +                                           'action' => common_local_url('unsubscribe')));
10886 +        common_hidden('token', common_session_token());
10887 +        common_element('input', array('id' => 'unsubscribeto',
10888 +                                      'name' => 'unsubscribeto',
10889 +                                      'type' => 'hidden',
10890 +                                      'value' => $profile->nickname));
10891 +        common_element('input', array('type' => 'submit',
10892 +                                      'class' => 'submit',
10893 +                                      'value' => _('Unsubscribe')));
10894 +        common_element_end('form');
10895 +    }
10896 hunk ./actions/showstream.php 271
10897 -       function show_subscriptions($profile) {
10898 -               global $config;
10899 +    function show_subscriptions($profile) {
10900 +        global $config;
10901 hunk ./actions/showstream.php 274
10902 -               $subs = DB_DataObject::factory('subscription');
10903 -               $subs->subscriber = $profile->id;
10904 -               $subs->whereAdd('subscribed != ' . $profile->id);
10905 +        $subs = DB_DataObject::factory('subscription');
10906 +        $subs->subscriber = $profile->id;
10907 +        $subs->whereAdd('subscribed != ' . $profile->id);
10908 hunk ./actions/showstream.php 278
10909 -               $subs->orderBy('created DESC');
10910 +        $subs->orderBy('created DESC');
10911 hunk ./actions/showstream.php 280
10912 -               # We ask for an extra one to know if we need to do another page
10913 +        # We ask for an extra one to know if we need to do another page
10914 hunk ./actions/showstream.php 282
10915 -               $subs->limit(0, SUBSCRIPTIONS + 1);
10916 +        $subs->limit(0, SUBSCRIPTIONS + 1);
10917 hunk ./actions/showstream.php 284
10918 -               $subs_count = $subs->find();
10919 +        $subs_count = $subs->find();
10920 hunk ./actions/showstream.php 286
10921 -               common_element_start('div', array('id' => 'subscriptions'));
10922 +        common_element_start('div', array('id' => 'subscriptions'));
10923 hunk ./actions/showstream.php 288
10924 -               common_element('h2', NULL, _('Subscriptions'));
10925 +        common_element('h2', NULL, _('Subscriptions'));
10926 hunk ./actions/showstream.php 290
10927 -               if ($subs_count > 0) {
10928 +        if ($subs_count > 0) {
10929 hunk ./actions/showstream.php 292
10930 -                       common_element_start('ul', array('id' => 'subscriptions_avatars'));
10931 +            common_element_start('ul', array('id' => 'subscriptions_avatars'));
10932 hunk ./actions/showstream.php 294
10933 -                       for ($i = 0; $i < min($subs_count, SUBSCRIPTIONS); $i++) {
10934 +            for ($i = 0; $i < min($subs_count, SUBSCRIPTIONS); $i++) {
10935 hunk ./actions/showstream.php 296
10936 -                               if (!$subs->fetch()) {
10937 -                                       common_debug('Weirdly, broke out of subscriptions loop early', __FILE__);
10938 -                                       break;
10939 -                               }
10940 +                if (!$subs->fetch()) {
10941 +                    common_debug('Weirdly, broke out of subscriptions loop early', __FILE__);
10942 +                    break;
10943 +                }
10944 hunk ./actions/showstream.php 301
10945 -                               $other = Profile::staticGet($subs->subscribed);
10946 +                $other = Profile::staticGet($subs->subscribed);
10947 hunk ./actions/showstream.php 303
10948 -                               if (!$other) {
10949 -                                       common_log_db_error($subs, 'SELECT', __FILE__);
10950 -                                       continue;
10951 -                               }
10952 +                if (!$other) {
10953 +                    common_log_db_error($subs, 'SELECT', __FILE__);
10954 +                    continue;
10955 +                }
10956 hunk ./actions/showstream.php 308
10957 -                               common_element_start('li', 'vcard');
10958 -                               common_element_start('a', array('title' => ($other->fullname) ?
10959 -                                                                                               $other->fullname :
10960 -                                                                                               $other->nickname,
10961 -                                                                                               'href' => $other->profileurl,
10962 -                                                                                               'rel' => 'contact',
10963 -                                                                                               'class' => 'subscription fn url'));
10964 -                               $avatar = $other->getAvatar(AVATAR_MINI_SIZE);
10965 -                               common_element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) :  common_default_avatar(AVATAR_MINI_SIZE)),
10966 -                                                                                       'width' => AVATAR_MINI_SIZE,
10967 -                                                                                       'height' => AVATAR_MINI_SIZE,
10968 -                                                                                       'class' => 'avatar mini photo',
10969 -                                                                                       'alt' =>  ($other->fullname) ?
10970 -                                                                                       $other->fullname :
10971 -                                                                                       $other->nickname));
10972 -                               common_element_end('a');
10973 -                               common_element_end('li');
10974 -                       }
10975 +                common_element_start('li', 'vcard');
10976 +                common_element_start('a', array('title' => ($other->fullname) ?
10977 +                                                $other->fullname :
10978 +                                                $other->nickname,
10979 +                                                'href' => $other->profileurl,
10980 +                                                'rel' => 'contact',
10981 +                                                 'class' => 'subscription fn url'));
10982 +                $avatar = $other->getAvatar(AVATAR_MINI_SIZE);
10983 +                common_element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) :  common_default_avatar(AVATAR_MINI_SIZE)),
10984 +                                            'width' => AVATAR_MINI_SIZE,
10985 +                                            'height' => AVATAR_MINI_SIZE,
10986 +                                            'class' => 'avatar mini photo',
10987 +                                            'alt' =>  ($other->fullname) ?
10988 +                                            $other->fullname :
10989 +                                            $other->nickname));
10990 +                common_element_end('a');
10991 +                common_element_end('li');
10992 +            }
10993 hunk ./actions/showstream.php 327
10994 -                       common_element_end('ul');
10995 -               }
10996 +            common_element_end('ul');
10997 +        }
10998 hunk ./actions/showstream.php 330
10999 -               if ($subs_count > SUBSCRIPTIONS) {
11000 -                       common_element_start('p', array('id' => 'subscriptions_viewall'));
11001 +        if ($subs_count > SUBSCRIPTIONS) {
11002 +            common_element_start('p', array('id' => 'subscriptions_viewall'));
11003 hunk ./actions/showstream.php 333
11004 -                       common_element('a', array('href' => common_local_url('subscriptions',
11005 -                                                                                                                                array('nickname' => $profile->nickname)),
11006 -                                                                         'class' => 'moresubscriptions'),
11007 -                                                  _('All subscriptions'));
11008 -                       common_element_end('p');
11009 -               }
11010 +            common_element('a', array('href' => common_local_url('subscriptions',
11011 +                                                                 array('nickname' => $profile->nickname)),
11012 +                                      'class' => 'moresubscriptions'),
11013 +                           _('All subscriptions'));
11014 +            common_element_end('p');
11015 +        }
11016 hunk ./actions/showstream.php 340
11017 -               common_element_end('div');
11018 -       }
11019 +        common_element_end('div');
11020 +    }
11021 hunk ./actions/showstream.php 343
11022 -       function show_statistics($profile) {
11023 +    function show_statistics($profile) {
11024 hunk ./actions/showstream.php 345
11025 -               // XXX: WORM cache this
11026 -               $subs = DB_DataObject::factory('subscription');
11027 -               $subs->subscriber = $profile->id;
11028 -               $subs_count = (int) $subs->count() - 1;
11029 +        // XXX: WORM cache this
11030 +        $subs = DB_DataObject::factory('subscription');
11031 +        $subs->subscriber = $profile->id;
11032 +        $subs_count = (int) $subs->count() - 1;
11033 hunk ./actions/showstream.php 350
11034 -               $subbed = DB_DataObject::factory('subscription');
11035 -               $subbed->subscribed = $profile->id;
11036 -               $subbed_count = (int) $subbed->count() - 1;
11037 +        $subbed = DB_DataObject::factory('subscription');
11038 +        $subbed->subscribed = $profile->id;
11039 +        $subbed_count = (int) $subbed->count() - 1;
11040 hunk ./actions/showstream.php 354
11041 -               $notices = DB_DataObject::factory('notice');
11042 -               $notices->profile_id = $profile->id;
11043 -               $notice_count = (int) $notices->count();
11044 +        $notices = DB_DataObject::factory('notice');
11045 +        $notices->profile_id = $profile->id;
11046 +        $notice_count = (int) $notices->count();
11047 hunk ./actions/showstream.php 358
11048 -               common_element_start('div', 'statistics');
11049 -               common_element('h2', 'statistics', _('Statistics'));
11050 +        common_element_start('div', 'statistics');
11051 +        common_element('h2', 'statistics', _('Statistics'));
11052 hunk ./actions/showstream.php 361
11053 -               # Other stats...?
11054 -               common_element_start('dl', 'statistics');
11055 -               common_element('dt', 'membersince', _('Member since'));
11056 -               common_element('dd', 'membersince', date('j M Y',
11057 -                                                                                                strtotime($profile->created)));
11058 +        # Other stats...?
11059 +        common_element_start('dl', 'statistics');
11060 +        common_element('dt', 'membersince', _('Member since'));
11061 +        common_element('dd', 'membersince', date('j M Y',
11062 +                                                 strtotime($profile->created)));
11063 hunk ./actions/showstream.php 367
11064 -               common_element_start('dt', 'subscriptions');
11065 -               common_element('a', array('href' => common_local_url('subscriptions',
11066 -                                                                                                                        array('nickname' => $profile->nickname))),
11067 -                                          _('Subscriptions'));
11068 -               common_element_end('dt');
11069 -               common_element('dd', 'subscriptions', (is_int($subs_count)) ? $subs_count : '0');
11070 -               common_element_start('dt', 'subscribers');
11071 -               common_element('a', array('href' => common_local_url('subscribers',
11072 -                                                                                                                        array('nickname' => $profile->nickname))),
11073 -                                          _('Subscribers'));
11074 -               common_element_end('dt');
11075 -               common_element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0');
11076 -               common_element('dt', 'notices', _('Notices'));
11077 -               common_element('dd', 'notices', (is_int($notice_count)) ? $notice_count : '0');
11078 -               # XXX: link these to something
11079 -               common_element('dt', 'tags', _('Tags'));
11080 -               common_element_start('dd', 'tags');
11081 -               $tags = Profile_tag::getTags($profile->id, $profile->id);
11082 +        common_element_start('dt', 'subscriptions');
11083 +        common_element('a', array('href' => common_local_url('subscriptions',
11084 +                                                             array('nickname' => $profile->nickname))),
11085 +                       _('Subscriptions'));
11086 +        common_element_end('dt');
11087 +        common_element('dd', 'subscriptions', (is_int($subs_count)) ? $subs_count : '0');
11088 +        common_element_start('dt', 'subscribers');
11089 +        common_element('a', array('href' => common_local_url('subscribers',
11090 +                                                             array('nickname' => $profile->nickname))),
11091 +                       _('Subscribers'));
11092 +        common_element_end('dt');
11093 +        common_element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0');
11094 +        common_element('dt', 'notices', _('Notices'));
11095 +        common_element('dd', 'notices', (is_int($notice_count)) ? $notice_count : '0');
11096 +        # XXX: link these to something
11097 +        common_element('dt', 'tags', _('Tags'));
11098 +        common_element_start('dd', 'tags');
11099 +        $tags = Profile_tag::getTags($profile->id, $profile->id);
11100 hunk ./actions/showstream.php 386
11101 -               common_element_start('ul', 'tags xoxo');
11102 -               foreach ($tags as $tag) {
11103 -                       common_element_start('li');
11104 -                       common_element('a', array('rel' => 'bookmark tag',
11105 -                                                                         'href' => common_local_url('peopletag',
11106 -                                                                                                                                array('tag' => $tag))),
11107 -                                                  $tag);
11108 -                       common_element_end('li');
11109 -               }
11110 -               common_element_end('ul');
11111 -           common_element_end('dd');
11112 +        common_element_start('ul', 'tags xoxo');
11113 +        foreach ($tags as $tag) {
11114 +            common_element_start('li');
11115 +            common_element('a', array('rel' => 'bookmark tag',
11116 +                                      'href' => common_local_url('peopletag',
11117 +                                                                 array('tag' => $tag))),
11118 +                           $tag);
11119 +            common_element_end('li');
11120 +        }
11121 +        common_element_end('ul');
11122 +        common_element_end('dd');
11123 hunk ./actions/showstream.php 398
11124 -               common_element_end('dl');
11125 +        common_element_end('dl');
11126 hunk ./actions/showstream.php 400
11127 -               common_element_end('div');
11128 -       }
11129 +        common_element_end('div');
11130 +    }
11131 hunk ./actions/showstream.php 403
11132 -       function show_notices($user) {
11133 +    function show_notices($user) {
11134 hunk ./actions/showstream.php 405
11135 -               $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
11136 +        $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
11137 hunk ./actions/showstream.php 407
11138 -               $notice = $user->getNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
11139 +        $notice = $user->getNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
11140 hunk ./actions/showstream.php 412
11141 -               common_pagination($page>1, $cnt>NOTICES_PER_PAGE, $page,
11142 -                                                 'showstream', array('nickname' => $user->nickname));
11143 -       }
11144 +        common_pagination($page>1, $cnt>NOTICES_PER_PAGE, $page,
11145 +                          'showstream', array('nickname' => $user->nickname));
11146 +    }
11147 hunk ./actions/showstream.php 416
11148 -       function show_last_notice($profile) {
11149 +    function show_last_notice($profile) {
11150 hunk ./actions/showstream.php 418
11151 -               common_element('h2', NULL, _('Currently'));
11152 +        common_element('h2', NULL, _('Currently'));
11153 hunk ./actions/showstream.php 420
11154 -               $notice = $profile->getCurrentNotice();
11155 +        $notice = $profile->getCurrentNotice();
11156 hunk ./actions/showstream.php 422
11157 -               if ($notice) {
11158 -                       # FIXME: URL, image, video, audio
11159 -                       common_element_start('p', array('class' => 'notice_current'));
11160 -                       if ($notice->rendered) {
11161 -                               common_raw($notice->rendered);
11162 -                       } else {
11163 -                               # XXX: may be some uncooked notices in the DB,
11164 -                               # we cook them right now. This can probably disappear in future
11165 -                               # versions (>> 0.4.x)
11166 -                               common_raw(common_render_content($notice->content, $notice));
11167 -                       }
11168 -                       common_element_end('p');
11169 -               }
11170 -       }
11171 +        if ($notice) {
11172 +            # FIXME: URL, image, video, audio
11173 +            common_element_start('p', array('class' => 'notice_current'));
11174 +            if ($notice->rendered) {
11175 +                common_raw($notice->rendered);
11176 +            } else {
11177 +                # XXX: may be some uncooked notices in the DB,
11178 +                # we cook them right now. This can probably disappear in future
11179 +                # versions (>> 0.4.x)
11180 +                common_raw(common_render_content($notice->content, $notice));
11181 +            }
11182 +            common_element_end('p');
11183 +        }
11184 +    }
11185 hunk ./actions/smssettings.php 27
11186 -       function get_instructions() {
11187 -               return _('You can receive SMS messages through email from %%site.name%%.');
11188 -       }
11189 +    function get_instructions() {
11190 +        return _('You can receive SMS messages through email from %%site.name%%.');
11191 +    }
11192 hunk ./actions/smssettings.php 31
11193 -       function show_form($msg=NULL, $success=false) {
11194 -               $user = common_current_user();
11195 -               $this->form_header(_('SMS Settings'), $msg, $success);
11196 -               common_element_start('form', array('method' => 'post',
11197 -                                                                                  'id' => 'smssettings',
11198 -                                                                                  'action' =>
11199 -                                                                                  common_local_url('smssettings')));
11200 -               common_hidden('token', common_session_token());
11201 -               common_element('h2', NULL, _('Address'));
11202 +    function show_form($msg=NULL, $success=false) {
11203 +        $user = common_current_user();
11204 +        $this->form_header(_('SMS Settings'), $msg, $success);
11205 +        common_element_start('form', array('method' => 'post',
11206 +                                           'id' => 'smssettings',
11207 +                                           'action' =>
11208 +                                           common_local_url('smssettings')));
11209 +        common_hidden('token', common_session_token());
11210 +        common_element('h2', NULL, _('Address'));
11211 hunk ./actions/smssettings.php 41
11212 -               if ($user->sms) {
11213 -                       common_element_start('p');
11214 -                       $carrier = $user->getCarrier();
11215 -                       common_element('span', 'address confirmed', $user->sms . ' (' . $carrier->name . ')');
11216 -                       common_element('span', 'input_instructions',
11217 -                                      _('Current confirmed SMS-enabled phone number.'));
11218 -                       common_hidden('sms', $user->sms);
11219 -                       common_hidden('carrier', $user->carrier);
11220 -                       common_element_end('p');
11221 -                       common_submit('remove', _('Remove'));
11222 -               } else {
11223 -                       $confirm = $this->get_confirmation();
11224 -                       if ($confirm) {
11225 -                               $carrier = Sms_carrier::staticGet($confirm->address_extra);
11226 -                               common_element_start('p');
11227 -                               common_element('span', 'address unconfirmed', $confirm->address . ' (' . $carrier->name . ')');
11228 -                               common_element('span', 'input_instructions',
11229 -                                                          _('Awaiting confirmation on this phone number.'));
11230 -                               common_hidden('sms', $confirm->address);
11231 -                               common_hidden('carrier', $confirm->address_extra);
11232 -                               common_element_end('p');
11233 -                               common_submit('cancel', _('Cancel'));
11234 -                               common_input('code', _('Confirmation code'), NULL,
11235 -                                                        _('Enter the code you received on your phone.'));
11236 -                               common_submit('confirm', _('Confirm'));
11237 -                       } else {
11238 -                               common_input('sms', _('SMS Phone number'),
11239 -                                                        ($this->arg('sms')) ? $this->arg('sms') : NULL,
11240 -                                                        _('Phone number, no punctuation or spaces, with area code'));
11241 -                               $this->carrier_select();
11242 -                               common_submit('add', _('Add'));
11243 -                       }
11244 -               }
11245 +        if ($user->sms) {
11246 +            common_element_start('p');
11247 +            $carrier = $user->getCarrier();
11248 +            common_element('span', 'address confirmed', $user->sms . ' (' . $carrier->name . ')');
11249 +            common_element('span', 'input_instructions',
11250 +                           _('Current confirmed SMS-enabled phone number.'));
11251 +            common_hidden('sms', $user->sms);
11252 +            common_hidden('carrier', $user->carrier);
11253 +            common_element_end('p');
11254 +            common_submit('remove', _('Remove'));
11255 +        } else {
11256 +            $confirm = $this->get_confirmation();
11257 +            if ($confirm) {
11258 +                $carrier = Sms_carrier::staticGet($confirm->address_extra);
11259 +                common_element_start('p');
11260 +                common_element('span', 'address unconfirmed', $confirm->address . ' (' . $carrier->name . ')');
11261 +                common_element('span', 'input_instructions',
11262 +                               _('Awaiting confirmation on this phone number.'));
11263 +                common_hidden('sms', $confirm->address);
11264 +                common_hidden('carrier', $confirm->address_extra);
11265 +                common_element_end('p');
11266 +                common_submit('cancel', _('Cancel'));
11267 +                common_input('code', _('Confirmation code'), NULL,
11268 +                             _('Enter the code you received on your phone.'));
11269 +                common_submit('confirm', _('Confirm'));
11270 +            } else {
11271 +                common_input('sms', _('SMS Phone number'),
11272 +                             ($this->arg('sms')) ? $this->arg('sms') : NULL,
11273 +                             _('Phone number, no punctuation or spaces, with area code'));
11274 +                $this->carrier_select();
11275 +                common_submit('add', _('Add'));
11276 +            }
11277 +        }
11278 hunk ./actions/smssettings.php 75
11279 -               if ($user->sms) {
11280 -                       common_element('h2', NULL, _('Incoming email'));
11281 -                       
11282 -                       if ($user->incomingemail) {
11283 -                               common_element_start('p');
11284 -                               common_element('span', 'address', $user->incomingemail);
11285 -                               common_element('span', 'input_instructions',
11286 -                                                          _('Send email to this address to post new notices.'));
11287 -                               common_element_end('p');
11288 -                               common_submit('removeincoming', _('Remove'));
11289 -                       }
11290 -                       
11291 -                       common_element_start('p');
11292 -                       common_element('span', 'input_instructions',
11293 -                                                  _('Make a new email address for posting to; cancels the old one.'));
11294 -                       common_element_end('p');
11295 -                       common_submit('newincoming', _('New'));
11296 -               }
11297 -               
11298 -               common_element('h2', NULL, _('Preferences'));
11299 -               
11300 -               common_checkbox('smsnotify',
11301 -                                               _('Send me notices through SMS; I understand I may incur exorbitant charges from my carrier.'),
11302 -                                               $user->smsnotify);
11303 -                       
11304 -               common_submit('save', _('Save'));
11305 -               
11306 -               common_element_end('form');
11307 -               common_show_footer();
11308 -       }
11309 +        if ($user->sms) {
11310 +            common_element('h2', NULL, _('Incoming email'));
11311 +            
11312 +            if ($user->incomingemail) {
11313 +                common_element_start('p');
11314 +                common_element('span', 'address', $user->incomingemail);
11315 +                common_element('span', 'input_instructions',
11316 +                               _('Send email to this address to post new notices.'));
11317 +                common_element_end('p');
11318 +                common_submit('removeincoming', _('Remove'));
11319 +            }
11320 +            
11321 +            common_element_start('p');
11322 +            common_element('span', 'input_instructions',
11323 +                           _('Make a new email address for posting to; cancels the old one.'));
11324 +            common_element_end('p');
11325 +            common_submit('newincoming', _('New'));
11326 +        }
11327 +        
11328 +        common_element('h2', NULL, _('Preferences'));
11329 +        
11330 +        common_checkbox('smsnotify',
11331 +                        _('Send me notices through SMS; I understand I may incur exorbitant charges from my carrier.'),
11332 +                        $user->smsnotify);
11333 +            
11334 +        common_submit('save', _('Save'));
11335 +        
11336 +        common_element_end('form');
11337 +        common_show_footer();
11338 +    }
11339 hunk ./actions/smssettings.php 106
11340 -       function get_confirmation() {
11341 -               $user = common_current_user();
11342 -               $confirm = new Confirm_address();
11343 -               $confirm->user_id = $user->id;
11344 -               $confirm->address_type = 'sms';
11345 -               if ($confirm->find(TRUE)) {
11346 -                       return $confirm;
11347 -               } else {
11348 -                       return NULL;
11349 -               }
11350 -       }
11351 +    function get_confirmation() {
11352 +        $user = common_current_user();
11353 +        $confirm = new Confirm_address();
11354 +        $confirm->user_id = $user->id;
11355 +        $confirm->address_type = 'sms';
11356 +        if ($confirm->find(TRUE)) {
11357 +            return $confirm;
11358 +        } else {
11359 +            return NULL;
11360 +        }
11361 +    }
11362 hunk ./actions/smssettings.php 118
11363 -       function handle_post() {
11364 +    function handle_post() {
11365 hunk ./actions/smssettings.php 120
11366 -               # CSRF protection
11367 +        # CSRF protection
11368 hunk ./actions/smssettings.php 122
11369 -               $token = $this->trimmed('token');
11370 -               if (!$token || $token != common_session_token()) {
11371 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
11372 -                       return;
11373 -               }
11374 +        $token = $this->trimmed('token');
11375 +        if (!$token || $token != common_session_token()) {
11376 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
11377 +            return;
11378 +        }
11379 hunk ./actions/smssettings.php 128
11380 -               if ($this->arg('save')) {
11381 -                       $this->save_preferences();
11382 -               } else if ($this->arg('add')) {
11383 -                       $this->add_address();
11384 -               } else if ($this->arg('cancel')) {
11385 -                       $this->cancel_confirmation();
11386 -               } else if ($this->arg('remove')) {
11387 -                       $this->remove_address();
11388 -               } else if ($this->arg('removeincoming')) {
11389 -                       $this->remove_incoming();
11390 -               } else if ($this->arg('newincoming')) {
11391 -                       $this->new_incoming();
11392 -               } else if ($this->arg('confirm')) {
11393 -                       $this->confirm_code();
11394 -               } else {
11395 -                       $this->show_form(_('Unexpected form submission.'));
11396 -               }
11397 -       }
11398 +        if ($this->arg('save')) {
11399 +            $this->save_preferences();
11400 +        } else if ($this->arg('add')) {
11401 +            $this->add_address();
11402 +        } else if ($this->arg('cancel')) {
11403 +            $this->cancel_confirmation();
11404 +        } else if ($this->arg('remove')) {
11405 +            $this->remove_address();
11406 +        } else if ($this->arg('removeincoming')) {
11407 +            $this->remove_incoming();
11408 +        } else if ($this->arg('newincoming')) {
11409 +            $this->new_incoming();
11410 +        } else if ($this->arg('confirm')) {
11411 +            $this->confirm_code();
11412 +        } else {
11413 +            $this->show_form(_('Unexpected form submission.'));
11414 +        }
11415 +    }
11416 hunk ./actions/smssettings.php 147
11417 -       function save_preferences() {
11418 +    function save_preferences() {
11419 hunk ./actions/smssettings.php 149
11420 -               $smsnotify = $this->boolean('smsnotify');
11421 -               
11422 -               $user = common_current_user();
11423 +        $smsnotify = $this->boolean('smsnotify');
11424 +        
11425 +        $user = common_current_user();
11426 hunk ./actions/smssettings.php 153
11427 -               assert(!is_null($user)); # should already be checked
11428 +        assert(!is_null($user)); # should already be checked
11429 hunk ./actions/smssettings.php 155
11430 -               $user->query('BEGIN');
11431 +        $user->query('BEGIN');
11432 hunk ./actions/smssettings.php 157
11433 -               $original = clone($user);
11434 +        $original = clone($user);
11435 hunk ./actions/smssettings.php 159
11436 -               $user->smsnotify = $smsnotify;
11437 +        $user->smsnotify = $smsnotify;
11438 hunk ./actions/smssettings.php 161
11439 -               $result = $user->update($original);
11440 +        $result = $user->update($original);
11441 hunk ./actions/smssettings.php 163
11442 -               if ($result === FALSE) {
11443 -                       common_log_db_error($user, 'UPDATE', __FILE__);
11444 -                       common_server_error(_('Couldn\'t update user.'));
11445 -                       return;
11446 -               }
11447 +        if ($result === FALSE) {
11448 +            common_log_db_error($user, 'UPDATE', __FILE__);
11449 +            common_server_error(_('Couldn\'t update user.'));
11450 +            return;
11451 +        }
11452 hunk ./actions/smssettings.php 169
11453 -               $user->query('COMMIT');
11454 +        $user->query('COMMIT');
11455 hunk ./actions/smssettings.php 171
11456 -               $this->show_form(_('Preferences saved.'), true);
11457 -       }
11458 +        $this->show_form(_('Preferences saved.'), true);
11459 +    }
11460 hunk ./actions/smssettings.php 174
11461 -       function add_address() {
11462 +    function add_address() {
11463 hunk ./actions/smssettings.php 176
11464 -               $user = common_current_user();
11465 +        $user = common_current_user();
11466 hunk ./actions/smssettings.php 178
11467 -               $sms = $this->trimmed('sms');
11468 -               $carrier_id = $this->trimmed('carrier');
11469 -               
11470 -               # Some validation
11471 +        $sms = $this->trimmed('sms');
11472 +        $carrier_id = $this->trimmed('carrier');
11473 +        
11474 +        # Some validation
11475 hunk ./actions/smssettings.php 183
11476 -               if (!$sms) {
11477 -                       $this->show_form(_('No phone number.'));
11478 -                       return;
11479 -               }
11480 +        if (!$sms) {
11481 +            $this->show_form(_('No phone number.'));
11482 +            return;
11483 +        }
11484 hunk ./actions/smssettings.php 188
11485 -               if (!$carrier_id) {
11486 -                       $this->show_form(_('No carrier selected.'));
11487 -                       return;
11488 -               }
11489 -               
11490 -               $sms = common_canonical_sms($sms);
11491 -               
11492 -               if ($user->sms == $sms) {
11493 -                   $this->show_form(_('That is already your phone number.'));
11494 -                   return;
11495 -               } else if ($this->sms_exists($sms)) {
11496 -                   $this->show_form(_('That phone number already belongs to another user.'));
11497 -                   return;
11498 -               }
11499 +        if (!$carrier_id) {
11500 +            $this->show_form(_('No carrier selected.'));
11501 +            return;
11502 +        }
11503 +        
11504 +        $sms = common_canonical_sms($sms);
11505 +        
11506 +        if ($user->sms == $sms) {
11507 +            $this->show_form(_('That is already your phone number.'));
11508 +            return;
11509 +        } else if ($this->sms_exists($sms)) {
11510 +            $this->show_form(_('That phone number already belongs to another user.'));
11511 +            return;
11512 +        }
11513 hunk ./actions/smssettings.php 203
11514 -               $confirm = new Confirm_address();
11515 -               $confirm->address = $sms;
11516 -               $confirm->address_extra = $carrier_id;
11517 -               $confirm->address_type = 'sms';
11518 -               $confirm->user_id = $user->id;
11519 -               $confirm->code = common_confirmation_code(40);
11520 +          $confirm = new Confirm_address();
11521 +           $confirm->address = $sms;
11522 +           $confirm->address_extra = $carrier_id;
11523 +           $confirm->address_type = 'sms';
11524 +           $confirm->user_id = $user->id;
11525 +           $confirm->code = common_confirmation_code(40);
11526 hunk ./actions/smssettings.php 210
11527 -               $result = $confirm->insert();
11528 +        $result = $confirm->insert();
11529 hunk ./actions/smssettings.php 212
11530 -               if ($result === FALSE) {
11531 -                       common_log_db_error($confirm, 'INSERT', __FILE__);
11532 -                       common_server_error(_('Couldn\'t insert confirmation code.'));
11533 -                       return;
11534 -               }
11535 +        if ($result === FALSE) {
11536 +            common_log_db_error($confirm, 'INSERT', __FILE__);
11537 +            common_server_error(_('Couldn\'t insert confirmation code.'));
11538 +            return;
11539 +        }
11540 hunk ./actions/smssettings.php 218
11541 -               $carrier = Sms_carrier::staticGet($carrier_id);
11542 -               
11543 -               mail_confirm_sms($confirm->code,
11544 -                                                $user->nickname,
11545 -                                                $carrier->toEmailAddress($sms));
11546 +        $carrier = Sms_carrier::staticGet($carrier_id);
11547 +        
11548 +        mail_confirm_sms($confirm->code,
11549 +                         $user->nickname,
11550 +                         $carrier->toEmailAddress($sms));
11551 hunk ./actions/smssettings.php 224
11552 -               $msg = _('A confirmation code was sent to the phone number you added. Check your inbox (and spam box!) for the code and instructions on how to use it.');
11553 +        $msg = _('A confirmation code was sent to the phone number you added. Check your inbox (and spam box!) for the code and instructions on how to use it.');
11554 hunk ./actions/smssettings.php 226
11555 -               $this->show_form($msg, TRUE);
11556 -       }
11557 +        $this->show_form($msg, TRUE);
11558 +    }
11559 hunk ./actions/smssettings.php 229
11560 -       function cancel_confirmation() {
11561 -               
11562 -               $sms = $this->trimmed('sms');
11563 -               $carrier = $this->trimmed('carrier');
11564 -               
11565 -               $confirm = $this->get_confirmation();
11566 -               
11567 -               if (!$confirm) {
11568 -                       $this->show_form(_('No pending confirmation to cancel.'));
11569 -                       return;
11570 -               }
11571 -               if ($confirm->address != $sms) {
11572 -                       $this->show_form(_('That is the wrong confirmation number.'));
11573 -                       return;
11574 -               }
11575 +    function cancel_confirmation() {
11576 +        
11577 +        $sms = $this->trimmed('sms');
11578 +        $carrier = $this->trimmed('carrier');
11579 +        
11580 +        $confirm = $this->get_confirmation();
11581 +        
11582 +        if (!$confirm) {
11583 +            $this->show_form(_('No pending confirmation to cancel.'));
11584 +            return;
11585 +        }
11586 +        if ($confirm->address != $sms) {
11587 +            $this->show_form(_('That is the wrong confirmation number.'));
11588 +            return;
11589 +        }
11590 hunk ./actions/smssettings.php 248
11591 -                       common_log_db_error($confirm, 'DELETE', __FILE__);
11592 +            common_log_db_error($confirm, 'DELETE', __FILE__);
11593 hunk ./actions/smssettings.php 254
11594 -       }
11595 +    }
11596 hunk ./actions/smssettings.php 256
11597 -       function remove_address() {
11598 +    function remove_address() {
11599 hunk ./actions/smssettings.php 258
11600 -               $user = common_current_user();
11601 -               $sms = $this->arg('sms');
11602 -               $carrier = $this->arg('carrier');
11603 -               
11604 -               # Maybe an old tab open...?
11605 +        $user = common_current_user();
11606 +        $sms = $this->arg('sms');
11607 +        $carrier = $this->arg('carrier');
11608 +        
11609 +        # Maybe an old tab open...?
11610 hunk ./actions/smssettings.php 264
11611 -               if ($user->sms != $sms) {
11612 -                   $this->show_form(_('That is not your phone number.'));
11613 -                   return;
11614 -               }
11615 +        if ($user->sms != $sms) {
11616 +            $this->show_form(_('That is not your phone number.'));
11617 +            return;
11618 +        }
11619 hunk ./actions/smssettings.php 269
11620 -               $user->query('BEGIN');
11621 -               $original = clone($user);
11622 -               $user->sms = NULL;
11623 -               $user->carrier = NULL;          
11624 -               $user->smsemail = NULL;         
11625 -               $result = $user->updateKeys($original);
11626 -               if (!$result) {
11627 -                       common_log_db_error($user, 'UPDATE', __FILE__);
11628 -                       common_server_error(_('Couldn\'t update user.'));
11629 -                       return;
11630 -               }
11631 -               $user->query('COMMIT');
11632 +        $user->query('BEGIN');
11633 +        $original = clone($user);
11634 +        $user->sms = NULL;
11635 +        $user->carrier = NULL;        
11636 +        $user->smsemail = NULL;        
11637 +        $result = $user->updateKeys($original);
11638 +        if (!$result) {
11639 +            common_log_db_error($user, 'UPDATE', __FILE__);
11640 +            common_server_error(_('Couldn\'t update user.'));
11641 +            return;
11642 +        }
11643 +        $user->query('COMMIT');
11644 hunk ./actions/smssettings.php 282
11645 -               $this->show_form(_('The address was removed.'), TRUE);
11646 -       }
11647 -       
11648 -       function sms_exists($sms) {
11649 -               $user = common_current_user();
11650 -               $other = User::staticGet('sms', $sms);
11651 -               if (!$other) {
11652 -                       return false;
11653 -               } else {
11654 -                       return $other->id != $user->id;
11655 -               }
11656 -       }
11657 +        $this->show_form(_('The address was removed.'), TRUE);
11658 +    }
11659 +    
11660 +    function sms_exists($sms) {
11661 +        $user = common_current_user();
11662 +        $other = User::staticGet('sms', $sms);
11663 +        if (!$other) {
11664 +            return false;
11665 +        } else {
11666 +            return $other->id != $user->id;
11667 +        }
11668 +    }
11669 hunk ./actions/smssettings.php 295
11670 -       function carrier_select() {
11671 -               $carrier = new Sms_carrier();
11672 -               $cnt = $carrier->find();
11673 +    function carrier_select() {
11674 +        $carrier = new Sms_carrier();
11675 +        $cnt = $carrier->find();
11676 hunk ./actions/smssettings.php 299
11677 -               common_element_start('p');
11678 -               common_element('label', array('for' => 'carrier'));
11679 -               common_element_start('select', array('name' => 'carrier',
11680 -                                                                                        'id' => 'carrier'));
11681 -               common_element('option', array('value' => 0),
11682 -                                          _('Select a carrier'));
11683 -               while ($carrier->fetch()) {
11684 -                       common_element('option', array('value' => $carrier->id),
11685 -                                                  $carrier->name);
11686 -               }
11687 -               common_element_end('select');
11688 -               common_element_end('p');
11689 -               common_element('span', 'input_instructions',
11690 -                                          sprintf(_('Mobile carrier for your phone. '.
11691 -                                                                'If you know a carrier that accepts ' . 
11692 -                                                                'SMS over email but isn\'t listed here, ' .
11693 -                                                                'send email to let us know at %s.'),
11694 -                                                          common_config('site', 'email')));
11695 -       }
11696 +        common_element_start('p');
11697 +        common_element('label', array('for' => 'carrier'));
11698 +        common_element_start('select', array('name' => 'carrier',
11699 +                                             'id' => 'carrier'));
11700 +        common_element('option', array('value' => 0),
11701 +                       _('Select a carrier'));
11702 +        while ($carrier->fetch()) {
11703 +            common_element('option', array('value' => $carrier->id),
11704 +                           $carrier->name);
11705 +        }
11706 +        common_element_end('select');
11707 +        common_element_end('p');
11708 +        common_element('span', 'input_instructions',
11709 +                       sprintf(_('Mobile carrier for your phone. '.
11710 +                                 'If you know a carrier that accepts ' . 
11711 +                                 'SMS over email but isn\'t listed here, ' .
11712 +                                 'send email to let us know at %s.'),
11713 +                               common_config('site', 'email')));
11714 +    }
11715 hunk ./actions/smssettings.php 319
11716 -       function confirm_code() {
11717 -               
11718 -               $code = $this->trimmed('code');
11719 -               
11720 -               if (!$code) {
11721 -                       $this->show_form(_('No code entered'));
11722 -                       return;
11723 -               }
11724 -               
11725 -               common_redirect(common_local_url('confirmaddress', 
11726 -                                                                                array('code' => $code)));
11727 -       }
11728 +    function confirm_code() {
11729 +        
11730 +        $code = $this->trimmed('code');
11731 +        
11732 +        if (!$code) {
11733 +            $this->show_form(_('No code entered'));
11734 +            return;
11735 +        }
11736 +        
11737 +        common_redirect(common_local_url('confirmaddress', 
11738 +                                         array('code' => $code)));
11739 +    }
11740 hunk ./actions/subedit.php 35
11741 -               $token = $this->trimmed('token');
11742 +        $token = $this->trimmed('token');
11743 hunk ./actions/subedit.php 37
11744 -               if (!$token || $token != common_session_token()) {
11745 -                       $this->client_error(_('There was a problem with your session token. Try again, please.'));
11746 -                       return;
11747 -               }
11748 +        if (!$token || $token != common_session_token()) {
11749 +            $this->client_error(_('There was a problem with your session token. Try again, please.'));
11750 +            return;
11751 +        }
11752 hunk ./actions/subscribe.php 24
11753 -       function handle($args) {
11754 -               parent::handle($args);
11755 +    function handle($args) {
11756 +        parent::handle($args);
11757 hunk ./actions/subscribe.php 27
11758 -               if (!common_logged_in()) {
11759 -                       common_user_error(_('Not logged in.'));
11760 -                       return;
11761 -               }
11762 +        if (!common_logged_in()) {
11763 +            common_user_error(_('Not logged in.'));
11764 +            return;
11765 +        }
11766 hunk ./actions/subscribe.php 32
11767 -               $user = common_current_user();
11768 +        $user = common_current_user();
11769 hunk ./actions/subscribe.php 34
11770 -               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
11771 -                       common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)));
11772 -                       return;
11773 -               }
11774 +        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
11775 +            common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)));
11776 +            return;
11777 +        }
11778 hunk ./actions/subscribe.php 39
11779 -               # CSRF protection
11780 +        # CSRF protection
11781 hunk ./actions/subscribe.php 41
11782 -               $token = $this->trimmed('token');
11783 +        $token = $this->trimmed('token');
11784 hunk ./actions/subscribe.php 43
11785 -               if (!$token || $token != common_session_token()) {
11786 -                       $this->client_error(_('There was a problem with your session token. Try again, please.'));
11787 -                       return;
11788 -               }
11789 +        if (!$token || $token != common_session_token()) {
11790 +            $this->client_error(_('There was a problem with your session token. Try again, please.'));
11791 +            return;
11792 +        }
11793 hunk ./actions/subscribe.php 48
11794 -               $other_id = $this->arg('subscribeto');
11795 +        $other_id = $this->arg('subscribeto');
11796 hunk ./actions/subscribe.php 53
11797 -                       $this->client_error(_('Not a local user.'));
11798 -                       return;
11799 +            $this->client_error(_('Not a local user.'));
11800 +            return;
11801 hunk ./actions/subscribe.php 57
11802 -               $result = subs_subscribe_to($user, $other);
11803 +        $result = subs_subscribe_to($user, $other);
11804 hunk ./actions/subscribe.php 59
11805 -               if($result != true) {
11806 -                       common_user_error($result);
11807 -                       return;
11808 -               }
11809 +        if($result != true) {
11810 +            common_user_error($result);
11811 +            return;
11812 +        }
11813 hunk ./actions/subscribe.php 64
11814 -               if ($this->boolean('ajax')) {
11815 -                       common_start_html('text/xml;charset=utf-8', true);
11816 -                       common_element_start('head');
11817 -                       common_element('title', null, _('Subscribed'));
11818 -                       common_element_end('head');
11819 -                       common_element_start('body');
11820 -                       common_unsubscribe_form($other->getProfile());
11821 -                       common_element_end('body');
11822 -                       common_element_end('html');
11823 -               } else {
11824 -                   common_redirect(common_local_url('subscriptions', array('nickname' =>
11825 -                                                                                                                               $user->nickname)));
11826 +        if ($this->boolean('ajax')) {
11827 +            common_start_html('text/xml;charset=utf-8', true);
11828 +            common_element_start('head');
11829 +            common_element('title', null, _('Subscribed'));
11830 +            common_element_end('head');
11831 +            common_element_start('body');
11832 +            common_unsubscribe_form($other->getProfile());
11833 +            common_element_end('body');
11834 +            common_element_end('html');
11835 +        } else {
11836 +            common_redirect(common_local_url('subscriptions', array('nickname' =>
11837 +                                                                $user->nickname)));
11838 hunk ./actions/subscribe.php 77
11839 -       }
11840 +    }
11841 hunk ./actions/subscribers.php 26
11842 -       function gallery_type() {
11843 -               return _('Subscribers');
11844 -       }
11845 +    function gallery_type() {
11846 +        return _('Subscribers');
11847 +    }
11848 hunk ./actions/subscribers.php 30
11849 -       function get_instructions(&$profile) {
11850 -               $user =& common_current_user();
11851 -               if ($user && ($user->id == $profile->id)) {
11852 -                       return _('These are the people who listen to your notices.');
11853 -               } else {
11854 -                       return sprintf(_('These are the people who listen to %s\'s notices.'), $profile->nickname);
11855 -               }
11856 -       }
11857 +    function get_instructions(&$profile) {
11858 +        $user =& common_current_user();
11859 +        if ($user && ($user->id == $profile->id)) {
11860 +            return _('These are the people who listen to your notices.');
11861 +        } else {
11862 +            return sprintf(_('These are the people who listen to %s\'s notices.'), $profile->nickname);
11863 +        }
11864 +    }
11865 hunk ./actions/subscribers.php 39
11866 -       function fields() {
11867 -               return array('subscriber', 'subscribed');
11868 -       }
11869 +    function fields() {
11870 +        return array('subscriber', 'subscribed');
11871 +    }
11872 hunk ./actions/subscribers.php 43
11873 -       function div_class() {
11874 -               return 'subscribers';
11875 -       }
11876 +    function div_class() {
11877 +        return 'subscribers';
11878 +    }
11879 hunk ./actions/subscribers.php 47
11880 -       function get_other(&$subs) {
11881 -               return $subs->subscriber;
11882 -       }
11883 +    function get_other(&$subs) {
11884 +        return $subs->subscriber;
11885 +    }
11886 hunk ./actions/subscriptions.php 26
11887 -       function gallery_type() {
11888 -               return _('Subscriptions');
11889 -       }
11890 +    function gallery_type() {
11891 +        return _('Subscriptions');
11892 +    }
11893 hunk ./actions/subscriptions.php 30
11894 -       function get_instructions(&$profile) {
11895 -               $user =& common_current_user();
11896 -               if ($user && ($user->id == $profile->id)) {
11897 -                       return _('These are the people whose notices you listen to.');
11898 -               } else {
11899 -                       return sprintf(_('These are the people whose notices %s listens to.'), $profile->nickname);
11900 -               }
11901 -       }
11902 +    function get_instructions(&$profile) {
11903 +        $user =& common_current_user();
11904 +        if ($user && ($user->id == $profile->id)) {
11905 +            return _('These are the people whose notices you listen to.');
11906 +        } else {
11907 +            return sprintf(_('These are the people whose notices %s listens to.'), $profile->nickname);
11908 +        }
11909 +    }
11910 hunk ./actions/subscriptions.php 39
11911 -       function fields() {
11912 -               return array('subscribed', 'subscriber');
11913 -       }
11914 +    function fields() {
11915 +        return array('subscribed', 'subscriber');
11916 +    }
11917 hunk ./actions/subscriptions.php 43
11918 -       function div_class() {
11919 -               return 'subscriptions';
11920 -       }
11921 +    function div_class() {
11922 +        return 'subscriptions';
11923 +    }
11924 hunk ./actions/subscriptions.php 47
11925 -       function get_other(&$subs) {
11926 -               return $subs->subscribed;
11927 -       }
11928 +    function get_other(&$subs) {
11929 +        return $subs->subscribed;
11930 +    }
11931 hunk ./actions/subscriptions.php 60
11932 -               $sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id,
11933 -                                                                                  'subscribed' => $profile->id));
11934 +        $sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id,
11935 +                                           'subscribed' => $profile->id));
11936 hunk ./actions/sup.php 23
11937 -       
11938 -       function handle($args) {
11939 -               
11940 -               parent::handle($args);
11941 -               
11942 -               $seconds = $this->trimmed('seconds');
11943 -               
11944 -               if (!$seconds) {
11945 -                       $seconds = 15;
11946 -               }
11947 +    
11948 +    function handle($args) {
11949 +        
11950 +        parent::handle($args);
11951 +        
11952 +        $seconds = $this->trimmed('seconds');
11953 +        
11954 +        if (!$seconds) {
11955 +            $seconds = 15;
11956 +        }
11957 hunk ./actions/sup.php 34
11958 -               $updates = $this->get_updates($seconds);
11959 -               
11960 -               header('Content-Type: application/json; charset=utf-8');
11961 -               
11962 -               print json_encode(array('updated_time' => date('c'),
11963 -                                                               'since_time' => date('c', time() - $seconds),
11964 -                                                               'available_periods' => $this->available_periods(),
11965 -                                                               'period' => $seconds,
11966 -                                                               'updates' => $updates));
11967 -       }
11968 -       
11969 -       function available_periods() {
11970 -               static $periods = array(86400, 43200, 21600, 7200,
11971 -                                                               3600, 1800,     600, 300, 120,
11972 -                                                               60, 30, 15); 
11973 -               $available = array();
11974 -               foreach ($periods as $period) {
11975 -                       $available[$period] = common_local_url('sup',
11976 -                                                                                                  array('seconds' => $period));
11977 -               }
11978 -               
11979 -               return $available;
11980 -       }
11981 -       
11982 -       function get_updates($seconds) {
11983 -               $notice = new Notice();
11984 +        $updates = $this->get_updates($seconds);
11985 +        
11986 +        header('Content-Type: application/json; charset=utf-8');
11987 +        
11988 +        print json_encode(array('updated_time' => date('c'),
11989 +                                'since_time' => date('c', time() - $seconds),
11990 +                                'available_periods' => $this->available_periods(),
11991 +                                'period' => $seconds,
11992 +                                'updates' => $updates));
11993 +    }
11994 +    
11995 +    function available_periods() {
11996 +        static $periods = array(86400, 43200, 21600, 7200,
11997 +                                3600, 1800,    600, 300, 120,
11998 +                                60, 30, 15); 
11999 +        $available = array();
12000 +        foreach ($periods as $period) {
12001 +            $available[$period] = common_local_url('sup',
12002 +                                                   array('seconds' => $period));
12003 +        }
12004 +        
12005 +        return $available;
12006 +    }
12007 +    
12008 +    function get_updates($seconds) {
12009 +        $notice = new Notice();
12010 hunk ./actions/sup.php 61
12011 -               # XXX: cache this. Depends on how big this protocol becomes;
12012 -               # Re-doing this query every 15 seconds isn't the end of the world.
12013 +        # XXX: cache this. Depends on how big this protocol becomes;
12014 +        # Re-doing this query every 15 seconds isn't the end of the world.
12015 hunk ./actions/sup.php 64
12016 -               $notice->query('SELECT profile_id, max(id) AS max_id ' .
12017 -                                          'FROM notice ' .
12018 -                                          'WHERE created > (now() - ' . $seconds . ') ' .
12019 -                                          'GROUP BY profile_id');
12020 -               
12021 -               $updates = array();
12022 -               
12023 -               while ($notice->fetch()) {
12024 -                       $updates[] = array($notice->profile_id, $notice->max_id);
12025 -               }
12026 -               
12027 -               return $updates;
12028 -       }
12029 -       
12030 -       function is_readonly() {
12031 -               return true;
12032 -       }
12033 +        $notice->query('SELECT profile_id, max(id) AS max_id ' .
12034 +                       'FROM notice ' .
12035 +                       'WHERE created > (now() - ' . $seconds . ') ' .
12036 +                       'GROUP BY profile_id');
12037 +        
12038 +        $updates = array();
12039 +        
12040 +        while ($notice->fetch()) {
12041 +            $updates[] = array($notice->profile_id, $notice->max_id);
12042 +        }
12043 +        
12044 +        return $updates;
12045 +    }
12046 +    
12047 +    function is_readonly() {
12048 +        return true;
12049 +    }
12050 hunk ./actions/tag.php 27
12051 -       function handle($args) {
12052 +    function handle($args) {
12053 hunk ./actions/tag.php 29
12054 -               parent::handle($args);
12055 +        parent::handle($args);
12056 hunk ./actions/tag.php 31
12057 -               # Looks like we're good; show the header
12058 +        # Looks like we're good; show the header
12059 hunk ./actions/tag.php 33
12060 -               if (isset($args['tag']) && $args['tag']) {
12061 -                       $tag = $args['tag'];
12062 -                       common_show_header(sprintf(_("Notices tagged with %s"), $tag),
12063 -                                                          array($this, 'show_header'), $tag,
12064 -                                                          array($this, 'show_top'));
12065 -                       $this->show_notices($tag);
12066 -               } else {
12067 -                       common_show_header(_("Tags"),
12068 -                                                          array($this, 'show_header'), '',
12069 -                                                          array($this, 'show_top'));
12070 -                       $this->show_tags();
12071 -               }
12072 +        if (isset($args['tag']) && $args['tag']) {
12073 +            $tag = $args['tag'];
12074 +            common_show_header(sprintf(_("Notices tagged with %s"), $tag),
12075 +                               array($this, 'show_header'), $tag,
12076 +                               array($this, 'show_top'));
12077 +            $this->show_notices($tag);
12078 +        } else {
12079 +            common_show_header(_("Tags"),
12080 +                               array($this, 'show_header'), '',
12081 +                               array($this, 'show_top'));
12082 +            $this->show_tags();
12083 +        }
12084 hunk ./actions/tag.php 46
12085 -               common_show_footer();
12086 -       }
12087 +        common_show_footer();
12088 +    }
12089 hunk ./actions/tag.php 49
12090 -       function show_header($tag = false) {
12091 -               if ($tag) {
12092 -                       common_element('link', array('rel' => 'alternate',
12093 -                                                                                'href' => common_local_url('tagrss', array('tag' => $tag)),
12094 -                                                                                'type' => 'application/rss+xml',
12095 -                                                                                'title' => sprintf(_('Feed for tag %s'), $tag)));
12096 -               }
12097 -       }
12098 +    function show_header($tag = false) {
12099 +        if ($tag) {
12100 +            common_element('link', array('rel' => 'alternate',
12101 +                                         'href' => common_local_url('tagrss', array('tag' => $tag)),
12102 +                                         'type' => 'application/rss+xml',
12103 +                                         'title' => sprintf(_('Feed for tag %s'), $tag)));
12104 +        }
12105 +    }
12106 hunk ./actions/tag.php 58
12107 -       function get_instructions() {
12108 -               return _('Showing most popular tags from the last week');
12109 -       }
12110 +    function get_instructions() {
12111 +        return _('Showing most popular tags from the last week');
12112 +    }
12113 hunk ./actions/tag.php 62
12114 -       function show_top($tag = false) {
12115 -               if (!$tag) {
12116 -                       $instr = $this->get_instructions();
12117 -                       $output = common_markup_to_html($instr);
12118 -                       common_element_start('div', 'instructions');
12119 -                       common_raw($output);
12120 -                       common_element_end('div');
12121 -                       $this->public_views_menu();
12122 -               }
12123 -               else {
12124 -                       $this->show_feeds_list(array(0=>array('href'=>common_local_url('tagrss'),
12125 -                                                                                                 'type' => 'rss',
12126 -                                                                                                 'version' => 'RSS 1.0',
12127 -                                                                                                 'item' => 'tagrss')));
12128 -               }
12129 -       }
12130 +    function show_top($tag = false) {
12131 +        if (!$tag) {
12132 +            $instr = $this->get_instructions();
12133 +            $output = common_markup_to_html($instr);
12134 +            common_element_start('div', 'instructions');
12135 +            common_raw($output);
12136 +            common_element_end('div');
12137 +            $this->public_views_menu();
12138 +        }
12139 +        else {
12140 +            $this->show_feeds_list(array(0=>array('href'=>common_local_url('tagrss'),
12141 +                                                  'type' => 'rss',
12142 +                                                  'version' => 'RSS 1.0',
12143 +                                                  'item' => 'tagrss')));
12144 +        }
12145 +    }
12146 hunk ./actions/tag.php 79
12147 -       function show_tags()
12148 -       {
12149 -               # This should probably be cached rather than recalculated
12150 -               $tags = DB_DataObject::factory('Notice_tag');
12151 +    function show_tags()
12152 +    {
12153 +        # This should probably be cached rather than recalculated
12154 +        $tags = DB_DataObject::factory('Notice_tag');
12155 hunk ./actions/tag.php 84
12156 -               #Need to clear the selection and then only re-add the field
12157 -               #we are grouping by, otherwise it's not a valid 'group by'
12158 -               #even though MySQL seems to let it slide...
12159 -               $tags->selectAdd();
12160 -               $tags->selectAdd('tag');
12161 +        #Need to clear the selection and then only re-add the field
12162 +        #we are grouping by, otherwise it's not a valid 'group by'
12163 +        #even though MySQL seems to let it slide...
12164 +        $tags->selectAdd();
12165 +        $tags->selectAdd('tag');
12166 hunk ./actions/tag.php 90
12167 -               #Add the aggregated columns...
12168 -               $tags->selectAdd('max(notice_id) as last_notice_id');
12169 -               if(common_config('db','type')=='pgsql') {
12170 -                       $calc='sum(exp(-extract(epoch from (now()-created))/%s)) as weight';
12171 -               } else {
12172 -                       $calc='sum(exp(-(now() - created)/%s)) as weight';
12173 -               }
12174 -               $tags->selectAdd(sprintf($calc, common_config('tag', 'dropoff')));
12175 -               $tags->groupBy('tag');
12176 -               $tags->orderBy('weight DESC');
12177 +        #Add the aggregated columns...
12178 +        $tags->selectAdd('max(notice_id) as last_notice_id');
12179 +        if(common_config('db','type')=='pgsql') {
12180 +            $calc='sum(exp(-extract(epoch from (now()-created))/%s)) as weight';
12181 +        } else {
12182 +            $calc='sum(exp(-(now() - created)/%s)) as weight';
12183 +        }
12184 +        $tags->selectAdd(sprintf($calc, common_config('tag', 'dropoff')));
12185 +        $tags->groupBy('tag');
12186 +        $tags->orderBy('weight DESC');
12187 hunk ./actions/tag.php 101
12188 -               # $tags->whereAdd('created > "' . strftime('%Y-%m-%d %H:%M:%S', strtotime('-1 MONTH')) . '"');
12189 +        # $tags->whereAdd('created > "' . strftime('%Y-%m-%d %H:%M:%S', strtotime('-1 MONTH')) . '"');
12190 hunk ./actions/tag.php 103
12191 -               $tags->limit(TAGS_PER_PAGE);
12192 +        $tags->limit(TAGS_PER_PAGE);
12193 hunk ./actions/tag.php 105
12194 -               $cnt = $tags->find();
12195 +        $cnt = $tags->find();
12196 hunk ./actions/tag.php 107
12197 -               if ($cnt > 0) {
12198 -                       common_element_start('p', 'tagcloud');
12199 +        if ($cnt > 0) {
12200 +            common_element_start('p', 'tagcloud');
12201 hunk ./actions/tag.php 110
12202 -                       $tw = array();
12203 -                       $sum = 0;
12204 -                       while ($tags->fetch()) {
12205 -                               $tw[$tags->tag] = $tags->weight;
12206 -                               $sum += $tags->weight;
12207 -                       }
12208 +            $tw = array();
12209 +            $sum = 0;
12210 +            while ($tags->fetch()) {
12211 +                $tw[$tags->tag] = $tags->weight;
12212 +                $sum += $tags->weight;
12213 +            }
12214 hunk ./actions/tag.php 117
12215 -                       ksort($tw);
12216 +            ksort($tw);
12217 hunk ./actions/tag.php 119
12218 -                       foreach ($tw as $tag => $weight) {
12219 -                               $this->show_tag($tag, $weight, $weight/$sum);
12220 -                       }
12221 +            foreach ($tw as $tag => $weight) {
12222 +                $this->show_tag($tag, $weight, $weight/$sum);
12223 +            }
12224 hunk ./actions/tag.php 123
12225 -                       common_element_end('p');
12226 -               }
12227 -       }
12228 +            common_element_end('p');
12229 +        }
12230 +    }
12231 hunk ./actions/tag.php 127
12232 -       function show_tag($tag, $weight, $relative) {
12233 +    function show_tag($tag, $weight, $relative) {
12234 hunk ./actions/tag.php 129
12235 -               # XXX: these should probably tune to the size of the site
12236 -               if ($relative > 0.1) {
12237 -                       $cls =  'largest';
12238 -               } else if ($relative > 0.05) {
12239 -                       $cls = 'verylarge';
12240 -               } else if ($relative > 0.02) {
12241 -                       $cls = 'large';
12242 -               } else if ($relative > 0.01) {
12243 -                       $cls = 'medium';
12244 -               } else if ($relative > 0.005) {
12245 -                       $cls = 'small';
12246 -               } else if ($relative > 0.002) {
12247 -                       $cls = 'verysmall';
12248 -               } else {
12249 -                       $cls = 'smallest';
12250 -               }
12251 +        # XXX: these should probably tune to the size of the site
12252 +        if ($relative > 0.1) {
12253 +            $cls =  'largest';
12254 +        } else if ($relative > 0.05) {
12255 +            $cls = 'verylarge';
12256 +        } else if ($relative > 0.02) {
12257 +            $cls = 'large';
12258 +        } else if ($relative > 0.01) {
12259 +            $cls = 'medium';
12260 +        } else if ($relative > 0.005) {
12261 +            $cls = 'small';
12262 +        } else if ($relative > 0.002) {
12263 +            $cls = 'verysmall';
12264 +        } else {
12265 +            $cls = 'smallest';
12266 +        }
12267 hunk ./actions/tag.php 146
12268 -               common_element('a', array('class' => "$cls weight-$weight relative-$relative",
12269 -                                                                 'href' => common_local_url('tag', array('tag' => $tag))),
12270 -                                          $tag);
12271 -               common_text(' ');
12272 -       }
12273 +        common_element('a', array('class' => "$cls weight-$weight relative-$relative",
12274 +                                  'href' => common_local_url('tag', array('tag' => $tag))),
12275 +                       $tag);
12276 +        common_text(' ');
12277 +    }
12278 hunk ./actions/tag.php 152
12279 -       function show_notices($tag) {
12280 +    function show_notices($tag) {
12281 hunk ./actions/tag.php 154
12282 -               $cnt = 0;
12283 +        $cnt = 0;
12284 hunk ./actions/tag.php 156
12285 -               $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
12286 +        $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
12287 hunk ./actions/tag.php 158
12288 -               $notice = Notice_tag::getStream($tag, (($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
12289 +        $notice = Notice_tag::getStream($tag, (($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
12290 hunk ./actions/tag.php 162
12291 -               common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
12292 -                                                 $page, 'tag', array('tag' => $tag));
12293 -       }
12294 +        common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
12295 +                          $page, 'tag', array('tag' => $tag));
12296 +    }
12297 hunk ./actions/tagother.php 26
12298 -       function handle($args) {
12299 +    function handle($args) {
12300 hunk ./actions/tagother.php 28
12301 -               parent::handle($args);
12302 +        parent::handle($args);
12303 hunk ./actions/tagother.php 30
12304 -               if (!common_logged_in()) {
12305 -                       $this->client_error(_('Not logged in'), 403);
12306 -                       return;
12307 -               }
12308 +        if (!common_logged_in()) {
12309 +            $this->client_error(_('Not logged in'), 403);
12310 +            return;
12311 +        }
12312 hunk ./actions/tagother.php 35
12313 -               if ($_SERVER['REQUEST_METHOD'] == 'POST') {
12314 -                       $this->save_tags();
12315 -               } else {
12316 -                       $id = $this->trimmed('id');
12317 -                       if (!$id) {
12318 -                               $this->client_error(_('No id argument.'));
12319 -                               return;
12320 -                       }
12321 -                       $profile = Profile::staticGet('id', $id);
12322 -                       if (!$profile) {
12323 -                               $this->client_error(_('No profile with that ID.'));
12324 -                               return;
12325 -                       }
12326 -                       $this->show_form($profile);
12327 -               }
12328 -       }
12329 +        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
12330 +            $this->save_tags();
12331 +        } else {
12332 +            $id = $this->trimmed('id');
12333 +            if (!$id) {
12334 +                $this->client_error(_('No id argument.'));
12335 +                return;
12336 +            }
12337 +            $profile = Profile::staticGet('id', $id);
12338 +            if (!$profile) {
12339 +                $this->client_error(_('No profile with that ID.'));
12340 +                return;
12341 +            }
12342 +            $this->show_form($profile);
12343 +        }
12344 +    }
12345 hunk ./actions/tagother.php 52
12346 -       function show_form($profile, $error=NULL) {
12347 +    function show_form($profile, $error=NULL) {
12348 hunk ./actions/tagother.php 54
12349 -               $user = common_current_user();
12350 +        $user = common_current_user();
12351 hunk ./actions/tagother.php 56
12352 -               common_show_header(_('Tag a person'),
12353 -                                                  NULL, array($profile, $error), array($this, 'show_top'));
12354 +        common_show_header(_('Tag a person'),
12355 +                           NULL, array($profile, $error), array($this, 'show_top'));
12356 hunk ./actions/tagother.php 59
12357 -               $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
12358 +        $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
12359 hunk ./actions/tagother.php 61
12360 -               common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
12361 -                                                                       'class' => 'avatar stream',
12362 -                                                                       'width' => AVATAR_PROFILE_SIZE,
12363 -                                                                       'height' => AVATAR_PROFILE_SIZE,
12364 -                                                                       'alt' =>
12365 -                                                                       ($profile->fullname) ? $profile->fullname :
12366 -                                                                       $profile->nickname));
12367 +        common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
12368 +                                    'class' => 'avatar stream',
12369 +                                    'width' => AVATAR_PROFILE_SIZE,
12370 +                                    'height' => AVATAR_PROFILE_SIZE,
12371 +                                    'alt' =>
12372 +                                    ($profile->fullname) ? $profile->fullname :
12373 +                                    $profile->nickname));
12374 hunk ./actions/tagother.php 69
12375 -               common_element('a', array('href' => $profile->profileurl,
12376 -                                                                 'class' => 'external profile nickname'),
12377 -                                          $profile->nickname);
12378 +        common_element('a', array('href' => $profile->profileurl,
12379 +                                  'class' => 'external profile nickname'),
12380 +                       $profile->nickname);
12381 hunk ./actions/tagother.php 73
12382 -               if ($profile->fullname) {
12383 -                       common_element_start('div', 'fullname');
12384 -                       if ($profile->homepage) {
12385 -                               common_element('a', array('href' => $profile->homepage),
12386 -                                                          $profile->fullname);
12387 -                       } else {
12388 -                               common_text($profile->fullname);
12389 -                       }
12390 -                       common_element_end('div');
12391 -               }
12392 -               if ($profile->location) {
12393 -                       common_element('div', 'location', $profile->location);
12394 -               }
12395 -               if ($profile->bio) {
12396 -                       common_element('div', 'bio', $profile->bio);
12397 -               }
12398 +        if ($profile->fullname) {
12399 +            common_element_start('div', 'fullname');
12400 +            if ($profile->homepage) {
12401 +                common_element('a', array('href' => $profile->homepage),
12402 +                               $profile->fullname);
12403 +            } else {
12404 +                common_text($profile->fullname);
12405 +            }
12406 +            common_element_end('div');
12407 +        }
12408 +        if ($profile->location) {
12409 +            common_element('div', 'location', $profile->location);
12410 +        }
12411 +        if ($profile->bio) {
12412 +            common_element('div', 'bio', $profile->bio);
12413 +        }
12414 hunk ./actions/tagother.php 90
12415 -               common_element_start('form', array('method' => 'post',
12416 -                                                                                  'id' => 'tag_user',
12417 -                                                                                  'name' => 'tagother',
12418 -                                                                                  'action' => $this->self_url()));
12419 -               common_hidden('token', common_session_token());
12420 -               common_hidden('id', $profile->id);
12421 -               common_input('tags', _('Tags'),
12422 -                                        ($this->arg('tags')) ? $this->arg('tags') : implode(' ', Profile_tag::getTags($user->id, $profile->id)),
12423 -                                        _('Tags for this user (letters, numbers, -, ., and _), comma- or space- separated'));
12424 +        common_element_start('form', array('method' => 'post',
12425 +                                           'id' => 'tag_user',
12426 +                                           'name' => 'tagother',
12427 +                                           'action' => $this->self_url()));
12428 +        common_hidden('token', common_session_token());
12429 +        common_hidden('id', $profile->id);
12430 +        common_input('tags', _('Tags'),
12431 +                     ($this->arg('tags')) ? $this->arg('tags') : implode(' ', Profile_tag::getTags($user->id, $profile->id)),
12432 +                     _('Tags for this user (letters, numbers, -, ., and _), comma- or space- separated'));
12433 hunk ./actions/tagother.php 100
12434 -               common_submit('save', _('Save'));
12435 -               common_element_end('form');
12436 -               common_show_footer();
12437 +        common_submit('save', _('Save'));
12438 +        common_element_end('form');
12439 +        common_show_footer();
12440 hunk ./actions/tagother.php 104
12441 -       }
12442 +    }
12443 hunk ./actions/tagother.php 106
12444 -       function save_tags() {
12445 +    function save_tags() {
12446 hunk ./actions/tagother.php 108
12447 -               $id = $this->trimmed('id');
12448 -               $tagstring = $this->trimmed('tags');
12449 -               $token = $this->trimmed('token');
12450 +        $id = $this->trimmed('id');
12451 +        $tagstring = $this->trimmed('tags');
12452 +        $token = $this->trimmed('token');
12453 hunk ./actions/tagother.php 112
12454 -               if (!$token || $token != common_session_token()) {
12455 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
12456 -                       return;
12457 -               }
12458 +        if (!$token || $token != common_session_token()) {
12459 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
12460 +            return;
12461 +        }
12462 hunk ./actions/tagother.php 117
12463 -               $profile = Profile::staticGet('id', $id);
12464 +        $profile = Profile::staticGet('id', $id);
12465 hunk ./actions/tagother.php 119
12466 -               if (!$profile) {
12467 -                       $this->client_error(_('No such profile.'));
12468 -                       return;
12469 -               }
12470 +        if (!$profile) {
12471 +            $this->client_error(_('No such profile.'));
12472 +            return;
12473 +        }
12474 hunk ./actions/tagother.php 124
12475 -               if (is_string($tagstring) && strlen($tagstring) > 0) {
12476 +        if (is_string($tagstring) && strlen($tagstring) > 0) {
12477 hunk ./actions/tagother.php 126
12478 -                       $tags = array_map('common_canonical_tag',
12479 -                                                         preg_split('/[\s,]+/', $tagstring));
12480 +            $tags = array_map('common_canonical_tag',
12481 +                              preg_split('/[\s,]+/', $tagstring));
12482 hunk ./actions/tagother.php 129
12483 -                       foreach ($tags as $tag) {
12484 -                               if (!common_valid_profile_tag($tag)) {
12485 -                                       $this->show_form($profile, sprintf(_('Invalid tag: "%s"'), $tag));
12486 -                                       return;
12487 -                               }
12488 -                       }
12489 -               } else {
12490 -                       $tags = array();
12491 -               }
12492 +            foreach ($tags as $tag) {
12493 +                if (!common_valid_profile_tag($tag)) {
12494 +                    $this->show_form($profile, sprintf(_('Invalid tag: "%s"'), $tag));
12495 +                    return;
12496 +                }
12497 +            }
12498 +        } else {
12499 +            $tags = array();
12500 +        }
12501 hunk ./actions/tagother.php 139
12502 -               $user = common_current_user();
12503 +        $user = common_current_user();
12504 hunk ./actions/tagother.php 141
12505 -               if (!Subscription::pkeyGet(array('subscriber' => $user->id,
12506 -                                                                                'subscribed' => $profile->id)) &&
12507 -                       !Subscription::pkeyGet(array('subscriber' => $profile->id,
12508 -                                                                                'subscribed' => $user->id)))
12509 -               {
12510 -                       $this->client_error(_('You can only tag people you are subscribed to or who are subscribed to you.'));
12511 -                       return;
12512 -               }
12513 +        if (!Subscription::pkeyGet(array('subscriber' => $user->id,
12514 +                                         'subscribed' => $profile->id)) &&
12515 +            !Subscription::pkeyGet(array('subscriber' => $profile->id,
12516 +                                         'subscribed' => $user->id)))
12517 +        {
12518 +            $this->client_error(_('You can only tag people you are subscribed to or who are subscribed to you.'));
12519 +            return;
12520 +        }
12521 hunk ./actions/tagother.php 150
12522 -               $result = Profile_tag::setTags($user->id, $profile->id, $tags);
12523 +        $result = Profile_tag::setTags($user->id, $profile->id, $tags);
12524 hunk ./actions/tagother.php 152
12525 -               if (!$result) {
12526 -                       $this->client_error(_('Could not save tags.'));
12527 -                       return;
12528 -               }
12529 +        if (!$result) {
12530 +            $this->client_error(_('Could not save tags.'));
12531 +            return;
12532 +        }
12533 hunk ./actions/tagother.php 157
12534 -               $action = $user->isSubscribed($profile) ? 'subscriptions' : 'subscribers';
12535 +        $action = $user->isSubscribed($profile) ? 'subscriptions' : 'subscribers';
12536 hunk ./actions/tagother.php 159
12537 -               if ($this->boolean('ajax')) {
12538 -                       common_start_html('text/xml');
12539 -                       common_element_start('head');
12540 -                       common_element('title', null, _('Tags'));
12541 -                       common_element_end('head');
12542 -                       common_element_start('body');
12543 -                       common_element_start('p', 'subtags');
12544 -                       foreach ($tags as $tag) {
12545 -                               common_element('a', array('href' => common_local_url($action,
12546 -                                                                                                                                        array('nickname' => $user->nickname,
12547 -                                                                                                                                                  'tag' => $tag))),
12548 -                                                          $tag);
12549 -                       }
12550 -                       common_element_end('p');
12551 -                       common_element_end('body');
12552 -                       common_element_end('html');
12553 -               } else {
12554 -                       common_redirect(common_local_url($action, array('nickname' =>
12555 -                                                                                                                       $user->nickname)));
12556 +        if ($this->boolean('ajax')) {
12557 +            common_start_html('text/xml');
12558 +            common_element_start('head');
12559 +            common_element('title', null, _('Tags'));
12560 +            common_element_end('head');
12561 +            common_element_start('body');
12562 +            common_element_start('p', 'subtags');
12563 +            foreach ($tags as $tag) {
12564 +                common_element('a', array('href' => common_local_url($action,
12565 +                                                                     array('nickname' => $user->nickname,
12566 +                                                                           'tag' => $tag))),
12567 +                               $tag);
12568 +            }
12569 +            common_element_end('p');
12570 +            common_element_end('body');
12571 +            common_element_end('html');
12572 +        } else {
12573 +            common_redirect(common_local_url($action, array('nickname' =>
12574 +                                                            $user->nickname)));
12575 hunk ./actions/tagother.php 179
12576 -       }
12577 +    }
12578 hunk ./actions/tagother.php 181
12579 -       function show_top($arr = NULL) {
12580 -               list($profile, $error) = $arr;
12581 -               if ($error) {
12582 -                       common_element('p', 'error', $error);
12583 -               } else {
12584 -                       common_element_start('div', 'instructions');
12585 -                       common_element('p', NULL,
12586 -                                                  _('Use this form to add tags to your subscribers or subscriptions.'));
12587 -                       common_element_end('div');
12588 -               }
12589 -       }
12590 +    function show_top($arr = NULL) {
12591 +        list($profile, $error) = $arr;
12592 +        if ($error) {
12593 +            common_element('p', 'error', $error);
12594 +        } else {
12595 +            common_element_start('div', 'instructions');
12596 +            common_element('p', NULL,
12597 +                           _('Use this form to add tags to your subscribers or subscriptions.'));
12598 +            common_element_end('div');
12599 +        }
12600 +    }
12601 hunk ./actions/tagrss.php 28
12602 -       function init() {
12603 -               $tag = $this->trimmed('tag');
12604 -               $this->tag = Notice_tag::staticGet('tag', $tag);
12605 +    function init() {
12606 +        $tag = $this->trimmed('tag');
12607 +        $this->tag = Notice_tag::staticGet('tag', $tag);
12608 hunk ./actions/tagrss.php 32
12609 -               if (!$this->tag) {
12610 -                       common_user_error(_('No such tag.'));
12611 -                       return false;
12612 -               } else {
12613 -                       return true;
12614 -               }
12615 -       }
12616 +        if (!$this->tag) {
12617 +            common_user_error(_('No such tag.'));
12618 +            return false;
12619 +        } else {
12620 +            return true;
12621 +        }
12622 +    }
12623 hunk ./actions/tagrss.php 40
12624 -       function get_notices($limit=0) {
12625 -               $tag = $this->tag;
12626 +    function get_notices($limit=0) {
12627 +        $tag = $this->tag;
12628 hunk ./actions/tagrss.php 43
12629 -               if (is_null($tag)) {
12630 -                       return NULL;
12631 -               }
12632 +        if (is_null($tag)) {
12633 +            return NULL;
12634 +        }
12635 hunk ./actions/tagrss.php 47
12636 -               $notice = Notice_tag::getStream($tag->tag, 0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
12637 +        $notice = Notice_tag::getStream($tag->tag, 0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
12638 hunk ./actions/tagrss.php 49
12639 -               while ($notice->fetch()) {
12640 -                       $notices[] = clone($notice);
12641 -               }
12642 +        while ($notice->fetch()) {
12643 +            $notices[] = clone($notice);
12644 +        }
12645 hunk ./actions/tagrss.php 53
12646 -               return $notices;
12647 -       }
12648 +        return $notices;
12649 +    }
12650 hunk ./actions/tagrss.php 56
12651 -       function get_channel() {
12652 -               $tag = $this->tag->tag;
12653 +    function get_channel() {
12654 +        $tag = $this->tag->tag;
12655 hunk ./actions/tagrss.php 59
12656 -               $c = array('url' => common_local_url('tagrss', array('tag' => $tagname)),
12657 -                          'title' => $tagname,
12658 -                          'link' => common_local_url('tagrss', array('tag' => $tagname)),
12659 -                          'description' => sprintf(_('Microblog tagged with %s'), $tagname));
12660 -               return $c;
12661 -       }
12662 +        $c = array('url' => common_local_url('tagrss', array('tag' => $tagname)),
12663 +               'title' => $tagname,
12664 +               'link' => common_local_url('tagrss', array('tag' => $tagname)),
12665 +               'description' => sprintf(_('Microblog tagged with %s'), $tagname));
12666 +        return $c;
12667 +    }
12668 hunk ./actions/twitapiaccount.php 26
12669 -       function verify_credentials($args, $apidata) {
12670 -               parent::handle($args);
12671 +    function verify_credentials($args, $apidata) {
12672 +        parent::handle($args);
12673 hunk ./actions/twitapiaccount.php 29
12674 -               if (!in_array($apidata['content-type'], array('xml', 'json'))) {
12675 -                       common_user_error(_('API method not found!'), $code = 404);
12676 -                       return;
12677 -               }
12678 +        if (!in_array($apidata['content-type'], array('xml', 'json'))) {
12679 +            common_user_error(_('API method not found!'), $code = 404);
12680 +            return;
12681 +        }
12682 hunk ./actions/twitapiaccount.php 34
12683 -               $this->show_extended_profile($apidata['user'], $apidata);
12684 -       }
12685 +        $this->show_extended_profile($apidata['user'], $apidata);
12686 +    }
12687 hunk ./actions/twitapiaccount.php 37
12688 -       function end_session($args, $apidata) {
12689 -               parent::handle($args);
12690 -               common_server_error(_('API method under construction.'), $code=501);
12691 -       }
12692 +    function end_session($args, $apidata) {
12693 +        parent::handle($args);
12694 +        common_server_error(_('API method under construction.'), $code=501);
12695 +    }
12696 hunk ./actions/twitapiaccount.php 42
12697 -       function update_location($args, $apidata) {
12698 -               parent::handle($args);
12699 +    function update_location($args, $apidata) {
12700 +        parent::handle($args);
12701 hunk ./actions/twitapiaccount.php 45
12702 -               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
12703 -                       $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
12704 -                       return;
12705 -               }
12706 +        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
12707 +            $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
12708 +            return;
12709 +        }
12710 hunk ./actions/twitapiaccount.php 50
12711 -               $location = trim($this->arg('location'));
12712 +        $location = trim($this->arg('location'));
12713 hunk ./actions/twitapiaccount.php 52
12714 -               if (!is_null($location) && strlen($location) > 255) {
12715 +        if (!is_null($location) && strlen($location) > 255) {
12716 hunk ./actions/twitapiaccount.php 54
12717 -                       // XXX: But Twitter just truncates and runs with it. -- Zach
12718 -                       $this->client_error(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
12719 -                       return;
12720 -               }
12721 +            // XXX: But Twitter just truncates and runs with it. -- Zach
12722 +            $this->client_error(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']);
12723 +            return;
12724 +        }
12725 hunk ./actions/twitapiaccount.php 59
12726 -               $user = $apidata['user'];
12727 -               $profile = $user->getProfile();
12728 +        $user = $apidata['user'];
12729 +        $profile = $user->getProfile();
12730 hunk ./actions/twitapiaccount.php 62
12731 -               if (!$profile) {
12732 -                       common_server_error(_('User has no profile.'));
12733 -                       return;
12734 -               }
12735 +        if (!$profile) {
12736 +            common_server_error(_('User has no profile.'));
12737 +            return;
12738 +        }
12739 hunk ./actions/twitapiaccount.php 67
12740 -               $orig_profile = clone($profile);
12741 -               $profile->location = $location;
12742 +        $orig_profile = clone($profile);
12743 +        $profile->location = $location;
12744 hunk ./actions/twitapiaccount.php 70
12745 -               $result = $profile->update($orig_profile);
12746 +        $result = $profile->update($orig_profile);
12747 hunk ./actions/twitapiaccount.php 72
12748 -               if (!$result) {
12749 -                       common_log_db_error($profile, 'UPDATE', __FILE__);
12750 -                       common_server_error(_('Couldn\'t save profile.'));
12751 -                       return;
12752 -               }
12753 +        if (!$result) {
12754 +            common_log_db_error($profile, 'UPDATE', __FILE__);
12755 +            common_server_error(_('Couldn\'t save profile.'));
12756 +            return;
12757 +        }
12758 hunk ./actions/twitapiaccount.php 78
12759 -               common_broadcast_profile($profile);
12760 -               $type = $apidata['content-type'];
12761 +        common_broadcast_profile($profile);
12762 +        $type = $apidata['content-type'];
12763 hunk ./actions/twitapiaccount.php 81
12764 -               $this->init_document($type);
12765 -               $this->show_profile($profile, $type);
12766 -               $this->end_document($type);
12767 -       }
12768 +        $this->init_document($type);
12769 +        $this->show_profile($profile, $type);
12770 +        $this->end_document($type);
12771 +    }
12772 hunk ./actions/twitapiaccount.php 87
12773 -       function update_delivery_device($args, $apidata) {
12774 -               parent::handle($args);
12775 -               common_server_error(_('API method under construction.'), $code=501);
12776 -       }
12777 +    function update_delivery_device($args, $apidata) {
12778 +        parent::handle($args);
12779 +        common_server_error(_('API method under construction.'), $code=501);
12780 +    }
12781 hunk ./actions/twitapiaccount.php 92
12782 -       function rate_limit_status($args, $apidata) {
12783 -               parent::handle($args);
12784 -               common_server_error(_('API method under construction.'), $code=501);
12785 -       }
12786 +    function rate_limit_status($args, $apidata) {
12787 +        parent::handle($args);
12788 +        common_server_error(_('API method under construction.'), $code=501);
12789 +    }
12790 hunk ./actions/twitapiblocks.php 26
12791 -       function create($args, $apidata) {
12792 +    function create($args, $apidata) {
12793 hunk ./actions/twitapiblocks.php 28
12794 -               parent::handle($args);
12795 +        parent::handle($args);
12796 hunk ./actions/twitapiblocks.php 30
12797 -               $blockee = $this->get_user($apidata['api_arg'], $apidata);
12798 +        $blockee = $this->get_user($apidata['api_arg'], $apidata);
12799 hunk ./actions/twitapiblocks.php 33
12800 -                       $this->client_error('Not Found', 404, $apidata['content-type']);
12801 -                       return;
12802 +            $this->client_error('Not Found', 404, $apidata['content-type']);
12803 +            return;
12804 hunk ./actions/twitapiblocks.php 45
12805 -                       common_server_error(_('Block user failed.'));
12806 +            common_server_error(_('Block user failed.'));
12807 hunk ./actions/twitapiblocks.php 47
12808 -       }
12809 +    }
12810 hunk ./actions/twitapiblocks.php 49
12811 -       function destroy($args, $apidata) {
12812 -               parent::handle($args);
12813 -               $blockee = $this->get_user($apidata['api_arg'], $apidata);
12814 +    function destroy($args, $apidata) {
12815 +        parent::handle($args);
12816 +        $blockee = $this->get_user($apidata['api_arg'], $apidata);
12817 hunk ./actions/twitapiblocks.php 54
12818 -                       $this->client_error('Not Found', 404, $apidata['content-type']);
12819 -                       return;
12820 +            $this->client_error('Not Found', 404, $apidata['content-type']);
12821 +            return;
12822 hunk ./actions/twitapiblocks.php 66
12823 -                       common_server_error(_('Unblock user failed.'));
12824 +            common_server_error(_('Unblock user failed.'));
12825 hunk ./actions/twitapiblocks.php 68
12826 -       }
12827 +    }
12828 hunk ./actions/twitapidirect_messages.php 26
12829 -       function direct_messages($args, $apidata) {
12830 -               parent::handle($args);
12831 -               return $this->show_messages($args, $apidata, 'received');
12832 -       }
12833 +    function direct_messages($args, $apidata) {
12834 +        parent::handle($args);
12835 +        return $this->show_messages($args, $apidata, 'received');
12836 +    }
12837 hunk ./actions/twitapidirect_messages.php 31
12838 -       function sent($args, $apidata) {
12839 -               parent::handle($args);
12840 -               return $this->show_messages($args, $apidata, 'sent');
12841 -       }
12842 +    function sent($args, $apidata) {
12843 +        parent::handle($args);
12844 +        return $this->show_messages($args, $apidata, 'sent');
12845 +    }
12846 hunk ./actions/twitapidirect_messages.php 36
12847 -       function show_messages($args, $apidata, $type) {
12848 +    function show_messages($args, $apidata, $type) {
12849 hunk ./actions/twitapidirect_messages.php 38
12850 -               $user = $apidata['user'];
12851 +        $user = $apidata['user'];
12852 hunk ./actions/twitapidirect_messages.php 40
12853 -               $count = $this->arg('count');
12854 -               $since = $this->arg('since');
12855 -               $since_id = $this->arg('since_id');
12856 -               $before_id = $this->arg('before_id');
12857 +        $count = $this->arg('count');
12858 +        $since = $this->arg('since');
12859 +        $since_id = $this->arg('since_id');
12860 +        $before_id = $this->arg('before_id');
12861 hunk ./actions/twitapidirect_messages.php 45
12862 -               $page = $this->arg('page');
12863 +        $page = $this->arg('page');
12864 hunk ./actions/twitapidirect_messages.php 47
12865 -               if (!$page) {
12866 -                       $page = 1;
12867 -               }
12868 +        if (!$page) {
12869 +            $page = 1;
12870 +        }
12871 hunk ./actions/twitapidirect_messages.php 51
12872 -               if (!$count) {
12873 -                       $count = 20;
12874 -               }
12875 +        if (!$count) {
12876 +            $count = 20;
12877 +        }
12878 hunk ./actions/twitapidirect_messages.php 55
12879 -               $message = new Message();
12880 +        $message = new Message();
12881 hunk ./actions/twitapidirect_messages.php 57
12882 -               $title = null;
12883 -               $subtitle = null;
12884 -               $link = null;
12885 -               $server = common_root_url();
12886 +        $title = null;
12887 +        $subtitle = null;
12888 +        $link = null;
12889 +        $server = common_root_url();
12890 hunk ./actions/twitapidirect_messages.php 62
12891 -               if ($type == 'received') {
12892 -                       $message->to_profile = $user->id;
12893 -                       $title = sprintf(_("Direct messages to %s"), $user->nickname);
12894 -                       $subtitle = sprintf(_("All the direct messages sent to %s"), $user->nickname);
12895 -                       $link = $server . $user->nickname . '/inbox';
12896 -               } else {
12897 -                       $message->from_profile = $user->id;
12898 -                       $title = _('Direct Messages You\'ve Sent');
12899 -                       $subtitle = sprintf(_("All the direct messages sent from %s"), $user->nickname);
12900 -                       $link = $server . $user->nickname . '/outbox';
12901 -               }
12902 +        if ($type == 'received') {
12903 +            $message->to_profile = $user->id;
12904 +            $title = sprintf(_("Direct messages to %s"), $user->nickname);
12905 +            $subtitle = sprintf(_("All the direct messages sent to %s"), $user->nickname);
12906 +            $link = $server . $user->nickname . '/inbox';
12907 +        } else {
12908 +            $message->from_profile = $user->id;
12909 +            $title = _('Direct Messages You\'ve Sent');
12910 +            $subtitle = sprintf(_("All the direct messages sent from %s"), $user->nickname);
12911 +            $link = $server . $user->nickname . '/outbox';
12912 +        }
12913 hunk ./actions/twitapidirect_messages.php 74
12914 -               if ($before_id) {
12915 -                       $message->whereAdd("id < $before_id");
12916 -               }
12917 +        if ($before_id) {
12918 +            $message->whereAdd("id < $before_id");
12919 +        }
12920 hunk ./actions/twitapidirect_messages.php 78
12921 -               if ($since_id) {
12922 -                       $message->whereAdd("id > $since_id");
12923 -               }
12924 +        if ($since_id) {
12925 +            $message->whereAdd("id > $since_id");
12926 +        }
12927 hunk ./actions/twitapidirect_messages.php 82
12928 -               $since = strtotime($this->arg('since'));
12929 +        $since = strtotime($this->arg('since'));
12930 hunk ./actions/twitapidirect_messages.php 84
12931 -               if ($since) {
12932 -                       $d = date('Y-m-d H:i:s', $since);
12933 -                       $message->whereAdd("created > '$d'");
12934 -               }
12935 +        if ($since) {
12936 +            $d = date('Y-m-d H:i:s', $since);
12937 +            $message->whereAdd("created > '$d'");
12938 +        }
12939 hunk ./actions/twitapidirect_messages.php 89
12940 -               $message->orderBy('created DESC, id DESC');
12941 -               $message->limit((($page-1)*20), $count);
12942 -               $message->find();
12943 +        $message->orderBy('created DESC, id DESC');
12944 +        $message->limit((($page-1)*20), $count);
12945 +        $message->find();
12946 hunk ./actions/twitapidirect_messages.php 93
12947 -               switch($apidata['content-type']) {
12948 -                case 'xml':
12949 -                       $this->show_xml_dmsgs($message);
12950 -                       break;
12951 -                case 'rss':
12952 -                       $this->show_rss_dmsgs($message, $title, $link, $subtitle);
12953 -                       break;
12954 -                case 'atom':
12955 -                       $this->show_atom_dmsgs($message, $title, $link, $subtitle);
12956 -                       break;
12957 -                case 'json':
12958 -                       $this->show_json_dmsgs($message);
12959 -                       break;
12960 -                default:
12961 -                       common_user_error(_('API method not found!'), $code = 404);
12962 -               }
12963 +        switch($apidata['content-type']) {
12964 +         case 'xml':
12965 +            $this->show_xml_dmsgs($message);
12966 +            break;
12967 +         case 'rss':
12968 +            $this->show_rss_dmsgs($message, $title, $link, $subtitle);
12969 +            break;
12970 +         case 'atom':
12971 +            $this->show_atom_dmsgs($message, $title, $link, $subtitle);
12972 +            break;
12973 +         case 'json':
12974 +            $this->show_json_dmsgs($message);
12975 +            break;
12976 +         default:
12977 +            common_user_error(_('API method not found!'), $code = 404);
12978 +        }
12979 hunk ./actions/twitapidirect_messages.php 110
12980 -       }
12981 +    }
12982 hunk ./actions/twitapidirect_messages.php 112
12983 -       // had to change this from "new" to "create" to avoid PHP reserved word
12984 -       function create($args, $apidata) {
12985 -               parent::handle($args);
12986 +    // had to change this from "new" to "create" to avoid PHP reserved word
12987 +    function create($args, $apidata) {
12988 +        parent::handle($args);
12989 hunk ./actions/twitapidirect_messages.php 116
12990 -               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
12991 -                       $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
12992 -                       return;
12993 -               }
12994 +        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
12995 +            $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
12996 +            return;
12997 +        }
12998 hunk ./actions/twitapidirect_messages.php 121
12999 -               $user = $apidata['user'];
13000 -               $source = $this->trimmed('source');      // Not supported by Twitter.
13001 +        $user = $apidata['user'];
13002 +        $source = $this->trimmed('source');     // Not supported by Twitter.
13003 hunk ./actions/twitapidirect_messages.php 125
13004 -               if (!$source || in_array($source, $reserved_sources)) {
13005 -                       $source = 'api';
13006 -               }
13007 +        if (!$source || in_array($source, $reserved_sources)) {
13008 +            $source = 'api';
13009 +        }
13010 hunk ./actions/twitapidirect_messages.php 129
13011 -               $content = $this->trimmed('text');
13012 +        $content = $this->trimmed('text');
13013 hunk ./actions/twitapidirect_messages.php 131
13014 -               if (!$content) {
13015 -                       $this->client_error(_('No message text!'), $code = 406, $apidata['content-type']);
13016 -               } else {
13017 -                       $content_shortened = common_shorten_links($content);
13018 -                       if (mb_strlen($content_shortened) > 140) {
13019 -                               $this->client_error(_('That\'s too long. Max message size is 140 chars.'),
13020 -                                       $code = 406, $apidata['content-type']);
13021 -                               return;
13022 -                       }
13023 -               }
13024 +        if (!$content) {
13025 +            $this->client_error(_('No message text!'), $code = 406, $apidata['content-type']);
13026 +        } else {
13027 +            $content_shortened = common_shorten_links($content);
13028 +            if (mb_strlen($content_shortened) > 140) {
13029 +                $this->client_error(_('That\'s too long. Max message size is 140 chars.'),
13030 +                    $code = 406, $apidata['content-type']);
13031 +                return;
13032 +            }
13033 +        }
13034 hunk ./actions/twitapidirect_messages.php 142
13035 -               $other = $this->get_user($this->trimmed('user'));
13036 +        $other = $this->get_user($this->trimmed('user'));
13037 hunk ./actions/twitapidirect_messages.php 144
13038 -               if (!$other) {
13039 -                       $this->client_error(_('Recipient user not found.'), $code = 403, $apidata['content-type']);
13040 -                       return;
13041 -               } else if (!$user->mutuallySubscribed($other)) {
13042 -                       $this->client_error(_('Can\'t send direct messages to users who aren\'t your friend.'),
13043 -                               $code = 403, $apidata['content-type']);
13044 -                       return;
13045 -               } else if ($user->id == $other->id) {
13046 -                       // Sending msgs to yourself is allowed by Twitter
13047 -                       $this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'),
13048 -                               $code = 403, $apidata['content-type']);
13049 -                       return;
13050 -               }
13051 +        if (!$other) {
13052 +            $this->client_error(_('Recipient user not found.'), $code = 403, $apidata['content-type']);
13053 +            return;
13054 +        } else if (!$user->mutuallySubscribed($other)) {
13055 +            $this->client_error(_('Can\'t send direct messages to users who aren\'t your friend.'),
13056 +                $code = 403, $apidata['content-type']);
13057 +            return;
13058 +        } else if ($user->id == $other->id) {
13059 +            // Sending msgs to yourself is allowed by Twitter
13060 +            $this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'),
13061 +                $code = 403, $apidata['content-type']);
13062 +            return;
13063 +        }
13064 hunk ./actions/twitapidirect_messages.php 158
13065 -               $message = Message::saveNew($user->id, $other->id,
13066 -                       html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source);
13067 +        $message = Message::saveNew($user->id, $other->id,
13068 +            html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source);
13069 hunk ./actions/twitapidirect_messages.php 161
13070 -               if (is_string($message)) {
13071 -                       $this->server_error($message);
13072 -                       return;
13073 -               }
13074 +        if (is_string($message)) {
13075 +            $this->server_error($message);
13076 +            return;
13077 +        }
13078 hunk ./actions/twitapidirect_messages.php 166
13079 -               $this->notify($user, $other, $message);
13080 +        $this->notify($user, $other, $message);
13081 hunk ./actions/twitapidirect_messages.php 168
13082 -               if ($apidata['content-type'] == 'xml') {
13083 -                       $this->show_single_xml_dmsg($message);
13084 -               } elseif ($apidata['content-type'] == 'json') {
13085 -                       $this->show_single_json_dmsg($message);
13086 -               }
13087 +        if ($apidata['content-type'] == 'xml') {
13088 +            $this->show_single_xml_dmsg($message);
13089 +        } elseif ($apidata['content-type'] == 'json') {
13090 +            $this->show_single_json_dmsg($message);
13091 +        }
13092 hunk ./actions/twitapidirect_messages.php 174
13093 -       }
13094 +    }
13095 hunk ./actions/twitapidirect_messages.php 176
13096 -       function destroy($args, $apidata) {
13097 -               parent::handle($args);
13098 -               common_server_error(_('API method under construction.'), $code=501);
13099 -       }
13100 +    function destroy($args, $apidata) {
13101 +        parent::handle($args);
13102 +        common_server_error(_('API method under construction.'), $code=501);
13103 +    }
13104 hunk ./actions/twitapidirect_messages.php 181
13105 -       function show_xml_dmsgs($message) {
13106 +    function show_xml_dmsgs($message) {
13107 hunk ./actions/twitapidirect_messages.php 183
13108 -               $this->init_document('xml');
13109 -               common_element_start('direct-messages', array('type' => 'array'));
13110 +        $this->init_document('xml');
13111 +        common_element_start('direct-messages', array('type' => 'array'));
13112 hunk ./actions/twitapidirect_messages.php 186
13113 -               if (is_array($messages)) {
13114 -                       foreach ($message as $m) {
13115 -                               $twitter_dm = $this->twitter_dmsg_array($m);
13116 -                               $this->show_twitter_xml_dmsg($twitter_dm);
13117 -                       }
13118 -               } else {
13119 -                       while ($message->fetch()) {
13120 -                               $twitter_dm = $this->twitter_dmsg_array($message);
13121 -                               $this->show_twitter_xml_dmsg($twitter_dm);
13122 -                       }
13123 -               }
13124 +        if (is_array($messages)) {
13125 +            foreach ($message as $m) {
13126 +                $twitter_dm = $this->twitter_dmsg_array($m);
13127 +                $this->show_twitter_xml_dmsg($twitter_dm);
13128 +            }
13129 +        } else {
13130 +            while ($message->fetch()) {
13131 +                $twitter_dm = $this->twitter_dmsg_array($message);
13132 +                $this->show_twitter_xml_dmsg($twitter_dm);
13133 +            }
13134 +        }
13135 hunk ./actions/twitapidirect_messages.php 198
13136 -               common_element_end('direct-messages');
13137 -               $this->end_document('xml');
13138 +        common_element_end('direct-messages');
13139 +        $this->end_document('xml');
13140 hunk ./actions/twitapidirect_messages.php 201
13141 -       }
13142 +    }
13143 hunk ./actions/twitapidirect_messages.php 203
13144 -       function show_json_dmsgs($message) {
13145 +    function show_json_dmsgs($message) {
13146 hunk ./actions/twitapidirect_messages.php 205
13147 -               $this->init_document('json');
13148 +        $this->init_document('json');
13149 hunk ./actions/twitapidirect_messages.php 207
13150 -               $dmsgs = array();
13151 +        $dmsgs = array();
13152 hunk ./actions/twitapidirect_messages.php 209
13153 -               if (is_array($message)) {
13154 -                       foreach ($message as $m) {
13155 -                               $twitter_dm = $this->twitter_dmsg_array($m);
13156 -                               array_push($dmsgs, $twitter_dm);
13157 -                       }
13158 -               } else {
13159 -                       while ($message->fetch()) {
13160 -                               $twitter_dm = $this->twitter_dmsg_array($message);
13161 -                               array_push($dmsgs, $twitter_dm);
13162 -                       }
13163 -               }
13164 +        if (is_array($message)) {
13165 +            foreach ($message as $m) {
13166 +                $twitter_dm = $this->twitter_dmsg_array($m);
13167 +                array_push($dmsgs, $twitter_dm);
13168 +            }
13169 +        } else {
13170 +            while ($message->fetch()) {
13171 +                $twitter_dm = $this->twitter_dmsg_array($message);
13172 +                array_push($dmsgs, $twitter_dm);
13173 +            }
13174 +        }
13175 hunk ./actions/twitapidirect_messages.php 221
13176 -               $this->show_json_objects($dmsgs);
13177 -               $this->end_document('json');
13178 +        $this->show_json_objects($dmsgs);
13179 +        $this->end_document('json');
13180 hunk ./actions/twitapidirect_messages.php 224
13181 -       }
13182 +    }
13183 hunk ./actions/twitapidirect_messages.php 226
13184 -       function show_rss_dmsgs($message, $title, $link, $subtitle) {
13185 +    function show_rss_dmsgs($message, $title, $link, $subtitle) {
13186 hunk ./actions/twitapidirect_messages.php 228
13187 -               $this->init_document('rss');
13188 +        $this->init_document('rss');
13189 hunk ./actions/twitapidirect_messages.php 230
13190 -               common_element_start('channel');
13191 -               common_element('title', NULL, $title);
13192 +        common_element_start('channel');
13193 +        common_element('title', NULL, $title);
13194 hunk ./actions/twitapidirect_messages.php 233
13195 -               common_element('link', NULL, $link);
13196 -               common_element('description', NULL, $subtitle);
13197 -               common_element('language', NULL, 'en-us');
13198 -               common_element('ttl', NULL, '40');
13199 +        common_element('link', NULL, $link);
13200 +        common_element('description', NULL, $subtitle);
13201 +        common_element('language', NULL, 'en-us');
13202 +        common_element('ttl', NULL, '40');
13203 hunk ./actions/twitapidirect_messages.php 238
13204 -               if (is_array($message)) {
13205 -                       foreach ($message as $m) {
13206 -                               $entry = $this->twitter_rss_dmsg_array($m);
13207 -                               $this->show_twitter_rss_item($entry);
13208 -                       }
13209 -               } else {
13210 -                       while ($message->fetch()) {
13211 -                               $entry = $this->twitter_rss_dmsg_array($message);
13212 -                               $this->show_twitter_rss_item($entry);
13213 -                       }
13214 -               }
13215 +        if (is_array($message)) {
13216 +            foreach ($message as $m) {
13217 +                $entry = $this->twitter_rss_dmsg_array($m);
13218 +                $this->show_twitter_rss_item($entry);
13219 +            }
13220 +        } else {
13221 +            while ($message->fetch()) {
13222 +                $entry = $this->twitter_rss_dmsg_array($message);
13223 +                $this->show_twitter_rss_item($entry);
13224 +            }
13225 +        }
13226 hunk ./actions/twitapidirect_messages.php 250
13227 -               common_element_end('channel');
13228 -               $this->end_twitter_rss();
13229 +        common_element_end('channel');
13230 +        $this->end_twitter_rss();
13231 hunk ./actions/twitapidirect_messages.php 253
13232 -       }
13233 +    }
13234 hunk ./actions/twitapidirect_messages.php 255
13235 -       function show_atom_dmsgs($message, $title, $link, $subtitle) {
13236 +    function show_atom_dmsgs($message, $title, $link, $subtitle) {
13237 hunk ./actions/twitapidirect_messages.php 257
13238 -               $this->init_document('atom');
13239 +        $this->init_document('atom');
13240 hunk ./actions/twitapidirect_messages.php 259
13241 -               common_element('title', NULL, $title);
13242 -               $siteserver = common_config('site', 'server');
13243 -               common_element('id', NULL, "tag:$siteserver,2008:DirectMessage");
13244 -               common_element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), NULL);
13245 -               common_element('updated', NULL, common_date_iso8601(strftime('%c')));
13246 -               common_element('subtitle', NULL, $subtitle);
13247 +        common_element('title', NULL, $title);
13248 +        $siteserver = common_config('site', 'server');
13249 +        common_element('id', NULL, "tag:$siteserver,2008:DirectMessage");
13250 +        common_element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), NULL);
13251 +        common_element('updated', NULL, common_date_iso8601(strftime('%c')));
13252 +        common_element('subtitle', NULL, $subtitle);
13253 hunk ./actions/twitapidirect_messages.php 266
13254 -               if (is_array($message)) {
13255 -                       foreach ($message as $m) {
13256 -                               $entry = $this->twitter_rss_dmsg_array($m);
13257 -                               $this->show_twitter_atom_entry($entry);
13258 -                       }
13259 -               } else {
13260 -                       while ($message->fetch()) {
13261 -                               $entry = $this->twitter_rss_dmsg_array($message);
13262 -                               $this->show_twitter_atom_entry($entry);
13263 -                       }
13264 -               }
13265 +        if (is_array($message)) {
13266 +            foreach ($message as $m) {
13267 +                $entry = $this->twitter_rss_dmsg_array($m);
13268 +                $this->show_twitter_atom_entry($entry);
13269 +            }
13270 +        } else {
13271 +            while ($message->fetch()) {
13272 +                $entry = $this->twitter_rss_dmsg_array($message);
13273 +                $this->show_twitter_atom_entry($entry);
13274 +            }
13275 +        }
13276 hunk ./actions/twitapidirect_messages.php 278
13277 -               $this->end_document('atom');
13278 -       }
13279 +        $this->end_document('atom');
13280 +    }
13281 hunk ./actions/twitapidirect_messages.php 281
13282 -       // swiped from MessageAction. Should it be place in util.php?
13283 -       function notify($from, $to, $message) {
13284 -               mail_notify_message($message, $from, $to);
13285 -               # XXX: Jabber, SMS notifications... probably queued
13286 -       }
13287 +    // swiped from MessageAction. Should it be place in util.php?
13288 +    function notify($from, $to, $message) {
13289 +        mail_notify_message($message, $from, $to);
13290 +        # XXX: Jabber, SMS notifications... probably queued
13291 +    }
13292 hunk ./actions/twitapifavorites.php 26
13293 -       function favorites($args, $apidata) {
13294 -               parent::handle($args);
13295 +    function favorites($args, $apidata) {
13296 +        parent::handle($args);
13297 hunk ./actions/twitapifavorites.php 29
13298 -               $this->auth_user = $apidata['user'];
13299 -               $user = $this->get_user($apidata['api_arg'], $apidata);
13300 +        $this->auth_user = $apidata['user'];
13301 +        $user = $this->get_user($apidata['api_arg'], $apidata);
13302 hunk ./actions/twitapifavorites.php 32
13303 -               if (!$user) {
13304 -                       $this->client_error('Not Found', 404, $apidata['content-type']);
13305 -                       return;
13306 -               }
13307 +        if (!$user) {
13308 +            $this->client_error('Not Found', 404, $apidata['content-type']);
13309 +            return;
13310 +        }
13311 hunk ./actions/twitapifavorites.php 37
13312 -               $profile = $user->getProfile();
13313 +        $profile = $user->getProfile();
13314 hunk ./actions/twitapifavorites.php 39
13315 -               if (!$profile) {
13316 -                       common_server_error(_('User has no profile.'));
13317 -                       return;
13318 -               }
13319 +        if (!$profile) {
13320 +            common_server_error(_('User has no profile.'));
13321 +            return;
13322 +        }
13323 hunk ./actions/twitapifavorites.php 44
13324 -               $page = $this->arg('page');
13325 +        $page = $this->arg('page');
13326 hunk ./actions/twitapifavorites.php 46
13327 -               if (!$page) {
13328 -                       $page = 1;
13329 -               }
13330 +        if (!$page) {
13331 +            $page = 1;
13332 +        }
13333 hunk ./actions/twitapifavorites.php 50
13334 -               if (!$count) {
13335 -                       $count = 20;
13336 -               }
13337 +        if (!$count) {
13338 +            $count = 20;
13339 +        }
13340 hunk ./actions/twitapifavorites.php 54
13341 -               $notice = $user->favoriteNotices((($page-1)*20), $count);
13342 +        $notice = $user->favoriteNotices((($page-1)*20), $count);
13343 hunk ./actions/twitapifavorites.php 56
13344 -               if (!$notice) {
13345 -                       common_server_error(_('Could not retrieve favorite notices.'));
13346 -                       return;
13347 -               }
13348 +        if (!$notice) {
13349 +            common_server_error(_('Could not retrieve favorite notices.'));
13350 +            return;
13351 +        }
13352 hunk ./actions/twitapifavorites.php 61
13353 -               $sitename = common_config('site', 'name');
13354 -               $siteserver = common_config('site', 'server');
13355 +        $sitename = common_config('site', 'name');
13356 +        $siteserver = common_config('site', 'server');
13357 hunk ./actions/twitapifavorites.php 64
13358 -               $title = sprintf(_('%s / Favorites from %s'), $sitename, $user->nickname);
13359 -               $id = "tag:$siteserver:favorites:".$user->id;
13360 -               $link = common_local_url('favorites', array('nickname' => $user->nickname));
13361 -               $subtitle = sprintf(_('%s updates favorited by %s / %s.'), $sitename, $profile->getBestName(), $user->nickname);
13362 +        $title = sprintf(_('%s / Favorites from %s'), $sitename, $user->nickname);
13363 +        $id = "tag:$siteserver:favorites:".$user->id;
13364 +        $link = common_local_url('favorites', array('nickname' => $user->nickname));
13365 +        $subtitle = sprintf(_('%s updates favorited by %s / %s.'), $sitename, $profile->getBestName(), $user->nickname);
13366 hunk ./actions/twitapifavorites.php 69
13367 -               switch($apidata['content-type']) {
13368 -                case 'xml':
13369 -                       $this->show_xml_timeline($notice);
13370 -                       break;
13371 -                case 'rss':
13372 -                       $this->show_rss_timeline($notice, $title, $link, $subtitle);
13373 -                       break;
13374 -                case 'atom':
13375 -                       $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
13376 -                       break;
13377 -                case 'json':
13378 -                       $this->show_json_timeline($notice);
13379 -                       break;
13380 -                default:
13381 -                       common_user_error(_('API method not found!'), $code = 404);
13382 -               }
13383 +        switch($apidata['content-type']) {
13384 +         case 'xml':
13385 +            $this->show_xml_timeline($notice);
13386 +            break;
13387 +         case 'rss':
13388 +            $this->show_rss_timeline($notice, $title, $link, $subtitle);
13389 +            break;
13390 +         case 'atom':
13391 +            $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
13392 +            break;
13393 +         case 'json':
13394 +            $this->show_json_timeline($notice);
13395 +            break;
13396 +         default:
13397 +            common_user_error(_('API method not found!'), $code = 404);
13398 +        }
13399 hunk ./actions/twitapifavorites.php 86
13400 -       }
13401 +    }
13402 hunk ./actions/twitapifavorites.php 88
13403 -       function create($args, $apidata) {
13404 -               parent::handle($args);
13405 +    function create($args, $apidata) {
13406 +        parent::handle($args);
13407 hunk ./actions/twitapifavorites.php 91
13408 -               // Check for RESTfulness
13409 -               if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
13410 -                       // XXX: Twitter just prints the err msg, no XML / JSON.
13411 -                       $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
13412 -                       return;
13413 -               }
13414 +        // Check for RESTfulness
13415 +        if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
13416 +            // XXX: Twitter just prints the err msg, no XML / JSON.
13417 +            $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
13418 +            return;
13419 +        }
13420 hunk ./actions/twitapifavorites.php 98
13421 -               if (!in_array($apidata['content-type'], array('xml', 'json'))) {
13422 -                       common_user_error(_('API method not found!'), $code = 404);
13423 -                       return;
13424 -               }
13425 +        if (!in_array($apidata['content-type'], array('xml', 'json'))) {
13426 +            common_user_error(_('API method not found!'), $code = 404);
13427 +            return;
13428 +        }
13429 hunk ./actions/twitapifavorites.php 103
13430 -               $this->auth_user = $apidata['user'];
13431 -               $user = $this->auth_user;
13432 -               $notice_id = $apidata['api_arg'];
13433 -               $notice = Notice::staticGet($notice_id);
13434 +        $this->auth_user = $apidata['user'];
13435 +        $user = $this->auth_user;
13436 +        $notice_id = $apidata['api_arg'];
13437 +        $notice = Notice::staticGet($notice_id);
13438 hunk ./actions/twitapifavorites.php 108
13439 -               if (!$notice) {
13440 -                       $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
13441 -                       return;
13442 -               }
13443 +        if (!$notice) {
13444 +            $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
13445 +            return;
13446 +        }
13447 hunk ./actions/twitapifavorites.php 113
13448 -               // XXX: Twitter lets you fave things repeatedly via api.
13449 -               if ($user->hasFave($notice)) {
13450 -                       $this->client_error(_('This notice is already a favorite!'), 403, $apidata['content-type']);
13451 -                       return;
13452 -               }
13453 +        // XXX: Twitter lets you fave things repeatedly via api.
13454 +        if ($user->hasFave($notice)) {
13455 +            $this->client_error(_('This notice is already a favorite!'), 403, $apidata['content-type']);
13456 +            return;
13457 +        }
13458 hunk ./actions/twitapifavorites.php 119
13459 -               $fave = Fave::addNew($user, $notice);
13460 +        $fave = Fave::addNew($user, $notice);
13461 hunk ./actions/twitapifavorites.php 121
13462 -               if (!$fave) {
13463 -                       common_server_error(_('Could not create favorite.'));
13464 -                       return;
13465 -               }
13466 +        if (!$fave) {
13467 +            common_server_error(_('Could not create favorite.'));
13468 +            return;
13469 +        }
13470 hunk ./actions/twitapifavorites.php 126
13471 -               $this->notify($fave, $notice, $user);
13472 -               $user->blowFavesCache();
13473 +        $this->notify($fave, $notice, $user);
13474 +        $user->blowFavesCache();
13475 hunk ./actions/twitapifavorites.php 129
13476 -               if ($apidata['content-type'] == 'xml') {
13477 -                       $this->show_single_xml_status($notice);
13478 -               } elseif ($apidata['content-type'] == 'json') {
13479 -                       $this->show_single_json_status($notice);
13480 -               }
13481 +        if ($apidata['content-type'] == 'xml') {
13482 +            $this->show_single_xml_status($notice);
13483 +        } elseif ($apidata['content-type'] == 'json') {
13484 +            $this->show_single_json_status($notice);
13485 +        }
13486 hunk ./actions/twitapifavorites.php 135
13487 -       }
13488 +    }
13489 hunk ./actions/twitapifavorites.php 137
13490 -       function destroy($args, $apidata) {
13491 -               parent::handle($args);
13492 -               common_server_error(_('API method under construction.'), $code=501);
13493 -       }
13494 +    function destroy($args, $apidata) {
13495 +        parent::handle($args);
13496 +        common_server_error(_('API method under construction.'), $code=501);
13497 +    }
13498 hunk ./actions/twitapifavorites.php 142
13499 -       // XXX: these two funcs swiped from faves.  Maybe put in util.php, or some common base class?
13500 +    // XXX: these two funcs swiped from faves.  Maybe put in util.php, or some common base class?
13501 hunk ./actions/twitapifavorites.php 144
13502 -       function notify($fave, $notice, $user) {
13503 -           $other = User::staticGet('id', $notice->profile_id);
13504 -               if ($other && $other->id != $user->id) {
13505 -                       if ($other->email && $other->emailnotifyfav) {
13506 -                               $this->notify_mail($other, $user, $notice);
13507 -                       }
13508 -                       # XXX: notify by IM
13509 -                       # XXX: notify by SMS
13510 -               }
13511 -       }
13512 +    function notify($fave, $notice, $user) {
13513 +        $other = User::staticGet('id', $notice->profile_id);
13514 +        if ($other && $other->id != $user->id) {
13515 +            if ($other->email && $other->emailnotifyfav) {
13516 +                $this->notify_mail($other, $user, $notice);
13517 +            }
13518 +            # XXX: notify by IM
13519 +            # XXX: notify by SMS
13520 +        }
13521 +    }
13522 hunk ./actions/twitapifavorites.php 155
13523 -       function notify_mail($other, $user, $notice) {
13524 -               $profile = $user->getProfile();
13525 -               $bestname = $profile->getBestName();
13526 -               $subject = sprintf(_('%s added your notice as a favorite'), $bestname);
13527 -               $body = sprintf(_("%1\$s just added your notice from %2\$s as one of their favorites.\n\n" .
13528 -                                                 "In case you forgot, you can see the text of your notice here:\n\n" .
13529 -                                                 "%3\$s\n\n" .
13530 -                                                 "You can see the list of %1\$s's favorites here:\n\n" .
13531 -                                                 "%4\$s\n\n" .
13532 -                                                 "Faithfully yours,\n" .
13533 -                                                 "%5\$s\n"),
13534 -                                               $bestname,
13535 -                                               common_exact_date($notice->created),
13536 -                                               common_local_url('shownotice', array('notice' => $notice->id)),
13537 -                                               common_local_url('showfavorites', array('nickname' => $user->nickname)),
13538 -                                               common_config('site', 'name'));
13539 +    function notify_mail($other, $user, $notice) {
13540 +        $profile = $user->getProfile();
13541 +        $bestname = $profile->getBestName();
13542 +        $subject = sprintf(_('%s added your notice as a favorite'), $bestname);
13543 +        $body = sprintf(_("%1\$s just added your notice from %2\$s as one of their favorites.\n\n" .
13544 +                          "In case you forgot, you can see the text of your notice here:\n\n" .
13545 +                          "%3\$s\n\n" .
13546 +                          "You can see the list of %1\$s's favorites here:\n\n" .
13547 +                          "%4\$s\n\n" .
13548 +                          "Faithfully yours,\n" .
13549 +                          "%5\$s\n"),
13550 +                        $bestname,
13551 +                        common_exact_date($notice->created),
13552 +                        common_local_url('shownotice', array('notice' => $notice->id)),
13553 +                        common_local_url('showfavorites', array('nickname' => $user->nickname)),
13554 +                        common_config('site', 'name'));
13555 hunk ./actions/twitapifavorites.php 172
13556 -               mail_to_user($other, $subject, $body);
13557 -       }
13558 +        mail_to_user($other, $subject, $body);
13559 +    }
13560 hunk ./actions/twitapifriendships.php 26
13561 -       function create($args, $apidata) {
13562 -               parent::handle($args);
13563 +    function create($args, $apidata) {
13564 +        parent::handle($args);
13565 hunk ./actions/twitapifriendships.php 29
13566 -               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
13567 -                       $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
13568 -                       return;
13569 -               }
13570 +        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
13571 +            $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
13572 +            return;
13573 +        }
13574 hunk ./actions/twitapifriendships.php 34
13575 -               $id = $apidata['api_arg'];
13576 +        $id = $apidata['api_arg'];
13577 hunk ./actions/twitapifriendships.php 36
13578 -               $other = $this->get_user($id);
13579 +        $other = $this->get_user($id);
13580 hunk ./actions/twitapifriendships.php 38
13581 -               if (!$other) {
13582 -                       $this->client_error(_('Could not follow user: User not found.'), 403, $apidata['content-type']);
13583 -                       return;
13584 -               }
13585 +        if (!$other) {
13586 +            $this->client_error(_('Could not follow user: User not found.'), 403, $apidata['content-type']);
13587 +            return;
13588 +        }
13589 hunk ./actions/twitapifriendships.php 43
13590 -               $user = $apidata['user'];
13591 +        $user = $apidata['user'];
13592 hunk ./actions/twitapifriendships.php 45
13593 -               if ($user->isSubscribed($other)) {
13594 -                       $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
13595 -                       $this->client_error($errmsg, 403, $apidata['content-type']);
13596 -                       return;
13597 -               }
13598 +        if ($user->isSubscribed($other)) {
13599 +            $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
13600 +            $this->client_error($errmsg, 403, $apidata['content-type']);
13601 +            return;
13602 +        }
13603 hunk ./actions/twitapifriendships.php 51
13604 -               $sub = new Subscription();
13605 +        $sub = new Subscription();
13606 hunk ./actions/twitapifriendships.php 53
13607 -               $sub->query('BEGIN');
13608 +        $sub->query('BEGIN');
13609 hunk ./actions/twitapifriendships.php 55
13610 -               $sub->subscriber = $user->id;
13611 -               $sub->subscribed = $other->id;
13612 -               $sub->created = DB_DataObject_Cast::dateTime(); # current time
13613 +        $sub->subscriber = $user->id;
13614 +        $sub->subscribed = $other->id;
13615 +        $sub->created = DB_DataObject_Cast::dateTime(); # current time
13616 hunk ./actions/twitapifriendships.php 59
13617 -               $result = $sub->insert();
13618 +        $result = $sub->insert();
13619 hunk ./actions/twitapifriendships.php 61
13620 -               if (!$result) {
13621 -                       $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
13622 -                       $this->client_error($errmsg, 400, $apidata['content-type']);
13623 -                       return;
13624 -               }
13625 +        if (!$result) {
13626 +            $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname);
13627 +            $this->client_error($errmsg, 400, $apidata['content-type']);
13628 +            return;
13629 +        }
13630 hunk ./actions/twitapifriendships.php 67
13631 -               $sub->query('COMMIT');
13632 +        $sub->query('COMMIT');
13633 hunk ./actions/twitapifriendships.php 69
13634 -               mail_subscribe_notify($other, $user);
13635 +        mail_subscribe_notify($other, $user);
13636 hunk ./actions/twitapifriendships.php 71
13637 -               $type = $apidata['content-type'];
13638 -               $this->init_document($type);
13639 -               $this->show_profile($other, $type);
13640 -               $this->end_document($type);
13641 +        $type = $apidata['content-type'];
13642 +        $this->init_document($type);
13643 +        $this->show_profile($other, $type);
13644 +        $this->end_document($type);
13645 hunk ./actions/twitapifriendships.php 76
13646 -       }
13647 +    }
13648 hunk ./actions/twitapifriendships.php 78
13649 -       function destroy($args, $apidata) {
13650 -               parent::handle($args);
13651 +    function destroy($args, $apidata) {
13652 +        parent::handle($args);
13653 hunk ./actions/twitapifriendships.php 81
13654 -               if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
13655 -                       $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
13656 -                       return;
13657 -               }
13658 +        if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
13659 +            $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
13660 +            return;
13661 +        }
13662 hunk ./actions/twitapifriendships.php 86
13663 -               $id = $apidata['api_arg'];
13664 +        $id = $apidata['api_arg'];
13665 hunk ./actions/twitapifriendships.php 88
13666 -               # We can't subscribe to a remote person, but we can unsub
13667 +        # We can't subscribe to a remote person, but we can unsub
13668 hunk ./actions/twitapifriendships.php 90
13669 -               $other = $this->get_profile($id);
13670 -               $user = $apidata['user'];
13671 +        $other = $this->get_profile($id);
13672 +        $user = $apidata['user'];
13673 hunk ./actions/twitapifriendships.php 93
13674 -               $sub = new Subscription();
13675 -               $sub->subscriber = $user->id;
13676 -               $sub->subscribed = $other->id;
13677 +        $sub = new Subscription();
13678 +        $sub->subscriber = $user->id;
13679 +        $sub->subscribed = $other->id;
13680 hunk ./actions/twitapifriendships.php 97
13681 -               if ($sub->find(TRUE)) {
13682 -                       $sub->query('BEGIN');
13683 -                       $sub->delete();
13684 -                       $sub->query('COMMIT');
13685 -               } else {
13686 -                       $this->client_error(_('You are not friends with the specified user.'), 403, $apidata['content-type']);
13687 -                       return;
13688 -               }
13689 +        if ($sub->find(TRUE)) {
13690 +            $sub->query('BEGIN');
13691 +            $sub->delete();
13692 +            $sub->query('COMMIT');
13693 +        } else {
13694 +            $this->client_error(_('You are not friends with the specified user.'), 403, $apidata['content-type']);
13695 +            return;
13696 +        }
13697 hunk ./actions/twitapifriendships.php 106
13698 -               $type = $apidata['content-type'];
13699 -               $this->init_document($type);
13700 -               $this->show_profile($other, $type);
13701 -               $this->end_document($type);
13702 +        $type = $apidata['content-type'];
13703 +        $this->init_document($type);
13704 +        $this->show_profile($other, $type);
13705 +        $this->end_document($type);
13706 hunk ./actions/twitapifriendships.php 111
13707 -       }
13708 +    }
13709 hunk ./actions/twitapifriendships.php 113
13710 -       function exists($args, $apidata) {
13711 -               parent::handle($args);
13712 +    function exists($args, $apidata) {
13713 +        parent::handle($args);
13714 hunk ./actions/twitapifriendships.php 116
13715 -               if (!in_array($apidata['content-type'], array('xml', 'json'))) {
13716 -                       common_user_error(_('API method not found!'), $code = 404);
13717 -                       return;
13718 -               }
13719 +        if (!in_array($apidata['content-type'], array('xml', 'json'))) {
13720 +            common_user_error(_('API method not found!'), $code = 404);
13721 +            return;
13722 +        }
13723 hunk ./actions/twitapifriendships.php 121
13724 -               $user_a_id = $this->trimmed('user_a');
13725 -               $user_b_id = $this->trimmed('user_b');
13726 +        $user_a_id = $this->trimmed('user_a');
13727 +        $user_b_id = $this->trimmed('user_b');
13728 hunk ./actions/twitapifriendships.php 124
13729 -               $user_a = $this->get_user($user_a_id);
13730 -               $user_b = $this->get_user($user_b_id);
13731 +        $user_a = $this->get_user($user_a_id);
13732 +        $user_b = $this->get_user($user_b_id);
13733 hunk ./actions/twitapifriendships.php 127
13734 -               if (!$user_a || !$user_b) {
13735 -                       $this->client_error(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']);
13736 -                       return;
13737 -               }
13738 +        if (!$user_a || !$user_b) {
13739 +            $this->client_error(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']);
13740 +            return;
13741 +        }
13742 hunk ./actions/twitapifriendships.php 132
13743 -               if ($user_a->isSubscribed($user_b)) {
13744 -                       $result = 'true';
13745 -               } else {
13746 -                       $result = 'false';
13747 -               }
13748 +        if ($user_a->isSubscribed($user_b)) {
13749 +            $result = 'true';
13750 +        } else {
13751 +            $result = 'false';
13752 +        }
13753 hunk ./actions/twitapifriendships.php 138
13754 -               switch ($apidata['content-type']) {
13755 -                case 'xml':
13756 -                       $this->init_document('xml');
13757 -                       common_element('friends', NULL, $result);
13758 -                       $this->end_document('xml');
13759 -                       break;
13760 -                case 'json':
13761 -                       $this->init_document('json');
13762 -                       print json_encode($result);
13763 -                       $this->end_document('json');
13764 -                       break;
13765 -                default:
13766 -                       break;
13767 -               }
13768 +        switch ($apidata['content-type']) {
13769 +         case 'xml':
13770 +            $this->init_document('xml');
13771 +            common_element('friends', NULL, $result);
13772 +            $this->end_document('xml');
13773 +            break;
13774 +         case 'json':
13775 +            $this->init_document('json');
13776 +            print json_encode($result);
13777 +            $this->end_document('json');
13778 +            break;
13779 +         default:
13780 +            break;
13781 +        }
13782 hunk ./actions/twitapifriendships.php 153
13783 -       }
13784 +    }
13785 hunk ./actions/twitapihelp.php 26
13786 -       /* Returns the string "ok" in the requested format with a 200 OK HTTP status code.
13787 -        * URL:http://identi.ca/api/help/test.format
13788 -        * Formats: xml, json
13789 -        */
13790 -       function test($args, $apidata) {
13791 -               parent::handle($args);
13792 +    /* Returns the string "ok" in the requested format with a 200 OK HTTP status code.
13793 +     * URL:http://identi.ca/api/help/test.format
13794 +     * Formats: xml, json
13795 +     */
13796 +    function test($args, $apidata) {
13797 +        parent::handle($args);
13798 hunk ./actions/twitapihelp.php 33
13799 -               if ($apidata['content-type'] == 'xml') {
13800 -                       $this->init_document('xml');
13801 -                       common_element('ok', NULL, 'true');
13802 -                       $this->end_document('xml');
13803 -               } elseif ($apidata['content-type'] == 'json') {
13804 -                       $this->init_document('json');
13805 -                       print '"ok"';
13806 -                       $this->end_document('json');
13807 -               } else {
13808 -                       common_user_error(_('API method not found!'), $code=404);
13809 -               }
13810 +        if ($apidata['content-type'] == 'xml') {
13811 +            $this->init_document('xml');
13812 +            common_element('ok', NULL, 'true');
13813 +            $this->end_document('xml');
13814 +        } elseif ($apidata['content-type'] == 'json') {
13815 +            $this->init_document('json');
13816 +            print '"ok"';
13817 +            $this->end_document('json');
13818 +        } else {
13819 +            common_user_error(_('API method not found!'), $code=404);
13820 +        }
13821 hunk ./actions/twitapihelp.php 45
13822 -       }
13823 +    }
13824 hunk ./actions/twitapihelp.php 47
13825 -       function downtime_schedule($args, $apidata) {
13826 -               parent::handle($args);
13827 -               common_server_error(_('API method under construction.'), $code=501);
13828 -       }
13829 +    function downtime_schedule($args, $apidata) {
13830 +        parent::handle($args);
13831 +        common_server_error(_('API method under construction.'), $code=501);
13832 +    }
13833 hunk ./actions/twitapinotifications.php 27
13834 -       function follow($args, $apidata) {
13835 -               parent::handle($args);
13836 -               common_server_error(_('API method under construction.'), $code=501);
13837 -       }
13838 +    function follow($args, $apidata) {
13839 +        parent::handle($args);
13840 +        common_server_error(_('API method under construction.'), $code=501);
13841 +    }
13842 hunk ./actions/twitapinotifications.php 32
13843 -       function leave($args, $apidata) {
13844 -               parent::handle($args);
13845 -               common_server_error(_('API method under construction.'), $code=501);
13846 -       }
13847 +    function leave($args, $apidata) {
13848 +        parent::handle($args);
13849 +        common_server_error(_('API method under construction.'), $code=501);
13850 +    }
13851 hunk ./actions/twitapistatuses.php 26
13852 -       function public_timeline($args, $apidata) {
13853 -               parent::handle($args);
13854 +    function public_timeline($args, $apidata) {
13855 +        parent::handle($args);
13856 hunk ./actions/twitapistatuses.php 29
13857 -               $sitename = common_config('site', 'name');
13858 -               $siteserver = common_config('site', 'server');
13859 -               $title = sprintf(_("%s public timeline"), $sitename);
13860 -               $id = "tag:$siteserver:Statuses";
13861 -               $link = common_root_url();
13862 -               $subtitle = sprintf(_("%s updates from everyone!"), $sitename);
13863 +        $sitename = common_config('site', 'name');
13864 +        $siteserver = common_config('site', 'server');
13865 +        $title = sprintf(_("%s public timeline"), $sitename);
13866 +        $id = "tag:$siteserver:Statuses";
13867 +        $link = common_root_url();
13868 +        $subtitle = sprintf(_("%s updates from everyone!"), $sitename);
13869 hunk ./actions/twitapistatuses.php 36
13870 -               // Number of public statuses to return by default -- Twitter sends 20
13871 -               $MAX_PUBSTATUSES = 20;
13872 +        // Number of public statuses to return by default -- Twitter sends 20
13873 +        $MAX_PUBSTATUSES = 20;
13874 hunk ./actions/twitapistatuses.php 39
13875 -               // FIXME: To really live up to the spec we need to build a list
13876 -               // of notices by users who have custom avatars, so fix this SQL -- Zach
13877 +        // FIXME: To really live up to the spec we need to build a list
13878 +        // of notices by users who have custom avatars, so fix this SQL -- Zach
13879 hunk ./actions/twitapistatuses.php 42
13880 -               $page = $this->arg('page');
13881 -               $since_id = $this->arg('since_id');
13882 -               $before_id = $this->arg('before_id');
13883 +        $page = $this->arg('page');
13884 +        $since_id = $this->arg('since_id');
13885 +        $before_id = $this->arg('before_id');
13886 hunk ./actions/twitapistatuses.php 46
13887 -               // NOTE: page, since_id, and before_id are extensions to Twitter API -- TB
13888 -               if (!$page) {
13889 -                       $page = 1;
13890 -               }
13891 -               if (!$since_id) {
13892 -                       $since_id = 0;
13893 -               }
13894 -               if (!$before_id) {
13895 -                       $before_id = 0;
13896 -               }
13897 +        // NOTE: page, since_id, and before_id are extensions to Twitter API -- TB
13898 +        if (!$page) {
13899 +            $page = 1;
13900 +        }
13901 +        if (!$since_id) {
13902 +            $since_id = 0;
13903 +        }
13904 +        if (!$before_id) {
13905 +            $before_id = 0;
13906 +        }
13907 hunk ./actions/twitapistatuses.php 57
13908 -               $since = strtotime($this->arg('since'));
13909 +        $since = strtotime($this->arg('since'));
13910 hunk ./actions/twitapistatuses.php 59
13911 -               $notice = Notice::publicStream((($page-1)*$MAX_PUBSTATUSES), $MAX_PUBSTATUSES, $since_id, $before_id, $since);
13912 +        $notice = Notice::publicStream((($page-1)*$MAX_PUBSTATUSES), $MAX_PUBSTATUSES, $since_id, $before_id, $since);
13913 hunk ./actions/twitapistatuses.php 61
13914 -               if ($notice) {
13915 +        if ($notice) {
13916 hunk ./actions/twitapistatuses.php 63
13917 -                       switch($apidata['content-type']) {
13918 -                               case 'xml':
13919 -                                       $this->show_xml_timeline($notice);
13920 -                                       break;
13921 -                               case 'rss':
13922 -                                       $this->show_rss_timeline($notice, $title, $link, $subtitle);
13923 -                                       break;
13924 -                               case 'atom':
13925 -                                       $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
13926 -                                       break;
13927 -                               case 'json':
13928 -                                       $this->show_json_timeline($notice);
13929 -                                       break;
13930 -                               default:
13931 -                                       common_user_error(_('API method not found!'), $code = 404);
13932 -                                       break;
13933 -                       }
13934 +            switch($apidata['content-type']) {
13935 +                case 'xml':
13936 +                    $this->show_xml_timeline($notice);
13937 +                    break;
13938 +                case 'rss':
13939 +                    $this->show_rss_timeline($notice, $title, $link, $subtitle);
13940 +                    break;
13941 +                case 'atom':
13942 +                    $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
13943 +                    break;
13944 +                case 'json':
13945 +                    $this->show_json_timeline($notice);
13946 +                    break;
13947 +                default:
13948 +                    common_user_error(_('API method not found!'), $code = 404);
13949 +                    break;
13950 +            }
13951 hunk ./actions/twitapistatuses.php 81
13952 -               } else {
13953 -                       common_server_error(_('Couldn\'t find any statuses.'), $code = 503);
13954 -               }
13955 +        } else {
13956 +            common_server_error(_('Couldn\'t find any statuses.'), $code = 503);
13957 +        }
13958 hunk ./actions/twitapistatuses.php 85
13959 -       }
13960 +    }
13961 hunk ./actions/twitapistatuses.php 87
13962 -       function friends_timeline($args, $apidata) {
13963 -               parent::handle($args);
13964 +    function friends_timeline($args, $apidata) {
13965 +        parent::handle($args);
13966 hunk ./actions/twitapistatuses.php 90
13967 -               $since = $this->arg('since');
13968 -               $since_id = $this->arg('since_id');
13969 -               $count = $this->arg('count');
13970 -               $page = $this->arg('page');
13971 -               $before_id = $this->arg('before_id');
13972 +        $since = $this->arg('since');
13973 +        $since_id = $this->arg('since_id');
13974 +        $count = $this->arg('count');
13975 +        $page = $this->arg('page');
13976 +        $before_id = $this->arg('before_id');
13977 hunk ./actions/twitapistatuses.php 96
13978 -               if (!$page) {
13979 -                       $page = 1;
13980 -               }
13981 +        if (!$page) {
13982 +            $page = 1;
13983 +        }
13984 hunk ./actions/twitapistatuses.php 100
13985 -               if (!$count) {
13986 -                       $count = 20;
13987 -               }
13988 +        if (!$count) {
13989 +            $count = 20;
13990 +        }
13991 hunk ./actions/twitapistatuses.php 104
13992 -               if (!$since_id) {
13993 -                       $since_id = 0;
13994 -               }
13995 +        if (!$since_id) {
13996 +            $since_id = 0;
13997 +        }
13998 hunk ./actions/twitapistatuses.php 108
13999 -               // NOTE: before_id is an extension to Twitter API -- TB
14000 -               if (!$before_id) {
14001 -                       $before_id = 0;
14002 -               }
14003 +        // NOTE: before_id is an extension to Twitter API -- TB
14004 +        if (!$before_id) {
14005 +            $before_id = 0;
14006 +        }
14007 hunk ./actions/twitapistatuses.php 113
14008 -               $since = strtotime($this->arg('since'));
14009 +        $since = strtotime($this->arg('since'));
14010 hunk ./actions/twitapistatuses.php 115
14011 -               $user = $this->get_user(NULL, $apidata);
14012 -               $this->auth_user = $user;
14013 +        $user = $this->get_user(NULL, $apidata);
14014 +        $this->auth_user = $user;
14015 hunk ./actions/twitapistatuses.php 118
14016 -               $profile = $user->getProfile();
14017 +        $profile = $user->getProfile();
14018 hunk ./actions/twitapistatuses.php 120
14019 -               $sitename = common_config('site', 'name');
14020 -               $siteserver = common_config('site', 'server');
14021 +        $sitename = common_config('site', 'name');
14022 +        $siteserver = common_config('site', 'server');
14023 hunk ./actions/twitapistatuses.php 123
14024 -               $title = sprintf(_("%s and friends"), $user->nickname);
14025 -               $id = "tag:$siteserver:friends:" . $user->id;
14026 -               $link = common_local_url('all', array('nickname' => $user->nickname));
14027 -               $subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'), $user->nickname, $sitename);
14028 +        $title = sprintf(_("%s and friends"), $user->nickname);
14029 +        $id = "tag:$siteserver:friends:" . $user->id;
14030 +        $link = common_local_url('all', array('nickname' => $user->nickname));
14031 +        $subtitle = sprintf(_('Updates from %1$s and friends on %2$s!'), $user->nickname, $sitename);
14032 hunk ./actions/twitapistatuses.php 128
14033 -               $notice = $user->noticesWithFriends(($page-1)*20, $count, $since_id, $before_id, $since);
14034 +        $notice = $user->noticesWithFriends(($page-1)*20, $count, $since_id, $before_id, $since);
14035 hunk ./actions/twitapistatuses.php 130
14036 -               switch($apidata['content-type']) {
14037 -                case 'xml':
14038 -                       $this->show_xml_timeline($notice);
14039 -                       break;
14040 -                case 'rss':
14041 -                       $this->show_rss_timeline($notice, $title, $link, $subtitle);
14042 -                       break;
14043 -                case 'atom':
14044 -                       $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
14045 -                       break;
14046 -                case 'json':
14047 -                       $this->show_json_timeline($notice);
14048 -                       break;
14049 -                default:
14050 -                       common_user_error(_('API method not found!'), $code = 404);
14051 -               }
14052 +        switch($apidata['content-type']) {
14053 +         case 'xml':
14054 +            $this->show_xml_timeline($notice);
14055 +            break;
14056 +         case 'rss':
14057 +            $this->show_rss_timeline($notice, $title, $link, $subtitle);
14058 +            break;
14059 +         case 'atom':
14060 +            $this->show_atom_timeline($notice, $title, $id, $link, $subtitle);
14061 +            break;
14062 +         case 'json':
14063 +            $this->show_json_timeline($notice);
14064 +            break;
14065 +         default:
14066 +            common_user_error(_('API method not found!'), $code = 404);
14067 +        }
14068 hunk ./actions/twitapistatuses.php 147
14069 -       }
14070 +    }
14071 hunk ./actions/twitapistatuses.php 149
14072 -       function user_timeline($args, $apidata) {
14073 -               parent::handle($args);
14074 +    function user_timeline($args, $apidata) {
14075 +        parent::handle($args);
14076 hunk ./actions/twitapistatuses.php 152
14077 -               $this->auth_user = $apidata['user'];
14078 -               $user = $this->get_user($apidata['api_arg'], $apidata);
14079 +        $this->auth_user = $apidata['user'];
14080 +        $user = $this->get_user($apidata['api_arg'], $apidata);
14081 hunk ./actions/twitapistatuses.php 155
14082 -               if (!$user) {
14083 -                       $this->client_error('Not Found', 404, $apidata['content-type']);
14084 -                       return;
14085 -               }
14086 +        if (!$user) {
14087 +            $this->client_error('Not Found', 404, $apidata['content-type']);
14088 +            return;
14089 +        }
14090 hunk ./actions/twitapistatuses.php 160
14091 -               $profile = $user->getProfile();
14092 +        $profile = $user->getProfile();
14093 hunk ./actions/twitapistatuses.php 162
14094 -               if (!$profile) {
14095 -                       common_server_error(_('User has no profile.'));
14096 -                       return;
14097 -               }
14098 +        if (!$profile) {
14099 +            common_server_error(_('User has no profile.'));
14100 +            return;
14101 +        }
14102 hunk ./actions/twitapistatuses.php 167
14103 -               $count = $this->arg('count');
14104 -               $since = $this->arg('since');
14105 -               $since_id = $this->arg('since_id');
14106 -               $page = $this->arg('page');
14107 -               $before_id = $this->arg('before_id');
14108 +        $count = $this->arg('count');
14109 +        $since = $this->arg('since');
14110 +        $since_id = $this->arg('since_id');
14111 +        $page = $this->arg('page');
14112 +        $before_id = $this->arg('before_id');
14113 hunk ./actions/twitapistatuses.php 173
14114 -               if (!$page) {
14115 -                       $page = 1;
14116 -               }
14117 +        if (!$page) {
14118 +            $page = 1;
14119 +        }
14120 hunk ./actions/twitapistatuses.php 177
14121 -               if (!$count) {
14122 -                       $count = 20;
14123 -               }
14124 +        if (!$count) {
14125 +            $count = 20;
14126 +        }
14127 hunk ./actions/twitapistatuses.php 181
14128 -               if (!$since_id) {
14129 -                       $since_id = 0;
14130 -               }
14131 +        if (!$since_id) {
14132 +            $since_id = 0;
14133 +        }
14134 hunk ./actions/twitapistatuses.php 185
14135 -               // NOTE: before_id is an extensions to Twitter API -- TB
14136 -               if (!$before_id) {
14137 -                       $before_id = 0;
14138 -               }
14139 +        // NOTE: before_id is an extensions to Twitter API -- TB
14140 +        if (!$before_id) {
14141 +            $before_id = 0;
14142 +        }
14143 hunk ./actions/twitapistatuses.php 190
14144 -               $since = strtotime($this->arg('since'));
14145 +        $since = strtotime($this->arg('since'));
14146 hunk ./actions/twitapistatuses.php 192
14147 -               $sitename = common_config('site', 'name');
14148 -               $siteserver = common_config('site', 'server');
14149 +        $sitename = common_config('site', 'name');
14150 +        $siteserver = common_config('site', 'server');
14151 hunk ./actions/twitapistatuses.php 195
14152 -               $title = sprintf(_("%s timeline"), $user->nickname);
14153 -               $id = "tag:$siteserver:user:".$user->id;
14154 -               $link = common_local_url('showstream', array('nickname' => $user->nickname));
14155 -               $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
14156 +        $title = sprintf(_("%s timeline"), $user->nickname);
14157 +        $id = "tag:$siteserver:user:".$user->id;
14158 +        $link = common_local_url('showstream', array('nickname' => $user->nickname));
14159 +        $subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
14160 hunk ./actions/twitapistatuses.php 200
14161 -               # FriendFeed's SUP protocol
14162 -               # Also added RSS and Atom feeds
14163 +        # FriendFeed's SUP protocol
14164 +        # Also added RSS and Atom feeds
14165 hunk ./actions/twitapistatuses.php 203
14166 -               $suplink = common_local_url('sup', NULL, $user->id);
14167 -               header('X-SUP-ID: '.$suplink);
14168 +        $suplink = common_local_url('sup', NULL, $user->id);
14169 +        header('X-SUP-ID: '.$suplink);
14170 hunk ./actions/twitapistatuses.php 206
14171 -               # XXX: since
14172 +        # XXX: since
14173 hunk ./actions/twitapistatuses.php 208
14174 -               $notice = $user->getNotices((($page-1)*20), $count, $since_id, $before_id, $since);
14175 +        $notice = $user->getNotices((($page-1)*20), $count, $since_id, $before_id, $since);
14176 hunk ./actions/twitapistatuses.php 210
14177 -               switch($apidata['content-type']) {
14178 -                case 'xml':
14179 -                       $this->show_xml_timeline($notice);
14180 -                       break;
14181 -                case 'rss':
14182 -                       $this->show_rss_timeline($notice, $title, $link, $subtitle, $suplink);
14183 -                       break;
14184 -                case 'atom':
14185 -                       $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink);
14186 -                       break;
14187 -                case 'json':
14188 -                       $this->show_json_timeline($notice);
14189 -                       break;
14190 -                default:
14191 -                       common_user_error(_('API method not found!'), $code = 404);
14192 -               }
14193 +        switch($apidata['content-type']) {
14194 +         case 'xml':
14195 +            $this->show_xml_timeline($notice);
14196 +            break;
14197 +         case 'rss':
14198 +            $this->show_rss_timeline($notice, $title, $link, $subtitle, $suplink);
14199 +            break;
14200 +         case 'atom':
14201 +            $this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink);
14202 +            break;
14203 +         case 'json':
14204 +            $this->show_json_timeline($notice);
14205 +            break;
14206 +         default:
14207 +            common_user_error(_('API method not found!'), $code = 404);
14208 +        }
14209 hunk ./actions/twitapistatuses.php 227
14210 -       }
14211 +    }
14212 hunk ./actions/twitapistatuses.php 229
14213 -       function update($args, $apidata) {
14214 +    function update($args, $apidata) {
14215 hunk ./actions/twitapistatuses.php 231
14216 -               parent::handle($args);
14217 +        parent::handle($args);
14218 hunk ./actions/twitapistatuses.php 233
14219 -               if (!in_array($apidata['content-type'], array('xml', 'json'))) {
14220 -                       common_user_error(_('API method not found!'), $code = 404);
14221 -                       return;
14222 -               }
14223 +        if (!in_array($apidata['content-type'], array('xml', 'json'))) {
14224 +            common_user_error(_('API method not found!'), $code = 404);
14225 +            return;
14226 +        }
14227 hunk ./actions/twitapistatuses.php 238
14228 -               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
14229 -                       $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
14230 -                       return;
14231 -               }
14232 +        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
14233 +            $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
14234 +            return;
14235 +        }
14236 hunk ./actions/twitapistatuses.php 243
14237 -               $this->auth_user = $apidata['user'];
14238 -               $user = $this->auth_user;
14239 -               $status = $this->trimmed('status');
14240 -               $source = $this->trimmed('source');
14241 -               $in_reply_to_status_id = intval($this->trimmed('in_reply_to_status_id'));
14242 +        $this->auth_user = $apidata['user'];
14243 +        $user = $this->auth_user;
14244 +        $status = $this->trimmed('status');
14245 +        $source = $this->trimmed('source');
14246 +        $in_reply_to_status_id = intval($this->trimmed('in_reply_to_status_id'));
14247 hunk ./actions/twitapistatuses.php 249
14248 -               if (!$source || in_array($source, $reserved_sources)) {
14249 -                       $source = 'api';
14250 -               }
14251 +        if (!$source || in_array($source, $reserved_sources)) {
14252 +            $source = 'api';
14253 +        }
14254 hunk ./actions/twitapistatuses.php 253
14255 -               if (!$status) {
14256 +        if (!$status) {
14257 hunk ./actions/twitapistatuses.php 255
14258 -                       // XXX: Note: In this case, Twitter simply returns '200 OK'
14259 -                       // No error is given, but the status is not posted to the
14260 -                       // user's timeline.      Seems bad.      Shouldn't we throw an
14261 -                       // errror? -- Zach
14262 -                       return;
14263 +            // XXX: Note: In this case, Twitter simply returns '200 OK'
14264 +            // No error is given, but the status is not posted to the
14265 +            // user's timeline.     Seems bad.     Shouldn't we throw an
14266 +            // errror? -- Zach
14267 +            return;
14268 hunk ./actions/twitapistatuses.php 261
14269 -               } else {
14270 +        } else {
14271 hunk ./actions/twitapistatuses.php 263
14272 -                       $status_shortened = common_shorten_links($status);
14273 +            $status_shortened = common_shorten_links($status);
14274 hunk ./actions/twitapistatuses.php 265
14275 -                       if (mb_strlen($status_shortened) > 140) {
14276 +            if (mb_strlen($status_shortened) > 140) {
14277 hunk ./actions/twitapistatuses.php 267
14278 -                               // XXX: Twitter truncates anything over 140, flags the status
14279 -                               // as "truncated." Sending this error may screw up some clients
14280 -                               // that assume Twitter will truncate for them.  Should we just
14281 -                               // truncate too? -- Zach
14282 -                               $this->client_error(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']);
14283 -                               return;
14284 +                // XXX: Twitter truncates anything over 140, flags the status
14285 +                // as "truncated." Sending this error may screw up some clients
14286 +                // that assume Twitter will truncate for them.    Should we just
14287 +                // truncate too? -- Zach
14288 +                $this->client_error(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']);
14289 +                return;
14290 hunk ./actions/twitapistatuses.php 274
14291 -                       }
14292 -               }
14293 +            }
14294 +        }
14295 hunk ./actions/twitapistatuses.php 277
14296 -               // Check for commands
14297 -               $inter = new CommandInterpreter();
14298 -               $cmd = $inter->handle_command($user, $status_shortened);
14299 +        // Check for commands
14300 +        $inter = new CommandInterpreter();
14301 +        $cmd = $inter->handle_command($user, $status_shortened);
14302 hunk ./actions/twitapistatuses.php 281
14303 -               if ($cmd) {
14304 +        if ($cmd) {
14305 hunk ./actions/twitapistatuses.php 283
14306 -                       if ($this->supported($cmd)) {
14307 -                               $cmd->execute(new Channel());
14308 -                       }
14309 +            if ($this->supported($cmd)) {
14310 +                $cmd->execute(new Channel());
14311 +            }
14312 hunk ./actions/twitapistatuses.php 287
14313 -                       // cmd not supported?  Twitter just returns your latest status.
14314 -                       // And, it returns your last status whether the cmd was successful
14315 -                       // or not!
14316 -                       $n = $user->getCurrentNotice();
14317 -                       $apidata['api_arg'] = $n->id;
14318 -               } else {
14319 +            // cmd not supported?  Twitter just returns your latest status.
14320 +            // And, it returns your last status whether the cmd was successful
14321 +            // or not!
14322 +            $n = $user->getCurrentNotice();
14323 +            $apidata['api_arg'] = $n->id;
14324 +        } else {
14325 hunk ./actions/twitapistatuses.php 294
14326 -                       $reply_to = NULL;
14327 +            $reply_to = NULL;
14328 hunk ./actions/twitapistatuses.php 296
14329 -                       if ($in_reply_to_status_id) {
14330 +            if ($in_reply_to_status_id) {
14331 hunk ./actions/twitapistatuses.php 298
14332 -                               // check whether notice actually exists
14333 -                               $reply = Notice::staticGet($in_reply_to_status_id);
14334 +                // check whether notice actually exists
14335 +                $reply = Notice::staticGet($in_reply_to_status_id);
14336 hunk ./actions/twitapistatuses.php 301
14337 -                               if ($reply) {
14338 -                                       $reply_to = $in_reply_to_status_id;
14339 -                               } else {
14340 -                                       $this->client_error(_('Not found'), $code = 404, $apidata['content-type']);
14341 -                                       return;
14342 -                               }
14343 -                       }
14344 +                if ($reply) {
14345 +                    $reply_to = $in_reply_to_status_id;
14346 +                } else {
14347 +                    $this->client_error(_('Not found'), $code = 404, $apidata['content-type']);
14348 +                    return;
14349 +                }
14350 +            }
14351 hunk ./actions/twitapistatuses.php 309
14352 -                       $notice = Notice::saveNew($user->id, html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'),
14353 -                               $source, 1, $reply_to);
14354 +            $notice = Notice::saveNew($user->id, html_entity_decode($status, ENT_NOQUOTES, 'UTF-8'),
14355 +                $source, 1, $reply_to);
14356 hunk ./actions/twitapistatuses.php 312
14357 -                       if (is_string($notice)) {
14358 -                               $this->server_error($notice);
14359 -                               return;
14360 -                       }
14361 +            if (is_string($notice)) {
14362 +                $this->server_error($notice);
14363 +                return;
14364 +            }
14365 hunk ./actions/twitapistatuses.php 317
14366 -                       common_broadcast_notice($notice);
14367 -                       $apidata['api_arg'] = $notice->id;
14368 -               }
14369 +            common_broadcast_notice($notice);
14370 +            $apidata['api_arg'] = $notice->id;
14371 +        }
14372 hunk ./actions/twitapistatuses.php 321
14373 -               $this->show($args, $apidata);
14374 -       }
14375 +        $this->show($args, $apidata);
14376 +    }
14377 hunk ./actions/twitapistatuses.php 324
14378 -       function replies($args, $apidata) {
14379 +    function replies($args, $apidata) {
14380 hunk ./actions/twitapistatuses.php 326
14381 -               parent::handle($args);
14382 +        parent::handle($args);
14383 hunk ./actions/twitapistatuses.php 328
14384 -               $since = $this->arg('since');
14385 -               $count = $this->arg('count');
14386 -               $page = $this->arg('page');
14387 -               $since_id = $this->arg('since_id');
14388 -               $before_id = $this->arg('before_id');
14389 +        $since = $this->arg('since');
14390 +        $count = $this->arg('count');
14391 +        $page = $this->arg('page');
14392 +        $since_id = $this->arg('since_id');
14393 +        $before_id = $this->arg('before_id');
14394 hunk ./actions/twitapistatuses.php 334
14395 -               $this->auth_user = $apidata['user'];
14396 -               $user = $this->auth_user;
14397 -               $profile = $user->getProfile();
14398 +        $this->auth_user = $apidata['user'];
14399 +        $user = $this->auth_user;
14400 +        $profile = $user->getProfile();
14401 hunk ./actions/twitapistatuses.php 338
14402 -               $sitename = common_config('site', 'name');
14403 -               $siteserver = common_config('site', 'server');
14404 +        $sitename = common_config('site', 'name');
14405 +        $siteserver = common_config('site', 'server');
14406 hunk ./actions/twitapistatuses.php 341
14407 -               $title = sprintf(_('%1$s / Updates replying to %2$s'), $sitename, $user->nickname);
14408 -               $id = "tag:$siteserver:replies:".$user->id;
14409 -               $link = common_local_url('replies', array('nickname' => $user->nickname));
14410 -               $subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'), $sitename, $user->nickname, $profile->getBestName());
14411 +        $title = sprintf(_('%1$s / Updates replying to %2$s'), $sitename, $user->nickname);
14412 +        $id = "tag:$siteserver:replies:".$user->id;
14413 +        $link = common_local_url('replies', array('nickname' => $user->nickname));
14414 +        $subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'), $sitename, $user->nickname, $profile->getBestName());
14415 hunk ./actions/twitapistatuses.php 346
14416 -               if (!$page) {
14417 -                       $page = 1;
14418 -               }
14419 +        if (!$page) {
14420 +            $page = 1;
14421 +        }
14422 hunk ./actions/twitapistatuses.php 350
14423 -               if (!$count) {
14424 -                       $count = 20;
14425 -               }
14426 +        if (!$count) {
14427 +            $count = 20;
14428 +        }
14429 hunk ./actions/twitapistatuses.php 354
14430 -               if (!$since_id) {
14431 -                       $since_id = 0;
14432 -               }
14433 +        if (!$since_id) {
14434 +            $since_id = 0;
14435 +        }
14436 hunk ./actions/twitapistatuses.php 358
14437 -               // NOTE: before_id is an extension to Twitter API -- TB
14438 -               if (!$before_id) {
14439 -                       $before_id = 0;
14440 -               }
14441 +        // NOTE: before_id is an extension to Twitter API -- TB
14442 +        if (!$before_id) {
14443 +            $before_id = 0;
14444 +        }
14445 hunk ./actions/twitapistatuses.php 363
14446 -               $since = strtotime($this->arg('since'));
14447 +        $since = strtotime($this->arg('since'));
14448 hunk ./actions/twitapistatuses.php 365
14449 -               $notice = $user->getReplies((($page-1)*20), $count, $since_id, $before_id, $since);
14450 -               $notices = array();
14451 +        $notice = $user->getReplies((($page-1)*20), $count, $since_id, $before_id, $since);
14452 +        $notices = array();
14453 hunk ./actions/twitapistatuses.php 368
14454 -               while ($notice->fetch()) {
14455 -                       $notices[] = clone($notice);
14456 -               }
14457 +        while ($notice->fetch()) {
14458 +            $notices[] = clone($notice);
14459 +        }
14460 hunk ./actions/twitapistatuses.php 372
14461 -               switch($apidata['content-type']) {
14462 -                case 'xml':
14463 -                       $this->show_xml_timeline($notices);
14464 -                       break;
14465 -                case 'rss':
14466 -                       $this->show_rss_timeline($notices, $title, $link, $subtitle);
14467 -                       break;
14468 -                case 'atom':
14469 -                       $this->show_atom_timeline($notices, $title, $id, $link, $subtitle);
14470 -                       break;
14471 -                case 'json':
14472 -                       $this->show_json_timeline($notices);
14473 -                       break;
14474 -                default:
14475 -                       common_user_error(_('API method not found!'), $code = 404);
14476 -               }
14477 +        switch($apidata['content-type']) {
14478 +         case 'xml':
14479 +            $this->show_xml_timeline($notices);
14480 +            break;
14481 +         case 'rss':
14482 +            $this->show_rss_timeline($notices, $title, $link, $subtitle);
14483 +            break;
14484 +         case 'atom':
14485 +            $this->show_atom_timeline($notices, $title, $id, $link, $subtitle);
14486 +            break;
14487 +         case 'json':
14488 +            $this->show_json_timeline($notices);
14489 +            break;
14490 +         default:
14491 +            common_user_error(_('API method not found!'), $code = 404);
14492 +        }
14493 hunk ./actions/twitapistatuses.php 389
14494 -       }
14495 +    }
14496 hunk ./actions/twitapistatuses.php 391
14497 -       function show($args, $apidata) {
14498 -               parent::handle($args);
14499 +    function show($args, $apidata) {
14500 +        parent::handle($args);
14501 hunk ./actions/twitapistatuses.php 394
14502 -               if (!in_array($apidata['content-type'], array('xml', 'json'))) {
14503 -                       common_user_error(_('API method not found!'), $code = 404);
14504 -                       return;
14505 -               }
14506 +        if (!in_array($apidata['content-type'], array('xml', 'json'))) {
14507 +            common_user_error(_('API method not found!'), $code = 404);
14508 +            return;
14509 +        }
14510 hunk ./actions/twitapistatuses.php 399
14511 -               $this->auth_user = $apidata['user'];
14512 -               $notice_id = $apidata['api_arg'];
14513 -               $notice = Notice::staticGet($notice_id);
14514 +        $this->auth_user = $apidata['user'];
14515 +        $notice_id = $apidata['api_arg'];
14516 +        $notice = Notice::staticGet($notice_id);
14517 hunk ./actions/twitapistatuses.php 403
14518 -               if ($notice) {
14519 -                       if ($apidata['content-type'] == 'xml') {
14520 -                               $this->show_single_xml_status($notice);
14521 -                       } elseif ($apidata['content-type'] == 'json') {
14522 -                               $this->show_single_json_status($notice);
14523 -                       }
14524 -               } else {
14525 -                       // XXX: Twitter just sets a 404 header and doens't bother to return an err msg
14526 -                       $this->client_error(_('No status with that ID found.'), 404, $apidata['content-type']);
14527 -               }
14528 +        if ($notice) {
14529 +            if ($apidata['content-type'] == 'xml') {
14530 +                $this->show_single_xml_status($notice);
14531 +            } elseif ($apidata['content-type'] == 'json') {
14532 +                $this->show_single_json_status($notice);
14533 +            }
14534 +        } else {
14535 +            // XXX: Twitter just sets a 404 header and doens't bother to return an err msg
14536 +            $this->client_error(_('No status with that ID found.'), 404, $apidata['content-type']);
14537 +        }
14538 hunk ./actions/twitapistatuses.php 414
14539 -       }
14540 +    }
14541 hunk ./actions/twitapistatuses.php 416
14542 -       function destroy($args, $apidata) {
14543 +    function destroy($args, $apidata) {
14544 hunk ./actions/twitapistatuses.php 418
14545 -               parent::handle($args);
14546 +        parent::handle($args);
14547 hunk ./actions/twitapistatuses.php 420
14548 -               if (!in_array($apidata['content-type'], array('xml', 'json'))) {
14549 -                       common_user_error(_('API method not found!'), $code = 404);
14550 -                       return;
14551 -               }
14552 +        if (!in_array($apidata['content-type'], array('xml', 'json'))) {
14553 +            common_user_error(_('API method not found!'), $code = 404);
14554 +            return;
14555 +        }
14556 hunk ./actions/twitapistatuses.php 425
14557 -               // Check for RESTfulness
14558 -               if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
14559 -                       // XXX: Twitter just prints the err msg, no XML / JSON.
14560 -                       $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
14561 -                       return;
14562 -               }
14563 +        // Check for RESTfulness
14564 +        if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
14565 +            // XXX: Twitter just prints the err msg, no XML / JSON.
14566 +            $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
14567 +            return;
14568 +        }
14569 hunk ./actions/twitapistatuses.php 432
14570 -               $this->auth_user = $apidata['user'];
14571 -               $user = $this->auth_user;
14572 -               $notice_id = $apidata['api_arg'];
14573 -               $notice = Notice::staticGet($notice_id);
14574 +        $this->auth_user = $apidata['user'];
14575 +        $user = $this->auth_user;
14576 +        $notice_id = $apidata['api_arg'];
14577 +        $notice = Notice::staticGet($notice_id);
14578 hunk ./actions/twitapistatuses.php 437
14579 -               if (!$notice) {
14580 -                       $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
14581 -                       return;
14582 -               }
14583 +        if (!$notice) {
14584 +            $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']);
14585 +            return;
14586 +        }
14587 hunk ./actions/twitapistatuses.php 442
14588 -               if ($user->id == $notice->profile_id) {
14589 -                       $replies = new Reply;
14590 -                       $replies->get('notice_id', $notice_id);
14591 -                       common_dequeue_notice($notice);
14592 -                       $replies->delete();
14593 -                       $notice->delete();
14594 +        if ($user->id == $notice->profile_id) {
14595 +            $replies = new Reply;
14596 +            $replies->get('notice_id', $notice_id);
14597 +            common_dequeue_notice($notice);
14598 +            $replies->delete();
14599 +            $notice->delete();
14600 hunk ./actions/twitapistatuses.php 449
14601 -                       if ($apidata['content-type'] == 'xml') {
14602 -                               $this->show_single_xml_status($notice);
14603 -                       } elseif ($apidata['content-type'] == 'json') {
14604 -                               $this->show_single_json_status($notice);
14605 -                       }
14606 -               } else {
14607 -                       $this->client_error(_('You may not delete another user\'s status.'), 403, $apidata['content-type']);
14608 -               }
14609 +            if ($apidata['content-type'] == 'xml') {
14610 +                $this->show_single_xml_status($notice);
14611 +            } elseif ($apidata['content-type'] == 'json') {
14612 +                $this->show_single_json_status($notice);
14613 +            }
14614 +        } else {
14615 +            $this->client_error(_('You may not delete another user\'s status.'), 403, $apidata['content-type']);
14616 +        }
14617 hunk ./actions/twitapistatuses.php 458
14618 -       }
14619 +    }
14620 hunk ./actions/twitapistatuses.php 460
14621 -       function friends($args, $apidata) {
14622 -               parent::handle($args);
14623 -               return $this->subscriptions($apidata, 'subscribed', 'subscriber');
14624 -       }
14625 +    function friends($args, $apidata) {
14626 +        parent::handle($args);
14627 +        return $this->subscriptions($apidata, 'subscribed', 'subscriber');
14628 +    }
14629 hunk ./actions/twitapistatuses.php 465
14630 -       function followers($args, $apidata) {
14631 -               parent::handle($args);
14632 +    function followers($args, $apidata) {
14633 +        parent::handle($args);
14634 hunk ./actions/twitapistatuses.php 468
14635 -               return $this->subscriptions($apidata, 'subscriber', 'subscribed');
14636 -       }
14637 +        return $this->subscriptions($apidata, 'subscriber', 'subscribed');
14638 +    }
14639 hunk ./actions/twitapistatuses.php 471
14640 -       function subscriptions($apidata, $other_attr, $user_attr) {
14641 +    function subscriptions($apidata, $other_attr, $user_attr) {
14642 hunk ./actions/twitapistatuses.php 473
14643 -               # XXX: lite
14644 +        # XXX: lite
14645 hunk ./actions/twitapistatuses.php 475
14646 -               $this->auth_user = $apidate['user'];
14647 -               $user = $this->get_user($apidata['api_arg'], $apidata);
14648 +        $this->auth_user = $apidate['user'];
14649 +        $user = $this->get_user($apidata['api_arg'], $apidata);
14650 hunk ./actions/twitapistatuses.php 478
14651 -               if (!$user) {
14652 -                       $this->client_error('Not Found', 404, $apidata['content-type']);
14653 -                       return;
14654 -               }
14655 +        if (!$user) {
14656 +            $this->client_error('Not Found', 404, $apidata['content-type']);
14657 +            return;
14658 +        }
14659 hunk ./actions/twitapistatuses.php 483
14660 -               $page = $this->trimmed('page');
14661 +        $page = $this->trimmed('page');
14662 hunk ./actions/twitapistatuses.php 485
14663 -               if (!$page || !is_numeric($page)) {
14664 -                       $page = 1;
14665 -               }
14666 +        if (!$page || !is_numeric($page)) {
14667 +            $page = 1;
14668 +        }
14669 hunk ./actions/twitapistatuses.php 489
14670 -               $profile = $user->getProfile();
14671 +        $profile = $user->getProfile();
14672 hunk ./actions/twitapistatuses.php 491
14673 -               if (!$profile) {
14674 -                       common_server_error(_('User has no profile.'));
14675 -                       return;
14676 -               }
14677 +        if (!$profile) {
14678 +            common_server_error(_('User has no profile.'));
14679 +            return;
14680 +        }
14681 hunk ./actions/twitapistatuses.php 496
14682 -               $sub = new Subscription();
14683 -               $sub->$user_attr = $profile->id;
14684 +        $sub = new Subscription();
14685 +        $sub->$user_attr = $profile->id;
14686 hunk ./actions/twitapistatuses.php 499
14687 -               $since = strtotime($this->trimmed('since'));
14688 +        $since = strtotime($this->trimmed('since'));
14689 hunk ./actions/twitapistatuses.php 501
14690 -               if ($since) {
14691 -                       $d = date('Y-m-d H:i:s', $since);
14692 -                       $sub->whereAdd("created > '$d'");
14693 -               }
14694 +        if ($since) {
14695 +            $d = date('Y-m-d H:i:s', $since);
14696 +            $sub->whereAdd("created > '$d'");
14697 +        }
14698 hunk ./actions/twitapistatuses.php 506
14699 -               $sub->orderBy('created DESC');
14700 -               $sub->limit(($page-1)*100, 100);
14701 +        $sub->orderBy('created DESC');
14702 +        $sub->limit(($page-1)*100, 100);
14703 hunk ./actions/twitapistatuses.php 509
14704 -               $others = array();
14705 +        $others = array();
14706 hunk ./actions/twitapistatuses.php 511
14707 -               if ($sub->find()) {
14708 -                       while ($sub->fetch()) {
14709 -                               $others[] = Profile::staticGet($sub->$other_attr);
14710 -                       }
14711 -               } else {
14712 -                       // user has no followers
14713 -               }
14714 +        if ($sub->find()) {
14715 +            while ($sub->fetch()) {
14716 +                $others[] = Profile::staticGet($sub->$other_attr);
14717 +            }
14718 +        } else {
14719 +            // user has no followers
14720 +        }
14721 hunk ./actions/twitapistatuses.php 519
14722 -               $type = $apidata['content-type'];
14723 +        $type = $apidata['content-type'];
14724 hunk ./actions/twitapistatuses.php 521
14725 -               $this->init_document($type);
14726 -               $this->show_profiles($others, $type);
14727 -               $this->end_document($type);
14728 -       }
14729 +        $this->init_document($type);
14730 +        $this->show_profiles($others, $type);
14731 +        $this->end_document($type);
14732 +    }
14733 hunk ./actions/twitapistatuses.php 526
14734 -       function show_profiles($profiles, $type) {
14735 -               switch ($type) {
14736 -                case 'xml':
14737 -                       common_element_start('users', array('type' => 'array'));
14738 -                       foreach ($profiles as $profile) {
14739 -                               $this->show_profile($profile);
14740 -                       }
14741 -                       common_element_end('users');
14742 -                       break;
14743 -                case 'json':
14744 -                       $arrays = array();
14745 -                       foreach ($profiles as $profile) {
14746 -                               $arrays[] = $this->twitter_user_array($profile, true);
14747 -                       }
14748 -                       print json_encode($arrays);
14749 -                       break;
14750 -                default:
14751 -                       $this->client_error(_('unsupported file type'));
14752 -               }
14753 -       }
14754 +    function show_profiles($profiles, $type) {
14755 +        switch ($type) {
14756 +         case 'xml':
14757 +            common_element_start('users', array('type' => 'array'));
14758 +            foreach ($profiles as $profile) {
14759 +                $this->show_profile($profile);
14760 +            }
14761 +            common_element_end('users');
14762 +            break;
14763 +         case 'json':
14764 +            $arrays = array();
14765 +            foreach ($profiles as $profile) {
14766 +                $arrays[] = $this->twitter_user_array($profile, true);
14767 +            }
14768 +            print json_encode($arrays);
14769 +            break;
14770 +         default:
14771 +            $this->client_error(_('unsupported file type'));
14772 +        }
14773 +    }
14774 hunk ./actions/twitapistatuses.php 547
14775 -       function featured($args, $apidata) {
14776 -               parent::handle($args);
14777 -               common_server_error(_('API method under construction.'), $code=501);
14778 -       }
14779 +    function featured($args, $apidata) {
14780 +        parent::handle($args);
14781 +        common_server_error(_('API method under construction.'), $code=501);
14782 +    }
14783 hunk ./actions/twitapistatuses.php 552
14784 -       function supported($cmd) {
14785 +    function supported($cmd) {
14786 hunk ./actions/twitapistatuses.php 554
14787 -               $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand', 'FavCommand', 'OnCommand', 'OffCommand');
14788 +        $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand', 'FavCommand', 'OnCommand', 'OffCommand');
14789 hunk ./actions/twitapistatuses.php 556
14790 -               if (in_array(get_class($cmd), $cmdlist)) {
14791 -                       return true;
14792 -               }
14793 +        if (in_array(get_class($cmd), $cmdlist)) {
14794 +            return true;
14795 +        }
14796 hunk ./actions/twitapistatuses.php 560
14797 -               return false;
14798 -       }
14799 +        return false;
14800 +    }
14801 hunk ./actions/twitapiusers.php 13
14802 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
14803 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
14804 hunk ./actions/twitapiusers.php 17
14805 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
14806 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
14807 hunk ./actions/twitapiusers.php 26
14808 -       function show($args, $apidata) {
14809 -               parent::handle($args);
14810 +    function show($args, $apidata) {
14811 +        parent::handle($args);
14812 hunk ./actions/twitapiusers.php 29
14813 -               if (!in_array($apidata['content-type'], array('xml', 'json'))) {
14814 -                       common_user_error(_('API method not found!'), $code = 404);
14815 -                       return;
14816 -               }
14817 +        if (!in_array($apidata['content-type'], array('xml', 'json'))) {
14818 +            common_user_error(_('API method not found!'), $code = 404);
14819 +            return;
14820 +        }
14821 hunk ./actions/twitapiusers.php 34
14822 -               $user = null;
14823 -               $email = $this->arg('email');
14824 +        $user = null;
14825 +        $email = $this->arg('email');
14826 hunk ./actions/twitapiusers.php 37
14827 -               if ($email) {
14828 -                       $user = User::staticGet('email', $email);
14829 -               } elseif (isset($apidata['api_arg'])) {
14830 -                       $user = $this->get_user($apidata['api_arg']);
14831 -               }
14832 +        if ($email) {
14833 +            $user = User::staticGet('email', $email);
14834 +        } elseif (isset($apidata['api_arg'])) {
14835 +            $user = $this->get_user($apidata['api_arg']);
14836 +        }
14837 hunk ./actions/twitapiusers.php 43
14838 -               if (!$user) {
14839 -                       // XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach
14840 -                       $this->client_error(_('Not found.'), 404, $apidata['content-type']);
14841 -                       return;
14842 -               }
14843 +        if (!$user) {
14844 +            // XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach
14845 +            $this->client_error(_('Not found.'), 404, $apidata['content-type']);
14846 +            return;
14847 +        }
14848 hunk ./actions/twitapiusers.php 49
14849 -               $this->show_extended_profile($user, $apidata);
14850 -       }
14851 +        $this->show_extended_profile($user, $apidata);
14852 +    }
14853 hunk ./actions/twittersettings.php 28
14854 -       function get_instructions() {
14855 -               return _('Add your Twitter account to automatically send your notices to Twitter, ' .
14856 -                       'and subscribe to Twitter friends already here.');
14857 -       }
14858 +    function get_instructions() {
14859 +        return _('Add your Twitter account to automatically send your notices to Twitter, ' .
14860 +            'and subscribe to Twitter friends already here.');
14861 +    }
14862 hunk ./actions/twittersettings.php 33
14863 -       function show_form($msg=NULL, $success=false) {
14864 -               $user = common_current_user();
14865 -               $profile = $user->getProfile();
14866 -               $fuser = NULL;
14867 -               $flink = Foreign_link::getByUserID($user->id, 1); // 1 == Twitter
14868 +    function show_form($msg=NULL, $success=false) {
14869 +        $user = common_current_user();
14870 +        $profile = $user->getProfile();
14871 +        $fuser = NULL;
14872 +        $flink = Foreign_link::getByUserID($user->id, 1); // 1 == Twitter
14873 hunk ./actions/twittersettings.php 39
14874 -               if ($flink) {
14875 -                       $fuser = $flink->getForeignUser();
14876 -               }
14877 +        if ($flink) {
14878 +            $fuser = $flink->getForeignUser();
14879 +        }
14880 hunk ./actions/twittersettings.php 43
14881 -               $this->form_header(_('Twitter settings'), $msg, $success);
14882 -               common_element_start('form', array('method' => 'post',
14883 -                                                                                  'id' => 'twittersettings',
14884 -                                                                                  'action' =>
14885 -                                                                                  common_local_url('twittersettings')));
14886 -               common_hidden('token', common_session_token());
14887 +        $this->form_header(_('Twitter settings'), $msg, $success);
14888 +        common_element_start('form', array('method' => 'post',
14889 +                                           'id' => 'twittersettings',
14890 +                                           'action' =>
14891 +                                           common_local_url('twittersettings')));
14892 +        common_hidden('token', common_session_token());
14893 hunk ./actions/twittersettings.php 50
14894 -               common_element('h2', NULL, _('Twitter Account'));
14895 +        common_element('h2', NULL, _('Twitter Account'));
14896 hunk ./actions/twittersettings.php 52
14897 -               if ($fuser) {
14898 -                       common_element_start('p');
14899 +        if ($fuser) {
14900 +            common_element_start('p');
14901 hunk ./actions/twittersettings.php 55
14902 -                       common_element('span', 'twitter_user', $fuser->nickname);
14903 -                       common_element('a', array('href' => $fuser->uri),  $fuser->uri);
14904 -                       common_element('span', 'input_instructions',
14905 -                                      _('Current verified Twitter account.'));
14906 -                       common_hidden('flink_foreign_id', $flink->foreign_id);
14907 -                       common_element_end('p');
14908 -                       common_submit('remove', _('Remove'));
14909 -               } else {
14910 -                       common_input('twitter_username', _('Twitter user name'),
14911 -                                                ($this->arg('twitter_username')) ? $this->arg('twitter_username') : $profile->nickname,
14912 -                                                _('No spaces, please.')); // hey, it's what Twitter says
14913 +            common_element('span', 'twitter_user', $fuser->nickname);
14914 +            common_element('a', array('href' => $fuser->uri),  $fuser->uri);
14915 +            common_element('span', 'input_instructions',
14916 +                           _('Current verified Twitter account.'));
14917 +            common_hidden('flink_foreign_id', $flink->foreign_id);
14918 +            common_element_end('p');
14919 +            common_submit('remove', _('Remove'));
14920 +        } else {
14921 +            common_input('twitter_username', _('Twitter user name'),
14922 +                         ($this->arg('twitter_username')) ? $this->arg('twitter_username') : $profile->nickname,
14923 +                         _('No spaces, please.')); // hey, it's what Twitter says
14924 hunk ./actions/twittersettings.php 67
14925 -                       common_password('twitter_password', _('Twitter password'));
14926 -               }
14927 +            common_password('twitter_password', _('Twitter password'));
14928 +        }
14929 hunk ./actions/twittersettings.php 70
14930 -               common_element('h2', NULL, _('Preferences'));
14931 +        common_element('h2', NULL, _('Preferences'));
14932 hunk ./actions/twittersettings.php 72
14933 -               common_checkbox('noticesync', _('Automatically send my notices to Twitter.'),
14934 -                                               ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true);
14935 +        common_checkbox('noticesync', _('Automatically send my notices to Twitter.'),
14936 +                        ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true);
14937 hunk ./actions/twittersettings.php 75
14938 -               common_checkbox('replysync', _('Send local "@" replies to Twitter.'),
14939 -                                               ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
14940 +        common_checkbox('replysync', _('Send local "@" replies to Twitter.'),
14941 +                        ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
14942 hunk ./actions/twittersettings.php 78
14943 -               common_checkbox('friendsync', _('Subscribe to my Twitter friends here.'),
14944 -                                               ($flink) ? ($flink->friendsync & FOREIGN_FRIEND_RECV) : false);
14945 +        common_checkbox('friendsync', _('Subscribe to my Twitter friends here.'),
14946 +                        ($flink) ? ($flink->friendsync & FOREIGN_FRIEND_RECV) : false);
14947 hunk ./actions/twittersettings.php 81
14948 -               if ($flink) {
14949 -                       common_submit('save', _('Save'));
14950 -               } else {
14951 -                       common_submit('add', _('Add'));
14952 -               }
14953 +        if ($flink) {
14954 +            common_submit('save', _('Save'));
14955 +        } else {
14956 +            common_submit('add', _('Add'));
14957 +        }
14958 hunk ./actions/twittersettings.php 87
14959 -               $this->show_twitter_subscriptions();
14960 +        $this->show_twitter_subscriptions();
14961 hunk ./actions/twittersettings.php 89
14962 -               common_element_end('form');
14963 +        common_element_end('form');
14964 hunk ./actions/twittersettings.php 91
14965 -               common_show_footer();
14966 -       }
14967 +        common_show_footer();
14968 +    }
14969 hunk ./actions/twittersettings.php 94
14970 -       function subscribed_twitter_users() {
14971 +    function subscribed_twitter_users() {
14972 hunk ./actions/twittersettings.php 96
14973 -               $current_user = common_current_user();
14974 +        $current_user = common_current_user();
14975 hunk ./actions/twittersettings.php 98
14976 -               $qry = 'SELECT user.* ' .
14977 -                       'FROM subscription ' .
14978 -                       'JOIN user ON subscription.subscribed = user.id ' .
14979 -                       'JOIN foreign_link ON foreign_link.user_id = user.id ' .
14980 -                       'WHERE subscriber = %d ' .
14981 -                       'ORDER BY user.nickname';
14982 +        $qry = 'SELECT user.* ' .
14983 +            'FROM subscription ' .
14984 +            'JOIN user ON subscription.subscribed = user.id ' .
14985 +            'JOIN foreign_link ON foreign_link.user_id = user.id ' .
14986 +            'WHERE subscriber = %d ' .
14987 +            'ORDER BY user.nickname';
14988 hunk ./actions/twittersettings.php 105
14989 -               $user = new User();
14990 +        $user = new User();
14991 hunk ./actions/twittersettings.php 107
14992 -               $user->query(sprintf($qry, $current_user->id));
14993 +        $user->query(sprintf($qry, $current_user->id));
14994 hunk ./actions/twittersettings.php 109
14995 -               $users = array();
14996 +        $users = array();
14997 hunk ./actions/twittersettings.php 111
14998 -               while ($user->fetch()) {
14999 +        while ($user->fetch()) {
15000 hunk ./actions/twittersettings.php 113
15001 -                       // Don't include the user's own self-subscription
15002 -                       if ($user->id != $current_user->id) {
15003 -                               $users[] = clone($user);
15004 -                       }
15005 -               }
15006 +            // Don't include the user's own self-subscription
15007 +            if ($user->id != $current_user->id) {
15008 +                $users[] = clone($user);
15009 +            }
15010 +        }
15011 hunk ./actions/twittersettings.php 119
15012 -               return $users;
15013 -       }
15014 +        return $users;
15015 +    }
15016 hunk ./actions/twittersettings.php 122
15017 -       function show_twitter_subscriptions() {
15018 +    function show_twitter_subscriptions() {
15019 hunk ./actions/twittersettings.php 124
15020 -               $friends = $this->subscribed_twitter_users();
15021 -               $friends_count = count($friends);
15022 +        $friends = $this->subscribed_twitter_users();
15023 +        $friends_count = count($friends);
15024 hunk ./actions/twittersettings.php 127
15025 -               if ($friends_count > 0) {
15026 +        if ($friends_count > 0) {
15027 hunk ./actions/twittersettings.php 129
15028 -                       common_element('h3', NULL, _('Twitter Friends'));
15029 -                       common_element_start('div', array('id' => 'subscriptions'));
15030 -                       common_element_start('ul', array('id' => 'subscriptions_avatars'));
15031 +            common_element('h3', NULL, _('Twitter Friends'));
15032 +            common_element_start('div', array('id' => 'subscriptions'));
15033 +            common_element_start('ul', array('id' => 'subscriptions_avatars'));
15034 hunk ./actions/twittersettings.php 133
15035 -                       for ($i = 0; $i < min($friends_count, SUBSCRIPTIONS); $i++) {
15036 +            for ($i = 0; $i < min($friends_count, SUBSCRIPTIONS); $i++) {
15037 hunk ./actions/twittersettings.php 135
15038 -                               $other = Profile::staticGet($friends[$i]->id);
15039 +                $other = Profile::staticGet($friends[$i]->id);
15040 hunk ./actions/twittersettings.php 137
15041 -                               if (!$other) {
15042 -                                       common_log_db_error($subs, 'SELECT', __FILE__);
15043 -                                       continue;
15044 -                               }
15045 +                if (!$other) {
15046 +                    common_log_db_error($subs, 'SELECT', __FILE__);
15047 +                    continue;
15048 +                }
15049 hunk ./actions/twittersettings.php 142
15050 -                               common_element_start('li');
15051 -                               common_element_start('a', array('title' => ($other->fullname) ?
15052 -                                                                                               $other->fullname :
15053 -                                                                                               $other->nickname,
15054 -                                                                                               'href' => $other->profileurl,
15055 -                                                                                               'rel' => 'contact',
15056 -                                                                                               'class' => 'subscription'));
15057 -                               $avatar = $other->getAvatar(AVATAR_MINI_SIZE);
15058 -                               common_element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) :  common_default_avatar(AVATAR_MINI_SIZE)),
15059 -                                                                                       'width' => AVATAR_MINI_SIZE,
15060 -                                                                                       'height' => AVATAR_MINI_SIZE,
15061 -                                                                                       'class' => 'avatar mini',
15062 -                                                                                       'alt' =>  ($other->fullname) ?
15063 -                                                                                       $other->fullname :
15064 -                                                                                       $other->nickname));
15065 -                               common_element_end('a');
15066 -                               common_element_end('li');
15067 +                common_element_start('li');
15068 +                common_element_start('a', array('title' => ($other->fullname) ?
15069 +                                                $other->fullname :
15070 +                                                $other->nickname,
15071 +                                                'href' => $other->profileurl,
15072 +                                                'rel' => 'contact',
15073 +                                                'class' => 'subscription'));
15074 +                $avatar = $other->getAvatar(AVATAR_MINI_SIZE);
15075 +                common_element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) :  common_default_avatar(AVATAR_MINI_SIZE)),
15076 +                                            'width' => AVATAR_MINI_SIZE,
15077 +                                            'height' => AVATAR_MINI_SIZE,
15078 +                                            'class' => 'avatar mini',
15079 +                                            'alt' =>  ($other->fullname) ?
15080 +                                            $other->fullname :
15081 +                                            $other->nickname));
15082 +                common_element_end('a');
15083 +                common_element_end('li');
15084 hunk ./actions/twittersettings.php 160
15085 -                       }
15086 +            }
15087 hunk ./actions/twittersettings.php 162
15088 -                       common_element_end('ul');
15089 -                       common_element_end('div');
15090 +            common_element_end('ul');
15091 +            common_element_end('div');
15092 hunk ./actions/twittersettings.php 165
15093 -               }
15094 +        }
15095 hunk ./actions/twittersettings.php 167
15096 -               // XXX Figure out a way to show all Twitter friends... ?
15097 +        // XXX Figure out a way to show all Twitter friends... ?
15098 hunk ./actions/twittersettings.php 169
15099 -               /*
15100 -               if ($subs_count > SUBSCRIPTIONS) {
15101 -                       common_element_start('p', array('id' => 'subscriptions_viewall'));
15102 +        /*
15103 +        if ($subs_count > SUBSCRIPTIONS) {
15104 +            common_element_start('p', array('id' => 'subscriptions_viewall'));
15105 hunk ./actions/twittersettings.php 173
15106 -                       common_element('a', array('href' => common_local_url('subscriptions',
15107 -                                                                                                                                array('nickname' => $profile->nickname)),
15108 -                                                                         'class' => 'moresubscriptions'),
15109 -                                                  _('All subscriptions'));
15110 -                       common_element_end('p');
15111 -               }
15112 -               */
15113 +            common_element('a', array('href' => common_local_url('subscriptions',
15114 +                                                                 array('nickname' => $profile->nickname)),
15115 +                                      'class' => 'moresubscriptions'),
15116 +                           _('All subscriptions'));
15117 +            common_element_end('p');
15118 +        }
15119 +        */
15120 hunk ./actions/twittersettings.php 181
15121 -       }
15122 +    }
15123 hunk ./actions/twittersettings.php 183
15124 -       function handle_post() {
15125 +    function handle_post() {
15126 hunk ./actions/twittersettings.php 185
15127 -               # CSRF protection
15128 -               $token = $this->trimmed('token');
15129 -               if (!$token || $token != common_session_token()) {
15130 -                       $this->show_form(_('There was a problem with your session token. Try again, please.'));
15131 -                       return;
15132 -               }
15133 +        # CSRF protection
15134 +        $token = $this->trimmed('token');
15135 +        if (!$token || $token != common_session_token()) {
15136 +            $this->show_form(_('There was a problem with your session token. Try again, please.'));
15137 +            return;
15138 +        }
15139 hunk ./actions/twittersettings.php 192
15140 -               if ($this->arg('save')) {
15141 -                       $this->save_preferences();
15142 -               } else if ($this->arg('add')) {
15143 -                       $this->add_twitter_acct();
15144 -               } else if ($this->arg('remove')) {
15145 -                       $this->remove_twitter_acct();
15146 -               } else {
15147 -                       $this->show_form(_('Unexpected form submission.'));
15148 -               }
15149 -       }
15150 +        if ($this->arg('save')) {
15151 +            $this->save_preferences();
15152 +        } else if ($this->arg('add')) {
15153 +            $this->add_twitter_acct();
15154 +        } else if ($this->arg('remove')) {
15155 +            $this->remove_twitter_acct();
15156 +        } else {
15157 +            $this->show_form(_('Unexpected form submission.'));
15158 +        }
15159 +    }
15160 hunk ./actions/twittersettings.php 203
15161 -       function add_twitter_acct() {
15162 +    function add_twitter_acct() {
15163 hunk ./actions/twittersettings.php 205
15164 -               $screen_name = $this->trimmed('twitter_username');
15165 -               $password = $this->trimmed('twitter_password');
15166 -               $noticesync = $this->boolean('noticesync');
15167 -               $replysync = $this->boolean('replysync');
15168 -               $friendsync = $this->boolean('friendsync');
15169 +        $screen_name = $this->trimmed('twitter_username');
15170 +        $password = $this->trimmed('twitter_password');
15171 +        $noticesync = $this->boolean('noticesync');
15172 +        $replysync = $this->boolean('replysync');
15173 +        $friendsync = $this->boolean('friendsync');
15174 hunk ./actions/twittersettings.php 211
15175 -               if (!Validate::string($screen_name,
15176 -                               array(  'min_length' => 1,
15177 -                                               'max_length' => 15,
15178 -                                               'format' => VALIDATE_NUM . VALIDATE_ALPHA . '_'))) {
15179 -                       $this->show_form(
15180 -                               _('Username must have only numbers, upper- and lowercase letters, and underscore (_). 15 chars max.'));
15181 -                       return;
15182 -               }
15183 +        if (!Validate::string($screen_name,
15184 +                array(    'min_length' => 1,
15185 +                        'max_length' => 15,
15186 +                         'format' => VALIDATE_NUM . VALIDATE_ALPHA . '_'))) {
15187 +            $this->show_form(
15188 +                _('Username must have only numbers, upper- and lowercase letters, and underscore (_). 15 chars max.'));
15189 +            return;
15190 +        }
15191 hunk ./actions/twittersettings.php 220
15192 -               if (!$this->verify_credentials($screen_name, $password)) {
15193 -                       $this->show_form(_('Could not verify your Twitter credentials!'));
15194 -                       return;
15195 -               }
15196 +        if (!$this->verify_credentials($screen_name, $password)) {
15197 +            $this->show_form(_('Could not verify your Twitter credentials!'));
15198 +            return;
15199 +        }
15200 hunk ./actions/twittersettings.php 225
15201 -               $twit_user = twitter_user_info($screen_name, $password);
15202 +        $twit_user = twitter_user_info($screen_name, $password);
15203 hunk ./actions/twittersettings.php 227
15204 -               if (!$twit_user) {
15205 -                       $this->show_form(sprintf(_('Unable to retrieve account information for "%s" from Twitter.'),
15206 -                               $screen_name));
15207 -                       return;
15208 -               }
15209 +        if (!$twit_user) {
15210 +            $this->show_form(sprintf(_('Unable to retrieve account information for "%s" from Twitter.'),
15211 +                $screen_name));
15212 +            return;
15213 +        }
15214 hunk ./actions/twittersettings.php 233
15215 -               if (!save_twitter_user($twit_user->id, $screen_name)) {
15216 -                       $this->show_form(_('Unable to save your Twitter settings!'));
15217 -                       return;
15218 -               }
15219 +        if (!save_twitter_user($twit_user->id, $screen_name)) {
15220 +            $this->show_form(_('Unable to save your Twitter settings!'));
15221 +            return;
15222 +        }
15223 hunk ./actions/twittersettings.php 238
15224 -               $user = common_current_user();
15225 +        $user = common_current_user();
15226 hunk ./actions/twittersettings.php 240
15227 -               $flink = DB_DataObject::factory('foreign_link');
15228 -               $flink->user_id = $user->id;
15229 -               $flink->foreign_id = $twit_user->id;
15230 -               $flink->service = 1; // Twitter
15231 -               $flink->credentials = $password;
15232 -               $flink->created = common_sql_now();
15233 +        $flink = DB_DataObject::factory('foreign_link');
15234 +        $flink->user_id = $user->id;
15235 +        $flink->foreign_id = $twit_user->id;
15236 +        $flink->service = 1; // Twitter
15237 +        $flink->credentials = $password;
15238 +        $flink->created = common_sql_now();
15239 hunk ./actions/twittersettings.php 247
15240 -               $this->set_flags($flink, $noticesync, $replysync, $friendsync);
15241 +        $this->set_flags($flink, $noticesync, $replysync, $friendsync);
15242 hunk ./actions/twittersettings.php 249
15243 -               $flink_id = $flink->insert();
15244 +        $flink_id = $flink->insert();
15245 hunk ./actions/twittersettings.php 251
15246 -               if (!$flink_id) {
15247 -                       common_log_db_error($flink, 'INSERT', __FILE__);
15248 -                       $this->show_form(_('Unable to save your Twitter settings!'));
15249 -                       return;
15250 -               }
15251 +        if (!$flink_id) {
15252 +            common_log_db_error($flink, 'INSERT', __FILE__);
15253 +            $this->show_form(_('Unable to save your Twitter settings!'));
15254 +            return;
15255 +        }
15256 hunk ./actions/twittersettings.php 257
15257 -               if ($friendsync) {
15258 -                       save_twitter_friends($user, $twit_user->id, $screen_name, $password);
15259 -               }
15260 +        if ($friendsync) {
15261 +            save_twitter_friends($user, $twit_user->id, $screen_name, $password);
15262 +        }
15263 hunk ./actions/twittersettings.php 261
15264 -               $this->show_form(_('Twitter settings saved.'), true);
15265 -       }
15266 +        $this->show_form(_('Twitter settings saved.'), true);
15267 +    }
15268 hunk ./actions/twittersettings.php 264
15269 -       function remove_twitter_acct() {
15270 +    function remove_twitter_acct() {
15271 hunk ./actions/twittersettings.php 266
15272 -               $user = common_current_user();
15273 -               $flink = Foreign_link::getByUserID($user->id, 1);
15274 -               $flink_foreign_id = $this->arg('flink_foreign_id');
15275 +        $user = common_current_user();
15276 +        $flink = Foreign_link::getByUserID($user->id, 1);
15277 +        $flink_foreign_id = $this->arg('flink_foreign_id');
15278 hunk ./actions/twittersettings.php 270
15279 -               # Maybe an old tab open...?
15280 -               if ($flink->foreign_id != $flink_foreign_id) {
15281 -                   $this->show_form(_('That is not your Twitter account.'));
15282 -                   return;
15283 -               }
15284 +        # Maybe an old tab open...?
15285 +        if ($flink->foreign_id != $flink_foreign_id) {
15286 +            $this->show_form(_('That is not your Twitter account.'));
15287 +            return;
15288 +        }
15289 hunk ./actions/twittersettings.php 276
15290 -               $result = $flink->delete();
15291 +        $result = $flink->delete();
15292 hunk ./actions/twittersettings.php 278
15293 -               if (!$result) {
15294 -                       common_log_db_error($flink, 'DELETE', __FILE__);
15295 -                       common_server_error(_('Couldn\'t remove Twitter user.'));
15296 -                       return;
15297 -               }
15298 +        if (!$result) {
15299 +            common_log_db_error($flink, 'DELETE', __FILE__);
15300 +            common_server_error(_('Couldn\'t remove Twitter user.'));
15301 +            return;
15302 +        }
15303 hunk ./actions/twittersettings.php 284
15304 -               $this->show_form(_('Twitter account removed.'), TRUE);
15305 -       }
15306 +        $this->show_form(_('Twitter account removed.'), TRUE);
15307 +    }
15308 hunk ./actions/twittersettings.php 287
15309 -       function save_preferences() {
15310 +    function save_preferences() {
15311 hunk ./actions/twittersettings.php 289
15312 -               $noticesync = $this->boolean('noticesync');
15313 -               $friendsync = $this->boolean('friendsync');
15314 -               $replysync = $this->boolean('replysync');
15315 +        $noticesync = $this->boolean('noticesync');
15316 +        $friendsync = $this->boolean('friendsync');
15317 +        $replysync = $this->boolean('replysync');
15318 hunk ./actions/twittersettings.php 293
15319 -               $user = common_current_user();
15320 +        $user = common_current_user();
15321 hunk ./actions/twittersettings.php 295
15322 -               $flink = Foreign_link::getByUserID($user->id, 1);
15323 +        $flink = Foreign_link::getByUserID($user->id, 1);
15324 hunk ./actions/twittersettings.php 297
15325 -               if (!$flink) {
15326 -                       common_log_db_error($flink, 'SELECT', __FILE__);
15327 -                       $this->show_form(_('Couldn\'t save Twitter preferences.'));
15328 -                       return;
15329 -               }
15330 +        if (!$flink) {
15331 +            common_log_db_error($flink, 'SELECT', __FILE__);
15332 +            $this->show_form(_('Couldn\'t save Twitter preferences.'));
15333 +            return;
15334 +        }
15335 hunk ./actions/twittersettings.php 303
15336 -               $twitter_id = $flink->foreign_id;
15337 -               $password = $flink->credentials;
15338 +        $twitter_id = $flink->foreign_id;
15339 +        $password = $flink->credentials;
15340 hunk ./actions/twittersettings.php 306
15341 -               $fuser = $flink->getForeignUser();
15342 +        $fuser = $flink->getForeignUser();
15343 hunk ./actions/twittersettings.php 308
15344 -               if (!$fuser) {
15345 -                       common_log_db_error($fuser, 'SELECT', __FILE__);
15346 -                       $this->show_form(_('Couldn\'t save Twitter preferences.'));
15347 -                       return;
15348 -               }
15349 +        if (!$fuser) {
15350 +            common_log_db_error($fuser, 'SELECT', __FILE__);
15351 +            $this->show_form(_('Couldn\'t save Twitter preferences.'));
15352 +            return;
15353 +        }
15354 hunk ./actions/twittersettings.php 314
15355 -               $screen_name = $fuser->nickname;
15356 +        $screen_name = $fuser->nickname;
15357 hunk ./actions/twittersettings.php 316
15358 -               $original = clone($flink);
15359 -               $this->set_flags($flink, $noticesync, $replysync, $friendsync);
15360 -               $result = $flink->update($original);
15361 +        $original = clone($flink);
15362 +        $this->set_flags($flink, $noticesync, $replysync, $friendsync);
15363 +        $result = $flink->update($original);
15364 hunk ./actions/twittersettings.php 320
15365 -               if ($result === FALSE) {
15366 -                       common_log_db_error($flink, 'UPDATE', __FILE__);
15367 -                       $this->show_form(_('Couldn\'t save Twitter preferences.'));
15368 -                       return;
15369 -               }
15370 +        if ($result === FALSE) {
15371 +            common_log_db_error($flink, 'UPDATE', __FILE__);
15372 +            $this->show_form(_('Couldn\'t save Twitter preferences.'));
15373 +            return;
15374 +        }
15375 hunk ./actions/twittersettings.php 326
15376 -               if ($friendsync) {
15377 -                       save_twitter_friends($user, $flink->foreign_id, $screen_name, $password);
15378 -               }
15379 +        if ($friendsync) {
15380 +            save_twitter_friends($user, $flink->foreign_id, $screen_name, $password);
15381 +        }
15382 hunk ./actions/twittersettings.php 330
15383 -               $this->show_form(_('Twitter preferences saved.'));
15384 -       }
15385 +        $this->show_form(_('Twitter preferences saved.'));
15386 +    }
15387 hunk ./actions/twittersettings.php 333
15388 -       function verify_credentials($screen_name, $password) {
15389 -               $uri = 'http://twitter.com/account/verify_credentials.json';
15390 -               $data = get_twitter_data($uri, $screen_name, $password);
15391 +    function verify_credentials($screen_name, $password) {
15392 +        $uri = 'http://twitter.com/account/verify_credentials.json';
15393 +        $data = get_twitter_data($uri, $screen_name, $password);
15394 hunk ./actions/twittersettings.php 337
15395 -               if (!$data) {
15396 -                       return false;
15397 -               }
15398 +        if (!$data) {
15399 +            return false;
15400 +        }
15401 hunk ./actions/twittersettings.php 341
15402 -               $user = json_decode($data);
15403 +        $user = json_decode($data);
15404 hunk ./actions/twittersettings.php 343
15405 -               if (!$user) {
15406 -                       return false;
15407 -               }
15408 +        if (!$user) {
15409 +            return false;
15410 +        }
15411 hunk ./actions/twittersettings.php 347
15412 -               $twitter_id = $user->status->id;
15413 +         $twitter_id = $user->status->id;
15414 hunk ./actions/twittersettings.php 349
15415 -               if ($twitter_id) {
15416 -                       return $twitter_id;
15417 -               }
15418 +        if ($twitter_id) {
15419 +            return $twitter_id;
15420 +        }
15421 hunk ./actions/twittersettings.php 353
15422 -               return false;
15423 -       }
15424 +        return false;
15425 +    }
15426 hunk ./actions/twittersettings.php 356
15427 -       function set_flags(&$flink, $noticesync, $replysync, $friendsync) {
15428 -               if ($noticesync) {
15429 -                       $flink->noticesync |= FOREIGN_NOTICE_SEND;
15430 -               } else {
15431 -                       $flink->noticesync &= ~FOREIGN_NOTICE_SEND;
15432 -               }
15433 +    function set_flags(&$flink, $noticesync, $replysync, $friendsync) {
15434 +        if ($noticesync) {
15435 +            $flink->noticesync |= FOREIGN_NOTICE_SEND;
15436 +        } else {
15437 +            $flink->noticesync &= ~FOREIGN_NOTICE_SEND;
15438 +        }
15439 hunk ./actions/twittersettings.php 363
15440 -               if ($replysync) {
15441 -                       $flink->noticesync |= FOREIGN_NOTICE_SEND_REPLY;
15442 -               } else {
15443 -                       $flink->noticesync &= ~FOREIGN_NOTICE_SEND_REPLY;
15444 -               }
15445 +        if ($replysync) {
15446 +            $flink->noticesync |= FOREIGN_NOTICE_SEND_REPLY;
15447 +        } else {
15448 +            $flink->noticesync &= ~FOREIGN_NOTICE_SEND_REPLY;
15449 +        }
15450 hunk ./actions/twittersettings.php 369
15451 -               if ($friendsync) {
15452 -                       $flink->friendsync |= FOREIGN_FRIEND_RECV;
15453 -               } else {
15454 -                       $flink->friendsync &= ~FOREIGN_FRIEND_RECV;
15455 -               }
15456 +        if ($friendsync) {
15457 +            $flink->friendsync |= FOREIGN_FRIEND_RECV;
15458 +        } else {
15459 +            $flink->friendsync &= ~FOREIGN_FRIEND_RECV;
15460 +        }
15461 hunk ./actions/twittersettings.php 375
15462 -               $flink->profilesync = 0;
15463 -       }
15464 +        $flink->profilesync = 0;
15465 +    }
15466 hunk ./actions/unblock.php 35
15467 -               $token = $this->trimmed('token');
15468 +        $token = $this->trimmed('token');
15469 hunk ./actions/unblock.php 37
15470 -               if (!$token || $token != common_session_token()) {
15471 -                       $this->client_error(_('There was a problem with your session token. Try again, please.'));
15472 -                       return;
15473 -               }
15474 +        if (!$token || $token != common_session_token()) {
15475 +            $this->client_error(_('There was a problem with your session token. Try again, please.'));
15476 +            return;
15477 +        }
15478 hunk ./actions/unsubscribe.php 22
15479 -       function handle($args) {
15480 -               parent::handle($args);
15481 -               if (!common_logged_in()) {
15482 -                       common_user_error(_('Not logged in.'));
15483 -                       return;
15484 -               }
15485 +    function handle($args) {
15486 +        parent::handle($args);
15487 +        if (!common_logged_in()) {
15488 +            common_user_error(_('Not logged in.'));
15489 +            return;
15490 +        }
15491 hunk ./actions/unsubscribe.php 29
15492 -               $user = common_current_user();
15493 +        $user = common_current_user();
15494 hunk ./actions/unsubscribe.php 31
15495 -               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
15496 -                       common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)));
15497 -                       return;
15498 -               }
15499 +        if ($_SERVER['REQUEST_METHOD'] != 'POST') {
15500 +            common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname)));
15501 +            return;
15502 +        }
15503 hunk ./actions/unsubscribe.php 36
15504 -               # CSRF protection
15505 +        # CSRF protection
15506 hunk ./actions/unsubscribe.php 38
15507 -               $token = $this->trimmed('token');
15508 +        $token = $this->trimmed('token');
15509 hunk ./actions/unsubscribe.php 40
15510 -               if (!$token || $token != common_session_token()) {
15511 -                       $this->client_error(_('There was a problem with your session token. Try again, please.'));
15512 -                       return;
15513 -               }
15514 +        if (!$token || $token != common_session_token()) {
15515 +            $this->client_error(_('There was a problem with your session token. Try again, please.'));
15516 +            return;
15517 +        }
15518 hunk ./actions/unsubscribe.php 45
15519 -               $other_id = $this->arg('unsubscribeto');
15520 +        $other_id = $this->arg('unsubscribeto');
15521 hunk ./actions/unsubscribe.php 59
15522 -               $result = subs_unsubscribe_to($user, $other);
15523 +        $result = subs_unsubscribe_to($user, $other);
15524 hunk ./actions/unsubscribe.php 61
15525 -               if ($result != true) {
15526 -                       common_user_error($result);
15527 -                       return;
15528 -               }
15529 +        if ($result != true) {
15530 +            common_user_error($result);
15531 +            return;
15532 +        }
15533 hunk ./actions/unsubscribe.php 66
15534 -               if ($this->boolean('ajax')) {
15535 -                       common_start_html('text/xml;charset=utf-8', true);
15536 -                       common_element_start('head');
15537 -                       common_element('title', null, _('Unsubscribed'));
15538 -                       common_element_end('head');
15539 -                       common_element_start('body');
15540 -                       common_subscribe_form($other);
15541 -                       common_element_end('body');
15542 -                       common_element_end('html');
15543 -               } else {
15544 -               common_redirect(common_local_url('subscriptions', array('nickname' =>
15545 -                                                                                                                               $user->nickname)));
15546 +        if ($this->boolean('ajax')) {
15547 +            common_start_html('text/xml;charset=utf-8', true);
15548 +            common_element_start('head');
15549 +            common_element('title', null, _('Unsubscribed'));
15550 +            common_element_end('head');
15551 +            common_element_start('body');
15552 +            common_subscribe_form($other);
15553 +            common_element_end('body');
15554 +            common_element_end('html');
15555 +        } else {
15556 +            common_redirect(common_local_url('subscriptions', array('nickname' =>
15557 +                                                                    $user->nickname)));
15558 hunk ./actions/unsubscribe.php 79
15559 -       }
15560 +    }
15561 hunk ./actions/updateprofile.php 25
15562 -       
15563 -       function handle($args) {
15564 -               parent::handle($args);
15565 -               try {
15566 -                       common_remove_magic_from_request();
15567 -                       $req = OAuthRequest::from_request();
15568 -                       # Note: server-to-server function!
15569 -                       $server = omb_oauth_server();
15570 -                       list($consumer, $token) = $server->verify_request($req);
15571 -                       if ($this->update_profile($req, $consumer, $token)) {
15572 -                               print "omb_version=".OMB_VERSION_01;
15573 -                       }
15574 -               } catch (OAuthException $e) {
15575 -                       $this->server_error($e->getMessage());
15576 -                       return;
15577 -               }
15578 -       }
15579 +    
15580 +    function handle($args) {
15581 +        parent::handle($args);
15582 +        try {
15583 +            common_remove_magic_from_request();
15584 +            $req = OAuthRequest::from_request();
15585 +            # Note: server-to-server function!
15586 +            $server = omb_oauth_server();
15587 +            list($consumer, $token) = $server->verify_request($req);
15588 +            if ($this->update_profile($req, $consumer, $token)) {
15589 +                print "omb_version=".OMB_VERSION_01;
15590 +            }
15591 +        } catch (OAuthException $e) {
15592 +            $this->server_error($e->getMessage());
15593 +            return;
15594 +        }
15595 +    }
15596 hunk ./actions/updateprofile.php 43
15597 -       function update_profile($req, $consumer, $token) {
15598 -               $version = $req->get_parameter('omb_version');
15599 -               if ($version != OMB_VERSION_01) {
15600 -                       $this->client_error(_('Unsupported OMB version'), 400);
15601 -                       return false;
15602 -               }
15603 -               # First, check to see if listenee exists
15604 -               $listenee =  $req->get_parameter('omb_listenee');
15605 -               $remote = Remote_profile::staticGet('uri', $listenee);
15606 -               if (!$remote) {
15607 -                       $this->client_error(_('Profile unknown'), 404);
15608 -                       return false;
15609 -               }
15610 -               # Second, check to see if they should be able to post updates!
15611 -               # We see if there are any subscriptions to that remote user with
15612 -               # the given token.
15613 +    function update_profile($req, $consumer, $token) {
15614 +        $version = $req->get_parameter('omb_version');
15615 +        if ($version != OMB_VERSION_01) {
15616 +            $this->client_error(_('Unsupported OMB version'), 400);
15617 +            return false;
15618 +        }
15619 +        # First, check to see if listenee exists
15620 +        $listenee =  $req->get_parameter('omb_listenee');
15621 +        $remote = Remote_profile::staticGet('uri', $listenee);
15622 +        if (!$remote) {
15623 +            $this->client_error(_('Profile unknown'), 404);
15624 +            return false;
15625 +        }
15626 +        # Second, check to see if they should be able to post updates!
15627 +        # We see if there are any subscriptions to that remote user with
15628 +        # the given token.
15629 hunk ./actions/updateprofile.php 60
15630 -               $sub = new Subscription();
15631 -               $sub->subscribed = $remote->id;
15632 -               $sub->token = $token->key;
15633 -               if (!$sub->find(true)) {
15634 -                       $this->client_error(_('You did not send us that profile'), 403);
15635 -                       return false;
15636 -               }
15637 +        $sub = new Subscription();
15638 +        $sub->subscribed = $remote->id;
15639 +        $sub->token = $token->key;
15640 +        if (!$sub->find(true)) {
15641 +            $this->client_error(_('You did not send us that profile'), 403);
15642 +            return false;
15643 +        }
15644 hunk ./actions/updateprofile.php 68
15645 -               $profile = Profile::staticGet('id', $remote->id);
15646 -               if (!$profile) {
15647 -                       # This one is our fault
15648 -                       $this->server_error(_('Remote profile with no matching profile'), 500);
15649 -                       return false;
15650 -               }
15651 -               $nickname = $req->get_parameter('omb_listenee_nickname');
15652 -               if ($nickname && !Validate::string($nickname, array('min_length' => 1,
15653 -                                                                                                                       'max_length' => 64,
15654 -                                                                                                                       'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
15655 -                       $this->client_error(_('Nickname must have only lowercase letters and numbers and no spaces.'));
15656 -                       return false;
15657 -               }
15658 -               $license = $req->get_parameter('omb_listenee_license');
15659 -               if ($license && !common_valid_http_url($license)) {
15660 -                       $this->client_error(sprintf(_("Invalid license URL '%s'"), $license));
15661 -                       return false;
15662 -               }
15663 -               $profile_url = $req->get_parameter('omb_listenee_profile');
15664 -               if ($profile_url && !common_valid_http_url($profile_url)) {
15665 -                       $this->client_error(sprintf(_("Invalid profile URL '%s'."), $profile_url));
15666 -                       return false;
15667 -               }
15668 -               # optional stuff
15669 -               $fullname = $req->get_parameter('omb_listenee_fullname');
15670 -               if ($fullname && strlen($fullname) > 255) {
15671 -                       $this->client_error(_("Full name is too long (max 255 chars)."));
15672 -                       return false;
15673 -               }
15674 -               $homepage = $req->get_parameter('omb_listenee_homepage');
15675 -               if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) {
15676 -                       $this->client_error(sprintf(_("Invalid homepage '%s'"), $homepage));
15677 -                       return false;
15678 -               }
15679 -               $bio = $req->get_parameter('omb_listenee_bio');
15680 -               if ($bio && strlen($bio) > 140) {
15681 -                       $this->client_error(_("Bio is too long (max 140 chars)."));
15682 -                       return false;
15683 -               }
15684 -               $location = $req->get_parameter('omb_listenee_location');
15685 -               if ($location && strlen($location) > 255) {
15686 -                       $this->client_error(_("Location is too long (max 255 chars)."));
15687 -                       return false;
15688 -               }
15689 -               $avatar = $req->get_parameter('omb_listenee_avatar');
15690 -               if ($avatar) {
15691 -                       if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
15692 -                               $this->client_error(sprintf(_("Invalid avatar URL '%s'"), $avatar));
15693 -                               return false;
15694 -                       }
15695 -                       $size = @getimagesize($avatar);
15696 -                       if (!$size) {
15697 -                               $this->client_error(sprintf(_("Can't read avatar URL '%s'"), $avatar));
15698 -                               return false;
15699 -                       }
15700 -                       if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
15701 -                               $this->client_error(sprintf(_("Wrong size image at '%s'"), $avatar));
15702 -                               return false;
15703 -                       }
15704 -                       if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
15705 -                                                                                 IMAGETYPE_PNG))) {
15706 -                               $this->client_error(sprintf(_("Wrong image type for '%s'"), $avatar));
15707 -                               return false;
15708 -                       }
15709 -               }
15710 +        $profile = Profile::staticGet('id', $remote->id);
15711 +        if (!$profile) {
15712 +            # This one is our fault
15713 +            $this->server_error(_('Remote profile with no matching profile'), 500);
15714 +            return false;
15715 +        }
15716 +        $nickname = $req->get_parameter('omb_listenee_nickname');
15717 +        if ($nickname && !Validate::string($nickname, array('min_length' => 1,
15718 +                                                            'max_length' => 64,
15719 +                                                            'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
15720 +            $this->client_error(_('Nickname must have only lowercase letters and numbers and no spaces.'));
15721 +            return false;
15722 +        }
15723 +        $license = $req->get_parameter('omb_listenee_license');
15724 +        if ($license && !common_valid_http_url($license)) {
15725 +            $this->client_error(sprintf(_("Invalid license URL '%s'"), $license));
15726 +            return false;
15727 +        }
15728 +        $profile_url = $req->get_parameter('omb_listenee_profile');
15729 +        if ($profile_url && !common_valid_http_url($profile_url)) {
15730 +            $this->client_error(sprintf(_("Invalid profile URL '%s'."), $profile_url));
15731 +            return false;
15732 +        }
15733 +        # optional stuff
15734 +        $fullname = $req->get_parameter('omb_listenee_fullname');
15735 +        if ($fullname && strlen($fullname) > 255) {
15736 +            $this->client_error(_("Full name is too long (max 255 chars)."));
15737 +            return false;
15738 +        }
15739 +        $homepage = $req->get_parameter('omb_listenee_homepage');
15740 +        if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) {
15741 +            $this->client_error(sprintf(_("Invalid homepage '%s'"), $homepage));
15742 +            return false;
15743 +        }
15744 +        $bio = $req->get_parameter('omb_listenee_bio');
15745 +        if ($bio && strlen($bio) > 140) {
15746 +            $this->client_error(_("Bio is too long (max 140 chars)."));
15747 +            return false;
15748 +        }
15749 +        $location = $req->get_parameter('omb_listenee_location');
15750 +        if ($location && strlen($location) > 255) {
15751 +            $this->client_error(_("Location is too long (max 255 chars)."));
15752 +            return false;
15753 +        }
15754 +        $avatar = $req->get_parameter('omb_listenee_avatar');
15755 +        if ($avatar) {
15756 +            if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
15757 +                $this->client_error(sprintf(_("Invalid avatar URL '%s'"), $avatar));
15758 +                return false;
15759 +            }
15760 +            $size = @getimagesize($avatar);
15761 +            if (!$size) {
15762 +                $this->client_error(sprintf(_("Can't read avatar URL '%s'"), $avatar));
15763 +                return false;
15764 +            }
15765 +            if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
15766 +                $this->client_error(sprintf(_("Wrong size image at '%s'"), $avatar));
15767 +                return false;
15768 +            }
15769 +            if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
15770 +                                          IMAGETYPE_PNG))) {
15771 +                $this->client_error(sprintf(_("Wrong image type for '%s'"), $avatar));
15772 +                return false;
15773 +            }
15774 +        }
15775 hunk ./actions/updateprofile.php 134
15776 -               $orig_profile = clone($profile);
15777 +        $orig_profile = clone($profile);
15778 hunk ./actions/updateprofile.php 136
15779 -               if ($nickname) {
15780 -                       $profile->nickname = $nickname;
15781 -               }
15782 -               if ($profile_url) {
15783 -                       $profile->profileurl = $profile_url;
15784 -               }
15785 -               if ($fullname) {
15786 -                       $profile->fullname = $fullname;
15787 -               }
15788 -               if ($homepage) {
15789 -                       $profile->homepage = $homepage;
15790 -               }
15791 -               if ($bio) {
15792 -                       $profile->bio = $bio;
15793 -               }
15794 -               if ($location) {
15795 -                       $profile->location = $location;
15796 -               }
15797 +        if ($nickname) {
15798 +            $profile->nickname = $nickname;
15799 +        }
15800 +        if ($profile_url) {
15801 +            $profile->profileurl = $profile_url;
15802 +        }
15803 +        if ($fullname) {
15804 +            $profile->fullname = $fullname;
15805 +        }
15806 +        if ($homepage) {
15807 +            $profile->homepage = $homepage;
15808 +        }
15809 +        if ($bio) {
15810 +            $profile->bio = $bio;
15811 +        }
15812 +        if ($location) {
15813 +            $profile->location = $location;
15814 +        }
15815 hunk ./actions/updateprofile.php 155
15816 -               if (!$profile->update($orig_profile)) {
15817 -                       $this->server_error(_('Could not save new profile info'), 500);
15818 -                       return false;
15819 -               } else {
15820 -                       if ($avatar) {
15821 -                               $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
15822 -                               copy($avatar, $temp_filename);
15823 -                               if (!$profile->setOriginal($temp_filename)) {
15824 -                                       $this->server_error(_('Could not save avatar info'), 500);
15825 -                                       return false;
15826 -                               }
15827 -                       }
15828 -                       header('HTTP/1.1 200 OK');
15829 -                       header('Content-type: text/plain');
15830 -                       print 'Updated profile';
15831 -                       print "\n";
15832 -                       return true;
15833 -               }
15834 -       }
15835 +        if (!$profile->update($orig_profile)) {
15836 +            $this->server_error(_('Could not save new profile info'), 500);
15837 +            return false;
15838 +        } else {
15839 +            if ($avatar) {
15840 +                $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
15841 +                copy($avatar, $temp_filename);
15842 +                if (!$profile->setOriginal($temp_filename)) {
15843 +                    $this->server_error(_('Could not save avatar info'), 500);
15844 +                    return false;
15845 +                }
15846 +            }
15847 +            header('HTTP/1.1 200 OK');
15848 +            header('Content-type: text/plain');
15849 +            print 'Updated profile';
15850 +            print "\n";
15851 +            return true;
15852 +        }
15853 +    }
15854 hunk ./actions/userauthorization.php 27
15855 -       function handle($args) {
15856 -               parent::handle($args);
15857 +    function handle($args) {
15858 +        parent::handle($args);
15859 hunk ./actions/userauthorization.php 30
15860 -               if ($_SERVER['REQUEST_METHOD'] == 'POST') {
15861 -                       # CSRF protection
15862 -                       $token = $this->trimmed('token');
15863 -                       if (!$token || $token != common_session_token()) {
15864 -                               $req = $this->get_stored_request();
15865 -                               $this->show_form(_('There was a problem with your session token. Try again, please.'), $req);
15866 -                               return;
15867 -                       }
15868 -                       # We've shown the form, now post user's choice
15869 -                       $this->send_authorization();
15870 -               } else {
15871 -                       if (!common_logged_in()) {
15872 -                               # Go log in, and then come back
15873 -                               common_debug('saving URL for returnto', __FILE__);
15874 -                               common_set_returnto($_SERVER['REQUEST_URI']);
15875 +        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
15876 +            # CSRF protection
15877 +            $token = $this->trimmed('token');
15878 +            if (!$token || $token != common_session_token()) {
15879 +                $req = $this->get_stored_request();
15880 +                $this->show_form(_('There was a problem with your session token. Try again, please.'), $req);
15881 +                return;
15882 +            }
15883 +            # We've shown the form, now post user's choice
15884 +            $this->send_authorization();
15885 +        } else {
15886 +            if (!common_logged_in()) {
15887 +                # Go log in, and then come back
15888 +                common_debug('saving URL for returnto', __FILE__);
15889 +                common_set_returnto($_SERVER['REQUEST_URI']);
15890 hunk ./actions/userauthorization.php 46
15891 -                               common_debug('redirecting to login', __FILE__);
15892 -                               common_redirect(common_local_url('login'));
15893 -                               return;
15894 -                       }
15895 -                       try {
15896 -                               # this must be a new request
15897 -                               common_debug('getting new request', __FILE__);
15898 -                               $req = $this->get_new_request();
15899 -                               if (!$req) {
15900 -                                       $this->client_error(_('No request found!'));
15901 -                               }
15902 -                               common_debug('validating request', __FILE__);
15903 -                               # XXX: only validate new requests, since nonce is one-time use
15904 -                               $this->validate_request($req);
15905 -                               common_debug('showing form', __FILE__);
15906 -                               $this->store_request($req);
15907 -                               $this->show_form($req);
15908 -                       } catch (OAuthException $e) {
15909 -                               $this->clear_request();
15910 -                               $this->client_error($e->getMessage());
15911 -                               return;
15912 -                       }
15913 +                common_debug('redirecting to login', __FILE__);
15914 +                common_redirect(common_local_url('login'));
15915 +                return;
15916 +            }
15917 +            try {
15918 +                # this must be a new request
15919 +                common_debug('getting new request', __FILE__);
15920 +                $req = $this->get_new_request();
15921 +                if (!$req) {
15922 +                    $this->client_error(_('No request found!'));
15923 +                }
15924 +                common_debug('validating request', __FILE__);
15925 +                # XXX: only validate new requests, since nonce is one-time use
15926 +                $this->validate_request($req);
15927 +                common_debug('showing form', __FILE__);
15928 +                $this->store_request($req);
15929 +                $this->show_form($req);
15930 +            } catch (OAuthException $e) {
15931 +                $this->clear_request();
15932 +                $this->client_error($e->getMessage());
15933 +                return;
15934 +            }
15935 hunk ./actions/userauthorization.php 69
15936 -               }
15937 -       }
15938 +        }
15939 +    }
15940 hunk ./actions/userauthorization.php 72
15941 -       function show_form($req) {
15942 +    function show_form($req) {
15943 hunk ./actions/userauthorization.php 74
15944 -               $nickname = $req->get_parameter('omb_listenee_nickname');
15945 -               $profile = $req->get_parameter('omb_listenee_profile');
15946 -               $license = $req->get_parameter('omb_listenee_license');
15947 -               $fullname = $req->get_parameter('omb_listenee_fullname');
15948 -               $homepage = $req->get_parameter('omb_listenee_homepage');
15949 -               $bio = $req->get_parameter('omb_listenee_bio');
15950 -               $location = $req->get_parameter('omb_listenee_location');
15951 -               $avatar = $req->get_parameter('omb_listenee_avatar');
15952 +        $nickname = $req->get_parameter('omb_listenee_nickname');
15953 +        $profile = $req->get_parameter('omb_listenee_profile');
15954 +        $license = $req->get_parameter('omb_listenee_license');
15955 +        $fullname = $req->get_parameter('omb_listenee_fullname');
15956 +        $homepage = $req->get_parameter('omb_listenee_homepage');
15957 +        $bio = $req->get_parameter('omb_listenee_bio');
15958 +        $location = $req->get_parameter('omb_listenee_location');
15959 +        $avatar = $req->get_parameter('omb_listenee_avatar');
15960 hunk ./actions/userauthorization.php 83
15961 -               common_show_header(_('Authorize subscription'));
15962 -               common_element('p', NULL, _('Please check these details to make sure '.
15963 -                                                                        'that you want to subscribe to this user\'s notices. '.
15964 -                                                                        'If you didn\'t just ask to subscribe to someone\'s notices, '.
15965 -                                                                        'click "Cancel".'));
15966 -               common_element_start('div', 'profile');
15967 -               if ($avatar) {
15968 -                       common_element('img', array('src' => $avatar,
15969 -                                                                               'class' => 'avatar profile',
15970 -                                                                               'width' => AVATAR_PROFILE_SIZE,
15971 -                                                                               'height' => AVATAR_PROFILE_SIZE,
15972 -                                                                               'alt' => $nickname));
15973 -               }
15974 -               common_element('a', array('href' => $profile,
15975 -                                                                 'class' => 'external profile nickname'),
15976 -                                          $nickname);
15977 -               if ($fullname) {
15978 -                       common_element_start('div', 'fullname');
15979 -                       if ($homepage) {
15980 -                               common_element('a', array('href' => $homepage),
15981 -                                                          $fullname);
15982 -                       } else {
15983 -                               common_text($fullname);
15984 -                       }
15985 -                       common_element_end('div');
15986 -               }
15987 -               if ($location) {
15988 -                       common_element('div', 'location', $location);
15989 -               }
15990 -               if ($bio) {
15991 -                       common_element('div', 'bio', $bio);
15992 -               }
15993 -               common_element_start('div', 'license');
15994 -               common_element('a', array('href' => $license,
15995 -                                                                 'class' => 'license'),
15996 -                                          $license);
15997 -               common_element_end('div');
15998 -               common_element_end('div');
15999 -               common_element_start('form', array('method' => 'post',
16000 -                                                                                  'id' => 'userauthorization',
16001 -                                                                                  'name' => 'userauthorization',
16002 -                                                                                  'action' => common_local_url('userauthorization')));
16003 -               common_hidden('token', common_session_token());
16004 -               common_submit('accept', _('Accept'));
16005 -               common_submit('reject', _('Reject'));
16006 -               common_element_end('form');
16007 -               common_show_footer();
16008 -       }
16009 +        common_show_header(_('Authorize subscription'));
16010 +        common_element('p', NULL, _('Please check these details to make sure '.
16011 +                                     'that you want to subscribe to this user\'s notices. '.
16012 +                                     'If you didn\'t just ask to subscribe to someone\'s notices, '.
16013 +                                     'click "Cancel".'));
16014 +        common_element_start('div', 'profile');
16015 +        if ($avatar) {
16016 +            common_element('img', array('src' => $avatar,
16017 +                                        'class' => 'avatar profile',
16018 +                                        'width' => AVATAR_PROFILE_SIZE,
16019 +                                        'height' => AVATAR_PROFILE_SIZE,
16020 +                                        'alt' => $nickname));
16021 +        }
16022 +        common_element('a', array('href' => $profile,
16023 +                                  'class' => 'external profile nickname'),
16024 +                       $nickname);
16025 +        if ($fullname) {
16026 +            common_element_start('div', 'fullname');
16027 +            if ($homepage) {
16028 +                common_element('a', array('href' => $homepage),
16029 +                               $fullname);
16030 +            } else {
16031 +                common_text($fullname);
16032 +            }
16033 +            common_element_end('div');
16034 +        }
16035 +        if ($location) {
16036 +            common_element('div', 'location', $location);
16037 +        }
16038 +        if ($bio) {
16039 +            common_element('div', 'bio', $bio);
16040 +        }
16041 +        common_element_start('div', 'license');
16042 +        common_element('a', array('href' => $license,
16043 +                                  'class' => 'license'),
16044 +                       $license);
16045 +        common_element_end('div');
16046 +        common_element_end('div');
16047 +        common_element_start('form', array('method' => 'post',
16048 +                                           'id' => 'userauthorization',
16049 +                                           'name' => 'userauthorization',
16050 +                                           'action' => common_local_url('userauthorization')));
16051 +        common_hidden('token', common_session_token());
16052 +        common_submit('accept', _('Accept'));
16053 +        common_submit('reject', _('Reject'));
16054 +        common_element_end('form');
16055 +        common_show_footer();
16056 +    }
16057 hunk ./actions/userauthorization.php 132
16058 -       function send_authorization() {
16059 -               $req = $this->get_stored_request();
16060 +    function send_authorization() {
16061 +        $req = $this->get_stored_request();
16062 hunk ./actions/userauthorization.php 135
16063 -               if (!$req) {
16064 -                       common_user_error(_('No authorization request!'));
16065 -                       return;
16066 -               }
16067 +        if (!$req) {
16068 +            common_user_error(_('No authorization request!'));
16069 +            return;
16070 +        }
16071 hunk ./actions/userauthorization.php 140
16072 -               $callback = $req->get_parameter('oauth_callback');
16073 +        $callback = $req->get_parameter('oauth_callback');
16074 hunk ./actions/userauthorization.php 142
16075 -               if ($this->arg('accept')) {
16076 -                       if (!$this->authorize_token($req)) {
16077 -                               $this->client_error(_('Error authorizing token'));
16078 -                       }
16079 -                       if (!$this->save_remote_profile($req)) {
16080 -                               $this->client_error(_('Error saving remote profile'));
16081 -                       }
16082 -                       if (!$callback) {
16083 -                               $this->show_accept_message($req->get_parameter('oauth_token'));
16084 -                       } else {
16085 -                               $params = array();
16086 -                               $params['oauth_token'] = $req->get_parameter('oauth_token');
16087 -                               $params['omb_version'] = OMB_VERSION_01;
16088 -                               $user = User::staticGet('uri', $req->get_parameter('omb_listener'));
16089 -                               $profile = $user->getProfile();
16090 -                               if (!$profile) {
16091 -                                       common_log_db_error($user, 'SELECT', __FILE__);
16092 -                                       $this->server_error(_('User without matching profile'));
16093 -                                       return;
16094 -                               }
16095 -                               $params['omb_listener_nickname'] = $user->nickname;
16096 -                               $params['omb_listener_profile'] = common_local_url('showstream',
16097 -                                                                                                                                  array('nickname' => $user->nickname));
16098 -                               if ($profile->fullname) {
16099 -                                       $params['omb_listener_fullname'] = $profile->fullname;
16100 -                               }
16101 -                               if ($profile->homepage) {
16102 -                                       $params['omb_listener_homepage'] = $profile->homepage;
16103 -                               }
16104 -                               if ($profile->bio) {
16105 -                                       $params['omb_listener_bio'] = $profile->bio;
16106 -                               }
16107 -                               if ($profile->location) {
16108 -                                       $params['omb_listener_location'] = $profile->location;
16109 -                               }
16110 -                               $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
16111 -                               if ($avatar) {
16112 -                                       $params['omb_listener_avatar'] = $avatar->url;
16113 -                               }
16114 -                               $parts = array();
16115 -                               foreach ($params as $k => $v) {
16116 -                                       $parts[] = $k . '=' . OAuthUtil::urlencodeRFC3986($v);
16117 -                               }
16118 -                               $query_string = implode('&', $parts);
16119 -                               $parsed = parse_url($callback);
16120 -                               $url = $callback . (($parsed['query']) ? '&' : '?') . $query_string;
16121 -                               common_redirect($url, 303);
16122 -                       }
16123 -               } else {
16124 -                       if (!$callback) {
16125 -                               $this->show_reject_message();
16126 -                       } else {
16127 -                               # XXX: not 100% sure how to signal failure... just redirect without token?
16128 -                               common_redirect($callback, 303);
16129 -                       }
16130 -               }
16131 -       }
16132 +        if ($this->arg('accept')) {
16133 +            if (!$this->authorize_token($req)) {
16134 +                $this->client_error(_('Error authorizing token'));
16135 +            }
16136 +            if (!$this->save_remote_profile($req)) {
16137 +                $this->client_error(_('Error saving remote profile'));
16138 +            }
16139 +            if (!$callback) {
16140 +                $this->show_accept_message($req->get_parameter('oauth_token'));
16141 +            } else {
16142 +                $params = array();
16143 +                $params['oauth_token'] = $req->get_parameter('oauth_token');
16144 +                $params['omb_version'] = OMB_VERSION_01;
16145 +                $user = User::staticGet('uri', $req->get_parameter('omb_listener'));
16146 +                $profile = $user->getProfile();
16147 +                if (!$profile) {
16148 +                    common_log_db_error($user, 'SELECT', __FILE__);
16149 +                    $this->server_error(_('User without matching profile'));
16150 +                    return;
16151 +                }
16152 +                $params['omb_listener_nickname'] = $user->nickname;
16153 +                $params['omb_listener_profile'] = common_local_url('showstream',
16154 +                                                                   array('nickname' => $user->nickname));
16155 +                if ($profile->fullname) {
16156 +                    $params['omb_listener_fullname'] = $profile->fullname;
16157 +                }
16158 +                if ($profile->homepage) {
16159 +                    $params['omb_listener_homepage'] = $profile->homepage;
16160 +                }
16161 +                if ($profile->bio) {
16162 +                    $params['omb_listener_bio'] = $profile->bio;
16163 +                }
16164 +                if ($profile->location) {
16165 +                    $params['omb_listener_location'] = $profile->location;
16166 +                }
16167 +                $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
16168 +                if ($avatar) {
16169 +                    $params['omb_listener_avatar'] = $avatar->url;
16170 +                }
16171 +                $parts = array();
16172 +                foreach ($params as $k => $v) {
16173 +                    $parts[] = $k . '=' . OAuthUtil::urlencodeRFC3986($v);
16174 +                }
16175 +                $query_string = implode('&', $parts);
16176 +                $parsed = parse_url($callback);
16177 +                $url = $callback . (($parsed['query']) ? '&' : '?') . $query_string;
16178 +                common_redirect($url, 303);
16179 +            }
16180 +        } else {
16181 +            if (!$callback) {
16182 +                $this->show_reject_message();
16183 +            } else {
16184 +                # XXX: not 100% sure how to signal failure... just redirect without token?
16185 +                common_redirect($callback, 303);
16186 +            }
16187 +        }
16188 +    }
16189 hunk ./actions/userauthorization.php 200
16190 -       function authorize_token(&$req) {
16191 -               $consumer_key = $req->get_parameter('oauth_consumer_key');
16192 -               $token_field = $req->get_parameter('oauth_token');
16193 -               common_debug('consumer key = "'.$consumer_key.'"', __FILE__);
16194 -               common_debug('token field = "'.$token_field.'"', __FILE__);
16195 -               $rt = new Token();
16196 -               $rt->consumer_key = $consumer_key;
16197 -               $rt->tok = $token_field;
16198 -               $rt->type = 0;
16199 -               $rt->state = 0;
16200 -               common_debug('request token to look up: "'.print_r($rt,TRUE).'"');
16201 -               if ($rt->find(true)) {
16202 -                       common_debug('found request token to authorize', __FILE__);
16203 -                       $orig_rt = clone($rt);
16204 -                       $rt->state = 1; # Authorized but not used
16205 -                       if ($rt->update($orig_rt)) {
16206 -                               common_debug('updated request token so it is authorized', __FILE__);
16207 -                               return true;
16208 -                       }
16209 -               }
16210 -               return FALSE;
16211 -       }
16212 +    function authorize_token(&$req) {
16213 +        $consumer_key = $req->get_parameter('oauth_consumer_key');
16214 +        $token_field = $req->get_parameter('oauth_token');
16215 +        common_debug('consumer key = "'.$consumer_key.'"', __FILE__);
16216 +        common_debug('token field = "'.$token_field.'"', __FILE__);
16217 +        $rt = new Token();
16218 +        $rt->consumer_key = $consumer_key;
16219 +        $rt->tok = $token_field;
16220 +        $rt->type = 0;
16221 +        $rt->state = 0;
16222 +        common_debug('request token to look up: "'.print_r($rt,TRUE).'"');
16223 +        if ($rt->find(true)) {
16224 +            common_debug('found request token to authorize', __FILE__);
16225 +            $orig_rt = clone($rt);
16226 +            $rt->state = 1; # Authorized but not used
16227 +            if ($rt->update($orig_rt)) {
16228 +                common_debug('updated request token so it is authorized', __FILE__);
16229 +                return true;
16230 +            }
16231 +        }
16232 +        return FALSE;
16233 +    }
16234 hunk ./actions/userauthorization.php 223
16235 -       # XXX: refactor with similar code in finishremotesubscribe.php
16236 +    # XXX: refactor with similar code in finishremotesubscribe.php
16237 hunk ./actions/userauthorization.php 225
16238 -       function save_remote_profile(&$req) {
16239 -               # FIXME: we should really do this when the consumer comes
16240 -               # back for an access token. If they never do, we've got stuff in a
16241 -               # weird state.
16242 +    function save_remote_profile(&$req) {
16243 +        # FIXME: we should really do this when the consumer comes
16244 +        # back for an access token. If they never do, we've got stuff in a
16245 +        # weird state.
16246 hunk ./actions/userauthorization.php 230
16247 -               $nickname = $req->get_parameter('omb_listenee_nickname');
16248 -               $fullname = $req->get_parameter('omb_listenee_fullname');
16249 -               $profile_url = $req->get_parameter('omb_listenee_profile');
16250 -               $homepage = $req->get_parameter('omb_listenee_homepage');
16251 -               $bio = $req->get_parameter('omb_listenee_bio');
16252 -               $location = $req->get_parameter('omb_listenee_location');
16253 -               $avatar_url = $req->get_parameter('omb_listenee_avatar');
16254 +        $nickname = $req->get_parameter('omb_listenee_nickname');
16255 +        $fullname = $req->get_parameter('omb_listenee_fullname');
16256 +        $profile_url = $req->get_parameter('omb_listenee_profile');
16257 +        $homepage = $req->get_parameter('omb_listenee_homepage');
16258 +        $bio = $req->get_parameter('omb_listenee_bio');
16259 +        $location = $req->get_parameter('omb_listenee_location');
16260 +        $avatar_url = $req->get_parameter('omb_listenee_avatar');
16261 hunk ./actions/userauthorization.php 238
16262 -               $listenee = $req->get_parameter('omb_listenee');
16263 -               $remote = Remote_profile::staticGet('uri', $listenee);
16264 +        $listenee = $req->get_parameter('omb_listenee');
16265 +        $remote = Remote_profile::staticGet('uri', $listenee);
16266 hunk ./actions/userauthorization.php 241
16267 -               if ($remote) {
16268 -                       $exists = true;
16269 -                       $profile = Profile::staticGet($remote->id);
16270 -                       $orig_remote = clone($remote);
16271 -                       $orig_profile = clone($profile);
16272 -               } else {
16273 -                       $exists = false;
16274 -                       $remote = new Remote_profile();
16275 -                       $remote->uri = $listenee;
16276 -                       $profile = new Profile();
16277 -               }
16278 +        if ($remote) {
16279 +            $exists = true;
16280 +            $profile = Profile::staticGet($remote->id);
16281 +            $orig_remote = clone($remote);
16282 +            $orig_profile = clone($profile);
16283 +        } else {
16284 +            $exists = false;
16285 +            $remote = new Remote_profile();
16286 +            $remote->uri = $listenee;
16287 +            $profile = new Profile();
16288 +        }
16289 hunk ./actions/userauthorization.php 253
16290 -               $profile->nickname = $nickname;
16291 -               $profile->profileurl = $profile_url;
16292 +        $profile->nickname = $nickname;
16293 +        $profile->profileurl = $profile_url;
16294 hunk ./actions/userauthorization.php 256
16295 -               if ($fullname) {
16296 -                       $profile->fullname = $fullname;
16297 -               }
16298 -               if ($homepage) {
16299 -                       $profile->homepage = $homepage;
16300 -               }
16301 -               if ($bio) {
16302 -                       $profile->bio = $bio;
16303 -               }
16304 -               if ($location) {
16305 -                       $profile->location = $location;
16306 -               }
16307 +        if ($fullname) {
16308 +            $profile->fullname = $fullname;
16309 +        }
16310 +        if ($homepage) {
16311 +            $profile->homepage = $homepage;
16312 +        }
16313 +        if ($bio) {
16314 +            $profile->bio = $bio;
16315 +        }
16316 +        if ($location) {
16317 +            $profile->location = $location;
16318 +        }
16319 hunk ./actions/userauthorization.php 269
16320 -               if ($exists) {
16321 -                       $profile->update($orig_profile);
16322 -               } else {
16323 -                       $profile->created = DB_DataObject_Cast::dateTime(); # current time
16324 -                       $id = $profile->insert();
16325 -                       if (!$id) {
16326 -                               return FALSE;
16327 -                       }
16328 -                       $remote->id = $id;
16329 -               }
16330 +        if ($exists) {
16331 +            $profile->update($orig_profile);
16332 +        } else {
16333 +            $profile->created = DB_DataObject_Cast::dateTime(); # current time
16334 +            $id = $profile->insert();
16335 +            if (!$id) {
16336 +                return FALSE;
16337 +            }
16338 +            $remote->id = $id;
16339 +        }
16340 hunk ./actions/userauthorization.php 280
16341 -               if ($exists) {
16342 -                       if (!$remote->update($orig_remote)) {
16343 -                               return FALSE;
16344 -                       }
16345 -               } else {
16346 -                       $remote->created = DB_DataObject_Cast::dateTime(); # current time
16347 -                       if (!$remote->insert()) {
16348 -                               return FALSE;
16349 -                       }
16350 -               }
16351 +        if ($exists) {
16352 +            if (!$remote->update($orig_remote)) {
16353 +                return FALSE;
16354 +            }
16355 +        } else {
16356 +            $remote->created = DB_DataObject_Cast::dateTime(); # current time
16357 +            if (!$remote->insert()) {
16358 +                return FALSE;
16359 +            }
16360 +        }
16361 hunk ./actions/userauthorization.php 291
16362 -               if ($avatar_url) {
16363 -                       if (!$this->add_avatar($profile, $avatar_url)) {
16364 -                               return FALSE;
16365 -                       }
16366 -               }
16367 +        if ($avatar_url) {
16368 +            if (!$this->add_avatar($profile, $avatar_url)) {
16369 +                return FALSE;
16370 +            }
16371 +        }
16372 hunk ./actions/userauthorization.php 297
16373 -               $user = common_current_user();
16374 -               $datastore = omb_oauth_datastore();
16375 -               $consumer = $this->get_consumer($datastore, $req);
16376 -               $token = $this->get_token($datastore, $req, $consumer);
16377 +        $user = common_current_user();
16378 +        $datastore = omb_oauth_datastore();
16379 +        $consumer = $this->get_consumer($datastore, $req);
16380 +        $token = $this->get_token($datastore, $req, $consumer);
16381 hunk ./actions/userauthorization.php 302
16382 -               $sub = new Subscription();
16383 -               $sub->subscriber = $user->id;
16384 -               $sub->subscribed = $remote->id;
16385 -               $sub->token = $token->key; # NOTE: request token, not valid for use!
16386 -               $sub->created = DB_DataObject_Cast::dateTime(); # current time
16387 +        $sub = new Subscription();
16388 +        $sub->subscriber = $user->id;
16389 +        $sub->subscribed = $remote->id;
16390 +        $sub->token = $token->key; # NOTE: request token, not valid for use!
16391 +        $sub->created = DB_DataObject_Cast::dateTime(); # current time
16392 hunk ./actions/userauthorization.php 308
16393 -               if (!$sub->insert()) {
16394 -                       return FALSE;
16395 -               }
16396 +        if (!$sub->insert()) {
16397 +            return FALSE;
16398 +        }
16399 hunk ./actions/userauthorization.php 312
16400 -               return TRUE;
16401 -       }
16402 +        return TRUE;
16403 +    }
16404 hunk ./actions/userauthorization.php 315
16405 -       function add_avatar($profile, $url) {
16406 -               $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
16407 -               copy($url, $temp_filename);
16408 -               return $profile->setOriginal($temp_filename);
16409 -       }
16410 +    function add_avatar($profile, $url) {
16411 +        $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
16412 +        copy($url, $temp_filename);
16413 +        return $profile->setOriginal($temp_filename);
16414 +    }
16415 hunk ./actions/userauthorization.php 321
16416 -       function show_accept_message($tok) {
16417 -               common_show_header(_('Subscription authorized'));
16418 -               common_element('p', NULL,
16419 -                                          _('The subscription has been authorized, but no '.
16420 -                                                 'callback URL was passed. Check with the site\'s instructions for '.
16421 -                                                 'details on how to authorize the subscription. Your subscription token is:'));
16422 -               common_element('blockquote', 'token', $tok);
16423 -               common_show_footer();
16424 -       }
16425 +    function show_accept_message($tok) {
16426 +        common_show_header(_('Subscription authorized'));
16427 +        common_element('p', NULL,
16428 +                       _('The subscription has been authorized, but no '.
16429 +                          'callback URL was passed. Check with the site\'s instructions for '.
16430 +                          'details on how to authorize the subscription. Your subscription token is:'));
16431 +        common_element('blockquote', 'token', $tok);
16432 +        common_show_footer();
16433 +    }
16434 hunk ./actions/userauthorization.php 331
16435 -       function show_reject_message($tok) {
16436 -               common_show_header(_('Subscription rejected'));
16437 -               common_element('p', NULL,
16438 -                                          _('The subscription has been rejected, but no '.
16439 -                                                 'callback URL was passed. Check with the site\'s instructions for '.
16440 -                                                 'details on how to fully reject the subscription.'));
16441 -               common_show_footer();
16442 -       }
16443 +    function show_reject_message($tok) {
16444 +        common_show_header(_('Subscription rejected'));
16445 +        common_element('p', NULL,
16446 +                       _('The subscription has been rejected, but no '.
16447 +                          'callback URL was passed. Check with the site\'s instructions for '.
16448 +                          'details on how to fully reject the subscription.'));
16449 +        common_show_footer();
16450 +    }
16451 hunk ./actions/userauthorization.php 340
16452 -       function store_request($req) {
16453 -               common_ensure_session();
16454 -               $_SESSION['userauthorizationrequest'] = $req;
16455 -       }
16456 +    function store_request($req) {
16457 +        common_ensure_session();
16458 +        $_SESSION['userauthorizationrequest'] = $req;
16459 +    }
16460 hunk ./actions/userauthorization.php 345
16461 -       function clear_request() {
16462 -               common_ensure_session();
16463 -               unset($_SESSION['userauthorizationrequest']);
16464 -       }
16465 +    function clear_request() {
16466 +        common_ensure_session();
16467 +        unset($_SESSION['userauthorizationrequest']);
16468 +    }
16469 hunk ./actions/userauthorization.php 350
16470 -       function get_stored_request() {
16471 -               common_ensure_session();
16472 -               $req = $_SESSION['userauthorizationrequest'];
16473 -               return $req;
16474 -       }
16475 +    function get_stored_request() {
16476 +        common_ensure_session();
16477 +        $req = $_SESSION['userauthorizationrequest'];
16478 +        return $req;
16479 +    }
16480 hunk ./actions/userauthorization.php 356
16481 -       function get_new_request() {
16482 -               common_remove_magic_from_request();
16483 -               $req = OAuthRequest::from_request();
16484 -               return $req;
16485 -       }
16486 +    function get_new_request() {
16487 +        common_remove_magic_from_request();
16488 +        $req = OAuthRequest::from_request();
16489 +        return $req;
16490 +    }
16491 hunk ./actions/userauthorization.php 362
16492 -       # Throws an OAuthException if anything goes wrong
16493 +    # Throws an OAuthException if anything goes wrong
16494 hunk ./actions/userauthorization.php 364
16495 -       function validate_request(&$req) {
16496 -               # OAuth stuff -- have to copy from OAuth.php since they're
16497 -               # all private methods, and there's no user-authentication method
16498 -               common_debug('checking version', __FILE__);
16499 -               $this->check_version($req);
16500 -               common_debug('getting datastore', __FILE__);
16501 -               $datastore = omb_oauth_datastore();
16502 -               common_debug('getting consumer', __FILE__);
16503 -               $consumer = $this->get_consumer($datastore, $req);
16504 -               common_debug('getting token', __FILE__);
16505 -               $token = $this->get_token($datastore, $req, $consumer);
16506 -               common_debug('checking timestamp', __FILE__);
16507 -               $this->check_timestamp($req);
16508 -               common_debug('checking nonce', __FILE__);
16509 -               $this->check_nonce($datastore, $req, $consumer, $token);
16510 -               common_debug('checking signature', __FILE__);
16511 -               $this->check_signature($req, $consumer, $token);
16512 -               common_debug('validating omb stuff', __FILE__);
16513 -               $this->validate_omb($req);
16514 -               common_debug('done validating', __FILE__);
16515 -               return true;
16516 -       }
16517 +    function validate_request(&$req) {
16518 +        # OAuth stuff -- have to copy from OAuth.php since they're
16519 +        # all private methods, and there's no user-authentication method
16520 +        common_debug('checking version', __FILE__);
16521 +        $this->check_version($req);
16522 +        common_debug('getting datastore', __FILE__);
16523 +        $datastore = omb_oauth_datastore();
16524 +        common_debug('getting consumer', __FILE__);
16525 +        $consumer = $this->get_consumer($datastore, $req);
16526 +        common_debug('getting token', __FILE__);
16527 +        $token = $this->get_token($datastore, $req, $consumer);
16528 +        common_debug('checking timestamp', __FILE__);
16529 +        $this->check_timestamp($req);
16530 +        common_debug('checking nonce', __FILE__);
16531 +        $this->check_nonce($datastore, $req, $consumer, $token);
16532 +        common_debug('checking signature', __FILE__);
16533 +        $this->check_signature($req, $consumer, $token);
16534 +        common_debug('validating omb stuff', __FILE__);
16535 +        $this->validate_omb($req);
16536 +        common_debug('done validating', __FILE__);
16537 +        return true;
16538 +    }
16539 hunk ./actions/userauthorization.php 387
16540 -       function validate_omb(&$req) {
16541 -               foreach (array('omb_version', 'omb_listener', 'omb_listenee',
16542 -                                          'omb_listenee_profile', 'omb_listenee_nickname',
16543 -                                          'omb_listenee_license') as $param)
16544 -               {
16545 -                       if (!$req->get_parameter($param)) {
16546 -                               throw new OAuthException("Required parameter '$param' not found");
16547 -                       }
16548 -               }
16549 -               # Now, OMB stuff
16550 -               $version = $req->get_parameter('omb_version');
16551 -               if ($version != OMB_VERSION_01) {
16552 -                       throw new OAuthException("OpenMicroBlogging version '$version' not supported");
16553 -               }
16554 -               $listener =     $req->get_parameter('omb_listener');
16555 -               $user = User::staticGet('uri', $listener);
16556 -               if (!$user) {
16557 -                       throw new OAuthException("Listener URI '$listener' not found here");
16558 -               }
16559 -               $cur = common_current_user();
16560 -               if ($cur->id != $user->id) {
16561 -                       throw new OAuthException("Can't add for another user!");
16562 -               }
16563 -               $listenee = $req->get_parameter('omb_listenee');
16564 -               if (!Validate::uri($listenee) &&
16565 -                       !common_valid_tag($listenee)) {
16566 -                       throw new OAuthException("Listenee URI '$listenee' not a recognizable URI");
16567 -               }
16568 -               if (strlen($listenee) > 255) {
16569 -                       throw new OAuthException("Listenee URI '$listenee' too long");
16570 -               }
16571 +    function validate_omb(&$req) {
16572 +        foreach (array('omb_version', 'omb_listener', 'omb_listenee',
16573 +                       'omb_listenee_profile', 'omb_listenee_nickname',
16574 +                       'omb_listenee_license') as $param)
16575 +        {
16576 +            if (!$req->get_parameter($param)) {
16577 +                throw new OAuthException("Required parameter '$param' not found");
16578 +            }
16579 +        }
16580 +        # Now, OMB stuff
16581 +        $version = $req->get_parameter('omb_version');
16582 +        if ($version != OMB_VERSION_01) {
16583 +            throw new OAuthException("OpenMicroBlogging version '$version' not supported");
16584 +        }
16585 +        $listener =    $req->get_parameter('omb_listener');
16586 +        $user = User::staticGet('uri', $listener);
16587 +        if (!$user) {
16588 +            throw new OAuthException("Listener URI '$listener' not found here");
16589 +        }
16590 +        $cur = common_current_user();
16591 +        if ($cur->id != $user->id) {
16592 +            throw new OAuthException("Can't add for another user!");
16593 +        }
16594 +        $listenee = $req->get_parameter('omb_listenee');
16595 +        if (!Validate::uri($listenee) &&
16596 +            !common_valid_tag($listenee)) {
16597 +            throw new OAuthException("Listenee URI '$listenee' not a recognizable URI");
16598 +        }
16599 +        if (strlen($listenee) > 255) {
16600 +            throw new OAuthException("Listenee URI '$listenee' too long");
16601 +        }
16602 hunk ./actions/userauthorization.php 419
16603 -               $other = User::staticGet('uri', $listenee);
16604 -               if ($other) {
16605 -                       throw new OAuthException("Listenee URI '$listenee' is local user");
16606 -               }
16607 +        $other = User::staticGet('uri', $listenee);
16608 +        if ($other) {
16609 +            throw new OAuthException("Listenee URI '$listenee' is local user");
16610 +        }
16611 hunk ./actions/userauthorization.php 424
16612 -               $remote = Remote_profile::staticGet('uri', $listenee);
16613 -               if ($remote) {
16614 -                       $sub = new Subscription();
16615 -                       $sub->subscriber = $user->id;
16616 -                       $sub->subscribed = $remote->id;
16617 -                       if ($sub->find(TRUE)) {
16618 -                               throw new OAuthException("Already subscribed to user!");
16619 -                       }
16620 -               }
16621 -               $nickname = $req->get_parameter('omb_listenee_nickname');
16622 -               if (!Validate::string($nickname, array('min_length' => 1,
16623 -                                                                                          'max_length' => 64,
16624 -                                                                                          'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
16625 -                       throw new OAuthException('Nickname must have only letters and numbers and no spaces.');
16626 -               }
16627 -               $profile = $req->get_parameter('omb_listenee_profile');
16628 -               if (!common_valid_http_url($profile)) {
16629 -                       throw new OAuthException("Invalid profile URL '$profile'.");
16630 -               }
16631 +        $remote = Remote_profile::staticGet('uri', $listenee);
16632 +        if ($remote) {
16633 +            $sub = new Subscription();
16634 +            $sub->subscriber = $user->id;
16635 +            $sub->subscribed = $remote->id;
16636 +            if ($sub->find(TRUE)) {
16637 +                throw new OAuthException("Already subscribed to user!");
16638 +            }
16639 +        }
16640 +        $nickname = $req->get_parameter('omb_listenee_nickname');
16641 +        if (!Validate::string($nickname, array('min_length' => 1,
16642 +                                               'max_length' => 64,
16643 +                                               'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
16644 +            throw new OAuthException('Nickname must have only letters and numbers and no spaces.');
16645 +        }
16646 +        $profile = $req->get_parameter('omb_listenee_profile');
16647 +        if (!common_valid_http_url($profile)) {
16648 +            throw new OAuthException("Invalid profile URL '$profile'.");
16649 +        }
16650 hunk ./actions/userauthorization.php 444
16651 -               if ($profile == common_local_url('showstream', array('nickname' => $nickname))) {
16652 -                       throw new OAuthException("Profile URL '$profile' is for a local user.");
16653 -               }
16654 +        if ($profile == common_local_url('showstream', array('nickname' => $nickname))) {
16655 +            throw new OAuthException("Profile URL '$profile' is for a local user.");
16656 +        }
16657 hunk ./actions/userauthorization.php 448
16658 -               $license = $req->get_parameter('omb_listenee_license');
16659 -               if (!common_valid_http_url($license)) {
16660 -                       throw new OAuthException("Invalid license URL '$license'.");
16661 -               }
16662 -               $site_license = common_config('license', 'url');
16663 -               if (!common_compatible_license($license, $site_license)) {
16664 -                       throw new OAuthException("Listenee stream license '$license' not compatible with site license '$site_license'.");
16665 -               }
16666 -               # optional stuff
16667 -               $fullname = $req->get_parameter('omb_listenee_fullname');
16668 -               if ($fullname && strlen($fullname) > 255) {
16669 -                       throw new OAuthException("Full name '$fullname' too long.");
16670 -               }
16671 -               $homepage = $req->get_parameter('omb_listenee_homepage');
16672 -               if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) {
16673 -                       throw new OAuthException("Invalid homepage '$homepage'");
16674 -               }
16675 -               $bio = $req->get_parameter('omb_listenee_bio');
16676 -               if ($bio && strlen($bio) > 140) {
16677 -                       throw new OAuthException("Bio too long '$bio'");
16678 -               }
16679 -               $location = $req->get_parameter('omb_listenee_location');
16680 -               if ($location && strlen($location) > 255) {
16681 -                       throw new OAuthException("Location too long '$location'");
16682 -               }
16683 -               $avatar = $req->get_parameter('omb_listenee_avatar');
16684 -               if ($avatar) {
16685 -                       if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
16686 -                               throw new OAuthException("Invalid avatar URL '$avatar'");
16687 -                       }
16688 -                       $size = @getimagesize($avatar);
16689 -                       if (!$size) {
16690 -                               throw new OAuthException("Can't read avatar URL '$avatar'");
16691 -                       }
16692 -                       if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
16693 -                               throw new OAuthException("Wrong size image at '$avatar'");
16694 -                       }
16695 -                       if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
16696 -                                                                                 IMAGETYPE_PNG))) {
16697 -                               throw new OAuthException("Wrong image type for '$avatar'");
16698 -                       }
16699 -               }
16700 -               $callback = $req->get_parameter('oauth_callback');
16701 -               if ($callback && !common_valid_http_url($callback)) {
16702 -                       throw new OAuthException("Invalid callback URL '$callback'");
16703 -               }
16704 -               if ($callback && $callback == common_local_url('finishremotesubscribe')) {
16705 -                       throw new OAuthException("Callback URL '$callback' is for local site.");
16706 -               }
16707 -       }
16708 +        $license = $req->get_parameter('omb_listenee_license');
16709 +        if (!common_valid_http_url($license)) {
16710 +            throw new OAuthException("Invalid license URL '$license'.");
16711 +        }
16712 +        $site_license = common_config('license', 'url');
16713 +        if (!common_compatible_license($license, $site_license)) {
16714 +            throw new OAuthException("Listenee stream license '$license' not compatible with site license '$site_license'.");
16715 +        }
16716 +        # optional stuff
16717 +        $fullname = $req->get_parameter('omb_listenee_fullname');
16718 +        if ($fullname && strlen($fullname) > 255) {
16719 +            throw new OAuthException("Full name '$fullname' too long.");
16720 +        }
16721 +        $homepage = $req->get_parameter('omb_listenee_homepage');
16722 +        if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) {
16723 +            throw new OAuthException("Invalid homepage '$homepage'");
16724 +        }
16725 +        $bio = $req->get_parameter('omb_listenee_bio');
16726 +        if ($bio && strlen($bio) > 140) {
16727 +            throw new OAuthException("Bio too long '$bio'");
16728 +        }
16729 +        $location = $req->get_parameter('omb_listenee_location');
16730 +        if ($location && strlen($location) > 255) {
16731 +            throw new OAuthException("Location too long '$location'");
16732 +        }
16733 +        $avatar = $req->get_parameter('omb_listenee_avatar');
16734 +        if ($avatar) {
16735 +            if (!common_valid_http_url($avatar) || strlen($avatar) > 255) {
16736 +                throw new OAuthException("Invalid avatar URL '$avatar'");
16737 +            }
16738 +            $size = @getimagesize($avatar);
16739 +            if (!$size) {
16740 +                throw new OAuthException("Can't read avatar URL '$avatar'");
16741 +            }
16742 +            if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) {
16743 +                throw new OAuthException("Wrong size image at '$avatar'");
16744 +            }
16745 +            if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG,
16746 +                                          IMAGETYPE_PNG))) {
16747 +                throw new OAuthException("Wrong image type for '$avatar'");
16748 +            }
16749 +        }
16750 +        $callback = $req->get_parameter('oauth_callback');
16751 +        if ($callback && !common_valid_http_url($callback)) {
16752 +            throw new OAuthException("Invalid callback URL '$callback'");
16753 +        }
16754 +        if ($callback && $callback == common_local_url('finishremotesubscribe')) {
16755 +            throw new OAuthException("Callback URL '$callback' is for local site.");
16756 +        }
16757 +    }
16758 hunk ./actions/userauthorization.php 499
16759 -       # Snagged from OAuthServer
16760 +    # Snagged from OAuthServer
16761 hunk ./actions/userauthorization.php 501
16762 -       function check_version(&$req) {
16763 -               $version = $req->get_parameter("oauth_version");
16764 -               if (!$version) {
16765 -                       $version = 1.0;
16766 -               }
16767 -               if ($version != 1.0) {
16768 -                       throw new OAuthException("OAuth version '$version' not supported");
16769 -               }
16770 -               return $version;
16771 -       }
16772 +    function check_version(&$req) {
16773 +        $version = $req->get_parameter("oauth_version");
16774 +        if (!$version) {
16775 +            $version = 1.0;
16776 +        }
16777 +        if ($version != 1.0) {
16778 +            throw new OAuthException("OAuth version '$version' not supported");
16779 +        }
16780 +        return $version;
16781 +    }
16782 hunk ./actions/userauthorization.php 512
16783 -       # Snagged from OAuthServer
16784 +    # Snagged from OAuthServer
16785 hunk ./actions/userauthorization.php 514
16786 -       function get_consumer($datastore, $req) {
16787 -               $consumer_key = @$req->get_parameter("oauth_consumer_key");
16788 -               if (!$consumer_key) {
16789 -                       throw new OAuthException("Invalid consumer key");
16790 -               }
16791 +    function get_consumer($datastore, $req) {
16792 +        $consumer_key = @$req->get_parameter("oauth_consumer_key");
16793 +        if (!$consumer_key) {
16794 +            throw new OAuthException("Invalid consumer key");
16795 +        }
16796 hunk ./actions/userauthorization.php 520
16797 -               $consumer = $datastore->lookup_consumer($consumer_key);
16798 -               if (!$consumer) {
16799 -                       throw new OAuthException("Invalid consumer");
16800 -               }
16801 -               return $consumer;
16802 -       }
16803 +        $consumer = $datastore->lookup_consumer($consumer_key);
16804 +        if (!$consumer) {
16805 +            throw new OAuthException("Invalid consumer");
16806 +        }
16807 +        return $consumer;
16808 +    }
16809 hunk ./actions/userauthorization.php 527
16810 -       # Mostly cadged from OAuthServer
16811 +    # Mostly cadged from OAuthServer
16812 hunk ./actions/userauthorization.php 529
16813 -       function get_token($datastore, &$req, $consumer) {/*{{{*/
16814 -               $token_field = @$req->get_parameter('oauth_token');
16815 -               $token = $datastore->lookup_token($consumer, 'request', $token_field);
16816 -               if (!$token) {
16817 -                       throw new OAuthException("Invalid $token_type token: $token_field");
16818 -               }
16819 -               return $token;
16820 -       }
16821 +    function get_token($datastore, &$req, $consumer) {/*{{{*/
16822 +        $token_field = @$req->get_parameter('oauth_token');
16823 +        $token = $datastore->lookup_token($consumer, 'request', $token_field);
16824 +        if (!$token) {
16825 +            throw new OAuthException("Invalid $token_type token: $token_field");
16826 +        }
16827 +        return $token;
16828 +    }
16829 hunk ./actions/userauthorization.php 538
16830 -       function check_timestamp(&$req) {
16831 -               $timestamp = @$req->get_parameter('oauth_timestamp');
16832 -               $now = time();
16833 -               if ($now - $timestamp > TIMESTAMP_THRESHOLD) {
16834 -                       throw new OAuthException("Expired timestamp, yours $timestamp, ours $now");
16835 -               }
16836 -       }
16837 +    function check_timestamp(&$req) {
16838 +        $timestamp = @$req->get_parameter('oauth_timestamp');
16839 +        $now = time();
16840 +        if ($now - $timestamp > TIMESTAMP_THRESHOLD) {
16841 +            throw new OAuthException("Expired timestamp, yours $timestamp, ours $now");
16842 +        }
16843 +    }
16844 hunk ./actions/userauthorization.php 546
16845 -       # NOTE: don't call twice on the same request; will fail!
16846 -       function check_nonce(&$datastore, &$req, $consumer, $token) {
16847 -               $timestamp = @$req->get_parameter('oauth_timestamp');
16848 -               $nonce = @$req->get_parameter('oauth_nonce');
16849 -               $found = $datastore->lookup_nonce($consumer, $token, $nonce, $timestamp);
16850 -               if ($found) {
16851 -                       throw new OAuthException("Nonce already used");
16852 -               }
16853 -               return true;
16854 -       }
16855 +    # NOTE: don't call twice on the same request; will fail!
16856 +    function check_nonce(&$datastore, &$req, $consumer, $token) {
16857 +        $timestamp = @$req->get_parameter('oauth_timestamp');
16858 +        $nonce = @$req->get_parameter('oauth_nonce');
16859 +        $found = $datastore->lookup_nonce($consumer, $token, $nonce, $timestamp);
16860 +        if ($found) {
16861 +            throw new OAuthException("Nonce already used");
16862 +        }
16863 +        return true;
16864 +    }
16865 hunk ./actions/userauthorization.php 557
16866 -       function check_signature(&$req, $consumer, $token) {
16867 -               $signature_method = $this->get_signature_method($req);
16868 -               $signature = $req->get_parameter('oauth_signature');
16869 -               $valid_sig = $signature_method->check_signature($req,
16870 -                                                                                                               $consumer,
16871 -                                                                                                               $token,
16872 -                                                                                                               $signature);
16873 -               if (!$valid_sig) {
16874 -                       throw new OAuthException("Invalid signature");
16875 -               }
16876 -       }
16877 +    function check_signature(&$req, $consumer, $token) {
16878 +        $signature_method = $this->get_signature_method($req);
16879 +        $signature = $req->get_parameter('oauth_signature');
16880 +        $valid_sig = $signature_method->check_signature($req,
16881 +                                                        $consumer,
16882 +                                                        $token,
16883 +                                                        $signature);
16884 +        if (!$valid_sig) {
16885 +            throw new OAuthException("Invalid signature");
16886 +        }
16887 +    }
16888 hunk ./actions/userauthorization.php 569
16889 -       function get_signature_method(&$req) {
16890 -               $signature_method = @$req->get_parameter("oauth_signature_method");
16891 -               if (!$signature_method) {
16892 -                       $signature_method = "PLAINTEXT";
16893 -               }
16894 -               if ($signature_method != 'HMAC-SHA1') {
16895 -                       throw new OAuthException("Signature method '$signature_method' not supported.");
16896 -               }
16897 -               return omb_hmac_sha1();
16898 -       }
16899 +    function get_signature_method(&$req) {
16900 +        $signature_method = @$req->get_parameter("oauth_signature_method");
16901 +        if (!$signature_method) {
16902 +            $signature_method = "PLAINTEXT";
16903 +        }
16904 +        if ($signature_method != 'HMAC-SHA1') {
16905 +            throw new OAuthException("Signature method '$signature_method' not supported.");
16906 +        }
16907 +        return omb_hmac_sha1();
16908 +    }
16909 hunk ./actions/userbyid.php 23
16910 -       
16911 -       function is_readonly() {                                
16912 -               return true;
16913 -       }
16914 -       
16915 +    
16916 +    function is_readonly() {                
16917 +        return true;
16918 +    }
16919 +    
16920 hunk ./actions/userbyid.php 32
16921 -               $this->client_error(_('No id.'));
16922 -               }
16923 -               $user =& User::staticGet($id);
16924 -               if (!$user) {
16925 -                       $this->client_error(_('No such user.'));
16926 +            $this->client_error(_('No id.'));
16927 +        }
16928 +        $user =& User::staticGet($id);
16929 +        if (!$user) {
16930 +            $this->client_error(_('No such user.'));
16931 hunk ./actions/userbyid.php 42
16932 -       $type = common_negotiate_type(common_accept_to_prefs($httpaccept),
16933 +        $type = common_negotiate_type(common_accept_to_prefs($httpaccept),
16934 hunk ./actions/userbyid.php 44
16935 -               $page = $type == 'application/rdf+xml' ? 'foaf' : 'showstream';
16936 +        $page = $type == 'application/rdf+xml' ? 'foaf' : 'showstream';
16937 hunk ./actions/userbyid.php 46
16938 -               $url = common_local_url($page, array('nickname' => $user->nickname));
16939 -               common_redirect($url, 303);
16940 -       }
16941 +        $url = common_local_url($page, array('nickname' => $user->nickname));
16942 +        common_redirect($url, 303);
16943 +    }
16944 hunk ./actions/userrss.php 28
16945 -       var $user = NULL;
16946 +    var $user = NULL;
16947 hunk ./actions/userrss.php 30
16948 -       function init() {
16949 -               $nickname = $this->trimmed('nickname');
16950 -               $this->user = User::staticGet('nickname', $nickname);
16951 +    function init() {
16952 +        $nickname = $this->trimmed('nickname');
16953 +        $this->user = User::staticGet('nickname', $nickname);
16954 hunk ./actions/userrss.php 34
16955 -               if (!$this->user) {
16956 -                       common_user_error(_('No such user.'));
16957 -                       return false;
16958 -               } else {
16959 -                       return true;
16960 -               }
16961 -       }
16962 +        if (!$this->user) {
16963 +            common_user_error(_('No such user.'));
16964 +            return false;
16965 +        } else {
16966 +            return true;
16967 +        }
16968 +    }
16969 hunk ./actions/userrss.php 42
16970 -       function get_notices($limit=0) {
16971 +    function get_notices($limit=0) {
16972 hunk ./actions/userrss.php 44
16973 -               $user = $this->user;
16974 -               
16975 -               if (is_null($user)) {
16976 -                       return NULL;
16977 -               }
16978 -               
16979 -               $notice = $user->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
16980 -               
16981 -               while ($notice->fetch()) {
16982 -                       $notices[] = clone($notice);
16983 -               }
16984 +        $user = $this->user;
16985 +        
16986 +        if (is_null($user)) {
16987 +            return NULL;
16988 +        }
16989 +        
16990 +        $notice = $user->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
16991 +        
16992 +        while ($notice->fetch()) {
16993 +            $notices[] = clone($notice);
16994 +        }
16995 hunk ./actions/userrss.php 56
16996 -               return $notices;
16997 -       }
16998 +        return $notices;
16999 +    }
17000 hunk ./actions/userrss.php 59
17001 -       function get_channel() {
17002 -               $user = $this->user;
17003 -               $profile = $user->getProfile();
17004 -               $c = array('url' => common_local_url('userrss',
17005 -                                                                                        array('nickname' =>
17006 -                                                                                                  $user->nickname)),
17007 -                                  'title' => $user->nickname,
17008 -                                  'link' => $profile->profileurl,
17009 -                                  'description' => sprintf(_('Microblog by %s'), $user->nickname));
17010 -               return $c;
17011 -       }
17012 +    function get_channel() {
17013 +        $user = $this->user;
17014 +        $profile = $user->getProfile();
17015 +        $c = array('url' => common_local_url('userrss',
17016 +                                             array('nickname' =>
17017 +                                                   $user->nickname)),
17018 +                   'title' => $user->nickname,
17019 +                   'link' => $profile->profileurl,
17020 +                   'description' => sprintf(_('Microblog by %s'), $user->nickname));
17021 +        return $c;
17022 +    }
17023 hunk ./actions/userrss.php 71
17024 -       function get_image() {
17025 -               $user = $this->user;
17026 -               $profile = $user->getProfile();
17027 -               if (!$profile) {
17028 -                       common_log_db_error($user, 'SELECT', __FILE__);
17029 -                       $this->server_error(_('User without matching profile'));
17030 -                       return NULL;
17031 -               }
17032 -               $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
17033 -               return ($avatar) ? $avatar->url : NULL;
17034 -       }
17035 +    function get_image() {
17036 +        $user = $this->user;
17037 +        $profile = $user->getProfile();
17038 +        if (!$profile) {
17039 +            common_log_db_error($user, 'SELECT', __FILE__);
17040 +            $this->server_error(_('User without matching profile'));
17041 +            return NULL;
17042 +        }
17043 +        $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
17044 +        return ($avatar) ? $avatar->url : NULL;
17045 +    }
17046 hunk ./actions/userrss.php 83
17047 -       # override parent to add X-SUP-ID URL
17048 -       
17049 -       function init_rss($limit=0) {
17050 -               $url = common_local_url('sup', NULL, $this->user->id);
17051 -               header('X-SUP-ID: '.$url);
17052 -               parent::init_rss($limit);
17053 -       }
17054 +    # override parent to add X-SUP-ID URL
17055 +    
17056 +    function init_rss($limit=0) {
17057 +        $url = common_local_url('sup', NULL, $this->user->id);
17058 +        header('X-SUP-ID: '.$url);
17059 +        parent::init_rss($limit);
17060 +    }
17061 hunk ./actions/xrds.php 26
17062 -       function is_readonly() {                                
17063 -               return true;
17064 -       }
17065 +    function is_readonly() {                
17066 +        return true;
17067 +    }
17068 hunk ./actions/xrds.php 30
17069 -       function handle($args) {
17070 -               parent::handle($args);
17071 -               $nickname = $this->trimmed('nickname');
17072 -               $user = User::staticGet('nickname', $nickname);
17073 -               if (!$user) {
17074 -                       common_user_error(_('No such user.'));
17075 -                       return;
17076 -               }
17077 -               $this->show_xrds($user);
17078 -       }
17079 +    function handle($args) {
17080 +        parent::handle($args);
17081 +        $nickname = $this->trimmed('nickname');
17082 +        $user = User::staticGet('nickname', $nickname);
17083 +        if (!$user) {
17084 +            common_user_error(_('No such user.'));
17085 +            return;
17086 +        }
17087 +        $this->show_xrds($user);
17088 +    }
17089 hunk ./actions/xrds.php 41
17090 -       function show_xrds($user) {
17091 +    function show_xrds($user) {
17092 hunk ./actions/xrds.php 43
17093 -               header('Content-Type: application/xrds+xml');
17094 +        header('Content-Type: application/xrds+xml');
17095 hunk ./actions/xrds.php 45
17096 -               common_start_xml();
17097 -               common_element_start('XRDS', array('xmlns' => 'xri://$xrds'));
17098 +        common_start_xml();
17099 +        common_element_start('XRDS', array('xmlns' => 'xri://$xrds'));
17100 hunk ./actions/xrds.php 48
17101 -               common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
17102 -                                                 'xml:id' => 'oauth',
17103 -                                                                                 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
17104 -                                                                                 'version' => '2.0'));
17105 +        common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
17106 +                                          'xml:id' => 'oauth',
17107 +                                          'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
17108 +                                          'version' => '2.0'));
17109 hunk ./actions/xrds.php 53
17110 -               common_element('Type', NULL, 'xri://$xrds*simple');
17111 +        common_element('Type', NULL, 'xri://$xrds*simple');
17112 hunk ./actions/xrds.php 55
17113 -               $this->show_service(OAUTH_ENDPOINT_REQUEST,
17114 -                                                       common_local_url('requesttoken'),
17115 -                                                       array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
17116 -                                                       array(OAUTH_HMAC_SHA1),
17117 -                                                       $user->uri);
17118 +        $this->show_service(OAUTH_ENDPOINT_REQUEST,
17119 +                            common_local_url('requesttoken'),
17120 +                            array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
17121 +                            array(OAUTH_HMAC_SHA1),
17122 +                            $user->uri);
17123 hunk ./actions/xrds.php 61
17124 -               $this->show_service(OAUTH_ENDPOINT_AUTHORIZE,
17125 -                                                       common_local_url('userauthorization'),
17126 -                                                       array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
17127 -                                                       array(OAUTH_HMAC_SHA1));
17128 +        $this->show_service(OAUTH_ENDPOINT_AUTHORIZE,
17129 +                            common_local_url('userauthorization'),
17130 +                            array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
17131 +                            array(OAUTH_HMAC_SHA1));
17132 hunk ./actions/xrds.php 66
17133 -               $this->show_service(OAUTH_ENDPOINT_ACCESS,
17134 -                                                       common_local_url('accesstoken'),
17135 -                                                       array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
17136 -                                                       array(OAUTH_HMAC_SHA1));
17137 +        $this->show_service(OAUTH_ENDPOINT_ACCESS,
17138 +                            common_local_url('accesstoken'),
17139 +                            array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
17140 +                            array(OAUTH_HMAC_SHA1));
17141 hunk ./actions/xrds.php 71
17142 -               $this->show_service(OAUTH_ENDPOINT_RESOURCE,
17143 -                                                       NULL,
17144 -                                                       array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
17145 -                                                       array(OAUTH_HMAC_SHA1));
17146 +        $this->show_service(OAUTH_ENDPOINT_RESOURCE,
17147 +                            NULL,
17148 +                            array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY),
17149 +                            array(OAUTH_HMAC_SHA1));
17150 hunk ./actions/xrds.php 76
17151 -               common_element_end('XRD');
17152 +        common_element_end('XRD');
17153 hunk ./actions/xrds.php 78
17154 -               # XXX: decide whether to include user's ID/nickname in postNotice URL
17155 +        # XXX: decide whether to include user's ID/nickname in postNotice URL
17156 hunk ./actions/xrds.php 80
17157 -               common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
17158 -                                                 'xml:id' => 'omb',
17159 -                                                                                 'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
17160 -                                                                                 'version' => '2.0'));
17161 +        common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
17162 +                                          'xml:id' => 'omb',
17163 +                                          'xmlns:simple' => 'http://xrds-simple.net/core/1.0',
17164 +                                          'version' => '2.0'));
17165 hunk ./actions/xrds.php 85
17166 -               common_element('Type', NULL, 'xri://$xrds*simple');
17167 +        common_element('Type', NULL, 'xri://$xrds*simple');
17168 hunk ./actions/xrds.php 87
17169 -               $this->show_service(OMB_ENDPOINT_POSTNOTICE,
17170 -                                                       common_local_url('postnotice'));
17171 +        $this->show_service(OMB_ENDPOINT_POSTNOTICE,
17172 +                            common_local_url('postnotice'));
17173 hunk ./actions/xrds.php 90
17174 -               $this->show_service(OMB_ENDPOINT_UPDATEPROFILE,
17175 -                                                       common_local_url('updateprofile'));
17176 +        $this->show_service(OMB_ENDPOINT_UPDATEPROFILE,
17177 +                            common_local_url('updateprofile'));
17178 hunk ./actions/xrds.php 93
17179 -               common_element_end('XRD');
17180 +        common_element_end('XRD');
17181 hunk ./actions/xrds.php 95
17182 -               common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
17183 -                                                                                 'version' => '2.0'));
17184 +        common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
17185 +                                          'version' => '2.0'));
17186 hunk ./actions/xrds.php 98
17187 -               common_element('Type', NULL, 'xri://$xrds*simple');
17188 +        common_element('Type', NULL, 'xri://$xrds*simple');
17189 hunk ./actions/xrds.php 100
17190 -               $this->show_service(OAUTH_DISCOVERY,
17191 -                                                       '#oauth');
17192 -               $this->show_service(OMB_NAMESPACE,
17193 -                                                       '#omb');
17194 +        $this->show_service(OAUTH_DISCOVERY,
17195 +                            '#oauth');
17196 +        $this->show_service(OMB_NAMESPACE,
17197 +                            '#omb');
17198 hunk ./actions/xrds.php 105
17199 -               common_element_end('XRD');
17200 +        common_element_end('XRD');
17201 hunk ./actions/xrds.php 107
17202 -               common_element_end('XRDS');
17203 -               common_end_xml();
17204 -       }
17205 +        common_element_end('XRDS');
17206 +        common_end_xml();
17207 +    }
17208 hunk ./actions/xrds.php 111
17209 -       function show_service($type, $uri, $params=NULL, $sigs=NULL, $localId=NULL) {
17210 -               common_element_start('Service');
17211 -               if ($uri) {
17212 -                       common_element('URI', NULL, $uri);
17213 -               }
17214 -               common_element('Type', NULL, $type);
17215 -               if ($params) {
17216 -                       foreach ($params as $param) {
17217 -                               common_element('Type', NULL, $param);
17218 -                       }
17219 -               }
17220 -               if ($sigs) {
17221 -                       foreach ($sigs as $sig) {
17222 -                               common_element('Type', NULL, $sig);
17223 -                       }
17224 -               }
17225 -               if ($localId) {
17226 -                       common_element('LocalID', NULL, $localId);
17227 -               }
17228 -               common_element_end('Service');
17229 -       }
17230 +    function show_service($type, $uri, $params=NULL, $sigs=NULL, $localId=NULL) {
17231 +        common_element_start('Service');
17232 +        if ($uri) {
17233 +            common_element('URI', NULL, $uri);
17234 +        }
17235 +        common_element('Type', NULL, $type);
17236 +        if ($params) {
17237 +            foreach ($params as $param) {
17238 +                common_element('Type', NULL, $param);
17239 +            }
17240 +        }
17241 +        if ($sigs) {
17242 +            foreach ($sigs as $sig) {
17243 +                common_element('Type', NULL, $sig);
17244 +            }
17245 +        }
17246 +        if ($localId) {
17247 +            common_element('LocalID', NULL, $localId);
17248 +        }
17249 +        common_element_end('Service');
17250 +    }
17251 hunk ./classes/Avatar.php 29
17252 -       # We clean up the file, too
17253 +    # We clean up the file, too
17254 hunk ./classes/Avatar.php 31
17255 -       function delete() {
17256 -               $filename = $this->filename;
17257 -               if (parent::delete()) {
17258 -                       @unlink(common_avatar_path($filename));
17259 -               }
17260 -       }
17261 +    function delete() {
17262 +        $filename = $this->filename;
17263 +        if (parent::delete()) {
17264 +            @unlink(common_avatar_path($filename));
17265 +        }
17266 +    }
17267 hunk ./classes/Avatar.php 38
17268 -       # Create and save scaled version of this avatar
17269 -       # XXX: maybe break into different methods
17270 +    # Create and save scaled version of this avatar
17271 +    # XXX: maybe break into different methods
17272 hunk ./classes/Avatar.php 41
17273 -       function scale($size) {
17274 +    function scale($size) {
17275 hunk ./classes/Avatar.php 43
17276 -               $image_s = imagecreatetruecolor($size, $size);
17277 -               $image_a = $this->to_image();
17278 -               $square = min($this->width, $this->height);
17279 +        $image_s = imagecreatetruecolor($size, $size);
17280 +        $image_a = $this->to_image();
17281 +        $square = min($this->width, $this->height);
17282 hunk ./classes/Avatar.php 49
17283 -               imagecopyresampled($image_s, $image_a, 0, 0, 0, 0,
17284 -                                                  $size, $size, $square, $square);
17285 +        imagecopyresampled($image_s, $image_a, 0, 0, 0, 0,
17286 +                           $size, $size, $square, $square);
17287 hunk ./classes/Avatar.php 52
17288 -               $ext = ($this->mediattype == 'image/jpeg') ? ".jpeg" : ".png";
17289 +        $ext = ($this->mediattype == 'image/jpeg') ? ".jpeg" : ".png";
17290 hunk ./classes/Avatar.php 54
17291 -               $filename = common_avatar_filename($this->profile_id, $ext, $size, common_timestamp());
17292 +        $filename = common_avatar_filename($this->profile_id, $ext, $size, common_timestamp());
17293 hunk ./classes/Avatar.php 56
17294 -               if ($this->mediatype == 'image/jpeg') {
17295 -                       imagejpeg($image_s, common_avatar_path($filename));
17296 -               } else {
17297 -                       imagepng($image_s, common_avatar_path($filename));
17298 -               }
17299 +        if ($this->mediatype == 'image/jpeg') {
17300 +            imagejpeg($image_s, common_avatar_path($filename));
17301 +        } else {
17302 +            imagepng($image_s, common_avatar_path($filename));
17303 +        }
17304 hunk ./classes/Avatar.php 62
17305 -               $scaled = DB_DataObject::factory('avatar');
17306 -               $scaled->profile_id = $this->profile_id;
17307 -               $scaled->width = $size;
17308 -               $scaled->height = $size;
17309 -               $scaled->original = false;
17310 -               $scaled->mediatype = ($this->mediattype == 'image/jpeg') ? 'image/jpeg' : 'image/png';
17311 -               $scaled->filename = $filename;
17312 -               $scaled->url = common_avatar_url($filename);
17313 -               $scaled->created = DB_DataObject_Cast::dateTime(); # current time
17314 +        $scaled = DB_DataObject::factory('avatar');
17315 +        $scaled->profile_id = $this->profile_id;
17316 +        $scaled->width = $size;
17317 +        $scaled->height = $size;
17318 +        $scaled->original = false;
17319 +        $scaled->mediatype = ($this->mediattype == 'image/jpeg') ? 'image/jpeg' : 'image/png';
17320 +        $scaled->filename = $filename;
17321 +        $scaled->url = common_avatar_url($filename);
17322 +        $scaled->created = DB_DataObject_Cast::dateTime(); # current time
17323 hunk ./classes/Avatar.php 72
17324 -               if ($scaled->insert()) {
17325 -                       return $scaled;
17326 -               } else {
17327 -                       return NULL;
17328 -               }
17329 -       }
17330 +        if ($scaled->insert()) {
17331 +            return $scaled;
17332 +        } else {
17333 +            return NULL;
17334 +        }
17335 +    }
17336 hunk ./classes/Avatar.php 79
17337 -       function to_image() {
17338 -               $filepath = common_avatar_path($this->filename);
17339 -               if ($this->mediatype == 'image/gif') {
17340 -                       return imagecreatefromgif($filepath);
17341 -               } else if ($this->mediatype == 'image/jpeg') {
17342 -                       return imagecreatefromjpeg($filepath);
17343 -               } else if ($this->mediatype == 'image/png') {
17344 -                       return imagecreatefrompng($filepath);
17345 -               } else {
17346 -                       return NULL;
17347 -               }
17348 -       }
17349 -       
17350 -       function &pkeyGet($kv) {
17351 -               return Memcached_DataObject::pkeyGet('Avatar', $kv);
17352 -       }
17353 +    function to_image() {
17354 +        $filepath = common_avatar_path($this->filename);
17355 +        if ($this->mediatype == 'image/gif') {
17356 +            return imagecreatefromgif($filepath);
17357 +        } else if ($this->mediatype == 'image/jpeg') {
17358 +            return imagecreatefromjpeg($filepath);
17359 +        } else if ($this->mediatype == 'image/png') {
17360 +            return imagecreatefrompng($filepath);
17361 +        } else {
17362 +            return NULL;
17363 +        }
17364 +    }
17365 +    
17366 +    function &pkeyGet($kv) {
17367 +        return Memcached_DataObject::pkeyGet('Avatar', $kv);
17368 +    }
17369 hunk ./classes/Channel.php 23
17370 -       
17371 -       function on($user) {
17372 -               return false;
17373 -       }
17374 +    
17375 +    function on($user) {
17376 +        return false;
17377 +    }
17378 hunk ./classes/Channel.php 28
17379 -       function off($user) {
17380 -               return false;
17381 -       }
17382 +    function off($user) {
17383 +        return false;
17384 +    }
17385 hunk ./classes/Channel.php 32
17386 -       function output($user, $text) {
17387 -               return false;
17388 -       }
17389 -       
17390 -       function error($user, $text) {
17391 -               return false;
17392 -       }
17393 -       
17394 -       function source() {
17395 -               return NULL;
17396 -       }
17397 +    function output($user, $text) {
17398 +        return false;
17399 +    }
17400 +    
17401 +    function error($user, $text) {
17402 +        return false;
17403 +    }
17404 +    
17405 +    function source() {
17406 +        return NULL;
17407 +    }
17408 hunk ./classes/Channel.php 47
17409 -       var $conn = NULL;
17410 -       
17411 -       function source() {
17412 -               return 'xmpp';
17413 -       }
17414 -       
17415 -       function __construct($conn) {
17416 -               $this->conn = $conn;
17417 -       }
17418 -       
17419 -       function on($user) {
17420 -               return $this->set_notify($user, 1);
17421 -       }
17422 -       
17423 -       function off($user) {
17424 -               return $this->set_notify($user, 0);
17425 -       }
17426 +    var $conn = NULL;
17427 +    
17428 +    function source() {
17429 +        return 'xmpp';
17430 +    }
17431 +    
17432 +    function __construct($conn) {
17433 +        $this->conn = $conn;
17434 +    }
17435 +    
17436 +    function on($user) {
17437 +        return $this->set_notify($user, 1);
17438 +    }
17439 +    
17440 +    function off($user) {
17441 +        return $this->set_notify($user, 0);
17442 +    }
17443 hunk ./classes/Channel.php 65
17444 -       function output($user, $text) {
17445 -               $text = '['.common_config('site', 'name') . '] ' . $text;
17446 -               jabber_send_message($user->jabber, $text);
17447 -       }
17448 -       
17449 -       function error($user, $text) {
17450 -               $text = '['.common_config('site', 'name') . '] ' . $text;
17451 -               jabber_send_message($user->jabber, $text);
17452 -       }
17453 -       
17454 -       function set_notify(&$user, $notify) {
17455 -               $orig = clone($user);
17456 -               $user->jabbernotify = $notify;
17457 -               $result = $user->update($orig);
17458 -               if (!$result) {
17459 -                       $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
17460 -                       common_log(LOG_ERR,
17461 -                                          'Could not set notify flag to ' . $notify .
17462 -                                          ' for user ' . common_log_objstring($user) .
17463 -                                          ': ' . $last_error->message);
17464 -                       return false;
17465 -               } else {
17466 -                       common_log(LOG_INFO,
17467 -                                          'User ' . $user->nickname . ' set notify flag to ' . $notify);
17468 -                       return true;
17469 -               }
17470 -       }
17471 +    function output($user, $text) {
17472 +        $text = '['.common_config('site', 'name') . '] ' . $text;
17473 +        jabber_send_message($user->jabber, $text);
17474 +    }
17475 +    
17476 +    function error($user, $text) {
17477 +        $text = '['.common_config('site', 'name') . '] ' . $text;
17478 +        jabber_send_message($user->jabber, $text);
17479 +    }
17480 +    
17481 +    function set_notify(&$user, $notify) {
17482 +        $orig = clone($user);
17483 +        $user->jabbernotify = $notify;
17484 +        $result = $user->update($orig);
17485 +        if (!$result) {
17486 +            $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
17487 +            common_log(LOG_ERR,
17488 +                       'Could not set notify flag to ' . $notify .
17489 +                       ' for user ' . common_log_objstring($user) .
17490 +                       ': ' . $last_error->message);
17491 +            return false;
17492 +        } else {
17493 +            common_log(LOG_INFO,
17494 +                       'User ' . $user->nickname . ' set notify flag to ' . $notify);
17495 +            return true;
17496 +        }
17497 +    }
17498 hunk ./classes/Channel.php 97
17499 -       function source() {
17500 -               return 'web';
17501 -       }
17502 -       
17503 -       function on($user) {
17504 -               return false;
17505 -       }
17506 -       
17507 -       function off($user) {
17508 -               return false;
17509 -       }
17510 +    function source() {
17511 +        return 'web';
17512 +    }
17513 +    
17514 +    function on($user) {
17515 +        return false;
17516 +    }
17517 +    
17518 +    function off($user) {
17519 +        return false;
17520 +    }
17521 hunk ./classes/Channel.php 109
17522 -       function output($user, $text) {
17523 -               # XXX: buffer all output and send it at the end
17524 -               # XXX: even better, redirect to appropriate page
17525 -               #      depending on what command was run
17526 -               common_show_header(_('Command results'));
17527 -               common_element('p', NULL, $text);
17528 -               common_show_footer();
17529 -       }
17530 -       
17531 -       function error($user, $text) {
17532 -               common_user_error($text);
17533 -       }
17534 +    function output($user, $text) {
17535 +        # XXX: buffer all output and send it at the end
17536 +        # XXX: even better, redirect to appropriate page
17537 +        #      depending on what command was run
17538 +        common_show_header(_('Command results'));
17539 +        common_element('p', NULL, $text);
17540 +        common_show_footer();
17541 +    }
17542 +    
17543 +    function error($user, $text) {
17544 +        common_user_error($text);
17545 +    }
17546 hunk ./classes/Channel.php 126
17547 -       function output($user, $text) {
17548 -               common_start_html('text/xml;charset=utf-8', true);
17549 -               common_element_start('head');
17550 -               common_element('title', null, _('Command results'));
17551 -               common_element_end('head');
17552 -               common_element_start('body');
17553 -               common_element('p', array('id' => 'command_result'), $text);
17554 -               common_element_end('body');
17555 -               common_element_end('html');
17556 -       }
17557 +    function output($user, $text) {
17558 +        common_start_html('text/xml;charset=utf-8', true);
17559 +        common_element_start('head');
17560 +        common_element('title', null, _('Command results'));
17561 +        common_element_end('head');
17562 +        common_element_start('body');
17563 +        common_element('p', array('id' => 'command_result'), $text);
17564 +        common_element_end('body');
17565 +        common_element_end('html');
17566 +    }
17567 hunk ./classes/Channel.php 137
17568 -       function error($user, $text) {
17569 -               common_start_html('text/xml;charset=utf-8', true);
17570 -               common_element_start('head');
17571 -               common_element('title', null, _('Ajax Error'));
17572 -               common_element_end('head');
17573 -               common_element_start('body');
17574 -               common_element('p', array('id' => 'error'), $text);
17575 -               common_element_end('body');
17576 -               common_element_end('html');
17577 -       }
17578 +    function error($user, $text) {
17579 +        common_start_html('text/xml;charset=utf-8', true);
17580 +        common_element_start('head');
17581 +        common_element('title', null, _('Ajax Error'));
17582 +        common_element_end('head');
17583 +        common_element_start('body');
17584 +        common_element('p', array('id' => 'error'), $text);
17585 +        common_element_end('body');
17586 +        common_element_end('html');
17587 +    }
17588 hunk ./classes/Channel.php 152
17589 -       var $addr = NULL;
17590 +    var $addr = NULL;
17591 hunk ./classes/Channel.php 154
17592 -       function source() {
17593 -               return 'mail';
17594 -       }
17595 -       
17596 -       function __construct($addr=NULL) {
17597 -               $this->addr = $addr;
17598 -       }
17599 -       
17600 -       function on($user) {
17601 -               return $this->set_notify($user, 1);
17602 -       }
17603 -       
17604 -       function off($user) {
17605 -               return $this->set_notify($user, 0);
17606 -       }
17607 +    function source() {
17608 +        return 'mail';
17609 +    }
17610 +    
17611 +    function __construct($addr=NULL) {
17612 +        $this->addr = $addr;
17613 +    }
17614 +    
17615 +    function on($user) {
17616 +        return $this->set_notify($user, 1);
17617 +    }
17618 +    
17619 +    function off($user) {
17620 +        return $this->set_notify($user, 0);
17621 +    }
17622 hunk ./classes/Channel.php 170
17623 -       function output($user, $text) {
17624 +    function output($user, $text) {
17625 hunk ./classes/Channel.php 172
17626 -               $headers['From'] = $user->incomingemail;
17627 -               $headers['To'] = $this->addr;
17628 -               
17629 -               $headers['Subject'] = _('Command complete');
17630 +        $headers['From'] = $user->incomingemail;
17631 +        $headers['To'] = $this->addr;
17632 +        
17633 +        $headers['Subject'] = _('Command complete');
17634 hunk ./classes/Channel.php 177
17635 -               return mail_send(array($this->addr), $headers, $text);
17636 -       }
17637 -       
17638 -       function error($user, $text) {
17639 -               
17640 -               $headers['From'] = $user->incomingemail;
17641 -               $headers['To'] = $this->addr;
17642 -               
17643 -               $headers['Subject'] = _('Command failed');
17644 +        return mail_send(array($this->addr), $headers, $text);
17645 +    }
17646 +    
17647 +    function error($user, $text) {
17648 +        
17649 +        $headers['From'] = $user->incomingemail;
17650 +        $headers['To'] = $this->addr;
17651 +        
17652 +        $headers['Subject'] = _('Command failed');
17653 hunk ./classes/Channel.php 187
17654 -               return mail_send(array($this->addr), $headers, $text);
17655 -       }
17656 -       
17657 -       function set_notify($user, $value) {
17658 -               $orig = clone($user);
17659 -               $user->smsnotify = $value;
17660 -               $result = $user->update($orig);
17661 -               if (!$result) {
17662 -                       common_log_db_error($user, 'UPDATE', __FILE__);
17663 -                       return false;
17664 -               }
17665 -               return true;
17666 -       }
17667 +        return mail_send(array($this->addr), $headers, $text);
17668 +    }
17669 +    
17670 +    function set_notify($user, $value) {
17671 +        $orig = clone($user);
17672 +        $user->smsnotify = $value;
17673 +        $result = $user->update($orig);
17674 +        if (!$result) {
17675 +            common_log_db_error($user, 'UPDATE', __FILE__);
17676 +            return false;
17677 +        }
17678 +        return true;
17679 +    }
17680 hunk ./classes/Command.php 25
17681 -       
17682 -       var $user = NULL;
17683 -       
17684 -       function __construct($user=NULL) {
17685 -               $this->user = $user;
17686 -       }
17687 -       
17688 -       function execute($channel) {
17689 -               return false;
17690 -       }
17691 +    
17692 +    var $user = NULL;
17693 +    
17694 +    function __construct($user=NULL) {
17695 +        $this->user = $user;
17696 +    }
17697 +    
17698 +    function execute($channel) {
17699 +        return false;
17700 +    }
17701 hunk ./classes/Command.php 38
17702 -       function execute($channel) {
17703 -               $channel->error($this->user, _("Sorry, this command is not yet implemented."));
17704 -       }
17705 +    function execute($channel) {
17706 +        $channel->error($this->user, _("Sorry, this command is not yet implemented."));
17707 +    }
17708 hunk ./classes/Command.php 50
17709 -       var $word = NULL;
17710 -       function __construct($user, $word) {
17711 -               parent::__construct($user);
17712 -               $this->word = $word;
17713 -       }
17714 +    var $word = NULL;
17715 +    function __construct($user, $word) {
17716 +        parent::__construct($user);
17717 +        $this->word = $word;
17718 +    }
17719 hunk ./classes/Command.php 58
17720 -       var $word = NULL;
17721 -       function __construct($user, $word) {
17722 -               parent::__construct($user);
17723 -               $this->word = $word;
17724 -       }
17725 +    var $word = NULL;
17726 +    function __construct($user, $word) {
17727 +        parent::__construct($user);
17728 +        $this->word = $word;
17729 +    }
17730 hunk ./classes/Command.php 66
17731 -       var $other = NULL;
17732 -       function __construct($user, $other) {
17733 -               parent::__construct($user);
17734 -               $this->other = $other;
17735 -       }
17736 +    var $other = NULL;
17737 +    function __construct($user, $other) {
17738 +        parent::__construct($user);
17739 +        $this->other = $other;
17740 +    }
17741 hunk ./classes/Command.php 74
17742 -       var $other = NULL;
17743 -       function __construct($user, $other) {
17744 -               parent::__construct($user);
17745 -               $this->other = $other;
17746 -       }
17747 +    var $other = NULL;
17748 +    function __construct($user, $other) {
17749 +        parent::__construct($user);
17750 +        $this->other = $other;
17751 +    }
17752 hunk ./classes/Command.php 82
17753 -       function execute($channel) {
17754 +    function execute($channel) {
17755 hunk ./classes/Command.php 84
17756 -               $subs = new Subscription();
17757 -               $subs->subscriber = $this->user->id;
17758 -               $subs_count = (int) $subs->count() - 1;
17759 +        $subs = new Subscription();
17760 +        $subs->subscriber = $this->user->id;
17761 +        $subs_count = (int) $subs->count() - 1;
17762 hunk ./classes/Command.php 88
17763 -               $subbed = new Subscription();
17764 -               $subbed->subscribed = $this->user->id;
17765 -               $subbed_count = (int) $subbed->count() - 1;
17766 +        $subbed = new Subscription();
17767 +        $subbed->subscribed = $this->user->id;
17768 +        $subbed_count = (int) $subbed->count() - 1;
17769 hunk ./classes/Command.php 92
17770 -               $notices = new Notice();
17771 -               $notices->profile_id = $this->user->id;
17772 -               $notice_count = (int) $notices->count();
17773 -               
17774 -               $channel->output($this->user, sprintf(_("Subscriptions: %1\$s\n".
17775 -                                                                  "Subscribers: %2\$s\n".
17776 -                                                                  "Notices: %3\$s"),
17777 -                                                                $subs_count,
17778 -                                                                $subbed_count,
17779 -                                                                $notice_count));
17780 -       }
17781 +        $notices = new Notice();
17782 +        $notices->profile_id = $this->user->id;
17783 +        $notice_count = (int) $notices->count();
17784 +        
17785 +        $channel->output($this->user, sprintf(_("Subscriptions: %1\$s\n".
17786 +                                   "Subscribers: %2\$s\n".
17787 +                                   "Notices: %3\$s"),
17788 +                                 $subs_count,
17789 +                                 $subbed_count,
17790 +                                 $notice_count));
17791 +    }
17792 hunk ./classes/Command.php 106
17793 -       
17794 -       var $other = NULL;
17795 -       
17796 -       function __construct($user, $other) {
17797 -               parent::__construct($user);
17798 -               $this->other = $other;
17799 -       }
17800 -       
17801 -       function execute($channel) {
17802 -               
17803 -               $recipient = 
17804 -                 common_relative_profile($this->user, common_canonical_nickname($this->other));
17805 -               
17806 -               if (!$recipient) {
17807 -                       $channel->error($this->user, _('No such user.'));
17808 -                       return;
17809 -               }
17810 -               $notice = $recipient->getCurrentNotice();
17811 -               if (!$notice) {
17812 -                       $channel->error($this->user, _('User has no last notice'));
17813 -                       return;
17814 -               }
17815 -               
17816 -               $fave = Fave::addNew($this->user, $notice);
17817 +    
17818 +    var $other = NULL;
17819 +    
17820 +    function __construct($user, $other) {
17821 +        parent::__construct($user);
17822 +        $this->other = $other;
17823 +    }
17824 +    
17825 +    function execute($channel) {
17826 +        
17827 +        $recipient = 
17828 +          common_relative_profile($this->user, common_canonical_nickname($this->other));
17829 +        
17830 +        if (!$recipient) {
17831 +            $channel->error($this->user, _('No such user.'));
17832 +            return;
17833 +        }
17834 +        $notice = $recipient->getCurrentNotice();
17835 +        if (!$notice) {
17836 +            $channel->error($this->user, _('User has no last notice'));
17837 +            return;
17838 +        }
17839 +        
17840 +        $fave = Fave::addNew($this->user, $notice);
17841 hunk ./classes/Command.php 131
17842 -               if (!$fave) {
17843 -                       $channel->error($this->user, _('Could not create favorite.'));
17844 -                       return;
17845 -               }
17846 +        if (!$fave) {
17847 +            $channel->error($this->user, _('Could not create favorite.'));
17848 +            return;
17849 +        }
17850 hunk ./classes/Command.php 136
17851 -           $other = User::staticGet('id', $recipient->id);
17852 -               
17853 -               if ($other && $other->id != $user->id) {
17854 -                       if ($other->email && $other->emailnotifyfav) {
17855 -                               mail_notify_fave($other, $this->user, $notice);
17856 -                       }
17857 -               }
17858 -               
17859 -               $this->user->blowFavesCache();
17860 -               
17861 -               $channel->output($this->user, _('Notice marked as fave.'));
17862 -       }
17863 +        $other = User::staticGet('id', $recipient->id);
17864 +        
17865 +        if ($other && $other->id != $user->id) {
17866 +            if ($other->email && $other->emailnotifyfav) {
17867 +                mail_notify_fave($other, $this->user, $notice);
17868 +            }
17869 +        }
17870 +        
17871 +        $this->user->blowFavesCache();
17872 +        
17873 +        $channel->output($this->user, _('Notice marked as fave.'));
17874 +    }
17875 hunk ./classes/Command.php 151
17876 -       var $other = NULL;
17877 -       function __construct($user, $other) {
17878 -               parent::__construct($user);
17879 -               $this->other = $other;
17880 -       }
17881 -       
17882 -       function execute($channel) {
17883 -               $recipient = 
17884 -                 common_relative_profile($this->user, common_canonical_nickname($this->other));
17885 -               
17886 -               if (!$recipient) {
17887 -                       $channel->error($this->user, _('No such user.'));
17888 -                       return;
17889 -               }
17890 -               
17891 -               $whois = sprintf(_("%1\$s (%2\$s)"), $recipient->nickname,
17892 -                                                $recipient->profileurl);
17893 -               if ($recipient->fullname) {
17894 -                       $whois .= "\n" . sprintf(_('Fullname: %s'), $recipient->fullname);
17895 -               }
17896 -               if ($recipient->location) {
17897 -                       $whois .= "\n" . sprintf(_('Location: %s'), $recipient->location);
17898 -               }
17899 -               if ($recipient->homepage) {
17900 -                       $whois .= "\n" . sprintf(_('Homepage: %s'), $recipient->homepage);
17901 -               }
17902 -               if ($recipient->bio) {
17903 -                       $whois .= "\n" . sprintf(_('About: %s'), $recipient->bio);
17904 -               }
17905 -               $channel->output($this->user, $whois);
17906 -       }
17907 +    var $other = NULL;
17908 +    function __construct($user, $other) {
17909 +        parent::__construct($user);
17910 +        $this->other = $other;
17911 +    }
17912 +    
17913 +    function execute($channel) {
17914 +        $recipient = 
17915 +          common_relative_profile($this->user, common_canonical_nickname($this->other));
17916 +        
17917 +        if (!$recipient) {
17918 +            $channel->error($this->user, _('No such user.'));
17919 +            return;
17920 +        }
17921 +        
17922 +        $whois = sprintf(_("%1\$s (%2\$s)"), $recipient->nickname,
17923 +                         $recipient->profileurl);
17924 +        if ($recipient->fullname) {
17925 +            $whois .= "\n" . sprintf(_('Fullname: %s'), $recipient->fullname);
17926 +        }
17927 +        if ($recipient->location) {
17928 +            $whois .= "\n" . sprintf(_('Location: %s'), $recipient->location);
17929 +        }
17930 +        if ($recipient->homepage) {
17931 +            $whois .= "\n" . sprintf(_('Homepage: %s'), $recipient->homepage);
17932 +        }
17933 +        if ($recipient->bio) {
17934 +            $whois .= "\n" . sprintf(_('About: %s'), $recipient->bio);
17935 +        }
17936 +        $channel->output($this->user, $whois);
17937 +    }
17938 hunk ./classes/Command.php 185
17939 -       var $other = NULL;
17940 -       var $text = NULL;
17941 -       function __construct($user, $other, $text) {
17942 -               parent::__construct($user);
17943 -               $this->other = $other;
17944 -               $this->text = $text;
17945 -       }
17946 -       
17947 -       function execute($channel) {
17948 -               $other = User::staticGet('nickname', common_canonical_nickname($this->other));
17949 -               $len = mb_strlen($this->text);
17950 -               if ($len == 0) {
17951 -                       $channel->error($this->user, _('No content!'));
17952 -                       return;
17953 -               } else if ($len > 140) {
17954 -                       $content = common_shorten_links($content);
17955 -                       if (mb_strlen($content) > 140) {
17956 -                               $channel->error($this->user, sprintf(_('Message too long - maximum is 140 characters, you sent %d'), $len));
17957 -                               return;
17958 -                       }
17959 -               }
17960 -               
17961 -               if (!$other) {
17962 -                       $channel->error($this->user, _('No such user.'));
17963 -                       return;
17964 -               } else if (!$this->user->mutuallySubscribed($other)) {
17965 -                       $channel->error($this->user, _('You can\'t send a message to this user.'));
17966 -                       return;
17967 -               } else if ($this->user->id == $other->id) {
17968 -                       $channel->error($this->user, _('Don\'t send a message to yourself; just say it to yourself quietly instead.'));
17969 -                       return;
17970 -               }
17971 -               $message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
17972 -               if ($message) {
17973 -                       $channel->output($this->user, sprintf(_('Direct message to %s sent'), $this->other));
17974 -               } else {
17975 -                       $channel->error($this->user, _('Error sending direct message.'));
17976 -               }
17977 -       }
17978 +    var $other = NULL;
17979 +    var $text = NULL;
17980 +    function __construct($user, $other, $text) {
17981 +        parent::__construct($user);
17982 +        $this->other = $other;
17983 +        $this->text = $text;
17984 +    }
17985 +    
17986 +    function execute($channel) {
17987 +        $other = User::staticGet('nickname', common_canonical_nickname($this->other));
17988 +        $len = mb_strlen($this->text);
17989 +        if ($len == 0) {
17990 +            $channel->error($this->user, _('No content!'));
17991 +            return;
17992 +        } else if ($len > 140) {
17993 +            $content = common_shorten_links($content);
17994 +            if (mb_strlen($content) > 140) {
17995 +                $channel->error($this->user, sprintf(_('Message too long - maximum is 140 characters, you sent %d'), $len));
17996 +                return;
17997 +            }
17998 +        }
17999 +        
18000 +        if (!$other) {
18001 +            $channel->error($this->user, _('No such user.'));
18002 +            return;
18003 +        } else if (!$this->user->mutuallySubscribed($other)) {
18004 +            $channel->error($this->user, _('You can\'t send a message to this user.'));
18005 +            return;
18006 +        } else if ($this->user->id == $other->id) {
18007 +            $channel->error($this->user, _('Don\'t send a message to yourself; just say it to yourself quietly instead.'));
18008 +            return;
18009 +        }
18010 +        $message = Message::saveNew($this->user->id, $other->id, $this->text, $channel->source());
18011 +        if ($message) {
18012 +            $channel->output($this->user, sprintf(_('Direct message to %s sent'), $this->other));
18013 +        } else {
18014 +            $channel->error($this->user, _('Error sending direct message.'));
18015 +        }
18016 +    }
18017 hunk ./classes/Command.php 227
18018 -       
18019 -       var $other = NULL;
18020 -       
18021 -       function __construct($user, $other) {
18022 -               parent::__construct($user);
18023 -               $this->other = $other;
18024 -       }
18025 -       
18026 -       function execute($channel) {
18027 -               $target_nickname = common_canonical_nickname($this->other);
18028 -               
18029 -               $target =
18030 -                 common_relative_profile($this->user, $target_nickname);
18031 +    
18032 +    var $other = NULL;
18033 +    
18034 +    function __construct($user, $other) {
18035 +        parent::__construct($user);
18036 +        $this->other = $other;
18037 +    }
18038 +    
18039 +    function execute($channel) {
18040 +        $target_nickname = common_canonical_nickname($this->other);
18041 +        
18042 +        $target =
18043 +          common_relative_profile($this->user, $target_nickname);
18044 hunk ./classes/Command.php 241
18045 -               if (!$target) {
18046 -                       $channel->error($this->user, _('No such user.'));
18047 -                       return;
18048 -               }
18049 -               $notice = $target->getCurrentNotice();
18050 -               if (!$notice) {
18051 -                       $channel->error($this->user, _('User has no last notice'));
18052 -                       return;
18053 -               }
18054 -               $notice_content = $notice->content;
18055 -               
18056 -               $channel->output($this->user, $target_nickname . ": " . $notice_content);
18057 -       }
18058 +        if (!$target) {
18059 +            $channel->error($this->user, _('No such user.'));
18060 +            return;
18061 +        }
18062 +        $notice = $target->getCurrentNotice();
18063 +        if (!$notice) {
18064 +            $channel->error($this->user, _('User has no last notice'));
18065 +            return;
18066 +        }
18067 +        $notice_content = $notice->content;
18068 +        
18069 +        $channel->output($this->user, $target_nickname . ": " . $notice_content);
18070 +    }
18071 hunk ./classes/Command.php 257
18072 -       
18073 -       var $other = NULL;
18074 -       
18075 -       function __construct($user, $other) {
18076 -               parent::__construct($user);
18077 -               $this->other = $other;
18078 -       }
18079 -       
18080 -       function execute($channel) {
18081 -               
18082 -               if (!$this->other) {
18083 -                       $channel->error($this->user, _('Specify the name of the user to subscribe to'));
18084 -                       return;
18085 -               }
18086 -               
18087 -               $result = subs_subscribe_user($this->user, $this->other);
18088 -               
18089 -               if ($result == 'true') {
18090 -                       $channel->output($this->user, sprintf(_('Subscribed to %s'), $this->other));
18091 -               } else {
18092 -                       $channel->error($this->user, $result);
18093 -               }
18094 -       }
18095 +    
18096 +    var $other = NULL;
18097 +    
18098 +    function __construct($user, $other) {
18099 +        parent::__construct($user);
18100 +        $this->other = $other;
18101 +    }
18102 +    
18103 +    function execute($channel) {
18104 +        
18105 +        if (!$this->other) {
18106 +            $channel->error($this->user, _('Specify the name of the user to subscribe to'));
18107 +            return;
18108 +        }
18109 +        
18110 +        $result = subs_subscribe_user($this->user, $this->other);
18111 +        
18112 +        if ($result == 'true') {
18113 +            $channel->output($this->user, sprintf(_('Subscribed to %s'), $this->other));
18114 +        } else {
18115 +            $channel->error($this->user, $result);
18116 +        }
18117 +    }
18118 hunk ./classes/Command.php 284
18119 -       var $other = NULL;
18120 -       
18121 -       function __construct($user, $other) {
18122 -               parent::__construct($user);
18123 -               $this->other = $other;
18124 -       }
18125 +    var $other = NULL;
18126 +    
18127 +    function __construct($user, $other) {
18128 +        parent::__construct($user);
18129 +        $this->other = $other;
18130 +    }
18131 hunk ./classes/Command.php 291
18132 -       function execute($channel) {
18133 -               if(!$this->other) {
18134 -                       $channel->error($this->user, _('Specify the name of the user to unsubscribe from'));
18135 -                       return;
18136 -               }
18137 -               
18138 -               $result=subs_unsubscribe_user($this->user, $this->other);
18139 -               
18140 -               if ($result) {
18141 -                       $channel->output($this->user, sprintf(_('Unsubscribed from %s'), $this->other));
18142 -               } else {
18143 -                       $channel->error($this->user, $result);
18144 -               }
18145 -       }
18146 +    function execute($channel) {
18147 +        if(!$this->other) {
18148 +            $channel->error($this->user, _('Specify the name of the user to unsubscribe from'));
18149 +            return;
18150 +        }
18151 +        
18152 +        $result=subs_unsubscribe_user($this->user, $this->other);
18153 +        
18154 +        if ($result) {
18155 +            $channel->output($this->user, sprintf(_('Unsubscribed from %s'), $this->other));
18156 +        } else {
18157 +            $channel->error($this->user, $result);
18158 +        }
18159 +    }
18160 hunk ./classes/Command.php 308
18161 -       var $other = NULL;
18162 -       function __construct($user, $other=NULL) {
18163 -               parent::__construct($user);
18164 -               $this->other = $other;
18165 -       }
18166 -       function execute($channel) {
18167 -               if ($other) {
18168 -                       $channel->error($this->user, _("Command not yet implemented."));
18169 -               } else {
18170 -                       if ($channel->off($this->user)) {
18171 -                               $channel->output($this->user, _('Notification off.'));
18172 -                       } else {
18173 -                               $channel->error($this->user, _('Can\'t turn off notification.'));
18174 -                       }
18175 -               }
18176 -       }
18177 +    var $other = NULL;
18178 +    function __construct($user, $other=NULL) {
18179 +        parent::__construct($user);
18180 +        $this->other = $other;
18181 +    }
18182 +    function execute($channel) {
18183 +        if ($other) {
18184 +            $channel->error($this->user, _("Command not yet implemented."));
18185 +        } else {
18186 +            if ($channel->off($this->user)) {
18187 +                $channel->output($this->user, _('Notification off.'));
18188 +            } else {
18189 +                $channel->error($this->user, _('Can\'t turn off notification.'));
18190 +            }
18191 +        }
18192 +    }
18193 hunk ./classes/Command.php 327
18194 -       var $other = NULL;
18195 -       function __construct($user, $other=NULL) {
18196 -               parent::__construct($user);
18197 -               $this->other = $other;
18198 -       }
18199 -       
18200 -       function execute($channel) {
18201 -               if ($other) {
18202 -                       $channel->error($this->user, _("Command not yet implemented."));
18203 -               } else {
18204 -                       if ($channel->on($this->user)) {
18205 -                               $channel->output($this->user, _('Notification on.'));
18206 -                       } else {
18207 -                               $channel->error($this->user, _('Can\'t turn on notification.'));
18208 -                       }
18209 -               }
18210 -       }
18211 +    var $other = NULL;
18212 +    function __construct($user, $other=NULL) {
18213 +        parent::__construct($user);
18214 +        $this->other = $other;
18215 +    }
18216 +    
18217 +    function execute($channel) {
18218 +        if ($other) {
18219 +            $channel->error($this->user, _("Command not yet implemented."));
18220 +        } else {
18221 +            if ($channel->on($this->user)) {
18222 +                $channel->output($this->user, _('Notification on.'));
18223 +            } else {
18224 +                $channel->error($this->user, _('Can\'t turn on notification.'));
18225 +            }
18226 +        }
18227 +    }
18228 hunk ./classes/Command.php 347
18229 -       function execute($channel) {
18230 -               $channel->output($this->user,
18231 -                                                _("Commands:\n".
18232 -                                                  "on - turn on notifications\n".
18233 -                                                  "off - turn off notifications\n".
18234 -                                                  "help - show this help\n".
18235 -                                                  "follow <nickname> - subscribe to user\n".
18236 -                                                  "leave <nickname> - unsubscribe from user\n".
18237 -                                                  "d <nickname> <text> - direct message to user\n".
18238 -                                                  "get <nickname> - get last notice from user\n".
18239 -                                                  "whois <nickname> - get profile info on user\n".
18240 -                                                  "fav <nickname> - add user's last notice as a 'fave'\n".
18241 -                                                  "stats - get your stats\n".
18242 -                                                  "stop - same as 'off'\n".
18243 -                                                  "quit - same as 'off'\n".
18244 -                                                  "sub <nickname> - same as 'follow'\n".
18245 -                                                  "unsub <nickname> - same as 'leave'\n".
18246 -                                                  "last <nickname> - same as 'get'\n".
18247 -                                                  "on <nickname> - not yet implemented.\n".
18248 -                                                  "off <nickname> - not yet implemented.\n".                                              
18249 -                                                  "nudge <nickname> - not yet implemented.\n".
18250 -                                                  "invite <phone number> - not yet implemented.\n".
18251 -                                                  "track <word> - not yet implemented.\n".
18252 -                                                  "untrack <word> - not yet implemented.\n".
18253 -                                                  "track off - not yet implemented.\n".
18254 -                                                  "untrack all - not yet implemented.\n".
18255 -                                                  "tracks - not yet implemented.\n".
18256 -                                                  "tracking - not yet implemented.\n"));
18257 -       }
18258 +    function execute($channel) {
18259 +        $channel->output($this->user,
18260 +                         _("Commands:\n".
18261 +                           "on - turn on notifications\n".
18262 +                           "off - turn off notifications\n".
18263 +                           "help - show this help\n".
18264 +                           "follow <nickname> - subscribe to user\n".
18265 +                           "leave <nickname> - unsubscribe from user\n".
18266 +                           "d <nickname> <text> - direct message to user\n".
18267 +                           "get <nickname> - get last notice from user\n".
18268 +                           "whois <nickname> - get profile info on user\n".
18269 +                           "fav <nickname> - add user's last notice as a 'fave'\n".
18270 +                           "stats - get your stats\n".
18271 +                           "stop - same as 'off'\n".
18272 +                           "quit - same as 'off'\n".
18273 +                           "sub <nickname> - same as 'follow'\n".
18274 +                           "unsub <nickname> - same as 'leave'\n".
18275 +                           "last <nickname> - same as 'get'\n".
18276 +                           "on <nickname> - not yet implemented.\n".
18277 +                           "off <nickname> - not yet implemented.\n".                           
18278 +                           "nudge <nickname> - not yet implemented.\n".
18279 +                           "invite <phone number> - not yet implemented.\n".
18280 +                           "track <word> - not yet implemented.\n".
18281 +                           "untrack <word> - not yet implemented.\n".
18282 +                           "track off - not yet implemented.\n".
18283 +                           "untrack all - not yet implemented.\n".
18284 +                           "tracks - not yet implemented.\n".
18285 +                           "tracking - not yet implemented.\n"));
18286 +    }
18287 hunk ./classes/CommandInterpreter.php 25
18288 -       
18289 -       function handle_command($user, $text) {
18290 -               # XXX: localise
18291 +    
18292 +    function handle_command($user, $text) {
18293 +        # XXX: localise
18294 hunk ./classes/CommandInterpreter.php 29
18295 -               $text = preg_replace('/\s+/', ' ', trim($text));
18296 -               list($cmd, $arg) = explode(' ', $text, 2);
18297 +        $text = preg_replace('/\s+/', ' ', trim($text));
18298 +        list($cmd, $arg) = explode(' ', $text, 2);
18299 hunk ./classes/CommandInterpreter.php 32
18300 -               # We try to support all the same commands as Twitter, see
18301 -               # http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands
18302 -               # There are a few compatibility commands from earlier versions of 
18303 -               # Laconica
18304 -               
18305 -               switch(strtolower($cmd)) {
18306 -                case 'help':
18307 -                       if ($arg) {
18308 -                               return NULL;
18309 -                       }
18310 -                       return new HelpCommand($user);
18311 -                case 'on':
18312 -                       if ($arg) {
18313 -                               list($other, $extra) = explode(' ', $arg, 2);
18314 -                               if ($extra) {
18315 -                                       return NULL;
18316 -                               } else {
18317 -                                       return new OnCommand($user, $other);
18318 -                               }
18319 -                       } else {
18320 -                               return new OnCommand($user);
18321 -                       }
18322 -                case 'off':
18323 -                       if ($arg) {
18324 -                               list($other, $extra) = explode(' ', $arg, 2);
18325 -                               if ($extra) {
18326 -                                       return NULL;
18327 -                               } else {
18328 -                                       return new OffCommand($user, $other);
18329 -                               }
18330 -                       } else {
18331 -                               return new OffCommand($user);
18332 -                       }
18333 -                case 'stop':
18334 -                case 'quit':
18335 -                       if ($arg) {
18336 -                               return NULL;
18337 -                       } else {
18338 -                               return new OffCommand($user);
18339 -                       }
18340 -                case 'follow':
18341 -                case 'sub':
18342 -                       if (!$arg) {
18343 -                               return NULL;
18344 -                       }
18345 -                       list($other, $extra) = explode(' ', $arg, 2);
18346 -                       if ($extra) {
18347 -                               return NULL;
18348 -                       } else {
18349 -                               return new SubCommand($user, $other);
18350 -                       }
18351 -                case 'leave':
18352 -                case 'unsub':
18353 -                       if (!$arg) {
18354 -                               return NULL;
18355 -                       }
18356 -                       list($other, $extra) = explode(' ', $arg, 2);
18357 -                       if ($extra) {
18358 -                               return NULL;
18359 -                       } else {
18360 -                               return new UnsubCommand($user, $other);
18361 -                       }
18362 -                case 'get':
18363 -                case 'last':
18364 -                       if (!$arg) {
18365 -                               return NULL;
18366 -                       }
18367 -                       list($other, $extra) = explode(' ', $arg, 2);
18368 -                       if ($extra) {
18369 -                               return NULL;
18370 -                       } else {
18371 -                               return new GetCommand($user, $other);
18372 -                       }
18373 -                case 'd':
18374 -                       if (!$arg) {
18375 -                               return NULL;
18376 -                       }
18377 -                       list($other, $extra) = explode(' ', $arg, 2);
18378 -                       if (!$extra) {
18379 -                               return NULL;
18380 -                       } else {
18381 -                               return new MessageCommand($user, $other, $extra);
18382 -                       }
18383 -                case 'whois':
18384 -                       if (!$arg) {
18385 -                               return NULL;
18386 -                       }
18387 -                       list($other, $extra) = explode(' ', $arg, 2);
18388 -                       if ($extra) {
18389 -                               return NULL;
18390 -                       } else {
18391 -                               return new WhoisCommand($user, $other);
18392 -                       }
18393 -                case 'fav':
18394 -                       if (!$arg) {
18395 -                               return NULL;
18396 -                       }
18397 -                       list($other, $extra) = explode(' ', $arg, 2);
18398 -                       if ($extra) {
18399 -                               return NULL;
18400 -                       } else {
18401 -                               return new FavCommand($user, $other);
18402 -                       }
18403 -                case 'nudge':
18404 -                       if (!$arg) {
18405 -                               return NULL;
18406 -                       }
18407 -                       list($other, $extra) = explode(' ', $arg, 2);
18408 -                       if ($extra) {
18409 -                               return NULL;
18410 -                       } else {
18411 -                               return new NudgeCommand($user, $other);
18412 -                       }
18413 -                case 'stats':
18414 -                       if ($arg) {
18415 -                               return NULL;
18416 -                       }
18417 -                       return new StatsCommand($user);
18418 -                case 'invite':
18419 -                       if (!$arg) {
18420 -                               return NULL;
18421 -                       }
18422 -                       list($other, $extra) = explode(' ', $arg, 2);
18423 -                       if ($extra) {
18424 -                               return NULL;
18425 -                       } else {
18426 -                               return new InviteCommand($user, $other);
18427 -                       }
18428 -                case 'track':
18429 -                       if (!$arg) {
18430 -                               return NULL;
18431 -                       }
18432 -                       list($word, $extra) = explode(' ', $arg, 2);
18433 -                       if ($extra) {
18434 -                               return NULL;
18435 -                       } else if ($word == 'off') {
18436 -                               return new TrackOffCommand($user);
18437 -                       } else {
18438 -                               return new TrackCommand($user, $word);
18439 -                       }
18440 -                case 'untrack':
18441 -                       if (!$arg) {
18442 -                               return NULL;
18443 -                       }
18444 -                       list($word, $extra) = explode(' ', $arg, 2);
18445 -                       if ($extra) {
18446 -                               return NULL;
18447 -                       } else if ($word == 'all') {
18448 -                               return new TrackOffCommand($user);
18449 -                       } else {
18450 -                               return new UntrackCommand($user, $word);
18451 -                       }
18452 -                case 'tracks':
18453 -                case 'tracking':
18454 -                       if ($arg) {
18455 -                               return NULL;
18456 -                       }
18457 -                       return new TrackingCommand($user);
18458 -                default:
18459 -                       return false;
18460 -               }
18461 -       }
18462 +        # We try to support all the same commands as Twitter, see
18463 +        # http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands
18464 +        # There are a few compatibility commands from earlier versions of 
18465 +        # Laconica
18466 +        
18467 +        switch(strtolower($cmd)) {
18468 +         case 'help':
18469 +            if ($arg) {
18470 +                return NULL;
18471 +            }
18472 +            return new HelpCommand($user);
18473 +         case 'on':
18474 +            if ($arg) {
18475 +                list($other, $extra) = explode(' ', $arg, 2);
18476 +                if ($extra) {
18477 +                    return NULL;
18478 +                } else {
18479 +                    return new OnCommand($user, $other);
18480 +                }
18481 +            } else {
18482 +                return new OnCommand($user);
18483 +            }
18484 +         case 'off':
18485 +            if ($arg) {
18486 +                list($other, $extra) = explode(' ', $arg, 2);
18487 +                if ($extra) {
18488 +                    return NULL;
18489 +                } else {
18490 +                    return new OffCommand($user, $other);
18491 +                }
18492 +            } else {
18493 +                return new OffCommand($user);
18494 +            }
18495 +         case 'stop':
18496 +         case 'quit':
18497 +            if ($arg) {
18498 +                return NULL;
18499 +            } else {
18500 +                return new OffCommand($user);
18501 +            }
18502 +         case 'follow':
18503 +         case 'sub':
18504 +            if (!$arg) {
18505 +                return NULL;
18506 +            }
18507 +            list($other, $extra) = explode(' ', $arg, 2);
18508 +            if ($extra) {
18509 +                return NULL;
18510 +            } else {
18511 +                return new SubCommand($user, $other);
18512 +            }
18513 +         case 'leave':
18514 +         case 'unsub':
18515 +            if (!$arg) {
18516 +                return NULL;
18517 +            }
18518 +            list($other, $extra) = explode(' ', $arg, 2);
18519 +            if ($extra) {
18520 +                return NULL;
18521 +            } else {
18522 +                return new UnsubCommand($user, $other);
18523 +            }
18524 +         case 'get':
18525 +         case 'last':
18526 +            if (!$arg) {
18527 +                return NULL;
18528 +            }
18529 +            list($other, $extra) = explode(' ', $arg, 2);
18530 +            if ($extra) {
18531 +                return NULL;
18532 +            } else {
18533 +                return new GetCommand($user, $other);
18534 +            }
18535 +         case 'd':
18536 +            if (!$arg) {
18537 +                return NULL;
18538 +            }
18539 +            list($other, $extra) = explode(' ', $arg, 2);
18540 +            if (!$extra) {
18541 +                return NULL;
18542 +            } else {
18543 +                return new MessageCommand($user, $other, $extra);
18544 +            }
18545 +         case 'whois':
18546 +            if (!$arg) {
18547 +                return NULL;
18548 +            }
18549 +            list($other, $extra) = explode(' ', $arg, 2);
18550 +            if ($extra) {
18551 +                return NULL;
18552 +            } else {
18553 +                return new WhoisCommand($user, $other);
18554 +            }
18555 +         case 'fav':
18556 +            if (!$arg) {
18557 +                return NULL;
18558 +            }
18559 +            list($other, $extra) = explode(' ', $arg, 2);
18560 +            if ($extra) {
18561 +                return NULL;
18562 +            } else {
18563 +                return new FavCommand($user, $other);
18564 +            }
18565 +         case 'nudge':
18566 +            if (!$arg) {
18567 +                return NULL;
18568 +            }
18569 +            list($other, $extra) = explode(' ', $arg, 2);
18570 +            if ($extra) {
18571 +                return NULL;
18572 +            } else {
18573 +                return new NudgeCommand($user, $other);
18574 +            }
18575 +         case 'stats':
18576 +            if ($arg) {
18577 +                return NULL;
18578 +            }
18579 +            return new StatsCommand($user);
18580 +         case 'invite':
18581 +            if (!$arg) {
18582 +                return NULL;
18583 +            }
18584 +            list($other, $extra) = explode(' ', $arg, 2);
18585 +            if ($extra) {
18586 +                return NULL;
18587 +            } else {
18588 +                return new InviteCommand($user, $other);
18589 +            }
18590 +         case 'track':
18591 +            if (!$arg) {
18592 +                return NULL;
18593 +            }
18594 +            list($word, $extra) = explode(' ', $arg, 2);
18595 +            if ($extra) {
18596 +                return NULL;
18597 +            } else if ($word == 'off') {
18598 +                return new TrackOffCommand($user);
18599 +            } else {
18600 +                return new TrackCommand($user, $word);
18601 +            }
18602 +         case 'untrack':
18603 +            if (!$arg) {
18604 +                return NULL;
18605 +            }
18606 +            list($word, $extra) = explode(' ', $arg, 2);
18607 +            if ($extra) {
18608 +                return NULL;
18609 +            } else if ($word == 'all') {
18610 +                return new TrackOffCommand($user);
18611 +            } else {
18612 +                return new UntrackCommand($user, $word);
18613 +            }
18614 +         case 'tracks':
18615 +         case 'tracking':
18616 +            if ($arg) {
18617 +                return NULL;
18618 +            }
18619 +            return new TrackingCommand($user);
18620 +         default:
18621 +            return false;
18622 +        }
18623 +    }
18624 hunk ./classes/Fave.php 23
18625 -       static function addNew($user, $notice) {
18626 -               $fave = new Fave();
18627 -               $fave->user_id = $user->id;
18628 -               $fave->notice_id = $notice->id;
18629 -               if (!$fave->insert()) {
18630 -                       common_log_db_error($fave, 'INSERT', __FILE__);
18631 -                       return false;
18632 -               }
18633 -               return $fave;
18634 -       }
18635 -       
18636 -       function &pkeyGet($kv) {
18637 -               return Memcached_DataObject::pkeyGet('Fave', $kv);
18638 -       }
18639 +    static function addNew($user, $notice) {
18640 +        $fave = new Fave();
18641 +        $fave->user_id = $user->id;
18642 +        $fave->notice_id = $notice->id;
18643 +        if (!$fave->insert()) {
18644 +            common_log_db_error($fave, 'INSERT', __FILE__);
18645 +            return false;
18646 +        }
18647 +        return $fave;
18648 +    }
18649 +    
18650 +    function &pkeyGet($kv) {
18651 +        return Memcached_DataObject::pkeyGet('Fave', $kv);
18652 +    }
18653 hunk ./classes/Foreign_link.php 29
18654 -       // XXX:  This only returns a 1->1 single obj mapping.  Change?  Or make
18655 -       // a getForeignUsers() that returns more than one? --Zach
18656 -       static function getByUserID($user_id, $service) {
18657 -               $flink = new Foreign_link();
18658 -               $flink->service = $service;
18659 -               $flink->user_id = $user_id;
18660 -               $flink->limit(1);
18661 +    // XXX:  This only returns a 1->1 single obj mapping.  Change?  Or make
18662 +    // a getForeignUsers() that returns more than one? --Zach
18663 +    static function getByUserID($user_id, $service) {
18664 +        $flink = new Foreign_link();
18665 +        $flink->service = $service;
18666 +        $flink->user_id = $user_id;
18667 +        $flink->limit(1);
18668 hunk ./classes/Foreign_link.php 37
18669 -               if ($flink->find(TRUE)) {
18670 -                       return $flink;
18671 -               }
18672 +        if ($flink->find(TRUE)) {
18673 +            return $flink;
18674 +        }
18675 hunk ./classes/Foreign_link.php 41
18676 -               return NULL;            
18677 -       }
18678 -       
18679 -       static function getByForeignID($foreign_id, $service) {
18680 -               $flink = new Foreign_link();
18681 -               $flink->service = $service;
18682 -               $flink->foreign_id = $foreign_id;
18683 -               $flink->limit(1);
18684 +        return NULL;        
18685 +    }
18686 +    
18687 +    static function getByForeignID($foreign_id, $service) {
18688 +        $flink = new Foreign_link();
18689 +        $flink->service = $service;
18690 +        $flink->foreign_id = $foreign_id;
18691 +        $flink->limit(1);
18692 hunk ./classes/Foreign_link.php 50
18693 -               if ($flink->find(TRUE)) {
18694 -                       return $flink;
18695 -               }
18696 +        if ($flink->find(TRUE)) {
18697 +            return $flink;
18698 +        }
18699 hunk ./classes/Foreign_link.php 54
18700 -               return NULL;            
18701 -       }
18702 -               
18703 -       # Convenience methods
18704 -       function getForeignUser() {             
18705 -               $fuser = new Foreign_user();
18706 -               $fuser->service = $this->service;
18707 -               $fuser->id = $this->foreign_id;
18708 -               
18709 -               $fuser->limit(1);
18710 -               
18711 -               if ($fuser->find(TRUE)) {
18712 -                       return $fuser;
18713 -               }
18714 -               
18715 -               return NULL;            
18716 -       }
18717 -       
18718 -       function getUser() {
18719 -               return User::staticGet($this->user_id);
18720 -       }
18721 -               
18722 +        return NULL;        
18723 +    }
18724 +        
18725 +    # Convenience methods
18726 +    function getForeignUser() {        
18727 +        $fuser = new Foreign_user();
18728 +        $fuser->service = $this->service;
18729 +        $fuser->id = $this->foreign_id;
18730 +        
18731 +        $fuser->limit(1);
18732 +        
18733 +        if ($fuser->find(TRUE)) {
18734 +            return $fuser;
18735 +        }
18736 +        
18737 +        return NULL;        
18738 +    }
18739 +    
18740 +    function getUser() {
18741 +        return User::staticGet($this->user_id);
18742 +    }
18743 +        
18744 hunk ./classes/Foreign_user.php 25
18745 -       
18746 -       // XXX:  This only returns a 1->1 single obj mapping.  Change?  Or make
18747 -       // a getForeignUsers() that returns more than one? --Zach
18748 -       static function getForeignUser($id, $service) {         
18749 -               $fuser = new Foreign_user();
18750 -               $fuser->whereAdd("service = $service");
18751 -               $fuser->whereAdd("id = $id");
18752 -               $fuser->limit(1);
18753 -               
18754 -               if ($fuser->find()) {
18755 -                       $fuser->fetch();
18756 -                       return $fuser;
18757 -               }
18758 -               
18759 -               return NULL;            
18760 -       }
18761 -       
18762 -       function updateKeys(&$orig) {
18763 -               $parts = array();
18764 -               foreach (array('id', 'service', 'uri', 'nickname') as $k) {
18765 -                       if (strcmp($this->$k, $orig->$k) != 0) {
18766 -                               $parts[] = $k . ' = ' . $this->_quote($this->$k);
18767 -                       }
18768 -               }
18769 -               if (count($parts) == 0) {
18770 -                       # No changes
18771 -                       return true;
18772 -               }
18773 -               $toupdate = implode(', ', $parts);
18774 +    
18775 +    // XXX:  This only returns a 1->1 single obj mapping.  Change?  Or make
18776 +    // a getForeignUsers() that returns more than one? --Zach
18777 +    static function getForeignUser($id, $service) {        
18778 +        $fuser = new Foreign_user();
18779 +        $fuser->whereAdd("service = $service");
18780 +        $fuser->whereAdd("id = $id");
18781 +        $fuser->limit(1);
18782 +        
18783 +        if ($fuser->find()) {
18784 +            $fuser->fetch();
18785 +            return $fuser;
18786 +        }
18787 +        
18788 +        return NULL;        
18789 +    }
18790 +    
18791 +    function updateKeys(&$orig) {
18792 +        $parts = array();
18793 +        foreach (array('id', 'service', 'uri', 'nickname') as $k) {
18794 +            if (strcmp($this->$k, $orig->$k) != 0) {
18795 +                $parts[] = $k . ' = ' . $this->_quote($this->$k);
18796 +            }
18797 +        }
18798 +        if (count($parts) == 0) {
18799 +            # No changes
18800 +            return true;
18801 +        }
18802 +        $toupdate = implode(', ', $parts);
18803 hunk ./classes/Foreign_user.php 55
18804 -               $table = $this->tableName();
18805 -               if(common_config('db','quote_identifiers')) {
18806 -                       $table = '"' . $table . '"';
18807 -               }
18808 -               $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
18809 -                 ' WHERE id = ' . $this->id;
18810 -               $orig->decache();
18811 -               $result = $this->query($qry);
18812 -               if ($result) {
18813 -                       $this->encache();
18814 -               }
18815 -               return $result;
18816 -       }
18817 +        $table = $this->tableName();
18818 +        if(common_config('db','quote_identifiers')) {
18819 +            $table = '"' . $table . '"';
18820 +        }
18821 +        $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
18822 +          ' WHERE id = ' . $this->id;
18823 +        $orig->decache();
18824 +        $result = $this->query($qry);
18825 +        if ($result) {
18826 +            $this->encache();
18827 +        }
18828 +        return $result;
18829 +    }
18830 hunk ./classes/Foreign_user.php 69
18831 -       
18832 +    
18833 hunk ./classes/Memcached_DataObject.php 27
18834 -               if (is_null($v)) {
18835 -                       $v = $k;
18836 -                       # XXX: HACK!
18837 -                       $i = new $cls;
18838 -                       $keys = $i->keys();
18839 -                       $k = $keys[0];
18840 -                       unset($i);
18841 -               }
18842 -               $i = Memcached_DataObject::getcached($cls, $k, $v);
18843 -               if ($i) {
18844 -                       return $i;
18845 -               } else {
18846 -                       $i = DB_DataObject::staticGet($cls, $k, $v);
18847 -                       if ($i) {
18848 -                               $i->encache();
18849 -                       }
18850 -                       return $i;
18851 -               }
18852 -       }
18853 +        if (is_null($v)) {
18854 +            $v = $k;
18855 +            # XXX: HACK!
18856 +            $i = new $cls;
18857 +            $keys = $i->keys();
18858 +            $k = $keys[0];
18859 +            unset($i);
18860 +        }
18861 +        $i = Memcached_DataObject::getcached($cls, $k, $v);
18862 +        if ($i) {
18863 +            return $i;
18864 +        } else {
18865 +            $i = DB_DataObject::staticGet($cls, $k, $v);
18866 +            if ($i) {
18867 +                $i->encache();
18868 +            }
18869 +            return $i;
18870 +        }
18871 +    }
18872 hunk ./classes/Memcached_DataObject.php 47
18873 -       function &pkeyGet($cls, $kv) {
18874 -               $i = Memcached_DataObject::multicache($cls, $kv);
18875 -               if ($i) {
18876 -                       return $i;
18877 -               } else {
18878 -                       $i = new $cls();
18879 -                       foreach ($kv as $k => $v) {
18880 -                               $i->$k = $v;
18881 -                       }
18882 -                       if ($i->find(true)) {
18883 -                               $i->encache();
18884 -                       } else {
18885 -                               $i = NULL;
18886 -                       }
18887 +    function &pkeyGet($cls, $kv) {
18888 +        $i = Memcached_DataObject::multicache($cls, $kv);
18889 +        if ($i) {
18890 +            return $i;
18891 +        } else {
18892 +            $i = new $cls();
18893 +            foreach ($kv as $k => $v) {
18894 +                $i->$k = $v;
18895 +            }
18896 +            if ($i->find(true)) {
18897 +                $i->encache();
18898 +            } else {
18899 +                $i = NULL;
18900 +            }
18901 hunk ./classes/Memcached_DataObject.php 62
18902 -               }
18903 -       }
18904 +        }
18905 +    }
18906 hunk ./classes/Memcached_DataObject.php 65
18907 -       function insert() {
18908 -               $result = parent::insert();
18909 -               return $result;
18910 -       }
18911 -       
18912 -       function update($orig=NULL) {
18913 -               if (is_object($orig) && $orig instanceof Memcached_DataObject) {
18914 -                       $orig->decache(); # might be different keys
18915 -               }
18916 -               $result = parent::update($orig);
18917 -               if ($result) {
18918 -                       $this->encache();
18919 -               }
18920 -               return $result;
18921 -       }
18922 -       
18923 -       function delete() {
18924 -               $this->decache(); # while we still have the values!
18925 -               return parent::delete();
18926 -       }
18927 -       
18928 -       static function memcache() {
18929 -               return common_memcache();
18930 -       }
18931 -       
18932 -       static function cacheKey($cls, $k, $v) {
18933 -               return common_cache_key(strtolower($cls).':'.$k.':'.$v);
18934 -       }
18935 -       
18936 -       static function getcached($cls, $k, $v) {
18937 -               $c = Memcached_DataObject::memcache();
18938 -               if (!$c) {
18939 -                       return false;
18940 -               } else {
18941 -                       return $c->get(Memcached_DataObject::cacheKey($cls, $k, $v));
18942 -               }
18943 -       }
18944 +    function insert() {
18945 +        $result = parent::insert();
18946 +        return $result;
18947 +    }
18948 +    
18949 +    function update($orig=NULL) {
18950 +        if (is_object($orig) && $orig instanceof Memcached_DataObject) {
18951 +            $orig->decache(); # might be different keys
18952 +        }
18953 +        $result = parent::update($orig);
18954 +        if ($result) {
18955 +            $this->encache();
18956 +        }
18957 +        return $result;
18958 +    }
18959 +    
18960 +    function delete() {
18961 +        $this->decache(); # while we still have the values!
18962 +        return parent::delete();
18963 +    }
18964 +    
18965 +    static function memcache() {
18966 +        return common_memcache();
18967 +    }
18968 +    
18969 +    static function cacheKey($cls, $k, $v) {
18970 +        return common_cache_key(strtolower($cls).':'.$k.':'.$v);
18971 +    }
18972 +    
18973 +    static function getcached($cls, $k, $v) {
18974 +        $c = Memcached_DataObject::memcache();
18975 +        if (!$c) {
18976 +            return false;
18977 +        } else {
18978 +            return $c->get(Memcached_DataObject::cacheKey($cls, $k, $v));
18979 +        }
18980 +    }
18981 hunk ./classes/Memcached_DataObject.php 103
18982 -       function keyTypes() {
18983 -               global $_DB_DATAOBJECT;
18984 +    function keyTypes() {
18985 +        global $_DB_DATAOBJECT;
18986 hunk ./classes/Memcached_DataObject.php 106
18987 -                       $this->databaseStructure();
18988 +            $this->databaseStructure();
18989 hunk ./classes/Memcached_DataObject.php 109
18990 -               return $_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"];
18991 -       }
18992 -       
18993 -       function encache() {
18994 -               $c = $this->memcache();
18995 -               if (!$c) {
18996 -                       return false;
18997 -               } else {
18998 -                       $pkey = array();
18999 -                       $pval = array();                        
19000 -                       $types = $this->keyTypes();
19001 -                       ksort($types);
19002 -                       foreach ($types as $key => $type) {
19003 -                               if ($type == 'K') {
19004 -                                       $pkey[] = $key;
19005 -                                       $pval[] = $this->$key;
19006 -                               } else {
19007 -                                       $c->set($this->cacheKey($this->tableName(), $key, $this->$key), $this);
19008 -                               }
19009 -                       }
19010 -                       # XXX: should work for both compound and scalar pkeys
19011 -                       $pvals = implode(',', $pval);
19012 -                       $pkeys = implode(',', $pkey);
19013 -                       $c->set($this->cacheKey($this->tableName(), $pkeys, $pvals), $this);
19014 -               }
19015 -       }
19016 -       
19017 -       function decache() {
19018 -               $c = $this->memcache();
19019 -               if (!$c) {
19020 -                       return false;
19021 -               } else {
19022 -                       $pkey = array();
19023 -                       $pval = array();                        
19024 -                       $types = $this->keyTypes();
19025 -                       ksort($types);
19026 -                       foreach ($types as $key => $type) {
19027 -                               if ($type == 'K') {
19028 -                                       $pkey[] = $key;
19029 -                                       $pval[] = $this->$key;
19030 -                               } else {
19031 -                                       $c->delete($this->cacheKey($this->tableName(), $key, $this->$key));
19032 -                               }
19033 -                       }
19034 -                       # should work for both compound and scalar pkeys
19035 -                       # XXX: comma works for now but may not be safe separator for future keys
19036 -                       $pvals = implode(',', $pval);
19037 -                       $pkeys = implode(',', $pkey);
19038 -                       $c->delete($this->cacheKey($this->tableName(), $pkeys, $pvals));
19039 -               }
19040 -       }
19041 +        return $_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"];
19042 +    }
19043 +    
19044 +    function encache() {
19045 +        $c = $this->memcache();
19046 +        if (!$c) {
19047 +            return false;
19048 +        } else {
19049 +            $pkey = array();
19050 +            $pval = array();            
19051 +            $types = $this->keyTypes();
19052 +            ksort($types);
19053 +            foreach ($types as $key => $type) {
19054 +                if ($type == 'K') {
19055 +                    $pkey[] = $key;
19056 +                    $pval[] = $this->$key;
19057 +                } else {
19058 +                    $c->set($this->cacheKey($this->tableName(), $key, $this->$key), $this);
19059 +                }
19060 +            }
19061 +            # XXX: should work for both compound and scalar pkeys
19062 +            $pvals = implode(',', $pval);
19063 +            $pkeys = implode(',', $pkey);
19064 +            $c->set($this->cacheKey($this->tableName(), $pkeys, $pvals), $this);
19065 +        }
19066 +    }
19067 +    
19068 +    function decache() {
19069 +        $c = $this->memcache();
19070 +        if (!$c) {
19071 +            return false;
19072 +        } else {
19073 +            $pkey = array();
19074 +            $pval = array();            
19075 +            $types = $this->keyTypes();
19076 +            ksort($types);
19077 +            foreach ($types as $key => $type) {
19078 +                if ($type == 'K') {
19079 +                    $pkey[] = $key;
19080 +                    $pval[] = $this->$key;
19081 +                } else {
19082 +                    $c->delete($this->cacheKey($this->tableName(), $key, $this->$key));
19083 +                }
19084 +            }
19085 +            # should work for both compound and scalar pkeys
19086 +            # XXX: comma works for now but may not be safe separator for future keys
19087 +            $pvals = implode(',', $pval);
19088 +            $pkeys = implode(',', $pkey);
19089 +            $c->delete($this->cacheKey($this->tableName(), $pkeys, $pvals));
19090 +        }
19091 +    }
19092 hunk ./classes/Memcached_DataObject.php 161
19093 -       function multicache($cls, $kv) {
19094 -               ksort($kv);
19095 -               $c = Memcached_DataObject::memcache();
19096 -               if (!$c) {
19097 -                       return false;
19098 -               } else {
19099 -                       $pkeys = implode(',', array_keys($kv));
19100 -                       $pvals = implode(',', array_values($kv));
19101 -                       return $c->get(Memcached_DataObject::cacheKey($cls, $pkeys, $pvals));
19102 -               }
19103 -       }
19104 +    function multicache($cls, $kv) {
19105 +        ksort($kv);
19106 +        $c = Memcached_DataObject::memcache();
19107 +        if (!$c) {
19108 +            return false;
19109 +        } else {
19110 +            $pkeys = implode(',', array_keys($kv));
19111 +            $pvals = implode(',', array_values($kv));
19112 +            return $c->get(Memcached_DataObject::cacheKey($cls, $pkeys, $pvals));
19113 +        }
19114 +    }
19115 hunk ./classes/Message.php 29
19116 -       
19117 -       function getFrom() {
19118 -               return Profile::staticGet('id', $this->from_profile);
19119 -       }
19120 -       
19121 -       function getTo() {
19122 -               return Profile::staticGet('id', $this->to_profile);
19123 -       }
19124 -       
19125 -       static function saveNew($from, $to, $content, $source) {
19126 -               
19127 -               $msg = new Message();
19128 -               
19129 -               $msg->from_profile = $from;
19130 -               $msg->to_profile = $to;
19131 -               $msg->content = common_shorten_links($content);
19132 -               $msg->rendered = common_render_text($content);
19133 -               $msg->created = common_sql_now();
19134 -               $msg->source = $source;
19135 -               
19136 -               $result = $msg->insert();
19137 -               
19138 -               if (!$result) {
19139 -                       common_log_db_error($msg, 'INSERT', __FILE__);
19140 -                       return _('Could not insert message.');
19141 -               }
19142 -               
19143 -               $orig = clone($msg);
19144 -               $msg->uri = common_local_url('showmessage', array('message' => $msg->id));
19145 -               
19146 -               $result = $msg->update($orig);
19147 -               
19148 -               if (!$result) {
19149 -                       common_log_db_error($msg, 'UPDATE', __FILE__);
19150 -                       return _('Could not update message with new URI.');
19151 -               }
19152 -               
19153 -               return $msg;
19154 -       }
19155 +    
19156 +    function getFrom() {
19157 +        return Profile::staticGet('id', $this->from_profile);
19158 +    }
19159 +    
19160 +    function getTo() {
19161 +        return Profile::staticGet('id', $this->to_profile);
19162 +    }
19163 +    
19164 +    static function saveNew($from, $to, $content, $source) {
19165 +        
19166 +        $msg = new Message();
19167 +        
19168 +        $msg->from_profile = $from;
19169 +        $msg->to_profile = $to;
19170 +        $msg->content = common_shorten_links($content);
19171 +        $msg->rendered = common_render_text($content);
19172 +        $msg->created = common_sql_now();
19173 +        $msg->source = $source;
19174 +        
19175 +        $result = $msg->insert();
19176 +        
19177 +        if (!$result) {
19178 +            common_log_db_error($msg, 'INSERT', __FILE__);
19179 +            return _('Could not insert message.');
19180 +        }
19181 +        
19182 +        $orig = clone($msg);
19183 +        $msg->uri = common_local_url('showmessage', array('message' => $msg->id));
19184 +        
19185 +        $result = $msg->update($orig);
19186 +        
19187 +        if (!$result) {
19188 +            common_log_db_error($msg, 'UPDATE', __FILE__);
19189 +            return _('Could not update message with new URI.');
19190 +        }
19191 +        
19192 +        return $msg;
19193 +    }
19194 hunk ./classes/Notice.php 13
19195 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
19196 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
19197 hunk ./classes/Notice.php 17
19198 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
19199 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
19200 hunk ./classes/Notice.php 34
19201 -       ###START_AUTOCODE
19202 -       /* the code below is auto generated do not remove the above tag */
19203 +    ###START_AUTOCODE
19204 +    /* the code below is auto generated do not remove the above tag */
19205 hunk ./classes/Notice.php 37
19206 -       public $__table = 'notice';                                                      // table name
19207 -       public $id;                                                              // int(4)      primary_key not_null
19208 -       public $profile_id;                                              // int(4)       not_null
19209 -       public $uri;                                                     // varchar(255)  unique_key
19210 -       public $content;                                                 // varchar(140)
19211 -       public $rendered;                                                // text()
19212 -       public $url;                                                     // varchar(255)
19213 -       public $created;                                                 // datetime()   not_null
19214 -       public $modified;                                                // timestamp()   not_null default_CURRENT_TIMESTAMP
19215 -       public $reply_to;                                                // int(4)
19216 -       public $is_local;                                                // tinyint(1)
19217 -       public $source;                                                  // varchar(32)
19218 +    public $__table = 'notice';                             // table name
19219 +    public $id;                                 // int(4)    primary_key not_null
19220 +    public $profile_id;                         // int(4)     not_null
19221 +    public $uri;                             // varchar(255)  unique_key
19222 +    public $content;                         // varchar(140)
19223 +    public $rendered;                         // text()
19224 +    public $url;                             // varchar(255)
19225 +    public $created;                         // datetime()     not_null
19226 +    public $modified;                         // timestamp()      not_null default_CURRENT_TIMESTAMP
19227 +    public $reply_to;                         // int(4)
19228 +    public $is_local;                         // tinyint(1)
19229 +    public $source;                             // varchar(32)
19230 hunk ./classes/Notice.php 50
19231 -       /* Static get */
19232 -       function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Notice',$k,$v); }
19233 +    /* Static get */
19234 +    function staticGet($k,$v=NULL) { return Memcached_DataObject::staticGet('Notice',$k,$v); }
19235 hunk ./classes/Notice.php 53
19236 -       /* the code above is auto generated do not remove the tag below */
19237 -       ###END_AUTOCODE
19238 +    /* the code above is auto generated do not remove the tag below */
19239 +    ###END_AUTOCODE
19240 hunk ./classes/Notice.php 56
19241 -       function getProfile() {
19242 -               return Profile::staticGet('id', $this->profile_id);
19243 -       }
19244 +    function getProfile() {
19245 +        return Profile::staticGet('id', $this->profile_id);
19246 +    }
19247 hunk ./classes/Notice.php 60
19248 -       function delete() {
19249 -               $this->blowCaches(true);
19250 -               $this->blowFavesCache(true);
19251 -               $this->blowInboxes();
19252 -               return parent::delete();
19253 -       }
19254 +    function delete() {
19255 +        $this->blowCaches(true);
19256 +        $this->blowFavesCache(true);
19257 +        $this->blowInboxes();
19258 +        return parent::delete();
19259 +    }
19260 hunk ./classes/Notice.php 67
19261 -       function saveTags() {
19262 -               /* extract all #hastags */
19263 -               $count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($this->content), $match);
19264 -               if (!$count) {
19265 -                       return true;
19266 -               }
19267 +    function saveTags() {
19268 +        /* extract all #hastags */
19269 +        $count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($this->content), $match);
19270 +        if (!$count) {
19271 +            return true;
19272 +        }
19273 hunk ./classes/Notice.php 74
19274 -               /* elide characters we don't want in the tag */
19275 -               $match[1] = str_replace(array('-', '_', '.'), '', $match[1]);
19276 +        /* elide characters we don't want in the tag */
19277 +        $match[1] = str_replace(array('-', '_', '.'), '', $match[1]);
19278 hunk ./classes/Notice.php 77
19279 -               /* Add them to the database */
19280 -               foreach(array_unique($match[1]) as $hashtag) {
19281 -                       $tag = DB_DataObject::factory('Notice_tag');
19282 -                       $tag->notice_id = $this->id;
19283 -                       $tag->tag = $hashtag;
19284 -                       $tag->created = $this->created;
19285 -                       $id = $tag->insert();
19286 -                       if (!$id) {
19287 -                               $last_error = PEAR::getStaticProperty('DB_DataObject','lastError');
19288 -                               common_log(LOG_ERR, 'DB error inserting hashtag: ' . $last_error->message);
19289 -                               common_server_error(sprintf(_('DB error inserting hashtag: %s'), $last_error->message));
19290 -                               return;
19291 -                       }
19292 -               }
19293 -               return true;
19294 -       }
19295 +        /* Add them to the database */
19296 +        foreach(array_unique($match[1]) as $hashtag) {
19297 +            $tag = DB_DataObject::factory('Notice_tag');
19298 +            $tag->notice_id = $this->id;
19299 +            $tag->tag = $hashtag;
19300 +            $tag->created = $this->created;
19301 +            $id = $tag->insert();
19302 +            if (!$id) {
19303 +                $last_error = PEAR::getStaticProperty('DB_DataObject','lastError');
19304 +                common_log(LOG_ERR, 'DB error inserting hashtag: ' . $last_error->message);
19305 +                common_server_error(sprintf(_('DB error inserting hashtag: %s'), $last_error->message));
19306 +                return;
19307 +            }
19308 +        }
19309 +        return true;
19310 +    }
19311 hunk ./classes/Notice.php 94
19312 -       static function saveNew($profile_id, $content, $source=NULL, $is_local=1, $reply_to=NULL, $uri=NULL) {
19313 +    static function saveNew($profile_id, $content, $source=NULL, $is_local=1, $reply_to=NULL, $uri=NULL) {
19314 hunk ./classes/Notice.php 96
19315 -               $profile = Profile::staticGet($profile_id);
19316 +        $profile = Profile::staticGet($profile_id);
19317 hunk ./classes/Notice.php 105
19318 -                       return _('Too many notices too fast; take a breather and post again in a few minutes.');
19319 +            return _('Too many notices too fast; take a breather and post again in a few minutes.');
19320 hunk ./classes/Notice.php 108
19321 -               $banned = common_config('profile', 'banned');
19322 +        $banned = common_config('profile', 'banned');
19323 hunk ./classes/Notice.php 110
19324 -               if ( in_array($profile_id, $banned) || in_array($profile->nickname, $banned)) {
19325 -                       common_log(LOG_WARNING, "Attempted post from banned user: $profile->nickname (user id = $profile_id).");
19326 +        if ( in_array($profile_id, $banned) || in_array($profile->nickname, $banned)) {
19327 +            common_log(LOG_WARNING, "Attempted post from banned user: $profile->nickname (user id = $profile_id).");
19328 hunk ./classes/Notice.php 113
19329 -               }
19330 +        }
19331 hunk ./classes/Notice.php 115
19332 -               $notice = new Notice();
19333 -               $notice->profile_id = $profile_id;
19334 +        $notice = new Notice();
19335 +        $notice->profile_id = $profile_id;
19336 hunk ./classes/Notice.php 118
19337 -               $blacklist = common_config('public', 'blacklist');
19338 +        $blacklist = common_config('public', 'blacklist');
19339 hunk ./classes/Notice.php 120
19340 -               # Blacklisted are non-false, but not 1, either
19341 +        # Blacklisted are non-false, but not 1, either
19342 hunk ./classes/Notice.php 122
19343 -               if ($blacklist && in_array($profile_id, $blacklist)) {
19344 -                       $notice->is_local = -1;
19345 -               } else {
19346 -                       $notice->is_local = $is_local;
19347 -               }
19348 +        if ($blacklist && in_array($profile_id, $blacklist)) {
19349 +            $notice->is_local = -1;
19350 +        } else {
19351 +            $notice->is_local = $is_local;
19352 +        }
19353 hunk ./classes/Notice.php 128
19354 -               $notice->reply_to = $reply_to;
19355 -               $notice->created = common_sql_now();
19356 -               $notice->content = common_shorten_links($content);
19357 -               $notice->rendered = common_render_content($notice->content, $notice);
19358 -               $notice->source = $source;
19359 -               $notice->uri = $uri;
19360 +        $notice->reply_to = $reply_to;
19361 +        $notice->created = common_sql_now();
19362 +        $notice->content = common_shorten_links($content);
19363 +        $notice->rendered = common_render_content($notice->content, $notice);
19364 +        $notice->source = $source;
19365 +        $notice->uri = $uri;
19366 hunk ./classes/Notice.php 135
19367 -               $id = $notice->insert();
19368 +        $id = $notice->insert();
19369 hunk ./classes/Notice.php 137
19370 -               if (!$id) {
19371 -                       common_log_db_error($notice, 'INSERT', __FILE__);
19372 -                       return _('Problem saving notice.');
19373 -               }
19374 +        if (!$id) {
19375 +            common_log_db_error($notice, 'INSERT', __FILE__);
19376 +            return _('Problem saving notice.');
19377 +        }
19378 hunk ./classes/Notice.php 142
19379 -               # Update the URI after the notice is in the database
19380 -               if (!$uri) {
19381 -                       $orig = clone($notice);
19382 -                       $notice->uri = common_notice_uri($notice);
19383 +        # Update the URI after the notice is in the database
19384 +        if (!$uri) {
19385 +            $orig = clone($notice);
19386 +            $notice->uri = common_notice_uri($notice);
19387 hunk ./classes/Notice.php 147
19388 -                       if (!$notice->update($orig)) {
19389 -                               common_log_db_error($notice, 'UPDATE', __FILE__);
19390 -                               return _('Problem saving notice.');
19391 -                       }
19392 -               }
19393 +            if (!$notice->update($orig)) {
19394 +                common_log_db_error($notice, 'UPDATE', __FILE__);
19395 +                return _('Problem saving notice.');
19396 +            }
19397 +        }
19398 hunk ./classes/Notice.php 153
19399 -               # XXX: do we need to change this for remote users?
19400 +        # XXX: do we need to change this for remote users?
19401 hunk ./classes/Notice.php 155
19402 -               common_save_replies($notice);
19403 -               $notice->saveTags();
19404 +        common_save_replies($notice);
19405 +        $notice->saveTags();
19406 hunk ./classes/Notice.php 158
19407 -               # Clear the cache for subscribed users, so they'll update at next request
19408 -               # XXX: someone clever could prepend instead of clearing the cache
19409 +        # Clear the cache for subscribed users, so they'll update at next request
19410 +        # XXX: someone clever could prepend instead of clearing the cache
19411 hunk ./classes/Notice.php 161
19412 -               if (common_config('memcached', 'enabled')) {
19413 -                       $notice->blowCaches();
19414 -               }
19415 +        if (common_config('memcached', 'enabled')) {
19416 +            $notice->blowCaches();
19417 +        }
19418 hunk ./classes/Notice.php 165
19419 -               $notice->addToInboxes();
19420 -               return $notice;
19421 -       }
19422 +        $notice->addToInboxes();
19423 +        return $notice;
19424 +    }
19425 hunk ./classes/Notice.php 187
19426 -       function blowCaches($blowLast=false) {
19427 -               $this->blowSubsCache($blowLast);
19428 -               $this->blowNoticeCache($blowLast);
19429 -               $this->blowRepliesCache($blowLast);
19430 -               $this->blowPublicCache($blowLast);
19431 -               $this->blowTagCache($blowLast);
19432 -       }
19433 +    function blowCaches($blowLast=false) {
19434 +        $this->blowSubsCache($blowLast);
19435 +        $this->blowNoticeCache($blowLast);
19436 +        $this->blowRepliesCache($blowLast);
19437 +        $this->blowPublicCache($blowLast);
19438 +        $this->blowTagCache($blowLast);
19439 +    }
19440 hunk ./classes/Notice.php 195
19441 -       function blowTagCache($blowLast=false) {
19442 -               $cache = common_memcache();
19443 -               if ($cache) {
19444 -                       $tag = new Notice_tag();
19445 -                       $tag->notice_id = $this->id;
19446 -                       if ($tag->find()) {
19447 -                               while ($tag->fetch()) {
19448 -                                       $cache->delete(common_cache_key('notice_tag:notice_stream:' . $tag->tag));
19449 -                                       if ($blowLast) {
19450 -                                               $cache->delete(common_cache_key('notice_tag:notice_stream:' . $tag->tag . ';last'));
19451 -                                       }
19452 -                               }
19453 -                       }
19454 -                       $tag->free();
19455 -                       unset($tag);
19456 -               }
19457 -       }
19458 +    function blowTagCache($blowLast=false) {
19459 +        $cache = common_memcache();
19460 +        if ($cache) {
19461 +            $tag = new Notice_tag();
19462 +            $tag->notice_id = $this->id;
19463 +            if ($tag->find()) {
19464 +                while ($tag->fetch()) {
19465 +                    $cache->delete(common_cache_key('notice_tag:notice_stream:' . $tag->tag));
19466 +                    if ($blowLast) {
19467 +                        $cache->delete(common_cache_key('notice_tag:notice_stream:' . $tag->tag . ';last'));
19468 +                    }
19469 +                }
19470 +            }
19471 +            $tag->free();
19472 +            unset($tag);
19473 +        }
19474 +    }
19475 hunk ./classes/Notice.php 213
19476 -       function blowSubsCache($blowLast=false) {
19477 -               $cache = common_memcache();
19478 -               if ($cache) {
19479 -                       $user = new User();
19480 +    function blowSubsCache($blowLast=false) {
19481 +        $cache = common_memcache();
19482 +        if ($cache) {
19483 +            $user = new User();
19484 hunk ./classes/Notice.php 218
19485 -                       $user->query('SELECT id ' .
19486 -                                                'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
19487 -                                                'WHERE subscription.subscribed = ' . $this->profile_id);
19488 +            $user->query('SELECT id ' .
19489 +                         'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
19490 +                         'WHERE subscription.subscribed = ' . $this->profile_id);
19491 hunk ./classes/Notice.php 222
19492 -                       while ($user->fetch()) {
19493 -                               $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
19494 -                               if ($blowLast) {
19495 -                                       $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id . ';last'));
19496 -                               }
19497 -                       }
19498 -                       $user->free();
19499 -                       unset($user);
19500 -               }
19501 -       }
19502 +            while ($user->fetch()) {
19503 +                $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
19504 +                if ($blowLast) {
19505 +                    $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id . ';last'));
19506 +                }
19507 +            }
19508 +            $user->free();
19509 +            unset($user);
19510 +        }
19511 +    }
19512 hunk ./classes/Notice.php 233
19513 -       function blowNoticeCache($blowLast=false) {
19514 -               if ($this->is_local) {
19515 -                       $cache = common_memcache();
19516 -                       if ($cache) {
19517 -                               $cache->delete(common_cache_key('profile:notices:'.$this->profile_id));
19518 -                               if ($blowLast) {
19519 -                                       $cache->delete(common_cache_key('profile:notices:'.$this->profile_id.';last'));
19520 -                               }
19521 -                       }
19522 -               }
19523 -       }
19524 +    function blowNoticeCache($blowLast=false) {
19525 +        if ($this->is_local) {
19526 +            $cache = common_memcache();
19527 +            if ($cache) {
19528 +                $cache->delete(common_cache_key('profile:notices:'.$this->profile_id));
19529 +                if ($blowLast) {
19530 +                    $cache->delete(common_cache_key('profile:notices:'.$this->profile_id.';last'));
19531 +                }
19532 +            }
19533 +        }
19534 +    }
19535 hunk ./classes/Notice.php 245
19536 -       function blowRepliesCache($blowLast=false) {
19537 -               $cache = common_memcache();
19538 -               if ($cache) {
19539 -                       $reply = new Reply();
19540 -                       $reply->notice_id = $this->id;
19541 -                       if ($reply->find()) {
19542 -                               while ($reply->fetch()) {
19543 -                                       $cache->delete(common_cache_key('user:replies:'.$reply->profile_id));
19544 -                                       if ($blowLast) {
19545 -                                               $cache->delete(common_cache_key('user:replies:'.$reply->profile_id.';last'));
19546 -                                       }
19547 -                               }
19548 -                       }
19549 -                       $reply->free();
19550 -                       unset($reply);
19551 -               }
19552 -       }
19553 +    function blowRepliesCache($blowLast=false) {
19554 +        $cache = common_memcache();
19555 +        if ($cache) {
19556 +            $reply = new Reply();
19557 +            $reply->notice_id = $this->id;
19558 +            if ($reply->find()) {
19559 +                while ($reply->fetch()) {
19560 +                    $cache->delete(common_cache_key('user:replies:'.$reply->profile_id));
19561 +                    if ($blowLast) {
19562 +                        $cache->delete(common_cache_key('user:replies:'.$reply->profile_id.';last'));
19563 +                    }
19564 +                }
19565 +            }
19566 +            $reply->free();
19567 +            unset($reply);
19568 +        }
19569 +    }
19570 hunk ./classes/Notice.php 263
19571 -       function blowPublicCache($blowLast=false) {
19572 -               if ($this->is_local == 1) {
19573 -                       $cache = common_memcache();
19574 -                       if ($cache) {
19575 -                               $cache->delete(common_cache_key('public'));
19576 -                               if ($blowLast) {
19577 -                                       $cache->delete(common_cache_key('public').';last');
19578 -                               }
19579 -                       }
19580 -               }
19581 -       }
19582 +    function blowPublicCache($blowLast=false) {
19583 +        if ($this->is_local == 1) {
19584 +            $cache = common_memcache();
19585 +            if ($cache) {
19586 +                $cache->delete(common_cache_key('public'));
19587 +                if ($blowLast) {
19588 +                    $cache->delete(common_cache_key('public').';last');
19589 +                }
19590 +            }
19591 +        }
19592 +    }
19593 hunk ./classes/Notice.php 275
19594 -       function blowFavesCache($blowLast=false) {
19595 -               $cache = common_memcache();
19596 -               if ($cache) {
19597 -                       $fave = new Fave();
19598 -                       $fave->notice_id = $this->id;
19599 -                       if ($fave->find()) {
19600 -                               while ($fave->fetch()) {
19601 -                                       $cache->delete(common_cache_key('user:faves:'.$fave->user_id));
19602 -                                       if ($blowLast) {
19603 -                                               $cache->delete(common_cache_key('user:faves:'.$fave->user_id.';last'));
19604 -                                       }
19605 -                               }
19606 -                       }
19607 -                       $fave->free();
19608 -                       unset($fave);
19609 -               }
19610 -       }
19611 +    function blowFavesCache($blowLast=false) {
19612 +        $cache = common_memcache();
19613 +        if ($cache) {
19614 +            $fave = new Fave();
19615 +            $fave->notice_id = $this->id;
19616 +            if ($fave->find()) {
19617 +                while ($fave->fetch()) {
19618 +                    $cache->delete(common_cache_key('user:faves:'.$fave->user_id));
19619 +                    if ($blowLast) {
19620 +                        $cache->delete(common_cache_key('user:faves:'.$fave->user_id.';last'));
19621 +                    }
19622 +                }
19623 +            }
19624 +            $fave->free();
19625 +            unset($fave);
19626 +        }
19627 +    }
19628 hunk ./classes/Notice.php 293
19629 -       # XXX: too many args; we need to move to named params or even a separate
19630 -       # class for notice streams
19631 +    # XXX: too many args; we need to move to named params or even a separate
19632 +    # class for notice streams
19633 hunk ./classes/Notice.php 296
19634 -       static function getStream($qry, $cachekey, $offset=0, $limit=20, $since_id=0, $before_id=0, $order=NULL, $since=NULL) {
19635 +    static function getStream($qry, $cachekey, $offset=0, $limit=20, $since_id=0, $before_id=0, $order=NULL, $since=NULL) {
19636 hunk ./classes/Notice.php 298
19637 -               if (common_config('memcached', 'enabled')) {
19638 +        if (common_config('memcached', 'enabled')) {
19639 hunk ./classes/Notice.php 300
19640 -                       # Skip the cache if this is a since, since_id or before_id qry
19641 -                       if ($since_id > 0 || $before_id > 0 || $since) {
19642 -                               return Notice::getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since);
19643 -                       } else {
19644 -                               return Notice::getCachedStream($qry, $cachekey, $offset, $limit, $order);
19645 -                       }
19646 -               }
19647 +            # Skip the cache if this is a since, since_id or before_id qry
19648 +            if ($since_id > 0 || $before_id > 0 || $since) {
19649 +                return Notice::getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since);
19650 +            } else {
19651 +                return Notice::getCachedStream($qry, $cachekey, $offset, $limit, $order);
19652 +            }
19653 +        }
19654 hunk ./classes/Notice.php 308
19655 -               return Notice::getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since);
19656 -       }
19657 +        return Notice::getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since);
19658 +    }
19659 hunk ./classes/Notice.php 311
19660 -       static function getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since) {
19661 +    static function getStreamDirect($qry, $offset, $limit, $since_id, $before_id, $order, $since) {
19662 hunk ./classes/Notice.php 313
19663 -               $needAnd = FALSE;
19664 -               $needWhere = TRUE;
19665 +        $needAnd = FALSE;
19666 +        $needWhere = TRUE;
19667 hunk ./classes/Notice.php 316
19668 -               if (preg_match('/\bWHERE\b/i', $qry)) {
19669 -                       $needWhere = FALSE;
19670 -                       $needAnd = TRUE;
19671 -               }
19672 +        if (preg_match('/\bWHERE\b/i', $qry)) {
19673 +            $needWhere = FALSE;
19674 +            $needAnd = TRUE;
19675 +        }
19676 hunk ./classes/Notice.php 321
19677 -               if ($since_id > 0) {
19678 +        if ($since_id > 0) {
19679 hunk ./classes/Notice.php 323
19680 -                       if ($needWhere) {
19681 -                               $qry .= ' WHERE ';
19682 -                               $needWhere = FALSE;
19683 -                       } else {
19684 -                               $qry .= ' AND ';
19685 -                       }
19686 +            if ($needWhere) {
19687 +                $qry .= ' WHERE ';
19688 +                $needWhere = FALSE;
19689 +            } else {
19690 +                $qry .= ' AND ';
19691 +            }
19692 hunk ./classes/Notice.php 330
19693 -                       $qry .= ' notice.id > ' . $since_id;
19694 -               }
19695 +            $qry .= ' notice.id > ' . $since_id;
19696 +        }
19697 hunk ./classes/Notice.php 333
19698 -               if ($before_id > 0) {
19699 +        if ($before_id > 0) {
19700 hunk ./classes/Notice.php 335
19701 -                       if ($needWhere) {
19702 -                               $qry .= ' WHERE ';
19703 -                               $needWhere = FALSE;
19704 -                       } else {
19705 -                               $qry .= ' AND ';
19706 -                       }
19707 +            if ($needWhere) {
19708 +                $qry .= ' WHERE ';
19709 +                $needWhere = FALSE;
19710 +            } else {
19711 +                $qry .= ' AND ';
19712 +            }
19713 hunk ./classes/Notice.php 342
19714 -                       $qry .= ' notice.id < ' . $before_id;
19715 -               }
19716 +            $qry .= ' notice.id < ' . $before_id;
19717 +        }
19718 hunk ./classes/Notice.php 345
19719 -               if ($since) {
19720 +        if ($since) {
19721 hunk ./classes/Notice.php 347
19722 -                       if ($needWhere) {
19723 -                               $qry .= ' WHERE ';
19724 -                               $needWhere = FALSE;
19725 -                       } else {
19726 -                               $qry .= ' AND ';
19727 -                       }
19728 +            if ($needWhere) {
19729 +                $qry .= ' WHERE ';
19730 +                $needWhere = FALSE;
19731 +            } else {
19732 +                $qry .= ' AND ';
19733 +            }
19734 hunk ./classes/Notice.php 354
19735 -                       $qry .= ' notice.created > \'' . date('Y-m-d H:i:s', $since) . '\'';
19736 -               }
19737 +            $qry .= ' notice.created > \'' . date('Y-m-d H:i:s', $since) . '\'';
19738 +        }
19739 hunk ./classes/Notice.php 357
19740 -               # Allow ORDER override
19741 +        # Allow ORDER override
19742 hunk ./classes/Notice.php 359
19743 -               if ($order) {
19744 -                       $qry .= $order;
19745 -               } else {
19746 -                       $qry .= ' ORDER BY notice.created DESC, notice.id DESC ';
19747 -               }
19748 +        if ($order) {
19749 +            $qry .= $order;
19750 +        } else {
19751 +            $qry .= ' ORDER BY notice.created DESC, notice.id DESC ';
19752 +        }
19753 hunk ./classes/Notice.php 365
19754 -               if (common_config('db','type') == 'pgsql') {
19755 -                       $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
19756 -               } else {
19757 -                       $qry .= ' LIMIT ' . $offset . ', ' . $limit;
19758 -               }
19759 +        if (common_config('db','type') == 'pgsql') {
19760 +            $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
19761 +        } else {
19762 +            $qry .= ' LIMIT ' . $offset . ', ' . $limit;
19763 +        }
19764 hunk ./classes/Notice.php 371
19765 -               $notice = new Notice();
19766 +        $notice = new Notice();
19767 hunk ./classes/Notice.php 373
19768 -               $notice->query($qry);
19769 +        $notice->query($qry);
19770 hunk ./classes/Notice.php 375
19771 -               return $notice;
19772 -       }
19773 +        return $notice;
19774 +    }
19775 hunk ./classes/Notice.php 378
19776 -       # XXX: this is pretty long and should probably be broken up into
19777 -       # some helper functions
19778 +    # XXX: this is pretty long and should probably be broken up into
19779 +    # some helper functions
19780 hunk ./classes/Notice.php 381
19781 -       static function getCachedStream($qry, $cachekey, $offset, $limit, $order) {
19782 +    static function getCachedStream($qry, $cachekey, $offset, $limit, $order) {
19783 hunk ./classes/Notice.php 383
19784 -               # If outside our cache window, just go to the DB
19785 +        # If outside our cache window, just go to the DB
19786 hunk ./classes/Notice.php 385
19787 -               if ($offset + $limit > NOTICE_CACHE_WINDOW) {
19788 -                       return Notice::getStreamDirect($qry, $offset, $limit, NULL, NULL, $order, NULL);
19789 -               }
19790 +        if ($offset + $limit > NOTICE_CACHE_WINDOW) {
19791 +            return Notice::getStreamDirect($qry, $offset, $limit, NULL, NULL, $order, NULL);
19792 +        }
19793 hunk ./classes/Notice.php 389
19794 -               # Get the cache; if we can't, just go to the DB
19795 +        # Get the cache; if we can't, just go to the DB
19796 hunk ./classes/Notice.php 391
19797 -               $cache = common_memcache();
19798 +        $cache = common_memcache();
19799 hunk ./classes/Notice.php 393
19800 -               if (!$cache) {
19801 -                       return Notice::getStreamDirect($qry, $offset, $limit, NULL, NULL, $order, NULL);
19802 -               }
19803 +        if (!$cache) {
19804 +            return Notice::getStreamDirect($qry, $offset, $limit, NULL, NULL, $order, NULL);
19805 +        }
19806 hunk ./classes/Notice.php 397
19807 -               # Get the notices out of the cache
19808 +        # Get the notices out of the cache
19809 hunk ./classes/Notice.php 399
19810 -               $notices = $cache->get(common_cache_key($cachekey));
19811 +        $notices = $cache->get(common_cache_key($cachekey));
19812 hunk ./classes/Notice.php 401
19813 -               # On a cache hit, return a DB-object-like wrapper
19814 +        # On a cache hit, return a DB-object-like wrapper
19815 hunk ./classes/Notice.php 403
19816 -               if ($notices !== FALSE) {
19817 -                       $wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
19818 -                       return $wrapper;
19819 -               }
19820 +        if ($notices !== FALSE) {
19821 +            $wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
19822 +            return $wrapper;
19823 +        }
19824 hunk ./classes/Notice.php 408
19825 -               # If the cache was invalidated because of new data being
19826 -               # added, we can try and just get the new stuff. We keep an additional
19827 -               # copy of the data at the key + ';last'
19828 +        # If the cache was invalidated because of new data being
19829 +        # added, we can try and just get the new stuff. We keep an additional
19830 +        # copy of the data at the key + ';last'
19831 hunk ./classes/Notice.php 412
19832 -               # No cache hit. Try to get the *last* cached version
19833 +        # No cache hit. Try to get the *last* cached version
19834 hunk ./classes/Notice.php 414
19835 -               $last_notices = $cache->get(common_cache_key($cachekey) . ';last');
19836 +        $last_notices = $cache->get(common_cache_key($cachekey) . ';last');
19837 hunk ./classes/Notice.php 416
19838 -               if ($last_notices) {
19839 +        if ($last_notices) {
19840 hunk ./classes/Notice.php 418
19841 -                       # Reverse-chron order, so last ID is last.
19842 +            # Reverse-chron order, so last ID is last.
19843 hunk ./classes/Notice.php 420
19844 -                       $last_id = $last_notices[0]->id;
19845 +            $last_id = $last_notices[0]->id;
19846 hunk ./classes/Notice.php 422
19847 -                       # XXX: this assumes monotonically increasing IDs; a fair
19848 -                       # bet with our DB.
19849 +            # XXX: this assumes monotonically increasing IDs; a fair
19850 +            # bet with our DB.
19851 hunk ./classes/Notice.php 425
19852 -                       $new_notice = Notice::getStreamDirect($qry, 0, NOTICE_CACHE_WINDOW,
19853 -                                                                                                 $last_id, NULL, $order, NULL);
19854 +            $new_notice = Notice::getStreamDirect($qry, 0, NOTICE_CACHE_WINDOW,
19855 +                                                  $last_id, NULL, $order, NULL);
19856 hunk ./classes/Notice.php 428
19857 -                       if ($new_notice) {
19858 -                               $new_notices = array();
19859 -                               while ($new_notice->fetch()) {
19860 -                                       $new_notices[] = clone($new_notice);
19861 -                               }
19862 -                               $new_notice->free();
19863 -                               $notices = array_slice(array_merge($new_notices, $last_notices),
19864 -                                                                          0, NOTICE_CACHE_WINDOW);
19865 +            if ($new_notice) {
19866 +                $new_notices = array();
19867 +                while ($new_notice->fetch()) {
19868 +                    $new_notices[] = clone($new_notice);
19869 +                }
19870 +                $new_notice->free();
19871 +                $notices = array_slice(array_merge($new_notices, $last_notices),
19872 +                                       0, NOTICE_CACHE_WINDOW);
19873 hunk ./classes/Notice.php 437
19874 -                               # Store the array in the cache for next time
19875 +                # Store the array in the cache for next time
19876 hunk ./classes/Notice.php 439
19877 -                               $result = $cache->set(common_cache_key($cachekey), $notices);
19878 -                               $result = $cache->set(common_cache_key($cachekey) . ';last', $notices);
19879 +                $result = $cache->set(common_cache_key($cachekey), $notices);
19880 +                $result = $cache->set(common_cache_key($cachekey) . ';last', $notices);
19881 hunk ./classes/Notice.php 442
19882 -                               # return a wrapper of the array for use now
19883 +                # return a wrapper of the array for use now
19884 hunk ./classes/Notice.php 444
19885 -                               return new NoticeWrapper(array_slice($notices, $offset, $limit));
19886 -                       }
19887 -               }
19888 +                return new NoticeWrapper(array_slice($notices, $offset, $limit));
19889 +            }
19890 +        }
19891 hunk ./classes/Notice.php 448
19892 -               # Otherwise, get the full cache window out of the DB
19893 +        # Otherwise, get the full cache window out of the DB
19894 hunk ./classes/Notice.php 450
19895 -               $notice = Notice::getStreamDirect($qry, 0, NOTICE_CACHE_WINDOW, NULL, NULL, $order, NULL);
19896 +        $notice = Notice::getStreamDirect($qry, 0, NOTICE_CACHE_WINDOW, NULL, NULL, $order, NULL);
19897 hunk ./classes/Notice.php 452
19898 -               # If there are no hits, just return the value
19899 +        # If there are no hits, just return the value
19900 hunk ./classes/Notice.php 454
19901 -               if (!$notice) {
19902 -                       return $notice;
19903 -               }
19904 +        if (!$notice) {
19905 +            return $notice;
19906 +        }
19907 hunk ./classes/Notice.php 458
19908 -               # Pack results into an array
19909 +        # Pack results into an array
19910 hunk ./classes/Notice.php 460
19911 -               $notices = array();
19912 +        $notices = array();
19913 hunk ./classes/Notice.php 462
19914 -               while ($notice->fetch()) {
19915 -                       $notices[] = clone($notice);
19916 -               }
19917 +        while ($notice->fetch()) {
19918 +            $notices[] = clone($notice);
19919 +        }
19920 hunk ./classes/Notice.php 466
19921 -               $notice->free();
19922 +        $notice->free();
19923 hunk ./classes/Notice.php 468
19924 -               # Store the array in the cache for next time
19925 +        # Store the array in the cache for next time
19926 hunk ./classes/Notice.php 470
19927 -               $result = $cache->set(common_cache_key($cachekey), $notices);
19928 -               $result = $cache->set(common_cache_key($cachekey) . ';last', $notices);
19929 +        $result = $cache->set(common_cache_key($cachekey), $notices);
19930 +        $result = $cache->set(common_cache_key($cachekey) . ';last', $notices);
19931 hunk ./classes/Notice.php 473
19932 -               # return a wrapper of the array for use now
19933 +        # return a wrapper of the array for use now
19934 hunk ./classes/Notice.php 475
19935 -               $wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
19936 +        $wrapper = new NoticeWrapper(array_slice($notices, $offset, $limit));
19937 hunk ./classes/Notice.php 477
19938 -               return $wrapper;
19939 -       }
19940 +        return $wrapper;
19941 +    }
19942 hunk ./classes/Notice.php 480
19943 -       function publicStream($offset=0, $limit=20, $since_id=0, $before_id=0, $since=NULL) {
19944 +    function publicStream($offset=0, $limit=20, $since_id=0, $before_id=0, $since=NULL) {
19945 hunk ./classes/Notice.php 482
19946 -               $parts = array();
19947 +        $parts = array();
19948 hunk ./classes/Notice.php 484
19949 -               $qry = 'SELECT * FROM notice ';
19950 +        $qry = 'SELECT * FROM notice ';
19951 hunk ./classes/Notice.php 486
19952 -               if (common_config('public', 'localonly')) {
19953 -                       $parts[] = 'is_local = 1';
19954 -               } else {
19955 -                       # -1 == blacklisted
19956 -                       $parts[] = 'is_local != -1';
19957 -               }
19958 +        if (common_config('public', 'localonly')) {
19959 +            $parts[] = 'is_local = 1';
19960 +        } else {
19961 +            # -1 == blacklisted
19962 +            $parts[] = 'is_local != -1';
19963 +        }
19964 hunk ./classes/Notice.php 493
19965 -               if ($parts) {
19966 -                       $qry .= ' WHERE ' . implode(' AND ', $parts);
19967 -               }
19968 +        if ($parts) {
19969 +            $qry .= ' WHERE ' . implode(' AND ', $parts);
19970 +        }
19971 hunk ./classes/Notice.php 497
19972 -               return Notice::getStream($qry,
19973 -                                                                'public',
19974 -                                                                $offset, $limit, $since_id, $before_id, NULL, $since);
19975 -       }
19976 +        return Notice::getStream($qry,
19977 +                                 'public',
19978 +                                 $offset, $limit, $since_id, $before_id, NULL, $since);
19979 +    }
19980 hunk ./classes/Notice.php 502
19981 -       function addToInboxes() {
19982 -               $enabled = common_config('inboxes', 'enabled');
19983 +    function addToInboxes() {
19984 +        $enabled = common_config('inboxes', 'enabled');
19985 hunk ./classes/Notice.php 505
19986 -               if ($enabled === true || $enabled === 'transitional') {
19987 -                       $inbox = new Notice_inbox();
19988 -                       $qry = 'INSERT INTO notice_inbox (user_id, notice_id, created) ' .
19989 -                         'SELECT user.id, ' . $this->id . ', "' . $this->created . '" ' .
19990 -                         'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
19991 -                         'WHERE subscription.subscribed = ' . $this->profile_id . ' ' .
19992 -                         'AND NOT EXISTS (SELECT user_id, notice_id ' .
19993 -                         'FROM notice_inbox ' .
19994 -                         'WHERE user_id = user.id ' .
19995 -                         'AND notice_id = ' . $this->id . ' )';
19996 -                       if ($enabled === 'transitional') {
19997 -                               $qry .= ' AND user.inboxed = 1';
19998 -                       }
19999 -                       $inbox->query($qry);
20000 -               }
20001 -               return;
20002 -       }
20003 +        if ($enabled === true || $enabled === 'transitional') {
20004 +            $inbox = new Notice_inbox();
20005 +            $qry = 'INSERT INTO notice_inbox (user_id, notice_id, created) ' .
20006 +              'SELECT user.id, ' . $this->id . ', "' . $this->created . '" ' .
20007 +              'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
20008 +              'WHERE subscription.subscribed = ' . $this->profile_id . ' ' .
20009 +              'AND NOT EXISTS (SELECT user_id, notice_id ' .
20010 +              'FROM notice_inbox ' .
20011 +              'WHERE user_id = user.id ' .
20012 +              'AND notice_id = ' . $this->id . ' )';
20013 +            if ($enabled === 'transitional') {
20014 +                $qry .= ' AND user.inboxed = 1';
20015 +            }
20016 +            $inbox->query($qry);
20017 +        }
20018 +        return;
20019 +    }
20020 hunk ./classes/Notice.php 523
20021 -       # Delete from inboxes if we're deleted.
20022 +    # Delete from inboxes if we're deleted.
20023 hunk ./classes/Notice.php 525
20024 -       function blowInboxes() {
20025 +    function blowInboxes() {
20026 hunk ./classes/Notice.php 527
20027 -               $enabled = common_config('inboxes', 'enabled');
20028 +        $enabled = common_config('inboxes', 'enabled');
20029 hunk ./classes/Notice.php 529
20030 -               if ($enabled === true || $enabled === 'transitional') {
20031 -                       $inbox = new Notice_inbox();
20032 -                       $inbox->notice_id = $this->id;
20033 -                       $inbox->delete();
20034 -               }
20035 +        if ($enabled === true || $enabled === 'transitional') {
20036 +            $inbox = new Notice_inbox();
20037 +            $inbox->notice_id = $this->id;
20038 +            $inbox->delete();
20039 +        }
20040 hunk ./classes/Notice.php 535
20041 -               return;
20042 -       }
20043 +        return;
20044 +    }
20045 hunk ./classes/NoticeWrapper.php 38
20046 -       var $notices = NULL;
20047 -       var $i = -1;
20048 -       
20049 -       function __construct($arr) {
20050 -               $this->notices = $arr;
20051 -       }
20052 -       
20053 -       function fetch() {
20054 -               static $fields = array('id', 'profile_id', 'uri', 'content', 'rendered',
20055 -                                                          'url', 'created', 'modified', 'reply_to', 'is_local', 'source');
20056 -               $this->i++;
20057 -               if ($this->i >= count($this->notices)) {
20058 -                       return false;
20059 -               } else {
20060 -                       $n = $this->notices[$this->i];
20061 -                       foreach ($fields as $f) {
20062 -                               $this->$f = $n->$f;
20063 -                       }
20064 -                       return true;
20065 -               }
20066 -       }
20067 +    var $notices = NULL;
20068 +    var $i = -1;
20069 +    
20070 +    function __construct($arr) {
20071 +        $this->notices = $arr;
20072 +    }
20073 +    
20074 +    function fetch() {
20075 +        static $fields = array('id', 'profile_id', 'uri', 'content', 'rendered',
20076 +                               'url', 'created', 'modified', 'reply_to', 'is_local', 'source');
20077 +        $this->i++;
20078 +        if ($this->i >= count($this->notices)) {
20079 +            return false;
20080 +        } else {
20081 +            $n = $this->notices[$this->i];
20082 +            foreach ($fields as $f) {
20083 +                $this->$f = $n->$f;
20084 +            }
20085 +            return true;
20086 +        }
20087 +    }
20088 hunk ./classes/Notice_tag.php 37
20089 -       
20090 -       static function getStream($tag, $offset=0, $limit=20) {
20091 -               $qry = 
20092 -                 'SELECT notice.* ' .
20093 -                 'FROM notice JOIN notice_tag ON notice.id = notice_tag.notice_id ' .
20094 -                 'WHERE notice_tag.tag = "%s" ';
20095 +    
20096 +    static function getStream($tag, $offset=0, $limit=20) {
20097 +        $qry = 
20098 +          'SELECT notice.* ' .
20099 +          'FROM notice JOIN notice_tag ON notice.id = notice_tag.notice_id ' .
20100 +          'WHERE notice_tag.tag = "%s" ';
20101 hunk ./classes/Notice_tag.php 44
20102 -               return Notice::getStream(sprintf($qry, $tag),
20103 -                                                                'notice_tag:notice_stream:' . common_keyize($tag),
20104 -                                                                $offset, $limit);
20105 -       }
20106 -       
20107 -       function blowCache() {
20108 -               $cache = common_memcache();
20109 -               if ($cache) {
20110 -                       $cache->delete(common_cache_key('notice_tag:notice_stream:' . $this->tag));
20111 -               }
20112 -       }
20113 +        return Notice::getStream(sprintf($qry, $tag),
20114 +                                 'notice_tag:notice_stream:' . common_keyize($tag),
20115 +                                 $offset, $limit);
20116 +    }
20117 +    
20118 +    function blowCache() {
20119 +        $cache = common_memcache();
20120 +        if ($cache) {
20121 +            $cache->delete(common_cache_key('notice_tag:notice_stream:' . $this->tag));
20122 +        }
20123 +    }
20124 hunk ./classes/Profile.php 49
20125 -       function getAvatar($width, $height=NULL) {
20126 -               if (is_null($height)) {
20127 -                       $height = $width;
20128 -               }
20129 -               return Avatar::pkeyGet(array('profile_id' => $this->id,
20130 -                                                                        'width' => $width,
20131 -                                                                        'height' => $height));
20132 -       }
20133 +    function getAvatar($width, $height=NULL) {
20134 +        if (is_null($height)) {
20135 +            $height = $width;
20136 +        }
20137 +        return Avatar::pkeyGet(array('profile_id' => $this->id,
20138 +                                     'width' => $width,
20139 +                                     'height' => $height));
20140 +    }
20141 hunk ./classes/Profile.php 58
20142 -       function getOriginalAvatar() {
20143 -               $avatar = DB_DataObject::factory('avatar');
20144 -               $avatar->profile_id = $this->id;
20145 -               $avatar->original = true;
20146 -               if ($avatar->find(true)) {
20147 -                       return $avatar;
20148 -               } else {
20149 -                       return NULL;
20150 -               }
20151 -       }
20152 +    function getOriginalAvatar() {
20153 +        $avatar = DB_DataObject::factory('avatar');
20154 +        $avatar->profile_id = $this->id;
20155 +        $avatar->original = true;
20156 +        if ($avatar->find(true)) {
20157 +            return $avatar;
20158 +        } else {
20159 +            return NULL;
20160 +        }
20161 +    }
20162 hunk ./classes/Profile.php 69
20163 -       function setOriginal($source) {
20164 +    function setOriginal($source) {
20165 hunk ./classes/Profile.php 71
20166 -               $info = @getimagesize($source);
20167 +        $info = @getimagesize($source);
20168 hunk ./classes/Profile.php 73
20169 -               if (!$info) {
20170 -                       return NULL;
20171 -               }
20172 +        if (!$info) {
20173 +            return NULL;
20174 +        }
20175 hunk ./classes/Profile.php 77
20176 -               $filename = common_avatar_filename($this->id,
20177 -                                                                                  image_type_to_extension($info[2]),
20178 -                                                                                  NULL, common_timestamp());
20179 -               $filepath = common_avatar_path($filename);
20180 +        $filename = common_avatar_filename($this->id,
20181 +                                           image_type_to_extension($info[2]),
20182 +                                           NULL, common_timestamp());
20183 +        $filepath = common_avatar_path($filename);
20184 hunk ./classes/Profile.php 82
20185 -               copy($source, $filepath);
20186 +        copy($source, $filepath);
20187 hunk ./classes/Profile.php 84
20188 -               $avatar = new Avatar();
20189 +        $avatar = new Avatar();
20190 hunk ./classes/Profile.php 86
20191 -               $avatar->profile_id = $this->id;
20192 -               $avatar->width = $info[0];
20193 -               $avatar->height = $info[1];
20194 -               $avatar->mediatype = image_type_to_mime_type($info[2]);
20195 -               $avatar->filename = $filename;
20196 -               $avatar->original = true;
20197 -               $avatar->url = common_avatar_url($filename);
20198 -               $avatar->created = DB_DataObject_Cast::dateTime(); # current time
20199 +        $avatar->profile_id = $this->id;
20200 +        $avatar->width = $info[0];
20201 +        $avatar->height = $info[1];
20202 +        $avatar->mediatype = image_type_to_mime_type($info[2]);
20203 +        $avatar->filename = $filename;
20204 +        $avatar->original = true;
20205 +        $avatar->url = common_avatar_url($filename);
20206 +        $avatar->created = DB_DataObject_Cast::dateTime(); # current time
20207 hunk ./classes/Profile.php 95
20208 -               # XXX: start a transaction here
20209 +        # XXX: start a transaction here
20210 hunk ./classes/Profile.php 97
20211 -               if (!$this->delete_avatars()) {
20212 -                       @unlink($filepath);
20213 -                       return NULL;
20214 -               }
20215 +        if (!$this->delete_avatars()) {
20216 +            @unlink($filepath);
20217 +            return NULL;
20218 +        }
20219 hunk ./classes/Profile.php 102
20220 -               if (!$avatar->insert()) {
20221 -                       @unlink($filepath);
20222 -                       return NULL;
20223 -               }
20224 +        if (!$avatar->insert()) {
20225 +            @unlink($filepath);
20226 +            return NULL;
20227 +        }
20228 hunk ./classes/Profile.php 107
20229 -               foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
20230 -                       # We don't do a scaled one if original is our scaled size
20231 -                       if (!($avatar->width == $size && $avatar->height == $size)) {
20232 -                               $s = $avatar->scale($size);
20233 -                               if (!$s) {
20234 -                                       return NULL;
20235 -                               }
20236 -                       }
20237 -               }
20238 +        foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
20239 +            # We don't do a scaled one if original is our scaled size
20240 +            if (!($avatar->width == $size && $avatar->height == $size)) {
20241 +                $s = $avatar->scale($size);
20242 +                if (!$s) {
20243 +                    return NULL;
20244 +                }
20245 +            }
20246 +        }
20247 hunk ./classes/Profile.php 117
20248 -               return $avatar;
20249 -       }
20250 +        return $avatar;
20251 +    }
20252 hunk ./classes/Profile.php 120
20253 -       function delete_avatars() {
20254 -               $avatar = new Avatar();
20255 -               $avatar->profile_id = $this->id;
20256 -               $avatar->find();
20257 -               while ($avatar->fetch()) {
20258 -                       $avatar->delete();
20259 -               }
20260 -               return true;
20261 -       }
20262 +    function delete_avatars() {
20263 +        $avatar = new Avatar();
20264 +        $avatar->profile_id = $this->id;
20265 +        $avatar->find();
20266 +        while ($avatar->fetch()) {
20267 +            $avatar->delete();
20268 +        }
20269 +        return true;
20270 +    }
20271 hunk ./classes/Profile.php 130
20272 -       function getBestName() {
20273 -               return ($this->fullname) ? $this->fullname : $this->nickname;
20274 -       }
20275 +    function getBestName() {
20276 +        return ($this->fullname) ? $this->fullname : $this->nickname;
20277 +    }
20278 hunk ./classes/Profile.php 135
20279 -       function getCurrentNotice($dt=NULL) {
20280 -               $notice = new Notice();
20281 -               $notice->profile_id = $this->id;
20282 -               if ($dt) {
20283 -                       $notice->whereAdd('created < "' . $dt . '"');
20284 -               }
20285 -               $notice->orderBy('created DESC, notice.id DESC');
20286 -               $notice->limit(1);
20287 -               if ($notice->find(true)) {
20288 -                       return $notice;
20289 -               }
20290 -               return NULL;
20291 -       }
20292 +    function getCurrentNotice($dt=NULL) {
20293 +        $notice = new Notice();
20294 +        $notice->profile_id = $this->id;
20295 +        if ($dt) {
20296 +            $notice->whereAdd('created < "' . $dt . '"');
20297 +        }
20298 +        $notice->orderBy('created DESC, notice.id DESC');
20299 +        $notice->limit(1);
20300 +        if ($notice->find(true)) {
20301 +            return $notice;
20302 +        }
20303 +        return NULL;
20304 +    }
20305 hunk ./classes/Profile.php 149
20306 -       function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) {
20307 -               $qry =
20308 -                 'SELECT * ' .
20309 -                 'FROM notice ' .
20310 -                 'WHERE profile_id = %d ';
20311 +    function getNotices($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0) {
20312 +        $qry =
20313 +          'SELECT * ' .
20314 +          'FROM notice ' .
20315 +          'WHERE profile_id = %d ';
20316 hunk ./classes/Profile.php 155
20317 -               return Notice::getStream(sprintf($qry, $this->id),
20318 -                                                                'profile:notices:'.$this->id,
20319 -                                                                $offset, $limit, $since_id, $before_id);
20320 -       }
20321 +        return Notice::getStream(sprintf($qry, $this->id),
20322 +                                 'profile:notices:'.$this->id,
20323 +                                 $offset, $limit, $since_id, $before_id);
20324 +    }
20325 hunk ./classes/Profile_tag.php 24
20326 -       static function getTags($tagger, $tagged) {
20327 -               
20328 -               $tags = array();
20329 +    static function getTags($tagger, $tagged) {
20330 +        
20331 +        $tags = array();
20332 hunk ./classes/Profile_tag.php 28
20333 -               # XXX: store this in memcached
20334 -               
20335 -               $profile_tag = new Profile_tag();
20336 -               $profile_tag->tagger = $tagger;
20337 -               $profile_tag->tagged = $tagged;
20338 -               
20339 -               $profile_tag->find();
20340 -               
20341 -               while ($profile_tag->fetch()) {
20342 -                       $tags[] = $profile_tag->tag;
20343 -               }
20344 -               
20345 -               $profile_tag->free();
20346 -               
20347 -               return $tags;
20348 -       }
20349 -       
20350 -       static function setTags($tagger, $tagged, $newtags) {
20351 -               
20352 -               $oldtags = Profile_tag::getTags($tagger, $tagged);
20353 -               
20354 -               # Delete stuff that's old that not in new
20355 -               
20356 -               $to_delete = array_diff($oldtags, $newtags);
20357 -               
20358 -               # Insert stuff that's in new and not in old
20359 -               
20360 -               $to_insert = array_diff($newtags, $oldtags);
20361 -               
20362 -               $profile_tag = new Profile_tag();
20363 -               
20364 -               $profile_tag->tagger = $tagger;
20365 -               $profile_tag->tagged = $tagged;
20366 -               
20367 -               $profile_tag->query('BEGIN');
20368 -               
20369 -               foreach ($to_delete as $deltag) {
20370 -                       $profile_tag->tag = $deltag;
20371 -                       $result = $profile_tag->delete();
20372 -                       if (!$result) {
20373 -                               common_log_db_error($profile_tag, 'DELETE', __FILE__);
20374 -                               return false;
20375 -                       }
20376 -               }
20377 -               
20378 -               foreach ($to_insert as $instag) {
20379 -                       $profile_tag->tag = $instag;
20380 -                       $result = $profile_tag->insert();
20381 -                       if (!$result) {
20382 -                               common_log_db_error($profile_tag, 'INSERT', __FILE__);
20383 -                               return false;
20384 -                       }
20385 -               }
20386 -               
20387 -               $profile_tag->query('COMMIT');
20388 -               
20389 -               return true;
20390 -       }
20391 -       
20392 -       # Return profiles with a given tag
20393 -       static function getTagged($tagger, $tag) {
20394 -               $profile = new Profile();
20395 -               $profile->query('SELECT profile.* ' .
20396 -                                               'FROM profile JOIN profile_tag ' .
20397 -                                               'ON profile.id = profile_tag.tagged ' .
20398 -                                               'WHERE profile_tag.tagger = ' . $tagger . ' ' .
20399 -                                               'AND profile_tag.tag = "' . $tag . '" ');
20400 -               $tagged = array();
20401 -               while ($profile->fetch()) {
20402 -                       $tagged[] = clone($profile);
20403 -               }
20404 -               return $tagged;
20405 -       }
20406 +        # XXX: store this in memcached
20407 +        
20408 +        $profile_tag = new Profile_tag();
20409 +        $profile_tag->tagger = $tagger;
20410 +        $profile_tag->tagged = $tagged;
20411 +        
20412 +        $profile_tag->find();
20413 +        
20414 +        while ($profile_tag->fetch()) {
20415 +            $tags[] = $profile_tag->tag;
20416 +        }
20417 +        
20418 +        $profile_tag->free();
20419 +        
20420 +        return $tags;
20421 +    }
20422 +    
20423 +    static function setTags($tagger, $tagged, $newtags) {
20424 +        
20425 +        $oldtags = Profile_tag::getTags($tagger, $tagged);
20426 +        
20427 +        # Delete stuff that's old that not in new
20428 +        
20429 +        $to_delete = array_diff($oldtags, $newtags);
20430 +        
20431 +        # Insert stuff that's in new and not in old
20432 +        
20433 +        $to_insert = array_diff($newtags, $oldtags);
20434 +        
20435 +        $profile_tag = new Profile_tag();
20436 +        
20437 +        $profile_tag->tagger = $tagger;
20438 +        $profile_tag->tagged = $tagged;
20439 +        
20440 +        $profile_tag->query('BEGIN');
20441 +        
20442 +        foreach ($to_delete as $deltag) {
20443 +            $profile_tag->tag = $deltag;
20444 +            $result = $profile_tag->delete();
20445 +            if (!$result) {
20446 +                common_log_db_error($profile_tag, 'DELETE', __FILE__);
20447 +                return false;
20448 +            }
20449 +        }
20450 +        
20451 +        foreach ($to_insert as $instag) {
20452 +            $profile_tag->tag = $instag;
20453 +            $result = $profile_tag->insert();
20454 +            if (!$result) {
20455 +                common_log_db_error($profile_tag, 'INSERT', __FILE__);
20456 +                return false;
20457 +            }
20458 +        }
20459 +        
20460 +        $profile_tag->query('COMMIT');
20461 +        
20462 +        return true;
20463 +    }
20464 +    
20465 +    # Return profiles with a given tag
20466 +    static function getTagged($tagger, $tag) {
20467 +        $profile = new Profile();
20468 +        $profile->query('SELECT profile.* ' .
20469 +                        'FROM profile JOIN profile_tag ' .
20470 +                        'ON profile.id = profile_tag.tagged ' .
20471 +                        'WHERE profile_tag.tagger = ' . $tagger . ' ' .
20472 +                        'AND profile_tag.tag = "' . $tag . '" ');
20473 +        $tagged = array();
20474 +        while ($profile->fetch()) {
20475 +            $tagged[] = clone($profile);
20476 +        }
20477 +        return $tagged;
20478 +    }
20479 hunk ./classes/Queue_item.php 25
20480 -       
20481 -       static function top($transport) {
20482 +    
20483 +    static function top($transport) {
20484 hunk ./classes/Queue_item.php 28
20485 -               $qi = new Queue_item();
20486 -               $qi->transport = $transport;
20487 -               $qi->orderBy('created');
20488 -               $qi->whereAdd('claimed is NULL');
20489 +        $qi = new Queue_item();
20490 +        $qi->transport = $transport;
20491 +        $qi->orderBy('created');
20492 +        $qi->whereAdd('claimed is NULL');
20493 hunk ./classes/Queue_item.php 33
20494 -               $qi->limit(1);
20495 +        $qi->limit(1);
20496 hunk ./classes/Queue_item.php 35
20497 -               $cnt = $qi->find(TRUE);
20498 +        $cnt = $qi->find(TRUE);
20499 hunk ./classes/Queue_item.php 37
20500 -               if ($cnt) {
20501 -                       # XXX: potential race condition
20502 -                       # can we force it to only update if claimed is still NULL
20503 -                       # (or old)?
20504 -                       common_log(LOG_INFO, 'claiming queue item = ' . $qi->notice_id . ' for transport ' . $transport);
20505 -                       $orig = clone($qi);
20506 -                       $qi->claimed = common_sql_now();
20507 -                       $result = $qi->update($orig);
20508 -                       if ($result) {
20509 -                               common_log(LOG_INFO, 'claim succeeded.');
20510 -                               return $qi;
20511 -                       } else {
20512 -                               common_log(LOG_INFO, 'claim failed.');
20513 -                       }
20514 -               }
20515 -               $qi = NULL;
20516 -               return NULL;
20517 -       }
20518 +        if ($cnt) {
20519 +            # XXX: potential race condition
20520 +            # can we force it to only update if claimed is still NULL
20521 +            # (or old)?
20522 +            common_log(LOG_INFO, 'claiming queue item = ' . $qi->notice_id . ' for transport ' . $transport);
20523 +            $orig = clone($qi);
20524 +            $qi->claimed = common_sql_now();
20525 +            $result = $qi->update($orig);
20526 +            if ($result) {
20527 +                common_log(LOG_INFO, 'claim succeeded.');
20528 +                return $qi;
20529 +            } else {
20530 +                common_log(LOG_INFO, 'claim failed.');
20531 +            }
20532 +        }
20533 +        $qi = NULL;
20534 +        return NULL;
20535 +    }
20536 hunk ./classes/Sms_carrier.php 24
20537 -       
20538 -       function toEmailAddress($sms) {
20539 -               return sprintf($this->email_pattern, $sms);
20540 -       }
20541 +    
20542 +    function toEmailAddress($sms) {
20543 +        return sprintf($this->email_pattern, $sms);
20544 +    }
20545 hunk ./classes/Subscription.php 47
20546 -       
20547 -       function &pkeyGet($kv) {
20548 -               return Memcached_DataObject::pkeyGet('Subscription', $kv);
20549 -       }
20550 +    
20551 +    function &pkeyGet($kv) {
20552 +        return Memcached_DataObject::pkeyGet('Subscription', $kv);
20553 +    }
20554 hunk ./classes/User.php 70
20555 -       function getProfile() {
20556 -               return Profile::staticGet('id', $this->id);
20557 -       }
20558 +    function getProfile() {
20559 +        return Profile::staticGet('id', $this->id);
20560 +    }
20561 hunk ./classes/User.php 74
20562 -       function isSubscribed($other) {
20563 -               assert(!is_null($other));
20564 -               # XXX: cache results of this query
20565 -               $sub = Subscription::pkeyGet(array('subscriber' => $this->id,
20566 -                                                                                  'subscribed' => $other->id));
20567 -               return (is_null($sub)) ? false : true;
20568 -       }
20569 +    function isSubscribed($other) {
20570 +        assert(!is_null($other));
20571 +        # XXX: cache results of this query
20572 +        $sub = Subscription::pkeyGet(array('subscriber' => $this->id,
20573 +                                           'subscribed' => $other->id));
20574 +        return (is_null($sub)) ? false : true;
20575 +    }
20576 hunk ./classes/User.php 82
20577 -       # 'update' won't write key columns, so we have to do it ourselves.
20578 +    # 'update' won't write key columns, so we have to do it ourselves.
20579 hunk ./classes/User.php 84
20580 -       function updateKeys(&$orig) {
20581 -               $parts = array();
20582 -               foreach (array('nickname', 'email', 'jabber', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
20583 -                       if (strcmp($this->$k, $orig->$k) != 0) {
20584 -                               $parts[] = $k . ' = ' . $this->_quote($this->$k);
20585 -                       }
20586 -               }
20587 -               if (count($parts) == 0) {
20588 -                       # No changes
20589 -                       return true;
20590 -               }
20591 -               $toupdate = implode(', ', $parts);
20592 +    function updateKeys(&$orig) {
20593 +        $parts = array();
20594 +        foreach (array('nickname', 'email', 'jabber', 'incomingemail', 'sms', 'carrier', 'smsemail', 'language', 'timezone') as $k) {
20595 +            if (strcmp($this->$k, $orig->$k) != 0) {
20596 +                $parts[] = $k . ' = ' . $this->_quote($this->$k);
20597 +            }
20598 +        }
20599 +        if (count($parts) == 0) {
20600 +            # No changes
20601 +            return true;
20602 +        }
20603 +        $toupdate = implode(', ', $parts);
20604 hunk ./classes/User.php 97
20605 -               $table = $this->tableName();
20606 -               if(common_config('db','quote_identifiers')) {
20607 -                       $table = '"' . $table . '"';
20608 -               }
20609 -               $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
20610 -                 ' WHERE id = ' . $this->id;
20611 -               $orig->decache();
20612 -               $result = $this->query($qry);
20613 -               if ($result) {
20614 -                       $this->encache();
20615 -               }
20616 -               return $result;
20617 -       }
20618 +        $table = $this->tableName();
20619 +        if(common_config('db','quote_identifiers')) {
20620 +            $table = '"' . $table . '"';
20621 +        }
20622 +        $qry = 'UPDATE ' . $table . ' SET ' . $toupdate .
20623 +          ' WHERE id = ' . $this->id;
20624 +        $orig->decache();
20625 +        $result = $this->query($qry);
20626 +        if ($result) {
20627 +            $this->encache();
20628 +        }
20629 +        return $result;
20630 +    }
20631 hunk ./classes/User.php 111
20632 -       function allowed_nickname($nickname) {
20633 -               # XXX: should already be validated for size, content, etc.
20634 -               static $blacklist = array('rss', 'xrds', 'doc', 'main',
20635 -                                                                 'settings', 'notice', 'user',
20636 -                                                                 'search', 'avatar', 'tag', 'tags',
20637 -                                                                 'api', 'message');
20638 -               $merged = array_merge($blacklist, common_config('nickname', 'blacklist'));
20639 -               return !in_array($nickname, $merged);
20640 -       }
20641 +    function allowed_nickname($nickname) {
20642 +        # XXX: should already be validated for size, content, etc.
20643 +        static $blacklist = array('rss', 'xrds', 'doc', 'main',
20644 +                                  'settings', 'notice', 'user',
20645 +                                  'search', 'avatar', 'tag', 'tags',
20646 +                                  'api', 'message');
20647 +        $merged = array_merge($blacklist, common_config('nickname', 'blacklist'));
20648 +        return !in_array($nickname, $merged);
20649 +    }
20650 hunk ./classes/User.php 121
20651 -       function getCurrentNotice($dt=NULL) {
20652 -               $profile = $this->getProfile();
20653 -               if (!$profile) {
20654 -                       return NULL;
20655 -               }
20656 -               return $profile->getCurrentNotice($dt);
20657 -       }
20658 +    function getCurrentNotice($dt=NULL) {
20659 +        $profile = $this->getProfile();
20660 +        if (!$profile) {
20661 +            return NULL;
20662 +        }
20663 +        return $profile->getCurrentNotice($dt);
20664 +    }
20665 hunk ./classes/User.php 129
20666 -       function getCarrier() {
20667 -               return Sms_carrier::staticGet('id', $this->carrier);
20668 -       }
20669 +    function getCarrier() {
20670 +        return Sms_carrier::staticGet('id', $this->carrier);
20671 +    }
20672 hunk ./classes/User.php 133
20673 -       function subscribeTo($other) {
20674 -               $sub = new Subscription();
20675 -               $sub->subscriber = $this->id;
20676 -               $sub->subscribed = $other->id;
20677 +    function subscribeTo($other) {
20678 +        $sub = new Subscription();
20679 +        $sub->subscriber = $this->id;
20680 +        $sub->subscribed = $other->id;
20681 hunk ./classes/User.php 138
20682 -               $sub->created = common_sql_now(); # current time
20683 +        $sub->created = common_sql_now(); # current time
20684 hunk ./classes/User.php 140
20685 -               if (!$sub->insert()) {
20686 -                       return false;
20687 -               }
20688 +        if (!$sub->insert()) {
20689 +            return false;
20690 +        }
20691 hunk ./classes/User.php 144
20692 -               return true;
20693 -       }
20694 +        return true;
20695 +    }
20696 hunk ./classes/User.php 161
20697 -       static function register($fields) {
20698 +    static function register($fields) {
20699 hunk ./classes/User.php 163
20700 -               # MAGICALLY put fields into current scope
20701 +        # MAGICALLY put fields into current scope
20702 hunk ./classes/User.php 165
20703 -               extract($fields);
20704 +        extract($fields);
20705 hunk ./classes/User.php 167
20706 -               $profile = new Profile();
20707 +        $profile = new Profile();
20708 hunk ./classes/User.php 169
20709 -               $profile->query('BEGIN');
20710 +        $profile->query('BEGIN');
20711 hunk ./classes/User.php 171
20712 -               $profile->nickname = $nickname;
20713 -               $profile->profileurl = common_profile_url($nickname);
20714 +        $profile->nickname = $nickname;
20715 +        $profile->profileurl = common_profile_url($nickname);
20716 hunk ./classes/User.php 174
20717 -               if ($fullname) {
20718 -                       $profile->fullname = $fullname;
20719 -               }
20720 -               if ($homepage) {
20721 -                       $profile->homepage = $homepage;
20722 -               }
20723 -               if ($bio) {
20724 -                       $profile->bio = $bio;
20725 -               }
20726 -               if ($location) {
20727 -                       $profile->location = $location;
20728 -               }
20729 +        if ($fullname) {
20730 +            $profile->fullname = $fullname;
20731 +        }
20732 +        if ($homepage) {
20733 +            $profile->homepage = $homepage;
20734 +        }
20735 +        if ($bio) {
20736 +            $profile->bio = $bio;
20737 +        }
20738 +        if ($location) {
20739 +            $profile->location = $location;
20740 +        }
20741 hunk ./classes/User.php 187
20742 -               $profile->created = common_sql_now();
20743 +        $profile->created = common_sql_now();
20744 hunk ./classes/User.php 189
20745 -               $id = $profile->insert();
20746 +        $id = $profile->insert();
20747 hunk ./classes/User.php 191
20748 -               if (!$id) {
20749 -                       common_log_db_error($profile, 'INSERT', __FILE__);
20750 -                   return FALSE;
20751 -               }
20752 +        if (!$id) {
20753 +            common_log_db_error($profile, 'INSERT', __FILE__);
20754 +            return FALSE;
20755 +        }
20756 hunk ./classes/User.php 196
20757 -               $user = new User();
20758 +        $user = new User();
20759 hunk ./classes/User.php 198
20760 -               $user->id = $id;
20761 -               $user->nickname = $nickname;
20762 +        $user->id = $id;
20763 +        $user->nickname = $nickname;
20764 hunk ./classes/User.php 201
20765 -               if ($password) { # may not have a password for OpenID users
20766 -                       $user->password = common_munge_password($password, $id);
20767 -               }
20768 +        if ($password) { # may not have a password for OpenID users
20769 +            $user->password = common_munge_password($password, $id);
20770 +        }
20771 hunk ./classes/User.php 205
20772 -               # Users who respond to invite email have proven their ownership of that address
20773 +        # Users who respond to invite email have proven their ownership of that address
20774 hunk ./classes/User.php 207
20775 -               if ($code) {
20776 -                       $invite = Invitation::staticGet($code);
20777 -                       if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
20778 -                               $user->email = $invite->address;
20779 -                       }
20780 -               }
20781 +        if ($code) {
20782 +            $invite = Invitation::staticGet($code);
20783 +            if ($invite && $invite->address && $invite->address_type == 'email' && $invite->address == $email) {
20784 +                $user->email = $invite->address;
20785 +            }
20786 +        }
20787 hunk ./classes/User.php 214
20788 -               $inboxes = common_config('inboxes', 'enabled');
20789 +        $inboxes = common_config('inboxes', 'enabled');
20790 hunk ./classes/User.php 216
20791 -               if ($inboxes === true || $inboxes == 'transitional') {
20792 -                       $user->inboxed = 1;
20793 -               }
20794 +        if ($inboxes === true || $inboxes == 'transitional') {
20795 +            $user->inboxed = 1;
20796 +        }
20797 hunk ./classes/User.php 220
20798 -               $user->created = common_sql_now();
20799 -               $user->uri = common_user_uri($user);
20800 +        $user->created = common_sql_now();
20801 +        $user->uri = common_user_uri($user);
20802 hunk ./classes/User.php 223
20803 -               $result = $user->insert();
20804 +        $result = $user->insert();
20805 hunk ./classes/User.php 225
20806 -               if (!$result) {
20807 -                       common_log_db_error($user, 'INSERT', __FILE__);
20808 -                       return FALSE;
20809 -               }
20810 +        if (!$result) {
20811 +            common_log_db_error($user, 'INSERT', __FILE__);
20812 +            return FALSE;
20813 +        }
20814 hunk ./classes/User.php 230
20815 -               # Everyone is subscribed to themself
20816 +        # Everyone is subscribed to themself
20817 hunk ./classes/User.php 232
20818 -               $subscription = new Subscription();
20819 -               $subscription->subscriber = $user->id;
20820 -               $subscription->subscribed = $user->id;
20821 -               $subscription->created = $user->created;
20822 +        $subscription = new Subscription();
20823 +        $subscription->subscriber = $user->id;
20824 +        $subscription->subscribed = $user->id;
20825 +        $subscription->created = $user->created;
20826 hunk ./classes/User.php 237
20827 -               $result = $subscription->insert();
20828 +        $result = $subscription->insert();
20829 hunk ./classes/User.php 239
20830 -               if (!$result) {
20831 -                       common_log_db_error($subscription, 'INSERT', __FILE__);
20832 -                       return FALSE;
20833 -               }
20834 +        if (!$result) {
20835 +            common_log_db_error($subscription, 'INSERT', __FILE__);
20836 +            return FALSE;
20837 +        }
20838 hunk ./classes/User.php 244
20839 -               if ($email && !$user->email) {
20840 +        if ($email && !$user->email) {
20841 hunk ./classes/User.php 246
20842 -                       $confirm = new Confirm_address();
20843 -                       $confirm->code = common_confirmation_code(128);
20844 -                       $confirm->user_id = $user->id;
20845 -                       $confirm->address = $email;
20846 -                       $confirm->address_type = 'email';
20847 +            $confirm = new Confirm_address();
20848 +            $confirm->code = common_confirmation_code(128);
20849 +            $confirm->user_id = $user->id;
20850 +            $confirm->address = $email;
20851 +            $confirm->address_type = 'email';
20852 hunk ./classes/User.php 252
20853 -                       $result = $confirm->insert();
20854 -                       if (!$result) {
20855 -                               common_log_db_error($confirm, 'INSERT', __FILE__);
20856 -                               return FALSE;
20857 -                       }
20858 -               }
20859 +            $result = $confirm->insert();
20860 +            if (!$result) {
20861 +                common_log_db_error($confirm, 'INSERT', __FILE__);
20862 +                return FALSE;
20863 +            }
20864 +        }
20865 hunk ./classes/User.php 259
20866 -               if ($code && $user->email) {
20867 -                       $user->emailChanged();
20868 -               }
20869 +        if ($code && $user->email) {
20870 +            $user->emailChanged();
20871 +        }
20872 hunk ./classes/User.php 263
20873 -               $profile->query('COMMIT');
20874 +        $profile->query('COMMIT');
20875 hunk ./classes/User.php 265
20876 -               if ($email && !$user->email) {
20877 -                       mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
20878 -               }
20879 +        if ($email && !$user->email) {
20880 +            mail_confirm_address($user, $confirm->code, $profile->nickname, $email);
20881 +        }
20882 hunk ./classes/User.php 269
20883 -               return $user;
20884 -       }
20885 +        return $user;
20886 +    }
20887 hunk ./classes/User.php 272
20888 -       # Things we do when the email changes
20889 +    # Things we do when the email changes
20890 hunk ./classes/User.php 274
20891 -       function emailChanged() {
20892 +    function emailChanged() {
20893 hunk ./classes/User.php 276
20894 -               $invites = new Invitation();
20895 -               $invites->address = $this->email;
20896 -               $invites->address_type = 'email';
20897 +        $invites = new Invitation();
20898 +        $invites->address = $this->email;
20899 +        $invites->address_type = 'email';
20900 hunk ./classes/User.php 280
20901 -               if ($invites->find()) {
20902 -                       while ($invites->fetch()) {
20903 -                               $other = User::staticGet($invites->user_id);
20904 -                               subs_subscribe_to($other, $this);
20905 -                       }
20906 -               }
20907 -       }
20908 +        if ($invites->find()) {
20909 +            while ($invites->fetch()) {
20910 +                $other = User::staticGet($invites->user_id);
20911 +                subs_subscribe_to($other, $this);
20912 +            }
20913 +        }
20914 +    }
20915 hunk ./classes/User.php 288
20916 -       function hasFave($notice) {
20917 -               $cache = common_memcache();
20918 +    function hasFave($notice) {
20919 +        $cache = common_memcache();
20920 hunk ./classes/User.php 291
20921 -               # XXX: Kind of a hack.
20922 -               if ($cache) {
20923 -                       # This is the stream of favorite notices, in rev chron
20924 -                       # order. This forces it into cache.
20925 -                       $faves = $this->favoriteNotices(0, NOTICE_CACHE_WINDOW);
20926 -                       $cnt = 0;
20927 -                       while ($faves->fetch()) {
20928 -                               if ($faves->id < $notice->id) {
20929 -                                       # If we passed it, it's not a fave
20930 -                                       return false;
20931 -                               } else if ($faves->id == $notice->id) {
20932 -                                       # If it matches a cached notice, then it's a fave
20933 -                                       return true;
20934 -                               }
20935 -                               $cnt++;
20936 -                       }
20937 -                       # If we're not past the end of the cache window,
20938 -                       # then the cache has all available faves, so this one
20939 -                       # is not a fave.
20940 -                       if ($cnt < NOTICE_CACHE_WINDOW) {
20941 -                               return false;
20942 -                       }
20943 -                       # Otherwise, cache doesn't have all faves;
20944 -                       # fall through to the default
20945 -               }
20946 -               $fave = Fave::pkeyGet(array('user_id' => $this->id,
20947 -                                                                       'notice_id' => $notice->id));
20948 -               return ((is_null($fave)) ? false : true);
20949 -       }
20950 -       function mutuallySubscribed($other) {
20951 -               return $this->isSubscribed($other) &&
20952 -                 $other->isSubscribed($this);
20953 -       }
20954 +        # XXX: Kind of a hack.
20955 +        if ($cache) {
20956 +            # This is the stream of favorite notices, in rev chron
20957 +            # order. This forces it into cache.
20958 +            $faves = $this->favoriteNotices(0, NOTICE_CACHE_WINDOW);
20959 +            $cnt = 0;
20960 +            while ($faves->fetch()) {
20961 +                if ($faves->id < $notice->id) {
20962 +                    # If we passed it, it's not a fave
20963 +                    return false;
20964 +                } else if ($faves->id == $notice->id) {
20965 +                    # If it matches a cached notice, then it's a fave
20966 +                    return true;
20967 +                }
20968 +                $cnt++;
20969 +            }
20970 +            # If we're not past the end of the cache window,
20971 +            # then the cache has all available faves, so this one
20972 +            # is not a fave.
20973 +            if ($cnt < NOTICE_CACHE_WINDOW) {
20974 +                return false;
20975 +            }
20976 +            # Otherwise, cache doesn't have all faves;
20977 +            # fall through to the default
20978 +        }
20979 +        $fave = Fave::pkeyGet(array('user_id' => $this->id,
20980 +                                    'notice_id' => $notice->id));
20981 +        return ((is_null($fave)) ? false : true);
20982 +    }
20983 +    function mutuallySubscribed($other) {
20984 +        return $this->isSubscribed($other) &&
20985 +          $other->isSubscribed($this);
20986 +    }
20987 hunk ./classes/User.php 327
20988 -               # 3-way join; probably should get cached
20989 -               $qry = 'SELECT user.* ' .
20990 -                 'FROM subscription sub1 JOIN user ON sub1.subscribed = user.id ' .
20991 -                 'JOIN subscription sub2 ON user.id = sub2.subscriber ' .
20992 -                 'WHERE sub1.subscriber = %d and sub2.subscribed = %d ' .
20993 -                 'ORDER BY user.nickname';
20994 -               $user = new User();
20995 -               $user->query(sprintf($qry, $this->id, $this->id));
20996 +        # 3-way join; probably should get cached
20997 +        $qry = 'SELECT user.* ' .
20998 +          'FROM subscription sub1 JOIN user ON sub1.subscribed = user.id ' .
20999 +          'JOIN subscription sub2 ON user.id = sub2.subscriber ' .
21000 +          'WHERE sub1.subscriber = %d and sub2.subscribed = %d ' .
21001 +          'ORDER BY user.nickname';
21002 +        $user = new User();
21003 +        $user->query(sprintf($qry, $this->id, $this->id));
21004 hunk ./classes/User.php 336
21005 -               return $user;
21006 -       }
21007 +        return $user;
21008 +    }
21009 hunk ./classes/User.php 339
21010 -       function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=NULL) {
21011 -               $qry =
21012 -                 'SELECT notice.* ' .
21013 -                 'FROM notice JOIN reply ON notice.id = reply.notice_id ' .
21014 -                 'WHERE reply.profile_id = %d ';
21015 -               return Notice::getStream(sprintf($qry, $this->id),
21016 -                                                                'user:replies:'.$this->id,
21017 -                                                                $offset, $limit, $since_id, $before_id, NULL, $since);
21018 -       }
21019 +    function getReplies($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=NULL) {
21020 +        $qry =
21021 +          'SELECT notice.* ' .
21022 +          'FROM notice JOIN reply ON notice.id = reply.notice_id ' .
21023 +          'WHERE reply.profile_id = %d ';
21024 +        return Notice::getStream(sprintf($qry, $this->id),
21025 +                                 'user:replies:'.$this->id,
21026 +                                 $offset, $limit, $since_id, $before_id, NULL, $since);
21027 +    }
21028 hunk ./classes/User.php 356
21029 -       }
21030 +    }
21031 hunk ./classes/User.php 359
21032 -               $qry =
21033 -                 'SELECT notice.* ' .
21034 -                 'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
21035 -                 'WHERE fave.user_id = %d ';
21036 -               return Notice::getStream(sprintf($qry, $this->id),
21037 -                                                                'user:faves:'.$this->id,
21038 -                                                                $offset, $limit);
21039 -       }
21040 +        $qry =
21041 +          'SELECT notice.* ' .
21042 +          'FROM notice JOIN fave ON notice.id = fave.notice_id ' .
21043 +          'WHERE fave.user_id = %d ';
21044 +        return Notice::getStream(sprintf($qry, $this->id),
21045 +                                 'user:faves:'.$this->id,
21046 +                                 $offset, $limit);
21047 +    }
21048 hunk ./classes/User.php 369
21049 -               $enabled = common_config('inboxes', 'enabled');
21050 +        $enabled = common_config('inboxes', 'enabled');
21051 hunk ./classes/User.php 371
21052 -               # Complicated code, depending on whether we support inboxes yet
21053 -               # XXX: make this go away when inboxes become mandatory
21054 +        # Complicated code, depending on whether we support inboxes yet
21055 +        # XXX: make this go away when inboxes become mandatory
21056 hunk ./classes/User.php 374
21057 -               if ($enabled === false ||
21058 -                       ($enabled == 'transitional' && $this->inboxed == 0)) {
21059 -                       $qry =
21060 -                         'SELECT notice.* ' .
21061 -                         'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
21062 -                         'WHERE subscription.subscriber = %d ';
21063 -                       $order = NULL;
21064 -               } else if ($enabled === true ||
21065 -                          ($enabled == 'transitional' && $this->inboxed == 1)) {
21066 +        if ($enabled === false ||
21067 +            ($enabled == 'transitional' && $this->inboxed == 0)) {
21068 +            $qry =
21069 +              'SELECT notice.* ' .
21070 +              'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
21071 +              'WHERE subscription.subscriber = %d ';
21072 +            $order = NULL;
21073 +        } else if ($enabled === true ||
21074 +               ($enabled == 'transitional' && $this->inboxed == 1)) {
21075 hunk ./classes/User.php 384
21076 -                       $qry =
21077 -                         'SELECT notice.* ' .
21078 -                         'FROM notice JOIN notice_inbox ON notice.id = notice_inbox.notice_id ' .
21079 -                         'WHERE notice_inbox.user_id = %d ';
21080 -                       # NOTE: we override ORDER
21081 -                       $order = 'ORDER BY notice_inbox.created DESC, notice_inbox.notice_id DESC ';
21082 -               }
21083 -               return Notice::getStream(sprintf($qry, $this->id),
21084 -                                                                'user:notices_with_friends:' . $this->id,
21085 -                                                                $offset, $limit, $since_id, $before_id,
21086 -                                                                $order, $since);
21087 -       }
21088 +            $qry =
21089 +              'SELECT notice.* ' .
21090 +              'FROM notice JOIN notice_inbox ON notice.id = notice_inbox.notice_id ' .
21091 +              'WHERE notice_inbox.user_id = %d ';
21092 +            # NOTE: we override ORDER
21093 +            $order = 'ORDER BY notice_inbox.created DESC, notice_inbox.notice_id DESC ';
21094 +        }
21095 +        return Notice::getStream(sprintf($qry, $this->id),
21096 +                                 'user:notices_with_friends:' . $this->id,
21097 +                                 $offset, $limit, $since_id, $before_id,
21098 +                                 $order, $since);
21099 +    }
21100 hunk ./classes/User.php 398
21101 -               $cache = common_memcache();
21102 -               if ($cache) {
21103 -                       # Faves don't happen chronologically, so we need to blow
21104 -                       # ;last cache, too
21105 -                       $cache->delete(common_cache_key('user:faves:'.$this->id));
21106 -                       $cache->delete(common_cache_key('user:faves:'.$this->id).';last');
21107 -               }
21108 -       }
21109 +        $cache = common_memcache();
21110 +        if ($cache) {
21111 +            # Faves don't happen chronologically, so we need to blow
21112 +            # ;last cache, too
21113 +            $cache->delete(common_cache_key('user:faves:'.$this->id));
21114 +            $cache->delete(common_cache_key('user:faves:'.$this->id).';last');
21115 +        }
21116 +    }
21117 hunk ./classes/User.php 408
21118 -               return Profile_tag::getTags($this->id, $this->id);
21119 -       }
21120 +        return Profile_tag::getTags($this->id, $this->id);
21121 +    }
21122 hunk ./classes/User.php 412
21123 -               return Profile_tag::setTags($this->id, $this->id, $newtags);
21124 -       }
21125 +        return Profile_tag::setTags($this->id, $this->id, $newtags);
21126 +    }
21127 hunk ./classes/User.php 437
21128 -               $sub = Subscription::pkeyGet(array('subscriber' => $other->id,
21129 -                                                                                  'subscribed' => $this->id));
21130 +        $sub = Subscription::pkeyGet(array('subscriber' => $other->id,
21131 +                                           'subscribed' => $this->id));
21132 hunk ./lib/common.php 57
21133 -               array('name' => 'Just another Laconica microblog',
21134 -                         'server' => 'localhost',
21135 -                         'theme' => 'default',
21136 -                         'path' => '/',
21137 -                         'logfile' => NULL,
21138 -                         'fancy' => false,
21139 -                         'locale_path' => INSTALLDIR.'/locale',
21140 -                         'language' => 'en_US',
21141 -                         'languages' => get_all_languages(),
21142 -                     'email' =>
21143 -                     array_key_exists('SERVER_ADMIN', $_SERVER) ? $_SERVER['SERVER_ADMIN'] : NULL,
21144 -                         'broughtby' => NULL,
21145 -                         'timezone' => 'UTC',
21146 -                         'broughtbyurl' => NULL,
21147 -                         'closed' => false,
21148 -                         'inviteonly' => false,
21149 +        array('name' => 'Just another Laconica microblog',
21150 +              'server' => 'localhost',
21151 +              'theme' => 'default',
21152 +              'path' => '/',
21153 +              'logfile' => NULL,
21154 +              'fancy' => false,
21155 +              'locale_path' => INSTALLDIR.'/locale',
21156 +              'language' => 'en_US',
21157 +              'languages' => get_all_languages(),
21158 +              'email' =>
21159 +              array_key_exists('SERVER_ADMIN', $_SERVER) ? $_SERVER['SERVER_ADMIN'] : NULL,
21160 +              'broughtby' => NULL,
21161 +              'timezone' => 'UTC',
21162 +              'broughtbyurl' => NULL,
21163 +              'closed' => false,
21164 +              'inviteonly' => false,
21165 hunk ./lib/common.php 74
21166 -               'syslog' =>
21167 -               array('appname' => 'laconica', # for syslog
21168 -                         'priority' => 'debug'), # XXX: currently ignored
21169 -               'queue' =>
21170 -               array('enabled' => false),
21171 -               'license' =>
21172 -               array('url' => 'http://creativecommons.org/licenses/by/3.0/',
21173 -                         'title' => 'Creative Commons Attribution 3.0',
21174 -                         'image' => 'http://i.creativecommons.org/l/by/3.0/88x31.png'),
21175 -               'mail' =>
21176 -               array('backend' => 'mail',
21177 -                         'params' => NULL),
21178 -               'nickname' =>
21179 -               array('blacklist' => array(),
21180 -                         'featured' => array()),
21181 -               'profile' =>
21182 -               array('banned' => array()),
21183 -               'avatar' =>
21184 -               array('server' => NULL),
21185 -               'public' =>
21186 -               array('localonly' => true,
21187 -                         'blacklist' => array()),
21188 -               'theme' =>
21189 -               array('server' => NULL),
21190 -               'throttle' =>
21191 +        'syslog' =>
21192 +        array('appname' => 'laconica', # for syslog
21193 +              'priority' => 'debug'), # XXX: currently ignored
21194 +        'queue' =>
21195 +        array('enabled' => false),
21196 +        'license' =>
21197 +        array('url' => 'http://creativecommons.org/licenses/by/3.0/',
21198 +              'title' => 'Creative Commons Attribution 3.0',
21199 +              'image' => 'http://i.creativecommons.org/l/by/3.0/88x31.png'),
21200 +        'mail' =>
21201 +        array('backend' => 'mail',
21202 +              'params' => NULL),
21203 +        'nickname' =>
21204 +        array('blacklist' => array(),
21205 +              'featured' => array()),
21206 +        'profile' =>
21207 +        array('banned' => array()),
21208 +        'avatar' =>
21209 +        array('server' => NULL),
21210 +        'public' =>
21211 +        array('localonly' => true,
21212 +              'blacklist' => array()),
21213 +        'theme' =>
21214 +        array('server' => NULL),
21215 +        'throttle' =>
21216 hunk ./lib/common.php 102
21217 -               'xmpp' =>
21218 -               array('enabled' => false,
21219 -                         'server' => 'INVALID SERVER',
21220 -                         'port' => 5222,
21221 -                         'user' => 'update',
21222 -                         'encryption' => true,
21223 -                         'resource' => 'uniquename',
21224 -                         'password' => 'blahblahblah',
21225 -                         'host' => NULL, # only set if != server
21226 -                         'debug' => false, # print extra debug info
21227 -                         'public' => array()), # JIDs of users who want to receive the public stream
21228 +        'xmpp' =>
21229 +        array('enabled' => false,
21230 +              'server' => 'INVALID SERVER',
21231 +              'port' => 5222,
21232 +              'user' => 'update',
21233 +              'encryption' => true,
21234 +              'resource' => 'uniquename',
21235 +              'password' => 'blahblahblah',
21236 +              'host' => NULL, # only set if != server
21237 +              'debug' => false, # print extra debug info
21238 +              'public' => array()), # JIDs of users who want to receive the public stream
21239 hunk ./lib/common.php 117
21240 -               'tag' =>
21241 -               array('dropoff' => 864000.0),
21242 -               'popular' =>
21243 -               array('dropoff' => 864000.0),
21244 -               'daemon' =>
21245 -               array('piddir' => '/var/run',
21246 -                         'user' => false,
21247 -                         'group' => false),
21248 -               'integration' =>
21249 -               array('source' => 'Laconica'), # source attribute for Twitter
21250 -               'memcached' =>
21251 -               array('enabled' => false,
21252 -                         'server' => 'localhost',
21253 -                         'port' => 11211),
21254 -               'inboxes' =>
21255 -               array('enabled' => true), # on by default for new sites
21256 -               );
21257 +        'tag' =>
21258 +        array('dropoff' => 864000.0),
21259 +        'popular' =>
21260 +        array('dropoff' => 864000.0),
21261 +        'daemon' =>
21262 +        array('piddir' => '/var/run',
21263 +              'user' => false,
21264 +              'group' => false),
21265 +        'integration' =>
21266 +        array('source' => 'Laconica'), # source attribute for Twitter
21267 +        'memcached' =>
21268 +        array('enabled' => false,
21269 +              'server' => 'localhost',
21270 +              'port' => 11211),
21271 +        'inboxes' =>
21272 +        array('enabled' => true), # on by default for new sites
21273 +        );
21274 hunk ./lib/common.php 139
21275 -           'schema_location' => INSTALLDIR . '/classes',
21276 -               'class_location' => INSTALLDIR . '/classes',
21277 -               'require_prefix' => 'classes/',
21278 -               'class_prefix' => '',
21279 -               'mirror' => NULL,
21280 +        'schema_location' => INSTALLDIR . '/classes',
21281 +        'class_location' => INSTALLDIR . '/classes',
21282 +        'require_prefix' => 'classes/',
21283 +        'class_prefix' => '',
21284 +        'mirror' => NULL,
21285 hunk ./lib/common.php 145
21286 -               'quote_identifiers' => false,
21287 -               'type' => 'mysql' );
21288 +        'quote_identifiers' => false,
21289 +        'type' => 'mysql' );
21290 hunk ./lib/common.php 149
21291 -       /* Work internally in UTC */
21292 -       date_default_timezone_set('UTC');
21293 +    /* Work internally in UTC */
21294 +    date_default_timezone_set('UTC');
21295 hunk ./lib/common.php 167
21296 -       if ($class == 'OAuthRequest') {
21297 -               require_once('OAuth.php');
21298 -       } else if (file_exists(INSTALLDIR.'/classes/' . $class . '.php')) {
21299 +    if ($class == 'OAuthRequest') {
21300 +        require_once('OAuth.php');
21301 +    } else if (file_exists(INSTALLDIR.'/classes/' . $class . '.php')) {
21302 hunk ./lib/deleteaction.php 24
21303 -       function handle($args) {
21304 -               parent::handle($args);
21305 -               $user = common_current_user();
21306 -               $notice_id = $this->trimmed('notice');
21307 -               $notice = Notice::staticGet($notice_id);
21308 -               if (!$notice) {
21309 -                       common_user_error(_('No such notice.'));
21310 -                       exit;
21311 -               }
21312 +    function handle($args) {
21313 +        parent::handle($args);
21314 +        $user = common_current_user();
21315 +        $notice_id = $this->trimmed('notice');
21316 +        $notice = Notice::staticGet($notice_id);
21317 +        if (!$notice) {
21318 +            common_user_error(_('No such notice.'));
21319 +            exit;
21320 +        }
21321 hunk ./lib/deleteaction.php 34
21322 -               $profile = $notice->getProfile();
21323 -               $user_profile = $user->getProfile();
21324 +        $profile = $notice->getProfile();
21325 +        $user_profile = $user->getProfile();
21326 hunk ./lib/deleteaction.php 37
21327 -               if (!common_logged_in()) {
21328 -                       common_user_error(_('Not logged in.'));
21329 -                       exit;
21330 -               } else if ($notice->profile_id != $user_profile->id) {
21331 -                       common_user_error(_('Can\'t delete this notice.'));
21332 -                       exit;
21333 -               }
21334 -       }
21335 +        if (!common_logged_in()) {
21336 +            common_user_error(_('Not logged in.'));
21337 +            exit;
21338 +        } else if ($notice->profile_id != $user_profile->id) {
21339 +            common_user_error(_('Can\'t delete this notice.'));
21340 +            exit;
21341 +        }
21342 +    }
21343 hunk ./lib/deleteaction.php 46
21344 -       function show_top($arr=NULL) {
21345 -               $instr = $this->get_instructions();
21346 -               $output = common_markup_to_html($instr);
21347 -               common_element_start('div', 'instructions');
21348 -               common_raw($output);
21349 -               common_element_end('div');
21350 -       }
21351 +    function show_top($arr=NULL) {
21352 +        $instr = $this->get_instructions();
21353 +        $output = common_markup_to_html($instr);
21354 +        common_element_start('div', 'instructions');
21355 +        common_raw($output);
21356 +        common_element_end('div');
21357 +    }
21358 hunk ./lib/deleteaction.php 54
21359 -       function get_title() {
21360 -               return NULL;
21361 -       }
21362 +    function get_title() {
21363 +        return NULL;
21364 +    }
21365 hunk ./lib/deleteaction.php 58
21366 -       function show_header() {
21367 -               return;
21368 -       }
21369 +    function show_header() {
21370 +        return;
21371 +    }
21372 hunk ./lib/facebookaction.php 13
21373 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
21374 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
21375 hunk ./lib/facebookaction.php 17
21376 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
21377 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
21378 hunk ./lib/facebookaction.php 26
21379 -       function handle($args) {
21380 -               parent::handle($args);
21381 -       }
21382 +    function handle($args) {
21383 +        parent::handle($args);
21384 +    }
21385 hunk ./lib/facebookaction.php 30
21386 -       function get_facebook() {
21387 -               $apikey = common_config('facebook', 'apikey');
21388 -               $secret = common_config('facebook', 'secret');
21389 -               return new Facebook($apikey, $secret);
21390 -       }
21391 +    function get_facebook() {
21392 +        $apikey = common_config('facebook', 'apikey');
21393 +        $secret = common_config('facebook', 'secret');
21394 +        return new Facebook($apikey, $secret);
21395 +    }
21396 hunk ./lib/facebookaction.php 36
21397 -       function update_profile_box($facebook, $fbuid, $user) {
21398 +    function update_profile_box($facebook, $fbuid, $user) {
21399 hunk ./lib/facebookaction.php 38
21400 -               $notice = $user->getCurrentNotice();
21401 +        $notice = $user->getCurrentNotice();
21402 hunk ./lib/facebookaction.php 40
21403 -               # Need to include inline CSS for styling the Profile box
21404 +        # Need to include inline CSS for styling the Profile box
21405 hunk ./lib/facebookaction.php 42
21406 -               $style = '<style>
21407 -               #notices {
21408 -               clear: both;
21409 -               margin: 0 auto;
21410 -               padding: 0;
21411 -               list-style-type: none;
21412 -               width: 600px;
21413 -               border-top: 1px solid #dec5b5;
21414 -               }
21415 -               #notices a:hover {
21416 -               text-decoration: underline;
21417 -               }
21418 -               .notice_single {
21419 -               clear: both;
21420 -               display: block;
21421 -               margin: 0;
21422 -               padding: 5px 5px 5px 0;
21423 -               min-height: 48px;
21424 -               font-family: Georgia, "Times New Roman", Times, serif;
21425 -               font-size: 13px;
21426 -               line-height: 16px;
21427 -               border-bottom: 1px solid #dec5b5;
21428 -               background-color:#FCFFF5;
21429 -               opacity:1;
21430 -               }
21431 -               .notice_single:hover {
21432 -               background-color: #f7ebcc;
21433 -               }
21434 -               .notice_single p {
21435 -               display: inline;
21436 -               margin: 0;
21437 -               padding: 0;
21438 -               }
21439 -               </style>';
21440 +        $style = '<style>
21441 +        #notices {
21442 +        clear: both;
21443 +        margin: 0 auto;
21444 +        padding: 0;
21445 +        list-style-type: none;
21446 +        width: 600px;
21447 +        border-top: 1px solid #dec5b5;
21448 +        }
21449 +        #notices a:hover {
21450 +        text-decoration: underline;
21451 +        }
21452 +        .notice_single {
21453 +        clear: both;
21454 +        display: block;
21455 +        margin: 0;
21456 +        padding: 5px 5px 5px 0;
21457 +        min-height: 48px;
21458 +        font-family: Georgia, "Times New Roman", Times, serif;
21459 +        font-size: 13px;
21460 +        line-height: 16px;
21461 +        border-bottom: 1px solid #dec5b5;
21462 +        background-color:#FCFFF5;
21463 +        opacity:1;
21464 +        }
21465 +        .notice_single:hover {
21466 +        background-color: #f7ebcc;
21467 +        }
21468 +        .notice_single p {
21469 +        display: inline;
21470 +        margin: 0;
21471 +        padding: 0;
21472 +        }
21473 +        </style>';
21474 hunk ./lib/facebookaction.php 77
21475 -               $html = $this->render_notice($notice);
21476 +        $html = $this->render_notice($notice);
21477 hunk ./lib/facebookaction.php 79
21478 -               $fbml = "<fb:wide>$content $html</fb:wide>";
21479 -               $fbml .= "<fb:narrow>$content $html</fb:narrow>";
21480 +        $fbml = "<fb:wide>$content $html</fb:wide>";
21481 +        $fbml .= "<fb:narrow>$content $html</fb:narrow>";
21482 hunk ./lib/facebookaction.php 82
21483 -               $fbml_main = "<fb:narrow>$content $html</fb:narrow>";
21484 +        $fbml_main = "<fb:narrow>$content $html</fb:narrow>";
21485 hunk ./lib/facebookaction.php 84
21486 -               $facebook->api_client->profile_setFBML(NULL, $fbuid, $fbml, NULL, NULL, $fbml_main);
21487 -       }
21488 +        $facebook->api_client->profile_setFBML(NULL, $fbuid, $fbml, NULL, NULL, $fbml_main);
21489 +    }
21490 hunk ./lib/facebookaction.php 87
21491 -       # Display methods
21492 +    # Display methods
21493 hunk ./lib/facebookaction.php 89
21494 -       function show_header($selected ='Home') {
21495 +    function show_header($selected ='Home') {
21496 hunk ./lib/facebookaction.php 91
21497 -               # Add a timestamp to the CSS file so Facebook cache wont ignore our changes
21498 -               $ts = filemtime(theme_file('facebookapp.css'));
21499 -               $cssurl = theme_path('facebookapp.css') . "?ts=$ts";
21500 +        # Add a timestamp to the CSS file so Facebook cache wont ignore our changes
21501 +        $ts = filemtime(theme_file('facebookapp.css'));
21502 +        $cssurl = theme_path('facebookapp.css') . "?ts=$ts";
21503 hunk ./lib/facebookaction.php 95
21504 -               $header = '<link rel="stylesheet" type="text/css" href="'. $cssurl . '" />';
21505 -               # $header .='<script src="" ></script>';
21506 -               $header .= '<fb:dashboard/>';
21507 +         $header = '<link rel="stylesheet" type="text/css" href="'. $cssurl . '" />';
21508 +         # $header .='<script src="" ></script>';
21509 +          $header .= '<fb:dashboard/>';
21510 hunk ./lib/facebookaction.php 99
21511 -               $header .=
21512 -                       '<fb:tabs>'
21513 -                       .'<fb:tab-item title="Home" href="index.php" selected="' . ($selected == 'Home') .'" />'
21514 -                       .'<fb:tab-item title="Invite Friends"  href="invite.php" selected="' . ($selected == 'Invite') . '" />'
21515 -                       .'<fb:tab-item title="Settings"  href="settings.php" selected="' . ($selected == 'Settings') . '" />'
21516 -                       .'</fb:tabs>';
21517 -               $header .= '<div id="main_body">';
21518 +          $header .=
21519 +            '<fb:tabs>'
21520 +            .'<fb:tab-item title="Home" href="index.php" selected="' . ($selected == 'Home') .'" />'
21521 +            .'<fb:tab-item title="Invite Friends"  href="invite.php" selected="' . ($selected == 'Invite') . '" />'
21522 +            .'<fb:tab-item title="Settings"     href="settings.php" selected="' . ($selected == 'Settings') . '" />'
21523 +            .'</fb:tabs>';
21524 +          $header .= '<div id="main_body">';
21525 hunk ./lib/facebookaction.php 107
21526 -         echo $header;
21527 +      echo $header;
21528 hunk ./lib/facebookaction.php 109
21529 -       }
21530 +    }
21531 hunk ./lib/facebookaction.php 111
21532 -       function show_footer() {
21533 -         $footer = '</div>';
21534 -         echo $footer;
21535 -       }
21536 +    function show_footer() {
21537 +      $footer = '</div>';
21538 +      echo $footer;
21539 +    }
21540 hunk ./lib/facebookaction.php 116
21541 -       function show_login_form() {
21542 +    function show_login_form() {
21543 hunk ./lib/facebookaction.php 118
21544 -               $loginform =
21545 -                       ' <h2>To add the Identi.ca application, you need to log into your Identi.ca account.</h2>'
21546 -                       .'<a href="http://identi.ca/">'
21547 -                       .'      <img src="http://theme.identi.ca/identica/logo.png" alt="Identi.ca" id="logo"/>'
21548 -                       .'</a>'
21549 -                       .'<h1 class="pagetitle">Login</h1>'
21550 -                       .'<div class="instructions">'
21551 -                       .'      <p>Login with your username and password. Don\'t have a username yet?'
21552 -                       .'        <a href="http://identi.ca/main/register">Register</a> a new account.'
21553 -                       .'      </p>'
21554 -                       .'</div>'
21555 -                       .'<div id="content">'
21556 -                       .'      <form method="post" id="login">'
21557 -                       .'        <p>'
21558 -                       .'              <label for="nickname">Nickname</label>'
21559 -                       .'              <input name="nickname" type="text" class="input_text" id="nickname"/>'
21560 -                       .'        </p>'
21561 -                       .'        <p>'
21562 -                       .'                <label for="password">Password</label>'
21563 -                       .'              <input name="password" type="password" class="password" id="password"/>'
21564 -                       .'        </p>'
21565 -                       .'        <p>'
21566 -                       .'              <input type="submit" id="submit" name="submit" class="submit" value="Login"/>'
21567 -                       .'        </p>'
21568 -                       .'      </form>'
21569 -                       .'      <p>'
21570 -                       .'        <a href="http://identi.ca/main/recoverpassword">Lost or forgotten password?</a>'
21571 -                       .'      </p>'
21572 -                       .'</div';
21573 +        $loginform =
21574 +            ' <h2>To add the Identi.ca application, you need to log into your Identi.ca account.</h2>'
21575 +            .'<a href="http://identi.ca/">'
21576 +            .'    <img src="http://theme.identi.ca/identica/logo.png" alt="Identi.ca" id="logo"/>'
21577 +            .'</a>'
21578 +            .'<h1 class="pagetitle">Login</h1>'
21579 +            .'<div class="instructions">'
21580 +            .'    <p>Login with your username and password. Don\'t have a username yet?'
21581 +            .'      <a href="http://identi.ca/main/register">Register</a> a new account.'
21582 +            .'    </p>'
21583 +            .'</div>'
21584 +            .'<div id="content">'
21585 +            .'    <form method="post" id="login">'
21586 +            .'      <p>'
21587 +            .'        <label for="nickname">Nickname</label>'
21588 +            .'        <input name="nickname" type="text" class="input_text" id="nickname"/>'
21589 +            .'      </p>'
21590 +            .'      <p>'
21591 +            .'          <label for="password">Password</label>'
21592 +            .'        <input name="password" type="password" class="password" id="password"/>'
21593 +            .'      </p>'
21594 +            .'      <p>'
21595 +            .'        <input type="submit" id="submit" name="submit" class="submit" value="Login"/>'
21596 +            .'      </p>'
21597 +            .'    </form>'
21598 +            .'    <p>'
21599 +            .'      <a href="http://identi.ca/main/recoverpassword">Lost or forgotten password?</a>'
21600 +            .'    </p>'
21601 +            .'</div';
21602 hunk ./lib/facebookaction.php 148
21603 -                       echo $loginform;
21604 -       }
21605 +            echo $loginform;
21606 +    }
21607 hunk ./lib/facebookaction.php 151
21608 -       function render_notice($notice) {
21609 +    function render_notice($notice) {
21610 hunk ./lib/facebookaction.php 153
21611 -               global $config;
21612 +        global $config;
21613 hunk ./lib/facebookaction.php 155
21614 -               $profile = $notice->getProfile();
21615 -               $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
21616 +        $profile = $notice->getProfile();
21617 +        $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
21618 hunk ./lib/facebookaction.php 158
21619 -               $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
21620 +        $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
21621 hunk ./lib/facebookaction.php 160
21622 -               # XXX: we need to figure this out better. Is this right?
21623 -               if (strcmp($notice->uri, $noticeurl) != 0 && preg_match('/^http/', $notice->uri)) {
21624 -                       $noticeurl = $notice->uri;
21625 -               }
21626 +        # XXX: we need to figure this out better. Is this right?
21627 +        if (strcmp($notice->uri, $noticeurl) != 0 && preg_match('/^http/', $notice->uri)) {
21628 +            $noticeurl = $notice->uri;
21629 +        }
21630 hunk ./lib/facebookaction.php 165
21631 -               $html =
21632 -               '<li class="notice_single" id="' . $notice->id . '">'
21633 -               .'<a href="' . $profile->profileurl . '">'
21634 -               .'<img src="';
21635 +        $html =
21636 +        '<li class="notice_single" id="' . $notice->id . '">'
21637 +        .'<a href="' . $profile->profileurl . '">'
21638 +        .'<img src="';
21639 hunk ./lib/facebookaction.php 170
21640 -               if ($avatar) {
21641 -                       $html .= common_avatar_display_url($avatar);
21642 -               } else {
21643 -                       $html .= common_default_avatar(AVATAR_STREAM_SIZE);
21644 -               }
21645 +        if ($avatar) {
21646 +            $html .= common_avatar_display_url($avatar);
21647 +        } else {
21648 +            $html .= common_default_avatar(AVATAR_STREAM_SIZE);
21649 +        }
21650 hunk ./lib/facebookaction.php 176
21651 -               $html .=
21652 -               '" class="avatar stream" width="'
21653 -               . AVATAR_STREAM_SIZE . '" height="' . AVATAR_STREAM_SIZE .'"'
21654 -               .' alt="';
21655 +        $html .=
21656 +        '" class="avatar stream" width="'
21657 +        . AVATAR_STREAM_SIZE . '" height="' . AVATAR_STREAM_SIZE .'"'
21658 +        .' alt="';
21659 hunk ./lib/facebookaction.php 181
21660 -               if ($profile->fullname) {
21661 -                       $html .= $profile->fullname;
21662 -               } else {
21663 -                       $html .= $profile->nickname;
21664 -               }
21665 +        if ($profile->fullname) {
21666 +            $html .= $profile->fullname;
21667 +        } else {
21668 +            $html .= $profile->nickname;
21669 +        }
21670 hunk ./lib/facebookaction.php 187
21671 -               $html .=
21672 -               '"></a>'
21673 -               .'<a href="' .  $profile->profileurl . '" class="nickname">' . $profile->nickname . '</a>'
21674 -               .'<p class="content">' . $notice->rendered . '</p>'
21675 -               .'<p class="time">'
21676 -               .'<a class="permalink" href="' . $noticeurl . '" title="' . common_exact_date($notice->created) . '">' . common_date_string($notice->created) . '</a>';
21677 +        $html .=
21678 +        '"></a>'
21679 +        .'<a href="' .    $profile->profileurl . '" class="nickname">' . $profile->nickname . '</a>'
21680 +        .'<p class="content">' . $notice->rendered . '</p>'
21681 +        .'<p class="time">'
21682 +        .'<a class="permalink" href="' . $noticeurl . '" title="' . common_exact_date($notice->created) . '">' . common_date_string($notice->created) . '</a>';
21683 hunk ./lib/facebookaction.php 194
21684 -               if ($notice->source) {
21685 -                       $html .= _(' from ');
21686 -                       $html .= $this->source_link($notice->source);
21687 -               }
21688 +        if ($notice->source) {
21689 +            $html .= _(' from ');
21690 +            $html .= $this->source_link($notice->source);
21691 +        }
21692 hunk ./lib/facebookaction.php 199
21693 -               if ($notice->reply_to) {
21694 -                       $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
21695 -                       $html .=
21696 -                       ' (<a class="inreplyto" href="' . $replyurl . '">' . _('in reply to...') . ')';
21697 -               }
21698 +        if ($notice->reply_to) {
21699 +            $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
21700 +            $html .=
21701 +            ' (<a class="inreplyto" href="' . $replyurl . '">' . _('in reply to...') . ')';
21702 +        }
21703 hunk ./lib/facebookaction.php 205
21704 -               $html .= '</p></li>';
21705 +        $html .= '</p></li>';
21706 hunk ./lib/facebookaction.php 207
21707 -               return $html;
21708 -       }
21709 +        return $html;
21710 +    }
21711 hunk ./lib/facebookaction.php 210
21712 -       function source_link($source) {
21713 -               $source_name = _($source);
21714 +    function source_link($source) {
21715 +        $source_name = _($source);
21716 hunk ./lib/facebookaction.php 213
21717 -               $html = '<span class="noticesource">';
21718 +        $html = '<span class="noticesource">';
21719 hunk ./lib/facebookaction.php 215
21720 -               switch ($source) {
21721 -                case 'web':
21722 -                case 'xmpp':
21723 -                case 'mail':
21724 -                case 'omb':
21725 -                case 'api':
21726 -                       $html .= $source_name;
21727 -                       break;
21728 -                default:
21729 -                       $ns = Notice_source::staticGet($source);
21730 -                       if ($ns) {
21731 -                               $html .= '<a href="' . $ns->url . '">' . $ns->name . '</a>';
21732 -                       } else {
21733 -                               $html .= $source_name;
21734 -                       }
21735 -                       break;
21736 -               }
21737 +        switch ($source) {
21738 +         case 'web':
21739 +         case 'xmpp':
21740 +         case 'mail':
21741 +         case 'omb':
21742 +         case 'api':
21743 +            $html .= $source_name;
21744 +            break;
21745 +         default:
21746 +            $ns = Notice_source::staticGet($source);
21747 +            if ($ns) {
21748 +                $html .= '<a href="' . $ns->url . '">' . $ns->name . '</a>';
21749 +            } else {
21750 +                $html .= $source_name;
21751 +            }
21752 +            break;
21753 +        }
21754 hunk ./lib/facebookaction.php 233
21755 -               $html .= '</span>';
21756 +        $html .= '</span>';
21757 hunk ./lib/facebookaction.php 235
21758 -               return $html;
21759 -       }
21760 +        return $html;
21761 +    }
21762 hunk ./lib/facebookaction.php 238
21763 -       function pagination($have_before, $have_after, $page, $fbaction, $args=NULL) {
21764 +    function pagination($have_before, $have_after, $page, $fbaction, $args=NULL) {
21765 hunk ./lib/facebookaction.php 240
21766 -               $html = '';
21767 +        $html = '';
21768 hunk ./lib/facebookaction.php 242
21769 -               if ($have_before || $have_after) {
21770 -                       $html = '<div id="pagination">';
21771 -                       $html .'<ul id="nav_pagination">';
21772 -               }
21773 +        if ($have_before || $have_after) {
21774 +            $html = '<div id="pagination">';
21775 +            $html .'<ul id="nav_pagination">';
21776 +        }
21777 hunk ./lib/facebookaction.php 247
21778 -               if ($have_before) {
21779 -                       $pargs = array('page' => $page-1);
21780 -                       $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
21781 -                       $html .= '<li class="before">';
21782 -                       $html .'<a href="' . $this->pagination_url($fbaction, $newargs) . '">' . _('« After') . '</a>';
21783 -                       $html .'</li>';
21784 -               }
21785 +        if ($have_before) {
21786 +            $pargs = array('page' => $page-1);
21787 +            $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
21788 +            $html .= '<li class="before">';
21789 +            $html .'<a href="' . $this->pagination_url($fbaction, $newargs) . '">' . _('« After') . '</a>';
21790 +            $html .'</li>';
21791 +        }
21792 hunk ./lib/facebookaction.php 255
21793 -               if ($have_after) {
21794 -                       $pargs = array('page' => $page+1);
21795 -                       $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
21796 -                       $html .= '<li class="after">';
21797 -                       $html .'<a href="' . $this->pagination_url($fbaction, $newargs) . '">' . _('Before Â»') . '</a>';
21798 -                       $html .'</li>';
21799 -               }
21800 +        if ($have_after) {
21801 +            $pargs = array('page' => $page+1);
21802 +            $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
21803 +            $html .= '<li class="after">';
21804 +            $html .'<a href="' . $this->pagination_url($fbaction, $newargs) . '">' . _('Before Â»') . '</a>';
21805 +            $html .'</li>';
21806 +        }
21807 hunk ./lib/facebookaction.php 263
21808 -               if ($have_before || $have_after) {
21809 -                       $html .= '<ul>';
21810 -                       $html .'<div>';
21811 -               }
21812 -       }
21813 +        if ($have_before || $have_after) {
21814 +            $html .= '<ul>';
21815 +            $html .'<div>';
21816 +        }
21817 +    }
21818 hunk ./lib/facebookaction.php 269
21819 -       function pagination_url($fbaction, $args=NULL) {
21820 -               global $config;
21821 +    function pagination_url($fbaction, $args=NULL) {
21822 +        global $config;
21823 hunk ./lib/facebookaction.php 272
21824 -               $extra = '';
21825 +        $extra = '';
21826 hunk ./lib/facebookaction.php 274
21827 -               if ($args) {
21828 -                       foreach ($args as $key => $value) {
21829 -                               $extra .= "&${key}=${value}";
21830 -                       }
21831 -               }
21832 +        if ($args) {
21833 +            foreach ($args as $key => $value) {
21834 +                $extra .= "&${key}=${value}";
21835 +            }
21836 +        }
21837 hunk ./lib/facebookaction.php 280
21838 -               return "$fbaction?${extra}";
21839 -       }
21840 +        return "$fbaction?${extra}";
21841 +    }
21842 hunk ./lib/oauthstore.php 26
21843 -       # We keep a record of who's contacted us
21844 +    # We keep a record of who's contacted us
21845 hunk ./lib/oauthstore.php 28
21846 -       function lookup_consumer($consumer_key) {
21847 -               $con = Consumer::staticGet('consumer_key', $consumer_key);
21848 -               if (!$con) {
21849 -                       $con = new Consumer();
21850 -                       $con->consumer_key = $consumer_key;
21851 -                       $con->seed = common_good_rand(16);
21852 -                       $con->created = DB_DataObject_Cast::dateTime();
21853 -                       if (!$con->insert()) {
21854 -                               return NULL;
21855 -                       }
21856 -               }
21857 -               return new OAuthConsumer($con->consumer_key, '');
21858 -       }
21859 +    function lookup_consumer($consumer_key) {
21860 +        $con = Consumer::staticGet('consumer_key', $consumer_key);
21861 +        if (!$con) {
21862 +            $con = new Consumer();
21863 +            $con->consumer_key = $consumer_key;
21864 +            $con->seed = common_good_rand(16);
21865 +            $con->created = DB_DataObject_Cast::dateTime();
21866 +            if (!$con->insert()) {
21867 +                return NULL;
21868 +            }
21869 +        }
21870 +        return new OAuthConsumer($con->consumer_key, '');
21871 +    }
21872 hunk ./lib/oauthstore.php 42
21873 -       function lookup_token($consumer, $token_type, $token_key) {
21874 -               $t = new Token();
21875 -               $t->consumer_key = $consumer->key;
21876 -               $t->tok = $token_key;
21877 -               $t->type = ($token_type == 'access') ? 1 : 0;
21878 -               if ($t->find(true)) {
21879 -                       return new OAuthToken($t->tok, $t->secret);
21880 -               } else {
21881 -                       return NULL;
21882 -               }
21883 -       }
21884 +    function lookup_token($consumer, $token_type, $token_key) {
21885 +        $t = new Token();
21886 +        $t->consumer_key = $consumer->key;
21887 +        $t->tok = $token_key;
21888 +        $t->type = ($token_type == 'access') ? 1 : 0;
21889 +        if ($t->find(true)) {
21890 +            return new OAuthToken($t->tok, $t->secret);
21891 +        } else {
21892 +            return NULL;
21893 +        }
21894 +    }
21895 hunk ./lib/oauthstore.php 54
21896 -       function lookup_nonce($consumer, $token, $nonce, $timestamp) {
21897 -               $n = new Nonce();
21898 -               $n->consumer_key = $consumer->key;
21899 -               $n->tok = $token->key;
21900 -               $n->nonce = $nonce;
21901 -               if ($n->find(TRUE)) {
21902 -                       return TRUE;
21903 -               } else {
21904 -                       $n->timestamp = $timestamp;
21905 -                       $n->created = DB_DataObject_Cast::dateTime();
21906 -                       $n->insert();
21907 -                       return FALSE;
21908 -               }
21909 -       }
21910 +    function lookup_nonce($consumer, $token, $nonce, $timestamp) {
21911 +        $n = new Nonce();
21912 +        $n->consumer_key = $consumer->key;
21913 +        $n->tok = $token->key;
21914 +        $n->nonce = $nonce;
21915 +        if ($n->find(TRUE)) {
21916 +            return TRUE;
21917 +        } else {
21918 +            $n->timestamp = $timestamp;
21919 +            $n->created = DB_DataObject_Cast::dateTime();
21920 +            $n->insert();
21921 +            return FALSE;
21922 +        }
21923 +    }
21924 hunk ./lib/oauthstore.php 69
21925 -       function new_request_token($consumer) {
21926 -               $t = new Token();
21927 -               $t->consumer_key = $consumer->key;
21928 -               $t->tok = common_good_rand(16);
21929 -               $t->secret = common_good_rand(16);
21930 -               $t->type = 0; # request
21931 -               $t->state = 0; # unauthorized
21932 -               $t->created = DB_DataObject_Cast::dateTime();
21933 -               if (!$t->insert()) {
21934 -                       return NULL;
21935 -               } else {
21936 -                       return new OAuthToken($t->tok, $t->secret);
21937 -               }
21938 -       }
21939 +    function new_request_token($consumer) {
21940 +        $t = new Token();
21941 +        $t->consumer_key = $consumer->key;
21942 +        $t->tok = common_good_rand(16);
21943 +        $t->secret = common_good_rand(16);
21944 +        $t->type = 0; # request
21945 +        $t->state = 0; # unauthorized
21946 +        $t->created = DB_DataObject_Cast::dateTime();
21947 +        if (!$t->insert()) {
21948 +            return NULL;
21949 +        } else {
21950 +            return new OAuthToken($t->tok, $t->secret);
21951 +        }
21952 +    }
21953 hunk ./lib/oauthstore.php 84
21954 -       # defined in OAuthDataStore, but not implemented anywhere
21955 +    # defined in OAuthDataStore, but not implemented anywhere
21956 hunk ./lib/oauthstore.php 86
21957 -       function fetch_request_token($consumer) {
21958 -               return $this->new_request_token($consumer);
21959 -       }
21960 +    function fetch_request_token($consumer) {
21961 +        return $this->new_request_token($consumer);
21962 +    }
21963 hunk ./lib/oauthstore.php 90
21964 -       function new_access_token($token, $consumer) {
21965 -               common_debug('new_access_token("'.$token->key.'","'.$consumer->key.'")', __FILE__);
21966 -               $rt = new Token();
21967 -               $rt->consumer_key = $consumer->key;
21968 -               $rt->tok = $token->key;
21969 -               $rt->type = 0; # request
21970 -               if ($rt->find(TRUE) && $rt->state == 1) { # authorized
21971 -                       common_debug('request token found.', __FILE__);
21972 -                       $at = new Token();
21973 -                       $at->consumer_key = $consumer->key;
21974 -                       $at->tok = common_good_rand(16);
21975 -                       $at->secret = common_good_rand(16);
21976 -                       $at->type = 1; # access
21977 -                       $at->created = DB_DataObject_Cast::dateTime();
21978 -                       if (!$at->insert()) {
21979 -                               $e = $at->_lastError;
21980 -                               common_debug('access token "'.$at->tok.'" not inserted: "'.$e->message.'"', __FILE__);
21981 -                               return NULL;
21982 -                       } else {
21983 -                               common_debug('access token "'.$at->tok.'" inserted', __FILE__);
21984 -                               # burn the old one
21985 -                               $orig_rt = clone($rt);
21986 -                               $rt->state = 2; # used
21987 -                               if (!$rt->update($orig_rt)) {
21988 -                                       return NULL;
21989 -                               }
21990 -                               common_debug('request token "'.$rt->tok.'" updated', __FILE__);
21991 -                               # Update subscription
21992 -                               # XXX: mixing levels here
21993 -                               $sub = Subscription::staticGet('token', $rt->tok);
21994 -                               if (!$sub) {
21995 -                                       return NULL;
21996 -                               }
21997 -                               common_debug('subscription for request token found', __FILE__);
21998 -                               $orig_sub = clone($sub);
21999 -                               $sub->token = $at->tok;
22000 -                               $sub->secret = $at->secret;
22001 -                               if (!$sub->update($orig_sub)) {
22002 -                                       return NULL;
22003 -                               } else {
22004 -                                       common_debug('subscription updated to use access token', __FILE__);
22005 -                                       return new OAuthToken($at->tok, $at->secret);
22006 -                               }
22007 -                       }
22008 -               } else {
22009 -                       return NULL;
22010 -               }
22011 -       }
22012 +    function new_access_token($token, $consumer) {
22013 +        common_debug('new_access_token("'.$token->key.'","'.$consumer->key.'")', __FILE__);
22014 +        $rt = new Token();
22015 +        $rt->consumer_key = $consumer->key;
22016 +        $rt->tok = $token->key;
22017 +        $rt->type = 0; # request
22018 +        if ($rt->find(TRUE) && $rt->state == 1) { # authorized
22019 +            common_debug('request token found.', __FILE__);
22020 +            $at = new Token();
22021 +            $at->consumer_key = $consumer->key;
22022 +            $at->tok = common_good_rand(16);
22023 +            $at->secret = common_good_rand(16);
22024 +            $at->type = 1; # access
22025 +            $at->created = DB_DataObject_Cast::dateTime();
22026 +            if (!$at->insert()) {
22027 +                $e = $at->_lastError;
22028 +                common_debug('access token "'.$at->tok.'" not inserted: "'.$e->message.'"', __FILE__);
22029 +                return NULL;
22030 +            } else {
22031 +                common_debug('access token "'.$at->tok.'" inserted', __FILE__);
22032 +                # burn the old one
22033 +                $orig_rt = clone($rt);
22034 +                $rt->state = 2; # used
22035 +                if (!$rt->update($orig_rt)) {
22036 +                    return NULL;
22037 +                }
22038 +                common_debug('request token "'.$rt->tok.'" updated', __FILE__);
22039 +                # Update subscription
22040 +                # XXX: mixing levels here
22041 +                $sub = Subscription::staticGet('token', $rt->tok);
22042 +                if (!$sub) {
22043 +                    return NULL;
22044 +                }
22045 +                common_debug('subscription for request token found', __FILE__);
22046 +                $orig_sub = clone($sub);
22047 +                $sub->token = $at->tok;
22048 +                $sub->secret = $at->secret;
22049 +                if (!$sub->update($orig_sub)) {
22050 +                    return NULL;
22051 +                } else {
22052 +                    common_debug('subscription updated to use access token', __FILE__);
22053 +                    return new OAuthToken($at->tok, $at->secret);
22054 +                }
22055 +            }
22056 +        } else {
22057 +            return NULL;
22058 +        }
22059 +    }
22060 hunk ./lib/oauthstore.php 139
22061 -       # defined in OAuthDataStore, but not implemented anywhere
22062 +    # defined in OAuthDataStore, but not implemented anywhere
22063 hunk ./lib/oauthstore.php 141
22064 -       function fetch_access_token($consumer) {
22065 -               return $this->new_access_token($consumer);
22066 -       }
22067 +    function fetch_access_token($consumer) {
22068 +        return $this->new_access_token($consumer);
22069 +    }
22070 hunk ./lib/omb.php 47
22071 -       static $con = NULL;
22072 -       if (!$con) {
22073 -               $con = new OAuthConsumer(common_root_url(), '');
22074 -       }
22075 -       return $con;
22076 +    static $con = NULL;
22077 +    if (!$con) {
22078 +        $con = new OAuthConsumer(common_root_url(), '');
22079 +    }
22080 +    return $con;
22081 hunk ./lib/omb.php 55
22082 -       static $server = null;
22083 -       if (!$server) {
22084 -               $server = new OAuthServer(omb_oauth_datastore());
22085 -               $server->add_signature_method(omb_hmac_sha1());
22086 -       }
22087 -       return $server;
22088 +    static $server = null;
22089 +    if (!$server) {
22090 +        $server = new OAuthServer(omb_oauth_datastore());
22091 +        $server->add_signature_method(omb_hmac_sha1());
22092 +    }
22093 +    return $server;
22094 hunk ./lib/omb.php 64
22095 -       static $store = NULL;
22096 -       if (!$store) {
22097 -               $store = new LaconicaOAuthDataStore();
22098 -       }
22099 -       return $store;
22100 +    static $store = NULL;
22101 +    if (!$store) {
22102 +        $store = new LaconicaOAuthDataStore();
22103 +    }
22104 +    return $store;
22105 hunk ./lib/omb.php 72
22106 -       static $hmac_method = NULL;
22107 -       if (!$hmac_method) {
22108 -               $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
22109 -       }
22110 -       return $hmac_method;
22111 +    static $hmac_method = NULL;
22112 +    if (!$hmac_method) {
22113 +        $hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
22114 +    }
22115 +    return $hmac_method;
22116 hunk ./lib/omb.php 80
22117 -       return $xrd->services(array(omb_service_filter($type)));
22118 +    return $xrd->services(array(omb_service_filter($type)));
22119 hunk ./lib/omb.php 84
22120 -       return create_function('$s',
22121 -                                                  'return omb_match_service($s, \''.$type.'\');');
22122 +    return create_function('$s',
22123 +                           'return omb_match_service($s, \''.$type.'\');');
22124 hunk ./lib/omb.php 89
22125 -       return in_array($type, $service->getTypes());
22126 +    return in_array($type, $service->getTypes());
22127 hunk ./lib/omb.php 93
22128 -       if (!$service) {
22129 -               return NULL;
22130 -       }
22131 -       $uris = $service->getURIs();
22132 -       if (!$uris) {
22133 -               return NULL;
22134 -       }
22135 -       return $uris[0];
22136 +    if (!$service) {
22137 +        return NULL;
22138 +    }
22139 +    $uris = $service->getURIs();
22140 +    if (!$uris) {
22141 +        return NULL;
22142 +    }
22143 +    return $uris[0];
22144 hunk ./lib/omb.php 104
22145 -       if (!$service) {
22146 -               return NULL;
22147 -       }
22148 -       $els = $service->getElements('xrd:LocalID');
22149 -       if (!$els) {
22150 -               return NULL;
22151 -       }
22152 -       $el = $els[0];
22153 -       return $service->parser->content($el);
22154 +    if (!$service) {
22155 +        return NULL;
22156 +    }
22157 +    $els = $service->getElements('xrd:LocalID');
22158 +    if (!$els) {
22159 +        return NULL;
22160 +    }
22161 +    $el = $els[0];
22162 +    return $service->parser->content($el);
22163 hunk ./lib/omb.php 117
22164 -       # First, get remote users subscribed to this profile
22165 -       $rp = new Remote_profile();
22166 +    # First, get remote users subscribed to this profile
22167 +    $rp = new Remote_profile();
22168 hunk ./lib/omb.php 120
22169 -       $rp->query('SELECT postnoticeurl, token, secret ' .
22170 -                          'FROM subscription JOIN remote_profile ' .
22171 -                          'ON subscription.subscriber = remote_profile.id ' .
22172 -                          'WHERE subscription.subscribed = ' . $notice->profile_id . ' ');
22173 +    $rp->query('SELECT postnoticeurl, token, secret ' .
22174 +               'FROM subscription JOIN remote_profile ' .
22175 +               'ON subscription.subscriber = remote_profile.id ' .
22176 +               'WHERE subscription.subscribed = ' . $notice->profile_id . ' ');
22177 hunk ./lib/omb.php 125
22178 -       $posted = array();
22179 +    $posted = array();
22180 hunk ./lib/omb.php 127
22181 -       while ($rp->fetch()) {
22182 -               if (!$posted[$rp->postnoticeurl]) {
22183 -                       common_log(LOG_DEBUG, 'Posting to ' . $rp->postnoticeurl);
22184 -                       if (omb_post_notice_keys($notice, $rp->postnoticeurl, $rp->token, $rp->secret)) {
22185 -                               common_log(LOG_DEBUG, 'Finished to ' . $rp->postnoticeurl);
22186 -                               $posted[$rp->postnoticeurl] = TRUE;
22187 -                       } else {
22188 -                               common_log(LOG_DEBUG, 'Failed posting to ' . $rp->postnoticeurl);
22189 -                       }
22190 -               }
22191 -       }
22192 +    while ($rp->fetch()) {
22193 +        if (!$posted[$rp->postnoticeurl]) {
22194 +            common_log(LOG_DEBUG, 'Posting to ' . $rp->postnoticeurl);
22195 +            if (omb_post_notice_keys($notice, $rp->postnoticeurl, $rp->token, $rp->secret)) {
22196 +                common_log(LOG_DEBUG, 'Finished to ' . $rp->postnoticeurl);
22197 +                $posted[$rp->postnoticeurl] = TRUE;
22198 +            } else {
22199 +                common_log(LOG_DEBUG, 'Failed posting to ' . $rp->postnoticeurl);
22200 +            }
22201 +        }
22202 +    }
22203 hunk ./lib/omb.php 139
22204 -       $rp->free();
22205 -       unset($rp);
22206 +    $rp->free();
22207 +    unset($rp);
22208 hunk ./lib/omb.php 142
22209 -       return true;
22210 +    return true;
22211 hunk ./lib/omb.php 146
22212 -       return omb_post_notice_keys($notice, $remote_profile->postnoticeurl, $subscription->token, $subscription->secret);
22213 +    return omb_post_notice_keys($notice, $remote_profile->postnoticeurl, $subscription->token, $subscription->secret);
22214 hunk ./lib/omb.php 151
22215 -       common_debug('Posting notice ' . $notice->id . ' to ' . $postnoticeurl, __FILE__);
22216 +    common_debug('Posting notice ' . $notice->id . ' to ' . $postnoticeurl, __FILE__);
22217 hunk ./lib/omb.php 153
22218 -       $user = User::staticGet('id', $notice->profile_id);
22219 +    $user = User::staticGet('id', $notice->profile_id);
22220 hunk ./lib/omb.php 155
22221 -       if (!$user) {
22222 -               common_debug('Failed to get user for notice ' . $notice->id . ', profile = ' . $notice->profile_id, __FILE__);
22223 -               return false;
22224 -       }
22225 +    if (!$user) {
22226 +        common_debug('Failed to get user for notice ' . $notice->id . ', profile = ' . $notice->profile_id, __FILE__);
22227 +        return false;
22228 +    }
22229 hunk ./lib/omb.php 160
22230 -       $con = omb_oauth_consumer();
22231 +    $con = omb_oauth_consumer();
22232 hunk ./lib/omb.php 162
22233 -       $token = new OAuthToken($tk, $secret);
22234 +    $token = new OAuthToken($tk, $secret);
22235 hunk ./lib/omb.php 164
22236 -       $url = $postnoticeurl;
22237 -       $parsed = parse_url($url);
22238 -       $params = array();
22239 -       parse_str($parsed['query'], $params);
22240 +    $url = $postnoticeurl;
22241 +    $parsed = parse_url($url);
22242 +    $params = array();
22243 +    parse_str($parsed['query'], $params);
22244 hunk ./lib/omb.php 169
22245 -       $req = OAuthRequest::from_consumer_and_token($con, $token,
22246 -                                                                                                'POST', $url, $params);
22247 +    $req = OAuthRequest::from_consumer_and_token($con, $token,
22248 +                                                 'POST', $url, $params);
22249 hunk ./lib/omb.php 172
22250 -       $req->set_parameter('omb_version', OMB_VERSION_01);
22251 -       $req->set_parameter('omb_listenee', $user->uri);
22252 -       $req->set_parameter('omb_notice', $notice->uri);
22253 -       $req->set_parameter('omb_notice_content', $notice->content);
22254 -       $req->set_parameter('omb_notice_url', common_local_url('shownotice',
22255 -                                                                                                                  array('notice' =>
22256 -                                                                                                                                $notice->id)));
22257 -       $req->set_parameter('omb_notice_license', common_config('license', 'url'));
22258 +    $req->set_parameter('omb_version', OMB_VERSION_01);
22259 +    $req->set_parameter('omb_listenee', $user->uri);
22260 +    $req->set_parameter('omb_notice', $notice->uri);
22261 +    $req->set_parameter('omb_notice_content', $notice->content);
22262 +    $req->set_parameter('omb_notice_url', common_local_url('shownotice',
22263 +                                                           array('notice' =>
22264 +                                                                 $notice->id)));
22265 +    $req->set_parameter('omb_notice_license', common_config('license', 'url'));
22266 hunk ./lib/omb.php 181
22267 -       $user->free();
22268 -       unset($user);
22269 +    $user->free();
22270 +    unset($user);
22271 hunk ./lib/omb.php 184
22272 -       $req->sign_request(omb_hmac_sha1(), $con, $token);
22273 +    $req->sign_request(omb_hmac_sha1(), $con, $token);
22274 hunk ./lib/omb.php 186
22275 -       # We re-use this tool's fetcher, since it's pretty good
22276 +    # We re-use this tool's fetcher, since it's pretty good
22277 hunk ./lib/omb.php 188
22278 -       $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
22279 +    $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
22280 hunk ./lib/omb.php 190
22281 -       if (!$fetcher) {
22282 -               common_log(LOG_WARNING, 'Failed to initialize Yadis fetcher.', __FILE__);
22283 -               return false;
22284 -       }
22285 +    if (!$fetcher) {
22286 +        common_log(LOG_WARNING, 'Failed to initialize Yadis fetcher.', __FILE__);
22287 +        return false;
22288 +    }
22289 hunk ./lib/omb.php 195
22290 -       $result = $fetcher->post($req->get_normalized_http_url(),
22291 -                                                        $req->to_postdata(),
22292 +    $result = $fetcher->post($req->get_normalized_http_url(),
22293 +                             $req->to_postdata(),
22294 hunk ./lib/omb.php 199
22295 -       common_debug('Got HTTP result "'.print_r($result,TRUE).'"', __FILE__);
22296 +    common_debug('Got HTTP result "'.print_r($result,TRUE).'"', __FILE__);
22297 hunk ./lib/omb.php 201
22298 -       if ($result->status == 403) { # not authorized, don't send again
22299 -               common_debug('403 result, deleting subscription', __FILE__);
22300 -               # FIXME: figure out how to delete this
22301 -               # $subscription->delete();
22302 -               return false;
22303 -       } else if ($result->status != 200) {
22304 -               common_debug('Error status '.$result->status, __FILE__);
22305 -               return false;
22306 -       } else { # success!
22307 -               parse_str($result->body, $return);
22308 -               if ($return['omb_version'] == OMB_VERSION_01) {
22309 -                       return true;
22310 -               } else {
22311 -                       return false;
22312 -               }
22313 -       }
22314 +    if ($result->status == 403) { # not authorized, don't send again
22315 +        common_debug('403 result, deleting subscription', __FILE__);
22316 +        # FIXME: figure out how to delete this
22317 +        # $subscription->delete();
22318 +        return false;
22319 +    } else if ($result->status != 200) {
22320 +        common_debug('Error status '.$result->status, __FILE__);
22321 +        return false;
22322 +    } else { # success!
22323 +        parse_str($result->body, $return);
22324 +        if ($return['omb_version'] == OMB_VERSION_01) {
22325 +            return true;
22326 +        } else {
22327 +            return false;
22328 +        }
22329 +    }
22330 hunk ./lib/omb.php 220
22331 -       # First, get remote users subscribed to this profile
22332 -       # XXX: use a join here rather than looping through results
22333 -       $sub = new Subscription();
22334 -       $sub->subscribed = $profile->id;
22335 -       if ($sub->find()) {
22336 -               $updated = array();
22337 -               while ($sub->fetch()) {
22338 -                       $rp = Remote_profile::staticGet('id', $sub->subscriber);
22339 -                       if ($rp) {
22340 -                               if (!$updated[$rp->updateprofileurl]) {
22341 -                                       if (omb_update_profile($profile, $rp, $sub)) {
22342 -                                               $updated[$rp->updateprofileurl] = TRUE;
22343 -                                       }
22344 -                               }
22345 -                       }
22346 -               }
22347 -       }
22348 +    # First, get remote users subscribed to this profile
22349 +    # XXX: use a join here rather than looping through results
22350 +    $sub = new Subscription();
22351 +    $sub->subscribed = $profile->id;
22352 +    if ($sub->find()) {
22353 +        $updated = array();
22354 +        while ($sub->fetch()) {
22355 +            $rp = Remote_profile::staticGet('id', $sub->subscriber);
22356 +            if ($rp) {
22357 +                if (!$updated[$rp->updateprofileurl]) {
22358 +                    if (omb_update_profile($profile, $rp, $sub)) {
22359 +                        $updated[$rp->updateprofileurl] = TRUE;
22360 +                    }
22361 +                }
22362 +            }
22363 +        }
22364 +    }
22365 hunk ./lib/omb.php 240
22366 -       global $config; # for license URL
22367 -       $user = User::staticGet($profile->id);
22368 -       $con = omb_oauth_consumer();
22369 -       $token = new OAuthToken($subscription->token, $subscription->secret);
22370 -       $url = $remote_profile->updateprofileurl;
22371 -       $parsed = parse_url($url);
22372 -       $params = array();
22373 -       parse_str($parsed['query'], $params);
22374 -       $req = OAuthRequest::from_consumer_and_token($con, $token,
22375 -                                                                                                "POST", $url, $params);
22376 -       $req->set_parameter('omb_version', OMB_VERSION_01);
22377 -       $req->set_parameter('omb_listenee', $user->uri);
22378 -       $req->set_parameter('omb_listenee_profile', common_profile_url($profile->nickname));
22379 -       $req->set_parameter('omb_listenee_nickname', $profile->nickname);
22380 +    global $config; # for license URL
22381 +    $user = User::staticGet($profile->id);
22382 +    $con = omb_oauth_consumer();
22383 +    $token = new OAuthToken($subscription->token, $subscription->secret);
22384 +    $url = $remote_profile->updateprofileurl;
22385 +    $parsed = parse_url($url);
22386 +    $params = array();
22387 +    parse_str($parsed['query'], $params);
22388 +    $req = OAuthRequest::from_consumer_and_token($con, $token,
22389 +                                                 "POST", $url, $params);
22390 +    $req->set_parameter('omb_version', OMB_VERSION_01);
22391 +    $req->set_parameter('omb_listenee', $user->uri);
22392 +    $req->set_parameter('omb_listenee_profile', common_profile_url($profile->nickname));
22393 +    $req->set_parameter('omb_listenee_nickname', $profile->nickname);
22394 hunk ./lib/omb.php 255
22395 -       # We use blanks to force emptying any existing values in these optional fields
22396 +    # We use blanks to force emptying any existing values in these optional fields
22397 hunk ./lib/omb.php 257
22398 -       $req->set_parameter('omb_listenee_fullname',
22399 -                                               ($profile->fullname) ? $profile->fullname : '');
22400 -       $req->set_parameter('omb_listenee_homepage',
22401 -                                               ($profile->homepage) ? $profile->homepage : '');
22402 -       $req->set_parameter('omb_listenee_bio',
22403 -                                               ($profile->bio) ? $profile->bio : '');
22404 -       $req->set_parameter('omb_listenee_location',
22405 -                                               ($profile->location) ? $profile->location : '');
22406 +    $req->set_parameter('omb_listenee_fullname',
22407 +                        ($profile->fullname) ? $profile->fullname : '');
22408 +    $req->set_parameter('omb_listenee_homepage',
22409 +                        ($profile->homepage) ? $profile->homepage : '');
22410 +    $req->set_parameter('omb_listenee_bio',
22411 +                        ($profile->bio) ? $profile->bio : '');
22412 +    $req->set_parameter('omb_listenee_location',
22413 +                        ($profile->location) ? $profile->location : '');
22414 hunk ./lib/omb.php 266
22415 -       $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
22416 -       $req->set_parameter('omb_listenee_avatar',
22417 -                                               ($avatar) ? $avatar->url : '');
22418 +    $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
22419 +    $req->set_parameter('omb_listenee_avatar',
22420 +                        ($avatar) ? $avatar->url : '');
22421 hunk ./lib/omb.php 270
22422 -       $req->sign_request(omb_hmac_sha1(), $con, $token);
22423 +    $req->sign_request(omb_hmac_sha1(), $con, $token);
22424 hunk ./lib/omb.php 272
22425 -       # We re-use this tool's fetcher, since it's pretty good
22426 +    # We re-use this tool's fetcher, since it's pretty good
22427 hunk ./lib/omb.php 274
22428 -       $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
22429 +    $fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
22430 hunk ./lib/omb.php 276
22431 -       common_debug('request URL = '.$req->get_normalized_http_url(), __FILE__);
22432 -       common_debug('postdata = '.$req->to_postdata(), __FILE__);
22433 -       $result = $fetcher->post($req->get_normalized_http_url(),
22434 -                                                        $req->to_postdata(),
22435 +    common_debug('request URL = '.$req->get_normalized_http_url(), __FILE__);
22436 +    common_debug('postdata = '.$req->to_postdata(), __FILE__);
22437 +    $result = $fetcher->post($req->get_normalized_http_url(),
22438 +                             $req->to_postdata(),
22439 hunk ./lib/omb.php 282
22440 -       common_debug('Got HTTP result "'.print_r($result,TRUE).'"', __FILE__);
22441 +    common_debug('Got HTTP result "'.print_r($result,TRUE).'"', __FILE__);
22442 hunk ./lib/omb.php 284
22443 -       if ($result->status == 403) { # not authorized, don't send again
22444 -               common_debug('403 result, deleting subscription', __FILE__);
22445 -               $subscription->delete();
22446 -               return false;
22447 -       } else if ($result->status != 200) {
22448 -               common_debug('Error status '.$result->status, __FILE__);
22449 -               return false;
22450 -       } else { # success!
22451 -               parse_str($result->body, $return);
22452 -               if ($return['omb_version'] == OMB_VERSION_01) {
22453 -                       return true;
22454 -               } else {
22455 -                       return false;
22456 -               }
22457 -       }
22458 +    if ($result->status == 403) { # not authorized, don't send again
22459 +        common_debug('403 result, deleting subscription', __FILE__);
22460 +        $subscription->delete();
22461 +        return false;
22462 +    } else if ($result->status != 200) {
22463 +        common_debug('Error status '.$result->status, __FILE__);
22464 +        return false;
22465 +    } else { # success!
22466 +        parse_str($result->body, $return);
22467 +        if ($return['omb_version'] == OMB_VERSION_01) {
22468 +            return true;
22469 +        } else {
22470 +            return false;
22471 +        }
22472 +    }
22473 hunk ./lib/openid.php 36
22474 -       if (!$store) {
22475 -               # Can't be called statically
22476 -               $user = new User();
22477 -               $conn = $user->getDatabaseConnection();
22478 -               $store = new Auth_OpenID_MySQLStore($conn);
22479 -       }
22480 -       return $store;
22481 +    if (!$store) {
22482 +        # Can't be called statically
22483 +        $user = new User();
22484 +        $conn = $user->getDatabaseConnection();
22485 +        $store = new Auth_OpenID_MySQLStore($conn);
22486 +    }
22487 +    return $store;
22488 hunk ./lib/openid.php 46
22489 -       $store = oid_store();
22490 -       $consumer = new Auth_OpenID_Consumer($store);
22491 -       return $consumer;
22492 +    $store = oid_store();
22493 +    $consumer = new Auth_OpenID_Consumer($store);
22494 +    return $consumer;
22495 hunk ./lib/openid.php 52
22496 -       oid_set_last('');
22497 +    oid_set_last('');
22498 hunk ./lib/openid.php 56
22499 -       common_set_cookie(OPENID_COOKIE_KEY,
22500 -                                $openid_url,
22501 -                                time() + OPENID_COOKIE_EXPIRY);
22502 +    common_set_cookie(OPENID_COOKIE_KEY,
22503 +                     $openid_url,
22504 +                     time() + OPENID_COOKIE_EXPIRY);
22505 hunk ./lib/openid.php 62
22506 -       $openid_url = $_COOKIE[OPENID_COOKIE_KEY];
22507 -       if ($openid_url && strlen($openid_url) > 0) {
22508 -               return $openid_url;
22509 -       } else {
22510 -               return NULL;
22511 -       }
22512 +    $openid_url = $_COOKIE[OPENID_COOKIE_KEY];
22513 +    if ($openid_url && strlen($openid_url) > 0) {
22514 +        return $openid_url;
22515 +    } else {
22516 +        return NULL;
22517 +    }
22518 hunk ./lib/openid.php 72
22519 -       $oid = new User_openid();
22520 -       $oid->user_id = $id;
22521 -       $oid->canonical = $canonical;
22522 -       $oid->display = $display;
22523 -       $oid->created = DB_DataObject_Cast::dateTime();
22524 +    $oid = new User_openid();
22525 +    $oid->user_id = $id;
22526 +    $oid->canonical = $canonical;
22527 +    $oid->display = $display;
22528 +    $oid->created = DB_DataObject_Cast::dateTime();
22529 hunk ./lib/openid.php 78
22530 -       if (!$oid->insert()) {
22531 -               $err = PEAR::getStaticProperty('DB_DataObject','lastError');
22532 -               common_debug('DB error ' . $err->code . ': ' . $err->message, __FILE__);
22533 -               return false;
22534 -       }
22535 +    if (!$oid->insert()) {
22536 +        $err = PEAR::getStaticProperty('DB_DataObject','lastError');
22537 +        common_debug('DB error ' . $err->code . ': ' . $err->message, __FILE__);
22538 +        return false;
22539 +    }
22540 hunk ./lib/openid.php 84
22541 -       return true;
22542 +    return true;
22543 hunk ./lib/openid.php 88
22544 -       $user = NULL;
22545 -       $oid = User_openid::staticGet('canonical', $openid_url);
22546 -       if ($oid) {
22547 -               $user = User::staticGet('id', $oid->user_id);
22548 -       }
22549 -       return $user;
22550 +    $user = NULL;
22551 +    $oid = User_openid::staticGet('canonical', $openid_url);
22552 +    if ($oid) {
22553 +        $user = User::staticGet('id', $oid->user_id);
22554 +    }
22555 +    return $user;
22556 hunk ./lib/openid.php 97
22557 -       if (!$backto) {
22558 -               $action = $_REQUEST['action'];
22559 -               $args = common_copy_args($_GET);
22560 -               unset($args['action']);
22561 -               $backto = common_local_url($action, $args);
22562 -       }
22563 -       common_debug('going back to "' . $backto . '"', __FILE__);
22564 +    if (!$backto) {
22565 +        $action = $_REQUEST['action'];
22566 +        $args = common_copy_args($_GET);
22567 +        unset($args['action']);
22568 +        $backto = common_local_url($action, $args);
22569 +    }
22570 +    common_debug('going back to "' . $backto . '"', __FILE__);
22571 hunk ./lib/openid.php 105
22572 -       common_ensure_session();
22573 +    common_ensure_session();
22574 hunk ./lib/openid.php 107
22575 -       $_SESSION['openid_immediate_backto'] = $backto;
22576 -       common_debug('passed-in variable is "' . $backto . '"', __FILE__);
22577 -       common_debug('session variable is "' . $_SESSION['openid_immediate_backto'] . '"', __FILE__);
22578 +    $_SESSION['openid_immediate_backto'] = $backto;
22579 +    common_debug('passed-in variable is "' . $backto . '"', __FILE__);
22580 +    common_debug('session variable is "' . $_SESSION['openid_immediate_backto'] . '"', __FILE__);
22581 hunk ./lib/openid.php 111
22582 -       oid_authenticate($openid_url,
22583 -                                        'finishimmediate',
22584 -                                        true);
22585 +    oid_authenticate($openid_url,
22586 +                     'finishimmediate',
22587 +                     true);
22588 hunk ./lib/openid.php 118
22589 -       $consumer = oid_consumer();
22590 +    $consumer = oid_consumer();
22591 hunk ./lib/openid.php 120
22592 -       if (!$consumer) {
22593 -               common_server_error(_('Cannot instantiate OpenID consumer object.'));
22594 -               return false;
22595 -       }
22596 +    if (!$consumer) {
22597 +        common_server_error(_('Cannot instantiate OpenID consumer object.'));
22598 +        return false;
22599 +    }
22600 hunk ./lib/openid.php 125
22601 -       common_ensure_session();
22602 +    common_ensure_session();
22603 hunk ./lib/openid.php 127
22604 -       $auth_request = $consumer->begin($openid_url);
22605 +    $auth_request = $consumer->begin($openid_url);
22606 hunk ./lib/openid.php 129
22607 -       // Handle failure status return values.
22608 -       if (!$auth_request) {
22609 -               return _('Not a valid OpenID.');
22610 -       } else if (Auth_OpenID::isFailure($auth_request)) {
22611 -               return sprintf(_('OpenID failure: %s'), $auth_request->message);
22612 -       }
22613 +    // Handle failure status return values.
22614 +    if (!$auth_request) {
22615 +        return _('Not a valid OpenID.');
22616 +    } else if (Auth_OpenID::isFailure($auth_request)) {
22617 +        return sprintf(_('OpenID failure: %s'), $auth_request->message);
22618 +    }
22619 hunk ./lib/openid.php 136
22620 -       $sreg_request = Auth_OpenID_SRegRequest::build(// Required
22621 -                                                                                                  array(),
22622 -                                                                                                  // Optional
22623 -                                                                                                  array('nickname',
22624 -                                                                                                                'email',
22625 -                                                                                                                'fullname',
22626 -                                                                                                                'language',
22627 -                                                                                                                'timezone',
22628 -                                                                                                                'postcode',
22629 -                                                                                                                'country'));
22630 +    $sreg_request = Auth_OpenID_SRegRequest::build(// Required
22631 +                                                   array(),
22632 +                                                   // Optional
22633 +                                                   array('nickname',
22634 +                                                         'email',
22635 +                                                         'fullname',
22636 +                                                         'language',
22637 +                                                         'timezone',
22638 +                                                         'postcode',
22639 +                                                         'country'));
22640 hunk ./lib/openid.php 147
22641 -       if ($sreg_request) {
22642 -               $auth_request->addExtension($sreg_request);
22643 -       }
22644 +    if ($sreg_request) {
22645 +        $auth_request->addExtension($sreg_request);
22646 +    }
22647 hunk ./lib/openid.php 151
22648 -       $trust_root = common_local_url('public');
22649 -       $process_url = common_local_url($returnto);
22650 +    $trust_root = common_local_url('public');
22651 +    $process_url = common_local_url($returnto);
22652 hunk ./lib/openid.php 154
22653 -       if ($auth_request->shouldSendRedirect()) {
22654 -               $redirect_url = $auth_request->redirectURL($trust_root,
22655 -                                                                                                  $process_url,
22656 -                                                                                                  $immediate);
22657 -               if (!$redirect_url) {
22658 -               } else if (Auth_OpenID::isFailure($redirect_url)) {
22659 -                       return sprintf(_('Could not redirect to server: %s'), $redirect_url->message);
22660 -               } else {
22661 -                       common_redirect($redirect_url);
22662 -               }
22663 -       } else {
22664 -               // Generate form markup and render it.
22665 -               $form_id = 'openid_message';
22666 -               $form_html = $auth_request->formMarkup($trust_root, $process_url,
22667 -                                                                                          $immediate, array('id' => $form_id));
22668 +    if ($auth_request->shouldSendRedirect()) {
22669 +        $redirect_url = $auth_request->redirectURL($trust_root,
22670 +                                                   $process_url,
22671 +                                                   $immediate);
22672 +        if (!$redirect_url) {
22673 +        } else if (Auth_OpenID::isFailure($redirect_url)) {
22674 +            return sprintf(_('Could not redirect to server: %s'), $redirect_url->message);
22675 +        } else {
22676 +            common_redirect($redirect_url);
22677 +        }
22678 +    } else {
22679 +        // Generate form markup and render it.
22680 +        $form_id = 'openid_message';
22681 +        $form_html = $auth_request->formMarkup($trust_root, $process_url,
22682 +                                               $immediate, array('id' => $form_id));
22683 hunk ./lib/openid.php 170
22684 -               # XXX: This is cheap, but things choke if we don't escape ampersands
22685 -               # in the HTML attributes
22686 +        # XXX: This is cheap, but things choke if we don't escape ampersands
22687 +        # in the HTML attributes
22688 hunk ./lib/openid.php 173
22689 -               $form_html = preg_replace('/&/', '&amp;', $form_html);
22690 +        $form_html = preg_replace('/&/', '&amp;', $form_html);
22691 hunk ./lib/openid.php 175
22692 -               // Display an error if the form markup couldn't be generated;
22693 -               // otherwise, render the HTML.
22694 -               if (Auth_OpenID::isFailure($form_html)) {
22695 -                       $this->show_form(sprintf(_('Could not create OpenID form: %s'), $form_html->message));
22696 -               } else {
22697 -                       common_show_header(_('OpenID Auto-Submit'), NULL, NULL, '_oid_print_instructions');
22698 -                       common_raw($form_html);
22699 -                       common_element('script', NULL,
22700 -                                                  '$(document).ready(function() { ' .
22701 -                                                  '    $("#'. $form_id .'").submit(); '.
22702 -                                                  '});');
22703 -                       common_show_footer();
22704 -               }
22705 -       }
22706 +        // Display an error if the form markup couldn't be generated;
22707 +        // otherwise, render the HTML.
22708 +        if (Auth_OpenID::isFailure($form_html)) {
22709 +            $this->show_form(sprintf(_('Could not create OpenID form: %s'), $form_html->message));
22710 +        } else {
22711 +            common_show_header(_('OpenID Auto-Submit'), NULL, NULL, '_oid_print_instructions');
22712 +            common_raw($form_html);
22713 +            common_element('script', NULL,
22714 +                           '$(document).ready(function() { ' .
22715 +                           '    $("#'. $form_id .'").submit(); '.
22716 +                           '});');
22717 +            common_show_footer();
22718 +        }
22719 +    }
22720 hunk ./lib/openid.php 194
22721 -       common_element('div', 'instructions',
22722 -                                  _('This form should automatically submit itself. '.
22723 -                                         'If not, click the submit button to go to your '.
22724 -                                         'OpenID provider.'));
22725 +    common_element('div', 'instructions',
22726 +                   _('This form should automatically submit itself. '.
22727 +                      'If not, click the submit button to go to your '.
22728 +                      'OpenID provider.'));
22729 hunk ./lib/openid.php 204
22730 -       $profile = $user->getProfile();
22731 +    $profile = $user->getProfile();
22732 hunk ./lib/openid.php 206
22733 -       $orig_profile = clone($profile);
22734 +    $orig_profile = clone($profile);
22735 hunk ./lib/openid.php 208
22736 -       if ($sreg['fullname'] && strlen($sreg['fullname']) <= 255) {
22737 -               $profile->fullname = $sreg['fullname'];
22738 -       }
22739 +    if ($sreg['fullname'] && strlen($sreg['fullname']) <= 255) {
22740 +        $profile->fullname = $sreg['fullname'];
22741 +    }
22742 hunk ./lib/openid.php 212
22743 -       if ($sreg['country']) {
22744 -               if ($sreg['postcode']) {
22745 -                       # XXX: use postcode to get city and region
22746 -                       # XXX: also, store postcode somewhere -- it's valuable!
22747 -                       $profile->location = $sreg['postcode'] . ', ' . $sreg['country'];
22748 -               } else {
22749 -                       $profile->location = $sreg['country'];
22750 -               }
22751 -       }
22752 +    if ($sreg['country']) {
22753 +        if ($sreg['postcode']) {
22754 +            # XXX: use postcode to get city and region
22755 +            # XXX: also, store postcode somewhere -- it's valuable!
22756 +            $profile->location = $sreg['postcode'] . ', ' . $sreg['country'];
22757 +        } else {
22758 +            $profile->location = $sreg['country'];
22759 +        }
22760 +    }
22761 hunk ./lib/openid.php 222
22762 -       # XXX save language if it's passed
22763 -       # XXX save timezone if it's passed
22764 +    # XXX save language if it's passed
22765 +    # XXX save timezone if it's passed
22766 hunk ./lib/openid.php 225
22767 -       if (!$profile->update($orig_profile)) {
22768 -               common_server_error(_('Error saving the profile.'));
22769 -               return false;
22770 -       }
22771 +    if (!$profile->update($orig_profile)) {
22772 +        common_server_error(_('Error saving the profile.'));
22773 +        return false;
22774 +    }
22775 hunk ./lib/openid.php 230
22776 -       $orig_user = clone($user);
22777 +    $orig_user = clone($user);
22778 hunk ./lib/openid.php 232
22779 -       if ($sreg['email'] && Validate::email($sreg['email'], true)) {
22780 -               $user->email = $sreg['email'];
22781 -       }
22782 +    if ($sreg['email'] && Validate::email($sreg['email'], true)) {
22783 +        $user->email = $sreg['email'];
22784 +    }
22785 hunk ./lib/openid.php 236
22786 -       if (!$user->update($orig_user)) {
22787 -               common_server_error(_('Error saving the user.'));
22788 -               return false;
22789 -       }
22790 +    if (!$user->update($orig_user)) {
22791 +        common_server_error(_('Error saving the user.'));
22792 +        return false;
22793 +    }
22794 hunk ./lib/openid.php 241
22795 -       return true;
22796 +    return true;
22797 hunk ./lib/personal.php 23
22798 -       
22799 -       function is_readonly() {
22800 -               return true;
22801 -       }
22802 -       
22803 -       function handle($args) {
22804 -               parent::handle($args);
22805 -           common_set_returnto($this->self_url());
22806 -       }
22807 +    
22808 +    function is_readonly() {
22809 +        return true;
22810 +    }
22811 +    
22812 +    function handle($args) {
22813 +        parent::handle($args);
22814 +        common_set_returnto($this->self_url());
22815 +    }
22816 hunk ./lib/personal.php 33
22817 -       function views_menu() {
22818 +    function views_menu() {
22819 hunk ./lib/personal.php 35
22820 -               $user = NULL;
22821 -               $action = $this->trimmed('action');
22822 -               $nickname = $this->trimmed('nickname');
22823 +        $user = NULL;
22824 +        $action = $this->trimmed('action');
22825 +        $nickname = $this->trimmed('nickname');
22826 hunk ./lib/personal.php 39
22827 -               if ($nickname) {
22828 -                       $user = User::staticGet('nickname', $nickname);
22829 -                       $user_profile = $user->getProfile();
22830 -               } else {
22831 -                       $user_profile = false;
22832 -               }
22833 +        if ($nickname) {
22834 +            $user = User::staticGet('nickname', $nickname);
22835 +            $user_profile = $user->getProfile();
22836 +        } else {
22837 +            $user_profile = false;
22838 +        }
22839 hunk ./lib/personal.php 46
22840 -               common_element_start('ul', array('id' => 'nav_views'));
22841 +        common_element_start('ul', array('id' => 'nav_views'));
22842 hunk ./lib/personal.php 48
22843 -               common_menu_item(common_local_url('all', array('nickname' =>
22844 -                                                                                                          $nickname)),
22845 -                                                _('Personal'),
22846 -                                                sprintf(_('%s and friends'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
22847 -                                                $action == 'all');
22848 -               common_menu_item(common_local_url('replies', array('nickname' =>
22849 -                                                                                                                         $nickname)),
22850 -                                                _('Replies'),
22851 -                                                sprintf(_('Replies to %s'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
22852 -                                                $action == 'replies');
22853 -               common_menu_item(common_local_url('showstream', array('nickname' =>
22854 -                                                                                                                         $nickname)),
22855 -                                                _('Profile'),
22856 -                                                ($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname,
22857 -                                                $action == 'showstream');
22858 -               common_menu_item(common_local_url('showfavorites', array('nickname' =>
22859 -                                                                                                                         $nickname)),
22860 -                                                _('Favorites'),
22861 -                                                sprintf(_('%s\'s favorite notices'), ($user_profile) ? $user_profile->getBestName() : _('User')),
22862 -                                                $action == 'showfavorites');
22863 -               
22864 -               $cur = common_current_user();
22865 -               
22866 -               if ($cur && $cur->id == $user->id) {
22867 -                       
22868 -                       common_menu_item(common_local_url('inbox', array('nickname' =>
22869 -                                                                                                                                        $nickname)),
22870 -                                                        _('Inbox'),
22871 -                                                        _('Your incoming messages'),
22872 -                                                        $action == 'inbox');
22873 -                       common_menu_item(common_local_url('outbox', array('nickname' =>
22874 -                                                                                                                                        $nickname)),
22875 -                                                        _('Outbox'),
22876 -                                                        _('Your sent messages'),
22877 -                                                        $action == 'outbox');
22878 -               }
22879 -               
22880 -               common_element_end('ul');
22881 -       }
22882 +        common_menu_item(common_local_url('all', array('nickname' =>
22883 +                                                       $nickname)),
22884 +                         _('Personal'),
22885 +                         sprintf(_('%s and friends'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
22886 +                         $action == 'all');
22887 +        common_menu_item(common_local_url('replies', array('nickname' =>
22888 +                                                              $nickname)),
22889 +                         _('Replies'),
22890 +                         sprintf(_('Replies to %s'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
22891 +                         $action == 'replies');
22892 +        common_menu_item(common_local_url('showstream', array('nickname' =>
22893 +                                                              $nickname)),
22894 +                         _('Profile'),
22895 +                         ($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname,
22896 +                         $action == 'showstream');
22897 +        common_menu_item(common_local_url('showfavorites', array('nickname' =>
22898 +                                                              $nickname)),
22899 +                         _('Favorites'),
22900 +                         sprintf(_('%s\'s favorite notices'), ($user_profile) ? $user_profile->getBestName() : _('User')),
22901 +                         $action == 'showfavorites');
22902 +        
22903 +        $cur = common_current_user();
22904 +        
22905 +        if ($cur && $cur->id == $user->id) {
22906 +            
22907 +            common_menu_item(common_local_url('inbox', array('nickname' =>
22908 +                                                                     $nickname)),
22909 +                             _('Inbox'),
22910 +                             _('Your incoming messages'),
22911 +                             $action == 'inbox');
22912 +            common_menu_item(common_local_url('outbox', array('nickname' =>
22913 +                                                                     $nickname)),
22914 +                             _('Outbox'),
22915 +                             _('Your sent messages'),
22916 +                             $action == 'outbox');
22917 +        }
22918 +        
22919 +        common_element_end('ul');
22920 +    }
22921 hunk ./lib/personal.php 88
22922 -       function show_feeds_list($feeds) {
22923 -               common_element_start('div', array('class' => 'feeds'));
22924 -               common_element('p', null, 'Feeds:');
22925 -               common_element_start('ul', array('class' => 'xoxo'));
22926 +    function show_feeds_list($feeds) {
22927 +        common_element_start('div', array('class' => 'feeds'));
22928 +        common_element('p', null, 'Feeds:');
22929 +        common_element_start('ul', array('class' => 'xoxo'));
22930 hunk ./lib/personal.php 93
22931 -               foreach ($feeds as $key => $value) {
22932 -                       $this->common_feed_item($feeds[$key]);
22933 -               }
22934 -               common_element_end('ul');
22935 -               common_element_end('div');
22936 -       }
22937 +        foreach ($feeds as $key => $value) {
22938 +            $this->common_feed_item($feeds[$key]);
22939 +        }
22940 +        common_element_end('ul');
22941 +        common_element_end('div');
22942 +    }
22943 hunk ./lib/personal.php 100
22944 -       function common_feed_item($feed) {
22945 -               $nickname = $this->trimmed('nickname');
22946 +    function common_feed_item($feed) {
22947 +        $nickname = $this->trimmed('nickname');
22948 hunk ./lib/personal.php 103
22949 -               switch($feed['item']) {
22950 -                       case 'notices': default:
22951 -                               $feed_classname = $feed['type'];
22952 -                               $feed_mimetype = "application/".$feed['type']."+xml";
22953 -                               $feed_title = "$nickname's ".$feed['version']." notice feed";
22954 -                               $feed['textContent'] = "RSS";
22955 -                               break;
22956 +        switch($feed['item']) {
22957 +            case 'notices': default:
22958 +                $feed_classname = $feed['type'];
22959 +                $feed_mimetype = "application/".$feed['type']."+xml";
22960 +                $feed_title = "$nickname's ".$feed['version']." notice feed";
22961 +                $feed['textContent'] = "RSS";
22962 +                break;
22963 hunk ./lib/personal.php 111
22964 -                       case 'allrss':
22965 -                               $feed_classname = $feed['type'];
22966 -                               $feed_mimetype = "application/".$feed['type']."+xml";
22967 -                               $feed_title = $feed['version']." feed for $nickname and friends";
22968 -                               $feed['textContent'] = "RSS";
22969 -                               break;
22970 +            case 'allrss':
22971 +                $feed_classname = $feed['type'];
22972 +                $feed_mimetype = "application/".$feed['type']."+xml";
22973 +                $feed_title = $feed['version']." feed for $nickname and friends";
22974 +                $feed['textContent'] = "RSS";
22975 +                break;
22976 hunk ./lib/personal.php 118
22977 -                       case 'repliesrss':
22978 -                               $feed_classname = $feed['type'];
22979 -                               $feed_mimetype = "application/".$feed['type']."+xml";
22980 -                               $feed_title = $feed['version']." feed for replies to $nickname";
22981 -                               $feed['textContent'] = "RSS";
22982 -                               break;
22983 +            case 'repliesrss':
22984 +                $feed_classname = $feed['type'];
22985 +                $feed_mimetype = "application/".$feed['type']."+xml";
22986 +                $feed_title = $feed['version']." feed for replies to $nickname";
22987 +                $feed['textContent'] = "RSS";
22988 +                break;
22989 hunk ./lib/personal.php 125
22990 -                       case 'publicrss':
22991 -                               $feed_classname = $feed['type'];
22992 -                               $feed_mimetype = "application/".$feed['type']."+xml";
22993 -                               $feed_title = "Public timeline ".$feed['version']." feed";
22994 -                               $feed['textContent'] = "RSS";
22995 -                               break;
22996 +            case 'publicrss':
22997 +                $feed_classname = $feed['type'];
22998 +                $feed_mimetype = "application/".$feed['type']."+xml";
22999 +                $feed_title = "Public timeline ".$feed['version']." feed";
23000 +                $feed['textContent'] = "RSS";
23001 +                break;
23002 hunk ./lib/personal.php 132
23003 -                       case 'publicatom':
23004 -                               $feed_classname = "atom";
23005 -                               $feed_mimetype = "application/".$feed['type']."+xml";
23006 -                               $feed_title = "Public timeline ".$feed['version']." feed";
23007 -                               $feed['textContent'] = "Atom";
23008 -                               break;
23009 +            case 'publicatom':
23010 +                $feed_classname = "atom";
23011 +                $feed_mimetype = "application/".$feed['type']."+xml";
23012 +                $feed_title = "Public timeline ".$feed['version']." feed";
23013 +                $feed['textContent'] = "Atom";
23014 +                break;
23015 hunk ./lib/personal.php 139
23016 -                       case 'tagrss':
23017 -                               $feed_classname = $feed['type'];
23018 -                               $feed_mimetype = "application/".$feed['type']."+xml";
23019 -                               $feed_title = $feed['version']." feed for this tag";
23020 -                               $feed['textContent'] = "RSS";
23021 -                               break;
23022 +            case 'tagrss':
23023 +                $feed_classname = $feed['type'];
23024 +                $feed_mimetype = "application/".$feed['type']."+xml";
23025 +                $feed_title = $feed['version']." feed for this tag";
23026 +                $feed['textContent'] = "RSS";
23027 +                break;
23028 hunk ./lib/personal.php 146
23029 -                       case 'favoritedrss':
23030 -                               $feed_classname = $feed['type'];
23031 -                               $feed_mimetype = "application/".$feed['type']."+xml";
23032 -                               $feed_title = "Favorited ".$feed['version']." feed";
23033 -                               $feed['textContent'] = "RSS";
23034 -                               break;
23035 +            case 'favoritedrss':
23036 +                $feed_classname = $feed['type'];
23037 +                $feed_mimetype = "application/".$feed['type']."+xml";
23038 +                $feed_title = "Favorited ".$feed['version']." feed";
23039 +                $feed['textContent'] = "RSS";
23040 +                break;
23041 hunk ./lib/personal.php 153
23042 -                       case 'foaf':
23043 -                               $feed_classname = "foaf";
23044 -                               $feed_mimetype = "application/".$feed['type']."+xml";
23045 -                               $feed_title = "$nickname's FOAF file";
23046 -                               $feed['textContent'] = "FOAF";
23047 -                               break;
23048 +            case 'foaf':
23049 +                $feed_classname = "foaf";
23050 +                $feed_mimetype = "application/".$feed['type']."+xml";
23051 +                $feed_title = "$nickname's FOAF file";
23052 +                $feed['textContent'] = "FOAF";
23053 +                break;
23054 hunk ./lib/personal.php 160
23055 -                       case 'favoritesrss':
23056 -                               $feed_classname = "favorites";
23057 -                               $feed_mimetype = "application/".$feed['type']."+xml";
23058 -                               $feed_title = "Feed for favorites of $nickname";
23059 -                               $feed['textContent'] = "RSS";
23060 -                               break;
23061 +            case 'favoritesrss':
23062 +                $feed_classname = "favorites";
23063 +                $feed_mimetype = "application/".$feed['type']."+xml";
23064 +                $feed_title = "Feed for favorites of $nickname";
23065 +                $feed['textContent'] = "RSS";
23066 +                break;
23067 hunk ./lib/personal.php 167
23068 -                       case 'usertimeline':
23069 -                               $feed_classname = "atom";
23070 -                               $feed_mimetype = "application/".$feed['type']."+xml";
23071 -                               $feed_title = "$nickname's ".$feed['version']." notice feed";
23072 -                               $feed['textContent'] = "Atom";
23073 -                               break;
23074 -               }
23075 -               common_element_start('li');
23076 -               common_element('a', array('href' => $feed['href'],
23077 -                                                                 'class' => $feed_classname,
23078 -                                                                 'type' => $feed_mimetype,
23079 -                                                                 'title' => $feed_title),
23080 -                                                       $feed['textContent']);
23081 -               common_element_end('li');
23082 -       }
23083 +            case 'usertimeline':
23084 +                $feed_classname = "atom";
23085 +                $feed_mimetype = "application/".$feed['type']."+xml";
23086 +                $feed_title = "$nickname's ".$feed['version']." notice feed";
23087 +                $feed['textContent'] = "Atom";
23088 +                break;
23089 +        }
23090 +        common_element_start('li');
23091 +        common_element('a', array('href' => $feed['href'],
23092 +                                  'class' => $feed_classname,
23093 +                                  'type' => $feed_mimetype,
23094 +                                  'title' => $feed_title),
23095 +                            $feed['textContent']);
23096 +        common_element_end('li');
23097 +    }
23098 hunk ./lib/personal.php 183
23099 -       
23100 -       function source_link($source) {
23101 -               $source_name = _($source);
23102 -               switch ($source) {
23103 -                case 'web':
23104 -                case 'xmpp':
23105 -                case 'mail':
23106 -                case 'omb':
23107 -                case 'api':
23108 -                       common_element('span', 'noticesource', $source_name);
23109 -                       break;
23110 -                default:
23111 -                       $ns = Notice_source::staticGet($source);
23112 -                       if ($ns) {
23113 -                               common_element('a', array('href' => $ns->url),
23114 -                                                          $ns->name);
23115 -                       } else {
23116 -                               common_element('span', 'noticesource', $source_name);
23117 -                       }
23118 -                       break;
23119 -               }
23120 -               return;
23121 -       }
23122 +    
23123 +    function source_link($source) {
23124 +        $source_name = _($source);
23125 +        switch ($source) {
23126 +         case 'web':
23127 +         case 'xmpp':
23128 +         case 'mail':
23129 +         case 'omb':
23130 +         case 'api':
23131 +            common_element('span', 'noticesource', $source_name);
23132 +            break;
23133 +         default:
23134 +            $ns = Notice_source::staticGet($source);
23135 +            if ($ns) {
23136 +                common_element('a', array('href' => $ns->url),
23137 +                               $ns->name);
23138 +            } else {
23139 +                common_element('span', 'noticesource', $source_name);
23140 +            }
23141 +            break;
23142 +        }
23143 +        return;
23144 +    }
23145 hunk ./lib/profilelist.php 27
23146 -       var $profile = NULL;
23147 -       var $owner = NULL;
23148 -       var $action = NULL;
23149 +    var $profile = NULL;
23150 +    var $owner = NULL;
23151 +    var $action = NULL;
23152 hunk ./lib/profilelist.php 31
23153 -       function __construct($profile, $owner=NULL, $action=NULL) {
23154 -               $this->profile = $profile;
23155 -               $this->owner = $owner;
23156 -               $this->action = $action;
23157 -       }
23158 +    function __construct($profile, $owner=NULL, $action=NULL) {
23159 +        $this->profile = $profile;
23160 +        $this->owner = $owner;
23161 +        $this->action = $action;
23162 +    }
23163 hunk ./lib/profilelist.php 37
23164 -       function show_list() {
23165 +    function show_list() {
23166 hunk ./lib/profilelist.php 39
23167 -               common_element_start('ul', array('id' => 'profiles', 'class' => 'profile_list'));
23168 +        common_element_start('ul', array('id' => 'profiles', 'class' => 'profile_list'));
23169 hunk ./lib/profilelist.php 41
23170 -               $cnt = 0;
23171 +        $cnt = 0;
23172 hunk ./lib/profilelist.php 43
23173 -               while ($this->profile->fetch()) {
23174 -                       $cnt++;
23175 -                       if($cnt > PROFILES_PER_PAGE) {
23176 -                               break;
23177 -                       }
23178 -                       $this->show();
23179 -               }
23180 +        while ($this->profile->fetch()) {
23181 +            $cnt++;
23182 +            if($cnt > PROFILES_PER_PAGE) {
23183 +                break;
23184 +            }
23185 +            $this->show();
23186 +        }
23187 hunk ./lib/profilelist.php 51
23188 -               common_element_end('ul');
23189 +        common_element_end('ul');
23190 hunk ./lib/profilelist.php 53
23191 -               return $cnt;
23192 -       }
23193 +        return $cnt;
23194 +    }
23195 hunk ./lib/profilelist.php 56
23196 -       function show() {
23197 +    function show() {
23198 hunk ./lib/profilelist.php 58
23199 -               common_element_start('li', array('class' => 'profile_single',
23200 -                                                                                'id' => 'profile-' . $this->profile->id));
23201 +        common_element_start('li', array('class' => 'profile_single',
23202 +                                         'id' => 'profile-' . $this->profile->id));
23203 hunk ./lib/profilelist.php 61
23204 -               $user = common_current_user();
23205 +        $user = common_current_user();
23206 hunk ./lib/profilelist.php 63
23207 -               if ($user && $user->id != $this->profile->id) {
23208 -                       # XXX: special-case for user looking at own
23209 -                       # subscriptions page
23210 -                       if ($user->isSubscribed($this->profile)) {
23211 -                               common_unsubscribe_form($this->profile);
23212 -                       } else {
23213 -                               common_subscribe_form($this->profile);
23214 -                       }
23215 -               }
23216 +        if ($user && $user->id != $this->profile->id) {
23217 +            # XXX: special-case for user looking at own
23218 +            # subscriptions page
23219 +            if ($user->isSubscribed($this->profile)) {
23220 +                common_unsubscribe_form($this->profile);
23221 +            } else {
23222 +                common_subscribe_form($this->profile);
23223 +            }
23224 +        }
23225 hunk ./lib/profilelist.php 73
23226 -               $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
23227 -               common_element_start('a', array('href' => $this->profile->profileurl));
23228 -               common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
23229 -                                                                       'class' => 'avatar stream',
23230 -                                                                       'width' => AVATAR_STREAM_SIZE,
23231 -                                                                       'height' => AVATAR_STREAM_SIZE,
23232 -                                                                       'alt' =>
23233 -                                                                       ($this->profile->fullname) ? $this->profile->fullname :
23234 -                                                                       $this->profile->nickname));
23235 -               common_element_end('a');
23236 -               common_element_start('p');
23237 -               common_element_start('a', array('href' => $this->profile->profileurl,
23238 -                                                                               'class' => 'nickname'));
23239 -               common_raw($this->highlight($this->profile->nickname));
23240 -               common_element_end('a');
23241 -               if ($this->profile->fullname) {
23242 -                       common_text(' | ');
23243 -                       common_element_start('span', 'fullname');
23244 -                       common_raw($this->highlight($this->profile->fullname));
23245 -                       common_element_end('span');
23246 -               }
23247 -               if ($this->profile->location) {
23248 -                       common_text(' | ');
23249 -                       common_element_start('span', 'location');
23250 -                       common_raw($this->highlight($this->profile->location));
23251 -                       common_element_end('span');
23252 -               }
23253 -               common_element_end('p');
23254 -               if ($this->profile->homepage) {
23255 -                       common_element_start('p', 'website');
23256 -                       common_element_start('a', array('href' => $this->profile->homepage));
23257 -                       common_raw($this->highlight($this->profile->homepage));
23258 -                       common_element_end('a');
23259 -                       common_element_end('p');
23260 -               }
23261 -               if ($this->profile->bio) {
23262 -                       common_element_start('p', 'bio');
23263 -                       common_raw($this->highlight($this->profile->bio));
23264 -                       common_element_end('p');
23265 -               }
23266 +        $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE);
23267 +        common_element_start('a', array('href' => $this->profile->profileurl));
23268 +        common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
23269 +                                    'class' => 'avatar stream',
23270 +                                    'width' => AVATAR_STREAM_SIZE,
23271 +                                    'height' => AVATAR_STREAM_SIZE,
23272 +                                    'alt' =>
23273 +                                    ($this->profile->fullname) ? $this->profile->fullname :
23274 +                                    $this->profile->nickname));
23275 +        common_element_end('a');
23276 +        common_element_start('p');
23277 +        common_element_start('a', array('href' => $this->profile->profileurl,
23278 +                                        'class' => 'nickname'));
23279 +        common_raw($this->highlight($this->profile->nickname));
23280 +        common_element_end('a');
23281 +        if ($this->profile->fullname) {
23282 +            common_text(' | ');
23283 +            common_element_start('span', 'fullname');
23284 +            common_raw($this->highlight($this->profile->fullname));
23285 +            common_element_end('span');
23286 +        }
23287 +        if ($this->profile->location) {
23288 +            common_text(' | ');
23289 +            common_element_start('span', 'location');
23290 +            common_raw($this->highlight($this->profile->location));
23291 +            common_element_end('span');
23292 +        }
23293 +        common_element_end('p');
23294 +        if ($this->profile->homepage) {
23295 +            common_element_start('p', 'website');
23296 +            common_element_start('a', array('href' => $this->profile->homepage));
23297 +            common_raw($this->highlight($this->profile->homepage));
23298 +            common_element_end('a');
23299 +            common_element_end('p');
23300 +        }
23301 +        if ($this->profile->bio) {
23302 +            common_element_start('p', 'bio');
23303 +            common_raw($this->highlight($this->profile->bio));
23304 +            common_element_end('p');
23305 +        }
23306 hunk ./lib/profilelist.php 114
23307 -               # If we're on a list with an owner (subscriptions or subscribers)...
23308 +        # If we're on a list with an owner (subscriptions or subscribers)...
23309 hunk ./lib/profilelist.php 116
23310 -               if ($this->owner) {
23311 -                       # Get tags
23312 -                       $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
23313 +        if ($this->owner) {
23314 +            # Get tags
23315 +            $tags = Profile_tag::getTags($this->owner->id, $this->profile->id);
23316 hunk ./lib/profilelist.php 120
23317 -                       common_element_start('div', 'tags_user');
23318 -                       common_element_start('dl');
23319 -                       common_element_start('dt');
23320 -                       if ($user->id == $this->owner->id) {
23321 -                               common_element('a', array('href' => common_local_url('tagother',
23322 -                                                                                                                                        array('id' => $this->profile->id))),
23323 -                                                          _('Tags'));
23324 -                       } else {
23325 -                               common_text(_('Tags'));
23326 -                       }
23327 -                       common_text(":");
23328 -                       common_element_end('dt');
23329 -                       common_element_start('dd');
23330 -                       if ($tags) {
23331 -                               common_element_start('ul', 'tags xoxo');
23332 -                               foreach ($tags as $tag) {
23333 -                                       common_element_start('li');
23334 -                                       common_element('a', array('rel' => 'tag',
23335 -                                                                                         'href' => common_local_url($this->action,
23336 -                                                                                                                                                array('nickname' => $this->owner->nickname,
23337 -                                                                                                                                                          'tag' => $tag))),
23338 -                                                                  $tag);
23339 -                                       common_element_end('li');
23340 -                               }
23341 -                               common_element_end('ul');
23342 -                       } else {
23343 -                               common_text(_('(none)'));
23344 -                       }
23345 -                       common_element_end('dd');
23346 -                       common_element_end('dl');
23347 -                       common_element_end('div');
23348 -               }
23349 +            common_element_start('div', 'tags_user');
23350 +            common_element_start('dl');
23351 +            common_element_start('dt');
23352 +            if ($user->id == $this->owner->id) {
23353 +                common_element('a', array('href' => common_local_url('tagother',
23354 +                                                                     array('id' => $this->profile->id))),
23355 +                               _('Tags'));
23356 +            } else {
23357 +                common_text(_('Tags'));
23358 +            }
23359 +            common_text(":");
23360 +            common_element_end('dt');
23361 +            common_element_start('dd');
23362 +            if ($tags) {
23363 +                common_element_start('ul', 'tags xoxo');
23364 +                foreach ($tags as $tag) {
23365 +                    common_element_start('li');
23366 +                    common_element('a', array('rel' => 'tag',
23367 +                                              'href' => common_local_url($this->action,
23368 +                                                                         array('nickname' => $this->owner->nickname,
23369 +                                                                               'tag' => $tag))),
23370 +                                   $tag);
23371 +                    common_element_end('li');
23372 +                }
23373 +                common_element_end('ul');
23374 +            } else {
23375 +                common_text(_('(none)'));
23376 +            }
23377 +            common_element_end('dd');
23378 +            common_element_end('dl');
23379 +            common_element_end('div');
23380 +        }
23381 hunk ./lib/profilelist.php 157
23382 -               common_element_end('li');
23383 -       }
23384 +        common_element_end('li');
23385 +    }
23386 hunk ./lib/profilelist.php 166
23387 -       function highlight($text) {
23388 -               return htmlspecialchars($text);
23389 -       }
23390 +    function highlight($text) {
23391 +        return htmlspecialchars($text);
23392 +    }
23393 hunk ./lib/queuehandler.php 30
23394 -       var $_id = 'generic';
23395 +    var $_id = 'generic';
23396 hunk ./lib/queuehandler.php 32
23397 -       function QueueHandler($id=NULL) {
23398 -               if ($id) {
23399 -                       $this->set_id($id);
23400 -               }
23401 -       }
23402 -       
23403 -       function class_name() {
23404 -               return ucfirst($this->transport()) . 'Handler';
23405 -       }
23406 +    function QueueHandler($id=NULL) {
23407 +        if ($id) {
23408 +            $this->set_id($id);
23409 +        }
23410 +    }
23411 +    
23412 +    function class_name() {
23413 +        return ucfirst($this->transport()) . 'Handler';
23414 +    }
23415 hunk ./lib/queuehandler.php 42
23416 -       function name() {
23417 -               return strtolower($this->class_name().'.'.$this->get_id());
23418 -       }
23419 -       
23420 -       function get_id() {
23421 -               return $this->_id;
23422 -       }
23423 +    function name() {
23424 +        return strtolower($this->class_name().'.'.$this->get_id());
23425 +    }
23426 +    
23427 +    function get_id() {
23428 +        return $this->_id;
23429 +    }
23430 hunk ./lib/queuehandler.php 50
23431 -       function set_id($id) {
23432 -               $this->_id = $id;
23433 -       }
23434 -       
23435 -       function transport() {
23436 -               return NULL;
23437 -       }
23438 -       
23439 -       function start() {
23440 -       }
23441 -       
23442 -       function finish() {
23443 -       }
23444 +    function set_id($id) {
23445 +        $this->_id = $id;
23446 +    }
23447 +    
23448 +    function transport() {
23449 +        return NULL;
23450 +    }
23451 +    
23452 +    function start() {
23453 +    }
23454 +    
23455 +    function finish() {
23456 +    }
23457 hunk ./lib/queuehandler.php 64
23458 -       function handle_notice($notice) {
23459 -               return true;
23460 -       }
23461 -       
23462 -       function run() {
23463 -               if (!$this->start()) {
23464 -                       return false;
23465 -               }
23466 -               $this->log(LOG_INFO, 'checking for queued notices');
23467 -               $transport = $this->transport();
23468 -               do {
23469 -                       $qi = Queue_item::top($transport);
23470 -                       if ($qi) {
23471 -                               $this->log(LOG_INFO, 'Got item enqueued '.common_exact_date($qi->created));
23472 -                               $notice = Notice::staticGet($qi->notice_id);
23473 -                               if ($notice) {
23474 -                                       $this->log(LOG_INFO, 'broadcasting notice ID = ' . $notice->id);
23475 -                                       # XXX: what to do if broadcast fails?
23476 -                                       $result = $this->handle_notice($notice);
23477 -                                       if (!$result) {
23478 -                                               $this->log(LOG_WARNING, 'Failed broadcast for notice ID = ' . $notice->id);
23479 -                                               $orig = $qi;
23480 -                                               $qi->claimed = NULL;
23481 -                                               $qi->update($orig);
23482 -                                               $this->log(LOG_WARNING, 'Abandoned claim for notice ID = ' . $notice->id);
23483 -                                               continue;
23484 -                                       }
23485 -                                       $this->log(LOG_INFO, 'finished broadcasting notice ID = ' . $notice->id);
23486 -                                       $notice->free();
23487 -                                       unset($notice);
23488 -                                       $notice = NULL;
23489 -                               } else {
23490 -                                       $this->log(LOG_WARNING, 'queue item for notice that does not exist');
23491 -                               }
23492 -                               $qi->delete();
23493 -                               $qi->free();
23494 -                               unset($qi);
23495 -                               $this->idle(0);
23496 -                       } else {
23497 -                               $this->clear_old_claims();
23498 -                               $this->idle(5);
23499 -                       }       
23500 -               } while (true);
23501 -               if (!$this->finish()) {
23502 -                       return false;
23503 -               }
23504 -               return true;
23505 -       }
23506 +    function handle_notice($notice) {
23507 +        return true;
23508 +    }
23509 +    
23510 +    function run() {
23511 +        if (!$this->start()) {
23512 +            return false;
23513 +        }
23514 +        $this->log(LOG_INFO, 'checking for queued notices');
23515 +        $transport = $this->transport();
23516 +        do {
23517 +            $qi = Queue_item::top($transport);
23518 +            if ($qi) {
23519 +                $this->log(LOG_INFO, 'Got item enqueued '.common_exact_date($qi->created));
23520 +                $notice = Notice::staticGet($qi->notice_id);
23521 +                if ($notice) {
23522 +                    $this->log(LOG_INFO, 'broadcasting notice ID = ' . $notice->id);
23523 +                    # XXX: what to do if broadcast fails?
23524 +                    $result = $this->handle_notice($notice);
23525 +                    if (!$result) {
23526 +                        $this->log(LOG_WARNING, 'Failed broadcast for notice ID = ' . $notice->id);
23527 +                        $orig = $qi;
23528 +                        $qi->claimed = NULL;
23529 +                        $qi->update($orig);
23530 +                        $this->log(LOG_WARNING, 'Abandoned claim for notice ID = ' . $notice->id);
23531 +                        continue;
23532 +                    }
23533 +                    $this->log(LOG_INFO, 'finished broadcasting notice ID = ' . $notice->id);
23534 +                    $notice->free();
23535 +                    unset($notice);
23536 +                    $notice = NULL;
23537 +                } else {
23538 +                    $this->log(LOG_WARNING, 'queue item for notice that does not exist');
23539 +                }
23540 +                $qi->delete();
23541 +                $qi->free();
23542 +                unset($qi);
23543 +                $this->idle(0);
23544 +            } else {
23545 +                $this->clear_old_claims();
23546 +                $this->idle(5);
23547 +            }    
23548 +        } while (true);
23549 +        if (!$this->finish()) {
23550 +            return false;
23551 +        }
23552 +        return true;
23553 +    }
23554 hunk ./lib/queuehandler.php 113
23555 -       function idle($timeout=0) {
23556 -               if ($timeout>0) {
23557 -                       sleep($timeout);
23558 -               }
23559 -       }
23560 -       
23561 -       function clear_old_claims() {
23562 -               $qi = new Queue_item();
23563 -               $qi->transport = $this->transport();
23564 -               $qi->whereAdd('now() - claimed > '.CLAIM_TIMEOUT);
23565 -               $qi->update(DB_DATAOBJECT_WHEREADD_ONLY);
23566 -               $qi->free();
23567 -               unset($qi);
23568 -       }
23569 -       
23570 -       function log($level, $msg) {
23571 -               common_log($level, $this->class_name() . ' ('. $this->get_id() .'): '.$msg);
23572 -       }
23573 +    function idle($timeout=0) {
23574 +        if ($timeout>0) {
23575 +            sleep($timeout);
23576 +        }
23577 +    }
23578 +    
23579 +    function clear_old_claims() {
23580 +        $qi = new Queue_item();
23581 +        $qi->transport = $this->transport();
23582 +        $qi->whereAdd('now() - claimed > '.CLAIM_TIMEOUT);
23583 +        $qi->update(DB_DATAOBJECT_WHEREADD_ONLY);
23584 +        $qi->free();
23585 +        unset($qi);
23586 +    }
23587 +    
23588 +    function log($level, $msg) {
23589 +        common_log($level, $this->class_name() . ' ('. $this->get_id() .'): '.$msg);
23590 +    }
23591 hunk ./lib/queuehandler.php 132
23592 -       
23593 +    
23594 hunk ./lib/rssaction.php 26
23595 -       # This will contain the details of each feed item's author and be used to generate SIOC data.
23596 -       var $creators = array();
23597 +    # This will contain the details of each feed item's author and be used to generate SIOC data.
23598 +    var $creators = array();
23599 hunk ./lib/rssaction.php 29
23600 -       function is_readonly() {
23601 -               return true;
23602 -       }
23603 +    function is_readonly() {
23604 +        return true;
23605 +    }
23606 hunk ./lib/rssaction.php 33
23607 -       function handle($args) {
23608 -               parent::handle($args);
23609 -               $limit = (int) $this->trimmed('limit');
23610 -               if ($limit == 0) {
23611 -                       $limit = DEFAULT_RSS_LIMIT;
23612 -               }
23613 -               $this->show_rss($limit);
23614 -       }
23615 +    function handle($args) {
23616 +        parent::handle($args);
23617 +        $limit = (int) $this->trimmed('limit');
23618 +        if ($limit == 0) {
23619 +            $limit = DEFAULT_RSS_LIMIT;
23620 +        }
23621 +        $this->show_rss($limit);
23622 +    }
23623 hunk ./lib/rssaction.php 42
23624 -       function init() {
23625 -               return true;
23626 -       }
23627 +    function init() {
23628 +        return true;
23629 +    }
23630 hunk ./lib/rssaction.php 46
23631 -       function get_notices() {
23632 -               return array();
23633 -       }
23634 +    function get_notices() {
23635 +        return array();
23636 +    }
23637 hunk ./lib/rssaction.php 50
23638 -       function get_channel() {
23639 -               return array('url' => '',
23640 -                                        'title' => '',
23641 -                                        'link' => '',
23642 -                                        'description' => '');
23643 -       }
23644 +    function get_channel() {
23645 +        return array('url' => '',
23646 +                     'title' => '',
23647 +                     'link' => '',
23648 +                     'description' => '');
23649 +    }
23650 hunk ./lib/rssaction.php 57
23651 -       function get_image() {
23652 -               return NULL;
23653 -       }
23654 +    function get_image() {
23655 +        return NULL;
23656 +    }
23657 hunk ./lib/rssaction.php 61
23658 -       function show_rss($limit=0) {
23659 +    function show_rss($limit=0) {
23660 hunk ./lib/rssaction.php 63
23661 -               if (!$this->init()) {
23662 -                       return;
23663 -               }
23664 +        if (!$this->init()) {
23665 +            return;
23666 +        }
23667 hunk ./lib/rssaction.php 67
23668 -               $notices = $this->get_notices($limit);
23669 +        $notices = $this->get_notices($limit);
23670 hunk ./lib/rssaction.php 69
23671 -               $this->init_rss();
23672 -               $this->show_channel($notices);
23673 -               $this->show_image();
23674 +        $this->init_rss();
23675 +        $this->show_channel($notices);
23676 +        $this->show_image();
23677 hunk ./lib/rssaction.php 73
23678 -               foreach ($notices as $n) {
23679 -                       $this->show_item($n);
23680 -               }
23681 +        foreach ($notices as $n) {
23682 +            $this->show_item($n);
23683 +        }
23684 hunk ./lib/rssaction.php 77
23685 -               $this->show_creators();
23686 -               $this->end_rss();
23687 -       }
23688 +        $this->show_creators();
23689 +        $this->end_rss();
23690 +    }
23691 hunk ./lib/rssaction.php 81
23692 -       function show_channel($notices) {
23693 +    function show_channel($notices) {
23694 hunk ./lib/rssaction.php 83
23695 -               $channel = $this->get_channel();
23696 -               $image = $this->get_image();
23697 +        $channel = $this->get_channel();
23698 +        $image = $this->get_image();
23699 hunk ./lib/rssaction.php 86
23700 -               common_element_start('channel', array('rdf:about' => $channel['url']));
23701 -               common_element('title', NULL, $channel['title']);
23702 -               common_element('link', NULL, $channel['link']);
23703 -               common_element('description', NULL, $channel['description']);
23704 -               common_element('cc:licence', array('rdf:resource' => common_config('license','url')));
23705 +        common_element_start('channel', array('rdf:about' => $channel['url']));
23706 +        common_element('title', NULL, $channel['title']);
23707 +        common_element('link', NULL, $channel['link']);
23708 +        common_element('description', NULL, $channel['description']);
23709 +        common_element('cc:licence', array('rdf:resource' => common_config('license','url')));
23710 hunk ./lib/rssaction.php 92
23711 -               if ($image) {
23712 -                       common_element('image', array('rdf:resource' => $image));
23713 -               }
23714 +        if ($image) {
23715 +            common_element('image', array('rdf:resource' => $image));
23716 +        }
23717 hunk ./lib/rssaction.php 96
23718 -               common_element_start('items');
23719 -               common_element_start('rdf:Seq');
23720 +        common_element_start('items');
23721 +        common_element_start('rdf:Seq');
23722 hunk ./lib/rssaction.php 99
23723 -               foreach ($notices as $notice) {
23724 -                       common_element('sioct:MicroblogPost', array('rdf:resource' => $notice->uri));
23725 -               }
23726 +        foreach ($notices as $notice) {
23727 +            common_element('sioct:MicroblogPost', array('rdf:resource' => $notice->uri));
23728 +        }
23729 hunk ./lib/rssaction.php 103
23730 -               common_element_end('rdf:Seq');
23731 -               common_element_end('items');
23732 +        common_element_end('rdf:Seq');
23733 +        common_element_end('items');
23734 hunk ./lib/rssaction.php 106
23735 -               common_element_end('channel');
23736 -       }
23737 +        common_element_end('channel');
23738 +    }
23739 hunk ./lib/rssaction.php 109
23740 -       function show_image() {
23741 -               $image = $this->get_image();
23742 -               if ($image) {
23743 -                       $channel = $this->get_channel();
23744 -                       common_element_start('image', array('rdf:about' => $image));
23745 -                       common_element('title', NULL, $channel['title']);
23746 -                       common_element('link', NULL, $channel['link']);
23747 -                       common_element('url', NULL, $image);
23748 -                       common_element_end('image');
23749 -               }
23750 -       }
23751 +    function show_image() {
23752 +        $image = $this->get_image();
23753 +        if ($image) {
23754 +            $channel = $this->get_channel();
23755 +            common_element_start('image', array('rdf:about' => $image));
23756 +            common_element('title', NULL, $channel['title']);
23757 +            common_element('link', NULL, $channel['link']);
23758 +            common_element('url', NULL, $image);
23759 +            common_element_end('image');
23760 +        }
23761 +    }
23762 hunk ./lib/rssaction.php 121
23763 -       function show_item($notice) {
23764 -               $profile = Profile::staticGet($notice->profile_id);
23765 -               $nurl = common_local_url('shownotice', array('notice' => $notice->id));
23766 -               $creator_uri = common_profile_uri($profile);
23767 -               common_element_start('item', array('rdf:about' => $notice->uri));
23768 -               $title = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
23769 -               common_element('title', NULL, $title);
23770 -               common_element('link', NULL, $nurl);
23771 -               common_element('description', NULL, $profile->nickname."'s status on ".common_exact_date($notice->created));
23772 -               common_element('dc:date', NULL, common_date_w3dtf($notice->created));
23773 -               common_element('dc:creator', NULL, ($profile->fullname) ? $profile->fullname : $profile->nickname);
23774 -               common_element('sioc:has_creator', array('rdf:resource' => $creator_uri));
23775 -               common_element('laconica:postIcon', array('rdf:resource' => common_profile_avatar_url($profile)));
23776 -               common_element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
23777 -               common_element_end('item');
23778 -               $this->creators[$creator_uri] = $profile;
23779 -       }
23780 +    function show_item($notice) {
23781 +        $profile = Profile::staticGet($notice->profile_id);
23782 +        $nurl = common_local_url('shownotice', array('notice' => $notice->id));
23783 +        $creator_uri = common_profile_uri($profile);
23784 +        common_element_start('item', array('rdf:about' => $notice->uri));
23785 +        $title = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
23786 +        common_element('title', NULL, $title);
23787 +        common_element('link', NULL, $nurl);
23788 +        common_element('description', NULL, $profile->nickname."'s status on ".common_exact_date($notice->created));
23789 +        common_element('dc:date', NULL, common_date_w3dtf($notice->created));
23790 +        common_element('dc:creator', NULL, ($profile->fullname) ? $profile->fullname : $profile->nickname);
23791 +        common_element('sioc:has_creator', array('rdf:resource' => $creator_uri));
23792 +        common_element('laconica:postIcon', array('rdf:resource' => common_profile_avatar_url($profile)));
23793 +        common_element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
23794 +        common_element_end('item');
23795 +        $this->creators[$creator_uri] = $profile;
23796 +    }
23797 hunk ./lib/rssaction.php 139
23798 -       function show_creators() {
23799 -               foreach ($this->creators as $uri => $profile) {
23800 -                       $id = $profile->id;
23801 -                       $nickname = $profile->nickname;
23802 -                       common_element_start('sioc:User', array('rdf:about' => $uri));
23803 -                       common_element('foaf:nick', NULL, $nickname);
23804 -                       if ($profile->fullname) {
23805 -                               common_element('foaf:name', NULL, $profile->fullname);
23806 -                       }
23807 -                       common_element('sioc:id', NULL, $id);
23808 -                       $avatar = common_profile_avatar_url($profile);
23809 -                       common_element('sioc:avatar', array('rdf:resource' => $avatar));
23810 -                       common_element_end('sioc:User');
23811 -               }
23812 -       }
23813 +    function show_creators() {
23814 +        foreach ($this->creators as $uri => $profile) {
23815 +            $id = $profile->id;
23816 +            $nickname = $profile->nickname;
23817 +            common_element_start('sioc:User', array('rdf:about' => $uri));
23818 +            common_element('foaf:nick', NULL, $nickname);
23819 +            if ($profile->fullname) {
23820 +                common_element('foaf:name', NULL, $profile->fullname);
23821 +            }
23822 +            common_element('sioc:id', NULL, $id);
23823 +            $avatar = common_profile_avatar_url($profile);
23824 +            common_element('sioc:avatar', array('rdf:resource' => $avatar));
23825 +            common_element_end('sioc:User');
23826 +        }
23827 +    }
23828 hunk ./lib/rssaction.php 155
23829 -       function init_rss() {
23830 -               $channel = $this->get_channel();
23831 -               header('Content-Type: application/rdf+xml');
23832 +    function init_rss() {
23833 +        $channel = $this->get_channel();
23834 +        header('Content-Type: application/rdf+xml');
23835 hunk ./lib/rssaction.php 159
23836 -               common_start_xml();
23837 -               common_element_start('rdf:RDF', array('xmlns:rdf' =>
23838 -                                                                                         'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
23839 -                                                                                         'xmlns:dc' =>
23840 -                                                                                         'http://purl.org/dc/elements/1.1/',
23841 -                                                                                         'xmlns:cc' =>
23842 -                                                                                         'http://web.resource.org/cc/',
23843 +        common_start_xml();
23844 +        common_element_start('rdf:RDF', array('xmlns:rdf' =>
23845 +                                              'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
23846 +                                              'xmlns:dc' =>
23847 +                                              'http://purl.org/dc/elements/1.1/',
23848 +                                              'xmlns:cc' =>
23849 +                                              'http://web.resource.org/cc/',
23850 hunk ./lib/rssaction.php 168
23851 -                                                                                         'xmlns:foaf' =>
23852 -                                                                                         'http://xmlns.com/foaf/0.1/',
23853 -                                                                                         'xmlns:sioc' =>
23854 -                                                                                         'http://rdfs.org/sioc/ns#',
23855 -                                                     'xmlns:sioct' =>
23856 -                                                     'http://rdfs.org/sioc/types#',
23857 -                                                     'xmlns:laconica' =>
23858 -                                                     'http://laconi.ca/ont/',
23859 -                                                                                         'xmlns' => 'http://purl.org/rss/1.0/'));
23860 -               common_element_start('sioc:Site', array('rdf:about' => common_root_url()));
23861 -               common_element('sioc:name', NULL, common_config('site', 'name'));
23862 -               common_element_start('sioc:container_of');
23863 -               common_element('sioc:Container', array('rdf:about' =>
23864 -                                                      $channel['url']));
23865 -               common_element_end('sioc:container_of');
23866 -               common_element_end('sioc:Site');
23867 -       }
23868 +                                              'xmlns:foaf' =>
23869 +                                              'http://xmlns.com/foaf/0.1/',
23870 +                                              'xmlns:sioc' =>
23871 +                                              'http://rdfs.org/sioc/ns#',
23872 +                                              'xmlns:sioct' =>
23873 +                                              'http://rdfs.org/sioc/types#',
23874 +                                              'xmlns:laconica' =>
23875 +                                              'http://laconi.ca/ont/',
23876 +                                              'xmlns' => 'http://purl.org/rss/1.0/'));
23877 +        common_element_start('sioc:Site', array('rdf:about' => common_root_url()));
23878 +        common_element('sioc:name', NULL, common_config('site', 'name'));
23879 +        common_element_start('sioc:container_of');
23880 +        common_element('sioc:Container', array('rdf:about' =>
23881 +                                               $channel['url']));
23882 +        common_element_end('sioc:container_of');
23883 +        common_element_end('sioc:Site');
23884 +    }
23885 hunk ./lib/rssaction.php 186
23886 -       function end_rss() {
23887 -               common_element_end('rdf:RDF');
23888 -       }
23889 +    function end_rss() {
23890 +        common_element_end('rdf:RDF');
23891 +    }
23892 hunk ./lib/search_engines.php 101
23893 -                                                  'against (\''.addslashes($q).'\')');
23894 +                           'against (\''.addslashes($q).'\')');
23895 hunk ./lib/search_engines.php 104
23896 -                                                  'against (\''.addslashes($q).'\')');
23897 +                           'against (\''.addslashes($q).'\')');
23898 hunk ./lib/searchaction.php 24
23899 -       function is_readonly() {
23900 -               return true;
23901 -       }
23902 +    function is_readonly() {
23903 +        return true;
23904 +    }
23905 hunk ./lib/searchaction.php 28
23906 -       function handle($args) {
23907 -               parent::handle($args);
23908 -               $this->show_form();
23909 -       }
23910 +    function handle($args) {
23911 +        parent::handle($args);
23912 +        $this->show_form();
23913 +    }
23914 hunk ./lib/searchaction.php 33
23915 -       function show_top($arr=NULL) {
23916 -               if ($arr) {
23917 -                       $error = $arr[1];
23918 -               }
23919 -               if ($error) {
23920 -                       common_element('p', 'error', $error);
23921 -               } else {
23922 -                       $instr = $this->get_instructions();
23923 -                       $output = common_markup_to_html($instr);
23924 -                       common_element_start('div', 'instructions');
23925 -                       common_raw($output);
23926 -                       common_element_end('div');
23927 -               }
23928 -               $this->search_menu();
23929 -       }
23930 +    function show_top($arr=NULL) {
23931 +        if ($arr) {
23932 +            $error = $arr[1];
23933 +        }
23934 +        if ($error) {
23935 +            common_element('p', 'error', $error);
23936 +        } else {
23937 +            $instr = $this->get_instructions();
23938 +            $output = common_markup_to_html($instr);
23939 +            common_element_start('div', 'instructions');
23940 +            common_raw($output);
23941 +            common_element_end('div');
23942 +        }
23943 +        $this->search_menu();
23944 +    }
23945 hunk ./lib/searchaction.php 49
23946 -       function get_title() {
23947 -               return NULL;
23948 -       }
23949 +    function get_title() {
23950 +        return NULL;
23951 +    }
23952 hunk ./lib/searchaction.php 53
23953 -       function show_header($arr) {
23954 -               return;
23955 -       }
23956 +    function show_header($arr) {
23957 +        return;
23958 +    }
23959 hunk ./lib/searchaction.php 57
23960 -       function show_form($error=NULL) {
23961 -               global $config;
23962 +    function show_form($error=NULL) {
23963 +        global $config;
23964 hunk ./lib/searchaction.php 60
23965 -               $q = $this->trimmed('q');
23966 -               $page = $this->trimmed('page', 1);
23967 +        $q = $this->trimmed('q');
23968 +        $page = $this->trimmed('page', 1);
23969 hunk ./lib/searchaction.php 63
23970 -               common_show_header($this->get_title(), array($this, 'show_header'), array($q, $error),
23971 -                                                  array($this, 'show_top'));
23972 -               common_element_start('form', array('method' => 'get',
23973 -                                                                                  'id' => 'login',
23974 -                                                                                  'action' => common_local_url($this->trimmed('action'))));
23975 -               common_element_start('p');
23976 -               if (!isset($config['site']['fancy']) || !$config['site']['fancy']) {
23977 -                       common_element('input', array('name' => 'action',
23978 -                                                                                 'type' => 'hidden',
23979 -                                                                                 'value' => $this->trimmed('action')));
23980 -               }
23981 -               common_element('input', array('name' => 'q',
23982 -                                                                         'id' => 'q',
23983 -                                                                         'type' => 'text',
23984 -                                                                         'class' => 'input_text',
23985 -                                                                         'value' => ($q) ? $q : ''));
23986 -               common_text(' ');
23987 -               common_element('input', array('type' => 'submit',
23988 -                                                                         'id' => 'search',
23989 -                                                                         'name' => 'search',
23990 -                                                                         'class' => 'submit',
23991 -                                                                         'value' => _('Search')));
23992 +        common_show_header($this->get_title(), array($this, 'show_header'), array($q, $error),
23993 +                           array($this, 'show_top'));
23994 +        common_element_start('form', array('method' => 'get',
23995 +                                           'id' => 'login',
23996 +                                           'action' => common_local_url($this->trimmed('action'))));
23997 +        common_element_start('p');
23998 +        if (!isset($config['site']['fancy']) || !$config['site']['fancy']) {
23999 +            common_element('input', array('name' => 'action',
24000 +                                          'type' => 'hidden',
24001 +                                          'value' => $this->trimmed('action')));
24002 +        }
24003 +        common_element('input', array('name' => 'q',
24004 +                                      'id' => 'q',
24005 +                                      'type' => 'text',
24006 +                                      'class' => 'input_text',
24007 +                                      'value' => ($q) ? $q : ''));
24008 +        common_text(' ');
24009 +        common_element('input', array('type' => 'submit',
24010 +                                      'id' => 'search',
24011 +                                      'name' => 'search',
24012 +                                      'class' => 'submit',
24013 +                                      'value' => _('Search')));
24014 hunk ./lib/searchaction.php 86
24015 -               common_element_end('p');
24016 -               common_element_end('form');
24017 -               if ($q) {
24018 -                       $this->show_results($q, $page);
24019 -               }
24020 -               common_show_footer();
24021 -       }
24022 +        common_element_end('p');
24023 +        common_element_end('form');
24024 +        if ($q) {
24025 +            $this->show_results($q, $page);
24026 +        }
24027 +        common_show_footer();
24028 +    }
24029 hunk ./lib/searchaction.php 94
24030 -       function search_menu() {
24031 -               # action => array('prompt', 'title', $args)
24032 -               $action = $this->trimmed('action');
24033 -               $menu =
24034 -                 array('peoplesearch' =>
24035 -                               array(
24036 -                                         _('People'),
24037 -                                         _('Find people on this site'),
24038 -                                         ($action != 'peoplesearch' && $this->trimmed('q')) ? array('q' => $this->trimmed('q')) : NULL),
24039 -                               'noticesearch' =>
24040 -                               array( _('Text'),
24041 -                                          _('Find content of notices'),
24042 -                                          ($action != 'noticesearch' && $this->trimmed('q')) ? array('q' => $this->trimmed('q')) : NULL)
24043 -                               );
24044 -               $this->nav_menu($menu);
24045 -       }
24046 +    function search_menu() {
24047 +        # action => array('prompt', 'title', $args)
24048 +        $action = $this->trimmed('action');
24049 +        $menu =
24050 +          array('peoplesearch' =>
24051 +                array(
24052 +                      _('People'),
24053 +                      _('Find people on this site'),
24054 +                      ($action != 'peoplesearch' && $this->trimmed('q')) ? array('q' => $this->trimmed('q')) : NULL),
24055 +                'noticesearch' =>
24056 +                array( _('Text'),
24057 +                       _('Find content of notices'),
24058 +                       ($action != 'noticesearch' && $this->trimmed('q')) ? array('q' => $this->trimmed('q')) : NULL)
24059 +                );
24060 +        $this->nav_menu($menu);
24061 +    }
24062 hunk ./lib/settingsaction.php 30
24063 -               # Cookie theft means that automatic logins can't
24064 -               # change important settings or see private info, and
24065 -               # _all_ our settings are important
24066 +            # Cookie theft means that automatic logins can't
24067 +            # change important settings or see private info, and
24068 +            # _all_ our settings are important
24069 hunk ./lib/settingsaction.php 58
24070 -       function form_header($title, $msg=NULL, $success=false) {
24071 -               common_show_header($title,
24072 -                                  NULL,
24073 -                                  array($msg, $success),
24074 -                                                  array($this, 'show_top'));
24075 -       }
24076 +    function form_header($title, $msg=NULL, $success=false) {
24077 +        common_show_header($title,
24078 +                           NULL,
24079 +                           array($msg, $success),
24080 +                           array($this, 'show_top'));
24081 +    }
24082 hunk ./lib/settingsaction.php 65
24083 -       function show_top($arr) {
24084 -               $msg = $arr[0];
24085 -               $success = $arr[1];
24086 -               if ($msg) {
24087 -                       $this->message($msg, $success);
24088 -               } else {
24089 -                       $inst = $this->get_instructions();
24090 -                       $output = common_markup_to_html($inst);
24091 -                       common_element_start('div', 'instructions');
24092 -                       common_raw($output);
24093 -                       common_element_end('div');
24094 -               }
24095 -               $this->settings_menu();
24096 -       }
24097 +    function show_top($arr) {
24098 +        $msg = $arr[0];
24099 +        $success = $arr[1];
24100 +        if ($msg) {
24101 +            $this->message($msg, $success);
24102 +        } else {
24103 +            $inst = $this->get_instructions();
24104 +            $output = common_markup_to_html($inst);
24105 +            common_element_start('div', 'instructions');
24106 +            common_raw($output);
24107 +            common_element_end('div');
24108 +        }
24109 +        $this->settings_menu();
24110 +    }
24111 hunk ./lib/settingsaction.php 82
24112 -               $menu =
24113 -                 array('profilesettings' =>
24114 -                               array(_('Profile'),
24115 -                                         _('Change your profile settings')),
24116 -                               'emailsettings' =>
24117 -                               array(_('Email'),
24118 -                                         _('Change email handling')),
24119 -                               'openidsettings' =>
24120 -                               array(_('OpenID'),
24121 -                                         _('Add or remove OpenIDs')),
24122 -                               'smssettings' =>
24123 -                               array(_('SMS'),
24124 -                                         _('Updates by SMS')),
24125 -                               'imsettings' =>
24126 -                               array(_('IM'),
24127 -                                         _('Updates by instant messenger (IM)')),
24128 -                               'twittersettings' =>
24129 -                               array(_('Twitter'),
24130 -                                         _('Twitter integration options')),
24131 -                               'othersettings' =>
24132 -                               array(_('Other'),
24133 -                                         _('Other options')));
24134 -               
24135 +        $menu =
24136 +          array('profilesettings' =>
24137 +                array(_('Profile'),
24138 +                      _('Change your profile settings')),
24139 +                'emailsettings' =>
24140 +                array(_('Email'),
24141 +                      _('Change email handling')),
24142 +                'openidsettings' =>
24143 +                array(_('OpenID'),
24144 +                      _('Add or remove OpenIDs')),
24145 +                'smssettings' =>
24146 +                array(_('SMS'),
24147 +                      _('Updates by SMS')),
24148 +                'imsettings' =>
24149 +                array(_('IM'),
24150 +                      _('Updates by instant messenger (IM)')),
24151 +                'twittersettings' =>
24152 +                array(_('Twitter'),
24153 +                      _('Twitter integration options')),
24154 +                'othersettings' =>
24155 +                array(_('Other'),
24156 +                      _('Other options')));
24157 +        
24158 hunk ./lib/settingsaction.php 108
24159 -                       if ($menuaction == 'imsettings' &&
24160 -                               !common_config('xmpp', 'enabled')) {
24161 -                               continue;
24162 -                       }
24163 +            if ($menuaction == 'imsettings' &&
24164 +                !common_config('xmpp', 'enabled')) {
24165 +                continue;
24166 +            }
24167 hunk ./lib/stream.php 13
24168 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
24169 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
24170 hunk ./lib/stream.php 17
24171 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
24172 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
24173 hunk ./lib/stream.php 27
24174 -       function public_views_menu() {
24175 +    function public_views_menu() {
24176 hunk ./lib/stream.php 29
24177 -               $action = $this->trimmed('action');
24178 +        $action = $this->trimmed('action');
24179 hunk ./lib/stream.php 31
24180 -               common_element_start('ul', array('id' => 'nav_views'));
24181 +        common_element_start('ul', array('id' => 'nav_views'));
24182 hunk ./lib/stream.php 33
24183 -               common_menu_item(common_local_url('public'), _('Public'),
24184 -                       _('Public timeline'), $action == 'public');
24185 +        common_menu_item(common_local_url('public'), _('Public'),
24186 +            _('Public timeline'), $action == 'public');
24187 hunk ./lib/stream.php 36
24188 -               common_menu_item(common_local_url('tag'), _('Recent tags'),
24189 -                       _('Recent tags'), $action == 'tag');
24190 +        common_menu_item(common_local_url('tag'), _('Recent tags'),
24191 +            _('Recent tags'), $action == 'tag');
24192 hunk ./lib/stream.php 39
24193 -               if (count(common_config('nickname', 'featured')) > 0) {
24194 -                       common_menu_item(common_local_url('featured'), _('Featured'),
24195 -                               _('Featured users'), $action == 'featured');
24196 -               }
24197 +        if (count(common_config('nickname', 'featured')) > 0) {
24198 +            common_menu_item(common_local_url('featured'), _('Featured'),
24199 +                _('Featured users'), $action == 'featured');
24200 +        }
24201 hunk ./lib/stream.php 44
24202 -               common_menu_item(common_local_url('favorited'), _('Popular'),
24203 -                       _("Popular notices"), $action == 'favorited');
24204 +        common_menu_item(common_local_url('favorited'), _('Popular'),
24205 +            _("Popular notices"), $action == 'favorited');
24206 hunk ./lib/stream.php 47
24207 -               common_element_end('ul');
24208 +        common_element_end('ul');
24209 hunk ./lib/stream.php 49
24210 -       }
24211 +    }
24212 hunk ./lib/subs.php 30
24213 -       $other = User::staticGet('nickname', $other_nickname);
24214 +    $other = User::staticGet('nickname', $other_nickname);
24215 hunk ./lib/subs.php 32
24216 -       if (!$other) {
24217 -               return _('No such user.');
24218 -       }
24219 +    if (!$other) {
24220 +        return _('No such user.');
24221 +    }
24222 hunk ./lib/subs.php 36
24223 -       return subs_subscribe_to($user, $other);
24224 +    return subs_subscribe_to($user, $other);
24225 hunk ./lib/subs.php 46
24226 -       if ($user->isSubscribed($other)) {
24227 -               return _('Already subscribed!.');
24228 -       }
24229 +    if ($user->isSubscribed($other)) {
24230 +        return _('Already subscribed!.');
24231 +    }
24232 hunk ./lib/subs.php 51
24233 -               return _('User has blocked you.');
24234 +        return _('User has blocked you.');
24235 hunk ./lib/subs.php 54
24236 -       if (!$user->subscribeTo($other)) {
24237 -               return _('Could not subscribe.');
24238 -               return;
24239 -       }
24240 +    if (!$user->subscribeTo($other)) {
24241 +        return _('Could not subscribe.');
24242 +        return;
24243 +    }
24244 hunk ./lib/subs.php 61
24245 -       if (common_config('memcached', 'enabled')) {
24246 -               $cache = new Memcache();
24247 -               if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
24248 -                       $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
24249 -               }
24250 -       }
24251 +    if (common_config('memcached', 'enabled')) {
24252 +        $cache = new Memcache();
24253 +        if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
24254 +            $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
24255 +        }
24256 +    }
24257 hunk ./lib/subs.php 68
24258 -       if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) {
24259 -               if (!$other->subscribeTo($user)) {
24260 -                       return _('Could not subscribe other to you.');
24261 -               }
24262 -               if (common_config('memcached', 'enabled')) {
24263 -                       $cache = new Memcache();
24264 -                       if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
24265 -                               $cache->delete(common_cache_key('user:notices_with_friends:' . $other->id));
24266 -                       }
24267 -               }
24268 +    if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) {
24269 +        if (!$other->subscribeTo($user)) {
24270 +            return _('Could not subscribe other to you.');
24271 +        }
24272 +        if (common_config('memcached', 'enabled')) {
24273 +            $cache = new Memcache();
24274 +            if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
24275 +                $cache->delete(common_cache_key('user:notices_with_friends:' . $other->id));
24276 +            }
24277 +        }
24278 hunk ./lib/subs.php 79
24279 -               subs_notify($user, $other);
24280 -       }
24281 +        subs_notify($user, $other);
24282 +    }
24283 hunk ./lib/subs.php 82
24284 -       return true;
24285 +    return true;
24286 hunk ./lib/subs.php 86
24287 -       # XXX: add other notifications (Jabber, SMS) here
24288 -       # XXX: queue this and handle it offline
24289 -       # XXX: Whatever happens, do it in Twitter-like API, too
24290 -       subs_notify_email($listenee, $listener);
24291 +    # XXX: add other notifications (Jabber, SMS) here
24292 +    # XXX: queue this and handle it offline
24293 +    # XXX: Whatever happens, do it in Twitter-like API, too
24294 +    subs_notify_email($listenee, $listener);
24295 hunk ./lib/subs.php 93
24296 -       mail_subscribe_notify($listenee, $listener);
24297 +    mail_subscribe_notify($listenee, $listener);
24298 hunk ./lib/subs.php 102
24299 -       $other = User::staticGet('nickname', $other_nickname);
24300 +    $other = User::staticGet('nickname', $other_nickname);
24301 hunk ./lib/subs.php 104
24302 -       if (!$other) {
24303 -               return _('No such user.');
24304 -       }
24305 +    if (!$other) {
24306 +        return _('No such user.');
24307 +    }
24308 hunk ./lib/subs.php 108
24309 -       return subs_unsubscribe_to($user, $other->getProfile());
24310 +    return subs_unsubscribe_to($user, $other->getProfile());
24311 hunk ./lib/subs.php 116
24312 -       if (!$user->isSubscribed($other))
24313 -               return _('Not subscribed!.');
24314 +    if (!$user->isSubscribed($other))
24315 +        return _('Not subscribed!.');
24316 hunk ./lib/subs.php 119
24317 -       $sub = DB_DataObject::factory('subscription');
24318 +    $sub = DB_DataObject::factory('subscription');
24319 hunk ./lib/subs.php 121
24320 -       $sub->subscriber = $user->id;
24321 -       $sub->subscribed = $other->id;
24322 +    $sub->subscriber = $user->id;
24323 +    $sub->subscribed = $other->id;
24324 hunk ./lib/subs.php 124
24325 -       $sub->find(true);
24326 +    $sub->find(true);
24327 hunk ./lib/subs.php 126
24328 -       // note we checked for existence above
24329 +    // note we checked for existence above
24330 hunk ./lib/subs.php 128
24331 -       if (!$sub->delete())
24332 -               return _('Couldn\'t delete subscription.');
24333 +    if (!$sub->delete())
24334 +        return _('Couldn\'t delete subscription.');
24335 hunk ./lib/subs.php 131
24336 -       if (common_config('memcached', 'enabled')) {
24337 -               $cache = new Memcache();
24338 -               if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
24339 -                       $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
24340 -               }
24341 -       }
24342 +    if (common_config('memcached', 'enabled')) {
24343 +        $cache = new Memcache();
24344 +        if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
24345 +            $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
24346 +        }
24347 +    }
24348 hunk ./lib/subs.php 138
24349 -       return true;
24350 +    return true;
24351 hunk ./lib/theme.php 23
24352 -       $theme = common_config('site', 'theme');
24353 -       return INSTALLDIR.'/theme/'.$theme.'/'.$relative;
24354 +    $theme = common_config('site', 'theme');
24355 +    return INSTALLDIR.'/theme/'.$theme.'/'.$relative;
24356 hunk ./lib/theme.php 28
24357 -       $theme = common_config('site', 'theme');
24358 -       $server = common_config('theme', 'server');
24359 -       if ($server) {
24360 -               return 'http://'.$server.'/'.$theme.'/'.$relative;
24361 -       } else {
24362 -               return common_path('theme/'.$theme.'/'.$relative);
24363 -       }
24364 +    $theme = common_config('site', 'theme');
24365 +    $server = common_config('theme', 'server');
24366 +    if ($server) {
24367 +        return 'http://'.$server.'/'.$theme.'/'.$relative;
24368 +    } else {
24369 +        return common_path('theme/'.$theme.'/'.$relative);
24370 +    }
24371 hunk ./lib/twitter.php 24
24372 -       $options = array(
24373 -                       CURLOPT_USERPWD => sprintf("%s:%s", $screen_name, $password),
24374 -                       CURLOPT_RETURNTRANSFER  => true,
24375 -                       CURLOPT_FAILONERROR             => true,
24376 -                       CURLOPT_HEADER                  => false,
24377 -                       CURLOPT_FOLLOWLOCATION  => true,
24378 -                       // CURLOPT_USERAGENT            => "identi.ca",
24379 -                       CURLOPT_CONNECTTIMEOUT  => 120,
24380 -                       CURLOPT_TIMEOUT                 => 120
24381 -       );
24382 +    $options = array(
24383 +            CURLOPT_USERPWD => sprintf("%s:%s", $screen_name, $password),
24384 +            CURLOPT_RETURNTRANSFER    => true,
24385 +            CURLOPT_FAILONERROR        => true,
24386 +            CURLOPT_HEADER            => false,
24387 +            CURLOPT_FOLLOWLOCATION    => true,
24388 +            // CURLOPT_USERAGENT        => "identi.ca",
24389 +            CURLOPT_CONNECTTIMEOUT    => 120,
24390 +            CURLOPT_TIMEOUT            => 120
24391 +    );
24392 hunk ./lib/twitter.php 36
24393 -       $ch = curl_init($uri);
24394 +    $ch = curl_init($uri);
24395 hunk ./lib/twitter.php 41
24396 -       if ($errmsg) {
24397 -               common_debug("Twitter bridge - cURL error: $errmsg - trying to load: $uri with user $twit_user.",
24398 -                       __FILE__);
24399 -       }
24400 +    if ($errmsg) {
24401 +        common_debug("Twitter bridge - cURL error: $errmsg - trying to load: $uri with user $twit_user.",
24402 +            __FILE__);
24403 +    }
24404 hunk ./lib/twitter.php 46
24405 -       curl_close($ch);
24406 +    curl_close($ch);
24407 hunk ./lib/twitter.php 48
24408 -       return $data;
24409 +    return $data;
24410 hunk ./lib/twitter.php 53
24411 -       $uri = "http://twitter.com/users/show/$screen_name.json";
24412 -       $data = get_twitter_data($uri, $screen_name, $password);
24413 +    $uri = "http://twitter.com/users/show/$screen_name.json";
24414 +    $data = get_twitter_data($uri, $screen_name, $password);
24415 hunk ./lib/twitter.php 56
24416 -       if (!$data) {
24417 -               return false;
24418 -       }
24419 +    if (!$data) {
24420 +        return false;
24421 +    }
24422 hunk ./lib/twitter.php 60
24423 -       $twit_user = json_decode($data);
24424 +    $twit_user = json_decode($data);
24425 hunk ./lib/twitter.php 62
24426 -       if (!$twit_user) {
24427 -               return false;
24428 -       }
24429 +    if (!$twit_user) {
24430 +        return false;
24431 +    }
24432 hunk ./lib/twitter.php 66
24433 -       return $twit_user;
24434 +    return $twit_user;
24435 hunk ./lib/twitter.php 71
24436 -       $original = clone($fuser);
24437 -       $fuser->nickname = $screen_name;
24438 -       $fuser->uri = 'http://twitter.com/' . $screen_name;
24439 -       $result = $fuser->updateKeys($original);
24440 +    $original = clone($fuser);
24441 +    $fuser->nickname = $screen_name;
24442 +    $fuser->uri = 'http://twitter.com/' . $screen_name;
24443 +    $result = $fuser->updateKeys($original);
24444 hunk ./lib/twitter.php 76
24445 -       if (!$result) {
24446 -               common_log_db_error($fuser, 'UPDATE', __FILE__);
24447 -               return false;
24448 -       }
24449 +    if (!$result) {
24450 +        common_log_db_error($fuser, 'UPDATE', __FILE__);
24451 +        return false;
24452 +    }
24453 hunk ./lib/twitter.php 81
24454 -       return true;
24455 +    return true;
24456 hunk ./lib/twitter.php 86
24457 -       // Otherwise, create a new Twitter user
24458 -       $fuser = DB_DataObject::factory('foreign_user');
24459 +    // Otherwise, create a new Twitter user
24460 +    $fuser = DB_DataObject::factory('foreign_user');
24461 hunk ./lib/twitter.php 89
24462 -       $fuser->nickname = $screen_name;
24463 -       $fuser->uri = 'http://twitter.com/' . $screen_name;
24464 -       $fuser->id = $twitter_id;
24465 -       $fuser->service = 1; // Twitter
24466 -       $fuser->created = common_sql_now();
24467 -       $result = $fuser->insert();
24468 +    $fuser->nickname = $screen_name;
24469 +    $fuser->uri = 'http://twitter.com/' . $screen_name;
24470 +    $fuser->id = $twitter_id;
24471 +    $fuser->service = 1; // Twitter
24472 +    $fuser->created = common_sql_now();
24473 +    $result = $fuser->insert();
24474 hunk ./lib/twitter.php 96
24475 -       if (!$result) {
24476 -               common_debug("Twitter bridge - failed to add new Twitter user: $twitter_id - $screen_name.");
24477 -               common_log_db_error($fuser, 'INSERT', __FILE__);
24478 -               return false;
24479 -       }
24480 +    if (!$result) {
24481 +        common_debug("Twitter bridge - failed to add new Twitter user: $twitter_id - $screen_name.");
24482 +        common_log_db_error($fuser, 'INSERT', __FILE__);
24483 +        return false;
24484 +    }
24485 hunk ./lib/twitter.php 102
24486 -       common_debug("Twitter bridge - Added new Twitter user: $screen_name ($twitter_id).");
24487 +    common_debug("Twitter bridge - Added new Twitter user: $screen_name ($twitter_id).");
24488 hunk ./lib/twitter.php 104
24489 -       return true;
24490 +    return true;
24491 hunk ./lib/twitter.php 110
24492 -       // Check to see whether the Twitter user is already in the system,
24493 -       // and update its screen name and uri if so.
24494 -       $fuser = Foreign_user::getForeignUser($twitter_id, 1);
24495 +    // Check to see whether the Twitter user is already in the system,
24496 +    // and update its screen name and uri if so.
24497 +    $fuser = Foreign_user::getForeignUser($twitter_id, 1);
24498 hunk ./lib/twitter.php 114
24499 -       if ($fuser) {
24500 +    if ($fuser) {
24501 hunk ./lib/twitter.php 116
24502 -               // Only update if Twitter screen name has changed
24503 -               if ($fuser->nickname != $screen_name) {
24504 +        // Only update if Twitter screen name has changed
24505 +        if ($fuser->nickname != $screen_name) {
24506 hunk ./lib/twitter.php 119
24507 -                       common_debug('Twitter bridge - Updated nickname (and URI) for Twitter user ' .
24508 -                               "$fuser->id to $screen_name, was $fuser->nickname");
24509 +            common_debug('Twitter bridge - Updated nickname (and URI) for Twitter user ' .
24510 +                "$fuser->id to $screen_name, was $fuser->nickname");
24511 hunk ./lib/twitter.php 122
24512 -                       return update_twitter_user($fuser, $twitter_id, $screen_name);
24513 -               }
24514 +            return update_twitter_user($fuser, $twitter_id, $screen_name);
24515 +        }
24516 hunk ./lib/twitter.php 125
24517 -       } else {
24518 -               return add_twitter_user($twitter_id, $screen_name);
24519 -       }
24520 +    } else {
24521 +        return add_twitter_user($twitter_id, $screen_name);
24522 +    }
24523 hunk ./lib/twitter.php 129
24524 -       return true;
24525 +    return true;
24526 hunk ./lib/twitter.php 134
24527 -       $uri = "http://twitter.com/statuses/friends/$twitter_id.json?page=";
24528 -       $twitter_user = twitter_user_info($screen_name, $password);
24529 +    $uri = "http://twitter.com/statuses/friends/$twitter_id.json?page=";
24530 +    $twitter_user = twitter_user_info($screen_name, $password);
24531 hunk ./lib/twitter.php 137
24532 -       // Calculate how many pages to get...
24533 -       $pages = ceil($twitter_user->friends_count / 100);
24534 +    // Calculate how many pages to get...
24535 +    $pages = ceil($twitter_user->friends_count / 100);
24536 hunk ./lib/twitter.php 140
24537 -       if ($pages == 0) {
24538 -               common_debug("Twitter bridge - Twitter user $screen_name has no friends! Lame.");
24539 -       }
24540 +    if ($pages == 0) {
24541 +        common_debug("Twitter bridge - Twitter user $screen_name has no friends! Lame.");
24542 +    }
24543 hunk ./lib/twitter.php 144
24544 -       $friends = array();
24545 +    $friends = array();
24546 hunk ./lib/twitter.php 146
24547 -       for ($i = 1; $i <= $pages; $i++) {
24548 +    for ($i = 1; $i <= $pages; $i++) {
24549 hunk ./lib/twitter.php 148
24550 -               $data = get_twitter_data($uri . $i, $screen_name, $password);
24551 +        $data = get_twitter_data($uri . $i, $screen_name, $password);
24552 hunk ./lib/twitter.php 150
24553 -               if (!$data) {
24554 -                       return NULL;
24555 -               }
24556 +        if (!$data) {
24557 +            return NULL;
24558 +        }
24559 hunk ./lib/twitter.php 154
24560 -               $more_friends = json_decode($data);
24561 +        $more_friends = json_decode($data);
24562 hunk ./lib/twitter.php 156
24563 -               if (!$more_friends) {
24564 -                       return NULL;
24565 -               }
24566 +        if (!$more_friends) {
24567 +            return NULL;
24568 +        }
24569 hunk ./lib/twitter.php 160
24570 -               $friends = array_merge($friends, $more_friends);
24571 -       }
24572 +         $friends = array_merge($friends, $more_friends);
24573 +    }
24574 hunk ./lib/twitter.php 163
24575 -       return $friends;
24576 +    return $friends;
24577 hunk ./lib/twitter.php 168
24578 -       $friends = retreive_twitter_friends($twitter_id, $screen_name, $password);
24579 +    $friends = retreive_twitter_friends($twitter_id, $screen_name, $password);
24580 hunk ./lib/twitter.php 170
24581 -       if (is_null($friends)) {
24582 -               common_debug("Twitter bridge - Couldn't get friends data from Twitter.");
24583 -               return false;
24584 -       }
24585 +    if (is_null($friends)) {
24586 +        common_debug("Twitter bridge - Couldn't get friends data from Twitter.");
24587 +        return false;
24588 +    }
24589 hunk ./lib/twitter.php 177
24590 -               $friend_name = $friend->screen_name;
24591 -               $friend_id = $friend->id;
24592 +        $friend_name = $friend->screen_name;
24593 +        $friend_id = $friend->id;
24594 hunk ./lib/twitter.php 180
24595 -               // Update or create the Foreign_user record
24596 -               if (!save_twitter_user($friend_id, $friend_name)) {
24597 -                       return false;
24598 -               }
24599 +        // Update or create the Foreign_user record
24600 +        if (!save_twitter_user($friend_id, $friend_name)) {
24601 +            return false;
24602 +        }
24603 hunk ./lib/twitter.php 185
24604 -               // Check to see if there's a related local user
24605 -               $flink = Foreign_link::getByForeignID($friend_id, 1);
24606 +        // Check to see if there's a related local user
24607 +        $flink = Foreign_link::getByForeignID($friend_id, 1);
24608 hunk ./lib/twitter.php 188
24609 -               if ($flink) {
24610 +        if ($flink) {
24611 hunk ./lib/twitter.php 190
24612 -                       // Get associated user and subscribe her
24613 -                       $friend_user = User::staticGet('id', $flink->user_id);
24614 -                       subs_subscribe_to($user, $friend_user);
24615 -                       common_debug("Twitter bridge - subscribed $friend_user->nickname to $user->nickname.");
24616 -               }
24617 -       }
24618 +            // Get associated user and subscribe her
24619 +            $friend_user = User::staticGet('id', $flink->user_id);
24620 +            subs_subscribe_to($user, $friend_user);
24621 +            common_debug("Twitter bridge - subscribed $friend_user->nickname to $user->nickname.");
24622 +        }
24623 +    }
24624 hunk ./lib/twitter.php 197
24625 -       return true;
24626 +    return true;
24627 hunk ./lib/twitterapi.php 24
24628 -       var $auth_user;
24629 +    var $auth_user;
24630 hunk ./lib/twitterapi.php 26
24631 -       function handle($args) {
24632 -               parent::handle($args);
24633 -       }
24634 +    function handle($args) {
24635 +        parent::handle($args);
24636 +    }
24637 hunk ./lib/twitterapi.php 30
24638 -       function twitter_user_array($profile, $get_notice=false) {
24639 +    function twitter_user_array($profile, $get_notice=false) {
24640 hunk ./lib/twitterapi.php 32
24641 -               $twitter_user = array();
24642 +        $twitter_user = array();
24643 hunk ./lib/twitterapi.php 34
24644 -               $twitter_user['name'] = $profile->getBestName();
24645 -               $twitter_user['followers_count'] = $this->count_subscriptions($profile);
24646 -               $twitter_user['screen_name'] = $profile->nickname;
24647 -               $twitter_user['description'] = ($profile->bio) ? $profile->bio : NULL;
24648 -               $twitter_user['location'] = ($profile->location) ? $profile->location : NULL;
24649 -               $twitter_user['id'] = intval($profile->id);
24650 +        $twitter_user['name'] = $profile->getBestName();
24651 +        $twitter_user['followers_count'] = $this->count_subscriptions($profile);
24652 +        $twitter_user['screen_name'] = $profile->nickname;
24653 +        $twitter_user['description'] = ($profile->bio) ? $profile->bio : NULL;
24654 +        $twitter_user['location'] = ($profile->location) ? $profile->location : NULL;
24655 +        $twitter_user['id'] = intval($profile->id);
24656 hunk ./lib/twitterapi.php 41
24657 -               $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
24658 +        $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
24659 hunk ./lib/twitterapi.php 43
24660 -               $twitter_user['profile_image_url'] = ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE);
24661 -               $twitter_user['protected'] = 'false'; # not supported by Laconica yet
24662 -               $twitter_user['url'] = ($profile->homepage) ? $profile->homepage : NULL;
24663 +        $twitter_user['profile_image_url'] = ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE);
24664 +        $twitter_user['protected'] = 'false'; # not supported by Laconica yet
24665 +        $twitter_user['url'] = ($profile->homepage) ? $profile->homepage : NULL;
24666 hunk ./lib/twitterapi.php 47
24667 -               if ($get_notice) {
24668 -                       $notice = $profile->getCurrentNotice();
24669 -                       if ($notice) {
24670 -                               # don't get user!
24671 -                               $twitter_user['status'] = $this->twitter_status_array($notice, false);
24672 -                       }
24673 -               }
24674 +        if ($get_notice) {
24675 +            $notice = $profile->getCurrentNotice();
24676 +            if ($notice) {
24677 +                # don't get user!
24678 +                $twitter_user['status'] = $this->twitter_status_array($notice, false);
24679 +            }
24680 +        }
24681 hunk ./lib/twitterapi.php 55
24682 -               return $twitter_user;
24683 -       }
24684 +        return $twitter_user;
24685 +    }
24686 hunk ./lib/twitterapi.php 58
24687 -       function twitter_status_array($notice, $include_user=true) {
24688 +    function twitter_status_array($notice, $include_user=true) {
24689 hunk ./lib/twitterapi.php 60
24690 -               $profile = $notice->getProfile();
24691 +        $profile = $notice->getProfile();
24692 hunk ./lib/twitterapi.php 62
24693 -               $twitter_status = array();
24694 -               $twitter_status['text'] = $notice->content;
24695 -               $twitter_status['truncated'] = 'false'; # Not possible on Laconica
24696 -               $twitter_status['created_at'] = $this->date_twitter($notice->created);
24697 -               $twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ? intval($notice->reply_to) : NULL;
24698 -               $twitter_status['source'] = $this->source_link($notice->source);
24699 -               $twitter_status['id'] = intval($notice->id);
24700 -               $twitter_status['in_reply_to_user_id'] = ($notice->reply_to) ? $this->replier_by_reply(intval($notice->reply_to)) : NULL;
24701 +        $twitter_status = array();
24702 +        $twitter_status['text'] = $notice->content;
24703 +        $twitter_status['truncated'] = 'false'; # Not possible on Laconica
24704 +        $twitter_status['created_at'] = $this->date_twitter($notice->created);
24705 +        $twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ? intval($notice->reply_to) : NULL;
24706 +        $twitter_status['source'] = $this->source_link($notice->source);
24707 +        $twitter_status['id'] = intval($notice->id);
24708 +        $twitter_status['in_reply_to_user_id'] = ($notice->reply_to) ? $this->replier_by_reply(intval($notice->reply_to)) : NULL;
24709 hunk ./lib/twitterapi.php 71
24710 -               if (isset($this->auth_user)) {
24711 -                       $twitter_status['favorited'] = ($this->auth_user->hasFave($notice)) ? 'true' : 'false';
24712 -               } else {
24713 -                       $twitter_status['favorited'] = 'false';
24714 -               }
24715 +        if (isset($this->auth_user)) {
24716 +            $twitter_status['favorited'] = ($this->auth_user->hasFave($notice)) ? 'true' : 'false';
24717 +        } else {
24718 +            $twitter_status['favorited'] = 'false';
24719 +        }
24720 hunk ./lib/twitterapi.php 77
24721 -               if ($include_user) {
24722 -                       # Don't get notice (recursive!)
24723 -                       $twitter_user = $this->twitter_user_array($profile, false);
24724 -                       $twitter_status['user'] = $twitter_user;
24725 -               }
24726 +        if ($include_user) {
24727 +            # Don't get notice (recursive!)
24728 +            $twitter_user = $this->twitter_user_array($profile, false);
24729 +            $twitter_status['user'] = $twitter_user;
24730 +        }
24731 hunk ./lib/twitterapi.php 83
24732 -               return $twitter_status;
24733 -       }
24734 +        return $twitter_status;
24735 +    }
24736 hunk ./lib/twitterapi.php 86
24737 -       function twitter_rss_entry_array($notice) {
24738 +    function twitter_rss_entry_array($notice) {
24739 hunk ./lib/twitterapi.php 88
24740 -               $profile = $notice->getProfile();
24741 +        $profile = $notice->getProfile();
24742 hunk ./lib/twitterapi.php 90
24743 -               $server = common_config('site', 'server');
24744 -               $entry = array();
24745 +        $server = common_config('site', 'server');
24746 +        $entry = array();
24747 hunk ./lib/twitterapi.php 95
24748 -               $entry['content'] = common_xml_safe_str(trim($notice->rendered));
24749 -               $entry['title'] = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
24750 -               $entry['link'] = common_local_url('shownotice', array('notice' => $notice->id));
24751 -               $entry['published'] = common_date_iso8601($notice->created);
24752 -               $entry['id'] = "tag:$server,2008:$entry[link]";
24753 -               $entry['updated'] = $entry['published'];
24754 +        $entry['content'] = common_xml_safe_str(trim($notice->rendered));
24755 +        $entry['title'] = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
24756 +        $entry['link'] = common_local_url('shownotice', array('notice' => $notice->id));
24757 +        $entry['published'] = common_date_iso8601($notice->created);
24758 +        $entry['id'] = "tag:$server,2008:$entry[link]";
24759 +        $entry['updated'] = $entry['published'];
24760 hunk ./lib/twitterapi.php 102
24761 -               # RSS Item specific
24762 -               $entry['description'] = $entry['content'];
24763 -               $entry['pubDate'] = common_date_rfc2822($notice->created);
24764 -               $entry['guid'] = $entry['link'];
24765 +        # RSS Item specific
24766 +        $entry['description'] = $entry['content'];
24767 +        $entry['pubDate'] = common_date_rfc2822($notice->created);
24768 +        $entry['guid'] = $entry['link'];
24769 hunk ./lib/twitterapi.php 107
24770 -               return $entry;
24771 -       }
24772 +        return $entry;
24773 +    }
24774 hunk ./lib/twitterapi.php 110
24775 -       function twitter_rss_dmsg_array($message) {
24776 +    function twitter_rss_dmsg_array($message) {
24777 hunk ./lib/twitterapi.php 112
24778 -               $server = common_config('site', 'server');
24779 -               $entry = array();
24780 +        $server = common_config('site', 'server');
24781 +        $entry = array();
24782 hunk ./lib/twitterapi.php 115
24783 -               $entry['title'] = sprintf('Message from %s to %s',
24784 -                       $message->getFrom()->nickname, $message->getTo()->nickname);
24785 +        $entry['title'] = sprintf('Message from %s to %s',
24786 +            $message->getFrom()->nickname, $message->getTo()->nickname);
24787 hunk ./lib/twitterapi.php 118
24788 -               $entry['content'] = common_xml_safe_str(trim($message->content));
24789 -               $entry['link'] = common_local_url('showmessage', array('message' => $message->id));
24790 -               $entry['published'] = common_date_iso8601($message->created);
24791 -               $entry['id'] = "tag:$server,2008:$entry[link]";
24792 -               $entry['updated'] = $entry['published'];
24793 +        $entry['content'] = common_xml_safe_str(trim($message->content));
24794 +        $entry['link'] = common_local_url('showmessage', array('message' => $message->id));
24795 +        $entry['published'] = common_date_iso8601($message->created);
24796 +        $entry['id'] = "tag:$server,2008:$entry[link]";
24797 +        $entry['updated'] = $entry['published'];
24798 hunk ./lib/twitterapi.php 124
24799 -               # RSS Item specific
24800 -               $entry['description'] = $entry['content'];
24801 -               $entry['pubDate'] = common_date_rfc2822($message->created);
24802 -               $entry['guid'] = $entry['link'];
24803 +        # RSS Item specific
24804 +        $entry['description'] = $entry['content'];
24805 +        $entry['pubDate'] = common_date_rfc2822($message->created);
24806 +        $entry['guid'] = $entry['link'];
24807 hunk ./lib/twitterapi.php 129
24808 -               return $entry;
24809 -       }
24810 +        return $entry;
24811 +    }
24812 hunk ./lib/twitterapi.php 132
24813 -       function twitter_dmsg_array($message) {
24814 +    function twitter_dmsg_array($message) {
24815 hunk ./lib/twitterapi.php 134
24816 -               $twitter_dm = array();
24817 +        $twitter_dm = array();
24818 hunk ./lib/twitterapi.php 136
24819 -               $from_profile = $message->getFrom();
24820 -               $to_profile = $message->getTo();
24821 +        $from_profile = $message->getFrom();
24822 +        $to_profile = $message->getTo();
24823 hunk ./lib/twitterapi.php 139
24824 -               $twitter_dm['id'] = $message->id;
24825 -               $twitter_dm['sender_id'] = $message->from_profile;
24826 -               $twitter_dm['text'] = trim($message->content);
24827 -               $twitter_dm['recipient_id'] = $message->to_profile;
24828 -               $twitter_dm['created_at'] = $this->date_twitter($message->created);
24829 -               $twitter_dm['sender_screen_name'] = $from_profile->nickname;
24830 -               $twitter_dm['recipient_screen_name'] = $to_profile->nickname;
24831 -               $twitter_dm['sender'] = $this->twitter_user_array($from_profile, false);
24832 -               $twitter_dm['recipient'] = $this->twitter_user_array($to_profile, false);
24833 +        $twitter_dm['id'] = $message->id;
24834 +        $twitter_dm['sender_id'] = $message->from_profile;
24835 +        $twitter_dm['text'] = trim($message->content);
24836 +        $twitter_dm['recipient_id'] = $message->to_profile;
24837 +        $twitter_dm['created_at'] = $this->date_twitter($message->created);
24838 +        $twitter_dm['sender_screen_name'] = $from_profile->nickname;
24839 +        $twitter_dm['recipient_screen_name'] = $to_profile->nickname;
24840 +        $twitter_dm['sender'] = $this->twitter_user_array($from_profile, false);
24841 +        $twitter_dm['recipient'] = $this->twitter_user_array($to_profile, false);
24842 hunk ./lib/twitterapi.php 149
24843 -               return $twitter_dm;
24844 -       }
24845 +        return $twitter_dm;
24846 +    }
24847 hunk ./lib/twitterapi.php 152
24848 -       function show_twitter_xml_status($twitter_status) {
24849 -               common_element_start('status');
24850 -               foreach($twitter_status as $element => $value) {
24851 -                       switch ($element) {
24852 -                       case 'user':
24853 -                               $this->show_twitter_xml_user($twitter_status['user']);
24854 -                               break;
24855 -                       case 'text':
24856 -                               common_element($element, NULL, common_xml_safe_str($value));
24857 -                               break;
24858 -                       default:
24859 -                               common_element($element, NULL, $value);
24860 -                       }
24861 -               }
24862 -               common_element_end('status');
24863 -       }
24864 +    function show_twitter_xml_status($twitter_status) {
24865 +        common_element_start('status');
24866 +        foreach($twitter_status as $element => $value) {
24867 +            switch ($element) {
24868 +            case 'user':
24869 +                $this->show_twitter_xml_user($twitter_status['user']);
24870 +                break;
24871 +            case 'text':
24872 +                common_element($element, NULL, common_xml_safe_str($value));
24873 +                break;
24874 +            default:
24875 +                common_element($element, NULL, $value);
24876 +            }
24877 +        }
24878 +        common_element_end('status');
24879 +    }
24880 hunk ./lib/twitterapi.php 169
24881 -       function show_twitter_xml_user($twitter_user, $role='user') {
24882 -               common_element_start($role);
24883 -               foreach($twitter_user as $element => $value) {
24884 -                       if ($element == 'status') {
24885 -                               $this->show_twitter_xml_status($twitter_user['status']);
24886 -                       } else {
24887 -                               common_element($element, NULL, $value);
24888 -                       }
24889 -               }
24890 -               common_element_end($role);
24891 -       }
24892 +    function show_twitter_xml_user($twitter_user, $role='user') {
24893 +        common_element_start($role);
24894 +        foreach($twitter_user as $element => $value) {
24895 +            if ($element == 'status') {
24896 +                $this->show_twitter_xml_status($twitter_user['status']);
24897 +            } else {
24898 +                common_element($element, NULL, $value);
24899 +            }
24900 +        }
24901 +        common_element_end($role);
24902 +    }
24903 hunk ./lib/twitterapi.php 181
24904 -       function show_twitter_rss_item($entry) {
24905 -               common_element_start('item');
24906 -               common_element('title', NULL, $entry['title']);
24907 -               common_element('description', NULL, $entry['description']);
24908 -               common_element('pubDate', NULL, $entry['pubDate']);
24909 -               common_element('guid', NULL, $entry['guid']);
24910 -               common_element('link', NULL, $entry['link']);
24911 -               common_element_end('item');
24912 -       }
24913 +    function show_twitter_rss_item($entry) {
24914 +        common_element_start('item');
24915 +        common_element('title', NULL, $entry['title']);
24916 +        common_element('description', NULL, $entry['description']);
24917 +        common_element('pubDate', NULL, $entry['pubDate']);
24918 +        common_element('guid', NULL, $entry['guid']);
24919 +        common_element('link', NULL, $entry['link']);
24920 +        common_element_end('item');
24921 +    }
24922 hunk ./lib/twitterapi.php 191
24923 -       function show_twitter_atom_entry($entry) {
24924 -           common_element_start('entry');
24925 -               common_element('title', NULL, $entry['title']);
24926 -               common_element('content', array('type' => 'html'), $entry['content']);
24927 -               common_element('id', NULL, $entry['id']);
24928 -               common_element('published', NULL, $entry['published']);
24929 -               common_element('updated', NULL, $entry['updated']);
24930 -               common_element('link', array('href' => $entry['link'], 'rel' => 'alternate', 'type' => 'text/html'), NULL);
24931 -               common_element_end('entry');
24932 -       }
24933 +    function show_twitter_atom_entry($entry) {
24934 +        common_element_start('entry');
24935 +        common_element('title', NULL, $entry['title']);
24936 +        common_element('content', array('type' => 'html'), $entry['content']);
24937 +        common_element('id', NULL, $entry['id']);
24938 +        common_element('published', NULL, $entry['published']);
24939 +        common_element('updated', NULL, $entry['updated']);
24940 +        common_element('link', array('href' => $entry['link'], 'rel' => 'alternate', 'type' => 'text/html'), NULL);
24941 +        common_element_end('entry');
24942 +    }
24943 hunk ./lib/twitterapi.php 202
24944 -       function show_json_objects($objects) {
24945 -               print(json_encode($objects));
24946 -       }
24947 +    function show_json_objects($objects) {
24948 +        print(json_encode($objects));
24949 +    }
24950 hunk ./lib/twitterapi.php 206
24951 -       function show_single_xml_status($notice) {
24952 -               $this->init_document('xml');
24953 -               $twitter_status = $this->twitter_status_array($notice);
24954 -               $this->show_twitter_xml_status($twitter_status);
24955 -               $this->end_document('xml');
24956 -       }
24957 +    function show_single_xml_status($notice) {
24958 +        $this->init_document('xml');
24959 +        $twitter_status = $this->twitter_status_array($notice);
24960 +        $this->show_twitter_xml_status($twitter_status);
24961 +        $this->end_document('xml');
24962 +    }
24963 hunk ./lib/twitterapi.php 213
24964 -       function show_single_json_status($notice) {
24965 -               $this->init_document('json');
24966 -               $status = $this->twitter_status_array($notice);
24967 -               $this->show_json_objects($status);
24968 -               $this->end_document('json');
24969 -       }
24970 +    function show_single_json_status($notice) {
24971 +        $this->init_document('json');
24972 +        $status = $this->twitter_status_array($notice);
24973 +        $this->show_json_objects($status);
24974 +        $this->end_document('json');
24975 +    }
24976 hunk ./lib/twitterapi.php 220
24977 -       function show_single_xml_dmsg($message) {
24978 -               $this->init_document('xml');
24979 -               $dmsg = $this->twitter_dmsg_array($message);
24980 -               $this->show_twitter_xml_dmsg($dmsg);
24981 -               $this->end_document('xml');
24982 -       }
24983 +    function show_single_xml_dmsg($message) {
24984 +        $this->init_document('xml');
24985 +        $dmsg = $this->twitter_dmsg_array($message);
24986 +        $this->show_twitter_xml_dmsg($dmsg);
24987 +        $this->end_document('xml');
24988 +    }
24989 hunk ./lib/twitterapi.php 227
24990 -       function show_single_json_dmsg($message) {
24991 -               $this->init_document('json');
24992 -               $dmsg = $this->twitter_dmsg_array($message);
24993 -               $this->show_json_objects($dmsg);
24994 -               $this->end_document('json');
24995 -       }
24996 +    function show_single_json_dmsg($message) {
24997 +        $this->init_document('json');
24998 +        $dmsg = $this->twitter_dmsg_array($message);
24999 +        $this->show_json_objects($dmsg);
25000 +        $this->end_document('json');
25001 +    }
25002 hunk ./lib/twitterapi.php 234
25003 -       function show_twitter_xml_dmsg($twitter_dm) {
25004 -               common_element_start('direct_message');
25005 -               foreach($twitter_dm as $element => $value) {
25006 -                       switch ($element) {
25007 -                       case 'sender':
25008 -                       case 'recipient':
25009 -                               $this->show_twitter_xml_user($value, $element);
25010 -                               break;
25011 -                       case 'text':
25012 -                               common_element($element, NULL, common_xml_safe_str($value));
25013 -                               break;
25014 -                       default:
25015 -                               common_element($element, NULL, $value);
25016 -                       }
25017 -               }
25018 -               common_element_end('direct_message');
25019 -       }
25020 +    function show_twitter_xml_dmsg($twitter_dm) {
25021 +        common_element_start('direct_message');
25022 +        foreach($twitter_dm as $element => $value) {
25023 +            switch ($element) {
25024 +            case 'sender':
25025 +            case 'recipient':
25026 +                $this->show_twitter_xml_user($value, $element);
25027 +                break;
25028 +            case 'text':
25029 +                common_element($element, NULL, common_xml_safe_str($value));
25030 +                break;
25031 +            default:
25032 +                common_element($element, NULL, $value);
25033 +            }
25034 +        }
25035 +        common_element_end('direct_message');
25036 +    }
25037 hunk ./lib/twitterapi.php 252
25038 -       function show_xml_timeline($notice) {
25039 +    function show_xml_timeline($notice) {
25040 hunk ./lib/twitterapi.php 254
25041 -               $this->init_document('xml');
25042 -               common_element_start('statuses', array('type' => 'array'));
25043 +        $this->init_document('xml');
25044 +        common_element_start('statuses', array('type' => 'array'));
25045 hunk ./lib/twitterapi.php 257
25046 -               if (is_array($notice)) {
25047 -                       foreach ($notice as $n) {
25048 -                               $twitter_status = $this->twitter_status_array($n);
25049 -                               $this->show_twitter_xml_status($twitter_status);
25050 -                       }
25051 -               } else {
25052 -                       while ($notice->fetch()) {
25053 -                               $twitter_status = $this->twitter_status_array($notice);
25054 -                               $this->show_twitter_xml_status($twitter_status);
25055 -                       }
25056 -               }
25057 +        if (is_array($notice)) {
25058 +            foreach ($notice as $n) {
25059 +                $twitter_status = $this->twitter_status_array($n);
25060 +                $this->show_twitter_xml_status($twitter_status);
25061 +            }
25062 +        } else {
25063 +            while ($notice->fetch()) {
25064 +                $twitter_status = $this->twitter_status_array($notice);
25065 +                $this->show_twitter_xml_status($twitter_status);
25066 +            }
25067 +        }
25068 hunk ./lib/twitterapi.php 269
25069 -               common_element_end('statuses');
25070 -               $this->end_document('xml');
25071 -       }
25072 +        common_element_end('statuses');
25073 +        $this->end_document('xml');
25074 +    }
25075 hunk ./lib/twitterapi.php 273
25076 -       function show_rss_timeline($notice, $title, $link, $subtitle, $suplink=NULL) {
25077 +    function show_rss_timeline($notice, $title, $link, $subtitle, $suplink=NULL) {
25078 hunk ./lib/twitterapi.php 275
25079 -               $this->init_document('rss');
25080 +        $this->init_document('rss');
25081 hunk ./lib/twitterapi.php 277
25082 -               common_element_start('channel');
25083 -               common_element('title', NULL, $title);
25084 -               common_element('link', NULL, $link);
25085 -               if (!is_null($suplink)) {
25086 -                       # For FriendFeed's SUP protocol
25087 -                       common_element('link', array('xmlns' => 'http://www.w3.org/2005/Atom',
25088 -                                                                                'rel' => 'http://api.friendfeed.com/2008/03#sup',
25089 -                                                                                'href' => $suplink,
25090 -                                                                                'type' => 'application/json'));
25091 -               }
25092 -               common_element('description', NULL, $subtitle);
25093 -               common_element('language', NULL, 'en-us');
25094 -               common_element('ttl', NULL, '40');
25095 +        common_element_start('channel');
25096 +        common_element('title', NULL, $title);
25097 +        common_element('link', NULL, $link);
25098 +        if (!is_null($suplink)) {
25099 +            # For FriendFeed's SUP protocol
25100 +            common_element('link', array('xmlns' => 'http://www.w3.org/2005/Atom',
25101 +                                         'rel' => 'http://api.friendfeed.com/2008/03#sup',
25102 +                                         'href' => $suplink,
25103 +                                         'type' => 'application/json'));
25104 +        }
25105 +        common_element('description', NULL, $subtitle);
25106 +        common_element('language', NULL, 'en-us');
25107 +        common_element('ttl', NULL, '40');
25108 hunk ./lib/twitterapi.php 291
25109 -               if (is_array($notice)) {
25110 -                       foreach ($notice as $n) {
25111 -                               $entry = $this->twitter_rss_entry_array($n);
25112 -                               $this->show_twitter_rss_item($entry);
25113 -                       }
25114 -               } else {
25115 -                       while ($notice->fetch()) {
25116 -                               $entry = $this->twitter_rss_entry_array($notice);
25117 -                               $this->show_twitter_rss_item($entry);
25118 -                       }
25119 -               }
25120 +        if (is_array($notice)) {
25121 +            foreach ($notice as $n) {
25122 +                $entry = $this->twitter_rss_entry_array($n);
25123 +                $this->show_twitter_rss_item($entry);
25124 +            }
25125 +        } else {
25126 +            while ($notice->fetch()) {
25127 +                $entry = $this->twitter_rss_entry_array($notice);
25128 +                $this->show_twitter_rss_item($entry);
25129 +            }
25130 +        }
25131 hunk ./lib/twitterapi.php 303
25132 -               common_element_end('channel');
25133 -               $this->end_twitter_rss();
25134 -       }
25135 +        common_element_end('channel');
25136 +        $this->end_twitter_rss();
25137 +    }
25138 hunk ./lib/twitterapi.php 307
25139 -       function show_atom_timeline($notice, $title, $id, $link, $subtitle=NULL, $suplink=NULL) {
25140 +    function show_atom_timeline($notice, $title, $id, $link, $subtitle=NULL, $suplink=NULL) {
25141 hunk ./lib/twitterapi.php 309
25142 -               $this->init_document('atom');
25143 +        $this->init_document('atom');
25144 hunk ./lib/twitterapi.php 311
25145 -               common_element('title', NULL, $title);
25146 -               common_element('id', NULL, $id);
25147 -               common_element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), NULL);
25148 -               if (!is_null($suplink)) {
25149 -                       # For FriendFeed's SUP protocol
25150 -                       common_element('link', array('rel' => 'http://api.friendfeed.com/2008/03#sup',
25151 -                                                                                'href' => $suplink,
25152 -                                                                                'type' => 'application/json'));
25153 -               }
25154 -               common_element('subtitle', NULL, $subtitle);
25155 +        common_element('title', NULL, $title);
25156 +        common_element('id', NULL, $id);
25157 +        common_element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), NULL);
25158 +        if (!is_null($suplink)) {
25159 +            # For FriendFeed's SUP protocol
25160 +            common_element('link', array('rel' => 'http://api.friendfeed.com/2008/03#sup',
25161 +                                         'href' => $suplink,
25162 +                                         'type' => 'application/json'));
25163 +        }
25164 +        common_element('subtitle', NULL, $subtitle);
25165 hunk ./lib/twitterapi.php 322
25166 -               if (is_array($notice)) {
25167 -                       foreach ($notice as $n) {
25168 -                               $entry = $this->twitter_rss_entry_array($n);
25169 -                               $this->show_twitter_atom_entry($entry);
25170 -                       }
25171 -               } else {
25172 -                       while ($notice->fetch()) {
25173 -                               $entry = $this->twitter_rss_entry_array($notice);
25174 -                               $this->show_twitter_atom_entry($entry);
25175 -                       }
25176 -               }
25177 +        if (is_array($notice)) {
25178 +            foreach ($notice as $n) {
25179 +                $entry = $this->twitter_rss_entry_array($n);
25180 +                $this->show_twitter_atom_entry($entry);
25181 +            }
25182 +        } else {
25183 +            while ($notice->fetch()) {
25184 +                $entry = $this->twitter_rss_entry_array($notice);
25185 +                $this->show_twitter_atom_entry($entry);
25186 +            }
25187 +        }
25188 hunk ./lib/twitterapi.php 334
25189 -               $this->end_document('atom');
25190 +        $this->end_document('atom');
25191 hunk ./lib/twitterapi.php 336
25192 -       }
25193 +    }
25194 hunk ./lib/twitterapi.php 338
25195 -       function show_json_timeline($notice) {
25196 +    function show_json_timeline($notice) {
25197 hunk ./lib/twitterapi.php 340
25198 -               $this->init_document('json');
25199 +        $this->init_document('json');
25200 hunk ./lib/twitterapi.php 342
25201 -               $statuses = array();
25202 +        $statuses = array();
25203 hunk ./lib/twitterapi.php 344
25204 -               if (is_array($notice)) {
25205 -                       foreach ($notice as $n) {
25206 -                               $twitter_status = $this->twitter_status_array($n);
25207 -                               array_push($statuses, $twitter_status);
25208 -                       }
25209 -               } else {
25210 -                       while ($notice->fetch()) {
25211 -                               $twitter_status = $this->twitter_status_array($notice);
25212 -                               array_push($statuses, $twitter_status);
25213 -                       }
25214 -               }
25215 +        if (is_array($notice)) {
25216 +            foreach ($notice as $n) {
25217 +                $twitter_status = $this->twitter_status_array($n);
25218 +                array_push($statuses, $twitter_status);
25219 +            }
25220 +        } else {
25221 +            while ($notice->fetch()) {
25222 +                $twitter_status = $this->twitter_status_array($notice);
25223 +                array_push($statuses, $twitter_status);
25224 +            }
25225 +        }
25226 hunk ./lib/twitterapi.php 356
25227 -               $this->show_json_objects($statuses);
25228 +        $this->show_json_objects($statuses);
25229 hunk ./lib/twitterapi.php 358
25230 -               $this->end_document('json');
25231 -       }
25232 +        $this->end_document('json');
25233 +    }
25234 hunk ./lib/twitterapi.php 361
25235 -       // Anyone know what date format this is?
25236 -       // Twitter's dates look like this: "Mon Jul 14 23:52:38 +0000 2008" -- Zach
25237 -       function date_twitter($dt) {
25238 -               $t = strtotime($dt);
25239 -               return date("D M d G:i:s O Y", $t);
25240 -       }
25241 +    // Anyone know what date format this is?
25242 +    // Twitter's dates look like this: "Mon Jul 14 23:52:38 +0000 2008" -- Zach
25243 +    function date_twitter($dt) {
25244 +        $t = strtotime($dt);
25245 +        return date("D M d G:i:s O Y", $t);
25246 +    }
25247 hunk ./lib/twitterapi.php 368
25248 -       function replier_by_reply($reply_id) {
25249 -               $notice = Notice::staticGet($reply_id);
25250 -               if ($notice) {
25251 -                       $profile = $notice->getProfile();
25252 -                       if ($profile) {
25253 -                               return intval($profile->id);
25254 -                       } else {
25255 -                               common_debug('Can\'t find a profile for notice: ' . $notice->id, __FILE__);
25256 -                       }
25257 -               } else {
25258 -                       common_debug("Can't get notice: $reply_id", __FILE__);
25259 -               }
25260 -               return NULL;
25261 -       }
25262 +    function replier_by_reply($reply_id) {
25263 +        $notice = Notice::staticGet($reply_id);
25264 +        if ($notice) {
25265 +            $profile = $notice->getProfile();
25266 +            if ($profile) {
25267 +                return intval($profile->id);
25268 +            } else {
25269 +                common_debug('Can\'t find a profile for notice: ' . $notice->id, __FILE__);
25270 +            }
25271 +        } else {
25272 +            common_debug("Can't get notice: $reply_id", __FILE__);
25273 +        }
25274 +        return NULL;
25275 +    }
25276 hunk ./lib/twitterapi.php 383
25277 -       // XXX: Candidate for a general utility method somewhere?
25278 -       function count_subscriptions($profile) {
25279 +    // XXX: Candidate for a general utility method somewhere?
25280 +    function count_subscriptions($profile) {
25281 hunk ./lib/twitterapi.php 386
25282 -               $count = 0;
25283 -               $sub = new Subscription();
25284 -               $sub->subscribed = $profile->id;
25285 +        $count = 0;
25286 +        $sub = new Subscription();
25287 +        $sub->subscribed = $profile->id;
25288 hunk ./lib/twitterapi.php 390
25289 -               $count = $sub->find();
25290 +        $count = $sub->find();
25291 hunk ./lib/twitterapi.php 392
25292 -               if ($count > 0) {
25293 -                       return $count - 1;
25294 -               } else {
25295 -                       return 0;
25296 -               }
25297 -       }
25298 +        if ($count > 0) {
25299 +            return $count - 1;
25300 +        } else {
25301 +            return 0;
25302 +        }
25303 +    }
25304 hunk ./lib/twitterapi.php 399
25305 -       function init_document($type='xml') {
25306 -               switch ($type) {
25307 -                case 'xml':
25308 -                       header('Content-Type: application/xml; charset=utf-8');
25309 -                       common_start_xml();
25310 -                       break;
25311 -                case 'json':
25312 -                       header('Content-Type: application/json; charset=utf-8');
25313 +    function init_document($type='xml') {
25314 +        switch ($type) {
25315 +         case 'xml':
25316 +            header('Content-Type: application/xml; charset=utf-8');
25317 +            common_start_xml();
25318 +            break;
25319 +         case 'json':
25320 +            header('Content-Type: application/json; charset=utf-8');
25321 hunk ./lib/twitterapi.php 408
25322 -                       // Check for JSONP callback
25323 -                       $callback = $this->arg('callback');
25324 -                       if ($callback) {
25325 -                               print $callback . '(';
25326 -                       }
25327 -                       break;
25328 -                case 'rss':
25329 -                       header("Content-Type: application/rss+xml; charset=utf-8");
25330 -                       $this->init_twitter_rss();
25331 -                       break;
25332 -                case 'atom':
25333 -                       header('Content-Type: application/atom+xml; charset=utf-8');
25334 -                       $this->init_twitter_atom();
25335 -                       break;
25336 -                default:
25337 -                       $this->client_error(_('Not a supported data format.'));
25338 -                       break;
25339 -               }
25340 +            // Check for JSONP callback
25341 +            $callback = $this->arg('callback');
25342 +            if ($callback) {
25343 +                print $callback . '(';
25344 +            }
25345 +            break;
25346 +         case 'rss':
25347 +            header("Content-Type: application/rss+xml; charset=utf-8");
25348 +            $this->init_twitter_rss();
25349 +            break;
25350 +         case 'atom':
25351 +            header('Content-Type: application/atom+xml; charset=utf-8');
25352 +            $this->init_twitter_atom();
25353 +            break;
25354 +         default:
25355 +            $this->client_error(_('Not a supported data format.'));
25356 +            break;
25357 +        }
25358 hunk ./lib/twitterapi.php 427
25359 -               return;
25360 -       }
25361 +        return;
25362 +    }
25363 hunk ./lib/twitterapi.php 430
25364 -       function end_document($type='xml') {
25365 -               switch ($type) {
25366 -                case 'xml':
25367 -                       common_end_xml();
25368 -                       break;
25369 -                case 'json':
25370 +    function end_document($type='xml') {
25371 +        switch ($type) {
25372 +         case 'xml':
25373 +            common_end_xml();
25374 +            break;
25375 +         case 'json':
25376 hunk ./lib/twitterapi.php 437
25377 -                       // Check for JSONP callback
25378 -                       $callback = $this->arg('callback');
25379 -                       if ($callback) {
25380 -                               print ')';
25381 -                       }
25382 -                       break;
25383 -                case 'rss':
25384 -                       $this->end_twitter_rss();
25385 -                       break;
25386 -                case 'atom':
25387 -                       $this->end_twitter_rss();
25388 -                       break;
25389 -                default:
25390 -                       $this->client_error(_('Not a supported data format.'));
25391 -                       break;
25392 -               }
25393 -               return;
25394 -       }
25395 +            // Check for JSONP callback
25396 +            $callback = $this->arg('callback');
25397 +            if ($callback) {
25398 +                print ')';
25399 +            }
25400 +            break;
25401 +         case 'rss':
25402 +            $this->end_twitter_rss();
25403 +            break;
25404 +         case 'atom':
25405 +            $this->end_twitter_rss();
25406 +            break;
25407 +         default:
25408 +            $this->client_error(_('Not a supported data format.'));
25409 +            break;
25410 +        }
25411 +        return;
25412 +    }
25413 hunk ./lib/twitterapi.php 456
25414 -       function client_error($msg, $code = 400, $content_type = 'json') {
25415 +    function client_error($msg, $code = 400, $content_type = 'json') {
25416 hunk ./lib/twitterapi.php 458
25417 -               static $status = array(400 => 'Bad Request',
25418 -                                                          401 => 'Unauthorized',
25419 -                                                          402 => 'Payment Required',
25420 -                                                          403 => 'Forbidden',
25421 -                                                          404 => 'Not Found',
25422 -                                                          405 => 'Method Not Allowed',
25423 -                                                          406 => 'Not Acceptable',
25424 -                                                          407 => 'Proxy Authentication Required',
25425 -                                                          408 => 'Request Timeout',
25426 -                                                          409 => 'Conflict',
25427 -                                                          410 => 'Gone',
25428 -                                                          411 => 'Length Required',
25429 -                                                          412 => 'Precondition Failed',
25430 -                                                          413 => 'Request Entity Too Large',
25431 -                                                          414 => 'Request-URI Too Long',
25432 -                                                          415 => 'Unsupported Media Type',
25433 -                                                          416 => 'Requested Range Not Satisfiable',
25434 -                                                          417 => 'Expectation Failed');
25435 +        static $status = array(400 => 'Bad Request',
25436 +                               401 => 'Unauthorized',
25437 +                               402 => 'Payment Required',
25438 +                               403 => 'Forbidden',
25439 +                               404 => 'Not Found',
25440 +                               405 => 'Method Not Allowed',
25441 +                               406 => 'Not Acceptable',
25442 +                               407 => 'Proxy Authentication Required',
25443 +                               408 => 'Request Timeout',
25444 +                               409 => 'Conflict',
25445 +                               410 => 'Gone',
25446 +                               411 => 'Length Required',
25447 +                               412 => 'Precondition Failed',
25448 +                               413 => 'Request Entity Too Large',
25449 +                               414 => 'Request-URI Too Long',
25450 +                               415 => 'Unsupported Media Type',
25451 +                               416 => 'Requested Range Not Satisfiable',
25452 +                               417 => 'Expectation Failed');
25453 hunk ./lib/twitterapi.php 477
25454 -               $action = $this->trimmed('action');
25455 +        $action = $this->trimmed('action');
25456 hunk ./lib/twitterapi.php 479
25457 -               common_debug("User error '$code' on '$action': $msg", __FILE__);
25458 +        common_debug("User error '$code' on '$action': $msg", __FILE__);
25459 hunk ./lib/twitterapi.php 481
25460 -               if (!array_key_exists($code, $status)) {
25461 -                       $code = 400;
25462 -               }
25463 +        if (!array_key_exists($code, $status)) {
25464 +            $code = 400;
25465 +        }
25466 hunk ./lib/twitterapi.php 485
25467 -               $status_string = $status[$code];
25468 -               header('HTTP/1.1 '.$code.' '.$status_string);
25469 +        $status_string = $status[$code];
25470 +        header('HTTP/1.1 '.$code.' '.$status_string);
25471 hunk ./lib/twitterapi.php 488
25472 -               if ($content_type == 'xml') {
25473 -                       $this->init_document('xml');
25474 -                       common_element_start('hash');
25475 -                       common_element('error', NULL, $msg);
25476 -                       common_element('request', NULL, $_SERVER['REQUEST_URI']);
25477 -                       common_element_end('hash');
25478 -                       $this->end_document('xml');
25479 -               } else {
25480 -                       $this->init_document('json');
25481 -                       $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
25482 -                       print(json_encode($error_array));
25483 -                       $this->end_document('json');
25484 -               }
25485 +        if ($content_type == 'xml') {
25486 +            $this->init_document('xml');
25487 +            common_element_start('hash');
25488 +            common_element('error', NULL, $msg);
25489 +            common_element('request', NULL, $_SERVER['REQUEST_URI']);
25490 +            common_element_end('hash');
25491 +            $this->end_document('xml');
25492 +        } else {
25493 +            $this->init_document('json');
25494 +            $error_array = array('error' => $msg, 'request' => $_SERVER['REQUEST_URI']);
25495 +            print(json_encode($error_array));
25496 +            $this->end_document('json');
25497 +        }
25498 hunk ./lib/twitterapi.php 502
25499 -       }
25500 +    }
25501 hunk ./lib/twitterapi.php 504
25502 -       function init_twitter_rss() {
25503 -               common_start_xml();
25504 -               common_element_start('rss', array('version' => '2.0'));
25505 -       }
25506 +    function init_twitter_rss() {
25507 +        common_start_xml();
25508 +        common_element_start('rss', array('version' => '2.0'));
25509 +    }
25510 hunk ./lib/twitterapi.php 509
25511 -       function end_twitter_rss() {
25512 -               common_element_end('rss');
25513 -               common_end_xml();
25514 -       }
25515 +    function end_twitter_rss() {
25516 +        common_element_end('rss');
25517 +        common_end_xml();
25518 +    }
25519 hunk ./lib/twitterapi.php 514
25520 -       function init_twitter_atom() {
25521 -               common_start_xml();
25522 -               common_element_start('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en-US'));
25523 -       }
25524 +    function init_twitter_atom() {
25525 +        common_start_xml();
25526 +        common_element_start('feed', array('xmlns' => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en-US'));
25527 +    }
25528 hunk ./lib/twitterapi.php 519
25529 -       function end_twitter_atom() {
25530 -               common_end_xml();
25531 -               common_element_end('feed');
25532 -       }
25533 +    function end_twitter_atom() {
25534 +        common_end_xml();
25535 +        common_element_end('feed');
25536 +    }
25537 hunk ./lib/twitterapi.php 524
25538 -       function show_profile($profile, $content_type='xml', $notice=NULL) {
25539 -               $profile_array = $this->twitter_user_array($profile, true);
25540 -               switch ($content_type) {
25541 -                case 'xml':
25542 -                       $this->show_twitter_xml_user($profile_array);
25543 -                       break;
25544 -                case 'json':
25545 -                       $this->show_json_objects($profile_array);
25546 -                       break;
25547 -                default:
25548 -                       $this->client_error(_('Not a supported data format.'));
25549 -                       return;
25550 -               }
25551 -               return;
25552 -       }
25553 +    function show_profile($profile, $content_type='xml', $notice=NULL) {
25554 +        $profile_array = $this->twitter_user_array($profile, true);
25555 +        switch ($content_type) {
25556 +         case 'xml':
25557 +            $this->show_twitter_xml_user($profile_array);
25558 +            break;
25559 +         case 'json':
25560 +            $this->show_json_objects($profile_array);
25561 +            break;
25562 +         default:
25563 +            $this->client_error(_('Not a supported data format.'));
25564 +            return;
25565 +        }
25566 +        return;
25567 +    }
25568 hunk ./lib/twitterapi.php 540
25569 -       function get_user($id, $apidata=NULL) {
25570 -               if (!$id) {
25571 -                       return $apidata['user'];
25572 -               } else if (is_numeric($id)) {
25573 -                       return User::staticGet($id);
25574 -               } else {
25575 -                       $nickname = common_canonical_nickname($id);
25576 -                       return User::staticGet('nickname', $nickname);
25577 -               }
25578 -       }
25579 +    function get_user($id, $apidata=NULL) {
25580 +        if (!$id) {
25581 +            return $apidata['user'];
25582 +        } else if (is_numeric($id)) {
25583 +            return User::staticGet($id);
25584 +        } else {
25585 +            $nickname = common_canonical_nickname($id);
25586 +            return User::staticGet('nickname', $nickname);
25587 +        }
25588 +    }
25589 hunk ./lib/twitterapi.php 551
25590 -       function get_profile($id) {
25591 -               if (is_numeric($id)) {
25592 -                       return Profile::staticGet($id);
25593 -               } else {
25594 -                       $user = User::staticGet('nickname', $id);
25595 -                       if ($user) {
25596 -                               return $user->getProfile();
25597 -                       } else {
25598 -                               return NULL;
25599 -                       }
25600 -               }
25601 -       }
25602 +    function get_profile($id) {
25603 +        if (is_numeric($id)) {
25604 +            return Profile::staticGet($id);
25605 +        } else {
25606 +            $user = User::staticGet('nickname', $id);
25607 +            if ($user) {
25608 +                return $user->getProfile();
25609 +            } else {
25610 +                return NULL;
25611 +            }
25612 +        }
25613 +    }
25614 hunk ./lib/twitterapi.php 564
25615 -       function source_link($source) {
25616 -               $source_name = _($source);
25617 -               switch ($source) {
25618 -                case 'web':
25619 -                case 'xmpp':
25620 -                case 'mail':
25621 -                case 'omb':
25622 -                case 'api':
25623 -                       break;
25624 -                default:
25625 -                       $ns = Notice_source::staticGet($source);
25626 -                       if ($ns) {
25627 -                               $source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>';
25628 -                       }
25629 -                       break;
25630 -               }
25631 -               return $source_name;
25632 -       }
25633 +    function source_link($source) {
25634 +        $source_name = _($source);
25635 +        switch ($source) {
25636 +         case 'web':
25637 +         case 'xmpp':
25638 +         case 'mail':
25639 +         case 'omb':
25640 +         case 'api':
25641 +            break;
25642 +         default:
25643 +            $ns = Notice_source::staticGet($source);
25644 +            if ($ns) {
25645 +                $source_name = '<a href="' . $ns->url . '">' . $ns->name . '</a>';
25646 +            }
25647 +            break;
25648 +        }
25649 +        return $source_name;
25650 +    }
25651 hunk ./lib/twitterapi.php 583
25652 -       function show_extended_profile($user, $apidata) {
25653 +    function show_extended_profile($user, $apidata) {
25654 hunk ./lib/twitterapi.php 585
25655 -               $this->auth_user = $apidata['user'];
25656 +        $this->auth_user = $apidata['user'];
25657 hunk ./lib/twitterapi.php 587
25658 -               $profile = $user->getProfile();
25659 +        $profile = $user->getProfile();
25660 hunk ./lib/twitterapi.php 589
25661 -               if (!$profile) {
25662 -                       common_server_error(_('User has no profile.'));
25663 -                       return;
25664 -               }
25665 +        if (!$profile) {
25666 +            common_server_error(_('User has no profile.'));
25667 +            return;
25668 +        }
25669 hunk ./lib/twitterapi.php 594
25670 -               $twitter_user = $this->twitter_user_array($profile, true);
25671 +        $twitter_user = $this->twitter_user_array($profile, true);
25672 hunk ./lib/twitterapi.php 596
25673 -               // Add in extended user fields offered up by this method
25674 -               $twitter_user['created_at'] = $this->date_twitter($profile->created);
25675 +        // Add in extended user fields offered up by this method
25676 +        $twitter_user['created_at'] = $this->date_twitter($profile->created);
25677 hunk ./lib/twitterapi.php 599
25678 -               $subbed = DB_DataObject::factory('subscription');
25679 -               $subbed->subscriber = $profile->id;
25680 -               $subbed_count = (int) $subbed->count() - 1;
25681 +        $subbed = DB_DataObject::factory('subscription');
25682 +        $subbed->subscriber = $profile->id;
25683 +        $subbed_count = (int) $subbed->count() - 1;
25684 hunk ./lib/twitterapi.php 603
25685 -               $notices = DB_DataObject::factory('notice');
25686 -               $notices->profile_id = $profile->id;
25687 -               $notice_count = (int) $notices->count();
25688 +        $notices = DB_DataObject::factory('notice');
25689 +        $notices->profile_id = $profile->id;
25690 +        $notice_count = (int) $notices->count();
25691 hunk ./lib/twitterapi.php 607
25692 -               $twitter_user['friends_count'] = (is_int($subbed_count)) ? $subbed_count : 0;
25693 -               $twitter_user['statuses_count'] = (is_int($notice_count)) ? $notice_count : 0;
25694 +        $twitter_user['friends_count'] = (is_int($subbed_count)) ? $subbed_count : 0;
25695 +        $twitter_user['statuses_count'] = (is_int($notice_count)) ? $notice_count : 0;
25696 hunk ./lib/twitterapi.php 610
25697 -               // Other fields Twitter sends...
25698 -               $twitter_user['profile_background_color'] = '';
25699 -               $twitter_user['profile_text_color'] = '';
25700 -               $twitter_user['profile_link_color'] = '';
25701 -               $twitter_user['profile_sidebar_fill_color'] = '';
25702 +        // Other fields Twitter sends...
25703 +        $twitter_user['profile_background_color'] = '';
25704 +        $twitter_user['profile_text_color'] = '';
25705 +        $twitter_user['profile_link_color'] = '';
25706 +        $twitter_user['profile_sidebar_fill_color'] = '';
25707 hunk ./lib/twitterapi.php 616
25708 -               $faves = DB_DataObject::factory('fave');
25709 -               $faves->user_id = $user->id;
25710 -               $faves_count = (int) $faves->count();
25711 -               $twitter_user['favourites_count'] = $faves_count;
25712 +        $faves = DB_DataObject::factory('fave');
25713 +        $faves->user_id = $user->id;
25714 +        $faves_count = (int) $faves->count();
25715 +        $twitter_user['favourites_count'] = $faves_count;
25716 hunk ./lib/twitterapi.php 621
25717 -               $timezone = 'UTC';
25718 +        $timezone = 'UTC';
25719 hunk ./lib/twitterapi.php 623
25720 -               if ($user->timezone) {
25721 -                       $timezone = $user->timezone;
25722 -               }
25723 +        if ($user->timezone) {
25724 +            $timezone = $user->timezone;
25725 +        }
25726 hunk ./lib/twitterapi.php 627
25727 -               $t = new DateTime;
25728 -               $t->setTimezone(new DateTimeZone($timezone));
25729 -               $twitter_user['utc_offset'] = $t->format('Z');
25730 -               $twitter_user['time_zone'] = $timezone;
25731 +        $t = new DateTime;
25732 +        $t->setTimezone(new DateTimeZone($timezone));
25733 +        $twitter_user['utc_offset'] = $t->format('Z');
25734 +        $twitter_user['time_zone'] = $timezone;
25735 hunk ./lib/twitterapi.php 632
25736 -               $following = 'false';
25737 +        $following = 'false';
25738 hunk ./lib/twitterapi.php 634
25739 -               if (isset($this->auth_user)) {
25740 -                       if ($this->auth_user->isSubscribed($profile)) {
25741 -                               $following = 'true';
25742 -                       }
25743 +        if (isset($this->auth_user)) {
25744 +            if ($this->auth_user->isSubscribed($profile)) {
25745 +                $following = 'true';
25746 +            }
25747 hunk ./lib/twitterapi.php 639
25748 -                       // Not implemented yet
25749 -                       $twitter_user['notifications'] = 'false';
25750 -               }
25751 +            // Not implemented yet
25752 +            $twitter_user['notifications'] = 'false';
25753 +        }
25754 hunk ./lib/twitterapi.php 643
25755 -               $twitter_user['following'] = $following;
25756 +        $twitter_user['following'] = $following;
25757 hunk ./lib/twitterapi.php 645
25758 -               if ($apidata['content-type'] == 'xml') {
25759 -                       $this->init_document('xml');
25760 -                       $this->show_twitter_xml_user($twitter_user);
25761 -                       $this->end_document('xml');
25762 -               } elseif ($apidata['content-type'] == 'json') {
25763 -                       $this->init_document('json');
25764 -                       $this->show_json_objects($twitter_user);
25765 -                       $this->end_document('json');
25766 -               }
25767 +        if ($apidata['content-type'] == 'xml') {
25768 +            $this->init_document('xml');
25769 +            $this->show_twitter_xml_user($twitter_user);
25770 +            $this->end_document('xml');
25771 +        } elseif ($apidata['content-type'] == 'json') {
25772 +            $this->init_document('json');
25773 +            $this->show_json_objects($twitter_user);
25774 +            $this->end_document('json');
25775 +        }
25776 hunk ./lib/twitterapi.php 655
25777 -       }
25778 +    }
25779 hunk ./lib/xmppqueuehandler.php 32
25780 -       
25781 -       function start() {
25782 -               # Low priority; we don't want to receive messages
25783 -               $this->log(LOG_INFO, "INITIALIZE");
25784 -               $this->conn = jabber_connect($this->_id);
25785 -               if ($this->conn) {
25786 -                       $this->conn->addEventHandler('message', 'forward_message', $this);
25787 -                       $this->conn->addEventHandler('reconnect', 'handle_reconnect', $this);
25788 -                       $this->conn->setReconnectTimeout(600);
25789 -                       jabber_send_presence("Send me a message to post a notice", 'available', NULL, 'available', -1);
25790 -               }
25791 -               return !is_null($this->conn);
25792 -       }
25793 -       
25794 -       function handle_reconnect(&$pl) {
25795 -               $this->conn->processUntil('session_start');
25796 -               $this->conn->presence(NULL, 'available', NULL, 'available', -1);
25797 -       }
25798 +    
25799 +    function start() {
25800 +        # Low priority; we don't want to receive messages
25801 +        $this->log(LOG_INFO, "INITIALIZE");
25802 +        $this->conn = jabber_connect($this->_id);
25803 +        if ($this->conn) {
25804 +            $this->conn->addEventHandler('message', 'forward_message', $this);
25805 +            $this->conn->addEventHandler('reconnect', 'handle_reconnect', $this);
25806 +            $this->conn->setReconnectTimeout(600);
25807 +            jabber_send_presence("Send me a message to post a notice", 'available', NULL, 'available', -1);
25808 +        }
25809 +        return !is_null($this->conn);
25810 +    }
25811 +    
25812 +    function handle_reconnect(&$pl) {
25813 +        $this->conn->processUntil('session_start');
25814 +        $this->conn->presence(NULL, 'available', NULL, 'available', -1);
25815 +    }
25816 hunk ./lib/xmppqueuehandler.php 51
25817 -       function idle($timeout=0) {
25818 -               # Process the queue for as long as needed
25819 -               try {
25820 -                       if ($this->conn) {
25821 -                               $this->conn->processTime($timeout);
25822 -                       }
25823 -               } catch (XMPPHP_Exception $e) {
25824 -                       $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
25825 -                       die($e->getMessage());
25826 -               }
25827 -       }
25828 -       
25829 -       function forward_message(&$pl) {
25830 -               if ($pl['type'] != 'chat') {
25831 -                   $this->log(LOG_DEBUG, 'Ignoring message of type ' . $pl['type'] . ' from ' . $pl['from']);
25832 -                       return;
25833 -               }
25834 -               $listener = $this->listener();
25835 -               if (strtolower($listener) == strtolower($pl['from'])) {
25836 -                       $this->log(LOG_WARNING, 'Ignoring loop message.');
25837 -                       return;
25838 -               }
25839 -               $this->log(LOG_INFO, 'Forwarding message from ' . $pl['from'] . ' to ' . $listener);
25840 -               $this->conn->message($this->listener(), $pl['body'], 'chat', NULL, $this->ofrom($pl['from']));
25841 -       }
25842 +    function idle($timeout=0) {
25843 +        # Process the queue for as long as needed
25844 +        try {
25845 +            if ($this->conn) {
25846 +                $this->conn->processTime($timeout);
25847 +            }
25848 +        } catch (XMPPHP_Exception $e) {
25849 +            $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
25850 +            die($e->getMessage());
25851 +        }
25852 +    }
25853 +    
25854 +    function forward_message(&$pl) {
25855 +        if ($pl['type'] != 'chat') {
25856 +            $this->log(LOG_DEBUG, 'Ignoring message of type ' . $pl['type'] . ' from ' . $pl['from']);
25857 +            return;
25858 +        }
25859 +        $listener = $this->listener();
25860 +        if (strtolower($listener) == strtolower($pl['from'])) {
25861 +            $this->log(LOG_WARNING, 'Ignoring loop message.');
25862 +            return;
25863 +        }
25864 +        $this->log(LOG_INFO, 'Forwarding message from ' . $pl['from'] . ' to ' . $listener);
25865 +        $this->conn->message($this->listener(), $pl['body'], 'chat', NULL, $this->ofrom($pl['from']));
25866 +    }
25867 hunk ./lib/xmppqueuehandler.php 77
25868 -       function ofrom($from) {
25869 -               $address = "<addresses xmlns='http://jabber.org/protocol/address'>\n";
25870 -               $address .= "<address type='ofrom' jid='$from' />\n";
25871 -               $address .= "</addresses>\n";
25872 -               return $address;
25873 -       }
25874 +    function ofrom($from) {
25875 +        $address = "<addresses xmlns='http://jabber.org/protocol/address'>\n";
25876 +        $address .= "<address type='ofrom' jid='$from' />\n";
25877 +        $address .= "</addresses>\n";
25878 +        return $address;
25879 +    }
25880 hunk ./lib/xmppqueuehandler.php 84
25881 -       function listener() {
25882 -               if (common_config('xmpp', 'listener')) {
25883 -                       return common_config('xmpp', 'listener');
25884 -               } else {
25885 -                       return jabber_daemon_address() . '/' . common_config('xmpp','resource') . '-listener';
25886 -               }
25887 -       }
25888 +    function listener() {
25889 +        if (common_config('xmpp', 'listener')) {
25890 +            return common_config('xmpp', 'listener');
25891 +        } else {
25892 +            return jabber_daemon_address() . '/' . common_config('xmpp','resource') . '-listener';
25893 +        }
25894 +    }
25895 hunk ./scripts/enjitqueuehandler.php 23
25896 -       print "This script must be run from the command line\n";
25897 -       exit();
25898 +    print "This script must be run from the command line\n";
25899 +    exit();
25900 hunk ./scripts/enjitqueuehandler.php 37
25901 -       
25902 -       function transport() {
25903 -               return 'enjit';
25904 -       }
25905 +    
25906 +    function transport() {
25907 +        return 'enjit';
25908 +    }
25909 hunk ./scripts/enjitqueuehandler.php 42
25910 -       function start() {
25911 +    function start() {
25912 hunk ./scripts/enjitqueuehandler.php 45
25913 -               return true;
25914 -       }
25915 +        return true;
25916 +    }
25917 hunk ./scripts/enjitqueuehandler.php 48
25918 -       function handle_notice($notice) {
25919 +    function handle_notice($notice) {
25920 hunk ./scripts/enjitqueuehandler.php 50
25921 -               $profile = Profile::staticGet($notice->profile_id);
25922 +        $profile = Profile::staticGet($notice->profile_id);
25923 hunk ./scripts/enjitqueuehandler.php 63
25924 -               $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
25925 -               $msg = $profile->nickname . ': ' . $notice->content;
25926 +        $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
25927 +        $msg = $profile->nickname . ': ' . $notice->content;
25928 hunk ./scripts/enjitqueuehandler.php 66
25929 -               $atom  = "<entry xmlns='http://www.w3.org/2005/Atom'>\n";
25930 -               $atom .= "<apisource>".common_config('enjit','source')."</apisource>\n";
25931 -               $atom .= "<source>\n";
25932 -               $atom .= "<title>" . $profile->nickname . " - " . common_config('site', 'name') . "</title>\n";
25933 -               $atom .= "<link href='" . $profile->profileurl . "'/>\n";
25934 -               $atom .= "<link rel='self' type='application/rss+xml' href='" . common_local_url('userrss', array('nickname' => $profile->nickname)) . "'/>\n";
25935 -               $atom .= "<author><name>" . $profile->nickname . "</name></author>\n";
25936 -               $atom .= "<icon>" . common_profile_avatar_url($profile, AVATAR_PROFILE_SIZE) . "</icon>\n";
25937 -               $atom .= "</source>\n";
25938 -               $atom .= "<title>" . htmlspecialchars($msg) . "</title>\n";
25939 -               $atom .= "<summary>" . htmlspecialchars($msg) . "</summary>\n";
25940 -               $atom .= "<link rel='alternate' href='" . $noticeurl . "' />\n";
25941 -               $atom .= "<id>". $notice->uri . "</id>\n";
25942 -               $atom .= "<published>".common_date_w3dtf($notice->created)."</published>\n";
25943 -               $atom .= "<updated>".common_date_w3dtf($notice->modified)."</updated>\n";
25944 -               $atom .= "</entry>\n";
25945 +        $atom  = "<entry xmlns='http://www.w3.org/2005/Atom'>\n";
25946 +        $atom .= "<apisource>".common_config('enjit','source')."</apisource>\n";
25947 +        $atom .= "<source>\n";
25948 +        $atom .= "<title>" . $profile->nickname . " - " . common_config('site', 'name') . "</title>\n";
25949 +        $atom .= "<link href='" . $profile->profileurl . "'/>\n";
25950 +        $atom .= "<link rel='self' type='application/rss+xml' href='" . common_local_url('userrss', array('nickname' => $profile->nickname)) . "'/>\n";
25951 +        $atom .= "<author><name>" . $profile->nickname . "</name></author>\n";
25952 +        $atom .= "<icon>" . common_profile_avatar_url($profile, AVATAR_PROFILE_SIZE) . "</icon>\n";
25953 +        $atom .= "</source>\n";
25954 +        $atom .= "<title>" . htmlspecialchars($msg) . "</title>\n";
25955 +        $atom .= "<summary>" . htmlspecialchars($msg) . "</summary>\n";
25956 +        $atom .= "<link rel='alternate' href='" . $noticeurl . "' />\n";
25957 +        $atom .= "<id>". $notice->uri . "</id>\n";
25958 +        $atom .= "<published>".common_date_w3dtf($notice->created)."</published>\n";
25959 +        $atom .= "<updated>".common_date_w3dtf($notice->modified)."</updated>\n";
25960 +        $atom .= "</entry>\n";
25961 hunk ./scripts/enjitqueuehandler.php 89
25962 -               $ch   = curl_init();
25963 +        $ch   = curl_init();
25964 hunk ./scripts/enjitqueuehandler.php 91
25965 -               curl_setopt($ch, CURLOPT_URL, $url);
25966 +        curl_setopt($ch, CURLOPT_URL, $url);
25967 hunk ./scripts/enjitqueuehandler.php 94
25968 -               curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
25969 -               curl_setopt($ch, CURLOPT_POST, 1) ;
25970 -               curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
25971 +        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
25972 +        curl_setopt($ch, CURLOPT_POST, 1) ;
25973 +        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
25974 hunk ./scripts/enjitqueuehandler.php 100
25975 -               # curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
25976 -               # curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
25977 +        # curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
25978 +        # curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
25979 hunk ./scripts/enjitqueuehandler.php 104
25980 -               $result = curl_exec($ch);
25981 +        $result = curl_exec($ch);
25982 hunk ./scripts/enjitqueuehandler.php 106
25983 -               $code = curl_getinfo($ch, CURLINFO_HTTP_CODE );
25984 +        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE );
25985 hunk ./scripts/enjitqueuehandler.php 110
25986 -               curl_close($ch);
25987 +        curl_close($ch);
25988 hunk ./scripts/enjitqueuehandler.php 113
25989 -       }
25990 -       
25991 +    }
25992 +    
25993 hunk ./scripts/enjitqueuehandler.php 125
25994 -       $handler->handle_queue();
25995 +    $handler->handle_queue();
25996 hunk ./scripts/fixup_hashtags.php 40
25997 -       $original = clone($notice);
25998 -       $notice->rendered = common_render_content($notice->content, $notice);
25999 -       $result = $notice->update($original);
26000 -       if (!$result) {
26001 -               common_log_db_error($notice, 'UPDATE', __FILE__);
26002 -       }
26003 +    $original = clone($notice);
26004 +    $notice->rendered = common_render_content($notice->content, $notice);
26005 +    $result = $notice->update($original);
26006 +    if (!$result) {
26007 +        common_log_db_error($notice, 'UPDATE', __FILE__);
26008 +    }
26009 hunk ./scripts/fixup_inboxes.php 44
26010 -       $user->whereAdd('id >= ' . $start_at);
26011 +    $user->whereAdd('id >= ' . $start_at);
26012 hunk ./scripts/fixup_inboxes.php 52
26013 -       $user->query('BEGIN');
26014 -       $inbox = new Notice_inbox();
26015 -       $result = $inbox->query('INSERT LOW_PRIORITY INTO notice_inbox (user_id, notice_id, created) ' .
26016 -                                                       'SELECT ' . $user->id . ', notice.id, notice.created ' .
26017 -                                                       'FROM subscription JOIN notice ON subscription.subscribed = notice.profile_id ' .
26018 -                                                       'WHERE subscription.subscriber = ' . $user->id . ' ' .
26019 -                                                       'AND notice.created >= subscription.created ' . 
26020 -                                                       'AND NOT EXISTS (SELECT user_id, notice_id ' .
26021 -                                                       'FROM notice_inbox ' .
26022 -                                                       'WHERE user_id = ' . $user->id . ' ' . 
26023 -                                                       'AND notice_id = notice.id)');
26024 -       if (is_null($result) || $result === false) {
26025 -               common_log_db_error($inbox, 'INSERT', __FILE__);
26026 -               continue;
26027 -       }
26028 -       $orig = clone($user);
26029 -       $user->inboxed = 1;
26030 -       $result = $user->update($orig);
26031 -       if (!$result) {
26032 -               common_log_db_error($user, 'UPDATE', __FILE__);
26033 -               continue;
26034 -       }
26035 -       $user->query('COMMIT');
26036 -       $inbox->free();
26037 -       unset($inbox);
26038 -       if ($cache) {
26039 -               $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
26040 -       }
26041 +    $user->query('BEGIN');
26042 +    $inbox = new Notice_inbox();
26043 +    $result = $inbox->query('INSERT LOW_PRIORITY INTO notice_inbox (user_id, notice_id, created) ' .
26044 +                            'SELECT ' . $user->id . ', notice.id, notice.created ' .
26045 +                            'FROM subscription JOIN notice ON subscription.subscribed = notice.profile_id ' .
26046 +                            'WHERE subscription.subscriber = ' . $user->id . ' ' .
26047 +                            'AND notice.created >= subscription.created ' . 
26048 +                            'AND NOT EXISTS (SELECT user_id, notice_id ' .
26049 +                            'FROM notice_inbox ' .
26050 +                            'WHERE user_id = ' . $user->id . ' ' . 
26051 +                            'AND notice_id = notice.id)');
26052 +    if (is_null($result) || $result === false) {
26053 +        common_log_db_error($inbox, 'INSERT', __FILE__);
26054 +        continue;
26055 +    }
26056 +    $orig = clone($user);
26057 +    $user->inboxed = 1;
26058 +    $result = $user->update($orig);
26059 +    if (!$result) {
26060 +        common_log_db_error($user, 'UPDATE', __FILE__);
26061 +        continue;
26062 +    }
26063 +    $user->query('COMMIT');
26064 +    $inbox->free();
26065 +    unset($inbox);
26066 +    if ($cache) {
26067 +        $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
26068 +    }
26069 hunk ./scripts/fixup_notices_rendered.php 23
26070 -       print "This script must be run from the command line\n";
26071 -       exit();
26072 +    print "This script must be run from the command line\n";
26073 +    exit();
26074 hunk ./scripts/fixup_notices_rendered.php 38
26075 -       $notice->whereAdd('id >= ' . $start_at);
26076 +    $notice->whereAdd('id >= ' . $start_at);
26077 hunk ./scripts/fixup_notices_rendered.php 43
26078 -       common_log(LOG_INFO, 'Pre-rendering notice #' . $notice->id);
26079 -       $original = clone($notice);
26080 -       $notice->rendered = common_render_content($notice->content, $notice);
26081 -       $result = $notice->update($original);
26082 -       if (!$result) {
26083 -               common_log_db_error($notice, 'UPDATE', __FILE__);
26084 -       }
26085 +    common_log(LOG_INFO, 'Pre-rendering notice #' . $notice->id);
26086 +    $original = clone($notice);
26087 +    $notice->rendered = common_render_content($notice->content, $notice);
26088 +    $result = $notice->update($original);
26089 +    if (!$result) {
26090 +        common_log_db_error($notice, 'UPDATE', __FILE__);
26091 +    }
26092 hunk ./scripts/getpiddir.php 23
26093 -       print "This script must be run from the command line\n";
26094 -       exit();
26095 +    print "This script must be run from the command line\n";
26096 +    exit();
26097 hunk ./scripts/inbox_users.php 45
26098 -       
26099 -       $user = User::staticGet('id', $id);
26100 +    
26101 +    $user = User::staticGet('id', $id);
26102 hunk ./scripts/inbox_users.php 48
26103 -       if (!$user) {
26104 -               common_log(LOG_WARNING, 'No such user: ' . $id);
26105 -               continue;
26106 -       }
26107 -       
26108 -       if ($user->inboxed) {
26109 -               common_log(LOG_WARNING, 'Already inboxed: ' . $id);
26110 -               continue;
26111 -       }
26112 -       
26113 +    if (!$user) {
26114 +        common_log(LOG_WARNING, 'No such user: ' . $id);
26115 +        continue;
26116 +    }
26117 +    
26118 +    if ($user->inboxed) {
26119 +        common_log(LOG_WARNING, 'Already inboxed: ' . $id);
26120 +        continue;
26121 +    }
26122 +    
26123 hunk ./scripts/inbox_users.php 59
26124 -       
26125 -       $user->query('BEGIN');
26126 -       
26127 -       $old_inbox = new Notice_inbox();
26128 -       $old_inbox->user_id = $user->id;
26129 -       
26130 -       $result = $old_inbox->delete();
26131 -       
26132 -       if (is_null($result) || $result === false) {
26133 -               common_log_db_error($old_inbox, 'DELETE', __FILE__);
26134 -               continue;
26135 -       }
26136 +    
26137 +    $user->query('BEGIN');
26138 +    
26139 +    $old_inbox = new Notice_inbox();
26140 +    $old_inbox->user_id = $user->id;
26141 +    
26142 +    $result = $old_inbox->delete();
26143 +    
26144 +    if (is_null($result) || $result === false) {
26145 +        common_log_db_error($old_inbox, 'DELETE', __FILE__);
26146 +        continue;
26147 +    }
26148 hunk ./scripts/inbox_users.php 72
26149 -       $old_inbox->free();
26150 -       
26151 -       $inbox = new Notice_inbox();
26152 -       
26153 -       $result = $inbox->query('INSERT INTO notice_inbox (user_id, notice_id, created) ' .
26154 -                                                       'SELECT ' . $user->id . ', notice.id, notice.created ' .
26155 -                                                       'FROM subscription JOIN notice ON subscription.subscribed = notice.profile_id ' .
26156 -                                                       'WHERE subscription.subscriber = ' . $user->id . ' ' .
26157 -                                                       'AND notice.created >= subscription.created ' .
26158 -                                                       'AND now() - notice.created < ' . (7 * 24 * 3600) . ' ' .
26159 -                                                       'AND NOT EXISTS (SELECT user_id, notice_id ' .
26160 -                                                       'FROM notice_inbox ' .
26161 -                                                       'WHERE user_id = ' . $user->id . ' ' . 
26162 -                                                       'AND notice_id = notice.id)');
26163 -       
26164 -       if (is_null($result) || $result === false) {
26165 -               common_log_db_error($inbox, 'INSERT', __FILE__);
26166 -               continue;
26167 -       }
26168 -       
26169 -       $orig = clone($user);
26170 -       $user->inboxed = 1;
26171 -       $result = $user->update($orig);
26172 -       
26173 -       if (!$result) {
26174 -               common_log_db_error($user, 'UPDATE', __FILE__);
26175 -               continue;
26176 -       }
26177 -       
26178 -       $user->query('COMMIT');
26179 -       
26180 -       $inbox->free();
26181 -       unset($inbox);
26182 -       
26183 -       if ($cache) {
26184 -               $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
26185 -       }
26186 +    $old_inbox->free();
26187 +    
26188 +    $inbox = new Notice_inbox();
26189 +    
26190 +    $result = $inbox->query('INSERT INTO notice_inbox (user_id, notice_id, created) ' .
26191 +                            'SELECT ' . $user->id . ', notice.id, notice.created ' .
26192 +                            'FROM subscription JOIN notice ON subscription.subscribed = notice.profile_id ' .
26193 +                            'WHERE subscription.subscriber = ' . $user->id . ' ' .
26194 +                            'AND notice.created >= subscription.created ' .
26195 +                            'AND now() - notice.created < ' . (7 * 24 * 3600) . ' ' .
26196 +                            'AND NOT EXISTS (SELECT user_id, notice_id ' .
26197 +                            'FROM notice_inbox ' .
26198 +                            'WHERE user_id = ' . $user->id . ' ' . 
26199 +                            'AND notice_id = notice.id)');
26200 +    
26201 +    if (is_null($result) || $result === false) {
26202 +        common_log_db_error($inbox, 'INSERT', __FILE__);
26203 +        continue;
26204 +    }
26205 +    
26206 +    $orig = clone($user);
26207 +    $user->inboxed = 1;
26208 +    $result = $user->update($orig);
26209 +    
26210 +    if (!$result) {
26211 +        common_log_db_error($user, 'UPDATE', __FILE__);
26212 +        continue;
26213 +    }
26214 +    
26215 +    $user->query('COMMIT');
26216 +    
26217 +    $inbox->free();
26218 +    unset($inbox);
26219 +    
26220 +    if ($cache) {
26221 +        $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
26222 +    }
26223 hunk ./scripts/jabberqueuehandler.php 23
26224 -       print "This script must be run from the command line\n";
26225 -       exit();
26226 +    print "This script must be run from the command line\n";
26227 +    exit();
26228 hunk ./scripts/jabberqueuehandler.php 38
26229 -       var $conn = NULL;
26230 +    var $conn = NULL;
26231 hunk ./scripts/jabberqueuehandler.php 40
26232 -       function transport() {
26233 -               return 'jabber';
26234 -       }
26235 +    function transport() {
26236 +        return 'jabber';
26237 +    }
26238 hunk ./scripts/jabberqueuehandler.php 44
26239 -       function handle_notice($notice) {
26240 -               try {
26241 -                       return jabber_broadcast_notice($notice);
26242 -               } catch (XMPPHP_Exception $e) {
26243 -                       $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
26244 -                       exit(1);
26245 -               }
26246 -       }
26247 +    function handle_notice($notice) {
26248 +        try {
26249 +            return jabber_broadcast_notice($notice);
26250 +        } catch (XMPPHP_Exception $e) {
26251 +            $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
26252 +            exit(1);
26253 +        }
26254 +    }
26255 hunk ./scripts/maildaemon.php 23
26256 -       print "This script must be run from the command line\n";
26257 -       exit();
26258 +    print "This script must be run from the command line\n";
26259 +    exit();
26260 hunk ./scripts/maildaemon.php 39
26261 -       function __construct() {
26262 -       }
26263 +    function __construct() {
26264 +    }
26265 hunk ./scripts/maildaemon.php 42
26266 -       function handle_message($fname='php://stdin') {
26267 -               list($from, $to, $msg) = $this->parse_message($fname);
26268 -               if (!$from || !$to || !$msg) {
26269 -                       $this->error(NULL, _('Could not parse message.'));
26270 -               }
26271 -               common_log(LOG_INFO, "Mail from $from to $to: " .substr($msg, 0, 20));
26272 -               $user = $this->user_from($from);
26273 -               if (!$user) {
26274 -                       $this->error($from, _('Not a registered user.'));
26275 -                       return false;
26276 -               }
26277 -               if (!$this->user_match_to($user, $to)) {
26278 -                       $this->error($from, _('Sorry, that is not your incoming email address.'));
26279 -                       return false;
26280 -               }
26281 -               if (!$user->emailpost) {
26282 -                       $this->error($from, _('Sorry, no incoming email allowed.'));
26283 -                       return false;
26284 -               }
26285 -               $response = $this->handle_command($user, $from, $msg);
26286 -               if ($response) {
26287 -                       return true;
26288 -               }
26289 -               $msg = $this->cleanup_msg($msg);
26290 -               $this->add_notice($user, $msg);
26291 -       }
26292 +    function handle_message($fname='php://stdin') {
26293 +        list($from, $to, $msg) = $this->parse_message($fname);
26294 +        if (!$from || !$to || !$msg) {
26295 +            $this->error(NULL, _('Could not parse message.'));
26296 +        }
26297 +        common_log(LOG_INFO, "Mail from $from to $to: " .substr($msg, 0, 20));
26298 +        $user = $this->user_from($from);
26299 +        if (!$user) {
26300 +            $this->error($from, _('Not a registered user.'));
26301 +            return false;
26302 +        }
26303 +        if (!$this->user_match_to($user, $to)) {
26304 +            $this->error($from, _('Sorry, that is not your incoming email address.'));
26305 +            return false;
26306 +        }
26307 +        if (!$user->emailpost) {
26308 +            $this->error($from, _('Sorry, no incoming email allowed.'));
26309 +            return false;
26310 +        }
26311 +        $response = $this->handle_command($user, $from, $msg);
26312 +        if ($response) {
26313 +            return true;
26314 +        }
26315 +        $msg = $this->cleanup_msg($msg);
26316 +        $this->add_notice($user, $msg);
26317 +    }
26318 hunk ./scripts/maildaemon.php 69
26319 -       function error($from, $msg) {
26320 -               file_put_contents("php://stderr", $msg . "\n");
26321 -               exit(1);
26322 -       }
26323 +    function error($from, $msg) {
26324 +        file_put_contents("php://stderr", $msg . "\n");
26325 +        exit(1);
26326 +    }
26327 hunk ./scripts/maildaemon.php 74
26328 -       function user_from($from_hdr) {
26329 -               $froms = mailparse_rfc822_parse_addresses($from_hdr);
26330 -               if (!$froms) {
26331 -                       return NULL;
26332 -               }
26333 -               $from = $froms[0];
26334 -               $addr = common_canonical_email($from['address']);
26335 -               $user = User::staticGet('email', $addr);
26336 -               if (!$user) {
26337 -                       $user = User::staticGet('smsemail', $addr);
26338 -               }
26339 -               return $user;
26340 -       }
26341 +    function user_from($from_hdr) {
26342 +        $froms = mailparse_rfc822_parse_addresses($from_hdr);
26343 +        if (!$froms) {
26344 +            return NULL;
26345 +        }
26346 +        $from = $froms[0];
26347 +        $addr = common_canonical_email($from['address']);
26348 +        $user = User::staticGet('email', $addr);
26349 +        if (!$user) {
26350 +            $user = User::staticGet('smsemail', $addr);
26351 +        }
26352 +        return $user;
26353 +    }
26354 hunk ./scripts/maildaemon.php 88
26355 -       function user_match_to($user, $to_hdr) {
26356 -               $incoming = $user->incomingemail;
26357 -               $tos = mailparse_rfc822_parse_addresses($to_hdr);
26358 -               foreach ($tos as $to) {
26359 -                       if (strcasecmp($incoming, $to['address']) == 0) {
26360 -                               return true;
26361 -                       }
26362 -               }
26363 -               return false;
26364 -       }
26365 +    function user_match_to($user, $to_hdr) {
26366 +        $incoming = $user->incomingemail;
26367 +        $tos = mailparse_rfc822_parse_addresses($to_hdr);
26368 +        foreach ($tos as $to) {
26369 +            if (strcasecmp($incoming, $to['address']) == 0) {
26370 +                return true;
26371 +            }
26372 +        }
26373 +        return false;
26374 +    }
26375 hunk ./scripts/maildaemon.php 99
26376 -       function handle_command($user, $from, $msg) {
26377 -               $inter = new CommandInterpreter();
26378 -               $cmd = $inter->handle_command($user, $msg);
26379 -               if ($cmd) {
26380 -                       $cmd->execute(new MailChannel($from));
26381 -                       return true;
26382 -               }
26383 -               return false;
26384 -       }
26385 +    function handle_command($user, $from, $msg) {
26386 +        $inter = new CommandInterpreter();
26387 +        $cmd = $inter->handle_command($user, $msg);
26388 +        if ($cmd) {
26389 +            $cmd->execute(new MailChannel($from));
26390 +            return true;
26391 +        }
26392 +        return false;
26393 +    }
26394 hunk ./scripts/maildaemon.php 109
26395 -       function respond($from, $to, $response) {
26396 +    function respond($from, $to, $response) {
26397 hunk ./scripts/maildaemon.php 111
26398 -               $headers['From'] = $to;
26399 -               $headers['To'] = $from;
26400 -               $headers['Subject'] = "Command complete";
26401 +        $headers['From'] = $to;
26402 +        $headers['To'] = $from;
26403 +        $headers['Subject'] = "Command complete";
26404 hunk ./scripts/maildaemon.php 115
26405 -               return mail_send(array($from), $headers, $response);
26406 -       }
26407 +        return mail_send(array($from), $headers, $response);
26408 +    }
26409 hunk ./scripts/maildaemon.php 118
26410 -       function log($level, $msg) {
26411 -               common_log($level, 'MailDaemon: '.$msg);
26412 -       }
26413 +    function log($level, $msg) {
26414 +        common_log($level, 'MailDaemon: '.$msg);
26415 +    }
26416 hunk ./scripts/maildaemon.php 122
26417 -       function add_notice($user, $msg) {
26418 +    function add_notice($user, $msg) {
26419 hunk ./scripts/maildaemon.php 126
26420 -               $notice = Notice::saveNew($user->id, $msg, 'mail');
26421 -               if (is_string($notice)) {
26422 -                       $this->log(LOG_ERR, $notice);
26423 -                       return;
26424 -               }
26425 -               common_broadcast_notice($notice);
26426 -               $this->log(LOG_INFO,
26427 -                                  'Added notice ' . $notice->id . ' from user ' . $user->nickname);
26428 -       }
26429 +        $notice = Notice::saveNew($user->id, $msg, 'mail');
26430 +        if (is_string($notice)) {
26431 +            $this->log(LOG_ERR, $notice);
26432 +            return;
26433 +        }
26434 +        common_broadcast_notice($notice);
26435 +        $this->log(LOG_INFO,
26436 +                   'Added notice ' . $notice->id . ' from user ' . $user->nickname);
26437 +    }
26438 hunk ./scripts/maildaemon.php 136
26439 -       function parse_message($fname) {
26440 -               $contents = file_get_contents($fname);
26441 -               $parsed = Mail_mimeDecode::decode(array('input' => $contents,
26442 -                                                                                               'include_bodies' => true,
26443 -                                                                                               'decode_headers' => true,
26444 -                                                                                               'decode_bodies' => true));
26445 -               if (!$parsed) {
26446 -                       return NULL;
26447 -               }
26448 +    function parse_message($fname) {
26449 +        $contents = file_get_contents($fname);
26450 +        $parsed = Mail_mimeDecode::decode(array('input' => $contents,
26451 +                                                'include_bodies' => true,
26452 +                                                'decode_headers' => true,
26453 +                                                'decode_bodies' => true));
26454 +        if (!$parsed) {
26455 +            return NULL;
26456 +        }
26457 hunk ./scripts/maildaemon.php 146
26458 -               $from = $parsed->headers['from'];
26459 +        $from = $parsed->headers['from'];
26460 hunk ./scripts/maildaemon.php 148
26461 -               $to = $parsed->headers['to'];
26462 +        $to = $parsed->headers['to'];
26463 hunk ./scripts/maildaemon.php 150
26464 -               $type = $parsed->ctype_primary . '/' . $parsed->ctype_secondary;
26465 +        $type = $parsed->ctype_primary . '/' . $parsed->ctype_secondary;
26466 hunk ./scripts/maildaemon.php 152
26467 -               if ($parsed->ctype_primary == 'multipart') {
26468 -                       foreach ($parsed->parts as $part) {
26469 -                               if ($part->ctype_primary == 'text' &&
26470 -                                       $part->ctype_secondary == 'plain') {
26471 -                                       $msg = $part->body;
26472 -                                       break;
26473 -                               }
26474 -                       }
26475 -               } else if ($type == 'text/plain') {
26476 -                       $msg = $parsed->body;
26477 -               } else {
26478 -                       $this->unsupported_type($type);
26479 -               }
26480 +        if ($parsed->ctype_primary == 'multipart') {
26481 +            foreach ($parsed->parts as $part) {
26482 +                if ($part->ctype_primary == 'text' &&
26483 +                    $part->ctype_secondary == 'plain') {
26484 +                    $msg = $part->body;
26485 +                    break;
26486 +                }
26487 +            }
26488 +        } else if ($type == 'text/plain') {
26489 +            $msg = $parsed->body;
26490 +        } else {
26491 +            $this->unsupported_type($type);
26492 +        }
26493 hunk ./scripts/maildaemon.php 166
26494 -               return array($from, $to, $msg);
26495 -       }
26496 +        return array($from, $to, $msg);
26497 +    }
26498 hunk ./scripts/maildaemon.php 169
26499 -       function unsupported_type($type) {
26500 -               $this->error(NULL, "Unsupported message type: " . $type);
26501 -       }
26502 +    function unsupported_type($type) {
26503 +        $this->error(NULL, "Unsupported message type: " . $type);
26504 +    }
26505 hunk ./scripts/maildaemon.php 173
26506 -       function cleanup_msg($msg) {
26507 -               $lines = explode("\n", $msg);
26508 +    function cleanup_msg($msg) {
26509 +        $lines = explode("\n", $msg);
26510 hunk ./scripts/maildaemon.php 176
26511 -               $output = '';
26512 +        $output = '';
26513 hunk ./scripts/maildaemon.php 178
26514 -               foreach ($lines as $line) {
26515 -                       // skip quotes
26516 -                       if (preg_match('/^\s*>.*$/', $line)) {
26517 -                               continue;
26518 -                       }
26519 -                       // skip start of quote
26520 -                       if (preg_match('/^\s*On.*wrote:\s*$/', $line)) {
26521 -                               continue;
26522 -                       }
26523 -                       // probably interesting to someone, not us
26524 -                       if (preg_match('/^\s*Sent via/', $line)) {
26525 -                               continue;
26526 -                       }
26527 -                       // skip everything after a sig
26528 -                       if (preg_match('/^\s*--+\s*$/', $line) ||
26529 -                               preg_match('/^\s*__+\s*$/', $line))
26530 -                       {
26531 -                               break;
26532 -                       }
26533 -                       // skip everything after Outlook quote
26534 -                       if (preg_match('/^\s*-+\s*Original Message\s*-+\s*$/', $line)) {
26535 -                               break;
26536 -                       }
26537 -                       // skip everything after weird forward
26538 -                       if (preg_match('/^\s*Begin\s+forward/', $line)) {
26539 -                               break;
26540 -                       }
26541 +        foreach ($lines as $line) {
26542 +            // skip quotes
26543 +            if (preg_match('/^\s*>.*$/', $line)) {
26544 +                continue;
26545 +            }
26546 +            // skip start of quote
26547 +            if (preg_match('/^\s*On.*wrote:\s*$/', $line)) {
26548 +                continue;
26549 +            }
26550 +            // probably interesting to someone, not us
26551 +            if (preg_match('/^\s*Sent via/', $line)) {
26552 +                continue;
26553 +            }
26554 +            // skip everything after a sig
26555 +            if (preg_match('/^\s*--+\s*$/', $line) ||
26556 +                preg_match('/^\s*__+\s*$/', $line))
26557 +            {
26558 +                break;
26559 +            }
26560 +            // skip everything after Outlook quote
26561 +            if (preg_match('/^\s*-+\s*Original Message\s*-+\s*$/', $line)) {
26562 +                break;
26563 +            }
26564 +            // skip everything after weird forward
26565 +            if (preg_match('/^\s*Begin\s+forward/', $line)) {
26566 +                break;
26567 +            }
26568 hunk ./scripts/maildaemon.php 206
26569 -                       $output .= ' ' . $line;
26570 -               }
26571 +            $output .= ' ' . $line;
26572 +        }
26573 hunk ./scripts/maildaemon.php 209
26574 -               preg_replace('/\s+/', ' ', $output);
26575 -               return trim($output);
26576 -       }
26577 +        preg_replace('/\s+/', ' ', $output);
26578 +        return trim($output);
26579 +    }
26580 hunk ./scripts/ombqueuehandler.php 23
26581 -       print "This script must be run from the command line\n";
26582 -       exit();
26583 +    print "This script must be run from the command line\n";
26584 +    exit();
26585 hunk ./scripts/ombqueuehandler.php 37
26586 -       
26587 -       function transport() {
26588 -               return 'omb';
26589 -       }
26590 -       
26591 -       function start() {
26592 -               $this->log(LOG_INFO, "INITIALIZE");
26593 -               return true;
26594 -       }
26595 +    
26596 +    function transport() {
26597 +        return 'omb';
26598 +    }
26599 +    
26600 +    function start() {
26601 +        $this->log(LOG_INFO, "INITIALIZE");
26602 +        return true;
26603 +    }
26604 hunk ./scripts/ombqueuehandler.php 47
26605 -       function handle_notice($notice) {
26606 -               if ($this->is_remote($notice)) {
26607 -                       $this->log(LOG_DEBUG, 'Ignoring remote notice ' . $notice->id);
26608 -                       return true;
26609 -               } else {
26610 -                       return omb_broadcast_remote_subscribers($notice);
26611 -               }
26612 -       }
26613 -       
26614 -       function finish() {
26615 -       }
26616 +    function handle_notice($notice) {
26617 +        if ($this->is_remote($notice)) {
26618 +            $this->log(LOG_DEBUG, 'Ignoring remote notice ' . $notice->id);
26619 +            return true;
26620 +        } else {
26621 +            return omb_broadcast_remote_subscribers($notice);
26622 +        }
26623 +    }
26624 +    
26625 +    function finish() {
26626 +    }
26627 hunk ./scripts/ombqueuehandler.php 59
26628 -       function is_remote($notice) {
26629 -               $user = User::staticGet($notice->profile_id);
26630 -               return is_null($user);
26631 -       }
26632 +    function is_remote($notice) {
26633 +        $user = User::staticGet($notice->profile_id);
26634 +        return is_null($user);
26635 +    }
26636 hunk ./scripts/publicqueuehandler.php 23
26637 -       print "This script must be run from the command line\n";
26638 -       exit();
26639 +    print "This script must be run from the command line\n";
26640 +    exit();
26641 hunk ./scripts/publicqueuehandler.php 37
26642 -       
26643 -       function transport() {
26644 -               return 'public';
26645 -       }
26646 -       
26647 -       function handle_notice($notice) {
26648 -               try {
26649 -                       return jabber_public_notice($notice);
26650 -               } catch (XMPPHP_Exception $e) {
26651 -                       $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
26652 -                       die($e->getMessage());
26653 -               }
26654 -       }
26655 +    
26656 +    function transport() {
26657 +        return 'public';
26658 +    }
26659 +    
26660 +    function handle_notice($notice) {
26661 +        try {
26662 +            return jabber_public_notice($notice);
26663 +        } catch (XMPPHP_Exception $e) {
26664 +            $this->log(LOG_ERR, "Got an XMPPHP_Exception: " . $e->getMessage());
26665 +            die($e->getMessage());
26666 +        }
26667 +    }
26668 hunk ./scripts/sitemap.php 22
26669 -       global $output_paths;
26670 -       $output_dir = $output_paths['output_dir'];
26671 -       $output_url = $output_paths['output_url'];
26672 +    global $output_paths;
26673 +    $output_dir = $output_paths['output_dir'];
26674 +    $output_url = $output_paths['output_url'];
26675 hunk ./scripts/sitemap.php 26
26676 -       foreach (glob("$output_dir*.xml") as $file_name) {
26677 +    foreach (glob("$output_dir*.xml") as $file_name) {
26678 hunk ./scripts/sitemap.php 28
26679 -               # Just the file name please.
26680 -               $file_name = preg_replace("|$output_dir|", '', $file_name);
26681 +        # Just the file name please.
26682 +        $file_name = preg_replace("|$output_dir|", '', $file_name);
26683 hunk ./scripts/sitemap.php 31
26684 -               $index_urls .= sitemap(
26685 -                                                  array(
26686 -                                                                'url' => $output_url . $file_name,
26687 -                                                                'changefreq' => 'daily'
26688 -                                                                )
26689 -                                                  );
26690 -       }
26691 +        $index_urls .= sitemap(
26692 +                           array(
26693 +                                 'url' => $output_url . $file_name,
26694 +                                 'changefreq' => 'daily'
26695 +                                 )
26696 +                           );
26697 +    }
26698 hunk ./scripts/sitemap.php 39
26699 -       write_file($output_paths['index_file'], sitemapindex($index_urls));
26700 +    write_file($output_paths['index_file'], sitemapindex($index_urls));
26701 hunk ./scripts/sitemap.php 44
26702 -       global $output_paths;
26703 +    global $output_paths;
26704 hunk ./scripts/sitemap.php 46
26705 -       $standard_map_urls .= url(
26706 -                                                         array(
26707 -                                                                       'url' => common_local_url('public'),
26708 -                                                                       'changefreq' => 'daily',
26709 -                                                                       'priority' => '1',
26710 -                                                                       )
26711 -                                                         );
26712 +    $standard_map_urls .= url(
26713 +                              array(
26714 +                                    'url' => common_local_url('public'),
26715 +                                    'changefreq' => 'daily',
26716 +                                    'priority' => '1',
26717 +                                    )
26718 +                              );
26719 hunk ./scripts/sitemap.php 54
26720 -       $standard_map_urls .= url(
26721 -                                                         array(
26722 -                                                                       'url' => common_local_url('publicrss'),
26723 -                                                                       'changefreq' => 'daily',
26724 -                                                                       'priority' => '0.3',
26725 -                                                                       )
26726 -                                                         );
26727 +    $standard_map_urls .= url(
26728 +                              array(
26729 +                                    'url' => common_local_url('publicrss'),
26730 +                                    'changefreq' => 'daily',
26731 +                                    'priority' => '0.3',
26732 +                                    )
26733 +                              );
26734 hunk ./scripts/sitemap.php 62
26735 -       $docs = array('about', 'faq', 'contact', 'im', 'openid', 'openmublog', 'privacy', 'source');
26736 +    $docs = array('about', 'faq', 'contact', 'im', 'openid', 'openmublog', 'privacy', 'source');
26737 hunk ./scripts/sitemap.php 64
26738 -       foreach($docs as $title) {
26739 -               $standard_map_urls .= url(
26740 -                                                                 array(
26741 -                                                                               'url' => common_local_url('doc', array('title' => $title)),
26742 -                                                                               'changefreq' => 'monthly',
26743 -                                                                               'priority'   => '0.2',
26744 -                                                                               )
26745 -                                                                 );
26746 -       }
26747 +    foreach($docs as $title) {
26748 +        $standard_map_urls .= url(
26749 +                                  array(
26750 +                                        'url' => common_local_url('doc', array('title' => $title)),
26751 +                                        'changefreq' => 'monthly',
26752 +                                        'priority'   => '0.2',
26753 +                                        )
26754 +                                  );
26755 +    }
26756 hunk ./scripts/sitemap.php 74
26757 -       $urlset_path = $output_paths['output_dir'] . 'standard.xml';
26758 +    $urlset_path = $output_paths['output_dir'] . 'standard.xml';
26759 hunk ./scripts/sitemap.php 76
26760 -       write_file($urlset_path, urlset($standard_map_urls));
26761 +    write_file($urlset_path, urlset($standard_map_urls));
26762 hunk ./scripts/sitemap.php 81
26763 -       global $output_paths;
26764 +    global $output_paths;
26765 hunk ./scripts/sitemap.php 83
26766 -       $notices = DB_DataObject::factory('notice');
26767 +    $notices = DB_DataObject::factory('notice');
26768 hunk ./scripts/sitemap.php 85
26769 -       $notices->query('SELECT id, uri, url, modified FROM notice where is_local = 1');
26770 +    $notices->query('SELECT id, uri, url, modified FROM notice where is_local = 1');
26771 hunk ./scripts/sitemap.php 87
26772 -       $notice_count = 0;
26773 -       $map_count = 1;
26774 +    $notice_count = 0;
26775 +    $map_count = 1;
26776 hunk ./scripts/sitemap.php 90
26777 -       while ($notices->fetch()) {
26778 +    while ($notices->fetch()) {
26779 hunk ./scripts/sitemap.php 92
26780 -               # Maximum 50,000 URLs per sitemap file.
26781 -               if ($notice_count == 50000) {
26782 -                       $notice_count = 0;
26783 -                       $map_count++;
26784 -               }
26785 +        # Maximum 50,000 URLs per sitemap file.
26786 +        if ($notice_count == 50000) {
26787 +            $notice_count = 0;
26788 +            $map_count++;
26789 +        }
26790 hunk ./scripts/sitemap.php 98
26791 -               # remote notices have an URL
26792 -               
26793 -               if (!$notices->url && $notices->uri) {
26794 -                       $notice = array(
26795 -                                               'url'        => ($notices->uri) ? $notices->uri : common_local_url('shownotice', array('notice' => $notices->id)),
26796 -                                               'lastmod'    => common_date_w3dtf($notices->modified),
26797 -                                               'changefreq' => 'never',
26798 -                                               'priority'   => '1',
26799 -                                               );
26800 +        # remote notices have an URL
26801 +        
26802 +        if (!$notices->url && $notices->uri) {
26803 +            $notice = array(
26804 +                        'url'        => ($notices->uri) ? $notices->uri : common_local_url('shownotice', array('notice' => $notices->id)),
26805 +                        'lastmod'    => common_date_w3dtf($notices->modified),
26806 +                        'changefreq' => 'never',
26807 +                        'priority'   => '1',
26808 +                        );
26809 hunk ./scripts/sitemap.php 108
26810 -                       $notice_list[$map_count] .= url($notice);
26811 -                       $notice_count++;
26812 -               }
26813 -       }
26814 +            $notice_list[$map_count] .= url($notice);
26815 +            $notice_count++;
26816 +        }
26817 +    }
26818 hunk ./scripts/sitemap.php 113
26819 -       # Make full sitemaps from the lists and save them.
26820 -       array_to_map($notice_list, 'notice');
26821 +    # Make full sitemaps from the lists and save them.
26822 +    array_to_map($notice_list, 'notice');
26823 hunk ./scripts/sitemap.php 119
26824 -       global $output_paths;
26825 +    global $output_paths;
26826 hunk ./scripts/sitemap.php 121
26827 -       $users = DB_DataObject::factory('user');
26828 +    $users = DB_DataObject::factory('user');
26829 hunk ./scripts/sitemap.php 123
26830 -       $users->query('SELECT id, nickname FROM user');
26831 +    $users->query('SELECT id, nickname FROM user');
26832 hunk ./scripts/sitemap.php 125
26833 -       $user_count = 0;
26834 -       $map_count = 1;
26835 +    $user_count = 0;
26836 +    $map_count = 1;
26837 hunk ./scripts/sitemap.php 128
26838 -       while ($users->fetch()) {
26839 +    while ($users->fetch()) {
26840 hunk ./scripts/sitemap.php 130
26841 -               # Maximum 50,000 URLs per sitemap file.
26842 -               if ($user_count == 50000) {
26843 -                       $user_count = 0;
26844 -                       $map_count++;
26845 -               }
26846 +        # Maximum 50,000 URLs per sitemap file.
26847 +        if ($user_count == 50000) {
26848 +            $user_count = 0;
26849 +            $map_count++;
26850 +        }
26851 hunk ./scripts/sitemap.php 136
26852 -               $user_args = array('nickname' => $users->nickname);
26853 +        $user_args = array('nickname' => $users->nickname);
26854 hunk ./scripts/sitemap.php 138
26855 -               # Define parameters for generating <url></url> elements.
26856 -               $user = array(
26857 -                                         'url'        => common_local_url('showstream', $user_args),
26858 -                                         'changefreq' => 'daily',
26859 -                                         'priority'   => '1',
26860 -                                         );
26861 +        # Define parameters for generating <url></url> elements.
26862 +        $user = array(
26863 +                      'url'        => common_local_url('showstream', $user_args),
26864 +                      'changefreq' => 'daily',
26865 +                      'priority'   => '1',
26866 +                      );
26867 hunk ./scripts/sitemap.php 145
26868 -               $user_rss = array(
26869 -                                                 'url'        => common_local_url('userrss', $user_args),
26870 -                                                 'changefreq' => 'daily',
26871 -                                                 'priority'   => '0.3',
26872 -                                                 );
26873 +        $user_rss = array(
26874 +                          'url'        => common_local_url('userrss', $user_args),
26875 +                          'changefreq' => 'daily',
26876 +                          'priority'   => '0.3',
26877 +                          );
26878 hunk ./scripts/sitemap.php 151
26879 -               $all = array(
26880 -                                        'url'        => common_local_url('all', $user_args),
26881 -                                        'changefreq' => 'daily',
26882 -                                        'priority'   => '1',
26883 -                                        );
26884 +        $all = array(
26885 +                     'url'        => common_local_url('all', $user_args),
26886 +                     'changefreq' => 'daily',
26887 +                     'priority'   => '1',
26888 +                     );
26889 hunk ./scripts/sitemap.php 157
26890 -               $all_rss = array(
26891 -                                                'url'        => common_local_url('allrss', $user_args),
26892 -                                                'changefreq' => 'daily',
26893 -                                                'priority'   => '0.3',
26894 -                                                );
26895 +        $all_rss = array(
26896 +                         'url'        => common_local_url('allrss', $user_args),
26897 +                         'changefreq' => 'daily',
26898 +                         'priority'   => '0.3',
26899 +                         );
26900 hunk ./scripts/sitemap.php 163
26901 -               $replies = array(
26902 -                                                'url'        => common_local_url('replies', $user_args),
26903 -                                                'changefreq' => 'daily',
26904 -                                                'priority'   => '1',
26905 -                                                );
26906 +        $replies = array(
26907 +                         'url'        => common_local_url('replies', $user_args),
26908 +                         'changefreq' => 'daily',
26909 +                         'priority'   => '1',
26910 +                         );
26911 hunk ./scripts/sitemap.php 169
26912 -               $replies_rss = array(
26913 -                                                        'url'        => common_local_url('repliesrss', $user_args),
26914 -                                                        'changefreq' => 'daily',
26915 -                                                        'priority'   => '0.3',
26916 -                                                        );
26917 +        $replies_rss = array(
26918 +                             'url'        => common_local_url('repliesrss', $user_args),
26919 +                             'changefreq' => 'daily',
26920 +                             'priority'   => '0.3',
26921 +                             );
26922 hunk ./scripts/sitemap.php 175
26923 -               $foaf = array(
26924 -                                         'url'        => common_local_url('foaf', $user_args),
26925 -                                         'changefreq' => 'weekly',
26926 -                                         'priority'   => '0.5',
26927 -                                         );
26928 +        $foaf = array(
26929 +                      'url'        => common_local_url('foaf', $user_args),
26930 +                      'changefreq' => 'weekly',
26931 +                      'priority'   => '0.5',
26932 +                      );
26933 hunk ./scripts/sitemap.php 181
26934 -               # Construct a <url></url> element for each user facet and add it
26935 -               # to our existing list of those.
26936 -               $user_list[$map_count]        .= url($user);
26937 -               $user_rss_list[$map_count]    .= url($user_rss);
26938 -               $all_list[$map_count]         .= url($all);
26939 -               $all_rss_list[$map_count]     .= url($all_rss);
26940 -               $replies_list[$map_count]     .= url($replies);
26941 -               $replies_rss_list[$map_count] .= url($replies_rss);
26942 -               $foaf_list[$map_count]        .= url($foaf);
26943 +        # Construct a <url></url> element for each user facet and add it
26944 +        # to our existing list of those.
26945 +        $user_list[$map_count]        .= url($user);
26946 +        $user_rss_list[$map_count]    .= url($user_rss);
26947 +        $all_list[$map_count]         .= url($all);
26948 +        $all_rss_list[$map_count]     .= url($all_rss);
26949 +        $replies_list[$map_count]     .= url($replies);
26950 +        $replies_rss_list[$map_count] .= url($replies_rss);
26951 +        $foaf_list[$map_count]        .= url($foaf);
26952 hunk ./scripts/sitemap.php 191
26953 -               $user_count++;
26954 -       }
26955 +        $user_count++;
26956 +    }
26957 hunk ./scripts/sitemap.php 194
26958 -       # Make full sitemaps from the lists and save them.
26959 -       # Possible factoring: put all the lists into a master array, thus allowing
26960 -       # calling with single argument (i.e., array_to_map('user')).
26961 -       array_to_map($user_list, 'user');
26962 -       array_to_map($user_rss_list, 'user_rss');
26963 -       array_to_map($all_list, 'all');
26964 -       array_to_map($all_rss_list, 'all_rss');
26965 -       array_to_map($replies_list, 'replies');
26966 -       array_to_map($replies_rss_list, 'replies_rss');
26967 -       array_to_map($foaf_list, 'foaf');
26968 +    # Make full sitemaps from the lists and save them.
26969 +    # Possible factoring: put all the lists into a master array, thus allowing
26970 +    # calling with single argument (i.e., array_to_map('user')).
26971 +    array_to_map($user_list, 'user');
26972 +    array_to_map($user_rss_list, 'user_rss');
26973 +    array_to_map($all_list, 'all');
26974 +    array_to_map($all_rss_list, 'all_rss');
26975 +    array_to_map($replies_list, 'replies');
26976 +    array_to_map($replies_rss_list, 'replies_rss');
26977 +    array_to_map($foaf_list, 'foaf');
26978 hunk ./scripts/sitemap.php 212
26979 -       $url        = preg_replace('/&/', '&amp;', $url_args['url']); # escape ampersands for XML
26980 -       $lastmod    = $url_args['lastmod'];
26981 -       $changefreq = $url_args['changefreq'];
26982 -       $priority   = $url_args['priority'];
26983 +    $url        = preg_replace('/&/', '&amp;', $url_args['url']); # escape ampersands for XML
26984 +    $lastmod    = $url_args['lastmod'];
26985 +    $changefreq = $url_args['changefreq'];
26986 +    $priority   = $url_args['priority'];
26987 hunk ./scripts/sitemap.php 217
26988 -       if (is_null($url)) {
26989 -               error("url() arguments require 'url' value.");
26990 -       }
26991 +    if (is_null($url)) {
26992 +        error("url() arguments require 'url' value.");
26993 +    }
26994 hunk ./scripts/sitemap.php 221
26995 -       $url_out = "\t<url>\n";
26996 -       $url_out .= "\t\t<loc>$url</loc>\n";
26997 +    $url_out = "\t<url>\n";
26998 +    $url_out .= "\t\t<loc>$url</loc>\n";
26999 hunk ./scripts/sitemap.php 224
27000 -       if ($changefreq) {
27001 -               $url_out .= "\t\t<changefreq>$changefreq</changefreq>\n";
27002 -       }
27003 +    if ($changefreq) {
27004 +        $url_out .= "\t\t<changefreq>$changefreq</changefreq>\n";
27005 +    }
27006 hunk ./scripts/sitemap.php 228
27007 -       if ($lastmod) {
27008 -               $url_out .= "\t\t<lastmod>$lastmod</lastmod>\n";
27009 -       }
27010 +    if ($lastmod) {
27011 +        $url_out .= "\t\t<lastmod>$lastmod</lastmod>\n";
27012 +    }
27013 hunk ./scripts/sitemap.php 232
27014 -       if ($priority) {
27015 -               $url_out .= "\t\t<priority>$priority</priority>\n";
27016 -       }
27017 +    if ($priority) {
27018 +        $url_out .= "\t\t<priority>$priority</priority>\n";
27019 +    }
27020 hunk ./scripts/sitemap.php 236
27021 -       $url_out .= "\t</url>\n";
27022 +    $url_out .= "\t</url>\n";
27023 hunk ./scripts/sitemap.php 238
27024 -       return $url_out;
27025 +    return $url_out;
27026 hunk ./scripts/sitemap.php 242
27027 -       $url        = preg_replace('/&/', '&amp;', $sitemap_args['url']); # escape ampersands for XML
27028 -       $lastmod    = $sitemap_args['lastmod'];
27029 +    $url        = preg_replace('/&/', '&amp;', $sitemap_args['url']); # escape ampersands for XML
27030 +    $lastmod    = $sitemap_args['lastmod'];
27031 hunk ./scripts/sitemap.php 245
27032 -       if (is_null($url)) {
27033 -               error("url() arguments require 'url' value.");
27034 -       }
27035 +    if (is_null($url)) {
27036 +        error("url() arguments require 'url' value.");
27037 +    }
27038 hunk ./scripts/sitemap.php 249
27039 -       $sitemap_out = "\t<sitemap>\n";
27040 -       $sitemap_out .= "\t\t<loc>$url</loc>\n";
27041 +    $sitemap_out = "\t<sitemap>\n";
27042 +    $sitemap_out .= "\t\t<loc>$url</loc>\n";
27043 hunk ./scripts/sitemap.php 252
27044 -       if ($lastmod) {
27045 -               $sitemap_out .= "\t\t<lastmod>$lastmod</lastmod>\n";
27046 -       }
27047 +    if ($lastmod) {
27048 +        $sitemap_out .= "\t\t<lastmod>$lastmod</lastmod>\n";
27049 +    }
27050 hunk ./scripts/sitemap.php 256
27051 -       $sitemap_out .= "\t</sitemap>\n";
27052 +    $sitemap_out .= "\t</sitemap>\n";
27053 hunk ./scripts/sitemap.php 258
27054 -       return $sitemap_out;
27055 +    return $sitemap_out;
27056 hunk ./scripts/sitemap.php 263
27057 -       $urlset = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
27058 -         '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n" .
27059 -         $urlset_text .
27060 -         '</urlset>';
27061 +    $urlset = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
27062 +      '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n" .
27063 +      $urlset_text .
27064 +      '</urlset>';
27065 hunk ./scripts/sitemap.php 268
27066 -       return $urlset;
27067 +    return $urlset;
27068 hunk ./scripts/sitemap.php 273
27069 -       $sitemapindex = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
27070 -         '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n" .
27071 -         $sitemapindex_text .
27072 -         '</sitemapindex>';
27073 +    $sitemapindex = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" .
27074 +      '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n" .
27075 +      $sitemapindex_text .
27076 +      '</sitemapindex>';
27077 hunk ./scripts/sitemap.php 278
27078 -       return $sitemapindex;
27079 +    return $sitemapindex;
27080 hunk ./scripts/sitemap.php 283
27081 -       global $output_paths;
27082 +    global $output_paths;
27083 hunk ./scripts/sitemap.php 285
27084 -       if ($url_list) {
27085 -               # $map_urls is a long string containing concatenated <url></url> elements.
27086 -               while (list($map_idx, $map_urls) = each($url_list)) {
27087 -                       $urlset_path = $output_paths['output_dir'] . "$filename_prefix-$map_idx.xml";
27088 -                       
27089 -                       write_file($urlset_path, urlset($map_urls));
27090 -               }
27091 -       }
27092 +    if ($url_list) {
27093 +        # $map_urls is a long string containing concatenated <url></url> elements.
27094 +        while (list($map_idx, $map_urls) = each($url_list)) {
27095 +            $urlset_path = $output_paths['output_dir'] . "$filename_prefix-$map_idx.xml";
27096 +            
27097 +            write_file($urlset_path, urlset($map_urls));
27098 +        }
27099 +    }
27100 hunk ./scripts/sitemap.php 301
27101 -       $args = getopt('f:d:u:');
27102 +    $args = getopt('f:d:u:');
27103 hunk ./scripts/sitemap.php 303
27104 -       if (is_null($args[f]) && is_null($args[d]) && is_null($args[u])) {
27105 -               error('Mandatory arguments: -f <index file path> -d <output directory path> -u <URL of sitemaps directory>');
27106 -       }
27107 +    if (is_null($args[f]) && is_null($args[d]) && is_null($args[u])) {
27108 +        error('Mandatory arguments: -f <index file path> -d <output directory path> -u <URL of sitemaps directory>');
27109 +    }
27110 hunk ./scripts/sitemap.php 307
27111 -       if (is_null($args[f])) {
27112 -               error('You must specify an index file name with the -f option.');
27113 -       }
27114 +    if (is_null($args[f])) {
27115 +        error('You must specify an index file name with the -f option.');
27116 +    }
27117 hunk ./scripts/sitemap.php 311
27118 -       if (is_null($args[d])) {
27119 -               error('You must specify a directory for the output file with the -d option.');
27120 -       }
27121 +    if (is_null($args[d])) {
27122 +        error('You must specify a directory for the output file with the -d option.');
27123 +    }
27124 hunk ./scripts/sitemap.php 315
27125 -       if (is_null($args[u])) {
27126 -               error('You must specify a URL for the directory where the sitemaps will be kept with the -u option.');
27127 -       }
27128 +    if (is_null($args[u])) {
27129 +        error('You must specify a URL for the directory where the sitemaps will be kept with the -u option.');
27130 +    }
27131 hunk ./scripts/sitemap.php 319
27132 -       $index_file = $args[f];
27133 -       $output_dir = $args[d];
27134 -       $output_url = $args[u];
27135 +    $index_file = $args[f];
27136 +    $output_dir = $args[d];
27137 +    $output_url = $args[u];
27138 hunk ./scripts/sitemap.php 323
27139 -       if (file_exists($output_dir)) {
27140 -               if (is_writable($output_dir) === FALSE) {
27141 -                       error("$output_dir is not writable.");
27142 -               }
27143 -       }        else {
27144 -               error("output directory $output_dir does not exist.");
27145 -       }
27146 +    if (file_exists($output_dir)) {
27147 +        if (is_writable($output_dir) === FALSE) {
27148 +            error("$output_dir is not writable.");
27149 +        }
27150 +    }     else {
27151 +        error("output directory $output_dir does not exist.");
27152 +    }
27153 hunk ./scripts/sitemap.php 331
27154 -       $paths = array(
27155 -                                  'index_file' => $index_file,
27156 -                                  'output_dir' => trailing_slash($output_dir),
27157 -                                  'output_url' => trailing_slash($output_url),
27158 -                                  );
27159 +    $paths = array(
27160 +                   'index_file' => $index_file,
27161 +                   'output_dir' => trailing_slash($output_dir),
27162 +                   'output_url' => trailing_slash($output_url),
27163 +                   );
27164 hunk ./scripts/sitemap.php 337
27165 -       return $paths;
27166 +    return $paths;
27167 hunk ./scripts/sitemap.php 342
27168 -       if (preg_match('/\/$/', $path) == 0) {
27169 -               $path .= '/';
27170 -       }
27171 +    if (preg_match('/\/$/', $path) == 0) {
27172 +        $path .= '/';
27173 +    }
27174 hunk ./scripts/sitemap.php 346
27175 -       return $path;
27176 +    return $path;
27177 hunk ./scripts/sitemap.php 351
27178 -       if (is_null($path)) {
27179 -               error('No path specified for writing to.');
27180 -       }        elseif (is_null($data)) {
27181 -               error('No data specified for writing.');
27182 -       }
27183 +    if (is_null($path)) {
27184 +        error('No path specified for writing to.');
27185 +    }     elseif (is_null($data)) {
27186 +        error('No data specified for writing.');
27187 +    }
27188 hunk ./scripts/sitemap.php 357
27189 -       if (($fh_out = fopen($path,'w')) === FALSE) {
27190 -               error("couldn't open $path for writing.");
27191 -       }
27192 +    if (($fh_out = fopen($path,'w')) === FALSE) {
27193 +        error("couldn't open $path for writing.");
27194 +    }
27195 hunk ./scripts/sitemap.php 361
27196 -       if (fwrite($fh_out, $data) === FALSE) {
27197 -               error("couldn't write to $path.");
27198 -       }
27199 +    if (fwrite($fh_out, $data) === FALSE) {
27200 +        error("couldn't write to $path.");
27201 +    }
27202 hunk ./scripts/sitemap.php 368
27203 -       if (is_null($error_msg)) {
27204 -               $error_msg = 'error() was called without any explanation!';
27205 -       }
27206 +    if (is_null($error_msg)) {
27207 +        $error_msg = 'error() was called without any explanation!';
27208 +    }
27209 hunk ./scripts/sitemap.php 372
27210 -       echo "Error: $error_msg\n";
27211 -       exit(1);
27212 +    echo "Error: $error_msg\n";
27213 +    exit(1);
27214 hunk ./scripts/smsqueuehandler.php 23
27215 -       print "This script must be run from the command line\n";
27216 -       exit();
27217 +    print "This script must be run from the command line\n";
27218 +    exit();
27219 hunk ./scripts/smsqueuehandler.php 37
27220 -       
27221 -       function transport() {
27222 -               return 'sms';
27223 -       }
27224 +    
27225 +    function transport() {
27226 +        return 'sms';
27227 +    }
27228 hunk ./scripts/smsqueuehandler.php 42
27229 -       function start() {
27230 -               $this->log(LOG_INFO, "INITIALIZE");
27231 -               return true;
27232 -       }
27233 +    function start() {
27234 +        $this->log(LOG_INFO, "INITIALIZE");
27235 +        return true;
27236 +    }
27237 hunk ./scripts/smsqueuehandler.php 47
27238 -       function handle_notice($notice) {
27239 -               return mail_broadcast_notice_sms($notice);
27240 -       }
27241 -       
27242 -       function finish() {
27243 -       }
27244 +    function handle_notice($notice) {
27245 +        return mail_broadcast_notice_sms($notice);
27246 +    }
27247 +    
27248 +    function finish() {
27249 +    }
27250 hunk ./scripts/synctwitterfriends.php 14
27251 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
27252 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
27253 hunk ./scripts/synctwitterfriends.php 18
27254 - * along with this program.     If not, see <http://www.gnu.org/licenses/>.
27255 + * along with this program.     If not, see <http://www.gnu.org/licenses/>.
27256 hunk ./scripts/synctwitterfriends.php 23
27257 -       print "This script must be run from the command line\n";
27258 -       exit();
27259 +    print "This script must be run from the command line\n";
27260 +    exit();
27261 hunk ./scripts/synctwitterfriends.php 38
27262 -       if (($flink->friendsync & FOREIGN_FRIEND_RECV) == FOREIGN_FRIEND_RECV) {
27263 +    if (($flink->friendsync & FOREIGN_FRIEND_RECV) == FOREIGN_FRIEND_RECV) {
27264 hunk ./scripts/synctwitterfriends.php 40
27265 -               $user = User::staticGet($flink->user_id);
27266 +        $user = User::staticGet($flink->user_id);
27267 hunk ./scripts/synctwitterfriends.php 42
27268 -               print "Updating Twitter friends for user $user->nickname ($user->id)\n";
27269 +        print "Updating Twitter friends for user $user->nickname ($user->id)\n";
27270 hunk ./scripts/synctwitterfriends.php 44
27271 -               $fuser = $flink->getForeignUser();
27272 +        $fuser = $flink->getForeignUser();
27273 hunk ./scripts/synctwitterfriends.php 46
27274 -               $result = save_twitter_friends($user, $fuser->id, $fuser->nickname, $flink->credentials);
27275 +        $result = save_twitter_friends($user, $fuser->id, $fuser->nickname, $flink->credentials);
27276 hunk ./scripts/synctwitterfriends.php 48
27277 -               if ($result == false) {
27278 -                       print "Problems updating Twitter friends! Check the log.\n";
27279 -                       exit(1);
27280 -               }
27281 -       }
27282 +        if ($result == false) {
27283 +            print "Problems updating Twitter friends! Check the log.\n";
27284 +            exit(1);
27285 +        }
27286 +    }
27287 hunk ./scripts/update_translations.php 8
27288 -       'da_DK' => 'http://laconi.ca/translate/download.php?file_id=23',
27289 -       'nl_NL' => 'http://laconi.ca/translate/download.php?file_id=39',
27290 -       'en_NZ' => 'http://laconi.ca/translate/download.php?file_id=15',
27291 -       'eo'    => 'http://laconi.ca/translate/download.php?file_id=10',
27292 -       'fr_FR' => 'http://laconi.ca/translate/download.php?file_id=19',
27293 -       'de_DE' => 'http://laconi.ca/translate/download.php?file_id=18',
27294 -       'it_IT' => 'http://laconi.ca/translate/download.php?file_id=21',
27295 -       'ko'    => 'http://laconi.ca/translate/download.php?file_id=33',
27296 -       'no_NB' => 'http://laconi.ca/translate/download.php?file_id=31',
27297 -       'pt'    => 'http://laconi.ca/translate/download.php?file_id=8',
27298 -       'pt_BR' => 'http://laconi.ca/translate/download.php?file_id=72',
27299 -       'ru_RU' => 'http://laconi.ca/translate/download.php?file_id=26',
27300 -       'es'    => 'http://laconi.ca/translate/download.php?file_id=9',
27301 -       'tr_TR' => 'http://laconi.ca/translate/download.php?file_id=37',
27302 -       'uk_UA' => 'http://laconi.ca/translate/download.php?file_id=44',
27303 -       'he_IL' => 'http://laconi.ca/translate/download.php?file_id=71',
27304 -       'mk_MK' => 'http://laconi.ca/translate/download.php?file_id=67',
27305 -       'ja_JP' => 'http://laconi.ca/translate/download.php?file_id=43',
27306 -       'cs_CZ' => 'http://laconi.ca/translate/download.php?file_id=63',
27307 -       'ca_ES' => 'http://laconi.ca/translate/download.php?file_id=49',
27308 -       'pl_PL' => 'http://laconi.ca/translate/download.php?file_id=51',
27309 -       'sv_SE' => 'http://laconi.ca/translate/download.php?file_id=55'
27310 +    'da_DK' => 'http://laconi.ca/translate/download.php?file_id=23',
27311 +    'nl_NL' => 'http://laconi.ca/translate/download.php?file_id=39',
27312 +    'en_NZ' => 'http://laconi.ca/translate/download.php?file_id=15',
27313 +    'eo'    => 'http://laconi.ca/translate/download.php?file_id=10',
27314 +    'fr_FR' => 'http://laconi.ca/translate/download.php?file_id=19',
27315 +    'de_DE' => 'http://laconi.ca/translate/download.php?file_id=18',
27316 +    'it_IT' => 'http://laconi.ca/translate/download.php?file_id=21',
27317 +    'ko'    => 'http://laconi.ca/translate/download.php?file_id=33',
27318 +    'no_NB' => 'http://laconi.ca/translate/download.php?file_id=31',
27319 +    'pt'    => 'http://laconi.ca/translate/download.php?file_id=8',
27320 +    'pt_BR' => 'http://laconi.ca/translate/download.php?file_id=72',
27321 +    'ru_RU' => 'http://laconi.ca/translate/download.php?file_id=26',
27322 +    'es'    => 'http://laconi.ca/translate/download.php?file_id=9',
27323 +    'tr_TR' => 'http://laconi.ca/translate/download.php?file_id=37',
27324 +    'uk_UA' => 'http://laconi.ca/translate/download.php?file_id=44',
27325 +    'he_IL' => 'http://laconi.ca/translate/download.php?file_id=71',
27326 +    'mk_MK' => 'http://laconi.ca/translate/download.php?file_id=67',
27327 +    'ja_JP' => 'http://laconi.ca/translate/download.php?file_id=43',
27328 +    'cs_CZ' => 'http://laconi.ca/translate/download.php?file_id=63',
27329 +    'ca_ES' => 'http://laconi.ca/translate/download.php?file_id=49',
27330 +    'pl_PL' => 'http://laconi.ca/translate/download.php?file_id=51',
27331 +    'sv_SE' => 'http://laconi.ca/translate/download.php?file_id=55'
27332 hunk ./scripts/update_translations.php 35
27333 -       $lcdir='locale/'.$code;
27334 -       $msgdir=$lcdir.'/LC_MESSAGES';
27335 -       $pofile=$msgdir.'/laconica.po';
27336 -       $mofile=$msgdir.'/laconica.mo';
27337 +    $lcdir='locale/'.$code;
27338 +    $msgdir=$lcdir.'/LC_MESSAGES';
27339 +    $pofile=$msgdir.'/laconica.po';
27340 +    $mofile=$msgdir.'/laconica.mo';
27341 hunk ./scripts/update_translations.php 40
27342 -       /* Check for an existing */
27343 -       if (!is_dir($msgdir)) {
27344 -               mkdir($lcdir);
27345 -               mkdir($msgdir);
27346 -               $existingSHA1 = '';
27347 -       } else {
27348 -               $existingSHA1 = file_exists($pofile) ? sha1_file($pofile) : '';
27349 -       }
27350 +    /* Check for an existing */
27351 +    if (!is_dir($msgdir)) {
27352 +        mkdir($lcdir);
27353 +        mkdir($msgdir);
27354 +        $existingSHA1 = '';
27355 +    } else {
27356 +        $existingSHA1 = file_exists($pofile) ? sha1_file($pofile) : '';
27357 +    }
27358 hunk ./scripts/update_translations.php 49
27359 -       /* Get the remote one */
27360 -       $newFile = file_get_contents($file);
27361 +    /* Get the remote one */
27362 +    $newFile = file_get_contents($file);
27363 hunk ./scripts/update_translations.php 52
27364 -       // Update if the local .po file is different to the one downloaded, or
27365 -       // if the .mo file is not present.
27366 -       if(sha1($newFile)!=$existingSHA1 || !file_exists($mofile)) {
27367 -               echo "Updating ".$code."\n";
27368 -               file_put_contents($pofile, $newFile);
27369 -               $prevdir = getcwd();
27370 -               chdir($msgdir);
27371 -               system('msgmerge -U laconica.po ../../laconica.pot');
27372 -               system('msgfmt -f -o laconica.mo laconica.po');
27373 -               chdir($prevdir);
27374 -       } else {
27375 -               echo "Unchanged - ".$code."\n";
27376 -       }
27377 +    // Update if the local .po file is different to the one downloaded, or
27378 +    // if the .mo file is not present.
27379 +    if(sha1($newFile)!=$existingSHA1 || !file_exists($mofile)) {
27380 +        echo "Updating ".$code."\n";
27381 +        file_put_contents($pofile, $newFile);
27382 +        $prevdir = getcwd();
27383 +        chdir($msgdir);
27384 +        system('msgmerge -U laconica.po ../../laconica.pot');
27385 +        system('msgfmt -f -o laconica.mo laconica.po');
27386 +        chdir($prevdir);
27387 +    } else {
27388 +        echo "Unchanged - ".$code."\n";
27389 +    }
27390 hunk ./scripts/xmppconfirmhandler.php 23
27391 -       print "This script must be run from the command line\n";
27392 -       exit();
27393 +    print "This script must be run from the command line\n";
27394 +    exit();
27395 hunk ./scripts/xmppconfirmhandler.php 40
27396 -       var $_id = 'confirm';
27397 -       
27398 -       function class_name() {
27399 -               return 'XmppConfirmHandler';
27400 -       }
27401 -       
27402 -       function run() {
27403 -               if (!$this->start()) {
27404 -                       return false;
27405 -               }
27406 -               $this->log(LOG_INFO, 'checking for queued confirmations');
27407 -               do {
27408 -                       $confirm = $this->next_confirm();
27409 -                       if ($confirm) {
27410 -                               $this->log(LOG_INFO, 'Sending confirmation for ' . $confirm->address);
27411 -                               $user = User::staticGet($confirm->user_id);
27412 -                               if (!$user) {
27413 -                                       $this->log(LOG_WARNING, 'Confirmation for unknown user ' . $confirm->user_id);
27414 -                                       continue;
27415 -                               }
27416 -                               $success = jabber_confirm_address($confirm->code,
27417 -                                                                                                 $user->nickname,
27418 -                                                                                                 $confirm->address);
27419 -                               if (!$success) {
27420 -                                       $this->log(LOG_ERR, 'Confirmation failed for ' . $confirm->address);
27421 -                                       # Just let the claim age out; hopefully things work then
27422 -                                       continue;
27423 -                               } else {
27424 -                                       $this->log(LOG_INFO, 'Confirmation sent for ' . $confirm->address);
27425 -                                       # Mark confirmation sent; need a dupe so we don't have the WHERE clause
27426 -                                       $dupe = Confirm_address::staticGet('code', $confirm->code);
27427 -                                       if (!$dupe) {
27428 -                                               common_log(LOG_WARNING, 'Could not refetch confirm', __FILE__);
27429 -                                               continue;
27430 -                                       }
27431 -                                       $orig = clone($dupe);
27432 -                                       $dupe->sent = $dupe->claimed;
27433 -                                       $result = $dupe->update($orig);
27434 -                                       if (!$result) {
27435 -                                               common_log_db_error($dupe, 'UPDATE', __FILE__);
27436 -                                               # Just let the claim age out; hopefully things work then
27437 -                                               continue;
27438 -                                       }
27439 -                                       $dupe->free();
27440 -                                       unset($dupe);
27441 -                               }
27442 -                               $user->free();
27443 -                               unset($user);
27444 -                               $confirm->free();
27445 -                               unset($confirm);
27446 -                               $this->idle(0);
27447 -                       } else {
27448 -#                              $this->clear_old_confirm_claims();
27449 -                               $this->idle(10);
27450 -                       }
27451 -               } while (true);
27452 -               if (!$this->finish()) {
27453 -                       return false;
27454 -               }
27455 -               return true;
27456 -       }
27457 +    var $_id = 'confirm';
27458 +    
27459 +    function class_name() {
27460 +        return 'XmppConfirmHandler';
27461 +    }
27462 +    
27463 +    function run() {
27464 +        if (!$this->start()) {
27465 +            return false;
27466 +        }
27467 +        $this->log(LOG_INFO, 'checking for queued confirmations');
27468 +        do {
27469 +            $confirm = $this->next_confirm();
27470 +            if ($confirm) {
27471 +                $this->log(LOG_INFO, 'Sending confirmation for ' . $confirm->address);
27472 +                $user = User::staticGet($confirm->user_id);
27473 +                if (!$user) {
27474 +                    $this->log(LOG_WARNING, 'Confirmation for unknown user ' . $confirm->user_id);
27475 +                    continue;
27476 +                }
27477 +                $success = jabber_confirm_address($confirm->code,
27478 +                                                  $user->nickname,
27479 +                                                  $confirm->address);
27480 +                if (!$success) {
27481 +                    $this->log(LOG_ERR, 'Confirmation failed for ' . $confirm->address);
27482 +                    # Just let the claim age out; hopefully things work then
27483 +                    continue;
27484 +                } else {
27485 +                    $this->log(LOG_INFO, 'Confirmation sent for ' . $confirm->address);
27486 +                    # Mark confirmation sent; need a dupe so we don't have the WHERE clause
27487 +                    $dupe = Confirm_address::staticGet('code', $confirm->code);
27488 +                    if (!$dupe) {
27489 +                        common_log(LOG_WARNING, 'Could not refetch confirm', __FILE__);
27490 +                        continue;
27491 +                    }
27492 +                    $orig = clone($dupe);
27493 +                    $dupe->sent = $dupe->claimed;
27494 +                    $result = $dupe->update($orig);
27495 +                    if (!$result) {
27496 +                        common_log_db_error($dupe, 'UPDATE', __FILE__);
27497 +                        # Just let the claim age out; hopefully things work then
27498 +                        continue;
27499 +                    }
27500 +                    $dupe->free();
27501 +                    unset($dupe);
27502 +                }
27503 +                $user->free();
27504 +                unset($user);
27505 +                $confirm->free();
27506 +                unset($confirm);
27507 +                $this->idle(0);
27508 +            } else {
27509 +#                $this->clear_old_confirm_claims();
27510 +                $this->idle(10);
27511 +            }
27512 +        } while (true);
27513 +        if (!$this->finish()) {
27514 +            return false;
27515 +        }
27516 +        return true;
27517 +    }
27518 hunk ./scripts/xmppconfirmhandler.php 102
27519 -       function next_confirm() {
27520 -               $confirm = new Confirm_address();
27521 -               $confirm->whereAdd('claimed IS NULL');
27522 -               $confirm->whereAdd('sent IS NULL');
27523 -               # XXX: eventually we could do other confirmations in the queue, too
27524 -               $confirm->address_type = 'jabber';
27525 -               $confirm->orderBy('modified DESC');
27526 -               $confirm->limit(1);
27527 -               if ($confirm->find(TRUE)) {
27528 -                       $this->log(LOG_INFO, 'Claiming confirmation for ' . $confirm->address);
27529 -                       # working around some weird DB_DataObject behaviour
27530 -                       $confirm->whereAdd(''); # clears where stuff
27531 -                       $original = clone($confirm);
27532 -                       $confirm->claimed = common_sql_now();
27533 -                       $result = $confirm->update($original);
27534 -                       if ($result) {
27535 -                               $this->log(LOG_INFO, 'Succeeded in claim! '. $result);
27536 -                               return $confirm;
27537 -                       } else {
27538 -                               $this->log(LOG_INFO, 'Failed in claim!');
27539 -                               return false;
27540 -                       }
27541 -               }
27542 -               return NULL;
27543 -       }
27544 +    function next_confirm() {
27545 +        $confirm = new Confirm_address();
27546 +        $confirm->whereAdd('claimed IS NULL');
27547 +        $confirm->whereAdd('sent IS NULL');
27548 +        # XXX: eventually we could do other confirmations in the queue, too
27549 +        $confirm->address_type = 'jabber';
27550 +        $confirm->orderBy('modified DESC');
27551 +        $confirm->limit(1);
27552 +        if ($confirm->find(TRUE)) {
27553 +            $this->log(LOG_INFO, 'Claiming confirmation for ' . $confirm->address);
27554 +                # working around some weird DB_DataObject behaviour
27555 +            $confirm->whereAdd(''); # clears where stuff
27556 +            $original = clone($confirm);
27557 +            $confirm->claimed = common_sql_now();
27558 +            $result = $confirm->update($original);
27559 +            if ($result) {
27560 +                $this->log(LOG_INFO, 'Succeeded in claim! '. $result);
27561 +                return $confirm;
27562 +            } else {
27563 +                $this->log(LOG_INFO, 'Failed in claim!');
27564 +                return false;
27565 +            }
27566 +        }
27567 +        return NULL;
27568 +    }
27569 hunk ./scripts/xmppconfirmhandler.php 128
27570 -       function clear_old_confirm_claims() {
27571 -               $confirm = new Confirm();
27572 -               $confirm->claimed = NULL;
27573 -               $confirm->whereAdd('now() - claimed > '.CLAIM_TIMEOUT);
27574 -               $confirm->update(DB_DATAOBJECT_WHEREADD_ONLY);
27575 -               $confirm->free();
27576 -               unset($confirm);
27577 -       }
27578 +    function clear_old_confirm_claims() {
27579 +        $confirm = new Confirm();
27580 +        $confirm->claimed = NULL;
27581 +        $confirm->whereAdd('now() - claimed > '.CLAIM_TIMEOUT);
27582 +        $confirm->update(DB_DATAOBJECT_WHEREADD_ONLY);
27583 +        $confirm->free();
27584 +        unset($confirm);
27585 +    }
27586 hunk ./scripts/xmppdaemon.php 23
27587 -       print "This script must be run from the command line\n";
27588 -       exit();
27589 +    print "This script must be run from the command line\n";
27590 +    exit();
27591 hunk ./scripts/xmppdaemon.php 42
27592 -       function XMPPDaemon($resource=NULL) {
27593 -               static $attrs = array('server', 'port', 'user', 'password', 'host');
27594 +    function XMPPDaemon($resource=NULL) {
27595 +        static $attrs = array('server', 'port', 'user', 'password', 'host');
27596 hunk ./scripts/xmppdaemon.php 45
27597 -               foreach ($attrs as $attr)
27598 -               {
27599 -                       $this->$attr = common_config('xmpp', $attr);
27600 -               }
27601 +        foreach ($attrs as $attr)
27602 +        {
27603 +            $this->$attr = common_config('xmpp', $attr);
27604 +        }
27605 hunk ./scripts/xmppdaemon.php 50
27606 -               if ($resource) {
27607 -                       $this->resource = $resource;
27608 -               } else {
27609 -                       $this->resource = common_config('xmpp', 'resource') . 'daemon';
27610 -               }
27611 +        if ($resource) {
27612 +            $this->resource = $resource;
27613 +        } else {
27614 +            $this->resource = common_config('xmpp', 'resource') . 'daemon';
27615 +        }
27616 hunk ./scripts/xmppdaemon.php 56
27617 -               $this->log(LOG_INFO, "INITIALIZE XMPPDaemon {$this->user}@{$this->server}/{$this->resource}");
27618 -       }
27619 +        $this->log(LOG_INFO, "INITIALIZE XMPPDaemon {$this->user}@{$this->server}/{$this->resource}");
27620 +    }
27621 hunk ./scripts/xmppdaemon.php 59
27622 -       function connect() {
27623 +    function connect() {
27624 hunk ./scripts/xmppdaemon.php 61
27625 -               $connect_to = ($this->host) ? $this->host : $this->server;
27626 +        $connect_to = ($this->host) ? $this->host : $this->server;
27627 hunk ./scripts/xmppdaemon.php 63
27628 -               $this->log(LOG_INFO, "Connecting to $connect_to on port $this->port");
27629 +        $this->log(LOG_INFO, "Connecting to $connect_to on port $this->port");
27630 hunk ./scripts/xmppdaemon.php 65
27631 -               $this->conn = jabber_connect($this->resource);
27632 +        $this->conn = jabber_connect($this->resource);
27633 hunk ./scripts/xmppdaemon.php 67
27634 -               if (!$this->conn) {
27635 -                       return false;
27636 -               }
27637 +        if (!$this->conn) {
27638 +            return false;
27639 +        }
27640 hunk ./scripts/xmppdaemon.php 71
27641 -               $this->conn->setReconnectTimeout(600);
27642 +        $this->conn->setReconnectTimeout(600);
27643 hunk ./scripts/xmppdaemon.php 73
27644 -               jabber_send_presence("Send me a message to post a notice", 'available',
27645 -                                                        NULL, 'available', 100);
27646 -               return !$this->conn->isDisconnected();
27647 -       }
27648 +        jabber_send_presence("Send me a message to post a notice", 'available',
27649 +                             NULL, 'available', 100);
27650 +        return !$this->conn->isDisconnected();
27651 +    }
27652 hunk ./scripts/xmppdaemon.php 78
27653 -       function name() {
27654 -               return strtolower('xmppdaemon.'.$this->resource);
27655 -       }
27656 +    function name() {
27657 +        return strtolower('xmppdaemon.'.$this->resource);
27658 +    }
27659 hunk ./scripts/xmppdaemon.php 82
27660 -       function run() {
27661 -               if ($this->connect()) {
27662 +    function run() {
27663 +        if ($this->connect()) {
27664 hunk ./scripts/xmppdaemon.php 85
27665 -                       $this->conn->addEventHandler('message', 'handle_message', $this);
27666 -                       $this->conn->addEventHandler('presence', 'handle_presence', $this);
27667 -                       $this->conn->addEventHandler('reconnect', 'handle_reconnect', $this);
27668 +            $this->conn->addEventHandler('message', 'handle_message', $this);
27669 +            $this->conn->addEventHandler('presence', 'handle_presence', $this);
27670 +            $this->conn->addEventHandler('reconnect', 'handle_reconnect', $this);
27671 hunk ./scripts/xmppdaemon.php 89
27672 -                       $this->conn->process();
27673 -               }
27674 -       }
27675 +            $this->conn->process();
27676 +        }
27677 +    }
27678 hunk ./scripts/xmppdaemon.php 93
27679 -       function handle_reconnect(&$pl) {
27680 -               $this->conn->processUntil('session_start');
27681 -               $this->conn->presence('Send me a message to post a notice', 'available', NULL, 'available', 100);
27682 -       }
27683 +    function handle_reconnect(&$pl) {
27684 +        $this->conn->processUntil('session_start');
27685 +        $this->conn->presence('Send me a message to post a notice', 'available', NULL, 'available', 100);
27686 +    }
27687 hunk ./scripts/xmppdaemon.php 98
27688 -       function get_user($from) {
27689 -               $user = User::staticGet('jabber', jabber_normalize_jid($from));
27690 -               return $user;
27691 -       }
27692 +    function get_user($from) {
27693 +        $user = User::staticGet('jabber', jabber_normalize_jid($from));
27694 +        return $user;
27695 +    }
27696 hunk ./scripts/xmppdaemon.php 103
27697 -       function handle_message(&$pl) {
27698 -               if ($pl['type'] != 'chat') {
27699 -                       return;
27700 -               }
27701 -               if (mb_strlen($pl['body']) == 0) {
27702 -                       return;
27703 -               }
27704 +    function handle_message(&$pl) {
27705 +        if ($pl['type'] != 'chat') {
27706 +            return;
27707 +        }
27708 +        if (mb_strlen($pl['body']) == 0) {
27709 +            return;
27710 +        }
27711 hunk ./scripts/xmppdaemon.php 111
27712 -               $from = jabber_normalize_jid($pl['from']);
27713 +        $from = jabber_normalize_jid($pl['from']);
27714 hunk ./scripts/xmppdaemon.php 113
27715 -               # Forwarded from another daemon (probably a broadcaster) for
27716 -               # us to handle
27717 +        # Forwarded from another daemon (probably a broadcaster) for
27718 +        # us to handle
27719 hunk ./scripts/xmppdaemon.php 116
27720 -               if ($this->is_self($from)) {
27721 -                       $from = $this->get_ofrom($pl);
27722 -                       if (is_null($from) || $this->is_self($from)) {
27723 -                               return;
27724 -                       }
27725 -               }
27726 +        if ($this->is_self($from)) {
27727 +            $from = $this->get_ofrom($pl);
27728 +            if (is_null($from) || $this->is_self($from)) {
27729 +                return;
27730 +            }
27731 +        }
27732 hunk ./scripts/xmppdaemon.php 123
27733 -               $user = $this->get_user($from);
27734 +        $user = $this->get_user($from);
27735 hunk ./scripts/xmppdaemon.php 125
27736 -               if (!$user) {
27737 -                       $this->from_site($from, 'Unknown user; go to ' .
27738 -                                                        common_local_url('imsettings') .
27739 -                                                        ' to add your address to your account');
27740 -                       $this->log(LOG_WARNING, 'Message from unknown user ' . $from);
27741 -                       return;
27742 -               }
27743 -               if ($this->handle_command($user, $pl['body'])) {
27744 -                       return;
27745 -               } else if ($this->is_autoreply($pl['body'])) {
27746 -                       $this->log(LOG_INFO, 'Ignoring auto reply from ' . $from);
27747 -                       return;
27748 -               } else if ($this->is_otr($pl['body'])) {
27749 -                       $this->log(LOG_INFO, 'Ignoring OTR from ' . $from);
27750 -                       return;
27751 -               } else if ($this->is_direct($pl['body'])) {
27752 -                       preg_match_all('/d[\ ]*([a-z0-9]{1,64})/', $pl['body'], $to);
27753 +        if (!$user) {
27754 +            $this->from_site($from, 'Unknown user; go to ' .
27755 +                             common_local_url('imsettings') .
27756 +                             ' to add your address to your account');
27757 +            $this->log(LOG_WARNING, 'Message from unknown user ' . $from);
27758 +            return;
27759 +        }
27760 +        if ($this->handle_command($user, $pl['body'])) {
27761 +            return;
27762 +        } else if ($this->is_autoreply($pl['body'])) {
27763 +            $this->log(LOG_INFO, 'Ignoring auto reply from ' . $from);
27764 +            return;
27765 +        } else if ($this->is_otr($pl['body'])) {
27766 +            $this->log(LOG_INFO, 'Ignoring OTR from ' . $from);
27767 +            return;
27768 +        } else if ($this->is_direct($pl['body'])) {
27769 +            preg_match_all('/d[\ ]*([a-z0-9]{1,64})/', $pl['body'], $to);
27770 hunk ./scripts/xmppdaemon.php 143
27771 -                       $to = preg_replace('/^d([\ ])*/', '', $to[0][0]);
27772 -                       $body = preg_replace('/d[\ ]*('. $to .')[\ ]*/', '', $pl['body']);
27773 -                       $this->add_direct($user, $body, $to, $from);
27774 -               } else {
27775 -                       $len = mb_strlen($pl['body']);
27776 -                       if($len > 140) {
27777 -                               $this->from_site($from, 'Message too long - maximum is 140 characters, you sent ' . $len);
27778 -                               return;
27779 -                       }
27780 -                       $this->add_notice($user, $pl);
27781 -               }
27782 +            $to = preg_replace('/^d([\ ])*/', '', $to[0][0]);
27783 +            $body = preg_replace('/d[\ ]*('. $to .')[\ ]*/', '', $pl['body']);
27784 +            $this->add_direct($user, $body, $to, $from);
27785 +        } else {
27786 +            $len = mb_strlen($pl['body']);
27787 +            if($len > 140) {
27788 +                $this->from_site($from, 'Message too long - maximum is 140 characters, you sent ' . $len);
27789 +                return;
27790 +            }
27791 +            $this->add_notice($user, $pl);
27792 +        }
27793 hunk ./scripts/xmppdaemon.php 155
27794 -               $user->free();
27795 -               unset($user);
27796 -       }
27797 +        $user->free();
27798 +        unset($user);
27799 +    }
27800 hunk ./scripts/xmppdaemon.php 159
27801 -       function is_self($from) {
27802 -               return preg_match('/^'.strtolower(jabber_daemon_address()).'/', strtolower($from));
27803 -       }
27804 +    function is_self($from) {
27805 +        return preg_match('/^'.strtolower(jabber_daemon_address()).'/', strtolower($from));
27806 +    }
27807 hunk ./scripts/xmppdaemon.php 163
27808 -       function get_ofrom($pl) {
27809 -               $xml = $pl['xml'];
27810 -               $addresses = $xml->sub('addresses');
27811 -               if (!$addresses) {
27812 -                       $this->log(LOG_WARNING, 'Forwarded message without addresses');
27813 -                       return NULL;
27814 -               }
27815 -               $address = $addresses->sub('address');
27816 -               if (!$address) {
27817 -                       $this->log(LOG_WARNING, 'Forwarded message without address');
27818 -                       return NULL;
27819 -               }
27820 -               if (!array_key_exists('type', $address->attrs)) {
27821 -                       $this->log(LOG_WARNING, 'No type for forwarded message');
27822 -                       return NULL;
27823 -               }
27824 -               $type = $address->attrs['type'];
27825 -               if ($type != 'ofrom') {
27826 -                       $this->log(LOG_WARNING, 'Type of forwarded message is not ofrom');
27827 -                       return NULL;
27828 -               }
27829 -               if (!array_key_exists('jid', $address->attrs)) {
27830 -                       $this->log(LOG_WARNING, 'No jid for forwarded message');
27831 -                       return NULL;
27832 -               }
27833 -               $jid = $address->attrs['jid'];
27834 -               if (!$jid) {
27835 -                       $this->log(LOG_WARNING, 'Could not get jid from address');
27836 -                       return NULL;
27837 -               }
27838 -               $this->log(LOG_DEBUG, 'Got message forwarded from jid ' . $jid);
27839 -               return $jid;
27840 -       }
27841 +    function get_ofrom($pl) {
27842 +        $xml = $pl['xml'];
27843 +        $addresses = $xml->sub('addresses');
27844 +        if (!$addresses) {
27845 +            $this->log(LOG_WARNING, 'Forwarded message without addresses');
27846 +            return NULL;
27847 +        }
27848 +        $address = $addresses->sub('address');
27849 +        if (!$address) {
27850 +            $this->log(LOG_WARNING, 'Forwarded message without address');
27851 +            return NULL;
27852 +        }
27853 +        if (!array_key_exists('type', $address->attrs)) {
27854 +            $this->log(LOG_WARNING, 'No type for forwarded message');
27855 +            return NULL;
27856 +        }
27857 +        $type = $address->attrs['type'];
27858 +        if ($type != 'ofrom') {
27859 +            $this->log(LOG_WARNING, 'Type of forwarded message is not ofrom');
27860 +            return NULL;
27861 +        }
27862 +        if (!array_key_exists('jid', $address->attrs)) {
27863 +            $this->log(LOG_WARNING, 'No jid for forwarded message');
27864 +            return NULL;
27865 +        }
27866 +        $jid = $address->attrs['jid'];
27867 +        if (!$jid) {
27868 +            $this->log(LOG_WARNING, 'Could not get jid from address');
27869 +            return NULL;
27870 +        }
27871 +        $this->log(LOG_DEBUG, 'Got message forwarded from jid ' . $jid);
27872 +        return $jid;
27873 +    }
27874 hunk ./scripts/xmppdaemon.php 197
27875 -       function is_autoreply($txt) {
27876 -               if (preg_match('/[\[\(]?[Aa]uto[-\s]?[Rr]e(ply|sponse)[\]\)]/', $txt)) {
27877 -                       return true;
27878 -               } else {
27879 -                       return false;
27880 -               }
27881 -       }
27882 +    function is_autoreply($txt) {
27883 +        if (preg_match('/[\[\(]?[Aa]uto[-\s]?[Rr]e(ply|sponse)[\]\)]/', $txt)) {
27884 +            return true;
27885 +        } else {
27886 +            return false;
27887 +        }
27888 +    }
27889 hunk ./scripts/xmppdaemon.php 205
27890 -       function is_otr($txt) {
27891 -               if (preg_match('/^\?OTR/', $txt)) {
27892 -                       return true;
27893 -               } else {
27894 -                       return false;
27895 -               }
27896 -       }
27897 +    function is_otr($txt) {
27898 +        if (preg_match('/^\?OTR/', $txt)) {
27899 +            return true;
27900 +        } else {
27901 +            return false;
27902 +        }
27903 +    }
27904 hunk ./scripts/xmppdaemon.php 213
27905 -       function is_direct($txt) {
27906 -               if (strtolower(substr($txt, 0, 2))=='d ') {
27907 -                       return true;
27908 -               } else {
27909 -                       return false;
27910 -               }
27911 -       }
27912 +    function is_direct($txt) {
27913 +        if (strtolower(substr($txt, 0, 2))=='d ') {
27914 +            return true;
27915 +        } else {
27916 +            return false;
27917 +        }
27918 +    }
27919 hunk ./scripts/xmppdaemon.php 221
27920 -       function from_site($address, $msg) {
27921 -               $text = '['.common_config('site', 'name') . '] ' . $msg;
27922 -               jabber_send_message($address, $text);
27923 -       }
27924 +    function from_site($address, $msg) {
27925 +        $text = '['.common_config('site', 'name') . '] ' . $msg;
27926 +        jabber_send_message($address, $text);
27927 +    }
27928 hunk ./scripts/xmppdaemon.php 226
27929 -       function handle_command($user, $body) {
27930 -               $inter = new CommandInterpreter();
27931 -               $cmd = $inter->handle_command($user, $body);
27932 -               if ($cmd) {
27933 -                       $chan = new XMPPChannel($this->conn);
27934 -                       $cmd->execute($chan);
27935 -                       return true;
27936 -               } else {
27937 -                       return false;
27938 -               }
27939 -       }
27940 +    function handle_command($user, $body) {
27941 +        $inter = new CommandInterpreter();
27942 +        $cmd = $inter->handle_command($user, $body);
27943 +        if ($cmd) {
27944 +            $chan = new XMPPChannel($this->conn);
27945 +            $cmd->execute($chan);
27946 +            return true;
27947 +        } else {
27948 +            return false;
27949 +        }
27950 +    }
27951 hunk ./scripts/xmppdaemon.php 238
27952 -       function add_notice(&$user, &$pl) {
27953 +    function add_notice(&$user, &$pl) {
27954 hunk ./scripts/xmppdaemon.php 248
27955 -               $notice = Notice::saveNew($user->id, $content, 'xmpp');
27956 -               if (is_string($notice)) {
27957 -                       $this->log(LOG_ERR, $notice);
27958 -                       return;
27959 -               }
27960 -               common_broadcast_notice($notice);
27961 -               $this->log(LOG_INFO,
27962 -                                  'Added notice ' . $notice->id . ' from user ' . $user->nickname);
27963 -               $notice->free();
27964 -               unset($notice);
27965 -       }
27966 +        $notice = Notice::saveNew($user->id, $content, 'xmpp');
27967 +        if (is_string($notice)) {
27968 +            $this->log(LOG_ERR, $notice);
27969 +            return;
27970 +        }
27971 +        common_broadcast_notice($notice);
27972 +        $this->log(LOG_INFO,
27973 +                   'Added notice ' . $notice->id . ' from user ' . $user->nickname);
27974 +        $notice->free();
27975 +        unset($notice);
27976 +    }
27977 hunk ./scripts/xmppdaemon.php 260
27978 -       function handle_presence(&$pl) {
27979 -               $from = jabber_normalize_jid($pl['from']);
27980 -               switch ($pl['type']) {
27981 -                case 'subscribe':
27982 -                       # We let anyone subscribe
27983 -                       $this->subscribed($from);
27984 -                       $this->log(LOG_INFO,
27985 -                                          'Accepted subscription from ' . $from);
27986 -                       break;
27987 -                case 'subscribed':
27988 -                case 'unsubscribed':
27989 -                case 'unsubscribe':
27990 -                       $this->log(LOG_INFO,
27991 -                                          'Ignoring  "' . $pl['type'] . '" from ' . $from);
27992 -                       break;
27993 -                default:
27994 -                       if (!$pl['type']) {
27995 -                               $user = User::staticGet('jabber', $from);
27996 -                               if (!$user) {
27997 -                                       $this->log(LOG_WARNING, 'Presence from unknown user ' . $from);
27998 -                                       return;
27999 -                               }
28000 -                               if ($user->updatefrompresence) {
28001 -                                       $this->log(LOG_INFO, 'Updating ' . $user->nickname .
28002 -                                                          ' status from presence.');
28003 -                                       $this->add_notice($user, $pl);
28004 -                               }
28005 -                               $user->free();
28006 -                               unset($user);
28007 -                       }
28008 -                       break;
28009 -               }
28010 -       }
28011 +    function handle_presence(&$pl) {
28012 +        $from = jabber_normalize_jid($pl['from']);
28013 +        switch ($pl['type']) {
28014 +         case 'subscribe':
28015 +            # We let anyone subscribe
28016 +            $this->subscribed($from);
28017 +            $this->log(LOG_INFO,
28018 +                       'Accepted subscription from ' . $from);
28019 +            break;
28020 +         case 'subscribed':
28021 +         case 'unsubscribed':
28022 +         case 'unsubscribe':
28023 +            $this->log(LOG_INFO,
28024 +                       'Ignoring  "' . $pl['type'] . '" from ' . $from);
28025 +            break;
28026 +         default:
28027 +            if (!$pl['type']) {
28028 +                $user = User::staticGet('jabber', $from);
28029 +                if (!$user) {
28030 +                    $this->log(LOG_WARNING, 'Presence from unknown user ' . $from);
28031 +                    return;
28032 +                }
28033 +                if ($user->updatefrompresence) {
28034 +                    $this->log(LOG_INFO, 'Updating ' . $user->nickname .
28035 +                               ' status from presence.');
28036 +                    $this->add_notice($user, $pl);
28037 +                }
28038 +                $user->free();
28039 +                unset($user);
28040 +            }
28041 +            break;
28042 +        }
28043 +    }
28044 hunk ./scripts/xmppdaemon.php 294
28045 -       function log($level, $msg) {
28046 -               common_log($level, 'XMPPDaemon('.$this->resource.'): '.$msg);
28047 -       }
28048 +    function log($level, $msg) {
28049 +        common_log($level, 'XMPPDaemon('.$this->resource.'): '.$msg);
28050 +    }
28051 hunk ./scripts/xmppdaemon.php 298
28052 -       function subscribed($to) {
28053 -               jabber_special_presence('subscribed', $to);
28054 -       }
28055 +    function subscribed($to) {
28056 +        jabber_special_presence('subscribed', $to);
28057 +    }