';
}
/**
*
* Front end markup for the admin panel screen
*
* @param none
* @return none
*/
function answerMyQuestionView() {
loadMainScripts();
global $plugindir,$wpdb;
$table_name = $wpdb->prefix . "answer_my_question";
//Get a list of all questions
$result = $wpdb->get_results("SELECT id, date_asked, user_name, user_email, subject, show_on_site, answered, _wp_attached_file FROM $table_name ORDER BY date_asked DESC");
echo '
'.__("Answer My Question").'
Here you can administer all questions submitted by your site users.
';
if ($row->_wp_attached_file!='\'\'' && $row->_wp_attached_file!='')
echo '
';
else
echo ' ';
echo '
';
}
echo '
';
}else{
echo ''.__("Looks like you don't have any questions yet!").'';
}
echo '
';
}
/**
*
* Updates the database record for the question
*
* @param array $data: Array containing all posted question data
* @return boolean True if row has been updated. False otherwise
*/
function updateQuestionData($data=array()){
global $wpdb;
$table_name = $wpdb->prefix . "answer_my_question";
$questionID = $data['id'];
$notifyUser = $data['notify'];
$userEmail = $data['user_email'];
unset($data['id'], $data['posted'], $data['notify'], $data['user_email']);
$data['date_response'] = date("Y-m-d G:i:s");
$data['answered'] = 1;
$wpdb->update(
$table_name,
$data,
array('id' => $questionID)
);
if($wpdb->rows_affected > 0){
//Should user be notified?
$result = $wpdb->get_results("SELECT answer, user_name, question, subject, _wp_attached_file FROM $table_name WHERE id = $questionID LIMIT 1;");
foreach($result as $row){
$response = $row->answer;
$user_name= $row->user_name;
$question= $row->question;
$wp_attached_file= $row->_wp_attached_file;
$subject=$row->subject;
//die("". $response);
require('../wp-load.php');
//wp063/wp-content/plugins/answer-my-question/functions.inc.php
if(!function_exists('wp_get_current_user')) {
include(ABSPATH . "wp-includes/pluggable.php");
}
// Create post object
$my_post = array();
$my_post['post_title'] = $subject;
$cadena='';
if ($wp_attached_file!='\'\'' && $wp_attached_file!='')
{
$cadena.='';
}
$my_post['post_content'] = $cadena.'
20/01/2014 - '.$user_name.' preguntó:
CONSULTA:
'. $question.'
RESPUESTA:
'.$response .'
';
$my_post['post_status'] = 'pending';
$my_post['post_author'] = 2;
$my_post['post_category'] = array(4);
// Insert the post into the database
$new_id=wp_insert_post( $my_post );
//echo $new_id;
add_post_meta( $new_id,'ale_post_class', $user_name, true );
}
if($notifyUser == 1){
//sendNotificationMail($userEmail, $data['subject'], $data['date_response'], $response);
}
}
return true;
}
/**
*
* Send an email notification to a user that requested to be notified
*
* @param string $email: Email Address
* @param string $subject: The subject of the users question
* @param string $responseDate: Date of admin response. Should be in MySQL datetime format
* @return boolean True if email was sent. False otherwise
*/
function sendNotificationMail($email, $subject, $responseDate, $response){
$to = $email;
$emailSubject = 'Han respondido a tu pregunta';
$message = '
Desde Buccasana han respondido a tu pregunta.