? chart.d7.000.patch
Index: chart.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chart/chart.info,v
retrieving revision 1.5
diff -u -p -r1.5 chart.info
--- chart.info	16 Jul 2009 21:23:12 -0000	1.5
+++ chart.info	30 Sep 2010 15:12:45 -0000
@@ -2,5 +2,6 @@
 name = Chart API
 description = Google chart API integration.
 package = Charting
-core = 6.x
+core = 7.x
 php = 5
+files[] = chart.module
Index: chart.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chart/chart.module,v
retrieving revision 1.20
diff -u -p -r1.20 chart.module
--- chart.module	1 Feb 2010 15:27:03 -0000	1.20
+++ chart.module	30 Sep 2010 15:12:45 -0000
@@ -73,10 +73,15 @@ define('CHART_LEGEND_LEFT', 'l');
  *------------------------------------------------------------------*/
 
 /**
- * Implementation of hook_perm();
+ * Implementation of hook_permission();
  */
-function chart_perm() {
-  return array('administer chart');
+function chart_permission() {
+  return array(
+    'administer chart' => array(
+      '#title' => t('Administer Chart API'),
+      '#description' => t('Perform configuration tasks for Chart API'),
+    ),
+  );
 }
 
 /**
@@ -92,7 +97,7 @@ function chart_init() {
 function chart_menu() {
   $items = array();
 
-  $items['admin/settings/chart'] = array(
+  $items['admin/config/system/chart'] = array(
       'title' => 'Charts',
       'page callback' => 'drupal_get_form',
       'page arguments' => array('chart_settings'),
@@ -312,7 +317,7 @@ function chart_build($chart) {
   _chart_append('chld',  $chart['#countries'],               $data);
   _chart_append('chtm',  $chart['#georange'],                $data);
 
-  $charts[$chart['#chart_id']] = drupal_query_string_encode($data);
+  $charts[$chart['#chart_id']] = drupal_http_build_query($data);
 
   return $charts[$chart['#chart_id']];
 }
Index: contrib/system_charts/system_charts.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chart/contrib/system_charts/system_charts.info,v
retrieving revision 1.5
diff -u -p -r1.5 system_charts.info
--- contrib/system_charts/system_charts.info	16 Jul 2009 21:23:12 -0000	1.5
+++ contrib/system_charts/system_charts.info	30 Sep 2010 15:12:45 -0000
@@ -2,6 +2,7 @@
 name = Drupal System Charting
 description = Charting for various core modules.
 package = Charting
-core = 6.x
+core = 7.x
 php = 5
 dependencies[] = chart
+files[] = system_charts.module
Index: contrib/system_charts/system_charts.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chart/contrib/system_charts/system_charts.module,v
retrieving revision 1.11
diff -u -p -r1.11 system_charts.module
--- contrib/system_charts/system_charts.module	14 Jul 2009 02:45:33 -0000	1.11
+++ contrib/system_charts/system_charts.module	30 Sep 2010 15:12:45 -0000
@@ -13,10 +13,19 @@
  *------------------------------------------------------------------*/
 
 /**
- * Implementation of hook_perm();
+ * Implementation of hook_permission();
  */
-function system_charts_perm(){
-  return array('administer system charts', 'access system charts');
+function system_charts_permission(){
+  return array(
+    'administer system charts' => array(
+      '#title' => t('Administer System Charts'),
+      '#description' => t('Perform configuration tasks for System Charts'),
+    ),
+    'access system charts' => array(
+      '#title' => t('Access System Charts'),
+      '#description' => t('View System Charts content'),
+    )
+  );
 }
 
 /**
@@ -119,13 +128,16 @@ function system_charts_display($page = '
  */
 function system_charts_build($type) {
   $chart = array();
-  $now   = (isset($_GET['year']) && isset($_GET['month'])) ? mktime(0, 0, 0, $_GET['month'], 30, $_GET['year']) : time();
+  $now   = (isset($_GET['year']) && isset($_GET['month'])) ? mktime(0, 0, 0, $_GET['month'], 30, $_GET['year']) : REQUEST_TIME;
 
   switch($type) {
     case 'node_counts':
     case 'node_counts_published':
     case 'node_counts_unpublished':
     case 'node_counts_today':
+      $query = db_select('node', 'n');
+      $query->addExpression('COUNT(*)', 'count');
+      $query->fields('n', array('type'));
       switch($type){
         case 'node_counts':
           $title = t('Total');
@@ -133,24 +145,20 @@ function system_charts_build($type) {
 
         case 'node_counts_published':
           $title = t('Published');
-          $sql_where = " WHERE status = '1' ";
+          $query->condition('n.status', '1', '=');
+
           break;
 
         case 'node_counts_unpublished':
           $title = t('Unpublished');
-          $sql_where = " WHERE status = '0' ";
+          $query->condition('n.status', '0', '=');
           break;
       }
+      $query->orderBy('type');
+      $query->groupBy('type');
+      $results = $query->execute();
 
-      $results = db_query("
-          SELECT COUNT(*) as count, type
-          FROM {node}
-          " . $sql_where . "
-          GROUP BY type
-          ORDER BY type
-        ", $sql_args);
-
-      while ($result = db_fetch_array($results)){
+      while ($result = $results->fetchAssoc()){
         $chart['#data'][]        = $result['count'];
         $chart['#labels'][]      = $result['type'].': '.$result['count'];
         $chart['#data_colors'][] = chart_unique_color($result['type']);
@@ -163,18 +171,18 @@ function system_charts_build($type) {
       break;
 
     case 'node_activity':
-      $results = db_query("
-          SELECT type, created
-          FROM {node}
-          WHERE created  < %d AND created > %d
-          ORDER BY created
-        ", $now, mktime(0, 0, 0, date('m', $now), 1, date('Y', $now)));
+      $query = db_select('node', 'n');
+      $query->fields('n', array('type', 'created'));
+      $query->condition('n.created', $now, '<');
+      $query->condition('n.created', mktime(0, 0, 0, date('m', $now), 1, date('Y', $now)), '>');
+      $query->orderBy('created');
 
+      $results = $query->execute();
       $max    = array();
       $counts = array();
       $types  = array();
 
-      while ($result = db_fetch_array($results)){
+      while ($result = $results->fetchAssoc()){
         $day = ltrim(date('d', $result['created']), '0');
         $types[$result['type']] = $result['type'];
         $counts[$day][$result['type']]++;
@@ -218,14 +226,20 @@ function system_charts_build($type) {
       break;
 
     case 'watchdog_counts':
-      $results = db_query("
+      /* $results = db_query("
           SELECT COUNT(*) as count, type
           FROM {watchdog}
           GROUP BY type
           ORDER BY type
-        ");
+        "); */
+      $query = db_select('watchdog', 'w');
+      $query->addExpression('COUNT(*)', 'count');
+      $query->fields('w', array('type'));
+      $query->groupBy('type');
+      $query->orderBy('type');
 
-      while ($result = db_fetch_array($results)){
+      $results = $query->execute();
+      while ($result = $results->fetchAssoc()){
         $chart['#data'][]        = $result['count'];
         $chart['#labels'][]      = $result['type'] . ': ' . $result['count'];
         $chart['#data_colors'][] = chart_unique_color($result['type']);
@@ -244,8 +258,14 @@ function system_charts_build($type) {
           GROUP BY severity
           ORDER BY severity
         ");
+      $query = db_select('watchdog', 'w');
+      $query->addExpression('COUNT(*)', 'count');
+      $query->fields('w', array('severity'));
+      $query->groupBy('severity');
+      $query->orderBy('severity');
 
-      while ($result = db_fetch_array($results)){
+      $results = $query->execute();
+      while ($result = $results->fetchAssoc()){
         $severity_label          = _system_charts_watchdog_severity_label($result['severity']);
         $chart['#data'][]        = $result['count'];
         $chart['#labels'][]      = $severity_label . ': ' . $result['count'];
@@ -259,16 +279,16 @@ function system_charts_build($type) {
     break;
 
     case 'users_per_role':
-      $results = db_query("
-          SELECT COUNT(*) as count, r.*
-          FROM {users_roles} ur
-          LEFT JOIN {users} u ON ur.uid = u.uid
-          LEFT JOIN {role} r ON r.rid = ur.rid
-          GROUP BY r.rid
-          ORDER BY r.name
-        ");
+      $query = db_select('users_roles', 'ur');
+      $query->join('users', 'u', 'ur.uid = u.uid');
+      $query->join('role', 'r', 'r.rid = ur.uid');
+      $query->fields('r', array('rid', 'name'));
+      $query->addExpression('COUNT(*)', 'count');
+      $query->groupBy('r.rid');
+      $query->orderBy('r.name');
 
-      while ($result = db_fetch_array($results)){
+      $results = $query->execute();
+      while ($result = $results->fetchAssoc()) {
         $chart['#data'][]        = $result['count'];
         $chart['#labels'][]      = $result['name'] . ': ' . $result['count'];
         $chart['#data_colors'][] = chart_unique_color('role_' . $result['name']);
@@ -281,15 +301,15 @@ function system_charts_build($type) {
       break;
 
     case 'user_status':
-      $results = db_query("
-          SELECT COUNT(*) as count, status
-          FROM {users}
-          WHERE uid != 0
-          GROUP BY status
-          ORDER BY status
-        ");
-
-      while ($result = db_fetch_array($results)){
+      $query = db_select('users', 'u');
+      $query->addExpression('COUNT(*)', 'count');
+      $query->fields('u', array('status'));
+      $query->condition('uid', 0, '!=');
+      $query->groupBy('status');
+      $query->orderBy('status');
+      
+      $results = $query->execute();
+      while ($result = $results->fetchAssoc()){
         $chart['#data'][]        = $result['count'];
         $chart['#labels'][]      = _system_charts_user_status_label($result['status']) . ': ' . $result['count'];
         $chart['#data_colors'][] = chart_unique_color('status_' . $result['status']);
