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