Merge branch 'develop' into item-activities

This commit is contained in:
Michael Vogel 2018-07-08 06:35:50 +02:00 committed by GitHub
commit ff5ee74ecf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
60 changed files with 2256 additions and 748 deletions

View file

@ -61,7 +61,7 @@ class Conversation
unset($old_conv['source']);
}
// Update structure data all the time but the source only when its from a better protocol.
if (($old_conv['protocol'] < $conversation['protocol']) && ($old_conv['protocol'] != 0)) {
if (isset($conversation['protocol']) && isset($conversation['source']) && ($old_conv['protocol'] < $conversation['protocol']) && ($old_conv['protocol'] != 0)) {
unset($conversation['protocol']);
unset($conversation['source']);
}

View file

@ -6,26 +6,22 @@
namespace Friendica\Model;
use dba;
use Friendica\BaseObject;
use Friendica\Content\Text;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\Lock;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Group;
use Friendica\Model\Term;
use Friendica\Object\Image;
use Friendica\Protocol\Diaspora;
use Friendica\Protocol\OStatus;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\XML;
use Friendica\Util\Lock;
use dba;
use Text_LanguageDetect;
require_once 'boot.php';
@ -940,7 +936,9 @@ class Item extends BaseObject
// If item has attachments, drop them
foreach (explode(", ", $item['attach']) as $attach) {
preg_match("|attach/(\d+)|", $attach, $matches);
dba::delete('attach', ['id' => $matches[1], 'uid' => $item['uid']]);
if (is_array($matches) && count($matches) > 1) {
dba::delete('attach', ['id' => $matches[1], 'uid' => $item['uid']]);
}
}
// Delete tags that had been attached to other items
@ -1773,7 +1771,7 @@ class Item extends BaseObject
}
// To avoid timing problems, we are using locks.
$locked = Lock::set('item_insert_content');
$locked = Lock::acquire('item_insert_content');
if (!$locked) {
logger("Couldn't acquire lock for URI " . $item['uri'] . " - proceeding anyway.");
}
@ -1793,7 +1791,7 @@ class Item extends BaseObject
logger('Could not insert content for URI ' . $item['uri'] . ' - trying asynchronously');
}
if ($locked) {
Lock::remove('item_insert_content');
Lock::release('item_insert_content');
}
}
@ -2208,7 +2206,7 @@ class Item extends BaseObject
Contact::unmarkForArchival($contact);
}
$update = (!$arr['private'] && (($arr["author-link"] === $arr["owner-link"]) || ($arr["parent-uri"] === $arr["uri"])));
$update = (!$arr['private'] && ((defaults($arr, 'author-link', '') === defaults($arr, 'owner-link', '')) || ($arr["parent-uri"] === $arr["uri"])));
// Is it a forum? Then we don't care about the rules from above
if (!$update && ($arr["network"] == NETWORK_DFRN) && ($arr["parent-uri"] === $arr["uri"])) {

View file

@ -304,6 +304,33 @@ class User
return dba::update('user', $fields, ['uid' => $uid]);
}
/**
* @brief Checks if a nickname is in the list of the forbidden nicknames
*
* Check if a nickname is forbidden from registration on the node by the
* admin. Forbidden nicknames (e.g. role namess) can be configured in the
* admin panel.
*
* @param string $nickname The nickname that should be checked
* @return boolean True is the nickname is blocked on the node
*/
public static function isNicknameBlocked($nickname)
{
$forbidden_nicknames = Config::get('system', 'forbidden_nicknames', '');
// if the config variable is empty return false
if (!x($forbidden_nicknames)) {
return false;
}
// check if the nickname is in the list of blocked nicknames
$forbidden = explode(',', $forbidden_nicknames);
$forbidden = array_map('trim', $forbidden);
if (in_array(strtolower($nickname), $forbidden)) {
return true;
}
// else return false
return false;
}
/**
* @brief Catch-all user creation function
*
@ -417,6 +444,9 @@ class User
if (!valid_email($email) || !Network::isEmailDomainValid($email)) {
throw new Exception(L10n::t('Not a valid email address.'));
}
if (self::isNicknameBlocked($nickname)) {
throw new Exception(L10n::t('The nickname was blocked from registration by the nodes admin.'));
}
if (Config::get('system', 'block_extended_register', false) && dba::exists('user', ['email' => $email])) {
throw new Exception(L10n::t('Cannot use that email.'));