summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--].download.inc.swpbin16384 -> 16384 bytes
-rwxr-xr-xcheque_contact.inc10
-rwxr-xr-x[-rw-r--r--]cheque_manage.inc0
-rwxr-xr-xcode.inc4
-rwxr-xr-xcode_approval.inc6
-rwxr-xr-xdependency.inc2
-rwxr-xr-xdependency_approval.inc2
-rwxr-xr-xeditcode.inc2
-rwxr-xr-xeditcodeadmin.inc2
-rwxr-xr-xmanage_proposal.inc6
-rwxr-xr-xmanage_proposal.inc~1128
-rwxr-xr-x[-rw-r--r--]pdf/fpdf/fonts/certificate-bold.php0
-rwxr-xr-x[-rw-r--r--]pdf/fpdf/fonts/certificate-bold.ttfbin72344 -> 72344 bytes
-rwxr-xr-x[-rw-r--r--]pdf/fpdf/fonts/certificate-bold.zbin36713 -> 36713 bytes
-rwxr-xr-x[-rw-r--r--]pdf/fpdf/tutorial/certificate-bold.ttfbin72344 -> 72344 bytes
-rwxr-xr-xpdf/generate_pdf.inc43
-rwxr-xr-x[-rw-r--r--]pdf/images/garland_logo2.pngbin37271 -> 37271 bytes
-rwxr-xr-x[-rw-r--r--]pdf/images/garland_logo4.pngbin4018 -> 4018 bytes
-rw-r--r--pdf/images/sign.pngbin0 -> 41739 bytes
-rwxr-xr-xrun.inc3
-rwxr-xr-xrun.inc~397
-rwxr-xr-xtextbook_companion.module51
-rwxr-xr-xtextbook_companion.module~1754
23 files changed, 95 insertions, 3315 deletions
diff --git a/.download.inc.swp b/.download.inc.swp
index 601e6fd..601e6fd 100644..100755
--- a/.download.inc.swp
+++ b/.download.inc.swp
Binary files differ
diff --git a/cheque_contact.inc b/cheque_contact.inc
index 5328658..8f882f3 100755
--- a/cheque_contact.inc
+++ b/cheque_contact.inc
@@ -77,7 +77,7 @@ function paper_submission_form_submit($form, &$form_state)
$book_user = user_load($proposal_data->uid);
$param['proposal_completed']['proposal_id'] = $proposal_id;
$param['proposal_completed']['user_id'] = $proposal_data->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $book_user->mail;
if (!drupal_mail('textbook_companion', 'internship_form', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
drupal_set_message('Internship Form for Book proposal has been recieved. User has been notified .', 'status');
@@ -99,7 +99,7 @@ function paper_submission_form_submit($form, &$form_state)
$book_user = user_load($proposal_data->uid);
$param['proposal_completed']['proposal_id'] = $proposal_id;
$param['proposal_completed']['user_id'] = $proposal_data->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $book_user->mail;
if (!drupal_mail('textbook_companion', 'copyrighttransfer_form', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
drupal_set_message('Copyright Form for Book proposal has been recieved. User has been notified .', 'status');
@@ -121,7 +121,7 @@ function paper_submission_form_submit($form, &$form_state)
$book_user = user_load($proposal_data->uid);
$param['proposal_completed']['proposal_id'] = $proposal_id;
$param['proposal_completed']['user_id'] = $proposal_data->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $book_user->mail;
if (!drupal_mail('textbook_companion', 'undertakingform_form', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
drupal_set_message('Undertaking Form for Book proposal has been recieved. User has been notified .', 'status');
@@ -847,7 +847,7 @@ function cheque_status_form_submit($form, &$form_state)
$book_user = user_load($proposal_data->uid);
$param['proposal_completed']['proposal_id'] = $proposal_id;
$param['proposal_completed']['user_id'] = $proposal_data->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $book_user->mail;
if (!drupal_mail('textbook_companion', 'cheque_sent', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
drupal_set_message('Cheque for Book proposal has been Sent. User has been notified .', 'status');
@@ -874,7 +874,7 @@ function cheque_status_form_submit($form, &$form_state)
$book_user = user_load($proposal_data->uid);
$param['proposal_completed']['proposal_id'] = $proposal_id;
$param['proposal_completed']['user_id'] = $proposal_data->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $book_user->mail;
if (!drupal_mail('textbook_companion', 'remark', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
drupal_set_message(t('Remark Updated. User has been notified'), 'status');
diff --git a/cheque_manage.inc b/cheque_manage.inc
index 750874f..750874f 100644..100755
--- a/cheque_manage.inc
+++ b/cheque_manage.inc
diff --git a/code.inc b/code.inc
index 826fa7a..dec53f1 100755
--- a/code.inc
+++ b/code.inc
@@ -532,7 +532,7 @@ function upload_examples_form_submit($form, &$form_state) {
drupal_set_message('Example uploaded successfully.', 'status');
/* sending email */
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $user->mail;
$param['example_uploaded']['example_id'] = $example_id;
$param['example_uploaded']['user_id'] = $user->uid;
if (!drupal_mail('textbook_companion', 'example_uploaded', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
@@ -600,7 +600,7 @@ function _upload_examples_delete()
drupal_set_message('Example deleted.', 'status');
/* sending email */
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $user->mail;
$param['example_deleted_user']['book_title'] = $preference_data->book;
$param['example_deleted_user']['chapter_title'] = $chapter_data->name;
$param['example_deleted_user']['example_number'] = $example_data->number;
diff --git a/code_approval.inc b/code_approval.inc
index c53d5f9..341a34d 100755
--- a/code_approval.inc
+++ b/code_approval.inc
@@ -154,7 +154,7 @@ function code_approval_form_submit($form, &$form_state)
db_query("UPDATE {textbook_companion_example} SET approval_status = 1, approver_uid = %d, approval_date = %d WHERE id = %d", $user->uid, time(), $ex_data['example_id']);
/* sending email */
- $email_to = $user_data->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $user_data->mail;
$param['example_approved']['example_id'] = $ex_data['example_id'];
$param['example_approved']['user_id'] = $user_data->uid;
if (!drupal_mail('textbook_companion', 'example_approved', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
@@ -164,7 +164,7 @@ function code_approval_form_submit($form, &$form_state)
if (delete_example($ex_data['example_id']))
{
/* sending email */
- $email_to = $user_data->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $user_data->mail;
$param['example_disapproved']['example_number'] = $example_data->number;
$param['example_disapproved']['example_caption'] = $example_data->caption;
$param['example_disapproved']['user_id'] = $user_data->uid;
@@ -644,7 +644,7 @@ Reason for dis-approval:
/****** sending email when everything done ******/
if ($email_subject)
{
- $email_to = variable_get('textbook_companion_emails', '') . ', ' . $user->mail;
+ $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))
diff --git a/dependency.inc b/dependency.inc
index 3eae35c..2ecf500 100755
--- a/dependency.inc
+++ b/dependency.inc
@@ -240,7 +240,7 @@ function upload_dependency_form_submit($form, &$form_state) {
$param['dependency_uploaded']['user_id'] = $user->uid;
$param['dependency_uploaded']['dependency_names'] = $dependency_names;
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $user->mail;
if (!drupal_mail('textbook_companion', 'dependency_uploaded', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
}
diff --git a/dependency_approval.inc b/dependency_approval.inc
index cc07fde..4903141 100755
--- a/dependency_approval.inc
+++ b/dependency_approval.inc
@@ -139,7 +139,7 @@ function textbook_companion_dependency_approval_form_submit($form, &$form_state)
/* email */
$email_subject = t('Dependency deleted');
$email_body = t('Dependency deleted : .') . $form_state['values']['run']['dependency'];
- $email_to = variable_get('textbook_companion_emails', '') . ', ' . $user->mail;
+ $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))
diff --git a/editcode.inc b/editcode.inc
index dae3b44..fe7603c 100755
--- a/editcode.inc
+++ b/editcode.inc
@@ -894,7 +894,7 @@ function upload_examples_edit_form_submit($form, &$form_state)
}
/* sending email */
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $user->mail;
$param['example_updated']['example_id'] = $example_id;
$param['example_updated']['user_id'] = $user->uid;
if (!drupal_mail('textbook_companion', 'example_updated', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
diff --git a/editcodeadmin.inc b/editcodeadmin.inc
index 8830285..41f0e83 100755
--- a/editcodeadmin.inc
+++ b/editcodeadmin.inc
@@ -859,7 +859,7 @@ function upload_examples_admin_edit_form_submit($form, &$form_state)
}
/* sending email */
- $email_to = $user_data->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $user_data->mail;
$param['example_updated_admin']['example_id'] = $example_id;
$param['example_updated_admin']['user_id'] = $proposal_data->uid;
if (!drupal_mail('textbook_companion', 'example_updated_admin', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
diff --git a/manage_proposal.inc b/manage_proposal.inc
index 9ef15b4..a4be25e 100755
--- a/manage_proposal.inc
+++ b/manage_proposal.inc
@@ -253,7 +253,7 @@ function proposal_approval_form_submit($form, &$form_state)
$book_user = user_load($row->uid);
$param['proposal_disapproved']['proposal_id'] = $proposal_id;
$param['proposal_disapproved']['user_id'] = $row->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $book_user->mail;
if (!drupal_mail('textbook_companion', 'proposal_disapproved', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
@@ -271,7 +271,7 @@ function proposal_approval_form_submit($form, &$form_state)
$book_user = user_load($row->uid);
$param['proposal_approved']['proposal_id'] = $proposal_id;
$param['proposal_approved']['user_id'] = $row->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $book_user->mail;
if (!drupal_mail('textbook_companion', 'proposal_approved', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
@@ -459,7 +459,7 @@ function proposal_status_form_submit($form, &$form_state)
$book_user = user_load($proposal_data->uid);
$param['proposal_completed']['proposal_id'] = $proposal_id;
$param['proposal_completed']['user_id'] = $proposal_data->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $book_user->mail;
if (!drupal_mail('textbook_companion', 'proposal_completed', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
diff --git a/manage_proposal.inc~ b/manage_proposal.inc~
deleted file mode 100755
index 5c76446..0000000
--- a/manage_proposal.inc~
+++ /dev/null
@@ -1,1128 +0,0 @@
-<?php
-// $Id$
-
-function _proposal_pending()
-{
- /* get pending proposals to be approved */
- $pending_rows = array();
- $pending_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE proposal_status = 0 ORDER BY id DESC");
- while ($pending_data = db_fetch_object($pending_q))
- {
- $pending_rows[$pending_data->id] = array(date('d-m-Y', $pending_data->creation_date), l($pending_data->full_name, 'user/' . $pending_data->uid), date('d-m-Y', $pending_data->completion_date), l('Approve', 'manage_proposal/approve/' . $pending_data->id) . ' | ' . l('Edit', 'manage_proposal/edit/' . $pending_data->id));
- }
-
- /* check if there are any pending proposals */
- if (!$pending_rows)
- {
- drupal_set_message(t('There are no pending proposals.'), 'status');
- return '';
- }
-
- $pending_header = array('Date of Submission', 'Contributor Name', 'Date of Completion', 'Action');
- $output = theme_table($pending_header, $pending_rows);
- return $output;
-}
-
-function _proposal_all()
-{
- /* get pending proposals to be approved */
- $proposal_rows = array();
- $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} ORDER BY id DESC");
- while ($proposal_data = db_fetch_object($proposal_q))
- {
- /* get preference */
- $preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND approval_status = 1 LIMIT 1", $proposal_data->id);
- $preference_data = db_fetch_object($preference_q);
-
- $proposal_status = '';
- switch ($proposal_data->proposal_status)
- {
- case 0: $proposal_status = 'Pending'; break;
- case 1: $proposal_status = 'Approved'; break;
- case 2: $proposal_status = 'Dis-approved'; break;
- case 3: $proposal_status = 'Completed'; break;
- default: $proposal_status = 'Unknown'; break;
- }
- $proposal_rows[] = array(date('d-m-Y', $proposal_data->creation_date), $preference_data->book, $preference_data->author, l($proposal_data->full_name, 'user/' . $proposal_data->uid), date('d-m-Y', $proposal_data->completion_date), $proposal_status, l('Status', 'manage_proposal/status/' . $proposal_data->id) . ' | ' . l('Edit', 'manage_proposal/edit/' . $proposal_data->id));
- }
-
- /* check if there are any pending proposals */
- if (!$proposal_rows)
- {
- drupal_set_message(t('There are no proposals.'), 'status');
- return '';
- }
-
- $proposal_header = array('Date of Submission', 'Title of the Book', 'Author', 'Contributor Name', 'Expected Date of Completion', 'Status');
- $output = theme_table($proposal_header, $proposal_rows);
- return $output;
-}
-
-function _category_all()
-{
- /* get pending proposals to be approved */
- $preference_rows = array();
- $preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE approval_status = 1 ORDER BY id DESC");
- while ($preference_data = db_fetch_object($preference_q))
- {
- switch ($preference_data->category)
- {
- case 0: $category_data = 'Not Selected'; break;
- case 1: $category_data = 'Fluid Mechanics'; break;
- case 2: $category_data = 'Control Theory & Control Systems'; break;
- case 3: $category_data = 'Chemical Engineering'; break;
- case 4: $category_data = 'Thermodynamics'; break;
- case 5: $category_data = 'Mechanical Engineering'; break;
- case 6: $category_data = 'Signal Processing'; break;
- case 7: $category_data = 'Digital Communications'; break;
- case 8: $category_data = 'Electrical Technology'; break;
- case 9: $category_data = 'Mathematics & Pure Science'; break;
- case 10: $category_data = 'Analog Electronics'; break;
- case 11: $category_data = 'Digital Electronics'; break;
- case 12: $category_data = 'Computer Programming'; break;
- case 13: $category_data = 'Others'; break;
- default: $category_data = 'Unknown'; break;
- }
- $preference_rows[] = array($preference_data->book, $preference_data->author, $preference_data->isbn, $preference_data->publisher, $preference_data->edition, $preference_data->year, $category_data, l('Edit', 'manage_proposal/category/edit/' . $preference_data->id));
- }
-
- $preference_header = array('Book', 'Author', 'ISBN', 'Publisher', 'Edition', 'Year', 'Category', 'Status');
- $output = theme_table($preference_header, $preference_rows);
- return $output;
-}
-
-/******************************************************************************/
-/************************** PROPOSAL APPROVAL FORM ****************************/
-/******************************************************************************/
-
-function proposal_approval_form($form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = arg(2);
- $result = db_query("SELECT * FROM {textbook_companion_proposal} WHERE proposal_status = 0 and id = %d", $proposal_id);
- if ($result)
- {
- if ($row = db_fetch_object($result))
- {
- /* everything ok */
- } else {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('manage_proposal');
- return;
- }
- } else {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('manage_proposal');
- return;
- }
-
- $form['full_name'] = array(
- '#type' => 'item',
- '#value' => l($row->full_name, 'user/' . $row->uid),
- '#title' => t('Contributor Name'),
- );
- $form['email'] = array(
- '#type' => 'item',
- '#value' => user_load($row->uid)->mail,
- '#title' => t('Email'),
- );
- $form['mobile'] = array(
- '#type' => 'item',
- '#value' => $row->mobile,
- '#title' => t('Mobile'),
- );
- $form['how_project'] = array(
- '#type' => 'item',
- '#value' => $row->how_project,
- '#title' => t('How did you come to know about this project'),
- );
- $form['course'] = array(
- '#type' => 'item',
- '#value' => $row->course,
- '#title' => t('Course'),
- );
- $form['branch'] = array(
- '#type' => 'item',
- '#value' => $row->branch,
- '#title' => t('Department/Branch'),
- );
- $form['university'] = array(
- '#type' => 'item',
- '#value' => $row->university,
- '#title' => t('University/Institute'),
- );
- $form['faculty'] = array(
- '#type' => 'item',
- '#value' => $row->faculty,
- '#title' => t('College Teacher/Professor'),
- );
- $form['reviewer'] = array(
- '#type' => 'item',
- '#value' => $row->reviewer,
- '#title' => t('Reviewer'),
- );
- $form['completion_date'] = array(
- '#type' => 'item',
- '#value' => date('d-m-Y', $row->completion_date),
- '#title' => t('Expected Date of Completion'),
- );
- $form['operating_system'] = array(
- '#type' => 'item',
- '#value' => $row->operating_system,
- '#title' => t('Operating System'),
- );
- $form['scilab_version'] = array(
- '#type' => 'item',
- '#value' => $row->scilab_version,
- '#title' => t('Scilab Version'),
- );
-
- /* get book preference */
- $preference_rows = array();
- $preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d ORDER BY pref_number ASC", $proposal_id);
- while ($preference_data = db_fetch_object($preference_q))
- {
- $preference_rows[$preference_data->id] = $preference_data->book . ' (Written by ' . $preference_data->author . ')';
- }
-
- $form['book_preference'] = array(
- '#type' => 'radios',
- '#title' => t('Book Preferences'),
- '#options' => $preference_rows,
- );
-
- $form['disapprove'] = array(
- '#type' => 'checkbox',
- '#title' => t('Disapprove all the above book preferences'),
- );
-
- $form['message'] = array(
- '#type' => 'textarea',
- '#title' => t('Reason for disapproval'),
- );
-
- $form['proposal_id'] = array(
- '#type' => 'hidden',
- '#value' => $proposal_id,
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
-
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel'), 'manage_proposal'),
- );
- return $form;
-}
-
-function proposal_approval_form_submit($form, &$form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = $form_state['values']['proposal_id'];
- $result = db_query("SELECT * FROM {textbook_companion_proposal} WHERE proposal_status = 0 and id = %d", $proposal_id);
- if ($result)
- {
- if ($row = db_fetch_object($result))
- {
- /* everything ok */
- } else {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('manage_proposal');
- return;
- }
- } else {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('manage_proposal');
- return;
- }
-
- /* disapprove */
- if ($form_state['values']['disapprove'])
- {
- db_query("UPDATE {textbook_companion_proposal} SET approver_uid = %d, approval_date = %d, proposal_status = 2, message = '%s' WHERE id = %d", $user->uid, time(), $form_state['values']['message'], $proposal_id);
- db_query("UPDATE {textbook_companion_preference} SET approval_status = 2 WHERE proposal_id = %d", $proposal_id);
-
- /* sending email */
- $book_user = user_load($row->uid);
- $param['proposal_disapproved']['proposal_id'] = $proposal_id;
- $param['proposal_disapproved']['user_id'] = $row->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
- if (!drupal_mail('textbook_companion', 'proposal_disapproved', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message('Book proposal dis-approved. User has been notified of the dis-approval.', 'error');
- drupal_goto('manage_proposal');
- return;
- }
-
- /* get book preference and set the status */
- $preference_id = $form_state['values']['book_preference'];
- db_query("UPDATE {textbook_companion_proposal} SET approver_uid = %d, approval_date = %d, proposal_status = 1 WHERE id = %d", $user->uid, time(), $proposal_id);
- db_query("UPDATE {textbook_companion_preference} SET approval_status = 1 WHERE id = %d", $preference_id);
-
- /* sending email */
- $book_user = user_load($row->uid);
- $param['proposal_approved']['proposal_id'] = $proposal_id;
- $param['proposal_approved']['user_id'] = $row->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
- if (!drupal_mail('textbook_companion', 'proposal_approved', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message('Book proposal approved. User has been notified of the approval', 'status');
- drupal_goto('manage_proposal');
- return;
-}
-
-
-/******************************************************************************/
-/*************************** PROPOSAL STATUS FORM *****************************/
-/******************************************************************************/
-
-function proposal_status_form($form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = arg(2);
- $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d", $proposal_id);
- if (!$proposal_data = db_fetch_object($proposal_q))
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('manage_proposal');
- return;
- }
-
- $form['full_name'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->full_name,
- '#title' => t('Contributor Name'),
- );
- $form['email'] = array(
- '#type' => 'item',
- '#value' => user_load($proposal_data->uid)->mail,
- '#title' => t('Email'),
- );
- $form['mobile'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->mobile,
- '#title' => t('Mobile'),
- );
- $form['how_project'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->how_project,
- '#title' => t('How did you come to know about this project'),
- );
- $form['course'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->course,
- '#title' => t('Course'),
- );
- $form['branch'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->branch,
- '#title' => t('Department/Branch'),
- );
- $form['university'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->university,
- '#title' => t('University/Institute'),
- );
- $form['faculty'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->faculty,
- '#title' => t('College Teacher/Professor'),
- );
- $form['reviewer'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->reviewer,
- '#title' => t('Reviewer'),
- );
- $form['completion_date'] = array(
- '#type' => 'item',
- '#value' => date('d-m-Y', $proposal_data->completion_date),
- '#title' => t('Expected Date of Completion'),
- );
- $form['operating_system'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->operating_system,
- '#title' => t('Operating System'),
- );
- $form['scilab_version'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->scilab_version,
- '#title' => t('Scilab Version'),
- );
-
- /* get book preference */
- $preference_html = '<ul>';
- $preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d ORDER BY pref_number ASC", $proposal_id);
- while ($preference_data = db_fetch_object($preference_q))
- {
- if ($preference_data->approval_status == 1)
- $preference_html .= '<li><strong>' . $preference_data->book . ' (Written by ' . $preference_data->author . ') - Approved Book</strong></li>';
- else
- $preference_html .= '<li>' . $preference_data->book . ' (Written by ' . $preference_data->author . ')</li>';
- }
- $preference_html .= '</ul>';
-
- $form['book_preference'] = array(
- '#type' => 'item',
- '#value' => $preference_html,
- '#title' => t('Book Preferences'),
- );
-
- $proposal_status = '';
- switch ($proposal_data->proposal_status)
- {
- case 0: $proposal_status = t('Pending'); break;
- case 1: $proposal_status = t('Approved'); break;
- case 2: $proposal_status = t('Dis-approved'); break;
- case 3: $proposal_status = t('Completed'); break;
- default: $proposal_status = t('Unkown'); break;
- }
- $form['proposal_status'] = array(
- '#type' => 'item',
- '#value' => $proposal_status,
- '#title' => t('Proposal Status'),
- );
-
- if ($proposal_data->proposal_status == 2) {
- $form['message'] = array(
- '#type' => 'item',
- '#value' => $proposal_data->message,
- '#title' => t('Reason for disapproval'),
- );
- }
-
- if ($proposal_data->proposal_status == 1)
- {
- $form['completed'] = array(
- '#type' => 'checkbox',
- '#title' => t('Completed'),
- '#description' => t('Check if user has completed all the book examples.'),
- );
- }
-
- if ($proposal_data->proposal_status == 0)
- {
- $form['approve'] = array(
- '#type' => 'item',
- '#value' => l('Click here', 'manage_proposal/approve/' . $proposal_id),
- '#title' => t('Approve'),
- );
- }
-
- $form['proposal_id'] = array(
- '#type' => 'hidden',
- '#value' => $proposal_id,
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
-
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel'), 'manage_proposal/all'),
- );
- return $form;
-}
-
-function proposal_status_form_submit($form, &$form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = $form_state['values']['proposal_id'];
- $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d", $proposal_id);
- if (!$proposal_data = db_fetch_object($proposal_q))
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('manage_proposal');
- return;
- }
-
- /* set the book status to completed */
- if ($form_state['values']['completed'] == 1)
- {
- db_query("UPDATE {textbook_companion_proposal} SET proposal_status = 3 WHERE id = %d", $proposal_id);
-
- /* sending email */
- $book_user = user_load($proposal_data->uid);
- $param['proposal_completed']['proposal_id'] = $proposal_id;
- $param['proposal_completed']['user_id'] = $proposal_data->uid;
- $email_to = $book_user->mail . ', ' . variable_get('textbook_companion_emails', '');
- if (!drupal_mail('textbook_companion', 'proposal_completed', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message('Congratulations! Book proposal has been marked as completed. User has been notified of the completion.', 'status');
- }
- drupal_goto('manage_proposal');
- return;
-}
-
-
-/******************************************************************************/
-/**************************** PROPOSAL EDIT FORM ******************************/
-/******************************************************************************/
-
-function proposal_edit_form($form_state)
-{
- global $user;
-
- /* get current proposal */
- $proposal_id = arg(2);
- $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d", $proposal_id);
- if ($proposal_q)
- {
- $proposal_data = db_fetch_object($proposal_q);
- if (!$proposal_data)
- {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('manage_proposal');
- return;
- }
- } else {
- drupal_set_message(t('Invalid proposal selected. Please try again.'), 'error');
- drupal_goto('manage_proposal');
- return;
- }
-
- $user_data = user_load($proposal_data->uid);
-
- $preference1_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $proposal_id, 1);
- $preference1_data = db_fetch_object($preference1_q);
- $preference2_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $proposal_id, 2);
- $preference2_data = db_fetch_object($preference2_q);
- $preference3_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $proposal_id, 3);
- $preference3_data = db_fetch_object($preference3_q);
-
- $form['full_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Full Name'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $proposal_data->full_name,
- );
- $form['email_id'] = array(
- '#type' => 'textfield',
- '#title' => t('Email'),
- '#size' => 30,
- '#value' => $user_data->mail,
- '#disabled' => TRUE,
- );
- $form['mobile'] = array(
- '#type' => 'textfield',
- '#title' => t('Mobile No.'),
- '#size' => 30,
- '#maxlength' => 15,
- '#required' => TRUE,
- '#default_value' => $proposal_data->mobile,
- );
- $form['how_project'] = array(
- '#type' => 'select',
- '#title' => t('How did you come to know about this project'),
- '#options' => array('Scilab Website' => 'Scilab Website',
- 'Friend' => 'Friend',
- 'Professor/Teacher' => 'Professor/Teacher',
- 'Mailing List' => 'Mailing List',
- 'Poster in my/other college' => 'Poster in my/other college',
- 'Others' => 'Others'),
- '#required' => TRUE,
- '#default_value' => $proposal_data->how_project,
- );
- $form['course'] = array(
- '#type' => 'textfield',
- '#title' => t('Course'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $proposal_data->course,
- );
- $form['branch'] = array(
- '#type' => 'select',
- '#title' => t('Department/Branch'),
- '#options' => array('Electrical Engineering' => 'Electrical Engineering',
- 'Electronics Engineering' => 'Electronics Engineering',
- 'Computer Engineering' => 'Computer Engineering',
- 'Chemical Engineering' => 'Chemical Engineering',
- 'Instrumentation Engineering' => 'Instrumentation Engineering',
- 'Mechanical Engineering' => 'Mechanical Engineering',
- 'Civil Engineering' => 'Civil Engineering',
- 'Physics' => 'Physics',
- 'Mathematics' => 'Mathematics',
- 'Others' => 'Others'),
- '#required' => TRUE,
- '#default_value' => $proposal_data->branch,
- );
- $form['university'] = array(
- '#type' => 'textfield',
- '#title' => t('University/Institute'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $proposal_data->university,
- );
- $form['faculty'] = array(
- '#type' => 'textfield',
- '#title' => t('College Teacher/Professor'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $proposal_data->faculty,
- );
- $form['reviewer'] = array(
- '#type' => 'textfield',
- '#title' => t('Reviewer'),
- '#size' => 30,
- '#maxlength' => 100,
- '#default_value' => $proposal_data->reviewer,
- );
- $form['completion_date'] = array(
- '#type' => 'textfield',
- '#title' => t('Expected Date of Completion'),
- '#description' => t('Input date format should be DD-MM-YYYY. Eg: 23-03-2011'),
- '#size' => 10,
- '#maxlength' => 10,
- '#default_value' => date('d-m-Y', $proposal_data->completion_date),
- );
- $form['scilab_version'] = array(
- '#type' => 'textfield',
- '#title' => t('Scilab Version'),
- '#size' => 10,
- '#maxlength' => 10,
- '#default_value' => $proposal_data->scilab_version,
- );
- $form['operating_system'] = array(
- '#type' => 'textfield',
- '#title' => t('Operating System'),
- '#size' => 30,
- '#maxlength' => 50,
- '#default_value' => $proposal_data->operating_system,
- );
- $form['preference1'] = array(
- '#type' => 'fieldset',
- '#title' => t('Book Preference 1'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['preference1']['book1'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the book'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $preference1_data->book,
- );
- $form['preference1']['author1'] = array(
- '#type' => 'textfield',
- '#title' => t('Author Name'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $preference1_data->author,
- );
- $form['preference1']['isbn1'] = array(
- '#type' => 'textfield',
- '#title' => t('ISBN No'),
- '#size' => 30,
- '#maxlength' => 25,
- '#required' => TRUE,
- '#default_value' => $preference1_data->isbn,
- );
- $form['preference1']['publisher1'] = array(
- '#type' => 'textfield',
- '#title' => t('Publisher & Place'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $preference1_data->publisher,
- );
- $form['preference1']['edition1'] = array(
- '#type' => 'textfield',
- '#title' => t('Edition'),
- '#size' => 4,
- '#maxlength' => 2,
- '#required' => TRUE,
- '#default_value' => $preference1_data->edition,
- );
- $form['preference1']['year1'] = array(
- '#type' => 'textfield',
- '#title' => t('Year of pulication'),
- '#size' => 4,
- '#maxlength' => 4,
- '#required' => TRUE,
- '#default_value' => $preference1_data->year,
- );
- $form['preference2'] = array(
- '#type' => 'fieldset',
- '#title' => t('Book Preference 2'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['preference2']['book2'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the book'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $preference2_data->book,
- );
- $form['preference2']['author2'] = array(
- '#type' => 'textfield',
- '#title' => t('Author Name'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $preference2_data->author,
- );
- $form['preference2']['isbn2'] = array(
- '#type' => 'textfield',
- '#title' => t('ISBN No'),
- '#size' => 30,
- '#maxlength' => 25,
- '#required' => TRUE,
- '#default_value' => $preference2_data->isbn,
- );
- $form['preference2']['publisher2'] = array(
- '#type' => 'textfield',
- '#title' => t('Publisher & Place'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $preference2_data->publisher,
- );
- $form['preference2']['edition2'] = array(
- '#type' => 'textfield',
- '#title' => t('Edition'),
- '#size' => 4,
- '#maxlength' => 2,
- '#required' => TRUE,
- '#default_value' => $preference2_data->edition,
- );
- $form['preference2']['year2'] = array(
- '#type' => 'textfield',
- '#title' => t('Year of pulication'),
- '#size' => 4,
- '#maxlength' => 4,
- '#required' => TRUE,
- '#default_value' => $preference2_data->year,
- );
- $form['preference3'] = array(
- '#type' => 'fieldset',
- '#title' => t('Book Preference 3'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['preference3']['book3'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the book'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $preference3_data->book,
- );
- $form['preference3']['author3'] = array(
- '#type' => 'textfield',
- '#title' => t('Author Name'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $preference3_data->author,
- );
- $form['preference3']['isbn3'] = array(
- '#type' => 'textfield',
- '#title' => t('ISBN No'),
- '#size' => 30,
- '#maxlength' => 25,
- '#required' => TRUE,
- '#default_value' => $preference3_data->isbn,
- );
- $form['preference3']['publisher3'] = array(
- '#type' => 'textfield',
- '#title' => t('Publisher & Place'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $preference3_data->publisher,
- );
- $form['preference3']['edition3'] = array(
- '#type' => 'textfield',
- '#title' => t('Edition'),
- '#size' => 4,
- '#maxlength' => 2,
- '#required' => TRUE,
- '#default_value' => $preference3_data->edition,
- );
- $form['preference3']['year3'] = array(
- '#type' => 'textfield',
- '#title' => t('Year of pulication'),
- '#size' => 4,
- '#maxlength' => 4,
- '#required' => TRUE,
- '#default_value' => $preference3_data->year,
- );
-
- /* hidden fields */
- $form['hidden_proposal_id'] = array(
- '#type' => 'hidden',
- '#value' => $proposal_id,
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel'), 'manage_proposal'),
- );
- return $form;
-}
-
-function proposal_edit_form_validate($form, &$form_state)
-{
- /* mobile */
- if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['mobile']))
- form_set_error('mobile', t('Invalid mobile number'));
-
- /* date of completion */
- if (!preg_match('/^[0-9]{1,2}-[0-9]{1,2}-[0-9]{4}$/', $form_state['values']['completion_date']))
- form_set_error('completion_date', t('Invalid expected date of completion'));
-
- list($d, $m, $y) = explode('-', $form_state['values']['completion_date']);
- $d = (int)$d; $m = (int)$m; $y = (int)$y;
- if (!checkdate($m, $d, $y))
- form_set_error('completion_date', t('Invalid expected date of completion'));
- //if (mktime(0, 0, 0, $m, $d, $y) <= time())
- //form_set_error('completion_date', t('Expected date of completion should be in future'));
-
- /* edition */
- if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition1']))
- form_set_error('edition1', t('Invalid edition for Book Preference 1'));
- if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition2']))
- form_set_error('edition2', t('Invalid edition for Book Preference 2'));
- if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition3']))
- form_set_error('edition3', t('Invalid edition for Book Preference 3'));
-
- /* year of publication */
- if (!preg_match('/^[1-3][0-9][0-9][0-9]$/', $form_state['values']['year1']))
- form_set_error('year1', t('Invalid year of pulication for Book Preference 1'));
- if (!preg_match('/^[1-3][0-9][0-9][0-9]$/', $form_state['values']['year2']))
- form_set_error('year2', t('Invalid year of pulication for Book Preference 2'));
- if (!preg_match('/^[1-3][0-9][0-9][0-9]$/', $form_state['values']['year3']))
- form_set_error('year3', t('Invalid year of pulication for Book Preference 3'));
-
- /* year of publication */
- $cur_year = date('Y');
- if ((int)$form_state['values']['year1'] > $cur_year)
- form_set_error('year1', t('Year of pulication should be not in the future for Book Preference 1'));
- if ((int)$form_state['values']['year2'] > $cur_year)
- form_set_error('year2', t('Year of pulication should be not in the future for Book Preference 2'));
- if ((int)$form_state['values']['year3'] > $cur_year)
- form_set_error('year3', t('Year of pulication should be not in the future for Book Preference 3'));
-
- /* isbn */
- if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn1']))
- form_set_error('isbn1', t('Invalid ISBN for Book Preference 1'));
- if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn2']))
- form_set_error('isbn2', t('Invalid ISBN for Book Preference 2'));
- if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn3']))
- form_set_error('isbn3', t('Invalid ISBN for Book Preference 3'));
- return;
-}
-
-function proposal_edit_form_submit($form, &$form_state)
-{
- /* completion date to timestamp */
- list($d, $m, $y) = explode('-', $form_state['values']['completion_date']);
- $completion_date_timestamp = mktime(0, 0, 0, $m, $d, $y);
-
- $proposal_id = $form_state['values']['hidden_proposal_id'];
-
- db_query("UPDATE {textbook_companion_proposal} SET full_name = '%s', mobile = '%s', how_project = '%s', course = '%s', branch = '%s', university = '%s', faculty = '%s', reviewer = '%s', completion_date = %d, operating_system= '%s', scilab_version= '%s' WHERE id = %d",
- $form_state['values']['full_name'],
- $form_state['values']['mobile'],
- $form_state['values']['how_project'],
- $form_state['values']['course'],
- $form_state['values']['branch'],
- $form_state['values']['university'],
- $form_state['values']['faculty'],
- $form_state['values']['reviewer'],
- $completion_date_timestamp,
- $form_state['values']['operating_system'],
- $form_state['values']['scilab_version'],
- $proposal_id);
-
- $preference1_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $proposal_id, 1);
- $preference1_data = db_fetch_object($preference1_q);
- if ($preference1_data)
- $preference1_id = $preference1_data->id;
- $preference2_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $proposal_id, 2);
- $preference2_data = db_fetch_object($preference2_q);
- if ($preference2_data)
- $preference2_id = $preference2_data->id;
- $preference3_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $proposal_id, 3);
- $preference3_data = db_fetch_object($preference3_q);
- if ($preference3_data)
- $preference3_id = $preference3_data->id;
-
- if ($preference1_data)
- {
- del_book_pdf($preference1_data->id);
- db_query("UPDATE {textbook_companion_preference} SET book = '%s', author = '%s', isbn = '%s', publisher = '%s', edition = %d, year = %d WHERE id = %d",
- $form_state['values']['book1'],
- $form_state['values']['author1'],
- $form_state['values']['isbn1'],
- $form_state['values']['publisher1'],
- $form_state['values']['edition1'],
- $form_state['values']['year1'],
- $preference1_id);
- }
- if ($preference2_data)
- {
- del_book_pdf($preference2_data->id);
- db_query("UPDATE {textbook_companion_preference} SET book = '%s', author = '%s', isbn = '%s', publisher = '%s', edition = %d, year = %d WHERE id = %d",
- $form_state['values']['book2'],
- $form_state['values']['author2'],
- $form_state['values']['isbn2'],
- $form_state['values']['publisher2'],
- $form_state['values']['edition2'],
- $form_state['values']['year2'],
- $preference2_id);
- }
- if ($preference3_data)
- {
- del_book_pdf($preference3_data->id);
- db_query("UPDATE {textbook_companion_preference} SET book = '%s', author = '%s', isbn = '%s', publisher = '%s', edition = %d, year = %d WHERE id = %d",
- $form_state['values']['book3'],
- $form_state['values']['author3'],
- $form_state['values']['isbn3'],
- $form_state['values']['publisher3'],
- $form_state['values']['edition3'],
- $form_state['values']['year3'],
- $preference3_id);
- }
- drupal_set_message(t('Proposal Updated'), 'status');
-}
-
-
-
-/******************************************************************************/
-/**************************** CATEGORY EDIT FORM ******************************/
-/******************************************************************************/
-
-function category_edit_form($form_state)
-{
- /* get current proposal */
- $preference_id = arg(3);
- $preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE id = %d", $preference_id);
- $preference_data = db_fetch_object($preference_q);
- if (!$preference_data)
- {
- drupal_set_message(t('Invalid book selected. Please try again.'), 'error');
- drupal_goto('manage_proposal/category');
- return;
- }
-
- $form['book'] = array(
- '#type' => 'item',
- '#title' => t('Title of the book'),
- '#value' => $preference_data->book,
- );
- $form['author'] = array(
- '#type' => 'item',
- '#title' => t('Author Name'),
- '#value' => $preference_data->author,
- );
- $form['isbn'] = array(
- '#type' => 'item',
- '#title' => t('ISBN No'),
- '#value' => $preference_data->isbn,
- );
- $form['publisher'] = array(
- '#type' => 'item',
- '#title' => t('Publisher & Place'),
- '#value' => $preference_data->publisher,
- );
- $form['edition'] = array(
- '#type' => 'item',
- '#title' => t('Edition'),
- '#value' => $preference_data->edition,
- );
- $form['year'] = array(
- '#type' => 'item',
- '#title' => t('Year of pulication'),
- '#value' => $preference_data->year,
- );
-
- $form['category'] = array(
- '#type' => 'select',
- '#title' => t('Category'),
- '#options' => array(0 => 'Please select',
- 1 => 'Fluid Mechanics',
- 2 => 'Control Theory & Control Systems',
- 3 => 'Chemical Engineering',
- 4 => 'Thermodynamics',
- 5 => 'Mechanical Engineering',
- 6 => 'Signal Processing',
- 7 => 'Digital Communications',
- 8 => 'Electrical Technology',
- 9 => 'Mathematics & Pure Science',
- 10 => 'Analog Electronics',
- 11 => 'Digital Electronics',
- 12 => 'Computer Programming',
- 13 => 'Others'),
- '#required' => TRUE,
- '#default_value' => $preference_data->category,
- );
-
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- $form['cancel'] = array(
- '#type' => 'markup',
- '#value' => l(t('Cancel'), 'manage_proposal/category'),
- );
- return $form;
-}
-
-function category_edit_form_submit($form, &$form_state)
-{
- /* get current proposal */
- $preference_id = (int)arg(3);
- $preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE id = %d", $preference_id);
- $preference_data = db_fetch_object($preference_q);
- if (!$preference_data)
- {
- drupal_set_message(t('Invalid book selected. Please try again.'), 'error');
- drupal_goto('manage_proposal/category');
- return;
- }
-
- db_query("UPDATE {textbook_companion_preference} SET category = %d WHERE id = %d", $form_state['values']['category'], $preference_data->id);
-
- drupal_set_message(t('Book Category Updated'), 'status');
- drupal_goto('manage_proposal/category');
-}
-
-/****************************************************************/
-/* Data entry forms */
-/****************************************************************/
-
-function _data_entry_proposal_all()
-{
- /* get pending proposals to be approved */
- $proposal_rows = array();
- $preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE approval_status = 1 ORDER BY book ASC");
- $sno = 1;
- while ($preference_data = db_fetch_object($preference_q))
- {
- $proposal_rows[] = array($sno++, $preference_data->book, $preference_data->author, $preference_data->isbn, l('Edit', 'dataentry_edit/' . $preference_data->id));
- }
-
- /* check if there are any pending proposals */
- if (!$proposal_rows)
- {
- drupal_set_message(t('There are no proposals.'), 'status');
- return '';
- }
-
- $proposal_header = array('SNO', 'Title of the Book', 'Author', 'ISBN', '');
- $output = theme_table($proposal_header, $proposal_rows);
- return $output;
-}
-
-function dataentry_edit($id = NULL) {
- if($id) {
- return drupal_get_form('dataentry_edit_form', $id);
- }else {
- return 'Access denied';
- }
-}
-
-function dataentry_edit_form($form_state, $id)
-{
- global $user;
-
- $preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE id = %d", $id);
- $preference_data = db_fetch_object($preference_q);
-
- $form['id'] = array(
- '#type' => 'hidden',
- '#required' => TRUE,
- '#value' => $id,
- );
- $form['book'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the book'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $preference_data->book,
- );
- $form['author'] = array(
- '#type' => 'textfield',
- '#title' => t('Author Name'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#default_value' => $preference_data->author,
- );
- $form['isbn'] = array(
- '#type' => 'textfield',
- '#title' => t('ISBN No'),
- '#size' => 30,
- '#maxlength' => 25,
- '#required' => TRUE,
- '#attribute' => array('readonly' => 'readonly'),
- '#default_value' => $preference_data->isbn,
- );
- $form['publisher'] = array(
- '#type' => 'textfield',
- '#title' => t('Publisher & Place'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#default_value' => $preference_data->publisher,
- );
- $form['edition'] = array(
- '#type' => 'textfield',
- '#title' => t('Edition'),
- '#size' => 4,
- '#maxlength' => 2,
- '#required' => TRUE,
- '#default_value' => $preference_data->edition,
- );
- $form['year'] = array(
- '#type' => 'textfield',
- '#title' => t('Year of pulication'),
- '#size' => 4,
- '#maxlength' => 4,
- '#required' => TRUE,
- '#default_value' => $preference_data->year,
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
-
- return $form;
-}
-
-function dataentry_edit_form_submit($form, &$form_state)
-{
- db_query("UPDATE {textbook_companion_preference} SET book = '%s', author = '%s', isbn = '%s', publisher = '%s', edition = '%s', year = %d WHERE id = %d", $_POST['book'], $_POST['author'], $_POST['isbn'], $_POST['publisher'], $_POST['edition'], $_POST['year'], $_POST['id']);
- drupal_set_message('Book details updated successfully');
- drupal_goto('dataentry_book');
-}
diff --git a/pdf/fpdf/fonts/certificate-bold.php b/pdf/fpdf/fonts/certificate-bold.php
index 5ffea88..5ffea88 100644..100755
--- a/pdf/fpdf/fonts/certificate-bold.php
+++ b/pdf/fpdf/fonts/certificate-bold.php
diff --git a/pdf/fpdf/fonts/certificate-bold.ttf b/pdf/fpdf/fonts/certificate-bold.ttf
index 29d2792..29d2792 100644..100755
--- a/pdf/fpdf/fonts/certificate-bold.ttf
+++ b/pdf/fpdf/fonts/certificate-bold.ttf
Binary files differ
diff --git a/pdf/fpdf/fonts/certificate-bold.z b/pdf/fpdf/fonts/certificate-bold.z
index f7d88fc..f7d88fc 100644..100755
--- a/pdf/fpdf/fonts/certificate-bold.z
+++ b/pdf/fpdf/fonts/certificate-bold.z
Binary files differ
diff --git a/pdf/fpdf/tutorial/certificate-bold.ttf b/pdf/fpdf/tutorial/certificate-bold.ttf
index 29d2792..29d2792 100644..100755
--- a/pdf/fpdf/tutorial/certificate-bold.ttf
+++ b/pdf/fpdf/tutorial/certificate-bold.ttf
Binary files differ
diff --git a/pdf/generate_pdf.inc b/pdf/generate_pdf.inc
index 9e30109..2e222d8 100755
--- a/pdf/generate_pdf.inc
+++ b/pdf/generate_pdf.inc
@@ -25,34 +25,37 @@
$pdf->Line(270.0,210.0,270.0,7.0);
$pdf->Line(7.0,210.0,270.0,210.0);
- //$pdf->Image("http://10.118.248.101/scilab_in/sites/all/modules/textbook_companion/pdf/images/garland_logo.png", 10, 9, 0, 15);
+ $pdf->Image("/Sites/scilab_in/sites/default/files/scilab_logo.png", 10, 9, 0, 15);
$path = drupal_get_path('module', 'textbook_companion');
$pdf->Image($path."/pdf/images/fossee.png", 232, 9, 0, 15);
$pdf->SetFont('Arial','B',25);
$pdf->Ln(30);
$pdf->Cell(240,8,'Certificate', 0,1,'C');
-
+ $pdf->Ln(5);
$pdf->SetFont('Arial','B',12);
- $pdf->Cell(240,8,'Textbook Companion Project', '0','1','C');
+ $pdf->Cell(240,8,'Textbook Companion', '0','1','C');
$pdf->Ln(20);
- $pdf->Cell(240,8,'IIT Bombay', '0','1','C');
+ //$pdf->Cell(240,8,'IIT Bombay', '0','1','C');
$pdf->SetFont('Arial','',12);
if(strtolower($data3->branch)!="others")
{
- $pdf->MultiCell(240,8,'This is to certify that Mr. /Ms. '.$data3->full_name.'from the Department Of '.$data3->branch.' '.$data3->university.' Universty has sucessfully completed training under the Textbook Companion Project for a duration equivalent to six weeks.He/She has coded, in Scilab, all the solved examples of the alloted textbook: '.$data2->book, 0);
+ $pdf->MultiCell(240,8,'This is to certify that Mr./Ms. '.$data3->full_name.' from the Department of '.$data3->branch.', '.$data3->university.' has successfully completed Internship under Scilab Textbook Companion for a duration equivalent to six weeks. He/She has coded, in Scilab, all the solved examples of the allotted textbook: '.$data2->book.' by '.$data2->author.'.', 0);
}
else
{
- $pdf->MultiCell(240,8,'This is to certify that Mr. /Ms. '.$data3->full_name.' from '.$data3->university.' Universty has sucessfully completed training under the Textbook Companion Project for a duration equivalent to six weeks.He/She has coded, in Scilab, all the solved examples of the alloted textbook: '.$data2->book, 0);
+ $pdf->MultiCell(240,8,'This is to certify that Mr. /Ms. '.$data3->full_name.' from '.$data3->university.' has successfully completed training under Scilab Textbook Companion for a duration equivalent to six weeks.He/She has coded, in Scilab, all the solved examples of the allotted textbook: '.$data2->book.' by '.$data2->author.'.', 0);
} $pdf->Cell(10,10,'The work done is available at ', '0','0','L');
$pdf->SetX(75);
$pdf->SetFont('','U');
$pdf->SetTextColor(0,0,255);
$pdf->write(10,'http://scilab.in','http://scilab.in');
+ $pdf->SetFont('','');
+ $pdf->SetTextColor(0,0,0);
+ $pdf->write(10,'.','.');
$pdf->Ln(10);
@@ -62,25 +65,35 @@
$pdf->SetX(170);
$pdf->SetFont('','U');
+ $pdf->SetTextColor(0,0,255);
+ $pdf->write(10,'http://fossee.in','http://fossee.in');
+
+ $pdf->SetX(198);
+ $pdf->SetFont('','');
$pdf->SetTextColor(0,0,0);
- $pdf->write(10,'http://fossee.in)','http://fossee.in');
+ $pdf->write(10,').');
- $pdf->SetY(165);
+ $pdf->SetY(-50);
$pdf->SetX(209);
+ $pdf->SetTextColor(0,0,0);
$pdf->SetFont('','B');
- $pdf->Cell(0,10,'Prof. Madhu Belur', 0,1,'L');
-
- $pdf->SetX(201);
- $pdf->Cell(0,10,'Electrical Engineering Dept.', 0,1,'L');
+ $pdf->Image($path."/pdf/images/sign.png", 212, 151, 0, 15);
+ //$pdf->SetX(206);
+ $pdf->Cell(0,7,'Prof. Madhu Belur', 0,1,'L');
+ $pdf->SetX(195);
+ $pdf->Cell(0,7,'Principal Investigator - FOSSEE',0,1,'L');
+ $pdf->SetX(195);
+ $pdf->Cell(0,7,' Dept. of Electrical Engineering', 0,1,'L');
- $pdf->SetX(200);
- $pdf->Cell(0,10,'FOSSEE Project, IIT Bombay', 0,1,'L');
+ $pdf->SetX(216);
+ $pdf->Cell(0,7,'IIT Bombay', 0,1,'L');
- $cur_date=date('Y-m-d');
+ $cur_date=date('jS F, Y');
$pdf->SetY(180);
$pdf->SetFont('','');
$pdf->Cell(200,0,' Date: '.$cur_date.'',0,1,'L');
+ //$pdf->Cell(200,0,' Date: 28th August, 2013',0,1,'L');
$pdf->Cell(200,15,'Email: textbook@scilab.in', 0,1,'L');
$pdf->Output();
}
diff --git a/pdf/images/garland_logo2.png b/pdf/images/garland_logo2.png
index 0ea0ac3..0ea0ac3 100644..100755
--- a/pdf/images/garland_logo2.png
+++ b/pdf/images/garland_logo2.png
Binary files differ
diff --git a/pdf/images/garland_logo4.png b/pdf/images/garland_logo4.png
index fdbc1b6..fdbc1b6 100644..100755
--- a/pdf/images/garland_logo4.png
+++ b/pdf/images/garland_logo4.png
Binary files differ
diff --git a/pdf/images/sign.png b/pdf/images/sign.png
new file mode 100644
index 0000000..974f493
--- /dev/null
+++ b/pdf/images/sign.png
Binary files differ
diff --git a/run.inc b/run.inc
index 58f71b0..54a33e1 100755
--- a/run.inc
+++ b/run.inc
@@ -341,7 +341,8 @@ function textbook_companion_run_form_submit($form, &$form_state)
$param['feedback_received']['example_no'] = $example_data->number;
$param['feedback_received']['feedback'] = $form_state['values']['run']['feedback'];
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');// . ', ' . user_load($proposal_data->uid)->mail. ', ' . user_load($example_data->approver_uid)->mail;
+ $email_to = $user->mail;
+ // . ', ' . user_load($proposal_data->uid)->mail. ', ' . user_load($example_data->approver_uid)->mail;
if (!drupal_mail('textbook_companion', 'feedback_received', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
drupal_set_message('Error sending email message.', 'error');
diff --git a/run.inc~ b/run.inc~
deleted file mode 100755
index 6274985..0000000
--- a/run.inc~
+++ /dev/null
@@ -1,397 +0,0 @@
-<?php
-// $Id$
-
-function textbook_companion_run_form($form_state)
-{
- $form['#redirect'] = FALSE;
-
- ahah_helper_register($form, $form_state);
-
- /* default value for ahah fields */
- if (!isset($form_state['storage']['run']['category']))
- {
- /* get the book id from url */
- $url_book_id = (int)arg(1);
- if ($url_book_id)
- {
- /* add javascript for book selected */
- $chapter_name_js = " $(document).ready(function() {
- $('#edit-run-category').val(" . $url_book_id . ");
- $('#edit-run-category').change();
- });";
- drupal_add_js($chapter_name_js, 'inline', 'footer');
- } else {
- $category_default_value = 0;
- }
- } else {
- $category_default_value = $form_state['storage']['run']['category'];
- }
-
- if (!isset($form_state['storage']['run']['chapter']))
- {
- $chapter_default_value = 0;
- } else {
- if ($form_state['values']['run']['book_hidden'] != $form_state['values']['run']['book'])
- $chapter_default_value = 0;
- else
- $chapter_default_value = $form_state['storage']['run']['chapter'];
- }
-
- if (!isset($form_state['storage']['run']['example']))
- {
- $example_default_value = 0;
- } else {
- if ($form_state['values']['run']['book_hidden'] != $form_state['values']['run']['book'])
- $example_default_value = 0;
- else if ($form_state['values']['run']['chapter_hidden'] != $form_state['values']['run']['chapter'])
- $example_default_value = 0;
- else
- $example_default_value = $form_state['storage']['run']['example'];
- }
-
- $form['run'] = array(
- '#type' => 'fieldset',
- '#title' => t('Run Book Example'),
- '#collapsible' => FALSE,
- '#collapsed' => FALSE,
- '#prefix' => '<div id="run-wrapper">',
- '#suffix' => '</div>',
- '#tree' => TRUE,
- );
-
-$form['run']['category'] = array(
- '#type' => 'select',
- '#title' => t('Category'),
- '#options' => array(0 => 'Please select',
- 1 => 'Fluid Mechanics',
- 2 => 'Control Theory & Control Systems',
- 3 => 'Chemical Engineering',
- 4 => 'Thermodynamics',
- 5 => 'Mechanical Engineering',
- 6 => 'Signal Processing',
- 7 => 'Digital Communications',
- 8 => 'Electrical Technology',
- 9 => 'Mathematics & Pure Science',
- 10 => 'Analog Electronics',
- 11 => 'Digital Electronics',
- 12 => 'Computer Programming',
- 13 => 'Others'),
-
- '#tree' => TRUE,
- '#ahah' => array(
- 'event' => 'change',
- 'effect' => 'none',
- 'path' => ahah_helper_path(array('run')),
- 'wrapper' => 'run-wrapper',
- 'progress' => array(
- 'type' => 'throbber',
- 'message' => t(''),
- ),
- ),
- );
-if (isset($form_state['values']['run']['category']))
- {
- $form['run']['category']['#default_value'] = $form_state['values']['run']['category'];
- $category_default_value = $form_state['values']['run']['category'];
- }
-if ($category_default_value > 0)
- {
- $form['run']['book'] = array(
- '#type' => 'select',
- '#title' => t('Title of the Book'),
- '#options' => _list_of_books($category_default_value),
-// '#default_value' => $book_default_value,
- '#tree' => TRUE,
- '#ahah' => array(
- 'event' => 'change',
- 'effect' => 'none',
- 'path' => ahah_helper_path(array('run')),
- 'wrapper' => 'run-wrapper',
- 'progress' => array(
- 'type' => 'throbber',
- 'message' => t(''),
- ),
- ),
- );
-if (isset($form_state['values']['run']['book']))
- {
- $form['run']['book']['#default_value'] = $form_state['values']['run']['book'];
- $book_default_value = $form_state['values']['run']['book'];
- }
-
- /* hidden form elements */
- $form['run']['book_hidden'] = array(
- '#type' => 'hidden',
- '#value' => $form_state['values']['run']['book'],
- );
-
- /* hidden form elements */
- $form['run']['chapter_hidden'] = array(
- '#type' => 'hidden',
- '#value' => $form_state['values']['run']['chapter'],
- );
-
- if ($book_default_value > 0)
- {
- $book_details = _book_information($book_default_value);
- $form['run']['book_details'] = array(
- '#type' => 'item',
- '#value' => '<table cellspacing="1" cellpadding="1" border="0" style="width: 100%;" valign="top">' .
- '<tr><td style="width: 35%;"><span style="color: rgb(128, 0, 0);"><strong>About the Book</strong></span></td><td style="width: 35%;"><span style="color: rgb(128, 0, 0);"><strong>About the Contributor</strong></span></td>' .
- '<tr><td valign="top"><ul>' .
- '<li><strong>Author:</strong> ' . $book_details->preference_author . '</li>' .
- '<li><strong>Title of the Book:</strong> ' . $book_details->preference_book . '</li>' .
- '<li><strong>Publisher:</strong> ' . $book_details->preference_publisher . '</li>' .
- '<li><strong>Year:</strong> ' . $book_details->preference_year . '</li>' .
- '<li><strong>Edition:</strong> ' . $book_details->preference_edition . '</li>' .
- '</ul></td><td valign="top"><ul>' .
- '<li><strong>Contributor Name: </strong>' . $book_details->proposal_full_name . ', ' . $book_details->proposal_course . ', ' . $book_details->proposal_branch . ', ' . $book_details->proposal_university . '</li>' .
- '<li><strong>College Teacher: </strong>' . $book_details->proposal_faculty . '</li>' .
- '<li><strong>Reviewer: </strong>' . $book_details->proposal_reviewer . '</li>' .
- '</ul></td></tr>' .
- '</table>',
- );
-
- $form['run']['download_book'] = array(
- '#type' => 'item',
- '#value' => l('Download', 'download/book/' . $book_default_value) . ' ' . t('(Download all the examples of the entire book)'),
- );
-
- $form['run']['download_book_pdf'] = array(
- '#type' => 'item',
- '#value' => l('Download PDF', 'textbook_companion/generate_book/' . $book_default_value) . ' ' . t('(Download PDF for all examples of the entire book)'),
- );
-
- $form['run']['chapter'] = array(
- '#type' => 'select',
- '#title' => t('Title of the Chapter'),
- '#options' => _list_of_chapters($book_default_value),
- '#default_value' => $chapter_default_value,
- '#tree' => TRUE,
- '#ahah' => array(
- 'event' => 'change',
- 'effect' => 'none',
- 'path' => ahah_helper_path(array('run')),
- 'wrapper' => 'run-wrapper',
- 'progress' => array(
- 'type' => 'throbber',
- 'message' => t(''),
- ),
- ),
- );
- if ($chapter_default_value > 0)
- {
- $form['run']['download_chapter'] = array(
- '#type' => 'item',
- '#value' => l('Download', 'download/chapter/' . $chapter_default_value) . ' ' . t('(Download all the examples of the entire chapter)'),
- );
- $form['run']['example'] = array(
- '#type' => 'select',
- '#title' => t('Example No. (Caption)'),
- '#options' => _list_of_examples($chapter_default_value),
- '#default_value' => $example_default_value,
- '#tree' => TRUE,
- '#ahah' => array(
- 'event' => 'change',
- 'effect' => 'none',
- 'path' => ahah_helper_path(array('run')),
- 'wrapper' => 'run-wrapper',
- 'progress' => array(
- 'type' => 'throbber',
- 'message' => t(''),
- ),
- ),
- );
- }
- }
-
- /* hidden form elements */
- $form['run']['update_book'] = array(
- '#type' => 'submit',
- '#value' => t('Update'),
- '#submit' => array('ahah_helper_generic_submit'),
- '#attributes' => array('class' => 'no-js'),
- );
-
- $form['run']['update_chapter'] = array(
- '#type' => 'submit',
- '#value' => t('Update'),
- '#submit' => array('ahah_helper_generic_submit'),
- '#attributes' => array('class' => 'no-js'),
- );
-
- /************ START OF $_POST **************/
- if ($_POST)
- {
- if (($book_default_value > 0) && ($chapter_default_value > 0) && ($example_default_value > 0))
- {
- $example_list_q = db_query("SELECT * FROM {textbook_companion_example_files} WHERE example_id = %d", $form_state['values']['run']['example']);
- if ($example_list_q)
- {
- $example_files_rows = array();
- while ($example_list_data = db_fetch_object($example_list_q))
- {
- $example_file_type = '';
- switch ($example_list_data->filetype)
- {
- case 'S' : $example_file_type = 'Source or Main file'; break;
- case 'R' : $example_file_type = 'Result file'; break;
- case 'X' : $example_file_type = 'xcos file'; break;
- default : $example_file_type = 'Unknown'; break;
- }
- $example_files_rows[] = array(l($example_list_data->filename, 'download/file/' . $example_list_data->id), $example_file_type);
- }
-
- /* dependency files */
- $dependency_list_q = db_query("SELECT dependency.id as dependency_id, dependency.filename as dependency_filename, dependency.caption as dependency_caption
- FROM {textbook_companion_example_dependency} example_dependency LEFT JOIN {textbook_companion_dependency_files} dependency
- ON example_dependency.dependency_id = dependency.id
- WHERE example_dependency.example_id = %d", $form_state['values']['run']['example']);
- while ($dependency_list_data = db_fetch_object($dependency_list_q))
- {
- $example_file_type = 'Dependency file';
- $temp_caption = '';
- if ($dependency_list_data->dependency_caption)
- $temp_caption = ' (' . $dependency_list_data->dependency_caption . ')';
- $example_files_rows[] = array(l($dependency_list_data->dependency_filename, 'download/dependency/' . $dependency_list_data->dependency_id) . $temp_caption, $example_file_type);
- }
-
- /* creating list of files table */
- $example_files_header = array('Filename', 'Type');
- $example_files = theme_table($example_files_header, $example_files_rows);
- }
- $form['run']['download_example'] = array(
- '#type' => 'item',
- '#value' => l('Download Example', 'download/example/' . $example_default_value),
- );
- $form['run']['example_files'] = array(
- '#type' => 'item',
- '#title' => 'List of example files',
- '#value' => $example_files,
- );
- //$form['run']['submit'] = array(
- // '#type' => 'submit',
- // '#value' => t('Run')
- //);
- if (user_access('create feedback'))
- {
- $form['run']['feedback'] = array(
- '#type' => 'textarea',
- '#title' => t('Feedback on the above example')
- );
- $form['run']['feedback_submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- }
- }
- }
- /************ END OF $_POST **************/
-}
- return $form;
-
-}
-
-function textbook_companion_run_form_submit($form, &$form_state)
-{
- global $user;
-
- if ($form_state['clicked_button']['#value'] == 'Submit')
- {
- if (user_access('create feedback'))
- {
- $example_data = db_fetch_object(db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d", $form_state['values']['run']['example']));
- if (!$example_data)
- {
- drupal_set_message(t('Invalid example selected'), 'error');
- return;
- }
- $chapter_data = db_fetch_object(db_query("SELECT * FROM {textbook_companion_chapter} WHERE id = %d", $example_data->chapter_id));
- if (!$chapter_data)
- {
- drupal_set_message(t('Invalid chapter selected'), 'error');
- return;
- }
- $book_data = db_fetch_object(db_query("SELECT * FROM {textbook_companion_preference} WHERE id = %d", $chapter_data->preference_id));
- if (!$book_data)
- {
- drupal_set_message(t('Invalid book selected'), 'error');
- return;
- }
- $proposal_data = db_fetch_object(db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d", $book_data->proposal_id));
- if (!$proposal_data)
- {
- drupal_set_message(t('Invalid proposal selected'), 'error');
- return;
- }
- db_query("INSERT INTO {textbook_companion_feedback} (example_id, uid, feedback, ip_address, timestamp) VALUES (%d, %d, '%s', '%s', %d)",
- $example_data->id,
- $user->uid,
- $form_state['values']['run']['feedback'],
- $_SERVER['REMOTE_ADDR'],
- time());
-
- /* sending email */
- $param['feedback_received']['user_id'] = $user->uid;
- $param['feedback_received']['book_title'] = $book_data->book;
- $param['feedback_received']['chapter_number'] = $chapter_data->number;
- $param['feedback_received']['chapter_title'] = $chapter_data->name;
- $param['feedback_received']['example_no'] = $example_data->number;
- $param['feedback_received']['feedback'] = $form_state['values']['run']['feedback'];
-
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');// . ', ' . user_load($proposal_data->uid)->mail. ', ' . user_load($example_data->approver_uid)->mail;
- if (!drupal_mail('textbook_companion', 'feedback_received', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message(t('Thank you for your feedback.'), 'status');
- } else {
- drupal_set_message(t('You do not have permission to submit feeback.'), 'error');
- }
- }
-}
-
-function _list_of_books($category_default_value)
-{
- $book_titles = array('0' => 'Please select...');
- $book_titles_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE category=".$category_default_value." AND approval_status = 1 OR approval_status = 3 ORDER BY book ASC ");
-
- while ($book_titles_data = db_fetch_object($book_titles_q))
- {
- $book_titles[$book_titles_data->id] = $book_titles_data->book . ' (Written by ' . $book_titles_data->author . ')';
- }
- return $book_titles;
-}
-
-function _list_of_chapters($preference_id = 0)
-{
- $book_chapters = array('0' => 'Please select...');
- $book_chapters_q = db_query("SELECT * FROM {textbook_companion_chapter} WHERE preference_id = %d ORDER BY number ASC", $preference_id);
- while ($book_chapters_data = db_fetch_object($book_chapters_q))
- {
- $book_chapters[$book_chapters_data->id] = $book_chapters_data->number . '. ' . $book_chapters_data->name;
- }
- return $book_chapters;
-}
-
-function _list_of_examples($chapter_id = 0)
-{
- $book_examples = array('0' => 'Please select...');
- $book_examples_q = db_query("SELECT * FROM {textbook_companion_example} WHERE chapter_id = %d AND approval_status = 1 ORDER BY
- CAST(SUBSTRING_INDEX(number, '.', 1) AS BINARY) ASC,
- CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(number , '.', 2), '.', -1) AS UNSIGNED) ASC,
- CAST(SUBSTRING_INDEX(SUBSTRING_INDEX(number , '.', -1), '.', 1) AS UNSIGNED) ASC", $chapter_id);
- while ($book_examples_data = db_fetch_object($book_examples_q))
- {
- $book_examples[$book_examples_data->id] = $book_examples_data->number . ' (' . $book_examples_data->caption . ')';
- }
- return $book_examples;
-}
-
-function _book_information($preference_id)
-{
- $book_data = db_fetch_object(db_query("SELECT
- preference.book as preference_book, preference.author as preference_author, preference.isbn as preference_isbn, preference.publisher as preference_publisher, preference.edition as preference_edition, preference.year as preference_year,
- proposal.full_name as proposal_full_name, proposal.faculty as proposal_faculty, proposal.reviewer as proposal_reviewer, proposal.course as proposal_course, proposal.branch as proposal_branch, proposal.university as proposal_university
- FROM {textbook_companion_proposal} proposal LEFT JOIN {textbook_companion_preference} preference ON proposal.id = preference.proposal_id AND proposal.status = 3 WHERE preference.id = %d", $preference_id));
- return $book_data;
-}
diff --git a/textbook_companion.module b/textbook_companion.module
index bc39d2e..09a16a5 100755
--- a/textbook_companion.module
+++ b/textbook_companion.module
@@ -879,7 +879,7 @@ function book_proposal_form_submit($form, &$form_state)
//var_dump($form_state['values']);
$query = "INSERT INTO {textbook_companion_proposal}
- (uid, approver_uid, full_name, mobile, how_project, course, branch, university, faculty, reviewer, completion_date, creation_date, approval_date, proposal_status, scilab_version, operating_system, teacher_email) VALUES (".$user->uid.", 0, '".ucwords(strtolower($form_state['values']['full_name']))."', '".$form_state['values']['mobile']."', '".$form_state['values']['how_project']."', '".$form_state['values']['course']."', '".$form_state['values']['branch']."', '".$form_state['values']['university']."', '".ucwords(strtolower($form_state['values']['faculty']))."', '".ucwords(strtolower($form_state['values']['reviewer']))."', '".$completion_date_timestamp."', NOW(), 0, 0, '".$scilab_version."', '".$form_state['values']['operating_system']."', '".$form_state['values']['faculty_email']."')";
+ (uid, approver_uid, full_name, mobile, how_project, course, branch, university, faculty, reviewer, completion_date, creation_date, approval_date, proposal_status, scilab_version, operating_system, teacher_email) VALUES (".$user->uid.", 0, '".ucwords(strtolower($form_state['values']['full_name']))."', '".$form_state['values']['mobile']."', '".$form_state['values']['how_project']."', '".$form_state['values']['course']."', '".$form_state['values']['branch']."', '".$form_state['values']['university']."', '".ucwords(strtolower($form_state['values']['faculty']))."', '".ucwords(strtolower($form_state['values']['reviewer']))."', '".$completion_date_timestamp."', '".time()."', 0, 0, '".$scilab_version."', '".$form_state['values']['operating_system']."', '".$form_state['values']['faculty_email']."')";
$result = db_query($query);
if (!$result)
@@ -960,7 +960,7 @@ function book_proposal_form_submit($form, &$form_state)
}
/* sending email */
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');
+ $email_to = $user->mail;
$param['proposal_received']['proposal_id'] = $proposal_id;
$param['proposal_received']['user_id'] = $user->uid;
if (!drupal_mail('textbook_companion', 'proposal_received', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
@@ -976,10 +976,15 @@ function book_proposal_form_submit($form, &$form_state)
function textbook_companion_mail($key, &$message, $params)
{
global $user;
- $language = $message['language'];
+ $language = $message['lianguage'];
+ $tbc_bcc_emails = array(
+ 'Bcc' => variable_get('textbook_companion_emails', ''),
+ );
switch ($key)
{
case 'proposal_received':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
/* initializing data */
$proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']);
$proposal_data = db_fetch_object($proposal_q);
@@ -1041,6 +1046,8 @@ Best Wishes,
break;
case 'proposal_disapproved':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
/* initializing data */
$proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']);
$proposal_data = db_fetch_object($proposal_q);
@@ -1102,6 +1109,8 @@ Best Wishes,
break;
case 'proposal_approved':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']);
$proposal_data = db_fetch_object($proposal_q);
$approved_preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND approval_status = 1 LIMIT 1", $params['proposal_approved']['proposal_id']);
@@ -1137,6 +1146,9 @@ Best Wishes,
break;
case 'proposal_completed':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
+
$proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_completed']['proposal_id']);
$proposal_data = db_fetch_object($proposal_q);
$approved_preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND approval_status = 1 LIMIT 1", $params['proposal_completed']['proposal_id']);
@@ -1178,6 +1190,8 @@ Best Wishes,
break;
case 'example_uploaded':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d LIMIT 1", $params['example_uploaded']['example_id']);
$example_data = db_fetch_object($example_q);
$user_data = user_load($params['example_uploaded']['user_id']);
@@ -1199,6 +1213,8 @@ Best Wishes,
break;
case 'example_updated':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d LIMIT 1", $params['example_updated']['example_id']);
$example_data = db_fetch_object($example_q);
$user_data = user_load($params['example_updated']['user_id']);
@@ -1220,6 +1236,8 @@ Best Wishes,
break;
case 'example_updated_admin':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d LIMIT 1", $params['example_updated_admin']['example_id']);
$example_data = db_fetch_object($example_q);
$user_data = user_load($params['example_updated_admin']['user_id']);
@@ -1239,6 +1257,8 @@ Best Wishes,
break;
case 'example_approved':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d LIMIT 1", $params['example_approved']['example_id']);
$example_data = db_fetch_object($example_q);
$user_data = user_load($params['example_approved']['user_id']);
@@ -1258,6 +1278,8 @@ Best Wishes,
break;
case 'example_disapproved':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$user_data = user_load($params['example_disapproved']['user_id']);
$message['subject'] = t('[!site_name] Your uploaded example has been disapproved', array('!site_name' => variable_get('site_name', '')), $language->language);
@@ -1277,6 +1299,8 @@ Best Wishes,
break;
case 'example_deleted_user':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$user_data = user_load($params['example_deleted_user']['user_id']);
$message['subject'] = t('[!site_name] User has deleted pending example', array('!site_name' => variable_get('site_name', '')), $language->language);
@@ -1296,6 +1320,8 @@ Best Wishes,
break;
case 'dependency_uploaded':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$user_data = user_load($params['dependency_uploaded']['user_id']);
$dependency_files = implode(',', $params['dependency_uploaded']['dependency_names']);
@@ -1312,6 +1338,8 @@ Best Wishes,
break;
case 'feedback_received':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$user_data = user_load($params['feedback_received']['user_id']);
$message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
@@ -1333,6 +1361,9 @@ Best Wishes,
break;
case 'internshipform':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
+
$user_data = user_load($params['internshipform']['user_id']);
$message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
@@ -1351,6 +1382,9 @@ Best Wishes,
break;
case 'copyrighttransferform':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
+
$user_data = user_load($params['copyrighttransferform']['user_id']);
$message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
@@ -1369,6 +1403,9 @@ Best Wishes,
break;
case 'undertakingform':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
+
$user_data = user_load($params['undertakingform']['user_id']);
$message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
@@ -1388,6 +1425,9 @@ Best Wishes,
case 'remark':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
+
$user_data = user_load($params['remark']['user_id']);
$message['subject'] = t('[!site_name] A remark has been given.Please check your contact detail form', array('!site_name' => variable_get('site_name', '')), $language->language);
@@ -1406,6 +1446,9 @@ Best Wishes,
break;
case 'cheque_sent':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
+
$user_data = user_load($params['cheque_sent']['user_id']);
$message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
@@ -1425,6 +1468,8 @@ Best Wishes,
case 'standard':
+ // bcc to textbook_companion_emails
+ $message['headers'] += $tbc_bcc_emails;
$message['subject'] = $params['standard']['subject'];
$message['body'] = $params['standard']['body'];
break;
diff --git a/textbook_companion.module~ b/textbook_companion.module~
deleted file mode 100755
index 7ff316d..0000000
--- a/textbook_companion.module~
+++ /dev/null
@@ -1,1754 +0,0 @@
-<?php
-// $Id$
-
-/**
- * Implementation of hook_menu().
- */
-function textbook_companion_menu()
-{
- $items = array();
-
- /* users */
- $items['proposal'] = array(
- 'title' => 'Book Proposal Form',
- 'description' => 'Book Proposal Form.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('book_proposal_form'),
- 'access callback' => 'user_access',
- 'access arguments' => array('create book proposal'),
- 'type' => MENU_NORMAL_ITEM,
- );
-
- /* for reviewers */
- $items['manage_proposal'] = array(
- 'title' => 'Manage Book Proposals',
- 'description' => 'Manage Book Proposals',
- 'page callback' => '_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array('approve book proposal'),
- 'file' => 'manage_proposal.inc',
- );
- $items['manage_proposal/pending'] = array(
- 'title' => 'Pending Proposals',
- 'description' => 'Pending Proposals Queue',
- 'page callback' => '_proposal_pending',
- 'access callback' => 'user_access',
- 'access arguments' => array('approve book proposal'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 1,
- 'file' => 'manage_proposal.inc',
- );
- $items['manage_proposal/all'] = array(
- 'title' => 'All Proposals',
- 'description' => 'All Proposals',
- 'page callback' => '_proposal_all',
- 'access callback' => 'user_access',
- 'access arguments' => array('approve book proposal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'manage_proposal.inc',
- );
- $items['manage_proposal/category'] = array(
- 'title' => 'Categorize',
- 'description' => 'Categorize Books',
- 'page callback' => '_category_all',
- 'access callback' => 'user_access',
- 'access arguments' => array('approve book proposal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'manage_proposal.inc',
- );
- $items['manage_proposal/approve'] = array(
- 'title' => 'Proposal Approval',
- 'description' => 'Proposal Approval',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('proposal_approval_form'),
- 'access arguments' => array('approve book proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
- $items['manage_proposal/status'] = array(
- 'title' => 'Proposal Status',
- 'description' => 'Proposal Status',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('proposal_status_form'),
- 'access arguments' => array('approve book proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
- $items['manage_proposal/edit'] = array(
- 'title' => 'Edit Proposal',
- 'description' => 'Edit Proposal',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('proposal_edit_form'),
- 'access arguments' => array('edit book proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
- $items['manage_proposal/category/edit'] = array(
- 'title' => 'Edit Category',
- 'description' => 'Edit category',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('category_edit_form'),
- 'access arguments' => array('edit book proposal'),
- 'type' => MENU_CALLBACK,
- 'file' => 'manage_proposal.inc',
- );
-
- $items['code_approval'] = array(
- 'title' => 'Manage Code Approval',
- 'description' => 'Manage Code Approval',
- 'page callback' => 'code_approval',
- 'access arguments' => array('approve code'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'code_approval.inc',
- );
- $items['code_approval/approve'] = array(
- 'title' => 'Code Approval',
- 'description' => 'Code Approval',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('code_approval_form'),
- 'access arguments' => array('approve code'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'weight' => 1,
- 'file' => 'code_approval.inc',
- );
- $items['code_approval/bulk'] = array(
- 'title' => 'Bulk Manage',
- 'description' => 'Bulk Mangage',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('bulk_approval_form'),
- 'access arguments' => array('bulk manage code'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 2,
- 'file' => 'code_approval.inc',
- );
- $items['code_approval/editcode'] = array(
- 'title' => 'Admin Edit Example',
- 'description' => 'Admin Edit Example',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('upload_examples_admin_edit_form'),
- 'access arguments' => array('approve code'),
- 'type' => MENU_CALLBACK,
- 'weight' => 3,
- 'file' => 'editcodeadmin.inc',
- );
- $items['code_approval/notes'] = array(
- 'title' => 'Notes for Reviewers',
- 'description' => 'Notes for Reviewers',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('book_notes_form'),
- 'access arguments' => array('bulk manage code'),
- 'type' => MENU_CALLBACK,
- 'weight' => 4,
- 'file' => 'notes.inc',
- );
- $items['code_approval/dependency'] = array(
- 'title' => 'Dependency',
- 'description' => 'Dependency',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('textbook_companion_dependency_approval_form'),
- 'access arguments' => array('bulk manage code'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 3,
- 'file' => 'dependency_approval.inc',
- );
-
- $items['textbook_companion/code'] = array(
- 'title' => 'Code Submission',
- 'description' => 'Code Submission',
- 'page callback' => 'list_chapters',
- 'access callback' => 'user_access',
- 'access arguments' => array('upload code'),
- 'file' => 'general.inc',
- );
- $items['textbook_companion/code/list_chapters'] = array(
- 'title' => 'List Chapters',
- 'description' => 'List Chapters',
- 'page callback' => 'list_chapters',
- 'access arguments' => array('upload code'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'file' => 'general.inc',
- 'weight' => 1,
- );
- $items['textbook_companion/code/upload'] = array(
- 'title' => 'Code Submission',
- 'description' => 'Code Submission',
- 'page callback' => 'upload_examples',
- 'access arguments' => array('upload code'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'code.inc',
- 'weight' => 2,
- );
- $items['textbook_companion/code/upload_dep'] = array(
- 'title' => 'Upload Dependency',
- 'description' => 'Upload Dependency Files',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('upload_dependency_form'),
- 'access arguments' => array('upload code'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'dependency.inc',
- 'weight' => 3,
- );
- $items['textbook_companion/code/edit'] = array(
- 'title' => 'Edit Example',
- 'description' => 'Edit Example',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('upload_examples_edit_form'),
- 'access arguments' => array('edit uploaded code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'editcode.inc',
- );
- $items['textbook_companion/code/delete'] = array(
- 'title' => 'Delete Example',
- 'description' => 'Delete Example',
- 'page callback' => '_upload_examples_delete',
- 'access arguments' => array('upload code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'code.inc',
- );
- $items['textbook_companion/code/chapter/edit'] = array(
- 'title' => 'Edit Chapter Title',
- 'description' => 'Edit Chapter Title',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('edit_chapter_title_form'),
- 'access arguments' => array('upload code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'editcode.inc',
- );
- $items['textbook_companion/code/list_examples'] = array(
- 'title' => 'List Examples',
- 'description' => 'List Examples',
- 'page callback' => 'list_examples',
- 'access arguments' => array('upload code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'general.inc',
- 'weight' => 3,
- );
-
- $items['textbook_search'] = array(
- 'title' => 'Book Search',
- 'description' => '',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('textbook_companion_search_form'),
- 'access arguments' => array('access content'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'search.inc',
- );
- $items['textbook_search/search'] = array(
- 'title' => 'Book Search',
- 'description' => '',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('textbook_companion_search_form'),
- 'access arguments' => array('access content'),
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'file' => 'search.inc',
- 'weight' => 1,
- );
- $items['textbook_search/book'] = array(
- 'title' => 'Browse By Title of the Book',
- 'description' => '',
- 'page callback' => 'textbook_companion_browse_book',
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'search.inc',
- 'weight' => 2,
- );
- $items['textbook_search/author'] = array(
- 'title' => 'Browse By Author Name',
- 'description' => '',
- 'page callback' => 'textbook_companion_browse_author',
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'search.inc',
- 'weight' => 3,
- );
- $items['textbook_search/college'] = array(
- 'title' => 'Browse By College',
- 'description' => '',
- 'page callback' => 'textbook_companion_browse_college',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('textbook_companion_browse_college_form'),
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'search.inc',
- 'weight' => 4,
- );
-
- $items['textbook_run'] = array(
- 'title' => 'Download Codes',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('textbook_companion_run_form'),
- 'access arguments' => array('access content'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'run.inc',
- );
-
- /* download callbacks */
- $items['download/file'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'textbook_companion_download_example_file',
- 'access arguments' => array('download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );
- $items['download/dependency'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'textbook_companion_download_dependency_file',
- 'access arguments' => array('download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );
- $items['download/example'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'textbook_companion_download_example',
- 'access arguments' => array('download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );
- $items['download/chapter'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'textbook_companion_download_chapter',
- 'access arguments' => array('download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );
- $items['download/book'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'textbook_companion_download_book',
- 'access arguments' => array('download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'download.inc',
- );
-
- /* reviewer download */
- $items['full_download/chapter'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'textbook_companion_download_full_chapter',
- 'access arguments' => array('approve code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'full_download.inc',
- );
- $items['full_download/book'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'textbook_companion_download_full_book',
- 'access arguments' => array('approve code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'full_download.inc',
- );
-
- /* latex script for book generation */
- $items['textbook_companion/generate_book'] = array(
- 'title' => 'Generate Book',
- 'description' => 'Generate Book From Latex Script',
- 'page callback' => 'textbook_companion_download_book',
- 'access arguments' => array('generate book'),
- 'type' => MENU_CALLBACK,
- 'file' => 'latex.inc',
- );
- $items['textbook_companion/delete_book'] = array(
- 'title' => 'Delete Book PDF',
- 'description' => 'Delete Book PDF',
- 'page callback' => 'textbook_companion_delete_book',
- 'access arguments' => array('approve code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'latex.inc',
- );
-
- /* general purpose callbacks */
- $items['textbook_companion/ajax'] = array(
- 'title' => 'Ajax',
- 'description' => 'Ajax',
- 'page callback' => 'textbook_companion_ajax',
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
-
- /* for admin */
- $items['admin/settings/book_companion'] = array(
- 'title' => 'Book Companion Settings',
- 'description' => 'Book Companion Settings',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('textbook_companion_settings_form'),
- 'access arguments' => array('administer book companion'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'settings.inc',
- );
- /* for data entry */
- $items['dataentry_book'] = array(
- 'title' => 'Approved books list',
- 'page callback' => '_data_entry_proposal_all',
- 'access callback' => 'user_access',
- 'access arguments' => array('dataentry book proposal'),
- 'file' => 'manage_proposal.inc',
- );
- $items['dataentry_edit'] = array(
- 'title' => 'Edit book details',
- 'page callback' => 'dataentry_edit',
- 'access callback' => 'user_access',
- 'access arguments' => array('dataentry book proposal'),
- 'type' => MENU_NORMAL_ITEM,
- 'file' => 'manage_proposal.inc',
- );
- /*Cheque Details and Contact Form */
- $items['cheque_manage/all'] = array(
- 'title' => 'Cheque Proposals',
- 'description' => 'Cheque Proposals',
- 'page callback' => 'cheque_proposal_all',
- 'access arguments' => array('cheque proposal'),
- 'file' => 'cheque_manage.inc',
- );
- $items['mycontact'] = array(
- 'title' => 'Update Contact Details',
- 'description' => 'Update Contact Details',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('contact_details'),
- 'access arguments' => array('contact_details'),
- 'file' => 'cheque_contact.inc',
- );
-
- $items['cheque_contct'] = array(
- 'title' => 'Report',
- 'description' => 'Cheque Contact Form',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('cheque_contct_form'),
- 'access arguments' => array('cheque contct form'),
- 'file' => 'cheque_contact.inc',
- );
- $items['cheque_contact/status'] = array(
- 'title' => 'Cheque Status',
- 'description' => 'Cheque Status',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('cheque_status_form'),
- 'access' => 'user_is_logged_in',
- 'access arguments' => array('cheque status form'),
- 'file' => 'cheque_contact.inc',
- );
- $items['cheque_contct/report'] = array(
- 'title' => 'Report',
- 'description' => 'Report',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('cheque_report_form'),
- 'access' => 'user_is_logged_in',
- 'access arguments' => array('cheque report form'),
- 'file' => 'cheque_contact.inc',
- );
- $items['certificate'] = array(
- 'title' => 'List Of All Certificates',
- 'description' => 'List Of All Certificates',
- 'page callback' => '_list_all_certificates',
- 'access arguments' => array('list all certificates'),
- 'file' => 'pdf/list_all_certificates.inc',
- );
- $items['certificate/generate_pdf'] = array(
- 'title' => 'Download Certificate',
- 'description' => 'Download Certificate',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('generate_pdf'),
- 'access arguments' => array('generate pdf'),
- 'file' => 'pdf/generate_pdf.inc',
- );
- $items['manage_proposal/paper_submission'] = array(
- 'title' => 'Application Submission',
- 'description' => 'Application Submission',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('paper_submission_form'),
- 'access arguments' => array('paper submission form'),
- 'type' => MENU_CALLBACK,
- 'file' => 'cheque_contact.inc',
- );
- return $items;
-}
-
-/**
- * Implementation of hook_perm().
- */
-function textbook_companion_perm() {
-
- return array('create book proposal', 'approve book proposal', 'approve code', 'upload code', 'edit uploaded code', 'download code', 'create feedback', 'bulk manage code', 'bulk delete code', 'edit book proposal', 'administer book companion', 'generate book', 'cheque contct form', 'contact_details', 'comment cheque', 'list all certificates', 'generate pdf', 'paper submission form', 'cheque status form' ,'cheque report form' ,'cheque proposal');
-}
-
-
-function book_proposal_form($form_state)
-{
- global $user;
-
- if (!$user->uid) {
- drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
- return;
- }
-
- /* check if user has already submitted a proposal */
- $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE uid = %d ORDER BY id DESC LIMIT 1", $user->uid);
- if ($proposal_q)
- {
- if ($proposal_data = db_fetch_object($proposal_q))
- {
- switch ($proposal_data->proposal_status)
- {
- case 0:
- drupal_set_message(t('We have already received your proposal. We will get back to you soon.'), 'status');
- drupal_goto('');
- return;
- break;
- case 1:
- drupal_set_message(t('Your proposal has been approved. Please go to ' . l('Code Submission', 'textbook_companion/code') . ' to upload your code'), 'status');
- drupal_goto('');
- return;
- break;
- case 2:
- drupal_set_message(t('Your proposal has been dis-approved. Please create another proposal below.'), 'error');
- break;
- case 3:
- drupal_set_message(t('Congratulations! You have completed your last book proposal. You can create another proposal below.'), 'status');
- break;
- default:
- drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
- drupal_goto('');
- return;
- break;
- }
- }
- }
-
- $form['imp_notice'] = array(
- '#type' => 'item',
- '#value' => '<font color="red"><b>Please fill up this form carefully as the details entered here will be exactly written in the Textbook Companion</b></font>',
- );
-
- $form['full_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Full Name'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['email_id'] = array(
- '#type' => 'textfield',
- '#title' => t('Email'),
- '#size' => 30,
- '#value' => $user->mail,
- '#disabled' => TRUE,
- );
- $form['mobile'] = array(
- '#type' => 'textfield',
- '#title' => t('Mobile No.'),
- '#size' => 30,
- '#maxlength' => 15,
- '#required' => TRUE,
- );
- $form['how_project'] = array(
- '#type' => 'select',
- '#title' => t('How did you come to know about this project'),
- '#options' => array('Scilab Website' => 'Scilab Website',
- 'Friend' => 'Friend',
- 'Professor/Teacher' => 'Professor/Teacher',
- 'Mailing List' => 'Mailing List',
- 'Poster in my/other college' => 'Poster in my/other college',
- 'Others' => 'Others'),
- '#required' => TRUE,
- );
- $form['course'] = array(
- '#type' => 'textfield',
- '#title' => t('Course'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['branch'] = array(
- '#type' => 'select',
- '#title' => t('Department/Branch'),
- '#options' => array('Electrical Engineering' => 'Electrical Engineering',
- 'Electronics Engineering' => 'Electronics Engineering',
- 'Computer Engineering' => 'Computer Engineering',
- 'Chemical Engineering' => 'Chemical Engineering',
- 'Instrumentation Engineering' => 'Instrumentation Engineering',
- 'Mechanical Engineering' => 'Mechanical Engineering',
- 'Civil Engineering' => 'Civil Engineering',
- 'Physics' => 'Physics',
- 'Mathematics' => 'Mathematics',
- 'Others' => 'Others'),
- '#required' => TRUE,
- );
- $form['university'] = array(
- '#type' => 'textfield',
- '#title' => t('University/Institute'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['faculty'] = array(
- '#type' => 'textfield',
- '#title' => t('College Teacher/Professor'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['faculty_email'] = array(
- '#type' => 'textfield',
- '#title' => t('Teacher/Professor Email Id'),
- '#default_value' => '@email.com',
- '#size' => 30,
- '#maxlength' => 50,
- );
- $form['reviewer'] = array(
- '#type' => 'textfield',
- '#title' => t('Reviewer'),
- '#size' => 30,
- '#maxlength' => 50,
- );
- $form['version'] = array(
- '#type' => 'select',
- '#title' => t('Version'),
- '#options' => array('scilab541' => 'Scilab 5.4.1',
- 'scilab533' => 'Scilab 5.3.3',
- 'olderversion' => 'Older Version'),
- '#required' => TRUE,
- );
- $form['operating'] = array(
- '#type' => 'textfield',
- '#title' => t('Operating System used'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['completion_date'] = array(
- '#type' => 'textfield',
- '#title' => t('Expected Date of Completion'),
- '#description' => t('Input date format should be DD-MM-YYYY. Eg: 23-03-2011'),
- '#size' => 10,
- '#maxlength' => 10,
- );
- $form['operating_system'] = array(
- '#type' => 'textfield',
- '#title' => t('Operating System'),
- '#required' => TRUE,
- '#size' => 30,
- '#maxlength' => 50,
- );
- $form['scilab_version'] = array(
- '#type' => 'textfield',
- '#title' => t('Scilab Version'),
- '#required' => TRUE,
- '#size' => 10,
- '#maxlength' => 10,
- );
- $form['preference1'] = array(
- '#type' => 'fieldset',
- '#title' => t('Book Preference 1'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['preference1']['book1'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the book'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- );
- $form['preference1']['author1'] = array(
- '#type' => 'textfield',
- '#title' => t('Author Name'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- );
- $form['preference1']['isbn1'] = array(
- '#type' => 'textfield',
- '#title' => t('ISBN No'),
- '#size' => 30,
- '#maxlength' => 25,
- '#required' => TRUE,
- );
- $form['preference1']['publisher1'] = array(
- '#type' => 'textfield',
- '#title' => t('Publisher & Place'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['preference1']['edition1'] = array(
- '#type' => 'textfield',
- '#title' => t('Edition'),
- '#size' => 4,
- '#maxlength' => 2,
- '#required' => TRUE,
- );
- $form['preference1']['year1'] = array(
- '#type' => 'textfield',
- '#title' => t('Year of pulication'),
- '#size' => 4,
- '#maxlength' => 4,
- '#required' => TRUE,
- );
- $form['preference2'] = array(
- '#type' => 'fieldset',
- '#title' => t('Book Preference 2'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['preference2']['book2'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the book'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- );
- $form['preference2']['author2'] = array(
- '#type' => 'textfield',
- '#title' => t('Author Name'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- );
- $form['preference2']['isbn2'] = array(
- '#type' => 'textfield',
- '#title' => t('ISBN No'),
- '#size' => 30,
- '#maxlength' => 25,
- '#required' => TRUE,
- );
- $form['preference2']['publisher2'] = array(
- '#type' => 'textfield',
- '#title' => t('Publisher & Place'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['preference2']['edition2'] = array(
- '#type' => 'textfield',
- '#title' => t('Edition'),
- '#size' => 4,
- '#maxlength' => 2,
- '#required' => TRUE,
- );
- $form['preference2']['year2'] = array(
- '#type' => 'textfield',
- '#title' => t('Year of pulication'),
- '#size' => 4,
- '#maxlength' => 4,
- '#required' => TRUE,
- );
- $form['preference3'] = array(
- '#type' => 'fieldset',
- '#title' => t('Book Preference 3'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['preference3']['book3'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the book'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- );
- $form['preference3']['author3'] = array(
- '#type' => 'textfield',
- '#title' => t('Author Name'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- );
- $form['preference3']['isbn3'] = array(
- '#type' => 'textfield',
- '#title' => t('ISBN No'),
- '#size' => 30,
- '#maxlength' => 25,
- '#required' => TRUE,
- );
- $form['preference3']['publisher3'] = array(
- '#type' => 'textfield',
- '#title' => t('Publisher & Place'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['preference3']['edition3'] = array(
- '#type' => 'textfield',
- '#title' => t('Edition'),
- '#size' => 4,
- '#maxlength' => 2,
- '#required' => TRUE,
- );
- $form['preference3']['year3'] = array(
- '#type' => 'textfield',
- '#title' => t('Year of pulication'),
- '#size' => 4,
- '#maxlength' => 4,
- '#required' => TRUE,
- );
- $form['termconditions'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Terms And Conditions'),
- '#options' => array(
- 'status' => t('<a href="term-and-conditions" target="_blank">I agree to the Terms and Conditions</a>'),),
- '#required' => TRUE,
- );
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Submit')
- );
- return $form;
-}
-
-function book_proposal_form_validate($form, &$form_state)
-{
- /* mobile */
- if (!preg_match('/^[0-9\ \+]{0,15}$/', $form_state['values']['mobile']))
- form_set_error('mobile', t('Invalid mobile number'));
-
- /* date of completion */
- if (!preg_match('/^[0-9]{1,2}-[0-9]{1,2}-[0-9]{4}$/', $form_state['values']['completion_date']))
- form_set_error('completion_date', t('Invalid expected date of completion'));
-
- list($d, $m, $y) = explode('-', $form_state['values']['completion_date']);
- $d = (int)$d; $m = (int)$m; $y = (int)$y;
- if (!checkdate($m, $d, $y))
- form_set_error('completion_date', t('Invalid expected date of completion'));
- if (mktime(0, 0, 0, $m, $d, $y) <= time())
- form_set_error('completion_date', t('Expected date of completion should be in future'));
-
- /* edition */
- if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition1']))
- form_set_error('edition1', t('Invalid edition for Book Preference 1'));
- if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition2']))
- form_set_error('edition2', t('Invalid edition for Book Preference 2'));
- if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition3']))
- form_set_error('edition3', t('Invalid edition for Book Preference 3'));
-
- /* year of publication */
- if (!preg_match('/^[1-3][0-9][0-9][0-9]$/', $form_state['values']['year1']))
- form_set_error('year1', t('Invalid year of pulication for Book Preference 1'));
- if (!preg_match('/^[1-3][0-9][0-9][0-9]$/', $form_state['values']['year2']))
- form_set_error('year2', t('Invalid year of pulication for Book Preference 2'));
- if (!preg_match('/^[1-3][0-9][0-9][0-9]$/', $form_state['values']['year3']))
- form_set_error('year3', t('Invalid year of pulication for Book Preference 3'));
-
- /* year of publication */
- $cur_year = date('Y');
- if ((int)$form_state['values']['year1'] > $cur_year)
- form_set_error('year1', t('Year of pulication should be not in the future for Book Preference 1'));
- if ((int)$form_state['values']['year2'] > $cur_year)
- form_set_error('year2', t('Year of pulication should be not in the future for Book Preference 2'));
- if ((int)$form_state['values']['year3'] > $cur_year)
- form_set_error('year3', t('Year of pulication should be not in the future for Book Preference 3'));
-
- /* isbn */
- if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn1']))
- form_set_error('isbn1', t('Invalid ISBN for Book Preference 1'));
- if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn2']))
- form_set_error('isbn2', t('Invalid ISBN for Book Preference 2'));
- if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn3']))
- form_set_error('isbn3', t('Invalid ISBN for Book Preference 3'));
- return;
-}
-
-function book_proposal_form_submit($form, &$form_state)
-{
- global $user;
-
- if (!$user->uid) {
- drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
- return;
- }
-
- /* completion date to timestamp */
- list($d, $m, $y) = explode('-', $form_state['values']['completion_date']);
- $completion_date_timestamp = mktime(0, 0, 0, $m, $d, $y);
-if($form_state['values']['version']=='olderversion')
- {
- $result = db_query("INSERT INTO {textbook_companion_proposal}
- (uid, approver_uid, full_name, mobile, how_project, course, branch, university, faculty, reviewer, completion_date, creation_date, approval_date, proposal_status, scilab_versions, operating_system, teacher_email) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s')",
- $user->uid,
- 0,
- ucwords(strtolower($form_state['values']['full_name'])),
- $form_state['values']['mobile'],
- $form_state['values']['how_project'],
- $form_state['values']['course'],
- $form_state['values']['branch'],
- $form_state['values']['university'],
- ucwords(strtolower($form_state['values']['faculty'])),
- ucwords(strtolower($form_state['values']['reviewer'])),
- $completion_date_timestamp,
- time(),
- 0,
- 0,
- $form_state['values']['older'],
- $form_state['values']['operating'],
- $form_state['values']['faculty_email']
- );
- }
- else
- {
- /* inserting the user proposal */
- $result = db_query("INSERT INTO {textbook_companion_proposal}
- (uid, approver_uid, full_name, mobile, how_project, course, branch, university, faculty, reviewer, completion_date, operating_system, scilab_version, creation_date, approval_date, proposal_status ,scilab_versions, operating_system, teacher_email) VALUES
- (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d , '%s', '%s', '%s')",
- $user->uid,
- 0,
- ucwords(strtolower($form_state['values']['full_name'])),
- $form_state['values']['mobile'],
- $form_state['values']['how_project'],
- $form_state['values']['course'],
- $form_state['values']['branch'],
- $form_state['values']['university'],
- ucwords(strtolower($form_state['values']['faculty'])),
- ucwords(strtolower($form_state['values']['reviewer'])),
- $completion_date_timestamp,
- $form_state['values']['operating_system'],
- $form_state['values']['scilab_version'],
- time(),
- 0,
- 0,
- $form_state['values']['version'],
- $form_state['values']['operating'],
- $form_state['values']['faculty_email']
- );
- }
- if (!$result)
- {
- drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
- return;
- }
- /* proposal id */
- $proposal_id = db_last_insert_id('textbook_companion_proposal', 'id');
-
- /* inserting first book preference */
- if ($form_state['values']['book1'])
- {
- $result = db_query("INSERT INTO {textbook_companion_preference}
- (proposal_id, pref_number, book, author, isbn, publisher, edition, year, category, approval_status) VALUES
- (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)",
- $proposal_id,
- 1,
- ucwords(strtolower($form_state['values']['book1'])),
- ucwords(strtolower($form_state['values']['author1'])),
- $form_state['values']['isbn1'],
- ucwords(strtolower($form_state['values']['publisher1'])),
- $form_state['values']['edition1'],
- $form_state['values']['year1'],
- 0,
- 0
- );
- if (!$result)
- {
- drupal_set_message(t('Error receiving your first book preference.'), 'error');
- }
- }
-
- /* inserting second book preference */
- if ($form_state['values']['book2'])
- {
- $result = db_query("INSERT INTO {textbook_companion_preference}
- (proposal_id, pref_number, book, author, isbn, publisher, edition, year, category, approval_status) VALUES
- (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)",
- $proposal_id,
- 2,
- ucwords(strtolower($form_state['values']['book2'])),
- ucwords(strtolower($form_state['values']['author2'])),
- $form_state['values']['isbn2'],
- ucwords(strtolower($form_state['values']['publisher2'])),
- $form_state['values']['edition2'],
- $form_state['values']['year2'],
- 0,
- 0
- );
- if (!$result)
- {
- drupal_set_message(t('Error receiving your second book preference.'), 'error');
- }
- }
-
- /* inserting third book preference */
- if ($form_state['values']['book3'])
- {
- $result = db_query("INSERT INTO {textbook_companion_preference}
- (proposal_id, pref_number, book, author, isbn, publisher, edition, year, category, approval_status) VALUES
- (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d)",
- $proposal_id,
- 3,
- ucwords(strtolower($form_state['values']['book3'])),
- ucwords(strtolower($form_state['values']['author3'])),
- $form_state['values']['isbn3'],
- ucwords(strtolower($form_state['values']['publisher3'])),
- $form_state['values']['edition3'],
- $form_state['values']['year3'],
- 0,
- 0
- );
- if (!$result)
- {
- drupal_set_message(t('Error receiving your third book preference.'), 'error');
- }
- }
-
- /* sending email */
- $email_to = $user->mail . ', ' . variable_get('textbook_companion_emails', '');
- $param['proposal_received']['proposal_id'] = $proposal_id;
- $param['proposal_received']['user_id'] = $user->uid;
- if (!drupal_mail('textbook_companion', 'proposal_received', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
-
- drupal_set_message(t('We have received you book proposal. We will get back to you soon.'), 'status');
- drupal_goto('');
-}
-
-/**
- * Implementation of hook_mail().
- */
-function textbook_companion_mail($key, &$message, $params)
-{
- global $user;
- $language = $message['language'];
- switch ($key)
- {
- case 'proposal_received':
- /* initializing data */
- $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_received']['proposal_id']);
- $proposal_data = db_fetch_object($proposal_q);
- $preference1_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $params['proposal_received']['proposal_id'], 1);
- $preference1_data = db_fetch_object($preference1_q);
- $preference2_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $params['proposal_received']['proposal_id'], 2);
- $preference2_data = db_fetch_object($preference2_q);
- $preference3_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $params['proposal_received']['proposal_id'], 3);
- $preference3_data = db_fetch_object($preference3_q);
- $user_data = user_load($params['proposal_received']['user_id']);
-
- $message['subject'] = t('[!site_name] Your book proposal has been received', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-We have received your following book proposal:
-
-Full Name : ' . $proposal_data->full_name . '
-Email : ' . $user_data->mail . '
-Mobile : ' . $proposal_data->mobile . '
-Course : ' . $proposal_data->course . '
-Department/Branch : ' . $proposal_data->branch . '
-University/Institute : ' . $proposal_data->university . '
-College Teacher / Professor : ' . $proposal_data->faculty . '
-Reviewer : ' . $proposal_data->reviewer . '
-Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
-
-Your Book Preferences :
-
-Book Preference 1 :-
-Title of the book : ' . $preference1_data->book . '
-Author name : ' . $preference1_data->author . '
-ISBN No. : ' . $preference1_data->isbn . '
-Publisher and Place : ' . $preference1_data->publisher . '
-Edition : ' . $preference1_data->edition . '
-Year of publication : ' . $preference1_data->year . '
-
-Book Preference 2 :-
-Title of the book : ' . $preference2_data->book . '
-Author name : ' . $preference2_data->author . '
-ISBN No. : ' . $preference2_data->isbn . '
-Publisher and Place : ' . $preference2_data->publisher . '
-Edition : ' . $preference2_data->edition . '
-Year of publication : ' . $preference2_data->year . '
-
-Book Preference 3 :-
-Title of the book : ' . $preference3_data->book . '
-Author name : ' . $preference3_data->author . '
-ISBN No. : ' . $preference3_data->isbn . '
-Publisher and Place : ' . $preference3_data->publisher . '
-Edition : ' . $preference3_data->edition . '
-Year of publication : ' . $preference3_data->year . '
-
-Your proposal is under review and you will soon receive an email from us regarding the same.
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'proposal_disapproved':
- /* initializing data */
- $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_disapproved']['proposal_id']);
- $proposal_data = db_fetch_object($proposal_q);
- $preference1_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $params['proposal_disapproved']['proposal_id'], 1);
- $preference1_data = db_fetch_object($preference1_q);
- $preference2_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $params['proposal_disapproved']['proposal_id'], 2);
- $preference2_data = db_fetch_object($preference2_q);
- $preference3_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND pref_number = %d LIMIT 1", $params['proposal_disapproved']['proposal_id'], 3);
- $preference3_data = db_fetch_object($preference3_q);
- $user_data = user_load($params['proposal_disapproved']['user_id']);
-
- $message['subject'] = t('[!site_name] Your book proposal has been disapproved', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-Your following book proposal has been disapproved:
-
-Reason for disapproval: ' . $proposal_data->message . '
-
-Full Name : ' . $proposal_data->full_name . '
-Email : ' . $user_data->mail . '
-Mobile : ' . $proposal_data->mobile . '
-Course : ' . $proposal_data->course . '
-Department/Branch : ' . $proposal_data->branch . '
-University/Institute : ' . $proposal_data->university . '
-College Teacher / Professor : ' . $proposal_data->faculty . '
-Reviewer : ' . $proposal_data->reviewer . '
-Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
-
-Your Book Preferences :
-
-Book Preference 1 :-
-Title of the book : ' . $preference1_data->book . '
-Author name : ' . $preference1_data->author . '
-ISBN No. : ' . $preference1_data->isbn . '
-Publisher and Place : ' . $preference1_data->publisher . '
-Edition : ' . $preference1_data->edition . '
-Year of publication : ' . $preference1_data->year . '
-
-Book Preference 2 :-
-Title of the book : ' . $preference2_data->book . '
-Author name : ' . $preference2_data->author . '
-ISBN No. : ' . $preference2_data->isbn . '
-Publisher and Place : ' . $preference2_data->publisher . '
-Edition : ' . $preference2_data->edition . '
-Year of publication : ' . $preference2_data->year . '
-
-Book Preference 3 :-
-Title of the book : ' . $preference3_data->book . '
-Author name : ' . $preference3_data->author . '
-ISBN No. : ' . $preference3_data->isbn . '
-Publisher and Place : ' . $preference3_data->publisher . '
-Edition : ' . $preference3_data->edition . '
-Year of publication : ' . $preference3_data->year . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'proposal_approved':
- $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_approved']['proposal_id']);
- $proposal_data = db_fetch_object($proposal_q);
- $approved_preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND approval_status = 1 LIMIT 1", $params['proposal_approved']['proposal_id']);
- $approved_preference_data = db_fetch_object($approved_preference_q);
- $user_data = user_load($params['proposal_approved']['user_id']);
-
- $message['subject'] = t('[!site_name] Your book proposal has been approved', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-Your following book proposal has been approved:
-
-Full Name : ' . $proposal_data->full_name . '
-Email : ' . $user_data->mail . '
-Mobile : ' . $proposal_data->mobile . '
-Course : ' . $proposal_data->course . '
-Department/Branch : ' . $proposal_data->branch . '
-University/Institute : ' . $proposal_data->university . '
-College Teacher / Professor : ' . $proposal_data->faculty . '
-Reviewer : ' . $proposal_data->reviewer . '
-Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
-
-Title of the book : ' . $approved_preference_data->book . '
-Author name : ' . $approved_preference_data->author . '
-ISBN No. : ' . $approved_preference_data->isbn . '
-Publisher and Place : ' . $approved_preference_data->publisher . '
-Edition : ' . $approved_preference_data->edition . '
-Year of publication : ' . $approved_preference_data->year . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'proposal_completed':
- $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE id = %d LIMIT 1", $params['proposal_completed']['proposal_id']);
- $proposal_data = db_fetch_object($proposal_q);
- $approved_preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE proposal_id = %d AND approval_status = 1 LIMIT 1", $params['proposal_completed']['proposal_id']);
- $approved_preference_data = db_fetch_object($approved_preference_q);
- $user_data = user_load($params['proposal_completed']['user_id']);
-
- $message['subject'] = t('[!site_name] Congratulations for completion of the book.', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-Following book has been completed sucessfully by you:
-
-Full Name : ' . $proposal_data->full_name . '
-Email : ' . $user_data->mail . '
-Mobile : ' . $proposal_data->mobile . '
-Course : ' . $proposal_data->course . '
-Department/Branch : ' . $proposal_data->branch . '
-University/Institute : ' . $proposal_data->university . '
-College Teacher / Professor : ' . $proposal_data->faculty . '
-Reviewer : ' . $proposal_data->reviewer . '
-Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
-
-Title of the book : ' . $approved_preference_data->book . '
-Author name : ' . $approved_preference_data->author . '
-ISBN No. : ' . $approved_preference_data->isbn . '
-Publisher and Place : ' . $approved_preference_data->publisher . '
-Edition : ' . $approved_preference_data->edition . '
-Year of publication : ' . $approved_preference_data->year . '
-
-Your book is now available at following link to download.
-
-http://scilab.in/textbook_run/' . $approved_preference_data->id . '
-
-Now you should be able to propose a new book...
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'example_uploaded':
- $example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d LIMIT 1", $params['example_uploaded']['example_id']);
- $example_data = db_fetch_object($example_q);
- $user_data = user_load($params['example_uploaded']['user_id']);
-
- $message['subject'] = t('[!site_name] You have uploaded example', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-You have uploaded the following example:
-
-Example number : ' . $example_data->number . '
-Caption : ' . $example_data->caption . '
-
-The example is under review. You will be notified when it has been approved.
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'example_updated':
- $example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d LIMIT 1", $params['example_updated']['example_id']);
- $example_data = db_fetch_object($example_q);
- $user_data = user_load($params['example_updated']['user_id']);
-
- $message['subject'] = t('[!site_name] You have updated example', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-You have updated the following example:
-
-Example number : ' . $example_data->number . '
-Caption : ' . $example_data->caption . '
-
-The example is still under review. You will be notified when it has been approved.
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'example_updated_admin':
- $example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d LIMIT 1", $params['example_updated_admin']['example_id']);
- $example_data = db_fetch_object($example_q);
- $user_data = user_load($params['example_updated_admin']['user_id']);
-
- $message['subject'] = t('[!site_name] Reviewer have updated example', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-Reviewer have updated the following example:
-
-Example number : ' . $example_data->number . '
-Caption : ' . $example_data->caption . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'example_approved':
- $example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d LIMIT 1", $params['example_approved']['example_id']);
- $example_data = db_fetch_object($example_q);
- $user_data = user_load($params['example_approved']['user_id']);
-
- $message['subject'] = t('[!site_name] Your uploaded example has been approved', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-Your following example has been approved:
-
-Example number : ' . $example_data->number . '
-Caption : ' . $example_data->caption . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'example_disapproved':
- $user_data = user_load($params['example_disapproved']['user_id']);
-
- $message['subject'] = t('[!site_name] Your uploaded example has been disapproved', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-Your following example has been disapproved:
-
-Example number : ' . $params['example_disapproved']['example_number'] . '
-Caption : ' . $params['example_disapproved']['example_caption'] . '
-
-Reason for dis-approval : ' . $params['example_disapproved']['message'] . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'example_deleted_user':
- $user_data = user_load($params['example_deleted_user']['user_id']);
-
- $message['subject'] = t('[!site_name] User has deleted pending example', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-Your following pending example has been deleted :
-
-Title of the Book : ' . $params['example_deleted_user']['book_title'] . '
-Title of the Chapter : ' . $params['example_deleted_user']['chapter_title'] . '
-Example number : ' . $params['example_deleted_user']['example_number'] . '
-Caption : ' . $params['example_deleted_user']['example_caption'] . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'dependency_uploaded':
- $user_data = user_load($params['dependency_uploaded']['user_id']);
- $dependency_files = implode(',', $params['dependency_uploaded']['dependency_names']);
-
- $message['subject'] = t('[!site_name] You have uploaded dependency file', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-You have uploaded following dependency files :
- ' . $dependency_files . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'feedback_received':
- $user_data = user_load($params['feedback_received']['user_id']);
-
- $message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-We have received your following feedback
-
-Title of the Book: ' . $params['feedback_received']['book_title'] . '
-Title of the Chapter: ' . $params['feedback_received']['chapter_number'] . ' ' . $params['feedback_received']['chapter_title'] . '
-Example No.: ' . $params['feedback_received']['example_no'] . '
-
-Your feedback :
-' . $params['feedback_received']['feedback'] . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'internshipform':
- $user_data = user_load($params['internshipform']['user_id']);
-
- $message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-We have received your Internship Form Application for the book
-
-Title of the Book: ' . $params['internshipform']['book_title'] . '
-Title of the Chapter: ' . $params['internshipform']['chapter_number'] . ' ' . $params['internshipform']['chapter_title'] . '
-Example No.: ' . $params['internshipform']['example_no'] . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
-case 'copyrighttransferform':
- $user_data = user_load($params['copyrighttransferform']['user_id']);
-
- $message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-We have received your Copyright Form Application for the book
-
-Title of the Book: ' . $params['copyrighttransferform']['book_title'] . '
-Title of the Chapter: ' . $params['copyrighttransferform']['chapter_number'] . ' ' . $params['copyrighttransferform']['chapter_title'] . '
-Example No.: ' . $params['copyrighttransferform']['example_no'] . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
-case 'undertakingform':
- $user_data = user_load($params['undertakingform']['user_id']);
-
- $message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-We have received your Undertaking Form Application for the book
-
-Title of the Book: ' . $params['undertakingform']['book_title'] . '
-Title of the Chapter: ' . $params['undertakingform']['chapter_number'] . ' ' . $params['undertakingform']['chapter_title'] . '
-Example No.: ' . $params['undertakingform']['example_no'] . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
-
-case 'remark':
- $user_data = user_load($params['remark']['user_id']);
-
- $message['subject'] = t('[!site_name] A remark has been given.Please check your contact detail form', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-A Remark has been given.Please check your Contact Detail Form
-
-Title of the Book: ' . $params['internshipform']['book_title'] . '
-Title of the Chapter: ' . $params['internshipform']['chapter_number'] . ' ' . $params['internshipform']['chapter_title'] . '
-Example No.: ' . $params['internshipform']['example_no'] . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
- case 'cheque_sent':
- $user_data = user_load($params['cheque_sent']['user_id']);
-
- $message['subject'] = t('[!site_name] We have received your feedback', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear !user_name,
-
-We have Sent Cheque for the following book proposed
-
-Title of the Book: ' . $params['cheque_sent']['book_title'] . '
-Title of the Chapter: ' . $params['cheque_sent']['chapter_number'] . ' ' . $params['cheque_sent']['chapter_title'] . '
-Example No.: ' . $params['cheque_sent']['example_no'] . '
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-
-
- case 'standard':
- $message['subject'] = $params['standard']['subject'];
- $message['body'] = $params['standard']['body'];
- break;
- }
-}
-
-/* AJAX CALLS */
-function textbook_companion_ajax()
-{
- $query_type = arg(2);
- if ($query_type == 'chapter_title')
- {
- $chapter_number = arg(3);
- $preference_id = arg(4);
- $chapter_q = db_query("SELECT * FROM {textbook_companion_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id);
- if ($chapter_data = db_fetch_object($chapter_q))
- {
- echo $chapter_data->name;
- return;
- }
- } else if ($query_type == 'example_exists') {
- $chapter_number = arg(3);
- $preference_id = arg(4);
- $example_number = arg(5);
-
- $chapter_id = 0;
- $chapter_q = db_query("SELECT * FROM {textbook_companion_chapter} WHERE number = %d AND preference_id = %d LIMIT 1", $chapter_number, $preference_id);
- if (!$chapter_data = db_fetch_object($chapter_q))
- {
- echo '';
- return;
- } else {
- $chapter_id = $chapter_data->id;
- }
-
- $example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE chapter_id = %d AND number = '%s' LIMIT 1", $chapter_id, $example_number);
- if ($example_data = db_fetch_object($example_q))
- {
- if ($example_data->approval_status == 1)
- echo 'Warning! Example already approved. You cannot upload the same example again.';
- else
- echo 'Warning! Example already uploaded. Delete the example and reupload it.';
- return;
- }
- }
- echo '';
-}
-
-/*************************** VALIDATION FUNCTIONS *****************************/
-function textbook_companion_check_valid_filename($file_name) {
- if (!preg_match('/^[0-9a-zA-Z\_\.]+$/', $file_name))
- return FALSE;
- else
- if (substr_count($file_name, ".") > 1)
- return FALSE;
- else
- return TRUE;
-}
-
-function check_name($name = '') {
- if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
- return FALSE;
- else
- return TRUE;
-}
-
-function check_chapter_number($name = '') {
- if (!preg_match('/^([0-9])+(\.([0-9a-zA-Z])+)+$/', $name))
- return FALSE;
- else
- return TRUE;
-}
-
-function textbook_companion_path() {
- return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'uploads/';
-}
-
-/****************************** DELETION FUNCTIONS ****************************/
-
-function delete_example($example_id)
-{
- global $user;
- $root_path = textbook_companion_path();
- $status = TRUE;
-
- $example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE id = %d", $example_id);
- $example_data = db_fetch_object($example_q);
- if (!$example_data)
- {
- drupal_set_message(t('Invalid example.'), 'error');
- return FALSE;
- }
-
- $chapter_q = db_query("SELECT * FROM {textbook_companion_chapter} WHERE id = %d", $example_data->chapter_id);
- $chapter_data = db_fetch_object($chapter_q);
- if (!$chapter_data)
- {
- drupal_set_message(t('Invalid example chapter.'), 'error');
- return FALSE;
- }
-
- /* deleting example files */
- $examples_files_q = db_query("SELECT * FROM {textbook_companion_example_files} WHERE example_id = %d", $example_id);
- while ($examples_files_data = db_fetch_object($examples_files_q))
- {
- if (!file_exists($root_path . $examples_files_data->filepath))
- {
- $status = FALSE;
- drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $examples_files_data->filepath)), 'error');
- continue;
- }
-
- /* removing example file */
- if (!unlink($root_path . $examples_files_data->filepath))
- {
- $status = FALSE;
- drupal_set_message(t('Error deleting !file', array('!file' => $examples_files_data->filepath)), 'error');
-
- /* sending email to admins */
- $email_to = variable_get('textbook_companion_emails', '');
- $param['standard']['subject'] = "[ERROR] Error deleting example file";
- $param['standard']['body'] = "Error deleting example files by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " :
- example id : " . $example_id . "
- file id : " . $examples_files_data->id . "
- file path : " . $examples_files_data->filepath;
- if (!drupal_mail('textbook_companion', 'standard', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
- } else {
- /* deleting example files database entries */
- db_query("DELETE FROM {textbook_companion_example_files} WHERE id = %d", $examples_files_data->id);
- }
- }
-
- if (!$status)
- return FALSE;
-
- /* removing example folder */
- $ex_path = $chapter_data->preference_id . '/' . 'CH' . $chapter_data->number . '/' . 'EX' . $example_data->number;
- $dir_path = $root_path . $ex_path;
- if (is_dir($dir_path))
- {
- if (!rmdir($dir_path))
- {
- drupal_set_message(t('Error deleting folder !folder', array('!folder' => $dir_path)), 'error');
-
- /* sending email to admins */
- $email_to = variable_get('textbook_companion_emails', '');
- $param['standard']['subject'] = "[ERROR] Error deleting folder";
- $param['standard']['body'] = "Error deleting folder " . $dir_path . " by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
- if (!drupal_mail('textbook_companion', 'standard', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
- return FALSE;
- }
- } else {
- drupal_set_message(t('Cannot delete example folder. !folder does not exists.', array('!folder' => $dir_path)), 'error');
- return FALSE;
- }
-
- /* deleting example dependency and exmaple database entries */
- db_query("DELETE FROM {textbook_companion_example_dependency} WHERE example_id = %d", $example_id);
- db_query("DELETE FROM {textbook_companion_example} WHERE id = %d", $example_id);
-
- return $status;
-}
-
-function delete_chapter($chapter_id)
-{
- $status = TRUE;
- $root_path = textbook_companion_path();
-
- $chapter_q = db_query("SELECT * FROM {textbook_companion_chapter} WHERE id = %d", $chapter_id);
- $chapter_data = db_fetch_object($chapter_q);
- if (!$chapter_data)
- {
- drupal_set_message('Invalid chapter.', 'error');
- return FALSE;
- }
-
- /* deleting examples */
- $example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE chapter_id = %d", $chapter_id);
- while ($example_data = db_fetch_object($example_q))
- {
- if (!delete_example($example_data->id))
- $status = FALSE;
- }
-
- if ($status)
- {
- $dir_path = $root_path . $chapter_data->preference_id . '/CH' . $chapter_data->number;
-
- if (is_dir($dir_path))
- {
- $res = rmdir($dir_path);
- if (!$res)
- {
- drupal_set_message(t('Error deleting chapter folder !folder', array('!folder' => $dir_path)), 'error');
-
- /* sending email to admins */
- $email_to = variable_get('textbook_companion_emails', '');
- $param['standard']['subject'] = "[ERROR] Error deleting folder";
- $param['standard']['body'] = "Error deleting folder " . $dir_path;
- if (!drupal_mail('textbook_companion', 'standard', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
- return FALSE;
- } else {
- /* deleting chapter details from database */
- db_query("DELETE FROM {textbook_companion_chapter} WHERE id = %d", $chapter_id);
- return TRUE;
- }
- } else {
- drupal_set_message(t('Cannot delete chapter folder. !folder does not exists.', array('!folder' => $dir_path)), 'error');
- return FALSE;
- }
- }
- return FALSE;
-}
-
-function delete_book($book_id)
-{
- $status = TRUE;
- $root_path = textbook_companion_path();
-
- $preference_q = db_query("SELECT * FROM {textbook_companion_preference} WHERE id = %d", $book_id);
- $preference_data = db_fetch_object($preference_q);
- if (!$preference_data)
- {
- drupal_set_message('Invalid book.', 'error');
- return FALSE;
- }
-
- /* delete chapters */
- $chapter_q = db_query("SELECT * FROM {textbook_companion_chapter} WHERE preference_id = %d", $preference_data->id);
- while ($chapter_data = db_fetch_object($chapter_q))
- {
- if (!delete_chapter($chapter_data->id))
- {
- $status = FALSE;
- }
- }
- return $status;
-}
-
-function delete_file($file_id)
-{
- $root_path = textbook_companion_path();
-
- $file_q = db_query("SELECT * FROM {textbook_companion_example_files} WHERE id = %d LIMIT 1", $file_id);
- $file_data = db_fetch_object($file_q);
- if (!$file_data)
- {
- drupal_set_message('Invalid file specified.', 'error');
- return FALSE;
- }
-
- if (!file_exists($root_path . $file_data->filepath))
- {
- drupal_set_message(t('Error deleting !file. File does not exists.', array('!file' => $file_data->filepath)), 'error');
- return FALSE;
- }
-
- /* removing example file */
- if (!unlink($root_path . $file_data->filepath))
- {
- drupal_set_message(t('Error deleting !file', array('!file' => $file_data->filepath)), 'error');
-
- /* sending email to admins */
- $email_to = variable_get('textbook_companion_emails', '');
- $param['standard']['subject'] = "[ERROR] Error deleting file";
- $param['standard']['body'] = "Error deleting file by " . $user->uid . " at " . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . " :
- file id : " . $file_id . "
- file path : " . $file_data->filepath;
- if (!drupal_mail('textbook_companion', 'standard', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
- return FALSE;
- } else {
- /* deleting example files database entries */
- db_query("DELETE FROM {textbook_companion_example_files} WHERE id = %d", $file_id);
- return TRUE;
- }
-}
-
-function del_book_pdf($book_id)
-{
- $root_path = textbook_companion_path();
- $dir_path = $root_path . "latex/";
- $pdf_filename = "book_" . $book_id . ".pdf";
- if (file_exists($dir_path . $pdf_filename))
- unlink($dir_path . $pdf_filename);
-}
-function textbook_companion_init(){
- //drupal_add_css('http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css', array('type' => 'external'));
- //drupal_add_js('http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css', array('type' => 'external'));
- //drupal_add_js(drupal_get_path('module', 'textbook_companion') .'/js/jquery-ui.js');
- //drupal_add_js(drupal_get_path('module', 'textbook_companion') .'/js/jquery.js');
- drupal_add_css(drupal_get_path('module', 'textbook_companion') .'/css/textbook_companion.css');
- drupal_add_js(drupal_get_path('module', 'textbook_companion') .'/js/textbook_companion.js');
-}