From 65dbda501a30ae959cc21608d20d75ab3aaf9b3c Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Wed, 9 Aug 2017 20:30:06 +1000 Subject: [PATCH 1/2] Better fix for issue #399, ensuring we don't wipe out existing values when no new value has been submitted --- include/db_object.class.php | 10 ++++++---- include/general.php | 6 +++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/db_object.class.php b/include/db_object.class.php index ee8657f2..c4ec2d3d 100644 --- a/include/db_object.class.php +++ b/include/db_object.class.php @@ -710,13 +710,15 @@ public function processFieldInterface($name, $prefix='') { if (!$this->id || $this->haveLock()) { $value = process_widget($prefix.$name, $this->fields[$name]); - if (!is_null($value) || $this->fields[$name]['type'] == 'reference') { - // For a reference field, 'null' might be a meaninful value - // For other fields, it means the field hasn't been submitted. + if ($value !== NULL) { + if (($this->fields[$name]['type'] == 'reference') && ($value === 0)) { + // process_widget returns 0 when the user selects the 'empty' option + // but we want to save NULL to the db. + $value = NULL; + } $this->setValue($name, $value); } } - } diff --git a/include/general.php b/include/general.php index 05f68068..a4526ada 100644 --- a/include/general.php +++ b/include/general.php @@ -573,7 +573,11 @@ function process_widget($name, $params, $index=NULL, $preserveEmpties=FALSE) } break; case 'reference': - $value = empty($rawVal) ? NULL : (int)$rawVal; + if (!array_key_exists($name, $_REQUEST)) { + $value = NULL; + } else { + $value = (int)$rawVal; + } break; default: $value = $rawVal; From d6c0fd41f5873cd47819e4b2bdcc61be2c305cc4 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Wed, 9 Aug 2017 20:35:55 +1000 Subject: [PATCH 2/2] Fix #395 - you only need the VIEWSERVICE permission to view a run sheet --- views/view_8_services.class.php | 10 ++++++++-- views/view_8_services__1_list_all.class.php | 22 +++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/views/view_8_services.class.php b/views/view_8_services.class.php index 14afc683..36e0fa4e 100644 --- a/views/view_8_services.class.php +++ b/views/view_8_services.class.php @@ -11,7 +11,7 @@ class View_services extends View static function getMenuPermissionLevel() { - return PERM_EDITSERVICE; + return PERM_VIEWSERVICE; } function processView() @@ -138,6 +138,9 @@ function printView()

+ havePerm(PERM_EDITSERVICE)) { + ?> Edit   @@ -145,7 +148,10 @@ function printView() Printable - Run Sheet +

$details) { $details['id'] = $id; $this->_grouped_services[$details['date']][$details['congregationid']] = $details; + if ($details['has_items']) $this->_have_run_sheets = TRUE; } } } @@ -259,6 +261,8 @@ function _printServiceProgram() $message = ''; if ($GLOBALS['user_system']->havePerm(PERM_EDITSERVICE)) { $message .= _('Click a service below to edit its run sheet'); + } else if ($this->_have_run_sheets) { + $message .= _('Click a service below to view its run sheet'); } if ($GLOBALS['user_system']->havePerm(PERM_BULKSERVICE)) { $message .= ', '._('or click the "edit" button above to edit the service schedule including bible readings and titles.'); @@ -419,16 +423,14 @@ function _printParamsForm() function _printServiceViewCell($congid, $date, $data) { if (empty($data)) return; - if ($GLOBALS['user_system']->havePerm(PERM_EDITSERVICE)) { - if ($data['has_items']) { - ?> - - - - + + havePerm(PERM_EDITSERVICE)) { + ?> + + _dummy_service->populate($data['id'], $data); $this->_dummy_service->printFieldValue('summary');