package cPanel::Bulletin_Boards::phpBB;

use strict;
use warnings;

my $desc = <<'END_DESC';
<p><b>How to upgrade your 2.x installs to the 3.x series</b></p>
<p>
The differences between 2.x and 3.x are such that automating the process could leave you with corrupt data. Manual monitoring and intervention is required at several places to ensure this doesn't happen or is manually handled if it does happen.
<br /><br />phpBB has a howto guide (linked to in the appropriate step below) that you will need to read, understand, and follow closely to accomplish said conversion.<br /><br />
Below is an outline of the process as it pertains to cPAddon installations of phpBB. Please read it over and be sure to have a good understanding of what needs done before you begin:
  <ol>
    <li><a href="?addon=cPanel::Bulletin_Boards::phpBB3&leave_insecure_install=1">Install a brand new 3.x</a> (checking the "leave install/ directory in place so I can import an old 2.x install" box)</li>
    <li>Do the manual import and verification process <a href="http://www.phpbb.com/support/documents.php?mode=install&version=3#convert" target="_blank">as outlined by phpBB</a>
    <li>Once you are sure the previous step is complete:
       <ol style="list-style:lower-latin">
         <li>Remove the 3.x install's install/ directory (the one we left in place in step 1)</li>
         <li>Uninstall the 2.x installation via the screen you are on now</li>
         <li>At this point if you decide to, as the <a href="http://www.phpbb.com/support/documents.php?mode=install&version=3#convert" target="_blank">phpBB howto manual</a> puts it, "give it the name of your old installation, changing the directory name" the easiest way to do this is:
             <ol style="list-style:lower-roman">
               <li>Install another <a href="?addon=cPanel::Bulletin_Boards::phpBB3">new fresh phpBB 3.x</a> where the "old installation" used to be</li>
               <li>Import the data from the phpBB 3.x install from step 1 and 2 (Using a tool like <a target="_blank" href="/3rdparty/phpMyAdmin/index.php">phpMyAdmin</a>) into the new install from step 'i'</li>
               <li>Follow the applicable instructions that <a href="http://www.phpbb.com/support/documents.php?mode=install&version=3#postreq" target="_blank">phpBB provides</a> about how to "give it the name of your old installation"</li>
               <li>Once you are sure the previous step is complete: Uninstall the phpBB 3.x install from step 1 via <a href="?addon=cPanel::Bulletin_Boards::phpBB3">the phpBB 3.x screen</a></li>
             </ol>
         </li>
       </ol>
    </li>
  </ol>
</p>
END_DESC

my $new = <<'END_UPGRADE';
<p>New installs of phpBB 2.x are no longer available. For new phpBB installations please use the <a href="?addon=cPanel::Bulletin_Boards::phpBB3">phpBB 3.x</a> cPAddon</p>

END_UPGRADE

our $VERSION = 0.2;
my $pkg = __PACKAGE__;

our $meta_info = {
    setphpsuexecvar => 1,
   disable => {
      install => $new,
   },
   description => 'PHP/MySQL Based Bulletin Board' . $desc,
   security => 'Do not allow users to post HTML when posting. It has lower rating because it relies on 777 directory permissions and a 644 config file and has had many security issues inherent to PHP. Vendor does well in upgrading when problems are found but it requires more effort on your part to make sure you come back here to upgrade whenever necessary.',
   version => '2.0.23', 
   security_rank => 1,
   website => 'http://phpbb.com/', 
   config_files => ['config.php'],
   chmod => {
      '0644' => ['config.php'],
      '0777' => [qw(images/avatars images/avatars/tmp)],
   },
   mysql => ['phpbb'], 
   table_prefix => 'phpbb',
};

#### action functions ##
sub install { 
    print $meta_info->{'disable'}{'install'};
    return;
}

sub upgrade { 
   my $aoc = shift;
# do for "working copy" entry
#   $aoc->{phpbb2_dbms} = $aoc->{mysql_version} >= 4 ? 'mysql4' : 'mysql';
   $aoc->stdupgrade(@_);
}

sub uninstall { shift->stduninstall(@_) }

#### non action functions ##
sub installform { print $meta_info->{'disable'}{'install'}; }
sub upgradeform { print shift->{upgradeform} }
sub uninstallform { print shift->{uninstallform} }

1;
