* adjust for change isCat field.

This commit is contained in:
z
2020-08-24 15:30:00 +08:00
parent afb11b19de
commit 6ee48f38f7
3 changed files with 28 additions and 1 deletions
+2
View File
@@ -103,3 +103,5 @@ $lang->program->cmmiDesc = '<strong>简介:</strong>按阶段规范
$lang->program->cannotCreateChild = '该项目已经有实际的内容,无法直接添加子项目。您可以为当前项目创建一个父项目,然后在新的父项目下面添加子项目。';
$lang->program->hasChildren = '该项目有子项目存在,不能删除。';
$lang->program->confirmDelete = "您确定删除项目[%s]吗?";
$lang->program->cannotChangeToCat = "该项目已经有实际的内容,无法修改为父项目";
$lang->program->cannotCancelCat = "该项目下已经有子项目,无法取消父项目标记";
+20
View File
@@ -327,6 +327,11 @@ class programModel extends model
->get();
$program = $this->loadModel('file')->processImgURL($program, $this->config->program->editor->edit['id'], $this->post->uid);
if(!empty($program->isCat) and $this->checkHasContent($programID)) dao::$errors['isCat'] = $this->lang->program->cannotChangeToCat;
if(empty($program->isCat) and $this->checkHasChildren($programID)) dao::$errors['isCat'] = $this->lang->program->cannotCancelCat;
if(dao::isError()) return false;
$this->dao->update(TABLE_PROJECT)->data($program)
->autoCheck($skipFields = 'begin,end')
->batchcheck($this->config->program->edit->requiredFields, 'notempty')
@@ -397,6 +402,8 @@ class programModel extends model
{
$action = strtolower($action);
if(empty($program)) return true;
if($action == 'start') return $program->status == 'wait' or $program->status == 'suspended';
if($action == 'finish') return $program->status == 'wait' or $program->status == 'doing';
if($action == 'close') return $program->status != 'closed';
@@ -437,6 +444,19 @@ class programModel extends model
return $count > 0;
}
/**
* Check has children project.
*
* @param int $programID
* @access public
* @return bool
*/
public function checkHasChildren($programID)
{
$count = $this->dao->select('count(*) as count')->from(TABLE_PROJECT)->where('parent')->eq($programID)->fetch('count');
return $count > 0;
}
/**
* Set program tree path.
*
+6 -1
View File
@@ -28,7 +28,12 @@
<tr>
<th class='w-120px'><?php echo $lang->program->name;?></th>
<td class="col-main"><?php echo html::input('name', $program->name, "class='form-control' required");?></td>
<td></td><td></td>
<td>
<div class="checkbox-primary">
<input type="checkbox" name="isCat" value="1" id="isCat" <?php if($program->isCat) echo "checked";?>>
<label for="isCat"><?php echo $lang->program->parent;?></label>
</div>
</td><td></td>
</tr>
<tr>
<th><?php echo $lang->program->code;?></th>