summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--context.core.inc16
-rw-r--r--context.plugins.inc8
-rw-r--r--plugins/context_condition_user_page.inc20
3 files changed, 44 insertions, 0 deletions
diff --git a/context.core.inc b/context.core.inc
index 017b2bd..e635a68 100644
--- a/context.core.inc
+++ b/context.core.inc
@@ -27,6 +27,11 @@ function context_context_registry() {
'description' => t('Set this context when the current user has one of the selected role(s).'),
'plugin' => 'context_condition_user',
),
+ 'user_page' => array(
+ 'title' => t('User page'),
+ 'description' => t('Set this context when viewing a user page.'),
+ 'plugin' => 'context_condition_user_page',
+ ),
'menu' => array(
'title' => t('Menu'),
'description' => t('Set this context when any of the selected menu items belong to the current active menu trail.'),
@@ -266,6 +271,17 @@ function context_views_pre_view($view, $args) {
}
/**
+ * Implementation of hook_user().
+ */
+function context_user($op, &$edit, &$account, $category = NULL) {
+ if (in_array($op, array('view', 'form', 'register'))) {
+ if ($plugin = context_get_plugin('condition', 'user_page')) {
+ $plugin->execute($op);
+ }
+ }
+}
+
+/**
* BLOCK HANDLING =====================================================
*/
diff --git a/context.plugins.inc b/context.plugins.inc
index 1581580..bf9424c 100644
--- a/context.plugins.inc
+++ b/context.plugins.inc
@@ -49,6 +49,14 @@ function _context_context_plugins() {
'parent' => 'context_condition',
),
);
+ $plugins['context_condition_user_page'] = array(
+ 'handler' => array(
+ 'path' => drupal_get_path('module', 'context') .'/plugins',
+ 'file' => 'context_condition_user_page.inc',
+ 'class' => 'context_condition_user_page',
+ 'parent' => 'context_condition',
+ ),
+ );
$plugins['context_condition_menu'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') .'/plugins',
diff --git a/plugins/context_condition_user_page.inc b/plugins/context_condition_user_page.inc
new file mode 100644
index 0000000..ab62413
--- /dev/null
+++ b/plugins/context_condition_user_page.inc
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Expose user pages as a context condition.
+ */
+class context_condition_user_page extends context_condition {
+ function condition_values() {
+ $values = array();
+ $values['view'] = t('User profile');
+ $values['form'] = t('User account form');
+ $values['register'] = t('Registration form');
+ return $values;
+ }
+
+ function execute($op) {
+ foreach ($this->get_contexts($op) as $context) {
+ $this->condition_met($context);
+ }
+ }
+}