* code for task #44308.
This commit is contained in:
@@ -26,9 +26,18 @@ class projectsEntry extends entry
|
||||
|
||||
$_COOKIE['involved'] = $this->param('involved', 0);
|
||||
|
||||
$control = $this->loadController('project', 'browse');
|
||||
$control->browse($programID, $this->param('status', 'all'), 0, $this->param('order', 'order_asc'), 0, $this->param('limit', 20), $this->param('page', 1));
|
||||
$data = $this->getData();
|
||||
if($programID)
|
||||
{
|
||||
$control = $this->loadController('program', 'project');
|
||||
$control->project($programID, $this->param('status', 'all'), $this->param('order', 'order_asc'), 0, $this->param('limit', 20), $this->param('page', 1));
|
||||
$data = $this->getData();
|
||||
}
|
||||
else
|
||||
{
|
||||
$control = $this->loadController('project', 'browse');
|
||||
$control->browse($programID, $this->param('status', 'all'), 0, $this->param('order', 'order_asc'), 0, $this->param('limit', 20), $this->param('page', 1));
|
||||
$data = $this->getData();
|
||||
}
|
||||
|
||||
if(isset($data->status) and $data->status == 'success')
|
||||
{
|
||||
|
||||
134
api/v1/entries/stakeholders.php
Normal file
134
api/v1/entries/stakeholders.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* The stakeholder entry point of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2021 青岛易软天创网络科技有限公司(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 entries
|
||||
* @version 1
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
class stakeholdersEntry extends entry
|
||||
{
|
||||
/**
|
||||
* GET method.
|
||||
*
|
||||
* @param int $programID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get($programID = 0)
|
||||
{
|
||||
if(!$programID) $programID = $this->param('program', 0);
|
||||
|
||||
if($programID)
|
||||
{
|
||||
$control = $this->loadController('program', 'stakeholder');
|
||||
$control->stakeholder($programID, $this->param('order', 't1.id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
|
||||
$data = $this->getData();
|
||||
}
|
||||
|
||||
if(isset($data->status) and $data->status == 'success')
|
||||
{
|
||||
$this->app->loadLang('stakeholder');
|
||||
$pager = $data->data->pager;
|
||||
$users = $data->data->users;
|
||||
$result = array();
|
||||
foreach($data->data->stakeholders as $stakeholder)
|
||||
{
|
||||
$stakeholder->roleName = zget($this->lang->user->roleList, $stakeholder->role, '');
|
||||
$stakeholder->typeName = zget($this->lang->stakeholder->fromList, $stakeholder->from, '');
|
||||
|
||||
$result[] = $stakeholder;
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data['page'] = $pager->pageID;
|
||||
$data['total'] = $pager->recTotal;
|
||||
$data['limit'] = (int)$pager->recPerPage;
|
||||
$data['stakeholders'] = $result;
|
||||
|
||||
$withUser = $this->param('withUser', '');
|
||||
if(!empty($withUser)) $data['users'] = $users;
|
||||
|
||||
return $this->send(200, $data);
|
||||
}
|
||||
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
// TODO There is no handle for 401.
|
||||
return $this->sendError(400, 'error');
|
||||
}
|
||||
|
||||
/**
|
||||
* POST method.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function post()
|
||||
{
|
||||
$fields = 'name,begin,end,products';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$this->setPost('code', $this->request('code', ''));
|
||||
$this->setPost('acl', $this->request('acl', 'private'));
|
||||
$this->setPost('parent', $this->request('program', 0));
|
||||
$this->setPost('whitelist', $this->request('whitelist', array()));
|
||||
$this->setPost('PM', $this->request('PM', ''));
|
||||
$this->setPost('model', $this->request('model', 'scrum'));
|
||||
|
||||
$control = $this->loadController('project', 'create');
|
||||
$this->requireFields('name,code,begin,end,products');
|
||||
|
||||
$control->create($this->request('model', 'scrum'));
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
if(!isset($data->result)) return $this->sendError(400, 'error');
|
||||
|
||||
$project = $this->loadModel('project')->getByID($data->id);
|
||||
|
||||
$this->send(201, $this->format($project, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get drop menu.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function getDropMenu()
|
||||
{
|
||||
$control = $this->loadController('project', 'ajaxGetDropMenu');
|
||||
$control->ajaxGetDropMenu($this->request('projectID', 0), $this->request('module', 'project'), $this->request('method', 'browse'));
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
$dropMenu = array('owner' => array(), 'other' => array(), 'closed' => array());
|
||||
foreach($data->data->projects as $programID => $projects)
|
||||
{
|
||||
foreach($projects as $project)
|
||||
{
|
||||
if(helper::diffDate(date('Y-m-d'), $project->end) > 0) $project->delay = true;
|
||||
$project = $this->filterFields($project, 'id,model,type,name,code,parent,status,PM,delay');
|
||||
|
||||
if($project->status == 'closed')
|
||||
{
|
||||
$dropMenu['closed'][] = $project;
|
||||
}
|
||||
elseif($project->PM == $this->app->user->account)
|
||||
{
|
||||
$dropMenu['owner'][] = $project;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dropMenu['other'][] = $project;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->send(200, $dropMenu);
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,8 @@ $routes['/user'] = 'user';
|
||||
$routes['/programs'] = 'programs';
|
||||
$routes['/programs/:id'] = 'program';
|
||||
|
||||
$routes['/programs/:id/stakeholders'] = 'stakeholders';
|
||||
|
||||
$routes['/products/:productID/issues'] = 'productIssues';
|
||||
$routes['/projects/:projectID/issues'] = 'issues';
|
||||
$routes['/issues'] = 'issues';
|
||||
|
||||
@@ -488,7 +488,7 @@ class programModel extends model
|
||||
*/
|
||||
public function getStakeholders($programID = 0, $orderBy, $pager = null)
|
||||
{
|
||||
return $this->dao->select('t2.account,t2.realname,t2.role,t2.qq,t2.mobile,t2.phone,t2.weixin,t2.email,t1.id,t1.type,t1.key')->from(TABLE_STAKEHOLDER)->alias('t1')
|
||||
return $this->dao->select('t2.account,t2.realname,t2.role,t2.qq,t2.mobile,t2.phone,t2.weixin,t2.email,t1.id,t1.type,t1.from,t1.key')->from(TABLE_STAKEHOLDER)->alias('t1')
|
||||
->leftJoin(TABLE_USER)->alias('t2')->on('t1.user=t2.account')
|
||||
->where('t1.objectID')->eq($programID)
|
||||
->andWhere('t1.objectType')->eq('program')
|
||||
|
||||
Reference in New Issue
Block a user