Exemplo n.º 1
0
/**
 * 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');
    }
}
Exemplo n.º 2
0
/**
 * Whether or not system has registered admins (many), resellers or customers.
 *
 * @return bool
 */
function systemHasAdminsOrResellersOrCustomers()
{
    if (systemHasManyAdmins() || systemHasResellers() || systemHasCustomers()) {
        return true;
    }
    return false;
}