[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/includes/acp/ -> acp_groups.php (source)

   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  /**
  15  * @ignore
  16  */
  17  if (!defined('IN_PHPBB'))
  18  {
  19      exit;
  20  }
  21  
  22  class acp_groups
  23  {
  24      var $u_action;
  25  
  26  	function main($id, $mode)
  27      {
  28          global $config, $db, $user, $auth, $template, $cache;
  29          global $phpbb_root_path, $phpbb_admin_path, $phpEx;
  30          global $request, $phpbb_container, $phpbb_dispatcher;
  31  
  32          /** @var \phpbb\language\language $language Language object */
  33          $language = $phpbb_container->get('language');
  34  
  35          $user->add_lang('acp/groups');
  36          $this->tpl_name = 'acp_groups';
  37          $this->page_title = 'ACP_GROUPS_MANAGE';
  38  
  39          $form_key = 'acp_groups';
  40          add_form_key($form_key);
  41  
  42          if ($mode == 'position')
  43          {
  44              $this->manage_position();
  45              return;
  46          }
  47  
  48          if (!function_exists('group_user_attributes'))
  49          {
  50              include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
  51          }
  52  
  53          // Check and set some common vars
  54          $action        = (isset($_POST['add'])) ? 'add' : ((isset($_POST['addusers'])) ? 'addusers' : $request->variable('action', ''));
  55          $group_id    = $request->variable('g', 0);
  56          $mark_ary    = $request->variable('mark', array(0));
  57          $name_ary    = $request->variable('usernames', '', true);
  58          $leader        = $request->variable('leader', 0);
  59          $default    = $request->variable('default', 0);
  60          $start        = $request->variable('start', 0);
  61          $update        = (isset($_POST['update'])) ? true : false;
  62  
  63          /** @var \phpbb\group\helper $group_helper */
  64          $group_helper = $phpbb_container->get('group_helper');
  65  
  66          // Clear some vars
  67          $group_row = array();
  68  
  69          // Grab basic data for group, if group_id is set and exists
  70          if ($group_id)
  71          {
  72              $sql = 'SELECT g.*, t.teampage_position AS group_teampage
  73                  FROM ' . GROUPS_TABLE . ' g
  74                  LEFT JOIN ' . TEAMPAGE_TABLE . ' t
  75                      ON (t.group_id = g.group_id)
  76                  WHERE g.group_id = ' . $group_id;
  77              $result = $db->sql_query($sql);
  78              $group_row = $db->sql_fetchrow($result);
  79              $db->sql_freeresult($result);
  80  
  81              if (!$group_row)
  82              {
  83                  trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
  84              }
  85  
  86              // Check if the user is allowed to manage this group if set to founder only.
  87              if ($user->data['user_type'] != USER_FOUNDER && $group_row['group_founder_manage'])
  88              {
  89                  trigger_error($user->lang['NOT_ALLOWED_MANAGE_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
  90              }
  91          }
  92  
  93          // Which page?
  94          switch ($action)
  95          {
  96              case 'approve':
  97              case 'demote':
  98              case 'promote':
  99                  if (!check_form_key($form_key))
 100                  {
 101                      trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
 102                  }
 103  
 104                  if (!$group_id)
 105                  {
 106                      trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
 107                  }
 108  
 109                  // Approve, demote or promote
 110                  $group_name = $group_helper->get_name($group_row['group_name']);
 111                  $error = group_user_attributes($action, $group_id, $mark_ary, false, $group_name);
 112  
 113                  if (!$error)
 114                  {
 115                      switch ($action)
 116                      {
 117                          case 'demote':
 118                              $message = 'GROUP_MODS_DEMOTED';
 119                          break;
 120  
 121                          case 'promote':
 122                              $message = 'GROUP_MODS_PROMOTED';
 123                          break;
 124  
 125                          case 'approve':
 126                              $message = 'USERS_APPROVED';
 127                          break;
 128                      }
 129  
 130                      trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
 131                  }
 132                  else
 133                  {
 134                      trigger_error($user->lang[$error] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
 135                  }
 136  
 137              break;
 138  
 139              case 'default':
 140                  if (!$group_id)
 141                  {
 142                      trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
 143                  }
 144                  else if (empty($mark_ary))
 145                  {
 146                      trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
 147                  }
 148  
 149                  if (confirm_box(true))
 150                  {
 151                      $group_name = $group_helper->get_name($group_row['group_name']);
 152                      group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
 153                      trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
 154                  }
 155                  else
 156                  {
 157                      confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
 158                          'mark'        => $mark_ary,
 159                          'g'            => $group_id,
 160                          'i'            => $id,
 161                          'mode'        => $mode,
 162                          'action'    => $action))
 163                      );
 164                  }
 165              break;
 166  
 167              case 'set_default_on_all':
 168                  if (confirm_box(true))
 169                  {
 170                      $group_name = $group_helper->get_name($group_row['group_name']);
 171  
 172                      $start = 0;
 173  
 174                      do
 175                      {
 176                          $sql = 'SELECT user_id
 177                              FROM ' . USER_GROUP_TABLE . "
 178                              WHERE group_id = $group_id
 179                              ORDER BY user_id";
 180                          $result = $db->sql_query_limit($sql, 200, $start);
 181  
 182                          $mark_ary = array();
 183                          if ($row = $db->sql_fetchrow($result))
 184                          {
 185                              do
 186                              {
 187                                  $mark_ary[] = $row['user_id'];
 188                              }
 189                              while ($row = $db->sql_fetchrow($result));
 190  
 191                              group_user_attributes('default', $group_id, $mark_ary, false, $group_name, $group_row);
 192  
 193                              $start = (count($mark_ary) < 200) ? 0 : $start + 200;
 194                          }
 195                          else
 196                          {
 197                              $start = 0;
 198                          }
 199                          $db->sql_freeresult($result);
 200                      }
 201                      while ($start);
 202  
 203                      trigger_error($user->lang['GROUP_DEFS_UPDATED'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
 204                  }
 205                  else
 206                  {
 207                      confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
 208                          'mark'        => $mark_ary,
 209                          'g'            => $group_id,
 210                          'i'            => $id,
 211                          'mode'        => $mode,
 212                          'action'    => $action))
 213                      );
 214                  }
 215              break;
 216  
 217              case 'deleteusers':
 218                  if (empty($mark_ary))
 219                  {
 220                      trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
 221                  }
 222              case 'delete':
 223                  if (!$group_id)
 224                  {
 225                      trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
 226                  }
 227                  else if ($action === 'delete' && $group_row['group_type'] == GROUP_SPECIAL)
 228                  {
 229                      send_status_line(403, 'Forbidden');
 230                      trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
 231                  }
 232  
 233                  if (confirm_box(true))
 234                  {
 235                      $error = '';
 236  
 237                      switch ($action)
 238                      {
 239                          case 'delete':
 240                              if (!$auth->acl_get('a_groupdel'))
 241                              {
 242                                  send_status_line(403, 'Forbidden');
 243                                  trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
 244                              }
 245  
 246                              $error = group_delete($group_id, $group_row['group_name']);
 247                          break;
 248  
 249                          case 'deleteusers':
 250                              $group_name = $group_helper->get_name($group_row['group_name']);
 251                              $error = group_user_del($group_id, $mark_ary, false, $group_name);
 252                          break;
 253                      }
 254  
 255                      $back_link = ($action == 'delete') ? $this->u_action : $this->u_action . '&amp;action=list&amp;g=' . $group_id;
 256  
 257                      if ($error)
 258                      {
 259                          trigger_error($user->lang[$error] . adm_back_link($back_link), E_USER_WARNING);
 260                      }
 261  
 262                      $message = ($action == 'delete') ? 'GROUP_DELETED' : 'GROUP_USERS_REMOVE';
 263                      trigger_error($user->lang[$message] . adm_back_link($back_link));
 264                  }
 265                  else
 266                  {
 267                      confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
 268                          'mark'        => $mark_ary,
 269                          'g'            => $group_id,
 270                          'i'            => $id,
 271                          'mode'        => $mode,
 272                          'action'    => $action))
 273                      );
 274                  }
 275              break;
 276  
 277              case 'addusers':
 278                  if (!check_form_key($form_key))
 279                  {
 280                      trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
 281                  }
 282  
 283                  if (!$group_id)
 284                  {
 285                      trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
 286                  }
 287  
 288                  if (!$name_ary)
 289                  {
 290                      trigger_error($user->lang['NO_USERS'] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
 291                  }
 292  
 293                  $name_ary = array_unique(explode("\n", $name_ary));
 294                  $group_name = $group_helper->get_name($group_row['group_name']);
 295  
 296                  // Add user/s to group
 297                  if ($error = group_user_add($group_id, false, $name_ary, $group_name, $default, $leader, 0, $group_row))
 298                  {
 299                      $display_message = $language->lang($error);
 300  
 301                      if ($error == 'GROUP_USERS_INVALID')
 302                      {
 303                          // Find which users don't exist
 304                          $actual_name_ary = $name_ary;
 305                          $actual_user_id_ary = [];
 306                          user_get_id_name($actual_user_id_ary, $actual_name_ary, false, true);
 307  
 308                          $display_message = $language->lang('GROUP_USERS_INVALID', implode($language->lang('COMMA_SEPARATOR'), array_udiff($name_ary, $actual_name_ary, 'strcasecmp')));
 309                      }
 310  
 311                      trigger_error($display_message . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id), E_USER_WARNING);
 312                  }
 313  
 314                  $message = ($leader) ? 'GROUP_MODS_ADDED' : 'GROUP_USERS_ADDED';
 315                  trigger_error($user->lang[$message] . adm_back_link($this->u_action . '&amp;action=list&amp;g=' . $group_id));
 316              break;
 317  
 318              case 'edit':
 319              case 'add':
 320  
 321                  if (!function_exists('display_forums'))
 322                  {
 323                      include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
 324                  }
 325  
 326                  if ($action == 'edit' && !$group_id)
 327                  {
 328                      trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
 329                  }
 330  
 331                  if ($action == 'add' && !$auth->acl_get('a_groupadd'))
 332                  {
 333                      send_status_line(403, 'Forbidden');
 334                      trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
 335                  }
 336  
 337                  $error = array();
 338                  $user->add_lang('ucp');
 339  
 340                  // Setup avatar data for later
 341                  $avatars_enabled = false;
 342                  $avatar_drivers = null;
 343                  $avatar_data = null;
 344                  $avatar_error = array();
 345  
 346                  /** @var \phpbb\avatar\manager $phpbb_avatar_manager */
 347                  $phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
 348  
 349                  if ($config['allow_avatar'])
 350                  {
 351                      $avatar_drivers = $phpbb_avatar_manager->get_enabled_drivers();
 352  
 353                      // This is normalised data, without the group_ prefix
 354                      $avatar_data = \phpbb\avatar\manager::clean_row($group_row, 'group');
 355                      if (!isset($avatar_data['id']))
 356                      {
 357                          $avatar_data['id'] = 'g' . $group_id;
 358                      }
 359                  }
 360  
 361                  if ($request->is_set_post('avatar_delete'))
 362                  {
 363                      if (confirm_box(true))
 364                      {
 365                          $avatar_data['id'] = substr($avatar_data['id'], 1);
 366                          $phpbb_avatar_manager->handle_avatar_delete($db, $user, $avatar_data, GROUPS_TABLE, 'group_');
 367  
 368                          $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
 369                          trigger_error($user->lang[$message] . adm_back_link($this->u_action));
 370                      }
 371                      else
 372                      {
 373                          confirm_box(false, $user->lang('CONFIRM_AVATAR_DELETE'), build_hidden_fields(array(
 374                                  'avatar_delete'     => true,
 375                                  'i'                 => $id,
 376                                  'mode'              => $mode,
 377                                  'g'                    => $group_id,
 378                                  'action'            => $action))
 379                          );
 380                      }
 381                  }
 382  
 383                  // Did we submit?
 384                  if ($update)
 385                  {
 386                      if (!check_form_key($form_key))
 387                      {
 388                          trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
 389                      }
 390  
 391                      $group_name    = $request->variable('group_name', '', true);
 392                      $group_desc = $request->variable('group_desc', '', true);
 393                      $group_type    = $request->variable('group_type', GROUP_FREE);
 394  
 395                      $allow_desc_bbcode    = $request->variable('desc_parse_bbcode', false);
 396                      $allow_desc_urls    = $request->variable('desc_parse_urls', false);
 397                      $allow_desc_smilies    = $request->variable('desc_parse_smilies', false);
 398  
 399                      $submit_ary = array(
 400                          'colour'            => $request->variable('group_colour', ''),
 401                          'rank'                => $request->variable('group_rank', 0),
 402                          'receive_pm'        => isset($_REQUEST['group_receive_pm']) ? 1 : 0,
 403                          'legend'            => isset($_REQUEST['group_legend']) ? 1 : 0,
 404                          'teampage'            => isset($_REQUEST['group_teampage']) ? 1 : 0,
 405                          'message_limit'        => $request->variable('group_message_limit', 0),
 406                          'max_recipients'    => $request->variable('group_max_recipients', 0),
 407                          'founder_manage'    => 0,
 408                          'skip_auth'            => $request->variable('group_skip_auth', 0),
 409                      );
 410  
 411                      if ($user->data['user_type'] == USER_FOUNDER)
 412                      {
 413                          $submit_ary['founder_manage'] = isset($_REQUEST['group_founder_manage']) ? 1 : 0;
 414                      }
 415  
 416                      if ($config['allow_avatar'])
 417                      {
 418                          // Handle avatar
 419                          $driver_name = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', ''));
 420  
 421                          if (in_array($driver_name, $avatar_drivers) && !$request->is_set_post('avatar_delete'))
 422                          {
 423                              $driver = $phpbb_avatar_manager->get_driver($driver_name);
 424                              $result = $driver->process_form($request, $template, $user, $avatar_data, $avatar_error);
 425  
 426                              if ($result && empty($avatar_error))
 427                              {
 428                                  $result['avatar_type'] = $driver_name;
 429                                  $submit_ary = array_merge($submit_ary, $result);
 430                              }
 431                          }
 432                          else
 433                          {
 434                              $driver = $phpbb_avatar_manager->get_driver($avatar_data['avatar_type']);
 435                              if ($driver)
 436                              {
 437                                  $driver->delete($avatar_data);
 438                              }
 439  
 440                              // Removing the avatar
 441                              $submit_ary['avatar_type'] = '';
 442                              $submit_ary['avatar'] = '';
 443                              $submit_ary['avatar_width'] = 0;
 444                              $submit_ary['avatar_height'] = 0;
 445                          }
 446  
 447                          // Merge any avatar errors into the primary error array
 448                          $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error));
 449                      }
 450  
 451                      /*
 452                      * Validate the length of "Maximum number of allowed recipients per
 453                      * private message" setting. We use 16777215 as a maximum because it matches
 454                      * MySQL unsigned mediumint maximum value which is the lowest amongst DBMSes
 455                      * supported by phpBB3. Also validate the submitted colour value.
 456                      */
 457                      $validation_checks = array(
 458                          'max_recipients' => array('num', false, 0, 16777215),
 459                          'colour'    => array('hex_colour', true),
 460                      );
 461  
 462                      /**
 463                      * Request group data and operate on it
 464                      *
 465                      * @event core.acp_manage_group_request_data
 466                      * @var    string    action                Type of the action: add|edit
 467                      * @var    int        group_id            The group id
 468                      * @var    array    group_row            Array with new group data
 469                      * @var    array    error                Array of errors, if you add errors
 470                      *                            ensure to update the template variables
 471                      *                            S_ERROR and ERROR_MSG to display it
 472                      * @var    string    group_name            The group name
 473                      * @var    string    group_desc            The group description
 474                      * @var    int        group_type            The group type
 475                      * @var    bool    allow_desc_bbcode    Allow bbcode in group description: true|false
 476                      * @var    bool    allow_desc_urls        Allow urls in group description: true|false
 477                      * @var    bool    allow_desc_smilies    Allow smiles in group description: true|false
 478                      * @var    array    submit_ary            Array with new group data
 479                      * @var    array    validation_checks    Array with validation data
 480                      * @since 3.1.0-b5
 481                      */
 482                      $vars = array(
 483                          'action',
 484                          'group_id',
 485                          'group_row',
 486                          'error',
 487                          'group_name',
 488                          'group_desc',
 489                          'group_type',
 490                          'allow_desc_bbcode',
 491                          'allow_desc_urls',
 492                          'allow_desc_smilies',
 493                          'submit_ary',
 494                          'validation_checks',
 495                      );
 496                      extract($phpbb_dispatcher->trigger_event('core.acp_manage_group_request_data', compact($vars)));
 497  
 498                      if ($validation_error = validate_data($submit_ary, $validation_checks))
 499                      {
 500                          // Replace "error" string with its real, localised form
 501                          $error = array_merge($error, $validation_error);
 502                      }
 503  
 504                      if (!count($error))
 505                      {
 506                          // Only set the rank, colour, etc. if it's changed or if we're adding a new
 507                          // group. This prevents existing group members being updated if no changes
 508                          // were made.
 509                          // However there are some attributes that need to be set everytime,
 510                          // otherwise the group gets removed from the feature.
 511                          $set_attributes = array('legend', 'teampage');
 512  
 513                          $group_attributes = array();
 514                          $test_variables = array(
 515                              'rank'            => 'int',
 516                              'colour'        => 'string',
 517                              'avatar'        => 'string',
 518                              'avatar_type'    => 'string',
 519                              'avatar_width'    => 'int',
 520                              'avatar_height'    => 'int',
 521                              'receive_pm'    => 'int',
 522                              'legend'        => 'int',
 523                              'teampage'        => 'int',
 524                              'message_limit'    => 'int',
 525                              'max_recipients'=> 'int',
 526                              'founder_manage'=> 'int',
 527                              'skip_auth'        => 'int',
 528                          );
 529  
 530                          /**
 531                          * Initialise data before we display the add/edit form
 532                          *
 533                          * @event core.acp_manage_group_initialise_data
 534                          * @var    string    action                Type of the action: add|edit
 535                          * @var    int        group_id            The group id
 536                          * @var    array    group_row            Array with new group data
 537                          * @var    array    error                Array of errors, if you add errors
 538                          *                            ensure to update the template variables
 539                          *                            S_ERROR and ERROR_MSG to display it
 540                          * @var    string    group_name            The group name
 541                          * @var    string    group_desc            The group description
 542                          * @var    int        group_type            The group type
 543                          * @var    bool    allow_desc_bbcode    Allow bbcode in group description: true|false
 544                          * @var    bool    allow_desc_urls        Allow urls in group description: true|false
 545                          * @var    bool    allow_desc_smilies    Allow smiles in group description: true|false
 546                          * @var    array    submit_ary            Array with new group data
 547                          * @var    array    test_variables        Array with variables for test
 548                          * @since 3.1.0-b5
 549                          */
 550                          $vars = array(
 551                              'action',
 552                              'group_id',
 553                              'group_row',
 554                              'error',
 555                              'group_name',
 556                              'group_desc',
 557                              'group_type',
 558                              'allow_desc_bbcode',
 559                              'allow_desc_urls',
 560                              'allow_desc_smilies',
 561                              'submit_ary',
 562                              'test_variables',
 563                          );
 564                          extract($phpbb_dispatcher->trigger_event('core.acp_manage_group_initialise_data', compact($vars)));
 565  
 566                          foreach ($test_variables as $test => $type)
 567                          {
 568                              if (isset($submit_ary[$test]) && ($action == 'add' || $group_row['group_' . $test] != $submit_ary[$test] || isset($group_attributes['group_avatar']) && strpos($test, 'avatar') === 0 || in_array($test, $set_attributes)))
 569                              {
 570                                  settype($submit_ary[$test], $type);
 571                                  $group_attributes['group_' . $test] = $group_row['group_' . $test] = $submit_ary[$test];
 572                              }
 573                          }
 574  
 575                          if (!($error = group_create($group_id, $group_type, $group_name, $group_desc, $group_attributes, $allow_desc_bbcode, $allow_desc_urls, $allow_desc_smilies)))
 576                          {
 577                              $group_perm_from = $request->variable('group_perm_from', 0);
 578  
 579                              // Copy permissions?
 580                              // If the user has the a_authgroups permission and at least one additional permission ability set the permissions are fully transferred.
 581                              // We do not limit on one auth category because this can lead to incomplete permissions being tricky to fix for the admin, roles being assigned or added non-default permissions.
 582                              // Since the user only has the option to copy permissions from non leader managed groups this seems to be a good compromise.
 583                              if ($group_perm_from && $action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth'))
 584                              {
 585                                  $sql = 'SELECT group_founder_manage
 586                                      FROM ' . GROUPS_TABLE . '
 587                                      WHERE group_id = ' . $group_perm_from;
 588                                  $result = $db->sql_query($sql);
 589                                  $check_row = $db->sql_fetchrow($result);
 590                                  $db->sql_freeresult($result);
 591  
 592                                  // Check the group if non-founder
 593                                  if ($check_row && ($user->data['user_type'] == USER_FOUNDER || $check_row['group_founder_manage'] == 0))
 594                                  {
 595                                      // From the mysql documentation:
 596                                      // Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
 597                                      // Due to this we stay on the safe side if we do the insertion "the manual way"
 598  
 599                                      // Copy permisisons from/to the acl groups table (only group_id gets changed)
 600                                      $sql = 'SELECT forum_id, auth_option_id, auth_role_id, auth_setting
 601                                          FROM ' . ACL_GROUPS_TABLE . '
 602                                          WHERE group_id = ' . $group_perm_from;
 603                                      $result = $db->sql_query($sql);
 604  
 605                                      $groups_sql_ary = array();
 606                                      while ($row = $db->sql_fetchrow($result))
 607                                      {
 608                                          $groups_sql_ary[] = array(
 609                                              'group_id'            => (int) $group_id,
 610                                              'forum_id'            => (int) $row['forum_id'],
 611                                              'auth_option_id'    => (int) $row['auth_option_id'],
 612                                              'auth_role_id'        => (int) $row['auth_role_id'],
 613                                              'auth_setting'        => (int) $row['auth_setting']
 614                                          );
 615                                      }
 616                                      $db->sql_freeresult($result);
 617  
 618                                      // Now insert the data
 619                                      $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
 620  
 621                                      $auth->acl_clear_prefetch();
 622                                  }
 623                              }
 624  
 625                              $cache->destroy('sql', array(GROUPS_TABLE, TEAMPAGE_TABLE));
 626  
 627                              $message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
 628                              trigger_error($user->lang[$message] . adm_back_link($this->u_action));
 629                          }
 630                      }
 631  
 632                      if (count($error))
 633                      {
 634                          $error = array_map(array(&$user, 'lang'), $error);
 635                          $group_rank = $submit_ary['rank'];
 636  
 637                          $group_desc_data = array(
 638                              'text'            => $group_desc,
 639                              'allow_bbcode'    => $allow_desc_bbcode,
 640                              'allow_smilies'    => $allow_desc_smilies,
 641                              'allow_urls'    => $allow_desc_urls
 642                          );
 643                      }
 644                  }
 645                  else if (!$group_id)
 646                  {
 647                      $group_name = $request->variable('group_name', '', true);
 648                      $group_desc_data = array(
 649                          'text'            => '',
 650                          'allow_bbcode'    => true,
 651                          'allow_smilies'    => true,
 652                          'allow_urls'    => true
 653                      );
 654                      $group_rank = 0;
 655                      $group_type = GROUP_OPEN;
 656                  }
 657                  else
 658                  {
 659                      $group_name = $group_row['group_name'];
 660                      $group_desc_data = generate_text_for_edit($group_row['group_desc'], $group_row['group_desc_uid'], $group_row['group_desc_options']);
 661                      $group_type = $group_row['group_type'];
 662                      $group_rank = $group_row['group_rank'];
 663                  }
 664  
 665                  $sql = 'SELECT *
 666                      FROM ' . RANKS_TABLE . '
 667                      WHERE rank_special = 1
 668                      ORDER BY rank_title';
 669                  $result = $db->sql_query($sql);
 670  
 671                  $rank_options = '<option value="0"' . ((!$group_rank) ? ' selected="selected"' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>';
 672  
 673                  while ($row = $db->sql_fetchrow($result))
 674                  {
 675                      $selected = ($group_rank && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
 676                      $rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
 677                  }
 678                  $db->sql_freeresult($result);
 679  
 680                  $type_free        = ($group_type == GROUP_FREE) ? ' checked="checked"' : '';
 681                  $type_open        = ($group_type == GROUP_OPEN) ? ' checked="checked"' : '';
 682                  $type_closed    = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : '';
 683                  $type_hidden    = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : '';
 684  
 685                  // Load up stuff for avatars
 686                  if ($config['allow_avatar'])
 687                  {
 688                      $avatars_enabled = false;
 689                      $selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type']));
 690  
 691                      // Assign min and max values before generating avatar driver html
 692                      $template->assign_vars(array(
 693                              'AVATAR_MIN_WIDTH'        => $config['avatar_min_width'],
 694                              'AVATAR_MAX_WIDTH'        => $config['avatar_max_width'],
 695                              'AVATAR_MIN_HEIGHT'        => $config['avatar_min_height'],
 696                              'AVATAR_MAX_HEIGHT'        => $config['avatar_max_height'],
 697                      ));
 698  
 699                      foreach ($avatar_drivers as $current_driver)
 700                      {
 701                          $driver = $phpbb_avatar_manager->get_driver($current_driver);
 702  
 703                          $avatars_enabled = true;
 704                          $template->set_filenames(array(
 705                              'avatar' => $driver->get_acp_template_name(),
 706                          ));
 707  
 708                          if ($driver->prepare_form($request, $template, $user, $avatar_data, $avatar_error))
 709                          {
 710                              $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver);
 711                              $driver_upper = strtoupper($driver_name);
 712                              $template->assign_block_vars('avatar_drivers', array(
 713                                  'L_TITLE' => $user->lang($driver_upper . '_TITLE'),
 714                                  'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'),
 715  
 716                                  'DRIVER' => $driver_name,
 717                                  'SELECTED' => $current_driver == $selected_driver,
 718                                  'OUTPUT' => $template->assign_display('avatar'),
 719                              ));
 720                          }
 721                      }
 722                  }
 723  
 724                  $avatar = phpbb_get_group_avatar($group_row, 'GROUP_AVATAR', true);
 725  
 726                  if (isset($phpbb_avatar_manager) && !$update)
 727                  {
 728                      // Merge any avatar errors into the primary error array
 729                      $error = array_merge($error, $phpbb_avatar_manager->localize_errors($user, $avatar_error));
 730                  }
 731  
 732                  $back_link = $request->variable('back_link', '');
 733  
 734                  switch ($back_link)
 735                  {
 736                      case 'acp_users_groups':
 737                          $u_back = append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&amp;mode=groups&amp;u=' . $request->variable('u', 0));
 738                      break;
 739  
 740                      default:
 741                          $u_back = $this->u_action;
 742                      break;
 743                  }
 744  
 745                  $template->assign_vars(array(
 746                      'S_EDIT'            => true,
 747                      'S_ADD_GROUP'        => ($action == 'add') ? true : false,
 748                      'S_GROUP_PERM'        => ($action == 'add' && $auth->acl_get('a_authgroups') && $auth->acl_gets('a_aauth', 'a_fauth', 'a_mauth', 'a_uauth')) ? true : false,
 749                      'S_INCLUDE_SWATCH'    => true,
 750                      'S_ERROR'            => (count($error)) ? true : false,
 751                      'S_SPECIAL_GROUP'    => ($group_type == GROUP_SPECIAL) ? true : false,
 752                      'S_USER_FOUNDER'    => ($user->data['user_type'] == USER_FOUNDER) ? true : false,
 753                      'S_AVATARS_ENABLED'        => ($config['allow_avatar'] && $avatars_enabled),
 754  
 755                      'ERROR_MSG'                => (count($error)) ? implode('<br />', $error) : '',
 756                      'GROUP_NAME'            => $group_helper->get_name($group_name),
 757                      'GROUP_INTERNAL_NAME'    => $group_name,
 758                      'GROUP_DESC'            => $group_desc_data['text'],
 759                      'GROUP_RECEIVE_PM'        => (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : '',
 760                      'GROUP_FOUNDER_MANAGE'    => (isset($group_row['group_founder_manage']) && $group_row['group_founder_manage']) ? ' checked="checked"' : '',
 761                      'GROUP_LEGEND'            => (isset($group_row['group_legend']) && $group_row['group_legend']) ? ' checked="checked"' : '',
 762                      'GROUP_TEAMPAGE'        => (isset($group_row['group_teampage']) && $group_row['group_teampage']) ? ' checked="checked"' : '',
 763                      'GROUP_MESSAGE_LIMIT'    => (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0,
 764                      'GROUP_MAX_RECIPIENTS'    => (isset($group_row['group_max_recipients'])) ? $group_row['group_max_recipients'] : 0,
 765                      'GROUP_COLOUR'            => (isset($group_row['group_colour'])) ? $group_row['group_colour'] : '',
 766                      'GROUP_SKIP_AUTH'        => (!empty($group_row['group_skip_auth'])) ? ' checked="checked"' : '',
 767  
 768                      'S_DESC_BBCODE_CHECKED'    => $group_desc_data['allow_bbcode'],
 769                      'S_DESC_URLS_CHECKED'    => $group_desc_data['allow_urls'],
 770                      'S_DESC_SMILIES_CHECKED'=> $group_desc_data['allow_smilies'],
 771  
 772                      'S_RANK_OPTIONS'        => $rank_options,
 773                      'S_GROUP_OPTIONS'        => group_select_options(false, false, (($user->data['user_type'] == USER_FOUNDER) ? false : 0)),
 774                      'AVATAR'                => empty($avatar) ? '<img src="' . $phpbb_admin_path . 'images/no_avatar.gif" alt="" />' : $avatar,
 775                      'AVATAR_MAX_FILESIZE'    => $config['avatar_filesize'],
 776                      'AVATAR_WIDTH'            => (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : '',
 777                      'AVATAR_HEIGHT'            => (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : '',
 778  
 779                      'GROUP_TYPE_FREE'        => GROUP_FREE,
 780                      'GROUP_TYPE_OPEN'        => GROUP_OPEN,
 781                      'GROUP_TYPE_CLOSED'        => GROUP_CLOSED,
 782                      'GROUP_TYPE_HIDDEN'        => GROUP_HIDDEN,
 783                      'GROUP_TYPE_SPECIAL'    => GROUP_SPECIAL,
 784  
 785                      'GROUP_FREE'        => $type_free,
 786                      'GROUP_OPEN'        => $type_open,
 787                      'GROUP_CLOSED'        => $type_closed,
 788                      'GROUP_HIDDEN'        => $type_hidden,
 789  
 790                      'U_BACK'            => $u_back,
 791                      'U_ACTION'            => "{$this->u_action}&amp;action=$action&amp;g=$group_id",
 792                      'L_AVATAR_EXPLAIN'    => phpbb_avatar_explanation_string(),
 793                  ));
 794  
 795                  /**
 796                  * Modify group template data before we display the form
 797                  *
 798                  * @event core.acp_manage_group_display_form
 799                  * @var    string    action                Type of the action: add|edit
 800                  * @var    bool    update                Do we display the form only
 801                  *                            or did the user press submit
 802                  * @var    int        group_id            The group id
 803                  * @var    array    group_row            Array with new group data
 804                  * @var    string    group_name            The group name
 805                  * @var    int        group_type            The group type
 806                  * @var    array    group_desc_data        The group description data
 807                  * @var    string    group_rank            The group rank
 808                  * @var    string    rank_options        The rank options
 809                  * @var    array    error                Array of errors, if you add errors
 810                  *                            ensure to update the template variables
 811                  *                            S_ERROR and ERROR_MSG to display it
 812                  * @since 3.1.0-b5
 813                  */
 814                  $vars = array(
 815                      'action',
 816                      'update',
 817                      'group_id',
 818                      'group_row',
 819                      'group_desc_data',
 820                      'group_name',
 821                      'group_type',
 822                      'group_rank',
 823                      'rank_options',
 824                      'error',
 825                  );
 826                  extract($phpbb_dispatcher->trigger_event('core.acp_manage_group_display_form', compact($vars)));
 827  
 828                  return;
 829              break;
 830  
 831              case 'list':
 832  
 833                  if (!$group_id)
 834                  {
 835                      trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action), E_USER_WARNING);
 836                  }
 837  
 838                  /* @var $pagination \phpbb\pagination */
 839                  $pagination = $phpbb_container->get('pagination');
 840                  $this->page_title = 'GROUP_MEMBERS';
 841  
 842                  // Grab the leaders - always, on every page...
 843                  $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_regdate, u.user_colour, u.user_posts, u.group_id, ug.group_leader, ug.user_pending
 844                      FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
 845                      WHERE ug.group_id = $group_id
 846                          AND u.user_id = ug.user_id
 847                          AND ug.group_leader = 1
 848                      ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
 849                  $result = $db->sql_query($sql);
 850  
 851                  while ($row = $db->sql_fetchrow($result))
 852                  {
 853                      $template->assign_block_vars('leader', array(
 854                          'U_USER_EDIT'        => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&amp;action=edit&amp;u={$row['user_id']}"),
 855  
 856                          'USERNAME'            => $row['username'],
 857                          'USERNAME_COLOUR'    => $row['user_colour'],
 858                          'S_GROUP_DEFAULT'    => ($row['group_id'] == $group_id) ? true : false,
 859                          'JOINED'            => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ',
 860                          'USER_POSTS'        => $row['user_posts'],
 861                          'USER_ID'            => $row['user_id'],
 862                      ));
 863                  }
 864                  $db->sql_freeresult($result);
 865  
 866                  // Total number of group members (non-leaders)
 867                  $sql = 'SELECT COUNT(user_id) AS total_members
 868                      FROM ' . USER_GROUP_TABLE . "
 869                      WHERE group_id = $group_id
 870                          AND group_leader = 0";
 871                  $result = $db->sql_query($sql);
 872                  $total_members = (int) $db->sql_fetchfield('total_members');
 873                  $db->sql_freeresult($result);
 874  
 875                  $s_action_options = '';
 876                  $options = array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'demote' => 'DEMOTE', 'promote' => 'PROMOTE', 'deleteusers' => 'DELETE');
 877  
 878                  foreach ($options as $option => $lang)
 879                  {
 880                      $s_action_options .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';
 881                  }
 882  
 883                  $base_url = $this->u_action . "&amp;action=$action&amp;g=$group_id";
 884                  $pagination->generate_template_pagination($base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start);
 885  
 886                  $template->assign_vars(array(
 887                      'S_LIST'            => true,
 888                      'S_GROUP_SPECIAL'    => ($group_row['group_type'] == GROUP_SPECIAL) ? true : false,
 889                      'S_ACTION_OPTIONS'    => $s_action_options,
 890  
 891                      'GROUP_NAME'    => $group_helper->get_name($group_row['group_name']),
 892  
 893                      'U_ACTION'            => $this->u_action . "&amp;g=$group_id",
 894                      'U_BACK'            => $this->u_action,
 895                      'U_FIND_USERNAME'    => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=list&amp;field=usernames'),
 896                      'U_DEFAULT_ALL'        => "{$this->u_action}&amp;action=set_default_on_all&amp;g=$group_id",
 897                  ));
 898  
 899                  // Grab the members
 900                  $sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending
 901                      FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
 902                      WHERE ug.group_id = $group_id
 903                          AND u.user_id = ug.user_id
 904                          AND ug.group_leader = 0
 905                      ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username_clean";
 906                  $result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
 907  
 908                  $pending = false;
 909  
 910                  while ($row = $db->sql_fetchrow($result))
 911                  {
 912                      if ($row['user_pending'] && !$pending)
 913                      {
 914                          $template->assign_block_vars('member', array(
 915                              'S_PENDING'        => true)
 916                          );
 917  
 918                          $pending = true;
 919                      }
 920  
 921                      $template->assign_block_vars('member', array(
 922                          'U_USER_EDIT'        => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&amp;action=edit&amp;u={$row['user_id']}"),
 923  
 924                          'USERNAME'            => $row['username'],
 925                          'USERNAME_COLOUR'    => $row['user_colour'],
 926                          'S_GROUP_DEFAULT'    => ($row['group_id'] == $group_id) ? true : false,
 927                          'JOINED'            => ($row['user_regdate']) ? $user->format_date($row['user_regdate']) : ' - ',
 928                          'USER_POSTS'        => $row['user_posts'],
 929                          'USER_ID'            => $row['user_id'])
 930                      );
 931                  }
 932                  $db->sql_freeresult($result);
 933  
 934                  return;
 935              break;
 936          }
 937  
 938          $template->assign_vars(array(
 939              'U_ACTION'        => $this->u_action,
 940              'S_GROUP_ADD'    => ($auth->acl_get('a_groupadd')) ? true : false)
 941          );
 942  
 943          // Get us all the groups
 944          $sql = 'SELECT g.group_id, g.group_name, g.group_type, g.group_colour
 945              FROM ' . GROUPS_TABLE . ' g
 946              ORDER BY g.group_type ASC, g.group_name';
 947          $result = $db->sql_query($sql);
 948  
 949          $lookup = $cached_group_data = array();
 950          while ($row = $db->sql_fetchrow($result))
 951          {
 952              $type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : 'normal';
 953  
 954              // used to determine what type a group is
 955              $lookup[$row['group_id']] = $type;
 956  
 957              // used for easy access to the data within a group
 958              $cached_group_data[$type][$row['group_id']] = $row;
 959              $cached_group_data[$type][$row['group_id']]['total_members'] = 0;
 960              $cached_group_data[$type][$row['group_id']]['pending_members'] = 0;
 961          }
 962          $db->sql_freeresult($result);
 963  
 964          // How many people are in which group?
 965          $sql = 'SELECT COUNT(ug.user_id) AS total_members, SUM(ug.user_pending) AS pending_members, ug.group_id
 966              FROM ' . USER_GROUP_TABLE . ' ug
 967              WHERE ' . $db->sql_in_set('ug.group_id', array_keys($lookup)) . '
 968              GROUP BY ug.group_id';
 969          $result = $db->sql_query($sql);
 970  
 971          while ($row = $db->sql_fetchrow($result))
 972          {
 973              $type = $lookup[$row['group_id']];
 974              $cached_group_data[$type][$row['group_id']]['total_members'] = $row['total_members'];
 975              $cached_group_data[$type][$row['group_id']]['pending_members'] = $row['pending_members'];
 976          }
 977          $db->sql_freeresult($result);
 978  
 979          // The order is... normal, then special
 980          ksort($cached_group_data);
 981  
 982          foreach ($cached_group_data as $type => $row_ary)
 983          {
 984              if ($type == 'special')
 985              {
 986                  $template->assign_block_vars('groups', array(
 987                      'S_SPECIAL'            => true)
 988                  );
 989              }
 990  
 991              foreach ($row_ary as $group_id => $row)
 992              {
 993                  $group_name = (!empty($user->lang['G_' . $row['group_name']]))? $user->lang['G_' . $row['group_name']] : $row['group_name'];
 994  
 995                  $template->assign_block_vars('groups', array(
 996                      'U_LIST'        => "{$this->u_action}&amp;action=list&amp;g=$group_id",
 997                      'U_EDIT'        => "{$this->u_action}&amp;action=edit&amp;g=$group_id",
 998                      'U_DELETE'        => ($auth->acl_get('a_groupdel')) ? "{$this->u_action}&amp;action=delete&amp;g=$group_id" : '',
 999  
1000                      'S_GROUP_SPECIAL'    => ($row['group_type'] == GROUP_SPECIAL) ? true : false,
1001  
1002                      'GROUP_NAME'    => $group_name,
1003                      'GROUP_COLOR'    => $row['group_colour'],
1004                      'TOTAL_MEMBERS'    => $row['total_members'],
1005                      'PENDING_MEMBERS' => $row['pending_members']
1006                  ));
1007              }
1008          }
1009      }
1010  
1011  	public function manage_position()
1012      {
1013          global $config, $db, $template, $user, $request, $phpbb_container;
1014  
1015          $this->tpl_name = 'acp_groups_position';
1016          $this->page_title = 'ACP_GROUPS_POSITION';
1017  
1018          $field = $request->variable('field', '');
1019          $action = $request->variable('action', '');
1020          $group_id = $request->variable('g', 0);
1021          $teampage_id = $request->variable('t', 0);
1022          $category_id = $request->variable('c', 0);
1023  
1024          /** @var \phpbb\group\helper $group_helper */
1025          $group_helper = $phpbb_container->get('group_helper');
1026  
1027          if ($field && !in_array($field, array('legend', 'teampage')))
1028          {
1029              // Invalid mode
1030              trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING);
1031          }
1032          else if ($field && in_array($field, array('legend', 'teampage')))
1033          {
1034              /* @var $group_position \phpbb\groupposition\groupposition_interface */
1035              $group_position = $phpbb_container->get('groupposition.' . $field);
1036          }
1037  
1038          if ($field == 'teampage')
1039          {
1040              try
1041              {
1042                  switch ($action)
1043                  {
1044                      case 'add':
1045                          $group_position->add_group_teampage($group_id, $category_id);
1046                      break;
1047  
1048                      case 'add_category':
1049                          $group_position->add_category_teampage($request->variable('category_name', '', true));
1050                      break;
1051  
1052                      case 'delete':
1053                          $group_position->delete_teampage($teampage_id);
1054                      break;
1055  
1056                      case 'move_up':
1057                          $group_position->move_up_teampage($teampage_id);
1058                      break;
1059  
1060                      case 'move_down':
1061                          $group_position->move_down_teampage($teampage_id);
1062                      break;
1063                  }
1064              }
1065              catch (\phpbb\groupposition\exception $exception)
1066              {
1067                  trigger_error($user->lang($exception->getMessage()) . adm_back_link($this->u_action), E_USER_WARNING);
1068              }
1069          }
1070          else if ($field == 'legend')
1071          {
1072              try
1073              {
1074                  switch ($action)
1075                  {
1076                      case 'add':
1077                          $group_position->add_group($group_id);
1078                      break;
1079  
1080                      case 'delete':
1081                          $group_position->delete_group($group_id);
1082                      break;
1083  
1084                      case 'move_up':
1085                          $group_position->move_up($group_id);
1086                      break;
1087  
1088                      case 'move_down':
1089                          $group_position->move_down($group_id);
1090                      break;
1091                  }
1092              }
1093              catch (\phpbb\groupposition\exception $exception)
1094              {
1095                  trigger_error($user->lang($exception->getMessage()) . adm_back_link($this->u_action), E_USER_WARNING);
1096              }
1097          }
1098          else
1099          {
1100              switch ($action)
1101              {
1102                  case 'set_config_teampage':
1103                      $config->set('teampage_forums', $request->variable('teampage_forums', 0));
1104                      $config->set('teampage_memberships', $request->variable('teampage_memberships', 0));
1105                      trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
1106                  break;
1107  
1108                  case 'set_config_legend':
1109                      $config->set('legend_sort_groupname', $request->variable('legend_sort_groupname', 0));
1110                      trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
1111                  break;
1112              }
1113          }
1114  
1115          if (($action == 'move_up' || $action == 'move_down') && $request->is_ajax())
1116          {
1117              $json_response = new \phpbb\json_response;
1118              $json_response->send(array('success' => true));
1119          }
1120  
1121          $sql = 'SELECT group_id, group_name, group_colour, group_type, group_legend
1122              FROM ' . GROUPS_TABLE . '
1123              ORDER BY group_legend ASC, group_type DESC, group_name ASC';
1124          $result = $db->sql_query($sql);
1125  
1126          while ($row = $db->sql_fetchrow($result))
1127          {
1128              $group_name = $group_helper->get_name($row['group_name']);
1129              if ($row['group_legend'])
1130              {
1131                  $template->assign_block_vars('legend', array(
1132                      'GROUP_NAME'    => $group_name,
1133                      'GROUP_COLOUR'    => ($row['group_colour']) ? '#' . $row['group_colour'] : '',
1134                      'GROUP_TYPE'    => $user->lang[\phpbb\groupposition\legend::group_type_language($row['group_type'])],
1135  
1136                      'U_MOVE_DOWN'    => "{$this->u_action}&amp;field=legend&amp;action=move_down&amp;g=" . $row['group_id'],
1137                      'U_MOVE_UP'        => "{$this->u_action}&amp;field=legend&amp;action=move_up&amp;g=" . $row['group_id'],
1138                      'U_DELETE'        => "{$this->u_action}&amp;field=legend&amp;action=delete&amp;g=" . $row['group_id'],
1139                  ));
1140              }
1141              else
1142              {
1143                  $template->assign_block_vars('add_legend', array(
1144                      'GROUP_ID'        => (int) $row['group_id'],
1145                      'GROUP_NAME'    => $group_name,
1146                      'GROUP_SPECIAL'    => ($row['group_type'] == GROUP_SPECIAL),
1147                  ));
1148              }
1149          }
1150          $db->sql_freeresult($result);
1151  
1152          $category_url_param = (($category_id) ? '&amp;c=' . $category_id : '');
1153  
1154          $sql = 'SELECT t.*, g.group_name, g.group_colour, g.group_type
1155              FROM ' . TEAMPAGE_TABLE . ' t
1156              LEFT JOIN ' . GROUPS_TABLE . ' g
1157                  ON (t.group_id = g.group_id)
1158              WHERE t.teampage_parent = ' . $category_id . '
1159                  OR t.teampage_id = ' . $category_id . '
1160              ORDER BY t.teampage_position ASC';
1161          $result = $db->sql_query($sql);
1162  
1163          while ($row = $db->sql_fetchrow($result))
1164          {
1165              if ($row['teampage_id'] == $category_id)
1166              {
1167                  $template->assign_vars(array(
1168                      'CURRENT_CATEGORY_NAME'        => $row['teampage_name'],
1169                  ));
1170                  continue;
1171              }
1172  
1173              if ($row['group_id'])
1174              {
1175                  $group_name = $group_helper->get_name($row['group_name']);
1176                  $group_type = $user->lang[\phpbb\groupposition\teampage::group_type_language($row['group_type'])];
1177              }
1178              else
1179              {
1180                  $group_name = $row['teampage_name'];
1181                  $group_type = '';
1182              }
1183  
1184              $template->assign_block_vars('teampage', array(
1185                  'GROUP_NAME'    => $group_name,
1186                  'GROUP_COLOUR'    => ($row['group_colour']) ? '#' . $row['group_colour'] : '',
1187                  'GROUP_TYPE'    => $group_type,
1188  
1189                  'U_CATEGORY'    => (!$row['group_id']) ? "{$this->u_action}&amp;c=" . $row['teampage_id'] : '',
1190                  'U_MOVE_DOWN'    => "{$this->u_action}&amp;field=teampage&amp;action=move_down{$category_url_param}&amp;t=" . $row['teampage_id'],
1191                  'U_MOVE_UP'        => "{$this->u_action}&amp;field=teampage&amp;action=move_up{$category_url_param}&amp;t=" . $row['teampage_id'],
1192                  'U_DELETE'        => "{$this->u_action}&amp;field=teampage&amp;action=delete{$category_url_param}&amp;t=" . $row['teampage_id'],
1193              ));
1194          }
1195          $db->sql_freeresult($result);
1196  
1197          $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
1198              FROM ' . GROUPS_TABLE . ' g
1199              LEFT JOIN ' . TEAMPAGE_TABLE . ' t
1200                  ON (t.group_id = g.group_id)
1201              WHERE t.teampage_id IS NULL
1202              ORDER BY g.group_type DESC, g.group_name ASC';
1203          $result = $db->sql_query($sql);
1204  
1205          while ($row = $db->sql_fetchrow($result))
1206          {
1207              $group_name = $group_helper->get_name($row['group_name']);
1208              $template->assign_block_vars('add_teampage', array(
1209                  'GROUP_ID'        => (int) $row['group_id'],
1210                  'GROUP_NAME'    => $group_name,
1211                  'GROUP_SPECIAL'    => ($row['group_type'] == GROUP_SPECIAL),
1212              ));
1213          }
1214          $db->sql_freeresult($result);
1215  
1216          $template->assign_vars(array(
1217              'U_ACTION'                    => $this->u_action,
1218              'U_ACTION_LEGEND'            => $this->u_action . '&amp;field=legend',
1219              'U_ACTION_TEAMPAGE'            => $this->u_action . '&amp;field=teampage' . $category_url_param,
1220              'U_ACTION_TEAMPAGE_CAT'        => $this->u_action . '&amp;field=teampage_cat',
1221  
1222              'S_TEAMPAGE_CATEGORY'        => $category_id,
1223              'DISPLAY_FORUMS'            => ($config['teampage_forums']) ? true : false,
1224              'DISPLAY_MEMBERSHIPS'        => $config['teampage_memberships'],
1225              'LEGEND_SORT_GROUPNAME'        => ($config['legend_sort_groupname']) ? true : false,
1226          ));
1227      }
1228  }


Generated: Sat Oct 26 11:28:42 2019 Cross-referenced by PHPXref 0.7.1