4 include($strRel . 'config.php');
5 include($DIR_LIBS . 'PLUGINADMIN.php');
7 // Send out Content-type
8 sendContentType('application/xhtml+xml', 'admin-skinswitcher', _CHARSET);
10 if (!($member->isLoggedIn() && $member->isAdmin()))
11 doError('You\'re not logged in.');
13 if (!($member->isLoggedIn() && $member->getAdminBlogs()))
14 doError('You do not have admin rights for any blogs.');
16 $oPluginAdmin = new PluginAdmin('SkinSwitcher');
18 // include language file for this plugin
19 $language = ereg_replace( '[\\|/]', '', getLanguageName());
20 if (file_exists($oPluginAdmin->plugin->getDirectory().'language/'.$language.'.php'))
21 include_once($oPluginAdmin->plugin->getDirectory().'language/'.$language.'.php');
23 include_once($oPluginAdmin->plugin->getDirectory().'language/'.'english.php');
26 // ------------------------------------------------------------------
27 class NpSkinSwitcher_ADMIN{
29 function NpSkinSwitcher_ADMIN(){
31 $this->url = $oPluginAdmin->plugin->getAdminURL();
32 $this->extrahead = '<link rel="stylesheet" type="text/css" href="'.$this->url.'plus.css" />'."\n";
38 $msg = $_SESSION['msg'];
39 if ($msg) echo "<blockquote>"._MESSAGE.": $msg</blockquote>";
40 unset($_SESSION['msg']);
43 function showSelectList($blogid){
44 global $member, $oPluginAdmin;
45 if(!$blogid && !($member->isAdmin())) return;
47 $global_sdnums = $oPluginAdmin->plugin->getSdnums(0);
48 $defskinid = quickQuery('SELECT bdefskin as result FROM '.sql_table('blog').' WHERE bnumber='.intval($blogid));
49 if($hkey = array_search($defskinid,$global_sdnums)) unset($global_sdnums[$hkey]);
50 $sdnums = $oPluginAdmin->plugin->getSdnums($blogid);
52 echo '<h4>'._EBLOG_NAME.' : '.getBlogNameFromID($blogid).'</h4>';
54 echo '<h4>'._SETTINGS_TITLE.'</h4>';
58 <form method="post" action="<?php echo $this->url ?>index.php">
59 <input type="hidden" name="action" value="update" />
60 <input type="hidden" name="blogid" value="<?php echo $blogid ?>" />
63 echo '<thead><tr><th>'._SKIN_NAME.'</th><th>'._SKIN_TYPE.'</th><th>'._SKIN_DESC.'</th></tr></thead>'."\n";
65 $query = 'SELECT * FROM '.sql_table('skin_desc');
66 $res = sql_query($query);
70 while($ob = mysql_fetch_object($res)){
71 if($blogid && in_array($ob->sdnumber,$global_sdnums)) continue;
72 $chtxt = (in_array($ob->sdnumber,$sdnums))? ' checked="checked"': '';
73 $extxt = ($ob->sdnumber==$defskinid)? '<b> ('._EBLOG_DEFSKIN.')</b>': '';
74 echo '<tr'." onmouseover='focusRow(this);' onmouseout='blurRow(this);'".'><td><input type="checkbox" id="batch'.$i.'" name="sdnum['.$i.']" value="'.$ob->sdnumber.'"'.$chtxt.' /><label for="batch'.$i.'">'.$ob->sdname.$extxt.'</label></td><td>'.$ob->sdtype.'</td><td>'.$ob->sddesc.'</td></tr>'."\n";
77 echo '<tr><td colspan="3">
78 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); ">'._BATCH_SELECTALL.'</a>
79 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); ">'._BATCH_DESELECTALL.'</a>
80 <input type="submit" tabindex="10" value="'._SUBMIT.'" />
82 echo '</tbody></table></form>'."\n";
85 function bloglistForSS(){
88 echo '<h4>'._OVERVIEW_YRBLOGS.' ('._BMLET_OPTIONS.')</h4>';
89 if ($member->isAdmin()) {
90 // Super-Admins have access to all blogs! (no add item support though)
91 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
92 . ' FROM ' . sql_table('blog')
95 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
96 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
97 . ' WHERE tblog=bnumber and tmember=' . $member->getID() . ' and tadmin=1'
100 $res = sql_query($query);
104 echo '<tr><th>'._EBLOG_NAME.'</th><th>'._EBLOG_DESC.'</th><th>'._LISTS_ACTIONS.'</th></tr>'."\n";
105 while($ob = mysql_fetch_object($res)){
106 echo '<tr'." onmouseover='focusRow(this);' onmouseout='blurRow(this);'".'><td>' . $ob->bname . '</td><td>'.$ob->bdesc.'</td><td><a href="'.$this->url.'index.php?action=blogoverview&blogid='.$ob->bnumber.'">'._PLUG_SKINSWITCHER_BLOGLINK.'</a></td></tr>';
108 echo '</table>'."\n";
112 function action_overview(){
113 global $member, $oPluginAdmin;
114 // $member->isAdmin() or $this->disallow();
115 $member->isLoggedIn() or $this->disallow();
117 $oPluginAdmin->start($this->extrahead);
118 echo '<h2>SkinSwitcher</h2>';
119 echo _PLUG_SKINSWITCHER_HINT;
120 $this->showSelectList(0);
121 $this->bloglistForSS();
124 $oPluginAdmin->end();
127 function action_blogoverview(){
128 global $member, $oPluginAdmin;
129 $member->isLoggedIn() or $this->disallow();
131 $oPluginAdmin->start($this->extrahead);
132 echo '<h2>SkinSwitcher</h2>';
133 echo _PLUG_SKINSWITCHER_HINT;
134 $blogid = intRequestVar('blogid');
135 $this->showSelectList($blogid);
138 $oPluginAdmin->end();
142 function action_update(){
143 global $member, $oPluginAdmin, $oTemplate;
144 // $member->isAdmin() or $this->disallow();
145 $member->isLoggedIn() or $this->disallow();
147 $blogid = intRequestVar('blogid');
148 $sdnums = @join(',',requestVar('sdnum'));
150 $dq = 'DELETE FROM '.sql_table('plug_skinswitcher').' WHERE sblogid='.$blogid;
151 $dres = sql_query($dq);
156 ".sql_table('plug_skinswitcher')."
158 sblogid = ".$blogid.",
159 disskinid = '".$sdnums."'
161 $res = @mysql_query($iq);
163 $_SESSION['msg'] = $iq.'Could not save data: ' . mysql_error() . $query;
165 $_SESSION['msg'] = 'Saved.';
168 $_SESSION['msg'] = 'Saved.';
171 header('location: '.$this->url);
177 function action($action) {
178 $methodName = 'action_' . $action;
179 if (method_exists($this, $methodName)) {
180 call_user_func(array(&$this, $methodName));
182 $this->error(_BADACTION . " ($action)");
186 function disallow() {
187 global $HTTP_SERVER_VARS;
189 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . $HTTP_SERVER_VARS['REQUEST_URI']);
191 $this->error(_ERROR_DISALLOWED);
194 function error($msg) {
195 global $oPluginAdmin;
197 $oPluginAdmin->start();
198 $dir=$oPluginAdmin->plugin->getAdminURL();
203 echo "<a href='".$dir."index.php' onclick='history.back()'>"._BACK."</a>";
205 $oPluginAdmin->end();
209 // ------------------------------------------------------------------
210 $myAdmin = new NpSkinSwitcher_ADMIN();
211 if (requestVar('action')) {
212 $myAdmin->action(requestVar('action'));
214 $myAdmin->action('overview');