summaryrefslogtreecommitdiff
path: root/textbook_companion.module
diff options
context:
space:
mode:
authorprashant2016-01-30 12:25:22 +0530
committerprashantsinalkar2016-01-30 13:05:18 +0530
commit205c03ca3b0c7caaf42ba2e7649edd4ee06ccc44 (patch)
tree7e4b74e141452039fe6d5618cd058d2a2e696e75 /textbook_companion.module
parent96743e5f2674f353030512da2a58db05658912c2 (diff)
downloadDWSIM_textbook_companion-205c03ca3b0c7caaf42ba2e7649edd4ee06ccc44.tar.gz
DWSIM_textbook_companion-205c03ca3b0c7caaf42ba2e7649edd4ee06ccc44.tar.bz2
DWSIM_textbook_companion-205c03ca3b0c7caaf42ba2e7649edd4ee06ccc44.zip
Done minor changes and added submit all code notification for tbc reviver interface
Diffstat (limited to 'textbook_companion.module')
-rwxr-xr-xtextbook_companion.module6062
1 files changed, 3863 insertions, 2199 deletions
diff --git a/textbook_companion.module b/textbook_companion.module
index 0a6b051..5a3685c 100755
--- a/textbook_companion.module
+++ b/textbook_companion.module
@@ -1,67 +1,73 @@
<?php
-// $Id$
-
/*
-* Implementation of hook_menu().
+implementation of hook_menu().
*/
-
function textbook_companion_menu()
{
- $items = array();
-
- /* users */
- $items['proposal'] = array(
- 'title' => 'Book Proposal Form',
- 'description' => 'Book Proposal Form.',
- 'page callback' => 'textbook_companion_nonaicte_proposal_all',
- 'access callback' => 'user_access',
- 'access arguments' => array('create book proposal'),
- 'type' => MENU_CALLBACK,
- );
- /* $items["aicte_proposal"] = array(
+ $items = array();
+ /* users */
+ $items['textbook-companion/proposal'] = array(
+ 'title' => 'Book Proposal Form',
+ 'description' => 'Book Proposal Form.',
+ 'page callback' => 'textbook_companion_proposal_all',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'create book proposal'
+ ),
+ 'type' => MENU_CALLBACK
+ );
+ /*$items["aicte_proposal"] = array(
"title" => "AICTE Book Proposal",
"description" => "AICTE Book Proposal Form",
"page callback" => "textbook_companion_aicte_proposal_all",
'access arguments' => array('create book proposal'),
- 'type' => MENU_NORMAL_ITEM,
- );*/
- // $items["all_proposal"] = array(
- // "title" => "Book Proposal",
- // "description" => "Book Proposal Form",
- // "page callback" => "textbook_companion_aicte_proposal_all",
- // '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(
+ 'type' => MENU_CALLBACK,
+ );*/
+ $items["textbook-companion/all_proposal"] = array(
+ "title" => "Book Proposal",
+ "description" => "Book Proposal Form",
+ "page callback" => "textbook_companion_aicte_proposal_all",
+ 'access arguments' => array(
+ 'create book proposal'
+ ),
+ 'type' => MENU_CALLBACK
+ );
+ /* for reviewers */
+ $items['textbook-companion/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['textbook-companion/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['textbook-companion/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',
@@ -70,45 +76,59 @@ function textbook_companion_menu()
'type' => MENU_LOCAL_TASK,
'weight' => 2,
'file' => 'manage_proposal.inc',
- );
- $items['manage_proposal/failed'] = array(
- 'title' => 'Failed Proposals',
- 'description' => 'Failed to submit code',
- 'page callback' => '_failed_all',
- 'access callback' => 'user_access',
- 'access arguments' => array('approve book proposal'),
- 'type' => MENU_LOCAL_TASK,
- 'weight' => 3,
- '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(
+ );*/
+ $items['textbook-companion/manage-proposal/failed'] = array(
+ 'title' => 'Failed Proposals',
+ 'description' => 'Failed to submit code',
+ 'page callback' => '_failed_all',
+ 'access callback' => 'user_access',
+ 'access arguments' => array(
+ 'approve book proposal'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 3,
+ 'file' => 'manage_proposal.inc'
+ );
+ $items['textbook-companion/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['textbook-companion/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['textbook-companion/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',
@@ -116,543 +136,893 @@ function textbook_companion_menu()
'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',
+ );*/
+ $items['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/code-approval/edit-code-submission'] = array(
+ 'title' => 'Edit Code Submission',
+ 'description' => 'Enable users code submission interface',
+ // 'page callback' => 'drupal_get_form',
+ 'page callback' => 'edit_code_submission',
+ // 'page arguments' => array(
+ // 'edit_code_submission_form'
+ // ),
+ 'access arguments' => array(
+ 'bulk manage code'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'weight' => 3,
+ 'file' => 'code_approval.inc'
+ );*/
+ $items['textbook-companion/code-approval/edit-code-submission/edit'] = array(
+ 'title' => 'Edit Code Submission',
+ 'description' => 'Enable users code submission interface',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array(
+ 'edit_code_submission_form'
+ ),
+ 'access arguments' => array(
+ 'bulk manage code'
+ ),
+ 'file' => 'code_approval.inc'
+ );
+ $items['textbook-companion/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['textbook-companion/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('code_approval_form'),
- 'access arguments' => array('approve code'),
+ 'page arguments' => array('textbook_companion_dependency_approval_form'),
+ 'access arguments' => array('bulk manage code'),
'type' => MENU_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/ajax'] = array(
- 'title' => 'Ajax',
- 'description' => 'Ajax',
- 'page callback' => 'textbook_companion_bulk_manage_ajax',
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- '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',
+ '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('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' => 2,
- // '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',
+ 'page arguments' => array('upload_dependency_form'),
'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_dep'] = array(
+ 'file' => 'dependency.inc',
+ 'weight' => 3,
+ );
+ $items['textbook_companion/code/edit_dep'] = array(
'title' => 'Edit Dependency',
'description' => 'Edit Dependency File',
'page callback' => 'edit_dependency',
'access arguments' => array('upload code'),
'type' => MENU_CALLBACK,
'file' => 'dependency.inc',
- );
- $items['textbook_companion/code/delete_dep'] = array(
+ );
+ $items['textbook_companion/code/delete_dep'] = array(
'title' => 'Delete Dependency',
'description' => 'Delete Dependency File',
'page callback' => 'delete_dependency',
'access arguments' => array('upload code'),
'type' => MENU_CALLBACK,
'file' => 'dependency.inc',
- );
- $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' => 'By Book Title',
- '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' => 'By Author',
- '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' => '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_search/student'] = array(
- 'title' => 'By Student',
- 'description' => '',
- 'page callback' => 'textbook_companion_browse_student',
- 'access arguments' => array('access content'),
- 'type' => MENU_LOCAL_TASK,
- 'file' => 'search.inc',
- 'weight' => 5,
- );
- $items['textbook_run'] = array(
+ );*/
+ $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-companion/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-companion/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-companion/textbook-search/book'] = array(
+ 'title' => 'By Book Title',
+ 'description' => '',
+ 'page callback' => 'textbook_companion_browse_book',
+ 'access arguments' => array(
+ 'access content'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'search.inc',
+ 'weight' => 2
+ );
+ $items['textbook-companion/textbook-search/author'] = array(
+ 'title' => 'By Author',
+ 'description' => '',
+ 'page callback' => 'textbook_companion_browse_author',
+ 'access arguments' => array(
+ 'access content'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'search.inc',
+ 'weight' => 3
+ );
+ $items['textbook-companion/textbook-search/college'] = array(
+ 'title' => '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-companion/textbook-search/student'] = array(
+ 'title' => 'By Student',
+ 'description' => '',
+ 'page callback' => 'textbook_companion_browse_student',
+ 'access arguments' => array(
+ 'access content'
+ ),
+ 'type' => MENU_LOCAL_TASK,
+ 'file' => 'search.inc',
+ 'weight' => 5
+ );
+ /* $items['textbook_run'] = array(
'title' => 'Download Codes',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('textbook_companion_run_form'),
+ 'page arguments' => array('textbook_companion_run_form_ajax'),
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM,
'file' => 'run.inc',
- );
- $items['download_codes'] = array(
+ );*/
+ $items['textbook-companion/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'
+ );
+ /*$items['textbook_run_ajax'] = array(
+ 'page callback' => 'textbook_run_ajax',
+ 'access callback' => TRUE,
+ 'file' => 'run.inc',
+ );*/
+ /*$items['download_codes'] = array(
'title' => 'Download Codes',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('textbook_companion_run_form'),
+ 'page arguments' => array('textbook_companion_run_form_ajax'),
'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(
+ );*/
+ $items['textbook-companion/download-codes'] = 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['textbook-companion/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['textbook-companion/download/samplecode'] = array(
+ 'title' => 'Sample Code Download',
+ 'description' => 'Sample Code Download',
+ 'page callback' => 'textbook_companion_download_sample_code',
+ '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('download 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('download code'),
- 'type' => MENU_CALLBACK,
- 'file' => 'full_download.inc',
- );
-
- /* external reviewer download */
- $items['full_download_external/chapter'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'textbook_companion_download_full_chapter',
- 'access arguments' => array('download books to review'),
- 'type' => MENU_CALLBACK,
- 'file' => 'full_download.inc',
- );
- $items['full_download_external/book'] = array(
- 'title' => 'Code Download',
- 'description' => 'Code Download',
- 'page callback' => 'textbook_companion_download_full_book',
- 'access arguments' => array('download books to review'),
- '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',
- );
- // $items["nonaicte_proposal"] = array(
- // "title" => "Book Suggestion Form ",
- // "description" => "NON-AICTE Book Proposal Form",
- // 'page callback' => 'textbook_companion_nonaicte_proposal_all',
- // 'access arguments' => array('create book proposal'),
- // 'type' => MENU_NORMAL_ITEM,
- // );
- return $items;
+ );*/
+ $items['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/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'
+ );
+ /* external reviewer download */
+ $items['textbook-companion/full-download-external/chapter'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'textbook_companion_download_full_chapter',
+ 'access arguments' => array(
+ 'download books to review'
+ ),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'full_download.inc'
+ );
+ $items['textbook-companion/full-download-external/book'] = array(
+ 'title' => 'Code Download',
+ 'description' => 'Code Download',
+ 'page callback' => 'textbook_companion_download_full_book',
+ 'access arguments' => array(
+ 'download books to review'
+ ),
+ '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' => 'Textbook 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['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/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['textbook-companion/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'
+ );
+ $items["textbook-companion/nonaicte-proposal"] = array(
+ "title" => "Book Suggestion Form ",
+ "description" => "NON-AICTE Book Proposal Form",
+ 'page callback' => 'textbook_companion_nonaicte_proposal_all',
+ 'access arguments' => array(
+ 'create book proposal'
+ ),
+ 'type' => MENU_CALLBACK
+ );
+ 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', 'download books to review');
+function textbook_companion_permission()
+{
+ return array(
+ "create book proposal" => array(
+ "title" => t("Book Proposal Form"),
+ "description" => t("Book Proposal Form.")
+ ),
+ "approve book proposal" => array(
+ "title" => t("Approve book proposal"),
+ "description" => t("Allows users to approve book proposal.")
+ ),
+ "approve code" => array(
+ "title" => t("Approve code"),
+ "description" => t("Allows users to approve code.")
+ ),
+ "upload code" => array(
+ "title" => t("Upload code"),
+ "description" => t("Allows users to upload code.")
+ ),
+ "edit uploaded code" => array(
+ "title" => t("Edit uploaded code"),
+ "description" => t("Allows users to edit uploaded code.")
+ ),
+ "download code" => array(
+ "title" => t("Download code"),
+ "description" => t("Allows users to download code.")
+ ),
+ "create feedback" => array(
+ "title" => t("Create feedback"),
+ "description" => t("Allows users to create feedback.")
+ ),
+ "bulk manage code" => array(
+ "title" => t("Bulk manage code"),
+ "description" => t("Allows users to manage Bulk code.")
+ ),
+ "bulk delete code" => array(
+ "title" => t("Bulk delete code"),
+ "description" => t("Allows users to delete bulk code.")
+ ),
+ "edit book proposal" => array(
+ "title" => t("Edit book proposal"),
+ "description" => t("Allows users to edit book proposal.")
+ ),
+ "administer book companion" => array(
+ "title" => t("Administer book companion"),
+ "description" => t("Allows users to administer book companion.")
+ ),
+ "generate book" => array(
+ "title" => t("Generate book"),
+ "description" => t("Allows users to generate book.")
+ ),
+ "cheque contct form" => array(
+ "title" => t("Cheque contact form"),
+ "description" => t("Cheque contct form.")
+ ),
+ "contact_details" => array(
+ "title" => t("Contact_details"),
+ "description" => t("Contact_details.")
+ ),
+ "comment cheque" => array(
+ "title" => t("Comment cheque"),
+ "description" => t("Comment cheque.")
+ ),
+ "list all certificates" => array(
+ "title" => t("list all certificates"),
+ "description" => t("Allows users to list all certificates.")
+ ),
+ "generate pdf" => array(
+ "title" => t("Generate pdf"),
+ "description" => t("Allows users to Generate pdf.")
+ ),
+ "paper submission form" => array(
+ "title" => t("paper submission form"),
+ "description" => t("Paper submission form.")
+ ),
+ "cheque status form" => array(
+ "title" => t("Cheque status form"),
+ "description" => t("Cheque status form.")
+ ),
+ "cheque report form" => array(
+ "title" => t("Cheque report form"),
+ "description" => t("Cheque report form.")
+ ),
+ "cheque proposal" => array(
+ "title" => t("Cheque proposal"),
+ "description" => t("Cheque proposal.")
+ ),
+ "download books to review" => array(
+ "title" => t("download books to review"),
+ "description" => t("Download books to review.")
+ )
+ );
}
-
/* Aicte books pickup before the proposal form */
-function textbook_companion_aicte_proposal_form($form_state) {
- $query = "
- SELECT * FROM textbook_companion_aicte
- WHERE status = 0 AND selected = 0
- ";
- $result = db_query($query);
-
- $form = array();
- $form["wrapper"] = array(
- "#type" => "fieldset",
- "#prefix" => "<div id='aicte-form-wrapper'>",
- "#suffix" => "</div>",
- );
- $num_rows = mysql_num_rows($result);
- if ($num_rows > 0) {
- while($row = db_fetch_object($result)) {
- /* fixing title string */
- $title = "";
- $edition = "";
- $year = "";
- $title = "{$row->book} by {$row->author}";
- if($row->edition) {
- $edition = "<i>ed</i>: {$row->edition}";
- }
- if($row->year) {
- if($row->edition) {
- $year = ", <i>pub</i>: {$row->year}";
- } else {
- $year = "<i>pub</i>: {$row->year}";
- }
- }
- if($edition or $year) {
- $title .= "({$edition} {$year})";
- }
- $form["wrapper"][$row->id] = array(
- "#type" => "checkbox",
- "#title" => $title,
- "#prefix" => "<div class='title'>",
- "#suffix" => "</div>",
- );
- }
- }
- $form["submit"] = array(
- "#type" => "submit",
- "#value" => "Submit Book Selections"
- );
- return $form;
+/*function textbook_companion_aicte_proposal_form($form_state) {
+/* $query = "
+SELECT * FROM textbook_companion_aicte
+WHERE status = 0 AND selected = 0
+";
+$result = db_query($query);*/
+/* $query = "
+SELECT * FROM textbook_companion_aicte
+WHERE status = :status AND selected = :selected
+";
+$args = array(
+':status' => 0,
+':selected' => 0,
+);
+$result = db_query($query,$args); */
+/* $query = db_select('textbook_companion_aicte');
+$query->fields('textbook_companion_aicte');
+$query->condition('status', 0);
+$query->condition('selected', 0);
+$result = $query->execute();
+
+$form = array();
+$form["wrapper"] = array(
+"#type" => "fieldset",
+"#prefix" => "<div id='aicte-form-wrapper'>",
+"#suffix" => "</div>",
+);
+// $num_rows = mysql_num_rows($result);
+$num_rows = $query->countQuery();
+if ($num_rows > 0) {
+while($row = $result->fetchObject()) {
+/* fixing title string */
+/* $title = "";
+$edition = "";
+$year = "";
+$title = "{$row->book} by {$row->author}";
+if($row->edition) {
+$edition = "<i>ed</i>: {$row->edition}";
}
-
-function textbook_companion_aicte_proposal_form_validate($form, &$form_state) {
- $query = "
- SELECT * FROM textbook_companion_aicte
- WHERE status = 0 AND selected = 0
- ";
- $result = db_query($query);
-
- $count = 0;
- $selections = array();
- while($row = db_fetch_object($result)) {
- if($form_state["values"][$row->id] == 1) {
- $count++;
- array_push($selections, $row->id);
- }
- }
- /* user can choose only 3 books to propose */
- if($count != 3) {
- form_set_error("", "Please select exactly <strong>3</strong> books. You currently selected <strong>{$count}</strong>");
- } else {
- $form_state["values"]["selections"] = $selections;
- }
+if($row->year) {
+if($row->edition) {
+$year = ", <i>pub</i>: {$row->year}";
+} else {
+$year = "<i>pub</i>: {$row->year}";
}
-
-function textbook_companion_aicte_proposal_form_submit($form, &$form_state) {
- global $user;
- $selections = $form_state["values"]["selections"];
- variable_set("aicte_".$user->uid, $selections);
- drupal_goto("proposal");
}
-
-
-
-
-function textbook_companion_aicte_proposal_all() {
+if($edition or $year) {
+$title .= "({$edition} {$year})";
+}
+$form["wrapper"][$row->id] = array(
+"#type" => "checkbox",
+"#title" => $title,
+"#prefix" => "<div class='title'>",
+"#suffix" => "</div>",
+);
+}
+}
+$form["submit"] = array(
+"#type" => "submit",
+"#value" => "Submit Book Selections"
+);
+return $form;
+}*/
+/*function textbook_companion_aicte_proposal_form_validate($form, &$form_state) {
+/*$query = "
+SELECT * FROM textbook_companion_aicte
+WHERE status = 0 AND selected = 0
+";
+$result = db_query($query);*/
+/*$query = db_select('textbook_companion_aicte');
+$query->fields('textbook_companion_aicte');
+$query->condition('status', 0);
+$query->condition('selected', 0);
+$result = $query->execute();
+
+$count = 0;
+$selections = array();
+while($row = $result->fetchObject()) {
+if($form_state["values"][$row->id] == 1) {
+$count++;
+array_push($selections, $row->id);
+}
+}
+/* user can choose only 3 books to propose */
+/* if($count != 3) {
+form_set_error("", "Please select exactly <strong>3</strong> books. You currently selected <strong>{$count}</strong>");
+} else {
+$form_state["values"]["selections"] = $selections;
+}
+}*/
+/*function textbook_companion_aicte_proposal_form_submit($form, &$form_state) {
+global $user;
+$selections = $form_state["values"]["selections"];
+var_dump($selections);
+variable_set("aicte_".$user->uid, $selections);
+drupal_goto("proposal");
+}*/
+/*function textbook_companion_aicte_report_form($form_state) {
+/*$query = "
+SELECT * FROM textbook_companion_aicte
+WHERE status = 0
+ORDER BY book
+";
+$result = db_query($query);*/
+/*$query = db_select('textbook_companion_aicte');
+$query->fields('textbook_companion_aicte');
+$query->condition('status', 0);
+$query->orderBy('book', 'ASC');
+$result = $query->execute();
+
+$books = array();
+$books[0] = "Please select a book";
+while($row = $result->fetchObject()) {
+$books[$row->id] = "{$row->book} ({$row->author})";
+}
+$form = array();
+$form["name"] = array(
+"#type" => "textfield",
+"#title" => "Name",
+"#description" => t("Please enter your name."),
+);
+$form["email"] = array(
+"#type" => "textfield",
+"#title" => "Email",
+"#description" => t("Please enter your valid email id."),
+);
+$form["number"] = array(
+"#type" => "textfield",
+"#title" => "Number",
+"#description" => t("Please enter your valid phone number."),
+);
+$form["book"] = array(
+"#type" => "select",
+"#title" => "AICTE Book",
+"#description" => t("Please select a book."),
+"#options" => $books
+);
+$form["comment"] = array(
+"#type" => "textarea",
+"#title" => "Any other comment?",
+"#description" => t("Please enter your query (if any)")
+);
+$form["submit"] = array(
+"#type" => "submit",
+"#value" => "Submit"
+);
+return $form;
+}
+*/
+/*function textbook_companion_aicte_report_form_submit($form, &$form_state) {
+$v = $form_state["values"];
+
+/*$query = "
+INSERT INTO textbook_companion_aicte_report
+(aicte_id, name, number, email, comment)
+VALUES
+(%d, '%s', '%s', '%s', '%s')
+";
+$result = db_query($query,
+$v["book"], $v["name"], $v["number"], $v["email"], $v["comment"]
+);*/
+/*$query = "INSERT INTO textbook_companion_aicte_report
+(aicte_id, name, number, email, comment)
+VALUES (:aicte_id, :name, :number, :email, :comment)";
+$args = array(
+":aicte_id" => $v["book"],
+":name" => $v["name"],
+":number" => $v["number"],
+":email" =>$v["email"],
+":comment" => $v["comment"]
+);
+$result = db_query($query, $args, array('return' => Database::RETURN_INSERT_ID));
+
+drupal_set_message("Thank you for reporting.", "status");
+}
+*/
+function textbook_companion_aicte_proposal_all()
+{
global $user;
$page_content = "";
-
if (!$user->uid) {
- $query = "
- SELECT * FROM textbook_companion_aicte
- WHERE status = 0
+ /*$query = "
+ SELECT * FROM textbook_companion_aicte
+ WHERE status = 0
";
- $result = db_query($query);
-
+ $result = db_query($query);*/
+ $query = db_select('textbook_companion_aicte');
+ $query->fields('textbook_companion_aicte');
+ $query->condition('status', 0);
+ $result = $query->execute();
$page_content .= "<ul>";
$page_content .= "<li>These are the list of books available for <em>Textbook Companion</em> proposal.</li>";
$page_content .= "<li>Please <a href='/user'><b><u>Login</u></b></a> to create a proposal.</li>";
@@ -662,26 +1032,26 @@ function textbook_companion_aicte_proposal_all() {
$page_content .= "Search : <input type='text' id='searchtext' style='width:82%'/>";
$page_content .= "<input type='button' value ='clear' id='search_clear'/>";
$page_content .= "<div id='aicte-list-wrapper'>";
- $num_rows = mysql_num_rows($result);
+ $num_rows = $result->rowCount();
if ($num_rows > 0) {
$i = 1;
- while($row = db_fetch_object($result)) {
+ while ($row = $result->fetchObject()) {
/* fixing title string */
$title = "";
$edition = "";
$year = "";
$title = "{$row->book} by {$row->author}";
- if($row->edition) {
+ if ($row->edition) {
$edition = "<i>ed</i>: {$row->edition}";
}
- if($row->year) {
- if($row->edition) {
+ if ($row->year) {
+ if ($row->edition) {
$year = ", <i>pub</i>: {$row->year}";
} else {
$year = "<i>pub</i>: {$row->year}";
}
}
- if($edition or $year) {
+ if ($edition or $year) {
$title .= "({$edition} {$year})";
}
$page_content .= "<div class='title'>{$i}) {$title}</div>";
@@ -693,742 +1063,1592 @@ function textbook_companion_aicte_proposal_all() {
//$page_content .= drupal_get_form("textbook_companion_aicte_report_form");
return $page_content;
}
-
/* 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);
+ /* $proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE uid = %d ORDER BY id DESC LIMIT 1", $user->uid);*/
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
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;
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ 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;
}
}
}
-
- variable_del("aicte_".$user->uid);
+ variable_del("aicte_" . $user->uid);
$page_content .= "<h5><b>* Please select any 3 books from the below list.</b></h5></br>";
//$page_content .= "Unable to propose particular book: <a id='aicte-report' href='#'>Click here</a></br></br>";
//$page_content .= "Do not wish to propose any of the below books: <a id='aicte-report' href='http://fossee.in/feedback/scilab-aicte' target = _blank>Click here</a></br></br>";
$page_content .= "Search : <input type='text' id='searchtext' style='width:82%'/>";
- $page_content .= "<input type='button' value ='clear' id='search_clear'/>";
+ $page_content .= "<input type='button' value ='clear' id='search_clear'/>";
//$page_content .= drupal_get_form("textbook_companion_aicte_report_form");
- $page_content .= drupal_get_form("textbook_companion_aicte_proposal_form");
+ $textbook_companion_aicte_proposal_form = drupal_get_form("textbook_companion_aicte_proposal_form");
+ $page_content .= drupal_render($textbook_companion_aicte_proposal_form);
return $page_content;
}
/*non aicte book proposal */
-function textbook_companion_nonaicte_proposal_all() {
+function textbook_companion_nonaicte_proposal_all()
+{
global $user;
$page_content = "";
-
if (!$user->uid) {
-
- $page_content .= "<ul>";
- $page_content .= "<li>Please <a href='/user'><b><u>Login</u></b></a> to create a proposal.</li>";
- $page_content .= "</ul>";
+ $page_content .= "<ul>";
+ $page_content .= "<li>Please <a href='/user'><b><u>Login</u></b></a> to create a proposal.</li>";
+ $page_content .= "</ul>";
return $page_content;
}
-
/* 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);
+ /*$proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE uid = %d ORDER BY id DESC LIMIT 1", $user->uid);*/
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
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;
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ 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;
+ case 5:
+ drupal_set_message(t('You have submitted your all codes.'), 'status');
+ drupal_goto('');
+ return;
+ break;
+ default:
+ drupal_set_message(t('Invalid proposal state. Please contact site administrator for further information.'), 'error');
+ drupal_goto('');
+ return;
+ break;
}
}
}
-
- //variable_del("aicte_".$user->uid);
- $page_content .= drupal_get_form("book_proposal_nonaicte_form");
+ //variable_del("aicte_".$user->uid);
+ $book_proposal_nonaicte_form = drupal_get_form("book_proposal_nonaicte_form");
+ $page_content .= drupal_render($book_proposal_nonaicte_form);
return $page_content;
}
-
/* Textbook Companion Proposal */
-function textbook_companion_proposal_all() {
+function textbook_companion_proposal_all()
+{
global $user;
$page_content = "";
-
- // if (!$user->uid) {
- // drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
- // return;
- // }
-
+ if (!$user->uid) {
+ drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
+ drupal_goto('');
+ 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);
+ /*$proposal_q = db_query("SELECT * FROM {textbook_companion_proposal} WHERE uid = %d ORDER BY id DESC LIMIT 1", $user->uid);*/
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal');
+ $query->condition('uid', $user->uid);
+ $query->orderBy('id', 'DESC');
+ $query->range(0, 1);
+ $proposal_q = $query->execute();
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;
+ if ($proposal_data = $proposal_q->fetchObject()) {
+ 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;
}
}
}
-
- $selections = variable_get("aicte_".$user->uid, "");
- if($selections) {
- $selections = implode(",", $selections);
- $query = "
- SELECT * FROM textbook_companion_aicte
- WHERE id IN ({$selections})
- ";
- $result = db_query($query);
- $row1 = db_fetch_object($result);
- $row2 = db_fetch_object($result);
- $row3 = db_fetch_object($result);
- $page_content .= drupal_get_form("book_proposal_form", $row1, $row2, $row3);
- } else {
- $page_content .= drupal_get_form("book_proposal_form");
- // drupal_goto("aicte_proposal");
- }
-
+ $book_proposal_form = drupal_get_form("book_proposal_form");
+ $page_content .= drupal_render($book_proposal_form);
+ // drupal_goto("aicte_proposal");
return $page_content;
}
-
-function book_proposal_form($form_state, $row1=NULL, $row2=NULL, $row3=NULL)
+/*function book_proposal_form($form, $form_state)
{
- global $user;
- $form = array();
- $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['gender'] = array(
- '#type' => 'radios',
- '#title' => t('Gender'),
- '#options' => array('M' => 'Male', 'F' => 'Female'),
- '#required' => TRUE,
- );
-
- $form['how_project'] = array(
- '#type' => 'select',
- '#title' => t('How did you come to know about this project'),
- '#options' => array('DWSIM Website' => 'DWSIM 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' => 'hidden',
- '#value' => 'None',
- '#title' => t('College Teacher/Professor'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['faculty_email'] = array(
- '#type' => 'hidden',
- '#value' => 'None',
- '#title' => t('Teacher/Professor Email Id'),
- '#default_value' => '@email.com',
- '#size' => 30,
- '#maxlength' => 50,
- );
- $form['reviewer'] = array(
- '#type' => 'hidden',
- '#value' => 'None',
- '#title' => t('Reviewer'),
- '#size' => 30,
- '#maxlength' => 50,
- );
- $form['version'] = array(
- '#type' => 'select',
- '#title' => t('Version'),
- '#options' => array('scilab 5.4.1' => 'Scilab 5.4.1',
- 'scilab 5.3.3' => 'Scilab 5.3.3',
- 'olderversion' => 'Older Version'),
- '#required' => TRUE,
- );
- $form['older'] = array(
- '#type' => 'textfield',
- '#size' => 30,
- '#maxlength' => 50,
- //'#required' => TRUE,
- '#description' => t('Specify the Older version used'),
- );
- $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,
- '#value' => $row1->book,
- '#disabled' => ($row1->book?TRUE:FALSE),
- );
- $form['preference1']['author1'] = array(
- '#type' => 'textfield',
- '#title' => t('Author Name'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#value' => $row1->author,
- '#disabled' => ($row1->author?TRUE:FALSE),
- );
- $form['preference1']['isbn1'] = array(
- '#type' => 'textfield',
- '#title' => t('ISBN No'),
- '#size' => 30,
- '#maxlength' => 25,
- '#required' => TRUE,
- '#value' => $row1->isbn,
- '#disabled' => ($row1->isbn?TRUE:FALSE),
- );
- $form['preference1']['publisher1'] = array(
- '#type' => 'textfield',
- '#title' => t('Publisher & Place'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#value' => $row1->publisher,
- );
- $form['preference1']['edition1'] = array(
- '#type' => 'textfield',
- '#title' => t('Edition'),
- '#size' => 4,
- '#maxlength' => 2,
- '#required' => TRUE,
- '#value' => $row1->edition,
- );
- $form['preference1']['year1'] = array(
- '#type' => 'textfield',
- '#title' => t('Year of pulication'),
- '#size' => 4,
- '#maxlength' => 4,
- '#required' => TRUE,
- '#value' => $row1->year,
- );
- $form['preference2'] = array(
+global $user;
+$form = array();
+$form['imp_notice'] = array(
+'#type' => 'item',
+'#markup' => '<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['gender'] = array(
+'#type' => 'radios',
+'#title' => t('Gender'),
+'#options' => array(
+'M' => 'Male',
+'F' => 'Female'
+),
+'#required' => TRUE
+);
+$form['how_project'] = array(
+'#type' => 'select',
+'#title' => t('How did you come to know about this project'),
+'#options' => array(
+'DWSIM Website' => 'DWSIM 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' => _list_of_departments(),
+'#required' => TRUE
+);
+$form['university'] = array(
+'#type' => 'textfield',
+'#title' => t('University/ Institute'),
+'#size' => 80,
+'#maxlength' => 200,
+'#required' => TRUE,
+'#attributes' => array(
+'placeholder' => 'Insert full name of your institute/ university.... '
+)
+);
+$form['country'] = array(
+'#type' => 'select',
+'#title' => t('Country'),
+'#options' => array(
+'India' => 'India',
+'Others' => 'Others'
+),
+'#required' => TRUE,
+'#tree' => TRUE,
+'#validated' => TRUE
+);
+$form['other_country'] = array(
+'#type' => 'textfield',
+'#title' => t('Other than India'),
+'#size' => 100,
+'#attributes' => array(
+'placeholder' => t('Enter your country name')
+),
+'#states' => array(
+'visible' => array(
+':input[name="country"]' => array(
+'value' => 'Others'
+)
+)
+)
+);
+$form['other_state'] = array(
+'#type' => 'textfield',
+'#title' => t('State other than India'),
+'#size' => 100,
+'#attributes' => array(
+'placeholder' => t('Enter your state/region name')
+),
+'#states' => array(
+'visible' => array(
+':input[name="country"]' => array(
+'value' => 'Others'
+)
+)
+)
+);
+$form['other_city'] = array(
+'#type' => 'textfield',
+'#title' => t('City other than India'),
+'#size' => 100,
+'#attributes' => array(
+'placeholder' => t('Enter your city name')
+),
+'#states' => array(
+'visible' => array(
+':input[name="country"]' => array(
+'value' => 'Others'
+)
+)
+)
+);
+$form['all_state'] = array(
+'#type' => 'select',
+'#title' => t('State'),
+'#selected' => array(
+'' => '-select-'
+),
+'#options' => _list_of_states(),
+'#validated' => TRUE,
+'#states' => array(
+'visible' => array(
+':input[name="country"]' => array(
+'value' => 'India'
+)
+)
+)
+);
+$form['city'] = array(
+'#type' => 'select',
+'#title' => t('City'),
+'#options' => _list_of_cities(),
+'#states' => array(
+'visible' => array(
+':input[name="country"]' => array(
+'value' => 'India'
+)
+)
+)
+);
+$form['pincode'] = array(
+'#type' => 'textfield',
+'#title' => t('Pincode'),
+'#size' => 30,
+'#maxlength' => 6,
+'#required' => False,
+'#attributes' => array(
+'placeholder' => 'Enter pincode....'
+)
+);
+/***************************************************************************/
+/* $form['hr'] = array(
+'#type' => 'item',
+'#markup' => '<hr>'
+);
+$form['faculty'] = array(
+'#type' => 'hidden',
+'#value' => 'None',
+'#title' => t('College Teacher/Professor'),
+'#size' => 30,
+'#maxlength' => 50,
+'#required' => TRUE
+);
+$form['faculty_email'] = array(
+'#type' => 'hidden',
+'#value' => 'None',
+'#title' => t('Teacher/Professor Email Id'),
+'#value' => '@email.com',
+'#size' => 30,
+'#maxlength' => 50
+);
+$form['reviewer'] = array(
+'#type' => 'hidden',
+'#value' => 'None',
+'#title' => t('Reviewer'),
+'#size' => 30,
+'#maxlength' => 50
+);
+
+$form['version'] = array(
+'#type' => 'select',
+'#title' => t('Version'),
+'#options' => _list_of_software_version(),
+'#required' => TRUE
+);
+$form['older'] = array(
+'#type' => 'textfield',
+'#size' => 30,
+'#maxlength' => 50,
+//'#required' => TRUE,
+'#description' => t('Specify the Older version used'),
+'#states' => array(
+'visible' => array(
+':input[name="version"]' => array(
+'value' => 'olderversion'
+)
+)
+)
+);
+$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
+);
+$reason = array(
+'Used in more than one University' => t('Used in more than one University'),
+'The book has multiple editions' => t('The book has multiple editions'),
+'Extremely useful' => t('Extremely useful'),
+'Other reason' => t('Any other reason state below')
+);
+$form['reason'] = array(
+'#type' => 'hidden',
+'#default_value' => 'Not available'
+);
+/*$form['reason'] = array(
+'#type' => 'checkboxes',
+'#title' => t('Reasons'),
+'#options' => $reason,
+'#required' => TRUE
+);
+$form['other_reason'] = array(
+'#type' => 'textarea',
+'#size' => 300,
+'#maxlength' => 300,
+'#states' => array(
+'visible' => array(
+':input[name="reason[Other reason]"]' => array(
+'checked' => TRUE
+)
+)
+)
+//'#required' => FALSE,
+);*/
+/*$form['proposal_type'] = array(
+'#type' => 'hidden',
+'#default_value' => '0',
+'#required' => FALSE
+);
+$form['reference'] = array(
+'#type' => 'hidden',
+'#default_value' => 'Not available',
+);
+/*$form['reference'] = array(
+'#type' => 'textarea',
+'#title' => t('Reference'),
+'#required' => TRUE,
+'#size' => 500,
+'#maxlength' => 500,
+'#attributes' => array(
+'placeholder' => 'Links of the syllabus must be provided....'
+)
+);*/
+/*$form['scilab_version'] = array(
+'#type' => 'textfield',
+'#title' => t('Scilab Version'),
+'#required' => TRUE,
+'#size' => 10,
+'#maxlength' => 10,
+);*/
+/*$form['form_type'] = array(
+'#type' => 'hidden',
+'#value' => 1
+);
+$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
+//'#value' => $row1->author,
+//'#disabled' => ($row1->author?TRUE:FALSE),
+);
+$form['preference1']['isbn1'] = array(
+'#type' => 'textfield',
+'#title' => t('ISBN No'),
+'#size' => 30,
+'#maxlength' => 25,
+'#required' => TRUE
+// '#value' => $row1->isbn,
+// '#disabled' => ($row1->isbn?TRUE:FALSE),
+);
+$form['preference1']['publisher1'] = array(
+'#type' => 'textfield',
+'#title' => t('Publisher & Place'),
+'#size' => 30,
+'#maxlength' => 50,
+'#required' => TRUE
+//'#value' => $row1->publisher,
+);
+$form['preference1']['edition1'] = array(
+'#type' => 'textfield',
+'#title' => t('Edition'),
+'#size' => 4,
+'#maxlength' => 2,
+'#required' => TRUE
+//'#value' => $row1->edition,
+);
+$form['preference1']['year1'] = array(
+'#type' => 'textfield',
+'#title' => t('Year of pulication'),
+'#size' => 4,
+'#maxlength' => 4,
+'#required' => TRUE
+//'#value' => $row1->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
+//'#value' => $row2->book,
+//'#disabled' => ($row2->book?TRUE:FALSE),
+);
+$form['preference2']['author2'] = array(
+'#type' => 'textfield',
+'#title' => t('Author Name'),
+'#size' => 30,
+'#maxlength' => 100,
+'#required' => TRUE
+//'#value' => $row2->author,
+//'#disabled' => ($row2->author?TRUE:FALSE),
+);
+$form['preference2']['isbn2'] = array(
+'#type' => 'textfield',
+'#title' => t('ISBN No'),
+'#size' => 30,
+'#maxlength' => 25,
+'#required' => TRUE
+// '#value' => $row2->isbn,
+// '#disabled' => ($row2->isbn?TRUE:FALSE),
+);
+$form['preference2']['publisher2'] = array(
+'#type' => 'textfield',
+'#title' => t('Publisher & Place'),
+'#size' => 30,
+'#maxlength' => 50,
+'#required' => TRUE
+//'#value' => $row2->publisher,
+);
+$form['preference2']['edition2'] = array(
+'#type' => 'textfield',
+'#title' => t('Edition'),
+'#size' => 4,
+'#maxlength' => 2,
+'#required' => TRUE
+//'#value' => $row2->edition,
+);
+$form['preference2']['year2'] = array(
+'#type' => 'textfield',
+'#title' => t('Year of pulication'),
+'#size' => 4,
+'#maxlength' => 4,
+'#required' => TRUE
+//'#value' => $row2->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
+//'#value' => $row3->book,
+//'#disabled' => ($row3->book?TRUE:FALSE),
+);
+$form['preference3']['author3'] = array(
+'#type' => 'textfield',
+'#title' => t('Author Name'),
+'#size' => 30,
+'#maxlength' => 100,
+'#required' => TRUE
+//'#value' => $row3->author,
+// '#disabled' => ($row3->author?TRUE:FALSE),
+);
+$form['preference3']['isbn3'] = array(
+'#type' => 'textfield',
+'#title' => t('ISBN No'),
+'#size' => 30,
+'#maxlength' => 25,
+'#required' => TRUE
+//'#value' => $row3->isbn,
+//'#disabled' => ($row3->isbn?TRUE:FALSE),
+);
+$form['preference3']['publisher3'] = array(
+'#type' => 'textfield',
+'#title' => t('Publisher & Place'),
+'#size' => 30,
+'#maxlength' => 50,
+'#required' => TRUE
+// '#value' => $row3->publisher,
+);
+$form['preference3']['edition3'] = array(
+'#type' => 'textfield',
+'#title' => t('Edition'),
+'#size' => 4,
+'#maxlength' => 2,
+'#required' => TRUE
+//'#value' => $row3->edition,
+);
+$form['preference3']['year3'] = array(
+'#type' => 'textfield',
+'#title' => t('Year of pulication'),
+'#size' => 4,
+'#maxlength' => 4,
+'#required' => TRUE
+//'#value' => $row3->year,
+);
+/*$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['samplefile'] = array(
+'#type' => 'fieldset',
+'#title' => t('Sample Source Files'),
+'#collapsible' => FALSE,
+'#collapsed' => FALSE
+);*/
+/*$form['samplefile']['samplefile1'] = array(
+'#type' => 'file',
+'#title' => t('Upload sample source file'),
+'#size' => 48,
+'#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('textbook_companion_source_extensions', '') . '</span>'
+);*/
+/*$form['submit'] = array(
+'#type' => 'submit',
+'#value' => t('Submit')
+);
+$form['dir_name1'] = array(
+'#type' => 'hidden',
+'#value' => 'None'
+);
+$form['dir_name2'] = array(
+'#type' => 'hidden',
+'#value' => 'None'
+);
+$form['dir_name3'] = array(
+'#type' => 'hidden',
+'#value' => 'None'
+);
+/* #value fix for #default_value bug drupal6
+foreach(array("preference1", "preference2", "preference3") as $preference) {
+foreach($form[$preference] as $key => $value) {
+if(!$form[$preference][$key]["#value"]) {
+unset($form[$preference][$key]["#value"]);
+}
+}
+}*/
+/* return $form;
+}*/
+function book_proposal_form($form, $form_state)
+{
+ global $user;
+ $form = array();
+ $form['imp_notice'] = array(
+ '#type' => 'item',
+ '#markup' => '<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['gender'] = array(
+ '#type' => 'radios',
+ '#title' => t('Gender'),
+ '#options' => array(
+ 'M' => 'Male',
+ 'F' => 'Female'
+ ),
+ '#required' => TRUE
+ );
+ $form['how_project'] = array(
+ '#type' => 'select',
+ '#title' => t('How did you come to know about this project'),
+ '#options' => array(
+ 'DWSIM Website' => 'DWSIM 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' => _list_of_departments(),
+ '#required' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/ Institute'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#required' => TRUE,
+ '#attributes' => array(
+ 'placeholder' => 'Insert full name of your institute/ university.... '
+ )
+ );
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#required' => TRUE,
+ '#tree' => TRUE,
+ '#validated' => TRUE
+ );
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#selected' => array(
+ '' => '-select-'
+ ),
+ '#options' => _list_of_states(),
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _list_of_cities(),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#required' => False,
+ '#attributes' => array(
+ 'placeholder' => 'Enter pincode....'
+ )
+ );
+ /***************************************************************************/
+ $form['hr'] = array(
+ '#type' => 'item',
+ '#markup' => '<hr>'
+ );
+ $form['faculty'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None',
+ '#title' => t('College Teacher/Professor'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE
+ );
+ $form['faculty_email'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None',
+ '#title' => t('Teacher/Professor Email Id'),
+ '#value' => '@email.com',
+ '#size' => 30,
+ '#maxlength' => 50
+ );
+ $form['reviewer'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None',
+ '#title' => t('Reviewer'),
+ '#size' => 30,
+ '#maxlength' => 50
+ );
+ $form['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Version'),
+ '#options' => _list_of_software_version(),
+ '#required' => TRUE
+ );
+ $form['older'] = array(
+ '#type' => 'textfield',
+ '#size' => 30,
+ '#maxlength' => 50,
+ //'#required' => TRUE,
+ '#description' => t('Specify the Older version used'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="version"]' => array(
+ 'value' => 'olderversion'
+ )
+ )
+ )
+ );
+ $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
+ );
+ $reason = array(
+ 'Used in more than one University' => t('Used in more than one University'),
+ 'The book has multiple editions' => t('The book has multiple editions'),
+ 'Extremely useful' => t('Extremely useful'),
+ 'Other reason' => t('Any other reason state below')
+ );
+ $form['reason'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Reasons'),
+ '#options' => $reason,
+ '#required' => TRUE
+ );
+ $form['other_reason'] = array(
+ '#type' => 'textarea',
+ '#size' => 300,
+ '#maxlength' => 300,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="reason[Other reason]"]' => array(
+ 'checked' => TRUE
+ )
+ )
+ )
+ //'#required' => FALSE,
+ );
+ $form['proposal_type'] = array(
+ '#type' => 'hidden',
+ '#default_value' => '1',
+ '#required' => FALSE
+ );
+ $form['reference'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reference'),
+ '#required' => TRUE,
+ '#size' => 500,
+ '#maxlength' => 500,
+ '#attributes' => array(
+ 'placeholder' => 'Links of the syllabus must be provided....'
+ )
+ );
+ $form['form_type'] = array(
+ '#type' => 'hidden',
+ '#value' => 1
+ );
+ $form['preference1'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Book Preference'),
+ '#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
+ //'#value' => $row1->author,
+ //'#disabled' => ($row1->author?TRUE:FALSE),
+ );
+ $form['preference1']['isbn1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('ISBN No'),
+ '#size' => 30,
+ '#maxlength' => 25,
+ '#required' => TRUE
+ // '#value' => $row1->isbn,
+ // '#disabled' => ($row1->isbn?TRUE:FALSE),
+ );
+ $form['preference1']['publisher1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Publisher & Place'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE
+ //'#value' => $row1->publisher,
+ );
+ $form['preference1']['edition1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Edition'),
+ '#size' => 4,
+ '#maxlength' => 2,
+ '#required' => TRUE
+ //'#value' => $row1->edition,
+ );
+ $form['preference1']['year1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Year of publication'),
+ '#size' => 4,
+ '#maxlength' => 4,
+ '#required' => TRUE
+ //'#value' => $row1->year,
+ );
+ /*$form['preference2'] = array(
'#type' => 'fieldset',
'#title' => t('Book Preference 2'),
'#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['preference2']['book2'] = array(
+ '#collapsed' => FALSE
+ );
+ $form['preference2']['book2'] = array(
'#type' => 'textfield',
'#title' => t('Title of the book'),
'#size' => 30,
'#maxlength' => 100,
- '#required' => TRUE,
- '#value' => $row2->book,
- '#disabled' => ($row2->book?TRUE:FALSE),
- );
- $form['preference2']['author2'] = array(
+ '#required' => TRUE
+ //'#value' => $row2->book,
+ //'#disabled' => ($row2->book?TRUE:FALSE),
+ );
+ $form['preference2']['author2'] = array(
'#type' => 'textfield',
'#title' => t('Author Name'),
'#size' => 30,
'#maxlength' => 100,
- '#required' => TRUE,
- '#value' => $row2->author,
- '#disabled' => ($row2->author?TRUE:FALSE),
- );
- $form['preference2']['isbn2'] = array(
+ '#required' => TRUE
+ //'#value' => $row2->author,
+ //'#disabled' => ($row2->author?TRUE:FALSE),
+ );
+ $form['preference2']['isbn2'] = array(
'#type' => 'textfield',
'#title' => t('ISBN No'),
'#size' => 30,
'#maxlength' => 25,
- '#required' => TRUE,
- '#value' => $row2->isbn,
- '#disabled' => ($row2->isbn?TRUE:FALSE),
- );
- $form['preference2']['publisher2'] = array(
+ '#required' => TRUE
+ // '#value' => $row2->isbn,
+ // '#disabled' => ($row2->isbn?TRUE:FALSE),
+ );
+ $form['preference2']['publisher2'] = array(
'#type' => 'textfield',
'#title' => t('Publisher & Place'),
'#size' => 30,
'#maxlength' => 50,
- '#required' => TRUE,
- '#value' => $row2->publisher,
- );
- $form['preference2']['edition2'] = array(
+ '#required' => TRUE
+ //'#value' => $row2->publisher,
+ );
+ $form['preference2']['edition2'] = array(
'#type' => 'textfield',
'#title' => t('Edition'),
'#size' => 4,
'#maxlength' => 2,
- '#required' => TRUE,
- '#value' => $row2->edition,
- );
- $form['preference2']['year2'] = array(
+ '#required' => TRUE
+ //'#value' => $row2->edition,
+ );
+ $form['preference2']['year2'] = array(
'#type' => 'textfield',
'#title' => t('Year of pulication'),
'#size' => 4,
'#maxlength' => 4,
- '#required' => TRUE,
- '#value' => $row2->year,
- );
- $form['preference3'] = array(
+ '#required' => TRUE
+ //'#value' => $row2->year,
+ );
+ $form['preference3'] = array(
'#type' => 'fieldset',
'#title' => t('Book Preference 3'),
'#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['preference3']['book3'] = array(
+ '#collapsed' => FALSE
+ );
+ $form['preference3']['book3'] = array(
'#type' => 'textfield',
'#title' => t('Title of the book'),
'#size' => 30,
'#maxlength' => 100,
- '#required' => TRUE,
- '#value' => $row3->book,
- '#disabled' => ($row3->book?TRUE:FALSE),
- );
- $form['preference3']['author3'] = array(
+ '#required' => TRUE
+ //'#value' => $row3->book,
+ //'#disabled' => ($row3->book?TRUE:FALSE),
+ );
+ $form['preference3']['author3'] = array(
'#type' => 'textfield',
'#title' => t('Author Name'),
'#size' => 30,
'#maxlength' => 100,
- '#required' => TRUE,
- '#value' => $row3->author,
- '#disabled' => ($row3->author?TRUE:FALSE),
- );
- $form['preference3']['isbn3'] = array(
+ '#required' => TRUE
+ //'#value' => $row3->author,
+ // '#disabled' => ($row3->author?TRUE:FALSE),
+ );
+ $form['preference3']['isbn3'] = array(
'#type' => 'textfield',
'#title' => t('ISBN No'),
'#size' => 30,
'#maxlength' => 25,
- '#required' => TRUE,
- '#value' => $row3->isbn,
- '#disabled' => ($row3->isbn?TRUE:FALSE),
- );
- $form['preference3']['publisher3'] = array(
+ '#required' => TRUE
+ //'#value' => $row3->isbn,
+ //'#disabled' => ($row3->isbn?TRUE:FALSE),
+ );
+ $form['preference3']['publisher3'] = array(
'#type' => 'textfield',
'#title' => t('Publisher & Place'),
'#size' => 30,
'#maxlength' => 50,
- '#required' => TRUE,
- '#value' => $row3->publisher,
- );
- $form['preference3']['edition3'] = array(
+ '#required' => TRUE
+ // '#value' => $row3->publisher,
+ );
+ $form['preference3']['edition3'] = array(
'#type' => 'textfield',
'#title' => t('Edition'),
'#size' => 4,
'#maxlength' => 2,
- '#required' => TRUE,
- '#value' => $row3->edition,
- );
- $form['preference3']['year3'] = array(
+ '#required' => TRUE
+ //'#value' => $row3->edition,
+ );
+ $form['preference3']['year3'] = array(
'#type' => 'textfield',
'#title' => t('Year of pulication'),
'#size' => 4,
'#maxlength' => 4,
+ '#required' => TRUE
+ //'#value' => $row3->year,
+ );
+ /*$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,
- '#value' => $row3->year,
- );
- $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')
- );
-
- /* #value fix for #default_value bug drupal6
- foreach(array("preference1", "preference2", "preference3") as $preference) {
+ );*/
+ $form['samplefile'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Sample Source Files'),
+ '#collapsible' => FALSE,
+ '#collapsed' => FALSE
+ );
+ $form['samplefile']['samplefile1'] = array(
+ '#type' => 'file',
+ '#title' => t('Upload sample source file'),
+ '#size' => 48,
+ '#description' => t('Separate filenames with underscore. No spaces or any special characters allowed in filename.') . '<br />' . t('<span style="color:red;">Allowed file extensions : ') . variable_get('textbook_companion_source_extensions', '') . '</span>'
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ $form['dir_name'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None'
+ );
+ /* #value fix for #default_value bug drupal6
+ foreach(array("preference1", "preference2", "preference3") as $preference) {
foreach($form[$preference] as $key => $value) {
- if(!$form[$preference][$key]["#value"]) {
- unset($form[$preference][$key]["#value"]);
- }
+ if(!$form[$preference][$key]["#value"]) {
+ unset($form[$preference][$key]["#value"]);
}
- } */
- return $form;
+ }
+ }*/
+ 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']))
+ /* 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 */
+ $cur_year = date('Y');
+ if (!preg_match('/^[A-Za-z]/', $form_state['values']['book1']))
+ form_set_error('book1', t('Invalid book name for Book Preference 1'));
+ if (!preg_match('/^[A-Za-z]/', $form_state['values']['author1']))
+ if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn1']))
+ form_set_error('isbn1', t('Invalid ISBN for Book Preference 1'));
+ 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-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 ((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 ($form_state['values']['book1'] && $form_state['values']['author1']) {
+ $bk1 = trim($form_state['values']['book1']);
+ $auth1 = trim($form_state['values']['author1']);
+ //var_dump(_dir_name($bk1, $auth1))
+ $pref_id = NULL;
+ if (_dir_name($bk1, $auth1, $pref_id) != NULL) {
+ $form_state['values']['dir_name1'] = _dir_name($bk1, $auth1, $pref_id);
+ }
+ }
+ /*****************************************************************************
+ if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn2']))
+ form_set_error('isbn2', t('Invalid ISBN for Book Preference 2'));
+ 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']))
+ 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)
+ 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']))
+ if ($form_state['values']['book2'] && $form_state['values']['author2']) {
+ $bk2 = trim($form_state['values']['book2']);
+ $auth2 = trim($form_state['values']['author2']);
+ //var_dump(_dir_name($bk1, $auth1))
+ $pref_id = NULL;
+ if (_dir_name($bk2, $auth2, $pref_id) != NULL) {
+ $form_state['values']['dir_name2'] = _dir_name($bk2, $auth2, $pref_id);
+ }
+ /*****************************************************************************
+ }
+ if (!preg_match('/^[0-9\-xX]+$/', $form_state['values']['isbn3']))
form_set_error('isbn3', t('Invalid ISBN for Book Preference 3'));
-
- if($form_state['values']['version'] == 'olderversion'){
- if($form_state['values']['older'] == ''){
- form_set_error('older', t('Please provide valid version'));
- }
- }
- return;
+ if (!preg_match('/^[1-9][0-9]{0,1}$/', $form_state['values']['edition3']))
+ form_set_error('edition3', t('Invalid edition for Book Preference 3'));
+ 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'));
+ 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'));
+ if ($form_state['values']['book3'] && $form_state['values']['author3']) {
+ $bk3 = trim($form_state['values']['book3']);
+ $auth3 = trim($form_state['values']['author3']);
+ //var_dump(_dir_name($bk1, $auth1))
+ $pref_id = NULL;
+ if (_dir_name($bk1, $auth1, $pref_id) != NULL) {
+ $form_state['values']['dir_name3'] = _dir_name($bk3, $auth3, $pref_id);
+ }
+ /*****************************************************************************
+
+ }*/
+ if ($form_state['values']['version'] == 'olderversion') {
+ if ($form_state['values']['older'] == '') {
+ form_set_error('older', t('Please provide valid version'));
+ }
+ }
+ if (isset($_FILES['files'])) {
+ /* check if atleast one source or result file is uploaded */
+ if (!($_FILES['files']['name']['samplefile1']))
+ form_set_error('samplefile1', t('Please upload sample code main or source file.'));
+ /* check for valid filename extensions */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name) {
+ if ($file_name) {
+ /* checking file type */
+ if (strstr($file_form_name, 'sample'))
+ $file_type = 'S';
+ else
+ $file_type = 'U';
+ $allowed_extensions_str = '';
+ switch ($file_type) {
+ case 'S':
+ $allowed_extensions_str = variable_get('textbook_companion_source_extensions', '');
+ break;
+ }
+ $allowed_extensions = explode(',', $allowed_extensions_str);
+ $fnames = explode('.', strtolower($_FILES['files']['name'][$file_form_name]));
+ $temp_extension = end($fnames);
+ if (!in_array($temp_extension, $allowed_extensions))
+ form_set_error($file_form_name, t('Only file with ' . $allowed_extensions_str . ' extensions can be uploaded.'));
+ if ($_FILES['files']['size'][$file_form_name] <= 0)
+ form_set_error($file_form_name, t('File size cannot be zero.'));
+ /* check if valid file name */
+ if (!textbook_companion_check_valid_filename($_FILES['files']['name'][$file_form_name]))
+ form_set_error($file_form_name, t('Invalid file name specified. Only alphabets and numbers are allowed as a valid filename.'));
+ }
+ }
+ }
+ if ($form_state['values']['version'] == 'olderversion') {
+ if ($form_state['values']['older'] == '') {
+ form_set_error('older', t('Please provide valid version'));
+ }
+ }
+ return;
}
-
-function book_proposal_form_submit($form, &$form_state)
+function book_proposal_form_submit($form, &$form_state, $directory_name = NULL)
{
- global $user;
- $selections = variable_get("aicte_".$user->uid, "");
-
- 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);
-
-
- $dwsim_version = $form_state['values']['version'];
-
- if($form_state['values']['version'] == 'olderversion'){
- $dwsim_version = $form_state['values']['older'];
- }
-
- //var_dump($form_state['values']);
-
- $query = "INSERT INTO {textbook_companion_proposal}
- (uid, approver_uid, full_name, mobile, gender, how_project, course, branch, university, faculty, reviewer, completion_date, creation_date, approval_date, proposal_status, dwsim_version, operating_system, teacher_email) VALUES (".$user->uid.", 0, '".ucwords(strtolower($form_state['values']['full_name']))."', '".$form_state['values']['mobile']."', '".$form_state['values']['gender']."', '".$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, '".$dwsim_version."', '".$form_state['values']['operating_system']."', '".$form_state['values']['faculty_email']."')";
-
- $result = db_query($query);
- 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');
- } else {
- $preference_id = db_last_insert_id("textbook_companion_preference", "id");
- $query = "
- UPDATE textbook_companion_aicte
- SET preference_id = {$preference_id}
- WHERE id = {$selections[0]}
- ";
- db_query($query);
+ global $user;
+ $root_path = textbook_companion_samplecode_path();
+ $selections = variable_get("aicte_" . $user->uid, "");
+ if (!$user->uid) {
+ drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
+ return;
}
- }
-
- /* 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');
- } else {
- $preference_id = db_last_insert_id("textbook_companion_preference", "id");
- $query = "
- UPDATE textbook_companion_aicte
- SET preference_id = {$preference_id}
- WHERE id = {$selections[1]}
- ";
- db_query($query);
+ /* completion date to timestamp */
+ list($d, $m, $y) = explode('-', $form_state['values']['completion_date']);
+ $completion_date_timestamp = mktime(0, 0, 0, $m, $d, $y);
+ $dwsim_version = $form_state['values']['version'];
+ if ($form_state['values']['version'] == 'olderversion') {
+ $form_state['values']['version'] = $form_state['values']['older'];
}
- }
-
- /* 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');
- } else {
- $preference_id = db_last_insert_id("textbook_companion_preference", "id");
- $query = "
- UPDATE textbook_companion_aicte
- SET preference_id = {$preference_id}
- WHERE id = {$selections[2]}
- ";
- db_query($query);
+ if ($form_state['values']['country'] == 'other') {
+ $form_state['values']['country'] = trim($form_state['values']['other_country']);
+ $form_state['values']['all_state'] = trim($form_state['values']['other_state']);
}
-
- /* locking the books in the textbook_companion_aicte table */
- foreach ($selections as $selection) {
- $query = "
- UPDATE textbook_companion_aicte
- SET status = 1, uid = {$user->uid}, proposal_id = {$proposal_id}
- WHERE id = {$selection} AND status = 0
- ";
- db_query($query);
+ if (isset($_POST['reason'])) {
+ if (!($form_state['values']['other_reason'])) {
+ $my_reason = implode(", ", $_POST['reason']);
+ } else {
+ $my_reason = implode(", ", $_POST['reason']);
+ $my_reason = $my_reason . "-" . " " . $form_state['values']['other_reason'];
+ }
+ $form_state['values']['reason'] = $my_reason;
+ }
+ //var_dump($form_state['values']);
+ /*$query = "INSERT INTO {textbook_companion_proposal}
+ (uid, approver_uid, full_name, mobile, gender, 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']['gender']."', '".$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);*/
+ $query = "INSERT INTO {textbook_companion_proposal}
+ (uid, approver_uid, full_name, mobile, gender, how_project, course, branch, university,city,pincode,state,country, faculty, reviewer,reference, completion_date, creation_date, approval_date, proposal_status, dwsim_version, operating_system, teacher_email,reason,samplefilepath,proposal_type) VALUES (:uid, :approver_uid, :full_name, :mobile, :gender, :how_project, :course, :branch, :university, :city,:pincode,:state,:country, :faculty, :reviewer,:reference, :completion_date,
+ :creation_date, :approval_date, :proposal_status, :dwsim_version, :operating_system,
+:teacher_email,:reason,:samplefilepath,:proposal_type)";
+ $args = array(
+ ":uid" => $user->uid,
+ ":approver_uid" => 0,
+ ":full_name" => trim(ucwords(strtolower($form_state['values']['full_name']))),
+ ":mobile" => trim($form_state['values']['mobile']),
+ ":gender" => $form_state['values']['gender'],
+ ":how_project" => $form_state['values']['how_project'],
+ ":course" => trim($form_state['values']['course']),
+ ":branch" => $form_state['values']['branch'],
+ ":university" => trim($form_state['values']['university']),
+ ":city" => trim($form_state['values']['city']),
+ ":pincode" => $form_state['values']['pincode'],
+ ":state" => trim($form_state['values']['all_state']),
+ ":country" => $form_state['values']['country'],
+ ":faculty" => ucwords(strtolower($form_state['values']['faculty'])),
+ ":reviewer" => ucwords(strtolower($form_state['values']['reviewer'])),
+ ":reference" => trim($form_state['values']['reference']),
+ ":completion_date" => $completion_date_timestamp,
+ ":creation_date" => time(),
+ ":approval_date" => 0,
+ ":proposal_status" => 0,
+ ":dwsim_version" => trim($form_state['values']['version']),
+ ":operating_system" => trim($form_state['values']['operating_system']),
+ ":teacher_email" => $form_state['values']['faculty_email'],
+ ":reason" => $form_state['values']['reason'],
+ ":samplefilepath" => "",
+ ":proposal_type" => 0
+ );
+ $result = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ $dest_path = $result . '/';
+ if (!is_dir($root_path . $dest_path))
+ mkdir($root_path . $dest_path);
+ /* uploading files */
+ foreach ($_FILES['files']['name'] as $file_form_name => $file_name) {
+ if ($file_name) {
+ /* checking file type */
+ $file_type = 'S';
+ if (file_exists($root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) {
+ // drupal_set_message(t("Error uploading file. File !filename already exists.", array('!filename' => $_FILES['files']['name'][$file_form_name])), 'error');
+ unlink($root_path . $dest_path . $_FILES['files']['name'][$file_form_name]);
+ }
+ /* uploading file */
+ if (move_uploaded_file($_FILES['files']['tmp_name'][$file_form_name], $root_path . $dest_path . $_FILES['files']['name'][$file_form_name])) {
+ $query = "UPDATE {textbook_companion_proposal} SET samplefilepath = :samplefilepath WHERE id = :id";
+ $args = array(
+ ":samplefilepath" => $dest_path . $_FILES['files']['name'][$file_form_name],
+ ":id" => $result
+ );
+ $updateresult = db_query($query, $args);
+ drupal_set_message($file_name . ' uploaded successfully.', 'status');
+ } else {
+ drupal_set_message('Error uploading file : ' . $dest_path . '/' . $file_name, 'error');
+ }
+ }
}
- if (!$result)
- {
- drupal_set_message(t('Error receiving your third book preference.'), 'error');
+ if (!$result) {
+ drupal_set_message(t('Error receiving your proposal. Please try again.'), 'error');
+ return;
}
- }
-
- /* sending email */
- $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))
- 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('');
+ /* proposal id */
+ $proposal_id = $result;
+ /* 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
+ );*/
+ $bk1 = trim($form_state['values']['book1']);
+ $auth1 = trim($form_state['values']['author1']);
+ $pref_id = NULL;
+ $directory_name = _dir_name($bk1, $auth1, $pref_id);
+ $query = "INSERT INTO {textbook_companion_preference}
+ (proposal_id, pref_number, book, author, isbn, publisher, edition, year, category, approval_status, directory_name) VALUES (:proposal_id, :pref_number, :book, :author, :isbn, :publisher, :edition, :year, :category, :approval_status, :directory_name)
+ ";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":pref_number" => 1,
+ ":book" => trim(ucwords(strtolower($form_state['values']['book1']))),
+ ":author" => trim(ucwords(strtolower($form_state['values']['author1']))),
+ ":isbn" => trim($form_state['values']['isbn1']),
+ ":publisher" => trim(ucwords(strtolower($form_state['values']['publisher1']))),
+ ":edition" => trim($form_state['values']['edition1']),
+ ":year" => trim($form_state['values']['year1']),
+ ":category" => 0,
+ ":approval_status" => 0,
+ ":directory_name" => $form_state['values']['dir_name1']
+ );
+ $result = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ if (!$result) {
+ drupal_set_message(t('Error receiving your first book preference.'), 'error');
+ }
+ }
+ /*******************************************************/
+ /* 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,
+ 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
+ );*/
+ /**$bk2 = trim($form_state['values']['book2']);
+ $auth2 = trim($form_state['values']['author2']);
+ $pref_id = NULL;
+ $directory_name = _dir_name($bk2, $auth2, $pref_id);
+ $query = "INSERT INTO {textbook_companion_preference}
+ (proposal_id, pref_number, book, author, isbn, publisher, edition, year, category, approval_status, directory_name) VALUES (:proposal_id, :pref_number, :book, :author, :isbn, :publisher, :edition, :year, :category, :approval_status, :directory_name)
+ ";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+
+
+ ":pref_number" => 2,
+ ":book" => trim(ucwords(strtolower($form_state['values']['book2']))),
+ ":author" => trim(ucwords(strtolower($form_state['values']['author2']))),
+ ":isbn" => trim($form_state['values']['isbn2']),
+ ":publisher" => trim(ucwords(strtolower($form_state['values']['publisher2']))),
+ ":edition" => trim($form_state['values']['edition2']),
+ ":year" => trim($form_state['values']['year2']),
+ ":category" => 0,
+ ":approval_status" => 0,
+ ":directory_name" => $form_state['values']['dir_name2']
+ );
+ $result = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ if (!$result) {
+ drupal_set_message(t('Error receiving your second book preference.'), 'error');
+ }
+ }**/
+ /*******************************************************/
+ /**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,
+ 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
+ );*/
+ /** $bk3 = trim($form_state['values']['book3']);
+ $auth3 = trim($form_state['values']['author3']);
+ $pref_id = NULL;
+ $directory_name = _dir_name($bk3, $auth3, $pref_id);
+ $query = "INSERT INTO {textbook_companion_preference}
+ (proposal_id, pref_number, book, author, isbn, publisher, edition, year, category, approval_status, directory_name) VALUES (:proposal_id, :pref_number, :book, :author, :isbn, :publisher, :edition, :year, :category, :approval_status, :directory_name)
+ ";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":pref_number" => 3,
+ ":book" => trim(ucwords(strtolower($form_state['values']['book3']))),
+ ":author" => trim(ucwords(strtolower($form_state['values']['author3']))),
+ ":isbn" => trim($form_state['values']['isbn3']),
+ ":publisher" => trim(ucwords(strtolower($form_state['values']['publisher3']))),
+ ":edition" => trim($form_state['values']['edition3']),
+ ":year" => trim($form_state['values']['year3']),
+ ":category" => 0,
+ ":approval_status" => 0,
+ ":directory_name" => $form_state['values']['dir_name3']
+ );
+ $result = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ if (!$result) {
+ drupal_set_message(t('Error receiving your third book preference.'), 'error');
+ }
+
+ }**/
+ /*******************************************************/
+ /* sending email */
+ $email_to = $user->mail;
+ $from = variable_get('textbook_companion_from_email', '');
+ $bcc = variable_get('textbook_companion_emails', '');
+ $cc = variable_get('textbook_companion_cc_emails', '');
+ $param['proposal_received']['proposal_id'] = $proposal_id;
+ $param['proposal_received']['user_id'] = $user->uid;
+ $param['proposal_received']['headers'] = array(
+ 'From' => $from,
+ 'MIME-Version' => '1.0',
+ 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
+ 'Content-Transfer-Encoding' => '8Bit',
+ 'X-Mailer' => 'Drupal',
+ 'Cc' => $cc,
+ 'Bcc' => $bcc
+ );
+ if (!drupal_mail('textbook_companion', 'proposal_received', $email_to, language_default(), $param, $from, 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['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);
- $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('
+ global $user;
+ // $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);*/
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal');
+ $query->condition('id', $params['proposal_received']['proposal_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $proposal_data = $result->fetchObject();
+ $samplecodefilename = "";
+ if (strlen($proposal_data->samplefilepath) >= 5) {
+ $samplecodefilename = substr($proposal_data->samplefilepath, strrpos($proposal_data->samplefilepath, '/') + 1);
+ } else {
+ $samplecodefilename = "Not provided";
+ }
+ /*$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);*/
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('proposal_id', $params['proposal_received']['proposal_id']);
+ $query->condition('pref_number', 1);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $preference1_data = $result->fetchObject();
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('proposal_id', $params['proposal_received']['proposal_id']);
+ $query->condition('pref_number', 2);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $preference2_data = $result->fetchObject();
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('proposal_id', $params['proposal_received']['proposal_id']);
+ $query->condition('pref_number', 3);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $preference3_data = $result->fetchObject();
+ $user_data = user_load($params['proposal_received']['user_id']);
+ $message['subject'] = t('[!site_name] Your textbook companion book proposal has been received', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
-We have received your following book proposal:
+We have received your proposal for DWSIM Textbook Companion with the following details:
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) . '
+University/Institute : ' . $proposal_data->university . '
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
+Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
+
Your Book Preferences :
-Book Preference 1 :-
+Book Preference :-
Title of the book : ' . $preference1_data->book . '
Author name : ' . $preference1_data->author . '
ISBN No. : ' . $preference1_data->isbn . '
@@ -1436,64 +2656,68 @@ 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.
-Note:
-Send sample codes to contact_dwsim@fossee.in in a .zip or .tgz file. The sample codes should be sent utmost by the 3rd day of the proposal. The subject of the email containing sample code should be "New Book Proposal-Sample Codes-(Student Name)"​.
-The book will not be alloted to you until we receive the sample codes.
+
+
+
+Your proposal is under review. You will soon receive an email when your proposal has been approved/ disapproved. Thank you for your submission.
Best Wishes,
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- 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);
- $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);
- if($proposal_data->proposal_type != 1){
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ break;
+ 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);*/
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal');
+ $query->condition('id', $params['proposal_disapproved']['proposal_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $proposal_data = $result->fetchObject();
+ /*$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);*/
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('proposal_id', $params['proposal_disapproved']['proposal_id']);
+ $query->condition('pref_number', 1);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $preference1_data = $result->fetchObject();
+ $user_data = user_load($params['proposal_disapproved']['user_id']);
+ $message['subject'] = t('[!site_name] Your textbook companion book proposal has been disapproved', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
-Your following book proposal has been disapproved:
-
-Reason for disapproval: ' . $proposal_data->message . '
+We regret to inform you that all the uploaded examples including the book
+with following details have been deleted permanently.
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) . '
+University/Institute : ' . $proposal_data->university . '
+City : ' . $proposal_data->city . '
+State : ' . $proposal_data->state . '
+
+Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
+
+Reason : ' . $proposal_data->reason . '
+
+
+Reference : ' . $proposal_data->reference . '
Your Book Preferences :
@@ -1505,180 +2729,189 @@ 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 . '
+Reason for disapproval: ' . $proposal_data->message . '
+
+You are welcome to submit a new proposal.
Best Wishes,
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
-}
-else{
-//Non AICTE book proposal dissaprove//
-$message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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);*/
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal');
+ $query->condition('id', $params['proposal_approved']['proposal_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $proposal_data = $result->fetchObject();
+ /* $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);*/
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('proposal_id', $params['proposal_approved']['proposal_id']);
+ $query->condition('approval_status', 1);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $approved_preference_data = $result->fetchObject();
+ $user_data = user_load($params['proposal_approved']['user_id']);
+ $message['headers'] = $params['proposal_approved']['headers'];
+ $message['subject'] = t('[!site_name] Your book proposal has been approved', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
-Your following book proposal has been disapproved:
-
-Reason for disapproval: ' . $proposal_data->message . '
+Congratulations! Your proposal for DWSIM Textbook Companion with the following details is 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 . '
+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) . '
+Reviewer : ' . $proposal_data->reviewer . '
+Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
-Your Book Preferences :
+Reason : ' . $proposal_data->reason . '
-Book Preference :-
-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 . '
+Reference : ' . $proposal_data->reference . '
+
+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 . '
+Please ensure that ALL the guidelines for coding are strictly followed:
+
+http://dwsim.fossee.in/textbook-companion/guidelines-coding
Best Wishes,
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
-}
- break;
-
- /* Non AICTE Book Proposal */
- case 'nonaicte_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);
- $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);
-
- $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('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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);*/
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal');
+ $query->condition('id', $params['proposal_completed']['proposal_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $proposal_data = $result->fetchObject();
+ /*$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);*/
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('proposal_id', $params['proposal_completed']['proposal_id']);
+ $query->condition('approval_status', 1);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $approved_preference_data = $result->fetchObject();
+ $user_data = user_load($params['proposal_completed']['user_id']);
+ $message['subject'] = t('[!site_name] Congratulations on the completion of the Textbook Companion.', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
-We have received your following book proposal:
+The textbook companion on the following book has been completed successfully 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 . '
+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 Non AICTE Book Preferences :
-
-Book Preference :-
-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 . '
-
-
-Your proposal is under review and you will soon receive an email from us regarding the same.
-Note:
-Send sample codes to contact_dwsim@fossee.in in a .zip or .tgz file. The sample codes should be sent utmost by the 3rd day of the proposal. The subject of the email containing sample code should be "New Book Proposal-Sample Codes-(Student Name)"​.
-The book will not be alloted to you until we receive the sample codes.
-
-Best Wishes,
-
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- break;
-case 'nonaicte_proposal_to_pi':
- // 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);
- $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);
-
- $user_data = user_load($params['proposal_received']['user_id']);
-
- $message['subject'] = t('[!site_name] New Non AICTE book suggestion has been received', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
-Dear all,
-
-We have received following Non AICTE book suggestion:
-
-Full Name : ' . $proposal_data->full_name . '
-University/Institute :' . $proposal_data->university . '
-
-
-Reason(s): '. $proposal_data->reason . '
-
+Reviewer : ' . $proposal_data->reviewer . '
+Expected date of completion : ' . date('d-m-Y', $proposal_data->completion_date) . '
-Your Non AICTE Book Preference :
-
-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 . '
-Reference :- '.$proposal_data->reference.'
+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://dwsim.fossee.in/textbook-companion/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 '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']);
- $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('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ break;
+ /***********************************************************************************************/
+ case 'all_code_submitted':
+ // 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);*/
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal');
+ $query->condition('id', $params['all_code_submitted']['proposal_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $proposal_data = $result->fetchObject();
+ /*$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);*/
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('proposal_id', $params['all_code_submitted']['proposal_id']);
+ $query->condition('approval_status', 1);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $approved_preference_data = $result->fetchObject();
+ $user_data = user_load($params['all_code_submitted']['user_id']);
+ $message['subject'] = t('[!site_name][Textbook Companion] You have marked to submited code for all examples.', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
-Your following book proposal has been approved:
+You have submitted codes for all examples:
Full Name : ' . $proposal_data->full_name . '
Email : ' . $user_data->mail . '
-Mobile : ' . $proposal_data->mobile . '
+Mobile : ' . $proposal_data->mobile . '
Course : ' . $proposal_data->course . '
Department/Branch : ' . $proposal_data->branch . '
-University/Institute : ' . $proposal_data->university . '
+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) . '
+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 . '
@@ -1687,42 +2920,57 @@ Publisher and Place : ' . $approved_preference_data->publisher . '
Edition : ' . $approved_preference_data->edition . '
Year of publication : ' . $approved_preference_data->year . '
-According the new Textbook Companion procedure, a student doing a textbook companion is not required to have a mentor. For more details check the links given below.
-http://dwsim.fossee.in/tbc_honorarium
-http://dwsim.fossee.in/Textbook_Companion_Internship
-
-Please contact us by sending an e-mail to contact_dwsim@fossee.in in case you wish to cancel this book proposal.
+You shall be notified after the code is reviewed.
Best Wishes,
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- 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']);
- $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('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ break;
+ case 'all_code_submitted_status_changed':
+ // 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);*/
+ $query = db_select('textbook_companion_proposal');
+ $query->fields('textbook_companion_proposal');
+ $query->condition('id', $params['all_code_submitted_status_changed']['proposal_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $proposal_data = $result->fetchObject();
+ /*$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);*/
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('proposal_id', $params['all_code_submitted_status_changed']['proposal_id']);
+ $query->condition('approval_status', 1);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $approved_preference_data = $result->fetchObject();
+ $user_data = user_load($params['all_code_submitted_status_changed']['user_id']);
+ $message['subject'] = t('[!site_name][Textbook Companion] Your interface for code submission has been enabled by the reviewer', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
-Following book has been completed sucessfully by you:
+Your interface for code submission has been enabled by the reviewer, you can now able to send more code for this book.
Full Name : ' . $proposal_data->full_name . '
Email : ' . $user_data->mail . '
-Mobile : ' . $proposal_data->mobile . '
+Mobile : ' . $proposal_data->mobile . '
Course : ' . $proposal_data->course . '
Department/Branch : ' . $proposal_data->branch . '
-University/Institute : ' . $proposal_data->university . '
+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) . '
+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 . '
@@ -1730,118 +2978,238 @@ 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 . '
-
-
-
-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':
- // 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']);
-
- $message['subject'] = t('[!site_name] You have uploaded example', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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);*/
+ $query = db_select('textbook_companion_example');
+ $query->fields('textbook_companion_example');
+ $query->condition('id', $params['example_uploaded']['example_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $example_data = $result->fetchObject();
+ $query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('id', $example_data->chapter_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $chapter_data = $result->fetchObject();
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('id', $chapter_data->preference_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $preference_data = $result->fetchObject();
+ $user_data = user_load($params['example_uploaded']['user_id']);
+ $message['subject'] = t('[!site_name] You have uploaded example for Textbook Companion', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
-You have uploaded the following example:
+You have uploaded the following solution :
+Title of the book : ' . $preference_data->book . '
+Title of the chapter : ' . $chapter_data->name . '
Example number : ' . $example_data->number . '
-Caption : ' . $example_data->caption . '
-
-The example is under review. You will be notified when it has been approved.
+Caption : ' . $example_data->caption . '
-Please ensure that ALL the codes have followed the naming convention and contain captions as described here.
-The codes cannot be approved unless the convention is followed.
+You shall be notified after the solution is reviewed
Best Wishes,
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- 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']);
-
- $message['subject'] = t('[!site_name] You have updated example', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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);*/
+ $query = db_select('textbook_companion_example');
+ $query->fields('textbook_companion_example');
+ $query->condition('id', $params['example_updated']['example_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $example_data = $result->fetchObject();
+ $query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('id', $example_data->chapter_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $chapter_data = $result->fetchObject();
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('id', $chapter_data->preference_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $preference_data = $result->fetchObject();
+ $user_data = user_load($params['example_updated']['user_id']);
+ $message['subject'] = t('[!site_name] You have updated example for Textbook Companion', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
You have updated the following example:
+Title of the book : ' . $preference_data->book . '
+Title of the chapter : ' . $chapter_data->name . '
Example number : ' . $example_data->number . '
-Caption : ' . $example_data->caption . '
+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':
- // 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']);
-
- $message['subject'] = t('[!site_name] Reviewer have updated example', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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);*/
+ $query = db_select('textbook_companion_example');
+ $query->fields('textbook_companion_example');
+ $query->condition('id', $params['example_updated_admin']['example_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $example_data = $result->fetchObject();
+ $query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('id', $example_data->chapter_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $chapter_data = $result->fetchObject();
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('id', $chapter_data->preference_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $preference_data = $result->fetchObject();
+ $user_data = user_load($params['example_updated_admin']['user_id']);
+ $message['subject'] = t('[!site_name] Reviewer have updated example for Textbook Companion ', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Reviewer have updated the following example:
+Title of the book : ' . $preference_data->book . '
+Title of the chapter : ' . $chapter_data->name . '
Example number : ' . $example_data->number . '
-Caption : ' . $example_data->caption . '
+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':
- // 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']);
-
- $message['subject'] = t('[!site_name] Your uploaded example has been approved', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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);*/
+ $query = db_select('textbook_companion_example');
+ $query->fields('textbook_companion_example');
+ $query->condition('id', $params['example_approved']['example_id']);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $example_data = $result->fetchObject();
+ $query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('id', $example_data->chapter_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $chapter_data = $result->fetchObject();
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('id', $chapter_data->preference_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $preference_data = $result->fetchObject();
+ $user_data = user_load($params['example_approved']['user_id']);
+ $message['subject'] = t('[!site_name] Your uploaded example has been approved for Textbook Companion', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
-Your following example has been approved:
+Your example for DWSIM Textbook Companion with the following details is approved.
+Title of the book : ' . $preference_data->book . '
+Title of the chapter : ' . $chapter_data->name . '
Example number : ' . $example_data->number . '
-Caption : ' . $example_data->caption . '
+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':
- // 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);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ break;
+ case 'example_disapproved':
+ // bcc to textbook_companion_emails
+ //$message['headers'] += $tbc_bcc_emails;
+ $user_data = user_load($params['example_disapproved']['user_id']);
+ $preference_id = $param['example_disapproved']['preference_id'];
+ $chapter_id = $param['example_disapproved']['chapter_id'];
+ $query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('id', $chapter_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $chapter_data = $result->fetchObject();
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('id', $preference_id);
+ $query->range(0, 1);
+ $result = $query->execute();
+ $preference_data = $result->fetchObject();
+ $message['subject'] = t('[!site_name] Your uploaded example has been disapproved for Textbook Companion', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Your following example has been disapproved:
+Title of the book : ' . $preference_data->book . '
+Title of the chapter : ' . $chapter_data->name . '
Example number : ' . $params['example_disapproved']['example_number'] . '
Caption : ' . $params['example_disapproved']['example_caption'] . '
@@ -1849,16 +3217,22 @@ 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':
- // 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);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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 for Textbook Companion', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
Your following pending example has been deleted :
@@ -1870,17 +3244,23 @@ 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':
- // 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']);
-
- $message['subject'] = t('[!site_name] You have uploaded dependency file', array('!site_name' => variable_get('site_name', '')), $language->language);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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']);
+ $message['subject'] = t('[!site_name] You have uploaded dependency file', array(
+ '!site_name' => variable_get('site_name', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
You have uploaded following dependency files :
@@ -1888,16 +3268,22 @@ You have uploaded following dependency files :
Best Wishes,
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- 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);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
We have received your following feedback
@@ -1911,17 +3297,22 @@ Your feedback :
Best Wishes,
-!site_name', array('!site_name' => variable_get('site_name', ''), '!user_name' => $user_data->name), $language->language);
- 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);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
We have received your Internship Form Application for the book
@@ -1932,17 +3323,22 @@ 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':
- // 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);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
We have received your Copyright Form Application for the book
@@ -1953,17 +3349,22 @@ 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':
- // 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);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
We have received your Undertaking Form Application for the book
@@ -1974,18 +3375,22 @@ 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':
- // 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);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ break;
+ 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', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
A Remark has been given.Please check your Contact Detail Form
@@ -1996,17 +3401,22 @@ 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':
- // 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);
- $message['body'] = t('
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ 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', '')
+ ));
+ $message['body'] = array(
+ 'body' => t('
Dear !user_name,
We have Sent Cheque for the following book proposed
@@ -2017,690 +3427,944 @@ 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':
- // bcc to textbook_companion_emails
- $message['headers'] += $tbc_bcc_emails;
- $message['subject'] = $params['standard']['subject'];
- $message['body'] = $params['standard']['body'];
- break;
- }
+!site_name Team,
+FOSSEE,IIT Bombay', array(
+ '!site_name' => variable_get('site_name', ''),
+ '!user_name' => $user_data->name
+ ))
+ );
+ break;
+ case 'standard':
+ // bcc to textbook_companion_emails
+ //$message['headers'] += $tbc_bcc_emails;
+ $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;
+ $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);*/
+ $query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('number', $chapter_number);
+ $query->condition('preference_id', $preference_id);
+ $query->range(0, 1);
+ $chapter_q = $query->execute();
+ if ($chapter_data = $chapter_q->fetchObject()) {
+ 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);*/
+ $query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('number', $chapter_number);
+ $query->condition('preference_id', $preference_id);
+ $query->range(0, 1);
+ $chapter_q = $query->execute();
+ if (!$chapter_data = $chapter_q->fetchObject()) {
+ 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);*/
+ $query = db_select('textbook_companion_example');
+ $query->fields('textbook_companion_example');
+ $query->condition('chapter_id', $chapter_id);
+ $query->condition('number', $example_number);
+ $query->range(0, 1);
+ $example_q = $query->execute();
+ if ($example_data = $example_q->fetchObject()) {
+ 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 '';
+ 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;
+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;
+ return TRUE;
}
-
-function check_name($name = '') {
- if (!preg_match('/^[0-9a-zA-Z\ ]+$/', $name))
- 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 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/';
+function textbook_companion_path()
+{
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/tbc_uploads/';
+}
+function textbook_companion_temp_path()
+{
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/';
+}
+function textbook_companion_samplecode_path()
+{
+ return $_SERVER['DOCUMENT_ROOT'] . base_path() . 'dwsim_uploads/tbc_sample_code/';
}
-
/****************************** 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;
+ 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);*/
+ $query = db_select('textbook_companion_example');
+ $query->fields('textbook_companion_example');
+ $query->condition('id', $example_id);
+ $example_q = $query->execute();
+ $example_data = $example_q->fetchObject();
+ if (!$example_data) {
+ drupal_set_message(t('Invalid example.'), 'error');
+ return FALSE;
}
-
- /* 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'] . " :
+ /*$chapter_q = db_query("SELECT * FROM {textbook_companion_chapter} WHERE id = %d", $example_data->chapter_id);
+ $chapter_data = db_fetch_object($chapter_q);*/
+ $chapter_q = db_query("SELECT tcp.id as pref_id, tcp.directory_name, tcc.*
+FROM textbook_companion_preference tcp
+JOIN textbook_companion_chapter tcc
+ON tcp.id= tcc.preference_id
+WHERE tcc.id = :chapter_id", array(
+ ":chapter_id" => $example_data->chapter_id
+ ));
+ /*$query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('id', $example_data->chapter_id);
+ $chapter_q = $query->execute();*/
+ $chapter_data = $chapter_q->fetchObject();
+ 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);*/
+ $query = db_select('textbook_companion_example_files');
+ $query->fields('textbook_companion_example_files');
+ $query->condition('example_id', $example_id);
+ $examples_files_q = $query->execute();
+ while ($examples_files_data = $examples_files_q->fetchObject()) {
+ if (!file_exists($root_path . $chapter_data->directory_name . '/' . $examples_files_data->filepath)) {
+ $status = FALSE;
+ var_dump($root_path . $chapter_data->directory_name . '/' . $examples_files_data->filepath);
+ die;
+ 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 . $chapter_data->directory_name . '/' . $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 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 (!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);*/
+ $query = db_delete('textbook_companion_example_files');
+ $query->condition('id', $examples_files_data->id);
+ $num_deleted = $query->execute();
+ }
}
- }
-
- 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;
+ if (!$status)
+ return FALSE;
+ /* removing example folder */
+ $ex_path = $chapter_data->directory_name . '/' . '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;
}
- } 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;
+ /* deleting example dependency and exmaple database entries */
+ /*db_query("DELETE FROM {textbook_companion_example_dependency} WHERE example_id = %d", $example_id);*/
+ //$query = db_delete('textbook_companion_example_dependency');
+ //$query->condition('example_id', $example_id);
+ //$num_deleted = $query->execute();
+ /*db_query("DELETE FROM {textbook_companion_example} WHERE id = %d", $example_id);*/
+ $query = db_delete('textbook_companion_example');
+ $query->condition('id', $example_id);
+ $num_deleted = $query->execute();
+ return $status;
}
-
-function delete_chapter($chapter_id)
+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');
+ $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);*/
+ /*$query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('id', $chapter_id);
+ $chapter_q = $query->execute();
+ $chapter_data = $chapter_q->fetchObject();*/
+ $chapter_q = db_query("SELECT tcp.id as pref_id, tcp.directory_name, tcc.*
+FROM textbook_companion_preference tcp
+JOIN textbook_companion_chapter tcc
+ON tcp.id= tcc.preference_id
+WHERE tcc.id = :chapter_id", array(
+ ":chapter_id" => $chapter_id
+ ));
+ $chapter_data = $chapter_q->fetchObject();
+ if (!$chapter_data) {
+ drupal_set_message('Invalid chapter.', '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;
+ /* deleting examples */
+ /*$example_q = db_query("SELECT * FROM {textbook_companion_example} WHERE chapter_id = %d", $chapter_id);*/
+ $query = db_select('textbook_companion_example');
+ $query->fields('textbook_companion_example');
+ $query->condition('chapter_id', $chapter_id);
+ $example_q = $query->execute();
+ while ($example_data = $example_q->fetchObject()) {
+ if (!delete_example($example_data->id))
+ $status = FALSE;
+ }
+ if ($status) {
+ $dir_path = $root_path . $chapter_data->directory_name . '/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);*/
+ $query = db_delete('textbook_companion_chapter');
+ $query->condition('id', $chapter_id);
+ $num_deleted = $query->execute();
+ 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;
+ $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);*/
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('id', $book_id);
+ $preference_q = $query->execute();
+ $preference_data = $preference_q->fetchObject();
+ 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);*/
+ $query = db_select('textbook_companion_chapter');
+ $query->fields('textbook_companion_chapter');
+ $query->condition('preference_id', $preference_data->id);
+ $chapter_q = $query->execute();
+ while ($chapter_data = $chapter_q->fetchObject()) {
+ if (!delete_chapter($chapter_data->id)) {
+ $status = FALSE;
+ }
}
- }
- return $status;
+ 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;
- }
+ $root_path = textbook_companion_path();
+ /*$file_q = db_query("SELECT * FROM {textbook_companion_example_files} WHERE id = %d LIMIT 1", $file_id);*/
+ $file_q = db_query("SELECT * FROM textbook_companion_preference tcp JOIN textbook_companion_chapter tcc ON tcp.id = tcc.preference_id JOIN textbook_companion_example tce ON tcc.id=tce.chapter_id JOIN textbook_companion_example_files tcef on tce.id = tcef.example_id WHERE tcef.id = :example_id", array(
+ ':example_id' => $file_id
+ ));
+ /*$query = db_select('textbook_companion_example_files');
+ $query->fields('textbook_companion_example_files');
+ $query->condition('id', $file_id);
+ $query->range(0, 1);
+ $file_q = $query->execute();*/
+ $file_data = $file_q->fetchObject();
+ if (!$file_data) {
+ drupal_set_message('Invalid file specified.', 'error');
+ return FALSE;
+ }
+ if (!file_exists($root_path . $file_data->directory_name . '/' . $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->directory_name . '/' . $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->directory_name . '/' . $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);*/
+ $query = db_delete('textbook_companion_example_files');
+ $query->condition('id', $file_id);
+ $num_deleted = $query->execute();
+ return TRUE;
+ }
}
-
//Non aicte book proposal form
-
function book_proposal_nonaicte_form($form_state)
{
-
- global $user;
-
- $form = array();
- $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 and also follow the additional guidelines.</b></font>',
- );
-// $form['guidelines'] = array(
-// '#type' => 'fieldset',
-// '#title' => t('Guidelines'),
-// '#attributes' => array('style'=>'font-weight: bold'),
-// '#collapsible' => TRUE,
-// '#collapsed' => FALSE,
-// );
-// $form['guidelines']['book'] = array(
-// '#type' => 'item',
-// '#required' => TRUE,
-// '#value' => '<ul style="list-style-type:disc;font-weight: normal">
-// <li>All the fields are compulsory</li>
-// <li>Proof (example: syllabus) to the usage/ popularity of the textbook must be provided in the references box below</li>
-// <li>Please make sure that the book proposed by you has <b>at least 80</b> examples which include numerical computations and which can be coded in Scilab</li>
-// <li>If the book has less than 80 examples the <a href="tbc_honorarium" target="_blank">honorarium</a> will be provided on a pro-rata basis </li>
-// <li>Make sure the book you propose is not already an <a href="aicte_proposal" target="_blank">AICTE recommended book</a>, <a href="Completed_Books" target="_blank">completed book</a>
-// or a <a href="Books_Progress" target="_blank">book in progress</a> </li>
-// <li>You will be intimated about the approval or rejection of your suggestion via e-mail</li>
-
-// </ul> ',
-
-// );
-
-
- $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['gender'] = array(
- '#type' => 'radios',
- '#title' => t('Gender'),
- '#options' => array('M' => 'Male', 'F' => 'Female'),
- '#required' => TRUE,
- );
-
- $form['how_project'] = array(
- '#type' => 'select',
- '#title' => t('How did you come to know about this project'),
- '#options' => array('DWSIM Website' => 'DWSIM 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' => 'hidden',
- '#value' => 'None',
- '#title' => t('College Teacher/Professor'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- );
- $form['faculty_email'] = array(
- '#type' => 'hidden',
- '#value' => 'None',
- '#title' => t('Teacher/Professor Email Id'),
- '#default_value' => '@email.com',
- '#size' => 30,
- '#maxlength' => 50,
- );
- $form['reviewer'] = array(
- '#type' => 'hidden',
- '#value' => 'None',
- '#title' => t('Reviewer'),
- '#size' => 30,
- '#maxlength' => 50,
- );
-
- $form['version'] = array(
- '#type' => 'textfield',
- '#title' => t('Version'),
- '#size' => 30,
- '#value' => 'Dwsim 3.3',
- '#disabled' => TRUE,
- );
- // $form['version'] = array(
- // '#type' => 'select',
- // '#title' => t('Version'),
- // '#options' => array('dwsim 3.3' => 'Dwsim 3.3',
- // 'dwsim 3.2' => 'Dwsim 3.2',
- // 'olderversion' => 'Older Version'),
- // '#required' => TRUE,
- // );
- $form['older'] = array(
- '#type' => 'textfield',
- '#size' => 30,
- '#maxlength' => 50,
- //'#required' => TRUE,
- '#description' => t('Specify the Older version used'),
- );
- $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,
- '#required' => TRUE,
- );
- $form['operating_system'] = array(
- '#type' => 'textfield',
- '#title' => t('Operating System'),
- '#required' => TRUE,
- '#size' => 30,
- '#maxlength' => 50,
- );
-
- $reason=array(
- 'Used in more than one University' =>t('Used in more than one University'),
- 'The book has multiple editions' => t('The book has multiple editions'),
- 'Extremely useful' => t('Extremely useful'),
- 'Other reason' => t('Any other reason state below')
- );
- $form['reason'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Reasons'),
- '#options' => $reason,
- '#required' => TRUE,
- );
+ global $user;
+ $form = array();
+ $form['imp_notice'] = array(
+ '#type' => 'item',
+ '#markup' => '<font color="red"><b>Please fill up this form carefully as the details entered here will be exactly written in the Textbook Companion and also follow the additional guidelines.</b></font>'
+ );
+ $form['guidelines'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Guidelines'),
+ '#attributes' => array(
+ 'style' => 'font-weight: bold'
+ ),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE
+ );
+ $form['guidelines']['book'] = array(
+ '#type' => 'item',
+ '#required' => TRUE,
+ '#markup' => '<ul style="list-style-type:disc;font-weight: normal">
+ <li>All the fields are compulsory</li>
+ <li>Proof (example: syllabus) to the usage/ popularity of the textbook must be provided in the references box below</li>
+ <li>Please make sure that the book proposed by you has <b>at least 80</b> examples which include numerical computations and which can be coded in DWSIM</li>
+ <li>If the book has less than 80 examples the <a href="tbc_honorarium" target="_blank">honorarium</a> will be provided on a pro-rata basis </li>
+ <li>Make sure the book you propose is not already an <a href="aicte_proposal" target="_blank">AICTE recommended book</a>, <a href="Completed_Books" target="_blank">completed book</a>
+ or a <a href="Books_Progress" target="_blank">book in progress</a> </li>
+ <li>You will be intimated about the approval or rejection of your suggestion via e-mail</li>
+
+</ul> '
+ );
+ $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['gender'] = array(
+ '#type' => 'radios',
+ '#title' => t('Gender'),
+ '#options' => array(
+ 'M' => 'Male',
+ 'F' => 'Female'
+ ),
+ '#required' => TRUE
+ );
+ $form['how_project'] = array(
+ '#type' => 'select',
+ '#title' => t('How did you come to know about this project'),
+ '#options' => array(
+ 'DWSIM Website' => 'DWSIM 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['department'] = array(
+ '#type' => 'select',
+ '#title' => t('Department/Branch'),
+ '#options' => _list_of_departments(),
+ '#required' => TRUE
+ );
+ $form['university'] = array(
+ '#type' => 'textfield',
+ '#title' => t('University/ Institute'),
+ '#size' => 80,
+ '#maxlength' => 200,
+ '#required' => TRUE,
+ '#attributes' => array(
+ 'placeholder' => 'Insert full name of your institute/ university.... '
+ )
+ );
+ $form['country'] = array(
+ '#type' => 'select',
+ '#title' => t('Country'),
+ '#options' => array(
+ 'India' => 'India',
+ 'Others' => 'Others'
+ ),
+ '#required' => TRUE
+ //'#tree' => TRUE,
+ // '#validated' => TRUE,
+ );
+ $form['other_country'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your country name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_state'] = array(
+ '#type' => 'textfield',
+ '#title' => t('State other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your state/region name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['other_city'] = array(
+ '#type' => 'textfield',
+ '#title' => t('City other than India'),
+ '#size' => 100,
+ '#attributes' => array(
+ 'placeholder' => t('Enter your city name')
+ ),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'Others'
+ )
+ )
+ )
+ );
+ $form['all_state'] = array(
+ '#type' => 'select',
+ '#title' => t('State'),
+ '#options' => _list_of_states(),
+ '#validated' => TRUE,
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['city'] = array(
+ '#type' => 'select',
+ '#title' => t('City'),
+ '#options' => _list_of_cities(),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="country"]' => array(
+ 'value' => 'India'
+ )
+ )
+ )
+ );
+ $form['pincode'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Pincode'),
+ '#size' => 30,
+ '#maxlength' => 6,
+ '#required' => False,
+ '#attributes' => array(
+ 'placeholder' => 'Enter pincode....'
+ )
+ );
+ /***************************************************************************/
+ $form['hr'] = array(
+ '#type' => 'item',
+ '#markup' => '<hr>'
+ );
+ $form['faculty'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None',
+ '#title' => t('College Teacher/Professor'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE
+ );
+ $form['faculty_email'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None',
+ '#title' => t('Teacher/Professor Email Id'),
+ '#value' => '@email.com',
+ '#size' => 30,
+ '#maxlength' => 50
+ );
+ $form['reviewer'] = array(
+ '#type' => 'hidden',
+ '#value' => 'None',
+ '#title' => t('Reviewer'),
+ '#size' => 30,
+ '#maxlength' => 50
+ );
+ $form['version'] = array(
+ '#type' => 'hidden',
+ '#default_value' => 'Not available'
+ );
+ $form['version'] = array(
+ '#type' => 'select',
+ '#title' => t('Version'),
+ '#options' => _list_of_software_version(),
+ '#required' => TRUE
+ );
+ $form['older'] = array(
+ '#type' => 'textfield',
+ '#size' => 30,
+ '#maxlength' => 50,
+ //'#required' => TRUE,
+ '#description' => t('Specify the Older version used')
+ );
+ $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,
+ '#required' => TRUE
+ );
+ $form['operating_system'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Operating System'),
+ '#required' => TRUE,
+ '#size' => 30,
+ '#maxlength' => 50
+ );
+ $reason = array(
+ 'Used in more than one University' => t('Used in more than one University'),
+ 'The book has multiple editions' => t('The book has multiple editions'),
+ 'Extremely useful' => t('Extremely useful'),
+ 'Other reason' => t('Any other reason state below')
+ );
+ $form['reason'] = array(
+ '#type' => 'checkboxes',
+ '#title' => t('Reasons'),
+ '#options' => $reason,
+ '#required' => TRUE
+ );
$form['other_reason'] = array(
- '#type' => 'textarea',
- '#size' => 300,
- '#maxlength' => 300,
- //'#required' => FALSE,
- );
- $form['proposal_type'] = array(
- '#type' => 'hidden',
- '#default_value' => '1',
- '#required' => FALSE,
- );
- $form['reference'] = array(
- '#type' => 'textarea',
- '#title' => t('Reference'),
- '#required' => TRUE,
- '#size' => 500,
- '#maxlength' => 500,
- '#attributes' =>array('placeholder' =>'Links of the syllabus must be provided....'),
- );
- $form['preference1'] = array(
- '#type' => 'fieldset',
- '#title' => t('Book Preference'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['preference1']['book1'] = array(
- '#type' => 'textfield',
- '#title' => t('Title of the book'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#value' => $row1->book,
- '#disabled' => ($row1->book?TRUE:FALSE),
- );
- $form['preference1']['author1'] = array(
- '#type' => 'textfield',
- '#title' => t('Author Name'),
- '#size' => 30,
- '#maxlength' => 100,
- '#required' => TRUE,
- '#value' => $row1->author,
- '#disabled' => ($row1->author?TRUE:FALSE),
- );
- $form['preference1']['isbn1'] = array(
- '#type' => 'textfield',
- '#title' => t('ISBN No'),
- '#size' => 30,
- '#maxlength' => 25,
- '#required' => TRUE,
- '#value' => $row1->isbn,
- '#disabled' => ($row1->isbn?TRUE:FALSE),
- );
- $form['preference1']['publisher1'] = array(
- '#type' => 'textfield',
- '#title' => t('Publisher & Place'),
- '#size' => 30,
- '#maxlength' => 50,
- '#required' => TRUE,
- '#value' => $row1->publisher,
- );
- $form['preference1']['edition1'] = array(
- '#type' => 'textfield',
- '#title' => t('Edition'),
- '#size' => 4,
- '#maxlength' => 2,
- '#required' => TRUE,
- '#value' => $row1->edition,
- );
- $form['preference1']['year1'] = array(
- '#type' => 'textfield',
- '#title' => t('Year of pulication'),
- '#size' => 4,
- '#maxlength' => 4,
+ '#type' => 'textarea',
+ '#size' => 300,
+ '#maxlength' => 300
+ //'#required' => FALSE,
+ );
+ $form['proposal_type'] = array(
+ '#type' => 'hidden',
+ '#value' => '1',
+ '#required' => FALSE
+ );
+ $form['reference'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Reference'),
+ '#required' => TRUE,
+ '#size' => 500,
+ '#maxlength' => 500,
+ '#attributes' => array(
+ 'placeholder' => 'Links of the syllabus must be provided....'
+ )
+ );
+ $form['preference1'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Book Preference'),
+ '#collapsible' => TRUE,
+ '#collapsed' => FALSE
+ );
+ $form['preference1']['book1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title of the book'),
+ '#size' => 30,
+ '#maxlength' => 100,
+ '#required' => TRUE,
+ '#value' => $row1->book,
+ '#disabled' => ($row1->book ? TRUE : FALSE)
+ );
+ $form['preference1']['author1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Author Name'),
+ '#size' => 30,
+ '#maxlength' => 100,
+ '#required' => TRUE,
+ '#value' => $row1->author,
+ '#disabled' => ($row1->author ? TRUE : FALSE)
+ );
+ $form['preference1']['isbn1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('ISBN No'),
+ '#size' => 30,
+ '#maxlength' => 25,
+ '#required' => TRUE,
+ '#value' => $row1->isbn,
+ '#disabled' => ($row1->isbn ? TRUE : FALSE)
+ );
+ $form['preference1']['publisher1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Publisher & Place'),
+ '#size' => 30,
+ '#maxlength' => 50,
+ '#required' => TRUE,
+ '#value' => $row1->publisher
+ );
+ $form['preference1']['edition1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Edition'),
+ '#size' => 4,
+ '#maxlength' => 2,
+ '#required' => TRUE,
+ '#value' => $row1->edition
+ );
+ $form['preference1']['year1'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Year of publication'),
+ '#size' => 4,
+ '#maxlength' => 4,
+ '#required' => TRUE,
+ '#value' => $row1->year
+ );
+ /*$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,
- '#value' => $row1->year,
- );
-
-
- $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')
- );
-
- /* #value fix for #default_value bug drupal6 */
- foreach(array("preference1") as $preference) {
+ );*/
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ /* #value fix for #default_value bug drupal6
+ foreach(array("preference1") as $preference) {
foreach($form[$preference] as $key => $value) {
- if(!$form[$preference][$key]["#value"]) {
- unset($form[$preference][$key]["#value"]);
- }
+ if(!$form[$preference][$key]["#value"]) {
+ unset($form[$preference][$key]["#value"]);
}
- }
-
- return $form;
+ }
+ }*/
+ return $form;
}
-
function book_proposal_nonaicte_form_submit($form, &$form_state)
{
- global $user;
- $selections = variable_get("aicte_".$user->uid, "");
- $tbc_to_emails = variable_get("textbook_companion_emails_all", "");
-
-
- if (!$user->uid) {
- drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
- return;
- }
-
- /* completion date */
- list($d, $m, $y) = explode('-', $form_state['values']['completion_date']);
- $con_date = $y.'-'.$m.'-'.$d;
- $date = new DateTime($con_date);
- $expected_completion_date = $date->format('Y-m-d');
- // var_dump($expected_completion_date) ;
-
- $dt = new DateTime();
- $current_date = $dt->format("Y-m-d");
-
- /* Reasons for suggesting a book*/
-
-
- if (isset($_POST['reason'])) {
-
- if(!($form_state['values']['other_reason'])){
-
- $my_reason = implode(", ", $_POST['reason']);
-
+ global $user;
+ $selections = variable_get("aicte_" . $user->uid, "");
+ $tbc_to_emails = variable_get("textbook_companion_emails_all");
+ if (!$user->uid) {
+ drupal_set_message('It is mandatory to login on this website to access the proposal form', 'error');
+ return;
}
-
- else{
- $my_reason = implode(", ", $_POST['reason']);
- $my_reason = $my_reason."-"." ".$form_state['values']['other_reason'];
+ /* completion date to timestamp */
+ list($d, $m, $y) = explode('-', $form_state['values']['completion_date']);
+ $completion_date_timestamp = mktime(0, 0, 0, $m, $d, $y);
+ /* Reasons for suggesting a book*/
+ if (isset($_POST['reason'])) {
+ if (!($form_state['values']['other_reason'])) {
+ $my_reason = implode(", ", $_POST['reason']);
+ } else {
+ $my_reason = implode(", ", $_POST['reason']);
+ $my_reason = $my_reason . "-" . " " . $form_state['values']['other_reason'];
+ }
+ $form_state['values']['other_reason'] = $my_reason;
}
- }
-
- /************************************/
-
-
- $dwsim_version = $form_state['values']['version'];
-
- if($form_state['values']['version'] == 'olderversion'){
- $dwsim_version = $form_state['values']['older'];
- }
-
- var_dump($form_state['values']);
-
- $query = "INSERT INTO {textbook_companion_proposal}
- (uid, approver_uid, full_name, mobile, gender, how_project, course, branch, university, faculty, reviewer, reference, expected_completion_date, creation_date, approval_date, proposal_status, dwsim_version, operating_system, teacher_email, proposal_type, reason ) VALUES (".$user->uid.", 0, '".ucwords(strtolower($form_state['values']['full_name']))."', '".$form_state['values']['mobile']."', '".$form_state['values']['gender']."', '".$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']))."', '".strtolower($form_state['values']['reference'])."', '".$expected_completion_date."', '".$current_date."', 0, 0, '".$dwsim_version."', '".$form_state['values']['operating_system']."', '".$form_state['values']['faculty_email']."','".$form_state['values']['proposal_type']."','".$my_reason."')";
-
- $result = db_query($query);
- 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}
+ /************************************/
+ $dwsim_version = $form_state['values']['version'];
+ if ($form_state['values']['version'] == 'olderversion') {
+ $dwsim_version = $form_state['values']['older'];
+ }
+ $form_state['values']['version'] = $dwsim_version;
+ //var_dump($form_state['values']);
+ /*$query = "INSERT INTO {textbook_companion_proposal}
+ (uid, approver_uid, full_name, mobile, gender, how_project, course, branch, university, faculty, reviewer, reference, completion_date, creation_date, approval_date, proposal_status, scilab_version, operating_system, teacher_email, proposal_type, reason ) VALUES (".$user->uid.", 0, '".ucwords(strtolower($form_state['values']['full_name']))."', '".$form_state['values']['mobile']."', '".$form_state['values']['gender']."', '".$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']))."', '".strtolower($form_state['values']['reference'])."', '".$completion_date_timestamp."', '".time()."', 0, 0, '".$scilab_version."', '".$form_state['values']['operating_system']."', '".$form_state['values']['faculty_email']."','".$form_state['values']['proposal_type']."','".$my_reason."')";*/
+ $query = "INSERT INTO {textbook_companion_proposal}
+ (uid, approver_uid, full_name, mobile, gender, how_project, course, branch, university,city,pincode,state,faculty, reviewer, reference, completion_date, creation_date,approval_date, proposal_status, version, operating_system, teacher_email, proposal_type, reason ) VALUES (:uid, :approver_uid, :full_name, :mobile, :gender, :how_project, :course, :branch, :university,:city,:pincode,:state, :faculty, :reviewer, :reference,
+:expected_completion_date, :actual_completion_date,:creation_date,:message, :approval_date, :proposal_status, :dwsim_version, :operating_system, :teacher_email,
+:proposal_type, :reason)";
+ $args = array(
+ "uid" => $user->uid,
+ "approver_uid" => 0,
+ "full_name" => ucwords(strtolower($form_state['values']['full_name'])),
+ "mobile" => $form_state['values']['mobile'],
+ "gender" => $form_state['values']['gender'],
+ "how_project" => $form_state['values']['how_project'],
+ "course" => $form_state['values']['course'],
+ "branch" => $form_state['values']['branch'],
+ "university" => $form_state['values']['university'],
+ ":city" => $form_state['values']['city'],
+ ":pincode" => $form_state['values']['pincode'],
+ ":state" => $form_state['values']['all_state'],
+ "faculty" => ucwords(strtolower($form_state['values']['faculty'])),
+ "reviewer" => ucwords(strtolower($form_state['values']['reviewer'])),
+ "reference" => strtolower($form_state['values']['reference']),
+ "completion_date" => $completion_date_timestamp,
+ "creation_date" => time(),
+ "approval_date" => time(),
+ "proposal_status" => 0,
+ "dwsim_version" => $dwsim_version,
+ "operating_system" => $form_state['values']['operating_system'],
+ "teacher_email" => $form_state['values']['faculty_email'],
+ "proposal_type" => $form_state['values']['proposal_type'],
+ "reason" => $my_reason
+ );
+ $result = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ 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, nonaicte_book) VALUES
+ (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %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,
+ 1
+ );*/
+ $query = "INSERT INTO {textbook_companion_preference}
(proposal_id, pref_number, book, author, isbn, publisher, edition, year, category, approval_status, nonaicte_book) VALUES
- (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %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,
- 1
- );
- if (!$result)
- {
- drupal_set_message(t('Error receiving your first book preference.'), 'error');
+ (:proposal_id, :pref_number, :book, :author, :isbn, :publisher, :edition, :year, :category, :approval_status, :nonaicte_book)";
+ $args = array(
+ ":proposal_id" => $proposal_id,
+ ":pref_number" => 1,
+ ":book" => ucwords(strtolower($form_state['values']['book1'])),
+ ":author" => ucwords(strtolower($form_state['values']['author1'])),
+ ":isbn" => $form_state['values']['isbn1'],
+ ":publisher" => ucwords(strtolower($form_state['values']['publisher1'])),
+ ":edition" => $form_state['values']['edition1'],
+ ":year" => $form_state['values']['year1'],
+ ":category" => 0,
+ ":approval_status" => 0,
+ ":nonaicte_book" => 1
+ );
+ $result = db_query($query, $args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ if (!$result) {
+ drupal_set_message(t('Error receiving your first book preference.'), 'error');
+ }
}
- }
-
- /* sending email */
- $email_to = $user->mail;
- $param['proposal_received']['proposal_id'] = $proposal_id;
- $param['proposal_received']['user_id'] = $user->uid;
- if (!drupal_mail('textbook_companion', 'nonaicte_proposal_received', $email_to , language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
- drupal_set_message('Error sending email message.', 'error');
- if (!drupal_mail('textbook_companion', 'nonaicte_proposal_to_pi', $tbc_to_emails, 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 your book proposal. We will get back to you soon.'), 'status');
- drupal_goto('');
+ /* sending email */
+ $email_to = $user->mail;
+ $param['proposal_received']['proposal_id'] = $proposal_id;
+ $param['proposal_received']['user_id'] = $user->uid;
+ if (!drupal_mail('textbook_companion', 'nonaicte_proposal_received', $email_to, language_default(), $param, variable_get('textbook_companion_from_email', NULL), TRUE))
+ drupal_set_message('Error sending email message.', 'error');
+ if (!drupal_mail('textbook_companion', 'nonaicte_proposal_to_pi', $tbc_to_emails, 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 your book proposal. We will get back to you soon.'), 'status');
+ drupal_goto('');
}
-
//
-
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);
+ $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 _list_of_software_version()
+{
+ $software_version = array();
+ $query = db_select('dwsim_software_version');
+ $query->fields('dwsim_software_version');
+ $query->orderBy('dwsim_version', 'ASC');
+ $software_version_list = $query->execute();
+ while ($software_version_list_data = $software_version_list->fetchObject()) {
+ $software_version[$software_version_list_data->dwsim_version] = $software_version_list_data->dwsim_version;
+ }
+ return $software_version;
}
-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');
-
-
+function _list_of_departments()
+{
+ $department = array();
+ $query = db_select('list_of_departments');
+ $query->fields('list_of_departments');
+ $query->orderBy('id', 'DESC');
+ $department_list = $query->execute();
+ while ($department_list_data = $department_list->fetchObject()) {
+ $department[$department_list_data->department] = $department_list_data->department;
+ }
+ return $department;
+}
+function _list_of_states()
+{
+ $states = array(
+ '' => '-select-'
+ );
+ $query = db_select('list_states_of_india');
+ $query->fields('list_states_of_india');
+ //$query->orderBy('', '');
+ $states_list = $query->execute();
+ while ($states_list_data = $states_list->fetchObject()) {
+ $states[$states_list_data->state] = $states_list_data->state;
+ }
+ return $states;
+}
+function _list_of_cities()
+{
+ $city = array(
+ '' => '-select-'
+ );
+ $query = db_select('list_cities_of_india');
+ $query->fields('list_cities_of_india');
+ $query->orderBy('city', 'ASC');
+ $city_list = $query->execute();
+ while ($city_list_data = $city_list->fetchObject()) {
+ $city[$city_list_data->city] = $city_list_data->city;
+ }
+ return $city;
+}
+/*************************************************************************/
+/***** Function To convert only first charater of string in uppercase ****/
+/*************************************************************************/
+/*function ucname($string) {
+$string =ucwords(strtolower($string));
+
+foreach (array('-', '\'') as $delimiter) {
+if (strpos($string, $delimiter)!==false) {
+$string =implode($delimiter, array_map('ucfirst', explode($delimiter, $string)));
+}
+}
+return $string;
+}*/
+function _dir_name($book, $author, $pref_id)
+{
+ if (!$pref_id) {
+ $book_title = ucname($book);
+ $author = ucname($author);
+ $dir_name = $book_title . " " . "by" . " " . $author;
+ $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name));
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('directory_name', $directory_name);
+ $query->condition('approval_status', 1);
+ $result = $query->execute()->rowCount();
+ if ($result > 0) {
+ //var_dump('this');die;
+ form_set_error('', t('Book is already allotted. Please try another book or contact to administrator'));
+ return;
+ }
+ } else {
+ $book_title = ucname($book);
+ $author = ucname($author);
+ $dir_name = $book_title . " " . "by" . " " . $author;
+ $directory_name = str_replace("__", "_", str_replace(" ", "_", $dir_name));
+ $query = db_select('textbook_companion_preference');
+ $query->fields('textbook_companion_preference');
+ $query->condition('directory_name', $directory_name);
+ $query->condition('id', $pref_id);
+ $result = $query->execute()->rowCount();
+ if ($result > 1) {
+ form_set_error('', t('Book is already present. Please try another book or contact to administrator'));
+ return;
+ }
+ }
+ return $directory_name;
}