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
|
<?php
namespace Garradin;
use Garradin\Files\Files;
use Garradin\Entities\Files\File;
use Garradin\Membres\Champs;
use KD2\SMTP;
class Config extends Entity
{
const ADMIN_BACKGROUND_FILENAME = File::CONTEXT_CONFIG . '/admin_bg.png';
protected $nom_asso;
protected $adresse_asso;
protected $email_asso;
protected $telephone_asso;
protected $site_asso;
protected $monnaie;
protected $pays;
protected $champs_membres;
protected $categorie_membres;
protected $admin_homepage;
protected $frequence_sauvegardes;
protected $nombre_sauvegardes;
protected $champ_identifiant;
protected $champ_identite;
protected $last_chart_change;
protected $last_version_check;
protected $couleur1;
protected $couleur2;
protected $admin_background;
protected $site_disabled;
protected $_types = [
'nom_asso' => 'string',
'adresse_asso' => '?string',
'email_asso' => 'string',
'telephone_asso' => '?string',
'site_asso' => '?string',
'monnaie' => 'string',
'pays' => 'string',
'champs_membres' => Champs::class,
'categorie_membres' => 'int',
'admin_homepage' => '?string',
'frequence_sauvegardes' => '?int',
'nombre_sauvegardes' => '?int',
'champ_identifiant' => 'string',
'champ_identite' => 'string',
'last_chart_change' => '?int',
'last_version_check' => '?string',
'couleur1' => '?string',
'couleur2' => '?string',
'admin_background' => '?string',
'site_disabled' => 'bool',
];
static protected $_instance = null;
static public function getInstance()
|
>
|
>
>
>
<
<
>
>
<
<
>
>
|
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
|
<?php
namespace Garradin;
use Garradin\Files\Files;
use Garradin\Entities\Files\File;
use Garradin\Membres\Champs;
use KD2\SMTP;
class Config extends Entity
{
const DEFAULT_FILES = [
'admin_background' => File::CONTEXT_CONFIG . '/admin_bg.png',
'admin_homepage' => File::CONTEXT_CONFIG . '/admin_homepage.skriv',
'admin_css' => File::CONTEXT_CONFIG . '/admin.css',
];
protected $nom_asso;
protected $adresse_asso;
protected $email_asso;
protected $telephone_asso;
protected $site_asso;
protected $monnaie;
protected $pays;
protected $champs_membres;
protected $categorie_membres;
protected $frequence_sauvegardes;
protected $nombre_sauvegardes;
protected $champ_identifiant;
protected $champ_identite;
protected $last_chart_change;
protected $last_version_check;
protected $couleur1;
protected $couleur2;
protected $admin_background;
protected $admin_homepage = 'config/admin_homepage.skriv';
protected $admin_css = 'config/admin.css';
protected $site_disabled;
protected $_types = [
'nom_asso' => 'string',
'adresse_asso' => '?string',
'email_asso' => 'string',
'telephone_asso' => '?string',
'site_asso' => '?string',
'monnaie' => 'string',
'pays' => 'string',
'champs_membres' => Champs::class,
'categorie_membres' => 'int',
'frequence_sauvegardes' => '?int',
'nombre_sauvegardes' => '?int',
'champ_identifiant' => 'string',
'champ_identite' => 'string',
'last_chart_change' => '?int',
'last_version_check' => '?string',
'couleur1' => '?string',
'couleur2' => '?string',
'admin_background' => '?string',
'admin_homepage' => '?string',
'admin_css' => '?string',
'site_disabled' => 'bool',
];
static protected $_instance = null;
static public function getInstance()
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
{
$source['couleur1'] = null;
$source['couleur2'] = null;
}
if (isset($source['admin_background']) && trim($source['admin_background']) == 'RESET') {
$source['admin_background'] = null;
}
elseif (isset($source['admin_background']) && strlen($source['admin_background'])) {
$file = Files::get(self::ADMIN_BACKGROUND_FILENAME);
if ($file) {
$file->storeFromBase64($source['admin_background']);
}
else {
$file = File::createFromBase64(Utils::dirname(self::ADMIN_BACKGROUND_FILENAME), Utils::basename(self::ADMIN_BACKGROUND_FILENAME), $source['admin_background']);
}
$source['admin_background'] = $file->path;
}
else {
unset($source['admin_background']);
}
|
|
>
>
>
>
>
>
|
>
|
|
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
|
{
$source['couleur1'] = null;
$source['couleur2'] = null;
}
if (isset($source['admin_background']) && trim($source['admin_background']) == 'RESET') {
$source['admin_background'] = null;
$file = Files::get(self::DEFAULT_FILES['admin_background']);
if ($file) {
$file->delete();
}
}
elseif (isset($source['admin_background']) && strlen($source['admin_background'])) {
$file = Files::get(self::DEFAULT_FILES['admin_background']);
if ($file) {
$file->storeFromBase64($source['admin_background']);
}
else {
$path = self::DEFAULT_FILES['admin_background'];
$file = File::createFromBase64(Utils::dirname($path), Utils::basename($path), $source['admin_background']);
}
$source['admin_background'] = $file->path;
}
else {
unset($source['admin_background']);
}
|
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
public function selfCheck(): void
{
$this->assert(trim($this->nom_asso) != '', 'Le nom de l\'association ne peut rester vide.');
$this->assert(trim($this->monnaie) != '', 'La monnaie ne peut rester vide.');
$this->assert(trim($this->pays) != '' && Utils::getCountryName($this->pays), 'Le pays ne peut rester vide.');
$this->assert(null === $this->site_asso || filter_var($this->site_asso, FILTER_VALIDATE_URL), 'L\'adresse URL du site web est invalide.');
$this->assert(trim($this->email_asso) != '' && SMTP::checkEmailIsValid($this->email_asso, false), 'L\'adresse e-mail de l\'association est invalide.');
$this->assert(strlen($this->admin_homepage) > 0, 'Page d\'accueil invalide');
$this->assert($this->champs_membres instanceof Champs, 'Objet champs membres invalide');
$champs = $this->champs_membres;
$this->assert(!empty($champs->get($this->champ_identite)), sprintf('Le champ spécifié pour identité, "%s" n\'existe pas', $this->champ_identite));
$this->assert(!empty($champs->get($this->champ_identifiant)), sprintf('Le champ spécifié pour identifiant, "%s" n\'existe pas', $this->champ_identifiant));
$db = DB::getInstance();
|
<
>
>
>
>
>
|
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
public function selfCheck(): void
{
$this->assert(trim($this->nom_asso) != '', 'Le nom de l\'association ne peut rester vide.');
$this->assert(trim($this->monnaie) != '', 'La monnaie ne peut rester vide.');
$this->assert(trim($this->pays) != '' && Utils::getCountryName($this->pays), 'Le pays ne peut rester vide.');
$this->assert(null === $this->site_asso || filter_var($this->site_asso, FILTER_VALIDATE_URL), 'L\'adresse URL du site web est invalide.');
$this->assert(trim($this->email_asso) != '' && SMTP::checkEmailIsValid($this->email_asso, false), 'L\'adresse e-mail de l\'association est invalide.');
$this->assert($this->champs_membres instanceof Champs, 'Objet champs membres invalide');
// Files can only have one value: their name
$this->assert($this->admin_background === null || $this->admin_background === self::DEFAULT_FILES['admin_background']);
$this->assert($this->admin_homepage === null || $this->admin_homepage === self::DEFAULT_FILES['admin_homepage']);
$this->assert($this->admin_css === null || $this->admin_css === self::DEFAULT_FILES['admin_css']);
$champs = $this->champs_membres;
$this->assert(!empty($champs->get($this->champ_identite)), sprintf('Le champ spécifié pour identité, "%s" n\'existe pas', $this->champ_identite));
$this->assert(!empty($champs->get($this->champ_identifiant)), sprintf('Le champ spécifié pour identifiant, "%s" n\'existe pas', $this->champ_identifiant));
$db = DB::getInstance();
|