Changeset 204

Show
Ignore:
Timestamp:
07/02/08 20:45:58 (6 months ago)
Author:
llaumgui
Message:

Jointure facultative

Location:
ez_publish/ezfluxbb/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • ez_publish/ezfluxbb/trunk/classes/ezfluxbb.php

    r203 r204  
    203203                $db             = eZFluxBBDB::instance(); 
    204204                 
    205                                  
    206                 $topics         = $db->arrayQuery(      'SELECT t.id topic_id, t.poster, t.subject, t.num_replies, p.id post_id, p.message ' . 
     205                $select         = 't.id topic_id, t.poster, t.subject, t.num_replies'; 
     206                $leftJoin       = ''; 
     207                 
     208                /* Jointure avec les messages */ 
     209                if ( $params['get_first_message'] ) 
     210                { 
     211                        $select         .= ' ,p.id post_id, p.message'; 
     212                        $leftJoin       .= 'LEFT JOIN '.$this->fluxBBConfig['db_prefix'].'posts p ON (p.topic_id=t.id AND t.posted = p.posted)'; 
     213                } 
     214                 
     215                $topics         = $db->arrayQuery(      'SELECT ' . $select . ' ' . 
    207216                                                                                'FROM '.$this->fluxBBConfig['db_prefix'].'topics t ' . 
    208                                                                                 /* TODO : Rendre la jointure paramÚtrable */ 
    209                                                                                         'LEFT JOIN '.$this->fluxBBConfig['db_prefix'].'posts p ON (p.topic_id=t.id AND t.posted = p.posted) ' . 
     217                                                                                        $leftJoin . ' ' . 
    210218                                                                                'WHERE forum_id ' . $params['forum_id'] . ' ' . 
    211219                                                                                'ORDER BY ' . $params['sort_by'] .' ' . 
  • ez_publish/ezfluxbb/trunk/classes/ezfluxbbfetchfonctions.php

    r203 r204  
    100100         * @return array 
    101101         */ 
    102         function fetchTopics( $forum_id_filter_type, $forum_id_filter_array, $limit, $offset, $sort_by ) 
     102        function fetchTopics( $forum_id_filter_type, $forum_id_filter_array, $limit, $offset, $sort_by, $get_first_message ) 
    103103        { 
    104104                $sortingString          = 't.posted'; 
     
    129129                 
    130130                /* $forum_id */ 
    131         if ( $forum_id_filter_type == 'exclude' ) 
    132         { 
    133                 $sortingForum_id        = 'NOT IN'; 
    134         } 
    135         if ( is_array( $forum_id_filter_array ) ) 
    136         { 
    137                 $sortingForum_id        .= ' (' . implode( ', ', $forum_id_filter_array) . ')'; 
    138         } 
    139         else 
    140         { 
    141                 $sortingForum_id        .= ' (' . $forum_id_filter_array . ')'; 
    142         } 
    143                                  
     131                if ( $forum_id_filter_array ) 
     132                { 
     133                if ( $forum_id_filter_type == 'exclude' ) 
     134                { 
     135                        $sortingForum_id        = 'NOT IN'; 
     136                } 
     137                if ( is_array( $forum_id_filter_array ) ) 
     138                { 
     139                        $sortingForum_id        .= ' (' . implode( ', ', $forum_id_filter_array) . ')'; 
     140                } 
     141                else 
     142                { 
     143                        $sortingForum_id        .= ' (' . $forum_id_filter_array . ')'; 
     144                } 
     145                } 
     146                else 
     147                { 
     148                        $sortingForum_id        = ""; 
     149                } 
     150                 
    144151                $eZFluxBB               = eZFluxBB::instance(); 
    145152                $params                 = array(        'forum_id'                                      => $sortingForum_id, 
    146153                                                                        'limit'                                         => $limit, 
    147154                                                                        'offset'                                        => $offset, 
    148                                                                         'sort_by'                                       => $sortingString . ' ' . $sortingOrder ); 
     155                                                                        'sort_by'                                       => $sortingString . ' ' . $sortingOrder, 
     156                                                                        'get_first_message'             => $get_first_message); 
    149157                 
    150158                $topics                 = $eZFluxBB->getTopics( $params ); 
  • ez_publish/ezfluxbb/trunk/modules/ezfluxbb/function_definition.php

    r203 r204  
    106106                                'default'  => array( 't.posted', false ) 
    107107                ), 
     108                array(  'name'     => 'get_first_message', 
     109                                'type'     => 'boolean', 
     110                                'required' => false, 
     111                                'default'  => false 
     112                ), 
    108113        ) 
    109114);