Skip to content
Snippets Groups Projects
Commit 142b186f authored by Tim Steiner's avatar Tim Steiner
Browse files

[gh-131] Merging from testing into staging

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@796 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent 1e3f73be
No related branches found
No related tags found
No related merge requests found
<?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;
}
......@@ -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',
......
<?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
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment