Пример #1
0
 case 'getmorefolderdata':
     /* Need to use XML instead of JSON format for return data.
           It's taking up to 1500ms to interpret (eval) the JSON data into an object in the client code
           Parsing the XML is about 10ms
        */
     $filter->cleanData('int', array('cid' => $_POST['cid'], 'level' => $_POST['level']));
     $filter->cleanData('char', array('foldernumber' => $_POST['foldernumber']));
     $_CLEAN = $filter->normalize($filter->getDbData());
     $retval = '<result>';
     $retval .= '<retcode>200</retcode>';
     $tpl = new Template($_CONF['path_layout'] . 'nexfile');
     $tpl->set_file(array('filelisting_rec' => 'filelisting_record.thtml', 'tag_link' => 'taglink_record.thtml', 'tag_rec' => 'tagdesc_record.thtml', 'upload_action' => 'upload_link.thtml', 'download_action' => 'download_link.thtml', 'download_disabled' => 'download_disabled_link.thtml', 'editfile_action' => 'editfile_link.thtml'));
     $tpl->set_var('site_url', $_CONF['site_url']);
     $tpl->set_var('layout_url', $_CONF['layout_url']);
     $tpl->set_var('imgset', "{$_CONF['layout_url']}/nexfile/images");
     $retval .= '<displayhtml>' . htmlspecialchars(nexdoc_displayFileListing($tpl, $_CLEAN['cid'], 'getmorefolderdata', $_CLEAN['level'], "{$_CLEAN['foldernumber']}"), ENT_QUOTES, $charset) . '</displayhtml>';
     $retval .= '</result>';
     firelogmsg("Completed generating AJAX return data - cid: {$_CLEAN['cid']}");
     break;
 case 'getleftnavigation':
     $data = nexdocsrv_generateLeftSideNavigation();
     $retval = json_encode($data);
     break;
 case 'getfolderlisting':
     $ajaxBackgroundMode = true;
     $cid = $filter->getCleanData('int', $_GET['cid']);
     $folderName = DB_getItem($_TABLES['nxfile_categories'], 'name', "cid={$cid}");
     $retval = '<result>';
     $retval .= '<retcode>200</retcode>';
     $retval .= '<cid>' . $cid . '</cid>';
     // Update recent folders for this user if logged in
