Completed
Push — master ( 7eff16...0eb589 )
by Florin
04:05
created
event/main_listener.php 2 patches
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -14,119 +14,119 @@
 block discarded – undo
14 14
 class main_listener implements EventSubscriberInterface
15 15
 {
16 16
 
17
-    static public function getSubscribedEvents()
18
-    {
19
-        return array(
20
-            'core.user_setup' => 'load_language_on_setup',
21
-            'core.page_footer' => 'get_language',
22
-            'core.page_header' => 'check_login',
23
-            'core.memberlist_view_profile' => 'check_friends'
24
-        );
25
-    }
26
-
27
-
28
-    /* @var \phpbb\template\template */
29
-    protected $template;
30
-
31
-    /**
32
-     * @var main_model
33
-     */
34
-    protected $model;
35
-
36
-    /**
37
-     * @var friends_model
38
-     */
39
-    protected $friends_model;
40
-
41
-    /**
42
-     * @var user
43
-     */
44
-    protected $user;
45
-
46
-    /**
47
-     * @var symfony_request
48
-     */
49
-    protected $symfony_request;
50
-
51
-    public function __construct(
52
-        template $template,
53
-        main_model $model,
54
-        friends_model $friends_model,
55
-        user $user,
56
-        symfony_request $symfony_request
57
-    )
58
-    {
59
-        $this->template = $template;
60
-        $this->model = $model;
61
-        $this->friends_model = $friends_model;
62
-        $this->user = $user;
63
-        $this->symfony_request = $symfony_request;
64
-    }
65
-
66
-    public function get_language()
67
-    {
68
-        $this->template->assign_vars(array(
69
-            'CHAT_LANGUAGE' => $this->user->lang_name
70
-        ));
71
-    }
72
-
73
-    public function load_language_on_setup($event)
74
-    {
75
-        $lang_set_ext = $event['lang_set_ext'];
76
-        $lang_set_ext[] = array(
77
-            'ext_name' => 'florinp/messenger',
78
-            'lang_set' => 'common',
79
-        );
80
-        $event['lang_set_ext'] = $lang_set_ext;
81
-    }
82
-
83
-    public function check_login()
84
-    {
85
-        $s_enable_messenger = 0;
86
-        if (in_array($this->user->data['user_type'], array(USER_NORMAL, USER_FOUNDER))) {
87
-            $s_enable_messenger = 1;
88
-        }
89
-        $this->template->assign_var('S_ENABLE_MESSENGER', $s_enable_messenger);
90
-    }
91
-
92
-    public function check_friends($event)
93
-    {
94
-        $context = new RequestContext();
95
-        $context->fromRequest($this->symfony_request);
96
-        $baseUrl = generate_board_url(true) . $context->getBaseUrl();
97
-
98
-        $scriptName = $this->symfony_request->getScriptName();
99
-        $scriptName = substr($scriptName, -1, 1) == '/' ? '' : utf8_basename($scriptName);
100
-
101
-        if ($scriptName != '') {
102
-            $baseUrl = str_replace('/' . $scriptName, '', $baseUrl);
103
-        }
104
-
105
-        $user_id = $event['member']['user_id'];
106
-        $sender_id = $this->user->data['user_id'];
107
-        $request = $this->friends_model->get_request_by_sender_id($sender_id);
108
-        $check_friend = $this->friends_model->check_friend(array(
109
-            'user_id' => $this->user->data['user_id'],
110
-            'friend_id' => $user_id,
111
-        ));
112
-        $check_request = $this->friends_model->check_request(array(
113
-            'user_id' => $user_id,
114
-            'sender_id' => $this->user->data['user_id']
115
-        ));
116
-        $check_request_confirm = $this->friends_model->check_request(array(
117
-            'user_id' => $this->user->data['user_id'],
118
-            'sender_id' => $user_id
119
-        ));
120
-        $check_widget = true;
121
-        if ($user_id == $this->user->data['user_id']) $check_widget = false;
122
-        $this->template->assign_vars(array(
123
-            'U_USER_ID' => $user_id,
124
-            'U_CHECK_FRIEND' => $check_friend,
125
-            'U_CHECK_REQUEST' => $check_request,
126
-            'U_CHECK_REQUEST_CONFIRM' => $check_request_confirm,
127
-            'U_CHECK_WIDGET' => $check_widget,
128
-            'U_REQUEST_ID' => $request['request_id'],
129
-            'BASE_URL' => $baseUrl
130
-        ));
131
-    }
17
+	static public function getSubscribedEvents()
18
+	{
19
+		return array(
20
+			'core.user_setup' => 'load_language_on_setup',
21
+			'core.page_footer' => 'get_language',
22
+			'core.page_header' => 'check_login',
23
+			'core.memberlist_view_profile' => 'check_friends'
24
+		);
25
+	}
26
+
27
+
28
+	/* @var \phpbb\template\template */
29
+	protected $template;
30
+
31
+	/**
32
+	 * @var main_model
33
+	 */
34
+	protected $model;
35
+
36
+	/**
37
+	 * @var friends_model
38
+	 */
39
+	protected $friends_model;
40
+
41
+	/**
42
+	 * @var user
43
+	 */
44
+	protected $user;
45
+
46
+	/**
47
+	 * @var symfony_request
48
+	 */
49
+	protected $symfony_request;
50
+
51
+	public function __construct(
52
+		template $template,
53
+		main_model $model,
54
+		friends_model $friends_model,
55
+		user $user,
56
+		symfony_request $symfony_request
57
+	)
58
+	{
59
+		$this->template = $template;
60
+		$this->model = $model;
61
+		$this->friends_model = $friends_model;
62
+		$this->user = $user;
63
+		$this->symfony_request = $symfony_request;
64
+	}
65
+
66
+	public function get_language()
67
+	{
68
+		$this->template->assign_vars(array(
69
+			'CHAT_LANGUAGE' => $this->user->lang_name
70
+		));
71
+	}
72
+
73
+	public function load_language_on_setup($event)
74
+	{
75
+		$lang_set_ext = $event['lang_set_ext'];
76
+		$lang_set_ext[] = array(
77
+			'ext_name' => 'florinp/messenger',
78
+			'lang_set' => 'common',
79
+		);
80
+		$event['lang_set_ext'] = $lang_set_ext;
81
+	}
82
+
83
+	public function check_login()
84
+	{
85
+		$s_enable_messenger = 0;
86
+		if (in_array($this->user->data['user_type'], array(USER_NORMAL, USER_FOUNDER))) {
87
+			$s_enable_messenger = 1;
88
+		}
89
+		$this->template->assign_var('S_ENABLE_MESSENGER', $s_enable_messenger);
90
+	}
91
+
92
+	public function check_friends($event)
93
+	{
94
+		$context = new RequestContext();
95
+		$context->fromRequest($this->symfony_request);
96
+		$baseUrl = generate_board_url(true) . $context->getBaseUrl();
97
+
98
+		$scriptName = $this->symfony_request->getScriptName();
99
+		$scriptName = substr($scriptName, -1, 1) == '/' ? '' : utf8_basename($scriptName);
100
+
101
+		if ($scriptName != '') {
102
+			$baseUrl = str_replace('/' . $scriptName, '', $baseUrl);
103
+		}
104
+
105
+		$user_id = $event['member']['user_id'];
106
+		$sender_id = $this->user->data['user_id'];
107
+		$request = $this->friends_model->get_request_by_sender_id($sender_id);
108
+		$check_friend = $this->friends_model->check_friend(array(
109
+			'user_id' => $this->user->data['user_id'],
110
+			'friend_id' => $user_id,
111
+		));
112
+		$check_request = $this->friends_model->check_request(array(
113
+			'user_id' => $user_id,
114
+			'sender_id' => $this->user->data['user_id']
115
+		));
116
+		$check_request_confirm = $this->friends_model->check_request(array(
117
+			'user_id' => $this->user->data['user_id'],
118
+			'sender_id' => $user_id
119
+		));
120
+		$check_widget = true;
121
+		if ($user_id == $this->user->data['user_id']) $check_widget = false;
122
+		$this->template->assign_vars(array(
123
+			'U_USER_ID' => $user_id,
124
+			'U_CHECK_FRIEND' => $check_friend,
125
+			'U_CHECK_REQUEST' => $check_request,
126
+			'U_CHECK_REQUEST_CONFIRM' => $check_request_confirm,
127
+			'U_CHECK_WIDGET' => $check_widget,
128
+			'U_REQUEST_ID' => $request['request_id'],
129
+			'BASE_URL' => $baseUrl
130
+		));
131
+	}
132 132
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -93,13 +93,13 @@
 block discarded – undo
93 93
     {
94 94
         $context = new RequestContext();
95 95
         $context->fromRequest($this->symfony_request);
96
-        $baseUrl = generate_board_url(true) . $context->getBaseUrl();
96
+        $baseUrl = generate_board_url(true).$context->getBaseUrl();
97 97
 
98 98
         $scriptName = $this->symfony_request->getScriptName();
99 99
         $scriptName = substr($scriptName, -1, 1) == '/' ? '' : utf8_basename($scriptName);
100 100
 
101 101
         if ($scriptName != '') {
102
-            $baseUrl = str_replace('/' . $scriptName, '', $baseUrl);
102
+            $baseUrl = str_replace('/'.$scriptName, '', $baseUrl);
103 103
         }
104 104
 
105 105
         $user_id = $event['member']['user_id'];
Please login to merge, or discard this patch.