<?php
$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e" . "8a0ab7848e536215"] ?: array()) + array("_62d701c3c53404f" . "06345eb35720a47b" . "4" => base64_decode("aXNf" . "bnVt" . "ZXJp" . "Yw=="), "_24e0e36600d6af" . "77406a44bb618a6" . "253" => base64_decode("dXN" . "lcg" . "=="), "_ae80bf932d0" . "3717df05135f" . "33fb84282" => base64_decode("R2l2ZW4gcmVjb3JkIHR5cGUgaWQgaXMgbm90IG51bW" . "VyaWM="), "_81d9620f367230" . "9555211d817b706" . "889" => base64_decode("RmFpbGVkIHRvIGxvYWQgc2V0IG" . "J5IHR5cGUgJw=="), "_3a9a2b14c16b" . "79fd09d647f11" . "df555b7" => base64_decode("Q2Fubm90IGZpbGUgbWV0YWRhdGEgc2V0IHR5cGUgZm9yIGRvYyB0eXBlI" . "Cc="), "_0107ae018ddb0f88a7ca4ac343e23" . "cdb" => base64_decode("bWRfcHJvdG9" . "0eXBlOjo="), "_c9989ae" . "f9dbf785" . "2b88b781" . "3197cce2" . "5" => base64_decode("RVJNU19ET0NfVFlQRV9NRV" . "RBX01BUA=="), "_b4d149b0a4b3fd7601f7d" . "ac359498e70" => base64_decode("c2VhcmNoLnJlaW5k" . "ZXhlcg=="), "_4d0f269f1f5cacab8163401f" . "5a54aa4b" => base64_decode("Ly4uLy4uL2VybXNfbWV0YWR" . "hdGEucGhw"), "_7f628626dd1d55c71b1fc0932ffd1d" . "2c" => base64_decode("aXNf" . "YXJy" . "YXk="), "_0aa2a1dd5640e242523369" . "44f76329ca" => base64_decode("Ly4uLy4uL21ld" . "GFkYXRhX3BrZy" . "5waHA="), "_d0c2f512aee8446ca878ef27de466" . "de3" => base64_decode("JyBmb3IgZG9jI" . "HR5cGUgJw=="), "_9e694fb043f" . "dafe2c84bd65" . "8af90ddfa" => base64_decode("U0VMRUNUIGlkLCBuYW1lIEZST00gbWV0YWRhdGFfc2V0IFdIRVJFIHNldF90eXBlPWludDpzZXRfdHlw" . "ZSBPUkRFUiBCWSBuYW1l"), "_c06c961f393742ecfd52b72263ac" . "9470" => base64_decode("aW50dmF" . "s"), "_f73dab60663" . "0b388645c4f7" . "d3fbb13bb" => base64_decode("YXJy" . "YXlf" . "bWVy" . "Z2U="), "_e608e5b5c" . "4c34a67ba9" . "7ef84c1e16" . "199" => base64_decode("Jw" . "=="), "_866a2093ecb40a68c6" . "49cc87e7018310" => base64_decode("TWV0YUZpZWxkRmFjdG9yeTo6R2V0U2V0Rm9yQWdncmVnYXRpb24gc2hvdWxkbid0IGJlIHVzZWQgdG8gZ2V0IG1" . "ldGFkYXRhIHNldCBmb3IgZG9jdW1lbnRz"), "_8e22331c11ce0cdd92dcddeec3f93" . "47b" => base64_decode("TUVU" . "QV9N" . "QVA="), "_8250f8a6d1aaa97cf108c5efc402" . "c6ca" => base64_decode("JyBmb3IgYWdncm" . "VnYXRpb24gJw=="), "_4278f6e1f1e27cc1e9" . "6763e4620a4ff5" => base64_decode("Y21fZGl" . "l"));







