Пример #1
0
 private function _handleImportKbArticle($xml)
 {
     static $categoryList = NULL;
     static $categoryMap = NULL;
     $title = (string) $xml->title;
     $created = intval((string) $xml->created_date);
     $content_b64 = (string) $xml->content;
     // Bad file
     if (empty($content_b64) || empty($title)) {
         return false;
     }
     if (NULL == $categoryMap || NULL == $categoryList) {
         $categoryList = DAO_KbCategory::getWhere();
         $categoryMap = DAO_KbCategory::getTreeMap();
     }
     // Handle multiple <categories> elements
     $categoryIds = array();
     foreach ($xml->categories as $eCategories) {
         $pid = 0;
         $ptr =& $categoryMap[$pid];
         $categoryId = 0;
         foreach ($eCategories->category as $eCategory) {
             $catName = (string) $eCategory;
             //			echo "Looking for '", $catName, "' under $pid ...<br>";
             if (NULL == ($categoryId = $this->_getCategoryChildByName($categoryList, $ptr, $catName))) {
                 $fields = array(DAO_KbCategory::NAME => $catName, DAO_KbCategory::PARENT_ID => $pid);
                 $categoryId = DAO_KbCategory::create($fields);
                 //				echo " - Not found, inserted as $categoryId<br>";
                 $categoryList[$categoryId] = DAO_KbCategory::get($categoryId);
                 if (!isset($categoryMap[$pid])) {
                     $categoryMap[$pid] = array();
                 }
                 $categoryMap[$pid][$categoryId] = 0;
                 $categoryMap[$categoryId] = array();
                 $categoryIds[] = $categoryId;
             } else {
                 $categoryIds[] = $categoryId;
                 //				echo " - Found at $categoryId !<br>";
             }
             $pid = $categoryId;
             $ptr =& $categoryMap[$categoryId];
         }
     }
     // Decode content
     $content = base64_decode($content_b64);
     // [TODO] Dupe check?  (title in category)
     $fields = array(DAO_KbArticle::TITLE => $title, DAO_KbArticle::UPDATED => $created, DAO_KbArticle::FORMAT => 1, DAO_KbArticle::CONTENT_RAW => $content, DAO_KbArticle::CONTENT => $content, DAO_KbArticle::VIEWS => 0);
     if (null !== ($articleId = DAO_KbArticle::create($fields))) {
         DAO_KbArticle::setCategories($articleId, $categoryIds, false);
         return true;
     }
     return false;
 }
Пример #2
0
Файл: kb.php Проект: Hildy/cerb5
 function configure(Model_CommunityTool $instance)
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(dirname(__FILE__))) . '/templates/';
     // Knowledgebase
     $tree_map = DAO_KbCategory::getTreeMap();
     $tpl->assign('tree_map', $tree_map);
     $levels = DAO_KbCategory::getTree(0);
     $tpl->assign('levels', $levels);
     $categories = DAO_KbCategory::getWhere();
     $tpl->assign('categories', $categories);
     $sKbRoots = DAO_CommunityToolProperty::get($instance->code, self::PARAM_KB_ROOTS, '');
     $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
     $tpl->assign('kb_roots', $kb_roots);
     $tpl->display("file:{$tpl_path}portal/sc/config/kb.tpl");
 }
