function emailCollaborators($new_ids, $node)
{
    $query = db_select('users', 'u')->condition('uid', $new_ids)->fields('u', array('name', 'mail'));
    $result = $query->execute();
    foreach ($result as $row) {
        $options = array('absolute' => TRUE);
        $jobPath = url('node/' . $node->nid, $options);
        $jobTitle = $node->title;
        global $user;
        $inviter = $user->name;
        $module = 'tap_job_invite';
        $key = 'key';
        $email = $row->mail;
        $language = language_default();
        $params = array();
        $from = NULL;
        $send = FALSE;
        $message = drupal_mail($module, $key, $email, $language, $params, $from, $send);
        $message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
        $message['subject'] = "Collaborator invitation at Tap";
        $message['body'] = array();
        $message['body'][] = "You have invited as a Collaborator by {$inviter} to the job <a href=\"{$jobPath}\">{$jobTitle}</a>. ";
        $message['body'][] = "Log in to join the workroom.";
        // Retrieve the responsible implementation for this message.
        $system = drupal_mail_system($module, $key);
        // Format the message body.
        $message = $system->format($message);
        // Send e-mail.
        $message['result'] = $system->mail($message);
    }
}
 /**
  * Override parent deliver() function.
  */
 public function deliver(array $output = array())
 {
     $plugin = $this->plugin;
     $message = $this->message;
     $options = $plugin['options'];
     $account = user_load($message->uid);
     $mail = !empty($options['mail']) ? $options['mail'] : $account->mail;
     $languages = language_list();
     if (!$options['language override']) {
         $lang = !empty($account->language) && $account->language != LANGUAGE_NONE ? $languages[$account->language] : language_default();
     } else {
         $lang = $languages[$message->language];
     }
     // The subject in an email can't be with HTML, so strip it.
     $output['message_notify_email_subject'] = strip_tags($output['message_notify_email_subject']);
     // Allow for overriding the 'from' of the message.
     $from = isset($options['from']) ? $options['from'] : NULL;
     $from_account = !empty($message->user->uid) ? user_load($message->user->uid) : $account;
     $mimemail_name = variable_get('mimemail_name', t('Atrium'));
     $from = array('name' => oa_core_realname($from_account) . ' (' . $mimemail_name . ')', 'mail' => is_array($from) ? $from['mail'] : $from);
     // Pass the message entity along to hook_drupal_mail().
     $output['message_entity'] = $message;
     if (!empty($message->email_attachments)) {
         $output['attachments'] = isset($output['attachments']) ? $output['attachments'] : array();
         $output['attachments'] = array_merge($message->email_attachments, $output['attachments']);
     }
     return drupal_mail('message_notify', $message->type, $mail, $lang, $output, $from);
 }
示例#3
0
 /**
  * Checks the From: and Reply-to: headers.
  */
 public function testFromAndReplyToHeader()
 {
     $language = \Drupal::languageManager()->getCurrentLanguage();
     // Use the state system collector mail backend.
     \Drupal::config('system.mail')->set('interface.default', 'test_mail_collector')->save();
     // Reset the state variable that holds sent messages.
     \Drupal::state()->set('system.test_mail_collector', array());
     // Send an email with a reply-to address specified.
     $from_email = 'Drupal <*****@*****.**>';
     $reply_email = '*****@*****.**';
     drupal_mail('simpletest', 'from_test', '*****@*****.**', $language, array(), $reply_email);
     // Test that the reply-to email is just the email and not the site name
     // and default sender email.
     $captured_emails = \Drupal::state()->get('system.test_mail_collector');
     $sent_message = end($captured_emails);
     $this->assertEqual($from_email, $sent_message['headers']['From'], 'Message is sent from the site email account.');
     $this->assertEqual($reply_email, $sent_message['headers']['Reply-to'], 'Message reply-to headers are set.');
     $this->assertFalse(isset($sent_message['headers']['Errors-To']), 'Errors-to header must not be set, it is deprecated.');
     // Send an email and check that the From-header contains the site name.
     drupal_mail('simpletest', 'from_test', '*****@*****.**', $language);
     $captured_emails = \Drupal::state()->get('system.test_mail_collector');
     $sent_message = end($captured_emails);
     $this->assertEqual($from_email, $sent_message['headers']['From'], 'Message is sent from the site email account.');
     $this->assertFalse(isset($sent_message['headers']['Reply-to']), 'Message reply-to is not set if not specified.');
     $this->assertFalse(isset($sent_message['headers']['Errors-To']), 'Errors-to header must not be set, it is deprecated.');
 }
示例#4
0
function deleteUserPage_submit($form, $form_state)
{
    global $user;
    $UID = $user->uid;
    $teams = dbGetTeamsForUser($UID);
    // getting teams that are associated with a user
    foreach ($teams as $team) {
        // looping through these teams
        dbKickUserFromTeam($UID, $team['TID']);
        // removing the user from these teams
        dbRemoveAllUserRoles($UID, $team['TID']);
        // ensuring the user doesn't have any role on the team
    }
    dbRemoveAllEmailsForUser($UID);
    dbDisableUser($UID);
    $params['feedback'] = stripTags($form_state['values']['misc'], '');
    // stripping any "illegal" HTML tags
    $params['userName'] = dbGetUserName($UID);
    // getting the user name
    drupal_mail('users', 'userdeleted', '*****@*****.**', variable_get('language_default'), $params, $from = null, $send = true);
    // sending the user a confirmation mail
    drupal_set_message("Your account has been deleted. We're sorry to see you go!");
    // message displayed and redirected to front page
    drupal_goto('<front>');
}
示例#5
0
 public function mailStatusUpdate($status, $attached)
 {
     $mail = $this->node->field_email[0]['value'];
     $v['subject'] = 'Ваше замечание обработано';
     $v['body'] = "Добрый день!\n\n";
     $v['body'] .= "Вы писали нам про ошибку в вопросе %1\$s. ";
     if ($status == 'resolved') {
         $v['body'] .= "Эта ошибка исправлена. В течение 24 часов изменения будут отображены.\n\n";
     } elseif ($status == 'accepted') {
         $v['body'] .= "Мы признаём эту ошибку. \n\n";
     } elseif ($status == 'rejected') {
         $v['body'] .= "\n\nНам кажется, что этой ошибки в вопросе нет (или ваше сообщение не было сообщением об ошибке).\n\n";
     }
     if ($attached) {
         $v['body'] .= 'Ваше замечание прикреплено к вопросу.' . "\n\n";
     }
     $v['body'] .= "Постоянный адрес вашего сообщения -- %2\$s.";
     if ($this->oldnode->comment_count) {
         $v['body'] .= " По этому адресу вы можете прочитать комментарии";
     }
     $v['body'] .= "\n\nСпасибо!\n\n-- \nРоман Семизаров\n";
     $q = $this->getQuestion();
     $v['body'] = sprintf($v['body'], $q->getAbsoluteQuestionUrl(), url('node/' . $this->node->nid, array('absolute' => TRUE)));
     drupal_mail('chgk_db', 'issue_status_updated', $mail, language_default(), $v);
 }
