why does updated column not reflect album changes

freakout

Joined: 2011-05-15
Posts: 6
Posted: Tue, 2012-07-03 13:15

i use gallery3 not only by itself, but also with a standalone app.
the standalone app uses the gallery3 database and file store and
displays images in its own way. i use gallery3 as the back-end to
manage the images and have my own front-end to display the albums
and images.

for a specific reason i need to know when there are new images or
images were deleted. the "updated" column of items
type "album" does only reflect the last modification time of the
album itself but not when images are added or removed from the album.

how can i change that? any tips or source code fragments would be fine.

Thanks alot

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2012-07-03 14:07

You could write a module that has a listener for the creation and deletion of a item and in that function update a table or do something else:
item_before_create
item_before_delete
look for those functions for a clue.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
freakout

Joined: 2011-05-15
Posts: 6
Posted: Wed, 2012-07-04 10:35

I have made a module (my first) - it activates without problem - has only helper inside - but simply does nothing - no error messages - no log - deletes item - no update of album - please help:

modules/album_updated/helpers/album_updated.php :

<?php defined("SYSPATH") or die("No direct script access.");
class album_updated_Core {
  static function item_before_delete($itemi) {
    if ($itemi->is_photo()) {
      $albumi = $itemi->parent();
      $albumi->updated = time();
      $albumi->save();
    }
  }
}
?>
 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-07-04 13:37

I'm just guessing here...
The two or three other modules that use the item_before_delete() function have a class name that is:
class quotas_event_Core {
or
class videos_event_Core {
or
class keeporiginal_event_Core {

So I guess the _event_Core should be in the class name?

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
freakout

Joined: 2011-05-15
Posts: 6
Posted: Wed, 2012-07-04 14:23

does nothing - have also restarted webserver and de-/reactivated the module:

modules/album_updated/helpers/album_updated_event.php:

<?php defined("SYSPATH") or die("No direct script access.");
class album_updated_event_Core {
  static function item_before_delete($itemi) {
    error_log('album_updated_event_Core::item_before_delete');
  }
}
?>

when i patch this error_log into the core-code i see the log.
i'm lost here.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2012-07-04 23:44

So am I. I just copy and paste other modules code till I get something to work.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team