Install StatusNet
-main();
?>
diff --git a/lib/installer.php b/lib/installer.php
index 6f58b247b5..0f6af02378 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -42,7 +42,7 @@
abstract class Installer
{
/** Web site info */
- public $sitename, $server, $path, $fancy;
+ public $sitename, $server, $path, $fancy, $siteProfile;
/** DB info */
public $host, $database, $dbtype, $username, $password, $db;
/** Administrator info */
@@ -73,7 +73,7 @@ abstract class Installer
error_reporting($old);
return $ok;
}
-
+
/**
* Check if all is ready for installation
*
@@ -185,7 +185,7 @@ abstract class Installer
/**
* Basic validation on the database paramters
* Side effects: error output if not valid
- *
+ *
* @return boolean success
*/
function validateDb()
@@ -218,7 +218,7 @@ abstract class Installer
/**
* Basic validation on the administrator user paramters
* Side effects: error output if not valid
- *
+ *
* @return boolean success
*/
function validateAdmin()
@@ -251,10 +251,29 @@ abstract class Installer
return !$fail;
}
+ /**
+ * Make sure a site profile was selected
+ *
+ * @return type boolean success
+ */
+ function validateSiteProfile()
+ {
+ $fail = false;
+
+ $sprofile = $this->siteProfile;
+
+ if (empty($sprofile)) {
+ $this->updateStatus("No site profile selected.", true);
+ $fail = true;
+ }
+
+ return !$fail;
+ }
+
/**
* Set up the database with the appropriate function for the selected type...
* Saves database info into $this->db.
- *
+ *
* @fixme escape things in the connection string in case we have a funny pass etc
* @return mixed array of database connection params on success, false on failure
*/
@@ -316,7 +335,7 @@ abstract class Installer
* Open a connection to the database.
*
* @param $dsn
- * @return
+ * @return
*/
function connectDatabase($dsn)
{
@@ -384,7 +403,7 @@ abstract class Installer
* Write a stock configuration file.
*
* @return boolean success
- *
+ *
* @fixme escape variables in output in case we have funny chars, apostrophes etc
*/
function writeConf()
@@ -395,6 +414,7 @@ abstract class Installer
'path' => $this->path,
'db_database' => $this->db['database'],
'db_type' => $this->db['type'],
+ 'site_profile' => $this->siteProfile
));
// assemble configuration file in a string
@@ -414,7 +434,10 @@ abstract class Installer
// database
"\$config['db']['database'] = {$vals['db_database']};\n\n".
($this->db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n":'').
- "\$config['db']['type'] = {$vals['db_type']};\n\n";
+ "\$config['db']['type'] = {$vals['db_type']};\n\n".
+
+ // site profile
+ "\$config['site']['profile'] = {$vals['site_profile']};\n\n";
// Normalize line endings for Windows servers
$cfg = str_replace("\n", PHP_EOL, $cfg);
@@ -479,7 +502,7 @@ abstract class Installer
$user->grantRole('owner');
$user->grantRole('moderator');
$user->grantRole('administrator');
-
+
// Attempt to do a remote subscribe to update@status.net
// Will fail if instance is on a private network.
@@ -499,9 +522,9 @@ abstract class Installer
/**
* The beef of the installer!
* Create database, config file, and admin user.
- *
+ *
* Prerequisites: validation of input data.
- *
+ *
* @return boolean success
*/
function doInstall()
diff --git a/lib/siteprofile.php b/lib/siteprofile.php
new file mode 100644
index 0000000000..53e6482aae
--- /dev/null
+++ b/lib/siteprofile.php
@@ -0,0 +1,264 @@
+.
+ *
+ * @category Installation
+ * @package StatusNet
+ * @author Zach Copley
+ * @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/
+ */
+
+if (!defined('STATUSNET')) {
+ 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)) {
+ return $sprofileClass::getSettings();
+ } 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
+ * @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
+{
+ abstract static function getSettings();
+}
+
+/**
+ * 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() {
+ return array(
+ 'site' => array(
+ 'inviteonly' => false,
+ 'private' => false
+ ),
+ 'plugins' => array(
+ 'default' => array(
+ 'Activity' => null,
+ 'Bookmark' => null,
+ 'ClientSideShorten' => null,
+ 'Directory' => null,
+ 'Event' => null,
+ 'ExtendedProfile' => null,
+ 'Geonames' => null,
+ 'Gravatar' => null,
+ 'OpenID' => null,
+ 'OStatus' => null,
+ 'Poll' => null,
+ 'QnA' => null,
+ 'SearchSub' => null,
+ 'StrictTransportSecurity' => null,
+ 'TagSub' => null
+ ),
+ 'discovery' =>
+ array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
+ )
+ );
+ }
+}
+
+/**
+ * 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() {
+ return array(
+ 'site' => array(
+ 'inviteonly' => true,
+ 'private' => true
+ ),
+ 'plugins' => array(
+ 'default' => array(
+ 'Activity' => null,
+ 'Bookmark' => null,
+ 'ClientSideShorten' => null,
+ 'Directory' => null,
+ 'Event' => null,
+ 'ExtendedProfile' => null,
+ 'EmailRegistration' => null,
+ 'Geonames' => null,
+ 'Gravatar' => null,
+ 'NewMenu' => null,
+ 'MobileProfile' => null,
+ 'OpenID' => null,
+ 'Poll' => null,
+ 'QnA' => null,
+ 'SearchSub' => null,
+ 'StrictTransportSecurity' => null,
+ 'TagSub' => null
+ )
+ ),
+ '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() {
+ return array(
+ 'site' => array(
+ 'inviteonly' => true,
+ 'private' => false
+ ),
+ 'plugins' => array(
+ 'default' => array(
+ 'Activity' => null,
+ 'Bookmark' => null,
+ 'ClientSideShorten' => null,
+ 'Directory' => null,
+ 'Event' => null,
+ 'Geonames' => null,
+ 'Gravatar' => null,
+ 'OpenID' => null,
+ 'OStatus' => null,
+ 'Poll' => null,
+ 'QnA' => null,
+ 'SearchSub' => null,
+ 'StrictTransportSecurity' => null,
+ 'TagSub' => null
+ ),
+ 'discovery' =>
+ array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
+ )
+ );
+ }
+
+}
+
+/**
+ * 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() {
+ return array(
+ 'singleuser' => array('enabled' => true),
+ 'site' => array(
+ 'private' => false,
+ 'closed' => true,
+ ),
+ 'plugins' => array(
+ 'default' => array(
+ 'Activity' => null,
+ 'Bookmark' => null,
+ 'ClientSideShorten' => null,
+ 'Event' => null,
+ 'Geonames' => null,
+ 'NewMenu' => null,
+ 'MobileProfile' => null,
+ 'OpenID' => null,
+ 'OStatus' => null,
+ 'Poll' => null,
+ 'QnA' => null,
+ 'SearchSub' => null,
+ 'StrictTransportSecurity' => null,
+ 'TagSub' => null,
+ 'TwitterBridge' => null,
+ 'FacebookBridge' => null
+ ),
+ 'discovery' =>
+ array('cors' => true) // Allow Cross-Origin Resource Sharing for service discovery (host-meta, XRD, etc.)
+ )
+ );
+ }
+
+}
diff --git a/lib/statusnet.php b/lib/statusnet.php
index ce0d41e51e..846d525c38 100644
--- a/lib/statusnet.php
+++ b/lib/statusnet.php
@@ -113,6 +113,10 @@ class StatusNet
StatusNet::initDefaults($server, $path);
StatusNet::loadConfigFile($conffile);
+ $sprofile = common_config('site', 'profile');
+ if (!empty($sprofile)) {
+ StatusNet::loadSiteProfile($sprofile);
+ }
// Load settings from database; note we need autoload for this
Config::loadSettings();
@@ -302,6 +306,13 @@ class StatusNet
}
}
+ public static function loadSiteProfile($name)
+ {
+ global $config;
+ $settings = SiteProfile::getSettings($name);
+ $config = array_replace_recursive($config, $settings);
+ }
+
protected function _sn_to_path($sn)
{
$past_root = substr($sn, 1);