You are here

function hosting_subdirs_nodeapi in Hosting 6.2

Implementation of hook_nodeapi().

File

subdirs/hosting_subdirs.module, line 27
Allow sites to be installed in subdirectories.

Code

function hosting_subdirs_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($node->type == 'site') {
    switch ($op) {
      case 'validate':
        $aliases = $node->aliases;
        $subdirs = array();
        foreach ($aliases as $alias) {

          // If we're adding a subdirectory alias, it can't begin with '/'.
          if (@strpos($alias, '/', 1)) {
            $subdirs[$alias] = explode('/', $alias, 2);
            hosting_alias_validate_subdir($node, $alias);

            // We only support one level of subdirectories, for now.
            if (@strpos($subdirs[$alias][1], '/')) {
              form_set_error('aliases', t('Multi-level subdirectories are not currently supported. Check the subdirectory for <em>@alias</em>, which is set to <em>@subdir</em>.', array(
                '@alias' => $alias,
                '@subdir' => $subdirs[$alias][1],
              )));
            }
          }
          else {

            // No subdirectory in use, so validate normally.
            hosting_alias_validate_alias($node, $alias);
          }
        }
        break;
    }
  }
}