? game_clock_d7_axyjo_1.patch
Index: game_clock.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/game_clock/game_clock.admin.inc,v
retrieving revision 1.1
diff -u -p -r1.1 game_clock.admin.inc
--- game_clock.admin.inc	7 Dec 2008 21:31:03 -0000	1.1
+++ game_clock.admin.inc	5 Jan 2009 19:51:54 -0000
@@ -291,7 +291,10 @@ function _game_clock_create($state, $rep
     watchdog('game_clock', $error, $options, WATCHDOG_ERROR);
     return FALSE;
   }
-  $status = db_query("INSERT INTO {game_clocks} (name, title, status, turn, increment, block, init) VALUES ('%s', '%s', %d, %d, %d, %d, %d)", $state->name, $state->title, $state->status, $state->turn, $state->increment, $state->block, $state->init);
+  $status = db_insert('game_clocks')->
+    fields(array('name', 'title', 'status', 'turn', 'increment', 'block', 'init'))->
+    values(array($state->name, $state->title, $state->status, $state-turn, $state->increment, $state->block, $state->init))->
+    execute();
   if (!$status) {
     $error = 'Creation of the %clock game clock failed for an unknown reason.';
     if ($report_errors) {
Index: game_clock.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/game_clock/game_clock.info,v
retrieving revision 1.1
diff -u -p -r1.1 game_clock.info
--- game_clock.info	7 Dec 2008 21:31:03 -0000	1.1
+++ game_clock.info	5 Jan 2009 19:51:54 -0000
@@ -1,5 +1,9 @@
 ; $Id: game_clock.info,v 1.1 2008/12/07 21:31:03 aaron Exp $
 name = Game Clock
 description = Increment game turns automatically.
-core = 6.x
+core = 7.x
 package = Game
+
+files[] = game_clock.module
+files[] = game_clock.theme.inc
+files[] = game_clock.admin.ic
Index: game_clock.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/game_clock/game_clock.install,v
retrieving revision 1.1
diff -u -p -r1.1 game_clock.install
--- game_clock.install	7 Dec 2008 21:31:03 -0000	1.1
+++ game_clock.install	5 Jan 2009 19:51:55 -0000
@@ -17,7 +17,10 @@ function game_clock_install() {
     // Note that UI strings in the following SQL, e.g. "Bookmark this", aren't
     // wrapped in t() and that's intentional: they are passed to t() later,
     // thus allowing for multilingual sites.
-    db_query("INSERT INTO {game_clocks} (name, title, increment, block) VALUES ('default', 'Default', 5, 1)");
+    db_insert('game_clocks')->
+      fields(array('name', 'title', 'increment', 'block'))->
+      values(array('default', 'Default', 5, 1))->
+      execute();
   }
 
   if ($success) {
Index: game_clock.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/game_clock/game_clock.module,v
retrieving revision 1.2
diff -u -p -r1.2 game_clock.module
--- game_clock.module	7 Dec 2008 21:50:42 -0000	1.2
+++ game_clock.module	5 Jan 2009 19:51:55 -0000
@@ -20,7 +20,6 @@ define('GAME_CLOCK_TURN_DEFAULT', 0);   
  *  Implements hook_help().
  */
 function game_clock_help($section) {
-  module_load_include('inc', 'game_clock', 'game_clock.admin');
   return _game_clock_help($section);
 }
 
@@ -38,7 +37,10 @@ function game_clock_pause($clock = 'defa
   if ($state['status'] != $status) {
     global $game_clocks;
     $game_clocks[$clock]->status = $status;
-    db_query('UPDATE {game_clocks} SET status = %d WHERE cid = %d', $status, $state->cid);
+    db_update('game_clocks')->
+      fields(array('status'=>$status))->
+      condition('cid', $state->cid, '=')->
+      execute();
     module_invoke_all('game_clock', ($status ? 'start' : 'pause'), $clock, $game_clocks[$clock]);
     game_clock_increment($clock);
   }
@@ -75,7 +77,10 @@ function game_clock_increment($clock = '
     global $game_clocks;
     $game_clocks[$clock]->turn++;
     $game_clocks[$clock]->next_tick = time() + $game_clocks[$clock]->increment;
-    db_query("UPDATE {game_clocks} SET turn = %d, next_tick = %d WHERE cid = %d", $game_clocks[$clock]->turn, $game_clocks[$clock]->next_tick, $game_clocks[$clock]->cid);
+    db_update('game_clocks')->
+      fields(array('turn' => $game_clocks[$clock]->turn, 'next_tick' => $game_clocks[$clock]->next_tick))->
+      condition('cid', $game_clocks[$clock]->cid, '=')->
+      execute();
     module_invoke_all('game_clock', 'increment', $clock, $game_clocks[$clock]);
     return TRUE;
   }
@@ -95,7 +100,10 @@ function game_clock_reset($clock = 'defa
   $state = game_clock_state($clock);
   $game_clocks[$clock]->turn = isset($turn) ? $turn : GAME_CLOCK_TURN_DEFAULT;
   $game_clocks[$clock]->next_tick = 0;
-  db_query("UPDATE {game_clocks} SET turn = %d, next_tick = %d WHERE cid = %d", $game_clocks[$clock]->turn, $game_clocks[$clock]->next_tick, $game_clocks[$clock]->cid);
+  db_update('game_clocks')->
+    fields(array('turn' => $game_clocks[$clock]->turn, 'next_tick' => $game_clocks[$clock]->next_tick))->
+    condition('cid', $game_clocks[$clock]->cid, '=')->
+    execute();
   module_invoke_all('game_clock', 'reset', $clock, $game_clocks[$clock]);
   game_clock_increment($clock);
 }
@@ -114,7 +122,6 @@ function game_clock_reset($clock = 'defa
  *    Either the newly created clock object, or FALSE if there was an error.
  */
 function game_clock_create($state, $report_errors = FALSE) {
-  module_load_include('inc', 'game_clock', 'game_clock.admin');
   return _game_clock_create($state, $report_errors);
 }
 
@@ -142,7 +149,9 @@ function game_clock_state($clock = NULL)
   }
 
   if (is_null($game_clocks[$clock])) {
-    $results = db_query('SELECT * FROM {game_clocks} WHERE name = "%s"', $clock);
+    $results = db_query('SELECT * FROM {game_clocks} WHERE name = :clock_name', array(
+      ':clock_name' => $clock
+    ));
     while ($result = db_fetch_object($results)) {
       $game_clocks[$result->name] = $result;
     }
@@ -156,7 +165,9 @@ function game_clock_state($clock = NULL)
  */
 function game_clock_init() {
   global $game_clocks;
-  $results = db_query("SELECT * FROM {game_clocks} WHERE status <> 0 AND increment > 0 AND init <> 0 AND next_tick < %d", time());
+  $results = db_query("SELECT * FROM {game_clocks} WHERE status <> 0 AND increment > 0 AND init <> 0 AND next_tick < :current_time", array(
+    ':current_time' => time()
+  ));
   while ($result = db_fetch_object($results)) {
     $game_clocks[$result->name] = $result;
     game_clock_increment($result->name);
@@ -168,7 +179,10 @@ function game_clock_init() {
  */
 function game_clock_cron() {
   global $game_clocks;
-  $results = db_query("SELECT * FROM {game_clocks} WHERE status <> 0 AND increment > 0 AND next_tick < %d", time());
+  // From axyjo: Can't <> be replaced by != ?
+  $results = db_query("SELECT * FROM {game_clocks} WHERE status <> 0 AND increment > 0 AND next_tick < :current_time", array(
+    ':current_time' => time(),
+  ));
   while ($result = db_fetch_object($results)) {
     $game_clocks[$result->name] = $result;
     game_clock_increment($result->name);
@@ -185,7 +199,6 @@ function game_clock_menu() {
       'description' => 'Administer the game clock.',
       'page callback' => 'game_clock_settings_page',
       'access arguments' => array('administer game clock'),
-      'file' => 'game_clock.admin.inc',
     ),
   );
   return $items;
@@ -195,35 +208,40 @@ function game_clock_menu() {
  *  Implements hook_perm().
  */
 function game_clock_perm() {
-  return array('administer game clock');
+  return array(
+    'administer game clock' => array(
+      'title' => t('Administer game clock'),
+      'description' => t('Perform administrative tasks for the game clock module'),
+    ),
+  );
 }
 
 /**
- *  Implements hook_block().
+ *  Implements hook_block_*().
  */
-function game_clock_block($op = 'list', $delta = 'default', $edit = array()) {
-  switch ($op) {
-    case 'list':
-      $blocks = array();
-      foreach (game_clock_state() as $game => $state) {
-        // Only make a block available if it's been checked on the game clock administration page.
-        if ($state->block) {
-          $blocks[$game] = array(
-            'info' => t('Game clock: @title', array('@title' => $state->title)),
-          );
-        }
+function game_clock_block_list($delta = 'default', $edit = array()) {
+  $blocks = array();
+  foreach (game_clock_State() as $game => $state) {
+    // Only make a block available if it's been checked on the game clock administration page.
+      if ($state->block) {
+        $blocks[$game] = array(
+          'info' => t('Game clock: @title', array('@title' => $state->title)),
+        );
       }
-      return $blocks;
-    case 'view':
-      $state = game_clock_state($delta);
-      $block = array(
-        'subject' => t('@title game clock', array('@title' => $state->title)),
-        'content' => theme('game_clock_block', $delta),
-      );
-      return $block;
+    }
+    return $blocks;
   }
 }
 
+function game_clock_block_view($delta = 'default', $edit = array()) {
+  $state = game_clock_state($delta);
+  $block = array(
+    'subject' => t('@title game clock', array('@title' => $state->title)),
+    'content' => theme('game_clock_block', $delta),
+  );
+  return $block;
+}
+
 /**
  *  Implements hook_theme().
  */
@@ -231,11 +249,9 @@ function game_clock_theme($existing, $ty
   return array(
     'game_clock_block' => array(
       'arguments' => array('clock' => 'default'),
-      'file' => 'game_clock.theme.inc',
     ),
     'game_clock_settings_form' => array(
       'arguments' => array('form' => NULL),
-      'file' => 'game_clock.admin.inc',
     ),
   );
 }
