package cPanel::CMS::Xoops;

use strict;
use warnings;

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

my $new = <<'END_UPGRADE';
<p>We regret to inform you that we cannot provide an update of Xoops. However, you can manually update your Xoops installation. To learn more, please visit <a target="_blank" href="http://xoops.org/">Xoops' documentation</a>.</p>

END_UPGRADE

our $meta_info = {
    disable => {
        install => $new,
    },
    setphpsuexecvar     => 1,
    adminuser_pass      => 1,
    admin_email         => 1,
    installdir          => 'xoops',
    description         => q{PHP/MySQL based CMS. <b>If you'd like the Xoops->User Menu->[View | Edit]Accounts buttons to work instead of giving a "Fatal error: Call to a member function getVar() on a non-object in */class/theme.php on line 49*" error then:</b> install the "USERMANAGEMENT" module at Xoops->Administration Menu->Module->Administration},    # required
    security            => 'Configuration has to be world readable and writable, requires 777 directories. Subject to all common PHP security problems',
    version             => '2.2.6',                                                                                                                                                                                                                                                                                                                                  # required
    security_rank       => 1,
    website             => 'http://www.xoops.org/',
    config_files        => ['mainfile.php'],
    mysql               => ['xoops'],
    table_prefix        => 'xoops',
    install_fields_hook => sub {
        my ( $input_hr, $error_ref, $cpo ) = @_;
        ${$error_ref} .= 'Invalid peristent connection option.'
          if $input_hr->{'use_persistent'} ne '1' && $input_hr->{'use_persistent'} ne '0';
        ${$error_ref} .= 'Display name must be numbers, letter, underscores, or spaces only'
          if $input_hr->{'admin_display'} !~ m/^[\w\s?]+$/;
    },
    install_fields => {
        use_persistent => {
            label    => 'Use Peristent Connections?',
            value    => { '0' => 'No', '1' => 'Yes', },
            defvalue => '0',
            attr     => '',
            type     => 'radio'
        },
        admin_display => {
            label    => 'Admin display name',
            value    => '',
            defvalue => '0',
            attr     => '',
            type     => 'text'
        },
    },
    chmod => {
        '0777' => [qw(cache/ uploads/ templates_c/)],
    },
};

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

sub upgrade   { shift->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;
