Enalean /
tuleap
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Copyright (c) Enalean, 2014 - 2015. All rights reserved |
||
| 4 | * |
||
| 5 | * This file is a part of Tuleap. |
||
| 6 | * |
||
| 7 | * Tuleap is free software; you can redistribute it and/or modify |
||
| 8 | * it under the terms of the GNU General Public License as published by |
||
| 9 | * the Free Software Foundation; either version 2 of the License, or |
||
| 10 | * (at your option) any later version. |
||
| 11 | * |
||
| 12 | * Tuleap is distributed in the hope that it will be useful, |
||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 15 | * GNU General Public License for more details. |
||
| 16 | * |
||
| 17 | * You should have received a copy of the GNU General Public License |
||
| 18 | * along with Tuleap. If not, see <http://www.gnu.org/licenses/ |
||
| 19 | */ |
||
| 20 | |||
| 21 | class User_PreferencesPresenter { |
||
| 22 | |||
| 23 | /** @var PFUser */ |
||
| 24 | private $user; |
||
| 25 | public $can_change_real_name; |
||
| 26 | private $can_change_email; |
||
| 27 | private $can_change_password; |
||
| 28 | |||
| 29 | private $extra_user_info; |
||
| 30 | |||
| 31 | /** @var array */ |
||
| 32 | private $user_access; |
||
| 33 | |||
| 34 | /** string */ |
||
| 35 | private $third_party_html; |
||
| 36 | |||
| 37 | private $ssh_keys_extra_html; |
||
| 38 | |||
| 39 | /** @var SVN_TokenPresenter[] */ |
||
| 40 | public $svn_tokens; |
||
| 41 | |||
| 42 | public $csrf_input_html; |
||
| 43 | |||
| 44 | /** @var array */ |
||
| 45 | public $tracker_formats; |
||
| 46 | |||
| 47 | /** @var array */ |
||
| 48 | public $all_themes; |
||
| 49 | |||
| 50 | /** @var array */ |
||
| 51 | public $languages_html; |
||
| 52 | |||
| 53 | /** @var array */ |
||
| 54 | public $user_helper_preferences; |
||
| 55 | |||
| 56 | /** @var array */ |
||
| 57 | public $plugins_prefs; |
||
| 58 | |||
| 59 | /** @var array */ |
||
| 60 | public $all_csv_separator; |
||
| 61 | |||
| 62 | /** @var array */ |
||
| 63 | public $all_csv_dateformat; |
||
| 64 | |||
| 65 | /** @var string */ |
||
| 66 | public $last_svn_token; |
||
| 67 | |||
| 68 | public function __construct( |
||
| 69 | PFUser $user, |
||
| 70 | $can_change_real_name, |
||
| 71 | $can_change_email, |
||
| 72 | $can_change_password, |
||
| 73 | array $extra_user_info, |
||
| 74 | array $user_access, |
||
| 75 | $ssh_keys_extra_html, |
||
| 76 | $svn_tokens, |
||
| 77 | $third_party_html, |
||
| 78 | $csrf_input_html, |
||
| 79 | array $tracker_formats, |
||
| 80 | array $all_themes, |
||
| 81 | array $languages_html, |
||
| 82 | array $user_helper_preferences, |
||
| 83 | array $plugins_prefs, |
||
| 84 | array $all_csv_separator, |
||
| 85 | array $all_csv_dateformat, |
||
| 86 | $last_svn_token |
||
| 87 | ) { |
||
| 88 | $this->user = $user; |
||
| 89 | $this->can_change_real_name = $can_change_real_name; |
||
| 90 | $this->can_change_email = $can_change_email; |
||
| 91 | $this->can_change_password = $can_change_password; |
||
| 92 | $this->extra_user_info = $extra_user_info; |
||
| 93 | $this->user_access = $user_access; |
||
| 94 | $this->ssh_keys_extra_html = $ssh_keys_extra_html; |
||
| 95 | $this->svn_tokens = $svn_tokens; |
||
| 96 | $this->third_party_html = $third_party_html; |
||
| 97 | $this->csrf_input_html = $csrf_input_html; |
||
| 98 | $this->tracker_formats = $tracker_formats; |
||
| 99 | $this->all_themes = $all_themes; |
||
| 100 | $this->languages_html = $languages_html; |
||
| 101 | $this->user_helper_preferences = $user_helper_preferences; |
||
| 102 | $this->plugins_prefs = $plugins_prefs; |
||
| 103 | $this->all_csv_separator = $all_csv_separator; |
||
| 104 | $this->all_csv_dateformat = $all_csv_dateformat; |
||
| 105 | $this->last_svn_token = $last_svn_token; |
||
| 106 | } |
||
| 107 | |||
| 108 | public function generated_svn_token() { |
||
| 109 | return $GLOBALS['Language']->getText('account_options', 'generated_svn_token'); |
||
| 110 | } |
||
| 111 | |||
| 112 | public function has_avatar() { |
||
| 113 | return ForgeConfig::get('sys_enable_avatars'); |
||
| 114 | } |
||
| 115 | |||
| 116 | public function avatar() { |
||
| 117 | return $this->user->fetchHtmlAvatar(); |
||
| 118 | } |
||
| 119 | |||
| 120 | public function change_real_name() { |
||
| 121 | return $GLOBALS['Language']->getText('account_options', 'change_real_name'); |
||
| 122 | } |
||
| 123 | |||
| 124 | public function real_name() { |
||
| 125 | return $this->user->getRealName(); |
||
| 126 | } |
||
| 127 | |||
| 128 | public function user_username() { |
||
| 129 | return $this->user->getUnixName(); |
||
| 130 | } |
||
| 131 | |||
| 132 | public function welcome_user() { |
||
| 133 | return $GLOBALS['Language']->getText('account_options', 'welcome') . ' ' . $this->user->getRealName(); |
||
| 134 | } |
||
| 135 | |||
| 136 | public function user_id_label() { |
||
| 137 | return $GLOBALS['Language']->getText('account_options', 'user_id'); |
||
| 138 | } |
||
| 139 | |||
| 140 | public function user_id_value() { |
||
| 141 | return $this->user->getId(); |
||
| 142 | } |
||
| 143 | |||
| 144 | public function user_email_label() { |
||
| 145 | return $GLOBALS['Language']->getText('account_options', 'email_address'); |
||
| 146 | } |
||
| 147 | |||
| 148 | public function user_email_value() { |
||
| 149 | return $this->user->getEmail(); |
||
| 150 | } |
||
| 151 | |||
| 152 | public function can_change_email() { |
||
| 153 | return $this->can_change_email; |
||
| 154 | } |
||
| 155 | |||
| 156 | public function change_email() { |
||
| 157 | return $GLOBALS['Language']->getText('account_options', 'change_email_address'); |
||
| 158 | } |
||
| 159 | |||
| 160 | public function can_change_password() { |
||
| 161 | return $this->can_change_password; |
||
| 162 | } |
||
| 163 | |||
| 164 | public function change_password() { |
||
| 165 | return $GLOBALS['Language']->getText('account_options', 'change_password'); |
||
| 166 | } |
||
| 167 | |||
| 168 | public function member_since_label() { |
||
| 169 | return $GLOBALS['Language']->getText('account_options', 'member_since'); |
||
| 170 | } |
||
| 171 | |||
| 172 | public function member_since_value() { |
||
| 173 | return format_date($GLOBALS['Language']->getText('system', 'datefmt'), $this->user->getAddDate()); |
||
| 174 | } |
||
| 175 | |||
| 176 | public function timezone_label() { |
||
| 177 | return $GLOBALS['Language']->getText('account_options', 'timezone'); |
||
| 178 | } |
||
| 179 | |||
| 180 | public function timezone_value() { |
||
| 181 | return $this->user->getTimezone(); |
||
| 182 | } |
||
| 183 | |||
| 184 | public function change_timezone() { |
||
| 185 | return $GLOBALS['Language']->getText('account_options', 'change_timezone'); |
||
| 186 | } |
||
| 187 | |||
| 188 | public function extra_user_info() { |
||
| 189 | return $this->extra_user_info; |
||
| 190 | } |
||
| 191 | |||
| 192 | public function shell_account_title() { |
||
| 193 | return $GLOBALS['Language']->getText('account_options', 'shell_account_title'); |
||
| 194 | } |
||
| 195 | |||
| 196 | public function ssh_keys_count_label() { |
||
| 197 | return $GLOBALS['Language']->getText('account_options', 'shell_shared_keys'); |
||
| 198 | } |
||
| 199 | |||
| 200 | public function ssh_keys_count() { |
||
| 201 | return count($this->user->getAuthorizedKeysArray()); |
||
| 202 | } |
||
| 203 | |||
| 204 | public function ssh_keys_label() { |
||
| 205 | return 'Key'; |
||
| 206 | } |
||
| 207 | |||
| 208 | public function ssh_keys_list() { |
||
| 209 | $keys = array(); |
||
| 210 | foreach ($this->user->getAuthorizedKeysArray() as $ssh_key_number => $ssh_key_value) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 211 | $keys[] = array( |
||
| 212 | 'ssh_key_ellipsis_value' => substr($ssh_key_value, 0, 40).'...'.substr($ssh_key_value, -40), |
||
| 213 | 'ssh_key_value' => $ssh_key_value, |
||
| 214 | 'ssh_key_number' => $ssh_key_number |
||
| 215 | ); |
||
| 216 | } |
||
| 217 | return $keys; |
||
| 218 | } |
||
| 219 | |||
| 220 | public function ssh_keys_extra_html() { |
||
| 221 | return $this->ssh_keys_extra_html; |
||
| 222 | } |
||
| 223 | |||
| 224 | public function authentication_attempts_title() { |
||
| 225 | return $GLOBALS['Language']->getText('account_options', 'auth_attempt_title'); |
||
| 226 | } |
||
| 227 | |||
| 228 | public function last_successful_login_label() { |
||
| 229 | return $GLOBALS['Language']->getText('account_options', 'auth_attempt_last_success'); |
||
| 230 | } |
||
| 231 | |||
| 232 | public function last_successful_login_value() { |
||
| 233 | return format_date($GLOBALS['Language']->getText('system', 'datefmt'), $this->user_access['last_auth_success']); |
||
| 234 | } |
||
| 235 | |||
| 236 | public function last_login_failure_label() { |
||
| 237 | return $GLOBALS['Language']->getText('account_options', 'auth_attempt_last_failure'); |
||
| 238 | } |
||
| 239 | |||
| 240 | public function last_login_failure_value() { |
||
| 241 | return format_date($GLOBALS['Language']->getText('system', 'datefmt'), $this->user_access['last_auth_failure']); |
||
| 242 | } |
||
| 243 | |||
| 244 | public function number_login_failure_label() { |
||
| 245 | return $GLOBALS['Language']->getText('account_options', 'auth_attempt_nb_failure'); |
||
| 246 | } |
||
| 247 | |||
| 248 | public function number_login_failure_value() { |
||
| 249 | return $this->user_access['nb_auth_failure']; |
||
| 250 | } |
||
| 251 | |||
| 252 | public function previous_successful_login_label() { |
||
| 253 | return $GLOBALS['Language']->getText('account_options', 'auth_attempt_prev_success'); |
||
| 254 | } |
||
| 255 | |||
| 256 | public function previous_successful_login_value() { |
||
| 257 | return format_date($GLOBALS['Language']->getText('system', 'datefmt'), $this->user_access['prev_auth_success']); |
||
| 258 | } |
||
| 259 | |||
| 260 | public function third_party_applications_title() { |
||
| 261 | return 'Third party applications'; |
||
| 262 | } |
||
| 263 | |||
| 264 | public function third_party_applications_content() { |
||
| 265 | return $this->third_party_html; |
||
| 266 | } |
||
| 267 | |||
| 268 | public function user_legal() { |
||
| 269 | ob_start(); |
||
| 270 | include $GLOBALS['Language']->getContent('account/user_legal'); |
||
| 271 | return ob_get_clean(); |
||
| 272 | } |
||
| 273 | |||
| 274 | public function add_ssh_key_button() { |
||
| 275 | return $GLOBALS['Language']->getText('account_options', 'shell_add_keys'); |
||
| 276 | } |
||
| 277 | |||
| 278 | public function delete_ssh_key_button() { |
||
| 279 | return $GLOBALS['Language']->getText('account_options', 'shell_delete_ssh_keys'); |
||
| 280 | } |
||
| 281 | |||
| 282 | public function has_ssh_key() { |
||
| 283 | return $this->ssh_keys_count() > 0; |
||
| 284 | } |
||
| 285 | |||
| 286 | public function ssh_keys_no_key() { |
||
| 287 | return $GLOBALS['Language']->getText('account_options', 'ssh_keys_no_key'); |
||
| 288 | } |
||
| 289 | |||
| 290 | public function has_svn_tokens() { |
||
| 291 | return count($this->svn_tokens) > 0; |
||
| 292 | } |
||
| 293 | |||
| 294 | public function svn_tokens_title() { |
||
| 295 | return $GLOBALS['Language']->getText('account_options', 'svn_tokens_title'); |
||
| 296 | } |
||
| 297 | |||
| 298 | public function svn_tokens_help() { |
||
| 299 | return $GLOBALS['Language']->getText('account_options', 'svn_tokens_help'); |
||
| 300 | } |
||
| 301 | |||
| 302 | public function svn_tokens_no_token() { |
||
| 303 | return $GLOBALS['Language']->getText('account_options', 'svn_tokens_no_token'); |
||
| 304 | } |
||
| 305 | |||
| 306 | public function svn_token_generated_date() { |
||
| 307 | return $GLOBALS['Language']->getText('account_options', 'svn_token_generated_date'); |
||
| 308 | } |
||
| 309 | |||
| 310 | public function svn_token_last_usage() { |
||
| 311 | return $GLOBALS['Language']->getText('account_options', 'svn_token_last_usage'); |
||
| 312 | } |
||
| 313 | |||
| 314 | public function svn_token_last_ip() { |
||
| 315 | return $GLOBALS['Language']->getText('account_options', 'svn_token_last_ip'); |
||
| 316 | } |
||
| 317 | |||
| 318 | public function svn_token_comment() { |
||
| 319 | return $GLOBALS['Language']->getText('account_options', 'svn_token_comment'); |
||
| 320 | } |
||
| 321 | |||
| 322 | public function generate_svn_token_button() { |
||
| 323 | return $GLOBALS['Language']->getText('account_options', 'generate_svn_token_button'); |
||
| 324 | } |
||
| 325 | |||
| 326 | public function delete_svn_tokens_button() { |
||
| 327 | return $GLOBALS['Language']->getText('account_options', 'delete_svn_tokens_button'); |
||
| 328 | } |
||
| 329 | |||
| 330 | public function generate_svn_token_modal_title() { |
||
| 331 | return $GLOBALS['Language']->getText('account_options', 'generate_svn_token_modal_title'); |
||
| 332 | } |
||
| 333 | |||
| 334 | public function generate_svn_token_modal_button() { |
||
| 335 | return $GLOBALS['Language']->getText('account_options', 'generate_svn_token_modal_button'); |
||
| 336 | } |
||
| 337 | |||
| 338 | public function generate_svn_token_modal_button_comment_label() { |
||
| 339 | return $GLOBALS['Language']->getText('account_options', 'generate_svn_token_modal_button_comment_label'); |
||
| 340 | } |
||
| 341 | |||
| 342 | public function generate_svn_token_modal_button_comment_placeholder() { |
||
| 343 | return $GLOBALS['Language']->getText('account_options', 'generate_svn_token_modal_button_comment_placeholder'); |
||
| 344 | } |
||
| 345 | |||
| 346 | public function generate_svn_token_modal_button_help() { |
||
| 347 | return $GLOBALS['Language']->getText('account_options', 'generate_svn_token_modal_button_help'); |
||
| 348 | } |
||
| 349 | |||
| 350 | |||
| 351 | |||
| 352 | /* PREFERENCES */ |
||
| 353 | |||
| 354 | public function preference_title() { |
||
| 355 | return $GLOBALS['Language']->getText('account_options', 'preferences'); |
||
| 356 | } |
||
| 357 | |||
| 358 | public function email_settings() { |
||
| 359 | return $GLOBALS['Language']->getText('account_preferences', 'email_settings'); |
||
| 360 | } |
||
| 361 | |||
| 362 | public function user_has_mail_site_updates() { |
||
| 363 | return $this->user->getMailSiteUpdates(); |
||
| 364 | } |
||
| 365 | |||
| 366 | public function user_has_sticky_login() { |
||
| 367 | return $this->user->getStickyLogin(); |
||
| 368 | } |
||
| 369 | |||
| 370 | public function user_has_mail_va() { |
||
| 371 | return $this->user->getMailVA(); |
||
| 372 | } |
||
| 373 | |||
| 374 | public function site_update_label() { |
||
| 375 | return $GLOBALS['Language']->getText('account_register', 'siteupdate'); |
||
| 376 | } |
||
| 377 | |||
| 378 | public function community_mail_label() { |
||
| 379 | return $GLOBALS['Language']->getText('account_register', 'communitymail'); |
||
| 380 | } |
||
| 381 | |||
| 382 | public function tracker_mail_format_label() { |
||
| 383 | return $GLOBALS['Language']->getText('account_preferences','tracker_mail_format'); |
||
| 384 | } |
||
| 385 | |||
| 386 | public function tracker_mail_format_select_name() { |
||
| 387 | return Codendi_Mail_Interface::PREF_FORMAT; |
||
| 388 | } |
||
| 389 | |||
| 390 | public function session_label() { |
||
| 391 | return $GLOBALS['Language']->getText('account_preferences', 'session'); |
||
| 392 | } |
||
| 393 | |||
| 394 | public function remember_me() { |
||
| 395 | return $GLOBALS['Language']->getText('account_options', 'remember_me', $GLOBALS['sys_name']); |
||
| 396 | } |
||
| 397 | |||
| 398 | public function lab_features_title() { |
||
| 399 | return $GLOBALS['Language']->getText('account_preferences', 'lab_features_title', array($GLOBALS['sys_name'])); |
||
| 400 | } |
||
| 401 | |||
| 402 | public function lab_features_description() { |
||
| 403 | return $GLOBALS['Language']->getText('account_preferences', 'lab_features_description', array($GLOBALS['sys_name'])); |
||
| 404 | } |
||
| 405 | |||
| 406 | public function user_uses_lab_features() { |
||
| 407 | return $this->user->useLabFeatures(); |
||
| 408 | } |
||
| 409 | |||
| 410 | public function lab_features_checkbox_label() { |
||
| 411 | return $GLOBALS['Language']->getText('account_preferences', 'lab_features_cblabel', $GLOBALS['sys_name']); |
||
| 412 | } |
||
| 413 | |||
| 414 | public function lab_features_default_image() { |
||
| 415 | return $GLOBALS['HTML']->getImage('lab_features_default.png'); |
||
| 416 | } |
||
| 417 | |||
| 418 | public function appearance_title() { |
||
| 419 | return $GLOBALS['Language']->getText('account_preferences', 'appearance'); |
||
| 420 | } |
||
| 421 | |||
| 422 | public function theme_label() { |
||
| 423 | return $GLOBALS['Language']->getText('account_options', 'theme'); |
||
| 424 | } |
||
| 425 | |||
| 426 | public function default_theme() { |
||
| 427 | return $GLOBALS['Language']->getText('global', 'default'); |
||
| 428 | } |
||
| 429 | |||
| 430 | public function theme_variant_label() { |
||
| 431 | return $GLOBALS['Language']->getText('account_options', 'theme_variant'); |
||
| 432 | } |
||
| 433 | |||
| 434 | public function language_label() { |
||
| 435 | return $GLOBALS['Language']->getText('account_options', 'language'); |
||
| 436 | } |
||
| 437 | |||
| 438 | public function username_display_label() { |
||
| 439 | return $GLOBALS['Language']->getText('account_options', 'username_display'); |
||
| 440 | } |
||
| 441 | |||
| 442 | public function import_export_title() { |
||
| 443 | return $GLOBALS['Language']->getText('account_preferences', 'import_export'); |
||
| 444 | } |
||
| 445 | |||
| 446 | public function csv_separator_label() { |
||
| 447 | return $GLOBALS['Language']->getText('account_options', 'csv_separator'); |
||
| 448 | } |
||
| 449 | |||
| 450 | public function csv_dateformat_label() { |
||
| 451 | return $GLOBALS['Language']->getText('account_preferences', 'csv_dateformat'); |
||
| 452 | } |
||
| 453 | |||
| 454 | public function preference_save_button() { |
||
| 455 | return $GLOBALS['Language']->getText('account_preferences', 'save_preferences'); |
||
| 456 | } |
||
| 457 | |||
| 458 | /* MODAL */ |
||
| 459 | |||
| 460 | public function add_keys_modal_title() { |
||
| 461 | return $GLOBALS['Language']->getText('account_editsshkeys', 'add_keys_title'); |
||
| 462 | } |
||
| 463 | |||
| 464 | public function btn_close_label() { |
||
| 465 | return $GLOBALS['Language']->getText('global', 'btn_close'); |
||
| 466 | } |
||
| 467 | |||
| 468 | public function btn_save_keys_label() { |
||
| 469 | return $GLOBALS['Language']->getText('account_editsshkeys', 'btn_save_keys'); |
||
| 470 | } |
||
| 471 | } |
||
| 472 |