[DEV] Attach Mod

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Ideas Centre
User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] Attach Mod

Post by digioz » Sun May 17, 2015 10:36 am

Movie wrote:Any luck turning this into a Extension for phpbb 3.1 ?
Unfortunately no. The problem is the new events list does not provide an event for file name and location manipulation. So either we will have to keep doing this the way we are now or the development team of phpbb needs to add some events for this.
DigiOz Multimedia
http://www.digioz.com

Movie
Registered User
Posts: 127
Joined: Sun Nov 02, 2014 2:54 pm
Location: Chicago Illinois Area.

Re: [DEV] Attach Mod

Post by Movie » Sun May 17, 2015 9:11 pm

digioz wrote:
Movie wrote:Any luck turning this into a Extension for phpbb 3.1 ?
Unfortunately no. The problem is the new events list does not provide an event for file name and location manipulation. So either we will have to keep doing this the way we are now or the development team of phpbb needs to add some events for this.
Your talking way over my head so forgive me for my dumb questions, I assume you have looked at the events list for the latest release https://wiki.phpbb.com/Event_List ?

What is involved with getting a event for file name and location manipulation added?

Do you have any concerns that I need to worry about when "keep doing it this way" I guess what I worry about is getting myself and my site to the place where its broke and not being able to get support to get it running again, I have seen where if something that didn't get a complete blessing from the phpbb team they just don't care what your problem is and turn your back on you.

Thanks again.
View signatures turned off.

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] Attach Mod

Post by digioz » Mon May 18, 2015 12:17 am

Movie wrote:
digioz wrote:
Movie wrote:Any luck turning this into a Extension for phpbb 3.1 ?
Unfortunately no. The problem is the new events list does not provide an event for file name and location manipulation. So either we will have to keep doing this the way we are now or the development team of phpbb needs to add some events for this.
Your talking way over my head so forgive me for my dumb questions, I assume you have looked at the events list for the latest release https://wiki.phpbb.com/Event_List ?

What is involved with getting a event for file name and location manipulation added?

Do you have any concerns that I need to worry about when "keep doing it this way" I guess what I worry about is getting myself and my site to the place where its broke and not being able to get support to get it running again, I have seen where if something that didn't get a complete blessing from the phpbb team they just don't care what your problem is and turn your back on you.

Thanks again.
Yes, I did look through the list of events and as far as I can tell it does not contain any events for changing file location. If anyone sees an event that I don't please let me know.

To get an event added for this we will have to request it from the PHPBB development team and justify the use case for it. This will be subject to the approval of the team, so it is not guaranteed.

The problem with doing it the old way (aka direct PHP file manipulation) is that long term it will not be supported. It may also prevent you from applying PHPBB updates and you would have to undo all the changes and redo them every time you need to update the forum software, so basically I do not recommend doing it this way.

I will keep researching our options and post an update if I find anything.
DigiOz Multimedia
http://www.digioz.com

Movie
Registered User
Posts: 127
Joined: Sun Nov 02, 2014 2:54 pm
Location: Chicago Illinois Area.

Re: [DEV] Attach Mod

Post by Movie » Tue May 19, 2015 1:29 am

digioz wrote:
Movie wrote:
digioz wrote:
Movie wrote:Any luck turning this into a Extension for phpbb 3.1 ?
Unfortunately no. The problem is the new events list does not provide an event for file name and location manipulation. So either we will have to keep doing this the way we are now or the development team of phpbb needs to add some events for this.
Your talking way over my head so forgive me for my dumb questions, I assume you have looked at the events list for the latest release https://wiki.phpbb.com/Event_List ?

What is involved with getting a event for file name and location manipulation added?

Do you have any concerns that I need to worry about when "keep doing it this way" I guess what I worry about is getting myself and my site to the place where its broke and not being able to get support to get it running again, I have seen where if something that didn't get a complete blessing from the phpbb team they just don't care what your problem is and turn your back on you.

Thanks again.
Yes, I did look through the list of events and as far as I can tell it does not contain any events for changing file location. If anyone sees an event that I don't please let me know.

To get an event added for this we will have to request it from the PHPBB development team and justify the use case for it. This will be subject to the approval of the team, so it is not guaranteed.

The problem with doing it the old way (aka direct PHP file manipulation) is that long term it will not be supported. It may also prevent you from applying PHPBB updates and you would have to undo all the changes and redo them every time you need to update the forum software, so basically I do not recommend doing it this way.

I will keep researching our options and post an update if I find anything.
I took a look at the events list it didn't take me long to realize how clueless I am when it comes to those type things, hopefully something can be done soon to correct the oversight of putting files into a single folder when attachments went from a mod to part of phpbb.

