exists() публичный Метод

Return timestamp and TTL of cache entry or FALSE if not found
public exists ( $key, &$val = NULL ) : array | FALSE
$key string
$val mixed
Результат array | FALSE
 public function testExistsNoToString()
 {
     $object = new CacheTestNoToSTring();
     $cache = new Cache();
     $this->setExpectedException('PHPUnit_Framework_Error');
     $cache->exists($object);
 }
Пример #2
0
 /**
  * 
  * @param $model
  * @param $serviceClass
  * @return Model
  */
 public static function load($model, $path = null)
 {
     global $redirectedPackage;
     $modelName = (substr($model, 0, 1) == "." ? $redirectedPackage : "") . $model;
     if (!isset(Model::$instances[$modelName])) {
         if (!Cache::exists("model_{$modelName}")) {
             Model::$instances[$modelName] = Cache::add("model_{$modelName}", Model::loadModelClass($model, $path));
         } else {
             add_include_path(Cache::get("model_path_{$modelName}"), false);
             Model::$instances[$modelName] = Cache::get("model_{$modelName}");
         }
     }
     return Model::$instances[$modelName];
 }
Пример #3
0
 /**
  * Get object tag
  *
  * @param string $group_id Group
  *
  * @return string|null
  */
 static function getObjectTag($group_id = null)
 {
     // Recherche de l'établissement
     $group = CGroups::get($group_id);
     if (!$group_id) {
         $group_id = $group->_id;
     }
     $cache = new Cache(__METHOD__, array($group_id), Cache::INNER);
     if ($cache->exists()) {
         return $cache->get();
     }
     $tag = self::getDynamicTag();
     return $cache->put(str_replace('$g', $group_id, $tag));
 }
Пример #4
0
 /**
  * Chargement de a liste des dents disponibles
  *
  * @return self[] Liste des dents
  */
 static function loadList()
 {
     $cache = new Cache(__METHOD__, func_get_args(), Cache::INNER_OUTER);
     if ($cache->exists()) {
         return $cache->get();
     }
     $ds = self::getSpec()->ds;
     $query = "SELECT t_localisationdents.*\n      FROM t_localisationdents\n      ORDER BY t_localisationdents.LOCDENT ASC,\n        t_localisationdents.DATEFIN ASC";
     $result = $ds->exec($query);
     $listDents = array();
     while ($row = $ds->fetchArray($result)) {
         $dent = new CDentCCAM();
         $dent->map($row);
         $dent->loadLibelle();
         $listDents[$row["DATEFIN"]][] = $dent;
     }
     return $cache->put($listDents);
 }
 /**
  * Is HTML-caching enabled (either globally or for $url)?
  * 
  * @param string  $url  URL to check specifically for
  * @return bool
  */
 public function isEnabled($url)
 {
     // check to see if html-caching is on
     $global_enable = (bool) $this->fetchConfig('enable', false, null, true);
     if (!$global_enable || !Cache::exists()) {
         return false;
     }
     // check that the URL being requested is a content file
     $data = ContentService::getContent($this->removeQueryString($url));
     // not a content file, not enabled
     if (!$data) {
         return false;
     }
     // check for exclude on the current page
     $exclude_raw = $this->fetchConfig('exclude');
     // if excludes were set
     if ($exclude_raw) {
         $excluded = Parse::pipeList($exclude_raw);
         // loop through excluded options
         foreach ($excluded as $exclude) {
             // account for non-/-starting locations
             $this_url = substr($exclude, 0, 1) !== "/" ? ltrim($url, '/') : $url;
             if ($exclude === "*" || $exclude === "/*") {
                 // exclude all
                 return false;
             } elseif (substr($exclude, -1) === "*") {
                 // wildcard check
                 if (strpos($this_url, substr($exclude, 0, -1)) === 0) {
                     return false;
                 }
             } else {
                 // plain check
                 if ($exclude == $this_url) {
                     return false;
                 }
             }
         }
     }
     // all is well, return true
     return true;
 }
