summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcss/fellowship_testimonials.css69
-rw-r--r--css/testimonials.css23
-rwxr-xr-x[-rw-r--r--]fellowship_testimonials.info (renamed from testimonials.info)3
-rwxr-xr-xfellowship_testimonials.module85
-rw-r--r--settings.inc61
-rw-r--r--testimonials.module193
-rw-r--r--testimonials_add.inc412
7 files changed, 629 insertions, 217 deletions
diff --git a/css/fellowship_testimonials.css b/css/fellowship_testimonials.css
new file mode 100755
index 0000000..4f741af
--- /dev/null
+++ b/css/fellowship_testimonials.css
@@ -0,0 +1,69 @@
+#testimonials-wrapper .testimonial {
+ position: relative;
+ text-align: justify;
+ margin: 25px 0 0 0;
+ padding: 0 0 10px 0;
+ background: #e5e5e5;
+ padding: 10px;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -o-border-radius: 5px;
+ border-radius: 5px;
+}
+#testimonials-wrapper .testimonial > .author {
+ text-align: right;
+ font-weight: bolder;
+ margin: 15px 0 0 0;
+ background: #ffffff;
+ padding: 10px;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+ -o-border-radius: 5px;
+ border-radius: 5px;
+}
+.tabcontent {
+ display: none;
+ padding: 6px 12px;
+}
+.container-testimonial {
+ border: 2px solid #ccc;
+ background-color: #eee;
+ border-radius: 5px;
+ padding: 16px;
+ margin: 10px 0;
+}
+video {
+ max-width: 100%;
+ height: auto !important;
+}
+.container-testimonial::after {
+ content: "";
+ clear: both;
+ display: table;
+}
+
+.container-testimonial video {
+ float: left;
+ margin-right: 20px;
+}
+
+.container-testimonial span {
+ font-size: 20px;
+}
+
+.container-testimonial p {
+ margin: 0px !important;
+}
+
+
+@media (max-width: 500px) {
+ .container-testimonial {
+ text-align: center;
+ }
+ .container-testimonial video {
+ margin: auto;
+ float: none;
+ display: block;
+ }
+}
+
diff --git a/css/testimonials.css b/css/testimonials.css
deleted file mode 100644
index 54c9d2a..0000000
--- a/css/testimonials.css
+++ /dev/null
@@ -1,23 +0,0 @@
-#testimonials-wrapper .testimonial {
- position: relative;
- text-align: justify;
- margin: 25px 0 0 0;
- padding: 0 0 10px 0;
- background: #e5e5e5;
- padding: 10px;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- -o-border-radius: 5px;
- border-radius: 5px;
-}
-#testimonials-wrapper .testimonial > .author {
- text-align: right;
- font-weight: bolder;
- margin: 15px 0 0 0;
- background: #ffffff;
- padding: 10px;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- -o-border-radius: 5px;
- border-radius: 5px;
-}
diff --git a/testimonials.info b/fellowship_testimonials.info
index 083f62d..5c971e0 100644..100755
--- a/testimonials.info
+++ b/fellowship_testimonials.info
@@ -1,3 +1,4 @@
name = Testimonials
description = To manage and display testimonials
-core = 6.x
+core = 7.x
+package = IITB
diff --git a/fellowship_testimonials.module b/fellowship_testimonials.module
new file mode 100755
index 0000000..e84ec28
--- /dev/null
+++ b/fellowship_testimonials.module
@@ -0,0 +1,85 @@
+<?php
+ function fellowship_testimonials_menu() {
+ $items = array();
+ $items["fellowship-testimonials"] = array(
+ "title" => "Testimonials by FOSSEE Summer Fellows",
+ "page callback" => "fellowship_testimonials_display_all",
+ "access arguments" => array("view fellowship_testimonials"),
+ "type" => MENU_CALLBACK
+ );
+ $items["fellowship-testimonials/add"] = array(
+ "title" => "Add fellowship testimonials",
+ "page callback" => "fellowship_testimonials_add_all",
+ "access arguments" => array("manage fellowship_testimonials"),
+ "type" => MENU_CALLBACK,
+ 'file' => 'testimonials_add.inc'
+ );
+ $items["fellowship-testimonials/edit"] = array(
+ "title" => "Edit fellowship_testimonials",
+ "page callback" => "fellowship_testimonials_edit_all",
+ "access arguments" => array("manage fellowship_testimonials"),
+ "type" => MENU_CALLBACK,
+ 'file' => 'testimonials_add.inc'
+ );
+ $items["fellowship-testimonials/delete"] = array(
+ "title" => "Delete Testimonial",
+ "page callback" => "fellowship_testimonials_delete_all",
+ "access arguments" => array("manage fellowship_testimonials"),
+ "type" => MENU_CALLBACK
+ );
+ return $items;
+ }
+
+ function fellowship_testimonials_permission() {
+ return array(
+ "view fellowship_testimonials" => array (
+ "title" => t("view fellowship_testimonials"),
+ 'restrict access' => TRUE,
+ ),
+ "manage fellowship_testimonials" => array (
+ "title" => t("manage fellowship_testimonials"),
+ 'restrict access' => TRUE,
+ ),
+ );
+ }
+ function fellowship_testimonials_display_all() {
+ $page_content = "";
+ /*$query = "
+ SELECT * FROM fellowship_testimonials
+ ORDER BY id DESC
+ ";
+ $result = pager_query($query, 4, 0, "SELECT COUNT(*) FROM fellowship_testimonials");*/
+ $query = db_select('fellowship_testimonials');
+ $query->fields('fellowship_testimonials');
+ $query->orderBy('year', 'DESC');
+ $result = $query->extend('PagerDefault')->limit(3)->execute();
+
+ $page_content .= "<div id='fellowship_testimonials-wrapper'>";
+ while($row = $result->fetchObject()) {
+ $speakerquery = db_select('fellows');
+ $speakerquery->fields('fellows');
+ $speakerquery->condition('t_id', $row->id);
+ $speakerresult = $speakerquery->execute();
+
+ $page_content .= "
+ <div class='container-testimonial'>
+ <video title='' controls='' preload='' data-setup='{}' width='500' height='400'>
+ <source src={$row->testimonial_video} type='video/mp4'>
+ </video> ";
+ while($speakerrow = $speakerresult->fetchObject()){
+ $page_content .= "<p><span>{$speakerrow->name}</span><br>Institute: {$speakerrow->institute}, {$speakerrow->place}<br><br><span style='margin-right:0;'>";
+ }
+ $page_content .= "Fellowship task</span>: {$row->fellowship_task}
+ <br><br><span>Fellowship Year</span>: {$row->year}</p></div>";
+
+ }
+ $page_content .= "</div> <!-- /#fellowship_testimonials-wrapper -->";
+ //$page_content .= theme("pager", NULL, 4, 0);
+ $page_content .= theme('pager', array('header' => NULL, 'rows' => 4 ));
+ return $page_content;
+ }
+
+ function fellowship_testimonials_init() {
+ drupal_add_css(drupal_get_path("module", "fellowship_testimonials") . "/css/fellowship_testimonials.css");
+ }
+?>
diff --git a/settings.inc b/settings.inc
new file mode 100644
index 0000000..dccc684
--- /dev/null
+++ b/settings.inc
@@ -0,0 +1,61 @@
+<?php
+// $Id$
+function fellowship_testimonials_settings_form($form, $form_state)
+{
+ $form['extensions']['testimonial_video'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed file extensions for uploading resource files'),
+ '#description' => t('A comma separated list WITHOUT SPACE of source file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('resource_upload_extensions', '')
+ );
+ $form['extensions']['abstract_upload'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed file extensions for abstract'),
+ '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('fellowship_testimonials_abstract_upload_extensions', '')
+ );
+ $form['extensions']['fellowship_testimonials_upload'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed extensions for project files'),
+ '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('fellowship_testimonials_simulation_file', '')
+ );
+ $form['extensions']['fellowship_testimonials_script_upload'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Allowed extensions for script files'),
+ '#description' => t('A comma separated list WITHOUT SPACE of pdf file extensions that are permitted to be uploaded on the server'),
+ '#size' => 50,
+ '#maxlength' => 255,
+ '#required' => TRUE,
+ '#default_value' => variable_get('fellowship_testimonials_script_file', '')
+ );
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Submit')
+ );
+ return $form;
+}
+function fellowship_testimonials_settings_form_validate($form, &$form_state)
+{
+ return;
+}
+function fellowship_testimonials_settings_form_submit($form, &$form_state)
+{
+ variable_set('fellowship_testimonials_emails', $form_state['values']['emails']);
+ variable_set('fellowship_testimonials_cc_emails', $form_state['values']['cc_emails']);
+ variable_set('fellowship_testimonials_from_email', $form_state['values']['from_email']);
+ variable_set('resource_upload_extensions', $form_state['values']['resource_upload']);
+ variable_set('fellowship_testimonials_abstract_upload_extensions', $form_state['values']['abstract_upload']);
+ variable_set('fellowship_testimonials_simulation_file', $form_state['values']['fellowship_testimonials_upload']);
+ variable_set('fellowship_testimonials_script_file', $form_state['values']['fellowship_testimonials_script_upload']);
+ drupal_set_message(t('Settings updated'), 'status');
+} \ No newline at end of file
diff --git a/testimonials.module b/testimonials.module
deleted file mode 100644
index 9c35e70..0000000
--- a/testimonials.module
+++ /dev/null
@@ -1,193 +0,0 @@
-<?php
- function testimonials_menu() {
- $items = array();
- $items["testimonials"] = array(
- "title" => "Testimonials",
- "page callback" => "testimonials_display_all",
- "access arguments" => array("view testimonials"),
- "type" => MENU_CALLBACK
- );
- $items["testimonials/add"] = array(
- "title" => "Add Testimonials",
- "page callback" => "testimonials_add_all",
- "access arguments" => array("manage testimonials"),
- "type" => MENU_CALLBACK
- );
- $items["testimonials/edit"] = array(
- "title" => "Edit Testimonials",
- "page callback" => "testimonials_edit_all",
- "access arguments" => array("manage testimonials"),
- "type" => MENU_CALLBACK
- );
- $items["testimonials/delete"] = array(
- "title" => "Delete Testimonial",
- "page callback" => "testimonials_delete_all",
- "access arguments" => array("manage testimonials"),
- "type" => MENU_CALLBACK
- );
- return $items;
- }
-
- function testimonials_perm() {
- return array(
- "view testimonials",
- "manage testimonials",
- );
- }
-
- function testimonials_add_form($form_state, $testimonial_id=0) {
- $query = "
- SELECT * FROM testimonials
- WHERE id = {$testimonial_id}
- ";
- $result = db_query($query);
- $row = db_fetch_object($result);
-
- $form = array();
- $form["name"] = array(
- "#type" => "textfield",
- "#title" => "Name",
- "#default_value" => $row->name,
- "#required" => TRUE
- );
- $form["department"] = array(
- "#type" => "textfield",
- "#title" => "Department",
- "#default_value" => $row->department,
- "#required" => TRUE
- );
- $form["university"] = array(
- "#type" => "textfield",
- "#title" => "University",
- "#default_value" => $row->university,
- "#required" => TRUE
- );
- $form["contribution"] = array(
- "#type" => "textfield",
- "#title" => "Contribution",
- "#default_value" => $row->contribution,
- "#required" => TRUE
- );
- $form["reference"] = array(
- "#type" => "textfield",
- "#title" => "Reference",
- "#default_value" => $row->reference,
- "#required" => TRUE
- );
- $form["body"] = array(
- "#type" => "textarea",
- "#title" => "Testimonial",
- "#default_value" => $row->body,
- "#required" => TRUE
- );
- $form["testimonial_id"] = array(
- "#type" => "hidden",
- "#value" => $testimonial_id
- );
- $form["submit"] = array(
- "#type" => "submit",
- "#value" => "Submit"
- );
- return $form;
- }
-
- function testimonials_add_form_validate($form, &$form_state) {
- // for future use
- }
-
- function testimonials_add_form_submit($form, &$form_state) {
- $v = $form_state["values"];
- if($v["testimonial_id"]) {
- $query = "
- UPDATE testimonials SET
- name = '%s', department = '%s', university = '%s',
- contribution = '%s', reference = '%s', body = '%s'
- WHERE id = %d
- ";
- $result = db_query($query,
- $v["name"], $v["department"], $v["university"],
- $v["contribution"], $v["reference"], $v["body"],
- $v["testimonial_id"]
- );
- } else {
- $query = "
- INSERT INTO testimonials
- (name, department, university, contribution, reference, body)
- VALUES
- ('%s', '%s', '%s', '%s', '%s', '%s')
- ";
- $result = db_query($query,
- $v["name"], $v["department"], $v["university"],
- $v["contribution"], $v["reference"], $v["body"]
- );
- }
- if(!$result) {
- drupal_set_message("Something went wrong, please try again.", "error");
- } else {
- drupal_set_message("Testimonial added successfully", "status");
- }
- }
-
- function testimonials_add_all() {
- $page_content = "";
- $page_content .= drupal_get_form("testimonials_add_form");
- return $page_content;
- }
-
- function testimonials_edit_all($testimonial_id=0) {
- $page_content = "";
- if($testimonial_id){
- $page_content .= drupal_get_form("testimonials_add_form", $testimonial_id);
- } else {
- $query = "
- SELECT * FROM testimonials
- ORDER BY time DESC
- ";
- $result = db_query($query);
- $headers = array(
- "Name", "University", "Action"
- );
- $rows = array();
- while($row = db_fetch_object($result)) {
- $item = array(
- $row->name,
- $row->university,
- l("Edit", "testimonials/edit/{$row->id}") ." | ".
- l("Delete", "testimonials/delete/{$row->id}")
- );
- array_push($rows, $item);
- }
- $page_content .= theme("table", $headers, $rows);
- }
- return $page_content;
- }
-
- function testimonials_display_all() {
- $page_content = "";
- $query = "
- SELECT * FROM testimonials
- ORDER BY id DESC
- ";
- $result = pager_query($query, 4, 0, "SELECT COUNT(*) FROM testimonials");
-
- $page_content .= "<div id='testimonials-wrapper'>";
- while($row = db_fetch_object($result)) {
- $page_content .= "
- <div class='testimonial'>
- {$row->body}
- <div class='author'>
- - {$row->name}, {$row->department}, {$row->university}<br>
- ({$row->contribution}: {$row->reference})
- </div>
- </div>
- ";
- }
- $page_content .= "</div> <!-- /#testimonials-wrapper -->";
- $page_content .= theme("pager", NULL, 4, 0);
- return $page_content;
- }
-
- function testimonials_init() {
- drupal_add_css(drupal_get_path("module", "testimonials") . "/css/testimonials.css");
- }
-?>
diff --git a/testimonials_add.inc b/testimonials_add.inc
new file mode 100644
index 0000000..eeedb90
--- /dev/null
+++ b/testimonials_add.inc
@@ -0,0 +1,412 @@
+<?php
+function fellowship_testimonials_add_all() {
+ $page_content = "";
+ $fellowship_testimonials_add_form = drupal_get_form("fellowship_testimonials_add_form");
+ $page_content .= drupal_render($fellowship_testimonials_add_form);
+ return $page_content;
+ }
+function fellowship_testimonials_add_form($form,$form_state, $testimonial_id = 0) {
+ $testimonial_id = arg(2);
+ $query = db_select('fellowship_testimonials');
+ $query->fields('fellowship_testimonials');
+ $query->condition('id', $testimonial_id);
+ $result = $query->execute();
+ $row = $result->fetchObject();
+ $form = array();
+ $form["fellowship_year"] = array(
+ "#type" => "textfield",
+ "#title" => "Enter the fellowship year participated by the fellow(s)",
+ '#attributes' => array(
+ 'placeholder' => t('For eg: 2019')
+ ),
+ "#default_value" => $row->year,
+ "#required" => TRUE
+ );
+ $form["fellowship_task"] = array(
+ "#type" => "textfield",
+ "#title" => "Enter the fellowship task done by the fellow(s)",
+ '#attributes' => array(
+ 'placeholder' => t('For eg: Python, DWSIM, eSim etc')
+ ),
+ "#default_value" => $row->fellowship_task,
+ "#required" => TRUE
+ );
+
+ $form["testimonial_video"] = array(
+ "#type" => "textfield",
+ "#title" => "Testimonial Video",
+ '#attributes' => array(
+ 'placeholder' => t('Copy paste the static url of the video, for eg: https://static.fossee.in/fossee/videos/FOSSEE_intern_Video/DSC_0006.m4v')
+ ),
+ "#default_value" => $row->testimonial_video,
+ '#size' => 90,
+ "#required" => TRUE
+ );
+ /*$form['fellows_fieldset'] = array(
+ '#type' => 'fieldset',
+ '#tree' => TRUE,
+ '#prefix' => '<div id="fellows-fieldset-wrapper">',
+ '#suffix' => '</div>'
+ );
+ if (empty($form_state['num_fellows'])) {
+ $form_state['num_fellows'] = 1;
+ }
+ $temp = 0;
+ for ($i = 0; $i < $form_state['num_fellows']; $i++) {
+ $temp1 = $i;
+ $form['fellows_fieldset'][$i]["s_text"] = array(
+ "#type" => "item",
+ "#markup" => "<h4><label>fellow : " . ($temp1 + 1) . "</label></h4>"
+ );
+ $form['fellows_fieldset'][$i]["fellowname"] = array(
+ "#type" => "textfield",
+ "#title" => "Name: ",
+ "#default_value" => ""
+ );
+ $form['fellows_fieldset'][$i]["institute"] = array(
+ "#type" => "textfield",
+ "#title" => "Institute: ",
+ "#default_value" => ""
+ );
+ $form['fellows_fieldset'][$i]["place"] = array(
+ "#type" => "textfield",
+ "#title" => "Place: ",
+ "#default_value" => ""
+ );
+ }
+ $form["fellows_count"] = array(
+ "#type" => "hidden",
+ "#value" => $temp1
+ );
+ $form['fellows_fieldset']['add_fellows'] = array(
+ '#type' => 'submit',
+ '#value' => t('Add fellow'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'fellows_add_more_add_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'fellows_add_more_callback',
+ 'wrapper' => 'fellows-fieldset-wrapper'
+ )
+ );
+ if ($form_state['num_fellows'] > 1) {
+ $form['fellows_fieldset']['remove_fellows'] = array(
+ '#type' => 'submit',
+ '#value' => t('Remove Fellow'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'fellows_add_more_remove_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'fellows_add_more_callback',
+ 'wrapper' => 'fellows-fieldset-wrapper'
+ )
+ );
+ }
+ if ($no_js_use) {
+ if (!empty($form['fellows_fieldset']['remove_fellows']['#ajax'])) {
+ unset($form['fellows_fieldset']['remove_fellows']['#ajax']);
+ }
+ unset($form['fellows_fieldset']['add_fellows']['#ajax']);
+ }*/
+ $query_s = db_select('fellows');
+ $query_s->fields('fellows');
+ $query_s->condition('t_id', $row->id);
+ $result_s = $query_s->execute();
+ $num_of_fellowresults = $result_s->rowCount();
+
+ $form['fellows_fieldset'] = array(
+ '#type' => 'fieldset',
+ '#tree' => TRUE,
+ '#prefix' => '<div id="fellows-fieldset-wrapper">',
+ '#suffix' => '</div>'
+ );
+
+ if ($num_of_fellowresults != 0) {
+
+ $form_state['num_fellows'] = $num_of_fellowresults;
+ $temp = 0;
+ $i = 0;
+ while ($row_s = $result_s->fetchObject()) {
+ $temp = $i;
+ $form['fellows_fieldset'][$i]["s_text"] = array(
+ "#type" => "item",
+ "#markup" => "<h4><label>fellows : " . ($temp + 1) . "</label></h4>"
+ );
+ $form['fellows_fieldset'][$i]["s_id"] = array(
+ "#type" => "hidden",
+ "#default_value" => $row_s->s_id
+ );
+ $form['fellows_fieldset'][$i]["fellowname"] = array(
+ "#type" => "textfield",
+ "#title" => "Name",
+ "#default_value" => $row_s->name
+ );
+ $form['fellows_fieldset'][$i]["institute"] = array(
+ "#type" => "textfield",
+ "#title" => "Institute",
+ "#default_value" => $row_s->institute
+ );
+ $form['fellows_fieldset'][$i]["place"] = array(
+ "#type" => "textfield",
+ "#title" => "Place",
+ "#default_value" => $row_s->place
+ );
+
+ $i++;
+ }
+
+
+ $form["fellows_count"] = array(
+ "#type" => "hidden",
+ "#value" => $temp
+ );
+
+ }
+ else {
+ if (empty($form_state['num_fellows'])) {
+ $form_state['num_fellows'] = 1;
+ }
+ $temp = 0;
+ for ($i = 0; $i < $form_state['num_fellows']; $i++) {
+ $temp = $i;
+ $form['fellows_fieldset'][$i]["s_text"] = array(
+ "#type" => "item",
+ "#markup" => "<h4><label>fellows : " . ($temp + 1) . "</label></h4>"
+ );
+ $form['fellows_fieldset'][$i]["fellowname"] = array(
+ "#type" => "textfield",
+ "#title" => "Name",
+ "#default_value" => ""
+ );
+ $form['fellows_fieldset'][$i]["institute"] = array(
+ "#type" => "textfield",
+ "#title" => "Department",
+ "#default_value" => ""
+ );
+ $form['fellows_fieldset'][$i]["place"] = array(
+ "#type" => "textfield",
+ "#title" => "University",
+ "#default_value" => ""
+ );
+
+ }
+ $form["fellows_count"] = array(
+ "#type" => "hidden",
+ "#value" => $temp
+ );
+ $form['fellows_fieldset']['add_fellows'] = array(
+ '#type' => 'submit',
+ '#value' => t('Add fellow'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'fellows_add_more_add_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'fellows_add_more_callback',
+ 'wrapper' => 'fellows-fieldset-wrapper'
+ )
+ );
+ if ($form_state['num_fellows'] > 1) {
+ $form['fellows_fieldset']['remove_fellows'] = array(
+ '#type' => 'submit',
+ '#value' => t('Remove'),
+ '#limit_validation_errors' => array(),
+ '#submit' => array(
+ 'fellows_add_more_remove_one'
+ ),
+ '#ajax' => array(
+ 'callback' => 'fellows_add_more_callback',
+ 'wrapper' => 'fellows-fieldset-wrapper'
+ )
+ );
+ }
+ if ($no_js_use) {
+ if (!empty($form['fellows_fieldset']['remove_fellows']['#ajax'])) {
+ unset($form['fellows_fieldset']['remove_fellows']['#ajax']);
+ }
+ unset($form['fellows_fieldset']['add_fellows']['#ajax']);
+ }
+ }
+
+ $form["testimonial_id"] = array(
+ "#type" => "hidden",
+ "#value" => $testimonial_id
+ );
+ $form["submit"] = array(
+ "#type" => "submit",
+ "#value" => "Submit"
+ );
+ return $form;
+ }
+
+ function fellows_add_more_callback($form, $form_state) {
+ return $form['fellows_fieldset'];
+}
+
+
+function fellows_add_more_add_one($form, &$form_state) {
+ $form_state['num_fellows']++;
+ $form_state['rebuild'] = TRUE;
+ //$form_state['no_redirect'] = TRUE;
+}
+
+
+function fellows_add_more_remove_one($form, &$form_state) {
+ if ($form_state['num_fellows'] > 1) {
+ $form_state['num_fellows']--;
+ }
+ $form_state['rebuild'] = TRUE;
+}
+
+ function fellowship_testimonials_add_form_validate($form, &$form_state) {
+ // for future use
+ }
+
+ function fellowship_testimonials_add_form_submit($form, &$form_state) {
+ $v = $form_state["values"];
+ if($v["testimonial_id"]) {
+ /*$query = "
+ UPDATE fellowship_testimonials SET
+ name = '%s', department = '%s', university = '%s',
+ contribution = '%s', reference = '%s', body = '%s'
+ WHERE id = %d
+ ";
+ $result = db_query($query,
+ $v["name"], $v["department"], $v["university"],
+ $v["contribution"], $v["reference"], $v["body"],
+ $v["testimonial_id"]
+ );*/
+
+ $query = db_update('fellowship_testimonials');
+ $query->fields(array(
+ 'year' => $v["fellowship_year"],
+ 'fellowship_task' => $v["fellowship_task"],
+ 'testimonial_video' => $v["testimonial_video"]
+ ));
+ $query->condition('id', $v["testimonial_id"]);
+ $result = $query->execute();
+ } else {
+ /*$query = "
+ INSERT INTO fellowship_testimonials
+ (name, department, university, contribution, reference, body)
+ VALUES
+ ('%s', '%s', '%s', '%s', '%s', '%s')
+ ";
+ $result = db_query($query,
+ $v["name"], $v["department"], $v["university"],
+ $v["contribution"], $v["reference"], $v["body"]
+ );*/
+
+ $query = "
+ INSERT INTO fellowship_testimonials
+ (year, fellowship_task, testimonial_video)
+ VALUES
+ (:year, :fellowship_task, :testimonial_video)
+ ";
+ $args = array(
+ ':year' => $v["fellowship_year"],
+ ':fellowship_task' => $v["fellowship_task"],
+ ':testimonial_video' => $v["testimonial_video"]
+ );
+
+ $result = db_query($query,$args, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+
+ //var_dump($result->name);die;
+ $fellowsupload = 0;
+ for ($i = 0; $i <= $v["fellows_count"]; $i++) {
+ $s_id=$v['fellows_fieldset'][$i]["f_id"];
+ if ($s_id != "") {
+ if ($v['fellows_fieldset'][$i]["fellowname"] != "") {
+ $query = db_update('fellows');
+ $query->fields(array(
+ 'name' => $v['fellows_fieldset'][$i]["fellowname"],
+ 'institute' => $v['fellows_fieldset'][$i]["institute"],
+ 'place' => $v['fellows_fieldset'][$i]["place"]
+ ));
+ $query->condition('f_id', $v['fellows_fieldset'][$i]["s_id"]);
+ $result = $query->execute();
+ if ($result != 0) {
+ $fellowsupload++;
+ }
+ }
+ }
+ else {
+ if ($v['fellows_fieldset'][$i]["fellowname"] != "") {
+ $fellowsquery = "
+ INSERT INTO fellows
+ (t_id,name,institute,place)
+ VALUES
+ (:t_id,:name,:institute,:place)
+ ";
+ $fellowsargs = array(
+ ":t_id" => $result,
+ ":name" => $v['fellows_fieldset'][$i]["fellowname"],
+ ":institute" => $v['fellows_fieldset'][$i]["institute"],
+ ":place" => $v['fellows_fieldset'][$i]["place"]
+ );
+ /* storing the row id in $result */
+ $fellowsresult = db_query($fellowsquery, $fellowsargs, array(
+ 'return' => Database::RETURN_INSERT_ID
+ ));
+ if ($fellowsresult != 0) {
+ $fellowsupload++;
+ }
+ }
+ }
+ }
+ }
+ if(!$result) {
+ drupal_set_message("Something went wrong, please try again.", "error");
+ } else {
+ drupal_set_message("Testimonial added successfully", "status");
+ }
+ }
+
+function fellowship_testimonials_edit_all($testimonial_id=0) {
+
+ $page_content = "";
+
+ if($testimonial_id){
+
+ $fellowship_testimonials_add_form = drupal_get_form("fellowship_testimonials_add_form", $testimonial_id);
+ $page_content .= drupal_render($fellowship_testimonials_add_form);
+ } else {
+ /*$query = "
+ SELECT * FROM fellowship_testimonials
+ ORDER BY time DESC
+ ";
+ $result = db_query($query);*/
+ $speakerquery = db_select('fellows');
+ $speakerquery->fields('fellows');
+
+ $speakerresult = $speakerquery->execute();
+ while($speakerrow = $speakerresult->fetchObject()){
+ $query = db_select('fellowship_testimonials');
+ $query->fields('fellowship_testimonials');
+ // $query->orderBy('time', 'DESC');
+ $query->condition('id', $speakerrow->t_id);
+ $result = $query->execute();
+
+ $headers = array(
+ "Name", "University", "Action"
+ );
+ $rows = array();
+ while($row = $result->fetchObject()) {
+ $item = array(
+ $speakerrow->name,
+ $speakerrow->institute,
+ l("Edit", "fellowship_testimonials/edit/{$row->id}") ." | ".
+ l("Delete", "fellowship_testimonials/delete/{$row->id}")
+ );
+ array_push($rows, $item);
+ }
+ }
+ //$page_content .= theme("table", $headers, $rows);
+ $page_content .= theme('table', array('header' => $headers, 'rows' => $rows ));
+ }
+ return $page_content;
+ }