Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 66... Línea 66...
66
    /**
66
    /**
67
     * Repository method to serve the referenced file.
67
     * Repository method to serve the referenced file.
68
     *
68
     *
69
     * @inheritDocs
69
     * @inheritDocs
70
     */
70
     */
71
    public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, array $options = null) {
71
    public function send_file($storedfile, $lifetime=null , $filter=0, $forcedownload=false, ?array $options = null) {
72
        $reference = $this->unpack_reference($storedfile->get_reference());
72
        $reference = $this->unpack_reference($storedfile->get_reference());
Línea 73... Línea 73...
73
 
73
 
74
        $maxcachesize = $this->max_cache_bytes();
74
        $maxcachesize = $this->max_cache_bytes();
75
        if (empty($maxcachesize)) {
75
        if (empty($maxcachesize)) {
Línea 109... Línea 109...
109
     *
109
     *
110
     * @inheritDocs
110
     * @inheritDocs
111
     */
111
     */
112
    public function get_reference_details($reference, $filestatus = 0) {
112
    public function get_reference_details($reference, $filestatus = 0) {
113
        global $USER;
113
        global $USER;
114
        $ref  = unserialize($reference);
114
        $ref  = unserialize_object($reference);
115
        $detailsprefix = $this->get_name();
115
        $detailsprefix = $this->get_name();
116
        if (isset($ref->userid) && $ref->userid != $USER->id && isset($ref->username)) {
116
        if (isset($ref->userid) && $ref->userid != $USER->id && isset($ref->username)) {
117
            $detailsprefix .= ' ('.$ref->username.')';
117
            $detailsprefix .= ' ('.$ref->username.')';
118
        }
118
        }
119
        $details = $detailsprefix;
119
        $details = $detailsprefix;
Línea 341... Línea 341...
341
     *
341
     *
342
     * @param   string      $packed     Content of DB field files_reference.reference
342
     * @param   string      $packed     Content of DB field files_reference.reference
343
     * @return  string                  New serialized reference
343
     * @return  string                  New serialized reference
344
     */
344
     */
345
    protected function fix_old_style_reference($packed) {
345
    protected function fix_old_style_reference($packed) {
346
        $ref = unserialize($packed);
346
        $ref = unserialize_object($packed);
347
        $ref = $this->dropbox->get_file_share_info($ref->path);
347
        $ref = $this->dropbox->get_file_share_info($ref->path ?? '');
348
        if (!$ref || empty($ref->url)) {
348
        if (!$ref || empty($ref->url)) {
349
            // Some error occurred, do not fix reference for now.
349
            // Some error occurred, do not fix reference for now.
350
            return $packed;
350
            return $packed;
351
        }
351
        }
Línea 394... Línea 394...
394
     *
394
     *
395
     * @param   string      $packed     The packed reference
395
     * @param   string      $packed     The packed reference
396
     * @return  object                  The unpacked reference
396
     * @return  object                  The unpacked reference
397
     */
397
     */
398
    protected function unpack_reference($packed) {
398
    protected function unpack_reference($packed) {
399
        $reference = unserialize($packed);
399
        $reference = unserialize_object($packed);
400
        if (empty($reference->url)) {
400
        if (empty($reference->url)) {
401
            // The reference is missing some information. Attempt to update it.
401
            // The reference is missing some information. Attempt to update it.
402
            return unserialize($this->fix_old_style_reference($packed));
402
            return unserialize_object($this->fix_old_style_reference($packed));
403
        }
403
        }
Línea 404... Línea 404...
404
 
404
 
405
        return $reference;
405
        return $reference;