]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/siteprofile.php
Merge 1.1.x into master
[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     abstract static function getSettings();
77 }
78
79 /**
80  * Settings for a 'public' site
81  */
82 class PublicSite extends SiteProfileSettings
83 {
84     /**
85      * Get the settings for this site profile
86      *
87      * @return type array   an array of settings
88      */
89     static function getSettings() {
90         global $config;
91         return array(
92             // We only want to change these values, not replace entire 'site' array
93             'site' => array_merge(
94                 $config['site'], array(
95                     'inviteonly' => false,
96                     'private'    => false,
97                     'closed'     => false
98                 )
99             ),
100             'plugins' => array(
101                 'default' => array(
102                     'Bookmark'                => null,
103                     'ClientSideShorten'       => null,
104                     'Directory'               => null,
105                     'Event'                   => null,
106                     'ExtendedProfile'         => null,
107                     'Geonames'                => null,
108                     'Gravatar'                => null,
109                     'OpenID'                  => null,
110                     'OStatus'                 => null,
111                     'Poll'                    => null,
112                     'QnA'                     => null,
113                     'SearchSub'               => null,
114                     'StrictTransportSecurity' => null,
115                     'TagSub'                  => null
116                 )
117             ),
118             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
119         );
120     }
121 }
122
123 /**
124  * Settings for a 'private' site
125  *
126  * // XXX Too business oriented?
127  */
128 class PrivateSite extends SiteProfileSettings
129 {
130     /**
131      * Get the settings for this site profile
132      *
133      * @return type array  an array of settings
134      */
135     static function getSettings() {
136         global $config;
137         return array(
138             // We only want to change these values, not replace entire 'site' array
139             'site' => array_merge(
140                 $config['site'], array(
141                     'inviteonly' => true,
142                     'private'    => true,
143                 )
144             ),
145             'plugins' => array(
146                 'default' => array(
147                     'Bookmark'                => null,
148                     'ClientSideShorten'       => null,
149                     'Directory'               => null,
150                     'Event'                   => null,
151                     'ExtendedProfile'         => null,
152                     'EmailRegistration'       => null,
153                     'Geonames'                => null,
154                     'Gravatar'                => null,
155                     'NewMenu'                 => null,
156                     'MobileProfile'           => null,
157                     'OpenID'                  => null,
158                     'Poll'                    => null,
159                     'QnA'                     => null,
160                     'SearchSub'               => null,
161                     'StrictTransportSecurity' => null,
162                     'TagSub'                  => null
163                 )
164              ),
165             'profile'       => array('delete' => 'true'),
166             'license'       => array('type'   => 'private'),
167             'attachments'   => array(
168                 // Only allow uploads of pictures and MS Office files
169                 'supported' => array(
170                     'image/png',
171                     'image/jpeg',
172                     'image/gif',
173                     'image/svg+xml',
174                     'application/pdf',
175                     'application/msword',
176                     'application/vnd.ms-office',
177                     'application/vnd.ms-excel',
178                     'application/vnd.ms-powerpoint',
179                     'application/ogg'
180                 )
181              ),
182             'discovery' => array('cors'   => false) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
183         );
184     }
185 }
186
187 /**
188  * Settings for a 'community' site
189  */
190 class CommunitySite extends SiteProfileSettings
191 {
192     /**
193      * Get the settings for this site profile
194      *
195      * @return type array  an array of settings
196      */
197     static function getSettings() {
198         global $config;
199         return array(
200             // We only want to change these values, not replace entire 'site' array
201             'site' => array_merge(
202                 $config['site'], array(
203                     'private'    => false,
204                     'closed'     => false
205                 )
206             ),
207             'plugins' => array(
208                 'default' => array(
209                     'Bookmark'                => null,
210                     'ClientSideShorten'       => null,
211                     'Directory'               => null,
212                     'Event'                   => null,
213                     'Geonames'                => null,
214                     'Gravatar'                => null,
215                     'OpenID'                  => null,
216                     'OStatus'                 => null,
217                     'Poll'                    => null,
218                     'QnA'                     => null,
219                     'SearchSub'               => null,
220                     'StrictTransportSecurity' => null,
221                     'TagSub'                  => null
222                 )
223             ),
224             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
225         );
226     }
227
228 }
229
230 /**
231  * Settings for a 'singleuser' site
232  */
233 class SingleuserSite extends SiteProfileSettings
234 {
235     /**
236      * Get the settings for this site profile
237      *
238      * @return type array  an array of settings
239      */
240     static function getSettings() {
241         global $config;
242         return array(
243             'singleuser' => array('enabled' => true),
244             // We only want to change these values, not replace entire 'site' array
245             'site' => array_merge(
246                 $config['site'], array(
247                     'private'    => false,
248                     'closed'     => true,
249                 )
250             ),
251             'plugins' => array(
252                 'default' => array(
253                     'Bookmark'                => null,
254                     'ClientSideShorten'       => null,
255                     'Event'                   => null,
256                     'Geonames'                => null,
257                     'NewMenu'                 => null,
258                     'MobileProfile'           => null,
259                     'OpenID'                  => null,
260                     'OStatus'                 => null,
261                     'Poll'                    => null,
262                     'QnA'                     => null,
263                     'SearchSub'               => null,
264                     'StrictTransportSecurity' => null,
265                     'TagSub'                  => null,
266                     'TwitterBridge'           => null,
267                     'FacebookBridge'          => null,
268                 )
269             ),
270             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
271         );
272     }
273
274 }