Пример #6
0
 /**
  * Récupère le contenu d'une page ou le contenu d'un fichier de cache
  * @param string $url URL de la page
  * @return array Contenu + timestamp de la page $url
  */
 public static function get($url)
 {
     $datas = new stdClass();
     $fileName = '/' . preg_replace('/https?:\\/\\//', '', $url);
     curl_setopt(self::$ch, CURLOPT_URL, $url);
     // On check si le fichier n'existe pas ou s'il a expiré
     if (!Cache::exists($fileName) || Cache::hasExpired($fileName)) {
         $datas->url = $url;
         $datas->timestamp = time();
         $datas->content = curl_exec(self::$ch);
         $datas->info = curl_getinfo(self::$ch);
         $datas->httpCode = $datas->info['http_code'];
         $datas->error = curl_error(self::$ch);
         $datas->errno = curl_errno(self::$ch);
         Cache::set($fileName, serialize($datas));
         $datas->content = json_decode($datas->content);
     }
     // Si on a déjà un cache de dispo
     if (empty((array) $datas)) {
         $datas = Cache::get($fileName);
         $datas->content = json_decode($datas->content);
     }
     return $datas;
 }
 public function lookupEpisode($seriesid, $show)
 {
     //http://www.thetvdb.com/api/5F84ECB91B42D719/series/78804/default/1/1
     $season = ltrim(str_replace('S', '', $show['season']), '0');
     $ep = ltrim(str_replace('E', '', $show['episode']), '0');
     $cache = new Cache();
     $apiresponse = false;
     $url = $this->MIRROR . '/api/' . self::APIKEY . '/series/' . $seriesid . '/default/' . $season . "/" . $ep;
     if ($cache->exists($url)) {
         $apiresponse = $cache->fetch($url);
     }
     if (!$apiresponse) {
         $apiresponse = getUrl($url);
     }
     if ($apiresponse) {
         $TheTVDBAPIXML = @simplexml_load_string($apiresponse);
         if (!$TheTVDBAPIXML) {
             return false;
         }
         $cache->store($url, $apiresponse);
         return array('id' => (string) $TheTVDBAPIXML->Episode->id, 'summary' => (string) $TheTVDBAPIXML->Episode->Overview, 'name' => (string) $TheTVDBAPIXML->Episode->EpisodeName, 'director' => (string) $TheTVDBAPIXML->Episode->Director, 'epabsolute' => (string) $TheTVDBAPIXML->Episode->absolute_number, 'writer' => (string) $TheTVDBAPIXML->Episode->Writer, 'gueststars' => (string) $TheTVDBAPIXML->Episode->GuestStars, 'rating' => (int) $TheTVDBAPIXML->Episode->Rating, 'airdate' => (string) $TheTVDBAPIXML->Episode->FirstAired, 'season' => $season, 'number' => (string) $TheTVDBAPIXML->Episode->EpisodeNumber);
     }
     return false;
 }
Пример #8
0
function api_fetch($part, $ttl = false)
{
    $f3 = \Base::instance();
    $url = $f3->get("_api_url");
    $url = $url . "/api/" . $part;
    $apiHits = $f3->get("_api_hits");
    $apiHits[] = $url;
    $f3->set("_api_hits", $apiHits);
    $key = md5($url);
    $cache = new \Cache($key);
    //test_array($url);
    if ($cache->exists($key) && $ttl) {
        $data = json_decode($cache->get($key), true);
    } else {
        $web = new \Web();
        $data = $web->request($url);
        $data = json_decode($data['body'], true);
        $ddata = json_encode($data);
        $cache->set($key, $ddata, $ttl);
    }
    //test_array($data);
    //$url = substr($url,strpos($url,"."));
    return $data;
}
Пример #9
0
 /**
  * 
  * @param $model
  * @param $serviceClass
  * @return Model
  */
 public static function load($model, $path = null, $cached = true)
 {
     global $redirectedPackage;
     global $packageSchema;
     $modelName = (substr($model, 0, 1) == "." ? $redirectedPackage : "") . $model;
     if (!isset(Model::$instances[$modelName])) {
         if ($cached && CACHE_MODELS) {
             if (!Cache::exists("model_{$modelName}")) {
                 Model::$instances[$modelName] = Cache::add("model_{$modelName}", Model::_load($model, $path));
             } else {
                 add_include_path(Cache::get("model_path_{$modelName}"), false);
                 $modelInstance = Cache::get("model_{$modelName}");
                 if ($redirectedPackage == '') {
                     $redirectedPackage = $modelInstance->redirectedPackage;
                     $packageSchema = $modelInstance->packageSchema;
                 }
                 Model::$instances[$modelName] = $modelInstance;
             }
         } else {
             Model::$instances[$modelName] = Model::_load($model, $path);
         }
     }
     return Model::$instances[$modelName];
 }
