Skip to content
Snippets Groups Projects
Commit 43f89366 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

[gh-312] Merging trunk into test -c1536 -c1537

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/testing@1538 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent 99997097
Branches
Tags
No related merge requests found
sites/all/modules/unl/images/feedback_toolbar.png

426 B

<?php <?php
function technical_feedback(){ function unl_technical_feedback($form, &$form_state) {
echo drupal_render(drupal_get_form('technical_feedback_form'));
}
function technical_feedback_form($form, &$form_state) {
$form['root'] = array( $form['root'] = array(
'#type' => 'fieldset', '#title' => 'UNLcms Technical Feeedback Form',
'#title' => 'Technical Feeedback Form',
); );
$form['root']['browser_useragent'] = array( $form['root']['cas_username'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Browser UserAgent (textfield disabled)'), '#title' => t('Username'),
'#value' => $_SERVER['HTTP_USER_AGENT'], '#value' => ($GLOBALS['user']->name),
'#disabled' => 'disabled', '#disabled' => 'disabled',
); );
$form['root']['current_url'] = array( $form['root']['email'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Current url (text disabled)'), '#title' => t('Email'),
'#value' => $_SERVER['HTTP_REFERER'], '#value' => ($GLOBALS['user']->mail),
'#disabled' => 'disabled' '#disabled' => 'disabled',
); );
$form['root']['cas_username'] = array( $form['root']['browser_useragent'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('CAS Name (textfield disabled'), '#title' => t('Browser UserAgent'),
'#value' => ($GLOBALS['user']->name), '#value' => $_SERVER['HTTP_USER_AGENT'],
'#disabled' => 'disabled', '#disabled' => 'disabled',
'#size' => 120,
); );
$form['root']['email'] = array( $form['root']['site'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Email (textfield disabled)'), '#title' => t('Site'),
'#value' => ($GLOBALS['user']->mail), '#value' => $GLOBALS['base_root'] . (isset($GLOBALS['base_path']) ? $GLOBALS['base_path'] : ''),
'#disabled' => 'disabled' '#disabled' => 'disabled',
'#size' => 120,
); );
$form['root']['full_name'] = array( $form['root']['current_url'] = array(
'#type' => 'textfield', '#type' => 'textfield',
'#title' => t('Your first, last name'), '#title' => t('Page address in question'),
'#required' => TRUE, '#value' => $_SERVER['HTTP_REFERER'],
'#size' => 120,
); );
$form['root']['technical_feedback'] = array( $form['root']['technical_feedback'] = array(
...@@ -58,59 +53,30 @@ function technical_feedback_form($form, &$form_state) { ...@@ -58,59 +53,30 @@ function technical_feedback_form($form, &$form_state) {
'#value' => t('Submit'), '#value' => t('Submit'),
); );
return $form; return $form;
} }
function technical_feedback_form_submit($form, &$form_state){ function unl_technical_feedback_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"; $to = "unlcms-dev@listserv.unl.edu";
$from = $email; $from = $form_state['values']['email'];
$subject = "UNLcms Technical Feedback"; $subject = "UNLcms technical feedback from " . $form_state['values']['cas_username'];
$message = ' $message = '
<html> Username: '.$form_state['values']['cas_username'].'
<body> Email: '.$form_state['values']['email'].'
<table style="border:1px solid #bbb;cellpadding="10";"> UserAgent: '.$form_state['values']['browser_useragent'].'
<tr style="background-color: #eee;"> Site: '.$form_state['values']['site'].'
<td>Browser UserAgent</td><td>'.$browser_useragent.'</td> Page: '.$form_state['input']['current_url'].'
</tr> Comment:
<tr> '.$form_state['values']['technical_feedback'];
<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"; $headers = 'From: ' . $form_state['values']['email'] . "\n";
$technical_feedback_email_headers .= "Content-type:text/html; charset=ISO-8859-1\r\n"; $headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type:text/plain; charset=UTF-8\n";
mail($to, $subject, $message, $technical_feedback_email_headers);
mail($to, $subject, $message, $headers);
drupal_set_message(t('Your feedback has been emailed to the UNLcms dev team. Thank you!')); drupal_set_message(t('Your feedback has been emailed to the UNLcms dev team. Thank you!'));
$form_state['redirect'] = $current_url;
return; return;
} }
...@@ -96,6 +96,30 @@ function unl_context_page_reaction() { ...@@ -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(). * Implementation of hook_page_build().
*/ */
...@@ -345,8 +369,6 @@ function unl_preprocess_page(&$vars) { ...@@ -345,8 +369,6 @@ function unl_preprocess_page(&$vars) {
* Implementation of hook_menu(). * Implementation of hook_menu().
*/ */
function unl_menu() { function unl_menu() {
global $user;
$items = array(); $items = array();
// Adds UNL Migration Tool to the Content menu for admin // Adds UNL Migration Tool to the Content menu for admin
...@@ -358,18 +380,20 @@ function unl_menu() { ...@@ -358,18 +380,20 @@ function unl_menu() {
'file' => 'unl_whoami.php', 'file' => 'unl_whoami.php',
); );
// Returns html technical feedback form // Returns UNLcms technical feedback form
$items['user/unl/technical_feedback'] = array( $items['user/unl/technical_feedback'] = array(
'title' => 'Technical Feedback', 'title' => 'UNLcms Technical Feeedback Form',
'description' => 'Returns a form to fill out to give technical feedback', 'description' => 'Submit technical feedback/issues/problems about the UNLcms system.',
'access callback' => TRUE, 'access callback' => 'user_is_logged_in',
'page callback' => 'technical_feedback', 'page callback' => 'drupal_get_form',
'file' => 'technical_feedback.php' 'page arguments' => array('unl_technical_feedback'),
'type' => MENU_NORMAL_ITEM,
'file' => 'technical_feedback.php',
); );
$items['admin/content/unl/migration'] = array( $items['admin/content/unl/migration'] = array(
'title' => 'UNL Migration Tool', 'title' => 'UNL Migration Tool',
'description' => 'Migrate a static UNL template page into drupal', 'description' => 'Migrate a static UNL template page into Drupal.',
'access arguments' => array('unl migration'), 'access arguments' => array('unl migration'),
'page callback' => 'drupal_get_form', 'page callback' => 'drupal_get_form',
'page arguments' => array('unl_migration'), 'page arguments' => array('unl_migration'),
...@@ -415,7 +439,7 @@ function unl_menu() { ...@@ -415,7 +439,7 @@ function unl_menu() {
'access callback' => TRUE, 'access callback' => TRUE,
); );
// UNL // UNL Settings
$items['admin/config/system/unl'] = array( $items['admin/config/system/unl'] = array(
'title' => 'UNL', 'title' => 'UNL',
'description' => 'Configure UNL System Settings', 'description' => 'Configure UNL System Settings',
...@@ -431,7 +455,7 @@ function unl_menu() { ...@@ -431,7 +455,7 @@ function unl_menu() {
$items['admin/content/imce-file-browser'] = array( $items['admin/content/imce-file-browser'] = array(
'title' => 'File browser', 'title' => 'File browser',
'page callback' => 'imce_user_page', 'page callback' => 'imce_user_page',
'page arguments' => array($user->uid), 'page arguments' => array($GLOBALS['user']->uid),
'access callback' => '_unl_imce_file_browser_access', 'access callback' => '_unl_imce_file_browser_access',
'file' => 'inc/imce.page.inc', 'file' => 'inc/imce.page.inc',
'file path' => drupal_get_path('module', 'imce'), 'file path' => drupal_get_path('module', 'imce'),
...@@ -443,7 +467,7 @@ function unl_menu() { ...@@ -443,7 +467,7 @@ function unl_menu() {
'title' => 'File upload', 'title' => 'File upload',
'description' => 'Upload files from your computer, such as PDF documents, to the file system.', 'description' => 'Upload files from your computer, such as PDF documents, to the file system.',
'page callback' => 'imce_user_page', 'page callback' => 'imce_user_page',
'page arguments' => array($user->uid), 'page arguments' => array($GLOBALS['user']->uid),
'access callback' => '_unl_imce_file_browser_access', 'access callback' => '_unl_imce_file_browser_access',
'file' => 'inc/imce.page.inc', 'file' => 'inc/imce.page.inc',
'file path' => drupal_get_path('module', 'imce'), 'file path' => drupal_get_path('module', 'imce'),
......
...@@ -22,32 +22,4 @@ WDN.loadJQuery(function () { ...@@ -22,32 +22,4 @@ WDN.loadJQuery(function () {
document.location.hash = this.href.split('#')[1]; 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment