* GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) */ namespace Panel\Vmail; class Mboxes extends \Panel\Vmail { function beforeRoute($f3) { parent::beforeRoute($f3); $domain = $f3->get('PARAMS.domain'); /* first confirm domain exists */ if ($f3->call('\Panel::vGet', "vmail-domains-get.sh -d $domain -c")) { /* check if we are looking for specific email account */ if ($f3->exists('PARAMS.mbox')) { $mbox = $f3->get('PARAMS.mbox'); /* get mailbox */ if ($mboxes_array = $f3->call('\Panel::vGet', array("vmail-mboxes-get.sh -e $mbox@$domain -c", FALSE))) { $f3->set('mboxes_array', $mboxes_array); } } else { /* get mailboxes */ if ($mboxes_array = $f3->call('\Panel::vGet', array("vmail-mboxes-get.sh -d $domain -c", FALSE))) { $f3->set('mboxes_array', $mboxes_array); } } } } public static function get($f3) { $domain = $f3->get('PARAMS.domain'); $mboxes_array = $f3->get('mboxes_array'); if (is_array($mboxes_array) && count($mboxes_array) > 0) { foreach ($mboxes_array as $k=>$mbox_array) { if ($mbox_array['status'] == 0) { $mbox_array['status'] = 'Disabled'; } elseif ($mbox_array['status'] == 1) { $mbox_array['status'] = 'Enabled'; } elseif ($mbox_array['status'] == 2) { $mbox_array['status'] = 'Enabled - Admin'; } if ($mbox_array['quota'] == "NULL") { $mbox_array['quota'] = 'Unlimited'; } else { $mbox_array['quota'] .= ' GB'; } if ($mbox_array['ratelimit'] == "NULL") { $mbox_array['ratelimit'] = 'Unlimited'; } else { $mbox_array['ratelimit'] .= ' emails per hour'; } if ($mbox_array['filter'] == 0) { $mbox_array['filter'] = 'None'; } elseif ($mbox_array['filter'] == 1) { $mbox_array['filter'] = 'Junk Only'; } elseif ($mbox_array['filter'] == 2) { $mbox_array['filter'] = 'Junk & Spam'; } $mboxes_array[$k] = $mbox_array; } } if ($f3->exists('PARAMS.mbox')) { $f3->set('mbox_array', $mboxes_array[0]); $mbox = $f3->get('PARAMS.mbox'); $f3->set('page_header', "Email Account $mbox@$domain Details"); echo \Template::instance()->render('vmail/mboxes-mbox.html'); } else { $f3->set('mboxes_array', $mboxes_array); $domain = $f3->get('PARAMS.domain'); $f3->set('page_header', "Email Accounts for $domain"); echo \Template::instance()->render('vmail/mboxes.html'); } } }