Add user id to docs/todos/notes tables

This commit is contained in:
2019-09-07 12:38:37 +02:00
parent 81a17332b4
commit 42c6f8eff7
6 changed files with 97 additions and 55 deletions

View File

@@ -12,7 +12,8 @@ class CATC extends Main
{
$asClasses = array(
array('name'=>'auth', 'project'=>true),
array('name'=>'course', 'project'=>true)
array('name'=>'course', 'project'=>true),
array('name'=>'note', 'project'=>true)
);
parent::__construct($oClassManagement, $sProcessPage, $asClasses);
@@ -24,6 +25,7 @@ class CATC extends Main
{
//Install DB
$this->oDb->install();
$this->oDb->loadFile('db_build.sql');
}
protected function getSqlOptions()
@@ -34,9 +36,10 @@ class CATC extends Main
(
Auth::USER_TABLE => array(Db::getText(Auth::USER_TABLE), 'nickname', 'pass', 'cookie'),
Course::WS_TABLE => array('dates'),
Course::COURSE_TABLE=> array(Db::getId('workshops'), 'description', 'timeslot', 'notes'),
'docs' => array(Db::getId('courses'), 'type', 'path'),
'todos' => array(Db::getId('courses'), 'description')
Course::COURSE_TABLE=> array(Db::getId('workshops'), 'description', 'timeslot'),
'notes' => array(Db::getId(Auth::USER_TABLE), Db::getId(Course::COURSE_TABLE), 'notes'),
'docs' => array(Db::getId(Auth::USER_TABLE), Db::getId(Course::COURSE_TABLE), 'type', 'path'),
'todos' => array(Db::getId(Auth::USER_TABLE), Db::getId(Course::COURSE_TABLE), 'description')
),
'types' => array
(
@@ -145,19 +148,20 @@ class CATC extends Main
/* Notes*/
public function getNote($iCourseId) {
$oCourse = new Course($this->oDb, $iCourseId);
$asNote = $oCourse->getNote();
$iCourseId = $asNote[Db::getId(Course::COURSE_TABLE)];
$oNote = new Note($this->oDb, $this->oAuth->getUserId(), $iCourseId);
$asNote = $oNote->getNote();
return self::getJsonResult(($iCourseId > 0), '', array('id'=>$iCourseId, 'ops'=>$asNote['notes'], 'led'=>$asNote['led']));
return self::getJsonResult(!empty($asNote), '', $asNote);
}
public function setNote($iCourseId, $asOps) {
$oCourse = new Course($this->oDb, $iCourseId);
$sError = $oCourse->setNote($asOps);
$oNote = new Note($this->oDb, $this->oAuth->getUserId(), $iCourseId);
$sError = $oNote->setNote($asOps);
$bSuccess = ($sError=='');
return self::getJsonResult(($sError==''), $sError, array('led' => $oCourse->getNote()['led']));
$asData = ($bSuccess)?array('led' => $oNote->getNote()['led']):array();
return self::getJsonResult($bSuccess, $sError, $asData);
}
/*