Justifying the use case is self explanatory don't you think?

Thanks for your time and your work so far looking forward to a solution in the future.
View signatures turned off.

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] Attach Mod

Post by digioz » Tue May 19, 2015 3:17 am

I agree with you 100%. Let's hope the PHPBB Development Team agrees with us as well.
DigiOz Multimedia
http://www.digioz.com

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] Attach Mod

Post by digioz » Mon Aug 24, 2015 1:26 am

I went ahead and updated the current attach mod to work with PHPBB 3.1.5. The current method however is still not a PHPBB Extension and requires manual editing of php files, but it does work. You can download version 0.0.4 from HERE.

What I recommend is to manually do the edits as outlined in the install.xml, which is also shown below:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="modx.prosilver.en.xsl"?>
<!--NOTICE: Please open this file in your web browser. If presented with a security warning, you may safely tell it to allow the blocked content.-->
<!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD.\nAlthough MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD.\nNo support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/-->
<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.5.xsd">
   <header>
      <meta name="generator" content="MODX file generated with PP MODX Creator by tumba25 (online version)"/>
      <meta name="generator" content="MODX file generated by MODX Generator by tumba25"/>
      <license><![CDATA[http://opensource.org/licenses/gpl-license.php GNU General Public License v2]]></license>
      <title lang="en"><![CDATA[Attach Mod]]></title>
      <description lang="en"><![CDATA[The purpose of this mod is to store attachments at YYYY/MM/DD inside the files folder where attachments are normally stored. This is specially beneficial for sites with a large number of attachments to distribute the number of files into multiple folders for faster retrieval and more efficient storage.]]></description>
      <author-notes lang="en"><![CDATA[This ModX Installation Package does not move your existing attachments. You will have to manually move existing attachments to the proper folders. Special thanks to the original creator of this Mod John Z for allowing me to further develop the mod for others to enjoy.]]></author-notes>
      <author-group>
         <author>
            <realname><![CDATA[DigiOz Multimedia]]></realname>
            <username><![CDATA[digioz]]></username>
            <homepage><![CDATA[http://www.digioz.com]]></homepage>
            <email><![CDATA[webmaster@digioz.com]]></email>
         </author>
      </author-group>
      <mod-version>0.0.4</mod-version>
      <installation>
         <level>advanced</level>
         <time>300</time>
         <target-version>3.1.5</target-version>
      </installation>
      <history>
         <entry>
            <date>2011-11-12</date>
            <rev-version>0.0.1</rev-version>
            <changelog lang="en">
               <change><![CDATA[Initial Mod Creation]]></change>
            </changelog>
         </entry>
         <entry>
            <date>2011-11-15</date>
            <rev-version>0.0.2</rev-version>
            <changelog lang="en">
               <change><![CDATA[Completed the Mod for version 3.0.4]]></change>
            </changelog>
         </entry>
         <entry>
            <date>2011-11-22</date>
            <rev-version>0.0.3</rev-version>
            <changelog lang="en">
               <change><![CDATA[Upgraded the Mod for version 3.0.9]]></change>
            </changelog>
         </entry>
		 <entry>
            <date>2015-08-23</date>
            <rev-version>0.0.4</rev-version>
            <changelog lang="en">
               <change><![CDATA[Upgraded the Mod for version 3.1.5]]></change>
            </changelog>
         </entry>
      </history>
   </header>
   <action-group>
      <open src="download/file.php">
         <edit>
            <find><![CDATA[      // Determine the 'presenting'-method
      if ($download_mode == PHYSICAL_LINK)]]></find>
            <action type="before-add"><![CDATA[      // Attachment storage MOD
      $date = getdate((int)$attachment['filetime']);
      $filepath = $config['upload_path'] . '/' . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday'];
]]></action>
         </edit>
         <edit>
            <find><![CDATA[      redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']);]]></find>
            <action type="replace-with"><![CDATA[      redirect($phpbb_root_path . $filepath . '/' . $attachment['physical_filename']);]]></action>
         </edit>
         <edit>
            <find><![CDATA[      send_file_to_browser($attachment, $config['upload_path'], $display_cat);]]></find>
            <action type="replace-with"><![CDATA[      send_file_to_browser($attachment, $filepath, $display_cat);]]></action>
         </edit>
      </open>
      <open src="includes/functions_content.php">
         <edit>
            <find><![CDATA[       $attachment['extension'] = strtolower(trim($attachment['extension']));]]></find>
            <action type="after-add"><![CDATA[       // Attachment storage MOD
       $date = getdate((int)$attachment['filetime']);
       $filepath = $phpbb_root_path . $config['upload_path'] . '/' . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday'];
      
       $filename = $filepath . '/' . utf8_basename($attachment['physical_filename']);]]></action>
         </edit>
         <edit>
            <find><![CDATA[      $filename = $phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($attachment['physical_filename']);]]></find>
            <action type="replace-with"><![CDATA[      $thumbnail_filename = $filepath . '/thumb_' . utf8_basename($attachment['physical_filename']);
      // END Attach storage MOD]]></action>
         </edit>
         <edit>
            <remove><![CDATA[      $thumbnail_filename = $phpbb_root_path . $config['upload_path'] . '/thumb_' . utf8_basename($attachment['physical_filename']);]]></remove>
         </edit>
      </open>
      <open src="includes/functions_posting.php">
         <edit>
            <find><![CDATA[$is_image = (isset($extensions[$file->get('extension')]['display_cat'])) ? $extensions[$file->get('extension')]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE : false;]]></find>
            <action type="after-add"><![CDATA[   // Attachment storage MOD
   $date = getdate();   
   $filepath = $phpbb_root_path . $config['upload_path'] . '/' . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday'] . '/';

   if(!is_dir($filepath)) {
      $ok = @mkdir($filepath, 0777, true);
   }]]></action>
         </edit>
         <edit>
            <find><![CDATA[$file->move_file($config['upload_path'], false, !$is_image);]]></find>
            <action type="replace-with"><![CDATA[$file->move_file($filepath, false, !$is_image);
// End Attach storage MOD]]></action>
         </edit>
         <edit>
            <find><![CDATA[$filedata['real_filename'] = $file->get('uploadname');]]></find>
            <action type="after-add"><![CDATA[   // Attach storage MOD]]></action>
         </edit>
         <edit>
            <find><![CDATA[$filedata['filetime'] = time();]]></find>
            <action type="replace-with"><![CDATA[   $filedata['filetime'] = $date[0];
   // End Attach storage MOD]]></action>
         </edit>
         <edit>
            <find><![CDATA[if ($free_space = @disk_free_space($phpbb_root_path . $config['upload_path']))]]></find>
            <action type="replace-with"><![CDATA[if ($free_space = @disk_free_space($phpbb_root_path . $filepath))]]></action>
         </edit>
         <edit>
            <find><![CDATA[            // insert attachment into db]]></find>
            <action type="after-add"><![CDATA[            // Attachment storage MOD
                $date = getdate($attach_row['filetime']);
                $filepath = $phpbb_root_path . $config['upload_path'] . "/" . (string)$date['year'] . '/' . $date['month'] . '/' . (string)$date['mday'];

                // Below line modified for Attachment storage MOD]]></action>
         </edit>
         <edit>
            <find><![CDATA[            if (!@file_exists($phpbb_root_path . $config['upload_path'] . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename'])))]]></find>
            <action type="replace-with"><![CDATA[            if (!@file_exists($filepath . '/' . utf8_basename($orphan_rows[$attach_row['attach_id']]['physical_filename'])))]]></action>
         </edit>
      </open>
      <open src="includes/message_parser.php">
         <edit>
            <find><![CDATA[                  'attach_comment'=> $this->filename_data['filecomment'],]]></find>
            <action type="after-add"><![CDATA[                  'filetime' => $filedata['filetime'],]]></action>
         </edit>
         <edit>
            <find><![CDATA[                     'attach_comment'=> $this->filename_data['filecomment'],]]></find>
            <action type="after-add"><![CDATA[                     'filetime' => $filedata['filetime'],]]></action>
         </edit>
         <edit>
            <find><![CDATA[         $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment]]></find>
            <inline-edit>
               <inline-find><![CDATA[, attach_comment]]></inline-find>
               <inline-action type="after-add"><![CDATA[, filetime]]></inline-action>
            </inline-edit>
         </edit>
         <edit>
            <find><![CDATA[         $sql = 'SELECT attach_id, is_orphan, real_filename, attach_comment]]></find>
            <inline-edit>
               <inline-find><![CDATA[, attach_comment]]></inline-find>
               <inline-action type="after-add"><![CDATA[, filetime]]></inline-action>
            </inline-edit>
         </edit>
      </open>
   </action-group>
</mod>
Hopefully at some point we will be able to add an event trigger to turn this mod into an official extension.

Thanks,
Pete
DigiOz Multimedia
http://www.digioz.com

Locked

Return to “[3.0.x] MODs in Development”

Who is online

Users browsing this forum: Yandex [Bot] and 9 guests

cron