forked from GNUsocial/gnu-social
merge save and ajax save
darcs-hash:20081123014003-84dde-ea8f5d167a544617efb22bb0c553f18d718a65c6.gz
This commit is contained in:
parent
b2285dcb56
commit
cc10e1505f
@ -35,11 +35,7 @@ class NewnoticeAction extends Action {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->boolean('ajax')) {
|
|
||||||
$this->ajax_save_new_notice();
|
|
||||||
} else {
|
|
||||||
$this->save_new_notice();
|
$this->save_new_notice();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$this->show_form();
|
$this->show_form();
|
||||||
}
|
}
|
||||||
@ -88,6 +84,16 @@ class NewnoticeAction extends Action {
|
|||||||
|
|
||||||
common_broadcast_notice($notice);
|
common_broadcast_notice($notice);
|
||||||
|
|
||||||
|
if ($this->boolean('ajax')) {
|
||||||
|
common_start_html('text/xml');
|
||||||
|
common_element_start('head');
|
||||||
|
common_element('title', null, _('Notice posted'));
|
||||||
|
common_element_end('head');
|
||||||
|
common_element_start('body');
|
||||||
|
$this->show_notice($notice);
|
||||||
|
common_element_end('body');
|
||||||
|
common_element_end('html');
|
||||||
|
} else {
|
||||||
$returnto = $this->trimmed('returnto');
|
$returnto = $this->trimmed('returnto');
|
||||||
|
|
||||||
if ($returnto) {
|
if ($returnto) {
|
||||||
@ -99,56 +105,6 @@ class NewnoticeAction extends Action {
|
|||||||
}
|
}
|
||||||
common_redirect($url, 303);
|
common_redirect($url, 303);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax_save_new_notice() {
|
|
||||||
|
|
||||||
$user = common_current_user();
|
|
||||||
assert($user); # XXX: maybe an error instead...
|
|
||||||
$content = $this->trimmed('status_textarea');
|
|
||||||
|
|
||||||
if (!$content) {
|
|
||||||
$this->ajax_error_msg(_('No content!'));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$content = common_shorten_links($content);
|
|
||||||
|
|
||||||
if (mb_strlen($content) > 140) {
|
|
||||||
common_debug("Content = '$content'", __FILE__);
|
|
||||||
common_debug("mb_strlen(\$content) = " . mb_strlen($content), __FILE__);
|
|
||||||
$this->ajax_error_msg(_('That\'s too long. Max notice size is 140 chars.'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$inter = new CommandInterpreter();
|
|
||||||
|
|
||||||
$cmd = $inter->handle_command($user, $content);
|
|
||||||
|
|
||||||
if ($cmd) {
|
|
||||||
$cmd->execute(new WebChannel());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$replyto = $this->trimmed('inreplyto');
|
|
||||||
|
|
||||||
$notice = Notice::saveNew($user->id, $content, 'web', 1, ($replyto == 'false') ? NULL : $replyto);
|
|
||||||
|
|
||||||
if (is_string($notice)) {
|
|
||||||
$this->ajax_error_msg($notice);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
common_broadcast_notice($notice);
|
|
||||||
|
|
||||||
common_start_html('text/xml');
|
|
||||||
common_element_start('head');
|
|
||||||
common_element('title', null, _('Notice posted'));
|
|
||||||
common_element_end('head');
|
|
||||||
common_element_start('body');
|
|
||||||
$this->show_notice($notice);
|
|
||||||
common_element_end('body');
|
|
||||||
common_element_end('html');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajax_error_msg($msg) {
|
function ajax_error_msg($msg) {
|
||||||
@ -167,6 +123,10 @@ class NewnoticeAction extends Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show_form($msg=NULL) {
|
function show_form($msg=NULL) {
|
||||||
|
if ($msg && $this->boolean('ajax')) {
|
||||||
|
$this->ajax_error_msg($msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
$content = $this->trimmed('status_textarea');
|
$content = $this->trimmed('status_textarea');
|
||||||
if (!$content) {
|
if (!$content) {
|
||||||
$replyto = $this->trimmed('replyto');
|
$replyto = $this->trimmed('replyto');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user