/** * Return array of resourceID, type (A or Q) * and parsed div with comment * * */ protected function returnResult() { $aComment = $this->CommentParser->getArrayCopy(); /** * Add edit and delete tools because * Viewer already owns this comment and is * allowed to edit or delete it right away. * Javascript that usually dynamically adds these tools * is not going to be fired, so these tools * must alreayd be included in the returned html * */ $aComment['edit_delete'] = ' <span class="ico del ajax" title="Delete">delete</span> <span class="ico edit ajax" title="Edit">edit</span>'; /** * Important to add owner_id key * because it's not in the comment array * It is used when creating the 'reply' link * in the tplComment * That ID is then used when figuring out if * viewer has permission to add comment. * Users with low reputation still always have * premission to add comments to own resources. * */ $aComment['owner_id'] = $this->Resource->getOwnerId(); $aRet = array('comment' => array('id' => $aComment['_id'], 'res' => $aComment['i_res'], 'parent' => $aComment['i_prnt'], 'html' => \tplComment::parse($aComment))); Responder::sendJSON($aRet); }