allow creation of pre-archived memberships for double opt-in
This commit is contained in:
parent
91e81db30b
commit
26af0d7659
@ -211,7 +211,7 @@ function fulcrm_membership_cease_person2membership( $p2m, $now = NULL ) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fulcrm_membership_begin_person2membership( $person_id, $membership_id, $now = NULL ) {
|
function fulcrm_membership_begin_person2membership( $person_id, $membership_id, $now = NULL, $archived = false ) {
|
||||||
if ( is_null( $now ) )
|
if ( is_null( $now ) )
|
||||||
$now = new DateTime();
|
$now = new DateTime();
|
||||||
$tz = new DateTimeZone('UTC');
|
$tz = new DateTimeZone('UTC');
|
||||||
@ -220,19 +220,22 @@ function fulcrm_membership_begin_person2membership( $person_id, $membership_id,
|
|||||||
|
|
||||||
$timescale_data = fulcrm_apiv2_POST( 'timescale/', $data = array( 'start' => $start ) );
|
$timescale_data = fulcrm_apiv2_POST( 'timescale/', $data = array( 'start' => $start ) );
|
||||||
if ( $timescale_data[ 'success' ] ) {
|
if ( $timescale_data[ 'success' ] ) {
|
||||||
$api_data = fulcrm_apiv2_POST( 'person2membership/', $data = array( 'person' => '/api/v2/person/' . $person_id . '/',
|
$data = array( 'person' => '/api/v2/person/' . $person_id . '/',
|
||||||
'membership' => '/api/v2/membership/' . $membership_id . '/',
|
'membership' => '/api/v2/membership/' . $membership_id . '/',
|
||||||
'timescale' => $timescale_data[ 'data' ][ 'url' ],
|
'timescale' => $timescale_data[ 'data' ][ 'url' ],
|
||||||
) );
|
);
|
||||||
|
if ( $archived )
|
||||||
|
$data[ 'archived' ] = $start;
|
||||||
|
|
||||||
|
$api_data = fulcrm_apiv2_POST( 'person2membership/', $data = $data );
|
||||||
if ( $api_data[ 'success' ] ) {
|
if ( $api_data[ 'success' ] ) {
|
||||||
return true;
|
return $api_data[ 'headers' ][ 'Location' ];
|
||||||
} else {
|
} else {
|
||||||
watchdog('fulcrm_membership', 'could not post person2membership to create membership %mid for %pid', array('%mid'=>$membership_id,'%pid'=>$person_id), WATCHDOG_ERROR);
|
watchdog('fulcrm_membership', 'could not post person2membership to create membership %mid for %pid', array('%mid'=>$membership_id,'%pid'=>$person_id), WATCHDOG_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
watchdog('fulcrm_membership', 'could not post timescale to create membership %mid for %pid', array('%mid'=>$membership_id,'%pid'=>$person_id), WATCHDOG_ERROR);
|
watchdog('fulcrm_membership', 'could not post timescale to create membership %mid for %pid', array('%mid'=>$membership_id,'%pid'=>$person_id), WATCHDOG_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fulcrm_membership_self_set_form_submit( $form, &$form_state ) {
|
function fulcrm_membership_self_set_form_submit( $form, &$form_state ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user