git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit edbc0c66 authored by Evan Prodromou's avatar Evan Prodromou

replace all tabs with four spaces

The PEAR coding standards decree: no tabs, but indent by four spaces.
I've done a global search-and-replace on all tabs, replacing them by
four spaces. This is a huge change, but it will go a long way to
getting us towards phpcs-compliance. And that means better code
readability, and that means more participation.

darcs-hash:20081223191907-84dde-21e8efe210e6d5d54e935a22d0cee5c7bbfc007d.gz
parent 17ece077
......@@ -49,4 +49,14 @@ Evan Prodromou <evan@prodromou.name>**20081223173330]
[bring lib/noticelist.php into line with PEAR code standards
Evan Prodromou <evan@prodromou.name>**20081223190851]
[incorrect label on notice list file comment
Evan Prodromou <evan@prodromou.name>**20081223191430]
\ No newline at end of file
Evan Prodromou <evan@prodromou.name>**20081223191430]
[replace all tabs with four spaces
Evan Prodromou <evan@prodromou.name>**20081223191907
The PEAR coding standards decree: no tabs, but indent by four spaces.
I've done a global search-and-replace on all tabs, replacing them by
four spaces. This is a huge change, but it will go a long way to
getting us towards phpcs-compliance. And that means better code
readability, and that means more participation.
]
\ No newline at end of file
......@@ -22,21 +22,21 @@ if (!defined('LACONICA')) { exit(1); }
require_once(INSTALLDIR.'/lib/omb.php');
class AccesstokenAction extends Action {
function handle($args) {
parent::handle($args);
try {
common_debug('getting request from env variables', __FILE__);
common_remove_magic_from_request();
$req = OAuthRequest::from_request();
common_debug('getting a server', __FILE__);
$server = omb_oauth_server();
common_debug('fetching the access token', __FILE__);
$token = $server->fetch_access_token($req);
common_debug('got this token: "'.print_r($token,TRUE).'"', __FILE__);
common_debug('printing the access token', __FILE__);
print $token;
} catch (OAuthException $e) {
common_server_error($e->getMessage());
}
}
function handle($args) {
parent::handle($args);
try {
common_debug('getting request from env variables', __FILE__);
common_remove_magic_from_request();
$req = OAuthRequest::from_request();
common_debug('getting a server', __FILE__);
$server = omb_oauth_server();
common_debug('fetching the access token', __FILE__);
$token = $server->fetch_access_token($req);
common_debug('got this token: "'.print_r($token,TRUE).'"', __FILE__);
common_debug('printing the access token', __FILE__);
print $token;
} catch (OAuthException $e) {
common_server_error($e->getMessage());
}
}
}
......@@ -23,71 +23,71 @@ require_once(INSTALLDIR.'/actions/showstream.php');
class AllAction extends StreamAction {
function handle($args) {
function handle($args) {
parent::handle($args);
parent::handle($args);
$nickname = common_canonical_nickname($this->arg('nickname'));
$user = User::staticGet('nickname', $nickname);
$nickname = common_canonical_nickname($this->arg('nickname'));
$user = User::staticGet('nickname', $nickname);
if (!$user) {
$this->client_error(_('No such user.'));
return;
}
if (!$user) {
$this->client_error(_('No such user.'));
return;
}
$profile = $user->getProfile();
$profile = $user->getProfile();
if (!$profile) {
common_server_error(_('User has no profile.'));
return;
}
if (!$profile) {
common_server_error(_('User has no profile.'));
return;
}
# Looks like we're good; show the header
# Looks like we're good; show the header
common_show_header(sprintf(_("%s and friends"), $profile->nickname),
array($this, 'show_header'), $user,
array($this, 'show_top'));
common_show_header(sprintf(_("%s and friends"), $profile->nickname),
array($this, 'show_header'), $user,
array($this, 'show_top'));
$this->show_notices($user);
$this->show_notices($user);
common_show_footer();
}
common_show_footer();
}
function show_header($user) {
common_element('link', array('rel' => 'alternate',
'href' => common_local_url('allrss', array('nickname' =>
$user->nickname)),
'type' => 'application/rss+xml',
'title' => sprintf(_('Feed for friends of %s'), $user->nickname)));
}
function show_header($user) {
common_element('link', array('rel' => 'alternate',
'href' => common_local_url('allrss', array('nickname' =>
$user->nickname)),
'type' => 'application/rss+xml',
'title' => sprintf(_('Feed for friends of %s'), $user->nickname)));
}
function show_top($user) {
$cur = common_current_user();
function show_top($user) {
$cur = common_current_user();
if ($cur && $cur->id == $user->id) {
common_notice_form('all');
}
if ($cur && $cur->id == $user->id) {
common_notice_form('all');
}
$this->views_menu();
$this->views_menu();
$this->show_feeds_list(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $user->nickname)),
'type' => 'rss',
'version' => 'RSS 1.0',
'item' => 'allrss')));
}
$this->show_feeds_list(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $user->nickname)),
'type' => 'rss',
'version' => 'RSS 1.0',
'item' => 'allrss')));
}
function show_notices($user) {
function show_notices($user) {
$page = $this->trimmed('page');
if (!$page) {
$page = 1;
}
$page = $this->trimmed('page');
if (!$page) {
$page = 1;
}
$notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
$notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
$cnt = $this->show_notice_list($notice);
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
$page, 'all', array('nickname' => $user->nickname));
}
common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
$page, 'all', array('nickname' => $user->nickname));
}
}
......@@ -25,53 +25,53 @@ require_once(INSTALLDIR.'/lib/rssaction.php');
class AllrssAction extends Rss10Action {
var $user = NULL;
var $user = NULL;
function init() {
$nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname);
function init() {
$nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname);
if (!$this->user) {
common_user_error(_('No such user.'));
return false;
} else {
return true;
}
}
if (!$this->user) {
common_user_error(_('No such user.'));
return false;
} else {
return true;
}
}
function get_notices($limit=0) {
function get_notices($limit=0) {
$user = $this->user;
$notice = $user->noticesWithFriends(0, $limit);
while ($notice->fetch()) {
$notices[] = clone($notice);
}
$user = $this->user;
$notice = $user->noticesWithFriends(0, $limit);
while ($notice->fetch()) {
$notices[] = clone($notice);
}
return $notices;
}
return $notices;
}
function get_channel() {
$user = $this->user;
$c = array('url' => common_local_url('allrss',
array('nickname' =>
$user->nickname)),
'title' => sprintf(_('%s and friends'), $user->nickname),
'link' => common_local_url('all',
array('nickname' =>
$user->nickname)),
'description' => sprintf(_('Feed for friends of %s'), $user->nickname));
return $c;
}
function get_channel() {
$user = $this->user;
$c = array('url' => common_local_url('allrss',
array('nickname' =>
$user->nickname)),
'title' => sprintf(_('%s and friends'), $user->nickname),
'link' => common_local_url('all',
array('nickname' =>
$user->nickname)),
'description' => sprintf(_('Feed for friends of %s'), $user->nickname));
return $c;
}
function get_image() {
$user = $this->user;
$profile = $user->getProfile();
if (!$profile) {
return NULL;
}
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
return ($avatar) ? $avatar->url : NULL;
}
function get_image() {
$user = $this->user;
$profile = $user->getProfile();
if (!$profile) {
return NULL;
}
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
return ($avatar) ? $avatar->url : NULL;
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -24,45 +24,45 @@ class AvatarbynicknameAction extends Action {
parent::handle($args);
$nickname = $this->trimmed('nickname');
if (!$nickname) {
$this->client_error(_('No nickname.'));
return;
}
$size = $this->trimmed('size');
$this->client_error(_('No nickname.'));
return;
}
$size = $this->trimmed('size');
if (!$size) {
$this->client_error(_('No size.'));
return;
}
$size = strtolower($size);
if (!in_array($size, array('original', '96', '48', '24'))) {
$this->client_error(_('Invalid size.'));
return;
}
$this->client_error(_('No size.'));
return;
}
$size = strtolower($size);
if (!in_array($size, array('original', '96', '48', '24'))) {
$this->client_error(_('Invalid size.'));
return;
}
$user = User::staticGet('nickname', $nickname);
if (!$user) {
$this->client_error(_('No such user.'));
return;
}
$profile = $user->getProfile();
if (!$profile) {
$this->client_error(_('User has no profile.'));
return;
}
if ($size == 'original') {
$avatar = $profile->getOriginal();
} else {
$avatar = $profile->getAvatar($size+0);
}
$user = User::staticGet('nickname', $nickname);
if (!$user) {
$this->client_error(_('No such user.'));
return;
}
$profile = $user->getProfile();
if (!$profile) {
$this->client_error(_('User has no profile.'));
return;
}
if ($size == 'original') {
$avatar = $profile->getOriginal();
} else {
$avatar = $profile->getAvatar($size+0);
}
if ($avatar) {
$url = $avatar->url;
} else {
if ($size == 'original') {
$url = common_default_avatar(AVATAR_PROFILE_SIZE);
} else {
$url = common_default_avatar($size+0);
}
}
common_redirect($url, 302);
}
if ($avatar) {
$url = $avatar->url;
} else {
if ($size == 'original') {
$url = common_default_avatar(AVATAR_PROFILE_SIZE);
} else {
$url = common_default_avatar($size+0);
}
}
common_redirect($url, 302);
}
}
......@@ -32,12 +32,12 @@ class BlockAction extends Action {
return false;
}
$token = $this->trimmed('token');
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->client_error(_('There was a problem with your session token. Try again, please.'));
return;
}
if (!$token || $token != common_session_token()) {
$this->client_error(_('There was a problem with your session token. Try again, please.'));
return;
}
$id = $this->trimmed('blockto');
......@@ -75,7 +75,7 @@ class BlockAction extends Action {
$id = $this->profile->id;
common_show_header(_('Block user'));
common_show_header(_('Block user'));
common_element('p', NULL,
_('Are you sure you want to block this user? '.
......
......@@ -43,44 +43,44 @@ class ConfirmaddressAction extends Action {
$this->client_error(_('That confirmation code is not for you!'));
return;
}
$type = $confirm->address_type;
if (!in_array($type, array('email', 'jabber', 'sms'))) {
$this->server_error(sprintf(_('Unrecognized address type %s'), $type));
return;
}
$type = $confirm->address_type;
if (!in_array($type, array('email', 'jabber', 'sms'))) {
$this->server_error(sprintf(_('Unrecognized address type %s'), $type));
return;
}
if ($cur->$type == $confirm->address) {
$this->client_error(_('That address has already been confirmed.'));
return;
}
return;
}
$cur->query('BEGIN');
$orig_user = clone($cur);
$cur->$type = $confirm->address;
$cur->$type = $confirm->address;
if ($type == 'sms') {
$cur->carrier = ($confirm->address_extra)+0;
$carrier = Sms_carrier::staticGet($cur->carrier);
$cur->smsemail = $carrier->toEmailAddress($cur->sms);
}
if ($type == 'sms') {
$cur->carrier = ($confirm->address_extra)+0;
$carrier = Sms_carrier::staticGet($cur->carrier);
$cur->smsemail = $carrier->toEmailAddress($cur->sms);
}
$result = $cur->updateKeys($orig_user);
$result = $cur->updateKeys($orig_user);
if (!$result) {
common_log_db_error($cur, 'UPDATE', __FILE__);
common_log_db_error($cur, 'UPDATE', __FILE__);
$this->server_error(_('Couldn\'t update user.'));
return;
}
if ($type == 'email') {
$cur->emailChanged();
}
if ($type == 'email') {
$cur->emailChanged();
}
$result = $confirm->delete();
if (!$result) {
common_log_db_error($confirm, 'DELETE', __FILE__);
common_log_db_error($confirm, 'DELETE', __FILE__);
$this->server_error(_('Couldn\'t delete email confirmation.'));
return;
}
......
......@@ -22,80 +22,80 @@ if (!defined('LACONICA')) { exit(1); }
require_once(INSTALLDIR.'/lib/deleteaction.php');
class DeletenoticeAction extends DeleteAction {
function handle($args) {
parent::handle($args);
# XXX: Ajax!
function handle($args) {
parent::handle($args);
# XXX: Ajax!
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->delete_notice();
} else if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$this->show_form();
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->delete_notice();
} else if ($_SERVER['REQUEST_METHOD'] == 'GET') {
$this->show_form();
}
}
function get_instructions() {
return _('You are about to permanently delete a notice. Once this is done, it cannot be undone.');
}
function get_instructions() {
return _('You are about to permanently delete a notice. Once this is done, it cannot be undone.');
}
function get_title() {
return _('Delete notice');
}
function get_title() {
return _('Delete notice');
}
function show_form($error=NULL) {
$user = common_current_user();
function show_form($error=NULL) {
$user = common_current_user();
common_show_header($this->get_title(), array($this, 'show_header'), $error,
array($this, 'show_top'));
common_element_start('form', array('id' => 'notice_delete_form',
'method' => 'post',
'action' => common_local_url('deletenotice')));
common_hidden('token', common_session_token());
common_hidden('notice', $this->trimmed('notice'));
common_element_start('p');
common_element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?'));
common_show_header($this->get_title(), array($this, 'show_header'), $error,
array($this, 'show_top'));
common_element_start('form', array('id' => 'notice_delete_form',
'method' => 'post',
'action' => common_local_url('deletenotice')));
common_hidden('token', common_session_token());
common_hidden('notice', $this->trimmed('notice'));
common_element_start('p');
common_element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?'));
common_element('input', array('id' => 'submit_no',
'name' => 'submit',
'type' => 'submit',
'value' => _('No')));
common_element('input', array('id' => 'submit_yes',
'name' => 'submit',
'type' => 'submit',
'value' => _('Yes')));
common_element_end('p');
common_element_end('form');
common_show_footer();
}
common_element('input', array('id' => 'submit_no',
'name' => 'submit',
'type' => 'submit',
'value' => _('No')));
common_element('input', array('id' => 'submit_yes',
'name' => 'submit',
'type' => 'submit',
'value' => _('Yes')));
common_element_end('p');
common_element_end('form');
common_show_footer();
}
function delete_notice() {
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->show_form(_('There was a problem with your session token. Try again, please.'));
return;
}
$url = common_get_returnto();
$confirmed = $this->trimmed('submit');
if ($confirmed == _('Yes')) {
$user = common_current_user();
$notice_id = $this->trimmed('notice');
$notice = Notice::staticGet($notice_id);
$replies = new Reply;
$replies->get('notice_id', $notice_id);
function delete_notice() {
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->show_form(_('There was a problem with your session token. Try again, please.'));
return;
}
$url = common_get_returnto();
$confirmed = $this->trimmed('submit');
if ($confirmed == _('Yes')) {
$user = common_current_user();
$notice_id = $this->trimmed('notice');
$notice = Notice::staticGet($notice_id);
$replies = new Reply;
$replies->get('notice_id', $notice_id);
common_dequeue_notice($notice);
if (common_config('memcached', 'enabled')) {
$notice->blowSubsCache();
}
$replies->delete();
$notice->delete();
} else {
if ($url) {
common_set_returnto(NULL);
} else {
$url = common_local_url('public');
}
}
common_redirect($url);