diff --git a/e107_core/shortcodes/single/user_avatar.php b/e107_core/shortcodes/single/user_avatar.php
index 78a5afcdc..feeef3767 100644
--- a/e107_core/shortcodes/single/user_avatar.php
+++ b/e107_core/shortcodes/single/user_avatar.php
@@ -5,8 +5,8 @@ function user_avatar_shortcode($parm='')
global $loop_uid;
- $height = e107::getPref("im_height");
- $width = e107::getPref("im_width");
+ $height = e107::getPref("im_height",100);
+ $width = e107::getPref("im_width",100);
$tp = e107::getParser();
if(intval($loop_uid) > 0 && trim($parm) == "")
@@ -65,7 +65,7 @@ function user_avatar_shortcode($parm='')
$img = $tp->thumbUrl(e_IMAGE."generic/blank_avatar.jpg","w=".$width."&h=".$height,true);
}
- $text = "";
+ $text = "";
// return $img;
return $text;
diff --git a/e107_plugins/forum/forum_setup.php b/e107_plugins/forum/forum_setup.php
index 90b3ac3ef..2dec48132 100644
--- a/e107_plugins/forum/forum_setup.php
+++ b/e107_plugins/forum/forum_setup.php
@@ -61,7 +61,7 @@ class forum_setup
{
//Redirect upgrade to customized upgrade routine
- e107::getRedirect()->redirect(e_PLUGIN.'forum/forum_update.php');
+ e107::getRedirect()->redirect(e_PLUGIN_ABS.'forum/forum_update.php');
//header('Location: '.e_PLUGIN.'forum/forum_update.php');
}
diff --git a/e107_plugins/forum/forum_update.php b/e107_plugins/forum/forum_update.php
index ab7f72ba1..322b4b4eb 100644
--- a/e107_plugins/forum/forum_update.php
+++ b/e107_plugins/forum/forum_update.php
@@ -26,19 +26,31 @@ require_once (e_ADMIN . 'auth.php');
if (e_QUERY == "reset")
{
unset($_SESSION['forumUpgrade']);
- unset($_SESSION['forumupdate_thread_last']);
- unset($_SESSION['forumupdate_thread_count']);
+ unset($_SESSION['forumupdate']);
}
-//unset($_SESSION['forumupdate_thread_last']);
-// unset($_SESSION['forumupdate_thread_count']);
+
+
+//unset($_SESSION['forumupdate']['thread_last']);
+// unset($_SESSION['forumupdate']['thread_count']);
$forum = new e107forum(true);
$timestart = microtime();
$f = new forumUpgrade;
-$e107 = e107::getInstance();
+
$sql = e107::getDb();
+if($_GET['reset'])
+{
+ unset($_SESSION['forumUpgrade']);
+ unset($_SESSION['forumupdate']);
+ $f -> updateInfo['currentStep'] = intval($_GET['reset']);
+ $f -> setUpdateInfo();
+
+}
+
+
+
if (e_AJAX_REQUEST)
{
if (!vartrue($_GET['mode']))
@@ -109,7 +121,6 @@ function step1()
$f -> updateInfo['currentStep'] = 1;
$f -> setUpdateInfo();
- $e107 = e107::getInstance();
$mes = e107::getMessage();
//Check attachment dir permissions
if (!isset($f -> updateInfo['skip_attach']))
@@ -149,7 +160,6 @@ function step1()
function step2()
{
- $e107 = e107::getInstance();
$mes = e107::getMessage();
$ns = e107::getRender();
@@ -159,7 +169,7 @@ function step2()
This step will create the new forum_thread, forum_post, and forum_attach tables. It will also create a forum_new table that will become the 'real' forum table once the data from the current table is migrated.
";
$ns -> tablerender('Step 2: Forum table creation', $text);
@@ -205,7 +215,7 @@ function step2()
else
{
$text = "";
}
$ns -> tablerender('Step 2: Forum table creation', $mes -> render() . $text);
@@ -224,11 +234,13 @@ function step3()
{
$text = "
This step will create the new extended user fields required for the new forum code:
- * user_plugin_forum_posts (to track number of posts for each user)
- * user_plugin_forum_viewed (to track threads viewed by each user
+
+
user_plugin_forum_posts (to track number of posts for each user)
+
user_plugin_forum_viewed (to track threads viewed by each user
+
";
@@ -270,7 +282,7 @@ function step3()
{
$text .= "
";
}
@@ -282,7 +294,7 @@ function step3()
function step4()
{
global $pref;
- $e107 = e107::getInstance();
+
$mes = e107::getMessage();
$ns = e107::getRender();
@@ -296,7 +308,7 @@ function step4()
Depending on the size of your user table, this step could take a while.
";
$text .= "
";
$ns -> tablerender($stepCaption, $mes -> render() . $text);
@@ -487,7 +497,7 @@ function step5()
$text = "
";
@@ -496,160 +506,66 @@ function step5()
}
}
-function step6x()
-{
- global $f;
- $e107 = e107::getInstance();
- $ns = e107::getRender();
- $mes = e107::getMessage();
- $sql = e107::getDb();
- $stepCaption = 'Step 6: Thread and post data';
- $threadLimit = varset($_POST['threadLimit'], 1000);
- $lastThread = varset($f -> updateInfo['lastThread'], 0);
- $maxTime = ini_get('max_execution_time');
-
- if (!isset($_POST['move_thread_data']))
- {
- $count = $sql -> count('forum_t', '(*)', "WHERE thread_parent = 0 AND thread_id > {$lastThread}");
- $limitDropdown = createThreadLimitDropdown($count);
-
- $text = "This step will copy all of your existing forum threads and posts into the new `forum_thread` and `forum_post` tables.
- Depending on your forum size and speed of server, this could take some time. This routine will attempt to do it in steps in order to
- reduce the possibility of data loss and server timeouts.
-
- Your current timeout appears to be set at {$maxTime} seconds. This routine will attempt to extend this time in order to process all threads,
- success will depend on your server configuration. If you get a timeout while performing this function, return to this page and select fewer threads
- to process.
- ";
-
- $text .= "";
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
- return;
- }
-
- $count = $sql -> count('forum_t', '(*)', "WHERE thread_parent=0 AND thread_id>{$lastThread}");
- if ($count === false)
- {
- echo "error: Unable to determine last thread id";
- exit ;
- }
- $done = false;
-
- $qry = "
- SELECT thread_id FROM `#forum_t`
- WHERE thread_parent = 0
- AND thread_id > {$lastThread}
- ORDER BY thread_id ASC
- LIMIT 0, {$threadLimit}
- ";
- if ($sql -> gen($qry))
- {
- $postCount = 0;
- $threadList = $sql -> db_getList();
-
- foreach ($threadList as $t)
- {
- set_time_limit(30);
- $id = (int)$t['thread_id'];
- $result = $f -> migrateThread($id);
- if ($result === false)
- {
- $mes -> addError("ERROR! Failed to migrate thread id: {$id}");
- }
- else
- {
- $postCount += ($result - 1);
- $f -> updateInfo['lastThread'] = $id;
- $f -> setUpdateInfo();
- }
- }
-
- $mes -> addSuccess('Successfully converted ' . count($threadList) . " threads and {$postCount} replies");
- $mes -> addSuccess("Last thread id = {$t['thread_id']}");
-
- $count = $sql -> count('forum_t', '(*)', "WHERE thread_parent = 0 AND thread_id > {$f->updateInfo['lastThread']}");
-
- if ($count)
- {
- $limitDropdown = createThreadLimitDropdown($count);
- $text .= "
-
- ";
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
- }
- else
- {
- $done = true;
- }
- }
- else
- {
- $done = true;
- }
- if ($done)
- {
- $mes -> addSuccess("Thread migration is complete!!");
- $text = "";
-
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
- }
-
-}
function step6()
{
$sql = e107::getDb();
$ns = e107::getRender();
$mes = e107::getMessage();
+
$stepCaption = 'Step 6: Thread and post data';
- $_SESSION['forumupdate_thread_total'] = $sql -> count('forum_t', '(*)', "WHERE thread_parent = 0");
- $_SESSION['forumupdate_thread_count'] = 0;
- $_SESSION['forumupdate_thread_last'] = 0;
+ $_SESSION['forumupdate']['thread_total'] = $sql -> count('forum_t', '(*)', "WHERE thread_parent = 0");
+ $_SESSION['forumupdate']['thread_count'] = 0;
+ $_SESSION['forumupdate']['thread_last'] = 0;
$text = "This step will copy all of your existing forum threads and posts into the new `forum_thread` and `forum_post` tables.
Depending on your forum size and speed of server, this could take some time.
";
- // $text .= "";
- $ns -> tablerender($stepCaption, $mes -> render() . $text);
-
+ $text .= "";
+
+ return $text;
}
+
+
function step6_ajax()
{
global $f;
$sql = e107::getDb();
- $lastThread = vartrue($_SESSION['forumupdate_thread_last'], 0);
+ $lastThread = vartrue($_SESSION['forumupdate']['thread_last'], 0);
$qry = "
SELECT thread_id FROM `#forum_t`
@@ -674,20 +590,22 @@ function step6_ajax()
}
else
{
- $_SESSION['forumupdate_thread_last'] = $id;
- $_SESSION['forumupdate_thread_count']++;
+ $_SESSION['forumupdate']['thread_last'] = $id;
+ $_SESSION['forumupdate']['thread_count']++;
}
}
}
- echo round(($_SESSION['forumupdate_thread_count'] / $_SESSION['forumupdate_thread_total']) * 100);
+ echo round(($_SESSION['forumupdate']['thread_count'] / $_SESSION['forumupdate']['thread_total']) * 100, 1);
}
+
+
+
function step7()
{
- $e107 = e107::getInstance();
$ns = e107::getRender();
$stepCaption = 'Step 7: Calculate user post counts';
if (!isset($_POST['calculate_usercounts']))
@@ -696,7 +614,7 @@ function step7()
This step will calculate post count information for all users, as well as recount all for thread and reply counts.
";
$ns -> tablerender($stepCaption, $text);
@@ -720,59 +638,78 @@ function step7()
Successfully recalculated forum posts for " . count($counts) . " users.
";
$ns -> tablerender($stepCaption, $text);
}
-function step7_ajax()//TODO
-{
-}
+
+
+
+
+
function step8()
{
- $e107 = e107::getInstance();
+ $sql = e107::getDb();
+ $mes = e107::getMessage();
+
$stepCaption = 'Step 8: Calculate last post information';
- if (!isset($_POST['calculate_lastpost']))
- {
- $text = "
- This step will recalculate all thread and forum lastpost information
-
-
- ";
- e107::getRender() -> tablerender($stepCaption, $text);
- return;
- }
+
+
+ $_SESSION['forumupdate']['lastpost_total'] = $sql -> count('forum', '(*)', "WHERE forum_parent != 0");
+ $_SESSION['forumupdate']['lastpost_count'] = 0;
+ $_SESSION['forumupdate']['lastpost_last'] = 0;
+
+ $mes->addDebug("Total LastPost: ".$_SESSION['forumupdate']['lastpost_total']);
+
+ $text = "
+ This step will recalculate all thread and forum lastpost information";
+
+ $text .= renderProgress('Proceed with lastpost calculation',8);
+
+ e107::getRender() -> tablerender($stepCaption, $mes->render(). $text);
+ return;
+
+}
+
+function step8_ajax()
+{
+ $sql = e107::getDb();
+
+ $lastThread = vartrue($_SESSION['forumupdate']['lastpost_last'], 0);
+
global $forum;
- $forum -> forumUpdateLastpost('forum', 'all', true);
+ if ($sql->select('forum', 'forum_id', 'forum_parent != 0 AND forum_id > '.$lastThread.' ORDER BY forum_id LIMIT 2'))
+ {
+ while ($row = $sql->fetch(MYSQL_ASSOC))
+ {
+ $parentList[] = $row['forum_id'];
+ }
- // $forum->forumUpdateLastpost('thread', 84867);
+ foreach($parentList as $id)
+ {
+ set_time_limit(60);
+ $forum->forumUpdateLastpost('forum', $id, $updateThreads);
+ $_SESSION['forumupdate']['lastpost_last'] = $id;
+ $_SESSION['forumupdate']['lastpost_count']++;
+ }
+ }
- $text .= "
- Successfully recalculated lastpost information for all forums and threads.
-
-
- ";
- e107::getRender() -> tablerender($stepCaption, $text);
+ echo round(($_SESSION['forumupdate']['lastpost_count'] / $_SESSION['forumupdate']['lastpost_total']) * 100);
}
-function step8_ajax()//TODO
-{
-}
function step9()
{
- $e107 = e107::getInstance();
+
$sql = e107::getDb();
+
$stepCaption = 'Step 9: Migrate poll information';
if (!isset($_POST['migrate_polls']))
{
@@ -780,7 +717,7 @@ function step9()
This step will recalculate all poll information that has been entered in the forums.
";
e107::getRender() -> tablerender($stepCaption, $text);
@@ -829,267 +766,17 @@ function step9()
Successfully migrated forum poll information for " . count($threadList) . " thread poll(s).
";
e107::getRender() -> tablerender($stepCaption, $text);
}
-function step9_ajax()//TODO
-{
-}
-/*
- function step10x()
- {
- $e107 = e107::getInstance();
- $sql = e107::getDb();
- $ns = e107::getRender();
-
- global $f;
- $stepCaption = 'Step 10: Migrate forum attachments';
-
- //FIXME - Files should be moved to e107_media/files/forum/
- if(!isset($_POST['migrate_attachments']))
- {
- $text = "
- This step will migrate all forum attachment information.
- All files will be moved from the e107_files/public directory into the
-".e_MEDIA."plugins/forum/attachment directory and related posts will be updated
-accordingly.
-
-
- ";
- $ns->tablerender($stepCaption, $text);
- return;
- }
-
- $qry = "
- SELECT post_id, post_entry FROM `#forum_post`
- WHERE post_entry REGEXP '_[[:digit:]]+_FT'
- ";
-
- if($sql->gen($qry))
- {
- while($row = $sql->fetch(MYSQL_ASSOC))
- {
- $postList[] = $row;
- }
- $i = 0;
- $pcount = 0;
- $f->log("Found ".count($postList). " posts with attachments");
-
- //XXX Run post through $tp->toHtml() and then use $tp->getTag() to find images
-// or files.?
- foreach($postList as $post)
- {
- // echo htmlentities($post['post_entry'])." ";
- $i++;
- // if($pcount++ > 10) { die('here 10'); }
- $attachments = array();
- $foundFiles = array();
-
- // echo $post['post_entry']."
";
$ns -> tablerender($stepCaption, $text);
@@ -1116,25 +803,14 @@ function step10()
}
$text = "
- This step will migrate the forum attachment information that was found in " . $_SESSION['forumupdate_attachment_total'] . " posts.
+ This step will migrate the forum attachment information that was found in " . $_SESSION['forumupdate']['attachment_total'] . " posts.
All files will be moved from the e107_files/public directory into the " . e_MEDIA . "plugins/forum/ directory and related posts will be updated accordingly.
+
";
$ns -> tablerender($stepCaption, $text);
return;
@@ -1444,7 +1182,7 @@ function step11()
There were no orphaned files found
";
$ns -> tablerender($stepCaption, $text);
@@ -1462,35 +1200,36 @@ function step12()
$stepCaption = 'Step 12: Delete old forum data';
- if (!isset($_POST['delete_old']))
+ if (!isset($_POST['delete_old']) && !isset($_POST['skip_delete_old']))
{
$text = "
The forum upgrade should now be complete. During the upgrade process the old forum tables were
- retained, it is now time to remove the tables.
+ retained. You may choose to keep these tables as a backup or delete them.
We will also be marking the forum upgrade as completed!