Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. {
  2. "flow":[
  3. {
  4. "tasks":[
  5. { "id":"1", "uid":"bryan" },
  6. { "id":"2", "uid":"eric" }
  7. ]
  8. },
  9. {
  10. "tasks":[
  11. { "id":"1", "uid":"bryan" },
  12. { "id":"2", "uid":"eric" }
  13. ]
  14. },
  15. {
  16. "tasks":[
  17. { "id":"1", "uid":"bryan" },
  18. { "id":"2", "uid":"eric" }
  19. ]
  20. },
  21. {
  22. "tasks":[
  23. { "id":"1", "uid":"bryan" },
  24. { "id":"2", "uid":"eric" },
  25. { "id":"3", "uid":"eric" },
  26. { "id":"4", "uid":"bryan" }
  27. ]
  28. }
  29. ]
  30. }
  31.  
  32. {
  33. "flow":[
  34. {
  35. "tasks":[
  36. { "id":"2", "uid":"eric" },
  37. { "id":"1", "uid":"bryan" }
  38. ]
  39. },
  40. {
  41. "tasks":[
  42. { "id":"2", "uid":"eric" },
  43. { "id":"1", "uid":"bryan" }
  44. ]
  45. },
  46. {
  47. "tasks":[
  48. { "id":"2", "uid":"eric" },
  49. { "id":"1", "uid":"bryan" }
  50. ]
  51. },
  52. {
  53. "tasks":[
  54. { "id":"2", "uid":"eric" },
  55. { "id":"3", "uid":"eric" },
  56. { "id":"1", "uid":"bryan" },
  57. { "id":"4", "uid":"bryan" }
  58. ]
  59. }
  60. ]
  61. }
  62.  
  63. function reorder_flow($flow, $uid)
  64. {
  65. foreach($flow as &$step)
  66. {
  67. //step is the array with tasks
  68. $tasks = $step['tasks'];
  69. $new_tasks = array();
  70.  
  71. foreach($tasks as $key => $t)
  72. {
  73. if($t['uid'] == $uid)
  74. {
  75. $new_tasks = $new_tasks + $t;
  76. unset($tasks[$key]);
  77. }
  78. }
  79. $step['tasks'] = $new_tasks + $step['tasks'];
  80. }
  81. return $flow;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement