* Fix bugs of product api.
This commit is contained in:
@@ -18,9 +18,10 @@ class productsEntry extends entry
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get()
|
||||
public function get($programID = 0)
|
||||
{
|
||||
$programID = $this->param('program', 0);
|
||||
if(!$programID) $programID = $this->param('program', 0);
|
||||
|
||||
if($programID)
|
||||
{
|
||||
$control = $this->loadController('program', 'product');
|
||||
@@ -67,16 +68,16 @@ class productsEntry extends entry
|
||||
*/
|
||||
public function post()
|
||||
{
|
||||
$fields = 'program,line,name,PO,QD,RD,type,desc,whitelist';
|
||||
$fields = 'program,code,line,name,PO,QD,RD,type,desc,whitelist';
|
||||
$this->batchSetPost($fields);
|
||||
|
||||
$this->setPost('acl', $this->request('acl', 'private'));
|
||||
$this->setPost('whitelist', $this->request('whitelist', array()));
|
||||
|
||||
$control = $this->loadController('product', 'create');
|
||||
$this->requireFields('name,program');
|
||||
$this->requireFields('name,code');
|
||||
|
||||
$control->create($this->request('program'));
|
||||
$control->create($this->request('program', 0));
|
||||
|
||||
$data = $this->getData();
|
||||
if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
@@ -29,7 +29,7 @@ class ProgramsEntry extends Entry
|
||||
$result = array();
|
||||
foreach($programs as $program)
|
||||
{
|
||||
$result[] = $this->format($program, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time');
|
||||
$result[] = $this->format($program, 'begin:date,end:date,realBegan:date,realEnd:date,openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time,deleted:bool');
|
||||
}
|
||||
return $this->send(200, array('programs' => $result));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class userEntry extends Entry
|
||||
$user = $data->data->user;
|
||||
unset($user->password);
|
||||
|
||||
$this->send(200, $this->format($user, 'last:time,locked:time'));
|
||||
$this->send(200, $user);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,8 +46,10 @@ class userEntry extends Entry
|
||||
{
|
||||
$info = new stdclass();
|
||||
|
||||
$info->profile = $this->loadModel('user')->getById($this->app->user->account);
|
||||
unset($info->profile->password);
|
||||
$profile = $this->loadModel('user')->getById($this->app->user->account);
|
||||
unset($profile->password);
|
||||
|
||||
$info->profile = $this->format($profile, 'last:time,locked:time,birthday:date,join:date');
|
||||
|
||||
if(!$fields) return $this->send(200, $info);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user