coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: tantley on March 29, 2007, 06:50:33 PM

Title: list_MediaCount function > count ALL items rather than public-only items
Post by: tantley on March 29, 2007, 06:50:33 PM
Using CPG 1.4.10 & cpmFetch 1.6.4

I have groups enabled in CPG; unregistered visitors see a portion of the available images whereas registered can see all.

Currently, I am utilizing Ecto's code for counting items in the cpg_pictures table in MySQL. (See thread (http://forum.coppermine-gallery.net/index.php?topic=26227.msg120914#msg120914))

Using cpmFetch, the list_MediaCount function reports 1,694 items (as this is the number of 'public' images as per the docs).

Is there a method to have cpmFetch dynamically retrieve the total number of ALL categories, regardless of access grouping?

I wish to display that number to visitors in order to encourage registration.

Could not locate any relevant topic with search here or on FistFullOfCode.com that I could understand.

Thanks for this awesome utility. Very powerful and handy to have around!
Title: Re: list_MediaCount function > count ALL items rather than public-only items
Post by: vuud on March 29, 2007, 08:29:45 PM
Quote from: tantley on March 29, 2007, 06:50:33 PM
Using CPG 1.4.10 & cpmFetch 1.6.4

I have groups enabled in CPG; unregistered visitors see a portion of the available images whereas registered can see all.

Currently, I am utilizing Ecto's code for counting items in the cpg_pictures table in MySQL. (See thread (http://forum.coppermine-gallery.net/index.php?topic=26227.msg120914#msg120914))

Using cpmFetch, the list_MediaCount function reports 1,694 items (as this is the number of 'public' images as per the docs).

Is there a method to have cpmFetch dynamically retrieve the total number of ALL categories, regardless of access grouping?

I wish to display that number to visitors in order to encourage registration.

Could not locate any relevant topic with search here or on FistFullOfCode.com that I could understand.

Thanks for this awesome utility. Very powerful and handy to have around!


Hmmm, one of the functions used to do that, but I think I optimized it into working the way everything else does.

No matter.

To unlock the private images just call

$objCpm->cpm_unlockPrivate(true);

before you call the cpm_listMediaCount()

Mind you that from that point forward, any call will have access to private photos.

Guess how you change it back?

$objCpm->cpm_unlockPrivate(false);


Will that work for you?








Title: Re: list_MediaCount function > count ALL items rather than public-only items
Post by: tantley on March 29, 2007, 08:33:43 PM
After a few hours of working with the code and reading docs, I happened upon the "cpm_Unlock_Private" function. It was referred to as "cpm_unlockPrivate" in the online docs- thus confusing me until I looked directly at the function code in "cpmfetch.php". Once I called the function with the missing "_", it worked properly.

This code, when called with a non-zero value, will allow the count to include ALL items in CPG rather than just public. Also see "cpm_formatStats" for better formatting options.

<?php

include_once "../cpmfetch/cpmfetch.php";

$bool 1;

$objCpm = new cpm('/media_server');
$objCpm->cpm_unlock_Private($bool);
$objCpm->cpm_listMediaCount();
$objCpm->cpm_close();

?>


I always hate it when I find the answer myself- because I search and try multiple things before I ever post. Well, maybe this will help someone else...
Title: Re: list_MediaCount function > count ALL items rather than public-only items
Post by: tantley on March 29, 2007, 08:38:09 PM
Guess I worked too long on my previous post.

Thanks for the reply, just the same. I'm learning PHP, so this has been quite an adventure.
Title: Re: list_MediaCount function > count ALL items rather than public-only items
Post by: vuud on March 29, 2007, 09:45:44 PM
Quote from: tantley on March 29, 2007, 08:38:09 PM
Guess I worked too long on my previous post.

Thanks for the reply, just the same. I'm learning PHP, so this has been quite an adventure.

Yeah, the doc's may or may not be correct on that code.  I do know that in CpmFetch 2.0 (which will be the new stable very soon), you will need to unlock it first.  Changes to the backend and all...