Changeset 1420 in ExiteCMS


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

added a new module to define forum ranking

Location:
trunk
Files:
32 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/administration/tools/language_pack_English.php

    r1407 r1420  
    491491        $localestrings['236'] = "Language Settings"; 
    492492        $localestrings['237'] = "Webmaster Toolbox for"; 
     493        $localestrings['238'] = "Forum Ranking"; 
    493494        $localestrings['250'] = "Website Statistics"; 
    494495        $localestrings['251'] = "Registered Members:"; 
     
    514515        $localestrings['309'] = "You can not install this language pack. This pack is for ExiteCMS version"; 
    515516        load_localestrings($localestrings, LP_LOCALE, "admin.main", $step); 
     517 
     518        $localestrings = array(); 
     519        $localestrings['400'] = "Forum Rankings"; 
     520        $localestrings['401'] = "Add a new ranking"; 
     521        $localestrings['402'] = "Edit a ranking"; 
     522        $localestrings['408'] = "There are no forum rankings defined"; 
     523        $localestrings['409'] = "Note: The rankings are processed in the order shown here. Comparison stops at the first hit. If you use group membership filtering, and you have duplicate post ranges, make sure that the order is correct!"; 
     524        $localestrings['411'] = "Posts range"; 
     525        $localestrings['412'] = "Rank title"; 
     526        $localestrings['413'] = "Rank image"; 
     527        $localestrings['414'] = "Only for members of"; 
     528        $localestrings['415'] = "Order"; 
     529        $localestrings['416'] = "Options"; 
     530        $localestrings['417'] = "Move this rank up"; 
     531        $localestrings['418'] = "Move this rank down"; 
     532        $localestrings['419'] = "Edit this rank"; 
     533        $localestrings['420'] = "Delete this rank"; 
     534        $localestrings['421'] = "Posts selection range:"; 
     535        $localestrings['422'] = "From"; 
     536        $localestrings['423'] = "To"; 
     537        $localestrings['424'] = "Posts"; 
     538        $localestrings['425'] = "Rank title:"; 
     539        $localestrings['426'] = "Rank image:"; 
     540        $localestrings['427'] = "- none -"; 
     541        $localestrings['428'] = "Repeat this image:"; 
     542        $localestrings['429'] = "Times"; 
     543        $localestrings['430'] = "Available groups:"; 
     544        $localestrings['431'] = "Selected groups:"; 
     545        $localestrings['432'] = "Save this ranking"; 
     546        $localestrings['433'] = "Apply this ranking to the following user groups only:"; 
     547        $localestrings['434'] = "Rank order:"; 
     548        $localestrings['435'] = "Rank group comparison using:"; 
     549        $localestrings['436'] = " and "; 
     550        $localestrings['437'] = " or "; 
     551        $localestrings['438'] = "Rank title color:"; 
     552        $localestrings['439'] = "Show title as tooltip:"; 
     553        $localestrings['440'] = "No"; 
     554        $localestrings['441'] = "Yes"; 
     555        $localestrings['490'] = "The Post selection range must be filled in, and both values most be positive integers!"; 
     556        $localestrings['491'] = "The Post selection range must be filled in, and From must be lower than To!"; 
     557        $localestrings['492'] = "Ranking succesfully deleted"; 
     558        load_localestrings($localestrings, LP_LOCALE, "admin.ranking", $step); 
    516559 
    517560        $localestrings = array(); 
     
    889932        $localestrings['532'] = "Error: The session timeout value should be greater than the extended login timeout!"; 
    890933        $localestrings['533'] = "Error: The extended login timeout should be greater than the standard login timeout!"; 
     934        $localestrings['534'] = "Forum edit timeout:"; 
     935        $localestrings['535'] = "Hour"; 
     936        $localestrings['536'] = "Hours"; 
    891937        $localestrings['550'] = "Security"; 
    892938        $localestrings['551'] = "Enable registration system?"; 
     
    12121258        $localestrings['es'] = "Spain"; 
    12131259        $localestrings['et'] = "Ethiopia"; 
     1260        $localestrings['eu'] = "European Union"; 
    12141261        $localestrings['fi'] = "Finland"; 
    12151262        $localestrings['fj'] = "Fiji"; 
     
    12881335        $localestrings['mm'] = "Myanmar"; 
    12891336        $localestrings['mn'] = "Mongolia"; 
     1337        $localestrings['mo'] = "Macau"; 
    12901338        $localestrings['mp'] = "Northern Mariana Islands"; 
    12911339        $localestrings['mq'] = "Martinique"; 
     
    13211369        $localestrings['pm'] = "Saint Pierre And Miquelon"; 
    13221370        $localestrings['pr'] = "Puerto Rico"; 
     1371        $localestrings['pr'] = "Palestinian Territories"; 
    13231372        $localestrings['pt'] = "Portugal"; 
    13241373        $localestrings['pw'] = "Palau"; 
     
    13621411        $localestrings['tv'] = "Tuvalu"; 
    13631412        $localestrings['tw'] = "Taiwan, Province Of China"; 
     1413        $localestrings['tz'] = "Tanzania"; 
    13641414        $localestrings['ua'] = "Ukraine"; 
    13651415        $localestrings['ug'] = "Uganda"; 
     
    21622212        $localestrings['517'] = "Toggle smileys"; 
    21632213        $localestrings['518'] = "pixels"; 
     2214        $localestrings['519'] = ""; 
    21642215        $localestrings['520'] = "Moderator Options:"; 
    21652216        $localestrings['521'] = "Delete Thread"; 
  • trunk/files/locales/en.main.global.php

    r1401 r1420  
    33// locale       : English 
    44// locale name  : main.global 
    5 // generated on : Thu May 15 2008, 14:39:50 CEST 
     5// generated on : Fri May 30 2008, 20:06:43 CEST 
    66// translators  : ExiteCMS team,WanWizard 
    77// ---------------------------------------------------------- 
     
    8383$locale['085'] = "%u private message"; 
    8484$locale['086'] = "%u private messages"; 
    85 $locale['087'] = "?"; 
     85$locale['087'] = "Downloads"; 
    8686$locale['088'] = "%u new forum post"; 
    8787$locale['089'] = "%u new forum posts"; 
  • 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 
  • trunk/includes/templates/forum.renderpost.tpl

    r1400 r1420  
    7979            {/if} 
    8080            <br /> 
     81            {if $posts[pid].show_ranking} 
     82                {if $posts[pid].ranking.rank_image} 
     83                    {section name=img start=0 loop=$posts[pid].ranking.rank_image_repeat} 
     84                        <img src='{$smarty.const.IMAGES}ranking/{$posts[pid].ranking.rank_image}' alt='' title='{if $posts[pid].ranking.rank_tooltip && $posts[pid].ranking.rank_title != ""}{$posts[pid].ranking.rank_title}{/if}' style='border:0px;' /> 
     85                    {/section} 
     86                    <br /> 
     87                {/if} 
     88            {/if} 
     89            {* show a ranking title first *} 
     90            {section name=ug loop=$posts[pid].group_names} 
     91                {if $posts[pid].group_names[ug].type == "R"} 
     92                    {if $posts[pid].group_names[ug].color|default:"" != ""} 
     93                        <span class='small'><font color='{$posts[pid].group_names[ug].color}'>{$posts[pid].group_names[ug].name}</font></span> 
     94                    {else} 
     95                        <span class='small'>{$posts[pid].group_names[ug].name}</span> 
     96                    {/if} 
     97                    <br /> 
     98                {/if} 
     99            {/section} 
    81100            {* show admin/superadmin level first *} 
    82101            {section name=ug loop=$posts[pid].group_names} 
  • trunk/includes/user_functions.php

    r1401 r1420  
    250250} 
    251251 
    252 // Check if user is assigned to the specified user group 
     252// Check if the current user is assigned to the specified user group 
    253253function checkgroup($group) { 
    254254    if (iSUPERADMIN && ($group != "100")) { return true; } 
     
    262262        return false; 
    263263    } 
     264} 
     265 
     266// Check if a user is assigned to the specified user group 
     267function checkusergroup($user_id, $group_id) { 
     268    global $db_prefix; 
     269 
     270    // every user is a member 
     271    if ($group_id == "101") { return true; } 
     272    // get the group rights from the user record 
     273    $result = dbquery("SELECT user_groups, user_level FROM ".$db_prefix."users WHERE user_id = '".$user_id."'"); 
     274    if ($data = dbarray($result)) { 
     275        // check if the requested group matches a user level 
     276        if ($group_id == $data['user_level']) { return true; } 
     277        // if group memberships are defined, get the users own group memberships into an array 
     278        if (!empty($data['user_groups'])) { 
     279            $groups = explode(".", substr($data['user_groups'], 1)); 
     280            foreach ($groups as $group) { 
     281                // check if this groups has subgroups. If so, add them to the array 
     282                getsubgroups($group); 
     283            } 
     284            // now that we have all groups, check for a match 
     285            foreach ($groups as $group) { 
     286                if ($group == $group_id) { return true; } 
     287            } 
     288        } 
     289    } 
     290    // user not found or no group match 
     291    return false; 
    264292} 
    265293 
Note: See TracChangeset for help on using the changeset viewer.