Пример #2
0
function nexdoc_displayFolderListing($template, $id = 0, $reportmode = '', $level = 0, $folderprefix = '', $rowid = 1)
{
    // COM_errorLog("nexdoc_displayFolderListing - folder:$id, level $level");
    global $_CONF, $_TABLES, $actionurl, $allowableViewFolders, $paddingsize;
    global $allowableViewFoldersSql, $lastModifiedFolderDate, $lastModifiedParentFolderDate, $selectedTopLevelFolder;
    $stepNumber = 10;
    $folderOrder = 10;
    if ($id > 0 and !in_array($id, $allowableViewFolders)) {
        COM_errorLog("No view access to category {$id}");
        return;
    }
    $template->set_var('imgset', "{$_CONF['layout_url']}/nexfile/images");
    $retval = '';
    if (empty($folderprefix)) {
        $q1 = DB_query("SELECT cid,pid,folderorder FROM {$_TABLES['nxfile_categories']} WHERE cid={$id}");
        list($cid, $pid, $folderorder) = DB_fetchArray($q1);
        if ($pid != 0) {
            $folderprefix = $folderorder / 10;
            while ($pid != 0) {
                $q2 = DB_query("SELECT cid,pid,folderorder FROM {$_TABLES['nxfile_categories']} WHERE cid={$pid}");
                list($cid, $pid, $folderorder) = DB_fetchArray($q2);
                if ($pid == 0) {
                    break;
                }
                $folderprefix = $folderorder / 10 . '.' . $folderprefix;
            }
        } else {
            $folderprefix = $folderorder / 10;
        }
    }
    $level++;
    if ($level == 1) {
        $retval .= nexdoc_displayFileListing($template, $id, $reportmode, $level, $folderprefix);
    }
    $sql = '';
    if (function_exists('nexfile_customReportFoldersSQL')) {
        $sql = trim(nexfile_customReportFoldersSQL($id, $reportmode));
    }
    if ($id > 0 or !empty($sql)) {
        // Show any subfolders and check and see if this is a custom report
        if (empty($sql)) {
            $sql = "SELECT DISTINCT cid,pid,name,description,folderorder FROM {$_TABLES['nxfile_categories']} WHERE pid={$id} ";
            if (!empty($allowableViewFoldersSql)) {
                $sql .= "AND cid in ({$allowableViewFoldersSql}) ";
            }
            $sql .= "ORDER BY folderorder";
        }
        $resFolders = DB_QUERY($sql);
        if (!isset($lastModifiedParentFolderDate[$id])) {
            $lastModifiedParentFolderDate[$id] = 0;
        }
        $foldercount = DB_numRows($resFolders);
        if ($foldercount > 0) {
            $i = $rowid;
            $j = 1;
            while (list($folderId, $pid, $folderName, $folderDesc, $order) = DB_fetchARRAY($resFolders)) {
                if ($order != $folderOrder) {
                    DB_query("UPDATE {$_TABLES['nxfile_categories']} SET folderorder = {$folderOrder} WHERE cid = {$folderId}");
                    $order = $folderorder;
                }
                $folderOrder += $stepNumber;
                if (empty($folderprefix)) {
                    $formattedFolderNumber = $i;
                } else {
                    $formattedFolderNumber = "{$folderprefix}.{$i}";
                }
                //COM_errorLog("nexdoc_displayFolderListing - cid:$folderId, pid: $pid");
                $subfolderlisting = nexdoc_displayFileListing($template, $folderId, $reportmode, $level, $formattedFolderNumber);
                if (DB_count($_TABLES['nxfile_categories'], 'pid', $folderId)) {
                    // Show any sub-subfolders - calling this function again recursively
                    $subfolderlisting .= nexdoc_displayFolderListing($template, $folderId, $reportmode, $level, $formattedFolderNumber);
                    if ($lastModifiedParentFolderDate[$folderId] > $lastModifiedParentFolderDate[$pid]) {
                        $lastModifiedParentFolderDate[$pid] = $lastModifiedParentFolderDate[$folderId];
                    }
                }
                $template->set_var('folder_desc_padding_left', 23 + $level * 30);
                $template->set_var('folder_id', $folderId);
                $template->set_var('parent_folder_id', $pid);
                $template->set_var('folder_name', $folderName);
                $template->set_var('folder_description', $folderDesc);
                $template->set_var('folder_link', "{$_CONF['site_url']}/nexfile/index.php?cid={$folderId}");
                $template->set_var('folder_contents', $subfolderlisting);
                $template->set_var('folder_number', "{$formattedFolderNumber}.0");
                if ($lastModifiedParentFolderDate[$folderId] > 0) {
                    $template->set_var('last_modified_date', strftime($_CONF['shortdate'], $lastModifiedParentFolderDate[$folderId]));
                } else {
                    $template->set_var('last_modified_date', '');
                }
                //nexdoc_formatNotificationIcon($template,0,$folderId);
                // For the checkall files - need to set the inline files
                // and can't be done in nexdoc_displayFileListing since a folder can have subfolders
                // and template var in parent folder is being over-written
                $resFiles = DB_QUERY("SELECT fid from {$_TABLES['nxfile_files']} WHERE cid={$folderId}");
                $files = array();
                while ($A = DB_fetchArray($resFiles)) {
                    $files[] = $A['fid'];
                }
                $template->set_var('folder_files', implode(',', $files));
                if (fm_getPermission($folderId, 'admin')) {
                    if ($order == 10) {
                        $template->set_var('hide_moveup', 'none');
                    } else {
                        $template->set_var('hide_moveup', '');
                    }
                    if ($j < $foldercount) {
                        $template->set_var('hide_movedown', '');
                    } else {
                        $template->set_var('hide_movedown', 'none');
                    }
                    $template->parse('onhover_move_options', 'movefolder');
                } else {
                    $template->set_var('onhover_move_options', '');
                }
                $template->set_var('folder_padding_left', $level * $paddingsize);
                $template->parse('folderlisting', 'subfolder');
                $retval .= $template->get_var('folderlisting');
                $i++;
                $j++;
            }
        } elseif ($level == 1) {
            $retval .= "<div id=\"subfolder{$GLOBALS['lastRenderedFiles'][0][0]}_rec{$GLOBALS['lastRenderedFiles'][0][1]}_bottom\">";
        }
    }
    return $retval;
}