diff --git a/sites/all/modules/unl/technical_feedback.php b/sites/all/modules/unl/technical_feedback.php new file mode 100644 index 0000000000000000000000000000000000000000..e68b778443a72922bc1ddad3d9621b2e5f9a0348 --- /dev/null +++ b/sites/all/modules/unl/technical_feedback.php @@ -0,0 +1,116 @@ +<?php + +function technical_feedback(){ + echo drupal_render(drupal_get_form('technical_feedback_form')); +} + +function technical_feedback_form($form, &$form_state) { + + $form['root'] = array( + '#type' => 'fieldset', + '#title' => 'Technical Feeedback Form', + ); + + $form['root']['browser_useragent'] = array( + '#type' => 'textfield', + '#title' => t('Browser UserAgent (textfield disabled)'), + '#value' => $_SERVER['HTTP_USER_AGENT'], + '#disabled' => 'disabled', + ); + + $form['root']['current_url'] = array( + '#type' => 'textfield', + '#title' => t('Current url (text disabled)'), + '#value' => $_SERVER['HTTP_REFERER'], + '#disabled' => 'disabled' + ); + + $form['root']['cas_username'] = array( + '#type' => 'textfield', + '#title' => t('CAS Name (textfield disabled'), + '#value' => ($GLOBALS['user']->name), + '#disabled' => 'disabled', + + ); + + $form['root']['email'] = array( + '#type' => 'textfield', + '#title' => t('Email (textfield disabled)'), + '#value' => ($GLOBALS['user']->mail), + '#disabled' => 'disabled' + + ); + + $form['root']['full_name'] = array( + '#type' => 'textfield', + '#title' => t('Your first, last name'), + '#required' => TRUE, + ); + + $form['root']['technical_feedback'] = array( + '#type' => 'textarea', + '#title' => t('Please give your feedback or describe the issue you are having'), + '#required' => TRUE, + ); + + $form['root']['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit'), + ); + + + return $form; +} + +function technical_feedback_form_submit($form, &$form_state){ + $browser_useragent = $form_state['values']['browser_useragent']; + $current_url = $form_state['values']['current_url']; + $cas_username = $form_state['values']['cas_username']; + $email = $form_state['values']['email']; + $full_name = $form_state['values']['full_name']; + $technical_feedback = $form_state['values']['technical_feedback']; + + $to = "unlcms-dev@listserv.unl.edu"; + $from = $email; + $subject = "UNLcms Technical Feedback"; + + $message = ' + <html> + <body> + <table style="border:1px solid #bbb;cellpadding="10";"> + <tr style="background-color: #eee;"> + <td>Browser UserAgent</td><td>'.$browser_useragent.'</td> + </tr> + <tr> + <td>CAS Username</td><td>'.$cas_username.'</td> + </tr> + <tr style="background-color: #eee;"> + <td>Full Name</td><td>'.$full_name.'</td> + </tr> + <tr> + <td>Email</td><td>'.$email.'</td> + </tr> + <tr style="background-color: #eee;"> + <td>Page URL</td><td>'.$current_url.'</td> + </tr> + <tr> + <td>Technical Feedback/Issue</td><td>'.$technical_feedback.'</td> + </tr> + </table> + </body> + </html> + '; + + $technical_feedback_email_headers = 'From: ' . $email . "\r\n"; + + $technical_feedback_email_headers .= "MIME-Version: 1.0\r\n"; + $technical_feedback_email_headers .= "Content-type:text/html; charset=ISO-8859-1\r\n"; + + + mail($to, $subject, $message, $technical_feedback_email_headers); + + + drupal_set_message(t('Your feedback has been emailed to the UNLcms dev team. Thank you!')); + $form_state['redirect'] = $current_url; + return; +} diff --git a/sites/all/modules/unl/unl.module b/sites/all/modules/unl/unl.module index f63a70d91ab5f46321df57a4c31fc1a6224bcb57..809498db89aacf7c50858d98014839c9ec466d6a 100644 --- a/sites/all/modules/unl/unl.module +++ b/sites/all/modules/unl/unl.module @@ -100,6 +100,24 @@ function unl_permission() { */ function unl_menu() { $access = array(); + // Returns confirmation 'user_loggedin' if user is logged into the system + $items['user/unl/whoami'] = array( + 'title' => 'UNL Whoami Tool', + 'access callback' => TRUE, + 'page callback' => 'unl_whoami', + 'file' => 'unl_whoami.php', + ); + + // Returns html technical feedback form + $items['user/unl/technical_feedback'] = array( + 'title' => 'Technical Feedback', + 'description' => 'Returns a form to fill out to give technical feedback', + 'access callback' => TRUE, + 'page callback' => 'technical_feedback', + 'file' => 'technical_feedback.php' + + ); + $items['admin/content/unl/migration'] = array( 'title' => 'UNL Migration Tool', 'description' => 'Migrate a static UNL template page into drupal', diff --git a/sites/all/modules/unl/unl_whoami.php b/sites/all/modules/unl/unl_whoami.php new file mode 100644 index 0000000000000000000000000000000000000000..f2853863ab7d6dfe8aef4c7efae0dd2a92696d27 --- /dev/null +++ b/sites/all/modules/unl/unl_whoami.php @@ -0,0 +1,10 @@ +<?php + +/** + * if a user is logged in, it returns the name, mail + */ +function unl_whoami() { + if($GLOBALS['user']->uid) { + echo 'user_loggedin'; + } +} \ No newline at end of file diff --git a/sites/all/themes/unl_wdn/theme.js b/sites/all/themes/unl_wdn/theme.js index 3e5cae46e96267ad859e0d265728c093857404d2..b9865c3e1d4ea35a1b53f8ab2da3694fbf1c4f4a 100644 --- a/sites/all/themes/unl_wdn/theme.js +++ b/sites/all/themes/unl_wdn/theme.js @@ -21,4 +21,42 @@ WDN.jQuery(document).ready(function () { e.preventDefault(); document.location.hash = this.href.split('#')[1]; }); + + // checking using ajax if user is logged in. then the technical feedback div is shown + var userLoggedIn = ''; + + WDN.jQuery.ajax({ + url: "user/unl/whoami", + dataType: "text", + success: function(data){ + + userLoggedIn = String(data); + + if(userLoggedIn =='user_loggedin') { + + var technicalFeedbackHtml = WDN.jQuery.ajax({ + url: "user/unl/technical_feedback", + dataType: "html", + success: function(data) { + + var technicalFeedback = '<a id="technicalFeedbackLink">Found a bug? Report any issue with the cms (like when editing docs, uploading etc.) or give feedback</a>'; + technicalFeedback += '<div id="technicalFeedbackForm"></div>'; + + WDN.jQuery("#footer>div:nth-child(2)").append(technicalFeedback); + + WDN.jQuery("#technicalFeedbackLink").click(function(){ + + WDN.jQuery("#technicalFeedbackForm").append(data); + + }); + + } + + }); + + } // end of if userLoggedIn == 'user_loggedin' + + } // end of success: function(data) + }); + }); \ No newline at end of file