示例#6
0
function libya_cron_subscription_mail($data)
{
    // subscription node
    $mail = $data[0];
    $nids = $data[1];
    // watchdog('actions', 'Cron subscription vars', func_get_args());
    global $siteName, $isMail, $base_url;
    $isMail = TRUE;
    $body = '<h1 style="font-size:1.25em;">Your alert subscription results from ' . $siteName . '</h1>
	<p class="no-margin">The following results match your subscription alert.</p>';
    foreach ($nids as $nid) {
        $N = node_load($nid);
        $content = strip_tags($N->body['und'][0]['value']);
        if (strlen($content) > 200) {
            $content = substr($content, 0, 200);
        }
        $CL = strrpos($content, ' ');
        $content = substr($content, 0, $CL) . '...';
        $body .= '<h2 style="font-size:1.25em;">' . l($N->title, 'node/' . $N->nid, array('attributes' => array('style' => array('text-decoration' => 'none')))) . '</h2><p>' . $content . '</p>
		<p>' . t('read more: ') . l($base_url . '/' . drupal_lookup_path('alias', 'node/' . $N->nid), 'node/' . $N->nid, array('absolute' => TRUE)) . '</p>
		<hr/>';
    }
    $data['message'] = 'Mail sent';
    $to = $mail['mail'];
    $from = variable_get('site_mail', '*****@*****.**');
    $params = array('body' => $body, 'rand' => $mail['rand'], 'to' => $to);
    $sent = drupal_mail('libya', 'subscription_alert_mail', $to, language_default(), $params, $from, TRUE);
}
示例#7
0
/**
 * Sends the invitation.
 *
 * Called by the Invite::sendInvite() method.
 *
 * @param Invite $invite
 *   The invitation to send.
 */
function hook_invite_send($invite)
{
    if (!empty($invite->type_details()->invite_sending_controller['my_module'])) {
        global $language;
        $entity = entity_metadata_wrapper('invite', $invite);
        $params = array('invite' => $invite, 'wrapper' => $entity);
        $from = $entity->inviter->mail->value();
        drupal_mail('my_module', 'invite', $entity->invitee->mail->value(), $language, $params, $from, TRUE);
    }
}
示例#8
0
/**
 * Notify modules course credit was awarded.
 *
 * @param array $record
 *   The course credit awarded record, including 'ccaid' Course credit awarded
 *   ID from drupal_write_record().
 *
 * @see course_credit_award_save()
 */
function hook_course_credit_awarded_insert($record)
{
    // Example: send users an email when they are awarded credit.
    // TODO Convert "user_load" to "user_load_multiple" if "$record['uid']" is other than a uid.
    // To return a single user object, wrap "user_load_multiple" with "array_shift" or equivalent.
    // Example: array_shift(user_load_multiple(array(), $record['uid']))
    $params['account'] = $account = user_load($record['uid']);
    $params['record'] = $record;
    $params['subject'] = t("You've got new credit");
    drupal_mail('my_module', 'credit_awarded', $account->mail, user_preferred_language($account), $params);
}
示例#9
0
function rejectTeam($TID)
{
    dbRejectTeam($TID);
    $UID = dbGetOwnerForTeam($TID);
    drupal_mail('adminFunctions', 'teamRejected', dbGetUserPrimaryEmail($UID), variable_get('language_default'), $params = array('teamName' => dbGetTeamName($TID), 'fullName' => dbGetUserName($UID)), $from = NULL, $send = TRUE);
    drupal_set_message('The team has been rejected and the team owner has been notified!');
    if (isset($_SERVER['HTTP_REFERER'])) {
        drupal_goto($_SERVER['HTTP_REFERER']);
    } else {
        drupal_goto('adminPage');
    }
}
示例#10
0
function os_poker_report_abuse_form_submit($form, &$form_state)
{
    $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
    if ($op == t('Send')) {
        $to = variable_get('os_poker_abuse_mail_to', 1);
        if (is_numeric($to)) {
            $to = user_load($to)->mail;
        }
        $account = $form['#reporter'];
        $from = ($account->profile_nickname ? $account->profile_nickname : $account->name) . '<' . $account->mail . '>';
        $params = array('reason' => $form['reason']['#options'][reset(array_filter($form_state['values']['reason']))], 'details' => $form_state['values']['details'], 'reporter' => $form['#reporter'], 'reported' => $form['#reported']);
        drupal_mail('os_poker', 'abuse', $to, user_preferred_language($account), $params, $from);
        drupal_set_message(t('Your message has been sent.'));
    }
}
示例#11
0
/**
 * It delivers all the notification messages and empties the queue
 *
 * @param $send
 *   If FALSE, the messages won't be sent nor removed from the queue
 *
 * @return
 *   Message sent or to be sent, HTML formatted
 */
