This commit is contained in:
wangyuting2
2022-05-18 09:27:14 +08:00
parent 9ca1be70c7
commit af47d16938
2 changed files with 88 additions and 48 deletions
+87
View File
@@ -1498,4 +1498,91 @@ class programModel extends model
$this->lang->switcherMenu = $this->getSwitcher($programID);
common::setMenuVars('program', $programID);
}
/**
* Build program action menu.
*
* @param object $program
* @param string $type
* @access public
* @return string
*/
public function buildOperateMenu($program, $type = 'view')
{
$menu = '';
$params = "programID=$program->id";
if($program->type == 'program' && strpos(",{$this->app->user->view->programs},", ",$program->id,") !== false)
{
if($program->status == 'wait' || $program->status == 'suspended')
{
$menu .= $this->buildMenu('program', 'start', $params, $program, $type, 'play', '', 'iframe', true, '', $this->lang->program->start);
}
if($program->status == 'doing')
{
$menu .= $this->buildMenu('program', 'close', $params, $program, $type, 'off', '', 'iframe', true);
}
if($program->status == 'closed')
{
$menu .= $this->buildMenu('program', 'activate', $params, $program, $type, 'magic', '', 'iframe', true);
}
if(common::hasPriv('program', 'suspend') || (common::hasPriv('program', 'close') && $program->status != 'doing') || (common::hasPriv('program', 'activate') && $program->status != 'closed'))
{
$menu .= "<div class='btn-group'>";
$menu .= "<button type='button' class='btn icon-caret-down dropdown-toggle' data-toggle='dropdown' title='{$this->lang->more}' style='width: 16px; padding-left: 0px;'></button>";
$menu .= "<ul class='dropdown-menu pull-right text-center' role='menu' style='min-width:auto; padding: 5px 10px;'>";
$menu .= $this->buildMenu('program', 'suspend', $params, $program, $type, 'pause', '', 'iframe', true, '', $this->lang->program->suspend);
if($program->status != 'doing') $menu .= $this->buildMenu('program', 'close', $params, $program, $type, 'off', '', 'iframe', true);
if($program->status != 'closed') $menu .= $this->buildMenu('program', 'activate', $params, $program, $type, 'magic', '', 'iframe', true);
$menu .= "</ul>";
$menu .= "</div>";
}
$disabled = $program->status == 'closed' ? 'disabled' : '';
$menu .= $this->buildMenu('program', 'edit', $params, $program, $type, 'edit');
$menu .= $this->buildMenu('program', 'create', $params, $program, $type, 'split', '', '', '', $disabled, $this->lang->program->children);
if(common::hasPriv('program', 'delete'))
{
$menu .= $this->buildMenu('program', 'delete', $params, $program, $type, 'trash', 'hiddenwin', '', '', '', $this->lang->program->delete);
}
}
else if($program->type == 'project')
{
if($program->status == 'wait' || $program->status == 'suspended')
{
$menu .= $this->buildMenu('project', 'start', $params, $program, $type, 'play', '', 'iframe', true);
}
if($program->status == 'doing') $menu .= $this->buildMenu('project', 'close', $params, $program, $type, 'off', '', 'iframe', true);
if($program->status == 'closed') $menu .= $this->buildMenu('project', 'activate', $params, $program, $type, 'magic', '', 'iframe', true);
if(common::hasPriv('project', 'suspend') || (common::hasPriv('project', 'close') && $program->status != 'doing') || (common::hasPriv('project', 'activate') && $program->status != 'closed'))
{
$menu .= "<div class='btn-group'>";
$menu .= "<button type='button' class='btn icon-caret-down dropdown-toggle' data-toggle='dropdown' title='{$this->lang->more}' style='width: 16px; padding-left: 0px;'></button>";
$menu .= "<ul class='dropdown-menu pull-right text-center' role='menu' style='min-width:auto; padding: 5px 10px;'>";
$menu .= $this->buildMenu('project', 'suspend', $params, $program, $type, 'pause', '', 'iframe', true);
if($program->status != 'doing') $menu .= $this->buildMenu('project', 'close', $params, $program, $type, 'off', '', 'iframe', true);
if($program->status != 'closed') $menu .= $this->buildMenu('project', 'activate', $params, $program, $type, 'magic', '', 'iframe', true);
$menu .= "</ul>";
$menu .= "</div>";
}
$class = $program->model == 'kanban' ? 'disabled' : '';
$menu .= $this->buildMenu('project', 'edit', $params, $program, $type, 'edit', '', 'iframe', true);
$menu .= $this->buildMenu('project', 'team', $params, $program, $type, 'group', '', $class, '', 'data-app="project"');
$menu .= $this->buildMenu('project', 'group', $params, $program, $type, 'lock', '', $class, '', 'data-app="project"');
if(common::hasPriv('project', 'manageProducts') || common::hasPriv('project', 'whitelist') || common::hasPriv('project', 'delete'))
{
$menu .= "<div class='btn-group'>";
$menu .= "<button type='button' class='btn dropdown-toggle' data-toggle='dropdown' title='{$this->lang->more}'><i class='icon-more-alt'></i></button>";
$menu .= "<ul class='dropdown-menu pull-right text-center' role='menu'>";
$menu .= $this->buildMenu('project', 'manageProducts', "$params&from=browse", $program, $type, 'link', '', $class, '', "data-app={$this->app->tab}");
$menu .= $this->buildMenu('project', 'whitelist', "$params&module=project&from=browse", $program, $type, 'shield-check', '', $class, '', "data-app='project'");
if(common::hasPriv('project','delete'))
{
$menu .= $this->buildMenu("project", "delete", $params, $program, $type, 'trash', 'hiddenwin', '', '', "data-group='program'", $this->lang->delete);
}
$menu .= "</ul>";
$menu .= "</div>";
}
}
return $menu;
}
}
+1 -48
View File
@@ -85,54 +85,7 @@
</td>
<?php foreach($extendFields as $extendField) echo "<td>" . $this->loadModel('flow')->getFieldValue($extendField, $program) . "</td>";?>
<td class='c-actions'>
<?php if($program->type == 'program' and strpos(",{$app->user->view->programs},", ",$program->id,") !== false):?>
<?php if($program->status == 'wait' || $program->status == 'suspended') common::printIcon('program', 'start', "programID=$program->id", $program, 'list', 'play', '', 'iframe', true, '', $this->lang->program->start);?>
<?php if($program->status == 'doing') common::printIcon('program', 'close', "programID=$program->id", $program, 'list', 'off', '', 'iframe', true);?>
<?php if($program->status == 'closed') common::printIcon('program', 'activate', "programID=$program->id", $program, 'list', 'magic', '', 'iframe', true);?>
<?php if(common::hasPriv('program', 'suspend') || (common::hasPriv('program', 'close') && $program->status != 'doing') || (common::hasPriv('program', 'activate') && $program->status != 'closed')):?>
<div class='btn-group'>
<button type='button' class='btn icon-caret-down dropdown-toggle' data-toggle='dropdown' title="<?php echo $this->lang->more;?>" style="width: 16px; padding-left: 0px;"></button>
<ul class='dropdown-menu pull-right text-center' role='menu' style="min-width:auto; padding: 5px 10px;">
<?php common::printIcon('program', 'suspend', "programID=$program->id", $program, 'list', 'pause', '', 'iframe', true, '', $this->lang->program->suspend);?>
<?php if($program->status != 'doing') common::printIcon('program', 'close', "programID=$program->id", $program, 'list', 'off', '', 'iframe', true);?>
<?php if($program->status != 'closed') common::printIcon('program', 'activate', "programID=$program->id", $program, 'list', 'magic', '', 'iframe', true);?>
</ul>
</div>
<?php endif;?>
<?php common::printIcon('program', 'edit', "programID=$program->id", '', 'list', 'edit');?>
<?php common::printIcon('program', 'create', "programID=$program->id", '', 'list', 'split', '', '', '', $program->status == 'closed' ? 'disabled' : '', $this->lang->program->children);?>
<?php if(common::hasPriv('program', 'delete')) echo html::a($this->createLink("program", "delete", "programID=$program->id"), "<i class='icon-trash'></i>", 'hiddenwin', "class='btn' title='{$this->lang->program->delete}'");?>
<?php elseif($program->type == 'project'):?>
<?php if($program->status == 'wait' || $program->status == 'suspended') common::printIcon('project', 'start', "projectID=$program->id", $program, 'list', 'play', '', 'iframe', true);?>
<?php if($program->status == 'doing') common::printIcon('project', 'close', "projectID=$program->id", $program, 'list', 'off', '', 'iframe', true);?>
<?php if($program->status == 'closed') common::printIcon('project', 'activate', "projectID=$program->id", $program, 'list', 'magic', '', 'iframe', true);?>
<?php if(common::hasPriv('project', 'suspend') || (common::hasPriv('project', 'close') && $program->status != 'doing') || (common::hasPriv('project', 'activate') && $program->status != 'closed')):?>
<div class='btn-group'>
<button type='button' class='btn icon-caret-down dropdown-toggle' data-toggle='dropdown' title="<?php echo $this->lang->more;?>" style="width: 16px; padding-left: 0px;"></button>
<ul class='dropdown-menu pull-right text-center' role='menu' style="min-width:auto; padding: 5px 10px;">
<?php common::printIcon('project', 'suspend', "projectID=$program->id", $program, 'list', 'pause', '', 'iframe', true);?>
<?php if($program->status != 'doing') common::printIcon('project', 'close', "projectID=$program->id", $program, 'list', 'off', '', 'iframe', true);?>
<?php if($program->status != 'closed') common::printIcon('project', 'activate', "projectID=$program->id", $program, 'list', 'magic', '', 'iframe', true);?>
</ul>
</div>
<?php endif;?>
<?php $class = $program->model == 'kanban' ? 'disabled' : '';?>
<?php common::printIcon('project', 'edit', "projectID=$program->id", $program, 'list', 'edit', '', 'iframe', true);?>
<?php common::printIcon('project', 'team', "projectID=$program->id", $program, 'list', 'group', '', "$class", '', 'data-app="project"');?>
<?php common::printIcon('project', 'group', "projectID=$program->id", $program, 'list', 'lock', '', "$class", '', 'data-app="project"');?>
<?php if(common::hasPriv('project', 'manageProducts') || common::hasPriv('project', 'whitelist') || common::hasPriv('project', 'delete')):?>
<div class='btn-group'>
<button type='button' class='btn dropdown-toggle' data-toggle='dropdown' title="<?php echo $this->lang->more;?>"><i class='icon-more-alt'></i></button>
<ul class='dropdown-menu pull-right text-center' role='menu'>
<?php common::printIcon('project', 'manageProducts', "projectID=$program->id&from=browse", $program, 'list', 'link', '', "$class", '', "data-app={$this->app->tab}");?>
<?php common::printIcon('project', 'whitelist', "projectID=$program->id&module=project&from=browse", $program, 'list', 'shield-check', '', "$class", '', "data-app='project'");?>
<?php if(common::hasPriv('project','delete')) echo html::a($this->createLink("project", "delete", "projectID=$program->id"), "<i class='icon-trash'></i>", 'hiddenwin', "class='btn' title='{$this->lang->delete}' data-group='program'");?>
</ul>
</div>
<?php endif;?>
<?php endif;?>
<?php echo $this->program->buildOperateMenu($program, 'browse');?>
</td>
</tr>
<?php endforeach;?>