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