[DATABASE] Start transactions with START TRANSACTION

"BEGIN" is non-standard and unnecessary.
This commit is contained in:
Alexei Sorokin
2020-06-08 12:25:01 +03:00
committed by Diogo Peralta Cordeiro
parent 6ea0d441cd
commit 9ac632ca2d
36 changed files with 1588 additions and 1397 deletions

View File

@@ -1,44 +1,38 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* StatusNet, the distributed open-source microblogging tool
*
* Admin panel for plugin to use bit.ly URL shortening services.
*
* 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
* @package GNUsocial
* @author Brion Vibber <brion@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/
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('STATUSNET')) {
exit(1);
}
defined('GNUSOCIAL') || die();
/**
* Administer global bit.ly URL shortener settings
*
* @category Admin
* @package StatusNet
* @author Brion Vibber <brion@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/
* @category Admin
* @package GNUsocial
* @author Brion Vibber <brion@status.net>
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class BitlyadminpanelAction extends AdminPanelAction
{
@@ -47,7 +41,7 @@ class BitlyadminpanelAction extends AdminPanelAction
*
* @return string page title
*/
function title()
public function title()
{
// TRANS: Title of administration panel.
return _m('bit.ly URL shortening');
@@ -58,7 +52,7 @@ class BitlyadminpanelAction extends AdminPanelAction
*
* @return string instructions
*/
function getInstructions()
public function getInstructions()
{
// TRANS: Instructions for administration panel.
// TRANS: This message contains Markdown links in the form [decsription](link).
@@ -73,7 +67,7 @@ class BitlyadminpanelAction extends AdminPanelAction
*
* @return void
*/
function showForm()
public function showForm()
{
$form = new BitlyAdminPanelForm($this);
$form->show();
@@ -85,7 +79,7 @@ class BitlyadminpanelAction extends AdminPanelAction
*
* @return void
*/
function saveSettings()
public function saveSettings()
{
static $settings = array(
'bitly' => array('default_login', 'default_apikey')
@@ -108,7 +102,7 @@ class BitlyadminpanelAction extends AdminPanelAction
$config = new Config();
$config->query('BEGIN');
$config->query('START TRANSACTION');
foreach ($settings as $section => $parts) {
foreach ($parts as $setting) {
@@ -121,7 +115,7 @@ class BitlyadminpanelAction extends AdminPanelAction
return;
}
function validate(&$values)
public function validate(&$values)
{
// Validate consumer key and secret (can't be too long)
@@ -148,7 +142,7 @@ class BitlyAdminPanelForm extends AdminForm
*
* @return int ID of the form
*/
function id()
public function id()
{
return 'bitlyadminpanel';
}
@@ -158,7 +152,7 @@ class BitlyAdminPanelForm extends AdminForm
*
* @return string class of the form
*/
function formClass()
public function formClass()
{
return 'form_settings';
}
@@ -168,7 +162,7 @@ class BitlyAdminPanelForm extends AdminForm
*
* @return string URL of the action
*/
function action()
public function action()
{
return common_local_url('bitlyadminpanel');
}
@@ -178,27 +172,33 @@ class BitlyAdminPanelForm extends AdminForm
*
* @return void
*/
function formData()
public function formData()
{
$this->out->elementStart(
'fieldset',
array('id' => 'settings_bitly')
);
// TRANS: Fieldset legend in administration panel for bit.ly username and API key.
$this->out->element('legend', null, _m('LEGEND','Credentials'));
$this->out->element('legend', null, _m('LEGEND', 'Credentials'));
// Do we have global defaults to fall back on?
$login = $apiKey = false;
Event::handle('BitlyDefaultCredentials', array(&$login, &$apiKey));
$haveGlobalDefaults = ($login && $apiKey);
if ($login && $apiKey) {
$this->out->element('p', 'form_guide',
$this->out->element(
'p',
'form_guide',
// TRANS: Form guide in administration panel for bit.ly URL shortening.
_m('Leave these empty to use global default credentials.'));
_m('Leave these empty to use global default credentials.')
);
} else {
$this->out->element('p', 'form_guide',
$this->out->element(
'p',
'form_guide',
// TRANS: Form guide in administration panel for bit.ly URL shortening.
_m('If you leave these empty, bit.ly will be unavailable to users.'));
_m('If you leave these empty, bit.ly will be unavailable to users.')
);
}
$this->out->elementStart('ul', 'form_data');
@@ -231,14 +231,16 @@ class BitlyAdminPanelForm extends AdminForm
*
* @return void
*/
function formActions()
public function formActions()
{
$this->out->submit('submit',
// TRANS: Button text to save setting in administration panel for bit.ly URL shortening.
_m('BUTTON','Save'),
'submit',
null,
// TRANS: Button title to save setting in administration panel for bit.ly URL shortening.
_m('Save bit.ly settings'));
$this->out->submit(
'submit',
// TRANS: Button text to save setting in administration panel for bit.ly URL shortening.
_m('BUTTON', 'Save'),
'submit',
null,
// TRANS: Button title to save setting in administration panel for bit.ly URL shortening.
_m('Save bit.ly settings')
);
}
}

View File

@@ -1,20 +1,20 @@
<?php
/*
* 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/>.
*/
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
if (!defined('GNUSOCIAL')) { exit(1); }
defined('GNUSOCIAL') || die();
/**
* Table Definition for mention_url_profile
@@ -40,54 +40,59 @@ class Mention_url_profile extends Managed_DataObject
);
}
public static function fromUrl($url, $depth=0) {
public static function fromUrl($url, $depth = 0)
{
common_debug('MentionURL: trying to find a profile for ' . $url);
$url = preg_replace('#https?://#', 'https://', $url);
try {
$profile = Profile::fromUri($url);
} catch(UnknownUriException $ex) {}
} catch (UnknownUriException $ex) {}
if(!($profile instanceof Profile)) {
if (!($profile instanceof Profile)) {
$profile = self::findProfileByProfileURL($url);
}
$url = str_replace('https://', 'http://', $url);
if(!($profile instanceof Profile)) {
if (!($profile instanceof Profile)) {
try {
$profile = Profile::fromUri($url);
} catch(UnknownUriException $ex) {}
} catch (UnknownUriException $ex) {}
}
if(!($profile instanceof Profile)) {
if (!($profile instanceof Profile)) {
$profile = self::findProfileByProfileURL($url);
}
if(!($profile instanceof Profile)) {
if (!($profile instanceof Profile)) {
$hcard = mention_url_representative_hcard($url);
if(!$hcard) return null;
if (!$hcard) {
return null;
}
$mention_profile = new Mention_url_profile();
$mention_profile->query('BEGIN');
$mention_profile->query('START TRANSACTION');
$profile = new Profile();
$profile->profileurl = $hcard['url'][0];
$profile->fullname = $hcard['name'][0];
preg_match('/\/([^\/]+)\/*$/', $profile->profileurl, $matches);
if(!$hcard['nickname']) $hcard['nickname'] = array($matches[1]);
if (!$hcard['nickname']) {
$hcard['nickname'] = [$matches[1]];
}
$profile->nickname = $hcard['nickname'][0];
$profile->created = common_sql_now();
$mention_profile->profile_id = $profile->insert();
if(!$mention_profile->profile_id) {
if (!$mention_profile->profile_id) {
$mention_profile->query('ROLLBACK');
return null;
}
$mention_profile->profileurl = $profile->profileurl;
if(!$mention_profile->insert()) {
if (!$mention_profile->insert()) {
$mention_profile->query('ROLLBACK');
if($depth > 0) {
if ($depth > 0) {
return null;
} else {
return self::fromUrl($url, $depth+1);
@@ -100,9 +105,10 @@ class Mention_url_profile extends Managed_DataObject
return $profile;
}
protected static function findProfileByProfileURL($url) {
protected static function findProfileByProfileURL($url)
{
$profile = Profile::getKV('profileurl', $url);
if($profile instanceof Profile) {
if ($profile instanceof Profile) {
$mention_profile = new Mention_url_profile();
$mention_profile->profile_id = $profile->id;
$mention_profile->profileurl = $profile->profileurl;
@@ -112,7 +118,8 @@ class Mention_url_profile extends Managed_DataObject
return $profile;
}
public function getProfile() {
public function getProfile()
{
return Profile::getKV('id', $this->profile_id);
}
}

View File

@@ -1,28 +1,34 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/*
* StatusNet - the distributed open-source microblogging tool
* Copyright (C) 2009-2010, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* @package GNUsocial
* @author Brion Vibber <brion@status.net>
* @author Mikael Nordfeldth <mmn@hethane.se>
* @copyright 2009-2010 StatusNet, Inc.
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('GNUSOCIAL')) { exit(1); }
defined('GNUSOCIAL') || die();
/**
* @package OStatusPlugin
* @author Brion Vibber <brion@status.net>
* @maintainer Mikael Nordfeldth <mmn@hethane.se>
* @package OStatusPlugin
* @author Brion Vibber <brion@status.net>
* @author Mikael Nordfeldth <mmn@hethane.se>
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class Ostatus_profile extends Managed_DataObject
{
@@ -46,7 +52,7 @@ class Ostatus_profile extends Managed_DataObject
*
* @return array array of column definitions
*/
static function schemaDef()
public static function schemaDef()
{
return array(
'fields' => array(
@@ -96,7 +102,7 @@ class Ostatus_profile extends Managed_DataObject
return FeedSub::getByUri($this->feeduri);
}
static function fromProfile(Profile $profile)
public static function fromProfile(Profile $profile)
{
$oprofile = Ostatus_profile::getKV('profile_id', $profile->getID());
if (!$oprofile instanceof Ostatus_profile) {
@@ -156,11 +162,11 @@ class Ostatus_profile extends Managed_DataObject
*
* @return ActivityObject
*/
function asActivityObject()
public function asActivityObject()
{
if ($this->isGroup()) {
return ActivityObject::fromGroup($this->localGroup());
} else if ($this->isPeopletag()) {
} elseif ($this->isPeopletag()) {
return ActivityObject::fromPeopletag($this->localPeopletag());
} else {
return $this->localProfile()->asActivityObject();
@@ -178,12 +184,12 @@ class Ostatus_profile extends Managed_DataObject
* @param string $element one of 'actor', 'subject', 'object', 'target'
* @return string
*/
function asActivityNoun($element)
public function asActivityNoun($element)
{
if ($this->isGroup()) {
$noun = ActivityObject::fromGroup($this->localGroup());
return $noun->asString('activity:' . $element);
} else if ($this->isPeopletag()) {
} elseif ($this->isPeopletag()) {
$noun = ActivityObject::fromPeopletag($this->localPeopletag());
return $noun->asString('activity:' . $element);
} else {
@@ -195,13 +201,13 @@ class Ostatus_profile extends Managed_DataObject
/**
* @return boolean true if this is a remote group
*/
function isGroup()
public function isGroup()
{
if ($this->profile_id || $this->peopletag_id && !$this->group_id) {
return false;
} else if ($this->group_id && !$this->profile_id && !$this->peopletag_id) {
} elseif ($this->group_id && !$this->profile_id && !$this->peopletag_id) {
return true;
} else if ($this->group_id && ($this->profile_id || $this->peopletag_id)) {
} elseif ($this->group_id && ($this->profile_id || $this->peopletag_id)) {
// TRANS: Server exception. %s is a URI
throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->getUri()));
} else {
@@ -218,13 +224,13 @@ class Ostatus_profile extends Managed_DataObject
/**
* @return boolean true if this is a remote peopletag
*/
function isPeopletag()
public function isPeopletag()
{
if ($this->profile_id || $this->group_id && !$this->peopletag_id) {
return false;
} else if ($this->peopletag_id && !$this->profile_id && !$this->group_id) {
} elseif ($this->peopletag_id && !$this->profile_id && !$this->group_id) {
return true;
} else if ($this->peopletag_id && ($this->profile_id || $this->group_id)) {
} elseif ($this->peopletag_id && ($this->profile_id || $this->group_id)) {
// TRANS: Server exception. %s is a URI
throw new ServerException(sprintf(_m('Invalid ostatus_profile state: Two or more IDs set for %s.'), $this->getUri()));
} else {
@@ -260,7 +266,8 @@ class Ostatus_profile extends Managed_DataObject
* @return boolean true if subscription is removed, false if there are still subscribers to the feed
* @throws Exception of various kinds on failure.
*/
public function unsubscribe() {
public function unsubscribe()
{
return $this->garbageCollect();
}
@@ -296,7 +303,7 @@ class Ostatus_profile extends Managed_DataObject
if ($this->isGroup()) {
$members = $this->localGroup()->getMembers(0, 1);
$count = $members->N;
} else if ($this->isPeopletag()) {
} elseif ($this->isPeopletag()) {
$subscribers = $this->localPeopletag()->getSubscribers(0, 1);
$count = $subscribers->N;
} else {
@@ -334,10 +341,12 @@ class Ostatus_profile extends Managed_DataObject
return false;
}
$text = 'update';
$id = TagURI::mint('%s:%s:%s',
$verb,
$actor->getURI(),
common_date_iso8601(time()));
$id = TagURI::mint(
'%s:%s:%s',
$verb,
$actor->getURI(),
common_date_iso8601(time())
);
// @todo FIXME: Consolidate all these NS settings somewhere.
$attributes = array('xmlns' => Activity::ATOM,
@@ -421,9 +430,9 @@ class Ostatus_profile extends Managed_DataObject
$preamble = '<?xml version="1.0" encoding="UTF-8" ?' . ">\n";
if (is_string($entry)) {
return $entry;
} else if ($entry instanceof Activity) {
} elseif ($entry instanceof Activity) {
return $preamble . $entry->asString(true);
} else if ($entry instanceof Notice) {
} elseif ($entry instanceof Notice) {
return $preamble . $entry->asAtomEntry(true, true);
} else {
// TRANS: Server exception.
@@ -431,11 +440,11 @@ class Ostatus_profile extends Managed_DataObject
}
}
function getBestName()
public function getBestName()
{
if ($this->isGroup()) {
return $this->localGroup()->getBestName();
} else if ($this->isPeopletag()) {
} elseif ($this->isPeopletag()) {
return $this->localPeopletag()->getBestName();
} else {
return $this->localProfile()->getBestName();
@@ -456,7 +465,8 @@ class Ostatus_profile extends Managed_DataObject
if ($feed->localName == 'feed' && $feed->namespaceURI == Activity::ATOM) {
$this->processAtomFeed($feed, $source);
} else if ($feed->localName == 'rss') { // @todo FIXME: Check namespace.
} elseif ($feed->localName == 'rss') {
// @todo FIXME: Check namespace.
$this->processRssFeed($feed, $source);
} else {
// TRANS: Exception.
@@ -482,7 +492,7 @@ class Ostatus_profile extends Managed_DataObject
if ($channels->length == 0) {
// TRANS: Exception.
throw new Exception(_m('RSS feed without a channel.'));
} else if ($channels->length > 1) {
} elseif ($channels->length > 1) {
common_log(LOG_WARNING, __METHOD__ . ": more than one channel in an RSS feed");
}
@@ -532,7 +542,6 @@ class Ostatus_profile extends Managed_DataObject
if (Event::handle('StartHandleFeedEntryWithProfile', array($activity, $this->localProfile(), &$notice)) &&
Event::handle('StartHandleFeedEntry', array($activity))) {
common_log(LOG_INFO, "Ignoring activity with unrecognized verb $activity->verb");
Event::handle('EndHandleFeedEntry', array($activity));
@@ -569,7 +578,7 @@ class Ostatus_profile extends Managed_DataObject
* @param array in/out &$attention_uris set of URIs, will be pruned on output
* @return array of group IDs
*/
static public function filterAttention(Profile $sender, array $attention)
public static function filterAttention(Profile $sender, array $attention)
{
common_log(LOG_DEBUG, "Original reply recipients: " . implode(', ', array_keys($attention)));
$groups = array();
@@ -617,7 +626,6 @@ class Ostatus_profile extends Managed_DataObject
// Neither a recognizable local nor remote user!
common_log(LOG_DEBUG, "Skipping reply to unrecognized profile $recipient: " . $e->getMessage());
}
}
common_log(LOG_DEBUG, "Local reply recipients: " . implode(', ', $replies));
common_log(LOG_DEBUG, "Local group recipients: " . implode(', ', $groups));
@@ -653,7 +661,7 @@ class Ostatus_profile extends Managed_DataObject
if (!$response->isOk()) {
// TRANS: Exception. %s is a profile URL.
throw new Exception(sprintf(_m('Could not reach profile page %s.'),$profile_url));
throw new Exception(sprintf(_m('Could not reach profile page %s.'), $profile_url));
}
// Check if we have a non-canonical URL
@@ -661,7 +669,6 @@ class Ostatus_profile extends Managed_DataObject
$finalUrl = $response->getEffectiveUrl();
if ($finalUrl != $profile_url) {
$hints['profileurl'] = $finalUrl;
$oprofile = self::getFromProfileURL($finalUrl);
@@ -673,8 +680,13 @@ class Ostatus_profile extends Managed_DataObject
if (in_array(
preg_replace('/\s*;.*$/', '', $response->getHeader('Content-Type')),
array('application/rss+xml', 'application/atom+xml', 'application/xml', 'text/xml'))
) {
[
'application/rss+xml',
'application/atom+xml',
'application/xml',
'text/xml',
]
)) {
$hints['feedurl'] = $response->getEffectiveUrl();
} else {
// Try to get some hCard data
@@ -718,7 +730,7 @@ class Ostatus_profile extends Managed_DataObject
}
// TRANS: Exception. %s is a URL.
throw new Exception(sprintf(_m('Could not find a feed URL for profile page %s.'),$finalUrl));
throw new Exception(sprintf(_m('Could not find a feed URL for profile page %s.'), $finalUrl));
}
/**
@@ -729,7 +741,7 @@ class Ostatus_profile extends Managed_DataObject
* @return mixed Ostatus_profile or null
* @throws OStatusShadowException for local profiles
*/
static function getFromProfileURL($profile_url)
public static function getFromProfileURL($profile_url)
{
$profile = Profile::getKV('profileurl', $profile_url);
if (!$profile instanceof Profile) {
@@ -756,7 +768,7 @@ class Ostatus_profile extends Managed_DataObject
return null;
}
static function getFromProfile(Profile $profile)
public static function getFromProfile(Profile $profile)
{
$oprofile = new Ostatus_profile();
$oprofile->profile_id = $profile->id;
@@ -804,7 +816,7 @@ class Ostatus_profile extends Managed_DataObject
if ($feedEl->tagName == 'feed') {
return self::ensureAtomFeed($feedEl, $hints);
} else if ($feedEl->tagName == 'channel') {
} elseif ($feedEl->tagName == 'channel') {
return self::ensureRssChannel($feedEl, $hints);
} else {
throw new FeedSubBadXmlException($feeduri);
@@ -877,7 +889,9 @@ class Ostatus_profile extends Managed_DataObject
// with different <author> or <dc:creator> elements, and... I dunno.
// Do something about that.
if(empty($obj)) { $obj = ActivityObject::fromRssChannel($feedEl); }
if (empty($obj)) {
$obj = ActivityObject::fromRssChannel($feedEl);
}
return self::ensureActivityObjectProfile($obj, $hints);
}
@@ -927,10 +941,12 @@ class Ostatus_profile extends Managed_DataObject
$id = $this->profile_id;
}
$imagefile = new ImageFile(null, $temp_filename);
$filename = Avatar::filename($id,
image_type_to_extension($imagefile->type),
null,
common_timestamp());
$filename = Avatar::filename(
$id,
image_type_to_extension($imagefile->type),
null,
common_timestamp()
);
rename($temp_filename, Avatar::path($filename));
} catch (Exception $e) {
unlink($temp_filename);
@@ -960,7 +976,7 @@ class Ostatus_profile extends Managed_DataObject
* @param array $hints
* @return mixed URL string or false
*/
public static function getActivityObjectAvatar(ActivityObject $object, array $hints=array())
public static function getActivityObjectAvatar(ActivityObject $object, array $hints = [])
{
if ($object->avatarLinks) {
$best = false;
@@ -976,7 +992,7 @@ class Ostatus_profile extends Managed_DataObject
}
}
return $best->url;
} else if (array_key_exists('avatar', $hints)) {
} elseif (array_key_exists('avatar', $hints)) {
return $hints['avatar'];
}
return false;
@@ -1241,9 +1257,9 @@ class Ostatus_profile extends Managed_DataObject
throw new ServerException(_m('Cannot save local profile.'));
}
}
} else if ($object->type == ActivityObject::GROUP) {
} elseif ($object->type == ActivityObject::GROUP) {
$profile = new Profile();
$profile->query('BEGIN');
$profile->query('START TRANSACTION');
$group = new User_group();
$group->uri = $homeuri;
@@ -1282,7 +1298,7 @@ class Ostatus_profile extends Managed_DataObject
}
$profile->query('COMMIT');
} else if ($object->type == ActivityObject::_LIST) {
} elseif ($object->type == ActivityObject::_LIST) {
$ptag = new Profile_list();
$ptag->uri = $homeuri;
$ptag->created = common_sql_now();
@@ -1337,7 +1353,7 @@ class Ostatus_profile extends Managed_DataObject
if ($this->isGroup()) {
$group = $this->localGroup();
self::updateGroup($group, $object, $hints);
} else if ($this->isPeopletag()) {
} elseif ($this->isPeopletag()) {
$ptag = $this->localPeopletag();
self::updatePeopletag($ptag, $object, $hints);
} else {
@@ -1373,15 +1389,15 @@ class Ostatus_profile extends Managed_DataObject
if (!empty($object->title)) {
$profile->fullname = $object->title;
} else if (array_key_exists('fullname', $hints)) {
} elseif (array_key_exists('fullname', $hints)) {
$profile->fullname = $hints['fullname'];
}
if (!empty($object->link)) {
$profile->profileurl = $object->link;
} else if (array_key_exists('profileurl', $hints)) {
} elseif (array_key_exists('profileurl', $hints)) {
$profile->profileurl = $hints['profileurl'];
} else if (common_valid_http_url($object->id)) {
} elseif (common_valid_http_url($object->id)) {
$profile->profileurl = $object->id;
}
@@ -1430,7 +1446,7 @@ class Ostatus_profile extends Managed_DataObject
if (!empty($object->link)) {
$group->mainpage = $object->link;
} else if (array_key_exists('profileurl', $hints)) {
} elseif (array_key_exists('profileurl', $hints)) {
$group->mainpage = $hints['profileurl'];
}
@@ -1446,14 +1462,15 @@ class Ostatus_profile extends Managed_DataObject
}
}
protected static function updatePeopletag($tag, ActivityObject $object, array $hints=array()) {
protected static function updatePeopletag($tag, ActivityObject $object, array $hints=array())
{
$orig = clone($tag);
$tag->tag = $object->title;
if (!empty($object->link)) {
$tag->mainpage = $object->link;
} else if (array_key_exists('profileurl', $hints)) {
} elseif (array_key_exists('profileurl', $hints)) {
$tag->mainpage = $hints['profileurl'];
}
@@ -1492,7 +1509,7 @@ class Ostatus_profile extends Managed_DataObject
if (!empty($object->poco) &&
isset($object->poco->address->formatted)) {
$location = $object->poco->address->formatted;
} else if (array_key_exists('location', $hints)) {
} elseif (array_key_exists('location', $hints)) {
$location = $hints['location'];
}
@@ -1513,7 +1530,7 @@ class Ostatus_profile extends Managed_DataObject
if (!empty($object->poco)) {
$note = $object->poco->note;
} else if (array_key_exists('bio', $hints)) {
} elseif (array_key_exists('bio', $hints)) {
$note = $hints['bio'];
}
@@ -1550,7 +1567,7 @@ class Ostatus_profile extends Managed_DataObject
// Try the profile url (like foo.example.com or example.com/user/foo)
if (!empty($object->link)) {
$profileUrl = $object->link;
} else if (!empty($hints['profileurl'])) {
} elseif (!empty($hints['profileurl'])) {
$profileUrl = $hints['profileurl'];
}
@@ -1659,8 +1676,10 @@ class Ostatus_profile extends Managed_DataObject
throw new Exception(_m('Not a valid webfinger address.'));
}
$hints = array_merge(array('webfinger' => $addr),
DiscoveryHints::fromXRD($xrd));
$hints = array_merge(
['webfinger' => $addr],
DiscoveryHints::fromXRD($xrd)
);
// If there's an Hcard, let's grab its info
if (array_key_exists('hcard', $hints)) {
@@ -1735,7 +1754,7 @@ class Ostatus_profile extends Managed_DataObject
if ($profile_id === false) {
common_log_db_error($profile, 'INSERT', __FILE__);
// TRANS: Exception. %s is a webfinger address.
throw new Exception(sprintf(_m('Could not save profile for "%s".'),$addr));
throw new Exception(sprintf(_m('Could not save profile for "%s".'), $addr));
}
$oprofile = new Ostatus_profile();
@@ -1755,7 +1774,7 @@ class Ostatus_profile extends Managed_DataObject
$profile->delete();
common_log_db_error($oprofile, 'INSERT', __FILE__);
// TRANS: Exception. %s is a webfinger address.
throw new Exception(sprintf(_m('Could not save OStatus profile for "%s".'),$addr));
throw new Exception(sprintf(_m('Could not save OStatus profile for "%s".'), $addr));
}
self::cacheSet(sprintf('ostatus_profile:webfinger:%s', $addr), $oprofile->getUri());
@@ -1763,7 +1782,7 @@ class Ostatus_profile extends Managed_DataObject
}
// TRANS: Exception. %s is a webfinger address.
throw new Exception(sprintf(_m('Could not find a valid profile for "%s".'),$addr));
throw new Exception(sprintf(_m('Could not find a valid profile for "%s".'), $addr));
}
/**
@@ -1774,20 +1793,26 @@ class Ostatus_profile extends Managed_DataObject
* @param string $rendered HTML fragment for HTML page's body
* @return File
*/
function saveHTMLFile($title, $rendered)
public function saveHTMLFile($title, $rendered)
{
$final = sprintf("<!DOCTYPE html>\n" .
'<html><head>' .
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' .
'<title>%s</title>' .
'</head>' .
'<body>%s</body></html>',
htmlspecialchars($title),
$rendered);
$final = sprintf(
<<<'END'
<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>%s</title>
</head>
<body>%s</body></html>
END,
htmlspecialchars($title),
$rendered
);
$filename = File::filename($this->localProfile(),
'ostatus', // ignored?
'text/html');
$filename = File::filename(
$this->localProfile(),
'ostatus', // ignored?
'text/html'
);
$filepath = File::path($filename);
$fileurl = File::url($filename);
@@ -1814,7 +1839,7 @@ class Ostatus_profile extends Managed_DataObject
return $file;
}
static function ensureProfileURI($uri)
public static function ensureProfileURI($uri)
{
$oprofile = null;
@@ -1842,13 +1867,15 @@ class Ostatus_profile extends Managed_DataObject
default:
// TRANS: Server exception.
// TRANS: %1$s is a protocol, %2$s is a URI.
throw new ServerException(sprintf(_m('Unrecognized URI protocol for profile: %1$s (%2$s).'),
$protocol,
$uri));
throw new ServerException(sprintf(
_m('Unrecognized URI protocol for profile: %1$s (%2$s).'),
$protocol,
$uri
));
}
} else {
// TRANS: Server exception. %s is a URI.
throw new ServerException(sprintf(_m('No URI protocol for profile: %s.'),$uri));
throw new ServerException(sprintf(_m('No URI protocol for profile: %s.'), $uri));
}
return $oprofile;
@@ -1861,9 +1888,11 @@ class Ostatus_profile extends Managed_DataObject
$oprofile = self::ensureActorProfile($activity);
if ($oprofile->isGroup() || $oprofile->isPeopletag()) {
// Groups can't post notices in StatusNet.
common_log(LOG_WARNING,
"OStatus: skipping post with group listed ".
"as author: " . $oprofile->getUri() . " in feed from " . $this->getUri());
common_log(
LOG_WARNING,
'OStatus: skipping post with group listed as author: '
. "{$oprofile->getUri()} in feed from {$this->getUri()}"
);
throw new ServerException('Activity author is a non-actor');
}
} else {
@@ -1871,9 +1900,10 @@ class Ostatus_profile extends Managed_DataObject
if (empty($actor)) {
// OK here! assume the default
} else if ($actor->id == $this->getUri() || $actor->link == $this->getUri()) {
} elseif ($actor->id == $this->getUri()
|| $actor->link == $this->getUri()) {
$this->updateFromActivityObject($actor);
} else if ($actor->id) {
} elseif ($actor->id) {
// We have an ActivityStreams actor with an explicit ID that doesn't match the feed owner.
// This isn't what we expect from mainline OStatus person feeds!
// Group feeds go down another path, with different validation...

View File

@@ -1,35 +1,30 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* StatusNet, the distributed open-source microblogging tool
*
* Complete adding an OpenID
*
* 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
* @package GNUsocial
* @author Evan Prodromou <evan@status.net>
* @copyright 2008-2009 StatusNet, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('STATUSNET')) {
exit(1);
}
defined('GNUSOCIAL') || die();
require_once INSTALLDIR.'/plugins/OpenID/openid.php';
@@ -38,11 +33,10 @@ require_once INSTALLDIR.'/plugins/OpenID/openid.php';
*
* Handle the return from an OpenID verification
*
* @category Settings
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @category Settings
* @package GNUsocial
* @author Evan Prodromou <evan@status.net>
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class FinishaddopenidAction extends Action
{
@@ -128,7 +122,7 @@ class FinishaddopenidAction extends Action
// start a transaction
$cur->query('BEGIN');
$cur->query('START TRANSACTION');
$result = oid_link_user($cur->id, $canonical, $display);

View File

@@ -104,7 +104,7 @@ class FinishsynchopenidAction extends Action
// start a transaction
$cur->query('BEGIN');
$cur->query('START TRANSACTION');
if (Event::handle('StartOpenIDUpdateUser', [$cur, $canonical, &$sreg])) {
if (!oid_update_user($cur, $sreg)) {

View File

@@ -1,44 +1,38 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* StatusNet, the distributed open-source microblogging tool
*
* OpenID bridge 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
* @package GNUsocial
* @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/
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('STATUSNET')) {
exit(1);
}
defined('GNUSOCIAL') || die();
/**
* Administer global OpenID 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/
* @category Admin
* @package GNUsocial
* @author Zach Copley <zach@status.net>
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class OpenidadminpanelAction extends AdminPanelAction
{
@@ -47,10 +41,10 @@ class OpenidadminpanelAction extends AdminPanelAction
*
* @return string page title
*/
function title()
public function title()
{
// TRANS: Title for OpenID bridge administration page.
return _m('TITLE','OpenID Settings');
return _m('TITLE', 'OpenID Settings');
}
/**
@@ -58,7 +52,7 @@ class OpenidadminpanelAction extends AdminPanelAction
*
* @return string instructions
*/
function getInstructions()
public function getInstructions()
{
// TRANS: Page instructions.
return _m('OpenID settings');
@@ -69,7 +63,7 @@ class OpenidadminpanelAction extends AdminPanelAction
*
* @return void
*/
function showForm()
public function showForm()
{
$form = new OpenIDAdminPanelForm($this);
$form->show();
@@ -81,7 +75,7 @@ class OpenidadminpanelAction extends AdminPanelAction
*
* @return void
*/
function saveSettings()
public function saveSettings()
{
static $settings = array(
'openid' => array('trusted_provider', 'required_team')
@@ -116,7 +110,7 @@ class OpenidadminpanelAction extends AdminPanelAction
$config = new Config();
$config->query('BEGIN');
$config->query('START TRANSACTION');
foreach ($settings as $section => $parts) {
foreach ($parts as $setting) {
@@ -135,7 +129,7 @@ class OpenidadminpanelAction extends AdminPanelAction
return;
}
function validate(&$values)
public function validate(&$values)
{
// Validate consumer key and secret (can't be too long)
@@ -162,7 +156,7 @@ class OpenIDAdminPanelForm extends AdminForm
*
* @return int ID of the form
*/
function id()
public function id()
{
return 'openidadminpanel';
}
@@ -172,7 +166,7 @@ class OpenIDAdminPanelForm extends AdminForm
*
* @return string class of the form
*/
function formClass()
public function formClass()
{
return 'form_settings';
}
@@ -182,7 +176,7 @@ class OpenIDAdminPanelForm extends AdminForm
*
* @return string URL of the action
*/
function action()
public function action()
{
return common_local_url('openidadminpanel');
}
@@ -196,19 +190,22 @@ class OpenIDAdminPanelForm extends AdminForm
* Make sure that the acting administrator has a valid OpenID matching,
* or more carefully warn folks.
*/
function formData()
public function formData()
{
$this->out->elementStart(
'fieldset',
array('id' => 'settings_openid')
);
// TRANS: Fieldset legend.
$this->out->element('legend', null, _m('LEGEND','Trusted provider'));
$this->out->element('p', 'form_guide',
$this->out->element('legend', null, _m('LEGEND', 'Trusted provider'));
$this->out->element(
'p',
'form_guide',
// TRANS: Form guide.
_m('By default, users are allowed to authenticate with any OpenID provider. ' .
'If you are using your own OpenID service for shared sign-in, ' .
'you can restrict access to only your own users here.'));
'you can restrict access to only your own users here.')
);
$this->out->elementStart('ul', 'form_data');
$this->li();
@@ -225,7 +222,8 @@ class OpenIDAdminPanelForm extends AdminForm
$this->li();
$this->out->checkbox(
// TRANS: Checkbox label.
'append_username', _m('Append a username to base URL'),
'append_username',
_m('Append a username to base URL'),
(bool) $this->value('append_username', 'openid'),
// TRANS: Checkbox title.
_m('Login form will show the base URL and prompt for a username to add at the end. Use when OpenID provider URL should be the profile page for individual users.'),
@@ -252,7 +250,7 @@ class OpenIDAdminPanelForm extends AdminForm
array('id' => 'settings_openid-options')
);
// TRANS: Fieldset legend.
$this->out->element('legend', null, _m('LEGEND','Options'));
$this->out->element('legend', null, _m('LEGEND', 'Options'));
$this->out->elementStart('ul', 'form_data');
@@ -260,7 +258,8 @@ class OpenIDAdminPanelForm extends AdminForm
$this->out->checkbox(
// TRANS: Checkbox label.
'openidonly', _m('Enable OpenID-only mode'),
'openidonly',
_m('Enable OpenID-only mode'),
(bool) $this->value('openidonly', 'site'),
// TRANS: Checkbox title.
_m('Require all users to login via OpenID. Warning: disables password authentication for all users!'),
@@ -278,11 +277,16 @@ class OpenIDAdminPanelForm extends AdminForm
*
* @return void
*/
function formActions()
public function formActions()
{
// TRANS: Button text to save OpenID settings.
$this->out->submit('submit', _m('BUTTON','Save'), 'submit', null,
// TRANS: Button title to save OpenID settings.
_m('Save OpenID settings.'));
$this->out->submit(
'submit',
_m('BUTTON', 'Save'),
'submit',
null,
// TRANS: Button title to save OpenID settings.
_m('Save OpenID settings.')
);
}
}

View File

@@ -59,7 +59,7 @@ class OverwriteThemeBackgroundAdminPanelAction extends AdminPanelAction
*
* @return void
*/
function showForm()
public function showForm()
{
$form = new OverwriteThemeBackgroundAdminPanelForm($this);
$form->show();
@@ -71,7 +71,7 @@ class OverwriteThemeBackgroundAdminPanelAction extends AdminPanelAction
*
* @return void
*/
function saveSettings()
public function saveSettings()
{
static $settings = [
'overwritethemebackground' => [
@@ -100,7 +100,7 @@ class OverwriteThemeBackgroundAdminPanelAction extends AdminPanelAction
$config = new Config();
$config->query('BEGIN');
$config->query('START TRANSACTION');
foreach ($settings as $section => $parts) {
foreach ($parts as $setting) {
@@ -119,7 +119,7 @@ class OverwriteThemeBackgroundAdminPanelAction extends AdminPanelAction
* @param $values
* @throws ClientException
*/
function validate(&$values)
public function validate(&$values)
{
// Validate background
if (!empty($values['overwritethemebackground']['background-image']) &&
@@ -149,7 +149,7 @@ class OverwriteThemeBackgroundAdminPanelForm extends AdminForm
*
* @return int ID of the form
*/
function id()
public function id()
{
return 'form_site_admin_panel';
}
@@ -159,7 +159,7 @@ class OverwriteThemeBackgroundAdminPanelForm extends AdminForm
*
* @return string class of the form
*/
function formClass()
public function formClass()
{
return 'form_settings';
}
@@ -169,7 +169,7 @@ class OverwriteThemeBackgroundAdminPanelForm extends AdminForm
*
* @return string URL of the action
*/
function action()
public function action()
{
return common_local_url('overwritethemebackgroundAdminPanel');
}
@@ -179,7 +179,7 @@ class OverwriteThemeBackgroundAdminPanelForm extends AdminForm
*
* @return void
*/
function formData()
public function formData()
{
$this->out->elementStart('fieldset', ['id' => 'settings_site_background']);
// TRANS: Fieldset legend for form to change background.
@@ -189,52 +189,68 @@ class OverwriteThemeBackgroundAdminPanelForm extends AdminForm
/* Background colour */
$this->li();
$this->input('background-color',
$this->input(
'background-color',
// TRANS: Field label for GNU social site background.
_m('Site background color'),
// TRANS: Title for field label for GNU social site background.
'Background color for the site (hexadecimal with #).',
'overwritethemebackground');
'overwritethemebackground'
);
$this->unli();
/* Background image */
$this->li();
$this->input('background-image',
$this->input(
'background-image',
// TRANS: Field label for GNU social site background.
_m('Site background'),
// TRANS: Title for field label for GNU social site background.
'Background for the site (full URL).',
'overwritethemebackground');
'overwritethemebackground'
);
$this->unli();
$this->li();
$this->input('sslbackground-image',
$this->input(
'sslbackground-image',
// TRANS: Field label for SSL GNU social site background.
_m('SSL background'),
// TRANS: Title for field label for SSL GNU social site background.
'Background to show on SSL pages (full URL).',
'overwritethemebackground');
'overwritethemebackground'
);
$this->unli();
/* Background repeat */
$this->li();
// TRANS: Dropdown label on site settings panel.
$this->out->dropdown('background-repeat', _m('Background repeat'),
$this->out->dropdown(
'background-repeat',
_m('Background repeat'),
// TRANS: Dropdown title on site settings panel.
['Repeat horizontally and vertically', 'Repeat Horizontally', 'Repeat Vertically', 'Don\'t repeat'], _m('repeat horizontally and/or vertically'),
false, common_config('overwritethemebackground', 'background-repeat') ?? 'repeat');
['Repeat horizontally and vertically', 'Repeat Horizontally', 'Repeat Vertically', 'Don\'t repeat'],
_m('repeat horizontally and/or vertically'),
false,
common_config('overwritethemebackground', 'background-repeat') ?? 'repeat'
);
$this->unli();
/* Background attachment */
$this->li();
// TRANS: Dropdown label on site settings panel.
$this->out->dropdown('background-attachment', _m('Background attachment'),
$this->out->dropdown(
'background-attachment',
_m('Background attachment'),
// TRANS: Dropdown title on site settings panel.
['Scroll with page', 'Stay fixed'], _m('Whether the background image should scroll or be fixed (will not scroll with the rest of the page)'),
false, common_config('overwritethemebackground', 'background-attachment') ?? 'scroll');
['Scroll with page', 'Stay fixed'],
_m('Whether the background image should scroll or be fixed (will not scroll with the rest of the page)'),
false,
common_config('overwritethemebackground', 'background-attachment') ?? 'scroll'
);
$this->unli();
/* Background position */
@@ -253,10 +269,15 @@ class OverwriteThemeBackgroundAdminPanelForm extends AdminForm
];
$this->li();
// TRANS: Dropdown label on site settings panel.
$this->out->dropdown('background-position', _m('Background position'),
$this->out->dropdown(
'background-position',
_m('Background position'),
// TRANS: Dropdown title on site settings panel.
$background_position_options, _m('Sets the starting position of a background image'),
false, common_config('overwritethemebackground', 'background-attachment') ?? 'initial');
$background_position_options,
_m('Sets the starting position of a background image'),
false,
common_config('overwritethemebackground', 'background-attachment') ?? 'initial'
);
$this->unli();
$this->out->elementEnd('ul');
@@ -268,14 +289,16 @@ class OverwriteThemeBackgroundAdminPanelForm extends AdminForm
*
* @return void
*/
function formActions()
public function formActions()
{
$this->out->submit('submit',
$this->out->submit(
'submit',
// TRANS: Button text for saving site settings.
_m('BUTTON', 'Save'),
'submit',
null,
// TRANS: Button title for saving site settings.
_m('Save the site settings.'));
_m('Save the site settings.')
);
}
}

View File

@@ -1,44 +1,38 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* StatusNet, the distributed open-source microblogging tool
*
* Sitemap 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 Sitemap
* @package StatusNet
* @package GNUsocial
* @author Evan Prodromou <evan@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/
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('STATUSNET')) {
exit(1);
}
defined('GNUSOCIAL') || die();
/**
* Administer sitemap settings
*
* @category Sitemap
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://status.net/
* @category Sitemap
* @package GNUsocial
* @author Evan Prodromou <evan@status.net>
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class SitemapadminpanelAction extends AdminPanelAction
{
@@ -47,7 +41,7 @@ class SitemapadminpanelAction extends AdminPanelAction
*
* @return string page title
*/
function title()
public function title()
{
// TRANS: Title for sitemap.
return _m('Sitemap');
@@ -58,7 +52,7 @@ class SitemapadminpanelAction extends AdminPanelAction
*
* @return string instructions
*/
function getInstructions()
public function getInstructions()
{
// TRANS: Instructions for sitemap.
return _m('Sitemap settings for this StatusNet site');
@@ -69,7 +63,7 @@ class SitemapadminpanelAction extends AdminPanelAction
*
* @return void
*/
function showForm()
public function showForm()
{
$form = new SitemapAdminPanelForm($this);
$form->show();
@@ -81,7 +75,7 @@ class SitemapadminpanelAction extends AdminPanelAction
*
* @return void
*/
function saveSettings()
public function saveSettings()
{
static $settings = array('sitemap' => array('yahookey', 'bingkey'));
@@ -100,7 +94,7 @@ class SitemapadminpanelAction extends AdminPanelAction
$config = new Config();
$config->query('BEGIN');
$config->query('START TRANSACTION');
foreach ($settings as $section => $parts) {
foreach ($parts as $setting) {
@@ -113,7 +107,7 @@ class SitemapadminpanelAction extends AdminPanelAction
return;
}
function validate(&$values)
public function validate(&$values)
{
}
}
@@ -128,7 +122,7 @@ class SitemapAdminPanelForm extends AdminForm
*
* @return int ID of the form
*/
function id()
public function id()
{
return 'form_sitemap_admin_panel';
}
@@ -138,7 +132,7 @@ class SitemapAdminPanelForm extends AdminForm
*
* @return string class of the form
*/
function formClass()
public function formClass()
{
return 'form_sitemap';
}
@@ -148,7 +142,7 @@ class SitemapAdminPanelForm extends AdminForm
*
* @return string URL of the action
*/
function action()
public function action()
{
return common_local_url('sitemapadminpanel');
}
@@ -158,24 +152,28 @@ class SitemapAdminPanelForm extends AdminForm
*
* @return void
*/
function formData()
public function formData()
{
$this->out->elementStart('ul', 'form_data');
$this->li();
$this->input('yahookey',
// TRANS: Field label.
_m('Yahoo key'),
// TRANS: Title for field label.
_m('Yahoo! Site Explorer verification key.'),
'sitemap');
$this->input(
'yahookey',
// TRANS: Field label.
_m('Yahoo key'),
// TRANS: Title for field label.
_m('Yahoo! Site Explorer verification key.'),
'sitemap'
);
$this->unli();
$this->li();
$this->input('bingkey',
// TRANS: Field label.
_m('Bing key'),
// TRANS: Title for field label.
_m('Bing Webmaster Tools verification key.'),
'sitemap');
$this->input(
'bingkey',
// TRANS: Field label.
_m('Bing key'),
// TRANS: Title for field label.
_m('Bing Webmaster Tools verification key.'),
'sitemap'
);
$this->unli();
$this->out->elementEnd('ul');
}
@@ -185,14 +183,16 @@ class SitemapAdminPanelForm extends AdminForm
*
* @return void
*/
function formActions()
public function formActions()
{
$this->out->submit('submit',
// TRANS: Submit button text to save sitemap settings.
_m('BUTTON','Save'),
'submit',
null,
// TRANS: Submit button title to save sitemap settings.
_m('Save sitemap settings.'));
$this->out->submit(
'submit',
// TRANS: Submit button text to save sitemap settings.
_m('BUTTON', 'Save'),
'submit',
null,
// TRANS: Submit button title to save sitemap settings.
_m('Save sitemap settings.')
);
}
}

View File

@@ -1,44 +1,41 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social 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.
//
// GNU social 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 GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* StatusNet, the distributed open-source microblogging tool
*
* Twitter bridge 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
* @package GNUsocial
* @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/
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
if (!defined('STATUSNET')) {
exit(1);
}
defined('GNUSOCIAL') || die();
/**
* Administer global Twitter bridge 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/
* @category Admin
* @package GNUsocial
* @author Zach Copley <zach@status.net>
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class TwitteradminpanelAction extends AdminPanelAction
{
@@ -47,10 +44,10 @@ class TwitteradminpanelAction extends AdminPanelAction
*
* @return string page title
*/
function title()
public function title()
{
// TRANS: Page title for Twitter administration panel.
return _m('TITLE','Twitter');
return _m('TITLE', 'Twitter');
}
/**
@@ -58,7 +55,7 @@ class TwitteradminpanelAction extends AdminPanelAction
*
* @return string instructions
*/
function getInstructions()
public function getInstructions()
{
// TRANS: Instructions for Twitter bridge administration page.
return _m('Twitter bridge settings');
@@ -69,7 +66,7 @@ class TwitteradminpanelAction extends AdminPanelAction
*
* @return void
*/
function showForm()
public function showForm()
{
$form = new TwitterAdminPanelForm($this);
$form->show();
@@ -81,7 +78,7 @@ class TwitteradminpanelAction extends AdminPanelAction
*
* @return void
*/
function saveSettings()
public function saveSettings()
{
static $settings = array(
'twitter' => array('consumer_key', 'consumer_secret'),
@@ -119,7 +116,7 @@ class TwitteradminpanelAction extends AdminPanelAction
$config = new Config();
$config->query('BEGIN');
$config->query('START TRANSACTION');
foreach ($settings as $section => $parts) {
foreach ($parts as $setting) {
@@ -143,7 +140,7 @@ class TwitteradminpanelAction extends AdminPanelAction
return;
}
function validate(&$values)
public function validate(&$values)
{
// Validate consumer key and secret (can't be too long)
@@ -162,7 +159,7 @@ class TwitteradminpanelAction extends AdminPanelAction
}
}
function isImportEnabled()
public function isImportEnabled()
{
// Since daemon setup isn't automated yet...
// @todo: if merged into main queues, detect presence of daemon config
@@ -177,7 +174,7 @@ class TwitterAdminPanelForm extends AdminForm
*
* @return int ID of the form
*/
function id()
public function id()
{
return 'twitteradminpanel';
}
@@ -187,7 +184,7 @@ class TwitterAdminPanelForm extends AdminForm
*
* @return string class of the form
*/
function formClass()
public function formClass()
{
return 'form_settings';
}
@@ -197,7 +194,7 @@ class TwitterAdminPanelForm extends AdminForm
*
* @return string URL of the action
*/
function action()
public function action()
{
return common_local_url('twitteradminpanel');
}
@@ -207,7 +204,7 @@ class TwitterAdminPanelForm extends AdminForm
*
* @return void
*/
function formData()
public function formData()
{
$this->out->elementStart(
'fieldset',
@@ -276,7 +273,8 @@ class TwitterAdminPanelForm extends AdminForm
$this->out->checkbox(
// TRANS: Checkbox label for global setting.
'signin', _m('Enable "Sign-in with Twitter"'),
'signin',
_m('Enable "Sign-in with Twitter"'),
(bool) $this->value('signin', 'twitter'),
// TRANS: Checkbox title.
_m('This allow users to login with their Twitter credentials.')
@@ -287,7 +285,8 @@ class TwitterAdminPanelForm extends AdminForm
$this->li();
$this->out->checkbox(
// TRANS: Checkbox label for global setting.
'enabled', _m('Enable Twitter import'),
'enabled',
_m('Enable Twitter import'),
(bool) $this->value('enabled', 'twitterimport'),
// TRANS: Checkbox title for global setting.
_m('Allow users to import their Twitter friends\' timelines. Requires daemons to be manually configured.')
@@ -305,11 +304,16 @@ class TwitterAdminPanelForm extends AdminForm
*
* @return void
*/
function formActions()
public function formActions()
{
// TRANS: Button text for saving the administrative Twitter bridge settings.
$this->out->submit('submit', _m('BUTTON','Save'), 'submit', null,
// TRANS: Button title for saving the administrative Twitter bridge settings.
_m('Save the Twitter bridge settings.'));
$this->out->submit(
'submit',
_m('BUTTON', 'Save'),
'submit',
null,
// TRANS: Button title for saving the administrative Twitter bridge settings.
_m('Save the Twitter bridge settings.')
);
}
}

View File

@@ -262,7 +262,7 @@ class TwitterImport
}
$profile = new Profile();
$profile->query("BEGIN");
$profile->query('START TRANSACTION');
$profile->nickname = $twuser->screen_name;
$profile->fullname = $twuser->name;
$profile->homepage = $twuser->url;