/** * 添加版块、修改版块排序、修改版主等操作 * * @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); }
/** * 执行添加公共账号 * lyl */ public function doAddAction() { //判断公共账号所属的主分类是否存在 $configs = Wekit::C()->getValues('native'); $life_fid = isset($configs['forum.life_fid']) && $configs['forum.life_fid'] ? $configs['forum.life_fid'] : 0; Wind::import('SRV:forum.dm.PwForumDm'); $pwForum = Wekit::load('forum.PwForum'); $forumset = array('allowtype' => array('default'), 'typeorder' => array('default' => 0)); if (!$life_fid) { //尚未创建公共账号所属分类,自动创建 $dm = new PwForumDm(); $dm->setParentid(0)->setName('生活服务')->setVieworder(0)->setManager('')->setBasicSetting($forumset); if (($result = $pwForum->addForum($dm)) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } else { // var_dump($result); $life_fid = $result; $config = new PwConfigSet('native'); $config->set('forum.life_fid', $life_fid)->flush(); // var_dump($life_fid); } } if ($_FILES['logo']['size'] > 300000) { $this->showError("图片大小不能超过300k", 'native/life/run/', true); } // exit; //添加公共服务版面 $dm_life = new PwForumDm(); list($forumname, $manager, $vieworder, $descrip, $isshow, $url, $address) = $this->getInput(array('forumname', 'manager', 'vieworder', 'descrip', 'isshow', 'url', 'address'), 'post'); if (!$forumname) { $this->showError("商家名称不能为空", 'native/life/run/', true); } if (Pw::strlen($address) > 100) { $this->showError("商家地址不能超过100个汉字", 'native/life/run/', true); } $dm_life->setParentid($life_fid)->setName($forumname)->setVieworder($vieworder)->setManager($manager)->setDescrip($descrip)->setIsshow($isshow)->setBasicSetting($forumset); if (($result = $pwForum->addForum($dm_life)) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } $fid = $result; //上传版块logo $dm_life = new PwForumDm($fid); $logo = $this->_uploadImage('logo', $fid); $dm_life->setlogo($logo['path']); if (($result = $pwForum->updateForum($dm_life)) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } // Wekit::load('forum.srv.PwForumMiscService')->correctData(); $forumLifeDao = Wekit::loadDao('native.dao.PwForumLifeDao'); if (($result = $forumLifeDao->addForumLife(array('fid' => $fid, 'url' => $url, 'address' => $address))) instanceof PwError) { $this->showError($result->getError(), 'native/life/run/'); } $this->showMessage('success', 'native/life/run', true); }