[wp-hackers] NextGen Photo Album Plugin Patch

David J. Bisset dbisset at dimensionmedia.com
Thu Jun 26 19:38:34 GMT 2008

I am working on a patch for NextGen album plugin on behalf of a client.

As part of the project, I added this function to the plugin

// TRR - NEW function - adds a new gallery to the default album (i.e  
the lowest Numbered
function addToDefaultAlbum ($galleryid){
         global $wpdb, $ngg_options;

         list ($firstAlbum,$sortorder) = $wpdb->get_results("SELECT  
id,sortorder FROM
$wpdb->nggalbum ORDER BY id ASC LIMIT 1");
         $sort_array = unserialize($sortorder);
// if something went wrong, initialize to empty array
         if (!is_array($sort_array)) $sort_array = array();
// Adding first Gallery to end of the array
         $sort_array[] = $galleryid;

// Put it back where you found it
         $sortorder = serialize($sort_array);
         //$result = $wpdb->query(" UPDATE $wpdb->nggalbum SET  
sortorder = '0' WHERE id =
$firstAlbum ");
// TRR - END

If I uncomment the wpdb->query at the end of the function, the plugin  
dies during
activation complaining that a function in the same file (using an INIT  
callback) has been
previously declared. Specifically - Fatal error: Cannot redeclare  
(previously declared in
/sites/wptest/wp-content/plugins/nextgen-gallery/nggallery.php:121) in
/sites/wptest/wp-content/plugins/nextgen-gallery/nggallery.php on line 122

If I were doing an include or causing some recursion in my code - I'd  
figure that out.
But I can toggle the error by uncommenting this line.

Any insight (or brickbats) would greatly be appreciated.

David Bisset
Director of Web Development
Dimension Media, Inc.

More information about the wp-hackers mailing list