While i was working on a view that display the files according to the file schema type(private/public) i notice that it not exists. I wrote a patch that contain the filter criteria by the file schema type.

Files: 
CommentFileSizeAuthor
#19 filter-by-file-schema-type-1881356-19.patch2.59 KBjorisdejong
PASSED: [[SimpleTest]]: [MySQL] 874 pass(es).
[ View ]
#16 filter-by-file-schema-type-1881356-16.patch2.58 KBjorisdejong
PASSED: [[SimpleTest]]: [MySQL] 874 pass(es).
[ View ]
#14 filter-by-file-schema-type-1881356-12.patch2.5 KBMPetrovic
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch filter-by-file-schema-type-1881356-12.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#12 filter-by-file-schema-type-1881356-11.patch1.97 KBMPetrovic
PASSED: [[SimpleTest]]: [MySQL] 874 pass(es).
[ View ]
#10 filter-by-file-schema-type-1881356-10.patch2.34 KBRoySegall
PASSED: [[SimpleTest]]: [MySQL] 823 pass(es).
[ View ]
#7 filter-by-file-schema-type-1881356-7.patch2.39 KBRoySegall
PASSED: [[SimpleTest]]: [MySQL] 308 pass(es).
[ View ]
#3 filter-by-file-schema-type-1881356-3.patch2.28 KBRoySegall
PASSED: [[SimpleTest]]: [MySQL] 296 pass(es).
[ View ]
filter-by-file-schema-type.patch2.28 KBRoySegall
PASSED: [[SimpleTest]]: [MySQL] 296 pass(es).
[ View ]

Comments

Status:Needs work» Needs review

Status:Needs review» Needs work

+++ b/views/views_handler_filter_scehma_type.incundefined
@@ -0,0 +1,42 @@
+      '#title' => t('Scehma type'),
+      '#description' => t('Display files by the scehma type.'),

Typos

Status:Needs work» Needs review
StatusFileSize
new2.28 KB
PASSED: [[SimpleTest]]: [MySQL] 296 pass(es).
[ View ]

Status:Needs review» Needs work

#3 looks good but it seems like it is hardcoded to either public or private stream wrappers?

I'd suggest using file_get_stream_wrappers() to enable filtering by other schemes like those provided by projects such as Remote stream wrapper and AmazonS3.

Not stream wrappers - Schema type. As far as i know, in drupal there is two types of file schema: public and private.

The schema type of the file is the stream wrapper used, so Devin is correct this needs to support everything in file_get_stream_wrappers() that also has the 'visible' flag. There should be an file entity API function that can already be used to get the visible stream wrappers.

Status:Needs work» Needs review
StatusFileSize
new2.39 KB
PASSED: [[SimpleTest]]: [MySQL] 308 pass(es).
[ View ]

There's a typo in the filename and also in the class name: views_handler_filter_scehma_type.inc (scehma)

I've tried out this filter. It basically works, but lacks of some basic configuration options:

There is no operator to choose. At least the possibility to reverse the filter in order to exclude a specific scheme would be nice. Now, if you have a couple of filters and want to exclude only one of them, you would have to insert multiple schema filters for all the remaining schemas in an Views filter group with an OR condition - at least theoratically. Because that didn't work for me and resulted in an empty search result.

I ended up in removing this filter and using a filter on the file's path with the condition set, that the path should not start with "private://" and it worked better for me

StatusFileSize
new2.34 KB
PASSED: [[SimpleTest]]: [MySQL] 823 pass(es).
[ View ]

Re rolling and fix typos.

Status:Needs review» Needs work

This is a good start. However we need to address the concerns about the operator's in #9. Additionally, it does not work if you expose the filter. Lastly, we need to change the administrative description which currently reads "Filter files by private/public schema." I am not certain offhand what would be better, but an example would be if you are using, for instance, the media youtube module to add a youtube schema. Maybe we can have something like "filter files by their schema, such as private/public." Lastly lastly, I noticed that it allows you to select temporary files and I am not certain if those would be considered visible. And finally (for real), I think it would be better to have checkboxes to allow for multiple selections.

StatusFileSize
new1.97 KB
PASSED: [[SimpleTest]]: [MySQL] 874 pass(es).
[ View ]

This filter wasn't working for us either. Here's a new version that's more flexible.

Status:Needs work» Needs review

StatusFileSize
new2.5 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch filter-by-file-schema-type-1881356-12.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Missed a couple things

Status:Needs review» Needs work

The last submitted patch, filter-by-file-schema-type-1881356-12.patch, failed testing.

Issue summary:View changes
StatusFileSize
new2.58 KB
PASSED: [[SimpleTest]]: [MySQL] 874 pass(es).
[ View ]

Hi there,

I have recreated MPetrovic's #14 patch against the latest 7.x-2.x branch. Let's see if it gets passed by testbot.

Status:Needs work» Needs review

Status:Needs review» Needs work

Minor coding standart:

+++ b/views/views_handler_filter_schema_type.inc
@@ -0,0 +1,44 @@
+      $statements[] = 'uri '.$nope.'LIKE \''.db_like($schema).'://%\'';

=> $statements[] = 'uri ' . $nope . 'LIKE \'' . db_like($schema) . '://%\'';

StatusFileSize
new2.59 KB
PASSED: [[SimpleTest]]: [MySQL] 874 pass(es).
[ View ]

Made this small change in code, including your coding standard fix :)

$not_in = $this->operator == 'not in' ? TRUE : FALSE;
$schema_operator = $not_in ? 'NOT LIKE' : 'LIKE';
$composite = $not_in ? ' AND ' : ' OR ';
foreach ($this->value as $schema) {
  $statements[] = 'uri ' . $schema_operator . ' \'' . db_like($schema) . '://%\'';
}

Status:Needs work» Needs review