diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index b0b208b..e99d588 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -2,13 +2,17 @@ name: Moodle Plugin CI on: [push, pull_request] +# Nothing here writes to the repository. +permissions: + contents: read + jobs: test: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 services: postgres: - image: postgres:15 + image: postgres:17 env: POSTGRES_USER: 'postgres' POSTGRES_HOST_AUTH_METHOD: 'trust' @@ -17,7 +21,7 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 mariadb: - image: mariadb:10.11 + image: mariadb:11.4 env: MYSQL_USER: 'root' MYSQL_ALLOW_EMPTY_PASSWORD: "true" @@ -25,43 +29,49 @@ jobs: MYSQL_COLLATION_SERVER: "utf8mb4_unicode_ci" ports: - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 + options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval 10s --health-timeout 5s --health-retries 5 strategy: fail-fast: false matrix: + # Each Moodle branch is paired only with PHP versions it actually supports, so a red + # job means the plugin is broken rather than the combination being impossible. include: - # Moodle 4.0.1 - PHP 7.4, 8.0, 8.1 - - php: '7.4' - moodle-branch: 'MOODLE_401_STABLE' - database: pgsql - - php: '8.0' - moodle-branch: 'MOODLE_401_STABLE' - database: pgsql + # Moodle 4.1 LTS - oldest release this plugin is tested against. - php: '8.1' moodle-branch: 'MOODLE_401_STABLE' database: pgsql - - php: '7.4' - moodle-branch: 'MOODLE_401_STABLE' - database: mariadb - - php: '8.0' - moodle-branch: 'MOODLE_401_STABLE' - database: mariadb - php: '8.1' moodle-branch: 'MOODLE_401_STABLE' database: mariadb - # Moodle 4.0.5 - 8.1, 8.2 + # Moodle 4.5 LTS - what the plugins directory currently advertises. - php: '8.1' moodle-branch: 'MOODLE_405_STABLE' database: pgsql - - php: '8.2' - moodle-branch: 'MOODLE_405_STABLE' - database: pgsql - - php: '8.1' + - php: '8.3' moodle-branch: 'MOODLE_405_STABLE' database: mariadb + # Moodle 5.0 - php: '8.2' - moodle-branch: 'MOODLE_405_STABLE' + moodle-branch: 'MOODLE_500_STABLE' + database: pgsql + - php: '8.3' + moodle-branch: 'MOODLE_500_STABLE' + database: mariadb + # Moodle 5.1 - first release with the public/ directory layout. + - php: '8.3' + moodle-branch: 'MOODLE_501_STABLE' + database: pgsql + # Moodle 5.2 + - php: '8.3' + moodle-branch: 'MOODLE_502_STABLE' + database: mariadb + # Moodle 5.3 - latest release. + - php: '8.3' + moodle-branch: 'MOODLE_503_STABLE' + database: pgsql + - php: '8.3' + moodle-branch: 'MOODLE_503_STABLE' database: mariadb steps: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c5e9e3d..dfec0ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,22 +4,28 @@ on: release: types: [created] +# Publishing the release asset is the only thing this workflow needs to write. +permissions: + contents: write + jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 + # Checking out straight into the plugin directory name gives the ZIP its required + # layout without copying, which previously nested a partial copy of the plugin + # inside itself because the glob already matched the freshly created directory. + - name: Check out into the plugin directory + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + path: mod_clickmeeting - name: Create ZIP file - run: | - mkdir mod_clickmeeting - cp -R * mod_clickmeeting/ 2>/dev/null || true - zip -r mod_clickmeeting.zip mod_clickmeeting -x "*.git*" + run: zip -r mod_clickmeeting.zip mod_clickmeeting -x "*.git*" - name: Upload Release Asset - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2 with: files: mod_clickmeeting.zip env: diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d5728d1 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,47 @@ +# Changelog + +## v1.2.0 (2026-10-08) + +Fixes meetings and recordings disappearing from ClickMeeting without anyone deleting them +on purpose. + +### Fixed + +- **Deleting an activity no longer destroys the room immediately.** Moodle activity deletion + is reversible — it goes through the recycle bin and runs from cron — but the room in + ClickMeeting was being deleted right away. Restoring the activity brought back a link to a + room that no longer existed. Rooms now outlive their activity by a configurable grace + period, five months by default. +- **A room shared by several activities survives.** Copying, importing or restoring a course + duplicates the activity while both copies keep pointing at the same ClickMeeting room. + Deleting either copy destroyed the room for the other one, in a course nobody had touched. + A room is now only deleted once no activity refers to it. +- **Deletions use the room owner's API key.** The key was taken from whoever happened to be + acting, which under cron is nobody in particular, so the request fell back to the main + account key and could reach a room on a different subaccount. +- **Activities whose room record is missing can be deleted again.** Previously the deletion + failed indefinitely and the activity could never be removed from the course. +- **Access tokens are removed with their activity.** They identify participants and were + being left behind in the database. + +### Added + +- Admin setting "Keep deleted rooms for" (`clickmeeting/graceperiod`), default five months. +- Scheduled task `mod_clickmeeting\task\purge_deleted_rooms`, which deletes rooms once their + grace period has passed. Runs daily at 03:20. +- Event `mod_clickmeeting\event\room_deleted`, logged whenever a room is really deleted, so + a missing meeting can be traced back to when and why it went away. +- PHPUnit coverage for the deletion lifecycle. +- Privacy API support for the new table: the room owner is discoverable and is cleared on an + erasure request, while the room itself stays scheduled for deletion. + +### Compatibility + +Declares `$plugin->supported = [39, 503]`: Moodle 3.9 LTS through 5.3, each verified with a +clean install and a v1.1.5 upgrade. This is advisory - it does not block installation - and +makes the plugin show as compatible for Moodle 5.x in the plugins directory. + +### Upgrade notes + +Adds the table `clickmeeting_room_deletions`. Existing data is untouched. Rooms already +deleted before this release cannot be recovered. diff --git a/backup/moodle2/backup_clickmeeting_activity_task.class.php b/backup/moodle2/backup_clickmeeting_activity_task.class.php index 34d1139..1225ca9 100755 --- a/backup/moodle2/backup_clickmeeting_activity_task.class.php +++ b/backup/moodle2/backup_clickmeeting_activity_task.class.php @@ -28,7 +28,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class backup_clickmeeting_activity_task extends backup_activity_task { - /** * Define (add) particular settings this activity can have */ diff --git a/backup/moodle2/backup_clickmeeting_stepslib.php b/backup/moodle2/backup_clickmeeting_stepslib.php index e3f2263..846f0ff 100755 --- a/backup/moodle2/backup_clickmeeting_stepslib.php +++ b/backup/moodle2/backup_clickmeeting_stepslib.php @@ -31,7 +31,6 @@ * Define the complete choice structure */ class backup_activity_structure_step extends \backup_activity_structure_step { - /** * Define the complete structure for backup */ @@ -45,6 +44,7 @@ protected function define_structure() { 'course', 'name', 'description', + 'room_type', 'lobby_msg', 'start_time', 'access_type', diff --git a/backup/moodle2/restore_clickmeeting_activity_task.class.php b/backup/moodle2/restore_clickmeeting_activity_task.class.php index 5aeddbe..05f75c0 100755 --- a/backup/moodle2/restore_clickmeeting_activity_task.class.php +++ b/backup/moodle2/restore_clickmeeting_activity_task.class.php @@ -29,7 +29,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class restore_clickmeeting_activity_task extends restore_activity_task { - /** * Define (add) particular settings this activity can have */ @@ -68,7 +67,6 @@ public static function define_decode_rules() { $rules[] = new restore_decode_rule('CLICKMEETINGINDEX', '/mod/clickmeeting/index.php?id=$1', 'course'); return $rules; - } /** @@ -104,11 +102,17 @@ public static function define_restore_log_rules_for_course() { $rules = []; // Fix old wrong uses (missing extension) - $rules[] = new restore_log_rule('clickmeeting', 'view all', 'index?id={course}', null, - null, null, 'index.php?id={course}'); + $rules[] = new restore_log_rule( + 'clickmeeting', + 'view all', + 'index?id={course}', + null, + null, + null, + 'index.php?id={course}' + ); $rules[] = new restore_log_rule('clickmeeting', 'view all', 'index.php?id={course}', null); return $rules; } - } diff --git a/backup/moodle2/restore_clickmeeting_stepslib.php b/backup/moodle2/restore_clickmeeting_stepslib.php index ccbb50e..203fc60 100755 --- a/backup/moodle2/restore_clickmeeting_stepslib.php +++ b/backup/moodle2/restore_clickmeeting_stepslib.php @@ -28,7 +28,6 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class restore_activity_structure_step extends \restore_activity_structure_step { - /** * Defines table structure */ @@ -60,19 +59,66 @@ protected function process_clickmeeting($data) { } /** - * Inserts conference data into new table + * Creates a brand new ClickMeeting room for the restored activity. + * + * The backed up room belongs to the original activity and must not be shared: a copy would + * let two activities (and two courses) drive the same conference, and deleting one would + * take the other down with it. Restoring therefore books a fresh room through the API, + * owned by whoever is running the restore. * * @param object $data */ protected function process_clickmeeting_conferences($data) { - global $DB, $USER; + global $CFG, $DB, $USER; + global $clickmeetingowner; + require_once($CFG->dirroot . '/mod/clickmeeting/lib.php'); $data = (object)$data; - $oldid = $data->id; $data->user_id = $USER->id; $data->clickmeeting_id = $this->get_new_parentid('clickmeeting'); - $newitemid = $DB->insert_record('clickmeeting_conferences', $data); + $clickmeeting = $DB->get_record('clickmeeting', ['id' => $data->clickmeeting_id], '*', MUST_EXIST); + + // The room is created with the restoring user's API key, so it has to be billed to them too. + $clickmeetingowner = $USER->id; + + $password = clickmeeting_generate_password(8); + + $params = [ + 'name' => $clickmeeting->name, + // Backups taken before room_type was exported carry no type; webinar is the plugin default. + 'room_type' => !empty($clickmeeting->room_type) ? $clickmeeting->room_type : 'webinar', + 'permanent_room' => '0', + 'access_type' => $clickmeeting->access_type, + 'lobby_description' => $clickmeeting->lobby_msg, + 'starts_at' => $clickmeeting->start_time, + 'duration' => $clickmeeting->duration, + 'timezone' => date_default_timezone_get(), + 'password' => $password, + ]; + + $r = json_decode(clickmeeting_add_conference($params), true); + + if (!empty($r['code'])) { + $error = ''; + foreach ($r['errors'] as $err) { + $error .= $err['message'] . '
'; + } + throw new \moodle_exception($error, 'error'); + } + + if (!isset($r['room'])) { + throw new \moodle_exception('cannotcreateroom', 'clickmeeting'); + } + + $room = $r['room']; + $data->conference_id = $room['id']; + $data->room_url = $room['room_url']; + $data->embed_room = $room['embed_room_url']; + $data->room_pin = $room['room_pin']; + $data->password = $password; + + $DB->insert_record('clickmeeting_conferences', $data); } /** diff --git a/classes/event/room_deleted.php b/classes/event/room_deleted.php new file mode 100644 index 0000000..d7a9ae5 --- /dev/null +++ b/classes/event/room_deleted.php @@ -0,0 +1,56 @@ +. + +namespace mod_clickmeeting\event; + +/** + * Fired when a room is permanently removed from ClickMeeting. + * + * Deletion happens long after the Moodle activity disappears, so this event is what + * ties a missing meeting back to the moment and the reason it was destroyed. + * + * @package mod_clickmeeting + * @copyright 2026 Clickmeeting + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class room_deleted extends \core\event\base { + /** + * Sets the event metadata. + */ + protected function init() { + $this->data['crud'] = 'd'; + $this->data['edulevel'] = self::LEVEL_OTHER; + } + + /** + * Returns the localised event name. + * + * @return string + */ + public static function get_name() { + return get_string('event:roomdeleted', 'clickmeeting'); + } + + /** + * Returns a description of what happened. + * + * @return string + */ + public function get_description() { + return "The ClickMeeting room with id '{$this->other['conferenceid']}' was deleted " . + "because its Moodle activity had been removed and the grace period expired."; + } +} diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 51fa13a..2974c7c 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -39,8 +39,7 @@ /** * Ad hoc task that performs the actions for approved data privacy requests. */ -class provider implements metadata_provider, request_plugin_provider, core_userlist_provider { - +class provider implements core_userlist_provider, metadata_provider, request_plugin_provider { /** * Returns metadata about this system. * @@ -52,6 +51,10 @@ public static function get_metadata(collection $collection): collection { 'user_id' => 'privacy:metadata:clickmeetingtokens:userid', ], 'privacy:metadata:clickmeetingtokens'); + $collection->add_database_table('clickmeeting_room_deletions', [ + 'user_id' => 'privacy:metadata:clickmeetingroomdeletions:userid', + ], 'privacy:metadata:clickmeetingroomdeletions'); + $collection->add_external_location_link('clickmeeting.com', [ 'email' => 'privacy:metadata:clickmeeting_api:email', 'nickname' => 'privacy:metadata:clickmeeting_api:nickname', @@ -67,6 +70,8 @@ public static function get_metadata(collection $collection): collection { * @return contextlist $contextlist The list of contexts used in this plugin. */ public static function get_contexts_for_userid(int $userid): contextlist { + global $DB; + $contextlist = new contextlist(); $sql = 'SELECT c.id @@ -86,6 +91,11 @@ public static function get_contexts_for_userid(int $userid): contextlist { $contextlist->add_from_sql($sql, $params); + // A pending room deletion outlives its activity, so it belongs to no module context. + if ($DB->record_exists('clickmeeting_room_deletions', ['user_id' => $userid])) { + $contextlist->add_system_context(); + } + return $contextlist; } @@ -155,6 +165,12 @@ public static function export_user_data(approved_contextlist $contextlist): void public static function delete_data_for_all_users_in_context(\context $context): void { global $DB; + if ($context instanceof \context_system) { + $DB->set_field_select('clickmeeting_room_deletions', 'user_id', null, 'user_id IS NOT NULL', []); + + return; + } + if (!($context instanceof context_module)) { return; } @@ -179,6 +195,12 @@ public static function delete_data_for_user(approved_contextlist $contextlist): $user = $contextlist->get_user(); foreach ($contextlist->get_contexts() as $context) { + if ($context instanceof \context_system) { + // Keep the row - the room still has to go - but forget whose it was. + $DB->set_field('clickmeeting_room_deletions', 'user_id', null, ['user_id' => $user->id]); + continue; + } + if (!($context instanceof context_module)) { continue; } @@ -200,6 +222,16 @@ public static function delete_data_for_user(approved_contextlist $contextlist): public static function get_users_in_context(userlist $userlist): void { $context = $userlist->get_context(); + if ($context instanceof \context_system) { + $userlist->add_from_sql( + 'user_id', + 'SELECT user_id FROM {clickmeeting_room_deletions} WHERE user_id IS NOT NULL', + [] + ); + + return; + } + if (!($context instanceof context_module)) { return; } @@ -228,6 +260,13 @@ public static function delete_data_for_users(approved_userlist $userlist): void global $DB; $context = $userlist->get_context(); + if ($context instanceof \context_system) { + [$insql, $inparams] = $DB->get_in_or_equal($userlist->get_userids(), SQL_PARAMS_NAMED); + $DB->set_field_select('clickmeeting_room_deletions', 'user_id', null, "user_id $insql", $inparams); + + return; + } + if (!($context instanceof context_module)) { return; } diff --git a/classes/task/purge_deleted_rooms.php b/classes/task/purge_deleted_rooms.php new file mode 100644 index 0000000..0040a11 --- /dev/null +++ b/classes/task/purge_deleted_rooms.php @@ -0,0 +1,85 @@ +. + +namespace mod_clickmeeting\task; + +use mod_clickmeeting\event\room_deleted; + +/** + * Removes rooms whose Moodle activity is gone and whose grace period has expired. + * + * @package mod_clickmeeting + * @copyright 2026 Clickmeeting + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class purge_deleted_rooms extends \core\task\scheduled_task { + /** + * Returns the localised task name. + * + * @return string + */ + public function get_name() { + return get_string('task:purgedeletedrooms', 'clickmeeting'); + } + + /** + * Deletes every room that is past its grace period and no longer referenced. + */ + public function execute() { + global $DB, $CFG, $clickmeetingowner; + + require_once($CFG->dirroot . '/mod/clickmeeting/lib.php'); + + $cutoff = time() - clickmeeting_get_grace_period(); + $pending = $DB->get_records_select( + 'clickmeeting_room_deletions', + 'timescheduled <= :cutoff', + ['cutoff' => $cutoff] + ); + + foreach ($pending as $record) { + // Another activity - a course copy, an import, an activity restored from the recycle + // bin - points at this room again, so deleting it would take the meeting away from them. + if ($DB->record_exists('clickmeeting_conferences', ['conference_id' => $record->conference_id])) { + mtrace("Room {$record->conference_id} is in use again, cancelling its deletion."); + $DB->delete_records('clickmeeting_room_deletions', ['id' => $record->id]); + continue; + } + + // The room belongs to whoever created it, so it has to be deleted with their API key. + $clickmeetingowner = $record->user_id; + $apiresult = clickmeeting_delete_conference($record->conference_id); + + if ('"200 OK"' !== $apiresult && '"404 Not Found"' !== $apiresult) { + // Leave the record alone so the next run retries it. + mtrace("Could not delete room {$record->conference_id}, will retry: {$apiresult}"); + continue; + } + + $DB->delete_records('clickmeeting_room_deletions', ['id' => $record->id]); + + if ('"200 OK"' === $apiresult) { + room_deleted::create([ + 'context' => \context_system::instance(), + 'other' => ['conferenceid' => $record->conference_id], + ])->trigger(); + mtrace("Deleted room {$record->conference_id}."); + } else { + mtrace("Room {$record->conference_id} was already gone from ClickMeeting."); + } + } + } +} diff --git a/db/install.xml b/db/install.xml index 32d07e5..34ff9f2 100755 --- a/db/install.xml +++ b/db/install.xml @@ -56,5 +56,20 @@ + + + + + + + + + + + + + + +
diff --git a/db/tasks.php b/db/tasks.php new file mode 100644 index 0000000..882e33e --- /dev/null +++ b/db/tasks.php @@ -0,0 +1,37 @@ +. + +/** + * Scheduled task definitions for mod_clickmeeting. + * + * @package mod_clickmeeting + * @copyright 2026 Clickmeeting + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$tasks = [ + [ + 'classname' => 'mod_clickmeeting\task\purge_deleted_rooms', + 'blocking' => 0, + 'minute' => '20', + 'hour' => '3', + 'day' => '*', + 'dayofweek' => '*', + 'month' => '*', + ], +]; diff --git a/db/upgrade.php b/db/upgrade.php index 8eb76de..0783375 100755 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -68,7 +68,6 @@ function xmldb_clickmeeting_upgrade($oldversion) { // First example, some fields were added to install.xml on 2007/04/01 if ($oldversion < 2007040100) { - // Define field course to be added to clickmeeting $table = new xmldb_table('clickmeeting'); $field = new xmldb_field('course', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'id'); @@ -89,8 +88,16 @@ function xmldb_clickmeeting_upgrade($oldversion) { // Define field introformat to be added to clickmeeting $table = new xmldb_table('clickmeeting'); - $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', - 'intro'); + $field = new xmldb_field( + 'introformat', + XMLDB_TYPE_INTEGER, + '4', + XMLDB_UNSIGNED, + XMLDB_NOTNULL, + null, + '0', + 'intro' + ); // Add field introformat if (!$dbman->field_exists($table, $field)) { @@ -106,11 +113,18 @@ function xmldb_clickmeeting_upgrade($oldversion) { // two more fields and one index were added to install.xml (note the micro increment // "01" in the last two digits of the version if ($oldversion < 2007040101) { - // Define field timecreated to be added to clickmeeting $table = new xmldb_table('clickmeeting'); - $field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', - 'introformat'); + $field = new xmldb_field( + 'timecreated', + XMLDB_TYPE_INTEGER, + '10', + XMLDB_UNSIGNED, + XMLDB_NOTNULL, + null, + '0', + 'introformat' + ); // Add field timecreated if (!$dbman->field_exists($table, $field)) { @@ -119,8 +133,16 @@ function xmldb_clickmeeting_upgrade($oldversion) { // Define field timemodified to be added to clickmeeting $table = new xmldb_table('clickmeeting'); - $field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', - 'timecreated'); + $field = new xmldb_field( + 'timemodified', + XMLDB_TYPE_INTEGER, + '10', + XMLDB_UNSIGNED, + XMLDB_NOTNULL, + null, + '0', + 'timecreated' + ); // Add field timemodified if (!$dbman->field_exists($table, $field)) { @@ -143,14 +165,12 @@ function xmldb_clickmeeting_upgrade($oldversion) { // Third example, the next day, 2007/04/02 (with the trailing 00), some actions were performed to install.php, // related with the module if ($oldversion < 2007040200) { - // insert here code to perform some actions (same as in install.php) upgrade_mod_savepoint(true, 2007040200, 'clickmeeting'); } if ($oldversion < 2018101000) { - $table = new xmldb_table('clickmeeting'); $field = new xmldb_field('user_id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'description'); @@ -221,6 +241,23 @@ function xmldb_clickmeeting_upgrade($oldversion) { upgrade_mod_savepoint(true, 2018101000, 'clickmeeting'); } + if ($oldversion < 2026100800) { + $table = new xmldb_table('clickmeeting_room_deletions'); + $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, true, null); + $table->add_field('conference_id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null); + $table->add_field('user_id', XMLDB_TYPE_INTEGER, '10', null, null, null, null); + $table->add_field('timescheduled', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0'); + $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']); + $table->add_index('conference_id', XMLDB_INDEX_UNIQUE, ['conference_id']); + $table->add_index('timescheduled', XMLDB_INDEX_NOTUNIQUE, ['timescheduled']); + + if (!$dbman->table_exists($table)) { + $dbman->create_table($table); + } + + upgrade_mod_savepoint(true, 2026100800, 'clickmeeting'); + } + // And that's all. Please, examine and understand the 3 example blocks above. Also // it's interesting to look how other modules are using this script. Remember that // the basic idea is to have "blocks" of code (each one being executed only once, diff --git a/index.php b/index.php index 7a8a006..18d21ac 100755 --- a/index.php +++ b/index.php @@ -27,8 +27,8 @@ // Replace clickmeeting with the name of your module and remove this line -require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); -require_once(dirname(__FILE__).'/lib.php'); +require_once(dirname(dirname(dirname(__FILE__))) . '/config.php'); +require_once(dirname(__FILE__) . '/lib.php'); $id = required_param('id', PARAM_INT); // course @@ -76,7 +76,8 @@ } else { $link = html_writer::link( new moodle_url('/mod/clickmeeting/view.php', ['id' => $clickmeeting->coursemodule]), - format_string($clickmeeting->name, true)); + format_string($clickmeeting->name, true) + ); } if ($course->format == 'weeks' || $course->format == 'topics') { diff --git a/lang/en/clickmeeting.php b/lang/en/clickmeeting.php index e64e11b..f4ac59a 100755 --- a/lang/en/clickmeeting.php +++ b/lang/en/clickmeeting.php @@ -75,6 +75,7 @@ $string['startdate_booked'] = 'This start date is already booked'; $string['update_error'] = 'Error updating record'; +$string['cannotcreateroom'] = 'Could not create a ClickMeeting room for the restored activity'; $string['api_404_error'] = '404 Not Found'; $string['privacy:metadata:clickmeeting_api'] = 'In order to integrate with Clickmeeting API, user data needs to be exchanged with that service.'; @@ -84,3 +85,10 @@ $string['privacy:metadata:clickmeetingtokens:userid'] = 'Access token is stored in context of user'; $string['privacy:metadata:clickmeetingtokens'] = 'Plugin stores tokens assigned to particular user'; + +$string['settings:graceperiod'] = 'Keep deleted rooms for'; +$string['settings:graceperioddesc'] = 'How long a ClickMeeting room survives after its Moodle activity was deleted. During this time the meeting and its recordings stay reachable in ClickMeeting, and restoring the activity from the recycle bin reconnects it to the same room. Set to zero to use the default of five months.'; +$string['task:purgedeletedrooms'] = 'Delete ClickMeeting rooms past their grace period'; +$string['event:roomdeleted'] = 'ClickMeeting room deleted'; +$string['privacy:metadata:clickmeetingroomdeletions'] = 'Plugin remembers which rooms are awaiting deletion in ClickMeeting.'; +$string['privacy:metadata:clickmeetingroomdeletions:userid'] = 'The owner of the room is kept so that the deletion uses their API key.'; diff --git a/lang/pl/clickmeeting.php b/lang/pl/clickmeeting.php index ecdcb91..92a8e5d 100755 --- a/lang/pl/clickmeeting.php +++ b/lang/pl/clickmeeting.php @@ -75,6 +75,7 @@ $string['startdate_booked'] = 'Nie można utworzyć konferencji dla tej daty'; $string['update_error'] = 'Błąd przy aktualizacji wpisu'; +$string['cannotcreateroom'] = 'Nie udało się utworzyć pokoju ClickMeeting dla przywracanej aktywności'; $string['api_404_error'] = '404 Not Found'; $string['privacy:metadata:clickmeeting_api'] = 'W celu zachowania poprawnej integracji z Clickmeeting API, następuje przekazanie danych uczestników do zewnętrznego systemu'; @@ -83,3 +84,10 @@ $string['privacy:metadata:clickmeetingtokens:userid'] = 'Token dostępowy do wydarzenia przechowywany w kontekście użytkownika'; $string['privacy:metadata:clickmeetingtokens'] = 'Moduł przechowuje listę wygenerowanych tokenów dla uczestników'; + +$string['settings:graceperiod'] = 'Przechowuj usunięte pokoje przez'; +$string['settings:graceperioddesc'] = 'Jak długo pokój ClickMeeting istnieje po usunięciu powiązanej aktywności w Moodle. Przez ten czas wydarzenie i jego nagrania pozostają dostępne w ClickMeeting, a przywrócenie aktywności z kosza podłącza ją z powrotem do tego samego pokoju. Wartość zero oznacza domyślne pięć miesięcy.'; +$string['task:purgedeletedrooms'] = 'Usuwanie pokoi ClickMeeting po okresie karencji'; +$string['event:roomdeleted'] = 'Usunięto pokój ClickMeeting'; +$string['privacy:metadata:clickmeetingroomdeletions'] = 'Moduł przechowuje informację o pokojach oczekujących na usunięcie w ClickMeeting.'; +$string['privacy:metadata:clickmeetingroomdeletions:userid'] = 'Właściciel pokoju jest zapamiętywany, aby usunięcie wykonać jego kluczem API.'; diff --git a/lib.php b/lib.php index 5c218d0..51d9d17 100755 --- a/lib.php +++ b/lib.php @@ -30,6 +30,14 @@ defined('MOODLE_INTERNAL') || die(); +/** + * How long a room outlives its Moodle activity when the admin has not chosen otherwise. + * + * Roughly five months, which keeps meetings and their recordings reachable in ClickMeeting + * well past the point where Moodle itself has forgotten the activity. + */ +define('CLICKMEETING_DEFAULT_GRACE_PERIOD', 150 * DAYSECS); + $clickmeetingauthtypes = [ '1' => 'open', '2' => 'password', @@ -88,24 +96,33 @@ function clickmeeting_check_conference_availability($starttime, $duration, $id = ]; $curl = clickmeeting_init_curl(); - $curl->post($apiurl.'conference/availability', $params); + $curl->post($apiurl . 'conference/availability', $params); return 200 === $curl->get_info()['http_code']; } /** + * Returns the API key to talk to ClickMeeting with. + * + * A room lives on the subaccount that created it, so calls about an existing room must use + * its owner's key. $clickmeetingowner carries that owner; it matters most under cron, where + * the acting user is nobody in particular and the global key would hit the wrong subaccount. * * @return string */ function clickmeeting_get_api_key() { - global $DB, $CFG, $USER; - require_once($CFG->dirroot.'/user/profile/lib.php'); + global $DB, $CFG, $USER, $clickmeetingowner; + require_once($CFG->dirroot . '/user/profile/lib.php'); - $user = $DB->get_record('user', ['id' => $USER->id]); - profile_load_data($user); + $ownerid = !empty($clickmeetingowner) ? $clickmeetingowner : $USER->id; + $user = $DB->get_record('user', ['id' => $ownerid]); - if (isset($user->profile_field_clickmeetingapikey) && !empty($user->profile_field_clickmeetingapikey)) { - return $user->profile_field_clickmeetingapikey; + if ($user) { + profile_load_data($user); + + if (!empty($user->profile_field_clickmeetingapikey)) { + return $user->profile_field_clickmeetingapikey; + } } return get_config('clickmeeting', 'apikey'); @@ -121,7 +138,7 @@ function clickmeeting_add_conference($params) { $apiurl = get_config('clickmeeting', 'apiurl'); $curlhandle = clickmeeting_init_curl(); - $result = $curlhandle->post($apiurl.'conferences', $params); + $result = $curlhandle->post($apiurl . 'conferences', $params); return $result; } @@ -137,7 +154,9 @@ function clickmeeting_edit_conference($conferenceid, $params) { $apiurl = get_config('clickmeeting', 'apiurl'); $curlhandle = clickmeeting_init_curl(); - $result = $curlhandle->put($apiurl.'conferences/'.$conferenceid, [], ['CURLOPT_POSTFIELDS' => http_build_query($params, '', '&')]); + // The body goes in as the second argument: curl::put() overwrites the postfields option with + // whatever it finds there, so passing the body through the options would send an empty request. + $result = $curlhandle->put($apiurl . 'conferences/' . $conferenceid, http_build_query($params, '', '&')); return $result; } @@ -157,7 +176,7 @@ function clickmeeting_edit_conference_title($conferenceid, $title) { ]; $curlhandle = clickmeeting_init_curl(); - $result = $curlhandle->put($apiurl.'conferences/'.$conferenceid, [], ['CURLOPT_POSTFIELDS' => http_build_query($params, '', '&')]); + $result = $curlhandle->put($apiurl . 'conferences/' . $conferenceid, http_build_query($params, '', '&')); return $result; } @@ -172,7 +191,7 @@ function clickmeeting_delete_conference($conferenceid) { $apiurl = get_config('clickmeeting', 'apiurl'); $curlhandle = clickmeeting_init_curl(); - $result = $curlhandle->delete($apiurl.'conferences/'.$conferenceid); + $result = $curlhandle->delete($apiurl . 'conferences/' . $conferenceid); return $result; } @@ -191,7 +210,7 @@ function clickmeeting_generate_token($roomid) { $params['how_many'] = 1; $curlhandle = clickmeeting_init_curl(); - $result = $curlhandle->post($apiurl.'conferences/'.$roomid.'/tokens', $params); + $result = $curlhandle->post($apiurl . 'conferences/' . $roomid . '/tokens', $params); $decoder = json_decode($result, true); return $decoder['access_tokens'][0]['token']; @@ -242,7 +261,7 @@ function clickmeeting_get_login_url($roomid, $email, $nickname, $role, $auth, $a } $curlhandle = clickmeeting_init_curl(); - $result = $curlhandle->post($apiurl.'conferences/'.$roomid.'/room/autologin_hash', $params); + $result = $curlhandle->post($apiurl . 'conferences/' . $roomid . '/room/autologin_hash', $params); $decoded = json_decode($result, true); return !empty($decoded['autologin_hash']) @@ -326,7 +345,7 @@ function clickmeeting_add_instance(stdClass $clickmeeting, mod_clickmeeting_mod_ $error = ''; if (!empty($r['code'])) { foreach ($r['errors'] as $err) { - $error .= $err['message'].'
'; + $error .= $err['message'] . '
'; } throw new \moodle_exception($error, 'error'); } @@ -408,7 +427,7 @@ function clickmeeting_update_instance(stdClass $clickmeeting, mod_clickmeeting_m if (!empty($r['code'])) { $error = ''; foreach ($r['errors'] as $err) { - $error .= $err['message'].'
'; + $error .= $err['message'] . '
'; } throw new \moodle_exception($error, 'error'); } @@ -429,7 +448,7 @@ function clickmeeting_update_instance(stdClass $clickmeeting, mod_clickmeeting_m * @return boolean Success/Failure */ function clickmeeting_delete_instance($id) { - global $DB, $COURSE, $clickmeetingowner; + global $DB, $clickmeetingowner; if (! $clickmeeting = $DB->get_record('clickmeeting', ['id' => $id])) { return false; @@ -437,29 +456,54 @@ function clickmeeting_delete_instance($id) { $clickmeetingowner = $clickmeeting->user_id; - if (0 < $DB->count_records('clickmeeting_conferences', ['clickmeeting_id' => $clickmeeting->id])) { - $conferenceid = $DB->get_field('clickmeeting_conferences', 'conference_id', ['clickmeeting_id' => $clickmeeting->id]); - } else { - return false; - } - - $apiresult = clickmeeting_delete_conference($conferenceid); + $conferenceid = $DB->get_field('clickmeeting_conferences', 'conference_id', ['clickmeeting_id' => $clickmeeting->id]); - if ('"200 OK"' != $apiresult) { - // jezeli nie znajdujemy conferencji w clickmeetingu to nie trzeba jej tam usuwac - if ('"404 Not Found"' == $apiresult) { - throw new \moodle_exception('api_404_error', 'clickmeeting'); - } - } + $DB->delete_records('clickmeeting_conferences', ['clickmeeting_id' => $clickmeeting->id]); + // Tokens identify participants, so they must not outlive the activity they were issued for. + $DB->delete_records('clickmeeting_tokens', ['clickmeeting_id' => $clickmeeting->id]); + $DB->delete_records('clickmeeting', ['id' => $clickmeeting->id]); - if (0 < $DB->count_records('clickmeeting_conferences', ['clickmeeting_id' => $clickmeeting->id])) { - $DB->delete_records('clickmeeting_conferences', ['clickmeeting_id' => $clickmeeting->id]); + // The room itself outlives the activity for the configured grace period. Moodle deletions are + // reversible from the recycle bin, and a course copy may still point at this very room, so + // destroying it here would take meetings and recordings away from users who never asked for it. + if (!empty($conferenceid)) { + clickmeeting_schedule_room_deletion($conferenceid, $clickmeeting->user_id); } - $DB->delete_records('clickmeeting', ['id' => $clickmeeting->id]); return true; } +/** + * Marks a room for deletion once the grace period has passed. + * + * Re-scheduling an already pending room restarts its grace period, so the room always + * survives for the full period after the last activity pointing at it went away. + * + * @param int $conferenceid Room id in ClickMeeting. + * @param int|null $ownerid User whose API key created the room. + */ +function clickmeeting_schedule_room_deletion($conferenceid, $ownerid) { + global $DB; + + $DB->delete_records('clickmeeting_room_deletions', ['conference_id' => $conferenceid]); + $DB->insert_record('clickmeeting_room_deletions', (object) [ + 'conference_id' => $conferenceid, + 'user_id' => $ownerid, + 'timescheduled' => time(), + ]); +} + +/** + * Returns how long a room is kept after its activity was deleted. + * + * @return int Grace period in seconds. + */ +function clickmeeting_get_grace_period() { + $graceperiod = (int) get_config('clickmeeting', 'graceperiod'); + + return $graceperiod > 0 ? $graceperiod : CLICKMEETING_DEFAULT_GRACE_PERIOD; +} + /** * Returns a small object with summary information about what a * user has done with a given particular instance of this module @@ -598,7 +642,7 @@ function clickmeeting_scale_used_anywhere($scaleid) { */ function clickmeeting_grade_item_update(stdClass $clickmeeting) { global $CFG, $DB; - require_once($CFG->libdir.'/gradelib.php'); + require_once($CFG->libdir . '/gradelib.php'); $item = []; $item['itemname'] = clean_param($clickmeeting->name, PARAM_NOTAGS); @@ -641,7 +685,7 @@ function clickmeeting_generate_password($length) { */ function clickmeeting_update_grades(stdClass $clickmeeting, $userid = 0) { global $CFG, $DB; - require_once($CFG->libdir.'/gradelib.php'); + require_once($CFG->libdir . '/gradelib.php'); $grades = []; // populate array of grade objects indexed by userid @@ -729,7 +773,7 @@ function clickmeeting_extend_navigation(navigation_node $navref, stdClass $cours * @param settings_navigation $settingsnav * @param navigation_node $clickmeetingnode */ -function clickmeeting_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $clickmeetingnode=null) { +function clickmeeting_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $clickmeetingnode = null) { } /** @@ -766,10 +810,10 @@ function clickmeeting_init_curl() { */ function clickmeeting_page_view($clickmeeting, $course, $cm, $context) { - $params = array( + $params = [ 'context' => $context, 'objectid' => $clickmeeting->id, - ); + ]; $event = mod_clickmeeting\event\course_module_viewed::create($params); $event->add_record_snapshot('course_modules', $cm); diff --git a/mod_form.php b/mod_form.php index 3cebbf4..d470404 100755 --- a/mod_form.php +++ b/mod_form.php @@ -27,13 +27,12 @@ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot.'/course/moodleform_mod.php'); +require_once($CFG->dirroot . '/course/moodleform_mod.php'); /** * Module instance settings form */ class mod_clickmeeting_mod_form extends moodleform_mod { - /** * Defines webinar open to all */ @@ -71,7 +70,7 @@ public function definition() { $conferencestarttime = required_param('start_time', PARAM_TEXT); $conferenceduration = required_param('duration', PARAM_INT); - if (clickmeeting_check_conference_availability($conferencestarttime, $conferenceduration, $conferenceid)) { + if (clickmeeting_check_conference_availability($conferencestarttime, $conferenceduration, $conferenceid)) { http_response_code(200); echo 'SUCCESS'; } else { diff --git a/settings.php b/settings.php index facfe33..0404612 100755 --- a/settings.php +++ b/settings.php @@ -25,16 +25,27 @@ defined('MOODLE_INTERNAL') || die; if ($ADMIN->fulltree) { - require_once(dirname(__FILE__).'/lib.php'); + require_once(dirname(__FILE__) . '/lib.php'); - $settings->add(new admin_setting_configtext('clickmeeting/apiurl', - get_string('settings:apiurl', 'clickmeeting'), - get_string('settings:apiurldesc', 'clickmeeting'), - 'https://api.clickmeeting.com/v1/', - PARAM_URL)); + $settings->add(new admin_setting_configtext( + 'clickmeeting/apiurl', + get_string('settings:apiurl', 'clickmeeting'), + get_string('settings:apiurldesc', 'clickmeeting'), + 'https://api.clickmeeting.com/v1/', + PARAM_URL + )); - $settings->add(new admin_setting_configtext('clickmeeting/apikey', - get_string('settings:apikey', 'clickmeeting'), - get_string('settings:apikeydesc', 'clickmeeting'), - '')); + $settings->add(new admin_setting_configtext( + 'clickmeeting/apikey', + get_string('settings:apikey', 'clickmeeting'), + get_string('settings:apikeydesc', 'clickmeeting'), + '' + )); + + $settings->add(new admin_setting_configduration( + 'clickmeeting/graceperiod', + get_string('settings:graceperiod', 'clickmeeting'), + get_string('settings:graceperioddesc', 'clickmeeting'), + CLICKMEETING_DEFAULT_GRACE_PERIOD + )); } diff --git a/tests/api_test.php b/tests/api_test.php new file mode 100644 index 0000000..0bc96a7 --- /dev/null +++ b/tests/api_test.php @@ -0,0 +1,250 @@ +. + +namespace mod_clickmeeting; + +/** + * Tests for the requests the plugin puts on the wire. + * + * Mocked responses say nothing about what was actually sent, and the bug these tests cover lives + * entirely in the request: an edit that reached the API carrying no fields at all. So these tests + * run a throwaway HTTP server, point the plugin at it and read back the requests it received. + * + * @package mod_clickmeeting + * @copyright 2026 Clickmeeting + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +final class api_test extends \advanced_testcase { + /** @var resource|null Handle of the stub API server, closed after each test. */ + private $server = null; + + /** @var string Directory the stub server records received requests into. */ + private string $serverdir = ''; + + /** + * Loads the plugin library under test. + */ + public static function setUpBeforeClass(): void { + global $CFG; + require_once($CFG->dirroot . '/mod/clickmeeting/lib.php'); + require_once($CFG->dirroot . '/course/lib.php'); + parent::setUpBeforeClass(); + } + + /** + * Sets up a user, since every API call looks up its caller's API key. + */ + protected function setUp(): void { + parent::setUp(); + $this->resetAfterTest(); + $this->setAdminUser(); + } + + /** + * Stops the stub server so no process outlives the test. + */ + protected function tearDown(): void { + if (is_resource($this->server)) { + proc_terminate($this->server); + proc_close($this->server); + $this->server = null; + } + parent::tearDown(); + } + + /** + * Starts a stub ClickMeeting API on a free port and points the plugin at it. + * + * @param array $routes Responses keyed by "METHOD uri-fragment", matched in order. + * @param string $default Response for any request none of the routes matches. + */ + private function start_stub_api(array $routes, string $default = '{}'): void { + $this->serverdir = make_request_directory(); + file_put_contents($this->serverdir . '/routes.json', json_encode([ + 'routes' => $routes, + 'default' => $default, + ])); + file_put_contents($this->serverdir . '/router.php', <<<'PHP' + $_SERVER['REQUEST_METHOD'], + 'uri' => $_SERVER['REQUEST_URI'], + 'body' => file_get_contents('php://input'), + ]; + file_put_contents(__DIR__ . '/requests.jsonl', json_encode($request) . "\n", FILE_APPEND); + + $routes = json_decode(file_get_contents(__DIR__ . '/routes.json'), true); + $body = $routes['default']; + foreach ($routes['routes'] as $route => $response) { + [$method, $fragment] = explode(' ', $route, 2); + if ($method === $request['method'] && str_contains($request['uri'], $fragment)) { + $body = $response; + break; + } + } + + header('Content-Type: application/json'); + echo $body; + PHP); + + $socket = stream_socket_server('tcp://127.0.0.1:0'); + $address = stream_socket_get_name($socket, false); + $port = (int)substr($address, strrpos($address, ':') + 1); + fclose($socket); + + $devnull = ['file', '/dev/null', 'w']; + $this->server = proc_open( + [PHP_BINARY, '-S', '127.0.0.1:' . $port, '-t', $this->serverdir, $this->serverdir . '/router.php'], + [1 => $devnull, 2 => $devnull], + $pipes + ); + + for ($attempt = 0; $attempt < 100; $attempt++) { + $probe = @fsockopen('127.0.0.1', $port, $errno, $errstr, 0.1); + if ($probe !== false) { + fclose($probe); + set_config('apiurl', 'http://127.0.0.1:' . $port . '/', 'clickmeeting'); + return; + } + usleep(50000); + } + + $this->fail('The stub ClickMeeting API did not come up on port ' . $port . '.'); + } + + /** + * Returns the requests the stub API received, oldest first. + * + * @return array List of requests, each with method, uri and raw body. + */ + private function get_received_requests(): array { + $recorded = $this->serverdir . '/requests.jsonl'; + $this->assertFileExists($recorded, 'The plugin never reached the API.'); + + $requests = []; + foreach (file($recorded, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) { + $requests[] = json_decode($line, true); + } + + return $requests; + } + + /** + * Returns the first recorded request made with the given method. + * + * @param string $method HTTP method to look for. + * @return array The request, with method, uri and raw body. + */ + private function get_received_request(string $method): array { + foreach ($this->get_received_requests() as $request) { + if ($method === $request['method']) { + return $request; + } + } + + $this->fail('No ' . $method . ' request reached the API.'); + } + + /** + * Editing a room has to carry the new values; a PUT with an empty body leaves the room + * exactly as it was, which is how renaming or rescheduling an activity silently did nothing. + */ + public function test_editing_a_room_sends_the_changed_fields(): void { + $this->start_stub_api([], '{"room":{"id":777911}}'); + + clickmeeting_edit_conference(777911, [ + 'name' => 'Renamed meeting', + 'starts_at' => '2026-11-20 10:00:00', + 'duration' => 3, + ]); + + $request = $this->get_received_request('PUT'); + $this->assertStringContainsString('conferences/777911', $request['uri']); + parse_str($request['body'], $sent); + $this->assertSame('Renamed meeting', $sent['name']); + $this->assertSame('2026-11-20 10:00:00', $sent['starts_at']); + $this->assertSame('3', $sent['duration']); + } + + /** + * Renaming an activity inline on the course page goes through its own, narrower call, which + * has to put the new title on the wire just the same. + */ + public function test_editing_a_room_title_sends_the_new_title(): void { + $this->start_stub_api([], '{"room":{"id":777911}}'); + + clickmeeting_edit_conference_title(777911, 'Renamed inline'); + + $request = $this->get_received_request('PUT'); + parse_str($request['body'], $sent); + $this->assertSame('Renamed inline', $sent['name']); + } + + /** + * The whole path a teacher takes when they edit an activity: the new name and start date have + * to reach the room, not just the Moodle database. + */ + public function test_updating_an_activity_sends_the_new_name_and_date_to_the_api(): void { + global $COURSE, $DB; + + $course = $this->getDataGenerator()->create_course(); + $COURSE = $course; + // The edit form posts the section back and the update refuses to run without it. + $_POST['section'] = 0; + + $clickmeeting = (object)[ + 'course' => $course->id, + 'name' => 'Original name', + 'description' => '', + 'room_type' => 'meeting', + 'lobby_msg' => 'Please wait', + 'access_type' => '1', + 'timestart' => time() + DAYSECS, + 'start_time' => date('Y-m-d H:i:s', time() + DAYSECS), + 'duration' => 2, + 'user_id' => get_admin()->id, + 'timecreated' => time(), + 'timemodified' => time(), + ]; + $clickmeeting->id = $DB->insert_record('clickmeeting', $clickmeeting); + $DB->insert_record('clickmeeting_conferences', (object)[ + 'clickmeeting_id' => $clickmeeting->id, + 'conference_id' => 777911, + 'room_url' => 'https://example.clickmeeting.com/room', + 'embed_room' => 'https://example.clickmeeting.com/room/embed', + 'room_pin' => 111111, + 'password' => 'roompassword', + ]); + + $this->start_stub_api([ + 'GET conferences/777911' => '{"conference":{"status":"active"}}', + 'PUT conferences/777911' => '{"room":{"id":777911}}', + ], '{}'); + + $newstart = time() + (5 * DAYSECS); + $update = clone $clickmeeting; + $update->instance = $clickmeeting->id; + $update->name = 'Renamed by the teacher'; + $update->timestart = $newstart; + + clickmeeting_update_instance($update); + + $request = $this->get_received_request('PUT'); + parse_str($request['body'], $sent); + $this->assertSame('Renamed by the teacher', $sent['name']); + $this->assertSame(date('Y-m-d H:i:s', $newstart), $sent['starts_at']); + } +} diff --git a/tests/lib_test.php b/tests/lib_test.php new file mode 100644 index 0000000..8c1a60a --- /dev/null +++ b/tests/lib_test.php @@ -0,0 +1,429 @@ +. + +namespace mod_clickmeeting; + +/** + * Tests for the clickmeeting activity library. + * + * @package mod_clickmeeting + * @copyright 2026 Clickmeeting + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +final class lib_test extends \advanced_testcase { + /** @var string Response the ClickMeeting API returns when a room was deleted. */ + private const API_OK = '"200 OK"'; + + /** + * Loads the plugin library under test. + */ + public static function setUpBeforeClass(): void { + global $CFG; + require_once($CFG->dirroot . '/mod/clickmeeting/lib.php'); + parent::setUpBeforeClass(); + } + + /** + * Points the plugin at a dead address, so a test that unexpectedly reaches for the + * network fails fast instead of talking to the real ClickMeeting API. + */ + protected function setUp(): void { + global $clickmeetingowner; + + parent::setUp(); + $this->resetAfterTest(); + set_config('apiurl', 'http://127.0.0.1:9/', 'clickmeeting'); + $clickmeetingowner = null; + } + + /** + * Creates an activity row together with its conference row. + * + * @param int $courseid Course the activity belongs to. + * @param int $conferenceid ClickMeeting room id the activity points at. + * @param int $ownerid User owning the room. + * @return int Id of the new clickmeeting record. + */ + private function create_activity(int $courseid, int $conferenceid, int $ownerid): int { + global $DB; + + $instanceid = $DB->insert_record('clickmeeting', (object) [ + 'course' => $courseid, + 'name' => 'Webinar', + 'user_id' => $ownerid, + 'introformat' => 0, + 'timecreated' => time(), + 'timemodified' => time(), + ]); + $DB->insert_record('clickmeeting_conferences', (object) [ + 'clickmeeting_id' => $instanceid, + 'conference_id' => $conferenceid, + ]); + + return $instanceid; + } + + /** + * Runs the purge task, capturing the progress output it writes. + * + * @return string Whatever the task reported. + */ + private function run_purge_task(): string { + ob_start(); + (new \mod_clickmeeting\task\purge_deleted_rooms())->execute(); + + return ob_get_clean(); + } + + /** + * Asserts that nothing so far spoke to the API, by showing that a queued mock response + * is still waiting to be handed out. Consuming it here also keeps the queue, which Moodle + * does not reset between tests, from leaking into the next one. + */ + private function assert_api_was_not_called(): void { + $leftover = (new \curl())->get('http://127.0.0.1:9/'); + + $this->assertEquals(self::API_OK, $leftover, 'The ClickMeeting API should not have been called.'); + } + + /** + * Deleting an activity must not destroy the room straight away, because Moodle + * deletions are reversible from the recycle bin. + */ + public function test_delete_instance_schedules_room_deletion_instead_of_calling_api(): void { + global $DB; + + $this->resetAfterTest(); + $course = $this->getDataGenerator()->create_course(); + $owner = $this->getDataGenerator()->create_user(); + $instanceid = $this->create_activity($course->id, 777001, $owner->id); + + $this->assertTrue(clickmeeting_delete_instance($instanceid)); + + $this->assertFalse($DB->record_exists('clickmeeting', ['id' => $instanceid])); + $pending = $DB->get_record('clickmeeting_room_deletions', ['conference_id' => 777001]); + $this->assertNotFalse($pending, 'Room deletion should have been scheduled.'); + $this->assertEquals($owner->id, $pending->user_id); + } + + /** + * Once the grace period has passed the room is really gone from ClickMeeting. + */ + public function test_purge_task_deletes_room_once_grace_period_expired(): void { + global $DB; + + $this->resetAfterTest(); + set_config('graceperiod', WEEKSECS, 'clickmeeting'); + $owner = $this->getDataGenerator()->create_user(); + $DB->insert_record('clickmeeting_room_deletions', (object) [ + 'conference_id' => 777002, + 'user_id' => $owner->id, + 'timescheduled' => time() - WEEKSECS - 1, + ]); + \curl::mock_response(self::API_OK); + + $sink = $this->redirectEvents(); + $this->run_purge_task(); + $events = $sink->get_events(); + $sink->close(); + + $this->assertFalse($DB->record_exists('clickmeeting_room_deletions', ['conference_id' => 777002])); + $this->assertCount(1, $events); + $this->assertInstanceOf(\mod_clickmeeting\event\room_deleted::class, $events[0]); + $this->assertEquals(777002, $events[0]->other['conferenceid']); + } + + /** + * Within the grace period the room must be left alone, so that restoring the activity + * from the recycle bin gives the meeting and its recordings back. + */ + public function test_purge_task_keeps_room_within_grace_period(): void { + global $DB; + + $this->resetAfterTest(); + set_config('graceperiod', WEEKSECS, 'clickmeeting'); + $owner = $this->getDataGenerator()->create_user(); + $DB->insert_record('clickmeeting_room_deletions', (object) [ + 'conference_id' => 777003, + 'user_id' => $owner->id, + 'timescheduled' => time() - DAYSECS, + ]); + \curl::mock_response(self::API_OK); + + $sink = $this->redirectEvents(); + $this->run_purge_task(); + $events = $sink->get_events(); + $sink->close(); + + $this->assertTrue($DB->record_exists('clickmeeting_room_deletions', ['conference_id' => 777003])); + $this->assertCount(0, $events); + $this->assert_api_was_not_called(); + } + + /** + * A room shared with another activity - a course copy, an import, a restore - must survive + * the deletion of any single activity pointing at it. + */ + public function test_purge_task_spares_room_still_used_by_another_activity(): void { + global $DB; + + $this->resetAfterTest(); + set_config('graceperiod', WEEKSECS, 'clickmeeting'); + $course = $this->getDataGenerator()->create_course(); + $owner = $this->getDataGenerator()->create_user(); + $this->create_activity($course->id, 777004, $owner->id); + $DB->insert_record('clickmeeting_room_deletions', (object) [ + 'conference_id' => 777004, + 'user_id' => $owner->id, + 'timescheduled' => time() - WEEKSECS - 1, + ]); + \curl::mock_response(self::API_OK); + + $sink = $this->redirectEvents(); + $this->run_purge_task(); + $events = $sink->get_events(); + $sink->close(); + + $this->assertCount(0, $events, 'A room another activity still points at must not be deleted.'); + $this->assert_api_was_not_called(); + $this->assertFalse($DB->record_exists('clickmeeting_room_deletions', ['conference_id' => 777004])); + } + + /** + * An activity whose room row is missing must still be removable, otherwise Moodle keeps + * throwing on every attempt and the activity can never be deleted. + */ + public function test_delete_instance_removes_activity_that_has_no_room(): void { + global $DB; + + $course = $this->getDataGenerator()->create_course(); + $owner = $this->getDataGenerator()->create_user(); + $instanceid = $DB->insert_record('clickmeeting', (object) [ + 'course' => $course->id, + 'name' => 'Webinar without a room', + 'user_id' => $owner->id, + 'introformat' => 0, + 'timecreated' => time(), + 'timemodified' => time(), + ]); + + $this->assertTrue(clickmeeting_delete_instance($instanceid)); + + $this->assertFalse($DB->record_exists('clickmeeting', ['id' => $instanceid])); + $this->assertEquals(0, $DB->count_records('clickmeeting_room_deletions')); + } + + /** + * A room already gone from ClickMeeting is simply forgotten, without pretending we deleted it. + */ + public function test_purge_task_forgets_room_that_no_longer_exists(): void { + global $DB; + + set_config('graceperiod', WEEKSECS, 'clickmeeting'); + $owner = $this->getDataGenerator()->create_user(); + $DB->insert_record('clickmeeting_room_deletions', (object) [ + 'conference_id' => 777005, + 'user_id' => $owner->id, + 'timescheduled' => time() - WEEKSECS - 1, + ]); + \curl::mock_response('"404 Not Found"'); + + $sink = $this->redirectEvents(); + $this->run_purge_task(); + $events = $sink->get_events(); + $sink->close(); + + $this->assertFalse($DB->record_exists('clickmeeting_room_deletions', ['conference_id' => 777005])); + $this->assertCount(0, $events, 'Nothing was deleted, so no deletion should be reported.'); + } + + /** + * A failing API call must not lose the room: the record stays so the next run retries it. + */ + public function test_purge_task_retries_room_after_a_failed_api_call(): void { + global $DB; + + set_config('graceperiod', WEEKSECS, 'clickmeeting'); + $owner = $this->getDataGenerator()->create_user(); + $DB->insert_record('clickmeeting_room_deletions', (object) [ + 'conference_id' => 777006, + 'user_id' => $owner->id, + 'timescheduled' => time() - WEEKSECS - 1, + ]); + \curl::mock_response('{"errors":[{"message":"Service unavailable"}]}'); + + $output = $this->run_purge_task(); + + $this->assertTrue($DB->record_exists('clickmeeting_room_deletions', ['conference_id' => 777006])); + $this->assertStringContainsString('will retry', $output); + } + + /** + * Rooms live on the subaccount that created them, so calls must use the owner's key even + * when somebody else - or cron, acting as nobody - triggers the deletion. + */ + public function test_api_key_belongs_to_the_room_owner_not_the_acting_user(): void { + global $clickmeetingowner; + + set_config('apikey', 'main-account-key', 'clickmeeting'); + $this->getDataGenerator()->create_custom_profile_field([ + 'datatype' => 'text', + 'shortname' => 'clickmeetingapikey', + 'name' => 'ClickMeeting API key', + ]); + $owner = $this->getDataGenerator()->create_user(['profile_field_clickmeetingapikey' => 'subaccount-key']); + $this->setUser($this->getDataGenerator()->create_user()); + + $clickmeetingowner = $owner->id; + + $this->assertEquals('subaccount-key', clickmeeting_get_api_key()); + } + + /** + * With no owner on record the global key is the only sensible choice, and a missing user + * must not bring the whole deletion down. + */ + public function test_api_key_falls_back_to_the_global_key_for_an_unknown_owner(): void { + global $clickmeetingowner; + + set_config('apikey', 'main-account-key', 'clickmeeting'); + $this->setUser($this->getDataGenerator()->create_user()); + + $clickmeetingowner = 999999; + + $this->assertEquals('main-account-key', clickmeeting_get_api_key()); + } + + /** + * Access tokens carry user data, so they must not survive the activity they belong to. + */ + public function test_delete_instance_removes_access_tokens(): void { + global $DB; + + $course = $this->getDataGenerator()->create_course(); + $owner = $this->getDataGenerator()->create_user(); + $participant = $this->getDataGenerator()->create_user(); + $instanceid = $this->create_activity($course->id, 777007, $owner->id); + $DB->insert_record('clickmeeting_tokens', (object) [ + 'clickmeeting_id' => $instanceid, + 'conference_id' => 777007, + 'user_id' => $participant->id, + 'token' => 'abc123', + ]); + + clickmeeting_delete_instance($instanceid); + + $this->assertEquals(0, $DB->count_records('clickmeeting_tokens', ['clickmeeting_id' => $instanceid])); + } + + /** + * Two activities sharing a room both schedule it, which must not collide on the unique + * conference id, and must leave a single pending record behind. + */ + public function test_scheduling_the_same_room_twice_leaves_one_record(): void { + global $DB; + + $owner = $this->getDataGenerator()->create_user(); + + clickmeeting_schedule_room_deletion(777008, $owner->id); + clickmeeting_schedule_room_deletion(777008, $owner->id); + + $this->assertEquals(1, $DB->count_records('clickmeeting_room_deletions', ['conference_id' => 777008])); + } + + /** + * The pending deletions table stores who owned a room, which is personal data and has to + * be declared - Moodle's own privacy checks do not catch a "user_id" column on their own. + */ + public function test_room_deletions_table_is_declared_to_the_privacy_api(): void { + $collection = \mod_clickmeeting\privacy\provider::get_metadata( + new \core_privacy\local\metadata\collection('mod_clickmeeting') + ); + + $tables = []; + foreach ($collection->get_collection() as $type) { + if ($type instanceof \core_privacy\local\metadata\types\database_table) { + $tables[] = $type->get_name(); + } + } + + $this->assertContains('clickmeeting_room_deletions', $tables); + } + + /** + * Moodle rejects table names longer than 28 characters on 4.1 and earlier, which this + * plugin still supports. The limit was raised later, so a name that installs fine on 4.5 + * can still break every older site. + */ + public function test_table_names_fit_the_moodle_name_limit(): void { + global $CFG; + + $xml = simplexml_load_file($CFG->dirroot . '/mod/clickmeeting/db/install.xml'); + + $this->assertNotFalse($xml, 'install.xml should be readable.'); + foreach ($xml->TABLES->TABLE as $table) { + $name = (string) $table['NAME']; + $this->assertLessThanOrEqual(28, strlen($name), "Table name {$name} is too long for Moodle 4.1."); + } + } + + /** + * An erasure request must not leave the owner's id behind. The row itself has to stay, or + * the room would never be deleted from ClickMeeting - it falls back to the global API key. + */ + public function test_erasure_request_clears_the_room_owner(): void { + global $DB; + + $owner = $this->getDataGenerator()->create_user(); + $DB->insert_record('clickmeeting_room_deletions', (object) [ + 'conference_id' => 777009, + 'user_id' => $owner->id, + 'timescheduled' => time(), + ]); + + \mod_clickmeeting\privacy\provider::delete_data_for_user( + new \core_privacy\local\request\approved_contextlist( + $owner, + 'mod_clickmeeting', + [\context_system::instance()->id] + ) + ); + + $record = $DB->get_record('clickmeeting_room_deletions', ['conference_id' => 777009]); + $this->assertNotFalse($record, 'The room must still be scheduled for deletion.'); + $this->assertNull($record->user_id); + } + + /** + * A user known only through a pending room deletion still has to be discoverable, otherwise + * their erasure request never reaches that row. + */ + public function test_room_owner_is_found_by_the_privacy_api(): void { + global $DB; + + $owner = $this->getDataGenerator()->create_user(); + $DB->insert_record('clickmeeting_room_deletions', (object) [ + 'conference_id' => 777010, + 'user_id' => $owner->id, + 'timescheduled' => time(), + ]); + + $contextlist = \mod_clickmeeting\privacy\provider::get_contexts_for_userid($owner->id); + + // Context ids come back from the database as strings, so compare loosely. + $this->assertContainsEquals(\context_system::instance()->id, $contextlist->get_contextids()); + } +} diff --git a/tests/restore_test.php b/tests/restore_test.php new file mode 100644 index 0000000..3f1a4a1 --- /dev/null +++ b/tests/restore_test.php @@ -0,0 +1,215 @@ +. + +namespace mod_clickmeeting; + +/** + * Tests for what happens to the ClickMeeting room when an activity is copied. + * + * Copying, importing and restoring a course all go through the restore machinery. A copy must + * get a room of its own: two activities sharing one room means two courses sharing one meeting, + * one set of recordings and one schedule. + * + * @package mod_clickmeeting + * @copyright 2026 Clickmeeting + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +final class restore_test extends \advanced_testcase { + /** @var string Room the API hands out when asked to create one. */ + private const API_NEW_ROOM = '{"room":{"id":777911,"room_url":"https://example.clickmeeting.com/new",' + . '"embed_room_url":"https://example.clickmeeting.com/new/embed","room_pin":222222}}'; + + /** @var int Room the original activity points at. */ + private const ORIGINAL_ROOM = 777900; + + /** + * Loads the plugin library and the course functions the tests drive. + */ + public static function setUpBeforeClass(): void { + global $CFG; + require_once($CFG->dirroot . '/mod/clickmeeting/lib.php'); + require_once($CFG->dirroot . '/course/lib.php'); + parent::setUpBeforeClass(); + } + + /** + * Points the plugin at a dead address, so a test that unexpectedly reaches for the + * network fails fast instead of talking to the real ClickMeeting API. + */ + protected function setUp(): void { + parent::setUp(); + $this->resetAfterTest(); + set_config('apiurl', 'http://127.0.0.1:9/', 'clickmeeting'); + } + + /** + * Creates an activity, its conference row and the course module holding them together. + * + * @param \stdClass $course Course the activity lives in. + * @param int $conferenceid ClickMeeting room the activity points at. + * @return \cm_info The new course module. + */ + private function create_activity(\stdClass $course, int $conferenceid): \cm_info { + global $DB, $USER; + + $timestart = time() + DAYSECS; + $instanceid = $DB->insert_record('clickmeeting', (object) [ + 'course' => $course->id, + 'name' => 'Webinar', + 'description' => 'A meeting', + 'user_id' => $USER->id, + 'lobby_msg' => 'Please wait', + 'start_time' => date('Y-m-d H:i:s', $timestart), + 'timestart' => $timestart, + 'duration' => 2, + 'room_type' => 'meeting', + 'access_type' => '1', + 'introformat' => 0, + 'timecreated' => time(), + 'timemodified' => time(), + ]); + $DB->insert_record('clickmeeting_conferences', (object) [ + 'clickmeeting_id' => $instanceid, + 'conference_id' => $conferenceid, + 'room_url' => 'https://example.clickmeeting.com/original', + 'embed_room' => 'https://example.clickmeeting.com/original/embed', + 'room_pin' => 111111, + 'password' => 'originalpassword', + ]); + + $module = $DB->get_record('modules', ['name' => 'clickmeeting'], '*', MUST_EXIST); + $cmid = add_course_module((object) [ + 'course' => $course->id, + 'module' => $module->id, + 'instance' => $instanceid, + 'section' => 0, + 'visible' => 1, + 'visibleold' => 1, + 'groupmode' => 0, + 'groupingid' => 0, + 'completion' => 0, + 'showdescription' => 0, + ]); + course_add_cm_to_section($course, $cmid, 0); + + return get_fast_modinfo($course)->get_cm($cmid); + } + + /** + * Returns the conference row belonging to an activity. + * + * @param int $instanceid Activity the room belongs to. + * @return \stdClass + */ + private function get_conference(int $instanceid): \stdClass { + global $DB; + + return $DB->get_record('clickmeeting_conferences', ['clickmeeting_id' => $instanceid], '*', MUST_EXIST); + } + + /** + * A duplicated activity must book its own room rather than reuse the original one. + */ + public function test_duplicating_an_activity_creates_a_new_room(): void { + $this->setAdminUser(); + $course = $this->getDataGenerator()->create_course(); + $cm = $this->create_activity($course, self::ORIGINAL_ROOM); + \curl::mock_response(self::API_NEW_ROOM); + + $copy = duplicate_module($course, $cm); + + $this->assertEquals(777911, $this->get_conference($copy->instance)->conference_id); + } + + /** + * The original activity keeps the room it had, so copying a course does not disturb it. + */ + public function test_duplicating_leaves_the_original_room_alone(): void { + $this->setAdminUser(); + $course = $this->getDataGenerator()->create_course(); + $cm = $this->create_activity($course, self::ORIGINAL_ROOM); + \curl::mock_response(self::API_NEW_ROOM); + + duplicate_module($course, $cm); + + $this->assertEquals(self::ORIGINAL_ROOM, $this->get_conference($cm->instance)->conference_id); + } + + /** + * Everything identifying the room has to come from the API answer. A copied room_url or + * password would send participants to the original meeting however new the room id looks. + */ + public function test_duplicating_does_not_copy_the_room_credentials(): void { + $this->setAdminUser(); + $course = $this->getDataGenerator()->create_course(); + $cm = $this->create_activity($course, self::ORIGINAL_ROOM); + \curl::mock_response(self::API_NEW_ROOM); + + $copy = duplicate_module($course, $cm); + + $conference = $this->get_conference($copy->instance); + $this->assertEquals('https://example.clickmeeting.com/new', $conference->room_url); + $this->assertEquals('https://example.clickmeeting.com/new/embed', $conference->embed_room); + $this->assertEquals(222222, $conference->room_pin); + $this->assertNotEquals('originalpassword', $conference->password); + } + + /** + * The room type decides what the booked room actually is, so the backup has to carry it. + */ + public function test_duplicating_keeps_the_room_type_of_the_original(): void { + global $DB; + + $this->setAdminUser(); + $course = $this->getDataGenerator()->create_course(); + $cm = $this->create_activity($course, self::ORIGINAL_ROOM); + \curl::mock_response(self::API_NEW_ROOM); + + $copy = duplicate_module($course, $cm); + + $this->assertEquals('meeting', $DB->get_record('clickmeeting', ['id' => $copy->instance])->room_type); + } + + /** + * If the room cannot be booked the copy would be an activity pointing at nothing, so the + * restore has to fail loudly instead of leaving that behind. + */ + public function test_duplicating_fails_when_the_api_cannot_create_a_room(): void { + global $DB; + + $this->setAdminUser(); + $course = $this->getDataGenerator()->create_course(); + $cm = $this->create_activity($course, self::ORIGINAL_ROOM); + \curl::mock_response('{"code":400,"errors":[{"message":"Room limit reached"}]}'); + + try { + duplicate_module($course, $cm); + $this->fail('Expected the restore to abort with a moodle_exception.'); + } catch (\moodle_exception $e) { + $this->assertStringContainsString('Room limit reached', $e->getMessage()); + } finally { + // An aborted restore never gets to drop its temporary table. A real request tears the + // database connection down with it, but here the table outlives the test and the reset + // afterwards trips over it, so drop it while it is still there. + foreach (['backup_ids_temp', 'backup_files_temp'] as $name) { + $temptable = new \xmldb_table($name); + if ($DB->get_manager()->table_exists($temptable)) { + $DB->get_manager()->drop_table($temptable); + } + } + } + } +} diff --git a/version.php b/version.php index feb568e..6e0e08b 100755 --- a/version.php +++ b/version.php @@ -27,8 +27,12 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2025021002; -$plugin->requires = 2013111811.01; // Requires this Moodle 2.6 version +$plugin->version = 2026101301; +$plugin->requires = 2013111811.01; // Requires this Moodle 2.6 version. +// Branches this release is actually tested against: 3.9 LTS through 5.3. This is advisory - +// it tells the plugins directory and the admin UI what we stand behind, without blocking +// installation anywhere $plugin->requires allows it. +$plugin->supported = [39, 503]; $plugin->maturity = MATURITY_STABLE; $plugin->cron = 0; $plugin->component = 'mod_clickmeeting'; diff --git a/view.php b/view.php index 8729561..472d98c 100755 --- a/view.php +++ b/view.php @@ -25,8 +25,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -require_once(dirname(dirname(dirname(__FILE__))).'/config.php'); -require_once(dirname(__FILE__).'/lib.php'); +require_once(dirname(dirname(dirname(__FILE__))) . '/config.php'); +require_once(dirname(__FILE__) . '/lib.php'); $id = optional_param('id', 0, PARAM_INT); // course_module ID, or $n = optional_param('n', 0, PARAM_INT); // clickmeeting instance ID - it should be named as the first character of the module @@ -100,22 +100,22 @@ // Output starts here echo $OUTPUT->header(); -echo ''.get_string('view:room_name', 'clickmeeting').': '.$clickmeeting->name; +echo '' . get_string('view:room_name', 'clickmeeting') . ': ' . $clickmeeting->name; echo '

'; if (!clickmeeting_is_room_historical($conference->conference_id)) { - $timestamp = strtotime('+'.$clickmeeting->duration.' hours', $clickmeeting->timestart); - echo ''.get_string('view:room_date', 'clickmeeting').': '.$clickmeeting->start_time.' - '.date('Y-m-d H:i:s', $timestamp); + $timestamp = strtotime('+' . $clickmeeting->duration . ' hours', $clickmeeting->timestart); + echo '' . get_string('view:room_date', 'clickmeeting') . ': ' . $clickmeeting->start_time . ' - ' . date('Y-m-d H:i:s', $timestamp); echo '

'; - echo ''.get_string('view:room_description', 'clickmeeting').': '.$clickmeeting->description; + echo '' . get_string('view:room_description', 'clickmeeting') . ': ' . $clickmeeting->description; echo '

'; if (clickmeeting_is_password_protected($clickmeeting)) { - echo ''.get_string('view:password', 'clickmeeting').': '.$conference->password; + echo '' . get_string('view:password', 'clickmeeting') . ': ' . $conference->password; echo '

'; } $loginurl = sprintf('%s?l=%s', $conference->room_url, $loginhash); echo '
'; - echo ''.get_string('view:joinmeeting', 'clickmeeting').''; + echo '' . get_string('view:joinmeeting', 'clickmeeting') . ''; echo '
'; } else { echo '' . get_string('view:oldmeeting', 'clickmeeting') . '';