示例#1
0
     $validateOptions = array('skipReq' => TRUE, 'active' => FALSE);
     // check if email is valid
     if (!PommoHelper::isEmail($subscriber['email'])) {
         $json->fail(Pommo::_T('Invalid email.'));
     }
     // check for dupe
     $lookupID = current(PommoSubscriber::getIDByEmail($subscriber['email'], array(1, 2)));
     if ($lookupID && $lookupID != $subscriber['id']) {
         $json->fail(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
     }
     if (!PommoValidate::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 (!PommoSubscriber::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
     Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/fields.php');
     $dateFields = PommoField::getByType('date');
     foreach ($subscriber['data'] as $k => $val) {
         $out['d' . $k] = in_array($k, $dateFields) ? PommoHelper::timeToStr($val) : htmlspecialchars($val);
     }
     $json->add('callbackFunction', 'editSubscriber');
     $json->add('callbackParams', $out);
     $json->addMsg(Pommo::_T('Subscriber Updated'));
     break;
 default:
示例#2
0
 function perform(&$in)
 {
     global $pommo;
     $dbo =& $pommo->_dbo;
     $logger =& $pommo->_logger;
     if (!is_numeric($in['id']) || !is_numeric($in['subscriber_id'])) {
         $logger->addErr('PommoPending::perform() -> invalid pending object sent.');
         return false;
     }
     switch ($in['type']) {
         case 'add':
             // subscribe
             $query = "\n\t\t\t\t\tUPDATE " . $dbo->table['subscribers'] . "\n\t\t\t\t\tSET status=1\n\t\t\t\t\tWHERE subscriber_id=%i";
             $query = $dbo->prepare($query, array($in['subscriber_id']));
             if (!$dbo->query($query)) {
                 $logger->addErr('PommoPending::perform() -> Error updating subscriber.');
                 return false;
             }
             break;
         case 'change':
             // update
             $pommo->requireOnce($pommo->_baseDir . 'inc/helpers/subscribers.php');
             $subscriber =& $in['array'];
             if (!PommoSubscriber::update($subscriber, 'REPLACE_ACTIVE')) {
                 $logger->addErr('PommoPending::perform() -> Error updating subscriber.');
                 return false;
             }
             break;
         case 'password':
             // change (admin) password
             $pommo->requireOnce($pommo->_baseDir . 'inc/helpers/subscribers.php');
             $password = PommoHelper::makePassword();
             $config = PommoAPI::configGet(array('admin_username', 'admin_email'));
             if (!PommoAPI::configUpdate(array('admin_password' => md5($password)), TRUE)) {
                 $logger->addMsg('Error updating password.');
                 return false;
             }
             $logger->addErr(sprintf(Pommo::_T('You may now %1$s login %2$s with username: %3$s and password: %4$s '), '<a href="' . $pommo->_baseUrl . 'index.php">', '</a>', '<span style="font-size: 130%">' . $config['admin_username'] . '</span>', '<span style="font-size: 130%">' . $password . '</span>'));
             break;
     }
     $query = "\n\t\t\tDELETE FROM " . $dbo->table['subscriber_pending'] . "\n\t\t\tWHERE pending_id=%i";
     $query = $dbo->prepare($query, array($in['id']));
     if (!$dbo->query($query)) {
         $logger->addErr('PommoPending::perform() -> Error removing pending entry.');
         return false;
     }
     return true;
 }
示例#3
0
            }
        }
    } elseif (!PommoSubscriber::update($newsub, 'REPLACE_ACTIVE')) {
        $logger->addErr('Error updating subscriber.');
    } else {
        // update successful
        $logger->addMsg(Pommo::_T('Your records have been updated.'));
        Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/messages.php');
        if (isset($notices['update']) && $notices['update'] == 'on') {
            PommoHelperMessages::notify($notices, $newsub, 'update');
        }
    }
} elseif (!empty($_POST['unsubscribe'])) {
    $comments = isset($_POST['comments']) ? substr($_POST['comments'], 0, 255) : false;
    $newsub = array('id' => $subscriber['id'], 'status' => 0, 'data' => array());
    if (!PommoSubscriber::update($newsub)) {
        $logger->addErr('Error updating subscriber.');
    } else {
        $dbvalues = PommoAPI::configGet(array('messages'));
        $messages = unserialize($dbvalues['messages']);
        Pommo::requireOnce($pommo->_baseDir . 'inc/helpers/messages.php');
        // send unsubscription email / print unsubscription message
        PommoHelperMessages::sendMessage(array('to' => $subscriber['email'], 'type' => 'unsubscribe'));
        if ($comments || isset($notices['unsubscribe']) && $notices['unsubscribe'] == 'on') {
            PommoHelperMessages::notify($notices, $subscriber, 'unsubscribe', $comments);
        }
        $smarty->assign('unsubscribe', TRUE);
    }
}
$smarty->assign('email', $subscriber['email']);
$smarty->assign('code', $_REQUEST['code']);