<?php
//區塊主函式 (電子報訂閱)
function tadnews_newspaper($options)
{
    global $xoopsDB, $xoopsUser;

    $sql = "SELECT count(*) FROM " . $xoopsDB->prefix("tad_news_paper_email") . "";
    $result = $xoopsDB->query($sql) or web_error($sql);
    list($counter) = $xoopsDB->fetchRow($result);

    //找出現有設定組
    $sql    = "SELECT nps_sn,title FROM " . $xoopsDB->prefix("tad_news_paper_setup") . " WHERE status='1'";
    $result = $xoopsDB->query($sql);
    $i      = 0;
    $option = "";
    while (list($nps_sn, $title) = $xoopsDB->fetchRow($result)) {
        $option[$i]['value'] = $nps_sn;
        $option[$i]['text']  = $title;
        $i++;
    }
    if (empty($option)) {
        return;
    }

    $block['counter'] = sprintf(_MB_TADNEWS_ORDER_COUNT, $counter);
    $block['option']  = $option;
    $block['email']   = $xoopsUser ? $xoopsUser->email() : "";
    return $block;
}
