Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 141... Línea 141...
141
 
141
 
142
        return $this->render_from_template('tool_mfa/mfa_selector', $data);
142
        return $this->render_from_template('tool_mfa/mfa_selector', $data);
Línea 143... Línea 143...
143
    }
143
    }
144
 
-
 
145
    /**
-
 
146
     * Returns the html section for factor setup
-
 
147
     *
-
 
148
     * @param object $factor object of the factor class
144
 
149
     * @return string
-
 
150
     * @deprecated since Moodle 4.4
145
    /**
151
     * @todo Final deprecation in Moodle 4.8 MDL-80995
-
 
152
     */
146
     * @deprecated since Moodle 4.4
153
    public function setup_factor(object $factor): string {
-
 
154
        debugging('The method setup_factor() has been deprecated. The HTML derived from this method is no longer needed.
-
 
155
            Similar HTML is now achieved as part of available_factors().', DEBUG_DEVELOPER);
-
 
156
        $html = '';
-
 
157
 
-
 
158
        $html .= html_writer::start_tag('div', ['class' => 'card']);
-
 
159
 
-
 
160
        $html .= html_writer::tag('h4', $factor->get_display_name(), ['class' => 'card-header']);
147
     */
161
        $html .= html_writer::start_tag('div', ['class' => 'card-body']);
-
 
162
        $html .= $factor->get_info();
-
 
163
 
148
    #[\core\attribute\deprecated(null, reason: 'It is no longer used', since: '4.4', mdl: 'MDL-79920', final: true)]
164
        $setupparams = ['action' => 'setup', 'factor' => $factor->name, 'sesskey' => sesskey()];
-
 
165
        $setupurl = new \moodle_url('action.php', $setupparams);
-
 
166
        $html .= $this->output->single_button($setupurl, $factor->get_setup_string());
-
 
167
        $html .= html_writer::end_tag('div');
-
 
168
        $html .= html_writer::end_tag('div');
-
 
169
        $html .= '<br>';
-
 
170
 
149
    public function setup_factor(): void {
Línea 171... Línea 150...
171
        return $html;
150
        \core\deprecation::emit_deprecation([self::class, __FUNCTION__]);
172
    }
151
    }
173
 
152
 
174
    /**
153
    /**
175
     * Show a table displaying a users active factors.
154
     * Show a table displaying a users active factors.
176
     *
155
     *
177
     * @param string|null $filterfactor The factor name to filter on.
156
     * @param string|null $filterfactor The factor name to filter on.
178
     * @return string $html
157
     * @return string $html
179
     * @throws \coding_exception
158
     * @throws \coding_exception
Línea 180... Línea 159...
180
     */
159
     */
Línea 181... Línea 160...
181
    public function active_factors(string $filterfactor = null): string {
160
    public function active_factors(?string $filterfactor = null): string {
Línea 202... Línea 181...
202
            $headers->lastused,
181
            $headers->lastused,
203
            $headers->replace,
182
            $headers->replace,
204
            $headers->remove,
183
            $headers->remove,
205
        ];
184
        ];
206
        $table->colclasses = [
185
        $table->colclasses = [
207
            'text-left',
186
            'text-start',
208
            'text-left',
187
            'text-start',
209
            'text-left',
188
            'text-start',
210
            'text-center',
189
            'text-center',
211
            'text-center',
190
            'text-center',
212
        ];
191
        ];
213
        $table->data  = [];
192
        $table->data  = [];
Línea 377... Línea 356...
377
                            COUNT(id)
356
                            COUNT(id)
378
                        FROM {user}
357
                        FROM {user}
379
                        WHERE deleted = 0
358
                        WHERE deleted = 0
380
                        AND suspended = 0
359
                        AND suspended = 0
381
                    GROUP BY auth";
360
                    GROUP BY auth";
382
        $allusersinfo = $DB->get_records_sql($alluserssql, []);
361
        $allusersinfo = $DB->get_records_sql_menu($alluserssql);
Línea 383... Línea 362...
383
 
362
 
384
        $noncompletesql = "SELECT u.auth, COUNT(u.id)
363
        $noncompletesql = "SELECT u.auth, COUNT(u.id)
385
                             FROM {user} u
364
                             FROM {user} u
386
                        LEFT JOIN {tool_mfa_auth} mfaa ON u.id = mfaa.userid
365
                        LEFT JOIN {tool_mfa_auth} mfaa ON u.id = mfaa.userid
387
                            WHERE u.lastlogin >= ?
366
                            WHERE u.lastlogin >= ?
388
                              AND (mfaa.lastverified < ?
367
                              AND (mfaa.lastverified < ?
389
                               OR mfaa.lastverified IS NULL)
368
                               OR mfaa.lastverified IS NULL)
390
                         GROUP BY u.auth";
369
                         GROUP BY u.auth";
Línea 391... Línea 370...
391
        $noncompleteinfo = $DB->get_records_sql($noncompletesql, [$lookback, $lookback]);
370
        $noncompleteinfo = $DB->get_records_sql_menu($noncompletesql, [$lookback, $lookback]);
392
 
371
 
393
        $nologinsql = "SELECT auth, COUNT(id)
372
        $nologinsql = "SELECT auth, COUNT(id)
394
                         FROM {user}
373
                         FROM {user}
395
                        WHERE deleted = 0
374
                        WHERE deleted = 0
396
                          AND suspended = 0
375
                          AND suspended = 0
397
                          AND lastlogin < ?
376
                          AND lastlogin < ?
Línea 398... Línea 377...
398
                     GROUP BY auth";
377
                     GROUP BY auth";
399
        $nologininfo = $DB->get_records_sql($nologinsql, [$lookback]);
378
        $nologininfo = $DB->get_records_sql_menu($nologinsql, [$lookback]);
400
 
379
 
401
        $mfauserssql = "SELECT auth,
380
        $mfauserssql = "SELECT auth,
402
                            COUNT(DISTINCT tm.userid)
381
                            COUNT(DISTINCT tm.userid)
403
                        FROM {tool_mfa} tm
382
                        FROM {tool_mfa} tm
404
                        JOIN {user} u ON u.id = tm.userid
383
                        JOIN {user} u ON u.id = tm.userid
405
                        WHERE tm.lastverified >= ?
384
                        WHERE tm.lastverified >= ?
406
                        AND u.deleted = 0
385
                        AND u.deleted = 0
Línea 407... Línea 386...
407
                        AND u.suspended = 0
386
                        AND u.suspended = 0
408
                    GROUP BY u.auth";
387
                    GROUP BY u.auth";
409
        $mfausersinfo = $DB->get_records_sql($mfauserssql, [$lookback]);
388
        $mfausersinfo = $DB->get_records_sql_menu($mfauserssql, [$lookback]);
410
 
389
 
411
        $factorsusedsql = "SELECT CONCAT(u.auth, '_', tm.factor) as id,
390
        $factorsusedsql = "SELECT CONCAT(u.auth, '_', tm.factor) as id,
412
                                COUNT(*)
391
                                COUNT(*)
413
                            FROM {tool_mfa} tm
392
                            FROM {tool_mfa} tm
414
                            JOIN {user} u ON u.id = tm.userid
393
                            JOIN {user} u ON u.id = tm.userid
415
                            WHERE tm.lastverified >= ?
394
                            WHERE tm.lastverified >= ?
416
                            AND u.deleted = 0
395
                            AND u.deleted = 0
Línea 417... Línea 396...
417
                            AND u.suspended = 0
396
                            AND u.suspended = 0
418
                            AND (tm.revoked = 0 OR (tm.revoked = 1 AND tm.timemodified > ?))
397
                            AND (tm.revoked = 0 OR (tm.revoked = 1 AND tm.timemodified > ?))
419
                        GROUP BY CONCAT(u.auth, '_', tm.factor)";
398
                        GROUP BY CONCAT(u.auth, '_', tm.factor)";
420
        $factorsusedinfo = $DB->get_records_sql($factorsusedsql, [$lookback, $lookback]);
399
        $factorsusedinfo = $DB->get_records_sql_menu($factorsusedsql, [$lookback, $lookback]);
421
 
400
 
Línea 422... Línea 401...
422
        // Auth rows.
401
        // Auth rows.
423
        $authtypes = get_enabled_auth_plugins(true);
402
        $authtypes = get_enabled_auth_plugins(true);
424
        foreach ($authtypes as $authtype) {
403
        foreach ($authtypes as $authtype) {
425
            $row = [];
404
            $row = [];
426
            $row[] = \html_writer::tag('b', $authtype);
405
            $row[] = \html_writer::tag('b', $authtype);
Línea 427... Línea 406...
427
 
406
 
428
            // Setup the overall totals columns.
407
            // Setup the overall totals columns.
Línea 429... Línea 408...
429
            $row[] = $allusersinfo[$authtype]->count ?? '-';
408
            $row[] = $allusersinfo[$authtype] ?? '-';
430
            $row[] = $mfausersinfo[$authtype]->count ?? '-';
409
            $row[] = $mfausersinfo[$authtype] ?? '-';
431
            $row[] = $noncompleteinfo[$authtype]->count ?? '-';
410
            $row[] = $noncompleteinfo[$authtype] ?? '-';
432
            $row[] = $nologininfo[$authtype]->count ?? '-';
411
            $row[] = $nologininfo[$authtype] ?? '-';
433
 
412
 
434
            // Create a running counter for the total.
413
            // Create a running counter for the total.
435
            $authtotal = 0;
414
            $authtotal = 0;
Línea 436... Línea 415...
436
 
415
 
437
            // Now for each factor add the count from the factor query, and increment the running total.
416
            // Now for each factor add the count from the factor query, and increment the running total.
438
            foreach ($columns as $column) {
417
            foreach ($columns as $column) {