Ingen beskrivning
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.

ActionBeginBehavior.php 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\user\behavior;
  3. /**
  4. * 系统行为扩展:新增/更新/删除之后的后置操作
  5. */
  6. class ActionBeginBehavior {
  7. protected static $actionName;
  8. protected static $controllerName;
  9. protected static $moduleName;
  10. protected static $method;
  11. /**
  12. * 构造方法
  13. * @param Request $request Request对象
  14. * @access public
  15. */
  16. public function __construct()
  17. {
  18. }
  19. // 行为扩展的执行入口必须是run
  20. public function run(&$params){
  21. self::$actionName = request()->action();
  22. self::$controllerName = request()->controller();
  23. self::$moduleName = request()->module();
  24. self::$method = request()->method();
  25. $this->_initialize();
  26. }
  27. private function _initialize() {
  28. if ('GET' == self::$method) {
  29. $this->reg_origin();
  30. } else if ('POST' == self::$method) {
  31. $this->logout_origin();
  32. }
  33. }
  34. /**
  35. * 标记来自不同项目的注册会员渠道
  36. * @access private
  37. */
  38. private function reg_origin()
  39. {
  40. /*特定场景专用*/
  41. $opencodetype = config('global.opencodetype');
  42. if (1 == $opencodetype) {
  43. if (self::$controllerName == 'Users' && self::$actionName == 'login') {
  44. $origin_type = 0;
  45. $origin_mid = 0;
  46. $origin_query = input('param.origin_query/s');
  47. if (!empty($origin_query)) {
  48. $origin_query = mchStrCode($origin_query, 'DECODE', '#$eyoucms%^');
  49. $origin_arr = explode('|', $origin_query);
  50. $origin_type = !empty($origin_arr[0]) ? intval($origin_arr[0]) : 0;
  51. $origin_mid = !empty($origin_arr[1]) ? intval($origin_arr[1]) : 0;
  52. }
  53. if (!empty($origin_type)) {
  54. cookie('origin_type', $origin_type);
  55. cookie('origin_mid', $origin_mid);
  56. } else {
  57. cookie('origin_type', null);
  58. cookie('origin_mid', null);
  59. }
  60. }
  61. }
  62. }
  63. /**
  64. * 退出清除的注册会员渠道标记
  65. * @access private
  66. */
  67. private function logout_origin()
  68. {
  69. /*特定场景专用*/
  70. $opencodetype = config('global.opencodetype');
  71. if (1 == $opencodetype) {
  72. if (self::$controllerName == 'Users' && self::$actionName == 'logout') {
  73. cookie('origin_type', null);
  74. cookie('origin_mid', null);
  75. }
  76. }
  77. }
  78. }