summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorRobin Millette <millette@plantard.controlezvous.ca>2009-01-23 01:01:01 +0000
committerRobin Millette <millette@plantard.controlezvous.ca>2009-01-23 01:01:01 +0000
commit8a65c5175c3b734d4c53d6a3c3af51c5a645dff2 (patch)
tree6e85645d2e51d517f88413c119ddc4eed26f633b /actions
parent4a4efc3b0a453a0e345f4ec5bd8e970130589ae6 (diff)
parent1132e66f84c188f8267165d99d95d04047b6b23b (diff)
Merge branch 'master' of /var/www/trunk
Diffstat (limited to 'actions')
-rw-r--r--actions/finishopenidlogin.php123
-rw-r--r--actions/foaf.php90
-rw-r--r--actions/invite.php107
-rw-r--r--actions/openidlogin.php48
-rw-r--r--actions/public.php2
-rw-r--r--actions/recoverpassword.php133
-rw-r--r--actions/remotesubscribe.php121
-rw-r--r--actions/showgroup.php6
-rw-r--r--actions/subscribers.php6
-rw-r--r--actions/subscriptions.php6
-rw-r--r--actions/sup.php34
-rw-r--r--actions/tagother.php122
-rw-r--r--actions/userauthorization.php151
-rw-r--r--actions/xrds.php14
14 files changed, 536 insertions, 427 deletions
diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php
index bc33ac330..880a9505b 100644
--- a/actions/finishopenidlogin.php
+++ b/actions/finishopenidlogin.php
@@ -23,6 +23,9 @@ require_once(INSTALLDIR.'/lib/openid.php');
class FinishopenidloginAction extends Action
{
+ var $error = null;
+ var $username = null;
+ var $message = null;
function handle($args)
{
@@ -32,32 +35,32 @@ class FinishopenidloginAction extends Action
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->show_form(_('There was a problem with your session token. Try again, please.'));
+ $this->showForm(_('There was a problem with your session token. Try again, please.'));
return;
}
if ($this->arg('create')) {
if (!$this->boolean('license')) {
- $this->show_form(_('You can\'t register if you don\'t agree to the license.'),
- $this->trimmed('newname'));
+ $this->showForm(_('You can\'t register if you don\'t agree to the license.'),
+ $this->trimmed('newname'));
return;
}
- $this->create_new_user();
+ $this->createNewUser();
} else if ($this->arg('connect')) {
- $this->connect_user();
+ $this->connectUser();
} else {
common_debug(print_r($this->args, true), __FILE__);
- $this->show_form(_('Something weird happened.'),
- $this->trimmed('newname'));
+ $this->showForm(_('Something weird happened.'),
+ $this->trimmed('newname'));
}
} else {
- $this->try_login();
+ $this->tryLogin();
}
}
- function show_top($error=null)
+ function showPageNotice()
{
- if ($error) {
- $this->element('div', array('class' => 'error'), $error);
+ if ($this->error) {
+ $this->element('div', array('class' => 'error'), $this->error);
} else {
global $config;
$this->element('div', 'instructions',
@@ -65,21 +68,36 @@ class FinishopenidloginAction extends Action
}
}
- function show_form($error=null, $username=null)
+ function title()
{
- common_show_header(_('OpenID Account Setup'), null, $error,
- array($this, 'show_top'));
+ return _('OpenID Account Setup');
+ }
+
+ function showForm($error=null, $username=null)
+ {
+ $this->error = $error;
+ $this->username = $username;
+
+ $this->showPage();
+ }
+
+ function showContent()
+ {
+ if ($this->message_text) {
+ $this->element('p', null, $this->message);
+ return;
+ }
$this->elementStart('form', array('method' => 'post',
- 'id' => 'account_connect',
- 'action' => common_local_url('finishopenidlogin')));
+ 'id' => 'account_connect',
+ 'action' => common_local_url('finishopenidlogin')));
$this->hidden('token', common_session_token());
$this->element('h2', null,
_('Create new account'));
$this->element('p', null,
_('Create a new user with this nickname.'));
$this->input('newname', _('New nickname'),
- ($username) ? $username : '',
+ ($this->username) ? $this->username : '',
_('1-64 lowercase letters or numbers, no punctuation or spaces'));
$this->elementStart('p');
$this->element('input', array('type' => 'checkbox',
@@ -87,7 +105,7 @@ class FinishopenidloginAction extends Action
'name' => 'license',
'value' => 'true'));
$this->text(_('My text and files are available under '));
- $this->element('a', array(href => common_config('license', 'url')),
+ $this->element('a', array('href' => common_config('license', 'url')),
common_config('license', 'title'));
$this->text(_(' except this private data: password, email address, IM address, phone number.'));
$this->elementEnd('p');
@@ -100,12 +118,10 @@ class FinishopenidloginAction extends Action
$this->password('password', _('Password'));
$this->submit('connect', _('Connect'));
$this->elementEnd('form');
- common_show_footer();
}
- function try_login()
+ function tryLogin()
{
-
$consumer = oid_consumer();
$response = $consumer->complete(common_local_url('finishopenidlogin'));
@@ -143,22 +159,21 @@ class FinishopenidloginAction extends Action
common_rememberme($user);
}
unset($_SESSION['openid_rememberme']);
- $this->go_home($user->nickname);
+ $this->goHome($user->nickname);
} else {
- $this->save_values($display, $canonical, $sreg);
- $this->show_form(null, $this->best_new_nickname($display, $sreg));
+ $this->saveValues($display, $canonical, $sreg);
+ $this->showForm(null, $this->bestNewNickname($display, $sreg));
}
}
}
function message($msg)
{
- common_show_header(_('OpenID Login'));
- $this->element('p', null, $msg);
- common_show_footer();
+ $this->message_text = $msg;
+ $this->showPage();
}
- function save_values($display, $canonical, $sreg)
+ function saveValues($display, $canonical, $sreg)
{
common_ensure_session();
$_SESSION['openid_display'] = $display;
@@ -166,16 +181,15 @@ class FinishopenidloginAction extends Action
$_SESSION['openid_sreg'] = $sreg;
}
- function get_saved_values()
+ function getSavedValues()
{
return array($_SESSION['openid_display'],
$_SESSION['openid_canonical'],
$_SESSION['openid_sreg']);
}
- function create_new_user()
+ function createNewUser()
{
-
# FIXME: save invite code before redirect, and check here
if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
@@ -188,21 +202,21 @@ class FinishopenidloginAction extends Action
if (!Validate::string($nickname, array('min_length' => 1,
'max_length' => 64,
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
- $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.'));
+ $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
return;
}
if (!User::allowed_nickname($nickname)) {
- $this->show_form(_('Nickname not allowed.'));
+ $this->showForm(_('Nickname not allowed.'));
return;
}
if (User::staticGet('nickname', $nickname)) {
- $this->show_form(_('Nickname already in use. Try another one.'));
+ $this->showForm(_('Nickname already in use. Try another one.'));
return;
}
- list($display, $canonical, $sreg) = $this->get_saved_values();
+ list($display, $canonical, $sreg) = $this->getSavedValues();
if (!$display || !$canonical) {
$this->serverError(_('Stored OpenID not found.'));
@@ -256,14 +270,13 @@ class FinishopenidloginAction extends Action
common_redirect(common_local_url('showstream', array('nickname' => $user->nickname)));
}
- function connect_user()
+ function connectUser()
{
-
$nickname = $this->trimmed('nickname');
$password = $this->trimmed('password');
if (!common_check_user($nickname, $password)) {
- $this->show_form(_('Invalid username or password.'));
+ $this->showForm(_('Invalid username or password.'));
return;
}
@@ -271,7 +284,7 @@ class FinishopenidloginAction extends Action
$user = User::staticGet('nickname', $nickname);
- list($display, $canonical, $sreg) = $this->get_saved_values();
+ list($display, $canonical, $sreg) = $this->getSavedValues();
if (!$display || !$canonical) {
$this->serverError(_('Stored OpenID not found.'));
@@ -293,10 +306,10 @@ class FinishopenidloginAction extends Action
common_rememberme($user);
}
unset($_SESSION['openid_rememberme']);
- $this->go_home($user->nickname);
+ $this->goHome($user->nickname);
}
- function go_home($nickname)
+ function goHome($nickname)
{
$url = common_get_returnto();
if ($url) {
@@ -310,14 +323,14 @@ class FinishopenidloginAction extends Action
common_redirect($url);
}
- function best_new_nickname($display, $sreg)
+ function bestNewNickname($display, $sreg)
{
# Try the passed-in nickname
if ($sreg['nickname']) {
$nickname = $this->nicknamize($sreg['nickname']);
- if ($this->is_new_nickname($nickname)) {
+ if ($this->isNewNickname($nickname)) {
return $nickname;
}
}
@@ -326,16 +339,16 @@ class FinishopenidloginAction extends Action
if ($sreg['fullname']) {
$fullname = $this->nicknamize($sreg['fullname']);
- if ($this->is_new_nickname($fullname)) {
+ if ($this->isNewNickname($fullname)) {
return $fullname;
}
}
# Try the URL
- $from_url = $this->openid_to_nickname($display);
+ $from_url = $this->openidToNickname($display);
- if ($from_url && $this->is_new_nickname($from_url)) {
+ if ($from_url && $this->isNewNickname($from_url)) {
return $from_url;
}
@@ -344,14 +357,14 @@ class FinishopenidloginAction extends Action
return null;
}
- function is_new_nickname($str)
+ function isNewNickname($str)
{
if (!Validate::string($str, array('min_length' => 1,
'max_length' => 64,
'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
return false;
}
- if (!User::allowed_nickname($str)) {
+ if (!User::allowed_nickname($str)) {
return false;
}
if (User::staticGet('nickname', $str)) {
@@ -360,12 +373,12 @@ class FinishopenidloginAction extends Action
return true;
}
- function openid_to_nickname($openid)
+ function openidToNickname($openid)
{
if (Auth_Yadis_identifierScheme($openid) == 'XRI') {
- return $this->xri_to_nickname($openid);
+ return $this->xriToNickname($openid);
} else {
- return $this->url_to_nickname($openid);
+ return $this->urlToNickname($openid);
}
}
@@ -374,7 +387,7 @@ class FinishopenidloginAction extends Action
# 2. One element in path, like http://profile.typekey.com/EvanProdromou/
# or http://getopenid.com/evanprodromou
- function url_to_nickname($openid)
+ function urlToNickname($openid)
{
static $bad = array('query', 'user', 'password', 'port', 'fragment');
@@ -421,9 +434,9 @@ class FinishopenidloginAction extends Action
return null;
}
- function xri_to_nickname($xri)
+ function xriToNickname($xri)
{
- $base = $this->xri_base($xri);
+ $base = $this->xriBase($xri);
if (!$base) {
return null;
@@ -435,7 +448,7 @@ class FinishopenidloginAction extends Action
}
}
- function xri_base($xri)
+ function xriBase($xri)
{
if (substr($xri, 0, 6) == 'xri://') {
return substr($xri, 6);
diff --git a/actions/foaf.php b/actions/foaf.php
index 9fa321d4a..3a99835b4 100644
--- a/actions/foaf.php
+++ b/actions/foaf.php
@@ -25,35 +25,40 @@ define('BOTH', 0);
class FoafAction extends Action
{
-
function isReadOnly()
{
return true;
}
- function handle($args)
+ function prepare($args)
{
- parent::handle($args);
+ parent::prepare($args);
+ $this->nickname = $this->trimmed('nickname');
- $nickname = $this->trimmed('nickname');
+ $this->user = User::staticGet('nickname', $this->nickname);
- $user = User::staticGet('nickname', $nickname);
-
- if (!$user) {
+ if (!$this->user) {
$this->clientError(_('No such user.'), 404);
- return;
+ return false;
}
- $profile = $user->getProfile();
+ $this->profile = $this->user->getProfile();
- if (!$profile) {
+ if (!$this->profile) {
$this->serverError(_('User has no profile.'), 500);
- return;
+ return false;
}
+ return true;
+ }
+
+ function handle($args)
+ {
+ parent::handle($args);
+
header('Content-Type: application/rdf+xml');
- common_start_xml();
+ $this->startXML();
$this->elementStart('rdf:RDF', array('xmlns:rdf' =>
'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'xmlns:rdfs' =>
@@ -62,42 +67,42 @@ class FoafAction extends Action
'http://www.w3.org/2003/01/geo/wgs84_pos#',
'xmlns' => 'http://xmlns.com/foaf/0.1/'));
- # This is the document about the user
+ // This is the document about the user
- $this->show_ppd('', $user->uri);
+ $this->showPpd('', $this->user->uri);
- # XXX: might not be a person
+ // XXX: might not be a person
$this->elementStart('Person', array('rdf:about' =>
- $user->uri));
- $this->element('mbox_sha1sum', null, sha1('mailto:' . $user->email));
- if ($profile->fullname) {
- $this->element('name', null, $profile->fullname);
+ $this->user->uri));
+ $this->element('mbox_sha1sum', null, sha1('mailto:' . $this->user->email));
+ if ($this->profile->fullname) {
+ $this->element('name', null, $this->profile->fullname);
}
- if ($profile->homepage) {
- $this->element('homepage', array('rdf:resource' => $profile->homepage));
+ if ($this->profile->homepage) {
+ $this->element('homepage', array('rdf:resource' => $this->profile->homepage));
}
- if ($profile->bio) {
- $this->element('rdfs:comment', null, $profile->bio);
+ if ($this->profile->bio) {
+ $this->element('rdfs:comment', null, $this->profile->bio);
}
- # XXX: more structured location data
- if ($profile->location) {
+ // XXX: more structured location data
+ if ($this->profile->location) {
$this->elementStart('based_near');
$this->elementStart('geo:SpatialThing');
- $this->element('name', null, $profile->location);
+ $this->element('name', null, $this->profile->location);
$this->elementEnd('geo:SpatialThing');
$this->elementEnd('based_near');
}
- $this->show_microblogging_account($profile, common_root_url());
+ $this->showMicrobloggingAccount($this->profile, common_root_url());
- $avatar = $profile->getOriginalAvatar();
+ $avatar = $this->profile->getOriginalAvatar();
if ($avatar) {
$this->elementStart('img');
$this->elementStart('Image', array('rdf:about' => $avatar->url));
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
- $scaled = $profile->getAvatar($size);
- if (!$scaled->original) { # sometimes the original has one of our scaled sizes
+ $scaled = $this->profile->getAvatar($size);
+ if (!$scaled->original) { // sometimes the original has one of our scaled sizes
$this->elementStart('thumbnail');
$this->element('Image', array('rdf:about' => $scaled->url));
$this->elementEnd('thumbnail');
@@ -107,14 +112,14 @@ class FoafAction extends Action
$this->elementEnd('img');
}
- # Get people user is subscribed to
+ // Get people user is subscribed to
$person = array();
$sub = new Subscription();
- $sub->subscriber = $profile->id;
+ $sub->subscriber = $this->profile->id;
$sub->whereAdd('subscriber != subscribed');
-
+
if ($sub->find()) {
while ($sub->fetch()) {
if ($sub->token) {
@@ -131,10 +136,10 @@ class FoafAction extends Action
}
}
- # Get people who subscribe to user
+ // Get people who subscribe to user
$sub = new Subscription();
- $sub->subscribed = $profile->id;
+ $sub->subscribed = $this->profile->id;
$sub->whereAdd('subscriber != subscribed');
if ($sub->find()) {
@@ -163,26 +168,27 @@ class FoafAction extends Action
if ($p[1] instanceof User) {
$foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname));
}
- $profile = Profile::staticGet($p[1]->id);
+ $this->profile = Profile::staticGet($p[1]->id);
$this->elementStart('Person', array('rdf:about' => $uri));
if ($p[0] == LISTENER || $p[0] == BOTH) {
- $this->element('knows', array('rdf:resource' => $user->uri));
+ $this->element('knows', array('rdf:resource' => $this->user->uri));
}
- $this->show_microblogging_account($profile, ($p[1] instanceof User) ?
+ $this->showMicrobloggingAccount($this->profile, ($p[1] instanceof User) ?
common_root_url() : null);
if ($foaf_url) {
$this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url));
}
$this->elementEnd('Person');
if ($foaf_url) {
- $this->show_ppd($foaf_url, $uri);
+ $this->showPpd($foaf_url, $uri);
}
}
$this->elementEnd('rdf:RDF');
+ $this->endXML();
}
- function show_ppd($foaf_url, $person_uri)
+ function showPpd($foaf_url, $person_uri)
{
$this->elementStart('PersonalProfileDocument', array('rdf:about' => $foaf_url));
$this->element('maker', array('rdf:resource' => $person_uri));
@@ -190,9 +196,9 @@ class FoafAction extends Action
$this->elementEnd('PersonalProfileDocument');
}
- function show_microblogging_account($profile, $service=null)
+ function showMicrobloggingAccount($profile, $service=null)
{
- # Their account
+ // Their account
$this->elementStart('holdsAccount');
$this->elementStart('OnlineAccount');
if ($service) {
diff --git a/actions/invite.php b/actions/invite.php
index 95d96bcde..f4ad2f7c5 100644
--- a/actions/invite.php
+++ b/actions/invite.php
@@ -21,6 +21,11 @@ if (!defined('LACONICA')) { exit(1); }
class InviteAction extends Action
{
+ var $mode = null;
+ var $error = null;
+ var $already = null;
+ var $subbed = null;
+ var $sent = null;
function isReadOnly()
{
@@ -35,19 +40,18 @@ class InviteAction extends Action
common_config('site', 'name')));
return;
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $this->send_invitations();
+ $this->sendInvitations();
} else {
- $this->show_form();
+ $this->showForm();
}
}
- function send_invitations()
+ function sendInvitations()
{
-
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->show_form(_('There was a problem with your session token. Try again, please.'));
+ $this->showForm(_('There was a problem with your session token. Try again, please.'));
return;
}
@@ -63,78 +67,105 @@ class InviteAction extends Action
foreach ($addresses as $email) {
$email = trim($email);
if (!Validate::email($email, true)) {
- $this->show_form(sprintf(_('Invalid email address: %s'), $email));
+ $this->showForm(sprintf(_('Invalid email address: %s'), $email));
return;
}
}
- $already = array();
- $subbed = array();
+ $this->already = array();
+ $this->subbed = array();
foreach ($addresses as $email) {
$email = common_canonical_email($email);
$other = User::staticGet('email', $email);
if ($other) {
if ($user->isSubscribed($other)) {
- $already[] = $other;
+ $this->already[] = $other;
} else {
subs_subscribe_to($user, $other);
- $subbed[] = $other;
+ $this->subbed[] = $other;
}
} else {
- $sent[] = $email;
- $this->send_invitation($email, $user, $personal);
+ $this->sent[] = $email;
+ $this->sendInvitation($email, $user, $personal);
}
}
- common_show_header(_('Invitation(s) sent'));
- if ($already) {
+ $this->mode = 'sent';
+
+ $this->showPage();
+ }
+
+ function title()
+ {
+ if ($this->mode == 'sent') {
+ return _('Invitation(s) sent');
+ } else {
+ return _('Invite new users');
+ }
+ }
+
+ function showContent()
+ {
+ if ($this->mode == 'sent') {
+ $this->showInvitationSuccess();
+ } else {
+ $this->showInviteForm();
+ }
+ }
+
+ function showInvitationSuccess()
+ {
+ if ($this->already) {
$this->element('p', null, _('You are already subscribed to these users:'));
$this->elementStart('ul');
- foreach ($already as $other) {
+ foreach ($this->already as $other) {
$this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email));
}
$this->elementEnd('ul');
}
- if ($subbed) {
+ if ($this->subbed) {
$this->element('p', null, _('These people are already users and you were automatically subscribed to them:'));
$this->elementStart('ul');
- foreach ($subbed as $other) {
+ foreach ($this->subbed as $other) {
$this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email));
}
$this->elementEnd('ul');
}
- if ($sent) {
+ if ($this->sent) {
$this->element('p', null, _('Invitation(s) sent to the following people:'));
$this->elementStart('ul');
- foreach ($sent as $other) {
+ foreach ($this->sent as $other) {
$this->element('li', null, $other);
}
$this->elementEnd('ul');
$this->element('p', null, _('You will be notified when your invitees accept the invitation and register on the site. Thanks for growing the community!'));
}
- common_show_footer();
}
- function show_top($error=null)
+ function showPageNotice()
{
- if ($error) {
- $this->element('p', 'error', $error);
- } else {
- $this->elementStart('div', 'instructions');
- $this->element('p', null,
- _('Use this form to invite your friends and colleagues to use this service.'));
- $this->elementEnd('div');
+ if ($this->mode != 'sent') {
+ if ($this->error) {
+ $this->element('p', 'error', $this->error);
+ } else {
+ $this->elementStart('div', 'instructions');
+ $this->element('p', null,
+ _('Use this form to invite your friends and colleagues to use this service.'));
+ $this->elementEnd('div');
+ }
}
}
- function show_form($error=null)
+ function showForm($error=null)
{
+ $this->mode = 'form';
+ $this->error = $error;
+ $this->showPage();
+ }
- global $config;
-
- common_show_header(_('Invite new users'), null, $error, array($this, 'show_top'));
-
+ function showInviteForm()
+ {
$this->elementStart('form', array('method' => 'post',
'id' => 'invite',
'action' => common_local_url('invite')));
@@ -151,13 +182,10 @@ class InviteAction extends Action
$this->submit('send', _('Send'));
$this->elementEnd('form');
-
- common_show_footer();
}
- function send_invitation($email, $user, $personal)
+ function sendInvitation($email, $user, $personal)
{
-
$profile = $user->getProfile();
$bestname = $profile->getBestName();
@@ -203,4 +231,9 @@ class InviteAction extends Action
mail_send($recipients, $headers, $body);
}
+ function showLocalNav()
+ {
+ $nav = new SubGroupNav($this, common_current_user());
+ $nav->show();
+ }
}
diff --git a/actions/openidlogin.php b/actions/openidlogin.php
index d1989e0de..ec5361c8b 100644
--- a/actions/openidlogin.php
+++ b/actions/openidlogin.php
@@ -23,7 +23,6 @@ require_once(INSTALLDIR.'/lib/openid.php');
class OpenidloginAction extends Action
{
-
function handle($args)
{
parent::handle($args);
@@ -35,40 +34,40 @@ class OpenidloginAction extends Action
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->show_form(_('There was a problem with your session token. Try again, please.'), $openid_url);
+ $this->showForm(_('There was a problem with your session token. Try again, please.'), $openid_url);
return;
}
$rememberme = $this->boolean('rememberme');
-
+
common_ensure_session();
-
+
$_SESSION['openid_rememberme'] = $rememberme;
-
+
$result = oid_authenticate($openid_url,
'finishopenidlogin');
-
+
if (is_string($result)) { # error message
unset($_SESSION['openid_rememberme']);
- $this->show_form($result, $openid_url);
+ $this->showForm($result, $openid_url);
}
} else {
$openid_url = oid_get_last();
- $this->show_form(null, $openid_url);
+ $this->showForm(null, $openid_url);
}
}
- function get_instructions()
+ function getInstructions()
{
return _('Login with an [OpenID](%%doc.openid%%) account.');
}
- function show_top($error=null)
+ function showPageNotice()
{
- if ($error) {
- $this->element('div', array('class' => 'error'), $error);
+ if ($this->error) {
+ $this->element('div', array('class' => 'error'), $this->error);
} else {
- $instr = $this->get_instructions();
+ $instr = $this->getInstructions();
$output = common_markup_to_html($instr);
$this->elementStart('div', 'instructions');
$this->raw($output);
@@ -76,22 +75,37 @@ class OpenidloginAction extends Action
}
}
- function show_form($error=null, $openid_url)
+ function title()
{
- common_show_header(_('OpenID Login'), null, $error, array($this, 'show_top'));
+ return _('OpenID Login');
+ }
+
+ function showForm($error=null, $openid_url)
+ {
+ $this->error = $error;
+ $this->openid_url = $openid_url;
+ $this->showPage();
+ }
+
+ function showContent() {
$formaction = common_local_url('openidlogin');
$this->elementStart('form', array('method' => 'post',
'id' => 'openidlogin',
'action' => $formaction));
$this->hidden('token', common_session_token());
$this->input('openid_url', _('OpenID URL'),
- $openid_url,
+ $this->openid_url,
_('Your OpenID URL'));
$this->checkbox('rememberme', _('Remember me'), false,
_('Automatically login in the future; ' .
'not for shared computers!'));
$this->submit('submit', _('Login'));
$this->elementEnd('form');
- common_show_footer();
+ }
+
+ function showLocalNav()
+ {
+ $nav = new LoginGroupNav($this);
+ $nav->show();
}
}
diff --git a/actions/public.php b/actions/public.php
index b51a95f24..c2e90c3b5 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -206,5 +206,7 @@ class PublicAction extends Action
$pop->show();
$gbp = new GroupsByPostsSection($this);
$gbp->show();
+ $feat = new FeaturedUsersSection($this);
+ $feat->show();
}
}
diff --git a/actions/recoverpassword.php b/actions/recoverpassword.php
index 3d839e751..eeb6b2516 100644
--- a/actions/recoverpassword.php
+++ b/actions/recoverpassword.php
@@ -25,6 +25,9 @@ define(MAX_RECOVERY_TIME, 24 * 60 * 60);
class RecoverpasswordAction extends Action
{
+ var $mode = null;
+ var $msg = null;
+ var $success = null;
function handle($args)
{
@@ -34,22 +37,22 @@ class RecoverpasswordAction extends Action
return;
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($this->arg('recover')) {
- $this->recover_password();
+ $this->recoverPassword();
} else if ($this->arg('reset')) {
- $this->reset_password();
+ $this->resetPassword();
} else {
$this->clientError(_('Unexpected form submission.'));
}
} else {
if ($this->trimmed('code')) {
- $this->check_code();
+ $this->checkCode();
} else {
- $this->show_form();
+ $this->showForm();
}
}
}
- function check_code()
+ function checkCode()
{
$code = $this->trimmed('code');
@@ -88,7 +91,7 @@ class RecoverpasswordAction extends Action
# Note: it's still deleted; let's avoid a second attempt!
if ((time() - $touched) > MAX_RECOVERY_TIME) {
- common_log(LOG_WARNING,
+ common_log(LOG_WARNING,
'Attempted redemption on recovery code ' .
'that is ' . $touched . ' seconds old. ');
$this->clientError(_('This confirmation code is too old. ' .
@@ -112,17 +115,17 @@ class RecoverpasswordAction extends Action
# Success!
- $this->set_temp_user($user);
- $this->show_password_form();
+ $this->setTempUser($user);
+ $this->showPasswordForm();
}
- function set_temp_user(&$user)
+ function setTempUser(&$user)
{
common_ensure_session();
$_SESSION['tempuser'] = $user->id;
}
- function get_temp_user()
+ function getTempUser()
{
common_ensure_session();
$user_id = $_SESSION['tempuser'];
@@ -132,44 +135,51 @@ class RecoverpasswordAction extends Action
return $user;
}
- function clear_temp_user()
+ function clearTempUser()
{
common_ensure_session();
unset($_SESSION['tempuser']);
}
- function show_top($msg=null)
+ function showPageNotice()
{
- if ($msg) {
- $this->element('div', 'error', $msg);
+ if ($this->msg) {
+ $this->element('div', ($this->success) ? 'success' : 'error', $this->msg);
} else {
$this->elementStart('div', 'instructions');
- $this->element('p', null,
- _('If you\'ve forgotten or lost your' .
- ' password, you can get a new one sent to' .
- ' the email address you have stored ' .
- ' in your account.'));
+ if ($this->mode == 'recover') {
+ $this->element('p', null,
+ _('If you\'ve forgotten or lost your' .
+ ' password, you can get a new one sent to' .
+ ' the email address you have stored ' .
+ ' in your account.'));
+ } else if ($this->mode == 'reset') {
+ $this->element('p', null,
+ _('You\'ve been identified. Enter a ' .
+ ' new password below. '));
+ }
$this->elementEnd('div');
}
}
- function show_password_top($msg=null)
+ function showForm($msg=null)
{
- if ($msg) {
- $this->element('div', 'error', $msg);
- } else {
- $this->element('div', 'instructions',
- _('You\'ve been identified. Enter a ' .
- ' new password below. '));
- }
+ $this->msg = $msg;
+ $this->mode = 'recover';
+ $this->showPage();
}
- function show_form($msg=null)
+ function showContent()
{
+ if ($this->mode == 'recover') {
+ $this->showRecoverForm();
+ } else if ($this->mode == 'reset') {
+ $this->showResetForm();
+ }
+ }
- common_show_header(_('Recover password'), null,
- $msg, array($this, 'show_top'));
-
+ function showRecoverForm()
+ {
$this->elementStart('form', array('method' => 'post',
'id' => 'recoverpassword',
'action' => common_local_url('recoverpassword')));
@@ -179,15 +189,29 @@ class RecoverpasswordAction extends Action
'or your registered email address.'));
$this->submit('recover', _('Recover'));
$this->elementEnd('form');
- common_show_footer();
}
- function show_password_form($msg=null)
+ function title()
{
+ switch ($this->mode) {
+ case 'reset': return _('Reset password');
+ case 'recover': return _('Recover password');
+ case 'sent': return _('Password recovery requested');
+ case 'saved': return _('Password saved.');
+ default:
+ return _('Unknown action');
+ }
+ }
- common_show_header(_('Reset password'), null,
- $msg, array($this, 'show_password_top'));
+ function showPasswordForm($msg=null)
+ {
+ $this->msg = $msg;
+ $this->mode = 'reset';
+ $this->showPage();
+ }
+ function showResetForm()
+ {
$this->elementStart('form', array('method' => 'post',
'id' => 'recoverpassword',
'action' => common_local_url('recoverpassword')));
@@ -198,14 +222,13 @@ class RecoverpasswordAction extends Action
_('Same as password above'));
$this->submit('reset', _('Reset'));
$this->elementEnd('form');
- common_show_footer();
}
- function recover_password()
+ function recoverPassword()
{
$nore = $this->trimmed('nicknameoremail');
if (!$nore) {
- $this->show_form(_('Enter a nickname or email address.'));
+ $this->showForm(_('Enter a nickname or email address.'));
return;
}
@@ -225,7 +248,7 @@ class RecoverpasswordAction extends Action
}
if (!$user) {
- $this->show_form(_('No user with that email address or username.'));
+ $this->showForm(_('No user with that email address or username.'));
return;
}
@@ -277,25 +300,24 @@ class RecoverpasswordAction extends Action
mail_to_user($user, _('Password recovery requested'), $body, $confirm->address);
- common_show_header(_('Password recovery requested'));
- $this->element('p', null,
- _('Instructions for recovering your password ' .
+ $this->mode = 'sent';
+ $this->msg = _('Instructions for recovering your password ' .
'have been sent to the email address registered to your ' .
- 'account.'));
- common_show_footer();
+ 'account.');
+ $this->success = true;
+ $this->showPage();
}
- function reset_password()
+ function resetPassword()
{
-
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->show_form(_('There was a problem with your session token. Try again, please.'));
+ $this->showForm(_('There was a problem with your session token. Try again, please.'));
return;
}
- $user = $this->get_temp_user();
+ $user = $this->getTempUser();
if (!$user) {
$this->clientError(_('Unexpected password reset.'));
@@ -306,11 +328,11 @@ class RecoverpasswordAction extends Action
$confirm = $this->trimmed('confirm');
if (!$newpassword || strlen($newpassword) < 6) {
- $this->show_password_form(_('Password must be 6 chars or more.'));
+ $this->showPasswordForm(_('Password must be 6 chars or more.'));
return;
}
if ($newpassword != $confirm) {
- $this->show_password_form(_('Password and confirmation do not match.'));
+ $this->showPasswordForm(_('Password and confirmation do not match.'));
return;
}
@@ -326,7 +348,7 @@ class RecoverpasswordAction extends Action
return;
}
- $this->clear_temp_user();
+ $this->clearTempUser();
if (!common_set_user($user->nickname)) {
$this->serverError(_('Error setting user.'));
@@ -335,9 +357,10 @@ class RecoverpasswordAction extends Action
common_real_login(true);
- common_show_header(_('Password saved.'));
- $this->element('p', null, _('New password successfully saved. ' .
- 'You are now logged in.'));
- common_show_footer();
+ $this->mode = 'saved';
+ $this->msg = _('New password successfully saved. ' .
+ 'You are now logged in.');
+ $this->success = true;
+ $this->showPage();
}
}
diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php
index 32e9bf3d3..3c8346fbe 100644
--- a/actions/remotesubscribe.php
+++ b/actions/remotesubscribe.php
@@ -23,100 +23,112 @@ require_once(INSTALLDIR.'/lib/omb.php');
class RemotesubscribeAction extends Action
{
+ var $nickname;
+ var $profile_url;
+ var $err;
- function handle($args)
+ function prepare($args)
{
-
- parent::handle($args);
+ parent::prepare($args);
if (common_logged_in()) {
$this->clientError(_('You can use the local subscription!'));
- return;
+ return false;
}
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ $this->nickname = $this->trimmed('nickname');
+ $this->profile_url = $this->trimmed('profile_url');
+
+ return true;
+ }
+
+ function handle($args)
+ {
+ parent::handle($args);
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->show_form(_('There was a problem with your session token. Try again, please.'));
+ $this->showForm(_('There was a problem with your session token. '.
+ 'Try again, please.'));
return;
}
-
- $this->remote_subscription();
+ $this->remoteSubscription();
} else {
- $this->show_form();
+ $this->showForm();
}
}
- function get_instructions()
+ function showForm($err=null)
{
- return _('To subscribe, you can [login](%%action.login%%),' .
- ' or [register](%%action.register%%) a new ' .
- ' account. If you already have an account ' .
- ' on a [compatible microblogging site](%%doc.openmublog%%), ' .
- ' enter your profile URL below.');
+ $this->err = $err;
+ $this->showPage();
}
- function show_top($err=null)
+ function showPageNotice()
{
- if ($err) {
- $this->element('div', 'error', $err);
+ if ($this->err) {
+ $this->element('div', 'error', $this->err);
} else {
- $instructions = $this->get_instructions();
- $output = common_markup_to_html($instructions);
+ $inst = _('To subscribe, you can [login](%%action.login%%),' .
+ ' or [register](%%action.register%%) a new ' .
+ ' account. If you already have an account ' .
+ ' on a [compatible microblogging site](%%doc.openmublog%%), ' .
+ ' enter your profile URL below.');
+ $output = common_markup_to_html($inst);
$this->elementStart('div', 'instructions');
$this->raw($output);
- $this->elementEnd('p');
+ $this->elementEnd('div');
}
}
- function show_form($err=null)
+ function title()
+ {
+ return _('Remote subscribe');
+ }
+
+ function showContent()
{
- $nickname = $this->trimmed('nickname');
- $profile = $this->trimmed('profile_url');
- common_show_header(_('Remote subscribe'), null, $err,
- array($this, 'show_top'));
# id = remotesubscribe conflicts with the
# button on profile page
$this->elementStart('form', array('id' => 'remsub', 'method' => 'post',
'action' => common_local_url('remotesubscribe')));
$this->hidden('token', common_session_token());
- $this->input('nickname', _('User nickname'), $nickname,
+ $this->input('nickname', _('User nickname'), $this->nickname,
_('Nickname of the user you want to follow'));
- $this->input('profile_url', _('Profile URL'), $profile,
+ $this->input('profile_url', _('Profile URL'), $this->profile_url,
_('URL of your profile on another compatible microblogging service'));
$this->submit('submit', _('Subscribe'));
$this->elementEnd('form');
- common_show_footer();
}
- function remote_subscription()
+ function remoteSubscription()
{
- $user = $this->get_user();
+ $user = $this->getUser();
if (!$user) {
- $this->show_form(_('No such user.'));
+ $this->showForm(_('No such user.'));
return;
}
- $profile = $this->trimmed('profile_url');
+ $this->profile_url = $this->trimmed('profile_url');
- if (!$profile) {
- $this->show_form(_('No such user.'));
+ if (!$this->profile_url) {
+ $this->showForm(_('No such user.'));
return;
}
- if (!Validate::uri($profile, array('allowed_schemes' => array('http', 'https')))) {
- $this->show_form(_('Invalid profile URL (bad format)'));
+ if (!Validate::uri($this->profile_url, array('allowed_schemes' => array('http', 'https')))) {
+ $this->showForm(_('Invalid profile URL (bad format)'));
return;
}
$fetcher = Auth_Yadis_Yadis::getHTTPFetcher();
- $yadis = Auth_Yadis_Yadis::discover($profile, $fetcher);
+ $yadis = Auth_Yadis_Yadis::discover($this->profile_url, $fetcher);
if (!$yadis || $yadis->failed) {
- $this->show_form(_('Not a valid profile URL (no YADIS document).'));
+ $this->showForm(_('Not a valid profile URL (no YADIS document).'));
return;
}
@@ -125,52 +137,50 @@ class RemotesubscribeAction extends Action
$xrds =& Auth_Yadis_XRDS::parseXRDS(trim($yadis->response_text));
if (!$xrds) {
- $this->show_form(_('Not a valid profile URL (no XRDS defined).'));
+ $this->showForm(_('Not a valid profile URL (no XRDS defined).'));
return;
}
$omb = $this->getOmb($xrds);
if (!$omb) {
- $this->show_form(_('Not a valid profile URL (incorrect services).'));
+ $this->showForm(_('Not a valid profile URL (incorrect services).'));
return;
}
if (omb_service_uri($omb[OAUTH_ENDPOINT_REQUEST]) ==
common_local_url('requesttoken'))
{
- $this->show_form(_('That\'s a local profile! Login to subscribe.'));
+ $this->showForm(_('That\'s a local profile! Login to subscribe.'));
return;
}
if (User::staticGet('uri', omb_local_id($omb[OAUTH_ENDPOINT_REQUEST]))) {
- $this->show_form(_('That\'s a local profile! Login to subscribe.'));
+ $this->showForm(_('That\'s a local profile! Login to subscribe.'));
return;
}
- list($token, $secret) = $this->request_token($omb);
+ list($token, $secret) = $this->requestToken($omb);
if (!$token || !$secret) {
- $this->show_form(_('Couldn\'t get a request token.'));
+ $this->showForm(_('Couldn\'t get a request token.'));
return;
}
- $this->request_authorization($user, $omb, $token, $secret);
+ $this->requestAuthorization($user, $omb, $token, $secret);
}
- function get_user()
+ function getUser()
{
$user = null;
- $nickname = $this->trimmed('nickname');
- if ($nickname) {
- $user = User::staticGet('nickname', $nickname);
+ if ($this->nickname) {
+ $user = User::staticGet('nickname', $this->nickname);
}
return $user;
}
function getOmb($xrds)
{
-
static $omb_endpoints = array(OMB_ENDPOINT_UPDATEPROFILE, OMB_ENDPOINT_POSTNOTICE);
static $oauth_endpoints = array(OAUTH_ENDPOINT_REQUEST, OAUTH_ENDPOINT_AUTHORIZE,
OAUTH_ENDPOINT_ACCESS);
@@ -265,7 +275,7 @@ class RemotesubscribeAction extends Action
return true;
}
- function request_token($omb)
+ function requestToken($omb)
{
$con = omb_oauth_consumer();
@@ -310,7 +320,7 @@ class RemotesubscribeAction extends Action
return array($return['oauth_token'], $return['oauth_token_secret']);
}
- function request_authorization($user, $omb, $token, $secret)
+ function requestAuthorization($user, $omb, $token, $secret)
{
global $config; # for license URL
@@ -391,9 +401,4 @@ class RemotesubscribeAction extends Action
common_redirect($req->to_url());
return;
}
-
- function make_nonce()
- {
- return common_good_rand(16);
- }
}
diff --git a/actions/showgroup.php b/actions/showgroup.php
index 534043c24..8d8fbe6be 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -333,6 +333,8 @@ class ShowgroupAction extends Action
function showSections()
{
$this->showMembers();
+ $cloud = new GroupTagCloudSection($this, $this->group);
+ $cloud->show();
}
/**
@@ -349,7 +351,7 @@ class ShowgroupAction extends Action
return;
}
- $this->elementStart('div', array('id' => 'entity_subscriptions',
+ $this->elementStart('div', array('id' => 'entity_members',
'class' => 'section'));
$this->element('h2', null, _('Members'));
@@ -367,5 +369,7 @@ class ShowgroupAction extends Action
array('nickname' => $this->group->nickname))),
_('All members'));
}
+
+ $this->elementEnd('div');
}
}
diff --git a/actions/subscribers.php b/actions/subscribers.php
index 408829b54..be9df2b12 100644
--- a/actions/subscribers.php
+++ b/actions/subscribers.php
@@ -75,7 +75,11 @@ class SubscribersAction extends GalleryAction
$offset = ($this->page-1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1;
- $subscribers = $this->user->getSubscribers($offset, $limit);
+ if ($this->tag) {
+ $subscribers = $this->user->getTaggedSubscribers($this->tag, $offset, $limit);
+ } else {
+ $subscribers = $this->user->getSubscribers($offset, $limit);
+ }
if ($subscribers) {
$subscribers_list = new SubscribersList($subscribers, $this->user, $this);
diff --git a/actions/subscriptions.php b/actions/subscriptions.php
index bcc557891..d7ba0d624 100644
--- a/actions/subscriptions.php
+++ b/actions/subscriptions.php
@@ -84,7 +84,11 @@ class SubscriptionsAction extends GalleryAction
$offset = ($this->page-1) * PROFILES_PER_PAGE;
$limit = PROFILES_PER_PAGE + 1;
- $subscriptions = $this->user->getSubscriptions($offset, $limit);
+ if ($this->tag) {
+ $subscriptions = $this->user->getTaggedSubscriptions($this->tag, $offset, $limit);
+ } else {
+ $subscriptions = $this->user->getSubscriptions($offset, $limit);
+ }
if ($subscriptions) {
$subscriptions_list = new SubscriptionsList($subscriptions, $this->user, $this);
diff --git a/actions/sup.php b/actions/sup.php
index 38e2e2e59..f4b1cda23 100644
--- a/actions/sup.php
+++ b/actions/sup.php
@@ -21,44 +21,42 @@ if (!defined('LACONICA')) { exit(1); }
class SupAction extends Action
{
-
function handle($args)
{
-
parent::handle($args);
-
+
$seconds = $this->trimmed('seconds');
-
+
if (!$seconds) {
$seconds = 15;
}
- $updates = $this->get_updates($seconds);
-
+ $updates = $this->getUpdates($seconds);
+
header('Content-Type: application/json; charset=utf-8');
-
+
print json_encode(array('updated_time' => date('c'),
'since_time' => date('c', time() - $seconds),
- 'available_periods' => $this->available_periods(),
+ 'available_periods' => $this->availablePeriods(),
'period' => $seconds,
'updates' => $updates));
}
-
- function available_periods()
+
+ function availablePeriods()
{
static $periods = array(86400, 43200, 21600, 7200,
3600, 1800, 600, 300, 120,
- 60, 30, 15);
+ 60, 30, 15);
$available = array();
foreach ($periods as $period) {
$available[$period] = common_local_url('sup',
array('seconds' => $period));
}
-
+
return $available;
}
-
- function get_updates($seconds)
+
+ function getUpdates($seconds)
{
$notice = new Notice();
@@ -69,16 +67,16 @@ class SupAction extends Action
'FROM notice ' .
'WHERE created > (now() - ' . $seconds . ') ' .
'GROUP BY profile_id');
-
+
$updates = array();
-
+
while ($notice->fetch()) {
$updates[] = array($notice->profile_id, $notice->max_id);
}
-
+
return $updates;
}
-
+
function isReadOnly()
{
return true;
diff --git a/actions/tagother.php b/actions/tagother.php
index e60eb8b58..5daf612fb 100644
--- a/actions/tagother.php
+++ b/actions/tagother.php
@@ -23,71 +23,85 @@ require_once(INSTALLDIR.'/lib/settingsaction.php');
class TagotherAction extends Action
{
+ var $profile = null;
+ var $error = null;
- function handle($args)
+ function prepare($args)
{
-
- parent::handle($args);
-
+ parent::prepare($args);
if (!common_logged_in()) {
$this->clientError(_('Not logged in'), 403);
- return;
+ return false;
+ }
+
+ $id = $this->trimmed('id');
+ if (!$id) {
+ $this->clientError(_('No id argument.'));
+ return false;
}
+ $this->profile = Profile::staticGet('id', $id);
+
+ if (!$this->profile) {
+ $this->clientError(_('No profile with that ID.'));
+ return false;
+ }
+
+ return true;
+ }
+
+ function handle($args)
+ {
+ parent::handle($args);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
- $this->save_tags();
+ $this->saveTags();
} else {
- $id = $this->trimmed('id');
- if (!$id) {
- $this->clientError(_('No id argument.'));
- return;
- }
- $profile = Profile::staticGet('id', $id);
- if (!$profile) {
- $this->clientError(_('No profile with that ID.'));
- return;
- }
- $this->show_form($profile);
+ $this->showForm($profile);
}
}
- function show_form($profile, $error=null)
+ function title()
{
+ return sprintf(_('Tag %s'), $this->profile->nickname);
+ }
- $user = common_current_user();
-
- common_show_header(_('Tag a person'),
- null, array($profile, $error), array($this, 'show_top'));
+ function showForm($error=null)
+ {
+ $this->error = $error;
+ $this->showPage();
+ }
- $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ function showContent()
+ {
+ $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
$this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE),
'class' => 'avatar stream',
'width' => AVATAR_PROFILE_SIZE,
'height' => AVATAR_PROFILE_SIZE,
'alt' =>
- ($profile->fullname) ? $profile->fullname :
- $profile->nickname));
+ ($this->profile->fullname) ? $this->profile->fullname :
+ $this->profile->nickname));
- $this->element('a', array('href' => $profile->profileurl,
+ $this->element('a', array('href' => $this->profile->profileurl,
'class' => 'external profile nickname'),
- $profile->nickname);
+ $this->profile->nickname);
- if ($profile->fullname) {
+ if ($this->profile->fullname) {
$this->elementStart('div', 'fullname');
- if ($profile->homepage) {
- $this->element('a', array('href' => $profile->homepage),
- $profile->fullname);
+ if ($this->profile->homepage) {
+ $this->element('a', array('href' => $this->profile->homepage),
+ $this->profile->fullname);
} else {
- $this->text($profile->fullname);
+ $this->text($this->profile->fullname);
}
$this->elementEnd('div');
}
- if ($profile->location) {
- $this->element('div', 'location', $profile->location);
+ if ($this->profile->location) {
+ $this->element('div', 'location', $this->profile->location);
}
- if ($profile->bio) {
- $this->element('div', 'bio', $profile->bio);
+ if ($this->profile->bio) {
+ $this->element('div', 'bio', $this->profile->bio);
}
$this->elementStart('form', array('method' => 'post',
@@ -95,33 +109,24 @@ class TagotherAction extends Action
'name' => 'tagother',
'action' => $this->selfUrl()));
$this->hidden('token', common_session_token());
- $this->hidden('id', $profile->id);
+ $this->hidden('id', $this->profile->id);
$this->input('tags', _('Tags'),
- ($this->arg('tags')) ? $this->arg('tags') : implode(' ', Profile_tag::getTags($user->id, $profile->id)),
+ ($this->arg('tags')) ? $this->arg('tags') : implode(' ', Profile_tag::getTags($user->id, $this->profile->id)),
_('Tags for this user (letters, numbers, -, ., and _), comma- or space- separated'));
$this->submit('save', _('Save'));
$this->elementEnd('form');
- common_show_footer();
-
}
- function save_tags()
+ function saveTags()
{
-
$id = $this->trimmed('id');
$tagstring = $this->trimmed('tags');
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $this->show_form(_('There was a problem with your session token. Try again, please.'));
- return;
- }
-
- $profile = Profile::staticGet('id', $id);
-
- if (!$profile) {
- $this->clientError(_('No such profile.'));
+ $this->showForm(_('There was a problem with your session token.'.
+ ' Try again, please.'));
return;
}
@@ -132,7 +137,7 @@ class TagotherAction extends Action
foreach ($tags as $tag) {
if (!common_valid_profile_tag($tag)) {
- $this->show_form($profile, sprintf(_('Invalid tag: "%s"'), $tag));
+ $this->showForm(sprintf(_('Invalid tag: "%s"'), $tag));
return;
}
}
@@ -143,22 +148,22 @@ class TagotherAction extends Action
$user = common_current_user();
if (!Subscription::pkeyGet(array('subscriber' => $user->id,
- 'subscribed' => $profile->id)) &&
- !Subscription::pkeyGet(array('subscriber' => $profile->id,
+ 'subscribed' => $this->profile->id)) &&
+ !Subscription::pkeyGet(array('subscriber' => $this->profile->id,
'subscribed' => $user->id)))
{
$this->clientError(_('You can only tag people you are subscribed to or who are subscribed to you.'));
return;
}
- $result = Profile_tag::setTags($user->id, $profile->id, $tags);
+ $result = Profile_tag::setTags($user->id, $this->profile->id, $tags);
if (!$result) {
$this->clientError(_('Could not save tags.'));
return;
}
- $action = $user->isSubscribed($profile) ? 'subscriptions' : 'subscribers';
+ $action = $user->isSubscribed($this->profile) ? 'subscriptions' : 'subscribers';
if ($this->boolean('ajax')) {
common_start_html('text/xml');
@@ -182,11 +187,10 @@ class TagotherAction extends Action
}
}
- function show_top($arr = null)
+ function showPageNotice()
{
- list($profile, $error) = $arr;
- if ($error) {
- $this->element('p', 'error', $error);
+ if ($this->error) {
+ $this->element('p', 'error', $this->error);
} else {
$this->elementStart('div', 'instructions');
$this->element('p', null,
diff --git a/actions/userauthorization.php b/actions/userauthorization.php
index 838458932..ed62f640c 100644
--- a/actions/userauthorization.php
+++ b/actions/userauthorization.php
@@ -24,6 +24,8 @@ define('TIMESTAMP_THRESHOLD', 300);
class UserauthorizationAction extends Action
{
+ var $error;
+ var $req;
function handle($args)
{
@@ -33,37 +35,33 @@ class UserauthorizationAction extends Action
# CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
- $req = $this->get_stored_request();
- $this->show_form(_('There was a problem with your session token. Try again, please.'), $req);
+ $req = $this->getStoredRequest();
+ $this->showForm($req, _('There was a problem with your session token. '.
+ 'Try again, please.'));
return;
}
# We've shown the form, now post user's choice
- $this->send_authorization();
+ $this->sendAuthorization();
} else {
if (!common_logged_in()) {
# Go log in, and then come back
- common_debug('saving URL for returnto', __FILE__);
common_set_returnto($_SERVER['REQUEST_URI']);
- common_debug('redirecting to login', __FILE__);
common_redirect(common_local_url('login'));
return;
}
try {
# this must be a new request
- common_debug('getting new request', __FILE__);
- $req = $this->get_new_request();
+ $req = $this->getNewRequest();
if (!$req) {
$this->clientError(_('No request found!'));
}
- common_debug('validating request', __FILE__);
# XXX: only validate new requests, since nonce is one-time use
- $this->validate_request($req);
- common_debug('showing form', __FILE__);
- $this->store_request($req);
- $this->show_form($req);
+ $this->validateRequest($req);
+ $this->storeRequest($req);
+ $this->showForm($req);
} catch (OAuthException $e) {
- $this->clear_request();
+ $this->clearRequest();
$this->clientError($e->getMessage());
return;
}
@@ -71,8 +69,29 @@ class UserauthorizationAction extends Action
}
}
- function show_form($req)
+ function showForm($req, $error=null)
{
+ $this->req = $req;
+ $this->error = $error;
+ $this->showPage();
+ }
+
+ function title()
+ {
+ return _('Authorize subscription');
+ }
+
+ function showPageNotice()
+ {
+ $this->element('p', null, _('Please check these details to make sure '.
+ 'that you want to subscribe to this user\'s notices. '.
+ 'If you didn\'t just ask to subscribe to someone\'s notices, '.
+ 'click "Cancel".'));
+ }
+
+ function showContent()
+ {
+ $req = $this->req;
$nickname = $req->get_parameter('omb_listenee_nickname');
$profile = $req->get_parameter('omb_listenee_profile');
@@ -83,11 +102,6 @@ class UserauthorizationAction extends Action
$location = $req->get_parameter('omb_listenee_location');
$avatar = $req->get_parameter('omb_listenee_avatar');
- common_show_header(_('Authorize subscription'));
- $this->element('p', null, _('Please check these details to make sure '.
- 'that you want to subscribe to this user\'s notices. '.
- 'If you didn\'t just ask to subscribe to someone\'s notices, '.
- 'click "Cancel".'));
$this->elementStart('div', 'profile');
if ($avatar) {
$this->element('img', array('src' => $avatar,
@@ -122,19 +136,18 @@ class UserauthorizationAction extends Action
$this->elementEnd('div');
$this->elementEnd('div');
$this->elementStart('form', array('method' => 'post',
- 'id' => 'userauthorization',
- 'name' => 'userauthorization',
- 'action' => common_local_url('userauthorization')));
+ 'id' => 'userauthorization',
+ 'name' => 'userauthorization',
+ 'action' => common_local_url('userauthorization')));
$this->hidden('token', common_session_token());
$this->submit('accept', _('Accept'));
$this->submit('reject', _('Reject'));
$this->elementEnd('form');
- common_show_footer();
}
- function send_authorization()
+ function sendAuthorization()
{
- $req = $this->get_stored_request();
+ $req = $this->getStoredRequest();
if (!$req) {
$this->clientError(_('No authorization request!'));
@@ -144,14 +157,14 @@ class UserauthorizationAction extends Action
$callback = $req->get_parameter('oauth_callback');
if ($this->arg('accept')) {
- if (!$this->authorize_token($req)) {
+ if (!$this->authorizeToken($req)) {
$this->clientError(_('Error authorizing token'));
}
- if (!$this->save_remote_profile($req)) {
+ if (!$this->saveRemoteProfile($req)) {
$this->clientError(_('Error saving remote profile'));
}
if (!$callback) {
- $this->show_accept_message($req->get_parameter('oauth_token'));
+ $this->showAcceptMessage($req->get_parameter('oauth_token'));
} else {
$params = array();
$params['oauth_token'] = $req->get_parameter('oauth_token');
@@ -193,7 +206,7 @@ class UserauthorizationAction extends Action
}
} else {
if (!$callback) {
- $this->show_reject_message();
+ $this->showRejectMessage();
} else {
# XXX: not 100% sure how to signal failure... just redirect without token?
common_redirect($callback, 303);
@@ -201,24 +214,19 @@ class UserauthorizationAction extends Action
}
}
- function authorize_token(&$req)
+ function authorizeToken(&$req)
{
$consumer_key = $req->get_parameter('oauth_consumer_key');
$token_field = $req->get_parameter('oauth_token');
- common_debug('consumer key = "'.$consumer_key.'"', __FILE__);
- common_debug('token field = "'.$token_field.'"', __FILE__);
$rt = new Token();
$rt->consumer_key = $consumer_key;
$rt->tok = $token_field;
$rt->type = 0;
$rt->state = 0;
- common_debug('request token to look up: "'.print_r($rt,true).'"');
if ($rt->find(true)) {
- common_debug('found request token to authorize', __FILE__);
$orig_rt = clone($rt);
$rt->state = 1; # Authorized but not used
if ($rt->update($orig_rt)) {
- common_debug('updated request token so it is authorized', __FILE__);
return true;
}
}
@@ -227,7 +235,7 @@ class UserauthorizationAction extends Action
# XXX: refactor with similar code in finishremotesubscribe.php
- function save_remote_profile(&$req)
+ function saveRemoteProfile(&$req)
{
# 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
@@ -295,15 +303,15 @@ class UserauthorizationAction extends Action
}
if ($avatar_url) {
- if (!$this->add_avatar($profile, $avatar_url)) {
+ if (!$this->addAvatar($profile, $avatar_url)) {
return false;
}
}
$user = common_current_user();
$datastore = omb_oauth_datastore();
- $consumer = $this->get_consumer($datastore, $req);
- $token = $this->get_token($datastore, $req, $consumer);
+ $consumer = $this->getConsumer($datastore, $req);
+ $token = $this->getToken($datastore, $req, $consumer);
$sub = new Subscription();
$sub->subscriber = $user->id;
@@ -318,54 +326,54 @@ class UserauthorizationAction extends Action
return true;
}
- function add_avatar($profile, $url)
+ function addAvatar($profile, $url)
{
$temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
copy($url, $temp_filename);
return $profile->setOriginal($temp_filename);
}
- function show_accept_message($tok)
+ function showAcceptMessage($tok)
{
common_show_header(_('Subscription authorized'));
$this->element('p', null,
_('The subscription has been authorized, but no '.
- 'callback URL was passed. Check with the site\'s instructions for '.
- 'details on how to authorize the subscription. Your subscription token is:'));
+ 'callback URL was passed. Check with the site\'s instructions for '.
+ 'details on how to authorize the subscription. Your subscription token is:'));
$this->element('blockquote', 'token', $tok);
common_show_footer();
}
- function show_reject_message($tok)
+ function showRejectMessage($tok)
{
common_show_header(_('Subscription rejected'));
$this->element('p', null,
_('The subscription has been rejected, but no '.
- 'callback URL was passed. Check with the site\'s instructions for '.
- 'details on how to fully reject the subscription.'));
+ 'callback URL was passed. Check with the site\'s instructions for '.
+ 'details on how to fully reject the subscription.'));
common_show_footer();
}
- function store_request($req)
+ function storeRequest($req)
{
common_ensure_session();
$_SESSION['userauthorizationrequest'] = $req;
}
- function clear_request()
+ function clearRequest()
{
common_ensure_session();
unset($_SESSION['userauthorizationrequest']);
}
- function get_stored_request()
+ function getStoredRequest()
{
common_ensure_session();
$req = $_SESSION['userauthorizationrequest'];
return $req;
}
- function get_new_request()
+ function getNewRequest()
{
common_remove_magic_from_request();
$req = OAuthRequest::from_request();
@@ -374,31 +382,22 @@ class UserauthorizationAction extends Action
# Throws an OAuthException if anything goes wrong
- function validate_request(&$req)
+ function validateRequest(&$req)
{
# OAuth stuff -- have to copy from OAuth.php since they're
# all private methods, and there's no user-authentication method
- common_debug('checking version', __FILE__);
- $this->check_version($req);
- common_debug('getting datastore', __FILE__);
+ $this->checkVersion($req);
$datastore = omb_oauth_datastore();
- common_debug('getting consumer', __FILE__);
- $consumer = $this->get_consumer($datastore, $req);
- common_debug('getting token', __FILE__);
- $token = $this->get_token($datastore, $req, $consumer);
- common_debug('checking timestamp', __FILE__);
- $this->check_timestamp($req);
- common_debug('checking nonce', __FILE__);
- $this->check_nonce($datastore, $req, $consumer, $token);
- common_debug('checking signature', __FILE__);
- $this->check_signature($req, $consumer, $token);
- common_debug('validating omb stuff', __FILE__);
- $this->validate_omb($req);
- common_debug('done validating', __FILE__);
+ $consumer = $this->getConsumer($datastore, $req);
+ $token = $this->getToken($datastore, $req, $consumer);
+ $this->checkTimestamp($req);
+ $this->checkNonce($datastore, $req, $consumer, $token);
+ $this->checkSignature($req, $consumer, $token);
+ $this->validateOmb($req);
return true;
}
- function validate_omb(&$req)
+ function validateOmb(&$req)
{
foreach (array('omb_version', 'omb_listener', 'omb_listenee',
'omb_listenee_profile', 'omb_listenee_nickname',
@@ -513,7 +512,7 @@ class UserauthorizationAction extends Action
# Snagged from OAuthServer
- function check_version(&$req)
+ function checkVersion(&$req)
{
$version = $req->get_parameter("oauth_version");
if (!$version) {
@@ -527,7 +526,7 @@ class UserauthorizationAction extends Action
# Snagged from OAuthServer
- function get_consumer($datastore, $req)
+ function getConsumer($datastore, $req)
{
$consumer_key = @$req->get_parameter("oauth_consumer_key");
if (!$consumer_key) {
@@ -543,7 +542,7 @@ class UserauthorizationAction extends Action
# Mostly cadged from OAuthServer
- function get_token($datastore, &$req, $consumer)
+ function getToken($datastore, &$req, $consumer)
{/*{{{*/
$token_field = @$req->get_parameter('oauth_token');
$token = $datastore->lookup_token($consumer, 'request', $token_field);
@@ -553,7 +552,7 @@ class UserauthorizationAction extends Action
return $token;
}
- function check_timestamp(&$req)
+ function checkTimestamp(&$req)
{
$timestamp = @$req->get_parameter('oauth_timestamp');
$now = time();
@@ -563,7 +562,7 @@ class UserauthorizationAction extends Action
}
# NOTE: don't call twice on the same request; will fail!
- function check_nonce(&$datastore, &$req, $consumer, $token)
+ function checkNonce(&$datastore, &$req, $consumer, $token)
{
$timestamp = @$req->get_parameter('oauth_timestamp');
$nonce = @$req->get_parameter('oauth_nonce');
@@ -574,9 +573,9 @@ class UserauthorizationAction extends Action
return true;
}
- function check_signature(&$req, $consumer, $token)
+ function checkSignature(&$req, $consumer, $token)
{
- $signature_method = $this->get_signature_method($req);
+ $signature_method = $this->getSignatureMethod($req);
$signature = $req->get_parameter('oauth_signature');
$valid_sig = $signature_method->check_signature($req,
$consumer,
@@ -587,7 +586,7 @@ class UserauthorizationAction extends Action
}
}
- function get_signature_method(&$req)
+ function getSignatureMethod(&$req)
{
$signature_method = @$req->get_parameter("oauth_signature_method");
if (!$signature_method) {
diff --git a/actions/xrds.php b/actions/xrds.php
index 629de3a86..075831803 100644
--- a/actions/xrds.php
+++ b/actions/xrds.php
@@ -49,17 +49,17 @@ class XrdsAction extends Action
{
/**
* Is read only?
- *
+ *
* @return boolean true
*/
function isReadOnly()
- {
+ {
return true;
}
/**
* Class handler.
- *
+ *
* @param array $args query arguments
*
* @return void
@@ -78,7 +78,7 @@ class XrdsAction extends Action
/**
* Show XRDS for a user.
- *
+ *
* @param class $user XRDS for this user.
*
* @return void
@@ -86,7 +86,7 @@ class XrdsAction extends Action
function showXrds($user)
{
header('Content-Type: application/xrds+xml');
- common_start_xml();
+ $this->startXML();
$this->elementStart('XRDS', array('xmlns' => 'xri://$xrds'));
$this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)',
@@ -133,12 +133,12 @@ class XrdsAction extends Action
'#omb');
$this->elementEnd('XRD');
$this->elementEnd('XRDS');
- common_end_xml();
+ $this->endXML();
}
/**
* Show service.
- *
+ *
* @param string $type XRDS type
* @param string $uri URI
* @param array $params type parameters, null by default