summaryrefslogtreecommitdiff
path: root/actions
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-02-26 13:22:51 -0800
committerEvan Prodromou <evan@controlyourself.ca>2009-02-26 13:22:51 -0800
commit34a61b40f47a52d1fdcf7cd907f3ac53b96b038e (patch)
tree14ddeb18d9e020760d8c2308a12d858b6eab4a17 /actions
parent478192fa3b2375a0ff0a5ff03956381e5da7a6ac (diff)
parent8c3fe83c645265a11a3fca80cac2ac48ea72cdab (diff)
Merge branch '0.7.x' into 0.8.x
Diffstat (limited to 'actions')
-rw-r--r--actions/all.php36
-rw-r--r--actions/allrss.php14
-rw-r--r--actions/api.php10
-rw-r--r--actions/avatarsettings.php26
-rw-r--r--actions/doc.php12
-rw-r--r--actions/emailsettings.php7
-rw-r--r--actions/finishopenidlogin.php17
-rw-r--r--actions/finishremotesubscribe.php8
-rw-r--r--actions/grouprss.php15
-rw-r--r--actions/login.php6
-rw-r--r--actions/newmessage.php2
-rw-r--r--actions/newnotice.php17
-rw-r--r--actions/noticesearch.php42
-rw-r--r--actions/peoplesearch.php26
-rw-r--r--actions/public.php43
-rw-r--r--actions/replies.php28
-rw-r--r--actions/showfavorites.php33
-rw-r--r--actions/showgroup.php27
-rw-r--r--actions/showstream.php101
-rw-r--r--actions/tag.php22
-rw-r--r--actions/tagother.php5
-rw-r--r--actions/twitapiaccount.php25
-rw-r--r--actions/twitapistatuses.php54
-rw-r--r--actions/twittersettings.php5
-rw-r--r--actions/userauthorization.php8
-rw-r--r--actions/userrss.php11
26 files changed, 277 insertions, 323 deletions
diff --git a/actions/all.php b/actions/all.php
index d75d1b946..08dcccbdd 100644
--- a/actions/all.php
+++ b/actions/all.php
@@ -42,9 +42,9 @@ class AllAction extends Action
if (!$this->page) {
$this->page = 1;
}
-
+
common_set_returnto($this->selfUrl());
-
+
return true;
}
@@ -69,13 +69,22 @@ class AllAction extends Action
}
}
- function showFeeds()
+ function getFeeds()
{
- $this->element('link', array('rel' => 'alternate',
- 'href' => common_local_url('allrss', array('nickname' =>
- $this->user->nickname)),
- 'type' => 'application/rss+xml',
- 'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname)));
+ return array(new Feed(Feed::RSS1,
+ common_local_url('allrss', array('nickname' =>
+ $this->user->nickname)),
+ sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
+ new Feed(Feed::RSS2,
+ common_local_url('api', array('apiaction' => 'statuses',
+ 'method' => 'friends',
+ 'argument' => $this->user->nickname.'.rss')),
+ sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
+ new Feed(Feed::ATOM,
+ common_local_url('api', array('apiaction' => 'statuses',
+ 'method' => 'friends',
+ 'argument' => $this->user->nickname.'.atom')),
+ sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)));
}
function showLocalNav()
@@ -84,15 +93,6 @@ class AllAction extends Action
$nav->show();
}
- function showExportData()
- {
- $fl = new FeedList($this);
- $fl->show(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $this->user->nickname)),
- 'type' => 'rss',
- 'version' => 'RSS 1.0',
- 'item' => 'allrss')));
- }
-
function showContent()
{
$notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
@@ -110,7 +110,7 @@ class AllAction extends Action
$user =& common_current_user();
if ($user && ($user->id == $this->user->id)) {
$this->element('h1', NULL, _("You and friends"));
- } else {
+ } else {
$this->element('h1', NULL, sprintf(_('%s and friends'), $this->user->nickname));
}
}
diff --git a/actions/allrss.php b/actions/allrss.php
index 05787f3f7..0114c4396 100644
--- a/actions/allrss.php
+++ b/actions/allrss.php
@@ -53,7 +53,9 @@ class AllrssAction extends Rss10Action
/**
* Initialization.
- *
+ *
+ * @param array $args Web and URL arguments
+ *
* @return boolean false if user doesn't exist
*/
function prepare($args)
@@ -81,7 +83,7 @@ class AllrssAction extends Rss10Action
{
$user = $this->user;
$notice = $user->noticesWithFriends(0, $limit);
-
+
while ($notice->fetch()) {
$notices[] = clone($notice);
}
@@ -104,7 +106,8 @@ class AllrssAction extends Rss10Action
'link' => common_local_url('all',
array('nickname' =>
$user->nickname)),
- 'description' => sprintf(_('Feed for friends of %s'), $user->nickname));
+ 'description' => sprintf(_('Feed for friends of %s'),
+ $user->nickname));
return $c;
}
@@ -123,10 +126,5 @@ class AllrssAction extends Rss10Action
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
return $avatar ? $avatar->url : null;
}
-
- function isReadOnly()
- {
- return true;
- }
}
diff --git a/actions/api.php b/actions/api.php
index 21fe4eea3..a27d24492 100644
--- a/actions/api.php
+++ b/actions/api.php
@@ -131,14 +131,14 @@ class ApiAction extends Action
'statuses/followers',
'favorites/favorites');
- # If the site is "private", all API methods need authentication
-
+ $fullname = "$this->api_action/$this->api_method";
+
+ // If the site is "private", all API methods except laconica/config
+ // need authentication
if (common_config('site', 'private')) {
- return true;
+ return $fullname != 'laconica/config' || false;
}
- $fullname = "$this->api_action/$this->api_method";
-
if (in_array($fullname, $bareauth)) {
# bareauth: only needs auth if without an argument
if ($this->api_arg) {
diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php
index 7dd53f6eb..f38a44a24 100644
--- a/actions/avatarsettings.php
+++ b/actions/avatarsettings.php
@@ -145,6 +145,7 @@ class AvatarsettingsAction extends AccountSettingsAction
'height' => AVATAR_PROFILE_SIZE,
'alt' => $user->nickname));
$this->elementEnd('div');
+ $this->submit('delete', _('Delete'));
$this->elementEnd('li');
}
@@ -256,6 +257,8 @@ class AvatarsettingsAction extends AccountSettingsAction
$this->uploadAvatar();
} else if ($this->arg('crop')) {
$this->cropAvatar();
+ } else if ($this->arg('delete')) {
+ $this->deleteAvatar();
} else {
$this->showForm(_('Unexpected form submission.'));
}
@@ -344,6 +347,29 @@ class AvatarsettingsAction extends AccountSettingsAction
$this->showForm(_('Failed updating avatar.'));
}
}
+
+ /**
+ * Get rid of the current avatar.
+ *
+ * @return void
+ */
+
+ function deleteAvatar()
+ {
+ $user = common_current_user();
+ $profile = $user->getProfile();
+
+ $avatar = $profile->getOriginalAvatar();
+ $avatar->delete();
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ $avatar->delete();
+ $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
+ $avatar->delete();
+ $avatar = $profile->getAvatar(AVATAR_MINI_SIZE);
+ $avatar->delete();
+
+ $this->showForm(_('Avatar deleted.'), true);
+ }
/**
* Add the jCrop stylesheet
diff --git a/actions/doc.php b/actions/doc.php
index 6957659ad..ebffb7c15 100644
--- a/actions/doc.php
+++ b/actions/doc.php
@@ -50,7 +50,7 @@ class DocAction extends Action
/**
* Class handler.
- *
+ *
* @param array $args array of arguments
*
* @return nothing
@@ -59,7 +59,7 @@ class DocAction extends Action
{
parent::handle($args);
$this->title = $this->trimmed('title');
- $this->filename = INSTALLDIR.'/doc/'.$this->title;
+ $this->filename = INSTALLDIR.'/doc-src/'.$this->title;
if (!file_exists($this->filename)) {
$this->clientError(_('No such document.'));
return;
@@ -71,14 +71,14 @@ class DocAction extends Action
function showPageTitle() {
$this->element('h1', array('class' => 'entry-title'), $this->title());
}
-
+
// overrided to add hentry, and content-inner classes
function showContentBlock()
{
$this->elementStart('div', array('id' => 'content', 'class' => 'hentry'));
$this->showPageTitle();
$this->showPageNoticeBlock();
- $this->elementStart('div', array('id' => 'content_inner',
+ $this->elementStart('div', array('id' => 'content_inner',
'class' => 'entry-content'));
// show the actual content (forms, lists, whatever)
$this->showContent();
@@ -88,7 +88,7 @@ class DocAction extends Action
/**
* Display content.
- *
+ *
* @return nothing
*/
function showContent()
@@ -100,7 +100,7 @@ class DocAction extends Action
/**
* Page title.
- *
+ *
* @return page title
*/
function title()
diff --git a/actions/emailsettings.php b/actions/emailsettings.php
index b84acb214..634388fdd 100644
--- a/actions/emailsettings.php
+++ b/actions/emailsettings.php
@@ -164,6 +164,11 @@ class EmailsettingsAction extends AccountSettingsAction
$user->emailnotifymsg);
$this->elementEnd('li');
$this->elementStart('li');
+ $this->checkbox('emailnotifyattn',
+ _('Send me email when someone sends me an "@-reply".'),
+ $user->emailnotifyattn);
+ $this->elementEnd('li');
+ $this->elementStart('li');
$this->checkbox('emailnotifynudge',
_('Allow friends to nudge me and send me an email.'),
$user->emailnotifynudge);
@@ -255,6 +260,7 @@ class EmailsettingsAction extends AccountSettingsAction
$emailnotifyfav = $this->boolean('emailnotifyfav');
$emailnotifymsg = $this->boolean('emailnotifymsg');
$emailnotifynudge = $this->boolean('emailnotifynudge');
+ $emailnotifyattn = $this->boolean('emailnotifyattn');
$emailmicroid = $this->boolean('emailmicroid');
$emailpost = $this->boolean('emailpost');
@@ -270,6 +276,7 @@ class EmailsettingsAction extends AccountSettingsAction
$user->emailnotifyfav = $emailnotifyfav;
$user->emailnotifymsg = $emailnotifymsg;
$user->emailnotifynudge = $emailnotifynudge;
+ $user->emailnotifyattn = $emailnotifyattn;
$user->emailmicroid = $emailmicroid;
$user->emailpost = $emailpost;
diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php
index 1e7b73a7f..6d92cb9aa 100644
--- a/actions/finishopenidlogin.php
+++ b/actions/finishopenidlogin.php
@@ -83,7 +83,7 @@ class FinishopenidloginAction extends Action
function showContent()
{
- if ($this->message_text) {
+ if (!empty($this->message_text)) {
$this->element('p', null, $this->message);
return;
}
@@ -232,7 +232,8 @@ class FinishopenidloginAction extends Action
return;
}
- if ($sreg['country']) {
+ $location = '';
+ if (!empty($sreg['country'])) {
if ($sreg['postcode']) {
# XXX: use postcode to get city and region
# XXX: also, store postcode somewhere -- it's valuable!
@@ -242,12 +243,16 @@ class FinishopenidloginAction extends Action
}
}
- if ($sreg['fullname'] && mb_strlen($sreg['fullname']) <= 255) {
+ if (!empty($sreg['fullname']) && mb_strlen($sreg['fullname']) <= 255) {
$fullname = $sreg['fullname'];
+ } else {
+ $fullname = '';
}
- if ($sreg['email'] && Validate::email($sreg['email'], true)) {
+ if (!empty($sreg['email']) && Validate::email($sreg['email'], true)) {
$email = $sreg['email'];
+ } else {
+ $email = '';
}
# XXX: add language
@@ -328,7 +333,7 @@ class FinishopenidloginAction extends Action
# Try the passed-in nickname
- if ($sreg['nickname']) {
+ if (!empty($sreg['nickname'])) {
$nickname = $this->nicknamize($sreg['nickname']);
if ($this->isNewNickname($nickname)) {
return $nickname;
@@ -337,7 +342,7 @@ class FinishopenidloginAction extends Action
# Try the full name
- if ($sreg['fullname']) {
+ if (!empty($sreg['fullname'])) {
$fullname = $this->nicknamize($sreg['fullname']);
if ($this->isNewNickname($fullname)) {
return $fullname;
diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php
index f9094a50c..76db887de 100644
--- a/actions/finishremotesubscribe.php
+++ b/actions/finishremotesubscribe.php
@@ -237,7 +237,13 @@ class FinishremotesubscribeAction extends Action
{
$temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
copy($url, $temp_filename);
- return $profile->setOriginal($temp_filename);
+ $imagefile = new ImageFile($profile->id, $temp_filename);
+ $filename = Avatar::filename($profile->id,
+ image_type_to_extension($imagefile->type),
+ null,
+ common_timestamp());
+ rename($temp_filename, Avatar::path($filename));
+ return $profile->setOriginal($filename);
}
function access_token($omb)
diff --git a/actions/grouprss.php b/actions/grouprss.php
index 1a7b858b1..de76a5960 100644
--- a/actions/grouprss.php
+++ b/actions/grouprss.php
@@ -111,13 +111,13 @@ class groupRssAction extends Rss10Action
{
$group = $this->group;
-
+
if (is_null($group)) {
return null;
}
-
+
$notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
-
+
while ($notice->fetch()) {
$notices[] = clone($notice);
}
@@ -141,13 +141,4 @@ class groupRssAction extends Rss10Action
{
return $this->group->homepage_logo;
}
-
- # override parent to add X-SUP-ID URL
-
- function initRss($limit=0)
- {
- $url = common_local_url('sup', null, $this->group->id);
- header('X-SUP-ID: '.$url);
- parent::initRss($limit);
- }
}
diff --git a/actions/login.php b/actions/login.php
index 71e467929..b049791fb 100644
--- a/actions/login.php
+++ b/actions/login.php
@@ -108,13 +108,15 @@ class LoginAction extends Action
$nickname = common_canonical_nickname($this->trimmed('nickname'));
$password = $this->arg('password');
- if (!common_check_user($nickname, $password)) {
+ $user = common_check_user($nickname, $password);
+
+ if (!$user) {
$this->showForm(_('Incorrect username or password.'));
return;
}
// success!
- if (!common_set_user($nickname)) {
+ if (!common_set_user($user)) {
$this->serverError(_('Error setting user.'));
return;
}
diff --git a/actions/newmessage.php b/actions/newmessage.php
index f83015a37..82276ff34 100644
--- a/actions/newmessage.php
+++ b/actions/newmessage.php
@@ -201,7 +201,7 @@ class NewmessageAction extends Action
function showNoticeForm()
{
- $message_form = new MessageForm($this, $this->to, $this->content);
+ $message_form = new MessageForm($this, $this->other, $this->content);
$message_form->show();
}
}
diff --git a/actions/newnotice.php b/actions/newnotice.php
index 5e7691f33..9face9644 100644
--- a/actions/newnotice.php
+++ b/actions/newnotice.php
@@ -98,7 +98,12 @@ class NewnoticeAction extends Action
return;
}
- $this->saveNewNotice();
+ try {
+ $this->saveNewNotice();
+ } catch (Exception $e) {
+ $this->showForm($e->getMessage());
+ return;
+ }
} else {
$this->showForm();
}
@@ -123,15 +128,13 @@ class NewnoticeAction extends Action
$content = $this->trimmed('status_textarea');
if (!$content) {
- $this->showForm(_('No content!'));
- return;
+ $this->clientError(_('No content!'));
} else {
$content_shortened = common_shorten_links($content);
if (mb_strlen($content_shortened) > 140) {
- $this->showForm(_('That\'s too long. '.
- 'Max notice size is 140 chars.'));
- return;
+ $this->clientError(_('That\'s too long. '.
+ 'Max notice size is 140 chars.'));
}
}
@@ -154,7 +157,7 @@ class NewnoticeAction extends Action
($replyto == 'false') ? null : $replyto);
if (is_string($notice)) {
- $this->showForm($notice);
+ $this->clientError($notice);
return;
}
diff --git a/actions/noticesearch.php b/actions/noticesearch.php
index a5f01350c..dc58d7528 100644
--- a/actions/noticesearch.php
+++ b/actions/noticesearch.php
@@ -57,11 +57,11 @@ class NoticesearchAction extends SearchAction
return true;
}
-
+
/**
* Get instructions
- *
- * @return string instruction text
+ *
+ * @return string instruction text
*/
function getInstructions()
{
@@ -70,7 +70,7 @@ class NoticesearchAction extends SearchAction
/**
* Get title
- *
+ *
* @return string title
*/
function title()
@@ -78,6 +78,20 @@ class NoticesearchAction extends SearchAction
return _('Text search');
}
+ function getFeeds()
+ {
+ $q = $this->trimmed('q');
+
+ if (!$q) {
+ return null;
+ }
+
+ return array(new Feed(Feed::RSS1, common_local_url('noticesearchrss',
+ array('q' => $q)),
+ sprintf(_('Search results for "%s" on %s'),
+ $q, common_config('site', 'name'))));
+ }
+
/**
* Show results
*
@@ -120,26 +134,6 @@ class NoticesearchAction extends SearchAction
}
/**
- * Show header
- *
- * @param array $arr array containing the query
- *
- * @return void
- */
-
- function extraHead()
- {
- $q = $this->trimmed('q');
- if ($q) {
- $this->element('link', array('rel' => 'alternate',
- 'href' => common_local_url('noticesearchrss',
- array('q' => $q)),
- 'type' => 'application/rss+xml',
- 'title' => _('Search Stream Feed')));
- }
- }
-
- /**
* Show notice
*
* @param class $notice notice
diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php
index 615201c46..14177fcf0 100644
--- a/actions/peoplesearch.php
+++ b/actions/peoplesearch.php
@@ -86,33 +86,9 @@ class PeoplesearchAction extends SearchAction
}
$profile->free();
-
+
$this->pagination($page > 1, $cnt > PROFILES_PER_PAGE,
$page, 'peoplesearch', array('q' => $q));
}
}
-class PeopleSearchResults extends ProfileList
-{
- var $terms = null;
- var $pattern = null;
-
- function __construct($profile, $terms, $action)
- {
- parent::__construct($profile, $terms, $action);
- $this->terms = array_map('preg_quote',
- array_map('htmlspecialchars', $terms));
- $this->pattern = '/('.implode('|',$terms).')/i';
- }
-
- function highlight($text)
- {
- return preg_replace($this->pattern, '<strong>\\1</strong>', htmlspecialchars($text));
- }
-
- function isReadOnly()
- {
- return true;
- }
-}
-
diff --git a/actions/public.php b/actions/public.php
index cc6537f74..a20ae4032 100644
--- a/actions/public.php
+++ b/actions/public.php
@@ -73,9 +73,9 @@ class PublicAction extends Action
{
parent::prepare($args);
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-
+
common_set_returnto($this->selfUrl());
-
+
return true;
}
@@ -119,12 +119,20 @@ class PublicAction extends Action
* @return void
*/
- function showFeeds()
+ function getFeeds()
{
- $this->element('link', array('rel' => 'alternate',
- 'href' => common_local_url('publicrss'),
- 'type' => 'application/rss+xml',
- 'title' => _('Public Stream Feed')));
+ return array(new Feed(Feed::RSS1, common_local_url('publicrss'),
+ _('Public Stream Feed (RSS 1.0)')),
+ new Feed(Feed::RSS2,
+ common_local_url('api',
+ array('apiaction' => 'statuses',
+ 'method' => 'public_timeline.rss')),
+ _('Public Stream Feed (RSS 2.0)')),
+ new Feed(Feed::ATOM,
+ common_local_url('api',
+ array('apiaction' => 'statuses',
+ 'method' => 'public_timeline.atom')),
+ _('Public Stream Feed (Atom)')));
}
/**
@@ -185,27 +193,6 @@ class PublicAction extends Action
$this->page, 'public');
}
- /**
- * Makes a list of exported feeds for this page
- *
- * @return void
- *
- * @todo I18N
- */
-
- function showExportData()
- {
- $fl = new FeedList($this);
- $fl->show(array(0 => array('href' => common_local_url('publicrss'),
- 'type' => 'rss',
- 'version' => 'RSS 1.0',
- 'item' => 'publicrss'),
- 1 => array('href' => common_local_url('publicatom'),
- 'type' => 'atom',
- 'version' => 'Atom 1.0',
- 'item' => 'publicatom')));
- }
-
function showSections()
{
// $top = new TopPostersSection($this);
diff --git a/actions/replies.php b/actions/replies.php
index 7eff74a66..4ab9b14ed 100644
--- a/actions/replies.php
+++ b/actions/replies.php
@@ -84,7 +84,7 @@ class RepliesAction extends Action
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
common_set_returnto($this->selfUrl());
-
+
return true;
}
@@ -129,16 +129,13 @@ class RepliesAction extends Action
* @return void
*/
- function showFeeds()
+ function getFeeds()
{
$rssurl = common_local_url('repliesrss',
array('nickname' => $this->user->nickname));
$rsstitle = sprintf(_('Feed for replies to %s'), $this->user->nickname);
- $this->element('link', array('rel' => 'alternate',
- 'href' => $rssurl,
- 'type' => 'application/rss+xml',
- 'title' => $rsstitle));
+ return array(new Feed(Feed::RSS1, $rssurl, $rsstitle));
}
/**
@@ -154,25 +151,6 @@ class RepliesAction extends Action
}
/**
- * Show the replies feed links
- *
- * @return void
- */
-
- function showExportData()
- {
- $fl = new FeedList($this);
-
- $rssurl = common_local_url('repliesrss',
- array('nickname' => $this->user->nickname));
-
- $fl->show(array(0=>array('href'=> $rssurl,
- 'type' => 'rss',
- 'version' => 'RSS 1.0',
- 'item' => 'repliesrss')));
- }
-
- /**
* Show the content
*
* A list of notices that are replies to the user, plus pagination.
diff --git a/actions/showfavorites.php b/actions/showfavorites.php
index 31479e1a7..d1c9283f0 100644
--- a/actions/showfavorites.php
+++ b/actions/showfavorites.php
@@ -113,7 +113,7 @@ class ShowfavoritesAction extends Action
}
common_set_returnto($this->selfUrl());
-
+
return true;
}
@@ -136,10 +136,10 @@ class ShowfavoritesAction extends Action
/**
* Feeds for the <head> section
*
- * @return void
+ * @return array Feed objects to show
*/
- function showFeeds()
+ function getFeeds()
{
$feedurl = common_local_url('favoritesrss',
array('nickname' =>
@@ -147,10 +147,7 @@ class ShowfavoritesAction extends Action
$feedtitle = sprintf(_('Feed for favorites of %s'),
$this->user->nickname);
- $this->element('link', array('rel' => 'alternate',
- 'href' => $feedurl,
- 'type' => 'application/rss+xml',
- 'title' => $feedtitle));
+ return array(new Feed(Feed::RSS1, $feedurl, $feedtitle));
}
/**
@@ -166,28 +163,6 @@ class ShowfavoritesAction extends Action
}
/**
- * Show the replies feed links
- *
- * @return void
- */
-
- function showExportData()
- {
- $feedurl = common_local_url('favoritesrss',
- array('nickname' =>
- $this->user->nickname));
-
- $fl = new FeedList($this);
-
- // XXX: I18N
-
- $fl->show(array(0=>array('href'=> $feedurl,
- 'type' => 'rss',
- 'version' => 'RSS 1.0',
- 'item' => 'Favorites')));
- }
-
- /**
* Show the content
*
* A list of notices that this user has marked as a favorite
diff --git a/actions/showgroup.php b/actions/showgroup.php
index 7bc68fbc6..c20941a35 100644
--- a/actions/showgroup.php
+++ b/actions/showgroup.php
@@ -244,7 +244,7 @@ class ShowgroupAction extends Action
if ($this->group->location) {
$this->elementStart('dl', 'entity_location');
$this->element('dt', null, _('Location'));
- $this->element('dd', 'location', $this->group->location);
+ $this->element('dd', 'label', $this->group->location);
$this->elementEnd('dl');
}
@@ -292,37 +292,18 @@ class ShowgroupAction extends Action
}
/**
- * Show a list of links to feeds this page produces
+ * Get a list of the feeds for this page
*
* @return void
*/
- function showExportData()
- {
- $fl = new FeedList($this);
- $fl->show(array(0=>array('href'=>common_local_url('grouprss',
- array('nickname' => $this->group->nickname)),
- 'type' => 'rss',
- 'version' => 'RSS 1.0',
- 'item' => 'notices')));
- }
-
- /**
- * Show a list of links to feeds this page produces
- *
- * @return void
- */
-
- function showFeeds()
+ function getFeeds()
{
$url =
common_local_url('grouprss',
array('nickname' => $this->group->nickname));
- $this->element('link', array('rel' => 'alternate',
- 'href' => $url,
- 'type' => 'application/rss+xml',
- 'title' => sprintf(_('Notice feed for %s group'),
+ return array(new Feed(Feed::RSS1, $url, sprintf(_('Notice feed for %s group'),
$this->group->nickname)));
}
diff --git a/actions/showstream.php b/actions/showstream.php
index 28bb8453f..65482167e 100644
--- a/actions/showstream.php
+++ b/actions/showstream.php
@@ -111,7 +111,7 @@ class ShowstreamAction extends Action
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
common_set_returnto($this->selfUrl());
-
+
return true;
}
@@ -155,58 +155,39 @@ class ShowstreamAction extends Action
return;
}
- function showExportData()
- {
- $fl = new FeedList($this);
- $fl->show(array(0=>array('href'=>common_local_url('userrss',
- array('nickname' => $this->user->nickname)),
- 'type' => 'rss',
- 'version' => 'RSS 1.0',
- 'item' => 'notices'),
- 1=>array('href'=>common_local_url('usertimeline',
- array('nickname' => $this->user->nickname)),
- 'type' => 'atom',
- 'version' => 'Atom 1.0',
- 'item' => 'usertimeline'),
- 2=>array('href'=>common_local_url('foaf',
- array('nickname' => $this->user->nickname)),
- 'type' => 'rdf',
- 'version' => 'FOAF',
- 'item' => 'foaf')));
- }
-
- function showFeeds()
+ function getFeeds()
{
- $this->element('link', array('rel' => 'alternate',
- 'type' => 'application/rss+xml',
- 'href' => common_local_url('userrss',
- array('nickname' => $this->user->nickname)),
- 'title' => sprintf(_('Notice feed for %s (RSS)'),
- $this->user->nickname)));
-
- $this->element('link',
- array('rel' => 'alternate',
- 'href' => common_local_url('api',
- array('apiaction' => 'statuses',
- 'method' => 'user_timeline.atom',
- 'argument' => $this->user->nickname)),
- 'type' => 'application/atom+xml',
- 'title' => sprintf(_('Notice feed for %s (Atom)'),
- $this->user->nickname)));
+ return array(new Feed(Feed::RSS1,
+ common_local_url('userrss',
+ array('nickname' => $this->user->nickname)),
+ sprintf(_('Notice feed for %s (RSS 1.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::RSS2,
+ common_local_url('api',
+ array('apiaction' => 'statuses',
+ 'method' => 'user_timeline',
+ 'argument' => $this->user->nickname.'.rss')),
+ sprintf(_('Notice feed for %s (RSS 2.0)'),
+ $this->user->nickname)),
+ new Feed(Feed::ATOM,
+ common_local_url('api',
+ array('apiaction' => 'statuses',
+ 'method' => 'user_timeline',
+ 'argument' => $this->user->nickname.'.atom')),
+ sprintf(_('Notice feed for %s (Atom)'),
+ $this->user->nickname)),
+ new Feed(Feed::FOAF,
+ common_local_url('foaf', array('nickname' =>
+ $this->user->nickname)),
+ sprintf(_('FOAF for %s'), $this->user->nickname)));
}
function extraHead()
{
- // FOAF
- $this->element('link', array('rel' => 'meta',
- 'href' => common_local_url('foaf', array('nickname' =>
- $this->user->nickname)),
- 'type' => 'application/rdf+xml',
- 'title' => 'FOAF'));
// for remote subscriptions etc.
$this->element('meta', array('http-equiv' => 'X-XRDS-Location',
'content' => common_local_url('xrds', array('nickname' =>
- $this->user->nickname))));
+ $this->user->nickname))));
if ($this->profile->bio) {
$this->element('meta', array('name' => 'description',
@@ -248,6 +229,15 @@ class ShowstreamAction extends Action
'height' => AVATAR_PROFILE_SIZE,
'alt' => $this->profile->nickname));
$this->elementEnd('dd');
+
+ $user = User::staticGet('id', $this->profile->id);
+ $cur = common_current_user();
+ if ($cur && $cur->id == $user->id) {
+ $this->elementStart('dd');
+ $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar'));
+ $this->elementEnd('dd');
+ }
+
$this->elementEnd('dl');
$this->elementStart('dl', 'entity_nickname');
@@ -256,7 +246,7 @@ class ShowstreamAction extends Action
$hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid';
$this->element('a', array('href' => $this->profile->profileurl,
'rel' => 'me', 'class' => $hasFN),
- $this->profile->nickname);
+ $this->profile->nickname);
$this->elementEnd('dd');
$this->elementEnd('dl');
@@ -272,7 +262,7 @@ class ShowstreamAction extends Action
if ($this->profile->location) {
$this->elementStart('dl', 'entity_location');
$this->element('dt', null, _('Location'));
- $this->element('dd', 'location', $this->profile->location);
+ $this->element('dd', 'label', $this->profile->location);
$this->elementEnd('dl');
}
@@ -302,11 +292,11 @@ class ShowstreamAction extends Action
$this->elementStart('ul', 'tags xoxo');
foreach ($tags as $tag) {
$this->elementStart('li');
- $this->element('span', 'mark_hash', '#');
- $this->element('a', array('rel' => 'tag',
- 'href' => common_local_url('peopletag',
- array('tag' => $tag))),
- $tag);
+ // Avoid space by using raw output.
+ $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
+ common_local_url('peopletag', array('tag' => $tag)) .
+ '">' . $tag . '</a>';
+ $this->raw($pt);
$this->elementEnd('li');
}
$this->elementEnd('ul');
@@ -324,7 +314,7 @@ class ShowstreamAction extends Action
$this->elementStart('li', 'entity_edit');
$this->element('a', array('href' => common_local_url('profilesettings'),
'title' => _('Edit profile settings')),
- _('Edit'));
+ _('Edit'));
$this->elementEnd('li');
}
@@ -346,9 +336,8 @@ class ShowstreamAction extends Action
$this->elementEnd('li');
}
- $user = User::staticGet('id', $this->profile->id);
if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) {
- $this->elementStart('li', 'entity_send-a-message');
+ $this->elementStart('li', 'entity_send-a-message');
$this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
'title' => _('Send a direct message to this user')),
_('Message'));
@@ -490,7 +479,7 @@ class ShowstreamAction extends Action
$this->elementStart('dl', 'entity_member-since');
$this->element('dt', null, _('Member since'));
$this->element('dd', null, date('j M Y',
- strtotime($this->profile->created)));
+ strtotime($this->profile->created)));
$this->elementEnd('dl');
$this->elementStart('dl', 'entity_subscriptions');
diff --git a/actions/tag.php b/actions/tag.php
index 4401f892a..231f2c299 100644
--- a/actions/tag.php
+++ b/actions/tag.php
@@ -37,9 +37,9 @@ class TagAction extends Action
}
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
-
+
common_set_returnto($this->selfUrl());
-
+
return true;
}
@@ -61,12 +61,11 @@ class TagAction extends Action
$this->showPage();
}
- function showFeeds()
+ function getFeeds()
{
- $this->element('link', array('rel' => 'alternate',
- 'href' => common_local_url('tagrss', array('tag' => $this->tag)),
- 'type' => 'application/rss+xml',
- 'title' => sprintf(_('Feed for tag %s'), $this->tag)));
+ return array(new Feed(Feed::RSS1,
+ common_local_url('tagrss', array('tag' => $this->tag)),
+ sprintf(_('Feed for tag %s'), $this->tag)));
}
function showPageNotice()
@@ -74,15 +73,6 @@ class TagAction extends Action
return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
}
- function showExportData()
- {
- $fl = new FeedList($this);
- $fl->show(array(0=>array('href'=>common_local_url('tagrss', array('tag' => $this->tag)),
- 'type' => 'rss',
- 'version' => 'RSS 1.0',
- 'item' => 'tagrss')));
- }
-
function showContent()
{
$notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
diff --git a/actions/tagother.php b/actions/tagother.php
index 3e8a12fd6..0d18945a0 100644
--- a/actions/tagother.php
+++ b/actions/tagother.php
@@ -110,7 +110,7 @@ class TagotherAction extends Action
if ($this->profile->location) {
$this->elementStart('dl', 'entity_location');
$this->element('dt', null, _('Location'));
- $this->element('dd', 'location', $this->profile->location);
+ $this->element('dd', 'label', $this->profile->location);
$this->elementEnd('dl');
}
if ($this->profile->homepage) {
@@ -135,7 +135,8 @@ class TagotherAction extends Action
'id' => 'form_tag_user',
'class' => 'form_settings',
'name' => 'tagother',
- 'action' => $this->selfUrl()));
+ 'action' => common_local_url('tagother', array('id' => $this->profile->id))));
+
$this->elementStart('fieldset');
$this->element('legend', null, _('Tag user'));
$this->hidden('token', common_session_token());
diff --git a/actions/twitapiaccount.php b/actions/twitapiaccount.php
index b7c09cc9d..c19cd370d 100644
--- a/actions/twitapiaccount.php
+++ b/actions/twitapiaccount.php
@@ -24,20 +24,19 @@ require_once(INSTALLDIR.'/lib/twitterapi.php');
class TwitapiaccountAction extends TwitterapiAction
{
- function verify_credentials($args, $apidata)
+ function verify_credentials($args, $apidata)
{
-
- if ($apidata['content-type'] == 'xml') {
- header('Content-Type: application/xml; charset=utf-8');
- print '<authorized>true</authorized>';
- } elseif ($apidata['content-type'] == 'json') {
- header('Content-Type: application/json; charset=utf-8');
- print '{"authorized":true}';
- } else {
- common_user_error(_('API method not found!'), $code=404);
- }
-
- }
+ if ($apidata['content-type'] == 'xml') {
+ header('Content-Type: application/xml; charset=utf-8');
+ print '<authorized>true</authorized>';
+ } elseif ($apidata['content-type'] == 'json') {
+ header('Content-Type: application/json; charset=utf-8');
+ print '{"authorized":true}';
+ } else {
+ header('Content-Type: text/html; charset=utf-8');
+ print 'Authorized';
+ }
+ }
function end_session($args, $apidata)
{
diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php
index 18e24c0f5..216835026 100644
--- a/actions/twitapistatuses.php
+++ b/actions/twitapistatuses.php
@@ -204,7 +204,7 @@ class TwitapistatusesAction extends TwitterapiAction
# FriendFeed's SUP protocol
# Also added RSS and Atom feeds
- $suplink = common_local_url('sup', null, $user->id);
+ $suplink = common_local_url('sup', null, null, $user->id);
header('X-SUP-ID: '.$suplink);
# XXX: since
@@ -470,19 +470,28 @@ class TwitapistatusesAction extends TwitterapiAction
return $this->subscriptions($apidata, 'subscribed', 'subscriber');
}
- function followers($args, $apidata)
+ function friendsIDs($args, $apidata)
{
parent::handle($args);
+ return $this->subscriptions($apidata, 'subscribed', 'subscriber', true);
+ }
+ function followers($args, $apidata)
+ {
+ parent::handle($args);
return $this->subscriptions($apidata, 'subscriber', 'subscribed');
}
- function subscriptions($apidata, $other_attr, $user_attr)
+ function followersIDs($args, $apidata)
{
+ parent::handle($args);
+ return $this->subscriptions($apidata, 'subscriber', 'subscribed', true);
+ }
- # XXX: lite
+ function subscriptions($apidata, $other_attr, $user_attr, $onlyIDs=false)
+ {
- $this->auth_user = $apidate['user'];
+ $this->auth_user = $apidata['user'];
$user = $this->get_user($apidata['api_arg'], $apidata);
if (!$user) {
@@ -514,7 +523,10 @@ class TwitapistatusesAction extends TwitterapiAction
}
$sub->orderBy('created DESC');
- $sub->limit(($page-1)*100, 100);
+
+ if (!$onlyIDs) {
+ $sub->limit(($page-1)*100, 100);
+ }
$others = array();
@@ -529,7 +541,13 @@ class TwitapistatusesAction extends TwitterapiAction
$type = $apidata['content-type'];
$this->init_document($type);
- $this->show_profiles($others, $type);
+
+ if ($onlyIDs) {
+ $this->showIDs($others, $type);
+ } else {
+ $this->show_profiles($others, $type);
+ }
+
$this->end_document($type);
}
@@ -555,6 +573,28 @@ class TwitapistatusesAction extends TwitterapiAction
}
}
+ function showIDs($profiles, $type)
+ {
+ switch ($type) {
+ case 'xml':
+ $this->elementStart('ids');
+ foreach ($profiles as $profile) {
+ $this->element('id', null, $profile->id);
+ }
+ $this->elementEnd('ids');
+ break;
+ case 'json':
+ $ids = array();
+ foreach ($profiles as $profile) {
+ $ids[] = (int)$profile->id;
+ }
+ print json_encode($ids);
+ break;
+ default:
+ $this->clientError(_('unsupported file type'));
+ }
+ }
+
function featured($args, $apidata)
{
parent::handle($args);
diff --git a/actions/twittersettings.php b/actions/twittersettings.php
index 2d41469bb..a79859bbf 100644
--- a/actions/twittersettings.php
+++ b/actions/twittersettings.php
@@ -32,6 +32,7 @@ if (!defined('LACONICA')) {
}
require_once INSTALLDIR.'/lib/connectsettingsaction.php';
+require_once INSTALLDIR.'/lib/twitter.php';
define('SUBSCRIPTIONS', 80);
@@ -90,7 +91,7 @@ class TwittersettingsAction extends ConnectSettingsAction
$fuser = null;
- $flink = Foreign_link::getByUserID($user->id, 1); // 1 == Twitter
+ $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE);
if ($flink) {
$fuser = $flink->getForeignUser();
@@ -358,7 +359,7 @@ class TwittersettingsAction extends ConnectSettingsAction
$flink->user_id = $user->id;
$flink->foreign_id = $twit_user->id;
- $flink->service = 1; // Twitter
+ $flink->service = TWITTER_SERVICE;
$flink->credentials = $password;
$flink->created = common_sql_now();
diff --git a/actions/userauthorization.php b/actions/userauthorization.php
index 7455a41a6..ed17ceec9 100644
--- a/actions/userauthorization.php
+++ b/actions/userauthorization.php
@@ -330,7 +330,13 @@ class UserauthorizationAction extends Action
{
$temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar');
copy($url, $temp_filename);
- return $profile->setOriginal($temp_filename);
+ $imagefile = new ImageFile($profile->id, $temp_filename);
+ $filename = Avatar::filename($profile->id,
+ image_type_to_extension($imagefile->type),
+ null,
+ common_timestamp());
+ rename($temp_filename, Avatar::path($filename));
+ return $profile->setOriginal($filename);
}
function showAcceptMessage($tok)
diff --git a/actions/userrss.php b/actions/userrss.php
index 04855ccca..a3e5a3aab 100644
--- a/actions/userrss.php
+++ b/actions/userrss.php
@@ -46,13 +46,13 @@ class UserrssAction extends Rss10Action
{
$user = $this->user;
-
+
if (is_null($user)) {
return null;
}
-
+
$notice = $user->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
-
+
while ($notice->fetch()) {
$notices[] = clone($notice);
}
@@ -87,10 +87,10 @@ class UserrssAction extends Rss10Action
}
# override parent to add X-SUP-ID URL
-
+
function initRss($limit=0)
{
- $url = common_local_url('sup', null, $this->user->id);
+ $url = common_local_url('sup', null, null, $this->user->id);
header('X-SUP-ID: '.$url);
parent::initRss($limit);
}
@@ -100,4 +100,3 @@ class UserrssAction extends Rss10Action
return true;
}
}
-