Differences From Artifact [94deebcaa3]:

To Artifact [328c22ff92]:


1
2
3
4
5
6
7
8
9
10
<?php

class Garradin_Membres extends Garradin_DB
{
    const DROIT_CONNEXION = 1;
    const DROIT_INSCRIPTION = 2;

    const DROIT_WIKI_LIRE = 10;
    const DROIT_WIKI_ECRIRE = 11;
    const DROIT_WIKI_FICHIERS = 12;


|







1
2
3
4
5
6
7
8
9
10
<?php

class Garradin_Membres
{
    const DROIT_CONNEXION = 1;
    const DROIT_INSCRIPTION = 2;

    const DROIT_WIKI_LIRE = 10;
    const DROIT_WIKI_ECRIRE = 11;
    const DROIT_WIKI_FICHIERS = 12;
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117



















118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
        $_SESSION = array();
        setcookie(session_name(), '', 0, '/');
        return true;
    }

    public function _checkFields($data)
    {
        $mandatory = Config::getInstance()->get('champs_obligatoires');

        foreach ($mandatory as $field)
        {
            if (!array_key_exists($field, $data) || !trim($data[$field]))
            {
                throw new UserException('Le champ \''.$field.'\' ne peut rester vide.');
            }
        }

        if (isset($data['email']) && !filter_var($data['email'], FILTER_VALIDATE_EMAIL))
        {
            throw new UserException('Adresse e-mail \''.$field.'\' invalide.');
        }

        return true;
    }

    public function add($data = array())
    {
        $this->_checkFields($data);
        // INSERT SQL



















    }

    public function edit($id, $data = array())
    {
        $this->_checkFields($data);
        // UPDATE SQL
    }

    public function remove($id)
    {
    }

    public function search($query)
    {
    }

    public function getList($page = 1)
    {
    }

    public function
}

?>







|




















|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




















<



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156

157
158
159
        $_SESSION = array();
        setcookie(session_name(), '', 0, '/');
        return true;
    }

    public function _checkFields($data)
    {
        $mandatory = Garradin_Config::getInstance()->get('champs_obligatoires');

        foreach ($mandatory as $field)
        {
            if (!array_key_exists($field, $data) || !trim($data[$field]))
            {
                throw new UserException('Le champ \''.$field.'\' ne peut rester vide.');
            }
        }

        if (isset($data['email']) && !filter_var($data['email'], FILTER_VALIDATE_EMAIL))
        {
            throw new UserException('Adresse e-mail \''.$field.'\' invalide.');
        }

        return true;
    }

    public function add($data = array())
    {
        $this->_checkFields($data);

        if (!trim($data['passe']))
        {
            $data['passe'] = $this->_hashPassword($data['passe']);
        }

        if (!isset($data['id_categorie']))
        {
            $data['id_categorie'] = Garradin_Config::getInstance()->get('categorie_membres');
        }

        $db = Garradin_DB::getInstance();

        return $db->simpleExec('INSERT INTO membres
            (id_categorie, passe, nom, email, adresse, code_postal, ville, pays, telephone,
            date_anniversaire, details, date_inscription, date_connexion, date_cotisation)
            VALUES
            (:id_categorie, :passe, :nom, :email, :adresse, :code_postal, :ville, :pays, :telephone,
            :date_anniversaire, :details, :date_inscription, :date_connexion, :date_cotisation);',
            $data);
    }

    public function edit($id, $data = array())
    {
        $this->_checkFields($data);
        // UPDATE SQL
    }

    public function remove($id)
    {
    }

    public function search($query)
    {
    }

    public function getList($page = 1)
    {
    }


}

?>