Author Topic: [MOD] - User rating (rate for other profile - FREE)  (Read 21894 times)

0 Members and 1 Guest are viewing this topic.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
[MOD] - User rating (rate for other profile - FREE)
« on: November 26, 2007, 01:57:55 AM »
I search in forum for user search for this - is BIG.  8O :)

- Check for active / no active MOD - include .
- Check for rate same user (is ignore) - include .
- Check for vote user before (1 vote only) - include .
- Only register user is vote - include .
- Use define rank value (e.g: x/10) - include .
- Use define number format value - include
- Additional user fields - include
- User delete vote can in private page - include
- User is see who vote - include
- User is see value post for post - include
- User is see total with mark value in private page - include
- Userpic - possible
- Avatar - possible
- PM Link - possible
- Test 4images v1.74 - is test
- Paging - No include

So here -

// Step 1

In member.php file,

find:

Code: [Select]
else {
      $user_email = REPLACE_EMPTY;
      $user_email_save = REPLACE_EMPTY;
      $user_mailform_link = REPLACE_EMPTY;
      $user_email_button = REPLACE_EMPTY;
    }

add after:

Code: [Select]
if (defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 1) {       
        if (function_exists('member_rating_check_user') && member_rating_check_user($user_info['user_id'], $user_row[$user_table_fields['user_id']], $user_info['user_level'])) {
            $already_rated = member_rating_check_user($user_info['user_id'], $user_row[$user_table_fields['user_id']], $user_info['user_level']);
   
        } elseif (function_exists('member_rating_check_user') && !member_rating_check_user($user_info['user_id'], $user_row[$user_table_fields['user_id']], $user_info['user_level'])) {
            $rating_content = "";
            for ($i = MEMBER_RATING_MARK_VALUE; $i > 0; $i--) {
                $site_template->register_vars("i", $i);
                $rating_content .= $site_template->parse_template("member_rating_dropdown");           
            }
        }
    }

Find:

Code: [Select]
//-----------------------------------------------------
//--- Show Profile ------------------------------------
//-----------------------------------------------------

add before:

Code: [Select]
//-----------------------------------------------------
//--- Rate user ---------------------------------------
//-----------------------------------------------------
if ($action == "rate_user") {
   
    if (isset($HTTP_POST_VARS[URL_USER_ID])) {
        $user_id = (isset($HTTP_POST_VARS[URL_USER_ID])) ? intval(trim($HTTP_POST_VARS[URL_USER_ID])) : 0;
        $user_id = preg_replace("/[^0-9]+/i", "", $user_id);
    } else {
        $user_id = 0;
    }
   
    if (isset($HTTP_POST_VARS['rate_user'])) {
        $rate_user = (isset($HTTP_POST_VARS['rate_user'])) ? intval(trim($HTTP_POST_VARS['rate_user'])) : 0;
        $rate_user = preg_replace("/[^0-9]+/i", "", $rate_user);
    } else {
        $rate_user = 0;
    }
   
    if (empty($user_id) || empty($rate_user)) {
        redirect($url);
    }
   
    if (isset($user_id) && !empty($user_id) && $rate_user == "---") {
        redirect("member.php?action=showprofile&" . URL_USER_ID . "=" . $user_id);
    }
   
    if (isset($user_id) && !empty($user_id) && isset($rate_user) && !empty($rate_user)) {
        if (function_exists('member_rating_insert_rates')) {
            member_rating_insert_rates($user_info['user_id'], $user_id, $user_info['user_level'], $rate_user);           
            redirect("member.php?action=showprofile&" . URL_USER_ID . "=" . $user_id);           
        }
    } elseif (isset($user_id) && !empty($user_id)) {
        redirect("member.php?action=showprofile&" . URL_USER_ID . "=" . $user_id);
   
    } else {
        redirect($url);
    }
}

find:

Code: [Select]
"lang_profile_of" => $lang['profile_of'],

add after:

Code: [Select]
"lang_member_rating_user_rate" => $lang['member_rating_user_rate'],
"already_rated" => (isset($already_rated)) ? trim($already_rated) : "",
"rating_content" => (isset($rating_content) && $user_info['user_id'] != $user_row[$user_table_fields['user_id']]) ? trim($rating_content) : "",

// Step 2

In global.php file,

find:

Code: [Select]
$site_db = new Db($db_host, $db_user, $db_password, $db_name);

add after:

Code: [Select]
//-----------------------------------------------------
//--- Creates member rating table ---------------------
//-----------------------------------------------------
if (function_exists('member_rating_check_table')) {
    member_rating_check_table();
}

// Step 3

In includes/page_header.php file,

find:

Code: [Select]
"url_lost_password" => (!empty($url_lost_password)) ? $site_sess->url($url_lost_password) : $site_sess->url(ROOT_PATH."member.php?action=lostpassword"),
"url_captcha_image" => $site_sess->url(ROOT_PATH."captcha.php"),

add after:

Code: [Select]
"url_member_rating" => $site_sess->url(ROOT_PATH . "member_rating.php"),

find:

Code: [Select]
"lang_last_upload_images" => $lang['last_upload_images'],

add after:

Code: [Select]
"lang_member_rating_title" => $lang['member_rating_title'],

// Step 4

In includes/constants.php file,

add in top ?>:

Code: [Select]
define('MEMBER_RATING_ACTIVE', 1); // Set for active (1) - set for no active (0) for value.
define('MEMBER_RATING_MARK_VALUE', 10); // Set on what value is set (e.g: x/10). '10' is mark value.
define('MEMBER_RATING_DECIMAL_VALUE', 2); // Set decimal after answer value for vote (e.g: 9,67/10). ',67' is 2 after value.

Note: This first after install MOD (and no edit mark value after user start rate) :!:

// Step 5

In includes/functions.php file,

add in top ?>:

