Merge branch 'sprint/zentaopms240_wangyuting' into 'sprint/zentaopms240'
* Optimize code. See merge request easycorp/zentaopms!5394
This commit is contained in:
+24
-14
@@ -1598,26 +1598,36 @@ class programModel extends model
|
||||
*/
|
||||
public function createDefaultProgram()
|
||||
{
|
||||
$account = isset($this->app->user->account) ? $this->app->user->account : '';
|
||||
$minBegin = $this->dao->select('min(begin) as min')->from(TABLE_PROJECT)->where('deleted')->eq(0)->fetch('min');
|
||||
$program = new stdClass();
|
||||
|
||||
$program->type = 'program';
|
||||
$program->name = $this->lang->program->defaultProgram;
|
||||
$program->budgetUnit = 'CNY';
|
||||
$program->whitelist = '';
|
||||
$program->status = 'doing';
|
||||
$program->grade = 1;
|
||||
$program->auth = 'extend';
|
||||
$program->openedDate = helper::today();
|
||||
$program->begin = $minBegin;
|
||||
$program->end = LONG_TIME;
|
||||
$program = new stdclass();
|
||||
$program->name = $this->lang->program->defaultProgram;
|
||||
$program->type = 'program';
|
||||
$program->budgetUnit = 'CNY';
|
||||
$program->status = 'doing';
|
||||
$program->auth = 'extend';
|
||||
$program->begin = $minBegin;
|
||||
$program->end = LONG_TIME;
|
||||
$program->openedBy = $account;
|
||||
$program->openedDate = helper::now();
|
||||
$program->openedVersion = $this->config->version;
|
||||
$program->acl = 'open';
|
||||
$program->grade = 1;
|
||||
$program->vision = 'rnd';
|
||||
|
||||
$this->app->loadLang('program');
|
||||
$this->app->loadLang('project');
|
||||
$this->lang->project->name = $this->lang->program->name;
|
||||
|
||||
$this->dao->insert(TABLE_PROGRAM)->data($program)->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$insertID = $this->dao->lastInsertId();
|
||||
$programID = $this->dao->lastInsertId();
|
||||
|
||||
$this->dao->update(TABLE_PROGRAM)->set('path')->eq(",$insertID,")->where('id')->eq($insertID)->exec();
|
||||
$this->dao->update(TABLE_PROGRAM)->set('path')->eq(",{$programID},")->set('`order`')->eq($programID * 5)->where('id')->eq($programID)->exec();
|
||||
$this->loadModel('action')->create('program', $programID, 'openedbysystem');
|
||||
|
||||
return $insertID;
|
||||
return $programID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -710,9 +710,11 @@ class upgrade extends control
|
||||
$mergeMode = $this->post->projectType;
|
||||
if($mergeMode == 'manually') $this->locate(inlink('mergeProgram'));
|
||||
|
||||
$program = $this->upgrade->createDefaultProgram();
|
||||
if($mergeMode == 'project') $this->upgrade->upgradeInProjectMode($program->id);
|
||||
if($mergeMode == 'execution') $this->upgrade->upgradeInExecutionMode($program->id);
|
||||
if($mode == 'lean') $programID = $this->config->defaultProgram;
|
||||
if($mode == 'new') $programID = $this->loadModel('program')->createDefaultProgram();
|
||||
|
||||
if($mergeMode == 'project') $this->upgrade->upgradeInProjectMode($programID);
|
||||
if($mergeMode == 'execution') $this->upgrade->upgradeInExecutionMode($programID);
|
||||
|
||||
if(dao::isError()) return print(js::error(dao::getError()));
|
||||
$this->locate(inlink('afterExec', "fromVersion=$fromVersion"));
|
||||
|
||||
Reference in New Issue
Block a user