function guifi_notify_send($send = TRUE)
{
    global $user;
    $destinations = array();
    $messages = array();
    // Get all the queue to be processesed, grouping to every single destination
    $qt = db_query("\n    SELECT *\n    FROM {guifi_notify}");
    while ($message = db_fetch_array($qt)) {
        $messages[$message['id']] = $message;
        foreach (unserialize($message['to_array']) as $dest) {
            $destinations[$dest][] = $message['id'];
        }
    }
    // For every destination, construct a single mail with all messages
    $errors = FALSE;
    $output = '';
    foreach ($destinations as $to => $msgs) {
        $body = str_repeat('-', 72) . "\n\n" . t('Complete trace messages (for trace purposes, to be used by developers)') . "\n" . str_repeat('-', 72) . "\n";
        $subjects = t('Summary of changes:') . "\n" . str_repeat('-', 72) . "\n";
        foreach ($msgs as $msg_id) {
            $subjects .= format_date($messages[$msg_id]['timestamp'], 'small') . ' ** ' . $messages[$msg_id]['who_name'] . ' ' . $messages[$msg_id]['subject'] . "\n";
            $body .= format_date($messages[$msg_id]['timestamp'], 'small') . ' ** ' . $messages[$msg_id]['who_name'] . ' ' . $messages[$msg_id]['subject'] . "\n" . $messages[$msg_id]['body'] . "\n" . str_repeat('-', 72) . "\n";
        }
        $subject = t('[guifi.net notify] Report of changes at !date', array('!date' => format_date(time(), 'small')));
        $output .= '<h2>' . t('Sending a mail to: %to', array('%to' => $to)) . '</h2>';
        $output .= '<h3>' . $subject . '</h3>';
        $output .= '<pre><small>' . $subjects . $body . '</small></pre>';
        $params['mail']['subject'] = $subject;
        $params['mail']['body'] = $subjects . $body;
        $return = FALSE;
        if ($send) {
            $return = drupal_mail('guifi_notify', 'notify', $to, user_preferred_language($user), $params, variable_get('guifi_contact', $user->mail));
            guifi_log(GUIFILOG_TRACE, 'return code for email sent:', $return);
        }
        if ($return['result']) {
            watchdog('guifi', 'Report of changes sent to %name', array('%name' => $to));
        } else {
            watchdog('guifi', 'Unable to notify %name', array('%name' => $to), WATCHDOG_ERROR);
            $errors = TRUE;
        }
    }
    // delete messages
    if (!$errors and $send) {
        db_query("DELETE FROM {guifi_notify}\n       WHERE id in (" . implode(',', array_keys($messages)) . ")");
    }
    return $output;
}
 public function deliver(array $output = array())
 {
     $plugin = $this->plugin;
     $message = $this->message;
     $options = $plugin['options'];
     $account = user_load($message->uid);
     $mail = $options['mail'] ? $options['mail'] : $account->mail;
     $languages = language_list();
     if (!$options['language override']) {
         $lang = !empty($account->language) && $account->language != LANGUAGE_NONE ? $languages[$account->language] : language_default();
     } else {
         $lang = $languages[$message->language];
     }
     // The subject in an email can't be with HTML, so strip it.
     $output['message_notify_email_subject'] = strip_tags($output['message_notify_email_subject']);
     // Pass the message entity along to hook_drupal_mail().
     $output['message_entity'] = $message;
     return drupal_mail('message_notify', $message->type, $mail, $lang, $output);
 }
示例#13
0
function deleteTeamPage_submit($form, $form_state)
{
    global $user;
    $UID = $user->uid;
    $TID = $form_state['TID'];
    if (dbUserHasPermissionForTeam($user->uid, 'deleteTeam', $TID)) {
        dbDeactivateTeam($TID);
        dbKickAllUsersFromTeam($TID);
        dbRemoveAllRolesFromTeam($TID);
    } else {
        drupal_set_message('You do not have permission to perform this action.', 'error');
        return;
    }
    // send an email to the CROMA team detailing the team deletion
    $params['feedback'] = stripTags($form_state['values']['misc'], '');
    $params['userName'] = dbGetUserName($UID);
    $params['teamName'] = dbGetTeamName($TID);
    $params['teamNumber'] = dbGetTeamNumber($TID);
    drupal_mail('teams', 'teamDeleted', '*****@*****.**', variable_get('language_default'), $params, $from = NULL, $send = TRUE);
    drupal_set_message(dbGetTeamName($TID) . " has been deleted.");
    drupal_goto('<front>');
}
示例#14
0
 /**
  * {@inheritdoc}
  */
 public function execute($entity = NULL)
 {
     if (empty($this->configuration['node'])) {
         $this->configuration['node'] = $entity;
     }
     $recipient = $this->token->replace($this->configuration['recipient'], $this->configuration);
     // If the recipient is a registered user with a language preference, use
     // the recipient's preferred language. Otherwise, use the system default
     // language.
     $recipient_accounts = $this->storage->loadByProperties(array('mail' => $recipient));
     $recipient_account = reset($recipient_accounts);
     if ($recipient_account) {
         $langcode = $recipient_account->getPreferredLangcode();
     } else {
         $langcode = language_default()->id;
     }
     $params = array('context' => $this->configuration);
     if (drupal_mail('system', 'action_send_email', $recipient, $langcode, $params)) {
         watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient));
     } else {
         watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient));
     }
 }
