diff --git a/main.inc.php b/main.inc.php index 35c5090..f9d8400 100644 --- a/main.inc.php +++ b/main.inc.php @@ -1,7 +1,7 @@ private transition so Piwigo itself - * persists the permission together with the other selected users. - */ -function bratonien_tools_prepare_private_album_permissions() -{ - global $user; - - if ( - !defined('IN_ADMIN') - || $_SERVER['REQUEST_METHOD'] !== 'POST' - || empty($user['id']) - || (string)($_POST['status'] ?? '') !== 'private' - ) - { - return; - } - - $page = (string)($_GET['page'] ?? ''); - if (!preg_match('/^album-(\d+)-permissions$/', $page, $matches)) - { - return; - } - - $category_id = (int)$matches[1]; - if ($category_id < 1) - { - return; - } - - $result = pwg_query('SELECT status FROM '.CATEGORIES_TABLE.' WHERE id = '.$category_id.' LIMIT 1'); - if (!pwg_db_num_rows($result)) - { - return; - } - - $category = pwg_db_fetch_assoc($result); - if ($category['status'] !== 'public') - { - return; - } - - $users = isset($_POST['users']) && is_array($_POST['users']) ? $_POST['users'] : array(); - $current_user_id = (int)$user['id']; - $normalized_user_ids = array_map('intval', $users); - - if (!in_array($current_user_id, $normalized_user_ids, true)) - { - $users[] = $current_user_id; - } - - $_POST['users'] = $users; -} - -function bratonien_tools_admin_menu($menu) -{ - $menu[] = array( - 'NAME' => 'Bratonien Tools', - 'URL' => get_root_url() . 'admin.php?page=plugin-' . BRATONIEN_TOOLS_ID, - ); - - return $menu; -} +require_once(BRATONIEN_TOOLS_PATH . 'include/admin.inc.php'); +require_once(BRATONIEN_TOOLS_PATH . 'include/public.inc.php');