forked from GNUsocial/gnu-social
Merge branch '1.0.x' of gitorious.org:statusnet/mainline into 1.0.x
This commit is contained in:
commit
38eefd1b32
20
install.php
20
install.php
@ -248,6 +248,20 @@ class WebInstaller extends Installer
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset id="settings_profile">
|
||||||
|
<legend>Site profile</legend>
|
||||||
|
<ul class="form_data">
|
||||||
|
<li>
|
||||||
|
<label for="site_profile">Type of site</label>
|
||||||
|
<select id="site_profile" name="site_profile">
|
||||||
|
<option value="private">Private</option>
|
||||||
|
<option value="community">Community</option>
|
||||||
|
<option value ="public">Public</option>
|
||||||
|
</select>
|
||||||
|
<p class="form_guide">Initial access settings for your site</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</fieldset>
|
||||||
<input type="submit" name="submit" class="submit" value="Submit" />
|
<input type="submit" name="submit" class="submit" value="Submit" />
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
@ -304,6 +318,8 @@ STR;
|
|||||||
$this->adminEmail = $post->string('admin_email');
|
$this->adminEmail = $post->string('admin_email');
|
||||||
$this->adminUpdates = $post->string('admin_updates');
|
$this->adminUpdates = $post->string('admin_updates');
|
||||||
|
|
||||||
|
$this->siteProfile = $post->string('site_profile');
|
||||||
|
|
||||||
$this->server = $_SERVER['HTTP_HOST'];
|
$this->server = $_SERVER['HTTP_HOST'];
|
||||||
$this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
|
$this->path = substr(dirname($_SERVER['PHP_SELF']), 1);
|
||||||
|
|
||||||
@ -321,6 +337,10 @@ STR;
|
|||||||
$fail = true;
|
$fail = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->validateSiteProfile()) {
|
||||||
|
$fail = true;
|
||||||
|
}
|
||||||
|
|
||||||
return !$fail;
|
return !$fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
abstract class Installer
|
abstract class Installer
|
||||||
{
|
{
|
||||||
/** Web site info */
|
/** Web site info */
|
||||||
public $sitename, $server, $path, $fancy;
|
public $sitename, $server, $path, $fancy, $siteProfile;
|
||||||
/** DB info */
|
/** DB info */
|
||||||
public $host, $database, $dbtype, $username, $password, $db;
|
public $host, $database, $dbtype, $username, $password, $db;
|
||||||
/** Administrator info */
|
/** Administrator info */
|
||||||
@ -251,6 +251,25 @@ abstract class Installer
|
|||||||
return !$fail;
|
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...
|
* Set up the database with the appropriate function for the selected type...
|
||||||
* Saves database info into $this->db.
|
* Saves database info into $this->db.
|
||||||
@ -395,6 +414,7 @@ abstract class Installer
|
|||||||
'path' => $this->path,
|
'path' => $this->path,
|
||||||
'db_database' => $this->db['database'],
|
'db_database' => $this->db['database'],
|
||||||
'db_type' => $this->db['type'],
|
'db_type' => $this->db['type'],
|
||||||
|
'site_profile' => $this->siteProfile
|
||||||
));
|
));
|
||||||
|
|
||||||
// assemble configuration file in a string
|
// assemble configuration file in a string
|
||||||
@ -414,7 +434,10 @@ abstract class Installer
|
|||||||
// database
|
// database
|
||||||
"\$config['db']['database'] = {$vals['db_database']};\n\n".
|
"\$config['db']['database'] = {$vals['db_database']};\n\n".
|
||||||
($this->db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\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
|
// Normalize line endings for Windows servers
|
||||||
$cfg = str_replace("\n", PHP_EOL, $cfg);
|
$cfg = str_replace("\n", PHP_EOL, $cfg);
|
||||||
|
264
lib/siteprofile.php
Normal file
264
lib/siteprofile.php
Normal file
@ -0,0 +1,264 @@
|
|||||||
|
<?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/
|
||||||
|
*/
|
||||||
|
|
||||||
|
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 <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
|
||||||
|
{
|
||||||
|
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.)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -113,6 +113,10 @@ class StatusNet
|
|||||||
StatusNet::initDefaults($server, $path);
|
StatusNet::initDefaults($server, $path);
|
||||||
StatusNet::loadConfigFile($conffile);
|
StatusNet::loadConfigFile($conffile);
|
||||||
|
|
||||||
|
$sprofile = common_config('site', 'profile');
|
||||||
|
if (!empty($sprofile)) {
|
||||||
|
StatusNet::loadSiteProfile($sprofile);
|
||||||
|
}
|
||||||
// Load settings from database; note we need autoload for this
|
// Load settings from database; note we need autoload for this
|
||||||
Config::loadSettings();
|
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)
|
protected function _sn_to_path($sn)
|
||||||
{
|
{
|
||||||
$past_root = substr($sn, 1);
|
$past_root = substr($sn, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user