Request.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: Request.php 25522 2011-11-14 03:32:59Z yexinhao $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class Cloud_Service_Server_Request extends Cloud_Service_Server_Restful {
  12. protected static $_instance;
  13. public static function getInstance() {
  14. if (!(self::$_instance instanceof self)) {
  15. self::$_instance = new self();
  16. }
  17. return self::$_instance;
  18. }
  19. public function onRequestSend($uId, $recipientIds, $appId, $requestName, $myml, $type) {
  20. $now = time();
  21. $result = array();
  22. $type = ($type == 'request') ? 1 : 0;
  23. $fields = array('typename' => $requestName,
  24. 'appid' => $appId,
  25. 'type' => $type,
  26. 'fromuid' => $uId,
  27. 'dateline' => $now
  28. );
  29. foreach($recipientIds as $key => $val) {
  30. $hash = crc32($appId . $val . $now . rand(0, 1000));
  31. $hash = sprintf('%u', $hash);
  32. $fields['touid'] = intval($val);
  33. $fields['hash'] = $hash;
  34. $fields['myml'] = str_replace('{{MyReqHash}}', $hash, $myml);
  35. $result[] = C::t('common_myinvite')->insert($fields, true);
  36. $note = array(
  37. 'from_id' => $fields['touid'],
  38. 'from_idtype' => 'myappquery'
  39. );
  40. notification_add($fields['touid'], 'myapp', 'myinvite_request', $note);
  41. }
  42. return $result;
  43. }
  44. }