issue.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. require_once(realpath(dirname(__FILE__)).'/config.php');
  3. require_once(PATH_PHP.'database.php');
  4. require_once(PATH_PHP.'messages.php');
  5. function issueObj($id){
  6. if($res = query("SELECT i.id,i.title,i.description,i.s_id,u.name as user, p.name as priority, s.name as status,p.color FROM `issues` i JOIN `users` u ON u.id = i.u_id LEFT JOIN `priorities` p ON p.id = i.pr_id LEFT JOIN `statuses` s ON s.id = i.st_id WHERE i.id='%d'",array($id))){
  7. if($res->num_rows == 1){
  8. $issue = $res->fetch_assoc();
  9. $issue['user'] = userObj($issue['user']);
  10. $issue['comments'] = messages($issue['id'],'issue');
  11. return $issue;
  12. }
  13. }
  14. return false;
  15. }
  16. function newIssue($title,$description,$user=null,$sid=null){
  17. global $LOGGEDIN;
  18. global $mysqli;
  19. if($LOGGEDIN){
  20. if(is_null($user)){
  21. $user = $_SESSION['username'];
  22. }
  23. $user = userId($user);
  24. if(false != $user){
  25. if($res = query("SELECT id FROM `issues` WHERE title = '%s' AND u_id = %d",array($title,$user,$sid))){
  26. if($res->num_rows){
  27. return false;
  28. }
  29. }
  30. if(is_null($sid)){
  31. $sid = 'null';
  32. }else{
  33. $sid = intval($sid);
  34. }
  35. if(query("INSERT INTO `issues` (title,description,u_id,s_id,st_id) VALUES ('%s','%s',%d,%s,1)",array($title,$description,$user,$sid))){
  36. if($res = query("SELECT id FROM `issues` WHERE title = '%s' AND description = '%s' AND u_id = %d",array($title,$description,$user,$sid))){
  37. if($res->num_rows == 1){
  38. $res = $res->fetch_assoc();
  39. project_comment($res['id'],'Issue created');
  40. }
  41. return true;
  42. }
  43. }
  44. }
  45. }
  46. return false;
  47. }
  48. ?>