issue.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. require_once(PATH_PHP.'activity.php');
  6. function issueObj($id){
  7. 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))){
  8. if($res->num_rows == 1){
  9. $issue = $res->fetch_assoc();
  10. $issue['user'] = userObj($issue['user']);
  11. $issue['comments'] = messages($issue['id'],'issue');
  12. return $issue;
  13. }
  14. }
  15. return false;
  16. }
  17. function newIssue($title,$description,$user=null,$sid=null){
  18. global $LOGGEDIN;
  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. $id = mysqli_insert_id(get_sql());
  37. project_comment($id,'Issue created');
  38. alog('i',$id,"Issue created");
  39. return true;
  40. }
  41. }
  42. }
  43. return false;
  44. }
  45. ?>