Esempio n. 1
1
 /**
  * Set the hash for the user mails
  *
  * @return bool
  */
 protected function setUserMailHash()
 {
     $ds = CSQLDataSource::get("std");
     $mails = $ds->loadList("SELECT m.user_mail_id, m.account_class, m.account_id, m.from, m.to, m.subject, c.content FROM user_mail as m, content_html as c WHERE m.account_class IS NOT NULL AND m.account_id IS NOT NULL AND m.text_html_id = c.content_id ORDER BY m.user_mail_id DESC;");
     if (count($mails)) {
         $values = array();
         foreach ($mails as $_mail) {
             $data = "==FROM==\n" . $_mail['from'] . "\n==TO==\n" . $_mail['to'] . "\n==SUBJECT==\n" . $_mail['subject'] . "\n==CONTENT==\n" . $_mail['content'];
             $hash = CMbSecurity::hash(CMbSecurity::SHA256, $data);
             $values[] = '(' . $_mail['user_mail_id'] . ', ' . $_mail['account_id'] . ', \'' . $_mail['account_class'] . "', '{$hash}')";
         }
         $mails = $ds->loadList("SELECT m.user_mail_id, m.account_class, m.account_id, m.from, m.to, m.subject, c.content FROM user_mail AS m, content_any AS c WHERE m.account_class IS NOT NULL AND m.account_id IS NOT NULL AND m.text_html_id IS NULL AND m.text_plain_id = c.content_id ORDER BY m.user_mail_id DESC;");
         foreach ($mails as $_mail) {
             $data = "==FROM==\n" . $_mail['from'] . "\n==TO==\n" . $_mail['to'] . "\n==SUBJECT==\n" . $_mail['subject'] . "\n==CONTENT==\n" . $_mail['content'];
             $hash = CMbSecurity::hash(CMbSecurity::SHA256, $data);
             $values[] = '(' . $_mail['user_mail_id'] . ', ' . $_mail['account_id'] . ', \'' . $_mail['account_class'] . "', '{$hash}')";
         }
         $query = "INSERT INTO `user_mail` (`user_mail_id`, `account_id`, `account_class`, `hash`) VALUES " . implode(', ', $values) . " ON DUPLICATE KEY UPDATE `hash` = VALUES(`hash`);";
         $ds->query($query);
         if ($msg = $ds->error()) {
             CAppUI::stepAjax($msg, UI_MSG_WARNING);
             return false;
         }
     }
     return true;
 }
 public function remove(CAppUI $AppUI, w2p_Utilities_Date $date)
 {
     $perms = $AppUI->acl();
     $removed = false;
     if ($this->holiday_id && $perms->checkModuleItem('holiday', 'edit', $this->holiday_id)) {
         $holiday_start_date = new w2p_Utilities_Date($this->holiday_start_date);
         $holiday_end_date = new w2p_Utilities_Date($this->holiday_end_date);
         if ($holiday_start_date->equals($date->duplicate())) {
             if ($holiday_end_date->equals($date->duplicate())) {
                 $removed = $this->delete($AppUI);
             } else {
                 $holiday_start_date = new w2p_Utilities_Date($this->holiday_start_date);
                 $this->holiday_start_date = $holiday_start_date->getNextDay()->getDate();
                 $removed = $this->store($AppUI);
             }
         } elseif ($holiday_end_date->equals($date->duplicate())) {
             $holiday_end_date = new w2p_Utilities_Date($this->holiday_end_date);
             $this->holiday_end_date = $holiday_end_date->getPrevDay()->getDate();
             $removed = $this->store($AppUI);
         } elseif ($holiday_start_date->before($date->duplicate()) && $holiday_end_date->after($date->duplicate())) {
             $holiday_end_date = $this->holiday_end_date;
             $this->holiday_end_date = $date->getPrevDay()->getDate();
             $removed = $this->store($AppUI);
             $this->holiday_id = 0;
             // create new record
             $this->holiday_start_date = $date->getNextDay()->getDate();
             $this->holiday_end_date = $holiday_end_date;
             $removed = $this->store($AppUI);
         }
     }
     return $removed;
 }
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->field_id && canEdit('system')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->field_id && canEdit('system')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     return $stored;
 }
 public function store(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $stored = false;
     $this->file_folder_id = (int) $this->file_folder_id;
     $this->file_folder_parent = (int) $this->file_folder_parent;
     $this->_error = $this->check();
     if (count($this->_error)) {
         return $this->_error;
     }
     /*
      * TODO: I don't like the duplication on each of these two branches, but I
      *   don't have a good idea on how to fix it at the moment...
      */
     if ($this->file_folder_id && $perms->checkModuleItem('files', 'edit')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     if (0 == $this->file_folder_id && $perms->checkModuleItem('files', 'add')) {
         if ($msg = parent::store()) {
             return $msg;
         }
         $stored = true;
     }
     return $stored;
 }
Esempio n. 5
0
 public function process(CAppUI $AppUI, array $myArray)
 {
     if (!$this->object->bind($myArray)) {
         $AppUI->setMsg($this->object->getError(), UI_MSG_ERROR);
         $this->resultPath = $this->errorPath;
         return $AppUI;
     }
     $action = $this->delete ? 'deleted' : 'stored';
     $this->success = $this->delete ? $this->object->delete($AppUI) : $this->object->store($AppUI);
     if (is_array($this->success) || !$this->success) {
         $AppUI->holdObject($this->object);
         /*
          * TODO: This nasty structure was introduced in v3.0 and is only
          *   transitional while the individual modules are updated to
          *   stop using $this->success as both a boolean and the error array.
          *   -- This was due to a bad design decision on my part. -caseydk
          */
         if (is_array($this->object->getError())) {
             $AppUI->setMsg($this->object->getError(), UI_MSG_ERROR);
         } else {
             $AppUI->setMsg($this->success, UI_MSG_ERROR);
         }
         $this->resultPath = $this->errorPath;
         return $AppUI;
     }
     if ($this->success) {
         $AppUI->setMsg($this->prefix . ' ' . $action, UI_MSG_OK, true);
         $this->resultPath = $this->successPath;
     } else {
         $this->resultPath = $this->accessDeniedPath;
     }
     return $AppUI;
 }
 public static function renderColumn(CAppUI $AppUI, $fieldName, $row)
 {
     switch ($fieldName) {
         case 'project_creator':
         case 'project_owner':
             $s .= '<td nowrap="nowrap">';
             $s .= w2PgetUsernameFromID($row[$fieldName]);
             $s .= '</td>';
             break;
         case 'project_target_budget':
         case 'project_actual_budget':
             $s .= '<td>';
             $s .= $w2Pconfig['currency_symbol'];
             $s .= formatCurrency($row[$fieldName], $AppUI->getPref('CURRENCYFORM'));
             $s .= '</td>';
             break;
         case 'project_url':
         case 'project_demo_url':
             $s .= '<td>';
             $s .= w2p_url($row[$fieldName]);
             $s .= '</td>';
             break;
         case 'project_start_date':
         case 'project_end_date':
             $df = $AppUI->getPref('SHDATEFORMAT');
             $myDate = intval($row[$fieldName]) ? new w2p_Utilities_Date($row[$fieldName]) : null;
             $s .= '<td nowrap="nowrap" class="center">' . ($myDate ? $myDate->format($df) : '-') . '</td>';
             break;
         default:
             $s .= '<td nowrap="nowrap" class="center">';
             $s .= htmlspecialchars($row[$fieldName], ENT_QUOTES);
             $s .= '</td>';
     }
     return $s;
 }
Esempio n. 7
0
 public function remove(CAppUI $AppUI = null)
 {
     global $AppUI;
     $q = new w2p_Database_Query();
     $q->dropTable('history');
     $q->exec();
     $perms = $AppUI->acl();
     return $perms->unregisterModule('history');
 }
Esempio n. 8
0
 public function delete(CAppUI $AppUI)
 {
     $perms = $AppUI->acl();
     $this->_error = array();
     if ($perms->checkModuleItem('resources', 'delete', $this->resource_id)) {
         if ($msg = parent::delete()) {
             return $msg;
         }
         return true;
     }
     return false;
 }
Esempio n. 9
0
 /**
  * Check anti-CSRF protection
  */
 static function checkProtection()
 {
     if (!CAppUI::conf("csrf_protection") || strtoupper($_SERVER['REQUEST_METHOD']) != 'POST') {
         return;
     }
     if (!isset($_POST["csrf"])) {
         CAppUI::setMsg("CCSRF-no_token", UI_MSG_ERROR);
         return;
     }
     if (array_key_exists($_POST['csrf'], $_SESSION["tokens"])) {
         $token = $_SESSION['tokens'][$_POST['csrf']];
         if ($token["lifetime"] >= time()) {
             foreach ($token["fields"] as $_field => $_value) {
                 if (CValue::read($_POST, $_field) != $_value) {
                     CAppUI::setMsg("CCSRF-form_corrupted", UI_MSG_ERROR);
                     unset($_SESSION['tokens'][$_POST['csrf']]);
                     return;
                 }
             }
             //mbTrace("Le jeton est accepté !");
             unset($_SESSION['tokens'][$_POST['csrf']]);
         } else {
             CAppUI::setMsg("CCSRF-token_outdated", UI_MSG_ERROR);
             unset($_SESSION['tokens'][$_POST['csrf']]);
         }
         return;
     }
     CAppUI::setMsg("CCSRF-token_does_not_exist", UI_MSG_ERROR);
     return;
 }
 /**
  * @see parent::__construct
  */
 function __construct()
 {
     $this->evenement = "evt_serveurintervention";
     $this->acquittement = "acquittementsServeurActes";
     $version = str_replace(".", "", CAppUI::conf("hprimxml {$this->evenement} version"));
     parent::__construct("serveurActivitePmsi_v{$version}", "msgAcquittementsServeurActes{$version}");
 }
Esempio n. 11
0
 static function mine($parent_class)
 {
     $classes = CApp::getChildClasses($parent_class);
     $limit = CAppUI::conf("dataminer_limit");
     foreach ($classes as $_class) {
         $miner = new $_class();
         $report = $miner->mineSome($limit, "mine");
         $dt = CMbDT::dateTime();
         echo "<{$dt}> Miner: {$_class}. Success mining count is '" . $report["success"] . "'\n";
         if (!$report["failure"]) {
             echo "<{$dt}> Miner: {$_class}. Failure mining counts is '" . $report["failure"] . "'\n";
         }
         $miner = new $_class();
         $report = $miner->mineSome($limit, "remine");
         $dt = CMbDT::dateTime();
         echo "<{$dt}> Reminer: {$_class}. Success remining count is '" . $report["success"] . "'\n";
         if (!$report["failure"]) {
             echo "<{$dt}> Reminer: {$_class}. Failure remining counts is '" . $report["failure"] . "'\n";
         }
         $miner = new $_class();
         $report = $miner->mineSome($limit, "postmine");
         $dt = CMbDT::dateTime();
         echo "<{$dt}> Postminer: {$_class}. Success postmining count is '" . $report["success"] . "'\n";
         if (!$report["failure"]) {
             echo "<{$dt}> Postminer: {$_class}. Failure postmining counts is '" . $report["failure"] . "'\n";
         }
     }
 }
 /**
  * @see parent::onAfterStore()
  */
 function onAfterStore(CMbObject $mbObject)
 {
     if (!$this->isHandled($mbObject)) {
         return false;
     }
     /** @var CConsultation $consultation */
     $consultation = $mbObject;
     $praticien = $consultation->loadRefPraticien();
     if (!$praticien || $praticien && !$praticien->_id) {
         return false;
     }
     $function = $praticien->loadRefFunction();
     if (!$function || $function && !$function->_id) {
         return false;
     }
     $functions = CAppUI::conf("ihe RAD-3 function_ids");
     $functions = explode("|", $functions);
     if (!in_array($function->_id, $functions)) {
         return false;
     }
     $code = "O01";
     if (!$this->isMessageSupported($this->transaction, $this->message, $code, $consultation->_receiver)) {
         return false;
     }
     $this->sendITI($this->profil, $this->transaction, $this->message, $code, $consultation);
     return true;
 }
 /**
  * logSejourAccess
  *
  * @param CSejour $sejour
  *
  * @return bool has the access been logged
  */
 static function logForSejour($sejour)
 {
     $group = $sejour->loadRefEtablissement();
     if (!CAppUI::conf("admin CLogAccessMedicalData enable_log_access", $group) || !$sejour->_id) {
         return false;
     }
     $user = CMediusers::get();
     $conf = CAppUI::conf("admin CLogAccessMedicalData round_datetime", $group);
     $datetime = CMbDT::dateTime();
     switch ($conf) {
         case '1m':
             // minute
             $datetime = CMbDT::format($datetime, "%y-%m-%d %H:%M:00");
             break;
         case '10m':
             // 10 minutes
             $minute = CMbDT::format($datetime, "%M");
             $minute = str_pad(floor($minute / 10) * 10, 2, 0, STR_PAD_RIGHT);
             $datetime = CMbDT::format($datetime, "%y-%m-%d %H:{$minute}:00");
             break;
         case '1d':
             // 1 day
             $datetime = CMbDT::format($datetime, "%y-%m-%d 00:00:00");
             break;
         default:
             // 1 hour
             $datetime = CMbDT::format($datetime, "%y-%m-%d %H:00:00");
             break;
     }
     return self::logintoDb($user->_id, $sejour->_class, $sejour->_id, $datetime, $group->_id);
 }
 /**
  * @see parent::generateEnteteMessageAcquittement()
  */
 function generateEnteteMessageAcquittement($statut, $codes = null, $commentaires = null)
 {
     $echg_hprim = $this->_ref_echange_hprim;
     $identifiant = $echg_hprim->_id ? str_pad($echg_hprim->_id, 6, '0', STR_PAD_LEFT) : "ES{$this->now}";
     $acquittementsServeurActivitePmsi = $this->addElement($this, $this->acquittement, null, "http://www.hprim.org/hprimXML");
     $this->addAttribute($acquittementsServeurActivitePmsi, "version", CAppUI::conf("hprimxml {$this->evenement} version"));
     $enteteMessageAcquittement = $this->addElement($acquittementsServeurActivitePmsi, "enteteMessage");
     $this->addAttribute($enteteMessageAcquittement, "statut", $statut);
     $this->addElement($enteteMessageAcquittement, "identifiantMessage", $identifiant);
     $this->addDateTimeElement($enteteMessageAcquittement, "dateHeureProduction");
     $emetteur = $this->addElement($enteteMessageAcquittement, "emetteur");
     $agents = $this->addElement($emetteur, "agents");
     $this->addAgent($agents, "application", "MediBoard", "Gestion des Etablissements de Santé");
     $group = CGroups::loadCurrent();
     $group->loadLastId400();
     $this->addAgent($agents, $this->getAttSysteme(), CAppUI::conf('mb_id'), $group->text);
     $echg_hprim->loadRefsInteropActor();
     // Pour un acquittement l'emetteur du message devient destinataire
     $destinataire = $this->addElement($enteteMessageAcquittement, "destinataire");
     $agents = $this->addElement($destinataire, "agents");
     $this->addAgent($agents, "application", $echg_hprim->_ref_sender->nom, $echg_hprim->_ref_sender->libelle);
     /* @todo Doit-on gérer le système du destinataire ? */
     //$this->addAgent($agents, "système", $group->_id, $group->text);
     $this->addElement($enteteMessageAcquittement, "identifiantMessageAcquitte", $this->_identifiant_acquitte);
 }
Esempio n. 15
0
/**
 * Mediboard class autoloader
 * 
 * @param string $class Class to be loaded
 * 
 * @return bool
 */
function mbAutoload($class)
{
    $file_exists = false;
    $time = microtime(true);
    // Entry already in cache
    if (isset(CApp::$classPaths[$class])) {
        // The class is known to not be in MB
        if (CApp::$classPaths[$class] === false) {
            return false;
        }
        // Load it if we can
        if ($file_exists = file_exists(CApp::$classPaths[$class])) {
            CApp::$performance["autoloadCount"]++;
            return include_once CApp::$classPaths[$class];
        }
    }
    // File moved ?
    if (!$file_exists) {
        unset(CApp::$classPaths[$class]);
    }
    // CSetup* class
    if (preg_match('/^CSetup(.+)$/', $class, $matches)) {
        $dirs = array("modules/{$matches['1']}/setup.php");
    } else {
        $class_file = $class;
        $suffix = ".class";
        // Namespaced class
        if (strpos($class_file, "\\") !== false) {
            $namespace = explode("\\", $class_file);
            // Mediboard class
            if ($namespace[0] === "Mediboard") {
                array_shift($namespace);
                $class_file = implode("/", $namespace);
            } else {
                $class_file = "vendor/" . implode("/", $namespace);
                $suffix = "";
            }
        }
        $class_file .= $suffix;
        $dirs = array("classes/{$class_file}.php", "classes/*/{$class_file}.php", "mobile/*/{$class_file}.php", "modules/*/classes/{$class_file}.php", "modules/*/classes/*/{$class_file}.php", "modules/*/classes/*/*/{$class_file}.php", "install/classes/{$class_file}.php");
    }
    $rootDir = CAppUI::conf("root_dir");
    $class_path = false;
    foreach ($dirs as $dir) {
        $files = glob("{$rootDir}/{$dir}");
        foreach ($files as $filename) {
            include_once $filename;
            // The class was found
            if (class_exists($class, false) || interface_exists($class, false)) {
                $class_path = $filename;
                break 2;
            }
        }
    }
    // Class not found, it is not in MB
    CApp::$classPaths[$class] = $class_path;
    SHM::put("class-paths", CApp::$classPaths);
    CApp::$performance["autoload"][$class] = (microtime(true) - $time) * 1000;
    return $class_path !== false;
}
 function testFunction(&$object, $function_name, $params = array())
 {
     $str_params = implode(",", $params);
     $result = $object->{$function_name}($str_params);
     $log = "<div class=\"message\">" . get_class($object) . "::{$function_name}({$str_params}) -> {$result}</div>" . CAppUI::getMsg();
     $this->addLog($log);
 }
 /**
  * Méthode permettant de tester si le service d'extraction Tika est actif
  *
  * @return string
  */
 function loadTikaInfos()
 {
     $conf_host = trim(CAppUI::conf("search tika_host"));
     $conf_port = trim(CAppUI::conf("search tika_port"));
     $client = new CHTTPClient("http://{$conf_host}:{$conf_port}/tika");
     return $client->get();
 }
Esempio n. 18
0
 /**
  * Store
  *
  * @return void
  */
 function doStore()
 {
     // keep track of former values for fieldModified below
     $obj = $this->_obj;
     $old = $obj->loadOldObject();
     if ($msg = $obj->store()) {
         CAppUI::setMsg($msg, UI_MSG_ERROR);
         if ($this->redirectError) {
             CAppUI::redirect($this->redirectError);
         }
     } else {
         // Keep trace for redirections
         CValue::setSession($this->objectKey, $obj->_id);
         // Insert new group and function permission
         if ($obj->fieldModified("function_id") || !$old->_id) {
             $obj->insFunctionPermission();
             $obj->insGroupPermission();
         }
         // Message
         CAppUI::setMsg($old->_id ? $this->modifyMsg : $this->createMsg, UI_MSG_OK);
         // Redirection
         if ($this->redirectStore) {
             CAppUI::redirect($this->redirectStore);
         }
     }
 }
Esempio n. 19
0
 /**
  * @see parent::doRedirect()
  */
 function doRedirect()
 {
     if (CAppUI::conf("dPsalleOp CActeCCAM codage_strict") || !$this->_old->_id || !$this->_obj->_id) {
         $this->_ref_object->correctActes();
     }
     parent::doRedirect();
 }
Esempio n. 20
0
 /**
  * The constructor
  * 
  * @param string  $rooturl     The URL of the wsdl file
  * @param string  $type        The type of exchange
  * @param array   $options     An array of options
  * @param boolean $loggable    True if you want to log all the exchanges with the web service
  * @param string  $local_cert  Path of the certifacte
  * @param string  $passphrase  Pass phrase for the certificate
  * @param boolean $safe_mode   Safe mode
  * @param boolean $verify_peer Require verification of SSL certificate used
  * @param string  $cafile      Location of Certificate Authority file on local filesystem
  *
  * @throws CMbException
  *
  * @return CNuSOAPClient
  */
 function __construct($rooturl, $type = null, $options = array(), $loggable = null, $local_cert = null, $passphrase = null, $safe_mode = false, $verify_peer = false, $cafile = null)
 {
     $this->wsdl_url = $rooturl;
     if ($loggable) {
         $this->loggable = $loggable;
     }
     if ($type) {
         $this->type_echange_soap = $type;
     }
     if (!$safe_mode) {
         if (!($html = file_get_contents($this->wsdl_url))) {
             $this->soap_client_error = true;
             throw new CMbException("CSourceSOAP-unable-to-parse-url", $this->wsdl_url);
         }
         if (strpos($html, "<?xml") === false) {
             $this->soap_client_error = true;
             throw new CMbException("CSourceSOAP-wsdl-invalid");
         }
     }
     if (array_key_exists("encoding", $options)) {
         $encoding = $options["encoding"];
         $this->soap_defencoding = $encoding;
         if ($encoding == "UTF-8") {
             $this->decode_utf8 = false;
         }
     }
     if ($local_cert) {
         $this->certRequest = array("sslcertfile" => $local_cert);
     }
     if ($passphrase) {
         $this->certRequest = array("passphrase" => $passphrase);
     }
     parent::__construct($rooturl, true, false, false, false, false, CAppUI::conf("webservices connection_timeout"));
     $this->wsdl_url = $rooturl;
 }
Esempio n. 21
0
 /**
  * @see parent::getValue()
  */
 function getValue($object, $smarty = null, $params = array())
 {
     if ($object->color) {
         return "<div style=\"background-color: #{$object->color}; min-width:30px; height:1em; border: solid 1px #afafaf;\"></div>";
     }
     return CAppUI::tr("Undefined");
 }
Esempio n. 22
0
/**
 * Extract files
 *
 * @param string $schemaDir  Schema directory
 * @param string $schemaFile Schema files
 * @param bool   $delOldDir  Delete old directory
 *
 * @return void
 */
function extractFiles($schemaDir, $schemaFile, $delOldDir = false)
{
    $baseDir = "modules/hprimxml/xsd";
    $destinationDir = "{$baseDir}/{$schemaDir}";
    $archivePath = "{$baseDir}/{$schemaFile}";
    if ($delOldDir && file_exists($destinationDir)) {
        if (CMbPath::remove($destinationDir)) {
            echo "<div class='info'>Suppression de {$destinationDir}</div>";
        } else {
            echo "<div class='error'>Impossible de supprimer le dossier {$destinationDir}</div>";
            return;
        }
    }
    if (false != ($nbFiles = CMbPath::extract($archivePath, $destinationDir))) {
        echo "<div class='info'>Extraction de {$nbFiles} fichiers pour {$schemaDir}</div>";
    } else {
        echo "<div class='error'>Impossible d'extraire l'archive {$schemaFile}</div>";
        return;
    }
    if (CAppUI::conf("hprimxml concatenate_xsd")) {
        $rootFiles = glob("{$destinationDir}/msg*.xsd");
        $includeFiles = array_diff(glob("{$destinationDir}/*.xsd"), $rootFiles);
        foreach ($rootFiles as $rootFile) {
            $xsd = new CHPrimXMLSchema();
            $xsd->loadXML(file_get_contents($rootFile));
            $xpath = new DOMXPath($xsd);
            $importFiles = array();
            foreach ($includeFiles as $includeFile) {
                $include = new DOMDOcument();
                $include->loadXML(file_get_contents($includeFile));
                $isImport = false;
                foreach ($importFiles as $key => $value) {
                    if (strpos($includeFile, $key) !== false) {
                        $isImport = true;
                        break;
                    }
                }
                foreach ($include->documentElement->childNodes as $child) {
                    $impNode = $xsd->importNode($child, true);
                    $existing = false;
                    if (in_array($impNode->nodeName, array("xsd:simpleType", "xsd:complexType"))) {
                        $name = $impNode->getAttribute('name');
                        $existing = $xpath->query("//{$impNode->nodeName}[@name='{$name}']")->length > 0;
                    }
                    if ($isImport) {
                        $xsd->documentElement->setAttribute("xmlns:insee", "http://www.hprim.org/inseeXML");
                    }
                    if (!$existing) {
                        $xsd->documentElement->appendChild($impNode);
                    }
                }
            }
            $xsd->purgeImportedNamespaces();
            $xsd->purgeIncludes();
            file_put_contents(substr($rootFile, 0, -4) . ".xml", $xsd->saveXML());
            echo "<div class='info'>Schéma concatené</div>";
        }
    }
}
Esempio n. 23
0
 /**
  * Magic method (do not call directly).
  * @param string $name method name
  * @param array  $args arguments
  *
  * @return mixed
  *
  * @throws Exception
  * @throws CMbException
  */
 function __call($name, $args)
 {
     $name = strtolower($name);
     $silent = strncmp($name, 'try', 3) === 0;
     $function_name = $silent ? substr($name, 3) : $name;
     $function_name = '_' . (isset(self::$aliases[$function_name]) ? self::$aliases[$function_name] : $function_name);
     if (!method_exists($this, $function_name)) {
         throw new CMbException("CSourceFTP-call-undefined-method", $name);
     }
     if ($function_name == "_init") {
         return call_user_func_array(array($this, $function_name), $args);
     }
     if (!$this->loggable) {
         try {
             return call_user_func_array(array($this, $function_name), $args);
         } catch (CMbException $fault) {
             throw $fault;
         }
     }
     $echange_ftp = new CExchangeFTP();
     $echange_ftp->date_echange = CMbDT::dateTime();
     $echange_ftp->emetteur = CAppUI::conf("mb_id");
     $echange_ftp->destinataire = $this->hostname;
     $echange_ftp->function_name = $name;
     CApp::$chrono->stop();
     $chrono = new Chronometer();
     $chrono->start();
     $output = null;
     try {
         $output = call_user_func_array(array($this, $function_name), $args);
     } catch (CMbException $fault) {
         $echange_ftp->date_echange = CMbDT::dateTime();
         $echange_ftp->output = $fault->getMessage();
         $echange_ftp->ftp_fault = 1;
         $echange_ftp->store();
         CApp::$chrono->start();
         throw $fault;
     }
     $chrono->stop();
     CApp::$chrono->start();
     // response time
     $echange_ftp->response_time = $chrono->total;
     // Truncate input and output before storing
     $args = array_map_recursive(array("CFTP", "truncate"), $args);
     $echange_ftp->input = serialize($args);
     if ($echange_ftp->ftp_fault != 1) {
         if ($function_name == "_getlistfiles") {
             // Truncate le tableau des fichiers reçus dans le cas où c'est > 100
             $array_count = count($output);
             if ($array_count > 100) {
                 $output = array_slice($output, 0, 100);
                 $output["count"] = "{$array_count} files";
             }
         }
         $echange_ftp->output = serialize(array_map_recursive(array("CFTP", "truncate"), $output));
     }
     $echange_ftp->store();
     return $output;
 }
Esempio n. 24
0
 /**
  * CMbSemaphore Constructor
  *
  * @param string $key semaphore identifier
  */
 function __construct($key)
 {
     $this->path = CAppUI::conf("root_dir") . "/tmp/locks";
     CMbPath::forceDir($this->path);
     $this->process = getmypid();
     $prefix = CApp::getAppIdentifier();
     $this->key = "{$prefix}-sem-{$key}";
 }
 /**
  * @see parent::updateFormFields()
  **/
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_view = sprintf("FA%08d", $this->_id);
     if (CAppUI::conf("ref_pays") == 2) {
         $this->_view .= " /{$this->numero}";
     }
 }
 /**
  * Initialize object specification
  *
  * @return CMbObjectSpec the spec
  */
 function getSpec()
 {
     $spec = parent::getSpec();
     $spec->table = 'destinataire_hprim';
     $spec->key = 'dest_hprim_id';
     $spec->messages = array("patients" => array("evenementPatient"), "pmsi" => array(CAppUI::conf("hprimxml send_diagnostic") == "evt_serveuretatspatient" ? "evenementServeurEtatsPatient" : "evenementPMSI", "evenementServeurActe", "evenementFraisDivers", "evenementServeurIntervention"), "stock" => array("evenementMvtStocks"));
     return $spec;
 }
 function updateFormFields()
 {
     parent::updateFormFields();
     $this->_self_sender = $this->emetteur == CAppUI::conf('mb_id');
     $this->_self_receiver = $this->destinataire == CAppUI::conf('mb_id');
     // ms
     $this->response_time = $this->response_time * 1000;
 }
 public function stepAjax($type = UI_MSG_WARNING)
 {
     $args = func_get_args();
     $msg = CAppUI::tr($this->getMessage(), array_slice($args, 1));
     CAppUI::$localize = false;
     CAppUI::stepAjax($msg, $type);
     CAppUI::$localize = true;
 }
 /**
  * Try and store trigger mark according to module config
  * 
  * @param CTriggerMark $mark Mark content
  *
  * @return void
  */
 static function storeMark($mark)
 {
     if (CAppUI::conf("dPsante400 mark_row")) {
         if ($msg = $mark->store()) {
             trigger_error("Enable to store CTriggerMark: {$msg}", E_USER_WARNING);
         }
     }
 }
 /**
  * @see parent::__construct()
  */
 function __construct($key, $label = null)
 {
     parent::__construct($key, $label);
     $this->path = CAppUI::conf("root_dir") . "/tmp/locks";
     $this->process = getmypid();
     $this->filename = "{$this->path}/" . $this->getLockKey();
     CMbPath::forceDir(dirname($this->filename));
 }