function _post_save_vote(&$data, &$msg) { $msg->voteHash = md5(strtolower(substr($data['text'], 1))); // but if this person already voted, we need to unregister these previous votes DB_Update('UPDATE ' . getTableName('messages') . ' SET m_votehash = "", m_deleted = "Y" WHERE m_parent = ? AND m_author = ?', array($msg->parentKey, $msg->authorEntity->key())); DB_Update('DELETE FROM ' . getTableName('votes') . ' WHERE v_msg = ?', array($msg->parentKey)); // update the vote summary foreach (DB_GetList('SELECT COUNT(*) as votecount,m_data,m_id,m_votehash as count FROM ' . getTableName('messages') . ' WHERE m_parent = ? AND m_deleted = "N" AND m_type="post" AND m_votehash != "" GROUP BY m_votehash') as $vds) { $msgData = HubbubMessage::unpackData($vds); // get the some exemplary votes for this $voterList = array(); foreach (DB_GetList('SELECT m_author FROM ' . getTableName('messages') . ' WHERE m_parent = ? AND m_votehash = ? ORDER BY m_created DESC LIMIT 3', array($msg->parentKey, $vds['m_votehash'])) as $vex) { $voterList[] = $vex; } // if this is also what this message votes for, add it to the list if ($this->{$msg}->voteHash == $vds['m_votehash']) { $voterList[] = getDefault($msg->authorKey, $msg->ownerKey); } // make the vote summary dataset $voteDS = array('v_msg' => $msg->parentKey, 'v_choice' => $vds['m_votehash'], 'v_text' => $msgData['text'], 'v_voters' => implode(',', $voterList), 'v_count' => $vds['votecount']); DB_UpdateDataset('votes', $voteDS); } }
<? $ds = DB_GetDataset('messages', $_REQUEST['id']); $data = HubbubMessage::unpackData($ds); $data['created'] = $data['created'].' ('.gmdate('Y-m-d H:i:s', $data['created']).')'; $data['changed'] = $data['changed'].' ('.gmdate('Y-m-d H:i:s', $data['changed']).')'; ?> <h2>Inspect Message <?php echo $_REQUEST['id']; ?> </h2> <pre><? print('Message Data '); print_r($data); $ds['m_data'] = strlen($ds['m_data']).' bytes'; print('Local Storage '); print_r($ds); ?></pre>
tlog($post->ds['m_key'] > 0, 'post saved locally', 'OK (#'.$post->ds['m_id'].')', 'fail'); $streamPosts1 = $this->msg->getStream($ne2->key()); foreach($streamPosts1['list'] as $pds) if($pds['m_id'] == $post->data['msgid']) $matchDS7 = $pds; tlog(is_array($matchDS7), 'post in stream', 'OK (#'.$post->ds['m_key'].')', 'fail'); $textData = HubbubMessage::unpackData($matchDS); tlog($matchDS7['text'] == $textData['text'], 'post in stream is valid', 'OK (#'.$post->ds['m_key'].')', 'fail'); $post->markChanged(time()+$ctr++); $post->executeHandler('delete'); tlog($post->data['deleted'] == 'yes', '"deleted" property set', 'OK', 'fail'); $mds = DB_GetDataset('messages', $post->ds['m_key']); $textData = HubbubMessage::unpackData($mds); tlog($mds['m_deleted'] == 'Y', 'm_deleted in DB', 'OK (#'.$mds['m_key'].')', 'fail'); tlog($textData['deleted'] == 'yes', 'deleted in record', 'OK (#'.$mds['m_key'].')', 'fail'); $streamPosts1 = $this->msg->getStream($ne2->key()); $wallPosts1 = $this->msg->getPostList($ne1->key()); $postFound9 = -1; $postFound10 = -1; foreach($streamPosts1['list'] as $pds) if($pds['m_id'] == $post->data['msgid']) $postFound9 = $pds['m_id']; tlog($postFound9 == -1, 'Message gone from author stream', 'OK', 'fail (#'.$postFound9.')'); foreach($wallPosts1['list'] as $pds) if($pds['m_id'] == $post->data['msgid']) $postFound10 = $pds['m_id']; tlog($postFound10 == -1, 'Message gone from owner profile', 'OK', 'fail ('.$postFound10.')'); $post = new HubbubMessage('post'); $post->localUserEntity = $ne2->key();
function tmpl_commentlist($postDS, &$comments, $withContainer = false) { if($withContainer) print('<div class="comment_list" id="comments_'.$postDS['m_key'].'">'); if($comments['count'] > 3 && sizeof($comments['list'])==3) { ?><div class="comment_item smalltext"> <a onclick="loadThread(<?php echo $postDS['m_key']; ?> )">▼ Show entire conversation</a> (<?php echo $comments['count']; ?> )</div><? } if(sizeof($comments['votes']) > 0) { foreach($comments['votes'] as $voteDS) { $vData = HubbubMessage::unpackData($voteDS); ?><div class="comment_item smalltext"> <?php echo htmlspecialchars(substr($vData['text'], 1)); ?> (<?php echo $voteDS['votecount']; ?> )</div><? } } if(sizeof($comments['list'])) foreach($comments['list'] as $comment) { $data = HubbubMessage::unpackData($comment); $metaElements = array( ageToString($comment['m_created'])); if(object('user')->entity == $comment['m_owner'] || object('user')->entity == $comment['m_author']) $metaElements[] = '<a onclick="deleteComment('.$comment['m_key'].')">Delete</a>'; ?><div id="comment_item_<?php echo $comment['m_key']; ?> " class="comment_item comment_entry"> <div class="comment_img"><img src="img/anonymous.png" width="32"/></div> <div class="comment_text"><?php echo HubbubEntity::linkFromId($comment['m_author']); ?> <?php echo h2_post_excerpt($data['text'], $comment['m_key']); ?> <div class="comment_meta"><?php echo implode(' · ', $metaElements); ?> </div></div> </div><? } if($withContainer) { ?></div><? } }