# cpanel - cPanel/CMS/Nucleus.pm                  Copyright(c) 2012 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

package cPanel::CMS::Nucleus;

use strict;
use warnings;

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

our $meta_info = {
    setphpsuexecvar => 1,
    adminuser_pass  => 1,
    admin_email     => 1,
    installdir      => 'nucleus',
    description     => 'PHP/MySQL based CMS',                                                                                                                                                     # required
    security        => 'Configuration has to be world readable. 777 directory permission required, makes it extremely dangerouse and exploitable. Subject to all common PHP security problems',
    version         => '3.64',                                                                                                                                                                    # required
    security_rank   => 1,
    website         => 'http://www.nucleuscms.org/',
    config_files    => ['config.php'],
    mysql           => ['ncls'],
    table_prefix    => 'nl',
    chmod           => {
        '0777' => [ 'media/', 'skins/' ],
    },
};

if ( defined &Cpanel::cPAddons::proc_keys_named_after_version ) {
    Cpanel::cPAddons::proc_keys_named_after_version( $meta_info, __PACKAGE__ );
}

#### action functions ##
sub install {
    my $cpo = shift;
    $cpo->stdinstall(@_);
    $cpo->_do_phpsuexec_perms();

    my $file = 'config.php';
    if ( -w $file ) {
        chmod oct(444), $file;
    }
}

sub upgrade {
    my $cpo = shift;

    my $file = "$cpo->{'installed'}{ $cpo->{'workinginstall'} }{'installdir'}/config.php";
    if ( !-w $file ) {
        chmod oct(644), $file;
    }

    $cpo->stdupgrade(@_);

    if ( -w $file ) {
        chmod oct(444), $file;
    }
}

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

#### non action functions ##
sub installform   { print shift->{installform} }
sub upgradeform   { print shift->{upgradeform} }
sub uninstallform { print shift->{uninstallform} }

1;
