Last active
October 18, 2015 09:35
-
-
Save shardiwal/9d37dbd703fd15088b0a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function volunteer_area_of_interest_validate($form, &$form_state) { | |
// eCare vms new class object. | |
global $user; | |
$vms = variable_get('vms'); | |
$open_area_of_interest = $vms->getVoluntreeOpenTaskInterest($user->uid); | |
$values = $form_state['values']; | |
$account = user_load($user->uid); | |
$profile = profile2_load_by_user($account, 'volunteer_profile'); | |
function default_vala($val) { | |
return $val['nid']; | |
} | |
$default_Selected_areaofInterest = array_map('default_vala', $profile->field_area_of_interest['und']); | |
$open_interest = array(); | |
$user_area_open_interest = array(); | |
foreach ($open_area_of_interest as $k => $v) { | |
$open_interest[$v] = 1; | |
if (in_array($v, $default_Selected_areaofInterest) ) { | |
array_push( $user_area_open_interest, $v); | |
} | |
} | |
$new_values = $values['volunteer_area_of_interest']; | |
foreach ($values['volunteer_area_of_interest'] as $value) { | |
if ( array_key_exists($value, $open_interest) ) { | |
array_push( $new_values, $value); | |
} | |
} | |
$new_values = array_unique($new_values); | |
foreach ($user_area_open_interest as $latesd) { | |
if (!array_key_exists($latesd, $new_values )) { | |
array_push( $new_values, $latesd); | |
} | |
} | |
$new_values = array_unique($new_values); | |
$form_state['values']['volunteer_area_of_interest'] = $new_values; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment