/** * Generate page data * * @param iMSCP_pTemplate $tpl * @return void */ function admin_generatePageData($tpl) { $senderName = isset($_POST['sender_name']) ? $_POST['sender_name'] : ''; $senderEmail = isset($_POST['sender_email']) ? $_POST['sender_email'] : ''; $rcptTo = isset($_POST['rcpt_to']) ? $_POST['rcpt_to'] : ''; $subject = isset($_POST['subject']) ? $_POST['subject'] : ''; $body = isset($_POST['body']) ? $_POST['body'] : ''; if ($senderName == '' && $senderEmail == '') { $query = 'SELECT `admin_name`, `fname`, `lname`, `email` FROM `admin` WHERE `admin_id` = ?'; $stmt = exec_query($query, $_SESSION['user_id']); $data = $stmt->fetchRow(); if (!empty($data['fname']) && !empty($data['lname'])) { $senderName = $data['fname'] . ' ' . $data['lname']; } elseif (!empty($data['fname'])) { $senderName = $stmt->fields['fname']; } elseif (!empty($data['lname'])) { $senderName = $stmt->fields['lname']; } else { $senderName = $data['admin_name']; } if ($data['email'] != '') { $senderEmail = $data['email']; } else { $config = iMSCP_Registry::get('config'); if (isset($config['DEFAULT_ADMIN_ADDRESS']) && $config['DEFAULT_ADMIN_ADDRESS'] != '') { $senderEmail = $config['DEFAULT_ADMIN_ADDRESS']; } else { $senderEmail = 'webmaster@' . $config['BASE_SERVER_VHOST']; } } } $tpl->assign(array('SENDER_NAME' => tohtml($senderName), 'SENDER_EMAIL' => tohtml($senderEmail), 'SUBJECT' => tohtml($subject), 'BODY' => tohtml($body))); $rcptToOptions = array(array('all_users', tr('All users'))); if (systemHasManyAdmins() && systemHasResellers()) { $rcptToOptions[] = array('administrators_resellers', tr('Administrators and resellers')); } if (systemHasManyAdmins() && systemHasCustomers()) { $rcptToOptions[] = array('administrators_customers', tr('Administrators and customers')); } if (systemHasResellers() && systemHasCustomers()) { $rcptToOptions[] = array('resellers_customers', tr('Resellers and customers')); } if (systemHasManyAdmins()) { $rcptToOptions[] = array('administrators', tr('Administrators')); } if (systemHasResellers()) { $rcptToOptions[] = array('resellers', tr('Resellers')); } if (systemHasCustomers()) { $rcptToOptions[] = array('customers', tr('Customers')); } foreach ($rcptToOptions as $option) { $tpl->assign(array('RCPT_TO' => $option[0], 'TR_RCPT_TO' => $option[1], 'SELECTED' => $rcptTo == $option[0] ? ' selected="selected"' : '')); $tpl->parse('RCPT_TO_OPTION', '.rcpt_to_option'); } }
function generatePage($tpl) { $stmt = execute_query("SELECT admin_id, admin_name FROM admin WHERE admin_type = 'reseller'"); while ($row = $stmt->fetchRow(PDO::FETCH_ASSOC)) { _generateResellerStatistics($tpl, $row['admin_id'], $row['admin_name']); $tpl->parse('RESELLER_STATISTICS_BLOCK', '.reseller_statistics_block'); } } /*********************************************************************************************************************** * Main */ require 'imscp-lib.php'; $eventManager = iMSCP_Events_Aggregator::getInstance(); $eventManager->dispatch(iMSCP_Events::onAdminScriptStart); check_login('admin'); if (systemHasResellers()) { $tpl = new iMSCP_pTemplate(); $tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'admin/reseller_statistics.tpl', 'page_message' => 'layout', 'reseller_statistics_block' => 'page')); $tpl->assign(array('TR_PAGE_TITLE' => tohtml(tr('Admin / Statistics / Reseller Statistics')), 'TR_RESELLER_NAME' => tohtml(tr('Reseller')), 'TR_TRAFFIC_USAGE' => tohtml(tr('Traffic usage')), 'TR_DISK_USAGE' => tohtml(tr('Disk usage')), 'TR_DOMAINS' => tohtml(tr('Domains')), 'TR_SUBDOMAINS' => tohtml(tr('Subdomains')), 'TR_DOMAIN_ALIASES' => tohtml(tr('Domain aliases')), 'TR_MAIL_ACCOUNTS' => tohtml(tr('Email accounts')), 'TR_FTP_ACCOUNTS' => tohtml(tr('FTP accounts')), 'TR_SQL_DATABASES' => tohtml(tr('SQL databases')), 'TR_SQL_USERS' => tohtml(tr('SQL users')), 'TR_DETAILED_STATS_TOOLTIPS' => tohtml(tr('Show detailed statistics for this reseller'), 'htmlAttr'))); $eventManager->registerListener('onGetJsTranslations', function ($e) { /** @var $e \iMSCP_Events_Event */ $e->getParam('translations')->core['dataTable'] = getDataTablesPluginTranslations(false); }); generateNavigation($tpl); generatePage($tpl); generatePageMessage($tpl); $tpl->parse('LAYOUT_CONTENT', 'page'); $eventManager->dispatch(iMSCP_Events::onAdminScriptEnd, array('templateEngine' => $tpl)); $tpl->prnt(); unsetMessages(); } else {
} $errorsStack .= tr('<b>%s</b> has IP address that cannot be managed from the destination reseller!<br />This user cannot be moved!', $domainName); return false; } } return true; } /*********************************************************************************************************************** * Main * */ // Include core library require 'imscp-lib.php'; iMSCP_Events_Aggregator::getInstance()->dispatch(iMSCP_Events::onAdminScriptStart); check_login('admin'); if (!systemHasResellers(2)) { showBadRequestErrorPage(); } /** @var $cfg iMSCP_Config_Handler_File */ $cfg = iMSCP_Registry::get('config'); if (isset($_POST['uaction']) && $_POST['uaction'] == 'move_user' && check_user_data()) { set_page_message(tr('Customer(s) successfully moved.'), 'success'); redirectTo('manage_users.php'); } $tpl = new iMSCP_pTemplate(); $tpl->define_dynamic(array('layout' => 'shared/layouts/ui.tpl', 'page' => 'admin/manage_reseller_users.tpl', 'page_message' => 'layout', 'reseller_list' => 'page', 'reseller_item' => 'page', 'src_reseller' => 'page', 'src_reseller_option' => 'src_reseller', 'dst_reseller' => 'page', 'dst_reseller_option' => 'dst_reseller')); $tpl->assign(array('TR_PAGE_TITLE' => tr('Admin / Users / Customers Assignment'), 'TR_USER_ASSIGNMENT' => tr('User assignment'), 'TR_RESELLER_USERS' => tr('Users'), 'TR_CUSTOMER_ID' => tr('Customer ID'), 'TR_MARK' => tr('Mark'), 'TR_USER_NAME' => tr('Username'), 'TR_FROM_RESELLER' => tr('From reseller'), 'TR_TO_RESELLER' => tr('To reseller'), 'TR_MOVE' => tr('Move'))); iMSCP_Events_Aggregator::getInstance()->registerListener('onGetJsTranslations', function ($e) { /** @var $e \iMSCP_Events_Event */ $e->getParam('translations')->core['dataTable'] = getDataTablesPluginTranslations(false); });
/** * Whether or not system has registered resellers or customers. * * @return bool */ function systemHasResellersOrCustomers() { if (systemHasResellers() || systemHasCustomers()) { return true; } return false; }