nly in /Users/jucallme/Sites/drupal-7.4/sites/local.mobiletoolbox.co.za/files/coder_upgrade/old/geckoboard: .git
diff -up -r geckoboard.info geckoboard.info
--- geckoboard.info	2011-09-15 00:05:14.000000000 +0200
+++ geckoboard.info	2011-09-15 00:06:02.000000000 +0200
@@ -1,3 +1,5 @@
 name = Geckoboard
 description = Enables you to use widgets on Geckoboard
-core = 6.x
+core = 7.x
+
+files[] = geckoboardresponse.inc
diff -up -r geckoboard.install geckoboard.install
--- geckoboard.install	2011-09-15 00:05:14.000000000 +0200
+++ geckoboard.install	2011-09-15 00:06:02.000000000 +0200
@@ -1,11 +1,25 @@
 <?php
+/**
+ * @file
+ * Install, update and uninstall functions for the geckoboard module.
+ *
+ */
 
+
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function geckoboard_install() {
   $apikey = user_password(10);
   variable_set('geckoboard_api_key', $apikey);
 }
 
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function geckoboard_uninstall() {
   variable_del('geckoboard_api_key');
 }
diff -up -r geckoboard.module geckoboard.module
--- geckoboard.module	2011-09-15 00:05:14.000000000 +0200
+++ geckoboard.module	2011-09-15 00:06:02.000000000 +0200
@@ -1,49 +1,70 @@
 <?php
 
