subscriberData() 공개 정적인 메소드

@param array $in - The subscriber Data array $p - A parameter array with values as follows :- boolean prune - if true, prune the data array (passed by reference) to only recognized/checked fields boolean ignore - if true, invalid fields will be pruned from $in array -- no error thrown boolean ignoreInactive - if true, invalid inactive fields will be pruned from $in array - no error thrown boolean active - if true, only check data against active fields. Typically true if subscribing via form, false if admin importing. boolean skipReq - if true, skip the required check AND empty fields. boolean log - if true, log invalid fields as error. Typically true if subscribing via form, false if admin importing.
public static subscriberData ( array &$in, $p = [] ) : boolean
$in array
리턴 boolean validation status NOTE: has the MAGIC FUNCTIONALITY of converting date field input to a UNIX TIMESTAMP. This is necessary for quick SQL comparisson of dates, etc. NOTE: has the MAGIC FUNCTINALITY of changing "true"/"false" to checkbox "on"/off equivelent NOTE: has the MAGIC FUNCTIONALITY of trimming leading and trailing whitepace NOTE: has the MAGIC FUNCTIONALITY of shortening value to 60 characters (or 255 if a comment type) TODO -> should fields be passed by reference? e.g. are they usually already available when subscriberData() is called?
예제 #1
0
 *********************************/
