Unsupported scripts and control panel web app for a hosting company
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

searches.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?PHP
  2. require_once('lib/dashboard.php');
  3. require_once('lib/common.php');
  4. $categories = getCategories();
  5. $admins = getAdmins();
  6. if (!isset($_GET['n'])) { $_GET['n'] = 'list'; }
  7. if ($_GET['n'] == 'add') {
  8. if (isset($_POST['add'])) {
  9. $_GET['n'] = 'list';
  10. unset($_POST['add']);
  11. $_POST = repairPost($_POST);
  12. print_r($_POST);
  13. if (!empty($_POST['title'])) {
  14. $sql = 'INSERT INTO issues_searches (user_id, isea_name, isea_options)
  15. VALUES (0, \''.m($_POST['title']).'\', \''.m(serialize($_POST)).'\')';
  16. mysql_query($sql) or die(mysql_error().'<br />'.$sql);
  17. }
  18. } else {
  19. $title = ' :: Add search';
  20. $page = 'addsearch.php';
  21. }
  22. }
  23. elseif ($_GET['n'] == 'edit') {
  24. if (isset($_GET['m']) && ctype_digit($_GET['m'])) {
  25. $title = ' :: Edit Search';
  26. $page = 'editsearch.php';
  27. if (!isset($_POST['edit'])) {
  28. $sql = 'SELECT isea_id, isea_name, isea_options FROM issues_searches WHERE isea_id = '.$_GET['m'].';';
  29. $res = mysql_query($sql);
  30. if (mysql_num_rows($res) == 0) {
  31. $_GET['n'] = 'list';
  32. } else {
  33. $data = mysql_fetch_assoc($res);
  34. $search = unserialize($data['isea_options']);
  35. $search['title'] = $data['isea_name'];
  36. foreach($search as $key => $value) {
  37. if ($value == '<<me>>') {
  38. $search[$key] = getUserID($_SERVER['REDIRECT_REMOTE_USER']);
  39. }
  40. }
  41. }
  42. } else {
  43. echo 'moo';
  44. }
  45. if (!isset($search['categories'])) {
  46. $search['categories'] = array();
  47. }
  48. if ($search['categories'] == 'all') {
  49. $search['categories'] = array_keys($categories);
  50. }
  51. if (!is_array($search['categories'])) {
  52. $search['categories'] = array($search['categories']);
  53. }
  54. if (!isset($search['priority'])) {
  55. $search['priority'] = array();
  56. }
  57. if ($search['priority'] == 'all') {
  58. $search['priority'] = array('urgent', 'high', 'normal', 'low');
  59. }
  60. if (!is_array($search['priority'])) {
  61. $search['priority'] = array($search['priority']);
  62. }
  63. if (!isset($search['status'])) {
  64. $search['status'] = array();
  65. }
  66. if ($search['status'] == 'all') {
  67. $search['status'] = array('open', 'assigned', 'closed', 'reopened');
  68. }
  69. if (!is_array($search['status'])) {
  70. $search['status'] = array($search['status']);
  71. }
  72. }
  73. }
  74. elseif ($_GET['n'] == 'delete') {
  75. if (isset($_GET['m']) && ctype_digit($_GET['m'])) {
  76. $title = ' :: Delete search';
  77. $page = 'deletesearch.php';
  78. }
  79. }
  80. if ($_GET['n'] == 'list') {
  81. $title = ' :: List searches';
  82. $page = 'listsearch.php';
  83. $sql = 'SELECT isea_id, isea_name, isea_options FROM issues_searches WHERE user_id =\''.m(getUserID($_SERVER['REDIRECT_REMOTE_USER'])).'\';';
  84. $res = mysql_query($sql);
  85. $savedsearches = array();
  86. if (mysql_num_rows($res) > 0) {
  87. while ($data = mysql_fetch_assoc($res)) {
  88. $savedsearches[] = $data;
  89. }
  90. }
  91. $sql = 'SELECT isea_id, isea_name, isea_options FROM issues_searches WHERE user_id =\'0\';';
  92. $res = mysql_query($sql);
  93. $globalsavedsearches = array();
  94. if (mysql_num_rows($res) > 0) {
  95. while ($data = mysql_fetch_assoc($res)) {
  96. $globalsavedsearches[] = $data;
  97. }
  98. }
  99. }
  100. define('TITLE', 'Issue tracker :: Manage searches'.$title);
  101. addDashboardItem('Actions', 'Add new saved search', 'searches/add');
  102. include('res/commonDashboard.php');
  103. require_once('lib/header.php');
  104. echo '<p>Incomplete</p>';
  105. require_once('pages/'.$page);
  106. require_once('lib/footer.php');
  107. ?>