Update attachment

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in the Customisations Database.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTICE: This forum is only for the announcement of new releases and/or updates of MODs. Any MOD support should be obtained through the Customisations Database in the support area designated for each MOD.

A direct link to support for each MOD is in the first post of the respective topic.
rxu
Extensions Development Team
Posts: 2953
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Update attachment

Post by rxu » Mon Sep 15, 2008 12:40 pm

Actually.
Thanks, karlsemple! :)

User avatar
Tnias
Registered User
Posts: 62
Joined: Tue Apr 11, 2006 10:37 am
Location: Colorado
Contact:

Re: Update attachment

Post by Tnias » Sat Sep 20, 2008 8:50 pm

Thanks Stokerpiller:
stokerpiller wrote:
Tnias wrote:This mod will help a lot; however it would be even better if we can link an attachment that is already linked to one message to others instead of having to upload the same file over and over. We have many users that want to download the same file but we do not wnat to post the file openly for anyone to download on their own. Is there a way we can upload an attachment and then repeatedly attach it to multiple messages without uploading the same file over and over again?
Any ideas?
Just copy the posted download link and paste it in the other posts with an image of the download icon.
That is a nice workaround. It would still be nice to have that kind of ability in an Admin tool; that is the ability to link files we already have uploaded to any new private message or topic we desire. I would not want other forum users to have that ability but it would be nice to have that ability.

Thanks again for the nice work around; I should have thought of that one.
Tnias.
Tnias.

"In memory of our God, our faith, and freedom,
and of our spouses, our children, and our peace."

User avatar
Krakuspm
Registered User
Posts: 17
Joined: Mon Apr 02, 2007 2:23 pm
Location: Poland

Re: Update attachment

Post by Krakuspm » Wed Sep 24, 2008 3:19 am

As many of my users don't understand how to use the mod, would be great to modify it this way:
Attachments
update_attachments_mod.jpg
update_attachments_mod.jpg (62.86 KiB) Viewed 1448 times

jabhawk
Registered User
Posts: 2
Joined: Wed Nov 12, 2008 5:24 pm

Re: Update attachment

Post by jabhawk » Wed Nov 12, 2008 5:35 pm

NEW USER!! HELP! v3.0.2
I used a text editor to update all the files listed in the mod and saved them to the server. When I open post with my test attachment and EDIT the post I do not see any changes to the form.

I only have the default style installed and I went ahead and entered some generic text into the posting_editor.html file to see if I could show any changes and I still do not see anything.

I purged the local systems cashe and cleared all server cookies. I verified that the file was updated but nothing seems to work. I check the source of the displayed page and it is not showing me any of the changed content.

Am I missing a step in the mod process. Help a newb out.
Jon Black

rxu
Extensions Development Team
Posts: 2953
Joined: Wed Oct 25, 2006 12:46 pm
Location: Siberia, Russian Federation
Name: Ruslan
Contact:

Re: Update attachment

Post by rxu » Thu Nov 13, 2008 1:20 pm

jabhawk wrote:I purged the local systems cashe and cleared all server cookies.
You mean cache of your browser on your local PC?
You need to purge the board cache, you can do it through the Administration control panel. If it won't work, you might need to refresh the template (on ACP/Styles tab).

jeremyotten
Registered User
Posts: 145
Joined: Fri Mar 15, 2002 1:54 pm
Location: The Netherlands
Contact:

Re: Update attachment

Post by jeremyotten » Tue Dec 09, 2008 2:04 pm

Krakuspm wrote:As many of my users don't understand how to use the mod, would be great to modify it this way:
If you could make it like this WOOOOW!!

User avatar
Ahri89
Registered User
Posts: 516
Joined: Sat Apr 07, 2007 2:53 pm
Location: Spain
Contact:

Re: Update attachment

Post by Ahri89 » Thu Jan 29, 2009 12:55 am

Thanks!
MODs translated to Spanish: ACP Add User MOD, ACP Announcement Centre, Advertisement Management, Custom Profile Fields, Update Reminder, Flood time setting per forum, MOD Version Check, Posting template, Prune Log, Simple Trash Bin, TinyPic Plugin, User Reminder, View Profile, View your topics, and more...