Code: [Select]
if (!function_exists('member_rating_check_table')) {
    function member_rating_check_table() {
        global $site_db, $table_prefix;
       
        if (defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
       
        if (!defined('USERS_RATING_TABLE')) {
            define('USERS_RATING_TABLE', $table_prefix . 'users_rating');
        }
       
        $sql = "
       
        CREATE TABLE IF NOT EXISTS " . USERS_RATING_TABLE . " (
        field_id int(11) unsigned NOT NULL AUTO_INCREMENT,
        user_id int(11) NOT NULL DEFAULT '0',
        other_user_id int(11) NOT NULL DEFAULT '0',
        rating_date int(11) NOT NULL DEFAULT '0',       
        rating_value int(2) NOT NULL DEFAULT '0',
        rating_count int(11) NOT NULL DEFAULT '0',
        PRIMARY KEY(field_id)
        ) TYPE=MyISAM;
       
        ";
           
        $result = $site_db->query($sql);
    }
}

if (!function_exists('member_rating_check_user')) {
    function member_rating_check_user($user_id = 0, $other_user_id = 0, $user_level = GUEST) {
        global $site_db, $table_prefix;
       
        if (defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
       
        $user_id = preg_replace("/[^0-9]+/i", "", $user_id);
        $other_user_id = preg_replace("/[^0-9]+/i", "", $other_user_id);
        $user_level = preg_replace("/[^0-9]+/i", "", $user_level);
       
        if (empty($user_id) || empty($other_user_id) || $user_level == GUEST || $user_level == USER_AWAITING) {           
            return;
        }
       
        if (!defined('USERS_RATING_TABLE')) {
            define('USERS_RATING_TABLE', $table_prefix . 'users_rating');
        }
       
        $sql = "
       
        SELECT SUM(ur.rating_value) AS total_rates
        FROM " . USERS_RATING_TABLE . " ur
        LEFT JOIN " . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = ur.user_id)
        WHERE " . get_user_table_field("u.", "user_id") . " = ur.user_id AND ur.user_id = " . $user_id . " AND ur.other_user_id = " . $other_user_id . " AND " . get_user_table_field("u.", "user_level") . " >= '" . USER . "'
       
        ";
       
        $row = $site_db->query_firstrow($sql);
        $total_rates = (isset($row['total_rates'])) ? number_format($row['total_rates'], MEMBER_RATING_DECIMAL_VALUE) : 0;
       
        if (isset($total_rates) && $total_rates > 0) {
           
            $sql = "
           
            SELECT ur.rating_value
            FROM " . USERS_RATING_TABLE . " ur
            LEFT JOIN " . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = ur.other_user_id)
            WHERE " . get_user_table_field("u.", "user_id") . " = " . $other_user_id . " AND " . get_user_table_field("u.", "user_level") . " >= '" . USER . "'
       
            ";
       
            $result = $site_db->query($sql);
            $num_rows = $site_db->get_numrows($result);
           
            if (isset($num_rows) && $num_rows > 0) {
                $rating_value = "";
                while ($rate_row = $site_db->fetch_array($result)) {
                    $rating_value += $rate_row['rating_value'];                   
                }               
                           
                $calc_total_rates = ($rating_value / $num_rows);
                $answer_total_rates = (isset($calc_total_rates)) ? number_format($calc_total_rates, MEMBER_RATING_DECIMAL_VALUE) : "";
               
                return $answer_total_rates . "/" . MEMBER_RATING_MARK_VALUE;
               
            } else {
                return false;
            }
        }
    }
}

if (!function_exists('member_rating_insert_rates')) {
    function member_rating_insert_rates($user_id = 0, $other_user_id = 0, $user_level = GUEST, $user_rates = 0) {
        global $site_db, $table_prefix;
       
        if (defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
       
        $user_id = preg_replace("/[^0-9]+/i", "", $user_id);
        $other_user_id = preg_replace("/[^0-9]+/i", "", $other_user_id);
        $user_level = preg_replace("/[^0-9]+/i", "", $user_level);
        $user_rates = preg_replace("/[^0-9]+/i", "", $user_rates);
       
        if (empty($user_id) || empty($other_user_id) || $user_level == GUEST || $user_level == USER_AWAITING || empty($user_rates)) {
            return;
        }
       
        if (!defined('USERS_RATING_TABLE')) {
            define('USERS_RATING_TABLE', $table_prefix . 'users_rating');
        }
       
        $sql = "
       
        INSERT INTO " . USERS_RATING_TABLE . "
        (field_id, user_id, other_user_id, rating_date, rating_value, rating_count)
        VALUES(NULL, '" . $user_id . "', '" . $other_user_id . "', '" . time() . "', '" . $user_rates . "', '1')
       
        ";
       
        if ($site_db->query($sql)) {
            return true;
       
        } else {
            return false;
        }
    }
}

// Step 6

In lang/english/main.php file,

add in top ?>:

Code: [Select]
$lang['member_rating_user_rate'] = "User rate: ";
$lang['member_rating_no_content'] = "No one rated over your account yet.";
$lang['member_rating_title'] = "Who voted for me ?";
$lang['member_rating_user_name'] = "User name";
$lang['member_rating_date'] = "Date";
$lang['member_rating_value'] = "Gave you";
$lang['member_rating_total_rates_title'] = "Total rates";
$lang['member_rating_rated_value'] = "You have: <b>{answer_total_rates}</b>";
$lang['member_rating_delete'] = "Delete";

// Step 7

In ROOT_PATH - create file: member_rating.php .

Add:

Code: [Select]
<?php

$main_template 
"member_rating";

define('ROOT_PATH''./');
include(
ROOT_PATH 'global.php');
require(
ROOT_PATH 'includes/sessions.php');
@include_once(
ROOT_PATH 'includes/page_header.php');

if (
$user_info['user_level'] < USER) {
    
redirect($url);
}

if (
$action == "") {
    
$action "viewrating";
}

if (
$action == "delete_rate") {
    if (isset(
$HTTP_POST_VARS['delete_rate'])) {
        
$delete_rate = (isset($HTTP_POST_VARS['delete_rate'])) ? $HTTP_POST_VARS['delete_rate'] : $HTTP_GET_VARS['delete_rate'];
    } else {
        
$delete_rate "";
    }
    
    if (empty(
$delete_rate)) {
        
redirect("member_rating.php");
    }
    
    if (isset(
$delete_rate) && is_array($delete_rate) && !empty($delete_rate)) {        
        
$field_id_implode implode(", "$delete_rate);        
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }        
        
$result $site_db->query("DELETE FROM " USERS_RATING_TABLE " WHERE field_id IN (" $field_id_implode ")");
               
        if (isset(
$result) && $result) {
            
redirect("member_rating.php");
        }
    } else {
        
redirect("member_rating.php");
    }
}

if (
$action == "viewrating") {
    
    if (!
defined('USERS_RATING_TABLE')) {
        
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
    }
    
    if (isset(
$additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
        
$additional_sql "";
        foreach (
$additional_user_fields as $key => $val) {
            
$additional_sql .= ", u." $key;
        }
    }
    
    
$sql "
    
    SELECT ur.field_id, ur.user_id, ur.rating_date, ur.rating_value" 
get_user_table_field(", u.""user_name") . $additional_sql "    
    FROM " 
USERS_RATING_TABLE " ur
    LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = ur.user_id)
    WHERE ur.other_user_id = " 
$user_info['user_id'] . " AND " get_user_table_field("u.""user_level") . " >= '" USER "'    
    ORDER BY ur.rating_date DESC
    
    "
;
    
    
$result $site_db->query($sql);
    
$num_rows $site_db->get_numrows($result);
    
    if (isset(
$num_rows) && $num_rows <= 0) {
        
$msg $lang['member_rating_no_content'];
        
    } elseif (isset(
$num_rows) && $num_rows 0) {
        
$member_rating_content "";        
        
$calc_rating_value "";
        
$bgcounter 0;
        while (
$rate_row $site_db->fetch_array($result)) {
            
$row_bg_number = ($bgcounter++ % == 0) ? 2;

            
$field_id $rate_row['field_id'];
            
$user_id $rate_row['user_id'];
            
$user_name format_text(trim($rate_row[$user_table_fields['user_name']]), 2);
            
$user_url $site_sess->url(ROOT_PATH "member.php?action=showprofile&" URL_USER_ID "=" $user_id);
            
$rating_date format_date($config['date_format'] . ", " $config['time_format'], $rate_row['rating_date']);
            
$rating_value $rate_row['rating_value'];            
            
$calc_rating_value += $rate_row['rating_value']; 
            
            
$site_template->register_vars(array(
            
"field_id" => $field_id,
            
"user_id" => $user_id,
            
"user_name" => $user_name,
            
"user_url" => $user_url,
            
"rating_date" => $rating_date,
            
"rating_value" => $rating_value,
            
"counter" => $row_bg_number            
            
));
            if (isset(
$additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
                
$additional_field_array = array();
                foreach (
$additional_user_fields as $key => $val) {
                    
$additional_field_array[$key] = (!empty($rate_row[$key])) ? format_text($rate_row[$key], 1) : REPLACE_EMPTY;
                    
$additional_field_array['lang_'.$key] = $val[0];
                }
                if (!empty(
$additional_field_array)) {
                    
$site_template->register_vars($additional_field_array);
                }
            }
            
$member_rating_content .= $site_template->parse_template("member_rating_content");
        }
        
$calc_total_rates = (isset($calc_rating_value) && !empty($calc_rating_value)) ? ($calc_rating_value $num_rows) : "";
        
$answer_total_rates = (isset($calc_total_rates)) ? number_format($calc_total_ratesMEMBER_RATING_DECIMAL_VALUE) : "";                        
    }
}               

$clickstream "<a href=\"" $site_sess->url(ROOT_PATH "index.php") . "\">" $lang['home'] . "</a>" $config['category_separator'] . $lang['member_rating_title'];

$lang['delete'] = str_replace("["""$lang['delete']);
$lang['delete'] = str_replace("]"""$lang['delete']);

$site_template->register_vars(array(
"clickstream" => trim($clickstream),
"msg" => trim($msg),
"lang_member_rating_title" => $lang['member_rating_title'],
"lang_member_rating_user_name" => $lang['member_rating_user_name'],
"lang_member_rating_date" => $lang['member_rating_date'],
"lang_member_rating_value" => $lang['member_rating_value'],
"lang_member_rating_total_rates" => $lang['member_rating_total_rates_title'],
"lang_member_rating_delete" => $lang['member_rating_delete'],
"lang_delete" => $lang['delete'],
"member_rating_content" => (isset($member_rating_content)) ? trim($member_rating_content) : "",
"rated_value" => (isset($answer_total_rates) && $answer_total_rates && defined('MEMBER_RATING_MARK_VALUE')) ? preg_replace("/" $site_template->start "answer_total_rates" $site_template->end "/siU"$answer_total_rates "/" MEMBER_RATING_MARK_VALUE$lang['member_rating_rated_value']) : ""
));
$site_template->print_template($site_template->parse_template($main_template));

@include_once(
ROOT_PATH 'includes/page_footer.php');    
?>


// Step 8

In templates/your_template/member_profile.html file,

find:

Code: [Select]
<tr>
          <td class="row2"><b>{lang_icq}</b></td>
          <td class="row2">{if user_icq}<a href="http://www.icq.com/people/about_me.php?uin={user_icq}" target="_blank">{user_icq}</a> (<b>{user_icq_status}</b>){endif user_icq}</td>
        </tr>

add after:

Code: [Select]
{if user_loggedin}{if already_rated}
<tr>
          <td class="row1"><b>{lang_member_rating_user_rate}</b></td>
          <td class="row1">{already_rated}</td>
        </tr>
{endif already_rated}
{if rating_content}
<tr>
          <td class="row1"><b>{lang_member_rating_user_rate}</b></td>
          <td class="row1"><form name="jumpbox" action="{url_member}" method="post" /><input type="hidden" name="action" value="rate_user"><input type="hidden" name="user_id" value="{user_id}"><select name="rate_user" onchange="if (this.options[this.selectedIndex].value != 0) { forms['jumpbox'].submit() }" class="select" /><option value="---">---</option>{rating_content}</select></form></td>
        </tr>
{endif rating_content}{endif user_loggedin}

// Step 9

In templates/your_template - create new file: member_rating.html .

Add:
(Note: I use ULM).

Code: [Select]
{header}
{ste_layout_top}
{ste_layout_left}
                 
  {if is_admin}<! -- Who viewed my profile -- >{endif is_admin}
  {if msg}{ifno member_rating_content}
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td class="head1" valign="top">{lang_member_rating_title}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
    </table>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
                      <td class="row2" align="center" /><br /><b>{msg}</b><br /><br /></td>
                    </tr>
                  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
                      <td class="head2">&nbsp;</td>
                    </tr>
                  </table>
  <br />
  {endifno member_rating_content}{endif msg}
  {if is_admin}<! -- End - Who viewed my profile -- >{endif is_admin}
 
  {if is_admin}<! -- Who viewed my profile -- >{endif is_admin}
  {ifno msg}{if member_rating_content}
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="100%" class="head1" valign="top">{lang_member_rating_title}</td>
                          </tr>
                        </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="row2">&nbsp;</td>
                         </tr>
                       </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
                            <td width="100%" class="head1" valign="top">{lang_member_rating_total_rates}</td>
                          </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="100%" class="row2" valign="top" align="center" />{if rated_value}<br />{rated_value}{endif rated_value}</td>
                          </tr>
                        </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="row2">&nbsp;</td>
                         </tr>
                       </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="head1">&nbsp;</td>
                         </tr>
                       </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="row2">&nbsp;</td>
                         </tr>
                       </table>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_user_name}</td>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_date}</td>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_value}</td>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_delete}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
    </table>
  <table width="100%" border="1" cellspacing="0" cellpadding="0" class="tablebottom">
  <form action="{url_member_rating}" method="post" />
  <input type="hidden" name="action" value="delete_rate">
    {member_rating_content}  
                  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="25%" class="row2" valign="top" align="center" />&nbsp;</td>
                      <td width="25%" class="row2" valign="top" align="center" />&nbsp;</td>
                      <td width="25%" class="row2" valign="top" align="center" />&nbsp;</td>
                      <td width="25%" class="row2" valign="top" align="center" /><input type="submit" name="submit" value="{lang_delete}" class="button" /></form></td>
                    </tr>
                  </table>  
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
                      <td class="row2">&nbsp;</td>
                    </tr>
                  </table>
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
                      <td class="head2">&nbsp;</td>
                    </tr>
                  </table>
  <br />
  {endif member_rating_content}{endifno msg}
  {if is_admin}<! -- End - Who viewed my profile -- >{endif is_admin}
                 
