implement clean deletion of Seminaries
This commit is contained in:
parent
4dca3e8089
commit
60b7f12f79
25 changed files with 410 additions and 9 deletions
|
|
@ -34,6 +34,14 @@
|
||||||
public abstract function copyQuest($userId, $sourceQuestId, $targetQuestId, $seminaryMediaIds);
|
public abstract function copyQuest($userId, $sourceQuestId, $targetQuestId, $seminaryMediaIds);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete
|
||||||
|
*/
|
||||||
|
public abstract function deleteQuest($questId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a Model.
|
* Load a Model.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ CREATE TABLE `avatarpictures` (
|
||||||
PRIMARY KEY (`seminarymedia_id`),
|
PRIMARY KEY (`seminarymedia_id`),
|
||||||
KEY `created_user_id` (`created_user_id`),
|
KEY `created_user_id` (`created_user_id`),
|
||||||
CONSTRAINT `avatarpictures_ibfk_2` FOREIGN KEY (`created_user_id`) REFERENCES `users` (`id`),
|
CONSTRAINT `avatarpictures_ibfk_2` FOREIGN KEY (`created_user_id`) REFERENCES `users` (`id`),
|
||||||
CONSTRAINT `avatarpictures_ibfk_3` FOREIGN KEY (`seminarymedia_id`) REFERENCES `seminarymedia` (`id`)
|
CONSTRAINT `avatarpictures_ibfk_3` FOREIGN KEY (`seminarymedia_id`) REFERENCES `seminarymedia` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
|
@ -847,8 +847,8 @@ CREATE TABLE `questgroups_questgroupshierarchy` (
|
||||||
KEY `parent_questgoup_id` (`parent_questgroup_id`),
|
KEY `parent_questgoup_id` (`parent_questgroup_id`),
|
||||||
KEY `questgroupshierarchy_id` (`questgroupshierarchy_id`),
|
KEY `questgroupshierarchy_id` (`questgroupshierarchy_id`),
|
||||||
CONSTRAINT `questgroups_questgroupshierarchy_ibfk_1` FOREIGN KEY (`questgroup_id`) REFERENCES `questgroups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
CONSTRAINT `questgroups_questgroupshierarchy_ibfk_1` FOREIGN KEY (`questgroup_id`) REFERENCES `questgroups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
CONSTRAINT `questgroups_questgroupshierarchy_ibfk_2` FOREIGN KEY (`questgroupshierarchy_id`) REFERENCES `questgroupshierarchy` (`id`),
|
CONSTRAINT `questgroups_questgroupshierarchy_ibfk_2` FOREIGN KEY (`questgroupshierarchy_id`) REFERENCES `questgroupshierarchy` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
CONSTRAINT `questgroups_questgroupshierarchy_ibfk_3` FOREIGN KEY (`parent_questgroup_id`) REFERENCES `questgroups` (`id`)
|
CONSTRAINT `questgroups_questgroupshierarchy_ibfk_3` FOREIGN KEY (`parent_questgroup_id`) REFERENCES `questgroups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
|
@ -865,8 +865,8 @@ CREATE TABLE `questgroups_questtexts` (
|
||||||
`entry_text` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
`entry_text` text COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||||
PRIMARY KEY (`questgroup_id`,`questtext_id`),
|
PRIMARY KEY (`questgroup_id`,`questtext_id`),
|
||||||
KEY `questtext_id` (`questtext_id`),
|
KEY `questtext_id` (`questtext_id`),
|
||||||
CONSTRAINT `questgroups_questtexts_ibfk_1` FOREIGN KEY (`questgroup_id`) REFERENCES `questgroups` (`id`),
|
CONSTRAINT `questgroups_questtexts_ibfk_1` FOREIGN KEY (`questgroup_id`) REFERENCES `questgroups` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
CONSTRAINT `questgroups_questtexts_ibfk_2` FOREIGN KEY (`questtext_id`) REFERENCES `questtexts` (`id`)
|
CONSTRAINT `questgroups_questtexts_ibfk_2` FOREIGN KEY (`questtext_id`) REFERENCES `questtexts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1402,6 +1402,18 @@
|
||||||
$this->db->setAutocommit(true);
|
$this->db->setAutocommit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Achievements of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete Achievements of
|
||||||
|
*/
|
||||||
|
public function deleteAchievementsOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
// Delete Achievements
|
||||||
|
$this->db->query('DELETE FROM achievements WHERE seminary_id = ?', 'i', $seminaryId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Avatars.
|
||||||
|
*
|
||||||
|
* @param array $charactertypeIds List of Charactertype-IDs to delete Avatars of
|
||||||
|
* @param array $xplevelIds List of XP-level-IDs to delete Avatars of
|
||||||
|
*/
|
||||||
|
public function deleteAvatars($charactertypeIds, $xplevelIds)
|
||||||
|
{
|
||||||
|
$this->db->query(
|
||||||
|
sprintf(
|
||||||
|
'DELETE FROM avatars '.
|
||||||
|
'WHERE charactertype_id IN (%s) OR xplevel_id IN (%s)',
|
||||||
|
implode(',', $charactertypeIds),
|
||||||
|
implode(',', $xplevelIds)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,12 @@
|
||||||
*/
|
*/
|
||||||
class CharactergroupsModel extends \hhu\z\Model
|
class CharactergroupsModel extends \hhu\z\Model
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Required models
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
public $models = array('charactergroupsquests');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -225,6 +231,31 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Character groups-groups of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete Character groups-groups of
|
||||||
|
*/
|
||||||
|
public function deleteGroupsgroupsOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
// Get Groupsgroups
|
||||||
|
$charactergroupsgroups = $this->getGroupsroupsForSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Delete each Groupsgroup
|
||||||
|
foreach($charactergroupsgroups as $groupsgroup)
|
||||||
|
{
|
||||||
|
// Delete Groups
|
||||||
|
$this->deleteGroupsOfGroupsgroup($groupsgroup['id']);
|
||||||
|
|
||||||
|
// Delete Groupsquests
|
||||||
|
$this->Charactergroupsquests->deleteQuestsOfGroupsgroup($groupsgroup['id']);
|
||||||
|
|
||||||
|
// Delete Groupsgroup
|
||||||
|
$this->db->query('DELETE FROM charactergroupsgroups WHERE seminary_id = ?', 'i', $seminaryId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Character groups for a Character groups-group.
|
* Get Character groups for a Character groups-group.
|
||||||
*
|
*
|
||||||
|
|
@ -475,6 +506,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Character groups of a groups-group.
|
||||||
|
*
|
||||||
|
* @param int $groupsgroupId ID of Character groups-group to delete groups of
|
||||||
|
*/
|
||||||
|
public function deleteGroupsOfGroupsgroup($groupsgroupId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM charactergroups WHERE charactergroupsgroup_id = ?', 'i', $groupsgroupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the rank of a XP-value of a Character.
|
* Get the rank of a XP-value of a Character.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -437,6 +437,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Character groups Quests of a Character groups-group.
|
||||||
|
*
|
||||||
|
* @param int $groupsgroupId ID of Character groups-group to delete Quests of
|
||||||
|
*/
|
||||||
|
public function deleteQuestsOfGroupsgroup($groupsgroupId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM charactergroupsquests WHERE charactergroupsgroup_id = ?', 'i', $groupsgroupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,17 @@
|
||||||
$this->db->query('DELETE FROM charactertypes WHERE id = ?', 'i', $charactertypeId);
|
$this->db->query('DELETE FROM charactertypes WHERE id = ?', 'i', $charactertypeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Charactertypes of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete Charactertypes of
|
||||||
|
*/
|
||||||
|
public function deleteCharactertypesOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM charactertypes WHERE seminary_id = ?', 'i', $seminaryId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@
|
||||||
public function deleteMapOfSeminary($seminaryId)
|
public function deleteMapOfSeminary($seminaryId)
|
||||||
{
|
{
|
||||||
// Get map
|
// Get map
|
||||||
$map = $this->getMap($seminaryId);
|
$map = $this->getMapOfSeminary($seminaryId);
|
||||||
if(is_null($map)) {
|
if(is_null($map)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -200,6 +200,35 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all media of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete media of
|
||||||
|
*/
|
||||||
|
public function deleteSeminaryMediaOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
// Get all media from a Seminary
|
||||||
|
$seminaryMedia = $this->db->query(
|
||||||
|
'SELECT id '.
|
||||||
|
'FROM seminarymedia '.
|
||||||
|
'WHERE seminary_id = ?',
|
||||||
|
'i',
|
||||||
|
$seminaryId
|
||||||
|
);
|
||||||
|
|
||||||
|
// Delete each medium
|
||||||
|
foreach($seminaryMedia as &$medium)
|
||||||
|
{
|
||||||
|
// Delete file
|
||||||
|
$filename = ROOT.DS.\nre\configs\AppConfig::$dirs['seminarymedia'].DS.$medium['id'];
|
||||||
|
@unlink($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete database entries
|
||||||
|
$this->db->query('DELETE FROM seminarymedia WHERE seminary_id = ?', 'i', $seminaryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new moodpic.
|
* Create a new moodpic.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -749,6 +749,28 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Questgroups of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete Questgroups of
|
||||||
|
*/
|
||||||
|
public function deleteQuestgroupsOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
// Get Questgroups
|
||||||
|
$questgroups = $this->getQuestgroupsForSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Delete each Questgroup
|
||||||
|
foreach($questgroups as &$questgroup)
|
||||||
|
{
|
||||||
|
// Delete Questgroup texts
|
||||||
|
$this->Questgrouptexts->deleteQuestgrouptexts($questgroup['id']);
|
||||||
|
|
||||||
|
// Delete Questgroup
|
||||||
|
$this->db->query('DELETE FROM questgroups WHERE id = ?', 'i', $questgroup['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -339,6 +339,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete complete Questgroupshierarchy of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete Questgroupshierarchy of
|
||||||
|
*/
|
||||||
|
public function deleteQuestgroupshierarchyOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questgroupshierarchy WHERE seminary_id = ?', 'i', $seminaryId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,17 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Questgroup texts of a Questgroup.
|
||||||
|
*
|
||||||
|
* @param int $questgroupId ID of Questgroup to delete texts of
|
||||||
|
*/
|
||||||
|
public function deleteQuestgrouptexts($questgroupId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questgrouptexts WHERE questgroup_id = ?', 'i', $questgroupId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -813,6 +813,42 @@
|
||||||
$this->db->setAutocommit(true);
|
$this->db->setAutocommit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Quests of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete all Quests of
|
||||||
|
*/
|
||||||
|
public function deleteQuestsOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
// Get Quests
|
||||||
|
$quests = $this->getQuestsForSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Delete each Quest
|
||||||
|
foreach($quests as &$quest)
|
||||||
|
{
|
||||||
|
// Delete content
|
||||||
|
$questtype = $this->Questtypes->getQuesttypeById($quest['questtype_id']);
|
||||||
|
if(!is_null($questtype['classname']))
|
||||||
|
{
|
||||||
|
// Load Questtype Model
|
||||||
|
\hhu\z\models\QuesttypeModel::load($questtype['classname']);
|
||||||
|
|
||||||
|
// Construct Questtype Model
|
||||||
|
$questtypeModel = \hhu\z\models\QuesttypeModel::factory($questtype['classname']);
|
||||||
|
|
||||||
|
// Delete content
|
||||||
|
$questtypeModel->deleteQuest($quest['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete Quests texts
|
||||||
|
$this->Questtexts->deleteQuesttexts($quest['id']);
|
||||||
|
|
||||||
|
// Delete quest
|
||||||
|
$this->db->query('DELETE FROM quests WHERE id = ?', 'i', $quest['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -384,6 +384,17 @@
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Quest texts of a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete all texts of
|
||||||
|
*/
|
||||||
|
public function deleteQuesttexts($questId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questtexts WHERE quest_id = ?', 'i', $questId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -470,6 +470,17 @@
|
||||||
$this->db->query('DELETE FROM questsubtopics WHERE id = ?', 'i', $questtopicId);
|
$this->db->query('DELETE FROM questsubtopics WHERE id = ?', 'i', $questtopicId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Questtopics of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete Questtopics of
|
||||||
|
*/
|
||||||
|
public function deleteQuesttopicsOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questtopics WHERE seminary_id = ?', 'i', $seminaryId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $models = array('questgroupshierarchy', 'questgroups', 'quests', 'questtopics', 'media', 'charactertypes', 'xplevels', 'avatars', 'achievements', 'charactergroups', 'charactergroupsquests', 'seminarycharacterfields', 'map');
|
public $models = array('questgroupshierarchy', 'questgroups', 'quests', 'questtopics', 'media', 'characters', 'charactertypes', 'xplevels', 'avatars', 'achievements', 'charactergroups', 'charactergroupsquests', 'seminarycharacterfields', 'map', 'uploads');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -470,14 +470,65 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a seminary.
|
* Delete a seminary.
|
||||||
* TODO Delete media
|
|
||||||
*
|
*
|
||||||
* @param int $seminaryId ID of the seminary to delete
|
* @param int $seminaryId ID of the seminary to delete
|
||||||
*/
|
*/
|
||||||
public function deleteSeminary($seminaryId)
|
public function deleteSeminary($seminaryId)
|
||||||
{
|
{
|
||||||
|
$this->db->setAutocommit(false);
|
||||||
|
try {
|
||||||
|
// Map
|
||||||
|
$this->Map->deleteMapOfSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Charactergroups content
|
||||||
|
$this->Charactergroups->deleteGroupsgroupsOfSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Achievements
|
||||||
|
$this->Achievements->deleteAchievementsOfSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Character content
|
||||||
|
// Delete Characters
|
||||||
|
$characters = $this->Characters->getCharactersForSeminary($seminaryId);
|
||||||
|
foreach($characters as &$character) {
|
||||||
|
$this->Characters->deleteCharacter($character['id']);
|
||||||
|
}
|
||||||
|
// Delete Avatars
|
||||||
|
$charactertypes = $this->Charactertypes->getCharacterTypesForSeminary($seminaryId);
|
||||||
|
$charactertypeIds = array_map(function($type) { return $type['id']; }, $charactertypes);
|
||||||
|
$xplevels = $this->Xplevels->getXPLevelsForSeminary($seminaryId);
|
||||||
|
$xplevelIds = array_map(function($level) { return $level['id']; }, $xplevels);
|
||||||
|
$this->Avatars->deleteAvatars($charactertypeIds, $xplevelIds);
|
||||||
|
// Delete XP-levels
|
||||||
|
$this->Xplevels->deleteXPLevelsOfSeminary($seminaryId);
|
||||||
|
// Delete Charactertypes
|
||||||
|
$this->Charactertypes->deleteCharactertypesOfSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Delete Quests content
|
||||||
|
// Delete Quest topics
|
||||||
|
$this->Questtopics->deleteQuesttopicsOfSeminary($seminaryId);
|
||||||
|
// Delete Quests
|
||||||
|
$this->Quests->deleteQuestsOfSeminary($seminaryId);
|
||||||
|
// Delete Questgroups
|
||||||
|
$this->Questgroups->deleteQuestgroupsOfSeminary($seminaryId);
|
||||||
|
// Delete Questgroupshierarchy
|
||||||
|
$this->Questgroupshierarchy->deleteQuestgroupshierarchyOfSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Media
|
||||||
|
$this->Media->deleteSeminaryMediaOfSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Uploads
|
||||||
|
$this->Uploads->deleteSeminaryUploadsOfSeminary($seminaryId);
|
||||||
|
|
||||||
|
// Delete Seminary
|
||||||
$this->db->query('DELETE FROM seminaries WHERE id = ?', 'i', $seminaryId);
|
$this->db->query('DELETE FROM seminaries WHERE id = ?', 'i', $seminaryId);
|
||||||
}
|
}
|
||||||
|
catch(\Exception $e) {
|
||||||
|
$this->db->rollback();
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
$this->db->setAutocommit(true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,35 @@
|
||||||
$this->db->setAutocommit(true);
|
$this->db->setAutocommit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all Seminary uploads of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete all Uploads of
|
||||||
|
*/
|
||||||
|
public function deleteSeminaryUploadsOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
// Get all uploads from a Seminary
|
||||||
|
$seminaryUploads = $this->db->query(
|
||||||
|
'SELECT id, url '.
|
||||||
|
'FROM seminaryuploads '.
|
||||||
|
'WHERE seminary_id = ?',
|
||||||
|
'i',
|
||||||
|
$seminaryId
|
||||||
|
);
|
||||||
|
|
||||||
|
// Delete each upload
|
||||||
|
foreach($seminaryUploads as &$upload)
|
||||||
|
{
|
||||||
|
// Delete file
|
||||||
|
$filename = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
|
||||||
|
@unlink($filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete database entries
|
||||||
|
$this->db->query('DELETE FROM seminaryuploads WHERE seminary_id = ?', 'i', $seminaryId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,17 @@
|
||||||
$this->db->setAutocommit(true);
|
$this->db->setAutocommit(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all XP-levels of a Seminary.
|
||||||
|
*
|
||||||
|
* @param int $seminaryId ID of Seminary to delete XP-levels of
|
||||||
|
*/
|
||||||
|
public function deleteXPLevelsOfSeminary($seminaryId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM xplevels WHERE seminary_id = ?', 'i', $seminaryId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete
|
||||||
|
*/
|
||||||
|
public function deleteQuest($questId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questtypes_bossfight WHERE quest_id = ?', 'i', $questId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a Boss-Fight.
|
* Get a Boss-Fight.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete
|
||||||
|
*/
|
||||||
|
public function deleteQuest($questId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questtypes_choiceinput WHERE quest_id = ?', 'i', $questId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get choiceinput-text for a Quest.
|
* Get choiceinput-text for a Quest.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete
|
||||||
|
*/
|
||||||
|
public function deleteQuest($questId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questtypes_crossword_words WHERE quest_id = ?', 'i', $questId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all words for a crossword-Quest.
|
* Get all words for a crossword-Quest.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete
|
||||||
|
*/
|
||||||
|
public function deleteQuest($questId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questtypes_dragndrop WHERE quest_id = ?', 'i', $questId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Drag&Drop field for a Quest.
|
* Create a new Drag&Drop field for a Quest.
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete
|
||||||
|
*/
|
||||||
|
public function deleteQuest($questId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questtypes_multiplechoice WHERE quest_id = ?', 'i', $questId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the count of multiple choice questions for a Quest.
|
* Get the count of multiple choice questions for a Quest.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete
|
||||||
|
*/
|
||||||
|
public function deleteQuest($questId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questtypes_submit_characters WHERE quest_id = ?', 'i', $questId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save Character’s submitted upload.
|
* Save Character’s submitted upload.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a Quest.
|
||||||
|
*
|
||||||
|
* @param int $questId ID of Quest to delete
|
||||||
|
*/
|
||||||
|
public function deleteQuest($questId)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM questtypes_textinput WHERE quest_id = ?', 'i', $questId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get textinput-text for a Quest.
|
* Get textinput-text for a Quest.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue