function doaddcomment($uid, $post, $api = false)
 {
     $data['uid'] = $uid;
     $data['reply_comment_id'] = intval($post['reply_comment_id']);
     $data['weibo_id'] = intval($post['weibo_id']);
     $data['content'] = $post['content'];
     $data['ctime'] = time();
     $miniInfo = D('Weibo')->where('weibo_id=' . $data['weibo_id'])->find();
     if ($data['reply_comment_id']) {
         $replyInfo = $this->where('comment_id=' . $data['reply_comment_id'])->find();
         $data['reply_uid'] = $replyInfo['uid'];
     } else {
         $data['reply_uid'] = $miniInfo['uid'];
         $notify['reply_type'] = 'weibo';
     }
     if ($comment_id = $this->addcomment($data)) {
         //微博回复积分操作
         if ($data['uid'] != $data['reply_uid']) {
             X('Credit')->setUserCredit($data['uid'], 'reply_weibo')->setUserCredit($data['reply_uid'], 'replied_weibo');
         }
         $data['comment'] = $miniInfo['comment'] + 1;
         $return['data'] = $data;
         $return['html'] = '<div class="position_list" id="comment_list_c_' . $comment_id . '"> <a href="' . U('home/space/index', array('uid' => $this->mid)) . '" class="pic">
         		<img class="pic30" src="' . getUserFace($uid, 's') . '" /></a>
                   <p class="list_c"><a href="#">' . getUserName($uid) . '</a> ' . getUserGroupIcon($uid) . ' : ' . formatComment($data['content'], true) . ' (刚刚)</p>
                   <div class="alR clear"><a href="javascript:void(0)" onclick="ui.confirm(this,\'确认要删除此评论?\')" callback="delComment(' . $comment_id . ')">删除</a>&nbsp;&nbsp;<a href="javascript:void(0)" onclick="reply(\'' . getUserName($uid) . '\',' . $data['weibo_id'] . ')">回复</a></div>
                 </div>';
         if ($post['transpond'] != 0) {
             if ($miniInfo['transpond_id'] != 0) {
                 $transpondData['content'] = $data['content'] . " //@" . getUserName($miniInfo['uid']) . ":" . $miniInfo['content'];
                 $transpondData['transpond_id'] = $miniInfo['transpond_id'];
                 $transpondInfo = M('weibo')->where('weibo_id=' . $miniInfo['transpond_id'])->find();
                 $transpondData['transpond_uid'] = $transpondInfo['uid'];
             } else {
                 $transpondData['content'] = $data['content'];
                 $transpondData['transpond_id'] = $miniInfo['weibo_id'];
                 $transpondData['transpond_uid'] = $miniInfo['uid'];
             }
             $id = D('Weibo', 'weibo')->doSaveWeibo($uid, $transpondData, $post['from']);
             if ($id) {
                 //当转发的微博uid 与 回复人的uid不一致时发布@到我
                 if ($transpondData['transpond_uid'] != $data['reply_uid']) {
                     D('Weibo', 'weibo')->notifyToAtme($id, $transpondData['content'], $transpondData['transpond_uid']);
                 } else {
                     D('Weibo', 'weibo')->notifyToAtme($id, $transpondData['content'], $transpondData['transpond_uid'], false);
                 }
             }
         }
         //添加统计
         Model('UserCount')->addCount($data['reply_uid'], 'comment');
         if ($api) {
             return true;
         } else {
             return json_encode($return);
         }
     } else {
         return '0';
     }
 }
Beispiel #2
0
        echo '<li id="comment-' . $comment->getID() . '">';
        echo formatUserPicture($comment->getCreatorID(), 'small');
        if ($hasPermission) {
            echo '<input class="replyButton" type="button" value="Reply" />';
        }
        echo '<p class="headline">' . formatUserLink($comment->getCreatorID(), $project->getID()) . ' <span class="slash">/</span> <span class="when">' . formatTimeTag($comment->getDateCreated()) . '</span></p>';
        echo '<p class="message">' . formatComment($comment->getMessage()) . '</p>';
        //echo '<p class="when">'.formatTimeTag($comment->getDateCreated()).'</p>';
        echo '</li>';
        $replies = $comment->getReplies();
        if ($replies != null) {
            foreach ($replies as $reply) {
                echo '<li class="comment-reply">';
                echo formatUserPicture($reply->getCreatorID(), 'small');
                echo '<p class="headline">' . formatUserLink($reply->getCreatorID(), $project->getID()) . ' <span class="slash">/</span> <span class="when">' . formatTimeTag($reply->getDateCreated()) . '</span></p>';
                echo '<p class="message">' . formatComment($reply->getMessage()) . '</p>';
                //echo '<p class="when">'.formatTimeTag($reply->getDateCreated()).'</p>';
                echo '</li>';
            }
        }
    }
} else {
    echo '<li>(none)</li>';
}
?>

