set_prefilter('picture_modify', 'EA_modify'); } function EA_modify($content, &$smarty) { // Replace the piwigo author by our own author stuff $search = '//is'; $replacement = ' '; return preg_replace($search, $replacement, $content); } function EA_add_modify_vars_to_template() { // Check if we are at the modify page (the problem is that this will send the stuff to every admin page that has an ?image_id... if (isset($_GET['image_id'])) { global $template; load_language('plugin.lang', dirname(__FILE__).'/'); // Fetch all the authors and assign them to the template $query = sprintf( 'SELECT `author_id`,`name` FROM %s ;', AUTHORS); $result = pwg_query($query); $EAoptions = array(); while ($row = pwg_db_fetch_assoc($result)) { $EAoptions[$row['author_id']] = $row['name']; } $template->assign('EAoptions', $EAoptions); // Get the current author $image_id = $_GET['image_id']; $query = sprintf( 'SELECT author FROM %s WHERE id = %d ;', IMAGES, $image_id); $result = pwg_query($query); $EAname = '--'; // Default is '--' while ($row = pwg_db_fetch_assoc($result)) { $EAname = $row['author']; } $template->assign('EAname', $EAname); } } function EA_modify_submit() { // Check if we are at the modify page (the problem is that this will send the stuff to every admin page that has an ?image_id... if (isset($_GET['image_id'])) { if (isset($_POST['submit'])) { // The data from the submit $image_id = $_GET['image_id']; $name = pwg_db_real_escape_string($_POST['author']); // Dont update anything when the name is empty if(!$name) return false; // Add him to the images table // (yes, this is double work, since the author will be set by the piwigo core. But its not set right now, and insert_default_CR needs it...) $query = sprintf( 'UPDATE %s SET author=\'%s\' WHERE id=%d ;', IMAGES, $name, $image_id); pwg_query($query); // Insert the default copyrights insert_default_CR($name); } } } ?>