Пример #1
0
 /**
  * The student inserts this initially once he/she accepts a project offer
  * @param unknown $props
  * @param unknown $proposal_id
  * @return boolean|unknown
  */
 static function insertAgreement($props)
 {
     if (!$props) {
         drupal_set_message(t('Insert requested with empty (filtered) data set'), 'error');
         return false;
     }
     if (!isset($props['proposal_id'])) {
         drupal_set_message(t('Insert requested with no proposal set'), 'error');
         return false;
     }
     global $user;
     $txn = db_transaction();
     try {
         $proposal = objectToArray(Proposal::getInstance()->getProposalById($props['proposal_id']));
         $project = objectToArray(Project::getProjectById($proposal['pid']));
         if (!isset($props['student_id'])) {
             $props['student_id'] = $user->uid;
         }
         if (!isset($props['supervisor_id'])) {
             $props['supervisor_id'] = $proposal['supervisor_id'];
         }
         if (!isset($props['mentor_id'])) {
             $props['mentor_id'] = $project['mentor_id'];
         }
         $props['project_id'] = $proposal['pid'];
         if (!isset($props['description'])) {
             $props['description'] = '';
         }
         if (!isset($props['student_signed'])) {
             $props['student_signed'] = 0;
         }
         if (!isset($props['supervisor_signed'])) {
             $props['supervisor_signed'] = 0;
         }
         if (!isset($props['mentor_signed'])) {
             $props['mentor_signed'] = 0;
         }
         /*
         if (! testInput($props, array('owner_id', 'org_id', 'inst_id', 'supervisor_id','pid', 'title'))){
         	return FALSE;
         }
         */
         try {
             $id = db_insert(tableName(_AGREEMENT_OBJ))->fields($props)->execute();
         } catch (Exception $e) {
             drupal_set_message($e->getMessage(), 'error');
         }
         if ($id) {
             drupal_set_message(t('You have created your agreement: you can continue editing it later.'));
             return $id;
         } else {
             drupal_set_message(t('We could not add your agreement. ') . (_DEBUG ? '<br/>' . getDrupalMessages() : ""), 'error');
         }
         return $result;
     } catch (Exception $ex) {
         $txn->rollback();
         drupal_set_message(t('We could not add your agreement.') . (_DEBUG ? $ex->__toString() : ''), 'error');
     }
     return FALSE;
 }
Пример #2
0
function showMyProposals($proposals, $current_tab_propid = 0)
{
    $nr = 0;
    $apply_projects = $apply_projects = vals_soc_access_check('dashboard/projects/apply') ? 1 : 0;
    $rate_projects = Users::isSuperVisor();
    $tab_id_prefix = "proposal_page";
    $data = array();
    $activating_tabs = array();
    $current_tab = 1;
    $current_tab_id = "{$tab_id_prefix}{$current_tab}";
    $current_tab_content = '';
    foreach ($proposals as $proposal) {
        $nr++;
        if (!$current_tab_propid && $nr == 1 || $proposal->proposal_id == $current_tab_propid) {
            //$id = $proposal->pid;
            $current_tab = $nr;
            $current_tab_id = "{$tab_id_prefix}{$current_tab}";
            $current_tab_content = renderProposal(Proposal::getInstance()->getProposalById($proposal->proposal_id, TRUE), $current_tab_id, 'myproposal_page');
        }
        $activating_tabs[] = "'{$tab_id_prefix}{$nr}'";
        $data[] = array(0, $proposal->title, 'view', _PROPOSAL_OBJ, $proposal->proposal_id);
    }
    echo renderTabs($nr, 'Proposal', $tab_id_prefix, _PROPOSAL_OBJ, $data, 0, TRUE, $current_tab_content, $current_tab, _PROPOSAL_OBJ);
    ?>
	<script type="text/javascript">
		window.view_settings = {};
		window.view_settings.apply_projects = <?php 
    echo $apply_projects ? 1 : 0;
    ?>
;
		window.view_settings.rate_projects  = <?php 
    echo $rate_projects ? 1 : 0;
    ?>
;
		activatetabs('tab_', [<?php 
    echo implode(', ', $activating_tabs);
    ?>
], '<?php 
    echo $current_tab_id;
    ?>
');
	</script>
<?php 
}
Пример #3
0
                 Proposal::getInstance()->updateProposal($props, $single_proposal_for_accepted_project->proposal_id);
                 //uncomment to set this after testing **************
             }
         }
     }
 } else {
     // this.proposal =!= accepted proposal // any other proposals by this student not accepted
     if ($my_proposal->state != 'rejected') {
         $props = array();
         $props['state'] = 'archived';
         // set these to archived in case we need to separate later between auto rejected & manually rejected
         Proposal::getInstance()->updateProposal($props, $my_proposal->proposal_id);
         //uncomment to set this after testing **************
     }
     $project_id = $my_proposal->pid;
     $all_proposals_for_this_project = Proposal::getInstance()->getProposalsPerProject($project_id, '', true);
     // TODO - may need to set details flag here
     foreach ($all_proposals_for_this_project as $single_proposal_for_unaccepted_project) {
         if ($single_proposal_for_unaccepted_project->owner_id == $student && $single_proposal_for_unaccepted_project->proposal_id == $single_proposal_for_unaccepted_project->pr_proposal_id) {
             $update_props = array();
             $update_props['proposal_id'] = NULL;
             if ($single_proposal_for_unaccepted_project->selected == "0") {
                 //(means its an interim)
                 // email mentor only - withdrawn PREFERRED INTERIM
                 notify_all_of_project_offer_rejection($single_proposal_for_unaccepted_project, $proposal_id, true);
             } else {
                 // (means its an offer)
                 $update_props['selected'] = 0;
                 // email (mentor) - rejected OFFER - project is therefore reopened and he should choose another proposal
                 // email this proposal (student & supervisor) to say that the project has reopended and the mentor can choose another, possibly theirs
                 notify_all_of_project_offer_rejection($single_proposal_for_unaccepted_project, $proposal_id, false);
Пример #4
0
 $entity_id = altSubValue($_POST, 'entity_id', '');
 $target = altSubValue($_POST, 'target', '');
 $properties = ThreadedComments::getInstance()->filterPostLite(ThreadedComments::getInstance()->getKeylessFields(), $_POST);
 $properties['author'] = $user->uid;
 $result = ThreadedComments::getInstance()->addComment($properties);
 $new = false;
 if ($result) {
     // get all the threads
     $thread_details = ThreadedComments::getInstance()->getThreadsForEntity($entity_id, $type);
     // decide which entity it is and get the owner details & description etc
     if ($type == _PROJECT_OBJ) {
         $entity_details = Project::getInstance()->getProjectById($entity_id, true);
         $fire_emails = true;
     } else {
         if ($type == _PROPOSAL_OBJ) {
             $entity_details = objectToArray(Proposal::getInstance()->getProposalById($entity_id, true));
             $fire_emails = true;
         } else {
             // for now nothing - only have projects & proposal comments
             $fire_emails = false;
         }
     }
     // send emails out...
     if ($fire_emails) {
         $properties['name'] = $user->name;
         $properties['mail'] = $user->mail;
         module_load_include('inc', 'vals_soc', 'includes/module/vals_soc.mail');
         notify_all_of_new_comment($entity_details, $thread_details, $properties);
     }
     echo json_encode(array('result' => TRUE, 'id' => $result, 'type' => $type, 'entity_id' => $entity_id, 'msg' => tt('You succesfully added a comment to this %1$s', t_type($type)) . (_DEBUG ? showDrupalMessages() : '')));
 } else {