Füge folgende Funktion in die Datei themes/dein_theme/theme.php ein:
function theme_html_rating_box()
{
global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $THEME_DIR, $USER_DATA, $USER, $LINEBREAK;
global $template_image_rating, $template_image_rating_oldstyle, $lang_rate_pic;
if (!(USER_CAN_RATE_PICTURES && $CURRENT_ALBUM_DATA['votes'] == 'YES')) {
return '';
} else {
//if (USER_ID != mysql_result(cpg_db_query("SELECT owner FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '{$CURRENT_ALBUM_DATA['aid']}'"), 0)) return '';
if (USER_ID != $CURRENT_PIC_DATA['owner_id']) return '';
//check if the users already voted or if this user is the owner
$user_md5_id = USER_ID ? md5(USER_ID) : $USER['ID'];
$result = cpg_db_query("SELECT pic_id FROM {$CONFIG['TABLE_VOTES']} WHERE pic_id={$CURRENT_PIC_DATA['pid']} AND user_md5_id='$user_md5_id'");
$user_can_vote = 'false';
if ($CURRENT_PIC_DATA['owner_id'] == $USER_DATA['user_id'] && $USER_DATA['user_id'] != 0 && ($CONFIG['rate_own_files'] == 0 || $CONFIG['rate_own_files'] == 2 && !USER_IS_ADMIN)) {
// user is owner
$rate_title = $lang_rate_pic['forbidden'];
} elseif (!mysql_num_rows($result)) {
// user hasn't voted yet, show voting things
$rate_title = $lang_rate_pic['rate_this_pic'];
$user_can_vote = 'true';
} else {
//user has voted
$rate_title = $lang_rate_pic['already_voted'];
}
$rating_stars_amount = ($CONFIG['old_style_rating']) ? 5 : $CONFIG['rating_stars_amount'];
$votes = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_rate_pic['rating'], round(($CURRENT_PIC_DATA['pic_rating'] / 2000) / (5/$rating_stars_amount), 1), $rating_stars_amount, $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
$pid = $CURRENT_PIC_DATA['pid'];
if (defined('THEME_HAS_RATING_GRAPHICS')) {
$location= $THEME_DIR;
} else {
$location= '';
}
$superCage = Inspekt::makeSuperCage();
$params = array(
'{TITLE}' => $rate_title,
'{VOTES}' => $votes,
'{LOCATION}' => $location,
'{WIDTH}' => $CONFIG['picture_table_width'],
);
if ($CONFIG['old_style_rating']) {
// use old-style rating
$start_td = '<td class="tableb" width="17%" align="center">';
$end_td = '</td>';
$empty_star = '<img style="cursor:pointer" id="' . $pid . '_0" title="0" src="' . $location . 'images/rate_empty.png" alt="' . $lang_rate_pic['rubbish'] . '" onclick="rate(this)" />';
$rating_images = $start_td . $empty_star . $empty_star . $empty_star . $empty_star . $empty_star . $end_td . $LINEBREAK;
$empty_star = '<img style="cursor:pointer" id="' . $pid . '_1" title="1" src="' . $location . 'images/rate_empty.png" alt="' . $lang_rate_pic['poor'] . '" onclick="rate(this)" />';
$full_star = '<img style="cursor:pointer" id="' . $pid . '_1" title="1" src="' . $location . 'images/rate_full.png" alt="' . $lang_rate_pic['poor'] . '" onclick="rate(this)" />';
$rating_images .= $start_td . $full_star . $empty_star . $empty_star . $empty_star . $empty_star . $end_td . $LINEBREAK;
$empty_star = '<img style="cursor:pointer" id="' . $pid . '_2" title="2" src="' . $location . 'images/rate_empty.png" alt="' . $lang_rate_pic['fair'] . '" onclick="rate(this)" />';
$full_star = '<img style="cursor:pointer" id="' . $pid . '_2" title="2" src="' . $location . 'images/rate_full.png" alt="' . $lang_rate_pic['fair'] . '" onclick="rate(this)" />';
$rating_images .= $start_td . $full_star . $full_star . $empty_star . $empty_star . $empty_star . $end_td . $LINEBREAK;
$empty_star = '<img style="cursor:pointer" id="' . $pid . '_3" title="3" src="' . $location . 'images/rate_empty.png" alt="' . $lang_rate_pic['good'] . '" onclick="rate(this)" />';
$full_star = '<img style="cursor:pointer" id="' . $pid . '_3" title="3" src="' . $location . 'images/rate_full.png" alt="' . $lang_rate_pic['good'] . '" onclick="rate(this)" />';
$rating_images .= $start_td . $full_star . $full_star . $full_star . $empty_star . $empty_star . $end_td . $LINEBREAK;
$empty_star = '<img style="cursor:pointer" id="' . $pid . '_4" title="4" src="' . $location . 'images/rate_empty.png" alt="' . $lang_rate_pic['excellent'] . '" onclick="rate(this)" />';
$full_star = '<img style="cursor:pointer" id="' . $pid . '_4" title="4" src="' . $location . 'images/rate_full.png" alt="' . $lang_rate_pic['excellent'] . '" onclick="rate(this)" />';
$rating_images .= $start_td . $full_star . $full_star . $full_star . $full_star . $empty_star . $end_td . $LINEBREAK;
$full_star = '<img style="cursor:pointer" id="' . $pid . '_5" title="5" src="' . $location . 'images/rate_full.png" alt="' . $lang_rate_pic['great'] . '" onclick="rate(this)" />';
$rating_images .= $start_td . $full_star . $full_star . $full_star . $full_star . $full_star . $end_td . $LINEBREAK;
set_js_var('stars_amount', 'fallback');
set_js_var('lang_rate_pic', $rate_title);
$params['{RATING_IMAGES}'] = $rating_images;
$template_rating = $template_image_rating_oldstyle;
} else {
//use new rating
set_js_var('stars_amount', $rating_stars_amount);
set_js_var('lang_rate_pic', $lang_rate_pic['rollover_to_rate']);
$params['{JS_WARNING}'] = $lang_rate_pic['js_warning'];
$template_rating = $template_image_rating;
}
set_js_var('rating', round(($CURRENT_PIC_DATA['pic_rating'] / 2000) / (5/$rating_stars_amount), 0));
set_js_var('theme_dir', $location);
set_js_var('can_vote', $user_can_vote);
list($timestamp, $form_token) = getFormToken();
set_js_var('form_token', $form_token);
set_js_var('timestamp', $timestamp);
return template_eval($template_rating, $params);
}
}
Damit können Personen nur ihre eigenen Dateien bewerten.