forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: crl on February 22, 2012, 01:49:54 am

Title: mandatory description field using java?
Post by: crl on February 22, 2012, 01:49:54 am
I have a problem with gallery users not adding information to the description field when uploading their own images, thjs field needs to be made mandatory.  There is a similar old thread using a java script, unfortunately it'd for version 1.3 http://forum.coppermine-gallery.net/index.php/topic,20965.0.html  is there a similar script for 1.5?
Title: Re: mandatory description field using java?
Post by: Αndré on February 24, 2012, 04:35:53 pm
As JavaScript (not Java!) is client-sided it's no reliable way to make a field mandatory. However, as the flash uploader first adds the files to the gallery and the meta album is added later, the only way to make the description field mandatory is to disable the flash uploader for your users and only provide the single HTML upload form. Is this suitable for your gallery?
Title: Re: mandatory description field using java?
Post by: crl on February 25, 2012, 01:01:39 am
There's no problem disabling the flash uploader and jut use the single HTML uploader.  If I go along this route how do I then make the description field mandatory?
Title: Re: mandatory description field using java?
Post by: Αndré on March 01, 2012, 03:40:59 pm
To reject pictures without a file description, open db_input.php, find
Code: [Select]
    // Test if the filename of the temporary uploaded picture is empty
    // getRaw is safe here since this filename is generated by the server
    if ($superCage->files->getRaw("/userpicture/tmp_name") == '') {
        cpg_die(ERROR, $lang_db_input_php['no_pic_uploaded'], __FILE__, __LINE__);
    }
and below, add
Code: [Select]
    if (trim($superCage->post->getRaw("caption")) == '') {
        cpg_die(ERROR, 'You need to enter a file description', __FILE__, __LINE__);
    }
Title: Re: mandatory description field using java?
Post by: crl on March 01, 2012, 06:36:24 pm
Thank you  :)
It works!
Title: Re: mandatory description field using java?
Post by: Aero2012 on March 08, 2012, 07:18:03 pm
Does this work for Custom Fields too? If not, how may I may Custom Fields Mandatory?

Thanks in Advance -
Title: Re: mandatory description field using java?
Post by: Αndré on March 08, 2012, 07:58:18 pm
To make user field 1 mandatory, use something like
Code: [Select]
    if (trim($superCage->post->getRaw("user1")) == '') {
        cpg_die(ERROR, 'Your error message here', __FILE__, __LINE__);
    }
and so on...
Title: Re: mandatory description field using java?
Post by: Aero2012 on March 09, 2012, 01:56:09 pm
Thank You Andre