예제 #1
0
파일: lib.php 프로젝트: rboyatt/mahara
 /**
  * Fix annotations to point to the right view.
  */
 public static function setup_view_relationships_from_requests(PluginImportLeap $importer)
 {
     // Get all the annotations imported.
     if ($entry_requests = get_records_select_array('import_entry_requests', 'importid = ? AND entrytype = ?', array($importer->get('importertransport')->get('importid'), 'annotation'))) {
         foreach ($entry_requests as $entry_request) {
             $annotationids = $importer->get_artefactids_imported_by_entryid($entry_request->entryid);
             $annotation = new ArtefactTypeAnnotation($annotationids[0]);
             if (!$annotation->get('id')) {
                 continue;
             }
             $annotation_entry = $importer->get_entry_by_id($entry_request->entryid);
             $view_entry_request = self::get_referent_entryid($annotation_entry, $importer);
             // Now see which view had this entryid.
             if ($viewid = $importer->get_viewid_imported_by_entryid($view_entry_request)) {
                 // Set the view on the annotation.
                 $annotation->set('view', $viewid);
                 $annotation->commit();
             } else {
                 // Nothing to link this annotation to, so leave it in the temporary view.
                 self::$savetempview = true;
             }
         }
     }
 }
예제 #2
0
파일: lib.php 프로젝트: vohung96/mahara
 public static function instance_config_save($values, $instance)
 {
     require_once 'embeddedimage.php';
     safe_require('artefact', 'annotation');
     $data = array();
     $view = $instance->get_view();
     $configdata = $instance->get('configdata');
     foreach (array('owner', 'group', 'institution') as $f) {
         $data[$f] = $view->get($f);
     }
     // The title will always be Annotation.
     $title = get_string('Annotation', 'artefact.annotation');
     $data['title'] = $title;
     $values['title'] = $title;
     if (empty($configdata['artefactid'])) {
         // This is a new annotation.
         $artefact = new ArtefactTypeAnnotation(0, $data);
     } else {
         // The user is editing the annotation.
         $artefact = new ArtefactTypeAnnotation($configdata['artefactid']);
     }
     $artefact->set('title', $title);
     $artefact->set('description', $values['text']);
     $artefact->set('allowcomments', !empty($values['allowfeedback']) ? $values['allowfeedback'] : 0);
     $artefact->set('tags', $values['tags']);
     $artefact->set('view', $view->get('id'));
     $artefact->commit();
     // Now fix up the text in case there were any embedded images.
     // Do this after saving because we may not have an artefactid yet.
     $newdescription = EmbeddedImage::prepare_embedded_images($values['text'], 'annotation', $artefact->get('id'), $view->get('group'));
     if ($newdescription !== false && $newdescription !== $values['text']) {
         $updatedartefact = new stdClass();
         $updatedartefact->id = $artefact->get('id');
         $updatedartefact->description = $newdescription;
         update_record('artefact', $updatedartefact, 'id');
     }
     $values['artefactid'] = $artefact->get('id');
     $instance->save_artefact_instance($artefact);
     unset($values['text']);
     unset($values['allowfeedback']);
     unset($values['annotationreadonlymsg']);
     // Pass back a list of any other blocks that need to be rendered
     // due to this change.
     $values['_redrawblocks'] = array_unique(get_column('view_artefact', 'block', 'artefact', $values['artefactid'], 'view', $instance->get('view')));
     return $values;
 }