Ignore:
Timestamp:
Jan 27, 2011, 8:46:55 PM (13 years ago)
Author:
tiico
Message:

Prepare v2.0.0 for Concours photo plugin :

  • Add exaequo checking for the result (beta)
  • Add EN language
  • Correct "concours not displayed" when no group is selected in admin page. Now, concours is available for all registered user (not depending on the group appartenance)
  • Add option to allow author to vote for their photos (disable check based on username=authorname)
  • Add option to allow user to change the score after a validation
  • Add to guest the possibility to vote for a concours (BETA)
  • Some correction (code and database structure)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ConcoursPhoto/admin/audit.php

    r4428 r8946  
    1717    $user_id = 0;
    1818   
    19 //echo "USER_ID=".$user_id;
     19echo "USER_ID=".$user_id;
    2020   
    2121// Get the concours id if present
     
    2929    $users = array();     // contain {id;username} or each
    3030    $groups = $concours->concours_infos['groups'];
    31     $query = 'SELECT user_id, username FROM ' . USER_GROUP_TABLE
     31    $query = 'SELECT distinct(user_id), username FROM ' . USER_GROUP_TABLE
    3232    .' INNER JOIN ' . USERS_TABLE .' ON id = user_id'
    33     .($groups != NULL ? ' WHERE group_id = '.$groups : '')
     33    .($groups != NULL ? ' WHERE group_id IN ('.$groups.')' : '')
     34//    = '.$groups : '')
    3435    .' ORDER BY username ASC'
    3536    .';';
     
    5556    }
    5657
     58    // Add the guest list (if coucours OK for guest)
     59    $ipguest = $concours->get_guest_list();
     60    if ($concours->concours_infos['guest'])
     61    {
     62        foreach ( $ipguest as $i => $userid ) //on parcours le tableau
     63        {
     64            $template->append('user_list',
     65                array(  'ID' => 'G'.$i,     //$userid['user_id'],
     66                        'NAME' => $userid,
     67                        'SELECTED' => ($user_id == 'G'.$i ? 'selected' : '')));
     68        }
     69    }
    5770   
    5871    // Send concours info to template
     
    7083// Step 3 : Display theses informations
    7184       
    72        
    73         // nb of users who vote for each image (for a selected concours
    74         $query = 'SELECT img_id, COUNT(DISTINCT user_id) AS NBVOTE FROM ' . CONCOURS_DATA_TABLE
    75         .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id )
    76         .' GROUP BY img_id '
    77         .';';
    78                        
    79         $result = pwg_query($query);
    80         $nbvotes = array();
    81         while ($row = mysql_fetch_assoc($result))
    82         {
    83                 $nbvotes[$row['img_id']] = $row['NBVOTE'];
    84         }
     85    // Get the nb of vote for the concours
     86    $nbvotes = $concours->nb_votes_by_img();
     87
    8588
    8689        // Get all the users who have notes for the concours
    87         $query = 'SELECT distinct(user_id), USER.username'
     90        $query = 'SELECT distinct user_id, USER.username'
    8891        .' FROM ' .CONCOURS_DATA_TABLE
    8992        .' INNER JOIN ' . USERS_TABLE.' AS USER on USER.id = user_id'
    9093        .' WHERE id_concours = '.$concours_id
     94        // Dont take the guest informations because
     95    .' AND user_id <> '.$conf['guest_id']
    9196        .' ORDER BY username ASC'
    9297        .';';
     
    95100        $user_list = array();
    96101        while ($row2 = mysql_fetch_assoc($result))
    97                 array_push($user_list, $row2); 
    98 
     102        // Dont take the guest informations because
     103//        if ($row2['user_id'] != $conf['guest_id'])
     104            array_push($user_list, $row2);     
    99105
    100106
     
    185191                $user_note = array();
    186192                $globalnote = 0;
    187                 if ($user_id != 0)      // for user
     193            echo "USER=".$user_id."\n";
     194                if (!is_numeric($user_id) OR $user_id != 0)     // for user
     195                {   
     196            echo "USERNON0=".$user_id."\n";
     197            $pos = strpos($user_id, 'G');
     198            if ($pos === false)
     199            {
     200                $globalnote = $concours->get_img_globalnote_user($row['id'], $concours_id, $user_id);
     201                $user_note = $concours->get_img_note_user($row['id'], $concours_id, $user_id);
     202            }
     203            else
     204            {
     205                echo "G...".substr($user_id, $pos+1)." = ".substr($user_id, $pos+1)."\n";
     206                echo "IPGUEST=".$ipguest[substr($user_id, $pos+1)]."\n";
     207                $globalnote = $concours->get_img_globalnote_user($row['id'], $concours_id, $conf['guest_id'], $ipguest[substr($user_id, $pos+1)]);
     208                $user_note = $concours->get_img_note_user($row['id'], $concours_id, $conf['guest_id'], $ipguest[substr($user_id, $pos+1)]);
     209            }
     210                }
     211                elseif (is_numeric($user_id) AND $user_id == 0) // for user     // global
    188212                {
    189                         $globalnote = $concours->get_img_globalnote_user($row['id'], $concours_id, $user_id);
    190                         $user_note = $concours->get_img_note_user($row['id'], $concours_id, $user_id);
    191                 }
    192                 else    // global
    193                 {
    194                         foreach ($user_list as $userid)
    195                         $globalnote += $concours->get_img_globalnote_user($row['id'], null, $userid['user_id']);
    196                 }
     213            echo "USER00=".$user_id."\n";
     214       
     215                        foreach ($user_list as $i => $userid)
     216               $globalnote += $concours->get_img_globalnote_user($row['id'], null, $userid['user_id']);
     217           
     218                        foreach ($ipguest as $i => $ipguestt)
     219            {
     220                $globalnote += $concours->get_img_globalnote_user($row['id'], null, $conf['guest_id'], $ipguestt);
     221            }
     222        }
    197223
    198224               
     
    233259   
    234260        $rang = 1;
     261    $previousNote = $previousMoy = 0;
     262
    235263        foreach ($concours_img  as $key => $value)
    236264        {
     265
     266        // Check the exaequos
     267        if ($concours->my_config['check_exaequo'])
     268        {
     269            if ( ($concours->concours_infos['method'] == 1      // total
     270                   AND ($concours_img[$key]['note'] == $previousNote))
     271                 OR  ($concours->concours_infos['method'] == 2  // moyenne
     272                      AND ($concours_img[$key]['moyenne'] == $previousMoy)))
     273            {
     274                $rang --;
     275               
     276            }
     277        }
     278//        echo "RANG=".$rang."\n";
    237279           $concours_img[$key]['rang'] = $rang;
    238                 $rang++;
    239280
    240281                $template->append( 'concours_note', array(
     
    251292
    252293                        ));
     294        $rang++;
     295
     296        $previousNote = $concours_img[$key]['note'];
     297        $previousMoy = $concours_img[$key]['moyenne'];
    253298        }
    254299
Note: See TracChangeset for help on using the changeset viewer.