change function headers to K&R style

Another huge change, for PEAR code standards compliance. Function
headers have to be in K&R style (opening brace on its own line),
instead of having the opening brace on the same line as the function
and parameters. So, a little perl magic found all the function
definitions and move the opening brace to the next line (properly
indented... usually).

darcs-hash:20081223193323-84dde-a28e36ecc66672c783c2842d12fc11043c13ab28.gz
This commit is contained in:
Evan Prodromou 2008-12-23 14:33:23 -05:00
parent eb2f9c98ac
commit 04ef1ba8ee
291 changed files with 7292 additions and 3123 deletions

View File

@ -67,4 +67,15 @@ Evan Prodromou <evan@prodromou.name>**20081223192129
keyword 'NULL' with its lowercase version. This is another PEAR code keyword 'NULL' with its lowercase version. This is another PEAR code
standards change. standards change.
]
[change function headers to K&R style
Evan Prodromou <evan@prodromou.name>**20081223193323
Another huge change, for PEAR code standards compliance. Function
headers have to be in K&R style (opening brace on its own line),
instead of having the opening brace on the same line as the function
and parameters. So, a little perl magic found all the function
definitions and move the opening brace to the next line (properly
indented... usually).
] ]

View File

@ -22,7 +22,8 @@ if (!defined('LACONICA')) { exit(1); }
require_once(INSTALLDIR.'/lib/omb.php'); require_once(INSTALLDIR.'/lib/omb.php');
class AccesstokenAction extends Action { class AccesstokenAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
try { try {
common_debug('getting request from env variables', __FILE__); common_debug('getting request from env variables', __FILE__);

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/actions/showstream.php');
class AllAction extends StreamAction { class AllAction extends StreamAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -53,7 +54,8 @@ class AllAction extends StreamAction {
common_show_footer(); common_show_footer();
} }
function show_header($user) { function show_header($user)
{
common_element('link', array('rel' => 'alternate', common_element('link', array('rel' => 'alternate',
'href' => common_local_url('allrss', array('nickname' => 'href' => common_local_url('allrss', array('nickname' =>
$user->nickname)), $user->nickname)),
@ -61,7 +63,8 @@ class AllAction extends StreamAction {
'title' => sprintf(_('Feed for friends of %s'), $user->nickname))); 'title' => sprintf(_('Feed for friends of %s'), $user->nickname)));
} }
function show_top($user) { function show_top($user)
{
$cur = common_current_user(); $cur = common_current_user();
if ($cur && $cur->id == $user->id) { if ($cur && $cur->id == $user->id) {
@ -76,7 +79,8 @@ class AllAction extends StreamAction {
'item' => 'allrss'))); 'item' => 'allrss')));
} }
function show_notices($user) { function show_notices($user)
{
$page = $this->trimmed('page'); $page = $this->trimmed('page');
if (!$page) { if (!$page) {

View File

@ -27,7 +27,8 @@ class AllrssAction extends Rss10Action {
var $user = null; var $user = null;
function init() { function init()
{
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname); $this->user = User::staticGet('nickname', $nickname);
@ -39,7 +40,8 @@ class AllrssAction extends Rss10Action {
} }
} }
function get_notices($limit=0) { function get_notices($limit=0)
{
$user = $this->user; $user = $this->user;
@ -52,7 +54,8 @@ class AllrssAction extends Rss10Action {
return $notices; return $notices;
} }
function get_channel() { function get_channel()
{
$user = $this->user; $user = $this->user;
$c = array('url' => common_local_url('allrss', $c = array('url' => common_local_url('allrss',
array('nickname' => array('nickname' =>
@ -65,7 +68,8 @@ class AllrssAction extends Rss10Action {
return $c; return $c;
} }
function get_image() { function get_image()
{
$user = $this->user; $user = $this->user;
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {

View File

@ -27,7 +27,8 @@ class ApiAction extends Action {
var $api_method; var $api_method;
var $api_action; var $api_action;
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$this->api_action = $this->arg('apiaction'); $this->api_action = $this->arg('apiaction');
@ -79,7 +80,8 @@ class ApiAction extends Action {
} }
} }
function process_command() { function process_command()
{
$action = "twitapi$this->api_action"; $action = "twitapi$this->api_action";
$actionfile = INSTALLDIR."/actions/$action.php"; $actionfile = INSTALLDIR."/actions/$action.php";
@ -108,7 +110,8 @@ class ApiAction extends Action {
} }
# Whitelist of API methods that don't need authentication # Whitelist of API methods that don't need authentication
function requires_auth() { function requires_auth()
{
static $noauth = array( 'statuses/public_timeline', static $noauth = array( 'statuses/public_timeline',
'statuses/show', 'statuses/show',
'users/show', 'users/show',
@ -144,7 +147,8 @@ class ApiAction extends Action {
} }
} }
function show_basic_auth_error() { function show_basic_auth_error()
{
header('HTTP/1.1 401 Unauthorized'); header('HTTP/1.1 401 Unauthorized');
$msg = 'Could not authenticate you.'; $msg = 'Could not authenticate you.';
@ -166,7 +170,8 @@ class ApiAction extends Action {
} }
} }
function is_readonly() { function is_readonly()
{
# NOTE: before handle(), can't use $this->arg # NOTE: before handle(), can't use $this->arg
$apiaction = $_REQUEST['apiaction']; $apiaction = $_REQUEST['apiaction'];
$method = $_REQUEST['method']; $method = $_REQUEST['method'];

View File

@ -20,7 +20,8 @@
if (!defined('LACONICA')) { exit(1); } if (!defined('LACONICA')) { exit(1); }
class AvatarbynicknameAction extends Action { class AvatarbynicknameAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
if (!$nickname) { if (!$nickname) {

View File

@ -23,7 +23,8 @@ class BlockAction extends Action {
var $profile = null; var $profile = null;
function prepare($args) { function prepare($args)
{
parent::prepare($args); parent::prepare($args);
@ -56,7 +57,8 @@ class BlockAction extends Action {
return true; return true;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($this->arg('block')) { if ($this->arg('block')) {
@ -71,7 +73,8 @@ class BlockAction extends Action {
} }
} }
function are_you_sure_form() { function are_you_sure_form()
{
$id = $this->profile->id; $id = $this->profile->id;
@ -109,7 +112,8 @@ class BlockAction extends Action {
common_show_footer(); common_show_footer();
} }
function block_profile() { function block_profile()
{
$cur = common_current_user(); $cur = common_current_user();

View File

@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
class ConfirmaddressAction extends Action { class ConfirmaddressAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_set_returnto($this->self_url()); common_set_returnto($this->self_url());

View File

@ -22,7 +22,8 @@ if (!defined('LACONICA')) { exit(1); }
require_once(INSTALLDIR.'/lib/deleteaction.php'); require_once(INSTALLDIR.'/lib/deleteaction.php');
class DeletenoticeAction extends DeleteAction { class DeletenoticeAction extends DeleteAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
# XXX: Ajax! # XXX: Ajax!
@ -33,15 +34,18 @@ class DeletenoticeAction extends DeleteAction {
} }
} }
function get_instructions() { function get_instructions()
{
return _('You are about to permanently delete a notice. Once this is done, it cannot be undone.'); return _('You are about to permanently delete a notice. Once this is done, it cannot be undone.');
} }
function get_title() { function get_title()
{
return _('Delete notice'); return _('Delete notice');
} }
function show_form($error=null) { function show_form($error=null)
{
$user = common_current_user(); $user = common_current_user();
common_show_header($this->get_title(), array($this, 'show_header'), $error, common_show_header($this->get_title(), array($this, 'show_header'), $error,
@ -67,7 +71,8 @@ class DeletenoticeAction extends DeleteAction {
common_show_footer(); common_show_footer();
} }
function delete_notice() { function delete_notice()
{
# CSRF protection # CSRF protection
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {

View File

@ -20,7 +20,8 @@
if (!defined('LACONICA')) { exit(1); } if (!defined('LACONICA')) { exit(1); }
class DeleteprofileAction extends Action { class DeleteprofileAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$this->server_error(_('Code not yet ready.')); $this->server_error(_('Code not yet ready.'));
return; return;
@ -32,18 +33,21 @@ class DeleteprofileAction extends Action {
} }
} }
function get_instructions() { function get_instructions()
{
return _('Export and delete your user information.'); return _('Export and delete your user information.');
} }
function form_header($title, $msg=null, $success=false) { function form_header($title, $msg=null, $success=false)
{
common_show_header($title, common_show_header($title,
null, null,
array($msg, $success), array($msg, $success),
array($this, 'show_top')); array($this, 'show_top'));
} }
function show_feeds_list($feeds) { function show_feeds_list($feeds)
{
common_element_start('div', array('class' => 'feedsdel')); common_element_start('div', array('class' => 'feedsdel'));
common_element('p', null, 'Feeds:'); common_element('p', null, 'Feeds:');
common_element_start('ul', array('class' => 'xoxo')); common_element_start('ul', array('class' => 'xoxo'));
@ -56,7 +60,8 @@ class DeleteprofileAction extends Action {
} }
//TODO move to common.php (and retrace its origin) //TODO move to common.php (and retrace its origin)
function common_feed_item($feed) { function common_feed_item($feed)
{
$user = common_current_user(); $user = common_current_user();
$nickname = $user->nickname; $nickname = $user->nickname;
@ -84,14 +89,16 @@ class DeleteprofileAction extends Action {
common_element_end('li'); common_element_end('li');
} }
function show_form($msg=null, $success=false) { function show_form($msg=null, $success=false)
{
$this->form_header(_('Delete my account'), $msg, $success); $this->form_header(_('Delete my account'), $msg, $success);
common_element('h2', null, _('Delete my account confirmation')); common_element('h2', null, _('Delete my account confirmation'));
$this->show_confirm_delete_form(); $this->show_confirm_delete_form();
common_show_footer(); common_show_footer();
} }
function show_confirm_delete_form() { function show_confirm_delete_form()
{
$user = common_current_user(); $user = common_current_user();
$notices = DB_DataObject::factory('notice'); $notices = DB_DataObject::factory('notice');
$notices->profile_id = $user->id; $notices->profile_id = $user->id;
@ -120,7 +127,8 @@ class DeleteprofileAction extends Action {
common_element_end('form'); common_element_end('form');
} }
function handle_post() { function handle_post()
{
# CSRF protection # CSRF protection
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {
@ -134,7 +142,8 @@ class DeleteprofileAction extends Action {
$this->show_form(); $this->show_form();
} }
function delete_account() { function delete_account()
{
$user = common_current_user(); $user = common_current_user();
assert(!is_null($user)); # should already be checked assert(!is_null($user)); # should already be checked
@ -219,7 +228,8 @@ class DeleteprofileAction extends Action {
common_redirect(common_local_url('public')); common_redirect(common_local_url('public'));
} }
function show_top($arr) { function show_top($arr)
{
$msg = $arr[0]; $msg = $arr[0];
$success = $arr[1]; $success = $arr[1];
if ($msg) { if ($msg) {
@ -234,7 +244,8 @@ class DeleteprofileAction extends Action {
$this->settings_menu(); $this->settings_menu();
} }
function settings_menu() { function settings_menu()
{
# action => array('prompt', 'title') # action => array('prompt', 'title')
$menu = $menu =
array('profilesettings' => array('profilesettings' =>

View File

@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
class DisfavorAction extends Action { class DisfavorAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);

View File

@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
class DocAction extends Action { class DocAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$title = $this->trimmed('title'); $title = $this->trimmed('title');
$filename = INSTALLDIR.'/doc/'.$title; $filename = INSTALLDIR.'/doc/'.$title;

View File

@ -23,11 +23,13 @@ require_once(INSTALLDIR.'/lib/settingsaction.php');
class EmailsettingsAction extends SettingsAction { class EmailsettingsAction extends SettingsAction {
function get_instructions() { function get_instructions()
{
return _('Manage how you get email from %%site.name%%.'); return _('Manage how you get email from %%site.name%%.');
} }
function show_form($msg=null, $success=false) { function show_form($msg=null, $success=false)
{
$user = common_current_user(); $user = common_current_user();
$this->form_header(_('Email Settings'), $msg, $success); $this->form_header(_('Email Settings'), $msg, $success);
common_element_start('form', array('method' => 'post', common_element_start('form', array('method' => 'post',
@ -110,7 +112,8 @@ class EmailsettingsAction extends SettingsAction {
common_show_footer(); common_show_footer();
} }
function get_confirmation() { function get_confirmation()
{
$user = common_current_user(); $user = common_current_user();
$confirm = new Confirm_address(); $confirm = new Confirm_address();
$confirm->user_id = $user->id; $confirm->user_id = $user->id;
@ -122,7 +125,8 @@ class EmailsettingsAction extends SettingsAction {
} }
} }
function handle_post() { function handle_post()
{
# CSRF protection # CSRF protection
$token = $this->trimmed('token'); $token = $this->trimmed('token');
@ -148,7 +152,8 @@ class EmailsettingsAction extends SettingsAction {
} }
} }
function save_preferences() { function save_preferences()
{
$emailnotifysub = $this->boolean('emailnotifysub'); $emailnotifysub = $this->boolean('emailnotifysub');
$emailnotifyfav = $this->boolean('emailnotifyfav'); $emailnotifyfav = $this->boolean('emailnotifyfav');
@ -185,7 +190,8 @@ class EmailsettingsAction extends SettingsAction {
$this->show_form(_('Preferences saved.'), true); $this->show_form(_('Preferences saved.'), true);
} }
function add_address() { function add_address()
{
$user = common_current_user(); $user = common_current_user();
@ -236,7 +242,8 @@ class EmailsettingsAction extends SettingsAction {
$this->show_form($msg, TRUE); $this->show_form($msg, TRUE);
} }
function cancel_confirmation() { function cancel_confirmation()
{
$email = $this->arg('email'); $email = $this->arg('email');
$confirm = $this->get_confirmation(); $confirm = $this->get_confirmation();
if (!$confirm) { if (!$confirm) {
@ -259,7 +266,8 @@ class EmailsettingsAction extends SettingsAction {
$this->show_form(_('Confirmation cancelled.'), TRUE); $this->show_form(_('Confirmation cancelled.'), TRUE);
} }
function remove_address() { function remove_address()
{
$user = common_current_user(); $user = common_current_user();
$email = $this->arg('email'); $email = $this->arg('email');
@ -285,7 +293,8 @@ class EmailsettingsAction extends SettingsAction {
$this->show_form(_('The address was removed.'), TRUE); $this->show_form(_('The address was removed.'), TRUE);
} }
function remove_incoming() { function remove_incoming()
{
$user = common_current_user(); $user = common_current_user();
if (!$user->incomingemail) { if (!$user->incomingemail) {
@ -304,7 +313,8 @@ class EmailsettingsAction extends SettingsAction {
$this->show_form(_('Incoming email address removed.'), TRUE); $this->show_form(_('Incoming email address removed.'), TRUE);
} }
function new_incoming() { function new_incoming()
{
$user = common_current_user(); $user = common_current_user();
$orig = clone($user); $orig = clone($user);
@ -318,7 +328,8 @@ class EmailsettingsAction extends SettingsAction {
$this->show_form(_('New incoming email address added.'), TRUE); $this->show_form(_('New incoming email address added.'), TRUE);
} }
function email_exists($email) { function email_exists($email)
{
$user = common_current_user(); $user = common_current_user();
$other = User::staticGet('email', $email); $other = User::staticGet('email', $email);
if (!$other) { if (!$other) {

View File

@ -23,13 +23,15 @@ require_once(INSTALLDIR.'/lib/facebookaction.php');
class FacebookhomeAction extends FacebookAction { class FacebookhomeAction extends FacebookAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$this->login(); $this->login();
} }
function login() { function login()
{
$user = null; $user = null;
@ -89,7 +91,8 @@ class FacebookhomeAction extends FacebookAction {
} }
function show_home($facebook, $fbuid, $user) { function show_home($facebook, $fbuid, $user)
{
$this->show_header('Home'); $this->show_header('Home');
@ -99,7 +102,8 @@ class FacebookhomeAction extends FacebookAction {
$this->show_footer(); $this->show_footer();
} }
function show_notices($user) { function show_notices($user)
{
$page = $this->trimmed('page'); $page = $this->trimmed('page');
if (!$page) { if (!$page) {

View File

@ -23,13 +23,15 @@ require_once(INSTALLDIR.'/lib/facebookaction.php');
class FacebookinviteAction extends FacebookAction { class FacebookinviteAction extends FacebookAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$this->display(); $this->display();
} }
function display() { function display()
{
$facebook = $this->get_facebook(); $facebook = $this->get_facebook();

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/facebookaction.php');
class FacebookremoveAction extends FacebookAction { class FacebookremoveAction extends FacebookAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$secret = common_config('facebook', 'secret'); $secret = common_config('facebook', 'secret');

View File

@ -23,13 +23,15 @@ require_once(INSTALLDIR.'/lib/facebookaction.php');
class FacebooksettingsAction extends FacebookAction { class FacebooksettingsAction extends FacebookAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$this->display(); $this->display();
} }
function display() { function display()
{
$facebook = $this->get_facebook(); $facebook = $this->get_facebook();

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/mail.php');
class FavorAction extends Action { class FavorAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
@ -80,7 +81,8 @@ class FavorAction extends Action {
} }
} }
function notify($fave, $notice, $user) { function notify($fave, $notice, $user)
{
$other = User::staticGet('id', $notice->profile_id); $other = User::staticGet('id', $notice->profile_id);
if ($other && $other->id != $user->id) { if ($other && $other->id != $user->id) {
if ($other->email && $other->emailnotifyfav) { if ($other->email && $other->emailnotifyfav) {

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/stream.php');
class FavoritedAction extends StreamAction { class FavoritedAction extends StreamAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
@ -37,7 +38,8 @@ class FavoritedAction extends StreamAction {
common_show_footer(); common_show_footer();
} }
function show_top() { function show_top()
{
$instr = $this->get_instructions(); $instr = $this->get_instructions();
$output = common_markup_to_html($instr); $output = common_markup_to_html($instr);
common_element_start('div', 'instructions'); common_element_start('div', 'instructions');
@ -46,15 +48,18 @@ class FavoritedAction extends StreamAction {
$this->public_views_menu(); $this->public_views_menu();
} }
function show_header() { function show_header()
{
return; return;
} }
function get_instructions() { function get_instructions()
{
return _('Showing recently popular notices'); return _('Showing recently popular notices');
} }
function show_notices($page) { function show_notices($page)
{
$qry = 'SELECT notice.*, sum(exp(-(now() - fave.modified) / %s)) as weight ' . $qry = 'SELECT notice.*, sum(exp(-(now() - fave.modified) / %s)) as weight ' .
'FROM notice JOIN fave ON notice.id = fave.notice_id ' . 'FROM notice JOIN fave ON notice.id = fave.notice_id ' .

View File

@ -27,7 +27,8 @@ class FavoritesrssAction extends Rss10Action {
var $user = null; var $user = null;
function init() { function init()
{
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname); $this->user = User::staticGet('nickname', $nickname);
@ -39,7 +40,8 @@ class FavoritesrssAction extends Rss10Action {
} }
} }
function get_notices($limit=0) { function get_notices($limit=0)
{
$user = $this->user; $user = $this->user;
@ -54,7 +56,8 @@ class FavoritesrssAction extends Rss10Action {
return $notices; return $notices;
} }
function get_channel() { function get_channel()
{
$user = $this->user; $user = $this->user;
$c = array('url' => common_local_url('favoritesrss', $c = array('url' => common_local_url('favoritesrss',
array('nickname' => array('nickname' =>
@ -67,7 +70,8 @@ class FavoritesrssAction extends Rss10Action {
return $c; return $c;
} }
function get_image() { function get_image()
{
return null; return null;
} }
} }

View File

@ -24,7 +24,8 @@ require_once(INSTALLDIR.'/lib/profilelist.php');
class FeaturedAction extends StreamAction { class FeaturedAction extends StreamAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
@ -38,7 +39,8 @@ class FeaturedAction extends StreamAction {
common_show_footer(); common_show_footer();
} }
function show_top() { function show_top()
{
$instr = $this->get_instructions(); $instr = $this->get_instructions();
$output = common_markup_to_html($instr); $output = common_markup_to_html($instr);
common_element_start('div', 'instructions'); common_element_start('div', 'instructions');
@ -47,14 +49,17 @@ class FeaturedAction extends StreamAction {
$this->public_views_menu(); $this->public_views_menu();
} }
function show_header() { function show_header()
{
} }
function get_instructions() { function get_instructions()
{
return _('Featured users'); return _('Featured users');
} }
function show_notices($page) { function show_notices($page)
{
// XXX: Note I'm doing it this two-stage way because a raw query // XXX: Note I'm doing it this two-stage way because a raw query
// with a JOIN was *not* working. --Zach // with a JOIN was *not* working. --Zach

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/openid.php');
class FinishaddopenidAction extends Action { class FinishaddopenidAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); common_user_error(_('Not logged in.'));
@ -32,7 +33,8 @@ class FinishaddopenidAction extends Action {
} }
} }
function try_login() { function try_login()
{
$consumer =& oid_consumer(); $consumer =& oid_consumer();
@ -95,7 +97,8 @@ class FinishaddopenidAction extends Action {
} }
} }
function message($msg) { function message($msg)
{
common_show_header(_('OpenID Login')); common_show_header(_('OpenID Login'));
common_element('p', null, $msg); common_element('p', null, $msg);
common_show_footer(); common_show_footer();

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/openid.php');
class FinishimmediateAction extends Action { class FinishimmediateAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$consumer = oid_consumer(); $consumer = oid_consumer();
@ -53,7 +54,8 @@ class FinishimmediateAction extends Action {
return; return;
} }
function go_backto() { function go_backto()
{
common_ensure_session(); common_ensure_session();
$backto = $_SESSION['openid_immediate_backto']; $backto = $_SESSION['openid_immediate_backto'];
if (!$backto) { if (!$backto) {

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/openid.php');
class FinishopenidloginAction extends Action { class FinishopenidloginAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (common_logged_in()) { if (common_logged_in()) {
common_user_error(_('Already logged in.')); common_user_error(_('Already logged in.'));
@ -52,7 +53,8 @@ class FinishopenidloginAction extends Action {
} }
} }
function show_top($error=null) { function show_top($error=null)
{
if ($error) { if ($error) {
common_element('div', array('class' => 'error'), $error); common_element('div', array('class' => 'error'), $error);
} else { } else {
@ -62,7 +64,8 @@ class FinishopenidloginAction extends Action {
} }
} }
function show_form($error=null, $username=null) { function show_form($error=null, $username=null)
{
common_show_header(_('OpenID Account Setup'), null, $error, common_show_header(_('OpenID Account Setup'), null, $error,
array($this, 'show_top')); array($this, 'show_top'));
@ -99,7 +102,8 @@ class FinishopenidloginAction extends Action {
common_show_footer(); common_show_footer();
} }
function try_login() { function try_login()
{
$consumer = oid_consumer(); $consumer = oid_consumer();
@ -146,26 +150,30 @@ class FinishopenidloginAction extends Action {
} }
} }
function message($msg) { function message($msg)
{
common_show_header(_('OpenID Login')); common_show_header(_('OpenID Login'));
common_element('p', null, $msg); common_element('p', null, $msg);
common_show_footer(); common_show_footer();
} }
function save_values($display, $canonical, $sreg) { function save_values($display, $canonical, $sreg)
{
common_ensure_session(); common_ensure_session();
$_SESSION['openid_display'] = $display; $_SESSION['openid_display'] = $display;
$_SESSION['openid_canonical'] = $canonical; $_SESSION['openid_canonical'] = $canonical;
$_SESSION['openid_sreg'] = $sreg; $_SESSION['openid_sreg'] = $sreg;
} }
function get_saved_values() { function get_saved_values()
{
return array($_SESSION['openid_display'], return array($_SESSION['openid_display'],
$_SESSION['openid_canonical'], $_SESSION['openid_canonical'],
$_SESSION['openid_sreg']); $_SESSION['openid_sreg']);
} }
function create_new_user() { function create_new_user()
{
# FIXME: save invite code before redirect, and check here # FIXME: save invite code before redirect, and check here
@ -247,7 +255,8 @@ class FinishopenidloginAction extends Action {
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname))); common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
} }
function connect_user() { function connect_user()
{
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$password = $this->trimmed('password'); $password = $this->trimmed('password');
@ -286,7 +295,8 @@ class FinishopenidloginAction extends Action {
$this->go_home($user->nickname); $this->go_home($user->nickname);
} }
function go_home($nickname) { function go_home($nickname)
{
$url = common_get_returnto(); $url = common_get_returnto();
if ($url) { if ($url) {
# We don't have to return to it again # We don't have to return to it again
@ -299,7 +309,8 @@ class FinishopenidloginAction extends Action {
common_redirect($url); common_redirect($url);
} }
function best_new_nickname($display, $sreg) { function best_new_nickname($display, $sreg)
{
# Try the passed-in nickname # Try the passed-in nickname
@ -332,7 +343,8 @@ class FinishopenidloginAction extends Action {
return null; return null;
} }
function is_new_nickname($str) { function is_new_nickname($str)
{
if (!Validate::string($str, array('min_length' => 1, if (!Validate::string($str, array('min_length' => 1,
'max_length' => 64, 'max_length' => 64,
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) { 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
@ -347,7 +359,8 @@ class FinishopenidloginAction extends Action {
return true; return true;
} }
function openid_to_nickname($openid) { function openid_to_nickname($openid)
{
if (Auth_Yadis_identifierScheme($openid) == 'XRI') { if (Auth_Yadis_identifierScheme($openid) == 'XRI') {
return $this->xri_to_nickname($openid); return $this->xri_to_nickname($openid);
} else { } else {
@ -360,7 +373,8 @@ class FinishopenidloginAction extends Action {
# 2. One element in path, like http://profile.typekey.com/EvanProdromou/ # 2. One element in path, like http://profile.typekey.com/EvanProdromou/
# or http://getopenid.com/evanprodromou # or http://getopenid.com/evanprodromou
function url_to_nickname($openid) { function url_to_nickname($openid)
{
static $bad = array('query', 'user', 'password', 'port', 'fragment'); static $bad = array('query', 'user', 'password', 'port', 'fragment');
$parts = parse_url($openid); $parts = parse_url($openid);
@ -406,7 +420,8 @@ class FinishopenidloginAction extends Action {
return null; return null;
} }
function xri_to_nickname($xri) { function xri_to_nickname($xri)
{
$base = $this->xri_base($xri); $base = $this->xri_base($xri);
if (!$base) { if (!$base) {
@ -419,7 +434,8 @@ class FinishopenidloginAction extends Action {
} }
} }
function xri_base($xri) { function xri_base($xri)
{
if (substr($xri, 0, 6) == 'xri://') { if (substr($xri, 0, 6) == 'xri://') {
return substr($xri, 6); return substr($xri, 6);
} else { } else {
@ -429,7 +445,8 @@ class FinishopenidloginAction extends Action {
# Given a string, try to make it work as a nickname # Given a string, try to make it work as a nickname
function nicknamize($str) { function nicknamize($str)
{
$str = preg_replace('/\W/', '', $str); $str = preg_replace('/\W/', '', $str);
return strtolower($str); return strtolower($str);
} }

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/omb.php');
class FinishremotesubscribeAction extends Action { class FinishremotesubscribeAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -231,13 +232,15 @@ class FinishremotesubscribeAction extends Action {
$user->nickname))); $user->nickname)));
} }
function add_avatar($profile, $url) { function add_avatar($profile, $url)
{
$temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar'); $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
copy($url, $temp_filename); copy($url, $temp_filename);
return $profile->setOriginal($temp_filename); return $profile->setOriginal($temp_filename);
} }
function access_token($omb) { function access_token($omb)
{
common_debug('starting request for access token', __FILE__); common_debug('starting request for access token', __FILE__);

View File

@ -25,11 +25,13 @@ define('BOTH', 0);
class FoafAction extends Action { class FoafAction extends Action {
function is_readonly() { function is_readonly()
{
return true; return true;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
@ -179,14 +181,16 @@ class FoafAction extends Action {
common_element_end('rdf:RDF'); common_element_end('rdf:RDF');
} }
function show_ppd($foaf_url, $person_uri) { function show_ppd($foaf_url, $person_uri)
{
common_element_start('PersonalProfileDocument', array('rdf:about' => $foaf_url)); common_element_start('PersonalProfileDocument', array('rdf:about' => $foaf_url));
common_element('maker', array('rdf:resource' => $person_uri)); common_element('maker', array('rdf:resource' => $person_uri));
common_element('primaryTopic', array('rdf:resource' => $person_uri)); common_element('primaryTopic', array('rdf:resource' => $person_uri));
common_element_end('PersonalProfileDocument'); common_element_end('PersonalProfileDocument');
} }
function show_microblogging_account($profile, $service=null) { function show_microblogging_account($profile, $service=null)
{
# Their account # Their account
common_element_start('holdsAccount'); common_element_start('holdsAccount');
common_element_start('OnlineAccount'); common_element_start('OnlineAccount');

View File

@ -24,11 +24,13 @@ require_once(INSTALLDIR.'/lib/jabber.php');
class ImsettingsAction extends SettingsAction { class ImsettingsAction extends SettingsAction {
function get_instructions() { function get_instructions()
{
return _('You can send and receive notices through Jabber/GTalk [instant messages](%%doc.im%%). Configure your address and settings below.'); return _('You can send and receive notices through Jabber/GTalk [instant messages](%%doc.im%%). Configure your address and settings below.');
} }
function show_form($msg=null, $success=false) { function show_form($msg=null, $success=false)
{
$user = common_current_user(); $user = common_current_user();
$this->form_header(_('IM Settings'), $msg, $success); $this->form_header(_('IM Settings'), $msg, $success);
common_element_start('form', array('method' => 'post', common_element_start('form', array('method' => 'post',
@ -85,7 +87,8 @@ class ImsettingsAction extends SettingsAction {
common_show_footer(); common_show_footer();
} }
function get_confirmation() { function get_confirmation()
{
$user = common_current_user(); $user = common_current_user();
$confirm = new Confirm_address(); $confirm = new Confirm_address();
$confirm->user_id = $user->id; $confirm->user_id = $user->id;
@ -97,7 +100,8 @@ class ImsettingsAction extends SettingsAction {
} }
} }
function handle_post() { function handle_post()
{
# CSRF protection # CSRF protection
$token = $this->trimmed('token'); $token = $this->trimmed('token');
@ -119,7 +123,8 @@ class ImsettingsAction extends SettingsAction {
} }
} }
function save_preferences() { function save_preferences()
{
$jabbernotify = $this->boolean('jabbernotify'); $jabbernotify = $this->boolean('jabbernotify');
$updatefrompresence = $this->boolean('updatefrompresence'); $updatefrompresence = $this->boolean('updatefrompresence');
@ -152,7 +157,8 @@ class ImsettingsAction extends SettingsAction {
$this->show_form(_('Preferences saved.'), true); $this->show_form(_('Preferences saved.'), true);
} }
function add_address() { function add_address()
{
$user = common_current_user(); $user = common_current_user();
@ -207,7 +213,8 @@ class ImsettingsAction extends SettingsAction {
$this->show_form($msg, TRUE); $this->show_form($msg, TRUE);
} }
function cancel_confirmation() { function cancel_confirmation()
{
$jabber = $this->arg('jabber'); $jabber = $this->arg('jabber');
$confirm = $this->get_confirmation(); $confirm = $this->get_confirmation();
if (!$confirm) { if (!$confirm) {
@ -230,7 +237,8 @@ class ImsettingsAction extends SettingsAction {
$this->show_form(_('Confirmation cancelled.'), TRUE); $this->show_form(_('Confirmation cancelled.'), TRUE);
} }
function remove_address() { function remove_address()
{
$user = common_current_user(); $user = common_current_user();
$jabber = $this->arg('jabber'); $jabber = $this->arg('jabber');
@ -258,7 +266,8 @@ class ImsettingsAction extends SettingsAction {
$this->show_form(_('The address was removed.'), TRUE); $this->show_form(_('The address was removed.'), TRUE);
} }
function jabber_exists($jabber) { function jabber_exists($jabber)
{
$user = common_current_user(); $user = common_current_user();
$other = User::staticGet('jabber', $jabber); $other = User::staticGet('jabber', $jabber);
if (!$other) { if (!$other) {

View File

@ -21,11 +21,13 @@ if (!defined('LACONICA')) { exit(1); }
class InviteAction extends Action { class InviteAction extends Action {
function is_readonly() { function is_readonly()
{
return false; return false;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
$this->client_error(sprintf(_('You must be logged in to invite other users to use %s'), $this->client_error(sprintf(_('You must be logged in to invite other users to use %s'),
@ -38,7 +40,8 @@ class InviteAction extends Action {
} }
} }
function send_invitations() { function send_invitations()
{
# CSRF protection # CSRF protection
$token = $this->trimmed('token'); $token = $this->trimmed('token');
@ -112,7 +115,8 @@ class InviteAction extends Action {
common_show_footer(); common_show_footer();
} }
function show_top($error=null) { function show_top($error=null)
{
if ($error) { if ($error) {
common_element('p', 'error', $error); common_element('p', 'error', $error);
} else { } else {
@ -123,7 +127,8 @@ class InviteAction extends Action {
} }
} }
function show_form($error=null) { function show_form($error=null)
{
global $config; global $config;
@ -149,7 +154,8 @@ class InviteAction extends Action {
common_show_footer(); common_show_footer();
} }
function send_invitation($email, $user, $personal) { function send_invitation($email, $user, $personal)
{
$profile = $user->getProfile(); $profile = $user->getProfile();
$bestname = $profile->getBestName(); $bestname = $profile->getBestName();

View File

@ -21,11 +21,13 @@ if (!defined('LACONICA')) { exit(1); }
class LoginAction extends Action { class LoginAction extends Action {
function is_readonly() { function is_readonly()
{
return true; return true;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (common_is_real_login()) { if (common_is_real_login()) {
common_user_error(_('Already logged in.')); common_user_error(_('Already logged in.'));
@ -36,7 +38,8 @@ class LoginAction extends Action {
} }
} }
function check_login() { function check_login()
{
# XXX: login throttle # XXX: login throttle
# CSRF protection - token set in common_notice_form() # CSRF protection - token set in common_notice_form()
@ -100,7 +103,8 @@ class LoginAction extends Action {
common_redirect($url); common_redirect($url);
} }
function show_form($error=null) { function show_form($error=null)
{
common_show_header(_('Login'), null, $error, array($this, 'show_top')); common_show_header(_('Login'), null, $error, array($this, 'show_top'));
common_element_start('form', array('method' => 'post', common_element_start('form', array('method' => 'post',
'id' => 'login', 'id' => 'login',
@ -120,7 +124,8 @@ class LoginAction extends Action {
common_show_footer(); common_show_footer();
} }
function get_instructions() { function get_instructions()
{
if (common_logged_in() && if (common_logged_in() &&
!common_is_real_login() && !common_is_real_login() &&
common_get_returnto()) common_get_returnto())
@ -138,7 +143,8 @@ class LoginAction extends Action {
} }
} }
function show_top($error=null) { function show_top($error=null)
{
if ($error) { if ($error) {
common_element('p', 'error', $error); common_element('p', 'error', $error);
} else { } else {

View File

@ -23,11 +23,13 @@ require_once(INSTALLDIR.'/lib/openid.php');
class LogoutAction extends Action { class LogoutAction extends Action {
function is_readonly() { function is_readonly()
{
return true; return true;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); common_user_error(_('Not logged in.'));

View File

@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
class MicrosummaryAction extends Action { class MicrosummaryAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);

View File

@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
class NewmessageAction extends Action { class NewmessageAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
@ -33,7 +34,8 @@ class NewmessageAction extends Action {
} }
} }
function save_new_message() { function save_new_message()
{
$user = common_current_user(); $user = common_current_user();
assert($user); # XXX: maybe an error instead... assert($user); # XXX: maybe an error instead...
@ -89,7 +91,8 @@ class NewmessageAction extends Action {
common_redirect($url, 303); common_redirect($url, 303);
} }
function show_top($params) { function show_top($params)
{
list($content, $user, $to) = $params; list($content, $user, $to) = $params;
@ -98,7 +101,8 @@ class NewmessageAction extends Action {
common_message_form($content, $user, $to); common_message_form($content, $user, $to);
} }
function show_form($msg=null) { function show_form($msg=null)
{
$content = $this->trimmed('content'); $content = $this->trimmed('content');
$user = common_current_user(); $user = common_current_user();
@ -128,7 +132,8 @@ class NewmessageAction extends Action {
common_show_footer(); common_show_footer();
} }
function notify($from, $to, $message) { function notify($from, $to, $message)
{
mail_notify_message($message, $from, $to); mail_notify_message($message, $from, $to);
# XXX: Jabber, SMS notifications... probably queued # XXX: Jabber, SMS notifications... probably queued
} }

View File

@ -23,7 +23,8 @@ require_once INSTALLDIR . '/lib/noticelist.php';
class NewnoticeAction extends Action { class NewnoticeAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
@ -43,7 +44,8 @@ class NewnoticeAction extends Action {
} }
} }
function save_new_notice() { function save_new_notice()
{
$user = common_current_user(); $user = common_current_user();
assert($user); # XXX: maybe an error instead... assert($user); # XXX: maybe an error instead...
@ -110,7 +112,8 @@ class NewnoticeAction extends Action {
} }
} }
function ajax_error_msg($msg) { function ajax_error_msg($msg)
{
common_start_html('text/xml;charset=utf-8', true); common_start_html('text/xml;charset=utf-8', true);
common_element_start('head'); common_element_start('head');
common_element('title', null, _('Ajax Error')); common_element('title', null, _('Ajax Error'));
@ -121,11 +124,13 @@ class NewnoticeAction extends Action {
common_element_end('html'); common_element_end('html');
} }
function show_top($content=null) { function show_top($content=null)
{
common_notice_form(null, $content); common_notice_form(null, $content);
} }
function show_form($msg=null) { function show_form($msg=null)
{
if ($msg && $this->boolean('ajax')) { if ($msg && $this->boolean('ajax')) {
$this->ajax_error_msg($msg); $this->ajax_error_msg($msg);
return; return;
@ -146,7 +151,8 @@ class NewnoticeAction extends Action {
common_show_footer(); common_show_footer();
} }
function show_notice($notice) { function show_notice($notice)
{
$nli = new NoticeListItem($notice); $nli = new NoticeListItem($notice);
$nli->show(); $nli->show();
} }

View File

@ -25,15 +25,18 @@ require_once(INSTALLDIR.'/lib/searchaction.php');
class NoticesearchAction extends SearchAction { class NoticesearchAction extends SearchAction {
function get_instructions() { function get_instructions()
{
return _('Search for notices on %%site.name%% by their contents. Separate search terms by spaces; they must be 3 characters or more.'); return _('Search for notices on %%site.name%% by their contents. Separate search terms by spaces; they must be 3 characters or more.');
} }
function get_title() { function get_title()
{
return _('Text search'); return _('Text search');
} }
function show_results($q, $page) { function show_results($q, $page)
{
$notice = new Notice(); $notice = new Notice();
@ -72,7 +75,8 @@ class NoticesearchAction extends SearchAction {
$page, 'noticesearch', array('q' => $q)); $page, 'noticesearch', array('q' => $q));
} }
function show_header($arr) { function show_header($arr)
{
if ($arr) { if ($arr) {
$q = $arr[0]; $q = $arr[0];
} }
@ -87,7 +91,8 @@ class NoticesearchAction extends SearchAction {
# XXX: refactor and combine with StreamAction::show_notice() # XXX: refactor and combine with StreamAction::show_notice()
function show_notice($notice, $terms) { function show_notice($notice, $terms)
{
$profile = $notice->getProfile(); $profile = $notice->getProfile();
if (!$profile) { if (!$profile) {
common_log_db_error($notice, 'SELECT', __FILE__); common_log_db_error($notice, 'SELECT', __FILE__);
@ -149,7 +154,8 @@ class NoticesearchAction extends SearchAction {
common_element_end('li'); common_element_end('li');
} }
function highlight($text, $terms) { function highlight($text, $terms)
{
/* Highligh serach terms */ /* Highligh serach terms */
$pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i'; $pattern = '/('.implode('|',array_map('htmlspecialchars', $terms)).')/i';
$result = preg_replace($pattern, '<strong>\\1</strong>', $text); $result = preg_replace($pattern, '<strong>\\1</strong>', $text);

View File

@ -25,11 +25,13 @@ require_once(INSTALLDIR.'/lib/rssaction.php');
class NoticesearchrssAction extends Rss10Action { class NoticesearchrssAction extends Rss10Action {
function init() { function init()
{
return true; return true;
} }
function get_notices($limit=0) { function get_notices($limit=0)
{
$q = $this->trimmed('q'); $q = $this->trimmed('q');
$notices = array(); $notices = array();
@ -54,7 +56,8 @@ class NoticesearchrssAction extends Rss10Action {
return $notices; return $notices;
} }
function get_channel() { function get_channel()
{
global $config; global $config;
$q = $this->trimmed('q'); $q = $this->trimmed('q');
$c = array('url' => common_local_url('noticesearchrss', array('q' => $q)), $c = array('url' => common_local_url('noticesearchrss', array('q' => $q)),
@ -64,7 +67,8 @@ class NoticesearchrssAction extends Rss10Action {
return $c; return $c;
} }
function get_image() { function get_image()
{
return null; return null;
} }
} }

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/mail.php');
class NudgeAction extends Action { class NudgeAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
@ -71,7 +72,8 @@ class NudgeAction extends Action {
} }
} }
function notify($user, $other) { function notify($user, $other)
{
if ($other->id != $user->id) { if ($other->id != $user->id) {
if ($other->email && $other->emailnotifynudge) { if ($other->email && $other->emailnotifynudge) {
mail_notify_nudge($user, $other); mail_notify_nudge($user, $other);

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/openid.php');
class OpenidloginAction extends Action { class OpenidloginAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (common_logged_in()) { if (common_logged_in()) {
common_user_error(_('Already logged in.')); common_user_error(_('Already logged in.'));
@ -56,11 +57,13 @@ class OpenidloginAction extends Action {
} }
} }
function get_instructions() { function get_instructions()
{
return _('Login with an [OpenID](%%doc.openid%%) account.'); return _('Login with an [OpenID](%%doc.openid%%) account.');
} }
function show_top($error=null) { function show_top($error=null)
{
if ($error) { if ($error) {
common_element('div', array('class' => 'error'), $error); common_element('div', array('class' => 'error'), $error);
} else { } else {
@ -72,7 +75,8 @@ class OpenidloginAction extends Action {
} }
} }
function show_form($error=null, $openid_url) { function show_form($error=null, $openid_url)
{
common_show_header(_('OpenID Login'), null, $error, array($this, 'show_top')); common_show_header(_('OpenID Login'), null, $error, array($this, 'show_top'));
$formaction = common_local_url('openidlogin'); $formaction = common_local_url('openidlogin');
common_element_start('form', array('method' => 'post', common_element_start('form', array('method' => 'post',

View File

@ -24,13 +24,15 @@ require_once(INSTALLDIR.'/lib/openid.php');
class OpenidsettingsAction extends SettingsAction { class OpenidsettingsAction extends SettingsAction {
function get_instructions() { function get_instructions()
{
return _('[OpenID](%%doc.openid%%) lets you log into many sites ' . return _('[OpenID](%%doc.openid%%) lets you log into many sites ' .
' with the same user account. '. ' with the same user account. '.
' Manage your associated OpenIDs from here.'); ' Manage your associated OpenIDs from here.');
} }
function show_form($msg=null, $success=false) { function show_form($msg=null, $success=false)
{
$user = common_current_user(); $user = common_current_user();
@ -116,7 +118,8 @@ class OpenidsettingsAction extends SettingsAction {
common_show_footer(); common_show_footer();
} }
function handle_post() { function handle_post()
{
# CSRF protection # CSRF protection
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {
@ -136,7 +139,8 @@ class OpenidsettingsAction extends SettingsAction {
} }
} }
function remove_openid() { function remove_openid()
{
$openid_url = $this->trimmed('openid_url'); $openid_url = $this->trimmed('openid_url');
$oid = User_openid::staticGet('canonical', $openid_url); $oid = User_openid::staticGet('canonical', $openid_url);

View File

@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
class OpensearchAction extends Action { class OpensearchAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);

View File

@ -23,11 +23,13 @@ require_once(INSTALLDIR.'/lib/settingsaction.php');
class OthersettingsAction extends SettingsAction { class OthersettingsAction extends SettingsAction {
function get_instructions() { function get_instructions()
{
return _('Manage various other options.'); return _('Manage various other options.');
} }
function show_form($msg=null, $success=false) { function show_form($msg=null, $success=false)
{
$user = common_current_user(); $user = common_current_user();
$this->form_header(_('Other Settings'), $msg, $success); $this->form_header(_('Other Settings'), $msg, $success);
@ -63,7 +65,8 @@ class OthersettingsAction extends SettingsAction {
common_show_footer(); common_show_footer();
} }
function show_feeds_list($feeds) { function show_feeds_list($feeds)
{
common_element_start('div', array('class' => 'feedsdel')); common_element_start('div', array('class' => 'feedsdel'));
common_element('p', null, 'Feeds:'); common_element('p', null, 'Feeds:');
common_element_start('ul', array('class' => 'xoxo')); common_element_start('ul', array('class' => 'xoxo'));
@ -76,7 +79,8 @@ class OthersettingsAction extends SettingsAction {
} }
//TODO move to common.php (and retrace its origin) //TODO move to common.php (and retrace its origin)
function common_feed_item($feed) { function common_feed_item($feed)
{
$user = common_current_user(); $user = common_current_user();
$nickname = $user->nickname; $nickname = $user->nickname;
@ -131,7 +135,8 @@ class OthersettingsAction extends SettingsAction {
// common_element_end('form'); // common_element_end('form');
// } // }
function handle_post() { function handle_post()
{
# CSRF protection # CSRF protection
$token = $this->trimmed('token'); $token = $this->trimmed('token');
@ -147,7 +152,8 @@ class OthersettingsAction extends SettingsAction {
} }
} }
function save_preferences() { function save_preferences()
{
$urlshorteningservice = $this->trimmed('urlshorteningservice'); $urlshorteningservice = $this->trimmed('urlshorteningservice');

View File

@ -24,16 +24,19 @@ require_once(INSTALLDIR.'/lib/profilelist.php');
class PeoplesearchAction extends SearchAction { class PeoplesearchAction extends SearchAction {
function get_instructions() { function get_instructions()
{
return _('Search for people on %%site.name%% by their name, location, or interests. ' . return _('Search for people on %%site.name%% by their name, location, or interests. ' .
'Separate the terms by spaces; they must be 3 characters or more.'); 'Separate the terms by spaces; they must be 3 characters or more.');
} }
function get_title() { function get_title()
{
return _('People search'); return _('People search');
} }
function show_results($q, $page) { function show_results($q, $page)
{
$profile = new Profile(); $profile = new Profile();
@ -71,14 +74,16 @@ class PeopleSearchResults extends ProfileList {
var $terms = null; var $terms = null;
var $pattern = null; var $pattern = null;
function __construct($profile, $terms) { function __construct($profile, $terms)
{
parent::__construct($profile); parent::__construct($profile);
$this->terms = array_map('preg_quote', $this->terms = array_map('preg_quote',
array_map('htmlspecialchars', $terms)); array_map('htmlspecialchars', $terms));
$this->pattern = '/('.implode('|',$terms).')/i'; $this->pattern = '/('.implode('|',$terms).')/i';
} }
function highlight($text) { function highlight($text)
{
return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text)); return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text));
} }
} }

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/profilelist.php');
class PeopletagAction extends Action { class PeopletagAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -50,7 +51,8 @@ class PeopletagAction extends Action {
common_show_footer(); common_show_footer();
} }
function show_people($tag, $page) { function show_people($tag, $page)
{
$profile = new Profile(); $profile = new Profile();
@ -83,7 +85,8 @@ class PeopletagAction extends Action {
array('tag' => $tag)); array('tag' => $tag));
} }
function show_top($tag) { function show_top($tag)
{
$instr = sprintf(_('These are users who have tagged themselves "%s" ' . $instr = sprintf(_('These are users who have tagged themselves "%s" ' .
'to show a common interest, characteristic, hobby or job.'), $tag); 'to show a common interest, characteristic, hobby or job.'), $tag);
common_element_start('div', 'instructions'); common_element_start('div', 'instructions');
@ -93,11 +96,13 @@ class PeopletagAction extends Action {
common_element_end('div'); common_element_end('div');
} }
function get_title() { function get_title()
{
return null; return null;
} }
function show_header($arr) { function show_header($arr)
{
return; return;
} }
} }

View File

@ -22,7 +22,8 @@ if (!defined('LACONICA')) { exit(1); }
require_once(INSTALLDIR.'/lib/omb.php'); require_once(INSTALLDIR.'/lib/omb.php');
class PostnoticeAction extends Action { class PostnoticeAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
try { try {
common_remove_magic_from_request(); common_remove_magic_from_request();
@ -39,7 +40,8 @@ class PostnoticeAction extends Action {
} }
} }
function save_notice(&$req, &$consumer, &$token) { function save_notice(&$req, &$consumer, &$token)
{
$version = $req->get_parameter('omb_version'); $version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) { if ($version != OMB_VERSION_01) {
common_user_error(_('Unsupported OMB version'), 400); common_user_error(_('Unsupported OMB version'), 400);

View File

@ -23,12 +23,14 @@ require_once(INSTALLDIR.'/lib/settingsaction.php');
class ProfilesettingsAction extends SettingsAction { class ProfilesettingsAction extends SettingsAction {
function get_instructions() { function get_instructions()
{
return _('You can update your personal profile info here '. return _('You can update your personal profile info here '.
'so people know more about you.'); 'so people know more about you.');
} }
function show_form($msg=null, $success=false) { function show_form($msg=null, $success=false)
{
$this->form_header(_('Profile settings'), $msg, $success); $this->form_header(_('Profile settings'), $msg, $success);
$this->show_settings_form(); $this->show_settings_form();
common_element('h2', null, _('Avatar')); common_element('h2', null, _('Avatar'));
@ -40,7 +42,8 @@ class ProfilesettingsAction extends SettingsAction {
common_show_footer(); common_show_footer();
} }
function handle_post() { function handle_post()
{
# CSRF protection # CSRF protection
@ -60,7 +63,8 @@ class ProfilesettingsAction extends SettingsAction {
} }
function show_settings_form() { function show_settings_form()
{
$user = common_current_user(); $user = common_current_user();
$profile = $user->getProfile(); $profile = $user->getProfile();
@ -110,7 +114,8 @@ class ProfilesettingsAction extends SettingsAction {
} }
function show_avatar_form() { function show_avatar_form()
{
$user = common_current_user(); $user = common_current_user();
$profile = $user->getProfile(); $profile = $user->getProfile();
@ -168,7 +173,8 @@ class ProfilesettingsAction extends SettingsAction {
} }
function show_password_form() { function show_password_form()
{
$user = common_current_user(); $user = common_current_user();
common_element_start('form', array('method' => 'POST', common_element_start('form', array('method' => 'POST',
@ -190,7 +196,8 @@ class ProfilesettingsAction extends SettingsAction {
common_element_end('form'); common_element_end('form');
} }
function save_profile() { function save_profile()
{
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$fullname = $this->trimmed('fullname'); $fullname = $this->trimmed('fullname');
$homepage = $this->trimmed('homepage'); $homepage = $this->trimmed('homepage');
@ -337,7 +344,8 @@ class ProfilesettingsAction extends SettingsAction {
} }
function upload_avatar() { function upload_avatar()
{
switch ($_FILES['avatarfile']['error']) { switch ($_FILES['avatarfile']['error']) {
case UPLOAD_ERR_OK: # success, jump out case UPLOAD_ERR_OK: # success, jump out
break; break;
@ -384,7 +392,8 @@ class ProfilesettingsAction extends SettingsAction {
@unlink($_FILES['avatarfile']['tmp_name']); @unlink($_FILES['avatarfile']['tmp_name']);
} }
function nickname_exists($nickname) { function nickname_exists($nickname)
{
$user = common_current_user(); $user = common_current_user();
$other = User::staticGet('nickname', $nickname); $other = User::staticGet('nickname', $nickname);
if (!$other) { if (!$other) {
@ -394,7 +403,8 @@ class ProfilesettingsAction extends SettingsAction {
} }
} }
function change_password() { function change_password()
{
$user = common_current_user(); $user = common_current_user();
assert(!is_null($user)); # should already be checked assert(!is_null($user)); # should already be checked

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/stream.php');
class PublicAction extends StreamAction { class PublicAction extends StreamAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
@ -41,7 +42,8 @@ class PublicAction extends StreamAction {
common_show_footer(); common_show_footer();
} }
function show_top() { function show_top()
{
if (common_logged_in()) { if (common_logged_in()) {
common_notice_form('public'); common_notice_form('public');
} else { } else {
@ -64,13 +66,15 @@ class PublicAction extends StreamAction {
'item' => 'publicatom'))); 'item' => 'publicatom')));
} }
function get_instructions() { function get_instructions()
{
return _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' . return _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
'based on the Free Software [Laconica](http://laconi.ca/) tool. ' . 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
'[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))'); '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))');
} }
function show_header() { function show_header()
{
common_element('link', array('rel' => 'alternate', common_element('link', array('rel' => 'alternate',
'href' => common_local_url('publicrss'), 'href' => common_local_url('publicrss'),
'type' => 'application/rss+xml', 'type' => 'application/rss+xml',
@ -80,7 +84,8 @@ class PublicAction extends StreamAction {
'content' => common_local_url('publicxrds'))); 'content' => common_local_url('publicxrds')));
} }
function show_notices($page) { function show_notices($page)
{
$cnt = 0; $cnt = 0;
$notice = Notice::publicStream(($page-1)*NOTICES_PER_PAGE, $notice = Notice::publicStream(($page-1)*NOTICES_PER_PAGE,

View File

@ -25,11 +25,13 @@ require_once(INSTALLDIR.'/lib/rssaction.php');
class PublicrssAction extends Rss10Action { class PublicrssAction extends Rss10Action {
function init() { function init()
{
return true; return true;
} }
function get_notices($limit=0) { function get_notices($limit=0)
{
$notices = array(); $notices = array();
@ -42,7 +44,8 @@ class PublicrssAction extends Rss10Action {
return $notices; return $notices;
} }
function get_channel() { function get_channel()
{
global $config; global $config;
$c = array('url' => common_local_url('publicrss'), $c = array('url' => common_local_url('publicrss'),
'title' => sprintf(_('%s Public Stream'), $config['site']['name']), 'title' => sprintf(_('%s Public Stream'), $config['site']['name']),
@ -51,7 +54,8 @@ class PublicrssAction extends Rss10Action {
return $c; return $c;
} }
function get_image() { function get_image()
{
return null; return null;
} }
} }

View File

@ -25,11 +25,13 @@ require_once(INSTALLDIR.'/lib/openid.php');
class PublicxrdsAction extends Action { class PublicxrdsAction extends Action {
function is_readonly() { function is_readonly()
{
return true; return true;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -55,7 +57,8 @@ class PublicxrdsAction extends Action {
common_end_xml(); common_end_xml();
} }
function show_service($type, $uri, $params=null, $sigs=null, $localId=null) { function show_service($type, $uri, $params=null, $sigs=null, $localId=null)
{
common_element_start('Service'); common_element_start('Service');
if ($uri) { if ($uri) {
common_element('URI', null, $uri); common_element('URI', null, $uri);

View File

@ -25,7 +25,8 @@ define(MAX_RECOVERY_TIME, 24 * 60 * 60);
class RecoverpasswordAction extends Action { class RecoverpasswordAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (common_logged_in()) { if (common_logged_in()) {
$this->client_error(_('You are already logged in!')); $this->client_error(_('You are already logged in!'));
@ -47,7 +48,8 @@ class RecoverpasswordAction extends Action {
} }
} }
function check_code() { function check_code()
{
$code = $this->trimmed('code'); $code = $this->trimmed('code');
$confirm = Confirm_address::staticGet('code', $code); $confirm = Confirm_address::staticGet('code', $code);
@ -113,12 +115,14 @@ class RecoverpasswordAction extends Action {
$this->show_password_form(); $this->show_password_form();
} }
function set_temp_user(&$user) { function set_temp_user(&$user)
{
common_ensure_session(); common_ensure_session();
$_SESSION['tempuser'] = $user->id; $_SESSION['tempuser'] = $user->id;
} }
function get_temp_user() { function get_temp_user()
{
common_ensure_session(); common_ensure_session();
$user_id = $_SESSION['tempuser']; $user_id = $_SESSION['tempuser'];
if ($user_id) { if ($user_id) {
@ -127,12 +131,14 @@ class RecoverpasswordAction extends Action {
return $user; return $user;
} }
function clear_temp_user() { function clear_temp_user()
{
common_ensure_session(); common_ensure_session();
unset($_SESSION['tempuser']); unset($_SESSION['tempuser']);
} }
function show_top($msg=null) { function show_top($msg=null)
{
if ($msg) { if ($msg) {
common_element('div', 'error', $msg); common_element('div', 'error', $msg);
} else { } else {
@ -146,7 +152,8 @@ class RecoverpasswordAction extends Action {
} }
} }
function show_password_top($msg=null) { function show_password_top($msg=null)
{
if ($msg) { if ($msg) {
common_element('div', 'error', $msg); common_element('div', 'error', $msg);
} else { } else {
@ -156,7 +163,8 @@ class RecoverpasswordAction extends Action {
} }
} }
function show_form($msg=null) { function show_form($msg=null)
{
common_show_header(_('Recover password'), null, common_show_header(_('Recover password'), null,
$msg, array($this, 'show_top')); $msg, array($this, 'show_top'));
@ -173,7 +181,8 @@ class RecoverpasswordAction extends Action {
common_show_footer(); common_show_footer();
} }
function show_password_form($msg=null) { function show_password_form($msg=null)
{
common_show_header(_('Reset password'), null, common_show_header(_('Reset password'), null,
$msg, array($this, 'show_password_top')); $msg, array($this, 'show_password_top'));
@ -191,7 +200,8 @@ class RecoverpasswordAction extends Action {
common_show_footer(); common_show_footer();
} }
function recover_password() { function recover_password()
{
$nore = $this->trimmed('nicknameoremail'); $nore = $this->trimmed('nicknameoremail');
if (!$nore) { if (!$nore) {
$this->show_form(_('Enter a nickname or email address.')); $this->show_form(_('Enter a nickname or email address.'));
@ -274,7 +284,8 @@ class RecoverpasswordAction extends Action {
common_show_footer(); common_show_footer();
} }
function reset_password() { function reset_password()
{
# CSRF protection # CSRF protection
$token = $this->trimmed('token'); $token = $this->trimmed('token');

View File

@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
class RegisterAction extends Action { class RegisterAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (common_config('site', 'closed')) { if (common_config('site', 'closed')) {
@ -35,7 +36,8 @@ class RegisterAction extends Action {
} }
} }
function try_register() { function try_register()
{
$token = $this->trimmed('token'); $token = $this->trimmed('token');
if (!$token || $token != common_session_token()) { if (!$token || $token != common_session_token()) {
@ -133,14 +135,16 @@ class RegisterAction extends Action {
# checks if *CANONICAL* nickname exists # checks if *CANONICAL* nickname exists
function nickname_exists($nickname) { function nickname_exists($nickname)
{
$user = User::staticGet('nickname', $nickname); $user = User::staticGet('nickname', $nickname);
return ($user !== false); return ($user !== false);
} }
# checks if *CANONICAL* email exists # checks if *CANONICAL* email exists
function email_exists($email) { function email_exists($email)
{
$email = common_canonical_email($email); $email = common_canonical_email($email);
if (!$email || strlen($email) == 0) { if (!$email || strlen($email) == 0) {
return false; return false;
@ -149,7 +153,8 @@ class RegisterAction extends Action {
return ($user !== false); return ($user !== false);
} }
function show_top($error=null) { function show_top($error=null)
{
if ($error) { if ($error) {
common_element('p', 'error', $error); common_element('p', 'error', $error);
} else { } else {
@ -164,7 +169,8 @@ class RegisterAction extends Action {
} }
} }
function show_form($error=null) { function show_form($error=null)
{
global $config; global $config;
$code = $this->trimmed('code'); $code = $this->trimmed('code');
@ -236,7 +242,8 @@ class RegisterAction extends Action {
common_show_footer(); common_show_footer();
} }
function show_success() { function show_success()
{
$nickname = $this->arg('nickname'); $nickname = $this->arg('nickname');
common_show_header(_('Registration successful')); common_show_header(_('Registration successful'));
common_element_start('div', 'success'); common_element_start('div', 'success');

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/omb.php');
class RemotesubscribeAction extends Action { class RemotesubscribeAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -47,7 +48,8 @@ class RemotesubscribeAction extends Action {
} }
} }
function get_instructions() { function get_instructions()
{
return _('To subscribe, you can [login](%%action.login%%),' . return _('To subscribe, you can [login](%%action.login%%),' .
' or [register](%%action.register%%) a new ' . ' or [register](%%action.register%%) a new ' .
' account. If you already have an account ' . ' account. If you already have an account ' .
@ -55,7 +57,8 @@ class RemotesubscribeAction extends Action {
' enter your profile URL below.'); ' enter your profile URL below.');
} }
function show_top($err=null) { function show_top($err=null)
{
if ($err) { if ($err) {
common_element('div', 'error', $err); common_element('div', 'error', $err);
} else { } else {
@ -67,7 +70,8 @@ class RemotesubscribeAction extends Action {
} }
} }
function show_form($err=null) { function show_form($err=null)
{
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$profile = $this->trimmed('profile_url'); $profile = $this->trimmed('profile_url');
common_show_header(_('Remote subscribe'), null, $err, common_show_header(_('Remote subscribe'), null, $err,
@ -86,7 +90,8 @@ class RemotesubscribeAction extends Action {
common_show_footer(); common_show_footer();
} }
function remote_subscription() { function remote_subscription()
{
$user = $this->get_user(); $user = $this->get_user();
if (!$user) { if (!$user) {
@ -152,7 +157,8 @@ class RemotesubscribeAction extends Action {
$this->request_authorization($user, $omb, $token, $secret); $this->request_authorization($user, $omb, $token, $secret);
} }
function get_user() { function get_user()
{
$user = null; $user = null;
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
if ($nickname) { if ($nickname) {
@ -161,7 +167,8 @@ class RemotesubscribeAction extends Action {
return $user; return $user;
} }
function getOmb($xrds) { function getOmb($xrds)
{
static $omb_endpoints = array(OMB_ENDPOINT_UPDATEPROFILE, OMB_ENDPOINT_POSTNOTICE); static $omb_endpoints = array(OMB_ENDPOINT_UPDATEPROFILE, OMB_ENDPOINT_POSTNOTICE);
static $oauth_endpoints = array(OAUTH_ENDPOINT_REQUEST, OAUTH_ENDPOINT_AUTHORIZE, static $oauth_endpoints = array(OAUTH_ENDPOINT_REQUEST, OAUTH_ENDPOINT_AUTHORIZE,
@ -221,7 +228,8 @@ class RemotesubscribeAction extends Action {
return $omb; return $omb;
} }
function getXRD($main_service, $main_xrds) { function getXRD($main_service, $main_xrds)
{
$uri = omb_service_uri($main_service); $uri = omb_service_uri($main_service);
if (strpos($uri, "#") !== 0) { if (strpos($uri, "#") !== 0) {
# FIXME: more rigorous handling of external service definitions # FIXME: more rigorous handling of external service definitions
@ -242,7 +250,8 @@ class RemotesubscribeAction extends Action {
return null; return null;
} }
function addServices($xrd, $types, &$omb) { function addServices($xrd, $types, &$omb)
{
foreach ($types as $type) { foreach ($types as $type) {
$matches = omb_get_services($xrd, $type); $matches = omb_get_services($xrd, $type);
if ($matches) { if ($matches) {
@ -255,7 +264,8 @@ class RemotesubscribeAction extends Action {
return true; return true;
} }
function request_token($omb) { function request_token($omb)
{
$con = omb_oauth_consumer(); $con = omb_oauth_consumer();
$url = omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]); $url = omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]);
@ -299,7 +309,8 @@ class RemotesubscribeAction extends Action {
return array($return['oauth_token'], $return['oauth_token_secret']); return array($return['oauth_token'], $return['oauth_token_secret']);
} }
function request_authorization($user, $omb, $token, $secret) { function request_authorization($user, $omb, $token, $secret)
{
global $config; # for license URL global $config; # for license URL
$con = omb_oauth_consumer(); $con = omb_oauth_consumer();
@ -380,7 +391,8 @@ class RemotesubscribeAction extends Action {
return; return;
} }
function make_nonce() { function make_nonce()
{
return common_good_rand(16); return common_good_rand(16);
} }
} }

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/actions/showstream.php');
class RepliesAction extends StreamAction { class RepliesAction extends StreamAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -53,11 +54,13 @@ class RepliesAction extends StreamAction {
common_show_footer(); common_show_footer();
} }
function no_such_user() { function no_such_user()
{
common_user_error(_('No such user.')); common_user_error(_('No such user.'));
} }
function show_header($user) { function show_header($user)
{
common_element('link', array('rel' => 'alternate', common_element('link', array('rel' => 'alternate',
'href' => common_local_url('repliesrss', array('nickname' => 'href' => common_local_url('repliesrss', array('nickname' =>
$user->nickname)), $user->nickname)),
@ -65,7 +68,8 @@ class RepliesAction extends StreamAction {
'title' => sprintf(_('Feed for replies to %s'), $user->nickname))); 'title' => sprintf(_('Feed for replies to %s'), $user->nickname)));
} }
function show_top($user) { function show_top($user)
{
$cur = common_current_user(); $cur = common_current_user();
if ($cur && $cur->id == $user->id) { if ($cur && $cur->id == $user->id) {
@ -80,7 +84,8 @@ class RepliesAction extends StreamAction {
'item' => 'repliesrss'))); 'item' => 'repliesrss')));
} }
function show_replies($user) { function show_replies($user)
{
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;

View File

@ -27,7 +27,8 @@ class RepliesrssAction extends Rss10Action {
var $user = null; var $user = null;
function init() { function init()
{
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname); $this->user = User::staticGet('nickname', $nickname);
@ -39,7 +40,8 @@ class RepliesrssAction extends Rss10Action {
} }
} }
function get_notices($limit=0) { function get_notices($limit=0)
{
$user = $this->user; $user = $this->user;
@ -54,7 +56,8 @@ class RepliesrssAction extends Rss10Action {
return $notices; return $notices;
} }
function get_channel() { function get_channel()
{
$user = $this->user; $user = $this->user;
$c = array('url' => common_local_url('repliesrss', $c = array('url' => common_local_url('repliesrss',
array('nickname' => array('nickname' =>
@ -67,7 +70,8 @@ class RepliesrssAction extends Rss10Action {
return $c; return $c;
} }
function get_image() { function get_image()
{
$user = $this->user; $user = $this->user;
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {

View File

@ -23,11 +23,13 @@ require_once(INSTALLDIR.'/lib/omb.php');
class RequesttokenAction extends Action { class RequesttokenAction extends Action {
function is_readonly() { function is_readonly()
{
return false; return false;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
try { try {
common_remove_magic_from_request(); common_remove_magic_from_request();

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/actions/showstream.php');
class ShowfavoritesAction extends StreamAction { class ShowfavoritesAction extends StreamAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -53,7 +54,8 @@ class ShowfavoritesAction extends StreamAction {
common_show_footer(); common_show_footer();
} }
function show_header($user) { function show_header($user)
{
common_element('link', array('rel' => 'alternate', common_element('link', array('rel' => 'alternate',
'href' => common_local_url('favoritesrss', array('nickname' => 'href' => common_local_url('favoritesrss', array('nickname' =>
$user->nickname)), $user->nickname)),
@ -61,7 +63,8 @@ class ShowfavoritesAction extends StreamAction {
'title' => sprintf(_('Feed for favorites of %s'), $user->nickname))); 'title' => sprintf(_('Feed for favorites of %s'), $user->nickname)));
} }
function show_top($user) { function show_top($user)
{
$cur = common_current_user(); $cur = common_current_user();
if ($cur && $cur->id == $user->id) { if ($cur && $cur->id == $user->id) {
@ -75,7 +78,8 @@ class ShowfavoritesAction extends StreamAction {
$this->views_menu(); $this->views_menu();
} }
function show_notices($user) { function show_notices($user)
{
$page = $this->trimmed('page'); $page = $this->trimmed('page');
if (!$page) { if (!$page) {

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/mailbox.php');
class ShowmessageAction extends MailboxAction { class ShowmessageAction extends MailboxAction {
function handle($args) { function handle($args)
{
Action::handle($args); Action::handle($args);
@ -44,13 +45,15 @@ class ShowmessageAction extends MailboxAction {
} }
} }
function get_message() { function get_message()
{
$id = $this->trimmed('message'); $id = $this->trimmed('message');
$message = Message::staticGet('id', $id); $message = Message::staticGet('id', $id);
return $message; return $message;
} }
function get_title($user, $page) { function get_title($user, $page)
{
$message = $this->get_message(); $message = $this->get_message();
if (!$message) { if (!$message) {
return null; return null;
@ -70,14 +73,16 @@ class ShowmessageAction extends MailboxAction {
return $title; return $title;
} }
function get_messages($user, $page) { function get_messages($user, $page)
{
$message = new Message(); $message = new Message();
$message->id = $this->trimmed('message'); $message->id = $this->trimmed('message');
$message->find(); $message->find();
return $message; return $message;
} }
function get_message_profile($message) { function get_message_profile($message)
{
$user = common_current_user(); $user = common_current_user();
if ($user->id == $message->from_profile) { if ($user->id == $message->from_profile) {
return $message->getTo(); return $message->getTo();
@ -89,11 +94,13 @@ class ShowmessageAction extends MailboxAction {
} }
} }
function get_instructions() { function get_instructions()
{
return ''; return '';
} }
function views_menu() { function views_menu()
{
return; return;
} }
} }

View File

@ -27,7 +27,8 @@ class ShownoticeAction extends StreamAction {
var $profile = null; var $profile = null;
var $avatar = null; var $avatar = null;
function prepare($args) { function prepare($args)
{
parent::prepare($args); parent::prepare($args);
@ -51,13 +52,15 @@ class ShownoticeAction extends StreamAction {
return true; return true;
} }
function last_modified() { function last_modified()
{
return max(strtotime($this->notice->created), return max(strtotime($this->notice->created),
strtotime($this->profile->modified), strtotime($this->profile->modified),
($this->avatar) ? strtotime($this->avatar->modified) : 0); ($this->avatar) ? strtotime($this->avatar->modified) : 0);
} }
function etag() { function etag()
{
return 'W/"' . implode(':', array($this->arg('action'), return 'W/"' . implode(':', array($this->arg('action'),
common_language(), common_language(),
$this->notice->id, $this->notice->id,
@ -66,7 +69,8 @@ class ShownoticeAction extends StreamAction {
($this->avatar) ? strtotime($this->avatar->modified) : 0)) . '"'; ($this->avatar) ? strtotime($this->avatar->modified) : 0)) . '"';
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -84,7 +88,8 @@ class ShownoticeAction extends StreamAction {
common_show_footer(); common_show_footer();
} }
function show_header() { function show_header()
{
$user = User::staticGet($this->profile->id); $user = User::staticGet($this->profile->id);
@ -103,14 +108,16 @@ class ShownoticeAction extends StreamAction {
} }
} }
function show_top() { function show_top()
{
$cur = common_current_user(); $cur = common_current_user();
if ($cur && $cur->id == $this->profile->id) { if ($cur && $cur->id == $this->profile->id) {
common_notice_form(); common_notice_form();
} }
} }
function no_such_notice() { function no_such_notice()
{
common_user_error(_('No such notice.')); common_user_error(_('No such notice.'));
} }
} }

View File

@ -26,7 +26,8 @@ define('SUBSCRIPTIONS', 80);
class ShowstreamAction extends StreamAction { class ShowstreamAction extends StreamAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -76,7 +77,8 @@ class ShowstreamAction extends StreamAction {
common_show_footer(); common_show_footer();
} }
function show_top($user) { function show_top($user)
{
$cur = common_current_user(); $cur = common_current_user();
if ($cur && $cur->id == $user->id) { if ($cur && $cur->id == $user->id) {
@ -100,7 +102,8 @@ class ShowstreamAction extends StreamAction {
'item' => 'foaf'))); 'item' => 'foaf')));
} }
function show_header($user) { function show_header($user)
{
# Feeds # Feeds
common_element('link', array('rel' => 'alternate', common_element('link', array('rel' => 'alternate',
'href' => common_local_url('api', 'href' => common_local_url('api',
@ -153,11 +156,13 @@ class ShowstreamAction extends StreamAction {
array('nickname' => $profile->nickname)))); array('nickname' => $profile->nickname))));
} }
function no_such_user() { function no_such_user()
{
$this->client_error(_('No such user.'), 404); $this->client_error(_('No such user.'), 404);
} }
function show_profile($profile) { function show_profile($profile)
{
common_element_start('div', array('id' => 'profile', 'class' => 'vcard')); common_element_start('div', array('id' => 'profile', 'class' => 'vcard'));
@ -172,7 +177,8 @@ class ShowstreamAction extends StreamAction {
common_element_end('div'); common_element_end('div');
} }
function show_personal($profile) { function show_personal($profile)
{
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
common_element_start('div', array('id' => 'profile_avatar')); common_element_start('div', array('id' => 'profile_avatar'));
@ -246,7 +252,8 @@ class ShowstreamAction extends StreamAction {
common_element_end('div'); common_element_end('div');
} }
function show_remote_subscribe_link($profile) { function show_remote_subscribe_link($profile)
{
$url = common_local_url('remotesubscribe', $url = common_local_url('remotesubscribe',
array('nickname' => $profile->nickname)); array('nickname' => $profile->nickname));
common_element('a', array('href' => $url, common_element('a', array('href' => $url,
@ -254,7 +261,8 @@ class ShowstreamAction extends StreamAction {
_('Subscribe')); _('Subscribe'));
} }
function show_unsubscribe_form($profile) { function show_unsubscribe_form($profile)
{
common_element_start('form', array('id' => 'unsubscribe', 'method' => 'post', common_element_start('form', array('id' => 'unsubscribe', 'method' => 'post',
'action' => common_local_url('unsubscribe'))); 'action' => common_local_url('unsubscribe')));
common_hidden('token', common_session_token()); common_hidden('token', common_session_token());
@ -268,7 +276,8 @@ class ShowstreamAction extends StreamAction {
common_element_end('form'); common_element_end('form');
} }
function show_subscriptions($profile) { function show_subscriptions($profile)
{
global $config; global $config;
$subs = DB_DataObject::factory('subscription'); $subs = DB_DataObject::factory('subscription');
@ -340,7 +349,8 @@ class ShowstreamAction extends StreamAction {
common_element_end('div'); common_element_end('div');
} }
function show_statistics($profile) { function show_statistics($profile)
{
// XXX: WORM cache this // XXX: WORM cache this
$subs = DB_DataObject::factory('subscription'); $subs = DB_DataObject::factory('subscription');
@ -400,7 +410,8 @@ class ShowstreamAction extends StreamAction {
common_element_end('div'); common_element_end('div');
} }
function show_notices($user) { function show_notices($user)
{
$page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
@ -413,7 +424,8 @@ class ShowstreamAction extends StreamAction {
'showstream', array('nickname' => $user->nickname)); 'showstream', array('nickname' => $user->nickname));
} }
function show_last_notice($profile) { function show_last_notice($profile)
{
common_element('h2', null, _('Currently')); common_element('h2', null, _('Currently'));
@ -438,13 +450,15 @@ class ShowstreamAction extends StreamAction {
# We don't show the author for a profile, since we already know who it is! # We don't show the author for a profile, since we already know who it is!
class ProfileNoticeList extends NoticeList { class ProfileNoticeList extends NoticeList {
function newListItem($notice) { function newListItem($notice)
{
return new ProfileNoticeListItem($notice); return new ProfileNoticeListItem($notice);
} }
} }
class ProfileNoticeListItem extends NoticeListItem { class ProfileNoticeListItem extends NoticeListItem {
function showAuthor() { function showAuthor()
{
return; return;
} }
} }

View File

@ -24,11 +24,13 @@ require_once(INSTALLDIR.'/actions/emailsettings.php');
class SmssettingsAction extends EmailsettingsAction { class SmssettingsAction extends EmailsettingsAction {
function get_instructions() { function get_instructions()
{
return _('You can receive SMS messages through email from %%site.name%%.'); return _('You can receive SMS messages through email from %%site.name%%.');
} }
function show_form($msg=null, $success=false) { function show_form($msg=null, $success=false)
{
$user = common_current_user(); $user = common_current_user();
$this->form_header(_('SMS Settings'), $msg, $success); $this->form_header(_('SMS Settings'), $msg, $success);
common_element_start('form', array('method' => 'post', common_element_start('form', array('method' => 'post',
@ -103,7 +105,8 @@ class SmssettingsAction extends EmailsettingsAction {
common_show_footer(); common_show_footer();
} }
function get_confirmation() { function get_confirmation()
{
$user = common_current_user(); $user = common_current_user();
$confirm = new Confirm_address(); $confirm = new Confirm_address();
$confirm->user_id = $user->id; $confirm->user_id = $user->id;
@ -115,7 +118,8 @@ class SmssettingsAction extends EmailsettingsAction {
} }
} }
function handle_post() { function handle_post()
{
# CSRF protection # CSRF protection
@ -144,7 +148,8 @@ class SmssettingsAction extends EmailsettingsAction {
} }
} }
function save_preferences() { function save_preferences()
{
$smsnotify = $this->boolean('smsnotify'); $smsnotify = $this->boolean('smsnotify');
@ -171,7 +176,8 @@ class SmssettingsAction extends EmailsettingsAction {
$this->show_form(_('Preferences saved.'), true); $this->show_form(_('Preferences saved.'), true);
} }
function add_address() { function add_address()
{
$user = common_current_user(); $user = common_current_user();
@ -226,7 +232,8 @@ class SmssettingsAction extends EmailsettingsAction {
$this->show_form($msg, TRUE); $this->show_form($msg, TRUE);
} }
function cancel_confirmation() { function cancel_confirmation()
{
$sms = $this->trimmed('sms'); $sms = $this->trimmed('sms');
$carrier = $this->trimmed('carrier'); $carrier = $this->trimmed('carrier');
@ -253,7 +260,8 @@ class SmssettingsAction extends EmailsettingsAction {
$this->show_form(_('Confirmation cancelled.'), TRUE); $this->show_form(_('Confirmation cancelled.'), TRUE);
} }
function remove_address() { function remove_address()
{
$user = common_current_user(); $user = common_current_user();
$sms = $this->arg('sms'); $sms = $this->arg('sms');
@ -282,7 +290,8 @@ class SmssettingsAction extends EmailsettingsAction {
$this->show_form(_('The address was removed.'), TRUE); $this->show_form(_('The address was removed.'), TRUE);
} }
function sms_exists($sms) { function sms_exists($sms)
{
$user = common_current_user(); $user = common_current_user();
$other = User::staticGet('sms', $sms); $other = User::staticGet('sms', $sms);
if (!$other) { if (!$other) {
@ -292,7 +301,8 @@ class SmssettingsAction extends EmailsettingsAction {
} }
} }
function carrier_select() { function carrier_select()
{
$carrier = new Sms_carrier(); $carrier = new Sms_carrier();
$cnt = $carrier->find(); $cnt = $carrier->find();
@ -316,7 +326,8 @@ class SmssettingsAction extends EmailsettingsAction {
common_config('site', 'email'))); common_config('site', 'email')));
} }
function confirm_code() { function confirm_code()
{
$code = $this->trimmed('code'); $code = $this->trimmed('code');

View File

@ -23,7 +23,8 @@ class SubeditAction extends Action {
var $profile = null; var $profile = null;
function prepare($args) { function prepare($args)
{
parent::prepare($args); parent::prepare($args);
@ -56,7 +57,8 @@ class SubeditAction extends Action {
return true; return true;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$cur = common_current_user(); $cur = common_current_user();

View File

@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
class SubscribeAction extends Action { class SubscribeAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {

View File

@ -23,11 +23,13 @@ require_once(INSTALLDIR.'/lib/gallery.php');
class SubscribersAction extends GalleryAction { class SubscribersAction extends GalleryAction {
function gallery_type() { function gallery_type()
{
return _('Subscribers'); return _('Subscribers');
} }
function get_instructions(&$profile) { function get_instructions(&$profile)
{
$user =& common_current_user(); $user =& common_current_user();
if ($user && ($user->id == $profile->id)) { if ($user && ($user->id == $profile->id)) {
return _('These are the people who listen to your notices.'); return _('These are the people who listen to your notices.');
@ -36,25 +38,30 @@ class SubscribersAction extends GalleryAction {
} }
} }
function fields() { function fields()
{
return array('subscriber', 'subscribed'); return array('subscriber', 'subscribed');
} }
function div_class() { function div_class()
{
return 'subscribers'; return 'subscribers';
} }
function get_other(&$subs) { function get_other(&$subs)
{
return $subs->subscriber; return $subs->subscriber;
} }
function profile_list_class() { function profile_list_class()
{
return 'SubscribersList'; return 'SubscribersList';
} }
} }
class SubscribersList extends ProfileList { class SubscribersList extends ProfileList {
function show_owner_controls($profile) { function show_owner_controls($profile)
{
common_block_form($profile, array('action' => 'subscribers', common_block_form($profile, array('action' => 'subscribers',
'nickname' => $this->owner->nickname)); 'nickname' => $this->owner->nickname));
} }

View File

@ -23,11 +23,13 @@ require_once(INSTALLDIR.'/lib/gallery.php');
class SubscriptionsAction extends GalleryAction { class SubscriptionsAction extends GalleryAction {
function gallery_type() { function gallery_type()
{
return _('Subscriptions'); return _('Subscriptions');
} }
function get_instructions(&$profile) { function get_instructions(&$profile)
{
$user =& common_current_user(); $user =& common_current_user();
if ($user && ($user->id == $profile->id)) { if ($user && ($user->id == $profile->id)) {
return _('These are the people whose notices you listen to.'); return _('These are the people whose notices you listen to.');
@ -36,26 +38,31 @@ class SubscriptionsAction extends GalleryAction {
} }
} }
function fields() { function fields()
{
return array('subscribed', 'subscriber'); return array('subscribed', 'subscriber');
} }
function div_class() { function div_class()
{
return 'subscriptions'; return 'subscriptions';
} }
function get_other(&$subs) { function get_other(&$subs)
{
return $subs->subscribed; return $subs->subscribed;
} }
function profile_list_class() { function profile_list_class()
{
return 'SubscriptionsList'; return 'SubscriptionsList';
} }
} }
class SubscriptionsList extends ProfileList { class SubscriptionsList extends ProfileList {
function show_owner_controls($profile) { function show_owner_controls($profile)
{
$sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id, $sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id,
'subscribed' => $profile->id)); 'subscribed' => $profile->id));

View File

@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); }
class SupAction extends Action { class SupAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -42,7 +43,8 @@ class SupAction extends Action {
'updates' => $updates)); 'updates' => $updates));
} }
function available_periods() { function available_periods()
{
static $periods = array(86400, 43200, 21600, 7200, static $periods = array(86400, 43200, 21600, 7200,
3600, 1800, 600, 300, 120, 3600, 1800, 600, 300, 120,
60, 30, 15); 60, 30, 15);
@ -55,7 +57,8 @@ class SupAction extends Action {
return $available; return $available;
} }
function get_updates($seconds) { function get_updates($seconds)
{
$notice = new Notice(); $notice = new Notice();
# XXX: cache this. Depends on how big this protocol becomes; # XXX: cache this. Depends on how big this protocol becomes;
@ -75,7 +78,8 @@ class SupAction extends Action {
return $updates; return $updates;
} }
function is_readonly() { function is_readonly()
{
return true; return true;
} }
} }

View File

@ -24,7 +24,8 @@ define('TAGS_PER_PAGE', 100);
class TagAction extends StreamAction { class TagAction extends StreamAction {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -46,7 +47,8 @@ class TagAction extends StreamAction {
common_show_footer(); common_show_footer();
} }
function show_header($tag = false) { function show_header($tag = false)
{
if ($tag) { if ($tag) {
common_element('link', array('rel' => 'alternate', common_element('link', array('rel' => 'alternate',
'href' => common_local_url('tagrss', array('tag' => $tag)), 'href' => common_local_url('tagrss', array('tag' => $tag)),
@ -55,11 +57,13 @@ class TagAction extends StreamAction {
} }
} }
function get_instructions() { function get_instructions()
{
return _('Showing most popular tags from the last week'); return _('Showing most popular tags from the last week');
} }
function show_top($tag = false) { function show_top($tag = false)
{
if (!$tag) { if (!$tag) {
$instr = $this->get_instructions(); $instr = $this->get_instructions();
$output = common_markup_to_html($instr); $output = common_markup_to_html($instr);
@ -124,7 +128,8 @@ class TagAction extends StreamAction {
} }
} }
function show_tag($tag, $weight, $relative) { function show_tag($tag, $weight, $relative)
{
# XXX: these should probably tune to the size of the site # XXX: these should probably tune to the size of the site
if ($relative > 0.1) { if ($relative > 0.1) {
@ -149,7 +154,8 @@ class TagAction extends StreamAction {
common_text(' '); common_text(' ');
} }
function show_notices($tag) { function show_notices($tag)
{
$cnt = 0; $cnt = 0;

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/settingsaction.php');
class TagotherAction extends Action { class TagotherAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
@ -49,7 +50,8 @@ class TagotherAction extends Action {
} }
} }
function show_form($profile, $error=null) { function show_form($profile, $error=null)
{
$user = common_current_user(); $user = common_current_user();
@ -103,7 +105,8 @@ class TagotherAction extends Action {
} }
function save_tags() { function save_tags()
{
$id = $this->trimmed('id'); $id = $this->trimmed('id');
$tagstring = $this->trimmed('tags'); $tagstring = $this->trimmed('tags');
@ -178,7 +181,8 @@ class TagotherAction extends Action {
} }
} }
function show_top($arr = null) { function show_top($arr = null)
{
list($profile, $error) = $arr; list($profile, $error) = $arr;
if ($error) { if ($error) {
common_element('p', 'error', $error); common_element('p', 'error', $error);

View File

@ -25,7 +25,8 @@ require_once(INSTALLDIR.'/lib/rssaction.php');
class TagrssAction extends Rss10Action { class TagrssAction extends Rss10Action {
function init() { function init()
{
$tag = $this->trimmed('tag'); $tag = $this->trimmed('tag');
$this->tag = Notice_tag::staticGet('tag', $tag); $this->tag = Notice_tag::staticGet('tag', $tag);
@ -37,7 +38,8 @@ class TagrssAction extends Rss10Action {
} }
} }
function get_notices($limit=0) { function get_notices($limit=0)
{
$tag = $this->tag; $tag = $this->tag;
if (is_null($tag)) { if (is_null($tag)) {
@ -53,7 +55,8 @@ class TagrssAction extends Rss10Action {
return $notices; return $notices;
} }
function get_channel() { function get_channel()
{
$tag = $this->tag->tag; $tag = $this->tag->tag;
$c = array('url' => common_local_url('tagrss', array('tag' => $tagname)), $c = array('url' => common_local_url('tagrss', array('tag' => $tagname)),

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
class TwitapiaccountAction extends TwitterapiAction { class TwitapiaccountAction extends TwitterapiAction {
function verify_credentials($args, $apidata) { function verify_credentials($args, $apidata)
{
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { if (!in_array($apidata['content-type'], array('xml', 'json'))) {
@ -34,12 +35,14 @@ class TwitapiaccountAction extends TwitterapiAction {
$this->show_extended_profile($apidata['user'], $apidata); $this->show_extended_profile($apidata['user'], $apidata);
} }
function end_session($args, $apidata) { function end_session($args, $apidata)
{
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); common_server_error(_('API method under construction.'), $code=501);
} }
function update_location($args, $apidata) { function update_location($args, $apidata)
{
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') { if ($_SERVER['REQUEST_METHOD'] != 'POST') {
@ -84,12 +87,14 @@ class TwitapiaccountAction extends TwitterapiAction {
} }
function update_delivery_device($args, $apidata) { function update_delivery_device($args, $apidata)
{
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); common_server_error(_('API method under construction.'), $code=501);
} }
function rate_limit_status($args, $apidata) { function rate_limit_status($args, $apidata)
{
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); common_server_error(_('API method under construction.'), $code=501);
} }

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
class TwitapiblocksAction extends TwitterapiAction { class TwitapiblocksAction extends TwitterapiAction {
function create($args, $apidata) { function create($args, $apidata)
{
parent::handle($args); parent::handle($args);
@ -46,7 +47,8 @@ class TwitapiblocksAction extends TwitterapiAction {
} }
} }
function destroy($args, $apidata) { function destroy($args, $apidata)
{
parent::handle($args); parent::handle($args);
$blockee = $this->get_user($apidata['api_arg'], $apidata); $blockee = $this->get_user($apidata['api_arg'], $apidata);

View File

@ -23,17 +23,20 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
class Twitapidirect_messagesAction extends TwitterapiAction { class Twitapidirect_messagesAction extends TwitterapiAction {
function direct_messages($args, $apidata) { function direct_messages($args, $apidata)
{
parent::handle($args); parent::handle($args);
return $this->show_messages($args, $apidata, 'received'); return $this->show_messages($args, $apidata, 'received');
} }
function sent($args, $apidata) { function sent($args, $apidata)
{
parent::handle($args); parent::handle($args);
return $this->show_messages($args, $apidata, 'sent'); return $this->show_messages($args, $apidata, 'sent');
} }
function show_messages($args, $apidata, $type) { function show_messages($args, $apidata, $type)
{
$user = $apidata['user']; $user = $apidata['user'];
@ -110,7 +113,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
} }
// had to change this from "new" to "create" to avoid PHP reserved word // had to change this from "new" to "create" to avoid PHP reserved word
function create($args, $apidata) { function create($args, $apidata)
{
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') { if ($_SERVER['REQUEST_METHOD'] != 'POST') {
@ -173,12 +177,14 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
} }
function destroy($args, $apidata) { function destroy($args, $apidata)
{
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); common_server_error(_('API method under construction.'), $code=501);
} }
function show_xml_dmsgs($message) { function show_xml_dmsgs($message)
{
$this->init_document('xml'); $this->init_document('xml');
common_element_start('direct-messages', array('type' => 'array')); common_element_start('direct-messages', array('type' => 'array'));
@ -200,7 +206,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
} }
function show_json_dmsgs($message) { function show_json_dmsgs($message)
{
$this->init_document('json'); $this->init_document('json');
@ -223,7 +230,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
} }
function show_rss_dmsgs($message, $title, $link, $subtitle) { function show_rss_dmsgs($message, $title, $link, $subtitle)
{
$this->init_document('rss'); $this->init_document('rss');
@ -252,7 +260,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
} }
function show_atom_dmsgs($message, $title, $link, $subtitle) { function show_atom_dmsgs($message, $title, $link, $subtitle)
{
$this->init_document('atom'); $this->init_document('atom');
@ -279,7 +288,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
} }
// swiped from MessageAction. Should it be place in util.php? // swiped from MessageAction. Should it be place in util.php?
function notify($from, $to, $message) { function notify($from, $to, $message)
{
mail_notify_message($message, $from, $to); mail_notify_message($message, $from, $to);
# XXX: Jabber, SMS notifications... probably queued # XXX: Jabber, SMS notifications... probably queued
} }

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
class TwitapifavoritesAction extends TwitterapiAction { class TwitapifavoritesAction extends TwitterapiAction {
function favorites($args, $apidata) { function favorites($args, $apidata)
{
parent::handle($args); parent::handle($args);
$this->auth_user = $apidata['user']; $this->auth_user = $apidata['user'];
@ -85,7 +86,8 @@ class TwitapifavoritesAction extends TwitterapiAction {
} }
function create($args, $apidata) { function create($args, $apidata)
{
parent::handle($args); parent::handle($args);
// Check for RESTfulness // Check for RESTfulness
@ -134,14 +136,16 @@ class TwitapifavoritesAction extends TwitterapiAction {
} }
function destroy($args, $apidata) { function destroy($args, $apidata)
{
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); common_server_error(_('API method under construction.'), $code=501);
} }
// XXX: these two funcs swiped from faves. Maybe put in util.php, or some common base class? // XXX: these two funcs swiped from faves. Maybe put in util.php, or some common base class?
function notify($fave, $notice, $user) { function notify($fave, $notice, $user)
{
$other = User::staticGet('id', $notice->profile_id); $other = User::staticGet('id', $notice->profile_id);
if ($other && $other->id != $user->id) { if ($other && $other->id != $user->id) {
if ($other->email && $other->emailnotifyfav) { if ($other->email && $other->emailnotifyfav) {
@ -152,7 +156,8 @@ class TwitapifavoritesAction extends TwitterapiAction {
} }
} }
function notify_mail($other, $user, $notice) { function notify_mail($other, $user, $notice)
{
$profile = $user->getProfile(); $profile = $user->getProfile();
$bestname = $profile->getBestName(); $bestname = $profile->getBestName();
$subject = sprintf(_('%s added your notice as a favorite'), $bestname); $subject = sprintf(_('%s added your notice as a favorite'), $bestname);

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
class TwitapifriendshipsAction extends TwitterapiAction { class TwitapifriendshipsAction extends TwitterapiAction {
function create($args, $apidata) { function create($args, $apidata)
{
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] != 'POST') { if ($_SERVER['REQUEST_METHOD'] != 'POST') {
@ -75,7 +76,8 @@ class TwitapifriendshipsAction extends TwitterapiAction {
} }
function destroy($args, $apidata) { function destroy($args, $apidata)
{
parent::handle($args); parent::handle($args);
if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
@ -110,7 +112,8 @@ class TwitapifriendshipsAction extends TwitterapiAction {
} }
function exists($args, $apidata) { function exists($args, $apidata)
{
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { if (!in_array($apidata['content-type'], array('xml', 'json'))) {

View File

@ -27,7 +27,8 @@ class TwitapihelpAction extends TwitterapiAction {
* URL:http://identi.ca/api/help/test.format * URL:http://identi.ca/api/help/test.format
* Formats: xml, json * Formats: xml, json
*/ */
function test($args, $apidata) { function test($args, $apidata)
{
parent::handle($args); parent::handle($args);
if ($apidata['content-type'] == 'xml') { if ($apidata['content-type'] == 'xml') {
@ -44,7 +45,8 @@ class TwitapihelpAction extends TwitterapiAction {
} }
function downtime_schedule($args, $apidata) { function downtime_schedule($args, $apidata)
{
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); common_server_error(_('API method under construction.'), $code=501);
} }

View File

@ -24,12 +24,14 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
# This naming convention looks real sick # This naming convention looks real sick
class TwitapinotificationsAction extends TwitterapiAction { class TwitapinotificationsAction extends TwitterapiAction {
function follow($args, $apidata) { function follow($args, $apidata)
{
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); common_server_error(_('API method under construction.'), $code=501);
} }
function leave($args, $apidata) { function leave($args, $apidata)
{
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); common_server_error(_('API method under construction.'), $code=501);
} }

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
class TwitapistatusesAction extends TwitterapiAction { class TwitapistatusesAction extends TwitterapiAction {
function public_timeline($args, $apidata) { function public_timeline($args, $apidata)
{
parent::handle($args); parent::handle($args);
$sitename = common_config('site', 'name'); $sitename = common_config('site', 'name');
@ -84,7 +85,8 @@ class TwitapistatusesAction extends TwitterapiAction {
} }
function friends_timeline($args, $apidata) { function friends_timeline($args, $apidata)
{
parent::handle($args); parent::handle($args);
$since = $this->arg('since'); $since = $this->arg('since');
@ -146,7 +148,8 @@ class TwitapistatusesAction extends TwitterapiAction {
} }
function user_timeline($args, $apidata) { function user_timeline($args, $apidata)
{
parent::handle($args); parent::handle($args);
$this->auth_user = $apidata['user']; $this->auth_user = $apidata['user'];
@ -226,7 +229,8 @@ class TwitapistatusesAction extends TwitterapiAction {
} }
function update($args, $apidata) { function update($args, $apidata)
{
parent::handle($args); parent::handle($args);
@ -321,7 +325,8 @@ class TwitapistatusesAction extends TwitterapiAction {
$this->show($args, $apidata); $this->show($args, $apidata);
} }
function replies($args, $apidata) { function replies($args, $apidata)
{
parent::handle($args); parent::handle($args);
@ -388,7 +393,8 @@ class TwitapistatusesAction extends TwitterapiAction {
} }
function show($args, $apidata) { function show($args, $apidata)
{
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { if (!in_array($apidata['content-type'], array('xml', 'json'))) {
@ -413,7 +419,8 @@ class TwitapistatusesAction extends TwitterapiAction {
} }
function destroy($args, $apidata) { function destroy($args, $apidata)
{
parent::handle($args); parent::handle($args);
@ -457,18 +464,21 @@ class TwitapistatusesAction extends TwitterapiAction {
} }
function friends($args, $apidata) { function friends($args, $apidata)
{
parent::handle($args); parent::handle($args);
return $this->subscriptions($apidata, 'subscribed', 'subscriber'); return $this->subscriptions($apidata, 'subscribed', 'subscriber');
} }
function followers($args, $apidata) { function followers($args, $apidata)
{
parent::handle($args); parent::handle($args);
return $this->subscriptions($apidata, 'subscriber', 'subscribed'); return $this->subscriptions($apidata, 'subscriber', 'subscribed');
} }
function subscriptions($apidata, $other_attr, $user_attr) { function subscriptions($apidata, $other_attr, $user_attr)
{
# XXX: lite # XXX: lite
@ -523,7 +533,8 @@ class TwitapistatusesAction extends TwitterapiAction {
$this->end_document($type); $this->end_document($type);
} }
function show_profiles($profiles, $type) { function show_profiles($profiles, $type)
{
switch ($type) { switch ($type) {
case 'xml': case 'xml':
common_element_start('users', array('type' => 'array')); common_element_start('users', array('type' => 'array'));
@ -544,12 +555,14 @@ class TwitapistatusesAction extends TwitterapiAction {
} }
} }
function featured($args, $apidata) { function featured($args, $apidata)
{
parent::handle($args); parent::handle($args);
common_server_error(_('API method under construction.'), $code=501); common_server_error(_('API method under construction.'), $code=501);
} }
function supported($cmd) { function supported($cmd)
{
$cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand', 'FavCommand', 'OnCommand', 'OffCommand'); $cmdlist = array('MessageCommand', 'SubCommand', 'UnsubCommand', 'FavCommand', 'OnCommand', 'OffCommand');

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
class TwitapiusersAction extends TwitterapiAction { class TwitapiusersAction extends TwitterapiAction {
function show($args, $apidata) { function show($args, $apidata)
{
parent::handle($args); parent::handle($args);
if (!in_array($apidata['content-type'], array('xml', 'json'))) { if (!in_array($apidata['content-type'], array('xml', 'json'))) {

View File

@ -25,12 +25,14 @@ define('SUBSCRIPTIONS', 80);
class TwittersettingsAction extends SettingsAction { class TwittersettingsAction extends SettingsAction {
function get_instructions() { function get_instructions()
{
return _('Add your Twitter account to automatically send your notices to Twitter, ' . return _('Add your Twitter account to automatically send your notices to Twitter, ' .
'and subscribe to Twitter friends already here.'); 'and subscribe to Twitter friends already here.');
} }
function show_form($msg=null, $success=false) { function show_form($msg=null, $success=false)
{
$user = common_current_user(); $user = common_current_user();
$profile = $user->getProfile(); $profile = $user->getProfile();
$fuser = null; $fuser = null;
@ -91,7 +93,8 @@ class TwittersettingsAction extends SettingsAction {
common_show_footer(); common_show_footer();
} }
function subscribed_twitter_users() { function subscribed_twitter_users()
{
$current_user = common_current_user(); $current_user = common_current_user();
@ -119,7 +122,8 @@ class TwittersettingsAction extends SettingsAction {
return $users; return $users;
} }
function show_twitter_subscriptions() { function show_twitter_subscriptions()
{
$friends = $this->subscribed_twitter_users(); $friends = $this->subscribed_twitter_users();
$friends_count = count($friends); $friends_count = count($friends);
@ -180,7 +184,8 @@ class TwittersettingsAction extends SettingsAction {
} }
function handle_post() { function handle_post()
{
# CSRF protection # CSRF protection
$token = $this->trimmed('token'); $token = $this->trimmed('token');
@ -200,7 +205,8 @@ class TwittersettingsAction extends SettingsAction {
} }
} }
function add_twitter_acct() { function add_twitter_acct()
{
$screen_name = $this->trimmed('twitter_username'); $screen_name = $this->trimmed('twitter_username');
$password = $this->trimmed('twitter_password'); $password = $this->trimmed('twitter_password');
@ -261,7 +267,8 @@ class TwittersettingsAction extends SettingsAction {
$this->show_form(_('Twitter settings saved.'), true); $this->show_form(_('Twitter settings saved.'), true);
} }
function remove_twitter_acct() { function remove_twitter_acct()
{
$user = common_current_user(); $user = common_current_user();
$flink = Foreign_link::getByUserID($user->id, 1); $flink = Foreign_link::getByUserID($user->id, 1);
@ -284,7 +291,8 @@ class TwittersettingsAction extends SettingsAction {
$this->show_form(_('Twitter account removed.'), TRUE); $this->show_form(_('Twitter account removed.'), TRUE);
} }
function save_preferences() { function save_preferences()
{
$noticesync = $this->boolean('noticesync'); $noticesync = $this->boolean('noticesync');
$friendsync = $this->boolean('friendsync'); $friendsync = $this->boolean('friendsync');
@ -330,7 +338,8 @@ class TwittersettingsAction extends SettingsAction {
$this->show_form(_('Twitter preferences saved.')); $this->show_form(_('Twitter preferences saved.'));
} }
function verify_credentials($screen_name, $password) { function verify_credentials($screen_name, $password)
{
$uri = 'http://twitter.com/account/verify_credentials.json'; $uri = 'http://twitter.com/account/verify_credentials.json';
$data = get_twitter_data($uri, $screen_name, $password); $data = get_twitter_data($uri, $screen_name, $password);
@ -353,7 +362,8 @@ class TwittersettingsAction extends SettingsAction {
return false; return false;
} }
function set_flags(&$flink, $noticesync, $replysync, $friendsync) { function set_flags(&$flink, $noticesync, $replysync, $friendsync)
{
if ($noticesync) { if ($noticesync) {
$flink->noticesync |= FOREIGN_NOTICE_SEND; $flink->noticesync |= FOREIGN_NOTICE_SEND;
} else { } else {

View File

@ -23,7 +23,8 @@ class UnblockAction extends Action {
var $profile = null; var $profile = null;
function prepare($args) { function prepare($args)
{
parent::prepare($args); parent::prepare($args);
@ -56,14 +57,16 @@ class UnblockAction extends Action {
return true; return true;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->unblock_profile(); $this->unblock_profile();
} }
} }
function unblock_profile() { function unblock_profile()
{
$cur = common_current_user(); $cur = common_current_user();

View File

@ -19,7 +19,8 @@
class UnsubscribeAction extends Action { class UnsubscribeAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if (!common_logged_in()) { if (!common_logged_in()) {
common_user_error(_('Not logged in.')); common_user_error(_('Not logged in.'));

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/lib/omb.php');
class UpdateprofileAction extends Action { class UpdateprofileAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
try { try {
common_remove_magic_from_request(); common_remove_magic_from_request();
@ -40,7 +41,8 @@ class UpdateprofileAction extends Action {
} }
} }
function update_profile($req, $consumer, $token) { function update_profile($req, $consumer, $token)
{
$version = $req->get_parameter('omb_version'); $version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) { if ($version != OMB_VERSION_01) {
$this->client_error(_('Unsupported OMB version'), 400); $this->client_error(_('Unsupported OMB version'), 400);

View File

@ -24,7 +24,8 @@ define('TIMESTAMP_THRESHOLD', 300);
class UserauthorizationAction extends Action { class UserauthorizationAction extends Action {
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_SERVER['REQUEST_METHOD'] == 'POST') {
@ -69,7 +70,8 @@ class UserauthorizationAction extends Action {
} }
} }
function show_form($req) { function show_form($req)
{
$nickname = $req->get_parameter('omb_listenee_nickname'); $nickname = $req->get_parameter('omb_listenee_nickname');
$profile = $req->get_parameter('omb_listenee_profile'); $profile = $req->get_parameter('omb_listenee_profile');
@ -129,7 +131,8 @@ class UserauthorizationAction extends Action {
common_show_footer(); common_show_footer();
} }
function send_authorization() { function send_authorization()
{
$req = $this->get_stored_request(); $req = $this->get_stored_request();
if (!$req) { if (!$req) {
@ -197,7 +200,8 @@ class UserauthorizationAction extends Action {
} }
} }
function authorize_token(&$req) { function authorize_token(&$req)
{
$consumer_key = $req->get_parameter('oauth_consumer_key'); $consumer_key = $req->get_parameter('oauth_consumer_key');
$token_field = $req->get_parameter('oauth_token'); $token_field = $req->get_parameter('oauth_token');
common_debug('consumer key = "'.$consumer_key.'"', __FILE__); common_debug('consumer key = "'.$consumer_key.'"', __FILE__);
@ -222,7 +226,8 @@ class UserauthorizationAction extends Action {
# XXX: refactor with similar code in finishremotesubscribe.php # XXX: refactor with similar code in finishremotesubscribe.php
function save_remote_profile(&$req) { function save_remote_profile(&$req)
{
# FIXME: we should really do this when the consumer comes # FIXME: we should really do this when the consumer comes
# back for an access token. If they never do, we've got stuff in a # back for an access token. If they never do, we've got stuff in a
# weird state. # weird state.
@ -312,13 +317,15 @@ class UserauthorizationAction extends Action {
return TRUE; return TRUE;
} }
function add_avatar($profile, $url) { function add_avatar($profile, $url)
{
$temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar'); $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
copy($url, $temp_filename); copy($url, $temp_filename);
return $profile->setOriginal($temp_filename); return $profile->setOriginal($temp_filename);
} }
function show_accept_message($tok) { function show_accept_message($tok)
{
common_show_header(_('Subscription authorized')); common_show_header(_('Subscription authorized'));
common_element('p', null, common_element('p', null,
_('The subscription has been authorized, but no '. _('The subscription has been authorized, but no '.
@ -328,7 +335,8 @@ class UserauthorizationAction extends Action {
common_show_footer(); common_show_footer();
} }
function show_reject_message($tok) { function show_reject_message($tok)
{
common_show_header(_('Subscription rejected')); common_show_header(_('Subscription rejected'));
common_element('p', null, common_element('p', null,
_('The subscription has been rejected, but no '. _('The subscription has been rejected, but no '.
@ -337,23 +345,27 @@ class UserauthorizationAction extends Action {
common_show_footer(); common_show_footer();
} }
function store_request($req) { function store_request($req)
{
common_ensure_session(); common_ensure_session();
$_SESSION['userauthorizationrequest'] = $req; $_SESSION['userauthorizationrequest'] = $req;
} }
function clear_request() { function clear_request()
{
common_ensure_session(); common_ensure_session();
unset($_SESSION['userauthorizationrequest']); unset($_SESSION['userauthorizationrequest']);
} }
function get_stored_request() { function get_stored_request()
{
common_ensure_session(); common_ensure_session();
$req = $_SESSION['userauthorizationrequest']; $req = $_SESSION['userauthorizationrequest'];
return $req; return $req;
} }
function get_new_request() { function get_new_request()
{
common_remove_magic_from_request(); common_remove_magic_from_request();
$req = OAuthRequest::from_request(); $req = OAuthRequest::from_request();
return $req; return $req;
@ -361,7 +373,8 @@ class UserauthorizationAction extends Action {
# Throws an OAuthException if anything goes wrong # Throws an OAuthException if anything goes wrong
function validate_request(&$req) { function validate_request(&$req)
{
# OAuth stuff -- have to copy from OAuth.php since they're # OAuth stuff -- have to copy from OAuth.php since they're
# all private methods, and there's no user-authentication method # all private methods, and there's no user-authentication method
common_debug('checking version', __FILE__); common_debug('checking version', __FILE__);
@ -384,7 +397,8 @@ class UserauthorizationAction extends Action {
return true; return true;
} }
function validate_omb(&$req) { function validate_omb(&$req)
{
foreach (array('omb_version', 'omb_listener', 'omb_listenee', foreach (array('omb_version', 'omb_listener', 'omb_listenee',
'omb_listenee_profile', 'omb_listenee_nickname', 'omb_listenee_profile', 'omb_listenee_nickname',
'omb_listenee_license') as $param) 'omb_listenee_license') as $param)
@ -498,7 +512,8 @@ class UserauthorizationAction extends Action {
# Snagged from OAuthServer # Snagged from OAuthServer
function check_version(&$req) { function check_version(&$req)
{
$version = $req->get_parameter("oauth_version"); $version = $req->get_parameter("oauth_version");
if (!$version) { if (!$version) {
$version = 1.0; $version = 1.0;
@ -511,7 +526,8 @@ class UserauthorizationAction extends Action {
# Snagged from OAuthServer # Snagged from OAuthServer
function get_consumer($datastore, $req) { function get_consumer($datastore, $req)
{
$consumer_key = @$req->get_parameter("oauth_consumer_key"); $consumer_key = @$req->get_parameter("oauth_consumer_key");
if (!$consumer_key) { if (!$consumer_key) {
throw new OAuthException("Invalid consumer key"); throw new OAuthException("Invalid consumer key");
@ -526,7 +542,8 @@ class UserauthorizationAction extends Action {
# Mostly cadged from OAuthServer # Mostly cadged from OAuthServer
function get_token($datastore, &$req, $consumer) {/*{{{*/ function get_token($datastore, &$req, $consumer)
{/*{{{*/
$token_field = @$req->get_parameter('oauth_token'); $token_field = @$req->get_parameter('oauth_token');
$token = $datastore->lookup_token($consumer, 'request', $token_field); $token = $datastore->lookup_token($consumer, 'request', $token_field);
if (!$token) { if (!$token) {
@ -535,7 +552,8 @@ class UserauthorizationAction extends Action {
return $token; return $token;
} }
function check_timestamp(&$req) { function check_timestamp(&$req)
{
$timestamp = @$req->get_parameter('oauth_timestamp'); $timestamp = @$req->get_parameter('oauth_timestamp');
$now = time(); $now = time();
if ($now - $timestamp > TIMESTAMP_THRESHOLD) { if ($now - $timestamp > TIMESTAMP_THRESHOLD) {
@ -544,7 +562,8 @@ class UserauthorizationAction extends Action {
} }
# NOTE: don't call twice on the same request; will fail! # NOTE: don't call twice on the same request; will fail!
function check_nonce(&$datastore, &$req, $consumer, $token) { function check_nonce(&$datastore, &$req, $consumer, $token)
{
$timestamp = @$req->get_parameter('oauth_timestamp'); $timestamp = @$req->get_parameter('oauth_timestamp');
$nonce = @$req->get_parameter('oauth_nonce'); $nonce = @$req->get_parameter('oauth_nonce');
$found = $datastore->lookup_nonce($consumer, $token, $nonce, $timestamp); $found = $datastore->lookup_nonce($consumer, $token, $nonce, $timestamp);
@ -554,7 +573,8 @@ class UserauthorizationAction extends Action {
return true; return true;
} }
function check_signature(&$req, $consumer, $token) { function check_signature(&$req, $consumer, $token)
{
$signature_method = $this->get_signature_method($req); $signature_method = $this->get_signature_method($req);
$signature = $req->get_parameter('oauth_signature'); $signature = $req->get_parameter('oauth_signature');
$valid_sig = $signature_method->check_signature($req, $valid_sig = $signature_method->check_signature($req,
@ -566,7 +586,8 @@ class UserauthorizationAction extends Action {
} }
} }
function get_signature_method(&$req) { function get_signature_method(&$req)
{
$signature_method = @$req->get_parameter("oauth_signature_method"); $signature_method = @$req->get_parameter("oauth_signature_method");
if (!$signature_method) { if (!$signature_method) {
$signature_method = "PLAINTEXT"; $signature_method = "PLAINTEXT";

View File

@ -21,11 +21,13 @@ if (!defined('LACONICA')) { exit(1); }
class UserbyidAction extends Action { class UserbyidAction extends Action {
function is_readonly() { function is_readonly()
{
return true; return true;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$id = $this->trimmed('id'); $id = $this->trimmed('id');
if (!$id) { if (!$id) {

View File

@ -27,7 +27,8 @@ class UserrssAction extends Rss10Action {
var $user = null; var $user = null;
function init() { function init()
{
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname); $this->user = User::staticGet('nickname', $nickname);
@ -39,7 +40,8 @@ class UserrssAction extends Rss10Action {
} }
} }
function get_notices($limit=0) { function get_notices($limit=0)
{
$user = $this->user; $user = $this->user;
@ -56,7 +58,8 @@ class UserrssAction extends Rss10Action {
return $notices; return $notices;
} }
function get_channel() { function get_channel()
{
$user = $this->user; $user = $this->user;
$profile = $user->getProfile(); $profile = $user->getProfile();
$c = array('url' => common_local_url('userrss', $c = array('url' => common_local_url('userrss',
@ -68,7 +71,8 @@ class UserrssAction extends Rss10Action {
return $c; return $c;
} }
function get_image() { function get_image()
{
$user = $this->user; $user = $this->user;
$profile = $user->getProfile(); $profile = $user->getProfile();
if (!$profile) { if (!$profile) {
@ -82,7 +86,8 @@ class UserrssAction extends Rss10Action {
# override parent to add X-SUP-ID URL # override parent to add X-SUP-ID URL
function init_rss($limit=0) { function init_rss($limit=0)
{
$url = common_local_url('sup', null, $this->user->id); $url = common_local_url('sup', null, $this->user->id);
header('X-SUP-ID: '.$url); header('X-SUP-ID: '.$url);
parent::init_rss($limit); parent::init_rss($limit);

View File

@ -23,11 +23,13 @@ require_once(INSTALLDIR.'/lib/omb.php');
class XrdsAction extends Action { class XrdsAction extends Action {
function is_readonly() { function is_readonly()
{
return true; return true;
} }
function handle($args) { function handle($args)
{
parent::handle($args); parent::handle($args);
$nickname = $this->trimmed('nickname'); $nickname = $this->trimmed('nickname');
$user = User::staticGet('nickname', $nickname); $user = User::staticGet('nickname', $nickname);
@ -38,7 +40,8 @@ class XrdsAction extends Action {
$this->show_xrds($user); $this->show_xrds($user);
} }
function show_xrds($user) { function show_xrds($user)
{
header('Content-Type: application/xrds+xml'); header('Content-Type: application/xrds+xml');
@ -108,7 +111,8 @@ class XrdsAction extends Action {
common_end_xml(); common_end_xml();
} }
function show_service($type, $uri, $params=null, $sigs=null, $localId=null) { function show_service($type, $uri, $params=null, $sigs=null, $localId=null)
{
common_element_start('Service'); common_element_start('Service');
if ($uri) { if ($uri) {
common_element('URI', null, $uri); common_element('URI', null, $uri);

View File

@ -21,14 +21,16 @@ class Avatar extends Memcached_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Avatar',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Avatar',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
# We clean up the file, too # We clean up the file, too
function delete() { function delete()
{
$filename = $this->filename; $filename = $this->filename;
if (parent::delete()) { if (parent::delete()) {
@unlink(common_avatar_path($filename)); @unlink(common_avatar_path($filename));
@ -38,7 +40,8 @@ class Avatar extends Memcached_DataObject
# Create and save scaled version of this avatar # Create and save scaled version of this avatar
# XXX: maybe break into different methods # XXX: maybe break into different methods
function scale($size) { function scale($size)
{
$image_s = imagecreatetruecolor($size, $size); $image_s = imagecreatetruecolor($size, $size);
$image_a = $this->to_image(); $image_a = $this->to_image();
@ -76,7 +79,8 @@ class Avatar extends Memcached_DataObject
} }
} }
function to_image() { function to_image()
{
$filepath = common_avatar_path($this->filename); $filepath = common_avatar_path($this->filename);
if ($this->mediatype == 'image/gif') { if ($this->mediatype == 'image/gif') {
return imagecreatefromgif($filepath); return imagecreatefromgif($filepath);
@ -89,7 +93,8 @@ class Avatar extends Memcached_DataObject
} }
} }
function &pkeyGet($kv) { function &pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Avatar', $kv); return Memcached_DataObject::pkeyGet('Avatar', $kv);
} }
} }

View File

@ -21,23 +21,28 @@ if (!defined('LACONICA')) { exit(1); }
class Channel { class Channel {
function on($user) { function on($user)
{
return false; return false;
} }
function off($user) { function off($user)
{
return false; return false;
} }
function output($user, $text) { function output($user, $text)
{
return false; return false;
} }
function error($user, $text) { function error($user, $text)
{
return false; return false;
} }
function source() { function source()
{
return null; return null;
} }
} }
@ -46,33 +51,40 @@ class XMPPChannel extends Channel {
var $conn = null; var $conn = null;
function source() { function source()
{
return 'xmpp'; return 'xmpp';
} }
function __construct($conn) { function __construct($conn)
{
$this->conn = $conn; $this->conn = $conn;
} }
function on($user) { function on($user)
{
return $this->set_notify($user, 1); return $this->set_notify($user, 1);
} }
function off($user) { function off($user)
{
return $this->set_notify($user, 0); return $this->set_notify($user, 0);
} }
function output($user, $text) { function output($user, $text)
{
$text = '['.common_config('site', 'name') . '] ' . $text; $text = '['.common_config('site', 'name') . '] ' . $text;
jabber_send_message($user->jabber, $text); jabber_send_message($user->jabber, $text);
} }
function error($user, $text) { function error($user, $text)
{
$text = '['.common_config('site', 'name') . '] ' . $text; $text = '['.common_config('site', 'name') . '] ' . $text;
jabber_send_message($user->jabber, $text); jabber_send_message($user->jabber, $text);
} }
function set_notify(&$user, $notify) { function set_notify(&$user, $notify)
{
$orig = clone($user); $orig = clone($user);
$user->jabbernotify = $notify; $user->jabbernotify = $notify;
$result = $user->update($orig); $result = $user->update($orig);
@ -94,19 +106,23 @@ class XMPPChannel extends Channel {
class WebChannel extends Channel { class WebChannel extends Channel {
function source() { function source()
{
return 'web'; return 'web';
} }
function on($user) { function on($user)
{
return false; return false;
} }
function off($user) { function off($user)
{
return false; return false;
} }
function output($user, $text) { function output($user, $text)
{
# XXX: buffer all output and send it at the end # XXX: buffer all output and send it at the end
# XXX: even better, redirect to appropriate page # XXX: even better, redirect to appropriate page
# depending on what command was run # depending on what command was run
@ -115,7 +131,8 @@ class WebChannel extends Channel {
common_show_footer(); common_show_footer();
} }
function error($user, $text) { function error($user, $text)
{
common_user_error($text); common_user_error($text);
} }
} }
@ -123,7 +140,8 @@ class WebChannel extends Channel {
class AjaxWebChannel extends WebChannel { class AjaxWebChannel extends WebChannel {
function output($user, $text) { function output($user, $text)
{
common_start_html('text/xml;charset=utf-8', true); common_start_html('text/xml;charset=utf-8', true);
common_element_start('head'); common_element_start('head');
common_element('title', null, _('Command results')); common_element('title', null, _('Command results'));
@ -134,7 +152,8 @@ class AjaxWebChannel extends WebChannel {
common_element_end('html'); common_element_end('html');
} }
function error($user, $text) { function error($user, $text)
{
common_start_html('text/xml;charset=utf-8', true); common_start_html('text/xml;charset=utf-8', true);
common_element_start('head'); common_element_start('head');
common_element('title', null, _('Ajax Error')); common_element('title', null, _('Ajax Error'));
@ -151,23 +170,28 @@ class MailChannel extends Channel {
var $addr = null; var $addr = null;
function source() { function source()
{
return 'mail'; return 'mail';
} }
function __construct($addr=null) { function __construct($addr=null)
{
$this->addr = $addr; $this->addr = $addr;
} }
function on($user) { function on($user)
{
return $this->set_notify($user, 1); return $this->set_notify($user, 1);
} }
function off($user) { function off($user)
{
return $this->set_notify($user, 0); return $this->set_notify($user, 0);
} }
function output($user, $text) { function output($user, $text)
{
$headers['From'] = $user->incomingemail; $headers['From'] = $user->incomingemail;
$headers['To'] = $this->addr; $headers['To'] = $this->addr;
@ -177,7 +201,8 @@ class MailChannel extends Channel {
return mail_send(array($this->addr), $headers, $text); return mail_send(array($this->addr), $headers, $text);
} }
function error($user, $text) { function error($user, $text)
{
$headers['From'] = $user->incomingemail; $headers['From'] = $user->incomingemail;
$headers['To'] = $this->addr; $headers['To'] = $this->addr;
@ -187,7 +212,8 @@ class MailChannel extends Channel {
return mail_send(array($this->addr), $headers, $text); return mail_send(array($this->addr), $headers, $text);
} }
function set_notify($user, $value) { function set_notify($user, $value)
{
$orig = clone($user); $orig = clone($user);
$user->smsnotify = $value; $user->smsnotify = $value;
$result = $user->update($orig); $result = $user->update($orig);

View File

@ -25,17 +25,20 @@ class Command {
var $user = null; var $user = null;
function __construct($user=null) { function __construct($user=null)
{
$this->user = $user; $this->user = $user;
} }
function execute($channel) { function execute($channel)
{
return false; return false;
} }
} }
class UnimplementedCommand extends Command { class UnimplementedCommand extends Command {
function execute($channel) { function execute($channel)
{
$channel->error($this->user, _("Sorry, this command is not yet implemented.")); $channel->error($this->user, _("Sorry, this command is not yet implemented."));
} }
} }
@ -48,7 +51,8 @@ class TrackOffCommand extends UnimplementedCommand {
class TrackCommand extends UnimplementedCommand { class TrackCommand extends UnimplementedCommand {
var $word = null; var $word = null;
function __construct($user, $word) { function __construct($user, $word)
{
parent::__construct($user); parent::__construct($user);
$this->word = $word; $this->word = $word;
} }
@ -56,7 +60,8 @@ class TrackCommand extends UnimplementedCommand {
class UntrackCommand extends UnimplementedCommand { class UntrackCommand extends UnimplementedCommand {
var $word = null; var $word = null;
function __construct($user, $word) { function __construct($user, $word)
{
parent::__construct($user); parent::__construct($user);
$this->word = $word; $this->word = $word;
} }
@ -64,7 +69,8 @@ class UntrackCommand extends UnimplementedCommand {
class NudgeCommand extends UnimplementedCommand { class NudgeCommand extends UnimplementedCommand {
var $other = null; var $other = null;
function __construct($user, $other) { function __construct($user, $other)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
@ -72,14 +78,16 @@ class NudgeCommand extends UnimplementedCommand {
class InviteCommand extends UnimplementedCommand { class InviteCommand extends UnimplementedCommand {
var $other = null; var $other = null;
function __construct($user, $other) { function __construct($user, $other)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
} }
class StatsCommand extends Command { class StatsCommand extends Command {
function execute($channel) { function execute($channel)
{
$subs = new Subscription(); $subs = new Subscription();
$subs->subscriber = $this->user->id; $subs->subscriber = $this->user->id;
@ -106,12 +114,14 @@ class FavCommand extends Command {
var $other = null; var $other = null;
function __construct($user, $other) { function __construct($user, $other)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
function execute($channel) { function execute($channel)
{
$recipient = $recipient =
common_relative_profile($this->user, common_canonical_nickname($this->other)); common_relative_profile($this->user, common_canonical_nickname($this->other));
@ -149,12 +159,14 @@ class FavCommand extends Command {
class WhoisCommand extends Command { class WhoisCommand extends Command {
var $other = null; var $other = null;
function __construct($user, $other) { function __construct($user, $other)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
function execute($channel) { function execute($channel)
{
$recipient = $recipient =
common_relative_profile($this->user, common_canonical_nickname($this->other)); common_relative_profile($this->user, common_canonical_nickname($this->other));
@ -184,13 +196,15 @@ class WhoisCommand extends Command {
class MessageCommand extends Command { class MessageCommand extends Command {
var $other = null; var $other = null;
var $text = null; var $text = null;
function __construct($user, $other, $text) { function __construct($user, $other, $text)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
$this->text = $text; $this->text = $text;
} }
function execute($channel) { function execute($channel)
{
$other = User::staticGet('nickname', common_canonical_nickname($this->other)); $other = User::staticGet('nickname', common_canonical_nickname($this->other));
$len = mb_strlen($this->text); $len = mb_strlen($this->text);
if ($len == 0) { if ($len == 0) {
@ -227,12 +241,14 @@ class GetCommand extends Command {
var $other = null; var $other = null;
function __construct($user, $other) { function __construct($user, $other)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
function execute($channel) { function execute($channel)
{
$target_nickname = common_canonical_nickname($this->other); $target_nickname = common_canonical_nickname($this->other);
$target = $target =
@ -257,12 +273,14 @@ class SubCommand extends Command {
var $other = null; var $other = null;
function __construct($user, $other) { function __construct($user, $other)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
function execute($channel) { function execute($channel)
{
if (!$this->other) { if (!$this->other) {
$channel->error($this->user, _('Specify the name of the user to subscribe to')); $channel->error($this->user, _('Specify the name of the user to subscribe to'));
@ -283,12 +301,14 @@ class UnsubCommand extends Command {
var $other = null; var $other = null;
function __construct($user, $other) { function __construct($user, $other)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
function execute($channel) { function execute($channel)
{
if(!$this->other) { if(!$this->other) {
$channel->error($this->user, _('Specify the name of the user to unsubscribe from')); $channel->error($this->user, _('Specify the name of the user to unsubscribe from'));
return; return;
@ -306,11 +326,13 @@ class UnsubCommand extends Command {
class OffCommand extends Command { class OffCommand extends Command {
var $other = null; var $other = null;
function __construct($user, $other=null) { function __construct($user, $other=null)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
function execute($channel) { function execute($channel)
{
if ($other) { if ($other) {
$channel->error($this->user, _("Command not yet implemented.")); $channel->error($this->user, _("Command not yet implemented."));
} else { } else {
@ -325,12 +347,14 @@ class OffCommand extends Command {
class OnCommand extends Command { class OnCommand extends Command {
var $other = null; var $other = null;
function __construct($user, $other=null) { function __construct($user, $other=null)
{
parent::__construct($user); parent::__construct($user);
$this->other = $other; $this->other = $other;
} }
function execute($channel) { function execute($channel)
{
if ($other) { if ($other) {
$channel->error($this->user, _("Command not yet implemented.")); $channel->error($this->user, _("Command not yet implemented."));
} else { } else {
@ -344,7 +368,8 @@ class OnCommand extends Command {
} }
class HelpCommand extends Command { class HelpCommand extends Command {
function execute($channel) { function execute($channel)
{
$channel->output($this->user, $channel->output($this->user,
_("Commands:\n". _("Commands:\n".
"on - turn on notifications\n". "on - turn on notifications\n".

View File

@ -23,7 +23,8 @@ require_once(INSTALLDIR.'/classes/Command.php');
class CommandInterpreter { class CommandInterpreter {
function handle_command($user, $text) { function handle_command($user, $text)
{
# XXX: localise # XXX: localise
$text = preg_replace('/\s+/', ' ', trim($text)); $text = preg_replace('/\s+/', ' ', trim($text));

View File

@ -20,10 +20,12 @@ class Confirm_address extends Memcached_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Confirm_address',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Confirm_address',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
function sequenceKey() { return array(false, false); } function sequenceKey()
{ return array(false, false); }
} }

View File

@ -16,7 +16,8 @@ class Consumer extends Memcached_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Consumer',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Consumer',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE

View File

@ -15,7 +15,8 @@ class Fave extends Memcached_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Fave',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Fave',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
@ -31,7 +32,8 @@ class Fave extends Memcached_DataObject
return $fave; return $fave;
} }
function &pkeyGet($kv) { function &pkeyGet($kv)
{
return Memcached_DataObject::pkeyGet('Fave', $kv); return Memcached_DataObject::pkeyGet('Fave', $kv);
} }
} }

View File

@ -21,7 +21,8 @@ class Foreign_link extends Memcached_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Foreign_link',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Foreign_link',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
@ -55,7 +56,8 @@ class Foreign_link extends Memcached_DataObject
} }
# Convenience methods # Convenience methods
function getForeignUser() { function getForeignUser()
{
$fuser = new Foreign_user(); $fuser = new Foreign_user();
$fuser->service = $this->service; $fuser->service = $this->service;
$fuser->id = $this->foreign_id; $fuser->id = $this->foreign_id;
@ -69,7 +71,8 @@ class Foreign_link extends Memcached_DataObject
return null; return null;
} }
function getUser() { function getUser()
{
return User::staticGet($this->user_id); return User::staticGet($this->user_id);
} }

View File

@ -17,7 +17,8 @@ class Foreign_service extends Memcached_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Foreign_service',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Foreign_service',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE

View File

@ -16,7 +16,8 @@ class Foreign_subscription extends Memcached_DataObject
public $created; // datetime() not_null public $created; // datetime() not_null
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Foreign_subscription',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Foreign_subscription',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE

View File

@ -18,7 +18,8 @@ class Foreign_user extends Memcached_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Foreign_user',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Foreign_user',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
@ -39,7 +40,8 @@ class Foreign_user extends Memcached_DataObject
return null; return null;
} }
function updateKeys(&$orig) { function updateKeys(&$orig)
{
$parts = array(); $parts = array();
foreach (array('id', 'service', 'uri', 'nickname') as $k) { foreach (array('id', 'service', 'uri', 'nickname') as $k) {
if (strcmp($this->$k, $orig->$k) != 0) { if (strcmp($this->$k, $orig->$k) != 0) {

View File

@ -17,7 +17,8 @@ class Invitation extends Memcached_DataObject
public $created; // datetime() not_null public $created; // datetime() not_null
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Invitation',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Invitation',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE

View File

@ -23,7 +23,8 @@ require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
class Memcached_DataObject extends DB_DataObject class Memcached_DataObject extends DB_DataObject
{ {
function &staticGet($cls, $k, $v=null) { function &staticGet($cls, $k, $v=null)
{
if (is_null($v)) { if (is_null($v)) {
$v = $k; $v = $k;
# XXX: HACK! # XXX: HACK!
@ -44,7 +45,8 @@ class Memcached_DataObject extends DB_DataObject
} }
} }
function &pkeyGet($cls, $kv) { function &pkeyGet($cls, $kv)
{
$i = Memcached_DataObject::multicache($cls, $kv); $i = Memcached_DataObject::multicache($cls, $kv);
if ($i) { if ($i) {
return $i; return $i;
@ -62,12 +64,14 @@ class Memcached_DataObject extends DB_DataObject
} }
} }
function insert() { function insert()
{
$result = parent::insert(); $result = parent::insert();
return $result; return $result;
} }
function update($orig=null) { function update($orig=null)
{
if (is_object($orig) && $orig instanceof Memcached_DataObject) { if (is_object($orig) && $orig instanceof Memcached_DataObject) {
$orig->decache(); # might be different keys $orig->decache(); # might be different keys
} }
@ -78,7 +82,8 @@ class Memcached_DataObject extends DB_DataObject
return $result; return $result;
} }
function delete() { function delete()
{
$this->decache(); # while we still have the values! $this->decache(); # while we still have the values!
return parent::delete(); return parent::delete();
} }
@ -100,7 +105,8 @@ class Memcached_DataObject extends DB_DataObject
} }
} }
function keyTypes() { function keyTypes()
{
global $_DB_DATAOBJECT; global $_DB_DATAOBJECT;
if (!isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"])) { if (!isset($_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"])) {
$this->databaseStructure(); $this->databaseStructure();
@ -109,7 +115,8 @@ class Memcached_DataObject extends DB_DataObject
return $_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"]; return $_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"];
} }
function encache() { function encache()
{
$c = $this->memcache(); $c = $this->memcache();
if (!$c) { if (!$c) {
return false; return false;
@ -133,7 +140,8 @@ class Memcached_DataObject extends DB_DataObject
} }
} }
function decache() { function decache()
{
$c = $this->memcache(); $c = $this->memcache();
if (!$c) { if (!$c) {
return false; return false;
@ -158,7 +166,8 @@ class Memcached_DataObject extends DB_DataObject
} }
} }
function multicache($cls, $kv) { function multicache($cls, $kv)
{
ksort($kv); ksort($kv);
$c = Memcached_DataObject::memcache(); $c = Memcached_DataObject::memcache();
if (!$c) { if (!$c) {
@ -170,7 +179,8 @@ class Memcached_DataObject extends DB_DataObject
} }
} }
function getSearchEngine($table) { function getSearchEngine($table)
{
require_once INSTALLDIR.'/lib/search_engines.php'; require_once INSTALLDIR.'/lib/search_engines.php';
static $search_engine; static $search_engine;
if (!isset($search_engine)) { if (!isset($search_engine)) {

View File

@ -22,16 +22,19 @@ class Message extends Memcached_DataObject
public $source; // varchar(32) public $source; // varchar(32)
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Message',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Message',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
function getFrom() { function getFrom()
{
return Profile::staticGet('id', $this->from_profile); return Profile::staticGet('id', $this->from_profile);
} }
function getTo() { function getTo()
{
return Profile::staticGet('id', $this->to_profile); return Profile::staticGet('id', $this->to_profile);
} }

View File

@ -18,7 +18,8 @@ class Nonce extends Memcached_DataObject
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Nonce',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Nonce',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE

View File

@ -48,23 +48,27 @@ class Notice extends Memcached_DataObject
public $source; // varchar(32) public $source; // varchar(32)
/* Static get */ /* Static get */
function staticGet($k,$v=null) { return Memcached_DataObject::staticGet('Notice',$k,$v); } function staticGet($k,$v=null)
{ return Memcached_DataObject::staticGet('Notice',$k,$v); }
/* the code above is auto generated do not remove the tag below */ /* the code above is auto generated do not remove the tag below */
###END_AUTOCODE ###END_AUTOCODE
function getProfile() { function getProfile()
{
return Profile::staticGet('id', $this->profile_id); return Profile::staticGet('id', $this->profile_id);
} }
function delete() { function delete()
{
$this->blowCaches(true); $this->blowCaches(true);
$this->blowFavesCache(true); $this->blowFavesCache(true);
$this->blowInboxes(); $this->blowInboxes();
return parent::delete(); return parent::delete();
} }
function saveTags() { function saveTags()
{
/* extract all #hastags */ /* extract all #hastags */
$count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($this->content), $match); $count = preg_match_all('/(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/', strtolower($this->content), $match);
if (!$count) { if (!$count) {
@ -184,7 +188,8 @@ class Notice extends Memcached_DataObject
return true; return true;
} }
function blowCaches($blowLast=false) { function blowCaches($blowLast=false)
{
$this->blowSubsCache($blowLast); $this->blowSubsCache($blowLast);
$this->blowNoticeCache($blowLast); $this->blowNoticeCache($blowLast);
$this->blowRepliesCache($blowLast); $this->blowRepliesCache($blowLast);
@ -192,7 +197,8 @@ class Notice extends Memcached_DataObject
$this->blowTagCache($blowLast); $this->blowTagCache($blowLast);
} }
function blowTagCache($blowLast=false) { function blowTagCache($blowLast=false)
{
$cache = common_memcache(); $cache = common_memcache();
if ($cache) { if ($cache) {
$tag = new Notice_tag(); $tag = new Notice_tag();
@ -210,7 +216,8 @@ class Notice extends Memcached_DataObject
} }
} }
function blowSubsCache($blowLast=false) { function blowSubsCache($blowLast=false)
{
$cache = common_memcache(); $cache = common_memcache();
if ($cache) { if ($cache) {
$user = new User(); $user = new User();
@ -230,7 +237,8 @@ class Notice extends Memcached_DataObject
} }
} }
function blowNoticeCache($blowLast=false) { function blowNoticeCache($blowLast=false)
{
if ($this->is_local) { if ($this->is_local) {
$cache = common_memcache(); $cache = common_memcache();
if ($cache) { if ($cache) {
@ -242,7 +250,8 @@ class Notice extends Memcached_DataObject
} }
} }
function blowRepliesCache($blowLast=false) { function blowRepliesCache($blowLast=false)
{
$cache = common_memcache(); $cache = common_memcache();
if ($cache) { if ($cache) {
$reply = new Reply(); $reply = new Reply();
@ -260,7 +269,8 @@ class Notice extends Memcached_DataObject
} }
} }
function blowPublicCache($blowLast=false) { function blowPublicCache($blowLast=false)
{
if ($this->is_local == 1) { if ($this->is_local == 1) {
$cache = common_memcache(); $cache = common_memcache();
if ($cache) { if ($cache) {
@ -272,7 +282,8 @@ class Notice extends Memcached_DataObject
} }
} }
function blowFavesCache($blowLast=false) { function blowFavesCache($blowLast=false)
{
$cache = common_memcache(); $cache = common_memcache();
if ($cache) { if ($cache) {
$fave = new Fave(); $fave = new Fave();
@ -477,7 +488,8 @@ class Notice extends Memcached_DataObject
return $wrapper; return $wrapper;
} }
function publicStream($offset=0, $limit=20, $since_id=0, $before_id=0, $since=null) { function publicStream($offset=0, $limit=20, $since_id=0, $before_id=0, $since=null)
{
$parts = array(); $parts = array();
@ -499,7 +511,8 @@ class Notice extends Memcached_DataObject
$offset, $limit, $since_id, $before_id, null, $since); $offset, $limit, $since_id, $before_id, null, $since);
} }
function addToInboxes() { function addToInboxes()
{
$enabled = common_config('inboxes', 'enabled'); $enabled = common_config('inboxes', 'enabled');
if ($enabled === true || $enabled === 'transitional') { if ($enabled === true || $enabled === 'transitional') {
@ -522,7 +535,8 @@ class Notice extends Memcached_DataObject
# Delete from inboxes if we're deleted. # Delete from inboxes if we're deleted.
function blowInboxes() { function blowInboxes()
{
$enabled = common_config('inboxes', 'enabled'); $enabled = common_config('inboxes', 'enabled');

Some files were not shown because too many files have changed in this diff Show More