From b95d0e0dd1a3da7832ac518d7a373023e43cbb42 Mon Sep 17 00:00:00 2001 From: Tom Homer Date: Mon, 6 Nov 2017 16:10:27 -0500 Subject: [PATCH] Update development db script to include new theme group --- public_html/admin/install/devel-db-update.php | 48 +++++++++++++++++-- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/public_html/admin/install/devel-db-update.php b/public_html/admin/install/devel-db-update.php index c71f296f4..a980c6359 100644 --- a/public_html/admin/install/devel-db-update.php +++ b/public_html/admin/install/devel-db-update.php @@ -68,10 +68,50 @@ function update_DatabaseFor220() // *************************************** // Add database Geeklog Core updates here. // NOTE: Cannot use ones found in normal upgrade script as no checks are performed to see if already done. - - - - + + // Add theme admin + $result = DB_query("SELECT * FROM {$_TABLES['groups']} WHERE grp_name='Theme Admin'"); + if ( DB_numRows($result) == 0 ) { + $sql1 = "INSERT INTO {$_TABLES['groups']} (grp_id, grp_name, grp_descr, grp_gl_core) " + . "VALUES (NULL, 'Theme Admin', 'Has full access to themes', 1)"; + $sql2 = "INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_grp_id) VALUES (%d, %d)"; + $sql3 = "INSERT INTO {$_TABLES['features']} (ft_id, ft_name, ft_descr, ft_gl_core) " + . "VALUES (NULL, 'theme.edit', 'Access to theme settings', 1)"; + $sql4 = "INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (%d, %d)"; + + try { + DB_beginTransaction(); + + // Add Theme Admin to groups + if (!DB_query($sql1)) { + throw new \Exception(DB_error()); + } + + // Add Root group to Theme Admin group + $themeAdminGroupId = DB_insertId(); + $rootGroupId = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'"); + $sql2 = sprintf($sql2, $themeAdminGroupId, $rootGroupId); + if (!DB_query($sql2)) { + throw new \Exception(DB_error()); + } + + // Add theme.edit feature + if (!DB_query($sql3)) { + throw new \Exception(DB_error()); + } + + // Assign theme.edit feature to Theme Admin + $themeAdminFeatureId = DB_insertId(); + $sql4 = sprintf($sql4, $themeAdminFeatureId, $themeAdminGroupId); + if (!DB_query($sql4)) { + throw new \Exception(DB_error()); + } + + DB_commit(); + } catch (\Exception $e) { + DB_rollBack(); + } + } // *************************************** // Core Plugin Updates Here