currency.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. // This file is part of the Sloodle project (www.sloodle.org)
  3. /**
  4. * @package sloodle
  5. * @copyright Copyright (c) 2008 Sloodle (various contributors)
  6. * @license http://www.gnu.org/licenses/gpl-3.0.html GNU GPL v3
  7. *
  8. * @contributor Peter R. Bloomfield
  9. * @contributor Edmund Edgar
  10. * @contributor Fire Centaur
  11. */
  12. /** Include the general Sloodle library. */
  13. require_once(SLOODLE_LIBROOT.'/general.php');
  14. /**
  15. * The Sloodle course data class
  16. * @package sloodle
  17. */
  18. class SloodleCurrency
  19. {
  20. // DATA //
  21. // FUNCTIONS //
  22. /**
  23. * Constructor
  24. */
  25. function SloodleCurrency()
  26. {
  27. }
  28. function loadFromRecord($rec) {
  29. $this->id = $rec->id;
  30. $this->name = $rec->name;
  31. $this->timemodified = $rec->timemodified;
  32. $this->imageurl = $rec->imageurl;
  33. $this->displayorder = $rec->displayorder;
  34. }
  35. function FetchAll() {
  36. $recs = sloodle_get_records('sloodle_currency_types', null, null, 'displayorder asc, name asc');
  37. if (!$recs) {
  38. return false;
  39. }
  40. $currencies = array();
  41. foreach($recs as $rec) {
  42. $c = new SloodleCurrency();
  43. $c->loadFromRecord($rec);
  44. $currencies[] = $c;
  45. }
  46. return $currencies;
  47. }
  48. function FetchIDNameHash() {
  49. if (!$currencies = SloodleCurrency::FetchAll()) {
  50. return false;
  51. }
  52. $curbyid = array();
  53. foreach($currencies as $cur) {
  54. $id = $cur->id;
  55. $name = $cur->name;
  56. $curbyid[ $id ] = $name;
  57. }
  58. return $curbyid;
  59. }
  60. function ForID($id) {
  61. $rec = sloodle_get_record( 'sloodle_currency_types', 'id', $id );
  62. if (!$rec) {
  63. return null;
  64. }
  65. $curr = new SloodleCurrency();
  66. $curr->loadFromRecord( $rec );
  67. return $curr;
  68. }
  69. }
  70. ?>