Delete all Galleries in a group Delete all Galleries in a group
 

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

Main Menu

Delete all Galleries in a group

Started by the_todd, June 01, 2005, 07:07:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

the_todd

I used to let everyone in my PHPBB forum have galleries and such with 7 megs who were all under the "members group" then you get put into groups with higher storage based on the number of posts you have. I about a month ago changed the members group to 0 megs storage  because i'm out of storage on my server but all the galleries and files of those users are still there. I need to get rid of them.

Is there a way to delete all galleries and pictures in a usergroup?

Thanks,
Todd

Joachim Müller

out-of-the-box (using coppermine user interface): no!
You would have to come up with a custom query that would select all pics of user that are member of certain groups (a join), then delete both the files and the database entries.

the_todd

ok, I decided to do this on my own, so I went to the library today at my university and grabbed a pair of php books, and after a couple hours I have made the following script.
So far just ouputs in an array all of the userid's which need to have their galleries deleted (in my case,phpbb users with no assigned group)
Before I dig myself in a deeper hole what is the best way to go about deleting the galleries. Where / what is the code that coppermine uses to delete galleries, and what would be the best way to go.

<?php
include 'include/config.inc.php';
//excludegroup corresponds to members in usergroups whose galleries should not be deleted
$excludegroup1 2;
$excludegroup2 4;
$excludegroup3 6;
$excludegroup4 12;
$excludegroup5 14;
$excludegroup6 2;

$exuserarray = array();
$exspot 0;
$useridlist = array();
$counter 0;

mysql_select_db($CONFIG['dbname'], mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']))
or die(mysql_error());

$result mysql_query("SELECT group_id, user_id FROM `phpbb_user_group` ORDER BY group_id ASC");


echo 
'<table border = 1><tr><td>Username and GroupID</td></tr></table><table border = 1><tr><td>group_id</td><td>group name</td><td>user_id</td><TD>username</td></tr>';


while(
$group_result mysql_fetch_array($result)){
if($group_result['group_id'] == $excludegroup1 or $group_result['group_id'] == $excludegroup2 or $group_result['group_id'] == $excludegroup3
or $group_result['group_id'] == $excludegroup4 or $group_result['group_id'] == $excludegroup5 or $group_result['group_id'] == $excludegroup6){

$exuserarray[$exspot] = $group_result['user_id'];
$exspot += 1;

if(in_array($group_result['user_id'], $exuserarray)) {} else {
$group $group_result['group_id'];
$userid $group_result['user_id'];

echo '<tr><td>'.$group.'</td>';

$groupnameresult mysql_query("SELECT group_name FROM `phpbb_groups` WHERE group_id = $group");
$groupname_result mysql_fetch_array($groupnameresult);
echo '<td>'.$groupname_result[group_name].'</td>';


echo '<td>'.$userid.'</td>';

$userresult mysql_query("SELECT username FROM `phpbb_users` WHERE user_id = $userid");
$username_result mysql_fetch_array($userresult);
echo '<td>'.$username_result['username'].'</td>'.'</tr>';

$useridlist[$counter] = $group_result['user_id'];
$counter += 1;
}
}

//remove duplicate userid's from the list and resort to tidy up.
$useridlist array_unique($useridlist);
sort($useridlist);

//print the excluded users array
echo '<table border = 1><tr><td> Excluded User Array </td><td>';
print_r($exuserarray);
echo 
'</td></tr></table>';

// print the userlist to have galleries deleted array (members without a group)
echo '<table border = 1><tr><td> User List Array </td><td>';
print_r($useridlist);
echo 
'</td></tr></table>';
?>


Thanks,
Todd

the_todd

Why is this marked solved, this is very much not solved...

Joachim Müller

I thought it was. Unsolved it for you.