diff options
author | prashant | 2015-10-16 12:20:11 +0530 |
---|---|---|
committer | prashant | 2015-10-16 12:20:11 +0530 |
commit | 361c9ef806807e4174569b1e8bf773c433a897ad (patch) | |
tree | d6f56b70b65785f33be1e608dee5cd3e6407d2b4 | |
parent | 0e9506a4841efd2d62d561e0f322ed5e9259b5cf (diff) | |
download | DWSIM_lab_migration_module-361c9ef806807e4174569b1e8bf773c433a897ad.tar.gz DWSIM_lab_migration_module-361c9ef806807e4174569b1e8bf773c433a897ad.tar.bz2 DWSIM_lab_migration_module-361c9ef806807e4174569b1e8bf773c433a897ad.zip |
formated code and done minor
-rwxr-xr-x | email.inc | 747 |
1 files changed, 412 insertions, 335 deletions
@@ -1,48 +1,46 @@ <?php - /** * Implementation of hook_mail(). */ function lab_migration_mail($key, &$message, $params) -{ - global $user; - $language = $message['language']; - //$language = user_preferred_language($user); - switch ($key) - { - case 'solution_proposal_approved': - - /* initializing data */ - //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_approved']['proposal_id']); - $query = db_select('lab_migration_proposal'); - $query->fields('lab_migration_proposal'); - $query->condition('id', $params['solution_proposal_approved']['proposal_id']); - $query->range(0, 1); - $proposal_q = $query->execute(); - $proposal_data = $proposal_q->fetchObject(); - - if ($proposal_data->solution_display == 1) { - $solution_display = 'Yes'; - } else { - $solution_display = 'No'; - } - - // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_approved']['proposal_id'], 1); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('proposal_id', $params['solution_proposal_approved']['proposal_id']); - $query->orderBy('number', 'ASC'); - $experiment_q = $query->execute(); - $experiment_list = ' +{ + global $user; + $language = $message['language']; + //$language = user_preferred_language($user); + switch ($key) { + case 'solution_proposal_approved': + /* initializing data */ + //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_approved']['proposal_id']); + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $params['solution_proposal_approved']['proposal_id']); + $query->range(0, 1); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); + if ($proposal_data->solution_display == 1) { + $solution_display = 'Yes'; + } else { + $solution_display = 'No'; + } + // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_approved']['proposal_id'], 1); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('proposal_id', $params['solution_proposal_approved']['proposal_id']); + $query->orderBy('number', 'ASC'); + $experiment_q = $query->execute(); + $experiment_list = ' '; - while ($experiment_data = $experiment_q->fetchObject()) { - $experiment_list .= '<br>' . $experiment_data->number . ' ' . $experiment_data->title . '<br> '.$experiment_data->description.' <br>'; - } - - $user_data = user_load($params['solution_proposal_approved']['user_id']); - - $message['subject'] = t('[!site_name] Lab Migration Solution Proposal Approval', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array(0 => t(' + while ($experiment_data = $experiment_q->fetchObject()) { + $experiment_list .= '</br>' . $experiment_data->number . ') ' . $experiment_data->title . '</br> ' . $experiment_data->description . ' </br></br>'; + } + $user_data = user_load($params['solution_proposal_approved']['user_id']); + $message['subject'] = t('[!site_name] Lab Migration Solution Proposal Approval', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 0 => t(' Dear !user_name, Your following Lab migration solution proposal has been approved: @@ -55,20 +53,30 @@ University/Institute : ' . $proposal_data->solution_provider_university . ' Display solution on website : ' . $solution_display . ' -List of experiments : ' . $experiment_list . ' +List of experiments : ' . $experiment_list . '</br>' . ' Please ensure that ALL the codes follow guidelines at http://www.dwsim.fossee.in/coding-guidelines-lab-migration Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'solution_proposal_disapproved': - $user_data = user_load($params['solution_proposal_disapproved']['user_id']); - - $message['subject'] = t('[!site_name] Lab Migration Solution Disapproval', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array('body' => t(' +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'solution_proposal_disapproved': + $user_data = user_load($params['solution_proposal_disapproved']['user_id']); + $message['subject'] = t('[!site_name] Lab Migration Solution Disapproval', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, Your Lab migration solution proposal has been disapproved. @@ -77,55 +85,55 @@ Reason: ' . $params['solution_proposal_disapproved']['message'] . ' Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'proposal_received': - - /* initializing data */ - // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']); - // $proposal_data = $proposal_q->fetchObject(); - - $query = db_select('lab_migration_proposal'); +!site_name', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'proposal_received': + /* initializing data */ + // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']); + // $proposal_data = $proposal_q->fetchObject(); + $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); $query->condition('id', $params['proposal_received']['proposal_id']); $query->range(0, 1); $proposal_data = $query->execute()->fetchObject(); - - if ($proposal_data->solution_display == 1) { - $solution_display = 'Yes'; - } else { - $solution_display = 'No'; - } - - if ($proposal_data->solution_provider_uid == 0) { - $solution_provider_user = 'Open'; - } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) { - $solution_provider_user = 'Proposer'; - } else { - $solution_provider_user = 'Unknown'; - } - - // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", - // $params['proposal_received']['proposal_id'], 1); - - $query = db_select('lab_migration_experiment'); + if ($proposal_data->solution_display == 1) { + $solution_display = 'Yes'; + } else { + $solution_display = 'No'; + } + if ($proposal_data->solution_provider_uid == 0) { + $solution_provider_user = 'Open'; + } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) { + $solution_provider_user = 'Proposer'; + } else { + $solution_provider_user = 'Unknown'; + } + // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", + // $params['proposal_received']['proposal_id'], 1); + $query = db_select('lab_migration_experiment'); $query->fields('lab_migration_experiment'); $query->condition('proposal_id', $params['proposal_received']['proposal_id']); $query->orderBy('number', 'ASC'); - $experiment_q = $query->execute(); - - $experiment_list = ' + $experiment_q = $query->execute(); + $experiment_list = ' '; - while ($experiment_data = $experiment_q->fetchObject()) { - $experiment_list .= '<br>' . $experiment_data->number . ' ' . $experiment_data->title . '<br> '.$experiment_data->description.' <br>'; - } - - $user_data = user_load($params['proposal_received']['user_id']); - - $message['subject'] = t('[!site_name] Your Lab migration proposal has been received', array('!site_name' => variable_get('site_name', '')),array('language' => $language->language)); - - $message['body'] = array('body' => t(' + while ($experiment_data = $experiment_q->fetchObject()) { + $experiment_list .= '</br>' . $experiment_data->number . ') ' . $experiment_data->title . '</br> ' . $experiment_data->description . ' </br></br>'; + } + $user_data = user_load($params['proposal_received']['user_id']); + $message['subject'] = t('[!site_name] Your Lab migration proposal has been received', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, We have received your following Lab migration proposal: @@ -138,7 +146,7 @@ University/Institute : ' . $proposal_data->university . ' Solution Provided By : ' . $solution_provider_user . ' -List of experiments : ' . $experiment_list . ' +List of experiments : ' . $experiment_list . '</br>' . ' Your proposal is under review and you will soon receive an email from us regarding the same. @@ -146,52 +154,55 @@ Please ensure that ALL the codes follow guidelines at http://www.dwsim.fossee.in Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - - break; - - case 'proposal_disapproved': - - /* initializing data */ - // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']); - //$proposal_data = $proposal_q->fetchObject(); - $query = db_select('lab_migration_proposal'); +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'proposal_disapproved': + /* initializing data */ + // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']); + //$proposal_data = $proposal_q->fetchObject(); + $query = db_select('lab_migration_proposal'); $query->fields('lab_migration_proposal'); $query->condition('id', $params['proposal_disapproved']['proposal_id']); $query->range(0, 1); $proposal_data = $query->execute()->fetchObject(); - - - if ($proposal_data->solution_display == 1) { - $solution_display = 'Yes'; - } else { - $solution_display = 'No'; - } - - if ($proposal_data->solution_provider_uid == 0) { - $solution_provider_user = 'Open'; - } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) { - $solution_provider_user = 'Proposer'; - } else { - $solution_provider_user = 'Unknown'; - } - - // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_disapproved']['proposal_id'], 1); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('proposal_id', $params['proposal_disapproved']['proposal_id']); - $query->orderBy('number', 'ASC'); - $experiment_q = $query->execute(); - $experiment_list = ' + if ($proposal_data->solution_display == 1) { + $solution_display = 'Yes'; + } else { + $solution_display = 'No'; + } + if ($proposal_data->solution_provider_uid == 0) { + $solution_provider_user = 'Open'; + } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) { + $solution_provider_user = 'Proposer'; + } else { + $solution_provider_user = 'Unknown'; + } + // $experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_disapproved']['proposal_id'], 1); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('proposal_id', $params['proposal_disapproved']['proposal_id']); + $query->orderBy('number', 'ASC'); + $experiment_q = $query->execute(); + $experiment_list = ' '; - while ($experiment_data = $experiment_q->fetchObject()) { - $experiment_list .= '<br>' . $experiment_data->number . ' ' . $experiment_data->title . '<br> '.$experiment_data->description.' <br>'; - } - - $user_data = user_load($params['proposal_disapproved']['user_id']); - - $message['subject'] = t('[!site_name] Your Lab migration proposal has been disapproved', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array('body' => t(' + while ($experiment_data = $experiment_q->fetchObject()) { + $experiment_list .= '</br>' . $experiment_data->number . ') ' . $experiment_data->title . '</br> ' . $experiment_data->description . ' </br></br>'; + } + $user_data = user_load($params['proposal_disapproved']['user_id']); + $message['subject'] = t('[!site_name] Your Lab migration proposal has been disapproved', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, Your following Lab migration proposal has been disapproved: @@ -206,58 +217,60 @@ University/Institute : ' . $proposal_data->university . ' Solution Provided By : ' . $solution_provider_user . ' -List of experiments : ' . $experiment_list . ' +List of experiments : ' . $experiment_list . '</br>' . ' Please ensure that ALL the codes follow guidelines at http://www.dsim.fossee.in/coding-guidelines-lab-migration Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'proposal_approved': - - /* initializing data */ - // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']); - - $query = db_select('lab_migration_proposal'); - $query->fields('lab_migration_proposal'); - $query->condition('id', $params['proposal_approved']['proposal_id']); - $query->range(0, 1); - $proposal_q = $query->execute(); - $proposal_data = $proposal_q->fetchObject(); - - if ($proposal_data->solution_display == 1) { - $solution_display = 'Yes'; - } else { - $solution_display = 'No'; - } - - if ($proposal_data->solution_provider_uid == 0) { - $solution_provider_user = 'Open'; - } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) { - $solution_provider_user = 'Proposer'; - } else { - $solution_provider_user = 'Unknown'; - } - - //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_approved']['proposal_id'], 1); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('proposal_id', $params['proposal_approved']['proposal_id']); - $query->orderBy('number', 'ASC'); - $experiment_q = $query->execute(); - - $experiment_list = ' +!site_name', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'proposal_approved': + /* initializing data */ + // $proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']); + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $params['proposal_approved']['proposal_id']); + $query->range(0, 1); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); + if ($proposal_data->solution_display == 1) { + $solution_display = 'Yes'; + } else { + $solution_display = 'No'; + } + if ($proposal_data->solution_provider_uid == 0) { + $solution_provider_user = 'Open'; + } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) { + $solution_provider_user = 'Proposer'; + } else { + $solution_provider_user = 'Unknown'; + } + //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_approved']['proposal_id'], 1); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('proposal_id', $params['proposal_approved']['proposal_id']); + $query->orderBy('number', 'ASC'); + $experiment_q = $query->execute(); + $experiment_list = ' '; - while ($experiment_data = $experiment_q->fetchObject()) { - $experiment_list .= '<br>' . $experiment_data->number . ' ' . $experiment_data->title . '<br> '.$experiment_data->description.' <br>'; - } - - $user_data = user_load($params['proposal_approved']['user_id']); - $message['subject'] = t('[!site_name] Your Lab migration proposal has been approved', - array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array(0 => t(' + while ($experiment_data = $experiment_q->fetchObject()) { + $experiment_list .= '</br>' . $experiment_data->number . ') ' . $experiment_data->title . '</br> ' . $experiment_data->description . ' </br></br>'; + } + $user_data = user_load($params['proposal_approved']['user_id']); + $message['subject'] = t('[!site_name] Your Lab migration proposal has been approved', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 0 => t(' Dear !user_name, Your following Lab migration proposal has been approved: @@ -270,59 +283,64 @@ University/Institute : ' . $proposal_data->university . ' Solution Provided By : ' . $solution_provider_user . ' -List of experiments : ' . $experiment_list . ' +List of experiments : ' . $experiment_list . '</br>' . ' Please ensure that ALL the codes follow guidelines at http://www.dwsim.fossee.in/coding-guidelines-lab-migration Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'proposal_completed': - - /* initializing data */ - //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_completed']['proposal_id']); - $query = db_select('lab_migration_proposal'); - $query->fields('lab_migration_proposal'); - $query->condition('id', $params['proposal_completed']['proposal_id']); - $query->range(0, 1); - $proposal_q = $query->execute(); - $proposal_data = $proposal_q->fetchObject(); - - if ($proposal_data->solution_display == 1) { - $solution_display = 'Yes'; - } else { - $solution_display = 'No'; - } - - if ($proposal_data->solution_provider_uid == 0) { - $solution_provider_user = 'Open'; - } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) { - $solution_provider_user = 'Proposer'; - } else { - $user_data = user_load($proposal_data->solution_provider_uid); - if (!$user_data) { - $solution_provider_user = 'Unknown'; - } - } - - //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_completed']['proposal_id'], 1); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('proposal_id', $params['proposal_completed']['proposal_id']); - $query->orderBy('number', 'ASC'); - $experiment_q = $query->execute(); - $experiment_list = ' +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'proposal_completed': + /* initializing data */ + //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['proposal_completed']['proposal_id']); + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $params['proposal_completed']['proposal_id']); + $query->range(0, 1); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); + if ($proposal_data->solution_display == 1) { + $solution_display = 'Yes'; + } else { + $solution_display = 'No'; + } + if ($proposal_data->solution_provider_uid == 0) { + $solution_provider_user = 'Open'; + } else if ($proposal_data->solution_provider_uid == $proposal_data->uid) { + $solution_provider_user = 'Proposer'; + } else { + $user_data = user_load($proposal_data->solution_provider_uid); + if (!$user_data) { + $solution_provider_user = 'Unknown'; + } + } + //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['proposal_completed']['proposal_id'], 1); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('proposal_id', $params['proposal_completed']['proposal_id']); + $query->orderBy('number', 'ASC'); + $experiment_q = $query->execute(); + $experiment_list = ' '; - while ($experiment_data = $experiment_q->fetchObject()) { - $experiment_list .= '<br/><br/><span style="font-weight: bold;">'. $experiment_data->number . ' ' . $experiment_data->title . '</span><br/><br/> '.'Description:'. $experiment_data->description.'<br/><br/>'; - } - - $user_data = user_load($params['proposal_completed']['user_id']); - - $message['subject'] = t('[!site_name] Congratulations for completion of the Lab migration', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array('body' => t(' + while ($experiment_data = $experiment_q->fetchObject()) { + $experiment_list .= '<br/><br/><span style="font-weight: bold;">' . $experiment_data->number . ' ' . $experiment_data->title . '</span><br/><br/> ' . 'Description:' . $experiment_data->description . '<br/><br/>'; + } + $user_data = user_load($params['proposal_completed']['user_id']); + $message['subject'] = t('[!site_name] Congratulations for completion of the Lab migration', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, Following Lab migration has been completed sucessfully : @@ -335,7 +353,7 @@ University/Institute : ' . $proposal_data->university . ' Solution Provided By : ' . $solution_provider_user . ' -List of experiments : ' . $experiment_list . ' +List of experiments : ' . $experiment_list . '</br>' . ' Your Lab solution is now available at following link to download. @@ -347,42 +365,48 @@ Please ensure that ALL the codes follow guidelines at http://www.dwsim.fossee.in Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'solution_proposal_received': - - /* initializing data */ - //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_received']['proposal_id']); - $query = db_select('lab_migration_proposal'); - $query->fields('lab_migration_proposal'); - $query->condition('id', $params['solution_proposal_received']['proposal_id']); - $query->range(0, 1); - $proposal_q = $query->execute(); - $proposal_data = $proposal_q->fetchObject(); - - if ($proposal_data->solution_display == 1) { - $solution_display = 'Yes'; - } else { - $solution_display = 'No'; - } - - //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_received']['proposal_id'], 1); - $query = db_select('lab_migration_experiment'); - $query->fields('lab_migration_experiment'); - $query->condition('proposal_id', $params['solution_proposal_received']['proposal_id']); - $query->orderBy('number', 'ASC'); - $experiment_q = $query->execute(); - $experiment_list = ' +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'solution_proposal_received': + /* initializing data */ + //$proposal_q = db_query("SELECT * FROM {lab_migration_proposal} WHERE id = %d LIMIT 1", $params['solution_proposal_received']['proposal_id']); + $query = db_select('lab_migration_proposal'); + $query->fields('lab_migration_proposal'); + $query->condition('id', $params['solution_proposal_received']['proposal_id']); + $query->range(0, 1); + $proposal_q = $query->execute(); + $proposal_data = $proposal_q->fetchObject(); + if ($proposal_data->solution_display == 1) { + $solution_display = 'Yes'; + } else { + $solution_display = 'No'; + } + //$experiment_q = db_query("SELECT * FROM {lab_migration_experiment} WHERE proposal_id = %d ORDER BY number", $params['solution_proposal_received']['proposal_id'], 1); + $query = db_select('lab_migration_experiment'); + $query->fields('lab_migration_experiment'); + $query->condition('proposal_id', $params['solution_proposal_received']['proposal_id']); + $query->orderBy('number', 'ASC'); + $experiment_q = $query->execute(); + $experiment_list = ' '; - while ($experiment_data = $experiment_q->fetchObject()) { - $experiment_list .= '<br/><b>' . $experiment_data->number . ' ' . $experiment_data->title . '</b><br/> Description: '.$experiment_data->description.'<br/><br/><br/> '; - } - - $user_data = user_load($params['solution_proposal_received']['user_id']); - - $message['subject'] = t('[!site_name] Your Lab migration solution proposal has been received', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array('body' => t(' + while ($experiment_data = $experiment_q->fetchObject()) { + $experiment_list .= '</br>' . $experiment_data->number . ') ' . $experiment_data->title . '</b> Description: ' . $experiment_data->description . '</br></br> '; + } + $user_data = user_load($params['solution_proposal_received']['user_id']); + $message['subject'] = t('[!site_name] Your Lab migration solution proposal has been received', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, We have received your proposal for solution for following Lab migration : @@ -397,7 +421,7 @@ Display solution on website : ' . $solution_display . ' Solution Provided By : ' . $solution_provider_user . ' -List of experiments : ' . $experiment_list . ' +List of experiments : ' . $experiment_list . '</br>' . ' Your proposal is under review and you will soon receive an email from us regarding the same. @@ -405,77 +429,105 @@ Please ensure that ALL the codes follow guidelines at http://www.dwsim.fossee.in Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'solution_uploaded': - // $solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d LIMIT 1", $params['solution_uploaded']['solution_id']); - /*$query = db_select('lab_migration_solution'); - $query->fields('lab_migration_solution'); - $query->condition('id', $params['solution_uploaded']['solution_id']); - $query->range(0, 1); - $solution_q = $query->execute(); - $solution_data = $solution_q->fetchObject();*/ - - $query = "SELECT lms.* , lmp.lab_title FROM lab_migration_solution lms +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'solution_uploaded': + // $solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d LIMIT 1", $params['solution_uploaded']['solution_id']); + /*$query = db_select('lab_migration_solution'); + $query->fields('lab_migration_solution'); + $query->condition('id', $params['solution_uploaded']['solution_id']); + $query->range(0, 1); + $solution_q = $query->execute(); + $solution_data = $solution_q->fetchObject();*/ + $query = "SELECT lms.* , lmp.lab_title FROM lab_migration_solution lms INNER JOIN lab_migration_experiment lme ON lme.id = lms.experiment_id JOIN lab_migration_proposal lmp ON lme.proposal_id = lmp.id WHERE lms.id = :id"; - - $solution_q = db_query($query, array(":id" => $params['solution_uploaded']['solution_id'])); - $solution_data = $solution_q->fetchObject(); - - $user_data = user_load($params['solution_uploaded']['user_id']); - - $message['subject'] = t('[!site_name] You have uploaded solution', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array('body' => t(' + $solution_q = db_query($query, array( + ":id" => $params['solution_uploaded']['solution_id'] + )); + $solution_data = $solution_q->fetchObject(); + $user_data = user_load($params['solution_uploaded']['user_id']); + $message['subject'] = t('[!site_name] You have uploaded solution', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, You have uploaded the following solution: Lab title: ' . $solution_data->lab_title . ' -Example number : ' . $solution_data->code_number . ' -Caption : ' . $solution_data->caption . ' +Solution number : ' . $solution_data->code_number . ' +Caption : ' . $solution_data->caption . ' The solution is under review. You will be notified when it has been approved. Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'solution_approved': - //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d LIMIT 1", $params['solution_approved']['solution_id']); - $query = db_select('lab_migration_solution'); - $query->fields('lab_migration_solution'); - $query->condition('id', $params['solution_approved']['solution_id']); - $query->range(0, 1); - $solution_q = $query->execute(); - - $solution_data = $solution_q->fetchObject(); - $user_data = user_load($params['solution_approved']['user_id']); - - $message['subject'] = t('[!site_name] Your uploaded solution has been approved', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array('body' => t(' +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'solution_approved': + //$solution_q = db_query("SELECT * FROM {lab_migration_solution} WHERE id = %d LIMIT 1", $params['solution_approved']['solution_id']); + $query = db_select('lab_migration_solution'); + $query->fields('lab_migration_solution'); + $query->condition('id', $params['solution_approved']['solution_id']); + $query->range(0, 1); + $solution_q = $query->execute(); + $solution_data = $solution_q->fetchObject(); + $user_data = user_load($params['solution_approved']['user_id']); + $message['subject'] = t('[!site_name] Your uploaded solution has been approved', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, Your following solution has been approved: Solution number : ' . $solution_data->code_number . ' -Caption : ' . $solution_data->caption . ' +Caption : ' . $solution_data->caption . ' Please ensure that ALL the codes follow guidelines at http://www.dwsim.fossee.in/coding-guidelines-lab-migration Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'solution_disapproved': - $user_data = user_load($params['solution_disapproved']['user_id']); - - $message['subject'] = t('[!site_name] Your uploaded solution has been disapproved', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array('body' => t(' +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'solution_disapproved': + $user_data = user_load($params['solution_disapproved']['user_id']); + $message['subject'] = t('[!site_name] Your uploaded solution has been disapproved', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, Your following solution has been disapproved: @@ -489,13 +541,24 @@ Please ensure that ALL the codes follow guidelines at http://www.dwsim.fossee.in Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'solution_deleted_user': - $user_data = user_load($params['example_deleted_user']['user_id']); - $message['subject'] = t('[!site_name] User has deleted pending solution', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array('body' => t(' +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'solution_deleted_user': + $user_data = user_load($params['example_deleted_user']['user_id']); + $message['subject'] = t('[!site_name] User has deleted pending solution', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, Your following pending solution has been deleted : @@ -509,16 +572,25 @@ Please ensure that ALL the codes follow guidelines at http://www.dwsim.fossee.in Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'dependency_uploaded': - $user_data = user_load($params['dependency_uploaded']['user_id']); - - $dependency_files = implode(',', $params['dependency_uploaded']['dependency_names']); - - $message['subject'] = t('[!site_name] You have uploaded dependency file', array('!site_name' => variable_get('site_name', '')), array('language' => $language->language)); - $message['body'] = array('body' => t(' +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'dependency_uploaded': + $user_data = user_load($params['dependency_uploaded']['user_id']); + $dependency_files = implode(',', $params['dependency_uploaded']['dependency_names']); + $message['subject'] = t('[!site_name] You have uploaded dependency file', array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' Dear !user_name, You have uploaded following dependency files : @@ -528,13 +600,18 @@ Please ensure that ALL the codes follow guidelines at http://www.dwsim.fossee.in Best Wishes, -!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), array('language' => $language->language))); - break; - - case 'standard': - $message['subject'] = $params['standard']['subject']; - $message['body'] = $params['standard']['body']; - break; - } +!site_name Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'standard': + $message['subject'] = $params['standard']['subject']; + $message['body'] = $params['standard']['body']; + break; + } } - |