diff -r 96e3acc6c410 constants/constants.module
--- a/constants/constants.module	Sun Apr 15 02:44:53 2012 +0400
+++ b/constants/constants.module	Sun Apr 15 04:22:33 2012 +0400
@@ -42,8 +42,13 @@
 /**
  * Implementation of hook_perm().
  */
-function constants_perm() {
-  return array('administer constants');
+function constants_permission() {
+  return 
+    array('administer constants' =>
+      array(
+        'title' => t('Administer constants'),
+      )    
+    );
 }
 
 
@@ -53,7 +58,7 @@
 function constants_theme() {
   return array(
     'constants_table' => array(
-      'arguments' => array('form' => NULL),
+      'render element' => 'constants_table',
     )
   );
 }
@@ -104,8 +109,8 @@
   );
   
     foreach ($vars as $var) {   // each has 'name', 'value'
-      $name = _constants_variable_unname($var['name']);
-      $value = $var['value'];
+      $name = _constants_variable_unname($var->name);
+      $value = $var->value;
 
       $form['existing']['constants'][$name]['name'] = array(
         '#type' => 'textfield',
@@ -277,9 +282,8 @@
   $result = db_query("SELECT * from {variable} WHERE name like '" . CONSTANTS_VARIABLE_PREFIX . "%' ORDER BY name");
   $vars = array();
-  while ($row = db_fetch_array($result)) {
+  foreach($result as $row) {
     // unserialize
-    $row['value'] = unserialize($row['value']);
+    $row->value = unserialize($row->value);
     
     $vars[] = $row;
   }
@@ -351,7 +355,9 @@
  * theme function for variables table
  * (adapted from themekey module)
  */
-function theme_constants_table($form) {
+function theme_constants_table($variables) {
+
+  $form = $variables['constants_table'];
   $rows = array();
   $header = isset($form['#header']) ? $form['#header'] : array();
   $attributes = isset($form['#attributes']) ? $form['#attributes'] : array();
@@ -363,10 +369,10 @@
     }
   }
   
-    if (empty($rows)) {
+  if (empty($rows)) {
     $message = check_plain(isset($form['#empty']) ? $form['#empty'] : t('There are no items in the table.'));
     $rows[] = array(array('data' => $message, 'colspan' => count($header), 'align' => 'center', 'class' => 'message'));
   }
 
-  return count($rows) ? theme('table', $header, $rows, $attributes) : '';
+  return count($rows) ? theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)) : '';
 }
