add media to right/wrong text of Character group Quest Stations
This commit is contained in:
parent
2d65b2e4b0
commit
efd304833c
8 changed files with 547 additions and 22 deletions
|
|
@ -63,7 +63,7 @@
|
|||
public function getStationById($stationId)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT id, charactergroupsquest_id, stationtype_id, title, url, stationpicture_id, prolog, task, latitude, longitude, righttext, wrongtext '.
|
||||
'SELECT id, charactergroupsquest_id, stationtype_id, title, url, stationpicture_id, prolog, task, latitude, longitude, righttext, wrongtext, rightimage_id, rightav_id, wrongimage_id, wrongav_id '.
|
||||
'FROM charactergroupsqueststations '.
|
||||
'WHERE id = ?',
|
||||
'i',
|
||||
|
|
@ -88,7 +88,7 @@
|
|||
public function getStationByUrl($groupsquestId, $stationUrl)
|
||||
{
|
||||
$data = $this->db->query(
|
||||
'SELECT id, charactergroupsquest_id, stationtype_id, title, url, stationpicture_id, prolog, task, latitude, longitude, righttext, wrongtext '.
|
||||
'SELECT id, charactergroupsquest_id, stationtype_id, title, url, stationpicture_id, prolog, task, latitude, longitude, righttext, wrongtext, rightimage_id, rightav_id, wrongimage_id, wrongav_id '.
|
||||
'FROM charactergroupsqueststations '.
|
||||
'WHERE charactergroupsquest_id = ? AND url = ?',
|
||||
'is',
|
||||
|
|
@ -296,7 +296,7 @@
|
|||
* @param int $stationId ID of Station to upload media for
|
||||
* @param int $mediaId ID of Station media
|
||||
*/
|
||||
public function setPictureForStation($station, $mediaId)
|
||||
public function setPictureForStation($stationId, $mediaId)
|
||||
{
|
||||
$this->db->query(
|
||||
'UPDATE charactergroupsqueststations '.
|
||||
|
|
@ -304,11 +304,59 @@
|
|||
'WHERE id = ?',
|
||||
'ii',
|
||||
$mediaId,
|
||||
$station
|
||||
$stationId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the image for the right-text.
|
||||
*
|
||||
* @param int $stationId ID of Station to set image for
|
||||
* @param int $mediaId ID of Seminary media to set
|
||||
*/
|
||||
public function setRightImageForStation($stationId, $mediaId)
|
||||
{
|
||||
$this->setMediaForStation($stationId, $mediaId, 'rightimage_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the audio/video for the right-text.
|
||||
*
|
||||
* @param int $stationId ID of Station to set audio/video for
|
||||
* @param int $mediaId ID of Seminary media to set
|
||||
*/
|
||||
public function setRightAVForStation($stationId, $mediaId)
|
||||
{
|
||||
$this->setMediaForStation($stationId, $mediaId, 'rightav_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the image for the wrong-text.
|
||||
*
|
||||
* @param int $stationId ID of Station to set image for
|
||||
* @param int $mediaId ID of Seminary media to set
|
||||
*/
|
||||
public function setWrongImageForStation($stationId, $mediaId)
|
||||
{
|
||||
$this->setMediaForStation($stationId, $mediaId, 'wrongimage_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the audio/video for the wrong-text.
|
||||
*
|
||||
* @param int $stationId ID of Station to set audio/video for
|
||||
* @param int $mediaId ID of Seminary media to set
|
||||
*/
|
||||
public function setWrongAvForStation($stationId, $mediaId)
|
||||
{
|
||||
$this->setMediaForStation($stationId, $mediaId, 'wrongav_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Character groups Quest Station.
|
||||
*
|
||||
|
|
@ -437,6 +485,29 @@
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a medium for a Character groups Quest Station.
|
||||
*
|
||||
* @param int $stationId ID of Station to upload media for
|
||||
* @param int $mediaId ID of Seminary media
|
||||
* @param string $field Field name to set media to
|
||||
*/
|
||||
private function setMediaForStation($stationId, $mediaId, $field)
|
||||
{
|
||||
$this->db->query(
|
||||
sprintf(
|
||||
'UPDATE charactergroupsqueststations '.
|
||||
'SET %s = ? '.
|
||||
'WHERE id = ?',
|
||||
$field
|
||||
),
|
||||
'ii',
|
||||
$mediaId,
|
||||
$stationId
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -557,6 +557,46 @@
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Character groups Quest Station media by creating a new
|
||||
* Seminarymedia .
|
||||
*
|
||||
* @param int $userId ID of user that does the upload
|
||||
* @param int $seminaryId ID of Seminary
|
||||
* @param string $filename Filename of uploading media
|
||||
* @param string $description Description for media
|
||||
* @param string $mimetype Mimetype of media
|
||||
* @param string $tmpFilename Name of temporary uploaded file
|
||||
* @return mixed ID of media record or false if upload failed
|
||||
*/
|
||||
public function createStationMedia($userId, $seminaryId, $filename, $description, $mimetype, $tmpFilename)
|
||||
{
|
||||
$mediaId = false;
|
||||
$this->db->setAutocommit(false);
|
||||
|
||||
try {
|
||||
// Create Seminary media record
|
||||
$mediaId = $this->createSeminaryMedia($userId, $seminaryId, $filename, $description, $mimetype);
|
||||
|
||||
// Create filename
|
||||
$filename = ROOT.DS.\nre\configs\AppConfig::$dirs['seminarymedia'].DS.$mediaId;
|
||||
if(!move_uploaded_file($tmpFilename, $filename))
|
||||
{
|
||||
$this->db->rollback();
|
||||
$mediaId = false;
|
||||
}
|
||||
}
|
||||
catch(\nre\exceptions\DatamodelException $e) {
|
||||
$this->db->rollback();
|
||||
$this->db->setAutocommit(true);
|
||||
}
|
||||
|
||||
|
||||
$this->db->setAutocommit(true);
|
||||
return $mediaId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new Achievement media by creating a new Seminarymedia and
|
||||
* adding it to the list of media for Achievements.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue