Commit 073254470e2269bf261baf3b81141141319942ef

Authored by Michael Joseph
1 parent 3ecea857

fixed date handling


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2173 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/archiving/ArchivingDateSettings.inc
... ... @@ -62,7 +62,7 @@ class ArchivingDateSettings {
62 62 * @param date the new expiration date
63 63 */
64 64 function setExpirationDate($dNewExpirationDate){
65   - $this->dExpirationDate = strlen($dNewExpirationDate) == 0 ? "NULL" : "'$dNewExpirationDate'";
  65 + $this->dExpirationDate = strlen($dNewExpirationDate) == 0 ? "NULL" : $dNewExpirationDate;
66 66 }
67 67  
68 68 /**
... ... @@ -92,7 +92,7 @@ class ArchivingDateSettings {
92 92 if ($this->iId < 0) {
93 93 $sql = $default->db;
94 94 $sQuery = "INSERT INTO $default->owl_archiving_date_settings_table (expiration_date, time_period_id) " .
95   - "VALUES ($this->dExpirationDate, $this->iTimePeriodID)";
  95 + "VALUES (" . $this->addQuotes($this->dExpirationDate) . ", $this->iTimePeriodID)";
96 96 $result = $sql->query($sQuery);
97 97 $default->log->info($sQuery);
98 98 if ($result) {
... ... @@ -104,7 +104,14 @@ class ArchivingDateSettings {
104 104 }
105 105 return false;
106 106 }
107   -
  107 + function addQuotes($sDate) {
  108 + if ($sDate == "NULL") {
  109 + return $sDate;
  110 + } else {
  111 + return "'$sDate'";
  112 + }
  113 + }
  114 +
108 115 /**
109 116 * Update the archive date settings current values in the database
110 117 *
... ... @@ -115,7 +122,7 @@ class ArchivingDateSettings {
115 122 if ($this->iId >= 0) {
116 123 $sql = $default->db;
117 124 $sQuery = "UPDATE $default->owl_archiving_date_settings_table SET " .
118   - "expiration_date = $this->dExpirationDate, " .
  125 + "expiration_date = " . $this->addQuotes($this->dExpirationDate) . ", " .
119 126 "time_period_id = $this->iTimePeriodID " .
120 127 "WHERE id = $this->iId";
121 128 $default->log->info($sQuery);
... ...