예제 #1
0
 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();
     }
 }