forked from GNUsocial/gnu-social
Merge branch '0.9.x' of gitorious.org:statusnet/mainline into 1.0.x
Conflicts: actions/hostmeta.php actions/imsettings.php classes/User.php lib/adminpanelaction.php lib/channel.php lib/default.php lib/router.php lib/util.php
This commit is contained in:
commit
59119482ca
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,3 +25,4 @@ good-config.php
|
||||
lac08.log
|
||||
php.log
|
||||
.DS_Store
|
||||
nbproject
|
||||
|
54
EVENTS.txt
54
EVENTS.txt
@ -258,10 +258,28 @@ EndShowExportData: just after showing the <div> with export data (feeds)
|
||||
- $action: action object being shown
|
||||
|
||||
StartShowNoticeItem: just before showing the notice item
|
||||
- $action: action object being shown
|
||||
- $item: The NoticeListItem object being shown
|
||||
|
||||
EndShowNoticeItem: just after showing the notice item
|
||||
- $action: action object being shown
|
||||
- $item: the NoticeListItem object being shown
|
||||
|
||||
StartShowNoticeInfo: just before showing notice info
|
||||
- $item: The NoticeListItem object being shown
|
||||
|
||||
EndShowNoticeInfo: just after showing notice info
|
||||
- $item: The NoticeListItem object being shown
|
||||
|
||||
StartShowNoticeOptions: just before showing notice options like fave, repeat, etc.
|
||||
- $item: the NoticeListItem object being shown
|
||||
|
||||
EndShowNoticeOptions: just after showing notice options like fave, repeat, etc.
|
||||
- $item: the NoticeListItem object being shown
|
||||
|
||||
StartShowFaveForm: just before showing the fave form
|
||||
- $item: the NoticeListItem object being shown
|
||||
|
||||
EndShowFaveForm: just after showing the fave form
|
||||
- $item: the NoticeListItem object being shown
|
||||
|
||||
StartShowPageNotice: just before showing the page notice (instructions or error)
|
||||
- $action: action object being shown
|
||||
@ -780,6 +798,22 @@ EndDisfavorNotice: After saving a notice as a favorite
|
||||
- $profile: profile of the person faving (can be remote!)
|
||||
- $notice: notice being faved
|
||||
|
||||
StartFavorNoticeForm: starting the data in the form for favoring a notice
|
||||
- $FavorForm: the favor form being shown
|
||||
- $notice: notice being favored
|
||||
|
||||
EndFavorNoticeForm: Ending the data in the form for favoring a notice
|
||||
- $FavorForm: the favor form being shown
|
||||
- $notice: notice being favored
|
||||
|
||||
StartDisFavorNoticeForm: starting the data in the form for disfavoring a notice
|
||||
- $DisfavorForm: the disfavor form being shown
|
||||
- $notice: notice being difavored
|
||||
|
||||
EndDisFavorNoticeForm: Ending the data in the form for disfavoring a notice
|
||||
- $DisfavorForm: the disfavor form being shown
|
||||
- $notice: notice being disfavored
|
||||
|
||||
StartFindMentions: start finding mentions in a block of text
|
||||
- $sender: sender profile
|
||||
- $text: plain text version of the notice
|
||||
@ -1110,3 +1144,19 @@ StartDeleteOwnNotice: when a user starts to delete their own notice
|
||||
EndDeleteOwnNotice: when a user has deleted their own notice
|
||||
- $user: the user doing the delete
|
||||
- $notice: the notice being deleted
|
||||
|
||||
StartShowFeedLinkList: before showing the feed list in the sidebar
|
||||
- $action: action being executed
|
||||
- $feeds: list of feeds to show
|
||||
|
||||
EndShowFeedLinkList: after showing the feed list in the sidebar
|
||||
- $action: action being executed
|
||||
- $feeds: list of feeds shown
|
||||
|
||||
StartShowFeedLink: before showing an individual feed item
|
||||
- $action: action being executed
|
||||
- $feed: feed to show
|
||||
|
||||
EndShowFeedLink: after showing an individual feed
|
||||
- $action: action being executed
|
||||
- $feed: feed to show
|
||||
|
@ -83,6 +83,7 @@ class ApiAccountUpdateDeliveryDeviceAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error message. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400, $this->format
|
||||
);
|
||||
|
@ -86,6 +86,7 @@ class ApiAccountUpdateProfileAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400, $this->format
|
||||
);
|
||||
|
@ -83,6 +83,7 @@ class ApiAccountUpdateProfileBackgroundImageAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400, $this->format
|
||||
);
|
||||
|
@ -107,6 +107,7 @@ class ApiAccountUpdateProfileColorsAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400, $this->format
|
||||
);
|
||||
|
@ -81,6 +81,7 @@ class ApiAccountUpdateProfileImageAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400, $this->format
|
||||
);
|
||||
|
@ -86,6 +86,7 @@ class ApiBlockCreateAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -85,6 +85,7 @@ class ApiBlockDestroyAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -357,6 +357,7 @@ class ApiDirectMessageAction extends ApiAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
strtotime($this->messages[0]->created),
|
||||
strtotime($this->messages[$last]->created)
|
||||
|
@ -106,6 +106,7 @@ class ApiDirectMessageNewAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -88,6 +88,7 @@ class ApiFavoriteCreateAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -89,6 +89,7 @@ class ApiFavoriteDestroyAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -88,6 +88,7 @@ class ApiFriendshipsCreateAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -88,6 +88,7 @@ class ApiFriendshipsDestroyAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -102,6 +102,7 @@ class ApiGroupCreateAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -89,6 +89,7 @@ class ApiGroupJoinAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -89,6 +89,7 @@ class ApiGroupLeaveAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -213,6 +213,7 @@ class ApiGroupListAction extends ApiBareAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->user->id,
|
||||
strtotime($this->groups[0]->created),
|
||||
|
@ -204,6 +204,7 @@ class ApiGroupListAllAction extends ApiPrivateAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
strtotime($this->groups[0]->created),
|
||||
strtotime($this->groups[$last]->created))
|
||||
|
@ -183,6 +183,7 @@ class ApiGroupMembershipAction extends ApiPrivateAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->group->id,
|
||||
strtotime($this->profiles[0]->created),
|
||||
|
@ -149,6 +149,7 @@ class ApiGroupShowAction extends ApiPrivateAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->group->id,
|
||||
strtotime($this->group->modified))
|
||||
|
@ -64,6 +64,7 @@ class ApiMediaUploadAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400, $this->format
|
||||
);
|
||||
|
@ -270,7 +270,7 @@ class ApiOauthAuthorizeAction extends ApiOauthAction
|
||||
$this->elementStart('form', array('method' => 'post',
|
||||
'id' => 'form_apioauthauthorize',
|
||||
'class' => 'form_settings',
|
||||
'action' => common_local_url('apioauthauthorize')));
|
||||
'action' => common_local_url('ApiOauthAuthorize')));
|
||||
$this->elementStart('fieldset');
|
||||
$this->element('legend', array('id' => 'apioauthauthorize_allowdeny'),
|
||||
_('Allow or deny access'));
|
||||
|
@ -62,6 +62,7 @@ class ApiStatusesRetweetAction extends ApiAuthAction
|
||||
parent::prepare($args);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
$this->clientError(_('This method requires a POST.'),
|
||||
400, $this->format);
|
||||
return false;
|
||||
|
@ -194,6 +194,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->notice->id,
|
||||
strtotime($this->notice->created))
|
||||
|
@ -195,6 +195,7 @@ class ApiStatusesUpdateAction extends ApiAuthAction
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
|
||||
$this->clientError(
|
||||
// TRANS: Client error. POST is a HTTP command. It should not be translated.
|
||||
_('This method requires a POST.'),
|
||||
400,
|
||||
$this->format
|
||||
|
@ -181,6 +181,7 @@ class ApiSubscriptionsAction extends ApiBareAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->user->id,
|
||||
isset($this->ids_only) ? 'IDs' : 'Profiles',
|
||||
|
@ -259,6 +259,7 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->user->id,
|
||||
strtotime($this->notices[0]->created),
|
||||
|
@ -346,6 +346,7 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->user->id,
|
||||
strtotime($this->notices[0]->created),
|
||||
|
@ -229,6 +229,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->group->id,
|
||||
strtotime($this->notices[0]->created),
|
||||
|
@ -254,6 +254,7 @@ class ApiTimelineHomeAction extends ApiBareAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->user->id,
|
||||
strtotime($this->notices[0]->created),
|
||||
|
@ -244,6 +244,7 @@ class ApiTimelineMentionsAction extends ApiBareAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->user->id,
|
||||
strtotime($this->notices[0]->created),
|
||||
|
@ -311,6 +311,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
strtotime($this->notices[0]->created),
|
||||
strtotime($this->notices[$last]->created))
|
||||
|
@ -232,6 +232,7 @@ class ApiTimelineTagAction extends ApiPrivateAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->tag,
|
||||
strtotime($this->notices[0]->created),
|
||||
|
@ -234,6 +234,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
||||
return '"' . implode(
|
||||
':',
|
||||
array($this->arg('action'),
|
||||
common_user_cache_hash($this->auth_user),
|
||||
common_language(),
|
||||
$this->user->id,
|
||||
strtotime($this->notices[0]->created),
|
||||
|
@ -71,7 +71,7 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('Design settings for this StatusNet site.');
|
||||
return _('Design settings for this StatusNet site');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,9 +154,22 @@ class DesignadminpanelAction extends AdminPanelAction
|
||||
|
||||
$config->query('BEGIN');
|
||||
|
||||
// Only update colors if the theme has not changed.
|
||||
if ($themeChanged) {
|
||||
// If the theme has changed, reset custom colors and let them pick
|
||||
// up the new theme's defaults.
|
||||
$colors = array('background', 'content', 'sidebar', 'text', 'link');
|
||||
foreach ($colors as $colorKey) {
|
||||
// Clear from global config so we see defaults on this page...
|
||||
$GLOBALS['config']['design'][$colorKey . 'color'] = false;
|
||||
|
||||
if (!$themeChanged) {
|
||||
// And remove old settings from DB...
|
||||
$this->deleteSetting('design', $colorKey . 'color');
|
||||
}
|
||||
} else {
|
||||
// Only save colors from the form if the theme has not changed.
|
||||
//
|
||||
// @fixme a future more ajaxy form should allow theme switch
|
||||
// and color customization in one step.
|
||||
|
||||
$bgcolor = new WebColor($this->trimmed('design_background'));
|
||||
$ccolor = new WebColor($this->trimmed('design_content'));
|
||||
|
@ -188,7 +188,7 @@ class EditApplicationAction extends OwnerDesignAction
|
||||
} elseif (Oauth_application::descriptionTooLong($description)) {
|
||||
$this->showForm(sprintf(
|
||||
_('Description is too long (max %d chars).'),
|
||||
Oauth_application::maxDescription()));
|
||||
Oauth_application::maxDesc()));
|
||||
return;
|
||||
} elseif (mb_strlen($source_url) > 255) {
|
||||
$this->showForm(_('Source URL is too long.'));
|
||||
@ -253,7 +253,10 @@ class EditApplicationAction extends OwnerDesignAction
|
||||
|
||||
$result = $this->app->update($orig);
|
||||
|
||||
if (!$result) {
|
||||
// Note: 0 means no rows changed, which can happen if the only
|
||||
// thing we changed was the icon, since it's not altered until
|
||||
// the next step.
|
||||
if ($result === false) {
|
||||
common_log_db_error($this->app, 'UPDATE', __FILE__);
|
||||
$this->serverError(_('Could not update application.'));
|
||||
}
|
||||
|
@ -131,7 +131,11 @@ class EmailsettingsAction extends AccountSettingsAction
|
||||
// TRANS: Field label for e-mail address input in e-mail settings form.
|
||||
$this->input('email', _('Email address'),
|
||||
($this->arg('email')) ? $this->arg('email') : null,
|
||||
// TRANS: Instructions for e-mail address input form.
|
||||
// TRANS: Instructions for e-mail address input form. Do not translate
|
||||
// TRANS: "example.org". It is one of the domain names reserved for
|
||||
// TRANS: use in examples by http://www.rfc-editor.org/rfc/rfc2606.txt.
|
||||
// TRANS: Any other domain may be owned by a legitimate person or
|
||||
// TRANS: organization.
|
||||
_('Email address, like "UserName@example.org"'));
|
||||
$this->elementEnd('li');
|
||||
$this->elementEnd('ul');
|
||||
|
@ -97,9 +97,13 @@ class GroupmembersAction extends GroupDesignAction
|
||||
function title()
|
||||
{
|
||||
if ($this->page == 1) {
|
||||
// TRANS: Title of the page showing group members.
|
||||
// TRANS: %s is the name of the group.
|
||||
return sprintf(_('%s group members'),
|
||||
$this->group->nickname);
|
||||
} else {
|
||||
// TRANS: Title of the page showing group members.
|
||||
// TRANS: %1$s is the name of the group, %2$d is the page number of the members list.
|
||||
return sprintf(_('%1$s group members, page %2$d'),
|
||||
$this->group->nickname,
|
||||
$this->page);
|
||||
@ -389,7 +393,14 @@ class GroupBlockForm extends Form
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('submit', _('Block'), 'submit', null, _('Block this user'));
|
||||
$this->out->submit(
|
||||
'submit',
|
||||
// TRANS: Button text for the form that will block a user from a group.
|
||||
_m('BUTTON','Block'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Submit button title.
|
||||
_m('TOOLTIP', 'Block this user'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,6 +527,13 @@ class MakeAdminForm extends Form
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('submit', _('Make Admin'), 'submit', null, _('Make this user an admin'));
|
||||
$this->out->submit(
|
||||
'submit',
|
||||
// TRANS: Button text for the form that will make a user administrator.
|
||||
_m('BUTTON','Make Admin'),
|
||||
'submit',
|
||||
null,
|
||||
// TRANS: Submit button title.
|
||||
_m('TOOLTIP','Make this user an admin'));
|
||||
}
|
||||
}
|
||||
|
322
actions/licenseadminpanel.php
Normal file
322
actions/licenseadminpanel.php
Normal file
@ -0,0 +1,322 @@
|
||||
<?php
|
||||
/**
|
||||
* StatusNet, the distributed open-source microblogging tool
|
||||
*
|
||||
* License administration panel
|
||||
*
|
||||
* 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 Settings
|
||||
* @package StatusNet
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2010 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* License settings
|
||||
*
|
||||
* @category Admin
|
||||
* @package StatusNet
|
||||
* @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 LicenseadminpanelAction extends AdminPanelAction
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the page title
|
||||
*
|
||||
* @return string page title
|
||||
*/
|
||||
|
||||
function title()
|
||||
{
|
||||
// TRANS: User admin panel title
|
||||
return _m('TITLE', 'License');
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructions for using this form.
|
||||
*
|
||||
* @return string instructions
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('License for this StatusNet site');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the site admin panel form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showForm()
|
||||
{
|
||||
$form = new LicenseAdminPanelForm($this);
|
||||
$form->show();
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings from the form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveSettings()
|
||||
{
|
||||
static $settings = array(
|
||||
'license' => array('type', 'owner', 'url', 'title', 'image')
|
||||
);
|
||||
|
||||
$values = array();
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
$values[$section][$setting] = $this->trimmed($setting);
|
||||
}
|
||||
}
|
||||
|
||||
// This throws an exception on validation errors
|
||||
|
||||
$this->validate($values);
|
||||
|
||||
// assert(all values are valid);
|
||||
|
||||
$config = new Config();
|
||||
|
||||
$config->query('BEGIN');
|
||||
|
||||
foreach ($settings as $section => $parts) {
|
||||
foreach ($parts as $setting) {
|
||||
Config::save($section, $setting, $values[$section][$setting]);
|
||||
}
|
||||
}
|
||||
|
||||
$config->query('COMMIT');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate License admin form values
|
||||
*
|
||||
* @param array &$values from the form
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function validate(&$values)
|
||||
{
|
||||
// Validate license type (shouldn't have to do it, but just in case)
|
||||
|
||||
$types = array('private', 'allrightsreserved', 'cc');
|
||||
|
||||
if (!in_array($values['license']['type'], $types)) {
|
||||
$this->clientError(_("Invalid license selection."));
|
||||
}
|
||||
|
||||
// Make sure the user has set an owner if the site has a private
|
||||
// license
|
||||
|
||||
if ($values['license']['type'] == 'allrightsreserved'
|
||||
&& empty($values['license']['owner'])
|
||||
) {
|
||||
$this->clientError(
|
||||
_("You must specify the owner of the content when using the All Rights Reserved license.")
|
||||
);
|
||||
}
|
||||
|
||||
// Make sure the license title is not too long
|
||||
if (mb_strlen($values['license']['type']) > 255) {
|
||||
$this->clientError(
|
||||
_("Invalid license title. Max length is 255 characters.")
|
||||
);
|
||||
}
|
||||
|
||||
// make sure the license URL and license image URL are valid URLs
|
||||
|
||||
$options = array('allowed_schemes' => array('http', 'https'));
|
||||
|
||||
// URLs should be set for cc license
|
||||
|
||||
if ($values['license']['type'] == 'cc') {
|
||||
if (!Validate::uri($values['license']['url'], $options)) {
|
||||
$this->clientError(_("Invalid license URL."));
|
||||
}
|
||||
if (!Validate::uri($values['license']['image'], $options)) {
|
||||
$this->clientError(_("Invalid license image URL."));
|
||||
}
|
||||
}
|
||||
|
||||
// can be either blank or a valid URL for private & allrightsreserved
|
||||
|
||||
if (!empty($values['license']['url'])) {
|
||||
if (!Validate::uri($values['license']['url'], $options)) {
|
||||
$this->clientError(_("License URL must be blank or a valid URL."));
|
||||
}
|
||||
}
|
||||
|
||||
// can be either blank or a valid URL for private & allrightsreserved
|
||||
|
||||
if (!empty($values['license']['image'])) {
|
||||
if (!Validate::uri($values['license']['image'], $options)) {
|
||||
$this->clientError(_("License image must be blank or valid URL."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LicenseAdminPanelForm extends AdminForm
|
||||
{
|
||||
/**
|
||||
* ID of the form
|
||||
*
|
||||
* @return int ID of the form
|
||||
*/
|
||||
|
||||
function id()
|
||||
{
|
||||
return 'licenseadminpanel';
|
||||
}
|
||||
|
||||
/**
|
||||
* class of the form
|
||||
*
|
||||
* @return string class of the form
|
||||
*/
|
||||
|
||||
function formClass()
|
||||
{
|
||||
return 'form_settings';
|
||||
}
|
||||
|
||||
/**
|
||||
* Action of the form
|
||||
*
|
||||
* @return string URL of the action
|
||||
*/
|
||||
|
||||
function action()
|
||||
{
|
||||
return common_local_url('licenseadminpanel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Data elements of the form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formData()
|
||||
{
|
||||
$this->out->elementStart(
|
||||
'fieldset', array('id' => 'settings_license-selection')
|
||||
);
|
||||
$this->out->element('legend', null, _('License selection'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
|
||||
$types = array(
|
||||
'private' => _('Private'),
|
||||
'allrightsreserved' => _('All Rights Reserved'),
|
||||
'cc' => _('Creative Commons')
|
||||
);
|
||||
|
||||
$this->out->dropdown(
|
||||
'type',
|
||||
_('Type'),
|
||||
$types,
|
||||
_('Select license'),
|
||||
false,
|
||||
$this->value('type', 'license')
|
||||
);
|
||||
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
$this->out->elementEnd('fieldset');
|
||||
|
||||
$this->out->elementStart(
|
||||
'fieldset',
|
||||
array('id' => 'settings_license-details')
|
||||
);
|
||||
$this->out->element('legend', null, _('License details'));
|
||||
$this->out->elementStart('ul', 'form_data');
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'owner',
|
||||
_('Owner'),
|
||||
_('Name of the owner of the site\'s content (if applicable).'),
|
||||
'license'
|
||||
);
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'title',
|
||||
_('License Title'),
|
||||
_('The title of the license.'),
|
||||
'license'
|
||||
);
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'url',
|
||||
_('License URL'),
|
||||
_('URL for more information about the license.'),
|
||||
'license'
|
||||
);
|
||||
$this->unli();
|
||||
|
||||
$this->li();
|
||||
$this->input(
|
||||
'image', _('License Image URL'),
|
||||
_('URL for an image to display with the license.'),
|
||||
'license'
|
||||
);
|
||||
$this->unli();
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
$this->out->elementEnd('fieldset');
|
||||
}
|
||||
|
||||
/**
|
||||
* Action elements
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit(
|
||||
'submit', _('Save'), 'submit', null, _('Save license settings')
|
||||
);
|
||||
}
|
||||
}
|
@ -170,7 +170,7 @@ class NewApplicationAction extends OwnerDesignAction
|
||||
} elseif (Oauth_application::descriptionTooLong($description)) {
|
||||
$this->showForm(sprintf(
|
||||
_('Description is too long (max %d chars).'),
|
||||
Oauth_application::maxDescription()));
|
||||
Oauth_application::maxDesc()));
|
||||
return;
|
||||
} elseif (empty($source_url)) {
|
||||
$this->showForm(_('Source URL is required.'));
|
||||
|
@ -80,7 +80,7 @@ class OauthconnectionssettingsAction extends ConnectSettingsAction
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('You have allowed the following applications to access you account.');
|
||||
return _('You have allowed the following applications to access your account.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +67,7 @@ class PathsadminpanelAction extends AdminPanelAction
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('Path and server settings for this StatusNet site.');
|
||||
return _('Path and server settings for this StatusNet site');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,7 @@ class SessionsadminpanelAction extends AdminPanelAction
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('Session settings for this StatusNet site.');
|
||||
return _('Session settings for this StatusNet site');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,17 +271,17 @@ class ShowApplicationAction extends OwnerDesignAction
|
||||
|
||||
$this->elementStart('dl', 'entity_request_token_url');
|
||||
$this->element('dt', null, _('Request token URL'));
|
||||
$this->element('dd', null, common_local_url('apioauthrequesttoken'));
|
||||
$this->element('dd', null, common_local_url('ApiOauthRequestToken'));
|
||||
$this->elementEnd('dl');
|
||||
|
||||
$this->elementStart('dl', 'entity_access_token_url');
|
||||
$this->element('dt', null, _('Access token URL'));
|
||||
$this->element('dd', null, common_local_url('apioauthaccesstoken'));
|
||||
$this->element('dd', null, common_local_url('ApiOauthAccessToken'));
|
||||
$this->elementEnd('dl');
|
||||
|
||||
$this->elementStart('dl', 'entity_authorize_url');
|
||||
$this->element('dt', null, _('Authorize URL'));
|
||||
$this->element('dd', null, common_local_url('apioauthauthorize'));
|
||||
$this->element('dd', null, common_local_url('ApiOauthAuthorize'));
|
||||
$this->elementEnd('dl');
|
||||
|
||||
$this->element('p', 'note',
|
||||
|
@ -151,6 +151,7 @@ class ShownoticeAction extends OwnerDesignAction
|
||||
strtotime($this->avatar->modified) : 0;
|
||||
|
||||
return 'W/"' . implode(':', array($this->arg('action'),
|
||||
common_user_cache_hash(),
|
||||
common_language(),
|
||||
$this->notice->id,
|
||||
strtotime($this->notice->created),
|
||||
@ -291,6 +292,16 @@ class ShownoticeAction extends OwnerDesignAction
|
||||
array(),
|
||||
array('format'=>'xml','url'=>$this->notice->uri)),
|
||||
'title'=>'oEmbed'),null);
|
||||
|
||||
// Extras to aid in sharing notices to Facebook
|
||||
$avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||
$avatarUrl = ($avatar) ?
|
||||
$avatar->displayUrl() :
|
||||
Avatar::defaultImage($avatar_size);
|
||||
$this->element('meta', array('property' => 'og:image',
|
||||
'content' => $avatarUrl));
|
||||
$this->element('meta', array('property' => 'og:description',
|
||||
'content' => $this->notice->content));
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,10 +318,14 @@ class SingleNoticeItem extends NoticeListItem
|
||||
function show()
|
||||
{
|
||||
$this->showStart();
|
||||
$this->showNotice();
|
||||
$this->showNoticeAttachments();
|
||||
$this->showNoticeInfo();
|
||||
$this->showNoticeOptions();
|
||||
if (Event::handle('StartShowNoticeItem', array($this))) {
|
||||
$this->showNotice();
|
||||
$this->showNoticeAttachments();
|
||||
$this->showNoticeInfo();
|
||||
$this->showNoticeOptions();
|
||||
Event::handle('EndShowNoticeItem', array($this));
|
||||
}
|
||||
|
||||
$this->showEnd();
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
* (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.
|
||||
@ -24,7 +25,7 @@
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @copyright 2008-2009 StatusNet, Inc.
|
||||
* @copyright 2008-2010 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/
|
||||
*/
|
||||
@ -67,7 +68,7 @@ class UseradminpanelAction extends AdminPanelAction
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return _('User settings for this StatusNet site.');
|
||||
return _('User settings for this StatusNet site');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,6 +292,6 @@ class UserAdminPanelForm extends AdminForm
|
||||
|
||||
function formActions()
|
||||
{
|
||||
$this->out->submit('submit', _('Save'), 'submit', null, _('Save site settings'));
|
||||
$this->out->submit('submit', _('Save'), 'submit', null, _('Save user settings'));
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,9 @@ class Avatar extends Memcached_DataObject
|
||||
return Memcached_DataObject::pkeyGet('Avatar', $kv);
|
||||
}
|
||||
|
||||
// where should the avatar go for this user?
|
||||
|
||||
/**
|
||||
* Where should the avatar go for this user?
|
||||
*/
|
||||
static function filename($id, $extension, $size=null, $extra=null)
|
||||
{
|
||||
if ($size) {
|
||||
|
@ -65,5 +65,4 @@ class Consumer extends Memcached_DataObject
|
||||
$nonce->consumer_key = $this->consumer_key;
|
||||
$nonce->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,6 +74,4 @@ class Conversation extends Memcached_DataObject
|
||||
|
||||
return $conv;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -129,4 +129,32 @@ class Fave extends Memcached_DataObject
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
function asActivity()
|
||||
{
|
||||
$notice = Notice::staticGet('id', $this->notice_id);
|
||||
$profile = Profile::staticGet('id', $this->user_id);
|
||||
|
||||
$act = new Activity();
|
||||
|
||||
$act->verb = ActivityVerb::FAVORITE;
|
||||
$act->id = TagURI::mint('favor:%d:%d:%s',
|
||||
$profile->id,
|
||||
$notice->id,
|
||||
common_date_iso8601($this->modified));
|
||||
|
||||
$act->time = strtotime($this->modified);
|
||||
// TRANS: Activity title when marking a notice as favorite.
|
||||
$act->title = _("Favor");
|
||||
// TRANS: Ntofication given when a user marks a notice as favorite.
|
||||
// TRANS: %1$s is a user nickname or full name, %2$s is a notice URI.
|
||||
$act->content = sprintf(_("%1$s marked notice %2$s as a favorite."),
|
||||
$profile->getBestName(),
|
||||
$notice->uri);
|
||||
|
||||
$act->actor = ActivityObject::fromProfile($profile);
|
||||
$act->objects[] = ActivityObject::fromNotice($notice);
|
||||
|
||||
return $act;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,6 @@ require_once INSTALLDIR.'/classes/File_to_post.php';
|
||||
/**
|
||||
* Table Definition for file
|
||||
*/
|
||||
|
||||
class File extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
|
@ -131,4 +131,3 @@ class File_oembed extends Memcached_DataObject
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,4 +311,3 @@ class File_redirection extends Memcached_DataObject
|
||||
$file_redir->insert();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,4 +57,3 @@ class File_thumbnail extends Memcached_DataObject
|
||||
$tn->insert();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,4 +67,3 @@ class File_to_post extends Memcached_DataObject
|
||||
return Memcached_DataObject::pkeyGet('File_to_post', $kv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,6 @@ class Foreign_link extends Memcached_DataObject
|
||||
$result = $flink->find(true);
|
||||
|
||||
return empty($result) ? null : $flink;
|
||||
|
||||
}
|
||||
|
||||
static function getByForeignID($foreign_id, $service)
|
||||
@ -129,5 +128,4 @@ class Foreign_link extends Memcached_DataObject
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Foreign_service extends Memcached_DataObject
|
||||
class Foreign_service extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
@ -12,7 +12,7 @@ class Foreign_service extends Memcached_DataObject
|
||||
public $__table = 'foreign_service'; // table name
|
||||
public $id; // int(4) primary_key not_null
|
||||
public $name; // varchar(32) unique_key not_null
|
||||
public $description; // varchar(255)
|
||||
public $description; // varchar(255)
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Foreign_subscription extends Memcached_DataObject
|
||||
class Foreign_subscription extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
|
@ -83,5 +83,4 @@ class Foreign_user extends Memcached_DataObject
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -111,5 +111,4 @@ class Group_block extends Memcached_DataObject
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Table Definition for group_inbox
|
||||
*/
|
||||
|
||||
class Group_inbox extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
|
@ -65,4 +65,59 @@ class Group_member extends Memcached_DataObject
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getMember()
|
||||
{
|
||||
$member = Profile::staticGet('id', $this->profile_id);
|
||||
|
||||
if (empty($member)) {
|
||||
// TRANS: Exception thrown providing an invalid profile ID.
|
||||
// TRANS: %s is the invalid profile ID.
|
||||
throw new Exception(sprintf(_("Profile ID %s is invalid."),$this->profile_id));
|
||||
}
|
||||
|
||||
return $member;
|
||||
}
|
||||
|
||||
function getGroup()
|
||||
{
|
||||
$group = User_group::staticGet('id', $this->group_id);
|
||||
|
||||
if (empty($group)) {
|
||||
// TRANS: Exception thrown providing an invalid group ID.
|
||||
// TRANS: %s is the invalid group ID.
|
||||
throw new Exception(sprintf(_("Group ID %s is invalid."),$this->group_id));
|
||||
}
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
||||
function asActivity()
|
||||
{
|
||||
$member = $this->getMember();
|
||||
$group = $this->getGroup();
|
||||
|
||||
$act = new Activity();
|
||||
|
||||
$act->id = TagURI::mint('join:%d:%d:%s',
|
||||
$member->id,
|
||||
$group->id,
|
||||
common_date_iso8601($this->created));
|
||||
|
||||
$act->actor = ActivityObject::fromProfile($member);
|
||||
$act->verb = ActivityVerb::JOIN;
|
||||
$act->objects[] = ActivityObject::fromGroup($group);
|
||||
|
||||
$act->time = strtotime($this->created);
|
||||
// TRANS: Activity title.
|
||||
$act->title = _("Join");
|
||||
|
||||
// TRANS: Success message for subscribe to group attempt through OStatus.
|
||||
// TRANS: %1$s is the member name, %2$s is the subscribed group's name.
|
||||
$act->content = sprintf(_('%1$s has joined group %2$s.'),
|
||||
$member->getBestName(),
|
||||
$group->getBestName());
|
||||
|
||||
return $act;
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ class Inbox extends Memcached_DataObject
|
||||
/**
|
||||
* Create a new inbox from existing Notice_inbox stuff
|
||||
*/
|
||||
|
||||
static function initialize($user_id)
|
||||
{
|
||||
$inbox = Inbox::fromNoticeInbox($user_id);
|
||||
@ -115,10 +114,10 @@ class Inbox extends Memcached_DataObject
|
||||
*/
|
||||
static function insertNotice($user_id, $notice_id)
|
||||
{
|
||||
// Going straight to the DB rather than trusting our caching
|
||||
// during an update. Note: not using DB_DataObject::staticGet,
|
||||
// which is unsafe to use directly (in-process caching causes
|
||||
// memory leaks, which accumulate in queue processes).
|
||||
// Going straight to the DB rather than trusting our caching
|
||||
// during an update. Note: not using DB_DataObject::staticGet,
|
||||
// which is unsafe to use directly (in-process caching causes
|
||||
// memory leaks, which accumulate in queue processes).
|
||||
$inbox = new Inbox();
|
||||
if (!$inbox->get('user_id', $user_id)) {
|
||||
$inbox = Inbox::initialize($user_id);
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Invitation extends Memcached_DataObject
|
||||
class Invitation extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
|
@ -189,11 +189,11 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
str_replace("\n", " ", $e->getTraceAsString()));
|
||||
return false;
|
||||
} else {
|
||||
$keys = $this->_allCacheKeys();
|
||||
$keys = $this->_allCacheKeys();
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$c->set($key, $this);
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
$c->set($key, $this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -637,4 +637,3 @@ class Memcached_DataObject extends Safe_DataObject
|
||||
return $vstr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,6 @@ class Message extends Memcached_DataObject
|
||||
}
|
||||
|
||||
static function saveNew($from, $to, $content, $source) {
|
||||
|
||||
$sender = Profile::staticGet('id', $from);
|
||||
|
||||
if (!$sender->hasRight(Right::NEWMESSAGE)) {
|
||||
|
@ -36,5 +36,4 @@ class Nonce extends Memcached_DataObject
|
||||
{
|
||||
return array('consumer_key,token' => 'token:consumer_key,token');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -745,6 +745,7 @@ class Notice extends Memcached_DataObject
|
||||
1,
|
||||
1
|
||||
);
|
||||
|
||||
if ($conversation->N > 0) {
|
||||
return true;
|
||||
}
|
||||
@ -753,8 +754,15 @@ class Notice extends Memcached_DataObject
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $groups array of Group *objects*
|
||||
* @param $recipients array of profile *ids*
|
||||
* Pull up a full list of local recipients who will be getting
|
||||
* this notice in their inbox. Results will be cached, so don't
|
||||
* change the input data wily-nilly!
|
||||
*
|
||||
* @param array $groups optional list of Group objects;
|
||||
* if left empty, will be loaded from group_inbox records
|
||||
* @param array $recipient optional list of reply profile ids
|
||||
* if left empty, will be loaded from reply records
|
||||
* @return array associating recipient user IDs with an inbox source constant
|
||||
*/
|
||||
function whoGets($groups=null, $recipients=null)
|
||||
{
|
||||
@ -787,27 +795,27 @@ class Notice extends Memcached_DataObject
|
||||
$ni[$id] = NOTICE_INBOX_SOURCE_SUB;
|
||||
}
|
||||
|
||||
$profile = $this->getProfile();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$users = $group->getUserMembers();
|
||||
foreach ($users as $id) {
|
||||
if (!array_key_exists($id, $ni)) {
|
||||
$user = User::staticGet('id', $id);
|
||||
if (!$user->hasBlocked($profile)) {
|
||||
$ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
|
||||
}
|
||||
$ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($recipients as $recipient) {
|
||||
|
||||
if (!array_key_exists($recipient, $ni)) {
|
||||
$recipientUser = User::staticGet('id', $recipient);
|
||||
if (!empty($recipientUser)) {
|
||||
$ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
|
||||
}
|
||||
$ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude any deleted, non-local, or blocking recipients.
|
||||
$profile = $this->getProfile();
|
||||
foreach ($ni as $id => $source) {
|
||||
$user = User::staticGet('id', $id);
|
||||
if (empty($user) || $user->hasBlocked($profile)) {
|
||||
unset($ni[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1212,6 +1220,64 @@ class Notice extends Memcached_DataObject
|
||||
return $groups;
|
||||
}
|
||||
|
||||
function asActivity()
|
||||
{
|
||||
$profile = $this->getProfile();
|
||||
|
||||
$act = new Activity();
|
||||
|
||||
$act->actor = ActivityObject::fromProfile($profile);
|
||||
$act->verb = ActivityVerb::POST;
|
||||
$act->objects[] = ActivityObject::fromNotice($this);
|
||||
|
||||
$act->time = strtotime($this->created);
|
||||
$act->link = $this->bestUrl();
|
||||
|
||||
$act->content = common_xml_safe_str($this->rendered);
|
||||
$act->id = $this->uri;
|
||||
$act->title = common_xml_safe_str($this->content);
|
||||
|
||||
$ctx = new ActivityContext();
|
||||
|
||||
if (!empty($this->reply_to)) {
|
||||
$reply = Notice::staticGet('id', $this->reply_to);
|
||||
if (!empty($reply)) {
|
||||
$ctx->replyToID = $reply->uri;
|
||||
$ctx->replyToUrl = $reply->bestUrl();
|
||||
}
|
||||
}
|
||||
|
||||
$ctx->location = $this->getLocation();
|
||||
|
||||
$conv = null;
|
||||
|
||||
if (!empty($this->conversation)) {
|
||||
$conv = Conversation::staticGet('id', $this->conversation);
|
||||
if (!empty($conv)) {
|
||||
$ctx->conversation = $conv->uri;
|
||||
}
|
||||
}
|
||||
|
||||
$reply_ids = $this->getReplies();
|
||||
|
||||
foreach ($reply_ids as $id) {
|
||||
$profile = Profile::staticGet('id', $id);
|
||||
if (!empty($profile)) {
|
||||
$ctx->attention[] = $profile->getUri();
|
||||
}
|
||||
}
|
||||
|
||||
$groups = $this->getGroups();
|
||||
|
||||
foreach ($groups as $group) {
|
||||
$ctx->attention[] = $group->uri;
|
||||
}
|
||||
|
||||
$act->context = $ctx;
|
||||
|
||||
return $act;
|
||||
}
|
||||
|
||||
// This has gotten way too long. Needs to be sliced up into functional bits
|
||||
// or ideally exported to a utility class.
|
||||
|
||||
@ -1240,13 +1306,10 @@ class Notice extends Memcached_DataObject
|
||||
}
|
||||
|
||||
if (Event::handle('StartActivitySource', array(&$this, &$xs))) {
|
||||
|
||||
if ($source) {
|
||||
|
||||
$atom_feed = $profile->getAtomFeed();
|
||||
|
||||
if (!empty($atom_feed)) {
|
||||
|
||||
$xs->elementStart('source');
|
||||
|
||||
// XXX: we should store the actual feed ID
|
||||
@ -1834,7 +1897,6 @@ class Notice extends Memcached_DataObject
|
||||
$options = array();
|
||||
|
||||
if (!empty($location_id) && !empty($location_ns)) {
|
||||
|
||||
$options['location_id'] = $location_id;
|
||||
$options['location_ns'] = $location_ns;
|
||||
|
||||
@ -1846,7 +1908,6 @@ class Notice extends Memcached_DataObject
|
||||
}
|
||||
|
||||
} else if (!empty($lat) && !empty($lon)) {
|
||||
|
||||
$options['lat'] = $lat;
|
||||
$options['lon'] = $lon;
|
||||
|
||||
@ -1857,7 +1918,6 @@ class Notice extends Memcached_DataObject
|
||||
$options['location_ns'] = $location->location_ns;
|
||||
}
|
||||
} else if (!empty($profile)) {
|
||||
|
||||
if (isset($profile->lat) && isset($profile->lon)) {
|
||||
$options['lat'] = $profile->lat;
|
||||
$options['lon'] = $profile->lon;
|
||||
@ -1974,6 +2034,7 @@ class Notice extends Memcached_DataObject
|
||||
{
|
||||
// We always insert for the author so they don't
|
||||
// have to wait
|
||||
Event::handle('StartNoticeDistribute', array($this));
|
||||
|
||||
$user = User::staticGet('id', $this->profile_id);
|
||||
if (!empty($user)) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Notice_source extends Memcached_DataObject
|
||||
class Notice_source extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
|
@ -110,7 +110,6 @@ class Oauth_application extends Memcached_DataObject
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function uploadLogo()
|
||||
{
|
||||
if ($_FILES['app_icon']['error'] ==
|
||||
@ -153,5 +152,4 @@ class Oauth_application extends Memcached_DataObject
|
||||
$oauser->application_id = $this->id;
|
||||
$oauser->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,5 +40,4 @@ class Oauth_application_user extends Memcached_DataObject
|
||||
|
||||
return empty($result) ? null : $oau;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -103,7 +103,6 @@ class Profile extends Memcached_DataObject
|
||||
foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) {
|
||||
# We don't do a scaled one if original is our scaled size
|
||||
if (!($avatar->width == $size && $avatar->height == $size)) {
|
||||
|
||||
$scaled_filename = $imagefile->resize($size);
|
||||
|
||||
//$scaled = DB_DataObject::factory('avatar');
|
||||
@ -474,6 +473,41 @@ class Profile extends Memcached_DataObject
|
||||
return $cnt;
|
||||
}
|
||||
|
||||
function hasFave($notice)
|
||||
{
|
||||
$cache = Cache::instance();
|
||||
|
||||
// XXX: Kind of a hack.
|
||||
|
||||
if (!empty($cache)) {
|
||||
// This is the stream of favorite notices, in rev chron
|
||||
// order. This forces it into cache.
|
||||
|
||||
$ids = Fave::stream($this->id, 0, NOTICE_CACHE_WINDOW);
|
||||
|
||||
// If it's in the list, then it's a fave
|
||||
|
||||
if (in_array($notice->id, $ids)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we're not past the end of the cache window,
|
||||
// then the cache has all available faves, so this one
|
||||
// is not a fave.
|
||||
|
||||
if (count($ids) < NOTICE_CACHE_WINDOW) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, cache doesn't have all faves;
|
||||
// fall through to the default
|
||||
}
|
||||
|
||||
$fave = Fave::pkeyGet(array('user_id' => $this->id,
|
||||
'notice_id' => $notice->id));
|
||||
return ((is_null($fave)) ? false : true);
|
||||
}
|
||||
|
||||
function faveCount()
|
||||
{
|
||||
$c = Cache::instance();
|
||||
@ -517,6 +551,20 @@ class Profile extends Memcached_DataObject
|
||||
return $cnt;
|
||||
}
|
||||
|
||||
function blowFavesCache()
|
||||
{
|
||||
$cache = common_memcache();
|
||||
if ($cache) {
|
||||
// Faves don't happen chronologically, so we need to blow
|
||||
// ;last cache, too
|
||||
$cache->delete(common_cache_key('fave:ids_by_user:'.$this->id));
|
||||
$cache->delete(common_cache_key('fave:ids_by_user:'.$this->id.';last'));
|
||||
$cache->delete(common_cache_key('fave:ids_by_user_own:'.$this->id));
|
||||
$cache->delete(common_cache_key('fave:ids_by_user_own:'.$this->id.';last'));
|
||||
}
|
||||
$this->blowFaveCount();
|
||||
}
|
||||
|
||||
function blowSubscriberCount()
|
||||
{
|
||||
$c = Cache::instance();
|
||||
@ -790,13 +838,14 @@ class Profile extends Memcached_DataObject
|
||||
* @param $right string Name of the right, usually a constant in class Right
|
||||
* @return boolean whether the user has the right in question
|
||||
*/
|
||||
|
||||
function hasRight($right)
|
||||
{
|
||||
$result = false;
|
||||
|
||||
if ($this->hasRole(Profile_role::DELETED)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Event::handle('UserRightsCheck', array($this, $right, &$result))) {
|
||||
switch ($right)
|
||||
{
|
||||
|
@ -23,7 +23,6 @@ class Profile_tag extends Memcached_DataObject
|
||||
###END_AUTOCODE
|
||||
|
||||
static function getTags($tagger, $tagged) {
|
||||
|
||||
$tags = array();
|
||||
|
||||
# XXX: store this in memcached
|
||||
@ -44,7 +43,6 @@ class Profile_tag extends Memcached_DataObject
|
||||
}
|
||||
|
||||
static function setTags($tagger, $tagged, $newtags) {
|
||||
|
||||
$newtags = array_unique($newtags);
|
||||
$oldtags = Profile_tag::getTags($tagger, $tagged);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Remember_me extends Memcached_DataObject
|
||||
class Remember_me extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
@ -16,11 +16,15 @@ class Remember_me extends Memcached_DataObject
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=null)
|
||||
{ return Memcached_DataObject::staticGet('Remember_me',$k,$v); }
|
||||
{
|
||||
return Memcached_DataObject::staticGet('Remember_me',$k,$v);
|
||||
}
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
function sequenceKey()
|
||||
{ return array(false, false); }
|
||||
{
|
||||
return array(false, false);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Remote_profile extends Memcached_DataObject
|
||||
class Remote_profile extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
@ -32,8 +32,8 @@ class Remote_profile extends Memcached_DataObject
|
||||
public $__table = 'remote_profile'; // table name
|
||||
public $id; // int(4) primary_key not_null
|
||||
public $uri; // varchar(255) unique_key
|
||||
public $postnoticeurl; // varchar(255)
|
||||
public $updateprofileurl; // varchar(255)
|
||||
public $postnoticeurl; // varchar(255)
|
||||
public $updateprofileurl; // varchar(255)
|
||||
public $created; // datetime() not_null
|
||||
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
|
||||
|
||||
@ -43,7 +43,7 @@ class Remote_profile extends Memcached_DataObject
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
|
||||
function hasRight($right)
|
||||
{
|
||||
$profile = Profile::staticGet($this->id);
|
||||
|
@ -287,4 +287,3 @@ class Safe_DataObject extends DB_DataObject
|
||||
return Safe_DataObject::$iniCache[$key];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
require_once INSTALLDIR.'/classes/Memcached_DataObject.php';
|
||||
|
||||
class Sms_carrier extends Memcached_DataObject
|
||||
class Sms_carrier extends Memcached_DataObject
|
||||
{
|
||||
###START_AUTOCODE
|
||||
/* the code below is auto generated do not remove the above tag */
|
||||
@ -22,7 +22,7 @@ class Sms_carrier extends Memcached_DataObject
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
|
||||
|
||||
function toEmailAddress($sms)
|
||||
{
|
||||
return sprintf($this->email_pattern, $sms);
|
||||
|
@ -167,18 +167,17 @@ class Status_network extends Safe_DataObject
|
||||
' WHERE nickname = ' . $this->_quote($this->nickname);
|
||||
$orig->decache();
|
||||
$result = $this->query($qry);
|
||||
if ($result) {
|
||||
$this->encache();
|
||||
}
|
||||
$this->decache();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function delete()
|
||||
{
|
||||
$this->decache(); # while we still have the values!
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $servername hostname
|
||||
* @param string $wildcard hostname suffix to match wildcard config
|
||||
@ -314,7 +313,7 @@ class Status_network extends Safe_DataObject
|
||||
if (empty($result)) {
|
||||
return explode('|', $this->tags);
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -332,7 +331,7 @@ class Status_network extends Safe_DataObject
|
||||
$snt->site_id = $this->site_id;
|
||||
$snt->tag = $tag;
|
||||
$snt->created = common_sql_now();
|
||||
|
||||
|
||||
$id = $snt->insert();
|
||||
if (!$id) {
|
||||
// TRANS: Exception thrown when a tag cannot be saved.
|
||||
@ -357,7 +356,7 @@ class Status_network extends Safe_DataObject
|
||||
|
||||
$tag->free();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if this site record has a particular meta-info tag attached.
|
||||
* @param string $tag
|
||||
|
@ -26,7 +26,7 @@ class Status_network_tag extends Safe_DataObject
|
||||
|
||||
public $__table = 'status_network_tag'; // table name
|
||||
public $site_id; // int(4) primary_key not_null
|
||||
public $tag; // varchar(64) primary_key not_null
|
||||
public $tag; // varchar(64) primary_key not_null
|
||||
public $created; // datetime() not_null
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ class Status_network_tag extends Safe_DataObject
|
||||
{
|
||||
global $config;
|
||||
global $_DB_DATAOBJECT;
|
||||
|
||||
|
||||
$sn = new Status_network();
|
||||
$sn->_connect();
|
||||
|
||||
|
@ -235,4 +235,33 @@ class Subscription extends Memcached_DataObject
|
||||
'subscribed' => $other->id));
|
||||
return (empty($sub)) ? false : true;
|
||||
}
|
||||
|
||||
function asActivity()
|
||||
{
|
||||
$subscriber = Profile::staticGet('id', $this->subscriber);
|
||||
$subscribed = Profile::staticGet('id', $this->subscribed);
|
||||
|
||||
$act = new Activity();
|
||||
|
||||
$act->verb = ActivityVerb::FOLLOW;
|
||||
|
||||
$act->id = TagURI::mint('follow:%d:%d:%s',
|
||||
$subscriber->id,
|
||||
$subscribed->id,
|
||||
common_date_iso8601($this->created));
|
||||
|
||||
$act->time = strtotime($this->created);
|
||||
// TRANS: Activity tile when subscribing to another person.
|
||||
$act->title = _("Follow");
|
||||
// TRANS: Notification given when one person starts following another.
|
||||
// TRANS: %1$s is the subscriber, %2$s is the subscribed.
|
||||
$act->content = sprintf(_("%1$s is now following %2$s."),
|
||||
$subscriber->getBestName(),
|
||||
$subscribed->getBestName());
|
||||
|
||||
$act->actor = ActivityObject::fromProfile($subscriber);
|
||||
$act->objects[] = ActivityObject::fromProfile($subscribed);
|
||||
|
||||
return $act;
|
||||
}
|
||||
}
|
||||
|
@ -250,6 +250,19 @@ class User extends Memcached_DataObject
|
||||
|
||||
$user->inboxed = 1;
|
||||
|
||||
// Set default-on options here, otherwise they'll be disabled
|
||||
// initially for sites using caching, since the initial encache
|
||||
// doesn't know about the defaults in the database.
|
||||
$user->emailnotifysub = 1;
|
||||
$user->emailnotifyfav = 1;
|
||||
$user->emailnotifynudge = 1;
|
||||
$user->emailnotifymsg = 1;
|
||||
$user->emailnotifyattn = 1;
|
||||
$user->emailmicroid = 1;
|
||||
$user->emailpost = 1;
|
||||
$user->jabbermicroid = 1;
|
||||
$user->viewdesigns = 1;
|
||||
|
||||
$user->created = common_sql_now();
|
||||
|
||||
if (Event::handle('StartUserRegister', array(&$user, &$profile))) {
|
||||
@ -264,7 +277,13 @@ class User extends Memcached_DataObject
|
||||
}
|
||||
|
||||
$user->id = $id;
|
||||
$user->uri = common_user_uri($user);
|
||||
|
||||
if (!empty($uri)) {
|
||||
$user->uri = $uri;
|
||||
} else {
|
||||
$user->uri = common_user_uri($user);
|
||||
}
|
||||
|
||||
if (!empty($password)) { // may not have a password for OpenID users
|
||||
$user->password = common_munge_password($password, $id);
|
||||
}
|
||||
@ -388,37 +407,8 @@ class User extends Memcached_DataObject
|
||||
|
||||
function hasFave($notice)
|
||||
{
|
||||
$cache = Cache::instance();
|
||||
|
||||
// XXX: Kind of a hack.
|
||||
|
||||
if ($cache) {
|
||||
// This is the stream of favorite notices, in rev chron
|
||||
// order. This forces it into cache.
|
||||
|
||||
$ids = Fave::stream($this->id, 0, NOTICE_CACHE_WINDOW);
|
||||
|
||||
// If it's in the list, then it's a fave
|
||||
|
||||
if (in_array($notice->id, $ids)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If we're not past the end of the cache window,
|
||||
// then the cache has all available faves, so this one
|
||||
// is not a fave.
|
||||
|
||||
if (count($ids) < NOTICE_CACHE_WINDOW) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise, cache doesn't have all faves;
|
||||
// fall through to the default
|
||||
}
|
||||
|
||||
$fave = Fave::pkeyGet(array('user_id' => $this->id,
|
||||
'notice_id' => $notice->id));
|
||||
return ((is_null($fave)) ? false : true);
|
||||
$profile = $this->getProfile();
|
||||
return $profile->hasFave($notice);
|
||||
}
|
||||
|
||||
function mutuallySubscribed($other)
|
||||
@ -487,17 +477,8 @@ class User extends Memcached_DataObject
|
||||
|
||||
function blowFavesCache()
|
||||
{
|
||||
$cache = Cache::instance();
|
||||
if ($cache) {
|
||||
// Faves don't happen chronologically, so we need to blow
|
||||
// ;last cache, too
|
||||
$cache->delete(Cache::key('fave:ids_by_user:'.$this->id));
|
||||
$cache->delete(Cache::key('fave:ids_by_user:'.$this->id.';last'));
|
||||
$cache->delete(Cache::key('fave:ids_by_user_own:'.$this->id));
|
||||
$cache->delete(Cache::key('fave:ids_by_user_own:'.$this->id.';last'));
|
||||
}
|
||||
$profile = $this->getProfile();
|
||||
$profile->blowFaveCount();
|
||||
$profile->blowFavesCache();
|
||||
}
|
||||
|
||||
function getSelfTags()
|
||||
@ -547,6 +528,9 @@ class User extends Memcached_DataObject
|
||||
if (Subscription::exists($other, $self)) {
|
||||
Subscription::cancel($other, $self);
|
||||
}
|
||||
if (Subscription::exists($self, $other)) {
|
||||
Subscription::cancel($self, $other);
|
||||
}
|
||||
|
||||
$block->query('COMMIT');
|
||||
|
||||
|
@ -465,7 +465,6 @@ class User_group extends Memcached_DataObject
|
||||
}
|
||||
|
||||
static function register($fields) {
|
||||
|
||||
// MAGICALLY put fields into current scope
|
||||
|
||||
extract($fields);
|
||||
|
@ -18,7 +18,9 @@ class User_username extends Memcached_DataObject
|
||||
|
||||
/* Static get */
|
||||
function staticGet($k,$v=null)
|
||||
{ return Memcached_DataObject::staticGet('User_username',$k,$v); }
|
||||
{
|
||||
return Memcached_DataObject::staticGet('User_username',$k,$v);
|
||||
}
|
||||
|
||||
/* the code above is auto generated do not remove the tag below */
|
||||
###END_AUTOCODE
|
||||
@ -37,6 +39,7 @@ class User_username extends Memcached_DataObject
|
||||
$user_username->provider_name = $provider_name;
|
||||
$user_username->username = $username;
|
||||
$user_username->created = DB_DataObject_Cast::dateTime();
|
||||
|
||||
if($user_username->insert()){
|
||||
return $user_username;
|
||||
}else{
|
||||
@ -57,5 +60,4 @@ class User_username extends Memcached_DataObject
|
||||
function keys() {
|
||||
return array('provider_name' => 'K', 'username' => 'K');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,6 +52,10 @@ VALUES
|
||||
('socialoomphBfD4pMqz31', 'SocialOomph', 'http://www.socialoomph.com/', now()),
|
||||
('spaz','Spaz','http://funkatron.com/spaz', now()),
|
||||
('StatusNet Desktop', 'StatusNet Desktop', 'http://status.net/desktop', now()),
|
||||
('StatusNet Mobile', 'StatusNet Mobile', 'http://status.net/mobile', now()),
|
||||
('StatusNet iPhone', 'iPhone', 'http://status.net/iphone', now()),
|
||||
('StatusNet Android', 'Android', 'http://status.net/android', now()),
|
||||
('StatusNet Blackberry', 'Blackberry', 'http://status.net/blackberry', now()),
|
||||
('tarpipe','tarpipe','http://tarpipe.com/', now()),
|
||||
('tjunar','Tjunar','http://nederflash.nl/boek/titels/tjunar-air', now()),
|
||||
('tr.im','tr.im','http://tr.im/', now()),
|
||||
|
@ -44,7 +44,6 @@ require_once INSTALLDIR.'/lib/settingsaction.php';
|
||||
*
|
||||
* @see Widget
|
||||
*/
|
||||
|
||||
class AccountSettingsAction extends SettingsAction
|
||||
{
|
||||
/**
|
||||
@ -54,7 +53,6 @@ class AccountSettingsAction extends SettingsAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showLocalNav()
|
||||
{
|
||||
$menu = new AccountSettingsNav($this);
|
||||
@ -73,7 +71,6 @@ class AccountSettingsAction extends SettingsAction
|
||||
*
|
||||
* @see HTMLOutputter
|
||||
*/
|
||||
|
||||
class AccountSettingsNav extends Widget
|
||||
{
|
||||
var $action = null;
|
||||
@ -83,7 +80,6 @@ class AccountSettingsNav extends Widget
|
||||
*
|
||||
* @param Action $action current action, used for output
|
||||
*/
|
||||
|
||||
function __construct($action=null)
|
||||
{
|
||||
parent::__construct($action);
|
||||
@ -95,7 +91,6 @@ class AccountSettingsNav extends Widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function show()
|
||||
{
|
||||
$action_name = $this->action->trimmed('action');
|
||||
|
@ -314,7 +314,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function showFeeds()
|
||||
{
|
||||
$feeds = $this->getFeeds();
|
||||
@ -710,19 +709,18 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function showAside()
|
||||
{
|
||||
$this->elementStart('div', array('id' => 'aside_primary',
|
||||
'class' => 'aside'));
|
||||
if (Event::handle('StartShowExportData', array($this))) {
|
||||
$this->showExportData();
|
||||
Event::handle('EndShowExportData', array($this));
|
||||
}
|
||||
if (Event::handle('StartShowSections', array($this))) {
|
||||
$this->showSections();
|
||||
Event::handle('EndShowSections', array($this));
|
||||
}
|
||||
if (Event::handle('StartShowExportData', array($this))) {
|
||||
$this->showExportData();
|
||||
Event::handle('EndShowExportData', array($this));
|
||||
}
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
|
||||
@ -731,7 +729,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showExportData()
|
||||
{
|
||||
$feeds = $this->getFeeds();
|
||||
@ -807,6 +804,7 @@ class Action extends HTMLOutputter // lawsuit
|
||||
// TRANS: Secondary navigation menu option leading to contact information on the StatusNet site.
|
||||
_('Contact'));
|
||||
$this->menuItem(common_local_url('doc', array('title' => 'badge')),
|
||||
// TRANS: Secondary navigation menu option.
|
||||
_('Badge'));
|
||||
Event::handle('EndSecondaryNav', array($this));
|
||||
}
|
||||
@ -840,6 +838,9 @@ class Action extends HTMLOutputter // lawsuit
|
||||
$this->elementStart('dd', null);
|
||||
if (common_config('site', 'broughtby')) {
|
||||
// TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is set.
|
||||
// TRANS: Text between [] is a link description, text between () is the link itself.
|
||||
// TRANS: Make sure there is no whitespace between "]" and "(".
|
||||
// TRANS: "%%site.broughtby%%" is the value of the variable site.broughtby
|
||||
$instr = _('**%%site.name%%** is a microblogging service brought to you by [%%site.broughtby%%](%%site.broughtbyurl%%).');
|
||||
} else {
|
||||
// TRANS: First sentence of the StatusNet site license. Used if 'broughtby' is not set.
|
||||
@ -847,6 +848,9 @@ class Action extends HTMLOutputter // lawsuit
|
||||
}
|
||||
$instr .= ' ';
|
||||
// TRANS: Second sentence of the StatusNet site license. Mentions the StatusNet source code license.
|
||||
// TRANS: Make sure there is no whitespace between "]" and "(".
|
||||
// TRANS: Text between [] is a link description, text between () is the link itself.
|
||||
// TRANS: %s is the version of StatusNet that is being used.
|
||||
$instr .= sprintf(_('It runs the [StatusNet](http://status.net/) microblogging software, version %s, available under the [GNU Affero General Public License](http://www.fsf.org/licensing/licenses/agpl-3.0.html).'), STATUSNET_VERSION);
|
||||
$output = common_markup_to_html($instr);
|
||||
$this->raw($output);
|
||||
@ -893,7 +897,8 @@ class Action extends HTMLOutputter // lawsuit
|
||||
'width' => '80',
|
||||
'height' => '15'));
|
||||
$this->text(' ');
|
||||
// TRANS: license message in footer. %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration.
|
||||
// TRANS: license message in footer.
|
||||
// TRANS: %1$s is the site name, %2$s is a link to the license URL, with a licence name set in configuration.
|
||||
$notice = _('All %1$s content and data are available under the %2$s license.');
|
||||
$link = "<a class=\"license\" rel=\"external license\" href=\"" .
|
||||
htmlspecialchars(common_config('license', 'url')) .
|
||||
@ -947,7 +952,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return false;
|
||||
@ -1011,17 +1015,22 @@ class Action extends HTMLOutputter // lawsuit
|
||||
}
|
||||
}
|
||||
|
||||
$checked = false;
|
||||
if ($etag) {
|
||||
$if_none_match = (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER)) ?
|
||||
$_SERVER['HTTP_IF_NONE_MATCH'] : null;
|
||||
if ($if_none_match && $this->_hasEtag($etag, $if_none_match)) {
|
||||
header('HTTP/1.1 304 Not Modified');
|
||||
// Better way to do this?
|
||||
exit(0);
|
||||
if ($if_none_match) {
|
||||
// If this check fails, ignore the if-modified-since below.
|
||||
$checked = true;
|
||||
if ($this->_hasEtag($etag, $if_none_match)) {
|
||||
header('HTTP/1.1 304 Not Modified');
|
||||
// Better way to do this?
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
|
||||
if (!$checked && $lm && array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
|
||||
$if_modified_since = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
|
||||
$ims = strtotime($if_modified_since);
|
||||
if ($lm <= $ims) {
|
||||
@ -1041,7 +1050,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return boolean is read only action?
|
||||
*/
|
||||
|
||||
function isCacheable()
|
||||
{
|
||||
return true;
|
||||
@ -1055,7 +1063,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
|
||||
function _hasEtag($etag, $if_none_match)
|
||||
{
|
||||
$etags = explode(',', $if_none_match);
|
||||
@ -1095,7 +1102,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return integer integer value
|
||||
*/
|
||||
|
||||
function int($key, $defValue=null, $maxValue=null, $minValue=null)
|
||||
{
|
||||
$arg = strtolower($this->trimmed($key));
|
||||
@ -1123,7 +1129,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function serverError($msg, $code=500)
|
||||
{
|
||||
$action = $this->trimmed('action');
|
||||
@ -1139,7 +1144,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function clientError($msg, $code=400)
|
||||
{
|
||||
$action = $this->trimmed('action');
|
||||
@ -1152,7 +1156,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return string current URL
|
||||
*/
|
||||
|
||||
function selfUrl()
|
||||
{
|
||||
list($action, $args) = $this->returnToArgs();
|
||||
@ -1164,7 +1167,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return array two elements: action, other args
|
||||
*/
|
||||
|
||||
function returnToArgs()
|
||||
{
|
||||
$action = $this->trimmed('action');
|
||||
@ -1271,7 +1273,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return array Feed object to show in head and links
|
||||
*/
|
||||
|
||||
function getFeeds()
|
||||
{
|
||||
return null;
|
||||
@ -1282,7 +1283,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return Design a design object to use
|
||||
*/
|
||||
|
||||
function getDesign()
|
||||
{
|
||||
return Design::siteDesign();
|
||||
@ -1296,7 +1296,6 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
// XXX: Finding this type of check with the same message about 50 times.
|
||||
// Possible to refactor?
|
||||
function checkSessionToken()
|
||||
@ -1304,6 +1303,7 @@ class Action extends HTMLOutputter // lawsuit
|
||||
// CSRF protection
|
||||
$token = $this->trimmed('token');
|
||||
if (empty($token) || $token != common_session_token()) {
|
||||
// TRANS: Client error text when there is a problem with the session token.
|
||||
$this->clientError(_('There was a problem with your session token.'));
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class Activity
|
||||
{
|
||||
const SPEC = 'http://activitystrea.ms/spec/1.0/';
|
||||
@ -108,7 +107,6 @@ class Activity
|
||||
* @param DOMElement $entry Atom entry to poke at
|
||||
* @param DOMElement $feed Atom feed, for context
|
||||
*/
|
||||
|
||||
function __construct($entry = null, $feed = null)
|
||||
{
|
||||
if (is_null($entry)) {
|
||||
@ -133,6 +131,7 @@ class Activity
|
||||
$entry->localName == 'item') {
|
||||
$this->_fromRssItem($entry, $feed);
|
||||
} else {
|
||||
// Low level exception. No need for i18n.
|
||||
throw new Exception("Unknown DOM element: {$entry->namespaceURI} {$entry->localName}");
|
||||
}
|
||||
}
|
||||
@ -313,13 +312,12 @@ class Activity
|
||||
*
|
||||
* @return DOMElement Atom entry
|
||||
*/
|
||||
|
||||
function toAtomEntry()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
function asString($namespace=false)
|
||||
function asString($namespace=false, $author=true)
|
||||
{
|
||||
$xs = new XMLStringer(true);
|
||||
|
||||
@ -338,7 +336,7 @@ class Activity
|
||||
|
||||
$xs->element('id', null, $this->id);
|
||||
$xs->element('title', null, $this->title);
|
||||
$xs->element('published', null, common_date_iso8601($this->time));
|
||||
$xs->element('published', null, self::iso8601Date($this->time));
|
||||
$xs->element('content', array('type' => 'html'), $this->content);
|
||||
|
||||
if (!empty($this->summary)) {
|
||||
@ -353,13 +351,15 @@ class Activity
|
||||
|
||||
// XXX: add context
|
||||
|
||||
$xs->elementStart('author');
|
||||
$xs->element('uri', array(), $this->actor->id);
|
||||
if ($this->actor->title) {
|
||||
$xs->element('name', array(), $this->actor->title);
|
||||
if ($author) {
|
||||
$xs->elementStart('author');
|
||||
$xs->element('uri', array(), $this->actor->id);
|
||||
if ($this->actor->title) {
|
||||
$xs->element('name', array(), $this->actor->title);
|
||||
}
|
||||
$xs->elementEnd('author');
|
||||
$xs->raw($this->actor->asString('activity:actor'));
|
||||
}
|
||||
$xs->elementEnd('author');
|
||||
$xs->raw($this->actor->asString('activity:actor'));
|
||||
|
||||
$xs->element('activity:verb', null, $this->verb);
|
||||
|
||||
@ -386,5 +386,12 @@ class Activity
|
||||
{
|
||||
return ActivityUtils::child($element, $tag, $namespace);
|
||||
}
|
||||
}
|
||||
|
||||
static function iso8601Date($tm)
|
||||
{
|
||||
$dateStr = date('d F Y H:i:s', $tm);
|
||||
$d = new DateTime($dateStr, new DateTimeZone('UTC'));
|
||||
$d->setTimezone(new DateTimeZone(common_timezone()));
|
||||
return $d->format('c');
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +54,12 @@ class ActivityContext
|
||||
const MENTIONED = 'mentioned';
|
||||
const CONVERSATION = 'ostatus:conversation';
|
||||
|
||||
function __construct($element)
|
||||
function __construct($element = null)
|
||||
{
|
||||
if (empty($element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$replyToEl = ActivityUtils::child($element, self::INREPLYTO, self::THR);
|
||||
|
||||
if (!empty($replyToEl)) {
|
||||
@ -73,7 +77,6 @@ class ActivityContext
|
||||
|
||||
$attention = array();
|
||||
for ($i = 0; $i < $links->length; $i++) {
|
||||
|
||||
$link = $links->item($i);
|
||||
|
||||
$linkRel = $link->getAttribute(ActivityUtils::REL);
|
||||
|
@ -49,7 +49,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ActivityObject
|
||||
{
|
||||
const ARTICLE = 'http://activitystrea.ms/schema/1.0/article';
|
||||
@ -116,7 +115,6 @@ class ActivityObject
|
||||
*
|
||||
* @param DOMElement $element DOM thing to turn into an Activity thing
|
||||
*/
|
||||
|
||||
function __construct($element = null)
|
||||
{
|
||||
if (empty($element)) {
|
||||
@ -168,7 +166,6 @@ class ActivityObject
|
||||
ActivityObject::MEDIA_DESCRIPTION,
|
||||
Activity::MEDIA
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +201,7 @@ class ActivityObject
|
||||
|
||||
$title = ActivityUtils::childHtmlContent($element, self::TITLE);
|
||||
|
||||
$this->title = html_entity_decode(strip_tags($title));
|
||||
$this->title = html_entity_decode(strip_tags($title), ENT_QUOTES, 'UTF-8');
|
||||
|
||||
$this->source = $this->_getSource($element);
|
||||
|
||||
@ -217,8 +214,7 @@ class ActivityObject
|
||||
}
|
||||
}
|
||||
|
||||
// @fixme rationalize with Activity::_fromRssItem()
|
||||
|
||||
// @todo FIXME: rationalize with Activity::_fromRssItem()
|
||||
private function _fromRssItem($item)
|
||||
{
|
||||
$this->title = ActivityUtils::childContent($item, ActivityObject::TITLE, Activity::RSS);
|
||||
@ -418,7 +414,6 @@ class ActivityObject
|
||||
);
|
||||
|
||||
foreach ($sizes as $size) {
|
||||
|
||||
$alink = null;
|
||||
$avatar = $profile->getAvatar($size);
|
||||
|
||||
@ -430,6 +425,17 @@ class ActivityObject
|
||||
$alink->height = $size;
|
||||
$alink->width = $size;
|
||||
$alink->url = Avatar::defaultImage($size);
|
||||
|
||||
if ($size == AVATAR_PROFILE_SIZE) {
|
||||
// Hack for Twitter import: we don't have a 96x96 image,
|
||||
// but we do have a 73x73 image. For now, fake it with that.
|
||||
$avatar = $profile->getAvatar(73);
|
||||
if ($avatar) {
|
||||
$alink = AvatarLink::fromAvatar($avatar);
|
||||
$alink->height= $size;
|
||||
$alink->width = $size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$object->avatarLinks[] = $alink;
|
||||
|
@ -46,7 +46,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ActivityUtils
|
||||
{
|
||||
const ATOM = 'http://www.w3.org/2005/Atom';
|
||||
@ -66,7 +65,6 @@ class ActivityUtils
|
||||
*
|
||||
* @return string related link, if any
|
||||
*/
|
||||
|
||||
static function getPermalink($element)
|
||||
{
|
||||
return self::getLink($element, 'alternate', 'text/html');
|
||||
@ -79,19 +77,16 @@ class ActivityUtils
|
||||
*
|
||||
* @return string related link, if any
|
||||
*/
|
||||
|
||||
static function getLink(DOMNode $element, $rel, $type=null)
|
||||
{
|
||||
$els = $element->childNodes;
|
||||
|
||||
foreach ($els as $link) {
|
||||
|
||||
if (!($link instanceof DOMElement)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($link->localName == self::LINK && $link->namespaceURI == self::ATOM) {
|
||||
|
||||
$linkRel = $link->getAttribute(self::REL);
|
||||
$linkType = $link->getAttribute(self::TYPE);
|
||||
|
||||
@ -112,7 +107,6 @@ class ActivityUtils
|
||||
|
||||
foreach ($els as $link) {
|
||||
if ($link->localName == self::LINK && $link->namespaceURI == self::ATOM) {
|
||||
|
||||
$linkRel = $link->getAttribute(self::REL);
|
||||
$linkType = $link->getAttribute(self::TYPE);
|
||||
|
||||
@ -135,7 +129,6 @@ class ActivityUtils
|
||||
*
|
||||
* @return DOMElement found element or null
|
||||
*/
|
||||
|
||||
static function child(DOMNode $element, $tag, $namespace=self::ATOM)
|
||||
{
|
||||
$els = $element->childNodes;
|
||||
@ -160,7 +153,6 @@ class ActivityUtils
|
||||
*
|
||||
* @return string content of the child
|
||||
*/
|
||||
|
||||
static function childContent(DOMNode $element, $tag, $namespace=self::ATOM)
|
||||
{
|
||||
$el = self::child($element, $tag, $namespace);
|
||||
@ -194,7 +186,6 @@ class ActivityUtils
|
||||
* @todo handle embedded XML mime types
|
||||
* @todo handle base64-encoded non-XML and non-text mime types
|
||||
*/
|
||||
|
||||
static function getContent($element)
|
||||
{
|
||||
return self::childHtmlContent($element, self::CONTENT, self::ATOM);
|
||||
@ -205,6 +196,7 @@ class ActivityUtils
|
||||
$src = $el->getAttribute(self::SRC);
|
||||
|
||||
if (!empty($src)) {
|
||||
// TRANS: Client exception thrown when there is no source attribute.
|
||||
throw new ClientException(_("Can't handle remote content yet."));
|
||||
}
|
||||
|
||||
@ -241,10 +233,12 @@ class ActivityUtils
|
||||
return trim($text);
|
||||
} else if (in_array($type, array('text/xml', 'application/xml')) ||
|
||||
preg_match('#(+|/)xml$#', $type)) {
|
||||
// TRANS: Client exception thrown when there embedded XML content is found that cannot be processed yet.
|
||||
throw new ClientException(_("Can't handle embedded XML content yet."));
|
||||
} else if (strncasecmp($type, 'text/', 5)) {
|
||||
return $el->textContent;
|
||||
} else {
|
||||
// TRANS: Client exception thrown when base64 encoded content is found that cannot be processed yet.
|
||||
throw new ClientException(_("Can't handle embedded Base64 content yet."));
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,6 @@ if (!defined('STATUSNET')) {
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPLv3
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ActivityVerb
|
||||
{
|
||||
const POST = 'http://activitystrea.ms/schema/1.0/post';
|
||||
|
@ -45,7 +45,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
|
||||
*
|
||||
* @see Form
|
||||
*/
|
||||
|
||||
class AdminForm extends Form
|
||||
{
|
||||
/**
|
||||
@ -59,7 +58,6 @@ class AdminForm extends Form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function input($setting, $title, $instructions, $section='site')
|
||||
{
|
||||
$this->out->input($setting, $title, $this->value($setting, $section), $instructions);
|
||||
@ -73,7 +71,6 @@ class AdminForm extends Form
|
||||
*
|
||||
* @return string param value if posted, or current config value
|
||||
*/
|
||||
|
||||
function value($setting, $main='site')
|
||||
{
|
||||
$value = $this->out->trimmed($setting);
|
||||
@ -82,5 +79,4 @@ class AdminForm extends Form
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ if (!defined('STATUSNET')) {
|
||||
*
|
||||
* @todo Find some commonalities with SettingsAction and combine
|
||||
*/
|
||||
|
||||
class AdminPanelAction extends Action
|
||||
{
|
||||
var $success = true;
|
||||
@ -61,7 +60,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return boolean success flag
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -124,7 +122,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
@ -155,7 +152,6 @@ class AdminPanelAction extends Action
|
||||
* @return void
|
||||
* @see AdminPanelNav
|
||||
*/
|
||||
|
||||
function showLocalNav()
|
||||
{
|
||||
$nav = new AdminPanelNav($this);
|
||||
@ -169,7 +165,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$this->showForm();
|
||||
@ -199,7 +194,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showPageNotice()
|
||||
{
|
||||
if ($this->msg) {
|
||||
@ -222,7 +216,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showForm()
|
||||
{
|
||||
// TRANS: Client error message.
|
||||
@ -239,7 +232,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function getInstructions()
|
||||
{
|
||||
return '';
|
||||
@ -252,7 +244,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function saveSettings()
|
||||
{
|
||||
// TRANS: Client error message
|
||||
@ -267,7 +258,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @return mixed $result false if something didn't work
|
||||
*/
|
||||
|
||||
function deleteSetting($section, $setting)
|
||||
{
|
||||
$config = new Config();
|
||||
@ -314,7 +304,6 @@ class AdminPanelAction extends Action
|
||||
*
|
||||
* @see Widget
|
||||
*/
|
||||
|
||||
class AdminPanelNav extends Widget
|
||||
{
|
||||
var $action = null;
|
||||
@ -324,7 +313,6 @@ class AdminPanelNav extends Widget
|
||||
*
|
||||
* @param Action $action current action, used for output
|
||||
*/
|
||||
|
||||
function __construct($action=null)
|
||||
{
|
||||
parent::__construct($action);
|
||||
@ -336,7 +324,6 @@ class AdminPanelNav extends Widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function show()
|
||||
{
|
||||
$action_name = $this->action->trimmed('action');
|
||||
@ -409,6 +396,14 @@ class AdminPanelNav extends Widget
|
||||
$menu_title, $action_name == 'snapshotadminpanel', 'nav_snapshot_admin_panel');
|
||||
}
|
||||
|
||||
if (AdminPanelAction::canAdmin('license')) {
|
||||
// TRANS: Menu item title/tooltip
|
||||
$menu_title = _('Set site license');
|
||||
// TRANS: Menu item for site administration
|
||||
$this->out->menuItem(common_local_url('licenseadminpanel'), _('License'),
|
||||
$menu_title, $action_name == 'licenseadminpanel', 'nav_license_admin_panel');
|
||||
}
|
||||
|
||||
if (AdminPanelAction::canAdmin('plugins')) {
|
||||
// TRANS: Menu item title/tooltip
|
||||
$menu_title = _('Plugins configuration');
|
||||
@ -421,5 +416,4 @@ class AdminPanelNav extends Widget
|
||||
}
|
||||
$this->action->elementEnd('ul');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -114,7 +114,6 @@ class ApiValidationException extends Exception { }
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ApiAction extends Action
|
||||
{
|
||||
const READ_ONLY = 1;
|
||||
@ -141,7 +140,6 @@ class ApiAction extends Action
|
||||
*
|
||||
* @return boolean false if user doesn't exist
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
StatusNet::setApi(true); // reduce exception reports to aid in debugging
|
||||
@ -174,7 +172,6 @@ class ApiAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
@ -467,7 +464,6 @@ class ApiAction extends Action
|
||||
$entry = array();
|
||||
|
||||
if (Event::handle('StartRssEntryArray', array($notice, &$entry))) {
|
||||
|
||||
$profile = $notice->getProfile();
|
||||
|
||||
// We trim() to avoid extraneous whitespace in the output
|
||||
@ -557,7 +553,6 @@ class ApiAction extends Action
|
||||
$notifications = false;
|
||||
|
||||
if ($source->isSubscribed($target)) {
|
||||
|
||||
$sub = Subscription::pkeyGet(array('subscriber' =>
|
||||
$source->id, 'subscribed' => $target->id));
|
||||
|
||||
@ -743,7 +738,6 @@ class ApiAction extends Action
|
||||
|
||||
function showXmlTimeline($notice)
|
||||
{
|
||||
|
||||
$this->initDocument('xml');
|
||||
$this->elementStart('statuses', array('type' => 'array',
|
||||
'xmlns:statusnet' => 'http://status.net/schema/api/1/'));
|
||||
@ -768,7 +762,6 @@ class ApiAction extends Action
|
||||
|
||||
function showRssTimeline($notice, $title, $link, $subtitle, $suplink = null, $logo = null, $self = null)
|
||||
{
|
||||
|
||||
$this->initDocument('rss');
|
||||
|
||||
$this->element('title', null, $title);
|
||||
@ -824,7 +817,6 @@ class ApiAction extends Action
|
||||
|
||||
function showAtomTimeline($notice, $title, $id, $link, $subtitle=null, $suplink=null, $selfuri=null, $logo=null)
|
||||
{
|
||||
|
||||
$this->initDocument('atom');
|
||||
|
||||
$this->element('title', null, $title);
|
||||
@ -864,12 +856,10 @@ class ApiAction extends Action
|
||||
}
|
||||
|
||||
$this->endDocument('atom');
|
||||
|
||||
}
|
||||
|
||||
function showRssGroups($group, $title, $link, $subtitle)
|
||||
{
|
||||
|
||||
$this->initDocument('rss');
|
||||
|
||||
$this->element('title', null, $title);
|
||||
@ -1017,7 +1007,6 @@ class ApiAction extends Action
|
||||
|
||||
function showAtomGroups($group, $title, $id, $link, $subtitle=null, $selfuri=null)
|
||||
{
|
||||
|
||||
$this->initDocument('atom');
|
||||
|
||||
$this->element('title', null, common_xml_safe_str($title));
|
||||
@ -1048,7 +1037,6 @@ class ApiAction extends Action
|
||||
|
||||
function showJsonTimeline($notice)
|
||||
{
|
||||
|
||||
$this->initDocument('json');
|
||||
|
||||
$statuses = array();
|
||||
@ -1074,7 +1062,6 @@ class ApiAction extends Action
|
||||
|
||||
function showJsonGroups($group)
|
||||
{
|
||||
|
||||
$this->initDocument('json');
|
||||
|
||||
$groups = array();
|
||||
@ -1120,7 +1107,6 @@ class ApiAction extends Action
|
||||
|
||||
function showTwitterXmlUsers($user)
|
||||
{
|
||||
|
||||
$this->initDocument('xml');
|
||||
$this->elementStart('users', array('type' => 'array',
|
||||
'xmlns:statusnet' => 'http://status.net/schema/api/1/'));
|
||||
@ -1143,7 +1129,6 @@ class ApiAction extends Action
|
||||
|
||||
function showJsonUsers($user)
|
||||
{
|
||||
|
||||
$this->initDocument('json');
|
||||
|
||||
$users = array();
|
||||
@ -1228,7 +1213,6 @@ class ApiAction extends Action
|
||||
$this->endXML();
|
||||
break;
|
||||
case 'json':
|
||||
|
||||
// Check for JSONP callback
|
||||
if (isset($this->callback)) {
|
||||
print ')';
|
||||
@ -1374,7 +1358,6 @@ class ApiAction extends Action
|
||||
function getTargetUser($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
|
||||
// Twitter supports these other ways of passing the user ID
|
||||
if (is_numeric($this->arg('id'))) {
|
||||
return User::staticGet($this->arg('id'));
|
||||
@ -1485,7 +1468,6 @@ class ApiAction extends Action
|
||||
*/
|
||||
function arg($key, $def=null)
|
||||
{
|
||||
|
||||
// XXX: Do even more input validation/scrubbing?
|
||||
|
||||
if (array_key_exists($key, $this->args)) {
|
||||
@ -1552,5 +1534,4 @@ class ApiAction extends Action
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,7 +68,6 @@ require_once INSTALLDIR . '/lib/apioauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ApiAuthAction extends ApiAction
|
||||
{
|
||||
var $auth_user_nickname = null;
|
||||
@ -83,7 +82,6 @@ class ApiAuthAction extends ApiAction
|
||||
* @return boolean success flag
|
||||
*
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -126,7 +124,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return mixed the OAuthRequest or false
|
||||
*/
|
||||
|
||||
function getOAuthRequest()
|
||||
{
|
||||
ApiOauthAction::cleanRequest();
|
||||
@ -154,7 +151,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function checkOAuthRequest($request)
|
||||
{
|
||||
$datastore = new ApiStatusNetOAuthDataStore();
|
||||
@ -164,7 +160,6 @@ class ApiAuthAction extends ApiAction
|
||||
$server->add_signature_method($hmac_method);
|
||||
|
||||
try {
|
||||
|
||||
$server->verify_request($request);
|
||||
|
||||
$consumer = $request->get_parameter('oauth_consumer_key');
|
||||
@ -176,7 +171,8 @@ class ApiAuthAction extends ApiAction
|
||||
common_log(LOG_WARNING,
|
||||
'Couldn\'t find the OAuth app for consumer key: ' .
|
||||
$consumer);
|
||||
throw new OAuthException('No application for that consumer key.');
|
||||
// TRANS: OAuth exception thrown when no application is found for a given consumer key.
|
||||
throw new OAuthException(_('No application for that consumer key.'));
|
||||
}
|
||||
|
||||
// set the source attr
|
||||
@ -186,19 +182,15 @@ class ApiAuthAction extends ApiAction
|
||||
$appUser = Oauth_application_user::staticGet('token', $access_token);
|
||||
|
||||
if (!empty($appUser)) {
|
||||
|
||||
// If access_type == 0 we have either a request token
|
||||
// or a bad / revoked access token
|
||||
|
||||
if ($appUser->access_type != 0) {
|
||||
|
||||
// Set the access level for the api call
|
||||
|
||||
$this->access = ($appUser->access_type & Oauth_application::$writeAccess)
|
||||
? self::READ_WRITE : self::READ_ONLY;
|
||||
|
||||
// Set the auth user
|
||||
|
||||
if (Event::handle('StartSetApiUser', array(&$user))) {
|
||||
$this->auth_user = User::staticGet('id', $appUser->profile_id);
|
||||
Event::handle('EndSetApiUser', array($user));
|
||||
@ -216,13 +208,13 @@ class ApiAuthAction extends ApiAction
|
||||
'read-write' : 'read-only'
|
||||
));
|
||||
} else {
|
||||
throw new OAuthException('Bad access token.');
|
||||
// TRANS: OAuth exception given when an incorrect access token was given for a user.
|
||||
throw new OAuthException(_('Bad access token.'));
|
||||
}
|
||||
} else {
|
||||
|
||||
// Also should not happen
|
||||
|
||||
throw new OAuthException('No user for that token.');
|
||||
// TRANS: OAuth exception given when no user was found for a given token (no token was found).
|
||||
throw new OAuthException(_('No user for that token.'));
|
||||
}
|
||||
|
||||
} catch (OAuthException $e) {
|
||||
@ -237,7 +229,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return boolean true
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
return true;
|
||||
@ -249,7 +240,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
|
||||
function checkBasicAuthUser($required = true)
|
||||
{
|
||||
$this->basicAuthProcessHeader();
|
||||
@ -264,8 +254,8 @@ class ApiAuthAction extends ApiAction
|
||||
header('WWW-Authenticate: Basic realm="' . $realm . '"');
|
||||
|
||||
// show error if the user clicks 'cancel'
|
||||
|
||||
$this->clientError("Could not authenticate you.", 401, $this->format);
|
||||
// TRANS: Client error thrown when authentication fails becaus a user clicked "Cancel".
|
||||
$this->clientError(_("Could not authenticate you."), 401, $this->format);
|
||||
exit;
|
||||
|
||||
} else {
|
||||
@ -283,13 +273,11 @@ class ApiAuthAction extends ApiAction
|
||||
}
|
||||
|
||||
// By default, basic auth users have rw access
|
||||
|
||||
$this->access = self::READ_WRITE;
|
||||
|
||||
if (empty($this->auth_user) && ($required || isset($_SERVER['PHP_AUTH_USER']))) {
|
||||
|
||||
// basic authentication failed
|
||||
|
||||
list($proxy, $ip) = common_client_ip();
|
||||
|
||||
$msg = sprintf( 'Failed API auth attempt, nickname = %1$s, ' .
|
||||
@ -298,7 +286,8 @@ class ApiAuthAction extends ApiAction
|
||||
$proxy,
|
||||
$ip);
|
||||
common_log(LOG_WARNING, $msg);
|
||||
$this->clientError("Could not authenticate you.", 401, $this->format);
|
||||
// TRANS: Client error thrown when authentication fails.
|
||||
$this->clientError(_("Could not authenticate you."), 401, $this->format);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -310,7 +299,6 @@ class ApiAuthAction extends ApiAction
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function basicAuthProcessHeader()
|
||||
{
|
||||
$authHeaders = array('AUTHORIZATION',
|
||||
@ -332,7 +320,6 @@ class ApiAuthAction extends ApiAction
|
||||
|
||||
// Decode the HTTP_AUTHORIZATION header on php-cgi server self
|
||||
// on fcgid server the header name is AUTHORIZATION
|
||||
|
||||
$auth_hash = base64_decode(substr($authorization_header, 6));
|
||||
list($this->auth_user_nickname,
|
||||
$this->auth_user_password) = explode(':', $auth_hash);
|
||||
|
@ -30,7 +30,7 @@
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author mEDI <medi@milaro.net>
|
||||
* @author Sarven Capadisli <csarven@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @author Zach Copley <zach@status.net>
|
||||
* @copyright 2009 StatusNet, Inc.
|
||||
* @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
@ -60,10 +60,8 @@ require_once INSTALLDIR.'/lib/apiauth.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ApiBareAuthAction extends ApiAuthAction
|
||||
{
|
||||
|
||||
/**
|
||||
* Take arguments for running
|
||||
*
|
||||
@ -72,7 +70,6 @@ class ApiBareAuthAction extends ApiAuthAction
|
||||
* @return boolean success flag
|
||||
*
|
||||
*/
|
||||
|
||||
function prepare($args)
|
||||
{
|
||||
parent::prepare($args);
|
||||
@ -84,18 +81,15 @@ class ApiBareAuthAction extends ApiAuthAction
|
||||
*
|
||||
* @return boolean true or false
|
||||
*/
|
||||
|
||||
function requiresAuth()
|
||||
{
|
||||
// If the site is "private", all API methods except statusnet/config
|
||||
// need authentication
|
||||
|
||||
if (common_config('site', 'private')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// check whether a user has been specified somehow
|
||||
|
||||
$id = $this->arg('id');
|
||||
$user_id = $this->arg('user_id');
|
||||
$screen_name = $this->arg('screen_name');
|
||||
@ -106,5 +100,4 @@ class ApiBareAuthAction extends ApiAuthAction
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,6 @@ require_once INSTALLDIR . '/lib/apioauthstore.php';
|
||||
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||
* @link http://status.net/
|
||||
*/
|
||||
|
||||
class ApiOauthAction extends Action
|
||||
{
|
||||
/**
|
||||
@ -52,7 +51,6 @@ class ApiOauthAction extends Action
|
||||
*
|
||||
* @return boolean false
|
||||
*/
|
||||
|
||||
function isReadOnly($args)
|
||||
{
|
||||
return false;
|
||||
@ -73,7 +71,6 @@ class ApiOauthAction extends Action
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function handle($args)
|
||||
{
|
||||
parent::handle($args);
|
||||
@ -83,7 +80,6 @@ class ApiOauthAction extends Action
|
||||
static function cleanRequest()
|
||||
{
|
||||
// kill evil effects of magical slashing
|
||||
|
||||
if (get_magic_quotes_gpc() == 1) {
|
||||
$_POST = array_map('stripslashes', $_POST);
|
||||
$_GET = array_map('stripslashes', $_GET);
|
||||
@ -93,7 +89,6 @@ class ApiOauthAction extends Action
|
||||
|
||||
// XXX: should we strip anything else? Or alternatively
|
||||
// only allow a known list of params?
|
||||
|
||||
unset($_GET['p']);
|
||||
unset($_POST['p']);
|
||||
}
|
||||
@ -118,5 +113,4 @@ class ApiOauthAction extends Action
|
||||
return ($url . '&' . $k . '=' . $v);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ require_once INSTALLDIR . '/lib/oauthstore.php';
|
||||
|
||||
class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
{
|
||||
|
||||
function lookup_consumer($consumer_key)
|
||||
{
|
||||
$con = Consumer::staticGet('consumer_key', $consumer_key);
|
||||
@ -39,7 +38,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
function getAppByRequestToken($token_key)
|
||||
{
|
||||
// Look up the full req tokenx
|
||||
|
||||
$req_token = $this->lookup_token(null,
|
||||
'request',
|
||||
$token_key);
|
||||
@ -50,7 +48,6 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
}
|
||||
|
||||
// Look up the full Token
|
||||
|
||||
$token = new Token();
|
||||
$token->tok = $req_token->key;
|
||||
$result = $token->find(true);
|
||||
@ -150,10 +147,8 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
}
|
||||
|
||||
// Okay, good
|
||||
|
||||
return new OAuthToken($at->tok, $at->secret);
|
||||
}
|
||||
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@ -172,19 +167,20 @@ class ApiStatusNetOAuthDataStore extends StatusNetOAuthDataStore
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function revoke_token($token_key, $type = 0) {
|
||||
$rt = new Token();
|
||||
$rt->tok = $token_key;
|
||||
$rt->type = $type;
|
||||
$rt->state = 0;
|
||||
|
||||
if (!$rt->find(true)) {
|
||||
throw new Exception('Tried to revoke unknown token');
|
||||
// TRANS: Exception thrown when an attempt is made to revoke an unknown token.
|
||||
throw new Exception(_('Tried to revoke unknown token.'));
|
||||
}
|
||||
|
||||
if (!$rt->delete()) {
|
||||
throw new Exception('Failed to delete revoked token');
|
||||
// TRANS: Exception thrown when an attempt is made to remove a revoked token.
|
||||
throw new Exception(_('Failed to delete revoked token.'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user