Changeset 2341
- Timestamp:
- May 15, 2008, 2:09:44 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1_7/plugins/admin_multi_view/controller.php
r2017 r2341 12 12 pwg_unset_session_var( 'multiview_debug_l10n' ); 13 13 ?> 14 14 15 <script type="text/javascript"> 15 16 window.close(); … … 21 22 $refresh_main = false; 22 23 23 if ( isset($_GET['view_ guest']) )24 if ( isset($_GET['view_as']) ) 24 25 { 25 pwg_set_session_var( 'multiview_as', $conf['guest_id'] ); 26 if ( is_adviser() and $user['id']!=$_GET['view_as'] and $conf['guest_id']!=$_GET['view_as']) 27 die('security error'); 28 pwg_set_session_var( 'multiview_as', (int)$_GET['view_as'] ); 29 // user change resets theme/lang 30 pwg_unset_session_var( 'multiview_theme' ); 31 pwg_unset_session_var( 'multiview_lang' ); 26 32 $refresh_main = true; 27 33 } 28 elseif ( isset($_GET['view_admin']) ) 29 { 30 pwg_unset_session_var('multiview_as'); 31 $refresh_main = true; 32 } 33 $view_as = pwg_get_session_var( 'multiview_as', 0 ); 34 34 if (pwg_get_session_var( 'multiview_as', $user['id']) != $user['id'] ) 35 $view_as_user = build_user( pwg_get_session_var( 'multiview_as',0), false); 36 else 37 $view_as_user = $user; 35 38 36 39 if ( isset($_GET['theme']) ) … … 64 67 } 65 68 69 66 70 $my_url = get_root_url().'plugins/'.basename(dirname(__FILE__)).'/'.basename(__FILE__); 67 $my_theme = get_root_url().'template/'.$user['template'].'/theme/'.$user['theme'].'/theme.css';68 71 69 $themes_html='Theme: <select onchange="document.location = this.options[this.selectedIndex].value;">'; 72 // +-----------------------------------------------------------------------+ 73 // | users | 74 $query = ' 75 SELECT '.$conf['user_fields']['id'].' AS id,'.$conf['user_fields']['username'].' AS username 76 FROM '.USERS_TABLE; 77 if (is_adviser()) 78 { 79 $query .=' 80 WHERE '.$conf['user_fields']['id']. ' IN ('.$user['id'].','.$conf['guest_id'].') 81 '; 82 } 83 $query .=' 84 ORDER BY CONVERT('.$conf['user_fields']['username'].',CHAR) 85 ;'; 86 $user_map = simple_hash_from_query($query, 'id', 'username'); 87 88 $users_html = '<select onchange="document.location = this.options[this.selectedIndex].value;">'; 89 foreach( $user_map as $id=>$username) 90 { 91 $selected = ($id==$view_as_user['id']) ? 'selected="selected"' : ''; 92 $users_html .= 93 '<option value="' 94 .$my_url.'?view_as='.$id 95 .'" '.$selected.'>' 96 .$username 97 .'</option>'; 98 } 99 $users_html.= '</select>'; 100 101 102 // +-----------------------------------------------------------------------+ 103 // | templates | 104 $my_template = ''; 105 $themes_html='<select onchange="document.location = this.options[this.selectedIndex].value;">'; 70 106 foreach (get_pwg_themes() as $pwg_template) 71 107 { 72 $selected = $pwg_template == pwg_get_session_var( 'multiview_theme', $user['template'].'/'.$user['theme'] ) ? 'selected="selected"' : ''; 108 $selected = $pwg_template == pwg_get_session_var( 'multiview_theme', $view_as_user['template'].'/'.$view_as_user['theme'] ) ? 'selected="selected"' : ''; 109 $my_template = $selected == '' ? $my_template : $view_as_user['template'].'/theme/'.$view_as_user['theme']; 73 110 $themes_html .= 74 111 '<option value="' … … 80 117 $themes_html .= '</select>'; 81 118 82 $lang_html='Language: <select onchange="document.location = this.options[this.selectedIndex].value;">'; 119 // +-----------------------------------------------------------------------+ 120 // | language | 121 $lang_html='<select onchange="document.location = this.options[this.selectedIndex].value;">'; 83 122 foreach (get_languages() as $language_code => $language_name) 84 123 { 85 $selected = $language_code == pwg_get_session_var( 'multiview_lang', $ user['language'] ) ? 'selected="selected"' : '';124 $selected = $language_code == pwg_get_session_var( 'multiview_lang', $view_as_user['language'] ) ? 'selected="selected"' : ''; 86 125 $lang_html .= 87 126 '<option value="' … … 93 132 $lang_html .= '</select>'; 94 133 134 // +-----------------------------------------------------------------------+ 135 // | show queries | 95 136 $show_queries_html=''; 96 137 if (!$conf['show_queries']) 97 138 { 98 $show_queries_html = '<br/>';99 139 if ( !pwg_get_session_var( 'multiview_show_queries', 0 ) ) 100 140 $show_queries_html.='<a href="'.$my_url.'?show_queries=1">Show SQL queries</a>'; … … 103 143 } 104 144 145 // +-----------------------------------------------------------------------+ 146 // | debug language | 105 147 $debug_l10n_html=''; 106 if (!$conf[' show_queries'])148 if (!$conf['debug_l10n']) 107 149 { 108 $debug_l10n_html = '<br/>';109 150 if ( !pwg_get_session_var( 'multiview_debug_l10n', 0 ) ) 110 151 $debug_l10n_html.='<a href="'.$my_url.'?debug_l10n=1">Debug language</a>'; … … 112 153 $debug_l10n_html.='<a href="'.$my_url.'?debug_l10n=0">Revert debug language</a>'; 113 154 } 155 114 156 ?> 115 116 157 <html> 117 158 <head> 118 159 <title>Controller</title> 160 <?php 161 // Controller will be displayed with the **real admin template** (without Any if it has been removed) 162 if ( $my_template !== '') { 163 $my_template = get_root_url().'template/'.$my_template.'/theme.css'; 164 echo '<link rel="stylesheet" type="text/css" href="' . $my_template .'">'; 165 } 166 ?> 167 119 168 </head> 120 <link rel="stylesheet" type="text/css" href="<?php121 echo $my_theme;122 ?>">123 169 <body> 124 170 <div> 125 171 <script type="text/javascript"> 126 172 if (window.opener==null) { 127 173 window.close(); 128 document.write("< h2>How did you get here ???</h2>");174 document.write("<"+"h2>How did you get here ???<"+"/h2>"); 129 175 } 130 176 </script> 131 177 132 View as: 133 <?php 134 if ($view_as) 135 echo '<a href="'.$my_url.'?view_admin">admin</a>'; 136 else 137 echo '<a href="'.$my_url.'?view_guest">guest</a>'; 138 ?> 178 <table> 179 <tr><td>User</td><td><?php echo $users_html; ?></td></tr> 139 180 140 <br /> 141 <?php echo $themes_html; ?> 181 <tr><td>Theme</td><td><?php echo $themes_html; ?></td></tr> 142 182 143 <br /> 144 <?php echo $lang_html; ?> 145 146 <?php echo $show_queries_html; ?> 147 <?php echo $debug_l10n_html; ?> 183 <tr><td>Lang</td><td><?php echo $lang_html; ?></td></tr> 184 </table> 185 <?php echo implode( "<br/>\n", array($show_queries_html, $debug_l10n_html) ); ?> 148 186 149 187 <script type="text/javascript"> … … 153 191 ?> 154 192 </script> 155 193 </div> 156 194 </body> 157 158 195 </html>
Note: See TracChangeset
for help on using the changeset viewer.