aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/install.php
blob: c47eedd40e856bc4c70a960af23b64e68ec03614 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

/**
 * Elgg installation
 * Various functions to assist with installing and upgrading the system
 *
 * @package Elgg.Core
 * @subpackage Installation
 */

/**
 * Returns whether or not the database has been installed
 *
 * @return true|false Whether the database has been installed
 */
function is_db_installed() {
	global $CONFIG;

	if (isset($CONFIG->db_installed)) {
		return $CONFIG->db_installed;
	}

	if ($dblink = get_db_link('read')) {
		mysql_query("select name from {$CONFIG->dbprefix}datalists limit 1", $dblink);
		if (mysql_errno($dblink) > 0) {
			return false;
		}
	} else {
		return false;
	}

	// Set flag if db is installed (if false then we want to check every time)
	$CONFIG->db_installed = true;

	return true;
}

/**
 * Returns whether or not other settings have been set
 *
 * @return true|false Whether or not the rest of the installation has been followed through with
 */
function is_installed() {
	global $CONFIG;
	return datalist_get('installed');
}

/**
 * Check that installation has completed and the database is populated.
 *
 * @throws InstallationException
 * @return void
 */
function verify_installation() {
	$installed = FALSE;
	try {
		$installed = is_installed();
	} catch (DatabaseException $e) {}
	if (!$installed) {
		throw new InstallationException(elgg_echo('InstallationException:SiteNotInstalled'));
	}
}