/**
  * 需要从GET或者POST传入os,可以是android或者ios
  *
  */
 function __construct()
 {
     $_config = Wekit::C()->getValues('wukong');
     if (empty($_config) || !isset($_config['ios.appKey'])) {
         $_securityKey = Wekit::C()->getConfigByName('site', 'securityKey');
         $_config = self::saveAppekySetting($_securityKey['value']);
     }
     if (empty($_config)) {
         $info = Wekit::C()->getConfigByName('site', 'info.url');
         error_log('No laiwang info found for: ' . $info['value']);
         return;
     }
     // NOTE: 增加了os判断
     $os = isset($_POST['os']) ? $_POST['os'] : (isset($_GET['os']) ? $_GET['os'] : '');
     $os = strtolower($os);
     if (empty($os) || !in_array($os, array('android', 'ios'))) {
         $os = 'android';
     }
     $_config['appKey'] = $_config[$os . '.appKey'];
     self::$wk_appToken = $_config['appToken'];
     self::$wk_appSecret = $_config[$os . '.appSecret'];
     //
     unset($_config['android.appKey']);
     unset($_config['android.appSecret']);
     unset($_config['ios.appKey']);
     unset($_config['ios.appSecret']);
     unset($_config['appToken']);
     //
     self::$wk_setting = array_merge(self::$wk_setting, $_config);
 }
