1
|
|
|
<?php |
2
|
|
|
namespace core; |
3
|
|
|
|
4
|
|
|
class Configuration { |
5
|
|
|
//pour la configuration générale du site |
6
|
|
|
private $nom_site; //-> nom du site |
7
|
|
|
private $mail_site; //-> pour le gérant du site contact@nomdedomaine;com |
8
|
|
|
private $gerant_site; //->nom du gérant du site |
9
|
|
|
private $mail_administrateur; //-> mail de l'administrateur [email protected] |
10
|
|
|
private $last_save; //-> derniere sauvegarde de la bdd |
11
|
|
|
private $acces_admin; //-> si == 1 on a acces à l'admin |
12
|
|
|
private $contenu_dynamique; //->savoir si es contenus sont dynamique (stockés in DB) |
13
|
|
|
private $cache; //-> si == 1 alors on mets les pages du site en cache |
14
|
|
|
private $desactiver_navigation; //-> si == 1 alors on n'affichera pas la nav dans principal.php |
15
|
|
|
|
16
|
|
|
//pour la configuration des comptes |
17
|
|
|
private $valider_inscription; |
18
|
|
|
private $activer_inscription; |
19
|
|
|
private $activer_connexion; |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
//-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
23
|
|
|
public function __construct() { |
24
|
|
|
//pour la configuration générale du site |
25
|
|
|
$this->getConfigurationGenerale(); |
26
|
|
|
|
27
|
|
|
//pour la configuration des comptes |
28
|
|
|
$this->getConfigurationCompte(); |
29
|
|
|
} |
30
|
|
|
//-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
31
|
|
|
|
32
|
|
|
|
33
|
|
|
|
34
|
|
|
//-------------------------- GETTER ----------------------------------------------------------------------------// |
35
|
|
|
//pour la configuration générale du site |
36
|
|
|
public function getNomSite() { |
37
|
|
|
return $this->nom_site; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @return string|null |
42
|
|
|
*/ |
43
|
|
|
public function getMailSite() { |
44
|
|
|
return $this->mail_site; |
45
|
|
|
} |
46
|
|
|
public function getGerantSite() { |
47
|
|
|
return $this->gerant_site; |
48
|
|
|
} |
49
|
|
|
public function getMailAdministrateur() { |
50
|
|
|
return $this->mail_administrateur; |
51
|
|
|
} |
52
|
|
|
public function getLastSave() { |
53
|
|
|
return $this->last_save; |
54
|
|
|
} |
55
|
|
|
public function getAccesAdmin() { |
56
|
|
|
return $this->acces_admin; |
57
|
|
|
} |
58
|
|
|
public function getContenusDynamique() { |
59
|
|
|
return $this->contenu_dynamique; |
60
|
|
|
} |
61
|
|
|
public function getCache() { |
62
|
|
|
return $this->cache; |
63
|
|
|
} |
64
|
|
|
public function getDesactiverNavigation(){ |
65
|
|
|
return $this->desactiver_navigation; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
//pour la configuration des comptes |
69
|
|
|
public function getValiderInscription() { |
70
|
|
|
return $this->valider_inscription; |
71
|
|
|
} |
72
|
|
|
public function getActiverInscription() { |
73
|
|
|
return $this->activer_inscription; |
74
|
|
|
} |
75
|
|
|
public function getActiverConnexion() { |
76
|
|
|
return $this->activer_connexion; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
private function getConfigurationGenerale() { |
80
|
|
|
$dbc = App::getDb(); |
81
|
|
|
|
82
|
|
|
$query = $dbc->select()->from("configuration")->where("ID_configuration", "=", 1)->get(); |
83
|
|
|
|
84
|
|
|
if ((is_array($query)) && (count($query) > 0)) { |
85
|
|
|
foreach ($query as $obj) { |
86
|
|
|
$this->nom_site = $obj->nom_site; |
87
|
|
|
$this->mail_site = $obj->mail_site; |
88
|
|
|
$this->gerant_site = $obj->gerant_site; |
89
|
|
|
$this->mail_administrateur = $obj->mail_administrateur; |
90
|
|
|
$this->last_save = $obj->last_save; |
91
|
|
|
$this->acces_admin = $obj->acces_admin; |
92
|
|
|
$this->contenu_dynamique = $obj->contenu_dynamique; |
93
|
|
|
$this->cache = $obj->cache; |
94
|
|
|
$this->desactiver_navigation = $obj->desactiver_navigation; |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
private function getConfigurationCompte() { |
100
|
|
|
$dbc = App::getDb(); |
101
|
|
|
|
102
|
|
|
$query = $dbc->select()->from("configuration_compte")->where("ID_configuration_compte", "=", 1)->get(); |
103
|
|
|
|
104
|
|
|
if ((is_array($query)) && (count($query) > 0)) { |
105
|
|
|
foreach ($query as $obj) { |
106
|
|
|
$this->valider_inscription = $obj->valider_inscription; |
107
|
|
|
$this->activer_inscription = $obj->activer_inscription; |
108
|
|
|
$this->activer_connexion = $obj->activer_connexion; |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
//-------------------------- FIN GETTER ----------------------------------------------------------------------------// |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
|
116
|
|
|
//-------------------------- SETTER ----------------------------------------------------------------------------// |
117
|
|
|
/** |
118
|
|
|
* fonction qui permet de mettre à jour la date de la derniere save de la bdd |
119
|
|
|
* + supprimer la sauverde ancienne d'il y a 1 mois |
120
|
|
|
*/ |
121
|
|
|
public function setDateSaveToday() { |
122
|
|
|
$dbc = App::getDb(); |
123
|
|
|
|
124
|
|
|
$dbc->update("last_save", date("Y-m-d"))->from("configuration")->where("ID_configuration", "=", 1)->set(); |
125
|
|
|
|
126
|
|
|
$today = new \DateTime(date("Y-m-d")); |
127
|
|
|
$today->sub(new \DateInterval('P32D')); |
128
|
|
|
|
129
|
|
|
$nom_save = "save-".$today->format("Y-m-d").".sql"; |
130
|
|
|
|
131
|
|
|
if (file_exists(ROOT."bdd_backup/".$nom_save)) { |
132
|
|
|
unlink(ROOT."bdd_backup/".$nom_save); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
//-------------------------- FIN SETTER ----------------------------------------------------------------------------// |
136
|
|
|
} |