PageRenderTime 28ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/addTask.php

https://github.com/lovax/Producteev-Web-Form
PHP | 170 lines | 47 code | 74 blank | 49 comment | 2 complexity | 38c41d21ef0669e1b60de8b28d2245d1 MD5 | raw file
  1. <?php
  2. session_start();
  3. include_once("header.php");
  4. //print_r($_SESSION);
  5. include_once("include.php");
  6. if(!$_SESSION['producteev_access_token']){ /// Start Producteev Session Check
  7. ?>
  8. <a href="https://www.producteev.com/oauth/v2/auth?client_id=53518db120bce50455000004_1gphpxybebesgc04s8sw4s8kwooocsw80ocwc04kwkco0wsw4w&response_type=code&redirect_uri=http%3A%2F%2Fwww.pathinteractive.com%2Finternal%2Fproducteev%2Fauth.php">Please log in to Producteev</a>
  9. <?
  10. }else{ /// We have a valid Producteev Session
  11. $projectData=makeAPICall( "https://www.producteev.com/api/projects/".$_REQUEST['project']);
  12. //$projectData['content'];
  13. $projectData['content']=str_replace("\/","/",$projectData['content']);
  14. $pData2=json_decode($projectData['content']);
  15. //print_r($pData2->project->id);
  16. //print_r($projectData['content']);
  17. $taskData='{"task":{"title":"'.addslashes($_REQUEST['taskname']).'","project":{"id":"'.$pData2->project->id.'"}}}';
  18. $newTaskData=makeAPICall( "https://www.producteev.com/api/tasks", $taskData);
  19. ///print_r($newTaskData);
  20. if($newTaskData['http_code']=="201"){
  21. /// task created successfully
  22. $createdTaskData=json_decode($newTaskData['content']);
  23. /// TODO
  24. /// Get the new task ID
  25. //print_r($createdTaskData);
  26. $newTaskID=$createdTaskData->task->id;
  27. //print $newTaskID;
  28. ?>
  29. <h3>New task successfully added. <a href="https://www.producteev.com/workspace/t/<?=$newTaskID?>" class="btn btn-primary">Click to view</a></h3>
  30. <?
  31. $updateTaskData='{}';
  32. //// Update the task to add the label
  33. $updateTask=makeAPICall( "https://www.producteev.com/api/tasks/$newTaskID/labels/".$_REQUEST['labelid'],$updateTaskData,"PUT");
  34. $updateTaskData='{"task":{"deadline":"'.$_REQUEST['duedate'].'T20:00:00+0000",
  35. "deadline_timezone":"EST"
  36. }}';
  37. //// Update the task to add the label
  38. $updateTask=makeAPICall( "https://www.producteev.com/api/tasks/$newTaskID",$updateTaskData,"PUT");
  39. /// Update the task add the desc
  40. $newNoteData='{
  41. "note":{
  42. "message":"'.addslashes($_REQUEST['description']).'",
  43. "task":{
  44. "id":"'.$newTaskID.'"
  45. }
  46. }
  47. }';
  48. $updateTaskNotes=makeAPICall( "https://www.producteev.com/api/notes",$newNoteData,"POST");
  49. //api/notes?access_token=OGRlMWI1YmM5MDEyMjM3M2FkZmQ0ZjI2ZWUwYzJmYzZkOGZiMGJmMjZhZDYzMTliZDdhODY0NThkZjQ0M2UwMQ
  50. //print_r($updateTask);
  51. //// Update the task to add the attached images
  52. //// update the task to add Dev Team as a follower (or Tom King)
  53. }else{
  54. ?>
  55. There was a problem. Please try again.
  56. <?
  57. }
  58. //print_r($taskData);
  59. /*
  60. //$projectData['content'];
  61. $projectData['content']=str_replace("\/","/",$projectData['content']);
  62. for($i=0;$i<count($tasksToMove);$i++){
  63. $updateTask="";
  64. print "Updating...";
  65. print "<br>Looking to move to project id ".$_REQUEST['projectid'].":";
  66. print "<br>".$tasksToMove[$i];
  67. $taskDataToSend='{"task":'.$projectData['content'].'}';
  68. /// move the task into the project
  69. $updateTask=makeAPICall( "https://www.producteev.com/api/tasks/".$tasksToMove[$i],$taskDataToSend,"PUT");
  70. //print_r($taskDataToSend);
  71. //exit();
  72. //print_r($updateTask);
  73. //print($taskDataToSend);
  74. ?>
  75. <?
  76. // {"task":{"labels":["519b6a79bcd3e02c6d0000ba"]}}
  77. // remove the label from the task
  78. //$updateTask=makeAPICall("https://www.producteev.com/api/tasks/".$tasksToMove[$i]."/labels/".$_REQUEST['labelid'],"","DELETE");
  79. */
  80. ?>
  81. <?
  82. } /// End Producteev Session Check
  83. include_once("footer.php");
  84. ?>