| 1 |
|
<?php |
| 2 |
|
// $Id:$ |
| 3 |
|
|
| 4 |
|
|
| 5 |
|
/** |
| 6 |
|
* Implementation of hook_role_confer_configuration(). |
| 7 |
|
*/ |
| 8 |
|
function nodeprofile_role_confer_configuration($settings) { |
| 9 |
|
|
| 10 |
|
if (!module_exists('nodeprofile')) return; |
| 11 |
|
|
| 12 |
|
$node_profile_types = nodeprofile_get_types('names'); |
| 13 |
|
|
| 14 |
|
$form['nodeprofile'] = array( |
| 15 |
|
'#type' => 'fieldset', |
| 16 |
|
'#title' => t('Node Profile'), |
| 17 |
|
'#description' => t('Select nodeprofile content type(s) which must have their required fields filled in.'), |
| 18 |
|
); |
| 19 |
|
|
| 20 |
|
$form['nodeprofile']['nodeprofile_content_type'] = array( |
| 21 |
|
'#type' => 'checkboxes', |
| 22 |
|
'#title' => t('Nodeprofile Content Type'), |
| 23 |
|
'#options' => $node_profile_types, |
| 24 |
|
'#default_value' => $settings['nodeprofile_content_type'], |
| 25 |
|
); |
| 26 |
|
|
| 27 |
|
return $form; |
| 28 |
|
} |
| 29 |
|
|
| 30 |
|
/** |
| 31 |
|
* Implementation of hook_role_confer_forms_affected(). |
| 32 |
|
*/ |
| 33 |
|
function nodeprofile_role_confer_forms_affected($settings) { |
| 34 |
|
|
| 35 |
|
foreach ($settings['nodeprofile_content_type'] as $key => $value) { |
| 36 |
|
$forms_id[] = $key . '_node_form'; |
| 37 |
|
} |
| 38 |
|
|
| 39 |
|
return $forms_id; |
| 40 |
|
} |
| 41 |
|
|
| 42 |
|
/** |
| 43 |
|
* Implementation of hook_role_confer_validate(). |
| 44 |
|
* |
| 45 |
|
* @ To Do - check required fields are all filled in |
| 46 |
|
*/ |
| 47 |
|
function nodeprofile_role_confer_validate($settings, $form_values) { |
| 48 |
|
|
| 49 |
|
global $user; |
| 50 |
|
$types = $settings['nodeprofile_content_type']; |
| 51 |
|
|
| 52 |
|
// check user has a node of this type |
| 53 |
|
foreach ($types as $type) { |
| 54 |
|
$node = node_load(array('uid' => $user->uid, 'type' => $type)); |
| 55 |
|
|
| 56 |
|
if (empty($node) && $form_values['type'] != $type) $missing[] = t('missing'); |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
return $missing; |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|