/**
 * Script to send notification emails
 */
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
//_drush_bootstrap_drupal_full();
try {
    $completedJobRequests = QueueUtil::getPendingEmailsInfo();
    LogHelper::log_debug($completedJobRequests);
} catch (Exception $claimException) {
    LogHelper::log_debug("{$logId}: Error while fetching job from queue: " . $claimException);
    return;
}
foreach ($completedJobRequests as $request) {
    LogHelper::log_info($request);
    try {
        global $conf;
        $dir = variable_get('file_public_path', 'sites/default/files') . '/' . $conf['check_book']['data_feeds']['output_file_dir'];
        $file = $dir . '/' . $request['filename'];
        $params = array("download_url" => $file, "download_url_compressed" => $file . '.zip', "expiration_date" => date('d-M-Y', $request['end_time'] + 3600 * 24 * 7), "contact_email" => $request['contact_email'], "tracking_num" => $request['token']);
        LogHelper::log_debug($params);
        $response = drupal_mail('checkbook_datafeeds', "download_notification", $request['contact_email'], null, $params);
        LogHelper::log_debug($response);
        if ($response['result']) {
            QueueUtil::updateJobRequestEmailStatus($request['rid']);
        }
    } catch (Exception $claimException) {
        LogHelper::log_debug("Error while Sending Email Notification: " . $claimException . $params);
        return;
    }
}
示例#16
0
function os_poker_buddies_page($action = NULL, $page = 0)
{
    $output = "<div id='buddies-tabs' class='tabs-window'>" . theme('buddies_tabs', $action);
    switch ($action) {
        case "search":
            $lsr = NULL;
            if (isset($_REQUEST["form_id"]) && $_REQUEST["form_id"] == "os_poker_buddy_search_form") {
                /*$offset = 0;
                				$limit = NULL;
                
                				if (isset($_REQUEST["page"]))
                				{
                					$page = $_REQUEST["page"];
                					$offset = $page * $limit;
                				}*/
                if ($_REQUEST['profile_country'] == '00') {
                    unset($_REQUEST['profile_country']);
                }
                $lsr = CUserManager::instance()->SearchUsers($_REQUEST);
            }
            if ($lsr !== NULL) {
                // TODO : remonter la gestion des pages au niveau de CUserManager (fait dans la template temporairement)
                $output .= theme('buddies_list', CUserManager::instance()->UserList($lsr), CUserManager::instance()->CurrentUser(), $action, $page);
            } else {
                $output .= theme('buddies_search', drupal_get_form('os_poker_buddy_search_form'), CUserManager::instance()->CurrentUser());
            }
            break;
        case "invitefb":
            $block = module_invoke('fb_friend', 'block', 'view', FB_FRIEND_DELTA_INVITE_APP);
            $block = str_replace('<fb:multi-friend-selector', '<fb:multi-friend-selector rows="3" cols="4"', $block['content']);
            $block = str_replace('<fb:serverfbml', '<fb:serverfbml width="615" height="420"', $block);
            $output .= $block;
            break;
        case "inviteos":
            $block = module_invoke('os_integration', 'block', 'view', 0);
            $output .= $block['content'];
            break;
        case "invite":
            $output .= theme('buddies_invite', drupal_get_form('os_poker_buddies_invite_form'), CUserManager::instance()->CurrentUser());
            break;
        case "invitedlist":
            $cuser = CUserManager::instance()->CurrentUser();
            if (isset($_POST["invite_action"]) && !empty($_POST["invite_target"])) {
                if ($_POST["invite_action"] == "remind") {
                    $sql = "SELECT * FROM `{invite}` WHERE `email` = '%s' AND `uid` = %d AND `expiry` < %s LIMIT 1";
                    $time = time() * 2;
                    $res = db_query($sql, $_POST["invite_target"], $cuser->uid, $time);
                    if ($res != FALSE) {
                        $inv = db_fetch_object($res);
                        if ($inv != FALSE) {
                            require_once drupal_get_path('module', 'invite') . "/invite.module";
                            global $language;
                            if (!variable_get('invite_use_users_email', 0)) {
                                $from = variable_get('invite_manual_from', '');
                            } else {
                                if ($user->uid) {
                                    $from = $cuser->mail;
                                }
                            }
                            if (!$from) {
                                // Never pass an empty string to drupal_mail()
                                $from = NULL;
                            }
                            $invite = _invite_substitutions(array('email' => $_POST["invite_target"], 'code' => $inv->reg_code, 'resent' => TRUE, 'data' => array('subject' => invite_get_subject(), 'message' => NULL)));
                            // Send e-mail.
                            $params = array('invite' => $invite);
                            $message = drupal_mail('invite', 'invite', $_POST["invite_target"], $language, $params, $from, TRUE);
                            drupal_set_message(t("Invitation resent to !email", array("!email" => $_POST["invite_target"])));
                        } else {
                            drupal_set_message(t("Invitation must have expired to be resent."), 'error');
                        }
                    }
                } else {
                    if ($_POST["invite_action"] == "delete") {
                        $sql = "DELETE FROM `{invite}` WHERE `email` = '%s' AND `uid` = %d";
                        $res = db_query($sql, $_POST["invite_target"], $cuser->uid);
                        if ($res) {
                            drupal_set_message(t("Your invite has been deleted."));
                        }
                    }
                }
            }
            $output .= theme('buddies_invitedlist', $cuser);
            break;
        default:
            $output .= theme('buddies_list', CUserManager::instance()->CurrentUser()->Buddies(TRUE), CUserManager::instance()->CurrentUser());
            break;
    }
    return $output . "</div>";
}
 public function notify(MaestroNotification &$obj)
 {
     //now, we're offloading the notification to this class to do whatever it needs to do.
     $from = variable_get('site_mail', '*****@*****.**');
     $send = TRUE;
     if (is_array($obj->getUserIDs())) {
         foreach ($obj->getUserIDs() as $userID) {
             $to = $obj->getUserEmailAddresses($userID);
             $params = array('message' => $obj->getMessage(), 'subject' => $obj->getSubject(), 'queueID' => $obj->getQueueId());
             $result = drupal_mail('maestro', $obj->getNotificationType(), $to, language_default(), $params, $from, $send);
         }
     }
 }
	/*		$body = array(
			'to' => $val,
			'subject' => t($subject),
			'body' => t($message),
			'headers' => $headers
			);*/
			
			$body = array(
			'to' => $val,
			'subject' => t($subject),
			'message' => t($message),
			'headers' => $headers
			);
		 
			 //drupal_mail_send($body); // calling drupal mail function
			   $message = drupal_mail('tellafriend_node', 'taf', $val, language_default(), $body,  $from, $send = TRUE);
		
	}
	drupal_set_message('Invitation sent successfully.');

  }
  



		$urlexp1 = arg(1);
		if(strpos($urlexp1,'?'))
		{
		  $urlexp1_exp = explode("?",$urlexp1);
		  $urlexp = $urlexp1_exp[0];
		}