Пример #10
0
 /**
  * Query the indexer directly.  Returns an array of the results, unless
  * there was an error in which case ``false`` is returned.  However, if
  * Sphinx returns an "invalid query" error (1064), then an empty result
  * array is returned.  Note that an empty "result array" is not the same as
  * an empty array and will instead look like::
  *
  *      array({"_totalrows": 0})
  *
  * If  ``$lookupQuery`` is an empty string, then the results returned will
  * be the data from the index--this is not guaranteed to be the most recent
  * data that is in the MySQL database.  If you absolutely need the most
  * recent data from MySQL, then ``$lookupQuery`` should be a valid SQL
  * query that has contains "releases.ID IN (%s)".
  *
  * @param   string      $sphinxQuery    The raw SphinxQL query.
  * @param   string      $lookupQuery    The SQL to use to lookup the results.
  * @param   bool/int    $useCache    	The ttl to store the item in the cache.
  * @return  array|false
  */
 public function searchDirect($sphinxQuery, $lookupQuery = "", $useCache = false)
 {
     $cache = new Cache();
     if ($useCache !== false && $cache->enabled && $cache->exists($sphinxQuery)) {
         $ret = $cache->fetch($sphinxQuery);
         if ($ret !== false) {
             return $ret;
         }
     }
     // Connect to Sphinx
     $hostport = explode(":", $this->site->sphinxserverhost);
     $sdb = mysqli_connect($hostport[0], "root", "", "", $hostport[1]);
     if (!$sdb) {
         // Couldn't connect to Sphinx.
         return false;
     }
     // Get the results from Sphinx.
     $lev = error_reporting();
     error_reporting(0);
     $result = mysqli_query($sdb, $sphinxQuery);
     error_reporting($lev);
     $error = mysqli_error($sdb);
     // A 1064 error means that the query is invalid, so we don't care
     // about that.
     if ($error && mysqli_errno($sdb) != 1064) {
         // All other errors we will considered a failure.
         return false;
     }
     // Get the query metadata.
     $meta = array();
     $mresult = mysqli_query($sdb, "SHOW META");
     if (!$mresult) {
         return false;
     }
     while ($row = mysqli_fetch_row($mresult)) {
         $meta[$row[0]] = $row[1];
     }
     $results = array();
     if ($result) {
         while ($row = mysqli_fetch_assoc($result)) {
             if ($lookupQuery) {
                 // Save the IDs for a batch lookup.
                 $results[] = $row["id"];
             } else {
                 $results[] = $row;
             }
         }
     }
     if ($lookupQuery && count($results) > 0) {
         $ndb = new DB();
         $sql = sprintf($lookupQuery, implode(",", $results));
         $result = $ndb->queryDirect($sql);
         if ($result) {
             $results = array();
             while ($row = $ndb->getAssocArray($result)) {
                 $results[] = $row;
             }
         }
     }
     $count = 0;
     if (count($results) > 0 && array_key_exists("total", $meta)) {
         $count = (int) $meta["total_found"];
         $results[0]["_totalrows"] = $count > MAX_MATCHES ? MAX_MATCHES : $count;
     }
     if ($useCache !== false && $cache->enabled) {
         $cache->store($sphinxQuery, $results, $useCache);
     }
     return $results;
 }
Пример #11
0
 public function fetchCache($key)
 {
     $cache = new Cache();
     if ($cache->enabled && $cache->exists($key)) {
         $ret = $cache->fetch($key);
         if ($ret !== false) {
             return $ret;
         }
     }
     return false;
 }
