issue.path.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. Bugs::actions(
  3. 'issue.create',
  4. 'issue.update',
  5. 'issue.delete'
  6. );
  7. Router::paths(array(
  8. '/!{issue}'=>function($res,$args){
  9. Bugs::authorized('issue.read');
  10. $res->write(
  11. Bugs::template('issue')
  12. ->run(Bugs::issue($args->issue))
  13. );
  14. },
  15. '/issue/{issue}'=>function($res,$args){
  16. Router::redirect(Router::url(Router::$base.'/!'.$args->issue));
  17. },
  18. '/issue/{issue}/update'=>function($res,$args){
  19. error_handle_type('json');
  20. Bugs::authorized('issue.update');
  21. if(!empty($_POST['name'])&&!empty($_POST['description'])&&!empty($_POST['status'])&&!empty($_POST['priority'])){
  22. $issue = Bugs::issue($args->issue);
  23. $issue->name = $_POST['name'];
  24. $issue->description = $_POST['description'];
  25. $issue->s_id = $_POST['status'];
  26. $issue->pr_id = $_POST['priority'];
  27. $res->json(array(
  28. 'id'=>$issue->id
  29. ));
  30. Bugs::activity('issue.update',$issue);
  31. }else{
  32. $res->json(array(
  33. 'error'=>'You must specify a name and description.'
  34. ));
  35. }
  36. },
  37. '/create/issue'=>function($res,$args){
  38. Bugs::authorized('issue.create');
  39. $res->write(Bugs::template('issue'));
  40. },
  41. '/create/issue/complete'=>function($res,$args){
  42. error_handle_type('json');
  43. Bugs::authorized('issue.create');
  44. if(!empty($_POST['name'])&&!empty($_POST['description'])){
  45. $issue = Bugs::issue($_POST['name'],$_POST['description']);
  46. $res->json(array(
  47. 'id'=>$issue->id
  48. ));
  49. Bugs::activity('issue.create',$issue);
  50. }else{
  51. $res->json(array(
  52. 'error'=>'You must specify a name and description.'
  53. ));
  54. }
  55. }
  56. ));
  57. ?>