diff --git a/module/execution/control.php b/module/execution/control.php index 5273669242..2560b74d99 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2171,7 +2171,6 @@ class execution extends control $this->execution->manageMembers($execution, $memberDataList); if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); - $this->loadModel('action')->create('team', $executionID, 'managedTeam'); return $this->sendSuccess(array('load' => $this->createLink('execution', 'team', "executionID={$executionID}"))); } diff --git a/module/execution/model.php b/module/execution/model.php index 6f376013a6..0daaa2f77e 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -3089,13 +3089,27 @@ class executionModel extends model /* Only changed account update userview. */ $oldAccountList = array_keys($oldJoin); - $changedAccountList = array_diff($accountList, $oldAccountList); - $changedAccountList = array_merge($changedAccountList, array_diff($oldAccountList, $accountList)); + $addedAccountList = array_diff($accountList, $oldAccountList); + $removedAccountList = array_diff($oldAccountList, $accountList); + $changedAccountList = array_merge($addedAccountList, $removedAccountList); $changedAccountList = array_unique($changedAccountList); /* Add the execution team members to the project. */ if($execution->project) $this->addProjectMembers($execution->project, $executionMember); if($execution->acl != 'open') $this->updateUserView($execution->id, 'sprint', $changedAccountList); + + /* Log history. */ + $actionID = $this->loadModel('action')->create('execution', $execution->id, 'managedTeam'); + + if(empty($addedAccountList) && empty($removedAccountList)) return; + + $users = $this->loadModel('user')->getPairs('noletter'); + $addedAccountList = array_map(function($account) use ($users) { return $users[$account]; }, $addedAccountList); + $removedAccountList = array_map(function($account) use ($users) { return $users[$account]; }, $removedAccountList); + + if(!empty($addedAccountList)) $changes[] = array('field' => 'addDiff', 'old' => '', 'new' => '', 'diff' => join(',', $addedAccountList)); + if(!empty($removedAccountList)) $changes[] = array('field' => 'removeDiff', 'old' => '', 'new' => '', 'diff' => join(',', $removedAccountList)); + if(!empty($changes)) $this->action->logHistory($actionID, $changes); } /**