Exemple #1
0
function treeBuild($pid, &$fcache, &$xml_nodes, &$done)
{
    global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $forumpermissions, $new_note;
    $newForums = array();
    if (!empty($fcache[$pid])) {
        foreach ($fcache[$pid] as $parent) {
            foreach ($parent as $forum) {
                // Get the permissions for this forum
                $permissions = $forumpermissions[$forum['fid']];
                // If this user doesnt have permission to view this forum and we're hiding private forums, skip this forum
                if ($permissions['canview'] != 1 && $mybb->settings['hideprivateforums'] == 1) {
                    continue;
                }
                list($forum2, $new_post) = processForum($forum);
                $done[$id] = true;
                $child = treeBuild($forum['fid'], $fcache, $xml_nodes, $done);
                if ($new_note[$forum['fid']]) {
                    $forum2->addStruct(array('new_post' => new xmlrpcval(true, 'boolean')));
                }
                if ($child) {
                    $forum2->addStruct(array('child' => new xmlrpcval($child, 'array')));
                }
                if ($new_post || $new_note[$forum['fid']]) {
                    $new_note[$pid] = true;
                }
                $newForums[] = $forum2;
            }
        }
    }
    return $newForums;
}
Exemple #2
0
 function treeBuild($branches, $options, $branch_id = 0, $innerList = array())
 {
     $branch = array();
     foreach ($branches[$branch_id] as $b) {
         //Количества подопечной таблицы
         if (isset($options['inner']['table']) && isset($options['inner']['top_key'])) {
             if (isset($innerList[$b[$options['nouns']['id']]]) && $innerList[$b[$options['nouns']['id']]] > 0) {
                 $add_count = ' (' . $innerList[$b[$options['nouns']['id']]] . ')';
             } else {
                 $add_count = '';
             }
         } else {
             $add_count = '';
         }
         //Если запись — узел (ветка)
         if (isset($branches[$b[$options['nouns']['id']]])) {
             $branch[] = array('data' => array('title' => $b[$options['nouns']['name']] . $add_count, 'attributes' => array('id' => 't' . $b[$options['nouns']['id']])), 'children' => treeBuild($branches, $options, $b[$options['nouns']['id']], $innerList));
         } else {
             $branch[] = array('data' => array('title' => $b[$options['nouns']['name']] . $add_count, 'attributes' => array('id' => 't' . $b[$options['nouns']['id']])));
         }
     }
     return $branch;
 }