From 8bb1eb7b6924e51d1db091eb4a9bfa5ce67455ee Mon Sep 17 00:00:00 2001 From: mcfly Date: Sun, 14 Mar 2010 14:14:44 +0000 Subject: [PATCH] EONE-34 (Improvement): Preferences now handled correctly in forum admin. Attachments now working again. --- e107_plugins/forum/forum_admin.php | 78 +++++--------- e107_plugins/forum/forum_admin_class.php | 108 +++++-------------- e107_plugins/forum/forum_post.php | 2 +- e107_plugins/forum/forum_post_shortcodes.php | 36 +++---- 4 files changed, 72 insertions(+), 152 deletions(-) diff --git a/e107_plugins/forum/forum_admin.php b/e107_plugins/forum/forum_admin.php index 22f570049..2b3686227 100644 --- a/e107_plugins/forum/forum_admin.php +++ b/e107_plugins/forum/forum_admin.php @@ -29,9 +29,14 @@ require_once(e_HANDLER.'form_handler.php'); require_once(e_HANDLER.'ren_help.php'); require_once(e_PLUGIN.'forum/forum_class.php'); require_once(e_PLUGIN.'forum/forum_admin_class.php'); +$emessage = eMessage::getInstance(); $rs = new form; $for = new e107forum; $forum = new forumAdmin; + +$fPref = e107::getPlugConfig('forum', '', false); + + define('IMAGE_new', ""); define('IMAGE_sub', "".FORLAN_145.""); define('IMAGE_nosub', "".FORLAN_145.""); @@ -93,7 +98,7 @@ if(isset($_POST['tools'])) { require_once(e_HANDLER.'user_extended_class.php'); $ue = new e107_user_extended; - + $list = $for->getUserCounts(); foreach($list as $uid => $cnt) { @@ -255,27 +260,28 @@ if (isset($_POST['update_order'])) if (isset($_POST['updateoptions'])) { - $pref['email_notify'] = $_POST['email_notify']; - $pref['email_notify_on'] = $_POST['email_notify_on']; - $pref['forum_poll'] = $_POST['forum_poll']; - $pref['forum_popular'] = $_POST['forum_popular']; - $pref['forum_track'] = $_POST['forum_track']; - $pref['forum_eprefix'] = $_POST['forum_eprefix']; - $pref['forum_enclose'] = $_POST['forum_enclose']; - $pref['forum_title'] = $_POST['forum_title']; - $pref['forum_postspage'] = $_POST['forum_postspage']; - $pref['forum_threadspage'] = $_POST['forum_threadspage']; - $pref['html_post'] = $_POST['html_post']; - $pref['forum_attach'] = $_POST['forum_attach']; - $pref['forum_redirect'] = $_POST['forum_redirect']; - $pref['reported_post_email'] = $_POST['reported_post_email']; - $pref['forum_tooltip'] = $_POST['forum_tooltip']; - $pref['forum_tiplength'] = $_POST['forum_tiplength']; - $pref['forum_hilightsticky'] = $_POST['forum_hilightsticky']; - $pref['forum_maxwidth'] = $_POST['forum_maxwidth']; - $pref['forum_linkimg'] = $_POST['forum_linkimg']; - save_prefs(); - $forum->show_message(FORLAN_10); + $fPref->set('notify', $_POST['email_notify']); + $fPref->set('notify_on', $_POST['email_notify_on']); + $fPref->set('poll', $_POST['forum_poll']); + $fPref->set('popular', $_POST['forum_popular']); + $fPref->set('track', $_POST['forum_track']); + $fPref->set('eprefix', $_POST['forum_eprefix']); + $fPref->set('enclose', $_POST['forum_enclose']); + $fPref->set('title', $_POST['forum_title']); + $fPref->set('postspage', $_POST['forum_postspage']); + $fPref->set('threadspage', $_POST['forum_threadspage']); + $fPref->set('html_post', $_POST['html_post']); + $fPref->set('attach', $_POST['forum_attach']); + $fPref->set('redirect', $_POST['forum_redirect']); + $fPref->set('reported_post_email', $_POST['reported_post_email']); + $fPref->set('tooltip', $_POST['forum_tooltip']); + $fPref->set('tiplength', $_POST['forum_tiplength']); + $fPref->set('hilightsticky', $_POST['forum_hilightsticky']); + $fPref->set('maxwidth', $_POST['forum_maxwidth']); + $fPref->set('linkimg', $_POST['forum_linkimg']); + $fPref->save(true, true); + $emessage->add(FORLAN_10, E_MESSAGE_SUCCESS); +// $forum->show_message(FORLAN_10); } if (isset($_POST['do_prune'])) @@ -285,28 +291,6 @@ if (isset($_POST['do_prune'])) $action = 'main'; } -if (isset($_POST['set_ranks'])) -{ - extract($_POST); - for($a = 0; $a <= 9; $a++) - { - $r_names .= $e107->tp->toDB($rank_names[$a]).","; - $r_thresholds .= $e107->tp->toDB($rank_thresholds[$a]).","; - $r_images .= $e107->tp->toDB($rank_images[$a]).","; - } - $pref['rank_main_admin'] = $_POST['rank_main_admin']; - $pref['rank_main_admin_image'] = $_POST['rank_main_admin_image']; - $pref['rank_admin'] = $_POST['rank_admin']; - $pref['rank_admin_image'] = $_POST['rank_admin_image']; - $pref['rank_moderator'] = $_POST['rank_moderator']; - $pref['rank_moderator_image'] = $_POST['rank_moderator_image']; - $pref['forum_levels'] = $r_names; - $pref['forum_thresholds'] = $r_thresholds; - $pref['forum_images'] = $r_images; - save_prefs(); - $forum->show_message(FORLAN_95); -} - if (isset($_POST['frsubmit'])) { $guestrules = $e107->tp->toDB($_POST['guestrules']); @@ -373,7 +357,7 @@ switch($action) case 'opt': $forum->show_prefs(); break; - + case 'mods': $forum->show_mods(); break; @@ -385,10 +369,6 @@ switch($action) case 'prune': $forum->show_prune(); break; - - case 'rank': - $forum->show_levels(); - break; case 'rules': $forum->show_rules(); diff --git a/e107_plugins/forum/forum_admin_class.php b/e107_plugins/forum/forum_admin_class.php index 7e4378814..128111f55 100755 --- a/e107_plugins/forum/forum_admin_class.php +++ b/e107_plugins/forum/forum_admin_class.php @@ -35,8 +35,6 @@ class forumAdmin $var['opt']['link'] = e_SELF.'?opt'; $var['prune']['text'] = FORLAN_59; $var['prune']['link'] = e_SELF.'?prune'; - $var['rank']['text'] = FORLAN_63; - $var['rank']['link'] = e_SELF.'?rank'; $var['rules']['text'] = FORLAN_123; $var['rules']['link'] = e_SELF.'?rules'; $var['sr']['text'] = FORLAN_116; @@ -634,18 +632,19 @@ class forumAdmin function show_prefs() { - global $pref, $ns, $sql; + global $fPref, $ns, $sql; $e107 = e107::getInstance(); + $emessage = eMessage::getInstance(); $poll_installed = plugInstalled('poll'); if(!$poll_installed) { - if($pref['forum_poll'] == 1) + if($fPref['poll'] == 1) { - $pref['forum_poll'] = e_UC_NOBODY; - save_prefs(); + $fPref['forum_poll'] = e_UC_NOBODY; + $fPref->save(false, true); } } @@ -655,22 +654,22 @@ class forumAdmin ".FORLAN_44."
".FORLAN_45." - ".($pref['forum_enclose'] ? "" : "")." + ".($fPref->get('enclose') ? "" : "")." ".FORLAN_65."
".FORLAN_46." - + ".FORLAN_47."
".FORLAN_48." - ".($pref['email_notify'] ? "" : "")." + ".($fPref->get('email_notify') ? "" : "")." ".FORLAN_177."
".FORLAN_178." - ".($pref['email_notify_on'] ? "" : "")." + ".($fPref->get('email_notify_on') ? "" : "")." @@ -678,7 +677,7 @@ class forumAdmin if($poll_installed) { // ".$e107->user_class->uc_dropdown("mods[{$f['forum_id']}]", $f['forum_moderators'], 'admin,classes')." - $text .= "".$e107->user_class->uc_dropdown('forum_poll', $pref['forum_poll'], 'admin,classes').''; + $text .= "".$e107->user_class->uc_dropdown('forum_poll', $fPref->get('poll'), 'admin,classes').''; } else { @@ -700,69 +699,69 @@ class forumAdmin } $text .= " - ".($pref['forum_attach'] ? "" : "")." + ".($fPref->get('attach') ? "" : "")." ".FORLAN_134."
".FORLAN_135." - + ".FORLAN_136."
".FORLAN_137." - ".($pref['forum_linkimg'] ? "" : "")." + ".($fPref->get('linkimg') ? "" : "")." ".FORLAN_51."
".FORLAN_52." - ".($pref['forum_track'] ? "" : "")." + ".($fPref->get('track') ? "" : "")." ".FORLAN_112."
".FORLAN_113." - ".($pref['forum_redirect'] ? "" : "")." + ".($fPref->get('redirect') ? "" : "")." ".FORLAN_116."
".FORLAN_122." - ".($pref['reported_post_email'] ? "" : "")." + ".($fPref->get('reported_post_email') ? "" : "")." ".FORLAN_126."
".FORLAN_127." - ".($pref['forum_tooltip'] ? "" : "")." + ".($fPref->get('forum_tooltip') ? "" : "")." ".FORLAN_128."
".FORLAN_129." - + ".FORLAN_53."
".FORLAN_54." - + ".FORLAN_55."
".FORLAN_56." - + ".FORLAN_57."
".FORLAN_58." - + ".FORLAN_186."
".FORLAN_187." - + ".FORLAN_132."
".FORLAN_133." - ".($pref['forum_hilightsticky'] ? "" : "")." + ".($fPref->get('hilightsticky') ? "" : "")." @@ -773,7 +772,7 @@ class forumAdmin "; - $ns->tablerender(FORLAN_62, $text); + $ns->tablerender(FORLAN_62, $emessage->render().$text); } function show_reported ($sub_action, $id) @@ -926,65 +925,6 @@ class forumAdmin $ns->tablerender(FORLAN_59, $text); } - function show_levels() - { - global $sql, $pref, $ns, $rs; - - $rank_names = explode(",", $pref['forum_levels']); - $rank_thresholds = ($pref['forum_thresholds'] ? explode(",", $pref['forum_thresholds']) : array(20, 100, 250, 410, 580, 760, 950, 1150, 1370, 1600)); - $rank_images = ($pref['forum_images'] ? explode(",", $pref['forum_images']) : array("lev1.png", "lev2.png", "lev3.png", "lev4.png", "lev5.png", "lev6.png", "lev7.png", "lev8.png", "lev9.png", "lev10.png")); - - $text = "
-
\n - - - - - - - - - - - - - "; - - $text .= " - - - - - - - - - - - - - - - - "; - - for($a = 0; $a <= 9; $a++) - { - $text .= " - - - - "; - } - - $text .= " - - -
".FORLAN_98."".FORLAN_102."
".FORLAN_104."
 ".FORLAN_99."".FORLAN_100."
 
 
 
- -
\n
\n
"; - $ns->tablerender("Ranks", $text); - } function show_mods() { diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 5ea9525ec..4ff40e569 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -548,7 +548,7 @@ function forumjump() function process_upload() { - global $forumInfo, $thread_info, $admin_log; + global $forumInfo, $thread_info, $admin_log, $forum; $postId = (int)$postId; $ret = array(); diff --git a/e107_plugins/forum/forum_post_shortcodes.php b/e107_plugins/forum/forum_post_shortcodes.php index 0866d8ba7..65b255136 100644 --- a/e107_plugins/forum/forum_post_shortcodes.php +++ b/e107_plugins/forum/forum_post_shortcodes.php @@ -8,12 +8,12 @@ class forum_post_shortcodes var $e107; var $threadInfo; var $forum; - + function forum_post_shortcodes() { $this->e107 = e107::getInstance(); } - + function sc_latestposts($parm) { $parm = ($parm ? $parm : 10); @@ -21,9 +21,9 @@ class forum_post_shortcodes $txt = $this->e107->tp->parseTemplate($LATESTPOSTS_START, true); $start = max($this->threadInfo['thread_total_replies'] - $parm, 0); $num = min($this->threadInfo['thread_total_replies'], $parm); - + $tmp = $this->forum->postGet($this->threadInfo['thread_id'], $start, $num); - + for($i = count($tmp)-1; $i > 0; $i--) { setScVar('forum_shortcodes', 'postInfo', $tmp[$i]); @@ -45,7 +45,7 @@ class forum_post_shortcodes { return "
"; } - + function sc_formend() { return '
'; @@ -55,25 +55,25 @@ class forum_post_shortcodes { return forumjump(); } - + function sc_userbox() { global $userbox; return (USER == false ? $userbox : ''); } - + function sc_subjectbox() { global $subjectbox, $action; return ($action == 'nt' ? $subjectbox : ''); } - + function sc_posttype() { global $action; return ($action == 'nt' ? LAN_63 : LAN_73); } - + function sc_postbox() { global $post; @@ -85,7 +85,7 @@ class forum_post_shortcodes } return $ret; } - + function sc_buttons() { global $action, $eaction; @@ -100,14 +100,14 @@ class forum_post_shortcodes } return $ret; } - + function sc_fileattach() { global $forum, $pref, $fileattach, $fileattach_alert; - if ($forum->prefs->get('forum_attach') && strpos(e_QUERY, 'edit') === FALSE && (check_class($pref['upload_class']) || getperms('0'))) + if ($forum->prefs->get('attach') && strpos(e_QUERY, 'edit') === FALSE && (check_class($pref['upload_class']) || getperms('0'))) { - if (is_writable(e_UPLOAD)) + if (is_writable(e_PLUGIN.'forum/attachments')) { return $fileattach; } @@ -125,7 +125,7 @@ class forum_post_shortcodes } } } - + function sc_postthreadas() { global $action, $thread_info; @@ -136,7 +136,7 @@ class forum_post_shortcodes } return ''; } - + function sc_backlink() { global $forum, $thread_info, $eaction, $action; @@ -144,13 +144,13 @@ class forum_post_shortcodes $forum->set_crumb(true, ($action == 'nt' ? ($eaction ? LAN_77 : LAN_60) : ($eaction ? LAN_78 : LAN_406.' '.$thread_info['head']['thread_name'])), $_tmp); return $_tmp->BREADCRUMB; } - + function sc_noemotes() { if($eaction == true) { return ; } return " ".LAN_FORUMPOST_EMOTES.''; } - + function sc_emailnotify() { global $pref, $thread_info, $action, $eaction; @@ -176,7 +176,7 @@ class forum_post_shortcodes } return ''; } - + function sc_poll() { global $forum, $poll_form, $action;