Quantcast
Channel: Backup and restore
Viewing all articles
Browse latest Browse all 6511

Re: duplicate news forum on backup/restore/import

$
0
0
by steve miley.  

This is a patch I've deployed to solve this problem of offering the news forum as an item to backup/restore. 

Basically a mod to not display any forum of type news in the user interface for the backup.

Mods done to the file - 

backup/util/dbops/backup_plan_dbops.class.php

 

git diff util/dbops/backup_plan_dbops.class.php

diff --git a/backup/util/dbops/backup_plan_dbops.class.php b/backup/util/dbops/backup_plan_dbops.class.php

index 2e2faae..578b75e 100644

--- a/backup/util/dbops/backup_plan_dbops.class.php

+++ b/backup/util/dbops/backup_plan_dbops.class.php

@@ -83,15 +83,28 @@ abstract class backup_plan_dbops extends backup_dbops {

         // Get all course modules belonging to requested section

         $modulesarr = array();

         $modules = $DB->get_records_sql("

-            SELECT cm.id, m.name AS modname

+            SELECT cm.id, m.name AS modname, cm.module as m

               FROM {course_modules} cm

               JOIN {modules} m ON m.id = cm.module

-             WHERE cm.course = ?

+             WHERE  cm.course = ?

                AND cm.section = ?", array($courseid, $sectionid));

         foreach (explode(',', $sequence) as $moduleid) {

             if (isset($modules[$moduleid])) {

                 $module = array('id' => $modules[$moduleid]->id, 'modname' => $modules[$moduleid]->modname);

-                $modulesarr[] = (object)$module;

+               if ( $modules[$moduleid]->m != 9 ) {

+                       $modulesarr[] = (object)$module;

+               } else { 

+// Do check to make sure this is not a news forum

+                       $forumtype = $DB->record_exists_sql("

+                                       SELECT cm.id, f.type AS forumtype

+                                       FROM {course_modules} cm

+                                       JOIN {forum} f ON f.id = cm.instance

+                                       WHERE  cm.id = ?  AND f.type != ? ",  array($modules[$moduleid]->id,'news'));

+                       if ($forumtype) { 

+                               $modulesarr[] = (object)$module;

+                       }

+               }

+

                 unset($modules[$moduleid]);

             }

         }


Viewing all articles
Browse latest Browse all 6511

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>