/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $this->user = $this->getUser(); //$user_id = $_SESSION['symfony/user/sfUser/attributes']['symfony/user/sfUser/attributes']['user_id']; $user = $this->getUser()->getRaykuUser(); if ($user) { $user_id = $user->getId(); } if (!$user_id) { $this->forward('/dashboard'); } $this->setVar('user_id', $user_id); //Form submitted if (sfWebRequest::POST == $this->getRequest()->getMethod()) { $emails = $this->getRequestParameter('emails'); $ref = $this->getRequestParameter('ref'); if (!$emails) { echo "Invalid emails"; return false; } $mail = Mailman::createMailer(); $mail->setContentType('text/html'); $mail->addAddress($emails); $mail->setSubject('Invitation'); sfProjectConfiguration::getActive()->loadHelpers(array('Asset', 'Url', 'Partial')); $mail->setBody(get_partial('invitationEmailHtml', array('ref' => $ref, 'user' => $user))); $mail->send(); //$this->forward('referrals', 'invitesSent'); } }
/** * Execute the console command. * * @return mixed */ public function fire() { // send email $user = User::find(1); $data = array('user' => $user); $email = Mailman::make('emails.trialWillEnd')->with($data)->to('*****@*****.**')->subject('[Fruit Analytics] Your free trial is ending.')->show(); //->send(); File::put(public_path() . '/development_email.html', $email); }
public function fire($job, $data) { // we only get the user ID, get the user from it $user = User::find($data['userID']); Calculator::calculateMetricsOnConnect($user); Log::info('Sending "ready" email for user: '******'emails.connected')->to($user->email)->subject('Your metrics are ready!')->send(); $user->ready = 'connected'; $user->save(); $job->delete(); }
private function overview() { global $user, $smarty; $mails = array(); foreach ($user->getMails() as $mail) { if ($user->isVerified($mail)) { $mails[] = $mail; } } $smarty->assign("mails", $mails); $mailman = new Mailman($user, $this->options["mailman_group"], $this->options["mailman_binpath"]); if (isset($_POST["save"])) { foreach ($mailman->getLists() as $list) { $mail = stripslashes($_POST["mail"][$list->getName()]); if (empty($mail) && $list->hasMember() || !empty($mail) && !$list->hasMember($mail)) { foreach ($list->getMembers() as $member) { if ($user->hasMail($member)) { $list->removeMember($member); } } } if (!empty($mail) && !$list->hasMember($mail)) { $list->addMember($mail); } } } $lists = array(); foreach ($mailman->getLists() as $list) { $members = array(); $has = false; foreach ($mails as $mail) { if ($list->hasMember($mail)) { $members[] = $mail; $has = true; } } $lists[] = array($list->getName(), $list->getSendAddress(), $list->getDescription(), $list->getArchiveURL(), $has, $members); } $smarty->assign("lists", $lists); return $smarty->fetch("lists.tpl"); }
private function sendConfirmationEmail(User $user, $question) { $mail = Mailman::createMailer(); $mail->setContentType('text/html'); $mail->addAddress($user->getEmail()); $mail->setSubject('Activate your new account'); sfProjectConfiguration::getActive()->loadHelpers(array('Asset', 'Url', 'Partial')); $confirmationCode = array('code' => $user->getConfirmationCode(), 'question' => $question); $confirmationCode = base64_encode(serialize($confirmationCode)); $mail->setBody(get_partial('activationEmail', array('confirmationCode' => $confirmationCode, 'user' => $user))); $mail->setAltBody(get_partial('activationEmailHtml', array('confirmationCode' => url_for('@register_confirm?code=' . $confirmationCode, true), 'user' => $user))); $mail->send(); }
/** * Execute the console command. * * @return mixed */ public function fire() { $users = User::all(); foreach ($users as $user) { if ($user->isTrialEnded()) { if ($user->plan == 'trial') { // this is the first time we are checking it $user->plan = 'trial_ended'; $user->save(); // create intercom event IntercomHelper::trialEnded($user, 'now'); // send email } } if ($user->trialWillEndExactlyInDays(3)) { // create intercom event IntercomHelper::trialWillEnd($user, 3); // send email $data = array('user' => $user); Mailman::make('emails.trialWillEnd')->with($data)->to($user->email)->subject('[Fruit Analytics] Your free trial is ending.')->send(); } if ($user->trialWillEndExactlyInDays(-1)) { // create intercom event IntercomHelper::trialEnded($user, '1-day-ago'); // send email $data = array('user' => $user); Mailman::make('emails.trialEndedFirst')->with($data)->to($user->email)->subject('[Fruit Analytics] Your free trial is ended')->send(); } if ($user->trialWillEndExactlyInDays(-7)) { // create intercom event IntercomHelper::trialEnded($user, '7-days-ago'); // send email $data = array('user' => $user); Mailman::make('emails.trialEndedSecond')->with($data)->to($user->email)->subject('[Fruit Analytics] ')->send(); } if ($user->trialWillEndExactlyInDays(-14)) { /// create intercom event IntercomHelper::trialEnded($user, '14-days-ago'); // send email $data = array('user' => $user); Mailman::make('emails.trialEndedThird')->with($data)->to($user->email)->subject('[Fruit Analytics]')->send(); } } }
public function executeSendmail() { $c = new Criteria(); $users = UserPeer::doSelect($c); foreach ($users as $user) { $this->mail = Mailman::createCleanMailer(); $subject = $_POST['massmail_subject']; $this->mail->setSubject($subject); $this->mail->setFrom("Rayku < *****@*****.** >"); $to = $user->getEmail(); sfProjectConfiguration::getActive()->loadHelpers(array('Partial')); $this->mail->setBody($_POST['massmail_content']); $this->mail->setContentType('text/html'); $this->mail->addAddress($to); $this->mail->send(); if ($this->mail) { $_SESSION['mailsent'] = 1; } } $this->redirect('massmail/index'); }
public function update() { $userId = $this->registry->request->getParam("userId"); $name = $this->registry->request->getParam("name"); $email = $this->registry->request->getParam("email"); $pin = $this->registry->request->getParam("pin"); $birthday = new DateTime($this->registry->request->getParam("birthday")); $updatedUser = new User($email, $pin); $updatedUser->setName($name); $updatedUser->setBirthday($birthday); $updatedUser->setUserId((int) $userId); $userDao = new UserDAO(); try { $userDao->updateUser($updatedUser); $_SESSION[AppConstants::SESSION_USER] = $email; $_SESSION[AppConstants::SESSION_PASSWORD] = $pin; Mailman::sendNoticeOfUpdatedUser($updatedUser); $this->redirect("/account?success=" . MessageConfig::USER_UPDATE_SUCCESS); } catch (Exception $e) { $this->redirect("/account?error=" . $e->getMessage()); } }
public function executeSendNewPassword() { $password = $this->getRequest()->getAttribute('password'); $user = $this->getRequest()->getAttribute('user'); /* @var $user User */ $this->mail = Mailman::createMailer(); // set from, to and subject $this->mail->addAddress($user->getEmail()); $this->mail->setSubject('Rayku.com New Password'); // set view vars $this->name = $user->getName(); $this->password = $password; }
public function executeCheckout() { $this->user = $this->getUser()->getRaykuUser(); $voucher_id = $this->getUser()->getAttribute('voucher_id'); $offer = OfferVoucherPeer::retrieveByPK($voucher_id); //$_SESSION['offerid'] = $offer->getId(); if ($this->getRequest()->getMethod() == sfRequest::POST) { $c = new Criteria(); $c->add(ShoppingCartPeer::IS_ACTIVE, true); $c->add(ShoppingCartPeer::USER_ID, $this->user->getId()); $c->addDescendingOrderByColumn(ShoppingCartPeer::CREATED_AT); $this->cart_items = ShoppingCartPeer::doSelect($c); $purchase_detail = $this->getRequestParameter('purchase'); foreach ($purchase_detail as $index => $value) { $purchaseDetail[$index] = trim($value); } if ($purchaseDetail['name'] == '' || $purchaseDetail['email'] == '' || $purchaseDetail['address_1'] == '' || $purchaseDetail['city'] == '' || $purchaseDetail['state'] == '' || $purchaseDetail['zip'] == '' || $purchaseDetail['country'] == '' || $purchaseDetail['tel'] == '') { sfProjectConfiguration::getActive()->loadHelpers(array('Url', 'Tag')); $this->msg = "<p>Please fill in all additional information on the <b>Purchase Cart</b> page.</p>"; $this->msg .= "<p>" . link_to('Go back to the <b>Purchase Cart</b> page.', 'shop/checkoutPage') . "</p>"; } else { if (count($this->cart_items) > 0) { $count = 0; $tot_price = 0; $tot_item_price = 0; $tot_shipping_price = 0; $tot_quantity = 0; foreach ($this->cart_items as $cart_item) { $tot_price = $tot_price + $cart_item->getTotalPrice() + $cart_item->getTotalShippingCharge(); if ($tot_price > $this->user->getPoints()) { break; } $sales_detail = new SalesDetail(); $sales_detail->setItemId($cart_item->getItemId()); $sales_detail->setTotalPrice($cart_item->getTotalPrice()); $sales_detail->setTotalShippingCharge($cart_item->getTotalShippingCharge()); $sales_detail->setQuantity($cart_item->getQuantity()); $sales_detail->save(); $count++; $tot_item_price = $tot_item_price + $cart_item->getTotalPrice(); $tot_shipping_price = $tot_shipping_price + $cart_item->getTotalShippingCharge(); $tot_quantity = $tot_quantity + $cart_item->getQuantity(); $itemPurchased = ItemPeer::retrieveByPK($cart_item->getItemId()); if (empty($purchasedItems)) { $purchasedItems = $itemPurchased->getTitle(); } else { $purchasedItems = $purchasedItems . "," . $itemPurchased->getTitle(); } $cart_item->delete(); } $sales = new Sales(); if ($offer instanceof OfferVoucher) { $tot_price = $tot_price - $offer->getPrice(); //$sales->setOfferVoucherId($offer->getId()); $offer->setIsUsed(true); $offer->save(); } $sales->setTotalSalePrice($tot_price); $sales->setTotalItemPrice($tot_item_price); $sales->setTotalShippingCharge($tot_shipping_price); $sales->setQuantity($tot_quantity); $sales->setStatusId(1); $sales->save(); $this->user->setPoints($this->user->getPoints() - $tot_price); $this->user->save(); $full_name = htmlentities($purchase_detail['name']); $email = htmlentities($purchase_detail['email']); $address_1 = htmlentities($purchase_detail['address_1']); $address_2 = htmlentities($purchase_detail['address_2']); $city = htmlentities($purchase_detail['city']); $state = htmlentities($purchase_detail['state']); $zip = htmlentities($purchase_detail['zip']); $country = htmlentities($purchase_detail['country']); $tel = htmlentities($purchase_detail['tel']); $purchase_detail = new PurchaseDetail(); $purchase_detail->setFullName($full_name); $purchase_detail->setUserId($this->user->getId()); $purchase_detail->setEmail($email); $purchase_detail->setAddress1($address_1); $purchase_detail->setAddress2($address_2); $purchase_detail->setCity($city); $purchase_detail->setZip($zip); $purchase_detail->setState($state); $purchase_detail->setCountry($country); $purchase_detail->setSalesId($sales->getId()); $purchase_detail->save(); $user = $this->getUser()->getRaykuUser(); $this->mail = Mailman::createCleanMailer(); $this->mail->setSubject('Rayku.com Shoping Item Purchase Details'); $this->mail->setFrom($user->getName() . ' <' . $user->getEmail() . '>'); $to = "*****@*****.**"; $items = "<b>" . $purchasedItems . "</b>"; sfProjectConfiguration::getActive()->loadHelpers(array('Partial')); $this->mail->setBody(get_partial('purchaseitem', array('name' => $user->getName(), 'user' => $user, 'items' => $items))); $this->mail->setContentType('text/html'); $this->mail->addAddress($to); $this->mail->send(); $this->msg = "<p style='font-size:14px;color:#444444'>You have just spent " . $tot_price . "RP to purchase " . $count . " item(s).<br /><br />A Rayku administrator has been notified, and will deliver your purchase as soon as possible. Once your order has been processed, you will be notified by private message here on Rayku.<br /><br />Thanks!<br />Rayku.com Staff</p>"; $this->getUser()->setAttribute('voucher_id', null); } else { $this->msg = "<p style='font-size:14px;color:#444444'>No items in cart</p>"; } } } else { $this->msg = "<p style='font-size:14px;color:#444444'>Unauthorized access.</p>"; } }
/** * Execute the console command. * * @return mixed */ public function fire() { // get all the users $users = User::all(); $previousDayDate = Carbon::yesterday()->toDateString(); // currently calculated metrics $currentMetrics = Calculator::currentMetrics(); // for each user send email with their metrics $dailyEmailSent = 0; $weeklyEmailSent = 0; foreach ($users as $user) { // check if user finished the connect process if ($user->isConnected() && $user->ready == 'connected' && !$user->isTrialEnded()) { switch ($user->summaryEmailFrequency) { case 'none': // no summary email break; case 'daily': // default behavior, send yesterday's data // get the user's metrics $metric = Metric::where('user', $user->id)->where('date', $previousDayDate)->first(); if ($metric) { $previousMetrics = Metric::where('user', $user->id)->where('date', '<=', Carbon::yesterday()->subDays(30)->toDateString())->orderBy('date', 'desc')->first(); $changes = array(); foreach ($currentMetrics as $metricID => $metricDetails) { // get the correct color $changes[$metricID]['positiveIsGood'] = $metricDetails['metricClass']::POSITIVE_IS_GOOD; $date = $metric->date; if ($previousMetrics) { if ($previousMetrics->{$metricID} != 0) { $value = $metric->{$metricID} / $previousMetrics->{$metricID} * 100 - 100; $changes[$metricID][$date]['isBigger'] = $value > 0 ? true : false; $changes[$metricID][$date]['value'] = round($value) . ' %'; } else { $changes[$metricID][$date]['value'] = null; } } else { $changes[$metricID][$date]['value'] = null; } } // format metrics to presentable data $metric->formatMetrics(); // this line is for making the daily email the same format as the weekly // so we only need one email template $metrics = array($metric->date => $metric); $data = array('metrics' => $metrics, 'currentMetrics' => $currentMetrics, 'changes' => $changes, 'isDaily' => true, 'index' => 0); $email = Mailman::make('emails.summary')->with($data)->to($user->email)->subject('Daily summary')->send(); //File::put(public_path().'/summary_email.html',$email); $dailyEmailSent++; } break; case 'weekly': // send a weekly summary to the user with their numbers // check if today is monday (we send weekly emails on monday) /* improvment idea change this if to switch-case with days for user controlled daily send */ if (Carbon::now()->dayOfWeek == Carbon::WEDNESDAY) { // get the user's metrics $metrics = Metric::where('user', $user->id)->where('date', '<=', $previousDayDate)->orderBy('date', 'desc')->take(7)->get(); $previousMetrics = Metric::where('user', $user->id)->where('date', '<=', Carbon::yesterday()->subDays(30)->toDateString())->orderBy('date', 'desc')->take(7)->get(); $changes = array(); foreach ($currentMetrics as $metricID => $metricDetails) { // get the correct color $changes[$metricID]['positiveIsGood'] = $metricDetails['metricClass']::POSITIVE_IS_GOOD; foreach ($previousMetrics as $id => $prevMetric) { $date = $metrics[$id]->date; if ($prevMetric->{$metricID} != 0) { $value = $metrics[$id]->{$metricID} / $prevMetric->{$metricID} * 100 - 100; $changes[$metricID][$date]['isBigger'] = $value > 0 ? true : false; $changes[$metricID][$date]['value'] = round($value) . ' %'; } else { $changes[$metricID][$date]['value'] = null; } } } // format metrics to presentable data $weeklyMetrics = array(); foreach ($metrics as $metric) { $metric->formatMetrics(); $weeklyMetrics[$metric->date] = $metric; } $data = array('metrics' => $weeklyMetrics, 'currentMetrics' => $currentMetrics, 'changes' => $changes, 'isDaily' => false, 'index' => 0); // login the user (necessary to get the email address) // Auth::login($user); // send the email to the user $email = Mailman::make('emails.summary')->with($data)->to($user->email)->subject('Weekly summary')->send(); //File::put(public_path().'/summary_email.html',$email); $weeklyEmailSent++; } break; default: Log::error('notifications string has been changed, check the email sending code'); break; } // /switch } // /isConnected } // /foreach Log::info($dailyEmailSent . ' daily summary emails sent out of ' . count($users) . ' users'); Log::info($weeklyEmailSent . ' daily summary emails sent out of ' . count($users) . ' users'); Log::info('Total of ' . $dailyEmailSent + $weeklyEmailSent . ' emails sent'); }
/** * Sends a private message from this user to $recipientID * * @param int $recipientID * @param string $subject * @param string $message * @return bool */ public function sendMessage($recipientID, $subject, $message, $stripTags = true) { //If the user is banned, they can't send a message if ($this->getHidden()) { return false; } $recipient = UserPeer::retrieveByPK($recipientID); if (!$recipient) { return false; } $pm = new PrivateMessage(); $pm->setSenderId($this->getId()); $pm->setRecipientID($recipientID); // $subject = $stripTags ? strip_tags($subject, sfConfig::get('app_general_allowed_html_tags')) : $subject; $pm->setSubject($subject); // $message = $stripTags ? strip_tags($message, sfConfig::get('app_general_allowed_html_tags')) : $message; $pm->setBody($message); $saveStatus = $pm->save(); $c = new Criteria(); $c->add(NotificationEmailsPeer::USER_ID, $recipientID); $notifies = NotificationEmailsPeer::doSelectOne($c); if ($notifies != NULL) { if ($notifies->getOnOff() == 0) { if ($saveStatus) { $mailer = Mailman::createMailer(); $mailer->setContentType('text/html'); $mailer->addAddress($recipient->getEmail()); $mailer->setSubject('New Private Message from Rayku.com'); sfProjectConfiguration::getActive()->loadHelpers(array('Url', 'Partial')); $mailer->setBody(get_partial('global/mail/newPMNotification', array('pm' => $pm))); //Send the e-mail off $mailer->send(); } } } else { if ($saveStatus) { $mailer = Mailman::createMailer(); $mailer->setContentType('text/html'); $mailer->addAddress($recipient->getEmail()); $mailer->setSubject('New Private Message from Rayku.com'); sfProjectConfiguration::getActive()->loadHelpers(array('Url', 'Partial')); $mailer->setBody(get_partial('global/mail/newPMNotification', array('pm' => $pm))); //Send the e-mail off $mailer->send(); } } return $saveStatus; }
/** * Execute the console command. * * @return mixed */ public function fire() { $email = Mailman::make('emails.connected')->to('*****@*****.**')->subject('Your metrics are ready!')->send(); // File::put(public_path().'/connected_email.html',$email); }
private function deleteMail() { global $smarty, $user, $userdb; $smarty->assign("mail", stripslashes($_REQUEST["mail"])); $allmails = $user->getMails(); $mails = array(); foreach ($allmails as $mail) { if ($user->isVerified($mail)) { $mails[] = $mail; } } $smarty->assign("mails", $mails); if (isset($_POST["act"])) { $mail = stripslashes($_POST["mail"]); $listsoption = stripslashes($_POST["listsoption"]); $movemail = stripslashes($_REQUEST["movemail"]); if (!in_array($mail, $user->getMails())) { $smarty->assign("mailnotinuse", 1); return $this->overview(); } else { if ($listsoption == "move" && !$user->isVerified($movemail)) { $smarty->assign("notverified", 1); return $smarty->fetch("delete_mail.tpl"); } else { if ($listsoption == "move" && $mail == $movemail) { $smarty->assign("sourceequalsdestination", 1); return $smarty->fetch("delete_mail.tpl"); } else { $mailman = new Mailman($user); if ($listsoption == "delete") { $mailman = new Mailman($user); foreach ($mailman->getLists() as $list) { if ($list->hasMember($mail)) { $list->removeMember($mail); } } } if ($listsoption == "move") { $mailman = new Mailman($user); foreach ($mailman->getLists() as $list) { if ($list->hasMember($mail)) { $list->removeMember($mail); $list->addMember($movemail); } } } $user->deleteMail($mail); $user->save(); $smarty->assign("success", 1); return $this->overview(); } } } } else { return $smarty->fetch("delete_mail.tpl"); } }
private function sendConfirmationEmail(User $user) { $mail = Mailman::createMailer(); $mail->setContentType('text/html'); $mail->addAddress($user->getEmail()); $mail->setSubject('Confirm your Rayku Account'); sfProjectConfiguration::getActive()->loadHelpers(array('Asset', 'Url', 'Partial')); $mail->setBody(get_partial('activationEmailHtml', array('activationLink' => url_for('@regtutor_confirm?code=' . $user->getConfirmationCode(), true), 'user' => $user))); $mail->setAltBody(get_partial('activationEmail', array('activationLink' => url_for('@regtutor_confirm?code=' . $user->getConfirmationCode(), true), 'user' => $user))); $mail->send(); }
/** * Retrieve class instance * For use of static functions */ public static function instance() { if (self::$_instance === NULL) { self::$_instance = new Mailman(); } return self::$_instance; }