From e625d92490f42bf9000d4164b73d0ec03597247c Mon Sep 17 00:00:00 2001
From: Sven Decabooter <sven@puresign.be>
Date: Tue, 19 Apr 2011 09:15:06 +0200
Subject: improve variable_get for node types

---
 node_tasklist.module |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/node_tasklist.module b/node_tasklist.module
index a9679bd..c16bdad 100644
--- a/node_tasklist.module
+++ b/node_tasklist.module
@@ -60,8 +60,7 @@ function node_tasklist_menu() {
  * Implementation of hook_form_alter().
  */
 function node_tasklist_form_alter(&$form, &$form_state, $form_id) {
-
-  foreach (variable_get('node_tasklist_types', array(NULL => NULL)) as $type => $value) {
+  foreach (node_tasklist_get_enabled_types() as $type => $value) {
 
     if ("$type" == "$value") {
 
@@ -132,7 +131,12 @@ function node_tasklist_get_users($type) {
   return $users;
 }
 
-
+/**
+ * Get a list of enabled tasklist content types
+ */
+function node_tasklist_get_enabled_types() {
+  return array_filter(variable_get('node_tasklist_types', array()));
+}
 
 /**
  * magic node editing page - /tl/[type]
@@ -146,7 +150,7 @@ function node_tasklist_page($type) {
   }
 
   // convert to while to allow access denied msg for other forms
-  foreach (variable_get('node_tasklist_types', array(NULL => NULL)) as $types => $value) {
+  foreach (node_tasklist_get_enabled_types() as $types => $value) {
     if ("$type" == "$value") {
 
       if (user_access('edit any ' . $type . ' content')  || user_access('edit own ' . $type . ' content')) {
@@ -174,9 +178,8 @@ function node_tasklist_page($type) {
  */
 function node_tasklist_cron() {
 
-  $type = variable_get(node_tasklist_type, 'page');
-
-  foreach (variable_get('node_tasklist_types', array(NULL => NULL)) as $type => $value) {
+  $type = variable_get('node_tasklist_type', 'page');
+  foreach (node_tasklist_get_enabled_types() as $type => $value) {
 
     // is this type enabled?
     if ("$type" == "$value") {
@@ -245,8 +248,7 @@ function node_tasklist_cron() {
  * Implementation of hook_block().
  */
 function node_tasklist_block($op = 'list', $delta = 0, $edit = array()) {
-
-  foreach (variable_get('node_tasklist_types', array(NULL => NULL)) as $type => $value) {
+  foreach (node_tasklist_get_enabled_types() as $type => $value) {
 
     if ($type === $value) {
 
-- 
1.7.1

