* Task #5423
This commit is contained in:
yfl
2019-05-06 16:33:10 +08:00
13 changed files with 538 additions and 454 deletions
+110 -33
View File
@@ -204,39 +204,116 @@ $lang->action->label->linked2bug = "关联了";
/* 动态信息按照对象分组 */
$lang->action->dynamicAction = new stdclass;
$lang->action->dynamicAction->product['opened'] = '创建';
$lang->action->dynamicAction->product['edited'] = '编辑';
$lang->action->dynamicAction->product['deleted'] = '删除';
$lang->action->dynamicAction->product['closed'] = '关闭';
$lang->action->dynamicAction->story['opened'] = '创建';
$lang->action->dynamicAction->story['edited'] = '编辑';
$lang->action->dynamicAction->story['deleted'] = '删除';
$lang->action->dynamicAction->story['changed'] = '变更';
$lang->action->dynamicAction->story['changed'] = '变更';
$lang->action->dynamicAction->story['linked2project'] = "关联{$lang->projectCommon}";
$lang->action->dynamicAction->story['unlinkedfromproject'] = "移除{$lang->projectCommon}";
$lang->action->dynamicAction->story['subdividestory'] = $lang->action->label->subdividestory;
$lang->action->dynamicAction->story['unlinkchildstory'] = $lang->action->label->unlinkchildstory;
$lang->action->dynamicAction->story['undeleted'] = '还原';
$lang->action->dynamicAction->story['hidden'] = '隐藏';
$lang->action->dynamicAction->project['opened'] = '创建';
$lang->action->dynamicAction->project['edited'] = '编辑';
$lang->action->dynamicAction->project['deleted'] = '删除';
$lang->action->dynamicAction->project['closed'] = '关闭';
$lang->action->dynamicAction->project['activated'] = '激活';
$lang->action->dynamicAction->task['opened'] = '创建';
$lang->action->dynamicAction->task['edited'] = '编辑';
$lang->action->dynamicAction->task['deleted'] = '删除';
$lang->action->dynamicAction->bug['opened'] = '创建';
$lang->action->dynamicAction->bug['edited'] = '编辑';
$lang->action->dynamicAction->bug['deleted'] = '删除';
$lang->action->dynamicAction->bug['resolved'] = '解决';
$lang->action->dynamicAction->bug['bugconfirmed'] = '确认';
$lang->action->dynamicAction->bug['assigned'] = '指派';
$lang->action->dynamicAction->bug['activated'] = '激活';
$lang->action->dynamicAction->doc['opened'] = '创建';
$lang->action->dynamicAction->doc['edited'] = '编辑';
$lang->action->dynamicAction->doc['deleted'] = '删除';
$lang->action->dynamicAction->todo['opened'] = '创建待办';
$lang->action->dynamicAction->todo['edited'] = '编辑待办';
$lang->action->dynamicAction->todo['erased'] = '删除待办';
$lang->action->dynamicAction->todo['finished'] = '完成待办';
$lang->action->dynamicAction->todo['activated'] = '激活待办';
$lang->action->dynamicAction->todo['closed'] = '关闭待办';
$lang->action->dynamicAction->todo['deleted'] = '删除待办';
$lang->action->dynamicAction->todo['assigned'] = '指派';
$lang->action->dynamicAction->product['opened'] = '创建' . $lang->productCommon;
$lang->action->dynamicAction->product['deleted'] = '删除' . $lang->productCommon;
$lang->action->dynamicAction->product['edited'] = '编辑' . $lang->productCommon;
$lang->action->dynamicAction->product['closed'] = '关闭' . $lang->productCommon;
$lang->action->dynamicAction->productplan['opened'] = '创建产品计划';
$lang->action->dynamicAction->productplan['edited'] = '编辑产品计划';
$lang->action->dynamicAction->release['opened'] = '创建发布';
$lang->action->dynamicAction->release['edited'] = '编辑发布';
$lang->action->dynamicAction->release['changestatus'] = '修改状态';
$lang->action->dynamicAction->story['opened'] = '创建需求';
$lang->action->dynamicAction->story['edited'] = '编辑需求';
$lang->action->dynamicAction->story['activated'] = '激活需求';
$lang->action->dynamicAction->story['reviewed'] = '评审需求';
$lang->action->dynamicAction->story['closed'] = '关闭需求';
$lang->action->dynamicAction->story['assigned'] = '指派';
$lang->action->dynamicAction->story['closed'] = '关闭需求';
$lang->action->dynamicAction->story['linked2plan'] = '需求关联计划';
$lang->action->dynamicAction->story['unlinkedfromplan'] = '计划移除需求';
$lang->action->dynamicAction->story['linked2release'] = '需求关联发布';
$lang->action->dynamicAction->story['unlinkedfromrelease'] = '发布移除需求';
$lang->action->dynamicAction->story['linked2build'] = '需求关联版本';
$lang->action->dynamicAction->story['unlinkedfrombuild'] = '版本移除需求';
$lang->action->dynamicAction->story['unlinkedfromproject'] = '移除项目';
$lang->action->dynamicAction->project['opened'] = '创建项目';
$lang->action->dynamicAction->project['undeleted'] = '删除项目';
$lang->action->dynamicAction->project['edited'] = '编辑项目';
$lang->action->dynamicAction->project['started'] = '开始项目';
$lang->action->dynamicAction->project['delayed'] = '延期项目';
$lang->action->dynamicAction->project['suspended'] = '挂起项目';
$lang->action->dynamicAction->project['activated'] = '激活项目';
$lang->action->dynamicAction->project['closed'] = '关闭项目';
$lang->action->dynamicAction->project['managed'] = '维护项目';
$lang->action->dynamicAction->task['opened'] = '创建任务';
$lang->action->dynamicAction->task['commented'] = '任务备注';
$lang->action->dynamicAction->task['edited'] = '编辑任务';
$lang->action->dynamicAction->task['assigned'] = '任务指派';
$lang->action->dynamicAction->task['confirmed'] = '任务确认';
$lang->action->dynamicAction->task['started'] = '开始任务';
$lang->action->dynamicAction->task['editestimate'] = '编辑记录';
$lang->action->dynamicAction->task['deleteestimate'] = '删除记录';
$lang->action->dynamicAction->task['finished'] = '任务完成';
$lang->action->dynamicAction->task['paused'] = '任务暂停';
$lang->action->dynamicAction->task['closed'] = '任务关闭';
$lang->action->dynamicAction->task['canceled'] = '任务取消';
$lang->action->dynamicAction->task['activated'] = '任务激活';
$lang->action->dynamicAction->task['createchildren'] = '创建子任务';
$lang->action->dynamicAction->task['unlinkparenttask'] = '取消关联父任务';
$lang->action->dynamicAction->task['linkparenttask'] = '关联父任务';
$lang->action->dynamicAction->task['linkchildtask'] = '关联子任务';
$lang->action->dynamicAction->task['recordestimate'] = '记录日志';
$lang->action->dynamicAction->task['moved'] = '移动任务';
$lang->action->dynamicAction->build['opened'] = '创建版本';
$lang->action->dynamicAction->build['edited'] = '编辑版本';
$lang->action->dynamicAction->bug['opened'] = '创建bug';
$lang->action->dynamicAction->bug['edited'] = '编辑bug';
$lang->action->dynamicAction->bug['totask'] = '转任务';
$lang->action->dynamicAction->bug['activated'] = '激活bug';
$lang->action->dynamicAction->bug['assigned'] = '激活bug';
$lang->action->dynamicAction->bug['tostory'] = '转需求';
$lang->action->dynamicAction->bug['closed'] = '关闭bug';
$lang->action->dynamicAction->bug['bugconfirmed'] = '确认Bug';
$lang->action->dynamicAction->bug['confirmed'] = '确认需求变动';
$lang->action->dynamicAction->bug['linked2plan'] = '关联计划';
$lang->action->dynamicAction->bug['resolved'] = '解决bug';
$lang->action->dynamicAction->bug['unlinkedfromplan'] = '从计划中移除';
$lang->action->dynamicAction->bug['linked2release'] = '关联发布';
$lang->action->dynamicAction->bug['unlinkedfromrelease'] = '从发布中移除';
$lang->action->dynamicAction->bug['linked2bug'] = '关联到版本';
$lang->action->dynamicAction->bug['unlinkedfrombuild'] = '从版本中移除';
$lang->action->dynamicAction->testtask['started'] = '开始用例';
$lang->action->dynamicAction->testtask['activated'] = '激活用例';
$lang->action->dynamicAction->testtask['closed'] = '关闭用例';
$lang->action->dynamicAction->testtask['blocked'] = '阻塞用例';
$lang->action->dynamicAction->testtask['edited'] = '编辑用例';
$lang->action->dynamicAction->testtask['opened'] = '创建用例';
$lang->action->dynamicAction->case['opened'] = '创建用例';
$lang->action->dynamicAction->case['edited'] = '编辑用例';
$lang->action->dynamicAction->case['reviewed'] = '记录评审结果';
$lang->action->dynamicAction->case['confirmed'] = '确认用例';
$lang->action->dynamicAction->case['fromlib'] = '从用例库导入';
$lang->action->dynamicAction->testreport['opened'] = '创建测试报告';
$lang->action->dynamicAction->testreport['edited'] = '编辑测试报告';
$lang->action->dynamicAction->testsuite['opened'] = '创建测试套件';
$lang->action->dynamicAction->caselib['opened'] = '创建用例库';
$lang->action->dynamicAction->docLib['created'] = '创建文档库';
$lang->action->dynamicAction->docLib['edited'] = '编辑文档库';
$lang->action->dynamicAction->doc['created'] = '创建文档';
$lang->action->dynamicAction->doc['edited'] = '编辑文档';
$lang->action->dynamicAction->doc['commented'] = '评论文档';
$lang->action->dynamicAction->user['login'] = '用户登录';
$lang->action->dynamicAction->user['created'] = '创建用户';
$lang->action->dynamicAction->user['edited'] = '编辑用户';
$lang->action->dynamicAction->user['logout'] = '用户退出';
$lang->action->dynamicAction->user['loginxuanxuan'] = '登录喧喧';
$lang->action->dynamicAction->entry['created'] = '添加应用';
$lang->action->dynamicAction->entry['edited'] = '编辑应用';
/* 用来生成相应对象的链接。*/
$lang->action->label->product = $lang->productCommon . '|product|view|productID=%s';
+7 -7
View File
@@ -616,15 +616,15 @@ class actionModel extends model
$libs = $this->doc->getLibs('all');
$docs = $this->doc->getPrivDocs(array_keys($libs));
$setDynamicActions = array();
$actions = '';
if(isset($this->config->global->setdynamic) and $this->config->global->setdynamic != 'false')
$actionCondition = '';
if(isset($this->app->user->rights['acls']['actions']))
{
$setDynamicActions = json_decode($this->config->global->setdynamic, true);
foreach($setDynamicActions as $moudle => $action)
if(empty($this->app->user->rights['acls']['actions'])) return array();
foreach($this->app->user->rights['acls']['actions'] as $moduleName => $actions)
{
$actions .= implode(',', $action) . ',';
$actionCondition .= "(`objectType` = '$moduleName' and `action` " . helper::dbIN($actions) . ") or ";
}
$actionCondition = trim($actionCondition, 'or ');
}
/* Get actions. */
@@ -644,7 +644,7 @@ class actionModel extends model
->beginIF($this->config->global->flow == 'onlyStory')->andWhere('objectType')->notin('bug,build,project,task,taskcase,testreport,testsuite,testtask')->fi()
->beginIF($this->config->global->flow == 'onlyTask')->andWhere('objectType')->notin('product,productplan,release,story,testcase,testreport,testsuite')->fi()
->beginIF($this->config->global->flow == 'onlyTest')->andWhere('objectType')->notin('project,productplan,release,story,task')->fi()
->beginIF(!empty($setDynamicActions))->andWhere('objectType')->in(array_keys($setDynamicActions))->andWhere('action')->in($actions)->fi()
->beginIF(!empty($actionCondition))->andWhere("($actionCondition)")->fi()
->orderBy($orderBy)
->page($pager)
->fetchAll();
-28
View File
@@ -323,34 +323,6 @@ class custom extends control
$this->display();
}
/**
*Set dynamic recode what action
*
* @access public
* @return void
*/
public function setDynamic()
{
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$actions = $this->post->actions;
$actions = json_encode($actions);
$this->loadModel('setting')->setItem('system.common.global.setdynamic', $actions);
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'reload'));
}
$this->app->loadLang('action');
$this->app->loadLang('group');
$this->view->title = $this->lang->custom->setDynamic;
$this->view->position[] = $this->lang->custom->common;
$this->view->position[] = $this->view->title;
$this->view->objectTypes = $this->lang->action->objectTypes;
$this->view->dynamicAction = $this->lang->action->dynamicAction;
$this->view->actions = $this->lang->action->search->label;
$this->view->setActions = json_decode($this->loadModel('setting')->getItem("owner=system&module=common&section=global&key=setdynamic"), true);
$this->display();
}
/**
* Timezone.
*
+1 -3
View File
@@ -18,8 +18,6 @@ $lang->custom->required = '必填项';
$lang->custom->score = '积分';
$lang->custom->timezone = '时区';
$lang->custom->scoreReset = '重置积分';
$lang->custom->setDynamic = '动态设置';
$lang->custom->setAction = '设置动作';
$lang->custom->object['story'] = '需求';
$lang->custom->object['task'] = '任务';
@@ -79,7 +77,7 @@ $lang->custom->user->fields['statusList'] = '状态';
$lang->custom->user->fields['contactField'] = '可用联系方式';
$lang->custom->user->fields['deleted'] = '列出已删除用户';
$lang->custom->system = array('flow', 'working', 'required', 'score', 'setDynamic');
$lang->custom->system = array('flow', 'working', 'required', 'score');
$lang->custom->block->fields['closed'] = '关闭的区块';
-61
View File
@@ -1,61 +0,0 @@
<?php
/**
* The score view file of custom module of ZenTaoPMS.
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Memory <lvtao@cnezsoft.com>
* @package custom
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include 'header.html.php';?>
<style>
.checkbox-primary{float:left;margin-left:5px;}
</style>
<div id='mainContent' class='main-content'>
<form class="load-indicator main-form form-ajax" method='post'>
<div class='main-header'>
<div class='heading'>
<strong><?php echo $lang->custom->setDynamic?></strong>
</div>
</div>
<table class='table table-hover table-striped table-bordered'>
<thead>
<tr class='text-center'>
<th class='w-150px'><?php echo $lang->group->module;?></th>
<th><?php echo $lang->action->action;?></th>
</tr>
</thead>
<?php foreach($objectTypes as $objectKey => $objectTypeName):?>
<tr>
<th class='text-middle w-150px'>
<div class="text-center check-all">
<?php echo $objectTypeName?>
</div>
</th>
<td class='pv-10px'>
<?php if(isset($dynamicAction->$objectKey)):?>
<div class='group-item'>
<?php echo html::checkbox("actions[{$objectKey}]", $dynamicAction->$objectKey, isset($setActions[$objectKey]) ? $setActions[$objectKey] : '', '');?>
</div>
<?php endif;?>
</td>
</tr>
<?php endforeach;?>
<tr>
<th></th>
<td class='form-actions'>
<?php echo html::submitButton();?>
</td>
</tr>
</table>
</form>
</div>
<script>
$(function()
{
$('#mainMenu #setDynamicTab').addClass('btn-active-text');
})
</script>
<?php include '../../common/view/footer.html.php';?>
+6 -1
View File
@@ -142,10 +142,15 @@ class group extends control
$this->view->title = $this->lang->company->common . $this->lang->colon . $group->name . $this->lang->colon . $this->lang->group->manageView;
$this->view->position[] = $group->name;
$this->view->position[] = $this->lang->group->manageView;
$this->view->group = $group;
$this->view->products = $this->dao->select('*')->from(TABLE_PRODUCT)->where('deleted')->eq('0')->orderBy('order_desc')->fetchPairs('id', 'name');
$this->view->projects = $this->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq('0')->orderBy('order_desc')->fetchPairs('id', 'name');
$menugroup = array();
foreach($this->lang->menugroup as $moduleName => $groupName) $menugroup[$groupName][$moduleName] = $moduleName;
$this->view->menugroup = $menugroup;
$this->display();
}
+4
View File
@@ -1 +1,5 @@
.group-item {display:block; width:90px; float:left; margin-top:5px;}
.action-item {display:block; width:150px; float:left; margin-top:5px;}
.pl-0px {padding-left:0px !important;}
.pt-0px {padding-top:0px !important;}
+10 -3
View File
@@ -12,11 +12,11 @@ function selectAll(obj)
{
if($(obj).prop('checked'))
{
$(obj).closest('td').find(':checkbox').attr('checked', 'checked');
$(obj).closest('tr').find(':checkbox').attr('checked', 'checked');
}
else
{
$(obj).closest('td').find(':checkbox').removeAttr('checked');
$(obj).closest('tr').find(':checkbox').removeAttr('checked');
}
}
@@ -38,6 +38,13 @@ $(function()
{
if(!$(this).prop('checked')) allChecked = false;
})
$('input:checkbox[name^="allchecker"]').prop('checked', allChecked);
$('.group-item input:checkbox[name^="allchecker"]').prop('checked', allChecked);
var id = $(this).attr('id');
if($('#' + id + 'ActionBox').length == 1)
{
$('#' + id + 'ActionBox').toggle($(this).prop("checked"));
$('#' + id + 'ActionBox').closest('tr').find('td :checkbox').prop('checked', $(this).prop("checked"));
}
})
})
+1
View File
@@ -27,6 +27,7 @@ $lang->group->errorNotSaved = '没有保存,请确认选择了权限数
$lang->group->viewList = '可访问视图';
$lang->group->productList = '可访问' . $lang->productCommon;
$lang->group->projectList = '可访问' . $lang->projectCommon;
$lang->group->dynamic = '可访问动态';
$lang->group->noticeVisit = '空代表访问没有访问限制';
$lang->group->id = '编号';
+2 -1
View File
@@ -266,7 +266,8 @@ class groupModel extends model
public function updateView($groupID)
{
$actions = $this->post->actions;
if(isset($_POST['allchecker']))$actions['views'] = array();
if(isset($_POST['allchecker']))$actions['views'] = array();
if(!isset($actions['actions']))$actions['actions'] = array();
$actions = empty($actions) ? '' : json_encode($actions);
$this->dao->update(TABLE_GROUP)->set('acl')->eq($actions)->where('id')->eq($groupID)->exec();
+51 -1
View File
@@ -21,7 +21,7 @@
<form class="load-indicator main-form form-ajax" id="manageViewForm" method="post" target='hiddenwin'>
<table class='table table-form'>
<tr>
<th class='w-100px'>
<th class='w-110px'>
<?php echo $lang->group->viewList;?>
</th>
<td>
@@ -67,6 +67,56 @@
</div>
</td>
</tr>
<tr>
<th class='text-right text-top'><?php echo $lang->group->dynamic?></th>
<td class='pl-0px pt-0px'>
<table class='table table-form'>
<?php foreach($lang->menu as $module => $title):?>
<?php if(!isset($lang->action->dynamicAction->$module) and !isset($menugroup[$module])) continue;?>
<tr id='<?php echo "{$module}ActionBox";?>'>
<th class='w-100px text-left'>
<div class='action-item'>
<div class='checkbox-primary'>
<input type="checkbox" id='allchecker' name="allchecker" onclick="selectAll(this)"/>
<label class='priv' for='allchecker'><?php echo substr($title, 0, strpos($title, '|'));?></label>
</div>
</div>
</th>
<td>
<?php if(isset($lang->action->dynamicAction->$module)):?>
<div class='clearfix'>
<?php foreach($lang->action->dynamicAction->$module as $action => $actionTitle):?>
<div class='action-item'>
<div class='checkbox-primary'>
<input type='checkbox' id='<?php echo "$module-$action";?>' name='actions[actions][<?php echo $module;?>][<?php echo $action;?>]' value='<?php echo $action;?>' <?php if(isset($group->acl['actions'][$module][$action]) or empty($group->acl['actions'])) echo "checked";?> />
<label class='priv' for='<?php echo "$module-$action";?>'><?php echo $actionTitle;?></label>
</div>
</div>
<?php endforeach;?>
</div>
<?php endif;?>
<?php if(isset($menugroup[$module])):?>
<?php foreach($menugroup[$module] as $subModule):?>
<?php if(isset($lang->action->dynamicAction->$subModule)):?>
<div class='clearfix'>
<?php foreach($lang->action->dynamicAction->$subModule as $action => $actionTitle):?>
<div class='action-item'>
<div class='checkbox-primary'>
<input type='checkbox' id='<?php echo "$subModule-$action";?>' name='actions[actions][<?php echo $subModule;?>][<?php echo $action;?>]' value='<?php echo $action;?>' <?php if(isset($group->acl['actions'][$subModule][$action]) or empty($group->acl['actions'])) echo "checked";?> />
<label class='priv' for='<?php echo "$subModule-$action";?>'><?php echo $actionTitle;?></label>
</div>
</div>
<?php endforeach;?>
</div>
<?php endif;?>
<?php endforeach;?>
<?php endif;?>
</td>
</tr>
<?php endforeach;?>
</table>
</td>
</tr>
<tr>
<td colspan='2' class='form-actions text-center'>
<?php echo html::submitButton('', "onclick='setNoChecked()'");?>
+341 -316
View File
@@ -1,324 +1,324 @@
<?php
/**
* The model file of task module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package task
* @version $Id: model.php 5154 2013-07-16 05:51:02Z chencongzhi520@gmail.com $
* @link http://www.zentao.net
*/
* The model file of task module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package task
* @version $Id: model.php 5154 2013-07-16 05:51:02Z chencongzhi520@gmail.com $
* @link http://www.zentao.net
*/
?>
<?php
class taskModel extends model
{
/**
* Create a task.
*
* @param int $projectID
* @access public
* @return void
*/
public function create($projectID)
/**
* Create a task.
*
* @param int $projectID
* @access public
* @return void
*/
public function create($projectID)
{
$taskIdList = array();
$taskFiles = array();
$this->loadModel('file');
$task = fixer::input('post')
->setDefault('project', (int)$projectID)
->setDefault('estimate, left, story', 0)
->setDefault('status', 'wait')
->setIF($this->post->estimate != false, 'left', $this->post->estimate)
->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story))
->setDefault('estStarted', '0000-00-00')
->setDefault('deadline', '0000-00-00')
->setIF(strpos($this->config->task->create->requiredFields, 'estStarted') !== false, 'estStarted', $this->post->estStarted)
->setIF(strpos($this->config->task->create->requiredFields, 'deadline') !== false, 'deadline', $this->post->deadline)
->setIF(is_numeric($this->post->estimate), 'estimate', (float)$this->post->estimate)
->setIF(is_numeric($this->post->consumed), 'consumed', (float)$this->post->consumed)
->setIF(is_numeric($this->post->left), 'left', (float)$this->post->left)
->setDefault('openedBy', $this->app->user->account)
->setDefault('openedDate', helper::now())
->stripTags($this->config->task->editor->create['id'], $this->config->allowedTags)
->join('mailto', ',')
->remove('after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate')
->get();
if($task->type != 'test') $this->post->set('selectTestStory', 0);
foreach($this->post->assignedTo as $assignedTo)
{
$taskIdList = array();
$taskFiles = array();
$this->loadModel('file');
$task = fixer::input('post')
->setDefault('project', (int)$projectID)
->setDefault('estimate, left, story', 0)
->setDefault('status', 'wait')
->setIF($this->post->estimate != false, 'left', $this->post->estimate)
->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion($this->post->story))
->setDefault('estStarted', '0000-00-00')
->setDefault('deadline', '0000-00-00')
->setIF(strpos($this->config->task->create->requiredFields, 'estStarted') !== false, 'estStarted', $this->post->estStarted)
->setIF(strpos($this->config->task->create->requiredFields, 'deadline') !== false, 'deadline', $this->post->deadline)
->setIF(is_numeric($this->post->estimate), 'estimate', (float)$this->post->estimate)
->setIF(is_numeric($this->post->consumed), 'consumed', (float)$this->post->consumed)
->setIF(is_numeric($this->post->left), 'left', (float)$this->post->left)
->setDefault('openedBy', $this->app->user->account)
->setDefault('openedDate', helper::now())
->stripTags($this->config->task->editor->create['id'], $this->config->allowedTags)
->join('mailto', ',')
->remove('after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate')
->get();
if($task->type != 'test') $this->post->set('selectTestStory', 0);
/* When type is affair and has assigned then ignore none. */
if($task->type == 'affair' and count($this->post->assignedTo) > 1 and empty($assignedTo)) continue;
foreach($this->post->assignedTo as $assignedTo)
$task->assignedTo = $assignedTo;
if($assignedTo) $task->assignedDate = helper::now();
/* Check duplicate task. */
if($task->type != 'affair')
{
/* When type is affair and has assigned then ignore none. */
if($task->type == 'affair' and count($this->post->assignedTo) > 1 and empty($assignedTo)) continue;
$task->assignedTo = $assignedTo;
if($assignedTo) $task->assignedDate = helper::now();
/* Check duplicate task. */
if($task->type != 'affair')
$result = $this->loadModel('common')->removeDuplicate('task', $task, "project=$projectID and story=$task->story");
if($result['stop'])
{
$result = $this->loadModel('common')->removeDuplicate('task', $task, "project=$projectID and story=$task->story");
if($result['stop'])
{
$taskIdList[$assignedTo] = array('status' => 'exists', 'id' => $result['duplicate']);
continue;
}
$taskIdList[$assignedTo] = array('status' => 'exists', 'id' => $result['duplicate']);
continue;
}
$task = $this->file->processImgURL($task, $this->config->task->editor->create['id'], $this->post->uid);
/* Fix Bug #1525 */
$projectType = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch('type');
$requiredFields = "," . $this->config->task->create->requiredFields . ",";
if($projectType == 'ops') $requiredFields = str_replace(",story,", ',', "$requiredFields");
if($this->post->selectTestStory)
{
$requiredFields = str_replace(",estimate,", ',', "$requiredFields");
$requiredFields = str_replace(",story,", ',', "$requiredFields");
$requiredFields = str_replace(",estStarted,", ',', "$requiredFields");
$requiredFields = str_replace(",deadline,", ',', "$requiredFields");
}
$requiredFields = trim($requiredFields, ',');
/* Fix Bug #2466 */
if($this->post->multiple) $task->assignedTo = '';
$this->dao->insert(TABLE_TASK)->data($task)
->autoCheck()
->batchCheck($requiredFields, 'notempty')
->checkIF($task->estimate != '', 'estimate', 'float')
->checkIF($task->deadline != '0000-00-00', 'deadline', 'ge', $task->estStarted)
->exec();
if(dao::isError()) return false;
$taskID = $this->dao->lastInsertID();
if($this->post->story) $this->loadModel('story')->setStage($this->post->story);
if($this->post->selectTestStory)
{
$testStoryIdList = array();
$this->loadModel('action');
foreach($this->post->testStory as $storyID)
{
if($storyID) $testStoryIdList[$storyID] = $storyID;
}
$testStories = $this->dao->select('id,title')->from(TABLE_STORY)->where('id')->in($testStoryIdList)->fetchPairs('id', 'title');
foreach($this->post->testStory as $i => $storyID)
{
if(!isset($testStories[$storyID])) continue;
$task->parent = $taskID;
$task->story = $storyID;
$task->name = $this->lang->task->lblTestStory . " #{$storyID} " . zget($testStories, $storyID);
$task->pri = $this->post->testPri[$i];
$task->estStarted = $this->post->testEstStarted[$i];
$task->deadline = $this->post->testDeadline[$i];
$task->assignedTo = $this->post->testAssignedTo[$i];
$task->estimate = $this->post->testEstimate[$i];
$this->dao->insert(TABLE_TASK)->data($task)->exec();
$childTaskID = $this->dao->lastInsertID();
$this->action->create('task', $childTaskID, 'Opened');
}
$this->computeWorkingHours($taskID);
$this->computeBeginAndEnd($taskID);
$this->dao->update(TABLE_TASK)->set('parent')->eq(-1)->where('id')->eq($taskID)->exec();
}
$this->file->updateObjectID($this->post->uid, $taskID, 'task');
if(!empty($taskFiles))
{
foreach($taskFiles as $taskFile)
{
$taskFile->objectID = $taskID;
$this->dao->insert(TABLE_FILE)->data($taskFile)->exec();
}
}
else
{
$taskFileTitle = $this->file->saveUpload('task', $taskID);
$taskFiles = $this->dao->select('*')->from(TABLE_FILE)->where('id')->in(array_keys($taskFileTitle))->fetchAll('id');
foreach($taskFiles as $fileID => $taskFile) unset($taskFiles[$fileID]->id);
}
$teams = array();
if($this->post->multiple)
{
foreach($this->post->team as $row => $account)
{
if(empty($account) or isset($team[$account])) continue;
$member = new stdClass();
$member->root = 0;
$member->account = $account;
$member->role = $assignedTo;
$member->join = helper::today();
$member->estimate = $this->post->teamEstimate[$row] ? (float)$this->post->teamEstimate[$row] : 0;
$member->left = $member->estimate;
$member->order = $row;
$teams[$account] = $member;
}
}
if(!empty($teams))
{
foreach($teams as $team)
{
$team->root = $taskID;
$team->type = 'task';
$this->dao->insert(TABLE_TEAM)->data($team)->autoCheck()->exec();
}
$task->id = $taskID;
$this->computeHours4Multiple($task);
}
if(!dao::isError()) $this->loadModel('score')->create('task', 'create', $taskID);
$taskIdList[$assignedTo] = array('status' => 'created', 'id' => $taskID);
}
return $taskIdList;
$task = $this->file->processImgURL($task, $this->config->task->editor->create['id'], $this->post->uid);
/* Fix Bug #1525 */
$projectType = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch('type');
$requiredFields = "," . $this->config->task->create->requiredFields . ",";
if($projectType == 'ops') $requiredFields = str_replace(",story,", ',', "$requiredFields");
if($this->post->selectTestStory)
{
$requiredFields = str_replace(",estimate,", ',', "$requiredFields");
$requiredFields = str_replace(",story,", ',', "$requiredFields");
$requiredFields = str_replace(",estStarted,", ',', "$requiredFields");
$requiredFields = str_replace(",deadline,", ',', "$requiredFields");
}
$requiredFields = trim($requiredFields, ',');
/* Fix Bug #2466 */
if($this->post->multiple) $task->assignedTo = '';
$this->dao->insert(TABLE_TASK)->data($task)
->autoCheck()
->batchCheck($requiredFields, 'notempty')
->checkIF($task->estimate != '', 'estimate', 'float')
->checkIF($task->deadline != '0000-00-00', 'deadline', 'ge', $task->estStarted)
->exec();
if(dao::isError()) return false;
$taskID = $this->dao->lastInsertID();
if($this->post->story) $this->loadModel('story')->setStage($this->post->story);
if($this->post->selectTestStory)
{
$testStoryIdList = array();
$this->loadModel('action');
foreach($this->post->testStory as $storyID)
{
if($storyID) $testStoryIdList[$storyID] = $storyID;
}
$testStories = $this->dao->select('id,title')->from(TABLE_STORY)->where('id')->in($testStoryIdList)->fetchPairs('id', 'title');
foreach($this->post->testStory as $i => $storyID)
{
if(!isset($testStories[$storyID])) continue;
$task->parent = $taskID;
$task->story = $storyID;
$task->name = $this->lang->task->lblTestStory . " #{$storyID} " . zget($testStories, $storyID);
$task->pri = $this->post->testPri[$i];
$task->estStarted = $this->post->testEstStarted[$i];
$task->deadline = $this->post->testDeadline[$i];
$task->assignedTo = $this->post->testAssignedTo[$i];
$task->estimate = $this->post->testEstimate[$i];
$this->dao->insert(TABLE_TASK)->data($task)->exec();
$childTaskID = $this->dao->lastInsertID();
$this->action->create('task', $childTaskID, 'Opened');
}
$this->computeWorkingHours($taskID);
$this->computeBeginAndEnd($taskID);
$this->dao->update(TABLE_TASK)->set('parent')->eq(-1)->where('id')->eq($taskID)->exec();
}
$this->file->updateObjectID($this->post->uid, $taskID, 'task');
if(!empty($taskFiles))
{
foreach($taskFiles as $taskFile)
{
$taskFile->objectID = $taskID;
$this->dao->insert(TABLE_FILE)->data($taskFile)->exec();
}
}
else
{
$taskFileTitle = $this->file->saveUpload('task', $taskID);
$taskFiles = $this->dao->select('*')->from(TABLE_FILE)->where('id')->in(array_keys($taskFileTitle))->fetchAll('id');
foreach($taskFiles as $fileID => $taskFile) unset($taskFiles[$fileID]->id);
}
$teams = array();
if($this->post->multiple)
{
foreach($this->post->team as $row => $account)
{
if(empty($account) or isset($team[$account])) continue;
$member = new stdClass();
$member->root = 0;
$member->account = $account;
$member->role = $assignedTo;
$member->join = helper::today();
$member->estimate = $this->post->teamEstimate[$row] ? (float)$this->post->teamEstimate[$row] : 0;
$member->left = $member->estimate;
$member->order = $row;
$teams[$account] = $member;
}
}
if(!empty($teams))
{
foreach($teams as $team)
{
$team->root = $taskID;
$team->type = 'task';
$this->dao->insert(TABLE_TEAM)->data($team)->autoCheck()->exec();
}
$task->id = $taskID;
$this->computeHours4Multiple($task);
}
if(!dao::isError()) $this->loadModel('score')->create('task', 'create', $taskID);
$taskIdList[$assignedTo] = array('status' => 'created', 'id' => $taskID);
}
return $taskIdList;
}
/**
* Create a batch task.
*
* @param int $projectID
* @access public
* @return void
*/
public function batchCreate($projectID)
{
$this->loadModel('action');
$now = helper::now();
$mails = array();
$tasks = fixer::input('post')->get();
$storyIDs = array();
$taskNames = array();
$preStory = 0;
/* Judge whether the current task is a parent. */
$parentID = !empty($this->post->parent[0]) ? $this->post->parent[0] : 0;
foreach($tasks->story as $key => $storyID)
{
if(empty($tasks->name[$key])) continue;
if($tasks->type[$key] == 'affair') continue;
if($tasks->type[$key] == 'ditto' && isset($tasks->type[$key - 1]) && $tasks->type[$key - 1] == 'affair') continue;
if($storyID == 'ditto') $storyID = $preStory;
$preStory = $storyID;
$inNames = in_array($tasks->name[$key], $taskNames);
if(!$inNames || ($inNames && !in_array($storyID, $storyIDs)))
{
$storyIDs[] = $storyID;
$taskNames[] = $tasks->name[$key];
}
else
{
dao::$errors['message'][] = sprintf($this->lang->duplicate, $this->lang->task->common) . ' ' . $tasks->name[$key];
return false;
}
}
/**
* Create a batch task.
*
* @param int $projectID
* @access public
* @return void
*/
public function batchCreate($projectID)
$result = $this->loadModel('common')->removeDuplicate('task', $tasks, "project=$projectID and story " . helper::dbIN($storyIDs));
$tasks = $result['data'];
$story = 0;
$module = 0;
$type = '';
$assignedTo = '';
/* Get task data. */
$data = array();
foreach($tasks->name as $i => $name)
{
$this->loadModel('action');
$now = helper::now();
$mails = array();
$tasks = fixer::input('post')->get();
$story = !isset($tasks->story[$i]) || $tasks->story[$i] == 'ditto' ? $story : $tasks->story[$i];
$module = !isset($tasks->module[$i]) || $tasks->module[$i] == 'ditto' ? $module : $tasks->module[$i];
$type = !isset($tasks->type[$i]) || $tasks->type[$i] == 'ditto' ? $type : $tasks->type[$i];
$assignedTo = !isset($tasks->assignedTo[$i]) || $tasks->assignedTo[$i] == 'ditto' ? $assignedTo: $tasks->assignedTo[$i];
$storyIDs = array();
$taskNames = array();
$preStory = 0;
if(empty($tasks->name[$i])) continue;
/* Judge whether the current task is a parent. */
$parentID = !empty($this->post->parent[0]) ? $this->post->parent[0] : 0;
$data[$i] = new stdclass();
$data[$i]->story = (int)$story;
$data[$i]->type = $type;
$data[$i]->module = (int)$module;
$data[$i]->assignedTo = $assignedTo;
$data[$i]->color = $tasks->color[$i];
$data[$i]->name = $tasks->name[$i];
$data[$i]->desc = nl2br($tasks->desc[$i]);
$data[$i]->pri = $tasks->pri[$i];
$data[$i]->estimate = $tasks->estimate[$i];
$data[$i]->left = $tasks->estimate[$i];
$data[$i]->project = $projectID;
$data[$i]->estStarted = empty($tasks->estStarted[$i]) ? '0000-00-00' : $tasks->estStarted[$i];
$data[$i]->deadline = empty($tasks->deadline[$i]) ? '0000-00-00' : $tasks->deadline[$i];
$data[$i]->status = 'wait';
$data[$i]->openedBy = $this->app->user->account;
$data[$i]->openedDate = $now;
$data[$i]->parent = $tasks->parent[$i];
if($story) $data[$i]->storyVersion = $this->loadModel('story')->getVersion($data[$i]->story);
if($assignedTo) $data[$i]->assignedDate = $now;
if(strpos($this->config->task->create->requiredFields, 'estStarted') !== false and empty($tasks->estStarted[$i])) $data[$i]->estStarted = '';
if(strpos($this->config->task->create->requiredFields, 'deadline') !== false and empty($tasks->deadline[$i])) $data[$i]->deadline = '';
}
foreach($tasks->story as $key => $storyID)
/* Fix bug #1525*/
$projectType =$this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch('type');
$requiredFields = explode(',', $this->config->task->create->requiredFields);
if($projectType == 'ops') unset($requiredFields[array_search('story', $requiredFields)]);
$requiredFields = implode(',', $requiredFields);
/* check data. */
foreach($data as $i => $task)
{
if($task->estimate and !preg_match("/^[0-9]+(.[0-9]{1,3})?$/", $task->estimate))
{
if(empty($tasks->name[$key])) continue;
if($tasks->type[$key] == 'affair') continue;
if($tasks->type[$key] == 'ditto' && isset($tasks->type[$key - 1]) && $tasks->type[$key - 1] == 'affair') continue;
if($storyID == 'ditto') $storyID = $preStory;
$preStory = $storyID;
$inNames = in_array($tasks->name[$key], $taskNames);
if(!$inNames || ($inNames && !in_array($storyID, $storyIDs)))
dao::$errors['message'][] = $this->lang->task->error->estimateNumber;
return false;
}
foreach(explode(',', $requiredFields) as $field)
{
$field = trim($field);
if($field and empty($task->$field))
{
$storyIDs[] = $storyID;
$taskNames[] = $tasks->name[$key];
}
else
{
dao::$errors['message'][] = sprintf($this->lang->duplicate, $this->lang->task->common) . ' ' . $tasks->name[$key];
dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->task->$field);
return false;
}
}
if($task->estimate) $task->estimate = (float)$task->estimate;
}
$result = $this->loadModel('common')->removeDuplicate('task', $tasks, "project=$projectID and story " . helper::dbIN($storyIDs));
$tasks = $result['data'];
$childTasks = null;
foreach($data as $i => $task)
{
$this->dao->insert(TABLE_TASK)->data($task)
->autoCheck()
->batchCheck($requiredFields, 'notempty')
->checkIF($task->estimate != '', 'estimate', 'float')
->exec();
$story = 0;
$module = 0;
$type = '';
$assignedTo = '';
if(dao::isError()) die(js::error(dao::getError()));
/* Get task data. */
$data = array();
foreach($tasks->name as $i => $name)
{
$story = !isset($tasks->story[$i]) || $tasks->story[$i] == 'ditto' ? $story : $tasks->story[$i];
$module = !isset($tasks->module[$i]) || $tasks->module[$i] == 'ditto' ? $module : $tasks->module[$i];
$type = !isset($tasks->type[$i]) || $tasks->type[$i] == 'ditto' ? $type : $tasks->type[$i];
$assignedTo = !isset($tasks->assignedTo[$i]) || $tasks->assignedTo[$i] == 'ditto' ? $assignedTo: $tasks->assignedTo[$i];
$taskID = $this->dao->lastInsertID();
$childTasks .= $taskID . ',';
if($story) $this->story->setStage($task->story);
$actionID = $this->action->create('task', $taskID, 'Opened', '');
if(!dao::isError()) $this->loadModel('score')->create('task', 'create', $taskID);
if(empty($tasks->name[$i])) continue;
$mails[$i] = new stdclass();
$mails[$i]->taskID = $taskID;
$mails[$i]->actionID = $actionID;
}
$data[$i] = new stdclass();
$data[$i]->story = (int)$story;
$data[$i]->type = $type;
$data[$i]->module = (int)$module;
$data[$i]->assignedTo = $assignedTo;
$data[$i]->color = $tasks->color[$i];
$data[$i]->name = $tasks->name[$i];
$data[$i]->desc = nl2br($tasks->desc[$i]);
$data[$i]->pri = $tasks->pri[$i];
$data[$i]->estimate = $tasks->estimate[$i];
$data[$i]->left = $tasks->estimate[$i];
$data[$i]->project = $projectID;
$data[$i]->estStarted = empty($tasks->estStarted[$i]) ? '0000-00-00' : $tasks->estStarted[$i];
$data[$i]->deadline = empty($tasks->deadline[$i]) ? '0000-00-00' : $tasks->deadline[$i];
$data[$i]->status = 'wait';
$data[$i]->openedBy = $this->app->user->account;
$data[$i]->openedDate = $now;
$data[$i]->parent = $tasks->parent[$i];
if($story) $data[$i]->storyVersion = $this->loadModel('story')->getVersion($data[$i]->story);
if($assignedTo) $data[$i]->assignedDate = $now;
if(strpos($this->config->task->create->requiredFields, 'estStarted') !== false and empty($tasks->estStarted[$i])) $data[$i]->estStarted = '';
if(strpos($this->config->task->create->requiredFields, 'deadline') !== false and empty($tasks->deadline[$i])) $data[$i]->deadline = '';
}
/* Fix bug #1525*/
$projectType =$this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch('type');
$requiredFields = explode(',', $this->config->task->create->requiredFields);
if($projectType == 'ops') unset($requiredFields[array_search('story', $requiredFields)]);
$requiredFields = implode(',', $requiredFields);
/* check data. */
foreach($data as $i => $task)
{
if($task->estimate and !preg_match("/^[0-9]+(.[0-9]{1,3})?$/", $task->estimate))
{
dao::$errors['message'][] = $this->lang->task->error->estimateNumber;
return false;
}
foreach(explode(',', $requiredFields) as $field)
{
$field = trim($field);
if($field and empty($task->$field))
{
dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->task->$field);
return false;
}
}
if($task->estimate) $task->estimate = (float)$task->estimate;
}
$childTasks = null;
foreach($data as $i => $task)
{
$this->dao->insert(TABLE_TASK)->data($task)
->autoCheck()
->batchCheck($requiredFields, 'notempty')
->checkIF($task->estimate != '', 'estimate', 'float')
->exec();
if(dao::isError()) die(js::error(dao::getError()));
$taskID = $this->dao->lastInsertID();
$childTasks .= html::a(helper::createLink('task', 'view', 'taskID=' . $taskID), $task->name, '', "title='$task->name' class='text-ellipsis w-p10'") . ',';
if($story) $this->story->setStage($task->story);
$actionID = $this->action->create('task', $taskID, 'Opened', '');
if(!dao::isError()) $this->loadModel('score')->create('task', 'create', $taskID);
$mails[$i] = new stdclass();
$mails[$i]->taskID = $taskID;
$mails[$i]->actionID = $actionID;
}
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchCreate');
if($parentID && !empty($taskID))
{
$this->updateParentStatus($taskID);
$this->computeBeginAndEnd($parentID);
$this->dao->update(TABLE_TASK)->set('parent')->eq(-1)->where('id')->eq($parentID)->exec();
$this->action->create('task', $parentID, 'batchCreate', '', $taskID);
if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchCreate');
if($parentID && !empty($taskID))
{
$this->updateParentStatus($taskID);
$this->computeBeginAndEnd($parentID);
$this->dao->update(TABLE_TASK)->set('parent')->eq(-1)->where('id')->eq($parentID)->exec();
$this->action->create('task', $parentID, 'createChildren', '', trim($childTasks, ','));
}
return $mails;
}
@@ -396,10 +396,10 @@ class taskModel extends model
* @access public
* @return bool
*/
public function updateParentStatus($taskID)
public function updateParentStatus($taskID, $parentID = 0, $createAction = true)
{
$childTask = $this->dao->select('*')->from(TABLE_TASK)->where('id')->eq($taskID)->fetch();
$parentID = $childTask->parent;
if(empty($parentID)) $parentID = $childTask->parent;
if(empty($parentID)) return true;
$this->computeWorkingHours($parentID);
@@ -471,7 +471,7 @@ class taskModel extends model
$task->closedReason = 'done';
}
if($status == 'doing')
if($status == 'doing' or $status == 'wait')
{
if($parentTask->assignedTo == 'closed')
{
@@ -491,16 +491,22 @@ class taskModel extends model
$this->dao->update(TABLE_TASK)->data($task)->where('id')->eq($parentID)->exec();
if(!dao::isError())
{
if(!$createAction) return $task;
$changes = common::createChanges($parentTask, $task);
$action = 'Canceled';
$action = '';
if($status == 'done') $action = 'Finished';
if($status == 'closed') $action = 'Closed';
if($status == 'pause') $action = 'Paused';
if($status == 'cancel') $action = 'Canceled';
if($status == 'doing' and $parentTask->status == 'wait') $action = 'Started';
if($status == 'doing' and $parentTask->status == 'pause') $action = 'Restarted';
if($status == 'doing' and $parentTask->status != 'wait' and $parentTask->status != 'pause') $action = 'Activated';
$actionID = $this->loadModel('action')->create('task', $parentID, $action);
$this->action->logHistory($actionID, $changes);
if($action)
{
$actionID = $this->loadModel('action')->create('task', $parentID, $action);
$this->action->logHistory($actionID, $changes);
}
}
}
}
@@ -677,13 +683,6 @@ class taskModel extends model
$this->dao->update(TABLE_TASK)->set('project')->eq($task->project)->set('module')->eq($task->module)->where('parent')->eq($taskID)->exec();
}
if(isset($task->parent) and $task->parent != $oldTask->parent)
{
$this->loadModel('action')->create('task', $task->parent, 'linkChildTask', '', $taskID);
$this->loadModel('action')->create('task', $oldTask->parent, 'unLinkChildrenTask', '', $taskID);
$this->loadModel('action')->create('task', $taskID, 'linkParentTask', '', $task->parent);
}
$task = $this->loadModel('file')->processImgURL($task, $this->config->task->editor->edit['id'], $this->post->uid);
$teams = array();
@@ -747,25 +746,51 @@ class taskModel extends model
->batchCheckIF($task->closedReason == 'cancel', 'finishedBy, finishedDate', 'empty')
->where('id')->eq((int)$taskID)->exec();
if($oldTask->parent > 0)
{
if($task->parent == 0) $this->computeWorkingHours($oldTask->parent);
$this->updateParentStatus($taskID);
$this->computeBeginAndEnd($oldTask->parent);
}
if($this->post->story != false) $this->loadModel('story')->setStage($this->post->story);
if(!dao::isError())
{
if($this->post->story != false) $this->loadModel('story')->setStage($this->post->story);
if($task->status == 'done') $this->loadModel('score')->create('task', 'finish', $taskID);
if($task->status == 'closed') $this->loadModel('score')->create('task', 'close', $taskID);
if(!empty($task->parent))
$this->loadModel('action');
$changed = $task->parent != $oldTask->parent;
if($oldTask->parent > 0)
{
$oldParentTask = $this->dao->select('*')->from(TABLE_TASK)->where('id')->eq($oldTask->parent)->fetch();
if($task->parent == 0) $this->computeWorkingHours($oldTask->parent);
$this->updateParentStatus($taskID, $oldTask->parent, !$changed);
$this->computeBeginAndEnd($oldTask->parent);
if($changed)
{
$this->action->create('task', $taskID, 'unlinkParentTask', '', $oldTask->parent);
$actionID = $this->action->create('task', $oldTask->parent, 'unLinkChildrenTask', '', $taskID);
$newParentTask = $this->dao->select('*')->from(TABLE_TASK)->where('id')->eq($oldTask->parent)->fetch();
$changes = common::createChanges($oldParentTask, $newParentTask);
if(!empty($changes)) $this->action->logHistory($actionID, $changes);
}
}
if($task->parent > 0)
{
$parentTask = $this->dao->select('*')->from(TABLE_TASK)->where('id')->eq($task->parent)->fetch();
$this->dao->update(TABLE_TASK)->set('parent')->eq(-1)->where('id')->eq($task->parent)->exec();
$this->updateParentStatus($taskID);
$this->updateParentStatus($taskID, $task->parent, !$changed);
$this->computeBeginAndEnd($task->parent);
if($changed)
{
$this->action->create('task', $taskID, 'linkParentTask', '', $task->parent);
$actionID = $this->action->create('task', $task->parent, 'linkChildTask', '', $taskID);
$newParentTask = $this->dao->select('*')->from(TABLE_TASK)->where('id')->eq($task->parent)->fetch();
$changes = common::createChanges($parentTask, $newParentTask);
if(!empty($changes)) $this->action->logHistory($actionID, $changes);
}
}
$this->file->updateObjectID($this->post->uid, $taskID, 'task');
unset($oldTask->parent);
unset($task->parent);
return common::createChanges($oldTask, $task);
}
}
+5
View File
@@ -766,6 +766,7 @@ class userModel extends model
$viewAllow = false;
$productAllow = false;
$projectAllow = false;
$actionAllow = false;
foreach($groups as $group)
{
$acl = json_decode($group->acl, true);
@@ -774,12 +775,14 @@ class userModel extends model
$productAllow = true;
$projectAllow = true;
$viewAllow = true;
$actionAllow = true;
break;
}
if(empty($acl['products'])) $productAllow = true;
if(empty($acl['projects'])) $projectAllow = true;
if(empty($acl['views'])) $viewAllow = true;
if(!isset($acl['actions'])) $actionAllow = true;
if(empty($acls) and !empty($acl))
{
$acls = $acl;
@@ -789,11 +792,13 @@ class userModel extends model
if(!empty($acl['views'])) $acls['views'] = array_merge($acls['views'], $acl['views']);
if(!empty($acl['products'])) $acls['products'] = !empty($acls['products']) ? array_merge($acls['products'], $acl['products']) : $acl['products'];
if(!empty($acl['projects'])) $acls['projects'] = !empty($acls['projects']) ? array_merge($acls['projects'], $acl['projects']) : $acl['projects'];
if(!empty($acl['actions'])) $acls['actions'] = !empty($acls['actions']) ? ($acl['actions'] + $acls['actions']) : $acl['actions'];
}
if($productAllow) $acls['products'] = array();
if($projectAllow) $acls['projects'] = array();
if($viewAllow) $acls['views'] = array();
if($actionAllow) unset($acls['actions']);
$sql = $this->dao->select('module, method')->from(TABLE_USERGROUP)->alias('t1')->leftJoin(TABLE_GROUPPRIV)->alias('t2')
->on('t1.group = t2.group')