Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

acp_profile.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 35.03 KiB


0001  <?php
0002  /**
0003  *
0004  * This file is part of the phpBB Forum Software package.
0005  *
0006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
0007  * @license GNU General Public License, version 2 (GPL-2.0)
0008  *
0009  * For full copyright and license information, please see
0010  * the docs/CREDITS.txt file.
0011  *
0012  */
0013   
0014  /**
0015  * @ignore
0016  */
0017  if (!defined('IN_PHPBB'))
0018  {
0019      exit;
0020  }
0021   
0022  class acp_profile
0023  {
0024      var $u_action;
0025   
0026      var $edit_lang_id;
0027      var $lang_defs;
0028      protected $type_collection;
0029   
0030      function main($id, $mode)
0031      {
0032          global $config, $db, $user, $auth, $template, $cache;
0033          global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
0034          global $request, $phpbb_container;
0035   
0036          include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
0037          include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
0038   
0039          $user->add_lang(array('ucp', 'acp/profile'));
0040          $this->tpl_name = 'acp_profile';
0041          $this->page_title = 'ACP_CUSTOM_PROFILE_FIELDS';
0042   
0043          $field_id = $request->variable('field_id', 0);
0044          $action = (isset($_POST['create'])) ? 'create' : request_var('action', '');
0045   
0046          $error = array();
0047          $s_hidden_fields = '';
0048   
0049          if (!$field_id && in_array($action, array('delete','activate', 'deactivate', 'move_up', 'move_down', 'edit')))
0050          {
0051              trigger_error($user->lang['NO_FIELD_ID'] . adm_back_link($this->u_action), E_USER_WARNING);
0052          }
0053   
0054          $cp = $phpbb_container->get('profilefields.manager');
0055          $this->type_collection = $phpbb_container->get('profilefields.type_collection');
0056   
0057          // Build Language array
0058          // Based on this, we decide which elements need to be edited later and which language items are missing
0059          $this->lang_defs = array();
0060   
0061          $sql = 'SELECT lang_id, lang_iso
0062              FROM ' . LANG_TABLE . '
0063              ORDER BY lang_english_name';
0064          $result = $db->sql_query($sql);
0065   
0066          while ($row = $db->sql_fetchrow($result))
0067          {
0068              // Make some arrays with all available languages
0069              $this->lang_defs['id'][$row['lang_id']] = $row['lang_iso'];
0070              $this->lang_defs['iso'][$row['lang_iso']] = $row['lang_id'];
0071          }
0072          $db->sql_freeresult($result);
0073   
0074          $sql = 'SELECT field_id, lang_id
0075              FROM ' . PROFILE_LANG_TABLE . '
0076              ORDER BY lang_id';
0077          $result = $db->sql_query($sql);
0078   
0079          while ($row = $db->sql_fetchrow($result))
0080          {
0081              // Which languages are available for each item
0082              $this->lang_defs['entry'][$row['field_id']][] = $row['lang_id'];
0083          }
0084          $db->sql_freeresult($result);
0085   
0086          // Have some fields been defined?
0087          if (isset($this->lang_defs['entry']))
0088          {
0089              foreach ($this->lang_defs['entry'] as $field_ident => $field_ary)
0090              {
0091                  // Fill an array with the languages that are missing for each field
0092                  $this->lang_defs['diff'][$field_ident] = array_diff(array_values($this->lang_defs['iso']), $field_ary);
0093              }
0094          }
0095   
0096          switch ($action)
0097          {
0098              case 'delete':
0099   
0100                  if (confirm_box(true))
0101                  {
0102                      $sql = 'SELECT field_ident
0103                          FROM ' . PROFILE_FIELDS_TABLE . "
0104                          WHERE field_id = $field_id";
0105                      $result = $db->sql_query($sql);
0106                      $field_ident = (string) $db->sql_fetchfield('field_ident');
0107                      $db->sql_freeresult($result);
0108   
0109                      $db->sql_transaction('begin');
0110   
0111                      $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_TABLE . " WHERE field_id = $field_id");
0112                      $db->sql_query('DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . " WHERE field_id = $field_id");
0113                      $db->sql_query('DELETE FROM ' . PROFILE_LANG_TABLE . " WHERE field_id = $field_id");
0114   
0115                      $db_tools = $phpbb_container->get('dbal.tools');
0116                      $db_tools->sql_column_remove(PROFILE_FIELDS_DATA_TABLE, 'pf_' . $field_ident);
0117   
0118                      $order = 0;
0119   
0120                      $sql = 'SELECT *
0121                          FROM ' . PROFILE_FIELDS_TABLE . '
0122                          ORDER BY field_order';
0123                      $result = $db->sql_query($sql);
0124   
0125                      while ($row = $db->sql_fetchrow($result))
0126                      {
0127                          $order++;
0128                          if ($row['field_order'] != $order)
0129                          {
0130                              $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
0131                                  SET field_order = $order
0132                                  WHERE field_id = {$row['field_id']}";
0133                              $db->sql_query($sql);
0134                          }
0135                      }
0136                      $db->sql_freeresult($result);
0137   
0138                      $db->sql_transaction('commit');
0139   
0140                      add_log('admin', 'LOG_PROFILE_FIELD_REMOVED', $field_ident);
0141                      trigger_error($user->lang['REMOVED_PROFILE_FIELD'] . adm_back_link($this->u_action));
0142                  }
0143                  else
0144                  {
0145                      confirm_box(false, 'DELETE_PROFILE_FIELD', build_hidden_fields(array(
0146                          'i'            => $id,
0147                          'mode'        => $mode,
0148                          'action'    => $action,
0149                          'field_id'    => $field_id,
0150                      )));
0151                  }
0152   
0153              break;
0154   
0155              case 'activate':
0156   
0157                  $sql = 'SELECT lang_id
0158                      FROM ' . LANG_TABLE . "
0159                      WHERE lang_iso = '" . $db->sql_escape($config['default_lang']) . "'";
0160                  $result = $db->sql_query($sql);
0161                  $default_lang_id = (int) $db->sql_fetchfield('lang_id');
0162                  $db->sql_freeresult($result);
0163   
0164                  if (!in_array($default_lang_id, $this->lang_defs['entry'][$field_id]))
0165                  {
0166                      trigger_error($user->lang['DEFAULT_LANGUAGE_NOT_FILLED'] . adm_back_link($this->u_action), E_USER_WARNING);
0167                  }
0168   
0169                  $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
0170                      SET field_active = 1
0171                      WHERE field_id = $field_id";
0172                  $db->sql_query($sql);
0173   
0174                  $sql = 'SELECT field_ident
0175                      FROM ' . PROFILE_FIELDS_TABLE . "
0176                      WHERE field_id = $field_id";
0177                  $result = $db->sql_query($sql);
0178                  $field_ident = (string) $db->sql_fetchfield('field_ident');
0179                  $db->sql_freeresult($result);
0180   
0181                  add_log('admin', 'LOG_PROFILE_FIELD_ACTIVATE', $field_ident);
0182   
0183                  if ($request->is_ajax())
0184                  {
0185                      $json_response = new \phpbb\json_response();
0186                      $json_response->send(array(
0187                          'text'    => $user->lang('DEACTIVATE'),
0188                      ));
0189                  }
0190   
0191                  trigger_error($user->lang['PROFILE_FIELD_ACTIVATED'] . adm_back_link($this->u_action));
0192   
0193              break;
0194   
0195              case 'deactivate':
0196   
0197                  $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
0198                      SET field_active = 0
0199                      WHERE field_id = $field_id";
0200                  $db->sql_query($sql);
0201   
0202                  $sql = 'SELECT field_ident
0203                      FROM ' . PROFILE_FIELDS_TABLE . "
0204                      WHERE field_id = $field_id";
0205                  $result = $db->sql_query($sql);
0206                  $field_ident = (string) $db->sql_fetchfield('field_ident');
0207                  $db->sql_freeresult($result);
0208   
0209                  if ($request->is_ajax())
0210                  {
0211                      $json_response = new \phpbb\json_response();
0212                      $json_response->send(array(
0213                          'text'    => $user->lang('ACTIVATE'),
0214                      ));
0215                  }
0216   
0217                  add_log('admin', 'LOG_PROFILE_FIELD_DEACTIVATE', $field_ident);
0218   
0219                  trigger_error($user->lang['PROFILE_FIELD_DEACTIVATED'] . adm_back_link($this->u_action));
0220   
0221              break;
0222   
0223              case 'move_up':
0224              case 'move_down':
0225   
0226                  $sql = 'SELECT field_order
0227                      FROM ' . PROFILE_FIELDS_TABLE . "
0228                      WHERE field_id = $field_id";
0229                  $result = $db->sql_query($sql);
0230                  $field_order = $db->sql_fetchfield('field_order');
0231                  $db->sql_freeresult($result);
0232   
0233                  if ($field_order === false || ($field_order == 0 && $action == 'move_up'))
0234                  {
0235                      break;
0236                  }
0237                  $field_order = (int) $field_order;
0238                  $order_total = $field_order * 2 + (($action == 'move_up') ? -1 : 1);
0239   
0240                  $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . "
0241                      SET field_order = $order_total - field_order
0242                      WHERE field_order IN ($field_order" . (($action == 'move_up') ? $field_order - 1 : $field_order + 1) . ')';
0243                  $db->sql_query($sql);
0244   
0245                  if ($request->is_ajax())
0246                  {
0247                      $json_response = new \phpbb\json_response;
0248                      $json_response->send(array(
0249                          'success'    => (bool) $db->sql_affectedrows(),
0250                      ));
0251                  }
0252   
0253              break;
0254   
0255              case 'create':
0256              case 'edit':
0257   
0258                  $step = request_var('step', 1);
0259   
0260                  $submit = (isset($_REQUEST['next']) || isset($_REQUEST['prev'])) ? true : false;
0261                  $save = (isset($_REQUEST['save'])) ? true : false;
0262   
0263                  // The language id of default language
0264                  $this->edit_lang_id = $this->lang_defs['iso'][$config['default_lang']];
0265   
0266                  // We are editing... we need to grab basic things
0267                  if ($action == 'edit')
0268                  {
0269                      $sql = 'SELECT l.*, f.*
0270                          FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
0271                          WHERE l.lang_id = ' . $this->edit_lang_id . "
0272                              AND f.field_id = $field_id
0273                              AND l.field_id = f.field_id";
0274                      $result = $db->sql_query($sql);
0275                      $field_row = $db->sql_fetchrow($result);
0276                      $db->sql_freeresult($result);
0277   
0278                      if (!$field_row)
0279                      {
0280                          // Some admin changed the default language?
0281                          $sql = 'SELECT l.*, f.*
0282                              FROM ' . PROFILE_LANG_TABLE . ' l, ' . PROFILE_FIELDS_TABLE . ' f
0283                              WHERE l.lang_id <> ' . $this->edit_lang_id . "
0284                              AND f.field_id = $field_id
0285                              AND l.field_id = f.field_id";
0286                          $result = $db->sql_query($sql);
0287                          $field_row = $db->sql_fetchrow($result);
0288                          $db->sql_freeresult($result);
0289   
0290                          if (!$field_row)
0291                          {
0292                              trigger_error($user->lang['FIELD_NOT_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING);
0293                          }
0294   
0295                          $this->edit_lang_id = $field_row['lang_id'];
0296                      }
0297                      $field_type = $field_row['field_type'];
0298                      $profile_field = $this->type_collection[$field_type];
0299   
0300                      // Get language entries
0301                      $sql = 'SELECT *
0302                          FROM ' . PROFILE_FIELDS_LANG_TABLE . '
0303                          WHERE lang_id = ' . $this->edit_lang_id . "
0304                              AND field_id = $field_id
0305                          ORDER BY option_id ASC";
0306                      $result = $db->sql_query($sql);
0307   
0308                      $lang_options = array();
0309                      while ($row = $db->sql_fetchrow($result))
0310                      {
0311                          $lang_options[$row['option_id']] = $row['lang_value'];
0312                      }
0313                      $db->sql_freeresult($result);
0314   
0315                      $s_hidden_fields = '<input type="hidden" name="field_id" value="' . $field_id . '" />';
0316                  }
0317                  else
0318                  {
0319                      // We are adding a new field, define basic params
0320                      $lang_options = $field_row = array();
0321   
0322                      $field_type = request_var('field_type', '');
0323   
0324                      if (!isset($this->type_collection[$field_type]))
0325                      {
0326                          trigger_error($user->lang['NO_FIELD_TYPE'] . adm_back_link($this->u_action), E_USER_WARNING);
0327                      }
0328   
0329                      $profile_field = $this->type_collection[$field_type];
0330                      $field_row = array_merge($profile_field->get_default_option_values(), array(
0331                          'field_ident'        => str_replace(' ', '_', utf8_clean_string(request_var('field_ident', '', true))),
0332                          'field_required'    => 0,
0333                          'field_show_novalue'=> 0,
0334                          'field_hide'        => 0,
0335                          'field_show_profile'=> 0,
0336                          'field_no_view'        => 0,
0337                          'field_show_on_reg'    => 0,
0338                          'field_show_on_pm'    => 0,
0339                          'field_show_on_vt'    => 0,
0340                          'field_show_on_ml'    => 0,
0341                          'field_is_contact'    => 0,
0342                          'field_contact_desc'=> '',
0343                          'field_contact_url'    => '',
0344                          'lang_name'            => utf8_normalize_nfc(request_var('field_ident', '', true)),
0345                          'lang_explain'        => '',
0346                          'lang_default_value'=> '')
0347                      );
0348   
0349                      $s_hidden_fields = '<input type="hidden" name="field_type" value="' . $field_type . '" />';
0350                  }
0351   
0352                  // $exclude contains the data we gather in each step
0353                  $exclude = array(
0354                      1    => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_pm', 'field_show_on_vt', 'field_show_on_ml', 'field_required', 'field_show_novalue', 'field_hide', 'field_show_profile', 'field_no_view', 'field_is_contact', 'field_contact_desc', 'field_contact_url'),
0355                      2    => array('field_length', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value'),
0356                      3    => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options')
0357                  );
0358   
0359                  // Visibility Options...
0360                  $visibility_ary = array(
0361                      'field_required',
0362                      'field_show_novalue',
0363                      'field_show_on_reg',
0364                      'field_show_on_pm',
0365                      'field_show_on_vt',
0366                      'field_show_on_ml',
0367                      'field_show_profile',
0368                      'field_hide',
0369                      'field_is_contact',
0370                  );
0371   
0372                  $options = $profile_field->prepare_options_form($exclude, $visibility_ary);
0373   
0374                  $cp->vars['field_ident']        = ($action == 'create' && $step == 1) ? utf8_clean_string(request_var('field_ident', $field_row['field_ident'], true)) : request_var('field_ident', $field_row['field_ident']);
0375                  $cp->vars['lang_name']            = $request->variable('lang_name', $field_row['lang_name'], true);
0376                  $cp->vars['lang_explain']        = $request->variable('lang_explain', $field_row['lang_explain'], true);
0377                  $cp->vars['lang_default_value']    = $request->variable('lang_default_value', $field_row['lang_default_value'], true);
0378                  $cp->vars['field_contact_desc']    = $request->variable('field_contact_desc', $field_row['field_contact_desc'], true);
0379                  $cp->vars['field_contact_url']    = $request->variable('field_contact_url', $field_row['field_contact_url'], true);
0380   
0381                  foreach ($visibility_ary as $val)
0382                  {
0383                      $cp->vars[$val] = ($submit || $save) ? $request->variable($val, 0) : $field_row[$val];
0384                  }
0385   
0386                  $cp->vars['field_no_view'] = $request->variable('field_no_view', (int) $field_row['field_no_view']);
0387   
0388                  // If the user has submitted a form with options (i.e. dropdown field)
0389                  if ($options)
0390                  {
0391                      $exploded_options = (is_array($options)) ? $options : explode("\n", $options);
0392   
0393                      if (sizeof($exploded_options) == sizeof($lang_options) || $action == 'create')
0394                      {
0395                          // The number of options in the field is equal to the number of options already in the database
0396                          // Or we are creating a new dropdown list.
0397                          $cp->vars['lang_options'] = $exploded_options;
0398                      }
0399                      else if ($action == 'edit')
0400                      {
0401                          // Changing the number of options? (We remove and re-create the option fields)
0402                          $cp->vars['lang_options'] = $exploded_options;
0403                      }
0404                  }
0405                  else
0406                  {
0407                      $cp->vars['lang_options'] = $lang_options;
0408                  }
0409   
0410                  // step 2
0411                  foreach ($exclude[2] as $key)
0412                  {
0413                      $var = utf8_normalize_nfc(request_var($key, $field_row[$key], true));
0414   
0415                      $field_data = $cp->vars;
0416                      $var = $profile_field->get_excluded_options($key, $action, $var, $field_data, 2);
0417                      $cp->vars = $field_data;
0418   
0419                      $cp->vars[$key] = $var;
0420                  }
0421   
0422                  // step 3 - all arrays
0423                  if ($action == 'edit')
0424                  {
0425                      // Get language entries
0426                      $sql = 'SELECT *
0427                          FROM ' . PROFILE_FIELDS_LANG_TABLE . '
0428                          WHERE lang_id <> ' . $this->edit_lang_id . "
0429                              AND field_id = $field_id
0430                          ORDER BY option_id ASC";
0431                      $result = $db->sql_query($sql);
0432   
0433                      $l_lang_options = array();
0434                      while ($row = $db->sql_fetchrow($result))
0435                      {
0436                          $l_lang_options[$row['lang_id']][$row['option_id']] = $row['lang_value'];
0437                      }
0438                      $db->sql_freeresult($result);
0439   
0440                      $sql = 'SELECT lang_id, lang_name, lang_explain, lang_default_value
0441                          FROM ' . PROFILE_LANG_TABLE . '
0442                          WHERE lang_id <> ' . $this->edit_lang_id . "
0443                              AND field_id = $field_id
0444                          ORDER BY lang_id ASC";
0445                      $result = $db->sql_query($sql);
0446   
0447                      $l_lang_name = $l_lang_explain = $l_lang_default_value = array();
0448                      while ($row = $db->sql_fetchrow($result))
0449                      {
0450                          $l_lang_name[$row['lang_id']] = $row['lang_name'];
0451                          $l_lang_explain[$row['lang_id']] = $row['lang_explain'];
0452                          $l_lang_default_value[$row['lang_id']] = $row['lang_default_value'];
0453                      }
0454                      $db->sql_freeresult($result);
0455                  }
0456   
0457                  foreach ($exclude[3] as $key)
0458                  {
0459                      $cp->vars[$key] = utf8_normalize_nfc(request_var($key, array(0 => ''), true));
0460   
0461                      if (!$cp->vars[$key] && $action == 'edit')
0462                      {
0463                          $cp->vars[$key] = $$key;
0464                      }
0465   
0466                      $field_data = $cp->vars;
0467                      $var = $profile_field->get_excluded_options($key, $action, $var, $field_data, 3);
0468                      $cp->vars = $field_data;
0469                  }
0470   
0471                  // Check for general issues in every step
0472                  if ($submit) //  && $step == 1
0473                  {
0474                      // Check values for step 1
0475                      if ($cp->vars['field_ident'] == '')
0476                      {
0477                          $error[] = $user->lang['EMPTY_FIELD_IDENT'];
0478                      }
0479   
0480                      if (!preg_match('/^[a-z_]+$/', $cp->vars['field_ident']))
0481                      {
0482                          $error[] = $user->lang['INVALID_CHARS_FIELD_IDENT'];
0483                      }
0484   
0485                      if (strlen($cp->vars['field_ident']) > 17)
0486                      {
0487                          $error[] = $user->lang['INVALID_FIELD_IDENT_LEN'];
0488                      }
0489   
0490                      if ($cp->vars['lang_name'] == '')
0491                      {
0492                          $error[] = $user->lang['EMPTY_USER_FIELD_NAME'];
0493                      }
0494   
0495                      $error = $profile_field->validate_options_on_submit($error, $cp->vars);
0496   
0497                      // Check for already existing field ident
0498                      if ($action != 'edit')
0499                      {
0500                          $sql = 'SELECT field_ident
0501                              FROM ' . PROFILE_FIELDS_TABLE . "
0502                              WHERE field_ident = '" . $db->sql_escape($cp->vars['field_ident']) . "'";
0503                          $result = $db->sql_query($sql);
0504                          $row = $db->sql_fetchrow($result);
0505                          $db->sql_freeresult($result);
0506   
0507                          if ($row)
0508                          {
0509                              $error[] = $user->lang['FIELD_IDENT_ALREADY_EXIST'];
0510                          }
0511                      }
0512                  }
0513   
0514                  $step = (isset($_REQUEST['next'])) ? $step + 1 : ((isset($_REQUEST['prev'])) ? $step - 1 : $step);
0515   
0516                  if (sizeof($error))
0517                  {
0518                      $step--;
0519                      $submit = false;
0520                  }
0521   
0522                  // Build up the specific hidden fields
0523                  foreach ($exclude as $num => $key_ary)
0524                  {
0525                      if ($num == $step)
0526                      {
0527                          continue;
0528                      }
0529   
0530                      $_new_key_ary = array();
0531   
0532                      $field_data = $cp->vars;
0533                      foreach ($key_ary as $key)
0534                      {
0535                          $var = $profile_field->prepare_hidden_fields($step, $key, $action, $field_data);
0536                          if ($var !== null)
0537                          {
0538                              $_new_key_ary[$key] = $profile_field->prepare_hidden_fields($step, $key, $action, $field_data);
0539                          }
0540                      }
0541                      $cp->vars = $field_data;
0542   
0543                      $s_hidden_fields .= build_hidden_fields($_new_key_ary);
0544                  }
0545   
0546                  if (!sizeof($error))
0547                  {
0548                      if ($step == 3 && (sizeof($this->lang_defs['iso']) == 1 || $save))
0549                      {
0550                          $this->save_profile_field($cp, $field_type, $action);
0551                      }
0552                      else if ($action == 'edit' && $save)
0553                      {
0554                          $this->save_profile_field($cp, $field_type, $action);
0555                      }
0556                  }
0557   
0558                  $template->assign_vars(array(
0559                      'S_EDIT'            => true,
0560                      'S_EDIT_MODE'        => ($action == 'edit') ? true : false,
0561                      'ERROR_MSG'            => (sizeof($error)) ? implode('<br />', $error) : '',
0562   
0563                      'L_TITLE'            => $user->lang['STEP_' . $step . '_TITLE_' . strtoupper($action)],
0564                      'L_EXPLAIN'            => $user->lang['STEP_' . $step . '_EXPLAIN_' . strtoupper($action)],
0565   
0566                      'U_ACTION'            => $this->u_action . "&amp;action=$action&amp;step=$step",
0567                      'U_BACK'            => $this->u_action)
0568                  );
0569   
0570                  // Now go through the steps
0571                  switch ($step)
0572                  {
0573                      // Create basic options - only small differences between field types
0574                      case 1:
0575                          $template_vars = array(
0576                              'S_STEP_ONE'        => true,
0577                              'S_FIELD_REQUIRED'    => ($cp->vars['field_required']) ? true : false,
0578                              'S_FIELD_SHOW_NOVALUE'=> ($cp->vars['field_show_novalue']) ? true : false,
0579                              'S_SHOW_ON_REG'        => ($cp->vars['field_show_on_reg']) ? true : false,
0580                              'S_SHOW_ON_PM'        => ($cp->vars['field_show_on_pm']) ? true : false,
0581                              'S_SHOW_ON_VT'        => ($cp->vars['field_show_on_vt']) ? true : false,
0582                              'S_SHOW_ON_MEMBERLIST'=> ($cp->vars['field_show_on_ml']) ? true : false,
0583                              'S_FIELD_HIDE'        => ($cp->vars['field_hide']) ? true : false,
0584                              'S_SHOW_PROFILE'    => ($cp->vars['field_show_profile']) ? true : false,
0585                              'S_FIELD_NO_VIEW'    => ($cp->vars['field_no_view']) ? true : false,
0586                              'S_FIELD_CONTACT'    => $cp->vars['field_is_contact'],
0587                              'FIELD_CONTACT_DESC'=> $cp->vars['field_contact_desc'],
0588                              'FIELD_CONTACT_URL'    => $cp->vars['field_contact_url'],
0589   
0590                              'L_LANG_SPECIFIC'    => sprintf($user->lang['LANG_SPECIFIC_OPTIONS'], $config['default_lang']),
0591                              'FIELD_TYPE'        => $profile_field->get_name(),
0592                              'FIELD_IDENT'        => $cp->vars['field_ident'],
0593                              'LANG_NAME'            => $cp->vars['lang_name'],
0594                              'LANG_EXPLAIN'        => $cp->vars['lang_explain'],
0595                          );
0596   
0597                          $field_data = $cp->vars;
0598                          $profile_field->display_options($template_vars, $field_data);
0599                          $cp->vars = $field_data;
0600   
0601                          // Build common create options
0602                          $template->assign_vars($template_vars);
0603                      break;
0604   
0605                      case 2:
0606   
0607                          $template->assign_vars(array(
0608                              'S_STEP_TWO'        => true,
0609                              'L_NEXT_STEP'            => (sizeof($this->lang_defs['iso']) == 1) ? $user->lang['SAVE'] : $user->lang['PROFILE_LANG_OPTIONS'])
0610                          );
0611   
0612                          // Build options based on profile type
0613                          $options = $profile_field->get_options($this->lang_defs['iso'][$config['default_lang']], $cp->vars);
0614   
0615                          foreach ($options as $num => $option_ary)
0616                          {
0617                              $template->assign_block_vars('option', $option_ary);
0618                          }
0619   
0620                      break;
0621   
0622                      // Define remaining language variables
0623                      case 3:
0624   
0625                          $template->assign_var('S_STEP_THREE', true);
0626                          $options = $this->build_language_options($cp, $field_type, $action);
0627   
0628                          foreach ($options as $lang_id => $lang_ary)
0629                          {
0630                              $template->assign_block_vars('options', array(
0631                                  'LANGUAGE'        => sprintf($user->lang[(($lang_id == $this->edit_lang_id) ? 'DEFAULT_' : '') . 'ISO_LANGUAGE'], $lang_ary['lang_iso']))
0632                              );
0633   
0634                              foreach ($lang_ary['fields'] as $field_ident => $field_ary)
0635                              {
0636                                  $template->assign_block_vars('options.field', array(
0637                                      'L_TITLE'        => $field_ary['TITLE'],
0638                                      'L_EXPLAIN'        => (isset($field_ary['EXPLAIN'])) ? $field_ary['EXPLAIN'] : '',
0639                                      'FIELD'            => $field_ary['FIELD'])
0640                                  );
0641                              }
0642                          }
0643   
0644                      break;
0645                  }
0646   
0647                  $template->assign_vars(array(
0648                      'S_HIDDEN_FIELDS'    => $s_hidden_fields)
0649                  );
0650   
0651                  return;
0652   
0653              break;
0654          }
0655   
0656          $sql = 'SELECT *
0657              FROM ' . PROFILE_FIELDS_TABLE . '
0658              ORDER BY field_order';
0659          $result = $db->sql_query($sql);
0660   
0661          $s_one_need_edit = false;
0662          while ($row = $db->sql_fetchrow($result))
0663          {
0664              $active_lang = (!$row['field_active']) ? 'ACTIVATE' : 'DEACTIVATE';
0665              $active_value = (!$row['field_active']) ? 'activate' : 'deactivate';
0666              $id = $row['field_id'];
0667   
0668              $s_need_edit = (sizeof($this->lang_defs['diff'][$row['field_id']])) ? true : false;
0669   
0670              if ($s_need_edit)
0671              {
0672                  $s_one_need_edit = true;
0673              }
0674   
0675              $profile_field = $this->type_collection[$row['field_type']];
0676              $template->assign_block_vars('fields', array(
0677                  'FIELD_IDENT'        => $row['field_ident'],
0678                  'FIELD_TYPE'        => $profile_field->get_name(),
0679   
0680                  'L_ACTIVATE_DEACTIVATE'        => $user->lang[$active_lang],
0681                  'U_ACTIVATE_DEACTIVATE'        => $this->u_action . "&amp;action=$active_value&amp;field_id=$id",
0682                  'U_EDIT'                    => $this->u_action . "&amp;action=edit&amp;field_id=$id",
0683                  'U_TRANSLATE'                => $this->u_action . "&amp;action=edit&amp;field_id=$id&amp;step=3",
0684                  'U_DELETE'                    => $this->u_action . "&amp;action=delete&amp;field_id=$id",
0685                  'U_MOVE_UP'                    => $this->u_action . "&amp;action=move_up&amp;field_id=$id",
0686                  'U_MOVE_DOWN'                => $this->u_action . "&amp;action=move_down&amp;field_id=$id",
0687   
0688                  'S_NEED_EDIT'                => $s_need_edit)
0689              );
0690          }
0691          $db->sql_freeresult($result);
0692   
0693          // At least one option field needs editing?
0694          if ($s_one_need_edit)
0695          {
0696              $template->assign_var('S_NEED_EDIT', true);
0697          }
0698   
0699          $s_select_type = '';
0700          foreach ($this->type_collection as $key => $profile_field)
0701          {
0702              $s_select_type .= '<option value="' . $key . '">' . $profile_field->get_name() . '</option>';
0703          }
0704   
0705          $template->assign_vars(array(
0706              'U_ACTION'            => $this->u_action,
0707              'S_TYPE_OPTIONS'    => $s_select_type,
0708          ));
0709      }
0710   
0711      /**
0712      * Build all Language specific options
0713      */
0714      function build_language_options(&$cp, $field_type, $action = 'create')
0715      {
0716          global $user, $config, $db, $phpbb_container;
0717   
0718          $default_lang_id = (!empty($this->edit_lang_id)) ? $this->edit_lang_id : $this->lang_defs['iso'][$config['default_lang']];
0719   
0720          $sql = 'SELECT lang_id, lang_iso
0721              FROM ' . LANG_TABLE . '
0722              WHERE lang_id <> ' . (int) $default_lang_id . '
0723              ORDER BY lang_english_name';
0724          $result = $db->sql_query($sql);
0725   
0726          $languages = array();
0727          while ($row = $db->sql_fetchrow($result))
0728          {
0729              $languages[$row['lang_id']] = $row['lang_iso'];
0730          }
0731          $db->sql_freeresult($result);
0732   
0733          $profile_field = $this->type_collection[$field_type];
0734          $options = $profile_field->get_language_options($cp->vars);
0735   
0736          $lang_options = array();
0737   
0738          foreach ($options as $field => $field_type)
0739          {
0740              $lang_options[1]['lang_iso'] = $this->lang_defs['id'][$default_lang_id];
0741              $lang_options[1]['fields'][$field] = array(
0742                  'TITLE'        => $user->lang['CP_' . strtoupper($field)],
0743                  'FIELD'        => '<dd>' . ((is_array($cp->vars[$field])) ? implode('<br />', $cp->vars[$field]) : bbcode_nl2br($cp->vars[$field])) . '</dd>'
0744              );
0745   
0746              if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN']))
0747              {
0748                  $lang_options[1]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN'];
0749              }
0750          }
0751   
0752          foreach ($languages as $lang_id => $lang_iso)
0753          {
0754              $lang_options[$lang_id]['lang_iso'] = $lang_iso;
0755              foreach ($options as $field => $field_type)
0756              {
0757                  $value = ($action == 'create') ? utf8_normalize_nfc(request_var('l_' . $field, array(0 => ''), true)) : $cp->vars['l_' . $field];
0758                  if ($field == 'lang_options')
0759                  {
0760                      $var = (!isset($cp->vars['l_lang_options'][$lang_id]) || !is_array($cp->vars['l_lang_options'][$lang_id])) ? $cp->vars['lang_options'] : $cp->vars['l_lang_options'][$lang_id];
0761   
0762                      switch ($field_type)
0763                      {
0764                          case 'two_options':
0765   
0766                              $lang_options[$lang_id]['fields'][$field] = array(
0767                                  'TITLE'        => $user->lang['CP_' . strtoupper($field)],
0768                                  'FIELD'        => '
0769                                              <dd><input class="medium" name="l_' . $field . '[' . $lang_id . '][]" value="' . ((isset($value[$lang_id][0])) ? $value[$lang_id][0] : $var[0]) . '" /> ' . $user->lang['FIRST_OPTION'] . '</dd>
0770                                              <dd><input class="medium" name="l_' . $field . '[' . $lang_id . '][]" value="' . ((isset($value[$lang_id][1])) ? $value[$lang_id][1] : $var[1]) . '" /> ' . $user->lang['SECOND_OPTION'] . '</dd>'
0771                              );
0772                          break;
0773   
0774                          case 'optionfield':
0775                              $value = ((isset($value[$lang_id])) ? ((is_array($value[$lang_id])) ?  implode("\n", $value[$lang_id]) : $value[$lang_id]) : implode("\n", $var));
0776                              $lang_options[$lang_id]['fields'][$field] = array(
0777                                  'TITLE'        => $user->lang['CP_' . strtoupper($field)],
0778                                  'FIELD'        => '<dd><textarea name="l_' . $field . '[' . $lang_id . ']" rows="7" cols="80">' . $value . '</textarea></dd>'
0779                              );
0780                          break;
0781                      }
0782   
0783                      if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN']))
0784                      {
0785                          $lang_options[$lang_id]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN'];
0786                      }
0787                  }
0788                  else
0789                  {
0790                      $var = ($action == 'create' || !is_array($cp->vars[$field])) ? $cp->vars[$field] : $cp->vars[$field][$lang_id];
0791   
0792                      $lang_options[$lang_id]['fields'][$field] = array(
0793                          'TITLE'        => $user->lang['CP_' . strtoupper($field)],
0794                          'FIELD'        => ($field_type == 'string') ? '<dd><input class="medium" type="text" name="l_' . $field . '[' . $lang_id . ']" value="' . ((isset($value[$lang_id])) ? $value[$lang_id] : $var) . '" /></dd>' : '<dd><textarea name="l_' . $field . '[' . $lang_id . ']" rows="3" cols="80">' . ((isset($value[$lang_id])) ? $value[$lang_id] : $var) . '</textarea></dd>'
0795                      );
0796   
0797                      if (isset($user->lang['CP_' . strtoupper($field) . '_EXPLAIN']))
0798                      {
0799                          $lang_options[$lang_id]['fields'][$field]['EXPLAIN'] = $user->lang['CP_' . strtoupper($field) . '_EXPLAIN'];
0800                      }
0801                  }
0802              }
0803          }
0804   
0805          return $lang_options;
0806      }
0807   
0808      /**
0809      * Save Profile Field
0810      */
0811      function save_profile_field(&$cp, $field_type, $action = 'create')
0812      {
0813          global $db, $config, $user, $phpbb_container;
0814   
0815          $field_id = request_var('field_id', 0);
0816   
0817          // Collect all information, if something is going wrong, abort the operation
0818          $profile_sql = $profile_lang = $empty_lang = $profile_lang_fields = array();
0819   
0820          $default_lang_id = (!empty($this->edit_lang_id)) ? $this->edit_lang_id : $this->lang_defs['iso'][$config['default_lang']];
0821   
0822          if ($action == 'create')
0823          {
0824              $sql = 'SELECT MAX(field_order) as max_field_order
0825                  FROM ' . PROFILE_FIELDS_TABLE;
0826              $result = $db->sql_query($sql);
0827              $new_field_order = (int) $db->sql_fetchfield('max_field_order');
0828              $db->sql_freeresult($result);
0829   
0830              $field_ident = $cp->vars['field_ident'];
0831          }
0832   
0833          // Save the field
0834          $profile_fields = array(
0835              'field_length'            => $cp->vars['field_length'],
0836              'field_minlen'            => $cp->vars['field_minlen'],
0837              'field_maxlen'            => $cp->vars['field_maxlen'],
0838              'field_novalue'            => $cp->vars['field_novalue'],
0839              'field_default_value'    => $cp->vars['field_default_value'],
0840              'field_validation'        => $cp->vars['field_validation'],
0841              'field_required'        => $cp->vars['field_required'],
0842              'field_show_novalue'    => $cp->vars['field_show_novalue'],
0843              'field_show_on_reg'        => $cp->vars['field_show_on_reg'],
0844              'field_show_on_pm'        => $cp->vars['field_show_on_pm'],
0845              'field_show_on_vt'        => $cp->vars['field_show_on_vt'],
0846              'field_show_on_ml'        => $cp->vars['field_show_on_ml'],
0847              'field_hide'            => $cp->vars['field_hide'],
0848              'field_show_profile'    => $cp->vars['field_show_profile'],
0849              'field_no_view'            => $cp->vars['field_no_view'],
0850              'field_is_contact'        => $cp->vars['field_is_contact'],
0851              'field_contact_desc'    => $cp->vars['field_contact_desc'],
0852              'field_contact_url'        => $cp->vars['field_contact_url'],
0853          );
0854   
0855          if ($action == 'create')
0856          {
0857              $profile_fields += array(
0858                  'field_type'        => $field_type,
0859                  'field_ident'        => $field_ident,
0860                  'field_name'        => $field_ident,
0861                  'field_order'        => $new_field_order + 1,
0862                  'field_active'        => 1
0863              );
0864   
0865              $sql = 'INSERT INTO ' . PROFILE_FIELDS_TABLE . ' ' . $db->sql_build_array('INSERT', $profile_fields);
0866              $db->sql_query($sql);
0867   
0868              $field_id = $db->sql_nextid();
0869          }
0870          else
0871          {
0872              $sql = 'UPDATE ' . PROFILE_FIELDS_TABLE . '
0873                  SET ' . $db->sql_build_array('UPDATE', $profile_fields) . "
0874                  WHERE field_id = $field_id";
0875              $db->sql_query($sql);
0876          }
0877   
0878          $profile_field = $this->type_collection[$field_type];
0879   
0880          if ($action == 'create')
0881          {
0882              $field_ident = 'pf_' . $field_ident;
0883   
0884              $db_tools = $phpbb_container->get('dbal.tools');
0885              $db_tools->sql_column_add(PROFILE_FIELDS_DATA_TABLE, $field_ident, array($profile_field->get_database_column_type(), null));
0886          }
0887   
0888          $sql_ary = array(
0889              'lang_name'                => $cp->vars['lang_name'],
0890              'lang_explain'            => $cp->vars['lang_explain'],
0891              'lang_default_value'    => $cp->vars['lang_default_value']
0892          );
0893   
0894          if ($action == 'create')
0895          {
0896              $sql_ary['field_id'] = $field_id;
0897              $sql_ary['lang_id'] = $default_lang_id;
0898   
0899              $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
0900          }
0901          else
0902          {
0903              $this->update_insert(PROFILE_LANG_TABLE, $sql_ary, array('field_id' => $field_id, 'lang_id' => $default_lang_id));
0904          }
0905   
0906          if (is_array($cp->vars['l_lang_name']) && sizeof($cp->vars['l_lang_name']))
0907          {
0908              foreach ($cp->vars['l_lang_name'] as $lang_id => $data)
0909              {
0910                  if (($cp->vars['lang_name'] != '' && $cp->vars['l_lang_name'][$lang_id] == '')
0911                      || ($cp->vars['lang_explain'] != '' && $cp->vars['l_lang_explain'][$lang_id] == '')
0912                      || ($cp->vars['lang_default_value'] != '' && $cp->vars['l_lang_default_value'][$lang_id] == ''))
0913                  {
0914                      $empty_lang[$lang_id] = true;
0915                      break;
0916                  }
0917   
0918                  if (!isset($empty_lang[$lang_id]))
0919                  {
0920                      $profile_lang[] = array(
0921                          'field_id'        => $field_id,
0922                          'lang_id'        => $lang_id,
0923                          'lang_name'        => $cp->vars['l_lang_name'][$lang_id],
0924                          'lang_explain'    => (isset($cp->vars['l_lang_explain'][$lang_id])) ? $cp->vars['l_lang_explain'][$lang_id] : '',
0925                          'lang_default_value'    => (isset($cp->vars['l_lang_default_value'][$lang_id])) ? $cp->vars['l_lang_default_value'][$lang_id] : ''
0926                      );
0927                  }
0928              }
0929   
0930              foreach ($empty_lang as $lang_id => $NULL)
0931              {
0932                  $sql = 'DELETE FROM ' . PROFILE_LANG_TABLE . "
0933                      WHERE field_id = $field_id
0934                      AND lang_id = " . (int) $lang_id;
0935                  $db->sql_query($sql);
0936              }
0937          }
0938   
0939          $cp->vars = $profile_field->get_language_options_input($cp->vars);
0940   
0941          if ($cp->vars['lang_options'])
0942          {
0943              if (!is_array($cp->vars['lang_options']))
0944              {
0945                  $cp->vars['lang_options'] = explode("\n", $cp->vars['lang_options']);
0946              }
0947   
0948              if ($action != 'create')
0949              {
0950                  $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . "
0951                      WHERE field_id = $field_id
0952                          AND lang_id = " . (int) $default_lang_id;
0953                  $db->sql_query($sql);
0954              }
0955   
0956              foreach ($cp->vars['lang_options'] as $option_id => $value)
0957              {
0958                  $sql_ary = array(
0959                      'field_type'    => $field_type,
0960                      'lang_value'    => $value
0961                  );
0962   
0963                  if ($action == 'create')
0964                  {
0965                      $sql_ary['field_id'] = $field_id;
0966                      $sql_ary['lang_id'] = $default_lang_id;
0967                      $sql_ary['option_id'] = (int) $option_id;
0968   
0969                      $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
0970                  }
0971                  else
0972                  {
0973                      $this->update_insert(PROFILE_FIELDS_LANG_TABLE, $sql_ary, array(
0974                          'field_id'    => $field_id,
0975                          'lang_id'    => (int) $default_lang_id,
0976                          'option_id'    => (int) $option_id)
0977                      );
0978                  }
0979              }
0980          }
0981   
0982          if (is_array($cp->vars['l_lang_options']) && sizeof($cp->vars['l_lang_options']))
0983          {
0984              $empty_lang = array();
0985   
0986              foreach ($cp->vars['l_lang_options'] as $lang_id => $lang_ary)
0987              {
0988                  if (!is_array($lang_ary))
0989                  {
0990                      $lang_ary = explode("\n", $lang_ary);
0991                  }
0992   
0993                  if (sizeof($lang_ary) != sizeof($cp->vars['lang_options']))
0994                  {
0995                      $empty_lang[$lang_id] = true;
0996                  }
0997   
0998                  if (!isset($empty_lang[$lang_id]))
0999                  {
1000                      if ($action != 'create')
1001                      {
1002                          $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . "
1003                              WHERE field_id = $field_id
1004                              AND lang_id = " . (int) $lang_id;
1005                          $db->sql_query($sql);
1006                      }
1007   
1008                      foreach ($lang_ary as $option_id => $value)
1009                      {
1010                          $profile_lang_fields[] = array(
1011                              'field_id'        => (int) $field_id,
1012                              'lang_id'        => (int) $lang_id,
1013                              'option_id'        => (int) $option_id,
1014                              'field_type'    => $field_type,
1015                              'lang_value'    => $value
1016                          );
1017                      }
1018                  }
1019              }
1020   
1021              foreach ($empty_lang as $lang_id => $NULL)
1022              {
1023                  $sql = 'DELETE FROM ' . PROFILE_FIELDS_LANG_TABLE . "
1024                      WHERE field_id = $field_id
1025                      AND lang_id = " . (int) $lang_id;
1026                  $db->sql_query($sql);
1027              }
1028          }
1029   
1030          foreach ($profile_lang as $sql)
1031          {
1032              if ($action == 'create')
1033              {
1034                  $profile_sql[] = 'INSERT INTO ' . PROFILE_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql);
1035              }
1036              else
1037              {
1038                  $lang_id = $sql['lang_id'];
1039                  unset($sql['lang_id'], $sql['field_id']);
1040   
1041                  $this->update_insert(PROFILE_LANG_TABLE, $sql, array('lang_id' => (int) $lang_id, 'field_id' => $field_id));
1042              }
1043          }
1044   
1045          if (sizeof($profile_lang_fields))
1046          {
1047              foreach ($profile_lang_fields as $sql)
1048              {
1049                  if ($action == 'create')
1050                  {
1051                      $profile_sql[] = 'INSERT INTO ' . PROFILE_FIELDS_LANG_TABLE . ' ' . $db->sql_build_array('INSERT', $sql);
1052                  }
1053                  else
1054                  {
1055                      $lang_id = $sql['lang_id'];
1056                      $option_id = $sql['option_id'];
1057                      unset($sql['lang_id'], $sql['field_id'], $sql['option_id']);
1058   
1059                      $this->update_insert(PROFILE_FIELDS_LANG_TABLE, $sql, array(
1060                          'lang_id'    => $lang_id,
1061                          'field_id'    => $field_id,
1062                          'option_id'    => $option_id)
1063                      );
1064                  }
1065              }
1066          }
1067   
1068          $db->sql_transaction('begin');
1069   
1070          if ($action == 'create')
1071          {
1072              foreach ($profile_sql as $sql)
1073              {
1074                  $db->sql_query($sql);
1075              }
1076          }
1077   
1078          $db->sql_transaction('commit');
1079   
1080          if ($action == 'edit')
1081          {
1082              add_log('admin', 'LOG_PROFILE_FIELD_EDIT', $cp->vars['field_ident'] . ':' . $cp->vars['lang_name']);
1083              trigger_error($user->lang['CHANGED_PROFILE_FIELD'] . adm_back_link($this->u_action));
1084          }
1085          else
1086          {
1087              add_log('admin', 'LOG_PROFILE_FIELD_CREATE', substr($field_ident, 3) . ':' . $cp->vars['lang_name']);
1088              trigger_error($user->lang['ADDED_PROFILE_FIELD'] . adm_back_link($this->u_action));
1089          }
1090      }
1091   
1092      /**
1093      * Update, then insert if not successfull
1094      */
1095      function update_insert($table, $sql_ary, $where_fields)
1096      {
1097          global $db;
1098   
1099          $where_sql = array();
1100          $check_key = '';
1101   
1102          foreach ($where_fields as $key => $value)
1103          {
1104              $check_key = (!$check_key) ? $key : $check_key;
1105              $where_sql[] = $key . ' = ' . ((is_string($value)) ? "'" . $db->sql_escape($value) . "'" : (int) $value);
1106          }
1107   
1108          if (!sizeof($where_sql))
1109          {
1110              return;
1111          }
1112   
1113          $sql = "SELECT $check_key
1114              FROM $table
1115              WHERE " . implode(' AND ', $where_sql);
1116          $result = $db->sql_query($sql);
1117          $row = $db->sql_fetchrow($result);
1118          $db->sql_freeresult($result);
1119   
1120          if (!$row)
1121          {
1122              $sql_ary = array_merge($where_fields, $sql_ary);
1123   
1124              if (sizeof($sql_ary))
1125              {
1126                  $db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql_ary));
1127              }
1128          }
1129          else
1130          {
1131              if (sizeof($sql_ary))
1132              {
1133                  $sql = "UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql_ary) . '
1134                      WHERE ' . implode(' AND ', $where_sql);
1135                  $db->sql_query($sql);
1136              }
1137          }
1138      }
1139  }
1140