Script : adapt course rel URL deletion to make it usable from script and delete relation with all URLs - refs BT#20736

pull/4761/head
NicoDucou 2 years ago
parent 53f6bc86e5
commit bc4dc493d9
  1. 6
      main/inc/lib/course.lib.php
  2. 19
      main/inc/lib/urlmanager.lib.php

@ -2476,7 +2476,7 @@ class CourseManager
* course from the groups in the real course if they are not subscribed in
* that real course.
*/
public static function delete_course($code)
public static function delete_course($code, $from_ws = false)
{
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
@ -2534,7 +2534,9 @@ class CourseManager
}
$count = 0;
if (api_is_multiple_url_enabled()) {
if ($from_ws) {
UrlManager::deleteRelationFromCourseWithAllUrls($courseId);
} elseif (api_is_multiple_url_enabled()) {
$url_id = 1;
if (api_get_current_access_url_id() != -1) {
$url_id = api_get_current_access_url_id();

@ -913,6 +913,25 @@ class UrlManager
return $result;
}
/**
* Deletes course relationship with all urls.
*
* @author Nicolas Ducoulombier
*
* @param int $courseId
*
* @return bool true if success
* */
public static function deleteRelationFromCourseWithAllUrls ($courseId)
{
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sql = "DELETE FROM $table
WHERE c_id = '".intval($courseId)."' ";
$result = Database::query($sql);
return $result;
}
/**
* Deletes an url and $userGroup relationship.
*

Loading…
Cancel
Save