| | 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 | |