2 /* NP_SkinSwitcher ver 0.7.2 */
5 include($strRel . 'config.php');
6 include($DIR_LIBS . 'PLUGINADMIN.php');
8 // Send out Content-type
9 sendContentType('application/xhtml+xml', 'admin-skinswitcher', _CHARSET);
11 if (!($member->isLoggedIn() && $member->isAdmin()))
12 doError('You\'re not logged in.');
14 if (!($member->isLoggedIn() && $member->getAdminBlogs()))
15 doError('You do not have admin rights for any blogs.');
17 $oPluginAdmin = new PluginAdmin('SkinSwitcher');
19 // include language file for this plugin
20 $language = ereg_replace( '[\\|/]', '', getLanguageName());
21 if (file_exists($oPluginAdmin->plugin->getDirectory().'language/'.$language.'.php'))
22 include_once($oPluginAdmin->plugin->getDirectory().'language/'.$language.'.php');
24 include_once($oPluginAdmin->plugin->getDirectory().'language/'.'english.php');
27 // ------------------------------------------------------------------
28 class NpSkinSwitcher_ADMIN{
30 function NpSkinSwitcher_ADMIN(){
32 $this->url = $oPluginAdmin->plugin->getAdminURL();
33 $this->extrahead = '<link rel="stylesheet" type="text/css" href="'.$this->url.'plus.css" />'."\n";
39 $msg = $_SESSION['msg'];
40 if ($msg) echo "<blockquote>"._MESSAGE.": $msg</blockquote>";
41 unset($_SESSION['msg']);
44 function showSelectList($blogid){
45 global $member, $oPluginAdmin;
46 if(!$blogid && !($member->isAdmin())) return;
48 $global_sdnums = $oPluginAdmin->plugin->getSdnums(0);
49 $defskinid = quickQuery('SELECT bdefskin as result FROM '.sql_table('blog').' WHERE bnumber='.intval($blogid));
50 if($hkey = array_search($defskinid,$global_sdnums)) unset($global_sdnums[$hkey]);
51 $sdnums = $oPluginAdmin->plugin->getSdnums($blogid);
53 echo '<h4>'._EBLOG_NAME.' : '.getBlogNameFromID($blogid).'</h4>';
55 echo '<h4>'._SETTINGS_TITLE.'</h4>';
59 <form method="post" action="<?php echo $this->url ?>index.php">
60 <input type="hidden" name="action" value="update" />
61 <input type="hidden" name="blogid" value="<?php echo (int)$blogid ?>" />
64 echo '<thead><tr><th>'._SKIN_NAME.'</th><th>'._SKIN_TYPE.'</th><th>'._SKIN_DESC.'</th></tr></thead>'."\n";
66 $query = 'SELECT * FROM '.sql_table('skin_desc');
67 $res = sql_query($query);
71 while($ob = mysql_fetch_object($res)){
72 if($blogid && in_array($ob->sdnumber,$global_sdnums)) continue;
73 $chtxt = (in_array($ob->sdnumber,$sdnums))? ' checked="checked"': '';
74 $extxt = ($ob->sdnumber==$defskinid)? '<b> ('._EBLOG_DEFSKIN.')</b>': '';
75 echo '<tr'." onmouseover='focusRow(this);' onmouseout='blurRow(this);'".'>'.
76 '<td><input type="checkbox" id="batch'.$i.'" name="sdnum['.$i.']" value="'.(int)$ob->sdnumber.'"'.$chtxt.' />'.
77 '<label for="batch'.$i.'">'.htmlspecialchars($ob->sdname).$extxt.'</label></td>'.
78 '<td>'.htmlspecialchars($ob->sdtype).'</td><td>'.htmlspecialchars($ob->sddesc).'</td></tr>'."\n";
81 echo '<tr><td colspan="3">
82 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(1); ">'._BATCH_SELECTALL.'</a>
83 <a href="" onclick="if (event && event.preventDefault) event.preventDefault(); return batchSelectAll(0); ">'._BATCH_DESELECTALL.'</a>
84 <input type="submit" tabindex="10" value="'._SUBMIT.'" />
86 echo '</tbody></table></form>'."\n";
89 function bloglistForSS(){
92 echo '<h4>'._OVERVIEW_YRBLOGS.' ('._BMLET_OPTIONS.')</h4>';
93 if ($member->isAdmin()) {
94 // Super-Admins have access to all blogs! (no add item support though)
95 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
96 . ' FROM ' . sql_table('blog')
99 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
100 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
101 . ' WHERE tblog=bnumber and tmember=' . (int)$member->getID() . ' and tadmin=1'
104 $res = sql_query($query);
108 echo '<tr><th>'._EBLOG_NAME.'</th><th>'._EBLOG_DESC.'</th><th>'._LISTS_ACTIONS.'</th></tr>'."\n";
109 while($ob = mysql_fetch_object($res)){
110 echo '<tr'." onmouseover='focusRow(this);' onmouseout='blurRow(this);'".'>'.
111 '<td>' . htmlspecialchars($ob->bname) . '</td>'.
112 '<td>'.htmlspecialchars($ob->bdesc).'</td>'.
113 '<td><a href="'.$this->url.'index.php?action=blogoverview&blogid='.(int)$ob->bnumber.'">'._PLUG_SKINSWITCHER_BLOGLINK.'</a></td></tr>';
115 echo '</table>'."\n";
119 function action_overview(){
120 global $member, $oPluginAdmin;
121 // $member->isAdmin() or $this->disallow();
122 $member->isLoggedIn() or $this->disallow();
124 $oPluginAdmin->start($this->extrahead);
125 echo '<h2>SkinSwitcher</h2>';
126 echo _PLUG_SKINSWITCHER_HINT;
127 $this->showSelectList(0);
128 $this->bloglistForSS();
131 $oPluginAdmin->end();
134 function action_blogoverview(){
135 global $member, $oPluginAdmin;
136 $member->isLoggedIn() or $this->disallow();
138 $oPluginAdmin->start($this->extrahead);
139 echo '<h2>SkinSwitcher</h2>';
140 echo _PLUG_SKINSWITCHER_HINT;
141 $blogid = intRequestVar('blogid');
142 $this->showSelectList($blogid);
145 $oPluginAdmin->end();
149 function action_update(){
150 global $member, $oPluginAdmin, $oTemplate;
151 // $member->isAdmin() or $this->disallow();
152 $member->isLoggedIn() or $this->disallow();
154 $blogid = intRequestVar('blogid');
155 $sdnums = @join(',',requestVar('sdnum'));
157 $dq = 'DELETE FROM '.sql_table('plug_skinswitcher').' WHERE sblogid='.(int)$blogid;
158 $dres = sql_query($dq);
163 ".sql_table('plug_skinswitcher')."
165 sblogid = ".(int)$blogid.",
166 disskinid = '".addslashes($sdnums)."'
168 $res = @mysql_query($iq);
170 $_SESSION['msg'] = $iq.'Could not save data: ' . htmlspecialchars( mysql_error().$query );
172 $_SESSION['msg'] = 'Saved.';
175 $_SESSION['msg'] = 'Saved.';
178 header('location: '.$this->url);
184 function action($action) {
185 $methodName = 'action_' . $action;
186 if (method_exists($this, $methodName)) {
187 call_user_func(array(&$this, $methodName));
189 $this->error(_BADACTION . " ($action)");
193 function disallow() {
194 global $HTTP_SERVER_VARS;
196 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . $HTTP_SERVER_VARS['REQUEST_URI']);
198 $this->error(_ERROR_DISALLOWED);
201 function error($msg) {
202 global $oPluginAdmin;
204 $oPluginAdmin->start();
205 $dir=$oPluginAdmin->plugin->getAdminURL();
210 echo "<a href='".$dir."index.php' onclick='history.back()'>"._BACK."</a>";
212 $oPluginAdmin->end();
216 // ------------------------------------------------------------------
217 $myAdmin = new NpSkinSwitcher_ADMIN();
218 if (requestVar('action')) {
219 $myAdmin->action(requestVar('action'));
221 $myAdmin->action('overview');