Changeset 8946
- Timestamp:
- Jan 27, 2011, 8:46:55 PM (13 years ago)
- Location:
- extensions/ConcoursPhoto
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/ConcoursPhoto/CHANGELOG
r4368 r8946 1 1 TODO for next versions : 2 - 2 - Finaliser la page "Audit" dans la partie adminsitration 3 - Ajouter support ExtendedDescription (si nécessaire pour description du concours) 4 - Ajouter aide (help) pour le paramétrage et l'utilisation du plugin 5 - Fixer le pb pour masquer les données EXIFS/IPTC pour les photos d'un concours 6 - Ajouter possibilité de voter pour les guests (pb identification dans bdd!) 7 - Ajouter possibilité de sélectionner 1 ou plusieurs photos d'une catégorie pour participer à un concours. 8 - Ajouter une page de consultation du concours en cours 9 - Probleme lors que la date/heure de fin ou début est positionnée à 0h00 ou 24h00 --> erreur de date enregistrée dans la bdd. Mettre en place un contrôle de date_fin>date_debut 10 - Possibilité d'ajouter en direct (après vote) le résultat (+ paramétre pour afficher/masque en fonction du paramétre : modification notes attribuées à la photo) 11 - Ajouter la possibilité de consultation des résultats pour les "guests" 12 13 - Modifier onglet 1 pour la consultation des concours. Ajouter 3 sous onglets 14 - Problème d'affichage du menu concours dans le cas de non sélection de groupes... 15 16 - OK Ajout update_method pour l'ajout de données dans table Concours (param guest). 17 18 ______________ 19 20 Version 2.0.x 21 ------------- 22 2.0.0 - Add to guest the possibility to vote for a concours (BETA) 23 - Some correction (code and database structure) 3 24 4 25 ______________ … … 6 27 Version 1.0.x 7 28 ------------- 29 1.2.0 - Add exaequo checking for the result (beta) 30 - Add EN language 31 - Correct "concours not displayed" when no group is selected in admin page. Now, concours is available for all registered user (not depending on the group appartenance) 32 - Add option to allow author to vote for their photos (disable check based on username=authorname) 33 - Add option to allow user to change the score after a validation 8 34 1.1.0 - Add datas "moyenne" and "nbvotant" in database concours_result. Export theses datas in csv. 9 35 - add method of rank calculation in a concours (in database). -
extensions/ConcoursPhoto/admin/add_concours.php
r4368 r8946 115 115 116 116 $concours->concours_infos['groups'] = (!empty($_POST['groups']) ? '"' . implode(',', $_POST['groups']) . '"' : 'NULL'); 117 $concours->concours_infos['guest'] = isset($_POST['guest']); 117 118 $concours->concours_infos['category'] = $_POST['cat_selection']; 118 119 … … 227 228 $concours->concours_infos['groups'] = explode(',', $concours->concours_infos['groups']); 228 229 230 229 231 $tBeginDate = explodeDateArray($concours->concours_infos['begin_date']); 230 232 $tEndDate = explodeDateArray($concours->concours_infos['end_date']); … … 234 236 'NAME' => $concours->concours_infos['name'], 235 237 'DESCR' => $concours->concours_infos['descr'], 238 'GUEST' => ($concours->concours_infos['guest'] ? 'checked="checked"' : ''), 236 239 // 'BEGIN_DATE' => $concours->concours_infos['begin_date'], 237 240 // 'END_DATE' => NbJours($concours->concours_infos['begin_date'], $concours->concours_infos['end_date']) … … 266 269 'NAME' => $concours->concours_infos['name'], 267 270 'DESCR' => $concours->concours_infos['descr'], 271 'GUEST' => ($concours->concours_infos['guest'] ? 'checked="checked"' : ''), 268 272 // 'BEGIN_DATE' => $concours->concours_infos['begin_date'], 269 273 // 'END_DATE' => NbJours($concours->concours_infos['begin_date'], $concours->concours_infos['end_date']) … … 373 377 } 374 378 379 375 380 // Category selection 376 381 $query = ' -
extensions/ConcoursPhoto/admin/admin.php
r4428 r8946 35 35 $my_base_url.'&tab=params'); 36 36 37 /*$tabsheet->add('audit',37 $tabsheet->add('audit', 38 38 l10n('concours_audit'), 39 39 $my_base_url.'&tab=audit'); 40 */ 40 41 41 $tabsheet->select($page['tab']); 42 42 $tabsheet->assign(); 43 44 43 45 44 -
extensions/ConcoursPhoto/admin/audit.php
r4428 r8946 17 17 $user_id = 0; 18 18 19 //echo "USER_ID=".$user_id;19 echo "USER_ID=".$user_id; 20 20 21 21 // Get the concours id if present … … 29 29 $users = array(); // contain {id;username} or each 30 30 $groups = $concours->concours_infos['groups']; 31 $query = 'SELECT user_id, username FROM ' . USER_GROUP_TABLE31 $query = 'SELECT distinct(user_id), username FROM ' . USER_GROUP_TABLE 32 32 .' INNER JOIN ' . USERS_TABLE .' ON id = user_id' 33 .($groups != NULL ? ' WHERE group_id = '.$groups : '') 33 .($groups != NULL ? ' WHERE group_id IN ('.$groups.')' : '') 34 // = '.$groups : '') 34 35 .' ORDER BY username ASC' 35 36 .';'; … … 55 56 } 56 57 58 // Add the guest list (if coucours OK for guest) 59 $ipguest = $concours->get_guest_list(); 60 if ($concours->concours_infos['guest']) 61 { 62 foreach ( $ipguest as $i => $userid ) //on parcours le tableau 63 { 64 $template->append('user_list', 65 array( 'ID' => 'G'.$i, //$userid['user_id'], 66 'NAME' => $userid, 67 'SELECTED' => ($user_id == 'G'.$i ? 'selected' : ''))); 68 } 69 } 57 70 58 71 // Send concours info to template … … 70 83 // Step 3 : Display theses informations 71 84 72 73 // nb of users who vote for each image (for a selected concours 74 $query = 'SELECT img_id, COUNT(DISTINCT user_id) AS NBVOTE FROM ' . CONCOURS_DATA_TABLE 75 .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ) 76 .' GROUP BY img_id ' 77 .';'; 78 79 $result = pwg_query($query); 80 $nbvotes = array(); 81 while ($row = mysql_fetch_assoc($result)) 82 { 83 $nbvotes[$row['img_id']] = $row['NBVOTE']; 84 } 85 // Get the nb of vote for the concours 86 $nbvotes = $concours->nb_votes_by_img(); 87 85 88 86 89 // Get all the users who have notes for the concours 87 $query = 'SELECT distinct (user_id), USER.username'90 $query = 'SELECT distinct user_id, USER.username' 88 91 .' FROM ' .CONCOURS_DATA_TABLE 89 92 .' INNER JOIN ' . USERS_TABLE.' AS USER on USER.id = user_id' 90 93 .' WHERE id_concours = '.$concours_id 94 // Dont take the guest informations because 95 .' AND user_id <> '.$conf['guest_id'] 91 96 .' ORDER BY username ASC' 92 97 .';'; … … 95 100 $user_list = array(); 96 101 while ($row2 = mysql_fetch_assoc($result)) 97 array_push($user_list, $row2); 98 102 // Dont take the guest informations because 103 // if ($row2['user_id'] != $conf['guest_id']) 104 array_push($user_list, $row2); 99 105 100 106 … … 185 191 $user_note = array(); 186 192 $globalnote = 0; 187 if ($user_id != 0) // for user 193 echo "USER=".$user_id."\n"; 194 if (!is_numeric($user_id) OR $user_id != 0) // for user 195 { 196 echo "USERNON0=".$user_id."\n"; 197 $pos = strpos($user_id, 'G'); 198 if ($pos === false) 199 { 200 $globalnote = $concours->get_img_globalnote_user($row['id'], $concours_id, $user_id); 201 $user_note = $concours->get_img_note_user($row['id'], $concours_id, $user_id); 202 } 203 else 204 { 205 echo "G...".substr($user_id, $pos+1)." = ".substr($user_id, $pos+1)."\n"; 206 echo "IPGUEST=".$ipguest[substr($user_id, $pos+1)]."\n"; 207 $globalnote = $concours->get_img_globalnote_user($row['id'], $concours_id, $conf['guest_id'], $ipguest[substr($user_id, $pos+1)]); 208 $user_note = $concours->get_img_note_user($row['id'], $concours_id, $conf['guest_id'], $ipguest[substr($user_id, $pos+1)]); 209 } 210 } 211 elseif (is_numeric($user_id) AND $user_id == 0) // for user // global 188 212 { 189 $globalnote = $concours->get_img_globalnote_user($row['id'], $concours_id, $user_id); 190 $user_note = $concours->get_img_note_user($row['id'], $concours_id, $user_id); 191 } 192 else // global 193 { 194 foreach ($user_list as $userid) 195 $globalnote += $concours->get_img_globalnote_user($row['id'], null, $userid['user_id']); 196 } 213 echo "USER00=".$user_id."\n"; 214 215 foreach ($user_list as $i => $userid) 216 $globalnote += $concours->get_img_globalnote_user($row['id'], null, $userid['user_id']); 217 218 foreach ($ipguest as $i => $ipguestt) 219 { 220 $globalnote += $concours->get_img_globalnote_user($row['id'], null, $conf['guest_id'], $ipguestt); 221 } 222 } 197 223 198 224 … … 233 259 234 260 $rang = 1; 261 $previousNote = $previousMoy = 0; 262 235 263 foreach ($concours_img as $key => $value) 236 264 { 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"; 237 279 $concours_img[$key]['rang'] = $rang; 238 $rang++;239 280 240 281 $template->append( 'concours_note', array( … … 251 292 252 293 )); 294 $rang++; 295 296 $previousNote = $concours_img[$key]['note']; 297 $previousMoy = $concours_img[$key]['moyenne']; 253 298 } 254 299 -
extensions/ConcoursPhoto/admin/params.php
r4428 r8946 15 15 $concours->my_config['mask_author'] = isset($_POST['mask_author']); 16 16 $concours->my_config['thumb_note'] = isset($_POST['thumb_note']); 17 $concours->my_config['mask_exif'] = isset($_POST['mask_exif']); 17 18 $concours->my_config['check_exaequo'] = isset($_POST['check_exaequo']); 19 20 $concours->my_config['author_vote_available'] = isset($_POST['author_vote_available']); 21 $concours->my_config['concours_change_score'] = isset($_POST['concours_change_score']); 18 22 19 23 $concours->save_config(); … … 31 35 'MASK_AUTHOR' => ($concours->my_config['mask_author'] ? 'checked="checked"' : ''), 32 36 'THUMB_NOTE' => ($concours->my_config['thumb_note'] ? 'checked="checked"' : ''), 33 'MASK_EXIF' => ($concours->my_config['mask_exif'] ? 'checked="checked"' : ''), 34 )); 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"' : ''), 40 41 )); 35 42 36 43 $result = array(); -
extensions/ConcoursPhoto/admin/template/add_concours.tpl
r4428 r8946 96 96 </tr> 97 97 {/if} 98 <TR> 99 <TD colspan="4"> 100 <input type="checkbox" name="guest" {$CONCOURS.GUEST}/> {'concours_allow_guest'|@translate} 101 <br/> 102 </TD> 103 </TR> 104 98 105 <tr><td colspan="4"><br></td></tr> 99 106 <tr> … … 182 189 <fieldset> 183 190 <legend>{'concours_criterias'|@translate}</legend> 184 <table class="table2 littlefont" id="criteria_list"border="1">185 <tr class="throw">186 <t h><b>{'concours_id2'|@translate}</b></td>187 <t h><b>{'concours_name'|@translate}</b></td>188 <t h><b>{'concours_descr'|@translate}</b></td>189 <t h><b>{'concours_min_value'|@translate}</b></td>190 <t h><b>{'concours_max_value'|@translate}</b></td>191 <t h><b>{'concours_coef'|@translate}</b></td>191 <table border="1"> 192 <tr> 193 <td><b>{'concours_id'|@translate}</b></td> 194 <td><b>{'concours_name'|@translate}</b></td> 195 <td width="50%"><b>{'concours_descr'|@translate}</b></td> 196 <td><b>{'concours_min_value'|@translate}</b></td> 197 <td><b>{'concours_max_value'|@translate}</b></td> 198 <td><b>{'concours_coef'|@translate}</b></td> 192 199 {if $action != 'edit'} 193 <t h colspan="3"><b>{'concours_actions'|@translate}</b></td>200 <td width="10%"><b>{'concours_actions'|@translate}</b></td> 194 201 {/if} 195 202 </tr> 196 203 {foreach from=$concours_criteria item=concours_criteria} 197 <tr class="TableRow" style="cursor:pointer;">204 <tr> 198 205 <td>{$concours_criteria.id}</td> 199 206 <td> … … 214 221 {if $action != 'edit'} 215 222 <td> 216 {if $concours_criteria.level == 1}217 <a href="{$concours_criteria.U_ADD}" title="{'subcriteria_add'|@translate}" ><img src="{$IMG_URL}add.png" class="button" alt="{'subcriteria_add'|@translate}" /></a>218 {/if}219 </td>220 <td>221 223 {if isset($concours_criteria.U_EDIT)} 222 224 <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> 223 225 224 226 {/if} 225 </td>226 <td>227 227 {if isset($concours_criteria.U_DELETE)} 228 228 <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> 229 {/if} 230 {if $concours_criteria.level == 1} 231 <a href="{$concours_criteria.U_ADD}" title="{'subcriteria_add'|@translate}" ><img src="{$IMG_URL}add.png" class="button" alt="{'subcriteria_add'|@translate}" /></a> 229 232 {/if} 230 233 </td> -
extensions/ConcoursPhoto/admin/template/config.tpl
r4428 r8946 9 9 <legend>{'default_criteria'|@translate}</legend> 10 10 11 <table class="table2 littlefont" id="criteria_default"border="1">12 <tr class="throw">13 <t h><b>{'concours_id2'|@translate}</b></td>14 <t h><b>{'concours_name'|@translate}</b></td>15 <t h><b>{'concours_descr'|@translate}</b></td>16 <t h><b>{'concours_min_value'|@translate}</b></td>17 <t h><b>{'concours_max_value'|@translate}</b></td>18 <t h><b>{'concours_coef'|@translate}</b></td>19 <t h colspan="3"><b>{'concours_actions'|@translate}</b></td>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 20 </tr> 21 21 {foreach from=$concours_criteria item=concours_criteria} 22 <tr class="TableRow" style="cursor:pointer;">22 <tr> 23 23 <td>{$concours_criteria.id}</td> 24 24 <td> … … 38 38 {/if} 39 39 <td> 40 {if $concours_criteria.level == 1}41 <a href="{$concours_criteria.U_ADD}" title="{'subcriteria_add'|@translate}" ><img src="{$IMG_URL}add.png" class="button" alt="{'subcriteria_add'|@translate}" /></a>42 {/if}43 </td>44 <td>45 40 {if isset($concours_criteria.U_EDIT)} 46 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> 47 42 48 43 {/if} 49 </td>50 <td>51 44 {if isset($concours_criteria.U_DELETE)} 52 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> 53 49 {/if} 54 50 </td> -
extensions/ConcoursPhoto/admin/template/manage.tpl
r4428 r8946 11 11 <fieldset> 12 12 <legend>{'prepared_concours'|@translate}</legend> 13 {if isset($prepared_concours)} 14 <table class="table2 littlefont" id="pconcours_list" border="1"> 15 16 <tr class="throw"> 13 <table border="1"> 14 <tr> 17 15 <th><b>{'concours_id2'|@translate}</b></th> 18 16 <th><b>{'concours_name'|@translate}</b></th> 19 17 <th><b>{'concours_create_date'|@translate}</b></th> 20 <th ><b>{'concours_descr'|@translate}</b></th>18 <th width="50%"><b>{'concours_descr'|@translate}</b></th> 21 19 <th><b>{'concours_begin_date'|@translate}</b></th> 22 20 <th><b>{'concours_end_date'|@translate}</b></th> 23 <th colspan="4"><b>{'concours_actions'|@translate}</b></th>21 <th width="10%"><b>{'concours_actions'|@translate}</b></th> 24 22 </tr> 25 23 {foreach from=$prepared_concours item=prepared_concours} 26 <tr class="TableRow" style="cursor:pointer;">24 <tr> 27 25 <td>{$prepared_concours.ID}</td> 28 26 <td>{$prepared_concours.NAME}</td> … … 31 29 <td>{$prepared_concours.BEGIN_DATE}</td> 32 30 <td>{$prepared_concours.END_DATE}</td> 33 <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> </td>34 <td><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></td>35 <td colspan="2"></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 <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> 36 34 </tr> 37 35 {/foreach} 38 36 </table> 39 {else}40 <b>{'NO_concours'|@translate}</b>41 {/if}42 37 </fieldset> 43 38 44 39 <fieldset> 45 40 <legend>{'active_concours'|@translate}</legend> 46 {if isset($active_concours)} 47 <table class="table2 littlefont" id="aconcours_list" border="1"> 48 <tr class="throw"> 41 <table border="1"> 42 <tr> 49 43 <th><b>{'concours_id2'|@translate}</b></th> 50 44 <th><b>{'concours_name'|@translate}</b></th> 51 45 <th><b>{'concours_create_date'|@translate}</b></th> 52 <th ><b>{'concours_descr'|@translate}</b></th>46 <th width="50%"><b>{'concours_descr'|@translate}</b></th> 53 47 <th><b>{'concours_begin_date'|@translate}</b></th> 54 48 <th><b>{'concours_end_date'|@translate}</b></th> 55 <th colspan="4"><b>{'concours_actions'|@translate}</b></th>49 <th width="10%"><b>{'concours_actions'|@translate}</b></th> 56 50 </tr> 57 51 {foreach from=$active_concours item=active_concours} 58 <tr class="TableRow" style="cursor:pointer;">52 <tr> 59 53 <td>{$active_concours.ID}</td> 60 54 <td><a href="{$active_concours.U_AUDIT}" title="{'concours_audit1'|@translate}">{$active_concours.NAME}</a></td> … … 63 57 <td>{$active_concours.BEGIN_DATE}</td> 64 58 <td>{$active_concours.END_DATE}</td> 65 <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></td> 66 <td><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></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 <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> 67 62 </tr> 68 63 {/foreach} 69 64 </table> 70 {else}71 <b>{'NO_concours'|@translate}</b>72 {/if}73 65 </fieldset> 74 66 75 67 <fieldset> 76 68 <legend>{'closed_concours'|@translate}</legend> 77 {if isset($closed_concours)} 78 <table class="table2 littlefont" id="cconcours_list" border="1"> 79 <tr class="throw"> 69 <table border="1"> 70 <tr> 80 71 <th><b>{'concours_id2'|@translate}</b></th> 81 72 <th><b>{'concours_name'|@translate}</b></th> 82 73 <th><b>{'concours_create_date'|@translate}</b></th> 83 <th ><b>{'concours_descr'|@translate}</b></th>74 <th width="50%"><b>{'concours_descr'|@translate}</b></th> 84 75 <th><b>{'concours_begin_date'|@translate}</b></th> 85 76 <th><b>{'concours_end_date'|@translate}</b></th> 86 <th colspan="4"><b>{'concours_actions'|@translate}</b></th>77 <th><b>{'concours_actions'|@translate}</b></th> 87 78 </tr> 88 79 {foreach from=$closed_concours item=closed_concours} 89 <tr class="TableRow" style="cursor:pointer;">80 <tr> 90 81 <td>{$closed_concours.ID}</td> 91 82 <td><a href="{$closed_concours.U_AUDIT}" title="{'concours_audit1'|@translate}">{$closed_concours.NAME}</a></td> … … 94 85 <td>{$closed_concours.BEGIN_DATE}</td> 95 86 <td>{$closed_concours.END_DATE}</td> 96 <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></td> 97 <td><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></td> 98 <td>{if $closed_concours.U_RESULT != ''} <a href="{$closed_concours.U_RESULT}" title="{'concours_result'|@translate}"><img src="{$IMG_URL}generate.png" class="button" alt="{'concours_result'|@translate}" /></a>{/if}</td> 99 <td>{if $closed_concours.U_FILE != ''} <a href="{$closed_concours.U_FILE}" title="{'concours_file'|@translate}"><img src="{$IMG_URL}file.png" class="button" alt="{'concours_file'|@translate}" /></a>{/if}</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 <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 != ''} <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 != ''} <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> 100 93 </tr> 101 94 {/foreach} 102 95 </table> 103 {else}104 <b>{'NO_concours'|@translate}</b>105 {/if}106 96 </fieldset> 107 97 -
extensions/ConcoursPhoto/admin/template/params.tpl
r4428 r8946 35 35 <TR> 36 36 <TD colspan="2"> 37 <input type="checkbox" name=" mask_exif" {$MASK_EXIF}/> {'concours_mask_exif'|@translate}37 <input type="checkbox" name="thumb_note" {$THUMB_NOTE}/> {'concours_thumb_note'|@translate} 38 38 <br/> 39 39 </TD> … … 41 41 <TR> 42 42 <TD colspan="2"> 43 <input type="checkbox" name="thumb_note" {$THUMB_NOTE}/> {'concours_thumb_note'|@translate} 43 <input type="checkbox" name="check_exaequo" {$CHECK_EXAEQUO}/> {'concours_check_exaequo'|@translate} 44 <br/> 45 </TD> 46 <TR> 47 <TD colspan="2"> 48 <input type="checkbox" name="author_vote_available" {$AUTHOR_VOTE_AVAILABLE}/> {'concours_author_vote'|@translate} 44 49 <br/> 45 50 </TD> 46 51 </TR> 47 </table> 52 <TR> 53 <TD colspan="2"> 54 <input type="checkbox" name="concours_change_score" {$CHANGE_SCORE}/> {'concours_change_score'|@translate} 55 <br/> 56 </TD> 57 </TR> 58 </table> 48 59 <br/> 49 60 </fieldset> -
extensions/ConcoursPhoto/include/Concours.class.php
r4428 r8946 5 5 */ 6 6 7 global $user ;7 global $user, $conf; 8 8 9 9 class Concours … … 164 164 `category`, 165 165 `groups`, 166 `method` 166 `method`, 167 `guest` 168 167 169 ) 168 170 VALUES (".($concours_id !== NULL ? $concours_id : $this->concours_id).", now(), … … 170 172 \"".$this->concours_infos['begin_date']."\", \"".$this->concours_infos['end_date']."\", 171 173 ".$this->concours_infos['category'].", ".$this->concours_infos['groups'].", 172 ".$this->concours_infos['method']." 174 ".$this->concours_infos['method'].", ".($this->concours_infos['guest'] ? "TRUE" : "FALSE")." 173 175 );"; 174 176 if (pwg_query($query) != null) … … 196 198 category = ".$this->concours_infos['category'].", 197 199 groups = ".$this->concours_infos['groups'].", 198 method = ".$this->concours_infos['method']." 200 method = ".$this->concours_infos['method'].", 201 guest = ".($this->concours_infos['guest'] ? "TRUE" : "FALSE")." 199 202 200 203 WHERE id = ".($concours_id !== NULL ? $concours_id : $this->concours_id)." … … 458 461 $result = pwg_query($query); 459 462 if ($this->debug) echo $query."\n"; 460 463 $criteria = mysql_fetch_assoc($result); 461 464 /* while ($row = mysql_fetch_assoc($result)) 462 465 { … … 619 622 $query = 'SELECT img_id, COUNT(DISTINCT user_id) AS NBVOTE FROM ' . CONCOURS_DATA_TABLE 620 623 .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ) 624 .' AND ipguest IS NULL' 621 625 .' GROUP BY img_id ' 622 626 .';'; … … 628 632 $nbvotes[$row['img_id']] = $row['NBVOTE']; 629 633 } 634 635 // Add guest infos 636 $query = 'SELECT img_id, COUNT(DISTINCT user_id, ipguest) AS NBVOTE FROM ' . CONCOURS_DATA_TABLE 637 .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ) 638 .' AND ipguest IS NOT NULL' 639 .' GROUP BY img_id ' 640 .';'; 641 642 $result = pwg_query($query); 643 if ($this->debug) echo "NBVOTE = ".$query."\n"; 644 while ($row = mysql_fetch_assoc($result)) 645 if (!isset($nbvotes[$row['img_id']])) 646 $nbvotes[$row['img_id']] = $row['NBVOTE']; 647 else 648 $nbvotes[$row['img_id']] += $row['NBVOTE']; 649 630 650 return $nbvotes; 631 651 } 632 652 653 // Get All iaddr for guest who have vote (IP Stores in db) in a concours 654 function get_guest_list($concours_id = NULL) 655 { 656 $ipguest = array(); 657 if ($concours_id!== null or $this->concours_id !== null) 658 { 659 $query = ' 660 SELECT distinct(ipguest) 661 FROM ' . CONCOURS_DATA_TABLE .' 662 WHERE id_concours =' . ($concours_id !== null ? $concours_id : $this->concours_id ) . ' 663 AND ipguest IS NOT NULL 664 ORDER BY ipguest 665 '; 666 $result = pwg_query($query); 667 if ($this->debug) echo $query."\n"; 668 while ($row = mysql_fetch_assoc($result)) 669 { 670 array_push($ipguest, $row['ipguest']); 671 } 672 if ($this->debug) 673 { 674 foreach ($ipguest as $ip) 675 echo "IP=".$ip."\n"; 676 } 677 678 return $ipguest; 679 } 680 else 681 return $ipguest; 682 } 683 633 684 634 685 // After concours is completed (closed date is passed), generate the result and store it to DB 635 686 function create_result($concours_id = NULL) 636 687 { 688 global $conf; 637 689 // var which contains id=img_id and val =global note 638 690 $global_note = array(); … … 655 707 echo "CAT=".$category; 656 708 // Get all user_id from a concours 657 $query = 'SELECT DISTINCT (user_id)'709 $query = 'SELECT DISTINCT user_id' 658 710 .' FROM ' .CONCOURS_DATA_TABLE 659 711 .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ) 712 .' AND user_id <> '.$conf['guest_id'] 660 713 .';'; 661 714 $result = pwg_query($query); … … 663 716 echo $query; 664 717 while ($row = mysql_fetch_assoc($result)) 665 {666 718 array_push($user_id, $row['user_id']); 667 } 719 720 // Add guest info is present 721 $ipguest = array(); 722 if ($concours_id!== null) 723 $ipguest = $this->get_guest_list(($concours_id !== null ? $concours_id : $this->concours_id )); 668 724 669 725 if ($this->debug) 726 { 670 727 foreach ($user_id as $userid) 671 728 echo "USER = ".$userid; 672 729 } foreach ($ipguest as $userid) 730 echo "IPGUEST = ".$userid; 673 731 674 732 … … 687 745 if (!isset($global_note[$row['image_id']])) 688 746 $global_note[$row['image_id']] = 0; 689 $global_note[$row['image_id']] += $this->get_img_globalnote_user($row['image_id'], null, $userid ); 747 $global_note[$row['image_id']] += $this->get_img_globalnote_user($row['image_id'], null, $userid); 748 } 749 // Add guest scores if present 750 foreach ($ipguest as $i => $ipguestt) 751 { 752 if (!isset($global_note[$row['image_id']])) 753 $global_note[$row['image_id']] = 0; 754 $global_note[$row['image_id']] += $this->get_img_globalnote_user($row['image_id'], null, null, $ipguestt); 690 755 } 691 756 } … … 717 782 718 783 } 784 719 785 720 786 … … 755 821 756 822 757 // Disable exif if a concours is open or prepared758 function concours_disable_exifs()759 {760 global $page, $conf;761 762 // Get user group.763 $this->get_user_groups();764 765 $concours = array();766 767 // disable exifs on image which are present in a concours.768 // check the categories where the current image is present and disable the exifs769 if (isset($page['image_id']) && isset($this->my_config['mask_exifs']) && $this->my_config['mask_exifs'] == true)770 {771 // Get all categories where the current image is present772 $query = '773 SELECT category_id,uppercats,commentable,global_rank774 FROM '.IMAGE_CATEGORY_TABLE.'775 INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id776 WHERE image_id = '.$page['image_id'].'777 ;';778 // echo $query;779 $result = pwg_query($query);780 $related_categories = array();781 while ($row = mysql_fetch_array($result))782 {783 array_push($related_categories, $row['category_id']);784 }785 //786 //echo related_categories;787 if (count($related_categories))788 {789 // Request for all concours prepared & actived on each categories790 $query = '791 SELECT *792 FROM ' . CONCOURS_TABLE .'793 WHERE category IN ('.implode(',', $related_categories).')794 AND time_to_sec(TIMEDIFF(now(), end_date)) < 0795 ';796 // echo $query;797 $result = pwg_query($query);798 // If one or more concours are found, the exifs are masked799 if ($result && mysql_fetch_assoc($result))800 {801 $conf['show_exif'] = false;802 }803 }804 }805 806 // End disable author name807 808 }809 810 811 823 // Add tpl to picture.php page to display concours informations and vote 812 824 function display_concours_to_picture() 813 825 { 826 // Step0 : if user = guest, check the concours param and store ip address to user name. 814 827 // Step1 : concours is defined to this category AND concours is open AND user is authorized to access to this category (thru group) 815 828 // Step1 bis : dont show concours if img_author = user_id … … 825 838 $concours = array(); 826 839 827 840 // 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 879 880 828 881 // DEBUG 829 882 if ($this->debug) … … 916 969 while ($row = mysql_fetch_assoc($result)) 917 970 { 918 919 971 if (!empty($row['groups'])) 920 972 { … … 926 978 continue; 927 979 } 980 // If no group is parameter for that concours ==> available for all registered users 928 981 $concours = $row; 929 982 } 983 else 984 $concours = $row; 985 930 986 931 987 } … … 935 991 // Step 1 bis 936 992 // Actual user is the author of the picture ==>end 937 if ($this->check_img_user($page['current_item'])) 993 if ( !$this->my_config['author_vote_available'] 994 AND $this->check_img_user($page['current_item'])) 938 995 return; 939 996 … … 989 1046 990 1047 // $datas = "0=0"; 991 $this->store_img_note_user($page['current_item'], $user_note, $concours['id'] );1048 $this->store_img_note_user($page['current_item'], $user_note, $concours['id'], $user['ipguest']); 992 1049 if ($this->debug) echo "COMMENT=".$_POST['CONCOURS_COMMENT']; 993 $this->store_img_comment_user($page['current_item'], $_POST['concours_comment'], $concours['id'] );1050 $this->store_img_comment_user($page['current_item'], $_POST['concours_comment'], $concours['id'], $user['ipguest']); 994 1051 } 995 1052 … … 998 1055 { 999 1056 if ($this->debug) echo "RAZ"; 1000 $this->RAZ_img_note_user($page['current_item'], $concours['id'] );1057 $this->RAZ_img_note_user($page['current_item'], $concours['id'], $user['ipguest']); 1001 1058 } 1002 1059 else 1003 1060 { 1004 1061 // Recover previous note in DB (if exists) 1005 $user_notes = $this->get_img_note_user($page['current_item'], $concours['id'] );1062 $user_notes = $this->get_img_note_user($page['current_item'], $concours['id'], $user['id'], $user['ipguest']); 1006 1063 } 1007 1064 1008 1065 // Comment is not RAZ, always restore 1009 $comment = $this->get_img_comment_user($page['current_item'], $concours['id'] );1066 $comment = $this->get_img_comment_user($page['current_item'], $concours['id'], $user['id'], $user['ipguest']); 1010 1067 1011 1068 if ($this->debug) echo "STEP3\n"; … … 1061 1118 // Add the comment 1062 1119 $template->assign( 'CONCOURS_COMMENT', $comment); 1120 1121 // if a user has already vote for this photo, check if the score change is allowed 1122 1123 if ($this->debug) echo "change=".($this->my_config['concours_change_score'] ? "OK" : "KO"); 1124 if ($user_notes == array() OR $this->my_config['concours_change_score']) // Allow user to change his vote after a validation 1125 $template->assign( 'CONCOURS_CHANGE_SCORE', true); 1126 else 1127 $template->assign( 'CONCOURS_CHANGE_SCORE', false); 1128 1063 1129 1064 1130 // Add concours informations on template … … 1066 1132 'name' => $concours['name'], 1067 1133 'descr' => $concours['descr'], 1068 'note' => $this->get_img_globalnote_user($page['current_item'], $concours['id'] )1134 'note' => $this->get_img_globalnote_user($page['current_item'], $concours['id'], null, $user['ipguest']) 1069 1135 )); 1070 1136 … … 1083 1149 // fill criterias notes to 0 in DB 1084 1150 // return false if error 1085 function RAZ_img_note_user($img_id, $concours_id = NULL )1151 function RAZ_img_note_user($img_id, $concours_id = NULL, $ipguest = null) 1086 1152 { 1087 1153 $user_note = ""; … … 1114 1180 if (strlen($user_note) != 0) 1115 1181 { 1116 $this->store_img_note_user($img_id, $user_note, $concours_id );1182 $this->store_img_note_user($img_id, $user_note, $concours_id, $ipguest); 1117 1183 return true; 1118 1184 } … … 1125 1191 // Store notation from user to db 1126 1192 // save with format "criteria_id=note;criteria_id=note..." for data 1127 function store_img_note_user($img_id, $datas, $concours_id = NULL )1193 function store_img_note_user($img_id, $datas, $concours_id = NULL, $ipguest = null) 1128 1194 { 1129 1195 global $user; 1130 if ($this->get_img_note_user( $img_id, $concours_id ) == array())1196 if ($this->get_img_note_user( $img_id, $concours_id, $user['id'], $ipguest) == array() ) 1131 1197 { 1132 1198 $query = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id FROM ' . CONCOURS_DATA_TABLE . ' ;'; … … 1140 1206 `create_date` , 1141 1207 `img_id` , 1142 `datas` ) 1208 `datas`'. 1209 ($ipguest ? ',`ipguest` ' : '') 1210 1211 .') 1143 1212 VALUES ( '.$next_element_id.',' 1144 1213 .($concours_id !== null ? $concours_id : $this->concours_id ) .' 1145 , '. $user['id'] .', now(), '.$img_id.', "'.$datas.'");'; 1214 , '. $user['id'] .', now(), '.$img_id.', "'.$datas.'"' 1215 .($ipguest ? ',"'.$user['ipguest'].'"' : '') 1216 .');'; 1146 1217 } 1147 1218 else … … 1152 1223 WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ).' 1153 1224 AND user_id = '.$user['id'].' 1154 AND img_id = '.$img_id.';'; 1225 AND img_id = '.$img_id. 1226 ($ipguest ? ' AND ipguest = "'.$ipguest.'"' : '') 1227 .';'; 1155 1228 } 1156 1229 if ($this->debug) echo $query."\n"; … … 1163 1236 // Criteria_id ==> value 1164 1237 // Note : criterias with subcriterias are not saved and not restored. They are calculated for global result 1165 function get_img_note_user($img_id, $concours_id = NULL, $user_id = null )1238 function get_img_note_user($img_id, $concours_id = NULL, $user_id = null, $ipguest = null) 1166 1239 { 1167 1240 global $user; … … 1174 1247 WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id) . ' 1175 1248 AND user_id = '. ($user_id !== null ? $user_id : $user['id']).' 1176 AND img_id = '. $img_id .' 1177 '; 1249 AND img_id = '. $img_id . 1250 ($ipguest ? ' AND ipguest = "'.$ipguest.'"' : '') 1251 .';'; 1178 1252 if ($this->debug) echo $query."\n"; 1179 1253 $result = pwg_query($query); … … 1212 1286 // get notation's user from db 1213 1287 // Return the global note for a picture id from a user 1214 function get_img_globalnote_user($img_id, $concours_id = NULL, $user_id = null )1288 function get_img_globalnote_user($img_id, $concours_id = NULL, $user_id = null, $ipguest = null) 1215 1289 { 1216 1290 global $user; … … 1224 1298 WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id) . ' 1225 1299 AND user_id = '. ($user_id !== null ? $user_id : $user['id']).' 1226 AND img_id = '. $img_id .' 1227 '; 1300 AND img_id = '. $img_id . 1301 ($ipguest ? ' AND ipguest = "'.$ipguest.'"' : '') 1302 .';'; 1228 1303 $result = pwg_query($query); 1229 1304 … … 1271 1346 1272 1347 // Store comment from user to db 1273 function store_img_comment_user($img_id, $datas, $concours_id = NULL )1348 function store_img_comment_user($img_id, $datas, $concours_id = NULL, $ipguest = null) 1274 1349 { 1275 1350 global $user; 1276 if (($comment = $this->get_img_note_user( $img_id, $concours_id )) == false)1351 if (($comment = $this->get_img_note_user( $img_id, $concours_id, null, $ipguest)) == false) 1277 1352 { 1278 1353 $query = 'SELECT IF(MAX(id)+1 IS NULL, 1, MAX(id)+1) AS next_element_id FROM ' . CONCOURS_DATA_TABLE . ' ;'; … … 1286 1361 `create_date` , 1287 1362 `img_id` , 1288 `comment`) 1363 `comment`' 1364 .($ipguest ? ' `ipguest`' : ''). 1365 ') 1289 1366 VALUES ( '.$next_element_id.',' 1290 1367 .($concours_id !== null ? $concours_id : $this->concours_id ) .' … … 1298 1375 WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ).' 1299 1376 AND user_id = '.$user['id'].' 1300 AND img_id = '.$img_id.';'; 1377 AND img_id = '.$img_id. 1378 ($ipguest ? ' AND ipguest = "'.$ipguest.'"' : '') 1379 .';'; 1301 1380 } 1302 1381 if ($this->debug) echo $query."\n"; … … 1307 1386 1308 1387 // Get comment on an image for a user 1309 function get_img_comment_user($img_id, $concours_id = NULL, $user_id = null )1388 function get_img_comment_user($img_id, $concours_id = NULL, $user_id = null, $ipguest = null) 1310 1389 { 1311 1390 global $user; … … 1318 1397 WHERE id_concours =' . ($concours_id !== NULL ? $concours_id : $this->concours_id) . ' 1319 1398 AND user_id = '. ($user_id !== null ? $user_id : $user['id']).' 1320 AND img_id = '. $img_id .' 1321 '; 1399 AND img_id = '. $img_id . 1400 ($ipguest ? ' AND ipguest = "'.$ipguest.'"' : '') 1401 .';'; 1322 1402 if ($this->debug) echo $query."\n"; 1323 1403 $result = pwg_query($query); … … 1336 1416 function generate_csv($concours_id = NULL) 1337 1417 { 1418 global $conf; 1338 1419 $file = "rang, id_concours,method, img_id, img_name, img_file, date, note, moyenne, nbvotant, datas\r\n"; 1339 1420 … … 1344 1425 $query = 'SELECT id_concours,method, img_id, IMG.name, IMG.file, date, note, moyenne, nbvotant, datas' 1345 1426 .' FROM ' .CONCOURS_RESULT_TABLE 1346 .' INNER JOIN ' . CONCOURS .' AS CONC on CONC.id = id_concours'1427 .' INNER JOIN ' . CONCOURS_TABLE.' AS CONC on CONC.id = id_concours' 1347 1428 .' INNER JOIN ' . IMAGES_TABLE.' AS IMG on IMG.id = img_id' 1348 1429 .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ); … … 1383 1464 function generate_detail_csv($concours_id = NULL) 1384 1465 { 1466 global $conf; 1385 1467 if ($concours_id === null) 1386 1468 $concours_id = $this->concours_id; … … 1414 1496 $user_list = array(); 1415 1497 $users_criteria = ""; 1498 1499 1416 1500 // Get all the users who have notes for the concours 1417 1501 $query = 'SELECT distinct(user_id), USER.username' … … 1419 1503 .' INNER JOIN ' . USERS_TABLE.' AS USER on USER.id = user_id' 1420 1504 .' WHERE id_concours = '.($concours_id !== null ? $concours_id : $this->concours_id ) 1421 .' ORDER BY username ASC' 1505 // Dont take the guest informations because 1506 .' AND user_id <> '.$conf['guest_id'] 1507 .' ORDER BY username ASC' 1422 1508 .';'; 1423 1509 $result = pwg_query($query); … … 1429 1515 1430 1516 } 1517 1518 $ipguest = array(); 1519 // Get guest info (if available) 1520 if ($this->concours_infos['guest']) 1521 { 1522 $ipguest = $this->get_guest_list(); 1523 // For each guest 1524 foreach ( $ipguest as $i => $userid ) //on parcours le tableau 1525 { 1526 $users_criteria .= (strlen($users_criteria) ? "," : "")."user, user_global_note, comment, ".$criteria_list; 1527 } 1528 } 1431 1529 1432 1530 if ($this->debug) echo "users_criteria=".$users_criteria."\n"; … … 1443 1541 1444 1542 1445 /* $query = 'SELECT img_id, COUNT(DISTINCT user_id) AS NBVOTE FROM ' . CONCOURS_DATA_TABLE1446 .' GROUP BY img_id '1447 .';';1448 1449 $result = pwg_query($query);1450 // echo $query;1451 $nbvotes = array();1452 while ($row = mysql_fetch_assoc($result))1453 {1454 $nbvotes[$row['img_id']] = $row['NBVOTE'];1455 }1456 */1457 /*1458 foreach ($nbvotes as $id=>$val)1459 {1460 echo "Vote img(".$id.")=".$val."\n";1461 }1462 */1463 1543 // recover all img_id from the category 1464 1544 if (!(isset($this->concours_infos['method']))) … … 1481 1561 // For each images 1482 1562 $rang = 1; 1563 $previousNote = $previousMoy = 0; 1564 1483 1565 while ($row = mysql_fetch_assoc($result)) 1484 1566 { 1567 // Check and verify for exaequo 1568 if ($this->my_config['check_exaequo']) 1569 { 1570 if ( ($this->concours_infos['method'] == 1 // total 1571 AND ($row['note'] == $previousNote)) 1572 OR ($this->concours_infos['method'] == 2 // moyenne 1573 AND ($row['moyenne'] == $previousMoy))) 1574 { 1575 $rang --; 1576 1577 } 1578 } 1579 1485 1580 $file .= ($row['nbvotant'] != 0 ? $rang : 'N/A').', ' 1486 1581 .$row['id_concours'].', ' … … 1542 1637 } 1543 1638 1639 // Add guest infos (if present) 1640 foreach ($ipguest as $ipguestt) 1641 { 1642 // echo "IP=".$ipguestt."\n"; 1643 $comment = $this->get_img_comment_user($row['img_id'], $concours_id, $conf['guest_id'], $ipguestt); 1644 1645 $user_note = $this->get_img_note_user($row['img_id'], $concours_id, $conf['guest_id'], $ipguestt); 1646 1647 $file .= ', Guest('.$ipguestt.'), '.$this->get_img_globalnote_user($row['img_id'], $concours_id, $conf['guest_id'], $ipguestt) 1648 // .', '.($row['comment'] != null ? str_replace(",", "",$row['comment']) : '') 1649 .', '.($comment != false ? str_replace(array(",","\r\n", "\n", "\r"), " ",$comment) : '') 1650 .', ' 1651 ; 1652 1653 $user_note_by_crit = ""; 1654 foreach ($firstcriterias as $criteria) 1655 { 1656 // First without sub criterias 1657 if (!$this->is_criterias_contains_sub($criteria['criteria_id'],$concours_id )) 1658 { 1659 $user_note_by_crit .= (strlen($user_note_by_crit) ? "," : "").(isset($user_note[$criteria['criteria_id']]) ? $user_note[$criteria['criteria_id']] : ' '); 1660 } 1661 else 1662 { 1663 $user_note_by_subcrit = ""; 1664 $subcrit_note = 0; 1665 $user_has_vote = false; 1666 $secondcriterias = $this->get_subcriterias($criteria['criteria_id'], $concours_id ); 1667 foreach ($secondcriterias as $subcriteria) 1668 { 1669 if (isset($user_note[$subcriteria['criteria_id']])) $user_has_vote = true; 1670 $user_note_by_subcrit .= (strlen($user_note_by_subcrit) ? "," : "").(isset($user_note[$subcriteria['criteria_id']]) ? $user_note[$subcriteria['criteria_id']] : ' '); 1671 $subcrit_note += (int)$subcriteria['ponderation'] * (float)(isset($user_note[$subcriteria['criteria_id']]) ? $user_note[$subcriteria['criteria_id']] : 0); 1672 1673 } 1674 $user_note_by_crit .= (strlen($user_note_by_crit) ? "," : "").($user_has_vote ? $subcrit_note : ' ').",".$user_note_by_subcrit; 1675 } 1676 } 1677 $file .= $user_note_by_crit; 1678 1679 } 1680 1544 1681 $file .="\r\n"; 1545 1682 $rang ++; 1683 $previousNote = $row['note']; 1684 $previousMoy = $row['moyenne']; 1685 1546 1686 } 1547 1687 if ($this->debug) echo $file; … … 1756 1896 $this->get_user_groups(); 1757 1897 1898 $user['ipguest'] = null; 1899 if (is_a_guest()) 1900 { 1901 if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) 1902 $IP = $_SERVER['HTTP_X_FORWARDED_FOR']; 1903 elseif(isset($_SERVER['HTTP_CLIENT_IP'])) 1904 $IP = $_SERVER['HTTP_CLIENT_IP']; 1905 else 1906 $IP = $_SERVER['REMOTE_ADDR']; 1907 1908 // store ip 1909 $user['ipguest'] = $IP; 1910 } 1911 1758 1912 if ($this->my_config['thumb_note'] && $this->my_config['thumb_note'] == true) 1759 1913 { … … 1785 1939 $concours = $row; 1786 1940 } 1941 1942 // If no group is parameter for that concours ==> available for all registered users 1943 else 1944 $concours = $row; 1945 1787 1946 } 1788 1947 if (count($concours)) 1789 1948 { 1790 1791 foreach($tpl_var as $cle=>$valeur) 1792 { 1793 // show only if the author is not the active user 1794 if ($tpl_var[$cle]['FILE_AUTHOR'] != $user['username']) 1795 { 1796 $tpl_var[$cle]['NAME'] = $tpl_var[$cle]['NAME'].'<br> '.l10n('thumbnail_global_note').' : '.$this->get_img_globalnote_user($tpl_var[$cle]['ID'], $concours['id']); 1797 } 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> '.l10n('thumbnail_global_note').' : '.$this->get_img_globalnote_user($tpl_var[$cle]['ID'], $concours['id'], $user['id'], $user['ipguest']); 1961 } 1962 } 1798 1963 } 1799 1964 } -
extensions/ConcoursPhoto/include/default_values.inc.php
r4428 r8946 9 9 $concours_default_values['mask_author'] = true; // Mask author for prepared concours 10 10 $concours_default_values['thumb_note'] = true; // Display global note (for user) under thumbnail 11 $concours_default_values['mask_exif'] = true; // Mask exif/iptc datas during concours 11 $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['concours_change_score'] = true; // Allow a user to change his score afer a validation 14 12 15 ?> -
extensions/ConcoursPhoto/language/en_UK/description.txt
r3905 r8946 1 Create photo co mpetitionwith specifics criterias on Piwigo gallery1 Create photo contest with specifics criterias on Piwigo gallery -
extensions/ConcoursPhoto/language/en_UK/plugin.lang.php
r3905 r8946 6 6 */ 7 7 8 // Piclenslite button9 //$lang[''] = '';10 8 9 $lang['concours_save'] = 'Save'; 10 $lang['concours_RAZ'] = 'Reset'; 11 $lang['concours_admin_edit'] = 'Edit'; 12 $lang['concours_result'] = 'Contest Result'; 13 $lang['concours_add'] = 'Add a Contest'; 14 $lang['concours_id'] = 'Id'; 15 $lang['concours_id2'] = 'Id.'; 16 $lang['concours_name'] = 'Name'; 17 $lang['concours_descr'] = 'Description'; 18 $lang['concours_activation_date'] = 'Contest Period'; 19 $lang['concours_nb_jours'] = 'During'; 20 $lang['jours'] = 'Days'; 21 $lang['concours_category_select'] = 'Selected category'; 22 $lang['concours_authorized_group'] = 'Authorized Groups'; 23 $lang['concours_begin_date'] = 'Stard Date'; 24 $lang['concours_end_date'] = 'End Date'; 25 $lang['concours_criterias'] = 'Contest criteria'; 26 $lang['concours_min_value'] = 'Min.'; 27 $lang['concours_max_value'] = 'Max.'; 28 $lang['concours_coef'] = 'Coef.'; 29 $lang['criteria_edit'] = 'Edit the criteria'; 30 $lang['criteria_delete'] = 'Delete the criteria'; 31 $lang['criteria_add'] = 'Add a criteria'; 32 $lang['subcriteria_add'] = 'Add a sub-criteria'; 33 $lang['concours_actions'] = 'Actions'; 34 $lang['concours_admin_title'] = '"Concours Photo" plugin administration'; 35 $lang['default_criteria'] = 'Default criteria management'; 36 $lang['concours_add_criteria'] = 'Add a sub-criteria'; 37 $lang['concours_criteria_submit'] = 'Valid the criteria'; 38 $lang['manage_concours'] = 'Contest Management'; 39 $lang['prepared_concours'] = 'Prepared contest inactive'; 40 $lang['active_concours'] = 'Active contest'; 41 $lang['closed_concours'] = 'Contest closed'; 42 $lang['concours_result'] = 'Generate the result'; 43 $lang['concours_file'] = 'Download the result file'; 44 $lang['concours_create_date'] = 'Create date'; 45 $lang['concours_management'] = 'Contest Management'; 46 $lang['concours_edit'] = 'Edit the contest'; 47 $lang['concours_delete'] = 'Delete the contest'; 48 $lang['concours_add'] = 'Add a contest'; 49 $lang['concours_config'] = 'Default Criteria'; 50 $lang['concours_admin_add'] = $lang['concours_add']; 51 $lang['concours_comment'] = 'Comments/Notes about the photo'; 52 $lang['concours_result_page'] = 'Contest Result'; 53 $lang['concours_img_author'] = 'Masked for the contest'; 54 $lang['concours_1st'] = 'st'; 55 $lang['concours_2nd'] = 'nd'; 56 $lang['concours_3rd'] = 'rd'; 57 $lang['concours_4th'] = 'th'; 58 $lang['concours_submit'] = 'Validate'; 59 $lang['concours_params'] = 'General parameters'; 60 $lang['concours_show_menubar'] = 'Show the menu "Contest Result"'; 61 $lang['concours_nb_concours_menubar'] = 'Number of results to display'; 62 $lang['concours_result_files'] = 'Contest result files generates'; 63 $lang['concours_result_file_list'] = 'List of contest result files that can be downloaded (even though if the contest has been deleted)'; 64 $lang['concours_no_result_file'] = 'No Result files'; 65 66 $lang['concours_date_from'] = 'Begin date'; 67 $lang['concours_date_end'] = 'End date'; 68 $lang['concours_hour_from'] = 'Begin hour'; 69 $lang['concours_hour_to'] = 'End hour'; 70 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'; 75 $lang['concours_thumb_note'] = 'Add the global note under thumbnails'; 76 $lang['concours_global_user_note'] = 'Total registered'; 77 78 79 $lang['concours_activ_from'] = 'Contest active from '; 80 $lang['concours_activ_to'] = ' To '; 81 $lang['concours_method'] = 'Rank calculating method'; 82 $lang['concours_method1'] = 'Sum of scored'; 83 $lang['concours_method2'] = 'Average of scores'; 84 85 $lang['concours_note'] = 'Global score'; 86 $lang['concours_moyenne'] = 'Average'; 87 $lang['concours_nbvotant'] = 'Number of voting'; 88 $lang['concours_usernote'] = 'Your score'; 89 $lang['concours_infos'] = 'Contest information'; 90 $lang['concours_audit'] = 'Audit'; 91 $lang['concours_audit1'] = 'Audit the contest'; 92 $lang['concours_author'] = 'Author'; 93 $lang['NO_concours'] = 'No contest'; 94 $lang['concours_username_selection'] = 'Select a user'; 95 $lang['all_users'] = '-- All --'; 96 $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)'; 98 $lang['concours_change_score'] = 'Allow user to change his score after a validation'; 11 99 ?> -
extensions/ConcoursPhoto/language/fr_FR/description.txt
r3905 r8946 1 Création de concours photos avec critères sur les catégories de la galerie Piwigo1 Création de concours photos avec multi-critères sur les catégories de la galerie Piwigo -
extensions/ConcoursPhoto/language/fr_FR/plugin.lang.php
r4428 r8946 9 9 $lang['concours_save'] = 'Sauvegarder'; 10 10 $lang['concours_RAZ'] = 'Réinitialiser'; 11 $lang['concours_admin_edit'] 12 $lang['concours_result'] 11 $lang['concours_admin_edit'] = 'Edit'; 12 $lang['concours_result'] = 'Résultat du concours'; 13 13 $lang['concours_add'] = 'Ajouter un concours'; 14 14 $lang['concours_id'] = 'Identifiant'; … … 16 16 $lang['concours_name'] = 'Nom'; 17 17 $lang['concours_descr'] = 'Description'; 18 $lang['concours_activation_date'] 19 $lang['concours_nb_jours'] 20 $lang['jours'] = 'Jours';21 $lang['concours_category_select'] 22 $lang['concours_authorized_group'] 23 $lang['concours_begin_date'] 24 $lang['concours_end_date'] 25 $lang['concours_criterias'] 26 $lang['concours_min_value'] 27 $lang['concours_max_value'] 18 $lang['concours_activation_date'] = 'Période du concours'; 19 $lang['concours_nb_jours'] = 'Pendant'; 20 $lang['jours'] = 'Jours'; 21 $lang['concours_category_select'] = 'Catégorie sélectionnée'; 22 $lang['concours_authorized_group'] = 'Groupes authorisés'; 23 $lang['concours_begin_date'] = 'Date de début'; 24 $lang['concours_end_date'] = 'Date de fin'; 25 $lang['concours_criterias'] = 'Critères du concours'; 26 $lang['concours_min_value'] = 'Min.'; 27 $lang['concours_max_value'] = 'Max.'; 28 28 $lang['concours_coef'] = 'Coef.'; 29 29 $lang['criteria_edit'] = 'Editer le critère'; 30 $lang['criteria_delete'] 30 $lang['criteria_delete'] = 'Supprimer le critère'; 31 31 $lang['criteria_add'] = 'Ajouter un critère'; 32 $lang['subcriteria_add'] 33 $lang['concours_actions'] 34 $lang['concours_admin_title'] 35 $lang['default_criteria'] 36 $lang['concours_add_criteria'] 37 $lang['concours_criteria_submit'] 38 $lang['manage_concours'] 39 $lang['prepared_concours'] 40 $lang['active_concours'] 41 $lang['closed_concours'] 42 $lang['concours_result'] 32 $lang['subcriteria_add'] = 'Ajouter un sous-critère'; 33 $lang['concours_actions'] = 'Actions'; 34 $lang['concours_admin_title'] = 'Administration du plugin Concours Photo'; 35 $lang['default_criteria'] = 'Gestion des critères par défaut'; 36 $lang['concours_add_criteria'] = 'Ajouter un nouveau critère'; 37 $lang['concours_criteria_submit'] = 'Valider le critère'; 38 $lang['manage_concours'] = 'Gestion des concours'; 39 $lang['prepared_concours'] = 'Concours préparés non actifs'; 40 $lang['active_concours'] = 'Concours actifs en cours'; 41 $lang['closed_concours'] = 'Concours terminés'; 42 $lang['concours_result'] = 'Générer le résultat'; 43 43 $lang['concours_file'] = 'Télécharger le fichier résultat'; 44 $lang['concours_create_date'] 45 $lang['concours_management'] 44 $lang['concours_create_date'] = 'Date de création'; 45 $lang['concours_management'] = 'Gérer les concours'; 46 46 $lang['concours_edit'] = 'Editer le concours'; 47 $lang['concours_delete'] 47 $lang['concours_delete'] = 'Supprimer le concours'; 48 48 $lang['concours_add'] = 'Ajouter un concours'; 49 $lang['concours_config'] 50 $lang['concours_admin_add'] = $lang['concours_add'];51 $lang['concours_comment'] = 'Appréciation/Commentaire/Remarque sur la photo';52 $lang['concours_result_page'] = 'Résultat du concours';53 $lang['concours_img_author'] = 'Masqué pour le concours';54 $lang['concours_1st'] = 'er';55 $lang['concours_2nd'] = 'ème';56 $lang['concours_3rd'] = 'ème';57 $lang['concours_4th'] = 'ème';58 $lang['concours_submit'] = 'Valider';59 $lang['concours_params'] = 'Paramètres généraux';49 $lang['concours_config'] = 'Critères par défaut'; 50 $lang['concours_admin_add'] = $lang['concours_add']; 51 $lang['concours_comment'] = 'Appréciation/Commentaire/Remarque sur la photo'; 52 $lang['concours_result_page'] = 'Résultat du concours'; 53 $lang['concours_img_author'] = 'Masqué pour le concours'; 54 $lang['concours_1st'] = 'er'; 55 $lang['concours_2nd'] = 'ème'; 56 $lang['concours_3rd'] = 'ème'; 57 $lang['concours_4th'] = 'ème'; 58 $lang['concours_submit'] = 'Valider'; 59 $lang['concours_params'] = 'Paramètres généraux'; 60 60 $lang['concours_show_menubar'] = 'Affichage du menu "Résultat des concours"'; 61 $lang['concours_nb_concours_menubar'] 61 $lang['concours_nb_concours_menubar'] = 'Nombre de résultats à afficher'; 62 62 $lang['concours_result_files'] = 'Fichiers générés de résultat'; 63 $lang['concours_result_file_list'] 64 $lang['concours_no_result_file'] 63 $lang['concours_result_file_list'] = 'Liste des fichiers de résultat pouvant être téléchargés (même si le concours a été supprimé)'; 64 $lang['concours_no_result_file'] = 'Aucun fichier généré présent'; 65 65 66 $lang['concours_date_from'] = 'Date de Début';67 $lang['concours_date_end'] = 'Date de Fin';68 $lang['concours_hour_from'] = 'Heure de Début';69 $lang['concours_hour_to'] = 'Heure de Fin';66 $lang['concours_date_from'] = 'Date de Début'; 67 $lang['concours_date_end'] = 'Date de Fin'; 68 $lang['concours_hour_from'] = 'Heure de Début'; 69 $lang['concours_hour_to'] = 'Heure de Fin'; 70 70 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';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 73 74 $lang['thumbnail_global_note'] = 'Note concours';75 $lang['concours_thumb_note'] = 'Ajouter la note globale sous les miniatures';76 $lang['concours_global_user_note'] ='Total enregistré';74 $lang['thumbnail_global_note'] = 'Note concours'; 75 $lang['concours_thumb_note'] = 'Ajouter la note globale sous les miniatures'; 76 $lang['concours_global_user_note'] = 'Total enregistré'; 77 77 78 78 79 $lang['concours_activ_from'] = 'Concours actif de ';80 $lang['concours_activ_to'] = ' à ';81 $lang['concours_method'] = 'Méthode de calcul du classement';82 $lang['concours_method1'] = 'Somme des notes';83 $lang['concours_method2'] = 'Moyenne des notes';79 $lang['concours_activ_from'] = 'Concours actif de '; 80 $lang['concours_activ_to'] = ' à '; 81 $lang['concours_method'] = 'Méthode de calcul du classement'; 82 $lang['concours_method1'] = 'Somme des notes'; 83 $lang['concours_method2'] = 'Moyenne des notes'; 84 84 85 $lang['concours_note'] = 'Note globale';86 $lang['concours_moyenne'] = 'Moyenne';87 $lang['concours_nbvotant'] = 'Nombre de votant';88 $lang['concours_usernote'] = 'Votre note';89 $lang['concours_infos'] = 'Information sur le concours';90 $lang['concours_audit'] = 'Audit';91 $lang['concours_audit1'] = 'Auditer le concours';92 $lang['concours_author'] = 'Auteur';93 $lang['NO_concours'] = 'Aucun concours';85 $lang['concours_note'] = 'Note globale'; 86 $lang['concours_moyenne'] = 'Moyenne'; 87 $lang['concours_nbvotant'] = 'Nombre de votant'; 88 $lang['concours_usernote'] = 'Votre note'; 89 $lang['concours_infos'] = 'Information sur le concours'; 90 $lang['concours_audit'] = 'Audit'; 91 $lang['concours_audit1'] = 'Auditer le concours'; 92 $lang['concours_author'] = 'Auteur'; 93 $lang['NO_concours'] = 'Aucun concours'; 94 94 $lang['concours_username_selection'] = 'Sélection d\'un utilisateur'; 95 $lang['all_users'] = '-- Tous --'; 95 $lang['all_users'] = '-- Tous --'; 96 $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)'; 98 $lang['concours_change_score'] = 'Autoriser les votants à modifier les notes après validation'; 96 99 ?> -
extensions/ConcoursPhoto/main.inc.php
r4428 r8946 2 2 /* 3 3 * Plugin Name: ConcoursPhoto 4 * Version: 1. 1.04 * Version: 1.2.0 5 5 * Description: Concours de photo paramétrable 6 6 * Plugin URI: http://piwigo.org/ext/extension_view.php?eid=323 … … 46 46 47 47 // Add concours to picture page 48 add_event_handler('loc_begin_picture', array(&$concours, 'concours_disable_exifs'));49 48 add_event_handler('loc_end_picture', array(&$concours, 'display_concours_to_picture')); 50 49 // Add admin page -
extensions/ConcoursPhoto/maintain.inc.php
r4368 r8946 27 27 `groups` varchar(255) default NULL, 28 28 `method` smallint(5) default 1 NOT NULL, 29 `guest` Boolean default FALSE, 29 30 30 31 PRIMARY KEY (`id`) … … 59 60 `datas` longtext default NULL, 60 61 `comment` longtext default NULL, 62 `ipguest` longtext default NULL, 61 63 PRIMARY KEY (`id`) 62 64 ) DEFAULT CHARSET=utf8;'; … … 74 76 `nbvotant` smallint(5) default 0, 75 77 76 PRIMARY KEY (`img_id` ),78 PRIMARY KEY (`img_id`, `id_concours`), 77 79 FOREIGN KEY (`id_concours`) REFERENCES ' . $prefixeTable . 'concours(id) 78 80 ) DEFAULT CHARSET=utf8;'; … … 188 190 global $prefixeTable; 189 191 190 // Check if upgrade is needed 192 // Check if upgrade is needed (from 1.0.0) 191 193 $query = 'SHOW FULL COLUMNS FROM ' . $prefixeTable . 'concours_result;'; 192 194 $result = array_from_query($query, 'Field'); 193 195 if (count($result) < 7) // only 6 datas on previous database 194 196 { 197 upgrade_concoursresult_from_100(); 198 } 199 // Check if upgrade is needed (from 1.0.0) 200 $query = 'SHOW FULL COLUMNS FROM ' . $prefixeTable . 'concours;'; 201 $result = array_from_query($query, 'Field'); 202 if (count($result) < 10) // only 6 datas on previous database 203 { 195 204 upgrade_concours_from_100(); 196 205 } … … 216 225 } 217 226 218 // Add new parameter in database in version 2.0.0:227 // Add new parameter in database in version 1.0.1: 219 228 // - moy : moyenne of global note with all participant 220 229 // - nbvotant : nb of vote for an image 221 230 // - method = type of rank calculation (1-> total; 2-> moyenne) 222 function upgrade_concours _from_100()231 function upgrade_concoursresult_from_100() 223 232 { 224 233 global $prefixeTable; … … 241 250 } 242 251 252 // Add new parameter in database in version 2.0.0: 253 // - guest : boolean to allow guest to use this function (concours) 254 function upgrade_concours_from_100() 255 { 256 global $prefixeTable; 257 // Add new parameters 258 $query = 'ALTER TABLE ' . $prefixeTable . 'concours 259 ADD `guest` boolean default FALSE AFTER `method` 260 ;'; 261 262 pwg_query($query); 263 // Add new parameters 264 $query = 'ALTER TABLE ' . $prefixeTable . 'concours_data 265 ADD `ipguest` longtext default NULL AFTER `comment` 266 ;'; 267 268 pwg_query($query); 269 270 } 271 243 272 ?> -
extensions/ConcoursPhoto/publish.php
r4428 r8946 10 10 $ap_id = explode('concours/' , $_SERVER['REQUEST_URI']); 11 11 $id_concours = $ap_id[1]; 12 13 $user['ipguest'] = null; 14 if (is_a_guest()) 15 { 16 if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) 17 $IP = $_SERVER['HTTP_X_FORWARDED_FOR']; 18 elseif(isset($_SERVER['HTTP_CLIENT_IP'])) 19 $IP = $_SERVER['HTTP_CLIENT_IP']; 20 else 21 $IP = $_SERVER['REMOTE_ADDR']; 22 23 // store ip 24 $user['ipguest'] = $IP; 25 } 26 27 12 28 13 29 $concours = new Concours($id_concours); … … 34 50 .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' 35 51 .' INNER JOIN '.CONCOURS_RESULT_TABLE.' AS conc ON conc.img_id = img.id' 36 .' WHERE ic.category_id = '.$concours->concours_infos['category']; 52 .' WHERE ic.category_id = '.$concours->concours_infos['category'] 53 .' AND conc.id_concours = '.$concours->concours_infos['id'] 54 ; 37 55 38 56 if ($concours->concours_infos['method'] == 1) // total … … 45 63 $result = pwg_query($query); 46 64 $rang = 1; 65 $previousNote = $previousMoy = 0; 47 66 while ($row = mysql_fetch_assoc($result)) 48 67 { … … 76 95 unset_make_full_url(); 77 96 97 // Check the exaequos 98 if ($concours->my_config['check_exaequo']) 99 { 100 if ( ($concours->concours_infos['method'] == 1 // total 101 AND ($row['note'] == $previousNote)) 102 OR ($concours->concours_infos['method'] == 2 // moyenne 103 AND ($row['moyenne'] == $previousMoy))) 104 { 105 // echo "Rang=".$rang."\n"; 106 $rang --; 107 108 } 109 } 110 78 111 $template->append( 'concours_note', array( 79 112 'img_id' => $row['id'], … … 87 120 'moyenne' => ($row['moyenne'] == 0 ? 'N/A' :$row['moyenne']), 88 121 'nbvotant' => $row['nbvotant'], 89 'usernote' => $concours->get_img_globalnote_user($row['id'] )122 'usernote' => $concours->get_img_globalnote_user($row['id'], null, null, $user['ipguest']) 90 123 91 124 )); 92 $rang ++; 125 $rang ++; 126 127 // echo "Rang=".$rang."\n"; 128 $previousNote = $row['note']; 129 $previousMoy = $row['moyenne']; 93 130 94 131 } -
extensions/ConcoursPhoto/template/concours.tpl
r4260 r8946 47 47 </table> 48 48 <p> 49 {if $CONCOURS_CHANGE_SCORE} 49 50 <input type="submit" name="concours_submit" value="{'concours_save'|@translate}" /> 50 51 <input type="submit" name="concours_raz" value="{'concours_RAZ'|@translate}" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');"> 52 {/if} 51 53 </p> 52 54 </fieldset>
Note: See TracChangeset
for help on using the changeset viewer.