function gen_user_als_list(&$tpl, &$sql, $user_id)
{
    $domain_id = get_user_domain_id($sql, $user_id);
    $query = <<<SQL_QUERY
        select
            alias_id, alias_name, alias_status, alias_mount, alias_ip_id, url_forward
        from
            domain_aliasses
        where
            domain_id = ?
        order by
            alias_name
SQL_QUERY;
    $rs = exec_query($sql, $query, array($domain_id));
    if ($rs->RecordCount() == 0) {
        $tpl->assign(array('ALS_MSG' => tr('Alias list is empty!'), 'ALS_LIST' => ''));
        $tpl->parse('ALS_MESSAGE', 'als_message');
    } else {
        $counter = 0;
        while (!$rs->EOF) {
            if ($counter % 2 == 0) {
                $tpl->assign('ITEM_CLASS', 'content');
            } else {
                $tpl->assign('ITEM_CLASS', 'content2');
            }
            list($als_action, $als_action_script) = gen_user_als_action($rs->fields['alias_id'], $rs->fields['alias_status']);
            list($als_forward, $als_forward_script) = gen_user_als_forward($rs->fields['alias_id'], $rs->fields['alias_status'], $rs->fields['url_forward']);
            $IDN = new idna_convert();
            $alias_name = $IDN->decode($rs->fields['alias_name']);
            $alias_name = utf8_decode($alias_name);
            $tpl->assign(array('ALS_NAME' => $alias_name, 'ALS_MOUNT' => $rs->fields['alias_mount'], 'ALS_STATUS' => translate_dmn_status($rs->fields['alias_status']), 'ALS_FORWARD' => $als_forward, 'ALS_FWD_SCRIPT' => $als_forward_script, 'ALS_ACTION' => $als_action, 'ALS_ACTION_SCRIPT' => $als_action_script));
            $tpl->parse('ALS_ITEM', '.als_item');
            $rs->MoveNext();
            $counter++;
        }
        $tpl->parse('ALS_LIST', 'als_list');
        $tpl->assign('ALS_MESSAGE', '');
    }
}
示例#2
0
/**
 * @param EasySCP_TemplateEngine $tpl
 * @param int $user_id
 */
function gen_user_als_list($tpl, $user_id)
{
    $sql = EasySCP_Registry::get('Db');
    $domain_id = get_user_domain_id($user_id);
    $query = "\n\t\tSELECT\n\t\t\t`alias_id`,\n\t\t\t`alias_name`,\n\t\t\t`status`,\n\t\t\t`alias_mount`,\n\t\t\t`alias_ip_id`,\n\t\t\t`url_forward`\n\t\tFROM\n\t\t\t`domain_aliasses`\n\t\tWHERE\n\t\t\t`domain_id` = ?\n\t\tORDER BY\n\t\t\t`alias_mount`,\n\t\t\t`alias_name`\n\t;";
    $rs = exec_query($sql, $query, $domain_id);
    if ($rs->recordCount() == 0) {
        $tpl->assign(array('ALS_MSG' => tr('Alias list is empty!'), 'ALS_MSG_TYPE' => 'info', 'ALS_LIST' => ''));
    } else {
        while (!$rs->EOF) {
            list($als_action, $als_action_script) = gen_user_als_action($rs->fields['alias_id'], $rs->fields['status']);
            list($als_forward, $alias_edit_link, $als_edit) = gen_user_als_forward($rs->fields['alias_id'], $rs->fields['status'], $rs->fields['url_forward']);
            $alias_name = decode_idna($rs->fields['alias_name']);
            $als_forward = decode_idna($als_forward);
            $tpl->append(array('ALS_NAME' => tohtml($alias_name), 'ALS_MOUNT' => tohtml($rs->fields['alias_mount']), 'ALS_STATUS' => translate_dmn_status($rs->fields['status']), 'ALS_FORWARD' => tohtml($als_forward), 'ALS_EDIT_LINK' => $alias_edit_link, 'ALS_EDIT' => $als_edit, 'ALS_ACTION' => $als_action, 'ALS_ACTION_SCRIPT' => $als_action_script));
            $rs->moveNext();
        }
        $tpl->assign('ALS_MESSAGE', '');
    }
}