[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
parent 97bddc4537
commit 6c035d01d4
36 changed files with 1588 additions and 1397 deletions

View File

@@ -1,48 +1,42 @@
<?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
*
* Paths 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 Evan Prodromou <evan@status.net>
* @author Zach Copley <zach@status.net>
* @author Sarven Capadisli <csarven@status.net>
* @copyright 2008-2011 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();
/**
* Paths settings
*
* @category Admin
* @package StatusNet
* @author Evan Prodromou <evan@status.net>
* @author Zach Copley <zach@status.net>
* @author Sarven Capadisli <csarven@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 Evan Prodromou <evan@status.net>
* @author Zach Copley <zach@status.net>
* @author Sarven Capadisli <csarven@status.net>
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
class PathsadminpanelAction extends AdminPanelAction
{
@@ -52,7 +46,7 @@ class PathsadminpanelAction extends AdminPanelAction
* @return string page title
*/
function title()
public function title()
{
// TRANS: Title for Paths admin panel.
return _('Paths');
@@ -63,7 +57,7 @@ class PathsadminpanelAction extends AdminPanelAction
*
* @return string instructions
*/
function getInstructions()
public function getInstructions()
{
// TRANS: Form instructions for Path admin panel.
return _('Path and server settings for this StatusNet site');
@@ -74,7 +68,7 @@ class PathsadminpanelAction extends AdminPanelAction
*
* @return void
*/
function showForm()
public function showForm()
{
$form = new PathsAdminPanelForm($this);
$form->show();
@@ -86,14 +80,14 @@ class PathsadminpanelAction extends AdminPanelAction
*
* @return void
*/
function saveSettings()
public function saveSettings()
{
static $settings = array(
'site' => array('path', 'locale_path', 'ssl', 'sslserver'),
'theme' => array('server', 'dir', 'path', 'sslserver', 'sslpath'),
'avatar' => array('server', 'dir', 'path'),
'attachments' => array('server', 'dir', 'path', 'sslserver', 'sslpath')
);
static $settings = [
'site' => ['path', 'locale_path', 'ssl', 'sslserver'],
'theme' => ['server', 'dir', 'path', 'sslserver', 'sslpath'],
'avatar' => ['server', 'dir', 'path'],
'attachments' => ['server', 'dir', 'path', 'sslserver', 'sslpath'],
];
// XXX: If we're only going to have one boolean on thi page we
// can remove some of the boolean processing code --Z
@@ -120,7 +114,7 @@ class PathsadminpanelAction extends AdminPanelAction
$config = new Config();
$config->query('BEGIN');
$config->query('START TRANSACTION');
foreach ($settings as $section => $parts) {
foreach ($parts as $setting) {
@@ -144,7 +138,7 @@ class PathsadminpanelAction extends AdminPanelAction
*
* @return void
*/
function validate(&$values)
public function validate(&$values)
{
// Validate theme dir
@@ -189,7 +183,7 @@ class PathsAdminPanelForm extends AdminForm
*
* @return int ID of the form
*/
function id()
public function id()
{
return 'form_paths_admin_panel';
}
@@ -199,7 +193,7 @@ class PathsAdminPanelForm extends AdminForm
*
* @return string class of the form
*/
function formClass()
public function formClass()
{
return 'form_settings';
}
@@ -209,7 +203,7 @@ class PathsAdminPanelForm extends AdminForm
*
* @return string URL of the action
*/
function action()
public function action()
{
return common_local_url('pathsadminpanel');
}
@@ -219,7 +213,7 @@ class PathsAdminPanelForm extends AdminForm
*
* @return void
*/
function formData()
public function formData()
{
$this->out->elementStart('fieldset', array('id' => 'settings_paths_locale'));
// TRANS: Fieldset legend in Paths admin panel.
@@ -227,37 +221,45 @@ class PathsAdminPanelForm extends AdminForm
$this->out->elementStart('ul', 'form_data');
$this->li();
$this->input('server',
// TRANS: Field label in Paths admin panel.
_('Server'),
// TRANS: Field title in Paths admin panel.
_('Site\'s server hostname.'));
$this->input(
'server',
// TRANS: Field label in Paths admin panel.
_('Server'),
// TRANS: Field title in Paths admin panel.
_('Site\'s server hostname.')
);
$this->unli();
$this->li();
$this->input('path',
// TRANS: Field label in Paths admin panel.
_('Path'),
// TRANS: Field title in Paths admin panel.
_('Site path.'));
$this->input(
'path',
// TRANS: Field label in Paths admin panel.
_('Path'),
// TRANS: Field title in Paths admin panel.
_('Site path.')
);
$this->unli();
$this->li();
$this->input('locale_path',
// TRANS: Field label in Paths admin panel.
_('Locale directory'),
// TRANS: Field title in Paths admin panel.
_('Directory path to locales.'),
'site');
$this->input(
'locale_path',
// TRANS: Field label in Paths admin panel.
_('Locale directory'),
// TRANS: Field title in Paths admin panel.
_('Directory path to locales.'),
'site'
);
$this->unli();
$this->li();
$this->out->checkbox('fancy',
// TRANS: Checkbox label in Paths admin panel.
_('Fancy URLs'),
(bool) $this->value('fancy'),
// TRANS: Field title in Paths admin panel.
_('Use fancy URLs (more readable and memorable)?'));
$this->out->checkbox(
'fancy',
// TRANS: Checkbox label in Paths admin panel.
_('Fancy URLs'),
(bool) $this->value('fancy'),
// TRANS: Field title in Paths admin panel.
_('Use fancy URLs (more readable and memorable)?')
);
$this->unli();
$this->out->elementEnd('ul');
@@ -265,145 +267,176 @@ class PathsAdminPanelForm extends AdminForm
$this->out->elementStart('fieldset', array('id' => 'settings_paths_theme'));
// TRANS: Fieldset legend in Paths admin panel.
$this->out->element('legend', null, _m('LEGEND','Theme'));
$this->out->element('legend', null, _m('LEGEND', 'Theme'));
$this->out->elementStart('ul', 'form_data');
$this->li();
$this->input('server',
// TRANS: Field label in Paths admin panel.
_('Server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server for themes.'),
'theme');
$this->input(
'server',
// TRANS: Field label in Paths admin panel.
_('Server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server for themes.'),
'theme'
);
$this->unli();
$this->li();
$this->input('path',
// TRANS: Field label in Paths admin panel.
_('Path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Web path to themes.'),
'theme');
$this->input(
'path',
// TRANS: Field label in Paths admin panel.
_('Path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Web path to themes.'),
'theme'
);
$this->unli();
$this->li();
$this->input('sslserver',
// TRANS: Field label in Paths admin panel.
_('SSL server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('SSL server for themes (default: SSL server).'),
'theme');
$this->input(
'sslserver',
// TRANS: Field label in Paths admin panel.
_('SSL server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('SSL server for themes (default: SSL server).'),
'theme'
);
$this->unli();
$this->li();
$this->input('sslpath',
// TRANS: Field label in Paths admin panel.
_('SSL path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('SSL path to themes (default: /theme/).'),
'theme');
$this->input(
'sslpath',
// TRANS: Field label in Paths admin panel.
_('SSL path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('SSL path to themes (default: /theme/).'),
'theme'
);
$this->unli();
$this->li();
$this->input('dir',
// TRANS: Field label in Paths admin panel.
_('Directory'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Directory where themes are located.'),
'theme');
$this->input(
'dir',
// TRANS: Field label in Paths admin panel.
_('Directory'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Directory where themes are located.'),
'theme'
);
$this->unli();
$this->out->elementEnd('ul');
$this->out->elementEnd('fieldset');
$this->out->elementStart('fieldset', array('id' => 'settings_avatar-paths'));
$this->out->elementStart(
'fieldset',
['id' => 'settings_avatar-paths']
);
// TRANS: Fieldset legend in Paths admin panel.
$this->out->element('legend', null, _('Avatars'));
$this->out->elementStart('ul', 'form_data');
$this->li();
$this->input('server',
// TRANS: Field label in Paths admin panel.
_('Avatar server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server for avatars.'),
'avatar');
$this->input(
'server',
// TRANS: Field label in Paths admin panel.
_('Avatar server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server for avatars.'),
'avatar'
);
$this->unli();
$this->li();
$this->input('path',
// TRANS: Field label in Paths admin panel.
_('Avatar path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Web path to avatars.'),
'avatar');
$this->input(
'path',
// TRANS: Field label in Paths admin panel.
_('Avatar path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Web path to avatars.'),
'avatar'
);
$this->unli();
$this->li();
$this->input('dir',
// TRANS: Field label in Paths admin panel.
_('Avatar directory'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Directory where avatars are located.'),
'avatar');
$this->input(
'dir',
// TRANS: Field label in Paths admin panel.
_('Avatar directory'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Directory where avatars are located.'),
'avatar'
);
$this->unli();
$this->out->elementEnd('ul');
$this->out->elementEnd('fieldset');
$this->out->elementStart('fieldset', array('id' =>
'settings_attachments-paths'));
$this->out->elementStart(
'fieldset',
['id' => 'settings_attachments-paths']
);
// TRANS: Fieldset legens in Paths admin panel.
$this->out->element('legend', null, _('Attachments'));
$this->out->elementStart('ul', 'form_data');
$this->li();
$this->input('server',
// TRANS: Field label in Paths admin panel.
_('Server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server for attachments.'),
'attachments');
$this->input(
'server',
// TRANS: Field label in Paths admin panel.
_('Server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server for attachments.'),
'attachments'
);
$this->unli();
$this->li();
$this->input('path',
// TRANS: Field label in Paths admin panel.
_('Path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Web path to attachments.'),
'attachments');
$this->input(
'path',
// TRANS: Field label in Paths admin panel.
_('Path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Web path to attachments.'),
'attachments'
);
$this->unli();
$this->li();
$this->input('sslserver',
// TRANS: Field label in Paths admin panel.
_('SSL server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server for attachments on SSL pages.'),
'attachments');
$this->input(
'sslserver',
// TRANS: Field label in Paths admin panel.
_('SSL server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server for attachments on SSL pages.'),
'attachments'
);
$this->unli();
$this->li();
$this->input('sslpath',
// TRANS: Field label in Paths admin panel.
_('SSL path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Web path to attachments on SSL pages.'),
'attachments');
$this->input(
'sslpath',
// TRANS: Field label in Paths admin panel.
_('SSL path'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Web path to attachments on SSL pages.'),
'attachments'
);
$this->unli();
$this->li();
$this->input('dir',
// TRANS: Field label in Paths admin panel.
_('Directory'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Directory where attachments are located.'),
'attachments');
$this->input(
'dir',
// TRANS: Field label in Paths admin panel.
_('Directory'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Directory where attachments are located.'),
'attachments'
);
$this->unli();
$this->out->elementEnd('ul');
@@ -411,31 +444,38 @@ class PathsAdminPanelForm extends AdminForm
$this->out->elementStart('fieldset', array('id' => 'settings_admin_ssl'));
// TRANS: Fieldset legend in Paths admin panel.
$this->out->element('legend', null, _m('LEGEND','SSL'));
$this->out->element('legend', null, _m('LEGEND', 'SSL'));
$this->out->elementStart('ul', 'form_data');
$this->li();
// TRANS: Drop down option in Paths admin panel (option for "When to use SSL").
$ssl = array('never' => _('Never'),
// TRANS: Drop down option in Paths admin panel (option for "When to use SSL").
'always' => _('Always'));
$ssl = [
'never' => _('Never'),
// TRANS: Drop down option in Paths admin panel (option for "When to use SSL").
'always' => _('Always'),
];
$this->out->dropdown('site-ssl',
// TRANS: Drop down label in Paths admin panel.
_('Use SSL'),
// TRANS: Tooltip for field label in Paths admin panel.
$ssl, _('When to use SSL.'),
false,
$this->value('ssl', 'site'));
$this->out->dropdown(
'site-ssl',
// TRANS: Drop down label in Paths admin panel.
_('Use SSL'),
// TRANS: Tooltip for field label in Paths admin panel.
$ssl,
_('When to use SSL.'),
false,
$this->value('ssl', 'site')
);
$this->unli();
$this->li();
$this->input('sslserver',
// TRANS: Field label in Paths admin panel.
_('SSL server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server to direct SSL requests to.'),
'site');
$this->input(
'sslserver',
// TRANS: Field label in Paths admin panel.
_('SSL server'),
// TRANS: Tooltip for field label in Paths admin panel.
_('Server to direct SSL requests to.'),
'site'
);
$this->unli();
$this->out->elementEnd('ul');
$this->out->elementEnd('fieldset');
@@ -446,12 +486,17 @@ class PathsAdminPanelForm extends AdminForm
*
* @return void
*/
function formActions()
public function formActions()
{
// TRANS: Button text to store form data in the Paths admin panel.
$this->out->submit('save', _m('BUTTON','Save'), 'submit',
// TRANS: Button title text to store form data in the Paths admin panel.
'save', _('Save path settings.'));
$this->out->submit(
'save',
_m('BUTTON', 'Save'),
'submit',
// TRANS: Button title text to store form data in the Paths admin panel.
'save',
_('Save path settings.')
);
}
/**
@@ -467,7 +512,7 @@ class PathsAdminPanelForm extends AdminForm
*
* @return void
*/
function input($setting, $title, $instructions, $section='site')
public function input($setting, $title, $instructions, $section='site')
{
$this->out->input("$section-$setting", $title, $this->value($setting, $section), $instructions);
}