Exemplo n.º 1
0
            }
        }
        aout($json->encode($result));
        break;
    case "delete":
        $node_id = Get::req('node_id', DOTY_INT, 0);
        $result = array('success' => $treecat->deleteTreeById($node_id));
        aout($json->encode($result));
        break;
    case "movefolder":
        $src = Get::req('src', DOTY_INT, 0);
        $dest = Get::req('dest', DOTY_INT, 0);
        $result = array('success' => $treecat->move($src, $dest));
        aout($json->encode($result));
        break;
    case "options":
        $node_id = Get::req('node_id', DOTY_INT, 0);
        //get properties from DB
        $count = $treecat->getChildrenCount($node_id);
        $is_leaf = true;
        if ($count > 0) {
            $is_leaf = false;
        }
        $node_options = getNodeOptions($node_id, $is_leaf);
        $result = array('success' => true, 'options' => $node_options, '_debug' => $count);
        aout($json->encode($result));
        break;
        //invalid command
    //invalid command
    default:
}
Exemplo n.º 2
0
 function _getCourseTreeStatus()
 {
     require_once _lms_ . '/lib/category/class.categorytree.php';
     $treecat = new Categorytree();
     if (!isset($_SESSION['course_category']['filter_status']['c_category'])) {
         $_SESSION['course_category']['filter_status']['c_category'] = 0;
     }
     $treestatus =& $_SESSION['course_category']['filter_status']['c_category'];
     $result = array();
     $folders = $treecat->getOpenedFolders($treestatus);
     $ref =& $result;
     foreach ($folders as $folder) {
         if ($folder > 0) {
             for ($i = 0; $i < count($ref); $i++) {
                 if ($ref[$i]['id'] == $folder) {
                     $ref[$i]['expanded'] = true;
                     $ref[$i]['children'] = array();
                     $ref =& $ref[$i]['children'];
                     break;
                 }
             }
         }
         $childrens = $treecat->getChildrensById($folder);
         while (list($id_category, $idParent, $path, $lev, $left, $right) = sql_fetch_row($childrens)) {
             $is_leaf = $right - $left == 1;
             $node_options = getNodeOptions($id_category, $is_leaf);
             $ref[] = array('type' => 'FolderNode', 'id' => $id_category, 'label' => end(explode('/', $path)), 'html' => end(explode('/', $path)), 'is_leaf' => $is_leaf, 'count_content' => (int) (($right - $left - 1) / 2), 'options' => $node_options);
         }
     }
     return $result;
 }