Example #1
0
}
// Update attachments in the meta data, link active attachments
// to the message and delete stale attachments.
$dbmessage["meta"]["attachments"] = array();
foreach ($message["attachments"] as $info) {
    if ($info["keep"]) {
        // Because there might be inconsistencies in the list due to going
        // backward in the browser after deleting attachments, a check is
        // needed to see if the attachments are really in the database.
        if (!phorum_api_file_exists($info["file_id"])) {
            continue;
        }
        $dbmessage["meta"]["attachments"][] = array("file_id" => $info["file_id"], "name" => $info["name"], "size" => $info["size"]);
        $PHORUM['DB']->file_link($info["file_id"], $message["message_id"], PHORUM_LINK_MESSAGE);
    } else {
        if (phorum_api_file_check_delete_access($info["file_id"])) {
            phorum_api_file_delete($info["file_id"]);
        }
    }
}
if (!count($dbmessage["meta"]["attachments"])) {
    unset($dbmessage["meta"]["attachments"]);
}
/*
 * [hook]
 *     before_edit
 *
 * [description]
 *     This hook can be used to change the edited message before it is stored in
 *     the database.
 *
Example #2
0
    foreach ($deleteids as $msgthd_id => $doit) {
        // A hook to allow modules to implement extra or different
        // delete functionality.
        if ($doit && isset($mod_forums[$delete_messages[$msgthd_id]['forum_id']])) {
            $delete_handled = 0;
            if (isset($PHORUM["hooks"]["before_delete"])) {
                list($delete_handled, $msg_ids, $msgthd_id, $delete_messages[$msgthd_id], $delete_mode) = phorum_hook("before_delete", array(0, 0, $msgthd_id, $delete_messages[$msgthd_id], PHORUM_DELETE_MESSAGE));
            }
            // Handle the delete action, unless a module already handled it.
            if (!$delete_handled) {
                // Delete the message from the database.
                phorum_db_delete_message($msgthd_id, PHORUM_DELETE_MESSAGE);
                // Delete the message attachments from the database.
                $files = phorum_db_get_message_file_list($msgthd_id);
                foreach ($files as $file_id => $data) {
                    if (phorum_api_file_check_delete_access($file_id)) {
                        phorum_api_file_delete($file_id);
                    }
                }
            }
            // Run a hook for performing custom actions after cleanup.
            if (isset($PHORUM["hooks"]["delete"])) {
                phorum_hook("delete", array($msgthd_id));
            }
        }
    }
}
$PHORUM['DATA']['PREPOST'] = array();
if ($gotforums) {
    $foruminfo = phorum_db_get_forums($mod_forums, NULL, $PHORUM['vroot']);
} else {