Skip to content

Commit

Permalink
No Category with the given id 0 was found in the database #1722
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasse committed Dec 29, 2024
1 parent 7a18954 commit cd027f9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions adm_program/modules/events/events_function.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,24 +287,27 @@
if ($getCopy) {
// copy original role with their settings
$sql = 'SELECT dat_rol_id
FROM ' . TBL_EVENTS . '
WHERE dat_uuid = ?';
FROM ' . TBL_EVENTS . '
WHERE dat_uuid = ?';
$pdoStatement = $gDb->queryPrepared($sql, array($originalEventUuid));

$role = new Role($gDb, (int)$pdoStatement->fetchColumn());
$role->setNewRecord();
} else {
// Read category for event participation
$sql = 'SELECT cat_id
FROM ' . TBL_CATEGORIES . '
WHERE cat_name_intern = \'EVENTS\'
AND cat_org_id = ?';
FROM ' . TBL_CATEGORIES . '
WHERE cat_name_intern = \'EVENTS\'
AND cat_org_id = ?';
$pdoStatement = $gDb->queryPrepared($sql, array($gCurrentOrgId));
if(!$row = $pdoStatement->fetch()) {
throw new Exception('No category found for event participation!');
}
$role = new Role($gDb);
$role->setType(Role::ROLE_EVENT);

// these are the default settings for an event role
$role->setValue('rol_cat_id', (int)$pdoStatement->fetchColumn());
// these are the default settings for a event role
$role->setValue('rol_cat_id', (int) $row['cat_id']);
// role members are allowed to view lists
$role->setValue('rol_view_memberships', ($formValues['event_right_list_view']) ? Role::VIEW_ROLE_MEMBERS : Role::ROLE_LEADER_MEMBERS_ASSIGN_EDIT);
// role members are allowed to send mail to this role
Expand Down
1 change: 1 addition & 0 deletions install/db_scripts/update_4_3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,6 @@
<step id="1220" database="mysql">UPDATE %PREFIX%_preferences SET prf_value = '24' WHERE prf_name = 'photo_thumbs_page' AND CAST(prf_value AS unsigned) = 16</step>
<step id="1230" database="pgsql">UPDATE %PREFIX%_preferences SET prf_value = '24' WHERE prf_name = 'photo_thumbs_page' AND prf_value::int = 16</step>
<step id="1240">UPDATE %PREFIX%_categories SET cat_type = 'EVT' WHERE cat_type = 'DAT'</step>
<step id="1250">UPDATE %PREFIX%_categories SET cat_org_id = 1 WHERE cat_org_id IS NULL AND cat_name_intern = 'EVENTS'</step>
<step>stop</step>
</update>

0 comments on commit cd027f9

Please sign in to comment.