From 3fba4bb9b289f37c246588683413b6eb9e5b5d15 Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Fri, 20 Jan 2017 15:28:14 +0530 Subject: added the chapter name edit option and traker mail for every edit --- textbook_companion_fixer_email.inc | 154 +++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 textbook_companion_fixer_email.inc (limited to 'textbook_companion_fixer_email.inc') diff --git a/textbook_companion_fixer_email.inc b/textbook_companion_fixer_email.inc new file mode 100644 index 0000000..38df00b --- /dev/null +++ b/textbook_companion_fixer_email.inc @@ -0,0 +1,154 @@ +fields('textbook_companion_example'); + $query->condition('id', $params['chapter_example_updated']['example_id']); + $query->range(0, 1); + $result = $query->execute(); + $example_data = $result->fetchObject(); + $query = db_select('textbook_companion_chapter'); + $query->fields('textbook_companion_chapter'); + $query->condition('id', $example_data->chapter_id); + $query->range(0, 1); + $result = $query->execute(); + $chapter_data = $result->fetchObject(); + $query = db_select('textbook_companion_preference'); + $query->fields('textbook_companion_preference'); + $query->condition('id', $chapter_data->preference_id); + $query->range(0, 1); + $result = $query->execute(); + $preference_data = $result->fetchObject(); + $user_data = user_load($params['chapter_example_updated']['user_id']); + $message['headers'] = $params['chapter_example_updated']['headers']; + $message['subject'] = t('[!site_name][Textbook companion] You have updated chapter, example caption for textbook ' . $preference_data->book, array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' +Dear !user_name, + +You have updated the following example: + +Title of the book : ' . $preference_data->book . ' +Title of the chapter : ' . $chapter_data->name . ' +Example number : ' . $example_data->number . ' +Caption : ' . $example_data->caption . ' + + +Best Wishes, + +Scilab TBC Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'chapter_updated': + + $query = db_select('textbook_companion_chapter'); + $query->fields('textbook_companion_chapter'); + $query->condition('id', $params['chapter_updated']['chapter_id']);; + $query->range(0, 1); + $result = $query->execute(); + $chapter_data = $result->fetchObject(); + $query = db_select('textbook_companion_preference'); + $query->fields('textbook_companion_preference'); + $query->condition('id', $chapter_data->preference_id); + $query->range(0, 1); + $result = $query->execute(); + $preference_data = $result->fetchObject(); + $user_data = user_load($params['chapter_updated']['user_id']); + $message['headers'] = $params['chapter_updated']['headers']; + $message['subject'] = t('[!site_name][Textbook companion] You have updated chapter name for textbook ' . $preference_data->book, array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' +Dear !user_name, + +You have updated the following example: + +Title of the book : ' . $preference_data->book . ' +Title of the chapter : ' . $chapter_data->name . ' + +Best Wishes, + +Scilab TBC Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + case 'example_updated': + $query = db_select('textbook_companion_example'); + $query->fields('textbook_companion_example'); + $query->condition('id', $params['example_updated']['example_id']); + $query->range(0, 1); + $result = $query->execute(); + $example_data = $result->fetchObject(); + $query = db_select('textbook_companion_chapter'); + $query->fields('textbook_companion_chapter'); + $query->condition('id', $example_data->chapter_id); + $query->range(0, 1); + $result = $query->execute(); + $chapter_data = $result->fetchObject(); + $query = db_select('textbook_companion_preference'); + $query->fields('textbook_companion_preference'); + $query->condition('id', $chapter_data->preference_id); + $query->range(0, 1); + $result = $query->execute(); + $preference_data = $result->fetchObject(); + $user_data = user_load($params['example_updated']['user_id']); + $message['headers'] = $params['example_updated']['headers']; + $message['subject'] = t('[!site_name][Textbook companion] You have updated example caption for textbook ' . $preference_data->book, array( + '!site_name' => variable_get('site_name', '') + ), array( + 'language' => $language->language + )); + $message['body'] = array( + 'body' => t(' +Dear !user_name, + +You have updated the following example: + +Title of the book : ' . $preference_data->book . ' +Title of the chapter : ' . $chapter_data->name . ' +Example number : ' . $example_data->number . ' +Caption : ' . $example_data->caption . ' + + +Best Wishes, + +Scilab TBC Team, +FOSSEE, IIT Bombay', array( + '!site_name' => variable_get('site_name', ''), + '!user_name' => $user_data->name + ), array( + 'language' => $language->language + )) + ); + break; + } //$key +} -- cgit