Exemplo n.º 1
0
 public function __construct(PwPost $pwpost, $postInfo, $content)
 {
     $this->user = $pwpost->user;
     $this->postDm = $pwpost->getDm();
     $this->postInfo = $postInfo;
     $this->content = $content;
 }
Exemplo n.º 2
0
 public function domarkAction()
 {
     list($_credits, $tid, $pid, $reason, $isreply) = $this->getInput(array('credits', 'tid', 'pid', 'reason', 'isreply'), 'post');
     if (!$_credits) {
         $this->showError('还未添加评分哦');
     }
     if (!$reason) {
         $this->showError('请输入评分理由');
     }
     $credits = array();
     foreach ($_credits as $k => $v) {
         $v && ($credits[$k] = $v);
     }
     //检查权限
     if (($result = $this->_checkMarkRight($tid, $pid)) instanceof PwError) {
         $this->showError($result->getError());
     }
     //检查积分权限
     if (($result = $this->_checkMarkCreditsRight($credits)) instanceof PwError) {
         $this->showError($result->getError());
     }
     // 积分处理
     if (($info = $this->setCredits($credits, $tid, $pid)) instanceof PwError) {
         $this->showError($info->getError());
     }
     Wind::import('EXT:mark.service.dm.App_Mark_RecordDm');
     $newIds = array();
     foreach ($credits as $k => $v) {
         $dm = new App_Mark_RecordDm();
         $dm->setTid($tid)->setPid($pid)->setCreatedUserid($this->loginUser->uid)->setCreatedUsername($this->loginUser->username)->setPingUserid($info['created_userid'])->setReason($reason)->setCtype($k)->setCnum($v);
         if (($result = $this->_getDs()->addRecord($dm)) instanceof PwError) {
             $this->showError($result->getError());
         }
         $result && is_numeric($result) && ($newIds[] = $result);
     }
     // 回复帖子
     if ($isreply) {
         Wind::import('SRV:forum.srv.PwPost');
         Wind::import('SRV:forum.srv.post.PwReplyPost');
         $rpid = $pid ? $pid : 0;
         $pwPost = new PwPost(new PwReplyPost($tid, $this->loginUser));
         $postDm = $pwPost->getDm();
         $postDm->setContent($reason)->setReplyPid($rpid);
         $pwPost->execute($postDm);
     }
     // 更新帖子
     $this->_updateThreadAddMark($credits, $newIds, $info);
     $this->showMessage('success');
 }
 /**
  * 发表帖子
  * @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));
 }
 /**
  * 发送回复
  * @param int $tid
  * @param int $uid
  * @param string $title
  * @param string $content
  * return bool
  */
 public function sendPost($tid, $uid, $title, $content)
 {
     list($uid, $tid, $title, $content) = array(intval($uid), intval($tid), trim($title), trim($content));
     if ($uid < 1 || $tid < 1 || !$content) {
         return $this->buildResponse(THREAD_INVALID_PARAMS, "参数错误");
     }
     if ($this->_getOnline()->isOnline($uid) !== true) {
         $this->buildResponse(USER_NOT_LOGIN, "用户没有登录");
     }
     Wind::import('SRV:forum.srv.PwPost');
     Wind::import('SRV:forum.srv.post.PwReplyPost');
     $postAction = new PwReplyPost($tid);
     $pwPost = new PwPost($postAction);
     $info = $pwPost->getInfo();
     $title == 'Re:' . $info['subject'] && ($title = '');
     $postDm = $pwPost->getDm();
     $postDm->setTitle($title)->setContent($content)->setAuthor($uid, $user->username, $user->ip);
     if (($result = $pwPost->execute($postDm)) !== true) {
         $this->buildResponse(-1, $result->getError());
     }
     $postId = $pwPost->getNewId();
     return $this->buildResponse(0, array('pid' => $postId));
 }
