Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 11
Línea 111... Línea 111...
111
 
111
 
112
        return $url;
112
        return $url;
Línea 113... Línea 113...
113
    }
113
    }
-
 
114
 
-
 
115
    public function save_form_data(\stdClass $instance): void {
-
 
116
        if (empty($instance->customlinkurl)) {
-
 
117
            return;
114
 
118
        }
Línea 115... Línea 119...
115
    public function save_form_data(\stdClass $instance): void {
119
 
116
        global $DB;
120
        global $DB;
Línea 117... Línea 121...
117
 
121
 
118
        $commid = $this->communication->get_id();
122
        $commid = $this->communication->get_id();
Línea 119... Línea 123...
119
        $cachekey = "link_url_{$commid}";
123
        $cachekey = "link_url_{$commid}";
120
 
124
 
121
        $newrecord = new \stdClass();
125
        $newrecord = new \stdClass();
122
        $newrecord->url = $instance->customlinkurl ?? null;
126
        $newrecord->url = $instance->customlinkurl;
Línea 129... Línea 133...
129
 
133
 
130
        if (!$existingrecord) {
134
        if (!$existingrecord) {
131
            // Create the record if it does not exist.
135
            // Create the record if it does not exist.
132
            $newrecord->commid = $commid;
136
            $newrecord->commid = $commid;
133
            $DB->insert_record(self::CUSTOMLINK_TABLE, $newrecord);
137
            $DB->insert_record(self::CUSTOMLINK_TABLE, $newrecord);
134
        } else if ($newrecord->url !== $existingrecord->url) {
138
        } else if ($instance->customlinkurl !== $existingrecord->url) {
135
            // Update record if the URL has changed.
139
            // Update record if the URL has changed.
136
            $newrecord->id = $existingrecord->id;
140
            $newrecord->id = $existingrecord->id;
137
            $DB->update_record(self::CUSTOMLINK_TABLE, $newrecord);
141
            $DB->update_record(self::CUSTOMLINK_TABLE, $newrecord);
138
        } else {
142
        } else {