You are here

function context_update_6002 in Context 6.3

Same name and namespace in other branches
  1. 6.2 context.install \context_update_6002()

Update script for API change in path condition.

File

./context.install, line 149

Code

function context_update_6002() {
  define('CONTEXT_STORAGE_DEFAULT', 0);
  define('CONTEXT_STORAGE_OVERRIDDEN', 1);
  define('CONTEXT_STORAGE_NORMAL', 2);

  // Iterate through all DB-stored contexts and incorporate path
  // wildcards into their path conditions. Any exported/default
  // contexts will need to be updated by hand.
  $contexts = context_enabled_contexts();
  foreach ($contexts as $context) {
    if (($context->type == CONTEXT_STORAGE_NORMAL || $context->type == CONTEXT_STORAGE_OVERRIDDEN) && (!empty($context->path) && is_array($context->path))) {
      $changed = FALSE;
      foreach ($context->path as $k => $v) {
        if ($v != '<front>' && strpos($v, '*') === FALSE) {
          $changed = TRUE;
          $context->path[$k] = "{$v}*";
        }
      }
      if ($changed) {
        context_save_context($context);
      }
    }
  }
  return array();
}