]> git.mxchange.org Git - friendica.git/commitdiff
Merge branch 'develop' of https://github.com/friendica/friendica into develop
authorRalf Thees <ralf@herrthees.de>
Wed, 17 Oct 2018 19:19:52 +0000 (21:19 +0200)
committerRalf Thees <ralf@herrthees.de>
Wed, 17 Oct 2018 19:19:52 +0000 (21:19 +0200)
22 files changed:
boot.php
config/dbstructure.json
include/conversation.php
include/enotify.php
mod/admin.php
mod/invite.php
mod/parse_url.php
mod/ping.php
mod/register.php
mod/regmod.php
src/Database/DBA.php
src/Model/Item.php
src/Model/Register.php [new file with mode: 0644]
src/Model/User.php
src/Protocol/ActivityPub/Receiver.php
src/Protocol/Diaspora.php
src/Util/ParseUrl.php
src/Worker/Delivery.php
update.php
view/templates/contact_edit.tpl
view/theme/frio/templates/contact_edit.tpl
view/theme/vier/templates/contact_edit.tpl

index ea1b273f2e8f24fac000e355ce1293ee1bcab174..acbc737658c2a8d4aef307aee52092abc74c7008 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -41,7 +41,7 @@ define('FRIENDICA_PLATFORM',     'Friendica');
 define('FRIENDICA_CODENAME',     'The Tazmans Flax-lily');
 define('FRIENDICA_VERSION',      '2018.12-dev');
 define('DFRN_PROTOCOL_VERSION',  '2.23');
-define('DB_UPDATE_VERSION',      1287);
+define('DB_UPDATE_VERSION',      1288);
 define('NEW_UPDATE_ROUTINE_VERSION', 1170);
 
 /**
@@ -647,7 +647,7 @@ function killme()
 /**
  * @brief Redirect to another URL and terminate this process.
  */
