diff --git a/sites/all/modules/unl/images/feedback_toolbar.png b/sites/all/modules/unl/images/feedback_toolbar.png new file mode 100644 index 0000000000000000000000000000000000000000..80023e8f1a0c3a2749838f3cdbd547b46c6ccee8 Binary files /dev/null and b/sites/all/modules/unl/images/feedback_toolbar.png differ diff --git a/sites/all/modules/unl/technical_feedback.php b/sites/all/modules/unl/technical_feedback.php index e68b778443a72922bc1ddad3d9621b2e5f9a0348..070a403635252216840597d81d4bb8fe03239699 100644 --- a/sites/all/modules/unl/technical_feedback.php +++ b/sites/all/modules/unl/technical_feedback.php @@ -1,116 +1,82 @@ <?php -function technical_feedback(){ - echo drupal_render(drupal_get_form('technical_feedback_form')); -} +function unl_technical_feedback($form, &$form_state) { + $form['root'] = array( + '#title' => 'UNLcms Technical Feeedback Form', + ); + + $form['root']['cas_username'] = array( + '#type' => 'textfield', + '#title' => t('Username'), + '#value' => ($GLOBALS['user']->name), + '#disabled' => 'disabled', + ); + + $form['root']['email'] = array( + '#type' => 'textfield', + '#title' => t('Email'), + '#value' => ($GLOBALS['user']->mail), + '#disabled' => 'disabled', + ); + + $form['root']['browser_useragent'] = array( + '#type' => 'textfield', + '#title' => t('Browser UserAgent'), + '#value' => $_SERVER['HTTP_USER_AGENT'], + '#disabled' => 'disabled', + '#size' => 120, + ); + + $form['root']['site'] = array( + '#type' => 'textfield', + '#title' => t('Site'), + '#value' => $GLOBALS['base_root'] . (isset($GLOBALS['base_path']) ? $GLOBALS['base_path'] : ''), + '#disabled' => 'disabled', + '#size' => 120, + ); + + $form['root']['current_url'] = array( + '#type' => 'textfield', + '#title' => t('Page address in question'), + '#value' => $_SERVER['HTTP_REFERER'], + '#size' => 120, + ); -function technical_feedback_form($form, &$form_state) { + $form['root']['technical_feedback'] = array( + '#type' => 'textarea', + '#title' => t('Please give your feedback or describe the issue you are having'), + '#required' => TRUE, + ); - $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; + $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"; +function unl_technical_feedback_submit($form, &$form_state) { + $to = "unlcms-dev@listserv.unl.edu"; + $from = $form_state['values']['email']; + $subject = "UNLcms technical feedback from " . $form_state['values']['cas_username']; + + $message = ' +Username: '.$form_state['values']['cas_username'].' +Email: '.$form_state['values']['email'].' +UserAgent: '.$form_state['values']['browser_useragent'].' +Site: '.$form_state['values']['site'].' +Page: '.$form_state['input']['current_url'].' +Comment: +'.$form_state['values']['technical_feedback']; + + $headers = 'From: ' . $form_state['values']['email'] . "\n"; + $headers .= "MIME-Version: 1.0\n"; + $headers .= "Content-type:text/plain; charset=UTF-8\n"; + + mail($to, $subject, $message, $headers); + + drupal_set_message(t('Your feedback has been emailed to the UNLcms dev team. Thank you!')); - $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 992872f072d9279050ff0134c82199208d52fa96..24d06b6dbf7e0eaaf74b832635a3fee0e676952b 100644 --- a/sites/all/modules/unl/unl.module +++ b/sites/all/modules/unl/unl.module @@ -96,6 +96,30 @@ function unl_context_page_reaction() { } } +/** + * Implementation of hook_page_alter(). + */ +function unl_page_alter(&$page) { + // Add UNLcms technical feedback link to toolbar + if (isset($page['page_top']['toolbar'])) { + $page['page_top']['toolbar']['#pre_render'][] = 'unl_toolbar_add_links'; + } +} + +/** + * Custom function called from unl_page_alter() to add links to the toolbar. + */ +function unl_toolbar_add_links($toolbar) { + $link['html'] = TRUE; + $icon = '<span style="background-image:url('. base_path() . 'sites/all/modules/unl/images/feedback_toolbar.png); width:20px; height:20px; text-indent:-9999px; display:block;">Feedback</span>'; + $link['title'] = t("!icon", array('!icon' => $icon)); + $link['attributes']['title'] = t('Submit technical feedback/issues/problems about the UNLcms system'); + $link['href'] = 'user/unl/technical_feedback'; + + $toolbar['toolbar_user']['#links'] = array_merge(array('unl' => $link), $toolbar['toolbar_user']['#links']); + return $toolbar; +} + /** * Implementation of hook_page_build(). */ @@ -329,8 +353,6 @@ function unl_preprocess_page(&$vars) { * Implementation of hook_menu(). */ function unl_menu() { - global $user; - $items = array(); // Returns confirmation 'user_loggedin' if user is logged into the system @@ -341,34 +363,36 @@ function unl_menu() { 'file' => 'unl_whoami.php', ); - // Returns html technical feedback form + // Returns UNLcms 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' + 'title' => 'UNLcms Technical Feeedback Form', + 'description' => 'Submit technical feedback/issues/problems about the UNLcms system.', + 'access callback' => 'user_is_logged_in', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('unl_technical_feedback'), + 'type' => MENU_NORMAL_ITEM, + 'file' => 'technical_feedback.php', ); // Adds UNL Migration Tool to the Content menu for admin $items['admin/content/unl/migration'] = array( - 'title' => 'UNL Migration Tool', - 'description' => 'Migrate a static UNL template page into drupal', + 'title' => 'UNL Migration Tool', + 'description' => 'Migrate a static UNL template page into Drupal.', 'access arguments' => array('unl migration'), - 'page callback' => 'drupal_get_form', - 'page arguments' => array('unl_migration'), - 'type' => MENU_LOCAL_TASK, - 'file' => 'unl_migration.php', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('unl_migration'), + 'type' => MENU_LOCAL_TASK, + 'file' => 'unl_migration.php', ); $items['admin/content/unl/reset'] = array( - 'title' => 'Reset Site', - 'description' => 'Remove all nodes, menu items, etc from this site.', - 'access callback' => 'unl_user_is_administrator', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('unl_reset_site'), - 'type' => MENU_LOCAL_TASK, - 'file' => 'includes/reset_site.php', + 'title' => 'Reset Site', + 'description' => 'Remove all nodes, menu items, etc from this site.', + 'access callback' => 'unl_user_is_administrator', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('unl_reset_site'), + 'type' => MENU_LOCAL_TASK, + 'file' => 'includes/reset_site.php', ); // Redirect the Appearance link away from admin/appearance for users who can't Administer themes but can Change Theme Settings @@ -384,20 +408,20 @@ function unl_menu() { // Hello world type page for performance/uptime monitoring $items['_status'] = array( - 'title' => 'Still Alive', - 'page callback' => 'unl_still_alive', + 'title' => 'Still Alive', + 'page callback' => 'unl_still_alive', 'access callback' => TRUE, ); - // UNL + // UNL Settings $items['admin/config/system/unl'] = array( - 'title' => 'UNL', - 'description' => 'Configure UNL System Settings', - 'access callback' => 'unl_user_is_administrator', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('unl_config'), - 'file' => 'includes/unl.admin.inc', - 'weight' => 1, + 'title' => 'UNL', + 'description' => 'Configure UNL System Settings', + 'access callback' => 'unl_user_is_administrator', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('unl_config'), + 'file' => 'includes/unl.admin.inc', + 'weight' => 1, ); if (module_exists('imce')) { @@ -405,7 +429,7 @@ function unl_menu() { $items['admin/content/imce-file-browser'] = array( 'title' => 'File browser', 'page callback' => 'imce_user_page', - 'page arguments' => array($user->uid), + 'page arguments' => array($GLOBALS['user']->uid), 'access callback' => '_unl_imce_file_browser_access', 'file' => 'inc/imce.page.inc', 'file path' => drupal_get_path('module', 'imce'), @@ -417,7 +441,7 @@ function unl_menu() { 'title' => 'File upload', 'description' => 'Upload files from your computer, such as PDF documents, to the file system.', 'page callback' => 'imce_user_page', - 'page arguments' => array($user->uid), + 'page arguments' => array($GLOBALS['user']->uid), 'access callback' => '_unl_imce_file_browser_access', 'file' => 'inc/imce.page.inc', 'file path' => drupal_get_path('module', 'imce'), diff --git a/sites/all/themes/unl_wdn/theme.js b/sites/all/themes/unl_wdn/theme.js index fe3fad35ba48ef47a26402abfe8811f0dabb330a..a11c4fe26c02bc20b6f9aaa83e5f54921aba8e0c 100644 --- a/sites/all/themes/unl_wdn/theme.js +++ b/sites/all/themes/unl_wdn/theme.js @@ -1,53 +1,25 @@ WDN.loadJQuery(function () { - // if there's no base tag on the page, we don't have to worry about this - if (WDN.jQuery('base').length == 0) { - return; - } - WDN.jQuery('a').click(function(e) { - // if this link has a hash tag - if (!this.href.split('#')[1]) { - return; - } - // and it is specifically for this page - if (this.getAttribute('href').split('#')[0] != '') { - return; - } - // and something else hasn't already customized the link - if (e.isDefaultPrevented()) { - return; - } - - // fix clicking the link so that it ignores the base tag - 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) - }); + // if there's no base tag on the page, we don't have to worry about this + if (WDN.jQuery('base').length == 0) { + return; + } + WDN.jQuery('a').click(function(e) { + // if this link has a hash tag + if (!this.href.split('#')[1]) { + return; + } + // and it is specifically for this page + if (this.getAttribute('href').split('#')[0] != '') { + return; + } + // and something else hasn't already customized the link + if (e.isDefaultPrevented()) { + return; + } + + // fix clicking the link so that it ignores the base tag + e.preventDefault(); + document.location.hash = this.href.split('#')[1]; + }); + }); \ No newline at end of file