Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: mandatory description field using java?  (Read 2518 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: 15764
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: 15764
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: 15764
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.027 seconds with 20 queries.