public function see($mid, $uid, $type)
 {
     $map["uid"] = $uid;
     $map["type"] = "basic";
     $r = $this->where($map)->find();
     $privacy = unserialize($r["privacy"]);
     //没有设置过的话,默认从缓存里面读
     if (!$privacy) {
         $site_opts = TS_D("Option")->get();
         $privacy = unserialize($site_opts["privacy"]);
     }
     $privacy = intval($privacy[$type]);
     if ($mid == $uid) {
         //如果是看自己空间,肯定显示
         return true;
     } else {
         //看别人空间
         switch ($privacy) {
             case 0:
                 return true;
                 //任何人
             //任何人
             case 1:
                 $api = new TS_API();
                 return $api->friend_areFriends($mid, $uid);
                 //仅好友
             case 2:
                 return false;
                 //他自己可看
             //他自己可看
             default:
                 return true;
         }
     }
 }
 public function render($data)
 {
     $api = new TS_API();
     $data["mid"] = $api->user_getLoggedInUser();
     $content = $this->renderFile("ShowComment", $data);
     return $content;
 }
 public function render($data)
 {
     $api = new TS_API();
     $mid = $api->user_getLoggedInUser();
     if (!$mid) {
         return false;
     }
     $site_opts = $api->option_get();
     $reasons = explode(",", $site_opts["report_reason"]);
     $data['reasons'] = $reasons;
     $data['isReport'] = $api->Report_check($data['appid'], $data['type'], $data['recordId'], $mid);
     $content = $this->renderFile("Report", $data);
     return $content;
 }
 public function render($data)
 {
     $uid = intval($_GET["uid"]);
     $api = new TS_API();
     $mid = $api->user_getLoggedInUser();
     $data["mid"] = $uid ? $uid : $mid;
     $map = "uid = 0 or uid = " . $mid;
     $data["groups"] = D("FriendGroup")->where($map)->order("id asc")->findAll();
     if ($_GET["uid"]) {
         $other = "/uid/" . $_GET["uid"];
     }
     $data["cur_url"] = isset($data['this_url']) ? $data['this_url'] : C("TS_URL") . "/index.php?s=/" . MODULE_NAME . "/" . ACTION_NAME . $other;
     $content = $this->renderFile("FriendGroup", $data);
     return $content;
 }
 function getPhotos($uid, $albumId, $type, $order = 'id ASC', $shownum = 5)
 {
     //我的全部照片
     if ($type == 'mAll') {
         $map['userId'] = $uid;
         //好友的全部照片
     } elseif ($type == 'fAll') {
         $api = new TS_API();
         $friends = $api->friend_get();
         $map['userId'] = array('in', $friends);
     } else {
         //某个专辑的全部照片
         $map['albumId'] = $albumId;
         $map['userId'] = $uid;
     }
     $map['isDel'] = 0;
     $result = D('Photo')->order($order)->where($map)->findAll();
     return $result;
 }
 public function __call($fun, $args)
 {
     $fun = explode("_", $fun);
     $model = ucfirst($fun[0]);
     $method = $fun[1];
     if (TS_API::$dao->model_name != $model) {
         TS_API::$dao = TS_D($model);
     }
     return call_user_func_array(array(TS_API::$dao, $method), $args);
 }
示例#7
0
<?php

header("Content-type: text/html;charset=utf-8");
define("THINK_PATH", "..");
error_reporting(0);
session_start();
$_SESSION["mid"] = 1;
require "TS_API.class.php";
//调试demo
$api = new TS_API();
//ts_dump($api);
/* ===========================================================================================
 * ========================================= USER ============================================
 * ===========================================================================================
 */
/*-------------------------------------
= user_getInfo
-------------------------------------*/
$user_info = $api->user_getInfo("1,2", "name,email");
$user_info2 = $api->user_getInfo("1,2", "name,email", "json");
ts_dump($user_info);
ts_dump($user_info2);
/*-------------------------------------
= user_getLoggedInUser
-------------------------------------*/
$user_id = $api->user_getLoggedInUser();
ts_dump($user_id);
/*-------------------------------------
= user_getLoggedInUserLevel
-------------------------------------*/
$admin_level = $api->user_getLoggedInUserLevel();
 public function filterPrivacy($value)
 {
     $api = new TS_API();
     //基本信息过滤
     if (isset($value['privacy'])) {
         $privacy = $value['privacy'];
         $home = isset($value['display']) ? $value['display'] : $value['home'];
     } else {
         $privacy = $value[0];
         $home = $value[1];
     }
     if ($this->uid != $this->mid && (1 == $privacy && false == $api->friend_areFriends($this->uid, $this->mid))) {
         return false;
     }
     if (1 == $this->home && 1 != $home) {
         return false;
     }
     if ($this->uid != $this->mid && $privacy == 2) {
         return false;
     }
     return true;
 }
