X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fnewnotice.php;h=ea832cf4e1300ec0ce75424c40f9f4e8530e1164;hb=6a848bcc8ac37066f7c4941132195d2d67d3b376;hp=dd6da0b01c1b438f91b8904e5abb85bbbce4244c;hpb=4b98edf75f4e255f8c61087bd1525d89653a521f;p=quix0rs-gnu-social.git diff --git a/actions/newnotice.php b/actions/newnotice.php index dd6da0b01c..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,24 +159,20 @@ 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; } - $lat = $this->trimmed('lat'); - $lon = $this->trimmed('lon'); - $location_id = $this->trimmed('location_id'); - $location_ns = $this->trimmed('location_ns'); - $upload = null; $upload = MediaFile::fromUpload('attach'); 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(); @@ -187,16 +185,39 @@ class NewnoticeAction extends Action } } - $notice = Notice::saveNew($user->id, $content_shortened, 'web', 1, - ($replyto == 'false') ? null : $replyto, - null, null, - $lat, $lon, $location_id, $location_ns); + if ($user->shareLocation()) { + // use browser data if checked; otherwise profile data + if ($this->arg('notice_data-geo')) { + $locOptions = Notice::locationOptions($this->trimmed('lat'), + $this->trimmed('lon'), + $this->trimmed('location_id'), + $this->trimmed('location_ns'), + $user->getProfile()); + } else { + $locOptions = Notice::locationOptions(null, + null, + null, + null, + $user->getProfile()); + } - if (isset($upload)) { - $upload->attachToNotice($notice); + $options = array_merge($options, $locOptions); } - common_broadcast_notice($notice); + $author_id = $user->id; + $text = $content_shortened; + + 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'); @@ -289,6 +310,9 @@ class NewnoticeAction extends Action if ($profile) { $content = '@' . $profile->nickname . ' '; } + } else { + // @fixme most of these bits above aren't being passed on above + $inreplyto = null; } $notice_form = new NoticeForm($this, '', $content, null, $inreplyto);