Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  namespace mod_bigbluebuttonbn\output;
  18  
  19  use mod_bigbluebuttonbn\instance;
  20  use mod_bigbluebuttonbn\local\bigbluebutton\recordings\recording_data;
  21  use mod_bigbluebuttonbn\local\proxy\bigbluebutton_proxy;
  22  use mod_bigbluebuttonbn\recording;
  23  use renderable;
  24  use renderer_base;
  25  use stdClass;
  26  use templatable;
  27  
  28  /**
  29   * Renderer for recording_row_preview column
  30   *
  31   * @package   mod_bigbluebuttonbn
  32   * @copyright 2010 onwards, Blindside Networks Inc
  33   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   * @author    Laurent David  (laurent.david [at] call-learning [dt] fr)
  35   */
  36  class recording_row_preview implements renderable, templatable {
  37      /**
  38       * @var $recording
  39       */
  40      protected $recording;
  41  
  42      /**
  43       * recording_row_playback constructor.
  44       *
  45       * @param recording $rec
  46       */
  47      public function __construct(recording $rec) {
  48          $this->recording = $rec;
  49      }
  50  
  51      /**
  52       * Export for template
  53       *
  54       * @param renderer_base $output
  55       * @return stdClass
  56       */
  57      public function export_for_template(renderer_base $output): stdClass {
  58          global $CFG;
  59  
  60          $context = (object) [
  61              'id' => 'preview-' . $this->recording->get('id'),
  62              'hidden' => !$this->recording->get('published'),
  63              'recordingpreviews' => [],
  64          ];
  65  
  66          $playbacks = $this->recording->get('playbacks');
  67          foreach ($playbacks as $playback) {
  68              $thumbnails = [];
  69  
  70              if (isset($playback['preview'])) {
  71                  foreach ($playback['preview'] as $image) {
  72                      $url = trim($image['url']);
  73                      $validated = bigbluebutton_proxy::is_remote_resource_valid($url);
  74                      if ($validated) {
  75                          $thumbnails[] = $url . '?' . time();
  76                      }
  77                  }
  78  
  79                  if (!empty($thumbnails)) {
  80                      $context->recordingpreviews[] = (object) [
  81                          'thumbnails' => $thumbnails,
  82                      ];
  83                  }
  84              }
  85          }
  86  
  87          return $context;
  88      }
  89  }