merge branch ?charactergroupsqueststations?
This commit is contained in:
parent
ba97244b15
commit
76ba31c04e
18 changed files with 351 additions and 84 deletions
|
|
@ -384,9 +384,11 @@
|
|||
* @param array $groupsgroupIds Mapping of Character groups-group-IDs from source Seminary to target Seminary
|
||||
* @param array $questgroupIds Mapping of Questgroup-IDs from source Seminary to target Seminary
|
||||
* @param array $seminaryMediaIds Mapping of Seminarymedia-IDs from source Seminary to target Seminary (optional)
|
||||
* @return array Mapping of Quest-IDs from source Seminary to target Seminary
|
||||
*/
|
||||
public function copyQuestsOfSeminary($userId, $groupsgroupIds, $questgroupIds, $seminaryMediaIds=null)
|
||||
{
|
||||
$questIds = array();
|
||||
foreach($groupsgroupIds as $sourceGroupsgroupId => $targetGroupsgroupId)
|
||||
{
|
||||
// Get Quests
|
||||
|
|
@ -406,7 +408,7 @@
|
|||
$userId, $targetGroupsgroupId, $questgroupIds[$quest['questgroups_id']],
|
||||
$quest['id']
|
||||
);
|
||||
$targetQuestId = $this->db->getInsertId();
|
||||
$questIds[$quest['id']] = $this->db->getInsertId();
|
||||
|
||||
// Copy media
|
||||
if(!is_null($seminaryMediaIds) && !is_null($quest['questsmedia_id']))
|
||||
|
|
@ -418,11 +420,18 @@
|
|||
'WHERE id = ?',
|
||||
'ii',
|
||||
$seminaryMediaIds[$quest['questsmedia_id']],
|
||||
$targetQuestId
|
||||
$questIds[$quest['id']]
|
||||
);
|
||||
}
|
||||
|
||||
// TODO Copy Stations
|
||||
//$this->Charactergroupsqueststations->copyStationsOfQuest($quest['id'], $targetQuestId, $seminaryMediaIds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return target Quest-IDs
|
||||
return $questIds;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,13 @@
|
|||
*/
|
||||
const STATUS_SOLVED = 3;
|
||||
|
||||
/**
|
||||
* Required models
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('stationtypes');
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -103,6 +110,7 @@
|
|||
return $data[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all Stations for a Character groups Quest.
|
||||
*
|
||||
|
|
@ -112,7 +120,7 @@
|
|||
public function getStationsForQuest($questId)
|
||||
{
|
||||
return $this->db->query(
|
||||
'SELECT id, title, url, stationpicture_id, latitude, longitude '.
|
||||
'SELECT id, stationtype_id, title, url, stationpicture_id, latitude, longitude, rightimage_id, rightav_id, wrongimage_id, wrongav_id '.
|
||||
'FROM charactergroupsqueststations '.
|
||||
'WHERE charactergroupsquest_id = ? '.
|
||||
'ORDER BY pos ASC',
|
||||
|
|
@ -123,28 +131,84 @@
|
|||
|
||||
|
||||
/**
|
||||
* Get all Stations for a Character groups Quest and a Character group.
|
||||
* Get all Stations for a Character groups Quest that have been entered
|
||||
* by a Character group.
|
||||
*
|
||||
* @param int $questId ID of Character groups Quest
|
||||
* @param int $groupId ID of Character group
|
||||
* @return array List of Station
|
||||
*/
|
||||
public function getStationsForQuestAndGroup($questId, $groupId)
|
||||
private function getEnteredStationsForQuestAndGroup($questId, $groupId)
|
||||
{
|
||||
return $this->db->query(
|
||||
'SELECT charactergroupsqueststations.id, charactergroupsqueststations_charactergroups.created, title, url, stationpicture_id, latitude, longitude '.
|
||||
'FROM charactergroupsqueststations_charactergroups '.
|
||||
'INNER JOIN charactergroupsqueststations ON charactergroupsqueststations.id = charactergroupsqueststations_charactergroups.charactergroupsqueststation_id '.
|
||||
'WHERE '.
|
||||
'charactergroupsqueststations_charactergroups.charactergroup_id = ? AND '.
|
||||
'charactergroupsqueststations_charactergroups.status = ? AND '.
|
||||
'charactergroupsquest_id = ? '.
|
||||
'ORDER BY charactergroupsqueststations_charactergroups.created ASC',
|
||||
'iii',
|
||||
$groupId,
|
||||
self::STATUS_ENTERED,
|
||||
$questId
|
||||
);
|
||||
return $this->getStationsForQuestAndGroup($questId, $groupId, self::STATUS_ENTERED);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all Stations for a Character groups Quest that have been solved
|
||||
* by a Character group.
|
||||
*
|
||||
* @param int $questId ID of Character groups Quest
|
||||
* @param int $groupId ID of Character group
|
||||
* @return array List of Station
|
||||
*/
|
||||
public function getSolvedStationsForQuestAndGroup($questId, $groupId)
|
||||
{
|
||||
return $this->getStationsForQuestAndGroup($questId, $groupId, self::STATUS_SOLVED);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy all Character groups Quest Stations of a Seminary.
|
||||
*
|
||||
* @param int $userId ID of creating user
|
||||
* @param array $charactergroupsquestIds Mapping of Character groups Quest-IDs from source Seminary to target Seminary
|
||||
* @param array $seminaryMediaIds Mapping of Seminary-media-IDs from source Seminary to target Seminary (optional)
|
||||
*/
|
||||
public function copyStationsOfSeminary($userId, $charactergroupsquestIds, $seminaryMediaIds)
|
||||
{
|
||||
// Go through each Quest
|
||||
foreach($charactergroupsquestIds as $sourceQuestId => $targetQuestId)
|
||||
{
|
||||
// Get Stations
|
||||
$stations = $this->getStationsForQuest($sourceQuestId);
|
||||
|
||||
// Copy each station
|
||||
foreach($stations as &$station)
|
||||
{
|
||||
// Copy Station
|
||||
$this->db->query(
|
||||
'INSERT INTO charactergroupsqueststations '.
|
||||
'(charactergroupsquest_id, stationtype_id, title, url, pos, stationpicture_id, prolog, task, latitude, longitude, righttext, wrongtext, rightimage_id, rightav_id, wrongimage_id, wrongav_id) '.
|
||||
'SELECT ?, stationtype_id, title, url, pos, ?, prolog, task, latitude, longitude, righttext, wrongtext, ?, ?, ?, ? '.
|
||||
'FROM charactergroupsqueststations '.
|
||||
'WHERE id = ?',
|
||||
'iiiiiii',
|
||||
$targetQuestId,
|
||||
(!is_null($station['stationpicture_id'])) ? $seminaryMediaIds[$station['stationpicture_id']] : null,
|
||||
(!is_null($station['rightimage_id'])) ? $seminaryMediaIds[$station['rightimage_id']] : null,
|
||||
(!is_null($station['rightav_id'])) ? $seminaryMediaIds[$station['rightav_id']] : null,
|
||||
(!is_null($station['wrongimage_id'])) ? $seminaryMediaIds[$station['wrongimage_id']] : null,
|
||||
(!is_null($station['wrongav_id'])) ? $seminaryMediaIds[$station['wrongav_id']] : null,
|
||||
$station['id']
|
||||
);
|
||||
$targetStationId = $this->db->getInsertId();
|
||||
|
||||
// Copy content
|
||||
$stationtype = $this->Stationtypes->getStationtypeById($station['stationtype_id']);
|
||||
if(!is_null($stationtype['classname']))
|
||||
{
|
||||
// Load Stationtype Model
|
||||
\hhu\z\models\StationtypeModel::load($stationtype['classname']);
|
||||
|
||||
// Construct Station Model
|
||||
$stationtypeModel = \hhu\z\models\StationtypeModel::factory($stationtype['classname']);
|
||||
|
||||
// Copy content
|
||||
$stationtypeModel->copyStation($userId, $station['id'], $targetStationId, $seminaryMediaIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -508,6 +572,33 @@
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all Stations for a Character groups Quest with a minimum status.
|
||||
*
|
||||
* @param int $questId ID of Character groups Quest
|
||||
* @param int $groupId ID of Character group
|
||||
* @param int $statusMin Minimum status
|
||||
* @return array List of Station
|
||||
*/
|
||||
private function getStationsForQuestAndGroup($questId, $groupId, $statusMin)
|
||||
{
|
||||
return $this->db->query(
|
||||
'SELECT charactergroupsqueststations.id, charactergroupsqueststations_charactergroups.created, title, url, stationpicture_id, latitude, longitude '.
|
||||
'FROM charactergroupsqueststations_charactergroups '.
|
||||
'INNER JOIN charactergroupsqueststations ON charactergroupsqueststations.id = charactergroupsqueststations_charactergroups.charactergroupsqueststation_id '.
|
||||
'WHERE '.
|
||||
'charactergroupsqueststations_charactergroups.charactergroup_id = ? AND '.
|
||||
'charactergroupsqueststations_charactergroups.status >= ? AND '.
|
||||
'charactergroupsquest_id = ? '.
|
||||
'ORDER BY charactergroupsqueststations_charactergroups.created ASC',
|
||||
'iii',
|
||||
$groupId,
|
||||
$statusMin,
|
||||
$questId
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public $models = array('questgroupshierarchy', 'questgroups', 'quests', 'questtopics', 'media', 'characters', 'charactertypes', 'xplevels', 'avatars', 'achievements', 'charactergroups', 'charactergroupsquests', 'seminarycharacterfields', 'map', 'uploads');
|
||||
public $models = array('questgroupshierarchy', 'questgroups', 'quests', 'questtopics', 'media', 'characters', 'charactertypes', 'xplevels', 'avatars', 'achievements', 'charactergroups', 'charactergroupsquests', 'charactergroupsqueststations', 'seminarycharacterfields', 'map', 'uploads');
|
||||
|
||||
|
||||
|
||||
|
|
@ -328,27 +328,28 @@
|
|||
/**
|
||||
* Copy a Seminary and its content.
|
||||
*
|
||||
* @param int $userId ID of copying user
|
||||
* @param int $sourceSeminaryId ID of Seminary to copy
|
||||
* @param string $title Title of new Seminary
|
||||
* @param string $course Course of now Seminary
|
||||
* @param string $description Description of new Seminary
|
||||
* @param boolean $copySeminaryfields Whether to copy Seminary Character fields of not
|
||||
* @param boolean $copyMedia Whether to copy media or not
|
||||
* @param boolean $copyQuestgroupshierarchy Whether to copy Questgroupshierarchy or not
|
||||
* @param boolean $copyQuestgroups Whether to copy Questgroups or not
|
||||
* @param boolean $copyQuests Whether to copy Quests or not
|
||||
* @param boolean $copyQuesttopics Whether to copy Quest topics or not
|
||||
* @param boolean $copyCharactertypes Whether to copy Charactertypes or not
|
||||
* @param boolean $copyXPlevels Whether to copy XP-levels or not
|
||||
* @param boolean $copyAvatars Whether to copy Avatars or not
|
||||
* @param boolean $copyAchievements Whether to copy Achievements or not
|
||||
* @param boolean $copyCharactergroupsgroups Whether to copy Character groups-groups or not
|
||||
* @param boolean $copyCharactergroupsquests Whether to copy Character groups Quests or not
|
||||
* @param boolean $copyMap Whether to copy Map or not
|
||||
* @return ID of newly created Seminary
|
||||
* @param int $userId ID of copying user
|
||||
* @param int $sourceSeminaryId ID of Seminary to copy
|
||||
* @param string $title Title of new Seminary
|
||||
* @param string $course Course of now Seminary
|
||||
* @param string $description Description of new Seminary
|
||||
* @param boolean $copySeminaryfields Whether to copy Seminary Character fields of not
|
||||
* @param boolean $copyMedia Whether to copy media or not
|
||||
* @param boolean $copyQuestgroupshierarchy Whether to copy Questgroupshierarchy or not
|
||||
* @param boolean $copyQuestgroups Whether to copy Questgroups or not
|
||||
* @param boolean $copyQuests Whether to copy Quests or not
|
||||
* @param boolean $copyQuesttopics Whether to copy Quest topics or not
|
||||
* @param boolean $copyCharactertypes Whether to copy Charactertypes or not
|
||||
* @param boolean $copyXPlevels Whether to copy XP-levels or not
|
||||
* @param boolean $copyAvatars Whether to copy Avatars or not
|
||||
* @param boolean $copyAchievements Whether to copy Achievements or not
|
||||
* @param boolean $copyCharactergroupsgroups Whether to copy Character groups-groups or not
|
||||
* @param boolean $copyCharactergroupsquests Whether to copy Character groups Quests or not
|
||||
* @param boolean $copyCharactergroupsqueststations Whether to copy Character groups Quest Stations or not
|
||||
* @param boolean $copyMap Whether to copy Map or not
|
||||
* @return ID of newly created Seminary
|
||||
*/
|
||||
public function copySeminary($userId, $sourceSeminaryId, $title, $course, $description, $copySeminaryfields, $copyMedia, $copyQuestgroupshierarchy, $copyQuestgroups, $copyQuests, $copyQuesttopics, $copyCharactertypes, $copyXPlevels, $copyAvatars, $copyAchievements, $copyCharactergroupsgroups, $copyCharactergroupsquests, $copyMap)
|
||||
public function copySeminary($userId, $sourceSeminaryId, $title, $course, $description, $copySeminaryfields, $copyMedia, $copyQuestgroupshierarchy, $copyQuestgroups, $copyQuests, $copyQuesttopics, $copyCharactertypes, $copyXPlevels, $copyAvatars, $copyAchievements, $copyCharactergroupsgroups, $copyCharactergroupsquests, $copyCharactergroupsqueststations, $copyMap)
|
||||
{
|
||||
// Get Seminary
|
||||
$seminary = $this->getSeminaryById($sourceSeminaryId);
|
||||
|
|
@ -437,12 +438,17 @@
|
|||
|
||||
// Copy Charactergroups content
|
||||
// Charactergroupsgroups
|
||||
$characterGroupsgroupIds = null;
|
||||
$charactergroupsquestIds = null;
|
||||
if($copyCharactergroupsgroups)
|
||||
{
|
||||
$characterGroupsgroupIds = $this->Charactergroups->copyGroupsgroupsOfSeminary($userId, $sourceSeminaryId, $targetSeminaryId);
|
||||
// Copy Charactergroupsquests
|
||||
if($copyCharactergroupsquests &!is_null($questgroupIds)) {
|
||||
$this->Charactergroupsquests->copyQuestsOfSeminary($userId, $characterGroupsgroupIds, $questgroupIds, $seminaryMediaIds);
|
||||
$charactergroupsquestIds = $this->Charactergroupsquests->copyQuestsOfSeminary($userId, $characterGroupsgroupIds, $questgroupIds, $seminaryMediaIds);
|
||||
if($copyCharactergroupsqueststations && !is_null($charactergroupsquestIds)) {
|
||||
$this->Charactergroupsqueststations->copyStationsOfSeminary($userId, $charactergroupsquestIds, $seminaryMediaIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue