## MOD Title: Multi-File Uploader
## MOD Author: mstralka < email > (Mark Stralka)
http://www.photo-junky.com## MOD Description: This mod will simplify the upload process by
## letting users see alll of the uploaded photos on one page,
## move them to different albums accordingly (or to the same
## album with 1 click), set descriptions, keywords, etc, instead
## of one image per page.
## Administrator can determine whether users will edit all
## uploaded photos at once, or individually.
## MOD Version: 2.0.0
## Built on CPG 1.3.2 - may work with 1.3.1 MODED by AWJ for 1.4.3
##
## Installation Level: Easy
## Installation Time: 10 minutes
## Files To Edit: lang/english.php
## upload.php
## Included Files: (screenshot)
##############################################################
## Author Notes:
##
These steps are in order from top to bottom. You have to
## be careful modding upload.php because a lot of the code is
## duplicated in different sections.##
This mod incorporates Frogfoot's fancy album dropdown MOD.
## You must install it first (takes 5 minutes)##
http://forum.coppermine-gallery.net/index.php?topic=8861.0##
Thanks to DefenceTalk for the MOD Instruction Template##############################################################
## MOD History:
##
## 2004-08-27 - Version 1.0.0
## - Original version, was not in line-by-line order,
## - no Admin option
##
##############################################################
## Before Adding This MOD To Your Site, You Should Back Up All Files
## Related To This MOD
Database query (use phpMyAdmin):
INSERT INTO `cpg143_config` ( `name` , `value` )
VALUES (
'allow_assign_multiple_photos', '0'
);
Adding this code will create a Yes/No option on the CONFIG page, under User Settings. The default value
is No, which means uploads will work just like they do now. Setting it to Yes will turn on the mod.
lang/english.php
FIND:
'User settings',
array('Allow new user registrations', 'allow_user_registration', 1),
array('User registration requires email verification', 'reg_requires_valid_email', 1),
ADD to end of User Settings section:
array('Allow users to assign uploaded photos at once (instead of one-at-a-time)','allow_assign_multiple_photos',1), //Mark Stralka cpg1.3.2
upload.php:
FIND:
// The function to create the album list drop down.
function form_alb_list_box($text, $name) {
REPLACE WITH:
// The function to create the album list drop down.
function form_alb_list_box($text, $name,$onChange='') {
FIND WITHIN:
// Create the opening of the drop down box.
Before ADD:
if (!empty($onChange)) {
$onChange = " onChange=\"$onChange\" ";
}
FIND WITHIN:
<select name="$name" class="listbox">
REPLACE WITH:
<select name="$name" class="listbox" $onChange>
FIND:
// The open_form function creates the Javascript verification code and the opening form tags.
// $path hold the form action path.
function open_form($path) {
echo <<<EOT
<script language="JavaScript">
function textCounter(field, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
}
</script>
<form method="post" action="$path" ENCTYPE="multipart/form-data">
</td>
EOT;
}
Replace with:
// The open_form function creates the Javascript verification code and the opening form tags.
// $path hold the form action path.
function open_form($path,$formName = "") {
if (!empty($formName)) $fn = "name=\"$formName\"";
echo <<<EOT
<script language="JavaScript" type="text/javascript">
function textCounter(field, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
}
</script>
<form method="post" action="$path" $fn ENCTYPE="multipart/form-data">
</td>
EOT;
}
FIND:
// Create array index.
$index = count($escrow_array) - 1;
Add this below:
$start = 0;
if ((int)$CONFIG['allow_assign_multiple_photos'] == 1) {
$iCnt = count($_POST["album"]);
} else {
$iCnt = $index + 1;
$start = $index;
}
//Instead of doing one photo at a time, show one page with all of the photos that are being uploaded - this makes it much easier for the users.
for ($index = $start; $index < $iCnt; $index++) {
FIND:
// We have incoming placement data. Let's capture it.
Add this below:
$x = $index;
if ((int)$CONFIG['allow_assign_multiple_photos'] == 0) {
$x = 0;
} else {
$x = $index;
}
FIND:
$album = (int)$_POST['album'];
$title = addslashes($_POST['title']);
$caption = addslashes($_POST['caption']);
$keywords = addslashes($_POST['keywords']);
$user1 = addslashes($_POST['user1']);
$user2 = addslashes($_POST['user2']);
$user3 = addslashes($_POST['user3']);
$user4 = addslashes($_POST['user4']);
Replace with:
$album = (int)$_POST['album'][$x];
$title = addslashes($_POST['title'][$x]);
$caption = addslashes($_POST['caption'][$x]);
$keywords = addslashes($_POST['keywords'][$x]);
$user1 = addslashes($_POST['user1'][$x]);
$user2 = addslashes($_POST['user2'][$x]);
$user3 = addslashes($_POST['user3'][$x]);
$user4 = addslashes($_POST['user4'][$x]);
FIND:
// Delete the temporary data file.
delete_record($_POST['unique_ID']);
BEFORE ADD:
if ((int)$CONFIG['allow_assign_multiple_photos'] == 0) {
FIND:
// Exit the script.
exit;
}
AFTER ADD:
}
} //end for loop
if ((int)$CONFIG['allow_assign_multiple_photos'] == 1) {
// Delete the temporary data file.
delete_record($_POST['unique_ID']);
// Send e-mail notification to the admin if requested (added by gaugau: 03-11-09).
if (($CONFIG['upl_notify_admin_email']) and ($PIC_NEED_APPROVAL)) {
// Encapsulate so included lang file doesn't interfere with global one
function cpg_send_upload_notification() {
global $CONFIG;
$lang_db_input_php = cpg_get_default_lang_var('lang_db_input_php');
// Get the mail files.
include_once('include/mailer.inc.php');
// Send the message.
cpg_mail('admin', sprintf($lang_db_input_php['notify_admin_email_subject'], $CONFIG['gallery_name']), sprintf($lang_db_input_php['notify_admin_email_body'], USER_NAME, $CONFIG['ecards_more_pic_target']. (substr( $CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/') .'editpics.php?mode=upload_approval' ));
}
cpg_send_upload_notification();
}
// That was the last one. Create a redirect box.
pageheader($lang_info);
msg_box($lang_info, $final_message, $lang_continue, 'index.php', "100%");
pagefooter();
// Exit the script.
exit;
}
}
FIND:
// Create array index.
$index = count($escrow_array) - 1;
ADD:
$start = 0;
if ((int)$CONFIG['allow_assign_multiple_photos'] == 1) {
$iCnt = count($escrow_array);
} else {
$iCnt = $index + 1;
$start = $index;
}
// Create upload form headers.
pageheader($lang_upload_php['title']);
echo <<<EOT
<script type="text/javascript">
function moveAllTo(d,box) {
var f = document.editForm;
for (i = 0; i < f.length; i++) {
if (f[i].type == "select-one" && f[i].name.indexOf(box) >= 0) {
f[i].value = d
}
}
}
</script>
EOT;
// Open the form table.
starttable("100%", $lang_upload_php['title'], 2);
echo <<<EOT
<tr>
<td class="tableh2">
All Photos:
</td>
<td class="tableh2">
EOT;
//MOVE TO ALL MOD
form_alb_list_box("Move all photos to:","moveAllTo","moveAllTo(this.value,'album');");
echo <<<EOT
</td>
</tr>
EOT;
// Direct the request to this script.
open_form($_SERVER['PHP_SELF'],'editForm');
//Display all of the photos at once for editing
for ($index = $start; $index < $iCnt; $index++) {
FIND and Delete or comment out:
// Create upload form headers.
pageheader($lang_upload_php['title']);
// Open the form table.
starttable("100%", $lang_upload_php['title'], 2);
// Direct the request to this script.
open_form($_SERVER['PHP_SELF']);
I DID THIS REALLY FAST SO PLEASE! Let me know if you get any errors and I can fix it within seconds for you guys.