Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 114... Línea 114...
114
                $mform->addElement('warning', 'notification_'.$key, 'notify', $notification);
114
                $mform->addElement('warning', 'notification_'.$key, 'notify', $notification);
115
            }
115
            }
116
            $mform->addElement('cancel', 'cancel', get_string('back'));
116
            $mform->addElement('cancel', 'cancel', get_string('back'));
117
        } else {
117
        } else {
118
            $this->h5peditor->add_editor_to_form($mform);
118
            $this->h5peditor->add_editor_to_form($mform);
-
 
119
            parent::definition();
119
            $this->add_action_buttons();
120
            $this->add_action_buttons();
120
        }
121
        }
121
    }
122
    }
Línea 122... Línea 123...
122
 
123
 
Línea 155... Línea 156...
155
            $cbrecord->name = json_decode($data->h5pparams)->metadata->title;
156
            $cbrecord->name = json_decode($data->h5pparams)->metadata->title;
156
            $context = \context::instance_by_id($data->contextid, MUST_EXIST);
157
            $context = \context::instance_by_id($data->contextid, MUST_EXIST);
157
            // Create entry in content bank.
158
            // Create entry in content bank.
158
            $contenttype = new contenttype($context);
159
            $contenttype = new contenttype($context);
159
            $newcontent = $contenttype->create_content($cbrecord);
160
            $newcontent = $contenttype->create_content($cbrecord);
-
 
161
            $cfdata = fullclone($data);
-
 
162
            $cfdata->id = $newcontent->get_id();
-
 
163
            $handler = \core_contentbank\customfield\content_handler::create();
-
 
164
            $handler->instance_form_save($cfdata, true);
160
            if ($file && $newcontent) {
165
            if ($file && $newcontent) {
161
                $updatedfilerecord = new stdClass();
166
                $updatedfilerecord = new stdClass();
162
                $updatedfilerecord->id = $file->get_id();
167
                $updatedfilerecord->id = $file->get_id();
163
                $updatedfilerecord->itemid = $newcontent->get_id();
168
                $updatedfilerecord->itemid = $newcontent->get_id();
164
                // As itemid changed, the pathnamehash has to be updated in the file table.
169
                // As itemid changed, the pathnamehash has to be updated in the file table.
Línea 170... Línea 175...
170
                $h5pfs->updateContentFields($h5pcontentid, ['pathnamehash' => $pathnamehash]);
175
                $h5pfs->updateContentFields($h5pcontentid, ['pathnamehash' => $pathnamehash]);
171
            }
176
            }
172
        } else {
177
        } else {
173
            // Update content.
178
            // Update content.
174
            $this->content->update_content();
179
            $this->content->update_content();
-
 
180
            $cfdata = fullclone($data);
-
 
181
            $cfdata->id = $this->content->get_id();
-
 
182
            $handler = \core_contentbank\customfield\content_handler::create();
-
 
183
            $handler->instance_form_save($cfdata, true);
175
        }
184
        }
Línea 176... Línea 185...
176
 
185
 
177
        return $contentid ?? $newcontent->get_id();
186
        return $contentid ?? $newcontent->get_id();
178
    }
187
    }