Exemplo n.º 1
0
 /**
  * 
  * @param type $name nombre de la tabla de la base de datos.
  * @param type $basedir ruta del directorio table donde se encuentra el XML
  * con la estructura de la tabla de la base de datos.
  */
 public function __construct($name = '', $basedir = '')
 {
     $this->base_dir = $basedir;
     $this->cache = new fs_cache();
     $this->db = new fs_db2();
     $this->table_name = $name;
     $this->default_items = new fs_default_items();
     if (!self::$errors) {
         self::$errors = array();
     }
     if (!self::$checked_tables) {
         self::$checked_tables = $this->cache->get_array('fs_checked_tables', TRUE);
         if (self::$checked_tables) {
             /// nos aseguramos de que existan todas las tablas que se suponen comprobadas
             $tables = $this->db->list_tables();
             foreach (self::$checked_tables as $ct) {
                 if (!$this->db->table_exists($ct, $tables)) {
                     $this->clean_checked_tables();
                     break;
                 }
             }
         }
     }
     if ($name != '') {
         if (!in_array($name, self::$checked_tables)) {
             if ($this->check_table($name)) {
                 self::$checked_tables[] = $name;
                 $this->cache->set('fs_checked_tables', self::$checked_tables, 5400, TRUE);
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * 
  * @param type $name nombre de la tabla de la base de datos.
  */
 public function __construct($name = '')
 {
     $this->cache = new fs_cache();
     $this->db = new fs_db2();
     $this->table_name = $name;
     /// buscamos el xml de la tabla en los plugins
     $this->base_dir = '';
     foreach ($GLOBALS['plugins'] as $plugin) {
         if (file_exists('plugins/' . $plugin . '/model/table/' . $name . '.xml')) {
             $this->base_dir = 'plugins/' . $plugin . '/';
             break;
         }
     }
     $this->default_items = new fs_default_items();
     if (!self::$errors) {
         self::$errors = array();
     }
     if (!self::$checked_tables) {
         self::$checked_tables = $this->cache->get_array('fs_checked_tables', TRUE);
         if (self::$checked_tables) {
             /// nos aseguramos de que existan todas las tablas que se suponen comprobadas
             $tables = $this->db->list_tables();
             foreach (self::$checked_tables as $ct) {
                 if (!$this->db->table_exists($ct, $tables)) {
                     $this->clean_checked_tables();
                     break;
                 }
             }
         }
     }
     if ($name != '') {
         if (!in_array($name, self::$checked_tables)) {
             if ($this->check_table($name)) {
                 self::$checked_tables[] = $name;
                 $this->cache->set('fs_checked_tables', self::$checked_tables, 5400, TRUE);
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Añade un elemento a la lista de cambios del usuario.
  * @param type $txt texto descriptivo.
  * @param type $url URL del elemento (albarán, factura, artículos...).
  * @param type $nuevo TRUE si el elemento es nuevo, FALSE si se ha modificado.
  */
 public function new_change($txt, $url, $nuevo = FALSE)
 {
     $this->get_last_changes();
     if (count($this->last_changes) > 0) {
         if ($this->last_changes[0]['url'] == $url) {
             $this->last_changes[0]['nuevo'] = $nuevo;
         } else {
             array_unshift($this->last_changes, array('texto' => ucfirst($txt), 'url' => $url, 'nuevo' => $nuevo, 'cambio' => date('d-m-Y H:i:s')));
         }
     } else {
         array_unshift($this->last_changes, array('texto' => ucfirst($txt), 'url' => $url, 'nuevo' => $nuevo, 'cambio' => date('d-m-Y H:i:s')));
     }
     /// sólo queremos 10 elementos
     $num = 10;
     foreach ($this->last_changes as $i => $value) {
         if ($num > 0) {
             $num--;
         } else {
             unset($this->last_changes[$i]);
         }
     }
     $this->cache->set('last_changes_' . $this->user->nick, $this->last_changes);
 }
Exemplo n.º 4
0
 private function download_list2()
 {
     if (!isset($this->download_list2)) {
         $cache = new fs_cache();
         /**
          * Download_list2 es la lista de plugins de la comunidad, se descarga de Internet.
          */
         $this->download_list2 = $cache->get('download_list');
         if (!$this->download_list2) {
             $json = @$this->curl_get_contents('https://www.facturascripts.com/comm3/index.php?page=community_plugins&json2=TRUE', 5);
             if ($json) {
                 $this->download_list2 = json_decode($json);
                 $cache->set('download_list', $this->download_list2);
             } else {
                 $this->download_list2 = array();
             }
         }
     }
     return $this->download_list2;
 }