/[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.1, Tue Jul 22 22:47:21 2008 UTC revision 1.2, Wed Jul 23 04:02:04 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: coppa.module$  // $Id: coppa.module,v 1.1 2008/07/22 22:47:21 jgraham Exp $
3    
4  define('COPPA_AGE', 13);  define('COPPA_AGE', 13);
5  define('COPPA_ADD_ELEMENTS', 20);  define('COPPA_ADD_ELEMENTS', 20);
# Line 48  function coppa_menu($may_cache) { Line 48  function coppa_menu($may_cache) {
48                       'type' => MENU_CALLBACK,                       'type' => MENU_CALLBACK,
49                       'access' => 1,                       'access' => 1,
50                  );                  );
51        $items[] = array('path' => 'admin/user/coppa',
52                        'title' => t('Manage COPPA Relationships'),
53                        'description' => t('Manage and add COPPA Relationships'),
54                        'callback' => 'coppa_manage_page',
55                    );
56      $items[] = array('path' => 'admin/user/coppa/add',      $items[] = array('path' => 'admin/user/coppa/add',
57                       'title' => t('COPPA Add Relationships'),                       'title' => t('COPPA Add Relationships'),
                      'description' => t('Add parent/guardian to child relationships'),  
                      'callback' => 'drupal_get_form',  
                      'callback arguments' => array('coppa_set_parents'),  
58                       'access' => $admin_access,                       'access' => $admin_access,
59                       'type' => MENU_NORMAL_ITEM);                       'type' => MENU_LOCAL_TASK,
60                    );
61     $items[] = array('path' => 'admin/user/coppa/manage',     $items[] = array('path' => 'admin/user/coppa/manage',
62                      'title' => t('COPPA Manage Relationships'),                      'title' => t('COPPA Manage Relationships'),
                     'description' => t('Add parent/guardian to child relationships'),  
                     'callback' => 'drupal_get_form',  
                     'callback arguments' => array('coppa_manage_relationships'),  
63                      'access' => $admin_access,                      'access' => $admin_access,
64                      'type' => MENU_NORMAL_ITEM);                      'type' => MENU_DEFAULT_LOCAL_TASK,
65                    );
66    
67      return $items;      return $items;
68    }    }
69  }  }
70    
71    function coppa_manage_page($path = NULL) {
72      $bcrumb = drupal_get_breadcrumb();
73      $bcrumb[] = l(t('COPPA'), 'admin/user/coppa/add');
74      switch($path) {
75        case 'add':
76          $output = drupal_get_form('coppa_set_parents');
77          $bcrumb[] = l(t('Add'), 'admin/user/coppa/add');
78          break;
79        case 'manage':
80        default:
81          $manage = coppa_manage_relationships();
82          $bcrumb[] = l(t('Manage'), 'admin/user/coppa/manage');
83          if (!empty($manage)) {
84            $output = drupal_get_form('coppa_manage_relationships');
85          }
86          else {
87            $output = t('No existing COPPA relationships.');
88          }
89          break;
90      }
91    
92      drupal_set_title(t('COPPA'));
93      drupal_set_breadcrumb($bcrumb);
94      return $output;
95    }
96    
97  /**  /**
98   * Informational page to prompt user about COPPA requirements   * Informational page to prompt user about COPPA requirements
99   */   */
# Line 287  function coppa_set_parents_submit($form_ Line 315  function coppa_set_parents_submit($form_
315    
316        if (!in_array($child->uid, $inserted[$parent->uid])) {        if (!in_array($child->uid, $inserted[$parent->uid])) {
317          db_query('INSERT INTO {coppa} (cid, pid, status) values(%d, %d, %d)', $child->uid, $parent->uid, 0);          db_query('INSERT INTO {coppa} (cid, pid, status) values(%d, %d, %d)', $child->uid, $parent->uid, 0);
318            drupal_set_message(t('Added %cname as child of %pname', array('%cname' => $child->name, '%pname' => $parent->name)));
319          $inserted[$parent->uid][] = $child->uid;          $inserted[$parent->uid][] = $child->uid;
320        }        }
321        else {        else {
# Line 334  function coppa_manage_relationships() { Line 363  function coppa_manage_relationships() {
363    $form = array();    $form = array();
364    $date_format = 'n j Y'; // m/d/y    $date_format = 'n j Y'; // m/d/y
365    $result = db_query("SELECT cu.uid as cid, cu.name as cname, pu.uid as pid, pu.name as pname, pv.value as dob, c.status    $result = db_query("SELECT cu.uid as cid, cu.name as cname, pu.uid as pid, pu.name as pname, pv.value as dob, c.status
366                        FROM users cu, coppa c, users pu                        FROM {users} cu, {coppa} c, {users} pu
367                        LEFT JOIN profile_values pv ON pv.uid = c.cid                        LEFT JOIN profile_values pv ON pv.uid = c.cid
368                        LEFT JOIN profile_fields pf ON pv.fid = pf.fid                        LEFT JOIN profile_fields pf ON pv.fid = pf.fid
369                        WHERE  cu.uid = c.cid AND pu.uid = c.pid");                        WHERE  cu.uid = c.cid AND pu.uid = c.pid");

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.2