Wicked_Driver::attachFile PHP Method

attachFile() public method

Attaches a file to a page or update an attachment.
public attachFile ( array $file, string $data )
$file array This is a key/value array describing the attachment:
'page_id' =>          This is the id of the page to which we would
                      like to attach the file.
'attachment_name' =>  This is the filename of the attachment.
'change_log' =>       A change log entry for this attach or update
                      operation.  (Optional)
'change_author' =>    The user uploading this file.  If not present,
                      the currently logged-in user is assumed.
$data string This is the contents of the file to be attached.
    public function attachFile($file, $data)
    {
        $vfs = $this->getVFS();
        if (!isset($file['change_author'])) {
            $file['change_author'] = $GLOBALS['registry']->getAuth();
        }
        $result = $this->_attachFile($file);
        /* We encode the path quoted printable so we won't get any nasty
         * characters the filesystem might reject. */
        $path = Wicked::VFS_ATTACH_PATH . '/' . $file['page_id'];
        try {
            $vfs->writeData($path, $file['attachment_name'] . ';' . $result, $data, true);
        } catch (Horde_Vfs_Exception $e) {
            throw new Wicked_Exception($e);
        }
    }