2003-07-01 09:27:20 +00:00
|
|
|
<?php
|
2004-02-11 23:20:38 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 21:12:59 +00:00
|
|
|
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
2007-03-29 19:04:54 +00:00
|
|
|
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
2004-02-11 23:20:38 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
2007-03-29 19:04:54 +00:00
|
|
|
// | file : $Id$
|
2004-02-11 23:20:38 +00:00
|
|
|
// | last update : $Date$
|
|
|
|
// | last modifier : $Author$
|
|
|
|
// | revision : $Revision$
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2005-08-16 15:19:40 +00:00
|
|
|
|
2004-11-26 16:10:17 +00:00
|
|
|
if( !defined("PHPWG_ROOT_PATH") )
|
|
|
|
{
|
2005-08-16 15:19:40 +00:00
|
|
|
die ("Hacking attempt!");
|
2004-11-26 16:10:17 +00:00
|
|
|
}
|
2006-03-09 22:46:28 +00:00
|
|
|
|
|
|
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
|
|
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | Check Access and exit when user status is not ok |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
check_status(ACCESS_ADMINISTRATOR);
|
2004-11-26 16:10:17 +00:00
|
|
|
|
2005-08-16 15:19:40 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | delete a group |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
2006-11-02 23:11:43 +00:00
|
|
|
if (isset($_GET['delete']) and is_numeric($_GET['delete']) and !is_adviser())
|
2003-07-01 09:27:20 +00:00
|
|
|
{
|
2004-12-03 16:30:12 +00:00
|
|
|
// destruction of the access linked to the group
|
2005-08-16 15:19:40 +00:00
|
|
|
$query = '
|
|
|
|
DELETE
|
|
|
|
FROM '.GROUP_ACCESS_TABLE.'
|
|
|
|
WHERE group_id = '.$_GET['delete'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
|
|
|
|
// destruction of the users links for this group
|
|
|
|
$query = '
|
|
|
|
DELETE
|
|
|
|
FROM '.USER_GROUP_TABLE.'
|
|
|
|
WHERE group_id = '.$_GET['delete'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
|
|
|
|
$query = '
|
|
|
|
SELECT name
|
|
|
|
FROM '.GROUPS_TABLE.'
|
|
|
|
WHERE id = '.$_GET['delete'].'
|
|
|
|
;';
|
|
|
|
list($groupname) = mysql_fetch_row(pwg_query($query));
|
|
|
|
|
|
|
|
// destruction of the group
|
|
|
|
$query = '
|
|
|
|
DELETE
|
|
|
|
FROM '.GROUPS_TABLE.'
|
|
|
|
WHERE id = '.$_GET['delete'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
|
|
|
|
array_push(
|
|
|
|
$page['infos'],
|
|
|
|
sprintf(l10n('group "%s" deleted'), $groupname)
|
|
|
|
);
|
2003-07-01 09:27:20 +00:00
|
|
|
}
|
2005-08-16 15:19:40 +00:00
|
|
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | add a group |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
2006-11-02 23:11:43 +00:00
|
|
|
if (isset($_POST['submit_add']) and !is_adviser())
|
2003-07-01 09:27:20 +00:00
|
|
|
{
|
2005-08-16 15:19:40 +00:00
|
|
|
if (empty($_POST['groupname']))
|
2003-07-01 09:27:20 +00:00
|
|
|
{
|
2005-08-16 15:19:40 +00:00
|
|
|
array_push($page['errors'], $lang['group_add_error1']);
|
2003-07-01 09:27:20 +00:00
|
|
|
}
|
2005-08-16 15:19:40 +00:00
|
|
|
if (count($page['errors']) == 0)
|
2003-07-01 09:27:20 +00:00
|
|
|
{
|
|
|
|
// is the group not already existing ?
|
2005-08-16 15:19:40 +00:00
|
|
|
$query = '
|
|
|
|
SELECT COUNT(*)
|
|
|
|
FROM '.GROUPS_TABLE.'
|
|
|
|
WHERE name = \''.$_POST['groupname'].'\'
|
|
|
|
;';
|
|
|
|
list($count) = mysql_fetch_row(pwg_query($query));
|
|
|
|
if ($count != 0)
|
2003-07-01 09:27:20 +00:00
|
|
|
{
|
2005-08-16 15:19:40 +00:00
|
|
|
array_push($page['errors'], $lang['group_add_error2']);
|
2003-07-01 09:27:20 +00:00
|
|
|
}
|
|
|
|
}
|
2005-08-16 15:19:40 +00:00
|
|
|
if (count($page['errors']) == 0)
|
2003-07-01 09:27:20 +00:00
|
|
|
{
|
|
|
|
// creating the group
|
2005-01-17 21:02:43 +00:00
|
|
|
$query = '
|
2005-08-16 15:19:40 +00:00
|
|
|
INSERT INTO '.GROUPS_TABLE.'
|
|
|
|
(name)
|
2005-01-17 21:02:43 +00:00
|
|
|
VALUES
|
2005-08-16 15:19:40 +00:00
|
|
|
(\''.mysql_escape_string($_POST['groupname']).'\')
|
2005-01-17 21:02:43 +00:00
|
|
|
;';
|
|
|
|
pwg_query($query);
|
2005-08-16 15:19:40 +00:00
|
|
|
|
|
|
|
array_push(
|
|
|
|
$page['infos'],
|
|
|
|
sprintf(l10n('group "%s" added'), $_POST['groupname'])
|
|
|
|
);
|
2005-01-17 21:02:43 +00:00
|
|
|
}
|
2004-11-26 16:10:17 +00:00
|
|
|
}
|
|
|
|
|
2006-10-30 23:34:31 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | toggle is default group property |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
2006-11-02 23:11:43 +00:00
|
|
|
if (isset($_GET['toggle_is_default']) and is_numeric($_GET['toggle_is_default']) and !is_adviser())
|
2006-10-30 23:34:31 +00:00
|
|
|
{
|
|
|
|
$query = '
|
|
|
|
SELECT name, is_default
|
|
|
|
FROM '.GROUPS_TABLE.'
|
|
|
|
WHERE id = '.$_GET['toggle_is_default'].'
|
|
|
|
;';
|
|
|
|
list($groupname, $is_default) = mysql_fetch_row(pwg_query($query));
|
|
|
|
|
|
|
|
// update of the group
|
|
|
|
$query = '
|
|
|
|
UPDATE '.GROUPS_TABLE.'
|
|
|
|
SET is_default = \''.boolean_to_string(!get_boolean($is_default)).'\'
|
|
|
|
WHERE id = '.$_GET['toggle_is_default'].'
|
|
|
|
;';
|
|
|
|
pwg_query($query);
|
|
|
|
|
|
|
|
array_push(
|
|
|
|
$page['infos'],
|
|
|
|
sprintf(l10n('group "%s" updated'), $groupname)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2005-08-16 15:19:40 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | template init |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
$template->set_filenames(array('group_list' => 'admin/group_list.tpl'));
|
|
|
|
|
|
|
|
$template->assign_vars(
|
|
|
|
array(
|
2006-11-02 23:11:43 +00:00
|
|
|
'F_ADD_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=group_list',
|
|
|
|
'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=group_list',
|
2005-08-16 15:19:40 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | group list |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
$query = '
|
2006-10-30 23:34:31 +00:00
|
|
|
SELECT id, name, is_default
|
2005-08-16 15:19:40 +00:00
|
|
|
FROM '.GROUPS_TABLE.'
|
|
|
|
ORDER BY id ASC
|
|
|
|
;';
|
|
|
|
$result = pwg_query($query);
|
|
|
|
|
|
|
|
$admin_url = PHPWG_ROOT_PATH.'admin.php?page=';
|
|
|
|
$perm_url = $admin_url.'group_perm&group_id=';
|
|
|
|
$del_url = $admin_url.'group_list&delete=';
|
|
|
|
$members_url = $admin_url.'user_list&group=';
|
2006-10-30 23:34:31 +00:00
|
|
|
$toggle_is_default_url = $admin_url.'group_list&toggle_is_default=';
|
2005-08-16 15:19:40 +00:00
|
|
|
|
|
|
|
$num = 0;
|
|
|
|
while ($row = mysql_fetch_array($result))
|
2004-11-26 16:10:17 +00:00
|
|
|
{
|
2005-08-16 15:19:40 +00:00
|
|
|
$query = '
|
|
|
|
SELECT COUNT(*)
|
|
|
|
FROM '.USER_GROUP_TABLE.'
|
|
|
|
WHERE group_id = '.$row['id'].'
|
|
|
|
;';
|
|
|
|
list($counter) = mysql_fetch_row(pwg_query($query));
|
|
|
|
|
|
|
|
$template->assign_block_vars(
|
|
|
|
'group',
|
|
|
|
array(
|
|
|
|
'CLASS' => ($num++ % 2 == 1) ? 'row2' : 'row1',
|
|
|
|
'NAME' => $row['name'],
|
2006-10-30 23:34:31 +00:00
|
|
|
'IS_DEFAULT' => (get_boolean($row['is_default']) ? ' ['.l10n('is_default_group').']' : ''),
|
2007-03-29 19:04:54 +00:00
|
|
|
'MEMBERS' => l10n_dec('%d member', '%d members', $counter),
|
2005-08-16 15:19:40 +00:00
|
|
|
'U_MEMBERS' => $members_url.$row['id'],
|
|
|
|
'U_DELETE' => $del_url.$row['id'],
|
2006-10-30 23:34:31 +00:00
|
|
|
'U_PERM' => $perm_url.$row['id'],
|
|
|
|
'U_ISDEFAULT' => $toggle_is_default_url.$row['id']
|
2005-08-16 15:19:40 +00:00
|
|
|
)
|
|
|
|
);
|
2003-07-01 09:27:20 +00:00
|
|
|
}
|
|
|
|
|
2005-08-16 15:19:40 +00:00
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | sending html code |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
|
|
|
|
$template->assign_var_from_handle('ADMIN_CONTENT', 'group_list');
|
|
|
|
|
2004-02-11 23:20:38 +00:00
|
|
|
?>
|