示例#19
0
 /**
  * {@inheritdoc}
  */
 public function save(array $form, array &$form_state)
 {
     $user = $this->currentUser();
     $language_interface = $this->languageManager->getCurrentLanguage();
     $message = $this->entity;
     $sender = clone $this->entityManager->getStorage('user')->load($user->id());
     if ($user->isAnonymous()) {
         // At this point, $sender contains an anonymous user, so we need to take
         // over the submitted form values.
         $sender->name = $message->getSenderName();
         $sender->mail = $message->getSenderMail();
         // Save the anonymous user information to a cookie for reuse.
         // @todo remove when https://www.drupal.org/node/749748 is in.
         user_cookie_save(array('name' => $message->getSenderName(), 'mail' => $message->getSenderMail()));
         // For the email message, clarify that the sender name is not verified; it
         // could potentially clash with a username on this site.
         $sender->name = $this->t('!name (not verified)', array('!name' => $message->getSenderName()));
     }
     // Build email parameters.
     $params['contact_message'] = $message;
     $params['sender'] = $sender;
     if (!$message->isPersonal()) {
         // Send to the category recipient(s), using the site's default language.
         $category = $message->getCategory();
         $params['contact_category'] = $category;
         $to = implode(', ', $category->recipients);
         $recipient_langcode = $this->languageManager->getDefaultLanguage()->getId();
     } elseif ($recipient = $message->getPersonalRecipient()) {
         // Send to the user in the user's preferred language.
         $to = $recipient->getEmail();
         $recipient_langcode = $recipient->getPreferredLangcode();
         $params['recipient'] = $recipient;
     } else {
         throw new \RuntimeException($this->t('Unable to determine message recipient.'));
     }
     // Send email to the recipient(s).
     $key_prefix = $message->isPersonal() ? 'user' : 'page';
     drupal_mail('contact', $key_prefix . '_mail', $to, $recipient_langcode, $params, $sender->getEmail());
     // If requested, send a copy to the user, using the current language.
     if ($message->copySender()) {
         drupal_mail('contact', $key_prefix . '_copy', $sender->getEmail(), $language_interface->id, $params, $sender->getEmail());
     }
     // If configured, send an auto-reply, using the current language.
     if (!$message->isPersonal() && $category->reply) {
         // User contact forms do not support an auto-reply message, so this
         // message always originates from the site.
         drupal_mail('contact', 'page_autoreply', $sender->getEmail(), $language_interface->id, $params);
     }
     $this->flood->register('contact', $this->config('contact.settings')->get('flood.interval'));
     if (!$message->isPersonal()) {
         watchdog('contact', '%sender-name (@sender-from) sent an email regarding %category.', array('%sender-name' => $sender->getUsername(), '@sender-from' => $sender->getEmail(), '%category' => $category->label()));
     } else {
         watchdog('contact', '%sender-name (@sender-from) sent %recipient-name an email.', array('%sender-name' => $sender->getUsername(), '@sender-from' => $sender->getEmail(), '%recipient-name' => $message->getPersonalRecipient()->getUsername()));
     }
     drupal_set_message($this->t('Your message has been sent.'));
     // To avoid false error messages caused by flood control, redirect away from
     // the contact form; either to the contacted user account or the front page.
     if ($message->isPersonal() && $user->hasPermission('access user profiles')) {
         $form_state['redirect_route'] = $message->getPersonalRecipient()->urlInfo();
     } else {
         $form_state['redirect_route']['route_name'] = '<front>';
     }
     // Save the message. In core this is a no-op but should contrib wish to
     // implement message storage, this will make the task of swapping in a real
     // storage controller straight-forward.
     $message->save();
 }
示例#20
0
/**
 * submit hook for {@link approve_grades_hod_form()}
 *
 * <p>Relevant CA & Exam locked fields become 2.</p>
 * <p>If this is a CA approval, set the student visible CA scores to the values set by the lecturer.</p>
 * <p>Create an Approval Record.</p>
 * <p>Send e-mails to those that need to be notified.</p>
 * <p>Send e-mails to Students for CA only.</p>
 * @uses findcourseparameters()
 */
