Workshops page
This commit is contained in:
11
inc/catc.php
11
inc/catc.php
@@ -33,8 +33,8 @@ class CATC extends Main
|
||||
'tables' => array
|
||||
(
|
||||
Auth::USER_TABLE => array(Db::getText(Auth::USER_TABLE), 'nickname', 'pass', 'cookie'),
|
||||
'workshops' => array('dates'),
|
||||
'courses' => array(Db::getId('workshops'), 'description', 'timeslot', 'notes'),
|
||||
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')
|
||||
),
|
||||
@@ -136,7 +136,12 @@ class CATC extends Main
|
||||
return $this->oAuth->checkApiKey($sApiKey);
|
||||
}
|
||||
|
||||
/* Managing projects */
|
||||
/* Managing Courses */
|
||||
|
||||
public function getWorkshops() {
|
||||
return self::getJsonResult(true, '', (new Course($this->oDb))->getWorkshops());
|
||||
}
|
||||
|
||||
/*
|
||||
public function upload()
|
||||
{
|
||||
|
||||
@@ -2,4 +2,34 @@
|
||||
|
||||
class Course extends PhpObject {
|
||||
|
||||
const WS_TABLE = 'workshops';
|
||||
const COURSE_TABLE = 'courses';
|
||||
|
||||
/**
|
||||
* DB
|
||||
* @var Db
|
||||
*/
|
||||
private $oDb;
|
||||
|
||||
public function __construct(Db &$oDb)
|
||||
{
|
||||
parent::__construct(__CLASS__, Settings::DEBUG);
|
||||
$this->oDb = &$oDb;
|
||||
}
|
||||
|
||||
public function getWorkshops() {
|
||||
$asCourses = $this->oDb->selectRows(array(
|
||||
'select'=> array(Db::getId(self::WS_TABLE), 'dates', Db::getId(self::COURSE_TABLE), 'description', 'timeslot'),
|
||||
'from' => self::COURSE_TABLE,
|
||||
'join' => array(self::WS_TABLE => Db::getId(self::WS_TABLE)))
|
||||
);
|
||||
|
||||
$asWorkshops = array();
|
||||
foreach($asCourses as $asCourse) {
|
||||
$asWorkshops[$asCourse[Db::getId(self::WS_TABLE)]]['dates'] = $asCourse['dates'];
|
||||
$asWorkshops[$asCourse[Db::getId(self::WS_TABLE)]]['courses'][$asCourse[Db::getId(self::COURSE_TABLE)]] = array('description'=>$asCourse['description'], 'timeslot'=>$asCourse['timeslot']);
|
||||
}
|
||||
|
||||
return $asWorkshops;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user