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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.