Example #1
0
    /**
	 * 创建小组操作
	 */
    public function create()
    {
        //处理传递的数据
        $data = $this->filter_data();
        //检测小组类型是否存在
        if (!isset($data['team_type'])) {
            $this->errorOutput(PARAM_WRONG);
        }
        $result_type = $this->team->check_team_type($data['team_type']);
        if (!$result_type) {
            $this->errorOutput(PARAM_WRONG);
        }
        //检测小组分类是否存在
        $result_category = $this->team->check_team_category($data['team_category']);
        if (!$result_category) {
            $this->errorOutput(PARAM_WRONG);
        }
        //检测创建的小组名称是否存在
        $result_name = $this->team->check_team_name($data['team_name']);
        if ($result_name) {
            $this->errorOutput(TEAM_EXISTS);
        }
        //检测用户创建的小组的个数
        $result_num = $this->team->check_create_team_num($this->user['user_id']);
        if ($result_num >= $this->settings['create_team_num']) {
            $this->errorOutput(SYSTEM_LIMIT);
        }
        $data['creater_id'] = $this->user['user_id'];
        $data['creater_name'] = $this->user['user_name'];
        $data['pub_time'] = TIMENOW;
        $data['app_name'] = $this->user['display_name'];
        //创建小组
        $result = $this->team->create($data);
        //标签创建
        if (isset($data['tags']) && $data['tags'] && $result) {
            $mark = new mark();
            $mark_data = array('source' => 'team', 'source_id' => $result['team_id'], 'parent_id' => $result['team_id'], 'action' => 'team_tag', 'user_id' => $result['creater_id'], 'name' => $data['tags']);
            $result_mark = $mark->create_source_id_mark($mark_data);
            if ($result_mark) {
                $result['team_mark'] = $data['tags'];
                $this->team->update(array('tags' => $data['tags']), $result['team_id']);
            } else {
                $this->errorOutput(FAIL_OP);
            }
        }
        $this->addItem($result);
Example #2
0
 public function edit_member_mark($mark, $user_id)
 {
     if (empty($user_id) || empty($mark)) {
         return false;
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "member_info WHERE member_id=" . $user_id;
     $f = $this->db->query_first($sql);
     $sql = "";
     if (empty($f)) {
         $sql = "INSERT INTO " . DB_PREFIX . "member_info(member_id,mark) VALUES(" . $user_id . ",'" . $mark . "')";
     } else {
         $sql = "UPDATE " . DB_PREFIX . "member_info SET mark='" . $mark . "' WHERE member_id=" . $user_id;
     }
     $this->db->query($sql);
     include_once ROOT_PATH . 'lib/class/mark.class.php';
     $obj_mark = new mark();
     $data = array('user_id' => $user_id, 'source' => 'user', 'source_id' => $user_id, 'action' => 'myself', 'name' => $mark);
     $mark = $obj_mark->create_source_id_mark($data);
     //file_put_contents('./cache/1.php',var_export($mark,true));
     return true;
 }
Example #3
0
    /**
	 * 创建话题
	 */
    public function create()
    {
        //处理传递的数据
        $data = $this->filter_data();
        if ($data['source_name'] == 'team') {
            //验证来源是否存在
            $team_info = $this->team->detail($data['source_id'], 1);
            if (!$team_info) {
                $this->errorOutput(TEAM_NO_EXISTS);
            }
        }
        $data['creater_id'] = $this->user['user_id'];
        $data['creater_name'] = $this->user['user_name'];
        $data['pub_time'] = TIMENOW;
        $data['last_poster_name'] = $this->user['user_name'];
        $data['last_time'] = TIMENOW;
        $data['views'] = 1;
        $data['app_name'] = $this->user['display_name'];
        $reply_data = array();
        $reply_data['content'] = $data['content'];
        unset($data['content']);
        //创建话题
        $result = $this->topic->create($data);
        $reply_data['topic_id'] = $result['topic_id'];
        $reply_data['subject'] = $result['subject'];
        $reply_data['poster_id'] = $result['creater_id'];
        $reply_data['poster_name'] = $result['creater_name'];
        $reply_data['pub_time'] = $result['pub_time'];
        $reply_data['update_time'] = $result['pub_time'];
        $reply_data['from_ip'] = hg_getip();
        $reply_data['reply_num'] = 0;
        $reply_data['floor'] = 0;
        $reply_data['app_name'] = $this->user['display_name'];
        //对应话题数据的创建
        $reply = $this->topic->add_reply($reply_data);
        //附件图片的操作
        if (isset($this->input['material']) && $this->input['material']) {
            $img_info = unserialize(trim(urldecode($this->input['material'])));
            $materialData = array('user_id' => $result['creater_id'], 'user_name' => $result['creater_name'], 'topic_id' => $result['topic_id'], 'team_id' => $data['source_id'], 'reply_id' => 0);
            if (is_array($img_info) && !empty($img_info)) {
                $materialNum = $this->topic->add_material($img_info, $materialData);
                //插入附件
                //更新话题下的附件个数
                $this->topic->update(array('material_num' => $materialNum), $result['topic_id'], true);
            }
        }
        //视频添加
        if (isset($this->input['video_url']) && $this->input['video_url']) {
            $video_url = trim(urldecode($this->input['video_url']));
            $this->teamApi->add_video($video_url, 'topic', $result['topic_id']);
        }
        //标签操作
        if (isset($this->input['topic_mark']) && $this->input['topic_mark']) {
            $topic_mark = trim(urldecode($this->input['topic_mark']));
            $mark = new mark();
            $mark_data = array('source' => 'topic', 'source_id' => $result['topic_id'], 'parent_id' => $data['source_id'], 'action' => 'topic_tag', 'user_id' => $result['creater_id'], 'name' => $topic_mark);
            $result_mark = $mark->create_source_id_mark($mark_data);
            if ($result_mark) {
                $result['topic_mark'] = $topic_mark;
                $this->topic->update(array('tags' => $topic_mark), $result['topic_id']);
            } else {
                $this->errorOutput(FAIL_OP);
            }
        }
        //插入搜索
        $this->teamApi->add_search($result['topic_id'], 'topic');
        //更新小组的话题数
        $this->team->update(array('topic_num' => 1), $result['source_id'], true);
        $this->setXmlNode('topic_info', 'topic');
        $this->addItem($result['topic_id']);