Changeset 4260


Ignore:
Timestamp:
Nov 12, 2009, 9:56:21 PM (14 years ago)
Author:
tiico
Message:

[ConcoursPhoto] Add global note under thumb (+ param) and in concours image page; Correct author masking

Location:
extensions/ConcoursPhoto
Files:
7 edited

Legend:

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

    r4252 r4260  
    1414
    1515  $concours->my_config['mask_author'] = isset($_POST['mask_author']);
     16  $concours->my_config['thumb_note'] = isset($_POST['thumb_note']);
    1617
    1718  $concours->save_config();
     
    2829        'SHOW_MENUBAR'                  => ($concours->my_config['active_menubar'] ? 'checked="checked"' : ''),
    2930    'MASK_AUTHOR'                       => ($concours->my_config['mask_author'] ? 'checked="checked"' : ''),
     31    'THUMB_NOTE'                        => ($concours->my_config['thumb_note'] ? 'checked="checked"' : ''),
    3032                        ));
    3133
  • extensions/ConcoursPhoto/admin/template/params.tpl

    r4252 r4260  
    3030                <TD colspan="2">
    3131                    <input type="checkbox" name="mask_author" {$MASK_AUTHOR}/> {'concours_mask_author'|@translate}
     32                    <br/>
     33                </TD>
     34        </TR>
     35        <TR>
     36                <TD colspan="2">
     37                    <input type="checkbox" name="thumb_note" {$THUMB_NOTE}/> {'concours_thumb_note'|@translate}
    3238                    <br/>
    3339                </TD>
  • extensions/ConcoursPhoto/include/Concours.class.php

    r4254 r4260  
    724724}
    725725//  END DEBUG
     726
     727
     728        // disable author name on image which are present in a concours.
     729        // check the categories where the current image is present and disable the author name
     730                if ($this->my_config['mask_author'] && $this->my_config['mask_author'] == true)
     731                {
     732                        // Get all categories where the current image is present
     733                        $query = '
     734                        SELECT category_id,uppercats,commentable,global_rank
     735                          FROM '.IMAGE_CATEGORY_TABLE.'
     736                                INNER JOIN '.CATEGORIES_TABLE.' ON category_id = id
     737                          WHERE image_id = '.$page['image_id'].'
     738                          ;';
     739//                     echo $query;
     740                        $result = pwg_query($query);
     741                        $related_categories = array();
     742                        while ($row = mysql_fetch_array($result))
     743                        {
     744                          array_push($related_categories, $row['category_id']);
     745                        }
     746                        //
     747            //echo related_categories;
     748            if (count($related_categories))
     749            {
     750                // Request for all concours prepared & actived on each categories
     751                $query = '
     752                    SELECT *
     753                    FROM ' . CONCOURS_TABLE .'
     754                    WHERE category IN ('.implode(',', $related_categories).')
     755                    AND time_to_sec(TIMEDIFF(now(), end_date)) < 0
     756                ';
     757        //                echo $query;
     758                $result = pwg_query($query);
     759                // If one or more concours are found, the author name is masked
     760                if ($result && mysql_fetch_assoc($result))
     761                    $template->assign('INFO_AUTHOR',l10n('concours_img_author'));
     762            }
     763                }
     764
     765        // End disable author name
     766
     767
    726768                if (($page['section']) == 'categories' AND !empty($page['category']))
    727769                {
     
    729771                        //------------
    730772                        // Step 1
    731            
     773
     774/*           
    732775            if ($this->my_config['mask_author'] && $this->my_config['mask_author'] == true)
    733776            {
     
    744787                    $template->assign('INFO_AUTHOR',l10n('concours_img_author'));
    745788            }
    746 
     789*/
    747790           
    748791                        $query = '
     
    907950                                $template->assign( 'concours_infos', array(
    908951                                                        'name'  => $concours['name'],
    909                                                         'descr' => $concours['descr']
     952                                                        'descr' => $concours['descr'],
     953                            'note'  => $this->get_img_globalnote_user($page['current_item'], $concours['id'])
    910954                                                                ));
    911955                               
     
    14461490        if ($menu->get_id() != 'menubar' OR $this->my_config['active_menubar'] == false)
    14471491          return;
    1448         $menu->register_block( new RegisteredBlock( 'CONCOURS_menu', 'Polls', 'MYPOLLS'));
     1492        $menu->register_block( new RegisteredBlock( 'CONCOURS_menu', 'concours', 'ConcoursPhoto'));
    14491493        }
    14501494
     
    15461590                global $page;
    15471591               
     1592               
    15481593                if (isset($page['section']) and $page['section'] == 'concours')
    15491594                {
     
    15531598
    15541599       
     1600  // Show the global note under the thumbnail
     1601  function thumbnail_note($tpl_var)
     1602  {
     1603
     1604        global $page;
     1605        $this->get_user_groups();
     1606
     1607    if ($this->my_config['thumb_note'] && $this->my_config['thumb_note'] == true)
     1608    {
     1609        $concours = array();
     1610        if (($page['section']) == 'categories' AND !empty($page['category']))
     1611        {
     1612            $query = '
     1613                SELECT *
     1614                FROM ' . CONCOURS_TABLE .'
     1615                WHERE category =' . $page['category']['id'] . '
     1616                AND time_to_sec(TIMEDIFF(begin_date,now())) < 0
     1617                AND time_to_sec(TIMEDIFF(now(), end_date)) < 0
     1618                ';
     1619
     1620            $result = pwg_query($query);
     1621    if ($this->debug) echo $query."\n";
     1622            while ($row = mysql_fetch_assoc($result))
     1623            {
     1624               
     1625                if (!empty($row['groups']))
     1626                {
     1627    if ($this->debug)   echo "GROUPS=".$row['groups'];                         
     1628                    $authorized_groups = explode(',', $row['groups']);
     1629                    if (array_intersect($this->user_groups, $authorized_groups) == array())
     1630                    {
     1631    if ($this->debug)   echo "ERROR GROUPS";
     1632                        continue;
     1633                    }
     1634                    $concours = $row;
     1635                }
     1636            }
     1637            if (count($concours))
     1638            {
     1639
     1640                foreach($tpl_var as $cle=>$valeur) {
     1641                {
     1642                  $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']);
     1643                  }
     1644                }
     1645            }
     1646        }
     1647    }
     1648    return $tpl_var;
     1649  }
     1650       
     1651       
    15551652}
    15561653
  • extensions/ConcoursPhoto/include/default_values.inc.php

    r4252 r4260  
    88$concours_default_values['nbconcours_menubar'] = 3;     // Nb of last published concours show on concours menubar
    99$concours_default_values['mask_author'] =   true; // Mask author for prepared concours
     10$concours_default_values['thumb_note'] = true; // Display global note (for user) under thumbnail
    1011?>
  • extensions/ConcoursPhoto/language/fr_FR/plugin.lang.php

    r4252 r4260  
    6969
    7070$lang['concours_mask_author']   =  'Masquer l\'auteur pour les concours préparés non actifs';
     71
     72$lang['thumbnail_global_note'] = 'Note concours';
     73$lang['concours_thumb_note'] = 'Ajouter la note globale sous les miniatures';
     74$lang['concours_global_user_note']  =   'Total enregistré';
    7175?>
  • extensions/ConcoursPhoto/main.inc.php

    r3905 r4260  
    5858add_event_handler('loc_end_index', array(&$concours, 'index_concours'));
    5959
     60// Add Global note under thumbnail
     61add_event_handler('loc_end_index_thumbnails', array(&$concours, 'thumbnail_note'), 50, 2);
     62
    6063
    6164set_plugin_data($plugin['id'], $concours)
  • extensions/ConcoursPhoto/template/concours.tpl

    r3905 r4260  
    55        <table>
    66                <tr>
    7                         <td align="left" colspan="5"><b>Concours : {$concours_infos.name}&nbsp;</b>
     7                        <td align="left" colspan="2"><b>Concours : {$concours_infos.name}&nbsp;</b>
    88                        <i>({$concours_infos.descr})</i>&nbsp;
    9                         <td>
     9                        </td>
     10            <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;
     12            </td>
     13            <td>&nbsp;
     14            </td>
    1015                </tr>
    1116                <tr><td colspan="5"><br></td></tr>
Note: See TracChangeset for help on using the changeset viewer.