foreach ($downloadablecourses as $downloadablecourse) { $hubcourseids[] = $downloadablecourse->hubcourseid; } } } //unpublish the courses by web service if (!empty($hubcourseids)) { $function = 'hub_unregister_courses'; $params = array('courseids' => $hubcourseids); $serverurl = $huburl . "/local/hub/webservice/webservices.php"; $xmlrpcclient = new webservice_xmlrpc_client($serverurl, $hub->token); try { $result = $xmlrpcclient->call($function, $params); //delete the published courses if (!empty($enrollablecourses)) { $publicationmanager->delete_hub_publications($huburl, 1); } if (!empty($downloadablecourses)) { $publicationmanager->delete_hub_publications($huburl, 0); } } catch (Exception $e) { $errormessage = $e->getMessage(); $errormessage .= html_writer::empty_tag('br') . get_string('errorunpublishcourses', 'hub'); $confirm = false; $cleanregdata = 1; } } } //course unpublish went ok, unregister the site now if ($confirm) { $function = 'hub_unregister_site';