/** * @Given /^the newsletter subscription for "([^"]*)" (should|should not) be verified$/ */ public function theNewsletterSubscriptionForIsVerified($email, $shouldOrNot = '') { $recipient = \Recipient::get()->filter('Email', $email)->First(); assertNotNull($recipient, 'Could not find Recipient with ' . $email); $assertion = $shouldOrNot == 'should' ? 'assertTrue' : 'assertFalse'; $assertion((bool) $recipient->Verified); }
/** * @return null|string The instance URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. * * @throws Error\InvalidRequest */ public function instanceUrl() { $id = $this['id']; if (!$id) { $class = get_class($this); $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}"; throw new Error\InvalidRequest($msg, null); } if ($this['customer']) { $parent = $this['customer']; $base = Customer::classUrl(); $path = 'sources'; } elseif ($this['account']) { $parent = $this['account']; $base = Account::classUrl(); $path = 'external_accounts'; } elseif ($this['recipient']) { $parent = $this['recipient']; $base = Recipient::classUrl(); $path = 'cards'; } else { return; } $parent = Util\Util::utf8($parent); $id = Util\Util::utf8($id); $parentExtn = urlencode($parent); $extn = urlencode($id); return "{$base}/{$parentExtn}/{$path}/{$extn}"; }
public function testRecipientUpdateMetadataAll() { $recipient = self::createTestRecipient(); $recipient->metadata = array('test' => 'foo bar'); $recipient->save(); $updatedRecipient = Recipient::retrieve($recipient->id); $this->assertSame('foo bar', $updatedRecipient->metadata['test']); }
/** * Creates a single new log item * @param $idnewsjob integer ID of corresponding newsletter send job * @param $idnewsrcp integer ID of recipient * @param $rcp_name string Name of the recipient (-> recipient may be deleted) * @param $rcp_email string E-Mail of the recipient (-> recipient may be deleted) */ public function create($idnewsjob, $idnewsrcp) { global $client, $lang, $auth; $idnewsjob = Contenido_Security::toInteger($idnewsjob); $idnewsrcp = Contenido_Security::toInteger($idnewsrcp); $client = Contenido_Security::toInteger($client); $lang = Contenido_Security::toInteger($lang); $this->resetQuery(); $this->setWhere("idnewsjob", $idnewsjob); $this->setWhere("idnewsrcp", $idnewsrcp); $this->query(); if ($oItem = $this->next()) { return $oItem; } $oRecipient = new Recipient(); if ($oRecipient->loadByPrimaryKey($idnewsrcp)) { $oItem = parent::create(); $oItem->set("idnewsjob", $idnewsjob); $oItem->set("idnewsrcp", $idnewsrcp); $sEMail = $oRecipient->get("email"); $sName = $oRecipient->get("name"); if ($sName == "") { $oItem->set("rcpname", $sEMail); } else { $oItem->set("rcpname", $sName); } $oItem->set("rcpemail", $sEMail); $oItem->set("rcphash", $oRecipient->get("hash")); $oItem->set("rcpnewstype", $oRecipient->get("news_type")); $oItem->set("status", "pending"); $oItem->set("created", date("Y-m-d H:i:s"), false); $oItem->store(); return $oItem; } else { return false; } }
public function createConsignment(ConsignmentRequest $consignmentRequest) { $recipient = $consignmentRequest->getRecipient(); if ($recipient == null) { $recipient = new Recipient(); } $labelsRequest = $consignmentRequest->getLabelsRequest(); $consignmentArray = array('transport_service_id' => $consignmentRequest->getTransportServiceId(), 'address_state' => $recipient->getCountry(), 'register_branch_id' => $consignmentRequest->getRegisterBranchId(), 'destination_branch_id' => $consignmentRequest->getDestinationBranchId(), 'order_number' => $consignmentRequest->getOrderNumber(), 'partner_consignment_id' => $consignmentRequest->getPartnerConsignmentId(), 'parcel_count' => $consignmentRequest->getParcelCount(), 'weight' => $consignmentRequest->getWeight(), 'cash_on_delivery' => $consignmentRequest->getCashOnDelivery(), 'insurance' => $consignmentRequest->getInsurance(), 'stated_price' => $consignmentRequest->getStatedPrice(), 'currency' => $consignmentRequest->getCurrency(), 'variable' => $consignmentRequest->getValiable(), 'password' => $consignmentRequest->getPassword(), 'customer_name' => $recipient->getName(), 'customer_surname' => $recipient->getSurname(), 'company_name' => $recipient->getCompany(), 'customer_phone' => $recipient->getPhone(), 'customer_email' => $recipient->getEmail(), 'address_street' => $recipient->getStreet(), 'address_town' => $recipient->getTown(), 'address_zip' => $recipient->getZip(), 'allow_card_payment' => $consignmentRequest->getAllowCardPayment() ? 1 : 0, 'require_full_age' => $consignmentRequest->getRequireFullAge() ? 1 : 0, 'note' => $consignmentRequest->getNote()); if (isset($labelsRequest)) { $consignmentArray['labels'] = array('type' => $labelsRequest->getType(), 'first_position' => $labelsRequest->getFirstPosition(), 'labels_per_page' => $labelsRequest->getLabelsPerPage()); } $request = new Request($this->apiUrl, $this->shopId, $this->apiKey); $request->setType('POST'); $request->setResource(self::CONSIGNMENT_RESOURCE); $request->setData($consignmentArray); $response = $request->getResponse(); if ($response->isError()) { $this->errors = $response->getErrors(); return false; } else { $data = $response->getData(); return new Consignment($data[0]); } }
public function __construct($data) { $this->setId($data['id']); $recipient = new Recipient(); $recipient->setCompany($data['company_name']); $recipient->setCountry($data['address_state']); $recipient->setEmail($data['customer_email']); $recipient->setName($data['customer_name']); $recipient->setPhone($data['customer_phone']); $recipient->setStreet($data['address_street']); $recipient->setSurname($data['customer_surname']); $recipient->setTown($data['address_town']); $recipient->setZip($data['address_zip']); $this->setRecipient($recipient); $this->setOrderNumber($data['order_number']); $this->setPartnerConsignmentId($data['partner_consignment_id']); $this->setVariable($data['variable']); $this->setParcelCount($data['parcel_count']); $this->setCashOnDelivery($data['cash_on_delivery']); $this->setInsurance($data['insurance']); $this->setStatedPrice($data['stated_price']); $this->setCurrency($data['currency']); $this->setPassword($data['password']); $this->setRegisterBranchId($data['register_branch_id']); $this->setDestinationBranchId($data['destination_branch_id']); $timeCreated = $this->formatTime($data, 'time_created'); $this->setTimeCreated($timeCreated); $timeReceived = $this->formatTime($data, 'time_received'); $this->setTimeReceived($timeReceived); $this->setMaxStoringDate($data['max_storing_date']); $timeClosed = $this->formatTime($data, 'time_closed'); $this->setTimeClosed($timeClosed); $status = new Status($data['status']['id'], $data['status']['name']); $this->setStatus($status); $this->setParcelNumber($data['parcel_number']); $this->setWeight($data['weight']); $this->setRequireFullAge($data['require_full_age'] ? true : false); $this->setAllowCardPayment($data['allow_card_payment'] ? true : false); $this->setCardPaid($data['card_paid'] ? true : false); $this->setNote($data['note']); $timeUpdated = $this->formatTime($data, 'time_updated'); $this->setTimeUpdated($timeUpdated); $timeCodSent = $this->formatTime($data, 'time_cod_sent'); $this->setTimeCodSent($timeCodSent); $timeInvoiceSent = $this->formatTime($data, 'time_invoice_sent'); $this->setTimeInvoiceSent($timeInvoiceSent); $this->setTransportServiceId($data['transport_service_id']); $this->setMaxStoringDateIncreasedByClient($data['max_storing_date_increased_by_client'] ? true : false); $this->setMaxStoringDateIncreasedByPartner($data['max_storing_date_increased_by_partner'] ? true : false); }
public function testRecipientDeleteCard() { $token = Token::create(array("card" => array("number" => "4000056655665556", "exp_month" => 5, "exp_year" => date('Y') + 3, "cvc" => "314"))); $recipient = $this->createTestRecipient(); $createdCard = $recipient->cards->create(array("card" => $token->id)); $recipient->save(); $updatedRecipient = Recipient::retrieve($recipient->id); $updatedCards = $updatedRecipient->cards->all(); $this->assertSame(count($updatedCards["data"]), 1); $deleteStatus = $updatedRecipient->cards->retrieve($createdCard->id)->delete(); $this->assertTrue($deleteStatus->deleted); $updatedRecipient->save(); $postDeleteRecipient = Recipient::retrieve($recipient->id); $postDeleteCards = $postDeleteRecipient->cards->all(); $this->assertSame(count($postDeleteCards["data"]), 0); }
public function testRecipientDeleteCard() { $token = Token::create(array('card' => array('number' => '4000056655665556', 'exp_month' => 5, 'exp_year' => date('Y') + 3, 'cvc' => '314'))); $recipient = $this->createTestRecipient(); $createdCard = $recipient->cards->create(array('card' => $token->id)); $recipient->save(); $updatedRecipient = Recipient::retrieve($recipient->id); $updatedCards = $updatedRecipient->cards->all(); $this->assertSame(count($updatedCards['data']), 1); $deleteStatus = $updatedRecipient->cards->retrieve($createdCard->id)->delete(); $this->assertTrue($deleteStatus->deleted); $updatedRecipient->save(); $postDeleteRecipient = Recipient::retrieve($recipient->id); $postDeleteCards = $postDeleteRecipient->cards->all(); $this->assertSame(count($postDeleteCards['data']), 0); }
/** * emailing admin and or running custom code to update newsletter status * @param DataObject $order Order * @return Boolean **/ public function doStep(Order $order) { $billingAddress = $order->BillingAddress(); $member = $order->Member(); if ($member && $billingAddress) { $recipient = Recipient::get()->filter(array("Email" => $billingAddress->Email))->first(); if (!$recipient) { $recipient = Recipient::create(); $recipient->Email = $billingAddress->Email; } $recipient->FirstName = $billingAddress->FirstName; $recipient->Surname = $billingAddress->Surname; $recipient->write(); $mailingListToAdd = $member->MailingLists(); DB::query("DELETE FROM MailingList_Recipients WHERE RecipientID = " . $recipient->ID . ";"); if ($mailingListToAdd->count()) { $recipientsMailingLists = $recipient->MailingLists(); $recipientsMailingLists->addMany($mailingListToAdd->map("ID", "ID")->toArray()); if ($this->SendMessageToAdmin) { $member = $order->Member(); if ($member) { if ($member->NewsletterSignup) { $from = Order_Email::get_from_email(); $subject = _t("NewsletterSignup.NEWSLETTERREGISTRATIONUPDATE", "newsletter registration update"); $billingAddressOutput = ""; if ($billingAddress) { $billingAddressOutput = $billingAddress->renderWith("Order_AddressBilling"); } $body = "\n\t\t\t\t\t\t\t\t" . _t("NewsletterSignup.EMAIL", "Email") . ": <strong>" . $member->Email . "</strong>" . "<br /><br />" . _t("NewsletterSignup.SIGNUP", "Signed Up") . ": <strong>" . ($member->NewsletterSignup ? _t("NewsletterSignup.YES", "Yes") : _t("NewsletterSignup.NO", "No")) . "</strong>" . "<br /><br />" . $billingAddressOutput; $email = new Email($from, $to = Order_Email::get_from_email(), $subject, $body); $email->send(); //copy! if ($this->SendCopyTo) { $email = new Email($from, $to = $this->SendCopyTo, $subject, $body); $email->send(); } } //this can be used to connect with third parties (e.g. ) } } } $this->extend("updateNewsletterStatus", $member, $recipient); } return true; }
/** * @return string The instance URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. */ public function instanceUrl() { $id = $this['id']; if (!$id) { $class = get_class($this); $msg = "Could not determine which URL to request: {$class} instance " . "has invalid ID: {$id}"; throw new Error\InvalidRequest($msg, null); } if (isset($this['customer'])) { $parent = $this['customer']; $base = Customer::classUrl(); } elseif (isset($this['recipient'])) { $parent = $this['recipient']; $base = Recipient::classUrl(); } else { return null; } $parent = ApiRequestor::utf8($parent); $id = ApiRequestor::utf8($id); $parentExtn = urlencode($parent); $extn = urlencode($id); return "{$base}/{$parentExtn}/cards/{$extn}"; }
public function runJob() { global $cfg, $cfgClient, $client, $recipient; $iCount = 0; if ($this->get("status") == 2) { // Job is currently running, check start time and restart if // started 5 minutes ago $dStart = strtotime($this->get("started")); $dNow = time(); if ($dNow - $dStart > 5 * 60) { $this->set("status", 1); $this->set("started", "0000-00-00 00:00:00", false); $oLogs = new cNewsletterLogCollection(); $oLogs->setWhere("idnewsjob", $this->get($this->primaryKey)); $oLogs->setWhere("status", "sending"); $oLogs->query(); while ($oLog = $oLogs->next()) { $oLog->set("status", "error (sending)"); $oLog->store(); } } } if ($this->get("status") == 1) { // Job waiting for sending $this->set("status", 2); $this->set("started", date("Y-m-d H:i:s"), false); $this->store(); // Initialization $aMessages = array(); $oLanguage = new cApiLanguage($this->get("idlang")); $sFormatDate = $oLanguage->getProperty("dateformat", "date"); $sFormatTime = $oLanguage->getProperty("dateformat", "time"); unset($oLanguage); if ($sFormatDate == "") { $sFormatDate = 'Y-m-d'; } if ($sFormatTime == "") { $sFormatTime = 'h:i a'; } // Get newsletter data $sFrom = $this->get("newsfrom"); $sFromName = $this->get("newsfromname"); $sSubject = $this->get("subject"); $sMessageText = $this->get("message_text"); $sMessageHTML = $this->get("message_html"); $dNewsDate = strtotime($this->get("newsdate")); $sEncoding = $this->get("encoding"); $bIsHTML = false; if ($this->get("type") == "html" && $sMessageHTML != "") { $bIsHTML = true; } $bDispatch = false; if ($this->get("dispatch") == 1) { $bDispatch = true; } // Single replacements // Replace message tags (text message) $sMessageText = str_replace("MAIL_DATE", date($sFormatDate, $dNewsDate), $sMessageText); $sMessageText = str_replace("MAIL_TIME", date($sFormatTime, $dNewsDate), $sMessageText); $sMessageText = str_replace("MAIL_NUMBER", $this->get("rcpcount"), $sMessageText); // Replace message tags (html message) if ($bIsHTML) { $sMessageHTML = str_replace("MAIL_DATE", date($sFormatDate, $dNewsDate), $sMessageHTML); $sMessageHTML = str_replace("MAIL_TIME", date($sFormatTime, $dNewsDate), $sMessageHTML); $sMessageHTML = str_replace("MAIL_NUMBER", $this->get("rcpcount"), $sMessageHTML); # Link to online article --> if (!is_object($db)) { $db = new DB_Contenido(); } $sql = 'SELECT idart FROM ' . $cfg['tab']['news'] . ' WHERE (idnews=' . $this->get('idnews') . ')'; $db->query($sql); $db->next_record(); $news_idart = $db->f('idart'); $link = Contenido_Url::getInstance()->build(array('idart' => $news_idart, 'client' => $this->get('idclient'), 'lang' => $this->get("idlang"), 'nl' => $this->get('idnewsjob'), 'rcp' => '{RCP}'), true); $p1 = strpos($sMessageHTML, '<body'); if ($p1 !== false) { $p1 = strpos($sMessageHTML, '>', $p1) + 1; } else { $p1 = 0; } $sOnlineText = getEffectiveSetting('newsletter-online-text', $this->get("idlang"), 'If the newsletter is not shown properly, please click here to view the online version.'); $sMessageHTML = substr($sMessageHTML, 0, $p1) . '<div style="text-align: center; background-color: #FFF;"><a href="' . $link . '" style="font-weight: bold;">' . $sOnlineText . '</a></div>' . substr($sMessageHTML, $p1); # <-- Link to online article // Remove base tag $sMessageHTML = preg_replace('/<base href=(.*?)>/is', '', $sMessageHTML, 1); // Fix source path // TODO: Test any URL specification that may exist under the sun... $sMainURL = Contenido_Url::getInstance()->build(array('idcat' => getEffectiveSetting('navigation', 'idcat-home', 1), 'client' => $this->get('idclient'), 'lang' => $this->get("idlang")), true); $sSelfURL = Contenido_Url::getInstance()->build(array('idart' => $this->get("idart"), 'client' => $this->get('idclient'), 'lang' => $this->get("idlang")), true); $sMessageHTML = preg_replace("/(href|src)\\=(\"|\\')([^(http|#)])(\\/)?/", "\$1=" . "\$2" . $sMainURL . "\$3", $sMessageHTML); $sMessageHTML = preg_replace('/url\\([\\"\'](.*)[\\"\']\\)/', 'url(\'' . $sMainURL . '$1\')', $sMessageHTML); $sMessageHTML = str_replace('/cms//', '/', $sMessageHTML); // Now replace anchor tags to the newsletter article itself just by the anchor $sMessageHTML = preg_replace("/(href|src)\\=(\"|\\')" . str_replace('/', '\\/', $sSelfURL) . "(.*)#(.*)(\"|\\')/", "\$1=" . "\$2" . "#" . "\$4" . "\$5", $sMessageHTML); // Now correct mailto tags $sMessageHTML = str_replace($sMainURL . 'mailto:', 'mailto:', $sMessageHTML); # Remove the <noscript> info from the newsletter message $sMessageHTML = str_replace(array('This website is powered by drugCMS, the Content Management System with addictive potential.', 'For more info and download visit <a href="http://www.drugcms.org">www.drugcms.org</a>.', 'drugCMS is made in Germany.'), '', $sMessageHTML); } // Enabling plugin interface $bPluginEnabled = false; if (getSystemProperty("newsletter", "newsletter-recipients-plugin") == "true") { $bPluginEnabled = true; $aPlugins = array(); if (is_array($cfg['plugins']['recipients'])) { foreach ($cfg['plugins']['recipients'] as $sPlugin) { plugin_include("recipients", $sPlugin . "/" . $sPlugin . ".php"); if (function_exists("recipients_" . $sPlugin . "_wantedVariables")) { $aPlugins[$sPlugin] = call_user_func("recipients_" . $sPlugin . "_wantedVariables"); } } } } // Get recipients (from log table) if (!is_object($oLogs)) { $oLogs = new cNewsletterLogCollection(); } else { $oLogs->resetQuery(); } $oLogs->setWhere("idnewsjob", $this->get($this->primaryKey)); $oLogs->setWhere("status", "pending"); if ($bDispatch) { $oLogs->setLimit(0, $this->get("dispatch_count")); } $oLogs->query(); while ($oLog = $oLogs->next()) { $iCount++; $oLog->set("status", "sending"); $oLog->store(); $sRcpMsgText = $sMessageText; $sRcpMsgHTML = $sMessageHTML; $sKey = $oLog->get("rcphash"); $sEMail = $oLog->get("rcpemail"); $bSendHTML = false; if ($oLog->get("rcpnewstype") == 1) { $bSendHTML = true; // Recipient accepts html newsletter } if (strlen($sKey) == 30) { // Prevents sending without having a key $sRcpMsgText = str_replace("{KEY}", $sKey, $sRcpMsgText); $sRcpMsgText = str_replace("MAIL_MAIL", $sEMail, $sRcpMsgText); $sRcpMsgText = str_replace("MAIL_NAME", $oLog->get("rcpname"), $sRcpMsgText); // Replace message tags (html message) if ($bIsHTML && $bSendHTML) { $sRcpMsgHTML = str_replace("{KEY}", $sKey, $sRcpMsgHTML); $sRcpMsgHTML = str_replace("MAIL_MAIL", $sEMail, $sRcpMsgHTML); $sRcpMsgHTML = str_replace("MAIL_NAME", $oLog->get("rcpname"), $sRcpMsgHTML); $sRcpMsgHTML = str_replace(urlencode('{RCP}'), $sKey, $sRcpMsgHTML); } if ($bPluginEnabled) { // Don't change name of $recipient variable as it is used in plugins! $recipient = new Recipient(); $recipient->loadByPrimaryKey($oLog->get("idnewsrcp")); foreach ($aPlugins as $sPlugin => $aPluginVar) { foreach ($aPluginVar as $sPluginVar) { // Replace tags in text message $sRcpMsgText = str_replace("MAIL_" . strtoupper($sPluginVar), call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar), $sRcpMsgText); // Replace tags in html message if ($bIsHTML && $bSendHTML) { $sRcpMsgHTML = str_replace("MAIL_" . strtoupper($sPluginVar), call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar), $sRcpMsgHTML); } } } unset($recipient); } $oMail = new PHPMailer(); $oMail->CharSet = $sEncoding; $oMail->IsHTML($bIsHTML && $bSendHTML); $oMail->From = $sFrom; $oMail->FromName = $sFromName; $oMail->AddAddress($sEMail); # Mailer Configuration --> $sMailer = strtolower(getEffectiveSetting('newsletter', 'mailer')); $sHost = getEffectiveSetting('newsletter', 'host'); $iPort = intval(getEffectiveSetting('newsletter', 'port')); $sUsername = getEffectiveSetting('newsletter', 'username'); $sPassword = getEffectiveSetting('newsletter', 'password'); if (strlen($sMailer) == 0) { $sMailer = strtolower(getEffectiveSetting('email', 'mailer')); $sHost = getEffectiveSetting('email', 'host'); $iPort = intval(getEffectiveSetting('email', 'port')); $sUsername = getEffectiveSetting('email', 'username'); $sPassword = getEffectiveSetting('email', 'password'); } if (strlen($sMailer) == 0) { setSystemProperty('newsletter', 'mailer', 'mail'); $sMailer = 'mail'; } if (strlen($sHost) == 0) { setSystemProperty('newsletter', 'host', ''); } if ($iPort == 0) { setSystemProperty('newsletter', 'port', '25'); $iPort = 25; } if (strlen($sUsername) == 0) { setSystemProperty('newsletter', 'username', ''); } if (strlen($sPassword) == 0) { setSystemProperty('newsletter', 'password', ''); } $oMail->Mailer = $sMailer; if ($sMailer == 'smtp') { $oMail->SMTPAuth = true; $oMail->Host = $sHost; $oMail->Port = $iPort; $oMail->Username = $sUsername; $oMail->Password = $sPassword; } # <-- Mailer Configuration $oMail->Subject = $sSubject; if ($bIsHTML && $bSendHTML) { $oMail->Body = $sRcpMsgHTML; $oMail->AltBody = $sRcpMsgText . "\n\n"; } else { $oMail->Body = $sRcpMsgText . "\n\n"; } if ($oMail->Send()) { $oLog->set("status", "successful"); $oLog->set("sent", date("Y-m-d H:i:s"), false); } else { $oLog->set("status", "error (sending)"); } } else { $oLog->set("status", "error (key)"); } $oLog->store(); } $this->set("sendcount", $this->get("sendcount") + $iCount); if ($iCount == 0 || !$bDispatch) { // No recipients remaining, job finished $this->set("status", 9); $this->set("finished", date("Y-m-d H:i:s"), false); } else { if ($bDispatch) { // Check, if there are recipients remaining - stops job faster $oLogs->resetQuery(); $oLogs->setWhere("idnewsjob", $this->get($this->primaryKey)); $oLogs->setWhere("status", "pending"); $oLogs->setLimit(0, $this->get("dispatch_count")); $oLogs->query(); if ($oLogs->next()) { // Remaining recipients found, set job back to pending $this->set("status", 1); $this->set("started", "0000-00-00 00:00:00", false); } else { // No remaining recipients, job finished $this->set("status", 9); $this->set("finished", date("Y-m-d H:i:s"), false); } } else { // Set job back to pending $this->set("status", 1); $this->set("started", "0000-00-00 00:00:00", false); } } $this->store(); } return $iCount; }
$oClient = new cApiClient($client); $timeframe = $oClient->getProperty("newsletter", "purgetimeframe"); if (!$timeframe) { $timeframe = 30; } $purgedrecipients = $oRecipients->purge($timeframe); /* backslashdollar: There is a problem translating \$ - it is either not recognized or translated correctly (using poEdit) */ if ($purgedrecipients > 0) { $sNotis = $notification->messageBox("info", sprintf(str_replace("backslashdollar", "\$", i18n("%1backslashdollard recipients, which hasn't been confirmed since more than %2backslashdollard days has been removed.", $plugin_name)), $purgedrecipients, $timeframe), 0); } else { $sNotis = $notification->messageBox("info", sprintf(str_replace("backslashdollar", "\$", i18n("There are no recipients, which hasn't been confirmed since more than %2backslashdollard days has been removed.", $plugin_name)), 0, $timeframe), 0); } $recipient = new Recipient(); $oPage->setReload(); } else { $recipient = new Recipient($idrecipient); } if ($recipient->virgin == false && $recipient->get("idclient") == $client && $recipient->get("idlang") == $lang) { if ($action == "recipients_save" && $perm->have_perm_area_action($area, $action)) { $oPage->setReload(); $aMessages = array(); $name = stripslashes($name); $email = stripslashes($email); $confirmed = (int) $confirmed; $deactivated = (int) $deactivated; $newstype = (int) $newstype; $recipient->set("name", $name); if (!isValidMail($email)) { $aMessages[] = i18n("Please specify a valid e-mail address", $plugin_name); } else { $email = strtolower($email);
public function myRecipient() { return Recipient::searchByIdentification($this->recipientIdentification); }
<?php session_start(); include_once "../php/Recipient.php"; $recipient = Recipient::search($_SESSION['identification']); ?> <html> <head> <title>My Info</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"> <link href="../styles/new.css" rel="stylesheet" type="text/css"> </head> <body> <div class="navbar navbar-default navbar-static-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-ex-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#"><span>Brand</span></a> </div> <div class="collapse navbar-collapse" id="navbar-ex-collapse"> <ul class="nav navbar-nav navbar-right">
<?php session_start(); include_once "../php/Recipient.php"; $identification = $_REQUEST['identification']; $recipient = Recipient::search($identification); echo $recipient->identification() . "#"; echo $recipient->firstName() . "#"; echo $recipient->secondName() . "#"; echo $recipient->firstSurname() . "#"; echo $recipient->secondSurname() . "#"; echo $recipient->bornDate() . "#"; echo $recipient->gender() . "#"; echo $recipient->cellPhone() . "#"; echo $recipient->email() . "#"; echo $recipient->address() . "#";
/** Send an email with a link to unsubscribe from all this user's newsletters */ public function sendUnsubscribeLink(SS_HTTPRequest $request) { //get the form object (we just need its name to set the session message) $form = NewsletterContentControllerExtension::getUnsubscribeFormObject($this); $email = Convert::raw2sql($request->requestVar('email')); $recipient = Recipient::get()->filter('Email', $email)->First(); if ($recipient) { //get the IDs of all the Mailing Lists this user is subscribed to $lists = $recipient->MailingLists()->column('ID'); $listIDs = implode(',', $lists); $days = UnsubscribeController::get_days_unsubscribe_link_alive(); if ($recipient->ValidateHash) { $recipient->ValidateHashExpired = date('Y-m-d H:i:s', time() + 86400 * $days); $recipient->write(); } else { $recipient->generateValidateHashAndStore($days); } $templateData = array('FirstName' => $recipient->FirstName, 'UnsubscribeLink' => Director::absoluteBaseURL() . "unsubscribe/index/" . $recipient->ValidateHash . "/{$listIDs}"); //send unsubscribe link email $email = new Email(); $email->setTo($recipient->Email); $from = Email::getAdminEmail(); $email->setFrom($from); $email->setTemplate('UnsubscribeLinkEmail'); $email->setSubject(_t('Newsletter.ConfirmUnsubscribeSubject', "Confirmation of your unsubscribe request")); $email->populateTemplate($templateData); $email->send(); $form->sessionMessage(_t('Newsletter.GoodEmailMessage', 'You have been sent an email containing an unsubscribe link'), "good"); } else { //not found Recipient, just reload the form $form->sessionMessage(_t('Newsletter.BadEmailMessage', 'Email address not found'), "bad"); } Controller::curr()->redirectBack(); }
/** * Sends test newsletter directly to specified recipients (single or group) * * Note: Sending in chunks not supported! Only usable for tests and only a few * recipients. * * @param integer $iIDCatArt idcatart of newsletter handler article * @param integer $iIDNewsRcp If specified, newsletter recipient id, ignored, if group specified * @param integer $iIDNewsGroup If specified, newsletter recipient group id * @param array $aSendRcps As reference: Filled with a list of succesfull recipients * @param string $sEncoding Message (and header) encoding, e.g. iso-8859-1 */ public function sendDirect($iIDCatArt, $iIDNewsRcp = false, $iIDNewsGroup = false, &$aSendRcps, $sEncoding = "iso-8859-1") { global $lang, $client, $cfg, $cfgClient, $contenido, $recipient; // Initialization $aMessages = array(); $oLanguage = new cApiLanguage($lang); $sFormatDate = $oLanguage->getProperty("dateformat", "date"); $sFormatTime = $oLanguage->getProperty("dateformat", "time"); unset($oLanguage); if ($sFormatDate == "") { $sFormatDate = 'Y-m-d'; } if ($sFormatTime == "") { $sFormatTime = 'h:i a'; } #$sPath = $cfgClient[$client]["path"]["htmlpath"]."front_content.php?changelang=".$lang."&idcatart=".$iIDCatArt."&"; $sPath = Contenido_Url::getInstance()->build(array('idcatart' => $iIDCatArt, 'client' => $client, 'lang' => $lang), true); $sPath .= strpos($sPath, '?') === false ? '?' : '&'; // Get newsletter data $sFrom = $this->get("newsfrom"); $sFromName = $this->get("newsfromname"); if ($sFromName == "") { $sFromName = $sFrom; } $sSubject = $this->get("subject"); $sMessageText = $this->get("message"); $bIsHTML = false; if ($this->get("type") == "html") { $sMessageHTML = $this->getHTMLMessage(); if ($sMessageHTML === false) { // There was a problem getting the html message (maybe article // deleted). Exit with error instead of sending as text message only if ($contenido) { // Use i18n only in backend $sError = i18n("Newsletter could not be sent: No html message available", $plugin_name); } else { $sError = "Newsletter could not be sent: No html message available"; } $this->_sError = $sError; return false; } else { $bIsHTML = true; } } // Preventing double lines in mail, you may wish to disable this function on windows servers if (!getSystemProperty("newsletter", "disable-rn-replacement")) { $sMessageText = str_replace("\r\n", "\n", $sMessageText); } // Single replacements // Replace message tags (text message) $this->_replaceTag($sMessageText, false, "date", date($sFormatDate)); $this->_replaceTag($sMessageText, false, "time", date($sFormatTime)); // Replace message tags (html message) if ($bIsHTML) { $this->_replaceTag($sMessageHTML, true, "date", date($sFormatDate)); $this->_replaceTag($sMessageHTML, true, "time", date($sFormatTime)); } // Enabling plugin interface if (getSystemProperty("newsletter", "newsletter-recipients-plugin") == "true") { $bPluginEnabled = true; $aPlugins = array(); if (is_array($cfg['plugins']['recipients'])) { foreach ($cfg['plugins']['recipients'] as $sPlugin) { plugin_include("recipients", $sPlugin . "/" . $sPlugin . ".php"); if (function_exists("recipients_" . $sPlugin . "_wantedVariables")) { $aPlugins[$sPlugin] = call_user_func("recipients_" . $sPlugin . "_wantedVariables"); } } } } else { setSystemProperty("newsletter", "newsletter-recipients-plugin", "false"); $bPluginEnabled = false; } $aRecipients = array(); if ($iIDNewsGroup !== false) { $oGroupMembers = new RecipientGroupMemberCollection(); $aRecipients = $oGroupMembers->getRecipientsInGroup($iIDNewsGroup, false); } else { if ($iIDNewsRcp !== false) { $aRecipients[] = $iIDNewsRcp; } } $iCount = count($aRecipients); if ($iCount > 0) { $this->_replaceTag($sMessageText, false, "number", $iCount); // Replace message tags (html message) if ($bIsHTML) { $this->_replaceTag($sMessageHTML, true, "number", $iCount); } foreach ($aRecipients as $iID) { $sRcpMsgText = $sMessageText; $sRcpMsgHTML = $sMessageHTML; // Don't change name of $recipient variable as it is used in plugins! $recipient = new Recipient(); $recipient->loadByPrimaryKey($iID); $sEMail = $recipient->get("email"); $sName = $recipient->get("name"); if (empty($sName)) { $sName = $sEMail; } $sKey = $recipient->get("hash"); $bSendHTML = false; if ($recipient->get("news_type") == 1) { $bSendHTML = true; // Recipient accepts html newsletter } $this->_replaceTag($sRcpMsgText, false, "name", $sName); $this->_replaceTag($sRcpMsgText, false, "unsubscribe", $sPath . "unsubscribe=" . $sKey); $this->_replaceTag($sRcpMsgText, false, "change", $sPath . "change=" . $sKey); $this->_replaceTag($sRcpMsgText, false, "stop", $sPath . "stop=" . $sKey); $this->_replaceTag($sRcpMsgText, false, "goon", $sPath . "goon=" . $sKey); // Replace message tags (html message) if ($bIsHTML && $bSendHTML) { $this->_replaceTag($sRcpMsgHTML, true, "name", $sName); $this->_replaceTag($sRcpMsgHTML, true, "unsubscribe", $sPath . "unsubscribe=" . $sKey); $this->_replaceTag($sRcpMsgHTML, true, "change", $sPath . "change=" . $sKey); $this->_replaceTag($sRcpMsgHTML, true, "stop", $sPath . "stop=" . $sKey); $this->_replaceTag($sRcpMsgHTML, true, "goon", $sPath . "goon=" . $sKey); # Link to online article --> if (!is_object($db)) { $db = new DB_Contenido(); } $sql = 'SELECT idart FROM ' . $cfg['tab']['news'] . ' WHERE (idnews=' . $this->get('idnews') . ')'; $db->query($sql); $db->next_record(); $news_idart = $db->f('idart'); $link = Contenido_Url::getInstance()->build(array('idart' => $news_idart, 'client' => $this->get('idclient'), 'lang' => $this->get("idlang"), 'rcp' => $sKey), true); $p1 = strpos($sMessageHTML, '<body'); if ($p1 !== false) { $p1 = strpos($sMessageHTML, '>', $p1) + 1; } else { $p1 = 0; } $sOnlineText = getEffectiveSetting('newsletter-online-text', $this->get("idlang"), 'If the newsletter is not shown properly, please click here to view the online version.'); $sMessageHTML = substr($sMessageHTML, 0, $p1) . '<div style="text-align: center; background-color: #FFF;"><a href="' . $link . '" style="font-weight: bold;">' . $sOnlineText . '</a></div>' . substr($sMessageHTML, $p1); # <-- Link to online article // Remove base tag $sMessageHTML = preg_replace('/<base href=(.*?)>/is', '', $sMessageHTML, 1); // Fix source path // TODO: Test any URL specification that may exist under the sun... $sMainURL = Contenido_Url::getInstance()->build(array('idcat' => getEffectiveSetting('navigation', 'idcat-home', 1), 'client' => $this->get('idclient'), 'lang' => $this->get("idlang")), true); $sSelfURL = Contenido_Url::getInstance()->build(array('idart' => $this->get("idart"), 'client' => $this->get('idclient'), 'lang' => $this->get("idlang")), true); $sMessageHTML = preg_replace("/(href|src)\\=(\"|\\')([^(http|#)])(\\/)?/", "\$1=" . "\$2" . $sMainURL . "\$3", $sMessageHTML); $sMessageHTML = preg_replace('/url\\([\\"\'](.*)[\\"\']\\)/', 'url(\'' . $sMainURL . '$1\')', $sMessageHTML); $sMessageHTML = str_replace('/cms//', '/', $sMessageHTML); // Now replace anchor tags to the newsletter article itself just by the anchor $sMessageHTML = preg_replace("/(href|src)\\=(\"|\\')" . str_replace('/', '\\/', $sSelfURL) . "(.*)#(.*)(\"|\\')/", "\$1=" . "\$2" . "#" . "\$4" . "\$5", $sMessageHTML); // Now correct mailto tags $sMessageHTML = str_replace($sMainURL . 'mailto:', 'mailto:', $sMessageHTML); # Remove the <noscript> info from the newsletter message $sMessageHTML = str_replace(array('This website is powered by drugCMS, the Content Management System with addictive potential.', 'For more info and download visit <a href="http://www.drugcms.org">www.drugcms.org</a>.', 'drugCMS is made in Germany.'), '', $sMessageHTML); } if ($bPluginEnabled) { foreach ($aPlugins as $sPlugin => $aPluginVar) { foreach ($aPluginVar as $sPluginVar) { // Replace tags in text message $this->_replaceTag($sRcpMsgText, false, $sPluginVar, call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar)); // Replace tags in html message if ($bIsHTML && $bSendHTML) { $this->_replaceTag($sRcpMsgHTML, true, $sPluginVar, call_user_func("recipients_" . $sPlugin . "_getvalue", $sPluginVar)); } } } } if (strlen($sKey) != 30) { // Prevents sending without having a key if ($contenido) { // Use i18n only in backend $sError = i18n("Newsletter to %s could not be sent: Recipient has an incompatible or empty key", $plugin_name); } else { $sError = "Newsletter to %s could not be sent: Recipient has an incompatible or empty key"; } $aMessages[] = $sName . " (" . $sEMail . "): " . sprintf($sError, $sEMail); } else { if (!isValidMail($sEMail)) { if ($contenido) { // Use i18n only in backend $sError = i18n("Newsletter to %s could not be sent: No valid e-mail address specified", $plugin_name); } else { $sError = "Newsletter to %s could not be sent: No valid e-mail address specified"; } $aMessages[] = $sName . " (" . $sEMail . "): " . sprintf($sError, $sEMail); } else { $oMail = new PHPMailer(); $oMail->CharSet = $sEncoding; $oMail->IsHTML($bIsHTML && $bSendHTML); $oMail->From = $sFrom; $oMail->FromName = $sFromName; $oMail->AddAddress($sEMail); # Mailer Configuration --> $sMailer = strtolower(getEffectiveSetting('newsletter', 'mailer')); $sHost = getEffectiveSetting('newsletter', 'host'); $iPort = intval(getEffectiveSetting('newsletter', 'port')); $sUsername = getEffectiveSetting('newsletter', 'username'); $sPassword = getEffectiveSetting('newsletter', 'password'); if (strlen($sMailer) == 0) { $sMailer = strtolower(getEffectiveSetting('email', 'mailer')); $sHost = getEffectiveSetting('email', 'host'); $iPort = intval(getEffectiveSetting('email', 'port')); $sUsername = getEffectiveSetting('email', 'username'); $sPassword = getEffectiveSetting('email', 'password'); } if (strlen($sMailer) == 0) { setClientProperty('email', 'mailer', 'mail'); $sMailer = 'mail'; } if (strlen($sHost) == 0) { setClientProperty('email', 'host', ''); } if ($iPort == 0) { setClientProperty('email', 'port', '25'); $iPort = 25; } if (strlen($sUsername) == 0) { setClientProperty('email', 'username', ''); } if (strlen($sPassword) == 0) { setClientProperty('email', 'password', ''); } $oMail->Mailer = $sMailer; if ($sMailer == 'smtp') { $oMail->SMTPAuth = true; $oMail->Host = $sHost; $oMail->Port = $iPort; $oMail->Username = $sUsername; $oMail->Password = $sPassword; } # <-- Mailer Configuration $oMail->Subject = $sSubject; if ($bIsHTML && $bSendHTML) { $oMail->Body = $sRcpMsgHTML; $oMail->AltBody = $sRcpMsgText . "\n\n"; } else { $oMail->Body = $sRcpMsgText . "\n\n"; } if ($oMail->Send()) { $aSendRcps[] = $sName . " (" . $sEMail . ")"; } else { if ($contenido) { // Use i18n only in backend $sError = i18n("Newsletter to %s could not be sent", $plugin_name); } else { $sError = "Newsletter to %s could not be sent"; } $aMessages[] = $sName . " (" . $sEMail . "): " . sprintf($sError, $sEMail); } } } } } else { if ($contenido) { // Use i18n only in backend $sError = i18n("No recipient with specified recipient/group id %s/%s found", $plugin_name); } else { $sError = "No recipient with specified recpient/group id %s/%s found"; } $aMessages[] = sprintf($sError, $iIDNewsRcp, $iIDNewsGroup); } if (count($aMessages) > 0) { $this->_sError = implode("<br />", $aMessages); return false; } else { return true; } }
/** * @param string $email * @param string|null $name */ public function __construct($email, $name = null) { parent::__construct($email, $name, 'cc'); }
/** * Returns true if $this->Email appears to be a valid email * @return bool */ function IsValidEmail() { return Recipient::IsEmailInValidFormat($this->Email); }
function processQueue($newsletterID, $lockFile) { set_time_limit(0); //no time limit for running process if (!empty($newsletterID)) { $newsletter = Newsletter::get()->byID($newsletterID); if (!empty($newsletter)) { //try to clean up any stuck items $this->cleanUpStalledQueue($newsletterID); // Start a transaction $conn = DB::getConn(); if ($conn->supportsTransactions()) { $conn->transactionStart(); } $queueItemsList = array(); try { //get the first X items to process $queueItems = SendRecipientQueue::get()->filter(array('NewsletterID' => $newsletterID, 'Status' => 'Scheduled'))->sort('Created ASC')->limit(self::$items_to_batch_process); //set them all to "in process" at once foreach ($queueItems as $item) { $item->Status = 'InProgress'; $queueItemsList[] = $item->write(); } // Commit transaction if ($conn->supportsTransactions()) { $conn->transactionEnd(); } } catch (Exception $e) { // Rollback if ($conn->supportsTransactions()) { $conn->transactionRollback(); } //retry the processing SS_Log::log(new Exception("newsletter send out restart because of error"), SS_Log::ERR); $this->processQueueOnShutdown($newsletterID); } //fetch the queue items from the database again (after writing in-process to them) $queueItems2 = null; if (!empty($queueItemsList)) { $queueItems2 = SendRecipientQueue::get()->filter(array('ID' => $queueItemsList)); } //do the actual mail out if (!empty($queueItems2) && $queueItems2->count() > 0) { //fetch all the recipients at once in one query $recipients = Recipient::get()->filter(array('ID' => $queueItems2->column('RecipientID'))); if ($recipients->count() > 0) { $recipientsMap = array(); foreach ($recipients as $r) { $recipientsMap[$r->ID] = $r; } //send out the mails foreach ($queueItems2 as $item) { try { $item->send($newsletter, $recipientsMap[$item->RecipientID]); } catch (Exception $e) { $item->Status = 'Failed'; $item->write(); } } } unlink($lockFile); //do more processing, in case there are more items to process, do nothing if we've reached the end $this->processQueueOnShutdown($newsletterID); //wait to avoid overloading the email server with too many emails that look like spam if (!empty(self::$throttle_batch_delay)) { sleep(self::$throttle_batch_delay); } } else { //mark the send process as complete $newsletter->SentDate = SS_Datetime::now()->getValue(); $newsletter->Status = 'Sent'; $newsletter->write(); unlink($lockFile); } } } }
/** * Subscribes a given email address to the {@link NewsletterType} associated * with this page * * @param array * @param Form * @param SS_HTTPRequest * * @return Redirection */ public function doSubscribe($data, $form, $request) { if (!isset($data['Email'])) { $form->addErrorMessage('Email', _t('Newsletter.ValidEmail', 'Please enter your email address')); return $this->redirectBack(); } elseif (!Email::is_valid_address($data['Email'])) { $form->addErrorMessage('Email', _t('Newsletter.InvalidEmailAddress', '"{field}" field is invalid', array('field' => 'Email'))); return $this->redirectBack(); } // check to see if member already exists $recipient = Recipient::get()->find('Email', $data['Email']); if (!$recipient) { $recipient = new Recipient(); $recipient->Verified = false; //set new recipient as un-verified, if they subscribe through the website } $form->saveInto($recipient); $recipient->write(); $days = self::get_days_verification_link_alive(); if ($recipient->ValidateHash) { $recipient->ValidateHashExpired = date('Y-m-d H:i:s', time() + 86400 * $days); //extend the expiry date //default 2 days for validating $recipient->write(); } else { $recipient->generateValidateHashAndStore($days); //default 2 days for validating } $mailinglists = new ArrayList(); if (isset($data["NewsletterSelection"])) { foreach ($data["NewsletterSelection"] as $listID) { $mailinglist = DataObject::get_by_id("MailingList", $listID); if ($mailinglist && $mailinglist->exists()) { //remove recipient from unsubscribe if needed //$this->removeUnsubscribe($newsletterType,$recipient); $mailinglists->push($mailinglist); $recipient->MailingLists()->add($mailinglist); } } } else { // if the page has associate with one newsletter type, it won't appear in front form, but the // recipient needs to be added to the related mailling list. if ($this->MailingLists && ($listIDs = explode(",", $this->MailingLists))) { foreach ($listIDs as $listID) { $mailinglist = DataObject::get_by_id("MailingList", $listID); if ($mailinglist && $mailinglist->exists()) { //remove recipient from unsubscribe records if the recipient // unsubscribed from mailing list before //$this->removeUnsubscribe($mailingList,$recipient); $mailinglists->push($mailinglist); $recipient->MailingLists()->add($mailinglist); } } } else { user_error('No Newsletter type selected to subscribe to', E_USER_WARNING); } } $recipientInfoSection = $form->Fields()->fieldByName('MemberInfoSection')->FieldList(); $emailableFields = new FieldList(); if ($recipientInfoSection) { foreach ($recipientInfoSection as $field) { if (is_array($field->Value()) && is_a($field, 'SimpleImageField')) { $funcName = $field->Name(); $value = $recipient->{$funcName}()->CMSThumbnail()->Tag(); $field->EmailalbeValue = $value; } else { $field->EmailalbeValue = $field->Value(); } $emailableFields->push($field); } } $templateData = array('FirstName' => $recipient->FirstName, 'MemberInfoSection' => $emailableFields, 'MailingLists' => $mailinglists, 'SubscriptionVerificationLink' => Controller::join_links($this->Link('subscribeverify'), "/" . $recipient->ValidateHash), 'HashText' => substr($recipient->ValidateHash, 0, 10) . "******" . substr($recipient->ValidateHash, -10), 'SiteConfig' => $this->SiteConfig(), 'DaysExpired' => SubscriptionPage::get_days_verification_link_alive()); //Send Verification Email $email = new Email(); $email->setTo($recipient->Email); $from = $this->NotificationEmailFrom ? $this->NotificationEmailFrom : Email::getAdminEmail(); $email->setFrom($from); $email->setTemplate('SubscriptionVerificationEmail'); $email->setSubject(_t('Newsletter.VerifySubject', "Thanks for subscribing to our mailing lists, please verify your email")); $email->populateTemplate($templateData); $email->send(); $url = $this->Link('submitted') . "/" . $recipient->ID; $this->redirect($url); }
/** * @param $mailbox * @param $emailID * @param $isBounce */ private function isBounced($mailbox, $emailID, $isBounce) { $stripTags = array('<', '>'); // Some servers reply with "<*****@*****.**>", so, let's strip that. $to = str_replace($stripTags, array('', ''), $isBounce[1]); $error = $isBounce[2]; /** @var Recipient $recipient */ $recipient = Recipient::get()->filter(array("Email" => $to))->first(); if ($recipient->BouncedCount == self::$blacklistLimit) { // When we reach the blacklistLimit, just blacklist this address. $recipient->BlacklistedEmail = true; $recipient->write(); } else { // Otherwise, just up the bouncedCount. $recipient->BouncedCount = $recipient->BouncedCount + 1; $recipient->write(); /** @var NewsletterEmailBounceRecord $record Record this bounce in the NewsletterEmailBounceRecord class. */ $record = NewsletterEmailBounceRecord::get()->filter(array("BounceEmail" => $to)); if (!$record->count()) { $record = NewsletterEmailBounceRecord::create(); $record->BounceEmail = $to; $record->BounceMessage = $error; $record->RecipientID = $recipient->ID; } else { $record = $record->first(); } $record->LastBounceTime = SS_Datetime::create()->now(); $record->write(); } // Set the e-mail flag imap_setflag_full($mailbox, $emailID, '\\flagged', ST_UID); // Also mark it for deletion. imap_delete($mailbox, $emailID, ST_UID); // And up the bounces counter. $this->bounces = $this->bounces + 1; }
/** * returns true if the provided email appears to be valid * @return bool */ function IsValid($email) { return Recipient::IsEmailInValidFormat($email); }
/** * * @param type $recipient * @return \Zbase\Entity\Laravel\Message\Recipient */ protected function _msgRecipient($recipient) { $msgRecipient = new Recipient(); if (!$recipient instanceof \Zbase\Entity\Laravel\User\User && is_numeric($recipient)) { $recipient = zbase_user_byid($recipient); } if ($recipient instanceof \Zbase\Entity\Laravel\User\User) { $msgRecipient->user_id = $recipient->id(); } $msgRecipient->read_status = 0; $msgRecipient->admin_read_status = 1; $msgRecipient->trash_status = 0; $msgRecipient->reply_status = 0; $msgRecipient->status = 2; $msgRecipient->is_in = 1; $msgRecipient->is_out = 0; $msgRecipient->message_id = $this->message_id; $msgRecipient->save(); return $msgRecipient; }
/** * @param $object * * @return $this|void */ public function loadFromArray($object) { parent::loadFromArray($object); if (!empty($this->recipients->items)) { foreach ($this->recipients->items as &$item) { $Recipient = new Recipient(); $Recipient->loadFromArray($item); $item = $Recipient; } } return $this; }
</table> </div> </div> </div> </div> <div class="section"> <div class="container"> <div class="row"> <div class="col-md-12"> <form role="form" method="post" action="managePermissions.php"> <div class="form-group"> <label class="control-label">Recipient</label> <select class="form-control" id="recipient" name="recipient"> <option selected></option> <?php $recipients = Recipient::searchByOwner($_SESSION['identification']); foreach ($recipients as $recipient) { echo "<option>" . $recipient->identification() . "</option>"; } ?> </select> </div> <div class="form-group"> <label class="control-label">Lock</label> <select class="form-control" id="lock" name="lock"> <option selected></option> <?php $locks = Lock::searchByOwner($_SESSION['identification']); foreach ($locks as $lock) { echo "<option>" . $lock->serial() . "</option>"; }
/** * Create a valid test recipient */ protected static function createTestRecipient(array $attributes = array()) { self::authorizeFromEnv(); return Recipient::create($attributes + array('name' => 'PHP Test', 'type' => 'individual', 'tax_id' => '000000000', 'bank_account' => array('country' => 'US', 'routing_number' => '110000000', 'account_number' => '000123456789'))); }
<?php session_start(); include_once "../php/Recipient.php"; if (isset($_POST['submit'])) { $recipient = new Recipient(); $recipient->identification($_POST['identification']); $recipient->password($_POST['password']); $recipient->firstName($_POST['firstName']); $recipient->secondName($_POST['secondName']); $recipient->firstSurname($_POST['firstSurname']); $recipient->secondSurname($_POST['secondSurname']); $recipient->bornDate($_POST['bornDate']); $recipient->gender($_POST['gender']); $recipient->cellPhone($_POST['cellPhone']); $recipient->email($_POST['email']); $recipient->address($_POST['address']); $recipient->update(); } header("location: showRecipient.php");
public function setRecipientDataParam($recipient_folder, $recipient_list, RecipientIdentifier $recipientIdentifier, array $recipient_ids, array $transientData) { $recipientDataArray = array(); $optionalDataArray = array(); $recipientCount = count($recipient_ids); for ($cnt = 0; $cnt < $recipientCount; $cnt++) { $optionalDataArray = null; $recipient = null; $recipient = new Recipient(); $recipient->setListName($recipient_folder, $recipient_list); $recipient->setEmailFormat(EmailFormat::NO_FORMAT); $recipient->{"set" . $recipientIdentifier->getValue()}($recipient_ids[$cnt]); // Build optionalData array foreach ($transientData[$cnt] as $name => $value) { $optionalData = null; $optionalData = new optionalData(); $optionalData->setName($name); $optionalData->setValue($value); $optionalDataArray[] = $optionalData; } $recipientDataObj = new RecipientData(); $recipientDataObj->setRecipient($recipient); $recipientDataObj->setOptionalData($optionalDataArray); $this->params['recipientData'][] = $recipientDataObj; } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); //var_dump($model->recipients); if (isset($_POST['Event'])) { $model->attributes = $_POST['Event']; if ($model->save()) { $recipient = new Recipient(); $recipient->email = "emailaddress1"; $recipient->event_id = $model->id; if (!$recipient->save()) { var_dump($recipient->getErrors()); die; } $this->redirect(array('update', 'id' => $model->id)); } } $this->render('update', array('model' => $model)); }