]> git.mxchange.org Git - friendica.git/commitdiff
Remove relocation form from Admin Site settings
authorHypolite Petovan <hypolite@mrpetovan.com>
Sun, 29 May 2022 17:14:31 +0000 (13:14 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Sun, 29 May 2022 17:15:23 +0000 (13:15 -0400)
src/Core/Relocate.php [deleted file]
src/Module/Admin/Site.php
view/templates/admin/site.tpl
view/theme/frio/templates/admin/site.tpl

diff --git a/src/Core/Relocate.php b/src/Core/Relocate.php
deleted file mode 100644 (file)
index 951bbaa..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-/**
- * @copyright Copyright (C) 2010-2022, the Friendica project
- *
- * @license GNU AGPL version 3 or any later version
- *
- * 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 <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Core;
-
-use Friendica\App;
-use Friendica\Database;
-use Friendica\Util\Strings;
-use Friendica\Worker\Delivery;
-
-class Relocate
-{
-       /**
-        * @var App\BaseURL
-        */
-       private $baseUrl;
-       /**
-        * @var Database\Database
-        */
-       private $database;
-       /**
-        * @var Config\Capability\IManageConfigValues
-        */
-       private $config;
-
-       public function __construct(App\BaseURL $baseUrl, Database\Database $database, Config\Capability\IManageConfigValues $config)
-       {
-               $this->baseUrl  = $baseUrl;
-               $this->database = $database;
-               $this->config   = $config;
-       }
-
-       /**
-        * Performs relocation
-        *
-        * @param string $new_url The new node URL, including the scheme
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
-        */
-       public function run(string $new_url)
-       {
-               $new_url = rtrim($new_url, '/');
-
-               $parsed = @parse_url($new_url);
-               if (!is_array($parsed) || empty($parsed['host']) || empty($parsed['scheme'])) {
-                       throw new \InvalidArgumentException('Can not parse base URL. Must have at least <scheme>://<domain>');
-               }
-
-               /* steps:
-                * replace all "baseurl" to "new_url" in config, profile, term, items and contacts
-                * send relocate for every local user
-                * */
-               $old_url = $this->baseUrl->get(true);
-
-               // Generate host names for relocation the addresses in the format user@address.tld
-               $new_host = str_replace('http://', '@', Strings::normaliseLink($new_url));
-               $old_host = str_replace('http://', '@', Strings::normaliseLink($old_url));
-
-               // update tables
-               // update profile links in the format "http://server.tld"
-               $this->database->replaceInTableFields('profile', ['photo', 'thumb'], $old_url, $new_url);
-               $this->database->replaceInTableFields('contact', ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
-               $this->database->replaceInTableFields('post-content', ['body'], $old_url, $new_url);
-
-               // update profile addresses in the format "user@server.tld"
-               $this->database->replaceInTableFields('contact', ['addr'], $old_host, $new_host);
-
-               // update config
-               $this->config->set('system', 'url', $new_url);
-               $this->baseUrl->saveByURL($new_url);
-
-               // send relocate
-               $users = $this->database->selectToArray('user', ['uid'], ['account_removed' => false, 'account_expired' => false]);
-               foreach ($users as $user) {
-                       Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::RELOCATION, $user['uid']);
-               }
-       }
-}
index 50289ff21fa22ac24dd281e40dcda90847997bd9..36824d511922b23d6c9ccfc602819e33d22917ac 100644 (file)
@@ -61,23 +61,6 @@ class Site extends BaseAdmin
                        return;
                }
 
-               if (!empty($_POST['relocate']) && !empty($_POST['relocate_url'])) {
-                       try {
-                               $relocate = new Relocate(DI::baseUrl(), DI::dba(), DI::config());
-                               $relocate->run($_POST['relocate_url']);
-
-                               info(DI::l10n()->t('Relocation started. Could take a while to complete.'));
-                       } catch (\InvalidArgumentException $e) {
-                               notice(DI::l10n()->t('Can not parse base url. Must have at least <scheme>://<domain>'));
-                       } catch (\Throwable $e) {
-                               notice(DI::l10n()->t('Unable to perform the relocation, please retry later or check the application logs.'));
-                               notice($e->getMessage());
-                       }
-
-                       DI::baseUrl()->redirect('admin/site');
-               }
-               // end relocate
-
                $sitename         = (!empty($_POST['sitename'])         ? trim($_POST['sitename'])      : '');
                $sender_email     = (!empty($_POST['sender_email'])     ? trim($_POST['sender_email'])  : '');
                $banner           = (!empty($_POST['banner'])           ? trim($_POST['banner'])                             : false);