if (empty($_POST['pommo_signup'])) {
    Pommo::redirect('login.php');
}
$subscriber = array('email' => $_POST['Email'], 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 1, 'data' => @$_POST['d']);
// ** check for correct email syntax
if (!Pommo_Helper::isEmail($subscriber['email'])) {
    $logger->addErr(Pommo::_T('Invalid Email Address'));
}
// ** check if email already exists in DB ("duplicates are bad..")
if (Pommo_Helper::isDupe($subscriber['email'])) {
    $logger->addErr(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
    $smarty->assign('dupe', TRUE);
}
// check if errors exist with data, if so print results and die.
if ($logger->isErr() || !Pommo_Validate::subscriberData($subscriber['data'], array('active' => FALSE))) {
    $smarty->assign('back', TRUE);
    $smarty->display('user/process.tpl');
    Pommo::kill();
}
$comments = isset($_POST['comments']) ? substr($_POST['comments'], 0, 255) : false;
/**********************************
	ADD SUBSCRIBER
 *********************************/
$config = Pommo_Api::configGet(array('site_success', 'site_confirm', 'list_confirm', 'notices'));
$notices = unserialize($config['notices']);
require_once Pommo::$_baseDir . 'classes/Pommo_Helper_Messages.php';
if ($config['list_confirm'] == 'on') {
    // email confirmation required.
    // add user as "pending"
    $subscriber['pending_code'] = Pommo_Helper::makeCode();
예제 #2
0
 case 'editSubscriber':
     if (!is_numeric($_REQUEST['id']) || $_REQUEST['id'] == 0) {
         $json->fail('ERROR; Bad Subscriber ID Received');
     }
     $subscriber = array('id' => $_REQUEST['id'], 'email' => $_REQUEST['email'], 'data' => $_REQUEST['d']);
     $validateOptions = array('skipReq' => TRUE, 'active' => FALSE);
     // check if email is valid
     if (!Pommo_Helper::isEmail($subscriber['email'])) {
         $json->fail(Pommo::_T('Invalid email.'));
     }
     // check for dupe
     $lookupID = current(Pommo_Subscribers::getIDByEmail($subscriber['email'], array(1, 2)));
     if ($lookupID && $lookupID != $subscriber['id']) {
         $json->fail(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
     }
     if (!Pommo_Validate::subscriberData($subscriber['data'], $validateOptions) && !isset($_REQUEST['force'])) {
         $json->addErr(Pommo::_T('Fields failed validation') . " >>> ");
         $json->addErr($logger->getAll());
         $json->fail(Pommo::_T('Error updating subscriber.'));
     }
     if (!Pommo_Subscribers::update($subscriber, 'REPLACE_ALL')) {
         $json->fail(Pommo::_T('Error updating subscriber.'));
     }
     // subscriber updated successfully, build output
     $out = array('email' => $subscriber['email'], 'id' => $subscriber['id']);
     // return human readable date formatting
     require_once Pommo::$_baseDir . 'classes/Pommo_Fields.php';
     $dateFields = Pommo_Fields::getByType('date');
     foreach ($subscriber['data'] as $k => $val) {
         $out['d' . $k] = in_array($k, $dateFields) ? Pommo_Helper::timeToStr($val) : htmlspecialchars($val);
     }
예제 #3
0
        } elseif ($fid == 'registered') {
            $subscriber['registered'] = Pommo_Helper::timeFromStr($col);
        } elseif ($fid == 'ip') {
            $subscriber['ip'] = $col;
        }
    }
    if ($subscriber['email']) {
        // check for dupe
        // TODO -- DO THIS IN BATCH ??
        if (Pommo_Helper::isDupe($subscriber['email'], $includeUnsubscribed)) {
            $dupes++;
            $dupe_emails[] = $subscriber['email'];
            continue;
        }
        // validate/fix data
        if (!Pommo_Validate::subscriberData($subscriber['data'], array('log' => false, 'ignore' => true, 'active' => false))) {
            $subscriber['flag'] = 9;
        }
        // add subscriber
        if (Pommo_Subscribers::add($subscriber)) {
            $tally++;
            if (isset($subscriber['flag'])) {
                $flagged++;
            }
        }
    }
}
unlink(Pommo::$_workDir . '/import.csv');
echo '<div class="warn"><p>' . sprintf(_('%s subscribers imported! Of these, %s' . ' were flagged to update their records.'), $tally, $flagged) . '<p>' . sprintf(_('%s duplicates encountered.'), $dupes) . '</p></div>';
echo "<table>";
foreach ($dupe_emails as $de) {
예제 #4
0
    $vMsg['email'] = Pommo::_T('Invalid email address');
    $smarty->assign('vMsg', $vMsg);
} else {
    // ___ USER HAS SENT FORM ___
    SmartyValidate::connect($smarty);
    if (SmartyValidate::is_valid($_POST) && !$current) {
        // __ FORM IS VALID
        require_once Pommo::$_baseDir . 'classes/Pommo_Mail_Ctl.php';
        require_once Pommo::$_baseDir . 'classes/Pommo_Subscribers.php';
        require_once Pommo::$_baseDir . 'classes/Pommo_Validate.php';
        // get a copy of the message state
        // composition is valid (via preview.php)
        $state = Pommo::$_session['state']['mailing'];
        // create temp subscriber
        $subscriber = array('email' => $_POST['email'], 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 0, 'data' => $_POST['d']);
        Pommo_Validate::subscriberData($subscriber['data'], array('active' => FALSE, 'ignore' => TRUE, 'log' => false));
        $key = Pommo_Subscribers::add($subscriber);
        if (!$key) {
            $logger->addErr('Unable to Add Subscriber');
        } else {
            // temp subscriber created
            $state['tally'] = 1;
            $state['group'] = Pommo::_T('Test Mailing');
            if ($state['ishtml'] == 'off') {
                $state['body'] = $state['altbody'];
                $state['altbody'] = '';
            }
            // create mailing
            $mailing = Pommo_Mailing::make(array(), TRUE);
            $state['status'] = 1;
            $state['current_status'] = 'stopped';
예제 #5
0
파일: update.php 프로젝트: soonick/poMMo
}
if ($_REQUEST['code'] != Pommo_Subscribers::getActCode($subscriber)) {
    Pommo::kill(Pommo::_T('Invalid activation code.'));
}
// check if we have pending request
if (Pommo_Pending::isPending($subscriber['id'])) {
    $input = urlencode(serialize(array('Email' => $_POST['Email'])));
    Pommo::redirect('pending.php?input=' . $input);
}
$config = Pommo_Api::configGet(array('notices'));
$notices = unserialize($config['notices']);
if (!isset($_POST['d'])) {
    $view->assign('d', $subscriber['data']);
}
// check for an update + validate new subscriber info (also converts dates to ints)
if (!empty($_POST['update']) && Pommo_Validate::subscriberData($_POST['d'])) {
    $newsub = array('id' => $subscriber['id'], 'email' => $subscriber['email'], 'data' => $_POST['d']);
    if (!empty($_POST['newemail'])) {
        // if change in email, validate and send confirmation of update
        if ($_POST['newemail'] != $_POST['newemail2']) {
            $logger->addErr(Pommo::_T('Emails must match.'));
        } elseif (!Pommo_Helper::isEmail($_POST['newemail'])) {
            $logger->addErr(Pommo::_T('Invalid Email Address'));
        } elseif (Pommo_Helper::isDupe($_POST['newemail'])) {
            $logger->addMsg(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
        } else {
            $newsub['email'] = $_POST['newemail'];
            $code = Pommo_Pending::add($newsub, 'change');
            if (!$code) {
                die('Failed to Generate Pending Subscriber Code');
            }