示例#1
0
     $unsubscribed = PommoSubscriber::GetIDByEmail($_REQUEST['Email'], 0);
     if (!empty($unsubscribed)) {
         $json->fail(sprintf(Pommo::_T('%s has already unsubscribed. To add the subscriber anyway, check the box to force the addition.'), '<strong>' . $_REQUEST['Email'] . '</strong>'));
     }
 }
 // check if duplicate
 if (PommoHelper::isDupe($_POST['Email'])) {
     $json->fail(Pommo::_T('Email address already exists. Duplicates are not allowed.'));
 }
 $subscriber = array('email' => $_REQUEST['Email'], 'registered' => time(), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 1, 'data' => $_POST['d']);
 $flag = false;
 if (!PommoValidate::subscriberData($subscriber['data'], array('active' => FALSE, 'ignore' => TRUE))) {
     if (!isset($_REQUEST['force'])) {
         $json->addMsg(Pommo::_T('Invalid or missing information.'));
         foreach ($logger->getAll() as $err) {
             $json->addErr($err);
         }
         $json->fail();
     }
     $flag = true;
     $subscriber['flag'] = 9;
     // 9 for "update"
 }
 $key = PommoSubscriber::add($subscriber);
 if (!$key) {
     $json->fail();
 }
 $json->addMsg(sprintf(Pommo::_T('Subscriber %s added!'), '<strong>' . $subscriber['email'] . '</strong>'));
 if ($flag) {
     $json->addErr(Pommo::_T('Subscriber has been flagged for update due to invalid or missing information.'));
 }