{ste_layout_below}
{footer}

// Step 10

In templates/your_template - create new file: member_rating_content.html .

Add:

Code: [Select]
<tr>
<td width="25%" class="row{counter}" align="center"><a href="{user_url}" class="link" />{user_name}</a></td>
<td width="25%" class="row{counter}" align="center">{rating_date}</td>
<td width="25%" class="row{counter}" align="center">{rating_value}</td>
<td width="25%" class="row{counter}" align="center"><input type="checkbox" name="delete_rate[]" value="{field_id}"></td>
</tr>

// Step 11

In templates/your_template/user_logininfo.html file,

find:

Code: [Select]
&raquo; <a href="{url_control_panel}">{lang_control_panel}</a><br />

add after:

Code: [Select]
&raquo; <a href="{url_member_rating}">{lang_member_rating_title}</a><br />

// Step 12

In templates/your_template - create file: member_rating_dropdown.html .

Add:

Code: [Select]
<option value="{i}">{i}</option>

Finish. ;)
« Last Edit: November 26, 2007, 02:14:29 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #1 on: November 26, 2007, 04:23:14 AM »
I fix step 1 in first post.
I fix step 8 in first post.
I add step 11 in first post.
I add step 12 in first post.
I fix step 7 in first post.
I fix step 10 in first post.
« Last Edit: November 26, 2007, 02:16:24 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #2 on: November 26, 2007, 07:59:44 AM »
moved sticked.
thank you!
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline glitzer

  • Full Member
  • ***
  • Posts: 204
    • View Profile
    • over 7000 E-Cards
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #3 on: November 26, 2007, 10:47:23 AM »
Hi
I don´t understand this function?
I can vote for a user Profile?

greets,
Glitzer


Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #4 on: November 26, 2007, 11:04:16 AM »
hi, thank you for your work.
i miss the member_rating_dropdown.html file.
i'm correct?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #5 on: November 26, 2007, 02:15:00 PM »
hi, thank you for your work.
i miss the member_rating_dropdown.html file.
i'm correct?


Oh ... this is right ... thank for posting.  :oops:
I add step 12 and I fix step 7 and step 10. ;)

Quote
Hi
I don´t understand this function?
I can vote for a user Profile?

greets,
Glitzer

Yes - this is right. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline wickedd

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #6 on: June 18, 2008, 03:52:13 PM »
hey man, your mod is SUPER SWEET but I need something
is it possible to do voting for EVERYONE(guests) not only for members

thanks

Offline partymunich.de

  • Newbie
  • *
  • Posts: 14
    • View Profile
    • PartyMunich.de - München's Partyfotos
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #7 on: December 13, 2008, 03:02:32 PM »
works fine, but it would be nice to have a page which shows the best /most rated users
that'd be awesome!
http://adoz.de - Kostenloser Webkatalog ohne Backlinkpflicht
http://partymunich.de - Meine 4images Galerie

Offline luktur

  • Newbie
  • *
  • Posts: 37
    • View Profile
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #8 on: December 17, 2008, 02:49:21 AM »
Two problems:

1. I can't find in In includes/page_header.php file:
Quote
"lang_last_upload_images" => $lang['last_upload_images'],

2. Error:
Quote
DB Error: Bad SQL Query: SELECT ur.field_id, ur.user_id, ur.rating_date, ur.rating_value, u.user_name FROM 4images_users_rating ur LEFT JOIN 4images_users u ON (u.user_id = ur.user_id) WHERE ur.other_user_id = 44 AND u.user_level >= '2' ORDER BY ur.rating_date DESC
Table 'sony25_ogk.4images_users_rating' doesn't exist

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/sony25/domains/testowa.cal.pl/public_html/includes/db_mysql.php on line 116

Offline Benny Change

  • Addicted member
  • ******
  • Posts: 1.788
  • #WWG1WGA
    • View Profile
    • Qlobal-Change
[MOD] Rate other Profile | Berwerte andere Profile 1.7.7
« Reply #9 on: June 14, 2009, 10:13:06 PM »
Changelog: 2009-29-08
  • - {ste_layout_top}, {ste_layout_left} und {ste_layout_below} aus der member_rating.html gelöscht
  • - {ste_layout_top}, {ste_layout_left} and {ste_layout_below} deleted in member_rating.html

Changelog: 2009-14-06
  • - 4images 1.7.7 Kompatible
  • - Javascript Popup hinzugefügt für das löschen von Bewertungen (Willst du wirklich die Bewertung löschen? Ja/Nein)
  • - Javascript Popup added for deleate Rating (Really delte this Rate? Yes/No)

Step 1

Open / Öffne: member.php
Search / Suche:
else {
      
$user_email REPLACE_EMPTY;
      
$user_email_save REPLACE_EMPTY;
      
$user_mailform_link REPLACE_EMPTY;
      
$user_email_button REPLACE_EMPTY;
    }


Add after / Danach einfügen:
if (defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 1) {        
        if (
function_exists('member_rating_check_user') && member_rating_check_user($user_info['user_id'], $user_row[$user_table_fields['user_id']], $user_info['user_level'])) {
            
$already_rated member_rating_check_user($user_info['user_id'], $user_row[$user_table_fields['user_id']], $user_info['user_level']);
    
        } elseif (
function_exists('member_rating_check_user') && !member_rating_check_user($user_info['user_id'], $user_row[$user_table_fields['user_id']], $user_info['user_level'])) {
            
$rating_content "";
            for (
$i MEMBER_RATING_MARK_VALUE$i 0$i--) {
                
$site_template->register_vars("i"$i);
                
$rating_content .= $site_template->parse_template("member_rating_dropdown");            
            }
        }
    }


