Show
Ignore:
Timestamp:
09/03/07 22:44:40 (16 months ago)
Author:
llaumgui
Message:

Ticket #6 : Opérateur derniers messages

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ez_publish/ezipb/trunk/autoloads/ezipb_operators.php

    r8 r15  
    6060                                                                        'ezipb_member', 
    6161                                                                        'ezipb_md5_check', 
    62                                                                         'ezipb_vars' ); 
     62                                                                        'ezipb_vars', 
     63                                                                        'ezipb_fetch_post' ); 
    6364        } 
    6465                 
     
    8485                                                'ezipb_md5_check'               => array(), 
    8586                                                'ezipb_vars'                    => array(       'index' => array( 'type' => 'string', 'required' => false, 'default' => '' ) ), 
     87                                                'ezipb_fetch_post'              => array(       'options' => array( 'type' => 'array', 'required' => false, 'default' => array() ) ) 
    8688                                        ); 
    8789        } 
     
    111113                case 'ezipb_vars': 
    112114                        $operatorValue = $this->ezipb_vars(  $namedParameters['index'] ); 
     115                        break; 
     116                case 'ezipb_fetch_post': 
     117                        $operatorValue = $this->ezipb_fetch_post(  $namedParameters['options'] ); 
     118                        break; 
    113119                } 
    114120        } 
     
    184190        } 
    185191         
     192         
     193         
     194        /** 
     195         * Fonction retournant les information sur les derniers topics 
     196         *  
     197         * Dilemme dilemme... 
     198         * Utiliser le layer d'eZ ou celui d'IPB... 
     199         * J'ai pesé le pour et le contre et voici pourquoi j'utilise celui d'IPB : 
     200         *              - gestion automatique des préfixes des tables IPB. 
     201         *              - en cas de base de données eZ et IPB différentes eZDB et $ipsclass->DB  
     202         * peuvent pointer sur une base voir un serveur différent... 
     203         * Bref, je pense avoir fait le bon choix ! 
     204         * 
     205         * @param array $options Options de la requêtes. 
     206         * @return array Infos sur les postes 
     207         */ 
     208        function ezipb_fetch_post ( $options ) { 
     209 
     210                /* Valeurs par défauts */ 
     211                if ( !array_key_exists( 'sort_by', $options ) || !is_array( $options['sort_by']) ) 
     212                        $options['sort_by']             = array( 'last_post', true ); 
     213                if ( !array_key_exists( 'offset', $options ) ) 
     214                        $options['offset']              =  0; 
     215                if ( !array_key_exists( 'limit', $options ) ) 
     216                        $options['limit']               =  0;                                                                                                                                                                                            
     217                 
     218                /* true() or false() - ascending or descending */ 
     219                if ( $options['sort_by'][1] ) 
     220                         $options['sort_by'][1] = 'ASC'; 
     221                else 
     222                        $options['sort_by'][1]  = 'DESC'; 
     223                print_r ($options); 
     224                                                                 
     225                $this->ipsclass->DB->build_query( array( 'select'   => 't.*', 
     226                                                                                                 'from'     => array( 'topics' => 't' ), 
     227                                                                                                 'where'    => 't.approved=1 ', //AND t.forum_id IN (0,'.$this->topic_list_config['forums'].')', 
     228                                                                                             'order'    => $options['sort_by'][0].' '.$options['sort_by'][1], 
     229                                                                                                 'limit'    => array( $options['offset'], $options['limit'] ), 
     230                                                                                                 'add_join' => array(  
     231                                                                                                                                          0 => array( 'select' => 'p.*', 
     232                                                                                                                                                                  'from'   => array( 'posts' => 'p' ), 
     233                                                                                                                                                                  'where'  => 't.topic_firstpost=p.pid', 
     234                                                                                                                                                                  'type'   => 'left' ), 
     235                                                                                                                                          1 => array( 'select' => 'm.id as member_id, m.members_display_name as member_name, m.mgroup, m.email', 
     236                                                                                                                                                                  'from'   => array( 'members' => 'm' ), 
     237                                                                                                                                                                  'where'  => "m.id=p.author_id", 
     238                                                                                                                                                                  'type'   => 'left' ), 
     239                                                                                                                                          2 => array( 'select' => 'f.id as forum_id, f.name as forum_name, f.use_html', 
     240                                                                                                                                                                  'from'   => array( 'forums' => 'f' ), 
     241                                                                                                                                                                  'where'  => "t.forum_id=f.id", 
     242                                                                                                                                                                  'type'   => 'left' ) ) 
     243                                                                                )      ); 
     244                $this->ipsclass->DB->exec_query(); 
     245                return $this->ipsclass->DB->fetch_row(); 
     246        } 
     247         
    186248 
    187249} // EOC