Assign a doc to a workshop and not a course
This commit is contained in:
19
inc/doc.php
19
inc/doc.php
@@ -12,23 +12,23 @@ class Doc extends PhpObject {
|
||||
|
||||
private $iDocId;
|
||||
private $iUserId;
|
||||
private $iCourseId;
|
||||
private $iWorkshopId;
|
||||
|
||||
public function __construct(Db &$oDb, $iUserId=0, $iCourseId=0)
|
||||
public function __construct(Db &$oDb, $iUserId=0, $iWorkshopId=0)
|
||||
{
|
||||
parent::__construct(__CLASS__, Settings::DEBUG);
|
||||
$this->oDb = &$oDb;
|
||||
$this->setDocId(0);
|
||||
$this->setUserCourseId($iUserId, $iCourseId);
|
||||
$this->setUserWorkshopId($iUserId, $iWorkshopId);
|
||||
}
|
||||
|
||||
public function setDocId($iDocId) {
|
||||
$this->iDocId = $iDocId;
|
||||
}
|
||||
|
||||
public function setUserCourseId($iUserId, $iCourseId) {
|
||||
public function setUserWorkshopId($iUserId, $iWorkshopId) {
|
||||
$this->iUserId = $iUserId;
|
||||
$this->iCourseId = $iCourseId;
|
||||
$this->iWorkshopId = $iWorkshopId;
|
||||
}
|
||||
|
||||
public function exists($sFileName) {
|
||||
@@ -37,6 +37,7 @@ class Doc extends PhpObject {
|
||||
|
||||
public function add($sFileName, $sMimeType) {
|
||||
$sType = '';
|
||||
|
||||
switch(mime_content_type(self::getFilePath($sFileName))) {
|
||||
case 'application/msword':
|
||||
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document': $sType = 'word'; break;
|
||||
@@ -45,11 +46,15 @@ class Doc extends PhpObject {
|
||||
case 'image/gif': $sType = 'image'; break;
|
||||
case 'image/jpeg': $sType = 'image'; break;
|
||||
case 'image/png': $sType = 'image'; break;
|
||||
default:
|
||||
switch(pathinfo($sFileName, PATHINFO_EXTENSION)) {
|
||||
case 'mp3': $sType = 'audio'; break;
|
||||
}
|
||||
}
|
||||
|
||||
$asData = array_merge($this->getDocKeys(), array('filename'=>$sFileName, 'type'=>$sType));
|
||||
|
||||
$bResult = $this->oDb->insertRow(self::DOC_TABLE, $asData);
|
||||
|
||||
return $bResult?'':'error_db';
|
||||
}
|
||||
|
||||
@@ -77,7 +82,7 @@ class Doc extends PhpObject {
|
||||
}
|
||||
|
||||
private function getDocKeys() {
|
||||
return array(Db::getId(Auth::USER_TABLE) => $this->iUserId, Db::getId(Course::COURSE_TABLE) => $this->iCourseId);
|
||||
return array(Db::getId(Auth::USER_TABLE) => $this->iUserId, Db::getId(Course::WS_TABLE) => $this->iWorkshopId);
|
||||
}
|
||||
|
||||
private static function getFilePath($sFileName) {
|
||||
|
||||
Reference in New Issue
Block a user