Changeset 25618


Ignore:
Timestamp:
Nov 21, 2013, 6:03:42 PM (10 years ago)
Author:
mistic100
Message:

fix parameters overlapping when changing user

Location:
extensions/AdminTools
Files:
3 deleted
1 edited

Legend:

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

    r25617 r25618  
    22defined('ADMINTOOLS_ID') or die('Hacking attempt!');
    33
     4/**
     5 * Class managing multi views system
     6 */
    47class MultiView
    58{
     9  /** @var bool $is_admin */
    610  private $is_admin;
    711
     12  /** @var array $data */
    813  private $data = array();
    914
     15  /**
     16   * Constructor, load $data from session
     17   */
    1018  function __construct()
    1119  {
     
    2230        'template_combine_files' => $conf['template_combine_files'],
    2331        'no_history' => false,
    24         'purge_template' => false,
    2532        ),
    2633      pwg_get_session_var('multiview', array())
     
    2835  }
    2936
     37  /**
     38   * @return bool
     39   */
    3040  public function is_admin()
    3141  {
     
    3343  }
    3444
     45  /**
     46   * @return array
     47   */
    3548  public function get_data()
    3649  {
     
    3851  }
    3952
     53  /**
     54   * Save $data in session
     55   */
    4056  private function save()
    4157  {
     
    4359  }
    4460
     61  /**
     62   * Returns the current url minus MultiView params
     63   *
     64   * @param bool $with_amp - adds ? or & at the end of the url
     65   * @return string
     66   */
    4567  public function get_clean_url($with_amp=false)
    4668  {
     
    6688  }
    6789
     90  /**
     91   * Triggered on "user_init", change current view depending of URL params.
     92   */
    6893  public function user_init()
    6994  {
     
    7499      global $user, $conf;
    75100
    76       $this->data['view_as'] = $user['id'];
    77       $this->data['theme'] = $user['theme'];
    78       $this->data['lang'] = $user['language'];
    79 
    80       $refresh = false;
    81 
    82101      // view_as
    83102      if (isset($_GET['view_as']))
     
    85104        $this->data['view_as'] = (int)$_GET['view_as'];
    86105      }
    87       if ($this->data['view_as'] != $user['id'])
     106      if ($this->data['view_as'] != $user['id'] and $this->data['view_as'] != 0)
    88107      {
    89108        $user = build_user($this->data['view_as'], true);
     
    97116        $this->data['theme'] = $_GET['theme'];
    98117      }
    99       $user['theme'] = $this->data['theme'];
     118      if ($this->data['theme'] != '')
     119      {
     120        $user['theme'] = $this->data['theme'];
     121      }
    100122
    101123      // lang
     
    104126        $this->data['lang'] = $_GET['lang'];
    105127      }
    106       $user['language'] = $this->data['lang'];
     128      if ($this->data['lang'] != '')
     129      {
     130        $user['language'] = $this->data['lang'];
     131      }
    107132
    108133      // show_queries
     
    144169      }
    145170
    146       // purge_template
    147       if (isset($_GET['purge_template']))
    148       {
    149         $this->data['purge_template'] = true;
    150         $refresh = true;
    151       }
    152 
    153171      $this->save();
    154 
    155       if ($refresh)
    156       {
    157         redirect($this->get_clean_url());
    158       }
    159172    }
    160173  }
    161174
     175  /**
     176   * Triggered on "init", in order to clean template files (not initialized on "user_init")
     177   */
    162178  public function init()
    163179  {
    164     // can't know if user is admin, not build yet
    165     // so only do non-critical tasks only
    166 
    167     if ($this->data['purge_template'])
     180    if (isset($_GET['purge_template']))
    168181    {
    169182      global $template;
    170183      $template->delete_compiled_templates();
    171184      FileCombiner::clear_combined_files();
    172 
    173       $this->data['purge_template'] = false;
    174       $this->save();
    175185    }
    176186  }
Note: See TracChangeset for help on using the changeset viewer.