Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: mandatory description field using java?  (Read 2282 times)

0 Members and 1 Guest are viewing this topic.

crl

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 81
mandatory description field using java?
« 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?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: mandatory description field using java?
« Reply #1 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?
Logged

crl

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 81
Re: mandatory description field using java?
« Reply #2 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?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: mandatory description field using java?
« Reply #3 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__);
    }
Logged

crl

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Posts: 81
Re: mandatory description field using java?
« Reply #4 on: March 01, 2012, 06:36:24 pm »

Thank you  :)
It works!
Logged

Aero2012

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: mandatory description field using java?
« Reply #5 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 -
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: mandatory description field using java?
« Reply #6 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...
Logged

Aero2012

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: mandatory description field using java?
« Reply #7 on: March 09, 2012, 01:56:09 pm »

Thank You Andre
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 22 queries.