From 327f9d4bfc693286bced5f0d0e454665d8199d13 Mon Sep 17 00:00:00 2001 From: John Atkinson Date: Thu, 6 Jun 2013 17:49:09 -0700 Subject: [PATCH] automatic database manipulation --- upload/admin/controller/payment/bitcoin.php | 26 ++++++++++++++----- .../language/english/payment/bitcoin.php | 2 +- .../admin/view/template/payment/bitcoin.tpl | 3 --- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/upload/admin/controller/payment/bitcoin.php b/upload/admin/controller/payment/bitcoin.php index ab9b069..baa727c 100644 --- a/upload/admin/controller/payment/bitcoin.php +++ b/upload/admin/controller/payment/bitcoin.php @@ -139,6 +139,26 @@ public function index() { 'href' => $this->url->link('payment/bitcoin', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ' ); + + $result = $this->db->query("SHOW COLUMNS FROM ". DB_PREFIX ."order;"); + $rows = $result->rows; + $max = $result->num_rows; + $bitcoin_total_in_db = 0; + $bitcoin_address_in_db = 0; + for($i = 0;$i < $max;$i++) { + if($rows[$i]["Field"] == "bitcoin_total") { + $bitcoin_total_in_db = 1; + } + if($rows[$i]["Field"] == "bitcoin_address") { + $bitcoin_address_in_db = 1; + } + } + if(!$bitcoin_total_in_db) { + $this->db->query("ALTER TABLE ". DB_PREFIX ."order ADD bitcoin_total DOUBLE AFTER currency_value;"); + } + if(!$bitcoin_address_in_db) { + $this->db->query("ALTER TABLE ". DB_PREFIX ."order ADD bitcoin_address VARCHAR(34) AFTER bitcoin_total;"); + } $this->data['action'] = HTTPS_SERVER . 'index.php?route=payment/'.$this->payment_module_name.'&token=' . $this->session->data['token']; $this->data['cancel'] = HTTPS_SERVER . 'index.php?route=extension/payment&token=' . $this->session->data['token']; @@ -215,10 +235,4 @@ public function index() { $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression')); } - public function update_db() { - - $this->db->query("ALTER TABLE ". DB_PREFIX ."order ADD bitcoin_total DOUBLE AFTER currency_value;"); - $this->db->query("ALTER TABLE ". DB_PREFIX ."order ADD bitcoin_address VARCHAR(34) AFTER bitcoin_total;"); - - } } diff --git a/upload/admin/language/english/payment/bitcoin.php b/upload/admin/language/english/payment/bitcoin.php index 81b72d9..bc1be6f 100644 --- a/upload/admin/language/english/payment/bitcoin.php +++ b/upload/admin/language/english/payment/bitcoin.php @@ -26,7 +26,7 @@ $_['entry_prefix'] = 'The prefix for the address labels:
The account will be in the form [prefix]_[order_id]'; $_['entry_order_status'] = 'Status of a new order:'; $_['entry_show_btc'] = 'Show BTC as a store currency:'; -$_['entry_blockchain'] = 'Is this a blockchain.info JSON-RPC server?:'; +$_['entry_blockchain'] = 'Is this a blockchain.info JSON-RPC server?'; $_['entry_btc_decimal'] = 'Calculate BTC amount to this many decimal places:'; $_['entry_countdown_timer'] = 'Time to complete order:
In seconds'; $_['entry_status'] = 'Status:'; diff --git a/upload/admin/view/template/payment/bitcoin.tpl b/upload/admin/view/template/payment/bitcoin.tpl index ec37520..bd31754 100644 --- a/upload/admin/view/template/payment/bitcoin.tpl +++ b/upload/admin/view/template/payment/bitcoin.tpl @@ -22,9 +22,6 @@ Copyright (c) 2013 John Atkinson (jga)
- - -
Click here the first time you configure this extension to prepare your database.
*