Пример #12
0
 /**
  * Chargement optimisé des codes CCAM
  *
  * @param string $code Code CCAM
  * @param int    $niv  Niveau du chargement
  *
  * @return COldCodeCCAM
  */
 static function get($code, $niv = self::MEDIUM)
 {
     $cache = new Cache(__METHOD__, func_get_args(), Cache::INNER_OUTER);
     if ($cache->exists()) {
         return $cache->get();
     }
     // Chargement
     $code_ccam = new COldCodeCCAM($code);
     $code_ccam->load($niv);
     return $cache->put($code_ccam, true);
 }
 /**
  * Inform whether formerly cached value of caller fonction is available
  *
  * @param array $context Context as (methode name, array of params)
  *
  * @return bool
  * @deprecated Use Cache::exists() non-static method instead
  */
 static function exist($context)
 {
     list($function, $args) = $context;
     $cache = new Cache($function, $args, Cache::INNER);
     return $cache->exists();
 }
Пример #14
0
include_once "{$lib}/share/link.php";
include_once "{$lib}/share/stdio.php";
include_once "{$lib}/share/string.php";
pieLoadLocale();
pieHead();
$_REQUEST['limit'] = intval(@$_REQUEST['limit']);
if ($_REQUEST['limit'] < 1) {
    $_REQUEST['limit'] = 10;
}
if ($_REQUEST['limit'] > 100) {
    $_REQUEST['limit'] = 100;
}
$page = new Page();
$cache = new Cache();
$cid = $cache->key('latest', array());
if ($GLOBALS['pie']['query_caching'] && $cache->exists($cid)) {
    // Use existing cache.
    $dump = trim(file_get_contents($cache->file($cid)));
    $cache->update($cid);
    $dump = explode("\n", $dump);
    $data = array();
    foreach ($dump as $i) {
        $data[] = $i;
    }
} else {
    // Determine latest page changes.
    $data = array();
    for ($name = $page->first(); $name; $name = $page->next()) {
        $data[] = $page->stamp . "\t{$name}";
    }
    rsort($data);
Пример #15
0
 /**
  * @covers RyzomExtra\Cache::set
  * @covers RyzomExtra\Cache::expired
  */
 public function testDoesNotExpire()
 {
     $key = 'test-does-not-expire';
     $cache = new Cache($this->cachePath);
     $this->assertFalse($cache->exists($key), 'Cache file was found');
     $cache->set($key, '1234');
     $this->assertTrue($cache->exists($key), 'Cache file was not created');
     $this->assertFalse($cache->expired($key));
 }
Пример #16
0
 /**
  * Perform a single query
  *
  * @param string $query
  * @param bool $useCache
  * @param string|int $cacheTTL
  * @return bool|array
  */
 public function query($query, $useCache = false, $cacheTTL = '')
 {
     if ($query == "") {
         return false;
     }
     if ($useCache) {
         $cache = new Cache();
         if ($cache->enabled && $cache->exists($query)) {
             $ret = $cache->fetch($query);
             if ($ret !== false) {
                 return $ret;
             }
         }
     }
     $result = self::$instance->query($query)->fetchAll();
     if ($result === false || $result === true) {
         return array();
     }
     if ($useCache) {
         if ($cache->enabled) {
             $cache->store($query, $result, $cacheTTL);
         }
     }
     return $result;
 }
Пример #17
0
        }
        $total++;
    }
    // Walk directory for the second time. This time, encountered
    // files (and pages contained therein) are imported for real.
    rewinddir($dh);
    while (($file = readdir($dh)) !== false) {
        if ($file == "." || $file == "..") {
            continue;
        }
        if (!importFile($_REQUEST['path'] . "/{$file}")) {
            pieError("ImportError", array('page' => htmlspecialchars($file)));
        }
        $count++;
    }
} elseif (is_readable($_REQUEST['path'])) {
    // Just one file is to be imported.
    if (!importFile($_REQUEST['path'])) {
        pieError("ImportError", array('page' => htmlspecialchars($_REQUEST['path'])));
    }
    $total = 1;
    $count = 1;
}
// Update the cache.
$cache = new Cache();
if ($cache->exists($cache->key('latest', array()))) {
    $cache->delete($cache->key('latest', array()));
}
pieLog("alter");
pieNotice("ImportSuccess", array('total' => $total, 'count' => $count));
pieTail();
 public function saveCache()
 {
     if (Cache::enabled()) {
         if (!Cache::exists(self::CLIENT_ORACLE_CACHE)) {
             Cache::set(self::CLIENT_ORACLE_CACHE, $this->clientOracleCache);
         }
     }
 }
 /**
  * Get the exchange source
  *
  * @param string $name         Nom
  * @param string $type         Type de la source (FTP, SOAP, ...)
  * @param bool   $override     Charger les autres sources
  * @param string $type_echange Type de l'échange
  * @param bool   $only_active  Seulement la source active
  *
  * @return CExchangeSource
  */
 static function get($name, $type = null, $override = false, $type_echange = null, $only_active = true)
 {
     $cache = new Cache(__METHOD__, func_get_args(), Cache::INNER);
     if ($cache->exists()) {
         return $cache->get();
     }
     $exchange_classes = self::getExchangeClasses();
     foreach ($exchange_classes as $_class) {
         /** @var CExchangeSource $exchange_source */
         $exchange_source = new $_class();
         if (isset(self::$typeToClass[$type])) {
             $classname = self::$typeToClass[$type];
             if ($classname != $exchange_source->_class) {
                 continue;
             }
         }
         if ($only_active) {
             $exchange_source->active = 1;
         }
         $exchange_source->name = $name;
         $exchange_source->loadMatchingObject();
         if ($exchange_source->_id) {
             $exchange_source->_wanted_type = $type;
             $exchange_source->_allowed_instances = self::getObjects($name, $type, $type_echange);
             if ($exchange_source->role != CAppUI::conf("instance_role")) {
                 if (!$override) {
                     $incompatible_source = new $exchange_source->_class();
                     $incompatible_source->name = $exchange_source->name;
                     $incompatible_source->_incompatible = true;
                     CAppUI::displayAjaxMsg("CExchangeSource-_incompatible", UI_MSG_ERROR);
                     return $incompatible_source;
                 }
                 $exchange_source->_incompatible = true;
             }
             return $cache->put($exchange_source, false);
         }
     }
     $source = new CExchangeSource();
     if (isset(self::$typeToClass[$type])) {
         $source = new self::$typeToClass[$type]();
     }
     $source->name = $name;
     $source->type_echange = $type_echange;
     $source->_wanted_type = $type;
     $source->_allowed_instances = self::getObjects($name, $type, $type_echange);
     return $cache->put($source, false);
 }
