From f596686abb4aa13c40f8cfa0c89098a0985313ed Mon Sep 17 00:00:00 2001 From: Lucas Bartholemy Date: Mon, 6 Jun 2016 10:41:13 +0200 Subject: [PATCH 1/2] Doc adjustments --- protected/humhub/docs/guide/README.md | 4 +--- protected/humhub/docs/guide/admin-adv-config.md | 8 +------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/protected/humhub/docs/guide/README.md b/protected/humhub/docs/guide/README.md index 124cd78dcc..e6cb817b2d 100644 --- a/protected/humhub/docs/guide/README.md +++ b/protected/humhub/docs/guide/README.md @@ -16,10 +16,8 @@ Getting Started Administration --------------------- -* [User](admin-user.md) -* [Spaces](admin-spaces.md) -* [Authentication](admin-authentication.md) * [Advanced Configuration](admin-adv-config.md) +* [Authentication](admin-authentication.md) * [Console](admin-adv-console.md) * [Search](admin-adv-search.md) * [XSendFile](admin-adv-xsendfile.md) diff --git a/protected/humhub/docs/guide/admin-adv-config.md b/protected/humhub/docs/guide/admin-adv-config.md index 6da62bd696..035b6d6658 100644 --- a/protected/humhub/docs/guide/admin-adv-config.md +++ b/protected/humhub/docs/guide/admin-adv-config.md @@ -31,7 +31,7 @@ You can overwrite the default HumHub / Yii configuration in the folder `/protect ## Configurations -# Language +### Language **Restrict Languages:** @@ -72,9 +72,3 @@ return array ( 'What\'s on your mind?' => 'Wie geht es dir heute?', ); ``` - -# Further available params - -The following params are available to ch - - - **moduleAutoloadPaths** - Can be used to change the path of your modules folder From 73c2c6afc6fb11ae5b8a7be4c9b1f19fc9d6c03e Mon Sep 17 00:00:00 2001 From: Lucas Bartholemy Date: Tue, 7 Jun 2016 11:36:36 +0200 Subject: [PATCH 2/2] Improved space membership listing (sort order) --- .../controllers/MembershipController.php | 12 ++++------ .../modules/space/models/Membership.php | 21 ++++++++++++++++ .../humhub/modules/space/widgets/Members.php | 8 +++---- .../modules/space/widgets/views/members.php | 19 +++++++-------- .../user/components/ActiveQueryUser.php | 24 ++++++++++++++----- 5 files changed, 54 insertions(+), 30 deletions(-) diff --git a/protected/humhub/modules/space/controllers/MembershipController.php b/protected/humhub/modules/space/controllers/MembershipController.php index 51feb2e679..ef85b7771c 100644 --- a/protected/humhub/modules/space/controllers/MembershipController.php +++ b/protected/humhub/modules/space/controllers/MembershipController.php @@ -248,16 +248,12 @@ class MembershipController extends \humhub\modules\content\components\ContentCon */ public function actionMembersList() { - $query = User::find(); - $query->join('LEFT JOIN', 'space_membership', 'space_membership.user_id=user.id'); - $query->andWhere(['space_membership.status' => Membership::STATUS_MEMBER]); - $query->andWhere(['user.status' => User::STATUS_ENABLED]); - $query->andWhere(['space_id' => $this->getSpace()->id]); - $query->orderBy(['space_membership.group_id' => SORT_DESC]); - $title = Yii::t('SpaceModule.controllers_MembershipController', "Members"); - return $this->renderAjaxContent(UserListBox::widget(['query' => $query, 'title' => $title])); + return $this->renderAjaxContent(UserListBox::widget([ + 'query' => Membership::getSpaceMembersQuery($this->getSpace()), + 'title' => $title + ])); } } diff --git a/protected/humhub/modules/space/models/Membership.php b/protected/humhub/modules/space/models/Membership.php index e3c9da1558..91271ea5bb 100644 --- a/protected/humhub/modules/space/models/Membership.php +++ b/protected/humhub/modules/space/models/Membership.php @@ -3,6 +3,7 @@ namespace humhub\modules\space\models; use Yii; +use humhub\modules\user\models\User; use humhub\modules\content\models\WallEntry; use humhub\modules\activity\models\Activity; use humhub\modules\comment\models\Comment; @@ -176,4 +177,24 @@ class Membership extends \yii\db\ActiveRecord return $query; } + /** + * Returns a user query for space memberships + * + * @since 1.1 + * @param Space $space + * @param boolean $membersOnly Only return approved members + * @return \humhub\modules\user\components\ActiveQueryUser + */ + public static function getSpaceMembersQuery($space, $membersOnly = true) + { + $query = User::find()->active(); + $query->join('LEFT JOIN', 'space_membership', 'space_membership.user_id=user.id'); + if ($membersOnly) { + $query->andWhere(['space_membership.status' => self::STATUS_MEMBER]); + } + $query->andWhere(['space_id' => $space->id]); + $query->defaultOrder(); + return $query; + } + } diff --git a/protected/humhub/modules/space/widgets/Members.php b/protected/humhub/modules/space/widgets/Members.php index 1722194b82..d2f0f05907 100644 --- a/protected/humhub/modules/space/widgets/Members.php +++ b/protected/humhub/modules/space/widgets/Members.php @@ -34,12 +34,10 @@ class Members extends Widget */ public function run() { - $memberQuery = $this->space->getMemberships(); - $memberQuery->joinWith('user'); - $memberQuery->limit($this->maxMembers); - $memberQuery->where(['user.status' => \humhub\modules\user\models\User::STATUS_ENABLED]); + $query = \humhub\modules\space\models\Membership::getSpaceMembersQuery($this->space); + $query->limit($this->maxMembers); - return $this->render('members', ['space' => $this->space, 'maxMembers' => $this->maxMembers, 'members' => $memberQuery->all()]); + return $this->render('members', ['space' => $this->space, 'maxMembers' => $this->maxMembers, 'users' => $query->all()]); } } diff --git a/protected/humhub/modules/space/widgets/views/members.php b/protected/humhub/modules/space/widgets/views/members.php index 93cc719599..6e4dc1c6e3 100644 --- a/protected/humhub/modules/space/widgets/views/members.php +++ b/protected/humhub/modules/space/widgets/views/members.php @@ -7,18 +7,15 @@ use yii\helpers\Html; 'space-members-panel']); ?>
Space members'); ?>
- - user; ?> - status === \humhub\modules\space\models\Membership::STATUS_MEMBER) : ?> - - 24x24 - - + + + 24x24 + - +
diff --git a/protected/humhub/modules/user/components/ActiveQueryUser.php b/protected/humhub/modules/user/components/ActiveQueryUser.php index 2f5793208a..591948c4f7 100644 --- a/protected/humhub/modules/user/components/ActiveQueryUser.php +++ b/protected/humhub/modules/user/components/ActiveQueryUser.php @@ -2,7 +2,7 @@ /** * @link https://www.humhub.org/ - * @copyright Copyright (c) 2015 HumHub GmbH & Co. KG + * @copyright Copyright (c) 2016 HumHub GmbH & Co. KG * @license https://www.humhub.com/licences */ @@ -18,15 +18,27 @@ use yii\db\ActiveQuery; class ActiveQueryUser extends ActiveQuery { - public function init() - { - parent::init(); - } - + /** + * Limit to active users + * + * @return \humhub\modules\user\components\ActiveQueryUser + */ public function active() { $this->andWhere(['user.status' => \humhub\modules\user\models\User::STATUS_ENABLED]); return $this; } + /** + * Adds default user order (e.g. by lastname) + * + * @return \humhub\modules\user\components\ActiveQueryUser + */ + public function defaultOrder() + { + $this->joinWith('profile'); + $this->addOrderBy(['profile.lastname' => SORT_ASC]); + return $this; + } + }