function newsletters_user_register(&$pObject)
 {
     if (!empty($_REQUEST['newsletter_optin'])) {
         // hidden flag to indicate at least one newsletter was displayed
         require_once NEWSLETTERS_PKG_PATH . 'BitNewsletter.php';
         require_once NEWSLETTERS_PKG_PATH . 'BitNewsletterMailer.php';
         if (!empty($_REQUEST['unsub_all'])) {
             $subHash['unsubscribe_all'] = 'y';
         } else {
             $newsletter = new BitNewsletter();
             $pParamHash = array();
             $newsletters = $newsletter->getList($pParamHash);
             foreach (array_keys($newsletters) as $nlContentId) {
                 if (empty($_REQUEST['nl_content_id']) || !in_array($nlContentId, $_REQUEST['nl_content_id'])) {
                     $subHash['unsub_content'][] = $nlContentId;
                     $subHash['unsubscribe_all'] = NULL;
                 }
             }
         }
         if (!empty($subHash)) {
             $subHash['sub_lookup'] = array('user_id' => $pObject->mUserId);
             BitNewsletterMailer::storeSubscriptions($subHash);
         }
     }
 }
Exemple #2
0
 */
/** 
 * Initialization
 */
require_once '../kernel/setup_inc.php';
include_once NEWSLETTERS_PKG_PATH . 'BitNewsletterMailer.php';
$gBitSystem->verifyPackage('newsletters');
if (!$gBitUser->isRegistered() && !$gBitUser->hasPermission('p_newsletters_subscribe') && empty($_REQUEST['c'])) {
    $gBitSystem->fatalError(tra("You must be logged in to subscribe to newsletters"));
}
require_once NEWSLETTERS_PKG_PATH . 'lookup_newsletter_inc.php';
$feedback = array();
/* List newsletters */
$listHash = array();
$newsletters = $gContent->getList($listHash);
$gBitSmarty->assignByRef('subs', BitNewsletter::getUserSubscriptions($gBitUser->getField('user_id'), $gBitUser->getField('email')));
$gBitSmarty->assignByRef('newsletters', $newsletters);
$foo = parse_url($_SERVER["REQUEST_URI"]);
$gBitSmarty->assign('url_subscribe', httpPrefix() . $foo["path"]);
$subinfo = array();
$unsubs = array();
// We have a url_code from a clicked link in an email
if (isset($_REQUEST['c']) && strlen($_REQUEST['c']) == 32 && ($subInfo = BitNewsletterMailer::lookupSubscription(array('url_code' => $_REQUEST['c'])))) {
} elseif ($gBitUser->isRegistered()) {
    if (!($subInfo = BitNewsletterMailer::lookupSubscription(array('user_id' => $gBitUser->mUserId)))) {
        $subInfo = $gBitUser->mInfo;
    }
}
if (!empty($subInfo['user_id']) && BitBase::verifyId($subInfo['user_id'])) {
    $lookup['user_id'] = $subInfo['user_id'];
} else {
<?php

/**
 * Copyright (c) 2005 bitweaver.org
 * All Rights Reserved. See below for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
 *
 * created 2005/12/10
 * @author spider <*****@*****.**>
 *
 * @package newsletters
 */
/** 
 * Initialization
 */
require_once NEWSLETTERS_PKG_PATH . 'BitNewsletter.php';
$listHash = array('registration_optin' => TRUE);
$newsletters = BitNewsletter::getList($listHash);
global $gBitSmarty;
$gBitSmarty->assign('newsletters', $newsletters);
<?php

/**
 * Copyright (c) 2005 bitweaver.org
 * All Rights Reserved. See below for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
 *
 * created 2005/12/10
 *
 * @package newsletters
 * @author spider <*****@*****.**>
 */
/** 
 * Initialization
 */
require_once NEWSLETTERS_PKG_PATH . 'BitNewsletter.php';
if (empty($gContent) || !is_object($gContent) || !$gContent->isValid()) {
    $nlId = !empty($_REQUEST['nl_id']) ? $_REQUEST['nl_id'] : NULL;
    $conId = !empty($_REQUEST['content_id']) ? $_REQUEST['content_id'] : !empty($_REQUEST['nl_content_id']) && is_numeric($_REQUEST['nl_content_id']) ? $_REQUEST['nl_content_id'] : NULL;
    $gContent = new BitNewsletter($nlId, $conId);
    $gContent->load();
    $gBitSmarty->assignByRef('gContent', $gContent);
}
 public static function getList(&$pListHash)
 {
     global $gBitDb;
     if (empty($pParamHash["sort_mode"])) {
         $pListHash['sort_mode'] = 'created_desc';
     }
     BitBase::prepGetList($pListHash);
     $bindVars = array();
     $joinSql = '';
     $mid = '';
     if (@BitBase::verifyId($pListHash['nl_id'])) {
         $mid .= ' AND n.nl_id=? ';
         $bindVars[] = $pListHash['nl_id'];
     }
     if (!empty($pListHash['find'])) {
         $findesc = '%' . $pListHash['find'] . '%';
         $mid .= " AND (`name` like ? or `description` like ?)";
         $bindVars[] = $findesc;
         $bindVars[] = $findesc;
     }
     if (!empty($pListHash['registration_optin'])) {
         $joinSql = " INNER JOIN `" . BIT_DB_PREFIX . "liberty_content_prefs` lcp ON (lcp.`content_id`=n.`content_id` AND lcp.`pref_name`='registration_optin' AND lcp.`pref_value`='y') ";
     }
     $query = "SELECT *\n\t\t\t\t  FROM `" . BIT_DB_PREFIX . "newsletters` n INNER JOIN `" . BIT_DB_PREFIX . "liberty_content` lc ON( n.`content_id`=lc.`content_id`)\n\t\t\t\t\t{$joinSql}\n\t\t\t\t  WHERE n.`content_id`=lc.`content_id` {$mid}\n\t\t\t\t  ORDER BY " . $gBitDb->convertSortmode($pListHash['sort_mode']);
     $result = $gBitDb->query($query, $bindVars, $pListHash['max_records'], $pListHash['offset']);
     $query_cant = "select count(*) from `" . BIT_DB_PREFIX . "newsletters` {$mid}";
     $ret = array();
     while ($res = $result->fetchRow()) {
         $res['display_url'] = BitNewsletter::getDisplayUrlFromHash($res);
         $res["confirmed"] = $gBitDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "mail_subscriptions` WHERE `unsubscribe_date` IS NULL and `content_id`=?", array((int) $res['content_id']));
         $res["unsub_count"] = $gBitDb->getOne("SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "mail_subscriptions` WHERE `content_id`=?", array((int) $res['content_id']));
         $ret[$res['content_id']] = $res;
     }
     return $ret;
 }