/** * Returns all fields used when adding/editing a package, including any * javascript to execute when the page is rendered with these fields. * * @param $vars stdClass A stdClass object representing a set of post fields * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional HTML markup to include */ public function getPackageFields($vars = null) { Loader::loadHelpers($this, array("Html")); $fields = new ModuleFields(); $fields->setHtml("\n\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t// Set whether to show or hide the ACL option\n\t\t\t\t\t\$('#cpanel_acl').closest('li').hide();\n\t\t\t\t\tif (\$('input[name=\"meta[type]\"]:checked').val() == 'reseller')\n\t\t\t\t\t\t\$('#cpanel_acl').closest('li').show();\n\t\t\t\t\t\$('input[name=\"meta[type]\"]').change(function() {\n\t\t\t\t\t\tif (\$(this).val() == 'reseller')\n\t\t\t\t\t\t\t\$('#cpanel_acl').closest('li').show();\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\$('#cpanel_acl').closest('li').hide();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t</script>\n\t\t"); $row = $this->getCorrectModuleRow($vars); $api = $this->getApiByMeta($row->meta); if (!isset($this->ArrayHelper)) { $this->ArrayHelper = $this->DataStructure->create("Array"); } $packages = array("" => Language::_('Cpe.label.defaultpackage', true)); $acls = array("" => Language::_('Cpe.label.default', true)); if ($row) { $pkglist = $api->listpkgs()->getResponse(); $aclslist = $api->listacls()->getResponse(); //Generate a list with all ACLS $keys = (array) $this->Json->decode($api->listacls())->acls; $acls = array("" => Language::_('Cpe.label.default', true)); foreach ($keys as $key => $value) { $acls[$key] = $key; } //$fields->setHtml($this->debug($acls)); $packages = array("" => Language::_('Cpe.label.defaultpackage', true)) + $this->ArrayHelper->numericToKey($pkglist->package, "name", "name"); } $fields->setHtml(Language::_('Cpe.misc.packageaddhint', true)); // Set the cPanel package as a selectable option $package = $fields->label(Language::_('Cpe.label.package', true), "cpanel_package"); $package->attach($fields->fieldSelect("meta[package]", $packages, $this->Html->ifSet($vars->meta['package']), array('id' => "cpanel_package"))); $fields->setField($package); $usernamefield = $fields->label(Language::_('Cpe.label.usernamefield', true), "cpanel_usernamefield"); $usernamefield->attach($fields->fieldSelect("meta[usernamefield]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['usernamefield']))); $fields->setField($usernamefield); $passwordfield = $fields->label(Language::_('Cpe.label.passwordfield', true), "cpanel_passwordfield"); $passwordfield->attach($fields->fieldSelect("meta[passwordfield]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['passwordfield']))); $fields->setField($passwordfield); $quota = $fields->label(Language::_('Cpe.label.webquota', true), "cpanel_quota"); $quota->attach($fields->fieldText("meta[webquota]", $this->Html->ifSet($vars->meta['webquota']), array("style" => "width: 75px;"))); $quota->attach($fields->tooltip(Language::_('Cpe.tooltip.quota', true))); $fields->setField($quota); $bw = $fields->label(Language::_('Cpe.label.bandwidth', true), "cpanel_bw"); $bw->attach($fields->fieldText("meta[bandwidth]", $this->Html->ifSet($vars->meta['bandwidth']), array("style" => "width: 75px;"))); $bw->attach($fields->tooltip(Language::_('Cpe.bandwidth.tooltip'))); $fields->setField($bw); $shell = $fields->label(Language::_('Cpe.label.shellacc', true), "cpanel_shell"); $shell->attach($fields->fieldCheckbox("meta[shellaccess]", 1, $this->Html->ifSet($vars->meta['shellaccess'], false))); $fields->setField($shell); $cgi = $fields->label(Language::_('Cpe.label.cgiacc', true), "cpanel_cgi"); $cgi->attach($fields->fieldCheckbox("meta[cgi]", 1, $this->Html->ifSet($vars->meta['cgi'], false))); $fields->setField($cgi); $frontpageext = $fields->label(Language::_('Cpe.label.frontpageext', true), "cpanel_fpe"); $frontpageext->attach($fields->fieldCheckbox("meta[frontpageext]", 1, $this->Html->ifSet($vars->meta['frontpageext'], false))); $fields->setField($frontpageext); $cptheme = $fields->label(Language::_('Cpe.label.cptheme', true), "cpanel_theme"); $cptheme->attach($fields->fieldText("meta[cptheme]", $this->Html->ifSet($vars->meta['cptheme']), array("style" => "width: 75px;"))); $fields->setField($cptheme); $maxftp = $fields->label(Language::_('Cpe.label.maxftp', true), "cpanel_maxftp"); $maxftp->attach($fields->fieldText("meta[maxftp]", $this->Html->ifSet($vars->meta['maxftp']), array("style" => "width: 75px;"))); $fields->setField($maxftp); $maxsql = $fields->label(Language::_('Cpe.label.maxsql', true), "cpanel_maxsql"); $maxsql->attach($fields->fieldText("meta[maxsql]", $this->Html->ifSet($vars->meta['maxsql']), array("style" => "width: 75px;"))); $fields->setField($maxsql); $maxpop = $fields->label(Language::_('Cpe.label.maxpop', true), "cpanel_maxpop"); $maxpop->attach($fields->fieldText("meta[maxpop]", $this->Html->ifSet($vars->meta['maxpop']), array("style" => "width: 75px;"))); $fields->setField($maxpop); $dedicatedip = $fields->label(Language::_('Cpe.label.dedip', true), "cpanel_dedicatedip"); $dedicatedip->attach($fields->fieldCheckbox("meta[dedicatedip]", 1, $this->Html->ifSet($vars->meta['dedicatedip'], false))); $fields->setField($dedicatedip); $maxdb = $fields->label(Language::_('Cpe.label.maxsql', true), "cpanel_maxdatabases"); $maxdb->attach($fields->fieldText("meta[maxdatabases]", $this->Html->ifSet($vars->meta['maxdatabases']), array("style" => "width: 75px;"))); $fields->setField($maxdb); $maxsubdomains = $fields->label(Language::_('Cpe.label.maxsub', true), "cpanel_maxsubdomains"); $maxsubdomains->attach($fields->fieldText("meta[maxsubdomains]", $this->Html->ifSet($vars->meta['maxsubdomains']), array("style" => "width: 75px;"))); $fields->setField($maxsubdomains); $maxparkeddomains = $fields->label(Language::_('Cpe.label.maxpark', true), "cpanel_maxparkeddomains"); $maxparkeddomains->attach($fields->fieldText("meta[maxparkeddomains]", $this->Html->ifSet($vars->meta['maxparkeddomains']), array("style" => "width: 75px;"))); $fields->setField($maxparkeddomains); $maxaddondomains = $fields->label(Language::_('Cpe.label.maxaddon', true), "cpanel_maxaddondomains"); $maxaddondomains->attach($fields->fieldText("meta[maxaddondomains]", $this->Html->ifSet($vars->meta['maxaddondomains']), array("style" => "width: 75px;"))); $fields->setField($maxaddondomains); $type = $fields->label(Language::_('Cpe.label.type', true), "cpanel_type"); $type->attach($fields->fieldSelect("meta[type]", array("standard" => "standard", "reseller" => "reseller"), $this->Html->ifSet($vars->meta['type']))); $fields->setField($type); $diskreseller = $fields->label(Language::_('Cpe.label.diskreseller', true), "cpanel_diskreseller"); $diskreseller->attach($fields->fieldText("meta[diskreseller]", $this->Html->ifSet($vars->meta['diskreseller']), array("style" => "width: 75px;"))); $diskreseller->attach($fields->tooltip(Language::_('Cpe.tooltip.quota', true))); $fields->setField($diskreseller); $bandreseller = $fields->label(Language::_('Cpe.label.bandreseller', true), "cpanel_bandreseller"); $bandreseller->attach($fields->fieldText("meta[bandreseller]", $this->Html->ifSet($vars->meta['bandreseller']), array("style" => "width: 75px;"))); $bandreseller->attach($fields->tooltip(Language::_('Cpe.tooltip.quota', true))); $fields->setField($bandreseller); // Set the cPanel package as a selectable option $acl = $fields->label(Language::_('Cpe.label.acl', true), "cpanel_acl"); $acl->attach($fields->fieldSelect("meta[acl]", $acls, $this->Html->ifSet($vars->meta['acl']), array('id' => "cpanel_acl"))); $fields->setField($acl); // Enable/Disable Sections $dashboard = $fields->label(Language::_('Cpe.dashboard', true), "cpanel_dashboard"); $dashboard->attach($fields->fieldSelect("meta[dashboard]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['dashboard']))); $fields->setField($dashboard); $details = $fields->label(Language::_('Cpe.details', true), "cpanel_details"); $details->attach($fields->fieldSelect("meta[details]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['details']))); $fields->setField($details); $statistics = $fields->label(Language::_('Cpe.stats', true), "cpanel_statistics"); $statistics->attach($fields->fieldSelect("meta[statistics]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['statistics']))); $fields->setField($statistics); $changepass = $fields->label(Language::_('Cpe.changepass', true), "cpanel_changepass"); $changepass->attach($fields->fieldSelect("meta[changepass]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['changepass']))); $fields->setField($changepass); $ftpaccounts = $fields->label(Language::_('Cpe.ftp', true), "cpanel_ftpaccounts"); $ftpaccounts->attach($fields->fieldSelect("meta[ftpaccounts]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['ftpaccounts']))); $fields->setField($ftpaccounts); $webdisk = $fields->label(Language::_('Cpe.webdisk', true), "cpanel_webdisk"); $webdisk->attach($fields->fieldSelect("meta[webdisk]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['webdisk']))); $fields->setField($webdisk); $backups = $fields->label(Language::_('Cpe.backups', true), "cpanel_backups"); $backups->attach($fields->fieldSelect("meta[backups]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['backups']))); $fields->setField($backups); $databases = $fields->label(Language::_('Cpe.databases', true), "cpanel_databases"); $databases->attach($fields->fieldSelect("meta[databases]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['databases']))); $fields->setField($databases); $remotedatabase = $fields->label(Language::_('Cpe.remotedatabase', true), "cpanel_remotedatabase"); $remotedatabase->attach($fields->fieldSelect("meta[remotedatabase]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['remotedatabase']))); $fields->setField($remotedatabase); $emails = $fields->label(Language::_('Cpe.emails', true), "cpanel_emails"); $emails->attach($fields->fieldSelect("meta[emails]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['emails']))); $fields->setField($emails); $emailforwarder = $fields->label(Language::_('Cpe.emailforwarder', true), "cpanel_emailforwarder"); $emailforwarder->attach($fields->fieldSelect("meta[emailforwarder]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['emailforwarder']))); $fields->setField($emailforwarder); $subdomains = $fields->label(Language::_('Cpe.subdomains', true), "cpanel_subdomains"); $subdomains->attach($fields->fieldSelect("meta[subdomains]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['subdomains']))); $fields->setField($subdomains); $parkeddomains = $fields->label(Language::_('Cpe.parkeddomains', true), "cpanel_parkeddomains"); $parkeddomains->attach($fields->fieldSelect("meta[parkeddomains]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['subdomains']))); $fields->setField($parkeddomains); $addondomains = $fields->label(Language::_('Cpe.addondomains', true), "cpanel_addondomains"); $addondomains->attach($fields->fieldSelect("meta[addondomains]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['addondomains']))); $fields->setField($addondomains); $dnszone = $fields->label(Language::_('Cpe.dns_zone', true), "cpanel_dnszone"); $dnszone->attach($fields->fieldSelect("meta[dnszone]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['dnszone']))); $fields->setField($dnszone); $cron = $fields->label(Language::_('Cpe.cron', true), "cpanel_cron"); $cron->attach($fields->fieldSelect("meta[cron]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['cron']))); $fields->setField($cron); $blockip = $fields->label(Language::_('Cpe.blockip', true), "cpanel_blockip"); $blockip->attach($fields->fieldSelect("meta[blockip]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['blockip']))); $fields->setField($blockip); $ssh = $fields->label(Language::_('Cpe.ssh', true), "cpanel_ssh"); $ssh->attach($fields->fieldSelect("meta[ssh]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['ssh']))); $fields->setField($ssh); $ssl = $fields->label(Language::_('Cpe.ssl', true), "cpanel_ssl"); $ssl->attach($fields->fieldSelect("meta[ssl]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['ssl']))); $fields->setField($ssl); $softaculous = $fields->label(Language::_('Cpe.softaculous', true), "cpanel_softaculous"); $softaculous->attach($fields->fieldSelect("meta[softaculous]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['softaculous']))); $fields->setField($softaculous); $loginto = $fields->label(Language::_('Cpe.loginto', true), "cpanel_loginto"); $loginto->attach($fields->fieldSelect("meta[loginto]", array("true" => Language::_('Cpe.label.enable', true), "false" => Language::_('Cpe.label.disable', true)), $this->Html->ifSet($vars->meta['loginto']))); $fields->setField($loginto); return $fields; }
/** * Returns all fields used when adding/editing a package, including any * javascript to execute when the page is rendered with these fields. * * @param $vars stdClass A stdClass object representing a set of post fields * @return ModuleFields A ModuleFields object, containg the fields to render as well as any additional HTML markup to include */ public function getPackageFields($vars = null) { Loader::loadHelpers($this, array("Html")); $fields = new ModuleFields(); $fields->setHtml("\n\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t// Set whether to show or hide the ACL option\n\t\t\t\t\t\$('#cpanel_acl').closest('li').hide();\n\t\t\t\t\tif (\$('input[name=\"meta[type]\"]:checked').val() == 'reseller')\n\t\t\t\t\t\t\$('#cpanel_acl').closest('li').show();\n\t\t\t\t\t\$('input[name=\"meta[type]\"]').change(function() {\n\t\t\t\t\t\tif (\$(this).val() == 'reseller')\n\t\t\t\t\t\t\t\$('#cpanel_acl').closest('li').show();\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\$('#cpanel_acl').closest('li').hide();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t</script>\n\t\t"); $row = $this->getCorrectModuleRow($vars); $api = $this->getApiByMeta($row->meta); if (!isset($this->ArrayHelper)) { $this->ArrayHelper = $this->DataStructure->create("Array"); } $packages = array("" => Language::_('Cpe.label.defaultpackage', true)); $acls = array("" => Language::_('Cpe.label.default', true)); if ($row) { $pkglist = $api->listpkgs()->getResponse(); $aclslist = $api->listacls()->getResponse(); //Generate a list with all ACLS $keys = (array) $this->Json->decode($api->listacls())->acls; $acls = array("" => Language::_('Cpe.label.default', true)); foreach ($keys as $key => $value) { $acls[$key] = $key; } //$fields->setHtml($this->debug($acls)); $packages = array("" => Language::_('Cpe.label.defaultpackage', true)) + $this->ArrayHelper->numericToKey($pkglist->package, "name", "name"); } $fields->setHtml(Language::_('Cpe.misc.packageaddhint', true)); // Set the cPanel package as a selectable option $package = $fields->label(Language::_('Cpe.label.package', true), "cpanel_package"); $package->attach($fields->fieldSelect("meta[package]", $packages, $this->Html->ifSet($vars->meta['package']), array('id' => "cpanel_package"))); $fields->setField($package); $quota = $fields->label(Language::_('Cpe.label.webquota', true), "cpanel_quota"); $quota->attach($fields->fieldText("meta[webquota]", $this->Html->ifSet($vars->meta['webquota']), array("style" => "width: 75px;"))); $quota->attach($fields->tooltip(Language::_('Cpe.tooltip.quota', true))); $fields->setField($quota); $bw = $fields->label(Language::_('Cpe.label.bandwidth', true), "cpanel_bw"); $bw->attach($fields->fieldText("meta[bandwidth]", $this->Html->ifSet($vars->meta['bandwidth']), array("style" => "width: 75px;"))); $bw->attach($fields->tooltip(Language::_('Cpe.bandwidth.tooltip'))); $fields->setField($bw); $shell = $fields->label(Language::_('Cpe.label.shellacc', true), "cpanel_shell"); $shell->attach($fields->fieldCheckbox("meta[shellaccess]", 1, $this->Html->ifSet($vars->meta['shellaccess'], false))); $fields->setField($shell); $cgi = $fields->label(Language::_('Cpe.label.cgiacc', true), "cpanel_cgi"); $cgi->attach($fields->fieldCheckbox("meta[cgi]", 1, $this->Html->ifSet($vars->meta['cgi'], false))); $fields->setField($cgi); $frontpageext = $fields->label(Language::_('Cpe.label.frontpageext', true), "cpanel_fpe"); $frontpageext->attach($fields->fieldCheckbox("meta[frontpageext]", 1, $this->Html->ifSet($vars->meta['frontpageext'], false))); $fields->setField($frontpageext); $cptheme = $fields->label(Language::_('Cpe.label.cptheme', true), "cpanel_theme"); $cptheme->attach($fields->fieldText("meta[cptheme]", $this->Html->ifSet($vars->meta['cptheme']), array("style" => "width: 75px;"))); $fields->setField($cptheme); $maxftp = $fields->label(Language::_('Cpe.label.maxftp', true), "cpanel_maxftp"); $maxftp->attach($fields->fieldText("meta[maxftp]", $this->Html->ifSet($vars->meta['maxftp']), array("style" => "width: 75px;"))); $fields->setField($maxftp); $maxsql = $fields->label(Language::_('Cpe.label.maxsql', true), "cpanel_maxsql"); $maxsql->attach($fields->fieldText("meta[maxsql]", $this->Html->ifSet($vars->meta['maxsql']), array("style" => "width: 75px;"))); $fields->setField($maxsql); $maxpop = $fields->label(Language::_('Cpe.label.maxpop', true), "cpanel_maxpop"); $maxpop->attach($fields->fieldText("meta[maxpop]", $this->Html->ifSet($vars->meta['maxpop']), array("style" => "width: 75px;"))); $fields->setField($maxpop); $dedicatedip = $fields->label(Language::_('Cpe.label.dedip', true), "cpanel_dedicatedip"); $dedicatedip->attach($fields->fieldCheckbox("meta[dedicatedip]", 1, $this->Html->ifSet($vars->meta['dedicatedip'], false))); $fields->setField($dedicatedip); $maxdb = $fields->label("Max SQL Databases", "cpanel_maxdatabases"); $maxdb->attach($fields->fieldText("meta[maxdatabases]", $this->Html->ifSet($vars->meta['maxdatabases']), array("style" => "width: 75px;"))); $fields->setField($maxdb); $maxsubdomains = $fields->label(Language::_('Cpe.label.maxsub', true), "cpanel_maxsubdomains"); $maxsubdomains->attach($fields->fieldText("meta[maxsubdomains]", $this->Html->ifSet($vars->meta['maxsubdomains']), array("style" => "width: 75px;"))); $fields->setField($maxsubdomains); $maxparkeddomains = $fields->label(Language::_('Cpe.label.maxpark', true), "cpanel_maxparkeddomains"); $maxparkeddomains->attach($fields->fieldText("meta[maxparkeddomains]", $this->Html->ifSet($vars->meta['maxparkeddomains']), array("style" => "width: 75px;"))); $fields->setField($maxparkeddomains); $maxaddondomains = $fields->label(Language::_('Cpe.label.maxaddon', true), "cpanel_maxaddondomains"); $maxaddondomains->attach($fields->fieldText("meta[maxaddondomains]", $this->Html->ifSet($vars->meta['maxaddondomains']), array("style" => "width: 75px;"))); $fields->setField($maxaddondomains); $type = $fields->label(Language::_('Cpe.label.type', true), "cpanel_type"); $type->attach($fields->fieldSelect("meta[type]", array("standard" => "standard", "reseller" => "reseller"), $this->Html->ifSet($vars->meta['type']))); $fields->setField($type); // Set the cPanel package as a selectable option $acl = $fields->label(Language::_('Cpe.label.acl', true), "cpanel_acl"); $acl->attach($fields->fieldSelect("meta[acl]", $acls, $this->Html->ifSet($vars->meta['acl']), array('id' => "cpanel_acl"))); $fields->setField($acl); return $fields; }