Find / Finde:
//-----------------------------------------------------
//--- Show Profile ------------------------------------
//-----------------------------------------------------


Add befor / Füge davor ein:
//-----------------------------------------------------
//--- Rate user ---------------------------------------
//-----------------------------------------------------
if ($action == "rate_user") {
    
    if (isset(
$HTTP_POST_VARS[URL_USER_ID])) {
        
$user_id = (isset($HTTP_POST_VARS[URL_USER_ID])) ? intval(trim($HTTP_POST_VARS[URL_USER_ID])) : 0;
        
$user_id preg_replace("/[^0-9]+/i"""$user_id);
    } else {
        
$user_id 0;
    }
    
    if (isset(
$HTTP_POST_VARS['rate_user'])) {
        
$rate_user = (isset($HTTP_POST_VARS['rate_user'])) ? intval(trim($HTTP_POST_VARS['rate_user'])) : 0;
        
$rate_user preg_replace("/[^0-9]+/i"""$rate_user);
    } else {
        
$rate_user 0;
    }
    
    if (empty(
$user_id) || empty($rate_user)) {
        
redirect($url);
    }
    
    if (isset(
$user_id) && !empty($user_id) && $rate_user == "---") {
        
redirect("member.php?action=showprofile&" URL_USER_ID "=" $user_id);
    }
    
    if (isset(
$user_id) && !empty($user_id) && isset($rate_user) && !empty($rate_user)) {
        if (
function_exists('member_rating_insert_rates')) {
            
member_rating_insert_rates($user_info['user_id'], $user_id$user_info['user_level'], $rate_user);            
            
redirect("member.php?action=showprofile&" URL_USER_ID "=" $user_id);            
        }
    } elseif (isset(
$user_id) && !empty($user_id)) {
        
redirect("member.php?action=showprofile&" URL_USER_ID "=" $user_id);
    
    } else {
        
redirect($url);
    }
}


Find / Finde:
"lang_profile_of" => $lang['profile_of'],


Add after / Füge danach ein:
"lang_member_rating_user_rate" => $lang['member_rating_user_rate'],
"already_rated" => (isset($already_rated)) ? trim($already_rated) : "",
"rating_content" => (isset($rating_content) && $user_info['user_id'] != $user_row[$user_table_fields['user_id']]) ? trim($rating_content) : "",


Step 2

Open / öffne: global.php
Search / Suche:
$site_db = new Db($db_host$db_user$db_password$db_name);


Add after / Füge danach ein:
//-----------------------------------------------------
//--- Creates member rating table ---------------------
//-----------------------------------------------------
if (function_exists('member_rating_check_table')) {
    
member_rating_check_table();
}


Step 3

Open / Öffne: includes/page_header.php
Search / Finde:
"url_lost_password" => (!empty($url_lost_password)) ? $site_sess->url($url_lost_password) : $site_sess->url(ROOT_PATH."member.php?action=lostpassword"),
"url_captcha_image" => $site_sess->url(ROOT_PATH."captcha.php"),


Add after / Füge danach ein:
"url_member_rating" => $site_sess->url(ROOT_PATH "member_rating.php"),


Find / Finde:
$site_template->register_vars(array(
  
"lang_site_stats" => $lang['site_stats'],

or / oder
 "lang_site_stats" => $lang['site_stats'],

Add after / Füge danach ein:
"lang_member_rating_title" => $lang['member_rating_title'],


Step 4

Open / Öffne: includes/constants.php
Search / Suche:
?>
Add befor / Füge davor ein:
define('MEMBER_RATING_ACTIVE'1); // Set for active (1) - set for no active (0) for value.
define('MEMBER_RATING_MARK_VALUE'10); // Set on what value is set (e.g: x/10). '10' is mark value.
define('MEMBER_RATING_DECIMAL_VALUE'2); // Set decimal after answer value for vote (e.g: 9,67/10). ',67' is 2 after value.


Note / Wichtig: Ändere die Zahlen erst, wenn ein User schon jemanden bewertet hat! (Nicht ändern wenn kein User schon bewertet hat) / This first after install MOD (and no edit mark value after user start rate)

Step 5

Open / öffne: includes/functions.php
Search / Suche:
?>
Add befor / Füge davor ein:
if (!function_exists('member_rating_check_table')) {
    function 
member_rating_check_table() {
        global 
$site_db$table_prefix;
        
        if (
defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }
        
        
$sql "
        
        CREATE TABLE IF NOT EXISTS " 
USERS_RATING_TABLE " (
        field_id int(11) unsigned NOT NULL AUTO_INCREMENT,
        user_id int(11) NOT NULL DEFAULT '0',
        other_user_id int(11) NOT NULL DEFAULT '0',
        rating_date int(11) NOT NULL DEFAULT '0',        
        rating_value int(2) NOT NULL DEFAULT '0',
        rating_count int(11) NOT NULL DEFAULT '0',
        PRIMARY KEY(field_id)
        ) TYPE=MyISAM;
        
        "
;
            
        
$result $site_db->query($sql);
    }
}

if (!
function_exists('member_rating_check_user')) {
    function 
member_rating_check_user($user_id 0$other_user_id 0$user_level GUEST) {
        global 
$site_db$table_prefix;
        
        if (
defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
        
        
$user_id preg_replace("/[^0-9]+/i"""$user_id);
        
$other_user_id preg_replace("/[^0-9]+/i"""$other_user_id);
        
$user_level preg_replace("/[^0-9]+/i"""$user_level);
        
        if (empty(
$user_id) || empty($other_user_id) || $user_level == GUEST || $user_level == USER_AWAITING) {            
            return;
        }
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }
        
        
$sql "
        
        SELECT SUM(ur.rating_value) AS total_rates
        FROM " 
USERS_RATING_TABLE " ur
        LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = ur.user_id)
        WHERE " 
get_user_table_field("u.""user_id") . " = ur.user_id AND ur.user_id = " $user_id " AND ur.other_user_id = " $other_user_id " AND " get_user_table_field("u.""user_level") . " >= '" USER "'
        
        "
;
        
        
$row $site_db->query_firstrow($sql);
        
$total_rates = (isset($row['total_rates'])) ? number_format($row['total_rates'], MEMBER_RATING_DECIMAL_VALUE) : 0;
        
        if (isset(
$total_rates) && $total_rates 0) {
            
            
$sql "
            
            SELECT ur.rating_value
            FROM " 
USERS_RATING_TABLE " ur
            LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = ur.other_user_id)
            WHERE " 
get_user_table_field("u.""user_id") . " = " $other_user_id " AND " get_user_table_field("u.""user_level") . " >= '" USER "'
        
            "
;
        
            
$result $site_db->query($sql);
            
$num_rows $site_db->get_numrows($result);
            
            if (isset(
$num_rows) && $num_rows 0) {
                
$rating_value "";
                while (
$rate_row $site_db->fetch_array($result)) {
                    
$rating_value += $rate_row['rating_value'];                    
                }                
                            
                
$calc_total_rates = ($rating_value $num_rows);
                
$answer_total_rates = (isset($calc_total_rates)) ? number_format($calc_total_ratesMEMBER_RATING_DECIMAL_VALUE) : "";
                
                return 
$answer_total_rates "/" MEMBER_RATING_MARK_VALUE;
                
            } else {
                return 
false;
            }
        }
    }
}