function approve_grades_hod_form_submit($form, &$form_state)
{
    global $user;
    global $base_url;
    $fieldtoapprovehoda = $form_state['values']['fieldtoapprovehoda'];
    $comment = $form_state['values']['comment'];
    $course_url = $form_state['values']['course_url'];
    $hod_uid = $form_state['values']['hod_uid'];
    $dean_uid = $form_state['values']['dean_uid'];
    $coursecode = $form_state['values']['coursecode'];
    $session = $form_state['values']['session'];
    $semester = $form_state['values']['semester'];
    $location = $form_state['values']['location'];
    $number_of_ca = $form_state['values']['number_of_ca'];
    $ca_approved_onebyone = $form_state['values']['ca_approved_onebyone'];
    $gradestexthoda = $form_state['values']['gradestexthoda'];
    $srcfield = $form_state['values']['srcfield'];
    $destfield = $form_state['values']['destfield'];
    if ($semester === 'All') {
        $semesterwhere = '';
    } else {
        $semesterwhere = 'AND ci.field_semester_name_value=' . (int) $semester;
    }
    if ($location === 'All') {
        $locationwhere = '';
    } else {
        $locationwhere = 'AND ci.field_location_value=' . (int) $location;
    }
    // Don't allow an exam score approved by the VC to be changed
    if ($fieldtoapprovehoda === 'field_examscorelocked_value') {
        $protectVC = 'AND sg.field_examscorelocked_value < 5';
    } else {
        $protectVC = '';
    }
    if ($ca_approved_onebyone) {
        $setstatement = "SET sg.`{$fieldtoapprovehoda}`='2'";
    } else {
        // Approve CAs along with exam
        $setstatement = "SET\n      sg.`field_ca1locked_value`='2',\n      sg.`field_ca2locked_value`='2',\n      sg.`field_ca3locked_value`='2',\n      sg.`field_ca4locked_value`='2',\n      sg.`field_examscorelocked_value`='2'";
    }
    $sql = "UPDATE {content_type_student_grades} sg, {content_type_course_instance} ci, {content_type_course} c\n    {$setstatement}\n    WHERE\n      sg.field_course_instance_nid=ci.nid AND\n      sg.field_dropped_value=0 AND\n      ci.field_course_id_nid=c.nid AND\n      ci.field_sess_name_value='%s' {$semesterwhere} {$locationwhere} AND\n      c.field_code_value='%s'\n      {$protectVC}";
    db_query($sql, $session, $coursecode);
    cache_clear_all('content:', content_cache_tablename(), TRUE);
    if ($srcfield != 'NONE') {
        // Make the CAs visible to students
        $setstatement = "SET sg.`{$destfield}`=sg.`{$srcfield}`";
        $sql = "UPDATE {content_type_student_grades} sg, {content_type_course_instance} ci, {content_type_course} c\n      {$setstatement}\n      WHERE\n        sg.field_course_instance_nid=ci.nid AND\n        sg.field_dropped_value=0 AND\n        ci.field_course_id_nid=c.nid AND\n        ci.field_sess_name_value='%s' {$semesterwhere} {$locationwhere} AND\n        c.field_code_value='%s'";
        db_query($sql, $session, $coursecode);
        cache_clear_all('content:', content_cache_tablename(), TRUE);
    }
    list($level, $sem, $loc, $department, $college) = findcourseparameters($coursecode, $session, $semesterwhere, $locationwhere);
    $user_profile = new UserProfile($user->uid);
    $name = '';
    if (!empty($user_profile->profile_first_name) && !empty($user_profile->profile_last_name)) {
        $middle = '';
        if (!empty($user_profile->profile_middle_name)) {
            $middle = $user_profile->profile_middle_name . ' ';
        }
        $name = "{$user_profile->profile_first_name} {$middle}{$user_profile->profile_last_name}";
    }
    $firsttime = TRUE;
    // Determine who gets notified when HOD (or equiv) submits Grade approval form
    $inroles = "'Dean of Faculty', 'Faculty Grade Editor', 'Faculty Examination Officer', 'University Grade Editor'";
    $sql = "SELECT\n      d.field_college_id_nid AS college_id,\n      c.field_department_nid_nid AS department_id\n    FROM {content_type_department} d, {content_type_course} c\n    WHERE\n      d.nid=c.field_department_nid_nid AND\n      c.field_code_value='%s'";
    $staffresult = db_query($sql, $coursecode);
    $staff = db_fetch_object($staffresult);
    $sql = "SELECT DISTINCT uid AS dean_uid\n    FROM {eduerp_roles}\n    WHERE (department_id=%d OR college_id=%d OR (department_id=0 AND college_id=0)) AND role IN ({$inroles})";
    $hodresult = db_query($sql, $staff->department_id, $staff->college_id);
    while ($hod = db_fetch_object($hodresult)) {
        if (!empty($hod->dean_uid)) {
            $destination_user = user_load($hod->dean_uid);
            $user_profile = new UserProfile($hod->dean_uid);
        } else {
            $destination_user = NULL;
            $user_profile = NULL;
        }
        $subject = "{$gradestexthoda} for {$coursecode} Approved by {$name}";
        $body = '';
        if (!empty($user_profile->profile_first_name) && !empty($user_profile->profile_last_name)) {
            $middle = '';
            if (!empty($user_profile->profile_middle_name)) {
                $middle = $user_profile->profile_middle_name . ' ';
            }
            $body .= "Dear {$user_profile->profile_first_name} {$middle}{$user_profile->profile_last_name},\n\n";
        }
        $body .= "I have approved {$gradestexthoda} for {$coursecode}\n\n";
        $body .= "URL: {$course_url}\n";
        $body .= "Department: {$department}\n";
        $body .= "Faculty: {$college}\n";
        $body .= "Level: {$level}\n";
        $body .= "Session: {$session}\n";
        $body .= "Semester: {$sem}\n";
        $body .= "Location: {$loc}\n\n";
        $body .= "HOD's comment...\n";
        $body .= str_replace('<br />', "\n", $comment);
        $body .= "\n\n{$name}\n\n";
        if ($firsttime) {
            $node = new stdClass();
            $node->type = 'approval';
            $node->uid = 1;
            $node->status = 0;
            $node->promote = 0;
            $node->sticky = 0;
            $node->comment = 0;
            $node->title = $subject;
            $node->body = $comment;
            $node->field_url[0]['value'] = $course_url;
            $node->field_approver[0]['uid'] = $user->uid;
            $node->field_destination[0]['value'] = $dean_uid;
            $node->field_coursecode[0]['value'] = $coursecode;
            $node->field_programme[0]['value'] = '';
            $node->field_department1[0]['value'] = $department;
            $node->field_college1[0]['value'] = $college;
            $node->field_level1[0]['value'] = $level;
            $node->field_session1[0]['value'] = $session;
            $node->field_semester1[0]['value'] = $sem;
            $node->field_location1[0]['value'] = $loc;
            $node->field_what_approved[0]['value'] = $gradestexthoda;
            $node->field_action[0]['value'] = 'Approved by HOD';
            node_save($node);
            $firsttime = FALSE;
        }
        if (!empty($destination_user)) {
            $message = drupal_mail('grading', 'approval', $destination_user->mail, language_default(), array(), $user->mail, FALSE);
            $message['subject'] = $subject;
            $message['body'] = $body;
            drupal_mail_send($message);
        }
    }
    // Send e-mails to Students for CA only
    if ($srcfield != 'NONE') {
        $sql = "SELECT sg.field_mat_no_uid FROM {content_type_student_grades} sg, {content_type_course_instance} ci, {content_type_course} c\n      WHERE\n        sg.field_course_instance_nid=ci.nid AND\n        sg.field_dropped_value=0 AND\n        ci.field_course_id_nid=c.nid AND\n        ci.field_sess_name_value='%s' {$semesterwhere} {$locationwhere} AND\n        c.field_code_value='%s'";
        $studentresult = db_query($sql, $session, $coursecode);
        while ($student = db_fetch_object($studentresult)) {
            $student_uid = $student->field_mat_no_uid;
            $destination_user = user_load($student_uid);
            $user_profile = new UserProfile($student_uid);
            $subject = "{$gradestexthoda} for {$coursecode} Approved by {$name}";
            $body = '';
            if (!empty($user_profile->profile_first_name) && !empty($user_profile->profile_last_name)) {
                $middle = '';
                if (!empty($user_profile->profile_middle_name)) {
                    $middle = $user_profile->profile_middle_name . ' ';
                }
                $body .= "Dear {$user_profile->profile_first_name} {$middle}{$user_profile->profile_last_name},\n\n";
            }
            $body .= "I have approved {$gradestexthoda} for {$coursecode}\n\n";
            $body .= "To view your grades go to {$base_url}/student\n";
            $body .= "You will have to login first.\n\n";
            $body .= "{$name}\n";
            $message = drupal_mail('grading', 'notifystudent', $destination_user->mail, language_default(), array(), $user->mail, FALSE);
            $message['subject'] = $subject;
            $message['body'] = $body;
            drupal_mail_send($message);
            db_query("INSERT INTO cron_notification (approver_uid, student_uid, gradestext, programme, instruction) VALUES (%d, %d, '%s', '%s', %d)", $user->uid, $student_uid, $gradestexthoda, $coursecode, 1);
        }
    }
    drupal_set_message('Approval successfull');
}
示例#21
0
function createNewUser($form_state)
{
    //This will generate a random password, you could set your own here
    $password = user_password(8);
    $userName = $form_state['values']['firstName'] . ' ' . $form_state['values']['lastName'];
    //set up the user fields
    $fields = array('name' => $form_state['values']['primaryEmail'], 'mail' => $form_state['values']['primaryEmail'], 'pass' => $password, 'status' => 1, 'init' => 'email address', 'roles' => array(DRUPAL_AUTHENTICATED_RID => 'authenticated user'));
    //the first parameter is left blank so a new user is created
    $account = user_save('', $fields);
    // Manually set the password so it appears in the e-mail.
    $account->password = $fields['pass'];
    // Send the e-mail through the user module.
    $params['url'] = user_pass_reset_url($account);
    $params['teamName'] = dbGetTeamName($form_state['TID']);
    drupal_mail('users', 'userCreated', $form_state['values']['primaryEmail'], NULL, $params, '*****@*****.**');
    $fields = array('firstName', 'lastName');
    $profileData = getFields($fields, $form_state['values']);
    $profileData = stripTags($profileData, '');
    $profileData['UID'] = $account->uid;
    dbCreateProfile($profileData);
    // creating new profile
    return $profileData['UID'];
}
示例#22
0
/**
 * Send out notifications to all users that have subscribed to this file or file category
 * Will check user preferences for notification if Messenger Plugin is installed
 * @param        string      $id        Key used to retrieve details depending on message type
 * @param        string      $type      Message type ->
 *                                       (1) FILEDEPOT_NOTIFY_NEWFILE,
 *                                       (2) FILEDEPOT_NOTIFY_APPROVED,
 *                                       (3) FILEDEPOT_NOTIFY_REJECT,
 *                                       (4) FILEDEPOT_NOTIFY_ADMIN
 * @return       Boolean     Returns TRUE if atleast 1 message was sent out
 */
