Merge branch 'master' into develop

This commit is contained in:
Lucas Bartholemy 2021-03-17 17:00:36 +01:00
commit 7c1deaaf1e
11 changed files with 182 additions and 29 deletions

View File

@ -1,13 +1,26 @@
HumHub Changelog
================
1.8.1 (Unreleased)
---------------------
1.8.2 (Unreleased)
-------------------
- Fix #4959: Horizontal scrollbar for images
- Fix #4898: No streamExcludes option when loading single stream entry
1.8.1 (March 12, 2021)
----------------------
- Fix #4931: Fix highlight parent navigations for sub section "Profile Permissions" (and LDAP)
- Fix #4934: Show error instead of warning when using different MySQL Table Engines
- Fix #4936: Fix emoji in sample content
- Fix #4940: Typo in German translation "Benachrichtigungen"
- Fix #4942: MemberOf Display in LDAP CLI Show User Details
- Fix #4465: LDAP PHP 8 incompatibility (multiPageSearch)
- Enh #4569: Config to overwrite module path
- Fix #4946: Fix migration of the default permissions
- Fix #4955: Fix convert emoji with sign "+"
- Fix #4956: Fix file hash column length
1.8.0 (March 1, 2021)

View File

@ -80,6 +80,19 @@ class ModuleManager extends Component
*/
protected $coreModules = [];
/**
* @var bool Prevent registration of several different modules with the same id.
*/
public $preventDuplicatedModules = true;
/**
* List of module paths that should be overwritten
* Key - module id, Value - absolute path to module folder
*
* @var array
*/
public $overwriteModuleBasePath = [];
/**
* Module Manager init
*

View File

@ -75,7 +75,7 @@ class ModuleAutoLoader implements BootstrapInterface
try {
/** @noinspection PhpIncludeInspection */
$moduleConfig = require $folder . DIRECTORY_SEPARATOR . self::CONFIGURATION_FILE;
if (isset($moduleIdFolders[$moduleConfig['id']])) {
if (Yii::$app->moduleManager->preventDuplicatedModules && isset($moduleIdFolders[$moduleConfig['id']])) {
Yii::error('Duplicated module "' . $moduleConfig['id'] . '"(' . $folder . ') is already loaded from the folder "' . $moduleIdFolders[$moduleConfig['id']] . '"');
} else {
$modules[$folder] = $moduleConfig;
@ -86,6 +86,25 @@ class ModuleAutoLoader implements BootstrapInterface
}
}
if (Yii::$app->moduleManager->preventDuplicatedModules) {
// Overwrite module paths from config
foreach (Yii::$app->moduleManager->overwriteModuleBasePath as $overwriteModuleId => $overwriteModulePath) {
if (isset($moduleIdFolders[$overwriteModuleId]) && $moduleIdFolders[$overwriteModuleId] != $overwriteModulePath) {
try {
$moduleConfig = require $overwriteModulePath . DIRECTORY_SEPARATOR . self::CONFIGURATION_FILE;
Yii::info('Overwrite path of the module "' . $overwriteModuleId . '" to the folder "' . $overwriteModulePath . '"');
// Remove original config
unset($modules[$moduleIdFolders[$overwriteModuleId]]);
// Use config from the overwritten path
$modules[$overwriteModulePath] = $moduleConfig;
$moduleIdFolders[$overwriteModuleId] = $overwriteModulePath;
} catch (\Throwable $e) {
Yii::error($e);
}
}
}
}
return $modules;
}

View File

@ -13,15 +13,29 @@ class m201130_073907_default_permissions extends Migration
*/
public function safeUp()
{
$this->createTable('contentcontainer_default_permission', [
'permission_id' => $this->string(150)->notNull(),
'contentcontainer_class' => $this->char(60)->notNull(),
'group_id' => $this->string(50)->notNull(),
'module_id' => $this->string(50)->notNull(),
'class' => Schema::TYPE_STRING,
'state' => Schema::TYPE_BOOLEAN,
]);
$this->addPrimaryKey('contentcontainer_default_permission_pk', 'contentcontainer_default_permission', ['permission_id', 'group_id', 'module_id', 'contentcontainer_class']);
$table = 'contentcontainer_default_permission';
$primaryKey = $table . '_pk';
if ($this->tableExists($table)) {
// Make sure the column has a correct length because in first version it had a wrong length 255 chars so PK couldn't be created
$this->alterColumn($table, 'contentcontainer_class', $this->char(60)->notNull());
} else {
$this->createTable($table, [
'permission_id' => $this->string(150)->notNull(),
'contentcontainer_class' => $this->char(60)->notNull(),
'group_id' => $this->string(50)->notNull(),
'module_id' => $this->string(50)->notNull(),
'class' => Schema::TYPE_STRING,
'state' => Schema::TYPE_BOOLEAN,
]);
}
if ($this->primaryKeyExists($table)) {
// Remove old(probably wrong) primary key
$this->dropPrimaryKey($primaryKey, $table);
}
$this->addPrimaryKey($primaryKey, $table, ['permission_id', 'group_id', 'module_id', 'contentcontainer_class']);
}
/**
@ -31,4 +45,26 @@ class m201130_073907_default_permissions extends Migration
{
$this->dropTable('contentcontainer_default_permission');
}
/**
* Check if the table already exists
*
* @param string $table Table name
* @return bool
*/
protected function tableExists($table)
{
return Yii::$app->getDb()->getSchema()->getTableSchema($table) !== null;
}
/**
* Check if the table has a primary key
*
* @param string $table Table name
* @return bool
*/
protected function primaryKeyExists($table)
{
return !empty(Yii::$app->getDb()->getSchema()->getTableSchema($table)->primaryKey);
}
}