if (!
function_exists('member_rating_insert_rates')) {
    function 
member_rating_insert_rates($user_id 0$other_user_id 0$user_level GUEST$user_rates 0) {
        global 
$site_db$table_prefix;
        
        if (
defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
        
        
$user_id preg_replace("/[^0-9]+/i"""$user_id);
        
$other_user_id preg_replace("/[^0-9]+/i"""$other_user_id);
        
$user_level preg_replace("/[^0-9]+/i"""$user_level);
        
$user_rates preg_replace("/[^0-9]+/i"""$user_rates);
        
        if (empty(
$user_id) || empty($other_user_id) || $user_level == GUEST || $user_level == USER_AWAITING || empty($user_rates)) {
            return;
        }
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }
        
        
$sql "
        
        INSERT INTO " 
USERS_RATING_TABLE "
        (field_id, user_id, other_user_id, rating_date, rating_value, rating_count)
        VALUES(NULL, '" 
$user_id "', '" $other_user_id "', '" time() . "', '" $user_rates "', '1')
        
        "
;
        
        if (
$site_db->query($sql)) {
            return 
true;
        
        } else {
            return 
false;
        }
    }
}


Step 6

:flag-en: Open lang/english/main.php
Search
?>
Add befor:
$lang['member_rating_user_rate'] = "User rate: ";
$lang['member_rating_no_content'] = "No one rated over your account yet.";
$lang['member_rating_title'] = "Who voted for me ?";
$lang['member_rating_user_name'] = "User name";
$lang['member_rating_date'] = "Date";
$lang['member_rating_value'] = "Gave you";
$lang['member_rating_total_rates_title'] = "Total rates";
$lang['member_rating_rated_value'] = "You have: <b>{answer_total_rates}</b>";
$lang['member_rating_delete'] = "Delete";


:flag-de: Öffne lang/deutsch/main.php
Suche
?>
Füge davor ein:
$lang['member_rating_user_rate'] = "User bewerten: ";
$lang['member_rating_no_content'] = "Niemand hat dein Profil bewertet!";
$lang['member_rating_title'] = "Wer hat mich bewertet?";
$lang['member_rating_user_name'] = "Username";
$lang['member_rating_date'] = "Datum";
$lang['member_rating_value'] = "Bewertet dich mit";
$lang['member_rating_total_rates_title'] = "Gesamte Bewertung";
$lang['member_rating_rated_value'] = "Du hast: <b>{answer_total_rates}</b>";
$lang['member_rating_delete'] = "Loeschen";


Step 7

In ROOT-PATH  create a file with this code / Im ROOT_VERZEICHNIS erstelle eine Datei mit folgendem Inhalt
Filnename / Dateiname: member_rating.php
<?php

$main_template 
"member_rating";

define('ROOT_PATH''./');
include(
ROOT_PATH 'global.php');
require(
ROOT_PATH 'includes/sessions.php');
@include_once(
ROOT_PATH 'includes/page_header.php');

if (
$user_info['user_level'] < USER) {
    
redirect($url);
}

if (
$action == "") {
    
$action "viewrating";
}

if (
$action == "delete_rate") {
    if (isset(
$HTTP_POST_VARS['delete_rate'])) {
        
$delete_rate = (isset($HTTP_POST_VARS['delete_rate'])) ? $HTTP_POST_VARS['delete_rate'] : $HTTP_GET_VARS['delete_rate'];
    } else {
        
$delete_rate "";
    }
    
    if (empty(
$delete_rate)) {
        
redirect("member_rating.php");
    }
    
    if (isset(
$delete_rate) && is_array($delete_rate) && !empty($delete_rate)) {        
        
$field_id_implode implode(", "$delete_rate);        
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }        
        
$result $site_db->query("DELETE FROM " USERS_RATING_TABLE " WHERE field_id IN (" $field_id_implode ")");
               
        if (isset(
$result) && $result) {
            
redirect("member_rating.php");
        }
    } else {
        
redirect("member_rating.php");
    }
}

if (
$action == "viewrating") {
    
    if (!
defined('USERS_RATING_TABLE')) {
        
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
    }
    
    if (isset(
$additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
        
$additional_sql "";
        foreach (
$additional_user_fields as $key => $val) {
            
$additional_sql .= ", u." $key;
        }
    }
    
    
$sql "
    
    SELECT ur.field_id, ur.user_id, ur.rating_date, ur.rating_value" 
get_user_table_field(", u.""user_name") . $additional_sql "    
    FROM " 
USERS_RATING_TABLE " ur
    LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = ur.user_id)
    WHERE ur.other_user_id = " 
$user_info['user_id'] . " AND " get_user_table_field("u.""user_level") . " >= '" USER "'    
    ORDER BY ur.rating_date DESC
    
    "
;
    
    
$result $site_db->query($sql);
    
$num_rows $site_db->get_numrows($result);
    
    if (isset(
$num_rows) && $num_rows <= 0) {
        
$msg $lang['member_rating_no_content'];
        
    } elseif (isset(
$num_rows) && $num_rows 0) {
        
$member_rating_content "";        
        
$calc_rating_value "";
        
$bgcounter 0;
        while (
$rate_row $site_db->fetch_array($result)) {
            
$row_bg_number = ($bgcounter++ % == 0) ? 2;

            
$field_id $rate_row['field_id'];
            
$user_id $rate_row['user_id'];
            
$user_name format_text(trim($rate_row[$user_table_fields['user_name']]), 2);
            
$user_url $site_sess->url(ROOT_PATH "member.php?action=showprofile&" URL_USER_ID "=" $user_id);
            
$rating_date format_date($config['date_format'] . ", " $config['time_format'], $rate_row['rating_date']);
            
$rating_value $rate_row['rating_value'];            
            
$calc_rating_value += $rate_row['rating_value']; 
            
            
$site_template->register_vars(array(
            
"field_id" => $field_id,
            
"user_id" => $user_id,
            
"user_name" => $user_name,
            
"user_url" => $user_url,
            
"rating_date" => $rating_date,
            
"rating_value" => $rating_value,
            
"counter" => $row_bg_number            
            
));
            if (isset(
$additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
                
$additional_field_array = array();
                foreach (
$additional_user_fields as $key => $val) {
                    
$additional_field_array[$key] = (!empty($rate_row[$key])) ? format_text($rate_row[$key], 1) : REPLACE_EMPTY;
                    
$additional_field_array['lang_'.$key] = $val[0];
                }
                if (!empty(
$additional_field_array)) {
                    
$site_template->register_vars($additional_field_array);
                }
            }
            
$member_rating_content .= $site_template->parse_template("member_rating_content");
        }
        
$calc_total_rates = (isset($calc_rating_value) && !empty($calc_rating_value)) ? ($calc_rating_value $num_rows) : "";
        
$answer_total_rates = (isset($calc_total_rates)) ? number_format($calc_total_ratesMEMBER_RATING_DECIMAL_VALUE) : "";                        
    }
}               

$clickstream "<a href=\"" $site_sess->url(ROOT_PATH "index.php") . "\">" $lang['home'] . "</a>" $config['category_separator'] . $lang['member_rating_title'];

$lang['delete'] = str_replace("["""$lang['delete']);
$lang['delete'] = str_replace("]"""$lang['delete']);

$site_template->register_vars(array(
"clickstream" => trim($clickstream),
"msg" => trim($msg),
"lang_member_rating_title" => $lang['member_rating_title'],
"lang_member_rating_user_name" => $lang['member_rating_user_name'],
"lang_member_rating_date" => $lang['member_rating_date'],
"lang_member_rating_value" => $lang['member_rating_value'],
"lang_member_rating_total_rates" => $lang['member_rating_total_rates_title'],
"lang_member_rating_delete" => $lang['member_rating_delete'],
"lang_delete" => $lang['delete'],
"member_rating_content" => (isset($member_rating_content)) ? trim($member_rating_content) : "",
"rated_value" => (isset($answer_total_rates) && $answer_total_rates && defined('MEMBER_RATING_MARK_VALUE')) ? preg_replace("/" $site_template->start "answer_total_rates" $site_template->end "/siU"$answer_total_rates "/" MEMBER_RATING_MARK_VALUE$lang['member_rating_rated_value']) : ""
));
$site_template->print_template($site_template->parse_template($main_template));

@include_once(
ROOT_PATH 'includes/page_footer.php');    
?>


Step 8


Open / Öffne: templates/your_template/member_profile.html
Find / Finde
Code: [Select]
<tr>
          <td class="row2"><b>{lang_icq}</b></td>
          <td class="row2">{if user_icq}<a href="http://www.icq.com/people/about_me.php?uin={user_icq}" target="_blank">{user_icq}</a> (<b>{user_icq_status}</b>){endif user_icq}</td>
        </tr>

Add after / Füge danach ein:
Code: [Select]
{if user_loggedin}{if already_rated}
<tr>
          <td class="row1"><b>{lang_member_rating_user_rate}</b></td>
          <td class="row1">{already_rated}</td>
        </tr>
{endif already_rated}
{if rating_content}
<tr>
          <td class="row1"><b>{lang_member_rating_user_rate}</b></td>
          <td class="row1"><form name="jumpbox" action="{url_member}" method="post" /><input type="hidden" name="action" value="rate_user"><input type="hidden" name="user_id" value="{user_id}"><select name="rate_user" onchange="if (this.options[this.selectedIndex].value != 0) { forms['jumpbox'].submit() }" class="select" /><option value="---">---</option>{rating_content}</select></form></td>
        </tr>
{endif rating_content}{endif user_loggedin}

Step 9
In templates/your_template create a file with this code / Im templates/dein_template erstelle eine Datei mit folgendem Inhalt
Filename / Dateiname: member_rating.html
:flag-de:
Code: [Select]
{header}
                  
 {if is_admin}<! -- Who viewed my profile -- >{endif is_admin}
 {if msg}{ifno member_rating_content}
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td class="head1" valign="top">{lang_member_rating_title}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
   </table>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
                      <td class="row2" align="center" /><br /><b>{msg}</b><br /><br /></td>
                    </tr>
                  </table>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
                      <td class="head2">&nbsp;</td>
                    </tr>
                  </table>
 <br />
 {endifno member_rating_content}{endif msg}
 {if is_admin}<! -- End - Who viewed my profile -- >{endif is_admin}
 
 {if is_admin}<! -- Who viewed my profile -- >{endif is_admin}
 {ifno msg}{if member_rating_content}
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="100%" class="head1" valign="top">{lang_member_rating_title}</td>
                          </tr>
                        </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="row2">&nbsp;</td>
                         </tr>
                       </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
                            <td width="100%" class="head1" valign="top">{lang_member_rating_total_rates}</td>
                          </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="100%" class="row2" valign="top" align="center" />{if rated_value}<br />{rated_value}{endif rated_value}</td>
                          </tr>
                        </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="row2">&nbsp;</td>
                         </tr>
                       </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="head1">&nbsp;</td>
                         </tr>
                       </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="row2">&nbsp;</td>
                         </tr>
                       </table>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_user_name}</td>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_date}</td>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_value}</td>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_delete}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
   </table>
 <table width="100%" border="1" cellspacing="0" cellpadding="0" class="tablebottom">
 <form action="{url_member_rating}" method="post" />
 <input type="hidden" name="action" value="delete_rate">
   {member_rating_content}  
                  </table>
          <script language="JavaScript">
