예제 #1
0
 /** 
  * 获得登录用户信息
  *
  * @return PwUserBo
  */
 public function getLoginUser()
 {
     if ($this->_loginUser === null) {
         $user = $this->_getLoginUser();
         $user->ip = Wind::getComponent('request')->getClientIp();
         $this->_loginUser = $user->uid;
         PwUserBo::pushUser($user);
     }
     return PwUserBo::getInstance($this->_loginUser);
 }
예제 #2
0
 /** 
  * 获得登录用户信息
  *
  * @return PwUserBo
  */
 public function getLoginUser()
 {
     if ($this->_loginUser === null) {
         $user = $this->_getLoginUser();
         $user->ip = $this->clientIp;
         $this->_loginUser = $user->uid;
         PwUserBo::pushUser($user);
     }
     return PwUserBo::getInstance($this->_loginUser);
 }
예제 #3
0
 public function run()
 {
     $rmbrate = $this->_conf[$this->_order['buy']]['rate'];
     !$rmbrate && ($rmbrate = 10);
     $num = round($this->_order['price'] * $rmbrate);
     Wind::import('SRV:credit.bo.PwCreditBo');
     /* @var $creditBo PwCreditBo */
     $creditBo = PwCreditBo::getInstance();
     $creditBo->addLog('olpay_credit', array($this->_order['buy'] => $num), PwUserBo::getInstance($this->_order['created_userid']), array('number' => $this->_order['price']));
     $creditBo->set($this->_order['created_userid'], $this->_order['buy'], $num);
     //发送通知
     $params = array();
     $params['change_type'] = 'pay';
     $params['credit'] = $creditBo->cType[$this->_order['buy']];
     $params['num'] = $num;
     $params['unit'] = $creditBo->cUnit[$this->_order['buy']];
     $params['price'] = $this->_order['price'];
     /* @var $notice PwNoticeService */
     $notice = Wekit::load('SRV:message.srv.PwNoticeService');
     $notice->sendNotice($this->_order['created_userid'], 'credit', $this->_order['created_userid'], $params);
 }
 /**
  * 发送推送消息
  */
 public function afterPush($pushid)
 {
     $extend = '';
     $pushDs = Wekit::load('design.PwDesignPush');
     $push = $pushDs->getPush($pushid);
     if (!$push) {
         return false;
     }
     $thread = Wekit::load('forum.PwThread')->getThread($push['push_from_id']);
     if (!$thread) {
         return false;
     }
     $info = unserialize($push['push_extend']);
     $standard = unserialize($push['push_standard']);
     $sTitle = $info[$standard['sTitle']];
     $sUrl = $info[$standard['sUrl']];
     $user = Wekit::load('SRV:user.PwUser')->getUserByUid($push['created_userid']);
     Wind::import('SRV:credit.bo.PwCreditBo');
     Wind::import('SRV:forum.bo.PwForumBo');
     $credit = PwCreditBo::getInstance();
     $operation = 'push_thread';
     $forum = new PwForumBo($thread['fid']);
     $credit->operate($operation, PwUserBo::getInstance($thread['created_userid']), true, array('forumname' => $forum->foruminfo['name']), $forum->getCreditSet($operation));
     $credit->execute();
     $strategy = $credit->getStrategy($operation);
     foreach ((array) $strategy['credit'] as $k => $v) {
         $v && ($extend .= $credit->cType[$k] . '+' . $v);
     }
     //$bo->sets($push['author_uid'], $credit['credit']);
     if ($push['neednotice']) {
         $content = '恭喜,您的帖子<a href="' . $sUrl . '">' . Pw::substrs($sTitle, 20) . '</a>被<a href="' . WindUrlHelper::createUrl('space/index/run', array('uid' => $push['created_userid']), '', 'pw') . '">' . $user['username'] . '</a>执行 推送 操作。';
         $extend && ($content .= '获得' . $extend);
         $title = '帖子《<a href="' . $sUrl . '">' . Pw::substrs($sTitle, 20) . '</a>》被推送';
         Wekit::load('SRV:message.srv.PwNoticeService')->sendDefaultNotice($push['author_uid'], $content, $title);
         $pushDs->updateNeedNotice($pushid, 0);
     }
     return true;
 }
