Exemplo n.º 1
0
 public function stack_load($flags = 0)
 {
     global $config;
     if ($flags == 0) {
         $flags = Stack::FLAG_STACK_INFO | Stack::FLAG_STACK_SCRIPT | Stack::FLAG_STACK_ICONS;
     }
     $stmt = $this->file_db->prepare('SELECT stack_data,cant_delete,cant_modify,private_access FROM stack');
     Stack::sl_err($stmt, $this->file_db, 'Invalid Stack or Stack Corrupt', 520);
     Stack::sl_ok($stmt->execute(), $this->file_db, 'Loading Stack (2)');
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     Stack::sl_ok($row, $this->file_db, 'Loading Stack (3)');
     $stack = json_decode($row['stack_data'], true);
     $stack['stack_name'] = $this->name;
     $stack['cant_delete'] = Stack::decode_bool($row['cant_delete']);
     $stack['cant_modify'] = Stack::decode_bool($row['cant_modify']);
     $stack['private_access'] = Stack::decode_bool($row['private_access']);
     $stack['first_card_id'] = $this->stack_get_first_card_id();
     $stack['stack_id'] = substr($this->stack_id, strlen($config->stacks));
     $stack['stack_path'] = substr($this->stack_id, strlen($config->stacks));
     $stack['count_cards'] = $this->stack_get_count_cards();
     $stack['count_bkgnds'] = $this->stack_get_count_bkgnds();
     $stack['stack_size'] = filesize($this->stack_id);
     $stack['stack_free'] = $this->stack_get_free();
     // also need to retrieve icons here
     // unless specifically excluded, for example, subsequent reload of essential information only
     // ** TODO **
     if ($flags & Stack::FLAG_STACK_ICONS) {
         $list = array();
         $stmt = $this->file_db->prepare('SELECT icon_id,icon_name,icon_data FROM icon');
         Stack::sl_ok($stmt, $this->file_db, 'Loading Stack Icons (1)');
         Stack::sl_ok($stmt->execute(), $this->file_db, 'Loading Stack Icons (2)');
         while (($row = $stmt->fetch(PDO::FETCH_NUM)) !== false) {
             $list[] = $row;
         }
         $stack['stack_icons'] = $list;
     }
     /*$stack['cant_peek'] = Stack::decode_bool($data['cant_peek']);
     		$stack['cant_abort'] = Stack::decode_bool($data['cant_abort']);
     		$stack['user_level'] = $data['user_level'];
     		$stack['card_width'] = $data['card_width'];
     		$stack['card_height'] = $data['card_height'];*/
     return $stack;
 }