* code for task #7646.

This commit is contained in:
z
2020-08-21 10:31:07 +08:00
parent ea00a09d72
commit 20d3cab272
+14 -21
View File
@@ -94,11 +94,8 @@ class programModel extends model
$this->dao->update(TABLE_PROJECT)->set('`order`')->eq($programID * 5)->where('id')->eq($programID)->exec();
$this->file->updateObjectID($this->post->uid, $programID, 'project');
if($project->parent > 0)
{
$this->dao->update(TABLE_PROJECT)->set('isCat')->eq(1)->where('id')->eq($project->parent)->exec();
$this->fixPath($programID);
}
if($project->parent > 0) $this->dao->update(TABLE_PROJECT)->set('isCat')->eq(1)->where('id')->eq($project->parent)->exec();
$this->setTreePath($programID);
/* Add program admin.*/
$groupPriv = $this->dao->select('t1.*')->from(TABLE_USERGROUP)->alias('t1')
@@ -221,24 +218,20 @@ class programModel extends model
return $count > 0;
}
public function fixPath($programID)
public function setTreePath($programID)
{
$path = array();
$program = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($programID)->fetch();
if($program->parent == 0)
{
$path['path'] = ",{$program->id},";
$path['grade'] = 1;
$this->dao->update(TABLE_PROJECT)->set('path')->eq($path['path'])->set('grade')->eq($path['grade'])->where('id')->eq($program->id)->exec();
}
else
{
$path = $this->fixPath($program->parent);
$path['path'] .= "{$program->id},";
$path['grade'] += 1;
$this->dao->update(TABLE_PROJECT)->set('path')->eq($path['path'])->set('grade')->eq($path['grade'])->where('id')->eq($program->id)->exec();
}
return $path;
$path['path'] = ",{$program->id},";
$path['grade'] = 1;
if($program->parent)
{
$parent = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($program->parent)->fetch();
$path['path'] = $parent->path . "{$program->id},";
$path['grade'] = $parent->grade + 1;
}
$this->dao->update(TABLE_PROJECT)->set('path')->eq($path['path'])->set('grade')->eq($path['grade'])->where('id')->eq($program->id)->exec();
}
}