Usergroup settings affecting cpmFetch Usergroup settings affecting cpmFetch
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Usergroup settings affecting cpmFetch

Started by joeyhavlock, July 21, 2007, 11:58:13 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

joeyhavlock

Hi Vuud and All,

I have cpmFetch working beautifully, but...

For images in cats/albums that require a usergroup membership, cpmFetch returns no images

For example I have some adult images in coppermine and it requires adult usergroup access to view

When I load cpmFetch on a page trying to look at those images, I get a nothing returned, just blank, no images even if the person viewing is in the usergroup or even me as administrator

Is there somewhere I can override this?


Thanks much
Joey


Nibbler

I think the cpm_unlock_private option is what you are looking for (but that will make them visible to everyone). Call that before you retrieve the images.

$obj->cpm_unlock_private(true);

Post your code if you need help doing that.

joeyhavlock

Thanks for the reply

I tried it, but got an error.

Here's my code:

  <?php
  include_once "../../coppermine/cpmfetch/cpmfetch.php";
  $objCpm = new cpm("../../coppermine/cpmfetch/cpmfetch_config-adult.php");
  $options = array("windowtarget" => "_top");
  $objCpm->cpm_viewRandomMediaFrom("Cat=5",1, 6, $options);
  $objCpm->cpm_close();
?>
</div>


Where would I put this code you are referring to:

   $obj->cpm_unlock_private(true);

if I put it in my code above, I get an error;

Fatal error: Call to a member function on a non-object in /home/content/m/u/s/museumcurator/html/community/fetch/coppermine-adult-mod1.php on line 16


Do I put this in the config file or the fetch file?
Thanks again
Joey

joeyhavlock

Sorry, knee jerk response...

It worked!  Thanks so much!  The code should have the 'Cpm' after the obj though, like below.

It's ok about everyone having access as inorder to get to the page where this is displayed you have to have the adult access priveledge anyway, so its perfect.


  $obj->cpm_unlock_private(true);

should be;

  $objCpm->cpm_unlock_private(true);

Thanks much Bud!
Joey

majay

Hi,

I have a related issue with the album count. Despite cpm_unlock_private being set to (true), which displays the total image and view count for the entire gallery (public and private) perfectly well, for some reason it won't show the total number of albums, only the public ones are taken into account. Can something else be added so that usergroup settings are overriden in albums too?

Thank you.

Nibbler

Looks like a bug to me. Modify cpmfetch_dao.php


/**
* Returns the number of albums in the database.
* @access public
*/
function getAlbumCount( ) {
$sqlcode = "SELECT {$this->sqlPostSelect} COUNT(*) as media_total FROM "
. $this->cfg['table_prefix']
. "albums AS a";

if ($this->privacyfilter != "") {
$sqlcode .= " WHERE a.visibility = 0" ;
}

$result = $this->dbExecuteSql($sqlcode);
return $this->resultArray[0]['media_total'];
}


And change the "" to " "


/**
* Returns the number of albums in the database.
* @access public
*/
function getAlbumCount( ) {
$sqlcode = "SELECT {$this->sqlPostSelect} COUNT(*) as media_total FROM "
. $this->cfg['table_prefix']
. "albums AS a";

if ($this->privacyfilter != " ") {
$sqlcode .= " WHERE a.visibility = 0" ;
}

$result = $this->dbExecuteSql($sqlcode);
return $this->resultArray[0]['media_total'];
}


That way it corresponds to the default value here:

'cfShowPrivateOnSqlDefault' => ' ',

Which is actually a space, not an empty string.

majay

Yes that did the trick! Thanks Nibbler!