/** * 添加版块、修改版块排序、修改版主等操作 * * @return void */ public function dorunAction() { $this->getRequest()->isPost() || $this->showError('operate.fail'); /** * 修改版块资料 */ list($vieworder, $manager) = $this->getInput(array('vieworder', 'manager'), 'post'); //TODO 添加:先判断这些会员里是否含有身份不符合的用户,用户组1(游客),2(禁止发言),6(未验证用户) $_tmpManager = explode(',', implode(',', array_unique($manager))); $result = Wekit::load('SRV:user.srv.PwUserMiscService')->filterForumManger($_tmpManager); if ($result instanceof PwError) { $this->showError($result->getError()); } $editArray = array(); Wind::import('SRV:forum.dm.PwForumDm'); foreach ($vieworder as $key => $value) { $dm = new PwForumDm($key); $dm->setVieworder($value)->setManager($manager[$key]); if (($result = $dm->beforeUpdate()) instanceof PwError) { $this->showError($result->getError(), 'bbs/setforum/run/'); } $editArray[] = $dm; } $pwForum = Wekit::load('forum.PwForum'); foreach ($editArray as $dm) { $pwForum->updateForum($dm, PwForum::FETCH_MAIN); } $forumset = array('allowtype' => array('default'), 'typeorder' => array('default' => 0)); /** * 在真实版块下,添加子版 */ list($new_vieworder, $new_forumname, $new_manager, $tempid) = $this->getInput(array('new_vieworder', 'new_forumname', 'new_manager', 'tempid'), 'post'); $newArray = array(); is_array($new_vieworder) || ($new_vieworder = array()); //判断公共账号所属的主分类是否存在 $configs = Wekit::C()->getValues('native'); $life_cid = isset($configs['forum.life_fid']) && $configs['forum.life_fid'] ? $configs['forum.life_fid'] : 0; $life_forums = array(); foreach ($new_vieworder as $parentid => $value) { foreach ($value as $key => $v) { if ($tempid[$parentid][$key] && $new_forumname[$parentid][$key]) { $dm = new PwForumDm(); $dm->setParentid($parentid)->setName($new_forumname[$parentid][$key])->setVieworder($v)->setManager($new_manager[$parentid][$key])->setBasicSetting($forumset); if (($result = $pwForum->addForum($dm)) instanceof PwError) { $this->showError($result->getError(), 'bbs/setforum/run/'); } $newArray[$tempid[$parentid][$key]] = $result; $life_cid && $life_cid == $parentid && ($life_forums[] = array('fid' => $result)); } } } $life_forums && Wekit::loadDao('native.dao.PwForumLifeDao')->batchAddForumLife($life_forums); /** * 在虚拟版块下,添加子版 */ list($temp_vieworder, $temp_forumname, $temp_manager) = $this->getInput(array('temp_vieworder', 'temp_forumname', 'temp_manager'), 'post'); is_array($temp_vieworder) || ($temp_vieworder = array()); ksort($temp_vieworder); foreach ($temp_vieworder as $key => $value) { if (!isset($newArray[$key])) { continue; } foreach ($value as $k => $v) { if ($tempid[$key][$k] && $temp_forumname[$key][$k]) { $dm = new PwForumDm(); $dm->setParentid($newArray[$key])->setName($temp_forumname[$key][$k])->setVieworder($v)->setManager($temp_manager[$key][$k])->setBasicSetting($forumset); if (($result = $pwForum->addForum($dm)) instanceof PwError) { $this->showError($result->getError(), 'bbs/setforum/run/'); } $newArray[$tempid[$key][$k]] = $result; } } } Wekit::load('forum.srv.PwForumMiscService')->correctData(); $this->showMessage('success', 'bbs/setforum/run/', true); }
/** * 批量更新版块信息 * * @param array $fids 版块id序列 * @param object $dm 更新信息 * @param int $fetchmode 版块资料 <必然为FETCH_*的一种或者组合> * return bool */ public function batchUpdateForum($fids, PwForumDm $dm, $fetchmode = self::FETCH_ALL) { if (empty($fids)) { return false; } if (($result = $dm->beforeUpdate()) !== true) { return $result; } return $this->_getDao($fetchmode)->batchUpdateForum($fids, $dm->getData(), $dm->getIncreaseData()); }