Changeset 32457


Ignore:
Timestamp:
Feb 12, 2021, 7:00:27 PM (3 years ago)
Author:
tiico
Message:

Version 11.0.1 ConcoursPhoto (piwigo 11 compatible + some corrections/news)

Location:
extensions/ConcoursPhoto
Files:
44 added
6 deleted
30 edited

Legend:

Unmodified
Added
Removed
  • extensions/ConcoursPhoto/CHANGELOG

    r9370 r32457  
    11TODO for next versions :
     2- Clean and optimize code/requests + display (use CSS...)
     3- Add another "star notation" (https://codepen.io/tobiasdev/pen/XgegoO)
     4- Add compatibility with Smartpocket theme
    25
     6______________
     7
     8Version 11.0.x
     9-------------
     1011.0.1          - Minor corrections
     11                        - Change rule for author check (custom choice between "author"/"added by"/both/none)
     12                        - param to disable meta display on photo when concours is prepared or active
     13                        - Add language (LV+SK)
     14                        - clean code (suppress Debug)
     1511.0.0          - Version for Piwigo 11.x
     16
     17______________
     18
     19Version 2.9.x
     20-------------
     212.9.1           - Add RU translation (thanks to Alexander)
     22                        - Add "stars style" to vote instead of "text style" (with param to choose)
     23                        - Adjust admin page
     24                        - Add new page to vote for all images (with parameter to activate)
     25                        - Clean code
     26                        - Allow method change when concours was closed if result not already present
     27                        - Allow admin to access to contest (param)
     28                        - Add overlay message when user already have vote (and param "do not allow user to change score" is active)
     29
     302.9.0g          - Add parameters into admin page for the deadline information
     31                        - Add timer when the contest is prepared but not started
     32                        - Add parameter to allow possibility to mask photos before the contest start
     33
     342.9.0f          - Add deadline information (with css/js)
     35
     362.9.0e          - Corrections (pb guest)
     37                        - add RU language
     38
     392.9.0d          - Correct config file for PWG Stuffs
     40
     412.9.0c          - Add missing language (FR/EN)
     42                        - Correct/complete the help page
     43                        - Correct error when reinit score (concours.class.php)
     44                        - Correct bad link for criteria in admin page
     45                        - Correct bad test when user have not already vote and option "disable second vote" actived
     46                        - Adjust "Author=user" control to display note and concours
     47
     482.9.0b          - Add PWG Stuffs module (thnaks to "contest" plugin from Mistic)
     49                        - Correct maintain.inc.php (old sql function not allowed in php7)
     50
     512.9.0   - Correction display debug info "user id = " on image page even id debug=false
     52                - Compatible with Piwigo 2.9
     53                - Correct concours type not saved in second page (detailled criterias)
     54                - Add method "moderation1" & "moderation2" for the result of concours (update DB needed)
     55                - some little corrections (guest vote, templates...)
    356______________
    457
  • extensions/ConcoursPhoto/admin/add_concours.php

    r8965 r32457  
    1212//              List informations about concours id and modify it to store to piwifo_concours table
    1313//              Go to Step 2 (if needed by client choice ==> 2 buttons) with action=modify_crit
    14 //      Ste 2 : action=modify_crit &  concours_id=XX
     14//      Step 2 : action=modify_crit &  concours_id=XX
    1515//              List informations about criterias and modify them
    1616//              Warning : different cases are possible :
     
    3030load_language('plugin.lang', CONCOURS_PATH);
    3131
    32 $method_list = array(l10n('concours_method1'), l10n ('concours_method2') );
     32$method_list = array(l10n('concours_method1'), l10n ('concours_method2'), l10n ('concours_method3'), l10n ('concours_method4') );
    3333
    3434       
     
    3939  $action = $_GET['action'];
    4040
    41 
    42 
    43  
     41/*
     42echo "action : ".$action."\n";
     43sleep(5);
     44*/
     45 
    4446// Month initialization for date selection...
    4547$month_list = $lang['month'];
     
    6365        $query = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
    6466                                FROM ' . CONCOURS_TABLE . ' ;';
    65         list($next_element_id) = mysql_fetch_array(pwg_query($query));
     67        list($next_element_id) = pwg_db_fetch_array(pwg_query($query));
    6668        $concours_id = $next_element_id;
    6769}
     
    7577  {
    7678    case "1" :
    77     array_push($page['errors'],  sprintf( l10n('concours_end_date_change_to') ,$concours->concours_infos['end_date'] ));
     79    array_push($page['errors'],   l10n('concours_end_date_change_to' ,$concours->concours_infos['end_date'] ));
    7880    break;
    7981       
     
    9193{
    9294
     95// Update method if changed
     96        if (!isset($concours->concours_infos['method']) OR (isset($_POST['concours_method']) AND $concours->concours_infos['method'] != $_POST['concours_method']))
     97        {
     98                $concours->concours_infos['method'] = $_POST['concours_method'];
     99                $concours->update_concoursfield("method", $concours_id);
     100        }
    93101
    94102        if ($action == "modify_crit")
    95103    {
    96104        $concours->infos = 0;
    97         redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php&concours=' . $concours_id.(isset($concours->infos) ? '&infos=' .$concours->infos: ''));
    98 //              redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php');
     105//        redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php&concours=' . $concours_id.(isset($concours->infos) ? '&infos=' .$concours->infos: ''));
     106        redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php&concours=' . $concours_id.(isset($concours->infos) ? '&infos=' .$concours->infos: ''));
    99107    }
    100108
    101109        if ($action == "edit")
    102110        {
    103                 if ($concours->is_closed($concours_id) AND ! $concours->is_result_present($concours_id))
    104                         $concours->update_concoursfield("method", $concours_id);
    105        
    106                 redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php');
     111       
     112                redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php');
    107113        }
    108114
    109     $concours->concours_infos['method'] = $_POST['concours_method'];
    110115
    111116// Step 1 : action = modify
     
    128133        $concours->concours_infos['descr'] = $_POST['concours_descr'];
    129134
    130 //      $concours->concours_infos['begin_date'] = $_POST['concours_begin_date'];
    131 //      $concours->concours_infos['end_date'] = AjoutJours($concours->concours_infos['begin_date'],$_POST['concours_end_date'] );
    132135
    133136        $concours->concours_infos['begin_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d",$_POST['start_year'], $_POST['start_month'], $_POST['start_day'], $_POST['start_hour'], $_POST['start_min'], 0);
     
    148151        $tBeginDate = explodeDateArray($concours->concours_infos['begin_date']);
    149152        $tEndDate = explodeDateArray($concours->concours_infos['end_date']);
    150 //    echo "Hour=".intval($tBeginDate[3])." / ".intval($tEndDate[3]);
    151 //    echo "Min=".intval($tBeginDate[4])." / ".intval($tEndDate[4]);
    152153        if ( (intval(@$tEndDate[3]) < intval(@$tBeginDate[3]))    // End hour is lower than begin hour
    153154            OR ( (intval(@$tBeginDate[3]) == intval(@$tEndDate[3]))    // End hour is equal to begin hour
     
    168169        $concours->concours_infos['groups'] = (!empty($_POST['groups']) ? '"' . implode(',', $_POST['groups']) . '"' : 'NULL');
    169170        $concours->concours_infos['guest'] = isset($_POST['guest']);
     171        $concours->concours_infos['admin'] = isset($_POST['admin']);
     172       
    170173        $concours->concours_infos['category'] = $_POST['cat_selection'];
    171174       
     
    175178        {
    176179                case "edit" :
    177                         redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php');
     180                        redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php');
    178181                        break;
    179182                case "new" :
     
    181184                        $concours->save_concours();
    182185                        $concours->get_default_criterias();
    183 if ($concours->debug)   sleep(5);
    184186                        // Redirect to admin
    185                         redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php&amp;tab=add_concours&amp;action=modify_crit&amp;concours=' . $concours_id.(isset($concours->infos) ? '&amp;infos=' .$concours->infos: ''));
     187                        redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php&amp;tab=add_concours&amp;action=modify_crit&amp;concours=' . $concours_id.(isset($concours->infos) ? '&amp;infos=' .$concours->infos: ''));
    186188
    187189                        break;
    188190                case "modify" :
    189191            $concours->update_concours();
    190                         redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php&amp;tab=add_concours&amp;action=modify_crit&amp;concours=' . $concours_id.(isset($concours->infos) ? '&amp;infos=' .$concours->infos: ''));
     192                        redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php&amp;tab=add_concours&amp;action=modify_crit&amp;concours=' . $concours_id.(isset($concours->infos) ? '&amp;infos=' .$concours->infos: ''));
    191193
    192194                        break;
    193195                case "modify_crit" :
    194 //        echo "ICI";sleep(5);
    195196            $concours->infos = 0;
    196                         redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php&amp;concours=' . $concours_id.(isset($concours->infos) ? '&amp;infos=' .$concours->infos: ''));
     197                        redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php&amp;concours=' . $concours_id.(isset($concours->infos) ? '&amp;infos=' .$concours->infos: ''));
    197198                        break;
    198199        }
     
    207208// Download the file
    208209        case "file" :
    209                 // TODO generate csv file
     210                // generate csv file
    210211                $file = $concours->generate_csv();
    211212                // Get the existing filename or the new one if doesnt exist
    212213                $filename = $concours->save_file($file);
    213214
    214                 redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php');
     215                redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php');
    215216                break;
    216217
     
    227228                $filename = $concours->save_file($file);
    228229               
    229                 redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php');
     230                redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php');
    230231                break;
    231232
     
    233234        // Suppress concours and all parameters
    234235                $concours->delete_concours();
    235                 redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php');
     236                redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php');
    236237                break;
    237238               
     
    241242                $template->assign( 'CONCOURS', array(
    242243                                'ID'    => $concours_id,
    243 //                              'BEGIN_DATE'    => date("Y-m-d H:m:s"),
    244 //                              'END_DATE'      => 15
    245244                                ));
    246245
     
    270269        case "modify" :
    271270
    272 /*              $info_concours['groups']
    273                                 `create_date` datetime NOT NULL,
    274                                 `name` text NOT NULL,
    275                                 `descr` varchar(255) default NULL,
    276                                 `begin_date` datetime NOT NULL,
    277                                 `end_date` datetime NOT NULL,
    278                                 `category` smallint(5) default NULL,
    279                                 `groups` varchar(255) default NULL,
    280 */             
    281271                // Format group list
    282272                $concours->concours_infos['groups'] = explode(',', $concours->concours_infos['groups']);
     
    285275        $tBeginDate = explodeDateArray($concours->concours_infos['begin_date']);
    286276        $tEndDate = explodeDateArray($concours->concours_infos['end_date']);
     277
     278
     279
    287280               
    288281                $template->assign( 'CONCOURS', array(
     
    291284                                'DESCR' => $concours->concours_infos['descr'],
    292285                'GUEST' => ($concours->concours_infos['guest'] ? 'checked="checked"' : ''),
    293 //                              'BEGIN_DATE'    => $concours->concours_infos['begin_date'],
    294 //                              'END_DATE'      => NbJours($concours->concours_infos['begin_date'], $concours->concours_infos['end_date'])
     286                'ADMIN' => ($concours->concours_infos['admin'] ? 'checked="checked"' : ''),                             
    295287                                ));
    296288        $template->assign(
     
    298290
    299291            'START_DAY_SELECTED' => @$tBeginDate[2],
    300             'START_MONTH_SELECTED' => @$tBeginDate[1],
     292            'START_MONTH_SELECTED' => intval($tBeginDate[1]),
    301293            'START_YEAR' => @$tBeginDate[0],
    302294            'START_HOUR' => @$tBeginDate[3],
     
    304296           
    305297            'END_DAY_SELECTED' => @$tEndDate[2],
    306             'END_MONTH_SELECTED' => @$tEndDate[1],
     298            'END_MONTH_SELECTED' => intval($tEndDate[1]),
    307299            'END_YEAR'   => @$tEndDate[0],
    308300            'END_HOUR' => @$tEndDate[3],
     
    324316                                'DESCR' => $concours->concours_infos['descr'],
    325317                'GUEST' => ($concours->concours_infos['guest'] ? 'checked="checked"' : ''),
    326 //                              'BEGIN_DATE'    => $concours->concours_infos['begin_date'],
    327 //                              'END_DATE'      => NbJours($concours->concours_infos['begin_date'], $concours->concours_infos['end_date'])
     318                'ADMIN' => ($concours->concours_infos['admin'] ? 'checked="checked"' : ''),
    328319                                ));
    329320        $template->assign(
     
    361352                                                'pond'  => $criteria['ponderation'],                    // ponderation
    362353                                                'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;id_concours=' . $concours->concours_id.'&amp;action=modify&amp;id='.$criteria['id'],
    363                                                 'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;id_concours=' . $concours->concours_id.'&amp;action=delete&amp;id='.$criteria['id'] : '',
     354                                                'U_DELETE' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;id_concours=' . $concours->concours_id.'&amp;action=delete&amp;id='.$criteria['id'],
    364355                                                'U_ADD' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;id_concours=' . $concours->concours_id.'&amp;action=add&amp;upcriteria='.$criteria['criteria_id'],
    365356                                        ));
     
    389380                                                        'pond'  => $subcriteria['ponderation'],                 // ponderation
    390381                                                        'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;id_concours=' . $concours->concours_id.'&amp;action=modify&amp;id='.$subcriteria['id'],
    391                                                         'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;id_concours=' . $concours->concours_id.'&amp;action=delete&amp;id='.$subcriteria['id'] : '',
    392                                                 ));
    393                                        
     382                                                        'U_DELETE' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;id_concours=' . $concours->concours_id.'&amp;action=delete&amp;id='.$subcriteria['id'] ,
     383                                                ));                                     
    394384                                }
    395385                        }
     
    441431if (!empty($result))
    442432{
    443         while ($row = mysql_fetch_assoc($result))
     433        while ($row = pwg_db_fetch_array($result))
    444434                array_push($categories, $row);
    445435}
  • extensions/ConcoursPhoto/admin/audit.php

    r9370 r32457  
    1111global $template;
    1212
     13$user_vote = array();
    1314
    1415if (isset($_POST['user_list']))
     
    2627        $concours = new Concours($concours_id);
    2728
     29        // get user that already vote for the concours
     30        $user_vote = $concours->get_user_list();
     31       
    2832    // Get group authorized to participate
    2933    $users = array();     // contain {id;username} or each
    3034    $groups = $concours->concours_infos['groups'];
    31     $query = 'SELECT distinct(user_id), username FROM ' . USER_GROUP_TABLE
    32     .' INNER JOIN ' . USERS_TABLE .' ON id = user_id'
     35
     36    $query = 'SELECT distinct(id) AS user_id, username FROM '. USERS_TABLE .' USER '
     37    .($groups != NULL ?' INNER JOIN ' . USER_GROUP_TABLE .' ON id = user_id' : '')
    3338    .($groups != NULL ? ' WHERE group_id IN ('.$groups.')' : '')
    34 //    = '.$groups : '')
     39        .($user_vote != NULL ? ($groups != NULL ? 'AND ' : 'WHERE ').'id IN ('.implode(',', $user_vote).')' : '')
    3540    .' ORDER BY username ASC'
    3641    .';';
    37 //              echo $query."\n";
     42
    3843    $result = pwg_query($query);
    39     while ($row = mysql_fetch_assoc($result))
    40     {
    41       array_push($users, $row);
     44    while ($row = pwg_db_fetch_array($result))
     45    {           
     46                        array_push($users, $row);
    4247    }       
    4348
     49       
    4450    // Add user list
    4551    $template->append('user_list',
     
    7682            'BEGIN_DATE'        => $concours->concours_infos['begin_date'],
    7783            'END_DATE'  => $concours->concours_infos['end_date'],
    78             'METHOD'    => l10n("concours_method".$concours->concours_infos['method'])
     84            'METHOD'    => l10n("concours_method".$concours->concours_infos['method']),
     85                        'METHODNB'      => $concours->concours_infos['method']
    7986            ));
    8087
     
    99106        // For each user
    100107        $user_list = array();
    101         while ($row2 = mysql_fetch_assoc($result))
    102         // Dont take the guest informations because
    103 //        if ($row2['user_id'] != $conf['guest_id'])
     108        while ($row2 = pwg_db_fetch_array($result))
    104109            array_push($user_list, $row2);     
    105110
     
    142147        $category = $concours->concours_infos['category'];
    143148
    144         $query = 'SELECT DISTINCT(img.id), img.name, img.file, img.path, img.tn_ext, img.author ,
     149        $query = 'SELECT DISTINCT(img.id), img.name, img.file, img.path, img.author ,
    145150                          ic.category_id, cat.name AS catname'  //, conc.note'
    146151                        .' FROM ' . IMAGES_TABLE.' AS img'
    147152                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
    148153                        .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'
    149 //                      .' INNER JOIN '.CONCOURS_RESULT_TABLE.' AS conc ON conc.img_id = img.id'
    150154                        .' WHERE ic.category_id = '.$concours->concours_infos['category']
    151 //                      .' ORDER by note DESC
    152155                        .';';
    153156
    154157        $result = pwg_query($query);
    155 //      echo $query;
    156158        $concours_img = array();
    157159
    158160        // Recover all pictures and informations (global note
    159         while ($row = mysql_fetch_assoc($result))
     161        while ($row = pwg_db_fetch_array($result))
    160162        {
    161163                // link on picture.php page
     
    191193                $user_note = array();
    192194                $globalnote = 0;
    193 //                          echo "USER=".$user_id."\n";
    194195                if (!is_numeric($user_id) OR $user_id != 0)     // for user
    195196                {   
    196 //                          echo "USERNON0=".$user_id."\n";
    197197            $pos = strpos($user_id, 'G');
     198       
    198199            if ($pos === false)
    199200            {
    200201                $globalnote = $concours->get_img_globalnote_user($row['id'], $concours_id, $user_id);
     202                                if ($globalnote < 0) $globalnote = 0;
    201203                $user_note = $concours->get_img_note_user($row['id'], $concours_id, $user_id);
    202204            }
    203205            else
    204206            {
    205 //                              echo "G...".substr($user_id, $pos+1)." = ".substr($user_id, $pos+1)."\n";
    206 //                              echo "IPGUEST=".$ipguest[substr($user_id, $pos+1)]."\n";
    207207                $globalnote = $concours->get_img_globalnote_user($row['id'], $concours_id, $conf['guest_id'], $ipguest[substr($user_id, $pos+1)]);
     208                                if ($globalnote < 0) $globalnote = 0;   
    208209                $user_note = $concours->get_img_note_user($row['id'], $concours_id, $conf['guest_id'], $ipguest[substr($user_id, $pos+1)]);
    209210            }
    210211                }
    211212                elseif (is_numeric($user_id) AND $user_id == 0) // for user     // global
    212                 {
    213 //                          echo "USER00=".$user_id."\n";
    214        
     213                {       
    215214                        foreach ($user_list as $i => $userid)
    216                $globalnote += $concours->get_img_globalnote_user($row['id'], null, $userid['user_id']);
    217            
     215                        {       
     216                                $usernote = $concours->get_img_globalnote_user($row['id'], null, $userid['user_id']);
     217                $globalnote += ($usernote >= 0 ? $usernote : 0) ;
     218            }
    218219                        foreach ($ipguest as $i => $ipguestt)
    219220            {
    220                 $globalnote += $concours->get_img_globalnote_user($row['id'], null, $conf['guest_id'], $ipguestt);
    221             }
     221                                $usernote = $concours->get_img_globalnote_user($row['id'], null, $conf['guest_id'], $ipguestt);
     222                $globalnote += ($usernote >= 0 ? $usernote : 0) ;
     223
     224                        }
    222225        }
    223226
     227
     228
     229        // replace get_thumbnail_url (>piwigo 2.5)
     230    // DerivativeImage::thumb_url($row);
    224231               
    225232                $concours_img[$row['id']]  = array(
     
    229236                                'file'  => $row['file'],
    230237                                'rang'  => 0,
    231                                 'thumb' => get_thumbnail_url($row),
     238                                'thumb' => DerivativeImage::thumb_url($row),
    232239                                'url'   => $url,
    233                                 'note'  => $globalnote,
    234                 'moyenne'       => (isset($nbvotes[$row['id']]) && $nbvotes[$row['id']] !=0  ? $globalnote/(int)$nbvotes[$row['id']] : 0),
     240                                'note'  => ($globalnote < 0 ? "N/A" : $globalnote) ,
     241                'moyenne'       => (isset($nbvotes[$row['id']]) && $nbvotes[$row['id']] >=0  ? round ($globalnote/(int)$nbvotes[$row['id']], 2) : "N/A"),
    235242                                'nbvotant' => isset($nbvotes[$row['id']]) ? $nbvotes[$row['id']] : 0
    236243                                );
    237244
    238245        }
    239         /*
    240         foreach ($concours_img  as $key => $value)
    241         {
    242                 echo
    243                                 'img_id => '.$concours_img[$key]['img_id']
    244                                 .'author => '.$concours_img[$key]['author']
    245                                 .'name  => '.$concours_img[$key]['name']
    246                                 .'file  => '.$concours_img[$key]['file']
    247                                 .'rang  => '.$concours_img[$key]['rang']
    248                                 .'thumb => '.$concours_img[$key]['thumb']
    249                                 .'url   => '.$concours_img[$key]['url']
    250                                 .'note  => '.$concours_img[$key]['note'];
    251         }
    252         */
    253 
    254         // Ordre image by "note" or "moyenne"
     246
     247        // Order image by "note" or "moyenne"
    255248    if ($concours->concours_infos['method'] == 1) // sum method
    256249        $concours_img = array_sort($concours_img, 'note', false);
    257     elseif ($concours->concours_infos['method'] == 2) // moy method
     250    elseif ($concours->concours_infos['method'] > 1) // moy method (even for moderation, moderation are only calculated on final)
    258251        $concours_img = array_sort($concours_img, 'moyenne', false);
    259252   
     
    261254    $previousNote = $previousMoy = 0;
    262255
    263         foreach ($concours_img  as $key => $value)
     256        if ($concours_img != null)
    264257        {
    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";
    279            $concours_img[$key]['rang'] = $rang;
    280 
    281                 $template->append( 'concours_note', array(
    282                                 'img_id' => $concours_img[$key]['img_id'],
    283                                 'author' => $concours_img[$key]['author'],
    284                                 'name'  => $concours_img[$key]['name'],
    285                                 'file'  => $concours_img[$key]['file'],
    286                                 'rang'  => $concours_img[$key]['rang'],
    287                                 'thumb' => $concours_img[$key]['thumb'],
    288                                 'url'   => $concours_img[$key]['url'],
    289                                 'note'  => $concours_img[$key]['note'],
    290                 'moyenne'       => $concours_img[$key]['moyenne'],
    291                                 'nbvotant' => $concours_img[$key]['nbvotant']
    292 
    293                         ));
    294         $rang++;
    295 
    296         $previousNote = $concours_img[$key]['note'];
    297         $previousMoy = $concours_img[$key]['moyenne'];
     258                foreach ($concours_img  as $key => $value)
     259                {
     260
     261                        // Check the exaequos
     262                        if ($concours->my_config['check_exaequo'])
     263                        {
     264                                if ( ($concours->concours_infos['method'] == 1  // total
     265                                           AND ($concours_img[$key]['note'] == $previousNote))
     266                                         OR  ($concours->concours_infos['method'] > 1   // moyenne (and moderation)
     267                                                  AND ($concours_img[$key]['moyenne'] == $previousMoy)))
     268                                {
     269                                        $rang --;
     270                                       
     271                                }
     272                        }
     273                   $concours_img[$key]['rang'] = $rang;
     274
     275                        $template->append( 'concours_note', array(
     276                                        'img_id' => $concours_img[$key]['img_id'],
     277                                        'author' => $concours_img[$key]['author'],
     278                                        'name'  => $concours_img[$key]['name'],
     279                                        'file'  => $concours_img[$key]['file'],
     280                                        'rang'  => $concours_img[$key]['rang'],
     281                                        'thumb' => $concours_img[$key]['thumb'],
     282                                        'url'   => $concours_img[$key]['url'],
     283                                        'note'  => ($concours_img[$key]['note'] < 0 ? "N/A" : $concours_img[$key]['note']),
     284                                        'moyenne'       => ($concours_img[$key]['moyenne'] < 0 ? "N/A" : round($concours_img[$key]['moyenne'], 2)),
     285                                        'nbvotant' => $concours_img[$key]['nbvotant']
     286
     287                                ));
     288                        $rang++;
     289
     290                        $previousNote = ($concours_img[$key]['note'] < 0 ? $previousNote : $concours_img[$key]['note']);
     291                        $previousMoy = ($concours_img[$key]['moyenne'] < 0 ? $previousMoy : $concours_img[$key]['moyenne']);
     292                }
    298293        }
    299 
    300294}
    301295
     
    315309function array_sort($array, $key, $asc=true)
    316310{
    317         foreach ($array as $i => $o)
     311        if ($array != null)
    318312        {
    319            $sort_values[$i] = $array[$i][$key];
    320 
     313                foreach ($array as $i => $o)
     314                {
     315                   $sort_values[$i] = $array[$i][$key];
     316
     317                }
     318                if ($asc)
     319                        asort  ($sort_values);
     320                else
     321                        arsort ($sort_values);
     322                reset ($sort_values);
     323
     324
     325                while (list ($arr_key, $arr_val) = each ($sort_values))
     326                {
     327                         $sorted_arr[] = $array[$arr_key];
     328                }
     329
     330                unset($array);
     331                return $sorted_arr;
    321332        }
    322         if ($asc)
    323                 asort  ($sort_values);
    324         else
    325                 arsort ($sort_values);
    326         reset ($sort_values);
    327 
    328 
    329         while (list ($arr_key, $arr_val) = each ($sort_values))
    330         {
    331                  $sorted_arr[] = $array[$arr_key];
    332         }
    333 
    334         unset($array);
    335         return $sorted_arr;
     333        return null;
    336334}
    337335
  • extensions/ConcoursPhoto/admin/config.php

    r8946 r32457  
    5454                                'pond'  => $criteria['ponderation'],                    // ponderation
    5555                                'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;concours_id=' . $defaultconcours->concours_id.'&amp;action=modify&amp;id='.$criteria['id'],
    56                                 'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;concours_id=' . $defaultconcours->concours_id.'&amp;action=delete&amp;id='.$criteria['id'] : '',
     56                                'U_DELETE' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;concours_id=' . $defaultconcours->concours_id.'&amp;action=delete&amp;id='.$criteria['id'] ,
    5757                                'U_ADD' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;concours_id=' . $defaultconcours->concours_id.'&amp;action=add&amp;upcriteria='.$criteria['criteria_id'],
    5858                        ));
     
    8282                                        'pond'  => $subcriteria['ponderation'],                 // ponderation
    8383                                        'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;concours_id=' . $defaultconcours->concours_id.'&amp;action=modify&amp;id='.$subcriteria['id'],
    84                                         'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;concours_id=' . $defaultconcours->concours_id.'&amp;action=delete&amp;id='.$subcriteria['id'] : '',
     84                                        'U_DELETE' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fcriteria.php&amp;concours_id=' . $defaultconcours->concours_id.'&amp;action=delete&amp;id='.$subcriteria['id'] ,
    8585                                ));
    8686                       
  • extensions/ConcoursPhoto/admin/criteria.php

    r8946 r32457  
    4242
    4343        if ($id_concours == 0)
    44                 redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php&amp;tab=config');
     44                redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php&amp;tab=config');
    4545        else
    46                 redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php&amp;tab=add_concours&amp;action=modify_crit&amp;concours=' . $id_concours);
     46                redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php&amp;tab=add_concours&amp;action=modify_crit&amp;concours=' . $id_concours);
    4747}
    4848
     
    6060
    6161                        if ($id_concours == 0)
    62                                 redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php&amp;tab=config');
     62                                redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php&amp;tab=config');
    6363                        else
    64                                 redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin%2Fadmin.php&amp;tab=add_concours&amp;action=modify_crit&amp;concours=' . $id_concours);
     64                                redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin&section=' . CONCOURS_DIR . '%2Fadmin.php&amp;tab=add_concours&amp;action=modify_crit&amp;concours=' . $id_concours);
    6565                       
    6666                }
     
    9393                $query = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
    9494                                        FROM ' . CONCOURS_DETAIL_TABLE . ' ;';
    95                 list($next_element_id) = mysql_fetch_array(pwg_query($query));
     95                list($next_element_id) = pwg_db_fetch_array(pwg_query($query));
    9696                $query = 'SELECT IF(MAX(criteria_id)+1 IS NULL, 1, MAX(criteria_id)+1) AS next_criteria_id
    9797                                        FROM ' . CONCOURS_DETAIL_TABLE . '
    9898                                  WHERE id_concours = '.$concours->concours_id  . ' ;';
    99                 list($next_criteria_id) = mysql_fetch_array(pwg_query($query));
     99                list($next_criteria_id) = pwg_db_fetch_array(pwg_query($query));
    100100
    101101                $template->assign( array(
  • extensions/ConcoursPhoto/admin/functions.inc.php

    r8946 r32457  
    4747        $result = pwg_query($query);
    4848        if ($result)
    49                 return mysql_fetch_assoc($result);
     49                return pwg_db_fetch_assoc($result);
    5050        else
    5151                return false;
     
    6464        $result = pwg_query($query);
    6565        // For each images
    66         if (mysql_fetch_assoc($result))
     66        if (pwg_db_fetch_assoc($result))
     67
    6768                return true;
    6869        else
     
    8081        $result = pwg_query($query);
    8182        // For each images
    82         if ($row = mysql_fetch_assoc($result))
     83        if ($row = pwg_db_fetch_assoc($result))
    8384                return $row['file_name'];
    8485        else
    8586                return false;
    8687
     88}
     89
     90function get_nb_concours($type = null)
     91{
     92        switch ($type)
     93        {
     94                case 'prepared':
     95                        return get_nb_prepared_concours();
     96                        break;
     97                case 'active':
     98                        return get_nb_active_concours();
     99                        break;
     100                case 'closed':
     101                        return get_nb_closed_concours();
     102                        break;
     103                case 'closed-noresult':
     104                {
     105                        $query = '
     106                                SELECT count(distinct id) as nb_concours
     107                                FROM ' . CONCOURS_TABLE
     108                                .' WHERE id>0'  // Do not take Concours 0 (default)
     109                                .' AND id NOT IN (SELECT id_concours FROM ' .CONCOURS_RESULT_TABLE.')'
     110                                .';';
     111
     112                        $result = pwg_query($query);
     113                        if ($result)
     114                        {
     115                                $row = pwg_db_fetch_array($result);
     116                                return $row['nb_concours'];
     117                        }
     118                        else
     119                                return 0;
     120                        break;
     121                }
     122                default:
     123                {
     124                        $query = '
     125                                SELECT count(distinct id) as nb_concours
     126                                FROM ' . CONCOURS_TABLE
     127                                .' WHERE id>0'  // Do not take Concours 0 (default)
     128                                .';';
     129
     130                        $result = pwg_query($query);
     131                        if ($result)
     132                        {
     133                                $row = pwg_db_fetch_array($result);
     134                                return $row['nb_concours'];
     135                        }
     136                        else
     137                                return 0;
     138                        break;
     139                }
     140        }
     141
     142}
     143
     144function get_nb_active_concours()
     145{
     146        $query = '
     147                SELECT count(distinct id) as nb_concours
     148                FROM ' . CONCOURS_TABLE.
     149                ' WHERE time_to_sec(TIMEDIFF(begin_date, now())) < 0
     150                  AND time_to_sec(TIMEDIFF(now(), end_date)) < 0'
     151                .' AND id>0'    // Do not take Concours 0 (default)
     152                .';';
     153
     154        $result = pwg_query($query);
     155        if ($result)
     156        {
     157                $row = pwg_db_fetch_array($result);
     158                return $row['nb_concours'];
     159        }
     160        else
     161                return 0;
     162}
     163
     164
     165function get_nb_prepared_concours()
     166{
     167        $query = '
     168                SELECT count(distinct id) as nb_concours
     169                FROM ' . CONCOURS_TABLE .'
     170                WHERE time_to_sec(TIMEDIFF(begin_date, now())) > 0'
     171                .' AND id>0'    // Do not take Concours 0 (default)
     172                .';';
     173
     174        $result = pwg_query($query);
     175        if ($result)
     176        {
     177                $row = pwg_db_fetch_array($result);
     178                return $row['nb_concours'];
     179        }
     180        else
     181                return 0;
     182}
     183
     184function get_nb_closed_concours()
     185{
     186        $query = '
     187                SELECT count(distinct id) as nb_concours
     188                FROM ' . CONCOURS_TABLE .'
     189                WHERE time_to_sec(TIMEDIFF(now(), end_date)) > 0 '
     190                .' AND id>0'    // Do not take Concours 0 (default)
     191                .';';
     192
     193        $result = pwg_query($query);
     194        if ($result)
     195        {
     196                $row = pwg_db_fetch_array($result);
     197                return $row['nb_concours'];
     198        }
     199        else
     200                return 0;
    87201}
    88202
     
    96210                SELECT *
    97211                FROM ' . CONCOURS_TABLE .'
    98                 WHERE time_to_sec(TIMEDIFF(begin_date, now())) > 0
    99                 ORDER BY id
     212                WHERE time_to_sec(TIMEDIFF(begin_date, now())) > 0'
     213                .' AND id>0'    // Do not take Concours 0 (default)
     214                .' ORDER BY id
    100215                ;';
    101216
    102217        $result = pwg_query($query);
    103 //echo $query;
    104         while ($row = mysql_fetch_assoc($result))
     218        while ($row = pwg_db_fetch_assoc($result))
     219
    105220        {
    106221                array_push($concours_list, $row);
     
    118233                FROM ' . CONCOURS_TABLE .'
    119234                WHERE time_to_sec(TIMEDIFF(begin_date, now())) < 0
    120                 AND time_to_sec(TIMEDIFF(now(), end_date)) < 0
    121                 ORDER BY id
     235                AND time_to_sec(TIMEDIFF(now(), end_date)) < 0'
     236                .' AND id>0'    // Do not take Concours 0 (default)
     237                .' ORDER BY id
    122238                ;';
    123239
    124240        $result = pwg_query($query);
    125 //echo $query;
    126         while ($row = mysql_fetch_assoc($result))
     241        while ($row = pwg_db_fetch_assoc($result))
     242
    127243        {
    128244                array_push($concours_list, $row);
     
    139255                SELECT *
    140256                FROM ' . CONCOURS_TABLE .'
    141                 WHERE time_to_sec(TIMEDIFF(now(), end_date)) > 0
    142                 ORDER BY id
    143                
    144                 '
    145 //              .'AND id != 0'
     257                WHERE time_to_sec(TIMEDIFF(now(), end_date)) > 0 '
     258                .' AND id>0'    // Do not take Concours 0 (default)
     259                .'ORDER BY id'
    146260                .';';
    147261
    148262        $result = pwg_query($query);
    149 //echo $query;
    150         while ($row = mysql_fetch_assoc($result))
     263        while ($row = pwg_db_fetch_assoc($result))
    151264        {
    152265                array_push($concours_list, $row);
     
    206319
    207320$groups = array();
    208   while ($row = mysql_fetch_assoc($result))
     321        while ($row = pwg_db_fetch_assoc($result))
    209322  {
    210323    array_push($groups, $row);
  • extensions/ConcoursPhoto/admin/help.php

    r9370 r32457  
    99
    1010$template->assign(array('SCRIPT' =>
    11                         '<script type="text/javascript" src="'.CONCOURS_ADMIN_PATH.'template/Scripts.js"></script>'));
     11                        '<script type="text/javascript" src="'.CONCOURS_ADMIN_PATH.'template/Scripts.js"></script>
     12                        <link rel="stylesheet" type="text/css" href="'.CONCOURS_ADMIN_PATH.'template/concours.css")'
     13                       
     14                        ));
    1215
    1316
  • extensions/ConcoursPhoto/admin/manage.php

    r8946 r32457  
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
    5 global $template;
    6 
    7 // Show concours list in 3 cases :
    8 // 1-> prepared concours (not actived)
    9 // 2-> active concours
    10 // 3-> closed concours
    11 
    12 $prepared_concours = get_inactive_concours();
    13 $active_concours = get_active_concours();
    14 $closed_concours = get_closed_concours();
    15 
    16 // 1 prepared concours
    17 foreach ($prepared_concours as $concours)
     5global $template, $page;
     6
     7
     8if (isset($_POST['add_concours_submit']))
     9    redirect(PHPWG_ROOT_PATH.'admin.php?page=plugin-'.CONCOURS_DIR.'-add_concours&action=new');
     10
     11// Show default criterias (concours id=0)
     12$defaultconcours = new Concours(0);
     13
     14$status = (isset($_GET['status']) ? $_GET['status'] : '');
     15$sortby = (isset($_GET['sortby']) ? $_GET['sortby'] : 'id');
     16$sortorder = (isset($_GET['sortorder']) ? $_GET['sortorder'] : 'desc');
     17$start = (isset($_GET['start']) ? $_GET['start'] : 0);
     18$no_concours = l10n('active_concours_1') ;
     19$query = 'SELECT DISTINCT(id), name, descr, create_date, begin_date, end_date, method, category FROM '.CONCOURS_TABLE;
     20
     21if (isset($_POST['concours_form_filter_submit'])) {
     22        $start = 0;
     23        switch ($_POST['concours_status']) {
     24                case 'prepared':
     25                        $query .= ' WHERE time_to_sec(TIMEDIFF(begin_date, now())) > 0 AND id!=0';
     26                        $status = 'prepared';
     27                        $no_concours = l10n('prepared_concours_1') ;
     28                        break;
     29                case 'active':
     30                        $query .= ' WHERE time_to_sec(TIMEDIFF(begin_date, now())) < 0 AND id!=0
     31                        AND time_to_sec(TIMEDIFF(now(), end_date)) < 0';
     32                        $status = 'active';
     33                        $no_concours = l10n('active_concours_1') ;
     34                        break;
     35                case 'closed':
     36                        $query .= ' WHERE time_to_sec(TIMEDIFF(now(), end_date)) > 0 AND id!=0';
     37                        $status = 'closed';
     38                        $no_concours = l10n('closed_concours_1') ;
     39                        break;
     40                case'closed-noresult':
     41                        $query .= ' WHERE time_to_sec(TIMEDIFF(now(), end_date)) > 0 AND id!=0';
     42                        $query .= ' AND id NOT IN (SELECT id_concours FROM ' .CONCOURS_RESULT_TABLE.') ';
     43                        $status = 'closed-noresult';
     44                        $no_concours = l10n('closed_noresult_concours_1');
     45                        break;
     46                default:
     47                        $query .= ' WHERE id!=0';
     48                        $status = null;
     49                        $no_concours = '';
     50                        break;
     51        }
     52       
     53        switch ($_POST['concours_sort_by']) {
     54                case 'id':
     55                        $query .= ' ORDER BY id';
     56                        break;
     57                case 'name':
     58                        $query .= ' ORDER BY name';
     59                        break;
     60                case 'create_date':
     61                        $query .= ' ORDER BY create_date';
     62                        break;
     63                case 'begin_date':
     64                        $query .= ' ORDER BY begin_date';
     65                        break;
     66                case 'end_date':
     67                        $query .= ' ORDER BY end_date';
     68                        break;
     69                default:
     70                        $query .= ' ORDER BY create_date';
     71                        break;
     72        }
     73       
     74        switch ($_POST['concours_sort_order']) {
     75                case 'asc':
     76                        $query .= ' ASC';
     77                        break;
     78                case 'desc':
     79                        $query .= ' DESC';
     80                        break;
     81                default:
     82                        $query .= ' DESC';
     83                        break;
     84        }
     85       
     86        $template->assign('concours_filter', array(
     87                                                                                        'status' => $_POST['concours_status'],
     88                                                                                        'sort_by' => $_POST['concours_sort_by'],
     89                                                                                        'sort_order' => $_POST['concours_sort_order'],
     90                                                                                )
     91        );
     92       
     93        if (intval($_POST['concours_nb_concours_page']) == 0)
     94                $defaultconcours->my_config['nb_concours_page'] = 1;
     95        else
     96                $defaultconcours->my_config['nb_concours_page'] = intval($_POST['concours_nb_concours_page']);
     97        $defaultconcours->set_config();
     98
     99
     100}
     101else
    18102{
    19   $template->append('prepared_concours', array(
    20     'ID' => $concours['id'],
    21         'CREATE_DATE'   => $concours['create_date'],
    22     'NAME' => $concours['name'],
    23     'DESC' => $concours['descr'],
    24         'BEGIN_DATE'    => $concours['begin_date'],
    25         'END_DATE'      => $concours['end_date'],
    26 
    27     'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=modify',
    28     'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=del' : '',
    29   ));
    30 
    31 }
    32 // 2 active concours
    33 foreach ($active_concours as $concours)
    34 {
    35   $template->append('active_concours', array(
    36     'ID' => $concours['id'],
    37         'CREATE_DATE'   => $concours['create_date'],
    38     'NAME' => $concours['name'],
    39     'DESC' => $concours['descr'],
    40         'BEGIN_DATE'    => $concours['begin_date'],
    41         'END_DATE'      => $concours['end_date'],
    42 
    43     'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=modify',
    44     'U_AUDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Faudit.php&amp;concours=' . $concours['id'],
    45     'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=del': '',
    46   ));
    47 
    48 }
    49 // 3 closed concours
    50 foreach ($closed_concours as $concours)
    51 {
    52         if ($concours['id'] != 0)       // Default are not display
     103        switch ($status) {
     104                case 'prepared':
     105                        $query .= ' WHERE time_to_sec(TIMEDIFF(begin_date, now())) > 0 AND id!=0';
     106                        $status = 'prepared';
     107                        $no_concours = l10n('prepared_concours_1') ;
     108                        break;
     109                case 'active':
     110                        $query .= ' WHERE time_to_sec(TIMEDIFF(begin_date, now())) < 0 AND id!=0
     111                        AND time_to_sec(TIMEDIFF(now(), end_date)) < 0';
     112                        $status = 'active';
     113                        $no_concours = l10n('active_concours_1') ;
     114                        break;
     115                case 'closed':
     116                        $query .= ' WHERE time_to_sec(TIMEDIFF(now(), end_date)) > 0 AND id!=0';
     117                        $status = 'closed';
     118                        $no_concours = l10n('closed_concours_1') ;
     119                        break;
     120                case 'closed-noresult':
     121                        $query .= ' WHERE time_to_sec(TIMEDIFF(now(), end_date)) > 0 AND id!=0';
     122                        $query .= ' AND id NOT IN (SELECT id_concours FROM ' .CONCOURS_RESULT_TABLE.') ';
     123                        $status = 'closed-noresult';
     124                        $no_concours = l10n('closed_noresult_concours_1');
     125                        break;
     126                default:
     127                        $query .= ' WHERE id!=0';
     128                        $status = null;
     129                        $no_concours = '';
     130                        break;
     131        }
     132       
     133        switch ($sortby) {
     134                case 'id':
     135                        $query .= ' ORDER BY id';
     136                        break;
     137                case 'name':
     138                        $query .= ' ORDER BY name';
     139                        break;
     140                case 'create_date':
     141                        $query .= ' ORDER BY create_date';
     142                        break;
     143                case 'begin_date':
     144                        $query .= ' ORDER BY begin_date';
     145                        break;
     146                case 'end_date':
     147                        $query .= ' ORDER BY end_date';
     148                        break;
     149                default:
     150                        $query .= ' ORDER BY create_date';
     151                        break;
     152        }
     153       
     154        switch ($sortorder) {
     155                case 'asc':
     156                        $query .= ' ASC';
     157                        break;
     158                case 'desc':
     159                        $query .= ' DESC';
     160                        break;
     161                default:
     162                        $query .= ' DESC';
     163                        break;
     164        }
     165       
     166        $template->assign('concours_filter', array(
     167                                                                                        'status' => $status,
     168                                                                                        'sort_by' => $sortby,
     169                                                                                        'sort_order' => $sortorder,
     170                                                                                )
     171        );
     172       
     173}
     174
     175
     176
     177
     178
     179if (isset($_POST['delete_selected_submit'])) {
     180        if (isset($_POST['concours_to_delete_sure']) && $_POST['concours_to_delete_sure'] == '1') {
     181                if (isset($_POST['concours_to_delete'])) {
     182                        foreach ($_POST['concours_to_delete'] as $concours_id) {
     183                                $defaultconcours->delete_concours($concours_id);
     184                        }
     185                        array_push($page['infos'], l10n('concours_deleted'));
     186                }
     187                if (isset($_POST['concours_delete_closed']) && $_POST['concours_delete_closed'] == '1') {
     188                        $defaultconcours->delete_allclosed_concours();
     189                        array_push($page['infos'], l10n('concours_invalid_deleted'));
     190                }
     191        } else {
     192                array_push($page['errors'], l10n('You need to confirm deletion'));
     193        }
     194}
     195
     196//////////
     197$end = get_nb_concours($status);
     198$start =  (isset($_GET['start']) ? intval($_GET['start']) : 0);
     199if ($start > $end)
     200        $start = 0;
     201if ($start != 0 AND $end <= $defaultconcours->my_config['nb_concours_page'])
     202        $start = 0;
     203
     204$management_url_std = get_root_url().'admin.php?page=plugin-'.CONCOURS_DIR.'-manage';
     205//Create the navigation bar (for more than 1 page)
     206$management_url = get_root_url().'admin.php?page=plugin-'.CONCOURS_DIR.'-manage'.'&status='.$status.'&sortorder='.$sortorder.'&sortby='.$sortby;
     207$concours_navbar = array();
     208$concours_navbar = create_navigation_bar($management_url, $end, $start, $defaultconcours->my_config['nb_concours_page']);
     209
     210//DB Query
     211
     212if (strpos($query, 'WHERE') === FALSE) {
     213        $query .= ' WHERE time_to_sec(TIMEDIFF(begin_date, now())) < 0 AND id!=0
     214        AND time_to_sec(TIMEDIFF(now(), end_date)) < 0';
     215}
     216
     217if (strpos($query, 'ORDER BY') === FALSE) {
     218        $query .= ' ORDER BY create_date';
     219}
     220
     221
     222$query .= ' LIMIT '.$start.','.$defaultconcours->my_config['nb_concours_page'].';';
     223$result = pwg_query($query);
     224while($concours = pwg_db_fetch_assoc($result)) {
     225
     226        if ($concours['id']!=0)
    53227        {
     228               
     229               
     230                $concours_status = 0;
     231                // 0 Prepared / 1 Active / 2 Closed
     232                $concours_status = (strtotime($concours['begin_date'])-time() > 0 ? 0 : (strtotime($concours['end_date']) - time() > 0 ? 1 : 2  ));
    54233                $filename = has_file($concours['id']);
    55           $template->append('closed_concours', array(
    56                 'ID' => $concours['id'],
    57                 'CREATE_DATE'   => $concours['create_date'],
    58                 'NAME' => $concours['name'],
    59                 'DESC' => $concours['descr'],
    60                 'BEGIN_DATE'    => $concours['begin_date'],
    61                 'END_DATE'      => $concours['end_date'],
    62 
    63                 'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=edit',
    64         'U_AUDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Faudit.php&amp;concours=' . $concours['id'],
    65                 'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=del' : '',
    66                 'U_RESULT' => (!is_adviser() and !has_result($concours['id']) )? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=result' : '',
    67                 'U_FILE' => !is_adviser()
    68                                                 ? ($filename ? CONCOURS_ADMIN_PATH . 'file.php?file=' . $filename
    69                                                                                                                                 : (has_result($concours['id']) ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=file' : ''))
    70                                                 : '',
    71           ));
     234
     235                if ( ($status == 'closed-noresult' AND !has_result($concours['id']))    // option "closed without result' => display only closed without result
     236                         OR ($status != 'closed-noresult' )                                                             // OR option "closed" OR  "active" OR "prepared"
     237                        )
     238                {
     239                        $template->append('concours_list', array(
     240                                                                                        'ID' => $concours['id'],
     241                                                                                        'STATUS1' => $concours_status,
     242                                                                                        'STATUS' => ($concours_status == 0 ? 'prepared' : ($concours_status == 1 ? 'actived' : 'closed')) ,
     243                                                                                        'CREATE_DATE'   => $concours['create_date'],
     244                                                                                        'NAME' => $concours['name'],
     245                                                                                        'DESC' => $concours['descr'],
     246                                                                                        'BEGIN_DATE'    => $concours['begin_date'],
     247                                                                                        'END_DATE'      => $concours['end_date'],
     248
     249                                                                                        'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action='.($concours_status != 2 ? 'modify' : 'edit'),
     250                                                                                        'U_AUDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Faudit.php&amp;concours=' . $concours['id'],
     251                                                                                        'U_DELETE' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=del' ,
     252                                                                                        'U_RESULT' => !has_result($concours['id'])? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=result' : '',
     253                                                                                        'U_FILE' => $filename ? CONCOURS_ADMIN_PATH . 'file.php?file=' . $filename : (has_result($concours['id']) ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $concours['id'].'&amp;action=file' : ''),
     254                                                                                        'NB_VOTE' => count($defaultconcours->get_user_list($concours['id']))+count($defaultconcours->get_guest_list($concours['id']))
     255       
     256
     257                        ));
     258                }
    72259        }
    73260}
    74261
    75262$template->assign('IMG_URL', CONCOURS_IMG_PATH);
    76 
    77 
     263$template->assign('MANAGE_URL', $management_url_std);
     264
     265$template->assign('no_concours', sprintf(l10n('concours_no_concours'), $no_concours));
     266
     267$nb_concours_valid_total = sprintf(l10n('concours_nb_concours_total'), get_nb_concours(), get_nb_prepared_concours(), get_nb_active_concours(), get_nb_closed_concours());
     268
     269
     270$template->assign('nb_concours_total', $nb_concours_valid_total);
     271$template->assign('concours_nb_concours_page', $defaultconcours->my_config['nb_concours_page']);
     272$template->assign('navbar', $concours_navbar);
    78273
    79274$template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/manage.tpl');
    80275$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    81276
     277
     278
    82279?>
  • extensions/ConcoursPhoto/admin/params.php

    r8946 r32457  
    77
    88// General parameters for the concours
    9 $concours = new Concours();
     9$concours1 = new Concours();
    1010
    1111if (isset($_POST['submit'])) {
    12   $concours->my_config['active_menubar'] = isset($_POST['active_menubar']);
    13   $concours->my_config['nbconcours_menubar'] = $_POST['nbconcours_menubar'];
     12  $concours1->my_config['active_menubar'] = isset($_POST['active_menubar']);
     13  $concours1->my_config['nbconcours_menubar'] = $_POST['nbconcours_menubar'];
    1414
    15   $concours->my_config['mask_author'] = isset($_POST['mask_author']);
    16   $concours->my_config['thumb_note'] = isset($_POST['thumb_note']);
     15  $concours1->my_config['mask_author'] = isset($_POST['mask_author']);
     16  $concours1->my_config['mask_meta'] = isset($_POST['mask_meta']);
     17  $concours1->my_config['thumb_note'] = isset($_POST['thumb_note']);
    1718
    18   $concours->my_config['check_exaequo'] = isset($_POST['check_exaequo']);
     19  $concours1->my_config['check_exaequo'] = isset($_POST['check_exaequo']);
    1920
    20   $concours->my_config['author_vote_available'] = isset($_POST['author_vote_available']);
    21   $concours->my_config['concours_change_score'] = isset($_POST['concours_change_score']);
     21  $concours1->my_config['author_vote_available'] = $_POST['AUTHOR_MODE'];
    2222
    23   $concours->save_config();
     23  $concours1->my_config['concours_change_score'] = isset($_POST['concours_change_score']);
     24  $concours1->my_config['concours_deadline'] = $_POST['concours_deadline'];
     25  $concours1->my_config['mask_thumbnail'] = isset($_POST['mask_thumbnail']);
     26  $concours1->my_config['active_global_score_page'] = isset($_POST['active_global_score_page']);
     27  $concours1->my_config['score_mode'] = $_POST['score_mode'];
     28  $concours1->my_config['text_overlay'] = $_POST['text_overlay'];
     29 
     30  $concours1->save_config();
     31
    2432  array_push($page['infos'], l10n('concours_saveOK'));
    2533}
    2634
     35for($jj=0; $jj < 4; $jj++)
     36{
     37        $template->append('AUTHOR_MODE',array('ID' => $jj,'NAME' => l10n('concours_author_vote'.$jj),'SELECTED' => ($concours1->my_config['author_vote_available'] == $jj ? 'selected' : '')));
     38}
     39
     40
     41
    2742for($jj=0; $jj < 10; $jj++)
    2843{
    29         $template->append('NBCONCOURS',array('ID' => $jj,'NAME' => $jj,'SELECTED' => ($concours->my_config['nbconcours_menubar'] == $jj ? 'selected' : '')));
    30         $i++;   
     44        $template->append('NBCONCOURS',array('ID' => $jj,'NAME' => $jj,'SELECTED' => ($concours1->my_config['nbconcours_menubar'] == $jj ? 'selected' : '')));
    3145}
    3246
     47for($jj=0; $jj < 3; $jj++)
     48{
     49        $template->append('DEADLINE',array('ID' => $jj,'NAME' => l10n('concours_deadline_param'.$jj),'SELECTED' => ($concours1->my_config['concours_deadline'] == $jj ? 'selected' : '')));
     50}
     51for($jj=0; $jj < 2; $jj++)
     52{
     53        $template->append('SCORE_MODE',array('ID' => $jj,'NAME' => l10n('concours_score_mode'.$jj),'SELECTED' => ($concours1->my_config['score_mode'] == $jj ? 'selected' : '')));
     54}
     55
     56
    3357$template->assign(array(
    34         'SHOW_MENUBAR'                  => ($concours->my_config['active_menubar'] ? 'checked="checked"' : ''),
    35     'MASK_AUTHOR'                       => ($concours->my_config['mask_author'] ? 'checked="checked"' : ''),
    36     'THUMB_NOTE'                        => ($concours->my_config['thumb_note'] ? 'checked="checked"' : ''),
    37     'CHECK_EXAEQUO'         => ($concours->my_config['check_exaequo'] ? 'checked="checked"' : ''),
    38     'AUTHOR_VOTE_AVAILABLE' => ($concours->my_config['author_vote_available'] ? 'checked="checked"' : ''),
    39     'CHANGE_SCORE'          => ($concours->my_config['concours_change_score'] ? 'checked="checked"' : ''),
     58        'SHOW_MENUBAR'                  => ($concours1->my_config['active_menubar'] ? 'checked="checked"' : ''),
     59    'MASK_AUTHOR'                       => ($concours1->my_config['mask_author'] ? 'checked="checked"' : ''),
     60    'THUMB_NOTE'                        => ($concours1->my_config['thumb_note'] ? 'checked="checked"' : ''),
     61    'CHECK_EXAEQUO'         => ($concours1->my_config['check_exaequo'] ? 'checked="checked"' : ''),
     62    'CHANGE_SCORE'          => ($concours1->my_config['concours_change_score'] ? 'checked="checked"' : ''),
     63    'MASK_THUMB'            => ($concours1->my_config['mask_thumbnail'] ? 'checked="checked"' : ''),
     64    'GLOBAL_SCORE'          => ($concours1->my_config['active_global_score_page'] ? 'checked="checked"' : ''),
     65        'TEXT_OVERLAY'                  => $concours1->my_config['text_overlay'],
     66    'MASK_META'                         => ($concours1->my_config['mask_meta'] ? 'checked="checked"' : ''),
    4067
    4168        ));
  • extensions/ConcoursPhoto/admin/template/add_concours.tpl

    r9364 r32457  
    5656                        <td colspan = "3">             
    5757                                <select name="concours_method" {if !isset($result_not_generated)}disabled="disabled"{/if}>
    58                                 {foreach from=$concours_method item=concours_method}
    59                                         <option value="{$concours_method.ID}" {$concours_method.SELECTED}>{$concours_method.NAME}</option>
     58                                {foreach $concours_method as $concours_method1}
     59                                        <option value="{$concours_method1.ID}" {$concours_method1.SELECTED}>{$concours_method1.NAME}</option>
    6060                                {/foreach}
    6161                                </select>
     
    6868                        <b>{'concours_category_select'|@translate}</b>
    6969                        <select  name="cat_selection" disabled="disabled">
    70                          {foreach from=$category_selection item=category_selection}
    71                           <option value="{$category_selection.ID}" {$category_selection.SELECTED}>{$category_selection.NAME}</option>
     70                         {foreach $category_selection as $category_selection1}
     71                          <option value="{$category_selection1.ID}" {$category_selection1.SELECTED}>{$category_selection1.NAME}</option>
    7272                        {/foreach}
    7373                        </select>
     
    102102            </TD>
    103103        </TR>
     104        <TR>
     105            <TD colspan="4">
     106                <input type="checkbox" name="admin" {$CONCOURS.ADMIN}/> {'concours_allow_admin'|@translate}
     107                <br/>
     108            </TD>
     109        </TR>
    104110       
    105111        <tr><td colspan="4"><br></td></tr>
     
    180186                        <td colspan = "3">             
    181187                                <select name="concours_method">
    182                                 {foreach from=$concours_method item=concours_method}
    183                                         <option value="{$concours_method.ID}" {$concours_method.SELECTED}>{$concours_method.NAME}</option>
     188                                {foreach $concours_method as $concours_method1}
     189                                        <option value="{$concours_method1.ID}" {$concours_method1.SELECTED}>{$concours_method1.NAME}</option>
    184190                                {/foreach}
    185191                                </select>
     
    193199                        <b>{'concours_category_select'|@translate}</b>
    194200                        <select  name="cat_selection">
    195                          {foreach from=$category_selection item=category_selection}
    196                           <option value="{$category_selection.ID}" {$category_selection.SELECTED}>{$category_selection.NAME}</option>
     201                         {foreach $category_selection as $category_selection1}
     202                          <option value="{$category_selection1.ID}" {$category_selection1.SELECTED}>{$category_selection1.NAME}</option>
    197203                        {/foreach}
    198204                        </select>
     
    203209</fieldset>
    204210{if (isset($action) && ($action == 'modify_crit' || $action == 'edit'))}
    205 <fieldset>
    206         <legend>{'concours_criterias'|@translate}</legend>
    207          <table border="1">
    208                 <tr>
    209                         <td><b>{'concours_id'|@translate}</b></td>
    210                         <td><b>{'concours_name'|@translate}</b></td>
    211                         <td width="50%"><b>{'concours_descr'|@translate}</b></td>
    212                         <td><b>{'concours_min_value'|@translate}</b></td>
    213                         <td><b>{'concours_max_value'|@translate}</b></td>
    214                         <td><b>{'concours_coef'|@translate}</b></td>
    215                         {if $action != 'edit'}
    216                         <td width="10%"><b>{'concours_actions'|@translate}</b></td>
    217                         {/if}
    218                 </tr>
    219          {foreach from=$concours_criteria item=concours_criteria}
    220                 <tr>
    221                         <td>{$concours_criteria.id}</td>               
    222                         <td>
    223                                 {if $concours_criteria.level == 1}
    224                                         <b>{$concours_criteria.name}</b>
    225                                 {else}
    226                                         &nbsp;&nbsp;<i>{$concours_criteria.name}</i>
     211                <fieldset>
     212                <legend>{'concours_criterias'|@translate}</legend>
     213                </fieldset>
     214
     215        {if count($concours_criteria)}
     216                <table class="table2" width="97%">
     217                        <thead>
     218                                <tr class="throw">
     219                                        <td width="5%">{'concours_id'|@translate}</td>
     220                                        <td width="15%">{'concours_name'|@translate}</td>
     221                                        <td width="50%">{'concours_descr'|@translate}</td>
     222                                        <td width="5%">{'concours_min_value'|@translate}</td>
     223                                        <td width="5%">{'concours_max_value'|@translate}</td>
     224                                        <td width="5%">{'concours_coef'|@translate}</td>
     225                                        {if $action != 'edit'}
     226                                        <td width="10%">{'concours_actions'|@translate}</td>
     227                                        {/if}
     228                                </tr>
     229                        </thread>
     230                        <tbody>
     231                         {foreach $concours_criteria as $concours_criteria1}
     232                                {if $smarty.foreach.foreach_concours_criteria.iteration is even}
     233                                        <tr class="row1">
     234                                {else} 
     235                                        <tr class="row2">
    227236                                {/if}
    228                         </td>           
    229                         <td>{$concours_criteria.lib}</td>               
    230                         {if !$concours_criteria.nosub}
    231                                 <td colspan="3">&nbsp;</td>             
    232                         {else}
    233                                 <td>{$concours_criteria.min}</td>               
    234                                 <td>{$concours_criteria.max}</td>               
    235                                 <td>{$concours_criteria.pond}</td>             
    236                         {/if}
    237                         {if $action != 'edit'}
    238                         <td>
    239                                 {if isset($concours_criteria.U_EDIT)}
    240                                         <a href="{$concours_criteria.U_EDIT}" title="{'criteria_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'criteria_edit'|@translate}"/></a>
    241                                         &nbsp;
    242                                 {/if}
    243                                 {if isset($concours_criteria.U_DELETE)}
    244                                         <a href="{$concours_criteria.U_DELETE}" title="{'criteria_delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/delete.png" class="button" alt="{'criteria_delete'|@translate}" /></a>
    245                                 {/if}
    246                                 {if $concours_criteria.level == 1}
    247                                         <a href="{$concours_criteria.U_ADD}" title="{'subcriteria_add'|@translate}" ><img src="{$IMG_URL}add.png" class="button" alt="{'subcriteria_add'|@translate}" /></a>
    248                                 {/if}
    249                         </td>
    250                         {/if}
    251                 </tr>
    252         {/foreach}
    253         </table>
     237                                        <td>{$concours_criteria1.id}</td>               
     238                                        <td>
     239                                                {if $concours_criteria1.level == 1}
     240                                                        <b>{$concours_criteria1.name}</b>
     241                                                {else}
     242                                                        &nbsp;&nbsp;<i>{$concours_criteria1.name}</i>
     243                                                {/if}
     244                                        </td>           
     245                                        <td>{$concours_criteria1.lib}</td>             
     246                                        {if !$concours_criteria1.nosub}
     247                                                <td colspan="3">&nbsp;</td>             
     248                                        {else}
     249                                                <td>{$concours_criteria1.min}</td>             
     250                                                <td>{$concours_criteria1.max}</td>             
     251                                                <td>{$concours_criteria1.pond}</td>             
     252                                        {/if}
     253                                        {if $action != 'edit'}
     254                                        <td>
     255                                                {if isset($concours_criteria1.U_EDIT)}
     256                                                        <a href="{$concours_criteria1.U_EDIT}" title="{'criteria_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'criteria_edit'|@translate}"/></a>
     257                                                        &nbsp;
     258                                                {/if}
     259                                                {if isset($concours_criteria1.U_DELETE)}
     260                                                        <a href="{$concours_criteria1.U_DELETE}" title="{'criteria_delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/delete.png" class="button" alt="{'criteria_delete'|@translate}" /></a>
     261                                                {/if}
     262                                                {if $concours_criteria1.level == 1}
     263                                                        <a href="{$concours_criteria1.U_ADD}" title="{'subcriteria_add'|@translate}" ><img src="{$IMG_URL}add.png" width="30" class="button" alt="{'subcriteria_add'|@translate}" /></a>
     264                                                {/if}
     265                                        </td>
     266                                        {/if}
     267                                </tr>
     268                        {/foreach}
     269                </table>
     270        {else}
     271                <fieldset>
     272                        <div class="concours_no_criteria">
     273                                {'concours_no_criteria'|@translate}
     274                        </div>
     275                </fieldset>
     276
     277        {/if}
    254278        {if $action != 'edit'}
    255         <p><input type="submit" name="add" value="{'concours_add_criteria'|@translate}" />
     279                <p><input type="submit" name="add" value="{'concours_add_criteria'|@translate}" />
    256280        {/if}
    257281
    258 
    259 </fieldset>
    260 {/if}
     282{/if}   
    261283<p><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /></p>
    262284</form>
  • extensions/ConcoursPhoto/admin/template/audit.tpl

    r9364 r32457  
    55        <fieldset>
    66                <legend>{'concours_audit_page'|@translate}</legend>
    7         <fieldset>
    8                 <legend>{'concours_infos'|@translate}</legend>
    9         <table align="left">
    10                         <td align = "left">
    11                                 {'concours_name'|@translate} : <b>{$CONCOURS.NAME}</b>
    12                                 <br>{'concours_descr'|@translate} : <b>{$CONCOURS.DESCR}</b>
    13                                 <br>{'concours_activ_from'|@translate} <b>{$CONCOURS.BEGIN_DATE}</b> {'concours_activ_to'|@translate} <b>{$CONCOURS.END_DATE}</b>
    14                                 <br>{'concours_method'|@translate} : <b>{$CONCOURS.METHOD}</b>
    15                         </td>
    16                 </tr>
    17         </table>
    18         </fieldset>
    19 <form method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
    20     {'concours_username_selection'|@translate} : </b>
    21         <select name="user_list">
    22         {foreach from=$user_list item=user_list}
    23             <option value="{$user_list.ID}" {$user_list.SELECTED}>{$user_list.NAME}</option>
    24         {/foreach}
    25         </select>
    26     <input type="submit" name="Submit" value="{'Submit'|@translate}" />
    27 </form>
    28         <table align="left">
    29                 <tr><td colspan="4"><br></td></tr>
    30                  {foreach from=$concours_note item=concours_note}
    31                         <tr>
    32                                 <td><b><i> {if $concours_note.nbvotant != 0}
    33                             ({$concours_note.rang}{if $concours_note.rang == 1}{'concours_1st'|@translate}
    34                                                                                                  {elseif $concours_note.rang == 2}{'concours_2nd'|@translate}
    35                                                                                                  {elseif $concours_note.rang == 3}{'concours_3rd'|@translate}
    36                                                                                                  {else}{'concours_4th'|@translate}{/if}
    37                                                         )
    38                             {else}(N/A){/if}&nbsp;&nbsp;</i></b></td>
    39                                 <td>
    40                     <b>Photo Id : {$concours_note.img_id}&nbsp;&nbsp;</b>
    41                 </td>           
    42                                 <td>
    43                                         <a href="{$concours_note.url}">
    44                                         <img class="thumbnail" src="{$concours_note.thumb}" alt="{$concours_note.name}" title="{$concours_note.name}"/>
    45                                         </a>
    46                     <br><u>{'concours_name'|@translate}</u> : {$concours_note.name}
    47                     <br><u>{'concours_author'|@translate}</u> : {$concours_note.author}
     7                <fieldset>
     8                        <legend>{'concours_infos'|@translate}</legend>
     9                <table align="left">
     10                                <td align = "left">
     11                                        {'concours_name'|@translate} : <b>{$CONCOURS.NAME}</b>
     12                                        <br>{'concours_descr'|@translate} : <b>{$CONCOURS.DESCR}</b>
     13                                        <br>{'concours_activ_from'|@translate} <b>{$CONCOURS.BEGIN_DATE}</b> {'concours_activ_to'|@translate} <b>{$CONCOURS.END_DATE}</b>
     14                                        <br>{'concours_method'|@translate} : <b>{$CONCOURS.METHOD}</b>
    4815                                </td>
    49                 <td align="left">
    50                                 <fieldset>
    51                                         <i>{'concours_note'|@translate} : <b>{$concours_note.note}</b>&nbsp;&nbsp;</i>
    52                                         <br><i>{'concours_moyenne'|@translate} : <b>{$concours_note.moyenne}</b>&nbsp;&nbsp;</i>
    53                                         <br><i>{'concours_nbvotant'|@translate} : {$concours_note.nbvotant}&nbsp;&nbsp;</i>
    54                                 </fieldset>
    55                 </td>
    5616                        </tr>
    57                 <tr><td colspan="2"></td>
    58                 <td><hr></td>
    59                 <td></td>
    60             </tr>
    61                 {/foreach}
     17                </table>
     18                </fieldset>
     19                <fieldset>
     20        <form method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
     21                {'concours_username_selection'|@translate} : </b>
     22                        <select name="user_list">
     23                        {foreach $user_list as $user_list1}
     24                                <option value="{$user_list1.ID}" {$user_list1.SELECTED}>{$user_list1.NAME}</option>
     25                        {/foreach}
     26                        </select>
     27                <input type="submit" name="Submit" value="{'Submit'|@translate}" />
     28        </form>
     29                <table align="left">
     30                        <tr><td colspan="4"><br></td></tr>
     31                         {foreach $concours_note as $concours_note1}
     32                                <tr>
     33                                        <td><b><i> {if $concours_note1.nbvotant != 0}
     34                                                                ({$concours_note1.rang}{if $concours_note1.rang == 1}{'concours_1st'|@translate}
     35                                                                                                         {elseif $concours_note1.rang == 2}{'concours_2nd'|@translate}
     36                                                                                                         {elseif $concours_note1.rang == 3}{'concours_3rd'|@translate}
     37                                                                                                         {else}{'concours_4th'|@translate}{/if}
     38                                                                )
     39                                                                {else}(N/A){/if}&nbsp;&nbsp;</i></b></td>
     40                                        <td>
     41                                                <b>Photo Id : {$concours_note1.img_id}&nbsp;&nbsp;</b>
     42                                        </td>           
     43                                        <td>
     44                                                <a href="{$concours_note1.url}">
     45                                                <img class="thumbnail" src="{$concours_note1.thumb}" alt="{$concours_note1.name}" title="{$concours_note1.name}"/>
     46                                                </a>
     47                                                <br><u>{'concours_name'|@translate}</u> : {$concours_note1.name}
     48                                                <br><u>{'concours_author'|@translate}</u> : {$concours_note1.author}
     49                                        </td>
     50                                        <td align="left">
     51                                        <fieldset>
     52                                                <i>{'concours_note'|@translate} : <b>{$concours_note1.note}</b>&nbsp;&nbsp;</i>
     53                                                <br><i>{'concours_moyenne'|@translate} : <b>{$concours_note1.moyenne}</b>&nbsp;&nbsp;</i>
     54                                                {if ($CONCOURS.METHODNB > 2)}
     55                                                <br>{'concours_warn_moderation'|@translate}
     56                                                {/if}
     57                                                <br><i>{'concours_nbvotant'|@translate} : {$concours_note1.nbvotant}&nbsp;&nbsp;</i>
     58                                        </fieldset>
     59                                        </td>
     60                                </tr>
     61                                <tr><td colspan="2"></td>
     62                                        <td><hr></td>
     63                                        <td></td>
     64                                </tr>
     65                        {/foreach}
    6266
    63         </table>
     67                </table>
     68                </fieldset>
    6469        </fieldset>
    6570
  • extensions/ConcoursPhoto/admin/template/config.tpl

    r9364 r32457  
    55{'concours_admin_title'|@translate}
    66</p>
    7 <form method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
    8 <fieldset>
     7        <fieldset>
    98        <legend>{'default_criteria'|@translate}</legend>
     9        </fieldset>
    1010
    11          <table border="1">
    12                 <tr>
    13                         <td><b>{'concours_id'|@translate}</b></td>
    14                         <td><b>{'concours_name'|@translate}</b></td>
    15                         <td width="50%"><b>{'concours_descr'|@translate}</b></td>
    16                         <td><b>{'concours_min_value'|@translate}</b></td>
    17                         <td><b>{'concours_max_value'|@translate}</b></td>
    18                         <td><b>{'concours_coef'|@translate}</b></td>
    19                         <td width="10%"><b>{'concours_actions'|@translate}</b></td>
    20                 </tr>
    21          {foreach from=$concours_criteria item=concours_criteria}
    22                 <tr>
    23                         <td>{$concours_criteria.id}</td>               
    24                         <td>
    25                                 {if $concours_criteria.level == 1}
    26                                         <b>{$concours_criteria.name}</b>
    27                                 {else}
    28                                         &nbsp;&nbsp;<i>{$concours_criteria.name}</i>
    29                                 {/if}
    30                         </td>           
    31                         <td>{$concours_criteria.lib}</td>               
    32                         {if !$concours_criteria.nosub}
    33                                 <td colspan="3">&nbsp;</td>             
    34                         {else}
    35                                 <td>{$concours_criteria.min}</td>               
    36                                 <td>{$concours_criteria.max}</td>               
    37                                 <td>{$concours_criteria.pond}</td>             
    38                         {/if}
    39                         <td>
    40                         {if isset($concours_criteria.U_EDIT)}
    41                                 <a href="{$concours_criteria.U_EDIT}" title="{'criteria_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'criteria_edit'|@translate}"/></a>
    42                                 &nbsp;
    43                         {/if}
    44                         {if isset($concours_criteria.U_DELETE)}
    45                                 <a href="{$concours_criteria.U_DELETE}" title="{'criteria_delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/delete.png" class="button" alt="{'criteria_delete'|@translate}" /></a>
    46                         {/if}
    47                         {if $concours_criteria.level == 1}
    48                                 <a href="{$concours_criteria.U_ADD}" title="{'subcriteria_add'|@translate}" ><img src="{$IMG_URL}add.png" class="button" alt="{'subcriteria_add'|@translate}" /></a>
    49                         {/if}
    50                         </td>
    51                 </tr>
    52         {/foreach}
    53         </table>
    54         <p><input type="submit" name="add" value="{'concours_add_criteria'|@translate}" />
    55                
    56 </fieldset>
    57 </form>
     11        {if count($concours_criteria)}
     12                <table class="table2" width="97%">
     13                        <thead>
     14                                <tr class="throw">
     15                                        <td width="5%">{'concours_id'|@translate}</td>
     16                                        <td width="15%">{'concours_name'|@translate}</td>
     17                                        <td width="50%">{'concours_descr'|@translate}</td>
     18                                        <td width="5%">{'concours_min_value'|@translate}</td>
     19                                        <td width="5%">{'concours_max_value'|@translate}</td>
     20                                        <td width="5%">{'concours_coef'|@translate}</td>
     21                                        <td width="10%">{'concours_actions'|@translate}</td>
     22                                </tr>
     23                        </thead>
     24                        <tbody>
     25                                 {foreach $concours_criteria as $concours_criteria1}
     26                                        {if $smarty.foreach.foreach_concours_criteria.iteration is even}
     27                                                <tr class="row1">
     28                                        {else} 
     29                                                <tr class="row2">
     30                                        {/if}
     31                                                <td>{$concours_criteria1.id}</td>               
     32                                                <td>
     33                                                        {if $concours_criteria1.level == 1}
     34                                                                <b>{$concours_criteria1.name}</b>
     35                                                        {else}
     36                                                                &nbsp;&nbsp;<i>{$concours_criteria1.name}</i>
     37                                                        {/if}
     38                                                </td>           
     39                                                <td>{$concours_criteria1.lib}</td>             
     40                                                {if !$concours_criteria1.nosub}
     41                                                        <td colspan="3">&nbsp;</td>             
     42                                                {else}
     43                                                        <td>{$concours_criteria1.min}</td>             
     44                                                        <td>{$concours_criteria1.max}</td>             
     45                                                        <td>{$concours_criteria1.pond}</td>             
     46                                                {/if}
     47                                                <td>
     48                                                {if isset($concours_criteria1.U_EDIT)}
     49                                                        <a href="{$concours_criteria1.U_EDIT}" title="{'criteria_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'criteria_edit'|@translate}"/></a>
     50                                                        &nbsp;
     51                                                {/if}
     52                                                {if isset($concours_criteria1.U_DELETE)}
     53                                                        <a href="{$concours_criteria1.U_DELETE}" title="{'criteria_delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/delete.png" class="button" alt="{'criteria_delete'|@translate}" /></a>
     54                                                {/if}
     55                                                {if $concours_criteria1.level == 1}
     56                                                        <a href="{$concours_criteria1.U_ADD}" title="{'subcriteria_add'|@translate}" ><img src="{$IMG_URL}add.png" width="30" class="button" alt="{'subcriteria_add'|@translate}" /></a>
     57                                                {/if}
     58                                                </td>
     59                                        </tr>
     60                                {/foreach}
     61                        </tbody>
     62                </table>
     63        {else}
     64                <fieldset>
     65                        <div class="concours_no_criteria">
     66                                {'concours_no_criteria'|@translate}
     67                        </div>
     68                </fieldset>
     69        {/if}
     70        <fieldset>
     71                <form method="post" id="add">
     72                <p><input type="submit" name="add" value="{'concours_add_criteria'|@translate}" />
     73        </fieldset>
     74
     75        </form>
  • extensions/ConcoursPhoto/admin/template/help.tpl

    r9370 r32457  
    1 {known_script id="jquery" src= $ROOT_URL|@cat:$path_js|@cat:"jquery.js" }
    2 {known_script id="jquery.cluetip" src=$ROOT_URL|@cat:$path_js|@cat:"plugins/jquery.cluetip.js" }
    3 {known_script id="jquery" src= $ROOT_URL|@cat:$path_js|@cat:"jquery.js"}
    4 {known_script id="jquery.cluetip" src=$ROOT_URL|@cat:$path_js|@cat:"plugins/jquery.cluetip.packed.js" }
     1{combine_script id='jquery' path='themes/default/js/jquery.min.js'}
     2{combine_script id='jquery.cluetip' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'}
    53
    64{html_head}
     
    86{/html_head}
    97
     8
     9
     10
     11
     12
    1013<div class="instructions">
    1114  <h2>{$CONCOURS_VERSION}</h2>
    1215<fieldset style=" position:relative ; top:15px">
    1316  <legend>{'concours_admin_help'|translate}</legend>
    14 <div id="instructionFonction" class="instructionBlock" >
    15  
    16   <div
    17     id="fonction_header"
    18     class="instructionBlockHeaderCollapsed"
    19     onclick="blockToggleDisplay('fonction_header', 'Fonction')"
    20   ><span>
    21     {'ConcoursPhoto_Fonctionality'|translate}
    22   </span></div>
    23   <div
    24     id="Fonction"
    25     class="instructionBlockContent"
    26     style="display:none"
    27   >
    28     <p>{'CC_Function'|translate}.</p>
    29     <ol>     
    30           <li>{'CC_hlp_1_1'|translate}</li>
    31       <li>{'CC_hlp_1_2'|translate}</li>
    32       <li>{'CC_hlp_1_3'|translate}</li>
    33       <li>{'CC_hlp_1_4'|translate}</li>
    34       <li>{'CC_hlp_1_5'|translate}</li>
    35       <li>{'CC_hlp_1_6'|translate}</li>
    36     </ol>
    37     <p></p>
    38   </div> <!-- Fonction -->
    39 </div> <!-- Fonctions -->
    40 
    41 <div id="instructionOPTION" class="instructionBlock">
    42   <div
    43     id="USAGE_header"
    44     class="instructionBlockHeaderCollapsed"
    45     onclick="blockToggleDisplay('USAGE_header', 'USAGE_content')"
    46   ><span>
    47    {'CC_Usage'|translate}
    48   </span></div>
    49   <div
    50     id="USAGE_content"
    51     class="instructionBlockContent"
    52     style="display:none"
    53   >
    54 
    55  
    56 
    57 <ol>
    58   <li ><span class="throw"> {'CC_Create_step1'|translate}</span></li>
    59    <ul>
    60  <li>{'CC_hlp_C1_1'|translate}</li>
    61  <li>{'CC_hlp_C1_2'|translate}</li>
    62  <li>{'CC_hlp_C1_3'|translate}</li>
    63  <li>{'CC_hlp_C1_4'|translate}</li>
    64 </ul>
    65   <li ><span  class="throw">{'CC_Create_step2'|translate}</span></li>
    66  
    67    <ul>
    68  <li>{'CC_hlp_C2_1'|translate}</li>
    69  <li>{'CC_hlp_C2_2'|translate}</li>
    70  <li>{'CC_hlp_C2_3'|translate}</li>
    71  <li>{'CC_hlp_C2_4'|translate}</li>
    72 </ul>
    73   <li><span  class="throw">{'CC_usage'|translate}</span> </li>
    74   <ul>
    75  <li>{'CC_hlp_C3_1'|translate}</li>
    76  <li>{'CC_hlp_C3_2'|translate}</li>
    77  <li>{'CC_hlp_C3_3'|translate}</li>
    78  <li>{'CC_hlp_C3_4'|translate}</li>
    79 </ul>
    80 </ul>
    81   <li><span  class="throw">{'CC_result'|translate}</span> </li>
    82   <ul>
    83  <li>{'CC_hlp_C4_1'|translate}</li>
    84  <li>{'CC_hlp_C4_2'|translate}</li>
    85  <li>{'CC_hlp_C4_3'|translate}</li>
    86  <li>{'CC_hlp_C4_4'|translate}</li>
    87 </ul>
    88 </ol>
    8917
    9018
    9119
    9220
    93   </div> <!-- OPTION_content -->
    94 </div> <!-- instructionOPTION -->
     21        <div id="instructionConcours" class="instructionBlock" >
     22 
     23          <div id="Concours_header" class="instructionBlockHeaderCollapsed" onclick="blockToggleDisplay('Concours_header', 'Fonction')">
     24            <span class="cluetip" title="{'ConcoursPhoto_Fonctionality'|translate}">{'ConcoursPhoto_Fonctionality'|translate}</span>
     25          </div>
     26          <div id="Fonction" class="instructionBlockContent" style="display:none">
     27                        <fieldset>
     28                          {'ConcoursPhoto_Fonctionality_txt'|@translate}
     29                        </fieldset>
     30          </div> <!-- Fonction -->
     31        </div> <!-- instructionConcours -->
     32
     33        <div id="instructionOPTION" class="instructionBlock">
     34          <div id="USAGE_header" class="instructionBlockHeaderCollapsed" onclick="blockToggleDisplay('USAGE_header', 'USAGE_content')">
     35            <span class="cluetip" title="{'ConcoursPhoto_Options'|translate}">{'ConcoursPhoto_Options'|translate}</span>
     36          </div>
     37          <div id="USAGE_content" class="instructionBlockContent" style="display:none" >
     38                        <fieldset>
     39                          {'ConcoursPhoto_Options_txt'|@translate}
     40                        </fieldset>
     41
     42          </div> <!-- USAGE_header -->
     43        </div> <!-- USAGE_content -->
    9544
    9645 </fieldset>
  • extensions/ConcoursPhoto/admin/template/manage.tpl

    r9364 r32457  
    55{'concours_admin_title'|@translate}
    66</p>
    7 <form method="post" action="" class="properties"  ENCTYPE="multipart/form-data">
    8 <fieldset>
    9         <legend>{'manage_concours'|@translate}</legend>
     7
    108
    119        <fieldset>
    12                 <legend>{'prepared_concours'|@translate}</legend>
    13                  <table border="1">
    14                         <tr>
    15                                 <th><b>{'concours_id2'|@translate}</b></th>
    16                                 <th><b>{'concours_name'|@translate}</b></th>
    17                                 <th><b>{'concours_create_date'|@translate}</b></th>
    18                                 <th width="50%"><b>{'concours_descr'|@translate}</b></th>
    19                                 <th><b>{'concours_begin_date'|@translate}</b></th>
    20                                 <th><b>{'concours_end_date'|@translate}</b></th>
    21                                 <th width="10%"><b>{'concours_actions'|@translate}</b></th>
    22                         </tr>
    23                  {foreach from=$prepared_concours item=prepared_concours}
    24                         <tr>
    25                                 <td>{$prepared_concours.ID}</td>               
    26                                 <td>{$prepared_concours.NAME}</td>             
    27                                 <td>{$prepared_concours.CREATE_DATE}</td>               
    28                                 <td>{$prepared_concours.DESC}</td>             
    29                                 <td>{$prepared_concours.BEGIN_DATE}</td>               
    30                                 <td>{$prepared_concours.END_DATE}</td>         
    31                                 <td><a href="{$prepared_concours.U_EDIT}" title="{'concours_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'concours_edit'|@translate}"/></a>
    32                                 &nbsp;<a href="{$prepared_concours.U_DELETE}" title="{'concours_delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'concours_delete'|@translate}" /></a>
    33                                 </td>
    34                         </tr>
    35                 {/foreach}
    36                 </table>
    37         </fieldset>
    38        
    39         <fieldset>
    40                 <legend>{'active_concours'|@translate}</legend>
    41                  <table border="1">
    42                         <tr>
    43                                 <th><b>{'concours_id2'|@translate}</b></th>
    44                                 <th><b>{'concours_name'|@translate}</b></th>
    45                                 <th><b>{'concours_create_date'|@translate}</b></th>
    46                                 <th width="50%"><b>{'concours_descr'|@translate}</b></th>
    47                                 <th><b>{'concours_begin_date'|@translate}</b></th>
    48                                 <th><b>{'concours_end_date'|@translate}</b></th>
    49                                 <th width="10%"><b>{'concours_actions'|@translate}</b></th>
    50                         </tr>
    51                  {foreach from=$active_concours item=active_concours}
    52                         <tr>
    53                                 <td>{$active_concours.ID}</td>         
    54                                 <td><a href="{$active_concours.U_AUDIT}" title="{'concours_audit1'|@translate}">{$active_concours.NAME}</a></td>               
    55                                 <td>{$active_concours.CREATE_DATE}</td>         
    56                                 <td>{$active_concours.DESC}</td>               
    57                                 <td>{$active_concours.BEGIN_DATE}</td>         
    58                                 <td>{$active_concours.END_DATE}</td>           
    59                                 <td><a href="{$active_concours.U_EDIT}" title="{'concours_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'concours_edit'|@translate}"/></a>
    60                                 &nbsp;<a href="{$active_concours.U_DELETE}" title="{'concours_delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'concours_delete'|@translate}" /></a>
    61                                 </td>
    62                         </tr>
    63                 {/foreach}
    64                 </table>
     10                <legend>{'manage_concours'|@translate}</legend>
     11                <form method="post" id="add_concours_submit">
     12                <div class="concours_last_line">
     13                        <span>{$nb_concours_total} </span></br></br>
     14                        <span><input type="submit" name="add_concours_submit" value="{'concours_add'|@translate}" /></span>
     15                </div>
     16                </form>
    6517        </fieldset>
    6618
    6719        <fieldset>
    68                 <legend>{'closed_concours'|@translate}</legend>
    69                  <table border="1">
    70                         <tr>
    71                                 <th><b>{'concours_id2'|@translate}</b></th>
    72                                 <th><b>{'concours_name'|@translate}</b></th>
    73                                 <th><b>{'concours_create_date'|@translate}</b></th>
    74                                 <th width="50%"><b>{'concours_descr'|@translate}</b></th>
    75                                 <th><b>{'concours_begin_date'|@translate}</b></th>
    76                                 <th><b>{'concours_end_date'|@translate}</b></th>
    77                                 <th><b>{'concours_actions'|@translate}</b></th>
    78                         </tr>
    79                  {foreach from=$closed_concours item=closed_concours}
    80                         <tr>
    81                                 <td>{$closed_concours.ID}</td>         
    82                                 <td><a href="{$closed_concours.U_AUDIT}" title="{'concours_audit1'|@translate}">{$closed_concours.NAME}</a></td>               
    83                                 <td>{$closed_concours.CREATE_DATE}</td>         
    84                                 <td>{$closed_concours.DESC}</td>               
    85                                 <td>{$closed_concours.BEGIN_DATE}</td>         
    86                                 <td>{$closed_concours.END_DATE}</td>           
    87                                 <td><a href="{$closed_concours.U_EDIT}" title="{'concours_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'concours_edit'|@translate}"/></a>
    88                                 &nbsp;<a href="{$closed_concours.U_DELETE}" title="{'concours_delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'concours_delete'|@translate}" /></a>
    89                                 {if $closed_concours.U_RESULT != ''}&nbsp;<a href="{$closed_concours.U_RESULT}" title="{'concours_result'|@translate}"><img src="{$IMG_URL}generate.png" class="button" alt="{'concours_result'|@translate}" /></a>{/if}
    90                                 {if $closed_concours.U_FILE != ''}&nbsp;<a href="{$closed_concours.U_FILE}" title="{'concours_file'|@translate}"><img src="{$IMG_URL}file.png" class="button" alt="{'concours_file'|@translate}" /></a>{/if}
    91                                
    92                                 </td>
    93                         </tr>
    94                 {/foreach}
    95                 </table>
     20                <legend>{'Filter'|@translate}</legend>
     21                <form method="post" id="concours_form_filter" action="{$MANAGE_URL}">
     22                        <span>
     23                                <label>
     24                                        {'Status'|@translate}
     25                                        <select name="concours_status">
     26                                                <option value="all" label="------------">------------</option>
     27                                                <option value="active" label="{'active_concours'|@translate}" {if $concours_filter.status=='active'}selected="selected"{/if}>{'active_concours'|@translate}</option>
     28                                                <option value="prepared" label="{'prepared_concours'|@translate}" {if $concours_filter.status=='prepared'}selected="selected"{/if}>{'prepared_concours'|@translate}</option>
     29                                                <option value="closed" label="{'closed_concours'|@translate}" {if $concours_filter.status=='closed'}selected="selected"{/if}>{'closed_concours'|@translate}</option>
     30                                                <option value="closed-noresult" label="{'closed-noresult_concours'|@translate}" {if $concours_filter.status=='closed-noresult'}selected="selected"{/if}>{'closed_concours'|@translate}</option>
     31                                        </select>
     32                                </label>
     33                        </span>
     34                        <span>
     35                                <label>
     36                                        {'Sort by'|@translate}
     37                                        <select name="concours_sort_by">
     38                                                <option value="default" label="------------">------------</option>
     39                                                <option value="id" label="{'concours_id2'|@translate}" {if $concours_filter.sort_by=='id'}selected="selected"{/if}>{'concours_id2'|@translate}</option>
     40                                                <option value="name" label="{'concours_name'|@translate}" {if $concours_filter.sort_by=='name'}selected="selected"{/if}>{'concours_name'|@translate}</option>
     41                                                <option value="create_date" label="{'concours_create_date'|@translate}" {if $concours_filter.sort_by=='create_date'}selected="selected"{/if}>{'concours_create_date'|@translate}</option>
     42                                                <option value="begin_date" label="{'concours_begin_date'|@translate}" {if $concours_filter.sort_by=='begin_date'}selected="selected"{/if}>{'concours_begin_date'|@translate}</option>
     43                                                <option value="end_date" label="{'concours_end_date'|@translate}" {if $concours_filter.sort_by=='end_date'}selected="selected"{/if}>{'concours_end_date'|@translate}</option>
     44                                        </select>
     45                                </label>
     46                        </span>         
     47                        <span>
     48                                <label>
     49                                        {'Sort order'|@translate}
     50                                        <select name="concours_sort_order">
     51                                                <option value="asc" label="{'ascending'|@translate}" {if $concours_filter.sort_order=='asc'}selected="selected"{/if}>{'ascending'|@translate}</option>
     52                                                <option value="desc" label="{'descending'|@translate}" {if $concours_filter.sort_order=='desc'}selected="selected"{/if}>{'descending'|@translate}</option>
     53                                        </select>
     54                                </label>
     55                        </span>
     56                        <span>
     57                                <label>
     58                                        {'concours_nb_concours_page'|@translate}
     59                                        <input type="text" maxlength="3" size="3" name="concours_nb_concours_page" id="concours_nb_concours_page" value="{$concours_nb_concours_page}" />
     60                                </label>
     61                        </span>
     62                        <span>
     63                                <label>
     64                                        &nbsp;
     65                                        <input type="submit" name="concours_form_filter_submit" value="{'Submit'|@translate}" />
     66                                </label>
     67                        </span>
     68                        <span>
     69                                <div>
     70                                        <img src="{$IMG_URL}prepared-0.png"  width="20"/>&nbsp;{if $concours_filter.status=='prepared'}<b>{'prepared_concours'|@translate}</b>&nbsp;{else}{'prepared_concours'|@translate}&nbsp;{/if}
     71                                        <img src="{$IMG_URL}actived-1.png"  width="20"/> {if $concours_filter.status=='active'}<b>{'active_concours'|@translate}&nbsp;</b>{else}{'active_concours'|@translate}&nbsp;{/if}
     72                                        <img src="{$IMG_URL}closed-2.png"  width="20" /> {if $concours_filter.status=='closed' or $concours_filter.status=='closed-noresult'}<b>{'closed_concours'|@translate}&nbsp;</b>{else}{'closed_concours'|@translate}&nbsp;{/if}
     73                                </div>
     74                        </span>
     75                </form>
    9676        </fieldset>
     77        {if count($concours_list)}
     78                <form method="post" id="concours_form_delete">
     79                        <table class="table2" width="97%">
     80                                <thead>
     81                                        <tr class="throw">
     82                                                <td>&nbsp;</td>
     83                                                <td>{'concours_status'|@translate}</td>
     84                                                <td>{'concours_id2'|@translate}</td>
     85                                                <td>{'concours_name'|@translate}</td>
     86                                                <td>{'concours_descr'|@translate}</td>
     87                                                <td>{'concours_create_date'|@translate}</td>
     88                                                <td>{'concours_begin_date'|@translate}</td>
     89                                                <td>{'concours_end_date'|@translate}</td>
     90                                                <td>{'concours_actions'|@translate}</td>
     91                                        </tr>
     92                                </thead>
     93                                <tbody>
     94                                        {foreach from=$concours_list item=concours_list1 name=foreach_concours_list1}
     95                                                {if $smarty.foreach.foreach_concours_list1.iteration is even}
     96                                                        <tr class="row1">
     97                                                {else} 
     98                                                        <tr class="row2">
     99                                                {/if}
     100                                                        <td><input type="checkbox" name="concours_to_delete[]" value="{$concours_list1.ID}"></td>
     101                                                        <td align=center><img src="{$IMG_URL}prepared-{$concours_list1.STATUS1}.png" {if $concours_list1.STATUS1 == 0}width="35"{else}width="27"{/if} />
     102                                                        <img src="{$IMG_URL}actived-{$concours_list1.STATUS1}.png" {if $concours_list1.STATUS1 == 1}width="35"{else}width="27"{/if}/>
     103                                                        <img src="{$IMG_URL}closed-{$concours_list1.STATUS1}.png"  {if $concours_list1.STATUS1 == 2}width="35"{else}width="27"{/if}  /></td>           
     104                                                        <td>{$concours_list1.ID}</td>           
     105                                                        <td>{if $concours_list1.STATUS1}<a href="{$concours_list1.U_AUDIT}" target="_blank" title="{'concours_audit1'|@translate}">{$concours_list1.NAME}</a>
     106                                                                {else}{$concours_list1.NAME}
     107                                                                {/if}
     108                                                                <br>[<i>{'concours_nbscore'|@translate}: {$concours_list1.NB_VOTE}</i>]</td>           
     109                                                        <td>{$concours_list1.DESC}</td>         
     110                                                        <td>{$concours_list1.CREATE_DATE}</td>         
     111                                                        <td>{$concours_list1.BEGIN_DATE}</td>           
     112                                                        <td>{$concours_list1.END_DATE}</td>             
     113                                                        <td>
     114                                                                <a href="{$concours_list1.U_EDIT}" title="{'concours_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'concours_edit'|@translate}"/></a>
     115                                                        {if $concours_list1.STATUS1 == 2}
     116                                                                {if $concours_list1.U_RESULT != ''}<a href="{$concours_list1.U_RESULT}" title="{'concours_result'|@translate}"><img src="{$IMG_URL}generate.png" width="30" class="button" alt="{'concours_result'|@translate}" /></a>{/if}
     117                                                                {if $concours_list1.U_FILE != ''}<a href="{$concours_list1.U_FILE}" title="{'concours_file'|@translate}"><img src="{$IMG_URL}file.png" width="30" class="button" alt="{'concours_file'|@translate}" /></a>{/if}
     118                                                        {/if}
     119                                                                <a href="{$concours_list1.U_DELETE}" title="{'concours_delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:javascript}');"><img src="{$themeconf.admin_icon_dir}/category_delete.png" class="button" alt="{'concours_delete'|@translate}" /></a>
     120                                                        </td>
     121                                       
     122                                                </tr>
     123                                        {/foreach}
     124                                </tbody>
     125                        </table>
     126                        {if !empty($navbar)}{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
     127                        <fieldset>
     128                                <legend>{'concours_delete_selected'|@translate}</legend>
     129                                <div class="concours_line">
     130                                        <span><input type="checkbox" name="concours_delete_closed" id="concours_delete_closed" value="1"></span>
     131                                        <span><label for="concours_delete_closed">{'concours_delete_all_closed'|@translate}</label></span>
     132                                </div>
     133                                <div class="concours_last_line">
     134                                        <span><input type="checkbox" name="concours_to_delete_sure" id="concours_to_delete_sure" value="1"></span>
     135                                        <span><label for="concours_to_delete_sure">{'Are you sure?'|@translate}</label></span>
     136                                        <span><input type="submit" name="delete_selected_submit" value="{'concours_delete'|@translate}" /></span>
     137                                </div>
     138                        </fieldset>
     139                </form>
     140        {else}
     141                <fieldset>
     142                        <div class="concours_no_concours">
     143                                <b>{$no_concours}</b>
     144                        </div>
     145                </fieldset>
     146        {/if}
     147
     148
    97149       
    98 </fieldset>
    99 </form>
  • extensions/ConcoursPhoto/admin/template/params.tpl

    r9364 r32457  
     1{footer_script}{literal}
     2function detecter(){
     3    if(document.getElementById('concours_change_score').checked){
     4        document.getElementById('text_overlay_concours').style.display='none';
     5    }
     6    else{
     7        document.getElementById('text_overlay_concours').style.display='inline';
     8    }
     9}{/literal}{/footer_script}
     10
     11
    112<div class="titrePage">
    213  <h2>{$CONCOURS_VERSION}</h2>
     
    819<fieldset>
    920        <legend>{'concours_params'|@translate}</legend>
    10 <TABLE border="0" CELLPADDING="2" ALIGN="LEFT">
     21        <div id="ConcoursParams">
     22
     23<TABLE border="0" ALIGN="LEFT">
    1124
    1225        <TR>
    13                 <TD colspan="2">
     26                <TD colspan="3">
    1427                    <input type="checkbox" name="active_menubar" {$SHOW_MENUBAR}/> {'concours_show_menubar'|@translate}
    1528                    <br/>
     
    1730        </TR>
    1831        <TR>
    19                 <TD colspan="2">
     32                <TD colspan="3">
    2033                  {'concours_nb_concours_menubar'|@translate}
    2134                  <select id="nbconcours_menubar" name="nbconcours_menubar">
    22                          {foreach from=$NBCONCOURS item=NBCONCOURS}
    23                           <option value="{$NBCONCOURS.ID}" {$NBCONCOURS.SELECTED}>{$NBCONCOURS.NAME}</option>
     35                         {foreach $NBCONCOURS as $NBCONCOURS1}
     36                          <option value="{$NBCONCOURS1.ID}" {$NBCONCOURS1.SELECTED}>{$NBCONCOURS1.NAME}</option>
    2437                        {/foreach}
    2538                  </select>
     
    2841        </TR>
    2942        <TR>
    30                 <TD colspan="2">
     43                <TD colspan="3">
    3144                    <input type="checkbox" name="mask_author" {$MASK_AUTHOR}/> {'concours_mask_author'|@translate}
    3245                    <br/>
     
    3447        </TR>
    3548        <TR>
    36                 <TD colspan="2">
     49                <TD colspan="3">
     50                    <input type="checkbox" name="mask_meta" {$MASK_META}/> {'concours_mask_meta'|@translate}
     51                    <br/>
     52                </TD>
     53        </TR>
     54        <TR>
     55                <TD colspan="3">
    3756                    <input type="checkbox" name="thumb_note" {$THUMB_NOTE}/> {'concours_thumb_note'|@translate}
    3857                    <br/>
     
    4059        </TR>
    4160        <TR>
    42                 <TD colspan="2">
     61                <TD colspan="3">
    4362                    <input type="checkbox" name="check_exaequo" {$CHECK_EXAEQUO}/> {'concours_check_exaequo'|@translate}
    4463                    <br/>
    4564                </TD>
    4665        <TR>
     66                <TD colspan="3">
     67                  {'concours_author_vote'|@translate}
     68                  <select id="AUTHOR_MODE" name="AUTHOR_MODE">
     69                         {foreach $AUTHOR_MODE as $AUTHOR_MODE1}
     70                          <option value="{$AUTHOR_MODE1.ID}" {$AUTHOR_MODE1.SELECTED}>{$AUTHOR_MODE1.NAME}</option>
     71                        {/foreach}
     72                  </select>
     73
     74             </TD>
     75        </TR>
     76       
     77        <TR>
     78                <TD colspan="3">
     79                    {'concours_author_vote_detail'|@translate}
     80                    <br/>
     81                </TD>
     82        </TR>   
     83
     84        <TR>
     85                <TD>
     86                    <input type="checkbox" name="concours_change_score" id="concours_change_score" {$CHANGE_SCORE} onclick="detecter()" /> {'concours_change_score'|@translate}
     87                    <br/>
     88                </TD>
    4789                <TD colspan="2">
    48                     <input type="checkbox" name="author_vote_available" {$AUTHOR_VOTE_AVAILABLE}/> {'concours_author_vote'|@translate}
     90                        <div id="text_overlay_concours">
     91                        ({'concours_overlay_text'|@translate}<textarea name="text_overlay" id ="text_overlay" rows="1" cols="10" style="width:90%;">{$TEXT_OVERLAY}</textarea>)
     92                    <br/>
     93                        </div>
     94                </TD>
     95        </TR>
     96        <TR>
     97                <TD colspan="3">
     98                  {'concours_deadline_param'|@translate}
     99                  <select id="concours_deadline" name="concours_deadline">
     100                         {foreach $DEADLINE as $DEADLINE1}
     101                          <option value="{$DEADLINE1.ID}" {$DEADLINE1.SELECTED}>{$DEADLINE1.NAME}</option>
     102                        {/foreach}
     103                  </select>
     104
     105             </TD>
     106        </TR>
     107        <TR>
     108                <TD colspan="3">
     109                    <input type="checkbox" name="mask_thumbnail" {$MASK_THUMB}/> {'mask_thumbnail'|@translate}
    49110                    <br/>
    50111                </TD>
    51112        </TR>
    52113        <TR>
    53                 <TD colspan="2">
    54                     <input type="checkbox" name="concours_change_score" {$CHANGE_SCORE}/> {'concours_change_score'|@translate}
     114                <TD colspan="3">
     115                    <input type="checkbox" name="active_global_score_page" {$GLOBAL_SCORE}/> {'concours_global_score_admin'|@translate}
    55116                    <br/>
    56117                </TD>
    57118        </TR>
     119        <TR>
     120                <TD colspan="3">
     121                  {'concours_score_mode'|@translate}
     122                  <select id="score_mode" name="score_mode">
     123                         {foreach $SCORE_MODE as $SCORE_MODE1}
     124                          <option value="{$SCORE_MODE1.ID}" {$SCORE_MODE1.SELECTED}>{$SCORE_MODE1.NAME}</option>
     125                        {/foreach}
     126                  </select>
     127
     128             </TD>
     129        </TR>
     130       
    58131</table>
     132</div>
    59133<br/>
    60134</fieldset>
     
    75149        </tr>
    76150        {if count($FILE)}
    77          {foreach from=$FILE item=FILE}
     151         {foreach $FILE as $FILE1}
    78152                <tr align="left">
    79153                        <td>
    80                                 <a href="{$FILE.LINK}">{$FILE.NAME}</a>
     154                                <a href="{$FILE1.LINK}">{$FILE1.NAME}</a>
    81155                        </td>
    82156                        <td>
    83                                 Concours <b>{$FILE.CONC_NAME}</b> {if $FILE.CONC_ID != 0}({$FILE.CONC_ID}){/if} : <i>{$FILE.CONC_DESCR}</i>
     157                                Concours <b>{$FILE1.CONC_NAME}</b> {if $FILE1.CONC_ID != 0}({$FILE1.CONC_ID}){/if} : <i>{$FILE1.CONC_DESCR}</i>
    84158                        </td>
    85159                </tr>
  • extensions/ConcoursPhoto/include/Concours.class.php

    r9370 r32457  
    1212        var $concours_infos = array();
    1313       
    14 /*      var $create_date = null;
    15         var $name = null;
    16         var $descr = null;
    17         var $begin_date = null;
    18         var $end_date = null;
    19         var $category = null;
    20         var $groups = null;
    21 */     
    22 
    2314        // General configuration parameters
    2415        var $my_config = array();
    25 /*
    26         active_menubar
    27         nbconcours_menubar
    28 */
    2916        var $user_groups = array();
    3017        var $debug = false;
    31        
    32         // Class constructor with concours id. Return NULL if not existing or create it
    33         function Concours($concours_id = null, $force_creation = NULL)
    34         {
    35 //          $this->get_user_groups();
     18
     19
     20        /**
     21         * Class constructor with concours id.
     22         * Return NULL if not existing or create it
     23         */
     24        function __construct($concours_id = null, $force_creation = NULL)
     25        {
    3626                if ($concours_id !== null)
    3727                {               
     
    4434
    4535       
    46         // Load general configuration from config_database
    47         function load_config()
    48         {
    49 
    50                 $query = '
    51                   SELECT value
    52                   FROM '.CONFIG_TABLE.'
    53                   WHERE param = \'concoursphoto\'
    54                 ;';
    55 
     36        /**
     37         * Load configuration from database
     38         * Assign value to the variable $config
     39         */
     40        function load_config() {
     41                $query = 'SELECT value FROM '.CONFIG_TABLE.' WHERE param="concoursphoto";';
    5642                $result = pwg_query($query);
    5743
    58             if($result)
    59                 {
    60                      $row = mysql_fetch_row($result);
    61                      if(is_string($row[0]))
    62                          {
    63                         $this->my_config = unserialize(($row[0]));
    64                      }
     44            if(isset($result)) {
     45                        $row = pwg_db_fetch_row($result);
     46                        if(is_string($row[0])) {
     47                                $this->my_config = unserialize(($row[0]));
     48                        }
    6549            }
    66                 $this->load_default_config();
    67         }
    68        
    69         // Initialize default values of params
     50        if ($this->debug) 
     51            foreach ($this->my_config as $key => $value)
     52                {
     53                    echo "my_config[".$key."] = ".$value."\n";
     54                }   
     55            $this->load_default_config();
     56        }
     57       
     58       
     59        /**
     60         * Load default configuration, initialize default values of params
     61         */
    7062        private function load_default_config()
    7163        {
     
    9688        }
    9789       
     90        /**
     91         * Save the current configuration (ie the value of $config) to the database
     92         */
     93        function set_config() {
     94                conf_update_param('concoursphoto', pwg_db_real_escape_string(serialize($this->my_config)));
     95        }
     96       
    9897       
    9998        // Retrieve user groups
     
    101100        {
    102101                global $user;
    103 if ($this->debug)
    104 foreach ($user as $id=>$val)
    105 {
    106         if (is_array($val))
    107                 foreach ($val as $id2=>$val2)
    108                         echo "user[".$id."][".$id2."]=".$val2."\n";
    109         else
    110                 echo "user[".$id."]=".$val."\n";
    111 }
    112 
    113102                $query = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user['id'] . ';';
    114 if ($this->debug)               echo $query."\n";
     103
    115104                $result = pwg_query($query);
    116                 while ($row = mysql_fetch_assoc($result))
     105                while ($row = pwg_db_fetch_array($result))
    117106                {
    118107                  array_push($this->user_groups, $row['group_id']);
    119108                }
    120                
    121 if ($this->debug)
    122 foreach ($this->user_groups as $gr)
    123         echo "Group=".$gr."\n";
    124109
    125110        }
     
    144129                        $result = pwg_query($query);
    145130                        if ($result)
    146                                 $this->concours_infos = mysql_fetch_assoc($result);
    147                 }
    148 
    149         }
     131                                $this->concours_infos = pwg_db_fetch_array($result);
     132                }
     133
     134        }
     135
    150136
    151137        // save informations on database for a concours_id
     
    165151                                                `groups`,
    166152                                                `method`,
    167                                                 `guest`
     153                                                `guest`,
     154                                                `admin`
    168155                       
    169156                                                )
     
    172159                                                        \"".$this->concours_infos['begin_date']."\", \"".$this->concours_infos['end_date']."\",
    173160                                                        ".$this->concours_infos['category'].", ".$this->concours_infos['groups'].",
    174                                                         ".$this->concours_infos['method'].", ".($this->concours_infos['guest'] ? "TRUE" : "FALSE")."
     161                                                        ".$this->concours_infos['method'].", ".($this->concours_infos['guest'] ? "TRUE" : "FALSE").",
     162                                                        ".($this->concours_infos['admin'] ? "TRUE" : "FALSE")."
    175163                                                        );";
    176164                        if (pwg_query($query) != null)
     
    199187                                                groups = ".$this->concours_infos['groups'].",
    200188                                                method = ".$this->concours_infos['method'].",
    201                                                 guest = ".($this->concours_infos['guest'] ? "TRUE" : "FALSE")."
     189                                                guest = ".($this->concours_infos['guest'] ? "TRUE" : "FALSE").",
     190                                                admin = ".($this->concours_infos['admin'] ? "TRUE" : "FALSE")."
    202191                                               
    203192                                                WHERE id = ".($concours_id !== NULL ? $concours_id : $this->concours_id)."
     
    245234                        $query = '
    246235                                DELETE
    247                                 FROM ' . CONCOURS_TABLE .'
    248                                 WHERE id =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . '
     236                                FROM ' . CONCOURS_RESULT_TABLE .'
     237                                WHERE id_concours =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . '
     238                                ';
     239                        pwg_query($query);
     240                        $query = '
     241                                DELETE
     242                                FROM ' . CONCOURS_DATA_TABLE .'
     243                                WHERE id_concours =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . '
    249244                                ';
    250245                        pwg_query($query);
     
    257252                        $query = '
    258253                                DELETE
    259                                 FROM ' . CONCOURS_DATA_TABLE .'
    260                                 WHERE id_concours =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . '
     254                                FROM ' . CONCOURS_TABLE .'
     255                                WHERE id =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . '
    261256                                ';
    262257                        pwg_query($query);
    263                         $query = '
    264                                 DELETE
    265                                 FROM ' . CONCOURS_RESULT_TABLE .'
    266                                 WHERE id_concours =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . '
    267                                 ';
    268                         pwg_query($query);
    269258                }
    270259                else
    271260                        return false;
    272261               
     262        }
     263
     264       
     265        // delete all closed concours from db
     266        function delete_allclosed_concours()
     267        {
     268                $concours_list=array();
     269                $query = '
     270                        SELECT id
     271                        FROM ' . CONCOURS_TABLE .'
     272                        WHERE time_to_sec(TIMEDIFF(now(), end_date)) > 0
     273                        AND  id>0;';
     274
     275                $result = pwg_query($query);
     276                while ($row = pwg_db_fetch_assoc($result))
     277                {
     278                        $this->delete_concours($row['id']);
     279                }
    273280        }
    274281
     
    288295
    289296                        $result = pwg_query($query);
    290 if ($this->debug) echo $query."\n";
    291297                        if ($result != NULL)
    292298                                return true;
     
    311317
    312318                        $result = pwg_query($query);
    313 if ($this->debug) echo $query."\n";
    314319                        if ($result != NULL)
    315320                                return true;
     
    321326        }
    322327
    323 
     328        // Get high value of concours (max score for each criterias)
     329        function get_MaxScore_concours($concours_id = null)
     330        {
     331                $max = 0;
     332                $query = '
     333                        SELECT criteria_id, max_value, ponderation, uppercriteria
     334                        FROM ' . CONCOURS_DETAIL_TABLE .'
     335                        WHERE id_concours =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . '
     336                        ORDER BY criteria_id
     337                        ';
     338                $result = pwg_query($query);
     339                while ($row = pwg_db_fetch_array($result))
     340                {
     341                        if ($row['uppercriteria'] != NULL || !$this->is_criterias_contains_sub($row['criteria_id'])) // subcriteria or uppercriteria without sub
     342                                $max += $row['max_value']*$row['ponderation'];
     343                }
     344                return $max;
     345
     346
     347        }       
     348       
    324349        // Get criterias that are stored on db for default mode (concours_id = 0)
    325350        function get_default_criterias()
     
    328353                $query = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
    329354                                        FROM ' . CONCOURS_DETAIL_TABLE . ' ;';
    330                 list($next_element_id) = mysql_fetch_array(pwg_query($query));
     355                list($next_element_id) = pwg_db_fetch_array(pwg_query($query));
    331356
    332357                foreach ($criterias as $criteria)
    333358                {               
    334 if ($this->debug)                       echo "NEXT =".$next_element_id."\n";
     359                       
    335360                        $query = 'INSERT INTO '.CONCOURS_DETAIL_TABLE.'
    336361                                                (id, id_concours, criteria_id, name, descr, min_value, max_value, ponderation, uppercriteria)'
     
    343368                       
    344369                                $result = pwg_query($query);
    345 if ($this->debug)       echo $query;                   
     370
    346371                        $next_element_id = $next_element_id +1;
    347372                }
     
    361386                                ';
    362387                        $result = pwg_query($query);
    363 if ($this->debug) echo $query."\n";
    364                         while ($row = mysql_fetch_assoc($result))
     388                        while ($row = pwg_db_fetch_array($result))
    365389                        {
    366390                                array_push($criteria_list, $row);
     
    386410                                ';
    387411                        $result = pwg_query($query);
    388 if ($this->debug) echo $query."\n";
    389                         while ($row = mysql_fetch_assoc($result))
    390                         {
    391 if ($this->debug)                       echo "criteria_id=".$row['criteria_id']."\n";
     412                       
     413                        while ($row = pwg_db_fetch_array($result))
    392414                                array_push($criteria_list, $row);
    393                         }
    394415                        return $criteria_list;
    395416                }
     
    410431                                ';
    411432                        $result = pwg_query($query);
    412 if ($this->debug) echo $query."\n";
    413                         // mini 1 line
    414                         if(mysql_fetch_assoc($result))
     433                        if(pwg_db_fetch_array($result))
    415434                                return true;
    416435                        else
     
    435454                                ';
    436455                        $result = pwg_query($query);
    437 if ($this->debug) echo $query."\n";
    438                         while ($row = mysql_fetch_assoc($result))
     456                        while ($row = pwg_db_fetch_array($result))
    439457                        {
    440458                                array_push($criteria_list, $row);
     
    460478                                ';
    461479                        $result = pwg_query($query);
    462         if ($this->debug) echo $query."\n";
    463             $criteria = mysql_fetch_assoc($result);
    464         /*              while ($row = mysql_fetch_assoc($result))
    465                         {
    466                                 array_push($criteria, $row);
    467                         }
    468 */             
     480                       
     481            $criteria = pwg_db_fetch_array($result);
    469482                }
    470483                return $criteria;
     
    483496                        ';
    484497                $result = pwg_query($query);
    485 if ($this->debug) echo $query."\n";
    486 $criteria = mysql_fetch_assoc($result);
    487 /*              while ($row = mysql_fetch_assoc($result))
    488                 {
    489                         array_push($criteria, $row);
    490                 }
    491 */             
    492         return $criteria;
     498               
     499                $criteria = pwg_db_fetch_array($result);
     500                return $criteria;
    493501       
    494502        }
     
    504512                        $query = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id
    505513                                                FROM ' . CONCOURS_DETAIL_TABLE . ' ;';
    506                         list($next_element_id) = mysql_fetch_array(pwg_query($query));
     514                        list($next_element_id) = pwg_db_fetch_array(pwg_query($query));
     515
    507516                        $query = 'SELECT IF(MAX(criteria_id)+1 IS NULL, 1, MAX(criteria_id)+1) AS next_criteria_id
    508517                                                FROM ' . CONCOURS_DETAIL_TABLE . '
    509518                                          WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ) . ' ;';
    510                         list($next_criteria_id) = mysql_fetch_array(pwg_query($query));
     519                        list($next_criteria_id) = pwg_db_fetch_array(pwg_query($query));
    511520                       
    512521                        $query = '
     
    553562
    554563                        pwg_query($query);
    555 
    556                         if ($this->debug) echo $query."\n";
    557 
    558564                }               
    559565        }
     
    573579                                ';
    574580                        $result = pwg_query($query);
    575         if ($this->debug) echo $query."\n";
     581                       
    576582                        if($result)
    577583                                return true;
     
    594600                        ';
    595601                $result = pwg_query($query);
    596 if ($this->debug) echo $query."\n";
    597602
    598603        }       
     
    608613                $result = pwg_query($query);
    609614                // For each images
    610                 if (mysql_fetch_assoc($result))
     615                if (pwg_db_fetch_array($result))
    611616                        return true;
    612617                else
     
    614619       
    615620        }
     621       
     622
     623
    616624       
    617625        // function to return the number of votes for a concours by images
     
    628636                $result = pwg_query($query);
    629637                $nbvotes = array();
    630                 while ($row = mysql_fetch_assoc($result))
     638                while ($row = pwg_db_fetch_array($result))
    631639                {
    632640                        $nbvotes[$row['img_id']] = $row['NBVOTE'];
     
    634642       
    635643        // Add guest infos
    636         $query = 'SELECT img_id, COUNT(DISTINCT user_id, ipguest) AS NBVOTE FROM ' . CONCOURS_DATA_TABLE
     644        $query = 'SELECT img_id, COUNT(DISTINCT ipguest) AS NBVOTE FROM ' . CONCOURS_DATA_TABLE
    637645        .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id )
    638646        .' AND ipguest IS NOT NULL'
     
    641649               
    642650        $result = pwg_query($query);
    643     if ($this->debug)           echo "NBVOTE = ".$query."\n";
    644         while ($row = mysql_fetch_assoc($result))
     651        while ($row = pwg_db_fetch_array($result))
     652       
    645653            if (!isset($nbvotes[$row['img_id']]))
    646654                $nbvotes[$row['img_id']] = $row['NBVOTE'];
    647655            else
    648656                $nbvotes[$row['img_id']] += $row['NBVOTE'];
    649        
     657                       
    650658                return $nbvotes;
    651659        }
    652660
     661       
     662       
     663        // Get All user that are vote  for guest who have vote (IP Stores in db) in a concours
     664        function get_user_list($concours_id = NULL)
     665        {
     666                global $conf;
     667        $userid = array();
     668                if ($concours_id!== null or $this->concours_id !== null)
     669                {
     670                        $query = '
     671                                SELECT distinct(user_id)
     672                                FROM ' . CONCOURS_DATA_TABLE .'
     673                                WHERE id_concours =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . '
     674                AND ipguest IS  NULL
     675                                AND user_id !='.$conf['guest_id']
     676
     677                                .' ORDER BY user_id
     678                                ';
     679                        $result = pwg_query($query);
     680                        while ($row = pwg_db_fetch_array($result))
     681                        {
     682                                array_push($userid, $row['user_id']);
     683                        }
     684                }
     685                return $userid;
     686        }
     687       
     688       
    653689        // Get All iaddr for guest who have vote (IP Stores in db) in a concours
    654690        function get_guest_list($concours_id = NULL)
    655691        {
     692                global $conf;
    656693        $ipguest = array();
    657694                if ($concours_id!== null or $this->concours_id !== null)
     
    660697                                SELECT distinct(ipguest)
    661698                                FROM ' . CONCOURS_DATA_TABLE .'
    662                                 WHERE id_concours =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . '
    663                 AND ipguest IS NOT NULL
     699                                WHERE id_concours =' . ($concours_id !== null ? $concours_id : $this->concours_id )
     700                .' AND user_id = '.$conf['guest_id']
     701                .' AND ipguest IS NOT NULL
    664702                                ORDER BY ipguest
    665703                                ';
    666704                        $result = pwg_query($query);
    667 if ($this->debug) echo $query."\n";
    668                         while ($row = mysql_fetch_assoc($result))
     705                        while ($row = pwg_db_fetch_array($result))
    669706                        {
    670707                                array_push($ipguest, $row['ipguest']);
     
    689726                // var which contains id=img_id and val =global note
    690727                $global_note = array();
     728                // FOR MODERATION
     729                // var which contains id=user_id and val =global note
     730                $vote_by_user = array();
     731                $amplitiudeMINmax = 999; // MIN of all max score (for each users)
     732                $amplitiudeMAXmin = -999; // MIN of all max score (for each users)
     733                $REFaverage = 0;        // reference average (average between amplitiudeMINmax and amplitiudeMAXmin)
     734                $global_note_mod1 = array();
     735                $global_note_mod2 = array();
     736               
    691737                if ($concours_id!== null or $this->concours_id !== null)
    692738                {
     
    698744                                $nbvotes = $this->nb_votes_by_img($concours_id);
    699745                               
     746               
    700747                                $user_id = array();
    701748                                // vars not initialized
     
    703750                                        $this->get_concours();
    704751                                $category = $this->concours_infos['category'];
    705 
    706 if ($this->debug)
    707         echo "CAT=".$category;
     752                               
    708753                                // Get all user_id from a concours
    709754                                $query = 'SELECT DISTINCT user_id'
     
    713758                                .';';
    714759                                $result = pwg_query($query);
    715 if ($this->debug)
    716 echo $query;
    717                                 while ($row = mysql_fetch_assoc($result))
     760
     761                                while ($row = pwg_db_fetch_array($result))
    718762                                        array_push($user_id, $row['user_id']);
    719763
    720764                // Add guest info is present
    721765                $ipguest = array();
    722                 if ($concours_id!== null)
     766                if ($concours_id!== null or $this->concours_id !== null)
     767                                {
     768                                        if ($this->debug)
     769                                                echo "Check IPGUEST";
    723770                    $ipguest = $this->get_guest_list(($concours_id !== null ? $concours_id : $this->concours_id ));
    724 
    725 if ($this->debug)
    726 {
    727         foreach ($user_id as $userid)
    728                         echo "USER = ".$userid;
    729         foreach ($ipguest as $userid)
    730                         echo "IPGUEST = ".$userid;
    731 }                               
     771                                }
     772
    732773                               
    733774                                // recover all img_id from the category
     
    736777                                .' WHERE category_id = '.$category.';';
    737778                               
     779                                $nb_image_concours = 0;
    738780                                $result = pwg_query($query);
    739781                                // For each images
    740                                 while ($row = mysql_fetch_assoc($result))
     782                                while ($row = pwg_db_fetch_array($result))
    741783                                {
    742                 if ($this->debug)       echo "IMG_ID=".$row['image_id']."\n";
     784                                        $nb_image_concours++;
     785               
    743786                                        foreach ($user_id as $i => $userid)
    744787                                        {
     788                                                $img_note_user = $this->get_img_globalnote_user($row['image_id'], null, $userid);
     789                                               
    745790                                                if (!isset($global_note[$row['image_id']]))
    746791                                                        $global_note[$row['image_id']] = 0;
    747                                                 $global_note[$row['image_id']] +=  $this->get_img_globalnote_user($row['image_id'], null, $userid);                     
     792                                        // FOR MODERATION
     793                                        // store the nb of vote for each user
     794                                                if ($img_note_user >= 0) // user has made a vote
     795                                                {
     796                                                        if (!isset($vote_by_user[$userid]['nbvote']))
     797                                                                $vote_by_user[$userid]['nbvote'] = 0;
     798                                                       
     799                                                        $vote_by_user[$userid]['nbvote'] ++;    // update vote counter
     800                                               
     801                                                        $global_note[$row['image_id']] +=  $img_note_user       ;               
     802                                               
     803
     804                                                // FOR MODERATION
     805                                                        // store the total of note for the same user
     806                                                        if (!isset($vote_by_user[$userid]['totalvote']))
     807                                                                $vote_by_user[$userid]['totalvote'] = 0;
     808                                                        $vote_by_user[$userid]['totalvote'] +=  $img_note_user;
     809                                                        // FOR MODERATION
     810                                                        // store min/max for each user
     811                                                        if (!isset($vote_by_user[$userid]['min']))      $vote_by_user[$userid]['min'] = 999;
     812                                                        if (!isset($vote_by_user[$userid]['max']))      $vote_by_user[$userid]['max'] = 0;
     813                                                       
     814                                                       
     815                                                        if ($vote_by_user[$userid]['min'] > $img_note_user) $vote_by_user[$userid]['min'] = $img_note_user;
     816                                                        if ($vote_by_user[$userid]['max'] < $img_note_user) $vote_by_user[$userid]['max'] = $img_note_user;
     817                                                }                                               
     818                                       
    748819                                        }
    749820                    // Add guest scores if present
    750                                         foreach ($ipguest as $i => $ipguestt)
     821                                        foreach ($ipguest as $i => $userid)
    751822                                        {
     823                                               
     824                                                $img_note_user = $this->get_img_globalnote_user($row['image_id'], null, null, $userid); // $userid contains the ip address for the guest!
    752825                                                if (!isset($global_note[$row['image_id']]))
    753826                                                        $global_note[$row['image_id']] = 0;
    754                                                 $global_note[$row['image_id']] +=  $this->get_img_globalnote_user($row['image_id'], null, null, $ipguestt);                     
     827
     828                                        // FOR MODERATION
     829                                        // store the nb of vote for each guest (with ipaddr)
     830                                                if ($img_note_user >= 0) // user has made a vote
     831                                                {
     832                                                        if (!isset($vote_by_user[$userid]['nbvote']))
     833                                                                $vote_by_user[$userid]['nbvote'] = 0;
     834                                                       
     835                                                        $vote_by_user[$userid]['nbvote'] ++;    // update vote counter
     836                                               
     837                                                        $global_note[$row['image_id']] +=  $img_note_user       ;               
     838                                               
     839
     840                                                // FOR MODERATION
     841                                                        // store the total of note for the same user
     842                                                        if (!isset($vote_by_user[$userid]['totalvote']))
     843                                                                $vote_by_user[$userid]['totalvote'] = 0;
     844                                                        $vote_by_user[$userid]['totalvote'] +=  $img_note_user;
     845                                                        // FOR MODERATION
     846                                                        // store min/max for each user
     847                                                        if (!isset($vote_by_user[$userid]['min']))      $vote_by_user[$userid]['min'] = 999;
     848                                                        if (!isset($vote_by_user[$userid]['max']))      $vote_by_user[$userid]['max'] = 0;
     849                                                       
     850                                                       
     851                                                        if ($vote_by_user[$userid]['min'] > $img_note_user) $vote_by_user[$userid]['min'] = $img_note_user;
     852                                                        if ($vote_by_user[$userid]['max'] < $img_note_user) $vote_by_user[$userid]['max'] = $img_note_user;
     853                                                }                                               
     854
    755855                                        }
    756856                                }
    757                                 if ($this->debug)
     857
     858                                // FOR MODERATION
     859                                // calcul the average by user and min/max global
     860                                foreach ($user_id as $i => $userid)
    758861                                {
    759                                         foreach ($global_note as $id => $val)
    760                                                 echo "Note img ( ".$id.") = ".$val."\n";
     862                                        $vote_by_user[$userid]['average'] = $vote_by_user[$userid]['totalvote']/$vote_by_user[$userid]['nbvote'];
     863                                        $vote_by_user[$userid]['lowerAmp'] = $vote_by_user[$userid]['min'];
     864                                        // calcul the max value of the concours (for the moderation)
     865                                        $vote_by_user[$userid]['upperAmp'] = $this->get_MaxScore_concours() - $vote_by_user[$userid]['max'];
     866                                       
     867                                        $vote_by_user[$userid]['minLevel'] = $vote_by_user[$userid]['average'] - $vote_by_user[$userid]['lowerAmp'];
     868                                        $vote_by_user[$userid]['maxLevel'] = $vote_by_user[$userid]['average'] + $vote_by_user[$userid]['upperAmp'];
     869                                        if ($amplitiudeMINmax > $vote_by_user[$userid]['maxLevel']) $amplitiudeMINmax = $vote_by_user[$userid]['maxLevel'];
     870                                        if ($amplitiudeMAXmin < $vote_by_user[$userid]['minLevel']) $amplitiudeMAXmin = $vote_by_user[$userid]['minLevel'];                             
    761871                                }
     872
     873                                // calcul the average by guest and min/max global
     874                                foreach ($ipguest as $i => $userid)
     875                                {
     876                                        $vote_by_user[$userid]['average'] = $vote_by_user[$userid]['totalvote']/$vote_by_user[$userid]['nbvote'];
     877                                        $vote_by_user[$userid]['lowerAmp'] = $vote_by_user[$userid]['min'];
     878                                        // calcul the max value of the concours (for the moderation)
     879                                        $vote_by_user[$userid]['upperAmp'] = $this->get_MaxScore_concours() - $vote_by_user[$userid]['max'];
     880                                       
     881                                        $vote_by_user[$userid]['minLevel'] = $vote_by_user[$userid]['average'] - $vote_by_user[$userid]['lowerAmp'];
     882                                        $vote_by_user[$userid]['maxLevel'] = $vote_by_user[$userid]['average'] + $vote_by_user[$userid]['upperAmp'];
     883                                        if ($amplitiudeMINmax > $vote_by_user[$userid]['maxLevel']) $amplitiudeMINmax = $vote_by_user[$userid]['maxLevel'];
     884                                        if ($amplitiudeMAXmin < $vote_by_user[$userid]['minLevel']) $amplitiudeMAXmin = $vote_by_user[$userid]['minLevel'];                             
     885
     886                                }
     887
     888
     889                                // FOR MODERATION
     890                                // calcul the reference average
     891                                $calcultemp = (int)($amplitiudeMINmax+$amplitiudeMAXmin)/2+0.5;
     892                                if ((int)(($amplitiudeMINmax+$amplitiudeMAXmin)/2+0.5) > $amplitiudeMAXmin)
     893                                {
     894                                        if ((int)(($amplitiudeMINmax+$amplitiudeMAXmin)/2+0.5) < $amplitiudeMINmax)
     895                                                $REFaverage = (int)(($amplitiudeMINmax+$amplitiudeMAXmin)/2+0.5);
     896                                        else
     897                                                $REFaverage = $amplitiudeMINmax;
     898                                }
     899                                else
     900                                        $REFaverage = $amplitiudeMAXmin;
     901                               
     902                                       
     903                                // FOR MODERATION
     904                                // calcul the moderation scopr for each users
     905                                foreach ($user_id as $i => $userid)
     906                                        $vote_by_user[$userid]['moderation'] = $REFaverage - $vote_by_user[$userid]['average'];
     907
     908                                // FOR MODERATION
     909                                // calcul the moderation scopr for each guest ($ipguest)
     910                                foreach ($ipguest as $i => $userid)
     911                                        $vote_by_user[$userid]['moderation'] = $REFaverage - $vote_by_user[$userid]['average'];
     912                                       
     913                                // FOR MODERATION
     914                                // need to parse again image for new calcul with moderation
     915                                // moderation 1 => For each photo without note (user = author or user != author but no vote) add each user avaerage to the total of note and calcul the average
     916                                // moderation 2 => For each photo with note, adapt/change all the value with the moderation value : user note + moderation.
     917
     918                                // parse again all img_id from the category
     919                                $query = 'SELECT DISTINCT(image_id)'
     920                                .' FROM ' .IMAGE_CATEGORY_TABLE
     921                                .' WHERE category_id = '.$category.';';
     922                               
     923                                $result = pwg_query($query);
     924                                // For each images
     925                                while ($row = pwg_db_fetch_array($result))
     926                                {
     927                                        // for each user
     928                                        foreach ($user_id as $i => $userid)
     929                                        {
     930                                                if (!isset($global_note_mod1[$row['image_id']]))
     931                                                        $global_note_mod1[$row['image_id']] = 0;
     932                                                $globalnote_user = $this->get_img_globalnote_user($row['image_id'], null, $userid, null, 1, $vote_by_user[$userid]['average']);
     933
     934                                                $global_note_mod1[$row['image_id']] += ($globalnote_user >= 0 ? $globalnote_user : 0)   ;
     935
     936                                                if (!isset($global_note_mod2[$row['image_id']]))
     937                                                        $global_note_mod2[$row['image_id']] = 0;
     938                                                $globalnote_user = $this->get_img_globalnote_user($row['image_id'], null, $userid, null, 2, $vote_by_user[$userid]['moderation']);
     939
     940                                                $global_note_mod2[$row['image_id']] +=  ($globalnote_user >= 0 ? $globalnote_user : 0)  ;               
     941                                        }
     942                                       
     943                                        // for each guest
     944                                        foreach ($ipguest as $i => $userid)
     945                                        {
     946                                                if (!isset($global_note_mod1[$row['image_id']]))
     947                                                        $global_note_mod1[$row['image_id']] = 0;
     948                                                $globalnote_user = $this->get_img_globalnote_user($row['image_id'], null, null, $userid, 1, $vote_by_user[$userid]['average']); // userid contains the ip addr for the guest
     949
     950                                                $global_note_mod1[$row['image_id']] += ($globalnote_user >= 0 ? $globalnote_user : 0)   ;
     951
     952                                                if (!isset($global_note_mod2[$row['image_id']]))
     953                                                        $global_note_mod2[$row['image_id']] = 0;
     954                                                $globalnote_user = $this->get_img_globalnote_user($row['image_id'], null, null, $userid, 2, $vote_by_user[$userid]['moderation']);
     955
     956                                                $global_note_mod2[$row['image_id']] +=  ($globalnote_user >= 0 ? $globalnote_user : 0)  ;               
     957                                        }
     958
     959                                       
     960                                }
     961                                       
    762962                               
    763963                                // update database and store result into RESULT table
    764964                                // note = global note
    765965                                $IMGmoyenne = 0;
     966                                $IMGmoyenneModeration1 = 0;
     967                                $IMGmoyenneModeration2 = 0;
     968                               
    766969                                foreach ($global_note as $id => $val)
    767970                                // id contains the image id
    768971                                {
    769 if ($this->debug)               echo $nbvotes[$id];
    770972                                        $IMGmoyenne = (isset($nbvotes[$id]) && $nbvotes[$id] != 0 ? $val/$nbvotes[$id] : 0);
     973                                        // Moderation
     974
     975                                        $IMGmoyenneModeration1 = ($nb_image_concours != 0 ? $global_note_mod1[$id]/$this->nb_user_by_concours() : 0);   // all photos have note
     976                                        $IMGmoyenneModeration2 = (isset($nbvotes[$id]) && $nbvotes[$id] != 0 ? $global_note_mod2[$id]/$nbvotes[$id] : 0);       // only voted photos are used
    771977                                       
    772                                         $query = 'INSERT INTO  ' . CONCOURS_RESULT_TABLE .'(`id_concours`, `img_id`, `date` , `note`, `moyenne`, `nbvotant` )
     978                                        $query = 'INSERT INTO  ' . CONCOURS_RESULT_TABLE .'(`id_concours`, `img_id`, `date` , `note`, `moyenne`,
     979                                        `moderation1`, `moderation2`,
     980                                        `nbvotant` )
    773981                                                        VALUES ('.($concours_id !== null ? $concours_id : $this->concours_id )
    774982                                                                         .', '.$id
     
    776984                                                                         .', '.$val
    777985                                                                         .', '.$IMGmoyenne
     986                                                                         .', '.$IMGmoyenneModeration1
     987                                                                         .', '.$IMGmoyenneModeration2
    778988                                                                         .', '.(isset($nbvotes[$id]) ? $nbvotes[$id] : 0)
    779989                                                                         .');';
    780                                 $result = pwg_query($query);
    781                                                  
     990                                $result = pwg_query($query);     
    782991                                       
    783992                                }
    784            
    785                                
    786 
    787                                
    788993                        }
    789994                        else
     
    794999        }
    7951000       
    796 
    797         // Check if an image's author is the same as the actual user
     1001       
     1002        // Get array with nb of vote for each user of a concours_id
     1003        function nb_user_by_concours($concours_id = NULL)
     1004        {
     1005                $nbusertotal = 0;
     1006                // user
     1007                $query = 'SELECT count(distinct(user_id)) as nb_user FROM ' . CONCOURS_DATA_TABLE .'
     1008                                WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id).'
     1009                                AND ipguest IS NULL
     1010                          ;';
     1011                $result = pwg_query($query);
     1012                if ($result)
     1013                {
     1014                        $row = pwg_db_fetch_array($result);
     1015                        $nbusertotal += $row['nb_user'];
     1016                }
     1017                // guest
     1018                $query = 'SELECT count(distinct(ipguest)) as nb_user FROM ' . CONCOURS_DATA_TABLE .'
     1019                                WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id).'
     1020                                AND ipguest IS NOT NULL
     1021                          ;';
     1022                $result = pwg_query($query);
     1023                if ($result)
     1024                {
     1025                        $row = pwg_db_fetch_array($result);
     1026                        $nbusertotal +=  $row['nb_user'];
     1027                }
     1028                return $nbusertotal;
     1029               
     1030        }
     1031       
     1032       
     1033        // Check if an image's author OR addebBy is the same as the actual user
     1034        // depending the config param
    7981035        function check_img_user($img_id)
    7991036        {
    8001037                global $user;
     1038
     1039
    8011040                $query = '
    802                         SELECT author
     1041                        SELECT author, added_by
    8031042                        FROM ' . IMAGES_TABLE .'
    8041043                        WHERE id =' . $img_id . '
     
    8091048                if ($result)
    8101049                {
    811                         $row = mysql_fetch_assoc($result);
     1050                        $row = pwg_db_fetch_array($result);
    8121051                        $authorid = get_userid($row['author']);
    813                         if ($authorid and ($authorid == $user['id']))
    814                                 return true;
    815                         else
    816                                 return false;
     1052                        $addedbyid = $row['added_by'];
     1053
     1054                        switch ($this->my_config['author_vote_available'])
     1055                        {
     1056                       
     1057                                case 0 : // no check (allow to vote for all photos)
     1058                                        return false;
     1059                                       
     1060                                case 1 : // check between author and user
     1061                                        if ($authorid)  // Author name present as username
     1062                                        {
     1063                                                if ($authorid == $user['id'])
     1064                                                        return true;
     1065                                                else
     1066                                                        return false;
     1067                                        }
     1068                                        else
     1069                                        {
     1070                                                // check if author name = user name
     1071                                                $AuthorArray = strip_punctuation2($row['author']);
     1072                                                $UserArray = strip_punctuation2($user['username']);
     1073                                                // Patch if author is empty
     1074                                                if (empty($AuthorArray))
     1075                                                        return false;
     1076                               
     1077                                                if (count(array_intersect($AuthorArray, $UserArray)) == count ($AuthorArray)) // found                         
     1078                                                        return true;
     1079                                                else
     1080                                                        return false;
     1081                                        }
     1082       
     1083                                       
     1084                                case 2 : // check between author and user
     1085                                        if (isset($addedbyid) AND $addedbyid == $user['id'])
     1086                                                return true;
     1087                                        else
     1088                                                return false;
     1089                                case 3 : // check between author OR addedby and user
     1090                                        // Check Author
     1091                                        if ($authorid AND $authorid == $user['id'])     // Author name present as username
     1092                                                        return true;
     1093                                        else
     1094                                        {
     1095                                                // check if author name = user name
     1096                                                $AuthorArray = strip_punctuation2($row['author']);
     1097                                                $UserArray = strip_punctuation2($user['username']);                                                             
     1098                                                if (empty($AuthorArray) AND (count(array_intersect($AuthorArray, $UserArray)) == count ($AuthorArray))) // found                               
     1099                                                        return true;
     1100                                        }                       
     1101                                        // check addebBy
     1102                                        if (isset($addedbyid) AND $addedbyid == $user['id'])
     1103                                                return true;
     1104       
     1105                                        return false;
     1106
     1107                                default :
     1108                                        return false;
     1109                               
     1110                        }
     1111
    8171112                }
    8181113                return false;
    819        
    8201114        }
    8211115       
     
    8261120                // Step0 : if user = guest, check the concours param and store ip address to user name.
    8271121                // Step1 : concours is defined to this category AND concours is open AND user is authorized to access to this category (thru group)
    828                 // Step1 bis : dont show concours if img_author = user_id
     1122                // Step1 bis : dont show concours if check author or added_by id is the samie as used_id (depending the param)
    8291123                // Step 2 : Recover stored informations in db for this user
    8301124                // Step 3 : Complete tpl information
     
    8391133
    8401134        // STEP 0
    841 if ($this->debug)       echo "STEP0\n";
    842 
    843     $user['ipguest'] = null;
    844 
    845     echo "user id=".$user['id'];
    846     // Check if the user is a guest only
    847     if (is_a_guest())
    848     {
    849         if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
    850             $IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
    851         elseif(isset($_SERVER['HTTP_CLIENT_IP']))   
    852             $IP = $_SERVER['HTTP_CLIENT_IP'];   
    853         else
    854             $IP = $_SERVER['REMOTE_ADDR']; 
    855              
    856         // store ip
    857         $user['ipguest'] = $IP;
    858 if ($this->debug)           
    859     echo "user ip guest=".$user['ipguest'];
    860 
    861 }
    862 
    863 
    864                
    865 // DEBUG
    866 if ($this->debug)
    867 {
    868     foreach ($user as $id=>$val)
    869     {
    870         if (is_array($val))
    871             foreach ($val as $id2=>$val2)
    872                 echo "user[".$id."][".$id2."]=".$val2."\n";
    873         else
    874             echo "user[".$id."]=".$val."\n";
    875     }
    876 }
    877 
    878 //  END DEBUG
     1135                $user['ipguest'] = null;
     1136
     1137                // Check if the user is a guest only
     1138                if (is_a_guest())
     1139                {
     1140                        if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
     1141                                $IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
     1142                        elseif(isset($_SERVER['HTTP_CLIENT_IP']))   
     1143                                $IP = $_SERVER['HTTP_CLIENT_IP'];   
     1144                        else
     1145                                $IP = $_SERVER['REMOTE_ADDR']; 
     1146                                 
     1147                        // store ip
     1148                        $user['ipguest'] = $IP;
     1149                }
    8791150       
    8801151       
    881 // DEBUG
    882 if ($this->debug)
    883 foreach ($page as $id=>$val)
    884 {
    885         if (is_array($val))
    886                 foreach ($val as $id2=>$val2)
    887                         echo "page[".$id."][".$id2."]=".$val2."\n";
    888         else
    889                 echo "page[".$id."]=".$val."\n";
    890 }
    891 //  END DEBUG
    892 
    893         // disable author name  on image which are present in a concours.
    894         // check the categories where the current image is present and disable the author name
     1152                // disable author name  on image which are present in a concours.
     1153                // check the categories where the current image is present and disable the author name
    8951154                if (isset($this->my_config['mask_author']) && $this->my_config['mask_author'] == true)
    8961155                {
     
    9021161                          WHERE image_id = '.$page['image_id'].'
    9031162                          ;';
    904 //                     echo $query;
    9051163                        $result = pwg_query($query);
    9061164                        $related_categories = array();
    907                         while ($row = mysql_fetch_array($result))
     1165                        while ($row = pwg_db_fetch_array($result))
    9081166                        {
    9091167                          array_push($related_categories, $row['category_id']);
     
    9201178                    AND time_to_sec(TIMEDIFF(now(), end_date)) < 0
    9211179                ';
    922         //                echo $query;
    9231180                $result = pwg_query($query);
    9241181                // If one or more concours are found, the author name is masked
    925                 if ($result && mysql_fetch_assoc($result))
    926                 {
    927                     $template->assign('INFO_AUTHOR',l10n('concours_img_author'));
    928                 }
    929             }
    930                 }
    931 
    932         // End disable author name
    933 
    934 
    935                 if (($page['section']) == 'categories' AND !empty($page['category']))
    936                 {
    937 if ($this->debug)       echo "STEP1\n";
    938                         //------------
    939                         // Step 1
    940 
    941 /*           
    942             if ($this->my_config['mask_author'] && $this->my_config['mask_author'] == true)
    943             {
    944                 // Request for all concours prepared & actived
    945                 $query = '
    946                     SELECT *
    947                     FROM ' . CONCOURS_TABLE .'
    948                     WHERE category =' . $page['category']['id'] . '
    949                     AND time_to_sec(TIMEDIFF(now(), end_date)) < 0
    950                                 ';
    951 //                echo $query;
    952                 $result = pwg_query($query);
    953                 if ($result && mysql_fetch_assoc($result))
     1182                if ($result && pwg_db_fetch_array($result))
    9541183                    $template->assign('INFO_AUTHOR',l10n('concours_img_author'));
    9551184            }
    956 */
     1185                }
     1186
     1187        // End disable author name
     1188
     1189
     1190                if (($page['section']) == 'categories' AND !empty($page['category']))
     1191                {
     1192                        // Step 1
    9571193           
    9581194                        $query = '
     
    9651201
    9661202                        $result = pwg_query($query);
    967 if ($this->debug) echo $query."\n";
    968                         while ($row = mysql_fetch_assoc($result))
     1203
     1204                        while ($row = pwg_db_fetch_array($result))
    9691205                        {
    970                                 if (!empty($row['groups']))
     1206                                if (!is_a_guest() AND !empty($row['groups']))
    9711207                                {
    972 if ($this->debug)       echo "GROUPS=".$row['groups'];                         
    973                                         $authorized_groups = explode(',', $row['groups']);
    974                                         if (array_intersect($this->user_groups, $authorized_groups) == array())
    975                                         {
    976 if ($this->debug)       echo "ERROR GROUPS";
    977                                                 continue;
     1208
     1209                                        if (is_admin() AND $row['admin'])       // allow admin
     1210                                                $concours = $row;
     1211                                        else
     1212                                        {               
     1213                                                $authorized_groups = explode(',', $row['groups']);
     1214                                                if (array_intersect($this->user_groups, $authorized_groups) == array())
     1215                                                        continue;
     1216                                                // If no group is parameter for that concours  ==> available for all registered users
     1217                                                $concours = $row;
    9781218                                        }
    979                     // If no group is parameter for that concours  ==> available for all registered users
    980                                         $concours = $row;
    9811219                                }
    982                 else
     1220                else
     1221                                       
    9831222                                        $concours = $row;
    984 
    985 
    9861223                        }
    987 
    988 if ($this->debug)       echo "STEP1 bis\n";
    9891224                        //------------
    9901225                        // Step 1 bis
    9911226                        // Actual user is  the author of the picture ==>end
    992                         if ( !$this->my_config['author_vote_available']
    993                 AND $this->check_img_user($page['current_item']))
     1227                        // for the image, check (depending the config) if user = author or addedby or none
     1228                        if ($this->check_img_user($page['current_item']))
    9941229                                return;
    995                        
    996 
    997 if ($this->debug)       echo "STEP2\n";
     1230                               
     1231                        // Check if user is guest and if guest is allowed
     1232                        if (is_a_guest() AND array_key_exists('guest', $concours) AND !$concours['guest'])
     1233                                return;
     1234                        // Check if user is admin and if admin is allowed
     1235                        if (is_admin() AND (!isset($concours['admin']) OR (isset($concours['admin']) AND !$concours['admin'])))
     1236                                return;
     1237                       
    9981238                        //------------
    9991239                        // Step 2
     
    10031243                                if (isset($_POST['concours_submit']))
    10041244                                {
    1005                 
     1245         
    10061246//                    array_push($page['infos'] , l10n('concours_vote_saved'));
    10071247                   
    10081248                                        $user_note = "";
    1009                 if ($this->debug)                       echo "SUBMIT";
    1010                                 // concat all the notes to save on db
    1011                                
     1249                                       
     1250                                        // concat all the notes to save on db
    10121251                                        $firstcriterias = $this->get_firstlevel_criterias($concours['id']);
    10131252                                        foreach ($firstcriterias as $criteria)
    10141253                                        {
    1015                                                
    10161254                                                // First without sub criterias
    10171255                                                if (!$this->is_criterias_contains_sub($criteria['criteria_id'],$concours['id'] ))
    10181256                                                {
    10191257                                                        // Check value
    1020                                                         $value = str_replace(",",".",$_POST[$criteria['criteria_id']]);
     1258                                                        $value = str_replace(",",".",(isset($_POST[$criteria['criteria_id']]) ? $_POST[$criteria['criteria_id']] : floatval($criteria['min_value'])));
    10211259                                                        $value = str_replace(" ","",$value);
    10221260                                                        $value = floatval($value);
     
    10341272                                                        {
    10351273                                                                // Check value
    1036                                                                 $value = str_replace(",",".",$_POST[$subcriteria['criteria_id']]);
     1274                                                                $value = str_replace(",",".",(isset($_POST[$subcriteria['criteria_id']]) ? $_POST[$subcriteria['criteria_id']] : floatval($subcriteria['min_value'] )));
    10371275                                                                $value = str_replace(" ","",$value);
    10381276                                                                $value = floatval($value);
     
    10471285                                        }
    10481286                               
    1049 //                              $datas = "0=0";
    10501287                                        $this->store_img_note_user($page['current_item'], $user_note, $concours['id'], $user['ipguest']);
    1051 if ($this->debug)       echo "COMMENT=".$_POST['CONCOURS_COMMENT'];
    10521288                                        $this->store_img_comment_user($page['current_item'], $_POST['concours_comment'], $concours['id'], $user['ipguest']);
    10531289                                }
     
    10561292                                if (isset($_POST['concours_raz']))
    10571293                                {
    1058 if ($this->debug)                       echo "RAZ";                             
    1059                                         $this->RAZ_img_note_user($page['current_item'], $concours['id'], $user['ipguest']);
     1294                                        $this->delete_img_note_user($page['current_item'], $concours['id'], $user['ipguest']);
     1295                                        $user_notes = array();
    10601296                                }
    10611297                                else
     
    10681304                                $comment = $this->get_img_comment_user($page['current_item'], $concours['id'], $user['id'], $user['ipguest']);
    10691305
    1070 if ($this->debug)       echo "STEP3\n";
    10711306                                //------------
    10721307                                // Step 3
     
    10751310                                foreach ($firstcriterias as $criteria)
    10761311                                {
    1077 if ($this->debug)                                       echo "criteriaID=".$criteria['criteria_id']."\n";
    10781312                                        // First without sub criterias
    10791313                                        if (!$this->is_criterias_contains_sub($criteria['criteria_id'],$concours['id'] ))
     
    11021336                                                foreach ($secondcriterias as $subcriteria)
    11031337                                                {
    1104 if ($this->debug)                                                       echo "subcriteriaID=".$criteria['criteria_id']."\n";
    11051338                                                        $template->append( 'concours_criteria', array(
    11061339                                                                        'nosub' => true,
     
    11231356                                // if a user has already vote for this photo, check if the score change is allowed
    11241357
    1125 if ($this->debug)           echo "change=".($this->my_config['concours_change_score'] ? "OK" : "KO");
     1358
    11261359                if ($user_notes == array() OR $this->my_config['concours_change_score'])  // Allow user to change his vote after a validation
    11271360                    $template->assign( 'CONCOURS_CHANGE_SCORE', true);
     
    11291362                    $template->assign( 'CONCOURS_CHANGE_SCORE', false);
    11301363               
    1131                                
     1364                                $noteuser = $this->get_img_globalnote_user($page['current_item'], $concours['id'], null, $user['ipguest']);
    11321365                                // Add concours informations on template
    11331366                                $template->assign( 'concours_infos', array(
    11341367                                                        'name'  => $concours['name'],
    11351368                                                        'descr' => $concours['descr'],
    1136                             'note'  => $this->get_img_globalnote_user($page['current_item'], $concours['id'], null, $user['ipguest'])
     1369                            'note'  => ($noteuser >= 0 ? $noteuser : 0 ),
     1370                                                        'begin_date' => $concours['begin_date'],
     1371                                                        'end_date' => $concours['end_date'],
     1372                                                        'end_concours_min' => (strtotime($concours['end_date'])-time()) ,
     1373                                                        'max_note' => $this->get_concours_maxnote($concours['id']),
     1374                                                        'deadline_type' => $this->my_config['concours_deadline']
    11371375                                                                ));
    11381376                               
     1377
     1378                                $template->assign( 'SCORE_MODE', $this->my_config['score_mode']);
     1379                                $template->assign( 'TEXT_OVERLAY', $this->my_config['text_overlay']);
    11391380                       
    11401381                                $template->set_filenames(array('concours' =>  CONCOURS_ROOT.'/template/concours.tpl'));
    1141 //                              $template->concat('PLUGIN_PICTURE_AFTER', $template->parse('concours', true));
    11421382                                $template->concat('COMMENT_IMG', $template->parse('concours', true));
    11431383
    1144                                 //
    11451384                                $template->assign('INFO_AUTHOR',l10n('concours_img_author'));
    11461385                        }
     
    11481387        }
    11491388
     1389       
     1390        // RAZ notation from user to db
     1391        // fill criterias notes to 0 in DB
     1392        // return false if error
     1393        function delete_img_note_user($img_id, $concours_id = NULL, $ipguest = null, $userid=null)
     1394        {
     1395                global $user;
     1396               
     1397                if ($concours_id === null)
     1398                        if ($this->concours_id !== null)
     1399                                $concours_id = $this->concours_id;
     1400                        else
     1401                                return false;
     1402                               
     1403                $query = '
     1404                DELETE FROM ' . CONCOURS_DATA_TABLE .'
     1405                WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ).'
     1406                AND user_id = '.($userid == null ? $user['id'] : $userid).'
     1407                AND img_id = '.$img_id.
     1408                ($ipguest ? ' AND ipguest = "'.$ipguest.'"' : '')           
     1409                .';';
     1410
     1411                return pwg_query($query);
     1412
     1413        }
     1414       
     1415       
    11501416        // RAZ notation from user to db
    11511417        // fill criterias notes to 0 in DB
     
    11631429                foreach ($firstcriterias as $criteria)
    11641430                {
    1165 if ($this->debug)                                       echo "ID=".$criteria['criteria_id']."\n";
    11661431                        // First without sub criterias
    11671432                        if (!$this->is_criterias_contains_sub($criteria['criteria_id'],$concours_id ))
    1168                         {
    11691433                                $user_note .= (strlen($user_note) != 0 ? ";" : "").$criteria['criteria_id']."=".$criteria['min_value'];
    1170                         }
    11711434                        else
    11721435                        {
    11731436                                $secondcriterias = $this->get_subcriterias($criteria['criteria_id'], $concours_id );
    11741437                                foreach ($secondcriterias as $subcriteria)
    1175                                 {
    1176 if ($this->debug)                                                       echo "ID=".$criteria['criteria_id']."\n";
    11771438                                        $user_note .= (strlen($user_note) != 0 ? ";" : "").$subcriteria['criteria_id']."=".$subcriteria['min_value'];
    1178                                 }
    11791439                        }
    11801440                }
    1181 if ($this->debug)       echo "RAZ=>".$user_note."\n";
    11821441                if (strlen($user_note) != 0)
    11831442                {
     
    11871446                else
    11881447                        return false;
    1189                                
    1190 
    11911448        }
    11921449
     
    11991456                {
    12001457                        $query = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id  FROM ' . CONCOURS_DATA_TABLE . ' ;';
    1201                         list($next_element_id) = mysql_fetch_array(pwg_query($query));
    1202 if ($this->debug)       echo "Next_element=".$next_element_id."\n";
     1458                        list($next_element_id) = pwg_db_fetch_array(pwg_query($query));
     1459
    12031460                        $query = '
    12041461                        INSERT INTO ' . CONCOURS_DATA_TABLE .'
     
    12291486            .';';
    12301487                }
    1231 if ($this->debug)                       echo $query."\n";
    1232                         pwg_query($query);
     1488                pwg_query($query);
    12331489       
    12341490        }
     
    12401496        function get_img_note_user($img_id, $concours_id = NULL, $user_id = null, $ipguest = null)
    12411497        {
    1242                 global $user;
     1498                global $user, $conf;
    12431499                $img_note = array();
    12441500                if ($concours_id!== null or $this->concours_id !== null)
     
    12471503                        SELECT datas
    12481504                        FROM ' . CONCOURS_DATA_TABLE .'
    1249                         WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id) . '
    1250                         AND user_id = '. ($user_id !== null ? $user_id : $user['id']).'
    1251                         AND img_id = '. $img_id .
    1252             ($ipguest ? ' AND ipguest = "'.$ipguest.'"' : '')
     1505                        WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id)
     1506                        . ($ipguest == null ? ' AND user_id = '. ($user_id !== null ? $user_id : $user['id'])
     1507                           : ' AND user_id = '.$conf['guest_id'] .' AND ipguest = "'.$ipguest.'"')
     1508                        .' AND img_id = '. $img_id
    12531509                        .';';
    1254 if ($this->debug)                       echo $query."\n";
    1255                         $result = pwg_query($query);
    1256                        
    1257                         while ($row = mysql_fetch_assoc($result))
    1258                         {
    1259 if ($this->debug)                               echo "row[data]=".$row['datas']."\n";
    1260                                 $datas = explode(";",$row['datas']);
    1261                                 foreach ($datas as $val)
    1262                                 {
    1263                                         if (strpos($val, '=') !== FALSE)
    1264                                                 $img_note[substr($val, 0, strpos($val, '='))]=substr($val, strpos($val, '=')+1);
    1265                                 }
    1266                         }
    1267 // DEBUG
    1268 if ($this->debug)
    1269 foreach ($img_note as $id=>$val)
    1270 {
    1271         if (is_array($val))
    1272                 foreach ($val as $id2=>$val2)
    1273                         echo "img_note[".$id."][".$id2."]=".$val2."\n";
    1274         else
    1275                 echo "img_note[".$id."]=".$val."\n";
    1276 }
    1277 //  END DEBUG
    1278                        
    1279                         return $img_note;
    1280                 }
    1281                 else
    1282                         return array();
    1283                
    1284                
    1285         }
    1286 
    1287        
    1288         // get notation's user from db
    1289         // Return the global note for a picture id from a user
    1290         function get_img_globalnote_user($img_id, $concours_id = NULL, $user_id = null, $ipguest = null)
    1291         {
    1292                 global $user;
    1293                 $img_note = array();
    1294                 $global_user_note = 0;
    1295                 if ($concours_id!== null or $this->concours_id !== null)
    1296                 {
    1297                         $query = '
    1298                         SELECT datas
    1299                         FROM ' . CONCOURS_DATA_TABLE .'
    1300                         WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id) . '
    1301                         AND user_id = '. ($user_id !== null ? $user_id : $user['id']).'
    1302                         AND img_id = '. $img_id .
    13031510            ($ipguest ? ' AND ipguest = "'.$ipguest.'"' : '')
    13041511                        .';';
    13051512                        $result = pwg_query($query);
    13061513                       
    1307                         while ($row = mysql_fetch_assoc($result))
     1514                        while ($row = pwg_db_fetch_array($result))
     1515
    13081516                        {
    13091517                                $datas = explode(";",$row['datas']);
     
    13151523                        }
    13161524                       
     1525                        return $img_note;
     1526                }
     1527                else
     1528                        return array();
     1529        }
     1530
     1531
     1532
     1533        // Return the max note for a concours
     1534        function get_concours_maxnote($concours_id = NULL)
     1535        {
     1536
     1537                if ($concours_id!== null or $this->concours_id !== null)
     1538                {
     1539                        $query = '
     1540                        SELECT SUM(max_value) AS TOTAL
     1541                        FROM ' . CONCOURS_DETAIL_TABLE .'
     1542                        WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id)
     1543                        .' AND uppercriteria IS NULL'
     1544                        .';';
     1545                       
     1546                        $result = pwg_query($query);
     1547                        if ($this->debug)                                       echo "query=".$query."<br>\n";
     1548                       
     1549                        if ($row = pwg_db_fetch_array($result))
     1550                        {
     1551                                return $row['TOTAL'];
     1552                        }
     1553                        else
     1554                        return -1;
     1555                       
     1556                }
     1557
     1558       
     1559        }
     1560
     1561
     1562       
     1563        // get notation's user from db
     1564        // Return the global note for a picture id from a user
     1565        // if moderationMode = 1, the 'moderation' contains the GlobalAverage for all the concours
     1566        // if moderationMode = 2, the 'moderation' contains the user moderation for all image that are voted by
     1567        // return -1 if there is no vote for that user
     1568        function get_img_globalnote_user($img_id, $concours_id = NULL, $user_id = null, $ipguest = null, $moderationMode = 0, $moderation = 0)
     1569        {
     1570                global $user, $conf;
     1571                $img_note = array();
     1572                $global_user_note = -1;
     1573                $note_found = false;
     1574                if ($concours_id!== null or $this->concours_id !== null)
     1575                {
     1576                        $query = '
     1577                        SELECT datas
     1578                        FROM ' . CONCOURS_DATA_TABLE .'
     1579                        WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id)
     1580                        . ($ipguest == null ? ' AND user_id = '. ($user_id !== null ? $user_id : $user['id'])
     1581                           : ' AND user_id = '.$conf['guest_id'] .' AND ipguest = "'.$ipguest.'"')
     1582                        .' AND img_id = '. $img_id
     1583                        .';';
     1584                        $result = pwg_query($query);
     1585                        if ($this->debug)                                       echo "query=".$query."<br>\n";
     1586                       
     1587                        while ($row = pwg_db_fetch_array($result))
     1588                        {
     1589                                $global_user_note = 0; // init note if one vote is present
     1590                                $note_found = true;
     1591                                $datas = explode(";",$row['datas']);
     1592                                foreach ($datas as $val)
     1593                                {
     1594                                        if (strpos($val, '=') !== FALSE)
     1595                                                $img_note[substr($val, 0, strpos($val, '='))]=substr($val, strpos($val, '=')+1);
     1596                                }
     1597                        }
     1598                       
    13171599                        $firstcriterias = $this->get_firstlevel_criterias($concours_id);
    13181600                        foreach ($firstcriterias as $criteria)
    13191601                        {
    1320 if ($this->debug)                                       echo "criteriaID=".$criteria['criteria_id']."\n";
    13211602                                // First without sub criterias
    13221603                                if (!$this->is_criterias_contains_sub($criteria['criteria_id'],$concours_id ))
     
    13271608                                else
    13281609                                {
    1329 
    13301610                                        $secondcriterias = $this->get_subcriterias($criteria['criteria_id'], $concours_id );
    13311611                                        foreach ($secondcriterias as $subcriteria)
    13321612                                        {
    1333 if ($this->debug)                                                       echo "subcriteriaID=".$subcriteria['criteria_id']."\n";
    13341613                                                if (isset($img_note[$subcriteria['criteria_id']]))
    13351614                                                $global_user_note += (int)$subcriteria['ponderation'] * (float)$img_note[$subcriteria['criteria_id']];
    13361615                                        }
    13371616                                }
    1338 
    13391617                        }
    13401618                       
     1619                        // MODERATION
     1620                                // moderation 1 => For each photo without note (user = author or user != author but no vote) add each user avaerage to the total of note and calcul the average
     1621                                // moderation 2 => For each photo with note, adapt/change all the value with the moderation value : user note + moderation.
     1622                       
     1623                        if ($user_id !== null) // only for user
     1624                        {
     1625                                if ($moderationMode == 1 && !$note_found)
     1626                                {               // Moderation1
     1627                                        $global_user_note = $moderation;
     1628                                }
     1629                                elseif ($moderationMode == 2 && $note_found)
     1630                                {       // Moderation2
     1631                                        $global_user_note += $moderation;
     1632                                }               
     1633                               
     1634                               
     1635                        }
    13411636                        return $global_user_note;
    13421637                }
     
    13541649                {
    13551650                        $query = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id  FROM ' . CONCOURS_DATA_TABLE . ' ;';
    1356                         list($next_element_id) = mysql_fetch_array(pwg_query($query));
    1357 if ($this->debug)       echo "Next_element=".$next_element_id."\n";
     1651                        list($next_element_id) = pwg_db_fetch_array(pwg_query($query));
     1652
    13581653                        $query = '
    13591654                        INSERT INTO ' . CONCOURS_DATA_TABLE .'
     
    13811676            .';';
    13821677                }
    1383 if ($this->debug)                       echo $query."\n";
    13841678                        pwg_query($query);
    1385        
    13861679        }
    13871680       
     
    14021695            ($ipguest ? ' AND ipguest = "'.$ipguest.'"' : '')
    14031696                        .';';
    1404 if ($this->debug)                       echo $query."\n";
     1697
    14051698                        $result = pwg_query($query);
    14061699                       
    1407                         while ($row = mysql_fetch_assoc($result))
    1408                         {
    1409 if ($this->debug)                               echo "row[comment]=".$row['comment']."\n";
     1700                        while ($row = pwg_db_fetch_array($result))
    14101701                                $datas = $row['comment'];
    1411                         }
    14121702                }
    14131703                return $datas;
     
    14411731                // For each images
    14421732                $rang = 1;
    1443                 while ($row = mysql_fetch_assoc($result))
     1733                while ($row = pwg_db_fetch_array($result))
    14441734                {
    14451735                        $file .= ($row['nbvotant'] != 0 ? $rang : 'N/A').', '
     
    14671757        {
    14681758        global $conf;
     1759                $MethodType = "0";
    14691760                if ($concours_id === null)
    14701761                        $concours_id = $this->concours_id;
     
    14951786                        $ident1++;
    14961787                }
    1497 if ($this->debug)       echo "CRITERIA_LIST=".$criteria_list."\n";     
    14981788                $user_list = array();
    14991789                $users_criteria = "";
     
    15111801                $result = pwg_query($query);
    15121802                // For each user
    1513                 while ($row = mysql_fetch_assoc($result))
     1803                while ($row = pwg_db_fetch_array($result))
    15141804                {
    15151805                        array_push($user_list, $row);
    15161806                        $users_criteria .= (strlen($users_criteria) ? "," : "")."user, user_global_note, comment, ".$criteria_list;
    1517                        
    15181807                }
    15191808       
     
    15301819        }
    15311820
    1532 if ($this->debug)       echo "users_criteria=".$users_criteria."\n";   
    15331821               
    15341822                // All informations in csv format
    1535                 $file = "rang, id_concours, method, nom_concours, date_debut, date_fin, date_export, img_id, img_name, img_file, img_author, note, moyenne, nbvotant, datas,"
     1823                $file = "rang, id_concours, method, nom_concours, date_debut, date_fin, date_export, img_id, img_name, img_file, img_author, note, moyenne, moderation1, moderation2, nbvotant, datas,"
    15361824                .$users_criteria
    15371825                ."\r\n";
     
    15421830                $nbvotes = $this->nb_votes_by_img($concours_id);
    15431831
    1544                
    15451832                // recover all img_id from the category
    15461833                if (!(isset($this->concours_infos['method'])))
    15471834                        $this->concours_infos['method'] = 1;
    1548                 $query = 'SELECT id_concours, method, img_id, IMG.name, IMG.file, IMG.author, date, note, moyenne, nbvotant, datas, comment'
     1835                $query = 'SELECT id_concours, method, img_id, IMG.name, IMG.file, IMG.author, date, note, moyenne, moderation1, moderation2, nbvotant, datas, comment'
    15491836                .' FROM ' .CONCOURS_RESULT_TABLE
    15501837                .' INNER JOIN ' . CONCOURS_TABLE.' AS CONC on CONC.id = id_concours'
     
    15521839                .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id );
    15531840               
    1554                 if ($this->concours_infos['method'] == 1)       // total
     1841                switch ($this->concours_infos['method'])
     1842                {
     1843                case 1 :        // total
    15551844                        $query .= ' ORDER BY note DESC';
    1556                 elseif ($this->concours_infos['method'] == 2)   // moyenne
     1845                        $MethodType = "1-Sum";
     1846                        break;
     1847                case  2 :       // moyenne
    15571848                        $query .= ' ORDER BY moyenne DESC';
    1558                
     1849                        $MethodType = "2-Average";
     1850                        break;
     1851                case  3 :       // moderation1
     1852                        $query .= ' ORDER BY moderation1 DESC';
     1853                        $MethodType = "3-Average(Mod1)";
     1854                        break;
     1855                case  4 :       // moderation2
     1856                        $query .= ' ORDER BY moderation2 DESC';
     1857                        $MethodType = "4-Average(Mod2)";
     1858                        break;
     1859                }
     1860                               
    15591861                $query .=';';
    15601862               
    1561 if ($this->debug)               echo $query;
    15621863                $result = pwg_query($query);
    15631864                // For each images
     
    15651866        $previousNote = $previousMoy = 0;
    15661867
    1567                 while ($row = mysql_fetch_assoc($result))
     1868                while ($row = pwg_db_fetch_array($result))
    15681869                {
    15691870            // Check and verify for exaequo
     
    15751876                          AND ($row['moyenne'] == $previousMoy)))
    15761877                {
    1577                     $rang --;
    1578                    
     1878                    $rang --;         
    15791879                }
    15801880            }
     
    15821882                        $file .= ($row['nbvotant'] != 0 ? $rang : 'N/A').', '
    15831883                                        .$row['id_concours'].', '
    1584                                         .$row['method'].', '
     1884                                        .$MethodType.', '
    15851885                                        .str_replace(",", "",$this->concours_infos['name']).', '
    15861886                                        .$this->concours_infos['begin_date'].', '
     
    15941894                                        .$row['note'].', '
    15951895                                        .$row['moyenne'].', '
     1896                                        .$row['moderation1'].', '
     1897                                        .$row['moderation2'].', '
    15961898                                        .$row['nbvotant'].', '
    1597 //                                      .(isset($nbvotes[$row['img_id']]) ? $nbvotes[$row['img_id']] : 0).', '
    15981899                                        .($row['datas'] != null ? $row['datas'] : '')
    15991900                                        ;
     
    16051906                                $user_note = $this->get_img_note_user($row['img_id'], $concours_id, $uuser['user_id']);
    16061907                               
    1607                                 $file .= ', '.$uuser['username'].', '.$this->get_img_globalnote_user($row['img_id'], $concours_id, $uuser['user_id'])
    1608 //                                              .', '.($row['comment'] != null ? str_replace(",", "",$row['comment']) : '')
     1908                                $user_global_note = $this->get_img_globalnote_user($row['img_id'], $concours_id, $uuser['user_id']);
     1909                                $file .= ', '.$uuser['username'].', '.($user_global_note >= 0 ? $user_global_note  : 0)
    16091910                                                .', '.($comment != false ? str_replace(array(",","\r\n", "\n", "\r"), " ",$comment) : '')
    16101911                                                .', '
     
    16421943                        foreach ($ipguest as $ipguestt)
    16431944                        {
    1644 //                echo "IP=".$ipguestt."\n";
    16451945                                $comment = $this->get_img_comment_user($row['img_id'], $concours_id, $conf['guest_id'], $ipguestt);
    16461946                       
    16471947                                $user_note = $this->get_img_note_user($row['img_id'], $concours_id, $conf['guest_id'], $ipguestt);
    1648                                
    1649                                 $file .= ', Guest('.$ipguestt.'), '.$this->get_img_globalnote_user($row['img_id'], $concours_id, $conf['guest_id'], $ipguestt)
    1650 //                                              .', '.($row['comment'] != null ? str_replace(",", "",$row['comment']) : '')
     1948                                $user_global_note = $this->get_img_globalnote_user($row['img_id'], $concours_id, $conf['guest_id'], $ipguestt);
     1949                               
     1950                                $file .= ', Guest('.$ipguestt.'), '.($user_global_note >= 0 ? $user_global_note : 0)
    16511951                                                .', '.($comment != false ? str_replace(array(",","\r\n", "\n", "\r"), " ",$comment) : '')
    16521952                                                .', '
     
    16871987
    16881988                }
    1689 if ($this->debug)               echo $file;
    16901989                return utf8_decode($file);
    16911990       
    16921991               
    16931992        }
    1694        
    16951993       
    16961994       
     
    17222020                                                ;";
    17232021                        pwg_query($query);
    1724 if ($this->debug)               echo $query;
    17252022                       
    17262023                        return $filename;
     
    17352032                .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id )
    17362033                .';';
    1737 if ($this->debug)       echo $query;
    17382034                $result = pwg_query($query);
    17392035                if ($result)
    17402036                {
    1741                         $row = mysql_fetch_assoc($result);             
     2037                        $row = pwg_db_fetch_array($result);             
    17422038                        if ($row)
    17432039                                return $row['file_name'];
     
    17622058                        fpassthru($file);
    17632059                }
    1764        
    1765         }
    1766        
    1767         // Activation page administration
     2060        }
     2061       
     2062        // DEPRECATED Piwigo 11 Activation page administration
     2063/*
    17682064        function concours_admin_menu($menu)
    17692065        {
     
    17712067               array(
    17722068                    'NAME' => CONCOURS_NAME,
    1773                     'URL' => get_admin_plugin_menu_link(CONCOURS_ADMIN_PATH.'admin.php')
     2069                    'URL' => get_root_url().'admin.php?page=plugin-'.CONCOURS_DIR.'-manage'
    17742070                )
    17752071            );
    17762072            return $menu;
    17772073        }
     2074*/
    17782075       
    17792076        // register Concours Menubar
    17802077        public function register_blocks( $menu_ref_arr )
    17812078        {
    1782         $menu = & $menu_ref_arr[0];
    1783         if ($menu->get_id() != 'menubar' OR $this->my_config['active_menubar'] == false)
    1784           return;
    1785         $menu->register_block( new RegisteredBlock( 'CONCOURS_menu', 'concours', 'ConcoursPhoto'));
     2079                $menu = & $menu_ref_arr[0];
     2080                if ($menu->get_id() != 'menubar' OR $this->my_config['active_menubar'] == false)
     2081                  return;
     2082                $menu->register_block( new RegisteredBlock( 'CONCOURS_menu', 'concours', 'ConcoursPhoto'));
    17862083        }
    17872084
     
    17892086        public function blockmanager_apply( $menu_ref_arr )
    17902087        {
    1791  
     2088
    17922089                global $user, $template;
    17932090                $menu = & $menu_ref_arr[0];
     
    17982095                if ( ($block = $menu->get_block( 'CONCOURS_menu' ) ) != null )
    17992096                {
    1800 
    1801                   $menu_list=array();
    1802 
    1803                   if(is_admin())
    1804                   {
     2097                        $menu_list=array();
     2098
     2099                        if(is_admin())
     2100                        {
     2101
    18052102                        array_push($menu_list,
    18062103                          array(
    1807                                 'nfo' => "",
    1808                                 'text' => l10n('concours_admin_add'),
    1809                                 'link' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;action=new',
    1810                                 'edit' => ""
     2104                                'NAME' => l10n('concours_admin_add'),
     2105                                'TITLE' => l10n('concours_admin_add'),
     2106                                'URL' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;action=new',
     2107                                'REL' => ""
    18112108                          )
    18122109                        );
    1813                   }
     2110                       
     2111                        }
    18142112
    18152113                        // recover all img_id from the category
    1816                         $query = 'SELECT distinct(id_concours), groups, guest, CONC.name'
     2114                        $query = 'SELECT distinct(id_concours), groups, guest, admin, CONC.name'
    18172115                        .' FROM ' .CONCOURS_RESULT_TABLE
    18182116                        .' INNER JOIN '.CONCOURS_TABLE. ' AS CONC ON CONC.id = id_concours'
     
    18222120                        $result = pwg_query($query);
    18232121                        $nb_concours = 1;
     2122                       
    18242123                        // For each concours
    1825                         while ($row = mysql_fetch_assoc($result))
     2124                        while ($row = pwg_db_fetch_assoc($result))
     2125
    18262126                        {
    18272127                               
     
    18312131                $conc_to_show = false;  // Default ==> dont show
    18322132               
    1833                 // Guest
    1834                                 if (is_a_guest() AND $row['guest'])
     2133                // Guest OR admin
     2134                                if ((is_a_guest() AND $row['guest'])
     2135                                        OR (is_admin() AND $row['admin']))
    18352136                    $conc_to_show = true;
    18362137                // Group present
     2138                               
     2139                               
    18372140                elseif (!empty($row['groups']))
    18382141                                {
     
    18482151                                        {
    18492152                                        $nb_concours ++;
     2153
    18502154                                        array_push($menu_list,
    18512155                                          array(
    1852                                                 'nfo' => "",
    1853                                                 'text' => $row['name'],
    1854                                                 'link' => './index.php?/concours/'.$row['id_concours'],
    1855                                                 'edit' => (is_admin()? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $row['id_concours'].'&amp;action=modify':"")
     2156                                                'NAME' => $row['name'],
     2157                                                'TITLE' => $row['name'],
     2158                                                'URL' => './index.php?/concours/'.$row['id_concours'],
     2159                                                'EDIT' => (is_admin()? PHPWG_ROOT_PATH . 'admin.php?page=plugin&amp;section=' . CONCOURS_DIR . '%2Fadmin%2Fadd_concours.php&amp;concours=' . $row['id_concours'].'&amp;action=modify':"")
    18562160                                          )
    18572161                                        );
     
    18612165                  if (count($menu_list))
    18622166                  {
    1863 
    1864                           $block->set_title(l10n('concoursphoto'));
    18652167                          $block->template = CONCOURS_ROOT.'/template/concours_menu.tpl';
    18662168                          $block->data = $menu_list;
     
    18692171        }
    18702172
    1871        
    18722173        function section_init_concours()
    18732174        {
     
    18752176                if ($tokens[0] == 'concours')
    18762177                  $page['section'] = 'concours';
     2178                elseif ($tokens[0] == 'concours_vote')
     2179                  $page['section'] = 'concours_vote';
    18772180        }
    18782181       
     
    18802183        {
    18812184                global $page;
    1882                
    1883                
    18842185                if (isset($page['section']) and $page['section'] == 'concours')
    18852186                {
     
    18882189        }
    18892190
     2191        function index_vote_concours()
     2192        {
     2193                global $page;
     2194                if (isset($page['section']) and $page['section'] == 'concours_vote')
     2195                {
     2196                        include(CONCOURS_PATH . 'concours_vote.php');
     2197                }
     2198        }
     2199       
    18902200       
    18912201  // Show the global note under the thumbnail
    1892   function thumbnail_note($tpl_var)
     2202  function thumbnail_note($tpl_var, $pictures)
    18932203  {
    1894 
    1895         global $page, $user;
     2204        global $page, $user, $template;
    18962205        $this->get_user_groups();
    18972206
     
    19092218        $user['ipguest'] = $IP;
    19102219    }
    1911        
    1912     if ($this->my_config['thumb_note'] && $this->my_config['thumb_note'] == true)
    1913     {
    1914         $concours = array();
    1915         if (($page['section']) == 'categories' AND !empty($page['category']))
    1916         {
    1917             $query = '
    1918                 SELECT *
    1919                 FROM ' . CONCOURS_TABLE .'
    1920                 WHERE category =' . $page['category']['id'] . '
    1921                 AND time_to_sec(TIMEDIFF(begin_date,now())) < 0
    1922                 AND time_to_sec(TIMEDIFF(now(), end_date)) < 0
    1923                 ';
    1924 
    1925             $result = pwg_query($query);
    1926     if ($this->debug) echo $query."\n";
    1927             while ($row = mysql_fetch_assoc($result))
    1928             {
    1929                
    1930                 if (!empty($row['groups']))
    1931                 {
    1932     if ($this->debug)   echo "GROUPS=".$row['groups'];                         
    1933                     $authorized_groups = explode(',', $row['groups']);
    1934                     if (array_intersect($this->user_groups, $authorized_groups) == array())
    1935                     {
    1936     if ($this->debug)   echo "ERROR GROUPS";
    1937                         continue;
    1938                     }
    1939                     $concours = $row;
    1940                 }
    1941                
    1942                 // If no group is parameter for that concours  ==> available for all registered users
    1943                 else
    1944                     $concours = $row;
    1945                
    1946             }
    1947             if (count($concours))
    1948             {
    1949                 // Check if user is guest and if guest is allowed
    1950                 if ((is_a_guest() AND $concours['guest'])
    1951                     OR !is_a_guest())
    1952                 {
    1953                     foreach($tpl_var as $cle=>$valeur)
    1954                     {
    1955                         // show only if the author is not the active user
    1956                         if ($tpl_var[$cle]['FILE_AUTHOR'] != $user['username']
    1957                             OR $this->my_config['author_vote_available']    // Allow author to vote (and also show his score)
    1958                             )
    1959                         {
    1960                             $tpl_var[$cle]['NAME'] = $tpl_var[$cle]['NAME'].'<br>&nbsp;'.l10n('thumbnail_global_note').' : '.$this->get_img_globalnote_user($tpl_var[$cle]['ID'], $concours['id'], $user['id'], $user['ipguest']);
    1961                         }
    1962                     }
    1963                 }
    1964             }
    1965         }
    1966     }
     2220
     2221        if (($page['section']) == 'categories' AND !empty($page['category']))
     2222        {
     2223               
     2224                $concours = array();
     2225
     2226                $query = '
     2227                        SELECT *
     2228                        FROM ' . CONCOURS_TABLE .'
     2229                        WHERE category =' . $page['category']['id']
     2230// comment to load prepared contests and opened contests                                . ' AND time_to_sec(TIMEDIFF(begin_date,now())) < 0'
     2231                        . ' AND time_to_sec(TIMEDIFF(now(), end_date)) < 0';
     2232
     2233                $result = pwg_query($query);
     2234                // DEBUG
     2235                if ($this->debug) echo $query."\n";
     2236                // END DEBUG
     2237                while ($row = pwg_db_fetch_array($result))
     2238                {                               
     2239                        if ((strtotime($row['begin_date'])-time() > 0) AND $this->my_config['mask_thumbnail'])
     2240                        {
     2241                        // disable picture if contest is prepared for all users
     2242                          $i=0;
     2243                          while ($i<count($tpl_var))
     2244                          {
     2245                                  array_splice($tpl_var, $i, 1);
     2246                                  array_splice($pictures, $i, 1);
     2247                          }     
     2248                        $concours = $row;
     2249                               
     2250                        }
     2251                        elseif (is_admin() AND $row['admin'])
     2252                                $concours = $row;
     2253                        elseif (!is_a_guest() AND !empty($row['groups']))
     2254                        {
     2255                                $authorized_groups = explode(',', $row['groups']);
     2256                                if (array_intersect($this->user_groups, $authorized_groups) == array())
     2257                                        continue;
     2258                                $concours = $row;
     2259                        }
     2260                       
     2261                        // If no group is parameter for that concours  ==> available for all registered users
     2262                        else
     2263                                $concours = $row;               
     2264                }
     2265               
     2266
     2267                if (count($concours))
     2268                {               
     2269                        // Add timeline for all users.
     2270                        if (strtotime($concours['begin_date'])-time() > 0)
     2271                        {
     2272                                $template->assign('begin_concours_min', (strtotime($concours['begin_date'])-time()));
     2273                                $template->assign('deadline_type',$this->my_config['concours_deadline']);
     2274                                $template->assign('begin_concours', $concours['begin_date']);
     2275                        }
     2276                        else
     2277                        {
     2278                                // Check if user is guest and if guest is allowed
     2279                                if ((is_a_guest() AND $concours['guest'])
     2280                                        OR (is_admin() AND $concours['admin'])
     2281                                        OR !is_a_guest())
     2282                                {
     2283                         
     2284                                        // check if contest is concours not already open (date begin > now)
     2285
     2286                               
     2287                                       
     2288                                                foreach($tpl_var as $cle=>$valeur)
     2289                                                {
     2290                                                        // show only if the author is not the active user
     2291
     2292                                                        $AuthorArray = strip_punctuation2($tpl_var[$cle]['author']);
     2293                                                        $AddedByID = ($tpl_var[$cle]['added_by']);
     2294                                                        $UserArray = strip_punctuation2($user['username']);
     2295
     2296                                                        if ($this->my_config['author_vote_available']  == 0 // Allow to vote for all photos (and also show his score)
     2297                                                            OR ($this->my_config['author_vote_available'] == 1 // check between author and user
     2298                                                                AND (empty($AuthorArray) OR count(array_intersect($AuthorArray, $UserArray)) != count ($AuthorArray))  // Author is the same as user name
     2299                                                                )       
     2300                                                            OR ($this->my_config['author_vote_available'] == 2 // check between author and user
     2301                                                                AND (!isset($AddedByID) OR ($user['id'] != $AddedByID))  // Addedby is the same as user name
     2302                                                                )
     2303                                                            OR ($this->my_config['author_vote_available'] == 3 // check between author OR addedby and user
     2304                                                                AND (!isset($AddedByID) OR ($user['id'] != $AddedByID))  // Addedby is the same as user name
     2305                                                                AND (empty($AuthorArray) OR count(array_intersect($AuthorArray, $UserArray)) != count ($AuthorArray))  // Author is the same as user name
     2306                                                                )
     2307                                                           )
     2308
     2309                                                        {
     2310                                                                if ($this->my_config['thumb_note'])      // display thumbnail note only if option is activated
     2311                                                                {
     2312                                                                        $user_global_note = $this->get_img_globalnote_user($tpl_var[$cle]['id'], $concours['id'], $user['id'], $user['ipguest']);
     2313                                                                        $tpl_var[$cle]['NAME'] = $tpl_var[$cle]['NAME'].'('.l10n('thumbnail_global_note').': '.($user_global_note >= 0 ? $user_global_note : 0).')';
     2314                                                                }
     2315                                                        }
     2316                                                }
     2317                                               
     2318                                                // Add deadline on description page     
     2319                                                $template->assign('end_concours', $concours['end_date']);
     2320                                                $template->assign('end_concours_min', (strtotime($concours['end_date'])-time()));
     2321                                                $template->assign('deadline_type',$this->my_config['concours_deadline']);
     2322                                                if (isset($this->my_config['active_global_score_page']) AND $this->my_config['active_global_score_page'])       // only if option is activated
     2323                                                        $template->assign('global_vote_link', PHPWG_ROOT_PATH . 'index.php?/concours_vote/'.$concours['id']);
     2324                                }
     2325                               
     2326                        }
     2327                        $template->assign('IMG_URL', CONCOURS_IMG_PATH);
     2328                       
     2329                        $template->set_filenames(array('concours_description' =>  CONCOURS_ROOT.'/template/concours_description.tpl'));
     2330                        $template->concat('CONTENT_DESCRIPTION', $template->parse('concours_description', true));
     2331
     2332                }
     2333        }
     2334       
    19672335    return $tpl_var;
    19682336  }
    1969        
     2337
     2338        function concours_stuffs_module($modules)
     2339        {
     2340                array_push($modules, array(
     2341                'path' => CONCOURS_PATH.'stuffs_module/',
     2342                'name' => l10n('concours_stuffs_name'),
     2343                'description' => l10n('concours_stuffs_description'),
     2344                )
     2345                );
     2346                return $modules;
     2347        }       
     2348       
     2349       
     2350       
     2351        function add_contest_desc($tpl_var)
     2352        {       
     2353                global $page, $user, $template;
     2354        // TO DO : Add contest information on subcategory
     2355/*     
     2356        echo "ICI<br>";
     2357        echo "tpl_VAR".(is_array($tpl_var) ? "OK" : $tpl_var)."<br>";
     2358        foreach ($tpl_var as $id=>$val)
     2359        {
     2360               
     2361                if (is_array($val))
     2362                        foreach ($val as $id2=>$val2)
     2363                        if (is_array($val2))
     2364                                foreach ($val2 as $id3=>$val3)
     2365                                if (is_array($val3))
     2366                                        foreach ($val3  as $id4=>$val4)
     2367                                                echo "tpl_var[".$id."][".$id2."][".$id3."][".$id4."]=".$val4."<br>\n";
     2368                                else
     2369                                        echo "tpl_var[".$id."][".$id2."][".$id3."]=".$val3."<br>\n";
     2370                        else
     2371                                echo "tpl_var[".$id."][".$id2."]=".$val2."<br>\n";
     2372                else
     2373                        echo "tpl_var[".$id."]=".$val."<br>\n";
     2374        }
     2375          $i=0;
     2376          while ($i<count($tpl_var))
     2377          {
     2378                $tpl_var[$i]['NAME'] = "TEST TEST";
     2379                $i++;
     2380               
     2381          }
     2382       
     2383                $template->set_filenames(array('concours_description' =>  CONCOURS_ROOT.'/template/concours_description-cat.tpl'));
     2384                $template->concat('DESCRIPTION', $template->parse('concours_description', true));
     2385               
     2386                return  $tpl_var;
     2387*/             
     2388        }
     2389
     2390
     2391
     2392
     2393        // Check if a concours is present (prepared or actived) for the category and user group
     2394        function concours_present_cat($category = NULL)
     2395        {
     2396                global $page;
     2397                $concours_present = false;
     2398                if (!isset($category))  // param not present
     2399                {
     2400                        if (($page['section']) == 'categories' AND !empty($page['category']))
     2401                                        $category = $page['category']['id'] ;
     2402                }
     2403
     2404                if (isset($category))
     2405                {
     2406                        $query = '
     2407                                SELECT *
     2408                                FROM ' . CONCOURS_TABLE .'
     2409                                WHERE category =' . $category . '
     2410                AND time_to_sec(TIMEDIFF(now(), end_date)) < 0
     2411                                ';
     2412
     2413                        $result = pwg_query($query);
     2414                        while ($row = pwg_db_fetch_array($result))
     2415                                return true;
     2416                }
     2417                return false;
     2418        }
     2419
     2420
     2421        // Disable Metatdata to picture for a prepared or active concours
     2422        function disable_meta_to_picture()
     2423        {
     2424                if (isset($this->my_config['mask_meta']) && $this->my_config['mask_meta'] == true)
     2425                {
     2426                        if ($this->concours_present_cat())
     2427                                pwg_set_session_var('show_metadata', 0 );
     2428                }
     2429        }
     2430
    19702431       
    19712432}
    19722433
     2434function strip_punctuation($string) {
     2435    $string = strtolower($string);      // lower case
     2436    $string = preg_replace("/\p{P}+/", "", $string); // remove punctuation
     2437    $string = preg_replace("/\p{Nd}+/", "", $string); // remove numeric
     2438    $string = preg_replace("/[\p{Z}\t\r\n\v\f]+/", "", $string); // remove spaces
     2439    $string = str_replace(" +", "", $string);   // remove space
     2440//echo "stripPunct=".$string."!\n";
     2441    return $string;
     2442}
     2443
     2444// return array
     2445function strip_punctuation2($string) {
     2446    $string = strtolower($string);      // lower case
     2447    $string = preg_replace("/\p{P}+/", " ", $string); // remove punctuation by space
     2448    $string = preg_replace("/\p{Nd}+/", "", $string); // remove numeric
     2449    $string = preg_replace("/[\p{Z}\t\r\n\v\f]+/", " ", $string); // remove spaces by spaces (only 1)
     2450//    $string = str_replace(" +", "", $string); // remove space
     2451        $stringArray = $returnValue = preg_split('/\\W/', $string, -1, PREG_SPLIT_NO_EMPTY);
     2452
     2453    return $stringArray;
     2454}
     2455
     2456
     2457
    19732458?>
  • extensions/ConcoursPhoto/include/default_values.inc.php

    r8946 r32457  
    77$concours_default_values['active_menubar'] = true; // Activate menubar view
    88$concours_default_values['nbconcours_menubar'] = 3;     // Nb of last published concours show on concours menubar
    9 $concours_default_values['mask_author'] =   true; // Mask author for prepared concours
     9$concours_default_values['mask_author'] =   true; // Mask author for prepared concours or active concours
     10$concours_default_values['mask_meta'] =     false; // Mask meta for prepared concours or active concours
    1011$concours_default_values['thumb_note'] = true; // Display global note (for user) under thumbnail
    1112$concours_default_values['check_exaequo'] = false; // Check exaequo and display the same rank
    12 $concours_default_values['author_vote_available'] = false; // Dont allow author to vote for his own photo
     13//$concours_default_values['author_vote_available'] = false; // Dont allow author to vote for his own photo
     14$concours_default_values['author_vote_available'] = 0; // 0: Disable check between curent user and Author/AddedBy info for a photo ==> All user cound vote 
     15                                                                                                           // 1: Check between "Author" (of photo) and "User"
     16                                                                                                           // 2: Check between "AddedBy" (of photo) and "User"
     17                                                                                                           // 3: Check between "Author" OR "AddedBy" and "User"
     18
    1319$concours_default_values['concours_change_score']   = true; // Allow a user to change his score afer a validation
     20$concours_default_values['concours_deadline']   = 2; // 0: dont show deadline; 1: deadline version 1; 2: deadline version 2
     21$concours_default_values['mask_thumbnail']   = true; // Mask thumbnail on category page before the contest start
     22$concours_default_values['nb_concours_page']   = 10; // nb of contest by page (on admin page)
     23$concours_default_values['active_global_score_page']   = false; // activate global page for vote/score (all image in 1 page)
     24$concours_default_values['score_mode']   = 1; // score mode. 0: text box / 1: stars
     25$concours_default_values['text_overlay']   = "Vote déjà enregistré <br>"; // text to display when the score is already present and the option concours_change_score is false (allow the user to change the score after vote)
    1426
    1527?>
  • extensions/ConcoursPhoto/language/en_UK/plugin.lang.php

    r9370 r32457  
    1616$lang['concours_name']                                  = 'Name';
    1717$lang['concours_descr']                                 = 'Description';
    18 $lang['concours_activation_date']                                       = 'Contest Period';
     18$lang['concours_activation_date']               = 'Contest Period';
    1919$lang['concours_nb_jours']                              = 'During';
    2020$lang['jours']                                          = 'Days';
     
    6969$lang['concours_hour_to']               = 'End hour';
    7070
    71 $lang['concours_mask_author']           =  'Mask author for prepared inactive contest';
    72 $lang['concours_mask_exif']             =  'Mask EXIF/IPTC datas for prepared inactive contest';
    73 
    74 $lang['thumbnail_global_note']          = 'Contest score';
     71$lang['concours_mask_author']           =  'Mask author for prepared inactive or active contest';
     72//$lang['concours_mask_exif']             =  'Mask EXIF/IPTC datas for prepared inactive contest';
     73$lang['concours_mask_meta']             =  'Mask Metadata on picture for prepared inactive or active contest';
     74
     75$lang['thumbnail_global_note']          = 'Contest';
    7576$lang['concours_thumb_note']            = 'Add the global note under thumbnails';
    7677$lang['concours_global_user_note']      = 'Total registered';
     
    8283$lang['concours_method1']               = 'Sum of scored';
    8384$lang['concours_method2']               = 'Average of scores';
     85$lang['concours_method3']               = 'Average of scores with moderation type 1';
     86$lang['concours_method4']               = 'Average of scores with moderation type 2';
    8487
    8588$lang['concours_note']                  = 'Global score';
     
    8790$lang['concours_nbvotant']              = 'Number of voting';
    8891$lang['concours_usernote']              = 'Your score';
     92$lang['concours_moderation1']           = 'Average (moderation 1)';
     93$lang['concours_moderation2']           = 'average (moderation 2)';
     94$lang['concours_warn_moderation']               = 'Warning : Average with moderation only calculated at the end of contest';
    8995$lang['concours_infos']                 = 'Contest information';
    9096$lang['concours_audit']                 = 'Audit';
     
    95101$lang['all_users']                      = '-- All --';
    96102$lang['concours_check_exaequo']         = 'Manage exaequos';
    97 $lang['concours_author_vote']           = 'Allow author of a photo to vote (disable the check based on username/author)';
     103$lang['concours_author_vote']           = 'Control user/author for the contest vote : ';
     104$lang['concours_author_vote0']          = '0- No control (vote for any photos)';
     105$lang['concours_author_vote1']          = '1- Author control (vote not allowed if User=Author)';
     106$lang['concours_author_vote2']          = '2- Added_by control (vote not allowed if User=Added_by)';
     107$lang['concours_author_vote3']          = '3- Author or Added_by control (vote not allowed if User=Author or User=Added_by)';
     108$lang['concours_author_vote_detail']    = '<i>
     109          <ul>
     110          <li style="list-style-type: none;">0- No control : All users could show and vot for any photos .</li>
     111          <li style="list-style-type: none;">1- Author control : User cound not vote for photos whith same author information as user name .</li>
     112          <li style="list-style-type: none;">2- Added_by control : User cound not vote for photos added by himself.</li>
     113          <li style="list-style-type: none;">3- Author OR Added_by control: User cound not vote for photos whith same author information as user name or if photos are added by himself.</li>
     114                  </ul></i>
     115';
     116
     117
    98118$lang['concours_change_score']          = 'Allow user to change his score after a validation';
    99119$lang['concours_end_date_change_to']    = 'End date changed to %s';
     
    106126$lang['concours_admin_help']            = 'Guide/Help to use the ConcoursPhoto plugin';
    107127$lang['concours_audit_page']            = 'Contest Audit';
     128
     129
     130$lang['manage_criteria']                                = 'Manage default criterias';
     131
     132
     133$lang['concours_stuffs_name']                   = 'Photo Contest';
     134$lang['concours_stuffs_description']    = 'Display the result of one photo contest (podium)';
     135
     136$lang['ConcoursPhoto_Fonctionality']    = 'Concours Photo plugin functionnalities';
     137$lang['ConcoursPhoto_Fonctionality_txt'] = '
     138          <ul>
     139            <li>
     140            General Principle: On one album, allow a user list to note for photos during a set period. The result is then generated and displayed on a dedicated page accessible by users.
     141            <br/>
     142            Details below are steps to add a contest:
     143            </li>
     144            <li style="list-style-type: none;"><br/></li>
     145                        <li ><span class="throw"> Step 1 : Add a new contest on Piwigo:</span></li>
     146
     147<li style="list-style-type: none;"></li>
     148<li style="list-style-type: none;">- Click on the "Add Contests\" tab to add 1 new contest.</li>
     149<li style="list-style-type: none;">- Enter the name and description of the contest (eg Name = "Flowers" / Description = "Contest on the theme of flowers from xx / xx to xx / xx with Black & White photos).</li>
     150<li style="list-style-type: none;">- Select Groups Allowed to note Photos (if no group is present, all users are allowed).</li>
     151<li style="list-style-type: none;">- Set the start and end time of the contest.</li>
     152<li style="list-style-type: none;">- Choose the method of calculating the result (see details below for more details).</li>
     153<li style="list-style-type: none;">- Select the album in which the photos will be present for the contest.</li>
     154<li style="list-style-type: none;">- Confirm and go to step 2.</li>
     155            <li style="list-style-type: none;"><br/></li>
     156                        <li ><span class="throw"> Step 2 : Selection of rating criteria:</span></li>
     157<li style="list-style-type: none;">Note: The criteria of a contest are pre-initialized with the default criteria (see below to modify them)</li>
     158<li style="list-style-type: none;"></li>
     159<li style="list-style-type: none;">- Modify criteria / sub-criteria present.</li>
     160<li style="list-style-type: none;">- Or add new ones by clicking on "Add new criteria.</li>
     161<li style="list-style-type: none;"><i>To add a sub-criterion to an existing criterion, click on the icon to the right of the criterion (in the table).</i></li>
     162            <li style="list-style-type: none;"><br/></li>
     163                        <li ><span class="throw">Step 3 : The voting period:</span></li>
     164<li style="list-style-type: none;"></li>
     165<li style="list-style-type: none;">- During the voting period, the admin page allows you to view the intermediate result by clicking on the contest (<b> Manage Contests </b> tab).</li>
     166            <li style="list-style-type: none;"><br/></li>
     167                        <li ><span class="throw">Step 4 :Results:</span></li>
     168<li style="list-style-type: none;"></li>
     169<li style="list-style-type: none;">- At the end of the contest period, the result is generable on the admin page (<b> Manage Contests </b>).</li>
     170<li style="list-style-type: none;">- It is needed to click on the button to the right of the contest to generate the result (otherwise it will not be visible to users).</li>
     171<li style="list-style-type: none;">- After generating the result, a CSV file could be generated (click on the icon corresponding to the right of the contest).</li>
     172            <li style="list-style-type: none;"><br/></li>
     173         </ul>';
     174
     175
     176$lang['ConcoursPhoto_Options']          = 'Options and details of plugin Concours Photo';
     177$lang['ConcoursPhoto_Options_txt'] = '
     178          <ul>
     179            <li>
     180            Main options and rules for Photo Contest.
     181            <br/>
     182            </li>
     183            <li style="list-style-type: none;"><br/></li>
     184                        <li ><span class="throw"> Criteria, sub-criteria and default criteria</span></li>
     185<li style="list-style-type: none;">- The default criteria are those that are loaded when creating a new contest.</li>
     186<li style="list-style-type: none;">- The criteria and sub-criteria contain the following parameters: Name / Description / Note min / Note max / coefficient multipl.</li>
     187<li style="list-style-type: none;">- When a criterion contains sub-criteria, it is the latter that are used for the notation. In this case, the main criterion is used only as grouping.</li>
     188<li style="list-style-type: none;">- You can change the default criteria at any time, they will not affect competitions already in progress or completed.</li>
     189<li style="list-style-type: none;">- You can add as many default criteria and sub-criteria as you want.</li>
     190            <li style="list-style-type: none;"><br/></li>
     191                        <li ><span class="throw"> Methods of calculating the result</span></li>
     192<li style="list-style-type: none;">There are 4 methods of calculating the final score :</li>
     193<li style="list-style-type: none;">- "Sum" -> It corresponds to the simple sum of the scores / scores obtained per photo that defines the ranking regardless of the number of voters for the photos.</li>
     194<li style="list-style-type: none;">- "Average" -> It corresponds the average of the scores / scores obtained by photo between the voters (for the same photo) which defines the ranking.</li>
     195<li style="list-style-type: none;">- "Average (ponderation1)" -> It corresponds is the average of the scores / scores obtained per photo that defines the ranking. If a user does not vote for all the photos, they are awarded a score corresponding to the average score of the same voter</li>
     196<li style="list-style-type: none;">- "Average (ponderation2)" -> This is the average of the scores / scores obtained per photo that defines the ranking. An increase / decrease is calculated as a function of the difference between the minimum and maxi scores of the same voter. This mark-up is added to the photo\'s score before calculating the result.</li>
     197<li style="list-style-type: none;"></li>
     198<li style="list-style-type: none;"><i>Moderation 1 and 2 reduce the significant difference in score and rebalance the votes.</i></li>
     199            <li style="list-style-type: none;"><br/></li>
     200                        <li ><span class="throw"> Use of PWG_Stuffs modules</span></li>
     201<li style="list-style-type: none;">- Once the contest is closed (<u> and the result generated </u>), the result is accessible via the link present in the piwigo menu.</li>
     202<li style="list-style-type: none;">- You can also add a module with PWG_Stuffs which allows to highlight the podium of winning photos.</li>
     203            <li style="list-style-type: none;"><br/></li>
     204          </ul>';
     205
     206$lang['concours_deadline']                                      = 'Contest deadline ';
     207$lang['concours_begin']                                         = 'Contest starts in';
     208$lang['concours_deadline_days']                         = ' Days '; //':'
     209$lang['concours_deadline_hours']                        = ' Hours '; //':'
     210$lang['concours_deadline_mins']                         = ' Minutes '; //':'
     211$lang['concours_deadline_secs']                         = ' Seconds '; //'.'
     212$lang['concours_deadline_param']                                = 'Display deadline contest ';
     213$lang['concours_deadline_param0']                               = '0-No display';
     214$lang['concours_deadline_param1']                               = '1-Display v1';
     215$lang['concours_deadline_param2']                               = '2-Display v2';
     216
     217$lang['concours_begin']                                         = 'Contest begin in ';
     218$lang['mask_thumbnail']                                         = 'Mask thumbnails before contest start';
     219
     220$lang['concours_nb_concours_total']             = '<b>%d Contests saved </b> (<i>%d Prepared contest(s) / %d Active contest(s) / %d Closed contest(s)</i>)';
     221$lang['concours_nb_concours_page']                      = 'Number by page';
     222$lang['concours_status']                                        = 'Status';
     223$lang['concours_delete_selected']                       = 'Delete the contest';
     224$lang['concours_delete_all_closed']                     = 'Delete all closed contests';
     225$lang['concours_no_concours']                           = 'No contest saved in database';
     226$lang['concours_no_criteria']                           = 'No criteria saved';
     227
     228$lang['concours_global_score_title']            = 'Global score page';
     229$lang['concours_global_score']                          = 'Click to display Global score page';
     230$lang['concours_global_score_admin']            = 'Active global score page (all pictures)';
     231$lang['concours_score_mode']                            = 'Score display mode ';
     232$lang['concours_score_mode0']                           = '0-Text mode';
     233$lang['concours_score_mode1']                           = '1-Star v1 mode';
     234$lang['concours_notation']                                      = 'Global note of all contest pictures';
     235
     236$lang['CR_select_contest']                                      = 'Closed contest to display';
     237$lang['closed-noresult_concours']                       = 'closed contest (withouyt results)';
     238$lang['concours_comment_short']                 = 'Picture comment';
     239$lang['concours_nbscore']                               = 'Number of votes';
     240
     241$lang['prepared_concours_1']                            = 'prepared ';
     242$lang['active_concours_1']                                      = 'actived ';
     243$lang['closed_concours_1']                                      = 'closed ';
     244$lang['closed_noresult_concours_1']                     = 'closed (without result) ';
     245$lang['concours_allow_admin']                   = 'Allow Admin';
     246$lang['concours_overlay_text']                  = 'Text to display';
     247
    108248?>
  • extensions/ConcoursPhoto/language/fr_FR/plugin.lang.php

    r9370 r32457  
    1919$lang['concours_nb_jours']                              = 'Pendant';
    2020$lang['jours']                                          = 'Jours';
    21 $lang['concours_category_select']               = 'Catégorie sélectionnée';
     21$lang['concours_category_select']               = 'Album sélectionné';
    2222$lang['concours_authorized_group']              = 'Groupes authorisés';
    2323$lang['concours_begin_date']                    = 'Date de début';
     
    6969$lang['concours_hour_to']               = 'Heure de Fin';
    7070
    71 $lang['concours_mask_author']           =  'Masquer l\'auteur pour les concours préparés non actifs';
    72 $lang['concours_mask_exif']             =  'Masquer les données EXIF/IPTC pour les concours préparés non actifs';
    73 
    74 $lang['thumbnail_global_note']          = 'Note concours';
     71$lang['concours_mask_author']           =  'Masquer l\'auteur pour les concours préparés non actifs et actifs';
     72//$lang['concours_mask_exif']             =  'Masquer les données EXIF/IPTC pour les concours préparés non actifs';
     73$lang['concours_mask_meta']             =  'Masquer les metadonnées pour les concours préparés non actifs et actifs';
     74
     75$lang['thumbnail_global_note']          = 'Concours';
    7576$lang['concours_thumb_note']            = 'Ajouter la note globale sous les miniatures';
    7677$lang['concours_global_user_note']      = 'Total enregistré';
     
    8283$lang['concours_method1']               = 'Somme des notes';
    8384$lang['concours_method2']               = 'Moyenne des notes';
     85$lang['concours_method3']               = 'Moyenne des notes avec modération type 1';
     86$lang['concours_method4']               = 'Moyenne des notes avec modération type 2';
    8487
    8588$lang['concours_note']                  = 'Note globale';
     
    8790$lang['concours_nbvotant']              = 'Nombre de votant';
    8891$lang['concours_usernote']              = 'Votre note';
     92$lang['concours_moderation1']           = 'Moyenne (modération 1)';
     93$lang['concours_moderation2']           = 'Moyenne (modération 2)';
     94$lang['concours_warn_moderation']               = 'Attention : moyenne moderée appliquée en fin de concours';
    8995$lang['concours_infos']                 = 'Information sur le concours';
    9096$lang['concours_audit']                 = 'Audit';
     
    95101$lang['all_users']                      = '-- Tous --';
    96102$lang['concours_check_exaequo']         = 'Gérer les exaequos';
    97 $lang['concours_author_vote']           = 'Autoriser les auteurs à voter pour leur propres photos (désactive le contrôle username=auteur)';
     103$lang['concours_author_vote']           = 'Contrôle des utilisateurs / auteurs pour le vote : ';
     104$lang['concours_author_vote0']          = '0- Aucun contrôle (vote pour toutes les photos)';
     105$lang['concours_author_vote1']          = '1- Contrôle Auteur (vote impossible si User=Auteur)';
     106$lang['concours_author_vote2']          = '2- Contrôle Ajout (vote impossible si User="Ajouté par")';
     107$lang['concours_author_vote3']          = '3- Contrôle Auteur ou Ajout (vote impossible si User=Auteur ou User="Ajouté Par")';
     108$lang['concours_author_vote_detail']    = '<i>
     109          <ul>
     110          <li style="list-style-type: none;">0- Aucun contrôle : tous les participants peuvent noter toutes les photos.</li>
     111          <li style="list-style-type: none;">1- Contrôle Auteur: l\'utilisateur ne peut pas vôter pour les photos dont l\'auteur est identique au login de l\'utilisateur.</li>
     112          <li style="list-style-type: none;">2- Contrôle Ajouté Par: l\'utilisateur ne peut pas vôter pour les photos qui ont été ajoutées par lui même.</li>
     113          <li style="list-style-type: none;">3- Contrôle Auteur et Ajouté Par: l\'utilisateur XXX ne peut pas vôter pour les photos dont l\'auteur est identique au login de l\'utilisateur où qui ont été ajouté par lui même.</li>
     114                  </ul></i>
     115';
     116
     117
    98118$lang['concours_change_score']          = 'Autoriser les votants à modifier les notes après validation';
    99119$lang['concours_end_date_change_to']    = 'La date de fin du concours a été modifié : %s';
     
    106126$lang['concours_admin_help']            = 'Guide/Aide d\'utilisation du plugin ConcoursPhoto';
    107127$lang['concours_audit_page']            = 'Audit de concours';
     128
     129
     130$lang['manage_criteria']                                = 'Gestion des critères par défaut';
     131
     132
     133$lang['concours_stuffs_name']                   = 'Concours Photo';
     134$lang['concours_stuffs_description']    = 'Affiche le résultat d\'un concours photo (podium)';
     135
     136$lang['ConcoursPhoto_Fonctionality']    = 'Fonctionnalités du plugin Concours Photo';
     137$lang['ConcoursPhoto_Fonctionality_txt'] = '
     138          <ul>
     139            <li>
     140            Principe général : Sur un album, autoriser une liste d\'utilisateur à noter les différentes photos présentes pendant une période paramétrée. Le résultat est ensuite généré et affiché sur une page dédié accessible aux utilisateurs.
     141            <br/>
     142            Détail ci dessous des étapes pour l\'ajout d\'un concours:
     143            </li>
     144            <li style="list-style-type: none;"><br/></li>
     145                        <li ><span class="throw"> Etape 1 : Ajout d\'un nouveau concours sur Piwigo:</span></li>
     146
     147<li style="list-style-type: none;"></li>
     148<li style="list-style-type: none;">- Cliquez sur l\'onglet \"Ajouter un concours\" pour ajouter 1 nouveau concours.</li>
     149<li style="list-style-type: none;">- Renseigner le nom et la description du concours (ex. Nom = "Les fleurs" / Description = "Concours sur le thème des fleurs du xx/xx au xx/xx. Photos Noir & Blanc").</li>
     150<li style="list-style-type: none;">- Sélectionnez les groupes autorisés à notes les photos (si aucun groupe n\'est présent, tous les utilisateurs sont autorisés).</li>
     151<li style="list-style-type: none;">- Définissez la période de début et de fin du concours.</li>
     152<li style="list-style-type: none;">- Choississez la méthode de calcul du résultat (voir détail ci-dessous pour plus de précisions).</li>
     153<li style="list-style-type: none;">- Sélectionnez l\'album dans lequel les photos seront présentes pour le concours.</li>
     154<li style="list-style-type: none;">- Validez pour passer à l\'étape 2.</li>
     155            <li style="list-style-type: none;"><br/></li>
     156                        <li ><span class="throw"> Etape 2 : Sélection des critères de notation:</span></li>
     157<li style="list-style-type: none;">Remarque : les critères d\'un concours sont pré-initialisés avec les critères par défaut (voir ci-dessous pour les modifier)</li>
     158<li style="list-style-type: none;"></li>
     159<li style="list-style-type: none;">- Modifier les critères / sous-critères présents.</li>
     160<li style="list-style-type: none;">- Ou ajoutez-en de nouveau en cliquant sur "Ajouter un nouveau critère.</li>
     161<li style="list-style-type: none;"><i>Pour ajouter un sous-critère à un critère existant, cliquez sur l\'icone à droite du critère (dans le tableau).</i></li>
     162            <li style="list-style-type: none;"><br/></li>
     163                        <li ><span class="throw">Etape 3 : La période de vote:</span></li>
     164<li style="list-style-type: none;"></li>
     165<li style="list-style-type: none;">- pendant la période de vote, la page d\'admin permet de visualiser le résultat intermédiaire en cliquant sur le concours (onglet <b>Gérer les concours</b>).</li>
     166            <li style="list-style-type: none;"><br/></li>
     167                        <li ><span class="throw">Etape 4 :Les résultats:</span></li>
     168<li style="list-style-type: none;"></li>
     169<li style="list-style-type: none;">- A la fin de la période du concours, le résultat est générable dans la page admin (onglet <b>Gérer les concours</b>).</li>
     170<li style="list-style-type: none;">- Il est impératif de cliquer sur le bouton à droite du concours pour génére le résultat (sinon ce dernier ne sera pas visible par les utilisateurs).</li>
     171<li style="list-style-type: none;">- Après la génération du résultat, un fichier CVS est exportable (cliquez sur l\'icone correspondant à droite du concours).</li>
     172            <li style="list-style-type: none;"><br/></li>
     173         </ul>';
     174
     175
     176$lang['ConcoursPhoto_Options']          = 'Options et détails du plugin Concours Photo';
     177$lang['ConcoursPhoto_Options_txt'] = '
     178          <ul>
     179            <li>
     180            Principales options et règles de Concours Photo.
     181            <br/>
     182            </li>
     183            <li style="list-style-type: none;"><br/></li>
     184                        <li ><span class="throw"> Critères, sous-critères et critères par défaut</span></li>
     185<li style="list-style-type: none;">- Les critères par défaut sont ceux qui sont chargés lors de la création d\'un nouveau concours.</li>
     186<li style="list-style-type: none;">- Les critères et sous-critères contiennent les paramètres suivants : Nom / Description / Note min / Note max / coefficient multipl.</li>
     187<li style="list-style-type: none;">- Lorsqu\'un critère contient des sous-critères, ce sont ces derniers qui sont utilisés pour la notation. Dans ce cas, le critère principal n\'est utilisé que comme regroupement.</li>
     188<li style="list-style-type: none;">- Vous pouvez modifier les critères par défaut à tout moment, ils n\'influeront pas sur les concours déjà en cours ou terminés.</li>
     189<li style="list-style-type: none;">- Vous pouvez ajouter autant de critères et sous-critères par défaut que vous souhaitez.</li>
     190            <li style="list-style-type: none;"><br/></li>
     191                        <li ><span class="throw"> Les méthodes de calcul du résultat</span></li>
     192<li style="list-style-type: none;">Il y a 4 méthodes de calcul du score final :</li>
     193<li style="list-style-type: none;">- "la somme" --> C\'est la somme des scores/notes obtenus par photo qui définit le classement quelque soit le nombre de votant pour les photos.</li>
     194<li style="list-style-type: none;">- "la moyenne" --> C\'est la moyenne des scores/notes obtenus par photo entre les votants (pour 1 même photo) qui définit le classement.</li>
     195<li style="list-style-type: none;">- "la moyenne (pondération1)" --> C\'est la moyenne des scores/notes obtenus par photo qui définit le classement. Si un utilisateur ne vote pas pour toutes les photos, ces dernières se voient attribuées un score correspondant à la moyenne des notes du même votant </li>
     196<li style="list-style-type: none;">- "la moyenne (pondération2)" --> C\'est la moyenne des scores/notes obtenus par photo qui définit le classement. une majoration/minoration est calculée en fonction de l\'écart entre les notes mini et maxi d\'un même votant. Cette majoration/minoration est ajoutée au score de la photo avant de calculer le résultat.</li>
     197<li style="list-style-type: none;"></li>
     198<li style="list-style-type: none;"><i>la modération 1 et 2 permettent de réduire les écarts important de score et rééquilibrer les votes.</i></li>
     199            <li style="list-style-type: none;"><br/></li>
     200                        <li ><span class="throw"> Utilisation de PWG_Stuffs</span></li>
     201<li style="list-style-type: none;">- Une fois le concours clos (<u>et le résultat généré</u>), le résultat est accessible via le lien présent dans le menu piwigo.</li>
     202<li style="list-style-type: none;">- Vous pouvez également ajouter un module avec PWG_Stuffs qui permet de mettre en avant le podium de photos gagnantes.</li>
     203            <li style="list-style-type: none;"><br/></li>
     204          </ul>';
     205
     206$lang['concours_deadline']                                      = 'Fin du concours dans ';
     207$lang['concours_begin']                                         = 'Début du concours dans ';
     208$lang['concours_deadline_days']                         = ' Jours '; //':'
     209$lang['concours_deadline_hours']                        = ' Heures '; //':'
     210$lang['concours_deadline_mins']                         = ' Minutes '; //':'
     211$lang['concours_deadline_secs']                         = ' Secondes '; //'.'
     212$lang['concours_deadline_param']                                = 'Affichage de la deadline du concours ';
     213$lang['concours_deadline_param0']                               = '0-Pas d\'affichage';
     214$lang['concours_deadline_param1']                               = '1-Affichage v1';
     215$lang['concours_deadline_param2']                               = '2-Affichage v2';
     216
     217$lang['concours_begin']                                         = 'Début du concours dans ';
     218$lang['mask_thumbnail']                                         = 'Masquer les mignatures avant le démarrage du concours';
     219
     220$lang['concours_nb_concours_total']             = '<b>%d Concours stockés </b> (<i>%d Concours préparé(s) / %d Concours actif(s) / %d Concours clôturé(s)</i>)';
     221$lang['concours_nb_concours_page']                      = 'Nombre par page';
     222$lang['concours_status']                                        = 'Statut';
     223$lang['concours_delete_selected']                       = 'Suppression de concours';
     224$lang['concours_delete_all_closed']                     = 'Supprimer tous les concours clos';
     225$lang['concours_no_concours']                           = 'Aucun Concours %sdans la base de données';
     226$lang['concours_no_criteria']                           = 'Aucun critère enregistré';
     227
     228$lang['concours_global_score_title']            = 'Page de vote globale';
     229$lang['concours_global_score']                          = 'Cliquez ici pour ouvrir la page de vote globale';
     230$lang['concours_global_score_admin']            = 'Activer la page de vote globale (toutes images)';
     231$lang['concours_score_mode']                            = 'Mode de notation ';
     232$lang['concours_score_mode0']                           = '0-Mode texte';
     233$lang['concours_score_mode1']                           = '1-Mode étoile v1';
     234$lang['concours_notation']                                      = 'Score global de toutes photos du concours';
     235
     236$lang['CR_select_contest']                                      = 'Concours terminé a afficher';
     237$lang['closed-noresult_concours']                       = 'Concours terminés (sans résultats)';
     238$lang['concours_comment_short']                 = 'Commentaire sur la photo';
     239$lang['concours_nbscore']                               = 'votant(s)';
     240
     241$lang['prepared_concours_1']                            = 'préparé ';
     242$lang['active_concours_1']                                      = 'actif ';
     243$lang['closed_concours_1']                                      = 'terminé ';
     244$lang['closed_noresult_concours_1']                     = 'terminé (sans résultat) ';
     245$lang['concours_allow_admin']                   = 'Autoriser les Administrateurs';
     246$lang['concours_overlay_text']                  = 'Message à afficher';
     247
    108248?>
  • extensions/ConcoursPhoto/language/it_IT/index.php

    r11529 r32457  
    11<?php
    22// +-----------------------------------------------------------------------+
    3 // | Piwigo - a PHP based photo gallery                                    |
     3// | PhpWebGallery - a PHP based picture gallery                           |
     4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
     5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    46// +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
    6 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    7 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
     7// | file          : $Id: index.php 1912 2007-03-16 06:30:07Z rub $
     8// | last update   : $Date: 2007-03-16 07:30:07 +0100 (ven, 16 mar 2007) $
     9// | last modifier : $Author: rub $
     10// | revision      : $Revision: 1912 $
    811// +-----------------------------------------------------------------------+
    912// | This program is free software; you can redistribute it and/or modify  |
  • extensions/ConcoursPhoto/language/lv_LV/plugin.lang.php

    r11507 r32457  
    7070
    7171$lang['concours_mask_author'] = 'Maskēt sagatavota neaktīva konkursa autoru';
    72 $lang['concours_mask_exif'] = 'Maskēt EXIF/IPTC sagatavota neaktīvas konkursa datus';
     72//$lang['concours_mask_exif'] = 'Maskēt EXIF/IPTC sagatavota neaktīvas konkursa datus';
     73$lang['concours_mask_meta']             =  'Mask Metadata on picture for prepared inactive or active contest';
    7374
    7475$lang['thumbnail_global_note'] = 'Konkursa reitings';
     
    8283$lang['concours_method1'] = 'Novērtēto Summa';
    8384$lang['concours_method2'] = 'Vidējie vērtējumi';
     85$lang['concours_method3']               = 'Average of scores with moderation type 1';
     86$lang['concours_method4']               = 'Average of scores with moderation type 2';
    8487
    8588$lang['concours_note'] = 'Globālais vērtējums';
     
    8790$lang['concours_nbvotant'] = 'Balsojušo skaits';
    8891$lang['concours_usernote'] = 'Jūsu vērtējums';
     92$lang['concours_moderation1']           = 'Average (moderation 1)';
     93$lang['concours_moderation2']           = 'average (moderation 2)';
     94$lang['concours_warn_moderation']               = 'Warning : Average with moderation only calculated at the end of contest';
    8995$lang['concours_infos'] = 'Konkursa informācija';
    9096$lang['concours_audit'] = 'Pārbaude';
     
    95101$lang['all_users'] = '-- Visi --';
    96102$lang['concours_check_exaequo'] = 'Pārvaldīt exaequos';
    97 $lang['concours_author_vote'] = 'Atļaut foto autoram balsot (atslēgt pārbaudi, kas balstās uz lietotājvārds/autors)';
     103$lang['concours_author_vote']           = 'Control user/author for the contest vote : ';
     104$lang['concours_author_vote0']          = '0- No control (vote for any photos)';
     105$lang['concours_author_vote1']          = '1- Author control (vote not allowed if User=Author)';
     106$lang['concours_author_vote2']          = '2- Added_by control (vote not allowed if User=Added_by)';
     107$lang['concours_author_vote3']          = '3- Author or Added_by control (vote not allowed if User=Author or User=Added_by)';
     108$lang['concours_author_vote_detail']    = '<i>
     109          <ul>
     110          <li style="list-style-type: none;">0- No control : All users could show and vot for any photos .</li>
     111          <li style="list-style-type: none;">1- Author control : User cound not vote for photos whith same author information as user name .</li>
     112          <li style="list-style-type: none;">2- Added_by control : User cound not vote for photos added by himself.</li>
     113          <li style="list-style-type: none;">3- Author OR Added_by control: User cound not vote for photos whith same author information as user name or if photos are added by himself.</li>
     114                  </ul></i>
     115';
     116
     117
    98118$lang['concours_change_score'] = 'Atļaut lietotājam izmainīt savu vērtējumu pēc validācijas';
    99119$lang['concours_end_date_change_to'] = 'Beigu datums iznainīts uz %s';
     
    106126$lang['concours_admin_help'] = 'Ceļvedis/Palīdzība ConcoursPhoto spraudņa lietošanā';
    107127$lang['concours_audit_page'] = 'Konkursa Audits (pārbaude)';
     128
     129
     130$lang['manage_criteria']                                = 'Manage default criterias';
     131
     132
     133$lang['concours_stuffs_name']                   = 'Photo Contest';
     134$lang['concours_stuffs_description']    = 'Display the result of one photo contest (podium)';
     135
     136$lang['ConcoursPhoto_Fonctionality']    = 'ConcoursPhoto spraudnis Funkcionalitātes (Functionnalities)';
     137$lang['ConcoursPhoto_Fonctionality_txt'] = '
     138          <ul>
     139            <li>
     140            General Principle: On one album, allow a user list to note for photos during a set period. The result is then generated and displayed on a dedicated page accessible by users.
     141            <br/>
     142            Details below are steps to add a contest:
     143            </li>
     144            <li style="list-style-type: none;"><br/></li>
     145                        <li ><span class="throw"> Step 1 : Add a new contest on Piwigo:</span></li>
     146
     147<li style="list-style-type: none;"></li>
     148<li style="list-style-type: none;">- Click on the "Add Contests\" tab to add 1 new contest.</li>
     149<li style="list-style-type: none;">- Enter the name and description of the contest (eg Name = "Flowers" / Description = "Contest on the theme of flowers from xx / xx to xx / xx with Black & White photos).</li>
     150<li style="list-style-type: none;">- Select Groups Allowed to note Photos (if no group is present, all users are allowed).</li>
     151<li style="list-style-type: none;">- Set the start and end time of the contest.</li>
     152<li style="list-style-type: none;">- Choose the method of calculating the result (see details below for more details).</li>
     153<li style="list-style-type: none;">- Select the album in which the photos will be present for the contest.</li>
     154<li style="list-style-type: none;">- Confirm and go to step 2.</li>
     155            <li style="list-style-type: none;"><br/></li>
     156                        <li ><span class="throw"> Step 2 : Selection of rating criteria:</span></li>
     157<li style="list-style-type: none;">Note: The criteria of a contest are pre-initialized with the default criteria (see below to modify them)</li>
     158<li style="list-style-type: none;"></li>
     159<li style="list-style-type: none;">- Modify criteria / sub-criteria present.</li>
     160<li style="list-style-type: none;">- Or add new ones by clicking on "Add new criteria.</li>
     161<li style="list-style-type: none;"><i>To add a sub-criterion to an existing criterion, click on the icon to the right of the criterion (in the table).</i></li>
     162            <li style="list-style-type: none;"><br/></li>
     163                        <li ><span class="throw">Step 3 : The voting period:</span></li>
     164<li style="list-style-type: none;"></li>
     165<li style="list-style-type: none;">- During the voting period, the admin page allows you to view the intermediate result by clicking on the contest (<b> Manage Contests </b> tab).</li>
     166            <li style="list-style-type: none;"><br/></li>
     167                        <li ><span class="throw">Step 4 :Results:</span></li>
     168<li style="list-style-type: none;"></li>
     169<li style="list-style-type: none;">- At the end of the contest period, the result is generable on the admin page (<b> Manage Contests </b>).</li>
     170<li style="list-style-type: none;">- It is needed to click on the button to the right of the contest to generate the result (otherwise it will not be visible to users).</li>
     171<li style="list-style-type: none;">- After generating the result, a CSV file could be generated (click on the icon corresponding to the right of the contest).</li>
     172            <li style="list-style-type: none;"><br/></li>
     173         </ul>';
     174
     175
     176$lang['ConcoursPhoto_Options']          = 'Options and details of plugin Concours Photo';
     177$lang['ConcoursPhoto_Options_txt'] = '
     178          <ul>
     179            <li>
     180            Main options and rules for Photo Contest.
     181            <br/>
     182            </li>
     183            <li style="list-style-type: none;"><br/></li>
     184                        <li ><span class="throw"> Criteria, sub-criteria and default criteria</span></li>
     185<li style="list-style-type: none;">- The default criteria are those that are loaded when creating a new contest.</li>
     186<li style="list-style-type: none;">- The criteria and sub-criteria contain the following parameters: Name / Description / Note min / Note max / coefficient multipl.</li>
     187<li style="list-style-type: none;">- When a criterion contains sub-criteria, it is the latter that are used for the notation. In this case, the main criterion is used only as grouping.</li>
     188<li style="list-style-type: none;">- You can change the default criteria at any time, they will not affect competitions already in progress or completed.</li>
     189<li style="list-style-type: none;">- You can add as many default criteria and sub-criteria as you want.</li>
     190            <li style="list-style-type: none;"><br/></li>
     191                        <li ><span class="throw"> Methods of calculating the result</span></li>
     192<li style="list-style-type: none;">There are 4 methods of calculating the final score :</li>
     193<li style="list-style-type: none;">- "Sum" -> It corresponds to the simple sum of the scores / scores obtained per photo that defines the ranking regardless of the number of voters for the photos.</li>
     194<li style="list-style-type: none;">- "Average" -> It corresponds the average of the scores / scores obtained by photo between the voters (for the same photo) which defines the ranking.</li>
     195<li style="list-style-type: none;">- "Average (ponderation1)" -> It corresponds is the average of the scores / scores obtained per photo that defines the ranking. If a user does not vote for all the photos, they are awarded a score corresponding to the average score of the same voter</li>
     196<li style="list-style-type: none;">- "Average (ponderation2)" -> This is the average of the scores / scores obtained per photo that defines the ranking. An increase / decrease is calculated as a function of the difference between the minimum and maxi scores of the same voter. This mark-up is added to the photo\'s score before calculating the result.</li>
     197<li style="list-style-type: none;"></li>
     198<li style="list-style-type: none;"><i>Moderation 1 and 2 reduce the significant difference in score and rebalance the votes.</i></li>
     199            <li style="list-style-type: none;"><br/></li>
     200                        <li ><span class="throw"> Use of PWG_Stuffs modules</span></li>
     201<li style="list-style-type: none;">- Once the contest is closed (<u> and the result generated </u>), the result is accessible via the link present in the piwigo menu.</li>
     202<li style="list-style-type: none;">- You can also add a module with PWG_Stuffs which allows to highlight the podium of winning photos.</li>
     203            <li style="list-style-type: none;"><br/></li>
     204          </ul>';
     205
     206$lang['concours_deadline']                                      = 'Contest deadline ';
     207$lang['concours_begin']                                         = 'Contest starts in';
     208$lang['concours_deadline_days']                         = ' Days '; //':'
     209$lang['concours_deadline_hours']                        = ' Hours '; //':'
     210$lang['concours_deadline_mins']                         = ' Minutes '; //':'
     211$lang['concours_deadline_secs']                         = ' Seconds '; //'.'
     212$lang['concours_deadline_param']                                = 'Display deadline contest ';
     213$lang['concours_deadline_param0']                               = '0-No display';
     214$lang['concours_deadline_param1']                               = '1-Display v1';
     215$lang['concours_deadline_param2']                               = '2-Display v2';
     216
     217$lang['concours_begin']                                         = 'Contest begin in ';
     218$lang['mask_thumbnail']                                         = 'Mask thumbnails before contest start';
     219
     220$lang['concours_nb_concours_total']             = '<b>%d Contests saved </b> (<i>%d Prepared contest(s) / %d Active contest(s) / %d Closed contest(s)</i>)';
     221$lang['concours_nb_concours_page']                      = 'Number by page';
     222$lang['concours_status']                                        = 'Status';
     223$lang['concours_delete_selected']                       = 'Delete the contest';
     224$lang['concours_delete_all_closed']                     = 'Delete all closed contests';
     225$lang['concours_no_concours']                           = 'No contest saved in database';
     226$lang['concours_no_criteria']                           = 'No criteria saved';
     227
     228$lang['concours_global_score_title']            = 'Global score page';
     229$lang['concours_global_score']                          = 'Click to display Global score page';
     230$lang['concours_global_score_admin']            = 'Active global score page (all pictures)';
     231$lang['concours_score_mode']                            = 'Score display mode ';
     232$lang['concours_score_mode0']                           = '0-Text mode';
     233$lang['concours_score_mode1']                           = '1-Star v1 mode';
     234$lang['concours_notation']                                      = 'Global note of all contest pictures';
     235
     236$lang['CR_select_contest']                                      = 'Closed contest to display';
     237$lang['closed-noresult_concours']                       = 'closed contest (withouyt results)';
     238$lang['concours_comment_short']                 = 'Picture comment';
     239$lang['concours_nbscore']                               = 'Number of votes';
     240
     241$lang['prepared_concours_1']                            = 'prepared ';
     242$lang['active_concours_1']                                      = 'actived ';
     243$lang['closed_concours_1']                                      = 'closed ';
     244$lang['closed_noresult_concours_1']                     = 'closed (without result) ';
     245$lang['concours_allow_admin']                   = 'Allow Admin';
     246$lang['concours_overlay_text']                  = 'Text to display';
     247
    108248?>
  • extensions/ConcoursPhoto/language/sk_SK/plugin.lang.php

    r9512 r32457  
    7070
    7171$lang['concours_mask_author']           =  'Zakryť autora pre pripravené neaktívne hodnotenie';
    72 $lang['concours_mask_exif']             =  'Zakryť EXIF/IPTC údaje pre pripravené neaktívne hodnotenie';
     72//$lang['concours_mask_exif']             =  'Zakryť EXIF/IPTC údaje pre pripravené neaktívne hodnotenie';
     73$lang['concours_mask_meta']             =  'Mask Metadata on picture for prepared inactive or active contest';
    7374
    7475$lang['thumbnail_global_note']          = 'Bodovanie hodnotenia';
     
    8283$lang['concours_method1']               = 'Súčet bodov';
    8384$lang['concours_method2']               = 'Priemer bodov';
     85$lang['concours_method3']               = 'Priemer bodov (moderation type 1)';
     86$lang['concours_method4']               = 'Priemer bodov (moderation type 2)';
    8487
    8588$lang['concours_note']                  = 'Celkovo bodov';
     
    8790$lang['concours_nbvotant']              = 'Počet hlasovaní';
    8891$lang['concours_usernote']              = 'Vaše body';
     92$lang['concours_moderation1']           = 'Priemer (moderation 1)';
     93$lang['concours_moderation2']           = 'Priemer (moderation 2)';
     94$lang['concours_warn_moderation']               = 'Warning : Average with moderation only calculated at the end of contest';
    8995$lang['concours_infos']                 = 'Informácia o hodnotení';
    9096$lang['concours_audit']                 = 'Kontrola';
     
    95101$lang['all_users']                      = '-- Všetci --';
    96102$lang['concours_check_exaequo']         = 'Ovládanie exaequos';
    97 $lang['concours_author_vote']           = 'Povoliť autorovi fotografie hlasovať (zakázať kontrolu na používateľ/autor)';
     103$lang['concours_author_vote']           = 'Control user/author for the contest vote : ';
     104$lang['concours_author_vote0']          = '0- No control (vote for any photos)';
     105$lang['concours_author_vote1']          = '1- Author control (vote not allowed if User=Author)';
     106$lang['concours_author_vote2']          = '2- Added_by control (vote not allowed if User=Added_by)';
     107$lang['concours_author_vote3']          = '3- Author or Added_by control (vote not allowed if User=Author or User=Added_by)';
     108$lang['concours_author_vote_detail']    = '<i>
     109          <ul>
     110          <li style="list-style-type: none;">0- No control : All users could show and vot for any photos .</li>
     111          <li style="list-style-type: none;">1- Author control : User cound not vote for photos whith same author information as user name .</li>
     112          <li style="list-style-type: none;">2- Added_by control : User cound not vote for photos added by himself.</li>
     113          <li style="list-style-type: none;">3- Author OR Added_by control: User cound not vote for photos whith same author information as user name or if photos are added by himself.</li>
     114                  </ul></i>
     115';
     116
     117
    98118$lang['concours_change_score']          = 'Povoliť používateľovi zmeniť jeho bodovanie po kontrole';
    99119$lang['concours_end_date_change_to']    = 'Konečný dátum zmenený na %s';
     
    106126$lang['concours_admin_help']            = 'Návod/Pomoc pre doplnok ConcoursPhoto';
    107127$lang['concours_audit_page']            = 'Kontrola hodnotenia';
     128
     129
     130$lang['manage_criteria']                                = 'Manage default criterias';
     131
     132
     133$lang['concours_stuffs_name']                   = 'Photo Contest';
     134$lang['concours_stuffs_description']    = 'Display the result of one photo contest (podium)';
     135
     136$lang['ConcoursPhoto_Fonctionality']    = 'Concours Photo plugin functionnalities';
     137$lang['ConcoursPhoto_Fonctionality_txt'] = '
     138          <ul>
     139            <li>
     140            General Principle: On one album, allow a user list to note for photos during a set period. The result is then generated and displayed on a dedicated page accessible by users.
     141            <br/>
     142            Details below are steps to add a contest:
     143            </li>
     144            <li style="list-style-type: none;"><br/></li>
     145                        <li ><span class="throw"> Step 1 : Add a new contest on Piwigo:</span></li>
     146
     147<li style="list-style-type: none;"></li>
     148<li style="list-style-type: none;">- Click on the "Add Contests\" tab to add 1 new contest.</li>
     149<li style="list-style-type: none;">- Enter the name and description of the contest (eg Name = "Flowers" / Description = "Contest on the theme of flowers from xx / xx to xx / xx with Black & White photos).</li>
     150<li style="list-style-type: none;">- Select Groups Allowed to note Photos (if no group is present, all users are allowed).</li>
     151<li style="list-style-type: none;">- Set the start and end time of the contest.</li>
     152<li style="list-style-type: none;">- Choose the method of calculating the result (see details below for more details).</li>
     153<li style="list-style-type: none;">- Select the album in which the photos will be present for the contest.</li>
     154<li style="list-style-type: none;">- Confirm and go to step 2.</li>
     155            <li style="list-style-type: none;"><br/></li>
     156                        <li ><span class="throw"> Step 2 : Selection of rating criteria:</span></li>
     157<li style="list-style-type: none;">Note: The criteria of a contest are pre-initialized with the default criteria (see below to modify them)</li>
     158<li style="list-style-type: none;"></li>
     159<li style="list-style-type: none;">- Modify criteria / sub-criteria present.</li>
     160<li style="list-style-type: none;">- Or add new ones by clicking on "Add new criteria.</li>
     161<li style="list-style-type: none;"><i>To add a sub-criterion to an existing criterion, click on the icon to the right of the criterion (in the table).</i></li>
     162            <li style="list-style-type: none;"><br/></li>
     163                        <li ><span class="throw">Step 3 : The voting period:</span></li>
     164<li style="list-style-type: none;"></li>
     165<li style="list-style-type: none;">- During the voting period, the admin page allows you to view the intermediate result by clicking on the contest (<b> Manage Contests </b> tab).</li>
     166            <li style="list-style-type: none;"><br/></li>
     167                        <li ><span class="throw">Step 4 :Results:</span></li>
     168<li style="list-style-type: none;"></li>
     169<li style="list-style-type: none;">- At the end of the contest period, the result is generable on the admin page (<b> Manage Contests </b>).</li>
     170<li style="list-style-type: none;">- It is needed to click on the button to the right of the contest to generate the result (otherwise it will not be visible to users).</li>
     171<li style="list-style-type: none;">- After generating the result, a CSV file could be generated (click on the icon corresponding to the right of the contest).</li>
     172            <li style="list-style-type: none;"><br/></li>
     173         </ul>';
     174
     175
     176$lang['ConcoursPhoto_Options']          = 'Options and details of plugin Concours Photo';
     177$lang['ConcoursPhoto_Options_txt'] = '
     178          <ul>
     179            <li>
     180            Main options and rules for Photo Contest.
     181            <br/>
     182            </li>
     183            <li style="list-style-type: none;"><br/></li>
     184                        <li ><span class="throw"> Criteria, sub-criteria and default criteria</span></li>
     185<li style="list-style-type: none;">- The default criteria are those that are loaded when creating a new contest.</li>
     186<li style="list-style-type: none;">- The criteria and sub-criteria contain the following parameters: Name / Description / Note min / Note max / coefficient multipl.</li>
     187<li style="list-style-type: none;">- When a criterion contains sub-criteria, it is the latter that are used for the notation. In this case, the main criterion is used only as grouping.</li>
     188<li style="list-style-type: none;">- You can change the default criteria at any time, they will not affect competitions already in progress or completed.</li>
     189<li style="list-style-type: none;">- You can add as many default criteria and sub-criteria as you want.</li>
     190            <li style="list-style-type: none;"><br/></li>
     191                        <li ><span class="throw"> Methods of calculating the result</span></li>
     192<li style="list-style-type: none;">There are 4 methods of calculating the final score :</li>
     193<li style="list-style-type: none;">- "Sum" -> It corresponds to the simple sum of the scores / scores obtained per photo that defines the ranking regardless of the number of voters for the photos.</li>
     194<li style="list-style-type: none;">- "Average" -> It corresponds the average of the scores / scores obtained by photo between the voters (for the same photo) which defines the ranking.</li>
     195<li style="list-style-type: none;">- "Average (ponderation1)" -> It corresponds is the average of the scores / scores obtained per photo that defines the ranking. If a user does not vote for all the photos, they are awarded a score corresponding to the average score of the same voter</li>
     196<li style="list-style-type: none;">- "Average (ponderation2)" -> This is the average of the scores / scores obtained per photo that defines the ranking. An increase / decrease is calculated as a function of the difference between the minimum and maxi scores of the same voter. This mark-up is added to the photo\'s score before calculating the result.</li>
     197<li style="list-style-type: none;"></li>
     198<li style="list-style-type: none;"><i>Moderation 1 and 2 reduce the significant difference in score and rebalance the votes.</i></li>
     199            <li style="list-style-type: none;"><br/></li>
     200                        <li ><span class="throw"> Use of PWG_Stuffs modules</span></li>
     201<li style="list-style-type: none;">- Once the contest is closed (<u> and the result generated </u>), the result is accessible via the link present in the piwigo menu.</li>
     202<li style="list-style-type: none;">- You can also add a module with PWG_Stuffs which allows to highlight the podium of winning photos.</li>
     203            <li style="list-style-type: none;"><br/></li>
     204          </ul>';
     205
     206$lang['concours_deadline']                                      = 'Contest deadline ';
     207$lang['concours_begin']                                         = 'Contest starts in';
     208$lang['concours_deadline_days']                         = ' Days '; //':'
     209$lang['concours_deadline_hours']                        = ' Hours '; //':'
     210$lang['concours_deadline_mins']                         = ' Minutes '; //':'
     211$lang['concours_deadline_secs']                         = ' Seconds '; //'.'
     212$lang['concours_deadline_param']                                = 'Display deadline contest ';
     213$lang['concours_deadline_param0']                               = '0-No display';
     214$lang['concours_deadline_param1']                               = '1-Display v1';
     215$lang['concours_deadline_param2']                               = '2-Display v2';
     216
     217$lang['concours_begin']                                         = 'Contest begin in ';
     218$lang['mask_thumbnail']                                         = 'Mask thumbnails before contest start';
     219
     220$lang['concours_nb_concours_total']             = '<b>%d Contests saved </b> (<i>%d Prepared contest(s) / %d Active contest(s) / %d Closed contest(s)</i>)';
     221$lang['concours_nb_concours_page']                      = 'Number by page';
     222$lang['concours_status']                                        = 'Status';
     223$lang['concours_delete_selected']                       = 'Delete the contest';
     224$lang['concours_delete_all_closed']                     = 'Delete all closed contests';
     225$lang['concours_no_concours']                           = 'No contest saved in database';
     226$lang['concours_no_criteria']                           = 'No criteria saved';
     227
     228$lang['concours_global_score_title']            = 'Global score page';
     229$lang['concours_global_score']                          = 'Click to display Global score page';
     230$lang['concours_global_score_admin']            = 'Active global score page (all pictures)';
     231$lang['concours_score_mode']                            = 'Score display mode ';
     232$lang['concours_score_mode0']                           = '0-Text mode';
     233$lang['concours_score_mode1']                           = '1-Star v1 mode';
     234$lang['concours_notation']                                      = 'Global note of all contest pictures';
     235
     236$lang['CR_select_contest']                                      = 'Closed contest to display';
     237$lang['closed-noresult_concours']                       = 'closed contest (withouyt results)';
     238$lang['concours_comment_short']                 = 'Picture comment';
     239$lang['concours_nbscore']                               = 'Number of votes';
     240
     241$lang['prepared_concours_1']                            = 'prepared ';
     242$lang['active_concours_1']                                      = 'actived ';
     243$lang['closed_concours_1']                                      = 'closed ';
     244$lang['closed_noresult_concours_1']                     = 'closed (without result) ';
     245$lang['concours_allow_admin']                   = 'Allow Admin';
     246$lang['concours_overlay_text']                  = 'Text to display';
     247
    108248?>
  • extensions/ConcoursPhoto/main.inc.php

    r9370 r32457  
    11<?php
    22/*
    3  * Plugin Name: ConcoursPhoto
    4  * Version: 2.0.0
    5  * Description: Concours de photo paramétrable
    6  * Plugin URI: http://piwigo.org/ext/extension_view.php?eid=323
    7  * Author: Tiico
    8  * Author URI:
    9  * */
     3 Plugin Name: ConcoursPhoto
     4 Version: 11.0.0
     5 Description: Concours de photo paramétrable
     6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=323
     7 Author: Tiico
     8 Author URI: 
     9 Has Settings: true
     10*/
    1011/********* Fichier main.inc.php  *********/
    1112
     
    1718global $prefixeTable;
    1819
    19 define('CONCOURS_VERSION', '2.0.0 [BETA]');       //
     20define('CONCOURS_VERSION', '11.0.1');       //
    2021
    2122
     
    4849$concours = new Concours();
    4950
     51// disable meta to picture page (if param)
     52add_event_handler('loc_begin_picture',array(&$concours, 'disable_meta_to_picture'));
     53
     54
    5055// Add concours to picture page
    5156add_event_handler('loc_end_picture', array(&$concours, 'display_concours_to_picture'));
    52 // Add admin page
    53 add_event_handler('get_admin_plugin_menu_links', array(&$concours, 'concours_admin_menu') );
     57// Add admin page - DEPRECATED
     58//add_event_handler('get_admin_plugin_menu_links', array(&$concours, 'concours_admin_menu') );
    5459
    5560// MenuBar
     
    5964add_event_handler('loc_end_section_init', array(&$concours, 'section_init_concours'));
    6065
     66// Publish result page
    6167add_event_handler('loc_end_index', array(&$concours, 'index_concours'));
     68
     69// Global vote page (with all thumbnails)
     70add_event_handler('loc_end_index', array(&$concours, 'index_vote_concours'));
     71
    6272
    6373// Add Global note under thumbnail
    6474add_event_handler('loc_end_index_thumbnails', array(&$concours, 'thumbnail_note'), 50, 2);
     75
     76// Add PWG Stuffs
     77add_event_handler('get_stuffs_modules', array(&$concours, 'concours_stuffs_module'));
     78
     79// Add description with contest informations on category
     80add_event_handler ('render_category_description', array(&$concours, 'add_contest_desc'), EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     81
     82
     83
     84/* +-----------------------------------------------------------------------+
     85 * | CSS/JS Style                                                          |
     86 * +-----------------------------------------------------------------------+ */
     87add_event_handler('loc_end_page_header', 'ConcoursPhoto_css_js');
     88
     89function ConcoursPhoto_css_js() {
     90        global $template;
     91       
     92        $template->append('head_elements', '<link rel="stylesheet" type="text/css" href="'.CONCOURS_PATH . 'template/style.css">');
     93}
     94
    6595
    6696
  • extensions/ConcoursPhoto/publish.php

    r8946 r32457  
    3535                                'BEGIN_DATE'    => $concours->concours_infos['begin_date'],
    3636                                'END_DATE'      => $concours->concours_infos['end_date'],
    37                                 'METHOD'        => l10n("concours_method".$concours->concours_infos['method'])
     37                                'METHOD'        => l10n("concours_method".$concours->concours_infos['method']),
     38                                'METHODNB'      => $concours->concours_infos['method']
    3839                                ));
    3940
     
    4445        $concours->concours_infos['method'] = 1;
    4546
    46 $query = 'SELECT DISTINCT(img.id), img.name, img.file, img.path, img.tn_ext,img.author,
    47                   ic.category_id, cat.name AS catname, conc.note, conc.moyenne, conc.nbvotant'
     47$query = 'SELECT DISTINCT(img.id), img.name, img.file, img.path, img.author,
     48                  ic.category_id, cat.name AS catname, conc.note, conc.moyenne, conc.moderation1, conc.moderation2, conc.nbvotant'
    4849                .' FROM ' . IMAGES_TABLE.' AS img'
    4950                .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
     
    5152                .' INNER JOIN '.CONCOURS_RESULT_TABLE.' AS conc ON conc.img_id = img.id'
    5253                .' WHERE ic.category_id = '.$concours->concours_infos['category']
    53                 .' AND conc.id_concours = '.$concours->concours_infos['id']
    54         ;
     54                .' AND conc.id_concours = '.$concours->concours_infos['id'];
    5555
    56 if ($concours->concours_infos['method'] == 1)   // total
    57         $query .= ' ORDER BY note DESC';
    58 elseif ($concours->concours_infos['method'] == 2)       // moyenne
    59         $query .= ' ORDER BY moyenne DESC';
     56               
     57switch ($concours->concours_infos['method'])
     58{
     59        case 1 :// total
     60                $query .= ' ORDER BY note DESC';
     61                break;
     62        case 2 :// moyenne
     63                $query .= ' ORDER BY moyenne  DESC';
     64                break;
     65        case 3 :// moderation1
     66                $query .= ' ORDER BY moderation1 DESC';
     67                break;
     68        case 4 :// moderation2
     69                $query .= ' ORDER BY moderation2 DESC';
     70                break;
     71}
     72
    6073
    6174$query .=';';
     
    6477$rang = 1;
    6578$previousNote = $previousMoy = 0;
    66 while ($row = mysql_fetch_assoc($result))
     79while ($row = pwg_db_fetch_array($result))
    6780{
    6881        // link on picture.php page
     
    101114               AND ($row['note'] == $previousNote))
    102115             OR  ($concours->concours_infos['method'] == 2      // moyenne
    103                   AND ($row['moyenne'] == $previousMoy)))
     116                  AND ($row['moyenne'] == $previousMoy))
     117             OR  ($concours->concours_infos['method'] == 3      // moderation1
     118                  AND ($row['moderation1'] == $previousMoy))
     119             OR  ($concours->concours_infos['method'] == 4      // moderation2
     120                  AND ($row['moderation2'] == $previousMoy)))
     121                                 
    104122        {
    105123//            echo "Rang=".$rang."\n";
     
    108126        }
    109127    }
    110 
     128        $usernote = $concours->get_img_globalnote_user($row['id'], null, null, $user['ipguest']);
    111129        $template->append( 'concours_note', array(
    112130                        'img_id' => $row['id'],
     
    115133                        'author'        => $row['author'],
    116134                        'rang'  => $rang,
    117                         'thumb' => get_thumbnail_url($row),
     135//                      'thumb' => DerivativeImage::thumb_url($row),
     136                        'thumb' => DerivativeImage::url(IMG_XXSMALL, $row),
    118137                        'url'   => $url,
    119138                        'note'  => ($row['note'] == 0 ? 'N/A' :$row['note']),
    120                         'moyenne'       => ($row['moyenne'] == 0 ? 'N/A' :$row['moyenne']),
     139                        'moyenne'       => ($row['moyenne'] == 0 ? 'N/A' : round($row['moyenne'] , 2)),
     140                        'moderation1'   => ($row['moderation1'] == 0 ? 'N/A' : round($row['moderation1'], 2) ),
     141                        'moderation2'   => ($row['moderation2'] == 0 ? 'N/A' : round($row['moderation2'], 2)),                 
    121142                        'nbvotant'      => $row['nbvotant'],
    122                         'usernote'      => $concours->get_img_globalnote_user($row['id'], null, null, $user['ipguest'])
     143                        'usernote'      => ($usernote < 0 ? "N/A" : $usernote)
    123144                       
    124145                ));
  • extensions/ConcoursPhoto/template/concours.tpl

    r8946 r32457  
     1{combine_css path= 'plugins/ConcoursPhoto/template/overlay.css'}
     2
     3
     4{if $SCORE_MODE ==1}
     5{combine_css path= 'plugins/ConcoursPhoto/template/rating1.css'}
     6{/if}
     7
     8
     9{if $concours_infos.deadline_type == 1}
     10
     11        {combine_css path= 'plugins/ConcoursPhoto/template/concours-1.css'}
     12
     13        {literal}
     14        <script type="text/javascript">
     15        const second = 1000,
     16                  minute = second * 60,
     17                  hour = minute * 60,
     18                  day = hour * 24;
     19
     20        let countDown = new Date({/literal}'{$concours_infos.end_date}'{literal}).getTime(),
     21                x = setInterval(function() {
     22
     23                  let now = new Date().getTime(),
     24                          distance = countDown - now;
     25
     26                  document.getElementById('days').innerText = Math.floor(distance / (day)),
     27                        document.getElementById('hours').innerText = Math.floor((distance % (day)) / (hour)),
     28                        document.getElementById('minutes').innerText = Math.floor((distance % (hour)) / (minute)),
     29                        document.getElementById('seconds').innerText = Math.floor((distance % (minute)) / second);
     30                 
     31                }, second)
     32
     33
     34        </script>
     35        {/literal}
     36
     37        <div class="concours">
     38                <form  method="post" action="{$CONCOURS_F_ACTIONS}" class="concours">
     39                <div class="counter">
     40                  <div id="head">{'concours_deadline'|@translate}</div>
     41                  <ul>
     42                        <li><span id="days"></span>{'concours_deadline_days'|@translate}</li>
     43                        <li><span id="hours"></span>{'concours_deadline_hours'|@translate}</li>
     44                        <li><span id="minutes"></span>{'concours_deadline_mins'|@translate}</li>
     45                        <li><span id="seconds"></span>{'concours_deadline_secs'|@translate}</li>
     46                  </ul>
     47                </div>
     48
     49
     50{elseif $concours_infos.deadline_type == 2}
     51
     52
     53        {strip}
     54
     55                {combine_css path='plugins/ConcoursPhoto/template/concours-2.css'}
     56                {combine_script id='moment' load='footer' path='plugins/ConcoursPhoto/template/moment.js'}
     57                {combine_script id='vue.min' load='footer' path='plugins/ConcoursPhoto/template/vue.min.js'}
     58                {combine_script id='deadline' load='footer' require='vue.min' path='plugins/ConcoursPhoto/template/deadline.js'}
     59        {/strip}
     60
     61        <div class="concours">
     62                <form  method="post" action="{$CONCOURS_F_ACTIONS}" class="concours">
     63                <div class="counter">
     64        <div class="countdown-head">{'concours_deadline'|@translate}</div>
     65        {literal}
     66
     67                <div id="countdown">
     68        {/literal}
     69                <countdown duration="{$concours_infos.end_concours_min} second"></countdown>
     70        {literal}
     71                </div>
     72        </div>
     73
     74        <template id="countdown-template">
     75                <div class="countdown">
     76                        <div class="blockdeadline" :class="clDays">
     77                                <div class="digit">{{ days | two_digits }}</div>
     78        {/literal}
     79                                <div class="text">{'concours_deadline_days'|@translate}</div>
     80        {literal}
     81                        </div>
     82                        <div class="blockdeadline" :class="clHours">
     83                                <div class="digit">{{ hours | two_digits }}</div>
     84        {/literal}
     85                                <div class="text">{'concours_deadline_hours'|@translate}</div>
     86        {literal}
     87                        </div>
     88                        <div class="blockdeadline" :class="clMinutes">
     89                                <div class="digit">{{ minutes | two_digits }}</div>
     90        {/literal}
     91                                <div class="text">{'concours_deadline_mins'|@translate}</div>
     92        {literal}
     93                        </div>
     94                        <div class="blockdeadline" :class="clSeconds">
     95                                <div class="digit">{{ seconds | two_digits }}</div>
     96        {/literal}
     97                                <div class="text">{'concours_deadline_secs'|@translate}</div>
     98                        </div>
     99                </div>
     100        </template>
     101
     102
     103
     104{else if $concours_infos.deadline_type == 0}
     105
    1106<div class="concours">
    2107        <form  method="post" action="{$CONCOURS_F_ACTIONS}" class="concours">
     108{/if}
     109
    3110        <fieldset>
    4111                <legend>Concours Photo</legend>
     112
     113{if !$CONCOURS_CHANGE_SCORE}
     114<div class="container_mod">
     115{/if}
     116               
    5117        <table>
    6118                <tr>
     
    9121                        </td>
    10122            <td align="right" colspan="2">
    11                 {'concours_global_user_note'|@translate} : <input type="text" size="4" maxlength="4" name="global_note" value="{$concours_infos.note}" disabled="disabled"/>&nbsp;
     123                {'concours_global_user_note'|@translate} : <b>{$concours_infos.note}</b> / {$concours_infos.max_note} &nbsp;
     124                        {if $SCORE_MODE ==1}
     125                                                <fieldset class="rating1" align="left">
     126                                                {for $var={$concours_infos.max_note} to 1 step -1}
     127                                                        <input type="radio" id="star_{$concours_infos}__{$var}" name="{$concours_infos}_" value="{$var}" {if $var==$concours_infos.note}checked="checked"{/if} disabled="disabled" />
     128                                                        <label class = "full" for="star_{$concours_infos}__{$var}" title="{$var}"></label>                     
     129                                                        <input type="radio" id="star_{$concours_infos}__{$var-1}_half" name="{$concours_infos}_" value="{$var-0.5}" {if $var-0.5==$concours_infos.note}checked="checked"{/if} disabled="disabled"/>
     130                                                        <label class = "half" for="star_{$concours_infos}__{$var-1}_half" title="{$var-0.5}"></label>                   
     131                                                {/for}
     132                                                </fieldset>
     133                                        {/if}
     134
    12135            </td>
    13136            <td>&nbsp;
     
    15138                </tr>
    16139                <tr><td colspan="5"><br></td></tr>
    17                  {foreach from=$concours_criteria item=concours_criteria}
    18                         <tr>
    19                         {if $concours_criteria.level == 1}
    20                                 <td align="left" colspan="2"><b><u>{$concours_criteria.name}</u></b>&nbsp;
    21                                         (<b><i>{$concours_criteria.lib}</i></b>)&nbsp;&nbsp;</td>               
     140                 {foreach $concours_criteria as $concours_criteria1}
     141                        <tr align="left">
     142                        {if $concours_criteria1.level == 1}
     143                                <td align="left" colspan="2"><b><u>{$concours_criteria1.name}</u></b>&nbsp;
     144                                        (<b><i>{$concours_criteria1.lib}</i></b>)&nbsp;&nbsp;</td>             
    22145                        {else}
    23146                                <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>               
    24                                 <td><i>{$concours_criteria.name}&nbsp;&nbsp;</i></td>
    25                         {/if}
    26                         {if $concours_criteria.level == 1}
     147                                <td><i>{$concours_criteria1.name}&nbsp;&nbsp;</i></td>
     148                        {/if}
     149                        {if $concours_criteria1.level == 1}
    27150                                <td align="left" >&nbsp;</td>
    28151                        {else}
    29                                 <td><i>{$concours_criteria.lib}&nbsp;&nbsp;</i></td>
    30                         {/if}
    31                         {if $concours_criteria.nosub}
    32                         <td><input type="text" size="4" maxlength="4" value="{$concours_criteria.val}" name="{$concours_criteria.id}" /></td>
    33                         <td><i>(Min={$concours_criteria.min}&nbsp;;Max={$concours_criteria.max})&nbsp;</i></td>
     152                                <td><i>{$concours_criteria1.lib}&nbsp;&nbsp;</i></td>
     153                        {/if}
     154                        {if $concours_criteria1.nosub}
     155                        <td width=200>
     156                        {if $SCORE_MODE == 0}
     157                        <input type="text" size="4" maxlength="4" value="{$concours_criteria1.val}" name="{$concours_criteria1.id}" {if !$CONCOURS_CHANGE_SCORE}disabled="disabled"{/if}/>
     158                        {elseif $SCORE_MODE ==1}
     159                       
     160                        <fieldset class="rating">
     161                        {for $var={$concours_criteria1.max} to {$concours_criteria1.min + 1} step -1}
     162                                <input type="radio" id="star_{$concours_criteria1.id}_{$var}" name="{$concours_criteria1.id}" value="{$var}" {if $var==$concours_criteria1.val}checked{/if}  {if !$CONCOURS_CHANGE_SCORE}disabled="disabled"{/if}/>
     163                                <label class = "full" for="star_{$concours_criteria1.id}_{$var}" title="{$var}"></label>                       
     164                                <input type="radio" id="star_{$concours_criteria1.id}_{$var-1}_half" name="{$concours_criteria1.id}" value="{$var-0.5}" {if $var-0.5==$concours_criteria1.val}checked{/if} {if !$CONCOURS_CHANGE_SCORE}disabled="disabled"{/if}/>
     165                                <label class = "half" for="star_{$concours_criteria1.id}_{$var-1}_half" title="{$var-0.5}"></label>                     
     166                        {/for}
     167                        </fieldset>                     
     168                       
     169{******
     170                        <section id="rateConcours" class="ratingConcours">
     171                        {for $var={$concours_criteria1.max} to {$concours_criteria1.min} step -1}
     172                          <input type="radio" id="star_{$concours_criteria1.id}_{$var}" name="{$concours_criteria1.id}" value="{$var}" {if $var==$concours_criteria1.val}checked{/if}/>
     173                          <label for="star_{$concours_criteria1.id}_{$var}" title="{$var}">&#9733;</label>
     174                        {/for}
     175                        </section>
     176******}
     177
     178
     179                        {/if}
     180                        </td>
     181                       
     182                        <td><i>(Min={$concours_criteria1.min}&nbsp;;Max={$concours_criteria1.max})&nbsp;</i></td>
    34183                        {else}
    35184                                <td colspan="2">&nbsp;</td>             
     
    41190                        <td colspan="2">{'concours_comment'|@translate}&nbsp;</td>
    42191                        <td colspan="3">
    43                         <textarea cols="50" rows="4" name="concours_comment" id="concours_comment">{$CONCOURS_COMMENT}</textarea>
     192                        <textarea cols="50" rows="4" name="concours_comment" id="concours_comment" {if !$CONCOURS_CHANGE_SCORE}disabled="disabled"{/if}>{$CONCOURS_COMMENT} </textarea>
    44193                        </td>
    45194                </tr>           
    46195
     196       
     197{if !$CONCOURS_CHANGE_SCORE}
     198  <div class="middle_mod">
     199    <div class="text_mod">{$TEXT_OVERLAY}</div><br>
     200    <div class="text_mod">{$TEXT_OVERLAY}</div><br>
     201  </div>
     202{/if}
    47203        </table>
     204{if !$CONCOURS_CHANGE_SCORE}
     205</div>{/if}
     206
    48207        <p>
    49208    {if $CONCOURS_CHANGE_SCORE}
  • extensions/ConcoursPhoto/template/concours_menu.tpl

    r8946 r32457  
     1<dt>{'Concours'|@translate}</dt>
     2<dd>
     3        <ul>{strip}
     4        {foreach from=$block->data item=link}
     5                {if is_array($link)}
     6                        <li><a href="{$link.URL}" title="{$link.TITLE}"{if isset($link.REL)} {$link.REL}{/if}>{$link.NAME}</a>{if isset($link.COUNTER)} ({$link.COUNTER}){/if}
     7            {if $link.edit!=""} [<a href="{$link.edit}">{"concours_admin_edit"|@translate}</a>]
     8            {/if}
     9            </li>
    110
    2 {if isset($block->data) and count($block->data)}
    3   <!-- Concours menu bar -->
    4   {if $block->get_title() !="" }
    5     <dt>{$block->get_title()}</dt>
    6   {/if}
    7   <dd>
    8     <ul>
    9       {foreach from=$block->data key=name item=link}
    10         <li>
    11           {$link.nfo}<a href="{$link.link}">{$link.text}</a>
    12           {if $link.edit!=""} [<a href="{$link.edit}">{"concours_admin_edit"|@translate}</a>]
    13           {/if}
    14         </li>
    15       {/foreach}
    16     </ul>
    17   </dd>
    18 {/if}
     11                {/if}
     12        {/foreach}
     13        {/strip}</ul>
     14</dd>
     15
     16
     17
     18
  • extensions/ConcoursPhoto/template/result.tpl

    r8946 r32457  
    1616        <table>
    1717                <tr><td colspan="5"><br></td></tr>
    18                  {foreach from=$concours_note item=concours_note}
     18                 {foreach $concours_note as $concours_note1}
    1919                        <tr>
    20                                 <td><b><i> {if $concours_note.nbvotant != 0}
    21                             ({$concours_note.rang}{if $concours_note.rang == 1}{'concours_1st'|@translate}
    22                                                                                                  {elseif $concours_note.rang == 2}{'concours_2nd'|@translate}
    23                                                                                                  {elseif $concours_note.rang == 3}{'concours_3rd'|@translate}
     20                                <td><b><i> {if $concours_note1.nbvotant != 0}
     21                            ({$concours_note1.rang}{if $concours_note1.rang == 1}{'concours_1st'|@translate}
     22                                                                                                 {elseif $concours_note1.rang == 2}{'concours_2nd'|@translate}
     23                                                                                                 {elseif $concours_note1.rang == 3}{'concours_3rd'|@translate}
    2424                                                                                                 {else}{'concours_4th'|@translate}{/if}
    2525                                                        )
    2626                            {else}(N/A){/if}&nbsp;&nbsp;</i></b></td>
    27                                 <td><b>Photo {$concours_note.img_id}&nbsp;&nbsp;</b></td>               
    28                                 <td>
    29                                         <a href="{$concours_note.url}">
    30                                         <img class="thumbnail" src="{$concours_note.thumb}" alt="{$concours_note.name}" title="{$concours_note.name}"/>
     27                                <td><b>Photo {$concours_note1.img_id}&nbsp;&nbsp;</b></td>             
     28                                <td align="center">
     29                                        <a href="{$concours_note1.url}">
     30                                        <img class="thumbnail" src="{$concours_note1.thumb}" alt="{$concours_note1.name}" title="{$concours_note1.name}"/>
    3131                                        </a>
    32                     <br><u>{'concours_name'|@translate}</u> : {$concours_note.name}
    33                     <br><u>{'concours_author'|@translate}</u> : {$concours_note.author}
     32                    <br><u>{'concours_name'|@translate}</u> : {$concours_note1.name}
     33                    <br><u>{'concours_author'|@translate}</u> : {$concours_note1.author}
    3434                                </td>
    3535                                <td>
    3636                                <fieldset>
    37                                         <i>{'concours_note'|@translate} : <b>{$concours_note.note}</b>&nbsp;&nbsp;</i>
    38                                         <br><i>{'concours_moyenne'|@translate} : <b>{$concours_note.moyenne}</b>&nbsp;&nbsp;</i>
    39                                         <br><i>{'concours_nbvotant'|@translate} : {$concours_note.nbvotant}&nbsp;&nbsp;</i>
     37                                        {if ($CONCOURS.METHODNB == 1)}
     38                                                <i><b>{'concours_note'|@translate} : {$concours_note1.note}</b>&nbsp;&nbsp;</i>
     39                                        {else}
     40                                                <i>{'concours_note'|@translate} : {$concours_note1.note}&nbsp;&nbsp;</i>
     41                                        {/if}
     42                                        {if ($CONCOURS.METHODNB == 2)}
     43                                                <br><i><b>{'concours_moyenne'|@translate} : {$concours_note1.moyenne}</b>&nbsp;&nbsp;</i>
     44                                        {else}
     45                                                <br><i>{'concours_moyenne'|@translate} : {$concours_note1.moyenne}&nbsp;&nbsp;</i>
     46                                        {/if}
     47                                        {if ($CONCOURS.METHODNB == 3)}
     48                                                <br><i><b>{'concours_moderation1'|@translate} : {$concours_note1.moderation1}</b>&nbsp;&nbsp;</i>
     49                                        {else}
     50                                                <br><i>{'concours_moderation1'|@translate} : {$concours_note1.moderation1}&nbsp;&nbsp;</i>
     51                                        {/if}
     52                                        {if ($CONCOURS.METHODNB == 4)}
     53                                                <br><i><b>{'concours_moderation2'|@translate} : {$concours_note1.moderation2}</b>&nbsp;&nbsp;</i>
     54                                        {else}
     55                                                <br><i>{'concours_moderation2'|@translate} : {$concours_note1.moderation2}&nbsp;&nbsp;</i>
     56                                        {/if}
    4057                                        <br>
    41                                         <br>{'concours_usernote'|@translate} : <b>{$concours_note.usernote}</b>&nbsp;&nbsp;
     58                                        <br><i>{'concours_nbvotant'|@translate} : {$concours_note1.nbvotant}&nbsp;&nbsp;</i>
     59                                        <br>
     60                                        <br>  ==> {'concours_usernote'|@translate} : <b>{$concours_note1.usernote}</b>&nbsp;&nbsp;
    4261                                </fieldset>
    4362                                </td>
    44                                 {if $concours_note.rang > 3}
     63                                {if $concours_note1.rang > 3}
    4564                                <td>&nbsp;</td>
    4665                                {else}
    47                                 <td><img src="{$IMG_URL}trophee-{$concours_note.rang}.png" width="75" height="75"></td>
     66                                <td><img src="{$IMG_URL}trophee-{$concours_note1.rang}.png" width="75" height="75"></td>
    4867                                {/if}
    4968                        </tr>
Note: See TracChangeset for help on using the changeset viewer.