예제 #5
0
 /**
  * 结果分析路由
  */
 public function routeAction()
 {
     $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName());
     $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession();
     $sessionData = $sessionInfo['sessiondata'];
     $refer = $sessionData['httpReferer'] ? $sessionData['httpReferer'] : $this->hostInfo;
     if (!$this->_getAccountTypeService()->checkType($sessionData['type'])) {
         $this->showError('登录类型错误,请重试');
     }
     if (!$sessionId || !$sessionInfo || !$sessionData['data']['user_id'] || !$sessionData['action']) {
         $this->showError('验证失败,请重试');
     }
     $url = $refer ? $refer : $this->hostInfo . Wind::getComponent('request')->getScriptUrl();
     $type_name = $this->_getAccountTypeService()->getTypeName($sessionData['type']);
     $msg_info = '使用' . $type_name . '账号认证通过(窗口将自动关闭)';
     if ($sessionData['action'] == 'bind') {
         //绑定流程
         $result = $this->_getAccountBindService()->bind($this->uid, $sessionData['data']['user_id'], $sessionData['type']);
         if ($result instanceof PwError) {
             $this->showError($result->getError());
         }
     } elseif ($sessionData['data']['isBound'] == 0 && $sessionData['action'] == 'login') {
         $sign = $sessionData['data']['sign'];
         //没有绑定社区账号 注册或者绑定
         $config = Wekit::C()->getValues('register');
         if ($config['type'] == 0) {
             //关闭注册,跳转到绑定设置页面
             $url = WindUrlHelper::createUrl('app/login/run', array('app' => 'account', 'sign' => $sign));
         } else {
             $url = WindUrlHelper::createUrl('app/register/run', array('app' => 'account', 'sign' => $sign));
         }
     } elseif ($sessionData['data']['isBound'] == 1 && $sessionData['action'] == 'login') {
         //进入登录 用户校验
         $uid = intval($sessionData['data']['bbs_uid']);
         Wind::import('SRV:user.bo.PwUserBo');
         $userBo = PwUserBo::getInstance($uid);
         if (!$userBo->isExists()) {
             //用户不存在
             $this->_getAccountBindDs()->deleteByUid($uid);
             $this->showError('绑定用户在站点已删除,请重试');
         }
         $pattern = '/m=u&c=login/i';
         if (preg_match($pattern, $url)) {
             $url = $this->_getCommonService()->getHost();
         }
         $userService = Wekit::load('user.srv.PwUserService');
         $userService->createIdentity($userBo->uid, $userBo->info['password']);
     }
     $this->setOutput($msg_info, 'msg_info');
     $this->setOutput($url, 'jumpurl');
     $this->setOutput(Wekit::app()->charset, 'charset');
     $this->setTemplate('login_notice');
 }
 /**
  * 发表帖子
  * @param int $tid
  * @param int $fid
  * @param string $subject
  * @param string $content
  * return bool
  */
 public function postThread($uid, $fid, $subject, $content)
 {
     list($uid, $fid, $subject, $content) = array(intval($uid), intval($fid), trim($subject), trim($content));
     if ($uid < 1 || $fid < 1 || !$subject || !$content) {
         return $this->buildResponse(THREAD_INVALID_PARAMS, "参数错误");
     }
     $user = PwUserBo::getInstance($uid);
     if (!$user->isExists()) {
         return $this->buildResponse(USER_NOT_EXISTS, "用户不存在");
     }
     Wind::import('SRV:forum.srv.PwPost');
     Wind::import('SRV:forum.srv.post.PwTopicPost');
     $postAction = new PwTopicPost($fid);
     $pwPost = new PwPost($postAction);
     $postDm = $pwPost->getDm();
     $postDm->setFid($fid)->setTitle($subject)->setContent($content)->setAuthor($uid, $user->username, $user->ip);
     if (($result = $pwPost->execute($postDm)) !== true) {
         $this->buildResponse(-1, $result->getError());
     }
     $tid = $pwPost->getNewId();
     return $this->buildResponse(0, array('tid' => $tid));
 }