/* <![CDATA[ */
function del(){
   if(confirm("Willst du die Bewertung von {user_name} mit {rating_value} Punkten wikrlich löschen?") == true)
      document.form.submit();
}
/* ]]> */
</script>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="25%" class="row2" valign="top" align="center" />&nbsp;</td>
                      <td width="25%" class="row2" valign="top" align="center" />&nbsp;</td>
                      <td width="25%" class="row2" valign="top" align="center" />&nbsp;</td>
                      <td width="25%" class="row2" valign="top" align="center" /><input type="submit" name="submit" value="{lang_delete}" class="button" /></form></td>
                    </tr>
                  </table>  
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
                      <td class="row2">&nbsp;</td>
                    </tr>
                  </table>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
                      <td class="head2">&nbsp;</td>
                    </tr>
                  </table>
 <br />
 {endif member_rating_content}{endifno msg}
 {if is_admin}<! -- End - Who viewed my profile -- >{endif is_admin}
{footer}
:flag-en:
Code: [Select]
{header}
                  
 {if is_admin}<! -- Who viewed my profile -- >{endif is_admin}
 {if msg}{ifno member_rating_content}
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td class="head1" valign="top">{lang_member_rating_title}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
   </table>
   <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
                      <td class="row2" align="center" /><br /><b>{msg}</b><br /><br /></td>
                    </tr>
                  </table>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
                      <td class="head2">&nbsp;</td>
                    </tr>
                  </table>
 <br />
 {endifno member_rating_content}{endif msg}
 {if is_admin}<! -- End - Who viewed my profile -- >{endif is_admin}
 
 {if is_admin}<! -- Who viewed my profile -- >{endif is_admin}
 {ifno msg}{if member_rating_content}
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="100%" class="head1" valign="top">{lang_member_rating_title}</td>
                          </tr>
                        </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="row2">&nbsp;</td>
                         </tr>
                       </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr>
                            <td width="100%" class="head1" valign="top">{lang_member_rating_total_rates}</td>
                          </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="100%" class="row2" valign="top" align="center" />{if rated_value}<br />{rated_value}{endif rated_value}</td>
                          </tr>
                        </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="row2">&nbsp;</td>
                         </tr>
                       </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="head1">&nbsp;</td>
                         </tr>
                       </table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                          <td width="100%" class="row2">&nbsp;</td>
                         </tr>
                       </table>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_user_name}</td>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_date}</td>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_value}</td>
                            <td width="25%" class="head1" align="center" valign="top">{lang_member_rating_delete}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
   </table>
 <table width="100%" border="1" cellspacing="0" cellpadding="0" class="tablebottom">
 <form action="{url_member_rating}" method="post" />
 <input type="hidden" name="action" value="delete_rate">
   {member_rating_content}  
                  </table>
          <script language="JavaScript">
/* <![CDATA[ */
function del(){
   if(confirm("If you want the Rate of {user_name} with {rating_value} points really delete?") == true)
      document.form.submit();
}
/* ]]> */
</script>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="25%" class="row2" valign="top" align="center" />&nbsp;</td>
                      <td width="25%" class="row2" valign="top" align="center" />&nbsp;</td>
                      <td width="25%" class="row2" valign="top" align="center" />&nbsp;</td>
                      <td width="25%" class="row2" valign="top" align="center" /><input type="submit" name="submit" value="{lang_delete}" class="button" /></form></td>
                    </tr>
                  </table>  
                  <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
                      <td class="row2">&nbsp;</td>
                    </tr>
                  </table>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
                      <td class="head2">&nbsp;</td>
                    </tr>
                  </table>
 <br />
 {endif member_rating_content}{endifno msg}
 {if is_admin}<! -- End - Who viewed my profile -- >{endif is_admin}
{footer}

Step 10
In templates/your_template create a file with this code / Im templates/dein_template erstelle eine Datei mit folgendem Inhalt
Filename / Dateiname: member_rating_content.htmll
Code: [Select]
<tr>
<td width="25%" class="row{counter}" align="center"><a href="{user_url}" class="link" />{user_name}</a></td>
<td width="25%" class="row{counter}" align="center">{rating_date}</td>
<td width="25%" class="row{counter}" align="center">{rating_value}</td>
<td width="25%" class="row{counter}" align="center"><input type="checkbox" name="delete_rate[]" value="{field_id}" onClick="del()"></td>
</tr>

Step 11
Open / Öffne: templates/your_template/user_logininfo.html
Search / Suche:
Code: [Select]
&raquo; <a href="{url_control_panel}">{lang_control_panel}</a><br />
Add after / Füge danach ein:
Code: [Select]
&raquo; <a href="{url_member_rating}">{lang_member_rating_title}</a><br />

Step 12
In templates/your_template create a file with this code / Im templates/dein_template erstelle eine Datei mit folgendem Inhalt
Filename / Dateiname: member_rating_dropdown.htmll
Code: [Select]
<option value="{i}">{i}</option>

Step 13
Installation
Use you sql editor or phpmyadmin to insert this table into you database.
Benutze ein SQL Editor oder PhpMyAdmin um die Tabellen anzulegen
Code: [Select]
       CREATE TABLE IF NOT EXISTS `4images_users_rating` (
        `field_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `user_id` int(11) NOT NULL DEFAULT '0',
        `other_user_id` int(11) NOT NULL DEFAULT '0',
        `rating_date` int(11) NOT NULL DEFAULT '0',        
        `rating_value` int(2) NOT NULL DEFAULT '0',
        `rating_count` int(11) NOT NULL DEFAULT '0',
        PRIMARY KEY(`field_id`)
        ) TYPE=MyISAM;

Finish / Fertig
Have Fun / Viel Spaß
« Last Edit: September 29, 2009, 11:34:57 PM by Sumale.nin »
Beste Grüße
Benny

Offline MrAndrew

  • Sr. Member
  • ****
  • Posts: 302
    • View Profile
    • Aviation PhotoBase
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #10 on: October 21, 2010, 09:05:10 PM »
So, i have written a little addition for this MOD.

Description: With this addition you will have a possible to show something like this "Most Popular Photographer" on your main page.

Files to edit:
page_header.php
member_rating.php
includes/functions.php
lang/.../mail.php
home.html


Installation:

1) If you haven`t installed this mod, skip this step and go to 2 step.

In your PhpMyAdmin select table 4images_users_rating and search for user_id field.
Rename:
Code: [Select]
user_id to
Code: [Select]
user_ids
2) In includes/functions.php search:
if (!function_exists('member_rating_check_table')) {
    function 
member_rating_check_table() {
        global 
$site_db$table_prefix;
        
        if (
defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }
        
        
$sql "
        
        CREATE TABLE IF NOT EXISTS " 
USERS_RATING_TABLE " (
        field_id int(11) unsigned NOT NULL AUTO_INCREMENT,
        user_id int(11) NOT NULL DEFAULT '0',
        other_user_id int(11) NOT NULL DEFAULT '0',
        rating_date int(11) NOT NULL DEFAULT '0',        
        rating_value int(2) NOT NULL DEFAULT '0',
        rating_count int(11) NOT NULL DEFAULT '0',
        PRIMARY KEY(field_id)
        ) TYPE=MyISAM;
        
        "
;
            
        
$result $site_db->query($sql);
    }
}

