public function getForumsForHierarchy($parentDataItemId) { global $CFG; global $SynchContentHierarchy; // Have the modules been loaded for the parent section? if not load them if (!$SynchContentHierarchy->hasModulesLoaded($parentDataItemId)) { $this->getAndAppendModulesToSection($parentDataItemId); } $parentId = SynchContentHierarchy::getIdFromDataItemId($parentDataItemId); $sectionId = $parentId; $forumIds = $this->getInstanceIdsFromModulesByModuleType($parentDataItemId, '1010000006'); if (!is_array($forumIds)) { return null; } $records = get_records_list("forum", "id", implode(',', $forumIds), null, "id, course, type, name, intro"); if (!$records || !count($records)) { return null; } $contentItems = array(); $contentItem = null; $record = null; foreach ($records as $record) { $contentItem = new SynchContentItem(array('id' => $record->id, 'name' => $record->name, 'description' => $record->intro)); $contentItems[$record->id] = $contentItem; } return $contentItems; }
require_once $CFG->libdir . '/adminlib.php'; //require_once("../config.php"); require_once $CFG->dirroot . '/user/profile/lib.php'; $page = new stdClass(); $id = optional_param('id', 0, PARAM_INT); // user id $hubId = optional_param('hubId', 0, PARAM_INT); // hub id $course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site) $page->action = optional_param('action', 3, PARAM_INT); // action: Create 1, Read 2, Update 3, Delete 4 $page->server = new synch_modal_Server(); $page->updated = false; $defaultReturnUrl = '/synch/find_content.php'; $hubId = SynchContentHierarchy::getIdFromDataItemId($hubId); // Convert the dataItemId to an id $page->server->serverId = $hubId; admin_externalpage_setup('mnetpeers'); if (empty($id)) { // See your own profile by default require_login(); $id = $USER->id; } if (!($user = get_record("user", "id", $id))) { error("No such user in this course"); } if (!($course = get_record("course", "id", $course))) { error("No such course id"); } // Course is site for now. Get the context
public function restoreMergedBackup($dataItemId, $files, $session) { global $CFG; $page = new stdClass(); //Move the merged backup file from the session folder to the course folder // Move the backups from the course directory into synch/sessions/sessionid/backups with the serverid appended the file name // Generate a new file name from the original backup file and the local server id //$newFileName = $this->createSessionBackupFileName($preferences); $sessionBackupFileName = $files['merged']; // Generate the path to the session backup folder $sessionBackupPath = $this->createSessionBackupPath($session); // Does the merge file exist if (!FileSystem::exists($sessionBackupPath . '/' . $sessionBackupFileName, 'f')) { return false; } // Move the session merge file to the course backup folder. if (1) { // fudge for testing in development $courseBackupFileName = FileSystem::removeFromFileName($sessionBackupFileName, $CFG->synch->merge_file_suffix); $courseBackupFileName = FileSystem::removeFromFileName($courseBackupFileName, synch_backup_controller::getUniqueCodeFromFileName($sessionBackupFileName)); // Do we need to update the file name within the preferences. We will be passing // the file name and from then on it shouldn't be required. $courseId = SynchContentHierarchy::getIdFromDataItemId($dataItemId); $courseBackupPath = synch_Backup_controller::createBackupFilePath($courseId); // Create the folder structure if necessary FileSystem::createFoldersFromPath($courseBackupPath); $moved = FileSystem::copyFile($sessionBackupPath . '/' . $sessionBackupFileName, $courseBackupPath . '/' . $courseBackupFileName); } else { $moved = true; } if (!$moved) { return false; } $preferences = new Object(); $preferences->course_id = $courseId; $preferences->backup_name = $courseBackupFileName; $preferences->backup_unique_code = synch_backup_controller::getUniqueCodeFromFileName($sessionBackupFileName); global $SynchServerController; // If there are changes from the remote Moodle restore to the local Moodle $remoteServerId = $SynchServerController->getRemoteServerId(); if ($this->getSessionHasChangesByServerId($remoteServerId, $session)) { // Call the restoreCourse method of SynchBackupController $restored = synch_backup_controller::restoreCourse($preferences, $session); } return $restored; }