openbaseAction.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * 基本接口
  4. * 请求地址如:http://URL/api.php?m=openbase&openkey=openkey&a=方法名
  5. */
  6. class openbaseClassAction extends openapiAction
  7. {
  8. /**
  9. * 例子1:新增模块单据,如新增流程单据等
  10. * 接口地址:http://URL/api.php?m=openbase&openkey=openkey&a=querydata
  11. */
  12. public function querydataAction()
  13. {
  14. $arr = $this->getpostarr();
  15. if(!$arr)return returnerror('not data');
  16. $modenum = $this->rock->xssrepstr($arr['basemodenum']);
  17. if(c('check')->onlynoen($modenum))$modenum = '';
  18. $adminid = $this->rock->xssrepstr($arr['baseoptid']); //提交的用户
  19. if(isempt($modenum))return returnerror('modenum is empty');
  20. $uid = $this->getuserid($adminid);
  21. if($uid==0)return returnerror('['.$adminid.']用户不存在');
  22. $sm = arrvalue($arr,'baseexplain'); //说明
  23. unset($arr['basemodenum']);
  24. unset($arr['baseoptid']);
  25. if($sm)unset($arr['baseexplain']);
  26. //此方法在文件:webmain/model/flowModel.php下的querydata方法。
  27. $mid = m('flow')->querydata($modenum, $arr, $sm);
  28. return returnsuccess(array(
  29. 'mid' => $mid,
  30. ));
  31. }
  32. /**
  33. * 例子2:推送消息到应用中
  34. * 接口地址:http://URL/api.php?m=openbase&openkey=openkey&a=pushtodo
  35. */
  36. public function pushtodoAction()
  37. {
  38. $mid = null; //要推送单据ID
  39. $modenum = 'daily'; //推送到哪个模块中,daily是工作日报模块
  40. //1、初始化流程
  41. $flow = m('flow')->initflow($modenum, $mid);
  42. //2、调用推送方法,调用webmain/model/flow/flow.php 下的push方法
  43. $receid = '1'; //接收人ID,多个,分开,如推送给全部人员写:d1
  44. $gname = ''; //推送到哪个应用下,为空,默认是跟当前模块名一样的应用。
  45. $cont = '这是个推送的内容';
  46. $title = '这是个标题'; //可以为空
  47. $flow->push($receid, $gname, $cont, $title);
  48. return '推送完成';
  49. }
  50. /**
  51. * 往日志写消息
  52. */
  53. public function addlogAction()
  54. {
  55. $type = $this->jm->base64decode($this->get('type'));
  56. $remark = $this->jm->base64decode($this->get('remark'));
  57. $level = (int)$this->get('level','2');
  58. $arr = array(
  59. 'type' => $this->rock->xssrepstr($type),
  60. 'remark' => $this->rock->xssrepstr($remark),
  61. 'optname' => '系统',
  62. 'optdt' => $this->rock->now,
  63. 'ip' => $this->rock->ip,
  64. 'level' => $level,
  65. );
  66. m('log')->insert($arr);
  67. return 'ok';
  68. }
  69. }
粤ICP备19079148号