if (!
function_exists('member_rating_check_user')) {
    function 
member_rating_check_user($user_id 0$other_user_id 0$user_level GUEST) {
        global 
$site_db$table_prefix;
        
        if (
defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
        
        
$user_id preg_replace("/[^0-9]+/i"""$user_id);
        
$other_user_id preg_replace("/[^0-9]+/i"""$other_user_id);
        
$user_level preg_replace("/[^0-9]+/i"""$user_level);
        
        if (empty(
$user_id) || empty($other_user_id) || $user_level == GUEST || $user_level == USER_AWAITING) {            
            return;
        }
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }
        
        
$sql "
        
        SELECT SUM(ur.rating_value) AS total_rates
        FROM " 
USERS_RATING_TABLE " ur
        LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = ur.user_id)
        WHERE " 
get_user_table_field("u.""user_id") . " = ur.user_id AND ur.user_id = " $user_id " AND ur.other_user_id = " $other_user_id " AND " get_user_table_field("u.""user_level") . " >= '" USER "'
        
        "
;
        
        
$row $site_db->query_firstrow($sql);
        
$total_rates = (isset($row['total_rates'])) ? number_format($row['total_rates'], MEMBER_RATING_DECIMAL_VALUE) : 0;
        
        if (isset(
$total_rates) && $total_rates 0) {
            
            
$sql "
            
            SELECT ur.rating_value
            FROM " 
USERS_RATING_TABLE " ur
            LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = ur.other_user_id)
            WHERE " 
get_user_table_field("u.""user_id") . " = " $other_user_id " AND " get_user_table_field("u.""user_level") . " >= '" USER "'
        
            "
;
        
            
$result $site_db->query($sql);
            
$num_rows $site_db->get_numrows($result);
            
            if (isset(
$num_rows) && $num_rows 0) {
                
$rating_value "";
                while (
$rate_row $site_db->fetch_array($result)) {
                    
$rating_value += $rate_row['rating_value'];                    
                }                
                            
                
$calc_total_rates = ($rating_value $num_rows);
                
$answer_total_rates = (isset($calc_total_rates)) ? number_format($calc_total_ratesMEMBER_RATING_DECIMAL_VALUE) : "";
                
                return 
$answer_total_rates "/" MEMBER_RATING_MARK_VALUE;
                
            } else {
                return 
false;
            }
        }
    }
}

if (!
function_exists('member_rating_insert_rates')) {
    function 
member_rating_insert_rates($user_id 0$other_user_id 0$user_level GUEST$user_rates 0) {
        global 
$site_db$table_prefix;
        
        if (
defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
        
        
$user_id preg_replace("/[^0-9]+/i"""$user_id);
        
$other_user_id preg_replace("/[^0-9]+/i"""$other_user_id);
        
$user_level preg_replace("/[^0-9]+/i"""$user_level);
        
$user_rates preg_replace("/[^0-9]+/i"""$user_rates);
        
        if (empty(
$user_id) || empty($other_user_id) || $user_level == GUEST || $user_level == USER_AWAITING || empty($user_rates)) {
            return;
        }
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }
        
        
$sql "
        
        INSERT INTO " 
USERS_RATING_TABLE "
        (field_id, user_id, other_user_id, rating_date, rating_value, rating_count)
        VALUES(NULL, '" 
$user_id "', '" $other_user_id "', '" time() . "', '" $user_rates "', '1')
        
        "
;
        
        if (
$site_db->query($sql)) {
            return 
true;
        
        } else {
            return 
false;
        }
    }
}


Replace:

if (!function_exists('member_rating_check_table')) {
    function 
member_rating_check_table() {
        global 
$site_db$table_prefix;
        
        if (
defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }
        
        
$sql "
        
        CREATE TABLE IF NOT EXISTS " 
USERS_RATING_TABLE " (
        field_id int(11) unsigned NOT NULL AUTO_INCREMENT,
        user_ids int(11) NOT NULL DEFAULT '0',
        other_user_id int(11) NOT NULL DEFAULT '0',
        rating_date int(11) NOT NULL DEFAULT '0',        
        rating_value int(2) NOT NULL DEFAULT '0',
        rating_count int(11) NOT NULL DEFAULT '0',
        PRIMARY KEY(field_id)
        ) TYPE=MyISAM;
        
        "
;
            
        
$result $site_db->query($sql);
    }
}

if (!
function_exists('member_rating_check_user')) {
    function 
member_rating_check_user($user_id 0$other_user_id 0$user_level GUEST) {
        global 
$site_db$table_prefix;
        
        if (
defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
        
        
$user_id preg_replace("/[^0-9]+/i"""$user_id);
        
$other_user_id preg_replace("/[^0-9]+/i"""$other_user_id);
        
$user_level preg_replace("/[^0-9]+/i"""$user_level);
        
        if (empty(
$user_id) || empty($other_user_id) || $user_level == GUEST || $user_level == USER_AWAITING) {            
            return;
        }
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }
        
        
$sql "
        
        SELECT SUM(ur.rating_value) AS total_rates
        FROM " 
USERS_RATING_TABLE " ur
        LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = ur.user_ids)
        WHERE " 
get_user_table_field("u.""user_id") . " = ur.user_ids AND ur.user_ids = " $user_id " AND ur.other_user_id = " $other_user_id " AND " get_user_table_field("u.""user_level") . " >= '" USER "'
        
        "
;
        
        
$row $site_db->query_firstrow($sql);
        
$total_rates = (isset($row['total_rates'])) ? number_format($row['total_rates'], MEMBER_RATING_DECIMAL_VALUE) : 0;
        
        if (isset(
$total_rates) && $total_rates 0) {
            
            
$sql "
            
            SELECT ur.rating_value
            FROM " 
USERS_RATING_TABLE " ur
            LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = ur.other_user_id)
            WHERE " 
get_user_table_field("u.""user_id") . " = " $other_user_id " AND " get_user_table_field("u.""user_level") . " >= '" USER "'
        
            "
;
        
            
$result $site_db->query($sql);
            
$num_rows $site_db->get_numrows($result);
            
            if (isset(
$num_rows) && $num_rows 0) {
                
$rating_value "";
                while (
$rate_row $site_db->fetch_array($result)) {
                    
$rating_value += $rate_row['rating_value'];                    
                }                
                            
                
$calc_total_rates = ($rating_value $num_rows);
                
$answer_total_rates = (isset($calc_total_rates)) ? number_format($calc_total_ratesMEMBER_RATING_DECIMAL_VALUE) : "";
                
                return 
$answer_total_rates "/" MEMBER_RATING_MARK_VALUE;
                
            } else {
                return 
false;
            }
        }
    }
}

if (!
function_exists('member_rating_insert_rates')) {
    function 
member_rating_insert_rates($user_id 0$other_user_id 0$user_level GUEST$user_rates 0) {
        global 
$site_db$table_prefix;
        
        if (
defined('MEMBER_RATING_ACTIVE') && MEMBER_RATING_ACTIVE == 0) {
            return;
        }
        
        
$user_id preg_replace("/[^0-9]+/i"""$user_id);
        
$other_user_id preg_replace("/[^0-9]+/i"""$other_user_id);
        
$user_level preg_replace("/[^0-9]+/i"""$user_level);
        
$user_rates preg_replace("/[^0-9]+/i"""$user_rates);
        
        if (empty(
$user_id) || empty($other_user_id) || $user_level == GUEST || $user_level == USER_AWAITING || empty($user_rates)) {
            return;
        }
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }
        
        
$sql "
        
        INSERT INTO " 
USERS_RATING_TABLE "
        (field_id, user_ids, other_user_id, rating_date, rating_value, rating_count)
        VALUES(NULL, '" 
$user_id "', '" $other_user_id "', '" time() . "', '" $user_rates "', '1')
        
        "
;
        
        if (
$site_db->query($sql)) {
            return 
true;
        
        } else {
            return 
false;
        }
    }
}


3) In member_rating.php replace all path by this code:

<?php

$main_template 
"member_rating";

define('ROOT_PATH''./');
include(
ROOT_PATH 'global.php');
require(
ROOT_PATH 'includes/sessions.php');
@include_once(
ROOT_PATH 'includes/page_header.php');

if (
$user_info['user_level'] < USER) {
    
redirect($url);
}

if (
$action == "") {
    
$action "viewrating";
}

if (
$action == "delete_rate") {
    if (isset(
$HTTP_POST_VARS['delete_rate'])) {
        
$delete_rate = (isset($HTTP_POST_VARS['delete_rate'])) ? $HTTP_POST_VARS['delete_rate'] : $HTTP_GET_VARS['delete_rate'];
    } else {
        
$delete_rate "";
    }
    
    if (empty(
$delete_rate)) {
        
redirect("member_rating.php");
    }
    
    if (isset(
$delete_rate) && is_array($delete_rate) && !empty($delete_rate)) {        
        
$field_id_implode implode(", "$delete_rate);        
        
        if (!
defined('USERS_RATING_TABLE')) {
            
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
        }        
        
$result $site_db->query("DELETE FROM " USERS_RATING_TABLE " WHERE field_id IN (" $field_id_implode ")");
               
        if (isset(
$result) && $result) {
            
redirect("member_rating.php");
        }
    } else {
        
redirect("member_rating.php");
    }
}

