From 0ec91d8b4834d63c65dcbef6ac49ab5a8f68ddd1 Mon Sep 17 00:00:00 2001 From: z0rglub Date: Tue, 1 Jul 2003 09:27:20 +0000 Subject: *** empty log message *** git-svn-id: http://piwigo.org/svn/trunk@21 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/include/functions.php | 63 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 10 deletions(-) (limited to 'admin/include/functions.php') diff --git a/admin/include/functions.php b/admin/include/functions.php index c6678caf0..cd58d0822 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -101,13 +101,17 @@ function delete_category( $id ) { delete_image( $row['id'] ); } - - // destruction of the restrictions linked to the category - $query = 'DELETE FROM '.PREFIX_TABLE.'restrictions'; + + // destruction of the access linked to the category + $query = 'DELETE FROM '.PREFIX_TABLE.'user_access'; $query.= ' WHERE cat_id = '.$id; $query.= ';'; mysql_query( $query ); - + $query = 'DELETE FROM '.PREFIX_TABLE.'group_access'; + $query.= ' WHERE cat_id = '.$id; + $query.= ';'; + mysql_query( $query ); + // destruction of the sub-categories $query = 'SELECT id'; $query.= ' FROM '.PREFIX_TABLE.'categories'; @@ -118,7 +122,7 @@ function delete_category( $id ) { delete_category( $row['id'] ); } - + // destruction of the category $query = 'DELETE FROM '.PREFIX_TABLE.'categories'; $query.= ' WHERE id = '.$id; @@ -156,21 +160,35 @@ function delete_image( $id ) // The delete_user function delete a user identified by the $user_id // It also deletes : -// - all the restrictions linked to this user +// - all the access linked to this user +// - all the links to any group // - all the favorites linked to this user +// - all sessions linked to this user function delete_user( $user_id ) { - // destruction of the restrictions linked to the user - $query = 'DELETE FROM '.PREFIX_TABLE.'restrictions'; + // destruction of the access linked to the user + $query = 'DELETE FROM '.PREFIX_TABLE.'user_access'; $query.= ' WHERE user_id = '.$user_id; $query.= ';'; mysql_query( $query ); - + + // destruction of the group links for this user + $query = 'DELETE FROM '.PREFIX_TABLE.'user_group'; + $query.= ' WHERE user_id = '.$user_id; + $query.= ';'; + mysql_query( $query ); + // destruction of the favorites associated with the user $query = 'DELETE FROM '.PREFIX_TABLE.'favorites'; $query.= ' WHERE user_id = '.$user_id; $query.= ';'; mysql_query( $query ); + + // destruction of the sessions linked with the user + $query = 'DELETE FROM '.PREFIX_TABLE.'sessions'; + $query.= ' WHERE user_id = '.$user_id; + $query.= ';'; + mysql_query( $query ); // destruction of the user $query = 'DELETE FROM '.PREFIX_TABLE.'users'; @@ -178,7 +196,32 @@ function delete_user( $user_id ) $query.= ';'; mysql_query( $query ); } - + +// delete_group deletes a group identified by its $group_id. +// It also deletes : +// - all the access linked to this group +// - all the links between this group and any user +function delete_group( $group_id ) +{ + // destruction of the access linked to the group + $query = 'DELETE FROM '.PREFIX_TABLE.'group_access'; + $query.= ' WHERE group_id = '.$group_id; + $query.= ';'; + mysql_query( $query ); + + // destruction of the group links for this group + $query = 'DELETE FROM '.PREFIX_TABLE.'user_group'; + $query.= ' WHERE group_id = '.$group_id; + $query.= ';'; + mysql_query( $query ); + + // destruction of the group + $query = 'DELETE FROM '.PREFIX_TABLE.'groups'; + $query.= ' WHERE id = '.$group_id; + $query.= ';'; + mysql_query( $query ); +} + // The check_favorites function deletes all the favorites of a user if he is // not allowed to see them (the category or an upper category is restricted // or invisible) -- cgit v1.2.3