From 58ea8d18e77d2f2a179cca1602caaba3fe0b8c1a Mon Sep 17 00:00:00 2001
From: Andrew Berry <deviantintegral@gmail.com>
Date: Wed, 4 May 2011 13:20:55 -0400
Subject: [PATCH 1/5] #1147062: Add the initial ooyala_channels.info file.

---
 ooyala_channels/ooyala_channels.info |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
 create mode 100755 ooyala_channels/ooyala_channels.info

diff --git a/ooyala_channels/ooyala_channels.info b/ooyala_channels/ooyala_channels.info
new file mode 100755
index 0000000..152bea2
--- /dev/null
+++ b/ooyala_channels/ooyala_channels.info
@@ -0,0 +1,6 @@
+name = Ooyala Channels
+description = Allows the creation and management of Channels from the <a href="http://www.ooyala.com">Ooyala</a> video service.
+core = 6.x
+package = Ooyala
+dependencies[] = ooyala
+
-- 
1.7.4.4


From 823af653f2b72a6e528e0cde71576feab87cb625 Mon Sep 17 00:00:00 2001
From: Andrew Berry <deviantintegral@gmail.com>
Date: Wed, 4 May 2011 13:44:28 -0400
Subject: [PATCH 2/5] #1147066: Add the initial node type settings form for
 Ooyala channels.

---
 ooyala_channels/ooyala_channels.module |   33 ++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)
 create mode 100644 ooyala_channels/ooyala_channels.module

diff --git a/ooyala_channels/ooyala_channels.module b/ooyala_channels/ooyala_channels.module
new file mode 100644
index 0000000..e04261e
--- /dev/null
+++ b/ooyala_channels/ooyala_channels.module
@@ -0,0 +1,33 @@
+<?php
+
+/**
+ * @file
+ * Add support for Ooyala channels to Drupal.
+ */
+
+
+/**
+ * Implementation of hook_form_alter()
+ */
+function ooyala_channels_form_alter(&$form, $form_state, $form_id) {
+  switch ($form_id) {
+    case 'node_type_form':
+      $node_type = $form['#node_type']->type;
+      $node_type_name = $form['#node_type']->name;
+
+      $form['ooyala_channels'] = array(
+        '#type' => 'fieldset',
+        '#title' => t('Ooyala channels settings'),
+        '#collapsed' => TRUE,
+        '#collapsible' => TRUE,
+      );
+
+      $form['ooyala_channels']['ooyala_channels_enabled'] = array(
+        '#type' => 'checkbox',
+        '#title' => t("Associate Ooyala channels with the %type content type", array('%type' => $node_type_name)),
+        '#default_value' => variable_get('ooyala_channels_enabled_' . $node_type, FALSE),
+      );
+  }
+}
+
+
-- 
1.7.4.4


From 744c3f0b4a9111819bdd0bbccc09388f03698d25 Mon Sep 17 00:00:00 2001
From: Andrew Berry <deviantintegral@gmail.com>
Date: Wed, 4 May 2011 13:58:02 -0400
Subject: [PATCH 3/5] #1147066: Only allow configuring of Ooyala channels if
 Ooyala has been set up.

---
 ooyala_channels/ooyala_channels.module |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/ooyala_channels/ooyala_channels.module b/ooyala_channels/ooyala_channels.module
index e04261e..0e006f7 100644
--- a/ooyala_channels/ooyala_channels.module
+++ b/ooyala_channels/ooyala_channels.module
@@ -22,6 +22,15 @@ function ooyala_channels_form_alter(&$form, $form_state, $form_id) {
         '#collapsible' => TRUE,
       );
 
+      if (!variable_get('ooyala_global_pcode', '')) {
+        $form['ooyala_channels']['ooyala_configure_help'] = array(
+          '#prefix' => '<p>',
+          '#value' => t('Before you can create or manage Ooyala channels, you need to <a href="@ooyala-settings">configure your site for syncronizing with Ooyala</a>.', array('@ooyala-settings' => url('admin/settings/ooyala'))),
+          '#suffix' => '</p>',
+        );
+        return;
+      }
+
       $form['ooyala_channels']['ooyala_channels_enabled'] = array(
         '#type' => 'checkbox',
         '#title' => t("Associate Ooyala channels with the %type content type", array('%type' => $node_type_name)),
-- 
1.7.4.4


From abb8203dd280755780e0c0fd0c5cd01cb6b5e835 Mon Sep 17 00:00:00 2001
From: Andrew Berry <deviantintegral@gmail.com>
Date: Wed, 4 May 2011 14:16:19 -0400
Subject: [PATCH 4/5] #1147066: Clean up content type variables when deleting
 a content type or uninstalling Ooyala Chapters.

---
 ooyala_channels/ooyala_channels.install |   14 ++++++++++++++
 ooyala_channels/ooyala_channels.module  |   12 ++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)
 create mode 100644 ooyala_channels/ooyala_channels.install

diff --git a/ooyala_channels/ooyala_channels.install b/ooyala_channels/ooyala_channels.install
new file mode 100644
index 0000000..b955361
--- /dev/null
+++ b/ooyala_channels/ooyala_channels.install
@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * @file
+ * Install and uninstall hooks for the Ooyala Channels module.
+ */
+
+/**
+ * Implementation of hook_uninstall()
+ */
+function ooyala_channels_uninstall() {
+  db_query("DELETE FROM {variable} WHERE name LIKE 'ooyala_channels_enabled_%'");
+}
+
diff --git a/ooyala_channels/ooyala_channels.module b/ooyala_channels/ooyala_channels.module
index 0e006f7..36215c3 100644
--- a/ooyala_channels/ooyala_channels.module
+++ b/ooyala_channels/ooyala_channels.module
@@ -40,3 +40,15 @@ function ooyala_channels_form_alter(&$form, $form_state, $form_id) {
 }
 
 
+/**
+ * Implementation of hook_node_type()
+ */
+function ooyala_channels_node_type($op, $info) {
+  switch ($op) {
+    case "delete":
+      variable_del('ooyala_channels_enabled_' . $info->type);
+      break;
+  }
+}
+
+
-- 
1.7.4.4


From 88d6379912426a6e47b3408012e3cf19c581cc0e Mon Sep 17 00:00:00 2001
From: Andrew Berry <deviantintegral@gmail.com>
Date: Wed, 4 May 2011 17:24:48 -0400
Subject: [PATCH 5/5] #1147066: Change return to break when Ooyala has not
 been configured when viewing a content type settings
 page.

---
 ooyala_channels/ooyala_channels.module |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ooyala_channels/ooyala_channels.module b/ooyala_channels/ooyala_channels.module
index 36215c3..c7935ed 100644
--- a/ooyala_channels/ooyala_channels.module
+++ b/ooyala_channels/ooyala_channels.module
@@ -28,7 +28,7 @@ function ooyala_channels_form_alter(&$form, $form_state, $form_id) {
           '#value' => t('Before you can create or manage Ooyala channels, you need to <a href="@ooyala-settings">configure your site for syncronizing with Ooyala</a>.', array('@ooyala-settings' => url('admin/settings/ooyala'))),
           '#suffix' => '</p>',
         );
-        return;
+        break;
       }
 
       $form['ooyala_channels']['ooyala_channels_enabled'] = array(
-- 
1.7.4.4

