/[drupal]/contributions/modules/comment_info/comment_info.module
ViewVC logotype

Diff of /contributions/modules/comment_info/comment_info.module

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

revision 1.1.2.1.2.1, Sun Jan 14 23:20:23 2007 UTC revision 1.1.2.1.2.2, Fri Feb 23 20:20:50 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: comment_info.module,v 1.1.2.2 2007/01/14 19:27:32 mfer Exp $  // $Id: comment_info.module,v 1.1.2.1.2.1 2007/01/14 23:20:23 mfer Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 18  function comment_info_help($section) { Line 18  function comment_info_help($section) {
18    }    }
19  }  }
20    
21    /**
22     * Implementation of hook_menu().
23     */
24    function comment_info_menu($may_cache) {
25      $items = array();
26      if ($may_cache) {
27        $items[] = array(
28          'path' => 'admin/settings/comment_info',
29          'title' => t('Comment Info'),
30          'description' => t('Administer Comment Info Configuration.'),
31          'callback' => 'drupal_get_form',
32          'callback arguments' => array('comment_info_admin_settings'),
33          'access' => user_access('administer site configuration'),
34          'type' => MENU_NORMAL_ITEM,
35        );
36      }
37      return $items;
38    }
39    
40    /**
41     * Helper function generates admin settings page.
42     */
43    function comment_info_admin_settings() {
44      $form['comment_info_description'] = array(
45        '#value' => 'The Comment Info module allows anonymous users to save their comment information.  There are two methods for storing the anonymous users information.  The classic way via the users session and the new method using jQuery.  Using the jQuery method will only work in javascript enabled browsers but is the prefered method to use with caching.'
46      );
47    
48      $form['comment_info_setting'] = array(
49      '#type' => 'checkbox',
50      '#title' => t('Enable jQuery Comment Info.'),
51      '#default_value' => variable_get('comment_info_setting', 0),
52      );
53    
54      return system_settings_form($form);
55    }
56    
57  /**  /**
58   * Insert our checkbox, and populate fields.   * Insert our checkbox, and populate fields.
59   * set validation hook.   * set validation hook.
# Line 28  function comment_info_form_alter($form_i Line 64  function comment_info_form_alter($form_i
64    if ($user->uid || ($form_id != 'comment_form')) {    if ($user->uid || ($form_id != 'comment_form')) {
65      return;      return;
66    }    }
67    
68    foreach (array('name','homepage','mail') as $field) {    if (variable_get('comment_info_setting', 0) == 1) {
69      if (is_array($form[$field]) && $_SESSION['comment_info']['optin']) {      drupal_add_js(drupal_get_path('module', 'comment_info').'/comment_info.js');
70        $form[$field]['#value'] = $_SESSION['comment_info'][$field];      $form['comment_info']['optin'] = array(
71      }        '#value' => "<span id=\"comment_info\"></span>",
72        );
73    }    }
74    
75      else {
76        foreach (array('name','homepage','mail') as $field) {
77          if (is_array($form[$field]) && $_SESSION['comment_info']['optin']) {
78           $form[$field]['#value'] = $_SESSION['comment_info'][$field];
79          }
80        }
81    
82    $form['#validate']['comment_info_validate'] = array();      $form['#validate']['comment_info_validate'] = array();
83    
84    $form['comment_info']['optin'] = array(      $form['comment_info']['optin'] = array(
85      '#type' => 'checkbox',       '#type' => 'checkbox',
86      '#title' => 'Save my Comment Information for next time.',        '#title' => 'Save my Comment Information for next time.',
87      '#default_value' => $_SESSION['comment_info']['optin']        '#default_value' => $_SESSION['comment_info']['optin']
88    );      );
89      }
90  }  }
91    
92  /**  /**

Legend:
Removed from v.1.1.2.1.2.1  
changed lines
  Added in v.1.1.2.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.2