예제 #7
0
 public function doDeletePostAction()
 {
     $pid = $this->getInput('pid');
     if (empty($pid)) {
         $this->showError('operate.select');
     }
     !is_array($pid) && ($pid = array($pid));
     Wind::import('SRV:forum.srv.operation.PwDeleteReply');
     Wind::import('SRV:forum.srv.dataSource.PwFetchReplyByPid');
     $deleteReply = new PwDeleteReply(new PwFetchReplyByPid($pid), PwUserBo::getInstance($this->loginUser->uid));
     $deleteReply->setIsDeductCredit(1)->execute();
     $this->showMessage('success');
 }
 private function _getUserBo()
 {
     Wind::import('SRV:user.bo.PwUserBo');
     return PwUserBo::getInstance($this->loginUser->uid);
 }
 /**
  * 获取对话消息列表
  *
  * @param int $dialogId
  * @param int $start
  * @param int $limit
  * @return array
  */
 public function getMessageAndReply($dialogId, $offset, $limit)
 {
     list($dialogId, $offset, $limit) = array(intval($dialogId), intval($offset), intval($limit));
     if ($dialogId < 1) {
         return $this->buildResponse(MESSAGE_INVALID_PARAMS);
     }
     list($count, $dialogResult) = $this->getPwMessageService()->getDialogMessageList($dialogId, $limit, $offset);
     if ($dialogResult instanceof PwError) {
         return $this->buildResponse(-1, $dialogResult->getError());
     }
     $result = array();
     $dialogResult = array_values($dialogResult);
     foreach ($dialogResult as $k => $v) {
         $result[$k]['messageid'] = $v['message_id'];
         $result[$k]['uid'] = $v['from_uid'];
         $result[$k]['username'] = PwUserBo::getInstance($v['uid'])->username;
         $result[$k]['icon'] = Pw::getAvatar($v['from_uid']);
         $result[$k]['postdate'] = $v['created_time'];
         $result[$k]['content'] = $v['content'];
         $result[$k]['id'] = $v['id'];
         //dialog和message的关系id
         $result[$k]['dialog_id'] = $dialogId;
         $result[$k]['is_read'] = $v['is_read'];
         $result[$k]['from_username'] = $v['from_username'];
     }
     return $this->buildResponse(0, array('count' => $count, 'dialog' => $result));
 }
 /**
  * 获取用户(A)在帖子(B)中的回复
  *
  * @param int $tid
  * @param int $uid
  * @param int $limit
  * @param int $offset
  * @return array
  */
 public function getPostByTidAndUid($tid, $uid, $offset, $limit)
 {
     list($uid, $tid, $offset, $limit) = array(intval($uid), intval($tid), intval($offset), intval($limit));
     $user = PwUserBo::getInstance($uid);
     if (!$user->username) {
         return $this->buildResponse(THREAD_USER_NOT_EXIST, "用户不存在");
     }
     $postResult = $this->_getThread()->getPostByTidAndUid($tid, $uid, $limit, $offset);
     if ($postResult instanceof PwError) {
         return $this->buildResponse(-1, $postResult->getError());
     }
     $postResult = array_values($postResult);
     $count = $this->_getThread()->countPostByTidAndUid($tid, $uid);
     $result = array();
     foreach ($postResult as $k => $v) {
         $result[$k]['pid'] = $v['pid'];
         $result[$k]['tid'] = $v['tid'];
         $result[$k]['author'] = $uid;
         $result[$k]['authorid'] = $user->username;
         $result[$k]['subject'] = $v['subject'];
         $result[$k]['postdate'] = $v['created_time'];
         $result[$k]['icon'] = Pw::getAvatar($uid);
         $result[$k]['content'] = $v['content'];
         $result[$k]['attachlist'] = '';
         $result[$k]['fid'] = $v['fid'];
     }
     return $this->buildResponse(0, array('count' => $count, 'posts' => $result));
 }
예제 #11
0
 /**
  * 用户相关操作
  */
 private function _operateUser()
 {
     $operation = $this->digest == 1 ? 'digest_topic' : 'remove_digest';
     $digestNum = $this->digest == 1 ? 1 : -1;
     Wind::import('SRV:credit.bo.PwCreditBo');
     Wind::import('SRV:forum.bo.PwForumBo');
     /* @var $userDs PwUser */
     $userDs = Wekit::load('user.PwUser');
     $credit = PwCreditBo::getInstance();
     foreach ($this->threads as $thread) {
         //更新用户精华数
         $userInfo = new PwUserInfoDm($thread['created_userid']);
         $userInfo->addDigest($digestNum);
         $userDs->editUser($userInfo, PwUser::FETCH_DATA);
         //更新用户积分
         $forum = new PwForumBo($thread['fid']);
         $credit->operate($operation, PwUserBo::getInstance($thread['created_userid']), true, array('forumname' => $forum->foruminfo['name']), $forum->getCreditSet($operation));
         $credit->execute();
     }
     return true;
 }
