-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathModule.php
58 lines (50 loc) · 1.34 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace humhub\modules\autofollow;
use Yii;
use yii\helpers\Url;
use humhub\modules\space\models\Space;
use humhub\modules\user\models\User;
class Module extends \humhub\components\Module
{
/**
* @inheritdoc
*/
public $resourcesPath = 'resources';
/**
* @inheritdoc
*/
public function getConfigUrl()
{
return Url::to([
'/auto-follow/admin',
]);
}
/**
* Returns currently defined followable records
*
* @return \humhub\modules\content\components\ContentContainerActiveRecord[] the automatic followable records
*/
public function getAutoFollows()
{
$follows = [];
$spaces = $this->settings->getSerialized('spaces');
if ($spaces !== null && is_array($spaces)) {
foreach ($spaces as $guid) {
$s = Space::findOne(['guid' => trim($guid)]);
if ($s !== null) {
$follows[] = $s;
}
}
}
$users = $this->settings->getSerialized('users');
if ($users !== null && is_array($users)) {
foreach ($users as $guid) {
$u = User::findOne(['guid' => trim($guid)]);
if ($u !== null) {
$follows[] = $u;
}
}
}
return $follows;
}
}