root/ez_publish/ezipb/trunk/classes/ezipb.php

Revision 67, 3.6 KB (checked in by llaumgui, 16 months ago)

Ticket #14
A savoir que $ipsclass->return_md5_check() doit être après $ipsclass->sess->authorise() car il utilise des fonctions membres

Line 
1<?php
2
3/*
4 * #################### BEGIN LICENSE BLOCK ####################
5 * This file is part of ezipb.
6 * Copyright (c) 2007 Guillaume Kulakowski and contributors. All
7 * rights reserved.
8 *
9 * ezipb is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * ezipb is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty
16 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
17 * the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with ezipb; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330,
22 * Boston, MA  02111-1307  USA
23 * or visit http://www.gnu.org/licenses/gpl.html
24 * ###################### END LICENSE BLOCK ####################
25 *
26 * Fonction de communication entre eZ publish et IPB.
27 *
28 * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com>
29 * @version 1.0
30 */
31
32
33
34class ezipb {
35   
36    public $ipsclass;                // ipsclass
37    private $ezipbIni;                // ezipb.ini
38
39   
40   
41    /**
42     * Constructeur
43     */
44    function __construct() {
45       
46        /* Récupération des infos de ezipb.ini */
47        $this->ezipbIni = eZINI::instance( "ezipb.ini" );
48       
49        /* Chemin vers IPB */
50        define( 'IPB_PATH', $this->ezipbIni->variable( "IPB", "IPB_PATH" ) );
51       
52        /* On force MySQL à la place de MySQLi */
53        if ( $this->ezipbIni->variable( "ezipb", "FORCE_MYSQL_ONLY" ) == "enabled" )
54            define( 'FORCE_MYSQL_ONLY', 1 );
55       
56        /*
57         * Initialisation d'IPB
58         * Pompée dans le index.php
59         * @TODO Aléger la bête !
60         */
61        define( 'IPB_THIS_SCRIPT', 'public' );
62        $INFO = array();
63       
64        require_once IPB_PATH . 'init.php';
65        require_once IPB_PATH . 'conf_global.php';
66        require_once eZExtension::baseDirectory() . '/ezipb/classes/ezipsclass.php';
67        require_once IPB_PATH . "sources/classes/class_session.php";
68        require_once KERNEL_PATH . "class_converge.php";
69       
70        $this->ipsclass = new ezipsclass();
71        $this->ipsclass->ezipbIni             = &$this->ezipbIni;
72        $this->ipsclass->vars                 = $INFO;
73        $this->ipsclass->init_db_connection();
74        $this->ipsclass->sess                 =  new session();
75        $this->ipsclass->sess->ipsclass       =& $this->ipsclass;
76        $this->ipsclass->parse_incoming();
77       
78        $this->ipsclass->converge             = new class_converge( $this->ipsclass->DB );
79       
80        $this->ipsclass->member             = $this->ipsclass->sess->authorise();
81        $this->ipsclass->md5_check             = $this->ipsclass->return_md5_check();       
82        //echo "<pre>" . print_r( $this->ipsclass->DB->obj['cached_queries'] ) . "</pre>";
83    }
84   
85   
86    /**
87     * Permet d'instancier l'objet ezipb.
88     *
89     * @return object ezipb
90     */
91    static function instance() {
92
93        $impl =& $GLOBALS["ezipbGlobalInstance"];
94       
95        $class = strtolower( get_class( $impl ) ); 
96        if ( $class != "ezipb" )
97            $impl = new ezipb();
98           
99        return $impl;
100     }
101   
102   
103     /**
104      * Le visiteur est il membre
105      *
106      * @return boolean
107      */
108     public function isLoggin() {
109       
110        if ( $this->ipsclass->member['id'] > 0 )
111            return true;
112        return false;
113    }
114   
115   
116
117    /**
118     * Le membre est il super modérateur ?
119     *
120     * @return Booléen
121     */
122    public function isSuperModo() {
123       
124        if ($this->ipsclass->member['g_is_supmod'])
125            return true;
126        else
127            return false;
128    }
129
130
131   
132    /**
133     * Le membre est il administrateur ?
134     *
135     * @return Booléen
136     */
137    public function isAdmin() {
138       
139        if ($this->ipsclass->member['g_access_cp'])
140            return true;
141        else
142            return false;
143    }
144         
145}    // EOC
146
147?>
Note: See TracBrowser for help on using the browser.