Beispiel #1
0
 public function getChildren(&$pathArray, $requestParams)
 {
     $pid = null;
     /* should start with path check and see if child request is for a real db node*/
     if (empty($pathArray)) {
         if (empty($requestParams['query'])) {
             return;
         }
     } else {
         $lastNode = @$pathArray[sizeof($pathArray) - 1];
         if ($lastNode instanceof Dbnode || get_class($lastNode) == 'CB\\TreeNode\\Base') {
             $pid = $lastNode->id;
         } else {
             //we are under another node type
             $cfg = $lastNode->getConfig();
             if (!empty($cfg['realNodeId']) && $lastNode instanceof RealSubnode) {
                 $pid = $cfg['realNodeId'];
             } else {
                 return array();
             }
         }
     }
     if (empty($pid)) {
         return array();
     }
     /* end of check */
     $p =& $requestParams;
     $folderTemplates = \CB\Config::get('folder_templates');
     $p['fl'] = 'id,pid,system,path,name,case_id,date,date_end,size,cid,' . 'oid,cdate,uid,udate,template_id,acl_count,cls,status,task_status,versions,' . 'comment_user_id,comment_date';
     if (empty($p['showFoldersContent'])) {
         $p['templates'] = $folderTemplates;
     }
     if (empty($p['descendants'])) {
         $p['pid'] = $pid;
     } else {
         $p['pids'] = $pid;
     }
     $s = new \CB\Search();
     $rez = $s->query($p);
     if (!empty($rez['data'])) {
         for ($i = 0; $i < sizeof($rez['data']); $i++) {
             $d =& $rez['data'][$i];
             $r = DM\Tree::read($d['id']);
             if (!empty($r['cfg']) && $p['from'] == 'tree') {
                 if (isset($r['cfg']['loaded'])) {
                     $d['loaded'] = $r['cfg']['loaded'];
                 }
                 if (isset($r['cfg']['expanded'])) {
                     $d['expanded'] = $r['cfg']['expanded'];
                 }
                 if (isset($r['cfg']['leaf'])) {
                     $d['leaf'] = $r['cfg']['leaf'];
                 }
             }
         }
         \CB\Tasks::setTasksActionFlags($rez['data']);
     }
     return $rez;
 }