Sorry for my bad english xD

User avatar
AllCity
Registered User
Posts: 230
Joined: Sun Jun 22, 2008 6:33 pm
Name: Andrey Shapoval
Contact:

Re: Update attachment

Post by AllCity » Sun Apr 26, 2009 6:25 pm

Fix for admins and moders update file error:
open includes/message_parser.php and find

Code: Select all

            else if ($update_file && $upload_file)
            {
                include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);

                $filedata = upload_attachment($form_name, $forum_id, false, '', $is_message);
                $error = array_merge($error, $filedata['error']);

                $index = array_keys(request_var('update_file', array(0 => 0)));
                $index = (!empty($index)) ? $index[0] : false;
                $filename = $filedata['real_filename'];
    
                if ($index !== false && !empty($this->attachment_data[$index]))
                {
                    $sql = 'SELECT attach_id, is_orphan, filesize, physical_filename, thumbnail
                        FROM ' . ATTACHMENTS_TABLE . '
                        WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id'] . '
                            AND poster_id = ' . $user->data['user_id'];
                    $result = $db->sql_query($sql);
                    $row = $db->sql_fetchrow($result);
                    $db->sql_freeresult($result);

                    if (!sizeof($error))
                    {
                        $sql_ary = array(
                            'physical_filename'    => $filedata['physical_filename'],
                            'attach_comment'    => $this->filename_data['filecomment'],
                            'real_filename'        => $filedata['real_filename'],
                            'extension'            => $filedata['extension'],
                            'mimetype'            => $filedata['mimetype'],
                            'filesize'            => $filedata['filesize'],
                            'filetime'            => $filedata['filetime'],
                            'thumbnail'            => $filedata['thumbnail'],
                            'in_message'        => ($is_message) ? 1 : 0,
                            'poster_id'            => $user->data['user_id'],
                        );

                        $db->sql_query('UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id'] );
                        
                        //Delete old file
                        phpbb_unlink($row['physical_filename'], 'file');

                        if ($row['thumbnail'])
                        {
                            phpbb_unlink($row['physical_filename'], 'thumbnail');
                        }

                        if (!$row['is_orphan'])
                        {
                            set_config('upload_dir_size', $config['upload_dir_size'] - $row['filesize'] + $filedata['filesize'], true);
                        }

                        // Refresh attachment data
                        $this->attachment_data[$index]['real_filename'] = $filedata['real_filename'];
                        $this->attachment_data[$index]['attach_comment'] = ($this->filename_data['filecomment']) ? $this->filename_data['filecomment'] : $this->attachment_data[$index]['attach_comment'];
                        $this->message = preg_replace("#\[attachment=$index\](.*?)\[\/attachment\]#e", "'[attachment=$index]' . \$filename . '[/attachment]'", $this->message);
                        $this->filename_data['filecomment'] = '';
                    }
                } 
            } 
rep to:

