Example #1
0
     }
     $retval .= '<displayhtml>' . htmlspecialchars(nexdocsrv_generateFileListing($cid, $reportmode), ENT_QUOTES, $charset) . '</displayhtml>';
     firelogmsg("Completed generating FileListing");
     if (is_array($lastRenderedFiles) and count($lastRenderedFiles) > 0) {
         $retval .= '<lastrenderedfiles>' . serialize($lastRenderedFiles) . '</lastrenderedfiles>';
     }
     $retval .= '<activefolder>' . htmlspecialchars(nexdoc_displayActiveFolder($cid), ENT_QUOTES, $charset) . '</activefolder>';
     $retval .= '</result>';
     break;
 case 'rendernewfolderform':
     $cid = $filter->getCleanData('int', $_GET['cid']);
     $tpl = new Template($_CONF['path_layout'] . 'nexfile');
     $tpl->set_file('form', 'newfolder_form.thtml');
     $tpl->set_var('newfolder_options', nexdoc_recursiveAccessOptions('admin', $cid));
     if (function_exists('nexfile_customFolderFields')) {
         nexfile_customFolderFields($tpl, 'add', $cid);
     }
     $tpl->parse('output', 'form');
     $data['displayhtml'] = $tpl->finish($tpl->get_var('output'));
     $retval = json_encode($data);
     break;
 case 'rendernewfilefolderptions':
     $cid = $filter->getCleanData('int', $_GET['cid']);
     $tpl = new Template($_CONF['path_layout'] . 'nexfile');
     $tpl->set_file('form', 'newfile_form.thtml');
     $tpl->set_var('newfile_category_options', nexdoc_recursiveAccessOptions(array('upload', 'upload_dir'), $cid));
     $tpl->parse('output', 'form');
     $data['displayhtml'] = $tpl->finish($tpl->get_var('output'));
     $retval = json_encode($data);
     break;
 case 'rendermoveform':
