1 |
<?php |
<?php |
2 |
/** |
/** |
3 |
* |
* Ce fichier est destine a permettre la surcharge de certaines methodes de |
4 |
|
* la classe om_application pour des besoins specifiques de l'application |
5 |
* |
* |
6 |
* @package openmairie_exemple |
* @package openmairie_exemple |
7 |
* @version SVN : $Id: utils.class.php 489 2011-07-07 17:26:37Z fmichon $ |
* @version SVN : $Id: utils.class.php 547 2011-08-25 12:03:42Z fmichon $ |
8 |
*/ |
*/ |
9 |
|
|
10 |
/** |
/** |
36 |
* |
* |
37 |
*/ |
*/ |
38 |
class utils extends application { |
class utils extends application { |
39 |
|
|
40 |
var $schema; //*** |
var $om_utilisateur = array(); |
41 |
|
var $user_is_instr = false; |
42 |
|
var $user_is_service_ext = false; |
43 |
|
|
44 |
/** |
/** |
45 |
* Cette methode permet de charger les differents fichiers de configs dans |
* Surcharge du constructeur de la classe |
46 |
* des attributs de la classe |
*/ |
47 |
* |
function __construct($flag = NULL, $right = NULL, $title = NULL, $icon = NULL, $help = NULL) { |
48 |
|
parent::__construct($flag, $right, $title, $icon, $help); |
49 |
|
$this->getUserInfos(); |
50 |
|
} |
51 |
|
/** |
52 |
|
* Desctructeur de la classe, cette methode (appelee automatiquement) |
53 |
|
* permet d'afficher le footer de la page, le footer HTML, et de |
54 |
|
* deconnecter la base de donnees |
55 |
|
* |
56 |
* @return void |
* @return void |
57 |
*/ |
*/ |
58 |
function setParamsFromFiles() { |
function __destruct() { |
59 |
|
|
60 |
// |
// Footer |
61 |
if (file_exists("../dyn/config.inc.php")) { |
if (!defined('REST_REQUEST')) { |
62 |
include_once("../dyn/config.inc.php"); |
$this->displayFooter(); |
63 |
} |
} |
64 |
if (isset($config)) { |
|
65 |
$this->config = $config; |
// Deconnexion SGBD |
66 |
|
$this->disconnectDatabase(); |
67 |
|
|
68 |
|
// Logger |
69 |
|
$this->addToLog("__destruct()", EXTRA_VERBOSE_MODE); |
70 |
|
|
71 |
|
// Logger |
72 |
|
$this->addToLog("__destruct() : ".$this->elapsedtime()." sec", VERBOSE_MODE); |
73 |
|
|
74 |
|
// Affichage des logs |
75 |
|
logger::instance()->displayLog(); |
76 |
|
|
77 |
|
// Footer HTML |
78 |
|
if (!defined('REST_REQUEST')) { |
79 |
|
$this->displayHTMLFooter(); |
80 |
} |
} |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
/** |
87 |
|
* Cette méthode permet de vérifier si l'utilisateur est autorisé ou non à |
88 |
|
* accéder à un élément et permet d'agir en conséquence |
89 |
|
* |
90 |
|
* @param |
91 |
|
* @return mixed |
92 |
|
*/ |
93 |
|
function isAuthorized($obj = NULL, $operator = "AND") { |
94 |
|
|
95 |
// |
// |
96 |
if (file_exists("../dyn/database.inc.php")) { |
if ($obj == NULL) { |
97 |
include_once("../dyn/database.inc.php"); |
$obj = $this->right; |
98 |
} |
} |
99 |
|
// |
100 |
if (isset($conn)) { |
if ($obj == NULL) { |
101 |
$this->conn = $conn; |
return true; |
102 |
|
} |
103 |
|
|
104 |
|
// L'utilisateur n'est pas autorisé à accéder à l'élément |
105 |
|
if (!$this->isAccredited($obj, $operator)) { |
106 |
|
|
107 |
// |
// |
108 |
foreach($this->conn as $key => $conn) { |
$message_class = "error"; |
109 |
$this->database[$key] = array( |
$message = _("Droits insuffisants. Vous n'avez pas suffisament de ". |
110 |
'title' => $conn[0], |
"droits pour acceder a cette page."); |
111 |
'phptype' => $conn[1], |
$this->addToMessage($message_class, $message); |
112 |
'dbsyntax' => $conn[2], |
|
113 |
'username' => $conn[3], |
// |
114 |
'password' => $conn[4], |
$this->setFlag(NULL); |
115 |
'protocol' => $conn[5], |
if (!defined('REST_REQUEST')) { |
116 |
'hostspec' => $conn[6], |
$this->display(); |
|
'port' => $conn[7], |
|
|
'socket' => $conn[8], |
|
|
'database' => $conn[9], |
|
|
'formatdate' => $conn[10], |
|
|
'schema' => $conn[11], //**** |
|
|
'prefixe' => $conn[12], //**** |
|
|
); |
|
117 |
} |
} |
118 |
|
|
119 |
|
// Arrêt du script |
120 |
|
die(); |
121 |
|
|
122 |
} |
} |
123 |
|
|
124 |
// |
// L'utilisateur est autorisé à accéder à l'élément |
125 |
if (file_exists("../dyn/menu.inc.php")) { |
return true; |
126 |
include_once("../dyn/menu.inc.php"); |
|
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
/** |
132 |
|
* |
133 |
|
*/ |
134 |
|
function setDatabaseConfig() { |
135 |
|
|
136 |
|
// On recupere la liste des cles du tableau associatif de configuration |
137 |
|
// de la connexion aux bases de donnees |
138 |
|
$database_keys = array_keys($this->database); |
139 |
|
// Si il y a plusieurs cles |
140 |
|
if (count($database_keys) != 0) { |
141 |
|
// On configure la premiere par defaut |
142 |
|
$coll = $database_keys[0]; |
143 |
|
} else { // Si il n'y a aucune cle |
144 |
|
// Aucune base n'est configuree dans le fichier de configuration |
145 |
|
// donc on affiche un message d'erreur |
146 |
|
$class = "error"; |
147 |
|
$message = _("Erreur de configuration. Contactez votre administrateur."); |
148 |
|
$this->addToMessage($class, $message); |
149 |
|
// Debug |
150 |
|
$this->addToLog("setDatabaseConfig(): ERR", DEBUG_MODE); |
151 |
|
$this->addToLog("ERR: "._("Aucune entree dans le fichier de configuration"), DEBUG_MODE); |
152 |
|
// On affiche la structure de la page |
153 |
|
$this->setFlag(NULL); |
154 |
|
$this->display(); |
155 |
|
// On arrete le traitement en cours |
156 |
|
die(); |
157 |
|
} |
158 |
|
|
159 |
|
// Si la variable coll (representant la cle de la base sur laquelle |
160 |
|
// nous travaillons) n'est pas en variable SESSION ou est en variable |
161 |
|
// SESSION mais n'existe pas dans les cles du tableau associatif de |
162 |
|
// configuration de la connexion aux bases de donnees |
163 |
|
if (!isset($_SESSION['coll']) or |
164 |
|
(isset($_SESSION['coll']) and |
165 |
|
!isset($this->database[$_SESSION['coll']]))) { |
166 |
|
// On configure la premiere par defaut |
167 |
|
$_SESSION['coll'] = $coll; |
168 |
|
} else { |
169 |
|
// On recupere la cle du tableau associatif de configuration de la |
170 |
|
// connexion aux bases de donnees correspondante a la base de |
171 |
|
// donnees sur laquelle nous travaillons |
172 |
|
$coll = $_SESSION['coll']; |
173 |
} |
} |
174 |
if (isset($menu)) { |
|
175 |
$this->menu = $menu; |
// On renvoi le tableau de parametres pour la connexion a la base |
176 |
|
$this->database_config = $this->database[$coll]; |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
/** |
181 |
|
* Cette méthode permet de se connecter à la base de données |
182 |
|
* @return void |
183 |
|
*/ |
184 |
|
function connectDatabase() { |
185 |
|
// On inclus la classe d'abstraction de base de donnees |
186 |
|
require_once PATH_OPENMAIRIE."om_database.class.php"; |
187 |
|
// On recupere le tableau de parametres pour la connexion a la base |
188 |
|
$this->setDatabaseConfig(); |
189 |
|
// On fixe les options |
190 |
|
$options = array( |
191 |
|
'debug' => 2, |
192 |
|
'portability' => DB_PORTABILITY_ALL, |
193 |
|
); |
194 |
|
// Instanciation de l'objet connexion a la base de donnees |
195 |
|
$db = database::connect($this->database_config, $options); |
196 |
|
// Logger |
197 |
|
$this->addToLog("connectDatabase(): "._("Tentative de connexion au SGBD"), EXTRA_VERBOSE_MODE); |
198 |
|
// Traitement particulier de l'erreur en cas d'erreur de connexion a la |
199 |
|
// base de donnees |
200 |
|
if (database::isError($db, true)) { |
201 |
|
// Deconnexion de l'utilisateur |
202 |
|
$this->logout(); |
203 |
|
// On affiche la page de login a l'ecran |
204 |
|
$this->setFlag("login"); |
205 |
|
// On affiche un message d'erreur convivial pour l'utilisateur |
206 |
|
$class = "error"; |
207 |
|
$message = _("Erreur de base de donnees. Contactez votre administrateur."); |
208 |
|
$this->addToMessage($class, $message); |
209 |
|
// On affiche la page |
210 |
|
if (!defined('REST_REQUEST')) { |
211 |
|
$this->display(); |
212 |
|
} |
213 |
|
// On arrete le script |
214 |
|
die(); |
215 |
|
} else { |
216 |
|
// On affecte la resource a l'attribut de la classe du meme nom |
217 |
|
$this->db = $db; |
218 |
|
// Logger |
219 |
|
$this->addToLog("connectDatabase(): Connexion [".$this->database_config["phptype"]."] '".$this->database_config['database']."' OK", EXTRA_VERBOSE_MODE); |
220 |
|
|
221 |
|
// Compatibilite anterieure (deprecated) |
222 |
|
$this->phptype = $this->database_config["phptype"]; |
223 |
|
$this->formatdate = $this->database_config["formatdate"]; |
224 |
|
$this->schema = $this->database_config["schema"]; |
225 |
|
|
226 |
|
// Definition des constantes pour l'acces aux informations de la base |
227 |
|
// donnees facilement. |
228 |
|
$temp = ""; |
229 |
|
if ($this->database_config["schema"] != "") { |
230 |
|
$temp = $this->database_config["schema"]."."; |
231 |
|
} |
232 |
|
$temp = $temp.$this->database_config["prefixe"]; |
233 |
|
define("DB_PREFIXE", $temp); |
234 |
|
define("FORMATDATE", $this->database_config["formatdate"]); |
235 |
|
|
236 |
|
// Definition des constantes pour l'acces aux informations de la base |
237 |
|
// donnees facilement. |
238 |
|
define("OM_DB_FORMATDATE", $this->database_config["formatdate"]); |
239 |
|
define("OM_DB_PHPTYPE", $this->database_config["phptype"]); |
240 |
|
define("OM_DB_DATABASE", $this->database_config["database"]); |
241 |
|
define("OM_DB_SCHEMA", $this->database_config["schema"]); |
242 |
|
define("OM_DB_TABLE_PREFIX", $this->database_config["prefixe"]); |
243 |
} |
} |
244 |
|
|
245 |
|
} |
246 |
|
|
247 |
|
|
248 |
|
/** |
249 |
|
* |
250 |
|
* |
251 |
|
*/ |
252 |
|
function isDatabaseError($dbobj = NULL, $return = false) { |
253 |
|
|
254 |
// |
// |
255 |
if (file_exists("../dyn/actions.inc.php")) { |
if (database::isError($dbobj, $return)) { |
256 |
include_once("../dyn/actions.inc.php"); |
|
257 |
} |
if ($return == true) { |
258 |
if (isset($actions)) { |
|
259 |
$this->actions = $actions; |
// |
260 |
|
return true; |
261 |
|
|
262 |
|
} |
263 |
|
|
264 |
|
// |
265 |
|
$class = "error"; |
266 |
|
$message = _("Erreur de base de donnees. Contactez votre administrateur."); |
267 |
|
$this->addToMessage($class, $message); |
268 |
|
|
269 |
|
// Logger |
270 |
|
$this->addToLog("isDatabaseError(): ".$dbobj->getDebugInfo(), DEBUG_MODE); |
271 |
|
$this->addToLog("isDatabaseError(): ".$dbobj->getMessage(), DEBUG_MODE); |
272 |
|
|
273 |
|
// |
274 |
|
$this->setFlag(NULL); |
275 |
|
if (!defined('REST_REQUEST')) { |
276 |
|
$this->display(); |
277 |
|
// |
278 |
|
die(); |
279 |
|
} |
280 |
|
|
281 |
} |
} |
282 |
|
|
283 |
|
// |
284 |
|
return false; |
285 |
|
|
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
/** |
291 |
|
* |
292 |
|
* @return void |
293 |
|
*/ |
294 |
|
function displayMessage($class = "", $message = "") { |
295 |
|
if (!defined('REST_REQUEST')) { |
296 |
|
$this->m->displayMessage($class, $message); |
297 |
|
} |
298 |
|
} |
299 |
|
|
300 |
|
|
301 |
|
/** |
302 |
|
* |
303 |
|
*/ |
304 |
|
function addToLog($message, $type = DEBUG_MODE) { |
305 |
// |
// |
306 |
if (file_exists("../dyn/shortlinks.inc.php")) { |
if (!defined('REST_REQUEST')) { |
307 |
include_once("../dyn/shortlinks.inc.php"); |
logger::instance()->log("class ".get_class($this)." - ".$message, $type); |
308 |
} |
} |
309 |
if (isset($shortlinks)) { |
} |
310 |
$this->shortlinks = $shortlinks; |
|
311 |
|
/** |
312 |
|
* Envoie un mail avec piece jointe |
313 |
|
* |
314 |
|
* @param string $title Titre du mail |
315 |
|
* @param string $message Corps du mail |
316 |
|
* @param string $recipient Destinataire du mail |
317 |
|
* @param array $file Destinataire du mail |
318 |
|
* @access public |
319 |
|
* @return bool True si le mail est correctement envoye, false sinon. |
320 |
|
*/ |
321 |
|
public function sendMail($title, $message, $recipient, $file = array()) { |
322 |
|
|
323 |
|
@include_once "../php/phpmailer/class.phpmailer.php"; |
324 |
|
|
325 |
|
if (!class_exists("PHPMailer")) { |
326 |
|
$this->addToLog("sendMail(): !class_exists(\"PHPMailer\")", DEBUG_MODE); |
327 |
|
return false; |
328 |
} |
} |
329 |
|
|
330 |
|
// |
331 |
|
$this->setMailConfig(); |
332 |
|
|
333 |
// |
// |
334 |
if (file_exists("../dyn/footer.inc.php")) { |
if ($this->mail_config == false) { |
335 |
include_once("../dyn/footer.inc.php"); |
$this->addToLog("sendMail(): aucune configuration mail", DEBUG_MODE); |
336 |
} |
return false; |
|
if (isset($footer)) { |
|
|
$this->footer = $footer; |
|
337 |
} |
} |
338 |
|
|
339 |
// |
// |
340 |
if (file_exists("../dyn/version.inc.php")) { |
$mail = new PHPMailer(true); |
341 |
include_once("../dyn/version.inc.php"); |
|
342 |
|
// |
343 |
|
$mail->IsSMTP(); |
344 |
|
|
345 |
|
$mail->SMTPAuth = true; // enable SMTP authentication |
346 |
|
$mail->SMTPSecure = "tls"; |
347 |
|
$mail->Username = $this->mail_config["mail_username"]; |
348 |
|
$mail->Password = $this->mail_config["mail_pass"]; |
349 |
|
if ($this->mail_config["mail_username"] == '') { |
350 |
|
$mail->SMTPAuth = false; |
351 |
|
} else { |
352 |
|
$mail->SMTPAuth = true; |
353 |
} |
} |
354 |
if (isset($version)) { |
$mail->Port = $this->mail_config["mail_port"]; |
355 |
$this->version = $version; |
$mail->Host = $this->mail_config["mail_host"]; |
356 |
|
$mail->AddReplyTo($this->mail_config["mail_from"], $this->mail_config["mail_from_name"]); |
357 |
|
$mail->From = $this->mail_config["mail_from"]; |
358 |
|
$mail->FromName = $this->mail_config["mail_from_name"]; |
359 |
|
foreach (explode(",",$recipient) as $adresse) { |
360 |
|
if (!$this->checkValidEmailAddress($adresse)) { |
361 |
|
$this->addToLog("sendMail(): courriel incorrect ".$adresse, DEBUG_MODE); |
362 |
|
return false; |
363 |
|
} else |
364 |
|
$mail->AddAddress(trim($adresse)); |
365 |
|
} |
366 |
|
$mail->IsHTML(true); |
367 |
|
|
368 |
|
// Corps du message |
369 |
|
$mail_body ="<html>"; |
370 |
|
$mail_body .= "<head><title>".$title."</title></head>"; |
371 |
|
$mail_body .= "<body>".$message."</body>"; |
372 |
|
$mail_body .= "</html>"; |
373 |
|
|
374 |
|
$mail->Subject = $title; |
375 |
|
$mail->MsgHTML($mail_body); |
376 |
|
foreach($file as $oneFile) { |
377 |
|
|
378 |
|
if($oneFile['stream']){ |
379 |
|
$mail->AddStringAttachment($oneFile['content'], $oneFile['title'], $oneFile['encoding'] = 'base64',$oneFile['type'] = 'application/octet-stream'); |
380 |
|
} else{ |
381 |
|
$mail->AddAttachment($oneFile['url']); |
382 |
|
} |
383 |
|
} |
384 |
|
// Envoie de l'email |
385 |
|
if ($mail->Send()) { |
386 |
|
return true; |
387 |
|
} else { |
388 |
|
$this->addToLog("sendMail(): ".$mail->ErrorInfo, DEBUG_MODE); |
389 |
|
return false; |
390 |
} |
} |
|
|
|
391 |
} |
} |
392 |
|
|
393 |
/** |
/** |
|
* Cette methode permet de parametrer les valeurs par defaut pour les |
|
|
* fichiers css et javascript a appeler sur toutes les pages |
|
394 |
* |
* |
|
* @return void |
|
395 |
*/ |
*/ |
396 |
function setDefaultValues() { |
function isAccredited($obj = NULL, $operator = "AND") { |
397 |
|
// Lorsque l'utilisateur a le login 'admin' alors il est authorisé à |
398 |
$js = array( |
// accéder à toutes les fonctions du logiciel |
399 |
"../js/iepngfix_tilebg.js", |
// XXX à modifier pour changer ça vers un profil et non un login utilisateur |
400 |
"../lib/jquery/jquery.min.js", |
if ($_SESSION["login"] == "admin") { |
401 |
"../lib/jquery-ui/jquery.ui.datepicker-fr.min.js", |
return true; |
402 |
"../lib/jquery-ui/jquery-ui.min.js", |
} |
403 |
"../lib/jquery-thirdparty/jquery.collapsible.js", |
// Fonctionnement standard |
404 |
"../js/script.js", |
return parent::isAccredited($obj, $operator); |
405 |
); |
} |
406 |
$this->setHTMLHeadJs($js); |
|
407 |
|
/* |
408 |
$css = array( |
* Methode permettant de lister tous les fichiers d'un dossier |
409 |
"../css/main.css", |
*/ |
410 |
"../lib/jquery-ui-theme/jquery-ui.custom.css", |
function get_folder_file_list($id_folder) { |
|
"../css/specific.css", |
|
|
); |
|
|
$this->setHTMLHeadCss($css); |
|
411 |
|
|
412 |
$extras = "\t<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"../css/print.css\" />\n"; |
$file_list = array(); |
413 |
$this->setHTMLHeadExtras($extras); |
if(is_dir('../trs/'.$id_folder)) { |
414 |
|
if($dossier = opendir('../trs/'.$id_folder)) { |
415 |
|
|
416 |
|
while(false !== ($fichier = readdir($dossier))) { |
417 |
|
|
418 |
|
if($fichier != '.' && $fichier != '..' && !is_dir($fichier)) { |
419 |
|
|
420 |
|
$file_list[]=$fichier; |
421 |
|
} // On ferme le if (qui permet de ne pas afficher index.php, etc.) |
422 |
|
|
423 |
|
} // On termine la boucle |
424 |
|
|
425 |
|
closedir($dossier); |
426 |
|
|
427 |
|
} else { |
428 |
|
$this->displayMessage("error", _("Les documents du dossier ne sont pas accessible.")); |
429 |
|
} |
430 |
|
} else { |
431 |
|
$this->displayMessage("error", _("Ce dossier n'a pas de document.")); |
432 |
|
} |
433 |
|
return $file_list; |
434 |
|
} |
435 |
|
|
436 |
|
/* |
437 |
|
* Store the data recived in the request into a file on the |
438 |
|
* local filesystem. |
439 |
|
* @todo This function will need to be changed for the save to |
440 |
|
* be on GED |
441 |
|
* @param mixed $data The data received with the request |
442 |
|
* @param string $id The consultation ID |
443 |
|
* @return string OK on success, KO otherwise |
444 |
|
*/ |
445 |
|
|
446 |
|
function storeDecisionFile(&$fichier_base64, $basename, $dossier, $prefix = '') { |
447 |
|
|
448 |
|
if (empty($fichier_base64)) { |
449 |
|
$this -> addToMessage("error", _("Le fichier est vide")); |
450 |
|
return false; |
451 |
|
} |
452 |
|
$dir = $this->getPathFolderTrs().$dossier; |
453 |
|
|
454 |
|
// if a file already exists by that name and it |
455 |
|
// is not a directory, back out |
456 |
|
/*if (file_exists($dir) AND is_dir($dir)) { |
457 |
|
$this -> addToMessage("error", _("Le repertoire n'existe pas, le fichier ne peut pas etre enregistre.")); |
458 |
|
return false; |
459 |
|
}*/ |
460 |
|
// if a dirextory by that name exists, make sure it does |
461 |
|
// not already contain an avis de consultation, MAYBE WE DON'T NEED THIS |
462 |
|
if (file_exists($dir) AND is_dir($dir)) { |
463 |
|
$dir_contents = trim(shell_exec('ls '.$dir)); |
464 |
|
if (strpos($dir_contents, ' ') != false) { |
465 |
|
$dir_contents = explode(' ', $dir_contents); |
466 |
|
} else { |
467 |
|
$dir_contents = array($dir_contents); |
468 |
|
} |
469 |
|
foreach ($dir_contents as $basefname) { // very useful for consultation |
470 |
|
if (strpos($basefname, $prefix)!==false) { |
471 |
|
return _("Un retour d'avis existe deja."); |
472 |
|
|
473 |
|
} |
474 |
|
} |
475 |
|
} else { |
476 |
|
return _("Le dossier n'existe pas."); |
477 |
|
} |
478 |
|
// if no file by that name exists, create the directory |
479 |
|
|
480 |
|
if (!file_exists($dir)) { |
481 |
|
if (!mkdir($dir, 0775)) { |
482 |
|
return _("Erreur dans la création de répertoire."); |
483 |
|
} |
484 |
|
} |
485 |
|
|
486 |
|
|
487 |
|
// store the file contents into the file named: |
488 |
|
// consultation_<ID>_<file_name_received> |
489 |
|
$file_len = strlen($fichier_base64); |
490 |
|
|
491 |
|
$filename = $dir."/".$prefix.$basename; |
492 |
|
|
493 |
|
$file = fopen($filename, 'w'); |
494 |
|
if (!$file) { |
495 |
|
return _("Echec a la creation du fichier."); |
496 |
|
} |
497 |
|
// check that the number of bytes written is equal to the length |
498 |
|
// of the data received |
499 |
|
$num_written = fwrite($file, $fichier_base64, $file_len); |
500 |
|
|
501 |
|
if (!$num_written) { |
502 |
|
// remove the file |
503 |
|
// the return value from shell can't be used for checking since |
504 |
|
// one can not know if the NULL returned is because there was no |
505 |
|
// output or because there was an error |
506 |
|
$ret = shell_exec("rm -f $filename 2>&1"); |
507 |
|
//if ($ret == NULL) { // an error occured while deleting the file |
508 |
|
//} |
509 |
|
return _("La sauvegarde du fichier a echoue"); |
510 |
|
} |
511 |
|
fclose($file); |
512 |
|
return true; |
513 |
} |
} |
514 |
|
|
515 |
/** |
/** |
516 |
* Cette methode permet d'affecter des parametres dans un attribut de |
* |
|
* l'objet. |
|
|
* |
|
|
* @return void |
|
517 |
*/ |
*/ |
518 |
function setMoreParams() { |
function notExistsError ($explanation = NULL) { |
519 |
|
// message |
520 |
|
$message_class = "error"; |
521 |
|
$message = _("Cette page n'existe pas."); |
522 |
|
$this->addToMessage ($message_class, $message); |
523 |
// |
// |
524 |
if (file_exists("../dyn/var.inc")) { |
$this->setFlag(NULL); |
525 |
include_once("../dyn/var.inc"); |
$this->display(); |
|
} |
|
526 |
|
|
527 |
// |
// |
528 |
if (isset($chemin_plan)) { |
die(); |
529 |
$this->config['chemin_plan'] = $chemin_plan; |
} |
530 |
} else { |
|
531 |
$this->config['chemin_plan'] = "../trs/"; |
/** |
532 |
} |
* Méthode de récupération des informations de l'utilisateur connecté. |
533 |
|
*/ |
534 |
|
function getUserInfos() { |
535 |
|
|
536 |
|
// Si l'utilisateur est loggé $_SESSION existe |
537 |
|
if(isset($_SESSION['login']) AND !empty($_SESSION['login'])) { |
538 |
|
|
539 |
|
// Récupération des infos utilisateur |
540 |
|
$sqlUser = "SELECT om_utilisateur, nom, email, login, om_collectivite, om_profil ". |
541 |
|
"FROM om_utilisateur WHERE login = '".$_SESSION['login']."'"; |
542 |
|
$resUser=$this->db->query($sqlUser); |
543 |
|
$this->addToLog("getUserInfos(): db->query(\"".$sqlUser."\");", VERBOSE_MODE); |
544 |
|
$this->isDatabaseError($resUser); |
545 |
|
$this->om_utilisateur=&$resUser->fetchRow(DB_FETCHMODE_ASSOC); |
546 |
|
|
547 |
|
// Récupération des infos instructeur |
548 |
|
$sqlInstr = "SELECT instructeur.instructeur, instructeur.nom, instructeur.telephone, division.code, division.libelle ". |
549 |
|
"FROM instructeur INNER JOIN division ON division.division=instructeur.division ". |
550 |
|
"WHERE instructeur.om_utilisateur = ".$this->om_utilisateur['om_utilisateur']; |
551 |
|
$resInstr=$this->db->query($sqlInstr); |
552 |
|
$this->addToLog("getUserInfos(): db->query(\"".$sqlInstr."\");", VERBOSE_MODE); |
553 |
|
$this->isDatabaseError($resInstr); |
554 |
|
$tempInstr=&$resInstr->fetchRow(DB_FETCHMODE_ASSOC); |
555 |
|
// Si il y a un resultat c'est un instructeur |
556 |
|
if(count($tempInstr)>0) { |
557 |
|
$this->user_is_instr=true; |
558 |
|
$this->om_utilisateur = array_merge($this->om_utilisateur,$tempInstr); |
559 |
|
} |
560 |
|
|
561 |
|
// Récupération des infos de services ext consultés |
562 |
|
$sqlServExt = "SELECT service.service, service.abrege, service.libelle ". |
563 |
|
"FROM service ". |
564 |
|
"INNER JOIN lien_service_om_utilisateur ON lien_service_om_utilisateur.service=service.service ". |
565 |
|
"WHERE lien_service_om_utilisateur.om_utilisateur = ".$this->om_utilisateur['om_utilisateur']; |
566 |
|
$resServExt=$this->db->query($sqlServExt); |
567 |
|
$this->addToLog("getUserInfos(): db->query(\"".$sqlServExt."\");", VERBOSE_MODE); |
568 |
|
$this->isDatabaseError($resServExt); |
569 |
|
|
570 |
|
while ($tempServExt=&$resServExt->fetchRow(DB_FETCHMODE_ASSOC)) { |
571 |
|
$this->om_utilisateur['service'][]=$tempServExt; |
572 |
|
} |
573 |
|
// Si il y a un resultat c'est un utilisateur de service |
574 |
|
if(isset($this->om_utilisateur['service'])) { |
575 |
|
$this->user_is_service_ext=true; |
576 |
|
} |
577 |
|
} |
578 |
} |
} |
579 |
|
|
580 |
|
/** |
581 |
|
* getter user_is_service_ext |
582 |
|
*/ |
583 |
|
function isUserServiceExt() { |
584 |
|
return $this->user_is_service_ext; |
585 |
|
} |
586 |
|
/** |
587 |
|
* getter user_is_instr |
588 |
|
*/ |
589 |
|
function isUserInstructeur() { |
590 |
|
return $this->user_is_instr; |
591 |
|
} |
592 |
|
} |
593 |
|
|
|
} //fin class |
|
|
?> |
|
594 |
|
?> |