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