Example #2
0
function nexdoc_displayActiveFolder($cid = 0, $reportmode = '')
{
    global $_CONF, $uid, $_TABLES, $_FMCONF, $LANG_FM12, $validReportModes;
    $tpl = new Template($_CONF['path_layout'] . 'nexfile');
    $tpl->set_file(array('activefolder_container' => 'activefolder_container.thtml', 'selectedcategory' => 'activefolder_selectedcategory.thtml', 'toplevelcategory' => 'activefolder_toplevelcategory.thtml', 'reportingview' => 'activefolder_reportingview.thtml', 'activefolder_admin' => 'activefolder_admin.thtml', 'activefolder_display' => 'activefolder_nonadmin.thtml', 'activefolder_anonymous' => 'activefolder_anonymous.thtml', 'breadcrumb_link' => 'folder_breadcrumb_record.thtml', 'ajaxstatus' => 'ajaxstatus_div.thtml', 'ajaxactivity' => 'ajaxactivity_div.thtml', 'uploadbutton' => 'uploadfile_button.thtml'));
    $tpl->set_var('site_url', $_CONF['site_url']);
    $tpl->set_var('layout_url', $_CONF['layout_url']);
    $tpl->set_var('show_activefolder', 'none');
    $tpl->set_var('show_reportmodeheader', 'none');
    $tpl->set_var('show_nonadmin', 'none');
    $tpl->set_var('show_folderheader', 'block');
    $tpl->set_var('show_breadcrumbs', 'block');
    if ($cid == 0) {
        if (in_array($reportmode, $validReportModes)) {
            $tpl->set_var('report_heading', $LANG_FM12[$reportmode]);
            $tpl->parse('ajaxstatus_reportmode', 'ajaxstatus');
            $tpl->parse('ajaxactivity_reportmode', 'ajaxactivity');
            $tpl->set_var('show_reportmodeheader', '');
        } else {
            $tpl->parse('ajaxstatus_workspacemode', 'ajaxstatus');
            $tpl->parse('ajaxactivity_workspacemode', 'ajaxactivity');
        }
        $tpl->parse('selected_category_div', 'reportingview');
    } else {
        $tpl->set_var('cid', $cid);
        // Folder Stats
        $list = array();
        array_push($list, $cid);
        fm_getRecursiveCatIDs($list, $cid, 'view');
        $tpl->set_var('folder_count', count($list));
        $numfiles = 0;
        $totalsize = 0;
        foreach ($list as $folderid) {
            $q = DB_query("SELECT count(fid),sum(size) FROM {$_TABLES['nxfile_files']} WHERE cid={$folderid} GROUP BY cid");
            list($count, $size) = DB_fetchArray($q);
            $numfiles = $numfiles + $count;
            $totalsize = $totalsize + $size;
        }
        $tpl->set_var('file_count', $numfiles);
        $tpl->set_var('total_size', fm_formatFileSize($totalsize));
        $query = DB_QUERY("SELECT pid,name,description,folderorder from {$_TABLES['nxfile_categories']} WHERE cid='{$cid}'");
        list($pid, $activeFolderName, $folderDescription, $folderorder) = DB_fetchArray($query);
        if ($pid == 0) {
            $tpl->set_var('show_parentfolder', 'none');
            // used in activefolder_admin.thtml only
        }
        $tpl->set_var('active_category_id', $cid);
        $tpl->set_var('active_folder_name', $activeFolderName);
        $tpl->set_var('folder_description', $folderDescription);
        $tpl->set_var('folderorder', $folderorder);
        $categoryOptions .= nexdoc_recursiveAccessOptions(array('admin'), $pid);
        $tpl->set_var('activefolder_options', $categoryOptions);
        $query = DB_query("SELECT cid_newfiles,cid_changes FROM {$_TABLES['nxfile_notifications']} WHERE cid={$cid} and uid={$uid}");
        if (DB_numRows($query) == 1) {
            list($fileadded, $filechanged) = DB_fetchArray($query);
            if ($fileadded == 1) {
                $tpl->set_var('chk_fileadded', "CHECKED=checked");
            }
            if ($filechanged == 1) {
                $tpl->set_var('chk_filechanged', "CHECKED=checked");
            }
        } else {
            if ($_FMCONF['notify_newfile'] == 1) {
                $tpl->set_var('chk_fileadded', "CHECKED=checked");
            }
            if ($_FMCONF['notify_changedfile'] == 1) {
                $tpl->set_var('chk_filechanged', "CHECKED=checked");
            }
        }
        if (fm_getPermission($cid, 'admin')) {
            if (function_exists('nexfile_customFolderFields')) {
                nexfile_customFolderFields($tpl, 'edit', $cid);
            }
            $tpl->parse('active_folder', 'activefolder_admin');
        } elseif ($uid > 1) {
            $tpl->set_var('show_nonadmin', '');
            $tpl->parse('active_folder', 'activefolder_display');
        } else {
            $tpl->set_var('show_nonadmin', '');
            $tpl->parse('active_folder', 'activefolder_anonymous');
        }
        // Display the folder breadcrumb trail
        if ($pid != 0) {
            $parent = $pid;
            $rootfolder = $cid;
            while ($parent != 0) {
                // Determine the rootfolder
                $rootfolder = $parent;
                $parent = DB_getItem($_TABLES['nxfile_categories'], 'pid', "cid={$parent}");
            }
            $tpl->set_var('catid', $rootfolder);
            $tpl->set_var('padding_left', 0);
            $tpl->set_var('folder_name', DB_getItem($_TABLES['nxfile_categories'], 'name', "cid={$rootfolder}"));
            $tpl->parse('folder_breadcrumb_links', 'breadcrumb_link');
            if ($rootfolder != $pid) {
                $query = DB_QUERY("SELECT cid,name,description from {$_TABLES['nxfile_categories']} WHERE cid='{$pid}' ");
                list($catid, $folderName, $folderDescription) = DB_fetchArray($query);
                $tpl->set_var('catid', $catid);
                $tpl->set_var('padding_left', 5);
                $tpl->set_var('folder_action_url', "{$_CONF['site_url']}/nexfile/index.php?cid={$catid}");
                $tpl->set_var('folder_name', $folderName);
                $tpl->parse('folder_breadcrumb_links', 'breadcrumb_link', true);
            }
            // Check if user's role allows upload and if they have permission
            if (fm_getPermission($cid, 'admin') or in_array($role, array(1, 2, 3)) and fm_getPermission($cid, 'upload_dir')) {
                $tpl->parse('upload_button', 'uploadbutton');
            }
            $tpl->parse('ajaxstatus_breadcrumbmode', 'ajaxstatus');
            $tpl->parse('ajaxactivity_breadcrumbmode', 'ajaxactivity');
            $tpl->set_var('show_activefolder', 'block');
            $tpl->set_var('show_folderheader', 'none');
            $tpl->parse('selected_category_div', 'selectedcategory');
        } else {
            if (fm_getPermission($cid, 'admin')) {
                $tpl->set_var('show_breadcrumbs', 'none');
                $tpl->set_var('show_activefolder', 'block');
                $tpl->parse('ajaxstatus_foldermode', 'ajaxstatus');
                $tpl->parse('ajaxactivity_foldermode', 'ajaxactivity');
                $tpl->parse('selected_category_div', 'selectedcategory');
            } else {
                $tpl->parse('ajaxstatus_workspacemode', 'ajaxstatus');
                $tpl->parse('ajaxactivity_workspacemode', 'ajaxactivity');
                $tpl->parse('selected_category_div', 'toplevelcategory');
            }
        }
    }
    $tpl->parse('output', 'activefolder_container');
    return $tpl->finish($tpl->get_var('output'));
}