You are here

function patterns_db_is_pattern_updated in Patterns 7.2

Same name and namespace in other branches
  1. 7 includes/db.inc \patterns_db_is_pattern_updated()

Compares the date of the last update in the database with the one in the file system and return TRUE if the file system has a newer copy of the pattern stored in the database.

Return TRUE also if it cannot finds the file in the fs.

Parameters

mixed $pattern A pattern object, an array representing: the pattern object, a numeric id or alphanumeric name of the pattern as it is in the database

3 calls to patterns_db_is_pattern_updated()
patterns_edit in includes/forms/editor.inc
Form constructor for editing a pattern. TODO:params
patterns_enable_pattern in ./patterns.module
Form constructor for the Patterns enabling form.
patterns_io_scan_directories in includes/io/io.inc
Scan directories looking for patterns files.

File

includes/db.inc, line 398
Retrieve, save, and remove patterns from the database.

Code

function patterns_db_is_pattern_updated($pattern = NULL) {
  $pattern = _patterns_db_get_pattern($pattern);
  if (empty($pattern)) {
    return FALSE;
  }
  if (!file_exists($pattern->file)) {
    return TRUE;
  }
  $new_updated = filemtime($pattern->file);
  $updated = $pattern->updated;
  if ($new_updated && !$updated) {
    return TRUE;
  }
  if ($updated && !$new_updated) {
    return FALSE;
  }
  if (!$updated && !$new_updated) {
    return FALSE;
  }
  if ($new_updated > $updated) {
    return TRUE;
  }
}