summaryrefslogtreecommitdiff
path: root/app/Model/Currency.php
diff options
context:
space:
mode:
authorGerardo Zamudio <gerardozamudio@users.noreply.github.com>2016-02-24 23:48:50 -0600
committerGerardo Zamudio <gerardozamudio@users.noreply.github.com>2016-02-24 23:48:50 -0600
commite4de6b3898b64b26d29aff31f21df5fda8055686 (patch)
tree575f8a65440f291d70a070d168eafca8c82a6459 /app/Model/Currency.php
parentd9ffbea174ea6524d0a22f8375ca8b3aa04a3c96 (diff)
parenta6540bc604c837d92c9368540c145606723e97f7 (diff)
Merge pull request #1 from fguillot/master
Update from upstream
Diffstat (limited to 'app/Model/Currency.php')
-rw-r--r--app/Model/Currency.php53
1 files changed, 28 insertions, 25 deletions
diff --git a/app/Model/Currency.php b/app/Model/Currency.php
index c1156610..abcce2f0 100644
--- a/app/Model/Currency.php
+++ b/app/Model/Currency.php
@@ -2,9 +2,6 @@
namespace Kanboard\Model;
-use SimpleValidator\Validator;
-use SimpleValidator\Validators;
-
/**
* Currency
*
@@ -21,6 +18,32 @@ class Currency extends Base
const TABLE = 'currencies';
/**
+ * Get available application currencies
+ *
+ * @access public
+ * @return array
+ */
+ public function getCurrencies()
+ {
+ return array(
+ 'USD' => t('USD - US Dollar'),
+ 'EUR' => t('EUR - Euro'),
+ 'GBP' => t('GBP - British Pound'),
+ 'CHF' => t('CHF - Swiss Francs'),
+ 'CAD' => t('CAD - Canadian Dollar'),
+ 'AUD' => t('AUD - Australian Dollar'),
+ 'NZD' => t('NZD - New Zealand Dollar'),
+ 'INR' => t('INR - Indian Rupee'),
+ 'JPY' => t('JPY - Japanese Yen'),
+ 'RSD' => t('RSD - Serbian dinar'),
+ 'SEK' => t('SEK - Swedish Krona'),
+ 'NOK' => t('NOK - Norwegian Krone'),
+ 'BAM' => t('BAM - Konvertible Mark'),
+ 'RUB' => t('RUB - Russian Ruble'),
+ );
+ }
+
+ /**
* Get all currency rates
*
* @access public
@@ -45,7 +68,7 @@ class Currency extends Base
$reference = $this->config->get('application_currency', 'USD');
if ($reference !== $currency) {
- $rates = $rates === null ? $this->db->hashtable(self::TABLE)->getAll('currency', 'rate') : array();
+ $rates = $rates === null ? $this->db->hashtable(self::TABLE)->getAll('currency', 'rate') : $rates;
$rate = isset($rates[$currency]) ? $rates[$currency] : 1;
return $rate * $price;
@@ -68,7 +91,7 @@ class Currency extends Base
return $this->update($currency, $rate);
}
- return $this->persist(self::TABLE, compact('currency', 'rate'));
+ return $this->db->table(self::TABLE)->insert(array('currency' => $currency, 'rate' => $rate));
}
/**
@@ -83,24 +106,4 @@ class Currency extends Base
{
return $this->db->table(self::TABLE)->eq('currency', $currency)->update(array('rate' => $rate));
}
-
- /**
- * Validate
- *
- * @access public
- * @param array $values Form values
- * @return array $valid, $errors [0] = Success or not, [1] = List of errors
- */
- public function validate(array $values)
- {
- $v = new Validator($values, array(
- new Validators\Required('currency', t('Field required')),
- new Validators\Required('rate', t('Field required')),
- ));
-
- return array(
- $v->execute(),
- $v->getErrors()
- );
- }
}