Example #1
0
 function ajax_comment()
 {
     access_policy('write');
     if (trim($_REQUEST['text']) != '' && $_REQUEST['pid'] > 0) {
         $parentMessage = DB_GetDataset('messages', $_REQUEST['pid']);
         $ds = $this->model->post(array('owner' => array('_key' => $parentMessage['m_owner']), 'author' => array('_key' => $this->user->entity), 'text' => $_REQUEST['text'], 'parent' => $parentMessage['m_id']));
         $comments = array('list' => array($ds));
         if (substr($_REQUEST['text'], 0, 1) != '#') {
             ob_start();
             tmpl_commentlist($parentMessage, $comments, false);
             $comment = ob_get_clean();
         }
         print json_encode(array('result' => 'OK', 'post' => $comment));
     }
 }
Example #2
0
function dyn_type_post(&$data, &$ds, &$flags)
{
  /* are there any comments? */
	$comments = MsgModel::getComments($ds['m_key']);
	/* define the standard actions for this post */
	$metaElements = array(
	  ageToString($ds['m_created']), 
	  '<a onclick="springComment('.$ds['m_key'].')">Comment</a>', 
		'<a onclick="springVote('.$ds['m_key'].')">Vote</a>');
	/* insert entries from the cmd array in $flags (these come from plugins) */
	if(is_array($flags['cmd'])) foreach($flags['cmd'] as $cmd) $metaElements[] = $cmd;
	/* admin users get to see an "inspect" button */
  if(object('user')->isAdmin()) $metaElements[] = '<a target="_blank" href="'.actionUrl('inspect', 'test', array('id' => $ds['m_key'])).'">Inspect</a>';
  /* if user is either the owner or the author, she gets to see the delete button */
	if(object('user')->entity == $ds['m_owner'] || object('user')->entity == $ds['m_author']) $metaElements[] = '<a onclick="deletePost('.$ds['m_key'].')">Delete</a>';
  $text = h2_post_excerpt($data['text'], $ds['m_key']);
  /* onward to the actual display of the message: */
  ?><div class="post" id="post_<?php 
echo $ds['m_key'];
?>
">
  	<div class="postimg"><img src="img/anonymous.png" width="64"/></div>
		<div class="postcontent">
			<div>
			<?
			if($ds['m_author'] != $ds['m_owner']) print(HubbubEntity::linkFromId($ds['m_author']).' ► ');
			?>
			<?php 
echo HubbubEntity::linkFromId($ds['m_owner']);
?>
			<?php 
echo $text;
?>
</div>
			<? if(isset($flags['infoblock'])) print('<div>'.$flags['infoblock'].'</div>'); ?>
			<div class="postmeta"><?php 
echo implode(' · ', $metaElements);
?>
</div>
      <div id="post_<?php 
echo $ds['m_key'];
?>
_votething" style="display:none" class="comment_item">
        &nbsp;✓&nbsp; I am: <input type="text" id="vote_<?php 
echo $ds['m_key'];
?>
_text" value="liking it" style="width: 100px" 
        onkeypress="if(event.keyCode == 13) postVote(<?php 
echo $ds['m_key'];
?>
); else if(event.keyCode == 27) cancelVote(<?php 
echo $ds['m_key'];
?>
);"/>
				<input class="smallbtn" type="button" value="Vote" onclick="postVote(<?php 
echo $ds['m_key'];
?>
)"/><input class="smallbtn" type="button" value="Cancel" onclick="cancelVote(<?php 
echo $ds['m_key'];
?>
)"/>
      </div>
			<? tmpl_commentlist($ds, $comments, true) ?>
			<div class="post_actions" id="post_<?php 
echo $ds['m_key'];
?>
_actions">
				<div class="post_pseudocomment" onclick="springComment(<?php 
echo $ds['m_key'];
?>
)">Click here to comment</div>
			</div>
      <div id="post_<?php 
echo $ds['m_key'];
?>
_temp" style="display:none"></div>
      <div id="post_<?php 
echo $ds['m_key'];
?>
_temp_commentthing" style="display:none">
      	<textarea id="post_<?php 
echo $ds['m_key'];
?>
_comment" onblur="closeCommentIfEmpty(<?php 
echo $ds['m_key'];
?>
)"></textarea>
        <input type="button" value="Comment" onclick="postComment(<?php 
echo $ds['m_key'];
?>
)"/> 
				<span id="post_<?php 
echo $ds['m_key'];
?>
_status"></span>
      </div>
		</div>
  </div><?
}