/[openfoncier]/trunk/obj/utils.class.php
ViewVC logotype

Diff of /trunk/obj/utils.class.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1159 by fmichon, Mon Jan 7 17:15:57 2013 UTC revision 1859 by fmichon, Tue May 7 11:55:24 2013 UTC
# Line 74  class utils extends application { Line 74  class utils extends application {
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
# Line 84  class utils extends application { Line 86  class utils extends application {
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) {
# Line 101  class utils extends application { Line 105  class utils extends application {
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;
# Line 152  class utils extends application { Line 158  class utils extends application {
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) {
# Line 339  class utils extends application { Line 347  class utils extends application {
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      }      }
# Line 452  class utils extends application { Line 460  class utils extends application {
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       *       *

Legend:
Removed from v.1159  
changed lines
  Added in v.1859

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26