Exemplo n.º 5
0
 /**
  * 发送回复
  * @param int $tid
  * @param int $uid
  * @param string $title
  * @param string $content
  * return bool
  */
 public function sendPost($tid, $uid, $title, $content)
 {
     $userBo = new PwUserBo($uid);
     if (!$userBo->isExists()) {
         return $this->buildResponse(THREAD_USER_NOT_EXIST);
     }
     Wind::import('SRV:forum.srv.PwPost');
     Wind::import('SRV:forum.srv.post.PwReplyPost');
     $postAction = new PwReplyPost($tid);
     $pwPost = new PwPost($postAction);
     $info = $pwPost->getInfo();
     $title == 'Re:' . $info['subject'] && ($title = '');
     $postDm = $pwPost->getDm();
     $postDm->setTitle($title)->setContent($content)->setAuthor($uid, $userBo->username, $userBo->ip);
     if (($result = $pwPost->execute($postDm)) !== true) {
         $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }
 /**
  * 发表帖子
  * @param int $tid
  * @param int $fid
  * @param string $subject
  * @param string $content
  * return bool
  */
 public function postThread($uid, $fid, $subject, $content)
 {
     $userBo = new PwUserBo($uid);
     if (!$userBo->isExists()) {
         return $this->buildResponse(THREAD_USER_NOT_EXIST);
     }
     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, $userBo->username, $userBo->ip);
     if (($result = $pwPost->execute($postDm)) !== true) {
         $this->buildResponse(-1, $result->getError());
     }
     return $this->buildResponse(0, $result);
 }
Exemplo n.º 7
0
 /**
  * 安装完成
  */
 public function finishAction()
 {
     //Wekit::createapp('phpwind');
     Wekit::C()->reload('windid');
     WindidApi::api('user');
     $db = $this->_checkDatabase();
     //更新HOOK配置数据
     Wekit::load('hook.srv.PwHookRefresh')->refresh();
     //初始化站点config
     $site_hash = WindUtility::generateRandStr(8);
     $cookie_pre = WindUtility::generateRandStr(3);
     Wekit::load('config.PwConfig')->setConfig('site', 'hash', $site_hash);
     Wekit::load('config.PwConfig')->setConfig('site', 'cookie.pre', $cookie_pre);
     Wekit::load('config.PwConfig')->setConfig('site', 'info.mail', $db['founder']['manager_email']);
     Wekit::load('config.PwConfig')->setConfig('site', 'info.url', PUBLIC_URL);
     Wekit::load('nav.srv.PwNavService')->updateConfig();
     Wind::import('WINDID:service.config.srv.WindidConfigSet');
     $windidConfig = new WindidConfigSet('site');
     $windidConfig->set('hash', $site_hash)->set('cookie.pre', $cookie_pre)->flush();
     //风格默认数据
     Wekit::load('APPCENTER:service.srv.PwStyleInit')->init();
     //计划任务默认数据
     Wekit::load('cron.srv.PwCronService')->updateSysCron();
     //更新数据缓存
     /* @var $usergroup PwUserGroupsService */
     $usergroup = Wekit::load('SRV:usergroup.srv.PwUserGroupsService');
     $usergroup->updateLevelCache();
     $usergroup->updateGroupCache(range(1, 16));
     $usergroup->updateGroupRightCache();
     /* @var $emotion PwEmotionService */
     $emotion = Wekit::load('SRV:emotion.srv.PwEmotionService');
     $emotion->updateCache();
     //创始人配置
     $uid = $this->_writeFounder($db['founder']['manager'], $db['founder']['manager_pwd'], $db['founder']['manager_email']);
     //门户演示数据
     Wekit::load('SRV:design.srv.PwDesignDefaultService')->likeModule();
     Wekit::load('SRV:design.srv.PwDesignDefaultService')->tagModule();
     Wekit::load('SRV:design.srv.PwDesignDefaultService')->reviseDefaultData();
     //演示数据导入
     Wind::import('SRV:forum.srv.PwPost');
     Wind::import('SRV:forum.srv.post.PwTopicPost');
     $pwPost = new PwPost(new PwTopicPost(2, new PwUserBo($uid)));
     $threads = $this->_getDemoThreads();
     foreach ($threads as $thread) {
         $postDm = $pwPost->getDm();
         $postDm->setTitle($thread['title'])->setContent($thread['content']);
         $result = $pwPost->execute($postDm);
     }
     //全局缓存更新
     Wekit::load('SRV:cache.srv.PwCacheUpdateService')->updateConfig();
     Wekit::load('SRV:cache.srv.PwCacheUpdateService')->updateMedal();
     //清理安装过程的文件
     WindFile::write($this->_getInstallLockFile(), 'LOCKED');
     WindFile::del($this->_getTempFile());
     WindFile::del($this->_getTableLogFile());
     WindFile::del($this->_getTableSqlFile());
 }