| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * StatusNet, the distributed open-source microblogging tool | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * A site profile is a set of default settings for a particular style of | 
					
						
							|  |  |  |  * StatusNet site: public, private, community, etc. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * PHP version 5 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * LICENCE: This program is free software: you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU Affero General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation, either version 3 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU Affero General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							|  |  |  |  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @category  Installation | 
					
						
							|  |  |  |  * @package   StatusNet | 
					
						
							|  |  |  |  * @author    Zach Copley <zach@status.net> | 
					
						
							|  |  |  |  * @copyright 2011 StatusNet, Inc. | 
					
						
							|  |  |  |  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 | 
					
						
							|  |  |  |  * @link      http://status.net/ | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-15 13:43:41 +01:00
										 |  |  | if (!defined('GNUSOCIAL')) { | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |     exit(1); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Helper class for getting the settings for a particular site profile | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class SiteProfile | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Returns the config settings for a site profile by name | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param  string $name name of a site profile | 
					
						
							|  |  |  |      * @return array  config settings | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     static public function getSettings($name) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $sprofileClass = ucfirst($name) . "Site"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (class_exists($sprofileClass)) { | 
					
						
							| 
									
										
										
										
											2011-08-29 11:17:59 -07:00
										 |  |  |             return call_user_func(array($sprofileClass, 'getSettings')); | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             common_log( | 
					
						
							|  |  |  |                 LOG_ERR, | 
					
						
							|  |  |  |                 "Unknown site profile '{$name}' specified in config file.", | 
					
						
							|  |  |  |                 __FILE__ | 
					
						
							|  |  |  |             ); | 
					
						
							|  |  |  |             return array(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Site profile settings contain the list of the default settings (and | 
					
						
							|  |  |  |  * possibly other information for a particular flavor of StatusNet | 
					
						
							|  |  |  |  * installation). These will overwrite base defaults in $config global. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @category Installation | 
					
						
							|  |  |  |  * @package  StatusNet | 
					
						
							|  |  |  |  * @author   Zach Copley <zach@status.net> | 
					
						
							|  |  |  |  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 | 
					
						
							|  |  |  |  * @link     http://status.net/ | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | abstract class SiteProfileSettings | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-09-21 18:44:05 +02:00
										 |  |  |     static function getSettings() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         throw new MethodNotImplementedException(__METHOD__); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-08-18 20:29:16 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-19 15:25:59 +02:00
										 |  |  |     static function corePlugins() { | 
					
						
							|  |  |  |         return common_config('plugins', 'core'); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-08-18 20:29:16 +02:00
										 |  |  |     static function defaultPlugins() { | 
					
						
							| 
									
										
										
										
											2013-10-19 15:25:59 +02:00
										 |  |  |         return common_config('plugins', 'default'); | 
					
						
							| 
									
										
										
										
											2013-08-18 20:29:16 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Settings for a 'public' site | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class PublicSite extends SiteProfileSettings | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get the settings for this site profile | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return type array   an array of settings | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     static function getSettings() { | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |         global $config; | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |         return array( | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |             // We only want to change these values, not replace entire 'site' array
 | 
					
						
							| 
									
										
										
										
											2011-09-22 12:49:04 -07:00
										 |  |  |             'site' => array_merge( | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |                 $config['site'], array( | 
					
						
							|  |  |  |                     'inviteonly' => false, | 
					
						
							|  |  |  |                     'private'    => false, | 
					
						
							|  |  |  |                     'closed'     => false | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |             ), | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |             'plugins' => array( | 
					
						
							| 
									
										
										
										
											2013-10-19 15:25:59 +02:00
										 |  |  |                 'core'    => self::corePlugins(), | 
					
						
							| 
									
										
										
										
											2013-08-18 20:29:16 +02:00
										 |  |  |                 'default' => array_merge(self::defaultPlugins(), array( | 
					
						
							| 
									
										
										
										
											2014-03-07 21:29:29 +01:00
										 |  |  |                     'RegisterThrottle'        => array(), | 
					
						
							| 
									
										
										
										
											2013-08-18 20:29:16 +02:00
										 |  |  |                 )) | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |             ), | 
					
						
							|  |  |  |             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
 | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Settings for a 'private' site | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * // XXX Too business oriented?
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class PrivateSite extends SiteProfileSettings | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get the settings for this site profile | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return type array  an array of settings | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     static function getSettings() { | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |         global $config; | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |         return array( | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |             // We only want to change these values, not replace entire 'site' array
 | 
					
						
							| 
									
										
										
										
											2011-09-22 12:49:04 -07:00
										 |  |  |             'site' => array_merge( | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |                 $config['site'], array( | 
					
						
							|  |  |  |                     'inviteonly' => true, | 
					
						
							|  |  |  |                     'private'    => true, | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |             ), | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |             'plugins' => array( | 
					
						
							| 
									
										
										
										
											2013-10-19 15:25:59 +02:00
										 |  |  |                 'core'    => self::corePlugins(), | 
					
						
							| 
									
										
										
										
											2013-08-18 20:29:16 +02:00
										 |  |  |                 'default' => array_merge(self::defaultPlugins(), array( | 
					
						
							| 
									
										
										
										
											2013-11-19 13:50:49 +01:00
										 |  |  |                     'ExtendedProfile'         => array(), | 
					
						
							|  |  |  |                     'EmailRegistration'       => array(), | 
					
						
							|  |  |  |                     'MobileProfile'           => array(), | 
					
						
							| 
									
										
										
										
											2014-05-09 10:31:55 +02:00
										 |  |  |                 )), | 
					
						
							|  |  |  |                 'disable-OStatus' => 1, | 
					
						
							|  |  |  |                 'disable-WebFinger' => 1, | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |              ), | 
					
						
							| 
									
										
										
										
											2015-01-29 20:49:19 +01:00
										 |  |  |             'public'        => array('localonly' => true), | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |             'profile'       => array('delete' => 'true'), | 
					
						
							|  |  |  |             'license'       => array('type'   => 'private'), | 
					
						
							|  |  |  |             'attachments'   => array( | 
					
						
							|  |  |  |                 // Only allow uploads of pictures and MS Office files
 | 
					
						
							|  |  |  |                 'supported' => array( | 
					
						
							|  |  |  |                     'image/png', | 
					
						
							|  |  |  |                     'image/jpeg', | 
					
						
							|  |  |  |                     'image/gif', | 
					
						
							|  |  |  |                     'image/svg+xml', | 
					
						
							|  |  |  |                     'application/pdf', | 
					
						
							|  |  |  |                     'application/msword', | 
					
						
							|  |  |  |                     'application/vnd.ms-office', | 
					
						
							|  |  |  |                     'application/vnd.ms-excel', | 
					
						
							|  |  |  |                     'application/vnd.ms-powerpoint', | 
					
						
							|  |  |  |                     'application/ogg' | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |              ), | 
					
						
							|  |  |  |             'discovery' => array('cors'   => false) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
 | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Settings for a 'community' site | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class CommunitySite extends SiteProfileSettings | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get the settings for this site profile | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return type array  an array of settings | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     static function getSettings() { | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |         global $config; | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |         return array( | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |             // We only want to change these values, not replace entire 'site' array
 | 
					
						
							| 
									
										
										
										
											2011-09-22 12:49:04 -07:00
										 |  |  |             'site' => array_merge( | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |                 $config['site'], array( | 
					
						
							|  |  |  |                     'private'    => false, | 
					
						
							| 
									
										
										
										
											2014-03-07 20:57:33 +01:00
										 |  |  |                     'inviteonly' => true, | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |                     'closed'     => false | 
					
						
							|  |  |  |                 ) | 
					
						
							|  |  |  |             ), | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |             'plugins' => array( | 
					
						
							| 
									
										
										
										
											2013-10-19 15:25:59 +02:00
										 |  |  |                 'core'    => self::corePlugins(), | 
					
						
							| 
									
										
										
										
											2013-08-18 20:29:16 +02:00
										 |  |  |                 'default' => array_merge(self::defaultPlugins(), array( | 
					
						
							|  |  |  |                 )) | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |             ), | 
					
						
							| 
									
										
										
										
											2015-01-29 20:49:19 +01:00
										 |  |  |             'public'    => array('localonly' => true), | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
 | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Settings for a 'singleuser' site | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class SingleuserSite extends SiteProfileSettings | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     /** | 
					
						
							|  |  |  |      * Get the settings for this site profile | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return type array  an array of settings | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     static function getSettings() { | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |         global $config; | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |         return array( | 
					
						
							|  |  |  |             'singleuser' => array('enabled' => true), | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |             // We only want to change these values, not replace entire 'site' array
 | 
					
						
							| 
									
										
										
										
											2011-09-22 12:49:04 -07:00
										 |  |  |             'site' => array_merge( | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |                 $config['site'], array( | 
					
						
							|  |  |  |                     'private'    => false, | 
					
						
							|  |  |  |                     'closed'     => true, | 
					
						
							| 
									
										
										
										
											2015-01-29 20:49:19 +01:00
										 |  |  |                     'localonly'  => true, | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |                 ) | 
					
						
							|  |  |  |             ), | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |             'plugins' => array( | 
					
						
							| 
									
										
										
										
											2013-10-19 15:25:59 +02:00
										 |  |  |                 'core'    => self::corePlugins(), | 
					
						
							| 
									
										
										
										
											2013-08-18 20:29:16 +02:00
										 |  |  |                 'default' => array_merge(self::defaultPlugins(), array( | 
					
						
							| 
									
										
										
										
											2013-11-19 13:50:49 +01:00
										 |  |  |                     'MobileProfile'           => array(), | 
					
						
							| 
									
										
										
										
											2014-05-09 10:31:55 +02:00
										 |  |  |                 )), | 
					
						
							|  |  |  |                 'disable-Directory' => 1, | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |             ), | 
					
						
							| 
									
										
										
										
											2015-01-29 20:49:19 +01:00
										 |  |  |             'public'    => array('localonly' => true), | 
					
						
							| 
									
										
										
										
											2011-08-27 14:25:12 -07:00
										 |  |  |             'discovery' => array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
 | 
					
						
							| 
									
										
										
										
											2011-08-26 21:10:24 -07:00
										 |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |