-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds new upgrade script to fix bad paths in user profile extensions a…
…nd default avatar. Also updates the fix_database upgrade script to only run when upgrading from OLD versions. [#456 #458 state:resolved]
- Loading branch information
Showing
2 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
################################################## | ||
# | ||
# Copyright (c) 2004-2011 OIC Group, Inc. | ||
# Written and Designed by James Hunt | ||
# | ||
# This file is part of Exponent | ||
# | ||
# Exponent is free software; you can redistribute | ||
# it and/or modify it under the terms of the GNU | ||
# General Public License as published by the Free | ||
# Software Foundation; either version 2 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# GPL: http://www.gnu.org/licenses/gpl.txt | ||
# | ||
################################################## | ||
|
||
/** | ||
* @subpackage Upgrade | ||
* @package Installation | ||
*/ | ||
|
||
/** | ||
* This is the class update_profile_paths | ||
*/ | ||
class update_profile_paths extends upgradescript { | ||
protected $from_version = '1.99.0'; | ||
protected $to_version = '2.0.3'; // code was corrected in 2.0.4 | ||
|
||
/** | ||
* name/title of upgrade script | ||
* @return string | ||
*/ | ||
function name() { return "Corrects bad user profile extension path entries"; } | ||
|
||
/** | ||
* generic description of upgrade script | ||
* @return string | ||
*/ | ||
function description() { return "Prior to Exponent 2.0.4, the User profile extension table contained full paths which prevented moving Exponent to a new folder after a test install. | ||
There was also an issue with the default user avatar path entry. This Script deletes the bad entry placing the correct ones"; } | ||
|
||
/** | ||
* additional test(s) to see if upgrade script should be run | ||
* @return bool | ||
*/ | ||
function needed() { | ||
return true; // we'll just do it ine very instance instead of testing if user profile extensions are active | ||
} | ||
|
||
/** | ||
* coverts all headline modules/items into text modules/items and deletes headline controller files | ||
* @return bool | ||
*/ | ||
function upgrade() { | ||
global $db; | ||
|
||
// update each bad default avatar reference to default | ||
$badavatarurls = $db->selectObjects('user_avatar',"image = ''URL_FULL .'"); | ||
foreach ($badavatarurls as $badavatarurl) { | ||
$badavatarurl->image = URL_FULL.'framework/modules/users/assets/images/avatar_not_found.jpg'; | ||
$db->updateObject($badavatarurl,'user_avatar'); | ||
} | ||
|
||
// convert each active user profile extension path from a full to relative path | ||
$extdirs = array( | ||
'framework/modules/users/extensions', | ||
'themes/'.DISPLAY_THEME.'framework/modules/users/extensions' | ||
); | ||
foreach ($extdirs as $dir) { | ||
if (is_readable(BASE.$dir)) { | ||
$dh = opendir(BASE.$dir); | ||
while (($file = readdir($dh)) !== false) { | ||
if (is_file(BASE."$dir/$file") && is_readable(BASE."$dir/$file") && substr($file, 0, 1) != '_' && substr($file, 0, 1) != '.') { | ||
$classname = substr($file,0,-4); | ||
$extension = $db->selectObject('profileextension', "classname='".$classname."'"); | ||
if (!empty($extension->id)) { | ||
$extension->classfile = "$dir/$file"; | ||
$db->updateObject($extension,'profileextension'); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return gt('User Profile Extension Paths Corrected'); | ||
} | ||
} | ||
|
||
?> |