Agent.class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. include_once(__DIR__."/../../utils/Utils.class.php");
  3. class Agent
  4. {
  5. public $agentid = null; // string
  6. public $name = null; // string
  7. public $square_logo_url = null; // string
  8. public $description = null; // string
  9. public $allow_userinfos = null; // string array
  10. public $allow_partys = null; // uint array
  11. public $allow_tags = null; // uint array
  12. public $close = null; // uint, 企业应用是否被禁用
  13. public $redirect_domain = null; // string
  14. public $report_location_flag = null; // uint, 企业应用是否打开地理位置上报 0:不上报;1:进入会话上报;
  15. public $isreportenter = null; // uint, 是否上报用户进入应用事件。0:不接收;1:接收
  16. public $home_url = null; // string
  17. public static function Array2Agent($arr)
  18. {
  19. $agent = new Agent();
  20. $agent->agentid = Utils::arrayGet($arr, "agentid");
  21. $agent->name = Utils::arrayGet($arr, "name");
  22. $agent->square_logo_url = Utils::arrayGet($arr, "square_logo_url");
  23. $agent->description = Utils::arrayGet($arr, "description");
  24. $agent->close = Utils::arrayGet($arr, "close");
  25. $agent->redirect_domain = Utils::arrayGet($arr, "redirect_domain");
  26. $agent->report_location_flag = Utils::arrayGet($arr, "report_location_flag");
  27. $agent->isreportenter = Utils::arrayGet($arr, "isreportenter");
  28. $agent->home_url = Utils::arrayGet($arr, "home_url");
  29. if (array_key_exists("allow_userinfos", $arr) && array_key_exists("user", $arr["allow_userinfos"])) {
  30. $userArr = $arr["allow_userinfos"]["user"];
  31. foreach($userArr as $item) {
  32. $agent->allow_userinfos[] = $item["userid"];
  33. }
  34. }
  35. if (array_key_exists("allow_partys", $arr)) {
  36. $partyAr = $arr["allow_partys"];
  37. $agent->allow_partys = Utils::arrayGet($partyAr, "partyid");
  38. }
  39. if (array_key_exists("allow_tags", $arr)) {
  40. $tagArr= $arr["allow_tags"];
  41. $agent->allow_tags= Utils::arrayGet($tagArr, "tagid");
  42. }
  43. return $agent;
  44. }
  45. public static function Array2AgentList($arr)
  46. {
  47. $agentLIst = array();
  48. foreach($arr["agentlist"] as $item) {
  49. $agent = self::Array2Agent($item);
  50. $agentLIst[] = $agent;
  51. }
  52. return $agentLIst;
  53. }
  54. public static function Agent2Array($agent)
  55. {
  56. $args = array();
  57. Utils::setIfNotNull($agent->agentid, "agentid", $args);
  58. Utils::setIfNotNull($agent->name, "name", $args);
  59. Utils::setIfNotNull($agent->square_logo_url, "square_logo_url", $args);
  60. Utils::setIfNotNull($agent->description, "description", $args);
  61. Utils::setIfNotNull($agent->close, "close", $args);
  62. Utils::setIfNotNull($agent->redirect_domain, "redirect_domain", $args);
  63. Utils::setIfNotNull($agent->report_location_flag, "report_location_flag", $args);
  64. Utils::setIfNotNull($agent->isreportenter, "isreportenter", $args);
  65. Utils::setIfNotNull($agent->home_url, "home_url", $args);
  66. return $args;
  67. }
  68. public static function CheckAgentSetArgs($agent)
  69. {
  70. utils::checkIsUInt($agent->agentid, "agentid");
  71. }
  72. }