Implement doWhenDeletingUser to avoid constraint when deleting course/user

pull/2757/head^2
Angel Fernando Quiroz Campos 7 years ago
parent c51a213e5e
commit 2898d5ff9c
  1. 13
      plugin/ims_lti/ImsLtiPlugin.php
  2. 11
      plugin/studentfollowup/StudentFollowUpPlugin.php

@ -543,4 +543,17 @@ class ImsLtiPlugin extends Plugin
}
}
}
/**
* Avoid conflict with foreign key when deleting a course
*
* @param int $courseId
*/
public function doWhenDeletingCourse($courseId)
{
$em = Database::getManager();
$em->createQuery('DELETE FROM ChamiloPluginBundle:ImsLti\ImsLtiTool tool WHERE tool.course = :c_id')
->execute(['c_id' => (int) $courseId]);
}
}

@ -240,4 +240,15 @@ class StudentFollowUpPlugin extends Plugin
{
return 20;
}
/**
* @param int $userId
*/
public function doWhenDeletingUser($userId)
{
$userId = (int) $userId;
Database::query("DELETE FROM sfu_post WHERE user_id = $userId");
Database::query("DELETE FROM sfu_post WHERE insert_user_id = $userId");
}
}

Loading…
Cancel
Save