@@ -462,8 +445,9 @@ class Site extends BaseAdmin
                        '$no_relay_list'     => DI::l10n()->t('The system is not subscribed to any relays at the moment.'),
                        '$relay_list_title'  => DI::l10n()->t('The system is currently subscribed to the following relays:'),
                        '$relay_list'        => Relay::getList(['url']),
-                       '$relocate'          => DI::l10n()->t('Relocate Instance'),
-                       '$relocate_warning'  => DI::l10n()->t('<strong>Warning!</strong> Advanced function. Could make this server unreachable.'),
+                       '$relocate'          => DI::l10n()->t('Relocate Node'),
+                       '$relocate_msg'      => DI::l10n()->t('Relocating your node enables you to change the DNS domain of this node and keep all the existing users and posts. This process takes a while and can only be started from the relocate console command like this:'),
+                       '$relocate_cmd'      => DI::l10n()->t('(Friendica directory)# bin/console relocate https://newdomain.com'),
                        '$baseurl'           => DI::baseUrl()->get(true),
 
                        // name, label, value, help string, extra data...
@@ -551,8 +535,6 @@ class Site extends BaseAdmin
                        '$temppath'               => ['temppath', DI::l10n()->t('Temp path'), DI::config()->get('system', 'temppath'), DI::l10n()->t('If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.')],
                        '$only_tag_search'        => ['only_tag_search', DI::l10n()->t('Only search in tags'), DI::config()->get('system', 'only_tag_search'), DI::l10n()->t('On large systems the text search can slow down the system extremely.')],
 
-                       '$relocate_url'           => ['relocate_url', DI::l10n()->t('New base url'), DI::baseUrl()->get(), DI::l10n()->t('Change base url for this server. Sends relocate message to all Friendica and Diaspora* contacts of all users.')],
-
                        '$worker_queues'          => ['worker_queues', DI::l10n()->t('Maximum number of parallel workers'), DI::config()->get('system', 'worker_queues'), DI::l10n()->t('On shared hosters set this to %d. On larger systems, values of %d are great. Default value is %d.', 5, 20, 10)],
                        '$worker_fastlane'        => ['worker_fastlane', DI::l10n()->t('Enable fastlane'), DI::config()->get('system', 'worker_fastlane'), DI::l10n()->t('When enabed, the fastlane mechanism starts an additional worker if processes with higher priority are blocked by processes of lower priority.')],
 
index 6e2958b97894454028e097b2d6c6ec7c516e9e5f..f23cc521e7498243c8cda0c6d26d836575088402 100644 (file)
 
        </form>
 
-       {{* separate form for relocate... *}}
-       <form action="{{$baseurl}}/admin/site" method="post">
-               <input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
+       <div>
                <h2>{{$relocate}}</h2>
-               <p>{{$relocate_warning nofilter}}</p>
-               {{include file="field_input.tpl" field=$relocate_url}}
-               <input type="hidden" name="page_site" value="{{$submit}}">
-               <div class="submit"><input type="submit" name="relocate" value="{{$relocate_button}}"/></div>
-       </form>
+               <p>{{$relocate_msg}}</p>
+               <p><code>{{$relocate_cmd}}</code></p>
+       </div>
 
 </div>
index 3bd1a49af2e6dfe4ab194efc1f6ffb134def7bbe..f6a01b541a8ddd369755653e43366506b0ff9cb2 100644 (file)
                        </div>
                </form>
 
-               <!--
-               /*
-                *    Relocate
-                */ -->
-               <form id="relocate-form" class="panel" action="{{$baseurl}}/admin/site" method="post">
-                       <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
-                       <input type="hidden" name="page_site" value="{{$submit}}">
-                       <input type="hidden" name="active_panel" value="admin-settings-relocate-collapse">
+               <div class="panel">
                        <div class="section-subtitle-wrapper panel-heading" role="tab" id="admin-settings-relocate">
                                <h2>
                                        <button class="btn-link accordion-toggle collapsed" data-toggle="collapse" data-parent="#admin-settings" href="#admin-settings-relocate-collapse" aria-expanded="false" aria-controls="admin-settings-relocate-collapse">
                        </div>
                        <div id="admin-settings-relocate-collapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="admin-settings-relocate">
                                <div class="panel-body">
-                                       <div class="alert alert-danger alert-dismissible">
-                                               {{$relocate_warning nofilter}}
-                                       </div>
-                                       {{include file="field_input.tpl" field=$relocate_url}}
-                               </div>
-                               <div class="panel-footer">
-                                       <input type="submit" name="relocate" class="btn btn-primary" value="{{$relocate_button}}"/>
+                                       <p>
+                                               {{$relocate_msg}}
+                                       </p>
+                                       <p><code>{{$relocate_cmd}}</code></p>
                                </div>
                        </div>
-               </form>
+               </div>
        </div>
 </div>