Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 28... Línea 28...
28
 * @copyright 2010 onwards, Blindside Networks Inc
28
 * @copyright 2010 onwards, Blindside Networks Inc
29
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 * @author    Jesus Federico  (jesus [at] blindsidenetworks [dt] com)
30
 * @author    Jesus Federico  (jesus [at] blindsidenetworks [dt] com)
31
 */
31
 */
32
class broker {
32
class broker {
33
 
-
 
34
    /** @var array List of required params */
-
 
35
    protected $requiredparams = [
-
 
36
        'recording_ready' => [
-
 
37
            'bigbluebuttonbn' => 'The BigBlueButtonBN instance ID must be specified.',
-
 
38
            'signed_parameters' => 'A JWT encoded string must be included as [signed_parameters].'
-
 
39
        ],
-
 
40
        'meeting_events' => [
-
 
41
            'bigbluebuttonbn' => 'The BigBlueButtonBN instance ID must be specified.'
-
 
42
        ],
-
 
43
    ];
-
 
44
 
-
 
45
    /**
33
    /**
46
     * Validate the supplied list of parameters, providing feedback about any missing or incorrect values.
34
     * Validate the supplied list of parameters, providing feedback about any missing or incorrect values.
47
     *
35
     *
48
     * @param array $params
36
     * @param array $params
49
     * @return null|string
37
     * @return null|string
50
     */
38
     */
51
    public function validate_parameters(array $params): ?string {
39
    public static function validate_parameters(array $params): ?string {
-
 
40
        $requiredparams = [
-
 
41
            'recording_ready' => [
-
 
42
                'bigbluebuttonbn' => 'The BigBlueButtonBN instance ID must be specified.',
-
 
43
                'signed_parameters' => 'A JWT encoded string must be included as [signed_parameters].',
-
 
44
            ],
-
 
45
            'meeting_events' => [
-
 
46
                'bigbluebuttonbn' => 'The BigBlueButtonBN instance ID must be specified.',
-
 
47
            ],
-
 
48
        ];
52
        if (!isset($params['action']) || empty($params['action']) ) {
49
        if (!isset($params['action']) || empty($params['action'])) {
53
            return 'Parameter ['.$params['action'].'] was not included';
50
            return 'Parameter [' . $params['action'] . '] was not included';
54
        }
51
        }
Línea 55... Línea 52...
55
 
52
 
56
        $action = strtolower($params['action']);
53
        $action = strtolower($params['action']);
57
        if (!array_key_exists($action, $this->requiredparams)) {
54
        if (!array_key_exists($action, $requiredparams)) {
58
            return "Action {$params['action']} can not be performed.";
55
            return "Action {$params['action']} can not be performed.";
59
        }
56
        }
60
        return $this->validate_parameters_message($params, $this->requiredparams[$action]);
57
        return self::validate_parameters_message($params, $requiredparams[$action]);
Línea 61... Línea 58...
61
    }
58
    }
62
 
59
 
63
    /**
60
    /**
Línea 155... Línea 152...
155
            $jsonstr = file_get_contents('php://input');
152
            $jsonstr = file_get_contents('php://input');
Línea 156... Línea 153...
156
 
153
 
157
            // Convert JSON string to a JSON object.
154
            // Convert JSON string to a JSON object.
158
            $jsonobj = json_decode($jsonstr);
155
            $jsonobj = json_decode($jsonstr);
159
            $headermsg = meeting::meeting_events($instance, $jsonobj);
156
            $headermsg = meeting::meeting_events($instance, $jsonobj);
160
            header($headermsg);
157
            self::process_extension_actions($instance, $jsonstr);
161
        } catch (Exception $e) {
158
        } catch (Exception $e) {
-
 
159
            $msg = 'Caught exception: ' . $e->getMessage();
162
            $msg = 'Caught exception: ' . $e->getMessage();
160
            debugging($msg, DEBUG_DEVELOPER);
163
            header('HTTP/1.0 400 Bad Request. ' . $msg);
161
            $headermsg = 'HTTP/1.0 400 Bad Request. ' . $msg;
-
 
162
        }
-
 
163
 
164
        }
164
        header($headermsg);
Línea -... Línea 165...
-
 
165
    }
-
 
166
 
-
 
167
    /**
-
 
168
     * Process meeting events extension actions.
-
 
169
     *
-
 
170
     * @param instance $instance
-
 
171
     * @param string $jsonstr
-
 
172
     * @return void
-
 
173
     */
-
 
174
    protected static function process_extension_actions(instance $instance, string $jsonstr) {
-
 
175
        // Hooks for extensions.
-
 
176
        $extensions = extension::broker_meeting_events_addons_instances($instance, $jsonstr);
-
 
177
        foreach ($extensions as $extension) {
-
 
178
            $extension->process_action();
Línea 165... Línea 179...
165
    }
179
        }
166
 
180
    }
167
 
181
 
168
    /**
182
    /**