Repository navigation
Expand file tree
/
Copy pathSite_Config.php
More file actions
118 lines (93 loc) · 2.53 KB
/
Copy pathSite_Config.php
File metadata and controls
118 lines (93 loc) · 2.53 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* Created by PhpStorm.
* User: anguoyue
* Date: 15/08/2018
* Time: 4:44 PM
*/
class Site_Config
{
private $ctx;
public function __construct(BaseCtx $ctx)
{
$this->ctx = $ctx;
}
/**
* @param $configKey
* @param null $defaultValue
* @return null
*/
public function getConfigValue($configKey, $defaultValue = null)
{
$configValues = $this->ctx->SiteConfigTable->selectSiteConfig($configKey);
if ($configValues) {
return $configValues[$configKey];
}
return $defaultValue;
}
public function getFileSizeConfig()
{
return $this->getConfigValue(SiteConfig::SITE_FILE_SIZE, 10);
}
public function getAllConfig()
{
return $this->ctx->SiteConfigTable->selectSiteConfig();
}
/**
* get administrator,site has just one administrator
* @return null
*/
public function getSiteOwner()
{
$adminValue = $this->ctx->SiteConfigTable->selectSiteConfig(SiteConfig::SITE_OWNER);
if (isset($adminValue)) {
return $adminValue[SiteConfig::SITE_OWNER];
}
return null;
}
public function isSiteOwner($userId)
{
$siteOwner = $this->getSiteOwner();
if (empty($userId) || empty($siteOwner)) {
return false;
}
if ($userId == $siteOwner) {
return true;
}
}
/**
* get managers ,site has many managers
*
* @return array
*/
public function getSiteManagers()
{
$managers = [];
$admin = $this->getSiteOwner();
if (isset($admin)) {
$managers[] = $admin;
}
$managersValue = $this->ctx->SiteConfigTable->selectSiteConfig(SiteConfig::SITE_MANAGERS);
if ($managersValue) {
$managersValueStr = isset($managersValue['managers']) ? $managersValue['managers'] : "";
$managersArray = explode(",", $managersValueStr);
if (!empty($managersArray)) {
$managers = array_merge($managers, $managersArray);
}
}
return $managers;
}
public function isManager($userId)
{
if (empty($userId)) {
return false;
}
if (in_array($userId, $this->getSiteManagers())) {
return true;
}
}
public function getSiteDefaultFriendsAndGroups()
{
return $this->ctx->SiteConfigTable->selectSiteConfig([SiteConfig::SITE_DEFAULT_FRIENDS, SiteConfig::SITE_DEFAULT_GROUPS]);
}
}