]> git.mxchange.org Git - friendica.git/blobdiff - mod/delegate.php
Renamed System::redirect() to $a->redirect()
[friendica.git] / mod / delegate.php
index 7a98be75513e87bc87b202d6c7617010dcda2ee2..e525e1ab80d76a402356f96c582fa3de0292835d 100644 (file)
@@ -4,11 +4,13 @@
  */
 
 use Friendica\App;
+use Friendica\BaseModule;
 use Friendica\Core\L10n;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
-use Friendica\Database\DBM;
 use Friendica\Model\User;
+use Friendica\Util\Security;
 
 require_once 'mod/settings.php';
 
@@ -28,14 +30,14 @@ function delegate_post(App $a)
                return;
        }
 
-       check_form_security_token_redirectOnErr('/delegate', 'delegate');
+       BaseModule::checkFormSecurityTokenRedirectOnError('/delegate', 'delegate');
 
        $parent_uid = defaults($_POST, 'parent_user', 0);
        $parent_password = defaults($_POST, 'parent_password', '');
 
        if ($parent_uid != 0) {
                $user = DBA::selectFirst('user', ['nickname'], ['uid' => $parent_uid]);
-               if (!DBM::is_result($user)) {
+               if (!DBA::isResult($user)) {
                        notice(L10n::t('Parent user not found.') . EOL);
                        return;
                }
@@ -60,13 +62,13 @@ 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');
+                       $a->redirect('delegate');
                }
 
                $user_id = $a->argv[2];
 
                $user = DBA::selectFirst('user', ['nickname'], ['uid' => $user_id]);
-               if (DBM::is_result($user)) {
+               if (DBA::isResult($user)) {
                        $condition = [
                                'uid' => local_user(),
                                'nurl' => normalise_link(System::baseUrl() . '/profile/' . $user['nickname'])
@@ -75,17 +77,17 @@ function delegate_content(App $a)
                                DBA::insert('manage', ['uid' => $user_id, 'mid' => local_user()]);
                        }
                }
-               goaway(System::baseUrl() . '/delegate');
+               $a->redirect('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');
+                       $a->redirect('delegate');
                }
 
                DBA::delete('manage', ['uid' => $a->argv[2], 'mid' => local_user()]);
-               goaway(System::baseUrl() . '/delegate');
+               $a->redirect('delegate');
        }
 
        // find everybody that currently has delegated management to this account/page
@@ -93,7 +95,7 @@ function delegate_content(App $a)
        $r = q("SELECT * FROM `user` WHERE `uid` IN (SELECT `uid` FROM `manage` WHERE `mid` = %d)",
                intval(local_user())
        );
-       if (DBM::is_result($r)) {
+       if (DBA::isResult($r)) {
                $delegates = $r;
        }
 
@@ -111,21 +113,21 @@ function delegate_content(App $a)
                AND SUBSTRING_INDEX(`nurl`, '/', 3) = '%s'
                AND `uid` = %d
                AND `network` = '%s' ",
-               dbesc(normalise_link(System::baseUrl())),
+               DBA::escape(normalise_link(System::baseUrl())),
                intval(local_user()),
-               dbesc(NETWORK_DFRN)
+               DBA::escape(Protocol::DFRN)
        );
-       if (DBM::is_result($r)) {
+       if (DBA::isResult($r)) {
                $nicknames = [];
                foreach ($r as $rr) {
-                       $nicknames[] = "'" . dbesc(basename($rr['nurl'])) . "'";
+                       $nicknames[] = "'" . DBA::escape(basename($rr['nurl'])) . "'";
                }
 
                $nicks = implode(',', $nicknames);
 
                // get user records for all potential page delegates who are not already delegates or managers
                $r = q("SELECT `uid`, `username`, `nickname` FROM `user` WHERE `nickname` IN ($nicks)");
-               if (DBM::is_result($r)) {
+               if (DBA::isResult($r)) {
                        foreach ($r as $rr) {
                                if (!in_array($rr['uid'], $uids)) {
                                        $potentials[] = $rr;
@@ -140,7 +142,7 @@ function delegate_content(App $a)
 
        $parent_user = null;
 
-       if (DBM::is_result($user)) {
+       if (DBA::isResult($user)) {
                if (!DBA::exists('user', ['parent-uid' => local_user()])) {
                        $parent_uid = $user['parent-uid'];
                        $parents = [0 => L10n::t('No parent user')];
@@ -162,7 +164,7 @@ function delegate_content(App $a)
        }
 
        $o = replace_macros(get_markup_template('delegate.tpl'), [
-               '$form_security_token' => get_form_security_token('delegate'),
+               '$form_security_token' => BaseModule::getFormSecurityToken('delegate'),
                '$parent_header' => L10n::t('Parent User'),
                '$parent_user' => $parent_user,
                '$parent_password' => $parent_password,