if (
$action == "viewrating") {
    
    if (!
defined('USERS_RATING_TABLE')) {
        
define('USERS_RATING_TABLE'$table_prefix 'users_rating');
    }
    
    if (isset(
$additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
        
$additional_sql "";
        foreach (
$additional_user_fields as $key => $val) {
            
$additional_sql .= ", u." $key;
        }
    }
    
    
$sql "
    
    SELECT ur.field_id, ur.user_ids, ur.rating_date, ur.rating_value" 
get_user_table_field(", u.""user_name") . $additional_sql "    
    FROM " 
USERS_RATING_TABLE " ur
    LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = ur.user_ids)
    WHERE ur.other_user_id = " 
$user_info['user_id'] . " AND " get_user_table_field("u.""user_level") . " >= '" USER "'    
    ORDER BY ur.rating_date DESC
    
    "
;
    
    
$result $site_db->query($sql);
    
$num_rows $site_db->get_numrows($result);
    
    if (isset(
$num_rows) && $num_rows <= 0) {
        
$msg $lang['member_rating_no_content'];
        
    } elseif (isset(
$num_rows) && $num_rows 0) {
        
$member_rating_content "";        
        
$calc_rating_value "";
        
$bgcounter 0;
        while (
$rate_row $site_db->fetch_array($result)) {
            
$row_bg_number = ($bgcounter++ % == 0) ? 2;

            
$field_id $rate_row['field_id'];
            
$user_id $rate_row['user_ids'];
            
$user_name format_text(trim($rate_row[$user_table_fields['user_name']]), 2);
            
$user_url $site_sess->url(ROOT_PATH "member.php?action=showprofile&" URL_USER_ID "=" $user_id);
            
$rating_date format_date($config['date_format'] . ", " $config['time_format'], $rate_row['rating_date']);
            
$rating_value $rate_row['rating_value'];            
            
$calc_rating_value += $rate_row['rating_value']; 
            
            
$site_template->register_vars(array(
            
"field_id" => $field_id,
            
"user_id" => $user_id,
            
"user_name" => $user_name,
            
"user_url" => $user_url,
            
"rating_date" => $rating_date,
            
"rating_value" => $rating_value,
            
"counter" => $row_bg_number            
            
));
            if (isset(
$additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
                
$additional_field_array = array();
                foreach (
$additional_user_fields as $key => $val) {
                    
$additional_field_array[$key] = (!empty($rate_row[$key])) ? format_text($rate_row[$key], 1) : REPLACE_EMPTY;
                    
$additional_field_array['lang_'.$key] = $val[0];
                }
                if (!empty(
$additional_field_array)) {
                    
$site_template->register_vars($additional_field_array);
                }
            }
            
$member_rating_content .= $site_template->parse_template("member_rating_content");
        }
        
$calc_total_rates = (isset($calc_rating_value) && !empty($calc_rating_value)) ? ($calc_rating_value $num_rows) : "";
        
$answer_total_rates = (isset($calc_total_rates)) ? number_format($calc_total_ratesMEMBER_RATING_DECIMAL_VALUE) : "";                        
    }
}               

$clickstream "<a href=\"" $site_sess->url(ROOT_PATH "index.php") . "\">" $lang['home'] . "</a>" $config['category_separator'] . $lang['member_rating_title'];

$lang['delete'] = str_replace("["""$lang['delete']);
$lang['delete'] = str_replace("]"""$lang['delete']);

$site_template->register_vars(array(
"clickstream" => trim($clickstream),
"msg" => trim($msg),
"lang_member_rating_title" => $lang['member_rating_title'],
"lang_member_rating_user_name" => $lang['member_rating_user_name'],
"lang_member_rating_date" => $lang['member_rating_date'],
"lang_member_rating_value" => $lang['member_rating_value'],
"lang_member_rating_total_rates" => $lang['member_rating_total_rates_title'],
"lang_member_rating_delete" => $lang['member_rating_delete'],
"lang_delete" => $lang['delete'],
"member_rating_content" => (isset($member_rating_content)) ? trim($member_rating_content) : "",
"rated_value" => (isset($answer_total_rates) && $answer_total_rates && defined('MEMBER_RATING_MARK_VALUE')) ? preg_replace("/" $site_template->start "answer_total_rates" $site_template->end "/siU"$answer_total_rates "/" MEMBER_RATING_MARK_VALUE$lang['member_rating_rated_value']) : ""
));
$site_template->print_template($site_template->parse_template($main_template));

@include_once(
ROOT_PATH 'includes/page_footer.php');    
?>


4) Open includes/page_header and before ?> add:

//-----------------------------------------------------
//--- MOST RATED USERS --------------------------------
//-----------------------------------------------------

$most_rated_user "";

$sql =  "SELECT `other_user_id`, SUM(`rating_value`) AS `vot_sum`, `user_name` AS `name`
        FROM "
.USERS_RATING_TABLE." AS `rating`, ".USERS_TABLE." AS `users`
        WHERE `other_user_id` = `user_id`
        GROUP BY `other_user_id` ORDER BY `vot_sum` DESC LIMIT 10"
;
   
$result $site_db->query($sql);
$sum = (isset($row['vot_sum'])) ? $row['vot_sum'] : 0;


while (
$row $site_db->fetch_array($result)) {

$most_rated_user .= "<tr>";
$most_rated_user .= "<td width=\"180\" align=\"left\">";
$most_rated_user .= '<a href ="'.ROOT_PATH.'search.php?search_user='.$row['name'].'"><b>'.$row['name'].'</b></a>';
$most_rated_user .= "</td>";
$most_rated_user .= "<td width=\"70\" align=\"center\">";
$most_rated_user .= '<span class="smalltext"><b>'.$row['vot_sum'].'</b></span>';
$most_rated_user .= "</td>";
$most_rated_user .= "</tr>";

}

$site_template->register_vars(array(
"most_rated_user" => $most_rated_user,
));
unset(
$most_rated_user);
//-----------------------------------------------------


5) Open home.html and add where you want to show top

                <TABLE border="0" cellpadding="0" cellspacing="0" width="100%" class="head1">
                  <
TR>
                    <
TD>
                      <
TABLE border="0" cellpadding="2" cellspacing="1" width="100%">
                        <
TR>
                          <
TD bgcolor="#434242" ALIGN="center"><TABLE CELLPADDING="1" CELLSPACING="0" BORDER="0" WIDTH="100%"><TR><TD ALIGN="center"><FONT FACE="verdana" SIZE="2" COLOR="#f3f3f3"><b>- {lang_most_pop_spotter} -</FONT></TD></TR></TABLE></TD>
                        </
TR>
                        <
TR>
                          <
TD BGCOLOR="#e2e0e0">
                            <
TABLE BORDER="0" WIDTH="100%">
                              <
TR>
                                <
TD VALIGN="top" align="center" width="250">
                                  <
table border="0" cellspacing="1" cellpadding="1" background="{template_url}/images/cat.gif">
                                    <
tr>
                                      <
td class="row1" td width="180" align="left"><font color="black">{lang_spotter_name}</font></td>
                                      <
td class="row1" width="70" align="center"><span class="smalltext"><font color="black">{lang_total_rates}</font></span></td>
                                    </
tr>
                                    <
tr>
                                      <
td class="row1">{most_rated_user}</td>
                                    </
tr>
                                    {if 
user_loggedin}
                                    <
tr>
                                      <
td class="row1" align="center" colspan="2"><a href="{url_member_rating}">{lang_member_rating_title}</a></td>
                                    </
tr>
                                    {endif 
user_loggedin}
                                  </
table>
                                </
TD>
                              </
TR>
                            </
TABLE>
                          </
TD>
                        </
TR>
                      </
TABLE>
                    </
TD>
                  </
TR>
                </
table>


6) Open your lang/english/main.php and at the end of ?> add next:

$lang['most_pop_spotter'] = "Most Popular Spotters";
$lang['spotter_name'] = "Spotter name";
$lang['total_rates'] = "Total rates";
$lang['total_photos'] = "Total photos";


7) Upload all files to you site path, and enjoy you new TOPS!!!

Offline wassimo

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: [MOD] - User rating (rate for other profile - FREE)
« Reply #11 on: January 28, 2011, 08:10:24 PM »
great mod really love it ^-^ , but can i  show user rates per profile visible for all,?


suggestion if we repalce numbers of rates with images , from 1 rate to 100 image 1  , and  from 100 rates to 150 other pic shows on profile is it possible ?

& thanks

 

Post your comments here