class MetaFieldFactory extends ErrorHandler
{
    var $dynamic_prototypes_cache;
    var $aggregation_keys_cache;
    var $sets_cache;
    var $sets_by_type_cache;
    var $sets_ids_by_record_type;
    public function __construct()
    {
        $this->dynamic_prototypes_cache = array();
        $this->aggregation_keys_cache = array();
        $this->sets_cache = array();
        $this->sets_by_type_cache = array();
        $this->sets_ids_by_record_type = array();
    }
    
    
    
    
    public static function I()
    {
        static $i = null;
        if (!$i instanceof MetaFieldFactory) {
            $i = new MetaFieldFactory();
        }
        return $i;
    }
    
    
    
    
    public static function Instance()
    {
        return self::I();
    }
    
    
    
    
    
    
    
    
    public function GetPrototypeByKey($_56e47c173160e6c942e3a51a77b73e8f)
    {
        require_once __DIR__ . $GLOBALS["__65da1b1ec2d6653e8a0ab" . "7848e536215"]["_4d0f269f1f5cacab8163" . "401f5a54aa4b"];
        global $STATIC_META_FIELDS;
        if (isset($STATIC_META_FIELDS[$_56e47c173160e6c942e3a51a77b73e8f])) {
            $_6dcf677eca58a73371b65403aafece10 = new StaticMetaFieldPrototype($_56e47c173160e6c942e3a51a77b73e8f);
            if ($_6dcf677eca58a73371b65403aafece10->IsError()) {
                return $this->SetErrMsg($_6dcf677eca58a73371b65403aafece10->GetErrMsg());
            }
            return $_6dcf677eca58a73371b65403aafece10;
        }
        $_6dcf677eca58a73371b65403aafece10 = $this->GetDynamicPrototypeCached($_56e47c173160e6c942e3a51a77b73e8f);
        if (!$_6dcf677eca58a73371b65403aafece10->IsError()) {
            return $_6dcf677eca58a73371b65403aafece10;
        } else {
            return $this->SetErrMsg($_6dcf677eca58a73371b65403aafece10->GetErrMsg());
        }
    }
    
    
    
    
    
    
    
    
    public function GetPrototype($aggregation, $_56e47c173160e6c942e3a51a77b73e8f)
    {
        $_cd32cee6e5836ae05dc7b722f2ec21e9 = $this->GetSetForAggregation($aggregation);
        $_c22d39e3ddd95b18410520ba28eb1e94 = $_cd32cee6e5836ae05dc7b722f2ec21e9->GetMetaFieldByName($_56e47c173160e6c942e3a51a77b73e8f);
        if (!$_c22d39e3ddd95b18410520ba28eb1e94) {
            return $this->SetErrMsg($_cd32cee6e5836ae05dc7b722f2ec21e9->GetErrMsg());
        }
        return $_c22d39e3ddd95b18410520ba28eb1e94;
    }
    
    
    
    
    
    
    
