You are here

function _optimizely_duplicate_check in Optimizely 7.2

Same name and namespace in other branches
  1. 7.3 optimizely.admin.inc \_optimizely_duplicate_check()
1 call to _optimizely_duplicate_check()
_optimizely_unique_paths in ./optimizely.admin.inc

File

./optimizely.admin.inc, line 844
Admin page callback for the Optimizely module.

Code

function _optimizely_duplicate_check($paths) {
  $unreviewed_paths = $paths;

  // Check all of the paths
  foreach ($paths as $path) {

    // Remove path that's being processed from  the front of the list
    array_shift($unreviewed_paths);

    // "*" found in path
    if (strpos($path, '*') !== FALSE) {

      // Look for wild card match that's not site wide (posiiton not zero (0))
      if (strpos($path, '*') !== 0) {
        $path = substr($path, 0, -2);
        foreach ($unreviewed_paths as $unreviewed_path) {
          if (strpos($unreviewed_path, $path) !== FALSE) {
            return $path . '/*';
          }
        }
      }
      elseif (strpos($path, '*') === 0 && count($paths) > 1) {
        return $path;
      }
    }
    elseif (in_array($path, $unreviewed_paths)) {
      return $path;
    }
  }
  return FALSE;
}