Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #1

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
24 changes: 0 additions & 24 deletions Events.php

This file was deleted.

661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions Module.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php

namespace Baleks\humhub\modules\mostactivespaces;
namespace humhub\modules\mostactivespaces;

use Yii;
use yii\helpers\Url;
use humhub\models\Setting;

class Module extends \humhub\components\Module
{
Expand All @@ -16,6 +17,20 @@ public function getConfigUrl()
return Url::to(['/mostactivespaces/admin']);
}

/**
* On build of the dashboard sidebar widget, add the mostactivespaces widget if module is enabled.
*
* @param type $event
*/
public static function onSidebarInit($event)
{
if (Yii::$app->hasModule('mostactivespaces')) {
$event->sender->addWidget(widgets\Sidebar::class, [], [
'sortOrder' => 400
]);
}
}

/**
* @inheritdoc
*/
Expand All @@ -24,8 +39,8 @@ public function enable()
parent::enable();

$module = Yii::$app->getModule('mostactivespaces');
if (! $module->settings->get('spaces_count')) {
$module->settings->set('spaces_count', 5);
if (! $module->Settings::Set('spaces_count')) {
$module->Settings::Set('spaces_count', 5);
}
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Most-Active-Spaces
## Most Active Spaces Module

Adds a panel on the Dashboard, indicating the most active spaces based on space posts count.

2 changes: 1 addition & 1 deletion assets/Assets.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Baleks\humhub\modules\mostactivespaces\assets;
namespace humhub\modules\mostactivespaces\assets;

use yii\web\AssetBundle;

Expand Down
12 changes: 4 additions & 8 deletions config.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<?php

use Baleks\humhub\modules\mostactivespaces\Events;
use humhub\modules\dashboard\widgets\Sidebar;

return [
'id' => 'mostactivespaces',
'class' => 'Baleks\humhub\modules\mostactivespaces\Module',
'namespace' => 'Baleks\humhub\modules\mostactivespaces',
'class' => 'humhub\modules\mostactivespaces\Module',
'namespace' => 'humhub\modules\mostactivespaces',
'events' => [
[
'class' => Sidebar::class,
'event' => Sidebar::EVENT_INIT,
'callback' => [Events::class, 'onSidebarInit']
],
['class' => Sidebar::class, 'event' => Sidebar::EVENT_INIT, 'callback' => [\humhub\modules\mostactivespaces\Module::class, 'onSidebarInit']],
],
];
?>
4 changes: 2 additions & 2 deletions controllers/AdminController.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Baleks\humhub\modules\mostactivespaces\controllers;
namespace humhub\modules\mostactivespaces\controllers;

use Baleks\humhub\modules\mostactivespaces\models\ConfigForm;
use humhub\modules\mostactivespaces\models\ConfigForm;
use humhub\modules\admin\components\Controller;
use Yii;

Expand Down
10 changes: 6 additions & 4 deletions controllers/ListController.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

namespace Baleks\humhub\modules\mostactivespaces\controllers;
namespace humhub\modules\mostactivespaces\controllers;

use Baleks\humhub\modules\mostactivespaces\models\ActiveSpace;
use humhub\modules\mostactivespaces\models\ActiveSpace;
use humhub\components\behaviors\AccessControl;
use humhub\components\Controller;
use yii\data\Pagination;

class ListController extends Controller
{
Expand All @@ -17,7 +19,7 @@ public function behaviors()
{
return [
'acl' => [
'class' => \humhub\components\behaviors\AccessControl::class,
'class' => AccessControl::class,
'guestAllowedActions' => ['list']
]
];
Expand All @@ -31,7 +33,7 @@ public function actionIndex()
$query = ActiveSpace::find();

$countQuery = clone $query;
$pagination = new \yii\data\Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $this->pageSize]);
$pagination = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $this->pageSize]);
$query->offset($pagination->offset)->limit($pagination->limit);

return $this->renderAjax('index', [
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOGS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Changelogs
4 changes: 2 additions & 2 deletions models/ActiveSpace.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Baleks\humhub\modules\mostactivespaces\models;
namespace humhub\modules\mostactivespaces\models;

class ActiveSpace extends \humhub\modules\space\models\Space
{
Expand All @@ -20,4 +20,4 @@ public static function find()
return $query;
}

}
}
5 changes: 3 additions & 2 deletions models/ConfigForm.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Baleks\humhub\modules\mostactivespaces\models;

namespace humhub\modules\mostactivespaces\models;

use Yii;

Expand All @@ -23,4 +24,4 @@ public function attributeLabels()
];
}

}
}
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"keywords": [
"most", "active", "spaces", "widget", "dashboard"
],
"version": "0.1",
"version": "0.2",
"humhub": {
"minVersion": "1.2"
},
"screenshots": ["assets/screen1.jpg"]
}
}
4 changes: 3 additions & 1 deletion views/list/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use yii\helpers\Html;
use humhub\widgets\AjaxLinkPager;

?>
<div class="modal-dialog modal-dialog-normal animated fadeIn">
<div class="modal-content">
Expand Down Expand Up @@ -51,7 +53,7 @@ class="title"><?= Yii::t('MostactivespacesModule.views_mostActiveSpaces_list', '
</ul>
<div class="modal-footer" style="padding: 5px">
<div class="pagination-container">
<?= \humhub\widgets\AjaxLinkPager::widget(['pagination' => $pagination]); ?>
<?= AjaxLinkPager::widget(['pagination' => $pagination]); ?>
</div>
</div>
</div>
Expand Down
11 changes: 5 additions & 6 deletions widgets/Sidebar.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<?php

namespace Baleks\humhub\modules\mostactivespaces\widgets;
namespace humhub\modules\mostactivespaces\widgets;

use Baleks\humhub\modules\mostactivespaces\models\ActiveSpace;
use humhub\modules\mostactivespaces\models\ActiveSpace;
use humhub\components\Widget;
use Yii;

class Sidebar extends \humhub\components\Widget
class Sidebar extends Widget
{

public function run()
{
$module = Yii::$app->getModule('mostactivespaces');
$spaces = ActiveSpace::find()->limit((int) $module->settings->get('spaces_count'))->all();
return $this->render('sidebar', [
'spaces' => $spaces
]);
return $this->render('sidebar', ['spaces' => $spaces]);
}

}
3 changes: 2 additions & 1 deletion widgets/views/sidebar.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

use yii\helpers\Html;
use humhub\modules\mostactivespaces\assets\Assets;

Baleks\humhub\modules\mostactivespaces\assets\Assets::register($this);
Assets::register($this);
?>
<div class="panel panel-default" id="mostactivespaces-panel">

Expand Down