Example #2
0
 public function doaddAction()
 {
     $pageid = (int) $this->getInput('pageid', 'post');
     $moduleid = (int) $this->getInput('moduleid', 'post');
     $isnotice = (int) $this->getInput('isnotice', 'post');
     $fromid = (int) $this->getInput('fromid', 'post');
     $fromtype = $this->getInput('fromtype', 'post');
     $start = $this->getInput('start_time', 'post');
     $end = $this->getInput('end_time', 'post');
     /* 增加推送帖子到移动版start */
     if ($pageid === 0 && $moduleid === 0) {
         //推送移动端热帖
         $tid = (int) $this->getInput('tid');
         $tid || $this->showError("operate.fail");
         //                    $this->forwardRedirect(WindUrlHelper::createUrl('native/dynamic/sethot'));
         $threadsWeightDao = Wekit::loadDao('native.dao.PwThreadsWeightDao');
         //获取帖子最高权重,将其作为管理员推送帖子的初始权重置顶
         $weightData = $threadsWeightDao->getMaxWeight();
         isset($weightData['weight']) ? $max_weight = intval($weightData['weight']) + 1 : 1;
         //
         $data = array('create_time' => time(), 'weight' => $max_weight, 'create_userid' => $this->loginUser->uid, 'create_username' => $this->loginUser->username, 'tid' => $tid);
         $threadWeight = $threadsWeightDao->getByTid($tid);
         if ($threadWeight) {
             //更新数据
             $res = $threadsWeightDao->updateValue($data);
         } else {
             //新增数据
             $res = $threadsWeightDao->insertValue($data);
         }
         if ($res) {
             $thread = Wekit::load('forum.PwThread')->getThread($tid);
             $push_msg = '《' . $thread['subject'] . '》已被推荐热贴';
             Wekit::load("APPS:native.service.PwLaiWangSerivce");
             PwLaiWangSerivce::pushMessage($thread['created_userid'], $push_msg, $push_msg);
             //
             $this->showMessage('NATIVE:sethot.success');
         } else {
             $this->showMessage('NATIVE:sethot.failed');
         }
     }
     /* 增加推送帖子到移动版end */
     if ($moduleid < 1) {
         $this->showError("operate.fail");
     }
     $permiss = $this->_getPermissionsService()->getPermissionsForModule($this->loginUser->uid, $moduleid, $pageid);
     $pushService = $this->_getPushService();
     $data = $pushService->getDataByFromid($fromtype, $fromid);
     Wind::import('SRV:design.bo.PwDesignModuleBo');
     $bo = new PwDesignModuleBo($moduleid);
     $time = Pw::getTime();
     $startTime = $start ? Pw::str2time($start) : $time;
     $endTime = $end ? Pw::str2time($end) : $end;
     if ($end && $endTime < $time) {
         $this->showError("DESIGN:endtimd.error");
     }
     $pushDs = $this->_getPushDs();
     Wind::import('SRV:design.dm.PwDesignPushDm');
     $dm = new PwDesignPushDm();
     $dm->setFromid($fromid)->setModuleId($moduleid)->setCreatedUserid($this->loginUser->uid)->setCreatedTime($time)->setStartTime($startTime)->setEndTime($endTime)->setAuthorUid($data['uid']);
     if ($isnotice) {
         $dm->setNeedNotice(1);
     }
     if ($permiss <= PwDesignPermissions::NEED_CHECK) {
         $dm->setStatus(PwDesignPush::NEEDCHECK);
         $isdata = false;
     } else {
         $isdata = true;
     }
     $resource = $pushService->addPushData($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     if ($isdata) {
         $pushService->pushToData((int) $resource);
         $pushService->afterPush((int) $resource);
     }
     $this->showMessage("operate.success");
 }
 /**
  * 获得基本用户信息 
  * 
  * @param mixed $uid 
  * @access private
  * @return void
  */
 protected function _getUserInfo($laiwangOK = true)
 {
     //
     $_userInfo = $this->_getUserAllInfo(PwUser::FETCH_MAIN + PwUser::FETCH_INFO);
     //登录成功后,加密身份key
     $_idInfo = array('username' => $_userInfo['username'], 'password' => $_userInfo['password']);
     $securityKey = Pw::encrypt(serialize($_idInfo), $this->_securityKey);
     //laiwang
     $wk_setting = PwLaiWangSerivce::$wk_setting;
     $wk_setting['openid'] = $_userInfo['uid'];
     $wk_setting['secretToken'] = PwLaiWangSerivce::getSecretToken($_userInfo['uid'], $_userInfo['password']);
     // 是否已经成功同步用户到来往
     $wk_setting['laiwangOK'] = $laiwangOK;
     //返回数据
     $_data = array('securityKey' => $securityKey, 'userinfo' => array('uid' => $_userInfo['uid'], 'username' => $_userInfo['username'], 'avatar' => Pw::getAvatar($_userInfo['uid'], 'big'), 'gender' => $_userInfo['gender']), 'laiwangSetting' => $wk_setting);
     return $_data;
 }
 /**
  * send messages
  */
 protected function _sendMessage($action, $threads)
 {
     $userBo = new PwUserBo($this->uid);
     switch ($action) {
         case 'doban':
             foreach ($threads as $v) {
                 PwLaiWangSerivce::sendNotification($v['created_userid'], array('type' => 5, 'message' => '您被管理员 ' . $userBo->username . ' 禁止发帖了,同时您的头像、签名将不可见,如要申诉,请联系管理员。--系统消息,回复无效。'));
             }
             return;
             break;
         case 'dodelete_reply':
             foreach ($threads as $v) {
                 PwLaiWangSerivce::sendNotification($v['created_userid'], array('type' => 4, 'message' => "您有一个回帖被删除:\n" . mb_substr($v['content'], 0, 30)));
             }
             return;
             break;
     }
     if (!is_array($threads) || !$threads || !$action || $action == 'doban') {
         return false;
     }
     $noticeService = Wekit::load('message.srv.PwNoticeService');
     $reason = $this->getInput('reason');
     foreach ($threads as $thread) {
         $params = array();
         $params['manageUsername'] = $this->manage->user->username;
         $params['manageUserid'] = $this->manage->user->uid;
         $params['manageThreadTitle'] = $thread['subject'];
         $params['manageThreadId'] = $thread['tid'];
         //$this->params['_other']['reason'] && $params['manageReason'] = $this->params['_other']['reason'];
         $reason && ($params['manageReason'] = $reason);
         if ($action == 'docombined') {
             $actions = $this->getInput('actions');
             $tmp = array();
             foreach ($actions as $v) {
                 $tmp[] = $this->_getManageActionName('do' . $v);
             }
             $tmp && ($params['manageTypeString'] = implode(',', $tmp));
         } else {
             $params['manageTypeString'] = $this->_getManageActionName($action);
         }
         // laiwang
         PwLaiWangSerivce::sendNotification($thread['created_userid'], array('type' => 4, 'message' => '您的帖子《' . $params['manageThreadTitle'] . '》被管理员 ' . $userBo->username . ' 执行了删除操作。--系统消息,回复无效'));
         //
         $noticeService->sendNotice($thread['created_userid'], 'threadmanage', $thread['tid'], $params);
     }
 }
Example #5
0
 /**
  * 取消收藏 
  * 
  * @access public
  * @return void
  * @example
  * <pre>
  * /index.php?m=native&c=My&a=delCollect <br>
  * post|get : tid 
  * </pre>
  */
 public function delCollectAction()
 {
     $tid = intval($this->getInput('tid'));
     if ($this->_getCollectService()->delCollect($this->uid, $tid) !== false) {
         $thread = Wekit::load('forum.PwThread')->getThread($tid);
         PwLaiWangSerivce::sendNotification($thread['created_userid'], array('type' => 1, 'message' => '《' . $thread['subject'] . '》已被 ' . $this->userInfo['username'] . ' 取消收藏。--系统消息,回复无效。'));
         //
         $this->showMessage('success');
     }
     $this->showError('fail');
 }
 /**
 * 管理员设置最热帖子
 * @access public
 * @return void
  <pre>
  /index.php?m=native&c=dynamic&a=sethot&_json=1
  post: tid=1&starttime=2011-1-1&endtime=2016-1-1
  response: {err:"",data:""}
  </pre>
 */
 public function setHotAction()
 {
     $tid = $this->getInput('tid');
     $tid = (int) $tid;
     if ($this->uid && $tid && array_search(3, $this->loginUser->groups) !== false) {
         $threadsWeightDao = Wekit::loadDao('native.dao.PwThreadsWeightDao');
         //获取帖子最高权重,将其作为管理员推送帖子的初始权重置顶
         $weightData = $threadsWeightDao->getMaxWeight();
         isset($weightData['weight']) ? $max_weight = intval($weightData['weight']) + 1 : 1;
         //
         $data = array('create_time' => time(), 'weight' => $max_weight, 'create_userid' => $this->uid, 'create_username' => $this->loginUser->username, 'tid' => $tid);
         $threadWeight = $threadsWeightDao->getByTid($tid);
         if ($threadWeight) {
             //更新数据
             $res = $threadsWeightDao->updateValue($data);
         } else {
             //新增数据
             $res = $threadsWeightDao->insertValue($data);
         }
         if ($res) {
             $thread = Wekit::load('forum.PwThread')->getThread($tid);
             $push_msg = '《' . $thread['subject'] . '》已被推荐热贴';
             PwLaiWangSerivce::pushMessage($thread['created_userid'], $push_msg, $push_msg);
             //
             $this->showMessage('NATIVE:sethot.success');
         } else {
             $this->showMessage('NATIVE:sethot.failed');
         }
     } else {
         //传参有误
         $this->showError('NATIVE:args.error');
     }
     $this->showError('fail');
 }
 /**
  * (non-PHPdoc)
  * @see WindController::run()
  */
 public function run()
 {
     $config = PwLaiWangSerivce::getNotifier();
     $this->setOutput($config, 'config');
 }
Example #8
0
 /**
 * 回复帖子;回复回帖;回复回复
 * @access public
 * @return string
 * @example
 <pre>
 直接回复时参数状态:/index.php?m=native&c=post&a=doreply&_getHtml=1
 点击喜欢后顺便回复时参数状态:/index.php?m=native&c=post&a=doreply&fid=分类id
 ( _getHtml: 1表示回复帖子;2表示回复回帖 | )
 post(回复帖子): tid&atc_content&created_address&area_code
 post(回复回帖、回复回复->相当于在本楼层回帖): tid&pid&atc_content&created_address&area_code
 post(在点喜欢的时候顺便回复内容):tid&pid&atc_content&created_address&area_code&from_type=like
 cookie:usersession
 response: {err:"",data:""}  
 </pre>
 */
 public function doreplyAction()
 {
     $tid = $this->getInput('tid');
     list($title, $content, $hide, $rpid, $created_address, $area_code) = $this->getInput(array('atc_title', 'atc_content', 'hide', 'pid', 'created_address', 'area_code'), 'post');
     $_getHtml = $this->getInput('_getHtml', 'get');
     $this->runHook('c_post_run', $this->post);
     $this->runHook('c_post_doreply', $this->post);
     $info = $this->post->getInfo();
     $title == 'Re:' . $info['subject'] && ($title = '');
     if ($rpid) {
         //回复一个回帖
         $post = Wekit::load('thread.PwThread')->getPost($rpid);
         if ($post && $post['tid'] == $tid && $post['ischeck']) {
             $post['content'] = $post['ifshield'] ? '此帖已被屏蔽' : trim(Pw::stripWindCode(preg_replace('/\\[quote(=.+?\\,\\d+)?\\].*?\\[\\/quote\\]/is', '', $post['content'])));
             $post['content'] && ($content = '[quote=' . $post['created_username'] . ',' . $rpid . ']' . Pw::substrs($post['content'], 120) . '[/quote] ' . $content);
         } else {
             //回复主贴
             $rpid = 0;
         }
     }
     $postDm = $this->post->getDm();
     $postDm->setTitle($title)->setContent($content)->setHide($hide)->setReplyPid($rpid);
     if (($result = $this->post->execute($postDm)) !== true) {
         $data = $result->getData();
         $data && $this->addMessage($data, 'data');
         $this->showError($result->getError());
     }
     $pid = $this->post->getNewId();
     //记录回帖位置信息
     $data = array('pid' => $pid, 'created_address' => $created_address, 'area_code' => $area_code);
     $res = Wekit::loadDao('native.dao.PwPostsPlaceDao')->insertValue($data);
     // 发送通知
     // 关于type请查看sendNotification的注释
     // 如果自己回复了自己的帖子,则不发送通知
     if ($info['created_userid'] != $this->uid) {
         PwLaiWangSerivce::sendNotification($info['created_userid'], array('type' => $rpid > 0 ? 3 : 2, 'message' => $rpid > 0 ? $this->loginUser->info['username'] . " 评论了您的回帖:\n" . $content : $this->loginUser->info['username'] . ' 评论了您的帖子《' . $info['subject'] . "》:\n" . $content, 'url' => $rpid > 0 ? 'read' : 'read', 'arg' => $rpid > 0 ? array((string) $tid) : array((string) $tid)));
     }
     //
     $this->showMessage('success');
 }
Example #9
0
 /**
  * 检测一个openid在悟空是否注册
  *
  * @access public
  * @return void
  * @example
  * <pre>
  * /index.php?m=native&c=user&a=checkLaiwangUser&uid=1
  * </pre>
  */
 public function checkLaiwangUserAction()
 {
     $openid = $this->getInput('uid');
     $result = PwLaiWangSerivce::selectProfile($openid);
     //
     $this->setOutput($result ? '1' : '0', 'data');
     $this->showMessage('success');
 }