Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Commit

Permalink
send e-mail for authentication functionality added
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaifieraru committed Feb 2, 2014
1 parent 0a82427 commit 569cbe9
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 1 deletion.
86 changes: 86 additions & 0 deletions sites/all/modules/course_creation/course_creation.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@





/*
This will configure the e-mail that will be sent to all the members of the website
*/

function course_creation_mail($key, &$message, $params){
$language = $message["language"];
switch($key){

case "key":
$message["subject"] = t("PantaRhei Announcement: ".$params["title"]);
$message['body'][] =
'Dear '.$params["name"].',

'.$params["content"].'


You can comment '.$params['link'].'.


PantaRhei Admin
'


;
break;

}
}






/*
**Implements hook_node_presave() .
**/
Expand Down Expand Up @@ -603,8 +639,58 @@ function course_creation_node_presave($node){
}









}

/* This will send notifications to all members
*/


function course_creation_node_insert($node){
if($node->type == "announcement_entry" && $node->field_send_email['und']['0']['value'] == 1) {

$query = db_select('users', 'u');
$query->fields('u', array('name'));
$result = $query->execute();
$members = array();
while($record = $result->fetchAssoc()) {
$members[] = $record['name'];

}

foreach ($members AS $member) {
$user = user_load_by_name($member);





if ($user)
if($user->status == "1"){

$to = $user->mail;

if($user->field_full_name)
$params["name"] = $user->field_full_name["und"]["0"]["value"];
else
$params["name"] = $user->name;
$params["link"] = l(t("here"),"node/".$node->nid);
$params["title"] = $node->title;
$params["content"] = $node->body["und"]["0"]["value"];
$email_from = "[email protected]";

$sent = drupal_mail("course_creation", "key", $to, language_default(), $params, $email_from, TRUE);

}

}
}


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,33 @@ function course_creation_features_field_default_field_bases() {
'type' => 'tablefield',
);

// Exported field_base: 'field_send_email'
$field_bases['field_send_email'] = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_send_email',
'foreign keys' => array(),
'indexes' => array(
'value' => array(
0 => 'value',
),
),
'locked' => 0,
'module' => 'list',
'settings' => array(
'allowed_values' => array(
0 => 'No',
1 => 'Yes',
),
'allowed_values_function' => '',
'allowed_values_php' => '',
),
'translatable' => 0,
'type' => 'list_boolean',
);

// Exported field_base: 'field_summary'
$field_bases['field_summary'] = array(
'active' => 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,48 @@ function course_creation_features_field_default_field_instances() {
),
);

// Exported field_instance: 'node-announcement_entry-field_send_email'
$field_instances['node-announcement_entry-field_send_email'] = array(
'bundle' => 'announcement_entry',
'default_value' => array(
0 => array(
'value' => 0,
),
),
'default_value_function' => '',
'default_value_php' => '',
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'settings' => array(),
'type' => 'hidden',
'weight' => 1,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'field_send_email',
'label' => 'Send email',
'required' => 1,
'settings' => array(
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'options',
'settings' => array(),
'type' => 'options_buttons',
'weight' => -3,
),
);

// Exported field_instance: 'node-article-body'
$field_instances['node-article-body'] = array(
'bundle' => 'article',
Expand Down Expand Up @@ -3042,6 +3084,7 @@ function course_creation_features_field_default_field_instances() {
t('Name Instructor');
t('Request message');
t('Schedule');
t('Send email');
t('Summary');
t('TA Description');
t('TA Group Id');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ features[field_base][] = field_matric_no
features[field_base][] = field_name_general_course_admin
features[field_base][] = field_name_instructor
features[field_base][] = field_schedule
features[field_base][] = field_send_email
features[field_base][] = field_summary
features[field_base][] = field_ta_description
features[field_base][] = field_ta_group_id
Expand Down Expand Up @@ -100,6 +101,7 @@ features[field_instance][] = comment-comment_node_ta_general_info-comment_body
features[field_instance][] = comment-comment_node_ta_group-comment_body
features[field_instance][] = comment-comment_node_teacher_assistant-comment_body
features[field_instance][] = node-announcement_entry-body
features[field_instance][] = node-announcement_entry-field_send_email
features[field_instance][] = node-article-body
features[field_instance][] = node-article-field_image
features[field_instance][] = node-article-field_tags
Expand Down
2 changes: 1 addition & 1 deletion sites/all/modules/stack_overflow/stack_overflow.module
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ function stack_overflow_node_insert($node){
$params["course_name"] = node_load($node->og_group_ref["und"]["0"]["target_id"])->title;
$params["link"] = l(t("here"),"node/".$node->nid);
$params["question"] = $node->title;
$email_from = "admin@panta.kwarc.info";
$email_from = "noreply@panta.kwarc.info";



Expand Down

0 comments on commit 569cbe9

Please sign in to comment.