forked from FOSSEE/cfd_research_migration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
general_deletion.inc
executable file
·41 lines (40 loc) · 1.7 KB
/
general_deletion.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/******************************************************************************/
/****************************** DELETION FUNCTIONS ****************************/
/******************************************************************************/
function research_migration_abstract_delete_project($proposal_id)
{
$status = TRUE;
$root_path = cfd_research_migration_path();
$query = db_select('research_migration_proposal');
$query->fields('research_migration_proposal');
$query->condition('id', $proposal_id);
$proposal_q = $query->execute();
$proposal_data = $proposal_q->fetchObject();
if (!$proposal_data)
{
drupal_set_message('Invalid Research Migration Project.', 'error');
return FALSE;
} //!$proposal_data
$query = db_select('research_migration_submitted_abstracts_file');
$query->fields('research_migration_submitted_abstracts_file');
$query->condition('proposal_id', $proposal_id);
$abstract_q = $query->execute();
$dir_project_files = $root_path . $proposal_data->directory_name;
while ($abstract_data = $abstract_q->fetchObject())
{
if (is_dir($dir_project_files)){
unlink($root_path . $proposal_data->directory_name . '/' . $abstract_data->filepath);
}
else
{
drupal_set_message('Invalid Research Migration Project Abstract.', 'error');
}
db_delete('research_migration_submitted_abstracts_file')->condition('proposal_id', $proposal_id)->execute();
//!dwsim_flowsheet_delete_abstract_file($abstract_data->id)
}
$res = rmdir($root_path . $proposal_data->directory_name);
db_delete('research_migration_proposal')->condition('id', $proposal_data->id)->execute();
db_delete('research_migration_submitted_abstracts')->condition('proposal_id', $proposal_id)->execute();
return $status;
}