Add location form elements to the noticeform, and save their values on submission
This commit is contained in:
parent
26a86402cd
commit
9a74a094ed
@ -164,6 +164,11 @@ class NewnoticeAction extends Action
|
|||||||
$replyto = 'false';
|
$replyto = 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$lat = $this->trimmed('lat');
|
||||||
|
$lon = $this->trimmed('lon');
|
||||||
|
$location_id = $this->trimmed('location_id');
|
||||||
|
$location_ns = $this->trimmed('location_ns');
|
||||||
|
|
||||||
$upload = null;
|
$upload = null;
|
||||||
$upload = MediaFile::fromUpload('attach');
|
$upload = MediaFile::fromUpload('attach');
|
||||||
|
|
||||||
@ -183,7 +188,9 @@ class NewnoticeAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
|
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
|
||||||
($replyto == 'false') ? null : $replyto);
|
($replyto == 'false') ? null : $replyto,
|
||||||
|
null, null,
|
||||||
|
$lat, $lon, $location_id, $location_ns);
|
||||||
|
|
||||||
if (isset($upload)) {
|
if (isset($upload)) {
|
||||||
$upload->attachToNotice($notice);
|
$upload->attachToNotice($notice);
|
||||||
|
@ -75,6 +75,15 @@ class NoticeForm extends Form
|
|||||||
|
|
||||||
var $inreplyto = null;
|
var $inreplyto = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pre-filled location content of the form
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $lat;
|
||||||
|
var $lon;
|
||||||
|
var $location_id;
|
||||||
|
var $location_ns;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -83,13 +92,17 @@ class NoticeForm extends Form
|
|||||||
* @param string $content content to pre-fill
|
* @param string $content content to pre-fill
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null)
|
function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null, $lat=null, $lon=null, $location_id=null, $location_ns=null)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
|
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
$this->inreplyto = $inreplyto;
|
$this->inreplyto = $inreplyto;
|
||||||
|
$this->lat = $lat;
|
||||||
|
$this->lon = $lon;
|
||||||
|
$this->location_id = $location_id;
|
||||||
|
$this->location_ns = $location_ns;
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
@ -188,6 +201,10 @@ class NoticeForm extends Form
|
|||||||
$this->out->hidden('notice_return-to', $this->action, 'returnto');
|
$this->out->hidden('notice_return-to', $this->action, 'returnto');
|
||||||
}
|
}
|
||||||
$this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
|
$this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
|
||||||
|
$this->out->hidden('notice_data-lat', empty($this->lat) ? null : $this->lat, 'lat');
|
||||||
|
$this->out->hidden('notice_data-lon', empty($this->lon) ? null : $this->lon, 'lon');
|
||||||
|
$this->out->hidden('notice_data-location_id', empty($this->location_id) ? null : $this->location_id, 'location_id');
|
||||||
|
$this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? null : $this->location_ns, 'location_ns');
|
||||||
|
|
||||||
Event::handle('StartShowNoticeFormData', array($this));
|
Event::handle('StartShowNoticeFormData', array($this));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user