74 |
"FROM ".DB_PREFIXE."om_utilisateur WHERE login = '".$_SESSION['login']."'"; |
"FROM ".DB_PREFIXE."om_utilisateur WHERE login = '".$_SESSION['login']."'"; |
75 |
$resUser=$this->db->query($sqlUser); |
$resUser=$this->db->query($sqlUser); |
76 |
$this->addToLog("getUserInfos(): db->query(\"".$sqlUser."\");", VERBOSE_MODE); |
$this->addToLog("getUserInfos(): db->query(\"".$sqlUser."\");", VERBOSE_MODE); |
77 |
$this->isDatabaseError($resUser); |
if ( database::isError($resUser)){ |
78 |
|
die(); |
79 |
|
} |
80 |
$this->om_utilisateur=&$resUser->fetchRow(DB_FETCHMODE_ASSOC); |
$this->om_utilisateur=&$resUser->fetchRow(DB_FETCHMODE_ASSOC); |
81 |
|
|
82 |
// Récupération des infos instructeur |
// Récupération des infos instructeur |
86 |
"WHERE instructeur.om_utilisateur = ".$this->om_utilisateur['om_utilisateur']; |
"WHERE instructeur.om_utilisateur = ".$this->om_utilisateur['om_utilisateur']; |
87 |
$resInstr=$this->db->query($sqlInstr); |
$resInstr=$this->db->query($sqlInstr); |
88 |
$this->addToLog("getUserInfos(): db->query(\"".$sqlInstr."\");", VERBOSE_MODE); |
$this->addToLog("getUserInfos(): db->query(\"".$sqlInstr."\");", VERBOSE_MODE); |
89 |
$this->isDatabaseError($resInstr); |
if ( database::isError($resInstr)){ |
90 |
|
die(); |
91 |
|
} |
92 |
$tempInstr=&$resInstr->fetchRow(DB_FETCHMODE_ASSOC); |
$tempInstr=&$resInstr->fetchRow(DB_FETCHMODE_ASSOC); |
93 |
// Si il y a un resultat c'est un instructeur |
// Si il y a un resultat c'est un instructeur |
94 |
if(count($tempInstr)>0) { |
if(count($tempInstr)>0) { |
105 |
"WHERE lien_service_om_utilisateur.om_utilisateur = ".$this->om_utilisateur['om_utilisateur']; |
"WHERE lien_service_om_utilisateur.om_utilisateur = ".$this->om_utilisateur['om_utilisateur']; |
106 |
$resServExt=$this->db->query($sqlServExt); |
$resServExt=$this->db->query($sqlServExt); |
107 |
$this->addToLog("getUserInfos(): db->query(\"".$sqlServExt."\");", VERBOSE_MODE); |
$this->addToLog("getUserInfos(): db->query(\"".$sqlServExt."\");", VERBOSE_MODE); |
108 |
$this->isDatabaseError($resServExt); |
if ( database::isError($resServExt)){ |
109 |
|
die(); |
110 |
|
} |
111 |
|
|
112 |
while ($tempServExt=&$resServExt->fetchRow(DB_FETCHMODE_ASSOC)) { |
while ($tempServExt=&$resServExt->fetchRow(DB_FETCHMODE_ASSOC)) { |
113 |
$this->om_utilisateur['service'][]=$tempServExt; |
$this->om_utilisateur['service'][]=$tempServExt; |
158 |
WHERE instructeur.om_utilisateur='".$utilisateur["om_utilisateur"]."'"; |
WHERE instructeur.om_utilisateur='".$utilisateur["om_utilisateur"]."'"; |
159 |
$res = $this->db->query($sql); |
$res = $this->db->query($sql); |
160 |
$this->addToLog("triggerAfterLogin(): db->query(\"".$sql."\");", VERBOSE_MODE); |
$this->addToLog("triggerAfterLogin(): db->query(\"".$sql."\");", VERBOSE_MODE); |
161 |
$this->isDatabaseError($res); |
if ( database::isError($res)){ |
162 |
|
die(); |
163 |
|
} |
164 |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
$row = $res->fetchrow(DB_FETCHMODE_ASSOC); |
165 |
// |
// |
166 |
if (isset($row["division"]) && $row["division"] != NULL) { |
if (isset($row["division"]) && $row["division"] != NULL) { |
185 |
|
|
186 |
// }}} |
// }}} |
187 |
|
|
188 |
|
|
189 |
|
function getDivisionFromDossier($dossier) { |
190 |
|
// |
191 |
|
$sql = "select division from ".DB_PREFIXE."dossier "; |
192 |
|
$sql .= " where dossier='".$dossier."'"; |
193 |
|
// |
194 |
|
$division = $this->db->getOne($sql); |
195 |
|
$this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
196 |
|
database::isError($division); |
197 |
|
// |
198 |
|
return $division; |
199 |
|
} |
200 |
|
|
201 |
// {{{ SURCHARGES POUR LE FONCTIONNEMENT DES REQUETES REST |
// {{{ SURCHARGES POUR LE FONCTIONNEMENT DES REQUETES REST |
202 |
|
|
203 |
/** |
/** |
223 |
|
|
224 |
// |
// |
225 |
$message_class = "error"; |
$message_class = "error"; |
226 |
$message = _("Droits insuffisants. Vous n'avez pas suffisament de ". |
$message = _("Droits insuffisants. Vous n'avez pas suffisamment de ". |
227 |
"droits pour acceder a cette page."); |
"droits pour acceder a cette page."); |
228 |
$this->addToMessage($message_class, $message); |
$this->addToMessage($message_class, $message); |
229 |
|
|
347 |
$temp = $this->database_config["schema"]."."; |
$temp = $this->database_config["schema"]."."; |
348 |
} |
} |
349 |
$temp = $temp.$this->database_config["prefixe"]; |
$temp = $temp.$this->database_config["prefixe"]; |
350 |
define("DB_PREFIXE", $temp); |
(defined("DB_PREFIXE") ? "" : define("DB_PREFIXE", $temp)); |
351 |
define("FORMATDATE", $this->database_config["formatdate"]); |
(defined("FORMATDATE") ? "" : define("FORMATDATE", $this->database_config["formatdate"])); |
352 |
|
|
353 |
// Definition des constantes pour l'acces aux informations de la base |
// Definition des constantes pour l'acces aux informations de la base |
354 |
// donnees facilement. |
// donnees facilement. |
355 |
define("OM_DB_FORMATDATE", $this->database_config["formatdate"]); |
(defined("OM_DB_FORMATDATE") ? "" : define("OM_DB_FORMATDATE", $this->database_config["formatdate"])); |
356 |
define("OM_DB_PHPTYPE", $this->database_config["phptype"]); |
(defined("OM_DB_PHPTYPE") ? "" : define("OM_DB_PHPTYPE", $this->database_config["phptype"])); |
357 |
define("OM_DB_DATABASE", $this->database_config["database"]); |
(defined("OM_DB_DATABASE") ? "" : define("OM_DB_DATABASE", $this->database_config["database"])); |
358 |
define("OM_DB_SCHEMA", $this->database_config["schema"]); |
(defined("OM_DB_SCHEMA") ? "" : define("OM_DB_SCHEMA", $this->database_config["schema"])); |
359 |
define("OM_DB_TABLE_PREFIX", $this->database_config["prefixe"]); |
(defined("OM_DB_TABLE_PREFIX") ? "" : define("OM_DB_TABLE_PREFIX", $this->database_config["prefixe"])); |
360 |
} |
} |
361 |
|
|
362 |
} |
} |
410 |
*/ |
*/ |
411 |
function displayMessage($class = "", $message = "") { |
function displayMessage($class = "", $message = "") { |
412 |
if (!defined('REST_REQUEST')) { |
if (!defined('REST_REQUEST')) { |
413 |
$this->m->displayMessage($class, $message); |
$this->layout->display_message($class, $message); |
414 |
} |
} |
415 |
} |
} |
416 |
|
|
460 |
} |
} |
461 |
return $file_list; |
return $file_list; |
462 |
} |
} |
|
|
|
|
/* |
|
|
* Store the data recived in the request into a file on the |
|
|
* local filesystem. |
|
|
* @todo This function will need to be changed for the save to |
|
|
* be on GED |
|
|
* @param mixed $data The data received with the request |
|
|
* @param string $id The consultation ID |
|
|
* @return string OK on success, KO otherwise |
|
|
*/ |
|
|
|
|
|
function storeDecisionFile(&$fichier_base64, $basename, $dossier, $prefix = '') { |
|
|
|
|
|
if (empty($fichier_base64)) { |
|
|
$this -> addToMessage("error", _("Le fichier est vide")); |
|
|
return false; |
|
|
} |
|
|
$dir = $this->getPathFolderTrs().$dossier; |
|
|
|
|
|
// if a file already exists by that name and it |
|
|
// is not a directory, back out |
|
|
/*if (file_exists($dir) AND is_dir($dir)) { |
|
|
$this -> addToMessage("error", _("Le repertoire n'existe pas, le fichier ne peut pas etre enregistre.")); |
|
|
return false; |
|
|
}*/ |
|
|
// if a dirextory by that name exists, make sure it does |
|
|
// not already contain an avis de consultation, MAYBE WE DON'T NEED THIS |
|
|
if (file_exists($dir) AND is_dir($dir)) { |
|
|
$dir_contents = trim(shell_exec('ls '.$dir)); |
|
|
if (strpos($dir_contents, ' ') != false) { |
|
|
$dir_contents = explode(' ', $dir_contents); |
|
|
} else { |
|
|
$dir_contents = array($dir_contents); |
|
|
} |
|
|
foreach ($dir_contents as $basefname) { // very useful for consultation |
|
|
if (strpos($basefname, $prefix)!==false) { |
|
|
return _("Un retour d'avis existe deja."); |
|
|
|
|
|
} |
|
|
} |
|
|
} else { |
|
|
$this->createFolder($dossier); |
|
|
} |
|
|
|
|
|
// store the file contents into the file named: |
|
|
// consultation_<ID>_<file_name_received> |
|
|
$file_len = strlen($fichier_base64); |
|
|
|
|
|
$filename = $dir."/".$prefix.$basename; |
|
|
|
|
|
$file = fopen($filename, 'w'); |
|
|
if (!$file) { |
|
|
return _("Echec a la creation du fichier."); |
|
|
} |
|
|
// check that the number of bytes written is equal to the length |
|
|
// of the data received |
|
|
$num_written = fwrite($file, $fichier_base64, $file_len); |
|
|
|
|
|
if (!$num_written) { |
|
|
// remove the file |
|
|
// the return value from shell can't be used for checking since |
|
|
// one can not know if the NULL returned is because there was no |
|
|
// output or because there was an error |
|
|
$ret = shell_exec("rm -f $filename 2>&1"); |
|
|
//if ($ret == NULL) { // an error occured while deleting the file |
|
|
//} |
|
|
return _("La sauvegarde du fichier a echoue"); |
|
|
} |
|
|
fclose($file); |
|
|
return true; |
|
|
} |
|
463 |
|
|
464 |
/** |
/** |
465 |
* |
* |