function send() { DB::escapePost(); $model = new Notification(); $model->send(); $this->redirect('/notification/'); }
public function action_create() { $json = Input::json(); $project = Config::get('project'); $comment = new Comment(array('project_id' => $project->id, 'officer_id' => Auth::officer()->id)); $comment->body = $json->body; $comment->save(); foreach ($comment->project->officers as $officer) { if (Auth::officer()->id != $officer->id) { Notification::send("Comment", array('comment' => $comment, 'target_id' => $officer->user->id)); } } return Response::json($comment->to_array()); }
public static function sendNotification($type, $date, $tracker, $message) { if ($type == 'warning') { $header_message = 'Предупреждение.'; } if ($type == 'notification') { $header_message = 'Обновление.'; } $settingEmail = Database::getSetting('email'); if (!empty($settingEmail)) { if ($type == 'warning') { if (Database::getSetting('send_warning')) { Notification::send($settingEmail, $date, $tracker, $message, $header_message); } } if ($type == 'notification') { if (Database::getSetting('send')) { Notification::send($settingEmail, $date, $tracker, $message, $header_message); } } } }
/** * Raise a notification event event * * @param $event the event raised for the itemtype * @param $item the object which raised the event * @param $options array of options used * @param $label used for debugEvent() (default '') **/ static function raiseEvent($event, $item, $options = array(), $label = '') { global $CFG_GLPI; //If notifications are enabled in GLPI's configuration if ($CFG_GLPI["use_mailing"]) { $email_processed = array(); $email_notprocessed = array(); //Get template's information $template = new NotificationTemplate(); $notificationtarget = NotificationTarget::getInstance($item, $event, $options); if (!$notificationtarget) { return false; } $entity = $notificationtarget->getEntity(); //Foreach notification foreach (Notification::getNotificationsByEventAndType($event, $item->getType(), $entity) as $data) { $targets = getAllDatasFromTable('glpi_notificationtargets', 'notifications_id = ' . $data['id']); $notificationtarget->clearAddressesList(); //Process more infos (for example for tickets) $notificationtarget->addAdditionnalInfosForTarget(); $template->getFromDB($data['notificationtemplates_id']); $template->resetComputedTemplates(); //Set notification's signature (the one which corresponds to the entity) $template->setSignature(Notification::getMailingSignature($entity)); $notify_me = false; if (Session::isCron()) { // Cron notify me $notify_me = true; } else { // Not cron see my pref $notify_me = $_SESSION['glpinotification_to_myself']; } //Foreach notification targets foreach ($targets as $target) { //Get all users affected by this notification $notificationtarget->getAddressesByTarget($target, $options); foreach ($notificationtarget->getTargets() as $user_email => $users_infos) { if ($label || $notificationtarget->validateSendTo($event, $users_infos, $notify_me)) { //If the user have not yet been notified if (!isset($email_processed[$users_infos['language']][$users_infos['email']])) { //If ther user's language is the same as the template's one if (isset($email_notprocessed[$users_infos['language']][$users_infos['email']])) { unset($email_notprocessed[$users_infos['language']][$users_infos['email']]); } $options['item'] = $item; if ($tid = $template->getTemplateByLanguage($notificationtarget, $users_infos, $event, $options)) { //Send notification to the user if ($label == '') { $datas = $template->getDataToSend($notificationtarget, $tid, $users_infos, $options); $datas['_notificationtemplates_id'] = $data['notificationtemplates_id']; $datas['_itemtype'] = $item->getType(); $datas['_items_id'] = $item->getID(); $datas['_entities_id'] = $entity; Notification::send($datas); } else { $notificationtarget->getFromDB($target['id']); echo "<tr class='tab_bg_2'><td>" . $label . "</td>"; echo "<td>" . $notificationtarget->getNameID() . "</td>"; echo "<td>" . sprintf(__('%1$s (%2$s)'), $template->getName(), $users_infos['language']) . "</td>"; echo "<td>" . $users_infos['email'] . "</td>"; echo "</tr>"; } $email_processed[$users_infos['language']][$users_infos['email']] = $users_infos; } else { $email_notprocessed[$users_infos['language']][$users_infos['email']] = $users_infos; } } } } } } } unset($email_processed); unset($email_notprocessed); $template = null; return true; }
function sendUpdateNotification($activities = array()){ $notif = new Notification(); $params = $this->getNotificationParams($activities); if(!isset($params['project_ccs']) || empty($params['project_ccs'])) return TRUE; if($notif->getByName('ProjectUpdated') === FALSE){ $this->error = "SI_Project::update() : ".$notif->getLastError()."\n"; return FALSE; } if($notif->prepare($params) === FALSE){ $this->error = "SI_Project::update() : ".$notif->getLastError()."\n"; return FALSE; } if($notif->send() === FALSE){ $this->error = "SI_Project::update() : ".$notif->getLastError()."\n"; return FALSE; } return TRUE; }
<?php /* For licensing terms, see /license.txt */ /** * @package chamilo.notification * @author Julio Montoya <*****@*****.**> */ /** * Initialization */ if (PHP_SAPI != 'cli') { die('Run this script through the command line or comment this line in the code'); } $language_file = array('userInfo'); require_once '../inc/global.inc.php'; /** * Notification sending */ $notify = new Notification(); $notify->send();
/** * called by cli/cron.php */ function cron() { // If called by a regular cron job it's no problem to skip it sometimes. if (BN=="cron.php") { if (!cron_lock()) return; } else { while (!cron_lock()) { echo "Waiting for lock ...\n"; sleep(5); } } $sql_period = "SELECT *, debate <= now() AS debate_now, preparation <= now() AS preparation_now, voting <= now() AS voting_now, ballot_assignment <= now() AS ballot_assignment_now, ballot_preparation <= now() AS ballot_preparation_now, counting <= now() AS counting_now FROM period"; $result_period = DB::query($sql_period); while ( $period = DB::fetch_object($result_period, "Period") ) { /** @var Period $period */ DB::to_bool($period->debate_now); DB::to_bool($period->preparation_now); DB::to_bool($period->voting_now); DB::to_bool($period->ballot_assignment_now); DB::to_bool($period->ballot_preparation_now); DB::to_bool($period->counting_now); $issues_start_debate = array(); $issues_start_voting = array(); $issues_finished_voting = array(); // ballots switch ($period->state) { // ballot assignment case "ballot_application": if (!$period->ballot_assignment_now) break; $period->assign_members_to_ballots(); $sql_ballot = "SELECT * FROM ballot WHERE period=".intval($period->id); $result_ballot = DB::query($sql_ballot); while ( $ballot = DB::fetch_object($result_ballot, "Ballot") ) { // notification to the ballot agents whether the ballot was approved // TODO: more than one ballot agent $notification = new Notification("ballot_approved"); $notification->period = $period; $notification->ballot = $ballot; $sql = "SELECT member FROM offlinevoter WHERE ballot = ".intval($ballot->id)." AND agent = TRUE"; $recipients = DB::fetchfieldarray($sql); $notification->send($recipients); if (!$ballot->approved) continue; // notification to the members to which ballots they were assigned $notification = new Notification("ballot_assigned"); $notification->period = $period; $notification->ballot = $ballot; $sql = "SELECT member FROM offlinevoter WHERE ballot = ".intval($ballot->id); $recipients = DB::fetchfieldarray($sql); $notification->send($recipients); } $period->state = "ballot_assignment"; $period->update(["state"]); break; // ballot preparation case "ballot_assignment": if (!$period->ballot_preparation_now) break; // final upload of the complete postal and ballot voters if ( upload_voters($period, true) ) { $period->state = "ballot_preparation"; $period->update(["state"]); } // ballot_preparation is the final state. } // proposals and issues $sql_issue = "SELECT * FROM issue WHERE period=".intval($period->id)." AND state NOT IN ('finished', 'cancelled')"; $result_issue = DB::query($sql_issue); while ( $issue = DB::fetch_object($result_issue, "Issue") ) { /** @var Issue $issue */ switch ($issue->state) { // debate case "entry": if (!$period->debate_now) break; $all_proposals_revoked = true; $admitted_proposals = false; $not_admitted_proposals = false; foreach ( $issue->proposals() as $proposal ) { /** @var Proposal $proposal */ if ($proposal->state_cancelled()) continue; //if ( $proposal->check_proponents() ) { $all_proposals_revoked = false; if ($proposal->state=="admitted") $admitted_proposals = true; else $not_admitted_proposals = true; /*} else { // revoke proposals without proponents $proposal->state = "revoked"; $proposal->update(["state"]); }*/ } if ($all_proposals_revoked) { $issue->cancel(); break; } // None of the proposals are admitted yet. if (!$admitted_proposals) break; if ($not_admitted_proposals) { /* split issue $new_issue = new Issue; $new_issue->area = $issue->area; $new_issue->create(); foreach ( $issue->proposals() as $proposal ) { if ($proposal->state_cancelled()) continue; if ($proposal->state=="admitted") continue; $proposal->issue = $new_issue->id; $proposal->update(["issue"]); }*/ // cancel proposals foreach ( $issue->proposals() as $proposal ) { /** @var $proposal Proposal */ if ($proposal->state_cancelled()) continue; if ($proposal->state=="admitted") continue; $proposal->cancel("cancelled_debate"); } } $issue->state = "debate"; $issue->update(["state"], 'debate_started=now()'); $issues_start_debate[] = $issue; break; // preparation case "debate": if (!$period->preparation_now) break; // revoke proposals, which were scheduled for revokation revoke_before_preparation($issue); // don't proceed to preparation if all proposals were cancelled if ($issue->state == "cancelled") break; $issue->state = "preparation"; $issue->update(["state"], 'preparation_started=now()'); break; // voting case "preparation": if (!$period->voting_now) break; // collect issues for online voting start if ( !$issue->votingmode_offline() ) $issues_start_voting[] = $issue; // Issues which reached offline voting, stay in preparation state until an admin enters the voting result. break; // counting case "voting": if (!$period->counting_now) break; $issue->state = "counting"; $issue->update(["state"], 'counting_started=now()'); $issue->counting(); $issue->finish(); $issues_finished_voting[] = $issue; remove_inactive_participants($period->ngroup); break; // "finished" and "cancelled" are the final issue states. } } // debate start notifications if ($issues_start_debate) { $notification = new Notification("debate"); $notification->period = $period; $notification->issues = $issues_start_debate; $notification->send(); } // voting finished notifications if ($issues_finished_voting) { $notification = new Notification("finished"); $notification->period = $period; $notification->issues = $issues_finished_voting; $notification->send(); } // start voting and send individual notifications with tokens if ($issues_start_voting) $period->start_voting($issues_start_voting); } cron_unlock(); }
/** * move the proposal to a different issue * * @param integer $new_issue_id */ public function move_to_issue($new_issue_id) { DB::transaction_start(); $this->read(); if ( !$this->allowed_move_to_issue() ) { DB::transaction_rollback(); warning(_("Moving this proposal is not allowed anymore.")); redirect(); }; $options = $this->options_move_to_issue(); if (!isset($options[$new_issue_id])) { DB::transaction_rollback(); warning(_("The selected option is not available.")); redirect(); } $old_issue = $this->issue(); if ($new_issue_id) { $new_issue = new Issue($new_issue_id); if (!$new_issue->id) { DB::transaction_rollback(); warning(_("The issue does not exist.")); redirect(); } } else { // create a new empty issue $new_issue = new Issue; $new_issue->area = $old_issue->area; $new_issue->period = $old_issue->period; $new_issue->state = $old_issue->state; // If the old issue reached offline voting, the new issue gets offline voting unseen the number of offline voting demanders. $new_issue->votingmode_reached = $old_issue->votingmode_reached; $new_issue->debate_started = $old_issue->debate_started; $new_issue->create(); } $this->issue = $new_issue->id; if ( ! $this->update(['issue']) ) { DB::transaction_rollback(); return; } DB::transaction_commit(); // cancel empty issue if ( ! $old_issue->proposals() ) $old_issue->cancel(); // send notification $notification = new Notification("proposal_moved"); $notification->issue_old = $old_issue; $notification->issue = $new_issue; $notification->proposal = $this; // votingmode voters of both issues $sql = "SELECT DISTINCT member FROM votingmode_token WHERE issue=".intval($old_issue->id)." OR issue=".intval($new_issue->id); $recipients = DB::fetchfieldarray($sql); // supporters and proponents of the proposal $sql = "SELECT DISTINCT member FROM supporter WHERE proposal=".intval($this->id); $recipients = array_unique(array_merge($recipients, DB::fetchfieldarray($sql))); $notification->send($recipients); }
public function action_add_collaborator() { $project = Config::get('project'); $input = Input::json(); $email = $input->User->email; $user = User::where_email($email)->first(); if (!$user) { $user = User::new_officer_from_invite($email, Auth::user(), $project); if (!$user) { return Response::make('400', '400'); } $send_email = false; } else { $send_email = true; } if ($user->officer->collaborates_on($project->id)) { return Response::json(array("status" => "already exists")); } $project->officers()->attach($user->officer->id); Notification::send("ProjectCollaboratorAdded", array("project" => $project, "officer" => $user->officer, "actor_id" => Auth::user()->id), $send_email); return Response::json($user->officer->to_array()); }
public function award($message) { $this->awarded_at = new \DateTime(); $this->awarded_message = $message; $this->awarded_by = Auth::officer()->id; $this->save(); Notification::send("Award", array('actor_id' => Auth::user()->id, 'bid' => $this)); // Dismiss all the other bids. foreach ($this->project->bids as $bid) { if ($bid->id != $this->id && !$bid->dismissed_at) { $bid->dismiss(); } } if (trim($message) != "") { Mailer::send("BidAwarded", array('bid' => $this)); } }
/** * wrapper for create() * * @param Proposal $proposal */ function add(Proposal $proposal) { if (mb_strlen($this->title) > self::title_length) { $this->title = limitstr($this->title, self::title_length); warning(sprintf(_("The title has been truncated to the maximum allowed length of %d characters!"), self::title_length)); } if (mb_strlen($this->content) > self::content_length) { $this->content = limitstr($this->content, self::content_length); warning(sprintf(_("The content has been truncated to the maximum allowed length of %d characters!"), self::content_length)); } if (Login::$member) $this->member = Login::$member->id; $this->session = self::session_id(); $this->create(); // notification to authors of all parent comments $recipients = array(); $parent = $this->parent; while ( $parent > 0 ) { // "pro"/"contra"/"discussion" will be converted to 0 $comment = new Comment($parent); if ($comment->member) $recipients[] = $comment->member; $parent = $comment->parent; } $notification = new Notification("reply"); $notification->proposal = $proposal; $notification->comment = $this; $notification->send($recipients); // notification according to notify settings $notification = new Notification("comment"); $notification->proposal = $proposal; $notification->comment = $this; $notification->send([], $recipients); }
function sendEmail($notification = 'InvoiceEmail'){ $notif = new Notification(); $params = $this->getNotificationParams(); // if(!isset($params['invoice_emails']) || empty($params['invoice_emails'])) // return TRUE; if($notif->getByName($notification) === FALSE){ $this->error = "SI_Invoice::sendEmail() : ".$notif->getLastError()."\n"; return FALSE; } if($notif->prepare($params) === FALSE){ $this->error = "SI_Invoice::sendEmail() : ".$notif->getLastError()."\n"; return FALSE; } // Setup attachment $pdf_file = $this->getPDF(); if($pdf_file === FALSE) return FALSE; $my_company = SureInvoice::getMyCompany(); $filename = 'invoice_'.$this->id.'.pdf'; if(!empty($my_company->name)){ $normalized_name = str_replace(array(',','.',' ',"\t","'",'"'), '_', $my_company->name); $filename = $normalized_name.'_'.$this->id.'.pdf'; } $attachments[0]['data'] = $pdf_file; $attachments[0]['name'] = $filename; $attachments[0]['type'] = 'application/pdf'; $attachments[0]['encoding'] = 'base64'; if($notif->send($attachments) === FALSE){ $this->error = "SI_Invoice::sendEmail() : ".$notif->getLastError()."\n"; return FALSE; } // Update sent_ts $this->sent_ts = time(); if($this->update() === FALSE){ $this->error = "SI_Invoice::sendEmail(): Email sent, error updating sent timestamp: ".$this->getLastError(); return FALSE; } return TRUE; }
/** * will be called after a proposal gets admitted * * @param Proposal $admitted_proposal */ public function proposal_admitted(Proposal $admitted_proposal) { $admitted_proposals = array($admitted_proposal); // admit other proposals too, if they reached the quorum due to the now lower level foreach ( $this->proposals() as $proposal ) { /** @var $proposal Proposal */ if ($proposal->id==$admitted_proposal->id) continue; if ( $proposal->submitted and !$proposal->quorum_reached and $proposal->supporters >= $proposal->quorum_required() ) { // admit proposal $proposal->quorum_reached = true; $proposal->state = "admitted"; $proposal->update(["quorum_reached", "state"], "admitted=now()"); $admitted_proposals[] = $proposal; } } // send notification $notification = new Notification("admitted"); $notification->issue = $this; $notification->proposals = $admitted_proposals; $notification->send(); /* for now admins do the selection of the periods manually // The period has already been set by another proposal in the same issue. if ($this->period) return; // select the next period, which has not yet started $sql = "SELECT id FROM period WHERE ngroup=".intval($this->period()->ngroup)." AND debate > now() ORDER BY debate LIMIT 1"; $this->period = DB::fetchfield($sql); if ($this->period) { $this->update(["period"]); } else { // Error } */ }
public function __construct($action_type, $taken_by, $action_id, $notify_uid = null) { Notification::send($action_type, $taken_by, $action_id, $notify_uid); }
/** * Processes the request to update an existing user's details, including enabled/disabled status and activation status. * * Processes the request from the user update form, checking that: * 1. The target user's new email address, if specified, is not already in use; * 2. The logged-in user has the necessary permissions to update the posted field(s); * 3. We're not trying to disable the master account; * 4. The submitted data is valid. * This route requires authentication. * Request type: POST * @param int $user_id the id of the user to edit. * @see formUserEdit */ public function updateUser($user_id) { $post = $this->_app->request->post(); // Load the request schema $requestSchema = new \Fortress\RequestSchema($this->_app->config('schema.path') . "/forms/user-update.json"); // Get the alert message stream $ms = $this->_app->alerts; // Get the target user $target_user = User::find($user_id); // Get the target user's groups $groups = $target_user->getGroups(); /* // Access control for entire page if (!$this->_app->user->checkAccess('uri_update_user')){ $ms->addMessageTranslated("danger", "ACCESS_DENIED"); $this->_app->halt(403); } */ // Only the master account can edit the master account! if ($target_user->id == $this->_app->config('user_id_master') && $this->_app->user->id != $this->_app->config('user_id_master')) { $ms->addMessageTranslated("danger", "ACCESS_DENIED"); $this->_app->halt(403); } // Remove csrf_token unset($post['csrf_token']); // Set up Fortress to process the request $rf = new \Fortress\HTTPRequestFortress($ms, $requestSchema, $post); if (isset($post['passwordc'])) { unset($post['passwordc']); } // Check authorization for submitted fields, if the value has been changed foreach ($post as $name => $value) { if ($name == "groups" || isset($target_user->{$name}) && $post[$name] != $target_user->{$name}) { // Check authorization if (!$this->_app->user->checkAccess('update_account_setting', ['user' => $target_user, 'property' => $name])) { $ms->addMessageTranslated("danger", "ACCESS_DENIED"); $this->_app->halt(403); } } else { if (!isset($target_user->{$name})) { $ms->addMessageTranslated("danger", "NO_DATA"); $this->_app->halt(400); } } } // Check that we are not disabling the master account if ($target_user->id == $this->_app->config('user_id_master') && isset($post['flag_enabled']) && $post['flag_enabled'] == "0") { $ms->addMessageTranslated("danger", "ACCOUNT_DISABLE_MASTER"); $this->_app->halt(403); } // Check that the email address is not in use if (isset($post['email']) && $post['email'] != $target_user->email && UserLoader::exists($post['email'], 'email')) { $ms->addMessageTranslated("danger", "ACCOUNT_EMAIL_IN_USE", $post); $this->_app->halt(400); } // Sanitize $rf->sanitize(); // Validate, and halt on validation errors. if (!$rf->validate()) { $this->_app->halt(400); } // Remove passwordc $rf->removeFields(['passwordc']); // Get the filtered data $data = $rf->data(); // Update user groups if (isset($data['groups'])) { foreach ($data['groups'] as $group_id => $is_member) { if ($is_member == "1" && !isset($groups[$group_id])) { $target_user->addGroup($group_id); } else { if ($is_member == "0" && isset($groups[$group_id])) { $target_user->removeGroup($group_id); } } } unset($data['groups']); } // Hash password if (isset($data['password'])) { $data['password'] = Authentication::hashPassword($data['password']); } // Update the user and generate success messages foreach ($data as $name => $value) { if ($value != $target_user->{$name}) { $target_user->{$name} = $value; // Custom success messages (optional) if ($name == "flag_enabled") { if ($value == "1") { $ms->addMessageTranslated("success", "ACCOUNT_ENABLE_SUCCESSFUL", ["user_name" => $target_user->user_name]); } else { $ms->addMessageTranslated("success", "ACCOUNT_DISABLE_SUCCESSFUL", ["user_name" => $target_user->user_name]); } } if ($name == "flag_verified") { $ms->addMessageTranslated("success", "ACCOUNT_MANUALLY_ACTIVATED", ["user_name" => $target_user->user_name]); } } } // If we're generating a password reset, create the corresponding event and shoot off an email if (isset($data['flag_password_reset']) && $data['flag_password_reset'] == "1") { // Recheck auth if (!$this->_app->user->checkAccess('update_account_setting', ['user' => $target_user, 'property' => 'flag_password_reset'])) { $ms->addMessageTranslated("danger", "ACCESS_DENIED"); $this->_app->halt(403); } // New password reset event - bypass any rate limiting $target_user->newEventPasswordReset(); $target_user->save(); // Email the user asking to confirm this change password request $twig = $this->_app->view()->getEnvironment(); $template = $twig->loadTemplate("mail/password-reset.twig"); $notification = new Notification($template); $notification->fromWebsite(); // Automatically sets sender and reply-to $notification->addEmailRecipient($target_user->email, $target_user->display_name, ["user" => $target_user, "request_date" => date("Y-m-d H:i:s")]); try { $notification->send(); } catch (\Exception\phpmailerException $e) { $ms->addMessageTranslated("danger", "MAIL_ERROR"); error_log('Mailer Error: ' . $e->errorMessage()); $this->_app->halt(500); } $ms->addMessageTranslated("success", "FORGOTPASS_REQUEST_SENT", ["user_name" => $target_user->user_name]); } $ms->addMessageTranslated("success", "ACCOUNT_DETAILS_UPDATED", ["user_name" => $target_user->user_name]); $target_user->save(); }
/** * Processes a request to resend the activation email for a new user account. * * Processes the request from the resend activation email form, checking that: * 1. The provided username is associated with an existing user account; * 2. The provided email matches the user account; * 3. The user account is not already active; * 4. A request to resend the activation link wasn't already processed in the last X seconds (specified in site settings) * 5. The submitted data is valid. * This route is "public access". * Request type: POST * @todo Again, just like with password reset - do we really need to get the user's user_name to do this? */ public function resendActivation() { $data = $this->_app->request->post(); // Load the request schema $requestSchema = new \Fortress\RequestSchema($this->_app->config('schema.path') . "/forms/resend-activation.json"); // Get the alert message stream $ms = $this->_app->alerts; // Set up Fortress to validate the request $rf = new \Fortress\HTTPRequestFortress($ms, $requestSchema, $data); // Validate if (!$rf->validate()) { $this->_app->halt(400); } // Load the user, by username $user = User::where('user_name', $data['user_name'])->first(); // Check that the username exists if (!$user) { $ms->addMessageTranslated("danger", "ACCOUNT_INVALID_USERNAME"); $this->_app->halt(400); } // Check that the specified email is correct if (strtolower($user->email) != strtolower($data['email'])) { $ms->addMessageTranslated("danger", "ACCOUNT_USER_OR_EMAIL_INVALID"); $this->_app->halt(400); } // Check if user's account is already active if ($user->flag_verified == "1") { $ms->addMessageTranslated("danger", "ACCOUNT_ALREADY_ACTIVE"); $this->_app->halt(400); } // Get the most recent account verification request time $last_verification_request_time = $user->lastEventTime('verification_request'); $last_verification_request_time = $last_verification_request_time ? $last_verification_request_time : "0000-00-00 00:00:00"; // Check the time since the last activation request $current_time = new \DateTime("now"); $last_verification_request_datetime = new \DateTime($last_verification_request_time); $time_since_last_request = $current_time->getTimestamp() - $last_verification_request_datetime->getTimestamp(); // If an activation request has been sent too recently, they must wait if ($time_since_last_request < $this->_app->site->resend_activation_threshold || $time_since_last_request < 0) { $ms->addMessageTranslated("danger", "ACCOUNT_LINK_ALREADY_SENT", ["resend_activation_threshold" => $this->_app->site->resend_activation_threshold]); $this->_app->halt(429); // "Too many requests" code (http://tools.ietf.org/html/rfc6585#section-4) } // We're good to go - create a new verification request and send the email $user->newEventVerificationRequest(); // Email the user $twig = $this->_app->view()->getEnvironment(); $template = $twig->loadTemplate("mail/resend-activation.twig"); $notification = new Notification($template); $notification->fromWebsite(); // Automatically sets sender and reply-to $notification->addEmailRecipient($user->email, $user->display_name, ["user" => $user, "secret_token" => $user->secret_token]); try { $notification->send(); } catch (\phpmailerException $e) { $ms->addMessageTranslated("danger", "MAIL_ERROR"); error_log('Mailer Error: ' . $e->errorMessage()); $this->_app->halt(500); } $user->save(); $ms->addMessageTranslated("success", "ACCOUNT_NEW_ACTIVATION_SENT"); }
public function send_amendment_emails() { $open_bids = $this->open_bids()->get(); foreach ($open_bids as $bid) { $target_id = $bid->vendor->user_id; $actor_id = Auth::user()->id; $send_email = true; Notification::send("AnnounceAmendmentsToBidders", array("bid" => $bid, "target_id" => $target_id, "actor_id" => $actor_id), $send_email); } }