summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Petsovits2008-06-28 20:53:40 (GMT)
committer Jakob Petsovits2008-06-28 20:53:40 (GMT)
commitec0f42478fa7221a264b1615a4450029f5f4ee37 (patch)
tree0eda01d570a61bb305d26d234e9503d786254a79
parent876be3eae7c1d203830f7f61c1fc9088a386e637 (diff)
Move filefield_check_directory() next to filefield_file_upload(),
which is the only place where it's actually used. It had kind of an orphan status further down, which I didn't like.
-rw-r--r--filefield.module49
1 files changed, 25 insertions, 24 deletions
diff --git a/filefield.module b/filefield.module
index fe54421..23f7c2b 100644
--- a/filefield.module
+++ b/filefield.module
@@ -562,6 +562,31 @@ function filefield_file_upload(&$form_state, $field, $delta) {
}
/**
+ * Create the file directory relative to the 'files' dir recursively for every
+ * directory in the path.
+ *
+ * @param $directory
+ * The directory path under files to check, such as 'photo/path/here'.
+ * @param $form_item
+ * An optional string containing the name of a form item that any errors
+ * will be attached to. (See field_file_check_directory() for more details.)
+ */
+function filefield_check_directory($directory, $form_item = NULL) {
+ $directory = field_file_strip_path($directory);
+
+ foreach (explode('/', $directory) as $dir) {
+ $dirs[] = $dir;
+ $path = file_create_path(implode($dirs, '/'));
+ if (!field_file_check_directory($path, FILE_CREATE_DIRECTORY, $form_item)) {
+ watchdog('filefield', t('FileField failed to create directory (%d) at (%p).', array('%d' => $directory, '%p' => $path)), WATCHDOG_ERROR);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+
+/**
* The filefield widget for previously uploaded files.
*/
function filefield_file_edit_form(&$form, &$form_state, $field, $delta, $file) {
@@ -1187,30 +1212,6 @@ function filefield_file_download($file) {
);
}
-/**
- * Create the file directory relative to the 'files' dir recursively for every
- * directory in the path.
- *
- * @param $directory
- * The directory path under files to check, such as 'photo/path/here'
- * @param $form_item
- * An optional string containing the name of a form item that any errors
- * will be attached to. (See field_file_check_directory() for more details.)
- */
-function filefield_check_directory($directory, $form_item = NULL) {
- $directory = field_file_strip_path($directory);
-
- foreach (explode('/', $directory) as $dir) {
- $dirs[] = $dir;
- $path = file_create_path(implode($dirs, '/'));
- if (!field_file_check_directory($path, FILE_CREATE_DIRECTORY, $form_item)) {
- watchdog('filefield', t('FileField failed to create directory (%d) at (%p).', array('%d' => $directory, '%p' => $path)), WATCHDOG_ERROR);
- return FALSE;
- }
- }
- return TRUE;
-}
-
/**
* Implementation of hook_token_list():