/**
  * Get properties specifications as strings
  *
  * @see parent::getProps()
  *
  * @return array
  */
 function getProps()
 {
     $specs = parent::getProps();
     $specs["wsdl_external"] = "str";
     $specs["wsdl_mode"] = "bool default|1";
     $specs["evenement_name"] = "str";
     $specs["single_parameter"] = "str";
     $specs["encoding"] = "enum list|UTF-8|ISO-8859-1|ISO-8859-15 default|UTF-8";
     $specs["type_soap"] = "enum list|CMbSOAPClient|CNuSOAPClient default|CMbSOAPClient notNull";
     $specs["iv_passphrase"] = "str show|0 loggable|0";
     $specs["safe_mode"] = "bool default|0";
     $specs["return_mode"] = "enum list|normal|raw|file";
     $specs["soap_version"] = "enum list|SOAP_1_1|SOAP_1_2 default|SOAP_1_1 notNull";
     $specs["xop_mode"] = "bool default|0";
     $specs["use_tunnel"] = "bool default|0";
     $specs["socket_timeout"] = "num min|1";
     $specs["connection_timeout"] = "num min|1";
     $specs["feature"] = "enum list|SOAP_SINGLE_ELEMENT_ARRAYS|SOAP_USE_XSI_ARRAY_TYPE|SOAP_WAIT_ONE_WAY_CALLS";
     $specs["local_cert"] = "str";
     $specs["passphrase"] = "password show|0 loggable|0";
     $specs["verify_peer"] = "bool default|0";
     $specs["cafile"] = "str";
     $specs["stream_context"] = "str";
     return $specs;
 }
 function getSpec()
 {
     $spec = parent::getSpec();
     $spec->table = 'source_http';
     $spec->key = 'source_http_id';
     return $spec;
 }
 /**
  * Get the properties of our class as strings
  *
  * @return array
  */
 function getProps()
 {
     $props = parent::getProps();
     $props["port"] = "num default|22";
     $props["timeout"] = "num default|10";
     $props["fileprefix"] = "str";
     $props["fileextension_write_end"] = "str";
     $props["fileextension"] = "str";
     return $props;
 }
 /**
  * @see parent::getProps()
  */
 function getProps()
 {
     $specs = parent::getProps();
     $specs["ssl"] = "bool default|0";
     $specs["port"] = "num default|21";
     $specs["timeout"] = "num default|5";
     $specs["pasv"] = "bool default|0";
     $specs["mode"] = "enum list|FTP_ASCII|FTP_BINARY default|FTP_BINARY";
     $specs["counter"] = "str protected loggable|0";
     $specs["fileprefix"] = "str";
     $specs["fileextension"] = "str";
     $specs["filenbroll"] = "enum list|1|2|3|4";
     $specs["fileextension_write_end"] = "str";
     return $specs;
 }
<?php

