aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/systemsettings/install.php38
-rw-r--r--engine/lib/configuration.php39
-rw-r--r--engine/lib/database.php2
-rw-r--r--engine/lib/entities.php38
-rw-r--r--engine/lib/install.php33
-rw-r--r--engine/lib/languages.php2
-rw-r--r--engine/lib/metadata.php26
-rw-r--r--engine/lib/relationships.php12
-rw-r--r--engine/lib/users.php9
-rw-r--r--engine/start.php20
-rw-r--r--install.php4
-rw-r--r--languages/en.php15
-rw-r--r--views/default/navigation/toolbox.php3
-rw-r--r--views/default/pageshells/pageshell_sidebar.php2
-rw-r--r--views/default/settings/install.php19
-rw-r--r--views/default/settings/system.php50
16 files changed, 231 insertions, 81 deletions
diff --git a/actions/systemsettings/install.php b/actions/systemsettings/install.php
new file mode 100644
index 000000000..d1ed6b6a2
--- /dev/null
+++ b/actions/systemsettings/install.php
@@ -0,0 +1,38 @@
+<?php
+
+ /**
+ * Elgg install site action
+ *
+ * Creates a nwe site and sets it as the default
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ if (get_input('settings') == 'go') {
+
+ if (!datalist_get('default_site')) {
+
+ $site = new ElggSite();
+ $site->name = get_input('sitename');
+ $site->url = get_input('wwwroot');
+ $site->save();
+
+ datalist_set('path',get_input('path'));
+ datalist_set('dataroot',get_input('dataroot'));
+
+ datalist_set('default_site',$site->getGUID());
+
+ system_message(elgg_echo("installation:configuration:success"));
+
+ forward("register.php");
+
+ }
+
+ }
+
+?> \ No newline at end of file
diff --git a/engine/lib/configuration.php b/engine/lib/configuration.php
index 5144f0b89..9b608f7c4 100644
--- a/engine/lib/configuration.php
+++ b/engine/lib/configuration.php
@@ -70,10 +70,9 @@
function set_default_config() {
global $CONFIG;
-
if (empty($CONFIG->path))
$CONFIG->path = str_replace("\\","/",dirname(dirname(dirname(__FILE__)))) . "/";
-
+
if (empty($CONFIG->viewpath))
$CONFIG->viewpath = $CONFIG->path . "views/";
@@ -81,10 +80,8 @@
$CONFIG->pluginspath = $CONFIG->path . "mod/";
if (empty($CONFIG->wwwroot)) {
- $CONFIG->wwwroot = "http://" . $_SERVER['SERVER_NAME'];
- /*if (strripos($_SERVER['DOCUMENT_ROOT'],"/") < (strlen($_SERVER['DOCUMENT_ROOT']) - 1)) {
- $CONFIG->wwwroot .= "/";
- }*/
+ /*
+ $CONFIG->wwwroot = "http://" . $_SERVER['SERVER_NAME'];
$request = $_SERVER['REQUEST_URI'];
@@ -94,8 +91,8 @@
}
$CONFIG->wwwroot .= $request;
-
- //$CONFIG->wwwroot .= str_replace($_SERVER['DOCUMENT_ROOT'],"",$CONFIG->path);
+ */
+ $CONFIG->wwwroot = "http://" . $_SERVER['HTTP_HOST'] . str_replace("//","/",str_replace($_SERVER['DOCUMENT_ROOT'],"",$CONFIG->path));
}
@@ -107,7 +104,31 @@
if (empty($CONFIG->debug))
$CONFIG->debug = false;
-
+
}
+
+ /**
+ * Function that provides some config initialisation on system init
+ *
+ */
+
+ function configuration_init() {
+
+ global $CONFIG;
+
+ $CONFIG->path = datalist_get('path');
+ $CONFIG->dataroot = datalist_get('dataroot');
+ $CONFIG->wwwroot = $CONFIG->site->url;
+ $CONFIG->sitename = $CONFIG->site->name;
+
+ return true;
+
+ }
+
+ /**
+ * Register config_init
+ */
+ register_event_handler('init','system','configuration_init',10);
+
?> \ No newline at end of file
diff --git a/engine/lib/database.php b/engine/lib/database.php
index 0f4bc89b9..0979592c0 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -355,7 +355,7 @@
* @param string $string The string to sanitise
* @return string Sanitised string
*/
- function sanitise_string($string) {return $string;
+ function sanitise_string($string) {
return mysql_real_escape_string(trim($string));
}
diff --git a/engine/lib/entities.php b/engine/lib/entities.php
index f3ba92e92..c1168853e 100644
--- a/engine/lib/entities.php
+++ b/engine/lib/entities.php
@@ -712,13 +712,14 @@
/**
* Create a new entity of a given type.
*
- * @param string $type
- * @param string $subtype
- * @param int $owner_guid
- * @param int $access_id
- * @return mixed The new entity's GUID or false.
+ * @param string $type The type of the entity (site, user, object).
+ * @param string $subtype The subtype of the entity.
+ * @param int $owner_guid The GUID of the object's owner.
+ * @param int $access_id The access control group to create the entity with.
+ * @param int $site_guid The site to add this entity to. Leave as 0 (default) for the current site.
+ * @return mixed The new entity's GUID, or false on failure
*/
- function create_entity($type, $subtype, $owner_guid, $access_id)
+ function create_entity($type, $subtype, $owner_guid, $access_id, $site_guid = 0)
{
global $CONFIG;
@@ -726,14 +727,17 @@
$subtype = add_subtype($type, $subtype);
$owner_guid = (int)$owner_guid;
$access_id = (int)$access_id;
- $time = time();
+ $time = time();
+ if ($site_guid == 0)
+ $site_guid = $CONFIG->site_guid;
+ $site_guid = (int) $site_guid;
if ($type=="") throw new InvalidParameterException("Entity type must be set.");
// Erased by Ben: sometimes we need unauthenticated users to create things! (eg users on registration)
// if ($owner_guid==0) throw new InvalidParameterException("owner_guid must not be 0");
- if ($result = insert_data("INSERT into {$CONFIG->dbprefix}entities (type, subtype, owner_guid, access_id, time_created, time_updated) values ('$type',$subtype, $owner_guid, $access_id, $time, $time)")) {
+ if ($result = insert_data("INSERT into {$CONFIG->dbprefix}entities (type, subtype, owner_guid, site_guid, access_id, time_created, time_updated) values ('$type',$subtype, $owner_guid, $site_guid, $access_id, $time, $time)")) {
$entity = get_entity($result);
trigger_event('create',$entity->type,$entity);
}
@@ -745,13 +749,13 @@
*
* You will only get an object if a) it exists, b) you have access to it.
*
- * @param int $guid
+ * @param int $guid The GUID of the object to extract
*/
function get_entity_as_row($guid)
{
global $CONFIG;
- $guid = (int)$guid;
+ $guid = (int) $guid;
$access = get_access_list();
@@ -815,9 +819,10 @@
* @param string $order_by The field to order by; by default, time_created desc
* @param int $limit The number of entities to return; 10 by default
* @param int $offset The indexing offset, 0 by default
- * @param boolean $count Set to true to get a count rather than the entities themselves (limits and offsets don't apply in this context). Defaults to false.
+ * @param boolean $count Set to true to get a count rather than the entities themselves (limits and offsets don't apply in this context). Defaults to false.
+ * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
*/
- function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "time_created desc", $limit = 10, $offset = 0, $count = false)
+ function get_entities($type = "", $subtype = "", $owner_guid = 0, $order_by = "time_created desc", $limit = 10, $offset = 0, $count = false, $site_guid = 0)
{
global $CONFIG;
@@ -829,7 +834,10 @@
$order_by = sanitise_string($order_by);
$limit = (int)$limit;
- $offset = (int)$offset;
+ $offset = (int)$offset;
+ $site_guid = (int) $site_guid;
+ if ($site_guid == 0)
+ $site_guid = $CONFIG->site_guid;
$access = get_access_list();
@@ -849,7 +857,9 @@
$owner_guid = implode(",",$owner_guid);
$where[] = "owner_guid in ({$owner_guid})";
}
- }
+ }
+ if ($site_guid > 0)
+ $where[] = "site_guid = {$site_guid}";
if (!$count) {
$query = "SELECT * from {$CONFIG->dbprefix}entities where ";
diff --git a/engine/lib/install.php b/engine/lib/install.php
index 4892be509..2a9026959 100644
--- a/engine/lib/install.php
+++ b/engine/lib/install.php
@@ -41,38 +41,7 @@
return false;
}
-
- /**
- * Function that gets run once, when the system is first installed
- *
- */
- function install_prerequisites() {
-
- // Load existing config
- global $CONFIG;
-
- // Create a new Elgg site
- $site = new ElggSite();
- $site->name = "Elgg site";
- $site->save();
-
- // Set datalist alerting us to the fact that the default site is this one
- datalist_set('default_site',$site->getGUID());
-
- }
-
- /**
- * Functions to be run at install init-time.
- *
- */
- function install_init() {
-
- // Run the install_prerequisites function just once
- run_function_once("install_prerequisites");
-
- }
- // Make sure install_boot gets called on system book
- register_event_handler('init','system','install_init',1);
+ register_action("systemsettings/install",true);
?> \ No newline at end of file
diff --git a/engine/lib/languages.php b/engine/lib/languages.php
index c765bf116..a81cd13b3 100644
--- a/engine/lib/languages.php
+++ b/engine/lib/languages.php
@@ -100,6 +100,6 @@
}
}
- register_event_handler("init","system","load_translations");
+ register_event_handler("boot","system","load_translations");
?> \ No newline at end of file
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php
index 6bed71eb6..c099d6a9c 100644
--- a/engine/lib/metadata.php
+++ b/engine/lib/metadata.php
@@ -326,9 +326,10 @@
* @param string $entity_subtype The subtype of the entity.
* @param int $limit
* @param int $offset
- * @param string $order_by Optional ordering.
+ * @param string $order_by Optional ordering.
+ * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
*/
- function get_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $limit = 10, $offset = 0, $order_by = "e.time_created desc")
+ function get_entities_from_metadata($meta_name, $meta_value = "", $entity_type = "", $entity_subtype = "", $limit = 10, $offset = 0, $order_by = "e.time_created desc", $site_guid = 0)
{
global $CONFIG;
@@ -339,7 +340,10 @@
$entity_subtype = get_subtype_id($entity_type, $entity_subtype);
$limit = (int)$limit;
$offset = (int)$offset;
- $order_by = sanitise_string($order_by);
+ $order_by = sanitise_string($order_by);
+ $site_guid = (int) $site_guid;
+ if ($site_guid == 0)
+ $site_guid = $CONFIG->site_guid;
$access = get_access_list();
@@ -352,7 +356,9 @@
if ($meta_name!="")
$where[] = "m.name_id='$meta_n'";
if ($meta_value!="")
- $where[] = "m.value_id='$meta_v'";
+ $where[] = "m.value_id='$meta_v'";
+ if ($site_guid > 0)
+ $where[] = "e.site_guid = {$site_guid}";
$query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e JOIN {$CONFIG->dbprefix}metadata m on e.guid = m.entity_guid where";
foreach ($where as $w)
@@ -372,9 +378,10 @@
* @param int $limit
* @param int $offset
* @param string $order_by Optional ordering.
+ * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
* @return array List of ElggEntities
*/
- function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $limit = 10, $offset = 0, $order_by = "e.time_created desc")
+ function get_entities_from_metadata_multi($meta_array, $entity_type = "", $entity_subtype = "", $limit = 10, $offset = 0, $order_by = "e.time_created desc", $site_guid = 0)
{
global $CONFIG;
@@ -402,13 +409,18 @@
$limit = (int)$limit;
$offset = (int)$offset;
$order_by = sanitise_string($order_by);
+ $site_guid = (int) $site_guid;
+ if ($site_guid == 0)
+ $site_guid = $CONFIG->site_guid;
$access = get_access_list();
if ($entity_type!="")
- $where[] = "e.type='$entity_type'";
+ $where[] = "e.type = '{$entity_type}'";
if ($entity_subtype)
- $where[] = "e.subtype=$entity_subtype";
+ $where[] = "e.subtype = {$entity_subtype}";
+ if ($site_guid > 0)
+ $where[] = "e.site_guid = {$site_guid}";
$query = "SELECT distinct e.* from {$CONFIG->dbprefix}entities e {$join} where";
foreach ($where as $w)
diff --git a/engine/lib/relationships.php b/engine/lib/relationships.php
index 486005c3f..8e3298a61 100644
--- a/engine/lib/relationships.php
+++ b/engine/lib/relationships.php
@@ -371,9 +371,10 @@
* @param int $limit
* @param int $offset
* @param boolean $count Set to true if you want to count the number of entities instead (default false)
+ * @param int $site_guid The site to get entities for. Leave as 0 (default) for the current site; -1 for all sites.
* @return array|int|false An array of entities, or the number of entities, or false on failure
*/
- function get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $order_by = "time_created desc", $limit = 10, $offset = 0, $count = false)
+ function get_entities_from_relationship($relationship, $relationship_guid, $inverse_relationship = false, $type = "", $subtype = "", $owner_guid = 0, $order_by = "time_created desc", $limit = 10, $offset = 0, $count = false, $site_guid = 0)
{
global $CONFIG;
@@ -385,7 +386,10 @@
$owner_guid = (int)$owner_guid;
$order_by = sanitise_string($order_by);
$limit = (int)$limit;
- $offset = (int)$offset;
+ $offset = (int)$offset;
+ $site_guid = (int) $site_guid;
+ if ($site_guid == 0)
+ $site_guid = $CONFIG->site_guid;
$access = get_access_list();
@@ -400,7 +404,9 @@
if ($subtype)
$where[] = "e.subtype=$subtype";
if ($owner_guid != "")
- $where[] = "e.owner_guid='$owner_guid'";
+ $where[] = "e.owner_guid='$owner_guid'";
+ if ($site_guid > 0)
+ $where[] = "e.site_guid = {$site_guid}";
// Select what we're joining based on the options
$joinon = "e.guid = r.guid_one";
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 90b7622ae..a28a09ac3 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -576,6 +576,10 @@
return false;
}
+ // Check to see if we've registered the first admin yet.
+ // If not, this is the first admin user!
+ $admin = datalist_get('admin_registered');
+
// Otherwise ...
$user = new ElggUser();
$user->username = $username;
@@ -585,6 +589,11 @@
$user->access_id = 2;
$user->save();
+ if (!$admin) {
+ $user->admin = true;
+ datalist_set('admin_registered',1);
+ }
+
return $user->getGUID();
diff --git a/engine/start.php b/engine/start.php
index 87b8cfb1b..6c85ce75c 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -15,12 +15,11 @@
/**
* Load important prerequisites
*/
-
+
if (!@include_once(dirname(__FILE__) . "/lib/exceptions.php")) { // Exceptions
echo "Error in installation: could not load the Exceptions library.";
exit;
}
-
if (!@include_once(dirname(__FILE__) . "/lib/elgglib.php")) { // Main Elgg library
throw new InstallationException("Elgg could not load its main library.");
}
@@ -106,20 +105,23 @@
}
- // Autodetect some default configuration settings
- set_default_config();
-
// Trigger events
trigger_event('boot', 'system');
-
// Forward if we haven't been installed
if ((!is_installed() || !is_db_installed()) && !substr_count($_SERVER["PHP_SELF"],"install.php")) {
- forward("install.php");
+ // Autodetect some default configuration settings
+ set_default_config();
+ forward("install.php");
}
-
+
// Trigger events
- if (!substr_count($_SERVER["PHP_SELF"],"install.php")) {
+ if (!substr_count($_SERVER["PHP_SELF"],"install.php") &&
+ !substr_count($_SERVER["PHP_SELF"],"setup.php")) {
+ // If default settings haven't been installed, forward to the default settings page
trigger_event('init', 'system');
+ if (!datalist_get('default_settings')) {
+ //forward("setup.php");
+ }
}
?> \ No newline at end of file
diff --git a/install.php b/install.php
index 35d4febd6..63ac69d16 100644
--- a/install.php
+++ b/install.php
@@ -28,12 +28,12 @@
*/
if (!is_db_installed()) {
run_sql_script(dirname(__FILE__) . "/engine/schema/mysql.sql");
- system_message("The Elgg database was installed.");
+ system_message(elgg_echo("installation:success"));
}
/**
* Load the front page
*/
- echo page_draw("Installation", elgg_view("settings/system"));
+ echo page_draw(elgg_echo("installation:settings"), elgg_view("settings/install"));
?> \ No newline at end of file
diff --git a/languages/en.php b/languages/en.php
index ab68866f1..aac6af52f 100644
--- a/languages/en.php
+++ b/languages/en.php
@@ -89,6 +89,21 @@
'fileexists' => "A file has already been uploaded. To replace it, select it below:",
/**
+ * Installation and system settings
+ */
+
+ 'installation' => "Installation",
+ 'installation:success' => "Elgg's database was installed successfully.",
+ 'installation:configuration:success' => "Your initial configuration settings have been saved. Now register your initial user; this will be your first system administrator.",
+
+ 'installation:settings' => "System settings",
+ 'installation:settings:description' => "Now that the Elgg database has been successfully installed, you need to enter a couple of pieces of information to get your site fully up and running. We've tried to guess where we could, but you may find that you need to tweak these details.",
+ 'sitename' => "The name of your site (eg \"My social networking site\"):",
+ 'wwwroot' => "The site URL, followed by a trailing slash:",
+ 'path' => "The full path to your site root on your disk, followed by a trailing slash:",
+ 'dataroot' => "The full path to the directory where uploaded files will be stored, followed by a trailing slash:",
+
+ /**
* Welcome
*/
diff --git a/views/default/navigation/toolbox.php b/views/default/navigation/toolbox.php
index 94fe89662..f8fb2ae9d 100644
--- a/views/default/navigation/toolbox.php
+++ b/views/default/navigation/toolbox.php
@@ -19,7 +19,7 @@
if (is_array($menu) && sizeof($menu) > 0) {
?>
-
+ <div id="sidebar_toolbox">
<ul>
<?php
@@ -55,6 +55,7 @@
?>
</ul>
+</div>
<?php
diff --git a/views/default/pageshells/pageshell_sidebar.php b/views/default/pageshells/pageshell_sidebar.php
index fba0d627b..d55bf2842 100644
--- a/views/default/pageshells/pageshell_sidebar.php
+++ b/views/default/pageshells/pageshell_sidebar.php
@@ -27,9 +27,7 @@
<?php echo elgg_view('messages/list', array('object' => $vars['sysmessages'])); ?>
<!-- toolbox -->
- <div id="sidebar_toolbox">
<?php echo elgg_view("navigation/toolbox"); ?><!-- include the my world toolbox -->
- </div>
<!-- get the sidebar and contents -->
<div id="sidebar_left">
diff --git a/views/default/settings/install.php b/views/default/settings/install.php
new file mode 100644
index 000000000..8de795da4
--- /dev/null
+++ b/views/default/settings/install.php
@@ -0,0 +1,19 @@
+<?php
+
+ /**
+ * Elgg system settings on initial installation
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ *
+ */
+
+ echo "<p>" . nl2br(elgg_echo("installation:settings:description")) . "</p>";
+
+ echo elgg_view("settings/system",array("action" => "action/systemsettings/install"));
+
+?> \ No newline at end of file
diff --git a/views/default/settings/system.php b/views/default/settings/system.php
new file mode 100644
index 000000000..1d2d19c67
--- /dev/null
+++ b/views/default/settings/system.php
@@ -0,0 +1,50 @@
+<?php
+
+ /**
+ * Elgg system settings form
+ * The form to change system settings
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ *
+ * @uses $vars['action'] If set, the place to forward the form to (usually action/systemsettings/save)
+ */
+
+ // Set action appropriately
+ if (!isset($vars['action'])) {
+ $action = $vars['url'] . "action/systemsettings/save";
+ } else {
+ $action = $vars['action'];
+ }
+
+?>
+
+ <form action="<?php echo $action; ?>" method="post">
+
+<?php
+
+ foreach(array('sitename','wwwroot','path','dataroot') as $field) {
+
+?>
+ <p>
+ <?php echo elgg_echo($field); ?><br />
+ <?php
+ echo elgg_view("input/text",array('internalname' => $field, 'value' => $vars[$field]));
+ ?>
+ </p>
+
+<?php
+
+ }
+
+?>
+ <p>
+ <input type="hidden" name="settings" value="go" />
+ <input type="submit" value="<?php echo elgg_echo("save"); ?>" />
+ </p>
+
+ </form> \ No newline at end of file