In the AlbumDB.php source, the following numPhotos() function exists:
===============================
function numPhotos($user) {
$numPhotos = 0;
foreach ($this->albumList as $album) {
if ($user->canWriteToAlbum($album)) {
$numPhotos += $album->numPhotos(1);
} else if ($user->canReadAlbum($album)) {
$numPhotos += $album->numPhotos(0);
}
}
return $numPhotos;
================================
The purpose of this function is to return the number of individual photos in a given album.
I am having problems debugging this function to determine exactly how the function is determining the number of photographs in the album. The albumList array (albumList) is passed and each album name ($album) is then looked at. But I cannot figure out how/why the $numPhotos index is being incremented.
There is a bug in the random-photo block for the Geeklog plug-in which is causing the site to bomb based on information this function is providing. So I am trying to better understand how this function returns the number of photos so that I can resolve the problem. I have 99% of it figured out now and am just stuck on this part.
I am only semi-proficient in PHP and would appreciate any advice/guidance in this.
Thanks in advance!!!
Eddie
Posts: 19
The key to the counting function is this line:
foreach ($this->albumList as $album) {
it finds each $this which is a photo in a particular album, and for every photo it goes through the loop once and runs this line:
numPhotos += $album->numPhotos(1);
that line increments the $album->numPhotos by 1 if the user has access to the album, otherwise the function runs a different line which increments by 0 (does not increment).
If you have any other questions I would be happy to try and help, just drop me a line by e-mail.
-- Dave