/**
  * @see parent::onAfterStore()
  */
 function onAfterStore(CMbObject $mbObject)
 {
     if (!$this->isHandled($mbObject)) {
         return false;
     }
     if (!$mbObject->_id || !$this->create) {
         return false;
     }
     $group_id = $mbObject->_id;
     $object_class = array("CSejour", "CPatient");
     global $dPconfig;
     $original_value = $dPconfig["eai"]["use_domain"];
     $dPconfig["eai"]["use_domain"] = "0";
     foreach ($object_class as $_class) {
         switch ($_class) {
             case "CSejour":
                 $tag_group = CSejour::getTagNDA($group_id);
                 break;
             case "CPatient":
                 $tag_group = CPatient::getTagIPP($group_id);
                 break;
             default:
                 $tag_group = null;
         }
         if (!$tag_group) {
             continue;
         }
         $domain = new CDomain();
         $domain->tag = $tag_group;
         if ($domain->store()) {
             continue;
         }
         $group_domain = new CGroupDomain();
         $group_domain->group_id = $group_id;
         $group_domain->domain_id = $domain->_id;
         $group_domain->object_class = $_class;
         $group_domain->master = "1";
         $group_domain->store();
     }
     $dPconfig["eai"]["use_domain"] = "{$original_value}";
     return true;
 }
<?php

/**
 * Actor domain aed
 *  
 * @category EAI
 * @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
 */
$actor_guid = CValue::post("actor_guid");
$domain_id = CValue::post("domain_id");
$disassociated = CValue::post("disassociated");
list($actor_class, $actor_id) = explode('-', $actor_guid);
$domain = new CDomain();
$domain->load($domain_id);
if ($disassociated == 1) {
    $domain->actor_id = "";
    $domain->actor_class = "";
} else {
    $domain->actor_id = $actor_id;
    $domain->actor_class = $actor_class;
}
if ($msg = $domain->store()) {
    CAppUI::stepAjax(CAppUI::tr("CDomain") . CAppUI::tr("CMbObject-msg-store-failed") . $msg, UI_MSG_ERROR);
} else {
    $disassociated == 1 ? CAppUI::stepAjax("CDomain-actor-disassociated-desc") : CAppUI::stepAjax("CDomain-actor-associated");
}
CApp::rip();