mirror of
https://github.com/humhub/humhub.git
synced 2025-02-24 19:23:21 +01:00
Merge branch 'v1.3-dev' into patch-1
This commit is contained in:
commit
8a8b20ad64
40
protected/humhub/Yii.php
Normal file
40
protected/humhub/Yii.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file used for enhanced IDE code autocompletion only.
|
||||
* NOTE: To avoid warning of multiple autocompletion you should mark the file protected\vendor\yiisoft\yii2\Yii.php
|
||||
* as a plain text file for your IDE
|
||||
* @see https://github.com/samdark/yii2-cookbook/blob/master/book/ide-autocompletion.md#using-custom-yii-class
|
||||
*/
|
||||
class Yii extends \yii\BaseYii
|
||||
{
|
||||
/**
|
||||
* @var BaseApplication|WebApplication|ConsoleApplication the application instance
|
||||
*/
|
||||
public static $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class BaseApplication
|
||||
* Used for properties that are identical for both WebApplication and ConsoleApplication
|
||||
* @property-read \humhub\components\ModuleManager $moduleManager
|
||||
*/
|
||||
abstract class BaseApplication extends yii\base\Application
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WebApplication
|
||||
* Include only Web application related components here
|
||||
*/
|
||||
class WebApplication extends \humhub\components\Application
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Class ConsoleApplication
|
||||
* Include only Console application related components here
|
||||
*/
|
||||
class ConsoleApplication extends \humhub\components\console\Application
|
||||
{
|
||||
}
|
@ -38,4 +38,5 @@ HumHub Change Log - v1.3-dev Branch
|
||||
- Enh: Ensure valid permalinks when URL rewriting is enabled
|
||||
- Fix: Birthday field refactoring (@danielkesselberg)
|
||||
- Enh #2811: Added option to resend invites (@danielkesselberg)
|
||||
- Enh: Added current database name to the "Administration -> Information -> Database" (githubjeka)
|
||||
- Enh/Fix: Cache Handling + File Preview Fix (@Felli)
|
||||
|
36
protected/humhub/modules/admin/components/DatabaseInfo.php
Normal file
36
protected/humhub/modules/admin/components/DatabaseInfo.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\admin\components;
|
||||
|
||||
/**
|
||||
* @since 1.3
|
||||
*/
|
||||
class DatabaseInfo
|
||||
{
|
||||
/** @var string */
|
||||
private $pdoDSN;
|
||||
|
||||
public function __construct($pdoDSN)
|
||||
{
|
||||
$this->pdoDSN = $pdoDSN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDatabaseName()
|
||||
{
|
||||
$databaseName = '';
|
||||
if (preg_match('/dbname=([^;]*)/', $this->pdoDSN, $match)) {
|
||||
$databaseName = $match[1];
|
||||
}
|
||||
|
||||
return $databaseName;
|
||||
}
|
||||
}
|
@ -8,9 +8,10 @@
|
||||
|
||||
namespace humhub\modules\admin\controllers;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\admin\components\Controller;
|
||||
use humhub\modules\admin\components\DatabaseInfo;
|
||||
use humhub\modules\admin\libs\HumHubAPI;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* Informations
|
||||
@ -42,7 +43,7 @@ class InformationController extends Controller
|
||||
public function getAccessRules()
|
||||
{
|
||||
return [
|
||||
['permissions' => \humhub\modules\admin\permissions\SeeAdminInformation::className()]
|
||||
['permissions' => \humhub\modules\admin\permissions\SeeAdminInformation::class],
|
||||
];
|
||||
}
|
||||
|
||||
@ -62,7 +63,7 @@ class InformationController extends Controller
|
||||
'currentVersion' => Yii::$app->version,
|
||||
'latestVersion' => $latestVersion,
|
||||
'isNewVersionAvailable' => $isNewVersionAvailable,
|
||||
'isUpToDate' => $isUpToDate
|
||||
'isUpToDate' => $isUpToDate,
|
||||
]);
|
||||
}
|
||||
|
||||
@ -73,7 +74,15 @@ class InformationController extends Controller
|
||||
|
||||
public function actionDatabase()
|
||||
{
|
||||
return $this->render('database', ['migrate' => \humhub\commands\MigrateController::webMigrateAll()]);
|
||||
$databaseInfo = new DatabaseInfo(Yii::$app->db->dsn);
|
||||
|
||||
return $this->render(
|
||||
'database',
|
||||
[
|
||||
'databaseName' => $databaseInfo->getDatabaseName(),
|
||||
'migrate' => \humhub\commands\MigrateController::webMigrateAll(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -93,7 +102,7 @@ class InformationController extends Controller
|
||||
return $this->render('cronjobs', [
|
||||
'lastRunHourly' => $lastRunHourly,
|
||||
'lastRunDaily' => $lastRunDaily,
|
||||
'currentUser' => $currentUser
|
||||
'currentUser' => $currentUser,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ class SpaceSearch extends Space
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
public function getVisibilityAttributes()
|
||||
public static function getVisibilityAttributes()
|
||||
{
|
||||
$countPublic = Space::find()->where(['visibility' => Space::VISIBILITY_ALL])->orWhere(['visibility' => Space::VISIBILITY_REGISTERED_ONLY])->count();
|
||||
$countPrivate = Space::find()->where(['visibility' => Space::VISIBILITY_NONE])->count();
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace humhub\modules\admin\tests\codeception\unit;
|
||||
|
||||
use Codeception\Test\Unit;
|
||||
use humhub\modules\admin\components\DatabaseInfo;
|
||||
|
||||
class DatabaseInfoTest extends Unit
|
||||
{
|
||||
public function testGetDatabaseNameByMysqlDsn()
|
||||
{
|
||||
$data = [
|
||||
'humhub_demo1' => 'mysql:host=127.0.0.1;dbname=humhub_demo1',
|
||||
'humhub_demo3' => 'mysql:host=127.0.0.1;port:3310;dbname=humhub_demo3',
|
||||
'testdb1' => 'mysql:host=localhost;dbname=testdb1',
|
||||
'testdb2' => 'mysql:host=localhost;port=3307;dbname=testdb2',
|
||||
'testdb3' => 'mysql:unix_socket=/tmp/mysql.sock;dbname=testdb3',
|
||||
'testdb4' => 'mysql:unix_socket=/tmp/mysql.sock;dbname=testdb4;charset=utf8',
|
||||
];
|
||||
|
||||
foreach ($data as $name => $dsn) {
|
||||
$dbInfo = new DatabaseInfo($dsn);
|
||||
$this->assertEquals($name, $dbInfo->getDatabaseName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2017 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
/**
|
||||
* @var $this \humhub\components\View
|
||||
* @var $databaseName string
|
||||
* @var $migrate string
|
||||
*/
|
||||
?>
|
||||
<div>
|
||||
<p>
|
||||
<?= \Yii::t('base', 'The current main HumHub database name is ') ?>
|
||||
<i><b><?= \yii\helpers\Html::encode($databaseName) ?></b></i>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<p>Database migration results:</p>
|
||||
|
||||
<div class="well">
|
||||
@ -5,4 +25,3 @@
|
||||
<?= $migrate; ?>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
@ -68,7 +68,7 @@ class MembershipSearch extends Membership
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
*
|
||||
* @param array $params
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
@ -127,7 +127,7 @@ class MembershipSearch extends Membership
|
||||
if (!empty($this->group_id)) {
|
||||
$query->andFilterWhere(['space_membership.group_id' => $this->group_id]);
|
||||
}
|
||||
|
||||
|
||||
$query->andFilterWhere(['space_membership.group_id' => $this->group_id]);
|
||||
$query->andFilterWhere(['like', 'profile.lastname', $this->getAttribute('user.profile.lastname')]);
|
||||
$query->andFilterWhere(['like', 'profile.firstname', $this->getAttribute('user.profile.firstname')]);
|
||||
@ -136,7 +136,7 @@ class MembershipSearch extends Membership
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
public function getRoles(Space $space)
|
||||
public static function getRoles(Space $space)
|
||||
{
|
||||
$groups = $space->getUserGroups();
|
||||
unset($groups[Space::USERGROUP_OWNER], $groups[Space::USERGROUP_GUEST], $groups[Space::USERGROUP_USER]);
|
||||
|
1
protected/humhub/tests/codeception/_support/.gitignore
vendored
Normal file
1
protected/humhub/tests/codeception/_support/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
_generated
|
Loading…
x
Reference in New Issue
Block a user