]> git.mxchange.org Git - friendica.git/blobdiff - mod/regmod.php
Merge pull request #3965 from tobiasd/20171126-docGettingStarted
[friendica.git] / mod / regmod.php
index 34d29a77cecfee8360b9d2e63822876483a47e41..6d76e7ea7eb7f8814d892283ace04fa144782aac 100644 (file)
@@ -1,5 +1,11 @@
 <?php
 
+use Friendica\App;
+use Friendica\Core\Config;
+use Friendica\Core\System;
+use Friendica\Core\Worker;
+use Friendica\Database\DBM;
+
 require_once('include/enotify.php');
 require_once('include/user.php');
 
@@ -12,15 +18,17 @@ function user_allow($hash) {
        );
 
 
-       if(! count($register))
+       if (! DBM::is_result($register)) {
                return false;
+       }
 
        $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                intval($register[0]['uid'])
        );
 
-       if(! count($user))
+       if (! DBM::is_result($user)) {
                killme();
+       }
 
        $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
                dbesc($register[0]['hash'])
@@ -34,10 +42,10 @@ function user_allow($hash) {
        $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
                intval($user[0]['uid'])
        );
-       if (dbm::is_result($r) && $r[0]['net-publish']) {
-               $url = App::get_baseurl() . '/profile/' . $user[0]['nickname'];
-               if ($url && strlen(get_config('system','directory'))) {
-                       proc_run(PRIORITY_LOW, "include/directory.php", $url);
+       if (DBM::is_result($r) && $r[0]['net-publish']) {
+               $url = System::baseUrl() . '/profile/' . $user[0]['nickname'];
+               if ($url && strlen(Config::get('system','directory'))) {
+                       Worker::add(PRIORITY_LOW, "Directory", $url);
                }
        }
 
@@ -46,7 +54,7 @@ function user_allow($hash) {
        send_register_open_eml(
                $user[0]['email'],
                $a->config['sitename'],
-               App::get_baseurl(),
+               System::baseUrl(),
                $user[0]['username'],
                $register[0]['password']);
 
@@ -70,32 +78,23 @@ function user_deny($hash) {
                dbesc($hash)
        );
 
-       if(! count($register))
+       if (!DBM::is_result($register)) {
                return false;
+       }
 
        $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
                intval($register[0]['uid'])
        );
 
-       $r = q("DELETE FROM `user` WHERE `uid` = %d",
-               intval($register[0]['uid'])
-       );
-       $r = q("DELETE FROM `contact` WHERE `uid` = %d",
-               intval($register[0]['uid'])
-       );
-       $r = q("DELETE FROM `profile` WHERE `uid` = %d",
-               intval($register[0]['uid'])
-       );
+       dba::delete('user', array('uid' => $register[0]['uid']));
+       dba::delete('register', array('hash' => $register[0]['hash']));
 
-       $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
-               dbesc($register[0]['hash'])
-       );
-       notice( sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
+       notice(sprintf(t('Registration revoked for %s'), $user[0]['username']) . EOL);
        return true;
 
 }
 
-function regmod_content(&$a) {
+function regmod_content(App $a) {
 
        global $lang;
 
@@ -123,13 +122,13 @@ function regmod_content(&$a) {
 
        if ($cmd === 'deny') {
                user_deny($hash);
-               goaway(App::get_baseurl()."/admin/users/");
+               goaway(System::baseUrl()."/admin/users/");
                killme();
        }
 
        if ($cmd === 'allow') {
                user_allow($hash);
-               goaway(App::get_baseurl()."/admin/users/");
+               goaway(System::baseUrl()."/admin/users/");
                killme();
        }
 }