@@ -495,18 +495,16 @@ public function saveObject(): void
495495
496496 // assign style to style sheet folder,
497497 // if parent is style sheet folder
498- if ($ this ->requested_ref_id > 0 ) {
499- $ fold = ilObjectFactory::getInstanceByRefId ($ this ->requested_ref_id );
500- if ($ fold ->getType () == "stys " ) {
501- $ cont_style_settings = new ilContentStyleSettings ();
502- $ cont_style_settings ->addStyle ($ newObj ->getId ());
503- $ cont_style_settings ->update ();
504-
505- ilObjStyleSheet::_writeStandard ($ newObj ->getId (), true );
506- $ this ->tpl ->setOnScreenMessage ("success " , $ this ->lng ->txt ("object_added " ), true );
507- $ this ->ctrl ->setParameterByClass (self ::class, "obj_id " , (string ) $ newObj ->getId ());
508- $ this ->ctrl ->redirectByClass (self ::class, "" );
509- }
498+ if ($ this ->requested_ref_id > 0 &&
499+ ilObject::_lookupType ($ this ->requested_ref_id , true ) === "stys " ) {
500+ $ cont_style_settings = new ilContentStyleSettings ();
501+ $ cont_style_settings ->addStyle ($ newObj ->getId ());
502+ $ cont_style_settings ->update ();
503+
504+ ilObjStyleSheet::_writeStandard ($ newObj ->getId (), true );
505+ $ this ->tpl ->setOnScreenMessage ("success " , $ this ->lng ->txt ("object_added " ), true );
506+ $ this ->ctrl ->setParameterByClass (self ::class, "obj_id " , (string ) $ newObj ->getId ());
507+ $ this ->ctrl ->redirectByClass (self ::class, "" );
510508 }
511509 }
512510
0 commit comments