Anyone know how to delete an attachment from a glossary entry?
I looked at the edit.php file. I'm no expert but I'm hoping that a simple:
else {
'remove'($delete->attachment);
}
might do the trick?
Any PHP pro's have any advice?
MC
It is on one of the threads http://moodle.org/mod/forum/discuss.php?d=24679#116757 something about it being a bug. I found the easiest way was to copy the contents of the entry. Delete the entire entry using the cross. Then re add the entry without the attachment. Long winded but it works.
The code would have to delete the $entry->attachment value and then also go off and delete the file itself which is in:
$CFG->dataroot/$course->id/moddata/glossary/$glossary->id/$entry->id/
or in actual terms something like:
moodledata/2/moddata/glossary/1/22/
Doing that is fine if off a button but from your code I assume you wanted it done if like:
(!empty ($entry->attachment)){
.....
} else {
delete statements
}
Which wouldnt work too well because entries that have attachments but dont want to change them (changing another field) would be effected