function patterns_save_pattern in Patterns 6.2
Same name and namespace in other branches
- 5 patterns.module \patterns_save_pattern()
- 6 patterns.module \patterns_save_pattern()
3 calls to patterns_save_pattern()
- patterns_edit_submit in ./
patterns.module - Submit edits to the pattern
- patterns_get_patterns in ./
patterns.module - patterns_import_server_submit in ./
patterns.module
File
- ./
patterns.module, line 1054 - Enables extremely simple adding/removing features to your site with minimal to no configuration
Code
function patterns_save_pattern($pattern, $path = '', $name = '') {
$title = $pattern['info']['title'];
$description = $pattern['info']['description'];
$author = $pattern['info']['author'];
if ($pid = db_result(db_query("SELECT pid FROM {patterns} WHERE name = '%s'", $name))) {
$updated = db_result(db_query("SELECT updated FROM {patterns} WHERE pid = '%d'", $pid));
if (($new_updated = filemtime($path)) > $updated) {
db_query("UPDATE {patterns} SET pattern = '%s', title = '%s', file = '%s', updated = '%s', description = '%s' WHERE pid = %d", serialize($pattern), $title, $path, $new_updated, $description, $pid);
}
else {
db_query("UPDATE {patterns} SET pattern = '%s', title = '%s', file = '%s', description = '%s' WHERE pid = %d", serialize($pattern), $title, $path, $description, $pid);
}
}
else {
db_query("INSERT INTO {patterns} (name, status, file, updated, enabled, title, description, pattern) VALUES ( '%s', 0, '%s', '%s', 0, '%s', '%s', '%s')", $name, $path, time(), $title, $description, serialize($pattern));
}
}