set_filename('batch_global', dirname(__FILE__).'/batch_global.tpl'); // Fetch all the copyrights and assign them to the template $query = sprintf( 'SELECT `cr_id`,`name` FROM %s WHERE `visible`<>0 ;', COPYRIGHTS_ADMIN); $result = pwg_query($query); $CRoptions = array(); while ($row = pwg_db_fetch_assoc($result)) { $CRoptions[$row['cr_id']] = $row['name']; } $template->assign('CRoptions', $CRoptions); // Add info on the "choose action" dropdown in the batch manager $template->append('element_set_global_plugins_actions', array( 'ID' => 'copyrights', // ID of the batch manager action 'NAME' => l10n('Edit copyright'), // Description of the batch manager action 'CONTENT' => $template->parse('batch_global', true) ) ); } // * Deze functie wordt een keer aangeroepen, nadat de gebruiker submit. // * Fietst met een foreach loop over de geselecteerde fotos // * Rammelt alle toevoegingen in 1x met mass_updates naar de db. function copyrights_batch_global_submit($action, $collection) { // If its our plugin that is called if ($action == 'copyrights') { $crID = pwg_db_real_escape_string($_POST['copyrightID']); if (count($collection) > 0) { $query = sprintf( 'DELETE FROM %s WHERE media_id IN (%s) ;', COPYRIGHTS_MEDIA, implode(',', $collection)); pwg_query($query); } $edits = array(); foreach ($collection as $image_id) { array_push( $edits, array( 'media_id' => $image_id, 'cr_id' => $crID, ) ); } mass_inserts( COPYRIGHTS_MEDIA, // Table name array_keys($edits[0]), //Columns $edits // Data ); } } ?>