diff --git a/lib/model/QubitObject.php b/lib/model/QubitObject.php index 4a8c085aa2..9e49ca426f 100644 --- a/lib/model/QubitObject.php +++ b/lib/model/QubitObject.php @@ -305,8 +305,45 @@ public function getStatus($options = []) return QubitStatus::getOne($criteria); } + /** + * Check to see if note is saved in memory (field was updated). + * + * + * Used by ISAD, DACS, and RAD templates when duplicating a description, + * specifcally for updating the 'Language and script notes' field. + * + * @param array $options + * + * @return array $notes + */ + public function getMemoryNotesByType(array $options = []) + { + // Check memory for notes + if (count($this->notes) > 0) + { + $noteTypeId = $options['noteTypeId']; + $notes = new ArrayObject(); + + foreach($this->notes as $note) + { + if ($note->typeId == $noteTypeId) + { + $notes->append($note); + } + } + + if (count($notes) > 0) + { + return $notes; + } + } + + return $this->getNotesByType($options); + } + public function getNotesByType(array $options = []) { + $criteria = new Criteria(); $criteria->addJoin(QubitNote::TYPE_ID, QubitTerm::ID); $criteria->add(QubitNote::OBJECT_ID, $this->id); diff --git a/plugins/sfIsadPlugin/lib/sfIsadPlugin.class.php b/plugins/sfIsadPlugin/lib/sfIsadPlugin.class.php index a37f06a631..7ae63dc212 100644 --- a/plugins/sfIsadPlugin/lib/sfIsadPlugin.class.php +++ b/plugins/sfIsadPlugin/lib/sfIsadPlugin.class.php @@ -70,7 +70,7 @@ public function __set($name, $value) { switch ($name) { case 'languageNotes': - $note = $this->resource->getNotesByType(['noteTypeId' => QubitTerm::LANGUAGE_NOTE_ID])->offsetGet(0); + $note = $this->resource->getMemoryNotesByType(['noteTypeId' => QubitTerm::LANGUAGE_NOTE_ID])->offsetGet(0); $missingNote = 0 === count($note); if (0 == strlen($value)) { diff --git a/plugins/sfRadPlugin/lib/sfRadPlugin.class.php b/plugins/sfRadPlugin/lib/sfRadPlugin.class.php index ba40190f66..6aa05df0e3 100644 --- a/plugins/sfRadPlugin/lib/sfRadPlugin.class.php +++ b/plugins/sfRadPlugin/lib/sfRadPlugin.class.php @@ -104,7 +104,7 @@ public function setProperty($name, $value) return $this; case 'languageNotes': - $note = $this->resource->getNotesByType(['noteTypeId' => QubitTerm::LANGUAGE_NOTE_ID])->offsetGet(0); + $note = $this->resource->getMemoryNotesByType(['noteTypeId' => QubitTerm::LANGUAGE_NOTE_ID])->offsetGet(0); $missingNote = 0 === count($note); if (0 == strlen($value)) {