Пример #3
0
 function replyAction()
 {
     @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0));
     @($is_forward = DevblocksPlatform::importGPC($_REQUEST['forward'], 'integer', 0));
     $settings = CerberusSettings::getInstance();
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $tpl->assign('id', $id);
     $tpl->assign('is_forward', $is_forward);
     $message = DAO_Ticket::getMessage($id);
     $tpl->assign('message', $message);
     $ticket = DAO_Ticket::getTicket($message->ticket_id);
     $tpl->assign('ticket', $ticket);
     // ReplyToolbarItem Extensions
     $replyToolbarItems = DevblocksPlatform::getExtensions('cerberusweb.reply.toolbaritem', true);
     if (!empty($replyToolbarItems)) {
         $tpl->assign('reply_toolbaritems', $replyToolbarItems);
     }
     // Show attachments for forwarded messages
     if ($is_forward) {
         $forward_attachments = $message->getAttachments();
         $tpl->assign('forward_attachments', $forward_attachments);
     }
     $workers = DAO_Worker::getAllActive();
     $tpl->assign('workers', $workers);
     $teams = DAO_Group::getAll();
     $tpl->assign('teams', $teams);
     $team_categories = DAO_Bucket::getTeams();
     $tpl->assign('team_categories', $team_categories);
     @($ticket_team = $teams[$ticket->team_id]);
     if (null != ($worker = CerberusApplication::getActiveWorker())) {
         /* @var $worker CerberusWorker */
         /* [JAS]:
          * If the worker is replying to an unassigned ticket, assign it to them to warn
          * other workers.  By default the 'next worker' followup propery will revert back 
          * to 'anybody' when desired.
          * 
          * We're intentionally not telling the template about the new owner.
          */
         if (0 == $ticket->next_worker_id) {
             DAO_Ticket::updateTicket($ticket->id, array(DAO_Ticket::NEXT_WORKER_ID => $worker->id));
         }
         // Signatures
         if (!empty($ticket_team) && !empty($ticket_team->signature)) {
             $signature = $ticket_team->signature;
         } else {
             // [TODO] Default signature
             $signature = $settings->get(CerberusSettings::DEFAULT_SIGNATURE);
         }
         $tpl->assign('signature', str_replace(array('#first_name#', '#last_name#', '#title#'), array($worker->first_name, $worker->last_name, $worker->title), $signature));
         $signature_pos = $settings->get(CerberusSettings::DEFAULT_SIGNATURE_POS, 0);
         $tpl->assign('signature_pos', $signature_pos);
     }
     $tpl->assign('upload_max_filesize', ini_get('upload_max_filesize'));
     $kb_topics = DAO_KbCategory::getWhere(sprintf("%s = %d", DAO_KbCategory::PARENT_ID, 0));
     $tpl->assign('kb_topics', $kb_topics);
     $tpl->cache_lifetime = "0";
     $tpl->display('file:' . $this->_TPL_PATH . 'display/rpc/reply.tpl');
 }