-function geckoboard_perm() {
-    return array('administer Geckoboard');
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function geckoboard_permission() {
+  return array(
+    'administer Geckoboard' => array(
+      'title' => t('administer Geckoboard'),
+      'description' => t('TODO Add a description for \'administer Geckoboard\''),
+    ),
+  );
 }
 
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function geckoboard_menu() {
-  $items['admin/settings/geckoboard'] = array(
+  $items['admin/config/geckoboard'] = array(
     'title' => 'Geckoboard configuration',
     'description' => "Edit the configuration for Geckoboard",
     'page callback' => "drupal_get_form",
     'page arguments' => array("geckoboard_settings"),
     'access arguments' => array('administer Geckoboard'),
-    'type' => MENU_NORMAL_ITEM
+    'type' => MENU_NORMAL_ITEM,
   );
 
   $items['geckoboard/%'] = array(
     'page callback' => "geckoboard_show_widget",
     'type' => MENU_NORMAL_ITEM,
     'access arguments' => array('access content'),
-    'page arguments' => array(1)
+    'page arguments' => array(1),
   );
 
   return $items;
 }
 
 
-function geckoboard_settings() {
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function geckoboard_settings($form, &$form_state) {
   $form = array();
   $form['geckoboard_api_key'] = array(
     '#type' => 'textfield',
     '#title' => t('API Key'),
     '#description' => t('Enter a secret key. This key will be used on connect from your geckoboard dashboard to your drupal site.'),
-    '#default_value' => variable_get("geckoboard_api_key", "")
+    '#default_value' => variable_get("geckoboard_api_key", ""),
   );
   return system_settings_form($form);
 }
 
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function geckoboard_show_widget($input) {
   module_load_include('inc', 'geckoboard', 'geckoboardresponse');
   $geckoboardResponse = new GeckoboardResponse();
 
   if (isset($_POST) && isset($input) && isset($_SERVER['PHP_AUTH_USER'])) {
-    $format = isset($_POST['format']) ? (int)$_POST['format'] : 0;
+    $format = isset($_POST['format']) ? (int) $_POST['format'] : 0;
     $format = ($format == 1) ? 'xml' : 'json';
     $geckoboardResponse->setFormat($format);
     /**
@@ -53,27 +74,27 @@ function geckoboard_show_widget($input) 
      *  3 - RAG numbers only
      *  4 - Text
      */
-    $type = isset($_POST['type']) ? (int)$_POST['type'] : 1;
+    $type = isset($_POST['type']) ? (int) $_POST['type'] : 1;
     if (variable_get("geckoboard_api_key", "") == $_SERVER['PHP_AUTH_USER']) {
       switch ($input) {
         default:
         case 'users':
           $data = geckoboard_user_data($type);
-        break;
+          break;
         case 'posts':
           $data = geckoboard_posts_data($type);
-        break;
+          break;
         case 'comments':
           $data = geckoboard_comments_data($type);
-        break;
+          break;
       }
       $response = $geckoboardResponse->getResponse($data);
       echo $response;
     }
     else {
-        drupal_set_header("HTTP/1.1 403 Access denied");
-        $data = array('error' => 'Access denied.');
-        echo $geckoboardResponse->getResponse($data);
+      drupal_add_http_header('Status', '403 Access denied');
+      $data = array('error' => 'Access denied.');
+      echo $geckoboardResponse->getResponse($data);
     }
   }
   else {
@@ -90,36 +111,71 @@ function geckoboard_show_widget($input) 
  */
 function geckoboard_user_data($type) {
   $data = array();
-  $data_today = db_fetch_array(db_query("SELECT count(*) as amount FROM {users} WHERE created > %d" , time()- 86400));
-  $data_week = db_fetch_array(db_query("SELECT count(*) as amount from {users} WHERE created > %d" , time()- 604800));
-  $data_month = db_fetch_array(db_query("SELECT count(*) as amount from {users} WHERE created > %d" , time()- 2629743));
-
-  $data['item'][] = array('text' => t('Day'), 'value' => $data_today['amount']);
-  $data['item'][] = array('text' => t('Week'), 'value' => $data_week['amount']);
-  $data['item'][] = array('text' => t('Month'), 'value' => $data_month['amount']);
+  $data_today = db_fetch_array(db_query("SELECT count(*) as amount FROM {users} WHERE created > :created", array(':created' => REQUEST_TIME - 86400)));
+  $data_week = db_fetch_array(db_query("SELECT count(*) as amount from {users} WHERE created > :created", array(':created' => REQUEST_TIME - 604800)));
+  $data_month = db_fetch_array(db_query("SELECT count(*) as amount from {users} WHERE created > :created", array(':created' => REQUEST_TIME - 2629743)));
+
+  $data['item'][] = array(
+    'text' => t('Day'),
+    'value' => $data_today['amount'],
+  );
+  $data['item'][] = array(
+    'text' => t('Week'),
+    'value' => $data_week['amount'],
+  );
+  $data['item'][] = array(
+    'text' => t('Month'),
+    'value' => $data_month['amount'],
+  );
   return $data;
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function geckoboard_posts_data($type) {
   $data = array();
-  $data_today = db_fetch_array(db_query("SELECT count(*) as amount from {node} WHERE created > %d" , time()- 86400));
-  $data_week = db_fetch_array(db_query("SELECT count(*) as amount from {node} WHERE created > %d" , time()- 604800));
-  $data_month = db_fetch_array(db_query("SELECT count(*) as amount from {node} WHERE created > %d" , time()- 2629743));
-
-  $data['item'][] = array('text' => t('Day'), 'value' => $data_today['amount']);
-  $data['item'][] = array('text' => t('Week'), 'value' => $data_week['amount']);
-  $data['item'][] = array('text' => t('Month'), 'value' => $data_month['amount']);
+  $data_today = db_fetch_array(db_query("SELECT count(*) as amount from {node} WHERE created > :created", array(':created' => REQUEST_TIME - 86400)));
+  $data_week = db_fetch_array(db_query("SELECT count(*) as amount from {node} WHERE created > :created", array(':created' => REQUEST_TIME - 604800)));
+  $data_month = db_fetch_array(db_query("SELECT count(*) as amount from {node} WHERE created > :created", array(':created' => REQUEST_TIME - 2629743)));
+
+  $data['item'][] = array(
+    'text' => t('Day'),
+    'value' => $data_today['amount'],
+  );
+  $data['item'][] = array(
+    'text' => t('Week'),
+    'value' => $data_week['amount'],
+  );
+  $data['item'][] = array(
+    'text' => t('Month'),
+    'value' => $data_month['amount'],
+  );
   return $data;
 }
 
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
 function geckoboard_comments_data($type) {
   $data = array();
-  $data_today = db_fetch_array(db_query("SELECT count(*) as amount from {comments} WHERE timestamp > %d" , time()- 86400));
-  $data_week = db_fetch_array(db_query("SELECT count(*) as amount from {comments} WHERE timestamp > %d" , time()- 604800));
-  $data_month = db_fetch_array(db_query("SELECT count(*) as amount from {comments} WHERE timestamp > %d" , time()- 2629743));
-
-  $data['item'][] = array('text' => t('Day'), 'value' => (int)$data_today['amount']);
-  $data['item'][] = array('text' => t('Week'), 'value' => (int)$data_week['amount']);
-  $data['item'][] = array('text' => t('Month'), 'value' => (int)$data_month['amount']);
+  $data_today = db_fetch_array(db_query("SELECT count(*) as amount from {comments} WHERE timestamp > :timestamp", array(':timestamp' => REQUEST_TIME - 86400)));
+  $data_week = db_fetch_array(db_query("SELECT count(*) as amount from {comments} WHERE timestamp > :timestamp", array(':timestamp' => REQUEST_TIME - 604800)));
+  $data_month = db_fetch_array(db_query("SELECT count(*) as amount from {comments} WHERE timestamp > :timestamp", array(':timestamp' => REQUEST_TIME - 2629743)));
+
+  $data['item'][] = array(
+    'text' => t('Day'),
+    'value' => (int) $data_today['amount'],
+  );
+  $data['item'][] = array(
+    'text' => t('Week'),
+    'value' => (int) $data_week['amount'],
+  );
+  $data['item'][] = array(
+    'text' => t('Month'),
+    'value' => (int) $data_month['amount'],
+  );
   return $data;
 }
diff -up -r geckoboardresponse.inc geckoboardresponse.inc
--- geckoboardresponse.inc	2011-09-15 00:05:14.000000000 +0200
+++ geckoboardresponse.inc	2011-09-15 00:06:02.000000000 +0200
@@ -1,98 +1,98 @@
 <?php
-
-/**
- * @file
- * Class GeckoboardResponse - for response to geckoboard API
- *
- * This code is copied from http://support.geckoboard.com/entries/234460-example-scripts
- * The only difference is the classname.
- */
-
-class GeckoboardResponse {
-    /**
-     * Response format - xml or json
-     */
-    private $format = 'xml';
-
-    /**
-     * Set response format
-     *
-     * @access public
-     * @param string $format xml or json
-     * @return void
-     */
-    public function setFormat($format) {
-        $this->format = $format;
-    }
-
-    /**
-     * Create response string
-     *
-     * @access public
-     * @param array $data
-     * @param bool $cdata
-     * @return string
-     */
-    public function getResponse($data, $cdata = FALSE) {
-        switch ($this->format) {
-            case 'xml':
-                $response = $this->getXmlResponse($data, $cdata);
-                break;
-            case 'json':
-                $response = $this->getJsonResponse($data);
-                break;
-        }
-        return $response;
-    }
-
-    /**
-     * Create response in xml format
-     *
-     * @access private
-     * @param array $data
-     * @param bool $cdata
-     * @return string
-     */
-    private function getXmlResponse($data, $cdata) {
-        $dom = new DOMDocument('1.0', 'UTF-8');
-        $root = $dom->createElement('root');
-        $dom->appendChild($root);
-
-        foreach ($data as $k => $v) {
-            if (is_array($v)) {
-                for ($i = 0; $i < sizeof($v); $i++) {
-                    $item = $dom->createElement($k);
-                    foreach ($v[$i] as $k1 => $v1) {
-                        $cdata = $dom->createCDATASection($v1);
-                        $node = $dom->createElement($k1);
-                        $node->appendChild($cdata);
-                        $item->appendChild($node);
-                    }
-                    $root->appendChild($item);
-                }
-            }
-            else {
-                $item = $dom->createElement($k);
-                $cdata = $dom->createCDATASection($v);
-                //$node->appendChild($cdata);
-                $item->appendChild($cdata);
-                $root->appendChild($item);
-            }
-        }
-
-        $response = $dom->saveXML();
-        return $response;
-    }
-
-    /**
-     * Create response in json format
-     *
-     * @access private
-     * @param array $data
-     * @return string
-     */
-    private function getJsonResponse($data) {
-        $response = json_encode($data);
-        return $response;
-    }
-}
+
+/**
+ * @file
+ * Class GeckoboardResponse - for response to geckoboard API
+ *
+ * This code is copied from http://support.geckoboard.com/entries/234460-example-scripts
+ * The only difference is the classname.
+ */
+
+class GeckoboardResponse {
+  /**
+   * Response format - xml or json
+   */
+  private $format = 'xml';
+
+  /**
+   * Set response format
+   *
+   * @access public
+   * @param string $format xml or json
+   * @return void
+   */
+  public function setFormat($format) {
+    $this->format = $format;
+  }
+
+  /**
+   * Create response string
+   *
+   * @access public
+   * @param array $data
+   * @param bool $cdata
+   * @return string
+   */
+  public function getResponse($data, $cdata = FALSE) {
+    switch ($this->format) {
+      case 'xml':
+        $response = $this->getXmlResponse($data, $cdata);
+        break;
+      case 'json':
+        $response = $this->getJsonResponse($data);
+        break;
+    }
+    return $response;
+  }
+
+  /**
+   * Create response in xml format
+   *
+   * @access private
+   * @param array $data
+   * @param bool $cdata
+   * @return string
+   */
+  private function getXmlResponse($data, $cdata) {
+    $dom = new DOMDocument('1.0', 'UTF-8');
+    $root = $dom->createElement('root');
+    $dom->appendChild($root);
+
+    foreach ($data as $k => $v) {
+      if (is_array($v)) {
+        for ($i = 0; $i < sizeof($v); $i++) {
+          $item = $dom->createElement($k);
+          foreach ($v[$i] as $k1 => $v1) {
+            $cdata = $dom->createCDATASection($v1);
+            $node = $dom->createElement($k1);
+            $node->appendChild($cdata);
+            $item->appendChild($node);
+          }
+          $root->appendChild($item);
+        }
+      }
+      else {
+        $item = $dom->createElement($k);
+        $cdata = $dom->createCDATASection($v);
+        //$node->appendChild($cdata);
+        $item->appendChild($cdata);
+        $root->appendChild($item);
+      }
+    }
+
+    $response = $dom->saveXML();
+    return $response;
+  }
+
+  /**
+   * Create response in json format
+   *
+   * @access private
+   * @param array $data
+   * @return string
+   */
+  private function getJsonResponse($data) {
+    $response = json_encode($data);
+    return $response;
+  }
+}