Code: Select all

            else if ($update_file && $upload_file)
            {
                include_once($phpbb_root_path . 'includes/functions_admin.' . $phpEx);

                $filedata = upload_attachment($form_name, $forum_id, false, '', $is_message);
                $error = array_merge($error, $filedata['error']);

                $index = array_keys(request_var('update_file', array(0 => 0)));
                $index = (!empty($index)) ? $index[0] : false;
                $filename = $filedata['real_filename'];
    
                if ($index !== false && !empty($this->attachment_data[$index]))
                {
                    $sql = 'SELECT attach_id, is_orphan, filesize, physical_filename, thumbnail
                        FROM ' . ATTACHMENTS_TABLE . '
                        WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id'];
                    $result = $db->sql_query($sql);
                    $row = $db->sql_fetchrow($result);
                    $db->sql_freeresult($result);

                    if (!sizeof($error))
                    {
                        $sql_ary = array(
                            'physical_filename'    => $filedata['physical_filename'],
                            'attach_comment'    => $this->filename_data['filecomment'],
                            'real_filename'        => $filedata['real_filename'],
                            'extension'            => $filedata['extension'],
                            'mimetype'            => $filedata['mimetype'],
                            'filesize'            => $filedata['filesize'],
                            'filetime'            => $filedata['filetime'],
                            'thumbnail'            => $filedata['thumbnail'],
                            'in_message'        => ($is_message) ? 1 : 0,
                        );

                        $db->sql_query('UPDATE ' . ATTACHMENTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE attach_id = ' . (int) $this->attachment_data[$index]['attach_id'] );
                        
                        //Delete old file
                        phpbb_unlink($row['physical_filename'], 'file');

                        if ($row['thumbnail'])
                        {
                            phpbb_unlink($row['physical_filename'], 'thumbnail');
                        }

                        if (!$row['is_orphan'])
                        {
                            set_config('upload_dir_size', $config['upload_dir_size'] - $row['filesize'] + $filedata['filesize'], true);
                        }

                        // Refresh attachment data
                        $this->attachment_data[$index]['real_filename'] = $filedata['real_filename'];
                        $this->attachment_data[$index]['attach_comment'] = ($this->filename_data['filecomment']) ? $this->filename_data['filecomment'] : $this->attachment_data[$index]['attach_comment'];
                        $this->message = preg_replace("#\[attachment=$index\](.*?)\[\/attachment\]#e", "'[attachment=$index]' . \$filename . '[/attachment]'", $this->message);
                        $this->filename_data['filecomment'] = '';
                    }
                } 
            } 
or you can install this version of the mod http://www.phpbb.com/community/viewtopi ... &t=1617415
Last edited by AllCity on Tue May 26, 2009 4:48 pm, edited 3 times in total.
My mods home page.

User avatar
Greight
Registered User
Posts: 163
Joined: Sun Jan 18, 2009 12:10 pm

Re: Update attachment

Post by Greight » Mon May 25, 2009 4:08 pm

This does not work for me. Please Mod author do something about this. I need this feature (I mean admin's possibility to update attachments) crucially!
Last edited by Greight on Tue May 26, 2009 5:54 pm, edited 1 time in total.

User avatar
AllCity
Registered User
Posts: 230
Joined: Sun Jun 22, 2008 6:33 pm
Name: Andrey Shapoval
Contact:

Re: Update attachment

Post by AllCity » Tue May 26, 2009 5:39 am

This works fine ;)
My mods home page.

User avatar
Greight
Registered User
Posts: 163
Joined: Sun Jan 18, 2009 12:10 pm

Re: Update attachment

Post by Greight » Tue May 26, 2009 8:25 am

Oh a bug ! After I was not successful with changing an attachment, I dont know what I have done that I can not even delete that and get this error:

Code: Select all

General Error
You are not allowed to access this file.
What can I do to delete it ?

User avatar
AllCity
Registered User
Posts: 230
Joined: Sun Jun 22, 2008 6:33 pm
Name: Andrey Shapoval
Contact:

Re: Update attachment

Post by AllCity » Tue May 26, 2009 2:36 pm

Change the author of this message to yourself ;)
My mods home page.

User avatar
Greight
Registered User
Posts: 163
Joined: Sun Jan 18, 2009 12:10 pm

Re: Update attachment

Post by Greight » Tue May 26, 2009 2:56 pm

AllCity wrote:Change the author of this message to yourself ;)
Oh thanks !! That did the trick !
:)

User avatar
AllCity
Registered User
Posts: 230
Joined: Sun Jun 22, 2008 6:33 pm
Name: Andrey Shapoval
Contact:

Re: Update attachment

Post by AllCity » Tue May 26, 2009 4:34 pm

My mods home page.

User avatar
Greight
Registered User
Posts: 163
Joined: Sun Jan 18, 2009 12:10 pm

Re: Update attachment

Post by Greight » Tue May 26, 2009 5:54 pm

What's the difference and shall I remove this to install that ?

Locked

Return to “[3.0.x] MOD Database Releases”