Пример #4
0
 function writeResponse(DevblocksHttpResponse $response)
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(__FILE__)) . '/templates/';
     $theme = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_THEME, UmScApp::DEFAULT_THEME);
     if (!is_dir($tpl_path . 'portal/sc/themes/' . $theme)) {
         $theme = UmScApp::DEFAULT_THEME;
     }
     $umsession = $this->getSession();
     $active_user = $umsession->getProperty('sc_login', null);
     $stack = $response->path;
     @($module = array_shift($stack));
     switch ($module) {
         default:
         case 'home':
             $sHomeRss = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_HOME_RSS, '');
             $aHomeRss = !empty($sHomeRss) ? unserialize($sHomeRss) : array();
             $feeds = array();
             // [TODO] Implement a feed cache so we aren't bombing out
             foreach ($aHomeRss as $title => $url) {
                 $feed = null;
                 try {
                     $feed = Zend_Feed::import($url);
                 } catch (Exception $e) {
                 }
                 if (!empty($feed) && $feed->count()) {
                     $feeds[] = array('name' => $title, 'feed' => $feed);
                 }
             }
             $tpl->assign('feeds', $feeds);
             $tpl->display("file:{$tpl_path}portal/sc/internal/home/index.tpl");
             break;
         case 'account':
             if (!$this->allow_logins || empty($active_user)) {
                 break;
             }
             $address = DAO_Address::get($active_user->id);
             $tpl->assign('address', $address);
             $tpl->display("file:{$tpl_path}portal/sc/internal/account/index.tpl");
             break;
         case 'kb':
             // KB Roots
             $sKbRoots = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_KB_ROOTS, '');
             $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
             $kb_roots_str = '0';
             if (!empty($kb_roots)) {
                 $kb_roots_str = implode(',', array_keys($kb_roots));
             }
             switch (array_shift($stack)) {
                 case 'article':
                     if (empty($kb_roots)) {
                         return;
                     }
                     $id = intval(array_shift($stack));
                     list($articles, $count) = DAO_KbArticle::search(array(new DevblocksSearchCriteria(SearchFields_KbArticle::ID, '=', $id), new DevblocksSearchCriteria(SearchFields_KbArticle::TOP_CATEGORY_ID, 'in', array_keys($kb_roots))), -1, 0, null, null, false);
                     if (!isset($articles[$id])) {
                         break;
                     }
                     $article = DAO_KbArticle::get($id);
                     $tpl->assign('article', $article);
                     @($article_list = $umsession->getProperty(UmScApp::SESSION_ARTICLE_LIST, array()));
                     if (!empty($article) && !isset($article_list[$id])) {
                         DAO_KbArticle::update($article->id, array(DAO_KbArticle::VIEWS => ++$article->views));
                         $article_list[$id] = $id;
                         $umsession->setProperty(UmScApp::SESSION_ARTICLE_LIST, $article_list);
                     }
                     $categories = DAO_KbCategory::getWhere();
                     $tpl->assign('categories', $categories);
                     $cats = DAO_KbArticle::getCategoriesByArticleId($id);
                     $breadcrumbs = array();
                     foreach ($cats as $cat_id) {
                         if (!isset($breadcrumbs[$cat_id])) {
                             $breadcrumbs[$cat_id] = array();
                         }
                         $pid = $cat_id;
                         while ($pid) {
                             $breadcrumbs[$cat_id][] = $pid;
                             $pid = $categories[$pid]->parent_id;
                         }
                         $breadcrumbs[$cat_id] = array_reverse($breadcrumbs[$cat_id]);
                         // Remove any breadcrumbs not in this SC profile
                         $pid = reset($breadcrumbs[$cat_id]);
                         if (!isset($kb_roots[$pid])) {
                             unset($breadcrumbs[$cat_id]);
                         }
                     }
                     $tpl->assign('breadcrumbs', $breadcrumbs);
                     $tpl->display("file:{$tpl_path}portal/sc/internal/kb/article.tpl");
                     break;
                 default:
                 case 'browse':
                     @($root = intval(array_shift($stack)));
                     $tpl->assign('root_id', $root);
                     $categories = DAO_KbCategory::getWhere();
                     $tpl->assign('categories', $categories);
                     $tree_map = DAO_KbCategory::getTreeMap(0);
                     // Remove other top-level categories
                     if (is_array($tree_map[0])) {
                         foreach ($tree_map[0] as $child_id => $count) {
                             if (!isset($kb_roots[$child_id])) {
                                 unset($tree_map[0][$child_id]);
                             }
                         }
                     }
                     // Remove empty categories
                     if (is_array($tree_map[0])) {
                         foreach ($tree_map as $node_id => $children) {
                             foreach ($children as $child_id => $count) {
                                 if (empty($count)) {
                                     @($pid = $categories[$child_id]->parent_id);
                                     unset($tree_map[$pid][$child_id]);
                                     unset($tree_map[$child_id]);
                                 }
                             }
                         }
                     }
                     $tpl->assign('tree', $tree_map);
                     // Breadcrumb // [TODO] API-ize inside Model_KbTree ?
                     $breadcrumb = array();
                     $pid = $root;
                     while (0 != $pid) {
                         $breadcrumb[] = $pid;
                         $pid = $categories[$pid]->parent_id;
                     }
                     $tpl->assign('breadcrumb', array_reverse($breadcrumb));
                     $tpl->assign('mid', @intval(ceil(count($tree_map[$root]) / 2)));
                     // Articles
                     if (!empty($root)) {
                         list($articles, $count) = DAO_KbArticle::search(array(new DevblocksSearchCriteria(SearchFields_KbArticle::CATEGORY_ID, '=', $root), new DevblocksSearchCriteria(SearchFields_KbArticle::TOP_CATEGORY_ID, 'in', array_keys($kb_roots))), -1, 0, null, null, false);
                     }
                     $tpl->assign('articles', $articles);
                     $tpl->display("file:{$tpl_path}portal/sc/internal/kb/index.tpl");
                     break;
             }
             break;
         case 'answers':
             $query = rawurldecode(array_shift($stack));
             $tpl->assign('query', $query);
             $sFnrSources = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_FNR_SOURCES, '');
             $aFnrSources = !empty($sFnrSources) ? unserialize($sFnrSources) : array();
             if (!empty($query)) {
                 // [JAS]: If we've been customized with specific sources, use them
                 $where = !empty($aFnrSources) ? sprintf("%s IN (%s)", DAO_FnrExternalResource::ID, implode(',', array_keys($aFnrSources))) : sprintf("%s IN (-1)", DAO_FnrExternalResource::ID);
                 $resources = DAO_FnrExternalResource::getWhere($where);
                 $feeds = Model_FnrExternalResource::searchResources($resources, $query);
                 $tpl->assign('feeds', $feeds);
                 $fields = array(DAO_FnrQuery::QUERY => $query, DAO_FnrQuery::CREATED => time(), DAO_FnrQuery::SOURCE => $this->getPortal(), DAO_FnrQuery::NO_MATCH => empty($feeds) ? 1 : 0);
                 DAO_FnrQuery::create($fields);
             }
             // KB
             $sKbRoots = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_KB_ROOTS, '');
             $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
             list($articles, $count) = DAO_KbArticle::search(array(array(DevblocksSearchCriteria::GROUP_OR, new DevblocksSearchCriteria(SearchFields_KbArticle::TITLE, 'fulltext', $query), new DevblocksSearchCriteria(SearchFields_KbArticle::CONTENT, 'fulltext', $query)), new DevblocksSearchCriteria(SearchFields_KbArticle::TOP_CATEGORY_ID, 'in', array_keys($kb_roots))), 100, 0, null, null, true);
             $tpl->assign('articles', $articles);
             $tpl->display("file:{$tpl_path}portal/sc/internal/answers/index.tpl");
             break;
         case 'contact':
             $response = array_shift($stack);
             $settings = CerberusSettings::getInstance();
             $default_from = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM);
             $tpl->assign('default_from', $default_from);
             switch ($response) {
                 case 'confirm':
                     $tpl->assign('last_opened', $umsession->getProperty('support.write.last_opened', ''));
                     $tpl->display("file:{$tpl_path}portal/sc/internal/contact/confirm.tpl");
                     break;
                 default:
                 case 'step1':
                     $umsession->setProperty('support.write.last_error', null);
                 case 'step2':
                     $sFrom = $umsession->getProperty('support.write.last_from', '');
                     $sSubject = $umsession->getProperty('support.write.last_subject', '');
                     $sNature = $umsession->getProperty('support.write.last_nature', '');
                     $sContent = $umsession->getProperty('support.write.last_content', '');
                     //		    			$aLastFollowupQ = $umsession->getProperty('support.write.last_followup_q','');
                     $aLastFollowupA = $umsession->getProperty('support.write.last_followup_a', '');
                     $sError = $umsession->getProperty('support.write.last_error', '');
                     $tpl->assign('last_from', $sFrom);
                     $tpl->assign('last_subject', $sSubject);
                     $tpl->assign('last_nature', $sNature);
                     $tpl->assign('last_content', $sContent);
                     //						$tpl->assign('last_followup_q', $aLastFollowupQ);
                     $tpl->assign('last_followup_a', $aLastFollowupA);
                     $tpl->assign('last_error', $sError);
                     $sDispatch = DAO_CommunityToolProperty::get($this->getPortal(), UmScApp::PARAM_DISPATCH, '');
                     //		    			$dispatch = !empty($sDispatch) ? (is_array($sDispatch) ? unserialize($sDispatch): array($sDispatch)) : array();
                     $dispatch = !empty($sDispatch) ? unserialize($sDispatch) : array();
                     $tpl->assign('dispatch', $dispatch);
                     switch ($response) {
                         default:
                             // If there's only one situation, skip to step2
                             if (1 == count($dispatch)) {
                                 @($sNature = md5(key($dispatch)));
                                 $umsession->setProperty('support.write.last_nature', $sNature);
                                 reset($dispatch);
                             } else {
                                 $tpl->display("file:{$tpl_path}portal/sc/internal/contact/step1.tpl");
                                 break;
                             }
                         case 'step2':
                             // Cache along with answers?
                             if (is_array($dispatch)) {
                                 foreach ($dispatch as $k => $v) {
                                     if (md5($k) == $sNature) {
                                         $umsession->setProperty('support.write.last_nature_string', $k);
                                         $tpl->assign('situation', $k);
                                         $tpl->assign('situation_params', $v);
                                         break;
                                     }
                                 }
                             }
                             $ticket_fields = DAO_CustomField::getBySource('cerberusweb.fields.source.ticket');
                             $tpl->assign('ticket_fields', $ticket_fields);
                             $tpl->display("file:{$tpl_path}portal/sc/internal/contact/step2.tpl");
                             break;
                     }
                     break;
             }
             break;
             //				$tpl->display("file:${tpl_path}portal/sc/internal/contact/index.tpl");
             //				break;
         //				$tpl->display("file:${tpl_path}portal/sc/internal/contact/index.tpl");
         //				break;
         case 'history':
             if (!$this->allow_logins || empty($active_user)) {
                 break;
             }
             $mask = array_shift($stack);
             if (empty($mask)) {
                 list($open_tickets) = DAO_Ticket::search(array(), array(new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_WROTE_ID, '=', $active_user->id), new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', 0)), -1, 0, SearchFields_Ticket::TICKET_UPDATED_DATE, false, false);
                 $tpl->assign('open_tickets', $open_tickets);
                 list($closed_tickets) = DAO_Ticket::search(array(), array(new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_WROTE_ID, '=', $active_user->id), new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', 1)), -1, 0, SearchFields_Ticket::TICKET_UPDATED_DATE, false, false);
                 $tpl->assign('closed_tickets', $closed_tickets);
                 $tpl->display("file:{$tpl_path}portal/sc/internal/history/index.tpl");
             } else {
                 // Secure retrieval (address + mask)
                 list($tickets) = DAO_Ticket::search(array(), array(new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_MASK, '=', $mask), new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_WROTE_ID, '=', $active_user->id)), 1, 0, null, null, false);
                 $ticket = array_shift($tickets);
                 // Security check (mask compare)
                 if (0 == strcasecmp($ticket[SearchFields_Ticket::TICKET_MASK], $mask)) {
                     $messages = DAO_Ticket::getMessagesByTicket($ticket[SearchFields_Ticket::TICKET_ID]);
                     $messages = array_reverse($messages, true);
                     $tpl->assign('ticket', $ticket);
                     $tpl->assign('messages', $messages);
                     $tpl->display("file:{$tpl_path}portal/sc/internal/history/display.tpl");
                 }
             }
             break;
         case 'register':
             if (!$this->allow_logins) {
                 break;
             }
             @($step = array_shift($stack));
             switch ($step) {
                 case 'forgot':
                     $tpl->display("file:{$tpl_path}portal/sc/internal/register/forgot.tpl");
                     break;
                 case 'forgot2':
                     $tpl->display("file:{$tpl_path}portal/sc/internal/register/forgot_confirm.tpl");
                     break;
                 case 'confirm':
                     $tpl->display("file:{$tpl_path}portal/sc/internal/register/confirm.tpl");
                     break;
                 default:
                     $tpl->display("file:{$tpl_path}portal/sc/internal/register/index.tpl");
                     break;
             }
             break;
     }
     //		print_r($response);
 }
