aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/upgrades
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/upgrades')
-rw-r--r--engine/lib/upgrades/2008100701.php7
-rw-r--r--engine/lib/upgrades/2008101303.php16
-rw-r--r--engine/lib/upgrades/2009022701.php5
-rw-r--r--engine/lib/upgrades/2009041701.php7
-rw-r--r--engine/lib/upgrades/2009070101.php7
-rw-r--r--engine/lib/upgrades/2009102801.php165
-rw-r--r--engine/lib/upgrades/2010033101.php12
-rw-r--r--engine/lib/upgrades/2010060401.php14
-rw-r--r--engine/lib/upgrades/2010061501.php38
-rw-r--r--engine/lib/upgrades/2010062301.php3
-rw-r--r--engine/lib/upgrades/2010071001.php11
-rw-r--r--engine/lib/upgrades/2010071002.php5
12 files changed, 166 insertions, 124 deletions
diff --git a/engine/lib/upgrades/2008100701.php b/engine/lib/upgrades/2008100701.php
index cf976e84c..394a90046 100644
--- a/engine/lib/upgrades/2008100701.php
+++ b/engine/lib/upgrades/2008100701.php
@@ -1,8 +1,7 @@
<?php
/// Activate mail plugin
/**
- * Because Elgg now has a plugable account activation process we need to activate
+ * Because Elgg now has a plugable account activation process we need to activate
* the email account activation plugin for existing installs.
- */
- enable_plugin('uservalidationbyemail', $CONFIG->site->guid);
-?> \ No newline at end of file
+ */
+ enable_plugin('uservalidationbyemail', $CONFIG->site->guid); \ No newline at end of file
diff --git a/engine/lib/upgrades/2008101303.php b/engine/lib/upgrades/2008101303.php
index c98eace74..69e44e3a0 100644
--- a/engine/lib/upgrades/2008101303.php
+++ b/engine/lib/upgrades/2008101303.php
@@ -1,11 +1,9 @@
<?php
- // Upgrade to solve login issue
-
- if ($users = get_entities_from_metadata('validated_email', '', 'user', '', 0,9999)) {
- foreach($users as $user) {
- set_user_validation_status($user->guid, true, 'email');
- }
- }
-
-?> \ No newline at end of file
+// Upgrade to solve login issue
+
+if ($users = get_entities_from_metadata('validated_email', '', 'user', '', 0, 9999)) {
+ foreach ($users as $user) {
+ set_user_validation_status($user->guid, true, 'email');
+ }
+}
diff --git a/engine/lib/upgrades/2009022701.php b/engine/lib/upgrades/2009022701.php
index 92d540cd3..2e83b56b3 100644
--- a/engine/lib/upgrades/2009022701.php
+++ b/engine/lib/upgrades/2009022701.php
@@ -1,8 +1,7 @@
<?php
global $CONFIG;
-
+
/**
* Disable update client since this has now been removed.
*/
- disable_plugin('updateclient', $CONFIG->site->guid);
-?> \ No newline at end of file
+ disable_plugin('updateclient', $CONFIG->site->guid); \ No newline at end of file
diff --git a/engine/lib/upgrades/2009041701.php b/engine/lib/upgrades/2009041701.php
index 609c7e569..acc8fc0bd 100644
--- a/engine/lib/upgrades/2009041701.php
+++ b/engine/lib/upgrades/2009041701.php
@@ -1,10 +1,9 @@
<?php
global $CONFIG;
-
+
/// Activate kses
/**
* Elgg now has kses tag filtering built as a plugin. This needs to be enabled.
- */
- enable_plugin('kses', $CONFIG->site->guid);
-?> \ No newline at end of file
+ */
+ enable_plugin('kses', $CONFIG->site->guid); \ No newline at end of file
diff --git a/engine/lib/upgrades/2009070101.php b/engine/lib/upgrades/2009070101.php
index edd8ce4b4..3bf89e9b7 100644
--- a/engine/lib/upgrades/2009070101.php
+++ b/engine/lib/upgrades/2009070101.php
@@ -1,11 +1,10 @@
<?php
global $CONFIG;
-
+
/// Deprecate kses and activate htmlawed
/**
* Kses appears to be a dead project so we are deprecating it in favour of htmlawed.
- */
+ */
disable_plugin('kses', $CONFIG->site->guid);
- enable_plugin('htmlawed', $CONFIG->site->guid);
-?> \ No newline at end of file
+ enable_plugin('htmlawed', $CONFIG->site->guid); \ No newline at end of file
diff --git a/engine/lib/upgrades/2009102801.php b/engine/lib/upgrades/2009102801.php
index b72e0a781..8885dbb09 100644
--- a/engine/lib/upgrades/2009102801.php
+++ b/engine/lib/upgrades/2009102801.php
@@ -4,151 +4,176 @@
set_time_limit(0);
/**
- Elgg 1.0
+ * Generates a file matrix like Elgg 1.0 did
+ *
+ * @param string $username Username of user
+ *
+ * @return string File matrix path
*/
-function file_matrix_1_0($username)
-{
+function file_matrix_1_0($username) {
$matrix = "";
-
+
$len = strlen($username);
- if ($len > 5)
+ if ($len > 5) {
$len = 5;
-
+ }
+
for ($n = 0; $n < $len; $n++) {
- if (ctype_alnum($username[$n]))
+ if (ctype_alnum($username[$n])) {
$matrix .= $username[$n] . "/";
- }
+ }
+ }
- return $matrix.$username."/";
+ return $matrix . $username . "/";
}
/**
- Elgg 1.1, 1.2 and 1.5
+ * Generate a file matrix like Elgg 1.1, 1.2 and 1.5
+ *
+ * @param string $filename The filename
+ *
+ * @return string
*/
-function file_matrix_1_1($filename)
-{
+function file_matrix_1_1($filename) {
$matrix = "";
-
+
$name = $filename;
$filename = mb_str_split($filename);
- if (!$filename) return false;
-
+ if (!$filename) {
+ return false;
+ }
+
$len = count($filename);
- if ($len > 5)
+ if ($len > 5) {
$len = 5;
-
+ }
+
for ($n = 0; $n < $len; $n++) {
$matrix .= $filename[$n] . "/";
- }
+ }
- return $matrix.$name."/";
+ return $matrix . $name . "/";
}
-function mb_str_split($string, $charset = 'UTF8')
-{
- if (is_callable('mb_substr'))
- {
+/**
+ * Handle splitting multibyte strings
+ *
+ * @param string $string String to split.
+ * @param string $charset Charset to use.
+ *
+ * @return array|false
+ */
+function mb_str_split($string, $charset = 'UTF8') {
+ if (is_callable('mb_substr')) {
$length = mb_strlen($string);
$array = array();
-
- while ($length)
- {
+
+ while ($length) {
$array[] = mb_substr($string, 0, 1, $charset);
$string = mb_substr($string, 1, $length, $charset);
-
+
$length = mb_strlen($string);
}
-
+
return $array;
- }
- else
+ } else {
return str_split($string);
-
+ }
+
return false;
}
/**
- Elgg 1.6
+ * 1.6 style file matrix
+ *
+ * @param string $filename The filename
+ *
+ * @return string
*/
-function file_matrix_1_6($filename)
-{
+function file_matrix_1_6($filename) {
$invalid_fs_chars = '*\'\\/"!$%^&*.%(){}[]#~?<>;|¬`@-+=';
-
+
$matrix = "";
-
+
$name = $filename;
$filename = mb_str_split($filename);
- if (!$filename) return false;
-
+ if (!$filename) {
+ return false;
+ }
+
$len = count($filename);
- if ($len > 5)
+ if ($len > 5) {
$len = 5;
-
+ }
+
for ($n = 0; $n < $len; $n++) {
-
+
// Prevent a matrix being formed with unsafe characters
$char = $filename[$n];
- if (strpos($invalid_fs_chars, $char)!==false)
+ if (strpos($invalid_fs_chars, $char) !== false) {
$char = '_';
-
+ }
+
$matrix .= $char . "/";
- }
+ }
- return $matrix.$name."/";
+ return $matrix . $name . "/";
}
/**
- * Scans a directory and moves any files from $from to $to
+ * Scans a directory and moves any files from $from to $to
* preserving structure and handling existing paths.
* Will no overwrite files in $to.
*
* TRAILING SLASHES REQUIRED.
*
- * @param $from From dir.
- * @param $to To dir.
- * @param $move Bool. True to move, false to copy.
- * @param $preference str to|from If file collisions, which dir has preference.
+ * @param string $from From dir.
+ * @param string $to To dir.
+ * @param bool $move True to move, false to copy.
+ * @param string $preference to|from If file collisions, which dir has preference.
+ *
+ * @return bool
*/
-function merge_directories($from, $to, $move=false, $preference='to') {
+function merge_directories($from, $to, $move = false, $preference = 'to') {
if (!$entries = scandir($from)) {
return false;
}
-
+
// character filtering needs to be elsewhere.
if (!is_dir($to)) {
mkdir($to, 0700, true);
}
-
+
if ($move === true) {
$f = 'rename';
} else {
$f = 'copy';
}
-
+
foreach ($entries as $entry) {
if ($entry == '.' || $entry == '..') {
continue;
}
-
+
$from_path = $from . $entry;
$to_path = $to . $entry;
-
+
// check to see if the path exists and is a dir, if so, recurse.
if (is_dir($from_path) && is_dir($to_path)) {
$from_path .= '/';
$to_path .= '/';
merge_directories($from_path, $to_path, $move, $preference);
-
+
// since it's a dir that already exists we don't need to move it
continue;
}
-
+
// only move if target doesn't exist or if preference is for the from dir
if (!file_exists($to_path) || $preference == 'from') {
-
+
if ($f($from_path, $to_path)) {
//elgg_dump("Moved/Copied $from_path to $to_path");
}
@@ -158,20 +183,21 @@ function merge_directories($from, $to, $move=false, $preference='to') {
}
}
+/**
+ * Create a 1.7 style user file matrix based upon date.
+ *
+ * @param int $guid Guid of owner
+ *
+ * @return string File matrix path
+ */
function user_file_matrix($guid) {
// lookup the entity
$user = get_entity($guid);
- if ($user->type != 'user')
- {
+ if ($user->type != 'user') {
// only to be used for user directories
return FALSE;
}
-
- if (!$user->time_created) {
- // fall back to deprecated method
- return $this->deprecated_file_matrix($user->username);
- }
-
+
$time_created = date('Y/m/d', $user->time_created);
return "$time_created/$user->guid/";
}
@@ -180,7 +206,8 @@ global $DB_QUERY_CACHE, $DB_PROFILE, $ENTITY_CACHE;
/**
Upgrade file locations
*/
-$users = mysql_query("SELECT guid, username FROM {$CONFIG->dbprefix}users_entity WHERE username != ''");
+$users = mysql_query("SELECT guid, username
+ FROM {$CONFIG->dbprefix}users_entity WHERE username != ''");
while ($user = mysql_fetch_object($users)) {
$DB_QUERY_CACHE = $DB_PROFILE = $ENTITY_CACHE = array();
@@ -188,6 +215,6 @@ while ($user = mysql_fetch_object($users)) {
foreach (array('1_0', '1_1', '1_6') as $version) {
$function = "file_matrix_$version";
$from = $CONFIG->dataroot . $function($user->username);
- merge_directories($from, $to, $move=TRUE, $preference='from');
+ merge_directories($from, $to, $move = TRUE, $preference = 'from');
}
}
diff --git a/engine/lib/upgrades/2010033101.php b/engine/lib/upgrades/2010033101.php
index b137e0285..5c8ee036b 100644
--- a/engine/lib/upgrades/2010033101.php
+++ b/engine/lib/upgrades/2010033101.php
@@ -38,20 +38,24 @@ if ($dbversion < 2009100701) {
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}groups_entity DISABLE KEYS";
$qs[] = "REPLACE INTO {$CONFIG->dbprefix}groups_entity (guid, name, description)
- SELECT guid, unhex(hex(convert(name using latin1))), unhex(hex(convert(description using latin1)))
+ SELECT guid, unhex(hex(convert(name using latin1))),
+ unhex(hex(convert(description using latin1)))
FROM {$CONFIG->dbprefix}groups_entity";
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}groups_entity ENABLE KEYS";
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}objects_entity DISABLE KEYS";
$qs[] = "REPLACE INTO {$CONFIG->dbprefix}objects_entity (guid, title, description)
- SELECT guid, unhex(hex(convert(title using latin1))), unhex(hex(convert(description using latin1)))
+ SELECT guid, unhex(hex(convert(title using latin1))),
+ unhex(hex(convert(description using latin1)))
FROM {$CONFIG->dbprefix}objects_entity";
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}objects_entity ENABLE KEYS";
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity DISABLE KEYS";
- $qs[] = "REPLACE INTO {$CONFIG->dbprefix}users_entity (guid, name, username, password, salt, email, language, code,
+ $qs[] = "REPLACE INTO {$CONFIG->dbprefix}users_entity
+ (guid, name, username, password, salt, email, language, code,
banned, last_action, prev_last_action, last_login, prev_last_login)
- SELECT guid, unhex(hex(convert(name using latin1))), username, password, salt, email, language, code,
+ SELECT guid, unhex(hex(convert(name using latin1))),
+ username, password, salt, email, language, code,
banned, last_action, prev_last_action, last_login, prev_last_login
FROM {$CONFIG->dbprefix}users_entity";
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity ENABLE KEYS";
diff --git a/engine/lib/upgrades/2010060401.php b/engine/lib/upgrades/2010060401.php
index 2106bdbc0..6d628b8eb 100644
--- a/engine/lib/upgrades/2010060401.php
+++ b/engine/lib/upgrades/2010060401.php
@@ -11,7 +11,8 @@ $count = 0;
$user_guids = mysql_query("SELECT guid FROM {$CONFIG->dbprefix}users_entity");
while ($user = mysql_fetch_object($user_guids)) {
- $query = "SELECT * FROM {$CONFIG->dbprefix}entity_relationships WHERE guid_one=$user->guid AND relationship LIKE 'notify%'";
+ $query = "SELECT * FROM {$CONFIG->dbprefix}entity_relationships
+ WHERE guid_one=$user->guid AND relationship LIKE 'notify%'";
$relationships = mysql_query($query);
if (mysql_num_rows($relationships) == 0) {
// no notify relationships for this user
@@ -42,11 +43,12 @@ while ($user = mysql_fetch_object($user_guids)) {
WHERE guid_one=$user->guid AND relationship='$relationship_type'
AND guid_two=$obj->guid_two";
$results = mysql_query($query);
- if (mysql_num_rows($results) == 0) {
- $query = "DELETE FROM {$CONFIG->dbprefix}entity_relationships WHERE id=$obj->id";
- mysql_query($query);
- $count++;
- }
+
+ if (mysql_num_rows($results) == 0) {
+ $query = "DELETE FROM {$CONFIG->dbprefix}entity_relationships WHERE id=$obj->id";
+ mysql_query($query);
+ $count++;
+ }
}
}
diff --git a/engine/lib/upgrades/2010061501.php b/engine/lib/upgrades/2010061501.php
index 2b65cc5c7..d230236fc 100644
--- a/engine/lib/upgrades/2010061501.php
+++ b/engine/lib/upgrades/2010061501.php
@@ -1,7 +1,7 @@
<?php
/**
* utf8 conversion and file merging for usernames with multibyte chars
- *
+ *
*/
@@ -14,56 +14,60 @@ if ($dbversion < 2009100701) {
// start a new link to the DB to see what its defaults are.
$link = mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass, TRUE);
mysql_select_db($CONFIG->dbname, $link);
-
+
$q = "SHOW VARIABLES LIKE 'character_set_client'";
$r = mysql_query($q);
$client = mysql_fetch_assoc($r);
-
+
$q = "SHOW VARIABLES LIKE 'character_set_connection'";
$r = mysql_query($q);
$connection = mysql_fetch_assoc($r);
-
+
// only run upgrade if not already talking utf8
if ($client['Value'] != 'utf8' && $connection['Value'] != 'utf8') {
$qs = array();
$qs[] = "SET NAMES utf8";
-
+
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity DISABLE KEYS";
- $qs[] = "REPLACE INTO {$CONFIG->dbprefix}users_entity (guid, name, username, password, salt, email, language, code,
- banned, admin, last_action, prev_last_action, last_login, prev_last_login)
- SELECT guid, name, unhex(hex(convert(username using latin1))), password, salt, email, language, code,
+ $qs[] = "REPLACE INTO {$CONFIG->dbprefix}users_entity
+ (guid, name, username, password, salt, email, language, code,
+ banned, admin, last_action, prev_last_action, last_login, prev_last_login)
+
+ SELECT guid, name, unhex(hex(convert(username using latin1))),
+ password, salt, email, language, code,
banned, admin, last_action, prev_last_action, last_login, prev_last_login
FROM {$CONFIG->dbprefix}users_entity";
-
+
$qs[] = "ALTER TABLE {$CONFIG->dbprefix}users_entity ENABLE KEYS";
-
+
foreach ($qs as $q) {
if (!update_data($q)) {
throw new Exception('Couldn\'t execute upgrade query: ' . $q);
}
}
-
+
global $DB_QUERY_CACHE, $DB_PROFILE, $ENTITY_CACHE;
-
+
/**
Upgrade file locations
*/
// new connection to force into utf8 mode to get the old name
$link = mysql_connect($CONFIG->dbhost, $CONFIG->dbuser, $CONFIG->dbpass, TRUE);
mysql_select_db($CONFIG->dbname, $link);
-
+
// must be the first command
mysql_query("SET NAMES utf8");
-
- $users = mysql_query("SELECT guid, username FROM {$CONFIG->dbprefix}users_entity WHERE username != ''", $link);
+
+ $users = mysql_query("SELECT guid, username FROM {$CONFIG->dbprefix}users_entity
+ WHERE username != ''", $link);
while ($user = mysql_fetch_object($users)) {
$DB_QUERY_CACHE = $DB_PROFILE = $ENTITY_CACHE = array();
-
+
$to = $CONFIG->dataroot . user_file_matrix($user->guid);
foreach (array('1_0', '1_1', '1_6') as $version) {
$function = "file_matrix_$version";
$from = $CONFIG->dataroot . $function($user->username);
- merge_directories($from, $to, $move=TRUE, $preference='from');
+ merge_directories($from, $to, $move = TRUE, $preference = 'from');
}
}
}
diff --git a/engine/lib/upgrades/2010062301.php b/engine/lib/upgrades/2010062301.php
index 049a93440..f679fa46d 100644
--- a/engine/lib/upgrades/2010062301.php
+++ b/engine/lib/upgrades/2010062301.php
@@ -14,7 +14,8 @@ if ($groups) {
$acl = $group->group_acl;
try {
- $query = "UPDATE {$CONFIG->dbprefix}access_collections SET owner_guid = $group->guid WHERE id = $acl";
+ $query = "UPDATE {$CONFIG->dbprefix}access_collections
+ SET owner_guid = $group->guid WHERE id = $acl";
update_data($query);
} catch (Exception $e) {
// no acl so create one
diff --git a/engine/lib/upgrades/2010071001.php b/engine/lib/upgrades/2010071001.php
index 4df044cff..1b5d379d8 100644
--- a/engine/lib/upgrades/2010071001.php
+++ b/engine/lib/upgrades/2010071001.php
@@ -3,6 +3,14 @@
* Change profile image names to use guid rather than username
*/
+/**
+ * Need the same function to generate a user matrix, but can't call it
+ * the same thing as the previous update.
+ *
+ * @param int $guid User guid.
+ *
+ * @return string File matrix
+ */
function user_file_matrix_2010071001($guid) {
// lookup the entity
$user = get_entity($guid);
@@ -23,7 +31,8 @@ function user_file_matrix_2010071001($guid) {
$sizes = array('large', 'medium', 'small', 'tiny', 'master', 'topbar');
global $DB_QUERY_CACHE, $DB_PROFILE, $ENTITY_CACHE, $CONFIG;
-$users = mysql_query("SELECT guid, username FROM {$CONFIG->dbprefix}users_entity WHERE username != ''");
+$users = mysql_query("SELECT guid, username FROM {$CONFIG->dbprefix}users_entity
+ WHERE username != ''");
while ($user = mysql_fetch_object($users)) {
$DB_QUERY_CACHE = $DB_PROFILE = $ENTITY_CACHE = array();
diff --git a/engine/lib/upgrades/2010071002.php b/engine/lib/upgrades/2010071002.php
index cdf08c830..30bd6538c 100644
--- a/engine/lib/upgrades/2010071002.php
+++ b/engine/lib/upgrades/2010071002.php
@@ -6,7 +6,8 @@
// loop through all users checking collections and notifications
global $DB_QUERY_CACHE, $DB_PROFILE, $ENTITY_CACHE, $CONFIG;
global $NOTIFICATION_HANDLERS;
-$users = mysql_query("SELECT guid, username FROM {$CONFIG->dbprefix}users_entity WHERE username != ''");
+$users = mysql_query("SELECT guid, username FROM {$CONFIG->dbprefix}users_entity
+ WHERE username != ''");
while ($user = mysql_fetch_object($users)) {
$DB_QUERY_CACHE = $DB_PROFILE = $ENTITY_CACHE = array();
@@ -25,7 +26,7 @@ while ($user = mysql_fetch_object($users)) {
// check the all friends notifications
if ($collection_id == -1) {
$options = array(
- 'relationship' => 'friend',
+ 'relationship' => 'friend',
'relationship_guid' => $user->guid,
'limit' => 0
);