From 7eaf1d34e1bdb33c7e29c52c7f45484f7dd01d31 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Thu, 19 Nov 2020 08:53:47 +0800 Subject: [PATCH] * Adjust code. --- module/common/model.php | 2 +- module/program/model.php | 19 +++++++------------ module/program/view/pgmbrowse.html.php | 1 - module/program/view/pgmbrowsebylist.html.php | 5 ++--- module/upgrade/view/createprogram.html.php | 4 ++++ 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index ff8e527144..be8a2761d6 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1702,7 +1702,7 @@ EOD; /* If is the program admin, have all program privs. */ $inProject = isset($lang->navGroup->$module) && $lang->navGroup->$module == 'project'; - if($inProject && strpos(",{$app->user->rights['projects']},", ",{$app->session->PRJ},") !== false) return true; + if($inProject && $app->session->PRJ && strpos(",{$app->user->rights['projects']},", ",{$app->session->PRJ},") !== false) return true; /* If not super admin, check the rights. */ $rights = $app->user->rights['rights']; diff --git a/module/program/model.php b/module/program/model.php index e3c18ea438..fc745fd881 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -932,7 +932,7 @@ class programModel extends model } /** - * Get the program to which the project belongs. + * Get the top program which the project belongs to. * * @param int $projectID * @access public @@ -941,19 +941,14 @@ class programModel extends model public function getTopProgramID($projectID) { if(empty($projectID)) return 0; - $program = $this->getPGMByID($projectID); + $project = $this->getPRJByID($projectID); + + if($project->parent == 0) return 0; $programID = 0; - if($program->parent > 0) - { - $path = explode(',', $program->path); - $path = array_filter($path); - $programID = current($path); - } - elseif($program->parent == 0) - { - $programID = $program->id; - } + $path = explode(',', $project->path); + $path = array_filter($path); + $programID = current($path); return $programID; } diff --git a/module/program/view/pgmbrowse.html.php b/module/program/view/pgmbrowse.html.php index fcbddc1b37..4daf8f0ec7 100644 --- a/module/program/view/pgmbrowse.html.php +++ b/module/program/view/pgmbrowse.html.php @@ -21,7 +21,6 @@ program->PGMFeatureBar as $key => $label):?> $label";?> - {$pager->recTotal}";?> $lang->program->PGMShowClosed), '', $this->cookie->showClosed ? 'checked=checked' : '');?> diff --git a/module/program/view/pgmbrowsebylist.html.php b/module/program/view/pgmbrowsebylist.html.php index 1fd5fb695d..6bdf3f18e5 100644 --- a/module/program/view/pgmbrowsebylist.html.php +++ b/module/program/view/pgmbrowsebylist.html.php @@ -1,7 +1,7 @@
- recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}";?> +
@@ -25,8 +25,7 @@ if($program->type == 'program') { $trAttrs .= " data-nested='true'"; - if($program->parent == '0') $trClass .= ' is-top-level table-nest-child-hide'; - else $trClass .= ' table-nest-hide'; + $trClass .= $program->parent == '0' ? ' is-top-level table-nest-child-hide' : ' table-nest-hide'; } if($program->parent and isset($programs[$program->parent])) diff --git a/module/upgrade/view/createprogram.html.php b/module/upgrade/view/createprogram.html.php index 59f5f8e8d5..bf857b4952 100644 --- a/module/upgrade/view/createprogram.html.php +++ b/module/upgrade/view/createprogram.html.php @@ -1,5 +1,6 @@ + + + +
upgrade->program;?>
upgrade->existPGM;?> @@ -14,6 +15,8 @@
upgrade->existPRJ;?> @@ -28,6 +31,7 @@
program->PGMName;?>