? LICENSE.txt
? mark_context_condition.patch
Index: mark.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mark/mark.module,v
retrieving revision 1.5
diff -u -p -r1.5 mark.module
--- mark.module	26 Apr 2010 03:01:43 -0000	1.5
+++ mark.module	14 Jun 2010 18:31:31 -0000
@@ -105,6 +105,64 @@ function mark_views_api() {
 }
 
 /**
+ * Implementation of hook_ctools_plugin_api().
+ */
+function mark_ctools_plugin_api($module, $api) {
+  if ($module == 'context' && $api == 'plugins') {
+    return array('version' => 3);
+  }
+}
+
+/**
+ * Implementation of hook_context_registry().
+ */
+function mark_context_registry() {
+  $registry = array();
+  $registry['conditions'] = array(
+    'mark' => array(
+      'title' => t('Mark'),
+      'description' => t('Set this context when viewing an object with the selected mark.'),
+      'plugin' => 'context_condition_mark',
+    ),
+  );
+  return $registry;
+}
+
+/**
+ * Implementation of hook_context_plugins().
+ */
+function mark_context_plugins() {
+  $plugins = array();
+  $plugins['context_condition_mark'] = array(
+    'handler' => array(
+      'path' => drupal_get_path('module', 'mark') .'/include',
+      'file' => 'context_condition_mark.inc',
+      'class' => 'context_condition_mark',
+      'parent' => 'context_condition',
+    ),
+  );
+  return $plugins;
+}
+
+/**
+ * Implementation of hook_context_condition_node_alter().
+ */
+function mark_context_node_condition_alter($node, $op) {
+  if (($op === 'view') && ($plugin = context_get_plugin('condition', 'mark'))) {
+    $plugin->execute('node', $node);
+  }
+}
+
+/**
+ * Implementation of hook_user().
+ */
+function mark_user($op, &$edit, &$account, $category = NULL) {
+  if (($op === 'view') && ($plugin = context_get_plugin('condition', 'mark'))) {
+    $plugin->execute('users', $account);
+  }
+}
+
+/**
  * Implementation of hook_votingapi_metadata_alter().
  */
 function mark_votingapi_metadata_alter(&$data) {
Index: include/context_condition_mark.inc
===================================================================
RCS file: include/context_condition_mark.inc
diff -N include/context_condition_mark.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ include/context_condition_mark.inc	14 Jun 2010 18:31:31 -0000
@@ -0,0 +1,33 @@
+<?php
+// $Id$
+
+class context_condition_mark extends context_condition {
+  function condition_values() {
+    $values = array();
+    foreach (mark_load() as $mark) {
+      $values[$mark->name] = $mark->name;
+    }
+    return $values;
+  }
+
+  function execute($basetable, $object) {
+    switch ($basetable) {
+      case 'users':
+        $id = isset($object->uid) ? $object->uid : FALSE;
+        break;
+      default:
+      case 'node':
+        $id = isset($object->nid) ? $object->nid : FALSE;
+        break;
+    }
+    if ($id && ($marks = mark_load($basetable, 'tables'))) {
+      foreach ($marks as $mark) {
+        if (mark_is_set($mark->name, $basetable, $id)) {
+          foreach ($this->get_contexts($mark->name) as $context) {
+            $this->condition_met($context, $mark->name);
+          }
+        }
+      }
+    }
+  }
+}
