Subversion Repositories Applications.annuaire

Rev

Rev 149 | Rev 167 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 149 Rev 162
Line 21... Line 21...
21
	public function verifierPresenceTable($bdd, $nom_table) {
21
	public function verifierPresenceTable($bdd, $nom_table) {
Line 22... Line 22...
22
		
22
		
23
		if(!$bdd || !$nom_table) {
23
		if(!$bdd || !$nom_table) {
24
			return false;
24
			return false;
25
		}
25
		}
26
 
26
		
-
 
27
		$requete = 'DESCRIBE '.$bdd.'.'.$nom_table;
27
		$requete = 'DESCRIBE '.$bdd.'.'.$nom_table;
28
		
Line 28... Line 29...
28
		$resultat = $this->requeteUn($requete);
29
		$resultat = $this->requeteUn($requete);
29
		
30
		
Line 30... Line 31...
30
		return $resultat;
31
		return $resultat;
Line -... Line 32...
-
 
32
	}
-
 
33
	
-
 
34
	public function verifierPresenceChamps($bdd, $nom_table, $champs_a_verifier) {
-
 
35
		
-
 
36
		$tableau_champs_table = $this->obtenirListeNomsChampsAnnuaireParBddNomTable($bdd, $nom_table);
-
 
37
 
-
 
38
		foreach($champs_a_verifier as $champ) {
-
 
39
			if(!in_array($champ, $tableau_champs_table)) {
-
 
40
				return false;
-
 
41
			}
-
 
42
		}
-
 
43
		
-
 
44
		return $resultat;
31
	}
45
	}
32
	
46
	
33
	public function verifierPresenceChamps($bdd, $nom_table, $champs_a_verifier) {
47
	public function obtenirListeNomsChampsAnnuaireParBddNomTable($bdd, $nom_table) {
Line 34... Line 48...
34
		
48
		
Line 48... Line 62...
48
		
62
		
49
		foreach($resultat as $champ_table) {
63
		foreach($resultat as $champ_table) {
50
			$tableau_champs_table[] = $champ_table['Field'];
64
			$tableau_champs_table[] = $champ_table['Field'];
Line 51... Line 65...
51
		}
65
		}
-
 
66
		
-
 
67
		return $tableau_champs_table;
-
 
68
	}
-
 
69
	
-
 
70
	public function obtenirListeNomsChampsAnnuaireParIdAnnuaire($id_annuaire) {
-
 
71
		
-
 
72
		
-
 
73
		$requete_selection_bdd_table =  'SELECT aa_bdd, aa_table FROM annu_annuaire '.
-
 
74
					' WHERE aa_id_annuaire = '.$this->proteger($id_annuaire);
-
 
75
		
52
		
76
		$resultat_selection_bdd_table = $this->requeteUn($requete_selection_bdd_table);
53
		foreach($champs_a_verifier as $champ) {
77
			
54
			if(!in_array($champ, $tableau_champs_table)) {
-
 
55
				return false;
78
		if(!$resultat_selection_bdd_table) {
Line 56... Line 79...
56
			}
79
			return array();
57
		}
80
		}
Line 58... Line 81...
58
		
81
		
Line 59... Line 82...
59
		return $resultat;
82
		return $this->obtenirListeNomsChampsAnnuaireParBddNomTable($resultat_selection_bdd_table['aa_bdd'], $resultat_selection_bdd_table['aa_table']);
Line 91... Line 114...
91
		}
114
		}
Line 92... Line 115...
92
		
115
		
93
		return $id_annuaire;
116
		return $id_annuaire;
Line -... Line 117...
-
 
117
	}
-
 
118
	
-
 
119
	public function creerTableAnnuaire($informations_table, $informations_champs) {
-
 
120
		
-
 
121
		$nom_bdd = $this->proteger($informations_table['nom_bdd']);
-
 
122
		$nom_table = $this->proteger($informations_table['nom_table']);
-
 
123
		
-
 
124
		$champ_id = $this->proteger($informations_champs['champ_id']);
-
 
125
		$champ_nom = $this->proteger($informations_champs['champ_id']);
-
 
126
		$champ_mail = $this->proteger($informations_champs['champ_id']);
-
 
127
		$champ_mot_de_passe = $this->proteger($informations_champs['champ_id']);
-
 
128
		
-
 
129
		$requete_creation_table = 'CREATE TABLE '.$bdd.'.'.$nom_table.' '.
-
 
130
									'('.$champ_id.' INT NOT NULL AUTO_INCREMENT PRIMARY KEY,'. 
-
 
131
									$champ_nom.' TEXT NOT NULL,'. 
-
 
132
									$champ_mail.' TEXT NOT NULL)'. 
-
 
133
									$champ_mot_de_passe.' TEXT NOT NULL)';
-
 
134
									//'ENGINE = MyISAM' ;
-
 
135
									
-
 
136
		echo $requete_creation_table;
-
 
137
		exit;
-
 
138
		
-
 
139
		return $this->requete($requete_creation_table);
-
 
140
		
94
	}
141
	}
95
	
142
	
96
	/**
143
	/**
97
	 * Charge la liste complète des champs d'un annuaire
144
	 * Charge la liste complète des champs d'un annuaire
98
	 * @param int $identifiant l'identifiant de l'annuaire demandé
145
	 * @param int $identifiant l'identifiant de l'annuaire demandé