Beispiel #1
0
 private static function _delete_dbrecords($artefactids)
 {
     if (empty($artefactids)) {
         return;
     }
     $idstr = '(' . join(',', array_map('intval', $artefactids)) . ')';
     db_begin();
     // Detach any files from this artefact
     delete_records_select('artefact_attachment', "artefact IN {$idstr}");
     // Make sure that the artefacts are removed from any view blockinstances
     if ($records = get_records_sql_array("\n            SELECT va.block, va.artefact, bi.configdata\n            FROM {view_artefact} va JOIN {block_instance} bi ON va.block = bi.id\n            WHERE va.artefact IN {$idstr}", array())) {
         require_once get_config('docroot') . 'blocktype/lib.php';
         BlockInstance::bulk_delete_artefacts($records);
     }
     delete_records_select('view_artefact', "artefact IN {$idstr}");
     delete_records_select('artefact_tag', "artefact IN {$idstr}");
     delete_records_select('artefact_access_role', "artefact IN {$idstr}");
     delete_records_select('artefact_access_usr', "artefact IN {$idstr}");
     execute_sql("UPDATE {usr} SET profileicon = NULL WHERE profileicon IN {$idstr}");
     execute_sql("UPDATE {institution} SET logo = NULL WHERE logo IN {$idstr}");
     // Delete any references to files embedded in textboxes
     delete_records_select('artefact_file_embedded', "fileid IN {$idstr}");
     delete_records_select('artefact', "id IN {$idstr}");
     db_commit();
 }
 private static function _delete_dbrecords($artefactids)
 {
     if (empty($artefactids)) {
         return;
     }
     $idstr = '(' . join(',', array_map('intval', $artefactids)) . ')';
     db_begin();
     // Detach any files from this artefact
     delete_records_select('artefact_attachment', "artefact IN {$idstr}");
     // Delete any references to these artefacts from non-artefact places.
     delete_records_select('artefact_parent_cache', "artefact IN {$idstr}");
     // The artefacts should have no 'real' children at this point, but they
     // could still be in the artefact_parent_cache as parents if they had
     // attachments, or if any of their children had attachments.
     delete_records_select('artefact_parent_cache', "parent IN {$idstr}");
     // Make sure that the artefacts are removed from any view blockinstances
     if ($records = get_records_sql_array("\n            SELECT va.block, va.artefact, bi.configdata\n            FROM {view_artefact} va JOIN {block_instance} bi ON va.block = bi.id\n            WHERE va.artefact IN {$idstr}", array())) {
         require_once get_config('docroot') . 'blocktype/lib.php';
         BlockInstance::bulk_delete_artefacts($records);
     }
     delete_records_select('view_artefact', "artefact IN {$idstr}");
     delete_records_select('artefact_tag', "artefact IN {$idstr}");
     delete_records_select('artefact_access_role', "artefact IN {$idstr}");
     delete_records_select('artefact_access_usr', "artefact IN {$idstr}");
     delete_records_select('artefact', "id IN {$idstr}");
     db_commit();
 }