* Code for task #41238.
This commit is contained in:
@@ -172,6 +172,38 @@ class project extends control
|
||||
echo $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get unlink tips when unlink team member.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param int $account
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetUnlinkTips($projectID, $account)
|
||||
{
|
||||
$executions = $this->loadModel('execution')->getByProject($projectID, 'undone', 0, true);
|
||||
$executionMembers = $this->dao->select('t1.root,t2.name')->from(TABLE_TEAM)->alias('t1')
|
||||
->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.root=t2.id')
|
||||
->where('t1.root')->in(array_keys($executions))
|
||||
->andWhere('t1.type')->eq('execution')
|
||||
->andWhere('t1.account')->eq($account)
|
||||
->fetchPairs();
|
||||
|
||||
$executionNames = '';
|
||||
$count = 0;
|
||||
foreach($executionMembers as $executionName)
|
||||
{
|
||||
if($count == 0) $executionNames = $executionName;
|
||||
if($count == 1) $executionNames .= ',' . $executionName;
|
||||
if($count > 1) break;
|
||||
$count++;
|
||||
}
|
||||
if(count($executionMembers) <= 2) $this->lang->project->etc = ' ';
|
||||
$this->lang->project->unlinkExecutionMember = sprintf($this->lang->project->unlinkExecutionMember, $executionNames, $this->lang->project->etc, count($executionMembers));
|
||||
die($this->lang->project->unlinkExecutionMember);
|
||||
}
|
||||
|
||||
/**
|
||||
* Project index view.
|
||||
*
|
||||
@@ -1139,17 +1171,18 @@ class project extends control
|
||||
* @param int $projectID
|
||||
* @param int $userID
|
||||
* @param string $confirm yes|no
|
||||
* @param string $removeExecution yes|no
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function unlinkMember($projectID, $userID, $confirm = 'no')
|
||||
public function unlinkMember($projectID, $userID, $confirm = 'no', $removeExecution = 'no')
|
||||
{
|
||||
if($confirm == 'no') die(js::confirm($this->lang->project->confirmUnlinkMember, $this->inlink('unlinkMember', "projectID=$projectID&userID=$userID&confirm=yes")));
|
||||
|
||||
$user = $this->loadModel('user')->getById($userID, 'id');
|
||||
$account = $user->account;
|
||||
|
||||
$this->project->unlinkMember($projectID, $account);
|
||||
$this->project->unlinkMember($projectID, $account, $removeExecution);
|
||||
if(!dao::isError()) $this->loadModel('action')->create('team', $projectID, 'managedTeam');
|
||||
|
||||
/* if ajax request, send result. */
|
||||
|
||||
@@ -2,3 +2,38 @@ function checkUserDept(userID)
|
||||
{
|
||||
alert(noAccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete memeber of project team.
|
||||
*
|
||||
* @param projectID $projectID
|
||||
* @param account $account
|
||||
* @param userID $userID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function deleteMemeber(projectID, account, userID)
|
||||
{
|
||||
if(confirm(confirmUnlinkMember))
|
||||
{
|
||||
var removeConfirm = '';
|
||||
var tipsLink = createLink('project', 'ajaxGetUnlinkTips', 'projectID=' + projectID + '&account=' + account);
|
||||
$.get(tipsLink, function(tips)
|
||||
{
|
||||
if(confirm(tips))
|
||||
{
|
||||
var unlinkURL = createLink('project', 'unlinkMember', 'projectID=' + projectID + '&userID=' + userID + '&confirm=yes&removeExecution=yes');
|
||||
}
|
||||
else
|
||||
{
|
||||
var unlinkURL = createLink('project', 'unlinkMember', 'projectID=' + projectID + '&userID=' + userID + '&confirm=yes&removeExecution=no');
|
||||
}
|
||||
|
||||
$.get(unlinkURL, function(data)
|
||||
{
|
||||
data = JSON.parse(data);
|
||||
if(data.result == 'success') window.location.reload();
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ $lang->project->longTime = '长期';
|
||||
$lang->project->future = '待定';
|
||||
$lang->project->moreProject = '更多项目';
|
||||
$lang->project->days = '可用工作日';
|
||||
$lang->project->etc = "等";
|
||||
|
||||
$lang->project->productNotEmpty = '请关联产品或创建产品。';
|
||||
$lang->project->existProductName = '产品名称已存在。';
|
||||
@@ -138,6 +139,7 @@ $lang->project->linkedProjectsTip = '关联的项目如下';
|
||||
$lang->project->multiLinkedProductsTip = '该项目关联的如下产品还关联了其他项目,请取消关联后再操作';
|
||||
$lang->project->linkStoryByPlanTips = "此操作会将所选计划下面的{$lang->SRCommon}全部关联到此项目中";
|
||||
$lang->project->createExecution = "该项目下没有{$lang->executionCommon},请先创建{$lang->executionCommon}";
|
||||
$lang->project->unlinkExecutionMember = "该用户参与了%s%s%s个{$lang->executionCommon},是否同时将其移除?(该用户所产生的数据不会受影响。)";
|
||||
|
||||
$lang->project->tenThousand = '万';
|
||||
|
||||
|
||||
@@ -1261,13 +1261,20 @@ class projectModel extends model
|
||||
*
|
||||
* @param int $projectID
|
||||
* @param string $account
|
||||
* @param string $removeExecution no|yes
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function unlinkMember($projectID, $account)
|
||||
public function unlinkMember($projectID, $account, $removeExecution = 'no')
|
||||
{
|
||||
$this->dao->delete()->from(TABLE_TEAM)->where('root')->eq((int)$projectID)->andWhere('type')->eq('project')->andWhere('account')->eq($account)->exec();
|
||||
|
||||
if($removeExecution == 'yes')
|
||||
{
|
||||
$executions = $this->loadModel('execution')->getByProject($projectID, 'undone', 0, true);
|
||||
$this->dao->delete()->from(TABLE_TEAM)->where('root')->in(array_keys($executions))->andWhere('type')->eq('execution')->andWhere('account')->eq($account)->exec();
|
||||
}
|
||||
|
||||
$this->loadModel('user');
|
||||
$this->user->updateUserView($projectID, 'project', array($account));
|
||||
|
||||
|
||||
@@ -91,8 +91,7 @@
|
||||
<?php
|
||||
if (common::hasPriv('project', 'unlinkMember', $member))
|
||||
{
|
||||
$unlinkURL = $this->createLink('project', 'unlinkMember', "projectID=$projectID&userID=$member->userID&confirm=yes");
|
||||
echo html::a("javascript:ajaxDelete(\"$unlinkURL\", \"mainContent\", confirmUnlinkMember)", '<i class="icon-green-project-unlinkMember icon-unlink"></i>', '', "class='btn' title='{$lang->project->unlinkMember}'");
|
||||
echo html::a("javascript:deleteMemeber($projectID, \"{$member->account}\", \"{$member->userID}\")", '<i class="icon-green-project-unlinkMember icon-unlink"></i>', '', "class='btn' title='{$lang->project->unlinkMember}'");
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user