Ignore:
Timestamp:
07/02/08 18:27:06 (4 years ago)
Author:
hverton
Message:

Merged trunk revisions 1408:1508 into the PLi-Fusion branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/PLi-Fusion/forum/viewthread.php

    r1408 r1509  
    8686    "SELECT f.*, f2.forum_name AS forum_cat_name 
    8787    FROM ".$db_prefix."forums f 
    88     LEFT JOIN ".$db_prefix."forums f2 ON f.forum_cat=f2.forum_id 
     88    INNER JOIN ".$db_prefix."forums f2 ON f.forum_cat=f2.forum_id 
    8989    WHERE f.forum_id='".$forum_id."'" 
    9090); 
     
    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"; 
     
    199200            SELECT count(*) as unread, tr.thread_first_read, tr.thread_last_read 
    200201                FROM ".$db_prefix."posts p 
    201                 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
     202                INNER JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
    202203                WHERE tr.user_id = '".$userdata['user_id']."'  
    203204                    AND tr.thread_id = '".$thread_id."'  
     
    212213            SELECT count(*) as unread, tr.thread_first_read, tr.thread_last_read 
    213214                FROM ".$db_prefix."posts p 
    214                 LEFT JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
     215                INNER JOIN ".$db_prefix."threads_read tr ON p.thread_id = tr.thread_id 
    215216                WHERE tr.user_id = '".$userdata['user_id']."' 
    216217                    AND p.post_author != '".$userdata['user_id']."' 
     
    261262    $result = dbquery( 
    262263        "SELECT p.*, u.*, u2.user_name AS edit_name, u2.user_status AS edit_status FROM ".$db_prefix."posts p 
    263         LEFT JOIN ".$db_prefix."users u ON p.post_author = u.user_id 
     264        INNER JOIN ".$db_prefix."users u ON p.post_author = u.user_id 
    264265        LEFT JOIN ".$db_prefix."users u2 ON p.post_edituser = u2.user_id AND post_edituser > '0' 
    265266        WHERE p.thread_id='$thread_id' ORDER BY post_sticky DESC, post_datestamp ASC LIMIT $rowstart,".$settings['numofthreads'] 
     
    267268    $variables['posts'] = array(); 
    268269    while ($data = dbarray($result)) { 
     270 
     271        // default, show no ranking information 
     272        $data['show_ranking'] = false; 
    269273 
    270274        // check for a system-post (author = 0 ), use some of the webmasters details for this 
     
    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     
     
    311381                $data['cc_flag'] = GeoIP_Code2Flag($settings['country']); 
    312382            } else { 
    313                 $data['cc_flag'] = GeoIP_IP2Flag($data['post_ip']); 
     383                $data['cc_flag'] = !empty($data['post_cc']) ? GeoIP_Code2Flag($data['post_cc']) : GeoIP_IP2Flag($data['post_ip']); 
    314384            } 
    315385        } else { 
     
    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.