";
return $page_content;
}
function bulk_code_ajax() {
$data = "";
//$value =$_POST['value'];
if(isset($_POST['id']) && isset($_POST['type'])){
$type =mysql_real_escape_string($_POST['type']);
$id =mysql_real_escape_string($_POST['id']);
}
//$chapter_id =
if($type== "select_book"){
$query= "
SELECT * FROM {textbook_companion_chapter} WHERE preference_id = %d ORDER BY number ASC
";
$book_chapters_q= db_query($query, $id);
$data .= " ";
$data .= "Download (Download all the approved and unapproved examples of the entire book) ";
$data .= "Download PDF (Download PDF of all the approved and unapproved examples of the entire book) ";
$data .= "Regenerate PDF (Manually Regenerate PDF of the entire book)
";
$data .= "Approve Entire Book ";
$data .= "Delete Entire Book Including Proposal
";
echo $data;
exit();
}else {
$data .= "Please try again";
echo json_encode($data);
exit();
}
}
function bulk_code_books_ajax() {
global $user;
$data .= "";
if(isset($_POST['pref_id']) && isset($_POST['action'])){
$pref_id = mysql_real_escape_string($_POST['pref_id']);
$action = mysql_real_escape_string($_POST['action']);
$disapproval_reason = mysql_real_escape_string($_POST['dis_approve_reason']);
}
if($action == 1)
{
$data .= "";
/* approving entire book */
$chapter_q = db_query("SELECT * FROM {textbook_companion_chapter} WHERE preference_id = %d", $pref_id);
while ($chapter_data = db_fetch_object($chapter_q))
{
db_query("UPDATE {textbook_companion_example} SET approval_status = 1, approver_uid = %d WHERE chapter_id = %d AND approval_status = 0", $user->uid, $chapter_data->id);
}
$email_subject = t('Your uploaded examples have been approved');
$email_body = t('Your all the uploaded examples for the book have been approved.');
if ($email_subject)
{
$email_to = $user->mail;
$param['standard']['subject'] = $email_subject;
$param['standard']['body'] = $email_body;
if (!drupal_mail('textbook_companion', 'standard', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
$data .='Error sending email message.';
}
$data .= "Approved Entire Book";
echo $data;
exit();
}elseif($action == 4){
$root_path = textbook_companion_path();
$data .= "";
/* check if dependency files are present */
// $dep_q = db_query("SELECT * FROM {textbook_companion_dependency_files} WHERE preference_id = %d", $pref_id);
// if ($dep_data = db_fetch_object($dep_q))
// {
// drupal_set_message(t("Cannot delete book since it has dependency files that can be used by others. First delete the dependency files before deleing the Book."), 'error');
// }
if (delete_books($pref_id))
{
$dir_path = $root_path . $pref_id;
if (is_dir($dir_path))
{
$res = rmdir($dir_path);
if (!$res)
{
$data .= "Cannot delete Book directory : " . $dir_path . ". Please contact administrator.";
echo $data;
exit();
}
} else {
$data = "Book directory not present : " . $dir_path . ". Skipping deleting book directory.";
echo $data;
exit();
}
/* deleting preference and proposal */
$preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE id = %d", $pref_id);
$preference_data = db_fetch_object($preference_q);
$proposal_id = $preference_data->proposal_id;
db_query("DELETE FROM {textbook_companion_preference} WHERE proposal_id = %d", $proposal_id);
db_query("DELETE FROM {textbook_companion_proposal} WHERE id = %d", $proposal_id);
$data .= 'Deleted Book Proposal.';
/* email */
$email_subject = t('Your uploaded examples including the book proposal have been deleted');
$email_body = t('Your all the uploaded examples including the book have been deleted permanently.
Reason for deletion:
' . $disapproval_reason);
if ($email_subject)
{
$email_to = $user->mail;
$param['standard']['subject'] = $email_subject;
$param['standard']['body'] = $email_body;
if (!drupal_mail('textbook_companion', 'standard', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
$data .='Error sending email message.';
echo $data;
exit();
}
} else {
$data .= "Error Dis-Approving and Deleting Entire Book.";
echo $data;
exit();
}
}
}
// function bulk_code_books_all_ajax($id) {
// $data = "";
// $base_url = $GLOBALS['base_url']. '/sites/all/modules/tbc_comments/image/';
// $comment_query = db_query("
// SELECT * FROM tbc_comments WHERE post_id = %s ORDER BY id DESC
// ");
// $data .= "
".$comments_data->name." said....
".$comments_data->comment."
"; // $data .= "