Index: fasttoggle.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fasttoggle/fasttoggle.module,v
retrieving revision 1.4.2.6
diff -u -r1.4.2.6 fasttoggle.module
--- fasttoggle.module	14 Apr 2007 21:27:28 -0000	1.4.2.6
+++ fasttoggle.module	16 Apr 2007 00:27:25 -0000
@@ -15,9 +15,9 @@
 
   if (!$may_cache) {
     // The callback for toggling node settings
-    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'toggle' && arg(3) != '' && count(fasttoggle_get_options('node'))) {
+    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'toggle' && arg(3) != '') {
       $node = node_load(arg(1));
-      if ($node->nid) {
+      if ($node->nid && count(fasttoggle_get_options('node', $node))) {
         $items[] = array(
           'path' => 'node/'. arg(1) .'/toggle',
           'title' => t('toggle'),
@@ -30,9 +30,9 @@
     }
 
     // The callback for toggling user settings
-    elseif (arg(0) == 'admin' && arg(1) == 'user' && is_numeric(arg(2)) && arg(3) == 'toggle' && arg(4) != '' && count(fasttoggle_get_options('user'))) {
+    elseif (arg(0) == 'admin' && arg(1) == 'user' && is_numeric(arg(2)) && arg(3) == 'toggle' && arg(4) != '') {
       $user = user_load(array('uid' => arg(2)));
-      if ($user->uid) {
+      if ($user->uid && count(fasttoggle_get_options('user', $user))) {
         $items[] = array(
           'path' => 'admin/user/'. arg(2) .'/toggle',
           'title' => t('status'),
@@ -44,9 +44,9 @@
       }
     }
 
-    elseif (arg(0) == 'comment' && arg(1) == 'toggle' && is_numeric(arg(2)) && arg(3) != '' && count(fasttoggle_get_options('comment'))) {
+    elseif (arg(0) == 'comment' && arg(1) == 'toggle' && is_numeric(arg(2)) && arg(3) != '') {
       $comment = _comment_load(arg(2));
-      if ($comment->cid) {
+      if ($comment->cid && count(fasttoggle_get_options('comment', $comment))) {
         $items[] = array(
           'path' => 'comment/toggle/'. arg(2),
           'title' => t('status'),
@@ -121,31 +121,18 @@
  *
  * @param $type
  *   The object type the functions should return options for (e.g. node, comment, ...)
- * @param $cache
- *   (Optional) If set to false, the object option cache will be cleared and
- *   requeried from the respective modules.
+ * @param $obj
+ *   Node, comment, or user object.
  */
-function fasttoggle_get_options($type, $cache = true) {
-  static $options = array();
-
-  // Flush the cache
-  if (!$cache) {
-    $options = array();
-  }
-
-  // Cache the hook results
-  if (!isset($options[$type])) {
-    $options[$type] = module_invoke_all('fasttoggle_options', $type);
-  }
-
-  return $options[$type];
+function fasttoggle_get_options($type, $obj) {
+  return module_invoke_all('fasttoggle_options', $type, $obj);
 }
 
 
 /**
  * Implementation of hook_fasttoggle_options().
  */
-function fasttoggle_fasttoggle_options($type) {
+function fasttoggle_fasttoggle_options($type, $obj) {
   $return = array();
 
   switch ($type) {
@@ -208,7 +195,7 @@
  */
 function fasttoggle_link($type, $obj = null, $teaser = false) {
   $links = array();
-  $options = fasttoggle_get_options($type);
+  $options = fasttoggle_get_options($type, $obj);
 
   if (!empty($options)) {
     switch ($type) {
@@ -234,7 +221,7 @@
  * POST. Otherwise, display a confirmation form.
  */
 function fasttoggle_node_option($node, $option) {
-  $options = fasttoggle_get_options('node');
+  $options = fasttoggle_get_options('node', $node);
 
   // Check if the action is valid. This is essential to ensure the user has
   // access to the action.
@@ -290,7 +277,7 @@
  * POST. Otherwise, display a confirmation form.
  */
 function fasttoggle_user_option($user, $option) {
-  $options = fasttoggle_get_options('user');
+  $options = fasttoggle_get_options('user', $user);
 
   dsm($option);
 
@@ -345,7 +332,7 @@
  * POST. Otherwise, display a confirmation form.
  */
 function fasttoggle_comment_option($comment, $option) {
-  $options = fasttoggle_get_options('comment');
+  $options = fasttoggle_get_options('comment', $comment);
 
   // Check if the action is valid. This is essential to ensure the user has
   // access to the action.