示例#9
0
function setUserScore($uid, $credit)
{
    $api = new TS_API();
    $array = array();
    foreach ($credit['credit'] as $key => $score) {
        $temp = $api->UserScore_checkScore($uid, $key, $score);
        $array[] = $temp === 0 ? true : $temp;
        $credit_rule[$key] = $score;
    }
    if (count(array_filter($array)) != count($array)) {
        return false;
    }
    $credit_rule['action'] = $credit['action'];
    $credit_rule['actioncn'] = $credit['actioncn'];
    $credit_rule['info'] = isset($credit['info']) && !empty($credit['info']) ? $credit['info'] : '{action}{sign}了{score}分{typecn}';
    //操作积分
    $score_result = $api->UserScore_setScore($uid, $credit_rule);
    return $score_result;
}
 public function upload($attach_type = 'attach_type', $path, $save_name, $options = array())
 {
     //检查文件名和目录是否为空
     if (empty($path)) {
         $path = C('UPLOAD_PATH') . '/' . date('Ymd') . '/';
     }
     //创建目录
     if (!checkDir($path)) {
         $return['status'] = false;
         $return['info'] = '目录创建失败: ' . $path;
         return $return;
     }
     import("ORG.Net.UploadFile");
     $upload = new UploadFile();
     //设置上传文件大小
     $upload->maxSize = empty($options['maxsize']) ? '2000000' : $options['maxsize'];
     //设置上传文件类型
     $upload->allowExts = empty($options['allowExts']) ? explode(',', strtolower('jpg,gif,png,jpeg,bmp')) : explode(',', $options['allowExts']);
     //存储规则
     $upload->saveRule = 'uniqid';
     //设置上传路径
     $upload->savePath = $path;
     //保存的名字
     $upload->saveName = $save_name;
     //是否缩略图
     $upload->thumb = empty($options['is_thumb']) ? false : $options['is_thumb'];
     $upload->thumbMaxWidth = empty($options['thumb_width']) ? '200' : $options['thumb_width'];
     $upload->thumbFile = empty($options['thumb_file']) ? 'thumb_' . $save_name : $options['thumb_file'];
     //存在是否覆盖
     $upload->uploadReplace = empty($options['is_replace']) ? true : $options['is_replace'];
     //执行上传操作
     if (!$upload->upload()) {
         //上传失败,返回错误
         $return['status'] = false;
         $return['info'] = $upload->getErrorMsg();
         return $return;
     } else {
         $upload_info = $upload->getUploadFileInfo();
         //保存信息到附件表
         $api = new TS_API();
         $uid = $api->user_getLoggedInUser();
         foreach ($upload_info as $u) {
             unset($map);
             $map['attach_type'] = $attach_type;
             $map['userId'] = $uid;
             $map['uploadTime'] = time();
             $map['name'] = $u['name'];
             $map['type'] = $u['type'];
             $map['size'] = $u['size'];
             $map['extension'] = $u['extension'];
             $map['hash'] = $u['hash'];
             $map['savepath'] = $u['savepath'];
             $map['savename'] = $u['savename'];
             //$map['savedomain']=	C('ATTACH_SAVE_DOMAIN');
             $result = $this->add($map);
             $map['id'] = $result;
             $infos[] = $map;
         }
         //输出信息
         $return['status'] = true;
         $return['info'] = $infos;
         //上传成功,返回信息
         return $return;
     }
 }
示例#11
0
function check_relationship($uid, $mid = 0)
{
    $api = new TS_API();
    if (!$mid) {
        $mid = $api->user_getLoggedInUser();
    }
    if ($uid == $mid) {
        return 'self';
    } elseif ($api->friend_areFriends($uid, $mid)) {
        return 'friend';
    } else {
        return 'stranger';
    }
}