]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/siteprofile.php
Qvitter API changes (thanks hannes2peer)
[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 defaultPlugins() {
82         return array(
83             'Bookmark'                => null,
84             'Event'                   => null,
85             'OpenID'                  => null,
86             'LRDD'                    => null,
87             'Poll'                    => null,
88             'QnA'                     => null,
89             'SearchSub'               => null,
90             'StrictTransportSecurity' => null,
91             'TagSub'                  => null,
92         );
93     }
94 }
95
96 /**
97  * Settings for a 'public' site
98  */
99 class PublicSite extends SiteProfileSettings
100 {
101     /**
102      * Get the settings for this site profile
103      *
104      * @return type array   an array of settings
105      */
106     static function getSettings() {
107         global $config;
108         return array(
109             // We only want to change these values, not replace entire 'site' array
110             'site' => array_merge(
111                 $config['site'], array(
112                     'inviteonly' => false,
113                     'private'    => false,
114                     'closed'     => false
115                 )
116             ),
117             'plugins' => array(
118                 'default' => array_merge(self::defaultPlugins(), array(
119                     'ClientSideShorten'       => null,
120                     'Directory'               => null,
121                     'ExtendedProfile'         => null,
122                     'Geonames'                => null,
123                     'OStatus'                 => null,
124                     'WebFinger'               => null,
125                 ))
126             ),
127             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
128         );
129     }
130 }
131
132 /**
133  * Settings for a 'private' site
134  *
135  * // XXX Too business oriented?
136  */
137 class PrivateSite extends SiteProfileSettings
138 {
139     /**
140      * Get the settings for this site profile
141      *
142      * @return type array  an array of settings
143      */
144     static function getSettings() {
145         global $config;
146         return array(
147             // We only want to change these values, not replace entire 'site' array
148             'site' => array_merge(
149                 $config['site'], array(
150                     'inviteonly' => true,
151                     'private'    => true,
152                 )
153             ),
154             'plugins' => array(
155                 'default' => array_merge(self::defaultPlugins(), array(
156                     'ClientSideShorten'       => null,
157                     'Directory'               => null,
158                     'ExtendedProfile'         => null,
159                     'EmailRegistration'       => null,
160                     'Geonames'                => null,
161                     'NewMenu'                 => null,
162                     'MobileProfile'           => 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_merge(self::defaultPlugins(), array(
209                     'ClientSideShorten'       => null,
210                     'Directory'               => null,
211                     'Geonames'                => null,
212                     'OStatus'                 => null,
213                     'WebFinger'               => null,
214                 ))
215             ),
216             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
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         global $config;
234         return array(
235             'singleuser' => array('enabled' => true),
236             // We only want to change these values, not replace entire 'site' array
237             'site' => array_merge(
238                 $config['site'], array(
239                     'private'    => false,
240                     'closed'     => true,
241                 )
242             ),
243             'plugins' => array(
244                 'default' => array_merge(self::defaultPlugins(), array(
245                     'ClientSideShorten'       => null,
246                     'Geonames'                => null,
247                     'NewMenu'                 => null,
248                     'MobileProfile'           => null,
249                     'OStatus'                 => null,
250                     'TwitterBridge'           => null,
251                     'FacebookBridge'          => null,
252                     'WebFinger'               => null,
253                 ))
254             ),
255             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
256         );
257     }
258
259 }