Prev |  | Next

### 3.9.3. after_detach

The primary use of this hook would be for creating an alternate storage system for attachments. Using this hook, you can delete the file from your alternate storage.

Call time:

In `include/posting/action_attachments.php`, right after a file attachment is deleted from the database.

Hook input:

Two part array where the first element is the message array and the second element is a file array that contains the name, size, and `file_id` of the deleted file.

Hook output:

Same as input.

Example code:

    function phorum_mod_foo_reopen_after_detach($data)
    {
        global $PHORUM;

        // Remove the attachment from the log of messages with
        // attachments
        unset($PHORUM["mod_foo"]["messages_with_attachments"][$data[0]["message_id"]][$data[1]["file_id"]]);

        // If there are now no attachments on the current
        // message, remove the message from the log
        if (empty($PHORUM["mod_foo"]["messages_with_attachments"][$data[0]["message_id"]]))
            unset($PHORUM["mod_foo"]["messages_with_attachments"][$data[0]["message_id"]]);
        phorum_db_update_settings(array("mod_foo" => $PHORUM["mod_foo"]));

        return $data;
    }

Prev | Up | Next
| Home |