Changeset 1420 in ExiteCMS for trunk/forum/viewthread.php


Ignore:
Timestamp:
05/30/08 21:41:54 (4 years ago)
Author:
hverton
Message:

added a new module to define forum ranking

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/forum/viewthread.php

    r1398 r1420  
    158158        } 
    159159        // check if this isn't a reload, back-post, or double submit 
    160         if (isset($_COOKIE['post_'.$random_id])) { 
     160        if (isset($_SESSION['posts'][$random_id])) { 
    161161            redirect("post.php?action=quickreply&forum_id=$forum_id&thread_id=$thread_id&post_id=0&errorcode=3"); 
    162162        } else { 
    163163            if (!$flood) { 
    164                 setcookie("post_".$random_id, "posted", time() + 60*60, "/", "", "0"); 
     164                if (!isset($_SESSION['posts']) || !is_array($_SESSION['posts'])) $_SESSION['posts'] = array(); 
     165                $_SESSION['posts'][$random_id] = time()+60*60*12; 
    165166                $sig = ($userdata['user_sig'] ? '1' :'0'); 
    166167                $smileys = isset($_POST['disable_smileys']) ? "0" : "1"; 
     
    268269    while ($data = dbarray($result)) { 
    269270 
     271        // default, show no ranking information 
     272        $data['show_ranking'] = false; 
     273 
    270274        // check for a system-post (author = 0 ), use some of the webmasters details for this 
    271275        if ($data['post_author'] == 0) { 
     
    278282            $data['user_sig'] = ""; 
    279283            $data['user_status'] = "0"; 
     284        } else { 
     285            // check if a ranking is defined for this poster 
     286            $result2 = dbquery("SELECT * FROM ".$db_prefix."forum_ranking WHERE rank_posts_from <= '".$data['user_posts']."' AND rank_posts_to >= '".$data['user_posts']."' ORDER BY rank_order"); 
     287            while ($data2 = dbarray($result2)) { 
     288                // get the grouplist for this ranking 
     289                if (strpos($data2['rank_groups'], ",")) { 
     290                    $groups = explode(",", $data2['rank_groups']); 
     291                } else { 
     292                    if (empty($data2['rank_groups'])) { 
     293                        $groups = ""; 
     294                    } else { 
     295                        $groups = array($data2['rank_groups']); 
     296                    } 
     297                } 
     298                if (is_array($groups)) { 
     299                    // check for group matching as well, assume a match will be found 
     300                    $ranking_match = true; 
     301                    foreach($groups as $group) { 
     302                        if ($data2['rank_groups_and']) { 
     303                            // all should match 
     304                            if (!checkusergroup($data['post_author'], $group)) { 
     305                                // bail out if a non-match has been found 
     306                                $ranking_match = false; 
     307                                break; 
     308                            } 
     309                        } else { 
     310                            // one match is sufficient 
     311                            if (checkusergroup($data['post_author'], $group)) { 
     312                                $ranking_match = true; 
     313                                break; 
     314                            } 
     315                        } 
     316                    } 
     317                } else { 
     318                    // no groups to test, must be a match on posts range 
     319                    $ranking_match = true; 
     320                } 
     321                // if we had a match, add the ranking information to the post data 
     322                if ($ranking_match) { 
     323                    $data['ranking'] = $data2; 
     324                    $data['show_ranking'] = true; 
     325                    break; 
     326                } 
     327            } 
    280328        } 
    281329 
     
    301349        $last_post_datestamp = max($data['post_datestamp'], $data['post_edittime'], $last_post_datestamp); 
    302350 
    303         // check what options to show for this post 
    304         $data['user_can_edit'] = iMEMBER && $data['post_author'] != 0 && (iMOD || iSUPERADMIN || (!$tdata['thread_locked'] && $userdata['user_id'] == $data['post_author'])); 
     351        // check if the user can edit this post. Assume the user can't 
     352        $data['user_can_edit'] = false; 
     353        if (iMEMBER) { 
     354            // webmasters and forum moderators may always edit 
     355            if (iSUPERADMIN || iMOD) { 
     356                $data['user_can_edit'] = true; 
     357            } else { 
     358                // check if this is not a system post 
     359                if ($data['post_author'] != 0) { 
     360                    // check if the thread is not locked 
     361                    if (!$tdata['thread_locked']) { 
     362                        // check if this is the users own post 
     363                        if ($userdata['user_id'] == $data['post_author']) { 
     364                            // check if the edit time is not expired 
     365                            if ($settings['forum_edit_timeout'] == 0 || ($data['post_datestamp'] + $settings['forum_edit_timeout'] * 3600) > time()) { 
     366                                $data['user_can_edit'] = true; 
     367                            } 
     368                        } 
     369                    } 
     370                } 
     371            } 
     372        } 
     373 
     374        // check if we can show the poster's IP address 
    305375        $data['show_ip'] = (iMOD || iSUPERADMIN && ($data['post_ip'] != "0.0.0.0" && file_exists(PATH_THEME."images/ip.gif"))); 
    306376     
     
    324394        // user & group memberships 
    325395        $data['group_names'] = array(); 
     396        // if a ranking is present, and a rank title is defined, display that first 
     397        if (isset($data['ranking']) && !empty($data['ranking']['rank_title']) && !$data['ranking']['rank_tooltip']) { 
     398            $data['group_names'][] = array('type' => 'R', 'color' => $data['ranking']['rank_color'], 'name' => $data['ranking']['rank_title']); 
     399        } 
     400        // display the standard user level next 
    326401        $data['group_names'][] = array('type' => 'U', 'level' => $data['user_level'], 'name' => getuserlevel($data['user_level'])); 
    327402 
Note: See TracChangeset for help on using the changeset viewer.