1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-22 13:41:52 +02:00

Fixed e107 v1 to v2 forum migration adding check for deprecated files. Fixed breadcrumb subforum visibility and URL when SEFURL is disabled.

This commit is contained in:
Cameron 2021-09-26 10:43:33 -07:00
parent 69d5b49525
commit 5fd8fdc92b
3 changed files with 43 additions and 6 deletions

@ -2351,10 +2351,11 @@ class e107forum
$replace = array($tp->toHTML($forumInfo['parent_name']), e107::url('forum','index')."#".$frm->name2id($forumInfo['parent_name']));
$FORUM_CRUMB['parent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['parent']['value']);
if($forumInfo['forum_sub'])
{
$search = array('{SUBPARENT_TITLE}', '{SUBPARENT_HREF}');
$replace = array(ltrim($forumInfo['sub_parent'], '*'), e107::url('forum', 'forum', array('forum_id'=>$forumInfo['parent_id'],'forum_sef'=>$forumInfo['parent_sef'])));
$replace = array(ltrim($forumInfo['sub_parent'], '*'), e107::url('forum', 'forum', array('forum_id'=>$forumInfo['forum_sub'],'forum_sef'=>$forumInfo['parent_sef'])));
$FORUM_CRUMB['subparent']['value'] = str_replace($search, $replace, $FORUM_CRUMB['subparent']['value']);
}
else

@ -1314,6 +1314,9 @@ class forumUpgrade
public $updateInfo = array();
private $attachmentData;
private $logf;
private $deprecated = array(
'e_latest.php','e_status.php', 'forum_post_shortcodes.php','forum_shortcodes.php',
'forum_update_check.php', 'newforumposts_menu_config.php');
public function __construct()
{
@ -1322,6 +1325,34 @@ class forumUpgrade
$this->attachmentData = array();
$this->logf = e_LOG . 'forum_upgrade.log';
$this->getUpdateInfo();
if(empty($updateInfo))
{
$this->removeDeprecatedFiles();
}
}
private function removeDeprecatedFiles()
{
foreach($this->deprecated as $file)
{
$path = e_PLUGIN."forum/".$file;
if(file_exists($path))
{
if(unlink($path))
{
e107::getMessage()->addDebug("Deprecated file deleted: <b>".$path."</b>");
}
else
{
e107::getMessage()->addWarning("Was unable to delete the following deprecated file: <b>".$path."</b> (please remove manually)");
}
}
}
}
public function log($msg, $append = true)
@ -1511,24 +1542,29 @@ class forumUpgrade
$thread['thread_user'] = $userInfo['user_id'];
$thread['thread_user_anon'] = $userInfo['anon_name'];
$sql = e107::getDb();
// If thread marked as 'tracked by starter', we must convert to using
// forum_track table
if($thread['thread_active'] == 99 && $thread['thread_user'] > 0)
{
$forum->track('add', $thread['thread_user'], $thread['thread_id'], true);
if(!$forum->track('add', $thread['thread_user'], $thread['thread_id'], true))
{
$this->log(__METHOD__." (track): ".$sql->getLastErrorText(), true);
}
$thread['thread_active'] = 1;
}
// $thread['_FIELD_TYPES'] = $forum->fieldTypes['forum_thread'];
// $thread['_FIELD_TYPES']['thread_name'] = 'escape'; //use escape to prevent
// double entities
$sql = e107::getDb();
$result = $sql->insert('forum_thread', $thread);
if($result === false)
{
$this->log($sql->getLastErrorText(), true);
$this->log(__METHOD__.": ".$sql->getLastErrorText(), true);
}
return $result;
@ -1584,7 +1620,7 @@ class forumUpgrade
if($result === false)
{
$this->log($sql->getLastErrorText(), true);
$this->log(__METHOD__.": ".$sql->getLastErrorText(), true);
}
return $result;

@ -67,7 +67,7 @@ function init()
// todo - remove all these globals.
global $FORUM_VIEW_START, $urlparms, $doNothing;
global $sc, $FORUM_VIEW_FORUM, $FORUM_VIEW_FORUM_STICKY, $FORUM_VIEW_FORUM_ANNOUNCE;
global $forum_info, $FORUM_CRUMB;
global $forum_info, $FORUM_CRUMB, $forumInfo;
global $forum;
$sql = e107::getDb();