Esempio n. 1
0
 /**
  * Set starting and closing formulas
  *
  * @param integer|null $user_id Given owner id
  *
  * @return null
  */
 function loadSalutations($user_id = null)
 {
     if (!$this->_id) {
         return null;
     }
     $salutation = new CSalutation();
     $salutation->owner_id = $user_id ? $user_id : CMediusers::get()->_id;
     $salutation->object_class = $this->_class;
     $salutation->object_id = $this->_id;
     if ($salutation->loadMatchingObject()) {
         $this->_starting_formula = $salutation->starting_formula;
         $this->_closing_formula = $salutation->closing_formula;
     } else {
         $this->_starting_formula = CAppUI::tr('CSalutation-starting_formula|default');
         $this->_closing_formula = CAppUI::tr('CSalutation-closing_formula|default');
     }
 }
Esempio n. 2
0
<?php

/**
 * $Id$
 *
 * @package    Mediboard
 * @subpackage Patients
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
$salutation_id = CValue::get('salutation_id');
$object_class = CValue::get('object_class');
$object_id = CValue::get('object_id');
$salutation = new CSalutation();
$salutation->load($salutation_id);
if (!$salutation_id) {
    if (!$object_class || !in_array('CStoredObject', class_parents($object_class))) {
        CAppUI::stepAjax('common-error-Invalid class name', UI_MSG_ERROR);
    }
    $object = CStoredObject::loadFromGuid("{$object_class}-{$object_id}");
    if (!$object || !$object->_id) {
        CAppUI::stepAjax('common-error-Invalid object', UI_MSG_ERROR);
    }
    $salutation->owner_id = CMediusers::get()->_id;
    $salutation->object_class = $object_class;
    $salutation->object_id = $object_id;
}
$salutation->loadRefOwner();
$salutation->loadTargetObject();
$users = new CMediusers();
 * @version    $Revision$
 */
$object_class = CValue::get('object_class');
$object_id = CValue::get('object_id');
if (!$object_class || !$object_id) {
    CAppUI::stepAjax('common-error-Missing parameter', UI_MSG_ERROR);
}
if (!$object_class || !in_array('CStoredObject', class_parents($object_class))) {
    CAppUI::stepAjax('common-error-Invalid class name', UI_MSG_ERROR);
}
$object = CStoredObject::loadFromGuid("{$object_class}-{$object_id}");
if (!$object || !$object->_id) {
    CAppUI::stepAjax('common-error-Invalid object', UI_MSG_ERROR);
}
/** @var CSalutation[] $salutations */
$salutations = CSalutation::loadAllSalutations($object->_class, $object->_id);
CStoredObject::massLoadFwdRef($salutations, 'owner_id');
CStoredObject::massLoadFwdRef($salutations, 'object_id');
$functions = array();
$salutations_by_function = array();
/** @var CSalutation $_salutation */
foreach ($salutations as $_salutation) {
    $_salutation->loadRefOwner();
    if (!isset($salutations_by_function[$_salutation->_ref_owner->function_id])) {
        $salutations_by_function[$_salutation->_ref_owner->function_id] = array();
        $functions[$_salutation->_ref_owner->function_id] = $_salutation->_ref_owner->loadRefFunction();
    }
    $salutations_by_function[$_salutation->_ref_owner->function_id][] = $_salutation;
}
$salutations = $salutations_by_function;
ksort($salutations);