context_condition_context.inc 749 B

1234567891011121314151617181920212223
  1. <?php
  2. /**
  3. * Expose active contexts as a context condition.
  4. */
  5. class context_condition_context extends context_condition_path {
  6. function execute() {
  7. if ($this->condition_used()) {
  8. $active_contexts = array_keys(context_active_contexts());
  9. foreach ($this->get_contexts() as $context) {
  10. if (!in_array($context->name, $active_contexts, TRUE) && $values = $this->fetch_from_context($context, 'values')) {
  11. if ($this->match($active_contexts, $values)) {
  12. $this->condition_met($context);
  13. }
  14. }
  15. }
  16. // If the list of active contexts has changed, we need to recurse.
  17. if ($active_contexts != array_keys(context_active_contexts())) {
  18. $this->execute();
  19. }
  20. }
  21. }
  22. }