Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: list_MediaCount function > count ALL items rather than public-only items  (Read 4854 times)

0 Members and 1 Guest are viewing this topic.

tantley

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 18
    • BayouMX

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)

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!
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code

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)

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?








Logged
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

tantley

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 18
    • BayouMX

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.

Code: [Select]
<?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...
Logged

tantley

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 18
    • BayouMX

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.
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code

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...

Logged
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco
Pages: [1]   Go Up
 

Page created in 0.039 seconds with 19 queries.