function getGroupPopedom($groupid) { if ($groupid) { $arrPopedomList = $this->where('groupid=' . $groupid)->field('menuid,modelid,arraction,type')->findAll(); foreach ($arrPopedomList as $key => $val) { $modelname = TS_D('SyNode')->where('id=' . $val['modelid'])->field('name')->find(); $arraction = unserialize($val['arraction']); $map['id'] = array('in', $arraction); $actionlist = TS_D('SyNode')->where($map)->field('title,name,containaction')->findall(); foreach ($actionlist as $k => $v) { foreach (unserialize($v['containaction']) as $kk => $vv) { $arr[strtoupper($vv['name'])] = true; } } if ($val['type'] == 'admin') { $result['ADMIN'][strtoupper($modelname['name'])] = $arr; } else { $result[strtoupper($modelname['name'])]['ADMIN'] = $arr; } unset($arr); unset($map); } } $r = array_change_key_case($result, CASE_UPPER); return $result; }
/** * 设置用户的积分 * @param int $uid 用户id * @param int $score 积分操作数 * @param type $type 积分种类 */ public function setScore($uid, $credit, $type = null) { //获取缓存的积分种类 $dao = TS_D('CreditSetting'); $cache_type = $dao->getCreditType(); $array = array('action', 'id', 'type', 'info', 'actioncn'); foreach ($credit as $key => $value) { if (!in_array($key, $array)) { if (!$this->checkScore($uid, $key, $value)) { continue; } $request[$key]['number'] = $value; $request[$key]['uid'] = intval($uid); $request[$key]['cTime'] = time(); } } foreach ($request as $key => $map) { $map['type'] = $key; $map['action'] = $credit['action']; $map['info'] = $this->__paramInfo($cache_type, $credit, $map); $result[$key] = $this->add($map); } foreach ($cache_type as $key => $value) { $old_score = $this->getScore($uid, $key); $this->credit[$key] = isset($old_score) ? $old_score : 0; } //将积分记录到用户信息表 $dao = TS_D('UserInfo'); $dao->addCredit($uid, $this->credit); $this->credit = null; return $result; }
public function notify(array $type, array $data, $appid) { $dao = TS_D('Notify'); $dao->setAppId($appid); if ($this->mid != $data['uids']) { switch (true) { case $data['uids'] == $data['toUid'] && !empty($data['toUid']): //发布者的回复的回复 setScore($data['toUid'], 'comment_comment'); $notify = $dao->send($data['toUid'], 'comment_comment', $data['title_data'], $data['title_body'], $data['url']); break; case $data['uids'] != $data['toUid'] && !empty($data['toUid']): //回复的回复 setScore($this->mid, 'commented'); if ($data['toUid'] != $this->mid) { setScore($data['toUid'], 'comment_comment'); $notify = $dao->send($data['toUid'], 'comment_comment', $data['title_data'], $data['title_body'], $data['url']); } setScore($data['uids'], 'commented'); $notify = $dao->send($data['uids'], $type . '_comment', $data['title_data'], $data['title_body'], $data['url']); break; default: //评论 setScore($this->mid, 'comment'); setScore($data['uids'], 'commented'); $notify = $dao->send($data['uids'], $type . '_comment', $data['title_data'], $data['title_body'], $data['url']); } return $notify; } else { if ($data['uids'] != $data['toUid'] && !empty($data['toUid'])) { setScore($data['toUid'], 'comment_comment'); $notify = $dao->send($data['toUid'], 'comment_comment', $data['title_data'], $data['title_body'], $data['url']); } } }
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); }
/** * 获得积分规则 * @param <type> $userId 用户id * @param <type> $action 动作 * @return <type> */ function getCredit($userId, $action) { $user = TS_D('User'); $setting = $this->where("action='{$action}'")->find(); $userInfo = $user->where('id=' . $userId)->field('id')->find(); if (empty($userId) || !$userInfo) { return 'not_user'; } //用户id错误 if (!$setting) { return 'no_have_action'; } //没有这个动作 return $setting; }
public function changeCount($appname, $count, $uid = null) { if (isset($uid)) { $mid = $uid; } else { $userLwDao = TS_D("User"); $mid = $userLwDao->getLoggedInUser(); } $map['value'] = intval($count); $where['appname'] = $appname; $where['uid'] = $mid; $where['variable'] = 'count'; if ($find = $this->where($where)->find()) { $result = $this->where($where)->save($map); } else { $map['appname'] = $appname; $map['variable'] = 'count'; $map['uid'] = $mid; $map['name'] = $uid; $map['value'] = $count; $result = $this->add($map); } return $result; }
function saveEmail($toEmail, $title, $content, $mid, $name = '', $type = '') { $result = false; if ($toEmail) { $map['title'] = $title; $map['content'] = $content; $map['uid'] = $mid; $api_name = TS_D('User')->getInfo($mid, 'name'); $map['userName'] = !empty($name) ? $name : $api_name['name']; if (is_string($toEmail) && false !== strpos($toEmail, ',')) { $toEmail = implode(',', $toEmail); } false == is_array($toEmail) && ($toEmail = array($toEmail)); foreach ($toEmail as $k => $v) { $map['toemail'] = $v; $value_map = $this->__stringToMarks($map); $value[] = "(" . implode(',', $value_map) . ")"; $field = "(" . implode(',', array_keys($value_map)) . ")"; } $sql = "INSERT INTO `ts_saveemail` " . $field . " VALUES " . implode(',', $value); $result = $this->db->query($sql); } return $result; }
foreach ($v as $kk => $vv) { if (!$vv) { $v[$kk] = "NULL"; } } echo "<tr>"; echo "<td>" . $v['id'] . "</td><td>" . $v['type'] . "</td><td>" . $v['type_cn'] . "</td><td>" . $v['deal'] . "</td><td>" . $v['title'] . "</td><td>" . $v['body'] . "</td><td><a href='?do=m&id=" . $v["id"] . "'>修改</a> <a href='javascript:del_Notify(" . $v["id"] . ")'>删除</a></td>"; echo "</tr>"; } ?> </table> </center> <hr> <h3>2、已有Notify 模板举例</h3> <?php $NotifyDao = TS_D("Notify"); $Notifys = $NotifyDao->findAll(); foreach ($Notifys as $fkey => $Notify) { $Notify_template = $dao->where(array("type" => $Notify['type']))->find(); /*------------------------------------- = title -------------------------------------*/ $Notify_title = $Notify_template["title"]; //title的模板 $title_data = unserialize(stripcslashes($Notify["title"])); //title的数据 $actor = "<a href='space.php?" . $Notify["authorid"] . "'>" . $Notify["author"] . '</a>'; $title_data["actor"] = $actor; foreach ($title_data as $k => $v) { //替换 $Notify_title = str_replace('{' . $k . '}', $v, $Notify_title);
public function upload($attach_type = 'attach', $input_options = array()) { //网站定义的主上传目录 $upload_path = C('UPLOAD_PATH'); $default_options = array(); $default_options['custom_path'] = date('Ymd/H/'); //应用定义的上传目录规则 $default_options['max_size'] = '2048000'; //默认是2兆 $default_options['allow_exts'] = 'jpg,gif,png,jpeg,bmp'; $default_options['allow_types'] = ''; $default_options['save_path'] = $upload_path . $default_options['custom_path']; $default_options['save_name'] = ''; $default_options['save_rule'] = 'uniqid'; //覆盖默认设置 $options = array_merge($default_options, $input_options); //载入上传类 import("ORG.Net.UploadFile"); //初始化上传参数 $upload = new UploadFile($options['max_size'], $options['allow_exts'], $options['allow_types']); //设置上传路径 $upload->savePath = $options['save_path']; //启用子目录 $upload->autoSub = false; //保存的名字 $upload->saveName = $options['save_name']; //默认文件名规则 $upload->saveRule = $options['save_rule']; //是否缩略图 $upload->thumb = false; //创建目录 mkdir($upload->savePath, 0777, true); //执行上传操作 if (!$upload->upload()) { //上传失败,返回错误 $return['status'] = false; $return['info'] = $upload->getErrorMsg(); return $return; } else { $upload_info = $upload->getUploadFileInfo(); //如果同步保存照片 $uid = TS_D("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'] = $options['custom_path']; $map['savename'] = $u['savename']; //$map['savedomain']= C('ATTACH_SAVE_DOMAIN'); $result = $this->add($map); $map['id'] = $result; $infos[] = $map; } if (isset($options['save_photo'])) { $infos = $this->save_photo($options['save_photo'], $infos); } //输出信息 $return['status'] = true; $return['info'] = $infos; //上传成功,返回信息 return $return; } }
private function __feedTemplate($feeds) { //feed的icon $feedTemplateDao = TS_D("FeedTemplate"); foreach ($feeds as $fkey => $feed) { //不用额外处理的动态部分 $feed_output[$fkey]["type"] = $feed["type"]; $feed_output[$fkey]["id"] = $feed["id"]; $feed_output[$fkey]["cTime"] = $feed["cTime"]; $feed_output[$fkey]["uid"] = $feed["uid"]; //TODO 临时数据转换 $feed['title'] = $feed['title_data']; $feed['body'] = $feed['body_data']; unset($feed['title_data']); unset($feed['body_data']); $feed_template = $feedTemplateDao->where(array("type" => $feed['type']))->find(); $feed_output[$fkey]["title"] = $this->__getTitle($feed_template['title'], $feed); $body_template = $feed_template["body"]; //body的模板 if ($body_template) { $feed_output[$fkey]["body"] = $this->__getBody($body_template, $feed); } $feed_output[$fkey]['icon'] = getAppInfo($feed['appid'], 'APP_ICON'); } return $feed_output; }
private function __sendEmail($data, $uid, $toEmail) { //存储到数据库 $email = TS_D('SaveEmail'); $data = $this->__paramData($data['title'], $data['body'], $data['url']); $title = $data['title']; $content = $data['body']; $result = $email->saveEmail($toEmail, $title, $content, $uid, $name = '', $type = ''); return $result; }
public function getCommendUser($limit) { $opts = TS_D('Option')->get(); $map['commend'] = 1; $map['active'] = 1; //查找所有被推荐的用户id $uid_list = array(); $command_user = $this->where($map)->field('id')->limit('0,' . $limit)->order('rand()')->findAll(); foreach ($command_user as $value) { $result[] = $value['id']; } return $result; }
function _sendMessage($type, $aimId, $mid, $username, $data, $info, $fri_ids, $url, $result) { if (isset($data['content'])) { unset($data['content']); } $body_data = $data; if (!empty($aimId)) { $body_data['aimId'] = $aimId; } $body_data['typeId'] = $type['typeId']; $body_data['toUid'] = $mid; $body_data['toUserName'] = $username; $body_data['info'] = $info; $body_data['id'] = $result; $title_data['id'] = $result; if ($type['typeId'] == 10) { $body_data['username'] = getUserName($data['uid']); $userface = getUserFace($data['uid']); $body_data['userface'] = str_replace(SITE_URL, '{WR}', $userface); } $appid = TS_D('App')->getChoiceId('share'); TS_D('Feed')->publish("share_" . $type['alias'], $title_data, $body_data, $appid); $notifyDao = TS_D('Notify'); $notifyDao->setAppId($appid); $title_data['type'] = $type['typeName']; if (empty($url)) { $url = $this->_getURL($type['typeId'], $aimId, $data); } if (empty($url)) { $url = SITE_URL . '/apps/share/index.php?s=/Index/content/id/' . $result; } if (!empty($fri_ids)) { $notifyDao->send($fri_ids, "share_notice", $title_data, $body_data, $url); } $uid = $this->_getUid($data, $type); if (!empty($uid) && $uid != $mid) { $notifyDao->send($uid, "share_notice2", $title_data, $body_data, $url); } if ($type['typeId'] == 10) { $uid = $aimId; $notifyDao->send($uid, "share_notice3", $title_data, $body_data, $url); } }
function _sendMessage($content, $type, $mid, $fri_ids, $url) { $body_content['content'] = $this->_getcontent($content, $type, $mid); $appid = TS_D('App')->getChoiceId('wish'); //TS_D('Feed')->publish("wish_".$type,$title_content,$body_content,$appid); $notifyDao = TS_D('Notify'); $notifyDao->setAppId($appid); if (empty($url)) { $url = '{WR}/apps/wish/index.php?s=/Index/friends/uid/' . $mid; } if (!empty($fri_ids)) { $notifyDao->send($fri_ids, "wish_notice", '', $body_content, $url); } }
private function __paramMap($cate, $type) { if ($cate != "all") { $map = "cate = '" . $cate . "'"; } else { $map = "(cate = 'friend' OR cate = 'notification')"; } if ($type) { $map .= " AND type = '" . $type . "'"; } //只查我的 $mid = TS_D("User")->getLoggedInUser(); $map .= " AND uid = " . $mid; return $map; }
private function filterPrivacy($value) { //基本信息过滤 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 == TS_D('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; }
/** * 获取用户组图标 * $uid 用户ID */ function getUserGroupIcon($uid) { $groupId = TS_D('User')->where('id=' . $uid)->field('admin_level')->find(); if ($uid) { $info = TS_D('SystemGroup')->where("id='" . $groupId['admin_level'] . "'")->find(); if ($info['icon']) { return '<img src=' . __THEME__ . '/images/icon/groupicon/' . $info['icon'] . ' Alt="' . $info['showname'] . '" />'; } } }
foreach ($v as $kk => $vv) { if (!$vv) { $v[$kk] = "NULL"; } } echo "<tr>"; echo "<td>" . $v['id'] . "</td><td>" . $v['type'] . "</td><td>" . htmlspecialchars($v['title']) . "</td><td>" . htmlspecialchars($v['body']) . "</td>" . "<td><a href='?do=m&id=" . $v["id"] . "'>修改</a> <a href='javascript:del_feed(" . $v["id"] . ")'>删除</a></td>"; echo "</tr>"; } ?> </table> </center> <hr> <h3>2、已有Feed 模板举例</h3> <?php $feedDao = TS_D("Feed"); $feeds = $feedDao->findAll(); foreach ($feeds as $fkey => $feed) { $feed_template = $dao->where(array("type" => $feed['type']))->find(); /*------------------------------------- = title -------------------------------------*/ $feed_title = $feed_template["title"]; //title的模板 $title_data = unserialize(stripcslashes($feed["title_data"])); //title的数据 $actor = "<a href='space.php?" . $feed["uid"] . "'>" . $feed["username"] . '</a>'; $title_data["actor"] = $actor; foreach ($title_data as $k => $v) { //替换 $feed_title = str_replace('{' . $k . '}', $v, $feed_title);
public function getFriNum($uid = false, $gid = false) { if ($gid) { $map["gid"] = $gid; $map["uid"] = $uid; $r = TS_D("Fg")->where($map)->field("count(*) as num")->find(); return $r["num"]; } else { $map["uid"] = $uid; $r = $this->where($map)->field("count(*) as num")->find(); return $r["num"]; } // $map["uid"] = $uid?$uid:TS_D("User")->getLoggedInUser(); // $map["status"] = 1; // if($gid) $map["gid"] = $gid; // // $fris_num = $this->where($map)->field("count(*) as count")->find(); // return $fris_num["count"]; }