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

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

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


Revision 1.4 - (show annotations) (download) (as text)
Thu Mar 5 06:33:19 2009 UTC (8 months, 3 weeks ago) by freso
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +38 -9 lines
File MIME type: text/x-php
Task #295237 by Freso and jonathan1055: Mission Clean Code.
1 <?php
2 // $Id: pingback.admin.inc,v 1.0.0.1 2007/07/26 23:17:13 dww Exp $
3
4 /**
5 * @file
6 * Admin page callbacks for the Pingback module.
7 */
8
9 /**
10 * Form builder; Configure the Pingback system.
11 *
12 * @ingroup forms
13 * @see system_settings_form()
14 */
15 function pingback_settings_form() {
16 $form = array();
17 $formats = array();
18 foreach (filter_formats() as $f) {
19 $formats[$f->format] = $f->name;
20 }
21 $form['pingback_input_format'] = array(
22 '#type' => 'select',
23 '#title' => t('Pingback input format'),
24 '#options' => $formats,
25 '#default_value' => variable_get('pingback_input_format', FILTER_FORMAT_DEFAULT),
26 '#description' => t('The input format used to display pingbacks. All comments in this input format will be considered as pingbacks, so you must create <a href="@create-format">an exclusive input format</a> only for pingbacks (and let anonymous users post comments with that format). If you change this option, any existing pingbacks may become comments.', array('@create-format' => url('admin/settings/filters/add'))),
27 );
28 $form['pingback_hide_format_for_anon'] = array(
29 '#type' => 'radios',
30 '#title' => t('Hide pingback input format for anonymous users'),
31 '#options' => array(
32 0 => t('Disabled'),
33 1 => t('Enabled'),
34 ),
35 '#default_value' => variable_get('pingback_hide_format_for_anon', 0),
36 '#description' => t('Hide the input format chosen from the above option when anonymous users post comments. Enable this, or else people can post comments as pingbacks!'), //to devs: every node update will invalidate the variable cache, so it is not appropriate for sites that has many concurrent node insert / update, e.g. 50 node updates each second.
37 );
38 $form['pingback_receive'] = array(
39 '#type' => 'radios',
40 '#title' => t('Receive pingbacks'),
41 '#options' => array(
42 1 => t('Yes'),
43 0 => t('No'),
44 ),
45 '#default_value' => variable_get('pingback_receive', 1),
46 '#description' => t('Receive pingbacks sent from other sites linking to you.'),
47 );
48 $form['pingback_mode'] = array(
49 '#type' => 'radios',
50 '#title' => t('Pingback autoping'),
51 '#options' => array(
52 'off' => t('Never'),
53 'submit' => t('When creating and updating nodes'),
54 'cron' => t('On cron run'),
55 ),
56 '#default_value' => variable_get('pingback_mode', 'off'),
57 '#description' => t('When to automatically ping linked sites. Performance of cron mode is still poor if post creation and update traffic is very high.'),
58 );
59 $form['pingback_check_per_cron'] = array(
60 '#type' => 'textfield',
61 '#title' => t('Number of checks per cron run'),
62 '#default_value' => variable_get('pingback_check_per_cron', 30),
63 '#description' => t('How many pingbacks one cron run must check. Because pingbacks connect to external servers the process can be time consuming, depending on the amount of pingbacks. This option is effective only if pingbacks are sent at cron run.'),
64 );
65 $form['pingback_notify_successful_pings'] = array(
66 '#type' => 'radios',
67 '#title' => t('Notify for successful pingbacks'),
68 '#options' => array(
69 1 => t('Yes'),
70 0 => t('No'),
71 ),
72 '#default_value' => variable_get('pingback_notify_successful_pings', 1),
73 '#description' => t('Notify users about successful pingbacks. This option is efective only if pingbacks are sent when creating and updating nodes.'),
74 );
75 /*
76 How to implement this, I wonder. comment_save() doesn't let modules insert comments with arbitrary status
77 $form['pingback_moderation'] = array(
78 '#type' => 'radios',
79 '#title' => t('Pingback moderation'),
80 '#options' => array(
81 0 => t('Disabled'),
82 1 => t('Enabled'),
83 ),
84 '#default_value' => variable_get('pingback_moderation', 0),
85 '#description' => t('If pingback moderation is enabled, incoming pingbacks will not be published automatically. A user with "administer comments" permission can publish those pingbacks.'),
86 );
87 */
88 return system_settings_form($form);
89 }
90
91 /**
92 * Validate pingback_settings form submissions.
93 */
94 function pingback_settings_form_validate($form, &$form_state) {
95 $formats = filter_formats();
96 $f = $formats[$form_state['values']['pingback_input_format']];
97 //note: this role-matching is dependent of current implementation of filter.module
98 if (strpos($f->roles, ','. DRUPAL_ANONYMOUS_RID .',') === FALSE) {
99 form_set_error('pingback_input_format', t('The input format has to be usable by anonymous users.'));
100 }
101 }

  ViewVC Help
Powered by ViewVC 1.1.2