Пример #20
0
 /**
  * Get actor tag
  *
  * @param int $group_id Group
  *
  * @return string
  */
 function getTag($group_id = null)
 {
     // Recherche de l'établissement
     $group = CGroups::get($group_id);
     if (!$group_id) {
         $group_id = $group->_id;
     }
     $cache = new Cache(__METHOD__, array($group_id), Cache::INNER);
     if ($cache->exists()) {
         return $cache->get();
     }
     $ljoin["group_domain"] = "`group_domain`.`domain_id` = `domain`.`domain_id`";
     $where = array();
     $where["group_domain.group_id"] = " = '{$group_id}'";
     $where["domain.actor_class"] = " = '{$this->_class}'";
     $where["domain.actor_id"] = " = '{$this->_id}'";
     $domain = new CDomain();
     $domain->loadObject($where, null, null, $ljoin);
     return $cache->put($domain->tag, false);
 }
Пример #21
0
 private static function executeCachedSelectQuery(&$params, $mode)
 {
     $results = false;
     $queryKey = self::getQueryKey($params);
     if (Cache::exists($queryKey)) {
         $query = Cache::get($queryKey);
         if (isset($params['limit'])) {
             $params['bind'][] = $params['limit'];
         }
         if (isset($params['offset'])) {
             $params['bind'][] = $params['offset'];
         }
         $results = Db::boundQuery($query, Db::$defaultDatabase, $params['bind'], $mode, $queryKey);
         $params['cache_key'] = $queryKey;
     } else {
         if (isset($params['filter'])) {
             $params['filter'] = FilterCompiler::compile($params['filter']);
         }
         $params['cache_key'] = $queryKey;
     }
     return $results;
 }
Пример #22
0
 protected static function read_tags_cache()
 {
     return Cache::exists('tags.cache') ? unserialize(Cache::read('tags.cache')) : false;
 }
