oDb = &$oDb; $this->setNoteId(0); $this->setUserCourseId($iUserId, $iCourseId); } public function setNoteId($iNoteId) { $this->iNoteId = $iNoteId; } public function setUserCourseId($iUserId, $iCourseId) { $this->iUserId = $iUserId; $this->iCourseId = $iCourseId; } private function getNoteKeys() { return array(Db::getId(Auth::USER_TABLE) => $this->iUserId, Db::getId(Course::COURSE_TABLE) => $this->iCourseId); } public function getNoteOld() { $asCourse = $this->oDb->selectRow(self::NOTE_TABLE, $this->getNoteKeys()); if(!empty($asCourse)) { $asCourse['notes'] = json_decode($asCourse['notes_old'], true); $asCourse['led_date'] = date('d/m/Y', strtotime($asCourse['led'])); $asCourse['led_time'] = date('H:i'); } return $asCourse; } public function getNote() { $asCourse = $this->oDb->selectRow(self::NOTE_TABLE, $this->getNoteKeys()); if(!empty($asCourse)) { $asCourse['led_date'] = date('d/m/Y', strtotime($asCourse['led'])); $asCourse['led_time'] = date('H:i'); } return $asCourse; } public function setNote($sNotes) { $sError = ''; if($this->iUserId > 0 && $this->iCourseId > 0) { $asData = array_merge($this->getNoteKeys(), array('notes'=>$sNotes)); $iNoteId = $this->oDb->insertUpdateRow(self::NOTE_TABLE, $asData, array_keys($this->getNoteKeys())); if(!$iNoteId) $sError = $this->oDb->getLastError(); } else $sError = 'Course ID not set'; return $sError; } }