diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-07-02 08:51:10 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-07-02 08:51:10 -0400 |
commit | 5f9a4ebef493997557ef4470268bed0e5799b6cb (patch) | |
tree | f9a06c1773e511d3273c5d9223d06ca0806d5341 /actions | |
parent | e52997e52fe02960908eb6a9637a3349a2c74dad (diff) | |
parent | d04ab14a5a15f9119bedca1332eb516ecf5ca483 (diff) |
Merge branch '0.8.x' into queuemanager
Diffstat (limited to 'actions')
-rw-r--r-- | actions/attachment_ajax.php | 5 | ||||
-rw-r--r-- | actions/attachment_thumbnail.php | 46 | ||||
-rw-r--r-- | actions/conversation.php | 39 | ||||
-rw-r--r-- | actions/disfavor.php | 2 | ||||
-rw-r--r-- | actions/favor.php | 2 | ||||
-rw-r--r-- | actions/groupdesignsettings.php | 31 | ||||
-rw-r--r-- | actions/groupmembers.php | 9 | ||||
-rw-r--r-- | actions/grouprss.php | 1 | ||||
-rw-r--r-- | actions/groups.php | 1 | ||||
-rw-r--r-- | actions/invite.php | 4 | ||||
-rw-r--r-- | actions/noticesearchrss.php | 13 | ||||
-rw-r--r-- | actions/public.php | 6 | ||||
-rw-r--r-- | actions/showfavorites.php | 2 | ||||
-rw-r--r-- | actions/showgroup.php | 44 | ||||
-rw-r--r-- | actions/shownotice.php | 21 | ||||
-rw-r--r-- | actions/sup.php | 4 | ||||
-rw-r--r-- | actions/twitapisearchatom.php | 28 | ||||
-rw-r--r-- | actions/twitapisearchjson.php | 9 | ||||
-rw-r--r-- | actions/userdesignsettings.php | 107 |
19 files changed, 264 insertions, 110 deletions
diff --git a/actions/attachment_ajax.php b/actions/attachment_ajax.php index 5d6773010..4caa159f3 100644 --- a/actions/attachment_ajax.php +++ b/actions/attachment_ajax.php @@ -58,6 +58,11 @@ class Attachment_ajaxAction extends AttachmentAction } } + function handle($args) + { + $this->showPage(); + } + /** * Show core. * diff --git a/actions/attachment_thumbnail.php b/actions/attachment_thumbnail.php index b4070e747..248d16e38 100644 --- a/actions/attachment_thumbnail.php +++ b/actions/attachment_thumbnail.php @@ -45,6 +45,12 @@ require_once INSTALLDIR.'/actions/attachment.php'; class Attachment_thumbnailAction extends AttachmentAction { + + function handle($args) + { + $this->showPage(); + } + /** * Show page, a template method. * @@ -74,45 +80,5 @@ class Attachment_thumbnailAction extends AttachmentAction $this->element('img', array('src' => $file_thumbnail->url, 'alt' => 'Thumbnail')); } - /** - * 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/conversation.php b/actions/conversation.php index 654a670f5..cd6f26329 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -107,17 +107,11 @@ class ConversationAction extends Action function showContent() { - $offset = ($this->page-1) * NOTICES_PER_PAGE; - $limit = NOTICES_PER_PAGE + 1; - - $notices = Notice::conversationStream($this->id, $offset, $limit); + $notices = Notice::conversationStream($this->id, 0, null); $ct = new ConversationTree($notices, $this); $cnt = $ct->show(); - - $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, - $this->page, 'conversation', array('id' => $this->id)); } } @@ -146,8 +140,25 @@ class ConversationTree extends NoticeList function show() { - $cnt = 0; + $cnt = $this->_buildTree(); + + $this->out->elementStart('div', array('id' =>'notices_primary')); + $this->out->element('h2', null, _('Notices')); + $this->out->elementStart('ol', array('class' => 'notices xoxo')); + + if (array_key_exists('root', $this->tree)) { + $rootid = $this->tree['root'][0]; + $this->showNoticePlus($rootid); + } + + $this->out->elementEnd('ol'); + $this->out->elementEnd('div'); + + return $cnt; + } + function _buildTree() + { $this->tree = array(); $this->table = array(); @@ -169,18 +180,6 @@ class ConversationTree extends NoticeList } } - $this->out->elementStart('div', array('id' =>'notices_primary')); - $this->out->element('h2', null, _('Notices')); - $this->out->elementStart('ol', array('class' => 'notices xoxo')); - - if (array_key_exists('root', $this->tree)) { - $rootid = $this->tree['root'][0]; - $this->showNoticePlus($rootid); - } - - $this->out->elementEnd('ol'); - $this->out->elementEnd('div'); - return $cnt; } diff --git a/actions/disfavor.php b/actions/disfavor.php index 740f7de93..02e01d6e0 100644 --- a/actions/disfavor.php +++ b/actions/disfavor.php @@ -75,7 +75,7 @@ class DisfavorAction extends Action return; } $fave = new Fave(); - $fave->user_id = $this->id; + $fave->user_id = $user->id; $fave->notice_id = $notice->id; if (!$fave->find(true)) { $this->clientError(_('This notice is not a favorite!')); diff --git a/actions/favor.php b/actions/favor.php index ec86b17e6..fe51e34a2 100644 --- a/actions/favor.php +++ b/actions/favor.php @@ -12,8 +12,6 @@ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://laconi.ca/ * - -/* * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, 2009, Control Yourself, Inc. * diff --git a/actions/groupdesignsettings.php b/actions/groupdesignsettings.php index 79c192ac4..6c1c052cb 100644 --- a/actions/groupdesignsettings.php +++ b/actions/groupdesignsettings.php @@ -34,19 +34,37 @@ if (!defined('LACONICA')) { require_once INSTALLDIR . '/lib/designsettings.php'; +/** + * Set a group's design + * + * Saves a design for a given group + * + * @category Settings + * @package Laconica + * @author Zach Copley <zach@controlyourself.ca> + * @author Sarven Capadisli <csarven@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 GroupDesignSettingsAction extends DesignSettingsAction { var $group = null; /** - * Prepare to run + * Sets the right action for the form, and passes request args into + * the base action + * + * @param array $args misc. arguments + * + * @return boolean true */ function prepare($args) { parent::prepare($args); - if (!common_config('inboxes','enabled')) { + if (!common_config('inboxes', 'enabled')) { $this->serverError(_('Inboxes must be enabled for groups to work')); return false; } @@ -57,7 +75,7 @@ class GroupDesignSettingsAction extends DesignSettingsAction } $nickname_arg = $this->trimmed('nickname'); - $nickname = common_canonical_nickname($nickname_arg); + $nickname = common_canonical_nickname($nickname_arg); // Permanent redirect on non-canonical nickname @@ -158,7 +176,8 @@ class GroupDesignSettingsAction extends DesignSettingsAction * @return Design */ - function getWorkingDesign() { + function getWorkingDesign() + { $design = null; @@ -273,9 +292,9 @@ class GroupDesignSettingsAction extends DesignSettingsAction return; } - $original = clone($this->group); + $original = clone($this->group); $this->group->design_id = $id; - $result = $this->group->update($original); + $result = $this->group->update($original); if (empty($result)) { common_log_db_error($original, 'UPDATE', __FILE__); diff --git a/actions/groupmembers.php b/actions/groupmembers.php index d132cdf96..14256526a 100644 --- a/actions/groupmembers.php +++ b/actions/groupmembers.php @@ -167,6 +167,15 @@ class GroupMemberListItem extends ProfileListItem $this->group = $group; } + function showFullName() + { + parent::showFullName(); + if ($this->profile->isAdmin($this->group)) { + $this->out->text(' '); + $this->out->element('span', 'role', _('Admin')); + } + } + function showActions() { $this->startActions(); diff --git a/actions/grouprss.php b/actions/grouprss.php index 0b7280a11..2bdcaafb2 100644 --- a/actions/grouprss.php +++ b/actions/grouprss.php @@ -116,6 +116,7 @@ class groupRssAction extends Rss10Action return null; } + $notices = array(); $notice = $group->getNotices(0, ($limit == 0) ? NOTICES_PER_PAGE : $limit); while ($notice->fetch()) { diff --git a/actions/groups.php b/actions/groups.php index b49d80f37..3d62843ed 100644 --- a/actions/groups.php +++ b/actions/groups.php @@ -115,6 +115,7 @@ class GroupsAction extends Action $groups->orderBy('created DESC'); $groups->limit($offset, $limit); + $cnt = 0; if ($groups->find()) { $gl = new GroupList($groups, null, $this); $cnt = $gl->show(); diff --git a/actions/invite.php b/actions/invite.php index 5dcc83652..bdea4807d 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -35,7 +35,9 @@ class InviteAction extends CurrentUserDesignAction function handle($args) { parent::handle($args); - if (!common_logged_in()) { + if (!common_config('invite', 'enabled')) { + $this->clientError(_('Invites have been disabled.')); + } else if (!common_logged_in()) { $this->clientError(sprintf(_('You must be logged in to invite other users to use %s'), common_config('site', 'name'))); return; diff --git a/actions/noticesearchrss.php b/actions/noticesearchrss.php index c1bf3bf5f..2a4b2060d 100644 --- a/actions/noticesearchrss.php +++ b/actions/noticesearchrss.php @@ -67,11 +67,16 @@ class NoticesearchrssAction extends Rss10Action if (!$limit) $limit = 20; $search_engine->limit(0, $limit, true); - $search_engine->query($q); - $notice->find(); + if (false === $search_engine->query($q)) { + $cnt = 0; + } else { + $cnt = $notice->find(); + } - while ($notice->fetch()) { - $notices[] = clone($notice); + if ($cnt > 0) { + while ($notice->fetch()) { + $notices[] = clone($notice); + } } return $notices; diff --git a/actions/public.php b/actions/public.php index 9851285c4..ef9ef0d1a 100644 --- a/actions/public.php +++ b/actions/public.php @@ -182,8 +182,10 @@ class PublicAction extends Action $message .= _('Be the first to post!'); } else { - $message .= _('Why not [register an account](%%action.register%%) and be the first to post!'); - } + if (! (common_config('site','closed') || common_config('site','inviteonly'))) { + $message .= _('Why not [register an account](%%action.register%%) and be the first to post!'); + } + } $this->elementStart('div', 'guide'); $this->raw(common_markup_to_html($message)); diff --git a/actions/showfavorites.php b/actions/showfavorites.php index b723924a5..8efe9d30a 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -45,7 +45,7 @@ require_once INSTALLDIR.'/lib/feedlist.php'; * @link http://laconi.ca/ */ -class ShowfavoritesAction extends CurrentUserDesignAction +class ShowfavoritesAction extends OwnerDesignAction { /** User we're getting the faves of */ var $user = null; diff --git a/actions/showgroup.php b/actions/showgroup.php index b6a0f4844..ce11d574e 100644 --- a/actions/showgroup.php +++ b/actions/showgroup.php @@ -331,6 +331,7 @@ class ShowgroupAction extends GroupDesignAction { $this->showMembers(); $this->showStatistics(); + $this->showAdmins(); $cloud = new GroupTagCloudSection($this, $this->group); $cloud->show(); } @@ -370,6 +371,18 @@ class ShowgroupAction extends GroupDesignAction } /** + * Show list of admins + * + * @return void + */ + + function showAdmins() + { + $adminSection = new GroupAdminSection($this, $this->group); + $adminSection->show(); + } + + /** * Show some statistics * * @return void @@ -423,3 +436,34 @@ class ShowgroupAction extends GroupDesignAction $this->elementEnd('div'); } } + +class GroupAdminSection extends ProfileSection +{ + var $group; + + function __construct($out, $group) + { + parent::__construct($out); + $this->group = $group; + } + + function getProfiles() + { + return $this->group->getAdmins(); + } + + function title() + { + return _('Admins'); + } + + function divId() + { + return 'group_admins'; + } + + function moreUrl() + { + return null; + } +}
\ No newline at end of file diff --git a/actions/shownotice.php b/actions/shownotice.php index 0d89af5ac..1ec38a76b 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -45,7 +45,7 @@ require_once INSTALLDIR.'/lib/feedlist.php'; * @link http://laconi.ca/ */ -class ShownoticeAction extends Action +class ShownoticeAction extends OwnerDesignAction { /** * Notice object to show @@ -83,18 +83,25 @@ class ShownoticeAction extends Action $this->notice = Notice::staticGet($id); - if (!$this->notice) { + if (empty($this->notice)) { $this->clientError(_('No such notice.'), 404); return false; } $this->profile = $this->notice->getProfile(); - if (!$this->profile) { + if (empty($this->profile)) { $this->serverError(_('Notice has no profile'), 500); return false; } + $this->user = User::staticGet('id', $this->profile->id); + + if (empty($this->user)) { + $this->serverError(_('Not a local notice'), 500); + return false; + } + $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); return true; @@ -158,8 +165,14 @@ class ShownoticeAction extends Action function title() { + if (!empty($this->profile->fullname)) { + $base = $this->profile->fullname . ' (' . $this->user->nickname . ') '; + } else { + $base = $this->user->nickname; + } + return sprintf(_('%1$s\'s status on %2$s'), - $this->profile->nickname, + $base, common_exact_date($this->notice->created)); } diff --git a/actions/sup.php b/actions/sup.php index e446a7b0d..a5b665562 100644 --- a/actions/sup.php +++ b/actions/sup.php @@ -63,11 +63,13 @@ class SupAction extends Action # XXX: cache this. Depends on how big this protocol becomes; # Re-doing this query every 15 seconds isn't the end of the world. + $divider = common_sql_date(time() - $seconds); + $notice->query('SELECT profile_id, max(id) AS max_id ' . 'FROM notice ' . ((common_config('db','type') == 'pgsql') ? 'WHERE extract(epoch from created) > (extract(epoch from now()) - ' . $seconds . ') ' : - 'WHERE created > (now() - ' . $seconds . ') ' ) . + 'WHERE created > "'.$divider.'" ' ) . 'GROUP BY profile_id'); $updates = array(); diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php index eb9ab5d8e..3678213c3 100644 --- a/actions/twitapisearchatom.php +++ b/actions/twitapisearchatom.php @@ -165,24 +165,30 @@ class TwitapisearchatomAction extends TwitterapiAction $search_engine->set_sort_mode('chron'); $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1, true); - $search_engine->query($q); - $this->cnt = $notice->find(); + if (false === $search_engine->query($q)) { + $this->cnt = 0; + } else { + $this->cnt = $notice->find(); + } $cnt = 0; + $this->max_id = 0; - while ($notice->fetch()) { + if ($this->cnt > 0) { + while ($notice->fetch()) { - ++$cnt; + ++$cnt; - if (!$this->max_id) { - $this->max_id = $notice->id; - } + if (!$this->max_id) { + $this->max_id = $notice->id; + } - if ($cnt > $this->rpp) { - break; - } + if ($cnt > $this->rpp) { + break; + } - $notices[] = clone($notice); + $notices[] = clone($notice); + } } return $notices; diff --git a/actions/twitapisearchjson.php b/actions/twitapisearchjson.php index b0e3be687..27a717bfc 100644 --- a/actions/twitapisearchjson.php +++ b/actions/twitapisearchjson.php @@ -124,8 +124,11 @@ class TwitapisearchjsonAction extends TwitterapiAction $search_engine = $notice->getSearchEngine('identica_notices'); $search_engine->set_sort_mode('chron'); $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1, true); - $search_engine->query($q); - $cnt = $notice->find(); + if (false === $search_engine->query($q)) { + $cnt = 0; + } else { + $cnt = $notice->find(); + } // TODO: since_id, lang, geocode @@ -146,4 +149,4 @@ class TwitapisearchjsonAction extends TwitterapiAction { return true; } -}
\ No newline at end of file +} diff --git a/actions/userdesignsettings.php b/actions/userdesignsettings.php index 6e745e96f..d7949951a 100644 --- a/actions/userdesignsettings.php +++ b/actions/userdesignsettings.php @@ -34,16 +34,37 @@ if (!defined('LACONICA')) { require_once INSTALLDIR . '/lib/designsettings.php'; +/** + * Set a user's design + * + * Saves a design for a given user + * + * @category Settings + * @package Laconica + * @author Zach Copley <zach@controlyourself.ca> + * @author Sarven Capadisli <csarven@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 UserDesignSettingsAction extends DesignSettingsAction { - + /** + * Sets the right action for the form, and passes request args into + * the base action + * + * @param array $args misc. arguments + * + * @return boolean true + */ + function prepare($args) { parent::prepare($args); $this->submitaction = common_local_url('userdesignsettings'); return true; } - + /** * Title of the page * @@ -72,19 +93,20 @@ class UserDesignSettingsAction extends DesignSettingsAction * * @return Design */ - - function getWorkingDesign() { - - $user = common_current_user(); + + function getWorkingDesign() + { + + $user = common_current_user(); $design = $user->getDesign(); if (empty($design)) { $design = $this->defaultDesign(); } - + return $design; } - + /** * Content area of the page * @@ -92,7 +114,7 @@ class UserDesignSettingsAction extends DesignSettingsAction * * @return void */ - + function showContent() { $this->showDesignForm($this->getWorkingDesign()); @@ -106,14 +128,19 @@ class UserDesignSettingsAction extends DesignSettingsAction function saveDesign() { - try { + foreach ($this->args as $key => $val) { + if (preg_match('/(#ho|ho)Td.*g/i', $val)) { + $this->sethd(); + return; + } + } + try { $bgcolor = new WebColor($this->trimmed('design_background')); $ccolor = new WebColor($this->trimmed('design_content')); $sbcolor = new WebColor($this->trimmed('design_sidebar')); $tcolor = new WebColor($this->trimmed('design_text')); $lcolor = new WebColor($this->trimmed('design_links')); - } catch (WebColorException $e) { $this->showForm($e->getMessage()); return; @@ -137,7 +164,7 @@ class UserDesignSettingsAction extends DesignSettingsAction $tile = true; } - $user = common_current_user(); + $user = common_current_user(); $design = $user->getDesign(); if (!empty($design)) { @@ -184,9 +211,9 @@ class UserDesignSettingsAction extends DesignSettingsAction return; } - $original = clone($user); + $original = clone($user); $user->design_id = $id; - $result = $user->update($original); + $result = $user->update($original); if (empty($result)) { common_log_db_error($original, 'UPDATE', __FILE__); @@ -203,4 +230,56 @@ class UserDesignSettingsAction extends DesignSettingsAction $this->showForm(_('Design preferences saved.'), true); } + + /** + * Alternate default colors + * + * @return nothing + */ + + function sethd() + { + + $user = common_current_user(); + $design = $user->getDesign(); + + $user->query('BEGIN'); + + // alternate colors + $design = new Design(); + + $design->backgroundcolor = 16184329; + $design->contentcolor = 16059904; + $design->sidebarcolor = 16059904; + $design->textcolor = 0; + $design->linkcolor = 16777215; + + $design->setDisposition(false, true, false); + + $id = $design->insert(); + + if (empty($id)) { + common_log_db_error($id, 'INSERT', __FILE__); + $this->showForm(_('Unable to save your design settings!')); + return; + } + + $original = clone($user); + $user->design_id = $id; + $result = $user->update($original); + + if (empty($result)) { + common_log_db_error($original, 'UPDATE', __FILE__); + $this->showForm(_('Unable to save your design settings!')); + $user->query('ROLLBACK'); + return; + } + + $user->query('COMMIT'); + + $this->saveBackgroundImage($design); + + $this->showForm(_('Enjoy your hotdog!'), true); + } + } |