coppermine-gallery.com/forum

Support => Deutsch (German) => Language Specific Support => cpg1.5.x Deutsch (German) => Topic started by: donvm on June 18, 2010, 12:34:00 PM

Title: Nur eigenes Album bewerten?
Post by: donvm on June 18, 2010, 12:34:00 PM
Hallo,

ich stehe vor dem Problem, dass wir in unserer Gallerie 20 User haben, die jeweils ein eigenes Album haben. Ich verzweifle, weil ich nirgends finde, wie jeder User NUR SEIN EIGENES ALBUM BEWERTEN kann.

Bin sehr dankbar für schnelle Hilfe!
Title: Re: Nur eigenes Album bewerten?
Post by: Αndré on June 18, 2010, 07:17:06 PM
Welchen Sinn hat es, wenn die Benutzer nur ihre eigenen Bilder bewerten können?
Title: Re: Nur eigenes Album bewerten?
Post by: donvm on June 19, 2010, 01:00:39 PM
Sinn ist:

Ein Fotoworkshop für Kinder. Die laufen den ganzen Tag mit einer Kamera rum. Der Dozent stellt alle Bilder online (da die Kameras nur ausgeliehen werden und anschliessend eingesammelt). Jedes Kind wählt seine Favoriten aus (mittels Bewerten) - die besten 2 von jedem Kind kommen in die nächste Runde. Dort stimmt dann eine Jury (die jedes Album bewerten kann) final ab und pro Kind kommt ein Bild dann in eine Ausstellung.

Somit ist in diesem Fall Copper "nur" ein Abstimmungs-Tool.

Gibt es eine Lösung? Bisher, die einzige, die ich sehe, ist jeden User als eigene Gruppe anzulegen. Wäre allerdings doch umständlich, weil dann hätten wir pro User: 1 Useraccount + 1 Album + 1 Gruppe (also 60 Sachen, die man pro Workshop anlegen müsste). Habe die Hoffnung, es gibt noch eine einfachere Lösung.
Bitte um Ideen! Danke!
Title: Re: Nur eigenes Album bewerten?
Post by: Αndré on June 24, 2010, 12:05:17 PM
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.
Title: Re: Nur eigenes Album bewerten?
Post by: donvm on June 24, 2010, 12:12:31 PM
Hi André,

vielen Dank. Frage: mit nur "ihre eigenen Bilder" - meinst Du die die in ihrem Album sind?
Denn die Bilder werden ja von den Dozenten (unter einem anderen Account hochgeladen...)

Diese Funktion muss also an den Album-Namen gekoppelt sein, nicht an den User-Namen.
Passt deine Lösung dafür?
Title: Re: Nur eigenes Album bewerten?
Post by: Αndré on June 24, 2010, 12:41:46 PM
Nein ;)

Ersetze
if (USER_ID != $CURRENT_PIC_DATA['owner_id']) return '';
mit
if (USER_ID != mysql_result(cpg_db_query("SELECT owner FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '{$CURRENT_ALBUM_DATA['aid']}'"), 0)) return '';

Dann können die Personen nur Bilder in den Alben bewerten, die sie selbst erstellt haben. Reicht das als Lösung?
Title: Re: Nur eigenes Album bewerten?
Post by: donvm on June 24, 2010, 04:04:13 PM
Super André! Vielen herzlichen Dank.
Das funktioniert so (zwar noch etwas umständlich, da man sich dauernd neu als User einloggen muss,
und nicht der Admin alle Alben auf einmal anlegen kann, aber wie gesagt - es funktioniert).

Blöde Frage: würde sowas in php funktionieren "if USER_ID = same as ALBUM_NAME"
(dann nennen wir einfach User und das entsprechende Album gleich?!?)

Wenn sowas ginge, wäre es natürlich einfacher; ansonsten ist das Problem auch hiermit "solved"
Herzlichen Dank nochmal.
Title: Re: Nur eigenes Album bewerten?
Post by: Αndré on June 24, 2010, 04:25:35 PM
Ja das würde auch gehen. Soll ich einen Codeschnipsel erstellen, der das Bewerten nur zulässt wenn Albumname und Benutzername gleich sind?
Title: Re: Nur eigenes Album bewerten?
Post by: donvm on June 24, 2010, 04:27:12 PM
König! Ja! Ja! Ja! Bitte, bitte!
(kann ja nicht programmieren)
Title: Re: Nur eigenes Album bewerten?
Post by: Αndré on June 24, 2010, 05:14:21 PM
Bitteschön:
if ($USER_DATA['user_name'] != mysql_result(cpg_db_query("SELECT title FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '{$CURRENT_ALBUM_DATA['aid']}'"), 0)) return '';
Title: Re: Nur eigenes Album bewerten?
Post by: donvm on June 24, 2010, 05:35:36 PM
Herzlichen Dank! Hab nen neuen Helden  ;)

(hätte zu Beginn des Threads nicht gedacht, dass die Lösung doch so einfach sein würde)