function filedepot_sendNotification($id, $type = 1)
{
    global $user;
    /* If notifications have been disabled via the module admin settings - return TRUE */
    if (variable_get('filedepot_notifications_enabled', 1) == 0) {
        return TRUE;
    }
    if (intval($id) > 0) {
        $target_users = filedepot_build_notification_distribution($id, $type);
        if (count($target_users) > 0) {
            $values = array('fid' => $id, 'target_users' => $target_users);
            drupal_mail('filedepot', $type, $user, language_default(), $values);
        } else {
            watchdog('filedepot', "filedepot_sendNotification (@type) - no target users", array("@type" => $type));
        }
    }
}
<p>Telefon: $tovholder_contact</p>
<br/>
<p>God fornøjelse på cykelstien!</p>
EOD;

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <*****@*****.**>' . "\r\n";

$to = $email;
$subject = $mail_subject;
$txt = $mail_body;
$params = array('body' => $txt, 'subject' => $subject, 'headers'=> $headers);
if(isset($to) && ($to != '')){
drupal_mail('cyklingudenalder', 'send_email', $to, language_default(), $params, '*****@*****.**', TRUE);
}


}

global $user;

if (in_array('aktivitetsmedarbejder', $user->roles)) {
$taluid = "";
$view = views_get_view('sendtogodkendtbruger');
$view->set_display('default');
$view->pre_execute();
$view->execute('default');
foreach ($view->result as $result) {
$taluid .= $result->uid . ",";
示例#24
0
/**
 * Allow modules to take action when a stock level is changed.
 *
 * @param $sku
 *   The SKU whose stock level is being changed.
 * @param $stock
 *   The stock level before the adjustment.
 * @param $qty
 *   The amount by which the stock level was changed.
 */
function hook_uc_stock_adjusted($sku, $stock, $qty)
{
    $params = array('sku' => $sku, 'stock' => $stock, 'qty' => $qty);
    drupal_mail('uc_stock_notify', 'stock-adjusted', uc_store_email_from(), language_default(), $params);
}
示例#25
0
function guifi_user_reset_password($edit)
{
    global $user;
    if (is_numeric($edit)) {
        $edit = guifi_user_load($edit);
    } else {
        $edit = guifi_user_load($edit['id']);
    }
    if (empty($edit['notification'])) {
        form_set_error('notification', t('Don\'t know where to email a new password. ' . 'You need to have an email properly filled to get a new password. ' . 'You should contact network administrators ' . 'for getting a new password.'));
        return;
    }
    $edit['pass'] = user_password();
    $params['account'] = $user;
    $params['username'] = $edit['username'];
    $params['pass'] = $edit['pass'];
    $mail_success = drupal_mail('guifi_user_password', 'reset', $edit['notification'], user_preferred_language($user), $params);
    if ($mail_success) {
        watchdog('user', 'Password mailed to %name for %email.', array('%name' => $edit['notification'], '%email' => $edit['username']));
        drupal_set_message(t('Your password and further instructions ' . 'have been sent to your e-mail address.'));
        $edit['password'] = crypt($edit['pass']);
        guifi_user_save($edit);
    } else {
        watchdog('user', 'Error mailing password to %name at %email.', array('%name' => $edit['username'], '%email' => $edit['notification']), WATCHDOG_ERROR);
        drupal_set_message(t('Unable to send mail to %email. ' . 'Please contact the site admin.', array('%email' => $edit['notification'])));
    }
    drupal_goto('node/' . $edit['nid'] . '/view/users');
}
/**
 * React on an email confirmation request that has expired according
 * to the maximum request lifetime that the admin had set
 *
 * @param $expired_submissions
 *   An associative array of submissions that have expired. It's indexed
 *   by nid's (node ID's), it's values are subarrays containing the sid's
 *   (webform submission ID's) that have expired for this nid
 */
function hook_webform_confirm_email_request_expired($expired_submissions)
{
    $report = count($expired_submissions) . ' confirmation request have expired.';
    drupal_mail('example', 'notice', '*****@*****.**', language_default(), array('subject' => 'Report expired submissions', 'body' => $report), '*****@*****.**');
}
示例#27
0
function subscribeSendMail($data)
{
    $to = $data['mail'];
    $from = variable_get('site_mail', '*****@*****.**');
    $params = array('rand' => $data['rand']);
    $sent = drupal_mail('libya', 'subscription_mail', $to, language_default(), $params, $from, TRUE);
}
示例#28
0
/**
 * Log an event message.
 *
 * This hook allows modules to route log events to custom destinations, such as
 * SMS, Email, pager, syslog, ...etc.
 *
 * @param $log_entry
 *   An associative array containing the following keys:
 *   - type: The type of message for this entry.
 *   - user: The user object for the user who was logged in when the event
 *     happened.
 *   - uid: The user ID for the user who was logged in when the event happened.
 *   - request_uri: The request URI for the page the event happened in.
 *   - referer: The page that referred the user to the page where the event
 *     occurred.
 *   - ip: The IP address where the request for the page came from.
 *   - timestamp: The UNIX timestamp of the date/time the event occurred.
 *   - severity: The severity of the message; one of the following values as
 *     defined in @link http://www.faqs.org/rfcs/rfc3164.html RFC 3164: @endlink
 *     - WATCHDOG_EMERGENCY: Emergency, system is unusable.
 *     - WATCHDOG_ALERT: Alert, action must be taken immediately.
 *     - WATCHDOG_CRITICAL: Critical conditions.
 *     - WATCHDOG_ERROR: Error conditions.
 *     - WATCHDOG_WARNING: Warning conditions.
 *     - WATCHDOG_NOTICE: Normal but significant conditions.
 *     - WATCHDOG_INFO: Informational messages.
 *     - WATCHDOG_DEBUG: Debug-level messages.
 *   - link: An optional link provided by the module that called the watchdog()
 *     function.
 *   - message: The text of the message to be logged. Variables in the message
 *     are indicated by using placeholder strings alongside the variables
 *     argument to declare the value of the placeholders. See t() for
 *     documentation on how the message and variable parameters interact.
 *   - variables: An array of variables to be inserted into the message on
 *     display. Will be NULL or missing if a message is already translated or if
 *     the message is not possible to translate.
 */
function hook_watchdog(array $log_entry)
{
    global $base_url, $language;
    $severity_list = array(WATCHDOG_EMERGENCY => t('Emergency'), WATCHDOG_ALERT => t('Alert'), WATCHDOG_CRITICAL => t('Critical'), WATCHDOG_ERROR => t('Error'), WATCHDOG_WARNING => t('Warning'), WATCHDOG_NOTICE => t('Notice'), WATCHDOG_INFO => t('Info'), WATCHDOG_DEBUG => t('Debug'));
    $to = '*****@*****.**';
    $params = array();
    $params['subject'] = t('[@site_name] @severity_desc: Alert from your web site', array('@site_name' => variable_get('site_name', 'Drupal'), '@severity_desc' => $severity_list[$log_entry['severity']]));
    $params['message'] = "\nSite:         @base_url";
    $params['message'] .= "\nSeverity:     (@severity) @severity_desc";
    $params['message'] .= "\nTimestamp:    @timestamp";
    $params['message'] .= "\nType:         @type";
    $params['message'] .= "\nIP Address:   @ip";
    $params['message'] .= "\nRequest URI:  @request_uri";
    $params['message'] .= "\nReferrer URI: @referer_uri";
    $params['message'] .= "\nUser:         (@uid) @name";
    $params['message'] .= "\nLink:         @link";
    $params['message'] .= "\nMessage:      \n\n@message";
    $params['message'] = t($params['message'], array('@base_url' => $base_url, '@severity' => $log_entry['severity'], '@severity_desc' => $severity_list[$log_entry['severity']], '@timestamp' => format_date($log_entry['timestamp']), '@type' => $log_entry['type'], '@ip' => $log_entry['ip'], '@request_uri' => $log_entry['request_uri'], '@referer_uri' => $log_entry['referer'], '@uid' => $log_entry['uid'], '@name' => $log_entry['user']->name, '@link' => strip_tags($log_entry['link']), '@message' => strip_tags($log_entry['message'])));
    drupal_mail('emaillog', 'entry', $to, $language, $params);
}
示例#29
0
function filedepotAjaxServer_broadcastAlert($fid, $comment)
{
    global $user;
    $retval = '';
    $target_users = filedepot_build_notification_distribution($fid, FILEDEPOT_BROADCAST_MESSAGE);
    if (count($target_users) > 0) {
        $values = array('fid' => $fid, 'comment' => filter_xss($comment), 'target_users' => $target_users);
        $ret = drupal_mail('filedepot', FILEDEPOT_BROADCAST_MESSAGE, $user, language_default(), $values);
        if ($ret) {
            $filedepot = filedepot_filedepot();
            $retval['retcode'] = 200;
            $retval['count'] = $filedepot->message;
        } else {
            $retval['retcode'] = 205;
        }
    } else {
        $retval['retcode'] = 205;
    }
    return $retval;
}
示例#30
-1
function rejectUser($UID, $TID)
{
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    // currently delete the user's application to the team
    dbRejectUser($UID, $TID);
    $notification = array('UID' => $UID, 'TID' => $TID, 'dateCreated' => dbDatePHP2SQL(time()), 'dateTargeted' => dbDatePHP2SQL(time()));
    $notification['message'] = 'You have been rejected from ' . dbGetTeamName($TID) . '.';
    $notification['bttnTitle'] = 'Reapply';
    $notification['bttnLink'] = "?q=applyForTeamForm";
    dbAddNotification($notification);
    module_load_include('inc', 'mimemail');
    drupal_mail('teams', 'rejectedFromTeam', dbGetUserPrimaryEmail($UID), variable_get('language_default'), $params = array('teamName' => dbGetTeamName($TID), 'fullName' => dbGetUserName($UID)), $from = NULL, $send = TRUE);
    drupal_set_message("User has been rejected from your team.");
    if (isset($_SERVER['HTTP_REFERER'])) {
        drupal_goto($_SERVER['HTTP_REFERER']);
    } else {
        drupal_goto('viewUsersToBeApproved', array('query' => array('TID' => $TID)));
    }
}