Example #1
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');
		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");
	}
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");
 }