Skip to content
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
20 changes: 19 additions & 1 deletion .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

services:
postgres:
image: postgres:14
image: postgres:15
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
Expand Down Expand Up @@ -49,6 +49,12 @@ jobs:
- php: 8.2
moodle-branch: MOODLE_500_STABLE
database: pgsql
- php: 8.2
moodle-branch: MOODLE_501_STABLE
database: mariadb
- php: 8.2
moodle-branch: MOODLE_501_STABLE
database: pgsql
- php: 8.3
moodle-branch: MOODLE_405_STABLE
database: mariadb
Expand All @@ -61,12 +67,24 @@ jobs:
- php: 8.3
moodle-branch: MOODLE_500_STABLE
database: pgsql
- php: 8.3
moodle-branch: MOODLE_501_STABLE
database: mariadb
- php: 8.3
moodle-branch: MOODLE_501_STABLE
database: pgsql
- php: 8.4
moodle-branch: MOODLE_500_STABLE
database: mariadb
- php: 8.4
moodle-branch: MOODLE_500_STABLE
database: pgsql
- php: 8.4
moodle-branch: MOODLE_501_STABLE
database: mariadb
- php: 8.4
moodle-branch: MOODLE_501_STABLE
database: pgsql

steps:
- name: Check out repository code
Expand Down
5 changes: 2 additions & 3 deletions backup/moodle2/backup_lightboxgallery_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* @package mod_lightboxgallery
*/
class backup_lightboxgallery_activity_task extends backup_activity_task {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lucaboesch Moodle coding style has the opening brace for classes on the same line as the class name - not the next line (same as function declarations). I'm guessing your lint rules or whatever you're using to check these is missing that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

If you could check again, please?

Best,
Luca


/**
* Define (add) particular settings this activity can have
*/
Expand Down Expand Up @@ -60,11 +59,11 @@ public static function encode_content_links($content) {
$base = preg_quote($CFG->wwwroot, "/");

// Link to the list of pages.
$search = "/(".$base."\/mod\/lightboxgallery\/index.php\?id\=)([0-9]+)/";
$search = "/(" . $base . "\/mod\/lightboxgallery\/index.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@LIGHTBOXGALLERYINDEX*$2@$', $content);

// Link to page view by moduleid.
$search = "/(".$base."\/mod\/lightboxgallery\/view.php\?id\=)([0-9]+)/";
$search = "/(" . $base . "\/mod\/lightboxgallery\/view.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@LIGHTBOXGALLERYVIEWBYID*$2@$', $content);

return $content;
Expand Down
1 change: 0 additions & 1 deletion backup/moodle2/backup_lightboxgallery_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* Define the complete lightboxgallery structure for backup, with file and id annotations
*/
class backup_lightboxgallery_activity_structure_step extends backup_activity_structure_step {

/**
* Define the backup structure for this activity
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
* complete restore of the activity
*/
class restore_lightboxgallery_activity_task extends restore_activity_task {

/**
* Define (add) particular settings this activity can have
*/
Expand Down Expand Up @@ -68,7 +67,6 @@ public static function define_decode_rules() {
$rules[] = new restore_decode_rule('LIGHTBOXGALLERYINDEX', '/mod/lightboxgallery/index.php?id=$1', 'course');

return $rules;

}

/**
Expand Down
2 changes: 1 addition & 1 deletion backup/moodle2/restore_lightboxgallery_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* Structure step to restore one lightboxgallery activity
*/
class restore_lightboxgallery_activity_structure_step extends restore_activity_structure_step {

/**
* Define (add) particular settings this activity can have
*
Expand Down Expand Up @@ -96,6 +95,7 @@ protected function process_lightboxgallery_comment($data) {
if (isset($data->comment)) {
$data->commenttext = $data->comment;
}

$DB->insert_record('lightboxgallery_comments', $data);
}

Expand Down
1 change: 0 additions & 1 deletion classes/event/course_module_instance_list_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed {
// No code required here as the parent class handles it all.
}

2 changes: 0 additions & 2 deletions classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_viewed extends \core\event\course_module_viewed {

/**
* Init method.
*
Expand All @@ -68,5 +67,4 @@ public function get_url() {
public static function get_objectid_mapping() {
return ['db' => 'lightboxgallery', 'restore' => 'lightboxgallery'];
}

}
11 changes: 5 additions & 6 deletions classes/event/gallery_searched.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class gallery_searched extends \core\event\base {

/**
* Init method.
*
Expand All @@ -58,7 +57,7 @@ protected function init() {
*/
public function get_description() {
$searchterm = s($this->other['searchterm']);
return "The user with id '$this->userid' has searched the lightboxgallery with id '{$this->other['lightboxgalleryid']}'".
return "The user with id '$this->userid' has searched the lightboxgallery with id '{$this->other['lightboxgalleryid']}'" .
" for lightboxgallery images containing \"{$searchterm}\".";
}

Expand All @@ -77,8 +76,10 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/lightboxgallery/search.php',
['id' => $this->courseid, 'gallery' => $this->other['lightboxgalleryid'], 'search' => $this->other['searchterm']]);
return new \moodle_url(
'/mod/lightboxgallery/search.php',
['id' => $this->courseid, 'gallery' => $this->other['lightboxgalleryid'], 'search' => $this->other['searchterm']]
);
}

/**
Expand Down Expand Up @@ -106,6 +107,4 @@ protected function validate_data() {
public static function get_other_mapping() {
return [];
}

}

16 changes: 11 additions & 5 deletions classes/gallery_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@

defined('MOODLE_INTERNAL') || die();

require_once(dirname(__FILE__).'/../imageclass.php');
require_once(dirname(__FILE__) . '/../imageclass.php');

/**
* This class is used to display a page of images in the gallery.
*/
class gallery_page {

/**
* Sort by filename.
*/
Expand Down Expand Up @@ -115,10 +114,17 @@ public function __construct($cm, $gallery, $editing = false, $page = 0) {
public function display_images() {
$html = '';
foreach ($this->pagefiles as $filename => $file) {
$image = new \lightboxgallery_image($file, $this->gallery, $this->cm,
$this->metadata[$filename], $this->pagethumbs[$filename], $this->gallery->extinfo);
$image = new \lightboxgallery_image(
$file,
$this->gallery,
$this->cm,
$this->metadata[$filename],
$this->pagethumbs[$filename],
$this->gallery->extinfo
);
$html .= $image->get_image_display_html($this->editing);
}

return $html;
}

Expand Down Expand Up @@ -155,7 +161,7 @@ protected function load_metadata() {
return;
}

list ($insql, $params) = $DB->get_in_or_equal($filenames, SQL_PARAMS_NAMED);
[$insql, $params] = $DB->get_in_or_equal($filenames, SQL_PARAMS_NAMED);
$params['gallery'] = $this->gallery->id;
$select = "gallery = :gallery AND image $insql";
$metadata = $DB->get_records_select('lightboxgallery_image_meta', $select, $params);
Expand Down
18 changes: 9 additions & 9 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
// This plugin stores personal data.
\core_privacy\local\metadata\provider,
\core_privacy\local\request\core_userlist_provider,

// This plugin is a core_user_data_provider.
\core_privacy\local\request\plugin\provider {

\core_privacy\local\request\core_userlist_provider,
\core_privacy\local\metadata\provider,
\core_privacy\local\request\plugin\provider {
/**
* Return the fields which contain personal data.
*
Expand Down Expand Up @@ -108,7 +104,7 @@ public static function export_user_data(approved_contextlist $contextlist) {

$user = $contextlist->get_user();

list($contextsql, $contextparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
[$contextsql, $contextparams] = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);

$sql = "SELECT cm.id AS cmid,
lbgc.commenttext,
Expand Down Expand Up @@ -138,14 +134,17 @@ public static function export_user_data(approved_contextlist $contextlist) {
$context = \context_module::instance($lastcmid);
self::export_lightboxgallery_data_for_user($commentdata, $context, $user);
}

$commentdata = [];
}

$commentdata['comments'][] = [
'commenttext' => $comment->commenttext,
'timemodified' => \core_privacy\local\request\transform::datetime($comment->timemodified),
];
$lastcmid = $comment->cmid;
}

$lbgcomments->close();

// The data for the last activity won't have been written yet, so make sure to write it now!
Expand Down Expand Up @@ -243,7 +242,7 @@ public static function delete_data_for_users(approved_userlist $userlist) {
}

// Prepare the SQL we'll need below.
list($insql, $inparams) = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
[$insql, $inparams] = $DB->get_in_or_equal($userids, SQL_PARAMS_NAMED);
$sql = "gallery = :instanceid AND userid {$insql}";
$params = array_merge($inparams, ['instanceid' => $instanceid]);

Expand Down Expand Up @@ -279,6 +278,7 @@ public static function delete_data_for_user(approved_contextlist $contextlist) {
if (!$context instanceof \context_module) {
continue;
}

$instanceid = $DB->get_field('course_modules', 'instance', ['id' => $context->instanceid], MUST_EXIST);
$DB->delete_records('lightboxgallery_comments', ['gallery' => $instanceid, 'userid' => $userid]);
}
Expand Down
21 changes: 12 additions & 9 deletions comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
*/


require_once(dirname(dirname(dirname(__FILE__))).'/config.php');
require_once(dirname(__FILE__).'/locallib.php');
require_once(dirname(__FILE__).'/comment_form.php');
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once(dirname(__FILE__) . '/locallib.php');
require_once(dirname(__FILE__) . '/comment_form.php');

$id = required_param('id', PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
Expand All @@ -34,7 +34,8 @@
if (!$gallery = $DB->get_record('lightboxgallery', ['id' => $id])) {
throw new \moodle_exception('invalidlightboxgalleryid', 'lightboxgallery');
}
list($course, $cm) = get_course_and_cm_from_instance($gallery, 'lightboxgallery');

[$course, $cm] = get_course_and_cm_from_instance($gallery, 'lightboxgallery');

if ($delete && ! $comment = $DB->get_record('lightboxgallery_comments', ['gallery' => $gallery->id, 'id' => $delete])) {
throw new \moodle_exception('Invalid comment ID');
Expand All @@ -49,7 +50,7 @@

$context = context_module::instance($cm->id);

$galleryurl = $CFG->wwwroot.'/mod/lightboxgallery/view.php?id='.$cm->id;
$galleryurl = $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id;

if ($delete && has_capability('mod/lightboxgallery:edit', $context)) {
if ($confirm && confirm_sesskey()) {
Expand All @@ -61,9 +62,11 @@
echo('<br />');
$paramsyes = ['id' => $gallery->id, 'delete' => $comment->id, 'sesskey' => sesskey(), 'confirm' => 1];
$paramsno = ['id' => $cm->id];
echo $OUTPUT->confirm(get_string('commentdelete', 'lightboxgallery'),
new moodle_url('/mod/lightboxgallery/comment.php', $paramsyes),
new moodle_url('/mod/lightboxgallery/view.php', $paramsno));
echo $OUTPUT->confirm(
get_string('commentdelete', 'lightboxgallery'),
new moodle_url('/mod/lightboxgallery/comment.php', $paramsyes),
new moodle_url('/mod/lightboxgallery/view.php', $paramsno)
);
echo $OUTPUT->footer();
die();
}
Expand All @@ -80,7 +83,7 @@
if ($mform->is_cancelled()) {
redirect($galleryurl);
} else if ($formadata = $mform->get_data()) {
$newcomment = new stdClass;
$newcomment = new stdClass();
$newcomment->gallery = $gallery->id;
$newcomment->userid = $USER->id;
$newcomment->commenttext = $formadata->comment['text'];
Expand Down
4 changes: 1 addition & 3 deletions comment_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@

defined('MOODLE_INTERNAL') || die();

require_once($CFG->libdir.'/formslib.php');
require_once($CFG->libdir . '/formslib.php');

/**
* Form for adding comments on a gallery
*/
class mod_lightboxgallery_comment_form extends moodleform {

/**
* Form definition
*
Expand All @@ -53,6 +52,5 @@ public function definition() {
$mform->setType('id', PARAM_INT);

$this->add_action_buttons(true, $straddcomment);

}
}
Loading