Fix issue with foreign keys when removing URLs and avoid a notice

1.10.x
Yannick Warnier 9 years ago
parent aa83c1fe12
commit 28117fcfc2
  1. 2
      main/admin/access_urls.php
  2. 19
      main/inc/lib/urlmanager.lib.php

@ -33,7 +33,7 @@ if (isset($_GET['action'])) {
Display :: display_normal_message(Security::remove_XSS(stripslashes($_GET['message'])));
}
$url_id = intval($_GET['url_id']);
$url_id = (empty($_GET['url_id']) ? 0 : intval($_GET['url_id']));
switch ($_GET['action']) {
case 'delete_url':

@ -73,6 +73,25 @@ class UrlManager
{
$id = intval($id);
$table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL);
$tableUser = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$tableCourse = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$tableSession = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$tableCourseCategory = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
$tableGroup = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USERGROUP);
$sql = "DELETE FROM $tableCourse WHERE access_url_id = ".$id;
$result = Database::query($sql);
/*
$sql = "DELETE FROM $tableCourseCategory WHERE access_url_id = ".$id;
$result = Database::query($sql);
*/
$sql = "DELETE FROM $tableSession WHERE access_url_id = ".$id;
$result = Database::query($sql);
$sql = "DELETE FROM $tableGroup WHERE access_url_id = ".$id;
$result = Database::query($sql);
$sql = "DELETE FROM $tableUser WHERE access_url_id = ".$id;
$result = Database::query($sql);
$sql= "DELETE FROM $table WHERE id = ".$id;
$result = Database::query($sql);

Loading…
Cancel
Save