Project_Version.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. require_once($path["entity"] . "Entity.php");
  3. require_once($path["entity"] . "Project_Version_Type.php");
  4. require_once($path["helper"] . "text.php");
  5. /**
  6. * Version of a project.
  7. *
  8. * Represents an object from the table 'project_version'.
  9. */
  10. class Project_Version extends Entity{
  11. /**
  12. * Project identifier.
  13. */
  14. public $project;
  15. /**
  16. * Version code, autogenerated.
  17. */
  18. public $code;
  19. /**
  20. * Version name or number.
  21. */
  22. public $name;
  23. /**
  24. * Version {@see Project_Version_Type}.
  25. */
  26. public $type;
  27. /**
  28. * Short text about the version, in the defined language.
  29. */
  30. public $summary;
  31. /**
  32. * Full changelog, in the defined language.
  33. */
  34. public $changelog;
  35. /**
  36. * Time the version was released at.
  37. */
  38. public $dtime;
  39. /**
  40. * Indictes wether the version must be visible.
  41. */
  42. public $visible;
  43. /**
  44. * Constructor.
  45. *
  46. * Searches the database and retrieves the information about the
  47. * version, populating it and its items.
  48. *
  49. * @param MySQL_connection $db Connection to the database.
  50. * @param string $lang Lowercase, two-letter language code.
  51. * @param int $project Project identifier.
  52. * @param int $code Version code.
  53. */
  54. public function __construct($db, $lang, $project, $code){
  55. parent::__construct($db, $lang);
  56. $s =
  57. "SELECT " .
  58. " project, " .
  59. " version_code AS code, " .
  60. " version_name AS name, " .
  61. " type, " .
  62. " changelog, " .
  63. " dtime, " .
  64. " visible " .
  65. "FROM project_version " .
  66. "WHERE " .
  67. " project = $project AND " .
  68. " version_code = $code ;";
  69. $q = mysqli_query($this->db, $s);
  70. if (mysqli_num_rows($q) > 0){
  71. $r = mysqli_fetch_array($q);
  72. $this->project = $r["project"];
  73. $this->code = $r["code"];
  74. $this->name = $r["name"];
  75. $this->changelog = text($this, $r["changelog"]);
  76. $this->dtime = $r["dtime"];
  77. $this->visible = $r["visible"];
  78. $this->type = new Project_Version_Type($this->db, $this->lang, $r["type"]);
  79. }
  80. }
  81. }
  82. ?>