Ejemplo n.º 1
0
 /**
  * Get meta description of the table and generate fields array
  * @return array
  */
 public function getMetadata()
 {
     if ($this->table && !$this->fields) {
         $runtime_cache = new waRuntimeCache('db/' . $this->table);
         if ($this->fields = $runtime_cache->get()) {
             return $this->fields;
         }
         if (SystemConfig::isDebug()) {
             $this->fields = $this->getFields();
         } else {
             $cache = new waSystemCache('db/' . $this->table);
             if (!($this->fields = $cache->get())) {
                 $this->fields = $this->getFields();
                 $cache->set($this->fields);
             }
         }
         $runtime_cache->set($this->fields);
     }
     return $this->fields;
 }
Ejemplo n.º 2
0
 /**
  * Change rate of currency
  *
  * @param string $code
  * @param double $rate
  */
 public function changeRate($code, $rate)
 {
     $primary = $this->getPrimaryCurrency();
     if ($code == $primary) {
         return false;
     }
     $currency = $this->getById($code);
     if (!$currency) {
         return false;
     }
     $rate = (double) $rate;
     $old_rate = (double) $currency['rate'];
     if ($rate < 0) {
         return false;
     }
     if ($rate != $old_rate) {
         $result = $this->updateById($code, array('rate' => $rate));
         $this->recalcProductPrimaryPrices($code);
         $this->recalcServicePrimaryPrices($code);
         $cache = new waRuntimeCache('shop_currencies');
         $cache->delete();
         if ($cache = wa('shop')->getCache()) {
             $cache->delete('currencies');
         }
         return $result;
     }
     return true;
 }
 protected function install()
 {
     $file_db = $this->path . '/lib/config/db.php';
     if (file_exists($file_db)) {
         $schema = (include $file_db);
         $model = new waModel();
         $model->createSchema($schema);
     } else {
         // check plugin.sql
         $file_sql = $this->path . '/lib/config/plugin.sql';
         if (file_exists($file_sql)) {
             waAppConfig::executeSQL($file_sql, 1);
         }
     }
     // check install.php
     $file = $this->path . '/lib/config/install.php';
     if (file_exists($file)) {
         $app_id = $this->app_id;
         include $file;
         // clear db scheme cache, see waModel::getMetadata
         try {
             // remove files
             $path = waConfig::get('wa_path_cache') . '/db/';
             waFiles::delete($path, true);
         } catch (waException $e) {
             waLog::log($e->__toString());
         }
         // clear runtime cache
         waRuntimeCache::clearAll();
     }
 }
Ejemplo n.º 4
0
 public function setAuth($data)
 {
     $path = $this->getPath('config', 'auth');
     if (waUtils::varExportToFile($data, $path)) {
         $cache = new waRuntimeCache('wa-config/auth');
         $cache->set($data);
         return true;
     }
     return false;
 }
Ejemplo n.º 5
0
 public static function clearAll()
 {
     self::$cache = array();
 }