]> git.mxchange.org Git - friendica.git/blobdiff - mod/delegate.php
Catch HTTPExceptions in App::runFrontend()
[friendica.git] / mod / delegate.php
index 2b29632dda00bc265800937b642c59406f6546b6..4bfc0e31ba8b78879d5c47021f7f524ae9ea8606 100644 (file)
@@ -7,10 +7,12 @@ use Friendica\App;
 use Friendica\BaseModule;
 use Friendica\Core\L10n;
 use Friendica\Core\Protocol;
+use Friendica\Core\Renderer;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Model\User;
 use Friendica\Util\Security;
+use Friendica\Util\Strings;
 
 require_once 'mod/settings.php';
 
@@ -25,7 +27,7 @@ function delegate_post(App $a)
                return;
        }
 
-       if (count($a->user) && x($a->user, 'uid') && $a->user['uid'] != local_user()) {
+       if (count($a->user) && !empty($a->user['uid']) && $a->user['uid'] != local_user()) {
                notice(L10n::t('Permission denied.') . EOL);
                return;
        }
@@ -61,8 +63,8 @@ function delegate_content(App $a)
 
        if ($a->argc > 2 && $a->argv[1] === 'add' && intval($a->argv[2])) {
                // delegated admins can view but not change delegation permissions
-               if (x($_SESSION, 'submanage')) {
-                       goaway(System::baseUrl() . '/delegate');
+               if (!empty($_SESSION['submanage'])) {
+                       $a->internalRedirect('delegate');
                }
 
                $user_id = $a->argv[2];
@@ -71,23 +73,23 @@ function delegate_content(App $a)
                if (DBA::isResult($user)) {
                        $condition = [
                                'uid' => local_user(),
-                               'nurl' => normalise_link(System::baseUrl() . '/profile/' . $user['nickname'])
+                               'nurl' => Strings::normaliseLink(System::baseUrl() . '/profile/' . $user['nickname'])
                        ];
                        if (DBA::exists('contact', $condition)) {
                                DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
                        }
                }
-               goaway(System::baseUrl() . '/delegate');
+               $a->internalRedirect('delegate');
        }
 
        if ($a->argc > 2 && $a->argv[1] === 'remove' && intval($a->argv[2])) {
                // delegated admins can view but not change delegation permissions
-               if (x($_SESSION, 'submanage')) {
-                       goaway(System::baseUrl() . '/delegate');
+               if (!empty($_SESSION['submanage'])) {
+                       $a->internalRedirect('delegate');
                }
 
                DBA::delete('manage', ['uid' => $a->argv[2], 'mid' => local_user()]);
-               goaway(System::baseUrl() . '/delegate');
+               $a->internalRedirect('delegate');
        }
 
        // find everybody that currently has delegated management to this account/page
@@ -113,7 +115,7 @@ function delegate_content(App $a)
                AND SUBSTRING_INDEX(`nurl`, '/', 3) = '%s'
                AND `uid` = %d
                AND `network` = '%s' ",
-               DBA::escape(normalise_link(System::baseUrl())),
+               DBA::escape(Strings::normaliseLink(System::baseUrl())),
                intval(local_user()),
                DBA::escape(Protocol::DFRN)
        );
@@ -161,9 +163,11 @@ function delegate_content(App $a)
 
        if (!is_null($parent_user)) {
                $parent_password = ['parent_password', L10n::t('Parent Password:'), '', L10n::t('Please enter the password of the parent account to legitimize your request.')];
+       } else {
+               $parent_password = '';
        }
 
-       $o = replace_macros(get_markup_template('delegate.tpl'), [
+       $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('delegate.tpl'), [
                '$form_security_token' => BaseModule::getFormSecurityToken('delegate'),
                '$parent_header' => L10n::t('Parent User'),
                '$parent_user' => $parent_user,