'Affiliate settings',
'description' => 'Affiliate settings',
'page callback' => 'drupal_get_form',
'page arguments' => array('affiliate_admin_settings'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
'file' => 'affiliate.admin.inc',
);
$items['affiliate/register'] = array(
'title' => 'Affiliate agreement',
'page callback' => 'affiliate_page',
'page arguments' => array('user selected'),
'access callback' => '_register_access',
'access arguments' => array('create affiliate profile'),
'type' => MENU_CALLBACK,
);
$items['affiliate/show'] = array(
'title' => 'Display Affiliate agreement',
'page callback' => 'affiliate_show',
'page arguments' => array(''),
'access callback' => '_show_access',
'access arguments' => array('view any affiliate profile'),
'type' => MENU_CALLBACK,
);
$items['affiliate/show/%'] = array(
'title' => 'Display Affiliate agreement',
'page callback' => 'affiliate_show',
'page arguments' => array(2),
'access callback' => '_show_access',
'access arguments' => array('view own affiliate profile'),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Access callbacks
*/
function _register_access($account) {
global $user;
debug_local("In _register_access()");
if ( $user->uid == 1 ) {
return TRUE;
}
$roles = $user->roles;
// allow only anonymous or authenticated user access
$count = count(array_diff($roles,array('authenticated user','anonymous user')));
if ( $count > 0 ) {
debug_local("count of roles: $count");
return FALSE;
}
return TRUE;
}
function _show_access($account) {
return TRUE;
}
/**
* Menu callback.
* Called when user goes to affiliate/register
*/
function affiliate_page($arg = '') {
debug_local("In affiliate_page()");
global $user;
require_once(drupal_get_path('module', 'profile') .'/profile.module');
if ($user->uid > 0 ) { // user is logged in
$count = db_result(db_query('SELECT COUNT(*) FROM {affiliate} WHERE uid = %d',$user->uid));
if ($count) { // the user has already registered as affiliate
return '
You have already submitted an application. If this request is for another service please log out and register another account.
';
}
if ($arg == 'new') {
if( preg_match("/Affiliate/",$user->profile_servreq) ) {
$output = drupal_get_form('affiliate_form');
return $output;
}
else {
drupal_goto('/', NULL, NULL);
}
}
else {
$output = drupal_get_form('affiliate_form');
return $output;
}
}
else {
$output = '
Please ' . l('Create an account','user/register') . ' before filling out the Affiliate application.
';
return $output;
}
}
/**
* Define a form.
*/
function affiliate_form($form_id, $form_state = NULL) {
global $user;
// dvr($user);
debug_local("In affiliate_form()\n");
$form['#cache'] = TRUE;
$form['#attributes'] = array(
'enctype' => "multipart/form-data");
$form['#submit'][] = 'affiliate_form_submit';
$form['#redirect'] = '/';
$form['aff_accept'] = array(
'#type' => 'fieldset',
'#title' => t('Acceptance'),
'#description' => t('Check to accept the conditions stated in the Release and Clearance above.'),
'#required' => TRUE,
);
$form['aff_accept'] ['affiliate_accept'] = array(
'#type' => 'checkbox',
'#title' => t('I accept the conditions.'),
'#description' => t(''),
);
$form['aff_ident'] = array(
'#type' => 'fieldset',
'#title' => t('Affiliate Identification'),
'#description' => t(''),
);
$form['aff_ident'] ['affiliate_type'] = array(
'#type' => 'select',
'#title' => t('Type of Service'),
'#options' => array(
'' => t(''),
'radio reading service' => t('Radio Reading Service'),
'cable system' => t('Cable System'),
'telecommunications entity' => t('Telecommunications Entity'),
'other' => t('Other'),
),
'#description' => t('Please select the type of service you provide.'),
'#required' => TRUE,
);
$form['aff_ident'] ['affiliate_name'] = array(
'#type' => 'textfield',
'#title' => t('Name of Service'),
'#size' => 80,
'#description' => t('Please enter the name of your broadcasting service'),
'#required' => TRUE,
);
$form['aff_ident'] ['affiliate_address'] = array(
'#type' => 'textarea',
'#title' => t('Address of Service'),
'#size' => 80,
'#description' => t('Please enter your mailing address (Unit, Street, City, Country, if applicable)'),
'#required' => TRUE,
);
$form['aff_ident'] ['affiliate_postalcode'] = array(
'#type' => 'textfield',
'#title' => t('Postal Code'),
'#size' => 8,
'#description' => t('Please enter your postal code (ZIP)'),
'#required' => TRUE,
);
$form['aff_ident'] ['affiliate_fax'] = array(
'#type' => 'textfield',
'#title' => t('Fax'),
'#size' => 16,
'#description' => t('Please enter your Fax number (if any)'),
);
$form['aff_ident'] ['affiliate_url'] = array(
'#type' => 'textfield',
'#title' => t('Web-site URL'),
'#size' => 80,
'#default_value' => 'http://',
'#description' => t('Please enter your web-site URL (if any)'),
);
$form['aff_ident'] ['affiliate_logo'] = array(
'#type' => 'image_upload_element',
'#title' => t('Upload your LOGO (Optional)'),
'#size' => 40,
'#description' => '',
);
$form['aff_primary'] = array(
'#type' => 'fieldset',
'#title' => t('Primary Contact Information'),
'#description' => t(''),
);
$form['aff_primary'] ['affiliate_contact_title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#size' => 80,
'#description' => t('Please enter the title of the primary contact'),
'#required' => TRUE,
);
$form['aff_primary'] ['affiliate_contact_name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 80,
'#description' => t('Please enter the full name of the primary contact'),
'#default_value' => $user->profile_fullname,
'#required' => TRUE,
);
$form['aff_primary'] ['affiliate_contact_telephone'] = array(
'#type' => 'textfield',
'#title' => t('Telephone'),
'#size' => 16,
'#description' => t('Please enter primary contact telephone number:'),
'#required' => TRUE,
);
$form['aff_primary'] ['affiliate_contact_extension'] = array(
'#type' => 'textfield',
'#title' => t('Extension'),
'#size' => 16,
'#description' => t('Please enter primary contact extension (if not direct-dial)'),
);
$form['aff_primary'] ['affiliate_contact_email'] = array(
'#type' => 'textfield',
'#title' => t('E-mail'),
'#size' => 80,
'#default_value' => $user->mail,
'#description' => t('Please enter the primary contact e-mail address.'),
'#required' => TRUE,
);
$form['aff_survey'] = array(
'#type' => 'fieldset',
'#title' => t('Usage Survey - Part 1'),
'#description' => 'Please answer all the questions in this part. Enter 0 (zero) if not known or not applicable. Please refer to IAAIS Guidelines for information on determining the answers to this section.',
);
$form['aff_survey'] ['affiliate_survey_individuals'] = array(
'#type' => 'textfield',
'#title' => t('Individuals'),
'#size' => 9,
'#description' => t('How many individuals do you serve?'),
'#required' => TRUE,
);
$form['aff_survey'] ['affiliate_survey_hosp'] = array(
'#type' => 'textfield',
'#title' => t('Hospitals'),
'#size' => 9,
'#description' => t('How many hospitals do you serve?'),
'#required' => TRUE,
);
$form['aff_survey'] ['affiliate_survey_lic_beds'] = array(
'#type' => 'textfield',
'#title' => t('Licensed beds'),
'#size' => 9,
'#description' => t('How many licensed beds do you serve?'),
'#required' => TRUE,
);
$form['aff_survey'] ['affiliate_survey_nurse_homes'] = array(
'#type' => 'textfield',
'#title' => t('Nursing Homes'),
'#size' => 9,
'#description' => t('How many nursing homes do you serve?'),
'#required' => TRUE,
);
$form['aff_survey'] ['affiliate_survey_nurse_or_resid_units'] = array(
'#type' => 'textfield',
'#title' => t('Nursing Homes or Resid. units'),
'#size' => 9,
'#description' => t('How many nursing home or residential home units do you serve?'),
'#required' => TRUE,
);
$form['aff_survey'] ['markup1'] = array(
'#type' => 'markup',
'#value' => '',
);
$form['aff_survey'] ['affiliate_survey_have_website'] = array(
'#type' => 'radios',
'#title' => t('Have Website'),
'#options' => array( t('No'), t('Yes') ),
'#description' => t('Do you have a website?'),
'#default_value' => 0,
'#required' => TRUE,
);
$form['aff_survey'] ['markup2'] = array(
'#type' => 'markup',
'#value' => '
',
);
$form['aff_survey'] ['affiliate_survey_website_users'] = array(
'#type' => 'textfield',
'#title' => t('Website users'),
'#size' => 9,
'#description' => t('How many registered Website users do you serve?'),
);
$form['aff_survey'] ['affiliate_survey_total_users'] = array(
'#type' => 'textfield',
'#title' => t('Total Users'),
'#size' => 9,
'#description' => t('How many total users do you serve?'),
'#required' => TRUE,
);
$form['aff_survey2'] = array(
'#type' => 'fieldset',
'#title' => t('Usage Survey - Part 2'),
'#description' => 'How will you be accessing the GATEWAVE feed? (Check all applicable methods.)',
);
$form['aff_survey2'] ['markup1'] = array(
'#type' => 'markup',
'#value' => '',
);
$form['aff_survey2'] ['affiliate_survey_acc_sat'] = array(
'#type' => 'checkbox',
'#title' => t('Satellite Feed'),
'#description' => t(''),
'#required' => TRUE,
);
$form['aff_survey2'] ['affiliate_survey_acc_stream'] = array(
'#type' => 'checkbox',
'#title' => t('Internet Stream'),
'#description' => t(''),
'#required' => TRUE,
);
$form['aff_survey2'] ['affiliate_survey_acc_ftp'] = array(
'#type' => 'checkbox',
'#title' => t('FTP download'),
'#description' => t(''),
'#required' => TRUE,
);
$form['aff_survey2'] ['markup2'] = array(
'#type' => 'markup',
'#value' => '
How many programs will you be using daily?',
);
$form['aff_survey2'] ['affiliate_survey_prog_daily'] = array(
'#type' => 'textfield',
'#title' => t('Programs'),
'#description' => t(''),
'#size' => 9,
'#required' => TRUE,
);
$form['aff_survey2'] ['markup3'] = array(
'#type' => 'markup',
'#value' => 'Name those, if possible.',
);
$form['aff_survey2'] ['affiliate_survey_prog_names'] = array(
'#type' => 'textarea',
'#description' => t(''),
'#size' => 80,
);
$form['aff_survey2'] ['markup4'] = array(
'#type' => 'markup',
'#value' => 'What changes/additions would you like to see to the schedule?',
);
$form['aff_survey2'] ['affiliate_survey_additions'] = array(
'#type' => 'textarea',
'#description' => t(''),
'#size' => 80,
);
$form['aff_survey2'] ['markup5'] = array(
'#type' => 'markup',
'#value' => 'Any other suggestions?',
);
$form['aff_survey2'] ['affiliate_survey_comments'] = array(
'#type' => 'textarea',
'#description' => t(''),
'#size' => 80,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit')
);
return $form;
}
/**
* Helper function for validation
**/
function aff_validate(&$form_state, $form, $aff_fieldset) {
$message = array( 'aff_chk_numeric' => 'must be numeric',
'aff_chk_telep' => 'must be a valid telephone number (10 digits)', );
$aff_fs = $aff_fieldset['name'];
$aff_fields = $aff_fieldset['fields'];
foreach ($aff_fields as $key => $val_function ) {
$val = $form_state['values'][$key];
if ($val && $val_function) {
if (!$val_function($form_state['values'][$key])) {
form_set_error($key, t('@field field @messg.',
array(
'@field' => $form[$aff_fs][$key]['#title'],
'@messg' => $message[$val_function])));
}
}
}
}
/**
* Check for valid telephone no & reformat
*/
function aff_chk_telep(&$arg) {
$arg_r = $arg;
$arg_r = preg_replace('/[()\-\s]/','',$arg);
if (strlen($arg_r) == 10 ) {
return is_numeric($arg_r);
}
else {
return FALSE;
}
}
function aff_chk_numeric(&$arg) {
$arg_r = preg_replace('/^\s+/','', $arg);
$arg_r = preg_replace('/\s+$/','', $arg_r);
return is_numeric($arg_r);
}
/**
* Validate the form.
*/
function affiliate_form_validate($form_id, &$form_state) {
debug_local("In affiliate_form_validate()");
$form_build_id = 'form_'.$form_id['#post']['form_build_id'];
if ($cached = cache_get($form_build_id, 'cache_form')) {
$form = $cached->data;
}
// Validate Acceptance #1
if ($form_state['values']['affiliate_accept'] == 0) {
form_set_error('user_name', t('The Acceptance box must be checked.'));
}
// Validate Acceptance #2
// fields
$aff_fs = 'aff_ident';
$aff_fieldset = array('name' => 'aff_ident',
'fields' => array(
'affiliate_type' => '',
'affiliate_name' => '',
'affiliate_address' => '',
'affiliate_postalcode',
'affiliate_fax' => 'aff_chk_telep',
'affiliate_url' => '',
));
$val = $form_state['values']['affiliate_url'];
if (!empty($val) && $val != 'http://' && !valid_url($val, TRUE)) {
form_set_error('affiliate_url', t('The URL %val is not valid.',
array('%val' => $val)));
}
aff_validate($form_state, $form, $aff_fieldset);
debug_local("verified #2");
// Validate Acceptance #3
// fields
$aff_fs = 'aff_primary';
$aff_fieldset = array('name' => 'aff_primary',
'fields' => array(
'affiliate_contact_title' => '',
'affiliate_contact_name' => '',
'affiliate_contact_telephone' => 'aff_chk_telep',
'affiliate_contact_extension' => 'aff_chk_numeric',
'affiliate_contact_email' => '',
));
$val = $form_state['values']['affiliate_contact_email'];
if (!empty($val) && !valid_email_address($val)) {
form_set_error('affiliate_contact_email', t('The E-mail address %val is not valid.',
array('%val' => $val)));
}
aff_validate($form_state, $form, $aff_fieldset);
debug_local("verified #3");
// Validate Acceptance #4
// fields
$aff_fs = 'aff_survey';
$aff_fieldset = array('name' => 'aff_survey',
'fields' => array(
'affiliate_survey_individuals' => 'aff_chk_numeric',
'affiliate_survey_hosp' => 'aff_chk_numeric',
'affiliate_survey_lic_beds' => 'aff_chk_numeric',
'affiliate_survey_nurse_homes' => 'aff_chk_numeric',
'affiliate_survey_nurse_or_resid_units' => 'aff_chk_numeric',
'affiliate_survey_have_website' => '',
'affiliate_survey_website_users' => 'aff_chk_numeric',
'affiliate_survey_total_users' => 'aff_chk_numeric',
));
aff_validate($form_state, $form, $aff_fieldset);
if ($form_state['values']['affiliate_survey_have_website'] == 1 &&
!$form_state['values']['affiliate_survey_website_users'] ) {
form_set_error('affiliate_survey_website_users', t('Website users must be specified.'));
}
debug_local("verified #4");
// Validate Acceptance #5
// fields
$aff_fs = 'aff_survey2';
$aff_fieldset = array('name' => 'aff_survey2',
'fields' => array(
'affiliate_survey_acc_sat' => '',
'affiliate_survey_acc_ftp' => '',
'affiliate_survey_acc_stream' => '',
'affiliate_survey_prog_daily' => 'aff_chk_numeric',
'affiliate_survey_prog_names' => '',
'affiliate_survey_additions' => '',
'affiliate_survey_comments' => '',
));
aff_validate($form_state, $form, $aff_fieldset);
debug_local( 'Access checkboxes |'. $form_state['values']['affiliate_survey_acc_sat'] . '|' . $form_state['values']['affiliate_survey_acc_ftp'] . '|' . $form_state['values']['affiliate_survey_acc_stream']);
if(!($form_state['values']['affiliate_survey_acc_sat'] ||
$form_state['values']['affiliate_survey_acc_ftp'] ||
$form_state['values']['affiliate_survey_acc_stream'])) {
form_set_error('affiliate_survey_acc_sat', t('Access methods must be specified.'));
}
debug_local("verified #5");
}
/**
* Handle post-validation form submission.
*/
function affiliate_form_submit($form_id, &$form_state) {
debug_local("In affiliate_form_submit()");
global $user;
require_once(drupal_get_path('module', 'upload_element') .'/upload_element.module');
/*print "FORM_STATE
";
var_dump($form_state);
print '
'; */
// Post completed form to database
// affiliate
$fld_info = array('uid',
'affiliate_application_status',
'affiliate_accept',
'affiliate_type',
'affiliate_name',
'affiliate_address',
'affiliate_postalcode',
'affiliate_fax',
'affiliate_url',
'affiliate_contact_title',
'affiliate_contact_name',
'affiliate_contact_telephone',
'affiliate_contact_extension',
'affiliate_contact_email',
'affiliate_creation_date',
);
// prepare data
$form_state['values']['uid'] = $user->uid;
$form_state['values']['affiliate_application_status'] = 'pending';
$table='affiliate';
$flds=array();
//print '';
foreach ($fld_info as $key => $fldname) {
$flds[$fldname] = check_plain($form_state['values'][$fldname]);
}
// handle logo element
$logo = $form_state['values']['affiliate_logo'];
$image_id = 0;
if ($logo) {
debug_local('upload_element_save');
$image_id = upload_element_save($logo, 'images', FILE_EXISTS_RENAME, 'save-original');
}
$flds['affiliate_logo'] = $image_id;
$flds['affiliate_creation_date'] = db_result(db_query('SELECT now()'));
drupal_write_record($table,$flds);
$aaid = db_result(db_query('SELECT aaid FROM {affiliate} WHERE uid = %d',$user->uid));
$fld_survey = array('affiliate_survey_indiv',
'affiliate_survey_hosp',
'affiliate_survey_lic_beds',
'affiliate_survey_nurse_homes',
'affiliate_survey_nurse_or_resid_units',
'affiliate_survey_have_website',
'affiliate_survey_website_users',
'affiliate_survey_total_users',
'affiliate_survey_acc_sat',
'affiliate_survey_acc_ftp',
'affiliate_survey_acc_stream',
'affiliate_survey_prog_daily',
'affiliate_survey_prog_names',
'affiliate_survey_additions',
'affiliate_survey_comments',
);
$table='affiliate_survey';
$flds=array();
foreach ($fld_survey as $key => $fldname) {
//$out .= "key: $key field: $fldname |" . $form_state['values'][$fldname] . "\n";
$flds[$fldname] = check_plain($form_state['values'][$fldname]);
}
$flds['aaid'] = $aaid;
drupal_write_record($table,$flds);
return;
}
function affiliate_show($arg='') {
debug_local("In affiliate_show()");
global $user;
if ($arg) {
$aa = db_fetch_object(db_query('SELECT * from {affiliate} WHERE uid = %d',$arg));
}
else {
// Print list if adminstrator
}
if (!$aa) {
$output= 'The specified user did not submit an application for affiliate status.';
return $output;
}
if ($arg == $user->uid) {
$output = '
Your application has been submitted to the station administrator and will be reviewed.
When the review is completed
you will receive an e-mail containing instructions for accessing the GATEWAVE feed.
';
drupal_set_message($output);
$output = 'Here is a copy of the application for your records:';
}
else {
$output = '';
}
$output .= '
Application for Affiliate Status
| Acceptance: |
CHECKED |
| Service Type: |
';
$output .= ucwords($aa->affiliate_type);
$address = preg_replace('/\n/',' ', $aa->affiliate_address);
$output .= ' |
| Service Name: |
' . ucwords($aa->affiliate_name) . ' |
| Mailing Address: |
' . ucwords($address) . ' |
| Postal Code: |
' . $aa->affiliate_postalcode . ' |
';
if ($aa->affiliate_fax) {
$output .= '
| Fax: |
' . $aa->affiliate_fax . ' |
';
}
$output .= '
| Contact Name: |
' . ucwords($aa->affiliate_contact_name) . ' |
| Contact Title: |
' . ucwords($aa->affiliate_contact_title) . ' |
| Contact Telephone: |
' . $aa->affiliate_contact_telephone .
($aa->affiliate_contact_extension ? ' Extn: ' . $aa->affiliate_contact_extension : '')
. ' |
| Contact E-mail: |
' . $aa->affiliate_contact_email . ' |
| Application Submitted: |
' . $aa->affiliate_creation_date . ' |
';
if ($arg == $user->uid) {
$output .= 'Your Survey:';
}
else {
$output .= 'Affilate Survey:';
}
$as = db_fetch_object(db_query('SELECT * from {affiliate_survey} WHERE aaid = %d ORDER BY affiliate_survey_date DESC LIMIT 1',$aa->aaid)); // latest survey
$output .= '
| Individual Users: |
' . $as->affiliate_survey_indiv . ' |
| Hospitals: |
' . $as->affiliate_survey_hosp . ' |
| Licensed Beds: |
' . $as->affiliate_survey_lic_beds . ' |
| Nursing Homes: |
' . $as->affiliate_survey_nurse_homes . ' |
| Nursing or Resid. Units: |
' . $as->affiliate_survey_nurse_or_resid_units . ' |
';
if ($as->affiliate_survey_have_website) {
$output .= '
| Has Website: |
Yes |
| Website Users: |
' . $as->affiliate_survey_website_users . ' |
';
}
$output .= '
| Total Users: |
' . $as->affiliate_survey_total_users . ' |
| Access by Satellite: |
' . ($as->affiliate_survey_acc_sat? 'Yes' : 'No') . ' |
| Access by FTP: |
' . ($as->affiliate_survey_acc_ftp? 'Yes' : 'No') . ' |
| Access by Stream: |
' . ($as->affiliate_survey_acc_stream? 'Yes' : 'No') . ' |
| Programs used daily: |
' . $as->affiliate_survey_prog_daily . ' |
| Program Names: |
' . $as->affiliate_survey_prog_names . ' |
| Additions: |
' . preg_replace('/\n/',' ', $as->affiliate_survey_additions) . ' |
| Comments: |
' . preg_replace('/\n/',' ', $as->affiliate_survey_comments) . ' |
| Survey Date: |
' . preg_replace('/\n/',' ', $as->affiliate_survey_date) . ' |
';
if (user_access('administer affiliate')) {
//drupal_rebuild_form($form_id, &$form_state, $args, $form_build_id = NULL)
$output .= drupal_get_form('affiliate_approve_form');
}
return $output ;
}
function affiliate_approve_form($form_id, $form_state = NULL) {
$user = user_load(arg(2));
$form['affiliate_approve']['app_btn'] = array(
'#type' => 'submit',
'#value' => 'Approve affiliate application',
'#submit' => array('affiliate_approve_submit'),
'#prefix' => '',
'#suffix' => '
',
);
$form['affiliate_approve']['app_uid'] = array(
'#type' => 'hidden',
'#value' => arg(2),
);
$form['affiliate_approve']['app_mail'] = array(
'#type' => 'hidden',
'#value' => $user->mail,
);
return $form;
}
function affiliate_approve_submit($form_id, &$form_state) {
// validate
$uid = $form_state['values']['app_uid'];
$aaid = db_result(db_query('SELECT aaid FROM {affiliate} WHERE uid = %d',$uid));
if ($aaid) {
$obj = db_fetch_object(db_query('SELECT affiliate_application_status, affiliate_name FROM {affiliate} WHERE aaid = %d',$aaid));
if ($obj) {
if ($obj->affiliate_application_status == 'approved' ) {
$output = "The application for this affiliate ($obj->affiliate_name) has already been approved.";
drupal_set_message($output);
return;
}
else {
$user = user_load($uid);
$role_list = user_roles(TRUE);
$found = 0;
foreach ($role_list as $rid => $role ) {
if ($role == 'affiliate') {
$user->roles[$rid] = $role_list[$rid];
user_save($user, array('roles' => $user->roles), NULL);
$found = 1;
break;
}
}
if ( ! $found ) {
$rid = 0;
drupal_set_message('Cannot set user role to affilate','warning');
}
$record = new stdClass();
$record->affiliate_application_status = 'approved';
$record->aaid = $aaid;
if(drupal_write_record('affiliate', $record, 'aaid')) {
drupal_set_message('Application successfully approved.');
return;
}
else {
drupal_set_message('Application approval failed.','error');
return;
}
}
}
else {
drupal_set_message("Failed to retrieve application from database, please contact system administrator.",
'error');
return;
}
}
else {
drupal_set_message("Application not found for user $uid.",'error');
return;
}
}
/**
* Implementation of hook_help().
*/
function affiliate_help($path,$arg) {
global $user;
switch($path) {
case 'affiliate/register' :
debug_local("In affiliate_help()");
if (! $user->uid) {
return '';
}
$count = db_result(db_query('SELECT COUNT(*) FROM {affiliate} WHERE uid = %d',$user->uid));
if ($count ) {
return '';
}
$node = node_load(array('nid' => 69)); $body = $node->body;
$from = array('$affiliateName$','$affiliateAddr$');
$to = array('(the User)','(the User\'s address)');
$text = str_replace($from, $to, $body);
return($text);
case 'affiliate/show/%' :
if ($arg[2] != $user->uid) {
// only show this to the user it belongs to
return;
}
else {
$aa = db_fetch_object(db_query('SELECT * from {affiliate} WHERE uid = %d',$arg[2]));
$node = node_load(array('nid' => 69));
$body = $node->body;
$from = array('$affiliateName$','$affiliateAddr$');
$addr = $aa->affiliate_address;
$addr = str_replace("\r\n",', ', $addr);
$to = array($aa->affiliate_name, $addr);
$text = str_replace($from, $to, $body);
return($text);
}
}
}
function affiliate_token_values($type, $object = NULL, $options = array()) {
$username = variable_get('affiliate_admin_username','admin');
if ($user = user_load(array('name' => $username))) {
$mail = $user->mail;
}
else {
return array();
}
if ($type == 'user') {
//$tokens['user:affiliate_admin_usermail_raw'] = $mail;
$tokens['user:affiliate_admin_usermail'] = check_plain($mail);
$message="Added user:affiliate_admin_usermail ($mail) to tokens";
return $tokens;
}
}
function affiliate_token_list($type = 'all') {
if ($type == 'user' || $type == 'all') {
$tokens['user']['user:affiliate_admin_usermail'] = t("The affiliate administrator's email address");
//$tokens['user']['user:affiliate_admin_usermail_raw'] = t("The affiliate administrator's email address");
return $tokens;
}
}
// Hook for volunteer form
function affiliate_form_webform_client_form_134_alter(&$form) {
$form['submitted']['name_title']['#multicolumn'] = array('width' => 5);
$form['submitted']['name_title']['#process'][] = 'multicolumncheckboxesradios_element_process';
$form['submitted']['name_title']['#prefix'] = '';
$form['submitted']['name_title']['#suffix'] = '
';
$form['submitted']['languages_spoken']['#multicolumn'] = array('width' => 3);
$form['submitted']['languages_spoken']['#process'][] = 'multicolumncheckboxesradios_element_process';
$form['submitted']['referred_by']['#multicolumn'] = array('width' => 3, 'row-major' => TRUE);
$form['submitted']['referred_by']['#process'][] = 'multicolumncheckboxesradios_element_process';
}
// Hook for user application
function affiliate_form_webform_client_form_135_alter(&$form) {
$form['submitted']['name_title']['#multicolumn'] = array('width' => 5);
$form['submitted']['name_title']['#process'][] = 'multicolumncheckboxesradios_element_process';
$form['submitted']['name_title']['#prefix'] = '';
$form['submitted']['name_title']['#suffix'] = '
';
$form['submitted']['brdcst_sch']['#multicolumn'] = array('width' => 5, 'row-major' => TRUE);
$form['submitted']['brdcst_sch']['#process'][] = 'multicolumncheckboxesradios_element_process';
$form['submitted']['service_req']['#multicolumn'] = array('width' => 3, 'row-major' => TRUE);
$form['submitted']['service_req']['#process'][] = 'multicolumncheckboxesradios_element_process';
$form['submitted']['gender']['#multicolumn'] = array('width' => 2);
$form['submitted']['gender']['#process'][] = 'multicolumncheckboxesradios_element_process';
$form['submitted']['gender']['#prefix'] = '';
$form['submitted']['gender']['#suffix'] = '
';
$form['submitted']['education']['#multicolumn'] = array('width' => 5);
$form['submitted']['education']['#process'][] = 'multicolumncheckboxesradios_element_process';
$form['submitted']['education']['#prefix'] = '';
$form['submitted']['education']['#suffix'] = '
';
$form['submitted']['referer']['#multicolumn'] = array('width' => 3, 'row-major' => TRUE);
$form['submitted']['referer']['#process'][] = 'multicolumncheckboxesradios_element_process';
// $form['submitted']['referer']['#prefix'] = '';
// $form['submitted']['referer']['#suffix'] = '
';
$form['submitted']['domicile']['#multicolumn'] = array('width' => 2, 'row-major' => TRUE);
$form['submitted']['domicile']['#process'][] = 'multicolumncheckboxesradios_element_process';
$form['submitted']['domicile']['#prefix'] = '';
$form['submitted']['domicile']['#suffix'] = '
';
$form['submitted']['i_agree']['#multicolumn'] = array('width' => 2, 'row-major' => TRUE);
$form['submitted']['i_agree']['#process'][] = 'multicolumncheckboxesradios_element_process';
$form['submitted']['i_agree']['#prefix'] = '';
$form['submitted']['i_agree']['#suffix'] = '
';
}