properly handle error returns in post w/ajax

This commit is contained in:
Friendika 2011-02-16 20:25:10 -08:00
parent 67bb737aa1
commit c397a2f89b
2 changed files with 13 additions and 4 deletions

View File

@ -117,6 +117,10 @@ function follow_post(&$a) {
$author = $feed->get_author(); $author = $feed->get_author();
if($author) { if($author) {
$vcard['fn'] = unxmlify(trim($author->get_name())); $vcard['fn'] = unxmlify(trim($author->get_name()));
if(! $vcard['fn'])
$vcard['fn'] = trim(unxmlify($author->get_email()));
if(strpos($vcard['fn'],'@') !== false)
$vcard['fn'] = substr($vcard['fn'],0,strpos($vcard['fn'],'@'));
$vcard['nick'] = strtolower(notags(unxmlify($vcard['fn']))); $vcard['nick'] = strtolower(notags(unxmlify($vcard['fn'])));
if(strpos($vcard['nick'],' ')) if(strpos($vcard['nick'],' '))
$vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' '))); $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' ')));

View File

@ -35,7 +35,9 @@ function item_post(&$a) {
); );
if(! count($r)) { if(! count($r)) {
notice( t('Unable to locate original post.') . EOL); notice( t('Unable to locate original post.') . EOL);
goaway($a->get_baseurl() . "/" . $_POST['return'] ); if(x($_POST,'return'))
goaway($a->get_baseurl() . "/" . $_POST['return'] );
killme();
} }
$parent_item = $r[0]; $parent_item = $r[0];
if($parent_item['contact-id'] && $uid) { if($parent_item['contact-id'] && $uid) {
@ -53,7 +55,9 @@ function item_post(&$a) {
if(! can_write_wall($a,$profile_uid)) { if(! can_write_wall($a,$profile_uid)) {
notice( t('Permission denied.') . EOL) ; notice( t('Permission denied.') . EOL) ;
return; if(x($_POST,'return'))
goaway($a->get_baseurl() . "/" . $_POST['return'] );
killme();
} }
$user = null; $user = null;
@ -92,8 +96,9 @@ function item_post(&$a) {
if(! strlen($body)) { if(! strlen($body)) {
notice( t('Empty post discarded.') . EOL ); notice( t('Empty post discarded.') . EOL );
goaway($a->get_baseurl() . "/" . $_POST['return'] ); if(x($_POST,'return'))
goaway($a->get_baseurl() . "/" . $_POST['return'] );
killme();
} }
// get contact info for poster // get contact info for poster