$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 {
         $mine_only = false;
     }
     //Return result to jTable
     $recs = Project::getInstance()->getStudentsAndProposalCountByCriteria($group, $_GET["jtSorting"], $_GET["jtStartIndex"], $_GET["jtPageSize"], $mine_only);
     $cnt = Project::getInstance()->getStudentsAndProposalCountByCriteriaRowCount($group, $mine_only);
Example #2
0
        }
        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'];
}
         $student = $GLOBALS['user']->uid;
         $organisation = null;
         if (isset($_POST['organisation']) && $_POST['organisation']) {
             $organisation = $_POST['organisation'];
         }
         $cnt = Proposal::getInstance()->getProposalsRowCountBySearchCriteria($student, null, $organisation, null, true);
         $recs = $cnt ? Proposal::getInstance()->getProposalsBySearchCriteria($student, null, $organisation, null, $_GET["jtSorting"], $_GET["jtStartIndex"], $_GET["jtPageSize"], true) : array();
         jsonGoodResultJT($recs, $cnt);
     } catch (Exception $ex) {
         //Return error message
         jsonBadResultJT($ex->getMessage());
     }
     break;
 case 'accept_proposal_offer':
     if (!Users::isStudent()) {
         echo jsonBadResult(t('Only students can accept project offers'));
         return;
     }
     $student = $GLOBALS['user']->uid;
     if (Agreement::getInstance()->getSingleStudentsAgreement()) {
         echo t('You have already accepted a project offer');
         return;
     }
     if (isset($_POST['proposal_id']) && $_POST['proposal_id'] && isset($_POST['project_id']) && $_POST['project_id']) {
         if (Groups::isOwner('proposal', $_POST['proposal_id'])) {
             $proposal_id = $_POST['proposal_id'];
             module_load_include('inc', 'vals_soc', 'includes/module/vals_soc.mail');
             // get ALL my proposals
             $all_my_proposals = Proposal::getInstance()->getProposalsBySearchCriteria($student, '', '', '', '', 0, 1000);
             foreach ($all_my_proposals as $my_proposal) {
                 if ($my_proposal->proposal_id == $proposal_id) {
                $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'];
}
        }
        break;
    case 'save':
        $type = altSubValue($_POST, 'type', '');
        $id = altSubValue($_POST, 'id', '');
        $show_action = altSubValue($_POST, 'show_action', '');
        //TODO do some checks here
        if (!isValidOrganisationType($type)) {
            //&& ($type !== _PROJECT_OBJ)
            $result = NULL;
            drupal_set_message(tt('This is not a valid type: %s', $type), 'error');
            echo jsonBadResult();
            return;
        }
        $properties = Groups::filterPostByType($type, $_POST);
        if (!$id) {
            $new = true;
            $result = $type == _STUDENT_GROUP ? Groups::addStudentGroup($properties) : ($type == _PROJECT_OBJ ? Project::getInstance()->addProject($properties) : Groups::addGroup($properties, $type));
        } else {
            $new = false;
            $result = Groups::changeGroup($type, $properties, $id);
        }
        if ($result) {
            echo json_encode(array('result' => TRUE, 'id' => $id, 'type' => $type, 'new_tab' => !$id ? $result : 0, 'show_action' => $show_action, 'msg' => ($id ? tt('You succesfully changed the data of your %1$s', t_type($type)) : tt('You succesfully added your %1$s', t_type($type))) . (_DEBUG ? showDrupalMessages() : '')));
        } else {
            echo jsonBadResult();
        }
        break;
    default:
        echo "No such action: " . $_GET['action'];
}