Exemple #1
0
            foreach ($data['mailing_lists'] as $mailing_list_id) {
                $lists[] = $mailing_lists[$mailing_list_id]['object'];
            }
            $newsletters[$newsletter_id]['mailing_list_names'] = implode(', ', $lists);
        }
    }
    Registry::get('view')->assign('newsletter_type', $newsletter_type);
    Registry::get('view')->assign('mailing_lists', $mailing_lists);
    Registry::get('view')->assign('newsletters', $newsletters);
    Registry::get('view')->assign('search', $search);
    fn_newsletters_generate_sections($newsletter_type);
} elseif ($mode == 'campaigns') {
    list($campaigns, $search) = fn_get_campaigns($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'));
    Registry::get('view')->assign('campaigns', $campaigns);
    Registry::get('view')->assign('search', $search);
    fn_newsletters_generate_sections('C');
} elseif ($mode == 'campaign_stats') {
    $campaign = db_get_row("SELECT c.*, d.* FROM ?:newsletter_campaigns AS c INNER JOIN ?:common_descriptions AS d ON c.campaign_id=d.object_id LEFT JOIN ?:newsletters ON c.campaign_id=?:newsletters.campaign_id WHERE d.object_holder='newsletter_campaigns' AND c.campaign_id = ?i AND d.lang_code = ?s", $_REQUEST['campaign_id'], DESCR_SL);
    $stats = db_get_array("SELECT n.*, d.*, SUM(e.clicks) AS clicks FROM ?:newsletters AS n INNER JOIN ?:newsletter_descriptions AS d ON n.newsletter_id=d.newsletter_id LEFT JOIN ?:newsletter_links AS e ON n.newsletter_id = e.newsletter_id AND e.campaign_id = n.campaign_id WHERE n.campaign_id=?i AND d.lang_code = ?s GROUP BY e.newsletter_id", $_REQUEST['campaign_id'], DESCR_SL);
    Registry::get('view')->assign('campaign', $campaign);
    Registry::get('view')->assign('campaign_stats', $stats);
}
function fn_delete_campaigns($campaign_ids)
{
    db_query("DELETE FROM ?:common_descriptions WHERE object_id IN (?n) AND object_holder = 'newsletter_campaigns'", $campaign_ids);
    db_query("DELETE FROM ?:newsletter_campaigns WHERE campaign_id IN (?n)", $campaign_ids);
    db_query("DELETE FROM ?:newsletter_links WHERE campaign_id IN (?n)", $campaign_ids);
    db_query("UPDATE ?:newsletters SET campaign_id = 0 WHERE campaign_id IN (?n)", $campaign_ids);
}
function fn_delete_newsletter($newsletter_id)
{
Exemple #2
0
            foreach (explode(',', $subscriber['list_ids']) as $list_id) {
                $subscriber['mailing_lists'][$list_id] = fn_get_mailing_list_data($list_id, DESCR_SL);
                // get additional user-specific data for each mailing list (like lang_code)
                $_where = array('list_id' => $list_id, 'subscriber_id' => $subscriber['subscriber_id']);
                $subscriber_list_data = db_get_row("SELECT * FROM ?:user_mailing_lists WHERE ?w", $_where);
                $subscriber['mailing_lists'][$list_id] = array_merge($subscriber['mailing_lists'][$list_id], $subscriber_list_data);
                $subscriber['lang_code'] = $subscriber['mailing_lists'][$list_id]['lang_code'];
            }
            unset($subscriber['list_ids']);
        }
    }
    $mailing_lists = db_get_hash_array("SELECT m.list_id, d.object, ?:newsletters.newsletter_id as register_autoresponder FROM ?:mailing_lists AS m INNER JOIN ?:common_descriptions AS d ON m.list_id=d.object_id LEFT JOIN ?:newsletters ON m.register_autoresponder = ?:newsletters.newsletter_id AND ?:newsletters.status = 'A' WHERE d.object_holder='mailing_lists' AND d.lang_code = ?s", 'list_id', DESCR_SL);
    Tygh::$app['view']->assign('mailing_lists', $mailing_lists);
    Tygh::$app['view']->assign('subscribers', $subscribers);
    Tygh::$app['view']->assign('search', $search);
    fn_newsletters_generate_sections('subscribers');
}
function fn_get_subscribers($params, $items_per_page = 0, $lang_code = CART_LANGUAGE)
{
    // Init filter
    $params = LastView::instance()->update('subscribers', $params);
    // Set default values to input params
    $default_params = array('page' => 1, 'items_per_page' => $items_per_page);
    $params = array_merge($default_params, $params);
    // Define fields that should be retrieved
    $fields = array('?:subscribers.subscriber_id', '?:subscribers.email', '?:subscribers.timestamp', '?:subscribers.subscriber_id', "GROUP_CONCAT(?:user_mailing_lists.list_id) as list_ids");
    // Define sort fields
    $sortings = array('email' => '?:subscribers.email', 'timestamp' => '?:subscribers.timestamp');
    $condition = '';
    $group_by = "?:subscribers.subscriber_id";
    $join = db_quote(" LEFT JOIN ?:user_mailing_lists ON ?:user_mailing_lists.subscriber_id = ?:subscribers.subscriber_id");
Exemple #3
0
    list($autoresponders) = fn_get_newsletters(array('type' => NEWSLETTER_TYPE_AUTORESPONDER, 'only_available' => false), 0, DESCR_SL);
    Registry::get('view')->assign('autoresponders', $autoresponders);
    Registry::get('view')->assign('mailing_list', fn_get_mailing_list_data($_REQUEST['list_id'], DESCR_SL));
} elseif ($mode == 'manage') {
    $params = $_REQUEST;
    $params['only_available'] = false;
    list($mailing_lists) = fn_get_mailing_lists($params, 0, DESCR_SL);
    $subscribers = db_get_hash_array("SELECT * FROM ?:subscribers", 'subscriber_id');
    foreach ($mailing_lists as &$list) {
        $list['subscribers_num'] = db_get_field("SELECT COUNT(*) FROM ?:user_mailing_lists WHERE list_id = ?i", $list['list_id']);
    }
    list($autoresponders) = fn_get_newsletters(array('type' => NEWSLETTER_TYPE_AUTORESPONDER, 'only_available' => false), 0, DESCR_SL);
    Registry::get('view')->assign('mailing_lists', $mailing_lists);
    Registry::get('view')->assign('autoresponders', $autoresponders);
    Registry::get('view')->assign('subscribers', $subscribers);
    fn_newsletters_generate_sections('mailing_lists');
}
function fn_update_mailing_list($mailing_list_data, $list_id, $lang_code = DESCR_SL)
{
    if (empty($list_id)) {
        $list_id = db_query("INSERT INTO ?:mailing_lists ?e", $mailing_list_data);
        $_data = $mailing_list_data;
        $_data['object_id'] = $list_id;
        $_data['object_holder'] = 'mailing_lists';
        $_data['object'] = $_data['name'];
        foreach (fn_get_translation_languages() as $_data['lang_code'] => $v) {
            db_query("REPLACE INTO ?:common_descriptions ?e", $_data);
        }
    } else {
        db_query("UPDATE ?:mailing_lists SET ?u WHERE list_id = ?i", $mailing_list_data, $list_id);
        $_data = $mailing_list_data;