/**
  * Get an instance from the code
  *
  * @param string $code Code
  *
  * @return CIntervenantCdARR
  **/
 static function get($code)
 {
     if (!$code) {
         return new self();
     }
     if ($intervenant = SHM::get("intervenant_{$code}")) {
         return $intervenant;
     }
     $intervenant = new self();
     $intervenant->load($code);
     SHM::put("intervenant_{$code}", $intervenant);
     return $intervenant;
 }
 /**
  * Get an instance from the code
  *
  * @param string $code Code CdARR
  *
  * @return CTypeActiviteCdARR
  **/
 static function get($code)
 {
     if (!$code) {
         return new self();
     }
     if ($type = SHM::get("type_activite_{$code}")) {
         return $type;
     }
     $type = new self();
     $type->load($code);
     SHM::put("type_activite_{$code}", $type);
     return $type;
 }
    foreach ($locales as &$_locale) {
        $_locale = CMbString::unslash($_locale);
    }
    $path = "./tmp/locales-{$localeName}.js";
    if (!is_file($path)) {
        CAppUI::stepAjax("Locales-javascript-cache-none", UI_MSG_OK, $localeName);
        continue;
    }
    $fp = fopen($path, 'r');
    preg_match('#^//(\\d+)#', fgets($fp), $v);
    if ($v[1] < $version['build']) {
        CAppUI::stepAjax("Locales-javascript-cache-ko", UI_MSG_WARNING, $localeName);
        fclose($fp);
        continue;
    }
    if (null == SHM::get("locales-{$localeName}-" . CAppUI::LOCALES_PREFIX)) {
        CAppUI::stepAjax("Locales-shm-none", UI_MSG_OK, $localeName);
        continue;
    }
    // Load overwritten locales if the table exists
    $overwrite = new CTranslationOverwrite();
    if ($overwrite->isInstalled()) {
        $locales = $overwrite->transformLocales($locales);
    }
    $cached_locales = CAppUI::flattenCachedLocales($localeName);
    if ($cached_locales != $locales) {
        CAppUI::stepAjax("Locales-shm-ko", UI_MSG_WARNING, $localeName);
        continue;
    }
    CAppUI::stepAjax("Locales-shm-ok", UI_MSG_OK, $localeName);
}
////////// Smarty templates
// DO NOT use CMbPath::removed because it must be used in the installer
$templates = array_merge(glob("tmp/templates_c/*/*/*/*/*"), glob("tmp/templates_c/*/*/*/*"), glob("tmp/templates_c/*/*/*"));
foreach ($templates as $_template) {
    if (is_file($_template)) {
        unlink($_template);
    }
}
$template_dirs = array_merge(glob("tmp/templates_c/*/*/*/*", GLOB_ONLYDIR), glob("tmp/templates_c/*/*/*", GLOB_ONLYDIR), glob("tmp/templates_c/*/*", GLOB_ONLYDIR));
foreach ($template_dirs as $_dir) {
    rmdir($_dir);
}
CAppUI::stepAjax("template-cache-removed", UI_MSG_OK, count($templates));
////////// Module specific removals
foreach (glob("modules/*/empty_shared_memory.php") as $script) {
    include $script;
}
// Remove locales, at the end because otherwise, next message aren't translated
foreach (glob("locales/*", GLOB_ONLYDIR) as $localeDir) {
    $localeName = basename($localeDir);
    $sharedName = "locales-{$localeName}";
    if (!SHM::get("{$sharedName}-" . CAppUI::LOCALES_PREFIX)) {
        CAppUI::stepAjax("Locales-shm-none", UI_MSG_OK, $localeName);
        continue;
    }
    if (!SHM::remKeys("{$sharedName}-*")) {
        CAppUI::stepAjax("Locales-shm-rem-ko", UI_MSG_WARNING, $localeName);
        continue;
    }
    CAppUI::stepAjax("Locales-shm-rem-ok", UI_MSG_OK, $localeName);
}
 protected static function _emptySHM($class, $key)
 {
     if (!SHM::get($key)) {
         CAppUI::stepAjax("{$class}-shm-none", UI_MSG_OK);
     } else {
         if (!SHM::rem($key)) {
             CAppUI::stepAjax("{$class}-shm-rem-ko", UI_MSG_WARNING);
         }
         CAppUI::stepAjax("{$class}-shm-rem-ok", UI_MSG_OK);
     }
 }
 /**
  * Get an instance from the code
  *
  * @param string $code Code
  *
  * @return self
  **/
 static function get($code)
 {
     if (!$code) {
         return new self();
     }
     if ($hierarchie = SHM::get("hierarchie_{$code}")) {
         return $hierarchie;
     }
     $hierarchie = new self();
     $hierarchie->load($code);
     SHM::put("hierarchie_{$code}", $hierarchie);
     return $hierarchie;
 }
