private function _updateForums($forum, $copyFids = array(), $copyItems = array()) { $mainFid = $forum->fid; $fids = array($mainFid); $copyFids && ($fids = array_merge($fids, $copyFids)); list($forumname, $vieworder, $parentid, $descrip, $isshow, $isshowsub, $jumpurl, $seotitle, $seokeywords, $seodescription, $numofthreadtitle, $threadperpage, $readperpage, $newtime, $threadorderby, $minlengthofcontent, $locktime, $edittime, $allowtype, $typeorder, $contentcheck, $ifthumb, $thumbwidth, $thumbheight, $anticopy, $copycontent, $water, $waterimg, $allowhide, $allowsell, $anonymous, $manager, $creditset, $password, $allowvisit, $allowread, $allowpost, $allowreply, $allowupload, $allowdownload, $style) = $this->getInput(array('forumname', 'vieworder', 'parentid', 'descrip', 'isshow', 'isshowsub', 'jumpurl', 'seotitle', 'seokeywords', 'seodescription', 'numofthreadtitle', 'threadperpage', 'readperpage', 'newtime', 'threadorderby', 'minlengthofcontent', 'locktime', 'edittime', 'allowtype', 'typeorder', 'contentcheck', 'ifthumb', 'thumbwidth', 'thumbheight', 'anticopy', 'copycontent', 'water', 'waterimg', 'allowhide', 'allowsell', 'anonymous', 'manager', 'creditset', 'password', 'allowvisit', 'allowread', 'allowpost', 'allowreply', 'allowupload', 'allowdownload', 'style')); Wind::import('SRV:forum.bo.PwForumBo'); Wind::import('SRV:forum.dm.PwForumDm'); $pwforum = Wekit::load('forum.PwForum'); $copyItems = $copyItems ? array_flip($copyItems) : array(); array_walk($copyItems, array($this, '_setCopyItems')); !$creditset && ($creditset = array()); foreach ($creditset as $key => $value) { !is_numeric($value['limit']) && ($creditset[$key]['limit'] = ''); foreach ($value['credit'] as $k => $v) { if (!is_numeric($v)) { $creditset[$key]['credit'][$k] = ''; } } } $misc = false; foreach ($fids as $fid) { $flag = $fid == $mainFid; $tmpforum = $flag ? $forum : new PwForumBo($fid, true); if (!$tmpforum->isForum(true)) { continue; } $isCate = $tmpforum->foruminfo['type'] == 'category'; $forumset = $tmpforum->forumset; ($flag || $copyItems['jumpurl']) && ($forumset['jumpurl'] = $jumpurl); ($flag || $copyItems['numofthreadtitle']) && ($forumset['numofthreadtitle'] = $numofthreadtitle ? intval($numofthreadtitle) : ''); ($flag || $copyItems['threadperpage']) && ($forumset['threadperpage'] = $threadperpage ? intval($threadperpage) : ''); ($flag || $copyItems['readperpage']) && ($forumset['readperpage'] = $readperpage ? intval($readperpage) : ''); ($flag || $copyItems['threadorderby']) && ($forumset['threadorderby'] = $threadorderby); if ($isCate) { $tmpParentid = 0; $creditset = array(); } else { $tmpParentid = $parentid; ($flag || $copyItems['minlengthofcontent']) && ($forumset['minlengthofcontent'] = $minlengthofcontent ? intval($minlengthofcontent) : ''); ($flag || $copyItems['locktime']) && ($forumset['locktime'] = $locktime ? intval($locktime) : ''); ($flag || $copyItems['edittime']) && ($forumset['edittime'] = $edittime ? intval($edittime) : ''); if ($flag || $copyItems['allowtype']) { $forumset['allowtype'] = is_array($allowtype) ? $allowtype : array(); $forumset['typeorder'] = array_map('intval', $typeorder); } if ($flag || $copyItems['allowhide']) { $forumset['allowhide'] = intval($allowhide); $forumset['allowsell'] = intval($allowsell); $forumset['anonymous'] = intval($anonymous); } ($flag || $copyItems['contentcheck']) && ($forumset['contentcheck'] = intval($contentcheck)); if ($flag || $copyItems['ifthumb']) { $forumset['ifthumb'] = intval($ifthumb); $forumset['thumbwidth'] = $thumbwidth ? intval($thumbwidth) : ''; $forumset['thumbheight'] = $thumbheight ? intval($thumbheight) : ''; } ($flag || $copyItems['water']) && ($forumset['water'] = intval($water)); ($flag || $copyItems['waterimg']) && ($forumset['waterimg'] = $waterimg); ($flag || $copyItems['anticopy']) && ($forumset['anticopy'] = intval($anticopy)); ($flag || $copyItems['copycontent']) && ($forumset['copycontent'] = $copycontent); //主题分类设置 list($topic_type, $force_topic_type, $topic_type_display) = $this->getInput(array('topic_type', 'force_topic_type', 'topic_type_display')); ($flag || $copyItems['topic_type']) && ($forumset['topic_type'] = intval($topic_type)); ($flag || $copyItems['force_topic_type']) && ($forumset['force_topic_type'] = intval($force_topic_type)); ($flag || $copyItems['topic_type_display']) && ($forumset['topic_type_display'] = intval($topic_type_display)); } $dm = new PwForumDm($fid); if ($flag) { $dm->setName($forumname)->setVieworder($vieworder)->setParentid($tmpParentid); //上传版块图标 $icon = $this->_uploadImage('icon', $fid); //上传版块logo $logo = $this->_uploadImage('logo', $fid); } if ($icon && ($flag || $copyItems['icon'])) { $dm->setIcon($icon['path']); } if ($logo && ($flag || $copyItems['logo'])) { $dm->setlogo($logo['path']); } ($flag || $copyItems['manager']) && $dm->setManager($manager); ($flag || $copyItems['descrip']) && $dm->setDescrip($descrip); ($flag || $copyItems['isshow']) && $dm->setIsshow($isshow); ($flag || $copyItems['across']) && $dm->setAcross($this->getInput('across')); ($flag || $copyItems['newtime']) && $dm->setNewtime($newtime); if ($flag || $copyItems['user_allows']) { $dm->setAllowVisit($allowvisit)->setAllowRead($allowread)->setAllowPost($allowpost)->setAllowReply($allowreply)->setAllowUpload($allowupload)->setAllowDownload($allowdownload); } ($flag || $copyItems['creditset']) && $dm->setCreditSetting($creditset); ($flag || $copyItems['style']) && $dm->setStyle($style); $dm->setBasicSetting($forumset); if ($password != '******' && ($flag || $copyItems['password'])) { $dm->setPassword($password); } elseif ($password == '******' && !$flag && $copyItems['password']) { $dm->setEncryptPassword($forum->foruminfo['password']); } $result = $pwforum->updateForum($dm); if ($result instanceof PwError) { $this->showError($result->getError()); } //($flag || $copyItems['topictype']) && $this->doeditTopicType($fid); if ($flag) { $this->doeditTopicType($fid); } else { if ($copyItems['topictype'] && !$flag) { Wekit::load('SRV:forum.srv.PwTopicTypeService')->copyTopicType($mainFid, $fid); } } //seo ($flag || $copyItems['seo']) && $this->_updateForumSeo($fid); //domain ($flag || $copyItems['forumdomain']) && $this->_updateForumDomain($tmpforum); if ($flag && $tmpforum->foruminfo['parentid'] != $tmpParentid) { Wekit::load('forum.srv.PwForumService')->updateForumStatistics($tmpParentid); Wekit::load('forum.srv.PwForumService')->updateForumStatistics($tmpforum->foruminfo['parentid']); $misc = true; } if ($flag && $forumname != $tmpforum->foruminfo['name']) { $misc = true; } if (($flag || $copyItems['manager']) && $manager != trim($tmpforum->foruminfo['manager'], ',')) { $misc = true; } } if ($misc) { Wekit::load('forum.srv.PwForumMiscService')->correctData(); } }
/** * 执行添加公共账号 * 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); }