summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
Diffstat (limited to 'actions')
-rw-r--r--actions/all.php3
-rw-r--r--actions/apiblockcreate.php11
-rw-r--r--actions/apidirectmessagenew.php2
-rw-r--r--actions/apistatusesretweet.php136
-rw-r--r--actions/apistatusesretweets.php116
-rw-r--r--actions/apistatusesupdate.php29
-rw-r--r--actions/apitimelinefavorites.php6
-rw-r--r--actions/apitimelinefriends.php58
-rw-r--r--actions/apitimelinegroup.php7
-rw-r--r--actions/apitimelinehome.php249
-rw-r--r--actions/apitimelinementions.php6
-rw-r--r--actions/apitimelinepublic.php5
-rw-r--r--actions/apitimelineretweetedbyme.php126
-rw-r--r--actions/apitimelineretweetedtome.php125
-rw-r--r--actions/apitimelineretweetsofme.php126
-rw-r--r--actions/apitimelinetag.php6
-rw-r--r--actions/apitimelineuser.php6
-rw-r--r--actions/avatarsettings.php110
-rw-r--r--actions/file.php8
-rw-r--r--actions/grouprss.php4
-rw-r--r--actions/login.php13
-rw-r--r--actions/newmessage.php8
-rw-r--r--actions/newnotice.php10
-rw-r--r--actions/repeat.php126
-rw-r--r--actions/showstream.php46
-rw-r--r--actions/subscribers.php2
-rw-r--r--actions/subscriptions.php2
-rw-r--r--actions/tagother.php4
-rw-r--r--actions/twitapisearchatom.php2
-rw-r--r--actions/userbyid.php11
30 files changed, 1219 insertions, 144 deletions
diff --git a/actions/all.php b/actions/all.php
index 61cedce74..452803d8a 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -160,12 +160,11 @@ class AllAction extends ProfileAction
function showPageTitle()
{
- $user =& common_current_user();
+ $user = common_current_user();
if ($user && ($user->id == $this->user->id)) {
$this->element('h1', null, _("You and friends"));
} else {
$this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname));
}
}
-
}
diff --git a/actions/apiblockcreate.php b/actions/apiblockcreate.php
index 4f941f6c3..e79dec32d 100644
--- a/actions/apiblockcreate.php
+++ b/actions/apiblockcreate.php
@@ -98,6 +98,17 @@ class ApiBlockCreateAction extends ApiAuthAction
return;
}
+ // Don't allow blocking yourself!
+
+ if ($this->user->id == $this->other->id) {
+ $this->clientError(
+ _("You cannot block yourself!"),
+ 403,
+ $this->format
+ );
+ return;
+ }
+
if ($this->user->hasBlocked($this->other)
|| $this->user->block($this->other)
) {
diff --git a/actions/apidirectmessagenew.php b/actions/apidirectmessagenew.php
index e6c39ce4a..b9ac92d77 100644
--- a/actions/apidirectmessagenew.php
+++ b/actions/apidirectmessagenew.php
@@ -175,7 +175,7 @@ class ApiDirectMessageNewAction extends ApiAuthAction
return;
}
- mail_notify_message($message, $this->user, $this->other);
+ $message->notify();
if ($this->format == 'xml') {
$this->showSingleXmlDirectMessage($message);
diff --git a/actions/apistatusesretweet.php b/actions/apistatusesretweet.php
new file mode 100644
index 000000000..d9d4820c0
--- /dev/null
+++ b/actions/apistatusesretweet.php
@@ -0,0 +1,136 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Repeat a notice through the API
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+require_once INSTALLDIR . '/lib/mediafile.php';
+
+/**
+ * Repeat a notice through the API
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class ApiStatusesRetweetAction extends ApiAuthAction
+{
+ var $original = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->clientError(_('This method requires a POST.'),
+ 400, $this->format);
+ return false;
+ }
+
+ $id = $this->trimmed('id');
+
+ $this->original = Notice::staticGet('id', $id);
+
+ if (empty($this->original)) {
+ $this->clientError(_('No such notice.'),
+ 400, $this->format);
+ return false;
+ }
+
+ $this->user = $this->auth_user;
+
+ if ($this->user->id == $notice->profile_id) {
+ $this->clientError(_('Cannot repeat your own notice.'),
+ 400, $this->format);
+ return false;
+ }
+
+ $profile = $this->user->getProfile();
+
+ if ($profile->hasRepeated($id)) {
+ $this->clientError(_('Already repeated that notice.'),
+ 400, $this->format);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Make a new notice for the update, save it, and show it
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ $repeat = $this->original->repeat($this->user->id, $this->source);
+
+ common_broadcast_notice($repeat);
+
+ $this->showNotice($repeat);
+ }
+
+ /**
+ * Show the resulting notice
+ *
+ * @return void
+ */
+
+ function showNotice($notice)
+ {
+ if (!empty($notice)) {
+ if ($this->format == 'xml') {
+ $this->showSingleXmlStatus($notice);
+ } elseif ($this->format == 'json') {
+ $this->show_single_json_status($notice);
+ }
+ }
+ }
+}
diff --git a/actions/apistatusesretweets.php b/actions/apistatusesretweets.php
new file mode 100644
index 000000000..2efd59b37
--- /dev/null
+++ b/actions/apistatusesretweets.php
@@ -0,0 +1,116 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show up to 100 repeats of a notice
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+require_once INSTALLDIR . '/lib/mediafile.php';
+
+/**
+ * Show up to 100 repeats of a notice
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class ApiStatusesRetweetsAction extends ApiAuthAction
+{
+ const MAXCOUNT = 100;
+
+ var $original = null;
+ var $cnt = self::MAXCOUNT;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $id = $this->trimmed('id');
+
+ $this->original = Notice::staticGet('id', $id);
+
+ if (empty($this->original)) {
+ $this->clientError(_('No such notice.'),
+ 400, $this->format);
+ return false;
+ }
+
+ $cnt = $this->trimmed('count');
+
+ if (empty($cnt) || !is_integer($cnt)) {
+ $cnt = 100;
+ } else {
+ $this->cnt = min((int)$cnt, self::MAXCOUNT);
+ }
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Make a new notice for the update, save it, and show it
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ $strm = $this->original->repeatStream($this->cnt);
+
+ switch ($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($strm);
+ break;
+ case 'json':
+ $this->showJsonTimeline($strm);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+}
diff --git a/actions/apistatusesupdate.php b/actions/apistatusesupdate.php
index 85a7c8c08..dabbea92f 100644
--- a/actions/apistatusesupdate.php
+++ b/actions/apistatusesupdate.php
@@ -231,19 +231,22 @@ class ApiStatusesUpdateAction extends ApiAuthAction
}
}
- $this->notice = Notice::saveNew(
- $this->user->id,
- html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8'),
- $this->source,
- 1,
- $reply_to,
- null,
- null,
- empty($location) ? null : $location->lat,
- empty($location) ? null : $location->lon,
- empty($location) ? null : $location->location_id,
- empty($location) ? null : $location->location_ns
- );
+ $content = html_entity_decode($status_shortened, ENT_NOQUOTES, 'UTF-8');
+
+ $options = array('reply_to' => $reply_to);
+
+ if (!empty($location)) {
+ $options['lat'] = $location->lat;
+ $options['lon'] = $location->lon;
+ $options['location_id'] = $location->location_id;
+ $options['location_ns'] = $location->location_ns;
+ }
+
+ $this->notice =
+ Notice::saveNew($this->user->id,
+ $content,
+ $this->source,
+ $options);
if (isset($upload)) {
$upload->attachToNotice($this->notice);
diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php
index f84d7b4cb..008e04212 100644
--- a/actions/apitimelinefavorites.php
+++ b/actions/apitimelinefavorites.php
@@ -101,6 +101,7 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
function showTimeline()
{
$profile = $this->user->getProfile();
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(
@@ -121,20 +122,21 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
$profile->getBestName(),
$this->user->nickname
);
+ $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
switch($this->format) {
case 'xml':
$this->showXmlTimeline($this->notices);
break;
case 'rss':
- $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
break;
case 'atom':
$selfuri = common_root_url() .
ltrim($_SERVER['QUERY_STRING'], 'p=');
$this->showAtomTimeline(
$this->notices, $title, $id, $link, $subtitle,
- null, $selfuri
+ null, $selfuri, $logo
);
break;
case 'json':
diff --git a/actions/apitimelinefriends.php b/actions/apitimelinefriends.php
index e84f77372..9ec7447e6 100644
--- a/actions/apitimelinefriends.php
+++ b/actions/apitimelinefriends.php
@@ -110,24 +110,26 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
function showTimeline()
{
$profile = $this->user->getProfile();
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(_("%s and friends"), $this->user->nickname);
$taguribase = common_config('integration', 'taguri');
$id = "tag:$taguribase:FriendsTimeline:" . $this->user->id;
$link = common_local_url(
- 'all', array('nickname' => $this->user->nickname)
- );
+ 'all', array('nickname' => $this->user->nickname)
+ );
$subtitle = sprintf(
- _('Updates from %1$s and friends on %2$s!'),
- $this->user->nickname, $sitename
- );
+ _('Updates from %1$s and friends on %2$s!'),
+ $this->user->nickname, $sitename
+ );
+ $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
switch($this->format) {
case 'xml':
$this->showXmlTimeline($this->notices);
break;
case 'rss':
- $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
break;
case 'atom':
@@ -135,17 +137,17 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
if (isset($target_id)) {
$selfuri = common_root_url() .
- 'api/statuses/friends_timeline/' .
- $target_id . '.atom';
+ 'api/statuses/friends_timeline/' .
+ $target_id . '.atom';
} else {
$selfuri = common_root_url() .
- 'api/statuses/friends_timeline.atom';
+ 'api/statuses/friends_timeline.atom';
}
$this->showAtomTimeline(
- $this->notices, $title, $id, $link,
- $subtitle, null, $selfuri
- );
+ $this->notices, $title, $id, $link,
+ $subtitle, null, $selfuri, $logo
+ );
break;
case 'json':
$this->showJsonTimeline($this->notices);
@@ -167,17 +169,13 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
$notices = array();
if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
- $notice = $this->user->noticeInbox(
- ($this->page-1) * $this->count,
- $this->count, $this->since_id,
- $this->max_id, $this->since
- );
+ $notice = $this->user->ownFriendsTimeline(($this->page-1) * $this->count,
+ $this->count, $this->since_id,
+ $this->max_id, $this->since);
} else {
- $notice = $this->user->noticesWithFriends(
- ($this->page-1) * $this->count,
- $this->count, $this->since_id,
- $this->max_id, $this->since
- );
+ $notice = $this->user->friendsTimeline(($this->page-1) * $this->count,
+ $this->count, $this->since_id,
+ $this->max_id, $this->since);
}
while ($notice->fetch()) {
@@ -231,14 +229,14 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
$last = count($this->notices) - 1;
return '"' . implode(
- ':',
- array($this->arg('action'),
- common_language(),
- $this->user->id,
- strtotime($this->notices[0]->created),
- strtotime($this->notices[$last]->created))
- )
- . '"';
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->user->id,
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created))
+ )
+ . '"';
}
return null;
diff --git a/actions/apitimelinegroup.php b/actions/apitimelinegroup.php
index de13e7eb9..22c577f39 100644
--- a/actions/apitimelinegroup.php
+++ b/actions/apitimelinegroup.php
@@ -105,6 +105,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
function showTimeline()
{
$sitename = common_config('site', 'name');
+ $avatar = $this->group->homepage_logo;
$title = sprintf(_("%s timeline"), $this->group->nickname);
$taguribase = common_config('integration', 'taguri');
$id = "tag:$taguribase:GroupTimeline:" . $this->group->id;
@@ -117,13 +118,14 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
$this->group->nickname,
$sitename
);
+ $logo = ($avatar) ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
switch($this->format) {
case 'xml':
$this->showXmlTimeline($this->notices);
break;
case 'rss':
- $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
break;
case 'atom':
$selfuri = common_root_url() .
@@ -136,7 +138,8 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
$link,
$subtitle,
null,
- $selfuri
+ $selfuri,
+ $logo
);
break;
case 'json':
diff --git a/actions/apitimelinehome.php b/actions/apitimelinehome.php
new file mode 100644
index 000000000..5f5ea37b1
--- /dev/null
+++ b/actions/apitimelinehome.php
@@ -0,0 +1,249 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show the home timeline
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/lib/apibareauth.php';
+
+/**
+ * Returns the most recent notices (default 20) posted by the target user.
+ * This is the equivalent of 'You and friends' page accessed via Web.
+ *
+ * @category API
+ * @package StatusNet
+ * @author Craig Andrews <candrews@integralblue.com>
+ * @author Evan Prodromou <evan@status.net>
+ * @author Jeffery To <jeffery.to@gmail.com>
+ * @author mac65 <mac65@mac65.com>
+ * @author Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author Robin Millette <robin@millette.info>
+ * @author Zach Copley <zach@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class ApiTimelineHomeAction extends ApiBareAuthAction
+{
+ var $notices = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+ common_debug("api home_timeline");
+ $this->user = $this->getTargetUser($this->arg('id'));
+
+ if (empty($this->user)) {
+ $this->clientError(_('No such user.'), 404, $this->format);
+ return;
+ }
+
+ $this->notices = $this->getNotices();
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * Just show the notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showTimeline();
+ }
+
+ /**
+ * Show the timeline of notices
+ *
+ * @return void
+ */
+
+ function showTimeline()
+ {
+ $profile = $this->user->getProfile();
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ $sitename = common_config('site', 'name');
+ $title = sprintf(_("%s and friends"), $this->user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:HomeTimeline:" . $this->user->id;
+ $link = common_local_url(
+ 'all', array('nickname' => $this->user->nickname)
+ );
+ $subtitle = sprintf(
+ _('Updates from %1$s and friends on %2$s!'),
+ $this->user->nickname, $sitename
+ );
+ $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
+
+ switch($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($this->notices);
+ break;
+ case 'rss':
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
+ break;
+ case 'atom':
+
+ $target_id = $this->arg('id');
+
+ if (isset($target_id)) {
+ $selfuri = common_root_url() .
+ 'api/statuses/home_timeline/' .
+ $target_id . '.atom';
+ } else {
+ $selfuri = common_root_url() .
+ 'api/statuses/home_timeline.atom';
+ }
+
+ $this->showAtomTimeline(
+ $this->notices, $title, $id, $link,
+ $subtitle, null, $selfuri, $logo
+ );
+ break;
+ case 'json':
+ $this->showJsonTimeline($this->notices);
+ break;
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+
+ /**
+ * Get notices
+ *
+ * @return array notices
+ */
+
+ function getNotices()
+ {
+ $notices = array();
+
+ if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
+ $notice = $this->user->noticeInbox(
+ ($this->page-1) * $this->count,
+ $this->count, $this->since_id,
+ $this->max_id, $this->since
+ );
+ } else {
+ $notice = $this->user->noticesWithFriends(
+ ($this->page-1) * $this->count,
+ $this->count, $this->since_id,
+ $this->max_id, $this->since
+ );
+ }
+
+ while ($notice->fetch()) {
+ $notices[] = clone($notice);
+ }
+
+ return $notices;
+ }
+
+ /**
+ * Is this action read only?
+ *
+ * @param array $args other arguments
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly($args)
+ {
+ return true;
+ }
+
+ /**
+ * When was this feed last modified?
+ *
+ * @return string datestamp of the latest notice in the stream
+ */
+
+ function lastModified()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+ return strtotime($this->notices[0]->created);
+ }
+
+ return null;
+ }
+
+ /**
+ * An entity tag for this stream
+ *
+ * Returns an Etag based on the action name, language, user ID, and
+ * timestamps of the first and last notice in the timeline
+ *
+ * @return string etag
+ */
+
+ function etag()
+ {
+ if (!empty($this->notices) && (count($this->notices) > 0)) {
+
+ $last = count($this->notices) - 1;
+
+ return '"' . implode(
+ ':',
+ array($this->arg('action'),
+ common_language(),
+ $this->user->id,
+ strtotime($this->notices[0]->created),
+ strtotime($this->notices[$last]->created))
+ )
+ . '"';
+ }
+
+ return null;
+ }
+
+}
diff --git a/actions/apitimelinementions.php b/actions/apitimelinementions.php
index 0956ccdce..19f40aebc 100644
--- a/actions/apitimelinementions.php
+++ b/actions/apitimelinementions.php
@@ -110,6 +110,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
function showTimeline()
{
$profile = $this->user->getProfile();
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(
@@ -126,20 +127,21 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
_('%1$s updates that reply to updates from %2$s / %3$s.'),
$sitename, $this->user->nickname, $profile->getBestName()
);
+ $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
switch($this->format) {
case 'xml':
$this->showXmlTimeline($this->notices);
break;
case 'rss':
- $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
break;
case 'atom':
$selfuri = common_root_url() .
ltrim($_SERVER['QUERY_STRING'], 'p=');
$this->showAtomTimeline(
$this->notices, $title, $id, $link, $subtitle,
- null, $selfuri
+ null, $selfuri, $logo
);
break;
case 'json':
diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php
index 7a8504259..633f3c36e 100644
--- a/actions/apitimelinepublic.php
+++ b/actions/apitimelinepublic.php
@@ -103,6 +103,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
function showTimeline()
{
$sitename = common_config('site', 'name');
+ $sitelogo = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png');
$title = sprintf(_("%s public timeline"), $sitename);
$taguribase = common_config('integration', 'taguri');
$id = "tag:$taguribase:PublicTimeline";
@@ -114,13 +115,13 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
$this->showXmlTimeline($this->notices);
break;
case 'rss':
- $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $sitelogo);
break;
case 'atom':
$selfuri = common_root_url() . 'api/statuses/public_timeline.atom';
$this->showAtomTimeline(
$this->notices, $title, $id, $link,
- $subtitle, null, $selfuri
+ $subtitle, null, $selfuri, $sitelogo
);
break;
case 'json':
diff --git a/actions/apitimelineretweetedbyme.php b/actions/apitimelineretweetedbyme.php
new file mode 100644
index 000000000..1e65678ad
--- /dev/null
+++ b/actions/apitimelineretweetedbyme.php
@@ -0,0 +1,126 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show authenticating user's most recent repeats
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+require_once INSTALLDIR . '/lib/mediafile.php';
+
+/**
+ * Show authenticating user's most recent repeats
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class ApiTimelineRetweetedByMeAction extends ApiAuthAction
+{
+ const DEFAULTCOUNT = 20;
+ const MAXCOUNT = 200;
+ const MAXNOTICES = 3200;
+
+ var $repeats = null;
+ var $cnt = self::DEFAULTCOUNT;
+ var $page = 1;
+ var $since_id = null;
+ var $max_id = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1);
+
+ $page = $this->int('page', 1, (self::MAXNOTICES/$this->cnt));
+
+ $since_id = $this->int('since_id');
+
+ $max_id = $this->int('max_id');
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * show a timeline of the user's repeated notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ $offset = ($this->page-1) * $this->cnt;
+ $limit = $this->cnt;
+
+ $strm = $this->auth_user->repeatedByMe($offset, $limit, $this->since_id, $this->max_id);
+
+ switch ($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($strm);
+ break;
+ case 'json':
+ $this->showJsonTimeline($strm);
+ break;
+ case 'atom':
+ $profile = $this->auth_user->getProfile();
+
+ $title = sprintf(_("Repeated by %s"), $this->auth_user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:RepeatedByMe:" . $this->auth_user->id;
+ $link = common_local_url('showstream',
+ array('nickname' => $this->auth_user->nickname));
+
+ $this->showAtomTimeline($strm, $title, $id, $link);
+ break;
+
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+}
diff --git a/actions/apitimelineretweetedtome.php b/actions/apitimelineretweetedtome.php
new file mode 100644
index 000000000..681b0b9e9
--- /dev/null
+++ b/actions/apitimelineretweetedtome.php
@@ -0,0 +1,125 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show most recent notices that are repeats in user's inbox
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+
+/**
+ * Show most recent notices that are repeats in user's inbox
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class ApiTimelineRetweetedToMeAction extends ApiAuthAction
+{
+ const DEFAULTCOUNT = 20;
+ const MAXCOUNT = 200;
+ const MAXNOTICES = 3200;
+
+ var $repeats = null;
+ var $cnt = self::DEFAULTCOUNT;
+ var $page = 1;
+ var $since_id = null;
+ var $max_id = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1);
+
+ $page = $this->int('page', 1, (self::MAXNOTICES/$this->cnt));
+
+ $since_id = $this->int('since_id');
+
+ $max_id = $this->int('max_id');
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * show a timeline of the user's repeated notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ $offset = ($this->page-1) * $this->cnt;
+ $limit = $this->cnt;
+
+ $strm = $this->auth_user->repeatedToMe($offset, $limit, $this->since_id, $this->max_id);
+
+ switch ($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($strm);
+ break;
+ case 'json':
+ $this->showJsonTimeline($strm);
+ break;
+ case 'atom':
+ $profile = $this->auth_user->getProfile();
+
+ $title = sprintf(_("Repeated to %s"), $this->auth_user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:RepeatedToMe:" . $this->auth_user->id;
+ $link = common_local_url('all',
+ array('nickname' => $this->auth_user->nickname));
+
+ $this->showAtomTimeline($strm, $title, $id, $link);
+ break;
+
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+}
diff --git a/actions/apitimelineretweetsofme.php b/actions/apitimelineretweetsofme.php
new file mode 100644
index 000000000..479bff431
--- /dev/null
+++ b/actions/apitimelineretweetsofme.php
@@ -0,0 +1,126 @@
+<?php
+/**
+ * StatusNet, the distributed open-source microblogging tool
+ *
+ * Show authenticating user's most recent notices that have been repeated
+ *
+ * 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 API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet, Inc.
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+require_once INSTALLDIR . '/lib/apiauth.php';
+require_once INSTALLDIR . '/lib/mediafile.php';
+
+/**
+ * Show authenticating user's most recent notices that have been repeated
+ *
+ * @category API
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
+
+class ApiTimelineRetweetsOfMeAction extends ApiAuthAction
+{
+ const DEFAULTCOUNT = 20;
+ const MAXCOUNT = 200;
+ const MAXNOTICES = 3200;
+
+ var $repeats = null;
+ var $cnt = self::DEFAULTCOUNT;
+ var $page = 1;
+ var $since_id = null;
+ var $max_id = null;
+
+ /**
+ * Take arguments for running
+ *
+ * @param array $args $_REQUEST args
+ *
+ * @return boolean success flag
+ *
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $cnt = $this->int('count', self::DEFAULTCOUNT, self::MAXCOUNT, 1);
+
+ $page = $this->int('page', 1, (self::MAXNOTICES/$this->cnt));
+
+ $since_id = $this->int('since_id');
+
+ $max_id = $this->int('max_id');
+
+ return true;
+ }
+
+ /**
+ * Handle the request
+ *
+ * show a timeline of the user's repeated notices
+ *
+ * @param array $args $_REQUEST data (unused)
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+
+ $offset = ($this->page-1) * $this->cnt;
+ $limit = $this->cnt;
+
+ $strm = $this->auth_user->repeatsOfMe($offset, $limit, $this->since_id, $this->max_id);
+
+ switch ($this->format) {
+ case 'xml':
+ $this->showXmlTimeline($strm);
+ break;
+ case 'json':
+ $this->showJsonTimeline($strm);
+ break;
+ case 'atom':
+ $profile = $this->auth_user->getProfile();
+
+ $title = sprintf(_("Repeats of %s"), $this->auth_user->nickname);
+ $taguribase = common_config('integration', 'taguri');
+ $id = "tag:$taguribase:RepeatsOfMe:" . $this->auth_user->id;
+ $link = common_local_url('showstream',
+ array('nickname' => $this->auth_user->nickname));
+
+ $this->showAtomTimeline($strm, $title, $id, $link);
+ break;
+
+ default:
+ $this->clientError(_('API method not found!'), $code = 404);
+ break;
+ }
+ }
+}
diff --git a/actions/apitimelinetag.php b/actions/apitimelinetag.php
index 452593c11..1a50520f4 100644
--- a/actions/apitimelinetag.php
+++ b/actions/apitimelinetag.php
@@ -98,6 +98,7 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
function showTimeline()
{
$sitename = common_config('site', 'name');
+ $sitelogo = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png');
$title = sprintf(_("Notices tagged with %s"), $this->tag);
$link = common_local_url(
'tag',
@@ -116,7 +117,7 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
$this->showXmlTimeline($this->notices);
break;
case 'rss':
- $this->showRssTimeline($this->notices, $title, $link, $subtitle);
+ $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $sitelogo);
break;
case 'atom':
$selfuri = common_root_url() .
@@ -129,7 +130,8 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
$link,
$subtitle,
null,
- $selfuri
+ $selfuri,
+ $sitelogo
);
break;
case 'json':
diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php
index ca1d21772..14c62a52e 100644
--- a/actions/apitimelineuser.php
+++ b/actions/apitimelineuser.php
@@ -112,6 +112,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
function showTimeline()
{
$profile = $this->user->getProfile();
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$sitename = common_config('site', 'name');
$title = sprintf(_("%s timeline"), $this->user->nickname);
@@ -125,6 +126,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
_('Updates from %1$s on %2$s!'),
$this->user->nickname, $sitename
);
+ $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
// FriendFeed's SUP protocol
// Also added RSS and Atom feeds
@@ -139,7 +141,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
case 'rss':
$this->showRssTimeline(
$this->notices, $title, $link,
- $subtitle, $suplink
+ $subtitle, $suplink, $logo
);
break;
case 'atom':
@@ -153,7 +155,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
}
$this->showAtomTimeline(
$this->notices, $title, $id, $link,
- $subtitle, $suplink, $selfuri
+ $subtitle, $suplink, $selfuri, $logo
);
break;
case 'json':
diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php
index 879e44842..cf4525552 100644
--- a/actions/avatarsettings.php
+++ b/actions/avatarsettings.php
@@ -118,53 +118,56 @@ class AvatarsettingsAction extends AccountSettingsAction
$this->elementStart('fieldset');
$this->element('legend', null, _('Avatar settings'));
$this->hidden('token', common_session_token());
-
- $this->elementStart('ul', 'form_data');
- if ($original) {
- $this->elementStart('li', array('id' => 'avatar_original',
- 'class' => 'avatar_view'));
- $this->element('h2', null, _("Original"));
- $this->elementStart('div', array('id'=>'avatar_original_view'));
- $this->element('img', array('src' => $original->url,
- 'width' => $original->width,
- 'height' => $original->height,
- 'alt' => $user->nickname));
- $this->elementEnd('div');
+
+ if (Event::handle('StartAvatarFormData', array($this))) {
+ $this->elementStart('ul', 'form_data');
+ if ($original) {
+ $this->elementStart('li', array('id' => 'avatar_original',
+ 'class' => 'avatar_view'));
+ $this->element('h2', null, _("Original"));
+ $this->elementStart('div', array('id'=>'avatar_original_view'));
+ $this->element('img', array('src' => $original->url,
+ 'width' => $original->width,
+ 'height' => $original->height,
+ 'alt' => $user->nickname));
+ $this->elementEnd('div');
+ $this->elementEnd('li');
+ }
+
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+
+ if ($avatar) {
+ $this->elementStart('li', array('id' => 'avatar_preview',
+ 'class' => 'avatar_view'));
+ $this->element('h2', null, _("Preview"));
+ $this->elementStart('div', array('id'=>'avatar_preview_view'));
+ $this->element('img', array('src' => $original->url,
+ 'width' => AVATAR_PROFILE_SIZE,
+ 'height' => AVATAR_PROFILE_SIZE,
+ 'alt' => $user->nickname));
+ $this->elementEnd('div');
+ $this->submit('delete', _('Delete'));
+ $this->elementEnd('li');
+ }
+
+ $this->elementStart('li', array ('id' => 'settings_attach'));
+ $this->element('input', array('name' => 'avatarfile',
+ 'type' => 'file',
+ 'id' => 'avatarfile'));
+ $this->element('input', array('name' => 'MAX_FILE_SIZE',
+ 'type' => 'hidden',
+ 'id' => 'MAX_FILE_SIZE',
+ 'value' => ImageFile::maxFileSizeInt()));
$this->elementEnd('li');
- }
-
- $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ $this->elementEnd('ul');
- if ($avatar) {
- $this->elementStart('li', array('id' => 'avatar_preview',
- 'class' => 'avatar_view'));
- $this->element('h2', null, _("Preview"));
- $this->elementStart('div', array('id'=>'avatar_preview_view'));
- $this->element('img', array('src' => $original->url,
- 'width' => AVATAR_PROFILE_SIZE,
- 'height' => AVATAR_PROFILE_SIZE,
- 'alt' => $user->nickname));
- $this->elementEnd('div');
- $this->submit('delete', _('Delete'));
+ $this->elementStart('ul', 'form_actions');
+ $this->elementStart('li');
+ $this->submit('upload', _('Upload'));
$this->elementEnd('li');
+ $this->elementEnd('ul');
}
-
- $this->elementStart('li', array ('id' => 'settings_attach'));
- $this->element('input', array('name' => 'avatarfile',
- 'type' => 'file',
- 'id' => 'avatarfile'));
- $this->element('input', array('name' => 'MAX_FILE_SIZE',
- 'type' => 'hidden',
- 'id' => 'MAX_FILE_SIZE',
- 'value' => ImageFile::maxFileSizeInt()));
- $this->elementEnd('li');
- $this->elementEnd('ul');
-
- $this->elementStart('ul', 'form_actions');
- $this->elementStart('li');
- $this->submit('upload', _('Upload'));
- $this->elementEnd('li');
- $this->elementEnd('ul');
+ Event::handle('EndAvatarFormData', array($this));
$this->elementEnd('fieldset');
$this->elementEnd('form');
@@ -266,15 +269,18 @@ class AvatarsettingsAction extends AccountSettingsAction
'Try again, please.'));
return;
}
-
- if ($this->arg('upload')) {
- $this->uploadAvatar();
- } else if ($this->arg('crop')) {
- $this->cropAvatar();
- } else if ($this->arg('delete')) {
- $this->deleteAvatar();
- } else {
- $this->showForm(_('Unexpected form submission.'));
+
+ if (Event::handle('StartAvatarSaveForm', array($this))) {
+ if ($this->arg('upload')) {
+ $this->uploadAvatar();
+ } else if ($this->arg('crop')) {
+ $this->cropAvatar();
+ } else if ($this->arg('delete')) {
+ $this->deleteAvatar();
+ } else {
+ $this->showForm(_('Unexpected form submission.'));
+ }
+ Event::handle('EndAvatarSaveForm', array($this));
}
}
diff --git a/actions/file.php b/actions/file.php
index 10c59a961..c6f7b998a 100644
--- a/actions/file.php
+++ b/actions/file.php
@@ -31,15 +31,15 @@ class FileAction extends Action
parent::prepare($args);
$this->id = $this->trimmed('notice');
if (empty($this->id)) {
- $this->clientError(_('No notice id'));
+ $this->clientError(_('No notice ID.'));
}
$notice = Notice::staticGet('id', $this->id);
if (empty($notice)) {
- $this->clientError(_('No notice'));
+ $this->clientError(_('No notice.'));
}
$atts = $notice->attachments();
if (empty($atts)) {
- $this->clientError(_('No attachments'));
+ $this->clientError(_('No attachments.'));
}
foreach ($atts as $att) {
if (!empty($att->filename)) {
@@ -48,7 +48,7 @@ class FileAction extends Action
}
}
if (empty($this->filerec)) {
- $this->clientError(_('No uploaded attachments'));
+ $this->clientError(_('No uploaded attachments.'));
}
return true;
}
diff --git a/actions/grouprss.php b/actions/grouprss.php
index 50e48a67e..866fc66eb 100644
--- a/actions/grouprss.php
+++ b/actions/grouprss.php
@@ -88,14 +88,14 @@ class groupRssAction extends Rss10Action
}
if (!$nickname) {
- $this->clientError(_('No nickname'), 404);
+ $this->clientError(_('No nickname.'), 404);
return false;
}
$this->group = User_group::staticGet('nickname', $nickname);
if (!$this->group) {
- $this->clientError(_('No such group'), 404);
+ $this->clientError(_('No such group.'), 404);
return false;
}
diff --git a/actions/login.php b/actions/login.php
index cd1326813..c775fa692 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -75,10 +75,16 @@ class LoginAction extends Action
function handle($args)
{
parent::handle($args);
+
+ $disabled = common_config('logincommand','disabled');
+ $disabled = isset($disabled) && $disabled;
+
if (common_is_real_login()) {
$this->clientError(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$this->checkLogin();
+ } else if (!$disabled && isset($args['user_id']) && isset($args['token'])){
+ $this->checkLogin($args['user_id'],$args['token']);
} else {
common_ensure_session();
$this->showForm();
@@ -95,7 +101,7 @@ class LoginAction extends Action
* @return void
*/
- function checkLogin()
+ function checkLogin($user_id=null, $token=null)
{
if(isset($token) && isset($user_id)){
//Token based login (from the LoginCommand)
@@ -137,11 +143,6 @@ class LoginAction extends Action
$user = common_check_user($nickname, $password);
}
- $nickname = common_canonical_nickname($this->trimmed('nickname'));
- $password = $this->arg('password');
-
- $user = common_check_user($nickname, $password);
-
if (!$user) {
$this->showForm(_('Incorrect username or password.'));
return;
diff --git a/actions/newmessage.php b/actions/newmessage.php
index 0db2e7181..350452091 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -173,7 +173,7 @@ class NewmessageAction extends Action
return;
}
- $this->notify($user, $this->other, $message);
+ $message->notify();
if ($this->boolean('ajax')) {
$this->startHTML('text/xml;charset=utf-8');
@@ -247,12 +247,6 @@ class NewmessageAction extends Action
}
}
- function notify($from, $to, $message)
- {
- mail_notify_message($message, $from, $to);
- // XXX: Jabber, SMS notifications... probably queued
- }
-
// Do nothing (override)
function showNoticeForm()
diff --git a/actions/newnotice.php b/actions/newnotice.php
index dd6da0b01..c6c70e326 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -187,10 +187,12 @@ class NewnoticeAction extends Action
}
}
- $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
- ($replyto == 'false') ? null : $replyto,
- null, null,
- $lat, $lon, $location_id, $location_ns);
+ $notice = Notice::saveNew($user->id, $content_shortened, 'web',
+ array('reply_to' => ($replyto == 'false') ? null : $replyto,
+ 'lat' => $lat,
+ 'lon' => $lon,
+ 'location_id' => $location_id,
+ 'location_ns' => $location_ns));
if (isset($upload)) {
$upload->attachToNotice($notice);
diff --git a/actions/repeat.php b/actions/repeat.php
new file mode 100644
index 000000000..b75523498
--- /dev/null
+++ b/actions/repeat.php
@@ -0,0 +1,126 @@
+<?php
+
+/**
+ * Repeat action.
+ *
+ * PHP version 5
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ *
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, 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
+ * 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/>.
+ */
+
+if (!defined('STATUSNET')) {
+ exit(1);
+}
+
+/**
+ * Repeat action
+ *
+ * @category Action
+ * @package StatusNet
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
+ * @link http://status.net/
+ */
+
+class RepeatAction extends Action
+{
+ var $user = null;
+ var $notice = null;
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $this->user = common_current_user();
+
+ if (empty($this->user)) {
+ $this->clientError(_("Only logged-in users can repeat notices."));
+ return false;
+ }
+
+ $id = $this->trimmed('notice');
+
+ if (empty($id)) {
+ $this->clientError(_("No notice specified."));
+ return false;
+ }
+
+ $this->notice = Notice::staticGet('id', $id);
+
+ if (empty($this->notice)) {
+ $this->clientError(_("No notice specified."));
+ return false;
+ }
+
+ if ($this->user->id == $this->notice->profile_id) {
+ $this->clientError(_("You can't repeat your own notice."));
+ return false;
+ }
+
+ $token = $this->trimmed('token-'.$id);
+
+ if (empty($token) || $token != common_session_token()) {
+ $this->clientError(_("There was a problem with your session token. Try again, please."));
+ return false;
+ }
+
+ $profile = $this->user->getProfile();
+
+ if ($profile->hasRepeated($id)) {
+ $this->clientError(_("You already repeated that notice."));
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Class handler.
+ *
+ * @param array $args query arguments
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ $repeat = $this->notice->repeat($this->user->id, 'web');
+
+ common_broadcast_notice($repeat);
+
+ if ($this->boolean('ajax')) {
+ $this->startHTML('text/xml;charset=utf-8');
+ $this->elementStart('head');
+ $this->element('title', null, _('Repeated'));
+ $this->elementEnd('head');
+ $this->elementStart('body');
+ $this->element('p', array('id' => 'repeat_response',
+ 'class' => 'repeated'),
+ _('Repeated!'));
+ $this->elementEnd('body');
+ $this->elementEnd('html');
+ } else {
+ // FIXME!
+ }
+ }
+}
diff --git a/actions/showstream.php b/actions/showstream.php
index 663638c18..74b46cc95 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -269,4 +269,50 @@ class ProfileNoticeListItem extends NoticeListItem
{
return;
}
+
+ /**
+ * show a link to the author of repeat
+ *
+ * @return void
+ */
+
+ function showRepeat()
+ {
+ if (!empty($this->repeat)) {
+
+ // FIXME: this code is almost identical to default; need to refactor
+
+ $attrs = array('href' => $this->profile->profileurl,
+ 'class' => 'url');
+
+ if (!empty($this->profile->fullname)) {
+ $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
+ }
+
+ $this->out->elementStart('span', 'repeat');
+
+ $this->out->elementStart('a', $attrs);
+
+ $avatar = $this->profile->getAvatar(AVATAR_MINI_SIZE);
+
+ $this->out->element('img', array('src' => ($avatar) ?
+ $avatar->displayUrl() :
+ Avatar::defaultImage(AVATAR_MINI_SIZE),
+ 'class' => 'avatar photo',
+ 'width' => AVATAR_MINI_SIZE,
+ 'height' => AVATAR_MINI_SIZE,
+ 'alt' =>
+ ($this->profile->fullname) ?
+ $this->profile->fullname :
+ $this->profile->nickname));
+
+ $this->out->elementEnd('a');
+
+ $text_link = XMLStringer::estring('a', $attrs, $this->profile->nickname);
+
+ $this->out->raw(sprintf(_('Repeat of %s'), $text_link));
+
+ $this->out->elementEnd('span');
+ }
+ }
}
diff --git a/actions/subscribers.php b/actions/subscribers.php
index df9ec9961..cc9452820 100644
--- a/actions/subscribers.php
+++ b/actions/subscribers.php
@@ -57,7 +57,7 @@ class SubscribersAction extends GalleryAction
function showPageNotice()
{
- $user =& common_current_user();
+ $user = common_current_user();
if ($user && ($user->id == $this->profile->id)) {
$this->element('p', null,
_('These are the people who listen to '.
diff --git a/actions/subscriptions.php b/actions/subscriptions.php
index cc7b38ee4..0dc5ee762 100644
--- a/actions/subscriptions.php
+++ b/actions/subscriptions.php
@@ -59,7 +59,7 @@ class SubscriptionsAction extends GalleryAction
function showPageNotice()
{
- $user =& common_current_user();
+ $user = common_current_user();
if ($user && ($user->id == $this->profile->id)) {
$this->element('p', null,
_('These are the people whose notices '.
diff --git a/actions/tagother.php b/actions/tagother.php
index c3f43be8b..e9e13b939 100644
--- a/actions/tagother.php
+++ b/actions/tagother.php
@@ -30,13 +30,13 @@ class TagotherAction extends Action
{
parent::prepare($args);
if (!common_logged_in()) {
- $this->clientError(_('Not logged in'), 403);
+ $this->clientError(_('Not logged in.'), 403);
return false;
}
$id = $this->trimmed('id');
if (!$id) {
- $this->clientError(_('No id argument.'));
+ $this->clientError(_('No ID argument.'));
return false;
}
diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php
index 526ca2ae8..1cb8d7efe 100644
--- a/actions/twitapisearchatom.php
+++ b/actions/twitapisearchatom.php
@@ -71,7 +71,7 @@ class TwitapisearchatomAction extends ApiAction
* @see Action::__construct
*/
- function __construct($output='php://output', $indent=true)
+ function __construct($output='php://output', $indent=null)
{
parent::__construct($output, $indent);
}
diff --git a/actions/userbyid.php b/actions/userbyid.php
index 86a61f20b..f3e1556f3 100644
--- a/actions/userbyid.php
+++ b/actions/userbyid.php
@@ -47,17 +47,17 @@ class UserbyidAction extends Action
{
/**
* Is read only?
- *
+ *
* @return boolean true
*/
function isReadOnly($args)
- {
+ {
return true;
}
/**
* Class handler.
- *
+ *
* @param array $args array of arguments
*
* @return nothing
@@ -67,9 +67,9 @@ class UserbyidAction extends Action
parent::handle($args);
$id = $this->trimmed('id');
if (!$id) {
- $this->clientError(_('No id.'));
+ $this->clientError(_('No ID.'));
}
- $user =& User::staticGet($id);
+ $user = User::staticGet($id);
if (!$user) {
$this->clientError(_('No such user.'));
}
@@ -88,4 +88,3 @@ class UserbyidAction extends Action
common_redirect($url, 303);
}
}
-