Example #7
0
 * Installation Shared memory manager
 *  
 * @package    Mediboard
 * @subpackage Installer
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 * @version    SVN: $Id: empty_shared_memory.php 27803 2015-04-01 10:02:08Z kgrisel $ 
 * @link       http://www.mediboard.org
 */
$rootName = basename($dPconfig["root_dir"]);
require_once "../classes/SHM.class.php";
// Remove locales
foreach (glob("../locales/*", GLOB_ONLYDIR) as $localeDir) {
    $localeName = basename($localeDir);
    $sharedName = "locales-{$localeName}";
    if (!SHM::get("{$sharedName}-.__prefixes__")) {
        echo "Table absente en mémoire pour langage '{$localeName}'<br />";
        continue;
    }
    if (!SHM::remKeys("{$sharedName}-*")) {
        echo "Impossible de supprimer la table pour le langage '{$localeName}'<br />";
        continue;
    }
    echo "Table supprimée pour langage '{$localeName}'<br />";
}
if (!SHM::rem("class-paths")) {
    echo "Impossible de supprimer la table des classes<br />";
    return;
}
echo "Table des classes supprimée<br />";
$classes = array("CApp");
Example #8
0
<?php

/**
 * $Id: about.php 20799 2013-10-29 11:43:54Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage System
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 20799 $
 */
CCanDo::checkRead();
$user = CAppUI::$user;
$latest_cache_key = "{$user->_guid}-latest_cache";
$latest_cache = SHM::get($latest_cache_key);
foreach ($latest_cache["hits"] as &$keys) {
    ksort($keys);
}
//mbTrace($latest_cache["totals"]);
$smarty = new CSmartyDP();
$smarty->assign("all_layers", Cache::$all_layers);
$smarty->assign("latest_cache", $latest_cache);
$smarty->display("latest_cache_hits.tpl");
Example #9
0
 * $Id: cache_tester_users.php 24615 2014-09-01 10:52:44Z phenxdesign $
 *
 * @package    Mediboard
 * @subpackage developpement
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision: 24615 $
 */
CCanDo::checkRead();
$chrono = new Chronometer();
$chrono->start();
if (CView::get("purge", "bool default|0")) {
    SHM::rem("mediusers");
    $chrono->step("purge");
}
if (!SHM::exists("mediusers")) {
    $chrono->step("acquire (not yet)");
    $mediuser = new CMediusers();
    $mediusers = $mediuser->loadListFromType();
    $chrono->step("load");
    SHM::put("mediusers", $mediusers, true);
    $chrono->step("put");
}
/** @var CMediusers[] $mediusers */
$mediusers = SHM::get("mediusers");
$chrono->step("get");
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("mediusers", $mediusers);
$smarty->assign("chrono", $chrono);
$smarty->display("cache_tester_users.tpl");
 /**
  * Get the values cache status
  *
  * @return string The values can be self::STATUS_EMPTY, self::STATUS_DIRTY or self::STATUS_OK
  */
 static function getValuesCacheStatus()
 {
     $hosts = SHM::get("config-values-__HOSTS__");
     if (!$hosts) {
         return self::STATUS_EMPTY;
     }
     if (self::_isValuesCacheDirty($hosts["date"])) {
         return self::STATUS_DIRTY;
     }
     return self::STATUS_OK;
 }
Example #11
0
 /**
  * Get a flattened version of all cached locales
  *
  * @param string $lang Language: fr, en
  *
  * @return array
  */
 static function flattenCachedLocales($lang)
 {
     $shared_name = "locales-{$lang}";
     $prefixes = SHM::get("{$shared_name}-" . self::LOCALES_PREFIX);
     $locales = array();
     foreach ($prefixes as $_hash => $_prefix) {
         $prefixed = SHM::get("{$shared_name}-{$_hash}");
         if ($_prefix === "__common__") {
             $_prefix = "";
         }
         foreach ($prefixed as $_key => $_value) {
             $locales["{$_prefix}{$_key}"] = $_value;
         }
     }
     return $locales;
 }
