function _make_topic_from($topic) { $topic['from_html'] = $topic['from_string'] = ''; if ($topic['relateid'] > 0) { $topic['channel_type'] = 'default'; } if ($topic['featureid'] > 0) { $features = jlogic('feature')->get_feature(); $topic['topic_feature_status'] = $features[$topic['featureid']] ? $features[$topic['featureid']] : ''; } if ($topic['item'] && $topic['item_id'] > 0) { if (!function_exists('item_topic_from')) { jfunc('item'); } $topic = item_topic_from($topic); } elseif ($topic['from']) { static $topic_from_config = null; if (null === $topic_from_config) { $topic_from_config = jconf::get('topic_from'); } $topic_from = $topic_from_config[$topic['from']]; if ($topic_from) { $topic['from_html'] = $topic['from_string'] = '来自 ' . $topic_from['name']; if ($topic_from['link']) { $topic['from_html'] = '来自 <a href="' . $topic_from['link'] . '">' . $topic_from['name'] . '</a>'; } } } if (!$topic['from']) { $topic['from'] = 'web'; } if (!$topic['from_string']) { $topic['from_string'] = '来自 ' . $GLOBALS['_J']['config']['site_name']; } if (!$topic['from_html']) { $topic['from_html'] = '来自 <a href="' . $GLOBALS['_J']['config']['site_url'] . '">' . $GLOBALS['_J']['config']['site_name'] . '</a>'; } return $topic; }
function do_recd() { Load::logic('topic_recommend'); $TopicRecommendLogic = new TopicRecommendLogic(); $tid = intval($this->Post['tid']); $topic = DB::fetch_first("SELECT * FROM " . DB::table("topic") . " WHERE tid='{$tid}'"); if (empty($topic)) { json_error("当前微博不存在或者已经被删除了"); } if ($topic['item'] == 'channel' && $topic['item_id'] > 0) { if (!function_exists('item_topic_from')) { jfunc('item'); } $topic = item_topic_from($topic); } if (!($this->MemberHandler->HasPermission('topic', 'do_recd') || $topic['ismanager'])) { json_error("您的角色没有推荐微博的权限!"); } $recd = intval($this->Post['recd'][0]); if ($recd > 4 || $recd < 0) { json_error("推荐类型错误"); } if ($topic['item'] == 'qun' && $topic['item_id'] > 0) { Load::logic('qun'); $QunLogic = new QunLogic(); $tmp_perm = $QunLogic->chk_perm($topic['item_id'], MEMBER_ID); if (!('admin' == MEMBER_ROLE_TYPE || in_array($tmp_perm, array(1, 2)))) { json_error("你没有权限推荐群内微博"); } } if ($recd == 0) { $topic_recd = $TopicRecommendLogic->delete(array($tid)); json_result("0|||取消推荐成功!"); } else { $expiration = jstrtotime(trim($this->Post['expiration'])); $tag_id = intval($this->Post['tag_id']); $r_title = strip_tags(trim($this->Post['r_title'])); if (!empty($tag_id)) { $count = DB::result_first("SELECT COUNT(*) FROM " . DB::table('topic_tag') . " WHERE item_id='{$tid}' AND tag_id='{$tag_id}' "); if (!empty($count)) { $topic['item'] = 'tag'; $topic['item_id'] = $tag_id; } } $item = $this->Post['item_id'] ? 'channel' : $topic['item']; $item_id = $this->Post['item_id'] ? intval($this->Post['item_id']) : $topic['item_id']; if (empty($r_title)) { json_error("推荐标题为空或内容不合法"); } if ($expiration && $expiration < time()) { json_error("时间设置无效,请重新设置"); } $data = array('expiration' => $expiration, 'item' => $item, 'item_id' => $item_id, 'tid' => $tid, 'recd' => $recd, 'dateline' => TIMESTAMP, 'r_uid' => MEMBER_ID, 'r_nickname' => MEMBER_NICKNAME, 'r_title' => $r_title); if ($TopicRecommendLogic->is_exists($tid)) { unset($data['tid']); $TopicRecommendLogic->modify($data, array('tid' => $tid)); json_result("2|||重新推荐成功!"); } else { $TopicRecommendLogic->add($data); feed_msg('recommend', 'recommend', $tid, $r_title, $item_id); if ($recd == 4) { $iphone_msg = cut_str($topic['content'], 30, ''); ios_push_msg('all', $r_title . ':' . $iphone_msg); } $credits = jconf::get('credits'); update_credits_by_action('recommend', $topic['uid']); json_result("1|||推荐成功!被推荐者因:" . $this->js_show_msg(1)); } } }