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

Diff of /contributions/modules/coppa/coppa.module

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

revision 1.3, Wed Jul 23 07:02:10 2008 UTC revision 1.4, Tue Jul 29 19:50:40 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: coppa.module,v 1.2 2008/07/23 04:02:04 jgraham Exp $  // $Id: coppa.module,v 1.3 2008/07/23 07:02:10 jgraham Exp $
3    
4  define('COPPA_AGE', 13);  define('COPPA_AGE', 13);
5  define('COPPA_ADD_ELEMENTS', 20);  define('COPPA_ADD_ELEMENTS', 20);
# Line 23  function coppa_help($section) { Line 23  function coppa_help($section) {
23   *   *
24   */   */
25  function coppa_menu($may_cache) {  function coppa_menu($may_cache) {
26      global $user;
27    $items = array();    $items = array();
28    $admin_access = user_access('administer users');    $admin_access = user_access('administer users');
29    
# Line 41  function coppa_menu($may_cache) { Line 42  function coppa_menu($may_cache) {
42                       'type' => MENU_CALLBACK,                       'type' => MENU_CALLBACK,
43                       'access' => 1,                       'access' => 1,
44                  );                  );
     $items[] = array('path' => 'coppa/sign',  
                      'title' => t('Sign COPPA compliance for your children'),  
                      'callback' => 'drupal_get_form',  
                      'callback arguments' => array('coppa_sign'),  
                      'type' => MENU_CALLBACK,  
                      'access' => 1,  
                 );  
45      $items[] = array('path' => 'admin/user/coppa',      $items[] = array('path' => 'admin/user/coppa',
46                      'title' => t('Manage COPPA Relationships'),                      'title' => t('Manage COPPA Relationships'),
47                      'description' => t('Manage and add COPPA Relationships'),                      'description' => t('Manage and add COPPA Relationships'),
# Line 63  function coppa_menu($may_cache) { Line 57  function coppa_menu($may_cache) {
57                      'access' => $admin_access,                      'access' => $admin_access,
58                      'type' => MENU_DEFAULT_LOCAL_TASK,                      'type' => MENU_DEFAULT_LOCAL_TASK,
59                  );                  );
   
     return $items;  
60    }    }
61      else {
62        // only add coppa/sign to the menu if the user is a parent/guardian
63        $result = db_query('SELECT * FROM {coppa} WHERE pid = %d', $user->uid);
64        if (db_num_rows($result)) {
65          $items[] = array('path' => 'coppa/sign',
66                           'title' => t('Sign COPPA compliance'),
67                           'callback' => 'drupal_get_form',
68                           'callback arguments' => array('coppa_sign'),
69                           'type' => MENU_NORMAL_ITEM,
70                           'access' => 1,
71                      );
72        }
73      }
74      return $items;
75  }  }
76    
77  function coppa_manage_page($path = NULL) {  function coppa_manage_page($path = NULL) {
# Line 144  function coppa_sign() { Line 150  function coppa_sign() {
150    $form['submit'] = array('#type' => 'submit', '#value' => t('Confirm COPPA'));    $form['submit'] = array('#type' => 'submit', '#value' => t('Confirm COPPA'));
151    
152    if (count($form['children']) == 1) {    if (count($form['children']) == 1) {
153      return t('You do not have any children associated to you.');      return array('message' => array('#type' => 'message', '#value' => t('You do not have any children associated to you.')));
154    }    }
155    else {    else {
156      return $form;      return $form;
# Line 166  function coppa_sign_submit($form_id, $ed Line 172  function coppa_sign_submit($form_id, $ed
172    
173  function theme_coppa_sign($edit) {  function theme_coppa_sign($edit) {
174    $rows = array();    $rows = array();
175      if (!isset($edit['children'])) {
176    $header = array(t('User History'), t('Date of Birth'), t('COPPA Status'));      $output = $edit['message']['#value'];
   
   foreach (element_children($edit['children']) as $uid) {  
     unset($row);  
     $row[] = drupal_render($edit['children'][$uid]['tracker']);  
     $row[] = drupal_render($edit['children'][$uid]['dob']);  
     unset($edit['children'][$uid]['status']['#title']);  
     $row[] = drupal_render($edit['children'][$uid]['status']);  
     $rows[] = $row;  
177    }    }
178      else {
179        $header = array(t('User History'), t('Date of Birth'), t('COPPA Status'));
180    
181    $output = theme('table', $header, $rows, array('id' => 'coppa-sign'));      foreach (element_children($edit['children']) as $uid) {
182    $output .= '<br />';        unset($row);
183    $output .= drupal_render($edit['submit']);        $row[] = drupal_render($edit['children'][$uid]['tracker']);
184          $row[] = drupal_render($edit['children'][$uid]['dob']);
185    $output .= drupal_render($edit['form_id']);        unset($edit['children'][$uid]['status']['#title']);
186          $row[] = drupal_render($edit['children'][$uid]['status']);
187          $rows[] = $row;
188        }
189    
190        $output = theme('table', $header, $rows, array('id' => 'coppa-sign'));
191        $output .= '<br />';
192        $output .= drupal_render($edit['submit']);
193    
194    $output .= drupal_render($edit['form_token']);      $output .= drupal_render($edit['form_id']);
195    
196        $output .= drupal_render($edit['form_token']);
197      }
198    return $output;    return $output;
199    
200  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.2