View File

@ -20,7 +20,7 @@ class RichTextEmojiExtension extends RichTextContentExtension
/**
* @inheritdoc
*/
const REGEX = '/[:|;](([A-Za-z0-9_-])+)[:|;]/';
const REGEX = '/[:|;](([A-Za-z0-9_\-+])+)[:|;]/';
/**
* @inheritdoc

View File

@ -0,0 +1,28 @@
<?php
use yii\db\Migration;
/**
* Class m210310_103412_fix_hash
*/
class m210310_103412_fix_hash extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->update('file', ['hash_sha1' => NULL]);
$this->alterColumn('file', 'hash_sha1', $this->string(40)->null());
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
echo "m210310_103412_fix_hash cannot be reverted.\n";
return false;
}
}

View File

@ -264,7 +264,7 @@ class LdapController extends \yii\console\Controller
$rows = [];
foreach ($x->getUserAttributes() as $name => $value) {
if (empty(mb_detect_encoding($value))) {
if (!is_array($value) && empty(mb_detect_encoding($value))) {
$value = '-Binary-';
}
$rows[] = [$name, $value];

View File

@ -83,20 +83,26 @@ class ZendLdap extends Ldap
ErrorHandler::start(E_WARNING);
$cookie = '';
$results = [];
do {
ldap_control_paged_result($resource, $pageSize, true, $cookie);
$result = ldap_search($resource, $basedn, $filter,
$attributes
);
foreach (ldap_get_entries($resource, $result) as $item) {
if (!is_array($item))
continue;
if (version_compare(PHP_VERSION, '7.3') >= 0) {
$results = $this->ldapSearchPaged($resource, $basedn, $filter, $attributes, 0, $pageSize, $timelimit);
} else {
do {
ldap_control_paged_result($resource, $pageSize, true, $cookie);
array_push($results, (array)$item);
}
ldap_control_paged_result_response($resource, $result, $cookie);
} while ($cookie);
$result = ldap_search($resource, $basedn, $filter,
$attributes
);
foreach (ldap_get_entries($resource, $result) as $item) {
if (!is_array($item))
continue;
array_push($results, (array)$item);
}
ldap_control_paged_result_response($resource, $result, $cookie);
} while ($cookie);
}
ErrorHandler::stop();
if (count($results) == 0) {
throw new Exception\LdapException($this, 'searching: ' . $filter);
@ -104,4 +110,39 @@ class ZendLdap extends Ldap
return $results;
}
private function ldapSearchPaged($resource, $basedn, $filter, $attributes, $attributesOnly, $sizelimit, $timelimit)
{
$results = [];
$cookie = '';
// define("LDAP_CONTROL_PAGEDRESULTS", "1.2.840.113556.1.4.319");
do {
$result = ldap_search($resource, $basedn, $filter, $attributes, $attributesOnly, 0, $timelimit, null,
[['oid' => '1.2.840.113556.1.4.319', 'value' => ['size' => $sizelimit, 'cookie' => $cookie]]]
);
$errCode = $dn = $errMsg = $refs = null;
ldap_parse_result($resource, $result, $errCode, $dn, $errMsg, $refs, $controls);
foreach (ldap_get_entries($resource, $result) as $item) {
if (!is_array($item)) {
continue;
}
array_push($results, (array)$item);
}
if (isset($controls['1.2.840.113556.1.4.319']['value']['cookie'])) {
$cookie = $controls['1.2.840.113556.1.4.319']['value']['cookie'];
} else {
$cookie = '';
}
} while (!empty($cookie));
return $results;
}
}

View File

@ -189,7 +189,11 @@ abstract class Stream extends Action
$this->user = Yii::$app->user->identity;
}
$this->excludes = array_merge($this->excludes, Yii::$app->getModule('stream')->streamExcludes);
$streamQueryParams = Yii::$app->request->getQueryParam('StreamQuery');
if (empty($streamQueryParams['contentId'])) {
$this->excludes = array_merge($this->excludes, Yii::$app->getModule('stream')->streamExcludes);
}
$this->streamQuery = $this->initQuery();

View File

@ -167,7 +167,6 @@
img:not(.center-block) {
max-width: 100%;
margin: 0 5px;
}
img.pull-right {

File diff suppressed because one or more lines are too long