コード例 #1
0
ファイル: function.php プロジェクト: suibber/jb
function setUserMessage($uid, $type, $body, $keyword, $is_sys_msg = 0, $modaction = '')
{
    $body = iconv('gb2312', 'utf-8', $body);
    $modaction = iconv('gb2312', 'utf-8', $modaction);
    // 次数统计
    $cishu = 1;
    if ($type == 1 || $type == 2 || $type == 3) {
        $cishu_sql = "SELECT id,cishu FROM `pre_jf_message` WHERE user={$uid} AND type={$type} AND has_read=0";
        $cishu_re = DB::query($cishu_sql);
        $cishu_data = mysql_fetch_assoc($cishu_re);
        if ($cishu_data['cishu']) {
            $cishu = $cishu_data['cishu'] + 1;
        }
    }
    $array = array(1 => "你的帖子####《" . $body . "》%%%%新增" . $cishu . "条回复", 2 => "你在####《" . $body . "》%%%%中的回复新增" . $cishu . "条回复", 3 => "你参与的帖子####《" . $body . "》%%%%新增" . $cishu . "条回复", 4 => "####" . $body . "</font>关注了你", 5 => "你在####《" . $body . "》%%%%中被点赞 " . $modaction . " 次", 6 => "你的帖子####《" . $body . "》%%%%已被管理员进行了 ####" . $modaction . "%%%% 操作", 7 => "你的帖子####《" . $body . "》%%%%已被管理员推荐至首页", 8 => "你的帖子####《" . $body . "》%%%%已被管理员移动至其他版块");
    $message = iconv('utf-8', 'gb2312', $array[$type]);
    if ($cishu_data['cishu']) {
        $cishu = $cishu_data['cishu'] + 1;
        $sql = "UPDATE `pre_jf_message` SET cishu={$cishu},message='{$message}' WHERE id=" . $cishu_data['id'] . ";";
        DB::query($sql);
    } else {
        switch ($type) {
            case 1:
                $url = "/forum.php?mod=viewthread&tid={$keyword}";
                break;
            case 2:
                $url = "/forum.php?mod=viewthread&tid={$keyword}";
                break;
            case 3:
                $url = "/forum.php?mod=viewthread&tid={$keyword}";
                break;
            case 4:
                $url = "/jointapp.php?app=appdiscuz&mod=uthread&uid={$keyword}";
                break;
            case 5:
                $url = "/forum.php?mod=viewthread&tid={$keyword}";
                break;
            case 6:
                $url = "/forum.php?mod=viewthread&tid={$keyword}";
                break;
            case 7:
                $url = "/forum.php?mod=viewthread&tid={$keyword}";
                break;
            case 8:
                break;
            default:
                $url = "/jointapp.php";
                break;
        }
        $created_time = date("Y-m-d H:i:s");
        // 给关注着发消息,判断是否是作者,如果是,就发了
        $break = 0;
        if ($type == 3) {
            $author_id = getUseridByTid($keyword);
            if ($uid == $author_id) {
                $break = 1;
            }
        }
        // 是否是当前用户自己
        if (!$break && $GLOBALS['_G']['uid'] && $uid != $GLOBALS['_G']['uid']) {
            $sql = "INSERT INTO `pre_jf_message` VALUES(NULL,'{$uid}','{$type}','{$message}','{$url}','{$created_time}',0,'{$keyword}','{$is_sys_msg}','{$cishu}')";
            DB::query($sql);
        }
    }
}
コード例 #2
0
ファイル: IndexController.class.php プロジェクト: suibber/jb
 public function aadd()
 {
     // 如果是提交操作
     if (IS_POST) {
         $data = I('post.');
         if ($_FILES['img']["size"]) {
             $img = $this->saveimage($_FILES['img'], 500000, __DIR__ . '/../../../Upload/');
             $data['img'] = '/JointForce/Upload/' . $img;
         }
         $data_m = M('jf_data');
         $re = $data_m->add($data);
         if ($re) {
             // 20151118 消息通知 - 推荐首页等
             preg_match('/tid\\=(\\d{1,20})/is', $data['url'], $tid);
             $tid = $tid[1];
             if (is_numeric($tid)) {
                 // 20151118 消息通知 - 高亮等
                 $userid = getUseridByTid($tid);
                 setUserMessage($userid, 7, iconv('utf-8', 'gb2312', $data['title']), $tid, 1, 22);
             }
             //var_dump($data);exit;
             $this->success('添加成功', C('BASE_URL') . '/index.php/Joint');
         } else {
             $this->error('添加失败', C('BASE_URL') . '/index.php/Joint');
         }
         exit;
     }
     $this->display();
 }