Пример #23
0
 /**
  * Construit le tag NDA en fonction des variables de configuration
  *
  * @param int    $group_id Permet de charger le NDA pour un établissement donné si non null
  * @param string $type_tag Permet de spécifier le type de tag
  *
  * @return string|void
  */
 static function getTagNDA($group_id = null, $type_tag = "tag_dossier")
 {
     // Recherche de l'établissement
     $group = CGroups::get($group_id);
     if (!$group_id) {
         $group_id = $group->_id;
     }
     $cache = new Cache(__METHOD__, array($group_id, $type_tag), Cache::INNER);
     if ($cache->exists()) {
         return $cache->get();
     }
     // Gestion du tag NDA par son domaine d'identification
     if (CAppUI::conf("eai use_domain")) {
         $tag_NDA = CDomain::getMasterDomain("CSejour", $group_id)->tag;
         if ($type_tag != "tag_dossier") {
             $tag_NDA = CAppUI::conf("dPplanningOp CSejour {$type_tag}") . $tag_NDA;
         }
         return $cache->put($tag_NDA, false);
     }
     $tag_NDA = CAppUI::conf("dPplanningOp CSejour tag_dossier");
     if ($type_tag != "tag_dossier") {
         $tag_NDA = CAppUI::conf("dPplanningOp CSejour {$type_tag}") . $tag_NDA;
     }
     // Si on est dans le cas d'un établissement gérant la numérotation
     $group->loadConfigValues();
     if ($group->_configs["smp_idex_generator"]) {
         $tag_NDA = CAppUI::conf("smp tag_nda");
     }
     // Pas de tag Num dossier
     if (null == $tag_NDA) {
         return $cache->put(null, false);
     }
     // Préférer un identifiant externe de l'établissement
     if ($tag_group_idex = CAppUI::conf("dPplanningOp CSejour tag_dossier_group_idex")) {
         $idex = new CIdSante400();
         $idex->loadLatestFor($group, $tag_group_idex);
         $group_id = $idex->id400;
     }
     return $cache->put(str_replace('$g', $group_id, $tag_NDA), false);
 }
Пример #24
0
 /**
  * Chargement optimisé des codes
  */
 static function get($code, $niv = self::LITE, $lang = self::LANG_FR)
 {
     $cache = new Cache(__METHOD__, func_get_args(), self::$cache_layers);
     if ($cache->exists()) {
         return $cache->get();
     }
     // Chargement
     $code_cim = new CCodeCIM10($code, $niv === self::LITE);
     switch ($niv) {
         case self::LITE:
             $code_cim->loadLite();
             break;
         case self::MEDIUM:
             $code_cim->load();
             break;
         case self::FULL:
             $code_cim->load();
             $code_cim->loadRefs();
     }
     return $cache->put($code_cim, true);
 }
Пример #25
0
} else {
    pieRequireSuperuser();
}
pieHead();
if (@$_REQUEST['page']) {
    // Purge the cache of a single page.
    $_REQUEST['page'] = pieGetOption($_REQUEST['page']);
    $_REQUEST['page'] = pieBeautifyName($_REQUEST['page']);
    if (!$page->isValidName($_REQUEST['page'])) {
        pieError('PageNameInvalid');
    }
    if (!$page->exists($_REQUEST['page'])) {
        pieError('PageNotFound');
    }
    $cid = $cache->key('page', array('page' => $_REQUEST['page']));
    if (!$cache->exists($cid)) {
        pieError('PurgeSuccess');
    }
    if ($cache->delete($cid)) {
        pieNotice('PurgeSuccess');
    } else {
        pieError('PurgeError');
    }
} else {
    // Purge the caches of all pages.
    if ($cache->expire('page', 0)) {
        pieNotice('ExpirationSuccess');
    } else {
        pieError('ExpirationError');
    }
}
 /**
  * Chargement optimisé des codes CCAM
  *
  * @param string $code Code CCAM
  * @param string $date Date de référence
  *
  * @return CDatedCodeCCAM
  */
 static function get($code, $date = null)
 {
     // Chargement en fonction de la configuration
     if (CAppUI::conf("ccam CCodeCCAM use_new_ccam_architecture") == "COldCodeCCAM") {
         return COldCodeCCAM::get($code);
     }
     // Cache by copy needed : OUTER
     $date = CMbDT::date($date);
     $cache = new Cache(__METHOD__, array($code, $date), self::$cache_layers);
     if ($cache->exists()) {
         return $cache->get();
     }
     $code_ccam = new CDatedCodeCCAM($code, $date);
     $code_ccam->load();
     return $cache->put($code_ccam, true);
 }
