Overview
Comment:Utilisation des namespaces
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9a0053fe6f79c0b6d34c62ede1ff985f6df7fbf3
User & Date: bohwaz on 2012-12-19 04:43:15
Other Links: manifest | tags
Context
2012-12-19
04:44
namespace étant une fonctionnalité de PHP 5.3, mettons la *après* le test de version de PHP check-in: c5b65759c6 user: bohwaz tags: trunk
04:43
Utilisation des namespaces check-in: 9a0053fe6f user: bohwaz tags: trunk
02:52
Ne pas effacer des comptes ceux qui ne sont pas issus du plan comptable check-in: 83f6675553 user: bohwaz tags: trunk
Changes

Modified include/class.compta_categories.php from [5c8f8779e6] to [b9c6a53ad0].

1
2


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php



class Garradin_Compta_Categories
{
    const DEPENSES = -1;
    const RECETTES = 1;
    const AUTRES = 0;

    public function importCategories()
    {
        $db = Garradin_DB::getInstance();
        $db->exec(file_get_contents(GARRADIN_ROOT . '/include/data/categories_comptables.sql'));
    }

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

        $db = Garradin_DB::getInstance();

        if (empty($data['compte']) || !trim($data['compte']))
        {
            throw new UserException('Le compte associé ne peut rester vide.');
        }

        $data['compte'] = trim($data['compte']);


>
>
|







|







|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

namespace Garradin;

class Compta_Categories
{
    const DEPENSES = -1;
    const RECETTES = 1;
    const AUTRES = 0;

    public function importCategories()
    {
        $db = DB::getInstance();
        $db->exec(file_get_contents(GARRADIN_ROOT . '/include/data/categories_comptables.sql'));
    }

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

        $db = DB::getInstance();

        if (empty($data['compte']) || !trim($data['compte']))
        {
            throw new UserException('Le compte associé ne peut rester vide.');
        }

        $data['compte'] = trim($data['compte']);
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
        return $db->lastInsertRowId();
    }

    public function edit($id, $data)
    {
        $this->_checkFields($data);

        $db = Garradin_DB::getInstance();

        $db->simpleUpdate('compta_categories',
            array(
                'intitule'  =>  $data['intitule'],
                'description'=> $data['description'],
            ),
            'id = \''.$db->escapeString(trim($id)).'\'');

        return true;
    }

    public function delete($id)
    {
        $db = Garradin_DB::getInstance();

        // Ne pas supprimer une catégorie qui est utilisée !
        if ($db->simpleQuerySingle('SELECT 1 FROM compta_journal WHERE id_categorie = ? LIMIT 1;', false, $id))
        {
            throw new UserException('Cette catégorie ne peut être supprimée car des opérations comptables y sont liées.');
        }

        $db->simpleExec('DELETE FROM compta_categories WHERE id = ?;', $id);

        return true;
    }

    public function get($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT * FROM compta_categories WHERE id = ?;', true, (int)$id);
    }

    public function getList($type = null)
    {
        $db = Garradin_DB::getInstance();
        $type = is_null($type) ? '' : 'cat.type = '.(int)$type;
        return $db->simpleStatementFetch('
            SELECT cat.*, cc.libelle AS compte_libelle
            FROM compta_categories AS cat INNER JOIN compta_comptes AS cc
                ON cc.id = cat.compte
            WHERE '.$type.' ORDER BY cat.intitule;', SQLITE3_ASSOC);
    }

    public function listMoyensPaiement()
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleStatementFetchAssocKey('SELECT code, nom FROM compta_moyens_paiement ORDER BY nom COLLATE NOCASE;');
    }

