コード例 #1
0
ファイル: topic.logic.php プロジェクト: YouthAndra/huaitaoo2o
 function Modify($tid, $content, $imageid = 0, $attachid = 0, $table = "", $itemid = 0, $featureid = 0)
 {
     $updatas = array();
     if (MEMBER_ID < 1) {
         return '游客不能执行此操作';
     }
     $tid = max(0, (int) $tid);
     if ($tid < 1) {
         return "微博ID错误";
     }
     $topic_info = $this->get($tid, '*', 'Make', $table, 'tid');
     if (!$topic_info) {
         return "微博已经不存在了";
     }
     if ($topic_info['item'] == 'channel' && $topic_info['item_id'] > 0) {
         if (!function_exists('item_topic_from')) {
             jfunc('item');
         }
         $topic_info = item_topic_from($topic_info);
     }
     if (!(jallow($topic_info['uid']) || $topic_info['ismanager'])) {
         return '您没有权限进行编辑操作';
     }
     $content = $this->_content_strip($content);
     $content_length = strlen($content);
     if ($content_length < 2) {
         return "微博内容不能为空";
     }
     if ($this->_len2 > 0 && $content_length > $this->_len2) {
         $content = cut_str($content, $this->_len2, '');
     }
     $f_rets = filter($content);
     if ($f_rets) {
         if ($f_rets['error']) {
             return $f_rets['msg'];
         }
     }
     if ($topic_info['totid'] > 0 && $topic_info['totid'] != $topic_info['roottid']) {
         $content = $this->GetForwardContent($content);
         $row = $this->Get($topic_info['totid'], '*', 'Make', $table);
         if ($row && ('forward' == $topic_info['type'] || 'both' == $topic_info['type'])) {
             $content .= $this->ForwardSeprator . "{$row['nickname']} : " . addslashes($this->_content_strip($row['content']));
             if (strlen($content) > $this->_len) {
             }
         }
     }
     if ($imageid != $topic_info['imageid']) {
         if ($imageid) {
             $imageid = jlogic('image')->get_ids($imageid, $topic_info['uid']);
             if ($imageid) {
                 jlogic('image')->set_tid($imageid, $tid);
             }
         }
         jlogic('image')->set_topic_imageid($tid, $imageid);
     }
     if ($attachid != $topic_info['attachid']) {
         if ($attachid) {
             $attachid = jlogic('attach')->get_ids($attachid, $topic_info['uid']);
             if ($attachid) {
                 jlogic('attach')->set_tid($attachid, $tid);
             }
         }
         jlogic('attach')->set_topic_attachid($tid);
     }
     $_process_result = $this->_process_content($content, $topic_info);
     $_content = $_process_result['content'];
     $at_uids = $_process_result['at_uids'];
     $tags = $_process_result['tags'];
     $urls = $_process_result['urls'];
     $updatas['longtextid'] = 0;
     $longtextid = jlogic('longtext')->modify($topic_info['tid'], $_content);
     if (jstrlen($_content) > $this->_len) {
         $_content = cut_str($_content, $this->_len, '');
         $_content = $this->_content_end($_content);
         if (strlen($_process_result['content']) > strlen($_content)) {
             $updatas['longtextid'] = $longtextid;
         }
     }
     if (!$GLOBALS['_J']['config']['clear_format_open']) {
         $_content = $this->clearFormat($_content);
     } else {
         $_content = preg_replace('/(\\n\\n)+/', '\\n', $_content);
         $_content = nl2br($_content);
     }
     if (strlen($_content) > 255) {
         $_content = cut_str($_content, 254 * 2, '');
         $content1 = cut_str($_content, 255, '');
         $content2 = substr($_content, strlen($content1));
         $updatas['content'] = $content1;
         $updatas['content2'] = $content2;
     } else {
         $updatas['content'] = $_content;
         $updatas['content2'] = '';
     }
     if ($itemid > 0 && ($topic_info['item'] == 'channel' && $topic_info['item_id'] > 0 || $topic_info['item'] == 'api' || $topic_info['item'] == '') && $itemid != $topic_info['item_id']) {
         $true_channel_id = jlogic('channel')->is_exists($itemid);
         $can_pub_topic = jlogic('channel')->can_pub_topic($itemid);
         if ($true_channel_id && $can_pub_topic) {
             jfunc('app');
             $param = array('tid' => $tid, 'uid' => $topic_info['uid'], 'old_itemid' => $topic_info['item_id'], 'itemid' => $itemid);
             app_mod_relation($param);
             unset($param);
             $updatas['item'] = 'channel';
             $updatas['item_id'] = $itemid;
             $to_info = jlogic('channel')->id2category($itemid);
             if ($topic_info['item'] == '') {
                 if ($to_info['purpostview']) {
                     $updatas['type'] = 'channel';
                 }
             } else {
                 if ($topic_info['type'] == 'channel' && $to_info['purpostview'] == '') {
                     $updatas['type'] = 'first';
                 }
             }
             if ($topic_info['managetype'] != $to_info['topictype']) {
                 $updatas['managetype'] = $to_info['topictype'];
             }
         }
     }
     $updatas['featureid'] = $featureid;
     if ($topic_info['featureid'] != $featureid && $topic_info['item'] == 'channel' && $topic_info['item_id'] > 0) {
         $ch_typeinfo = jlogic('channel')->get_channel_typeinfo_byid($topic_info['item_id']);
         if (in_array($ch_typeinfo['channel_type'], array('ask', 'idea'))) {
             $msg = '您提出的';
             $msg .= $ch_typeinfo['channel_type'] == 'ask' ? '问题' : '建议';
             $msg .= ',状态变更为“' . ($ch_typeinfo['feature'][$featureid] ? $ch_typeinfo['feature'][$featureid] : '等待处理') . '”';
         } else {
             $msg = '您发布的微博';
             if ($featureid > 0) {
                 $msg .= ',状态变更为“' . jlogic('feature')->id2subject($featureid) . '”';
             } else {
                 $msg .= ',取消了其属性状态';
             }
         }
         postpmsms($topic_info['uid'], $tid, $msg);
     }
     $updatas['lastupdate'] = TIMESTAMP;
     jtable('topic')->update($updatas, $tid);
     $verify_pub_topic = jlogic('channel')->verify_pub_topic($itemid);
     if ($verify_pub_topic) {
         $this->DeleteToBox($tid, 0);
     }
     if ($at_uids) {
         $this->_process_at_uids($topic_info, $at_uids);
     }
     if ($tags) {
         Load::logic('tag');
         $TagLogic = new TagLogic('topic');
         $tags_old = array();
         if (false !== strpos($topic_info['content'], '#')) {
             preg_match_all('~<T>#(.+?)#</T>~', $topic_info['content'], $subpatterns);
             if ($subpatterns && is_array($subpatterns[1])) {
                 $tags_old = $subpatterns['1'];
             }
         }
         $TagLogic->Modify(array('item_id' => $tid, 'tag' => $tags), $tags_old);
     }
     if ($urls) {
         $this->_process_urls($topic_info, $urls, true);
     }
     return $topic_info;
 }
