Example #1
0
 function __get($key)
 {
     if (in_array($key, self::$protectedVars)) {
         return parent::__get($key);
     }
     return $this->getVal($key, null);
 }
Example #2
0
/**
 * Get a forge size.
 *
 * @return array Associative array with the size of each element
 */
function IDF_Views_Admin_getForgeSize($force = false)
{
    $conf = new IDF_Gconf();
    $conf->setModel((object) array('_model' => 'IDF_Forge', 'id' => 1));
    $res = array();
    $res['repositories'] = 0;
    foreach (Pluf::factory('IDF_Project')->getList() as $prj) {
        $size = $prj->getRepositorySize($force);
        if ($size != -1) {
            $res['repositories'] += $size;
        }
    }
    $last_eval = $conf->getVal('downloads_size_check_date', 0);
    if (Pluf::f('idf_no_size_check', false) or !$force and $last_eval > time() - 172800) {
        $res['downloads'] = $conf->getVal('downloads_size', 0);
    } else {
        $conf->setVal('downloads_size_check_date', time());
        $cmd = Pluf::f('idf_exec_cmd_prefix', '') . 'du -sk ' . escapeshellarg(Pluf::f('upload_path'));
        $out = explode(' ', shell_exec($cmd), 2);
        $res['downloads'] = $out[0] * 1024;
        $conf->setVal('downloads_size', $res['downloads']);
    }
    $last_eval = $conf->getVal('attachments_size_check_date', 0);
    if (Pluf::f('idf_no_size_check', false) or !$force and $last_eval > time() - 172800) {
        $res['attachments'] = $conf->getVal('attachments_size', 0);
    } else {
        $conf->setVal('attachments_size_check_date', time());
        $cmd = Pluf::f('idf_exec_cmd_prefix', '') . 'du -sk ' . escapeshellarg(Pluf::f('upload_path'));
        $out = explode(' ', shell_exec($cmd), 2);
        $res['attachments'] = $out[0] * 1024;
        $conf->setVal('attachments_size', $res['attachments']);
    }
    $last_eval = $conf->getVal('database_size_check_date', 0);
    if (Pluf::f('idf_no_size_check', false) or !$force and $last_eval > time() - 172800) {
        $res['database'] = $conf->getVal('database_size', 0);
    } else {
        $conf->setVal('database_size_check_date', time());
        $res['database'] = IDF_Views_Admin_getForgeDbSize();
        $conf->setVal('database_size', $res['database']);
    }
    $res['total'] = $res['repositories'] + $res['downloads'] + $res['attachments'] + $res['database'];
    return $res;
}
Example #3
0
 function preDelete()
 {
     IDF_Timeline::remove($this);
     IDF_Search::remove($this);
     IDF_Gconf::dropForModel($this);
 }
Example #4
0
 function delVal($key, $initcache = true)
 {
     $gconf = new IDF_Gconf();
     $sql = new Pluf_SQL('vkey=%s AND model_class=%s AND model_id=%s', array($key, $this->_mod->_model, $this->_mod->id));
     foreach ($gconf->getList(array('filter' => $sql->gen())) as $c) {
         $c->delete();
     }
     if ($initcache) {
         $this->initCache();
     }
 }
Example #5
0
 /**
  * Collection selection.
  *
  * Suppose you have 5 objects with associated meta data in the
  * Gconf storage, if you load the data independently for each
  * object, you end up with 5 SELECT queries. With 25 objects, 25
  * SELECT. You can select with one query all the data and merge in
  * the code. It is faster. The collection selection get a
  * model_class and a list of ids and returns an id indexed array
  * of associative array data. This is for read only access as you
  * do not get a series of Gconf objects.
  */
 public static function collect($class, $ids)
 {
     $gconf = new IDF_Gconf();
     $stmpl = sprintf('model_class=%%s AND model_id IN (%s)', implode(',', $ids));
     $sql = new Pluf_SQL($stmpl, array($class));
     $out = array_fill_keys($ids, array());
     foreach ($gconf->getList(array('filter' => $sql->gen())) as $c) {
         $out[$c->model_id][$c->vkey] = $c->vdesc;
     }
     return $out;
 }