functions.php 900 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. require_once(realpath(dirname(__FILE__)).'/config.php');
  3. // TODO - create php functions for the api
  4. function retj($json,$title=null){
  5. if(is_null($title)){
  6. $title = $_GET['id'];
  7. }
  8. $type=$_GET['type'];
  9. $id=$_GET['id'];
  10. if(!isset($json['state'])){
  11. $json['state'] = Array();
  12. }
  13. unset($_GET['password']);
  14. if(!isset($json['state']['data'])){
  15. $json['state']['data'] = $_GET;
  16. }else{
  17. foreach($_GET as $key => $val){
  18. if(!isset($json['state']['data'][$key])&&$key!='password'){
  19. $json['state']['data'][$key] = $val;
  20. }
  21. }
  22. }
  23. $json['state']['title'] = $title;
  24. switch($type){
  25. case 'user':$url='~'.$id;break;
  26. case 'group':$url='+'.$id;break;
  27. case 'issue':$url='!'.$id;break;
  28. case 'template':$url='page-'.$id;break;
  29. case 'action':$url='';break;
  30. default:$url=$type.'-'.$id;
  31. }
  32. $json['state']['url'] = $url;
  33. die(json_encode($json));
  34. }
  35. ?>