issue.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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,u.name as user FROM `issues` i JOIN `users` u ON u.id = i.u_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){
  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 `projects` WHERE title = '%s' AND u_id = %d",array($title,$user))){
  26. if($res->num_rows){
  27. return false;
  28. }
  29. }
  30. if(query("INSERT INTO `projects` (title,description,u_id) VALUES ('%s','%s',%d)",array($title,$description,$user))){
  31. if($res = query("SELECT id FROM `projects` WHERE title = '%s' AND description = '%s' AND u_id = %d",array($title,$description,$user))){
  32. if($res->num_rows == 1){
  33. $res = $res->fetch_assoc();
  34. project_comment($res['id'],'Project created');
  35. }
  36. return true;
  37. }
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. ?>