1
rennevat
xcgallery hack to limit each user to one photo
  • 2008/12/1 17:52

  • rennevat

  • Just popping in

  • Posts: 6

  • Since: 2006/4/30


Would it be possible to restrict each user with a group to submitting only one photo to a public album?

2
rennevat
Re: xcgallery hack to limit each user to one photo
  • 2008/12/17 21:48

  • rennevat

  • Just popping in

  • Posts: 6

  • Since: 2006/4/30


I'm would like to limit users to uploading one photo and am still unable to resolve this. In include/init.inc.php around line 172, I am trying unsuccessfully with the following code:

if ($ugroup['can_upload_pictures'] == 1) {

$query = "SELECT pid FROM ".$xoopsDB->prefix("xcgal_pictures")." WHERE owner_id=".USER_ID." ";
$user_count = mysql_num_rows($query);

if ($user_count >= 1) {
$USER_DATA['can_upload_pictures'] = 0;
}


if ($user_count < 1) {
$USER_DATA['can_upload_pictures'] = $ugroup['can_upload_pictures'];
}
}

3
Anonymous
Re: xcgallery hack to limit each user to one photo
  • 2008/12/17 23:21

  • Anonymous

  • Posts: 0

  • Since:


I made this function but you need to test it:

add onlyonepic function to include/functions.inc.php file
function onlyonepic($owner_id) {
    global 
$xoopsDB;
    
$onepic "SELECT COUNT(*) FROM ".$xoopsDB->prefix('xcgal_pictures')." WHERE owner_id = '".$owner_id."'";
    
$resultlimit $xoopsDB->query($onepic);
    list(
$count) = $xoopsDB->fetchRow($resultlimit);
    if (
$count == 0) {
    
redirect_header('index.php',2,_MD_PERM_DENIED);
    die;
    }
}


edit upload.php file then add:

onlyonepic($owner_id);

after this line at the top:

require('include/init.inc.php');

4
rennevat
Re: xcgallery hack to limit each user to one photo
  • 2008/12/18 21:48

  • rennevat

  • Just popping in

  • Posts: 6

  • Since: 2006/4/30


Thank you!! Your code helped put me on the right track and now it's working perfectly from within init.inc.php at line 172. I've modified it further to only search certain albums and assigned "finished" to enable certain messages.

if ($ugroup['can_upload_pictures'] == 1) {


$onepic = "SELECT COUNT(*) FROM ".$xoopsDB->prefix('xcgal_pictures')." WHERE (aid = 1 OR aid = 2 OR aid = 3) AND owner_id = '".$xoopsUser->getVar('uid')."'";
$resultlimit = $xoopsDB->query($onepic);
list($count) = $xoopsDB->fetchRow($resultlimit);
if ($count != 0) {
$USER_DATA['can_upload_pictures'] = 0;
$USER_DATA['finished'] = 1;
}
if ($count == 0) {
$USER_DATA['can_upload_pictures'] = $ugroup['can_upload_pictures'];
$USER_DATA['finished'] = 0;
}
}

Login

Who's Online

257 user(s) are online (211 user(s) are browsing Support Forums)


Members: 0


Guests: 257


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits