@@ -56,6 +56,9 @@ class ucp_listener implements EventSubscriberInterface
5656 */
5757 protected $ language ;
5858
59+ /* @var \phpbb\db\driver\driver_interface */
60+ protected $ db ;
61+
5962 /**
6063 * ucp_listener constructor.
6164 *
@@ -65,20 +68,24 @@ class ucp_listener implements EventSubscriberInterface
6568 * @param \phpbb\template\template $template
6669 * @param \phpbb\user $user
6770 * @param \phpbb\language\language $language
71+ * @param \phpbb\db\driver\driver_interface $db
6872 */
6973 public function __construct (\phpbb \auth \auth $ auth ,
7074 \phpbb \config \config $ config ,
7175 \phpbb \request \request $ request ,
7276 \phpbb \template \template $ template ,
7377 \phpbb \user $ user ,
74- \phpbb \language \language $ language )
78+ \phpbb \language \language $ language ,
79+ \phpbb \db \driver \driver_interface $ db
80+ )
7581 {
7682 $ this ->auth = $ auth ;
7783 $ this ->config = $ config ;
7884 $ this ->request = $ request ;
7985 $ this ->template = $ template ;
8086 $ this ->user = $ user ;
8187 $ this ->language = $ language ;
88+ $ this ->db = $ db ;
8289 }
8390
8491 /**
@@ -89,6 +96,7 @@ static public function getSubscribedEvents()
8996 return array (
9097 'core.ucp_prefs_view_data ' => 'ucp_prefs_get_data ' ,
9198 'core.ucp_prefs_view_update_data ' => 'ucp_prefs_set_data ' ,
99+ 'core.ucp_register_data_after ' => 'ucp_register_set_data '
92100 );
93101 }
94102
@@ -115,6 +123,7 @@ public function ucp_prefs_get_data($event)
115123
116124 $ template_vars = array ();
117125
126+ // if authorised for one of these then set ucp master template variable to true
118127 if ($ this ->auth ->acl_get ('u_rt_enable ' ) || $ this ->auth ->acl_get ('u_rt_location ' ) || $ this ->auth ->acl_get ('u_rt_sort_start_time ' ) || $ this ->auth ->acl_get ('u_rt_unread_only ' ))
119128 {
120129 $ template_vars += array (
@@ -199,4 +208,24 @@ public function ucp_prefs_set_data($event)
199208 )
200209 );
201210 }
211+
212+ /**
213+ * After new user registration, set rt user parameters to default;
214+ * @param $event
215+ */
216+ public function ucp_register_set_data ($ event )
217+ {
218+ $ sql = ' UPDATE ' . USERS_TABLE . ' SET ' ;
219+ $ sql .= " user_rt_enable = ' " . $ this ->config ['rt_index ' ] . "' " ;
220+ $ sql .= ", user_rt_sort_start_time = ' " . $ this ->config ['rt_sort_start_time ' ] . "' " ;
221+ $ sql .= ", user_rt_unread_only = ' " . $ this ->config ['rt_unread_only ' ] . "' " ;
222+ $ sql .= ", user_rt_location = ' " . $ this ->config ['rt_location ' ] . "' " ;
223+ $ sql .= ', user_rt_number = ' . ((int ) $ this ->config ['rt_number ' ] > 0 ? (int ) $ this ->config ['rt_number ' ] : 5 ) . ' ' ;
224+ $ sql .= ' WHERE 1=1 ' ;
225+ $ sql .= ' AND user_id = ' . $ this ->user ->data ['user_id ' ];
226+
227+ $ this ->db ->sql_query ($ sql );
228+ }
229+
230+
202231}
0 commit comments