Пример #27
0
 /**
  * Get object tag
  *
  * @param string $group_id Group
  *
  * @return string|null
  */
 static function getObjectTag($group_id = null)
 {
     // Permettre des idex en fonction de l'établissement
     if (!$group_id) {
         $group_id = CGroups::loadCurrent()->_id;
     }
     $cache = new Cache(get_called_class() . "::" . __FUNCTION__, array($group_id), Cache::INNER);
     if ($cache->exists()) {
         return $cache->get();
     }
     /** @var CMbObject $object */
     $object = new static();
     $tag = $object->getDynamicTag();
     return $cache->put(str_replace('$g', $group_id, $tag));
 }
Пример #28
0
 /**
  * Return all child classes of a given class having given properties
  *
  * @param string $parent        [optional] Parent class
  * @param bool   $active_module [optional] If true, filter on active modules
  *
  * @return array Class names
  * @todo Default parent class should probably be CModelObject
  */
 static function getChildClasses($parent = "CMbObject", $active_module = false)
 {
     $cache = new Cache(__METHOD__, func_get_args(), Cache::INNER_OUTER);
     if ($cache->exists()) {
         return $cache->get();
     }
     self::includeAllClasses();
     $classes = get_declared_classes();
     foreach ($classes as $key => $class) {
         // Filter on parent class
         if ($parent && !is_subclass_of($class, $parent)) {
             unset($classes[$key]);
             continue;
         }
         // Filter on active module
         if ($active_module) {
             $object = new $class();
             if (!isset($object->_ref_module)) {
                 unset($classes[$key]);
             }
         }
     }
     sort($classes);
     return $cache->put($classes, true);
 }
Пример #29
0
 /**
  * Construit le tag IPP en fonction des variables de configuration
  *
  * @param int $group_id Permet de charger l'IPP pour un établissement donné si non null
  *
  * @return string|null
  */
 static function getTagIPP($group_id = null)
 {
     // Recherche de l'établissement
     $group = CGroups::get($group_id);
     if (!$group_id) {
         $group_id = $group->_id;
     }
     $cache = new Cache(__METHOD__, array($group_id), Cache::INNER);
     if ($cache->exists()) {
         return $cache->get();
     }
     // Gestion du tag IPP par son domaine d'identification
     if (CAppUI::conf("eai use_domain")) {
         return $cache->put(CDomain::getMasterDomain("CPatient", $group_id)->tag, false);
     }
     // Pas de tag IPP => pas d'affichage d'IPP
     if (null == ($tag_ipp = CAppUI::conf("dPpatients CPatient tag_ipp"))) {
         return $cache->put(null, false);
     }
     // Si on est dans le cas d'un établissement gérant la numérotation
     $group->loadConfigValues();
     if ($group->_configs["sip_idex_generator"]) {
         $tag_ipp = CAppUI::conf("sip tag_ipp");
     }
     // Préférer un identifiant externe de l'établissement
     if ($tag_group_idex = CAppUI::conf("dPpatients CPatient tag_ipp_group_idex")) {
         $idex = new CIdSante400();
         $idex->loadLatestFor($group, $tag_group_idex);
         $group_id = $idex->id400;
     }
     return $cache->put(str_replace('$g', $group_id, $tag_ipp), false);
 }
Пример #30
0
 static function loadFromAdeli($adeli)
 {
     $cache = new Cache(__METHOD__, func_get_args(), Cache::INNER);
     if ($cache->exists()) {
         return $cache->get();
     }
     $mediuser = new CMediusers();
     $where = array();
     $where["users_mediboard.adeli"] = " = '{$adeli}'";
     $mediuser->loadObject($where);
     return $cache->put($mediuser, false);
 }