Пример #5
0
 function renderCriteriaParam($param)
 {
     $field = $param->field;
     $values = !is_array($param->value) ? array($param->value) : $param->value;
     switch ($field) {
         case SearchFields_KbArticle::TOP_CATEGORY_ID:
             $topics = DAO_KbCategory::getWhere(sprintf("%s = %d", DAO_KbCategory::PARENT_ID, 0));
             $strings = array();
             foreach ($values as $val) {
                 if (0 == $val) {
                     $strings[] = "None";
                 } else {
                     if (!isset($topics[$val])) {
                         continue;
                     }
                     $strings[] = $topics[$val]->name;
                 }
             }
             echo implode(", ", $strings);
             break;
         default:
             parent::renderCriteriaParam($param);
             break;
     }
 }
Пример #6
0
 private function _getTreeAction($path, $keychain)
 {
     @($root = DevblocksPlatform::importGPC($_REQUEST['root'], 'integer', 0));
     //TODO: verify access permissions to that root node
     $cats = DAO_KbCategory::getWhere();
     $tree = DAO_KbCategory::getTreeMap();
     // create breadcrumb trail
     $breadcrumb = array();
     $pid = $root;
     while (0 != $pid) {
         $breadcrumb[$pid] = $cats[$pid]->name;
         $pid = $cats[$pid]->parent_id;
     }
     $breadcrumb[0] = 'Top';
     $breadcrumb = array_reverse($breadcrumb, true);
     $xml_out = new SimpleXMLElement("<categories></categories>");
     if (0 == $root) {
         $xml_out->addChild('name', "Top");
     } else {
         $xml_out->addChild('name', $cats[$root]->name);
     }
     $xml_out->addChild('breadcrumb', serialize($breadcrumb));
     if (is_array($tree[$root])) {
         foreach ($tree[$root] as $tree_idx => $cat) {
             $this->_addSubCategory($tree_idx, $tree, $cats, $xml_out);
         }
     }
     $this->_render($xml_out->asXML());
 }
