-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mark
committed
Jun 9, 2017
0 parents
commit 9be4076
Showing
15 changed files
with
1,474 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.page-node-add-crew-connect-application h1{ | ||
Display: none; | ||
} | ||
|
||
.page-node-delete.node-type-crew-connect-request h1{ | ||
Display: none; | ||
} | ||
|
||
.page-node-delete.node-type-crew-connect-request .tabs-primary { | ||
Display: none; | ||
} | ||
|
||
.page-node-delete.node-type-crew-connect-application h1{ | ||
Display: none; | ||
} | ||
|
||
.page-node-delete.node-type-crew-connect-application .tabs-primary { | ||
Display: none; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name = "CMA Crew Connect" | ||
description = "Provides helper files for managing crew connections. Relies on the Crew Request and Crew Application content types" | ||
|
||
files[] = includes/computed_field.inc | ||
files[] = includes/civicrm.inc | ||
files[] = includes/form_alter.inc | ||
files[] = includes/form.inc | ||
files[] = includes/menu.inc | ||
files[] = includes/misc.inc | ||
files[] = includes/page.inc | ||
files[] = includes/phpfields.inc | ||
files[] = includes/postsave.inc | ||
files[] = includes/presave.inc | ||
files[] = includes/validate.inc | ||
files[] = includes/view_util.inc | ||
|
||
|
||
package = "Community Media Advanced" | ||
version = "7.x-1.x" | ||
core = "7.x" | ||
project = "cm_crew_connect" | ||
project_status_url = https://github.com/cm-advanced/cm_crew_connect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* @file | ||
* Implementes the CM Crew Connect Module | ||
*/ | ||
|
||
/** | ||
* Implements hook_menu() | ||
*/ | ||
function cm_crew_connect_menu() { | ||
$items = array(); | ||
|
||
$items['user/%/cm_crew_connect'] = | ||
array( | ||
'title' => 'Crew Connect', | ||
'description' => 'Crew Connect', | ||
'access arguments' => array('access content'), | ||
'page callback' => 'cm_crew_connect_page', | ||
'page arguments' => array(1), | ||
'type' => MENU_LOCAL_TASK, | ||
); | ||
|
||
$items['crew-connect/requests-search'] = | ||
array( | ||
'title' => 'Crew Connect Search', | ||
'description' => 'Crew Connect Search', | ||
'access arguments' => array('access content'), | ||
'page callback' => 'cm_crew_connect_search_page', | ||
'page arguments' => array(1), | ||
'type' => MENU_CALLBACK, | ||
); | ||
|
||
return $items; | ||
} | ||
|
||
/** | ||
* Implements hook_init(). | ||
* | ||
* Loads all the include files | ||
*/ | ||
function cm_crew_connect_init() { | ||
drupal_add_css(drupal_get_path('module', 'cm_crew_connect') . | ||
'/cm_crew_connect.css'); | ||
|
||
module_load_include('inc', 'cm_crew_connect', 'includes/computed_field'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/civicrm'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/form_alter'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/form'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/menu'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/misc'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/page'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/phpfields'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/postsave'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/presave'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/validate'); | ||
module_load_include('inc', 'cm_crew_connect', 'includes/view_util'); | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<? | ||
/** | ||
* Get the the display name of the contact of the contact | ||
*/ | ||
function cm_crew_connect_get_display_name($uid) { | ||
|
||
$cid = cm_crew_connect_get_cid($uid); | ||
|
||
if ($cid) { | ||
civicrm_initialize(); | ||
|
||
$result = civicrm_api3('Contact', 'get', array( | ||
'sequential' => 1, | ||
'id' => $cid, | ||
)); | ||
|
||
$display_name = (isset($result) && isset($result['values']) && | ||
isset($result['values'][0])) ? | ||
$result['values'][0]['display_name'] : NULL; | ||
|
||
return $display_name; | ||
} | ||
return ""; | ||
} | ||
|
||
/** | ||
* Get the the public email address of the contact | ||
*/ | ||
function cm_crew_connect_get_public_email($uid) { | ||
|
||
//dpm($uid); | ||
|
||
$cid = cm_crew_connect_get_cid($uid); | ||
|
||
if ($cid) { | ||
$result = civicrm_api3('Email', 'get', array( | ||
'sequential' => 1, | ||
'contact_id' => $cid, | ||
'location_type_id' => 6, | ||
)); | ||
|
||
//dpm($result, 'email'); | ||
|
||
$public_email = (isset($result) && isset($result['values'][0])) ? | ||
$result['values'][0]['email'] : NULL; | ||
return $public_email; | ||
} | ||
return ""; | ||
|
||
} | ||
|
||
/** | ||
* Get the cid for a givin Drupal uid | ||
*/ | ||
function cm_crew_connect_get_cid($uid) { | ||
civicrm_initialize(); | ||
$result = civicrm_api3('UFMatch', 'get', array( | ||
'sequential' => 1, | ||
'uf_id' => $uid, | ||
)); | ||
|
||
$cid = (isset($result) && isset($result['values']) && | ||
isset($result['values'][0])) ? $result['values'][0]['contact_id'] : | ||
NULL; | ||
|
||
return $cid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<? | ||
/* | ||
function computed_field_field_civicrm_event_link_display($field, $entity_field_item, $entity_lang, $langcode) { | ||
dsm($field, 'field'); | ||
dsm($entity_field_item, 'item'); | ||
dsm($entity, 'ent'); | ||
return l('hi mom', ''); | ||
}*/ | ||
|
||
function computed_field_field_civicrm_event_link_compute(&$entity_field, | ||
$entity_type, | ||
$entity, $field, | ||
$instance, | ||
$langcode, $items) { | ||
|
||
//SEE IF WE HAVE A CIVI EVENT | ||
$event_id = | ||
cm_crew_connect_get_single_field_value($entity, | ||
'field_crew_civievent_id'); | ||
$link = ''; | ||
if ($event_id) { | ||
$deleting_application = $_SESSION['cm_crew_connect_deleting_application']; | ||
|
||
$_SESSION['cm_crew_connect_deleting_application'] = FALSE; | ||
if (!$deleting_application) { | ||
|
||
//find applicant node | ||
$view = views_get_view('crew_connect_application_for_request'); | ||
$view->set_arguments(array($entity->nid)); | ||
$view->execute(); | ||
|
||
$results = $view->result;; | ||
|
||
if ($results) { | ||
$result = array_pop($results); | ||
$nid = $result->nid; | ||
} | ||
else { | ||
$nid = $_SESSION['cm_crew_connect_request_nid']; | ||
} | ||
$_SESSION['cm_crew_connect_request_nid'] = NULL; | ||
|
||
if ($nid) { | ||
$applicant = node_load($nid); | ||
|
||
if ($applicant) { | ||
$participant_id = | ||
cm_crew_connect_get_single_field_value($applicant, | ||
'field_app_participant_id'); | ||
|
||
} | ||
} | ||
} | ||
|
||
//if it exists, find particpant id and contact id, and build link | ||
if ($participant_id) { | ||
$result = civicrm_api3('Participant', 'get', array( | ||
'sequential' => 1, | ||
'id' => $participant_id, | ||
)); | ||
if ($result && isset($result['values']) && $result['values'] && | ||
isset($result['values'][0]) && $result['values'][0]) { | ||
$contact_id = $result['values'][0]['contact_id']; | ||
$query = array( | ||
'reset' => 1, | ||
'action' => 'update', | ||
'id' => $participant_id, | ||
'cid' => $contact_id, | ||
); | ||
|
||
//contact/view/participant?reset=1&action=update&id=44639&cid=24432&context=search&compContext=participant&key=df0c891182920977f805756b43ddd75a_158 [^] | ||
|
||
$link = l(t("Manage CiviCRM Event"), | ||
'civicrm/contact/view/participant',array('query'=>$query)); | ||
} | ||
|
||
|
||
} | ||
//link will be as it was | ||
else { | ||
$query = array('id'=>$event_id, | ||
'action'=>'update', | ||
'reset'=>1); | ||
|
||
$link = l(t("Manage CiviCRM Event"), | ||
'civicrm/event/manage/settings', array('query'=>$query)); | ||
} | ||
|
||
|
||
|
||
|
||
} | ||
$entity_field[0]['value'] = $link; | ||
return $link; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<? | ||
/** | ||
* | ||
*/ | ||
function cm_crew_connect_project_alert_form($form, &$form_state, | ||
$project_nid) { | ||
$form = array(); | ||
|
||
$needs = array('yes'=>'Yes', 'no'=>'No', 'not_applicable'=>'N/A'); | ||
|
||
$form['cm_crew_connect_project_nid'] = | ||
array( | ||
'#type' => 'hidden', | ||
'#value'=> $project_nid, | ||
); | ||
|
||
$project = node_load($project_nid); | ||
$title = $project ? $project->title : ""; | ||
|
||
$label = t("Do you need a Crew For !title?", array('!title'=>$title)); | ||
|
||
$form['cm_crew_connect_project_needs'] = | ||
array( | ||
'#type' => 'select', | ||
'#options'=> $needs, | ||
'#required' => TRUE, | ||
'#prefix'=> "<table><tr><td>$label</td><td>", | ||
'#suffix'=>"</td>", | ||
); | ||
|
||
$form['cm_crew_connect_project_alert_submit'] = | ||
array( | ||
'#type' => 'submit', | ||
'#value'=> t("Update"), | ||
'#prefix' => "<td>", | ||
'#suffix' => "</tr></table>", | ||
); | ||
return $form; | ||
} | ||
|
||
function cm_crew_connect_project_alert_form_submit($form, &$form_state) { | ||
$project_nid = $form['cm_crew_connect_project_nid']['#value']; | ||
|
||
$needed = $form['cm_crew_connect_project_needs']['#value']; | ||
|
||
$project = node_load($project_nid); | ||
$project->field_is_crew_needed[LANGUAGE_NONE][0]['value'] = $needed; | ||
node_save($project); | ||
|
||
//FIXME ADD AS A REAL FORM VARIABLE | ||
$dashboard = variable_get('cm_crew_connect_dashboard_page', 'user'); | ||
$dashboard .= $project ? "/".$project->uid : ""; | ||
$dashboard_query_args = array(); | ||
|
||
$submit_request_page = "node/add/crew-connect-request"; | ||
$submit_query_args = array('field_crew_project_id'=>$project->nid, | ||
'destination'=>$dashboard); | ||
|
||
switch ($needed) { | ||
case 'yes': | ||
$destination = $submit_request_page; | ||
$query_args = $submit_query_args; | ||
break; | ||
case 'no': | ||
$destination = $dashboard; | ||
$query_args = $dashboard_query_args; | ||
break; | ||
case 'not_applicable': | ||
$destination = $dashboard; | ||
$query_args = $dashboard_query_args; | ||
break; | ||
} | ||
drupal_goto($destination, array('query'=>$query_args)); | ||
return; | ||
} |
Oops, something went wrong.