Example #12
0
 /**
  * Load the list of visible modules
  *
  * @param bool $shm Use shared memory
  *
  * @return void
  */
 static function loadModules($shm = true)
 {
     // @todo Experiment, then remove test if no problem
     if ($shm) {
         $modules = SHM::get("modules");
         if (!$modules) {
             $module = new self();
             $modules = $module->loadList(null, "mod_ui_order");
             SHM::put("modules", $modules);
         }
     } else {
         $module = new self();
         $modules = $module->loadList(null, "mod_ui_order");
     }
     /** @var $module CModule */
     foreach ($modules as &$module) {
         $module->checkModuleFiles();
         self::$installed[$module->mod_name] =& $module;
         if ($module->mod_active == 1) {
             self::$active[$module->mod_name] =& $module;
         }
         if ($module->mod_ui_active == 1) {
             self::$visible[$module->mod_name] =& $module;
         }
         if ($module->_files_missing) {
             self::$absent[$module->mod_name] =& $module;
         }
     }
 }
 *
 * @package    Mediboard
 * @subpackage developpement
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
CCanDo::checkRead();
$chrono = new Chronometer();
$chrono->start();
$classes = CApp::getChildClasses("CModelObject");
//$classes = array_keys(CModelObject::$spec);
foreach ($classes as $_class) {
    /** @var CModelObject $object */
    $object = new $_class();
    $object->makeAllBackSpecs();
    $chrono->step("make");
}
foreach ($classes as $_class) {
    $ballot = array("spec" => CModelObject::$spec[$_class], "props" => CModelObject::$props[$_class], "specs" => CModelObject::$specs[$_class], "backProps" => CModelObject::$backProps[$_class], "backSpecs" => CModelObject::$backSpecs[$_class]);
    SHM::put("ballot-{$_class}", $ballot, true);
    $chrono->step("put");
}
foreach ($classes as $_class) {
    SHM::get("ballot-{$_class}");
    $chrono->step("get");
}
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("chrono", $chrono);
$smarty->display("cache_tester_metamodel.tpl");
Example #14
0
 /**
  * Charge une activité par le code
  *
  * @param string $code Code d'activité
  *
  * @return self
  */
 static function get($code)
 {
     if (!$code) {
         return new self();
     }
     if ($activite = SHM::get("activite_cdarr_{$code}")) {
         return $activite;
     }
     $activite = new self();
     $activite->load($code);
     SHM::put("activite_cdarr_{$code}", $activite);
     return $activite;
 }
Example #15
0
<?php

/**
 * Autoload strategies
 *  
 * @category   Dispatcher
 * @package    Mediboard
 * @subpackage Includes
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html 
 * @version    SVN: $Id: autoload.php 20601 2013-10-10 13:45:17Z phenxdesign $ 
 * @link       http://www.mediboard.org
 */
CApp::$performance["autoloadCount"] = 0;
CApp::$performance["autoload"] = array();
CApp::$classPaths = SHM::get("class-paths");
/**
 * Mediboard class autoloader
 * 
 * @param string $class Class to be loaded
 * 
 * @return bool
 */
function mbAutoload($class)
{
    $file_exists = false;
    $time = microtime(true);
    // Entry already in cache
    if (isset(CApp::$classPaths[$class])) {
        // The class is known to not be in MB
        if (CApp::$classPaths[$class] === false) {
Example #16
0
 /**
  * Get a value from the cache
  *
  * @return mixed
  */
 public function get()
 {
     $layers = $this->layers;
     // Inner cache
     if ($layers & Cache::INNER) {
         if (isset(self::$data[$this->prefix][$this->key])) {
             $this->_hit("INNER");
             return self::$data[$this->prefix][$this->key];
         }
     }
     // Flat key for outer and distributed layers
     $key = "{$this->prefix}-{$this->key}";
     // Outer cache
     if ($layers & Cache::OUTER) {
         if (null !== ($value = SHM::get($key))) {
             if ($layers & Cache::INNER) {
                 self::$data[$this->prefix][$this->key] = $value;
             }
             $this->_hit("OUTER");
             return $value;
         }
     }
     // Distributed cache
     if ($layers & Cache::DISTR) {
         if (null !== ($value = DSHM::get($key))) {
             if ($layers & Cache::OUTER) {
                 SHM::put($key, $value);
             }
             if ($layers & Cache::INNER) {
                 self::$data[$this->prefix][$this->key] = $value;
             }
             $this->_hit("DISTR");
             return $value;
         }
     }
     $this->_hit("NONE");
     return null;
 }
Example #17
0
 /**
  * Charge une activité par le code
  *
  * @param string $code Code d'activité
  *
  * @return self
  */
 static function get($code)
 {
     if (!$code) {
         return new self();
     }
     if ($activite = SHM::get("activite_csarr_{$code}")) {
         $activite->loadRefReference();
         $activite->loadRefsModulateurs();
         return $activite;
     }
     $activite = new self();
     $activite->load($code);
     SHM::put("activite_csarr_{$code}", $activite);
     $activite->loadRefReference();
     $activite->loadRefsModulateurs();
     return $activite;
 }