<?php 
if ($hasPermission) {
    ?>

	<li class="comment">
Beispiel #3
0
function formatEventDetails($event)
{
    $details = '';
    switch ($event->getEventTypeID()) {
        case 'edit_update_uploads':
        case 'edit_task_uploads':
            $addedIDs = explode(',', $event->getData2());
            $added = '';
            foreach ($addedIDs as $a) {
                if ($a == '') {
                    continue;
                }
                // skip blanks
                $upload = Upload::load($a);
                $added .= $upload->getOriginalName() . ' (' . formatFileSize($upload->getSize()) . ')<br /><br />';
            }
            if (!empty($added)) {
                $details .= '<ins>' . $added . '</ins>';
            }
            $deletedIDs = explode(',', $event->getData1());
            $deleted = '';
            foreach ($deletedIDs as $d) {
                if ($d == '') {
                    continue;
                }
                // skip blanks
                $upload = Upload::load($d);
                $deleted .= $upload->getOriginalName() . ' (' . formatFileSize($upload->getSize()) . ')<br /><br />';
            }
            if (!empty($deleted)) {
                $details .= '<del>' . $deleted . '</del>';
            }
            break;
        case 'edit_pitch':
        case 'edit_specs':
        case 'edit_rules':
        case 'edit_task_description':
        case 'edit_update_message':
            $from = $event->getData1();
            $to = $event->getData2();
            $from = str_replace('&#10;', '<br />', $from);
            $to = str_replace('&#10;', '<br />', $to);
            $diff = new FineDiff($from, $to);
            $htmlDiff = $diff->renderDiffToHTML();
            $htmlDiff = html_entity_decode($htmlDiff, ENT_QUOTES, 'UTF-8');
            $htmlDiff = html_entity_decode($htmlDiff, ENT_QUOTES, 'UTF-8');
            $details .= $htmlDiff;
            break;
        case 'edit_task_title':
        case 'edit_update_title':
            $from = $event->getData1();
            $to = $event->getData2();
            $diff = new FineDiff($from, $to);
            $htmlDiff = $diff->renderDiffToHTML();
            $htmlDiff = html_entity_decode($htmlDiff, ENT_QUOTES, 'UTF-8');
            $htmlDiff = html_entity_decode($htmlDiff, ENT_QUOTES, 'UTF-8');
            $details .= $htmlDiff;
            break;
        case 'edit_task_leader':
            $details .= 'Old Leader: <del>' . formatUserLink($event->getUser1ID(), $event->getProjectID()) . '</del><br /><br />';
            $details .= 'New Leader: <ins>' . formatUserLink($event->getUser2ID(), $event->getProjectID()) . '</ins>';
            break;
        case 'edit_task_num_needed':
            $old = $event->getData1() != null ? $event->getData1() : '&#8734;';
            $new = $event->getData2() != null ? $event->getData2() : '&#8734;';
            $details .= 'Old: <del>' . $old . '</del> people needed<br /><br />';
            $details .= 'New: <ins>' . $new . '</ins> people needed';
            break;
        case 'edit_task_deadline':
        case 'edit_project_deadline':
            $old = $event->getData1() != null ? formatTimeTag($event->getData1()) : '(none)';
            $new = $event->getData2() != null ? formatTimeTag($event->getData2()) : '(none)';
            $details .= 'Old Deadline: <del>' . $old . '</del><br /><br />';
            $details .= 'New Deadline: <ins>' . $new . '</ins>';
            break;
        case 'edit_project_status':
            $old = formatProjectStatus($event->getData1());
            $new = formatProjectStatus($event->getData2());
            $details .= 'Old Project Status: <del>' . $old . '</del><br /><br />';
            $details .= 'New Project Status: <ins>' . $new . '</ins>';
            break;
        case 'edit_accepted_status':
            $old = formatAcceptedStatus($event->getData1());
            $new = formatAcceptedStatus($event->getData2());
            $details .= 'Old Status: <del>' . $old . '</del><br /><br />';
            $details .= 'New Status: <ins>' . $new . '</ins>';
            break;
        case 'create_task_comment':
        case 'create_task_comment_reply':
        case 'create_update_comment':
        case 'create_update_comment_reply':
            $details .= formatComment($event->getData1());
            break;
        case 'create_discussion':
            $details .= '<strong>' . $event->getData1() . '</strong><br /><br />';
            $details .= formatDiscussionReply($event->getData2());
            break;
        case 'create_discussion_reply':
            $details .= formatDiscussionReply($event->getData1());
            break;
        case 'create_update':
            if ($event->getData1() != '') {
                $details .= '<strong>' . $event->getData1() . '</strong><br /><br />';
            }
            if ($event->getData2() != '') {
                $details .= formatUpdate($event->getData2());
            }
            break;
        case 'create_task':
            if ($event->getData1() != '') {
                $details .= '<strong>' . $event->getData1() . '</strong><br /><br />';
            }
            if ($event->getData2() != '') {
                $details .= formatTaskDescription($event->getData2());
            }
            break;
    }
    return $details;
}
Beispiel #4
0
                $email = array('to' => $leader->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New comment reply on a task you are leading in ' . $project->getTitle(), 'message' => $body);
                // send email
                Email::send($email);
            }
        }
        // to task crew
        $crew = Accepted::getByTaskID($taskID);
        if ($crew != null) {
            foreach ($crew as $c) {
                $user = User::load($c->getCreatorID());
                if ($user->getID() != Session::getUserID()) {
                    // don't email yourself
                    if ($user->getNotifyCommentTaskAccepted()) {
                        // compose email
                        $body = "<p>" . formatUserLink(Session::getUserID()) . ' replied to a comment on the task <a href="' . Url::task($taskID) . '">' . $task->getTitle() . '</a> in the project ' . formatProjectLink($project->getID()) . '. The reply was:</p>';
                        $body .= "<blockquote>" . formatComment($message) . "</blockquote>";
                        $email = array('to' => $user->getEmail(), 'subject' => '[' . PIPELINE_NAME . '] New comment reply on a task you joined in ' . $project->getTitle(), 'message' => $body);
                        // send email
                        Email::send($email);
                    }
                }
            }
        }
        // send us back
        Session::setMessage('You replied to a comment on this task.');
        $json = array('success' => '1');
        echo json_encode($json);
    }
} else {
    $json = array('error' => 'Invalid action.');
    exit(json_encode($json));
Beispiel #5
0
 public function sendToWeibo()
 {
     $_REQUEST['with_new_weibo'] = intval($_REQUEST['with_new_weibo']);
     $_REQUEST['type'] = t($_REQUEST['type']);
     $_REQUEST['appid'] = intval($_REQUEST['appid']);
     $_REQUEST['comment'] = $_REQUEST['comment'];
     $_REQUEST['to_id'] = intval($_REQUEST['to_id']);
     $_REQUEST['author_uid'] = intval($_REQUEST['author_uid']);
     $_REQUEST['title'] = t(html_entity_decode($_REQUEST['title'], ENT_QUOTES));
     $_REQUEST['url'] = urldecode($_REQUEST['url']);
     $_REQUEST['table'] = t($_REQUEST['table']);
     $_REQUEST['id_field'] = t($_REQUEST['id_field']);
     $_REQUEST['comment_count_field'] = t($_REQUEST['comment_count_field']);
     $app_alias = getAppAlias($_REQUEST['type']);
     // 被回复内容
     $former_comment = array();
     if ($_REQUEST['to_id'] > 0) {
         $former_comment = M('comment')->where("`id`='{$_REQUEST['to_id']}'")->find();
     }
     // 插入新数据
     $map['type'] = $_REQUEST['type'];
     // 应用名
     $map['appid'] = $_REQUEST['appid'];
     $map['appuid'] = $_REQUEST['author_uid'];
     $map['uid'] = $this->mid;
     $map['comment'] = t(getShort($_REQUEST['comment'], $GLOBALS['ts']['site']['length']));
     $map['cTime'] = time();
     $map['toId'] = $_REQUEST['to_id'];
     $map['status'] = 0;
     // 0: 未读 1:已读
     $map['quietly'] = 0;
     $map['to_uid'] = $former_comment['uid'] ? $former_comment['uid'] : $_REQUEST['author_uid'];
     $map['data'] = serialize(array('title' => keyWordFilter($_REQUEST['title']), 'url' => $_REQUEST['url'], 'table' => $_REQUEST['table'], 'id_field' => $_REQUEST['id_field'], 'comment_count_field' => $_REQUEST['comment_count_field']));
     $res = M('comment')->add($map);
     // 避免命名冲突
     unset($map['data']);
     if ($res) {
         // 发表分享
         if ($_REQUEST['with_new_weibo']) {
             $from_data = array('app_type' => 'local_app', 'app_name' => $_REQUEST['type'], 'title' => $_REQUEST['title'], 'url' => $_REQUEST['url']);
             $from_data = serialize($from_data);
             D('Weibo', 'weibo')->publish($this->mid, array('content' => html_entity_decode($_REQUEST['comment'] . ($_REQUEST['to_id'] > 0 ? ' //@' . getUserName($former_comment['uid']) . ' :' . $former_comment['comment'] : ''), ENT_QUOTES)), 0, 0, '', '', $from_data);
         }
         // 组装结果集
         $result = $map;
         $result['data']['uavatar'] = getUserSpace($this->mid, 'null', '_blank', '{uavatar}');
         $result['data']['uspace'] = getUserSpace($this->mid, 'null', '_blank', '{uname}');
         //$result['data']['comment']        = $_REQUEST['comment'];
         $result['data']['ctime'] = L('just_now');
         $result['data']['uname'] = getUserName($this->mid);
         $result['data']['comment'] = formatComment(t($_REQUEST['comment']));
         $result['data']['id'] = $res;
         $result['data']['userGroupIcon'] = getUserGroupIcon($this->mid);
         $result['data']['del_state'] = 1;
         return json_encode($result);
     } else {
         echo -1;
     }
 }
Beispiel #6
0
            <section class="comments">
                <h2 class="section-heading">Comments</h2>
                
                <ul>
                <?php 
        foreach ($comments as $comment) {
            $date = new DateTime($comment->submitted_at, new DateTimeZone('UTC'));
            echo '<li>';
            echo '    <blockquote class="respondent">
                            ' . formatComment($comment->comment) . '
                            <time datetime="' . $date->format('Y-m-d') . '">' . $date->format('d M Y') . '</time>
                        </blockquote>';
            if (isset($comment->reply) && !empty($comment->reply)) {
                echo '    <blockquote class="reply">';
                echo '        <h3>Our reply</h3>
                            ' . formatComment($comment->reply) . '
                        </blockquote>';
            }
            echo '</li>';
        }
        ?>
                </ul>
            </section>
            <?php 
    }
    ?>

            <?php 
    if (isset($improvements) && count($improvements)) {
        ?>
            <section class="improvements">
 public function doAddComment()
 {
     $_POST['with_new_weibo'] = intval($_POST['with_new_weibo']);
     $_POST['type'] = t($_POST['type']);
     $_POST['appid'] = intval($_POST['appid']);
     $_POST['comment'] = $_POST['comment'];
     $_POST['to_id'] = intval($_POST['to_id']);
     $_POST['author_uid'] = intval($_POST['author_uid']);
     $_POST['title'] = t(html_entity_decode($_POST['title'], ENT_QUOTES));
     $_POST['url'] = urldecode($_POST['url']);
     $_POST['table'] = t($_POST['table']);
     $_POST['id_field'] = t($_POST['id_field']);
     $_POST['comment_count_field'] = t($_POST['comment_count_field']);
     $app_alias = getAppAlias($_POST['type']);
     // 被回复内容
     $former_comment = array();
     if ($_POST['to_id'] > 0) {
         $former_comment = M('comment')->where("`id`='{$_POST['to_id']}'")->find();
     }
     // 插入新数据
     $map['type'] = $_POST['type'];
     // 应用名
     $map['appid'] = $_POST['appid'];
     $map['appuid'] = $_POST['author_uid'];
     $map['uid'] = $this->mid;
     $map['comment'] = t(getShort($_POST['comment'], $GLOBALS['ts']['site']['length']));
     $map['cTime'] = time();
     $map['toId'] = $_POST['to_id'];
     $map['status'] = 0;
     // 0: 未读 1:已读
     $map['quietly'] = 0;
     $map['to_uid'] = $former_comment['uid'] ? $former_comment['uid'] : $_POST['author_uid'];
     $map['data'] = serialize(array('title' => $_POST['title'], 'url' => $_POST['url'], 'table' => $_POST['table'], 'id_field' => $_POST['id_field'], 'comment_count_field' => $_POST['comment_count_field']));
     $res = M('comment')->add($map);
     // 避免命名冲突
     unset($map['data']);
     if ($res) {
         // 应用回调: 增加应用的评论计数
         $this->__doAddCallBack($_POST['appid'], $_POST['table'], $_POST['id_field'], $_POST['comment_count_field']);
         //积分处理
         $setCredit = X('Credit');
         if ($map['toId'] > 0 && $this->mid != $map['to_uid']) {
             $setCredit->setUserCredit($this->mid, 'reply_comment')->setUserCredit($map['to_uid'], 'replied_comment');
         } else {
             if ($this->mid != $map['to_uid']) {
                 $setCredit->setUserCredit($this->mid, 'add_comment')->setUserCredit($map['to_uid'], 'is_commented');
             }
         }
         // 发表微博
         if ($_POST['with_new_weibo']) {
             $from_data = array('app_type' => 'local_app', 'app_name' => $_POST['type'], 'title' => $_POST['title'], 'url' => $_POST['url']);
             $from_data = serialize($from_data);
             D('Weibo', 'weibo')->publish($this->mid, array('content' => html_entity_decode($_POST['comment'] . ($_POST['to_id'] > 0 ? ' //@' . getUserName($former_comment['uid']) . ' :' . $former_comment['comment'] : ''), ENT_QUOTES)), 0, 0, '', '', $from_data);
         }
         /*        		
         	        	// 给被回复人发送通知
         				if ($former_comment['uid']) {
         					$data = array(
         						'app_alias'	=> $app_alias,
         						'url'		=> $_POST['url'],
         						'title'		=> $_POST['title'],
         						'content'	=> $_POST['comment'],
         						'my_content'=> $former_comment['comment'],
         					);
         					service('Notify')->send($former_comment['uid'], 'home_replyComment', $data, $this->mid);
         					unset($data);
         				}
         				// 给作者发送通知 ( 当被回复人和作者为同一人时, 只发一个通知. 优先被回复. )
         				if ($_POST['author_uid'] > 0 && $_POST['author_uid'] != $former_comment['uid']) {
         					$data = array(
         						'app_alias'	=> $app_alias,
         						'url'		=> $_POST['url'],
         						'title'		=> $_POST['title'],
         						'content'	=> $_POST['comment'],
         					);
         					service('Notify')->send($_POST['author_uid'], 'home_addComment', $data, $this->mid);
         					unset($data);
         				}
         */
         // 组装结果集
         $result = $map;
         $result['data']['uavatar'] = getUserSpace($this->mid, 'null', '_blank', '{uavatar}');
         $result['data']['uspace'] = getUserSpace($this->mid, 'null', '_blank', '{uname}');
         //$result['data']['comment']  		= $_POST['comment'];
         $result['data']['ctime'] = L('just_now');
         $result['data']['uname'] = getUserName($this->mid);
         $result['data']['comment'] = formatComment(t($_POST['comment']));
         $result['data']['id'] = $res;
         $result['data']['userGroupIcon'] = getUserGroupIcon($this->mid);
         $result['data']['del_state'] = 1;
         echo json_encode($result);
     } else {
         echo -1;
     }
 }