DroitAcces::getSuperAdmin()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
	namespace core\admin\droitsacces;
3
4
	use core\App;
5
6
	class DroitAcces {
7
8
		//pour la table identite
9
		protected $id_identite;
10
		private $super_admin;
11
12
		//pour la table liste_droit_acces
13
		protected $id_liste_droit_acces;
14
15
		//pour des droits pour la gestion des contenus
16
		private $modif_seo;
17
		private $modif_contenu;
18
		private $modif_navigation;
19
		private $supprimer_page;
20
		
21
		private $liste_droits_acces;
22
23
24
		//-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------//
25
		public function __construct() {
26
			$dbc = \core\App::getDb();
27
28
			$this->id_identite = $_SESSION["idlogin".CLEF_SITE];
29
30
			//on test voir si super admin
31
			$query = $dbc->select("super_admin")->select("liste_droit")->from("identite")->where("ID_identite", "=", $this->id_identite)->get();
32
33
			if ((is_array($query)) && (count($query) > 0)) {
34
				foreach ($query as $obj) {
35
					$this->super_admin = $obj->super_admin;
36
					$this->id_liste_droit_acces = $obj->liste_droit;
37
				}
38
				$this->liste_droits_acces = $this->getListeDroitAcces();
39
				App::setValues(["super_admin" => $this->super_admin]);
40
			}
41
		}
42
		//-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------//
43
    
44
    
45
    
46
		//-------------------------- GETTER ----------------------------------------------------------------------------//
47
		public function getSuperAdmin() {
48
			return $this->super_admin;
49
		}
50
		public function getModifSeo() {
51
			return $this->modif_seo;
52
		}
53
		public function getModifContenu() {
54
			return $this->modif_contenu;
55
		}
56
		public function getModifNavigation() {
57
			return $this->modif_navigation;
58
		}
59
		public function getSupprimerPage() {
60
			return $this->supprimer_page;
61
		}
62
		public function getListeDroitsAcces() {
63
			return $this->liste_droits_acces;
64
		}
65
66
		/**
67
		 * @return array
68
		 */
69
		private function getListeDroitAcces() {
70
			$dbc = App::getDb();
71
			$liste_droit_acces = [];
72
73
			$query = $dbc->select()->from("droit_acces")->from("liste_droit_acces")->from("liaison_liste_droit")
74
				->where("liste_droit_acces.ID_liste_droit_acces", "=", $this->id_liste_droit_acces, "AND")
75
				->where("droit_acces.ID_droit_acces", "=", "liaison_liste_droit.ID_droit_acces", "AND", true)
76
				->where("liste_droit_acces.ID_liste_droit_acces", "=", "liaison_liste_droit.ID_liste_droit_acces", "", true)
77
				->get();
78
79
			if ((is_array($query)) && (count($query) > 0)) {
80
				foreach ($query as $obj) {
81
					$liste_droit_acces[] = $obj->droit_acces;
82
				}
83
			}
84
			App::setValues(["droit_acces_user" => $liste_droit_acces]);
85
			return $liste_droit_acces;
86
		}
87
88
		/**
89
		 * @param $id_page
90
		 * function that get if user can edit content SEO nav or contenu of the current page
91
		 */
92
		public function getListeDroitModificationContenu($id_page) {
93
			$dbc = App::getDb();
94
			
95
			$query = $dbc->select()->from("droit_acces_page")
96
				->from("liste_droit_acces")
97
				->where("droit_acces_page.ID_page", "=", $id_page, "AND")
98
				->where("liste_droit_acces.ID_liste_droit_acces", "=", $this->id_liste_droit_acces, "AND")
99
				->where("droit_acces_page.ID_liste_droit_acces", "=", "liste_droit_acces.ID_liste_droit_acces", "", true)
100
				->get();
101
			
102
			if ((is_array($query)) && (count($query) > 0)) {
103
				foreach ($query as $obj) {
104
					App::setValues(["droit_acces_page" => [
105
						"seo" => $this->modif_seo = $obj->seo,
106
						"contenu" => $this->modif_contenu = $obj->contenu,
107
						"navigation" => $this->modif_navigation = $obj->navigation,
108
						"supprimer" => $this->supprimer_page = $obj->supprimer
109
					]]);
110
				}
111
			}
112
		}
113
		//-------------------------- FIN GETTER ----------------------------------------------------------------------------//
114
    
115
    
116
    
117
		//-------------------------- SETTER ----------------------------------------------------------------------------//
118
119
		//-------------------------- FIN SETTER ----------------------------------------------------------------------------//
120
	}