本文整理汇总了PHP中getVisitorClient函数的典型用法代码示例。如果您正苦于以下问题:PHP getVisitorClient函数的具体用法?PHP getVisitorClient怎么用?PHP getVisitorClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getVisitorClient函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _updateToComment
function _updateToComment($data, $sourceInfo, $lessUids)
{
$commentInfo = model('Source')->getSourceInfo($data['app_row_table'], $data['app_row_id'], false, $data['app']);
$oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
// 发表评论
$c['app'] = $data['app'];
$c['table'] = 'feed';
// 2013/3/27
$c['app_uid'] = !empty($oldInfo['source_user_info']['uid']) ? $oldInfo['source_user_info']['uid'] : $oldInfo['uid'];
$c['content'] = $data['content'];
$c['row_id'] = !empty($oldInfo['sourceInfo']) ? $oldInfo['sourceInfo']['source_id'] : $oldInfo['source_id'];
if ($data['app']) {
$c['row_id'] = $oldInfo['feed_id'];
}
$c['client_type'] = getVisitorClient();
model('Comment')->addComment($c, false, false, $lessUids);
}
示例2: saveInfo
private function saveInfo($upload_info, $options)
{
$data = array('table' => t($data['table']), 'row_id' => t($data['row_id']), 'app_name' => t($data['app_name']), 'attach_type' => t($options['attach_type']), 'uid' => (int) $data['uid'] ? $data['uid'] : $GLOBALS['ts']['mid'], 'ctime' => time(), 'private' => $data['private'] > 0 ? 1 : 0, 'is_del' => 0, 'from' => isset($data['from']) ? intval($data['from']) : getVisitorClient());
if ($options['save_to_db']) {
foreach ($upload_info as $u) {
$name = t($u['name']);
$data['name'] = $name ? $name : $u['savename'];
$data['type'] = $u['type'];
$data['size'] = $u['size'];
$data['extension'] = strtolower($u['extension']);
$data['hash'] = $u['hash'];
$data['save_path'] = $options['custom_path'];
$data['save_name'] = $u['savename'];
if (in_array($data['extension'], array('jpg', 'gif', 'png', 'jpeg', 'bmp')) && !in_array($options['attach_type'], array('feed_file', 'weiba_attach'))) {
list($width, $height) = getImageInfo($data['save_path'] . $data['save_name']);
$data['width'] = $width;
$data['height'] = $height;
} else {
$data['width'] = 0;
$data['height'] = 0;
}
$aid = $this->add($data);
$data['attach_id'] = intval($aid);
$data['key'] = $u['key'];
$data['size'] = byte_format($data['size']);
$infos[] = $data;
}
} else {
foreach ($upload_info as $u) {
$name = t($u['name']);
$data['name'] = $name ? $name : $u['savename'];
$data['type'] = $u['type'];
$data['size'] = byte_format($u['size']);
$data['extension'] = strtolower($u['extension']);
$data['hash'] = $u['hash'];
$data['save_path'] = $options['custom_path'];
$data['save_name'] = $u['savename'];
//$data['save_domain'] = C('ATTACH_SAVE_DOMAIN'); //如果做分布式存储,需要写方法来分配附件的服务器domain
$data['key'] = $u['key'];
$infos[] = $data;
}
}
return $infos;
}
示例3: _escapeData
/**
* 检测数据安全性
* @param array $data 待检测的数据
* @return array 验证后的数据
*/
private function _escapeData($data)
{
$add['type'] = !$data['type'] ? 1 : $data['type'];
$add['app'] = !$data['app'] ? $this->_app : $data['app'];
$add['table'] = !$data['table'] ? $this->_app_table : $data['table'];
$add['row_id'] = intval($data['row_id']);
$add['app_uid'] = intval($data['app_uid']);
$add['uid'] = $GLOBALS['ts']['mid'];
$add['content'] = preg_html($data['content']);
$add['to_comment_id'] = intval($data['to_comment_id']);
$add['to_uid'] = intval($data['to_uid']);
$add['data'] = serialize($data['data']);
$add['ctime'] = $_SERVER['REQUEST_TIME'];
$add['client_type'] = isset($data['client_type']) ? intval($data['client_type']) : getVisitorClient();
$add['app_detail_summary'] = t($data['app_detail_summary']);
$add['app_detail_url'] = $data['app_detail_url'];
return $add;
}
示例4: addcomment
//.........这里部分代码省略.........
$return['data'] = '内容已被删除,评论失败';
exit(json_encode($return));
}
// 添加评论操作
if ($data['comment_id'] = D('GroupComment')->addComment($data)) {
// 同步到微吧
if ($data['app'] == 'weiba') {
$postDetail = D('weiba_post')->where('feed_id=' . $data['row_id'])->find();
if ($postDetail) {
$datas['weiba_id'] = $postDetail['weiba_id'];
$datas['post_id'] = $postDetail['post_id'];
$datas['post_uid'] = $postDetail['post_uid'];
$datas['to_reply_id'] = $data['to_comment_id'] ? D('weiba_reply')->where('comment_id=' . $data['to_comment_id'])->getField('reply_id') : 0;
$datas['to_uid'] = $data['to_uid'];
$datas['uid'] = $this->mid;
$datas['ctime'] = time();
$datas['content'] = $data['content'];
$datas['comment_id'] = $data['comment_id'];
$datas['storey'] = D('GroupComment')->where('comment_id=' . $data['comment_id'])->getField('storey');
if (D('weiba_reply')->add($datas)) {
$map['last_reply_uid'] = $this->mid;
$map['last_reply_time'] = $datas['ctime'];
D('weiba_post')->where('post_id=' . $datas['post_id'])->save($map);
// 回复统计数加1
D('weiba_post')->where('post_id=' . $datas['post_id'])->setInc('reply_count');
}
}
}
$return['status'] = 1;
$return['data'] = $this->parseComment($data);
$oldInfo = model('Source')->getSourceInfo($data['table'], !empty($data['app_row_id']) ? $data['app_row_id'] : $data['row_id'], false, $data['app']);
// 转发到我的分享
if ($_POST['ifShareFeed'] == 1) {
$commentInfo = model('Source')->getSourceInfo($data['table'], $data['row_id'], false, $data['app']);
$oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
// 根据评论的对象获取原来的内容
$s['sid'] = $oldInfo['source_id'];
$s['app_name'] = $oldInfo['app'];
if ($commentInfo['feedType'] == 'post' || $commentInfo['feedType'] == 'postimage' || $commentInfo['feedType'] == 'postfile' || $commentInfo['feedType'] == 'postvideo' || $commentInfo['feedType'] == 'weiba_post') {
//加入微吧类型,2012/11/15
if (empty($data['to_comment_id'])) {
$s['body'] = $data['content'];
} else {
$replyInfo = D('GroupComment')->setAppName($data['app'])->setAppTable($data['table'])->getCommentInfo(intval($data['to_comment_id']), false);
$replyScream = '//@' . $replyInfo['user_info']['uname'] . ' :';
$s['body'] = $data['content'] . $replyScream . $replyInfo['content'];
}
} else {
$scream = '//@' . $commentInfo['source_user_info']['uname'] . ':' . $commentInfo['source_content'];
if (empty($data['to_comment_id'])) {
$s['body'] = $data['content'] . $scream;
} else {
$replyInfo = D('GroupComment')->setAppName($data['app'])->setAppTable($data['table'])->getCommentInfo(intval($data['to_comment_id']), false);
$replyScream = '//@' . $replyInfo['user_info']['uname'] . ' :';
$s['body'] = $data['content'] . $replyScream . $replyInfo['content'] . $scream;
}
}
$s['type'] = $oldInfo['source_table'];
$s['comment'] = $data['comment_old'];
$s['comment_touid'] = $data['app_uid'];
$s['gid'] = $data['gid'];
// 去掉回复用户@
$lessUids = array();
if (!empty($data['to_uid'])) {
$lessUids[] = $data['to_uid'];
}
// 如果为原创分享,不给原创用户发送@信息
if ($commentInfo['feedType'] == 'post' && empty($data['to_uid'])) {
$lessUids[] = $oldInfo['uid'];
}
D('GroupShare')->shareFeed($s, 'comment', $lessUids);
} else {
//是否评论给原来作者
if ($data['comment_old'] != 0) {
$commentInfo = model('Source')->getSourceInfo($data['app_row_table'], $data['app_row_id'], false, $data['app']);
$oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
//发表评论
$c['app'] = $data['app'];
//$c['table'] = $oldInfo['source_table'];
$c['table'] = 'group_feed';
//2013/3/27
$c['app_uid'] = !empty($oldInfo['source_user_info']['uid']) ? $oldInfo['source_user_info']['uid'] : $oldInfo['uid'];
$c['content'] = $data['content'];
$c['row_id'] = !empty($oldInfo['sourceInfo']) ? $oldInfo['sourceInfo']['source_id'] : $oldInfo['source_id'];
if ($data['app']) {
$c['row_id'] = $oldInfo['feed_id'];
}
$c['gid'] = $data['gid'];
$c['client_type'] = getVisitorClient();
// 去掉回复用户@
$lessUids = array();
if (!empty($data['to_uid'])) {
$lessUids[] = $data['to_uid'];
}
D('GroupComment')->addComment($c, false, false, $lessUids);
}
}
}
exit(json_encode($return));
}
示例5: put
/**
* 添加分享
* @param integer $uid 操作用户ID
* @param string $app 分享应用类型,默认为public
* @param string $type 分享类型,
* @param array $data 分享相关数据
* @param integer $app_id 应用资源ID,默认为0
* @param string $app_table 应用资源表名,默认为feed
* @param array $extUid 额外用户ID,默认为null
* @param array $lessUids 去除的用户ID,默认为null
* @param boolean $isAtMe 是否为进行发送,默认为true
* @return mix 添加失败返回false,成功返回新的分享ID
*/
public function put($uid, $app = 'group', $type = '', $data = array(), $app_id = 0, $app_table = 'group_feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
{
// 判断数据的正确性
if (!$uid || $type == '') {
return false;
}
if (strpos($type, 'postvideo') !== false) {
$type = 'postvideo';
}
//分享类型合法性验证 - 临时解决方案
if (!in_array($type, array('post', 'repost', 'postvideo', 'postfile', 'postimage'))) {
$type = 'post';
}
// //应用类型验证 用于分享框 - 临时解决方案
// if ( !in_array( $app , array('public','weiba','tipoff') ) ){
// $app = 'public';
// $type = 'post';
// $app_table = 'feed';
// }
$app_table = strtolower($app_table);
// 添加feed表记录
$data['gid'] = $data['gid'];
$data['uid'] = $uid;
$data['app'] = $app;
$data['type'] = $type;
$data['app_row_id'] = $app_id;
$data['app_row_table'] = $app_table;
$data['publish_time'] = time();
$data['from'] = isset($data['from']) ? intval($data['from']) : getVisitorClient();
$data['is_del'] = $data['comment_count'] = $data['repost_count'] = 0;
$data['is_repost'] = $is_repost;
//判断是否先审后发
// $weiboSet = model('Xdata')->get('admin_Config:feed');
// $weibo_premission = $weiboSet['weibo_premission'];
// if(in_array('audit',$weibo_premission) || CheckPermission('core_normal','feed_audit')){
// $data['is_audit'] = 0;
// }else{
$data['is_audit'] = 1;
// }
// 分享内容处理
if (Addons::requireHooks('weibo_publish_content')) {
Addons::hook("weibo_publish_content", array(&$data));
} else {
// 拼装数据,如果是评论再转发、回复评论等情况,需要额外叠加对话数据
$data['body'] = str_replace(SITE_URL, '[SITE_URL]', preg_html($data['body']));
// 获取用户发送的内容,仅仅以//进行分割
$scream = explode('//', $data['body']);
// 截取内容信息为分享内容字数 - 重点
$feedConf = model('Xdata')->get('admin_Config:feed');
$feedNums = $feedConf['weibo_nums'];
$body = array();
foreach ($scream as $value) {
$tbody[] = $value;
$bodyStr = implode('//', $tbody);
if (get_str_length($bodyStr) > $feedNums) {
break;
}
$body[] = $value;
unset($bodyStr);
}
$data['body'] = implode('//', $body);
// 获取用户发布内容
$data['content'] = trim($scream[0]);
}
//分享到分享的应用资源,加入原资源链接
$data['body'] .= $data['source_url'];
$data['content'] .= $data['source_url'];
// 分享类型插件钩子
// if($type){
// $addonsData = array();
// Addons::hook("weibo_type",array("typeId"=>$type,"typeData"=>$type_data,"result"=>&$addonsData));
// $data = array_merge($data,$addonsData);
// }
if ($type == 'postvideo') {
$typedata = model('Video')->_weiboTypePublish($_POST['videourl']);
if ($typedata && $typedata['flashvar'] && $typedata['flashimg']) {
$data = array_merge($data, $typedata);
} else {
$data['type'] = 'post';
}
}
// 添加分享信息
$feed_id = $this->data($data)->add();
if (!$feed_id) {
return false;
}
// if(!$data['is_audit']){
//.........这里部分代码省略.........
示例6: addReplyToCommentForApi
/**
* 添加评论回复forApi
* @param int reply_id 评论ID
* @param int content 回复内容
* @param int uid 回复者UID
* @return bool 是否回复成功
*/
public function addReplyToCommentForApi($reply_id, $content, $uid)
{
$reply_detail = $this->where('reply_id=' . $reply_id)->find();
$data['weiba_id'] = intval($reply_detail['weiba_id']);
$data['post_id'] = intval($reply_detail['post_id']);
$data['post_uid'] = intval($reply_detail['post_uid']);
$data['to_reply_id'] = $reply_id;
$data['to_uid'] = intval($reply_detail['uid']);
$data['uid'] = $uid;
$data['ctime'] = time();
$data['content'] = preg_html(h($content));
if ($data['reply_id'] = D('weiba_reply')->add($data)) {
$map['last_reply_uid'] = $data['uid'];
$map['last_reply_time'] = $data['ctime'];
D('weiba_post')->where('post_id=' . $data['post_id'])->save($map);
D('weiba_post')->where('post_id=' . $data['post_id'])->setInc('reply_count');
//回复统计数加1
//同步到分享评论
//$feed_id = intval($_POST['feed_id']);
$datas['app'] = 'weiba';
$datas['table'] = 'feed';
$datas['row_id'] = D('weiba_post')->where('post_id=' . $data['post_id'])->getField('feed_id');
$datas['app_uid'] = intval($data['post_uid']);
$datas['to_comment_id'] = intval($reply_detail['comment_id']);
$datas['to_uid'] = $data['to_uid'];
$datas['uid'] = $data['uid'];
$datas['content'] = preg_html($data['content']);
$datas['ctime'] = $data['ctime'];
$datas['client_type'] = getVisitorClient();
if ($comment_id = D('comment')->add($datas)) {
D('weiba_reply')->where('reply_id=' . $data['reply_id'])->setField('comment_id', $comment_id);
// 被评论内容的“评论统计数”加1,同时可检测出app,table,row_id的有效性
D('feed')->where('feed_id=' . $datas['row_id'])->setInc('comment_count');
// 给应用UID添加一个未读的评论数
if ($GLOBALS['ts']['mid'] != $datas['app_uid'] && $datas['app_uid'] != '') {
!$notCount && model('UserData')->updateKey('unread_comment', 1, true, $datas['app_uid']);
}
model('Feed')->cleanCache($datas['row_id']);
}
return true;
} else {
return false;
}
}
示例7: shareFeed
/**
* 分享到微博
* @example
* 需要传入的$data值
* sid:转发的微博/资源ID
* app_name:app名称
* content:转发时的内容信息,有时候会有某些标题的资源
* body:转发时,自定义写入的内容
* type:微博类型
* comment:是否给原作者评论
* @param array $data 分享的相关数据
* @param string $from 是否发@给资源作者,默认为share
* @param array $lessUids 去掉@用户,默认为null
* @return array 分享操作后,相关反馈信息数据
*/
public function shareFeed($data, $from = 'share', $lessUids = null)
{
// 返回的数据结果集
$return = array('status' => 0, 'data' => L('PUBLIC_SHARE_FAILED'));
// 分享失败
// 验证数据正确性
if (empty($data['sid'])) {
return $return;
}
// type是资源所在的表名
$type = t($data['type']);
// 当前产生微博所属的应用
$app = isset($data['app_name']) ? $data['app_name'] : APP_NAME;
// 是否为接口形式
$forApi = $data['forApi'] ? true : false;
if (!($oldInfo = model('Source')->getSourceInfo($type, $data['sid'], $forApi, $data['app_name']))) {
$return['data'] = L('PUBLIC_INFO_SHARE_FORBIDDEN');
// 此信息不可以被分享
return $return;
}
$d['gid'] = $data['gid'];
// 内容数据
$d['content'] = isset($data['content']) ? str_replace(SITE_URL, '[SITE_URL]', $data['content']) : '';
$d['body'] = str_replace(SITE_URL, '[SITE_URL]', $data['body']);
$feedType = 'repost';
// 默认为普通的转发格式
if (!empty($oldInfo['feedtype']) && !in_array($oldInfo['feedtype'], array('post', 'postimage', 'postfile'))) {
$feedType = $oldInfo['feedtype'];
}
$d['sourceInfo'] = !empty($oldInfo['sourceInfo']) ? $oldInfo['sourceInfo'] : $oldInfo;
// 是否发送@上级节点
$isOther = $from == 'comment' ? false : true;
// 获取上个节点资源ID
$d['curid'] = $data['curid'];
// 获取转发原微博信息
if ($oldInfo['app_row_id'] == 0) {
$appId = $oldInfo['source_id'];
$appTable = $oldInfo['source_table'];
} else {
$appId = $oldInfo['app_row_id'];
$appTable = $oldInfo['app_row_table'];
}
$d['from'] = isset($data['from']) ? intval($data['from']) : 0;
if ($res = D('GroupFeed')->put($GLOBALS['ts']['mid'], $app, $feedType, $d, $appId, $appTable, null, $lessUids, $isOther, 1)) {
if ($data['comment'] != 0 && $oldInfo['uid'] != $data['comment_touid']) {
// 发表评论
$c['app'] = $app;
$c['table'] = $appTable;
$c['app_uid'] = $oldInfo['uid'];
$c['content'] = !empty($d['body']) ? $d['body'] : $d['content'];
$c['row_id'] = !empty($oldInfo['sourceInfo']) ? $oldInfo['sourceInfo']['source_id'] : $appId;
$c['client_type'] = getVisitorClient();
$c['gid'] = $d['gid'];
$notCount = $from == "share" ? true : false;
$comment_id = D('GroupComment')->addComment($c, false, $notCount, $lessUids);
}
//添加话题
//model('FeedTopic')->addTopic(html_entity_decode($d['body'], ENT_QUOTES, 'UTF-8'), $res['feed_id'], $feedType);
// 渲染数据
$rdata = $res;
// 渲染完后的结果
$rdata['feed_id'] = $res['feed_id'];
$rdata['app_row_id'] = $data['sid'];
$rdata['app_row_table'] = $data['type'];
$rdata['app'] = $app;
$rdata['is_repost'] = 1;
switch ($app) {
case 'weiba':
$rdata['from'] = getFromClient(0, $app, '微吧');
break;
default:
$rdata['from'] = getFromClient($from, $app);
break;
}
$return['data'] = $rdata;
$return['status'] = 1;
// 被分享内容“分享统计”数+1,同时可检测出app,table,row_id 的有效性
if (!($pk = D($data['type'], $data['app_name'])->getPk())) {
$pk = $data['type'] . '_id';
}
D('GroupFeed')->setInc('repost_count', "`feed_id`={$data['sid']}", 1);
if ($data['curid'] != $data['sid'] && !empty($data['curid'])) {
// if(!$pk = D($data['curtable'])->getPk()) {
// $pk = $data['curtable'].'_id';
// }
//.........这里部分代码省略.........
示例8: addReply
/**
* 添加帖子回复的操作
* @return array 评论添加状态和提示信息
*/
public function addReply()
{
// echo $_POST['post_id'];exit;
if (!$this->mid || !CheckPermission('weiba_normal', 'weiba_reply')) {
return;
}
$return = array('status' => 0, 'data' => L('PUBLIC_CONCENT_IS_ERROR'));
$data['weiba_id'] = intval($_POST['weiba_id']);
$data['post_id'] = intval($_POST['post_id']);
$data['post_uid'] = intval($_POST['post_uid']);
$data['to_reply_id'] = intval($_POST['to_reply_id']);
$data['to_uid'] = intval($_POST['to_uid']);
$data['uid'] = $this->mid;
$data['ctime'] = time();
$data['content'] = preg_html(h($_POST['content']));
if ($data['reply_id'] = D('weiba_reply')->add($data)) {
//添加积分
model('Credit')->setUserCredit($this->mid, 'comment_topic');
model('Credit')->setUserCredit($data['post_uid'], 'commented_topic');
$map['last_reply_uid'] = $this->mid;
$map['last_reply_time'] = $data['ctime'];
D('weiba_post')->where('post_id=' . $data['post_id'])->save($map);
D('weiba_post')->where('post_id=' . $data['post_id'])->setInc('reply_count');
//回复统计数加1
D('weiba_post')->where('post_id=' . $data['post_id'])->setInc('reply_all_count');
//总回复统计数加1
//同步到微博评论
//$feed_id = intval($_POST['feed_id']);
$datas['app'] = 'weiba';
$datas['table'] = 'feed';
$datas['content'] = preg_html($data['content']);
$datas['app_uid'] = intval($_POST['post_uid']);
$datas['row_id'] = intval($_POST['feed_id']);
$datas['to_comment_id'] = $data['to_reply_id'] ? D('weiba_reply')->where('reply_id=' . $data['to_reply_id'])->getField('comment_id') : 0;
$datas['to_uid'] = intval($_POST['to_uid']);
$datas['uid'] = $this->mid;
$datas['ctime'] = time();
$datas['client_type'] = getVisitorClient();
if ($comment_id = model('Comment')->addComment($datas)) {
$data1['comment_id'] = $comment_id;
$data1['storey'] = model('Comment')->where('comment_id=' . $comment_id)->getField('storey');
D('weiba_reply')->where('reply_id=' . $data['reply_id'])->save($data1);
// 给应用UID添加一个未读的评论数
if ($GLOBALS['ts']['mid'] != $datas['app_uid'] && $datas['app_uid'] != '') {
!$notCount && model('UserData')->updateKey('unread_comment', 1, true, $datas['app_uid']);
}
model('Feed')->cleanCache($datas['row_id']);
}
//转发到我的微博
if ($_POST['ifShareFeed'] == 1) {
$commentInfo = model('Source')->getSourceInfo($datas['table'], $datas['row_id'], false, $datas['app']);
$oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
// 根据评论的对象获取原来的内容
$s['sid'] = $data['post_id'];
$s['app_name'] = 'weiba';
if ($commentInfo['feedtype'] == 'post' && $commentInfo['feedtype'] == 'weiba_post') {
//加入微吧类型,2012/11/15
if (empty($data['to_comment_id'])) {
$s['body'] = $data['content'];
} else {
$replyInfo = model('Comment')->setAppName($data['app'])->setAppTable($data['table'])->getCommentInfo(intval($data['to_comment_id']), false);
//$replyScream = '//@'.$replyInfo['user_info']['uname'].' :';
$s['body'] = $data['content'] . $replyScream . $replyInfo['content'];
}
} else {
//$scream = '//@'.$commentInfo['source_user_info']['uname'].':'.$commentInfo['source_content'];
if (empty($data['to_comment_id'])) {
$s['body'] = $data['content'] . $scream;
} else {
$replyInfo = model('Comment')->setAppName($data['app'])->setAppTable($data['table'])->getCommentInfo(intval($data['to_comment_id']), false);
//$replyScream = '//@'.$replyInfo['user_info']['uname'].' :';
$s['body'] = $data['content'] . $replyScream . $replyInfo['content'] . $scream;
}
}
$s['type'] = 'weiba_post';
$s['comment'] = $data['comment_old'];
// 去掉回复用户@
$lessUids = array();
if (!empty($data['to_uid'])) {
$lessUids[] = $data['to_uid'];
}
// 如果为原创微博,不给原创用户发送@信息
if ($oldInfo['feedtype'] == 'post' && empty($data['to_uid'])) {
$lessUids[] = $oldInfo['uid'];
}
model('Share')->shareFeed($s, 'comment', $lessUids);
}
$data['feed_id'] = $datas['row_id'];
$data['comment_id'] = $comment_id;
$data['storey'] = $data1['storey'];
$return['status'] = 1;
$return['data'] = $this->parseReply($data);
}
echo json_encode($return);
exit;
}
示例9: put
/**
* 添加微博
* @param integer $uid 操作用户ID
* @param string $app 微博应用类型,默认为public
* @param string $type 微博类型,
* @param array $data 微博相关数据
* @param integer $app_id 应用资源ID,默认为0
* @param string $app_table 应用资源表名,默认为feed
* @param array $extUid 额外用户ID,默认为null
* @param array $lessUids 去除的用户ID,默认为null
* @param boolean $isAtMe 是否为进行发送,默认为true
* @return mix 添加失败返回false,成功返回新的微博ID
*/
public function put($uid, $app = 'public', $type = '', $data = array(), $app_id = 0, $app_table = 'feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
{
if (isSubmitLocked()) {
$this->error = '发布内容过于频繁,请稍后再试';
return false;
}
// 判断数据的正确性
if (!$uid || $type == '') {
$this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
return false;
}
if (strpos($type, 'postvideo') !== false) {
$type = 'postvideo';
}
//微博类型合法性验证 - 临时解决方案
if (!in_array($type, array('post', 'repost', 'postvideo', 'postfile', 'postimage', 'weiba_post', 'weiba_repost'))) {
$type = 'post';
}
//应用类型验证 用于分享框 - 临时解决方案
if (!in_array($app, array('w3g', 'public', 'weiba', 'tipoff'))) {
$app = 'public';
$type = 'post';
$app_table = 'feed';
}
$app_table = strtolower($app_table);
// 添加feed表记录
$data['uid'] = $uid;
$data['app'] = $app;
$data['type'] = $type;
$data['app_row_id'] = $app_id;
$data['app_row_table'] = $app_table;
$data['publish_time'] = time();
$data['from'] = isset($data['from']) ? intval($data['from']) : getVisitorClient();
$data['is_del'] = $data['comment_count'] = $data['repost_count'] = 0;
$data['is_repost'] = $is_repost;
//判断是否先审后发
$weiboSet = model('Xdata')->get('admin_Config:feed');
$weibo_premission = $weiboSet['weibo_premission'];
if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit')) {
$data['is_audit'] = 0;
} else {
$data['is_audit'] = 1;
}
// 微博内容处理
if (Addons::requireHooks('weibo_publish_content')) {
Addons::hook("weibo_publish_content", array(&$data));
} else {
$content = $this->formatFeedContent($data['body']);
$data['body'] = $content['body'];
$data['content'] = $content['content'];
}
//分享到微博的应用资源,加入原资源链接
$data['body'] .= $data['source_url'];
$data['content'] .= $data['source_url'];
// 微博类型插件钩子
// if($type){
// $addonsData = array();
// Addons::hook("weibo_type",array("typeId"=>$type,"typeData"=>$type_data,"result"=>&$addonsData));
// $data = array_merge($data,$addonsData);
// }
if ($type == 'postvideo') {
$typedata = model('Video')->_weiboTypePublish($_POST['videourl']);
if ($typedata && $typedata['flashvar'] && $typedata['flashimg']) {
$data = array_merge($data, $typedata);
} else {
$data['type'] = 'post';
}
}
// 添加微博信息
$feed_id = $this->data($data)->add();
if (!$feed_id) {
return false;
}
if (!$data['is_audit']) {
$touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll();
foreach ($touid as $k => $v) {
model('Notify')->sendNotify($v['uid'], 'feed_audit');
}
}
// 目前处理方案格式化数据
$data['content'] = str_replace(chr(31), '', $data['content']);
$data['body'] = str_replace(chr(31), '', $data['body']);
// 添加关联数据
$feed_data = D('FeedData')->data(array('feed_id' => $feed_id, 'feed_data' => serialize($data), 'client_ip' => get_client_ip(), 'feed_content' => $data['body']))->add();
// 添加微博成功后
if ($feed_id && $feed_data) {
//锁定发布
//.........这里部分代码省略.........
示例10: put
/**
* 添加分享
* @param integer $uid 操作用户ID
* @param string $app 分享应用类型,默认为public
* @param string $type 分享类型,
* @param array $data 分享相关数据
* @param integer $app_id 应用资源ID,默认为0
* @param string $app_table 应用资源表名,默认为feed
* @param array $extUid 额外用户ID,默认为null
* @param array $lessUids 去除的用户ID,默认为null
* @param boolean $isAtMe 是否为进行发送,默认为true
* @return mix 添加失败返回false,成功返回新的分享ID
*/
public function put($uid, $app = 'public', $type = '', $data = array(), $app_id = 0, $app_table = 'feed', $extUid = null, $lessUids = null, $isAtMe = true, $is_repost = 0)
{
if (isSubmitLocked()) {
$this->error = '发布内容过于频繁,请稍后再试';
return false;
}
// 判断数据的正确性
if (!$uid || $type == '') {
$this->error = L('PUBLIC_ADMIN_OPRETING_ERROR');
return false;
}
if (strpos($type, 'postvideo') !== false) {
$type = 'postvideo';
}
//分享类型合法性验证 - 临时解决方案
$checkType = array('post', 'repost', 'postvideo', 'postfile', 'postimage', 'weiba_post', 'weiba_repost', 'long_post', 'photo_post', 'photo_repost', 'vote_post', 'vote_repost', 'event_post', 'event_repost', 'blog_post', 'blog_repost', 'poster_post', 'poster_repost');
if (!in_array($type, $checkType)) {
$type = 'post';
}
//应用类型验证 用于分享框 - 临时解决方案
$checkApp = array('w3g', 'public', 'weiba', 'tipoff', 'photo', 'vote', 'event', 'blog', 'poster');
if (!in_array($app, $checkApp)) {
$app = 'public';
$type = 'post';
$app_table = 'feed';
}
$app_table = strtolower($app_table);
// 添加feed表记录
$data['uid'] = $uid;
$data['app'] = $app;
$data['type'] = $type;
$data['app_row_id'] = $app_id;
$data['app_row_table'] = $app_table;
$data['publish_time'] = time();
$data['from'] = isset($data['from']) ? intval($data['from']) : getVisitorClient();
$data['is_del'] = $data['comment_count'] = $data['repost_count'] = 0;
$data['is_repost'] = $is_repost;
//判断是否先审后发
$filterStatus = filter_words($data['body']);
$weiboSet = model('Xdata')->get('admin_Config:feed');
$weibo_premission = $weiboSet['weibo_premission'];
if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit') || $filterStatus['type'] == 2) {
$data['is_audit'] = 0;
} else {
$data['is_audit'] = 1;
}
// 分享内容处理
if (Addons::requireHooks('weibo_publish_content')) {
Addons::hook("weibo_publish_content", array(&$data));
} else {
// 截取内容信息为分享内容字数 - 长分享
//$feedConf = model('Xdata')->get('admin_Config:feed');
//$feedNums = $feedConf['weibo_nums'];
//if(Addons::requireHooks('show_longtext_button')){
// $feedNums = 20000;
// $data['body'] = str_replace(SITE_URL, '[SITE_URL]', $data['body']);
//}else{
// $data['body'] = str_replace(SITE_URL, '[SITE_URL]', preg_html($data['body']));
//}
$content = $this->formatFeedContent($data['body']);
$data['body'] = $content['body'];
$data['content'] = $content['content'];
}
//分享到分享的应用资源,加入原资源链接
$data['body'] .= $data['source_url'];
$data['content'] .= $data['source_url'];
// 分享类型插件钩子
// if($type){
// $addonsData = array();
// Addons::hook("weibo_type",array("typeId"=>$type,"typeData"=>$type_data,"result"=>&$addonsData));
// $data = array_merge($data,$addonsData);
// }
if ($type == 'postvideo') {
if ($_POST['video_id']) {
$video_info = D('video')->where('video_id=' . $data['video_id'])->find();
$data['transfer_id'] = $video_info['transfer_id'];
$data['video_path'] = $video_info['video_path'];
$data['video_mobile_path'] = $video_info['video_mobile_path'];
$data['video_part_path'] = $video_info['video_part_path'];
$data['image_path'] = $video_info['image_path'];
$data['image_width'] = $video_info['image_width'];
$data['image_height'] = $video_info['image_height'];
} else {
$typedata = model('Video')->_weiboTypePublish($_POST['videourl']);
if ($typedata && $typedata['flashvar'] && $typedata['flashimg']) {
$data = array_merge($data, $typedata);
} else {
//.........这里部分代码省略.........
示例11: addReply
/**
* 添加帖子回复的操作
* @return array 评论添加状态和提示信息
*/
public function addReply()
{
// echo $_POST['post_id'];exit;
if (!$this->mid || !CheckPermission('weiba_normal', 'weiba_reply')) {
return;
}
$return = array('status' => 0, 'data' => L('PUBLIC_CONCENT_IS_ERROR'));
$type = intval($_POST['type']);
$data['weiba_id'] = intval($_POST['weiba_id']);
$data['post_id'] = intval($_POST['post_id']);
$data['post_uid'] = intval($_POST['post_uid']);
$data['to_reply_id'] = intval($_POST['to_reply_id']);
$data['to_uid'] = intval($_POST['to_uid']);
$data['uid'] = $this->mid;
$data['ctime'] = time();
$data['content'] = h($_POST['content']);
if (isSubmitLocked()) {
$return['status'] = 0;
$return['data'] = '发布内容过于频繁,请稍后再试!';
exit(json_encode($return));
}
if ($data['reply_id'] = D('weiba_reply')->add($data)) {
// 锁定发布
lockSubmit();
//添加积分
model('Credit')->setUserCredit(intval($_POST['post_uid']), 'comment_topic');
model('Credit')->setUserCredit($data['to_uid'], 'commented_topic');
$map['last_reply_uid'] = $this->mid;
$map['last_reply_time'] = $data['ctime'];
if ($data['to_reply_id'] == 0) {
$map['reply_count'] = array('exp', "reply_count+1");
}
$map['reply_all_count'] = array('exp', "reply_all_count+1");
D('weiba_post')->where('post_id=' . $data['post_id'])->save($map);
//同步到微博评论
//$feed_id = intval($_POST['feed_id']);
$datas['app'] = 'weiba';
$datas['table'] = 'feed';
$datas['content'] = h($data['content']);
$datas['app_uid'] = intval($_POST['post_uid']);
$datas['row_id'] = intval($_POST['feed_id']);
$datas['to_comment_id'] = $data['to_reply_id'] ? D('weiba_reply')->where('reply_id=' . $data['to_reply_id'])->getField('comment_id') : 0;
$datas['to_uid'] = intval($_POST['to_uid']);
$datas['uid'] = $this->mid;
$datas['ctime'] = time();
$datas['client_type'] = getVisitorClient();
// 解锁
unlockSubmit();
if ($comment_id = model('Comment')->addComment($datas)) {
$data1['comment_id'] = $comment_id;
// $data1['storey'] = model('Comment')->where('comment_id='.$comment_id)->getField('storey');
D('weiba_reply')->where('reply_id=' . $data['reply_id'])->save($data1);
// 给应用UID添加一个未读的评论数
if ($GLOBALS['ts']['mid'] != $datas['app_uid'] && $datas['app_uid'] != '') {
!$notCount && model('UserData')->updateKey('unread_comment', 1, true, $datas['app_uid']);
}
model('Feed')->cleanCache($datas['row_id']);
}
//转发到我的微博
if ($_POST['ifShareFeed'] == 1) {
$commentInfo = model('Source')->getSourceInfo($datas['table'], $datas['row_id'], false, $datas['app']);
$oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
// 根据评论的对象获取原来的内容
$s['sid'] = $data['post_id'];
$s['app_name'] = 'weiba';
if (!empty($data['to_comment_id'])) {
$replyInfo = model('Comment')->init($data['app'], $data['table'])->getCommentInfo($data['to_comment_id'], false);
$data['content'] .= $replyInfo['content'];
}
$s['body'] = $data['content'];
$s['type'] = 'weiba_post';
$s['comment'] = $data['comment_old'];
// 去掉回复用户@
$lessUids = array();
if (!empty($data['to_uid'])) {
$lessUids[] = $data['to_uid'];
}
// 如果为原创微博,不给原创用户发送@信息
if ($oldInfo['feedtype'] == 'post' && empty($data['to_uid'])) {
$lessUids[] = $oldInfo['uid'];
}
unlockSubmit();
model('Share')->shareFeed($s, 'comment', $lessUids);
}
$data['feed_id'] = $datas['row_id'];
$data['comment_id'] = $comment_id;
$data['storey'] = $data1['storey'];
$return['status'] = 1;
if ($type == 2) {
$return['data'] = $this->parseRightReply($data);
} else {
$return['data'] = $this->parseReply($data);
}
}
echo json_encode($return);
exit;
//.........这里部分代码省略.........
示例12: comment_post
/**
* 评论帖子 --using
*
* @param
* integer post_id 帖子ID
* @param
* integer to_comment_id 评论ID
* @param
* string content 评论内容
* @param
* integer from 来源(2-android 3-iPhone)
* @return array 状态+提示
*/
public function comment_post()
{
$return['status'] = 0;
$return['msg'] = '发布失败';
//检测用户是否被禁言
if ($isDisabled = model('DisableUser')->isDisableUser($this->mid, 'post')) {
return array('status' => 0, 'msg' => '您已经被禁言了');
}
if (!t($this->data['content'])) {
$return['msg'] = '评论内容不能为空';
return $return;
}
if (!intval($this->data['post_id'])) {
$return['msg'] = '参数非法';
return $return;
}
if (!$this->mid || !CheckPermission('weiba_normal', 'weiba_reply')) {
$return['msg'] = '你无权发布';
return $return;
}
$feed_detail = M('weiba_post')->where('post_id=' . intval($this->data['post_id']))->find();
$data['weiba_id'] = intval($feed_detail['weiba_id']);
$data['post_id'] = intval($this->data['post_id']);
$data['post_uid'] = intval($feed_detail['post_uid']);
if (!empty($this->data['to_comment_id'])) {
$data['to_reply_id'] = intval($this->data['to_comment_id']);
$data['to_uid'] = model('Comment')->where('comment_id=' . intval($this->data['to_comment_id']))->getField('uid');
}
$data['uid'] = $this->mid;
$data['ctime'] = time();
$data['content'] = preg_html(h($this->data['content']));
/* # 格式化emoji */
$data['content'] = formatEmoji(true, $data['content']);
$data['attach_id'] = intval($this->data['attach_id']);
$filterContentStatus = filter_words($data['content']);
if (!$filterContentStatus['status']) {
return array('status' => 0, 'msg' => $filterContentStatus['data']);
}
$data['content'] = $filterContentStatus['data'];
if (isSubmitLocked()) {
$return['msg'] = '发布内容过于频繁,请稍后再试!';
return $return;
}
if ($data['reply_id'] = D('weiba_reply')->add($data)) {
// 锁定发布
lockSubmit();
// 添加积分
model('Credit')->setUserCredit(intval($data['post_uid']), 'comment_topic');
model('Credit')->setUserCredit($data['to_uid'], 'commented_topic');
$map['last_reply_uid'] = $this->mid;
$map['last_reply_time'] = $data['ctime'];
$map['reply_count'] = array('exp', 'reply_count+1');
$map['reply_all_count'] = array('exp', 'reply_all_count+1');
D('weiba_post')->where('post_id=' . $data['post_id'])->save($map);
// 同步到微博评论
$datas['app'] = 'weiba';
$datas['table'] = 'feed';
$datas['content'] = preg_html($data['content']);
$datas['app_uid'] = intval($feed_detail['post_uid']);
$datas['row_id'] = intval($feed_detail['feed_id']);
$datas['to_comment_id'] = $data['to_reply_id'] ? D('weiba_reply')->where('reply_id=' . $data['to_reply_id'])->getField('comment_id') : 0;
$datas['to_uid'] = intval($data['to_uid']);
$datas['uid'] = $this->mid;
$datas['ctime'] = time();
$datas['client_type'] = getVisitorClient();
// $datas ['from'] = 'weiba';
$data['cancomment'] = 1;
// 解锁
unlockSubmit();
if ($comment_id = model('Comment')->addComment($datas)) {
$data1['comment_id'] = $comment_id;
// $data1['storey'] = model('Comment')->where('comment_id='.$comment_id)->getField('storey');
D('weiba_reply')->where('reply_id=' . $data['reply_id'])->save($data1);
// 给应用UID添加一个未读的评论数
// if ($GLOBALS ['ts'] ['mid'] != $datas ['app_uid'] && $datas ['app_uid'] != '') {
// ! $notCount && model('UserData')->updateKey('unread_comment_weiba', 1, true, $datas ['app_uid']);
// }
model('Feed')->cleanCache($datas['row_id']);
}
// 转发到我的微博
if ($this->data['ifShareFeed'] == 1) {
$commentInfo = model('Source')->getSourceInfo($datas['table'], $datas['row_id'], false, $datas['app']);
$oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
// 根据评论的对象获取原来的内容
$s['sid'] = $data['post_id'];
$s['app_name'] = 'weiba';
if (!empty($data['to_comment_id'])) {
//.........这里部分代码省略.........
示例13: saveInfo
private function saveInfo($upload_info, $options)
{
$data = array('table' => t($data['table']), 'row_id' => t($data['row_id']), 'app_name' => t($data['app_name']), 'attach_type' => t($data['attach_type']), 'uid' => (int) $data['uid'] ? $data['uid'] : $GLOBALS['ts']['mid'], 'ctime' => time(), 'private' => $data['private'] > 0 ? 1 : 0, 'is_del' => 0, 'from' => isset($data['from']) ? intval($data['form']) : getVisitorClient());
if ($options['save_to_db']) {
foreach ($upload_info as $u) {
$data['name'] = $u['name'];
$data['type'] = $u['type'];
$data['size'] = $u['size'];
$data['extension'] = strtolower($u['extension']);
$data['hash'] = $u['hash'];
$data['save_path'] = $options['custom_path'];
$data['save_name'] = $u['savename'];
//$data['save_domain'] = C('ATTACH_SAVE_DOMAIN'); //如果做分布式存储,需要写方法来分配附件的服务器domain
$aid = $this->add($data);
$data['attach_id'] = intval($aid);
$data['key'] = $u['key'];
$data['size'] = byte_format($data['size']);
$infos[] = $data;
unset($data);
}
} else {
foreach ($upload_info as $u) {
$data['name'] = $u['name'];
$data['type'] = $u['type'];
$data['size'] = byte_format($u['size']);
$data['extension'] = strtolower($u['extension']);
$data['hash'] = $u['hash'];
$data['save_path'] = $options['custom_path'];
$data['save_name'] = $u['savename'];
//$data['save_domain'] = C('ATTACH_SAVE_DOMAIN'); //如果做分布式存储,需要写方法来分配附件的服务器domain
$data['key'] = $u['key'];
$infos[] = $data;
unset($data);
}
}
return $infos;
}
示例14: addReply
/**
* 添加帖子回复的操作
* @return array 评论添加状态和提示信息
*/
public function addReply()
{
// echo $_POST['post_id'];exit;
if (!$this->mid || !CheckPermission('weiba_normal', 'weiba_reply')) {
return;
}
$is_lock = M('weiba_blacklist')->where('weiba_id=' . intval($_POST['weiba_id']) . ' and uid=' . intval($_POST['post_uid']))->find();
if ($is_lock) {
$return['status'] = 0;
$return['data'] = '您是黑名单用户没有发帖权限!';
exit(json_encode($return));
}
$return = array('status' => 0, 'data' => L('PUBLIC_CONCENT_IS_ERROR'));
$data['weiba_id'] = intval($_POST['weiba_id']);
$data['post_id'] = intval($_POST['post_id']);
$data['post_uid'] = intval($_POST['post_uid']);
$data['to_reply_id'] = intval($_POST['to_reply_id']);
$data['to_uid'] = intval($_POST['to_uid']);
$data['uid'] = $this->mid;
$data['ctime'] = time();
$data['content'] = preg_html(h($_POST['content']));
$data['attach_id'] = intval($_POST['attach_id']);
$filterContentStatus = filter_words($data['content']);
if (!$filterContentStatus['status']) {
exit(json_encode(array('status' => 0, 'data' => $filterContentStatus['data'])));
}
$data['content'] = $filterContentStatus['data'];
if (isSubmitLocked()) {
$return['status'] = 0;
$return['data'] = '发布内容过于频繁,请稍后再试!';
exit(json_encode($return));
}
if ($data['reply_id'] = D('weiba_reply')->add($data)) {
// 锁定发布
lockSubmit();
// 更新微吧今日新帖
D('Weiba')->setNewcount($data['weiba_id']);
//添加积分
model('Credit')->setUserCredit(intval($_POST['post_uid']), 'comment_topic');
model('Credit')->setUserCredit($data['to_uid'], 'commented_topic');
$map['last_reply_uid'] = $this->mid;
$map['last_reply_time'] = $data['ctime'];
$map['reply_count'] = array('exp', "reply_count+1");
$map['reply_all_count'] = array('exp', "reply_all_count+1");
D('weiba_post', 'weiba')->where('post_id=' . $data['post_id'])->save($map);
//同步到分享评论
//$feed_id = intval($_POST['feed_id']);
$datas['app'] = 'weiba';
$datas['table'] = 'feed';
$datas['content'] = preg_html($data['content']);
$datas['app_uid'] = intval($_POST['post_uid']);
$datas['row_id'] = intval($_POST['feed_id']);
$datas['to_comment_id'] = $data['to_reply_id'] ? D('weiba_reply', 'weiba')->where('reply_id=' . $data['to_reply_id'])->getField('comment_id') : 0;
$datas['to_uid'] = intval($_POST['to_uid']);
$datas['uid'] = $this->mid;
$datas['ctime'] = time();
$datas['client_type'] = getVisitorClient();
$data['cancomment'] = 1;
$data['list_count'] = intval($_POST['list_count']);
// 解锁
unlockSubmit();
if ($comment_id = model('Comment')->addComment($datas)) {
$data1['comment_id'] = $comment_id;
// $data1['storey'] = model('Comment')->where('comment_id='.$comment_id)->getField('storey');
D('weiba_reply', 'weiba')->where('reply_id=' . $data['reply_id'])->save($data1);
// 给应用UID添加一个未读的评论数
if ($GLOBALS['ts']['mid'] != $datas['app_uid'] && $datas['app_uid'] != '') {
!$notCount && model('UserData')->updateKey('unread_comment', 1, true, $datas['app_uid']);
}
model('Feed')->cleanCache($datas['row_id']);
}
//转发到我的分享
if ($_POST['ifShareFeed'] == 1) {
$commentInfo = model('Source')->getSourceInfo($datas['table'], $datas['row_id'], false, $datas['app']);
$oldInfo = isset($commentInfo['sourceInfo']) ? $commentInfo['sourceInfo'] : $commentInfo;
// 根据评论的对象获取原来的内容
$s['sid'] = $data['post_id'];
$s['app_name'] = 'weiba';
if (!empty($data['to_comment_id'])) {
$replyInfo = model('Comment')->init($data['app'], $data['table'])->getCommentInfo($data['to_comment_id'], false);
$data['content'] .= $replyInfo['content'];
}
$s['body'] = $data['content'];
$s['type'] = 'weiba_post';
$s['comment'] = $data['comment_old'];
// 去掉回复用户@
$lessUids = array();
if (!empty($data['to_uid'])) {
$lessUids[] = $data['to_uid'];
}
// 如果为原创分享,不给原创用户发送@信息
if ($oldInfo['feedtype'] == 'post' && empty($data['to_uid'])) {
$lessUids[] = $oldInfo['uid'];
}
unlockSubmit();
model('Share')->shareFeed($s, 'comment', $lessUids);
//.........这里部分代码省略.........
示例15: shareMessage
/**
* 分享给同事
*
* @example 需要传入的$data值
* uid:同事用户ID
* sid:转发的分享/资源ID
* app_name:app名称
* content:转发时的内容信息,有时候会有某些标题的资源
* body:转发时,自定义写入的内容
* type:分享类型
* comment:是否给原作者评论
* @param array $data
* 分享的相关数据
* @return array 分享操作后,相关反馈信息数据
*/
public function shareMessage($data)
{
$return = array('status' => 0, 'data' => L('PUBLIC_SHARE_FAILED'));
// 分享失败
$app = t($data['app_name']);
$msg['to'] = trim($data['uids'], ',');
if (empty($msg['to'])) {
$return['data'] = L('PUBLIC_SHARE_TOUSE_EMPTY');
// 分享接受人不能为空
return $return;
}
if (!($oldInfo = model('Source')->getSourceInfo($data['type'], $data['sid'], false, $app))) {
$return['data'] = L('PUBLIC_INFO_SHARE_FORBIDDEN');
// 此信息不可以被分享
return $return;
}
$data['content'] = trim($data['content']);
$content = empty($data['content']) ? "" : "“{$data['content']}” // ";
$content = parse_html($content);
$message['to'] = $msg['to'];
$message['content'] = $content . parse_html($oldInfo['source_content']) . ' <a href="' . $oldInfo['source_url'] . '" target=\'_blank\'>查看</a>';
if (model('Message')->postMessage($message, $GLOBALS['ts']['_user']['uid'])) {
// 发表评论
$c['type'] = 3;
$c['app'] = $app;
$c['table'] = 'feed';
$c['app_uid'] = $oldInfo['uid'];
$c['content'] = str_replace(SITE_URL, '[SITE_URL]', $data['content']);
$c['row_id'] = !empty($oldInfo['sourceInfo']) ? $oldInfo['sourceInfo']['source_id'] : $data['sid'];
$c['client_type'] = getVisitorClient();
$notCount = false;
unlockSubmit();
$comment_id = model('Comment')->addComment($c, true, $notCount, $lessUids);
// $config['name'] = $GLOBALS['ts']['_user']['uname'];
// $config['content'] = $content;
// //$config['sourceurl'] = $oldInfo['source_url'];
// $touids = explode(',', $msg['to']);
// foreach($touids as $v) {
// model('Notify')->sendNotify($v, 'new_message', $config);
// }
$return = array('status' => 1, 'data' => L('PUBLIC_SHARE_SUCCESS'));
// 分享成功
}
return $return;
}