diff --git a/admin/album_notification.php b/admin/album_notification.php index 69ec976d2..a08722425 100644 --- a/admin/album_notification.php +++ b/admin/album_notification.php @@ -14,6 +14,8 @@ } use App\Repository\ImageRepository; +use App\Repository\GroupRepository; +use App\Repository\GroupAccessRepository; // +-----------------------------------------------------------------------+ // | variable initialization | @@ -79,10 +81,10 @@ \Phyxo\Functions\URL::unset_make_full_url(); - $query = 'SELECT name FROM ' . GROUPS_TABLE . ' WHERE id = ' . $conn->db_real_escape_string($_POST['group']); - list($group_name) = $conn->db_fetch_row($conn->db_query($query)); + $result = (new GroupRepository($conn))->findById($_POST['group']); + $row = $conn->db_fetch_assoc($result); - $page['infos'][] = \Phyxo\Functions\Language::l10n('An information email was sent to group "%s"', $group_name); + $page['infos'][] = \Phyxo\Functions\Language::l10n('An information email was sent to group "%s"', $row['name']); } // +-----------------------------------------------------------------------+ @@ -104,15 +106,15 @@ // | form construction | // +-----------------------------------------------------------------------+ -$query = 'SELECT id AS group_id FROM ' . GROUPS_TABLE; -$all_group_ids = $conn->query2array($query, null, 'group_id'); +$result = (new GroupRepository($conn))->findAll(); +$all_group_ids = $conn->result2array($result, null, 'group_id'); if (count($all_group_ids) == 0) { $template->assign('no_group_in_gallery', true); } else { if ('private' == $category['status']) { - $query = 'SELECT group_id FROM ' . GROUP_ACCESS_TABLE . ' WHERE cat_id = ' . $category['id']; - $group_ids = $conn->query2array($query, null, 'group_id'); + $result = (new GroupAccessRepository($conn))->findByCatId($category['id']); + $group_ids = $conn->result2array($result, null, 'group_id'); if (count($group_ids) == 0) { $template->assign('permission_url', ALBUM_BASE_URL . '§ion=permissions'); @@ -122,11 +124,10 @@ } if (count($group_ids) > 0) { - $query = 'SELECT id,name FROM ' . GROUPS_TABLE; - $query .= ' WHERE id ' . $conn->in($group_ids) . ' ORDER BY name ASC'; + $result = (new GroupRepository($conn))->findByIds($group_ids, 'ORDER BY name ASC'); $template->assign( 'group_mail_options', - $conn->query2array($query, 'id', 'name') + $conn->result2array($result, 'id', 'name') ); } } diff --git a/admin/album_permissions.php b/admin/album_permissions.php index bff3e5b78..681b74b63 100644 --- a/admin/album_permissions.php +++ b/admin/album_permissions.php @@ -10,6 +10,8 @@ */ use App\Repository\CategoryRepository; +use App\Repository\GroupAccessRepository; +use App\Repository\GroupRepository; if (!defined('ALBUM_BASE_URL')) { die("Hacking attempt!"); @@ -37,8 +39,8 @@ // // manage groups // - $query = 'SELECT group_id FROM ' . GROUP_ACCESS_TABLE . ' WHERE cat_id = ' . $conn->db_real_escape_string($page['cat']); - $groups_granted = $conn->query2array($query, null, 'group_id'); + $result = (new GroupAccessRepository($conn))->findByCatId($page['cat']); + $groups_granted = $conn->result2array($result, null, 'group_id'); if (!isset($_POST['groups'])) { $_POST['groups'] = []; @@ -51,10 +53,7 @@ if (count($deny_groups) > 0) { // if you forbid access to an album, all sub-albums become // automatically forbidden - $query = 'DELETE FROM ' . GROUP_ACCESS_TABLE; - $query .= ' WHERE group_id ' . $conn->in($deny_groups); - $query .= ' AND cat_id ' . $conn->in((new CategoryRepository($conn))->getSubcatIds([$page['cat']])); - $conn->db_query($query); + (new GroupAccessRepository($conn))->deleteByGroupIdsAndCatIds($deny_groups, (new CategoryRepository($conn))->getSubcatIds([$page['cat']])); } // @@ -80,12 +79,7 @@ } } - $conn->mass_inserts( - GROUP_ACCESS_TABLE, - ['group_id', 'cat_id'], - $inserts, - ['ignore' => true] - ); + (new GroupAccessRepository($conn))->massInserts(['group_id', 'cat_id'], $inserts, ['ignore' => true]); } // @@ -149,13 +143,13 @@ $groups = []; -$query = 'SELECT id, name FROM ' . GROUPS_TABLE . ' ORDER BY name ASC;'; -$groups = $conn->query2array($query, 'id', 'name'); +$result = (new GroupRepository($conn))->findAll('ORDER BY name ASC'); +$groups = $conn->result2array($result, 'id', 'name'); $template->assign('groups', $groups); // groups granted to access the category -$query = 'SELECT group_id FROM ' . GROUP_ACCESS_TABLE . ' WHERE cat_id = ' . $conn->db_real_escape_string($page['cat']); -$group_granted_ids = $conn->query2array($query, null, 'group_id'); +$result = (new GroupAccessRepository($conn))->findByCatId($page['cat']); +$group_granted_ids = $conn->result2array($result, null, 'group_id'); $template->assign('groups_selected', $group_granted_ids); // users... diff --git a/admin/groups_list.php b/admin/groups_list.php index d0e98122c..ff2fc2f54 100644 --- a/admin/groups_list.php +++ b/admin/groups_list.php @@ -9,6 +9,10 @@ * file that was distributed with this source code. */ +use App\Repository\GroupRepository; +use App\Repository\GroupAccessRepository; +use App\Repository\UserGroupRepository; + if (!defined("GROUPS_BASE_URL")) { die("Hacking attempt!"); } @@ -22,18 +26,12 @@ $page['errors'][] = \Phyxo\Functions\Language::l10n('The name of a group must not contain " or \' or be empty.'); } if (count($page['errors']) == 0) { - // is the group not already existing ? - $query = 'SELECT COUNT(1) FROM ' . GROUPS_TABLE; - $query .= ' WHERE name = \'' . $conn->db_real_escape_string($_POST['groupname']) . '\''; - list($count) = $conn->db_fetch_row($conn->db_query($query)); - if ($count != 0) { + if ((new GroupRepository($conn))->isGroupNameExists($_POST['groupname'])) { $page['errors'][] = \Phyxo\Functions\Language::l10n('This name is already used by another group.'); } } if (count($page['errors']) == 0) { - // creating the group - $query = 'INSERT INTO ' . GROUPS_TABLE . ' (name) VALUES(\'' . $conn->db_real_escape_string($_POST['groupname']) . '\');'; - $conn->db_query($query); + (new GroupRepository($conn))->addGroup($_POST['groupname']); $page['infos'][] = \Phyxo\Functions\Language::l10n('group "%s" added', $_POST['groupname']); } @@ -43,8 +41,7 @@ // | action send | // +-----------------------------------------------------------------------+ if (isset($_POST['submit']) and isset($_POST['selectAction']) and isset($_POST['group_selection'])) { - // if the user tries to apply an action, it means that there is at least 1 - // photo in the selection + // if the user tries to apply an action, it means that there is at least 1 photo in the selection $groups = $_POST['group_selection']; if (count($groups) == 0) { $page['errors'][] = \Phyxo\Functions\Language::l10n('Select at least one group'); @@ -57,16 +54,13 @@ // + if ($action == "rename") { // is the group not already existing ? - $query = 'SELECT name FROM ' . GROUPS_TABLE; - $group_names = $conn->query2array($query, null, 'name'); + $result = (new GroupRepository($conn))->findAll(); + $group_names = $conn->result2array($result, null, 'name'); foreach ($groups as $group) { if (in_array($_POST['rename_' . $group . ''], $group_names)) { $page['errors'][] = $_POST['rename_' . $group . ''] . ' | ' . \Phyxo\Functions\Language::l10n('This name is already used by another group.'); - } elseif (!empty($_POST['rename_' . $group . ''])) { - $query = 'UPDATE ' . GROUPS_TABLE; - $query .= ' SET name = \'' . $conn->db_real_escape_string($_POST['rename_' . $group . '']) . '\''; - $query .= ' WHERE id = ' . $group; - $conn->db_query($query); + } elseif (!empty($_POST['rename_' . $group])) { + (new GroupRepository($conn))->updateGroup(['name' => $_POST['rename_' . $group]], $group); } } } @@ -75,72 +69,59 @@ // |delete a group // + if ($action == "delete" and isset($_POST['confirm_deletion']) and $_POST['confirm_deletion']) { - foreach ($groups as $group) { - // destruction of the access linked to the group - $query = 'DELETE FROM ' . GROUP_ACCESS_TABLE . ' WHERE group_id = ' . $group; - $conn->db_query($query); + // destruction of the access linked to the group + (new GroupAccessRepository($conn))->deleteByGroupIds($groups); - // destruction of the users links for this group - $query = 'DELETE FROM ' . USER_GROUP_TABLE . ' WHERE group_id = ' . $group; - $conn->db_query($query); + // destruction of the users links for this group + (new UserGroupRepository($conn))->deleteGroupByIds($groups); - $query = 'SELECT name FROM ' . GROUPS_TABLE . ' WHERE id = ' . $group; - list($groupname) = $conn->db_fetch_row($conn->db_query($query)); + $result = (new GroupRepository($conn))->findByIds($params['group_id']); + $groupnames = $conn->result2array($result, null, 'name'); - // destruction of the group - $query = 'DELETE FROM ' . GROUPS_TABLE . ' WHERE id = ' . $group; - $conn->db_query($query); + // destruction of the group + (new GroupRepository($conn))->deleteByIds($params['group_id']); - $page['infos'][] = \Phyxo\Functions\Language::l10n('group "%s" deleted', $groupname); - } + $page['infos'][] = \Phyxo\Functions\Language::l10n('groups "%s" deleted', implode(', ', $groupnames)); } // + // |merge groups into a new one // + if ($action == "merge" and count($groups) > 1) { - // is the group not already existing ? - $query = 'SELECT COUNT(1) FROM ' . GROUPS_TABLE; - $query .= ' WHERE name = \'' . $conn->db_real_escape_string($_POST['merge']) . '\''; - list($count) = $conn->db_fetch_row($conn->db_query($query)); - if ($count != 0) { + if ((new GroupRepository($conn))->isGroupNameExists($_POST['merge'])) { $page['errors'][] = \Phyxo\Functions\Language::l10n('This name is already used by another group.'); } else { - // creating the group - $query = 'INSERT INTO ' . GROUPS_TABLE . ' (name) VALUES(\'' . $conn->db_real_escape_string($_POST['merge']) . '\')'; - $conn->db_query($query); - $query = 'SELECT id FROM ' . GROUPS_TABLE . ' WHERE name = \'' . $conn->db_real_escape_string($_POST['merge']) . '\''; - list($groupid) = $conn->db_fetch_row($conn->db_query($query)); + $group_id = (new GroupRepository($conn))->addGroup(['name' => $_POST['merge']]); } - $grp_access = array(); - $usr_grp = array(); - foreach ($groups as $group) { - $query = 'SELECT * FROM ' . GROUP_ACCESS_TABLE . ' WHERE group_id = ' . $group; - $res = $conn->db_query($query); - while ($row = $conn->db_fetch_assoc($res)) { - $new_grp_access = array( - 'cat_id' => $row['cat_id'], - 'group_id' => $groupid - ); - if (!in_array($new_grp_access, $grp_access)) { - $grp_access[] = $new_grp_access; - } + + $grp_access = []; + $usr_grp = []; + $result = (new GroupAccessRepository($conn))->findByGroupIds($groups); + $groups_infos = $conn->result2array($result); + foreach ($groups_infos as $group) { + $new_grp_access = [ + 'cat_id' => $group['cat_id'], + 'group_id' => $group_id + ]; + if (!in_array($new_grp_access, $grp_access)) { + $grp_access[] = $new_grp_access; } + } - $query = 'SELECT * FROM ' . USER_GROUP_TABLE . ' WHERE group_id = ' . $group; - $result = $conn->db_query($query); - while ($row = $conn->db_fetch_assoc($result)) { - $new_usr_grp = array( - 'user_id' => $row['user_id'], - 'group_id' => $groupid - ); - if (!in_array($new_usr_grp, $usr_grp)) { - $usr_grp[] = $new_usr_grp; - } + $result = (new GroupAccessRepository($conn))->findByGroupIds($groups); + $groups_infos = $conn->result2array($result); + foreach ($groups_infos as $group) { + $new_grp_access = [ + 'cat_id' => $group['cat_id'], + 'group_id' => $group_id + ]; + if (!in_array($new_grp_access, $grp_access)) { + $grp_access[] = $new_grp_access; } } - $conn->mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $usr_grp); - $conn->mass_inserts(GROUP_ACCESS_TABLE, array('group_id', 'cat_id'), $grp_access); + + (new UserGroupRepository($conn))->massInserts(['user_id', 'group_id'], $usr_grp); + (new GroupAccessRepository($conn))->massInserts(['group_id', 'cat_id'], $grp_access); $page['infos'][] = \Phyxo\Functions\Language::l10n('group "%s" added', $_POST['merge']); } @@ -149,50 +130,40 @@ // |duplicate a group // + if ($action == "duplicate") { + // @TODO: avoid query in loop foreach ($groups as $group) { - if (empty($_POST['duplicate_' . $group . ''])) { + if (empty($_POST['duplicate_' . $group])) { break; } - // is the group not already existing ? - $query = 'SELECT COUNT(1) FROM ' . GROUPS_TABLE; - $query .= ' WHERE name = \'' . $conn->db_real_escape_string($_POST['duplicate_' . $group . '']); - list($count) = $conn->db_fetch_row($conn->db_query($query)); - if ($count != 0) { + + if ((new GroupRepository($conn))->isGroupNameExists($_POST['duplicate_' . $group])) { $page['errors'][] = \Phyxo\Functions\Language::l10n('This name is already used by another group.'); break; } - // creating the group - $query = 'INSERT INTO ' . GROUPS_TABLE; - $query .= ' (name) VALUES (\'' . $conn->db_real_escape_string($_POST['duplicate_' . $group . '']) . '\')'; - $conn->db_query($query); - - // @TODO: use last insert id - $query = 'SELECT id FROM ' . GROUPS_TABLE; - $query .= ' WHERE name = \'' . $conn->db_real_escape_string($_POST['duplicate_' . $group . '']) . '\''; - list($groupid) = $conn->db_fetch_row($conn->db_query($query)); - $query = 'SELECT * FROM ' . GROUP_ACCESS_TABLE . ' WHERE group_id = ' . $group; - $grp_access = array(); - $res = $conn->db_query($query); - while ($row = $conn->db_fetch_assoc($res)) { - $grp_access[] = array( + + $group_id = (new GroupRepository($conn))->addGroup(['name' => $_POST['duplicate_' . $group]]); + + $grp_access = []; + $result = (new GroupAccessRepository($conn))->findByGroupId($group); + while ($row = $conn->db_fetch_assoc($result)) { + $grp_access[] = [ 'cat_id' => $row['cat_id'], 'group_id' => $groupid - ); + ]; } - $conn->mass_inserts(GROUP_ACCESS_TABLE, array('group_id', 'cat_id'), $grp_access); + (new GroupAccessRepository($conn))->massInserts(['group_id', 'cat_id'], $grp_access); - $query = 'SELECT * FROM ' . USER_GROUP_TABLE . ' WHERE group_id = ' . $group; - $usr_grp = array(); - $result = $conn->db_query($query); + $usr_grp = []; + $result = (new UserGroupRepository($conn))->findByGroupId($group); while ($row = $conn->db_fetch_assoc($result)) { - $usr_grp[] = array( + $usr_grp[] = [ 'user_id' => $row['user_id'], 'group_id' => $groupid - ); + ]; } - $conn->mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $usr_grp); + (new UserGroupRepository($conn))->massInserts(['user_id', 'group_id'], $usr_grp); - $page['infos'][] = \Phyxo\Functions\Language::l10n('group "%s" added', $_POST['duplicate_' . $group . '']); + $page['infos'][] = \Phyxo\Functions\Language::l10n('group "%s" added', $_POST['duplicate_' . $group]); } } @@ -201,20 +172,10 @@ // | toggle_default // + if ($action == "toggle_default") { - foreach ($groups as $group) { - $query = 'SELECT name, is_default FROM ' . GROUPS_TABLE . ' WHERE id = ' . $group; - $row = $conn->db_fetch_assoc($conn->db_query($query)); - $groupname = $row['name']; - $is_default = $conn->get_boolean($row['is_default']); - - // update of the group - $query = 'UPDATE ' . GROUPS_TABLE; - $query .= ' SET is_default = \'' . $conn->boolean_to_db($is_default) . '\''; - $query .= ' WHERE id = ' . $group; - $conn->db_query($query); - - $page['infos'][] = \Phyxo\Functions\Language::l10n('group "%s" updated', $groupname); - } + // @TODO: strange idea to have multiple default groups + (new GroupRepository($conn))->toggleIsDefault($groups); + + $page['infos'][] = \Phyxo\Functions\Language::l10n('groups "%s" updated', implode(', ', $groups)); } \Phyxo\Functions\Utils::invalidate_user_cache(); } @@ -223,45 +184,43 @@ // +-----------------------------------------------------------------------+ $template->assign( - array( + [ 'F_ADD_ACTION' => GROUPS_BASE_URL . '§ion=list', //'U_HELP' => \Phyxo\Functions\URL::get_root_url().'admin/popuphelp.php?page=group_list', 'PWG_TOKEN' => \Phyxo\Functions\Utils::get_token(), - ) + ] ); // +-----------------------------------------------------------------------+ // | group list | // +-----------------------------------------------------------------------+ -$query = 'SELECT id, name, is_default FROM ' . GROUPS_TABLE . ' ORDER BY name ASC'; -$result = $conn->db_query($query); - $perm_url = GROUPS_BASE_URL . '§ion=perm&group_id='; $del_url = GROUPS_BASE_URL . '§ion=list&delete='; $toggle_is_default_url = GROUPS_BASE_URL . '§ion=list&toggle_is_default='; +$groups = []; +$result = (new GroupRepository($conn))->findUsersInGroups(); while ($row = $conn->db_fetch_assoc($result)) { - $query = 'SELECT u.' . $conf['user_fields']['username'] . ' AS username FROM ' . USERS_TABLE . ' AS u'; - $query .= ' LEFT JOIN ' . USER_GROUP_TABLE . ' AS ug ON u.' . $conf['user_fields']['id'] . ' = ug.user_id'; - $query .= ' WHERE ug.group_id = ' . $row['id']; - $members = array(); - $user_result = $conn->db_query($query); - while ($user = $conn->db_fetch_assoc($user_result)) { - $members[] = $user['username']; - } - $template->append( - 'groups', - array( - 'NAME' => $row['name'], + if (isset($groups[$row['id']])) { + if (!empty($row['username'])) { + $groups[$row['id']]['MEMBERS'][] = $row['username']; + } + } else { + $group = [ + 'MEMBERS' => [], 'ID' => $row['id'], + 'NAME' => $row['name'], 'IS_DEFAULT' => ($conn->get_boolean($row['is_default']) ? ' [' . \Phyxo\Functions\Language::l10n('default') . ']' : ''), - 'NB_MEMBERS' => count($members), - 'L_MEMBERS' => implode(' · ', $members), - 'MEMBERS' => \Phyxo\Functions\Language::l10n_dec('%d member', '%d members', count($members)), 'U_DELETE' => $del_url . $row['id'] . '&pwg_token=' . \Phyxo\Functions\Utils::get_token(), 'U_PERM' => $perm_url . $row['id'], 'U_ISDEFAULT' => $toggle_is_default_url . $row['id'] . '&pwg_token=' . \Phyxo\Functions\Utils::get_token(), - ) - ); + ]; + if (!empty($row['username'])) { + $group['MEMBERS'][] = $row['username']; + } + $groups[$row['id']] = $group; + } } + +$template->assign('groups', $groups); diff --git a/admin/groups_perm.php b/admin/groups_perm.php index 8e13e1efb..b5043a729 100644 --- a/admin/groups_perm.php +++ b/admin/groups_perm.php @@ -10,6 +10,8 @@ */ use App\Repository\CategoryRepository; +use App\Repository\GroupRepository; +use App\Repository\GroupAccessRepository; if (!defined("GROUPS_BASE_URL")) { die("Hacking attempt!"); @@ -30,9 +32,7 @@ // if you forbid access to a category, all sub-categories become // automatically forbidden $subcats = (new CategoryRepository($conn))->getSubcatIds($_POST['cat_true']); - $query = 'DELETE FROM ' . GROUP_ACCESS_TABLE; - $query .= ' WHERE group_id = ' . $page['group'] . ' AND cat_id ' . $conn->in($subcats); - $conn->db_query($query); + (new GroupAccessRepository($conn))->deleteByGroupIdsAndCatIds($page['group'], $subcats); } elseif (isset($_POST['trueify'], $_POST['cat_false']) && count($_POST['cat_false']) > 0) { $uppercats = \Phyxo\Functions\Category::get_uppercat_ids($_POST['cat_false']); $private_uppercats = []; @@ -47,9 +47,7 @@ // accesible $authorized_ids = []; - $query = 'SELECT cat_id FROM ' . GROUP_ACCESS_TABLE . ' WHERE group_id = ' . $conn->db_real_escape_string($page['group']); - $result = $conn->db_query($query); - + $result = (new GroupAccessRepository($conn))->findByGroupId($page['group']); while ($row = $conn->db_fetch_assoc($result)) { $authorized_ids[] = $row['cat_id']; } @@ -63,7 +61,7 @@ ]; } - $conn->mass_inserts(GROUP_ACCESS_TABLE, ['group_id', 'cat_id'], $inserts); + (new GroupAccessRepository($conn))->massInserts(['group_id', 'cat_id'], $inserts); \Phyxo\Functions\Utils::invalidate_user_cache(); } @@ -106,11 +104,9 @@ $template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); } else { - $query = 'SELECT id, name, is_default FROM ' . GROUPS_TABLE . ' ORDER BY name ASC'; - $result = $conn->db_query($query); - $perm_url = GROUPS_BASE_URL . '§ion=perm&group_id='; + $result = (new GroupRepository($conn))->findAll('ORDER BY name ASC'); while ($row = $conn->db_fetch_assoc($result)) { $template->append( 'groups', diff --git a/admin/intro.php b/admin/intro.php index 41a6aa63a..7112b6677 100644 --- a/admin/intro.php +++ b/admin/intro.php @@ -21,6 +21,7 @@ use App\Repository\ImageRepository; use App\Repository\ImageTagRepository; use App\Repository\ImageCategoryRepository; +use App\Repository\GroupRepository; include_once PHPWG_ROOT_PATH . 'include/dblayers.inc.php'; @@ -80,9 +81,7 @@ $query = 'SELECT COUNT(1) FROM ' . USERS_TABLE; list($nb_users) = $conn->db_fetch_row($conn->db_query($query)); -$query = 'SELECT COUNT(1) FROM ' . GROUPS_TABLE; -list($nb_groups) = $conn->db_fetch_row($conn->db_query($query)); - +$nb_groups = (new GroupRepository($conn))->count(); $nb_rates = (new RateRepository($conn))->count(); $template->assign( diff --git a/admin/site_update.php b/admin/site_update.php index ffa18c400..7728ceaa6 100644 --- a/admin/site_update.php +++ b/admin/site_update.php @@ -18,6 +18,8 @@ use App\Repository\CategoryRepository; use App\Repository\ImageRepository; use App\Repository\ImageCategoryRepository; +use App\Repository\GroupAccessRepository; +use App\Repository\UserAccessRepository; // +-----------------------------------------------------------------------+ // | Check Access and exit when user status is not ok | @@ -229,10 +231,7 @@ } $category_up = implode(',', array_unique($category_up)); if ($conf['inheritance_by_default']) { - // TODO remove SELECT * - $query = 'SELECT * FROM ' . GROUP_ACCESS_TABLE; - $query .= ' WHERE cat_id ' . $conn->in($category_up); - $result = $conn->db_query($query); + $result = (new GroupAccessRepository($conn))->findByCatIds($category_up); if (!empty($result)) { $granted_grps = []; while ($row = $conn->db_fetch_assoc($result)) { @@ -248,10 +247,7 @@ ); } } - // TODO remove SELECT * - $query = 'SELECT * FROM ' . USER_ACCESS_TABLE; - $query .= ' WHERE cat_id ' . $conn->in($category_up); - $result = $conn->db_query($query); + $result = (new UserAccessRepository($conn))->findByCatIds($category_up); if (!empty($result)) { $granted_users = []; while ($row = $conn->db_fetch_assoc($result)) { @@ -299,9 +295,10 @@ } } } - $conn->mass_inserts(GROUP_ACCESS_TABLE, ['group_id', 'cat_id'], $insert_granted_grps); + + (new GroupAccessRepository($conn))->massInserts(['group_id', 'cat_id'], $insert_granted_grps); $insert_granted_users = array_unique($insert_granted_users, SORT_REGULAR); - $conn->mass_inserts(USER_ACCESS_TABLE, ['user_id', 'cat_id'], $insert_granted_users); + (new UserAccessRepository($conn))->massInserts(['user_id', 'cat_id'], $insert_granted_users); } else { \Phyxo\Functions\Category::add_permission_on_category($category_ids, \Phyxo\Functions\Utils::get_admins()); } diff --git a/admin/theme/template/groups_list.tpl b/admin/theme/template/groups_list.tpl index 71ca7ac8d..f3ba4127d 100644 --- a/admin/theme/template/groups_list.tpl +++ b/admin/theme/template/groups_list.tpl @@ -44,7 +44,10 @@