Пример #7
0
 /**
  * @param $instance Model_CommunityTool 
  */
 public function configure(Model_CommunityTool $instance)
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(__FILE__) . '/templates/';
     $tpl->assign('config_path', $tpl_path);
     $base_url = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_BASE_URL, '');
     $tpl->assign('base_url', $base_url);
     $logo_url = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_LOGO_URL, '');
     $tpl->assign('logo_url', $logo_url);
     $page_title = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_PAGE_TITLE, 'Knowledgebase');
     $tpl->assign('page_title', $page_title);
     $captcha_enabled = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_CAPTCHA_ENABLED, 1);
     $tpl->assign('captcha_enabled', $captcha_enabled);
     // Roots
     $tree_map = DAO_KbCategory::getTreeMap();
     $tpl->assign('tree_map', $tree_map);
     $levels = DAO_KbCategory::getTree(0);
     $tpl->assign('levels', $levels);
     $categories = DAO_KbCategory::getWhere();
     $tpl->assign('categories', $categories);
     $sKbRoots = DAO_CommunityToolProperty::get($this->getPortal(), self::PARAM_KB_ROOTS, '');
     $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
     $tpl->assign('kb_roots', $kb_roots);
     $tpl->display("file:{$tpl_path}portal/kb/config/index.tpl");
 }
Пример #8
0
 function configure()
 {
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl_path = dirname(dirname(dirname(__FILE__))) . '/templates/';
     $require_login = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_REQUIRE_LOGIN, 0);
     $tpl->assign('kb_require_login', $require_login);
     // Knowledgebase
     $tree_map = DAO_KbCategory::getTreeMap();
     $tpl->assign('tree_map', $tree_map);
     $levels = DAO_KbCategory::getTree(0);
     $tpl->assign('levels', $levels);
     $categories = DAO_KbCategory::getWhere();
     $tpl->assign('categories', $categories);
     $sKbRoots = DAO_CommunityToolProperty::get(UmPortalHelper::getCode(), self::PARAM_KB_ROOTS, '');
     $kb_roots = !empty($sKbRoots) ? unserialize($sKbRoots) : array();
     $tpl->assign('kb_roots', $kb_roots);
     $tpl->display("file:{$tpl_path}portal/sc/config/kb.tpl");
 }