summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/accesstoken.php2
-rw-r--r--actions/all.php2
-rw-r--r--actions/api.php1
-rw-r--r--actions/attachment.php209
-rw-r--r--actions/attachment_ajax.php141
-rw-r--r--actions/attachments.php292
-rw-r--r--actions/attachments_ajax.php115
-rw-r--r--actions/conversation.php203
-rw-r--r--actions/deletenotice.php4
-rw-r--r--actions/designsettings.php99
-rw-r--r--actions/favoritesrss.php2
-rw-r--r--actions/finishopenidlogin.php33
-rw-r--r--actions/grouprss.php2
-rw-r--r--actions/logout.php16
-rw-r--r--actions/newmessage.php45
-rw-r--r--actions/newnotice.php23
-rw-r--r--actions/openidsettings.php4
-rw-r--r--actions/profilesettings.php343
-rw-r--r--actions/recoverpassword.php4
-rw-r--r--actions/register.php401
-rw-r--r--actions/showfavorites.php4
-rw-r--r--actions/showgroup.php4
-rw-r--r--actions/showstream.php16
-rw-r--r--actions/subscribers.php10
-rw-r--r--actions/subscriptions.php10
-rw-r--r--actions/tag.php3
-rw-r--r--actions/twitapifriendships.php6
-rw-r--r--actions/twitapistatuses.php38
-rw-r--r--actions/twitapiusers.php28
-rw-r--r--actions/twittersettings.php32
-rw-r--r--actions/userrss.php24
31 files changed, 1654 insertions, 462 deletions
diff --git a/actions/accesstoken.php b/actions/accesstoken.php
index bb68d3314..46b43c702 100644
--- a/actions/accesstoken.php
+++ b/actions/accesstoken.php
@@ -59,7 +59,7 @@ class AccesstokenAction extends Action
try {
common_debug('getting request from env variables', __FILE__);
common_remove_magic_from_request();
- $req = OAuthRequest::from_request('POST', common_locale_url('accesstoken'));
+ $req = OAuthRequest::from_request('POST', common_local_url('accesstoken'));
common_debug('getting a server', __FILE__);
$server = omb_oauth_server();
common_debug('fetching the access token', __FILE__);
diff --git a/actions/all.php b/actions/all.php
index a92e55462..a53bbea07 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -93,7 +93,7 @@ class AllAction extends ProfileAction
if (common_logged_in()) {
$current_user = common_current_user();
if ($this->user->id === $current_user->id) {
- $message .= _('Try subscribing to more people, [join a group](%%action.groups) or post something yourself.');
+ $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.');
} else {
$message .= sprintf(_('You can try to [nudge %s](../%s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
}
diff --git a/actions/api.php b/actions/api.php
index d2f0a2eff..8762b4bcd 100644
--- a/actions/api.php
+++ b/actions/api.php
@@ -130,6 +130,7 @@ class ApiAction extends Action
'statuses/friends_timeline',
'statuses/friends',
'statuses/replies',
+ 'statuses/mentions',
'statuses/followers',
'favorites/favorites');
diff --git a/actions/attachment.php b/actions/attachment.php
new file mode 100644
index 000000000..b9187ff08
--- /dev/null
+++ b/actions/attachment.php
@@ -0,0 +1,209 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Show notice attachments
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2008-2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+//require_once INSTALLDIR.'/lib/personalgroupnav.php';
+//require_once INSTALLDIR.'/lib/feedlist.php';
+require_once INSTALLDIR.'/lib/attachmentlist.php';
+
+/**
+ * Show notice attachments
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class AttachmentAction extends Action
+{
+ /**
+ * Attachment object to show
+ */
+
+ var $attachment = null;
+
+ /**
+ * Load attributes based on database arguments
+ *
+ * Loads all the DB stuff
+ *
+ * @param array $args $_REQUEST array
+ *
+ * @return success flag
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $id = $this->arg('attachment');
+
+ $this->attachment = File::staticGet($id);
+
+ if (!$this->attachment) {
+ $this->clientError(_('No such attachment.'), 404);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Is this action read-only?
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * Title of the page
+ *
+ * @return string title of the page
+ */
+ function title()
+ {
+ $a = new Attachment($this->attachment);
+ return $a->title();
+ }
+
+ /**
+ * Last-modified date for page
+ *
+ * When was the content of this page last modified? Based on notice,
+ * profile, avatar.
+ *
+ * @return int last-modified date as unix timestamp
+ */
+/*
+ function lastModified()
+ {
+ return max(strtotime($this->notice->created),
+ strtotime($this->profile->modified),
+ ($this->avatar) ? strtotime($this->avatar->modified) : 0);
+ }
+*/
+
+ /**
+ * An entity tag for this page
+ *
+ * Shows the ETag for the page, based on the notice ID and timestamps
+ * for the notice, profile, and avatar. It's weak, since we change
+ * the date text "one hour ago", etc.
+ *
+ * @return string etag
+ */
+/*
+ function etag()
+ {
+ $avtime = ($this->avatar) ?
+ strtotime($this->avatar->modified) : 0;
+
+ return 'W/"' . implode(':', array($this->arg('action'),
+ common_language(),
+ $this->notice->id,
+ strtotime($this->notice->created),
+ strtotime($this->profile->modified),
+ $avtime)) . '"';
+ }
+*/
+
+
+ /**
+ * Handle input
+ *
+ * Only handles get, so just show the page.
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showPage();
+ }
+
+ /**
+ * Don't show local navigation
+ *
+ * @return void
+ */
+
+ function showLocalNavBlock()
+ {
+ }
+
+ /**
+ * Fill the content area of the page
+ *
+ * Shows a single notice list item.
+ *
+ * @return void
+ */
+
+ function showContent()
+ {
+ $this->elementStart('ul', array('class' => 'attachments'));
+ $ali = new Attachment($this->attachment, $this);
+ $cnt = $ali->show();
+ $this->elementEnd('ul');
+ }
+
+ /**
+ * Don't show page notice
+ *
+ * @return void
+ */
+
+ function showPageNoticeBlock()
+ {
+ }
+
+ /**
+ * Show aside: this attachments appears in what notices
+ *
+ * @return void
+ */
+ function showSections() {
+ $ns = new AttachmentNoticeSection($this);
+ $ns->show();
+ $atcs = new AttachmentTagCloudSection($this);
+ $atcs->show();
+ }
+}
+
diff --git a/actions/attachment_ajax.php b/actions/attachment_ajax.php
new file mode 100644
index 000000000..1620b27dd
--- /dev/null
+++ b/actions/attachment_ajax.php
@@ -0,0 +1,141 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Show notice attachments
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2008-2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+require_once INSTALLDIR.'/actions/attachment.php';
+
+/**
+ * Show notice attachments
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class Attachment_ajaxAction extends AttachmentAction
+{
+ /**
+ * Load attributes based on database arguments
+ *
+ * Loads all the DB stuff
+ *
+ * @param array $args $_REQUEST array
+ *
+ * @return success flag
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ if (!$this->attachment) {
+ $this->clientError(_('No such attachment.'), 404);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Show page, a template method.
+ *
+ * @return nothing
+ */
+ function showPage()
+ {
+ if (Event::handle('StartShowBody', array($this))) {
+ $this->showCore();
+ Event::handle('EndShowBody', array($this));
+ }
+ }
+
+ /**
+ * Show core.
+ *
+ * Shows local navigation, content block and aside.
+ *
+ * @return nothing
+ */
+ function showCore()
+ {
+ $this->elementStart('div', array('id' => 'core'));
+ if (Event::handle('StartShowContentBlock', array($this))) {
+ $this->showContentBlock();
+ Event::handle('EndShowContentBlock', array($this));
+ }
+ $this->elementEnd('div');
+ }
+
+
+
+ /**
+ * Last-modified date for page
+ *
+ * When was the content of this page last modified? Based on notice,
+ * profile, avatar.
+ *
+ * @return int last-modified date as unix timestamp
+ */
+/*
+ function lastModified()
+ {
+ return max(strtotime($this->notice->created),
+ strtotime($this->profile->modified),
+ ($this->avatar) ? strtotime($this->avatar->modified) : 0);
+ }
+*/
+
+ /**
+ * An entity tag for this page
+ *
+ * Shows the ETag for the page, based on the notice ID and timestamps
+ * for the notice, profile, and avatar. It's weak, since we change
+ * the date text "one hour ago", etc.
+ *
+ * @return string etag
+ */
+/*
+ function etag()
+ {
+ $avtime = ($this->avatar) ?
+ strtotime($this->avatar->modified) : 0;
+
+ return 'W/"' . implode(':', array($this->arg('action'),
+ common_language(),
+ $this->notice->id,
+ strtotime($this->notice->created),
+ strtotime($this->profile->modified),
+ $avtime)) . '"';
+ }
+*/
+}
+
diff --git a/actions/attachments.php b/actions/attachments.php
new file mode 100644
index 000000000..6b31c839d
--- /dev/null
+++ b/actions/attachments.php
@@ -0,0 +1,292 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Show notice attachments
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2008-2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+//require_once INSTALLDIR.'/lib/personalgroupnav.php';
+//require_once INSTALLDIR.'/lib/feedlist.php';
+require_once INSTALLDIR.'/lib/attachmentlist.php';
+
+/**
+ * Show notice attachments
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class AttachmentsAction extends Action
+{
+ /**
+ * Notice object to show
+ */
+
+ var $notice = null;
+
+ /**
+ * Profile of the notice object
+ */
+
+ var $profile = null;
+
+ /**
+ * Avatar of the profile of the notice object
+ */
+
+ var $avatar = null;
+
+ /**
+ * Is this action read-only?
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * Last-modified date for page
+ *
+ * When was the content of this page last modified? Based on notice,
+ * profile, avatar.
+ *
+ * @return int last-modified date as unix timestamp
+ */
+
+ function lastModified()
+ {
+ return max(strtotime($this->notice->created),
+ strtotime($this->profile->modified),
+ ($this->avatar) ? strtotime($this->avatar->modified) : 0);
+ }
+
+ /**
+ * An entity tag for this page
+ *
+ * Shows the ETag for the page, based on the notice ID and timestamps
+ * for the notice, profile, and avatar. It's weak, since we change
+ * the date text "one hour ago", etc.
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ $avtime = ($this->avatar) ?
+ strtotime($this->avatar->modified) : 0;
+
+ return 'W/"' . implode(':', array($this->arg('action'),
+ common_language(),
+ $this->notice->id,
+ strtotime($this->notice->created),
+ strtotime($this->profile->modified),
+ $avtime)) . '"';
+ }
+
+ /**
+ * Title of the page
+ *
+ * @return string title of the page
+ */
+
+ function title()
+ {
+ return sprintf(_('%1$s\'s status on %2$s'),
+ $this->profile->nickname,
+ common_exact_date($this->notice->created));
+ }
+
+
+ /**
+ * Load attributes based on database arguments
+ *
+ * Loads all the DB stuff
+ *
+ * @param array $args $_REQUEST array
+ *
+ * @return success flag
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $id = $this->arg('notice');
+
+ $this->notice = Notice::staticGet($id);
+
+ if (!$this->notice) {
+ $this->clientError(_('No such notice.'), 404);
+ return false;
+ }
+
+
+/*
+// STOP if there are no attachments
+// maybe even redirect if there's a single one
+// RYM FIXME TODO
+ $this->clientError(_('No such attachment.'), 404);
+ return false;
+
+*/
+
+
+
+
+ $this->profile = $this->notice->getProfile();
+
+ if (!$this->profile) {
+ $this->serverError(_('Notice has no profile'), 500);
+ return false;
+ }
+
+ $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
+ return true;
+ }
+
+
+
+ /**
+ * Handle input
+ *
+ * Only handles get, so just show the page.
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ if ($this->notice->is_local == 0) {
+ if (!empty($this->notice->url)) {
+ common_redirect($this->notice->url, 301);
+ } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) {
+ common_redirect($this->notice->uri, 301);
+ }
+ } else {
+ $f2p = new File_to_post;
+ $f2p->post_id = $this->notice->id;
+ $file = new File;
+ $file->joinAdd($f2p);
+ $file->selectAdd();
+ $file->selectAdd('file.id as id');
+ $count = $file->find(true);
+ if (!$count) return;
+ if (1 === $count) {
+ common_redirect(common_local_url('attachment', array('attachment' => $file->id)), 301);
+ } else {
+ $this->showPage();
+ }
+ }
+ }
+
+ /**
+ * Don't show local navigation
+ *
+ * @return void
+ */
+
+ function showLocalNavBlock()
+ {
+ }
+
+ /**
+ * Fill the content area of the page
+ *
+ * Shows a single notice list item.
+ *
+ * @return void
+ */
+
+ function showContent()
+ {
+ $al = new AttachmentList($this->notice, $this);
+ $cnt = $al->show();
+ }
+
+ /**
+ * Don't show page notice
+ *
+ * @return void
+ */
+
+ function showPageNoticeBlock()
+ {
+ }
+
+ /**
+ * Don't show aside
+ *
+ * @return void
+ */
+
+ function showAside() {
+ }
+
+ /**
+ * Extra <head> content
+ *
+ * We show the microid(s) for the author, if any.
+ *
+ * @return void
+ */
+
+ function extraHead()
+ {
+ $user = User::staticGet($this->profile->id);
+
+ if (!$user) {
+ return;
+ }
+
+ if ($user->emailmicroid && $user->email && $this->notice->uri) {
+ $id = new Microid('mailto:'. $user->email,
+ $this->notice->uri);
+ $this->element('meta', array('name' => 'microid',
+ 'content' => $id->toString()));
+ }
+
+ if ($user->jabbermicroid && $user->jabber && $this->notice->uri) {
+ $id = new Microid('xmpp:', $user->jabber,
+ $this->notice->uri);
+ $this->element('meta', array('name' => 'microid',
+ 'content' => $id->toString()));
+ }
+ }
+}
+
diff --git a/actions/attachments_ajax.php b/actions/attachments_ajax.php
new file mode 100644
index 000000000..402d8b5e7
--- /dev/null
+++ b/actions/attachments_ajax.php
@@ -0,0 +1,115 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Show notice attachments
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @copyright 2008-2009 Control Yourself, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+if (!defined('LACONICA')) {
+ exit(1);
+}
+
+//require_once INSTALLDIR.'/lib/personalgroupnav.php';
+//require_once INSTALLDIR.'/lib/feedlist.php';
+require_once INSTALLDIR.'/actions/attachments.php';
+
+/**
+ * Show notice attachments
+ *
+ * @category Personal
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class Attachments_ajaxAction extends AttachmentsAction
+{
+ function showContent()
+ {
+ }
+
+ /**
+ * Fill the content area of the page
+ *
+ * Shows a single notice list item.
+ *
+ * @return void
+ */
+
+ function showContentBlock()
+ {
+ $al = new AttachmentList($this->notice, $this);
+ $cnt = $al->show();
+ }
+
+ /**
+ * Extra <head> content
+ *
+ * We show the microid(s) for the author, if any.
+ *
+ * @return void
+ */
+
+ function extraHead()
+ {
+ }
+
+
+ /**
+ * Show page, a template method.
+ *
+ * @return nothing
+ */
+ function showPage()
+ {
+ if (Event::handle('StartShowBody', array($this))) {
+ $this->showCore();
+ Event::handle('EndShowBody', array($this));
+ }
+ }
+
+ /**
+ * Show core.
+ *
+ * Shows local navigation, content block and aside.
+ *
+ * @return nothing
+ */
+ function showCore()
+ {
+ $this->elementStart('div', array('id' => 'core'));
+ if (Event::handle('StartShowContentBlock', array($this))) {
+ $this->showContentBlock();
+ Event::handle('EndShowContentBlock', array($this));
+ }
+ $this->elementEnd('div');
+ }
+
+
+
+
+}
+
diff --git a/actions/conversation.php b/actions/conversation.php
index 05cfb76e3..ef189016a 100644
--- a/actions/conversation.php
+++ b/actions/conversation.php
@@ -11,7 +11,7 @@
* @link http://laconi.ca/
*
* Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * Copyright (C) 2009, Control Yourself, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -31,7 +31,7 @@ if (!defined('LACONICA')) {
exit(1);
}
-require_once(INSTALLDIR.'/lib/noticelist.php');
+require_once INSTALLDIR.'/lib/noticelist.php';
/**
* Conversation tree in the browser
@@ -42,9 +42,10 @@ require_once(INSTALLDIR.'/lib/noticelist.php');
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
* @link http://laconi.ca/
*/
+
class ConversationAction extends Action
{
- var $id = null;
+ var $id = null;
var $page = null;
/**
@@ -69,24 +70,47 @@ class ConversationAction extends Action
return true;
}
+ /**
+ * Handle the action
+ *
+ * @param array $args Web and URL arguments
+ *
+ * @return void
+ */
+
function handle($args)
{
parent::handle($args);
$this->showPage();
}
+ /**
+ * Returns the page title
+ *
+ * @return string page title
+ */
+
function title()
{
return _("Conversation");
}
+ /**
+ * Show content.
+ *
+ * Display a hierarchical unordered list in the content area.
+ * Uses ConversationTree to do most of the heavy lifting.
+ *
+ * @return void
+ */
+
function showContent()
{
// FIXME this needs to be a tree, not a list
$qry = 'SELECT * FROM notice WHERE conversation = %s ';
- $offset = ($this->page-1)*NOTICES_PER_PAGE;
+ $offset = ($this->page-1) * NOTICES_PER_PAGE;
$limit = NOTICES_PER_PAGE + 1;
$txt = sprintf($qry, $this->id);
@@ -95,9 +119,9 @@ class ConversationAction extends Action
'notice:conversation:'.$this->id,
$offset, $limit);
- $nl = new NoticeList($notices, $this);
+ $ct = new ConversationTree($notices, $this);
- $cnt = $nl->show();
+ $cnt = $ct->show();
$this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
$this->page, 'conversation', array('id' => $this->id));
@@ -105,3 +129,170 @@ class ConversationAction extends Action
}
+/**
+ * Conversation tree
+ *
+ * The widget class for displaying a hierarchical list of notices.
+ *
+ * @category Widget
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://laconi.ca/
+ */
+
+class ConversationTree extends NoticeList
+{
+ var $tree = null;
+ var $table = null;
+
+ /**
+ * Show the tree of notices
+ *
+ * @return void
+ */
+
+ function show()
+ {
+ $cnt = 0;
+
+ $this->tree = array();
+ $this->table = array();
+
+ while ($this->notice->fetch()) {
+
+ $cnt++;
+
+ $id = $this->notice->id;
+ $notice = clone($this->notice);
+
+ $this->table[$id] = $notice;
+
+ if (is_null($notice->reply_to)) {
+ $this->tree['root'] = array($notice->id);
+ } else if (array_key_exists($notice->reply_to, $this->tree)) {
+ $this->tree[$notice->reply_to][] = $notice->id;
+ } else {
+ $this->tree[$notice->reply_to] = array($notice->id);
+ }
+ }
+
+ $this->out->elementStart('div', array('id' =>'notices_primary'));
+ $this->out->element('h2', null, _('Notices'));
+ $this->out->elementStart('ul', array('class' => 'notices'));
+
+ if (array_key_exists('root', $this->tree)) {
+ $rootid = $this->tree['root'][0];
+ $this->showNoticePlus($rootid);
+ }
+
+ $this->out->elementEnd('ul');
+ $this->out->elementEnd('div');
+
+ return $cnt;
+ }
+
+ /**
+ * Shows a notice plus its list of children.
+ *
+ * @param integer $id ID of the notice to show
+ *
+ * @return void
+ */
+
+ function showNoticePlus($id)
+ {
+ $notice = $this->table[$id];
+
+ // We take responsibility for doing the li
+
+ $this->out->elementStart('li', array('class' => 'hentry notice',
+ 'id' => 'notice-' . $this->notice->id));
+
+ $item = $this->newListItem($notice);
+ $item->show();
+
+ if (array_key_exists($id, $this->tree)) {
+ $children = $this->tree[$id];
+
+ $this->out->elementStart('ul', array('class' => 'notices'));
+
+ foreach ($children as $child) {
+ $this->showNoticePlus($child);
+ }
+
+ $this->out->elementEnd('ul');
+ }
+
+ $this->out->elementEnd('li');
+ }
+
+ /**
+ * Override parent class to return our preferred item.
+ *
+ * @param Notice $notice Notice to display
+ *
+ * @return NoticeListItem a list item to show
+ */
+
+ function newListItem($notice)
+ {
+ return new ConversationTreeItem($notice, $this->out);
+ }
+}
+
+/**
+ * Conversation tree list item
+ *
+ * Special class of NoticeListItem for use inside conversation trees.
+ *
+ * @category Widget
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://laconi.ca/
+ */
+
+class ConversationTreeItem extends NoticeListItem
+{
+ /**
+ * start a single notice.
+ *
+ * The default creates the <li>; we skip, since the ConversationTree
+ * takes care of that.
+ *
+ * @return void
+ */
+
+ function showStart()
+ {
+ return;
+ }
+
+ /**
+ * finish the notice
+ *
+ * The default closes the <li>; we skip, since the ConversationTree
+ * takes care of that.
+ *
+ * @return void
+ */
+
+ function showEnd()
+ {
+ return;
+ }
+
+ /**
+ * show link to notice conversation page
+ *
+ * Since we're only used on the conversation page, we skip this
+ *
+ * @return void
+ */
+
+ function showContext()
+ {
+ return;
+ }
+} \ No newline at end of file
diff --git a/actions/deletenotice.php b/actions/deletenotice.php
index 6c350b33a..e733f9650 100644
--- a/actions/deletenotice.php
+++ b/actions/deletenotice.php
@@ -112,8 +112,8 @@ class DeletenoticeAction extends DeleteAction
$this->hidden('token', common_session_token());
$this->hidden('notice', $this->trimmed('notice'));
$this->element('p', null, _('Are you sure you want to delete this notice?'));
- $this->submit('form_action-yes', _('Yes'), 'submit form_action-primary', 'yes');
- $this->submit('form_action-no', _('No'), 'submit form_action-secondary', 'no');
+ $this->submit('form_action-no', _('No'), 'submit form_action-primary', 'no', _("Do not delete this notice"));
+ $this->submit('form_action-yes', _('Yes'), 'submit form_action-secondary', 'yes', _('Delete this notice'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
diff --git a/actions/designsettings.php b/actions/designsettings.php
index cdd950e78..315e5a199 100644
--- a/actions/designsettings.php
+++ b/actions/designsettings.php
@@ -76,14 +76,22 @@ class DesignsettingsAction extends AccountSettingsAction
'action' =>
common_local_url('designsettings')));
$this->elementStart('fieldset');
-// $this->element('legend', null, _('Design settings'));
$this->hidden('token', common_session_token());
$this->elementStart('fieldset', array('id' => 'settings_design_background-image'));
$this->element('legend', null, _('Change background image'));
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
- $this->element('p', null, _('Upload background image'));
+ $this->element('label', array('for' => 'design_ background-image_file'),
+ _('Upload file'));
+ $this->element('input', array('name' => 'design_background-image_file',
+ 'type' => 'file',
+ 'id' => 'design_background-image_file'));
+ $this->element('p', 'form_guide', _('You can upload your personal background image. The maximum file size is 2Mb.'));
+ $this->element('input', array('name' => 'MAX_FILE_SIZE',
+ 'type' => 'hidden',
+ 'id' => 'MAX_FILE_SIZE',
+ 'value' => ImageFile::maxFileSizeInt()));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->elementEnd('fieldset');
@@ -91,28 +99,59 @@ class DesignsettingsAction extends AccountSettingsAction
$this->elementStart('fieldset', array('id' => 'settings_design_color'));
$this->element('legend', null, _('Change colours'));
$this->elementStart('ul', 'form_data');
- $this->elementStart('li');
- $this->input('color-1', _('Background color'), '#F0F2F5', null);
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('color-2', _('Content background color'), '#FFFFFF', null);
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('color-3', _('Sidebar background color'), '#CEE1E9', null);
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('color-4', _('Text color'), '#000000', null);
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('color-5', _('Link color'), '#002E6E', null);
- $this->elementEnd('li');
- $this->elementEnd('ul');
- $this->element('div', array('id' => 'color-picker'));
- $this->elementEnd('fieldset');
+ //This is a JSON object in the DB field. Here for testing. Remove later.
+ $userSwatch = '{"body":{"background-color":"#F0F2F5"},
+ "#content":{"background-color":"#FFFFFF"},
+ "#aside_primary":{"background-color":"#CEE1E9"},
+ "html body":{"color":"#000000"},
+ "a":{"color":"#002E6E"}}';
+
+ //Default theme swatch -- Where should this be stored?
+ $defaultSwatch = array('body' => array('background-color' => '#F0F2F5'),
+ '#content' => array('background-color' => '#FFFFFF'),
+ '#aside_primary' => array('background-color' => '#CEE1E9'),
+ 'html body' => array('color' => '#000000'),
+ 'a' => array('color' => '#002E6E'));
+
+ $userSwatch = ($userSwatch) ? json_decode($userSwatch, true) : $defaultSwatch;
+
+ $s = 0;
+ $labelSwatch = array('Background',
+ 'Content',
+ 'Sidebar',
+ 'Text',
+ 'Links');
+ foreach($userSwatch as $propertyvalue => $value) {
+ $foo = array_values($value);
+ $this->elementStart('li');
+ $this->element('label', array('for' => 'swatch-'.$s), _($labelSwatch[$s]));
+ $this->element('input', array('name' => 'swatch-'.$s, //prefer swatch[$s] ?
+ 'type' => 'text',
+ 'id' => 'swatch-'.$s,
+ 'class' => 'swatch',
+ 'maxlength' => '7',
+ 'size' => '7',
+ 'value' => $foo[0]));
+ $this->elementEnd('li');
+ $s++;
+ }
- $this->submit('save', _('Save'));
+ $this->elementEnd('ul');
+ $this->elementEnd('fieldset');
+ $this->element('input', array('id' => 'settings_design_reset',
+ 'type' => 'reset',
+ 'value' => 'Reset',
+ 'class' => 'submit form_action-primary',
+ 'title' => _('Reset back to default')));
+ $this->submit('save', _('Save'), 'submit form_action-secondary', 'save', _('Save design'));
+
+/*TODO: Check submitted form values:
+json_encode(form values)
+if submitted Swatch == DefaultSwatch, don't store in DB.
+else store in BD
+*/
$this->elementEnd('fieldset');
$this->elementEnd('form');
@@ -187,7 +226,7 @@ class DesignsettingsAction extends AccountSettingsAction
/**
- * Add the jCrop stylesheet
+ * Add the Farbtastic stylesheet
*
* @return void
*/
@@ -205,7 +244,7 @@ class DesignsettingsAction extends AccountSettingsAction
}
/**
- * Add the jCrop scripts
+ * Add the Farbtastic scripts
*
* @return void
*/
@@ -214,14 +253,12 @@ class DesignsettingsAction extends AccountSettingsAction
{
parent::showScripts();
-// if ($this->mode == 'crop') {
- $farbtasticPack = common_path('js/farbtastic/farbtastic.js');
- $farbtasticGo = common_path('js/farbtastic/farbtastic.go.js');
+ $farbtasticPack = common_path('js/farbtastic/farbtastic.js');
+ $farbtasticGo = common_path('js/farbtastic/farbtastic.go.js');
- $this->element('script', array('type' => 'text/javascript',
- 'src' => $farbtasticPack));
- $this->element('script', array('type' => 'text/javascript',
- 'src' => $farbtasticGo));
-// }
+ $this->element('script', array('type' => 'text/javascript',
+ 'src' => $farbtasticPack));
+ $this->element('script', array('type' => 'text/javascript',
+ 'src' => $farbtasticGo));
}
}
diff --git a/actions/favoritesrss.php b/actions/favoritesrss.php
index f85bf1b19..6b46b8dec 100644
--- a/actions/favoritesrss.php
+++ b/actions/favoritesrss.php
@@ -107,7 +107,7 @@ class FavoritesrssAction extends Rss10Action
$c = array('url' => common_local_url('favoritesrss',
array('nickname' =>
$user->nickname)),
- 'title' => sprintf(_("%s favorite notices"), $user->nickname),
+ 'title' => sprintf(_("%s's favorite notices"), $user->nickname),
'link' => common_local_url('showfavorites',
array('nickname' =>
$user->nickname)),
diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php
index 952185742..b08b96df6 100644
--- a/actions/finishopenidlogin.php
+++ b/actions/finishopenidlogin.php
@@ -191,11 +191,28 @@ class FinishopenidloginAction extends Action
{
# FIXME: save invite code before redirect, and check here
- if (common_config('site', 'closed') || common_config('site', 'inviteonly')) {
+ if (common_config('site', 'closed')) {
$this->clientError(_('Registration not allowed.'));
return;
}
+ $invite = null;
+
+ if (common_config('site', 'inviteonly')) {
+ $code = $_SESSION['invitecode'];
+ if (empty($code)) {
+ $this->clientError(_('Registration not allowed.'));
+ return;
+ }
+
+ $invite = Invitation::staticGet($code);
+
+ if (empty($invite)) {
+ $this->clientError(_('Not a valid invitation code.'));
+ return;
+ }
+ }
+
$nickname = $this->trimmed('newname');
if (!Validate::string($nickname, array('min_length' => 1,
@@ -257,10 +274,16 @@ class FinishopenidloginAction extends Action
# XXX: add language
# XXX: add timezone
- $user = User::register(array('nickname' => $nickname,
- 'email' => $email,
- 'fullname' => $fullname,
- 'location' => $location));
+ $args = array('nickname' => $nickname,
+ 'email' => $email,
+ 'fullname' => $fullname,
+ 'location' => $location);
+
+ if (!empty($invite)) {
+ $args['code'] = $invite->code;
+ }
+
+ $user = User::register($args);
$result = oid_link_user($user->id, $canonical, $display);
diff --git a/actions/grouprss.php b/actions/grouprss.php
index a9a2eef87..0b7280a11 100644
--- a/actions/grouprss.php
+++ b/actions/grouprss.php
@@ -34,7 +34,7 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR.'/lib/rssaction.php';
-define('MEMBERS_PER_SECTION', 81);
+define('MEMBERS_PER_SECTION', 27);
/**
* Group RSS feed
diff --git a/actions/logout.php b/actions/logout.php
index 9f3bfe247..c34b10987 100644
--- a/actions/logout.php
+++ b/actions/logout.php
@@ -70,10 +70,20 @@ class LogoutAction extends Action
if (!common_logged_in()) {
$this->clientError(_('Not logged in.'));
} else {
- common_set_user(null);
- common_real_login(false); // not logged in
- common_forgetme(); // don't log back in!
+ if (Event::handle('StartLogout', array($this))) {
+ $this->logout();
+ }
+ Event::handle('EndLogout', array($this));
+
common_redirect(common_local_url('public'), 303);
}
}
+
+ function logout()
+ {
+ common_set_user(null);
+ common_real_login(false); // not logged in
+ common_forgetme(); // don't log back in!
+ }
+
}
diff --git a/actions/newmessage.php b/actions/newmessage.php
index 82276ff34..52d4899ba 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -172,15 +172,54 @@ class NewmessageAction extends Action
$this->notify($user, $this->other, $message);
- $url = common_local_url('outbox', array('nickname' => $user->nickname));
+ if ($this->boolean('ajax')) {
+ $this->startHTML('text/xml;charset=utf-8');
+ $this->elementStart('head');
+ $this->element('title', null, _('Message sent'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $this->element('p', array('id' => 'command_result'),
+ sprintf(_('Direct message to %s sent'),
+ $this->other->nickname));
+ $this->elementEnd('body');
+ $this->elementEnd('html');
+ } else {
+ $url = common_local_url('outbox',
+ array('nickname' => $user->nickname));
+ common_redirect($url, 303);
+ }
+ }
- common_redirect($url, 303);
+ /**
+ * Show an Ajax-y error message
+ *
+ * Goes back to the browser, where it's shown in a popup.
+ *
+ * @param string $msg Message to show
+ *
+ * @return void
+ */
+
+ function ajaxErrorMsg($msg)
+ {
+ $this->startHTML('text/xml;charset=utf-8', true);
+ $this->elementStart('head');
+ $this->element('title', null, _('Ajax Error'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $this->element('p', array('id' => 'error'), $msg);
+ $this->elementEnd('body');
+ $this->elementEnd('html');
}
function showForm($msg = null)
{
- $this->msg = $msg;
+ if ($msg && $this->boolean('ajax')) {
+ $this->ajaxErrorMsg($msg);
+ return;
+ }
+ $this->msg = $msg;
$this->showPage();
}
diff --git a/actions/newnotice.php b/actions/newnotice.php
index cbd04c58b..ae0ff9636 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -158,7 +158,8 @@ class NewnoticeAction extends Action
$replyto = 'false';
}
- $notice = Notice::saveNew($user->id, $content, 'web', 1,
+// $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
+ $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
($replyto == 'false') ? null : $replyto);
if (is_string($notice)) {
@@ -166,6 +167,8 @@ class NewnoticeAction extends Action
return;
}
+ $this->saveUrls($notice);
+
common_broadcast_notice($notice);
if ($this->boolean('ajax')) {
@@ -191,6 +194,24 @@ class NewnoticeAction extends Action
}
}
+ /** save all urls in the notice to the db
+ *
+ * follow redirects and save all available file information
+ * (mimetype, date, size, oembed, etc.)
+ *
+ * @param class $notice Notice to pull URLs from
+ *
+ * @return void
+ */
+ function saveUrls($notice) {
+ common_replace_urls_callback($notice->content, array($this, 'saveUrl'), $notice->id);
+ }
+
+ function saveUrl($data) {
+ list($url, $notice_id) = $data;
+ $zzz = File::processNew($url, $notice_id);
+ }
+
/**
* Show an Ajax-y error message
*
diff --git a/actions/openidsettings.php b/actions/openidsettings.php
index 92469d20f..5f59ebc01 100644
--- a/actions/openidsettings.php
+++ b/actions/openidsettings.php
@@ -67,8 +67,8 @@ class OpenidsettingsAction extends AccountSettingsAction
function getInstructions()
{
- return _('[OpenID](%%doc.openid%%) lets you log into many sites ' .
- ' with the same user account. '.
+ return _('[OpenID](%%doc.openid%%) lets you log into many sites' .
+ ' with the same user account.'.
' Manage your associated OpenIDs from here.');
}
diff --git a/actions/profilesettings.php b/actions/profilesettings.php
index 60f7c0796..fb847680b 100644
--- a/actions/profilesettings.php
+++ b/actions/profilesettings.php
@@ -91,67 +91,68 @@ class ProfilesettingsAction extends AccountSettingsAction
$this->element('legend', null, _('Profile information'));
$this->hidden('token', common_session_token());
- # too much common patterns here... abstractable?
-
+ // too much common patterns here... abstractable?
$this->elementStart('ul', 'form_data');
- $this->elementStart('li');
- $this->input('nickname', _('Nickname'),
- ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname,
- _('1-64 lowercase letters or numbers, no punctuation or spaces'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('fullname', _('Full name'),
- ($this->arg('fullname')) ? $this->arg('fullname') : $profile->fullname);
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('homepage', _('Homepage'),
- ($this->arg('homepage')) ? $this->arg('homepage') : $profile->homepage,
- _('URL of your homepage, blog, or profile on another site'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->textarea('bio', _('Bio'),
- ($this->arg('bio')) ? $this->arg('bio') : $profile->bio,
- _('Describe yourself and your interests in 140 chars'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('location', _('Location'),
- ($this->arg('location')) ? $this->arg('location') : $profile->location,
- _('Where you are, like "City, State (or Region), Country"'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('tags', _('Tags'),
- ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $user->getSelfTags()),
- _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $language = common_language();
- $this->dropdown('language', _('Language'),
- get_nice_language_list(), _('Preferred language'),
- true, $language);
- $this->elementEnd('li');
- $timezone = common_timezone();
- $timezones = array();
- foreach(DateTimeZone::listIdentifiers() as $k => $v) {
- $timezones[$v] = $v;
+ if (Event::handle('StartProfileFormData', array($this))) {
+ $this->elementStart('li');
+ $this->input('nickname', _('Nickname'),
+ ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname,
+ _('1-64 lowercase letters or numbers, no punctuation or spaces'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->input('fullname', _('Full name'),
+ ($this->arg('fullname')) ? $this->arg('fullname') : $profile->fullname);
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->input('homepage', _('Homepage'),
+ ($this->arg('homepage')) ? $this->arg('homepage') : $profile->homepage,
+ _('URL of your homepage, blog, or profile on another site'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->textarea('bio', _('Bio'),
+ ($this->arg('bio')) ? $this->arg('bio') : $profile->bio,
+ _('Describe yourself and your interests in 140 chars'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->input('location', _('Location'),
+ ($this->arg('location')) ? $this->arg('location') : $profile->location,
+ _('Where you are, like "City, State (or Region), Country"'));
+ $this->elementEnd('li');
+ Event::handle('EndProfileFormData', array($this));
+ $this->elementStart('li');
+ $this->input('tags', _('Tags'),
+ ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $user->getSelfTags()),
+ _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $language = common_language();
+ $this->dropdown('language', _('Language'),
+ get_nice_language_list(), _('Preferred language'),
+ false, $language);
+ $this->elementEnd('li');
+ $timezone = common_timezone();
+ $timezones = array();
+ foreach(DateTimeZone::listIdentifiers() as $k => $v) {
+ $timezones[$v] = $v;
+ }
+ $this->elementStart('li');
+ $this->dropdown('timezone', _('Timezone'),
+ $timezones, _('What timezone are you normally in?'),
+ true, $timezone);
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->checkbox('autosubscribe',
+ _('Automatically subscribe to whoever '.
+ 'subscribes to me (best for non-humans)'),
+ ($this->arg('autosubscribe')) ?
+ $this->boolean('autosubscribe') : $user->autosubscribe);
+ $this->elementEnd('li');
}
- $this->elementStart('li');
- $this->dropdown('timezone', _('Timezone'),
- $timezones, _('What timezone are you normally in?'),
- true, $timezone);
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->checkbox('autosubscribe',
- _('Automatically subscribe to whoever '.
- 'subscribes to me (best for non-humans)'),
- ($this->arg('autosubscribe')) ?
- $this->boolean('autosubscribe') : $user->autosubscribe);
- $this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('save', _('Save'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
-
}
/**
@@ -165,158 +166,158 @@ class ProfilesettingsAction extends AccountSettingsAction
function handlePost()
{
- # CSRF protection
-
+ // CSRF protection
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
$this->showForm(_('There was a problem with your session token. '.
- 'Try again, please.'));
+ 'Try again, please.'));
return;
}
- $nickname = $this->trimmed('nickname');
- $fullname = $this->trimmed('fullname');
- $homepage = $this->trimmed('homepage');
- $bio = $this->trimmed('bio');
- $location = $this->trimmed('location');
- $autosubscribe = $this->boolean('autosubscribe');
- $language = $this->trimmed('language');
- $timezone = $this->trimmed('timezone');
- $tagstring = $this->trimmed('tags');
-
- # Some validation
-
- if (!Validate::string($nickname, array('min_length' => 1,
- 'max_length' => 64,
- 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
- $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
- return;
- } else if (!User::allowed_nickname($nickname)) {
- $this->showForm(_('Not a valid nickname.'));
- return;
- } else if (!is_null($homepage) && (strlen($homepage) > 0) &&
- !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
- $this->showForm(_('Homepage is not a valid URL.'));
- return;
- } else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
- $this->showForm(_('Full name is too long (max 255 chars).'));
- return;
- } else if (!is_null($bio) && mb_strlen($bio) > 140) {
- $this->showForm(_('Bio is too long (max 140 chars).'));
- return;
- } else if (!is_null($location) && mb_strlen($location) > 255) {
- $this->showForm(_('Location is too long (max 255 chars).'));
- return;
- } else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
- $this->showForm(_('Timezone not selected.'));
- return;
- } else if ($this->nicknameExists($nickname)) {
- $this->showForm(_('Nickname already in use. Try another one.'));
- return;
- } else if (!is_null($language) && strlen($language) > 50) {
- $this->showForm(_('Language is too long (max 50 chars).'));
- return;
- }
+ if (Event::handle('StartProfileSaveForm', array($this))) {
+
+ $nickname = $this->trimmed('nickname');
+ $fullname = $this->trimmed('fullname');
+ $homepage = $this->trimmed('homepage');
+ $bio = $this->trimmed('bio');
+ $location = $this->trimmed('location');
+ $autosubscribe = $this->boolean('autosubscribe');
+ $language = $this->trimmed('language');
+ $timezone = $this->trimmed('timezone');
+ $tagstring = $this->trimmed('tags');
+
+ // Some validation
+ if (!Validate::string($nickname, array('min_length' => 1,
+ 'max_length' => 64,
+ 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) {
+ $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.'));
+ return;
+ } else if (!User::allowed_nickname($nickname)) {
+ $this->showForm(_('Not a valid nickname.'));
+ return;
+ } else if (!is_null($homepage) && (strlen($homepage) > 0) &&
+ !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) {
+ $this->showForm(_('Homepage is not a valid URL.'));
+ return;
+ } else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
+ $this->showForm(_('Full name is too long (max 255 chars).'));
+ return;
+ } else if (!is_null($bio) && mb_strlen($bio) > 140) {
+ $this->showForm(_('Bio is too long (max 140 chars).'));
+ return;
+ } else if (!is_null($location) && mb_strlen($location) > 255) {
+ $this->showForm(_('Location is too long (max 255 chars).'));
+ return;
+ } else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) {
+ $this->showForm(_('Timezone not selected.'));
+ return;
+ } else if ($this->nicknameExists($nickname)) {
+ $this->showForm(_('Nickname already in use. Try another one.'));
+ return;
+ } else if (!is_null($language) && strlen($language) > 50) {
+ $this->showForm(_('Language is too long (max 50 chars).'));
+ return;
+ }
- if ($tagstring) {
- $tags = array_map('common_canonical_tag', preg_split('/[\s,]+/', $tagstring));
- } else {
- $tags = array();
- }
+ if ($tagstring) {
+ $tags = array_map('common_canonical_tag', preg_split('/[\s,]+/', $tagstring));
+ } else {
+ $tags = array();
+ }
- foreach ($tags as $tag) {
- if (!common_valid_profile_tag($tag)) {
- $this->showForm(sprintf(_('Invalid tag: "%s"'), $tag));
- return;
+ foreach ($tags as $tag) {
+ if (!common_valid_profile_tag($tag)) {
+ $this->showForm(sprintf(_('Invalid tag: "%s"'), $tag));
+ return;
+ }
}
- }
- $user = common_current_user();
+ $user = common_current_user();
- $user->query('BEGIN');
+ $user->query('BEGIN');
- if ($user->nickname != $nickname ||
- $user->language != $language ||
- $user->timezone != $timezone) {
+ if ($user->nickname != $nickname ||
+ $user->language != $language ||
+ $user->timezone != $timezone) {
- common_debug('Updating user nickname from ' . $user->nickname . ' to ' . $nickname,
- __FILE__);
- common_debug('Updating user language from ' . $user->language . ' to ' . $language,
- __FILE__);
- common_debug('Updating user timezone from ' . $user->timezone . ' to ' . $timezone,
- __FILE__);
+ common_debug('Updating user nickname from ' . $user->nickname . ' to ' . $nickname,
+ __FILE__);
+ common_debug('Updating user language from ' . $user->language . ' to ' . $language,
+ __FILE__);
+ common_debug('Updating user timezone from ' . $user->timezone . ' to ' . $timezone,
+ __FILE__);
- $original = clone($user);
+ $original = clone($user);
- $user->nickname = $nickname;
- $user->language = $language;
- $user->timezone = $timezone;
+ $user->nickname = $nickname;
+ $user->language = $language;
+ $user->timezone = $timezone;
- $result = $user->updateKeys($original);
+ $result = $user->updateKeys($original);
- if ($result === false) {
- common_log_db_error($user, 'UPDATE', __FILE__);
- $this->serverError(_('Couldn\'t update user.'));
- return;
- } else {
- # Re-initialize language environment if it changed
- common_init_language();
+ if ($result === false) {
+ common_log_db_error($user, 'UPDATE', __FILE__);
+ $this->serverError(_('Couldn\'t update user.'));
+ return;
+ } else {
+ // Re-initialize language environment if it changed
+ common_init_language();
+ }
}
- }
-
- # XXX: XOR
- if ($user->autosubscribe ^ $autosubscribe) {
+// XXX: XOR
+ if ($user->autosubscribe ^ $autosubscribe) {
- $original = clone($user);
+ $original = clone($user);
- $user->autosubscribe = $autosubscribe;
+ $user->autosubscribe = $autosubscribe;
- $result = $user->update($original);
+ $result = $user->update($original);
- if ($result === false) {
- common_log_db_error($user, 'UPDATE', __FILE__);
- $this->serverError(_('Couldn\'t update user for autosubscribe.'));
- return;
+ if ($result === false) {
+ common_log_db_error($user, 'UPDATE', __FILE__);
+ $this->serverError(_('Couldn\'t update user for autosubscribe.'));
+ return;
+ }
}
- }
-
- $profile = $user->getProfile();
- $orig_profile = clone($profile);
+ $profile = $user->getProfile();
- $profile->nickname = $user->nickname;
- $profile->fullname = $fullname;
- $profile->homepage = $homepage;
- $profile->bio = $bio;
- $profile->location = $location;
- $profile->profileurl = common_profile_url($nickname);
+ $orig_profile = clone($profile);
- common_debug('Old profile: ' . common_log_objstring($orig_profile), __FILE__);
- common_debug('New profile: ' . common_log_objstring($profile), __FILE__);
+ $profile->nickname = $user->nickname;
+ $profile->fullname = $fullname;
+ $profile->homepage = $homepage;
+ $profile->bio = $bio;
+ $profile->location = $location;
+ $profile->profileurl = common_profile_url($nickname);
- $result = $profile->update($orig_profile);
+ common_debug('Old profile: ' . common_log_objstring($orig_profile), __FILE__);
+ common_debug('New profile: ' . common_log_objstring($profile), __FILE__);
- if (!$result) {
- common_log_db_error($profile, 'UPDATE', __FILE__);
- $this->serverError(_('Couldn\'t save profile.'));
- return;
- }
+ $result = $profile->update($orig_profile);
- # Set the user tags
+ if (!$result) {
+ common_log_db_error($profile, 'UPDATE', __FILE__);
+ $this->serverError(_('Couldn\'t save profile.'));
+ return;
+ }
- $result = $user->setSelfTags($tags);
+ // Set the user tags
+ $result = $user->setSelfTags($tags);
- if (!$result) {
- $this->serverError(_('Couldn\'t save tags.'));
- return;
- }
+ if (!$result) {
+ $this->serverError(_('Couldn\'t save tags.'));
+ return;
+ }
- $user->query('COMMIT');
+ $user->query('COMMIT');
+ Event::handle('EndProfileSaveForm', array($this));
+ common_broadcast_profile($profile);
- common_broadcast_profile($profile);
+ $this->showForm(_('Settings saved.'), true);
- $this->showForm(_('Settings saved.'), true);
+ }
}
function nicknameExists($nickname)
diff --git a/actions/recoverpassword.php b/actions/recoverpassword.php
index 620fe7eb8..82263fcd5 100644
--- a/actions/recoverpassword.php
+++ b/actions/recoverpassword.php
@@ -151,11 +151,11 @@ class RecoverpasswordAction extends Action
$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 ' .
+ ' the email address you have stored' .
' in your account.'));
} else if ($this->mode == 'reset') {
$this->element('p', null,
- _('You\'ve been identified. Enter a ' .
+ _('You\'ve been identified. Enter a' .
' new password below. '));
}
$this->elementEnd('div');
diff --git a/actions/register.php b/actions/register.php
index 5c6fe39d3..dcbbbdb6a 100644
--- a/actions/register.php
+++ b/actions/register.php
@@ -56,6 +56,45 @@ class RegisterAction extends Action
var $registered = false;
/**
+ * Prepare page to run
+ *
+ *
+ * @param $args
+ * @return string title
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ $this->code = $this->trimmed('code');
+
+ if (empty($this->code)) {
+ common_ensure_session();
+ if (array_key_exists('invitecode', $_SESSION)) {
+ $this->code = $_SESSION['invitecode'];
+ }
+ }
+
+ if (common_config('site', 'inviteonly') && empty($this->code)) {
+ $this->clientError(_('Sorry, only invited people can register.'));
+ return false;
+ }
+
+ if (!empty($this->code)) {
+ $this->invite = Invitation::staticGet('code', $this->code);
+ if (empty($this->invite)) {
+ $this->clientError(_('Sorry, invalid invitation code.'));
+ return false;
+ }
+ // Store this in case we need it
+ common_ensure_session();
+ $_SESSION['invitecode'] = $this->code;
+ }
+
+ return true;
+ }
+
+ /**
* Title of the page
*
* @return string title
@@ -108,109 +147,109 @@ class RegisterAction extends Action
function tryRegister()
{
- $token = $this->trimmed('token');
- if (!$token || $token != common_session_token()) {
- $this->showForm(_('There was a problem with your session token. '.
- 'Try again, please.'));
- return;
- }
-
- $nickname = $this->trimmed('nickname');
- $email = $this->trimmed('email');
- $fullname = $this->trimmed('fullname');
- $homepage = $this->trimmed('homepage');
- $bio = $this->trimmed('bio');
- $location = $this->trimmed('location');
-
- // We don't trim these... whitespace is OK in a password!
-
- $password = $this->arg('password');
- $confirm = $this->arg('confirm');
+ if (Event::handle('StartRegistrationTry', array($this))) {
+ $token = $this->trimmed('token');
+ if (!$token || $token != common_session_token()) {
+ $this->showForm(_('There was a problem with your session token. '.
+ 'Try again, please.'));
+ return;
+ }
- // invitation code, if any
+ $nickname = $this->trimmed('nickname');
+ $email = $this->trimmed('email');
+ $fullname = $this->trimmed('fullname');
+ $homepage = $this->trimmed('homepage');
+ $bio = $this->trimmed('bio');
+ $location = $this->trimmed('location');
- $code = $this->trimmed('code');
+ // We don't trim these... whitespace is OK in a password!
+ $password = $this->arg('password');
+ $confirm = $this->arg('confirm');
- $invite = null;
-
- if ($code) {
- $invite = Invitation::staticGet($code);
- }
+ // invitation code, if any
+ $code = $this->trimmed('code');
- if (common_config('site', 'inviteonly') && !($code && !empty($invite))) {
- $this->clientError(_('Sorry, only invited people can register.'));
- return;
- }
+ if ($code) {
+ $invite = Invitation::staticGet($code);
+ }
- // Input scrubbing
-
- $nickname = common_canonical_nickname($nickname);
- $email = common_canonical_email($email);
-
- if (!$this->boolean('license')) {
- $this->showForm(_('You can\'t register if you don\'t '.
- 'agree to the license.'));
- } else if ($email && !Validate::email($email, true)) {
- $this->showForm(_('Not a valid email address.'));
- } else if (!Validate::string($nickname, array('min_length' => 1,
- 'max_length' => 64,
- 'format' => NICKNAME_FMT))) {
- $this->showForm(_('Nickname must have only lowercase letters '.
- 'and numbers and no spaces.'));
- } else if ($this->nicknameExists($nickname)) {
- $this->showForm(_('Nickname already in use. Try another one.'));
- } else if (!User::allowed_nickname($nickname)) {
- $this->showForm(_('Not a valid nickname.'));
- } else if ($this->emailExists($email)) {
- $this->showForm(_('Email address already exists.'));
- } else if (!is_null($homepage) && (strlen($homepage) > 0) &&
- !Validate::uri($homepage,
- array('allowed_schemes' =>
- array('http', 'https')))) {
- $this->showForm(_('Homepage is not a valid URL.'));
- return;
- } else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
- $this->showForm(_('Full name is too long (max 255 chars).'));
- return;
- } else if (!is_null($bio) && mb_strlen($bio) > 140) {
- $this->showForm(_('Bio is too long (max 140 chars).'));
- return;
- } else if (!is_null($location) && mb_strlen($location) > 255) {
- $this->showForm(_('Location is too long (max 255 chars).'));
- return;
- } else if (strlen($password) < 6) {
- $this->showForm(_('Password must be 6 or more characters.'));
- return;
- } else if ($password != $confirm) {
- $this->showForm(_('Passwords don\'t match.'));
- } else if ($user = User::register(array('nickname' => $nickname,
- 'password' => $password,
- 'email' => $email,
- 'fullname' => $fullname,
- 'homepage' => $homepage,
- 'bio' => $bio,
- 'location' => $location,
- 'code' => $code))) {
- if (!$user) {
- $this->showForm(_('Invalid username or password.'));
+ if (common_config('site', 'inviteonly') && !($code && $invite)) {
+ $this->clientError(_('Sorry, only invited people can register.'));
return;
}
- // success!
- if (!common_set_user($user)) {
- $this->serverError(_('Error setting user.'));
+
+ // Input scrubbing
+ $nickname = common_canonical_nickname($nickname);
+ $email = common_canonical_email($email);
+
+ if (!$this->boolean('license')) {
+ $this->showForm(_('You can\'t register if you don\'t '.
+ 'agree to the license.'));
+ } else if ($email && !Validate::email($email, true)) {
+ $this->showForm(_('Not a valid email address.'));
+ } else if (!Validate::string($nickname, array('min_length' => 1,
+ 'max_length' => 64,
+ 'format' => NICKNAME_FMT))) {
+ $this->showForm(_('Nickname must have only lowercase letters '.
+ 'and numbers and no spaces.'));
+ } else if ($this->nicknameExists($nickname)) {
+ $this->showForm(_('Nickname already in use. Try another one.'));
+ } else if (!User::allowed_nickname($nickname)) {
+ $this->showForm(_('Not a valid nickname.'));
+ } else if ($this->emailExists($email)) {
+ $this->showForm(_('Email address already exists.'));
+ } else if (!is_null($homepage) && (strlen($homepage) > 0) &&
+ !Validate::uri($homepage,
+ array('allowed_schemes' =>
+ array('http', 'https')))) {
+ $this->showForm(_('Homepage is not a valid URL.'));
return;
+ } else if (!is_null($fullname) && mb_strlen($fullname) > 255) {
+ $this->showForm(_('Full name is too long (max 255 chars).'));
+ return;
+ } else if (!is_null($bio) && mb_strlen($bio) > 140) {
+ $this->showForm(_('Bio is too long (max 140 chars).'));
+ return;
+ } else if (!is_null($location) && mb_strlen($location) > 255) {
+ $this->showForm(_('Location is too long (max 255 chars).'));
+ return;
+ } else if (strlen($password) < 6) {
+ $this->showForm(_('Password must be 6 or more characters.'));
+ return;
+ } else if ($password != $confirm) {
+ $this->showForm(_('Passwords don\'t match.'));
+ } else if ($user = User::register(array('nickname' => $nickname,
+ 'password' => $password,
+ 'email' => $email,
+ 'fullname' => $fullname,
+ 'homepage' => $homepage,
+ 'bio' => $bio,
+ 'location' => $location,
+ 'code' => $code))) {
+ if (!$user) {
+ $this->showForm(_('Invalid username or password.'));
+ return;
+ }
+ // success!
+ if (!common_set_user($user)) {
+ $this->serverError(_('Error setting user.'));
+ return;
+ }
+ // this is a real login
+ common_real_login(true);
+ if ($this->boolean('rememberme')) {
+ common_debug('Adding rememberme cookie for ' . $nickname);
+ common_rememberme($user);
+ }
+
+ Event::handle('EndRegistrationTry', array($this));
+
+ // Re-init language env in case it changed (not yet, but soon)
+ common_init_language();
+ $this->showSuccess();
+ } else {
+ $this->showForm(_('Invalid username or password.'));
}
- // this is a real login
- common_real_login(true);
- if ($this->boolean('rememberme')) {
- common_debug('Adding rememberme cookie for ' . $nickname);
- common_rememberme($user);
- }
- // Re-init language env in case it changed (not yet, but soon)
- common_init_language();
- $this->showSuccess();
- } else {
- $this->showForm(_('Invalid username or password.'));
}
}
@@ -252,22 +291,24 @@ class RegisterAction extends Action
// overrrided to add entry-title class
function showPageTitle() {
- $this->element('h1', array('class' => 'entry-title'), $this->title());
+ if (Event::handle('StartShowPageTitle', array($this))) {
+ $this->element('h1', array('class' => 'entry-title'), $this->title());
+ }
}
// overrided to add hentry, and content-inner class
function showContentBlock()
- {
- $this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
- $this->showPageTitle();
- $this->showPageNoticeBlock();
- $this->elementStart('div', array('id' => 'content_inner',
- 'class' => 'entry-content'));
- // show the actual content (forms, lists, whatever)
- $this->showContent();
- $this->elementEnd('div');
- $this->elementEnd('div');
- }
+ {
+ $this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
+ $this->showPageTitle();
+ $this->showPageNoticeBlock();
+ $this->elementStart('div', array('id' => 'content_inner',
+ 'class' => 'entry-content'));
+ // show the actual content (forms, lists, whatever)
+ $this->showContent();
+ $this->elementEnd('div');
+ $this->elementEnd('div');
+ }
/**
* Instructions or a notice for the page
@@ -362,82 +403,85 @@ class RegisterAction extends Action
$this->element('legend', null, 'Account settings');
$this->hidden('token', common_session_token());
- if ($code) {
- $this->hidden('code', $code);
+ if ($this->code) {
+ $this->hidden('code', $this->code);
}
$this->elementStart('ul', 'form_data');
- $this->elementStart('li');
- $this->input('nickname', _('Nickname'), $this->trimmed('nickname'),
- _('1-64 lowercase letters or numbers, '.
- 'no punctuation or spaces. Required.'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->password('password', _('Password'),
- _('6 or more characters. Required.'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->password('confirm', _('Confirm'),
- _('Same as password above. Required.'));
- $this->elementEnd('li');
- $this->elementStart('li');
- if (!empty($invite) && $invite->address_type == 'email') {
- $this->input('email', _('Email'), $invite->address,
- _('Used only for updates, announcements, '.
- 'and password recovery'));
- } else {
- $this->input('email', _('Email'), $this->trimmed('email'),
- _('Used only for updates, announcements, '.
- 'and password recovery'));
- }
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('fullname', _('Full name'),
- $this->trimmed('fullname'),
- _('Longer name, preferably your "real" name'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('homepage', _('Homepage'),
- $this->trimmed('homepage'),
- _('URL of your homepage, blog, '.
- 'or profile on another site'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->textarea('bio', _('Bio'),
- $this->trimmed('bio'),
- _('Describe yourself and your '.
- 'interests in 140 chars'));
- $this->elementEnd('li');
- $this->elementStart('li');
- $this->input('location', _('Location'),
- $this->trimmed('location'),
- _('Where you are, like "City, '.
- 'State (or Region), Country"'));
- $this->elementEnd('li');
- $this->elementStart('li', array('id' => 'settings_rememberme'));
- $this->checkbox('rememberme', _('Remember me'),
- $this->boolean('rememberme'),
- _('Automatically login in the future; '.
- 'not for shared computers!'));
- $this->elementEnd('li');
- $attrs = array('type' => 'checkbox',
- 'id' => 'license',
- 'class' => 'checkbox',
- 'name' => 'license',
- 'value' => 'true');
- if ($this->boolean('license')) {
- $attrs['checked'] = 'checked';
+ if (Event::handle('StartRegistrationFormData', array($this))) {
+ $this->elementStart('li');
+ $this->input('nickname', _('Nickname'), $this->trimmed('nickname'),
+ _('1-64 lowercase letters or numbers, '.
+ 'no punctuation or spaces. Required.'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->password('password', _('Password'),
+ _('6 or more characters. Required.'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->password('confirm', _('Confirm'),
+ _('Same as password above. Required.'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ if ($this->invite && $this->invite->address_type == 'email') {
+ $this->input('email', _('Email'), $this->invite->address,
+ _('Used only for updates, announcements, '.
+ 'and password recovery'));
+ } else {
+ $this->input('email', _('Email'), $this->trimmed('email'),
+ _('Used only for updates, announcements, '.
+ 'and password recovery'));
+ }
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->input('fullname', _('Full name'),
+ $this->trimmed('fullname'),
+ _('Longer name, preferably your "real" name'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->input('homepage', _('Homepage'),
+ $this->trimmed('homepage'),
+ _('URL of your homepage, blog, '.
+ 'or profile on another site'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->textarea('bio', _('Bio'),
+ $this->trimmed('bio'),
+ _('Describe yourself and your '.
+ 'interests in 140 chars'));
+ $this->elementEnd('li');
+ $this->elementStart('li');
+ $this->input('location', _('Location'),
+ $this->trimmed('location'),
+ _('Where you are, like "City, '.
+ 'State (or Region), Country"'));
+ $this->elementEnd('li');
+ Event::handle('EndRegistrationFormData', array($this));
+ $this->elementStart('li', array('id' => 'settings_rememberme'));
+ $this->checkbox('rememberme', _('Remember me'),
+ $this->boolean('rememberme'),
+ _('Automatically login in the future; '.
+ 'not for shared computers!'));
+ $this->elementEnd('li');
+ $attrs = array('type' => 'checkbox',
+ 'id' => 'license',
+ 'class' => 'checkbox',
+ 'name' => 'license',
+ 'value' => 'true');
+ if ($this->boolean('license')) {
+ $attrs['checked'] = 'checked';
+ }
+ $this->elementStart('li');
+ $this->element('input', $attrs);
+ $this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
+ $this->text(_('My text and files are available under '));
+ $this->element('a', array('href' => common_config('license', 'url')),
+ common_config('license', 'title'), _("Creative Commons Attribution 3.0"));
+ $this->text(_(' except this private data: password, '.
+ 'email address, IM address, and phone number.'));
+ $this->elementEnd('label');
+ $this->elementEnd('li');
}
- $this->elementStart('li');
- $this->element('input', $attrs);
- $this->elementStart('label', array('class' => 'checkbox', 'for' => 'license'));
- $this->text(_('My text and files are available under '));
- $this->element('a', array('href' => common_config('license', 'url')),
- common_config('license', 'title'), _("Creative Commons Attribution 3.0"));
- $this->text(_(' except this private data: password, '.
- 'email address, IM address, and phone number.'));
- $this->elementEnd('label');
- $this->elementEnd('li');
$this->elementEnd('ul');
$this->submit('submit', _('Register'));
$this->elementEnd('fieldset');
@@ -519,3 +563,4 @@ class RegisterAction extends Action
$nav->show();
}
}
+
diff --git a/actions/showfavorites.php b/actions/showfavorites.php
index 6e011d5ca..eed62a2ab 100644
--- a/actions/showfavorites.php
+++ b/actions/showfavorites.php
@@ -74,9 +74,9 @@ class ShowfavoritesAction extends Action
function title()
{
if ($this->page == 1) {
- return sprintf(_("%s favorite notices"), $this->user->nickname);
+ return sprintf(_("%s's favorite notices"), $this->user->nickname);
} else {
- return sprintf(_("%s favorite notices, page %d"),
+ return sprintf(_("%s's favorite notices, page %d"),
$this->user->nickname,
$this->page);
}
diff --git a/actions/showgroup.php b/actions/showgroup.php
index 025f8383a..a7df39727 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -35,7 +35,7 @@ if (!defined('LACONICA')) {
require_once INSTALLDIR.'/lib/noticelist.php';
require_once INSTALLDIR.'/lib/feedlist.php';
-define('MEMBERS_PER_SECTION', 81);
+define('MEMBERS_PER_SECTION', 27);
/**
* Group main page
@@ -361,7 +361,7 @@ class ShowgroupAction extends Action
$this->element('p', null, _('(None)'));
}
- if ($cnt == MEMBERS_PER_SECTION) {
+ if ($cnt > MEMBERS_PER_SECTION) {
$this->element('a', array('href' => common_local_url('groupmembers',
array('nickname' => $this->group->nickname))),
_('All members'));
diff --git a/actions/showstream.php b/actions/showstream.php
index 82665e5b8..678a3174c 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -68,6 +68,9 @@ class ShowstreamAction extends ProfileAction
} else {
$base = $this->user->nickname;
}
+ if (!empty($this->tag)) {
+ $base .= sprintf(_(' tagged %s'), $this->tag);
+ }
if ($this->page == 1) {
return $base;
@@ -110,6 +113,15 @@ class ShowstreamAction extends ProfileAction
function getFeeds()
{
+ if (!empty($this->tag)) {
+ return array(new Feed(Feed::RSS1,
+ common_local_url('userrss',
+ array('nickname' => $this->user->nickname,
+ 'tag' => $this->tag)),
+ sprintf(_('Notice feed for %s tagged %s (RSS 1.0)'),
+ $this->user->nickname, $this->tag)));
+ }
+
return array(new Feed(Feed::RSS1,
common_local_url('userrss',
array('nickname' => $this->user->nickname)),
@@ -363,7 +375,9 @@ class ShowstreamAction extends ProfileAction
function showNotices()
{
- $notice = $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
+ $notice = empty($this->tag)
+ ? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
+ : $this->user->getTaggedNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null, $this->tag);
$pnl = new ProfileNoticeList($notice, $this);
$cnt = $pnl->show();
diff --git a/actions/subscribers.php b/actions/subscribers.php
index d91a7d4fd..4482de9a7 100644
--- a/actions/subscribers.php
+++ b/actions/subscribers.php
@@ -118,6 +118,16 @@ class SubscribersAction extends GalleryAction
$this->raw(common_markup_to_html($message));
$this->elementEnd('div');
}
+
+ function showSections()
+ {
+ parent::showSections();
+ $cloud = new SubscribersPeopleTagCloudSection($this);
+ $cloud->show();
+
+ $cloud2 = new SubscribersPeopleSelfTagCloudSection($this);
+ $cloud2->show();
+ }
}
class SubscribersList extends ProfileList
diff --git a/actions/subscriptions.php b/actions/subscriptions.php
index e6f3c54db..095b18ad8 100644
--- a/actions/subscriptions.php
+++ b/actions/subscriptions.php
@@ -125,6 +125,16 @@ class SubscriptionsAction extends GalleryAction
$this->raw(common_markup_to_html($message));
$this->elementEnd('div');
}
+
+ function showSections()
+ {
+ parent::showSections();
+ $cloud = new SubscriptionsPeopleTagCloudSection($this);
+ $cloud->show();
+
+ $cloud2 = new SubscriptionsPeopleSelfTagCloudSection($this);
+ $cloud2->show();
+ }
}
class SubscriptionsList extends ProfileList
diff --git a/actions/tag.php b/actions/tag.php
index 02f3e3522..47420e4c3 100644
--- a/actions/tag.php
+++ b/actions/tag.php
@@ -49,9 +49,10 @@ class TagAction extends Action
{
$pop = new PopularNoticeSection($this);
$pop->show();
+ $freqatt = new FrequentAttachmentSection($this);
+ $freqatt->show();
}
-
function title()
{
if ($this->page == 1) {
diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php
index c50c5e84a..2f8250e0d 100644
--- a/actions/twitapifriendships.php
+++ b/actions/twitapifriendships.php
@@ -133,11 +133,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
return;
}
- if ($user_a->isSubscribed($user_b)) {
- $result = 'true';
- } else {
- $result = 'false';
- }
+ $result = $user_a->isSubscribed($user_b);
switch ($apidata['content-type']) {
case 'xml':
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 323c4f1f8..3abeba367 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -144,10 +144,10 @@ class TwitapistatusesAction extends TwitterapiAction
break;
case 'atom':
if (isset($apidata['api_arg'])) {
- $selfuri = $selfuri = common_root_url() .
+ $selfuri = common_root_url() .
'api/statuses/friends_timeline/' . $apidata['api_arg'] . '.atom';
} else {
- $selfuri = $selfuri = common_root_url() .
+ $selfuri = common_root_url() .
'api/statuses/friends_timeline.atom';
}
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, null, $selfuri);
@@ -231,10 +231,10 @@ class TwitapistatusesAction extends TwitterapiAction
break;
case 'atom':
if (isset($apidata['api_arg'])) {
- $selfuri = $selfuri = common_root_url() .
+ $selfuri = common_root_url() .
'api/statuses/user_timeline/' . $apidata['api_arg'] . '.atom';
} else {
- $selfuri = $selfuri = common_root_url() .
+ $selfuri = common_root_url() .
'api/statuses/user_timeline.atom';
}
$this->show_atom_timeline($notice, $title, $id, $link, $subtitle, $suplink, $selfuri);
@@ -344,7 +344,7 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show($args, $apidata);
}
- function replies($args, $apidata)
+ function mentions($args, $apidata)
{
parent::handle($args);
@@ -360,11 +360,13 @@ class TwitapistatusesAction extends TwitterapiAction
$profile = $user->getProfile();
$sitename = common_config('site', 'name');
- $title = sprintf(_('%1$s / Updates replying to %2$s'), $sitename, $user->nickname);
+ $title = sprintf(_('%1$s / Updates mentioning %2$s'),
+ $sitename, $user->nickname);
$taguribase = common_config('integration', 'taguri');
- $id = "tag:$taguribase:Replies:".$user->id;
+ $id = "tag:$taguribase:Mentions:".$user->id;
$link = common_local_url('replies', array('nickname' => $user->nickname));
- $subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'), $sitename, $user->nickname, $profile->getBestName());
+ $subtitle = sprintf(_('%1$s updates that reply to updates from %2$s / %3$s.'),
+ $sitename, $user->nickname, $profile->getBestName());
if (!$page) {
$page = 1;
@@ -385,7 +387,8 @@ class TwitapistatusesAction extends TwitterapiAction
$since = strtotime($this->arg('since'));
- $notice = $user->getReplies((($page-1)*20), $count, $since_id, $before_id, $since);
+ $notice = $user->getReplies((($page-1)*20),
+ $count, $since_id, $before_id, $since);
$notices = array();
while ($notice->fetch()) {
@@ -400,14 +403,10 @@ class TwitapistatusesAction extends TwitterapiAction
$this->show_rss_timeline($notices, $title, $link, $subtitle);
break;
case 'atom':
- if (isset($apidata['api_arg'])) {
- $selfuri = $selfuri = common_root_url() .
- 'api/statuses/replies/' . $apidata['api_arg'] . '.atom';
- } else {
- $selfuri = $selfuri = common_root_url() .
- 'api/statuses/replies.atom';
- }
- $this->show_atom_timeline($notices, $title, $id, $link, $subtitle, null, $selfuri);
+ $selfuri = common_root_url() .
+ ltrim($_SERVER['QUERY_STRING'], 'p=');
+ $this->show_atom_timeline($notices, $title, $id, $link, $subtitle,
+ null, $selfuri);
break;
case 'json':
$this->show_json_timeline($notices);
@@ -418,6 +417,11 @@ class TwitapistatusesAction extends TwitterapiAction
}
+ function replies($args, $apidata)
+ {
+ call_user_func(array($this, 'mentions'), $args, $apidata);
+ }
+
function show($args, $apidata)
{
parent::handle($args);
diff --git a/actions/twitapiusers.php b/actions/twitapiusers.php
index 2894b7486..1542cfb33 100644
--- a/actions/twitapiusers.php
+++ b/actions/twitapiusers.php
@@ -82,8 +82,8 @@ class TwitapiusersAction extends TwitterapiAction
$twitter_user['profile_text_color'] = '';
$twitter_user['profile_link_color'] = '';
$twitter_user['profile_sidebar_fill_color'] = '';
- $twitter_user['profile_sidebar_border_color'] = '';
- $twitter_user['profile_background_tile'] = 'false';
+ $twitter_user['profile_sidebar_border_color'] = '';
+ $twitter_user['profile_background_tile'] = false;
$faves = DB_DataObject::factory('fave');
$faves->user_id = $user->id;
@@ -103,24 +103,16 @@ class TwitapiusersAction extends TwitterapiAction
if (isset($apidata['user'])) {
- if ($apidata['user']->isSubscribed($profile)) {
- $twitter_user['following'] = 'true';
- } else {
- $twitter_user['following'] = 'false';
- }
+ $twitter_user['following'] = $apidata['user']->isSubscribed($profile);
- // Notifications on?
- $sub = Subscription::pkeyGet(array('subscriber' =>
- $apidata['user']->id, 'subscribed' => $profile->id));
+ // Notifications on?
+ $sub = Subscription::pkeyGet(array('subscriber' =>
+ $apidata['user']->id, 'subscribed' => $profile->id));
- if ($sub) {
- if ($sub->jabber || $sub->sms) {
- $twitter_user['notifications'] = 'true';
- } else {
- $twitter_user['notifications'] = 'false';
- }
- }
- }
+ if ($sub) {
+ $twitter_user['notifications'] = ($sub->jabber || $sub->sms);
+ }
+ }
if ($apidata['content-type'] == 'xml') {
$this->init_document('xml');
diff --git a/actions/twittersettings.php b/actions/twittersettings.php
index 45725d3ff..2b742788e 100644
--- a/actions/twittersettings.php
+++ b/actions/twittersettings.php
@@ -138,7 +138,7 @@ class TwittersettingsAction extends ConnectSettingsAction
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
- $this->checkbox('noticesync',
+ $this->checkbox('noticesend',
_('Automatically send my notices to Twitter.'),
($flink) ?
($flink->noticesync & FOREIGN_NOTICE_SEND) :
@@ -158,6 +158,22 @@ class TwittersettingsAction extends ConnectSettingsAction
($flink->friendsync & FOREIGN_FRIEND_RECV) :
false);
$this->elementEnd('li');
+
+ if (common_config('twitterbridge','enabled')) {
+ $this->elementStart('li');
+ $this->checkbox('noticerecv',
+ _('Import my Friends Timeline.'),
+ ($flink) ?
+ ($flink->noticesync & FOREIGN_NOTICE_RECV) :
+ false);
+ $this->elementEnd('li');
+ } else {
+ // preserve setting even if bidrection bridge toggled off
+ if ($flink && ($flink->noticesync & FOREIGN_NOTICE_RECV)) {
+ $this->hidden('noticerecv', true, 'noticerecv');
+ }
+ }
+
$this->elementEnd('ul');
if ($flink) {
@@ -261,7 +277,7 @@ class TwittersettingsAction extends ConnectSettingsAction
'alt' => ($other->fullname) ?
$other->fullname :
$other->nickname));
-
+
$this->element('span', 'fn nickname', $other->nickname);
$this->elementEnd('a');
$this->elementEnd('li');
@@ -320,7 +336,8 @@ class TwittersettingsAction extends ConnectSettingsAction
{
$screen_name = $this->trimmed('twitter_username');
$password = $this->trimmed('twitter_password');
- $noticesync = $this->boolean('noticesync');
+ $noticesend = $this->boolean('noticesend');
+ $noticerecv = $this->boolean('noticerecv');
$replysync = $this->boolean('replysync');
$friendsync = $this->boolean('friendsync');
@@ -363,7 +380,7 @@ class TwittersettingsAction extends ConnectSettingsAction
$flink->credentials = $password;
$flink->created = common_sql_now();
- $flink->set_flags($noticesync, $replysync, $friendsync);
+ $flink->set_flags($noticesend, $noticerecv, $replysync, $friendsync);
$flink_id = $flink->insert();
@@ -375,6 +392,8 @@ class TwittersettingsAction extends ConnectSettingsAction
if ($friendsync) {
save_twitter_friends($user, $twit_user->id, $screen_name, $password);
+ $flink->last_friendsync = common_sql_now();
+ $flink->update();
}
$this->showForm(_('Twitter settings saved.'), true);
@@ -419,7 +438,8 @@ class TwittersettingsAction extends ConnectSettingsAction
function savePreferences()
{
- $noticesync = $this->boolean('noticesync');
+ $noticesend = $this->boolean('noticesend');
+ $noticerecv = $this->boolean('noticerecv');
$friendsync = $this->boolean('friendsync');
$replysync = $this->boolean('replysync');
@@ -448,7 +468,7 @@ class TwittersettingsAction extends ConnectSettingsAction
$original = clone($flink);
- $flink->set_flags($noticesync, $replysync, $friendsync);
+ $flink->set_flags($noticesend, $noticerecv, $replysync, $friendsync);
$result = $flink->update($original);
diff --git a/actions/userrss.php b/actions/userrss.php
index 5861d9ee3..2280509b2 100644
--- a/actions/userrss.php
+++ b/actions/userrss.php
@@ -25,14 +25,15 @@ require_once(INSTALLDIR.'/lib/rssaction.php');
class UserrssAction extends Rss10Action
{
-
var $user = null;
+ var $tag = null;
function prepare($args)
{
parent::prepare($args);
- $nickname = $this->trimmed('nickname');
+ $nickname = $this->trimmed('nickname');
$this->user = User::staticGet('nickname', $nickname);
+ $this->tag = $this->trimmed('tag');
if (!$this->user) {
$this->clientError(_('No such user.'));
@@ -42,6 +43,25 @@ class UserrssAction extends Rss10Action
}
}
+ function getTaggedNotices($tag = null, $limit=0)
+ {
+ $user = $this->user;
+
+ if (is_null($user)) {
+ return null;
+ }
+
+ $notice = $user->getTaggedNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit, 0, 0, null, $tag);
+
+ $notices = array();
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ return $notices;
+ }
+
+
function getNotices($limit=0)
{