@@ -76,73 +76,83 @@ public function executeAndGetResponseObject(): stdClass
76
76
77
77
if ($ draftId > 0 ) {
78
78
if ('showreply ' === $ this ->action ) {
79
- $ draftObj = ilForumPostDraft::newInstanceByDraftId ($ draftId );
80
- $ draftObj ->setPostSubject ($ subjectFormatterCallback ($ inputValues ['subject ' ]));
81
- $ draftObj ->setPostMessage (ilRTE::_replaceMediaObjectImageSrc ($ inputValues ['message ' ], 0 ));
82
- $ draftObj ->setPostUserAlias ($ inputValues ['alias ' ]);
83
- $ draftObj ->setNotificationStatus ((bool ) $ inputValues ['notify ' ]);
84
- $ draftObj ->setUpdateUserId ($ this ->actor ->getId ());
85
- $ draftObj ->setPostAuthorId ($ this ->actor ->getId ());
86
- $ draftObj ->setPostDisplayUserId (($ this ->forumProperties ->isAnonymized () ? 0 : $ this ->actor ->getId ()));
87
- $ draftObj ->updateDraft ();
79
+ $ draft = ilForumPostDraft::newInstanceByDraftId ($ draftId );
80
+
81
+ if ($ draft ->getPostAuthorId () !== $ this ->actor ->getId ()) {
82
+ return $ response ;
83
+ }
84
+
85
+ $ draft ->setPostSubject ($ subjectFormatterCallback ($ inputValues ['subject ' ]));
86
+ $ draft ->setPostMessage (ilRTE::_replaceMediaObjectImageSrc ($ inputValues ['message ' ], 0 ));
87
+ $ draft ->setPostUserAlias ($ inputValues ['alias ' ]);
88
+ $ draft ->setNotificationStatus ((bool ) $ inputValues ['notify ' ]);
89
+ $ draft ->setUpdateUserId ($ this ->actor ->getId ());
90
+ $ draft ->setPostAuthorId ($ this ->actor ->getId ());
91
+ $ draft ->setPostDisplayUserId (($ this ->forumProperties ->isAnonymized () ? 0 : $ this ->actor ->getId ()));
92
+ $ draft ->updateDraft ();
88
93
89
94
$ uploadedObjects = ilObjMediaObject::_getMobsOfObject ('frm~:html ' , $ this ->actor ->getId ());
90
- $ oldMediaObjects = ilObjMediaObject::_getMobsOfObject ('frm~d:html ' , $ draftObj ->getDraftId ());
95
+ $ oldMediaObjects = ilObjMediaObject::_getMobsOfObject ('frm~d:html ' , $ draft ->getDraftId ());
91
96
$ curMediaObjects = ilRTE::_getMediaObjects ($ inputValues ['message ' ], 0 );
92
97
93
98
$ this ->handleMedia (
94
99
ilForumPostDraft::MEDIAOBJECT_TYPE ,
95
- $ draftObj ->getDraftId (),
100
+ $ draft ->getDraftId (),
96
101
$ uploadedObjects ,
97
102
$ oldMediaObjects ,
98
103
$ curMediaObjects
99
104
);
100
105
} else {
101
- $ draftObj = new ilForumDraftsHistory ();
102
- $ draftObj ->setDraftId ($ draftId );
103
- $ draftObj ->setPostSubject ($ subjectFormatterCallback ($ inputValues ['subject ' ]));
104
- $ draftObj ->setPostMessage (ilRTE::_replaceMediaObjectImageSrc ($ inputValues ['message ' ], 0 ));
105
- $ draftObj ->addDraftToHistory ();
106
+ $ draft = ilForumPostDraft::newInstanceByDraftId ($ draftId );
107
+ if ($ draft ->getPostAuthorId () !== $ this ->actor ->getId ()) {
108
+ return $ response ;
109
+ }
110
+
111
+ $ history_entry = new ilForumDraftsHistory ();
112
+ $ history_entry ->setDraftId ($ draft ->getDraftId ());
113
+ $ history_entry ->setPostSubject ($ subjectFormatterCallback ($ inputValues ['subject ' ]));
114
+ $ history_entry ->setPostMessage (ilRTE::_replaceMediaObjectImageSrc ($ inputValues ['message ' ], 0 ));
115
+ $ history_entry ->addDraftToHistory ();
106
116
107
117
$ uploadedObjects = ilObjMediaObject::_getMobsOfObject ('frm~:html ' , $ this ->actor ->getId ());
108
- $ oldMediaObjects = ilObjMediaObject::_getMobsOfObject ('frm~d:html ' , $ draftObj ->getDraftId ());
118
+ $ oldMediaObjects = ilObjMediaObject::_getMobsOfObject ('frm~d:html ' , $ history_entry ->getDraftId ());
109
119
$ curMediaObjects = ilRTE::_getMediaObjects ($ inputValues ['message ' ], 0 );
110
120
111
121
$ this ->handleMedia (
112
122
ilForumDraftsHistory::MEDIAOBJECT_TYPE ,
113
- $ draftObj ->getHistoryId (),
123
+ $ history_entry ->getHistoryId (),
114
124
$ uploadedObjects ,
115
125
$ oldMediaObjects ,
116
126
$ curMediaObjects
117
127
);
118
128
}
119
129
} else {
120
- $ draftObj = new ilForumPostDraft ();
121
- $ draftObj ->setForumId ($ this ->relatedForumId );
122
- $ draftObj ->setThreadId ($ this ->thread ->getId ());
123
- $ draftObj ->setPostId ($ relatedPostId );
124
- $ draftObj ->setPostSubject ($ subjectFormatterCallback ($ inputValues ['subject ' ]));
125
- $ draftObj ->setPostMessage (ilRTE::_replaceMediaObjectImageSrc ($ inputValues ['message ' ], 0 ));
126
- $ draftObj ->setPostUserAlias ($ inputValues ['alias ' ]);
127
- $ draftObj ->setNotificationStatus ((bool ) $ inputValues ['notify ' ]);
128
- $ draftObj ->setPostAuthorId ($ this ->actor ->getId ());
129
- $ draftObj ->setPostDisplayUserId (($ this ->forumProperties ->isAnonymized () ? 0 : $ this ->actor ->getId ()));
130
- $ draftObj ->saveDraft ();
130
+ $ draft = new ilForumPostDraft ();
131
+ $ draft ->setForumId ($ this ->relatedForumId );
132
+ $ draft ->setThreadId ($ this ->thread ->getId ());
133
+ $ draft ->setPostId ($ relatedPostId );
134
+ $ draft ->setPostSubject ($ subjectFormatterCallback ($ inputValues ['subject ' ]));
135
+ $ draft ->setPostMessage (ilRTE::_replaceMediaObjectImageSrc ($ inputValues ['message ' ], 0 ));
136
+ $ draft ->setPostUserAlias ($ inputValues ['alias ' ]);
137
+ $ draft ->setNotificationStatus ((bool ) $ inputValues ['notify ' ]);
138
+ $ draft ->setPostAuthorId ($ this ->actor ->getId ());
139
+ $ draft ->setPostDisplayUserId (($ this ->forumProperties ->isAnonymized () ? 0 : $ this ->actor ->getId ()));
140
+ $ draft ->saveDraft ();
131
141
132
142
$ uploadedObjects = ilObjMediaObject::_getMobsOfObject ('frm~:html ' , $ this ->actor ->getId ());
133
- $ oldMediaObjects = ilObjMediaObject::_getMobsOfObject ('frm~d:html ' , $ draftObj ->getDraftId ());
143
+ $ oldMediaObjects = ilObjMediaObject::_getMobsOfObject ('frm~d:html ' , $ draft ->getDraftId ());
134
144
$ curMediaObjects = ilRTE::_getMediaObjects ($ inputValues ['message ' ], 0 );
135
145
136
146
$ this ->handleMedia (
137
147
ilForumPostDraft::MEDIAOBJECT_TYPE ,
138
- $ draftObj ->getDraftId (),
148
+ $ draft ->getDraftId (),
139
149
$ uploadedObjects ,
140
150
$ oldMediaObjects ,
141
151
$ curMediaObjects
142
152
);
143
153
}
144
154
145
- $ response ->draft_id = $ draftObj ->getDraftId ();
155
+ $ response ->draft_id = $ draft ->getDraftId ();
146
156
147
157
return $ response ;
148
158
}
0 commit comments