diff --git a/category_handler.php b/category_handler.php index bbe6ad555..9ca8bc728 100644 --- a/category_handler.php +++ b/category_handler.php @@ -62,7 +62,7 @@ function updateIconBlob($catId, $iconData, $iconMimeType) { if (!dbi_execute( 'DELETE FROM webcal_categories WHERE cat_id = ? AND ( cat_owner = ?' - . ($is_admin ? ' OR cat_owner IS NULL )' : ' )'), + . ($is_admin ? ' OR cat_owner = \'\' )' : ' )'), [$id, $login] )) { $error = db_error(); @@ -95,16 +95,18 @@ function updateIconBlob($catId, $iconData, $iconMimeType) { $row = dbi_fetch_row($res); $id = $row[0] + 1; dbi_free_result($res); - // Set catowner to NULL for global category - $catowner = ($is_admin ? ($isglobal == 'Y' ? null : $login) : $login); + // Set catowner to empty string for global category + $catowner = ($is_admin ? ($isglobal == 'Y' ? '' : $login) : $login); if (!dbi_execute( 'INSERT INTO webcal_categories ( cat_id, cat_owner, cat_name, cat_color ) VALUES ( ?, ?, ?, ? )', [$id, $catowner, $catname, $catcolor] - )) + )) { $error = db_error(); - } else + } + } else { $error = db_error(); + } } if (empty($delIcon) && (!empty($ENABLE_ICON_UPLOADS) && $ENABLE_ICON_UPLOADS == 'Y' || $is_admin)) { // Save icon if uploaded. diff --git a/edit_entry.php b/edit_entry.php index 63761b6b4..8677ac6b5 100644 --- a/edit_entry.php +++ b/edit_entry.php @@ -368,7 +368,7 @@ function time_selection($prefix, $time = '', $trigger = false) if (!empty($cat_id)) { $res = dbi_execute( 'SELECT cat_name FROM webcal_categories ' . - 'WHERE cat_id = ? AND ( cat_owner = ? OR cat_owner IS NULL )', + 'WHERE cat_id = ? AND ( cat_owner = ? OR cat_owner = \'\' )', [$cat_id, $real_user] ); if ($res) { diff --git a/includes/functions.php b/includes/functions.php index 30e63678f..82eaf8c03 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -2471,7 +2471,7 @@ function get_categories_by_id ( $id, $user, $asterisk = false ) { $res = dbi_execute ( 'SELECT wc.cat_name, wc.cat_id, wec.cat_owner FROM webcal_categories wc, webcal_entry_categories wec WHERE wec.cal_id = ? - AND wec.cat_id = wc.cat_id AND ( wc.cat_owner = ? OR wc.cat_owner IS NULL ) + AND wec.cat_id = wc.cat_id AND ( wc.cat_owner = ? OR wc.cat_owner = \'\' ) ORDER BY wec.cat_order', [$id, ( empty ( $user ) ? $login : $user )] ); while ( $row = dbi_fetch_row ( $res ) ) { $categories[ ( empty ( $row[2] ) ? - $row[1] : $row[1] ) ] = $row[0] @@ -4209,7 +4209,7 @@ function load_user_categories ( $ex_global = '' ) { ( $is_assistant || $is_admin ) ? $user : $login ); $rows = dbi_get_cached_rows ( 'SELECT cat_id, cat_name, cat_owner, cat_color, cat_icon_mime FROM webcal_categories WHERE ( cat_owner = ? ) ' . ( $ex_global == '' - ? 'OR ( cat_owner IS NULL ) ORDER BY cat_owner,' : 'ORDER BY' ) + ? 'OR ( cat_owner = \'\' ) ORDER BY cat_owner,' : 'ORDER BY' ) . ' cat_name', $query_params ); if ( $rows ) { for ( $i = 0, $cnt = count ( $rows ); $i < $cnt; $i++ ) { diff --git a/includes/xcal.php b/includes/xcal.php index 7ac151f91..e423785c9 100644 --- a/includes/xcal.php +++ b/includes/xcal.php @@ -3121,7 +3121,7 @@ function get_categories_id_byname ( $cat_names ) { $categories = explode ( ',', $cat_names ); foreach ( $categories as $cat_name ) { $res = dbi_execute ( 'SELECT cat_id FROM webcal_categories - WHERE cat_name = ? AND ( cat_owner = ? OR cat_owner IS NULL )', + WHERE cat_name = ? AND ( cat_owner = ? OR cat_owner = \'\' )', [$cat_name, $login] ); if ( $res ) { if ( $row = dbi_fetch_row ( $res ) ) { diff --git a/install/sql/tables-mysql.sql b/install/sql/tables-mysql.sql index c0bb7ebd1..8d370c0e6 100644 --- a/install/sql/tables-mysql.sql +++ b/install/sql/tables-mysql.sql @@ -414,7 +414,7 @@ CREATE TABLE webcal_entry_log ( /** * Defines user categories. Categories can be specific to a user or global. - * When a category is global, the cat_owner field will be NULL. + * When a category is global, the cat_owner field will be an empty string. * (Only an admin user can create a global category.) */ CREATE TABLE webcal_categories (