From bf1aa0c785e94fe0680d726f77067f826bad9af8 Mon Sep 17 00:00:00 2001 From: priyankabhagwat Date: Wed, 30 Jul 2014 23:15:16 +0530 Subject: initial commit --- .gitignore | 42 +++++++ js/confirm.js | 15 +++ sbhs_past_workshop.info | 3 + sbhs_past_workshop.module | 309 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 369 insertions(+) create mode 100644 .gitignore create mode 100644 js/confirm.js create mode 100644 sbhs_past_workshop.info create mode 100644 sbhs_past_workshop.module diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8d25f50 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# Ignore configuration files that may contain sensitive information. +sites/*/*settings*.php + +# Ignore paths that contain generated content. +cache/ +files/ +sites/*/files +sites/*/private + +# Ignore default text files +robots.txt +/CHANGELOG.txt +/COPYRIGHT.txt +/INSTALL*.txt +/LICENSE.txt +/MAINTAINERS.txt +/UPGRADE.txt +/README.txt +sites/all/README.txt +sites/all/modules/README.txt +sites/all/themes/README.txt + +# Ignore everything but the "sites" folder ( for non core developer ) +.htaccess +web.config +authorize.php +cron.php +index.php +install.php +update.php +xmlrpc.php +/includes +/misc +/modules +/profiles +/scripts +/themes + +# Ignore vim temp. files +*.swo +*.swp +*~ diff --git a/js/confirm.js b/js/confirm.js new file mode 100644 index 0000000..0702632 --- /dev/null +++ b/js/confirm.js @@ -0,0 +1,15 @@ +$(document).ready(function() +{ + + $( ".delete").bind("click", function () { + var e=confirm('Are you sure?'); + if(e) + { + return true; + } + else + { + return false; + } + }); +}); diff --git a/sbhs_past_workshop.info b/sbhs_past_workshop.info new file mode 100644 index 0000000..ca6d4eb --- /dev/null +++ b/sbhs_past_workshop.info @@ -0,0 +1,3 @@ +name = sbhs_past_workshop +description = To manage and display testimonials +core = 6.x diff --git a/sbhs_past_workshop.module b/sbhs_past_workshop.module new file mode 100644 index 0000000..1a2f8fb --- /dev/null +++ b/sbhs_past_workshop.module @@ -0,0 +1,309 @@ + + "Past Workshops", + "page callback" => "sbhs_past_workshop_display_all", + "access arguments" => array("view past workshop"), + "type" => MENU_CALLBACK + ); + $items["workshops/add"] = array( + "title" => "Add Past Workshops", + "page callback" => "sbhs_past_workshop_add_all", + "access arguments" => array("manage past workshop"), + "type" => MENU_CALLBACK + ); + $items["workshops/edit"] = array( + "title" => "Edit Past Workshops", + "page callback" => "sbhs_past_workshop_edit_all", + "access arguments" => array("manage past workshop"), + "type" => MENU_CALLBACK + ); + $items["workshops/delete"] = array( + "title" => "Delete Past Workshops", + "page callback" => "sbhs_past_workshop_delete_all", + "access arguments" => array("manage past workshop"), + "type" => MENU_CALLBACK + ); + + $items["user_view"] = array( + "title" => "View Past Workshops", + "page callback" => "sbhs_past_workshop_view_all", + "access arguments" => array("view past workshop"), + "type" => MENU_CALLBACK + ); + + $items["user_view/view_details"] = array( + "title" => "View Past Workshops Details", + "page callback" => "sbhs_past_workshop_view_details_all", + "access arguments" => array("view past workshop"), + "type" => MENU_CALLBACK + ); + + $items["upcoming_workshops"] = array( + "title" => "View Upcoming Workshops", + "page callback" => "sbhs_past_workshop_view_upcoming_all", + "access arguments" => array("view upcoming workshop"), + "type" => MENU_CALLBACK + ); + + return $items; + } + + function sbhs_past_workshop_perm() { + return array( + "view past workshop", + "manage past workshop", + ); + } + + function sbhs_past_workshop_add_form($form_state, $workshop_id=0) { + $query = " + SELECT * FROM sbhs_workshop + WHERE w_id = {$workshop_id} + "; + $result = db_query($query); + $row = db_fetch_object($result); + + $form = array(); + $form["organiser"] = array( + "#type" => "textfield", + "#title" => "Organiser", + "#default_value" => $row->organiser, + "#required" => TRUE + ); + $form["date"] = array( + "#type" => "textfield", + "#title" => "Date", + "#default_value" => $row->date, + "#required" => TRUE + ); + $form["time"] = array( + "#type" => "textfield", + "#title" => "Time", + "#default_value" => $row->time, + "#required" => TRUE + ); + $form["institute"] = array( + "#type" => "textfield", + "#title" => "Institute", + "#default_value" => $row->institute, + "#required" => TRUE + ); + + $form["street"] = array( + "#type" => "textfield", + "#title" => "Street", + "#default_value" => $row->street, + "#required" => TRUE + ); + $form["city"] = array( + "#type" => "textfield", + "#title" => "City", + "#default_value" => $row->city, + "#required" => TRUE + ); + $form["state"] = array( + "#type" => "textfield", + "#title" => "State", + "#default_value" => $row->state, + "#required" => TRUE + ); + $form["pincode"] = array( + "#type" => "textfield", + "#title" => "Pincode", + "#default_value" => $row->pincode, + "#required" => TRUE + ); + $form["no_of_students"] = array( + "#type" => "textfield", + "#title" => "Number Of Students", + "#default_value" => $row->no_of_students, + "#required" => TRUE + ); + $form["body"] = array( + "#type" => "textarea", + "#title" => "Description", + "#default_value" => $row->body, + "#required" => TRUE + ); + + $form["workshop_id"] = array( + "#type" => "hidden", + "#value" => $workshop_id + ); + $form["submit"] = array( + "#type" => "submit", + "#value" => "Submit" + ); + return $form; + } + + + function sbhs_past_workshop_add_form_validate($form,&$form_state) { + // for future use + } + + function sbhs_past_workshop_display_all() + { + $page_content = ""; + $page_content .= drupal_get_form("sbhs_past_workshop_add_form"); + + return $page_content; + + } + + + + function sbhs_past_workshop_add_form_submit($form, &$form_state) { + $v = $form_state["values"]; + if($v["workshop_id"]) { + $query = " + UPDATE sbhs_workshop SET + organiser = '%s', date = '%s', time = '%s', + institute = '%s', street = '%s', city = '%s', + state = '%s',pincode = %d,no_of_students = %d,body = '%s' + WHERE w_id = %d + "; + $result = db_query($query, + $v["organiser"], $v["date"], $v["time"], + $v["institute"], $v["street"], $v["city"], + $v["state"], $v["pincode"], $v["no_of_students"],$v["body"],$v["workshop_id"] + ); + + } else { + $query = " + INSERT INTO sbhs_workshop + (organiser, date, time, institute, street, city,state,pincode,no_of_students,body) + VALUES + ('%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s') + "; + $result = db_query($query, + $v["organiser"], $v["date"], $v["time"], + $v["institute"], $v["street"], $v["city"], + $v["state"], $v["pincode"], $v["no_of_students"],$v["body"] + ); + } + if(!$result) { + drupal_set_message("Something went wrong, please try again.", "error"); + } else { + drupal_set_message("Workshop added successfully","status"); + } + } + + + + function sbhs_past_workshop_delete_all($workshop_id=0) + { + $page_content = ""; + $query = "DELETE from sbhs_workshop + WHERE w_id = {$workshop_id}"; + $result = db_query($query,$workshop_id); + if(!$result) { + drupal_set_message("Something went wrong, please try again.", "error"); + } else { + drupal_set_message("Workshop Deleted successfully","status"); + } + return $page_content; + } + + + function sbhs_past_workshop_edit_all($workshop_id=0) { + $page_content = ""; + if($workshop_id){ + $page_content .= drupal_get_form("sbhs_past_workshop_add_form", $workshop_id); + } else { + $query = " + SELECT * FROM sbhs_workshop + ORDER BY date desc"; + $result = db_query($query); + $headers = array( + "Date","Institute", "City","No of Students","Action" + ); + $rows = array(); + $options = array('attributes' => array('class' => 'delete')); + while($row = db_fetch_object($result)) { + $item = array( + $row->date, + $row->institute, + $row->city, + $row->no_of_students, + l("Edit", "workshops/edit/{$row->w_id}") ." | ". + l("Delete","workshops/delete/{$row->w_id}",$options) + + ); + array_push($rows, $item); + } + $page_content .= theme("table", $headers, $rows); + } + return $page_content; + } + + function sbhs_past_workshop_view_all($workshop_id=0) { + + $page_content = ""; + $query = " + SELECT * FROM sbhs_workshop + ORDER BY date desc"; + $result = db_query($query); + $headers = array( + "Date","Institute", "City","No of Students","Action" + ); + $rows = array(); + $options = array('attributes' => array('class' => 'delete')); + while($row = db_fetch_object($result)) { + $item = array( + $row->date, + $row->institute, + $row->city, + $row->no_of_students, + l("view", "user_view/view_details/{$row->w_id}") + + ); + array_push($rows, $item); + } + $page_content .= theme("table", $headers, $rows); + + return $page_content; + } + + function sbhs_past_workshop_view_details_all($workshop_id=0) { + $page_content = ""; + $query = " + SELECT * FROM sbhs_workshop + ORDER BY date desc"; + $result = db_query($query); + $row=db_fetch_object($result); + $page_content .=""; + $page_content .=""; + $page_content .=""; + $page_content .=""; + $page_content .=""; + $page_content .=""; + $page_content .=""; + $page_content .=""; + $page_content .=""; + $page_content .=""; + $page_content .=""; + $page_content .="
Institute{$row->institute}
Workshop Date{$row->date}
Workshop Time{$row->time}
No. of Participants{$row->no_of_students}
Organiser{$row->organiser}
Street{$row->street}
City{$row->city}
State{$row->state}
Pincode{$row->pincode}
Description{$row->body}
"; + + + return $page_content; + + } + + function sbhs_past_workshop_view_upcoming_all() + { + $page_content = ""; + $page_content .= "
There are no upcoming workshops for now. Keep checking for updates
"; + return $page_content; + + } + + function sbhs_past_workshop_init() { + drupal_add_js(drupal_get_path("module", "sbhs_past_workshop") . "/js/confirm.js"); + } + + +?> -- cgit