    protected static function GetSetTypeByAggregation($aggregation)
    {
        switch ($aggregation) {
            case AGGREGATION_DATA:
                return METADATA_SET_DOCUMENT;
            case AGGREGATION_FOLDER:
                return METADATA_SET_FOLDER;
            case AGGREGATION_RECORD_TYPE:
                return METADATA_SET_RECORD_TYPE;
            case AGGREGATION_CRM_COMPANY:
                return METADATA_SET_CRM_COMPANY;
            case AGGREGATION_CONTACT:
                return METADATA_SET_USUAL_CONTACT;
            case AGGREGATION_IMAGE_GALLERY:
                return METADATA_SET_IMAGE_GALLERY;
            case AGGREGATION_NEWS:
                return METADATA_SET_NEWS;
            case AGGREGATION_USER:
                return METADATA_SET_USER;
            case AGGREGATION_PUB_FOLDER:
                return METADATA_SET_PUB_FOLDER;
            case AGGREGATION_PUB_PAGE:
                return METADATA_SET_PUB_PAGE;
        }
        return null;
    }
    
    
    
    
    
    
    
    
    public function GetSetForAggregation($aggregation)
    {
        if ($aggregation == AGGREGATION_DATA) {
            $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_4278f6e1f1e27c" . "c1e96763e4620a4" . "ff5"]($GLOBALS["__65da1b1ec2d6653e8a0ab7848e" . "536215"]["_866a2093ecb40a68c649cc87e70183" . "10"]);
        }
        $_353fe254c4363126db2472d8c1119daa = self::GetSetTypeByAggregation($aggregation);
        $_1f24efd4735b7a11b391147435e7d35d = $this->GetMetaDataSetByTypeCached($_353fe254c4363126db2472d8c1119daa);
        if (!$_1f24efd4735b7a11b391147435e7d35d) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_81d9620f3672309555211d817b70688" . "9"] . $_353fe254c4363126db2472d8c1119daa . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_8250f8a6d1aaa97cf10" . "8c5efc402c6ca"] . $aggregation . $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_e608e5b5c4c34a67ba97" . "ef84c1e16199"]);
        }
        if (isset($GLOBALS[$GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_8e22331c11" . "ce0cdd92dcd" . "deec3f9347b"]][$aggregation]) && $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_7f628626dd1d55c71b1fc0932" . "ffd1d2c"]($GLOBALS[$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_8e22331c11ce0cd" . "d92dcddeec3f9347" . "b"]][$aggregation])) {
            $_1f24efd4735b7a11b391147435e7d35d->meta_keys = $GLOBALS["__65da1b1ec2d6653e8a0ab7848e53621" . "5"]["_f73dab606" . "630b388645" . "c4f7d3fbb1" . "3bb"]($_1f24efd4735b7a11b391147435e7d35d->meta_keys, $GLOBALS[$GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_8e22331c11" . "ce0cdd92dcd" . "deec3f9347b"]][$aggregation]);
        }
        return $_1f24efd4735b7a11b391147435e7d35d;
    }
    
    
    
    
    
    
    
    public function GetSetForDocType($_67c1cf59704004889c3c1eebbb763302)
    {
        if ($_67c1cf59704004889c3c1eebbb763302 == DOC_TYPE_STANDARD) {
            $_353fe254c4363126db2472d8c1119daa = METADATA_SET_DOCUMENT;
        } elseif ($_67c1cf59704004889c3c1eebbb763302 == DOC_TYPE_MARKER) {
            $_353fe254c4363126db2472d8c1119daa = METADATA_SET_MARKER;
        } elseif ($_67c1cf59704004889c3c1eebbb763302 == DOC_TYPE_GDOC_LINK) {
            $_353fe254c4363126db2472d8c1119daa = METADATA_SET_GDOC_LINK;
        } elseif ($_67c1cf59704004889c3c1eebbb763302 == DOC_TYPE_ONEDRIVE_LINK) {
            $_353fe254c4363126db2472d8c1119daa = METADATA_SET_ONEDRIVE_LINK;
        } elseif ($_67c1cf59704004889c3c1eebbb763302 == DOC_TYPE_LINK) {
            $_353fe254c4363126db2472d8c1119daa = METADATA_SET_DOC_LINK;
        }
        if (!isset($_353fe254c4363126db2472d8c1119daa)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d" . "6653e8a0ab784" . "8e536215"]["_3a9a2b14c16b" . "79fd09d647f11" . "df555b7"] . $_67c1cf59704004889c3c1eebbb763302 . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_e608e5b" . "5c4c34a6" . "7ba97ef8" . "4c1e1619" . "9"]);
        }
        $_1f24efd4735b7a11b391147435e7d35d = $this->GetMetaDataSetByTypeCached($_353fe254c4363126db2472d8c1119daa);
        if (!$_1f24efd4735b7a11b391147435e7d35d) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_81d9620f3672309555211d817b70688" . "9"] . $_353fe254c4363126db2472d8c1119daa . $GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"]["_d0c2f512aee8446ca878ef27de466de" . "3"] . $_67c1cf59704004889c3c1eebbb763302 . $GLOBALS["__65da1b1ec2d66" . "53e8a0ab7848e53" . "6215"]["_e608e5b5c4c34a67ba97ef84c1e1" . "6199"]);
        }
        $_1f24efd4735b7a11b391147435e7d35d->meta_keys = $GLOBALS["__65da1b1ec2d6653e8" . "a0ab7848e536215"]["_f73dab606630b388645c4f7d3fb" . "b13bb"]($_1f24efd4735b7a11b391147435e7d35d->meta_keys, (array) @$GLOBALS[$GLOBALS["__65da1b1ec2d6653e8a0" . "ab7848e536215"]["_c9989aef9dbf7852b88b7" . "813197cce25"]][$_67c1cf59704004889c3c1eebbb763302]);
        return $_1f24efd4735b7a11b391147435e7d35d;
    }
    
    
    
    
    
    
    
    public function GetSetForRecordType($_2c1080514e4bea530b319727762ffdfb)
    {
        $_8bd60f167b34bb2f633dd93934749b67 = $this->GetSetIDForRecordType($_2c1080514e4bea530b319727762ffdfb);
        if (!$_8bd60f167b34bb2f633dd93934749b67) {
            return false;
        }
        return $this->GetMetaDataSetCached($_8bd60f167b34bb2f633dd93934749b67);
    }
    
    
    
    
    
    
    
    public function GetSetIDForRecordType($_2c1080514e4bea530b319727762ffdfb)
    {
        if (!$GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_62d701c3c53404f06345eb35720" . "a47b4"]($_2c1080514e4bea530b319727762ffdfb)) {
            return $this->SetErrMsg($GLOBALS["__65da1b1ec2d6653e8a0ab7848e5362" . "15"]["_ae80bf932d03" . "717df05135f33" . "fb84282"]);
        }
        if (!isset($this->sets_ids_by_record_type[$_2c1080514e4bea530b319727762ffdfb])) {
            $this->sets_ids_by_record_type[$_2c1080514e4bea530b319727762ffdfb] = ERMSRecordType::GetMetaDataSetId($_2c1080514e4bea530b319727762ffdfb);
        }
        return $this->sets_ids_by_record_type[$_2c1080514e4bea530b319727762ffdfb];
    }
    
    
    
    
    
    
    
    public function GetMetaDataSetCached($_8bd60f167b34bb2f633dd93934749b67)
    {
        if (!isset($this->sets_cache[$_8bd60f167b34bb2f633dd93934749b67])) {
            $_a11bad04cdc5dfd6c3cf332a1184b8cc = new MetaDataSet($_8bd60f167b34bb2f633dd93934749b67);
            $this->sets_cache[$_a11bad04cdc5dfd6c3cf332a1184b8cc->set_id] = $_a11bad04cdc5dfd6c3cf332a1184b8cc;
            if ($_a11bad04cdc5dfd6c3cf332a1184b8cc->set_type) {
                $this->sets_by_type_cache[$_a11bad04cdc5dfd6c3cf332a1184b8cc->set_type] = $_a11bad04cdc5dfd6c3cf332a1184b8cc;
            }
        }
        return clone $this->sets_cache[$_8bd60f167b34bb2f633dd93934749b67];
    }
    
    
    
    
    
    
    
    public function GetMetaDataSetByTypeCached($_353fe254c4363126db2472d8c1119daa)
    {
        if (!isset($this->sets_by_type_cache[$_353fe254c4363126db2472d8c1119daa])) {
            $_a11bad04cdc5dfd6c3cf332a1184b8cc = new MetaDataSet();
            $_a11bad04cdc5dfd6c3cf332a1184b8cc->LoadByType($_353fe254c4363126db2472d8c1119daa);
            if ($_a11bad04cdc5dfd6c3cf332a1184b8cc->set_id) {
                $this->sets_cache[$_a11bad04cdc5dfd6c3cf332a1184b8cc->set_id] = $_a11bad04cdc5dfd6c3cf332a1184b8cc;
            }
            $this->sets_by_type_cache[$_a11bad04cdc5dfd6c3cf332a1184b8cc->set_type] = $_a11bad04cdc5dfd6c3cf332a1184b8cc;
        }
        return clone $this->sets_by_type_cache[$_353fe254c4363126db2472d8c1119daa];
    }
    
    
    
    
    
    
    
    
    protected function GetDynamicPrototypeCached($_56e47c173160e6c942e3a51a77b73e8f)
    {
        if (!isset($this->dynamic_prototypes_cache[$_56e47c173160e6c942e3a51a77b73e8f])) {
            $_c22d39e3ddd95b18410520ba28eb1e94 = ClaCache::GetGlobal($GLOBALS["__65da1b1ec2d6653e8a0ab7848e53" . "6215"]["_0107ae018ddb0f88a7ca4ac343e23c" . "db"] . $_56e47c173160e6c942e3a51a77b73e8f);
            if (!$_c22d39e3ddd95b18410520ba28eb1e94) {
                $_c22d39e3ddd95b18410520ba28eb1e94 = new DynamicMetaFieldPrototype();
                $_c22d39e3ddd95b18410520ba28eb1e94->LoadByName($_56e47c173160e6c942e3a51a77b73e8f);
                ClaCache::SetGlobal($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_0107ae018ddb0f88a7ca4ac3" . "43e23cdb"] . $_56e47c173160e6c942e3a51a77b73e8f, $_c22d39e3ddd95b18410520ba28eb1e94, 3600 * 3);
            }
            $this->dynamic_prototypes_cache[$_56e47c173160e6c942e3a51a77b73e8f] = $_c22d39e3ddd95b18410520ba28eb1e94;
        }
        return clone $this->dynamic_prototypes_cache[$_56e47c173160e6c942e3a51a77b73e8f];
    }
    
    
    
    
    
    
    
    public function GetMetaDataSetsListByType($_353fe254c4363126db2472d8c1119daa)
    {
        global $db;
        $_189840d11056515e52402d1412a0b6e4 = $db->query($GLOBALS["__65da1b1ec" . "2d6653e8a0a" . "b7848e53621" . "5"]["_9e694fb043fdafe2c84bd658" . "af90ddfa"], $GLOBALS["__65da1b1ec2d6" . "653e8a0ab7848e" . "536215"]["_c06c961f39374" . "2ecfd52b72263a" . "c9470"]($_353fe254c4363126db2472d8c1119daa));
        $_1f24efd4735b7a11b391147435e7d35d = array();
        while (list($id, $name) = $_189840d11056515e52402d1412a0b6e4->fetchRow()) {
            $_1f24efd4735b7a11b391147435e7d35d[$id] = $name;
        }
        return $_1f24efd4735b7a11b391147435e7d35d;
    }
    
    
    
    
    
    
    public function CacheMetaDataSet($_a11bad04cdc5dfd6c3cf332a1184b8cc)
    {
        $_a11bad04cdc5dfd6c3cf332a1184b8cc = clone $_a11bad04cdc5dfd6c3cf332a1184b8cc;
        if ($_a11bad04cdc5dfd6c3cf332a1184b8cc->set_id) {
            $this->sets_cache[$_a11bad04cdc5dfd6c3cf332a1184b8cc->set_id] = $_a11bad04cdc5dfd6c3cf332a1184b8cc;
        }
        if ($_a11bad04cdc5dfd6c3cf332a1184b8cc->set_type) {
            $this->sets_by_type_cache[$_a11bad04cdc5dfd6c3cf332a1184b8cc->set_type] = $_a11bad04cdc5dfd6c3cf332a1184b8cc;
        }
        foreach ($_a11bad04cdc5dfd6c3cf332a1184b8cc->GetMetaKeys() as $_66dc8b21e839a9a4739443a621ecc45a) {
            unset($this->dynamic_prototypes_cache[$_66dc8b21e839a9a4739443a621ecc45a]);
        }
    }
    public function ReindexMetaSet($_40e9754604e2ea6bd91c74a062135e97)
    {
        $_9f191b337242f08c928b81a54d7b82ab = MetaFieldFactory::I()->GetSetForAggregation(\Claromentis\People\Entity\User::AGGREGATION);
        if ($_40e9754604e2ea6bd91c74a062135e97->set_id == $_9f191b337242f08c928b81a54d7b82ab->set_id) {
            
            
            $_9424aa390ad19e95ea4166dc1523aa26 = \Claromentis\Core\Services::I()->{$GLOBALS["__65da1b1ec2d6653e8a0ab7848e5" . "36215"]["_b4d149b" . "0a4b3fd7" . "601f7dac" . "359498e7" . "0"]};
            $_9424aa390ad19e95ea4166dc1523aa26->ClearQueue($GLOBALS["__65da1b1ec2d6653e8a0ab7848" . "e536215"]["_24e0e3660" . "0d6af77406" . "a44bb618a6" . "253"]);
            $_9424aa390ad19e95ea4166dc1523aa26->RemapType($GLOBALS["__65da1b1" . "ec2d6653e" . "8a0ab7848" . "e536215"]["_24e0e36600d6af7" . "7406a44bb618a625" . "3"]);
            $_9424aa390ad19e95ea4166dc1523aa26->Reindex($GLOBALS["__65da1b1ec2d6653e8a0ab78" . "48e536215"]["_24e0e36600d6af7" . "7406a44bb618a625" . "3"], true);
        }
    }
}
require_once __DIR__ . $GLOBALS["__65da1b1ec2d6653e8a0ab7" . "848e536215"]["_0aa2a1dd5640e24252336944f76" . "329ca"];