Changeset 25618
- Timestamp:
- Nov 21, 2013, 6:03:42 PM (10 years ago)
- Location:
- extensions/AdminTools
- Files:
-
- 3 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/AdminTools/include/MultiView.class.php
r25617 r25618 2 2 defined('ADMINTOOLS_ID') or die('Hacking attempt!'); 3 3 4 /** 5 * Class managing multi views system 6 */ 4 7 class MultiView 5 8 { 9 /** @var bool $is_admin */ 6 10 private $is_admin; 7 11 12 /** @var array $data */ 8 13 private $data = array(); 9 14 15 /** 16 * Constructor, load $data from session 17 */ 10 18 function __construct() 11 19 { … … 22 30 'template_combine_files' => $conf['template_combine_files'], 23 31 'no_history' => false, 24 'purge_template' => false,25 32 ), 26 33 pwg_get_session_var('multiview', array()) … … 28 35 } 29 36 37 /** 38 * @return bool 39 */ 30 40 public function is_admin() 31 41 { … … 33 43 } 34 44 45 /** 46 * @return array 47 */ 35 48 public function get_data() 36 49 { … … 38 51 } 39 52 53 /** 54 * Save $data in session 55 */ 40 56 private function save() 41 57 { … … 43 59 } 44 60 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 */ 45 67 public function get_clean_url($with_amp=false) 46 68 { … … 66 88 } 67 89 90 /** 91 * Triggered on "user_init", change current view depending of URL params. 92 */ 68 93 public function user_init() 69 94 { … … 74 99 global $user, $conf; 75 100 76 $this->data['view_as'] = $user['id'];77 $this->data['theme'] = $user['theme'];78 $this->data['lang'] = $user['language'];79 80 $refresh = false;81 82 101 // view_as 83 102 if (isset($_GET['view_as'])) … … 85 104 $this->data['view_as'] = (int)$_GET['view_as']; 86 105 } 87 if ($this->data['view_as'] != $user['id'] )106 if ($this->data['view_as'] != $user['id'] and $this->data['view_as'] != 0) 88 107 { 89 108 $user = build_user($this->data['view_as'], true); … … 97 116 $this->data['theme'] = $_GET['theme']; 98 117 } 99 $user['theme'] = $this->data['theme']; 118 if ($this->data['theme'] != '') 119 { 120 $user['theme'] = $this->data['theme']; 121 } 100 122 101 123 // lang … … 104 126 $this->data['lang'] = $_GET['lang']; 105 127 } 106 $user['language'] = $this->data['lang']; 128 if ($this->data['lang'] != '') 129 { 130 $user['language'] = $this->data['lang']; 131 } 107 132 108 133 // show_queries … … 144 169 } 145 170 146 // purge_template147 if (isset($_GET['purge_template']))148 {149 $this->data['purge_template'] = true;150 $refresh = true;151 }152 153 171 $this->save(); 154 155 if ($refresh)156 {157 redirect($this->get_clean_url());158 }159 172 } 160 173 } 161 174 175 /** 176 * Triggered on "init", in order to clean template files (not initialized on "user_init") 177 */ 162 178 public function init() 163 179 { 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'])) 168 181 { 169 182 global $template; 170 183 $template->delete_compiled_templates(); 171 184 FileCombiner::clear_combined_files(); 172 173 $this->data['purge_template'] = false;174 $this->save();175 185 } 176 186 }
Note: See TracChangeset
for help on using the changeset viewer.