/[drupal]/contributions/modules/postalso/postalso.admin.inc
ViewVC logotype

Contents of /contributions/modules/postalso/postalso.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Jan 13 02:08:28 2009 UTC (10 months, 2 weeks ago) by yangyicn
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
File MIME type: text/x-php
add back link depending on the source of referer
1 <?php
2
3 /* helper function for the admin settings */
4 function postalso_admin_form() {
5 $destinations = variable_get('postalso_destinations', array());
6 // print_r($destinations); die;
7 $known_destinations = '';
8 foreach ($destinations as $destination) {
9 $types = implode($destination['types'], ', ');
10 $known_destinations .= "<li>{$destination['name']} ($types)</li>";
11 }
12 $form['postalso_know'] = array(
13 '#type' => 'fieldset',
14 '#title' => t('Known destinations'),
15 '#prefix' => '<ol>',
16 '#value' => $known_destinations,
17 '#suffix' => '</ol>',
18 '#collapsible' => true,
19 );
20
21 $form['postalso_where'] = array(
22 '#type' => 'fieldset',
23 '#title' => t('New destination'),
24 '#collapsible' => true,
25 '#collapsed' => true,
26 );
27
28 $form['postalso_where']['postalso_where_name'] = array(
29 '#type' => 'textfield',
30 '#title' => t('Destination name'),
31 '#default_value' => '',
32 '#required' => true,
33 );
34
35 $form['postalso_where']['postalso_where_types'] = array(
36 '#type' => 'select',
37 '#title' => t('Select supported types'),
38 '#default_value' => array(),
39 '#options' => node_get_types('names'),
40 '#multiple' => true,
41 '#required' => true,
42 );
43
44 // $form['postalso_where']['postalso_where_type_remote'] = array(
45 // '#type' => 'radios',
46 // );
47
48 $form['postalso_where']['postalso_where_url'] = array(
49 '#type' => 'textfield',
50 '#title' => t('URL of XMLRPC endpoint'),
51 '#default_value' => '',
52 '#description' => t('If http://example.com/ is your website, http://example.com/xmlrpc.php is often the correct URL.'),
53 '#required' => true,
54 );
55 $form['postalso_where']['postalso_where_user'] = array(
56 '#type' => 'textfield',
57 '#title' => t('Remote user for login'),
58 '#default_value' => '',
59 '#required' => true,
60 );
61 $form['postalso_where']['postalso_where_pass'] = array(
62 '#type' => 'password',
63 '#title' => t('Remote password for login.'),
64 '#default_value' => '',
65 '#required' => true,
66 );
67
68 $form['#validate'][] = 'postalso_admin_settings_form_validate';
69 $form['#submit'] = array('postalso_admin_settings_form_submit');
70
71 return system_settings_form($form);
72
73 }
74
75 function postalso_admin_settings_form_validate($form, &$form_values) {
76 if (!valid_url($form_values['values']['postalso_where_url'], true)) {
77 form_set_error('postalso_where_url', t('Invalid URL given.'));
78 }
79 }
80
81 function postalso_admin_settings_form_submit($form, $form_values) {
82 $destinations = variable_get('postalso_destinations', array());
83 $name = $form_values['values']['postalso_where_name'];
84 $destinations[$name] = array(
85 'name' => $name,
86 'types' => $form_values['values']['postalso_where_types'],
87 'url' => $form_values['values']['postalso_where_url'],
88 'user' => $form_values['values']['postalso_where_user'],
89 'pass' => $form_values['values']['postalso_where_pass'],
90 );
91 variable_set('postalso_destinations', $destinations);
92 }
93
94

  ViewVC Help
Powered by ViewVC 1.1.2