implement clean deletion of Seminaries
This commit is contained in:
parent
4dca3e8089
commit
60b7f12f79
25 changed files with 410 additions and 9 deletions
|
|
@ -170,6 +170,35 @@
|
|||
$this->db->setAutocommit(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all Seminary uploads of a Seminary.
|
||||
*
|
||||
* @param int $seminaryId ID of Seminary to delete all Uploads of
|
||||
*/
|
||||
public function deleteSeminaryUploadsOfSeminary($seminaryId)
|
||||
{
|
||||
// Get all uploads from a Seminary
|
||||
$seminaryUploads = $this->db->query(
|
||||
'SELECT id, url '.
|
||||
'FROM seminaryuploads '.
|
||||
'WHERE seminary_id = ?',
|
||||
'i',
|
||||
$seminaryId
|
||||
);
|
||||
|
||||
// Delete each upload
|
||||
foreach($seminaryUploads as &$upload)
|
||||
{
|
||||
// Delete file
|
||||
$filename = ROOT.DS.\nre\configs\AppConfig::$dirs['seminaryuploads'].DS.$upload['url'];
|
||||
@unlink($filename);
|
||||
}
|
||||
|
||||
// Delete database entries
|
||||
$this->db->query('DELETE FROM seminaryuploads WHERE seminary_id = ?', 'i', $seminaryId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue