From b5687370b3d7c178546fd18a02b1bee0197ce493 Mon Sep 17 00:00:00 2001 From: Rasmus Fuhse <fuhse@data-quest.de> Date: Wed, 18 Dec 2019 10:06:52 +0100 Subject: [PATCH] add avatar copying, KursVorabInfo and bugfixing --- controllers/copy.php | 35 +++++++++++++++++++++++++++++++++++ plugin.manifest | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/controllers/copy.php b/controllers/copy.php index be32261..6a075e6 100755 --- a/controllers/copy.php +++ b/controllers/copy.php @@ -64,6 +64,13 @@ class CopyController extends PluginController } $newcourse->store(); + //copy avatar + if (CourseAvatar::getAvatar($course_id)->is_customized()) { + CourseAvatar::getAvatar($newcourse->getId())->createFrom( + CourseAvatar::getAvatar($course_id)->getFilename(Avatar::NORMAL) + ); + } + //Check if the old course is in at least one course //group ("LV-Gruppe") of the module managemeny system: $course_groups = Lvgruppe::findBySeminar($course_id); @@ -152,8 +159,31 @@ class CopyController extends PluginController $newentry->store(); } + $wanted_course_configs = array("KURSVORABINFO_INFO"); + foreach ($wanted_course_configs as $config) { + if (CourseConfig::get($course_id)->$config) { + CourseConfig::get($newcourse->getId())->store($config, CourseConfig::get($course_id)->$config); + } + } + + if (Request::get("cycles")) { foreach ($oldcourse->cycles as $cycledate) { + + $statement = DBManager::get()->prepare(" + SELECT date_typ + FROM ( + SELECT termine.date_typ, COUNT(*) AS number + FROM termine + WHERE termine.metadate_id = :metadate_id + GROUP BY termine.date_typ + ) AS counter + ORDER BY number DESC + LIMIT 1 + "); + $statement->execute(array('metadate_id' => $cycledate->getId())); + $date_type = $statement->fetch(PDO::FETCH_COLUMN, 0); + $newcycle = new SeminarCycleDate(); $newcycle->setData($cycledate->toArray()); $newcycle->setId($newcycle->getNewId()); @@ -166,6 +196,11 @@ class CopyController extends PluginController $newcycle['chdate'] = time(); $newcycle->store(); + foreach ($newcycle->dates as $newdate) { + $newdate['date_typ'] = $date_type; + $newdate->store(); + } + if (Request::get("resource_assignments")) { $statement = DBManager::get()->prepare(" SELECT resource_id diff --git a/plugin.manifest b/plugin.manifest index 12228a7..27e9c9e 100755 --- a/plugin.manifest +++ b/plugin.manifest @@ -1,6 +1,6 @@ pluginname=CourseCopy pluginclassname=CourseCopy -version=1.3.1 +version=1.4 origin=data-quest studipMinVersion=4.0 studipMaxVersion=4.99.99 \ No newline at end of file -- GitLab