[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 14 namespace phpbb\profilefields; 15 16 /** 17 * Custom Profile Fields (CPF) manager. 18 */ 19 class manager 20 { 21 /** @var \phpbb\auth\auth */ 22 protected $auth; 23 24 /** @var \phpbb\config\db_text */ 25 protected $config_text; 26 27 /** @var \phpbb\db\driver\driver_interface */ 28 protected $db; 29 30 /** @var \phpbb\db\tools\tools */ 31 protected $db_tools; 32 33 /** @var \phpbb\event\dispatcher_interface */ 34 protected $dispatcher; 35 36 /** @var \phpbb\language\language */ 37 protected $language; 38 39 /** @var \phpbb\log\log */ 40 protected $log; 41 42 /** @var \phpbb\request\request */ 43 protected $request; 44 45 /** @var \phpbb\template\template */ 46 protected $template; 47 48 /** @var \phpbb\di\service_collection */ 49 protected $type_collection; 50 51 /** @var \phpbb\user */ 52 protected $user; 53 54 /** @var string Profile fields table */ 55 protected $fields_table; 56 57 /** @var string Profile fields data table */ 58 protected $fields_data_table; 59 60 /** @var string Profile fields data (options) table */ 61 protected $fields_data_lang_table; 62 63 /** @var string Profile fields language table */ 64 protected $fields_lang_table; 65 66 /** @var array Users custom profile fields cache */ 67 protected $profile_cache = []; 68 69 /** 70 * Construct 71 * 72 * @param \phpbb\auth\auth $auth Auth object 73 * @param \phpbb\config\db_text $config_text Config_text object 74 * @param \phpbb\db\driver\driver_interface $db Database object 75 * @param \phpbb\db\tools\tools $db_tools Database tools object 76 * @param \phpbb\event\dispatcher_interface $dispatcher Event dispatcher object 77 * @param \phpbb\language\language $language Language object 78 * @param \phpbb\log\log $log Log object 79 * @param \phpbb\request\request $request Request object 80 * @param \phpbb\template\template $template Template object 81 * @param \phpbb\di\service_collection $type_collection CPF Type collection 82 * @param \phpbb\user $user User object 83 * @param string $fields_table CPF Table 84 * @param string $fields_data_table CPF Data table 85 * @param string $fields_data_lang_table CPF Data language table 86 * @param string $fields_lang_table CPF Language table 87 */ 88 public function __construct( 89 \phpbb\auth\auth $auth, 90 \phpbb\config\db_text $config_text, 91 \phpbb\db\driver\driver_interface $db, 92 \phpbb\db\tools\tools $db_tools, 93 \phpbb\event\dispatcher_interface $dispatcher, 94 \phpbb\language\language $language, 95 \phpbb\log\log $log, 96 \phpbb\request\request $request, 97 \phpbb\template\template $template, 98 \phpbb\di\service_collection $type_collection, 99 \phpbb\user $user, 100 $fields_table, 101 $fields_data_table, 102 $fields_data_lang_table, 103 $fields_lang_table 104 ) 105 { 106 $this->auth = $auth; 107 $this->config_text = $config_text; 108 $this->db = $db; 109 $this->db_tools = $db_tools; 110 $this->dispatcher = $dispatcher; 111 $this->language = $language; 112 $this->log = $log; 113 $this->request = $request; 114 $this->template = $template; 115 $this->type_collection = $type_collection; 116 $this->user = $user; 117 118 $this->fields_table = $fields_table; 119 $this->fields_data_table = $fields_data_table; 120 $this->fields_data_lang_table = $fields_data_lang_table; 121 $this->fields_lang_table = $fields_lang_table; 122 } 123 124 /** 125 * Assign editable fields to template. 126 * 127 * Called by ucp_profile and ucp_register. 128 * 129 * @param string $mode The mode (profile|register) 130 * @param int $lang_id The language identifier 131 * @return void 132 */ 133 public function generate_profile_fields($mode, $lang_id) 134 { 135 $sql_where = ''; 136 137 switch ($mode) 138 { 139 case 'register': 140 // If the field is required we show it on the registration page 141 $sql_where .= ' AND f.field_show_on_reg = 1'; 142 break; 143 144 case 'profile': 145 // Show hidden fields to moderators/admins 146 if (!$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_')) 147 { 148 $sql_where .= ' AND f.field_show_profile = 1'; 149 } 150 break; 151 152 default: 153 trigger_error('NO_MODE', E_USER_ERROR); 154 break; 155 } 156 157 $sql = 'SELECT l.*, f.* 158 FROM ' . $this->fields_lang_table . ' l, 159 ' . $this->fields_table . ' f 160 WHERE l.field_id = f.field_id 161 AND f.field_active = 1 162 AND l.lang_id = ' . (int) $lang_id 163 . $sql_where . ' 164 ORDER BY f.field_order ASC'; 165 $result = $this->db->sql_query($sql); 166 while ($row = $this->db->sql_fetchrow($result)) 167 { 168 /** @var \phpbb\profilefields\type\type_interface $profile_field */ 169 $profile_field = $this->type_collection[$row['field_type']]; 170 171 $this->template->assign_block_vars('profile_fields', [ 172 'FIELD' => $profile_field->process_field_row('change', $row), 173 'FIELD_ID' => $profile_field->get_field_ident($row), 174 'LANG_NAME' => $this->language->lang($row['lang_name']), 175 'LANG_EXPLAIN' => $this->language->lang($row['lang_explain']), 176 'S_REQUIRED' => (bool) $row['field_required'], 177 ]); 178 } 179 $this->db->sql_freeresult($result); 180 } 181 182 /** 183 * Build profile cache, used for display. 184 * 185 * @return void 186 */ 187 protected function build_cache() 188 { 189 $this->profile_cache = []; 190 191 // Display hidden/no_view fields for admin/moderator 192 $sql_where = !$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_') ? ' AND f.field_hide = 0' : ''; 193 194 $sql = 'SELECT l.*, f.* 195 FROM ' . $this->fields_lang_table . ' l, 196 ' . $this->fields_table . ' f 197 WHERE l.field_id = f.field_id 198 AND f.field_active = 1 199 AND f.field_no_view = 0 200 AND l.lang_id = ' . $this->user->get_iso_lang_id() 201 . $sql_where . ' 202 ORDER BY f.field_order ASC'; 203 $result = $this->db->sql_query($sql); 204 while ($row = $this->db->sql_fetchrow($result)) 205 { 206 $this->profile_cache[$row['field_ident']] = $row; 207 } 208 $this->db->sql_freeresult($result); 209 } 210 211 /** 212 * Submit profile field for validation. 213 * 214 * @param string $mode The mode (profile|register) 215 * @param int $lang_id The language identifier 216 * @param array $cp_data Custom profile field data 217 * @param array $cp_error Custom profile field errors 218 */ 219 public function submit_cp_field($mode, $lang_id, &$cp_data, &$cp_error) 220 { 221 $sql_where = ''; 222 223 switch ($mode) 224 { 225 case 'register': 226 // If the field is required we show it on the registration page 227 $sql_where .= ' AND f.field_show_on_reg = 1'; 228 break; 229 230 case 'profile': 231 // Show hidden fields to moderators/admins 232 if (!$this->auth->acl_gets('a_', 'm_') && !$this->auth->acl_getf_global('m_')) 233 { 234 $sql_where .= ' AND f.field_show_profile = 1'; 235 } 236 break; 237 238 default: 239 trigger_error('NO_MODE', E_USER_ERROR); 240 break; 241 } 242 243 $sql = 'SELECT l.*, f.* 244 FROM ' . $this->fields_lang_table . ' l, 245 ' . $this->fields_table . ' f 246 WHERE l.field_id = f.field_id 247 AND f.field_active = 1 248 AND l.lang_id = ' . (int) $lang_id 249 . $sql_where . ' 250 ORDER BY f.field_order'; 251 $result = $this->db->sql_query($sql); 252 while ($row = $this->db->sql_fetchrow($result)) 253 { 254 /** @var \phpbb\profilefields\type\type_interface $profile_field */ 255 $profile_field = $this->type_collection[$row['field_type']]; 256 $cp_data['pf_' . $row['field_ident']] = $profile_field->get_profile_field($row); 257 258 /** 259 * Replace Emoji and other 4bit UTF-8 chars not allowed by MySQL 260 * with their Numeric Character Reference's Hexadecimal notation. 261 */ 262 $cp_data['pf_' . $row['field_ident']] = utf8_encode_ucr($cp_data['pf_' . $row['field_ident']]); 263 264 $check_value = $cp_data['pf_' . $row['field_ident']]; 265 266 if (($cp_result = $profile_field->validate_profile_field($check_value, $row)) !== false) 267 { 268 // If the result is not false, it's an error message 269 $cp_error[] = $cp_result; 270 } 271 } 272 $this->db->sql_freeresult($result); 273 } 274 275 /** 276 * Update profile field data directly. 277 * 278 * @param int $user_id The user identifier 279 * @param array $cp_data Custom profile field data 280 */ 281 public function update_profile_field_data($user_id, $cp_data) 282 { 283 if (empty($cp_data)) 284 { 285 return; 286 } 287 288 $sql = 'UPDATE ' . $this->fields_data_table . ' 289 SET ' . $this->db->sql_build_array('UPDATE', $cp_data) . ' 290 WHERE user_id = ' . (int) $user_id; 291 $this->db->sql_query($sql); 292 293 if (!$this->db->sql_affectedrows()) 294 { 295 $cp_data = $this->build_insert_sql_array($cp_data); 296 $cp_data['user_id'] = (int) $user_id; 297 298 $sql = 'INSERT INTO ' . $this->fields_data_table . $this->db->sql_build_array('INSERT', $cp_data); 299 $this->db->sql_query($sql); 300 } 301 } 302 303 /** 304 * Generate the template arrays in order to display the column names. 305 * 306 * @param string $restrict_option Restrict the published fields to a certain profile field option 307 * @return array Returns an array with the template variables type, 308 * name and explain for the fields to display 309 */ 310 public function generate_profile_fields_template_headlines($restrict_option = '') 311 { 312 if (empty($this->profile_cache)) 313 { 314 $this->build_cache(); 315 } 316 317 $tpl_fields = []; 318 319 // Go through the fields in correct order 320 foreach ($this->profile_cache as $field_ident => $field_data) 321 { 322 if ($restrict_option && !$field_data[$restrict_option]) 323 { 324 continue; 325 } 326 327 /** @var \phpbb\profilefields\type\type_interface $profile_field */ 328 $profile_field = $this->type_collection[$field_data['field_type']]; 329 330 $tpl_fields[] = [ 331 'PROFILE_FIELD_IDENT' => $field_ident, 332 'PROFILE_FIELD_TYPE' => $field_data['field_type'], 333 'PROFILE_FIELD_NAME' => $profile_field->get_field_name($field_data['lang_name']), 334 'PROFILE_FIELD_EXPLAIN' => $this->language->lang($field_data['lang_explain']), 335 ]; 336 } 337 338 $profile_cache = $this->profile_cache; 339 340 /** 341 * Event to modify template headlines of the generated profile fields 342 * 343 * @event core.generate_profile_fields_template_headlines 344 * @var string restrict_option Restrict the published fields to a certain profile field option 345 * @var array tpl_fields Array with template data fields 346 * @var array profile_cache A copy of the profile cache to make additional checks 347 * @since 3.1.6-RC1 348 */ 349 $vars = ['restrict_option', 'tpl_fields', 'profile_cache']; 350 extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_headlines', compact($vars))); 351 unset($profile_cache); 352 353 return $tpl_fields; 354 } 355 356 /** 357 * Grab the user specific profile fields data. 358 * 359 * @param int|array $user_ids Single user id or an array of ids 360 * @return array Users profile fields data 361 */ 362 public function grab_profile_fields_data($user_ids = 0) 363 { 364 if (empty($this->profile_cache)) 365 { 366 $this->build_cache(); 367 } 368 369 if (empty($user_ids)) 370 { 371 return []; 372 } 373 374 $user_ids = (array) $user_ids; 375 376 $sql = 'SELECT * 377 FROM ' . $this->fields_data_table . ' 378 WHERE ' . $this->db->sql_in_set('user_id', array_map('intval', $user_ids)); 379 $result = $this->db->sql_query($sql); 380 $rowset = $this->db->sql_fetchrowset($result); 381 $this->db->sql_freeresult($result); 382 383 $field_data = array_column($rowset, null, 'user_id'); 384 385 /** 386 * Event to modify profile fields data retrieved from the database 387 * 388 * @event core.grab_profile_fields_data 389 * @var array user_ids Single user id or an array of ids 390 * @var array field_data Array with profile fields data 391 * @since 3.1.0-b3 392 */ 393 $vars = ['user_ids', 'field_data']; 394 extract($this->dispatcher->trigger_event('core.grab_profile_fields_data', compact($vars))); 395 396 $user_fields = []; 397 398 // Go through the fields in correct order 399 foreach (array_keys($this->profile_cache) as $used_ident) 400 { 401 foreach ($field_data as $user_id => $row) 402 { 403 $user_fields[$user_id][$used_ident]['value'] = $row['pf_' . $used_ident]; 404 $user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident]; 405 } 406 407 foreach ($user_ids as $user_id) 408 { 409 if (!isset($user_fields[$user_id][$used_ident])) 410 { 411 $user_fields[$user_id][$used_ident]['value'] = ''; 412 $user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident]; 413 } 414 } 415 } 416 417 return $user_fields; 418 } 419 420 /** 421 * Generate the user's profile fields data for the template. 422 * 423 * @param array $profile_row Array with users profile field data 424 * @param bool $use_contact_fields Should we display contact fields as such? 425 * This requires special treatments: 426 * (links should not be parsed in the values, and more) 427 * @return array The user's profile fields data 428 */ 429 public function generate_profile_fields_template_data($profile_row, $use_contact_fields = true) 430 { 431 // $profile_row == $user_fields[$row['user_id']]; 432 $tpl_fields = [ 433 'row' => [], 434 'blockrow' => [], 435 ]; 436 437 /** 438 * Event to modify data of the generated profile fields, before the template assignment loop 439 * 440 * @event core.generate_profile_fields_template_data_before 441 * @var array profile_row Array with users profile field data 442 * @var array tpl_fields Array with template data fields 443 * @var bool use_contact_fields Should we display contact fields as such? 444 * @since 3.1.0-b3 445 */ 446 $vars = ['profile_row', 'tpl_fields', 'use_contact_fields']; 447 extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_data_before', compact($vars))); 448 449 foreach ($profile_row as $ident => $ident_ary) 450 { 451 /** @var \phpbb\profilefields\type\type_interface $profile_field */ 452 $profile_field = $this->type_collection[$ident_ary['data']['field_type']]; 453 454 $value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']); 455 $value_raw = $profile_field->get_profile_value_raw($ident_ary['value'], $ident_ary['data']); 456 457 if ($value === null) 458 { 459 continue; 460 } 461 462 $field_desc = ''; 463 $contact_url = ''; 464 $ident_upper = strtoupper($ident); 465 466 if ($use_contact_fields && $ident_ary['data']['field_is_contact']) 467 { 468 $value = $profile_field->get_profile_contact_value($ident_ary['value'], $ident_ary['data']); 469 $field_desc = $this->language->lang($ident_ary['data']['field_contact_desc']); 470 471 if (strpos($field_desc, '%s') !== false) 472 { 473 $field_desc = sprintf($field_desc, $value); 474 } 475 476 if (strpos($ident_ary['data']['field_contact_url'], '%s') !== false) 477 { 478 $contact_url = sprintf($ident_ary['data']['field_contact_url'], $value); 479 } 480 } 481 482 $tpl_fields['row'] += [ 483 "PROFILE_{$ident_upper}_IDENT" => $ident, 484 "PROFILE_{$ident_upper}_VALUE" => $value, 485 "PROFILE_{$ident_upper}_VALUE_RAW" => $value_raw, 486 "PROFILE_{$ident_upper}_CONTACT" => $contact_url, 487 "PROFILE_{$ident_upper}_DESC" => $field_desc, 488 "PROFILE_{$ident_upper}_TYPE" => $ident_ary['data']['field_type'], 489 "PROFILE_{$ident_upper}_NAME" => $this->language->lang($ident_ary['data']['lang_name']), 490 "PROFILE_{$ident_upper}_EXPLAIN" => $this->language->lang($ident_ary['data']['lang_explain']), 491 492 "S_PROFILE_{$ident_upper}_CONTACT" => $ident_ary['data']['field_is_contact'], 493 "S_PROFILE_{$ident_upper}" => true, 494 ]; 495 496 $tpl_fields['blockrow'][] = [ 497 'PROFILE_FIELD_IDENT' => $ident, 498 'PROFILE_FIELD_VALUE' => $value, 499 'PROFILE_FIELD_VALUE_RAW' => $value_raw, 500 'PROFILE_FIELD_CONTACT' => $contact_url, 501 'PROFILE_FIELD_DESC' => $field_desc, 502 'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'], 503 'PROFILE_FIELD_NAME' => $this->language->lang($ident_ary['data']['lang_name']), 504 'PROFILE_FIELD_EXPLAIN' => $this->language->lang($ident_ary['data']['lang_explain']), 505 506 'S_PROFILE_CONTACT' => $ident_ary['data']['field_is_contact'], 507 "S_PROFILE_{$ident_upper}" => true, 508 ]; 509 } 510 511 /** 512 * Event to modify template data of the generated profile fields 513 * 514 * @event core.generate_profile_fields_template_data 515 * @var array profile_row Array with users profile field data 516 * @var array tpl_fields Array with template data fields 517 * @var bool use_contact_fields Should we display contact fields as such? 518 * @since 3.1.0-b3 519 */ 520 $vars = ['profile_row', 'tpl_fields', 'use_contact_fields']; 521 extract($this->dispatcher->trigger_event('core.generate_profile_fields_template_data', compact($vars))); 522 523 return $tpl_fields; 524 } 525 526 /** 527 * Build array for the custom profile fields table. 528 * 529 * @param array $cp_data Custom profile field data 530 * @return array Custom profile field data for SQL usage 531 */ 532 public function build_insert_sql_array($cp_data) 533 { 534 $prefix = 'pf_'; 535 $length = strlen($prefix); 536 $not_in = []; 537 538 foreach ($cp_data as $key => $null) 539 { 540 $not_in[] = strncmp($key, $prefix, $length) === 0 ? substr($key, $length) : $key; 541 } 542 543 $sql = 'SELECT f.field_type, f.field_ident, f.field_default_value, l.lang_default_value 544 FROM ' . $this->fields_lang_table . ' l, 545 ' . $this->fields_table . ' f 546 WHERE l.field_id = f.field_id 547 AND l.lang_id = ' . $this->user->get_iso_lang_id() . 548 (!empty($not_in) ? ' AND ' . $this->db->sql_in_set('f.field_ident', $not_in, true) : ''); 549 $result = $this->db->sql_query($sql); 550 while ($row = $this->db->sql_fetchrow($result)) 551 { 552 /** @var \phpbb\profilefields\type\type_interface $profile_field */ 553 $profile_field = $this->type_collection[$row['field_type']]; 554 $cp_data[$prefix . $row['field_ident']] = $profile_field->get_default_field_value($row); 555 } 556 $this->db->sql_freeresult($result); 557 558 return $cp_data; 559 } 560 561 /** 562 * Disable all profile fields of a certain type. 563 * 564 * This should be called when an extension which has profile field types is disabled 565 * so that all those profile fields are hidden and do not cause errors. 566 * 567 * @param string $type_name Type identifier of the profile fields 568 */ 569 public function disable_profilefields($type_name) 570 { 571 // Get the list of active profile fields of this type 572 $profile_fields = $this->list_profilefields($type_name, true); 573 574 // If no profile fields affected, then nothing to do 575 if (empty($profile_fields)) 576 { 577 return; 578 } 579 580 // Update the affected profile fields to "inactive" 581 $sql = 'UPDATE ' . $this->fields_table . ' 582 SET field_active = 0 583 WHERE field_active = 1 584 AND ' . $this->db->sql_in_set('field_id', array_keys($profile_fields)); 585 $this->db->sql_query($sql); 586 587 // Save modified information into a config_text field to recover on enable 588 $this->config_text->set($type_name . '.saved', json_encode($profile_fields)); 589 590 // Log activity 591 foreach ($profile_fields as $field_ident) 592 { 593 $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_PROFILE_FIELD_DEACTIVATE', time(), [$field_ident]); 594 } 595 } 596 597 /** 598 * Purge all profile fields of a certain type. 599 * 600 * This should be called when an extension which has profile field types is purged 601 * so that all those profile fields are removed. 602 * 603 * @param string $type_name Type identifier of the profile fields 604 */ 605 public function purge_profilefields($type_name) 606 { 607 // Remove the information saved on disable in a config_text field, not needed any longer 608 $this->config_text->delete($type_name . '.saved'); 609 610 // Get the list of all profile fields of this type 611 $profile_fields = $this->list_profilefields($type_name); 612 613 // If no profile fields exist, then nothing to do 614 if (empty($profile_fields)) 615 { 616 return; 617 } 618 619 $this->db->sql_transaction('begin'); 620 621 // Delete entries from all profile field definition tables 622 $where = $this->db->sql_in_set('field_id', array_keys($profile_fields)); 623 $this->db->sql_query('DELETE FROM ' . $this->fields_table . ' WHERE ' . $where); 624 $this->db->sql_query('DELETE FROM ' . $this->fields_data_lang_table . ' WHERE ' . $where); 625 $this->db->sql_query('DELETE FROM ' . $this->fields_lang_table . ' WHERE ' . $where); 626 627 // Drop columns from the Profile Fields data table 628 foreach ($profile_fields as $field_ident) 629 { 630 $this->db_tools->sql_column_remove($this->fields_data_table, 'pf_' . $field_ident); 631 } 632 633 // Reset the order of the remaining fields 634 $order = 0; 635 636 $sql = 'SELECT * 637 FROM ' . $this->fields_table . ' 638 ORDER BY field_order'; 639 $result = $this->db->sql_query($sql); 640 while ($row = $this->db->sql_fetchrow($result)) 641 { 642 $order++; 643 644 if ($row['field_order'] != $order) 645 { 646 $sql = 'UPDATE ' . $this->fields_table . " 647 SET field_order = $order 648 WHERE field_id = {$row['field_id']}"; 649 $this->db->sql_query($sql); 650 } 651 } 652 $this->db->sql_freeresult($result); 653 654 $this->db->sql_transaction('commit'); 655 656 // Log activity 657 foreach ($profile_fields as $field_ident) 658 { 659 $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_PROFILE_FIELD_REMOVED', time(), [$field_ident]); 660 } 661 } 662 663 /** 664 * Enable the profile fields of a certain type. 665 * 666 * This should be called when an extension which has profile field types that was disabled is re-enabled 667 * so that all those profile fields that were disabled are enabled again. 668 * 669 * @param string $type_name Type identifier of the profile fields 670 */ 671 public function enable_profilefields($type_name) 672 { 673 // Read the modified information saved on disable from a config_text field to recover values 674 $profile_fields = $this->config_text->get($type_name . '.saved'); 675 676 // If nothing saved, then nothing to do 677 if (empty($profile_fields)) 678 { 679 return; 680 } 681 682 $profile_fields = (array) json_decode($profile_fields, true); 683 684 // Restore the affected profile fields to "active" 685 $sql = 'UPDATE ' . $this->fields_table . ' 686 SET field_active = 1 687 WHERE field_active = 0 688 AND ' . $this->db->sql_in_set('field_id', array_keys($profile_fields)); 689 $this->db->sql_query($sql); 690 691 // Remove the information saved in the config_text field, not needed any longer 692 $this->config_text->delete($type_name . '.saved'); 693 694 // Log activity 695 foreach ($profile_fields as $field_ident) 696 { 697 $this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_PROFILE_FIELD_ACTIVATE', time(), [$field_ident]); 698 } 699 } 700 701 /** 702 * Get list of profile fields of a certain type, if any 703 * 704 * @param string $type_name Type identifier of the profile fields 705 * @param bool $active True to limit output to active profile fields, false for all 706 * @return array Array with profile field ids as keys and idents as values 707 */ 708 private function list_profilefields($type_name, $active = false) 709 { 710 // Get list of profile fields affected by this operation, if any 711 $sql = 'SELECT field_id, field_ident 712 FROM ' . $this->fields_table . " 713 WHERE field_type = '" . $this->db->sql_escape($type_name) . "'" . 714 ($active ? ' AND field_active = 1' : ''); 715 $result = $this->db->sql_query($sql); 716 $rowset = $this->db->sql_fetchrowset($result); 717 $this->db->sql_freeresult($result); 718 719 return array_column($rowset, 'field_ident', 'field_id'); 720 } 721 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |