X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fnewnotice.php;h=ea832cf4e1300ec0ce75424c40f9f4e8530e1164;hb=a78f184652beb0fc84afbbfb6ec5a407e9409cc8;hp=748d104ff9391de95bd017d1014dc2eb311a5e23;hpb=4b80ce0be89fe50eabec1a19dbf4a0c26a413423;p=quix0rs-gnu-social.git diff --git a/actions/newnotice.php b/actions/newnotice.php index 748d104ff9..ea832cf4e1 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -131,6 +131,8 @@ class NewnoticeAction extends Action $user = common_current_user(); assert($user); // XXX: maybe an error instead... $content = $this->trimmed('status_textarea'); + $options = array(); + Event::handle('StartSaveNewNoticeWeb', array($this, $user, &$content, &$options)); if (!$content) { $this->clientError(_('No content!')); @@ -157,11 +159,9 @@ class NewnoticeAction extends Action Notice::maxContent())); } - $replyto = $this->trimmed('inreplyto'); - #If an ID of 0 is wrongly passed here, it will cause a database error, - #so override it... - if ($replyto == 0) { - $replyto = 'false'; + $replyto = intval($this->trimmed('inreplyto')); + if ($replyto) { + $options['reply_to'] = $replyto; } $upload = null; @@ -169,7 +169,10 @@ class NewnoticeAction extends Action if (isset($upload)) { - $content_shortened .= ' ' . $upload->shortUrl(); + if (Event::handle('StartSaveNewNoticeAppendAttachment', array($this, $upload, &$content_shortened, &$options))) { + $content_shortened .= ' ' . $upload->shortUrl(); + } + Event::handle('EndSaveNewNoticeAppendAttachment', array($this, $upload, &$content_shortened, &$options)); if (Notice::contentTooLong($content_shortened)) { $upload->delete(); @@ -182,8 +185,6 @@ class NewnoticeAction extends Action } } - $options = array('reply_to' => ($replyto == 'false') ? null : $replyto); - if ($user->shareLocation()) { // use browser data if checked; otherwise profile data if ($this->arg('notice_data-geo')) { @@ -203,11 +204,20 @@ class NewnoticeAction extends Action $options = array_merge($options, $locOptions); } - $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options); + $author_id = $user->id; + $text = $content_shortened; - if (isset($upload)) { - $upload->attachToNotice($notice); + if (Event::handle('StartNoticeSaveWeb', array($this, &$author_id, &$text, &$options))) { + + $notice = Notice::saveNew($user->id, $content_shortened, 'web', $options); + + if (isset($upload)) { + $upload->attachToNotice($notice); + } + + Event::handle('EndNoticeSaveWeb', array($this, $notice)); } + Event::handle('EndSaveNewNoticeWeb', array($this, $user, &$content_shortened, &$options)); if ($this->boolean('ajax')) { header('Content-Type: text/xml;charset=utf-8');