![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: index.php 40 2008-02-11 12:11:44Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/files/index.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 $AppUI->savePlace(); 7 8 // retrieve any state parameters 9 if (isset($_REQUEST['project_id'])) { 10 $AppUI->setState('FileIdxProject', w2PgetParam($_REQUEST, 'project_id', null)); 11 } 12 13 $project_id = $AppUI->getState('FileIdxProject', 0); 14 15 $AppUI->setState('FileIdxTab', w2PgetParam($_GET, 'tab')); 16 $tab = $AppUI->getState('FileIdxTab', 0); 17 $active = intval(!$AppUI->getState('FileIdxTab')); 18 19 $view_temp = w2PgetParam($_GET, 'view'); 20 if (isset($view_temp)) { 21 $view = w2PgetParam($_GET, 'view'); // folders or categories 22 $AppUI->setState('FileIdxView', $view); 23 } else { 24 $view = $AppUI->getState('FileIdxView'); 25 if ($view == '') { 26 $view = 'folders'; 27 } 28 } 29 $folder = w2PgetParam($_GET, 'folder', 0); // to pass to "new file" button 30 31 require_once ($AppUI->getModuleClass('projects')); 32 33 // get the list of visible companies 34 $extra = array('from' => 'files', 'where' => 'projects.project_id = file_project', 'join' => 'project_departments', 'on' => 'projects.project_id = project_departments.project_id'); 35 36 //get "Allowed" projects for filter list ("All" is always allowed when basing permission on projects) 37 $project = new CProject(); 38 $projects = $project->getAllowedRecords($AppUI->user_id, 'projects.project_id,project_name', 'project_name', null, $extra, 'projects'); 39 $allowedProjects = $project->getAllowedSQL($AppUI->user_id, 'file_project'); 40 $projects = arrayMerge(array('0' => $AppUI->_('All', UI_OUTPUT_RAW)), $projects); 41 42 // get SQL for allowed projects/tasks 43 $task = new CTask(); 44 $allowedTasks = $task->getAllowedSQL($AppUI->user_id, 'file_task'); 45 46 // setup the title block 47 $titleBlock = new CTitleBlock('Files', 'folder5.png', $m, "$m.$a"); 48 $titleBlock->addCell($AppUI->_('Filter') . ':'); 49 $titleBlock->addCell(arraySelect($projects, 'project_id', 'onChange="document.pickProject.submit()" size="1" class="text"', $project_id), '', '<form name="pickProject" action="?m=files" method="post">', '</form>'); 50 51 // override the $canEdit variable passed from the main index.php in order to check folder permissions 52 /** get permitted folders **/ 53 $cfObj = new CFileFolder(); 54 $allowed_folders_ary = $cfObj->getAllowedRecords($AppUI->user_id); 55 $denied_folders_ary = $cfObj->getDeniedRecords($AppUI->user_id); 56 57 if (count($allowed_folders_ary) < $cfObj->countFolders()) { 58 $limited = true; 59 } 60 if (!$limited) { 61 $canEdit = true; 62 } elseif ($limited and array_key_exists($folder, $allowed_folders_ary)) { 63 $canEdit = true; 64 } else { 65 $canEdit = false; 66 } 67 68 if ($canEdit) { 69 $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new file') . '">', '', '<form action="?m=files&a=addedit&folder=' . $folder . '" method="post">', '</form>'); 70 $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new folder') . '">', '', '<form action="?m=files&a=addedit_folder" method="post">', '</form>'); 71 } 72 $titleBlock->show(); 73 74 $file_types = w2PgetSysVal('FileType'); 75 76 $fts = $file_types; 77 78 if ($tab != -1) { 79 array_unshift($file_types, 'All Files'); 80 } 81 82 //if ($view == 'folders') { 83 //include('folders_table.php'); 84 //} else { 85 $tabBox = new CTabBox('?m=files', W2P_BASE_DIR . '/modules/files/', $tab); 86 $tabbed = $tabBox->isTabbed(); 87 $i = 0; 88 foreach ($file_types as $file_type) { 89 $q = new DBQuery; 90 $q->addQuery('count(file_id)'); 91 $q->addTable('files', 'f'); 92 $q->addJoin('projects', 'p', 'p.project_id = file_project'); 93 $q->addJoin('project_departments', 'pd', 'p.project_id = pd.project_id'); 94 $q->addJoin('departments', '', 'pd.department_id = dept_id'); 95 $q->addJoin('tasks', 't', 't.task_id = file_task'); 96 if (count($allowedProjects)) { 97 $q->addWhere('( ( ' . implode(' AND ', $allowedProjects) . ') OR file_project = 0 )'); 98 } 99 if (count($allowedTasks)) { 100 $q->addWhere('( ( ' . implode(' AND ', $allowedTasks) . ') OR file_task = 0 )'); 101 } 102 if ($catsql) { 103 $q->addWhere($catsql); 104 } 105 if ($company_id) { 106 $q->addWhere('project_company = ' . (int)$company_id); 107 } 108 if ($project_id) { 109 $q->addWhere('file_project = ' . (int)$project_id); 110 } 111 if ($task_id) { 112 $q->addWhere('file_task = ' . (int)$task_id); 113 } 114 $key = array_search($file_type, $fts); 115 if ($i > 0 || !$tabbed) { 116 $q->addWhere('file_category = ' . (int)$key); 117 } 118 if ($project_id > 0) { 119 $q->addWhere('file_project = ' . (int)$project_id); 120 } 121 $tabBox->add('index_table', $file_type . ' (' . $q->loadResult() . ')'); 122 ++$i; 123 } 124 $tabBox->add('folders_table', 'Folder Explorer'); 125 $tabBox->show(); 126 //} 127 128 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Jan 9 03:00:02 2009 | Cross-referenced by PHPXref 0.7 |