add form to be able to configure which memberships a user can edit themselves

master
Marek Isalski 6 years ago
parent 0ac90fb002
commit e3375f0159

@ -0,0 +1,52 @@
<?php
function fulcrm_membership_admin_form_submit( $form, &$form_state ) {
variable_set( 'fulcrm_membership_self_set_membership_ids', $form_state[ 'values' ][ 'self_set_membership_ids' ] );
drupal_set_message( t('Settings saved.'), 'status' );
}
function fulcrm_membership_admin_form( $form, &$form_state ) {
global $is_https;
$form[ 'title' ] = array( '#type' => 'item',
'#title' => 'fulcrm Membership Integration Settings',
'#description' => '',
);
$products = array( '' => '-- disabled --' );
$membership_data = fulcrm_apiv2_GET( 'membership/',
$query = array( 'page_size' => 1000,
) );
if ( $membership_data[ 'success' ] ) {
if ( $membership_data[ 'data' ][ 'results' ] ) {
foreach ( $membership_data[ 'data' ][ 'results' ] as $membership ) {
$memberships[ $membership[ 'id' ] ] = $membership[ 'name' ];
if ( $membership[ 'archived' ] )
$memberships[ $membership[ 'id' ] ] .= ' (archived)';
}
}
} else {
$memberships[ 'ERROR' ] = '** ERROR fetching memberships from fulcrm **';
}
$form[ 'self_set_membership_ids' ] = array( '#type' => 'checkboxes',
'#title' => 'Self-Set Memberships',
'#options' => $memberships,
'#default_value' => variable_get( 'fulcrm_membership_self_set_membership_ids', array() ),
'#description' => 'Which memberships can users add/remove for themselves?',
);
$form[ 'actions' ] = array( '#type' => 'actions' );
$form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
'#value' => t('Save'),
'#submit' => array( 'fulcrm_membership_admin_form_submit' ),
);
return $form;
}
function fulcrm_membership_admin() {
return drupal_get_form( 'fulcrm_membership_admin_form' );
}

@ -1,7 +1,23 @@
<?php /* -*- php -*- */
function fulcrm_membership_permission() {
return array( 'administer fulcrm membership' => array( 'title' => t('Administer fulcrm membership'),
'description' => t('Perform main installation/administration tasks for fulcrm membership integration.'),
),
);
}
function fulcrm_membership_menu() {
$items = array();
$items[ 'admin/config/services/fulcrm/membership' ] = array( 'page callback' => 'fulcrm_membership_admin',
'file' => 'fulcrm_membership.admin.inc',
'title' => 'fulcrm Membership',
'description' => 'Configure Membership integration with fulcrm.org.',
'access callback' => 'user_access',
'access arguments' => array('administer fulcrm membership'),
);
$items[ 'user/fulcrm/optin/%' ] = array( 'page callback' => 'fulcrm_membership_optin',
'page arguments' => array(3),
'title' => 'Subscription Opt-In',

Loading…
Cancel
Save