diff --git a/classes/datalynx.php b/classes/datalynx.php index ec95b017..120a21ab 100644 --- a/classes/datalynx.php +++ b/classes/datalynx.php @@ -768,15 +768,13 @@ public function set_content() { * * @throws \coding_exception */ - public function display() { + public function display(): void { global $PAGE; if (!empty($this->_currentview)) { - $event = event\course_module_viewed::create( array('objectid' => $PAGE->cm->instance, 'context' => $PAGE->context)); $event->add_record_snapshot('course', $PAGE->course); $event->trigger(); - $this->_currentview->display(); } } @@ -787,11 +785,11 @@ public function display() { * * @param int $datalynxid The id of the datalynx whose content should be displayed. * @param int $viewid The id of the datalynx's view whose content should be displayed. - * @param int $eids The id of the datalynx entrie that should be displayed. + * @param ?int $eids The id of the datalynx entrie that should be displayed. * @param array $options bool skiplogincheck, bool tohtml, string pagelayout. * @return string */ - public static function get_content_inline(int $datalynxid, int $viewid = 0, ?int $eids = null, array $options = array('tohtml' => true)) { + public static function get_content_inline(int $datalynxid, int $viewid = 0, ?int $eids = null, array $options = ['tohtml' => true]) { global $CFG; require_once($CFG->dirroot . '/mod/datalynx/classes/view/base.php'); $urlparams = new stdClass(); @@ -843,7 +841,7 @@ public static function get_content_inline(int $datalynxid, int $viewid = 0, ?int * * @return array */ - public function get_internal_fields() { + public function get_internal_fields(): array { global $CFG; if (!$this->internalfields) { @@ -869,7 +867,7 @@ public function get_internal_fields() { * Return the names of the internal fields * @return array */ - public function get_internal_fields_names() { + public function get_internal_fields_names(): array { global $CFG; $fieldplugins = get_list_of_plugins('mod/datalynx/field/'); diff --git a/classes/view/base.php b/classes/view/base.php index dc1987ae..549d0568 100644 --- a/classes/view/base.php +++ b/classes/view/base.php @@ -85,11 +85,20 @@ abstract class base { protected array $_tags = []; - protected string|moodle_url $_baseurl = ''; + protected moodle_url $_baseurl; protected array $_notifications = ['good' => [], 'bad' => []]; - protected int|string $_editentries = ''; + /** + * Empty array: Not editing entries. + * One element: Editing one entry + * More elements with positive numbers: Editing entries with these ids. + * One element with -1: New entry + * Not sure: One element with -3: Three new entries? + * TODO: Array of strings should be converted to array of int. + * @var array + */ + protected array $_editentries = []; protected array $_display_definition = []; @@ -531,17 +540,20 @@ public function name_exists($name, $viewid) { * * @return mixed */ - public function process_data() { + public function process_data(): void { // Process entries data. $processed = $this->process_entries_data(); if (is_array($processed)) { + if ($processed[0] === -1) { + return; + } list($strnotify, $processedeids) = $processed; } else { - list($strnotify, $processedeids) = array('', ''); + list($strnotify, $processedeids) = ['', '']; } - if ($processedeids) { + if (!empty($processedeids)) { $this->_notifications['good']['entries'] = $strnotify; } else { if ($strnotify) { @@ -549,18 +561,20 @@ public function process_data() { } } - // With one entry per page show the saved entry. - if ($processedeids && $this->_editentries && !$this->_returntoentriesform) { + // TODO: Revise this. Does not seem to make much sense. Old description: With one entry per page show the saved entry. + if ($processedeids && !empty($this->_editentries) && !$this->_returntoentriesform) { if ($this->_filter->perpage == 1) { - $this->_filter->eids = $this->_editentries; + $this->_filter->eids = implode(',', $this->_editentries); } - $this->_editentries = 0; + $this->_editentries = []; } - return $processed; } /** * Retrieve the content for the fields which is saved in the table datalynx_contents + * + * @param array $options + * @return void */ public function set_content(array $options = array()) { // Options: added for datalynxview_field calling external view. @@ -568,7 +582,7 @@ public function set_content(array $options = array()) { if ($this->_returntoentriesform) { return; } - if ($this->_editentries >= 0 || $this->view->perpage != 1) { + if (!empty($this->_editentries) && $this->_editentries[0] >= 0 || $this->view->perpage != 1) { $this->_entries->set_content($options); } } @@ -579,16 +593,15 @@ public function set_content(array $options = array()) { * @param array $options (tohtml = true means output is returned instead of echoed) * @return string (empty string of tohtml = false, html when tohtml is true) */ - public function display(array $options = array()): string { + public function display(array $options = []): string { global $OUTPUT; - // Set display options. $new = optional_param('new', 0, PARAM_INT); - $displaycontrols = isset($options['controls']) ? $options['controls'] : true; - $showentryactions = isset($options['entryactions']) ? $options['entryactions'] : true; - $notify = isset($options['notify']) ? $options['notify'] : true; - $tohtml = isset($options['tohtml']) ? $options['tohtml'] : false; - $pluginfileurl = isset($options['pluginfileurl']) ? $options['pluginfileurl'] : null; + $displaycontrols = $options['controls'] ?? true; + $showentryactions = $options['entryactions'] ?? true; + $notify = $options['notify'] ?? true; + $tohtml = $options['tohtml'] ?? false; + $pluginfileurl = $options['pluginfileurl'] ?? null; // Build entries display definition. $requiresmanageentries = $this->set__display_definition($options); @@ -597,7 +610,7 @@ public function display(array $options = array()): string { $viewoptions = array('pluginfileurl' => $pluginfileurl, 'entriescount' => $this->_entries->get_count(), 'entriesfiltercount' => $this->_entries->get_count(true), - 'hidenewentry' => $this->user_is_editing() ? 1 : 0, + 'hidenewentry' => !empty($this->_editentries) ? 1 : 0, 'showentryactions' => $requiresmanageentries && $showentryactions); $this->set_view_tags($viewoptions); @@ -617,9 +630,8 @@ public function display(array $options = array()): string { $output = str_replace('##entries##', $this->display_no_entries(), $output); } } else { - $redirectid = $this->_redirect ? $this->_redirect : $this->id(); - $url = new moodle_url($this->_baseurl, array('view' => $redirectid)); - $output = $notifications . $OUTPUT->continue_button($url); + $entriesform = $this->get_entries_form(); + $output = $notifications . $entriesform->html(); } $viewname = 'datalynxview-' . preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $this->name())); @@ -631,7 +643,6 @@ public function display(array $options = array()): string { } else { echo $output; } - return ''; } @@ -644,10 +655,10 @@ protected function print_notifications() { global $OUTPUT; $notifications = ''; foreach ($this->_notifications['good'] as $notification) { - $notifications = $OUTPUT->notification($notification, 'notifysuccess'); + $notifications .= $OUTPUT->notification($notification, 'notifysuccess'); } foreach ($this->_notifications['bad'] as $notification) { - $notifications = $OUTPUT->notification($notification); + $notifications .= $OUTPUT->notification($notification); } return $notifications; } @@ -1143,20 +1154,21 @@ protected function get_grading_options() { * @return string */ public function display_entries(array $options = null): string { - global $DB, $OUTPUT; + global $DB, $OUTPUT, $CFG; - if (!$this->user_is_editing()) { + if (empty($this->_editentries)) { $html = $this->definition_to_html(); if (isset($options['pluginfileurl'])) { $html = $this->replace_pluginfile_urls($html, $options['pluginfileurl']); } } else { $editallowed = false; + // TODO: is this compatible for editing multiple entries? Check if this has to be changed. Check if isset is necessary. if ($editallowed = $this->get_dl()->user_can_manage_entry()) { - if (count(explode(",", $this->_editentries)) == 1) { + if (isset($this->_editentries[0]) && count($this->_editentries) == 1) { $entrystatus = $DB->get_field('datalynx_entries', 'status', - array('id' => $this->_editentries)); - require_once('field/_status/field_class.php'); + array('id' => $this->_editentries[0])); + require_once($CFG->dirroot . '/mod/datalynx/field/_status/field_class.php'); if (!has_capability('mod/datalynx:manageentries', $this->_df->context) && $entrystatus == datalynxfield__status::STATUS_FINAL_SUBMISSION) { $editallowed = false; @@ -1216,10 +1228,11 @@ public function definition_to_form(HTML_QuickForm &$mform) { } /** + * Get view specific form for data input via Moodle form. * * @return datalynxview_entries_form */ - protected function get_entries_form() { + protected function get_entries_form(): ?datalynxview_entries_form { static $entriesform = null; if ($entriesform == null) { @@ -1227,11 +1240,11 @@ protected function get_entries_form() { // Prepare params for for content management. $actionparams = array('d' => $this->_df->id(), 'view' => $this->id(), 'page' => $this->_filter->page, 'eids' => $this->_filter->eids, - 'update' => $this->_editentries, + 'update' => implode(',', $this->_editentries), 'sourceview' => optional_param('sourceview', null, PARAM_INT) ); $actionurl = new moodle_url("/mod/datalynx/{$this->_df->pagefile()}.php", $actionparams); - $customdata = array('view' => $this, 'update' => $this->_editentries); + $customdata = array('view' => $this, 'update' => implode(',', $this->_editentries)); $formclass = 'datalynxview_entries_form'; require_once("$CFG->dirroot/mod/datalynx/view/view_entries_form.php"); @@ -1316,7 +1329,7 @@ protected function get_entry_tag_replacements($entry, $options) { * Set display definition * * @param array|null $options - * @return booly + * @return bool * @throws coding_exception */ protected function set__display_definition(array $options = null) { @@ -1325,19 +1338,17 @@ protected function set__display_definition(array $options = null) { // In which case edit/delete action. $requiresmanageentries = false; - $editentries = null; + $editentries = []; // Display a new entry to add in its own group. - if ($this->_editentries < 0 && $this->_editentries != "") { + if (count($this->_editentries) == 1 && $this->_editentries[0] < 0) { if ($this->_df->user_can_manage_entry()) { $this->_display_definition['newentry'] = array(); - for ($i = -1; $i >= $this->_editentries; $i--) { + for ($i = -1; $i >= $this->_editentries[0]; $i--) { $this->_display_definition['newentry'][$i] = null; } } } else { - if ($this->_editentries) { - $editentries = explode(',', $this->_editentries); - } + $editentries = $this->_editentries; } // Compile entries if any. @@ -1487,8 +1498,9 @@ public function get_filter() { } /** + * @return moodle_url */ - public function get_baseurl() { + public function get_baseurl(): moodle_url { return $this->_baseurl; } @@ -1517,7 +1529,7 @@ public function is_forcing_filter() { /** */ - public function user_is_editing() { + public function user_is_editing(): array { return $this->_editentries; } @@ -1531,6 +1543,24 @@ public function process_entries_data() { // Check first if returning from form. $update = optional_param('update', '', PARAM_RAW); + // Direct url params; not from form. + $new = optional_param('new', 0, PARAM_INT); // Open new entry form. + // Edit entries(all) or by record ids (comma delimited eids). + $editentries = optional_param('editentries', 0, PARAM_SEQUENCE); + $editentries = explode(',', $editentries); + // Duplicate entries (all) or by record ids (comma delimited eids). + $duplicate = optional_param('duplicate', '', PARAM_SEQUENCE); + // Delete entries (all) or by record Ids (comma delimited eids). + $delete = optional_param('delete', '', PARAM_SEQUENCE); + // Approve entries (all) or by record ids (comma delimited eids). + $approve = optional_param('approve', '', PARAM_SEQUENCE); + // Disapprove entries (all)or by record ids (comma delimited eids). + $disapprove = optional_param('disapprove', '', PARAM_SEQUENCE); + // Set status of entries (all) or by record ids (comma delimited eids). + $status = optional_param('status', '', PARAM_SEQUENCE); + // Confirm submission of data. + $confirmed = optional_param('confirmed', 0, PARAM_BOOL); + if ($update) { $action = ($update != self::ADD_NEW_ENTRY) ? "edit" : "addnewentry"; if (confirm_sesskey() && $this->confirm_view_action($action)) { @@ -1541,7 +1571,7 @@ public function process_entries_data() { } // Set the display definition for the form. - $this->_editentries = $update; + $this->_editentries = explode(',', $update); $this->set__display_definition(); $entriesform = $this->get_entries_form(); @@ -1552,39 +1582,27 @@ public function process_entries_data() { // Validated successfully so process request. $processed = $this->_entries->process_entries('update', $update, $data, true); + if (!$processed) { $this->_returntoentriesform = true; return false; } - - if (!empty($data->submitreturnbutton)) { - // If we have just added new entries refresh the content. - // This is far from ideal because this new entries may be. - // Spread out in the form when we return to edit them. - if ($this->_editentries < 0) { - $this->_entries->set_content(); - } - - // So that return after adding new entry will return the added entry. - $this->_editentries = is_array($processed[1]) ? implode(',', - $processed[1]) : $processed[1]; - $this->_returntoentriesform = true; - return true; + // So that we can show the new entries if we so wish. + if (isset($this->_editentries[0]) && $this->_editentries[0] < 0) { + $this->_editentries = is_array($processed[1]) ? $processed[1] : [$processed[1]]; } else { - // So that we can show the new entries if we so wish. - if ($this->_editentries < 0) { - $this->_editentries = is_array($processed[1]) ? implode(',', - $processed[1]) : $processed[1]; - } else { - $this->_editentries = 0; - } - $this->_returntoentriesform = true; - return $processed; + $this->_editentries = []; } + // TODO: Replace with more standard way to tell datalynx there is no new entry anymore to edit. + $_POST['new'] = 0; + $this->_entries->set_content(); + return $processed; } else { // Form validation failed so return to form. $this->_returntoentriesform = true; - return false; + $formdata = (array) $entriesform->get_submitted_data(); + $errors = $entriesform->validation($formdata, []); + return array(implode('
', $errors), []); } } else { $redirectid = $this->_redirect ? $this->_redirect : $this->id(); @@ -1597,23 +1615,7 @@ public function process_entries_data() { } } - // Direct url params; not from form. - $new = optional_param('new', 0, PARAM_INT); // Open new entry form. - // Edit entries(all) or by record ids (comma delimited eids). - $editentries = optional_param('editentries', 0, PARAM_SEQUENCE); - // Duplicate entries (all) or by record ids (comma delimited eids). - $duplicate = optional_param('duplicate', '', PARAM_SEQUENCE); - // Delete entries (all) or by record Ids (comma delimited eids). - $delete = optional_param('delete', '', PARAM_SEQUENCE); - // Approve entries (all) or by record ids (comma delimited eids). - $approve = optional_param('approve', '', PARAM_SEQUENCE); - // Disapprove entries (all)or by record ids (comma delimited eids). - $disapprove = optional_param('disapprove', '', PARAM_SEQUENCE); - // Set status of entries (all) or by record ids (comma delimited eids). - $status = optional_param('status', '', PARAM_SEQUENCE); - - $confirmed = optional_param('confirmed', 0, PARAM_BOOL); - + // TODO: Check if this is the right place to assign the var. $this->_editentries = $editentries; if ($new) { @@ -1621,7 +1623,7 @@ public function process_entries_data() { ($this->confirm_view_action("addnewentry") || $this->confirm_view_action("addnewentries")) ) { - return $this->_editentries = -$new; + return $this->_editentries = [-$new]; } else { $illegalaction = true; } diff --git a/entries_class.php b/entries_class.php index 470842e8..bab3d4d6 100644 --- a/entries_class.php +++ b/entries_class.php @@ -508,28 +508,25 @@ public function get_contentinfo(array $fids) { * Process entries when after editing content for saving into db * * @param string $action - * @param string||array $eids + * @param string $eids * @param null $data * @param bool $confirmed * @return array notificationstrings, list of processed ids - * @throws coding_exception - * @throws dml_exception - * @throws moodle_exception */ public function process_entries(string $action, $eids, $data = null, bool $confirmed = false): array { global $DB, $USER, $OUTPUT, $PAGE; $dl = $this->datalynx; $errorstring = ''; - $entries = array(); + $entries = []; // Some entries may be specified for action. if ($eids) { - $importentryids = array(); + $importentryids = []; // Adding or updating entries. if ($action == 'update') { if (!is_array($eids)) { // Adding new entries. - if ($eids < 0) { + if ((int)$eids < 0) { $eids = array_reverse(range($eids, -1)); // Editing existing entries. } else { @@ -746,7 +743,6 @@ public function process_entries(string $action, $eids, $data = null, bool $confi } $contents = $newcontents; - global $DB; // Now update entry and contents TODO: TEAM_CHANGED - check this! $addorupdate = ''; foreach ($entries as $eid => $entry) { diff --git a/filter/filter_class.php b/filter/filter_class.php index d996867d..546c0dbf 100644 --- a/filter/filter_class.php +++ b/filter/filter_class.php @@ -82,7 +82,9 @@ public function __construct($filterdata) { } $this->contentfields = empty($filterdata->contentfields) ? null : $filterdata->contentfields; + // TODO: Make eids string only and then do ? '' instead of null value. $this->eids = empty($filterdata->eids) ? null : $filterdata->eids; + $this->users = empty($filterdata->users) ? null : $filterdata->users; $this->groups = empty($filterdata->groups) ? null : $filterdata->groups; $this->page = empty($filterdata->page) ? 0 : $filterdata->page; diff --git a/tests/behat/fieldgroup_field.feature b/tests/behat/fieldgroup_field.feature index d35ffbb4..b780b1ff 100644 --- a/tests/behat/fieldgroup_field.feature +++ b/tests/behat/fieldgroup_field.feature @@ -36,7 +36,7 @@ Feature: Create entry and add fieldgroups # | select | Select | | Option X,Option Y,Option Z | | | | teammemberselect | Team member select | 3 | 20 | 1,2,4,8 | | And I add to "Datalynx Test Instance" datalynx the view of "Grid" type with: - | name | Gridview | + | name | Gridview | | description | Testgrid | And I follow "Set as default view" And I follow "Set as edit view" diff --git a/version.php b/version.php index 1addd064..85c49927 100644 --- a/version.php +++ b/version.php @@ -24,7 +24,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'mod_datalynx'; -$plugin->version = 2024091200; +$plugin->version = 2024092000; $plugin->release = 'v4.6-DataTreasure'; // Data words like data science, data mining. $plugin->requires = 2022112800; $plugin->maturity = MATURITY_STABLE; diff --git a/view/csv/view_class.php b/view/csv/view_class.php index db36d39b..7bfd4662 100644 --- a/view/csv/view_class.php +++ b/view/csv/view_class.php @@ -112,7 +112,7 @@ protected function apply_entry_group_layout($entriesset, $name = '') { /** * process any view specific actions */ - public function process_data() { + public function process_data(): void { global $CFG; // Proces csv export request. @@ -233,15 +233,14 @@ protected function set__patterns() { /** * Overridden to show import form without entries * @param array $options - * @return string|void - * @throws moodle_exception + * @return string */ public function display(array $options = []): string { if ($this->_showimportform) { $mform = $this->get_import_form(); - $tohtml = isset($params['tohtml']) ? $params['tohtml'] : false; + $tohtml = $params['tohtml'] ?? false; // Print view. $viewname = 'datalynxview-' . preg_replace('/[^A-Za-z0-9\-]/', '', str_replace(' ', '-', $this->name())); if ($tohtml) { diff --git a/view/csv/view_patterns.php b/view/csv/view_patterns.php index 30985b24..c6f21fb6 100644 --- a/view/csv/view_patterns.php +++ b/view/csv/view_patterns.php @@ -74,8 +74,10 @@ public function get_replacements($tags = null, $entry = null, array $options = [ } /** + * @param $checkvisibility + * @return array */ - protected function patterns($checkvisibility = true) { + protected function patterns($checkvisibility = true): array { $patterns = parent::patterns($checkvisibility); $cat = get_string('pluginname', 'datalynxview_csv'); $patterns['##export:all##'] = array(true, $cat); diff --git a/view/pdf/view_class.php b/view/pdf/view_class.php index 21f84b66..a6cd5687 100644 --- a/view/pdf/view_class.php +++ b/view/pdf/view_class.php @@ -135,8 +135,7 @@ public function __construct($df = 0, $view = 0) { /** * process any view specific actions */ - public function process_data() { - + public function process_data(): void { // Process pdf export request. if (optional_param('pdfexportall', 0, PARAM_INT)) { $this->process_export(self::EXPORT_ALL); @@ -151,7 +150,7 @@ public function process_data() { } // Do standard view processing. - return parent::process_data(); + parent::process_data(); } /** @@ -453,7 +452,7 @@ public function generate_default_view() { // Fields. foreach ($fields as $field) { - if ($field->field->id > 0) { + if (is_numeric($field->field->id) && $field->field->id > 0) { $name = new html_table_cell($field->name() . ':'); $name->style = 'text-align:right;'; if ($field->type == "userinfo") { @@ -478,6 +477,9 @@ public function generate_default_view() { } /** + * @param $entriesset + * @param $name string + * @return array */ protected function apply_entry_group_layout($entriesset, $name = '') { global $OUTPUT; diff --git a/view/pdf/view_patterns.php b/view/pdf/view_patterns.php index 1b0ad7b8..a22b666e 100644 --- a/view/pdf/view_patterns.php +++ b/view/pdf/view_patterns.php @@ -70,7 +70,7 @@ public function get_replacements($tags = null, $entry = null, array $options = [ /** */ - protected function patterns($checkvisibility = true) { + protected function patterns($checkvisibility = true): array { $patterns = parent::patterns($checkvisibility); $cat = get_string('pluginname', 'datalynxview_pdf'); $patterns['##export:all##'] = array(true, $cat); diff --git a/view/report/view_class.php b/view/report/view_class.php index 8cdb7b9a..cfae02fc 100644 --- a/view/report/view_class.php +++ b/view/report/view_class.php @@ -86,14 +86,6 @@ protected function new_entry_definition($entryid = -1) { return []; } - /** - * Process any view specific data. - * @return array|bool|mixed - */ - public function process_data() { - return parent::process_data(); - } - /** * @param $fielddefinitions * @return array diff --git a/view/report/view_form.php b/view/report/view_form.php index cafcc2ea..72cc32f4 100644 --- a/view/report/view_form.php +++ b/view/report/view_form.php @@ -34,7 +34,7 @@ class datalynxview_report_form extends datalynxview_base_form { */ public function view_definition_after_gps(): void { $mform = &$this->_form; - + $options = []; $mform->addElement('header', 'settingshdr', get_string('settings')); // Report count for this field (only select supported right now: A sum of the values choson for this field is being created. @@ -48,7 +48,7 @@ public function view_definition_after_gps(): void { } if (!empty($fieldnames)) { asort($fieldnames); - $options = array('multiple' => false); + $options = ['multiple' => false]; $mform->addElement('autocomplete', 'param1', get_string('fieldtobecounted', 'datalynxview_report'), $fieldnames, $options); $mform->addHelpButton('param1', 'fieldtobecounted', 'datalynxview_report'); diff --git a/view/report/view_patterns.php b/view/report/view_patterns.php index 06413d41..f63c389c 100644 --- a/view/report/view_patterns.php +++ b/view/report/view_patterns.php @@ -74,8 +74,10 @@ public function get_replacements($tags = null, $entry = null, array $options = [ } /** + * @param $checkvisibility + * @return array */ - protected function patterns($checkvisibility = true) { + protected function patterns($checkvisibility = true): array { $patterns = parent::patterns($checkvisibility); $cat = get_string('pluginname', 'datalynxview_report'); $patterns['##export:all##'] = array(true, $cat); diff --git a/view/view_form.php b/view/view_form.php index b233f404..52c6b894 100644 --- a/view/view_form.php +++ b/view/view_form.php @@ -357,13 +357,13 @@ public function validation($data, $files) { foreach ($fields['Fields']['Fields'] as $field) { // Error when we find more than one instance of this tag. - if (substr_count($entryview, $field) > 1) { + if (is_array($field)) { // Make sure multiple errors are shown. if (!array_key_exists('eparam2_editor', $errors)) { - $errors['eparam2_editor'] = get_string('viewrepeatedfields', 'datalynx', substr($field, 2, -2)); + $errors['eparam2_editor'] = get_string('viewrepeatedfields', 'datalynx', substr($field[0], 2, -2)); } else { - $errors['eparam2_editor'] .= "
" . get_string('viewrepeatedfields', 'datalynx', substr($field, 2, -2)); + $errors['eparam2_editor'] .= "
" . get_string('viewrepeatedfields', 'datalynx', substr($field[0], 2, -2)); } } diff --git a/view/view_patterns.php b/view/view_patterns.php index 170f3e0e..96181ed0 100644 --- a/view/view_patterns.php +++ b/view/view_patterns.php @@ -348,7 +348,7 @@ protected function get_userpref_replacements($tag, array $options = null) { case '##advancedfilter##': return $this->print_advanced_filter($filter, true); } - if (strpos($tag, '##customfilter') !== false && !$view->user_is_editing()) { + if (strpos($tag, '##customfilter') !== false && empty($view->user_is_editing())) { return $this->print_custom_filter($tag, true); } } @@ -653,7 +653,7 @@ protected function get_viewcontent_replacement(?string $viewname = null): string * @param boolean $checkvisibility if true only views visible to user are considered * @return array of tags/patterns */ - protected function patterns($checkvisibility = true) { + protected function patterns($checkvisibility = true): array { $patterns = array_merge($this->info_patterns(), $this->ref_patterns($checkvisibility), $this->userpref_patterns(), $this->action_patterns(), $this->paging_patterns(), $this->bulkedit_patterns()); @@ -899,7 +899,7 @@ protected function print_filters_menu($options, $return = false) { $view = $this->_view; // If in edit view filters should never be displayed. - if ($view->user_is_editing()) { + if (!empty($view->user_is_editing())) { return ''; }