only count post-notices (i.e. don't include activity-notices in statuses_count in the API)
See merge request !73
function getLists()
{
- $profile = $this->target;
- $fn = array($profile, 'getOtherTags');
+ $fn = array($this->target, 'getOtherTags');
# 20 lists
list($this->lists, $this->next_cursor, $this->prev_cursor) =
- Profile_list::getAtCursor($fn, array($this->auth_user), $this->cursor, 20);
+ Profile_list::getAtCursor($fn, array($this->scoped), $this->cursor, 20);
}
}
list($this->lists,
$this->next_cursor,
- $this->prev_cursor) = Profile_list::getAtCursor($fn, array($this->auth_user), $cursor, $count);
+ $this->prev_cursor) = Profile_list::getAtCursor($fn, array($this->scoped), $cursor, $count);
}
function isReadOnly($args)
$content = $this->scoped->shortenLinks($content);
+ // Reject notice if it is too long (without the HTML)
+ // Should we do this before or after the upload attachment link? I think before...
+ if (Notice::contentTooLong($content)) {
+ // TRANS: Client error displayed when the parameter "status" is missing.
+ // TRANS: %d is the maximum number of character for a notice.
+ throw new ClientException(sprintf(_m('That\'s too long. Maximum notice size is %d character.',
+ 'That\'s too long. Maximum notice size is %d characters.',
+ Notice::maxContent()),
+ Notice::maxContent()));
+ }
+
$upload = null;
try {
// throws exception on failure
}
Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content, &$options));
- if (Notice::contentTooLong($content)) {
- $upload->delete();
- // TRANS: Client error displayed exceeding the maximum notice length.
- // TRANS: %d is the maximum length for a notice.
- $this->clientError(sprintf(_m('Maximum notice size is %d character, including attachment URL.',
- 'Maximum notice size is %d characters, including attachment URL.',
- Notice::maxContent()),
- Notice::maxContent()));
- }
+ // We could check content length here if the URL was added, but I'll just let it slide for now...
$act->enclosures[] = $upload->getEnclosure();
} catch (NoUploadedMediaException $e) {
}
$profile = $this->user->getProfile();
- $tags = $profile->getLists(common_current_user());
+ $tags = $profile->getLists($this->scoped);
$this->tags = array();
while ($tags->fetch()) {
$user = common_current_user();
if ($this->arg('public')) {
- $this->tags = $this->tagger->getLists(false, $offset, $limit);
+ $this->tags = $this->tagger->getLists(null, $offset, $limit);
} else if ($this->arg('private')) {
if (empty($user)) {
// TRANS: Error message displayed when trying to perform an action that requires a logged in user.
$this->clientError(_('You cannot view others\' private lists'), 403);
}
} else {
- $this->tags = $this->tagger->getLists(common_current_user(), $offset, $limit);
+ $this->tags = $this->tagger->getLists($this->scoped, $offset, $limit);
}
return true;
}
$offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
$limit = PEOPLETAGS_PER_PAGE + 1;
- $ptags = $this->tagged->getOtherTags(common_current_user(), $offset, $limit);
+ $ptags = $this->tagged->getOtherTags($this->scoped, $offset, $limit);
$pl = new PeopletagList($ptags, $this);
$cnt = $pl->show();
$redir->httpcode = $redir_info['code'];
$redir->redirections = intval($redir_info['redirects']);
+ $redir->redir_url = $redir_info['url'];
$redir->file = new File();
$redir->file->url = $redir_info['url'];
$redir->file->mimetype = $redir_info['type'];
return $this->file;
}
-}
+}
\ No newline at end of file
$stored->rendered = $actor->isLocal() ? $content : common_purify($content);
$stored->content = common_strip_html($stored->rendered);
- // Reject notice if it is too long (without the HTML)
- // FIXME: Reject if too short (empty) too? But we have to pass the
- if ($actor->isLocal() && Notice::contentTooLong($stored->content)) {
- // TRANS: Client error displayed when the parameter "status" is missing.
- // TRANS: %d is the maximum number of character for a notice.
- throw new ClientException(sprintf(_m('That\'s too long. Maximum notice size is %d character.',
- 'That\'s too long. Maximum notice size is %d characters.',
- Notice::maxContent()),
- Notice::maxContent()));
- }
-
// Maybe a missing act-time should be fatal if the actor is not local?
if (!empty($act->time)) {
$stored->created = common_sql_date($act->time);
return false;
}
- function getLists($auth_user, $offset=0, $limit=null, $since_id=0, $max_id=0)
+ function getLists(Profile $scoped=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
{
$ids = array();
self::cacheSet($keypart, implode(',', $ids));
}
- $showPrivate = (($auth_user instanceof User ||
- $auth_user instanceof Profile) &&
- $auth_user->id === $this->id);
+ $showPrivate = $this->sameAs($scoped);
$lists = array();
/**
* Get tags that other people put on this profile, in reverse-chron order
*
- * @param (Profile|User) $auth_user Authorized user (used for privacy)
+ * @param Profile $scoped User we are requesting as
* @param int $offset Offset from latest
* @param int $limit Max number to get
* @param datetime $since_id max date
* @return Profile_list resulting lists
*/
- function getOtherTags($auth_user=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
+ function getOtherTags(Profile $scoped=null, $offset=0, $limit=null, $since_id=0, $max_id=0)
{
$list = new Profile_list();
$this->id);
- if ($auth_user instanceof User || $auth_user instanceof Profile) {
+ if (!is_null($scoped)) {
$qry .= sprintf('AND ( ( profile_list.private = false ) ' .
'OR ( profile_list.tagger = %d AND ' .
'profile_list.private = true ) )',
- $auth_user->id);
+ $scoped->getID());
} else {
$qry .= 'AND profile_list.private = 0 ';
}
{
return $this->getUser()->getConnectedApps($offset, $limit);
}
-}
\ No newline at end of file
+}
*/
function getUrl()
{
- return $this->url;
+ return $this->effectiveUrl;
}
/**
} while ($maxRedirs);
return new GNUsocial_HTTPResponse($response, $this->getUrl(), $redirs);
}
-}
+}
\ No newline at end of file
parent::__construct($out);
$this->profile = $profile;
- $user = common_current_user();
-
- $this->lists = $profile->getLists($user);
+ $this->lists = $profile->getLists(Profile::current());
}
function tag()
$limit = PEOPLETAGS_PER_SECTION+1;
$offset = 0;
- $auth_user = common_current_user();
- $ptags = $this->profile->getOtherTags($auth_user, $offset, $limit);
+ $ptags = $this->profile->getOtherTags(Profile::current(), $offset, $limit);
return $ptags;
}
} else {
$canon = File_redirection::_canonUrl($url);
$longurl_data = File_redirection::where($canon, common_config('attachments', 'process_links'));
- $longurl = $longurl_data->url;
+
+ if(isset($longurl_data->redir_url)) {
+ $longurl = $longurl_data->redir_url;
+ } else {
+ // e.g. local files
+ $longurl = $longurl_data->url;
+ }
}
-
- $attrs = array('href' => $canon, 'title' => $longurl);
+
+ $attrs = array('href' => $longurl, 'title' => $longurl);
$is_attachment = false;
$attachment_id = null;
$args[$i] = htmlspecialchars($args[$i]);
}
return call_user_func_array('sprintf', $args);
-}
+}
\ No newline at end of file
*/
function onRedirectToLogin($action, $user)
{
- if (common_config('site', 'openid_only') || (!empty($user) && User_openid::hasOpenID($user->id))) {
+ if (common_config('site', 'openidonly') || (!empty($user) && User_openid::hasOpenID($user->id))) {
common_redirect(common_local_url('openidlogin'), 303);
}
return true;