| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * Topic Image Preview. An extension for the phpBB Forum Software package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @copyright (c) 2017, 2020, Matt Friedman | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license GNU General Public License, version 2 (GPL-2.0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace vse\topicimagepreview\event; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use phpbb\config\config; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use phpbb\language\language; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use phpbb\request\request; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use phpbb\template\template; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use phpbb\user; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * Topic Image Preview Event listener. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | class settings implements EventSubscriberInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	/** @var config */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	protected $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	/** @var language */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	protected $language; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	/** @var request */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 	protected $request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 	/** @var template */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	protected $template; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 	/** @var user */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	protected $user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	 * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	public static function getSubscribedEvents() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 			// Global events | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 			'core.permissions'						=> 'add_permission', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 			// ACP events | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 			'core.acp_board_config_edit_add'		=> 'update_acp_data', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 			// UCP events | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 			'core.ucp_prefs_view_data'				=> 'handle_ucp_data', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 			'core.ucp_prefs_view_update_data'		=> 'update_ucp_data', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 	 * Constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	 * @param config   $config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	 * @param language $language | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	 * @param request  $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 	 * @param template $template | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	 * @param user     $user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	public function __construct(config $config, language $language, request $request, template $template, user $user) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 		$this->config = $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		$this->language = $language; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 		$this->request = $request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 		$this->template = $template; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 		$this->user = $user; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	 * Add administrative permissions to manage forums | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 	 * @param \phpbb\event\data $event The event object | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	public function add_permission($event) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 		$event->update_subarray('permissions', 'f_vse_tip', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 			'lang' => 'ACL_F_VSE_TIP', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 			'cat'  => 'actions', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 		]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	 * Add ACP config options to Post settings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 	 * @param \phpbb\event\data $event The event object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 	public function update_acp_data($event) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 		if ($event['mode'] === 'post' && array_key_exists('legend3', $event['display_vars']['vars'])) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 			$this->language->add_lang('tip_acp', 'vse/topicimagepreview'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 			$my_config_vars = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 				'legend_vse_tip'	=> 'ACP_TIP_TITLE', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 				'vse_tip_new'		=> ['lang' => 'ACP_TIP_DISPLAY_AGE', 'validate' => 'bool', 'type' => 'custom', 'function' => [$this, 'select_vse_tip_new'], 'explain' => true], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 				'vse_tip_num'		=> ['lang' => 'ACP_TIP_DISPLAY_NUM', 'validate' => 'int:0:99', 'type' => 'number:0:99', 'explain' => true], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 				'vse_tip_dim'		=> ['lang' => 'ACP_TIP_DISPLAY_DIM', 'validate' => 'int:0:999', 'type' => 'number:0:999', 'explain' => true, 'append' => ' ' . $this->language->lang('PIXEL')], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 				'vse_tip_srt'		=> ['lang' => 'ACP_TIP_DISPLAY_SRT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 			]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 			// Add an option to display in Precise Similar Topics if it is installed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 			if ($this->config->offsetExists('similar_topics')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 				$my_config_vars['vse_tip_pst'] = ['lang' => 'ACP_TIP_DISPLAY_PST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 			$event->update_subarray('display_vars', 'vars', phpbb_insert_config_array($event['display_vars']['vars'], $my_config_vars, ['before' => 'legend3'])); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 	 * Create custom radio buttons. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 	 * @param mixed  $value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 	 * @param string $key | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 	 * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 	public function select_vse_tip_new($value, $key = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 		$radio_ary = [1 => 'ACP_TIP_NEWEST_POST', 0 => 'ACP_TIP_OLDEST_POST']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 		return h_radio('config[vse_tip_new]', $radio_ary, $value, $key); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 	 * Get user's Topic Image Preview option and display it in UCP Preferences page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	 * @param \phpbb\event\data $event The event object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	 * @return void | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 140 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  | 	public function handle_ucp_data($event) | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  | 	{ | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  | 		// Request the user option vars and add them to the data array | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  | 		$event->update_subarray( | 
            
                                                                        
                            
            
                                    
            
            
                | 145 |  |  | 			'data', | 
            
                                                                        
                            
            
                                    
            
            
                | 146 |  |  | 			'user_vse_tip', | 
            
                                                                        
                            
            
                                    
            
            
                | 147 |  |  | 			$this->request->variable('user_vse_tip', (int) $this->user->data['user_vse_tip']) | 
            
                                                                        
                            
            
                                    
            
            
                | 148 |  |  | 		); | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  | 		// Output the data vars to the template (except on form submit) | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  | 		if (!$event['submit']) | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  | 		{ | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  | 			$this->language->add_lang('tip_ucp', 'vse/topicimagepreview'); | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  | 			$this->template->assign_vars([ | 
            
                                                                        
                            
            
                                    
            
            
                | 155 |  |  | 				'S_VSE_TIP_NUM' => $this->config->offsetGet('vse_tip_num'), | 
            
                                                                        
                            
            
                                    
            
            
                | 156 |  |  | 				'S_VSE_TIP_USER' => $event['data']['user_vse_tip'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 			]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 	 * Add user's Topic Image Preview option state into UCP sql_array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 	 * @param \phpbb\event\data $event The event object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 	public function update_ucp_data($event) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 		$event->update_subarray('sql_ary', 'user_vse_tip', $event['data']['user_vse_tip']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 172 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 173 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths