mirror of
https://github.com/e107inc/e107.git
synced 2025-07-25 17:01:43 +02:00
More forum migration work, only attachments left (I think)
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
* Message Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
|
||||
* $Revision: 1.34 $
|
||||
* $Date: 2008-12-23 20:48:24 $
|
||||
* $Revision: 1.35 $
|
||||
* $Date: 2008-12-24 04:51:27 $
|
||||
* $Author: mcfly_e107 $
|
||||
*
|
||||
*/
|
||||
@@ -455,7 +455,7 @@ class e107forum
|
||||
return $e107->sql->db_Count('forum_post', '(*)', "WHERE post_id <= {$postId} AND post_thread = {$threadId} ORDER BY post_id ASC");
|
||||
}
|
||||
|
||||
function forumUpdateLastpost($type, $id, $update_threads = FALSE)
|
||||
function forumUpdateLastpost($type, $id, $updateThreads = false)
|
||||
{
|
||||
global $sql, $tp;
|
||||
$sql2 = new db;
|
||||
@@ -472,15 +472,17 @@ class e107forum
|
||||
else
|
||||
{
|
||||
$tmp['thread_lastuser'] = 0;
|
||||
$tmp['thread_lastuser_anon'] = $lpInfo['post_user_anon'];
|
||||
$tmp['thread_lastuser_anon'] = ($lpInfo['post_user_anon'] ? $lpInfo['post_user_anon'] : 'Anonymous');
|
||||
}
|
||||
$tmp['thread_lastpost'] = $lpInfo['post_datestamp'];
|
||||
$tmp['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
|
||||
$tmp['WHERE'] = 'thread_id = '.$id;
|
||||
$sql->db_Update('forum_thread', $tmp);
|
||||
|
||||
return $lpInfo;
|
||||
}
|
||||
if ($type == 'forum') {
|
||||
if ($type == 'forum')
|
||||
{
|
||||
if ($id == 'all')
|
||||
{
|
||||
if ($sql->db_Select('forum', 'forum_id', 'forum_parent != 0'))
|
||||
@@ -491,7 +493,8 @@ class e107forum
|
||||
}
|
||||
foreach($parentList as $id)
|
||||
{
|
||||
$this->forumUpdateLastpost('forum', $id, $update_threads);
|
||||
set_time_limit(60);
|
||||
$this->forumUpdateLastpost('forum', $id, $updateThreads);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -500,13 +503,14 @@ class e107forum
|
||||
$id = (int)$id;
|
||||
$lp_info = '';
|
||||
$lp_user = 'NULL';
|
||||
if($update_threads == true)
|
||||
if($updateThreads == true)
|
||||
{
|
||||
if ($sql2->db_Select('forum_t', 'thread_id', "thread_forum_id = $id AND thread_parent = 0"))
|
||||
{
|
||||
while ($row = $sql2->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$this->update_lastpost('thread', $row['thread_id']);
|
||||
set_time_limit(60);
|
||||
$this->forumUpdateLastpost('thread', $row['thread_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1011,7 +1015,8 @@ class e107forum
|
||||
$flist = $e107->sql->db_getList();
|
||||
foreach($flist as $f)
|
||||
{
|
||||
$this->forumUpdateCounts($f['forum_id']);
|
||||
set_time_limit(60);
|
||||
$this->forumUpdateCounts($f['forum_id'], $recalcThreads);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1019,8 +1024,9 @@ class e107forum
|
||||
$threads = $e107->sql->db_Count('forum_thread', '(*)', 'WHERE thread_forum_id='.$forumId);
|
||||
$replies = $e107->sql->db_Count('forum_post', '(*)', 'WHERE post_forum='.$forumId);
|
||||
$e107->sql->db_Update('forum', "forum_threads={$threads}, forum_replies={$replies} WHERE forum_id={$forumId}");
|
||||
if($recalc_threads == true)
|
||||
if($recalcThreads == true)
|
||||
{
|
||||
set_time_limit(60);
|
||||
$e107->sql->db_Select('forum_post', 'post_thread, count(post_thread) AS replies', "post_forum={$forumId} GROUP BY post_thread");
|
||||
$tlist = $e107->sql->db_getList();
|
||||
foreach($tlist as $t)
|
||||
|
@@ -9,8 +9,8 @@
|
||||
* Message Handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_update.php,v $
|
||||
* $Revision: 1.9 $
|
||||
* $Date: 2008-12-23 20:48:24 $
|
||||
* $Revision: 1.10 $
|
||||
* $Date: 2008-12-24 04:51:27 $
|
||||
* $Author: mcfly_e107 $
|
||||
*
|
||||
*/
|
||||
@@ -507,7 +507,7 @@ function step7()
|
||||
if(!isset($_POST['calculate_usercounts']))
|
||||
{
|
||||
$text = "
|
||||
This step will calculate post count information for all users
|
||||
This step will calculate post count information for all users, as well as recount all for thread and reply counts.
|
||||
<br /><br />
|
||||
<form method='post'>
|
||||
<input class='button' type='submit' name='calculate_usercounts' value='Proceed with post count calculation' />
|
||||
@@ -526,6 +526,8 @@ function step7()
|
||||
{
|
||||
$ue->user_extended_setvalue($uid, 'user_plugin_forum_posts', $count, 'int');
|
||||
}
|
||||
$forum->forumUpdateCounts('all', true);
|
||||
|
||||
|
||||
// var_dump($counts);
|
||||
|
||||
@@ -539,6 +541,211 @@ function step7()
|
||||
$e107->ns->tablerender($stepCaption, $text);
|
||||
}
|
||||
|
||||
function step8()
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
$stepCaption = 'Step 8: Calculate last post information';
|
||||
if(!isset($_POST['calculate_lastpost']))
|
||||
{
|
||||
$text = "
|
||||
This step will recalculate all thread and forum lastpost information
|
||||
<br /><br />
|
||||
<form method='post'>
|
||||
<input class='button' type='submit' name='calculate_lastpost' value='Proceed with lastpost calculation' />
|
||||
</form>
|
||||
";
|
||||
$e107->ns->tablerender($stepCaption, $text);
|
||||
return;
|
||||
}
|
||||
|
||||
global $forum;
|
||||
|
||||
$forum->forumUpdateLastpost('forum', 'all', true);
|
||||
|
||||
|
||||
// $forum->forumUpdateLastpost('thread', 84867);
|
||||
|
||||
|
||||
$text .= "
|
||||
Successfully recalculated lastpost information for all forums and threads.
|
||||
<br /><br />
|
||||
<form method='post'>
|
||||
<input class='button' type='submit' name='nextStep[9]' value='Proceed to step 9' />
|
||||
</form>
|
||||
";
|
||||
$e107->ns->tablerender($stepCaption, $text);
|
||||
}
|
||||
|
||||
function step9()
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
$stepCaption = 'Step 9: Migrate poll information';
|
||||
if(!isset($_POST['migrate_polls']))
|
||||
{
|
||||
$text = "
|
||||
This step will recalculate all poll information that has been entered in the forums.
|
||||
<br /><br />
|
||||
<form method='post'>
|
||||
<input class='button' type='submit' name='migrate_polls' value='Proceed with poll migration' />
|
||||
</form>
|
||||
";
|
||||
$e107->ns->tablerender($stepCaption, $text);
|
||||
return;
|
||||
}
|
||||
|
||||
$qry = "
|
||||
SELECT t.thread_id, p.poll_id FROM `#polls` AS p
|
||||
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.poll_datestamp
|
||||
WHERE t.thread_id IS NOT NULL
|
||||
";
|
||||
if($e107->sql->db_Select_gen($qry))
|
||||
{
|
||||
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$threadList[] = $row['thread_id'];
|
||||
}
|
||||
foreach($threadList as $threadId)
|
||||
{
|
||||
if($e107->sql->db_Select('forum_thread', 'thread_options', 'thread_id = '.$threadId, 'default', true))
|
||||
{
|
||||
$row = $e107->sql->db_Fetch(MYSQL_ASSOC);
|
||||
if($row['thread_options'])
|
||||
{
|
||||
$opts = unserialize($row['thread_options']);
|
||||
$opts['poll'] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$opts = array('poll' => 1);
|
||||
}
|
||||
$tmp = array();
|
||||
$tmp['thread_options'] = serialize($opts);
|
||||
$tmp['WHERE'] = 'thread_id = '.$threadId;
|
||||
$tmp['_FIELD_TYPES']['thread_options'] = 'escape';
|
||||
$e107->sql->db_Update('forum_thread', $tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = 'No threads found! <br />';
|
||||
}
|
||||
|
||||
$text .= "
|
||||
Successfully migrated forum poll information for ".count($threadList)." thread poll(s).
|
||||
<br /><br />
|
||||
<form method='post'>
|
||||
<input class='button' type='submit' name='nextStep[10]' value='Proceed to step 10' />
|
||||
</form>
|
||||
";
|
||||
$e107->ns->tablerender($stepCaption, $text);
|
||||
}
|
||||
|
||||
function step10()
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
$stepCaption = 'Step 9: Migrate forum attachments';
|
||||
if(!isset($_POST['migrate_attachments']))
|
||||
{
|
||||
$text = "
|
||||
This step will migrate all forum attachment information.<br />
|
||||
All files will be moved from the e107_files/public directory into the e107_plugins/forum/attachment directory and related posts will be updated accordingly.
|
||||
<br /><br />
|
||||
<form method='post'>
|
||||
<input class='button' type='submit' name='migrate_attachments' value='Proceed with attachment migration' />
|
||||
</form>
|
||||
";
|
||||
$e107->ns->tablerender($stepCaption, $text);
|
||||
return;
|
||||
}
|
||||
|
||||
$qry = "
|
||||
SELECT thread_id, thread_thread FROM `#forum_t`
|
||||
WHERE thread_thread REGEXP '_[[:digit:]]+_FT'
|
||||
";
|
||||
if($e107->sql->db_Select_gen($qry))
|
||||
{
|
||||
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
|
||||
{
|
||||
$postList[] = $row;
|
||||
}
|
||||
$attachments = array();
|
||||
foreach($postList as $post)
|
||||
{
|
||||
//<div class='spacer'>[img:width=604&height=453]{e_FILE}public/1229562306_1_FT0_julia.jpg[/img]</div>
|
||||
//Check for attached full-size images
|
||||
if(preg_match_all('#<div.*?>\[img.*?\]({e_FILE}.*?_FT\d+_.*?)\[/img\]</div>#ms', $post['thread_thread'], $matches, PREG_SET_ORDER))
|
||||
{
|
||||
foreach($matches as $match)
|
||||
{
|
||||
// print_a($matches);
|
||||
$att = array();
|
||||
$att['thread_id'] = $post['thread_id'];
|
||||
$att['type'] = 'img';
|
||||
$att['html'] = $match[0];
|
||||
$att['name'] = $match[1];
|
||||
$att['thumb'] = '';
|
||||
$attachments[] = $att;
|
||||
}
|
||||
}
|
||||
|
||||
//[link={e_FILE}public/1230091080_1_FT0_julia.jpg][img:width=60&height=45]{e_FILE}public/1230091080_1_FT0_julia_.jpg[/img][/link][br]
|
||||
//Check for images with thumbnails linking to full size
|
||||
if(preg_match_all('#\[link=(.*?)\]\[img.*?\]({e_FILE}.*?)\[/img\]\[/link\]#ms', $post['thread_thread'], $matches, PREG_SET_ORDER))
|
||||
{
|
||||
foreach($matches as $match)
|
||||
{
|
||||
// print_a($matches);
|
||||
$att = array();
|
||||
$att['thread_id'] = $post['thread_id'];
|
||||
$att['type'] = 'img';
|
||||
$att['html'] = $match[0];
|
||||
$att['name'] = $match[1];
|
||||
$att['thumb'] = $match[2];
|
||||
$attachments[] = $att;
|
||||
}
|
||||
}
|
||||
|
||||
//[file={e_FILE}public/1230090820_1_FT0_julia.zip]julia.zip[/file]
|
||||
//Check for attached file (non-images)
|
||||
if(preg_match_all('#\[file=({e_FILE}.*?)\](.*?)\[/file\]#ms', $post['thread_thread'], $matches, PREG_SET_ORDER))
|
||||
{
|
||||
foreach($matches as $match)
|
||||
{
|
||||
// print_a($matches);
|
||||
$att = array();
|
||||
$att['thread_id'] = $post['thread_id'];
|
||||
$att['type'] = 'file';
|
||||
$att['html'] = $match[0];
|
||||
$att['name'] = $match[1];
|
||||
$att['thumb'] = '';
|
||||
$attachments[] = $att;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(count($attachments))
|
||||
{
|
||||
print_a($attachments);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$text = 'No forum attachments found! <br />';
|
||||
}
|
||||
|
||||
// $forum->forumUpdateLastpost('thread', 84867);
|
||||
|
||||
$text .= "
|
||||
Successfully migrated forum attachment information for ".count($postList)." post(s).
|
||||
<br /><br />
|
||||
<form method='post'>
|
||||
<input class='button' type='submit' name='nextStep[11]' value='Proceed to step 11' />
|
||||
</form>
|
||||
";
|
||||
$e107->ns->tablerender($stepCaption, $text);
|
||||
}
|
||||
|
||||
|
||||
class forumUpgrade
|
||||
{
|
||||
@@ -756,18 +963,21 @@ function forum_update_adminmenu()
|
||||
$var[6]['text'] = '6 - Migrate threads/replies';
|
||||
$var[6]['link'] = '#';
|
||||
|
||||
$var[7]['text'] = '7 - Calc counts/lastpost data';
|
||||
$var[7]['text'] = '7 - Recalc all counts';
|
||||
$var[7]['link'] = '#';
|
||||
|
||||
$var[8]['text'] = '8 - Migrate any poll data';
|
||||
$var[8]['text'] = '8 - Calc lastpost data';
|
||||
$var[8]['link'] = '#';
|
||||
|
||||
$var[9]['text'] = '9 - Migrate any attachments';
|
||||
$var[9]['text'] = '9 - Migrate any poll data';
|
||||
$var[9]['link'] = '#';
|
||||
|
||||
$var[10]['text'] = '10 - Delete old forum data';
|
||||
$var[10]['text'] = '10 - Migrate any attachments';
|
||||
$var[10]['link'] = '#';
|
||||
|
||||
$var[11]['text'] = '11 - Delete old forum data';
|
||||
$var[11]['link'] = '#';
|
||||
|
||||
|
||||
for($i=1; $i < $currentStep; $i++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user