$jTableResult['Records'] = Institutes::getInstance()->getInstitutesBySearchCriteria($instName, $_GET["jtSorting"], $_GET["jtStartIndex"], $_GET["jtPageSize"]); } print json_encode($jTableResult); } catch (Exception $ex) { //Return error message $jTableResult = array(); $jTableResult['Result'] = "ERROR"; $jTableResult['Message'] = $ex->getMessage(); print json_encode($jTableResult); } break; case 'detail': if (isset($_GET['instid'])) { try { $institutions = Institutes::getInstance()->getInstituteById($_GET['instid']); echo $institutions ? jsonGoodResult($institutions[0]) : jsonBadResult(t('Could not find the institution')); } catch (Exception $e) { echo jsonBadResult($e->getMessage()); } } else { echo jsonBadResult(t("No institution identifier submitted!")); } break; case 'list_search_proposal_count_student': $group = null; if (isset($_POST['group']) && $_POST['group']) { $group = $_POST['group']; } if (isset($_GET['mine_only']) && $_GET['mine_only']) { $mine_only = true; } else {
} unset($_POST); $form = drupal_get_form("vals_soc_project_form", $obj, $target); if ($originalPath) { $form['#action'] = url($originalPath); } // Process the submit button which uses ajax //$form['submit'] = ajax_pre_render_element($form['submit']); // Build renderable array // $build = array( // 'form' => $form, // '#attached' => $form['submit']['#attached'], // This will attach all needed JS behaviors onto the page // ); renderForm($form, $target); break; case 'delete': $type = altSubValue($_POST, 'type', ''); $id = altSubValue($_POST, 'id', ''); if (!isValidOrganisationType($type)) { echo jsonBadResult(t('There is no such type we can delete')); } elseif (count(Proposal::getProposalsPerProject($id))) { echo jsonBadResult(t('You cannot delte the project; there are already students working on a proposal for this project. You can still edit it though.')); } else { $result = Groups::removeGroup($type, $id); ThreadedComments::getInstance()->removethreadsForEntity($id, $type); echo $result ? jsonGoodResult(true, '', array('extra' => $mine ? array('mine' => 1) : '')) : jsonBadResult(); } break; default: echo "No such action: " . $_GET['action']; }
case 'reject_form': $target = getRequestVar('target'); renderForm(drupal_get_form('vals_soc_reject_form', getRequestVar('id', 0), $target), $target); break; case 'reject': $id = getRequestVar('id', 0, 'post'); $reason = getRequestVar('reason', '', 'post'); $rationale = getRequestVar('rationale', '', 'post'); try { $good_result = t('You rejected this proposal') . '<script>hideOtherDivsAfterProposalReject(' . $id . ')</script>'; $result = Proposal::getInstance()->rejectProposal($id, $reason, $rationale); if ($result) { $props = Proposal::getInstance()->getProposalById($id, true); module_load_include('inc', 'vals_soc', 'includes/module/vals_soc.mail'); notify_student_and_supervisor_of_proposal_rejection_by_mentor($props); echo jsonGoodResult(true, $good_result); } else { echo jsonBadResult(t('You tried to reject this proposal, but it failed')); } } catch (Exception $e) { jsonBadResult(t('Something went wrong in the database ' . (_DEBUG ? $e->getMessage() : ''))); } break; case 'view': $proposal_id = getRequestVar('id', 0, 'post'); $target = getRequestVar('target', 'admin_container', 'post'); if ($proposal_id) { //$is_modal = ($target !== 'our_content'); //this is the case where the result is bad and we show an error msg //$container = $is_modal ? 'modal-content' : 'our_content'; //$before = 'toc' ;
$organisations = Organisations::getInstance()->getOrganisationById($org_id); $jTableResult['TotalRecordCount'] = count($organisations); $jTableResult['Records'] = $organisations; } else { $jTableResult['TotalRecordCount'] = Organisations::getInstance()->getOrganisationsRowCountBySearchCriteria($orgName); $jTableResult['Records'] = Organisations::getInstance()->getOrganisationsBySearchCriteria($orgName, $_GET["jtSorting"], $_GET["jtStartIndex"], $_GET["jtPageSize"]); } print json_encode($jTableResult); } catch (Exception $ex) { //Return error message $jTableResult = array(); $jTableResult['Result'] = "ERROR"; $jTableResult['Message'] = $ex->getMessage(); print json_encode($jTableResult); } break; case 'organisation_detail': if (isset($_GET['orgid'])) { try { $organisations = Organisations::getInstance()->getOrganisationById($_GET['orgid']); echo $organisations ? jsonGoodResult($organisations[0]) : jsonBadResult(t('Could not find the organisation')); } catch (Exception $e) { echo jsonBadResult($e->getMessage()); } } else { echo jsonBadResult(t("No organisation identifier submitted!")); } break; default: echo "No such action: " . $_GET['action']; }
} else { echo "<div id='msg_{$target}'></div>"; echo renderOrganisation($type, $organisation, null, $target, $buttons); } break; case 'delete': $type = altSubValue($_POST, 'type', ''); $id = altSubValue($_POST, 'id', ''); $target = altSubValue($_POST, 'target', ''); //perhaps the type can be derived from the current url (based on http-referrer system var) extract(deriveTypeAndAction(empty($type)), EXTR_OVERWRITE); if (!isValidOrganisationType($type)) { echo jsonBadResult(t('There is no such type we can delete')); } else { $result = Groups::removeGroup($type, $id); echo $result ? jsonGoodResult() : jsonBadResult('', array('target' => $target)); } break; case 'send_invite_email': module_load_include('inc', 'vals_soc', 'includes/module/vals_soc.mail'); $type = altSubValue($_POST, 'type', ''); $email = altSubValue($_POST, 'contact_email', ''); $subject = altSubValue($_POST, 'subject', ''); $body = altSubValue($_POST, 'description', ''); $items = array(array('key' => 'vals_soc_invite_new_user', 'to' => $email, 'from' => NULL, 'subject' => $subject, 'body' => $body)); try { vals_soc_send_emails_cron($items); //$result = vals_soc_send_emails_now($items); $result = TRUE; $msg = t('Email successfully sent') . (_DEBUG ? showDrupalMessages() : ''); } catch (Exception $err) {