]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/siteprofile.php
Core plugin list would not merge into $config
[quix0rs-gnu-social.git] / lib / siteprofile.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * A site profile is a set of default settings for a particular style of
6  * StatusNet site: public, private, community, etc.
7  *
8  * PHP version 5
9  *
10  * LICENCE: This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  Installation
24  * @package   StatusNet
25  * @author    Zach Copley <zach@status.net>
26  * @copyright 2011 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET')) {
32     exit(1);
33 }
34
35 /**
36  * Helper class for getting the settings for a particular site profile
37  */
38 class SiteProfile
39 {
40     /**
41      * Returns the config settings for a site profile by name
42      *
43      * @param  string $name name of a site profile
44      * @return array  config settings
45      */
46     static public function getSettings($name)
47     {
48         $sprofileClass = ucfirst($name) . "Site";
49
50         if (class_exists($sprofileClass)) {
51             return call_user_func(array($sprofileClass, 'getSettings'));
52         } else {
53             common_log(
54                 LOG_ERR,
55                 "Unknown site profile '{$name}' specified in config file.",
56                 __FILE__
57             );
58             return array();
59         }
60     }
61 }
62
63 /**
64  * Site profile settings contain the list of the default settings (and
65  * possibly other information for a particular flavor of StatusNet
66  * installation). These will overwrite base defaults in $config global.
67  *
68  * @category Installation
69  * @package  StatusNet
70  * @author   Zach Copley <zach@status.net>
71  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
72  * @link     http://status.net/
73  */
74 abstract class SiteProfileSettings
75 {
76     static function getSettings()
77     {
78         throw new MethodNotImplementedException(__METHOD__);
79     }
80
81     static function corePlugins() {
82         return common_config('plugins', 'core');
83     }
84     static function defaultPlugins() {
85         return common_config('plugins', 'default');
86     }
87 }
88
89 /**
90  * Settings for a 'public' site
91  */
92 class PublicSite extends SiteProfileSettings
93 {
94     /**
95      * Get the settings for this site profile
96      *
97      * @return type array   an array of settings
98      */
99     static function getSettings() {
100         global $config;
101         return array(
102             // We only want to change these values, not replace entire 'site' array
103             'site' => array_merge(
104                 $config['site'], array(
105                     'inviteonly' => false,
106                     'private'    => false,
107                     'closed'     => false
108                 )
109             ),
110             'plugins' => array(
111                 'core'    => self::corePlugins(),
112                 'default' => array_merge(self::defaultPlugins(), array(
113                     'Directory'               => null,
114                     'ExtendedProfile'         => null,
115                     'Geonames'                => null,
116                     'OStatus'                 => null,
117                     'WebFinger'               => null,
118                 ))
119             ),
120             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
121         );
122     }
123 }
124
125 /**
126  * Settings for a 'private' site
127  *
128  * // XXX Too business oriented?
129  */
130 class PrivateSite extends SiteProfileSettings
131 {
132     /**
133      * Get the settings for this site profile
134      *
135      * @return type array  an array of settings
136      */
137     static function getSettings() {
138         global $config;
139         return array(
140             // We only want to change these values, not replace entire 'site' array
141             'site' => array_merge(
142                 $config['site'], array(
143                     'inviteonly' => true,
144                     'private'    => true,
145                 )
146             ),
147             'plugins' => array(
148                 'core'    => self::corePlugins(),
149                 'default' => array_merge(self::defaultPlugins(), array(
150                     'Directory'               => null,
151                     'ExtendedProfile'         => null,
152                     'EmailRegistration'       => null,
153                     'Geonames'                => null,
154                     'NewMenu'                 => null,
155                     'MobileProfile'           => null,
156                 ))
157              ),
158             'profile'       => array('delete' => 'true'),
159             'license'       => array('type'   => 'private'),
160             'attachments'   => array(
161                 // Only allow uploads of pictures and MS Office files
162                 'supported' => array(
163                     'image/png',
164                     'image/jpeg',
165                     'image/gif',
166                     'image/svg+xml',
167                     'application/pdf',
168                     'application/msword',
169                     'application/vnd.ms-office',
170                     'application/vnd.ms-excel',
171                     'application/vnd.ms-powerpoint',
172                     'application/ogg'
173                 )
174              ),
175             'discovery' => array('cors'   => false) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
176         );
177     }
178 }
179
180 /**
181  * Settings for a 'community' site
182  */
183 class CommunitySite extends SiteProfileSettings
184 {
185     /**
186      * Get the settings for this site profile
187      *
188      * @return type array  an array of settings
189      */
190     static function getSettings() {
191         global $config;
192         return array(
193             // We only want to change these values, not replace entire 'site' array
194             'site' => array_merge(
195                 $config['site'], array(
196                     'private'    => false,
197                     'closed'     => false
198                 )
199             ),
200             'plugins' => array(
201                 'core'    => self::corePlugins(),
202                 'default' => array_merge(self::defaultPlugins(), array(
203                     'Directory'               => null,
204                     'Geonames'                => null,
205                     'OStatus'                 => null,
206                     'WebFinger'               => null,
207                 ))
208             ),
209             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
210         );
211     }
212
213 }
214
215 /**
216  * Settings for a 'singleuser' site
217  */
218 class SingleuserSite extends SiteProfileSettings
219 {
220     /**
221      * Get the settings for this site profile
222      *
223      * @return type array  an array of settings
224      */
225     static function getSettings() {
226         global $config;
227         return array(
228             'singleuser' => array('enabled' => true),
229             // We only want to change these values, not replace entire 'site' array
230             'site' => array_merge(
231                 $config['site'], array(
232                     'private'    => false,
233                     'closed'     => true,
234                 )
235             ),
236             'plugins' => array(
237                 'core'    => self::corePlugins(),
238                 'default' => array_merge(self::defaultPlugins(), array(
239                     'Geonames'                => null,
240                     'NewMenu'                 => null,
241                     'MobileProfile'           => null,
242                     'OStatus'                 => null,
243                     'TwitterBridge'           => null,
244                     'FacebookBridge'          => null,
245                     'WebFinger'               => null,
246                 ))
247             ),
248             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
249         );
250     }
251
252 }