From 30ecc683d77f6323506a29fe17b9b087917fa251 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 8 May 2015 10:08:49 -0700 Subject: [PATCH] Forum now generates SEF URLs during upgrade. Forum tools reinstated. Additional debug options added. --- e107_plugins/forum/forum_admin.php | 148 +++++++++++++++++++++++++++- e107_plugins/forum/forum_update.php | 33 ++++--- 2 files changed, 163 insertions(+), 18 deletions(-) diff --git a/e107_plugins/forum/forum_admin.php b/e107_plugins/forum/forum_admin.php index 790f2afd4..ef721812a 100644 --- a/e107_plugins/forum/forum_admin.php +++ b/e107_plugins/forum/forum_admin.php @@ -20,17 +20,17 @@ if (!getperms('P')) e107::includeLan(e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/English_admin.php'); e107::lan('forum','', 'front'); +$legacy = false; - -if(E107_DEBUG_LEVEL == 0) +if(E107_DEBUG_LEVEL > 0 && $legacy == true) { - define('NEW_FORUMADMIN', true); + define('OLD_FORUMADMIN', true); //e107::getMessage()->addwarning("Experimental code now active. Using this page in debug mode active could break your forum configuration."); } // Generated e107 Plugin Admin Area -if(deftrue('NEW_FORUMADMIN')) +if(!deftrue('OLD_FORUMADMIN')) { class forum_admin extends e_admin_dispatcher @@ -89,6 +89,18 @@ if(deftrue('NEW_FORUMADMIN')) ); protected $menuTitle = 'Forum'; + + + function init() + { + if(E107_DEBUG_LEVEL > 0) + { + $this->adminMenu['opt3'] = array('divider'=>true); + $this->adminMenu['main/update'] = array('caption'=>"Redo v1.x Forum Upgrade", 'perm'=>0, 'uri'=>'{e_PLUGIN}forum/forum_update.php'); + } + + + } } @@ -691,10 +703,136 @@ if(deftrue('NEW_FORUMADMIN')) + function toolsPageProcess() + { + $mes = e107::getMessage(); + + $fList = array(); + + if(isset($_POST['tools'])) + { + $msg = ''; + if(isset($_POST['forum_all'])) + { + $fList[]='all'; + } + else + { + foreach(array_keys($_POST['forumlist']) as $k) + { + $fList[] = $k; + } + } + foreach($fList as $fid) + { + if(isset($_POST['counts'])) + { + $this->forumObj->forumUpdateCounts($fid, $_POST['counts_threads']); + $msg .= FORLAN_167.": $fid
"; + } + if(isset($_POST['lastpost'])) + { + $with_threads = (!empty($_POST['lastpost_nothread'])) ? FALSE : TRUE; + $this->forumObj->forumUpdateLastpost('forum', $fid, $with_threads); + $msg .= FORLAN_168.": $fid
"; + } + } + if(isset($_POST['userpostcounts'])) + { + $ue = e107::getUserExt(); + + $list = $this->forumObj->getUserCounts(); + foreach($list as $uid => $cnt) + { + $ue->user_extended_setvalue($uid, 'user_plugin_forum_posts', $cnt, 'int'); + } + $msg .= FORLAN_169.'
'; + } + + $mes->addSuccess($msg); + // $ns->tablerender($caption, $mes->render().$text); + } + + + } + + + //TODO Add SEF-url generation for forum and threads where missing. function toolsPage() { - return "Coming Soon!"; + $sql = e107::getDb(); + $ns = e107::getRender(); + $tp = e107::getParser(); + $frm = e107::getForm(); + + $this->toolsPageProcess(); + + $txt = " +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
".FORLAN_156." + "; + if($sql->select("forum", "*", "1 ORDER BY forum_order")) + { + $fList = $sql->db_getList(); + foreach($fList as $f) + { + $key = 'forumlist['.$f['forum_id'].']'; + $txt .= $frm->checkbox($key, 1, false, $tp->toHTML($f['forum_name'])); + // $txt .= " ".$tp->toHTML($f['forum_name'])."
"; + } + $txt .= "
"; + $txt .= $frm->checkbox('forum_all', 1, false, LAN_PLUGIN_FORUM_ALLFORUMS); + // $txt .= " ".LAN_PLUGIN_FORUM_ALLFORUMS.""; + } + + + //TODO LAN - see below + $txt .= " +
".FORLAN_158."".$frm->checkbox('lastpost', 1, false, LAN_ACTIVE). + "". + $frm->select('lastpost_nothread', array(0=>"Forums and Threads", 1=>"Forums Only"))." + +
".FORLAN_161."".$frm->checkbox('counts', 1, false, LAN_ACTIVE). + "". + $frm->checkbox('counts_threads', 1, false, FORLAN_182)." + ".FORLAN_183." + +
".FORLAN_163."".$frm->checkbox('userpostcounts',1, false, LAN_ACTIVE)."
+
+ ".$frm->admin_button('tools', LAN_GO, 'submit')." +
+
+ "; + + return $txt; + // $ns->tablerender(FORLAN_166, $txt); } diff --git a/e107_plugins/forum/forum_update.php b/e107_plugins/forum/forum_update.php index 51596012a..fc6174d8c 100644 --- a/e107_plugins/forum/forum_update.php +++ b/e107_plugins/forum/forum_update.php @@ -248,8 +248,6 @@ function step3() return; } - require_once (e_HANDLER . 'user_extended_class.php'); - $ue = new e107_user_extended; $fieldList = array( 'plugin_forum_posts' => EUF_INTEGER, @@ -260,7 +258,7 @@ function step3() foreach ($fieldList as $fieldName => $fieldType) { - $result = $ue -> user_extended_add_system($fieldName, $fieldType); + $result = e107::getUserExt()->user_extended_add_system($fieldName, $fieldType); if ($result === true) { @@ -280,7 +278,7 @@ function step3() } else { - $text .= " + $text = "
@@ -468,6 +466,9 @@ function step5() $tmp = $forum; $tmp['forum_threadclass'] = $tmp['forum_postclass']; $tmp['forum_options'] = '_NULL_'; + $tmp['forum_sef'] = eHelper::title2sef($forum['forum_name'],'dashl'); + + // $tmp['_FIELD_TYPES'] = $ftypes['_FIELD_TYPES']; if ($sql -> insert('forum_new', $tmp)) { @@ -489,10 +490,10 @@ function step5() "); - $result = $sql -> gen('RENAME TABLE `#forum` TO `#forum_old` ') ? e_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $result = $sql -> gen('RENAME TABLE `#forum` TO `#forum_old` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $mes -> add("Renaming forum to forum_old", $result); - $result = $sql -> gen('RENAME TABLE `#forum_new` TO `#forum` ') ? e_MESSAGE_SUCCESS : E_MESSAGE_ERROR; + $result = $sql -> gen('RENAME TABLE `#forum_new` TO `#forum` ') ? E_MESSAGE_SUCCESS : E_MESSAGE_ERROR; $mes -> add("Renaming forum_new to forum", $result); $text = " @@ -634,7 +635,7 @@ function step7() // var_dump($counts); - $text .= " + $text = " Successfully recalculated forum posts for " . count($counts) . " users.

@@ -1414,6 +1415,7 @@ class forumUpgrade * thread_lastuser_anon * thread_total_replies * thread_options + * thread_sef */ $detected = mb_detect_encoding($post['thread_name']); // 'ISO-8859-1' @@ -1447,6 +1449,8 @@ class forumUpgrade // $thread['_FIELD_TYPES']['thread_name'] = 'escape'; //use escape to prevent // double entities + $thread['thread_sef'] = eHelper::title2sef($threadName,'dashl'); + $result = e107::getDb() -> insert('forum_thread', $thread); return $result; } @@ -1720,13 +1724,16 @@ function forum_update_adminmenu() $var[13]['divider'] = true; $var[14]['text'] = 'Reset'; - $var[14]['link'] = e_SELF . "?reset"; + $var[14]['link'] = e_SELF . "?reset"; + + $var[15]['text'] = 'Reset to 6'; + $var[15]['link'] = e_SELF . "?step=6&reset=6"; + + $var[16]['text'] = 'Reset to 7'; + $var[16]['link'] = e_SELF . "?step=7&reset=7"; - $var[15]['text'] = 'Reset to 7'; - $var[15]['link'] = e_SELF . "?step=7&reset=7"; - - $var[16]['text'] = 'Reset to 10'; - $var[16]['link'] = e_SELF . "?step=10&reset=10"; + $var[17]['text'] = 'Reset to 10'; + $var[17]['link'] = e_SELF . "?step=10&reset=10"; }