| 42 | | switch($this->getVariable('type', 'html')){ |
| 43 | | case 'json': |
| 44 | | if(Variable::istype('TableObjectBase', $status)){ |
| 45 | | // success |
| 46 | | $replyUserName = $status->getReplyUserName(); |
| 47 | | $status->comment = PhwittrFormatter::c($status->comment); |
| 48 | | $status->createdAt = TemplateFormatter::dateformat($status->createdAt); |
| 49 | | $status->replyTo = ($status->replyUserId) ? sprintf(' in reply to <a href="%s">%s</a>', Rhaco::url($replyUserName), $replyUserName) : ''; |
| 50 | | $response = array( |
| 51 | | 'error' => 0, |
| 52 | | 'message' => 'status updated!', |
| 53 | | 'status' => $status, |
| 54 | | 'user' => $user, |
| 55 | | ); |
| 56 | | } else { |
| 57 | | // fail |
| 58 | | $error = array_shift(ExceptionTrigger::get('Status_comment')); |
| 59 | | $response = array( |
| 60 | | 'error' => 1, |
| 61 | | 'message' => $error->getMessage(), |
| 62 | | ); |
| 63 | | } |
| 64 | | $response = V::toJson($response); |
| 65 | | header('Content-type: application/json; charset=UTF-8'); |
| 66 | | header(sprintf("X-JSON: (%s)", $response)); |
| 67 | | echo $response; |
| 68 | | break; |
| 69 | | default: |
| 70 | | if(Variable::istype('TableObjectBase', $status)) |
| 71 | | $this->setSession('notice', 'status updated!'); |
| 72 | | Header::redirect(Rhaco::url('home')); |
| | 42 | if(Variable::istype('TableObjectBase', $status)){ |
| | 43 | // success |
| | 44 | $replyUserName = $status->getReplyUserName(); |
| | 45 | $status->comment = PhwittrFormatter::c($status->comment); |
| | 46 | $status->createdAt = TemplateFormatter::dateformat($status->createdAt); |
| | 47 | $status->replyTo = ($status->replyUserId) ? sprintf(' in reply to <a href="%s">%s</a>', Rhaco::url($replyUserName), $replyUserName) : ''; |
| | 48 | $response = array( |
| | 49 | 'error' => 0, |
| | 50 | 'message' => 'status updated!', |
| | 51 | 'status' => $status, |
| | 52 | 'user' => $user, |
| | 53 | ); |
| | 54 | } else { |
| | 55 | // fail |
| | 56 | $error = array_shift(ExceptionTrigger::get('Status_comment')); |
| | 57 | $response = array( |
| | 58 | 'error' => 1, |
| | 59 | 'message' => $error->getMessage(), |
| | 60 | ); |