-function goaway($path)
+function goaway($path = '')
 {
        if (strstr(normalise_link($path), 'http://')) {
                $url = $path;
index 51cb3ce4f3f84037259e6b1b39c84c9ac4b843f1..da1da7a66b1a295242db1cf7aaa4ff2af39765c2 100644 (file)
                "indexes": {
                        "PRIMARY": ["id"],
                        "uri-hash": ["UNIQUE", "uri-hash"],
-                       "uri": ["uri(191)"]
+                       "uri": ["uri(191)"],
+                       "uri-id": ["uri-id"]
                }
        },
        "item-content": {
                "indexes": {
                        "PRIMARY": ["id"],
                        "uri-plink-hash": ["UNIQUE", "uri-plink-hash"],
-                       "uri": ["uri(191)"]
+                       "uri": ["uri(191)"],
+                       "uri-id": ["uri-id"]
                }
        },
        "item-delivery-data": {
index 43854bb40f7b7e8d1486edb47d41e3a092fa7063..31920c2fcb163e4e7864cace513afa8148ce4cfe 100644 (file)
@@ -853,8 +853,8 @@ function item_photo_menu($item) {
 
        if ($cid && !$item['self']) {
                $poke_link = 'poke/?f=&c=' . $cid;
-               $contact_url = 'contacts/' . $cid;
-               $posts_link = 'contacts/' . $cid . '/posts';
+               $contact_url = 'contact/' . $cid;
+               $posts_link = 'contact/' . $cid . '/posts';
 
                if (in_array($network, [Protocol::DFRN, Protocol::DIASPORA])) {
                        $pm_url = 'message/new/' . $cid;
index d8e5614c171034ae4270eb5d38bceaddb765400b..6d8cef87947194eea4f23aeb15e68be772cf0d99 100644 (file)
@@ -84,7 +84,7 @@ function notification($params)
        // with $params['show_in_notification_page'] == false, the notification isn't inserted into
        // the database, and an email is sent if applicable.
        // default, if not specified: true
-       $show_in_notification_page = ((x($params, 'show_in_notification_page')) ? $params['show_in_notification_page']:true);
+       $show_in_notification_page = isset($params['show_in_notification_page']) ? $params['show_in_notification_page'] : true;
 
        $additional_mail_header = "";
        $additional_mail_header .= "Precedence: list\n";
index b02db73bdd9bdf76468881ae6164c3fc8b185279..b0fb6d47262a23024e8d0df63c464a2cd438f4c5 100644 (file)
@@ -18,13 +18,14 @@ use Friendica\Database\DBA;
 use Friendica\Database\DBStructure;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
+use Friendica\Model\Register;
 use Friendica\Model\User;
 use Friendica\Module\Login;
 use Friendica\Module\Tos;
 use Friendica\Util\Arrays;
 use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Temporal;
 use Friendica\Util\Network;
+use Friendica\Util\Temporal;
 
 require_once 'include/enotify.php';
 require_once 'include/text.php';
@@ -33,11 +34,11 @@ require_once 'include/items.php';
 /**
  * @brief Process send data from the admin panels subpages
  *
- * This function acts as relais for processing the data send from the subpages
+ * This function acts as relay for processing the data send from the subpages
  * of the admin panel. Depending on the 1st parameter of the url (argv[1])
  * specialized functions are called to process the data from the subpages.
  *
- * The function itself does not return anything, but the subsequencely function
+ * The function itself does not return anything, but the subsequently function
  * return the HTML for the pages of the admin panel.
  *
  * @param App $a
@@ -895,8 +896,7 @@ function admin_page_summary(App $a)
 
        logger('accounts: ' . print_r($accounts, true), LOGGER_DATA);
 
-       $r = q("SELECT COUNT(`id`) AS `count` FROM `register`");
-       $pending = $r[0]['count'];
+       $pending = Register::getPendingCount();
 
        $r = q("SELECT COUNT(*) AS `total` FROM `queue` WHERE 1");
        $queue = (($r) ? $r[0]['total'] : 0);
@@ -912,10 +912,10 @@ function admin_page_summary(App $a)
        $r = q("SHOW variables LIKE 'max_allowed_packet'");
        $max_allowed_packet = (($r) ? $r[0]['Value'] : 0);
 
-       $server_settings = ['label' => L10n::t('Server Settings'), 
-                               'php' => ['upload_max_filesize' => ini_get('upload_max_filesize'), 
-                                                 'post_max_size' => ini_get('post_max_size'), 
-                                                 'memory_limit' => ini_get('memory_limit')], 
+       $server_settings = ['label' => L10n::t('Server Settings'),
+                               'php' => ['upload_max_filesize' => ini_get('upload_max_filesize'),
+                                                 'post_max_size' => ini_get('post_max_size'),
+                                                 'memory_limit' => ini_get('memory_limit')],
                                'mysql' => ['max_allowed_packet' => $max_allowed_packet]];
 
        $t = get_markup_template('admin/summary.tpl');
@@ -1792,11 +1792,7 @@ function admin_page_users(App $a)
        }
 
        /* get pending */
-       $pending = q("SELECT `register`.*, `contact`.`name`, `user`.`email`
-                                FROM `register`
-                                INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
-                                INNER JOIN `user` ON `register`.`uid` = `user`.`uid`;");
-
+       $pending = Register::getPending();
 
        /* get users */
        $total = q("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
index 2a98d19ffcffaf5d3e3c660252e7f304d8d9572b..7318b77ae9f78c6e3318a3fad8ad32fabb12eb21 100644 (file)
@@ -58,14 +58,9 @@ function invite_post(App $a)
                }
 
                if ($invitation_only && ($invites_remaining || is_site_admin())) {
-                       $code = autoname(8) . srand(1000, 9999);
+                       $code = Friendica\Model\Register::createForInvitation();
                        $nmessage = str_replace('$invite_code', $code, $message);
 
-                       $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ",
-                               DBA::escape($code),
-                               DBA::escape(DateTimeFormat::utcNow())
-                       );
-
                        if (! is_site_admin()) {
                                $invites_remaining --;
                                if ($invites_remaining >= 0) {
index 40eddc3bdd5053afcd93e1581048d4f13f9baf1f..a14379e7096da14cbb13b86fb022c71dbd7a79b3 100644 (file)
@@ -73,6 +73,7 @@ function parse_url_content(App $a)
                                $hdrs[$k] = $v;
                        }
                }
+               $type = null;
                if (array_key_exists('Content-Type', $hdrs)) {
                        $type = $hdrs['Content-Type'];
                }
index ff0139f28f9d3b405f0b148ccf694b8ba03f0171..5ea75727a1152d6d3f12943dcb7b5b9eb684fcbc 100644 (file)
@@ -202,11 +202,7 @@ function ping_init(App $a)
                $mail_count = count($mails);
 
                if (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE && is_site_admin()) {
-                       $regs = q(
-                               "SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`
-                               FROM `contact` RIGHT JOIN `register` ON `register`.`uid` = `contact`.`uid`
-                               WHERE `contact`.`self` = 1"
-                       );
+                       $regs = Friendica\Model\Register::getPending();
 
                        if (DBA::isResult($regs)) {
                                $register_count = count($regs);
index 454062d89b6c90c874f7511a1acd8d0ca003fc93..48fe67afc5a828f56b0e66ebccd6a89acba2765e 100644 (file)
@@ -11,10 +11,8 @@ use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
-use Friendica\Database\DBA;
-use Friendica\Model\User;
+use Friendica\Model;
 use Friendica\Module\Tos;
-use Friendica\Util\DateTimeFormat;
 
 require_once 'include/enotify.php';
 
@@ -67,7 +65,7 @@ function register_post(App $a)
        $arr['language'] = L10n::getBrowserLanguage();
 
        try {
-               $result = User::create($arr);
+               $result = Model\User::create($arr);
        } catch (Exception $e) {
                notice($e->getMessage());
                return;
@@ -76,7 +74,7 @@ function register_post(App $a)
        $user = $result['user'];
 
        if ($netpublish && intval(Config::get('config', 'register_policy')) !== REGISTER_APPROVE) {
-               $url = System::baseUrl() . '/profile/' . $user['nickname'];
+               $url = $a->getBaseUrl() . '/profile/' . $user['nickname'];
                Worker::add(PRIORITY_LOW, "Directory", $url);
        }
 
@@ -86,18 +84,22 @@ function register_post(App $a)
 
        if (intval(Config::get('config', 'register_policy')) === REGISTER_OPEN) {
                if ($using_invites && $invite_id) {
-                       q("delete * from register where hash = '%s' limit 1", DBA::escape($invite_id));
+                       Model\Register::deleteByHash($invite_id);
                        PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites);
                }
 
                // Only send a password mail when the password wasn't manually provided
                if (!x($_POST, 'password1') || !x($_POST, 'confirm')) {
-                       $res = User::sendRegisterOpenEmail(
-                                       $user['email'], Config::get('config', 'sitename'), System::baseUrl(), $user['username'], $result['password'], $user);
+                       $res = Model\User::sendRegisterOpenEmail(
+                               $user,
+                               Config::get('config', 'sitename'),
+                               $a->getBaseUrl(),
+                               $result['password']
+                       );
 
                        if ($res) {
                                info(L10n::t('Registration successful. Please check your email for further instructions.') . EOL);
-                               goaway(System::baseUrl());
+                               goaway();
                        } else {
                                notice(
                                        L10n::t('Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.',
@@ -108,27 +110,19 @@ function register_post(App $a)
                        }
                } else {
                        info(L10n::t('Registration successful.') . EOL);
-                       goaway(System::baseUrl());
+                       goaway();
                }
        } elseif (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE) {
                if (!strlen(Config::get('config', 'admin_email'))) {
                        notice(L10n::t('Your registration can not be processed.') . EOL);
-                       goaway(System::baseUrl());
+                       goaway();
                }
 
-               $hash = random_string();
-               $r = q("INSERT INTO `register` ( `hash`, `created`, `uid`, `password`, `language`, `note` ) VALUES ( '%s', '%s', %d, '%s', '%s', '%s' ) ",
-                       DBA::escape($hash),
-                       DBA::escape(DateTimeFormat::utcNow()),
-                       intval($user['uid']),
-                       DBA::escape($result['password']),
-                       DBA::escape(Config::get('system', 'language')),
-                       DBA::escape($_POST['permonlybox'])
-               );
+               Model\Register::createForApproval($user['uid'], Config::get('system', 'language'), $_POST['permonlybox']);
 
                // invite system
                if ($using_invites && $invite_id) {
-                       q("DELETE * FROM `register` WHERE `hash` = '%s' LIMIT 1", DBA::escape($invite_id));
+                       Model\Register::deleteByHash($invite_id);
                        PConfig::set($user['uid'], 'system', 'invites_remaining', $num_invites);
                }
 
@@ -146,9 +140,9 @@ function register_post(App $a)
                                'source_name'  => $user['username'],
                                'source_mail'  => $user['email'],
                                'source_nick'  => $user['nickname'],
-                               'source_link'  => System::baseUrl() . "/admin/users/",
-                               'link'         => System::baseUrl() . "/admin/users/",
-                               'source_photo' => System::baseUrl() . "/photo/avatar/" . $user['uid'] . ".jpg",
+                               'source_link'  => $a->getBaseUrl() . "/admin/users/",
+                               'link'         => $a->getBaseUrl() . "/admin/users/",
+                               'source_photo' => $a->getBaseUrl() . "/photo/avatar/" . $user['uid'] . ".jpg",
                                'to_email'     => $admin['email'],
                                'uid'          => $admin['uid'],
                                'language'     => $admin['language'] ? $admin['language'] : 'en',
@@ -156,11 +150,15 @@ function register_post(App $a)
                        ]);
                }
                // send notification to the user, that the registration is pending
-               User::sendRegisterPendingEmail(
-                       $user['email'], Config::get('config', 'sitename'), $user['username']);
+               Model\User::sendRegisterPendingEmail(
+                       $user,
+                       Config::get('config', 'sitename'),
+                       $a->getBaseURL(),
+                       $result['password']
+               );
 
                info(L10n::t('Your registration is pending approval by the site owner.') . EOL);
-               goaway(System::baseUrl());
+               goaway();
        }
 
        return;
index 11d8eee412eadd013fb2b0197b825803db8baa2c..3f6f0e04e3253e6073f686548e16450b3374d225 100644 (file)
@@ -9,6 +9,7 @@ use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\Database\DBA;
+use Friendica\Model\Register;
 use Friendica\Model\User;
 use Friendica\Module\Login;
 
@@ -18,51 +19,35 @@ function user_allow($hash)
 {
        $a = get_app();
 
-       $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
-               DBA::escape($hash)
-       );
-
-
+       $register = Register::getByHash($hash);
        if (!DBA::isResult($register)) {
                return false;
        }
 
-       $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
-               intval($register[0]['uid'])
-       );
-
+       $user = User::getById($register['uid']);
        if (!DBA::isResult($user)) {
-               killme();
+               exit();
        }
 
-       $r = q("DELETE FROM `register` WHERE `hash` = '%s'",
-               DBA::escape($register[0]['hash'])
-       );
+       Register::deleteByHash($hash);
 
+       DBA::update('user', ['blocked' => false, 'verified' => true], ['uid' => $register['uid']]);
 
-       $r = q("UPDATE `user` SET `blocked` = 0, `verified` = 1 WHERE `uid` = %d",
-               intval($register[0]['uid'])
-       );
+       $profile = DBA::selectFirst('profile', ['net-publish'], ['uid' => $register['uid'], 'is-default' => true]);
 
-       $r = q("SELECT * FROM `profile` WHERE `uid` = %d AND `is-default` = 1",
-               intval($user[0]['uid'])
-       );
-       if (DBA::isResult($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);
-               }
+       if (DBA::isResult($profile) && $profile['net-publish'] && Config::get('system', 'directory')) {
+               $url = System::baseUrl() . '/profile/' . $user['nickname'];
+               Worker::add(PRIORITY_LOW, "Directory", $url);
        }
 
-       L10n::pushLang($register[0]['language']);
+       L10n::pushLang($register['language']);
 
        $res = User::sendRegisterOpenEmail(
-               $user[0]['email'],
+               $user,
                Config::get('config', 'sitename'),
-               System::baseUrl(),
-               $user[0]['username'],
-               $register[0]['password'],
-               $user[0]);
+               $a->getBaseUrl(),
+               defaults($register, 'password', 'Sent in a previous email')
+       );
 
        L10n::popLang();
 
@@ -77,22 +62,21 @@ function user_allow($hash)
 // allowed to have friends on this system
 function user_deny($hash)
 {
-       $register = q("SELECT * FROM `register` WHERE `hash` = '%s' LIMIT 1",
-               DBA::escape($hash)
-       );
-
+       $register = Register::getByHash($hash);
        if (!DBA::isResult($register)) {
                return false;
        }
 
-       $user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
-               intval($register[0]['uid'])
-       );
+       $user = User::getById($register['uid']);
+       if (!DBA::isResult($user)) {
+               exit();
+       }
+
+       DBA::delete('user', ['uid' => $register['uid']]);
 
-       DBA::delete('user', ['uid' => $register[0]['uid']]);
-       DBA::delete('register', ['hash' => $register[0]['hash']]);
+       Register::deleteByHash($register['hash']);
 
-       notice(L10n::t('Registration revoked for %s', $user[0]['username']) . EOL);
+       notice(L10n::t('Registration revoked for %s', $user['username']) . EOL);
        return true;
 }
 
@@ -100,17 +84,16 @@ function regmod_content(App $a)
 {
        if (!local_user()) {
                info(L10n::t('Please login.') . EOL);
-               $o = '<br /><br />' . Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
-               return $o;
+               return Login::form($a->query_string, intval(Config::get('config', 'register_policy')) === REGISTER_CLOSED ? 0 : 1);
        }
 
-       if ((!is_site_admin()) || (x($_SESSION, 'submanage') && intval($_SESSION['submanage']))) {
+       if (!is_site_admin() || !empty($_SESSION['submanage'])) {
                notice(L10n::t('Permission denied.') . EOL);
                return '';
        }
 
        if ($a->argc != 3) {
-               killme();
+               exit();
        }
 
        $cmd = $a->argv[1];
@@ -118,13 +101,11 @@ function regmod_content(App $a)
 
        if ($cmd === 'deny') {
                user_deny($hash);
-               goaway(System::baseUrl() . "/admin/users/");
-               killme();
+               goaway('admin/users/');
        }
 
        if ($cmd === 'allow') {
                user_allow($hash);
-               goaway(System::baseUrl() . "/admin/users/");
-               killme();
+               goaway('admin/users/');
        }
 }
index c33fa2152fb5aebfd5b9ad84ac04ed4dd3d57776..8fd117e5d2c56f742b399dcf93d8ea2988218317 100644 (file)
@@ -821,7 +821,7 @@ class DBA
         * @param array $param parameter array
         * @param bool $on_duplicate_update Do an update on a duplicate entry
         *
-        * @return boolean was the insert successfull?
+        * @return boolean was the insert successful?
         */
        public static function insert($table, $param, $on_duplicate_update = false) {
 
index 824e240cc36e54edcf7377889a80878ecfbb35d8..097baa658f9bf95642ad169648af266da3955e28 100644 (file)
@@ -380,7 +380,7 @@ class Item extends BaseObject
                        $usermode = true;
                }
 
-               $fields = self::fieldlist($selected, $usermode);
+               $fields = self::fieldlist($usermode);
 
                $select_fields = self::constructSelectFields($fields, $selected);
 
@@ -487,7 +487,7 @@ class Item extends BaseObject
                        $usermode = true;
                }
 
-               $fields = self::fieldlist($selected, $usermode);
+               $fields = self::fieldlist($usermode);
 
                $fields['thread'] = ['mention', 'ignored', 'iid'];
 
@@ -523,7 +523,7 @@ class Item extends BaseObject
         *
         * @return array field list
         */
-       private static function fieldlist($selected, $usermode)
+       private static function fieldlist($usermode)
        {
                $fields = [];
 
@@ -665,11 +665,11 @@ class Item extends BaseObject
                }
 
                if (strpos($sql_commands, "`item-activity`.") !== false) {
-                       $joins .= " LEFT JOIN `item-activity` ON `item-activity`.`id` = `item`.`iaid`";
+                       $joins .= " LEFT JOIN `item-activity` ON `item-activity`.`uri-id` = `item`.`uri-id`";
                }
 
                if (strpos($sql_commands, "`item-content`.") !== false) {
-                       $joins .= " LEFT JOIN `item-content` ON `item-content`.`id` = `item`.`icid`";
+                       $joins .= " LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`";
                }
 
                if (strpos($sql_commands, "`item-delivery-data`.") !== false) {
diff --git a/src/Model/Register.php b/src/Model/Register.php
new file mode 100644 (file)
index 0000000..e54db87
--- /dev/null
@@ -0,0 +1,131 @@
+<?php
+
+/**
+ * @file src/Model/Register.php
+ */
+namespace Friendica\Model;
+
+use Friendica\Database\DBA;
+use Friendica\Util\DateTimeFormat;
+
+/**
+ * Class interacting with the register database table
+ *
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+class Register
+{
+       /**
+        * Return the list of pending registrations
+        *
+        * @return array
+        */
+       public static function getPending()
+       {
+               $stmt = DBA::p(
+                       "SELECT `register`.*, `contact`.`name`, `user`.`email`
+                       FROM `register`
+                       INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid`
+                       INNER JOIN `user` ON `register`.`uid` = `user`.`uid`"
+               );
+
+               return DBA::toArray($stmt);
+       }
+
+       /**
+        * Returns the pending registration count
+        *
+        * @return int
+        */
+       public static function getPendingCount()
+       {
+               $register = DBA::fetchFirst(
+                       "SELECT COUNT(*) AS `count`
+                       FROM `register`
+                       INNER JOIN `contact` ON `register`.`uid` = `contact`.`uid` AND `contact`.`self`"
+               );
+
+               return $register['count'];
+       }
+
+       /**
+        * Returns the register record associated with the provided hash
+        *
+        * @param  string $hash
+        * @return array
+        */
+       public static function getByHash($hash)
+       {
+               return DBA::selectFirst('register', [], ['hash' => $hash]);
+       }
+
+       /**
+        * Returns true if a register record exists with the provided hash
+        *
+        * @param  string  $hash
+        * @return boolean
+        */
+       public static function existsByHash($hash)
+       {
+               return DBA::exists('register', ['hash' => $hash]);
+       }
+
+       /**
+        * Creates a register record for an invitation and returns the auto-generated code for it
+        *
+        * @return string
+        */
+       public static function createForInvitation()
+       {
+               $code = autoname(8) . srand(1000, 9999);
+
+               $fields = [
+                       'hash' => $code,
+                       'created' => DateTimeFormat::utcNow()
+               ];
+
+               DBA::insert('register', $fields);
+
+               return $code;
+       }
+
+       /**
+        * Creates a register record for approval and returns the success of the database insert
+        * Checks for the existence of the provided user id
+        *
+        * @param  integer $uid      The ID of the user needing approval
+        * @param  string  $language The registration language
+        * @param  string  $note     An additional message from the user
+        * @return boolean
+        */
+       public static function createForApproval($uid, $language, $note = '')
+       {
+               $hash = random_string();
+
+               if (!User::exists($uid)) {
+                       return false;
+               }
+
+               $fields = [
+                       'hash'     => $hash,
+                       'created'  => DateTimeFormat::utcNow(),
+                       'uid'      => $uid,
+                       'password' => '', // Obsolete, slated for deletion
+                       'language' => $language,
+                       'note'     => $note
+               ];
+
+               return DBA::insert('register', $fields);
+       }
+
+       /**
+        * Deletes a register record by the provided hash and returns the success of the database deletion
+        *
+        * @param  string  $hash
+        * @return boolean
+        */
+       public static function deleteByHash($hash)
+       {
+               return DBA::delete('register', ['hash' => $hash]);
+       }
+}
index b8b694de87194a6bd6e143c9672c4b49782e9e2d..eb042eb8b44b0115c7217782ca9cbb90896bed33 100644 (file)
@@ -32,9 +32,29 @@ require_once 'include/text.php';
 class User
 {
        /**
-        * @brief Returns the user id of a given profile url
+        * Returns true if a user record exists with the provided id
         *
-        * @param string $profile
+        * @param  integer $uid
+        * @return boolean
+        */
+       public static function exists($uid)
+       {
+               return DBA::exists('user', ['uid' => $uid]);
+       }
+
+       /**
+        * @param  integer       $uid
+        * @return array|boolean User record if it exists, false otherwise
+        */
+       public static function getById($uid)
+       {
+               return DBA::selectFirst('user', [], ['uid' => $uid]);
+       }
+
+       /**
+        * @brief Returns the user id of a given profile URL
+        *
+        * @param string $url
         *
         * @return integer user id
         */
@@ -401,7 +421,7 @@ class User
                                throw new Exception(L10n::t('An invitation is required.'));
                        }
 
-                       if (!DBA::exists('register', ['hash' => $invite_id])) {
+                       if (!Register::existsByHash($invite_id)) {
                                throw new Exception(L10n::t('Invitation could not be verified.'));
                        }
                }
@@ -644,27 +664,36 @@ class User
        }
 
        /**
-        * @brief Sends pending registration confiŕmation email
+        * @brief Sends pending registration confirmation email
         *
-        * @param string $email
+        * @param array  $user     User record array
         * @param string $sitename
-        * @param string $username
+        * @param string $siteurl
+        * @param string $password Plaintext password
         * @return NULL|boolean from notification() and email() inherited
         */
-       public static function sendRegisterPendingEmail($email, $sitename, $username)
+       public static function sendRegisterPendingEmail($user, $sitename, $siteurl, $password)
        {
                $body = deindent(L10n::t('
                        Dear %1$s,
                                Thank you for registering at %2$s. Your account is pending for approval by the administrator.
-               '));
 
-               $body = sprintf($body, $username, $sitename);
+                       Your login details are as follows:
+
+                       Site Location:  %3$s
+                       Login Name:             %4$s
+                       Password:               %5$s
+               ',
+                       $body, $user['username'], $sitename, $siteurl, $user['nickname'], $password
+               ));
 
                return notification([
-                       'type' => SYSTEM_EMAIL,
-                       'to_email' => $email,
-                       'subject'=> L10n::t('Registration at %s', $sitename),
-                       'body' => $body]);
+                       'type'     => SYSTEM_EMAIL,
+                       'uid'      => $user['uid'],
+                       'to_email' => $user['email'],
+                       'subject'  => L10n::t('Registration at %s', $sitename),
+                       'body'     => $body
+               ]);
        }
 
        /**
@@ -672,19 +701,20 @@ class User
         *
         * It's here as a function because the mail is sent from different parts
         *
-        * @param string $email
+        * @param array  $user     User record array
         * @param string $sitename
         * @param string $siteurl
-        * @param string $username
-        * @param string $password
+        * @param string $password Plaintext password
         * @return NULL|boolean from notification() and email() inherited
         */
-       public static function sendRegisterOpenEmail($email, $sitename, $siteurl, $username, $password, $user)
+       public static function sendRegisterOpenEmail($user, $sitename, $siteurl, $password)
        {
                $preamble = deindent(L10n::t('
                        Dear %1$s,
                                Thank you for registering at %2$s. Your account has been created.
-               '));
+               ',
+                       $preamble, $user['username'], $sitename
+               ));
                $body = deindent(L10n::t('
                        The login details are as follows:
 
@@ -711,19 +741,19 @@ class User
 
                        If you ever want to delete your account, you can do so at %3$s/removeme
 
-                       Thank you and welcome to %2$s.'));
-
-               $preamble = sprintf($preamble, $username, $sitename);
-               $body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
+                       Thank you and welcome to %2$s.',
+                       $body, $user['email'], $sitename, $siteurl, $user['username'], $password
+               ));
 
                return notification([
-                       'uid' => $user['uid'],
+                       'uid'      => $user['uid'],
                        'language' => $user['language'],
-                       'type' => SYSTEM_EMAIL,
-                       'to_email' => $email,
-                       'subject'=> L10n::t('Registration details for %s', $sitename),
-                       'preamble'=> $preamble,
-                       'body' => $body]);
+                       'type'     => SYSTEM_EMAIL,
+                       'to_email' => $user['email'],
+                       'subject'  => L10n::t('Registration details for %s', $sitename),
+                       'preamble' => $preamble,
+                       'body'     => $body
+               ]);
        }
 
        /**
@@ -760,7 +790,7 @@ class User
                if ($uid == local_user()) {
                        unset($_SESSION['authenticated']);
                        unset($_SESSION['uid']);
-                       goaway(System::baseUrl());
+                       goaway();;
                }
        }
 }
index 04da5fa596ea0858a6468a154eac71fba2b33833..a5ba0763db56a05bd83dd9abdce5b3e5c45921e1 100644 (file)
@@ -461,7 +461,7 @@ class Receiver
 
                logger('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub');
 
-               $photo = $profile['photo'];
+               $photo = defaults($profile, 'photo', null);
                unset($profile['photo']);
                unset($profile['baseurl']);
 
@@ -478,7 +478,7 @@ class Receiver
        }
 
        /**
-        * 
+        *
         *
         * @param $receivers
         * @param $actor
@@ -503,12 +503,12 @@ class Receiver
        }
 
        /**
-        * 
+        *
         *
         * @param $object_data
         * @param array $activity
         *
-        * @return 
+        * @return
         */
        private static function addActivityFields($object_data, $activity)
        {
index 00f4e1702d643779c6930f494dacc0b71882db62..0c3a52b2d3810ede4ce05e3348773486d8fda19a 100644 (file)
@@ -949,6 +949,7 @@ class Diaspora
                                $person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]);
                                if (!DBA::isResult($person)) {
                                        $person = $r;
+                                       $person['id'] = 0;
                                }
                        }
                }
@@ -3429,12 +3430,9 @@ class Diaspora
                /// @todo - establish "all day" events in Friendica
                $eventdata["all_day"] = "false";
 
-               if (!$event['adjust']) {
+               $eventdata['timezone'] = 'UTC';
+               if (!$event['adjust'] && $user['timezone']) {
                        $eventdata['timezone'] = $user['timezone'];
-
-                       if ($eventdata['timezone'] == "") {
-                               $eventdata['timezone'] = 'UTC';
-                       }
                }
 
                if ($event['start']) {
index f2a5eccd395247956c9e39a4e22c037d9c0567fa..24089b9cbd2a92bb33c22fe4e41ee3b501987cff 100644 (file)
@@ -141,7 +141,7 @@ class ParseUrl
                }
 
                // If the file is too large then exit
-               if ($curlResult->getInfo()['download_content_length'] > 1000000) {
+               if (defaults($curlResult->getInfo(), 'download_content_length', 0) > 1000000) {
                        return $siteinfo;
                }
 
index f2951cce1ff2bf13deb7aec6e112f16bfcb655f8..1c353fb6327e8da4e3621e8344f7eaea51bb96d1 100644 (file)
@@ -39,13 +39,13 @@ class Delivery extends BaseObject
                $followup = false;
                $public_message = false;
 
+               $items = [];
                if ($cmd == self::MAIL) {
                        $target_item = DBA::selectFirst('mail', [], ['id' => $item_id]);
                        if (!DBA::isResult($target_item)) {
                                return;
                        }
                        $uid = $target_item['uid'];
-                       $items = [];
                } elseif ($cmd == self::SUGGESTION) {
                        $target_item = DBA::selectFirst('fsuggest', [], ['id' => $item_id]);
                        if (!DBA::isResult($target_item)) {
@@ -65,7 +65,6 @@ class Delivery extends BaseObject
                        $params = ['order' => ['id']];
                        $itemdata = Item::select([], $condition, $params);
 
-                       $items = [];
                        while ($item = Item::fetch($itemdata)) {
                                if ($item['id'] == $parent_id) {
                                        $parent = $item;
index 56f285f2df9037f8f2dc405258f7bd51f495554b..d889e241e22061f56b549857a82995ce023c8957 100644 (file)
@@ -246,3 +246,12 @@ function update_1278() {
 
        return UPDATE_SUCCESS;
 }
+
+function update_1288() {
+       // Updates missing `uri-id` values
+
+       DBA::e("UPDATE `item-activity` INNER JOIN `item` ON `item`.`iaid` = `item-activity`.`id` SET `item-activity`.`uri-id` = `item`.`uri-id` WHERE `item-activity`.`uri-id` IS NULL OR `item-activity`.`uri-id` = 0");
+       DBA::e("UPDATE `item-content` INNER JOIN `item` ON `item`.`icid` = `item-content`.`id` SET `item-content`.`uri-id` = `item`.`uri-id` WHERE `item-content`.`uri-id` IS NULL OR `item-content`.`uri-id` = 0");
+
+       return UPDATE_SUCCESS;
+}
index 344ee296a2056f244c3992c2341b38957cda5fd5..b4c34f74e2ca3a08f7ca52207837f963f0143856 100644 (file)
@@ -5,7 +5,7 @@
 
 
        <div id="contact-edit-nav-wrapper" >
-               <form action="contacts/{{$contact_id}}" method="post" >
+               <form action="contact/{{$contact_id}}" method="post" >
                        <div id="contact-edit-links">
                                <div id="contact-edit-status-wrapper">
                                        <span id="contact-edit-contact-status">{{$contact_status}}</span>
index 4c12948dcef1b3d88d6d5b9e3385bd322b10e1b0..04426eeb12aa5b799d2cc2af2e1b1ae141d0c245 100644 (file)
@@ -9,7 +9,7 @@
 
 
                <div id="contact-edit-content-wrapper">
-                       <form action="contacts/{{$contact_id}}" method="post" >
+                       <form action="contact/{{$contact_id}}" method="post" >
 
                                {{* This is the Action menu where contact related actions like 'ignore', 'hide' can be performed *}}
                                <ul id="contact-edit-actions" class="nav nav-pills preferences">
index 63069a772138a48ecddaf8cd9bcae3496bd45938..9014be1d252356f5ee5d435ec8548d3cb98fbf6b 100644 (file)
@@ -6,7 +6,7 @@
 
 
        <div id="contact-edit-nav-wrapper" >
-               <form action="contacts/{{$contact_id}}" method="post" >
+               <form action="contact/{{$contact_id}}" method="post" >
                        <div id="contact-edit-links">
                                <div id="contact-edit-status-wrapper">
                                        <span id="contact-edit-contact-status">{{$contact_status}}</span>