Ignore:
Timestamp:
Dec 17, 2013, 12:14:08 PM (10 years ago)
Author:
mistic100
Message:

remove useless SQL queries, don't change user on admin pages, fix theme and language overwrites, fix toolbar overlap, colorbox max width

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/AdminTools/include/MultiView.class.php

    r25915 r25979  
    1212  /** @var array $data */
    1313  private $data = array();
     14  private $data_url_params = array();
    1415
    1516  /** @var array $user */
     
    3637      pwg_get_session_var('multiview', array())
    3738      );
     39
     40    $this->data_url_params = array_keys($this->data);
     41    $this->data_url_params = array_map(create_function('$d', 'return "ato_".$d;'), $this->data_url_params);
    3842  }
    3943
     
    8084    if (script_basename() == 'picture')
    8185    {
    82       $url = duplicate_picture_url(array(), array_keys($this->data));
     86      $url = duplicate_picture_url(array(), $this->data_url_params);
    8387    }
    8488    else if (script_basename() == 'index')
    8589    {
    86       $url = duplicate_index_url(array(), array_keys($this->data));
     90      $url = duplicate_index_url(array(), $this->data_url_params);
    8791    }
    8892    else
    8993    {
    90       $url = get_query_string_diff(array_keys($this->data));
     94      $url = get_query_string_diff($this->data_url_params);
    9195    }
    9296
     
    111115      'id' => $user['id'],
    112116      'username' => $user['username'],
     117      'language' => $user['language'],
     118      'theme' => $user['theme'],
    113119      );
    114120
     
    130136
    131137      // view_as
    132       if (isset($_GET['ato_view_as']))
    133       {
    134         $this->data['view_as'] = (int)$_GET['ato_view_as'];
    135       }
    136       if ($this->data['view_as'] != $user['id'])
    137       {
    138         $user = build_user($this->data['view_as'], true);
    139         $this->data['theme'] = $user['theme'];
    140         $this->data['lang'] = $user['language'];
     138      if (!defined('IN_ADMIN'))
     139      {
     140        if (isset($_GET['ato_view_as']))
     141        {
     142          $this->data['view_as'] = (int)$_GET['ato_view_as'];
     143        }
     144        if ($this->data['view_as'] != $user['id'])
     145        {
     146          $user = build_user($this->data['view_as'], true);
     147          if (isset($_GET['ato_view_as']))
     148          {
     149            $this->data['theme'] = $user['theme'];
     150            $this->data['lang'] = $user['language'];
     151          }
     152        }
    141153      }
    142154
     
    195207      $this->save();
    196208    }
     209  }
     210
     211  /**
     212   * Returns the language of the current user if different from the current language
     213   * false otherwise
     214   */
     215  function get_user_language()
     216  {
     217    if (isset($this->user['language']) && isset($this->data['lang'])
     218        && $this->user['language'] != $this->data['lang']
     219      )
     220    {
     221      return $this->user['language'];
     222    }
     223    return false;
    197224  }
    198225
Note: See TracChangeset for help on using the changeset viewer.