本文整理汇总了PHP中CASHSystem::getDefaultEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP CASHSystem::getDefaultEmail方法的具体用法?PHP CASHSystem::getDefaultEmail怎么用?PHP CASHSystem::getDefaultEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CASHSystem
的用法示例。
在下文中一共展示了CASHSystem::getDefaultEmail方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
public function getData()
{
switch ($this->status_uid) {
case 'people_signup_200' || 'people_verifyaddress_200':
// successful submit, return messaging and optionally an asset link
$show_final_message = true;
if ($this->status_uid == 'people_signup_200' && !$this->options['do_not_verify']) {
// if this is a first submit and we're verifying the email, first check to see if it's been verified already
$verification_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'checkverification', 'address' => $this->original_response['payload']['address'], 'list_id' => $this->options['email_list_id']));
if (!$verification_request->response['payload']) {
// not verified, so do not show the final message, and instead give a "you must verify" jam
$show_final_message = false;
$this->setTemplate('mustverify');
}
}
if ($show_final_message) {
$all_friends = array($this->original_request['friend1'], $this->original_request['friend2'], $this->original_request['friend3']);
if (!empty($this->original_request['main_name'])) {
$from_name = $this->original_request['main_name'];
} else {
$from_name = $this->original_request['address'];
}
if (!empty($this->options['email_html_message'])) {
$html_message = str_replace('</body>', '<br /><br /><br /><small>This e-card was sent from <a href="' . CASHSystem::getCurrentURL() . '">' . CASHSystem::getCurrentURL() . '</a></small></body>', $this->options['email_html_message']);
} else {
$html_message = false;
}
foreach ($all_friends as $friend) {
if (filter_var($friend, FILTER_VALIDATE_EMAIL)) {
CASHSystem::sendEmail(trim($this->options['email_subject']) . ' ' . $from_name, CASHSystem::getDefaultEmail(), $friend, $this->options['email_message'] . "\n\n\nThis e-card was sent from " . CASHSystem::getCurrentURL(), '', $html_message);
}
}
if ($this->options['asset_id'] != 0) {
// first we "unlock" the asset, telling the platform it's okay to generate a link for non-private assets
$unlock_request = new CASHRequest(array('cash_request_type' => 'asset', 'cash_action' => 'unlock', 'id' => $this->options['asset_id']));
// next we make the link
$asset_request = new CASHRequest(array('cash_request_type' => 'asset', 'cash_action' => 'getasset', 'id' => $this->options['asset_id']));
$this->element_data['asset_title'] = $asset_request->response['payload']['title'];
$this->element_data['asset_description'] = $asset_request->response['payload']['description'];
}
$this->setTemplate('success');
}
break;
case 'people_signup_400':
// error, likely in the email format. error message + default form
$this->element_data['error_message'] = $this->options['message_invalid_email'];
break;
}
return $this->element_data;
}
示例2: test_getDefaultEmail
function test_getDefaultEmail()
{
$cash_settings = parse_ini_file(CASH_PLATFORM_ROOT . '/settings/cashmusic.ini.php');
$parsed_default_email = $cash_settings['systememail'];
$this->assertEqual(CASHSystem::getDefaultEmail(), $parsed_default_email);
}
示例3: foreach
$settings = $cash_admin->getUserSettings();
if ($settings['banners'][BASE_PAGENAME]) {
$cash_admin->page_data['banner_main_content'] = '<a href="' . ADMIN_WWW_BASE_PATH . '/assets/" class="usecolor1">Assets</a>, your songs, photos, cover art, etc. <a href="' . ADMIN_WWW_BASE_PATH . '/people/" class="usecolor2">People</a>, fans, mailing lists, anyone you need to connect with on a regular basis. <a href="' . ADMIN_WWW_BASE_PATH . '/commerce/" class="usecolor3">Commerce</a> is where you’ll find info on all your orders. And <a href="' . ADMIN_WWW_BASE_PATH . '/calendar/" class="usecolor4">Calendar</a>, keeps a record of all your shows in one place.<br /><br />' . 'The last main category is <a href="' . ADMIN_WWW_BASE_PATH . '/elements/" class="usecolor5">Elements</a>, where Assets, People, Commerce, and Calendar can be combined to make customized tools for your site. Things like email collection, digital sales, and social feeds all just a copy/paste away.<br /><br />' . '<div class="moreinfospc"> </div></div>';
}
$elements_response = $cash_admin->requestAndStore(array('cash_request_type' => 'element', 'cash_action' => 'getelementsforuser', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'getelementsforuser');
if (is_array($elements_response['payload'])) {
$elements_data = AdminHelper::getElementsData();
foreach ($elements_response['payload'] as &$element) {
if (array_key_exists($element['type'], $elements_data)) {
$element['type_name'] = $elements_data[$element['type']]['name'];
}
}
$cash_admin->page_data['elements_for_user'] = new ArrayIterator($elements_response['payload']);
} else {
// no elements found, meaning it's a newer install
// first check if they've changed the default email as a sign of step 1:
if (CASHSystem::getDefaultEmail() != 'CASH Music <info@cashmusic.org>') {
$cash_admin->page_data['step1_complete'] = 'complete';
}
// now check for assets and/or lists as a sign of step 2:
$asset_response = $cash_admin->requestAndStore(array('cash_request_type' => 'asset', 'cash_action' => 'getanalytics', 'analtyics_type' => 'recentlyadded', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'asset_recently');
if (is_array($asset_response['payload'])) {
$cash_admin->page_data['step2_complete'] = 'complete';
} else {
$list_response = $cash_admin->requestAndStore(array('cash_request_type' => 'people', 'cash_action' => 'getlistsforuser', 'user_id' => AdminHelper::getPersistentData('cash_effective_user')), 'getlistsforuser');
if (is_array($asset_response['payload'])) {
$cash_admin->page_data['step2_complete'] = 'complete';
}
}
}
$cash_admin->setPageContentTemplate('mainpage');
示例4: getMarkup
public function getMarkup()
{
// define $markup to store all screen output
$markup = '';
// the default form and basic elements:
$default_markup = '<p class="cash_element_intro">' . $this->options->message_instructions . '</p>';
if (!empty($this->options->image_url)) {
$default_markup .= '<img src="' . $this->options->image_url . '" alt="E-Card" class="cash_image_ecard" />';
}
$default_markup .= '<form id="cash_' . self::type . '_form_' . $this->element_id . '" class="cash_form ' . self::type . '" method="post" action="">' . '<div class="cash_main_name_container"><label for="address">Your Name: (The \'from\' for the card)</label>' . '<input type="text" name="main_name" value="" class="cash_input cash_input_address cash_main_name" /></div>' . '<div class="cash_main_address_container"><label for="address">Your Email:</label>' . '<input type="email" name="address" value="" class="cash_input cash_input_address cash_main_address" /></div>' . '<div class="cash_friends">' . '<label for="address">Email Addresses For Up To 3 Friends:</label>' . '<input type="email" name="friend1" value="" class="cash_input cash_input_address cash_friend_address1" />' . '<input type="email" name="friend2" value="" class="cash_input cash_input_address cash_friend_address2" />' . '<input type="email" name="friend3" value="" class="cash_input cash_input_address cash_friend_address3" />' . '</div>' . '<input type="hidden" name="cash_request_type" value="people" />' . '<input type="hidden" name="cash_action" value="signup" />' . '<input type="hidden" name="list_id" value="' . $this->options->email_list_id . '" class="cash_input cash_input_list_id" />' . '<input type="hidden" name="element_id" value="' . $this->element_id . '" class="cash_input cash_input_element_id" />' . '<input type="hidden" name="comment" value="" class="cash_input cash_input_comment" />' . '<input type="submit" value="send the cards" class="button" /><br />' . '</form>';
switch ($this->status_uid) {
case 'people_signup_200' || 'people_verifyaddress_200':
// successful submit, return messaging and optionally an asset link
$markup = '<div class="cash_success ' . self::type . '">';
$show_final_message = true;
if ($this->status_uid == 'people_signup_200' && !$this->options->do_not_verify) {
// if this is a first submit and we're verifying the email, first check to see if it's been verified already
$verification_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'checkverification', 'address' => $this->original_response['payload']['address'], 'list_id' => $this->options->email_list_id));
if (!$verification_request->response['payload']) {
// not verified, so do not show the final message, and instead give a "you must verify" jam
$show_final_message = false;
$markup .= 'You must verify your email address to continue. An email has been sent. Click the link provided and you will be brought back here.<br /><br />(If you do not see the message, check your SPAM folder.)';
}
}
if ($show_final_message) {
$all_friends = array($this->original_request['friend1'], $this->original_request['friend2'], $this->original_request['friend3']);
if (!empty($this->original_request['main_name'])) {
$from_name = $this->original_request['main_name'];
} else {
$from_name = $this->original_request['address'];
}
if (!empty($this->options->email_html_message)) {
$html_message = str_replace('</body>', '<br /><br /><br /><small>This e-card was sent from <a href="' . CASHSystem::getCurrentURL() . '">' . CASHSystem::getCurrentURL() . '</a></small></body>', $this->options->email_html_message);
} else {
$html_message = false;
}
foreach ($all_friends as $friend) {
if (filter_var($friend, FILTER_VALIDATE_EMAIL)) {
CASHSystem::sendEmail(trim($this->options->email_subject) . ' ' . $from_name, CASHSystem::getDefaultEmail(), $friend, $this->options->email_message . "\n\n\nThis e-card was sent from " . CASHSystem::getCurrentURL(), '', $html_message);
}
}
$markup .= $this->options->message_success;
if ($this->options->asset_id != 0) {
// first we "unlock" the asset, telling the platform it's okay to generate a link for non-private assets
$unlock_request = new CASHRequest(array('cash_request_type' => 'asset', 'cash_action' => 'unlock', 'id' => $this->options->asset_id));
// next we make the link
$asset_request = new CASHRequest(array('cash_request_type' => 'asset', 'cash_action' => 'getasset', 'id' => $this->options->asset_id));
$asset_title = $asset_request->response['payload']['title'];
$asset_description = $asset_request->response['payload']['description'];
$markup .= '<br /><br />' . '<a href="?cash_request_type=asset&cash_action=claim&id=' . $this->options->asset_id . '&element_id=' . $this->element_id . '" class="download">' . $asset_title . '</a>' . '<div class="description">' . $asset_description . '</div>';
}
}
if (!empty($this->options->image_url)) {
$markup .= '<img src="' . $this->options->image_url . '" alt="E-Card" class="cash_image_ecard" />';
}
$markup .= '</div>';
break;
case 'people_signup_400':
// error, likely in the email format. error message + default form
$markup = '<div class="cash_error ' . self::type . '">' . $this->options->message_invalid_email . '</div>' . $default_markup;
break;
default:
// default form
$markup = $default_markup;
}
return $markup;
}
示例5: addAddress
/**
* Adds a user to a list. If no user exists for the email address passed, a
* new user will be created then added to the list.
*
* @param {string} $address - the email address in question
* @param {int} $list_id - the id of the list
* @param {bool} $verified - 0 for unverified, 1 to skip verification and mark ok
* @param {string} $initial_comment - a comment passed with the list signup
* @param {string} $additional_data - any extra data (JSON, etc) a dev might pass with signup for later use
* @param {string} $name - if the user doesn't exist in the system this will be used as their display name
* @return bool
*/
protected function addAddress($address, $list_id, $do_not_verify = false, $initial_comment = '', $additional_data = '', $name = 'Anonymous', $force_verification_url = false, $request_from_service = false, $service_opt_in = true)
{
if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
// first check to see if the email is already on the list
$user_id = $this->getUserIDForAddress($address);
if (!$this->getAddressListInfo($address, $list_id)) {
$initial_comment = strip_tags($initial_comment);
$name = strip_tags($name);
$user_id = $this->getUserIDForAddress($address);
if (!$user_id) {
$addlogin_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => $address, 'password' => rand(23456, 9876541), 'display_name' => $name));
if ($addlogin_request->response['status_code'] == 200) {
$user_id = $addlogin_request->response['payload'];
} else {
return false;
}
}
if ($user_id) {
$result = $this->db->setData('list_members', array('user_id' => $user_id, 'list_id' => $list_id, 'initial_comment' => $initial_comment, 'verified' => 0, 'active' => 1));
if ($result && !$request_from_service) {
if ($do_not_verify) {
$api_connection = $this->getConnectionAPI($list_id);
if ($api_connection) {
// connection found, api instantiated
switch ($api_connection['connection_type']) {
case 'com.mailchimp':
$mc = $api_connection['api'];
// mailchimp found. subscribe user and request opt-in
// error_log(json_encode($mc));
$rc = $mc->listSubscribe($address, null, null, $service_opt_in);
// error_log(json_encode($rc));
break;
}
}
} else {
$list_details = $this->getList($list_id);
$verification_code = $this->setAddressVerification($address, $list_id);
$verification_url = $force_verification_url;
if (!$verification_url) {
$verification_url = CASHSystem::getCurrentURL();
}
$verification_url .= '?cash_request_type=people&cash_action=verifyaddress&address=' . urlencode($address) . '&list_id=' . $list_id . '&verification_code=' . $verification_code;
CASHSystem::sendEmail('Complete sign-up for: ' . $list_details['name'], CASHSystem::getDefaultEmail(), $address, 'You requested to join the ' . $list_details['name'] . ' email list. If this message has been sent in error ignore it.' . 'To complete your sign-up simply visit: ' . "\n\n" . $verification_url, 'Please confirm your membership');
}
}
return $result;
}
} else {
// address already present, do nothing but return true
return true;
}
}
return false;
}
示例6: finalizeRedirectedPayment
protected function finalizeRedirectedPayment($order_id, $creation_date, $direct_post_details = false)
{
$order_details = $this->getOrder($order_id);
$transaction_details = $this->getTransaction($order_details['transaction_id']);
$connection_type = $this->getConnectionType($transaction_details['connection_id']);
switch ($connection_type) {
case 'com.paypal':
if (isset($_GET['token'])) {
if (isset($_GET['PayerID'])) {
$pp = new PaypalSeed($order_details['user_id'], $transaction_details['connection_id'], $_GET['token']);
$initial_details = $pp->getExpressCheckout();
if ($initial_details['ACK'] == 'Success') {
$order_totals = $this->getOrderTotals($order_details['order_contents']);
if ($initial_details['AMT'] >= $order_totals['price']) {
$final_details = $pp->doExpressCheckout();
if ($final_details) {
// look for a user to match the email. if not present, make one
$user_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getuseridforaddress', 'address' => $initial_details['EMAIL']));
$user_id = $user_request->response['payload'];
if (!$user_id) {
$user_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'addlogin', 'address' => $initial_details['EMAIL'], 'password' => time(), 'is_admin' => 0, 'display_name' => $initial_details['FIRSTNAME'] . ' ' . $initial_details['LASTNAME'], 'first_name' => $initial_details['FIRSTNAME'], 'last_name' => $initial_details['LASTNAME'], 'address_country' => $initial_details['COUNTRYCODE']));
$user_id = $user_request->response['payload'];
}
// record the details to the order/transaction where appropriate
$this->editOrder($order_id, 1, 0, false, $initial_details['COUNTRYCODE'], $user_id);
$this->editTransaction($order_details['transaction_id'], $service_timestamp = strtotime($final_details['TIMESTAMP']), $service_transaction_id = $final_details['CORRELATIONID'], $data_sent = json_encode($initial_details), $data_returned = json_encode($final_details), $successful = 1, $gross_price = $final_details['PAYMENTINFO_0_AMT'], $service_fee = $final_details['PAYMENTINFO_0_FEEAMT'], $status = 'complete');
$addcode_request = new CASHRequest(array('cash_request_type' => 'element', 'cash_action' => 'addlockcode', 'element_id' => $order_details['element_id']));
// bit of a hack, hard-wiring the email bits:
CASHSystem::sendEmail('Your download is ready', CASHSystem::getDefaultEmail(), $initial_details['EMAIL'], 'Your download of "' . $initial_details['L_PAYMENTREQUEST_0_NAME0'] . '" is ready and can be found at: ' . CASHSystem::getCurrentURL() . '?cash_request_type=element&cash_action=redeemcode&code=' . $addcode_request->response['payload'] . '&element_id=' . $order_details['element_id'] . '&email=' . urlencode($initial_details['EMAIL']), 'Thank you');
return true;
} else {
// make sure this isn't an accidentally refreshed page
if ($initial_details['CHECKOUTSTATUS'] != 'PaymentActionCompleted') {
$initial_details['ERROR_MESSAGE'] = $pp->getErrorMessage();
// there was an error processing the transaction
$this->editOrder($order_id, 0, 1);
$this->editTransaction($order_details['transaction_id'], $service_timestamp = strtotime($initial_details['TIMESTAMP']), $service_transaction_id = $initial_details['CORRELATIONID'], $data_sent = false, $data_returned = json_encode($initial_details), $successful = 0, $gross_price = false, $service_fee = false, $status = 'error processing payment');
return false;
} else {
// this is a successful transaction with the user hitting refresh
// as long as it's within 30 minutes of the original return true, otherwise
// call it false and allow the page to expire
if (time() - strtotime($initial_details['TIMESTAMP']) < 180) {
return true;
} else {
return false;
}
}
}
} else {
// insufficient funds — user changed amount?
$this->editOrder($order_id, 0, 1);
$this->editTransaction($order_details['transaction_id'], $service_timestamp = strtotime($initial_details['TIMESTAMP']), $service_transaction_id = $initial_details['CORRELATIONID'], $data_sent = false, $data_returned = json_encode($initial_details), $successful = 0, $gross_price = false, $service_fee = false, $status = 'incorrect amount');
return false;
}
} else {
// order reporting failure
$this->editOrder($order_id, 0, 1);
$this->editTransaction($order_details['transaction_id'], $service_timestamp = strtotime($initial_details['TIMESTAMP']), $service_transaction_id = $initial_details['CORRELATIONID'], $data_sent = false, $data_returned = json_encode($initial_details), $successful = 0, $gross_price = false, $service_fee = false, $status = 'payment failed');
return false;
}
} else {
// user canceled transaction
$this->editOrder($order_id, 0, 1);
$this->editTransaction($order_details['transaction_id'], $service_timestamp = time(), $service_transaction_id = false, $data_sent = false, $data_returned = false, $successful = 0, $gross_price = false, $service_fee = false, $status = 'canceled');
return false;
}
}
break;
default:
return false;
}
}
示例7: sendEmail
public static function sendEmail($subject, $user_id, $toaddress, $message_text, $message_title, $encoded_html = false)
{
// pulling out just the TO email from a 'Address Name <address@name.com>' style address:
if (strpos($toaddress, '>')) {
preg_match('/([^<]+)\\s<(.*)>/', $toaddress, $matches);
if (count($matches)) {
$toaddress = $matches[2];
}
}
// if the email is bullshit don't try to send to it:
if (!filter_var($toaddress, FILTER_VALIDATE_EMAIL)) {
return false;
}
// TODO: look up user settings for email if user_id is set — allow for multiple SMTP settings
// on a per-user basis in the multi-user system
$email_settings = CASHSystem::getDefaultEmail(true);
if (CASHSystem::getSystemSettings('instancetype') == 'multi' && $user_id) {
$user_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getuser', 'user_id' => $user_id));
$user_details = $user_request->response['payload'];
$setname = false;
if (trim($user_details['display_name'] . '') !== '' && $user_details['display_name'] !== 'Anonymous') {
$setname = $user_details['display_name'];
}
if (!$setname && $user_details['username']) {
$setname = $user_details['username'];
}
if ($setname) {
$fromaddress = $setname . ' <' . $user_details['email_address'] . '>';
} else {
$fromaddress = $user_details['email_address'];
}
} else {
$fromaddress = $email_settings['systememail'];
}
// let's deal with complex versus simple email addresses. if we find '>' present we try
// parsing for name + address from a 'Address Name <address@name.com>' style email:
if (strpos($fromaddress, '>')) {
preg_match('/([^<]+)\\s<(.*)>/', $fromaddress, $matches);
if (count($matches)) {
$from = array($matches[2] => $matches[1]);
} else {
$from = $fromaddress;
}
} else {
$from = $fromaddress;
}
// handle encoding of HTML if specific HTML isn't passed in:
if (!$encoded_html) {
$template = @file_get_contents(CASH_PLATFORM_ROOT . '/settings/defaults/system_email.mustache');
if (file_exists(CASH_PLATFORM_ROOT . '/lib/markdown/markdown.php')) {
include_once CASH_PLATFORM_ROOT . '/lib/markdown/markdown.php';
}
$message_text = Markdown($message_text);
$encoded_html = preg_replace('/(\\shttp:\\/\\/(\\S*))/', '<a href="\\1">\\1</a>', $message_text);
if (!$template) {
$encoded_html .= '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>' . $message_title . '</title></head><body>' . "<h1>{$message_title}</h1>\n" . "<p>" . $encoded_html . "</p>" . "</body></html>";
} else {
// open up some mustache in here:
include_once CASH_PLATFORM_ROOT . '/lib/mustache/Mustache.php';
$higgins = new Mustache();
$mustache_vars = array('encoded_html' => $encoded_html, 'message_title' => $message_title, 'cdn_url' => defined('CDN_URL') ? CDN_URL : CASH_ADMIN_URL);
$encoded_html = $higgins->render($template, $mustache_vars);
}
}
// deal with SMTP settings later:
$smtp = $email_settings['smtp'];
// include swift mailer
include_once CASH_PLATFORM_ROOT . '/lib/swift/swift_required.php';
if ($smtp) {
// use SMTP settings for goodtimes robust happy mailing
$transport = Swift_SmtpTransport::newInstance($email_settings['smtpserver'], $email_settings['smtpport']);
if ($email_settings['smtpusername']) {
$transport->setUsername($email_settings['smtpusername']);
$transport->setPassword($email_settings['smtppassword']);
}
} else {
// aww shit. use mail() and hope it gets there
$transport = Swift_MailTransport::newInstance();
}
$swift = Swift_Mailer::newInstance($transport);
$message = new Swift_Message($subject);
$message->setFrom($from);
$message->setBody($encoded_html, 'text/html');
$message->setTo($toaddress);
$message->addPart($message_text, 'text/plain');
$headers = $message->getHeaders();
$headers->addTextHeader('X-MC-Track', 'opens');
// Mandrill-specific tracking...leave in by defauly, no harm if not Mandrill
if ($recipients = $swift->send($message, $failures)) {
return true;
} else {
return false;
}
}