| 1 |
|
|
| 2 |
|
|
| 3 |
|
/** |
| 4 |
|
* this file contains all the implementations of signit hook operations |
| 5 |
|
* for the default operation of the module |
| 6 |
|
*/ |
| 7 |
|
|
| 8 |
|
|
| 9 |
|
/* ******************************************** */ |
| 10 |
|
/* Message functions */ |
| 11 |
|
/* ******************************************** */ |
| 12 |
|
|
| 13 |
|
/** |
| 14 |
|
* implementation of the hook_signit_messaging |
| 15 |
|
*/ |
| 16 |
|
function signit_signit_message($op, $data){ |
| 17 |
|
switch ($op) { |
| 18 |
|
case 'admin': |
| 19 |
|
return signit_signit_message_admin(); |
| 20 |
|
break; |
| 21 |
|
case 'create': |
| 22 |
|
return signit_signit_message_create($data); |
| 23 |
|
} |
| 24 |
|
} |
| 25 |
|
|
| 26 |
|
/** |
| 27 |
|
* generates the form for admining hook_signit_targets |
| 28 |
|
*/ |
| 29 |
|
function signit_signit_message_admin($signit){ |
| 30 |
|
$form['signit_message_control'] = array( |
| 31 |
|
'#type' => 'checkbox', |
| 32 |
|
'#title' => 'SignIt creators can set the email options of their signit', |
| 33 |
|
'#default_value' => variable_get('signit_message_control', true) |
| 34 |
|
); |
| 35 |
|
return $form; |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
/** |
| 39 |
|
* generates the form for creating hook_signit_targets |
| 40 |
|
*/ |
| 41 |
|
function signit_signit_message_create($signit){ |
| 42 |
|
$form['signit']['message']['signit_email_from'] = array( |
| 43 |
|
'#type' => 'textfield', |
| 44 |
|
'#title' => t('Email from'), |
| 45 |
|
'#default_value' => $node->signit['email_from'] ? $node->signit['email_from']: variable_get("site_mail", null), |
| 46 |
|
'#description' => t('Enter the email address that will appear in the "From: " header of sent messages. This is <em>only</em> used when sending a list of signatures.'), |
| 47 |
|
); |
| 48 |
|
$form['signit']['message']['signit_email_subject_set'] = array( |
| 49 |
|
'#type' => 'checkbox', |
| 50 |
|
'#title' => t('Allow users to set email subject.'), |
| 51 |
|
'#options' => array('Enabled'), |
| 52 |
|
'#default_value' => $node->signit['email_subject_set'] ? 1 : 0, |
| 53 |
|
'#description' => t('If this is not set, the subject will be populated by the below value'), |
| 54 |
|
); |
| 55 |
|
|
| 56 |
|
// signit message subject |
| 57 |
|
$form['signit']['message']['signit_email_subject'] = array( |
| 58 |
|
'#type' => 'textfield', |
| 59 |
|
'#title' => t('Email subject'), |
| 60 |
|
'#default_value' => $node->signit['email_subject'] ? $node->signit['email_subject'] : "My SignIt ", |
| 61 |
|
'#description' => t('Subject of auto-response email message to be sent.'), |
| 62 |
|
); |
| 63 |
|
|
| 64 |
|
// signit message body |
| 65 |
|
$form['signit']['message']['signit_message_filter']['signit_message'] = array( |
| 66 |
|
'#type' => 'textarea', |
| 67 |
|
'#title' => t('Email message'), |
| 68 |
|
'#default_value' => $node->signit['message'], |
| 69 |
|
'#description' => t('Body of auto-response email message to be sent. Please note, changes to this do not effect already collected signatures.'), |
| 70 |
|
); |
| 71 |
|
// add a filter form to to the body |
| 72 |
|
$form['signit']['message']['signit_message_filter']['signit_message_format'] = filter_form($node->signit['message_format'], null, array('signit_message_filter')); |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
$form['signit']['message']['signit_personal_message'] = array( |
| 76 |
|
'#type' => 'checkbox', |
| 77 |
|
'#title' => t('Allow users to add personal messages.'), |
| 78 |
|
'#options' => array('Enabled'), |
| 79 |
|
'#default_value' => $node->signit['personal_message'] ? 1 : 0, |
| 80 |
|
'#description' => t('Gives user the ability to add a personal message to the email template. ') |
| 81 |
|
); |
| 82 |
|
|
| 83 |
|
$form['signit']['message']['signit_comment_allow'] = array( |
| 84 |
|
'#type' => 'checkbox', |
| 85 |
|
'#title' => t('Allow users to add a comment.'), |
| 86 |
|
'#options' => array('Enabled'), |
| 87 |
|
'#default_value' => $node->signit['comment_allow'] ? 1 : 0, |
| 88 |
|
'#description' => t('Gives user the ability to leave a comment along with their message. This can be displayed on the list of signatures.') |
| 89 |
|
); |
| 90 |
|
|
| 91 |
|
$form['signit']['message']['signit_comment_allow_html'] = array( |
| 92 |
|
'#type' => 'checkbox', |
| 93 |
|
'#title' => t('Allow HTML in comment form.'), |
| 94 |
|
'#options' => array('Enabled'), |
| 95 |
|
'#default_value' => $node->signit['comment_allow_html'] ? 1 : 0, |
| 96 |
|
'#description' => t('If this is checked, non-anonymous users will be allowed to have HTML tags in the comment form. Anonymous users are <em>never</em> allowed to enter HTML.'), |
| 97 |
|
); |
| 98 |
|
return $form; |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
/* ******************************************** */ |
| 102 |
|
/* Target functions */ |
| 103 |
|
/* ******************************************** */ |
| 104 |
|
|
| 105 |
|
/** |
| 106 |
|
* implementation of the hook_signit_targets |
| 107 |
|
*/ |
| 108 |
|
function signit_signit_targets($op, $data){ |
| 109 |
|
switch ($op) { |
| 110 |
|
case 'admin': |
| 111 |
|
return signit_signit_targets_admin(); |
| 112 |
|
break; |
| 113 |
|
case 'create': |
| 114 |
|
return signit_signit_targets_create($data); |
| 115 |
|
} |
| 116 |
|
} |
| 117 |
|
|
| 118 |
|
/** |
| 119 |
|
* generates the form for hook_signit_targets |
| 120 |
|
*/ |
| 121 |
|
function signit_signit_targets_create($signit){ |
| 122 |
|
|
| 123 |
|
// set target title |
| 124 |
|
$form['target_title'] = array( |
| 125 |
|
'#type' => 'textfield', |
| 126 |
|
'#title' => t('Target title'), |
| 127 |
|
'#default_value' => $node->signit['target_title'], |
| 128 |
|
'#description' => t('Give the intended target of your SignIt a title.'), |
| 129 |
|
'#access' => variable_get('signit_target_title_set', false) ? true: false, |
| 130 |
|
); |
| 131 |
|
|
| 132 |
|
// build the potential targets |
| 133 |
|
// @ TODO |
| 134 |
|
|
| 135 |
|
// check the target settigns |
| 136 |
|
switch (variable_get('signit_targets_set', 0)) { |
| 137 |
|
|
| 138 |
|
case 0: |
| 139 |
|
$form['signit_targets_email_to'] = array( |
| 140 |
|
'#type' => 'hidden', |
| 141 |
|
'#default_value' => variable_get('signit_targets_default',''), |
| 142 |
|
); |
| 143 |
|
break; |
| 144 |
|
|
| 145 |
|
case 1: |
| 146 |
|
$form['signit_targets_email_to'] = array( |
| 147 |
|
'#type' => 'select', |
| 148 |
|
'#title' => t('SignIt email targets'), |
| 149 |
|
'#default_value' => $addresses, |
| 150 |
|
'#description' => t('Enter email address and name seperated by comma, eg: "janedoe@janedoe.com, Jane Doe". Names are not needed, but will replace the email address on the display. Please note, changes to this do not effect already collected signatures.'), |
| 151 |
|
); |
| 152 |
|
break; |
| 153 |
|
|
| 154 |
|
case 2: |
| 155 |
|
$form['signit_targets_email_to'] = array( |
| 156 |
|
'#type' => 'textarea', |
| 157 |
|
'#title' => t('SignIt email targets'), |
| 158 |
|
'#default_value' => $addresses, |
| 159 |
|
'#description' => t('Enter email address and name seperated by comma, eg: "janedoe@janedoe.com, Jane Doe". Names are not needed, but will replace the email address on the display. Please note, changes to this do not effect already collected signatures.'), |
| 160 |
|
); |
| 161 |
|
break; |
| 162 |
|
} |
| 163 |
|
return $form; |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
|
| 167 |
|
/** |
| 168 |
|
* generates the form for hook_signit_targets for admin |
| 169 |
|
*/ |
| 170 |
|
function signit_signit_targets_admin() { |
| 171 |
|
|
| 172 |
|
$form['signit_target_title_set'] = array( |
| 173 |
|
'#type' => 'checkbox', |
| 174 |
|
'#title' => t('SignIt creators can set the title of their signit'), |
| 175 |
|
'#default_value' => variable_get('signit_target_title_set', true), |
| 176 |
|
'#description' => t('This allows a SignIt creator to "name" a target or set of targets.'), |
| 177 |
|
); |
| 178 |
|
|
| 179 |
|
$radios = array( |
| 180 |
|
0 => t('SignIt Creators can not select target'), |
| 181 |
|
1 => t('SignIt Creators can select targets from a list'), |
| 182 |
|
2 => t('SignIt Creators can enter their own targets') |
| 183 |
|
); |
| 184 |
|
$form['signit_targets_set'] = array( |
| 185 |
|
'#type' => 'select', |
| 186 |
|
'#title' => t('Target settings'), |
| 187 |
|
'#options' => $radios, |
| 188 |
|
'#default_value' => variable_get('signit_targets_set', 0), |
| 189 |
|
'#description' => t('If SignIt creators can not select a target, the target(s) are used from the field below. If users can select from a list, that list is populated from the field below.'), |
| 190 |
|
); |
| 191 |
|
$form['signit_targets_default'] = array( |
| 192 |
|
'#type' => 'textarea', |
| 193 |
|
'#title' => t('SignIt email targets'), |
| 194 |
|
'#default_value' => variable_get('signit_targets_default',''), |
| 195 |
|
'#description' => t('Enter email address and name seperated by comma, eg: "janedoe@janedoe.com, Jane Doe". Names are not needed, but will replace the email address on the display. Please note, changes to this do not effect already collected signatures.'), |
| 196 |
|
); |
| 197 |
|
|
| 198 |
|
return $form; |
| 199 |
|
} |
| 200 |
|
|