    public function getMoyenPaiement($code)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT nom FROM compta_moyens_paiement WHERE code = ?;', false, $code);
    }

    protected function _checkFields(&$data)
    {
        if (empty($data['intitule']) || !trim($data['intitule']))
        {







|













|














|





|










|





|







49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
        return $db->lastInsertRowId();
    }

    public function edit($id, $data)
    {
        $this->_checkFields($data);

        $db = DB::getInstance();

        $db->simpleUpdate('compta_categories',
            array(
                'intitule'  =>  $data['intitule'],
                'description'=> $data['description'],
            ),
            'id = \''.$db->escapeString(trim($id)).'\'');

        return true;
    }

    public function delete($id)
    {
        $db = DB::getInstance();

        // Ne pas supprimer une catégorie qui est utilisée !
        if ($db->simpleQuerySingle('SELECT 1 FROM compta_journal WHERE id_categorie = ? LIMIT 1;', false, $id))
        {
            throw new UserException('Cette catégorie ne peut être supprimée car des opérations comptables y sont liées.');
        }

        $db->simpleExec('DELETE FROM compta_categories WHERE id = ?;', $id);

        return true;
    }

    public function get($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT * FROM compta_categories WHERE id = ?;', true, (int)$id);
    }

    public function getList($type = null)
    {
        $db = DB::getInstance();
        $type = is_null($type) ? '' : 'cat.type = '.(int)$type;
        return $db->simpleStatementFetch('
            SELECT cat.*, cc.libelle AS compte_libelle
            FROM compta_categories AS cat INNER JOIN compta_comptes AS cc
                ON cc.id = cat.compte
            WHERE '.$type.' ORDER BY cat.intitule;', SQLITE3_ASSOC);
    }

    public function listMoyensPaiement()
    {
        $db = DB::getInstance();
        return $db->simpleStatementFetchAssocKey('SELECT code, nom FROM compta_moyens_paiement ORDER BY nom COLLATE NOCASE;');
    }

    public function getMoyenPaiement($code)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT nom FROM compta_moyens_paiement WHERE code = ?;', false, $code);
    }

    protected function _checkFields(&$data)
    {
        if (empty($data['intitule']) || !trim($data['intitule']))
        {

Modified include/class.compta_comptes.php from [4e24838d5c] to [9445dfb633].

1
2


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php



class Garradin_Compta_Comptes
{
    const CAISSE = 530;

    const PASSIF = 0x01;
    const ACTIF = 0x02;
    const PRODUIT = 0x04;
    const CHARGE = 0x08;

    public function importPlan()
    {
        $plan = json_decode(file_get_contents(GARRADIN_ROOT . '/include/data/plan_comptable.json'), true);

        $db = Garradin_DB::getInstance();
        $db->exec('BEGIN;');
        $ids = array();

        foreach ($plan as $id=>$compte)
        {
            $ids[] = $id;



>
>
|












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

namespace Garradin;

class Compta_Comptes
{
    const CAISSE = 530;

    const PASSIF = 0x01;
    const ACTIF = 0x02;
    const PRODUIT = 0x04;
    const CHARGE = 0x08;

    public function importPlan()
    {
        $plan = json_decode(file_get_contents(GARRADIN_ROOT . '/include/data/plan_comptable.json'), true);

        $db = DB::getInstance();
        $db->exec('BEGIN;');
        $ids = array();

        foreach ($plan as $id=>$compte)
        {
            $ids[] = $id;

49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
        return true;
    }

    public function add($data)
    {
        $this->_checkFields($data, true);

        $db = Garradin_DB::getInstance();

        if (empty($data['id']))
        {
            $new_id = $data['parent'];
            $nb_sous_comptes = $db->simpleQuerySingle('SELECT COUNT(*) FROM compta_comptes WHERE parent = ?;', false, $new_id);

            // Pas plus de 26 sous-comptes par compte, parce que l'alphabet s'arrête à 26 lettres







|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
        return true;
    }

    public function add($data)
    {
        $this->_checkFields($data, true);

        $db = DB::getInstance();

        if (empty($data['id']))
        {
            $new_id = $data['parent'];
            $nb_sous_comptes = $db->simpleQuerySingle('SELECT COUNT(*) FROM compta_comptes WHERE parent = ?;', false, $new_id);

            // Pas plus de 26 sous-comptes par compte, parce que l'alphabet s'arrête à 26 lettres
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
        ));

        return $new_id;
    }

    public function edit($id, $data)
    {
        $db = Garradin_DB::getInstance();

        // Vérification que l'on peut éditer ce compte
        if ($db->simpleQuerySingle('SELECT plan_comptable FROM compta_comptes WHERE id = ?;', false, $id))
        {
            throw new UserException('Ce compte fait partie du plan comptable et n\'est pas modifiable.');
        }








|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
        ));

        return $new_id;
    }

    public function edit($id, $data)
    {
        $db = DB::getInstance();

        // Vérification que l'on peut éditer ce compte
        if ($db->simpleQuerySingle('SELECT plan_comptable FROM compta_comptes WHERE id = ?;', false, $id))
        {
            throw new UserException('Ce compte fait partie du plan comptable et n\'est pas modifiable.');
        }

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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
        $db->simpleUpdate('compta_comptes', $update, 'id = \''.$db->escapeString(trim($id)).'\'');

        return true;
    }

    public function delete($id)
    {
        $db = Garradin_DB::getInstance();

        // Ne pas supprimer un compte qui est utilisé !
        if ($db->simpleQuerySingle('SELECT 1 FROM compta_journal WHERE compte_debit = ? OR compte_debit = ? LIMIT 1;', false, $id, $id))
        {
            throw new UserException('Ce compte ne peut être supprimé car des opérations comptables y sont liées.');
        }

        $db->simpleExec('DELETE FROM compta_comptes WHERE id = ?;', trim($id));

        return true;
    }

    public function get($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT * FROM compta_comptes WHERE id = ?;', true, trim($id));
    }

    public function getList($parent = 0)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleStatementFetchAssocKey('SELECT id, * FROM compta_comptes WHERE parent = ? ORDER BY id;', SQLITE3_ASSOC, $parent);
    }

    public function getListAll($parent = 0)
    {
        $db = Garradin_DB::getInstance();
        return $db->queryFetchAssoc('SELECT id, libelle FROM compta_comptes ORDER BY id;');
    }

    public function listTree($parent = 0, $include_children = true)
    {
        $db = Garradin_DB::getInstance();

        if ($include_children)
        {
            $parent = $parent ? 'WHERE parent LIKE \''.$db->escapeString($parent).'%\' ' : '';
        }
        else
        {
            $parent = $parent ? 'WHERE parent = \''.$db->escapeString($parent).'\' ' : 'WHERE parent = 0';
        }

        return $db->simpleStatementFetch('SELECT * FROM compta_comptes '.$parent.' ORDER BY id;');
    }

    protected function _checkFields(&$data, $force_parent_check = false)
    {
        $db = Garradin_DB::getInstance();

        if (empty($data['libelle']) || !trim($data['libelle']))
        {
            throw new UserException('Le libellé ne peut rester vide.');
        }

        $data['libelle'] = trim($data['libelle']);







|














|





|





|





|















|







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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
        $db->simpleUpdate('compta_comptes', $update, 'id = \''.$db->escapeString(trim($id)).'\'');

        return true;
    }

    public function delete($id)
    {
        $db = DB::getInstance();

        // Ne pas supprimer un compte qui est utilisé !
        if ($db->simpleQuerySingle('SELECT 1 FROM compta_journal WHERE compte_debit = ? OR compte_debit = ? LIMIT 1;', false, $id, $id))
        {
            throw new UserException('Ce compte ne peut être supprimé car des opérations comptables y sont liées.');
        }

        $db->simpleExec('DELETE FROM compta_comptes WHERE id = ?;', trim($id));

        return true;
    }

    public function get($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT * FROM compta_comptes WHERE id = ?;', true, trim($id));
    }

    public function getList($parent = 0)
    {
        $db = DB::getInstance();
        return $db->simpleStatementFetchAssocKey('SELECT id, * FROM compta_comptes WHERE parent = ? ORDER BY id;', SQLITE3_ASSOC, $parent);
    }

    public function getListAll($parent = 0)
    {
        $db = DB::getInstance();
        return $db->queryFetchAssoc('SELECT id, libelle FROM compta_comptes ORDER BY id;');
    }

    public function listTree($parent = 0, $include_children = true)
    {
        $db = DB::getInstance();

        if ($include_children)
        {
            $parent = $parent ? 'WHERE parent LIKE \''.$db->escapeString($parent).'%\' ' : '';
        }
        else
        {
            $parent = $parent ? 'WHERE parent = \''.$db->escapeString($parent).'\' ' : 'WHERE parent = 0';
        }

        return $db->simpleStatementFetch('SELECT * FROM compta_comptes '.$parent.' ORDER BY id;');
    }

    protected function _checkFields(&$data, $force_parent_check = false)
    {
        $db = DB::getInstance();

        if (empty($data['libelle']) || !trim($data['libelle']))
        {
            throw new UserException('Le libellé ne peut rester vide.');
        }

        $data['libelle'] = trim($data['libelle']);

Modified include/class.compta_comptes_bancaires.php from [3dd0928cc5] to [49f15cf044].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

require_once GARRADIN_ROOT . '/include/class.compta_comptes.php';

class Garradin_Compta_Comptes_Bancaires extends Garradin_Compta_Comptes
{
    const NUMERO_PARENT_COMPTES = 512;

    public function add($data)
    {
        $db = Garradin_DB::getInstance();

        $data['parent'] = self::NUMERO_PARENT_COMPTES;
        $data['id'] = null;

        $this->_checkBankFields($data);

        $new_id = parent::add($data);

        $db = Garradin_DB::getInstance();
        $db->simpleInsert('compta_comptes_bancaires', array(
            'id'        =>  $new_id,
            'banque'    =>  $data['banque'],
            'iban'      =>  $data['iban'],
            'bic'       =>  $data['bic'],
        ));

        return $new_id;
    }

    public function edit($id, $data)
    {
        $db = Garradin_DB::getInstance();

        if (!$db->simpleQuerySingle('SELECT 1 FROM compta_comptes_bancaires WHERE id = ?;', false, $id))
        {
            throw new UserException('Ce compte n\'est pas un compte bancaire.');
        }

        $this->_checkBankFields($data);


|

|





|








|












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

namespace Garradin;

class Compta_Comptes_Bancaires extends Compta_Comptes
{
    const NUMERO_PARENT_COMPTES = 512;

    public function add($data)
    {
        $db = DB::getInstance();

        $data['parent'] = self::NUMERO_PARENT_COMPTES;
        $data['id'] = null;

        $this->_checkBankFields($data);

        $new_id = parent::add($data);

        $db = DB::getInstance();
        $db->simpleInsert('compta_comptes_bancaires', array(
            'id'        =>  $new_id,
            'banque'    =>  $data['banque'],
            'iban'      =>  $data['iban'],
            'bic'       =>  $data['bic'],
        ));

        return $new_id;
    }

    public function edit($id, $data)
    {
        $db = DB::getInstance();

        if (!$db->simpleQuerySingle('SELECT 1 FROM compta_comptes_bancaires WHERE id = ?;', false, $id))
        {
            throw new UserException('Ce compte n\'est pas un compte bancaire.');
        }

        $this->_checkBankFields($data);
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
        ), 'id = \''.$db->escapeString(trim($id)).'\'');

        return true;
    }

    public function delete($id)
    {
        $db = Garradin_DB::getInstance();
        if (!$db->simpleQuerySingle('SELECT 1 FROM compta_comptes_bancaires WHERE id = ?;', false, trim($id)))
        {
            throw new UserException('Ce compte n\'est pas un compte bancaire.');
        }

        $db->simpleExec('DELETE FROM compta_comptes_bancaires WHERE id = ?;', trim($id));
        $return = parent::delete($id);

        return $return;
    }

    public function get($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT * FROM compta_comptes AS c
            INNER JOIN compta_comptes_bancaires AS cc
            ON c.id = cc.id
            WHERE c.id = ?;', true, $id);
    }

    public function getList($parent = false)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleStatementFetchAssocKey('SELECT c.id AS id, * FROM compta_comptes AS c
            INNER JOIN compta_comptes_bancaires AS cc ON c.id = cc.id
            WHERE c.parent = '.self::NUMERO_PARENT_COMPTES.' ORDER BY c.id;');
    }

    protected function _checkBankFields(&$data)
    {







|













|








|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
        ), 'id = \''.$db->escapeString(trim($id)).'\'');

        return true;
    }

    public function delete($id)
    {
        $db = DB::getInstance();
        if (!$db->simpleQuerySingle('SELECT 1 FROM compta_comptes_bancaires WHERE id = ?;', false, trim($id)))
        {
            throw new UserException('Ce compte n\'est pas un compte bancaire.');
        }

        $db->simpleExec('DELETE FROM compta_comptes_bancaires WHERE id = ?;', trim($id));
        $return = parent::delete($id);

        return $return;
    }

    public function get($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT * FROM compta_comptes AS c
            INNER JOIN compta_comptes_bancaires AS cc
            ON c.id = cc.id
            WHERE c.id = ?;', true, $id);
    }

    public function getList($parent = false)
    {
        $db = DB::getInstance();
        return $db->simpleStatementFetchAssocKey('SELECT c.id AS id, * FROM compta_comptes AS c
            INNER JOIN compta_comptes_bancaires AS cc ON c.id = cc.id
            WHERE c.parent = '.self::NUMERO_PARENT_COMPTES.' ORDER BY c.id;');
    }

    protected function _checkBankFields(&$data)
    {

Modified include/class.compta_exercices.php from [14c90c6748] to [cee018764e].

1
2


3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php



class Garradin_Compta_Exercices
{
    public function add($data)
    {
        $this->_checkFields($data);

        $db = Garradin_DB::getInstance();

        if ($db->simpleQuerySingle('SELECT 1 FROM compta_exercices WHERE
            (debut <= :debut AND fin >= :debut) OR (debut <= :fin AND fin >= :fin);', false,
            array('debut' => $data['debut'], 'fin' => $data['fin'])))
        {
            throw new UserException('La date de début ou de fin se recoupe avec un autre exercice.');
        }


>
>
|





|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php

namespace Garradin;

class Compta_Exercices
{
    public function add($data)
    {
        $this->_checkFields($data);

        $db = DB::getInstance();

        if ($db->simpleQuerySingle('SELECT 1 FROM compta_exercices WHERE
            (debut <= :debut AND fin >= :debut) OR (debut <= :fin AND fin >= :fin);', false,
            array('debut' => $data['debut'], 'fin' => $data['fin'])))
        {
            throw new UserException('La date de début ou de fin se recoupe avec un autre exercice.');
        }
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
        ));

        return $db->lastInsertRowId();
    }

    public function edit($id, $data)
    {
        $db = Garradin_DB::getInstance();

        $this->_checkFields($data);

        // Evitons que les exercices se croisent
        if ($db->simpleQuerySingle('SELECT 1 FROM compta_exercices WHERE id != :id AND
            ((debut <= :debut AND fin >= :debut) OR (debut <= :fin AND fin >= :fin));', false,
            array('debut' => $data['debut'], 'fin' => $data['fin'], 'id' => (int) $id)))







|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
        ));

        return $db->lastInsertRowId();
    }

    public function edit($id, $data)
    {
        $db = DB::getInstance();

        $this->_checkFields($data);

        // Evitons que les exercices se croisent
        if ($db->simpleQuerySingle('SELECT 1 FROM compta_exercices WHERE id != :id AND
            ((debut <= :debut AND fin >= :debut) OR (debut <= :fin AND fin >= :fin));', false,
            array('debut' => $data['debut'], 'fin' => $data['fin'], 'id' => (int) $id)))
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
        ), 'id = \''.(int)$id.'\'');

        return true;
    }

    public function close($id)
    {
        $db = Garradin_DB::getInstance();

        $db->simpleUpdate('compta_exercices', array(
            'cloture'   =>  1,
        ), 'id = \''.(int)$id.'\'');

        return true;
    }

    public function delete($id)
    {
        $db = Garradin_DB::getInstance();

        // Ne pas supprimer un compte qui est utilisé !
        if ($db->simpleQuerySingle('SELECT 1 FROM compta_journal WHERE id_exercice = ? LIMIT 1;', false, $id))
        {
            throw new UserException('Cet exercice ne peut être supprimé car des opérations comptables y sont liées.');
        }

        $db->simpleExec('DELETE FROM compta_exercices WHERE id = ?;', (int)$id);

        return true;
    }

    public function get($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT *, strftime(\'%s\', debut) AS debut,
            strftime(\'%s\', fin) AS fin FROM compta_exercices WHERE id = ?;', true, (int)$id);
    }

    public function getCurrent()
    {
        $db = Garradin_DB::getInstance();
        return $db->querySingle('SELECT *, strftime(\'%s\', debut) AS debut, strftime(\'%s\', fin) FROM compta_exercices
            WHERE cloture = 0 LIMIT 1;', true);
    }

    public function getCurrentId()
    {
        $db = Garradin_DB::getInstance();
        return $db->querySingle('SELECT id FROM compta_exercices WHERE cloture = 0 LIMIT 1;');
    }

    public function getList()
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleStatementFetchAssocKey('SELECT id, *, strftime(\'%s\', debut) AS debut,
            strftime(\'%s\', fin) AS fin,
            (SELECT COUNT(*) FROM compta_journal WHERE id_exercice = compta_exercices.id) AS nb_operations
            FROM compta_exercices ORDER BY fin DESC;', SQLITE3_ASSOC);
    }

    protected function _checkFields(&$data)
    {
        $db = Garradin_DB::getInstance();

        if (empty($data['libelle']) || !trim($data['libelle']))
        {
            throw new UserException('Le libellé ne peut rester vide.');
        }

        $data['libelle'] = trim($data['libelle']);







|










|














|






|






|





|








|







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
        ), 'id = \''.(int)$id.'\'');

        return true;
    }

    public function close($id)
    {
        $db = DB::getInstance();

        $db->simpleUpdate('compta_exercices', array(
            'cloture'   =>  1,
        ), 'id = \''.(int)$id.'\'');

        return true;
    }

    public function delete($id)
    {
        $db = DB::getInstance();

        // Ne pas supprimer un compte qui est utilisé !
        if ($db->simpleQuerySingle('SELECT 1 FROM compta_journal WHERE id_exercice = ? LIMIT 1;', false, $id))
        {
            throw new UserException('Cet exercice ne peut être supprimé car des opérations comptables y sont liées.');
        }

        $db->simpleExec('DELETE FROM compta_exercices WHERE id = ?;', (int)$id);

        return true;
    }

    public function get($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT *, strftime(\'%s\', debut) AS debut,
            strftime(\'%s\', fin) AS fin FROM compta_exercices WHERE id = ?;', true, (int)$id);
    }

    public function getCurrent()
    {
        $db = DB::getInstance();
        return $db->querySingle('SELECT *, strftime(\'%s\', debut) AS debut, strftime(\'%s\', fin) FROM compta_exercices
            WHERE cloture = 0 LIMIT 1;', true);
    }

    public function getCurrentId()
    {
        $db = DB::getInstance();
        return $db->querySingle('SELECT id FROM compta_exercices WHERE cloture = 0 LIMIT 1;');
    }

    public function getList()
    {
        $db = DB::getInstance();
        return $db->simpleStatementFetchAssocKey('SELECT id, *, strftime(\'%s\', debut) AS debut,
            strftime(\'%s\', fin) AS fin,
            (SELECT COUNT(*) FROM compta_journal WHERE id_exercice = compta_exercices.id) AS nb_operations
            FROM compta_exercices ORDER BY fin DESC;', SQLITE3_ASSOC);
    }

    protected function _checkFields(&$data)
    {
        $db = DB::getInstance();

        if (empty($data['libelle']) || !trim($data['libelle']))
        {
            throw new UserException('Le libellé ne peut rester vide.');
        }

        $data['libelle'] = trim($data['libelle']);
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165

        return true;
    }


    public function getJournal($exercice)
    {
        $db = Garradin_DB::getInstance();
        $query = 'SELECT *, strftime(\'%s\', date) AS date FROM compta_journal
            WHERE id_exercice = '.(int)$exercice.' ORDER BY date, id;';
        return $db->simpleStatementFetch($query);
    }

    public function getGrandLivre($exercice)
    {
        $db = Garradin_DB::getInstance();
        $livre = array('classes' => array(), 'debit' => 0.0, 'credit' => 0.0);

        $res = $db->prepare('SELECT compte FROM
            (SELECT compte_debit AS compte FROM compta_journal
                    WHERE id_exercice = '.(int)$exercice.' GROUP BY compte_debit
                UNION
                SELECT compte_credit AS compte FROM compta_journal







|







|







145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167

        return true;
    }


    public function getJournal($exercice)
    {
        $db = DB::getInstance();
        $query = 'SELECT *, strftime(\'%s\', date) AS date FROM compta_journal
            WHERE id_exercice = '.(int)$exercice.' ORDER BY date, id;';
        return $db->simpleStatementFetch($query);
    }

    public function getGrandLivre($exercice)
    {
        $db = DB::getInstance();
        $livre = array('classes' => array(), 'debit' => 0.0, 'credit' => 0.0);

        $res = $db->prepare('SELECT compte FROM
            (SELECT compte_debit AS compte FROM compta_journal
                    WHERE id_exercice = '.(int)$exercice.' GROUP BY compte_debit
                UNION
                SELECT compte_credit AS compte FROM compta_journal
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
        $res->finalize();

        return $livre;
    }

    public function getCompteResultat($exercice)
    {
        $db = Garradin_DB::getInstance();

        $charges    = array('comptes' => array(), 'total' => 0.0);
        $produits   = array('comptes' => array(), 'total' => 0.0);
        $resultat   = 0.0;

        $res = $db->prepare('SELECT compte, debit, credit
            FROM







|







219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
        $res->finalize();

        return $livre;
    }

    public function getCompteResultat($exercice)
    {
        $db = DB::getInstance();

        $charges    = array('comptes' => array(), 'total' => 0.0);
        $produits   = array('comptes' => array(), 'total' => 0.0);
        $resultat   = 0.0;

        $res = $db->prepare('SELECT compte, debit, credit
            FROM
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
        $resultat = $produits['total'] - $charges['total'];

        return array('charges' => $charges, 'produits' => $produits, 'resultat' => $resultat);
    }

    public function getBilan($exercice)
    {
        $db = Garradin_DB::getInstance();

        require_once GARRADIN_ROOT . '/include/class.compta_comptes.php';
        $include = array(Garradin_Compta_Comptes::ACTIF, Garradin_Compta_Comptes::PASSIF,
            Garradin_Compta_Comptes::PASSIF | Garradin_Compta_Comptes::ACTIF);

        $actif      = array('comptes' => array(), 'total' => 0.0);
        $passif     = array('comptes' => array(), 'total' => 0.0);

        $resultat = $this->getCompteResultat($exercice);

        if ($resultat['resultat'] > 0)







|

<
|
|







279
280
281
282
283
284
285
286
287

288
289
290
291
292
293
294
295
296
        $resultat = $produits['total'] - $charges['total'];

        return array('charges' => $charges, 'produits' => $produits, 'resultat' => $resultat);
    }

    public function getBilan($exercice)
    {
        $db = DB::getInstance();


        $include = array(Compta_Comptes::ACTIF, Compta_Comptes::PASSIF,
            Compta_Comptes::PASSIF | Compta_Comptes::ACTIF);

        $actif      = array('comptes' => array(), 'total' => 0.0);
        $passif     = array('comptes' => array(), 'total' => 0.0);

        $resultat = $this->getCompteResultat($exercice);

        if ($resultat['resultat'] > 0)
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
            )->execute();

        while ($row = $res->fetchArray(SQLITE3_NUM))
        {
            list($compte, $debit, $credit, $position) = $row;
            $parent = substr($compte, 0, 2);

            if ($position & Garradin_Compta_Comptes::ACTIF)
            {
                if (!isset($actif['comptes'][$parent]))
                {
                    $actif['comptes'][$parent] = array('comptes' => array(), 'solde' => 0.0);
                }

                $solde = $debit - $credit;

                if (!isset($actif['comptes'][$parent]['comptes'][$compte]))
                {
                    $actif['comptes'][$parent]['comptes'][$compte] = 0.0;
                }

                $actif['comptes'][$parent]['comptes'][$compte] += $solde;
                $actif['total'] += $solde;
                $actif['comptes'][$parent]['solde'] += $solde;
            }

            if ($position & Garradin_Compta_Comptes::PASSIF)
            {
                if (!isset($passif['comptes'][$parent]))
                {
                    $passif['comptes'][$parent] = array('comptes' => array(), 'solde' => 0.0);
                }

                $solde = $credit - $debit;







|


















|







326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
            )->execute();

        while ($row = $res->fetchArray(SQLITE3_NUM))
        {
            list($compte, $debit, $credit, $position) = $row;
            $parent = substr($compte, 0, 2);

            if ($position & Compta_Comptes::ACTIF)
            {
                if (!isset($actif['comptes'][$parent]))
                {
                    $actif['comptes'][$parent] = array('comptes' => array(), 'solde' => 0.0);
                }

                $solde = $debit - $credit;

                if (!isset($actif['comptes'][$parent]['comptes'][$compte]))
                {
                    $actif['comptes'][$parent]['comptes'][$compte] = 0.0;
                }

                $actif['comptes'][$parent]['comptes'][$compte] += $solde;
                $actif['total'] += $solde;
                $actif['comptes'][$parent]['solde'] += $solde;
            }

            if ($position & Compta_Comptes::PASSIF)
            {
                if (!isset($passif['comptes'][$parent]))
                {
                    $passif['comptes'][$parent] = array('comptes' => array(), 'solde' => 0.0);
                }

                $solde = $credit - $debit;

Modified include/class.compta_import.php from [37a7b88d36] to [d5f3d8c89a].

1
2


3
4
5
6
7
8
9
10
11
12
13
14
<?php



class Garradin_Compta_Import
{
	public function toCSV($exercice)
	{
		$db = Garradin_DB::getInstance();

		$header = array(
			'Numéro mouvement',
			'Date',
			'Type de mouvement',
			'Catégorie',
			'Libellé',


>
>
|



|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php

namespace Garradin;

class Compta_Import
{
	public function toCSV($exercice)
	{
		$db = DB::getInstance();

		$header = array(
			'Numéro mouvement',
			'Date',
			'Type de mouvement',
			'Catégorie',
			'Libellé',
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
		$fp = fopen($path, 'r');

		if (!$fp)
		{
			return false;
		}

		require_once GARRADIN_ROOT . '/include/class.compta_comptes.php';
		require_once GARRADIN_ROOT . '/include/class.compta_comptes_bancaires.php';
		require_once GARRADIN_ROOT . '/include/class.compta_categories.php';
		require_once GARRADIN_ROOT . '/include/class.compta_journal.php';

		$db = Garradin_DB::getInstance();
		$db->exec('BEGIN;');
		$comptes = new Garradin_Compta_Comptes;
		$banques = new Garradin_Compta_Comptes_Bancaires;
		$cats = new Garradin_Compta_Categories;
		$journal = new Garradin_Compta_Journal;

		$columns = array();
		$liste_comptes = $db->simpleStatementFetchAssoc('SELECT id, id FROM compta_comptes;');
		$liste_cats = $db->simpleStatementFetchAssoc('SELECT intitule, id FROM compta_categories;');
		$liste_moyens = $cats->listMoyensPaiement();

		$get_compte = function ($compte, $intitule) use (&$liste_comptes, &$comptes, &$banques)







<
<
<
<
<
|

|
|
|
|







73
74
75
76
77
78
79





80
81
82
83
84
85
86
87
88
89
90
91
92
		$fp = fopen($path, 'r');

		if (!$fp)
		{
			return false;
		}






		$db = DB::getInstance();
		$db->exec('BEGIN;');
		$comptes = new Compta_Comptes;
		$banques = new Compta_Comptes_Bancaires;
		$cats = new Compta_Categories;
		$journal = new Compta_Journal;

		$columns = array();
		$liste_comptes = $db->simpleStatementFetchAssoc('SELECT id, id FROM compta_comptes;');
		$liste_cats = $db->simpleStatementFetchAssoc('SELECT intitule, id FROM compta_categories;');
		$liste_moyens = $cats->listMoyensPaiement();

		$get_compte = function ($compte, $intitule) use (&$liste_comptes, &$comptes, &$banques)

Modified include/class.compta_journal.php from [02840b2d4d] to [1e8df8be47].

1
2


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php



class Garradin_Compta_Journal
{
    protected function _getCurrentExercice()
    {
        $db = Garradin_DB::getInstance();
        $id = $db->querySingle('SELECT id FROM compta_exercices WHERE cloture = 0 LIMIT 1;');

        if (!$id)
        {
            throw new UserException('Aucun exercice en cours.');
        }

        return $id;
    }

    public function checkExercice()
    {
        return $this->_getCurrentExercice();
    }

    protected function _checkOpenExercice($id)
    {
        if (is_null($id))
            return true;

        $db = Garradin_DB::getInstance();
        $id = $db->simpleQuerySingle('SELECT id FROM compta_exercices
            WHERE cloture = 0 AND id = ? LIMIT 1;', false, (int)$id);

        if ($id)
            return true;

        return false;
    }

    public function getSolde($id_compte, $inclure_sous_comptes = false)
    {
        $db = Garradin_DB::getInstance();
        $exercice = $this->_getCurrentExercice();
        $compte = $inclure_sous_comptes
            ? 'LIKE \'' . $db->escapeString(trim($id_compte)) . '%\''
            : '= \'' . $db->escapeString(trim($id_compte)) . '\'';

        $debit = 'COALESCE((SELECT SUM(montant) FROM compta_journal WHERE compte_debit '.$compte.' AND id_exercice = '.(int)$exercice.'), 0)';
        $credit = 'COALESCE((SELECT SUM(montant) FROM compta_journal WHERE compte_credit '.$compte.' AND id_exercice = '.(int)$exercice.'), 0)';

        // L'actif augmente au débit, le passif au crédit
        require_once GARRADIN_ROOT . '/include/class.compta_comptes.php';
        $position = $db->simpleQuerySingle('SELECT position FROM compta_comptes WHERE id = ?;', false, $id_compte);

        if (($position & Garradin_Compta_Comptes::ACTIF) || ($position & Garradin_Compta_Comptes::CHARGE))
        {
            $query = $debit . ' - ' . $credit;
        }
        else
        {
            $query = $credit . ' - ' . $debit;
        }

        return $db->querySingle('SELECT ' . $query . ';');
    }

    public function getJournalCompte($compte, $inclure_sous_comptes = false)
    {
        $db = Garradin_DB::getInstance();

        require_once GARRADIN_ROOT . '/include/class.compta_comptes.php';
        $position = $db->simpleQuerySingle('SELECT position FROM compta_comptes WHERE id = ?;', false, $compte);

        $exercice = $this->_getCurrentExercice();
        $compte = $inclure_sous_comptes
            ? 'LIKE \'' . $db->escapeString(trim($compte)) . '%\''
            : '= \'' . $db->escapeString(trim($compte)) . '\'';

        // L'actif et les charges augmentent au débit, le passif et les produits au crédit
        if (($position & Garradin_Compta_Comptes::ACTIF) || ($position & Garradin_Compta_Comptes::CHARGE))
        {
            $d = '';
            $c = '-';
        }
        else
        {
            $d = '-';


>
>
|



|




















|











|









<


|













|

<








|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php

namespace Garradin;

class Compta_Journal
{
    protected function _getCurrentExercice()
    {
        $db = DB::getInstance();
        $id = $db->querySingle('SELECT id FROM compta_exercices WHERE cloture = 0 LIMIT 1;');

        if (!$id)
        {
            throw new UserException('Aucun exercice en cours.');
        }

        return $id;
    }

    public function checkExercice()
    {
        return $this->_getCurrentExercice();
    }

    protected function _checkOpenExercice($id)
    {
        if (is_null($id))
            return true;

        $db = DB::getInstance();
        $id = $db->simpleQuerySingle('SELECT id FROM compta_exercices
            WHERE cloture = 0 AND id = ? LIMIT 1;', false, (int)$id);

        if ($id)
            return true;

        return false;
    }

    public function getSolde($id_compte, $inclure_sous_comptes = false)
    {
        $db = DB::getInstance();
        $exercice = $this->_getCurrentExercice();
        $compte = $inclure_sous_comptes
            ? 'LIKE \'' . $db->escapeString(trim($id_compte)) . '%\''
            : '= \'' . $db->escapeString(trim($id_compte)) . '\'';

        $debit = 'COALESCE((SELECT SUM(montant) FROM compta_journal WHERE compte_debit '.$compte.' AND id_exercice = '.(int)$exercice.'), 0)';
        $credit = 'COALESCE((SELECT SUM(montant) FROM compta_journal WHERE compte_credit '.$compte.' AND id_exercice = '.(int)$exercice.'), 0)';

        // L'actif augmente au débit, le passif au crédit

        $position = $db->simpleQuerySingle('SELECT position FROM compta_comptes WHERE id = ?;', false, $id_compte);

        if (($position & Compta_Comptes::ACTIF) || ($position & Compta_Comptes::CHARGE))
        {
            $query = $debit . ' - ' . $credit;
        }
        else
        {
            $query = $credit . ' - ' . $debit;
        }

        return $db->querySingle('SELECT ' . $query . ';');
    }

    public function getJournalCompte($compte, $inclure_sous_comptes = false)
    {
        $db = DB::getInstance();


        $position = $db->simpleQuerySingle('SELECT position FROM compta_comptes WHERE id = ?;', false, $compte);

        $exercice = $this->_getCurrentExercice();
        $compte = $inclure_sous_comptes
            ? 'LIKE \'' . $db->escapeString(trim($compte)) . '%\''
            : '= \'' . $db->escapeString(trim($compte)) . '\'';

        // L'actif et les charges augmentent au débit, le passif et les produits au crédit
        if (($position & Compta_Comptes::ACTIF) || ($position & Compta_Comptes::CHARGE))
        {
            $d = '';
            $c = '-';
        }
        else
        {
            $d = '-';
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
160
161
162
163
164
165
        return $db->simpleStatementFetch($query);
    }

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

        $db = Garradin_DB::getInstance();

        $data['id_exercice'] = $this->_getCurrentExercice();

        $db->simpleInsert('compta_journal', $data);
        $id = $db->lastInsertRowId();

        return $id;
    }

    public function edit($id, $data)
    {
        $db = Garradin_DB::getInstance();

        // Vérification que l'on peut éditer cette opération
        if (!$this->_checkOpenExercice($db->simpleQuerySingle('SELECT id_exercice FROM compta_journal WHERE id = ?;', false, $id)))
        {
            throw new UserException('Cette opération fait partie d\'un exercice qui a été clôturé.');
        }

        $this->_checkFields($data);

        $db->simpleUpdate('compta_journal', $data,
            'id = \''.trim($id).'\'');

        return true;
    }

    public function delete($id)
    {
        $db = Garradin_DB::getInstance();

        // Vérification que l'on peut éditer cette opération
        if (!$this->_checkOpenExercice($db->simpleQuerySingle('SELECT id_exercice FROM compta_journal WHERE id = ?;', false, $id)))
        {
            throw new UserException('Cette opération fait partie d\'un exercice qui a été clôturé.');
        }

        $db->simpleExec('DELETE FROM compta_journal WHERE id = ?;', (int)$id);

        return true;
    }

    public function get($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT *, strftime(\'%s\', date) AS date FROM compta_journal WHERE id = ?;', true, $id);
    }

    protected function _checkFields(&$data)
    {
        $db = Garradin_DB::getInstance();

        if (empty($data['libelle']) || !trim($data['libelle']))
        {
            throw new UserException('Le libellé ne peut rester vide.');
        }

        $data['libelle'] = trim($data['libelle']);







|











|

















|














|





|







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
160
161
162
163
164
165
        return $db->simpleStatementFetch($query);
    }

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

        $db = DB::getInstance();

        $data['id_exercice'] = $this->_getCurrentExercice();

        $db->simpleInsert('compta_journal', $data);
        $id = $db->lastInsertRowId();

        return $id;
    }

    public function edit($id, $data)
    {
        $db = DB::getInstance();

        // Vérification que l'on peut éditer cette opération
        if (!$this->_checkOpenExercice($db->simpleQuerySingle('SELECT id_exercice FROM compta_journal WHERE id = ?;', false, $id)))
        {
            throw new UserException('Cette opération fait partie d\'un exercice qui a été clôturé.');
        }

        $this->_checkFields($data);

        $db->simpleUpdate('compta_journal', $data,
            'id = \''.trim($id).'\'');

        return true;
    }

    public function delete($id)
    {
        $db = DB::getInstance();

        // Vérification que l'on peut éditer cette opération
        if (!$this->_checkOpenExercice($db->simpleQuerySingle('SELECT id_exercice FROM compta_journal WHERE id = ?;', false, $id)))
        {
            throw new UserException('Cette opération fait partie d\'un exercice qui a été clôturé.');
        }

        $db->simpleExec('DELETE FROM compta_journal WHERE id = ?;', (int)$id);

        return true;
    }

    public function get($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT *, strftime(\'%s\', date) AS date FROM compta_journal WHERE id = ?;', true, $id);
    }

    protected function _checkFields(&$data)
    {
        $db = DB::getInstance();

        if (empty($data['libelle']) || !trim($data['libelle']))
        {
            throw new UserException('Le libellé ne peut rester vide.');
        }

        $data['libelle'] = trim($data['libelle']);
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
        }

        return true;
    }

    public function getListForCategory($type = null, $cat = null)
    {
        $db = Garradin_DB::getInstance();
        $exercice = $this->_getCurrentExercice();

        $query = 'SELECT compta_journal.*, strftime(\'%s\', compta_journal.date) AS date ';

        if (is_null($cat) && !is_null($type))
        {
            $query.= ', compta_categories.intitule AS categorie







|







251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
        }

        return true;
    }

    public function getListForCategory($type = null, $cat = null)
    {
        $db = DB::getInstance();
        $exercice = $this->_getCurrentExercice();

        $query = 'SELECT compta_journal.*, strftime(\'%s\', compta_journal.date) AS date ';

        if (is_null($cat) && !is_null($type))
        {
            $query.= ', compta_categories.intitule AS categorie

Modified include/class.compta_stats.php from [72fec75275] to [dd09198417].

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

require_once __DIR__ . '/class.compta_comptes.php';

class Garradin_Compta_Stats
{
	protected function _byType($type)
	{
		return $this->getStats('SELECT strftime(\'%Y%m\', date) AS date,
			SUM(montant) FROM compta_journal
			WHERE id_categorie IN (SELECT id FROM compta_categories WHERE type = '.$type.')
			AND id_exercice = (SELECT id FROM compta_exercices WHERE cloture = 0)


|

|







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

namespace Garradin;

class Compta_Stats
{
	protected function _byType($type)
	{
		return $this->getStats('SELECT strftime(\'%Y%m\', date) AS date,
			SUM(montant) FROM compta_journal
			WHERE id_categorie IN (SELECT id FROM compta_categories WHERE type = '.$type.')
			AND id_exercice = (SELECT id FROM compta_exercices WHERE cloture = 0)
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
	public function depenses()
	{
		return $this->_byType(1);
	}

	public function soldeCompte($compte, $augmente = 'debit', $diminue = 'credit')
	{
		$db = Garradin_DB::getInstance();

		if (strpos($compte, '%') !== false)
		{
			$compte = 'LIKE \''. $db->escapeString($compte) . '\'';
		}
		else
		{







|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
	public function depenses()
	{
		return $this->_byType(1);
	}

	public function soldeCompte($compte, $augmente = 'debit', $diminue = 'credit')
	{
		$db = DB::getInstance();

		if (strpos($compte, '%') !== false)
		{
			$compte = 'LIKE \''. $db->escapeString($compte) . '\'';
		}
		else
		{
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
		}

		return $stats;
	}

	public function getStats($query)
	{
		$db = Garradin_DB::getInstance();

		$data = $db->simpleStatementFetchAssoc($query);

		$e = $db->querySingle('SELECT *, strftime(\'%s\', debut) AS debut,
			strftime(\'%s\', fin) AS fin FROM compta_exercices WHERE cloture = 0;', true);

		$y = date('Y', $e['debut']);







|







59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
		}

		return $stats;
	}

	public function getStats($query)
	{
		$db = DB::getInstance();

		$data = $db->simpleStatementFetchAssoc($query);

		$e = $db->querySingle('SELECT *, strftime(\'%s\', debut) AS debut,
			strftime(\'%s\', fin) AS fin FROM compta_exercices WHERE cloture = 0;', true);

		$y = date('Y', $e['debut']);

Modified include/class.config.php from [b47f7a7c8d] to [55a84f4045].

1
2
3


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php

class Garradin_Config


{
    protected $fields_types = null;
    protected $config = null;
    protected $modified = array();

    protected $allowed_fields_membres = array('nom', 'passe', 'email', 'adresse', 'code_postal',
        'ville', 'pays', 'telephone', 'date_naissance', 'notes');

    static protected $_instance = null;

    static public function getInstance()
    {
        return self::$_instance ?: self::$_instance = new Garradin_Config;
    }

    private function __clone()
    {
    }

    protected function __construct()


|
>
>












|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

namespace Garradin;

class Config
{
    protected $fields_types = null;
    protected $config = null;
    protected $modified = array();

    protected $allowed_fields_membres = array('nom', 'passe', 'email', 'adresse', 'code_postal',
        'ville', 'pays', 'telephone', 'date_naissance', 'notes');

    static protected $_instance = null;

    static public function getInstance()
    {
        return self::$_instance ?: self::$_instance = new Config;
    }

    private function __clone()
    {
    }

    protected function __construct()
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
            'champs_modifiables_membre' =>  $array,

            'accueil_wiki'          =>  $string,

            'version'               =>  $string,
        );

        $db = Garradin_DB::getInstance();

        $this->config = $db->simpleStatementFetchAssoc('SELECT cle, valeur FROM config ORDER BY cle;');

        foreach ($this->config as $key=>&$value)
        {
            if (!array_key_exists($key, $this->fields_types))
            {







|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
            'champs_modifiables_membre' =>  $array,

            'accueil_wiki'          =>  $string,

            'version'               =>  $string,
        );

        $db = DB::getInstance();

        $this->config = $db->simpleStatementFetchAssoc('SELECT cle, valeur FROM config ORDER BY cle;');

        foreach ($this->config as $key=>&$value)
        {
            if (!array_key_exists($key, $this->fields_types))
            {
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
    public function save()
    {
        if (empty($this->modified))
            return true;

        $values = array();

        $db = Garradin_DB::getInstance();
        $db->exec('BEGIN;');

        foreach ($this->modified as $key=>$modified)
        {
            $value = $this->config[$key];

            if (is_array($value))







|







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    public function save()
    {
        if (empty($this->modified))
            return true;

        $values = array();

        $db = DB::getInstance();
        $db->exec('BEGIN;');

        foreach ($this->modified as $key=>$modified)
        {
            $value = $this->config[$key];

            if (is_array($value))
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
        return $this->config['version'];
    }

    public function setVersion($version)
    {
        $this->config['version'] = $version;

        $db = Garradin_DB::getInstance();
        $db->simpleExec('INSERT OR REPLACE INTO config (cle, valeur) VALUES (?, ?);',
                'version', $version);

        return true;
    }

    public function set($key, $value)







|







134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
        return $this->config['version'];
    }

    public function setVersion($version)
    {
        $this->config['version'] = $version;

        $db = DB::getInstance();
        $db->simpleExec('INSERT OR REPLACE INTO config (cle, valeur) VALUES (?, ?);',
                'version', $version);

        return true;
    }

    public function set($key, $value)
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
                }
                break;
            }
            case 'categorie_cotisations':
            case 'categorie_dons':
            {
                return false;
                $db = Garradin_DB::getInstance();
                if (!$db->simpleQuerySingle('SELECT 1 FROM compta_categories WHERE id = ?;', false, $value))
                {
                    throw new UserException('Champ '.$key.' : La catégorie comptable numéro \''.$value.'\' ne semble pas exister.');
                }
                break;
            }
            case 'categorie_membres':
            {
                $db = Garradin_DB::getInstance();
                if (!$db->simpleQuerySingle('SELECT 1 FROM membres_categories WHERE id = ?;', false, $value))
                {
                    throw new UserException('La catégorie de membres par défaut numéro \''.$value.'\' ne semble pas exister.');
                }
                break;
            }
            case 'monnaie':







|








|







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
                }
                break;
            }
            case 'categorie_cotisations':
            case 'categorie_dons':
            {
                return false;
                $db = DB::getInstance();
                if (!$db->simpleQuerySingle('SELECT 1 FROM compta_categories WHERE id = ?;', false, $value))
                {
                    throw new UserException('Champ '.$key.' : La catégorie comptable numéro \''.$value.'\' ne semble pas exister.');
                }
                break;
            }
            case 'categorie_membres':
            {
                $db = DB::getInstance();
                if (!$db->simpleQuerySingle('SELECT 1 FROM membres_categories WHERE id = ?;', false, $value))
                {
                    throw new UserException('La catégorie de membres par défaut numéro \''.$value.'\' ne semble pas exister.');
                }
                break;
            }
            case 'monnaie':

Modified include/class.db.php from [a844357902] to [92c22689a2].

1


2
3
4
5
6
7
8
<?php



function str_replace_first ($search, $replace, $subject)
{
    $pos = strpos($subject, $search);

    if ($pos !== false)
    {

>
>







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

namespace Garradin;

function str_replace_first ($search, $replace, $subject)
{
    $pos = strpos($subject, $search);

    if ($pos !== false)
    {
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

    public function __toString()
    {
        return $this->instruction;
    }
}

class Garradin_DB extends SQLite3
{
    static protected $_instance = null;

    protected $_running_sum = 0.0;

    static public function getInstance()
    {
        return self::$_instance ?: self::$_instance = new Garradin_DB;
    }

    private function __clone()
    {
    }

    public function __construct()







|







|







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

    public function __toString()
    {
        return $this->instruction;
    }
}

class DB extends \SQLite3
{
    static protected $_instance = null;

    protected $_running_sum = 0.0;

    static public function getInstance()
    {
        return self::$_instance ?: self::$_instance = new DB;
    }

    private function __clone()
    {
    }

    public function __construct()
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
        if (!$exists)
        {
            $this->exec('BEGIN;');
            $this->exec(file_get_contents(GARRADIN_DB_SCHEMA));
            $this->exec('END;');
        }

        $this->createFunction('transliterate_to_ascii', array('utils', 'transliterateToAscii'));
        $this->createFunction('base64', 'base64_encode');
        $this->createFunction('rank', array($this, 'sql_rank'));
        $this->createFunction('running_sum', array($this, 'sql_running_sum'));
    }

    public function sql_running_sum($data)
    {







|







58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
        if (!$exists)
        {
            $this->exec('BEGIN;');
            $this->exec(file_get_contents(GARRADIN_DB_SCHEMA));
            $this->exec('END;');
        }

        $this->createFunction('transliterate_to_ascii', array('Garradin\utils', 'transliterateToAscii'));
        $this->createFunction('base64', 'base64_encode');
        $this->createFunction('rank', array($this, 'sql_rank'));
        $this->createFunction('running_sum', array($this, 'sql_running_sum'));
    }

    public function sql_running_sum($data)
    {

Modified include/class.membres.php from [969e79b4e4] to [9a3079c5de].

1
2
3


4
5
6
7
8
9
10
<?php

class Garradin_Membres


{
    const DROIT_AUCUN = 0;
    const DROIT_ACCES = 1;
    const DROIT_ECRITURE = 2;
    const DROIT_ADMIN = 9;

    const ITEMS_PER_PAGE = 50;


|
>
>







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

namespace Garradin;

class Membres
{
    const DROIT_AUCUN = 0;
    const DROIT_ACCES = 1;
    const DROIT_ECRITURE = 2;
    const DROIT_ADMIN = 9;

    const ITEMS_PER_PAGE = 50;
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
    }

    public function login($email, $passe)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
            return false;

        $db = Garradin_DB::getInstance();
        $r = $db->simpleQuerySingle('SELECT *,
            strftime(\'%s\', date_connexion) AS date_connexion,
            strftime(\'%s\', date_inscription) AS date_inscription,
            strftime(\'%s\', date_cotisation) AS date_cotisation
            FROM membres WHERE email = ? LIMIT 1;', true, trim($email));

        if (empty($r))







|







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
    }

    public function login($email, $passe)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
            return false;

        $db = DB::getInstance();
        $r = $db->simpleQuerySingle('SELECT *,
            strftime(\'%s\', date_connexion) AS date_connexion,
            strftime(\'%s\', date_inscription) AS date_inscription,
            strftime(\'%s\', date_cotisation) AS date_cotisation
            FROM membres WHERE email = ? LIMIT 1;', true, trim($email));

        if (empty($r))
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
    }

    public function recoverPasswordCheck($email)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
            return false;

        $db = Garradin_DB::getInstance();

        $id = $db->simpleQuerySingle('SELECT id FROM membres WHERE email = ? LIMIT 1;', false, trim($email));

        if (!$id)
        {
            return false;
        }

        $config = Garradin_Config::getInstance();

        $dest = trim($email);

        $this->_sessionStart(true);
        $hash = sha1($dest . $id . 'recover' . GARRADIN_ROOT . time());
        $_SESSION['recover_password'] = array('id' => (int) $id, 'email' => $dest, 'hash' => $hash);








|








|







89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
    }

    public function recoverPasswordCheck($email)
    {
        if (!filter_var($email, FILTER_VALIDATE_EMAIL))
            return false;

        $db = DB::getInstance();

        $id = $db->simpleQuerySingle('SELECT id FROM membres WHERE email = ? LIMIT 1;', false, trim($email));

        if (!$id)
        {
            return false;
        }

        $config = Config::getInstance();

        $dest = trim($email);

        $this->_sessionStart(true);
        $hash = sha1($dest . $id . 'recover' . GARRADIN_ROOT . time());
        $_SESSION['recover_password'] = array('id' => (int) $id, 'email' => $dest, 'hash' => $hash);

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

        if (empty($_SESSION['recover_password']['hash']))
            return false;

        if (substr($_SESSION['recover_password']['hash'], -10) != $hash)
            return false;

        $config = Garradin_Config::getInstance();
        $db = Garradin_DB::getInstance();

        $password = utils::suggestPassword();

        $dest = $_SESSION['recover_password']['email'];
        $id = (int)$_SESSION['recover_password']['id'];

        $message = "Bonjour,\n\nVous avez demandé un nouveau mot de passe pour votre compte.\n\n";







|
|







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

        if (empty($_SESSION['recover_password']['hash']))
            return false;

        if (substr($_SESSION['recover_password']['hash'], -10) != $hash)
            return false;

        $config = Config::getInstance();
        $db = DB::getInstance();

        $password = utils::suggestPassword();

        $dest = $_SESSION['recover_password']['email'];
        $id = (int)$_SESSION['recover_password']['id'];

        $message = "Bonjour,\n\nVous avez demandé un nouveau mot de passe pour votre compte.\n\n";
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
        }

        $from = $this->getLoggedUser();
        $from = $from['email'];
        // Uniquement adresse email pour le moment car faudrait trouver comment
        // indiquer le nom mais qu'il soit correctement échappé FIXME

        $config = Garradin_Config::getInstance();

        $message .= "\n\n--\nCe message a été envoyé par un membre de ".$config->get('nom_asso');
        $message .= ", merci de contacter ".$config->get('email_asso')." en cas d'abus.";

        if ($copie)
        {
            utils::mail($from, $sujet, $message);







|







214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
        }

        $from = $this->getLoggedUser();
        $from = $from['email'];
        // Uniquement adresse email pour le moment car faudrait trouver comment
        // indiquer le nom mais qu'il soit correctement échappé FIXME

        $config = Config::getInstance();

        $message .= "\n\n--\nCe message a été envoyé par un membre de ".$config->get('nom_asso');
        $message .= ", merci de contacter ".$config->get('email_asso')." en cas d'abus.";

        if ($copie)
        {
            utils::mail($from, $sujet, $message);
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
        if (isset($data['nom']) && !trim($data['nom']))
        {
            throw new UserException('Le champ prénom et nom ne peut rester vide.');
        }

        if ($check_mandatory)
        {
            $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.');
                }







|







238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
        if (isset($data['nom']) && !trim($data['nom']))
        {
            throw new UserException('Le champ prénom et nom ne peut rester vide.');
        }

        if ($check_mandatory)
        {
            $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.');
                }
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323

        return true;
    }

    public function add($data = array())
    {
        $this->_checkFields($data);
        $db = Garradin_DB::getInstance();

        if (!empty($data['email'])
            && $db->simpleQuerySingle('SELECT 1 FROM membres WHERE email = ? LIMIT 1;', false, $data['email']))
        {
            throw new UserException('Cette adresse e-mail est déjà utilisée par un autre membre, il faut en choisir une autre.');
        }

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

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

        $db->simpleInsert('membres', $data);
        return $db->lastInsertRowId();
    }

    public function edit($id, $data = array(), $check_mandatory = true)
    {
        $db = Garradin_DB::getInstance();

        if (isset($data['id']) && ($data['id'] == $id || empty($data['id'])))
        {
            unset($data['id']);
        }

        $this->_checkFields($data, $check_mandatory);







|


















|








|







283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325

        return true;
    }

    public function add($data = array())
    {
        $this->_checkFields($data);
        $db = DB::getInstance();

        if (!empty($data['email'])
            && $db->simpleQuerySingle('SELECT 1 FROM membres WHERE email = ? LIMIT 1;', false, $data['email']))
        {
            throw new UserException('Cette adresse e-mail est déjà utilisée par un autre membre, il faut en choisir une autre.');
        }

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

        if (empty($data['id_categorie']))
        {
            $data['id_categorie'] = Config::getInstance()->get('categorie_membres');
        }

        $db->simpleInsert('membres', $data);
        return $db->lastInsertRowId();
    }

    public function edit($id, $data = array(), $check_mandatory = true)
    {
        $db = DB::getInstance();

        if (isset($data['id']) && ($data['id'] == $id || empty($data['id'])))
        {
            unset($data['id']);
        }

        $this->_checkFields($data, $check_mandatory);
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
        else
        {
            unset($data['passe']);
        }

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

        $db->simpleUpdate('membres', $data, 'id = '.(int)$id);
    }

    public function get($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT *,
            strftime(\'%s\', date_connexion) AS date_connexion,
            strftime(\'%s\', date_inscription) AS date_inscription,
            strftime(\'%s\', date_cotisation) AS date_cotisation
            FROM membres WHERE id = ? LIMIT 1;', true, (int)$id);
    }








|







|







355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
        else
        {
            unset($data['passe']);
        }

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

        $db->simpleUpdate('membres', $data, 'id = '.(int)$id);
    }

    public function get($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT *,
            strftime(\'%s\', date_connexion) AS date_connexion,
            strftime(\'%s\', date_inscription) AS date_inscription,
            strftime(\'%s\', date_cotisation) AS date_cotisation
            FROM membres WHERE id = ? LIMIT 1;', true, (int)$id);
    }

394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
        }

        return self::_deleteMembres($ids);
    }

    public function getNom($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT nom FROM membres WHERE id = ? LIMIT 1;', false, (int)$id);
    }

    public function getDroits($id)
    {
        $db = Garradin_DB::getInstance();
        $droits = $db->simpleQuerySingle('SELECT * FROM membres_categories WHERE id = ?;', true, (int)$id);

        foreach ($droits as $key=>$value)
        {
            unset($droits[$key]);
            $key = str_replace('droit_', '', $key, $found);

            if ($found)
            {
                $droits[$key] = (int) $value;
            }
        }

        return $droits;
    }

    public function search($field = null, $query)
    {
        $db = Garradin_DB::getInstance();

        if (is_null($field) || !in_array($field, array('id', 'nom', 'email', 'code_postal', 'ville', 'adresse', 'telephone')))
        {
            $field = 'nom';
        }

        if ($field == 'id' || $field == 'code_postal')







|





|


















|







396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
        }

        return self::_deleteMembres($ids);
    }

    public function getNom($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT nom FROM membres WHERE id = ? LIMIT 1;', false, (int)$id);
    }

    public function getDroits($id)
    {
        $db = DB::getInstance();
        $droits = $db->simpleQuerySingle('SELECT * FROM membres_categories WHERE id = ?;', true, (int)$id);

        foreach ($droits as $key=>$value)
        {
            unset($droits[$key]);
            $key = str_replace('droit_', '', $key, $found);

            if ($found)
            {
                $droits[$key] = (int) $value;
            }
        }

        return $droits;
    }

    public function search($field = null, $query)
    {
        $db = DB::getInstance();

        if (is_null($field) || !in_array($field, array('id', 'nom', 'email', 'code_postal', 'ville', 'adresse', 'telephone')))
        {
            $field = 'nom';
        }

        if ($field == 'id' || $field == 'code_postal')
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
        );
    }

    public function listByCategory($cat = 0, $page = 1, $order = 'nom', $desc = false)
    {
        $begin = ($page - 1) * self::ITEMS_PER_PAGE;

        $db = Garradin_DB::getInstance();

        if (is_int($cat) && $cat)
            $where = 'WHERE id_categorie = '.(int)$cat;
        elseif (is_array($cat))
            $where = 'WHERE id_categorie IN ('.implode(',', $cat).')';
        else
            $where = '';







|







453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
        );
    }

    public function listByCategory($cat = 0, $page = 1, $order = 'nom', $desc = false)
    {
        $begin = ($page - 1) * self::ITEMS_PER_PAGE;

        $db = DB::getInstance();

        if (is_int($cat) && $cat)
            $where = 'WHERE id_categorie = '.(int)$cat;
        elseif (is_array($cat))
            $where = 'WHERE id_categorie IN ('.implode(',', $cat).')';
        else
            $where = '';
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
            $begin,
            self::ITEMS_PER_PAGE
        );
    }

    public function countByCategory($cat = 0)
    {
        $db = Garradin_DB::getInstance();

        if (is_int($cat) && $cat)
            $where = 'WHERE id_categorie = '.(int)$cat;
        elseif (is_array($cat))
            $where = 'WHERE id_categorie IN ('.implode(',', $cat).')';
        else
            $where = '';

        return $db->simpleQuerySingle('SELECT COUNT(*) FROM membres '.$where.';');
    }

    public function countAllButHidden()
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT COUNT(*) FROM membres WHERE id_categorie NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);');
    }

    static public function checkCotisation($date_membre, $duree_cotisation, $date_verif = null)
    {
        if (is_null($date_verif))
            $date_verif = time();

        if (!$date_membre)
            return false;

        $echeance = new DateTime('@'.$date_membre);
        $echeance->setTime(0, 0);
        $echeance->modify('+'.$duree_cotisation.' months');

        if ($echeance->getTimestamp() < $date_verif)
            return round(($date_verif - $echeance->getTimestamp()) / 3600 / 24);

        return true;
    }

    static public function updateCotisation($id, $date)
    {
        if (preg_match('!^\d{2}/\d{2}/\d{4}$!', $date))
            $date = DateTime::createFromFormat('d/m/Y', $date, new DateTimeZone('UTC'));
        elseif (preg_match('!^\d{4}-\d{2}-\d{2}$!', $date))
            $date = DateTime::createFromFormat('Y-m-d', $date, new DateTimeZone('UTC'));
        else
            throw new UserException('Format de date invalide : '.$date);

        $db = Garradin_DB::getInstance();
        return $db->simpleUpdate('membres',
            array('date_cotisation' => $date->format('Y-m-d H:i:s')),
            'id = '.(int)$id
        );
    }

    static public function changeCategorie($id_cat, $membres)
    {
        foreach ($membres as &$id)
        {
            $id = (int) $id;
        }

        $db = Garradin_DB::getInstance();
        return $db->simpleUpdate('membres',
            array('id_categorie' => (int)$id_cat),
            'id IN ('.implode(',', $membres).')'
        );
    }

    static protected function _deleteMembres($membres)
    {
        foreach ($membres as &$id)
        {
            $id = (int) $id;
        }

        $membres = implode(',', $membres);

        $db = Garradin_DB::getInstance();
        $db->exec('UPDATE wiki_revisions SET id_auteur = NULL WHERE id_auteur IN ('.$membres.');');
        $db->exec('UPDATE compta_journal SET id_auteur = NULL WHERE id_auteur IN ('.$membres.');');
        //$db->exec('DELETE FROM wiki_suivi WHERE id_membre IN ('.$membres.');');
        return $db->exec('DELETE FROM membres WHERE id IN ('.$membres.');');
    }

    public function sendMessageToCategory($dest, $sujet, $message, $subscribed_only = false)
    {
        $config = Garradin_Config::getInstance();

        $headers = array(
            'From'  =>  '"'.$config->get('nom_asso').'" <'.$config->get('email_asso').'>',
        );
        $message .= "\n\n--\n".$config->get('nom_asso')."\n".$config->get('site_asso');

        if ($dest == 0)
            $where = 'id_categorie NOT IN (SELECT id FROM membres_categories WHERE cacher = 1)';
        else
            $where = 'id_categorie = '.(int)$dest;

        if ($subscribed_only)
        {
            $where .= ' AND lettre_infos = 1';
        }

        $db = Garradin_DB::getInstance();
        $res = $db->query('SELECT email FROM membres WHERE LENGTH(email) > 0 AND '.$where.' ORDER BY id;');

        $sujet = '['.$config->get('nom_asso').'] '.$sujet;

        while ($row = $res->fetchArray(SQLITE3_ASSOC))
        {
            utils::mail($row['email'], $sujet, $message, $headers);







|













|











|












|

|



|













|















|








|
















|







489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
            $begin,
            self::ITEMS_PER_PAGE
        );
    }

    public function countByCategory($cat = 0)
    {
        $db = DB::getInstance();

        if (is_int($cat) && $cat)
            $where = 'WHERE id_categorie = '.(int)$cat;
        elseif (is_array($cat))
            $where = 'WHERE id_categorie IN ('.implode(',', $cat).')';
        else
            $where = '';

        return $db->simpleQuerySingle('SELECT COUNT(*) FROM membres '.$where.';');
    }

    public function countAllButHidden()
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT COUNT(*) FROM membres WHERE id_categorie NOT IN (SELECT id FROM membres_categories WHERE cacher = 1);');
    }

    static public function checkCotisation($date_membre, $duree_cotisation, $date_verif = null)
    {
        if (is_null($date_verif))
            $date_verif = time();

        if (!$date_membre)
            return false;

        $echeance = new \DateTime('@'.$date_membre);
        $echeance->setTime(0, 0);
        $echeance->modify('+'.$duree_cotisation.' months');

        if ($echeance->getTimestamp() < $date_verif)
            return round(($date_verif - $echeance->getTimestamp()) / 3600 / 24);

        return true;
    }

    static public function updateCotisation($id, $date)
    {
        if (preg_match('!^\d{2}/\d{2}/\d{4}$!', $date))
            $date = \DateTime::createFromFormat('d/m/Y', $date, new DateTimeZone('UTC'));
        elseif (preg_match('!^\d{4}-\d{2}-\d{2}$!', $date))
            $date = \DateTime::createFromFormat('Y-m-d', $date, new DateTimeZone('UTC'));
        else
            throw new UserException('Format de date invalide : '.$date);

        $db = DB::getInstance();
        return $db->simpleUpdate('membres',
            array('date_cotisation' => $date->format('Y-m-d H:i:s')),
            'id = '.(int)$id
        );
    }

    static public function changeCategorie($id_cat, $membres)
    {
        foreach ($membres as &$id)
        {
            $id = (int) $id;
        }

        $db = DB::getInstance();
        return $db->simpleUpdate('membres',
            array('id_categorie' => (int)$id_cat),
            'id IN ('.implode(',', $membres).')'
        );
    }

    static protected function _deleteMembres($membres)
    {
        foreach ($membres as &$id)
        {
            $id = (int) $id;
        }

        $membres = implode(',', $membres);

        $db = DB::getInstance();
        $db->exec('UPDATE wiki_revisions SET id_auteur = NULL WHERE id_auteur IN ('.$membres.');');
        $db->exec('UPDATE compta_journal SET id_auteur = NULL WHERE id_auteur IN ('.$membres.');');
        //$db->exec('DELETE FROM wiki_suivi WHERE id_membre IN ('.$membres.');');
        return $db->exec('DELETE FROM membres WHERE id IN ('.$membres.');');
    }

    public function sendMessageToCategory($dest, $sujet, $message, $subscribed_only = false)
    {
        $config = Config::getInstance();

        $headers = array(
            'From'  =>  '"'.$config->get('nom_asso').'" <'.$config->get('email_asso').'>',
        );
        $message .= "\n\n--\n".$config->get('nom_asso')."\n".$config->get('site_asso');

        if ($dest == 0)
            $where = 'id_categorie NOT IN (SELECT id FROM membres_categories WHERE cacher = 1)';
        else
            $where = 'id_categorie = '.(int)$dest;

        if ($subscribed_only)
        {
            $where .= ' AND lettre_infos = 1';
        }

        $db = DB::getInstance();
        $res = $db->query('SELECT email FROM membres WHERE LENGTH(email) > 0 AND '.$where.' ORDER BY id;');

        $sujet = '['.$config->get('nom_asso').'] '.$sujet;

        while ($row = $res->fetchArray(SQLITE3_ASSOC))
        {
            utils::mail($row['email'], $sujet, $message, $headers);

Modified include/class.membres_categories.php from [0442acff8f] to [2fa9f9ee18].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

require_once GARRADIN_ROOT . '/include/class.membres.php';

class Garradin_Membres_Categories
{
    protected $droits = array(
        'inscription'=> Garradin_Membres::DROIT_AUCUN,
        'connexion' =>  Garradin_Membres::DROIT_ACCES,
        'membres'   =>  Garradin_Membres::DROIT_ACCES,
        'compta'    =>  Garradin_Membres::DROIT_ACCES,
        'wiki'      =>  Garradin_Membres::DROIT_ACCES,
        'config'    =>  Garradin_Membres::DROIT_AUCUN,
    );

    static public function getDroitsDefaut()
    {
        return $this->droits;
    }



|

|


|
|
|
|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

namespace Garradin;

class Membres_Categories
{
    protected $droits = array(
        'inscription'=> Membres::DROIT_AUCUN,
        'connexion' =>  Membres::DROIT_ACCES,
        'membres'   =>  Membres::DROIT_ACCES,
        'compta'    =>  Membres::DROIT_ACCES,
        'wiki'      =>  Membres::DROIT_ACCES,
        'config'    =>  Membres::DROIT_AUCUN,
    );

    static public function getDroitsDefaut()
    {
        return $this->droits;
    }

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
160
161
162
163
164
165
166
167
        {
            if (!isset($data['droit_'.$key]))
                $data['droit_'.$key] = $value;
            else
                $data['droit_'.$key] = (int)$data['droit_'.$key];
        }

        $db = Garradin_DB::getInstance();
        $db->simpleInsert('membres_categories', $data);

        return $db->lastInsertRowID();
    }

    public function edit($id, $data)
    {
        $this->_checkData($data);

        foreach ($this->droits as $key=>$value)
        {
            if (isset($data['droit_'.$key]))
                $data['droit_'.$key] = (int)$data['droit_'.$key];
        }

        if (!isset($data['cacher']) || $data['cacher'] != 1)
            $data['cacher'] = 0;

        $db = Garradin_DB::getInstance();
        return $db->simpleUpdate('membres_categories', $data, 'id = '.(int)$id);
    }

    public function get($id)
    {
        $db = Garradin_DB::getInstance();

        return $db->simpleQuerySingle('SELECT * FROM membres_categories WHERE id = ?;',
            true, (int) $id);
    }

    public function remove($id)
    {
        $db = Garradin_DB::getInstance();
        $config = Garradin_Config::getInstance();

        if ($id == $config->get('categorie_membres'))
        {
            throw new UserException('Il est interdit de supprimer la catégorie définie par défaut dans la configuration.');
        }

        if ($db->simpleQuerySingle('SELECT 1 FROM membres WHERE id_categorie = ?;', false, (int)$id))
        {
            throw new UserException('La catégorie contient encore des membres, il n\'est pas possible de la supprimer.');
        }

        // Remise à zéro des droits sur les pages du wiki
        require_once GARRADIN_ROOT . '/include/class.wiki.php';

        $db->simpleUpdate(
            'wiki_pages',
            array(
                'droit_lecture'     =>  Garradin_Wiki::LECTURE_NORMAL,
                'droit_ecriture'    =>  Garradin_Wiki::ECRITURE_NORMAL,
            ),
            'droit_lecture = '.(int)$id.' OR droit_ecriture = '.(int)$id
        );

        return $db->simpleExec('DELETE FROM membres_categories WHERE id = ?;', (int) $id);
    }

    public function listSimple()
    {
        $db = Garradin_DB::getInstance();
        return $db->queryFetchAssoc('SELECT id, nom FROM membres_categories ORDER BY nom;');
    }

    public function listComplete()
    {
        $db = Garradin_DB::getInstance();
        return $db->queryFetch('SELECT * FROM membres_categories ORDER BY nom;');
    }

    public function listCompleteWithStats()
    {
        $db = Garradin_DB::getInstance();
        return $db->queryFetch('SELECT *, (SELECT COUNT(*) FROM membres WHERE id_categorie = membres_categories.id) AS nombre FROM membres_categories ORDER BY nom;');
    }


    public function listHidden()
    {
        $db = Garradin_DB::getInstance();
        return $db->queryFetchAssoc('SELECT id, nom FROM membres_categories WHERE cacher = 1;');
    }

    public function listNotHidden()
    {
        $db = Garradin_DB::getInstance();
        return $db->queryFetchAssoc('SELECT id, nom FROM membres_categories WHERE cacher = 0;');
    }
}

?>







|


















|





|







|
|











<
<
<



|
|









|





|





|






|





|





67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
160
161
162
163
164
        {
            if (!isset($data['droit_'.$key]))
                $data['droit_'.$key] = $value;
            else
                $data['droit_'.$key] = (int)$data['droit_'.$key];
        }

        $db = DB::getInstance();
        $db->simpleInsert('membres_categories', $data);

        return $db->lastInsertRowID();
    }

    public function edit($id, $data)
    {
        $this->_checkData($data);

        foreach ($this->droits as $key=>$value)
        {
            if (isset($data['droit_'.$key]))
                $data['droit_'.$key] = (int)$data['droit_'.$key];
        }

        if (!isset($data['cacher']) || $data['cacher'] != 1)
            $data['cacher'] = 0;

        $db = DB::getInstance();
        return $db->simpleUpdate('membres_categories', $data, 'id = '.(int)$id);
    }

    public function get($id)
    {
        $db = DB::getInstance();

        return $db->simpleQuerySingle('SELECT * FROM membres_categories WHERE id = ?;',
            true, (int) $id);
    }

    public function remove($id)
    {
        $db = DB::getInstance();
        $config = Config::getInstance();

        if ($id == $config->get('categorie_membres'))
        {
            throw new UserException('Il est interdit de supprimer la catégorie définie par défaut dans la configuration.');
        }

        if ($db->simpleQuerySingle('SELECT 1 FROM membres WHERE id_categorie = ?;', false, (int)$id))
        {
            throw new UserException('La catégorie contient encore des membres, il n\'est pas possible de la supprimer.');
        }




        $db->simpleUpdate(
            'wiki_pages',
            array(
                'droit_lecture'     =>  Wiki::LECTURE_NORMAL,
                'droit_ecriture'    =>  Wiki::ECRITURE_NORMAL,
            ),
            'droit_lecture = '.(int)$id.' OR droit_ecriture = '.(int)$id
        );

        return $db->simpleExec('DELETE FROM membres_categories WHERE id = ?;', (int) $id);
    }

    public function listSimple()
    {
        $db = DB::getInstance();
        return $db->queryFetchAssoc('SELECT id, nom FROM membres_categories ORDER BY nom;');
    }

    public function listComplete()
    {
        $db = DB::getInstance();
        return $db->queryFetch('SELECT * FROM membres_categories ORDER BY nom;');
    }

    public function listCompleteWithStats()
    {
        $db = DB::getInstance();
        return $db->queryFetch('SELECT *, (SELECT COUNT(*) FROM membres WHERE id_categorie = membres_categories.id) AS nombre FROM membres_categories ORDER BY nom;');
    }


    public function listHidden()
    {
        $db = DB::getInstance();
        return $db->queryFetchAssoc('SELECT id, nom FROM membres_categories WHERE cacher = 1;');
    }

    public function listNotHidden()
    {
        $db = DB::getInstance();
        return $db->queryFetchAssoc('SELECT id, nom FROM membres_categories WHERE cacher = 0;');
    }
}

?>

Modified include/class.squelette.php from [e5876d4057] to [a85f914a56].

1
2

3
4
5
6
7
8
9
10
11
<?php


require_once GARRADIN_ROOT . '/include/libs/miniskel/class.miniskel.php';
require_once GARRADIN_ROOT . '/include/lib.squelette.filtres.php';

class Squelette_Snippet
{
    const TEXT = 0;
    const PHP = 1;
    const GUESS = 2;
    const OBJ = 3;


>
|
|







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

namespace Garradin;

require_once GARRADIN_ROOT . '/include/libs/miniskel/class.miniskel.php';

class Squelette_Snippet
{
    const TEXT = 0;
    const PHP = 1;
    const GUESS = 2;
    const OBJ = 3;
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
            $this->_content[$key] = (string) (int) $type . $value;
        }

        unset($value);
    }
}

class Squelette extends miniSkel
{
    private $parent = null;
    private $current = null;
    private $_vars = array();

    private function _registerDefaultModifiers()
    {
        foreach (Squelette_Filtres::$filtres_php as $func=>$name)
        {
            if (is_string($func))
                $this->register_modifier($name, $func);
            else
                $this->register_modifier($name, $name);
        }

        foreach (get_class_methods('Squelette_Filtres') as $name)
        {
            $this->register_modifier($name, array('Squelette_Filtres', $name));
        }

        foreach (Squelette_Filtres::$filtres_alias as $name=>$func)
        {
            $this->register_modifier($name, array('Squelette_Filtres', $func));
        }
    }

    public function __construct()
    {
        $this->_registerDefaultModifiers();

        $config = Garradin_Config::getInstance();

        $this->assign('nom_asso', $config->get('nom_asso'));
        $this->assign('adresse_asso', $config->get('adresse_asso'));
        $this->assign('email_asso', $config->get('email_asso'));
        $this->assign('site_asso', $config->get('site_asso'));

        $this->assign('url_racine', WWW_URL);
        $this->assign('url_site', WWW_URL);
        $this->assign('url_atom', WWW_URL . 'feed/atom/');
        $this->assign('url_elements', WWW_URL . 'elements/');
        $this->assign('url_admin', WWW_URL . 'admin/');
    }

    protected function processInclude($args)
    {
        if (empty($args))
            throw new miniSkelMarkupException("Le tag INCLURE demande à préciser le fichier à inclure.");

        $file = key($args);

        if (empty($file) || !preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $file))
            throw new miniSkelMarkupException("INCLURE: le nom de fichier ne peut contenir que des caractères alphanumériques.");

        return new Squelette_Snippet(1, '$this->fetch("'.$file.'", false);');
    }

    protected function processVariable($name, $value, $applyDefault, $modifiers, $pre, $post, $context)
    {
        if ($context == self::CONTEXT_IN_ARG)







|















|

|




|







|
















|




|







165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
            $this->_content[$key] = (string) (int) $type . $value;
        }

        unset($value);
    }
}

class Squelette extends \miniSkel
{
    private $parent = null;
    private $current = null;
    private $_vars = array();

    private function _registerDefaultModifiers()
    {
        foreach (Squelette_Filtres::$filtres_php as $func=>$name)
        {
            if (is_string($func))
                $this->register_modifier($name, $func);
            else
                $this->register_modifier($name, $name);
        }

        foreach (get_class_methods('Garradin\Squelette_Filtres') as $name)
        {
            $this->register_modifier($name, array('Garradin\Squelette_Filtres', $name));
        }

        foreach (Squelette_Filtres::$filtres_alias as $name=>$func)
        {
            $this->register_modifier($name, array('Garradin\Squelette_Filtres', $func));
        }
    }

    public function __construct()
    {
        $this->_registerDefaultModifiers();

        $config = Config::getInstance();

        $this->assign('nom_asso', $config->get('nom_asso'));
        $this->assign('adresse_asso', $config->get('adresse_asso'));
        $this->assign('email_asso', $config->get('email_asso'));
        $this->assign('site_asso', $config->get('site_asso'));

        $this->assign('url_racine', WWW_URL);
        $this->assign('url_site', WWW_URL);
        $this->assign('url_atom', WWW_URL . 'feed/atom/');
        $this->assign('url_elements', WWW_URL . 'elements/');
        $this->assign('url_admin', WWW_URL . 'admin/');
    }

    protected function processInclude($args)
    {
        if (empty($args))
            throw new \miniSkelMarkupException("Le tag INCLURE demande à préciser le fichier à inclure.");

        $file = key($args);

        if (empty($file) || !preg_match('!^[\w\d_-]+(?:\.[\w\d_-]+)*$!', $file))
            throw new \miniSkelMarkupException("INCLURE: le nom de fichier ne peut contenir que des caractères alphanumériques.");

        return new Squelette_Snippet(1, '$this->fetch("'.$file.'", false);');
    }

    protected function processVariable($name, $value, $applyDefault, $modifiers, $pre, $post, $context)
    {
        if ($context == self::CONTEXT_IN_ARG)
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
        $out = new Squelette_Snippet(1, '$value = $this->getVariable(\''.$name.'\');');

        // We process modifiers
        foreach ($modifiers as &$modifier)
        {
            if (!isset($this->modifiers[$modifier['name']]))
            {
                throw new miniSkelMarkupException('Filtre '.$modifier['name'].' inconnu !');
            }

            $out->append(1, '$value = call_user_func_array('.var_export($this->modifiers[$modifier['name']], true).', array($value, ');

            foreach ($modifier['arguments'] as $arg)
            {
                if ($arg == 'debut_liste')







|







249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
        $out = new Squelette_Snippet(1, '$value = $this->getVariable(\''.$name.'\');');

        // We process modifiers
        foreach ($modifiers as &$modifier)
        {
            if (!isset($this->modifiers[$modifier['name']]))
            {
                throw new \miniSkelMarkupException('Filtre '.$modifier['name'].' inconnu !');
            }

            $out->append(1, '$value = call_user_func_array('.var_export($this->modifiers[$modifier['name']], true).', array($value, ');

            foreach ($modifier['arguments'] as $arg)
            {
                if ($arg == 'debut_liste')
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
        return $out;
    }

    protected function processLoop($loopName, $loopType, $loopCriterias, $loopContent, $preContent, $postContent, $altContent)
    {
        if ($loopType != 'articles' && $loopType != 'rubriques' && $loopType != 'pages')
        {
            throw new miniSkelMarkupException("Le type de boucle '".$loopType."' est inconnu.");
        }

        $loopStart = '';
        $query = $where = $order = '';
        $limit = $begin = 0;

        $query = 'SELECT w.*, strftime(\\\'%s\\\', w.date_creation) AS date_creation, strftime(\\\'%s\\\', w.date_modification) AS date_modification';







|







311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
        return $out;
    }

    protected function processLoop($loopName, $loopType, $loopCriterias, $loopContent, $preContent, $postContent, $altContent)
    {
        if ($loopType != 'articles' && $loopType != 'rubriques' && $loopType != 'pages')
        {
            throw new \miniSkelMarkupException("Le type de boucle '".$loopType."' est inconnu.");
        }

        $loopStart = '';
        $query = $where = $order = '';
        $limit = $begin = 0;

        $query = 'SELECT w.*, strftime(\\\'%s\\\', w.date_creation) AS date_creation, strftime(\\\'%s\\\', w.date_modification) AS date_modification';
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403

        foreach ($loopCriterias as $criteria)
        {
            if (isset($criteria['field']))
            {
                if (!in_array($criteria['field'], $allowed_fields))
                {
                    throw new miniSkelMarkupException("Critère '".$criteria['field']."' invalide pour la boucle '$loopName' de type '$loopType'.");
                }
                elseif ($criteria['field'] == 'rubrique')
                {
                    $criteria['field'] = 'parent';
                }
                elseif ($criteria['field'] == 'date')
                {
                    $criteria['field'] = 'date_creation';
                }
                elseif ($criteria['field'] == 'points')
                {
                    if ($criteria['action'] != miniSkel::ACTION_ORDER_BY)
                    {
                        throw new miniSkelMarkupException("Le critère 'points' n\'est pas valide dans ce contexte.");
                    }

                    $search_rank = true;
                }
            }

            switch ($criteria['action'])
            {
                case miniSkel::ACTION_ORDER_BY:
                    if (!$order)
                        $order = 'ORDER BY '.$criteria['field'].'';
                    else
                        $order .= ', '.$criteria['field'].'';
                    break;
                case miniSkel::ACTION_ORDER_DESC:
                    if ($order)
                        $order .= ' DESC';
                    break;
                case miniSkel::ACTION_LIMIT:
                    $begin = $criteria['begin'];
                    $limit = $criteria['number'];
                    break;
                case miniSkel::ACTION_MATCH_FIELD_BY_VALUE:
                    $where .= ' AND '.$criteria['field'].' '.$criteria['comparison'].' \\\'\'.$db->escapeString(\''.$criteria['value'].'\').\'\\\'';
                    break;
                case miniSkel::ACTION_MATCH_FIELD:
                {
                    if ($criteria['field'] == 'recherche')
                    {
                        $query = 'SELECT w.*, r.contenu AS texte, rank(matchinfo(wiki_recherche), 0, 1.0, 1.0) AS points FROM wiki_pages AS w INNER JOIN wiki_recherche AS r ON (w.id = r.id) ';
                        $where .= ' AND wiki_recherche MATCH \\\'\'.$db->escapeString($this->getVariable(\''.$criteria['field'].'\')).\'\\\'';
                        $search = true;
                    }







|











|

|








|





|



|



|


|







350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404

        foreach ($loopCriterias as $criteria)
        {
            if (isset($criteria['field']))
            {
                if (!in_array($criteria['field'], $allowed_fields))
                {
                    throw new \miniSkelMarkupException("Critère '".$criteria['field']."' invalide pour la boucle '$loopName' de type '$loopType'.");
                }
                elseif ($criteria['field'] == 'rubrique')
                {
                    $criteria['field'] = 'parent';
                }
                elseif ($criteria['field'] == 'date')
                {
                    $criteria['field'] = 'date_creation';
                }
                elseif ($criteria['field'] == 'points')
                {
                    if ($criteria['action'] != \miniSkel::ACTION_ORDER_BY)
                    {
                        throw new \miniSkelMarkupException("Le critère 'points' n\'est pas valide dans ce contexte.");
                    }

                    $search_rank = true;
                }
            }

            switch ($criteria['action'])
            {
                case \miniSkel::ACTION_ORDER_BY:
                    if (!$order)
                        $order = 'ORDER BY '.$criteria['field'].'';
                    else
                        $order .= ', '.$criteria['field'].'';
                    break;
                case \miniSkel::ACTION_ORDER_DESC:
                    if ($order)
                        $order .= ' DESC';
                    break;
                case \miniSkel::ACTION_LIMIT:
                    $begin = $criteria['begin'];
                    $limit = $criteria['number'];
                    break;
                case \miniSkel::ACTION_MATCH_FIELD_BY_VALUE:
                    $where .= ' AND '.$criteria['field'].' '.$criteria['comparison'].' \\\'\'.$db->escapeString(\''.$criteria['value'].'\').\'\\\'';
                    break;
                case \miniSkel::ACTION_MATCH_FIELD:
                {
                    if ($criteria['field'] == 'recherche')
                    {
                        $query = 'SELECT w.*, r.contenu AS texte, rank(matchinfo(wiki_recherche), 0, 1.0, 1.0) AS points FROM wiki_pages AS w INNER JOIN wiki_recherche AS r ON (w.id = r.id) ';
                        $where .= ' AND wiki_recherche MATCH \\\'\'.$db->escapeString($this->getVariable(\''.$criteria['field'].'\')).\'\\\'';
                        $search = true;
                    }
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
                default:
                    break;
            }
        }

        if ($search_rank && !$search)
        {
            throw new miniSkelMarkupException("Le critère par points n'est possible que dans les boucles de recherche.");
        }

        if (trim($loopContent))
        {
            $loopStart .= '$row[\'url\'] = WWW_URL . $row[\'uri\']; ';
        }








|







416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
                default:
                    break;
            }
        }

        if ($search_rank && !$search)
        {
            throw new \miniSkelMarkupException("Le critère par points n'est possible que dans les boucles de recherche.");
        }

        if (trim($loopContent))
        {
            $loopStart .= '$row[\'url\'] = WWW_URL . $row[\'uri\']; ';
        }

505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527

        $tpl_id = basename(dirname($path)) . '/' . $template;

        if (!self::compile_check($tpl_id, $path))
        {
            if (!file_exists($path))
            {
                throw new miniSkelMarkupException('Le squelette "'.$tpl_id.'" n\'existe pas.');
            }

            $content = file_get_contents($path);
            $content = strtr($content, array('<?php' => '&lt;?php', '<?' => '<?php echo \'<?\'; ?>'));

            $out = new Squelette_Snippet(2, $this->parse($content));
            $out->prepend(1, '/* '.$tpl_id.' */ '.
                '$db = Garradin_DB::getInstance(); '.
                'if ($this->parent) $parent_hash = $this->parent[\'_self_hash\']; '. // For included files
                'else $parent_hash = false;');

            if (!$no_display)
            {
                self::compile_store($tpl_id, $out);
            }







|







|







506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528

        $tpl_id = basename(dirname($path)) . '/' . $template;

        if (!self::compile_check($tpl_id, $path))
        {
            if (!file_exists($path))
            {
                throw new \miniSkelMarkupException('Le squelette "'.$tpl_id.'" n\'existe pas.');
            }

            $content = file_get_contents($path);
            $content = strtr($content, array('<?php' => '&lt;?php', '<?' => '<?php echo \'<?\'; ?>'));

            $out = new Squelette_Snippet(2, $this->parse($content));
            $out->prepend(1, '/* '.$tpl_id.' */ '.
                'namespace Garradin; $db = DB::getInstance(); '.
                'if ($this->parent) $parent_hash = $this->parent[\'_self_hash\']; '. // For included files
                'else $parent_hash = false;');

            if (!$no_display)
            {
                self::compile_store($tpl_id, $out);
            }

Modified include/class.wiki.php from [59c6d2a39d] to [6ab6597ecc].

1
2


3
4
5
6
7
8
9
10
<?php



class Garradin_Wiki
{
    const LECTURE_PUBLIC = -1;
    const LECTURE_NORMAL = 0;
    const LECTURE_CATEGORIE = 1;

    const ECRITURE_NORMAL = 0;
    const ECRITURE_CATEGORIE = 1;


>
>
|







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

namespace Garradin;

class Wiki
{
    const LECTURE_PUBLIC = -1;
    const LECTURE_NORMAL = 0;
    const LECTURE_CATEGORIE = 1;

    const ECRITURE_NORMAL = 0;
    const ECRITURE_CATEGORIE = 1;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
        return $str;
    }

    // Gestion des données ///////////////////////////////////////////////////////

    public function _checkFields(&$data)
    {
        $db = Garradin_DB::getInstance();

        if (isset($data['titre']) && !trim($data['titre']))
        {
            throw new UserException('Le titre ne peut rester vide.');
        }

        if (isset($data['uri']) && !trim($data['uri']))







|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
        return $str;
    }

    // Gestion des données ///////////////////////////////////////////////////////

    public function _checkFields(&$data)
    {
        $db = DB::getInstance();

        if (isset($data['titre']) && !trim($data['titre']))
        {
            throw new UserException('Le titre ne peut rester vide.');
        }

        if (isset($data['uri']) && !trim($data['uri']))
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

        return true;
    }

    public function create($data = array())
    {
        $this->_checkFields($data);
        $db = Garradin_DB::getInstance();

        if (!empty($data['uri']))
        {
            $data['uri'] = self::transformTitleToURI($data['uri']);

            if ($db->simpleQuerySingle('SELECT 1 FROM wiki_pages WHERE uri = ? LIMIT 1;', false, $data['uri']))
            {







|







79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

        return true;
    }

    public function create($data = array())
    {
        $this->_checkFields($data);
        $db = DB::getInstance();

        if (!empty($data['uri']))
        {
            $data['uri'] = self::transformTitleToURI($data['uri']);

            if ($db->simpleQuerySingle('SELECT 1 FROM wiki_pages WHERE uri = ? LIMIT 1;', false, $data['uri']))
            {
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
        $db->simpleInsert('wiki_recherche', array('id' => $id, 'titre' => $data['titre']));

        return $id;
    }

    public function edit($id, $data = array())
    {
        $db = Garradin_DB::getInstance();
        $this->_checkFields($data);

        if (isset($data['uri']))
        {
            $data['uri'] = self::transformTitleToURI($data['uri']);

            if ($db->simpleQuerySingle('SELECT 1 FROM wiki_pages WHERE uri = ? AND id != ? LIMIT 1;', false, $data['uri'], (int)$id))







|







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
        $db->simpleInsert('wiki_recherche', array('id' => $id, 'titre' => $data['titre']));

        return $id;
    }

    public function edit($id, $data = array())
    {
        $db = DB::getInstance();
        $this->_checkFields($data);

        if (isset($data['uri']))
        {
            $data['uri'] = self::transformTitleToURI($data['uri']);

            if ($db->simpleQuerySingle('SELECT 1 FROM wiki_pages WHERE uri = ? AND id != ? LIMIT 1;', false, $data['uri'], (int)$id))
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219

        $db->simpleUpdate('wiki_pages', $data, 'id = '.(int)$id);
        return true;
    }

    public function delete($id)
    {
        $db = Garradin_DB::getInstance();

        if ($db->simpleQuerySingle('SELECT COUNT(*) FROM wiki_pages WHERE parent = ?;', false, (int)$id))
        {
            return false;
        }

        $db->simpleExec('DELETE FROM wiki_revisions WHERE id_page = ?;', (int)$id);
        //$db->simpleExec('DELETE FROM wiki_suivi WHERE id_page = ?;', (int)$id); FIXME
        $db->simpleExec('DELETE FROM wiki_recherche WHERE id = ?;', (int)$id);
        $db->simpleExec('DELETE FROM wiki_pages WHERE id = ?;', (int)$id);
        return true;
    }

    public function get($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT *,
            strftime(\'%s\', date_creation) AS date_creation,
            strftime(\'%s\', date_modification) AS date_modification
            FROM wiki_pages WHERE id = ? LIMIT 1;', true, (int)$id);
    }

    public function getTitle($id)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT titre FROM wiki_pages WHERE id = ? LIMIT 1;', false, (int)$id);
    }

    public function getRevision($id, $rev)
    {
        $db = Garradin_DB::getInstance();
        // FIXME pagination au lieu de bloquer à 1000
        return $db->simpleQuerySingle('SELECT r.revision, r.modification, r.id_auteur, r.contenu,
            strftime(\'%s\', r.date) AS date, LENGTH(r.contenu) AS taille, m.nom AS nom_auteur,
            r.chiffrement
            FROM wiki_revisions AS r LEFT JOIN membres AS m ON m.id = r.id_auteur
            WHERE r.id_page = ? AND revision = ? LIMIT 1;', true, (int) $id, (int) $rev);
    }

    public function listRevisions($id)
    {
        $db = Garradin_DB::getInstance();
        // FIXME pagination au lieu de bloquer à 1000
        return $db->simpleStatementFetch('SELECT r.revision, r.modification, r.id_auteur,
            strftime(\'%s\', r.date) AS date, LENGTH(r.contenu) AS taille, m.nom AS nom_auteur,
            LENGTH(r.contenu) - (SELECT LENGTH(contenu) FROM wiki_revisions WHERE id_page = r.id_page AND revision < r.revision ORDER BY revision DESC LIMIT 1)
            AS diff_taille, r.chiffrement
            FROM wiki_revisions AS r LEFT JOIN membres AS m ON m.id = r.id_auteur
            WHERE r.id_page = ? ORDER BY r.revision DESC LIMIT 1000;', SQLITE3_ASSOC, (int) $id);
    }

    public function editRevision($id, $revision_edition = 0, $data)
    {
        $db = Garradin_DB::getInstance();

        $revision = $db->simpleQuerySingle('SELECT revision FROM wiki_pages WHERE id = ?;', false, (int)$id);

        // ?! L'ID fournit ne correspond à rien ?
        if ($revision === false)
        {
            throw new RuntimeException('La page demandée n\'existe pas.');







|















|








|





|










|











|







153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221

        $db->simpleUpdate('wiki_pages', $data, 'id = '.(int)$id);
        return true;
    }

    public function delete($id)
    {
        $db = DB::getInstance();

        if ($db->simpleQuerySingle('SELECT COUNT(*) FROM wiki_pages WHERE parent = ?;', false, (int)$id))
        {
            return false;
        }

        $db->simpleExec('DELETE FROM wiki_revisions WHERE id_page = ?;', (int)$id);
        //$db->simpleExec('DELETE FROM wiki_suivi WHERE id_page = ?;', (int)$id); FIXME
        $db->simpleExec('DELETE FROM wiki_recherche WHERE id = ?;', (int)$id);
        $db->simpleExec('DELETE FROM wiki_pages WHERE id = ?;', (int)$id);
        return true;
    }

    public function get($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT *,
            strftime(\'%s\', date_creation) AS date_creation,
            strftime(\'%s\', date_modification) AS date_modification
            FROM wiki_pages WHERE id = ? LIMIT 1;', true, (int)$id);
    }

    public function getTitle($id)
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT titre FROM wiki_pages WHERE id = ? LIMIT 1;', false, (int)$id);
    }

    public function getRevision($id, $rev)
    {
        $db = DB::getInstance();
        // FIXME pagination au lieu de bloquer à 1000
        return $db->simpleQuerySingle('SELECT r.revision, r.modification, r.id_auteur, r.contenu,
            strftime(\'%s\', r.date) AS date, LENGTH(r.contenu) AS taille, m.nom AS nom_auteur,
            r.chiffrement
            FROM wiki_revisions AS r LEFT JOIN membres AS m ON m.id = r.id_auteur
            WHERE r.id_page = ? AND revision = ? LIMIT 1;', true, (int) $id, (int) $rev);
    }

    public function listRevisions($id)
    {
        $db = DB::getInstance();
        // FIXME pagination au lieu de bloquer à 1000
        return $db->simpleStatementFetch('SELECT r.revision, r.modification, r.id_auteur,
            strftime(\'%s\', r.date) AS date, LENGTH(r.contenu) AS taille, m.nom AS nom_auteur,
            LENGTH(r.contenu) - (SELECT LENGTH(contenu) FROM wiki_revisions WHERE id_page = r.id_page AND revision < r.revision ORDER BY revision DESC LIMIT 1)
            AS diff_taille, r.chiffrement
            FROM wiki_revisions AS r LEFT JOIN membres AS m ON m.id = r.id_auteur
            WHERE r.id_page = ? ORDER BY r.revision DESC LIMIT 1000;', SQLITE3_ASSOC, (int) $id);
    }

    public function editRevision($id, $revision_edition = 0, $data)
    {
        $db = DB::getInstance();

        $revision = $db->simpleQuerySingle('SELECT revision FROM wiki_pages WHERE id = ?;', false, (int)$id);

        // ?! L'ID fournit ne correspond à rien ?
        if ($revision === false)
        {
            throw new RuntimeException('La page demandée n\'existe pas.');
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
        ), 'id = '.(int)$id);

        return true;
    }

    public function search($query)
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleStatementFetch('SELECT
            p.uri, r.*, snippet(wiki_recherche, "<b>", "</b>", "...", -1, -50) AS snippet,
            rank(matchinfo(wiki_recherche), 0, 1.0, 1.0) AS points
            FROM wiki_recherche AS r INNER JOIN wiki_pages AS p ON p.id = r.id
            WHERE '.$this->_getLectureClause('p.').' AND wiki_recherche MATCH \''.$db->escapeString($query).'\'
            ORDER BY points DESC LIMIT 0,50;');
    }







|







268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
        ), 'id = '.(int)$id);

        return true;
    }

    public function search($query)
    {
        $db = DB::getInstance();
        return $db->simpleStatementFetch('SELECT
            p.uri, r.*, snippet(wiki_recherche, "<b>", "</b>", "...", -1, -50) AS snippet,
            rank(matchinfo(wiki_recherche), 0, 1.0, 1.0) AS points
            FROM wiki_recherche AS r INNER JOIN wiki_pages AS p ON p.id = r.id
            WHERE '.$this->_getLectureClause('p.').' AND wiki_recherche MATCH \''.$db->escapeString($query).'\'
            ORDER BY points DESC LIMIT 0,50;');
    }
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
    protected function _getLectureClause($prefix = '')
    {
        if (is_null($this->restriction_categorie))
        {
            throw new UnexpectedValueException('setRestrictionCategorie doit être appelé auparavant.');
        }

        if ($this->restriction_droit == Garradin_Membres::DROIT_AUCUN)
        {
            throw new UserException('Vous n\'avez pas accès au wiki.');
        }

        if ($this->restriction_droit == Garradin_Membres::DROIT_ADMIN)
            return '1';

        return '('.$prefix.'droit_lecture = '.self::LECTURE_NORMAL.' OR '.$prefix.'droit_lecture = '.self::LECTURE_PUBLIC.'
            OR '.$prefix.'droit_lecture = '.(int)$this->restriction_categorie.')';
    }

    public function canReadPage($lecture)
    {
        if (is_null($this->restriction_categorie))
        {
            throw new UnexpectedValueException('setRestrictionCategorie doit être appelé auparavant.');
        }

        if ($this->restriction_droit < Garradin_Membres::DROIT_ACCES)
        {
            return false;
        }

        if ($this->restriction_droit == Garradin_Membres::DROIT_ADMIN
            || $lecture == self::LECTURE_NORMAL || $lecture == self::LECTURE_PUBLIC
            || $lecture == $this->restriction_categorie)
            return true;

        return false;
    }

    public function canWritePage($ecriture)
    {
        if (is_null($this->restriction_categorie))
        {
            throw new UnexpectedValueException('setRestrictionCategorie doit être appelé auparavant.');
        }

        if ($this->restriction_droit < Garradin_Membres::DROIT_ECRITURE)
        {
            return false;
        }

        if ($this->restriction_droit == Garradin_Membres::DROIT_ADMIN
            || $ecriture == self::ECRITURE_NORMAL
            || $ecriture == $this->restriction_categorie)
            return true;

        return false;
    }

    public function getList($parent = 0)
    {
        $db = Garradin_DB::getInstance();

        return $db->simpleStatementFetch(
            'SELECT id, revision, uri, titre,
                strftime(\'%s\', date_creation) AS date_creation,
                strftime(\'%s\', date_modification) AS date_modification
                FROM wiki_pages
                WHERE parent = ? AND '.$this->_getLectureClause().'
                ORDER BY transliterate_to_ascii(titre) COLLATE NOCASE  LIMIT 500;',
            SQLITE3_ASSOC,
            (int) $parent
        );
    }

    public function getById($id)
    {
        $db = Garradin_DB::getInstance();
        $page = $db->simpleQuerySingle('SELECT *,
                strftime(\'%s\', date_creation) AS date_creation,
                strftime(\'%s\', date_modification) AS date_modification
                FROM wiki_pages
                WHERE id = ?;', true, (int)$id);

        if (!$page)







|




|













|




|














|




|









|















|







291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
    protected function _getLectureClause($prefix = '')
    {
        if (is_null($this->restriction_categorie))
        {
            throw new UnexpectedValueException('setRestrictionCategorie doit être appelé auparavant.');
        }

        if ($this->restriction_droit == Membres::DROIT_AUCUN)
        {
            throw new UserException('Vous n\'avez pas accès au wiki.');
        }

        if ($this->restriction_droit == Membres::DROIT_ADMIN)
            return '1';

        return '('.$prefix.'droit_lecture = '.self::LECTURE_NORMAL.' OR '.$prefix.'droit_lecture = '.self::LECTURE_PUBLIC.'
            OR '.$prefix.'droit_lecture = '.(int)$this->restriction_categorie.')';
    }

    public function canReadPage($lecture)
    {
        if (is_null($this->restriction_categorie))
        {
            throw new UnexpectedValueException('setRestrictionCategorie doit être appelé auparavant.');
        }

        if ($this->restriction_droit < Membres::DROIT_ACCES)
        {
            return false;
        }

        if ($this->restriction_droit == Membres::DROIT_ADMIN
            || $lecture == self::LECTURE_NORMAL || $lecture == self::LECTURE_PUBLIC
            || $lecture == $this->restriction_categorie)
            return true;

        return false;
    }

    public function canWritePage($ecriture)
    {
        if (is_null($this->restriction_categorie))
        {
            throw new UnexpectedValueException('setRestrictionCategorie doit être appelé auparavant.');
        }

        if ($this->restriction_droit < Membres::DROIT_ECRITURE)
        {
            return false;
        }

        if ($this->restriction_droit == Membres::DROIT_ADMIN
            || $ecriture == self::ECRITURE_NORMAL
            || $ecriture == $this->restriction_categorie)
            return true;

        return false;
    }

    public function getList($parent = 0)
    {
        $db = DB::getInstance();

        return $db->simpleStatementFetch(
            'SELECT id, revision, uri, titre,
                strftime(\'%s\', date_creation) AS date_creation,
                strftime(\'%s\', date_modification) AS date_modification
                FROM wiki_pages
                WHERE parent = ? AND '.$this->_getLectureClause().'
                ORDER BY transliterate_to_ascii(titre) COLLATE NOCASE  LIMIT 500;',
            SQLITE3_ASSOC,
            (int) $parent
        );
    }

    public function getById($id)
    {
        $db = DB::getInstance();
        $page = $db->simpleQuerySingle('SELECT *,
                strftime(\'%s\', date_creation) AS date_creation,
                strftime(\'%s\', date_modification) AS date_modification
                FROM wiki_pages
                WHERE id = ?;', true, (int)$id);

        if (!$page)
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
        }

        return $page;
    }

    public function getByURI($uri)
    {
        $db = Garradin_DB::getInstance();
        $page = $db->simpleQuerySingle('SELECT *,
                strftime(\'%s\', date_creation) AS date_creation,
                strftime(\'%s\', date_modification) AS date_modification
                FROM wiki_pages
                WHERE uri = ?;', true, trim($uri));

        if (!$page)







|







388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
        }

        return $page;
    }

    public function getByURI($uri)
    {
        $db = DB::getInstance();
        $page = $db->simpleQuerySingle('SELECT *,
                strftime(\'%s\', date_creation) AS date_creation,
                strftime(\'%s\', date_modification) AS date_modification
                FROM wiki_pages
                WHERE uri = ?;', true, trim($uri));

        if (!$page)
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
        return $page;
    }

    public function listRecentModifications($page = 1)
    {
        $begin = ($page - 1) * self::ITEMS_PER_PAGE;

        $db = Garradin_DB::getInstance();

        return $db->simpleStatementFetch('SELECT *,
                strftime(\'%s\', date_creation) AS date_creation,
                strftime(\'%s\', date_modification) AS date_modification
                FROM wiki_pages
                WHERE '.$this->_getLectureClause().'
                ORDER BY date_modification DESC;', SQLITE3_ASSOC);
    }

    public function countRecentModifications()
    {
        $db = Garradin_DB::getInstance();
        return $db->simpleQuerySingle('SELECT COUNT(*) FROM wiki_pages WHERE '.$this->_getLectureClause().';');
    }

    public function listBackBreadCrumbs($id)
    {
        if ($id == 0)
            return array();

        $db = Garradin_DB::getInstance();
        $flat = array();

        while ($id > 0)
        {
            $res = $db->simpleQuerySingle('SELECT parent, titre, uri
                FROM wiki_pages WHERE id = ? LIMIT 1;', true, (int)$id);








|











|








|







417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
        return $page;
    }

    public function listRecentModifications($page = 1)
    {
        $begin = ($page - 1) * self::ITEMS_PER_PAGE;

        $db = DB::getInstance();

        return $db->simpleStatementFetch('SELECT *,
                strftime(\'%s\', date_creation) AS date_creation,
                strftime(\'%s\', date_modification) AS date_modification
                FROM wiki_pages
                WHERE '.$this->_getLectureClause().'
                ORDER BY date_modification DESC;', SQLITE3_ASSOC);
    }

    public function countRecentModifications()
    {
        $db = DB::getInstance();
        return $db->simpleQuerySingle('SELECT COUNT(*) FROM wiki_pages WHERE '.$this->_getLectureClause().';');
    }

    public function listBackBreadCrumbs($id)
    {
        if ($id == 0)
            return array();

        $db = DB::getInstance();
        $flat = array();

        while ($id > 0)
        {
            $res = $db->simpleQuerySingle('SELECT parent, titre, uri
                FROM wiki_pages WHERE id = ? LIMIT 1;', true, (int)$id);

458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
        }

        return array_reverse($flat);
    }

    public function listBackParentTree($id)
    {
        $db = Garradin_DB::getInstance();
        $flat = array(
            array(
                'id' => 0,
                'parent' => null,
                'titre' => 'Racine',
                'children' => $db->simpleStatementFetchAssocKey('SELECT id, parent, titre FROM wiki_pages
                    WHERE parent = ? ORDER BY transliterate_to_ascii(titre) COLLATE NOCASE;',







|







460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
        }

        return array_reverse($flat);
    }

    public function listBackParentTree($id)
    {
        $db = DB::getInstance();
        $flat = array(
            array(
                'id' => 0,
                'parent' => null,
                'titre' => 'Racine',
                'children' => $db->simpleStatementFetchAssocKey('SELECT id, parent, titre FROM wiki_pages
                    WHERE parent = ? ORDER BY transliterate_to_ascii(titre) COLLATE NOCASE;',

Modified include/init.php from [f8252b41a0] to [633742bb37].

1
2


3
4
5
6
7
8
9
<?php



/*
 * Version de Garradin
 */

function garradin_version()
{
    if (defined('GARRADIN_VERSION'))


>
>







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

namespace Garradin;

/*
 * Version de Garradin
 */

function garradin_version()
{
    if (defined('GARRADIN_VERSION'))
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
    define('WWW_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . WWW_URI);
}

/*
 * Gestion des erreurs et exceptions
 */

class UserException extends LogicException
{
}

error_reporting(-1);

function exception_error_handler($errno, $errstr, $errfile, $errline )
{
    // For @ ignored errors
    if (error_reporting() === 0) return;
    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}

function exception_handler($e)
{
    if ($e instanceOf UserException || $e instanceOf miniSkelMarkupException)
    {
        try {
            require_once GARRADIN_ROOT . '/include/template.php';
            $tpl = Garradin_TPL::getInstance();

            $tpl->assign('error', $e->getMessage());
            $tpl->display('error.tpl');
            exit;
        }
        catch (Exception $e)
        {







|









|







<
|







80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104

105
106
107
108
109
110
111
112
    define('WWW_URL', 'http' . (!empty($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . WWW_URI);
}

/*
 * Gestion des erreurs et exceptions
 */

class UserException extends \LogicException
{
}

error_reporting(-1);

function exception_error_handler($errno, $errstr, $errfile, $errline )
{
    // For @ ignored errors
    if (error_reporting() === 0) return;
    throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
}

function exception_handler($e)
{
    if ($e instanceOf UserException || $e instanceOf miniSkelMarkupException)
    {
        try {

            $tpl = Template::getInstance();

            $tpl->assign('error', $e->getMessage());
            $tpl->display('error.tpl');
            exit;
        }
        catch (Exception $e)
        {
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
    //$error .= print_r($_SERVER, true);

    echo '<pre>';
    echo $error;
    exit;
}

set_error_handler("exception_error_handler");
set_exception_handler("exception_handler");

// Nettoyage des variables GPC pour ceux qui n'auraient
// toujours pas désactivé les magic quotes
if (get_magic_quotes_gpc())
{
    function strip_slashes_from_user_data(&$array)
    {







|
|







124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
    //$error .= print_r($_SERVER, true);

    echo '<pre>';
    echo $error;
    exit;
}

set_error_handler("Garradin\exception_error_handler");
set_exception_handler("Garradin\exception_handler");

// Nettoyage des variables GPC pour ceux qui n'auraient
// toujours pas désactivé les magic quotes
if (get_magic_quotes_gpc())
{
    function strip_slashes_from_user_data(&$array)
    {
148
149
150
151
152
153
154
155









156










157

158























159
160























161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
    }

    strip_slashes_from_user_data($_GET);
    strip_slashes_from_user_data($_POST);
    strip_slashes_from_user_data($_COOKIE);
}

/*









 * Inclusion des fichiers de base










 */

























require_once GARRADIN_ROOT . '/include/lib.utils.php';
























if (!defined('GARRADIN_INSTALL_PROCESS') && !defined('GARRADIN_UPGRADE_PROCESS'))
{
    if (!file_exists(GARRADIN_DB_FILE))
    {
        utils::redirect('/admin/install.php');
    }

    require_once GARRADIN_ROOT . '/include/class.db.php';
    require_once GARRADIN_ROOT . '/include/class.config.php';
    $config = Garradin_Config::getInstance();

    if (version_compare($config->getVersion(), garradin_version(), '<'))
    {
        utils::redirect('/admin/upgrade.php');
    }
}

?>







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

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







<
<
|








149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234


235
236
237
238
239
240
241
242
243
    }

    strip_slashes_from_user_data($_GET);
    strip_slashes_from_user_data($_POST);
    strip_slashes_from_user_data($_COOKIE);
}

/**
 * Auto-load classes and libs
 */
class Loader
{
    /**
     * Already loaded filenames
     * @var array
     */
    static protected $loaded = array();

    static protected $libs = array(
        'utils',
        'squelette_filtres',
        'static_cache',
        );

    /**
     * Loads a class from the $name
     * @param  stringg $classname
     * @return bool true
     */
    static public function load($classname)
    {
        $classname = ltrim($classname, '\\');
        $filename  = '';
        $namespace = '';

        if ($lastnspos = strripos($classname, '\\')) 
        {
            $namespace = substr($classname, 0, $lastnspos);
            $classname = substr($classname, $lastnspos + 1);

            if ($namespace != 'Garradin')
            {
                $filename  = str_replace('\\', '/', $namespace) . '/';
            }
        }

        $classname = strtolower($classname);

        if (in_array($classname, self::$libs)) {
            $filename = 'lib.' . $classname . '.php';
        } else {
            $filename .= 'class.' . $classname . '.php';
        }

        $filename = GARRADIN_ROOT . '/include/' . $filename;

        if (array_key_exists($filename, self::$loaded))
        {
            return true;
        }

        if (!file_exists($filename)) {
            throw new \Exception('File '.$filename.' doesn\'t exists');
        }

        self::$loaded[$filename] = true;

        require $filename;
    }
}

\spl_autoload_register(array('Garradin\Loader', 'load'), true);

$n = new Membres;

/*
 * Inclusion des fichiers de base
 */

if (!defined('GARRADIN_INSTALL_PROCESS') && !defined('GARRADIN_UPGRADE_PROCESS'))
{
    if (!file_exists(GARRADIN_DB_FILE))
    {
        utils::redirect('/admin/install.php');
    }



    $config = Config::getInstance();

    if (version_compare($config->getVersion(), garradin_version(), '<'))
    {
        utils::redirect('/admin/upgrade.php');
    }
}

?>

Modified include/lib.squelette_filtres.php from [cb6fbac260] to [d5a87498f4].

1


2
3
4
5
6
7
8
<?php



class Squelette_Filtres
{
    static private $g2x = null;
    static private $alt = array();

    static public $filtres_php = array(

>
>







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

namespace Garradin;

class Squelette_Filtres
{
    static private $g2x = null;
    static private $alt = array();

    static public $filtres_php = array(

Modified include/lib.static_cache.php from [c6cac25605] to [7c8d502706].

1


2
3
4
5
6
7
8
<?php



class Static_Cache
{
	const EXPIRE = 3600; // 1h
	const CLEAN_EXPIRE = 86400; // 1 day
	protected static $cache_dir = null;


>
>







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

namespace Garradin;

class Static_Cache
{
	const EXPIRE = 3600; // 1h
	const CLEAN_EXPIRE = 86400; // 1 day
	protected static $cache_dir = null;

Modified include/lib.utils.php from [d0080360fa] to [8d453d0b79].

1
2


3
4
5
6
7
8
9
<?php



class utils
{
    static protected $country_list = null;

    static protected $g2x = null;

    static private $french_date_names = array(


>
>







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

namespace Garradin;

class utils
{
    static protected $country_list = null;

    static protected $g2x = null;

    static private $french_date_names = array(
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
    }

    static public function htmlGarbage2xhtml($str)
    {
        if (!self::$g2x)
        {
            require_once GARRADIN_ROOT . '/include/libs/garbage2xhtml/lib.garbage2xhtml.php';
            self::$g2x = new garbage2xhtml;
            self::$g2x->core_attributes = array('class', 'id', 'title');
        }

        return self::$g2x->process($str);
    }

    static public function htmlSpip($str)







|







324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
    }

    static public function htmlGarbage2xhtml($str)
    {
        if (!self::$g2x)
        {
            require_once GARRADIN_ROOT . '/include/libs/garbage2xhtml/lib.garbage2xhtml.php';
            self::$g2x = new \garbage2xhtml;
            self::$g2x->core_attributes = array('class', 'id', 'title');
        }

        return self::$g2x->process($str);
    }

    static public function htmlSpip($str)
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
        $content = trim($content);

        $content = preg_replace("#(?<!\r)\n#si", "\r\n", $content);

        // Construction des entêtes
        $headers = '';

        $config = Garradin_Config::getInstance();

        if (empty($additional_headers['From']))
        {
            $additional_headers['From'] = '"NE PAS REPONDRE" <'.$config->get('email_envoi_automatique').'>';
        }

        $additional_headers['MIME-Version'] = '1.0';







|







366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
        $content = trim($content);

        $content = preg_replace("#(?<!\r)\n#si", "\r\n", $content);

        // Construction des entêtes
        $headers = '';

        $config = Config::getInstance();

        if (empty($additional_headers['From']))
        {
            $additional_headers['From'] = '"NE PAS REPONDRE" <'.$config->get('email_envoi_automatique').'>';
        }

        $additional_headers['MIME-Version'] = '1.0';
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
        $dir->close();
        return true;
    }

    static public function suggestPassword()
    {
        require_once GARRADIN_ROOT . '/include/libs/passphrase/lib.passphrase.french.php';
        return Passphrase::generate();
    }

    static public function checkIBAN($iban)
    {
        $iban = substr($iban, 4) . substr($iban, 0, 4);
        $iban = str_replace(range('A', 'Z'), range(10, 35), $iban);
        return (bcmod($iban, 97) == 1);







|







419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
        $dir->close();
        return true;
    }

    static public function suggestPassword()
    {
        require_once GARRADIN_ROOT . '/include/libs/passphrase/lib.passphrase.french.php';
        return \Passphrase::generate();
    }

    static public function checkIBAN($iban)
    {
        $iban = substr($iban, 4) . substr($iban, 0, 4);
        $iban = str_replace(range('A', 'Z'), range(10, 35), $iban);
        return (bcmod($iban, 97) == 1);

Modified include/template.php from [8a63c595f0] to [2a741f1d56].

1


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php



require_once GARRADIN_ROOT . '/include/libs/template_lite/class.template.php';

class Garradin_TPL extends Template_Lite
{
    static protected $_instance = null;

    static public function getInstance()
    {
        return self::$_instance ?: self::$_instance = new Garradin_TPL;
    }

    private function __clone()
    {
    }

    public function __construct()

>
>



|





|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

namespace Garradin;

require_once GARRADIN_ROOT . '/include/libs/template_lite/class.template.php';

class Template extends \Template_Lite
{
    static protected $_instance = null;

    static public function getInstance()
    {
        return self::$_instance ?: self::$_instance = new Template;
    }

    private function __clone()
    {
    }

    public function __construct()
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
        $this->assign('www_url', WWW_URL);
        $this->assign('self_url', utils::getSelfUrl());

        $this->assign('is_logged', false);
    }
}

$tpl = Garradin_TPL::getInstance();

if (class_exists('Garradin_Config'))
{
    $tpl->assign('config', Garradin_Config::getInstance()->getConfig());
}
else
{
    $tpl->assign('config', false);
}

function tpl_csrf_field($params)
{
    $name = utils::CSRF_field_name($params['key']);
    $value = utils::CSRF_create($params['key']);

    return '<input type="hidden" name="'.$name.'" value="'.$value.'" />';







|

<
<
<
<
<
<
|
<







33
34
35
36
37
38
39
40
41






42

43
44
45
46
47
48
49
        $this->assign('www_url', WWW_URL);
        $this->assign('self_url', utils::getSelfUrl());

        $this->assign('is_logged', false);
    }
}

$tpl = Template::getInstance();







$tpl->assign('config', Config::getInstance()->getConfig());


function tpl_csrf_field($params)
{
    $name = utils::CSRF_field_name($params['key']);
    $value = utils::CSRF_create($params['key']);

    return '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
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
160
161
162
163
164
165
166
167
168
function tpl_format_droits($params)
{
    $droits = $params['droits'];

    $out = array('connexion' => '', 'inscription' => '', 'membres' => '', 'compta' => '',
        'wiki' => '', 'config' => '');
    $classes = array(
        Garradin_Membres::DROIT_AUCUN   =>  'aucun',
        Garradin_Membres::DROIT_ACCES   =>  'acces',
        Garradin_Membres::DROIT_ECRITURE=>  'ecriture',
        Garradin_Membres::DROIT_ADMIN   =>  'admin',
    );

    foreach ($droits as $cle=>$droit)
    {
        $cle = str_replace('droit_', '', $cle);

        if (array_key_exists($cle, $out))
        {

            $class = $classes[$droit];
            $desc = false;
            $s = false;

            if ($cle == 'connexion')
            {
                if ($droit == Garradin_Membres::DROIT_AUCUN)
                    $desc = 'N\'a pas le droit de se connecter';
                else
                    $desc = 'A le droit de se connecter';
            }
            elseif ($cle == 'inscription')
            {
                if ($droit == Garradin_Membres::DROIT_AUCUN)
                    $desc = 'N\'a pas le droit de s\'inscrire seul';
                else
                    $desc = 'A le droit de s\'inscrire seul';
            }
            elseif ($cle == 'config')
            {
                $s = '&#x2611;';

                if ($droit == Garradin_Membres::DROIT_AUCUN)
                    $desc = 'Ne peut modifier la configuration';
                else
                    $desc = 'Peut modifier la configuration';
            }
            elseif ($cle == 'compta')
            {
                $s = '&euro;';
            }

            if (!$s)
                $s = strtoupper($cle[0]);

            if (!$desc)
            {
                $desc = ucfirst($cle). ' : ';

                if ($droit == Garradin_Membres::DROIT_AUCUN)
                    $desc .= 'Pas accès';
                elseif ($droit == Garradin_Membres::DROIT_ACCES)
                    $desc .= 'Lecture uniquement';
                elseif ($droit == Garradin_Membres::DROIT_ECRITURE)
                    $desc .= 'Lecture & écriture';
                else
                    $desc .= 'Administration';
            }

            $out[$cle] = '<b class="'.$class.' '.$cle.'" title="'
                .htmlspecialchars($desc, ENT_QUOTES, 'UTF-8').'">'.$s.'</b>';







|
|
|
|















|






|








|
















|

|

|







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
160
161
162
163
function tpl_format_droits($params)
{
    $droits = $params['droits'];

    $out = array('connexion' => '', 'inscription' => '', 'membres' => '', 'compta' => '',
        'wiki' => '', 'config' => '');
    $classes = array(
        Membres::DROIT_AUCUN   =>  'aucun',
        Membres::DROIT_ACCES   =>  'acces',
        Membres::DROIT_ECRITURE=>  'ecriture',
        Membres::DROIT_ADMIN   =>  'admin',
    );

    foreach ($droits as $cle=>$droit)
    {
        $cle = str_replace('droit_', '', $cle);

        if (array_key_exists($cle, $out))
        {

            $class = $classes[$droit];
            $desc = false;
            $s = false;

            if ($cle == 'connexion')
            {
                if ($droit == Membres::DROIT_AUCUN)
                    $desc = 'N\'a pas le droit de se connecter';
                else
                    $desc = 'A le droit de se connecter';
            }
            elseif ($cle == 'inscription')
            {
                if ($droit == Membres::DROIT_AUCUN)
                    $desc = 'N\'a pas le droit de s\'inscrire seul';
                else
                    $desc = 'A le droit de s\'inscrire seul';
            }
            elseif ($cle == 'config')
            {
                $s = '&#x2611;';

                if ($droit == Membres::DROIT_AUCUN)
                    $desc = 'Ne peut modifier la configuration';
                else
                    $desc = 'Peut modifier la configuration';
            }
            elseif ($cle == 'compta')
            {
                $s = '&euro;';
            }

            if (!$s)
                $s = strtoupper($cle[0]);

            if (!$desc)
            {
                $desc = ucfirst($cle). ' : ';

                if ($droit == Membres::DROIT_AUCUN)
                    $desc .= 'Pas accès';
                elseif ($droit == Membres::DROIT_ACCES)
                    $desc .= 'Lecture uniquement';
                elseif ($droit == Membres::DROIT_ECRITURE)
                    $desc .= 'Lecture & écriture';
                else
                    $desc .= 'Administration';
            }

            $out[$cle] = '<b class="'.$class.' '.$cle.'" title="'
                .htmlspecialchars($desc, ENT_QUOTES, 'UTF-8').'">'.$s.'</b>';
178
179
180
181
182
183
184

185

186
187
188
189
190
191
192
    $str = utils::htmlSpip($str);
    $str = utils::htmlGarbage2xhtml($str);
    return $str;
}

function tpl_liens_wiki($str, $prefix)
{

    return preg_replace('!<a href="([^/.]+)">!ie', '"<a href=\"".$prefix.Garradin_Wiki::transformTitleToURI("$1")."\">"', $str);

}

function tpl_pagination($params)
{
    if (!isset($params['url']) || !isset($params['page']) || !isset($params['bypage']) || !isset($params['total']))
        throw new BadFunctionCallException("Paramètre manquant pour pagination");








>
|
>







173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
    $str = utils::htmlSpip($str);
    $str = utils::htmlGarbage2xhtml($str);
    return $str;
}

function tpl_liens_wiki($str, $prefix)
{
    return preg_replace_callback('!<a href="([^/.]+)">!i', function ($matches) use ($prefix) {
        return '<a href="' . $prefix . Wiki::transformTitleToURI($matches[1]) . '">';
    }, $str);
}

function tpl_pagination($params)
{
    if (!isset($params['url']) || !isset($params['page']) || !isset($params['bypage']) || !isset($params['total']))
        throw new BadFunctionCallException("Paramètre manquant pour pagination");

352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
}

function escape_money($number)
{
    return number_format((float)$number, 2, ',', ' ');
}

$tpl->register_function('csrf_field', 'tpl_csrf_field');
$tpl->register_function('form_field', 'tpl_form_field');
$tpl->register_function('select_compte', 'tpl_select_compte');

$tpl->register_function('format_droits', 'tpl_format_droits');

$tpl->register_function('pagination', 'tpl_pagination');

$tpl->register_function('diff', 'tpl_diff');

$tpl->register_modifier('get_country_name', array('utils', 'getCountryName'));
$tpl->register_modifier('format_tel', 'tpl_format_tel');
$tpl->register_modifier('format_wiki', 'tpl_format_wiki');
$tpl->register_modifier('liens_wiki', 'tpl_liens_wiki');
$tpl->register_modifier('escape_money', 'escape_money');
$tpl->register_modifier('abs', 'abs');

//$tpl->register_modifier('retard_cotisation', array('Garradin_Membres', 'checkCotisation'));

$tpl->register_modifier('strftime_fr', 'tpl_strftime_fr');
$tpl->register_modifier('date_fr', 'tpl_date_fr');

?>







|
|
|

|

|

|

|
|
|
|
|


|

|
|


349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
}

function escape_money($number)
{
    return number_format((float)$number, 2, ',', ' ');
}

$tpl->register_function('csrf_field', 'Garradin\tpl_csrf_field');
$tpl->register_function('form_field', 'Garradin\tpl_form_field');
$tpl->register_function('select_compte', 'Garradin\tpl_select_compte');

$tpl->register_function('format_droits', 'Garradin\tpl_format_droits');

$tpl->register_function('pagination', 'Garradin\tpl_pagination');

$tpl->register_function('diff', 'Garradin\tpl_diff');

$tpl->register_modifier('get_country_name', array('Garradin\utils', 'getCountryName'));
$tpl->register_modifier('format_tel', 'Garradin\tpl_format_tel');
$tpl->register_modifier('format_wiki', 'Garradin\tpl_format_wiki');
$tpl->register_modifier('liens_wiki', 'Garradin\tpl_liens_wiki');
$tpl->register_modifier('escape_money', 'Garradin\escape_money');
$tpl->register_modifier('abs', 'abs');

//$tpl->register_modifier('retard_cotisation', array('Membres', 'checkCotisation'));

$tpl->register_modifier('strftime_fr', 'Garradin\tpl_strftime_fr');
$tpl->register_modifier('date_fr', 'Garradin\tpl_date_fr');

?>

Modified templates/admin/_head.tpl from [d05ea277a4] to [2c361b7758].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{if empty($is_popup)}
<div class="header">
    <h1>{$title|escape}</h1>

    {if $is_logged}
    <ul class="menu">
        <li class="home{if $current == 'home'} current{/if}"><a href="{$www_url}admin/">Accueil</a></li>
        {if $user.droits.membres >= Garradin_Membres::DROIT_ACCES}
            <li class="list_members{if $current == 'membres'} current{/if}"><a href="{$www_url}admin/membres/">Membres <small>({$nb_membres|escape})</small></a>
            {if $user.droits.membres >= Garradin_Membres::DROIT_ECRITURE}
            <ul>
                <li class="add_member{if $current == 'membres/ajouter'} current{/if}"><a href="{$www_url}admin/membres/ajouter.php">Ajouter</a></li>
                {if $user.droits.membres >= Garradin_Membres::DROIT_ADMIN}
                <li class="member_cats{if $current == 'membres/categories'} current{/if}"><a href="{$www_url}admin/membres/categories.php">Catégories</a></li>
                <li class="members_mail{if $current == 'membres/message_collectif'} current{/if}"><a href="{$www_url}admin/membres/message_collectif.php">Message collectif</a></li>
                {/if}
            </ul>
            {/if}
            </li>
        {/if}
        {if $user.droits.compta >= Garradin_Membres::DROIT_ACCES}
            <li class="compta{if $current == 'compta'} current{/if}"><a href="{$www_url}admin/compta/">Comptabilité <small>[beta]</small></a>
            <ul>
            {if $user.droits.compta >= Garradin_Membres::DROIT_ECRITURE}
                <li class="compta_saisie{if $current == 'compta/saisie'} current{/if}"><a href="{$www_url}admin/compta/operations/saisir.php">Saisie</a></li>
            {/if}
                <li class="compta_gestion{if $current == 'compta/gestion'} current{/if}"><a href="{$www_url}admin/compta/operations/">Suivi des opérations</a></li>
                <li class="compta_banques{if $current == 'compta/banques'} current{/if}"><a href="{$www_url}admin/compta/banques/">Banques &amp; caisse</a></li>
            {if $user.droits.compta >= Garradin_Membres::DROIT_ADMIN}
                <li class="compta_cats{if $current == 'compta/categories'} current{/if}"><a href="{$www_url}admin/compta/categories/">Catégories &amp; comptes</a></li>
            {/if}
                <li class="compta_exercices{if $current == 'compta/exercices'} current{/if}"><a href="{$www_url}admin/compta/exercices/">Exercices</a></li>
            </ul>
            </li>
        {/if}
        {if $user.droits.wiki >= Garradin_Membres::DROIT_ACCES}
            <li class="wiki{if $current == 'wiki'} current{/if}"><a href="{$www_url}admin/wiki/">Wiki</a>
            <ul>
                <li class="wiki_recent{if $current == 'wiki/recent'} current{/if}"><a href="{$www_url}admin/wiki/recent.php">Dernières modifications</a>
                <li class="wiki_chercher{if $current == 'wiki/chercher'} current{/if}"><a href="{$www_url}admin/wiki/chercher.php">Recherche</a>
                {if $user.droits.wiki >= Garradin_Membres::DROIT_ECRITURE}
                {/if}
                {*<li class="wiki_suivi{if $current == 'wiki/suivi'} current{/if}"><a href="{$www_url}admin/wiki/suivi.php">Mes pages suivies</a>*}
                {*<li class="wiki_contribution{if $current == 'wiki/contribution'} current{/if}"><a href="{$www_url}admin/wiki/contributions.php">Mes contributions</a>*}
            </ul>
            </li>
        {/if}
        {if $user.droits.config >= Garradin_Membres::DROIT_ADMIN}
            <li class="config{if $current == 'config'} current{/if}"><a href="{$www_url}admin/config/">Configuration</a>
        {/if}
        {if count($config.champs_modifiables_membre) > 0}
            <li class="mes_infos{if $current == 'mes_infos'} current{/if}"><a href="{$www_url}admin/mes_infos.php">Mes infos</a>
        {/if}
        <li class="logout"><a href="{$www_url}admin/logout.php">Déconnexion</a></li>
    </ul>
    {/if}
</div>
{/if}

<div class="page">







|

|


|







|


|




|






|




|






|












17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{if empty($is_popup)}
<div class="header">
    <h1>{$title|escape}</h1>

    {if $is_logged}
    <ul class="menu">
        <li class="home{if $current == 'home'} current{/if}"><a href="{$www_url}admin/">Accueil</a></li>
        {if $user.droits.membres >= Garradin\Membres::DROIT_ACCES}
            <li class="list_members{if $current == 'membres'} current{/if}"><a href="{$www_url}admin/membres/">Membres <small>({$nb_membres|escape})</small></a>
            {if $user.droits.membres >= Garradin\Membres::DROIT_ECRITURE}
            <ul>
                <li class="add_member{if $current == 'membres/ajouter'} current{/if}"><a href="{$www_url}admin/membres/ajouter.php">Ajouter</a></li>
                {if $user.droits.membres >= Garradin\Membres::DROIT_ADMIN}
                <li class="member_cats{if $current == 'membres/categories'} current{/if}"><a href="{$www_url}admin/membres/categories.php">Catégories</a></li>
                <li class="members_mail{if $current == 'membres/message_collectif'} current{/if}"><a href="{$www_url}admin/membres/message_collectif.php">Message collectif</a></li>
                {/if}
            </ul>
            {/if}
            </li>
        {/if}
        {if $user.droits.compta >= Garradin\Membres::DROIT_ACCES}
            <li class="compta{if $current == 'compta'} current{/if}"><a href="{$www_url}admin/compta/">Comptabilité <small>[beta]</small></a>
            <ul>
            {if $user.droits.compta >= Garradin\Membres::DROIT_ECRITURE}
                <li class="compta_saisie{if $current == 'compta/saisie'} current{/if}"><a href="{$www_url}admin/compta/operations/saisir.php">Saisie</a></li>
            {/if}
                <li class="compta_gestion{if $current == 'compta/gestion'} current{/if}"><a href="{$www_url}admin/compta/operations/">Suivi des opérations</a></li>
                <li class="compta_banques{if $current == 'compta/banques'} current{/if}"><a href="{$www_url}admin/compta/banques/">Banques &amp; caisse</a></li>
            {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
                <li class="compta_cats{if $current == 'compta/categories'} current{/if}"><a href="{$www_url}admin/compta/categories/">Catégories &amp; comptes</a></li>
            {/if}
                <li class="compta_exercices{if $current == 'compta/exercices'} current{/if}"><a href="{$www_url}admin/compta/exercices/">Exercices</a></li>
            </ul>
            </li>
        {/if}
        {if $user.droits.wiki >= Garradin\Membres::DROIT_ACCES}
            <li class="wiki{if $current == 'wiki'} current{/if}"><a href="{$www_url}admin/wiki/">Wiki</a>
            <ul>
                <li class="wiki_recent{if $current == 'wiki/recent'} current{/if}"><a href="{$www_url}admin/wiki/recent.php">Dernières modifications</a>
                <li class="wiki_chercher{if $current == 'wiki/chercher'} current{/if}"><a href="{$www_url}admin/wiki/chercher.php">Recherche</a>
                {if $user.droits.wiki >= Garradin\Membres::DROIT_ECRITURE}
                {/if}
                {*<li class="wiki_suivi{if $current == 'wiki/suivi'} current{/if}"><a href="{$www_url}admin/wiki/suivi.php">Mes pages suivies</a>*}
                {*<li class="wiki_contribution{if $current == 'wiki/contribution'} current{/if}"><a href="{$www_url}admin/wiki/contributions.php">Mes contributions</a>*}
            </ul>
            </li>
        {/if}
        {if $user.droits.config >= Garradin\Membres::DROIT_ADMIN}
            <li class="config{if $current == 'config'} current{/if}"><a href="{$www_url}admin/config/">Configuration</a>
        {/if}
        {if count($config.champs_modifiables_membre) > 0}
            <li class="mes_infos{if $current == 'mes_infos'} current{/if}"><a href="{$www_url}admin/mes_infos.php">Mes infos</a>
        {/if}
        <li class="logout"><a href="{$www_url}admin/logout.php">Déconnexion</a></li>
    </ul>
    {/if}
</div>
{/if}

<div class="page">

Modified templates/admin/compta/banques/index.tpl from [403ed3db83] to [b89f5aedf9].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{include file="admin/_head.tpl" title="Comptes bancaires" current="compta/banques"}

<ul class="actions">
    <li class="current"><a href="{$www_url}admin/compta/banques/">Comptes bancaires</a></li>
    <li><a href="{$www_url}admin/compta/comptes/journal.php?id={Garradin_Compta_Comptes::CAISSE}">Journal de caisse</a></li>
    {if $user.droits.compta >= Garradin_Membres::DROIT_ADMIN}<li><strong><a href="{$www_url}admin/compta/banques/ajouter.php">Ajouter un compte bancaire</a></strong></li>{/if}
</ul>

    {if !empty($liste)}
        <dl class="catList">
        {foreach from=$liste item="compte"}
            <dt>{$compte.libelle|escape} {if !empty($compte.banque)}({$compte.banque|escape}){/if}</dt>
            <dd class="desc">
                IBAN : {$compte.iban|escape|format_iban}<br />
                BIC : {$compte.bic|escape}<br />
                {$compte.iban|escape|format_rib}
            </dd>
            <dd class="desc">Solde : {$compte.solde|escape_money} {$config.monnaie|escape}</dd>
            <dd class="actions">
                <a href="{$www_url}admin/compta/comptes/journal.php?id={$compte.id|escape}">Journal</a>
            {if $user.droits.compta >= Garradin_Membres::DROIT_ADMIN}
                | <a href="{$www_url}admin/compta/banques/modifier.php?id={$compte.id|escape}">Modifier</a>
                | <a href="{$www_url}admin/compta/banques/supprimer.php?id={$compte.id|escape}">Supprimer</a>
            {/if}
            </dd>
        {/foreach}
        </dl>
    {else}
        <p class="alert">
            Aucun compte bancaire trouvé.
        </p>
    {/if}

{include file="admin/_foot.tpl"}




|
|














|













1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{include file="admin/_head.tpl" title="Comptes bancaires" current="compta/banques"}

<ul class="actions">
    <li class="current"><a href="{$www_url}admin/compta/banques/">Comptes bancaires</a></li>
    <li><a href="{$www_url}admin/compta/comptes/journal.php?id={Garradin\Compta_Comptes::CAISSE}">Journal de caisse</a></li>
    {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}<li><strong><a href="{$www_url}admin/compta/banques/ajouter.php">Ajouter un compte bancaire</a></strong></li>{/if}
</ul>

    {if !empty($liste)}
        <dl class="catList">
        {foreach from=$liste item="compte"}
            <dt>{$compte.libelle|escape} {if !empty($compte.banque)}({$compte.banque|escape}){/if}</dt>
            <dd class="desc">
                IBAN : {$compte.iban|escape|format_iban}<br />
                BIC : {$compte.bic|escape}<br />
                {$compte.iban|escape|format_rib}
            </dd>
            <dd class="desc">Solde : {$compte.solde|escape_money} {$config.monnaie|escape}</dd>
            <dd class="actions">
                <a href="{$www_url}admin/compta/comptes/journal.php?id={$compte.id|escape}">Journal</a>
            {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
                | <a href="{$www_url}admin/compta/banques/modifier.php?id={$compte.id|escape}">Modifier</a>
                | <a href="{$www_url}admin/compta/banques/supprimer.php?id={$compte.id|escape}">Supprimer</a>
            {/if}
            </dd>
        {/foreach}
        </dl>
    {else}
        <p class="alert">
            Aucun compte bancaire trouvé.
        </p>
    {/if}

{include file="admin/_foot.tpl"}

Modified templates/admin/compta/categories/ajouter.tpl from [226c1b73f8] to [1bbfd84c3c].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

    <fieldset>
        <legend>Ajouter une catégorie</legend>
        <dl>
            <dt><label for="f_type">Type</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select name="type" id="f_type">
                    <option value="{Garradin_Compta_Categories::RECETTES}"{if $type == Garradin_Compta_Categories::RECETTES} selected="selected"{/if}>Recette</option>
                    <option value="{Garradin_Compta_Categories::DEPENSES}"{if $type == Garradin_Compta_Categories::DEPENSES} selected="selected"{/if}>Dépense</option>
                </select>
            </dd>
            <dt><label for="f_intitule">Intitulé</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="intitule" id="f_intitule" value="{form_field name=intitule}" /></dd>
            <dt><label for="f_description">Description</label></dt>
            <dd><textarea name="description" id="f_description" rows="4" cols="30">{form_field name=description}</textarea></dd>
            <dt><label for="f_compte">Compte affecté</label> <b title="(Champ obligatoire)">obligatoire</b></dt>







|
|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

    <fieldset>
        <legend>Ajouter une catégorie</legend>
        <dl>
            <dt><label for="f_type">Type</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select name="type" id="f_type">
                    <option value="{Garradin\Compta_Categories::RECETTES}"{if $type == Garradin\Compta_Categories::RECETTES} selected="selected"{/if}>Recette</option>
                    <option value="{Garradin\Compta_Categories::DEPENSES}"{if $type == Garradin\Compta_Categories::DEPENSES} selected="selected"{/if}>Dépense</option>
                </select>
            </dd>
            <dt><label for="f_intitule">Intitulé</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="intitule" id="f_intitule" value="{form_field name=intitule}" /></dd>
            <dt><label for="f_description">Description</label></dt>
            <dd><textarea name="description" id="f_description" rows="4" cols="30">{form_field name=description}</textarea></dd>
            <dt><label for="f_compte">Compte affecté</label> <b title="(Champ obligatoire)">obligatoire</b></dt>

Modified templates/admin/compta/categories/index.tpl from [3b8458015a] to [9500d269a7].

1
2
3
4
5
6
7
8
9
10
11
12
{include file="admin/_head.tpl" title="Catégories" current="compta/categories"}

<ul class="actions">
    <li{if $type == Garradin_Compta_Categories::RECETTES} class="current"{/if}><a href="?recettes">Recettes</a></li>
    <li{if $type == Garradin_Compta_Categories::DEPENSES} class="current"{/if}><a href="?depenses">Dépenses</a></li>
    <li><strong><a href="{$www_url}admin/compta/categories/ajouter.php">Ajouter une catégorie</a></strong></li>
    <li><em><a href="{$www_url}admin/compta/comptes/">Plan comptable</a></em></li>
</ul>

    {if !empty($liste)}
        <dl class="catList">
        {foreach from=$liste item="cat"}



|
|







1
2
3
4
5
6
7
8
9
10
11
12
{include file="admin/_head.tpl" title="Catégories" current="compta/categories"}

<ul class="actions">
    <li{if $type == Garradin\Compta_Categories::RECETTES} class="current"{/if}><a href="?recettes">Recettes</a></li>
    <li{if $type == Garradin\Compta_Categories::DEPENSES} class="current"{/if}><a href="?depenses">Dépenses</a></li>
    <li><strong><a href="{$www_url}admin/compta/categories/ajouter.php">Ajouter une catégorie</a></strong></li>
    <li><em><a href="{$www_url}admin/compta/comptes/">Plan comptable</a></em></li>
</ul>

    {if !empty($liste)}
        <dl class="catList">
        {foreach from=$liste item="cat"}

Modified templates/admin/compta/comptes/journal.tpl from [fb338237e5] to [56e444f799].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        </tr>
    </thead>
    <tbody>
    {foreach from=$journal item="ligne"}
        <tr>
            <td><a href="{$admin_url}compta/operations/voir.php?id={$ligne.id|escape}">{$ligne.id|escape}</a></td>
            <td class="actions">
            {if $user.droits.compta >= Garradin_Membres::DROIT_ADMIN}
                <a class="icn" href="{$admin_url}compta/operations/modifier.php?id={$ligne.id|escape}">✎</a>
            {/if}
            </td>
            <td>{$ligne.date|date_fr:'d/m/Y'|escape}</td>
            <td>{if $ligne.compte_credit == $compte.id}{$credit}{else}{$debit}{/if}{$ligne.montant|escape_money}</td>
            <td>{$ligne.solde|escape_money}</td>
            <th>{$ligne.libelle|escape}</th>







|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        </tr>
    </thead>
    <tbody>
    {foreach from=$journal item="ligne"}
        <tr>
            <td><a href="{$admin_url}compta/operations/voir.php?id={$ligne.id|escape}">{$ligne.id|escape}</a></td>
            <td class="actions">
            {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
                <a class="icn" href="{$admin_url}compta/operations/modifier.php?id={$ligne.id|escape}">✎</a>
            {/if}
            </td>
            <td>{$ligne.date|date_fr:'d/m/Y'|escape}</td>
            <td>{if $ligne.compte_credit == $compte.id}{$credit}{else}{$debit}{/if}{$ligne.montant|escape_money}</td>
            <td>{$ligne.solde|escape_money}</td>
            <th>{$ligne.libelle|escape}</th>

Modified templates/admin/compta/exercices/index.tpl from [1a7b7857d4] to [2910a1324e].

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
        </dd>
        <dd class="desc">
            <a href="{$www_url}admin/compta/exercices/journal.php?id={$exercice.id|escape}">Journal général</a>
            | <a href="{$www_url}admin/compta/exercices/grand_livre.php?id={$exercice.id|escape}">Grand livre</a>
            | <a href="{$www_url}admin/compta/exercices/compte_resultat.php?id={$exercice.id|escape}">Compte de résultat</a>
            | <a href="{$www_url}admin/compta/exercices/bilan.php?id={$exercice.id|escape}">Bilan</a>
        </dd>
        {if $user.droits.compta >= Garradin_Membres::DROIT_ADMIN}
        <dd class="actions">
            {if !$exercice.cloture}
            <a href="{$www_url}admin/compta/exercices/modifier.php?id={$exercice.id|escape}">Modifier</a>
            | <a href="{$www_url}admin/compta/exercices/cloturer.php?id={$exercice.id|escape}">Clôturer</a>
            | <a href="{$www_url}admin/compta/exercices/supprimer.php?id={$exercice.id|escape}">Supprimer</a>
            {/if}
        </dd>







|







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
        </dd>
        <dd class="desc">
            <a href="{$www_url}admin/compta/exercices/journal.php?id={$exercice.id|escape}">Journal général</a>
            | <a href="{$www_url}admin/compta/exercices/grand_livre.php?id={$exercice.id|escape}">Grand livre</a>
            | <a href="{$www_url}admin/compta/exercices/compte_resultat.php?id={$exercice.id|escape}">Compte de résultat</a>
            | <a href="{$www_url}admin/compta/exercices/bilan.php?id={$exercice.id|escape}">Bilan</a>
        </dd>
        {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
        <dd class="actions">
            {if !$exercice.cloture}
            <a href="{$www_url}admin/compta/exercices/modifier.php?id={$exercice.id|escape}">Modifier</a>
            | <a href="{$www_url}admin/compta/exercices/cloturer.php?id={$exercice.id|escape}">Clôturer</a>
            | <a href="{$www_url}admin/compta/exercices/supprimer.php?id={$exercice.id|escape}">Supprimer</a>
            {/if}
        </dd>

Modified templates/admin/compta/index.tpl from [c78e6d3fcf] to [9550307577].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{include file="admin/_head.tpl" title="Comptabilité" current="compta"}

<p class="alert">
    <strong>Attention !</strong>
    La comptabilité est une fonctionnalité en beta,
    il est déconseillé pour le moment de l'utiliser pour la
    comptabilité réelle de votre association.<br />
    Vous êtes cependant encouragé à la tester et à faire part
    de votre retour sur le site de <a href="http://dev.kd2.org/garradin/">Garradin</a>.
</p>

{if $user.droits.compta >= Garradin_Membres::DROIT_ADMIN}
<ul class="actions">
    <li><a href="{$www_url}admin/compta/import.php">Import / export</a></li>
</ul>
{/if}

<p>
    <img src="{$www_url}admin/compta/graph.php?g=recettes_depenses" />
    <img src="{$www_url}admin/compta/graph.php?g=banques_caisses" />
    <img src="{$www_url}admin/compta/graph.php?g=dettes" />
</p>

{include file="admin/_foot.tpl"}











|












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{include file="admin/_head.tpl" title="Comptabilité" current="compta"}

<p class="alert">
    <strong>Attention !</strong>
    La comptabilité est une fonctionnalité en beta,
    il est déconseillé pour le moment de l'utiliser pour la
    comptabilité réelle de votre association.<br />
    Vous êtes cependant encouragé à la tester et à faire part
    de votre retour sur le site de <a href="http://dev.kd2.org/garradin/">Garradin</a>.
</p>

{if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
<ul class="actions">
    <li><a href="{$www_url}admin/compta/import.php">Import / export</a></li>
</ul>
{/if}

<p>
    <img src="{$www_url}admin/compta/graph.php?g=recettes_depenses" />
    <img src="{$www_url}admin/compta/graph.php?g=banques_caisses" />
    <img src="{$www_url}admin/compta/graph.php?g=dettes" />
</p>

{include file="admin/_foot.tpl"}

Modified templates/admin/compta/operations/index.tpl from [34794d89f6] to [e60008a93a].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{include file="admin/_head.tpl" title="Suivi des opérations" current="compta/gestion"}

<ul class="actions">
    <li class="recettes{if $type == Garradin_Compta_Categories::RECETTES} current{/if}"><a href="{$www_url}admin/compta/operations/?recettes">Recettes</a></li>
    <li class="depenses{if $type == Garradin_Compta_Categories::DEPENSES} current{/if}"><a href="{$www_url}admin/compta/operations/?depenses">Dépenses</a></li>
    <li class="autres{if $type == Garradin_Compta_Categories::AUTRES} current{/if}"><a href="{$www_url}admin/compta/operations/?autres">Autres</a></li>
    <li><a href="{$www_url}admin/compta/comptes/journal.php?id={Garradin_Compta_Comptes::CAISSE}">Journal de caisse</a></li>
    {*<li><a href="{$www_url}admin/compta/operations/recherche.php">Recherche d'opération</a></li>*}
</ul>

{if $type != Garradin_Compta_Categories::AUTRES}
<form method="get" action="{$self_url}">
    <fieldset>
        <legend>Filtrer par catégorie</legend>
        <select name="cat" onchange="if (!this.value) location.href = '?{if $type == Garradin_Compta_Categories::RECETTES}recettes{else}depenses{/if}'; else this.form.submit();">
            <option value="">-- Toutes</option>
        {foreach from=$liste_cats item="cat"}
            <option value="{$cat.id|escape}"{if $cat.id == $categorie.id} selected="selected"{/if}>{$cat.intitule|escape}</option>
        {/foreach}
        </select>
        <input type="submit" value="OK" />
    </fieldset>



|
|
|
|



|



|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
{include file="admin/_head.tpl" title="Suivi des opérations" current="compta/gestion"}

<ul class="actions">
    <li class="recettes{if $type == Garradin\Compta_Categories::RECETTES} current{/if}"><a href="{$www_url}admin/compta/operations/?recettes">Recettes</a></li>
    <li class="depenses{if $type == Garradin\Compta_Categories::DEPENSES} current{/if}"><a href="{$www_url}admin/compta/operations/?depenses">Dépenses</a></li>
    <li class="autres{if $type == Garradin\Compta_Categories::AUTRES} current{/if}"><a href="{$www_url}admin/compta/operations/?autres">Autres</a></li>
    <li><a href="{$www_url}admin/compta/comptes/journal.php?id={Garradin\Compta_Comptes::CAISSE}">Journal de caisse</a></li>
    {*<li><a href="{$www_url}admin/compta/operations/recherche.php">Recherche d'opération</a></li>*}
</ul>

{if $type != Garradin\Compta_Categories::AUTRES}
<form method="get" action="{$self_url}">
    <fieldset>
        <legend>Filtrer par catégorie</legend>
        <select name="cat" onchange="if (!this.value) location.href = '?{if $type == Garradin\Compta_Categories::RECETTES}recettes{else}depenses{/if}'; else this.form.submit();">
            <option value="">-- Toutes</option>
        {foreach from=$liste_cats item="cat"}
            <option value="{$cat.id|escape}"{if $cat.id == $categorie.id} selected="selected"{/if}>{$cat.intitule|escape}</option>
        {/foreach}
        </select>
        <input type="submit" value="OK" />
    </fieldset>
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
        {/if}
    </colgroup>
    <tbody>
    {foreach from=$journal item="ligne"}
        <tr>
            <td><a href="{$admin_url}compta/operations/voir.php?id={$ligne.id|escape}">{$ligne.id|escape}</a></td>
            <td class="actions">
            {if $user.droits.compta >= Garradin_Membres::DROIT_ADMIN}
                <a class="icn" href="{$admin_url}compta/operations/modifier.php?id={$ligne.id|escape}">✎</a>
            {/if}
            </td>
            <td>{$ligne.date|date_fr:'d/m/Y'|escape}</td>
            <td>{$ligne.montant|escape_money} {$config.monnaie|escape}</td>
            <th>{$ligne.libelle|escape}</th>
            {if !$categorie && $type}







|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
        {/if}
    </colgroup>
    <tbody>
    {foreach from=$journal item="ligne"}
        <tr>
            <td><a href="{$admin_url}compta/operations/voir.php?id={$ligne.id|escape}">{$ligne.id|escape}</a></td>
            <td class="actions">
            {if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
                <a class="icn" href="{$admin_url}compta/operations/modifier.php?id={$ligne.id|escape}">✎</a>
            {/if}
            </td>
            <td>{$ligne.date|date_fr:'d/m/Y'|escape}</td>
            <td>{$ligne.montant|escape_money} {$config.monnaie|escape}</td>
            <th>{$ligne.libelle|escape}</th>
            {if !$categorie && $type}

Modified templates/admin/compta/operations/modifier.tpl from [5811422558] to [9ed77c42d7].

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
            </dd>
            <dt class="cheque"><label for="f_numero_cheque">Numéro de chèque</label></dt>
            <dd class="cheque"><input type="text" name="numero_cheque" id="f_numero_cheque" value="{form_field name=numero_cheque data=$operation}" /></dd>
            <dt class="banque"><label for="f_banque">Compte bancaire</label></dt>
            <dd class="banque">
                <select name="banque" id="f_banque">
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id|escape}"{if ($type == Garradin_Compta_Categories::DEPENSES && $compte.id == $operation.compte_credit) || $compte.id == $operation.compte_debit} selected="selected"{/if}>{$compte.libelle|escape} - {$compte.banque|escape}</option>
                {/foreach}
                </select>
            </dd>
{/if}

            <dt><label for="f_numero_piece">Numéro de pièce comptable</label></dt>
            <dd><input type="text" name="numero_piece" id="f_numero_piece" value="{form_field name=numero_piece data=$operation}" /></dd>







|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
            </dd>
            <dt class="cheque"><label for="f_numero_cheque">Numéro de chèque</label></dt>
            <dd class="cheque"><input type="text" name="numero_cheque" id="f_numero_cheque" value="{form_field name=numero_cheque data=$operation}" /></dd>
            <dt class="banque"><label for="f_banque">Compte bancaire</label></dt>
            <dd class="banque">
                <select name="banque" id="f_banque">
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id|escape}"{if ($type == Garradin\Compta_Categories::DEPENSES && $compte.id == $operation.compte_credit) || $compte.id == $operation.compte_debit} selected="selected"{/if}>{$compte.libelle|escape} - {$compte.banque|escape}</option>
                {/foreach}
                </select>
            </dd>
{/if}

            <dt><label for="f_numero_piece">Numéro de pièce comptable</label></dt>
            <dd><input type="text" name="numero_piece" id="f_numero_piece" value="{form_field name=numero_piece data=$operation}" /></dd>

Modified templates/admin/compta/operations/saisir.tpl from [aa309e6b6b] to [d28986fc85].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    <p class="confirm">
        L'opération numéro <a href="{$www_url}admin/compta/operations/voir.php?id={$ok|escape}">{$ok|escape}</a> a été ajoutée.
        (<a href="{$www_url}admin/compta/operations/voir.php?id={$ok|escape}">Voir l'opération</a>)
    </p>
{/if}

<ul class="actions">
    <li{if $type == Garradin_Compta_Categories::RECETTES} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?recette">Recette</a></li>
    <li{if $type == Garradin_Compta_Categories::DEPENSES} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?depense">Dépense</a></li>
    <li{if $type === 'virement'} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?virement">Virement interne</a></li>
    <li{if $type === 'dette'} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?dette">Dette</a></li>
    <li{if is_null($type)} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?avance">Saisie avancée</a></li>
</ul>

<form method="post" action="{$self_url|escape}">








|
|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
    <p class="confirm">
        L'opération numéro <a href="{$www_url}admin/compta/operations/voir.php?id={$ok|escape}">{$ok|escape}</a> a été ajoutée.
        (<a href="{$www_url}admin/compta/operations/voir.php?id={$ok|escape}">Voir l'opération</a>)
    </p>
{/if}

<ul class="actions">
    <li{if $type == Garradin\Compta_Categories::RECETTES} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?recette">Recette</a></li>
    <li{if $type == Garradin\Compta_Categories::DEPENSES} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?depense">Dépense</a></li>
    <li{if $type === 'virement'} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?virement">Virement interne</a></li>
    <li{if $type === 'dette'} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?dette">Dette</a></li>
    <li{if is_null($type)} class="current"{/if}><a href="{$www_url}admin/compta/operations/saisir.php?avance">Saisie avancée</a></li>
</ul>

<form method="post" action="{$self_url|escape}">

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
            <dd>
                {select_compte comptes=$comptes name="compte_credit"}
            </dd>
{elseif $type === 'virement'}
            <dt><label for="f_compte1">Compte débité</label></dt>
            <dd>
                <select name="compte1" id="f_compte1">
                    <option value="{Garradin_Compta_Comptes::CAISSE}">Caisse</option>
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id|escape}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle|escape} - {$compte.banque|escape}</option>
                {/foreach}
                </select>
            </dd>
            <dt><label for="f_compte2">Compte crédité</label></dt>
            <dd>
                <select name="compte2" id="f_compte2">
                    <option value="{Garradin_Compta_Comptes::CAISSE}">Caisse</option>
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id|escape}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle|escape} - {$compte.banque|escape}</option>
                {/foreach}
                </select>
            </dd>
{elseif $type === 'dette'}
            <dt><label for="f_compte_usager">Type de dette</label></dt>







|








|







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
            <dd>
                {select_compte comptes=$comptes name="compte_credit"}
            </dd>
{elseif $type === 'virement'}
            <dt><label for="f_compte1">Compte débité</label></dt>
            <dd>
                <select name="compte1" id="f_compte1">
                    <option value="{Garradin\Compta_Comptes::CAISSE}">Caisse</option>
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id|escape}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle|escape} - {$compte.banque|escape}</option>
                {/foreach}
                </select>
            </dd>
            <dt><label for="f_compte2">Compte crédité</label></dt>
            <dd>
                <select name="compte2" id="f_compte2">
                    <option value="{Garradin\Compta_Comptes::CAISSE}">Caisse</option>
                {foreach from=$comptes_bancaires item="compte"}
                    <option value="{$compte.id|escape}"{if $compte.id == $banque} selected="selected"{/if}>{$compte.libelle|escape} - {$compte.banque|escape}</option>
                {/foreach}
                </select>
            </dd>
{elseif $type === 'dette'}
            <dt><label for="f_compte_usager">Type de dette</label></dt>
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
            <dt><label for="f_numero_piece">Numéro de pièce comptable</label></dt>
            <dd><input type="text" name="numero_piece" id="f_numero_piece" value="{form_field name=numero_piece}" /></dd>
            <dt><label for="f_remarques">Remarques</label></dt>
            <dd><textarea name="remarques" id="f_remarques" rows="4" cols="30">{form_field name=remarques}</textarea></dd>
        </dl>
    </fieldset>

{if $type == Garradin_Compta_Categories::DEPENSES || $type == Garradin_Compta_Categories::RECETTES || $type == 'dette'}
    <fieldset>
        <legend>Catégorie</legend>
        <dl class="catList">
        {foreach from=$categories item="cat"}
            <dt>
                <input type="radio" name="categorie" value="{$cat.id|escape}" id="f_cat_{$cat.id|escape}" {form_field name="categorie" checked=$cat.id} />
                <label for="f_cat_{$cat.id|escape}">{$cat.intitule|escape}</label>







|







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
            <dt><label for="f_numero_piece">Numéro de pièce comptable</label></dt>
            <dd><input type="text" name="numero_piece" id="f_numero_piece" value="{form_field name=numero_piece}" /></dd>
            <dt><label for="f_remarques">Remarques</label></dt>
            <dd><textarea name="remarques" id="f_remarques" rows="4" cols="30">{form_field name=remarques}</textarea></dd>
        </dl>
    </fieldset>

{if $type == Garradin\Compta_Categories::DEPENSES || $type == Garradin\Compta_Categories::RECETTES || $type == 'dette'}
    <fieldset>
        <legend>Catégorie</legend>
        <dl class="catList">
        {foreach from=$categories item="cat"}
            <dt>
                <input type="radio" name="categorie" value="{$cat.id|escape}" id="f_cat_{$cat.id|escape}" {form_field name="categorie" checked=$cat.id} />
                <label for="f_cat_{$cat.id|escape}">{$cat.intitule|escape}</label>

Modified templates/admin/compta/operations/voir.tpl from [cda96468bd] to [30335ca44c].

1
2
3
4
5
6
7
8
9
10
{include file="admin/_head.tpl" title="Opération n°`$operation.id`" current="compta/gestion"}

{if $user.droits.compta >= Garradin_Membres::DROIT_ADMIN}
<ul class="actions">
    <li class="edit"><a href="{$admin_url}compta/operations/modifier.php?id={$operation.id|escape}">Modifier cette opération</a></li>
    <li class="delete"><a href="{$admin_url}compta/operations/supprimer.php?id={$operation.id|escape}">Supprimer cette opération</a></li>
</ul>
{/if}

<dl class="describe">


|







1
2
3
4
5
6
7
8
9
10
{include file="admin/_head.tpl" title="Opération n°`$operation.id`" current="compta/gestion"}

{if $user.droits.compta >= Garradin\Membres::DROIT_ADMIN}
<ul class="actions">
    <li class="edit"><a href="{$admin_url}compta/operations/modifier.php?id={$operation.id|escape}">Modifier cette opération</a></li>
    <li class="delete"><a href="{$admin_url}compta/operations/supprimer.php?id={$operation.id|escape}">Supprimer cette opération</a></li>
</ul>
{/if}

<dl class="describe">
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
        {if $operation.moyen_paiement && $operation.moyen_paiement != 'ES'}
            <dt>Compte bancaire</dt>
            <dd>{$compte|escape}</dd>
        {/if}

        <dt>Catégorie</dt>
        <dd>
            <a href="{$www_url}admin/compta/operations/?{if $categorie.type == Garradin_Compta_Categories::DEPENSES}depenses{else}recettes{/if}">{if $categorie.type == Garradin_Compta_Categories::DEPENSES}Dépense{else}Recette{/if}</a>&nbsp;:
            <a href="{$www_url}admin/compta/operations/?cat={$operation.id_categorie|escape}">{$categorie.intitule|escape}</a>
        </dd>
    {/if}

    <dt>Exercice</dt>
    <dd>
        <a href="{$www_url}admin/compta/exercices/">{$exercice.libelle|escape}</a>
        | Du {$exercice.debut|date_fr:'d/m/Y'} au {$exercice.fin|date_fr:'d/m/Y'}
        | <strong>{if $exercice.cloture}Clôturé{else}En cours{/if}</strong>
    </dd>

    <dt>Opération créée par</dt>
    <dd>
        {if $operation.id_auteur}
            {if $user.droits.membres >= Garradin_Membres::DROIT_ACCES}
                <a href="{$www_url}admin/membres/fiche.php?id={$operation.id_auteur|escape}">{$nom_auteur|escape}</a>
            {else}
                {$nom_auteur|escape}
            {/if}
        {else}
            <em>membre supprimé</em>
        {/if}







|














|







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
        {if $operation.moyen_paiement && $operation.moyen_paiement != 'ES'}
            <dt>Compte bancaire</dt>
            <dd>{$compte|escape}</dd>
        {/if}

        <dt>Catégorie</dt>
        <dd>
            <a href="{$www_url}admin/compta/operations/?{if $categorie.type == Garradin\Compta_Categories::DEPENSES}depenses{else}recettes{/if}">{if $categorie.type == Garradin\Compta_Categories::DEPENSES}Dépense{else}Recette{/if}</a>&nbsp;:
            <a href="{$www_url}admin/compta/operations/?cat={$operation.id_categorie|escape}">{$categorie.intitule|escape}</a>
        </dd>
    {/if}

    <dt>Exercice</dt>
    <dd>
        <a href="{$www_url}admin/compta/exercices/">{$exercice.libelle|escape}</a>
        | Du {$exercice.debut|date_fr:'d/m/Y'} au {$exercice.fin|date_fr:'d/m/Y'}
        | <strong>{if $exercice.cloture}Clôturé{else}En cours{/if}</strong>
    </dd>

    <dt>Opération créée par</dt>
    <dd>
        {if $operation.id_auteur}
            {if $user.droits.membres >= Garradin\Membres::DROIT_ACCES}
                <a href="{$www_url}admin/membres/fiche.php?id={$operation.id_auteur|escape}">{$nom_auteur|escape}</a>
            {else}
                {$nom_auteur|escape}
            {/if}
        {else}
            <em>membre supprimé</em>
        {/if}

Modified templates/admin/membres/ajouter.tpl from [aaf37f23c6] to [c5f344c967].

44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
            </dd>
            <dd><input type="password" name="passe" id="f_passe" value="{form_field name=passe}" /></dd>
            <dt><label for="f_repasse">Encore le mot de passe</label> (vérification){if in_array('passe', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt>
            <dd><input type="password" name="repasse" id="f_repasse" value="{form_field name=repasse}" /></dd>
        </dl>
    </fieldset>

    {if $user.droits.membres == Garradin_Membres::DROIT_ADMIN}
    <fieldset>
        <legend>Général</legend>
        <dl>
            <dt><label for="f_cat">Catégorie du membre</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select name="id_categorie" id="f_cat">
                {foreach from=$membres_cats key="id" item="nom"}







|







44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
            </dd>
            <dd><input type="password" name="passe" id="f_passe" value="{form_field name=passe}" /></dd>
            <dt><label for="f_repasse">Encore le mot de passe</label> (vérification){if in_array('passe', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt>
            <dd><input type="password" name="repasse" id="f_repasse" value="{form_field name=repasse}" /></dd>
        </dl>
    </fieldset>

    {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}
    <fieldset>
        <legend>Général</legend>
        <dl>
            <dt><label for="f_cat">Catégorie du membre</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select name="id_categorie" id="f_cat">
                {foreach from=$membres_cats key="id" item="nom"}

Modified templates/admin/membres/cat_modifier.tpl from [2c33157031] to [193d9a8064].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
    </fieldset>

    <fieldset>
        <legend>Droits</legend>
        <dl class="droits">
            <dt><label for="f_droit_connexion_aucun">Les membres de cette catégorie peuvent-ils se connecter ?</label></dt>
            <dd>
                <input type="radio" name="droit_connexion" value="{Garradin_Membres::DROIT_AUCUN}" id="f_droit_connexion_aucun" {if $cat.droit_connexion == Garradin_Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_connexion_aucun"><b class="aucun">C</b> Non</label>
            </dd>
            <dd>
                <input type="radio" name="droit_connexion" value="{Garradin_Membres::DROIT_ACCES}" id="f_droit_connexion_acces" {if $cat.droit_connexion == Garradin_Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_connexion_acces"><b class="acces">C</b> Oui</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_inscription_aucun">Les membres de cette catégorie peuvent-ils s'inscrire d'eux-même ?</label></dt>
            <dd>
                <input type="radio" name="droit_inscription" value="{Garradin_Membres::DROIT_AUCUN}" id="f_droit_inscription_aucun" {if $cat.droit_inscription == Garradin_Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_inscription_aucun"><b class="aucun">I</b> Non</label>
            </dd>
            <dd>
                <input type="radio" name="droit_inscription" value="{Garradin_Membres::DROIT_ACCES}" id="f_droit_inscription_acces" {if $cat.droit_inscription == Garradin_Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_inscription_acces"><b class="acces">I</b> Oui</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_membres_aucun">Gestion des membres :</label></dt>
            <dd>
                <input type="radio" name="droit_membres" value="{Garradin_Membres::DROIT_AUCUN}" id="f_droit_membres_aucun" {if $cat.droit_membres == Garradin_Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_membres_aucun"><b class="aucun">M</b> Pas d'accès</label>
            </dd>
            <dd>
                <input type="radio" name="droit_membres" value="{Garradin_Membres::DROIT_ACCES}" id="f_droit_membres_acces" {if $cat.droit_membres == Garradin_Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_membres_acces"><b class="acces">M</b> Lecture uniquement</label>
            </dd>
            <dd>
                <input type="radio" name="droit_membres" value="{Garradin_Membres::DROIT_ECRITURE}" id="f_droit_membres_ecriture" {if $cat.droit_membres == Garradin_Membres::DROIT_ECRITURE}checked="checked"{/if} />
                <label for="f_droit_membres_ecriture"><b class="ecriture">M</b> Lecture &amp; écriture</label>
            </dd>
            <dd>
                <input type="radio" name="droit_membres" value="{Garradin_Membres::DROIT_ADMIN}" id="f_droit_membres_admin" {if $cat.droit_membres == Garradin_Membres::DROIT_ADMIN}checked="checked"{/if} />
                <label for="f_droit_membres_admin"><b class="admin">M</b> Administration</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_compta_aucun">Comptabilité :</label></dt>
            <dd>
                <input type="radio" name="droit_compta" value="{Garradin_Membres::DROIT_AUCUN}" id="f_droit_compta_aucun" {if $cat.droit_compta == Garradin_Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_compta_aucun"><b class="aucun">€</b> Pas d'accès</label>
            </dd>
            <dd>
                <input type="radio" name="droit_compta" value="{Garradin_Membres::DROIT_ACCES}" id="f_droit_compta_acces" {if $cat.droit_compta == Garradin_Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_compta_acces"><b class="acces">€</b> Lecture uniquement</label>
            </dd>
            <dd>
                <input type="radio" name="droit_compta" value="{Garradin_Membres::DROIT_ECRITURE}" id="f_droit_compta_ecriture" {if $cat.droit_compta == Garradin_Membres::DROIT_ECRITURE}checked="checked"{/if} />
                <label for="f_droit_compta_ecriture"><b class="ecriture">€</b> Lecture &amp; écriture</label>
            </dd>
            <dd>
                <input type="radio" name="droit_compta" value="{Garradin_Membres::DROIT_ADMIN}" id="f_droit_compta_admin" {if $cat.droit_compta == Garradin_Membres::DROIT_ADMIN}checked="checked"{/if} />
                <label for="f_droit_compta_admin"><b class="admin">€</b> Administration</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_wiki_aucun">Wiki :</label></dt>
            <dd>
                <input type="radio" name="droit_wiki" value="{Garradin_Membres::DROIT_AUCUN}" id="f_droit_wiki_aucun" {if $cat.droit_wiki == Garradin_Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_wiki_aucun"><b class="aucun">W</b> Pas d'accès</label>
            </dd>
            <dd>
                <input type="radio" name="droit_wiki" value="{Garradin_Membres::DROIT_ACCES}" id="f_droit_wiki_acces" {if $cat.droit_wiki == Garradin_Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_wiki_acces"><b class="acces">W</b> Lecture uniquement</label>
            </dd>
            <dd>
                <input type="radio" name="droit_wiki" value="{Garradin_Membres::DROIT_ECRITURE}" id="f_droit_wiki_ecriture" {if $cat.droit_wiki == Garradin_Membres::DROIT_ECRITURE}checked="checked"{/if} />
                <label for="f_droit_wiki_ecriture"><b class="ecriture">W</b> Lecture &amp; écriture</label>
            </dd>
            <dd>
                <input type="radio" name="droit_wiki" value="{Garradin_Membres::DROIT_ADMIN}" id="f_droit_wiki_admin" {if $cat.droit_wiki == Garradin_Membres::DROIT_ADMIN}checked="checked"{/if} />
                <label for="f_droit_wiki_admin"><b class="admin">W</b> Administration</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_config_aucun">Les membres de cette catégorie peuvent-ils modifier la configuration ?</label></dt>
            <dd>
                <input type="radio" name="droit_config" value="{Garradin_Membres::DROIT_AUCUN}" id="f_droit_config_aucun" {if $cat.droit_config == Garradin_Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_config_aucun"><b class="aucun">&#x2611;</b> Non</label>
            </dd>
            <dd>
                <input type="radio" name="droit_config" value="{Garradin_Membres::DROIT_ADMIN}" id="f_droit_config_admin" {if $cat.droit_config == Garradin_Membres::DROIT_ADMIN}checked="checked"{/if} />
                <label for="f_droit_config_admin"><b class="admin">&#x2611;</b> Oui</label>
            </dd>
        </dl>
    </fieldset>

    <p class="submit">
        {csrf_field key="edit_cat_"|cat:$cat.id}
        <input type="submit" name="save" value="Enregistrer &rarr;" />
    </p>

</form>

{include file="admin/_foot.tpl"}







|



|






|



|






|



|



|



|






|



|



|



|






|



|



|



|






|



|













30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
    </fieldset>

    <fieldset>
        <legend>Droits</legend>
        <dl class="droits">
            <dt><label for="f_droit_connexion_aucun">Les membres de cette catégorie peuvent-ils se connecter ?</label></dt>
            <dd>
                <input type="radio" name="droit_connexion" value="{Garradin\Membres::DROIT_AUCUN}" id="f_droit_connexion_aucun" {if $cat.droit_connexion == Garradin\Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_connexion_aucun"><b class="aucun">C</b> Non</label>
            </dd>
            <dd>
                <input type="radio" name="droit_connexion" value="{Garradin\Membres::DROIT_ACCES}" id="f_droit_connexion_acces" {if $cat.droit_connexion == Garradin\Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_connexion_acces"><b class="acces">C</b> Oui</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_inscription_aucun">Les membres de cette catégorie peuvent-ils s'inscrire d'eux-même ?</label></dt>
            <dd>
                <input type="radio" name="droit_inscription" value="{Garradin\Membres::DROIT_AUCUN}" id="f_droit_inscription_aucun" {if $cat.droit_inscription == Garradin\Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_inscription_aucun"><b class="aucun">I</b> Non</label>
            </dd>
            <dd>
                <input type="radio" name="droit_inscription" value="{Garradin\Membres::DROIT_ACCES}" id="f_droit_inscription_acces" {if $cat.droit_inscription == Garradin\Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_inscription_acces"><b class="acces">I</b> Oui</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_membres_aucun">Gestion des membres :</label></dt>
            <dd>
                <input type="radio" name="droit_membres" value="{Garradin\Membres::DROIT_AUCUN}" id="f_droit_membres_aucun" {if $cat.droit_membres == Garradin\Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_membres_aucun"><b class="aucun">M</b> Pas d'accès</label>
            </dd>
            <dd>
                <input type="radio" name="droit_membres" value="{Garradin\Membres::DROIT_ACCES}" id="f_droit_membres_acces" {if $cat.droit_membres == Garradin\Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_membres_acces"><b class="acces">M</b> Lecture uniquement</label>
            </dd>
            <dd>
                <input type="radio" name="droit_membres" value="{Garradin\Membres::DROIT_ECRITURE}" id="f_droit_membres_ecriture" {if $cat.droit_membres == Garradin\Membres::DROIT_ECRITURE}checked="checked"{/if} />
                <label for="f_droit_membres_ecriture"><b class="ecriture">M</b> Lecture &amp; écriture</label>
            </dd>
            <dd>
                <input type="radio" name="droit_membres" value="{Garradin\Membres::DROIT_ADMIN}" id="f_droit_membres_admin" {if $cat.droit_membres == Garradin\Membres::DROIT_ADMIN}checked="checked"{/if} />
                <label for="f_droit_membres_admin"><b class="admin">M</b> Administration</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_compta_aucun">Comptabilité :</label></dt>
            <dd>
                <input type="radio" name="droit_compta" value="{Garradin\Membres::DROIT_AUCUN}" id="f_droit_compta_aucun" {if $cat.droit_compta == Garradin\Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_compta_aucun"><b class="aucun">€</b> Pas d'accès</label>
            </dd>
            <dd>
                <input type="radio" name="droit_compta" value="{Garradin\Membres::DROIT_ACCES}" id="f_droit_compta_acces" {if $cat.droit_compta == Garradin\Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_compta_acces"><b class="acces">€</b> Lecture uniquement</label>
            </dd>
            <dd>
                <input type="radio" name="droit_compta" value="{Garradin\Membres::DROIT_ECRITURE}" id="f_droit_compta_ecriture" {if $cat.droit_compta == Garradin\Membres::DROIT_ECRITURE}checked="checked"{/if} />
                <label for="f_droit_compta_ecriture"><b class="ecriture">€</b> Lecture &amp; écriture</label>
            </dd>
            <dd>
                <input type="radio" name="droit_compta" value="{Garradin\Membres::DROIT_ADMIN}" id="f_droit_compta_admin" {if $cat.droit_compta == Garradin\Membres::DROIT_ADMIN}checked="checked"{/if} />
                <label for="f_droit_compta_admin"><b class="admin">€</b> Administration</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_wiki_aucun">Wiki :</label></dt>
            <dd>
                <input type="radio" name="droit_wiki" value="{Garradin\Membres::DROIT_AUCUN}" id="f_droit_wiki_aucun" {if $cat.droit_wiki == Garradin\Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_wiki_aucun"><b class="aucun">W</b> Pas d'accès</label>
            </dd>
            <dd>
                <input type="radio" name="droit_wiki" value="{Garradin\Membres::DROIT_ACCES}" id="f_droit_wiki_acces" {if $cat.droit_wiki == Garradin\Membres::DROIT_ACCES}checked="checked"{/if} />
                <label for="f_droit_wiki_acces"><b class="acces">W</b> Lecture uniquement</label>
            </dd>
            <dd>
                <input type="radio" name="droit_wiki" value="{Garradin\Membres::DROIT_ECRITURE}" id="f_droit_wiki_ecriture" {if $cat.droit_wiki == Garradin\Membres::DROIT_ECRITURE}checked="checked"{/if} />
                <label for="f_droit_wiki_ecriture"><b class="ecriture">W</b> Lecture &amp; écriture</label>
            </dd>
            <dd>
                <input type="radio" name="droit_wiki" value="{Garradin\Membres::DROIT_ADMIN}" id="f_droit_wiki_admin" {if $cat.droit_wiki == Garradin\Membres::DROIT_ADMIN}checked="checked"{/if} />
                <label for="f_droit_wiki_admin"><b class="admin">W</b> Administration</label>
            </dd>
        </dl>
        <dl class="droits">
            <dt><label for="f_droit_config_aucun">Les membres de cette catégorie peuvent-ils modifier la configuration ?</label></dt>
            <dd>
                <input type="radio" name="droit_config" value="{Garradin\Membres::DROIT_AUCUN}" id="f_droit_config_aucun" {if $cat.droit_config == Garradin\Membres::DROIT_AUCUN}checked="checked"{/if} />
                <label for="f_droit_config_aucun"><b class="aucun">&#x2611;</b> Non</label>
            </dd>
            <dd>
                <input type="radio" name="droit_config" value="{Garradin\Membres::DROIT_ADMIN}" id="f_droit_config_admin" {if $cat.droit_config == Garradin\Membres::DROIT_ADMIN}checked="checked"{/if} />
                <label for="f_droit_config_admin"><b class="admin">&#x2611;</b> Oui</label>
            </dd>
        </dl>
    </fieldset>

    <p class="submit">
        {csrf_field key="edit_cat_"|cat:$cat.id}
        <input type="submit" name="save" value="Enregistrer &rarr;" />
    </p>

</form>

{include file="admin/_foot.tpl"}

Modified templates/admin/membres/fiche.tpl from [e9bd1d4d9d] to [2a06a6a32e].

1
2
3
4
5
6
7
8
9
10
11
12
13
{include file="admin/_head.tpl" title="`$membre.nom` (`$categorie.nom`)" current="membres"}

{if $user.droits.membres >= Garradin_Membres::DROIT_ECRITURE}
<ul class="actions">
    <li><a href="{$www_url}admin/membres/modifier.php?id={$membre.id|escape}">Modifier</a></li>
    {if $user.droits.membres >= Garradin_Membres::DROIT_ADMIN}
        <li><a href="{$www_url}admin/membres/supprimer.php?id={$membre.id|escape}">Supprimer</a></li>
    {/if}
</ul>
{/if}

{if $error}
    <p class="error">


|


|







1
2
3
4
5
6
7
8
9
10
11
12
13
{include file="admin/_head.tpl" title="`$membre.nom` (`$categorie.nom`)" current="membres"}

{if $user.droits.membres >= Garradin\Membres::DROIT_ECRITURE}
<ul class="actions">
    <li><a href="{$www_url}admin/membres/modifier.php?id={$membre.id|escape}">Modifier</a></li>
    {if $user.droits.membres >= Garradin\Membres::DROIT_ADMIN}
        <li><a href="{$www_url}admin/membres/supprimer.php?id={$membre.id|escape}">Supprimer</a></li>
    {/if}
</ul>
{/if}

{if $error}
    <p class="error">

Modified templates/admin/membres/index.tpl from [183d274e48] to [1064c30559].

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
        <legend>Filtrer</legend>
        <dl>
            <dt><label for="f_cat">Catégorie</label></dt>
            <dd>
                <select name="cat" id="f_cat">
                    <option value="0" {if $current_cat == 0} selected="selected"{/if}>-- Toutes</option>
                {foreach from=$membres_cats key="id" item="nom"}
                    {if $user.droits.membres >= Garradin_Membres::DROIT_ECRITURE
                        || !array_key_exists($id, $membres_cats_cachees)}
                    <option value="{$id|escape}"{if $current_cat == $id} selected="selected"{/if}>{$nom|escape}</option>
                    {/if}
                {/foreach}
                </select>
            </dd>
        </dl>
    </fieldset>

    <p class="submit">
        <input type="submit" value="Filtrer &rarr;" />
    </p>
</form>

{if $user.droits.membres >= Garradin_Membres::DROIT_ECRITURE}
    <form method="get" action="{$self_url|escape}" class="searchMember">
        <fieldset>
            <legend>Rechercher un membre</legend>
            <dl>
                <dt><label for="f_field">Dont le champ</label></dt>
                <dd>
                    <select name="search_field" id="f_field">







|














|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
        <legend>Filtrer</legend>
        <dl>
            <dt><label for="f_cat">Catégorie</label></dt>
            <dd>
                <select name="cat" id="f_cat">
                    <option value="0" {if $current_cat == 0} selected="selected"{/if}>-- Toutes</option>
                {foreach from=$membres_cats key="id" item="nom"}
                    {if $user.droits.membres >= Garradin\Membres::DROIT_ECRITURE
                        || !array_key_exists($id, $membres_cats_cachees)}
                    <option value="{$id|escape}"{if $current_cat == $id} selected="selected"{/if}>{$nom|escape}</option>
                    {/if}
                {/foreach}
                </select>
            </dd>
        </dl>
    </fieldset>

    <p class="submit">
        <input type="submit" value="Filtrer &rarr;" />
    </p>
</form>

{if $user.droits.membres >= Garradin\Membres::DROIT_ECRITURE}
    <form method="get" action="{$self_url|escape}" class="searchMember">
        <fieldset>
            <legend>Rechercher un membre</legend>
            <dl>
                <dt><label for="f_field">Dont le champ</label></dt>
                <dd>
                    <select name="search_field" id="f_field">
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
                <td>Ville</td>
            {/if}
            <td></td>
        </thead>
        <tbody>
            {foreach from=$liste item="membre"}
                <tr>
                    <td class="check">{if $user.droits.membres == Garradin_Membres::DROIT_ADMIN}<input type="checkbox" name="selected[]" value="{$membre.id|escape}" />{/if}</td>
                    <td class="num"><a title="Fiche membre" href="{$www_url}admin/membres/fiche.php?id={$membre.id|escape}">{$membre.id|escape}</a></td>
                    <th>{$membre.nom|escape}</th>
                    {if empty($membre.date_cotisation)}
                        <td class="error">jamais réglée</td>
                    {elseif $membre.date_cotisation > strtotime('12 months ago')} {* FIXME durée de cotisation variable *}
                        <td class="confirm">à jour</td>
                    {else}
                        <td class="alert">en retard</td>
                    {/if}
                    <td>{$membre.date_inscription|date_fr:'d/m/Y'}</td>
                    <td>{$membre.ville|escape}</td>
                    <td class="actions">
                        {if !empty($membre.email)}<a class="icn" href="{$www_url}admin/membres/message.php?id={$membre.id|escape}" title="Envoyer un message">✉</a> {/if}
                        <a class="icn" href="modifier.php?id={$membre.id|escape}">✎</a>
                    </td>
                </tr>
            {/foreach}
        </tbody>
    </table>

    {if $user.droits.membres == Garradin_Membres::DROIT_ADMIN}
    <p class="checkUncheck">
        <input type="button" value="Tout cocher / décocher" onclick="checkUncheck();" />
    </p>
    <p class="actions">
        <em>Pour les membres cochés :</em>
        <input type="submit" name="move" value="Changer de catégorie" />
        <input type="submit" name="delete" value="Supprimer" />







|




















|







75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
                <td>Ville</td>
            {/if}
            <td></td>
        </thead>
        <tbody>
            {foreach from=$liste item="membre"}
                <tr>
                    <td class="check">{if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}<input type="checkbox" name="selected[]" value="{$membre.id|escape}" />{/if}</td>
                    <td class="num"><a title="Fiche membre" href="{$www_url}admin/membres/fiche.php?id={$membre.id|escape}">{$membre.id|escape}</a></td>
                    <th>{$membre.nom|escape}</th>
                    {if empty($membre.date_cotisation)}
                        <td class="error">jamais réglée</td>
                    {elseif $membre.date_cotisation > strtotime('12 months ago')} {* FIXME durée de cotisation variable *}
                        <td class="confirm">à jour</td>
                    {else}
                        <td class="alert">en retard</td>
                    {/if}
                    <td>{$membre.date_inscription|date_fr:'d/m/Y'}</td>
                    <td>{$membre.ville|escape}</td>
                    <td class="actions">
                        {if !empty($membre.email)}<a class="icn" href="{$www_url}admin/membres/message.php?id={$membre.id|escape}" title="Envoyer un message">✉</a> {/if}
                        <a class="icn" href="modifier.php?id={$membre.id|escape}">✎</a>
                    </td>
                </tr>
            {/foreach}
        </tbody>
    </table>

    {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}
    <p class="checkUncheck">
        <input type="button" value="Tout cocher / décocher" onclick="checkUncheck();" />
    </p>
    <p class="actions">
        <em>Pour les membres cochés :</em>
        <input type="submit" name="move" value="Changer de catégorie" />
        <input type="submit" name="delete" value="Supprimer" />

Modified templates/admin/membres/modifier.tpl from [4b897c0d4d] to [e562da8857].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{include file="admin/_head.tpl" title="Modifier un membre" current="membres"}

{if $error}
    <p class="error">
        {$error|escape}
    </p>
{/if}

<form method="post" action="{$self_url|escape}">

    <fieldset>
        <legend>Informations personnelles</legend>
        <dl>
        {if $user.droits.membres == Garradin_Membres::DROIT_ADMIN}
            <dt><label for="f_id">Numéro de membre</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="id" id="f_id" value="{form_field data=$membre name=id}" /></dd>
        {/if}
            <dt><label for="f_nom">Prénom et nom</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="nom" id="f_nom" value="{form_field data=$membre name=nom}" /></dd>
            <dt><label for="f_email">Adresse E-Mail</label>{if in_array('email', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt>
            <dd><input type="email" name="email" id="f_email" value="{form_field data=$membre name=email}" /></dd>













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{include file="admin/_head.tpl" title="Modifier un membre" current="membres"}

{if $error}
    <p class="error">
        {$error|escape}
    </p>
{/if}

<form method="post" action="{$self_url|escape}">

    <fieldset>
        <legend>Informations personnelles</legend>
        <dl>
        {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}
            <dt><label for="f_id">Numéro de membre</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="id" id="f_id" value="{form_field data=$membre name=id}" /></dd>
        {/if}
            <dt><label for="f_nom">Prénom et nom</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd><input type="text" name="nom" id="f_nom" value="{form_field data=$membre name=nom}" /></dd>
            <dt><label for="f_email">Adresse E-Mail</label>{if in_array('email', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt>
            <dd><input type="email" name="email" id="f_email" value="{form_field data=$membre name=email}" /></dd>
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
            </dd>
            <dd><input type="password" name="passe" id="f_passe" value="{form_field name=passe}" /></dd>
            <dt><label for="f_repasse">Encore le mot de passe</label> (vérification){if !$membre.passe && in_array('passe', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt>
            <dd><input type="password" name="repasse" id="f_repasse" value="{form_field name=repasse}" /></dd>
        </dl>
    </fieldset>

    {if $user.droits.membres == Garradin_Membres::DROIT_ADMIN}
    <fieldset>
        <legend>Général</legend>
        <dl>
            <dt><label for="f_cat">Catégorie du membre</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select name="id_categorie" id="f_cat">
                {foreach from=$membres_cats key="id" item="nom"}







|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
            </dd>
            <dd><input type="password" name="passe" id="f_passe" value="{form_field name=passe}" /></dd>
            <dt><label for="f_repasse">Encore le mot de passe</label> (vérification){if !$membre.passe && in_array('passe', $obligatoires)} <b title="(Champ obligatoire)">obligatoire</b>{/if}</dt>
            <dd><input type="password" name="repasse" id="f_repasse" value="{form_field name=repasse}" /></dd>
        </dl>
    </fieldset>

    {if $user.droits.membres == Garradin\Membres::DROIT_ADMIN}
    <fieldset>
        <legend>Général</legend>
        <dl>
            <dt><label for="f_cat">Catégorie du membre</label> <b title="(Champ obligatoire)">obligatoire</b></dt>
            <dd>
                <select name="id_categorie" id="f_cat">
                {foreach from=$membres_cats key="id" item="nom"}

Modified templates/admin/wiki/editer.tpl from [ffe4fb1fef] to [6c17d86f54].

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
    </fieldset>

    <fieldset class="wikiRights">
        <legend>Droits d'accès</legend>
        <dl>
            <dt><label for="f_droit_lecture_public">Cette page est visible :</label></dt>
            <dd>
                <input type="radio" name="droit_lecture" id="f_droit_lecture_public" value="{Garradin_Wiki::LECTURE_PUBLIC}" {form_field data=$page name="droit_lecture" checked=Garradin_Wiki::LECTURE_PUBLIC} />
                <label for="f_droit_lecture_public"><strong>Sur le site de l'association</strong></label>
                &mdash; cette page apparaîtra sur le site public de l'association, accessible à tous les visiteurs
            </dd>
            <dd>
                <input type="radio" name="droit_lecture" id="f_droit_lecture_normal" value="{Garradin_Wiki::LECTURE_NORMAL}"  {form_field data=$page name="droit_lecture" checked=Garradin_Wiki::LECTURE_NORMAL} />
                <label for="f_droit_lecture_normal"><strong>Sur le wiki uniquement</strong></label>
                &mdash; seuls les membres ayant accès au wiki pourront la voir
            </dd>
            <dd>
                <input type="radio" name="droit_lecture" id="f_droit_lecture_categorie" value="{$user.id_categorie}"  {if $page.droit_lecture >= Garradin_Wiki::LECTURE_CATEGORIE}checked="checked"{/if} />
                <label for="f_droit_lecture_categorie"><strong>Aux membres de ma catégorie</strong></label>
                &mdash; seuls les membres de la même catégorie que moi pourront voir cette page
            </dd>
            <dt><label for="f_droit_ecriture_normal">Cette page peut être modifiée par :</label></dt>
            <dd>
                <input type="radio" name="droit_ecriture" id="f_droit_ecriture_normal" value="{Garradin_Wiki::ECRITURE_NORMAL}" {form_field data=$page name="droit_ecriture" checked=Garradin_Wiki::ECRITURE_NORMAL} {if $page.droit_lecture >= Garradin_Wiki::LECTURE_CATEGORIE}disabled="disabled"{/if} />
                <label for="f_droit_ecriture_normal">Les membres qui ont accès au wiki en écriture</label>
            </dd>
            <dd>
                <input type="radio" name="droit_ecriture" id="f_droit_ecriture_categorie" value="{$user.id_categorie}" {if $page.droit_ecriture >= Garradin_Wiki::ECRITURE_CATEGORIE || $page.droit_lecture >= Garradin_Wiki::LECTURE_CATEGORIE}checked="checked"{/if} {if $page.droit_lecture >= Garradin_Wiki::LECTURE_CATEGORIE}disabled="disabled"{/if} />
                <label for="f_droit_ecriture_categorie">Les membres de ma catégorie</label>
            </dd>
        </dl>
    </fieldset>

    <fieldset class="wikiEncrypt">
        <dl>







|




|




|





|



|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
    </fieldset>

    <fieldset class="wikiRights">
        <legend>Droits d'accès</legend>
        <dl>
            <dt><label for="f_droit_lecture_public">Cette page est visible :</label></dt>
            <dd>
                <input type="radio" name="droit_lecture" id="f_droit_lecture_public" value="{Garradin\Wiki::LECTURE_PUBLIC}" {form_field data=$page name="droit_lecture" checked=Garradin\Wiki::LECTURE_PUBLIC} />
                <label for="f_droit_lecture_public"><strong>Sur le site de l'association</strong></label>
                &mdash; cette page apparaîtra sur le site public de l'association, accessible à tous les visiteurs
            </dd>
            <dd>
                <input type="radio" name="droit_lecture" id="f_droit_lecture_normal" value="{Garradin\Wiki::LECTURE_NORMAL}"  {form_field data=$page name="droit_lecture" checked=Garradin\Wiki::LECTURE_NORMAL} />
                <label for="f_droit_lecture_normal"><strong>Sur le wiki uniquement</strong></label>
                &mdash; seuls les membres ayant accès au wiki pourront la voir
            </dd>
            <dd>
                <input type="radio" name="droit_lecture" id="f_droit_lecture_categorie" value="{$user.id_categorie}"  {if $page.droit_lecture >= Garradin\Wiki::LECTURE_CATEGORIE}checked="checked"{/if} />
                <label for="f_droit_lecture_categorie"><strong>Aux membres de ma catégorie</strong></label>
                &mdash; seuls les membres de la même catégorie que moi pourront voir cette page
            </dd>
            <dt><label for="f_droit_ecriture_normal">Cette page peut être modifiée par :</label></dt>
            <dd>
                <input type="radio" name="droit_ecriture" id="f_droit_ecriture_normal" value="{Garradin\Wiki::ECRITURE_NORMAL}" {form_field data=$page name="droit_ecriture" checked=Garradin\Wiki::ECRITURE_NORMAL} {if $page.droit_lecture >= Garradin\Wiki::LECTURE_CATEGORIE}disabled="disabled"{/if} />
                <label for="f_droit_ecriture_normal">Les membres qui ont accès au wiki en écriture</label>
            </dd>
            <dd>
                <input type="radio" name="droit_ecriture" id="f_droit_ecriture_categorie" value="{$user.id_categorie}" {if $page.droit_ecriture >= Garradin\Wiki::ECRITURE_CATEGORIE || $page.droit_lecture >= Garradin\Wiki::LECTURE_CATEGORIE}checked="checked"{/if} {if $page.droit_lecture >= Garradin\Wiki::LECTURE_CATEGORIE}disabled="disabled"{/if} />
                <label for="f_droit_ecriture_categorie">Les membres de ma catégorie</label>
            </dd>
        </dl>
    </fieldset>

    <fieldset class="wikiEncrypt">
        <dl>

Modified templates/admin/wiki/historique.tpl from [2bf9333141] to [487bc70707].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
                    {else}
                        <a href="?id={$page.id|escape}&amp;diff={math equation="x-1" x=$rev.revision}.{$rev.revision|escape}">diff</a>
                    {/if}
                {/if}
            </td>
            <th>{$rev.date|date_fr:'d/m/Y à H:i'}</th>
            <td>
                {if $user.droits.membres >= Garradin_Membres::DROIT_ACCES}
                <a href="{$www_url}admin/membres/fiche.php?id={$rev.id_auteur|escape}">{$rev.nom_auteur|escape}</a>
                {/if}
            </td>
            <td class="length">
                {$rev.taille|escape} octets
                {if $rev.revision > 1 && !$rev.chiffrement}
                    {if $rev.diff_taille > 0}







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
                    {else}
                        <a href="?id={$page.id|escape}&amp;diff={math equation="x-1" x=$rev.revision}.{$rev.revision|escape}">diff</a>
                    {/if}
                {/if}
            </td>
            <th>{$rev.date|date_fr:'d/m/Y à H:i'}</th>
            <td>
                {if $user.droits.membres >= Garradin\Membres::DROIT_ACCES}
                <a href="{$www_url}admin/membres/fiche.php?id={$rev.id_auteur|escape}">{$rev.nom_auteur|escape}</a>
                {/if}
            </td>
            <td class="length">
                {$rev.taille|escape} octets
                {if $rev.revision > 1 && !$rev.chiffrement}
                    {if $rev.diff_taille > 0}
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
            </td>
        </tr>
    {/foreach}
    </table>
{elseif !empty($diff)}
    <div class="wikiRevision revisionLeft">
        <h3>Version du {$rev1.date|date_fr:'d/m/Y à H:i'}</h3>
        {if $user.droits.membres >= Garradin_Membres::DROIT_ACCES}
            <h4>De <a href="{$www_url}admin/membres/fiche.php?id={$rev1.id_auteur|escape}">{$rev1.nom_auteur|escape}</a></h4>
        {/if}
        {if $rev1.modification}
            <p><em>{$rev1.modification|escape}</em></p>
        {/if}
    </div>
    <div class="wikiRevision revisionRight">
        <h3>Version {if $rev2.revision == $page.revision}actuelle en date{/if} du {$rev2.date|date_fr:'d/m/Y à H:i'}</h3>
        {if $user.droits.membres >= Garradin_Membres::DROIT_ACCES}
            <h4>De <a href="{$www_url}admin/membres/fiche.php?id={$rev2.id_auteur|escape}">{$rev2.nom_auteur|escape}</a></h4>
        {/if}
        {if $rev2.modification}
            <p><em>{$rev2.modification|escape}</em></p>
        {/if}
    </div>
    {diff old=$rev1.contenu new=$rev2.contenu}







|








|







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
            </td>
        </tr>
    {/foreach}
    </table>
{elseif !empty($diff)}
    <div class="wikiRevision revisionLeft">
        <h3>Version du {$rev1.date|date_fr:'d/m/Y à H:i'}</h3>
        {if $user.droits.membres >= Garradin\Membres::DROIT_ACCES}
            <h4>De <a href="{$www_url}admin/membres/fiche.php?id={$rev1.id_auteur|escape}">{$rev1.nom_auteur|escape}</a></h4>
        {/if}
        {if $rev1.modification}
            <p><em>{$rev1.modification|escape}</em></p>
        {/if}
    </div>
    <div class="wikiRevision revisionRight">
        <h3>Version {if $rev2.revision == $page.revision}actuelle en date{/if} du {$rev2.date|date_fr:'d/m/Y à H:i'}</h3>
        {if $user.droits.membres >= Garradin\Membres::DROIT_ACCES}
            <h4>De <a href="{$www_url}admin/membres/fiche.php?id={$rev2.id_auteur|escape}">{$rev2.nom_auteur|escape}</a></h4>
        {/if}
        {if $rev2.modification}
            <p><em>{$rev2.modification|escape}</em></p>
        {/if}
    </div>
    {diff old=$rev1.contenu new=$rev2.contenu}

Modified templates/admin/wiki/page.tpl from [649c98b64a] to [60cc46abba].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{if !empty($page.titre) && $can_read}
    {include file="admin/_head.tpl" title=$page.titre current="wiki"}
{else}
    {include file="admin/_head.tpl" title="Wiki" current="wiki"}
{/if}

<ul class="actions">
    {if $user.droits.wiki >= Garradin_Membres::DROIT_ECRITURE}
        <li><a href="{$www_url}admin/wiki/creer.php?parent={if $config.accueil_wiki == $page.uri}0{else}{$page.id|escape}{/if}"><strong>Créer une nouvelle page</strong></a></li>
    {/if}
    {if $can_edit}
        <li><a href="{$www_url}admin/wiki/editer.php?id={$page.id|escape}">Éditer</a></li>
    {/if}
    {if $can_read && $page && $page.contenu}
        <li><a href="{$www_url}admin/wiki/historique.php?id={$page.id|escape}">Historique</a>
        {if $page.droit_lecture == Garradin_Wiki::LECTURE_PUBLIC}
            <li><a href="{$www_url}{$page.uri|escape}">Voir sur le site</a>
        {/if}
    {/if}
    {if $user.droits.wiki >= Garradin_Membres::DROIT_ADMIN}
        <li><a href="{$www_url}admin/wiki/supprimer.php?id={$page.id|escape}">Supprimer</a></li>
    {/if}
</ul>

{if !$can_read}
    <p class="alert">Vous n'avez pas le droit de lire cette page.</p>
{else}







|







|



|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{if !empty($page.titre) && $can_read}
    {include file="admin/_head.tpl" title=$page.titre current="wiki"}
{else}
    {include file="admin/_head.tpl" title="Wiki" current="wiki"}
{/if}

<ul class="actions">
    {if $user.droits.wiki >= Garradin\Membres::DROIT_ECRITURE}
        <li><a href="{$www_url}admin/wiki/creer.php?parent={if $config.accueil_wiki == $page.uri}0{else}{$page.id|escape}{/if}"><strong>Créer une nouvelle page</strong></a></li>
    {/if}
    {if $can_edit}
        <li><a href="{$www_url}admin/wiki/editer.php?id={$page.id|escape}">Éditer</a></li>
    {/if}
    {if $can_read && $page && $page.contenu}
        <li><a href="{$www_url}admin/wiki/historique.php?id={$page.id|escape}">Historique</a>
        {if $page.droit_lecture == Garradin\Wiki::LECTURE_PUBLIC}
            <li><a href="{$www_url}{$page.uri|escape}">Voir sur le site</a>
        {/if}
    {/if}
    {if $user.droits.wiki >= Garradin\Membres::DROIT_ADMIN}
        <li><a href="{$www_url}admin/wiki/supprimer.php?id={$page.id|escape}">Supprimer</a></li>
    {/if}
</ul>

{if !$can_read}
    <p class="alert">Vous n'avez pas le droit de lire cette page.</p>
{else}
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
                <div class="wikiContent">
                    {$page.contenu.contenu|format_wiki|liens_wiki:'?'}
                </div>
            {/if}

            <p class="wikiFooter">
                Dernière modification le {$page.date_modification|date_fr:'d/m/Y à H:i'}
                {if $user.droits.membres >= Garradin_Membres::DROIT_ACCES}
                par <a href="{$www_url}admin/membres/fiche.php?id={$page.contenu.id_auteur|escape}">{$auteur|escape}</a>
                {/if}
            </p>
        {/if}
    {/if}
{/if}


{include file="admin/_foot.tpl"}







|









86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
                <div class="wikiContent">
                    {$page.contenu.contenu|format_wiki|liens_wiki:'?'}
                </div>
            {/if}

            <p class="wikiFooter">
                Dernière modification le {$page.date_modification|date_fr:'d/m/Y à H:i'}
                {if $user.droits.membres >= Garradin\Membres::DROIT_ACCES}
                par <a href="{$www_url}admin/membres/fiche.php?id={$page.contenu.id_auteur|escape}">{$auteur|escape}</a>
                {/if}
            </p>
        {/if}
    {/if}
{/if}


{include file="admin/_foot.tpl"}

Modified www/_inc.php from [c847e91abc] to [30742e6275].

1

2
3
4
5
6
<?php


require_once __DIR__ . '/../include/init.php';
require_once GARRADIN_ROOT . '/include/template.php';

?>

>





1
2
3
4
5
6
7
<?php
namespace Garradin;

require_once __DIR__ . '/../include/init.php';
require_once GARRADIN_ROOT . '/include/template.php';

?>

Modified www/admin/_inc.php from [a8f15a7f8e] to [ad2ed7d16f].

1


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php



require_once __DIR__ . '/../../include/init.php';
require_once GARRADIN_ROOT . '/include/template.php';
require_once GARRADIN_ROOT . '/include/class.membres.php';

$tpl->assign('admin_url', WWW_URL . 'admin/');

$membres = new Garradin_Membres;

if (!defined('GARRADIN_LOGIN_PROCESS'))
{
    if (!$membres->isLogged())
    {
        utils::redirect('/admin/login.php');
    }

    $tpl->assign('is_logged', true);
    $tpl->assign('user', $membres->getLoggedUser());
    $user = $membres->getLoggedUser();

    $tpl->assign('current', '');

    if ($user['droits']['membres'] >= Garradin_Membres::DROIT_ACCES)
    {
        $tpl->assign('nb_membres', $membres->countAllButHidden());
    }
}

?>

>
>



<



|














|






1
2
3
4
5
6

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

namespace Garradin;

require_once __DIR__ . '/../../include/init.php';
require_once GARRADIN_ROOT . '/include/template.php';


$tpl->assign('admin_url', WWW_URL . 'admin/');

$membres = new Membres;

if (!defined('GARRADIN_LOGIN_PROCESS'))
{
    if (!$membres->isLogged())
    {
        utils::redirect('/admin/login.php');
    }

    $tpl->assign('is_logged', true);
    $tpl->assign('user', $membres->getLoggedUser());
    $user = $membres->getLoggedUser();

    $tpl->assign('current', '');

    if ($user['droits']['membres'] >= Membres::DROIT_ACCES)
    {
        $tpl->assign('nb_membres', $membres->countAllButHidden());
    }
}

?>

Modified www/admin/compta/_inc.php from [6390a5e341] to [2130bd6f42].

1


2
3
4
5
6
7
8
9
10
11
12
13
<?php



require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_comptes.php';
$comptes = new Garradin_Compta_Comptes;

?>

>
>



|




<
|


1
2
3
4
5
6
7
8
9
10
11

12
13
14
<?php

namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$comptes = new Compta_Comptes;

?>

Modified www/admin/compta/banques/ajouter.php from [1f87f74b9b] to [157d630661].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_comptes_bancaires.php';
$banque = new Garradin_Compta_Comptes_Bancaires;

$error = false;

if (!empty($_POST['add']))
{
    if (!utils::CSRF_check('compta_ajout_banque'))
    {

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$banque = new Compta_Comptes_Bancaires;

$error = false;

if (!empty($_POST['add']))
{
    if (!utils::CSRF_check('compta_ajout_banque'))
    {

Modified www/admin/compta/banques/index.php from [9810224a3e] to [029add7039].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php


require_once __DIR__ . '/../_inc.php';

require_once GARRADIN_ROOT . '/include/class.compta_comptes_bancaires.php';
$banques = new Garradin_Compta_Comptes_Bancaires;

require_once GARRADIN_ROOT . '/include/class.compta_journal.php';
$journal = new Garradin_Compta_Journal;

$liste = $banques->getList();

foreach ($liste as &$banque)
{
    $banque['solde'] = $journal->getSolde($banque['id']);
}

>



<
|
<
<
|







1
2
3
4
5

6


7
8
9
10
11
12
13
14
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';


$banques = new Compta_Comptes_Bancaires;


$journal = new Compta_Journal;

$liste = $banques->getList();

foreach ($liste as &$banque)
{
    $banque['solde'] = $journal->getSolde($banque['id']);
}
31
32
33
34
35
36
37
38
39
40
41
42
43
    $rib = explode(' ', $rib);

    $out = '<table class="rib"><thead><tr><th>Banque</th><th>Guichet</th><th>Compte</th><th>Clé</th></tr></thead>';
    $out.= '<tbody><tr><td>'.$rib[0].'</td><td>'.$rib[1].'</td><td>'.$rib[2].'</td><td>'.$rib[3].'</td></tr></tbody></table>';
    return $out;
}

$tpl->register_modifier('format_iban', 'tpl_format_iban');
$tpl->register_modifier('format_rib', 'tpl_format_rib');

$tpl->display('admin/compta/banques/index.tpl');

?>







|
|




29
30
31
32
33
34
35
36
37
38
39
40
41
    $rib = explode(' ', $rib);

    $out = '<table class="rib"><thead><tr><th>Banque</th><th>Guichet</th><th>Compte</th><th>Clé</th></tr></thead>';
    $out.= '<tbody><tr><td>'.$rib[0].'</td><td>'.$rib[1].'</td><td>'.$rib[2].'</td><td>'.$rib[3].'</td></tr></tbody></table>';
    return $out;
}

$tpl->register_modifier('format_iban', 'Garradin\tpl_format_iban');
$tpl->register_modifier('format_rib', 'Garradin\tpl_format_rib');

$tpl->display('admin/compta/banques/index.tpl');

?>

Modified www/admin/compta/banques/modifier.php from [f2b5f3c171] to [2d8b19f471].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_comptes_bancaires.php';
$banque = new Garradin_Compta_Comptes_Bancaires;

$compte = $banque->get(utils::get('id'));

if (!$compte)
{
    throw new UserException('Le compte demandé n\'existe pas.');
}

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$banque = new Compta_Comptes_Bancaires;

$compte = $banque->get(utils::get('id'));

if (!$compte)
{
    throw new UserException('Le compte demandé n\'existe pas.');
}

Modified www/admin/compta/banques/supprimer.php from [2f7d00ed88] to [8aaef315e4].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_comptes_bancaires.php';
$banque = new Garradin_Compta_Comptes_Bancaires;

$compte = $banque->get(utils::get('id'));

if (!$compte)
{
    throw new UserException('Le compte demandé n\'existe pas.');
}

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$banque = new Compta_Comptes_Bancaires;

$compte = $banque->get(utils::get('id'));

if (!$compte)
{
    throw new UserException('Le compte demandé n\'existe pas.');
}

Modified www/admin/compta/categories/ajouter.php from [ac65ec1732] to [e88782f185].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_categories.php';

$cats = new Garradin_Compta_Categories;

$error = false;

if (!empty($_POST['add']))
{
    if (!utils::CSRF_check('compta_ajout_cat'))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try
        {
            $id = $cats->add(array(
                'intitule'      =>  utils::post('intitule'),
                'description'   =>  utils::post('description'),
                'compte'        =>  utils::post('compte'),
                'type'          =>  utils::post('type'),
            ));

            if (utils::post('type') == Garradin_Compta_Categories::DEPENSES)
                $type = 'depenses';
            elseif (utils::post('type') == Garradin_Compta_Categories::AUTRES)
                $type = 'autres';
            else
                $type = 'recettes';

            utils::redirect('/admin/compta/categories/?'.$type);
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

$tpl->assign('error', $error);

$tpl->assign('type', isset($_POST['type']) ? utils::post('type') : Garradin_Compta_Categories::RECETTES);
$tpl->assign('comptes', $comptes->listTree());

$tpl->display('admin/compta/categories/ajouter.tpl');

?>

>



|




<
<
|




















|

|















|





1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}



$cats = new Compta_Categories;

$error = false;

if (!empty($_POST['add']))
{
    if (!utils::CSRF_check('compta_ajout_cat'))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    else
    {
        try
        {
            $id = $cats->add(array(
                'intitule'      =>  utils::post('intitule'),
                'description'   =>  utils::post('description'),
                'compte'        =>  utils::post('compte'),
                'type'          =>  utils::post('type'),
            ));

            if (utils::post('type') == Compta_Categories::DEPENSES)
                $type = 'depenses';
            elseif (utils::post('type') == Compta_Categories::AUTRES)
                $type = 'autres';
            else
                $type = 'recettes';

            utils::redirect('/admin/compta/categories/?'.$type);
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

$tpl->assign('error', $error);

$tpl->assign('type', isset($_POST['type']) ? utils::post('type') : Compta_Categories::RECETTES);
$tpl->assign('comptes', $comptes->listTree());

$tpl->display('admin/compta/categories/ajouter.tpl');

?>

Modified www/admin/compta/categories/index.php from [bb370d597c] to [3af79fd85a].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_categories.php';

$cats = new Garradin_Compta_Categories;

if (isset($_GET['depenses']))
    $type = Garradin_Compta_Categories::DEPENSES;
else
    $type = Garradin_Compta_Categories::RECETTES;

$tpl->assign('type', $type);
$tpl->assign('liste', $cats->getList($type));

$tpl->display('admin/compta/categories/index.tpl');

?>

>



|




<
<
|


|

|







1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}



$cats = new Compta_Categories;

if (isset($_GET['depenses']))
    $type = Compta_Categories::DEPENSES;
else
    $type = Compta_Categories::RECETTES;

$tpl->assign('type', $type);
$tpl->assign('liste', $cats->getList($type));

$tpl->display('admin/compta/categories/index.tpl');

?>

Modified www/admin/compta/categories/modifier.php from [542f1e5fbe] to [ada5e96d69].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_categories.php';

$cats = new Garradin_Compta_Categories;

$id = (int)utils::get('id');
$cat = $cats->get($id);

if (!$cat)
{
    throw new UserException('Cette catégorie n\'existe pas.');

>



|




<
<
|







1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}



$cats = new Compta_Categories;

$id = (int)utils::get('id');
$cat = $cats->get($id);

if (!$cat)
{
    throw new UserException('Cette catégorie n\'existe pas.');
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
        {
            $id = $cats->edit($id,
                array(
                'intitule'      =>  utils::post('intitule'),
                'description'   =>  utils::post('description'),
            ));

            if ($cat['type'] == Garradin_Compta_Categories::DEPENSES)
                $type = 'depenses';
            elseif ($cat['type'] == Garradin_Compta_Categories::AUTRES)
                $type = 'autres';
            else
                $type = 'recettes';

            utils::redirect('/admin/compta/categories/?'.$type);
        }
        catch (UserException $e)







|

|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        {
            $id = $cats->edit($id,
                array(
                'intitule'      =>  utils::post('intitule'),
                'description'   =>  utils::post('description'),
            ));

            if ($cat['type'] == Compta_Categories::DEPENSES)
                $type = 'depenses';
            elseif ($cat['type'] == Compta_Categories::AUTRES)
                $type = 'autres';
            else
                $type = 'recettes';

            utils::redirect('/admin/compta/categories/?'.$type);
        }
        catch (UserException $e)

Modified www/admin/compta/categories/supprimer.php from [306fd86894] to [a9166144fd].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_categories.php';

$cats = new Garradin_Compta_Categories;

$id = (int)utils::get('id');
$cat = $cats->get($id);

if (!$cat)
{
    throw new UserException('Cette catégorie n\'existe pas.');

>



|




<
<
|







1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}



$cats = new Compta_Categories;

$id = (int)utils::get('id');
$cat = $cats->get($id);

if (!$cat)
{
    throw new UserException('Cette catégorie n\'existe pas.');

Modified www/admin/compta/comptes/ajouter.php from [2e3cc2770a] to [c130f35679].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$classe = (int) utils::get('classe');

if (!$classe || $classe < 1 || $classe > 9)

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$classe = (int) utils::get('classe');

if (!$classe || $classe < 1 || $classe > 9)

Modified www/admin/compta/comptes/index.php from [427030542d] to [e53011c462].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$classe = (int) utils::get('classe');

$tpl->assign('classe', $classe);

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$classe = (int) utils::get('classe');

$tpl->assign('classe', $classe);
25
26
27
28
29
30
31
32
33
34
35
36

function tpl_get_position($pos)
{
    global $positions;
    return $positions[$pos];
}

$tpl->register_modifier('get_position', 'tpl_get_position');

$tpl->display('admin/compta/comptes/index.tpl');

?>







|




26
27
28
29
30
31
32
33
34
35
36
37

function tpl_get_position($pos)
{
    global $positions;
    return $positions[$pos];
}

$tpl->register_modifier('get_position', 'Garradin\tpl_get_position');

$tpl->display('admin/compta/comptes/index.tpl');

?>

Modified www/admin/compta/comptes/journal.php from [edcf9d2a13] to [77ef0acb33].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php


require_once __DIR__ . '/../_inc.php';

$compte = $comptes->get(utils::get('id'));

if (!$compte)
{
    throw new UserException("Le compte demandé n'existe pas.");
}

require_once GARRADIN_ROOT . '/include/class.compta_journal.php';
$journal = new Garradin_Compta_Journal;

$solde = $journal->getSolde($compte['id']);

if (($compte['position'] & Garradin_Compta_Comptes::ACTIF) || ($compte['position'] & Garradin_Compta_Comptes::CHARGE))
{
    $tpl->assign('credit', '-');
    $tpl->assign('debit', '+');
}
else
{
    $tpl->assign('credit', '+');

>










<
|



|







1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
24
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

$compte = $comptes->get(utils::get('id'));

if (!$compte)
{
    throw new UserException("Le compte demandé n'existe pas.");
}


$journal = new Compta_Journal;

$solde = $journal->getSolde($compte['id']);

if (($compte['position'] & Compta_Comptes::ACTIF) || ($compte['position'] & Compta_Comptes::CHARGE))
{
    $tpl->assign('credit', '-');
    $tpl->assign('debit', '+');
}
else
{
    $tpl->assign('credit', '+');

Modified www/admin/compta/comptes/modifier.php from [90c9a3da26] to [6b5daa24ea].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$id = utils::get('id');
$compte = $comptes->get($id);


>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$id = utils::get('id');
$compte = $comptes->get($id);

Modified www/admin/compta/comptes/supprimer.php from [34fc693a7f] to [182753fafe].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$id = utils::get('id');
$compte = $comptes->get($id);


>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$id = utils::get('id');
$compte = $comptes->get($id);

Modified www/admin/compta/exercices/ajouter.php from [58c4c8a7f1] to [09ec7794c9].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';

$e = new Garradin_Compta_Exercices;

$error = false;

if (!empty($_POST['add']))
{
    if (!utils::CSRF_check('compta_ajout_exercice'))
    {

>



|




<
<
|







1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}



$e = new Compta_Exercices;

$error = false;

if (!empty($_POST['add']))
{
    if (!utils::CSRF_check('compta_ajout_exercice'))
    {

Modified www/admin/compta/exercices/bilan.php from [fb00a50299] to [34d5f4e5a6].

1
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php


require_once __DIR__ . '/../_inc.php';

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
$exercices = new Garradin_Compta_Exercices;

$exercice = $exercices->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

$liste_comptes = $comptes->getListAll();

function get_nom_compte($compte)
{
	global $liste_comptes;
	return $liste_comptes[$compte];
}

$tpl->register_modifier('get_nom_compte', 'get_nom_compte');
$tpl->assign('bilan', $exercices->getBilan($exercice['id']));

$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);

$tpl->display('admin/compta/exercices/bilan.tpl');

?>


>


<
|
















|








1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

namespace Garradin;
require_once __DIR__ . '/../_inc.php';


$exercices = new Compta_Exercices;

$exercice = $exercices->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

$liste_comptes = $comptes->getListAll();

function get_nom_compte($compte)
{
	global $liste_comptes;
	return $liste_comptes[$compte];
}

$tpl->register_modifier('get_nom_compte', 'Garradin\get_nom_compte');
$tpl->assign('bilan', $exercices->getBilan($exercice['id']));

$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);

$tpl->display('admin/compta/exercices/bilan.tpl');

?>

Modified www/admin/compta/exercices/cloturer.php from [7fd9817659] to [8a9abb1f9f].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
$e = new Garradin_Compta_Exercices;

$exercice = $e->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$e = new Compta_Exercices;

$exercice = $e->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

Modified www/admin/compta/exercices/compte_resultat.php from [5f95d64742] to [1bbee3194f].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php


require_once __DIR__ . '/../_inc.php';

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
$exercices = new Garradin_Compta_Exercices;

$exercice = $exercices->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

$liste_comptes = $comptes->getListAll();

function get_nom_compte($compte)
{
	global $liste_comptes;
	return $liste_comptes[$compte];
}

$tpl->register_modifier('get_nom_compte', 'get_nom_compte');
$tpl->assign('compte_resultat', $exercices->getCompteResultat($exercice['id']));

$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);

$tpl->display('admin/compta/exercices/compte_resultat.tpl');

?>

>



<
|
















|








1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';


$exercices = new Compta_Exercices;

$exercice = $exercices->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

$liste_comptes = $comptes->getListAll();

function get_nom_compte($compte)
{
	global $liste_comptes;
	return $liste_comptes[$compte];
}

$tpl->register_modifier('get_nom_compte', 'Garradin\get_nom_compte');
$tpl->assign('compte_resultat', $exercices->getCompteResultat($exercice['id']));

$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);

$tpl->display('admin/compta/exercices/compte_resultat.tpl');

?>

Modified www/admin/compta/exercices/grand_livre.php from [45472657f2] to [be02a28b84].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php


require_once __DIR__ . '/../_inc.php';

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
$exercices = new Garradin_Compta_Exercices;

$exercice = $exercices->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

$liste_comptes = $comptes->getListAll();

function get_nom_compte($compte)
{
	global $liste_comptes;
	return $liste_comptes[$compte];
}

$tpl->register_modifier('get_nom_compte', 'get_nom_compte');
$tpl->assign('livre', $exercices->getGrandLivre($exercice['id']));

$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);

$tpl->display('admin/compta/exercices/grand_livre.tpl');

?>

>



<
|
















|








1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';


$exercices = new Compta_Exercices;

$exercice = $exercices->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

$liste_comptes = $comptes->getListAll();

function get_nom_compte($compte)
{
	global $liste_comptes;
	return $liste_comptes[$compte];
}

$tpl->register_modifier('get_nom_compte', 'Garradin\get_nom_compte');
$tpl->assign('livre', $exercices->getGrandLivre($exercice['id']));

$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);

$tpl->display('admin/compta/exercices/grand_livre.tpl');

?>

Modified www/admin/compta/exercices/index.php from [d50a5e3189] to [5b2ebbf44d].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
<?php


require_once __DIR__ . '/../_inc.php';

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';

$e = new Garradin_Compta_Exercices;

$tpl->assign('liste', $e->getList());
$tpl->assign('current', $e->getCurrent());

$tpl->display('admin/compta/exercices/index.tpl');

?>

>



<
<
|







1
2
3
4
5


6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';



$e = new Compta_Exercices;

$tpl->assign('liste', $e->getList());
$tpl->assign('current', $e->getCurrent());

$tpl->display('admin/compta/exercices/index.tpl');

?>

Modified www/admin/compta/exercices/journal.php from [76b24a8693] to [4fbf523f4a].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php


require_once __DIR__ . '/../_inc.php';

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
$exercices = new Garradin_Compta_Exercices;

$exercice = $exercices->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

$liste_comptes = $comptes->getListAll();

function get_nom_compte($compte)
{
	global $liste_comptes;
	return $liste_comptes[$compte];
}

$tpl->register_modifier('get_nom_compte', 'get_nom_compte');
$tpl->assign('journal', $exercices->getJournal($exercice['id']));

$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);

$tpl->display('admin/compta/exercices/journal.tpl');

?>

>



<
|
















|








1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';


$exercices = new Compta_Exercices;

$exercice = $exercices->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

$liste_comptes = $comptes->getListAll();

function get_nom_compte($compte)
{
	global $liste_comptes;
	return $liste_comptes[$compte];
}

$tpl->register_modifier('get_nom_compte', 'Garradin\get_nom_compte');
$tpl->assign('journal', $exercices->getJournal($exercice['id']));

$tpl->assign('cloture', $exercice['cloture'] ? $exercice['fin'] : time());
$tpl->assign('exercice', $exercice);

$tpl->display('admin/compta/exercices/journal.tpl');

?>

Modified www/admin/compta/exercices/modifier.php from [728b071b8f] to [2fc5a1ee59].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
$e = new Garradin_Compta_Exercices;

$exercice = $e->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$e = new Compta_Exercices;

$exercice = $e->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

Modified www/admin/compta/exercices/supprimer.php from [9797c642e7] to [40563bfe34].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
$e = new Garradin_Compta_Exercices;

$exercice = $e->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$e = new Compta_Exercices;

$exercice = $e->get((int)utils::get('id'));

if (!$exercice)
{
	throw new UserException('Exercice inconnu.');
}

Modified www/admin/compta/graph.php from [c331553672] to [051251e8e7].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php


require_once __DIR__ . '/_inc.php';

if (!in_array(utils::get('g'), array('recettes_depenses', 'banques_caisses', 'dettes')))
{
	throw new UserException('Graphique inconnu.');
}

$graph = utils::get('g');

define('GRAPH_CACHE_DIR', GARRADIN_ROOT . '/cache/static');

if (!file_exists(GRAPH_CACHE_DIR))
{
	mkdir(GRAPH_CACHE_DIR);
}

require_once GARRADIN_ROOT . '/include/lib.static_cache.php';
Static_Cache::setCacheDir(GRAPH_CACHE_DIR);

if (Static_Cache::expired('graph_' . $graph))
{
	require_once GARRADIN_ROOT . '/include/class.compta_stats.php';
	$stats = new Garradin_Compta_Stats;

	require_once GARRADIN_ROOT . '/include/libs/svgplot/lib.svgplot.php';

	$plot = new SVGPlot(400, 300);

	if ($graph == 'recettes_depenses')
	{
		$r = new SVGPlot_Data($stats->recettes());
		$r->title = 'Recettes';

		$d = new SVGPlot_Data($stats->depenses());
		$d->title = 'Dépenses';

		$data = array($r, $d);

		$plot->setTitle('Recettes et dépenses de l\'exercice courant');

		$labels = array();

		foreach ($r->get() as $k=>$v)
		{
			$labels[] = utils::date_fr('M y', strtotime(substr($k, 0, 4) . '-' . substr($k, 4, 2) .'-01'));
		}

		$plot->setLabels($labels);
	}
	elseif ($graph == 'banques_caisses')
	{
		require_once GARRADIN_ROOT . '/include/class.compta_comptes_bancaires.php';
		$banques = new Garradin_Compta_Comptes_Bancaires;

		$data = array();

		$r = new SVGPlot_Data($stats->soldeCompte(Garradin_Compta_Comptes::CAISSE));
		$r->title = 'Caisse';

		$data[] = $r;

		foreach ($banques->getList() as $banque)
		{
			$r = new SVGPlot_Data($stats->soldeCompte($banque['id']));
			$r->title = $banque['libelle'];
			$data[] = $r;
		}

		$plot->setTitle('Solde des comptes et caisses');
	}
	elseif ($graph == 'dettes')
	{
		$data = array();

		$r = new SVGPlot_Data($stats->soldeCompte('401%', 'credit', 'debit'));
		$r->title = 'Dettes fournisseurs';
		$data[] = $r;

		$r = new SVGPlot_Data($stats->soldeCompte('411%', 'credit', 'debit'));
		$r->title = 'Dettes usagers';
		$data[] = $r;

		$plot->setTitle('Dettes');
	}

	if (!empty($data))

>

















<




<
|



|



|


|

















<
|



|






|










|



|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

if (!in_array(utils::get('g'), array('recettes_depenses', 'banques_caisses', 'dettes')))
{
	throw new UserException('Graphique inconnu.');
}

$graph = utils::get('g');

define('GRAPH_CACHE_DIR', GARRADIN_ROOT . '/cache/static');

if (!file_exists(GRAPH_CACHE_DIR))
{
	mkdir(GRAPH_CACHE_DIR);
}


Static_Cache::setCacheDir(GRAPH_CACHE_DIR);

if (Static_Cache::expired('graph_' . $graph))
{

	$stats = new Compta_Stats;

	require_once GARRADIN_ROOT . '/include/libs/svgplot/lib.svgplot.php';

	$plot = new \SVGPlot(400, 300);

	if ($graph == 'recettes_depenses')
	{
		$r = new \SVGPlot_Data($stats->recettes());
		$r->title = 'Recettes';

		$d = new \SVGPlot_Data($stats->depenses());
		$d->title = 'Dépenses';

		$data = array($r, $d);

		$plot->setTitle('Recettes et dépenses de l\'exercice courant');

		$labels = array();

		foreach ($r->get() as $k=>$v)
		{
			$labels[] = utils::date_fr('M y', strtotime(substr($k, 0, 4) . '-' . substr($k, 4, 2) .'-01'));
		}

		$plot->setLabels($labels);
	}
	elseif ($graph == 'banques_caisses')
	{

		$banques = new Compta_Comptes_Bancaires;

		$data = array();

		$r = new \SVGPlot_Data($stats->soldeCompte(Compta_Comptes::CAISSE));
		$r->title = 'Caisse';

		$data[] = $r;

		foreach ($banques->getList() as $banque)
		{
			$r = new \SVGPlot_Data($stats->soldeCompte($banque['id']));
			$r->title = $banque['libelle'];
			$data[] = $r;
		}

		$plot->setTitle('Solde des comptes et caisses');
	}
	elseif ($graph == 'dettes')
	{
		$data = array();

		$r = new \SVGPlot_Data($stats->soldeCompte('401%', 'credit', 'debit'));
		$r->title = 'Dettes fournisseurs';
		$data[] = $r;

		$r = new \SVGPlot_Data($stats->soldeCompte('411%', 'credit', 'debit'));
		$r->title = 'Dettes usagers';
		$data[] = $r;

		$plot->setTitle('Dettes');
	}

	if (!empty($data))

Modified www/admin/compta/import.php from [6c40e72a5a] to [c88663e1e0].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php


require_once __DIR__ . '/_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
$e = new Garradin_Compta_Exercices;

require_once GARRADIN_ROOT . '/include/class.compta_import.php';
$import = new Garradin_Compta_Import;

if (isset($_GET['export']))
{
    header('Content-type: application/csv');
    header('Content-Disposition: attachment; filename="Export comptabilité - ' . $config->get('nom_asso') . ' - ' . date('Y-m-d') . '.csv"');
    $import->toCSV($e->getCurrentId());
    exit;

>



|




<
|
<
<
|







1
2
3
4
5
6
7
8
9
10

11


12
13
14
15
16
17
18
19
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$e = new Compta_Exercices;


$import = new Compta_Import;

if (isset($_GET['export']))
{
    header('Content-type: application/csv');
    header('Content-Disposition: attachment; filename="Export comptabilité - ' . $config->get('nom_asso') . ' - ' . date('Y-m-d') . '.csv"');
    $import->toCSV($e->getCurrentId());
    exit;

Modified www/admin/compta/index.php from [42aa9c4768] to [ebf65a5059].

1

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


require_once __DIR__ . '/_inc.php';

require_once GARRADIN_ROOT . '/include/class.compta_journal.php';
$journal = new Garradin_Compta_Journal;

$tpl->display('admin/compta/index.tpl');

?>

>



<
|




1
2
3
4
5

6
7
8
9
10
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';


$journal = new Compta_Journal;

$tpl->display('admin/compta/index.tpl');

?>

Modified www/admin/compta/operations/index.php from [a55a0affee] to [272fd61633].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php


require_once __DIR__ . '/../_inc.php';

require_once GARRADIN_ROOT . '/include/class.compta_categories.php';

$cats = new Garradin_Compta_Categories;
$cat = $type = false;

if (utils::get('cat'))
{
	$cat = $cats->get(utils::get('cat'));

	if (!$cat)
	{
		throw new UserException("La catégorie demandée n'existe pas.");
	}

	$type = $cat['type'];
}
else
{
	if (isset($_GET['autres']))
		$type = Garradin_Compta_Categories::AUTRES;
	elseif (isset($_GET['depenses']))
		$type = Garradin_Compta_Categories::DEPENSES;
	else
		$type = Garradin_Compta_Categories::RECETTES;
}

require_once GARRADIN_ROOT . '/include/class.compta_journal.php';
$journal = new Garradin_Compta_Journal;

$list = $journal->getListForCategory($type === Garradin_Compta_Categories::AUTRES ? null : $type, $cat ? $cat['id'] : null);

$tpl->assign('categorie', $cat);
$tpl->assign('journal', $list);
$tpl->assign('type', $type);

if ($type !== Garradin_Compta_Categories::AUTRES)
{
	$tpl->assign('liste_cats', $cats->getList($type));
}

$total = 0.0;

foreach ($list as $row)

>



<
<
|
















|

|

|


<
|

|





|







1
2
3
4
5


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';



$cats = new Compta_Categories;
$cat = $type = false;

if (utils::get('cat'))
{
	$cat = $cats->get(utils::get('cat'));

	if (!$cat)
	{
		throw new UserException("La catégorie demandée n'existe pas.");
	}

	$type = $cat['type'];
}
else
{
	if (isset($_GET['autres']))
		$type = Compta_Categories::AUTRES;
	elseif (isset($_GET['depenses']))
		$type = Compta_Categories::DEPENSES;
	else
		$type = Compta_Categories::RECETTES;
}


$journal = new Compta_Journal;

$list = $journal->getListForCategory($type === Compta_Categories::AUTRES ? null : $type, $cat ? $cat['id'] : null);

$tpl->assign('categorie', $cat);
$tpl->assign('journal', $list);
$tpl->assign('type', $type);

if ($type !== Compta_Categories::AUTRES)
{
	$tpl->assign('liste_cats', $cats->getList($type));
}

$total = 0.0;

foreach ($list as $row)

Modified www/admin/compta/operations/modifier.php from [1f384e474b] to [7e09e8ab8b].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_journal.php';
$journal = new Garradin_Compta_Journal;

require_once GARRADIN_ROOT . '/include/class.compta_categories.php';
$cats = new Garradin_Compta_Categories;

require_once GARRADIN_ROOT . '/include/class.compta_comptes_bancaires.php';
$banques = new Garradin_Compta_Comptes_Bancaires;

$operation = $journal->get(utils::get('id'));

if (!$operation)
{
    throw new UserException("L'opération demandée n'existe pas.");
}

if ($operation['id_categorie'])
{
    $categorie = $cats->get($operation['id_categorie']);
}
else
{
    $categorie = false;
}

if ($categorie && $categorie['type'] != Garradin_Compta_Categories::AUTRES)
{
    $type = $categorie['type'];
}
else
{
    $type = null;
}

>



|




<
|
<
<
|
<
<
|

















|







1
2
3
4
5
6
7
8
9
10

11


12


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$journal = new Compta_Journal;


$cats = new Compta_Categories;


$banques = new Compta_Comptes_Bancaires;

$operation = $journal->get(utils::get('id'));

if (!$operation)
{
    throw new UserException("L'opération demandée n'existe pas.");
}

if ($operation['id_categorie'])
{
    $categorie = $cats->get($operation['id_categorie']);
}
else
{
    $categorie = false;
}

if ($categorie && $categorie['type'] != Compta_Categories::AUTRES)
{
    $type = $categorie['type'];
}
else
{
    $type = null;
}
77
78
79
80
81
82
83
84
85
86
87
88
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
                if (!array_key_exists(utils::post('moyen_paiement'), $cats->listMoyensPaiement()))
                {
                    throw new UserException('Moyen de paiement invalide.');
                }

                if (utils::post('moyen_paiement') == 'ES')
                {
                    $a = Garradin_Compta_Comptes::CAISSE;
                    $b = $cat['compte'];
                }
                else
                {
                    if (!trim(utils::post('banque')))
                    {
                        throw new UserException('Le compte bancaire choisi est invalide.');
                    }

                    if (!array_key_exists(utils::post('banque'), $banques->getList()))
                    {
                        throw new UserException('Le compte bancaire choisi n\'existe pas.');
                    }

                    $a = utils::post('banque');
                    $b = $cat['compte'];
                }

                if ($type == Garradin_Compta_Categories::DEPENSES)
                {
                    $debit = $b;
                    $credit = $a;
                }
                elseif ($type == Garradin_Compta_Categories::RECETTES)
                {
                    $debit = $a;
                    $credit = $b;
                }

                $journal->edit($operation['id'], array(
                    'libelle'       =>  utils::post('libelle'),







|


















|




|







73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
                if (!array_key_exists(utils::post('moyen_paiement'), $cats->listMoyensPaiement()))
                {
                    throw new UserException('Moyen de paiement invalide.');
                }

                if (utils::post('moyen_paiement') == 'ES')
                {
                    $a = Compta_Comptes::CAISSE;
                    $b = $cat['compte'];
                }
                else
                {
                    if (!trim(utils::post('banque')))
                    {
                        throw new UserException('Le compte bancaire choisi est invalide.');
                    }

                    if (!array_key_exists(utils::post('banque'), $banques->getList()))
                    {
                        throw new UserException('Le compte bancaire choisi n\'existe pas.');
                    }

                    $a = utils::post('banque');
                    $b = $cat['compte'];
                }

                if ($type == Compta_Categories::DEPENSES)
                {
                    $debit = $b;
                    $credit = $a;
                }
                elseif ($type == Compta_Categories::RECETTES)
                {
                    $debit = $a;
                    $credit = $b;
                }

                $journal->edit($operation['id'], array(
                    'libelle'       =>  utils::post('libelle'),

Modified www/admin/compta/operations/saisir.php from [1e26ed2699] to [d4241581d2].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_journal.php';
$journal = new Garradin_Compta_Journal;

$journal->checkExercice();

require_once GARRADIN_ROOT . '/include/class.compta_categories.php';
$cats = new Garradin_Compta_Categories;

require_once GARRADIN_ROOT . '/include/class.compta_comptes_bancaires.php';
$banques = new Garradin_Compta_Comptes_Bancaires;

if (isset($_GET['depense']))
    $type = Garradin_Compta_Categories::DEPENSES;
elseif (isset($_GET['virement']))
    $type = 'virement';
elseif (isset($_GET['dette']))
    $type = 'dette';
elseif (isset($_GET['avance']))
    $type = null;
else
    $type = Garradin_Compta_Categories::RECETTES;

$error = false;

if (!empty($_POST['save']))
{
    if (!utils::CSRF_check('compta_saisie'))
    {

>



|




<
|



<
|
<
<
|


|







|







1
2
3
4
5
6
7
8
9
10

11
12
13
14

15


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$journal = new Compta_Journal;

$journal->checkExercice();


$cats = new Compta_Categories;


$banques = new Compta_Comptes_Bancaires;

if (isset($_GET['depense']))
    $type = Compta_Categories::DEPENSES;
elseif (isset($_GET['virement']))
    $type = 'virement';
elseif (isset($_GET['dette']))
    $type = 'dette';
elseif (isset($_GET['avance']))
    $type = null;
else
    $type = Compta_Categories::RECETTES;

$error = false;

if (!empty($_POST['save']))
{
    if (!utils::CSRF_check('compta_saisie'))
    {
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
                    if (!array_key_exists(utils::post('moyen_paiement'), $cats->listMoyensPaiement()))
                    {
                        throw new UserException('Moyen de paiement invalide.');
                    }

                    if (utils::post('moyen_paiement') == 'ES')
                    {
                        $a = Garradin_Compta_Comptes::CAISSE;
                        $b = $cat['compte'];
                    }
                    else
                    {
                        if (!trim(utils::post('banque')))
                        {
                            throw new UserException('Le compte bancaire choisi est invalide.');
                        }

                        if (!array_key_exists(utils::post('banque'), $banques->getList()))
                        {
                            throw new UserException('Le compte bancaire choisi n\'existe pas.');
                        }

                        $a = utils::post('banque');
                        $b = $cat['compte'];
                    }
                }

                if ($type === Garradin_Compta_Categories::DEPENSES)
                {
                    $debit = $b;
                    $credit = $a;
                }
                elseif ($type === Garradin_Compta_Categories::RECETTES)
                {
                    $debit = $a;
                    $credit = $b;
                }
                elseif ($type === 'dette')
                {
                    $debit = $cat['compte'];







|



















|




|







86
87
88
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
                    if (!array_key_exists(utils::post('moyen_paiement'), $cats->listMoyensPaiement()))
                    {
                        throw new UserException('Moyen de paiement invalide.');
                    }

                    if (utils::post('moyen_paiement') == 'ES')
                    {
                        $a = Compta_Comptes::CAISSE;
                        $b = $cat['compte'];
                    }
                    else
                    {
                        if (!trim(utils::post('banque')))
                        {
                            throw new UserException('Le compte bancaire choisi est invalide.');
                        }

                        if (!array_key_exists(utils::post('banque'), $banques->getList()))
                        {
                            throw new UserException('Le compte bancaire choisi n\'existe pas.');
                        }

                        $a = utils::post('banque');
                        $b = $cat['compte'];
                    }
                }

                if ($type === Compta_Categories::DEPENSES)
                {
                    $debit = $b;
                    $credit = $a;
                }
                elseif ($type === Compta_Categories::RECETTES)
                {
                    $debit = $a;
                    $credit = $b;
                }
                elseif ($type === 'dette')
                {
                    $debit = $cat['compte'];
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
                    'id_categorie'  =>  ($type === 'dette') ? null : (int)$cat['id'],
                    'id_auteur'     =>  $user['id'],
                ));
            }

            $membres->sessionStore('compta_date', utils::post('date'));

            if ($type == Garradin_Compta_Categories::DEPENSES)
                $type = 'depense';
            elseif (is_null($type))
                $type = 'avance';
            elseif ($type == Garradin_Compta_Categories::RECETTES)
                $type = 'recette';

            utils::redirect('/admin/compta/operations/saisir.php?'.$type.'&ok='.(int)$id);
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();







|



|







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
                    'id_categorie'  =>  ($type === 'dette') ? null : (int)$cat['id'],
                    'id_auteur'     =>  $user['id'],
                ));
            }

            $membres->sessionStore('compta_date', utils::post('date'));

            if ($type == Compta_Categories::DEPENSES)
                $type = 'depense';
            elseif (is_null($type))
                $type = 'avance';
            elseif ($type == Compta_Categories::RECETTES)
                $type = 'recette';

            utils::redirect('/admin/compta/operations/saisir.php?'.$type.'&ok='.(int)$id);
        }
        catch (UserException $e)
        {
            $error = $e->getMessage();
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
{
    $tpl->assign('comptes', $comptes->listTree());
}
else
{
    $tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
    $tpl->assign('moyen_paiement', utils::post('moyen_paiement') ?: 'ES');
    $tpl->assign('categories', $cats->getList($type === 'dette' ? Garradin_Compta_Categories::DEPENSES : $type));
    $tpl->assign('comptes_bancaires', $banques->getList());
    $tpl->assign('banque', utils::post('banque'));
}

if (!$membres->sessionGet('compta_date'))
{
    require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
    $exercices = new Garradin_Compta_Exercices;
    $exercice = $exercices->getCurrent();

    if ($exercice['debut'] > time() || $exercice['fin'] < time())
    {
        $membres->sessionStore('compta_date', date('Y-m-d', $exercice['debut']));
    }
    else







|






<
|







167
168
169
170
171
172
173
174
175
176
177
178
179
180

181
182
183
184
185
186
187
188
{
    $tpl->assign('comptes', $comptes->listTree());
}
else
{
    $tpl->assign('moyens_paiement', $cats->listMoyensPaiement());
    $tpl->assign('moyen_paiement', utils::post('moyen_paiement') ?: 'ES');
    $tpl->assign('categories', $cats->getList($type === 'dette' ? Compta_Categories::DEPENSES : $type));
    $tpl->assign('comptes_bancaires', $banques->getList());
    $tpl->assign('banque', utils::post('banque'));
}

if (!$membres->sessionGet('compta_date'))
{

    $exercices = new Compta_Exercices;
    $exercice = $exercices->getCurrent();

    if ($exercice['debut'] > time() || $exercice['fin'] < time())
    {
        $membres->sessionStore('compta_date', date('Y-m-d', $exercice['debut']));
    }
    else

Modified www/admin/compta/operations/supprimer.php from [991aa49481] to [1766cca412].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.compta_journal.php';
$journal = new Garradin_Compta_Journal;

$operation = $journal->get(utils::get('id'));

if (!$operation)
{
    throw new UserException("L'opération demandée n'existe pas.");
}

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['compta'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$journal = new Compta_Journal;

$operation = $journal->get(utils::get('id'));

if (!$operation)
{
    throw new UserException("L'opération demandée n'existe pas.");
}

Modified www/admin/compta/operations/voir.php from [37d6bd592e] to [aeff1e102d].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php


require_once __DIR__ . '/../_inc.php';

require_once GARRADIN_ROOT . '/include/class.compta_journal.php';
$journal = new Garradin_Compta_Journal;

$operation = $journal->get(utils::get('id'));

if (!$operation)
{
    throw new UserException("L'opération demandée n'existe pas.");
}

require_once GARRADIN_ROOT . '/include/class.compta_categories.php';
require_once GARRADIN_ROOT . '/include/class.compta_exercices.php';
$exercices = new Garradin_Compta_Exercices;

$tpl->assign('operation', $operation);

$credit = $comptes->get($operation['compte_credit']);
$tpl->assign('nom_compte_credit', $credit['libelle']);

$debit = $comptes->get($operation['compte_debit']);
$tpl->assign('nom_compte_debit', $debit['libelle']);

$tpl->assign('exercice', $exercices->get($operation['id_exercice']));

if ($operation['id_categorie'])
{
    $cats = new Garradin_Compta_Categories;

    $categorie = $cats->get($operation['id_categorie']);
    $tpl->assign('categorie', $categorie);

    if ($categorie['type'] == Garradin_Compta_Categories::RECETTES)
    {
        $tpl->assign('compte', $debit['libelle']);
    }
    else
    {
        $tpl->assign('compte', $credit['libelle']);
    }

>



<
|







<
<
<
|













|




|







1
2
3
4
5

6
7
8
9
10
11
12
13



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';


$journal = new Compta_Journal;

$operation = $journal->get(utils::get('id'));

if (!$operation)
{
    throw new UserException("L'opération demandée n'existe pas.");
}



$exercices = new Compta_Exercices;

$tpl->assign('operation', $operation);

$credit = $comptes->get($operation['compte_credit']);
$tpl->assign('nom_compte_credit', $credit['libelle']);

$debit = $comptes->get($operation['compte_debit']);
$tpl->assign('nom_compte_debit', $debit['libelle']);

$tpl->assign('exercice', $exercices->get($operation['id_exercice']));

if ($operation['id_categorie'])
{
    $cats = new Compta_Categories;

    $categorie = $cats->get($operation['id_categorie']);
    $tpl->assign('categorie', $categorie);

    if ($categorie['type'] == Compta_Categories::RECETTES)
    {
        $tpl->assign('compte', $debit['libelle']);
    }
    else
    {
        $tpl->assign('compte', $credit['libelle']);
    }

Modified www/admin/config/index.php from [5464e2ccad] to [7317baac5f].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['config'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$error = false;

if (isset($_GET['ok']))

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['config'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$error = false;

if (isset($_GET['ok']))

Modified www/admin/config/membres.php from [cf27d4d861] to [29f5a4b562].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['config'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$error = false;

if (isset($_GET['ok']))

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['config'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$error = false;

if (isset($_GET['ok']))
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

$cats = new Garradin_Membres_Categories;
$tpl->assign('membres_cats', $cats->listSimple());

$tpl->assign('champs_membres', $config->getChampsMembres());
$tpl->assign('error', $error);

$tpl->display('admin/config/membres.tpl');

?>







<
<
|








34
35
36
37
38
39
40


41
42
43
44
45
46
47
48
49
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}



$cats = new Membres_Categories;
$tpl->assign('membres_cats', $cats->listSimple());

$tpl->assign('champs_membres', $config->getChampsMembres());
$tpl->assign('error', $error);

$tpl->display('admin/config/membres.tpl');

?>

Modified www/admin/config/site.php from [6f62adaff8] to [280581e919].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['config'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.squelette.php';

$error = false;

if (isset($_GET['ok']))
{
    $error = 'OK';
}


>



|




<
<







1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['config'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}



$error = false;

if (isset($_GET['ok']))
{
    $error = 'OK';
}

Modified www/admin/index.php from [93f2fa5ed9] to [fa023c719f].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php


require_once __DIR__ . '/_inc.php';

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

$cats = new Garradin_Membres_Categories;
$categorie = $cats->get($user['id_categorie']);

$tpl->assign('categorie', $categorie);
$tpl->assign('verif_cotisation', Garradin_Membres::checkCotisation($user['date_cotisation'], $categorie['duree_cotisation']));

$tpl->display('admin/index.tpl');

?>

>



<
<
|



|




1
2
3
4
5


6
7
8
9
10
11
12
13
14
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';



$cats = new Membres_Categories;
$categorie = $cats->get($user['id_categorie']);

$tpl->assign('categorie', $categorie);
$tpl->assign('verif_cotisation', Membres::checkCotisation($user['date_cotisation'], $categorie['duree_cotisation']));

$tpl->display('admin/index.tpl');

?>

Modified www/admin/install.php from [d62336b07f] to [495d72a3bc].

1

2
3
4
5
6
7
8
<?php


/*
 * Tests : vérification que les conditions pour s'exécuter sont remplies
 */

$tests = array(
    'La version de PHP installée est inférieure à 5.3 !'

>







1
2
3
4
5
6
7
8
9
<?php
namespace Garradin;

/*
 * Tests : vérification que les conditions pour s'exécuter sont remplies
 */

$tests = array(
    'La version de PHP installée est inférieure à 5.3 !'
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

    exit;
}

define('GARRADIN_INSTALL_PROCESS', true);

require_once __DIR__ . '/../../include/init.php';
require_once GARRADIN_ROOT . '/include/class.membres.php';
require_once GARRADIN_ROOT . '/include/template.php';

if (file_exists(GARRADIN_DB_FILE))
{
    $tpl->assign('disabled', true);
}
else







<







42
43
44
45
46
47
48

49
50
51
52
53
54
55

    exit;
}

define('GARRADIN_INSTALL_PROCESS', true);

require_once __DIR__ . '/../../include/init.php';

require_once GARRADIN_ROOT . '/include/template.php';

if (file_exists(GARRADIN_DB_FILE))
{
    $tpl->assign('disabled', true);
}
else
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
160
161
162
163
164
165
166
        elseif (utils::post('passe_membre') != utils::post('repasse_membre'))
        {
            $error = 'La vérification ne correspond pas au mot de passe.';
        }
        else
        {
            try {
                require_once GARRADIN_ROOT . '/include/class.db.php';
                require_once GARRADIN_ROOT . '/include/class.config.php';

                // Configuration de base
                $config = Garradin_Config::getInstance();
                $config->set('nom_asso', utils::post('nom_asso'));
                $config->set('adresse_asso', utils::post('adresse_asso'));
                $config->set('email_asso', utils::post('email_asso'));
                $config->set('site_asso', utils::post('site_asso'));
                $config->set('monnaie', '€');
                $config->set('pays', 'FR');
                $config->set('email_envoi_automatique', utils::post('email_asso'));
                $config->set('champs_obligatoires', array('passe', 'email'));
                $config->set('champs_modifiables_membre', array('passe', 'email', 'adresse',
                    'code_postal', 'ville', 'pays', 'telephone', 'date_naissance'));
                $config->setVersion(garradin_version());

                // Création catégories
                require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

                $cats = new Garradin_Membres_Categories;
                $id = $cats->add(array(
                    'nom' => 'Membres actifs',
                    'montant_cotisation' => 10));
                $config->set('categorie_membres', $id);

                $id = $cats->add(array(
                    'nom' => 'Anciens membres',
                    'montant_cotisation' => 0,
                    'droit_inscription' => Garradin_Membres::DROIT_AUCUN,
                    'droit_wiki' => Garradin_Membres::DROIT_AUCUN,
                    'droit_membres' => Garradin_Membres::DROIT_AUCUN,
                    'droit_compta' => Garradin_Membres::DROIT_AUCUN,
                    'droit_config' => Garradin_Membres::DROIT_AUCUN,
                    'droit_connexion' => Garradin_Membres::DROIT_AUCUN,
                    'cacher' => 1,
                    ));

                $id = $cats->add(array(
                    'nom' => ucfirst(utils::post('cat_membre')),
                    'montant_cotisation' => 0,
                    'droit_inscription' => Garradin_Membres::DROIT_AUCUN,
                    'droit_wiki' => Garradin_Membres::DROIT_ADMIN,
                    'droit_membres' => Garradin_Membres::DROIT_ADMIN,
                    'droit_compta' => Garradin_Membres::DROIT_ADMIN,
                    'droit_config' => Garradin_Membres::DROIT_ADMIN,
                    ));

                // Création premier membre
                $membres = new Garradin_Membres;
                $id_membre = $membres->add(array(
                    'id_categorie'  =>  $id,
                    'nom'           =>  utils::post('nom_membre'),
                    'email'         =>  utils::post('email_membre'),
                    'passe'         =>  utils::post('passe_membre'),
                    'pays'          =>  'FR',
                ));

                // Création wiki
                require_once GARRADIN_ROOT . '/include/class.wiki.php';
                $page = Garradin_Wiki::transformTitleToURI(utils::post('nom_asso'));
                $config->set('accueil_wiki', $page);
                $wiki = new Garradin_Wiki;
                $id_page = $wiki->create(array(
                    'titre' =>  utils::post('nom_asso'),
                    'uri'   =>  $page,
                ));

                $wiki->editRevision($id_page, 0, array(
                    'id_auteur' =>  $id_membre,
                    'contenu'   =>  "Bienvenue dans Garradin !\n\nCliquez sur le bouton « éditer » pour modifier cette page.",
                ));

                // Mise en place compta
                require GARRADIN_ROOT . '/include/class.compta_comptes.php';

                $comptes = new Garradin_Compta_Comptes;
                $comptes->importPlan();

                require GARRADIN_ROOT . '/include/class.compta_categories.php';

                $comptes = new Garradin_Compta_Categories;
                $comptes->importCategories();

                require GARRADIN_ROOT . '/include/class.compta_exercices.php';

                $ex = new Garradin_Compta_Exercices;
                $ex->add(array('libelle' => 'Premier exercice', 'debut' => date('Y-01-01'), 'fin' => date('Y-12-31')));

                $config->save();

                utils::redirect('/admin/login.php');
            }
            catch (UserException $e)







<
<
<

|













<
<
|








|
|
|
|
|
|






|
|
|
|
|



|









<
|

|











<
<
|


<
<
|


<
<
|







66
67
68
69
70
71
72



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87


88
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
        elseif (utils::post('passe_membre') != utils::post('repasse_membre'))
        {
            $error = 'La vérification ne correspond pas au mot de passe.';
        }
        else
        {
            try {



                // Configuration de base
                $config = Config::getInstance();
                $config->set('nom_asso', utils::post('nom_asso'));
                $config->set('adresse_asso', utils::post('adresse_asso'));
                $config->set('email_asso', utils::post('email_asso'));
                $config->set('site_asso', utils::post('site_asso'));
                $config->set('monnaie', '€');
                $config->set('pays', 'FR');
                $config->set('email_envoi_automatique', utils::post('email_asso'));
                $config->set('champs_obligatoires', array('passe', 'email'));
                $config->set('champs_modifiables_membre', array('passe', 'email', 'adresse',
                    'code_postal', 'ville', 'pays', 'telephone', 'date_naissance'));
                $config->setVersion(garradin_version());

                // Création catégories


                $cats = new Membres_Categories;
                $id = $cats->add(array(
                    'nom' => 'Membres actifs',
                    'montant_cotisation' => 10));
                $config->set('categorie_membres', $id);

                $id = $cats->add(array(
                    'nom' => 'Anciens membres',
                    'montant_cotisation' => 0,
                    'droit_inscription' => Membres::DROIT_AUCUN,
                    'droit_wiki' => Membres::DROIT_AUCUN,
                    'droit_membres' => Membres::DROIT_AUCUN,
                    'droit_compta' => Membres::DROIT_AUCUN,
                    'droit_config' => Membres::DROIT_AUCUN,
                    'droit_connexion' => Membres::DROIT_AUCUN,
                    'cacher' => 1,
                    ));

                $id = $cats->add(array(
                    'nom' => ucfirst(utils::post('cat_membre')),
                    'montant_cotisation' => 0,
                    'droit_inscription' => Membres::DROIT_AUCUN,
                    'droit_wiki' => Membres::DROIT_ADMIN,
                    'droit_membres' => Membres::DROIT_ADMIN,
                    'droit_compta' => Membres::DROIT_ADMIN,
                    'droit_config' => Membres::DROIT_ADMIN,
                    ));

                // Création premier membre
                $membres = new Membres;
                $id_membre = $membres->add(array(
                    'id_categorie'  =>  $id,
                    'nom'           =>  utils::post('nom_membre'),
                    'email'         =>  utils::post('email_membre'),
                    'passe'         =>  utils::post('passe_membre'),
                    'pays'          =>  'FR',
                ));

                // Création wiki

                $page = Wiki::transformTitleToURI(utils::post('nom_asso'));
                $config->set('accueil_wiki', $page);
                $wiki = new Wiki;
                $id_page = $wiki->create(array(
                    'titre' =>  utils::post('nom_asso'),
                    'uri'   =>  $page,
                ));

                $wiki->editRevision($id_page, 0, array(
                    'id_auteur' =>  $id_membre,
                    'contenu'   =>  "Bienvenue dans Garradin !\n\nCliquez sur le bouton « éditer » pour modifier cette page.",
                ));

                // Mise en place compta


                $comptes = new Compta_Comptes;
                $comptes->importPlan();



                $comptes = new Compta_Categories;
                $comptes->importCategories();



                $ex = new Compta_Exercices;
                $ex->add(array('libelle' => 'Premier exercice', 'debut' => date('Y-01-01'), 'fin' => date('Y-12-31')));

                $config->save();

                utils::redirect('/admin/login.php');
            }
            catch (UserException $e)

Modified www/admin/login.php from [9c18b1f51c] to [2e1cd5e3ac].

1

2
3
4
5
6
7
8
<?php


define('GARRADIN_LOGIN_PROCESS', true);
require_once __DIR__ . '/_inc.php';

// Relance session_start et renvoie une image de 1px transparente
if (isset($_GET['keepSessionAlive']))
{

>







1
2
3
4
5
6
7
8
9
<?php
namespace Garradin;

define('GARRADIN_LOGIN_PROCESS', true);
require_once __DIR__ . '/_inc.php';

// Relance session_start et renvoie une image de 1px transparente
if (isset($_GET['keepSessionAlive']))
{

Modified www/admin/logout.php from [a2b4b7198b] to [e871d9cd95].

1

2
3
4
5
6
7
8
9
<?php


define('GARRADIN_LOGIN_PROCESS', true);
require_once __DIR__ . '/_inc.php';

$membres->logout();
utils::redirect('/');

?>

>








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

define('GARRADIN_LOGIN_PROCESS', true);
require_once __DIR__ . '/_inc.php';

$membres->logout();
utils::redirect('/');

?>

Modified www/admin/membres/action.php from [a26315ef2d] to [15a0ce78de].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (empty($_POST['selected']))
{
    throw new UserException("Aucun membre sélectionné.");

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (empty($_POST['selected']))
{
    throw new UserException("Aucun membre sélectionné.");
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
}

$tpl->assign('selected', $_POST['selected']);
$tpl->assign('nb_selected', count($_POST['selected']));

if (!empty($_POST['move']))
{
    require_once GARRADIN_ROOT . '/include/class.membres_categories.php';
    $cats = new Garradin_Membres_Categories;

    $tpl->assign('membres_cats', $cats->listSimple());
    $tpl->assign('action', 'move');
}
elseif (!empty($_POST['delete']))
{
    $tpl->assign('action', 'delete');







<
|







58
59
60
61
62
63
64

65
66
67
68
69
70
71
72
}

$tpl->assign('selected', $_POST['selected']);
$tpl->assign('nb_selected', count($_POST['selected']));

if (!empty($_POST['move']))
{

    $cats = new Membres_Categories;

    $tpl->assign('membres_cats', $cats->listSimple());
    $tpl->assign('action', 'move');
}
elseif (!empty($_POST['delete']))
{
    $tpl->assign('action', 'delete');

Modified www/admin/membres/ajouter.php from [aede73c259] to [cf2d4eb7f8].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

$cats = new Garradin_Membres_Categories;

$error = false;

if (!empty($_POST['save']))
{
    if (!utils::CSRF_check('new_member'))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    elseif (utils::post('passe') != utils::post('repasse'))
    {
        $error = 'La vérification ne correspond pas au mot de passe.';
    }
    else
    {
        try
        {
            if ($user['droits']['membres'] == Garradin_Membres::DROIT_ADMIN)
            {
                $id_categorie = utils::post('id_categorie');
            }
            else
            {
                $id_categorie = $config->get('categorie_membres');
            }

>



|




<
<
|

















|







1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}



$cats = new Membres_Categories;

$error = false;

if (!empty($_POST['save']))
{
    if (!utils::CSRF_check('new_member'))
    {
        $error = 'Une erreur est survenue, merci de renvoyer le formulaire.';
    }
    elseif (utils::post('passe') != utils::post('repasse'))
    {
        $error = 'La vérification ne correspond pas au mot de passe.';
    }
    else
    {
        try
        {
            if ($user['droits']['membres'] == Membres::DROIT_ADMIN)
            {
                $id_categorie = utils::post('id_categorie');
            }
            else
            {
                $id_categorie = $config->get('categorie_membres');
            }

Modified www/admin/membres/cat_modifier.php from [10ff9ca9f0] to [efca9071a1].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';
$cats = new Garradin_Membres_Categories;

if (empty($_GET['id']) || !is_numeric($_GET['id']))
{
    throw new UserException("Argument du numéro de catégorie manquant.");
}

$id = (int) $_GET['id'];

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$cats = new Membres_Categories;

if (empty($_GET['id']) || !is_numeric($_GET['id']))
{
    throw new UserException("Argument du numéro de catégorie manquant.");
}

$id = (int) $_GET['id'];

Modified www/admin/membres/cat_supprimer.php from [705a16ef45] to [7ec6a968ec].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';
$cats = new Garradin_Membres_Categories;

if (empty($_GET['id']) || !is_numeric($_GET['id']))
{
    throw new UserException("Argument du numéro de catégorie manquant.");
}

$id = (int) $_GET['id'];

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$cats = new Membres_Categories;

if (empty($_GET['id']) || !is_numeric($_GET['id']))
{
    throw new UserException("Argument du numéro de catégorie manquant.");
}

$id = (int) $_GET['id'];

Modified www/admin/membres/categories.php from [0a43d0c059] to [64b9725668].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';
$cats = new Garradin_Membres_Categories;

$error = false;

if (!empty($_POST['save']))
{
    if (!utils::CSRF_check('new_cat'))
    {

>



|




<
|







1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$cats = new Membres_Categories;

$error = false;

if (!empty($_POST['save']))
{
    if (!utils::CSRF_check('new_cat'))
    {

Modified www/admin/membres/fiche.php from [0dd4fbb8f9] to [4b68d7e288].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (empty($_GET['id']) || !is_numeric($_GET['id']))
{
    throw new UserException("Argument du numéro de membre manquant.");

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (empty($_GET['id']) || !is_numeric($_GET['id']))
{
    throw new UserException("Argument du numéro de membre manquant.");
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

$cats = new Garradin_Membres_Categories;
$categorie = $cats->get($membre['id_categorie']);

$tpl->assign('categorie', $categorie);
$tpl->assign('membre', $membre);
$tpl->assign('verif_cotisation', Garradin_Membres::checkCotisation($membre['date_cotisation'], $categorie['duree_cotisation']));

if (!empty($membre['date_cotisation']))
{
    $prochaine_cotisation = new DateTime('@'.$membre['date_cotisation']);
    $prochaine_cotisation->modify('+1 year');
    $prochaine_cotisation = $prochaine_cotisation->getTimestamp();
}







<
<
|




|







45
46
47
48
49
50
51


52
53
54
55
56
57
58
59
60
61
62
63
64
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}



$cats = new Membres_Categories;
$categorie = $cats->get($membre['id_categorie']);

$tpl->assign('categorie', $categorie);
$tpl->assign('membre', $membre);
$tpl->assign('verif_cotisation', Membres::checkCotisation($membre['date_cotisation'], $categorie['duree_cotisation']));

if (!empty($membre['date_cotisation']))
{
    $prochaine_cotisation = new DateTime('@'.$membre['date_cotisation']);
    $prochaine_cotisation->modify('+1 year');
    $prochaine_cotisation = $prochaine_cotisation->getTimestamp();
}

Modified www/admin/membres/index.php from [0a0ea7feed] to [fdd9e71154].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

$cats = new Garradin_Membres_Categories;
$membres_cats = $cats->listSimple();
$membres_cats_cachees = $cats->listHidden();

$cat = (int) utils::get('cat') ?: 0;
$page = (int) utils::get('p') ?: 1;

$search_field = utils::get('search_field') ?: ($membres->sessionGet('membre_search_field') ?: 'nom');

>



|




<
<
|







1
2
3
4
5
6
7
8
9
10


11
12
13
14
15
16
17
18
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}



$cats = new Membres_Categories;
$membres_cats = $cats->listSimple();
$membres_cats_cachees = $cats->listHidden();

$cat = (int) utils::get('cat') ?: 0;
$page = (int) utils::get('p') ?: 1;

$search_field = utils::get('search_field') ?: ($membres->sessionGet('membre_search_field') ?: 'nom');
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
}

$tpl->assign('membres_cats', $membres_cats);
$tpl->assign('membres_cats_cachees', $membres_cats_cachees);
$tpl->assign('current_cat', $cat);

$tpl->assign('page', $page);
$tpl->assign('bypage', Garradin_Membres::ITEMS_PER_PAGE);

$tpl->assign('search_field', $search_field);
$tpl->assign('search_query', $search_query);

$tpl->display('admin/membres/index.tpl');

?>







|







55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
}

$tpl->assign('membres_cats', $membres_cats);
$tpl->assign('membres_cats_cachees', $membres_cats_cachees);
$tpl->assign('current_cat', $cat);

$tpl->assign('page', $page);
$tpl->assign('bypage', Membres::ITEMS_PER_PAGE);

$tpl->assign('search_field', $search_field);
$tpl->assign('search_query', $search_query);

$tpl->display('admin/membres/index.tpl');

?>

Modified www/admin/membres/message.php from [bd7b8e0fb6] to [ed8a685029].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (empty($user['email']))
{
    throw new UserException("Vous devez renseigner l'adresse e-mail dans vos informations pour pouvoir contacter les autres membres.");

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (empty($user['email']))
{
    throw new UserException("Vous devez renseigner l'adresse e-mail dans vos informations pour pouvoir contacter les autres membres.");
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

$cats = new Garradin_Membres_Categories;

$tpl->assign('categorie', $cats->get($membre['id_categorie']));
$tpl->assign('membre', $membre);
$tpl->assign('error', $error);

$tpl->display('admin/membres/message.tpl');

?>







<
<
|








54
55
56
57
58
59
60


61
62
63
64
65
66
67
68
69
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}



$cats = new Membres_Categories;

$tpl->assign('categorie', $cats->get($membre['id_categorie']));
$tpl->assign('membre', $membre);
$tpl->assign('error', $error);

$tpl->display('admin/membres/message.tpl');

?>

Modified www/admin/membres/message_collectif.php from [087d8ed3ae] to [5ce0d3d537].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$error = false;

if (!empty($_POST['save']))

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$error = false;

if (!empty($_POST['save']))
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';
$cats = new Garradin_Membres_Categories;

$tpl->assign('cats_liste', $cats->listSimple());
$tpl->assign('cats_cachees', $cats->listHidden());
$tpl->assign('error', $error);

$tpl->display('admin/membres/message_collectif.tpl');

?>







<
|








33
34
35
36
37
38
39

40
41
42
43
44
45
46
47
48
        catch (UserException $e)
        {
            $error = $e->getMessage();
        }
    }
}


$cats = new Membres_Categories;

$tpl->assign('cats_liste', $cats->listSimple());
$tpl->assign('cats_cachees', $cats->listHidden());
$tpl->assign('error', $error);

$tpl->display('admin/membres/message_collectif.tpl');

?>

Modified www/admin/membres/modifier.php from [a7f241e7e0] to [acc914fdf8].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (empty($_GET['id']) || !is_numeric($_GET['id']))
{
    throw new UserException("Argument du numéro de membre manquant.");
}

$id = (int) $_GET['id'];

$membre = $membres->get($id);

if (!$membre)
{
    throw new UserException("Ce membre n'existe pas.");
}

require_once GARRADIN_ROOT . '/include/class.membres_categories.php';

$cats = new Garradin_Membres_Categories;

// Protection contre la modification des admins par des membres moins puissants
$membre_cat = $cats->get($membre['id_categorie']);
if (($membre_cat['droit_membres'] == Garradin_Membres::DROIT_ADMIN)
    && ($user['droits']['membres'] < Garradin_Membres::DROIT_ADMIN))
{
    throw new UserException("Seul un membre admin peut modifier un autre membre admin.");
}

$error = false;

if (!empty($_POST['save']))

>



|


















<
<
|



|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24


25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (empty($_GET['id']) || !is_numeric($_GET['id']))
{
    throw new UserException("Argument du numéro de membre manquant.");
}

$id = (int) $_GET['id'];

$membre = $membres->get($id);

if (!$membre)
{
    throw new UserException("Ce membre n'existe pas.");
}



$cats = new Membres_Categories;

// Protection contre la modification des admins par des membres moins puissants
$membre_cat = $cats->get($membre['id_categorie']);
if (($membre_cat['droit_membres'] == Membres::DROIT_ADMIN)
    && ($user['droits']['membres'] < Membres::DROIT_ADMIN))
{
    throw new UserException("Seul un membre admin peut modifier un autre membre admin.");
}

$error = false;

if (!empty($_POST['save']))
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
                'ville'         =>  utils::post('ville'),
                'pays'          =>  utils::post('pays'),
                'date_naissance'=>  utils::post('date_naissance'),
                'notes'         =>  utils::post('notes'),
                'lettre_infos'  =>  utils::post('lettre_infos'),
            );

            if ($user['droits']['membres'] == Garradin_Membres::DROIT_ADMIN)
            {
                $data['id_categorie'] = utils::post('id_categorie');
                $data['id'] = utils::post('id');
            }

            $membres->edit($id, $data, false);








|







57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
                'ville'         =>  utils::post('ville'),
                'pays'          =>  utils::post('pays'),
                'date_naissance'=>  utils::post('date_naissance'),
                'notes'         =>  utils::post('notes'),
                'lettre_infos'  =>  utils::post('lettre_infos'),
            );

            if ($user['droits']['membres'] == Membres::DROIT_ADMIN)
            {
                $data['id_categorie'] = utils::post('id_categorie');
                $data['id'] = utils::post('id');
            }

            $membres->edit($id, $data, false);

85
86
87
88
89
90
91
92
93
94
95
96
97
98

$tpl->assign('membres_cats', $cats->listSimple());
$tpl->assign('current_cat', utils::post('id_categorie') ?: $membre['id_categorie']);

$tpl->assign('pays', utils::getCountryList());
$tpl->assign('current_cc', utils::post('pays') ?: $membre['pays']);

$tpl->assign('can_change_id', $user['droits']['membres'] == Garradin_Membres::DROIT_ADMIN);

$tpl->assign('membre', $membre);

$tpl->display('admin/membres/modifier.tpl');

?>







|






84
85
86
87
88
89
90
91
92
93
94
95
96
97

$tpl->assign('membres_cats', $cats->listSimple());
$tpl->assign('current_cat', utils::post('id_categorie') ?: $membre['id_categorie']);

$tpl->assign('pays', utils::getCountryList());
$tpl->assign('current_cc', utils::post('pays') ?: $membre['pays']);

$tpl->assign('can_change_id', $user['droits']['membres'] == Membres::DROIT_ADMIN);

$tpl->assign('membre', $membre);

$tpl->display('admin/membres/modifier.tpl');

?>

Modified www/admin/membres/supprimer.php from [846ef2a6a8] to [ade09b789c].

1

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


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$membre = $membres->get(utils::get('id'));

if (!$membre)

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/../_inc.php';

if ($user['droits']['membres'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

$membre = $membres->get(utils::get('id'));

if (!$membre)

Modified www/admin/mes_infos.php from [50a1cbe2cc] to [6caeebaa2e].

1

2
3
4
5
6
7
8
<?php


require_once __DIR__ . '/_inc.php';

if (count($config->get('champs_modifiables_membre')) == 0)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

>







1
2
3
4
5
6
7
8
9
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

if (count($config->get('champs_modifiables_membre')) == 0)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

Modified www/admin/password.php from [9e02a3a9a7] to [a3f7db9d48].

1

2
3
4
5
6
7
8
<?php


define('GARRADIN_LOGIN_PROCESS', true);
require_once __DIR__ . '/_inc.php';

$error = false;

if (trim(utils::get('c')))

>







1
2
3
4
5
6
7
8
9
<?php
namespace Garradin;

define('GARRADIN_LOGIN_PROCESS', true);
require_once __DIR__ . '/_inc.php';

$error = false;

if (trim(utils::get('c')))

Modified www/admin/upgrade.php from [933a24bcdc] to [ccc2bd00cb].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php


define('GARRADIN_UPGRADE_PROCESS', true);

require_once __DIR__ . '/../../include/init.php';

if (!file_exists(GARRADIN_DB_FILE))
{
    utils::redirect('/admin/install.php');
}

require_once GARRADIN_ROOT . '/include/class.db.php';
require_once GARRADIN_ROOT . '/include/class.config.php';
$config = Garradin_Config::getInstance();

$v = $config->getVersion();

if (version_compare($v, garradin_version(), '>='))
{
    throw new UserException("Pas de mise à jour à faire.");
}

$db = Garradin_DB::getInstance();

echo '<!DOCTYPE html>
<meta charset="utf-8" />
<h3>Mise à jour de Garradin '.$config->getVersion().' vers la version '.garradin_version().'...</h3>';

flush();


>










<
<
|








|







1
2
3
4
5
6
7
8
9
10
11
12


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
namespace Garradin;

define('GARRADIN_UPGRADE_PROCESS', true);

require_once __DIR__ . '/../../include/init.php';

if (!file_exists(GARRADIN_DB_FILE))
{
    utils::redirect('/admin/install.php');
}



$config = Config::getInstance();

$v = $config->getVersion();

if (version_compare($v, garradin_version(), '>='))
{
    throw new UserException("Pas de mise à jour à faire.");
}

$db = DB::getInstance();

echo '<!DOCTYPE html>
<meta charset="utf-8" />
<h3>Mise à jour de Garradin '.$config->getVersion().' vers la version '.garradin_version().'...</h3>';

flush();

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    $config->set('monnaie', '€');
    $config->set('pays', 'FR');
    $config->save();

    $db->exec(file_get_contents(GARRADIN_ROOT . '/include/data/0.4.0.sql'));

    // Mise en place compta
    require GARRADIN_ROOT . '/include/class.compta_comptes.php';

    $comptes = new Garradin_Compta_Comptes;
    $comptes->importPlan();

    require GARRADIN_ROOT . '/include/class.compta_categories.php';

    $comptes = new Garradin_Compta_Categories;
    $comptes->importCategories();
}

if (version_compare($v, '0.4.3', '<'))
{
    $db->exec(file_get_contents(GARRADIN_ROOT . '/include/data/0.4.3.sql'));
}







<
<
|


<
<
|







39
40
41
42
43
44
45


46
47
48


49
50
51
52
53
54
55
56
    $config->set('monnaie', '€');
    $config->set('pays', 'FR');
    $config->save();

    $db->exec(file_get_contents(GARRADIN_ROOT . '/include/data/0.4.0.sql'));

    // Mise en place compta


    $comptes = new Compta_Comptes;
    $comptes->importPlan();



    $comptes = new Compta_Categories;
    $comptes->importCategories();
}

if (version_compare($v, '0.4.3', '<'))
{
    $db->exec(file_get_contents(GARRADIN_ROOT . '/include/data/0.4.3.sql'));
}

Modified www/admin/wiki/_chercher_parent.php from [fbfc6a9ed9] to [effaf27acb].

1

2
3
4
5
6
7
8
<?php


require_once __DIR__ . '/_inc.php';

if ((trim(utils::get('parent')) == '') || !is_numeric(utils::get('parent')))
{
    throw new UserException('Numéro de page parent invalide.');
}

>







1
2
3
4
5
6
7
8
9
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

if ((trim(utils::get('parent')) == '') || !is_numeric(utils::get('parent')))
{
    throw new UserException('Numéro de page parent invalide.');
}
34
35
36
37
38
39
40
41
42
43
44
45
    }

    $out .= '</ul>';

    return $out;
}

$tpl->register_function('display_tree', 'tpl_display_tree');

$tpl->display('admin/wiki/_chercher_parent.tpl');

?>







|




35
36
37
38
39
40
41
42
43
44
45
46
    }

    $out .= '</ul>';

    return $out;
}

$tpl->register_function('display_tree', 'Garradin\tpl_display_tree');

$tpl->display('admin/wiki/_chercher_parent.tpl');

?>

Modified www/admin/wiki/_inc.php from [d3b19f61f8] to [cc2813c16f].

1
2

3
4
5
6
7
8
9
10
11
12
13
14
<?php


require_once __DIR__ . '/../_inc.php';

if ($user['droits']['wiki'] < Garradin_Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

require_once GARRADIN_ROOT . '/include/class.wiki.php';
$wiki = new Garradin_Wiki;
$wiki->setRestrictionCategorie($user['id_categorie'], $user['droits']['wiki']);

?>


>


|




<
|



1
2
3
4
5
6
7
8
9
10

11
12
13
14
<?php

namespace Garradin;
require_once __DIR__ . '/../_inc.php';

if ($user['droits']['wiki'] < Membres::DROIT_ACCES)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}


$wiki = new Wiki;
$wiki->setRestrictionCategorie($user['id_categorie'], $user['droits']['wiki']);

?>

Modified www/admin/wiki/chercher.php from [f2bf08b61b] to [d240a1c23d].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php


require_once __DIR__ . '/_inc.php';

$q = trim(utils::get('q'));

$tpl->assign('recherche', $q);

if (utils::get('q'))
{
    $r = $wiki->search($q);
    $tpl->assign('resultats', $r);
    $tpl->assign('nb_resultats', count($r));
}

function tpl_clean_snippet($str)
{
    return preg_replace('!&lt;(/?b)&gt;!', '<$1>', $str);
}

$tpl->register_modifier('clean_snippet', 'tpl_clean_snippet');

$tpl->display('admin/wiki/chercher.tpl');

?>

>



















|




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

$q = trim(utils::get('q'));

$tpl->assign('recherche', $q);

if (utils::get('q'))
{
    $r = $wiki->search($q);
    $tpl->assign('resultats', $r);
    $tpl->assign('nb_resultats', count($r));
}

function tpl_clean_snippet($str)
{
    return preg_replace('!&lt;(/?b)&gt;!', '<$1>', $str);
}

$tpl->register_modifier('clean_snippet', 'Garradin\tpl_clean_snippet');

$tpl->display('admin/wiki/chercher.tpl');

?>

Modified www/admin/wiki/creer.php from [1c3f44794f] to [e5fd55da62].

1

2
3
4
5
6
7
8
<?php


require_once __DIR__ . '/_inc.php';

$error = false;
$parent = (int) utils::get('parent') ?: 0;

if (!empty($_POST['create']))

>







1
2
3
4
5
6
7
8
9
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

$error = false;
$parent = (int) utils::get('parent') ?: 0;

if (!empty($_POST['create']))

Modified www/admin/wiki/editer.php from [636dd7aeb4] to [7e374d05ed].

1

2
3





4
5
6
7
8
9
10
<?php


require_once __DIR__ . '/_inc.php';






if (!utils::get('id') || !is_numeric(utils::get('id')))
{
    throw new UserException('Numéro de page invalide.');
}

$page = $wiki->getById(utils::get('id'));

>


>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

if ($user['droits']['wiki'] < Membres::DROIT_ECRITURE)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (!utils::get('id') || !is_numeric(utils::get('id')))
{
    throw new UserException('Numéro de page invalide.');
}

$page = $wiki->getById(utils::get('id'));

Modified www/admin/wiki/historique.php from [6775a3ea3a] to [ba4e72832c].

1

2
3
4
5
6
7
8
<?php


require_once __DIR__ . '/_inc.php';

if (!trim(utils::get('id')))
{
    throw new UserException("Page inconnue.");
}

>







1
2
3
4
5
6
7
8
9
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

if (!trim(utils::get('id')))
{
    throw new UserException("Page inconnue.");
}

Modified www/admin/wiki/index.php from [6eccb277f5] to [3739c3a318].

1
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php


require_once __DIR__ . '/_inc.php';

if (!empty($_SERVER['QUERY_STRING']))
{
    $page = $wiki->getByURI($_SERVER['QUERY_STRING']);
}
else
{
    $page = $wiki->getByURI($config->get('accueil_wiki'));
}

if (!$page)
{
    $tpl->assign('uri', $_SERVER['QUERY_STRING']);
    $tpl->assign('can_edit', $wiki->canWritePage(Garradin_Wiki::ECRITURE_NORMAL));
    $tpl->assign('can_read', true);
}
else
{
    $tpl->assign('can_read', $wiki->canReadPage($page['droit_lecture']));
    $tpl->assign('can_edit', $wiki->canWritePage($page['droit_ecriture']));
    $tpl->assign('children', $wiki->getList($page['uri'] == $config->get('accueil_wiki') ? 0 : $page['id']));


>














|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php

namespace Garradin;
require_once __DIR__ . '/_inc.php';

if (!empty($_SERVER['QUERY_STRING']))
{
    $page = $wiki->getByURI($_SERVER['QUERY_STRING']);
}
else
{
    $page = $wiki->getByURI($config->get('accueil_wiki'));
}

if (!$page)
{
    $tpl->assign('uri', $_SERVER['QUERY_STRING']);
    $tpl->assign('can_edit', $wiki->canWritePage(Wiki::ECRITURE_NORMAL));
    $tpl->assign('can_read', true);
}
else
{
    $tpl->assign('can_read', $wiki->canReadPage($page['droit_lecture']));
    $tpl->assign('can_edit', $wiki->canWritePage($page['droit_ecriture']));
    $tpl->assign('children', $wiki->getList($page['uri'] == $config->get('accueil_wiki') ? 0 : $page['id']));

Modified www/admin/wiki/recent.php from [be8cef1fa8] to [a9b96a50df].

1


2
3
4
5
6
7
8
9
10
11
12
13
14
<?php



require_once __DIR__ . '/_inc.php';

$page = (int) utils::get('p') ?: 1;

$tpl->assign('page', $page);
$tpl->assign('bypage', Garradin_Wiki::ITEMS_PER_PAGE);
$tpl->assign('total', $wiki->countRecentModifications());
$tpl->assign('list', $wiki->listRecentModifications($page));

$tpl->display('admin/wiki/recent.tpl');

?>

>
>






|






1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php

namespace Garradin;

require_once __DIR__ . '/_inc.php';

$page = (int) utils::get('p') ?: 1;

$tpl->assign('page', $page);
$tpl->assign('bypage', Wiki::ITEMS_PER_PAGE);
$tpl->assign('total', $wiki->countRecentModifications());
$tpl->assign('list', $wiki->listRecentModifications($page));

$tpl->display('admin/wiki/recent.tpl');

?>

Modified www/admin/wiki/supprimer.php from [4ad020de34] to [8a4e744163].

1

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


require_once __DIR__ . '/_inc.php';

if ($user['droits']['wiki'] < Garradin_Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (!trim(utils::get('id')))
{
    throw new UserException("Page inconnue.");

>



|







1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
namespace Garradin;

require_once __DIR__ . '/_inc.php';

if ($user['droits']['wiki'] < Membres::DROIT_ADMIN)
{
    throw new UserException("Vous n'avez pas le droit d'accéder à cette page.");
}

if (!trim(utils::get('id')))
{
    throw new UserException("Page inconnue.");

Modified www/index.php from [950ba75a86] to [115e526b6f].

1

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


require __DIR__ . '/_inc.php';
require_once GARRADIN_ROOT . '/include/class.squelette.php';

$squelette = new Squelette;

$squelette->dispatchURI();

?>

>


<


<



1
2
3
4

5
6

7
8
9
<?php
namespace Garradin;

require __DIR__ . '/_inc.php';


$squelette = new Squelette;

$squelette->dispatchURI();

?>