* code for task #44314.
This commit is contained in:
@@ -15,26 +15,16 @@ class releasesEntry extends entry
|
||||
* GET method.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get($productID = 0, $projectID = 0)
|
||||
public function get($productID = 0)
|
||||
{
|
||||
if(!$productID) $productID = $this->param('product');
|
||||
if(!$projectID) $projectID = $this->param('project');
|
||||
if(!$productID and !$projectID) return $this->sendError(400, 'Need product or project id.');
|
||||
if(empty($productID)) $productID = $this->param('product');
|
||||
if(empty($productID)) return $this->sendError(400, 'Need product id.');
|
||||
|
||||
if($projectID)
|
||||
{
|
||||
$control = $this->loadController('projectrelease', 'browse');
|
||||
$control->browse($projectID, 0, $this->param('status', 'all'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$control = $this->loadController('release', 'browse');
|
||||
$control->browse($productID, $this->param('branch', 0), $this->param('status', 'all'));
|
||||
}
|
||||
$control = $this->loadController('release', 'browse');
|
||||
$control->browse($productID, $this->param('branch', 0), $this->param('status', 'all'), $this->param('order', 't1.date_desc'));
|
||||
|
||||
/* Response */
|
||||
$data = $this->getData();
|
||||
@@ -44,7 +34,7 @@ class releasesEntry extends entry
|
||||
$releases = $data->data->releases;
|
||||
foreach($releases as $release) $result[] = $this->format($release, 'deleted:bool,date:date');
|
||||
|
||||
return $this->send(200, array('releases' => $result));
|
||||
return $this->send(200, array('total' => count($result), 'releases' => $result));
|
||||
}
|
||||
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
+2
-2
@@ -28,8 +28,8 @@ $routes['/products/:id/plans'] = 'productPlans';
|
||||
$routes['/productplans/:id'] = 'productPlan';
|
||||
|
||||
$routes['/releases'] = 'releases';
|
||||
$routes['/product/:id/releases'] = 'releases';
|
||||
$routes['/projects/:id/releases'] = 'projectreleases';
|
||||
$routes['/products/:id/releases'] = 'releases';
|
||||
$routes['/projects/:id/releases'] = 'projectReleases';
|
||||
$routes['/releases/:id'] = 'release';
|
||||
|
||||
$routes['/stories'] = 'stories';
|
||||
|
||||
@@ -37,17 +37,18 @@ class release extends control
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param string $type
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function browse($productID, $branch = 0, $type = 'all')
|
||||
public function browse($productID, $branch = 0, $type = 'all', $orderBy = 't1.date_desc')
|
||||
{
|
||||
$this->commonAction($productID, $branch);
|
||||
$this->session->set('releaseList', $this->app->getURI(true), 'product');
|
||||
|
||||
$this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->release->browse;
|
||||
$this->view->position[] = $this->lang->release->browse;
|
||||
$this->view->releases = $this->release->getList($productID, $branch, $type);
|
||||
$this->view->releases = $this->release->getList($productID, $branch, $type, $orderBy);
|
||||
$this->view->type = $type;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -46,10 +46,11 @@ class releaseModel extends model
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param string $type
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getList($productID, $branch = 0, $type = 'all')
|
||||
public function getList($productID, $branch = 0, $type = 'all', $orderBy = 't1.date_desc')
|
||||
{
|
||||
return $this->dao->select('t1.*, t2.name as productName, t3.id as buildID, t3.name as buildName, t3.project, t4.name as projectName')
|
||||
->from(TABLE_RELEASE)->alias('t1')
|
||||
@@ -60,7 +61,7 @@ class releaseModel extends model
|
||||
->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi()
|
||||
->beginIF($type != 'all')->andWhere('t1.status')->eq($type)->fi()
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->orderBy('t1.date DESC')
|
||||
->orderBy($orderBy)
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user