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

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

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


Revision 1.1 - (show annotations) (download) (as text)
Sun Mar 29 19:47:48 2009 UTC (7 months, 4 weeks ago) by icecreamyou
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--2
File MIME type: text/x-php
Initial 2.x commit!
1 <?php
2 // $Id$
3
4 /**
5 * @file
6 * Allows users to have a "status."
7 */
8
9 /**
10 * Settings form.
11 */
12 function facebook_status_admin($form_state) {
13 $form['facebook_status_concat'] = array(
14 '#type' => 'checkbox',
15 '#title' => t('Facebook Mode'),
16 '#description' => t("Facebook Mode makes this module work like Facebook, where the user's username is appended to the front of the status."),
17 '#default_value' => variable_get('facebook_status_concat', 1),
18 );
19 $form['facebook_status_slide'] = array(
20 '#type' => 'checkbox',
21 '#title' => t('Slide Effect'),
22 '#description' => t('Slides the status update form into a fieldset to reduce the space it takes up.'),
23 '#default_value' => variable_get('facebook_status_slide', 1),
24 );
25 $form['facebook_status_legacy'] = array(
26 '#type' => 'checkboxes',
27 '#title' => t('Legacy Mode'),
28 '#description' => t('On nodes and/or user profiles, use the status of the author of the node or owner of the profile, respectively, in the status block.'),
29 '#default_value' => variable_get('facebook_status_legacy', array('user')),
30 '#options' => array('node' => t('Nodes'), 'user' => t('User profiles')),
31 );
32 $form['facebook_status_exclude'] = array(
33 '#type' => 'textfield',
34 '#title' => t('Exclude users'),
35 '#description' => t('Disallow these users from having statuses. Type in usernames separated by commas, following the rules of taxonomy autocomplete fields.'),
36 '#default_value' => variable_get('facebook_status_exclude', ''),
37 '#maxlength' => 0,
38 '#autocomplete_path' => 'facebook_status/autocomplete',
39 );
40 $form['facebook_status_size'] = array(
41 '#type' => 'textfield',
42 '#title' => t('Status update field size'),
43 '#description' => t('The width of the status update textfield.'),
44 '#default_value' => variable_get('facebook_status_size', 32),
45 '#size' => 4,
46 '#maxlength' => 4,
47 '#required' => TRUE,
48 );
49 return system_settings_form($form);
50 }
51
52 /**
53 * Validate function for the settings form.
54 */
55 function facebook_status_admin_validate($form, &$form_state) {
56 $exclude_string = $form_state['values']['facebook_status_exclude'];
57 $exclude_orig = explode(',', $exclude_string);
58 $exclude_final = array();
59 foreach ($exclude_orig as $excluded) {
60 $excluded = trim($excluded);
61 $exists = db_result(db_query("SELECT name FROM {users} WHERE name = '%s'", $excluded));
62 if ($exists) {
63 $exclude_final[] = $excluded;
64 }
65 }
66 $exclude = implode(', ', $exclude_final);
67 form_set_value($form['facebook_status_exclude'], $exclude, $form_state);
68
69 /**
70 * Not quite sure what I originally intended this to do, but apparently I left off in the middle of it.
71 if ($form_state['values']['facebook_status_exclude']) {
72 form_set_error('facebook_status_exclude', t('
73 }
74 */
75 $size = $form_state['values']['facebook_status_size'];
76 if (!is_numeric($size) || $size < 1 || $size != round($size)) {
77 form_set_error('facebook_status_size', t('The size of the status update field must be a positive integer!'));
78 }
79 }

  ViewVC Help
Powered by ViewVC 1.1.2