예제 #12
0
 /**
  * 获取用户的粉丝
  *
  * @param int $uid 用户id
  * @param int $limit
  * @param int $offset
  * @return array
  */
 public function getFanByUid($uid, $offset, $limit)
 {
     list($uid, $offset, $limit) = array(intval($uid), intval($offset), intval($limit));
     if ($uid < 1) {
         $this->buildResponse(Friend_INVALID_PARAMS);
     }
     $fansResult = $this->getAttention()->getFans($uid, $limit, $offset);
     if ($fansResult instanceof PwError) {
         return $this->buildResponse(-1, $fansResult->getError());
     }
     $result = array();
     $loginUid = Wekit::getLoginUser()->uid;
     foreach ($fansResult as $k => $v) {
         $result[$k]['uid'] = $v['uid'];
         $result[$k]['icon'] = Pw::getAvatar($v['uid']);
         $result[$k]['username'] = PwUserBo::getInstance($v['uid'])->username;
         $isFollowed = $this->getAttention()->isFollowed($loginUid, $v['uid']);
         $result[$k]['isfollowd'] = $isFollowed == false ? 0 : 1;
     }
     $user = PwUserBo::getInstance($uid);
     $count = $user->info['fans'];
     return $this->buildResponse(0, array('friends' => $result, 'count' => $count));
 }
예제 #13
0
 /**
  * 积分操作
  * 
  * @param array $value 帖子
  */
 protected function _operateCredit($value)
 {
     Wind::import('SRV:forum.bo.PwForumBo');
     $forum = new PwForumBo($value['fid']);
     PwCreditBo::getInstance()->operate('delete_topic', PwUserBo::getInstance($value['created_userid']), true, array('operator' => $this->srv->user->username, 'title' => $value['subject']), $forum->getCreditSet('delete_topic'));
 }
예제 #14
0
 private function __formUserData()
 {
     if (!isset($this->acceptData['username']) || !isset($this->acceptData['passwd'])) {
         echo "data is not ok";
         exit;
     }
     Wind::import('SRV:user.srv.PwLoginService');
     /*
     	PwLoginService()说明:只能使用5次
     	可以在:全局->注册登录->登录设置->密码尝试次数中修改
     */
     $login = new PwLoginService();
     $isSuccess = $login->login($this->acceptData['username'], $this->acceptData['passwd'], NULL);
     if ($isSuccess instanceof PwError) {
         $this->_echoError($isSuccess->getError()[0]);
     }
     $this->uid = $isSuccess['uid'];
     $this->__echoUserinfo();
     // dump($this->uid);
     // var_dump(  get_class_methods($login->login('taita','mm520131s4')));
     //
     // dump(get_class_methods($isSuccess));
     Wind::import("SRV:user.bo.PwUserBo");
     $pwUserBo = PwUserBo::getInstance($this->uid);
     if ($pwUserBo->uid == '0') {
         //检查uid合法性
         $this->_echoError('uid over');
     } else {
         /*需要与cookie交互  
         			$this->username=$this->loginUser->info['username'];      ×
         			$this->username=$this->loginUser->info['uid'];           ×
         		*/
         $this->avatarPath = Pw::getAvatar($this->uid);
         //获取头像 √
         $this->username = $pwUserBo->username;
         $this->uid = $pwUserBo->uid;
         $this->ip = $this->GetIP();
         $this->onlinetime = intval(intval($pwUserBo->info['onlinetime']) / 3600);
         $this->gid = intval($pwUserBo->info['groupid']);
         if (($group = Wekit::cache()->get('group', $this->gid)) === false) {
             $group = Wekit::cache()->get('group', 1);
         }
         $this->groupInfo = array('name' => $group['name'], 'type' => $group['type'], 'image' => $group['image'], 'points' => $group['points']);
         $this->permission = $group['permission'];
         // dump($this->groupInfo);
         // dump(get_class_methods(Pw));
         // dump($this);
         $this->echoData = array('uid' => $this->uid, 'username' => $this->username, 'avatarpath' => $this->avatarPath, 'ip' => $this->ip, 'onlinetime' => $this->onlinetime, 'gid' => $this->gid, 'groupinfo' => $this->groupInfo);
         // $this->_echoSuccess('获取用户信息成功');
     }
 }