コード例 #2
0
 function set_topic_feature($tid = 0, $relateid = 0, $featureid = 0)
 {
     $topicinfo = jlogic('topic')->Get($tid, '`item`,`item_id`,`uid`,`relateid`,`featureid`', '');
     if ($topicinfo && $topicinfo['item'] == 'channel' && $topicinfo['item_id'] > 0) {
         $ch_typeinfo = jlogic('channel')->get_channel_typeinfo_byid($topicinfo['item_id']);
         if (in_array($ch_typeinfo['channel_type'], array('ask', 'idea')) && ('admin' == MEMBER_ROLE_TYPE || $ch_typeinfo['manageid'] && in_array(MEMBER_ID, explode(',', $ch_typeinfo['manageid'])))) {
             DB::Query("update " . DB::table('topic') . " set  `relateid` = '{$relateid}', `featureid` = '{$featureid}'  where `tid`='{$tid}'");
         }
         if (!($relateid == $topicinfo['relateid'] && $featureid == $topicinfo['featureid'])) {
             $msg = '您提出的';
             $msg .= $ch_typeinfo['channel_type'] == 'ask' ? '问题' : '建议';
             if ($relateid != $topicinfo['relateid']) {
                 $msg .= $relateid == 0 ? ',原有答复已被取消' : ($topicinfo['relateid'] == 0 ? ',已经有了答复' : '重新给予了答复');
             }
             if ($featureid != $topicinfo['featureid']) {
                 $msg .= ',状态变更为“' . ($ch_typeinfo['feature'][$featureid] ? $ch_typeinfo['feature'][$featureid] : '等待处理') . '”';
             }
             postpmsms($topicinfo['uid'], $tid, $msg);
         }
     }
 }