Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 57... Línea 57...
57
     * @param int $expires the length of time the secret is valid. e.g. 1 min = 60
57
     * @param int $expires the length of time the secret is valid. e.g. 1 min = 60
58
     * @param bool $session whether this secret should be linked to the session.
58
     * @param bool $session whether this secret should be linked to the session.
59
     * @param string $secret an optional provided secret
59
     * @param string $secret an optional provided secret
60
     * @return string the secret code, or 0 if no new code created.
60
     * @return string the secret code, or 0 if no new code created.
61
     */
61
     */
62
    public function create_secret(int $expires, bool $session, string $secret = null): string {
62
    public function create_secret(int $expires, bool $session, ?string $secret = null): string {
63
        // Check if there already an active secret, unless we are forcibly given a code.
63
        // Check if there already an active secret, unless we are forcibly given a code.
64
        if ($this->has_active_secret($session) && empty($secret)) {
64
        if ($this->has_active_secret($session) && empty($secret)) {
65
            return '';
65
            return '';
66
        }
66
        }
Línea 86... Línea 86...
86
     * @param string $secret the secret to store
86
     * @param string $secret the secret to store
87
     * @param int $expires expiry duration in seconds
87
     * @param int $expires expiry duration in seconds
88
     * @param string $sessionid an optional sessionID to tie this record to
88
     * @param string $sessionid an optional sessionID to tie this record to
89
     * @return void
89
     * @return void
90
     */
90
     */
91
    private function add_secret_to_db(string $secret, int $expires, string $sessionid = null): void {
91
    private function add_secret_to_db(string $secret, int $expires, ?string $sessionid = null): void {
92
        global $DB, $USER;
92
        global $DB, $USER;
93
        $expirytime = time() + $expires;
93
        $expirytime = time() + $expires;
Línea 94... Línea 94...
94
 
94
 
95
        $data = [
95
        $data = [