Skip to content

Fixed issue #41 #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: MOODLE_311_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## V1.9.1 08/03/2023
### Fixed
* Improve PHP 8.x compatability

## V1.9 – 04/11/2021
### Added
• Ability to add ogimage and HEAD content
Expand Down
8 changes: 5 additions & 3 deletions classes/custompage.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,17 @@ public static function load($id, $editor = false) {
require_once(dirname(__FILE__) . '/../lib.php');

$data = new \stdClass();
if (intval($id) > 0) {
$data = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE id=? LIMIT 1", array(intval($id)));
if ((int)$id > 0) {
$data = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE id=?", [(int)$id], IGNORE_MULTIPLE);
} else {

// Check url for page name.
$main = explode('?', trim($_SERVER['REQUEST_URI']));
$parts = explode("/", trim($main[0]));
$url = '%' . end($parts) . '%';
$page = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE menuname LIKE ? limit 1", array(trim($url)));
$like_menu_name = $DB->sql_like('menuname', '?');

$page = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE $like_menu_name", [trim($url)], IGNORE_MULTIPLE);

if ($page) {
$data = $page;
Expand Down
5 changes: 2 additions & 3 deletions forms/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,10 @@ public function validation($data, $files) {
*/
private function build_html_form() {
global $DB;
$usertable = $DB->get_record_sql("select * FROM {user} LIMIT 1");
$usertable = $DB->get_record_sql("select * FROM {user}", null, IGNORE_MULTIPLE);
$records = json_decode($this->_pagedata);

// PHP 7.2 now gives an error if the item cannot be counted - pre 7.2 it returned 0.
$limit = intval(@count($records));
$limit = (is_countable($records)) ? count($records) : 0;

$i = 0;
$html = '<div class="form-builder row" id="form-builder">' .
Expand Down
6 changes: 3 additions & 3 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function local_pages_build_menu(navigation_node $nav, $parent, global_navigation
$records = $DB->get_records_sql("SELECT * FROM {local_pages} WHERE deleted=0 AND onmenu=1 " .
"AND pagetype='page' AND pageparent=? AND pagedate <=? " .
"ORDER BY pageorder", array($parent, $today));
local_pages_process_records($records, $nav, false, $gnav);
local_pages_process_records($records, $nav, $gnav);
}

/**
Expand All @@ -99,7 +99,7 @@ function local_pages_build_menu(navigation_node $nav, $parent, global_navigation
* @throws dml_exception
* @throws moodle_exception
*/
function local_pages_process_records($records, $nav, $parent = false, global_navigation $gnav) {
function local_pages_process_records($records, $nav, global_navigation $gnav, $parent = false) {
global $CFG;
if ($records) {
foreach ($records as $page) {
Expand Down Expand Up @@ -175,7 +175,7 @@ function local_pages_extend_navigation(global_navigation $nav) {
$records = $DB->get_records_sql("SELECT * FROM {local_pages} WHERE deleted=0 AND onmenu=1 " .
"AND pagetype='page' AND pageparent=0 AND pagedate <= ? ORDER BY pageorder", array($today));

local_pages_process_records($records, $nav, false, $nav);
local_pages_process_records($records, $nav, $nav);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

defined('MOODLE_INTERNAL') || die;

$plugin->requires = 2020061500; // This plugin requires Moodle VER 3.9.
$plugin->version = 2021110400; // This plugins version number.
$plugin->release = 'v1.9'; // This plugins release number.
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'local_pages';
$plugin->requires = 2021051700; // Moodle 3.11
$plugin->version = 2023030800;
$plugin->release = '1.9.1';
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'local_pages';