diff --git a/modules/projects/config.php b/modules/projects/config.php new file mode 100644 index 00000000..bf281335 --- /dev/null +++ b/modules/projects/config.php @@ -0,0 +1,3 @@ + diff --git a/modules/projects/configure.php b/modules/projects/configure.php new file mode 100644 index 00000000..6fc2cb5b --- /dev/null +++ b/modules/projects/configure.php @@ -0,0 +1,147 @@ +redirect("m=public&a=access_denied"); + +@include_once('./functions/admin_func.php'); +$CONFIG_FILE = './modules/projects/config.php'; + +$AppUI->savePlace(); + +// Define user type list +$user_types = arrayMerge($utypes, array('9' => $AppUI->_('None'))); + +$config_options = array( + 'heading1' => $AppUI->_('General Options'), + 'always_show_archived' => array( + 'description' => $AppUI->_('Show Archived Projects In All Tab'), + 'value' => '1', + 'type' => 'radio', + 'buttons' => array (1 => $AppUI->_('Yes'), 0 => $AppUI->_('No')) + ) +); + +// If this is a submitted page, overwrite the config file +if (dPgetParam($_POST, 'Save', '') != '') { + if (is_writable($CONFIG_FILE)) { + if (!$handle = fopen($CONFIG_FILE, 'w')) { + $AppUI->setMsg($CONFIG_FILE . ' ' . $AppUI->_('cannot be opened'), UI_MSG_ERROR); + exit; + } + + if (fwrite($handle, "setMsg($CONFIG_FILE . ' ' . $AppUI->_('cannot be written to'), UI_MSG_ERROR); + exit; + } else { + foreach ($config_options as $key=>$value) { + if (substr($key, 0, 7) == 'heading') + continue; + + $val = ''; + switch ($value['type']) { + case 'checkbox': + $val = isset($_POST[$key]) ? '1' : '0'; + break; + case 'text': + $val = isset($_POST[$key]) ? $_POST[$key] : ''; + break; + case 'longtext': + $val = isset($_POST[$key]) ? $_POST[$key] : ''; + break; + case 'select': + $val = isset($_POST[$key]) ? $_POST[$key] : '0'; + break; + case 'radio': + $val = $_POST[$key]; + break; + default: + break; + } + fwrite($handle, "\$PROJECTS_CONFIG['" . $key . "'] = '" . $val . "';\n"); + } + fwrite($handle, "?>\n"); + $AppUI->setMsg($CONFIG_FILE . ' ' . $AppUI->_('has been successfully updated'), UI_MSG_OK); + require($CONFIG_FILE); + } + } else { + $AppUI->setMsg($CONFIG_FILE . ' ' . $AppUI->_('is not writable'), UI_MSG_ERROR); + } +} elseif (dPgetParam($_POST, $AppUI->_('Cancel'), '') != '') { + $AppUI->redirect('m=system&a=viewmods'); +} + +include($CONFIG_FILE); + +// Read the current config values from config file and update the array +foreach ($config_options as $key=>$value) + if (isset($PROJECTS_CONFIG[$key])) + $config_options[$key]['value'] = $PROJECTS_CONFIG[$key]; + +// Setup the title block +$titleBlock = new CTitleBlock('Projects Module Configuration', 'applet3-48.png', $m, "$m.$a"); +$titleBlock->addCrumb('?m=system', 'System Admin'); +$titleBlock->addCrumb('?m=system&a=viewmods', 'Modules'); +$titleBlock->show(); +?> + +
\ No newline at end of file diff --git a/modules/projects/index.php b/modules/projects/index.php index cafd8295..9901a8e6 100644 --- a/modules/projects/index.php +++ b/modules/projects/index.php @@ -3,7 +3,7 @@ die('You should not access this file directly.'); } -global $cBuffer; +global $cBuffer, $PROJECTS_CONFIG; $AppUI->savePlace(); $q = new DBQuery(); @@ -156,6 +156,9 @@ // count number of projects per project_status $q->addTable('projects', 'p'); $q->addQuery('p.project_status, COUNT(p.project_id) as count'); +if ($PROJECTS_CONFIG['always_show_archived'] == 0) { + $q->addWhere('NOT p.project_status=7'); +} $obj_project->setAllowedSQL($AppUI->user_id, $q, null, 'p'); if ($owner > 0) { $q->addWhere('p.project_owner = ' . $owner); diff --git a/modules/projects/projects.class.php b/modules/projects/projects.class.php index d918d7cb..53519401 100644 --- a/modules/projects/projects.class.php +++ b/modules/projects/projects.class.php @@ -14,6 +14,7 @@ require_once ($AppUI->getModuleClass('tasks')); require_once ($AppUI->getModuleClass('companies')); require_once ($AppUI->getModuleClass('departments')); +include_once("./modules/projects/config.php"); /** * The Project Class diff --git a/modules/projects/setup.php b/modules/projects/setup.php new file mode 100644 index 00000000..c5a47b52 --- /dev/null +++ b/modules/projects/setup.php @@ -0,0 +1,21 @@ +redirect('m=projects&a=configure'); + return true; + } +} \ No newline at end of file diff --git a/modules/projects/view.php b/modules/projects/view.php index 2ff03adb..ffcfecc0 100644 --- a/modules/projects/view.php +++ b/modules/projects/view.php @@ -15,7 +15,7 @@ $canAuthorTask = getPermission('tasks', 'add'); -//Check if the proect is viewable. +//Check if the project is viewable. if (!($canRead)) { $AppUI->redirect('m=public&a=access_denied'); } diff --git a/modules/projects/vw_idx_proposed.php b/modules/projects/vw_idx_proposed.php index ae1599a6..eea74d59 100644 --- a/modules/projects/vw_idx_proposed.php +++ b/modules/projects/vw_idx_proposed.php @@ -4,7 +4,7 @@ } GLOBAL $AppUI, $projects, $company_id, $pstatus, $project_types, $currentTabId, $currentTabName; -GLOBAL $priority; +GLOBAL $priority, $PROJECTS_CONFIG; $show_all_projects = false; if ($currentTabId == 500) { @@ -117,6 +117,9 @@ if (! getPermission('projects', 'view', $row['project_id'])) { continue; } + if ($show_all_projects && $PROJECTS_CONFIG['always_show_archived'] == 0 && $row['project_status'] == 7) { + continue; + } if ($show_all_projects || $row['project_status'] == $project_status_filter) { $none = false; $start_date = ((intval(@$row['project_start_date']))