/**
 * Send a mail concerning the diskfull problem while backuping
 *
 * $Id$
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
/** @var CSourceSMTP $source */
$source = CExchangeSource::get("system-message", "smtp", true, null, true);
try {
    // Source init
    $source->init();
    $source->addTo(CAppUI::conf("system CMessage default_email_to"));
    $source->addBcc(CAppUI::conf("system CMessage default_email_from"));
    $source->addRe(CAppUI::conf("system CMessage default_email_from"));
    // Email subject
    $page_title = CAppUI::conf("page_title");
    $message_subject = CAppUI::tr("system-msg-backup-diskfull");
    $source->setSubject("{$page_title} - {$message_subject}");
    // Email body
    $message_body = CAppUI::tr("system-msg-backup-diskfull-desc");
    $body = "<strong>{$page_title}</strong>";
    $body .= "<p>{$message_body}</p>";
    $source->setBody($body);
    // Do send
Exemple #6
0
<?php

/**
 * Configuration du module Hprim21
 *
 * @category Hprim21
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License; see http://www.gnu.org/licenses/gpl.html
 * @version  SVN: $Id: configure.php 19437 2013-06-05 22:38:47Z rhum1 $
 * @link     http://www.mediboard.org
 */
CCanDo::checkAdmin();
$hprim21_source = CExchangeSource::get("hprim21", "ftp", true);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("hprim21_source", $hprim21_source);
$smarty->display("configure.tpl");
/* $Id: ajax_test_dsn.php 6069 2009-04-14 10:17:11Z phenxdesign $ */
/**
 * @package Mediboard
 * @subpackage hl7
 * @version $Revision: 6069 $
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 */
CCanDo::checkAdmin();
// Check params
if (null == ($exchange_source_name = CValue::get("exchange_source_name"))) {
    CAppUI::stepAjax("Aucun nom de source d'échange spécifié", UI_MSG_ERROR);
}
/** @var CSourceMLLP $exchange_source */
$exchange_source = CExchangeSource::get($exchange_source_name, "mllp", true, null, false);
if (!$exchange_source) {
    CAppUI::stepAjax("Aucune source d'échange disponible pour ce nom : '{$exchange_source_name}'", UI_MSG_ERROR);
}
if (!$exchange_source->host) {
    CAppUI::stepAjax("Aucun hôte pour la source d'échange : '{$exchange_source_name}'", UI_MSG_ERROR);
}
try {
    $exchange_source->getSocketClient();
    CAppUI::stepAjax("Connexion au serveur MLLP réussi");
    if ($ack = $exchange_source->getData()) {
        echo "<pre>{$ack}</pre>";
    }
} catch (Exception $e) {
    CAppUI::stepAjax($e->getMessage(), UI_MSG_ERROR);
}
 * $Id$
 *  
 * @package    Mediboard
 * @subpackage messagerie
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 * @link       http://www.mediboard.org
 */
$account_id = CValue::get('account_id');
$mail_id = Cvalue::get('mail_id');
$reply_to_id = CValue::get('reply_to_id');
$answer_to_all = CValue::get('answer_to_all');
$account = new CSourcePOP();
$account->load($account_id);
$smtp = CExchangeSource::get("mediuser-{$account->object_id}", 'smtp');
if (!$smtp->_id) {
    $smarty = new CSmartyDP();
    $smarty->assign('msg', CAppUI::tr('CUserMail-msg-no_smtp_source_linked_to_pop_account'));
    $smarty->assign('type', 'error');
    $smarty->assign('modal', 1);
    $smarty->assign('close_modal', 1);
    $smarty->display('inc_display_msg.tpl');
    CApp::rip();
}
$mail = new CUserMail();
if ($mail_id) {
    $mail->load($mail_id);
    if ($mail->text_html_id) {
        $mail->loadContentHTML();
        $mail->_content = $mail->_text_html->content;
Exemple #9
0
 * @category CompteRendu
 * @package  Mediboard
 * @author   SARL OpenXtrem <*****@*****.**>
 * @license  GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version  SVN: $Id:\$
 * @link     http://www.mediboard.org
 */
CCanDo::checkRead();
$nom = CValue::post("nom");
$email = CValue::post("email");
$subject = CValue::post("subject");
$body = CValue::post("body");
$object_guid = CValue::post("object_guid");
$object = CMbObject::loadFromGuid($object_guid);
/** @var $exchange_source CSourceSMTP */
$exchange_source = CExchangeSource::get("mediuser-" . CMediusers::get()->_id, "smtp");
$exchange_source->init();
if (CAppUI::pref('hprim_med_header')) {
    $body = $object->makeHprimHeader($exchange_source->email, $email) . "\n" . $body;
}
try {
    $exchange_source->setRecipient($email, $nom);
    $exchange_source->setSubject($subject);
    $exchange_source->setBody(nl2br($body));
    switch ($object->_class) {
        case "CCompteRendu":
            /** @var $object CCompteRendu */
            $object->makePDFpreview(true);
            $file = $object->_ref_file;
            $exchange_source->addAttachment($file->_file_path, $file->file_name);
            break;
 function loadRefsExchangesSources()
 {
     $source_fs = CExchangeSource::get("{$this->_guid}", "file_system", true, $this->_type_echange, false);
     $this->_ref_exchanges_sources[$source_fs->_guid] = $source_fs;
 }
 /**
  * Send event PMSI
  *
  * @param CHPrimXMLEvenementsServeurActivitePmsi $dom_evt  Event
  * @param CMbObject                              $mbObject Object
  *
  * @throws CMbException
  *
  * @return void
  */
 function sendEvenementPMSI(CHPrimXMLEvenementsServeurActivitePmsi $dom_evt, CMbObject $mbObject)
 {
     if (!($msg = $dom_evt->generateTypeEvenement($mbObject))) {
         return;
     }
     $source = CExchangeSource::get("{$this->_guid}-{$dom_evt->sous_type}");
     if (!$source->_id || !$source->active) {
         return;
     }
     $exchange = $dom_evt->_ref_echange_hprim;
     $source->setData($msg, false, $exchange);
     try {
         $source->send();
     } catch (Exception $e) {
         throw new CMbException("CExchangeSource-no-response");
     }
     $exchange->date_echange = CMbDT::dateTime();
     $acq = $source->getACQ();
     if (!$acq) {
         $exchange->store();
         return;
     }
     $dom_acq = CHPrimXMLAcquittementsServeurActivitePmsi::getEvtAcquittement($dom_evt);
     $dom_acq->loadXML($acq);
     $dom_acq->_ref_echange_hprim = $exchange;
     $doc_valid = $dom_acq->schemaValidate(null, false, $this->display_errors);
     $exchange->statut_acquittement = $dom_acq->getStatutAcquittementServeurActivitePmsi();
     $exchange->acquittement_valide = $doc_valid ? 1 : 0;
     $exchange->_acquittement = $acq;
     $exchange->store();
 }
Exemple #12
0
 /**
  * Load the sent mails for an account
  *
  * @param int $account_id The account id
  * @param int $start      The start
  * @param int $limit      The number of mails to load
  *
  * @return CUserMail[]
  */
 public static function loadSent($account_id, $start, $limit)
 {
     $source_smtp = CExchangeSource::get('mediuser-' . CMediusers::get()->_id, "smtp");
     if ($source_smtp->_id) {
         $where[] = "(account_id = '{$account_id}' AND account_class = 'CSourcePOP') OR (account_id = '{$source_smtp->_id}' AND account_class = 'CSourceSMTP')";
     } else {
         $where['account_id'] = "= '{$account_id}'";
         $where['account_class'] = "= 'CSourcePOP'";
     }
     $where['sent'] = " = '1' ";
     $order = "date_inbox DESC";
     $limit = "{$start}, {$limit}";
     $mail = new CUserMail();
     return $mail->loadList($where, $order, $limit);
 }
Exemple #13
0
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
// Check params
if (null == ($exchange_source_name = CValue::get("exchange_source_name"))) {
    CAppUI::stepAjax("CExchangeSource-error-noSourceName", UI_MSG_ERROR);
}
if (null == ($type_action = CValue::get("type_action"))) {
    CAppUI::stepAjax("CExchangeSource-error-noTestDefined", UI_MSG_ERROR);
}
/** @var CSyslogSource $exchange_source */
$exchange_source = CExchangeSource::get($exchange_source_name, "syslog", true, null, false);
if (!$exchange_source->_id) {
    CAppUI::stepAjax("CExchangeSource-error-unsavedParameters", UI_MSG_ERROR);
}
switch ($type_action) {
    case 'connection':
        if ($exchange_source->protocol == 'UDP') {
            try {
                $exchange_source->testUDPConnection();
                CAppUI::setMsg("common-msg-Successful connection", UI_MSG_OK);
            } catch (CMbException $e) {
                $e->stepAjax(UI_MSG_ERROR);
            }
        } else {
            try {
                $exchange_source->connect();
<?php

/* $Id $ */
/**
 * @package Mediboard
 * @subpackage hl7
 * @version $Revision:$
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 */
CCanDo::checkRead();
// Envoi à la source créée 'HL7 v.2'
$exchange_source = CExchangeSource::get("hl7v2", "ftp");
$extension = $exchange_source->fileextension;
$ftp = new CFTP();
$ftp->init($exchange_source);
$ftp->connect();
if (!($list = $ftp->getListFiles($ftp->fileprefix))) {
    CAppUI::stepAjax("Le répertoire ne contient aucun fichier", UI_MSG_ERROR);
}
$messages = array();
foreach ($list as $filepath) {
    if (substr($filepath, -strlen($extension)) == $extension) {
        $filename = tempnam("", "hl7");
        $ftp->getFile($filepath, $filename);
        $hl7v2_reader = new CHL7v2Reader();
        $message = $hl7v2_reader->readFile($filename);
        if (!$message) {
            $message = new CHL7v2Message();
        }
        $message->filename = basename($filepath);
<?php

/* $Id: ajax_test_dsn.php 6069 2009-04-14 10:17:11Z phenxdesign $ */
/**
 * @package Mediboard
 * @subpackage system
 * @version $Revision: 6069 $
 * @author SARL OpenXtrem
 * @license GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 */
// Check params
if (null == ($exchange_source_name = CValue::get("exchange_source_name"))) {
    CAppUI::stepAjax("Aucun nom de source d'échange spécifié", UI_MSG_ERROR);
}
$exchange_source = CExchangeSource::get($exchange_source_name, "ftp", false, null, false);
$ftp = new CFTP();
$ftp->init($exchange_source);
try {
    $ftp->testSocket();
    CAppUI::stepAjax("CFTP-success-connection", E_USER_NOTICE, $ftp->hostname, $ftp->port);
    $ftp->connect();
    CAppUI::stepAjax("CFTP-success-authentification", E_USER_NOTICE, $ftp->username);
    if ($ftp->passif_mode) {
        CAppUI::stepAjax("CFTP-msg-passive_mode");
    }
    $sent_file = CAppUI::conf('root_dir') . "/offline.php";
    $remote_file = $ftp->fileprefix . "test.txt";
    $ftp->sendFile($sent_file, $remote_file);
    CAppUI::stepAjax("CFTP-success-transfer_out", E_USER_NOTICE, $sent_file, $remote_file);
    $get_file = "tmp/offline.php";
    $ftp->getFile($remote_file, $get_file);
 /**
  * Traitement des retours en erreur d'xml d'un praticien
  *
  * @param int $chir_id praticien de la consultation
  *
  * @return void|string
  */
 static function traitementDossier($chir_id)
 {
     $files = array();
     $fs_source_reception = CExchangeSource::get("reception-tarmed-CMediusers-{$chir_id}", "file_system", true, null, false);
     if (!$fs_source_reception->_id || !$fs_source_reception->active) {
         return null;
     }
     $count_files = CMbPath::countFiles($fs_source_reception->host);
     if ($count_files < 100) {
         try {
             $files = $fs_source_reception->receive();
         } catch (CMbException $e) {
             return CAppUI::tr($e->getMessage());
         }
     }
     $delfile_read_reject = CAppUI::conf("dPfacturation Other delfile_read_reject", CGroups::loadCurrent());
     foreach ($files as $_file) {
         $fs = new CSourceFileSystem();
         $rejet = new self();
         $rejet->praticien_id = $chir_id;
         $rejet->file_name = basename($_file);
         if ($msg = $rejet->store()) {
             return $msg;
         }
         $rejet->readXML($fs->getData($_file));
         //Sauvegarde du XML en CFile
         $new_file = new CFile();
         $new_file->setObject($rejet);
         $new_file->file_name = basename($_file);
         $new_file->file_type = "application/xml";
         $new_file->author_id = CAppUI::$user->_id;
         $new_file->fillFields();
         $new_file->updateFormFields();
         $new_file->forceDir();
         $new_file->putContent(trim($fs->getData($_file)));
         if ($msg = $new_file->store()) {
             mbTrace($msg);
         }
         //Suppression du fichier selon configuration
         if ($delfile_read_reject) {
             $fs->delFile($_file);
         }
     }
     return null;
 }
 /**
  * Send exchange
  *
  * @throws CMbException
  *
  * @return void
  */
 function send()
 {
     $this->loadRefsInteropActor();
     if (!$this->message_valide) {
         throw new CMbException("CExchangeDataFormat-msg-Invalid exchange");
     }
     $receiver = $this->_ref_receiver;
     $receiver->loadConfigValues();
     $evenement = null;
     $msg = $this->_message;
     if ($receiver instanceof CReceiverHL7v2) {
         if ($receiver->_configs["encoding"] == "UTF-8") {
             $msg = utf8_encode($msg);
         }
         $evenement = "evenementsPatient";
         $data_format = CIHE::getEvent($this);
     }
     if ($receiver instanceof CDestinataireHprim) {
         if ($receiver->_configs["encoding"] == "UTF-8") {
             $msg = utf8_encode($msg);
         }
         if ($this->type == "patients") {
             $evenement = "evenementPatient";
             $data_format = CHPrimXMLEventPatient::getHPrimXMLEvenements($this->_message);
         }
         if ($this->type == "pmsi") {
             $data_format = CHPrimXMLEventServeurActivitePmsi::getHPrimXMLEvenements($this->_message);
             $evenement = $data_format->sous_type;
         }
     }
     if ($receiver instanceof CPhastDestinataire) {
         $data_format = CPhastEvenementsPN13::getXMLEvenementsPN13($this->_message);
         $evenement = $data_format->sous_type;
     }
     if (!$evenement) {
         throw new CMbException("CExchangeDataFormat-msg-No events defined");
     }
     $source = CExchangeSource::get("{$receiver->_guid}-{$evenement}");
     if (!$source->_id || !$source->active) {
         throw new CMbException("CExchangeDataFormat-msg-No source for this actor");
     }
     // Si on n'a pas d'IPP et NDA
     if ($this->master_idex_missing) {
         throw new CMbException("CExchangeDataFormat-msg-Master idex missing");
     }
     $source->setData($msg, false, $this);
     $source->send();
     $this->date_echange = CMbDT::dateTime();
     // Si on n'a pas d'acquittement
     if (!($ack_data = $source->getACQ())) {
         $this->store();
         return;
     }
     if ($this instanceof CEchangeHprim) {
         $ack_data = utf8_decode($ack_data);
         $ack = CHPrimXMLAcquittements::getAcquittementEvenementXML($data_format);
         $ack->loadXML($ack_data);
         $doc_valid = $ack->schemaValidate();
         if ($doc_valid) {
             $this->statut_acquittement = $ack->getStatutAcquittement();
         }
     }
     if ($this instanceof CExchangeHL7v2) {
         $ack = new CHL7v2Acknowledgment($data_format);
         $ack->handle($ack_data);
         $this->statut_acquittement = $ack->getStatutAcknowledgment();
         $this->acquittement_valide = $ack->message->isOK(CHL7v2Error::E_ERROR) ? 1 : 0;
     }
     if ($this instanceof CExchangePhast) {
         $ack = new CPhastAcquittementsPN13();
         $ack->loadXML($ack_data);
         $doc_valid = $ack->schemaValidate();
         if ($doc_valid) {
             $this->statut_acquittement = $ack->getCodeAcquittement();
         }
     }
     $this->_acquittement = $ack_data;
     $this->store();
 }
$prescripteur = $doc->addElement($prescription, "Prescripteur");
$code9 = $doc->addElement($prescripteur, "Code9", $idSantePratCode9->id400);
$code4 = $doc->addElement($prescripteur, "Code4", $idSantePratCode4->id400);
// Sauvegarde du fichier temporaire
$tmpPath = "tmp/dPlabo/export_prescription.xml";
CMbPath::forceDir(dirname($tmpPath));
$doc->save($tmpPath);
$doc->load($tmpPath);
// Validation du document
if (!$doc->schemaValidate()) {
    CAppUI::setMsg("Document de prescription non valide", UI_MSG_ERROR);
    redirect();
}
// Envoi de la prescription par sur un seveurFTP
// Envoi à la source créée 'PrescriptionLabo' (FTP)
$prescriptionlabo_source = CExchangeSource::get("prescriptionlabo", "ftp");
// Creation du FTP
$ftp = new CFTP();
$ftp->init($prescriptionlabo_source);
if (!$ftp->hostname) {
    CAppUI::setMsg("Le document n'a pas pu être envoyé, configuration FTP manquante", UI_MSG_ERROR);
    redirect();
}
// Transfert
$destination_basename = "Prescription-" . $mbPrescription->_id;
$file = "tmp/dPlabo/export_prescription.xml";
try {
    $ftp->connect();
    $ftp->sendFile($file, "{$destination_basename}.xml");
} catch (CMbException $e) {
    $e->stepAjax();
 /**
  * Load exchanges sources
  *
  * @return CExchangeSource[]
  */
 function loadRefsExchangesSources()
 {
     if (!$this->_ref_msg_supported_family) {
         $this->getMessagesSupportedByFamily();
     }
     $this->_ref_exchanges_sources = array();
     foreach ($this->_ref_msg_supported_family as $_evenement) {
         $source = CExchangeSource::get("{$this->_guid}-{$_evenement}", null, true, $this->_type_echange);
         if ($source instanceof CSourcePOP) {
             $source->loadRefMetaObject();
         }
         $this->_ref_exchanges_sources[$_evenement] = $source;
     }
     return $this->_ref_exchanges_sources;
 }
 /**
  * Send event
  *
  * @param CHL7v3Event                            $event          Event
  * @param CMbObject|CXDSQueryRegistryStoredQuery $mbObject       Object
  * @param array                                  $headers        Headers
  * @param boolean                                $soapVar        XML message ?
  * @param bool                                   $message_return No Send the message
  *
  * @throws Exception
  * @return null|string
  */
 function sendEvent($event, CMbObject $mbObject, $headers = array(), $soapVar = false, $message_return = false)
 {
     $event->_receiver = $this;
     if (!$this->isMessageSupported(get_class($event))) {
         return false;
     }
     $this->loadConfigValues();
     $event->build($mbObject);
     $exchange = $event->_exchange_hl7v3;
     if (!$exchange->message_valide) {
         return null;
     }
     if (!$this->synchronous) {
         return null;
     }
     if ($message_return) {
         return $event->message;
     }
     $msg = $event->message;
     if ($soapVar) {
         $msg = trim(preg_replace("#^<\\?xml[^>]*>#", "", $msg));
         $msg = new SoapVar($msg, XSD_ANYXML);
     }
     $source = CExchangeSource::get("{$this->_guid}-C{$event->event_type}");
     if (!$source->_id || !$source->active) {
         return null;
     }
     if ($headers) {
         $source->_headerbody = $headers;
     }
     $source->setData($msg, null, $exchange);
     try {
         $event_name = isset($event->_event_name) ? $event->_event_name : null;
         $source->send($event_name);
     } catch (Exception $e) {
         throw $e;
     }
     $exchange->date_echange = CMbDT::dateTime();
     $ack_data = $source->getACQ();
     if (!$ack_data) {
         $exchange->store();
         return null;
     }
     if (!($ack = self::createAcknowledgment($event->event_type, $ack_data))) {
         $exchange->store();
         return null;
     }
     $exchange->date_echange = CMbDT::dateTime();
     $exchange->statut_acquittement = $ack->getStatutAcknowledgment();
     $exchange->acquittement_valide = $ack->dom->schemafilename ? $ack->dom->schemaValidate() ? 1 : 0 : 1;
     $exchange->_acquittement = $ack_data;
     $exchange->store();
     $ack->object = $mbObject;
     $ack->_receiver = $this;
     $ack->_exchange_hl7v3 = $exchange;
     return $ack;
 }
Exemple #21
0
<?php

/**
 * $Id$
 *  
 * @package    Mediboard
 * @subpackage messagerie
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 * @link       http://www.mediboard.org
 */
$user = CMediusers::get();
$source_smtp = CExchangeSource::get("mediuser-" . $user->_id, "smtp", true, null, false);
$source_pop = new CSourcePOP();
$source_pop->object_class = $user->_class;
$source_pop->object_id = $user->_id;
$source_pop->name = 'SourcePOP-' . $user->_id . '-' . ($source_pop->countMatchingList() + 1);
$mssante = false;
if (CModule::getActive('mssante') && CModule::getCanDo('mssante')->read) {
    $mssante = true;
}
$apicrypt = false;
if (CModule::getActive('apicrypt') && CModule::getCanDo('apicrypt')->read) {
    $apicrypt = true;
}
$smarty = new CSmartyDP();
$smarty->assign('source_smtp', $source_smtp);
$smarty->assign('source_pop', $source_pop);
$smarty->assign('mssante', $mssante);
$smarty->assign('apicrypt', $apicrypt);
$smarty->assign('object_class', CValue::get("object_class", $compte_rendu->object_class));
$smarty->assign("nb_printers", $nb_printers);
$smarty->assign("pack_id", $pack_id);
$smarty->assign("destinataires", $destinataires);
$smarty->assign("lock_bloked", $lock_bloked);
$smarty->assign("can_duplicate", $can_duplicate);
$smarty->assign("read_only", $read_only);
preg_match_all("/(:?\\[\\[Texte libre - ([^\\]]*)\\]\\])/i", $compte_rendu->_source, $matches);
$templateManager->textes_libres = $matches[2];
// Suppression des doublons
$templateManager->textes_libres = array_unique($templateManager->textes_libres);
if (isset($compte_rendu->_ref_file->_id)) {
    $smarty->assign("file", $compte_rendu->_ref_file);
}
$smarty->assign("textes_libres", $templateManager->textes_libres);
$exchange_source = CExchangeSource::get("mediuser-" . $curr_user->_id);
$smarty->assign("exchange_source", $exchange_source, "smtp");
// Ajout d'entête / pied de page à la volée
$headers = array();
$footers = array();
if (CAppUI::conf("dPcompteRendu CCompteRendu header_footer_fly")) {
    $headers = CCompteRendu::loadAllModelesFor($user->_id, "prat", $compte_rendu->object_class, "header");
    $footers = CCompteRendu::loadAllModelesFor($user->_id, "prat", $compte_rendu->object_class, "footer");
}
$smarty->assign("headers", $headers);
$smarty->assign("footers", $footers);
// Nettoyage des balises meta et link.
// Pose problème lors de la présence d'un entête et ou/pied de page
$source =& $templateManager->document;
$source = preg_replace("/<meta\\s*[^>]*\\s*[^\\/]>/", '', $source);
$source = preg_replace("/(<\\/meta>)+/i", '', $source);
 function getPassword($pwd = null, $iv_field = "iv")
 {
     if (is_null($pwd)) {
         $pwd = $this->password;
         if (!$this->password) {
             return "";
         }
     }
     try {
         $master_key_filepath = CAppUI::conf("master_key_filepath");
         $master_key_filepath = rtrim($master_key_filepath, "/");
         if (CExchangeSource::checkMasterKeyFile($master_key_filepath)) {
             CAppUI::requireLibraryFile("phpseclib/phpseclib/Crypt/AES");
             CAppUI::requireLibraryFile("phpseclib/phpseclib/Crypt/Random");
             $cipher = new Crypt_AES(CRYPT_AES_MODE_CTR);
             $cipher->setKeyLength(256);
             $keyAB = file($master_key_filepath . "/.mediboard.key");
             if (count($keyAB) == 2) {
                 $cipher->setKey($keyAB[0] . $keyAB[1]);
                 $ivToUse = $this->{$iv_field};
                 if (!$ivToUse) {
                     $clear = $pwd;
                     $this->store();
                     return $clear;
                 }
                 $cipher->setIV($ivToUse);
                 $decrypted = rtrim(base64_decode($pwd), "");
                 $decrypted = $cipher->decrypt($decrypted);
                 if ($decrypted) {
                     return $decrypted;
                 }
             }
         }
     } catch (Exception $e) {
         return $pwd;
     }
     return $pwd;
 }
 function setData($data, $argsList = false, CExchangeDataFormat $exchange = null)
 {
     parent::setData($data, $argsList);
     $file_path = str_replace(array(" ", ":", "-"), array("_", "", ""), CMbDT::dateTime());
     // Ajout du prefix si existant
     $file_path = $this->fileprefix . $file_path;
     if ($exchange) {
         $file_path = "{$file_path}-{$exchange->_id}";
     }
     $this->_file_path = "MB-{$file_path}.{$this->fileextension}";
 }
$where["function_id"] = "IS NOT NULL";
$affectatione = new CAffectation();
/** @var CAffectation[] $blocages_lit */
$blocages_lit = $affectatione->loadList($where);
$where["function_id"] = "IS NULL";
foreach ($blocages_lit as $key => $blocage) {
    $blocage->loadRefLit()->loadRefChambre()->loadRefService();
    $where["lit_id"] = "= '{$blocage->lit_id}'";
    if (!$sejour->_id && $affectatione->loadObject($where)) {
        $affectatione->loadRefSejour();
        $affectatione->_ref_sejour->loadRefPatient();
        $jusqua = CMbDT::transform($affectatione->sortie, null, "%Hh%Mmin %d-%m-%Y") . " (" . $affectatione->_ref_sejour->_ref_patient->_view;
        $blocage->_ref_lit->_view .= " indisponible jusqu'à " . $jusqua . ")";
    }
}
$exchange_source = CExchangeSource::get("mediuser-" . CAppUI::$user->_id, "smtp");
$_functions = array();
if ($chir->_id) {
    $_functions = $chir->loadBackRefs("secondary_functions");
}
$op->loadRefChir2();
$op->loadRefChir3();
$op->loadRefChir4();
if (!$op->_id) {
    $op->_time_op = $op->temp_operation = "00:00:00";
    if ($hour_urgence && $min_urgence) {
        $time = "{$hour_urgence}:{$min_urgence}:00";
    } else {
        $time = str_pad($hours_urgence["deb"], 2, "0", STR_PAD_LEFT) . ":00:00";
    }
    $op->_time_urgence = $op->time_operation = $time;
 */
CCanDo::checkRead();
$message_id = CValue::get("message_id");
$update_moment = CValue::get("_update_moment");
$update_initiator = CValue::get("_update_initiator");
$update_benefits = CValue::get("_update_benefits");
// Récupération du message à ajouter/éditer
$message = new CMessage();
$message->deb = CMbDT::dateTime();
$message->load($message_id);
$message->loadRefsNotes();
// Création du possible
if ($update_moment) {
    $message->deb = CMbDT::dateTime("-8 hours", $update_moment);
    $message->fin = CMbDT::dateTime("+15 minutes", $update_moment);
    $message->titre = CAppUI::tr("CMessage-create_update-titre");
    $message->corps = CAppUI::tr("CMessage-create_update-corps", CMbDT::format($update_moment, CAppUI::conf("datetime")));
    $details = CAppUI::tr("CMessage-create_update-details", stripslashes($update_initiator), stripslashes($update_benefits));
    $message->_email_details = CMbString::br2nl($details);
}
// Etablissements disponisbles
$groups = CMediusers::loadEtablissements(PERM_EDIT);
// Source SMTP
$message_smtp = CExchangeSource::get("system-message", "smtp", true, null, false);
$message->_email_from = CAppUI::conf("system CMessage default_email_from");
$message->_email_to = CAppUI::conf("system CMessage default_email_to");
$smarty = new CSmartyDP();
$smarty->assign("message", $message);
$smarty->assign("message_smtp", $message_smtp);
$smarty->assign("groups", $groups);
$smarty->display("inc_form_message.tpl");
<?php

/**
 * $Id: ajax_edit_source_mediuser.php 27587 2015-03-18 09:31:32Z aurelie17 $
 *
 * @package    Mediboard
 * @subpackage mediusers
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 27587 $
 */
CCanDo::checkRead();
$user_id = CValue::getOrSession("user_id");
$mediuser = CMediusers::get($user_id);
// Source File system d'envoi
$fs_source_envoi = CExchangeSource::get("envoi-tarmed-{$mediuser->_guid}", "file_system", true, null, false);
// Source File system d'envoi
$fs_source_reception = CExchangeSource::get("reception-tarmed-{$mediuser->_guid}", "file_system", true, null, false);
$fs_sources_tarmed = array("fs_source_envoi" => array($fs_source_envoi), "fs_source_reception" => array($fs_source_reception));
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("fs_sources_tarmed", $fs_sources_tarmed);
$smarty->display("sources_archive.tpl");
 function loadRefsExchangesSources()
 {
     $source_mllp = CExchangeSource::get("{$this->_guid}", "mllp", true, $this->_type_echange, false);
     $this->_ref_exchanges_sources[$source_mllp->_guid] = $source_mllp;
 }
/**
 * $Id: configure.php 19087 2013-05-12 16:27:44Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage Urgences
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 19087 $
 */
// Le chargement des droits se fait sur le module "parent"
global $m;
$path = CAppUI::conf("{$m} gnupg_path");
$path = $path ? $path : "~";
$home = exec("cd {$path} && pwd") . "/.gnupg";
$user_apache = exec('whoami');
// Check /root is writable
$writable = is_writable($home);
$source_name = isset($source_name) ? $source_name : $m;
// Source
$source = CExchangeSource::get($source_name, null, true, null, false);
// Source rescue
$source_rescue = CExchangeSource::get("{$source_name}-rescue", null, true, null, false);
// Création du template
$smarty = new CSmartyDP("modules/dPurgences");
$smarty->assign("user_apache", $user_apache);
$smarty->assign("home", $home);
$smarty->assign("path", $path);
$smarty->assign("writable", $writable);
$smarty->assign("source", $source);
$smarty->assign("source_rescue", $source_rescue);
$smarty->display("Config_RPU_Sender.tpl");
 /**
  * @see parent::doStore()
  */
 function doStore()
 {
     /** @var CUserMail $mail */
     $mail = $this->_obj;
     $mail->date_inbox = CMbDT::dateTime();
     $mail->date_read = $mail->date_inbox;
     $content_html = new CContentHTML();
     $mail->_content = CUserMail::purifyHTML($mail->_content);
     $content_html->content = $mail->_content;
     if (!($msg = $content_html->store())) {
         $mail->text_html_id = $content_html->_id;
         $mail->_text_html = $content_html;
     }
     $content_plain = new CContentAny();
     $content_plain->content = strip_tags($mail->_content);
     if (!($msg = $content_plain->store())) {
         $mail->text_plain_id = $content_plain->_id;
     }
     $hash = CMbSecurity::hash(CMbSecurity::SHA256, "==FROM==\n{$mail->from}\n==TO==\n{$mail->to}\n==SUBJECT==\n{$mail->subject}\n==CONTENT==\n{$mail->_content}");
     if ($msg = $mail->store()) {
         CAppUI::setMsg($msg, UI_MSG_ERROR);
         return parent::doStore();
     }
     $action = CValue::post('action');
     switch ($action) {
         case 'draft':
             $mail->draft = '1';
             CAppUI::setMsg('CUserMail-msg-drafted', UI_MSG_OK);
             break;
         case 'send':
             $mail->sent = '1';
             $mail->draft = '0';
             $account = $mail->loadAccount();
             if ($mail->_is_apicrypt) {
                 /** @var CSourceSMTP $smtp */
                 $smtp = CExchangeSource::get("mediuser-{$account->object_id}-apicrypt", 'smtp');
             } else {
                 /** @var CSourceSMTP $smtp */
                 $smtp = CExchangeSource::get("mediuser-{$account->object_id}", 'smtp');
             }
             $smtp->init();
             foreach (explode(',', $mail->to) as $_address) {
                 $smtp->addTo($_address);
             }
             if ($mail->cc != '') {
                 foreach (explode(',', $mail->cc) as $_address) {
                     $smtp->addCc($_address);
                 }
             }
             if ($mail->bcc != '') {
                 foreach (explode(',', $mail->bcc) as $_address) {
                     $smtp->addBcc($_address);
                 }
             }
             $smtp->setSubject($mail->subject);
             if ($mail->_is_apicrypt) {
                 $receiver = explode(',', $mail->to);
                 $body = CApicrypt::encryptBody($account->object_id, $receiver[0], $mail->_content);
                 $smtp->setBody($body);
             } else {
                 $smtp->setBody($mail->_content);
             }
             /** @var CMailAttachments[] $attachments */
             $attachments = $mail->loadAttachments();
             foreach ($attachments as $_attachment) {
                 $file = $_attachment->loadFiles();
                 $smtp->addAttachment($file->_file_path, $file->file_name);
             }
             try {
                 $smtp->send();
                 CAppUI::setMsg('CUserMail-msg-sent', UI_MSG_OK);
             } catch (phpmailerException $e) {
                 CAppUI::setMsg($e->errorMessage(), UI_MSG_ERROR);
             } catch (CMbException $e) {
                 $e->stepAjax();
             }
             break;
         default:
     }
     $mail->store();
     if (CAppUI::isMsgOK() && $this->redirectStore) {
         $this->redirect =& $this->redirectStore;
     }
     if (!CAppUI::isMsgOK() && $this->redirectError) {
         $this->redirect =& $this->redirectError;
     }
 }