aye - sorry about not responding faster, I've written 3 different
versions of a workaround trying to think of the easiest way (you're
hacking the display won't work because the verifier ignores the
display and files of any type would be accepted).
I finally got it (it works! - no PHP coding!)
- For the main ('media') virtual root, in admin/formats uncheck
everything but ZIP
- Create a new virtual root in admin/cfgroot called 'submitall'
- In that virtual root, submitall/admin/formats check the formats you
want to allow
Now add the following two rules in .htaccess
RewriteRule ^(media/)?file/add/([0-9]+)$ submitall/file/add/$2 [L,R]
RewriteRule ^submitall/file/manage/([0-9]+)$ media/file/manage/$1 [L,R]
What's happening: When a user goes to submit a file in the main vroot,
they will only see ZIP and that will be what the verifier sees. When
they go to 'add/files' the browser will re-direct them to the virtual
root that allows more file types. The add/files form always redirects
back to 'file/manage' so we force redirect back to the main 'media'
On Mon, Aug 3, 2009 at 7:25 AM, Ben Weiner<ben@...> wrote:
> I want to have
> - new record form allow *only* ZIP uploads
> - add/replace file form allow some other formats.
> Is there somewhere I can manipulate the list of allowed formats to
> achieve this? They will all be either formats known to getId() and
> available in the list of formats here <cchost-root-url>/admin/formats or
> they will be pseudo-verified ones. Nothing completely unknown to the
> ccHost installation in question.
> I have done some looking around in the codebase. I guess that, as this
> is way off the design spec for ccHost, I will have to hack something in
> at page-generation time.
That will not work because the verification happens long after the
form is destroyed (i.e. on the _POST, not the _GET request)
You'll need to hook the validator and do a context sensitive switch on the fly
// pseudo code....
$current_url = cc_current_url();
if( $current_url == 'what_im_expecting' )
$path = $formatinfo->GetFilePath();
$id3 =& CCGetID3::InitID3Obj();
$tags = $id3->analyze($path);
if( empty($tags['zip']) )
$formatinfo->SetErrors('must be a zip file for the
submit form type');
// similar conditional stuff as above....
return new MyValidator();
$CC_UPLOAD_VALIDATOR = 'make_my_validator';
Of course this is missing dozens of lines of code required for error
checking etc. but I think you get the idea. You can find all that in
ccextras/cc-pseudo-verify.inc in the FileValidate section that handles
the CC_PV_VERIFY case.
Believe it or not, this is the least cumbersome way I can think of. In
the end it's simply a design flaw that doesn't allow for submit forms
to have different files types associated with them - there was the
same issue with licenses and I got around to fixing that in 5.1 but
didn't get to file types.