2 if ( !class_exists('BaseActions') )
4 include $DIR_LIBS . 'BaseActions.php';
8 class AdminActions extends BaseActions
10 // reference to the skin object for which a part is being parsed
15 /* NOTE: list of whole available action names for tags
24 'adminskineditallowedlist',
27 'adminskinselectoptions',
28 'adminspecialskinlist',
29 'admintemplateoverview',
30 'allowedadminskinactions',
53 'configsettingsyesno',
56 'defaultadminskintypes',
66 'editadmintemplateinfo',
72 'editplugoptionslist',
88 'insertpluginoptions',
93 'listplugplugoptionrow',
94 'localeselectoptions',
111 'selectlocaladminskinfiles',
112 'selectlocalskinfiles',
113 'skineditallowedlist',
130 * AdminActions::$default_actions
131 * list of whole action names with which this class can deal
133 static private $default_actions = array(
144 * AdminActions::$skin_type_friendly_names
145 * friendly name for wrapped page types
147 static private $default_skin_types = array(
148 'actionlog' => _ADM_SKPRT_ACTIONLOG,
149 'activate' => _ADM_SKPRT_ACTIVATE,
150 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
151 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
152 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
153 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
154 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
155 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
156 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
157 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
158 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
159 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
160 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
161 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
162 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
163 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
164 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
165 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
166 'banlist' => _ADM_SKPRT_BANLIST,
167 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
168 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
169 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
170 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
171 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
172 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
173 'batchitem' => _ADM_SKPRT_BATCHITEM,
174 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
175 'batchmove' => _ADM_SKPRT_BATCHMOVE,
176 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
177 'batchteam' => _ADM_SKPRT_BATCHTEAM,
178 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
179 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX,
180 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
181 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
182 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
183 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
184 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
185 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
186 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
187 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
188 'createitem' => _ADM_SKPRT_CREATEITEM,
189 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
190 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
191 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
192 'insertpluginoptions' => _ADM_SKPRT_INSERTPLUGINO,
193 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
194 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
195 'itemedit' => _ADM_SKPRT_ITEMEDIT,
196 'itemlist' => _ADM_SKPRT_ITEMLIST,
197 'itemmove' => _ADM_SKPRT_ITEMMOVE,
198 'login' => FALSE, //missing
199 'manage' => _ADM_SKPRT_MANAGE,
200 'manageteam' => _ADM_SKPRT_MANAGETEAM,
201 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
202 'memberedit' => FALSE, //missing
203 'overview' => _ADM_SKPRT_OVERVIEW,
204 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
205 'pagehead' => _ADM_SKPRT_PAGEHEAD,
206 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
207 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
208 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
209 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
210 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
211 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
212 'skindelete' => _ADM_SKPRT_SKINDELETE,
213 'skinedit' => _ADM_SKPRT_SKINEDIT,
214 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
215 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
216 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
217 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
218 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
219 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
220 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
221 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
222 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
223 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
224 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
225 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
229 * AdminActions::getAvailableSkinTypes()
233 * @return array list of friendly names for page actions
235 static public function getAvailableSkinTypes()
237 return self::$default_skin_types;
241 * AdminActions::getDefaultTypes()
245 * @return array list of friendly names for page actions
247 static public function getDefaultTypes()
249 return self::$default_skin_types;
253 * AdminActions::__construct()
254 * Constructor for a new Actions object
256 * @param string $type
259 public function __construct($type)
261 // call constructor of superclass first
262 parent::__construct();
263 $this->skintype = $type;
264 if ( !class_exists('Navlist') || !class_exists('Batch') )
267 include $DIR_LIBS . 'ENCAPSULATE.php';
273 * AdminActions::getAvailableActions()
276 * @return array allowed actions for the page type
278 public function getAvailableActions()
280 $extra_actions = array();
282 switch ( $this->skintype )
285 $extra_actions = array(
290 $extra_actions = array(
295 case 'activatesetpwd':
296 $extra_actions = array(
300 $extra_actions = array(
306 case 'adminerrorpage':
307 $extra_actions = array(
310 case 'adminskindelete':
311 $extra_actions = array(
315 case 'adminskinedit':
316 $extra_actions = array(
318 'defaultadminskintypes',
319 'adminspecialskinlist',
322 case 'adminskinedittype':
323 $extra_actions = array(
326 'allowedadminskinactions',
327 'adminskineditallowedlist',
330 case 'adminskiniedoimport':
331 $extra_actions = array(
335 case 'adminskinieimport':
336 $extra_actions = array(
340 case 'adminskinieoverview':
341 $extra_actions = array(
342 'selectlocaladminskinfiles',
346 case 'adminskinoverview':
347 $extra_actions = array(
351 case 'adminskinremovetype':
352 $extra_actions = array(
356 case 'admintemplatedelete':
357 $extra_actions = array(
358 'editadmintemplateinfo',
360 case 'admintemplateedit':
361 $extra_actions = array(
362 'editadmintemplateinfo',
365 case 'admntemplateoverview':
366 $extra_actions = array(
367 'admintemplateoverview',
370 case 'backupoverview':
371 $extra_actions = array(
374 case 'backuprestore':
375 $extra_actions = array(
379 $extra_actions = array(
385 case 'banlistdelete':
386 $extra_actions = array(
391 case 'banlistdeleteconfirm':
392 $extra_actions = array(
393 'banlistdeletedlist',
398 $extra_actions = array(
404 case 'batchcategory':
405 $extra_actions = array(
411 $extra_actions = array(
417 $extra_actions = array(
423 $extra_actions = array(
429 $extra_actions = array(
435 $extra_actions = array(
444 $extra_actions = array(
453 $extra_actions = array(
459 case 'blogcommentlist':
460 $extra_actions = array(
466 case 'blogselectbox':
467 $extra_actions = array(
472 $extra_actions = array(
488 $extra_actions = array(
492 case 'browseowncomments':
493 $extra_actions = array(
497 case 'browseownitems':
498 $extra_actions = array(
502 case 'categorydelete':
503 $extra_actions = array(
509 $extra_actions = array(
516 case 'commentdelete':
517 $extra_actions = array(
522 $extra_actions = array(
527 $extra_actions = array(
539 $extra_actions = array(
545 $extra_actions = array(
550 case 'editmembersettings':
551 $extra_actions = array(
552 'adminskinselectoptions',
554 'localeselectoptions',
558 case 'insertpluginoptions':
559 $extra_actions = array(
560 'insertpluginoptions',
563 case 'itemcommentlist':
564 $extra_actions = array(
570 $extra_actions = array(
577 $extra_actions = array(
589 $extra_actions = array(
596 $extra_actions = array(
602 $extra_actions = array(
606 $extra_actions = array(
615 $extra_actions = array(
620 $extra_actions = array(
625 $extra_actions = array(
633 $extra_actions = array(
646 $extra_actions = array(
651 $extra_actions = array(
657 $extra_actions = array(
662 case 'pluginoptions':
663 $extra_actions = array(
665 'editplugoptionslist',
669 $extra_actions = array(
672 'configsettingsedit',
673 'configsettingsyesno',
676 'localeselectoptions',
682 $extra_actions = array(
687 $extra_actions = array(
692 $extra_actions = array(
698 $extra_actions = array(
701 'allowedskinactions',
702 'skineditallowedlist',
703 'skineditallowedlist',
706 case 'skiniedoimport':
707 $extra_actions = array(
712 $extra_actions = array(
716 case 'skinieoverview':
717 $extra_actions = array(
718 'selectlocalskinfiles',
723 $extra_actions = array(
727 case 'skinremovetype':
728 $extra_actions = array(
732 case 'systemoverview':
733 $extra_actions = array(
738 $extra_actions = array(
744 case 'templatedelete':
745 $extra_actions = array(
750 $extra_actions = array(
754 case 'templateoverview':
755 $extra_actions = array(
759 case 'usermanagement':
760 $extra_actions = array(
766 $extra_actions = array(
776 'selectlocaladminskinfiles',
784 $defined_actions = array_merge(self::$default_actions, $extra_actions);
786 return array_merge($defined_actions, parent::getAvailableActions());
790 * AdminActions::setSkin()
792 * @param object $skin an instance of Skin class
795 public function setSkin(&$skin)
797 $this->skin =& $skin;
802 * AdminActions::parse_actionloglist()
803 * Parse skinvar actionloglist
805 * @param string $templateName name of template to use
808 public function parse_actionloglist($templateName = '')
810 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
811 $query = sprintf($query, sql_table('actionlog'));
813 $template['content'] = 'actionlist';
814 $amount = showlist($query, 'table', $template, $templateName);
820 * AdminActions::parse_activationmessage()
821 * Parse skinvar activationmessage
823 * @param string $type type of message
824 * @param string $templateName name of template to use
827 public function parse_activationmessage($type, $templateName = '')
829 global $CONF, $manager;
833 if ( !empty($templateName))
835 $template = Template::read($templateName);
838 $key = postVar('ackey');
841 Admin::error(_ERROR_ACTIVATE);
844 $info = MEMBER::getActivationInfo($key);
847 Admin::error(_ERROR_ACTIVATE);
850 $mem = MEMBER::createFromId($info->vmember);
853 Admin::error(_ERROR_ACTIVATE);
855 switch ( $info->vtype )
858 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
860 $title = $template['ACTIVATE_FORGOT_TITLE'];
864 $title = _ACTIVATE_FORGOT_TITLE;
866 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
868 $text = $template['ACTIVATE_FORGOT_TEXT'];
872 $text = _ACTIVATE_FORGOT_TEXT;
876 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
878 $title = $template['ACTIVATE_REGISTER_TITLE'];
882 $title = _ACTIVATE_REGISTER_TITLE;
884 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
886 $text = $template['ACTIVATE_REGISTER_TEXT'];
890 $text = _ACTIVATE_REGISTER_TEXT;
893 case 'addresschange':
894 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
896 $title = $template['ACTIVATE_CHANGE_TITLE'];
900 $title = _ACTIVATE_CHANGE_TITLE;
902 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
904 $text = $template['ACTIVATE_CHANGE_TEXT'];
908 $text = _ACTIVATE_CHANGE_TEXT;
913 'memberName' => Entity::hsc($mem->getDisplayName()),
914 'realName' => Entity::hsc($mem->getRealName()),
919 echo Template::fill($title, $aVars);
922 echo Template::fill($text, $aVars);
925 echo Entity::hsc($key);
932 * AdminActions::parse_addtickettourl()
933 * Parse skinvar addtickettourl
935 * @param string $url URI for ticket
938 public function parse_addtickettourl($url)
941 $url = $manager->addTicketToUrl($url);
942 echo Entity::hsc($url);
947 * AdminActions::parse_adminbanlist()
948 * Parse skinvar adminbanlist
950 * @param string $templateName name of template to use
953 public function parse_adminbanlist($templateName = '')
955 $blogid = intRequestVar('blogid');
957 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
958 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
960 $template['content'] = 'banlist';
962 $amount = Showlist($query, 'table', $template, $templateName);
972 * AdminActions::parse_adminbatchaction()
973 * Parse skinvar adminbatchaction
978 public function parse_adminbatchaction()
980 echo Entity::hsc(requestVar('batchaction'));
985 * AdminActions::parse_adminbatchlist()
986 * Parse skinvar adminbatchlist
988 * @param string $templateName name of template to use
991 public function parse_adminbatchlist($templateName = '')
994 $templates = array();
996 if ( !empty($templateName) )
998 $templates = Template::read($templateName);
1001 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
1003 $template = '<li><%text(_BATCH_EXECUTING)%>'
1004 . '<b><%adminbatchaction%></b>'
1005 . '<%batchlisttype%>'
1006 . '<b><%batchid%></b>...'
1007 . '<b><%batchlistmsg%></b>'
1012 $template = $templates['ADMIN_BATCHLIST'];
1015 $selected = requestIntArray('batch');
1016 $action = requestVar('batchaction');
1018 switch ( $this->skintype )
1021 $batchlisttype = _BATCH_ONITEM;
1022 $deleteaction = 'deleteOneItem';
1023 $moveaction = 'moveOneItem';
1024 $destid = intRequestVar('destcatid');
1026 case 'batchcomment':
1027 $batchlisttype = _BATCH_ONCOMMENT;
1028 $deleteaction = 'deleteOneComment';
1031 $batchlisttype = _BATCH_ONMEMBER;
1032 $deleteaction = 'deleteOneMember';
1033 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1034 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1035 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1036 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1039 $blogid = intRequestVar('blogid');
1040 $batchlisttype = _BATCH_ONTEAM;
1041 $deleteaction = 'deleteOneTeamMember';
1042 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1043 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1044 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1045 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1047 case 'batchcategory':
1048 $batchlisttype = _BATCH_ONCATEGORY;
1049 $deleteaction = 'deleteOneCategory';
1050 $moveaction = 'moveOneCategory';
1051 $destid = intRequestVar('destblogid');
1055 // walk over all selectedids and perform action
1056 foreach ( $selected as $selectedid )
1059 $selectedid = intval($selectedid);
1063 if ( $this->skintype != 'batchteam' )
1065 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
1069 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1073 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
1077 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1081 // there should always remain at least one super-admin
1082 $r = DB::getResult($unsetchksql);
1083 if ( $r->rowCount() < 2 )
1085 $error = $unseterrmsg;
1089 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1093 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1097 'batchid' => $selectedid,
1098 'batchlisttype' => Entity::hsc($batchlisttype),
1099 'adminbatchaction' => Entity::hsc($action),
1100 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1103 $handler = new AdminActions('template');
1104 $parser = new Parser($handler);
1107 $parser->parse($template);
1108 $template = ob_get_contents();
1110 echo Template::fill($template, $data);
1116 * AdminActions::parse_adminbloglink()
1117 * Parse skinvar adminbloglink
1119 * @param string $templateName name of template to use
1122 public function parse_adminbloglink($templateName = '')
1125 $blogid = intRequestVar('blogid');
1126 $blog =& $manager->getBlog($blogid);
1127 $templates = array();
1129 if ( !empty($templateName) )
1131 $templates = Template::read($templateName);
1134 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1136 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1140 $template = $templates['ADMIN_BLOGLINK'];
1144 'url' => Entity::hsc($blog->getURL()),
1145 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1146 'blogname' => Entity::hsc($blog->getName())
1149 echo Template::fill($template, $data);
1154 * AdminActions::parse_adminerrormesg()
1155 * Parse skinvar adminerrormesg
1160 public function parse_adminerrormesg()
1165 if ( requestVar('errormessage') )
1167 $message = requestVar('errormessage');
1169 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1171 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1173 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1175 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1177 echo Entity::hsc($message);
1182 * AdminActions::parse_adminskineditallowedlist()
1183 * Parse skinvar adminskineditallowedlist
1185 * @param string $type template/blog
1186 * @param string $templateName name of template to use
1189 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1193 /* TODO: blog seems not to be used */
1195 $query = "SELECT bshortname, bname FROM %s";
1196 $query = sprintf($query, sql_table('blog'));
1198 'content' => 'shortblognames'
1200 Showlist($query, 'table', $show, $templateName);
1203 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1204 $query = sprintf($query, sql_table('template_desc'));
1206 'content' => 'shortnames'
1208 Showlist($query, 'table', $show, $templateName);
1215 * AdminActions::parse_adminskinielist()
1216 * Parse skinvar adminskinielist
1218 * @param string $type skin/template
1219 * @param string $templateName name of template to use
1222 public function parse_adminskinielist($type, $templateName = '')
1224 $templates = array();
1225 if ( $templateName )
1227 $templates = Template::read($templateName);
1230 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1233 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1234 . "<label for=\"<%expid%>\"><%expname%></label>"
1236 . "<td><%expdesc%></td>\n"
1242 $template = $templates['SKINIE_EXPORT_LIST'];
1248 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1249 $query = sprintf($query, sql_table('skin_desc'));
1250 $res = DB::getResult($query);
1252 foreach ( $res as $row )
1255 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1256 'expid' => 'skinexp' . $row['sdnumber'],
1257 'expname' => Entity::hsc($row['sdname']),
1258 'expdesc' => Entity::hsc($row['sddesc']),
1260 echo Template::fill($template, $data);
1264 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1265 $query = sprintf($query, sql_table('template_desc'));
1266 $res = DB::getResult($query);
1267 foreach ( $res as $row )
1270 'typeid' => 'template[' . $row['tdnumber'] . ']',
1271 'expid' => 'templateexp' . $row['tdnumber'],
1272 'expname' => Entity::hsc($row['tdname']),
1273 'expdesc' => Entity::hsc($row['tddesc']),
1275 echo Template::fill($template, $data);
1283 * AdminActions::parse_adminskinoverview()
1284 * Parse skinvar adminskinoverview
1286 * @param string $templateName name of template to use
1289 public function parse_adminskinoverview($templateName = '')
1291 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1292 $query = sprintf($query, sql_table('skin_desc'));
1294 $template['content'] = 'adminskinlist';
1295 $template['tabindex'] = 10;
1296 $template['friendly_names'] = $this->skin->getAvailableTypes();
1297 Showlist($query, 'table', $template, $templateName);
1302 * AdminActions::parse_adminskinselectoptions()
1303 * Parse skinvar adminskinselectoptions
1308 public function parse_adminskinselectoptions()
1311 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1312 $query = sprintf($query, sql_table('skin_desc'));
1314 $template['name'] = 'adminskin';
1315 $template['selected'] = $CONF['AdminSkin'];
1316 $template['tabindex'] = 110;
1317 Showlist($query, 'select', $template, '');
1322 * AdminActions::parse_adminspecialskinlist()
1323 * Parse skinvar adminspecialskinlist
1325 * @param string $templateName name of template to use
1327 public function parse_adminspecialskinlist($templateName = '')
1329 $templates = array();
1330 if ( $templateName )
1332 $templates = Template::read($templateName);
1335 $nType = $this->skin->getAvailableTypes();
1336 $skinid = intRequestVar('skinid');
1338 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1339 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1341 $res = DB::getResult($query);
1342 if ( $res && $res->rowCount() > 0 )
1344 /* NOTE: set templates for HEAD/BODY/FOOT */
1345 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1347 $template['head'] = "<ul>\n";
1351 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1353 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1355 $template['body'] = '<li>'
1356 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1359 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1366 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1368 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1370 $template['foot'] = "</ul>\n";
1374 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1381 echo $template['head'];
1382 foreach ( $res as $row )
1385 'tabindex' => $tabstart++,
1386 'skinid' => $skinid,
1387 'skintype' => Entity::hsc(strtolower($row['stype']))
1389 echo Template::fill($template['body'], $data);
1392 echo $template['foot'];
1398 * AdminActions::parse_admintemplateoverview()
1399 * Parse skinvar admintemplateoverview
1401 * @param string $templateName name of template to use
1404 public function parse_admintemplateoverview($templateName = '')
1406 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1407 $query = sprintf($query, sql_table('template_desc'));
1409 $template['content'] = 'admintemplatelist';
1410 $template['tabindex'] = 10;
1412 Showlist($query, 'table', $template, $templateName);
1417 * AdminActions::parse_allowedadminskinactions()
1418 * Parse skinvar allowedadminskinactions
1423 public function parse_allowedadminskinactions()
1425 global $DIR_ADMINSKINS;
1426 $skinType = strtolower(trim(requestVar('type')));
1427 $actions = $this->skin->getAllowedActionsForType($skinType);
1430 while ( $current = array_shift($actions) )
1432 // TODO: remove this
1433 // skip deprecated vars
1434 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1439 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1441 if ( count($actions) != 0 )
1450 * AdminActions::parse_allowedskinactions()
1451 * Parse skinvar allowedskinactions
1456 public function parse_allowedskinactions()
1458 $skinType = strtolower(trim(requestVar('type')));
1459 $skinid = intRequestVar('skinid');
1461 $skin = new Skin($skinid);
1462 $actions = $skin->getAllowedActionsForType($skinType);
1465 while ( $current = array_shift($actions) )
1467 // TODO: remove this
1468 // skip deprecated vars
1469 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1474 /* TODO: alternative function should be used or not? */
1475 echo helplink("skinvar-{$current}") . "$current</a>\n";
1477 if ( count($actions) != 0 )
1486 * AdminActions::parse_banlistdeletedlist()
1487 * Parse skinvar banlistdeletedlist
1489 * @param string $templateName name of template to use
1492 public function parse_banlistdeletedlist($templateName = '')
1496 $templates = array();
1497 if ( $templateName )
1499 $templates = Template::read($templateName);
1502 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1504 $template = "<li><%blogname%></li>\n";
1508 $template = $templates['BANLIST_DELETED_LIST'];
1511 $deleted = requestArray('delblogs');
1512 foreach ( $deleted as $delblog )
1514 $blog =& $manager->getBlog($delblog);
1516 'blogname' => Entity::hsc($blog->getName())
1518 echo Template::fill($template, $data);
1525 * AdminActions::parse_batchdeletelist()
1526 * Parse skinvar batchdeletelist
1531 public function parse_batchdeletelist()
1533 $selected = requestIntArray('batch');
1536 foreach ( $selected as $select )
1538 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1540 // add hidden vars for team & comment
1541 if ( requestVar('action') == 'batchteam' )
1543 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1545 if ( requestVar('action') == 'batchcomment' )
1547 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1553 * AdminActions::parse_batchdeletetype()
1554 * Parse skinvar batchdeletetype
1559 public function parse_batchdeletetype()
1561 echo Entity::hsc(requestVar('action'));
1566 * AdminActions::parse_batchmovebtn()
1567 * Parse skinvar batchmovebtn
1572 public function parse_batchmovebtn()
1574 $actionType = requestVar('action');
1575 switch ( $actionType )
1580 case 'batchcategory':
1588 * AdminActions::parse_batchmovelist()
1589 * Parse skinvar batchmovelist
1594 public function parse_batchmovelist()
1596 $selected = requestIntArray('batch');
1598 foreach ( $selected as $select )
1600 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1607 * AdminActions::parse_batchmovetitle()
1608 * Parse skinvar batchmovetitle
1613 public function parse_batchmovetitle()
1615 $actionType = requestVar('action');
1616 switch ( $actionType )
1621 case 'batchcategory':
1622 echo _MOVECAT_TITLE;
1629 * AdminActions::parse_batchmovetype()
1630 * Parse skinvar batchmovetype
1635 public function parse_batchmovetype()
1637 echo Entity::hsc(requestVar('action'));
1642 * AdminActions::parse_blogcatlist()
1643 * Parse skinvar blogcatlist
1648 public function parse_blogcatlist()
1651 $blogid = intRequestVar('blogid');
1652 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1653 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1655 $template['content'] = 'categorylist';
1656 $template['tabindex'] = 200;
1658 $batch = new Batch('category');
1659 $batch->showlist($query, 'table', $template);
1664 * AdminActions::parse_blogid()
1665 * Parse skinvar blogid
1670 public function parse_blogid()
1672 echo intRequestVar('blogid');
1677 * AdminActions::parse_blognotifysetting()
1678 * Parse skinvar blognotifysetting
1683 public function parse_blognotifysetting($type)
1686 $blogid = intRequestVar('blogid');
1687 $blog = $manager->getBlog($blogid);
1692 if ( !$blog->notifyOnComment() )
1698 if ( !$blog->notifyOnVote() )
1704 if ( !$blog->notifyOnNewItem() )
1710 echo ' checked="checked"';
1715 * AdminActions::parse_blogselectbox()
1716 * Parse skinvar blogselectbox
1721 public function parse_blogselectbox()
1725 $selectData = requestVar('selectData');
1726 $mode = $selectData['mode'];
1727 $name = Entity::hsc($selectData['name']);
1728 $tabindex = Entity::hsc($selectData['tabindex']);
1729 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1730 $showNewCat = intval($selectData['showNewCat']);
1731 $selected = intval($selectData['selected']);
1733 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1735 // 1. select blogs (we'll create optiongroups)
1736 // (only select those blogs that have the user on the team)
1737 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1738 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1739 $blogs = DB::getResult($queryBlogs);
1741 if ( $mode == 'category' )
1743 if ( $blogs->rowCount() > 1 )
1747 foreach ( $blogs as $rBlog )
1749 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1751 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
1754 // show selection to create new category when allowed/wanted
1757 // check if allowed to do so
1758 if ( $member->blogAdminRights($rBlog['bnumber']) )
1760 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
1764 // 2. for each category in that blog
1765 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1766 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
1767 $categories = DB::getResult($catQuery);
1768 foreach ( $categories as $rCat )
1770 if ( $rCat['catid'] == $selected )
1772 $selectText = ' selected="selected" ';
1778 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
1781 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1790 foreach ( $blogs as $rBlog )
1792 echo '<option value="' . $rBlog['bnumber'] . '"';
1793 if ( $rBlog['bnumber'] == $selected )
1795 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
1799 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";
1808 * AdminActions::parse_blogsetting()
1809 * Parse skinvar blogsetting
1811 * @param string $which name of weblog setting
1814 public function parse_blogsetting($which)
1816 echo $this->parse_getblogsetting($which);
1821 * AdminActions::parse_blogsettingyesno()
1822 * Parse skinvar blogsettingyesno
1824 * @param string $type type of weblog setting
1825 * @param string $templateName name of template to use
1828 public function parse_blogsettingyesno($type, $templateName = '')
1832 $blogid = intRequestVar('blogid');
1833 $blog = $manager->getBlog($blogid);
1837 case 'convertbreaks':
1838 $checkedval = $blog->convertBreaks();
1841 case 'allowpastposting':
1842 $checkedval = $blog->allowPastPosting();
1846 $checkedval = $blog->commentsEnabled();
1850 $checkedval = $blog->isPublic();
1854 $checkedval = $blog->emailRequired();
1858 $checkedval = $blog->getSearchable();
1862 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1867 * AdminActions::parse_blogteamlist()
1868 * Parse skinvar blogteamlist
1870 * @param string $templateName name of template to use
1873 public function parse_blogteamlist($templateName = '')
1876 $blogid = intRequestVar('blogid');
1877 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1879 . "WHERE tmember=mnumber AND tblog= %d";
1880 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1882 $template['content'] = 'teamlist';
1883 $template['tabindex'] = 10;
1885 $batch = new Batch('team');
1886 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1891 * AdminActions::parse_blogteammembers()
1892 * Parse skinvar blogteammembers
1897 public function parse_blogteammembers()
1899 $blogid = intRequestVar('blogid');
1900 $query = "SELECT mname, mrealname "
1902 . "WHERE mnumber=tmember AND tblog=%d;";
1903 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1904 $res = DB::getResult($query);
1905 $memberNames = array();
1906 foreach ( $res as $row )
1908 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1910 echo implode(',', $memberNames);
1914 * AdminActions::parse_blogtime()
1915 * Parse skinvar blogtime
1917 * @param string $type type of time
1918 * @param string $format format for time expression
1919 * @param integer $offset offset of time
1922 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1926 if ( $type != 'blogtime' )
1928 /* return server time */
1929 $timestamp = time() + $offset;
1933 $bid = intRequestVar('blogid');
1934 $b = $manager->getBlog($bid);
1935 $timestamp = $b->getCorrectTime() + $offset;
1938 echo i18n::formatted_datetime($format, $timestamp);
1943 * AdminActions::parse_bookmarkletadmin()
1944 * Parse skinvar bookmarkletadmin
1949 public function parse_bookmarkletadmin()
1953 $blogid = intRequestVar('blogid');
1955 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1960 * AdminActions::parse_categories()
1961 * Parse skinvar categories
1963 * create category dropdown box
1965 * @param string $type name of setting for category
1968 public function parse_categories($startidx = 0)
1973 $itemid = intRequestVar('itemid');
1974 $item = &$manager->getItem($itemid, 1, 1);
1979 $blogid = intRequestVar('blogid');
1983 $blogid = $item['blogid'];
1985 $blog = &$manager->getBlog($blogid);
1987 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1989 $item['body'] = removeBreaks($item['body']);
1990 $item['more'] = removeBreaks($item['more']);
1993 $contents = array();
1994 if ( requestVar('action') == 'itemedit' )
1999 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
2002 $catid = $blog->getDefaultCategory();
2007 $catid = $contents['catid'];
2010 Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
2016 * AdminActions::parse_category()
2017 * Parse skinvar category
2019 * @param string $type name of setting for category
2022 public function parse_category($type = 'name')
2024 echo $this->parse_getcategory($type);
2029 * AdminActions::parse_categorysetting()
2030 * Parse skinvar categorysetting
2032 * @param string $type type in category setting
2035 public function parse_categorysetting($type)
2037 $catid = intRequestVar('catid');
2038 if ( $type == 'id' )
2043 $blogid = intRequestVar('blogid');
2044 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
2045 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
2046 $row = DB::getRow($query);
2048 if ( $type != 'name' )
2050 echo Entity::hsc($row['cdesc']);
2054 echo Entity::hsc($row['cname']);
2061 * AdminActions::parse_codename()
2062 * Parse templatevar codename
2068 public function parse_checkedonval($value, $name)
2073 $itemid = intRequestVar('itemid');
2074 $item =& $manager->getItem($itemid, 1, 1);
2076 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2078 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
2080 $item['body'] = removeBreaks($item['body']);
2081 $item['more'] = removeBreaks($item['more']);
2084 $contents = array();
2085 if ( requestVar('action') == 'itemedit' )
2089 if ( !isset($contents[$name]) )
2091 $contents[$name] = '';
2093 if ($contents[$name] == $value)
2095 echo 'checked="checked"';
2101 * AdminActions::parse_codename()
2102 * Parse templatevar codename
2107 * TODO: is this need???
2109 public function parse_codename()
2112 echo $nucleus['codename'];
2117 * AdminActions::parse_commentnavlist()
2118 * Parse skinvar commentnavlist
2123 public function parse_commentnavlist()
2125 global $CONF, $manager, $member;
2128 if ( postVar('start') )
2130 $start = intPostVar('start');
2137 // amount of items to show
2138 if ( postVar('amount') )
2140 $amount = intPostVar('amount');
2144 $amount = (integer) $CONF['DefaultListSize'];
2150 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2152 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2154 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2156 if ( $this->skintype == 'itemcommentlist' )
2158 $itemid = intRequestVar('itemid');
2159 $query .= " citem={$itemid}";
2160 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2162 $nonComments = _NOCOMMENTS;
2164 elseif ( $this->skintype == 'browseowncomments' )
2167 $query .= ' cmember=' . $member->getID();
2168 $template['canAddBan'] = 0;
2170 $nonComments = _NOCOMMENTS_YOUR;
2172 elseif ( $this->skintype == 'blogcommentlist' )
2175 $query .= ' cblog=' . intRequestVar('blogid');
2176 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2177 $bid = intRequestVar('blogid');
2178 $nonComments = _NOCOMMENTS_BLOG;
2181 $search = postVar('search');
2182 if ( !empty($search) )
2184 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2187 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2189 $template['content'] = 'commentlist';
2191 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2192 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2197 * AdminActions::parse_configsettingsedit()
2198 * Parse skinvar configsettingsedit
2200 * @param string $type type of global configuration
2203 public function parse_configsettingsedit($type)
2208 case 'DefaultListSize':
2209 if ( !array_key_exists('DefaultListSize', $CONF) )
2211 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2212 $query = sprintf($query, sql_table('config'));
2213 DB::execute($query);
2214 $CONF['DefaultListSize'] = 10;
2216 elseif ( intval($CONF['DefaultListSize']) < 1 )
2218 $CONF['DefaultListSize'] = 10;
2220 echo intval($CONF['DefaultListSize']);
2222 case 'SessionCookie':
2223 $value = $CONF['SessionCookie'];
2224 $txt1 = _SETTINGS_COOKIESESSION;
2225 $txt2 = _SETTINGS_COOKIEMONTH;
2226 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2229 $value = $CONF['URLMode'];
2230 $txt1 = _SETTINGS_URLMODE_NORMAL;
2231 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2232 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2235 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2237 echo Entity::hsc($CONF[$type]);
2245 * AdminActions::parse_configsettingsyesno()
2246 * Parse skinvar configsettingsyesno
2248 * @param string $type type of global setting
2249 * @param integer $tabindex tabindex attribute of input element
2252 public function parse_configsettingsyesno($type, $tabindex)
2255 if ( array_key_exists($type, $CONF) )
2257 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2263 * AdminActions::parse_contents()
2264 * Parse skinvar contents
2266 * @param string $which part for item
2269 public function parse_contents($which)
2274 $contents = array();
2276 if ( requestVar('action') == 'itemedit' )
2278 $itemid = intRequestVar('itemid');
2279 $item =& $manager->getItem($itemid, 1, 1);
2281 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2283 if ( $item && $blog->convertBreaks() )
2285 $item['body'] = removeBreaks($item['body']);
2286 $item['more'] = removeBreaks($item['more']);
2290 elseif ( requestVar('action') == 'createitem' )
2292 $blogid = intRequestVar('blogid');
2293 $blog =& $manager->getBlog($blogid);
2297 'contents' => &$contents,
2303 if ( !array_key_exists($which, $contents) )
2305 $contents[$which] = '';
2307 echo Entity::hsc($contents[$which],ENT_QUOTES);
2311 * AdminActions::parse_currenttime()
2312 * Parse skinvar currenttime
2314 * @param string $what
2317 public function parse_currenttime($what)
2320 if ( requestVar('action') == 'itemedit' )
2322 $itemid = intRequestVar('itemid');
2323 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2325 elseif ( requestVar('action') == 'createitem' )
2327 $blog =& $manager->getBlog(intRequestVar('blogid'));
2329 $nu = getdate($blog->getCorrectTime());
2334 * AdminActions::parse_customhelplink()
2335 * Parse skinvar customhelplink
2337 * @param string $topic name of topic
2338 * @param string $tplName name of template
2339 * @param string $url string as URI
2340 * @param string $iconURL string as URI for icon
2341 * @param string $alt alternative text for image element
2342 * @param string $title title for anchor element
2345 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2347 $this->customHelp($topic, $url, $iconURL);
2352 * AdminActions::parse_date()
2353 * Parse skinvar date
2355 public function parse_date($format = 'c')
2357 global $CONF, $manager;
2358 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2363 * AdminActions::parse_defaultadminskintypes()
2364 * Parse skinvar defaultadminskintypes
2366 * @param string $tabindex index number for tabindex attribute of input element
2367 * @param string $templateName name of template
2370 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2372 $templates = array();
2374 if ( $templateName )
2376 $templates = Template::read($templateName);
2379 $types = $this->skin->getAvailableTypes();
2382 /* NOTE: set templates for HEAD/BODY/FOOT */
2383 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2385 $template['head'] = "<ul>\n";
2389 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2391 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2393 $template['body'] = "<li>"
2394 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2399 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2401 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2403 $template['foot'] = "</ul>\n";
2407 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2410 $handler = new AdminActions('template');
2411 $parser = new PARSER($handler);
2413 /* NOTE: do output */
2414 echo $template['head'];
2415 foreach ( $types as $type => $fName )
2417 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2419 'tabindex' => $tabindex,
2420 'skintype' => $type,
2422 'help' => $helplink,
2423 'skinid' => intrequestVar('skinid'),
2425 $parser->parse(Template::fill($template['body'], $data));
2428 echo $template['foot'];
2434 * AdminActions::parse_defblogselect()
2435 * Parse skinvar defblogselect
2437 * @param string $templateName name of template
2440 public function parse_defblogselect($templateName = '')
2444 $query = "SELECT bname as text, bnumber as value FROM %s;";
2445 $query = sprintf($query, sql_table('blog'));
2447 $template['name'] = 'DefaultBlog';
2448 $template['selected'] = $CONF['DefaultBlog'];
2449 $template['tabindex'] = 10;
2451 Showlist($query, 'select', $template, $templateName);
2457 * AdminActions::parse_defcatselect()
2458 * Parse skinvar defcatselect
2460 * @param string $templateName name of template
2463 public function parse_defcatselect($templateName = '')
2467 $blogid = intRequestVar('blogid');
2468 $blog = $manager->getBlog($blogid);
2470 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2471 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2473 $template['name'] = 'defcat';
2474 $template['selected'] = $blog->getDefaultCategory();
2475 $template['tabindex'] = 110;
2477 Showlist($query, 'select', $template, $templateName);
2483 * AdminActions::parse_defskinselect()
2484 * Parse skinvar defskinselect
2486 * @param string $type type of skin
2487 * @param string $templateName name of template
2490 public function parse_defskinselect($type = 'blog', $templateName = '')
2492 global $CONF, $manager;
2494 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2495 $query = sprintf($query, sql_table('skin_desc'));
2497 $blogid = intRequestVar('blogid');
2501 $template['selected'] = $CONF['BaseSkin'];
2505 $blog = $manager->getBlog($blogid);
2506 $template['selected'] = $blog->getDefaultSkin();
2509 if ( $type != 'blog' )
2511 $nname = 'BaseSkin';
2518 $template['name'] = $nname;
2519 $template['tabindex'] = 50;
2521 Showlist($query, 'select', $template, $templateName);
2527 * AdminActions::parse_deletecomment()
2528 * Parse skinvar deletecomment
2530 * @param string $type type of infomation for comment
2533 public function parse_deletecomment($type = 'id')
2535 $commentid = intRequestVar('commentid');
2536 $comment = COMMENT::getComment($commentid);
2541 echo intRequestVar('commentid');
2544 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2546 echo $comment['member'];
2550 echo $comment['user'];
2554 $body = strip_tags($comment['body']);
2555 echo Entity::hsc(shorten($body, 300, '...'));
2561 * AdminActions::parse_deleteitembody()
2562 * Parse skinvar deleteitembody
2567 public function parse_deleteitembody()
2571 $itemid = intRequestVar('itemid');
2572 $item =& $manager->getItem($itemid, 1, 1);
2574 $body = strip_tags($item['body']);
2576 echo Entity::hsc(shorten($body, 300, '...'));
2582 * AdminActions::parse_deleteitemid()
2583 * Parse skinvar deleteitemid
2588 public function parse_deleteitemid()
2590 echo (integer) intRequestVar('itemid');
2595 * AdminActions::parse_deleteitemtitle()
2596 * Parse skinvar deleteitemtitle
2601 public function parse_deleteitemtitle()
2605 $itemid = intRequestVar('itemid');
2606 $item =& $manager->getItem($itemid, 1, 1);
2608 echo Entity::hsc(strip_tags($item['title']));
2614 * AdminActions::parse_editadminskin()
2615 * Parse skinvar editadminskin
2617 * @param string $type type of skin setting
2620 public function parse_editadminskin($type = 'id')
2622 $skinid = intRequestVar('skinid');
2623 $skin = new Skin($skinid);
2627 echo intRequestVar('skinid');
2630 echo Entity::hsc($skin->getName());
2633 echo Entity::hsc($skin->getDescription());
2636 echo Entity::hsc($skin->getContentType());
2639 echo Entity::hsc($skin->getIncludePrefix());
2642 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2650 * AdminActions::parse_editadminskintype()
2651 * Parse skinvar editadminskintype
2653 * @param string $type name of skin type
2656 public function parse_editadminskintype($type = 'id')
2658 global $CONF, $manager, $member;
2660 $fNames = $this->skin->getAvailableTypes();
2661 $sType = strtolower(trim(requestVar('type')));
2666 echo intRequestVar('skinid');
2669 echo Entity::hsc($this->skin->getName());
2672 echo Entity::hsc($this->skin->getDescription());
2675 echo Entity::hsc($this->skin->getContentType());
2678 echo Entity::hsc($this->skin->getContentFromDB($sType));
2681 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2682 echo Entity::hsc($skinType);
2685 echo Entity::hsc($sType);
2688 echo Entity::hsc($this->skin->getIncludePrefix());
2691 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2692 echo Entity::hsc($incMode);
2701 * AdminActions::parse_editcomment()
2702 * Parse skinvar editcomment
2704 * @param string $type type of comment setting
2707 public function parse_editcomment($type = 'id')
2711 $commentid = intRequestVar('commentid');
2712 $comment = COMMENT::getComment($commentid);
2714 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2719 echo intRequestVar('commentid');
2722 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2724 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2728 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2732 echo date("Y-m-d @ H:i", $comment['timestamp']);
2735 $comment['body'] = str_replace('<br />', '', $comment['body']);
2736 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2737 echo $comment['body'];
2740 echo $comment['userid'];
2743 echo $comment['userid'];
2746 echo $comment[$type];
2753 * AdminActions::parse_editdesturl()
2754 * Parse skinvar editdesturl
2756 public function parse_editdesturl()
2758 if ( requestVar('desturl') )
2760 echo Entity::hsc(requestVar('desturl'));
2766 * AdminActions::parse_editmemberlist()
2767 * Parse skinvar editmemberlist
2769 * @param string $templateName name of template
2772 public function parse_editmemberlist($templateName = '')
2775 // show list of members with actions
2776 $query = 'SELECT * FROM '.sql_table('member');
2777 $template['content'] = 'memberlist';
2778 $template['tabindex'] = 10;
2780 $batch = new Batch('member');
2781 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2786 * AdminActions::parse_editmember()
2787 * Parse skinvar editmember
2789 * @param string $type type of information for member
2790 * @return string $tempateName name of template to use
2793 public function parse_editmember($type = 'id', $templateName = '')
2795 global $CONF, $manager, $member;
2797 $memberid = intRequestVar('memberid');
2798 $mem = MEMBER::createFromID($memberid);
2803 echo intRequestVar('memberid');
2806 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2808 echo Entity::hsc($mem->getDisplayName());
2812 $dispName = Entity::hsc($mem->getDisplayName());
2813 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2815 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2824 echo Entity::hsc($mem->getRealName());
2827 echo Entity::hsc($mem->getEmail());
2830 echo Entity::hsc($mem->getURL());
2833 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2836 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2839 echo Entity::hsc($mem->getNotes());
2842 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2851 * AdminActions::parse_editpluginfo()
2852 * Parse skinvar editpluginfo
2854 * @param string $type type of plugin info
2857 public function parse_editpluginfo($type)
2859 $pid = intRequestVar('plugid');
2866 echo Entity::hsc(getPluginNameFromPid($pid));
2873 * AdminActions::parse_editplugoptionslist()
2874 * Parse skinvar editplugoptionslist
2876 * @param string $templateName name of template
2879 public function parse_editplugoptionslist($templateName = '')
2883 $pid = intRequestVar('plugid');
2884 $aOptions = array();
2887 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2888 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2889 $resource = DB::getResult($query);
2891 foreach ( $resource as $row )
2893 array_push($aOIDs, $row['oid']);
2894 $aOptions[$row['oid']] = array(
2895 'oid' => $row['oid'],
2896 'value' => $row['odef'],
2897 'name' => $row['oname'],
2898 'description' => $row['odesc'],
2899 'type' => $row['otype'],
2900 'typeinfo' => $row['oextra'],
2905 // fill out actual values
2906 if ( count($aOIDs) > 0 )
2908 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2909 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2911 $result = DB::getResult($query);
2913 foreach ( $result as $row )
2915 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2921 'context' => 'global',
2923 'options' => &$aOptions
2925 $manager->notify('PrePluginOptionsEdit', $data);
2927 $template['content'] = 'plugoptionlist';
2929 $amount = Showlist($aOptions, 'table', $template, $templateName);
2933 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2939 * AdminActions::parse_editskin()
2940 * Parse skinvar editskin
2942 * @param string $type type of skin
2945 public function parse_editskin($type = 'id')
2947 $skinid = intRequestVar('skinid');
2948 $skin = new SKIN($skinid);
2952 echo intRequestVar('skinid');
2955 echo Entity::hsc($skin->getName());
2958 echo Entity::hsc($skin->getDescription());
2961 echo Entity::hsc($skin->getContentType());
2964 echo Entity::hsc($skin->getIncludePrefix());
2967 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2975 * AdminActions::parse_editskintype()
2976 * Parse skinvar editskintype
2978 * @param string $type name of type for skin type
2981 public function parse_editskintype($type = 'id')
2983 global $CONF, $manager, $member;
2984 $skinid = intRequestVar('skinid');
2985 $skin = new SKIN($skinid);
2986 $fNames = $skin->getAvailableTypes();
2987 $sType = strtolower(trim(requestVar('type')));
2992 echo intRequestVar('skinid');
2995 echo Entity::hsc($skin->getName());
2998 echo Entity::hsc($skin->getDescription());
3001 echo Entity::hsc($skin->getContentType());
3004 echo Entity::hsc($skin->getContentFromDB($sType));
3007 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
3008 echo Entity::hsc($skinType);
3011 echo Entity::hsc($sType);
3014 echo Entity::hsc($skin->getIncludePrefix());
3017 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
3018 echo Entity::hsc($incMode);
3027 * AdminActions::parse_adminurl()
3028 * Parse skinvar adminurl
3029 * (shortcut for admin url)
3034 public function parse_adminurl()
3036 $this->parse_sitevar('adminurl');
3041 * AdminActions::parse_edittemplateinfo()
3042 * Parse skinvar edittemplateinfo
3044 * @param string $type name of type for skin
3045 * @param string $description description for skin
3046 * @param string $name name of skin
3047 * @param string $help
3048 * @param string $tabindex index value for tabindex attribute of input element
3049 * @param string $big
3050 * @param string $tplt name of template
3053 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3057 $t_id = intRequestVar('templateid');
3058 $t_name = Template::getNameFromId($t_id);
3059 $t_desc = Template::getDesc($t_id);
3060 $template = &Template::read($t_name);
3068 echo Entity::hsc($t_name);
3071 echo Entity::hsc($t_desc);
3073 case 'extratemplate':
3075 $pluginfields = array();
3076 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
3081 $tmplt = Template::read($desc);
3083 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3087 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3091 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3094 foreach ( $pluginfields as $pfkey => $pfvalue )
3096 $data = array('explugtplname' => Entity::hsc($pfkey));
3098 echo Template::fill($base, $data);
3100 foreach ( $pfvalue as $pffield => $pfdesc )
3102 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3107 $desc = defined($desc) ? constant($desc) : $desc;
3108 $name = defined($name) ? constant($name) : $name;
3109 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3117 * AdminActions::parse_editadmintemplateinfo()
3118 * Parse skinvar editadmintemplateinfo
3120 * @param string $type type of skin template
3121 * @param string $description description of template
3122 * @param string $name name of stemplate
3123 * @param string $tabindex index number for tabindex attribute of input element
3124 * @param string $big
3125 * @param string $tplt
3127 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3131 $t_id = intRequestVar('templateid');
3132 $t_name = Template::getNameFromId($t_id);
3133 $t_desc = Template::getDesc($t_id);
3134 $template = &Template::read($t_name);
3142 echo Entity::hsc($t_name);
3145 echo Entity::hsc($t_desc);
3147 case 'extratemplate':
3149 $pluginfields = array();
3150 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3155 $tmplt = Template::read($desc);
3157 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3161 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3165 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3168 foreach ( $pluginfields as $pfkey => $pfvalue )
3170 $data = array('explugtplname' => Entity::hsc($pfkey));
3172 echo Template::fill($base, $data);
3174 foreach ( $pfvalue as $pffield => $pfdesc )
3176 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3181 $desc = defined($desc) ? constant($desc) : $desc;
3182 $name = defined($name) ? constant($name) : $name;
3183 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3190 * AdminActions::parse_eventformextra()
3191 * Parse skinvar eventformextra
3193 * @param string $type name of type for event form extra
3196 public function parse_eventformextra($type = 'activation')
3205 $key = requestVar('ackey');
3208 Admin::error(_ERROR_ACTIVATE);
3210 $info = MEMBER::getActivationInfo($key);
3213 Admin::error(_ERROR_ACTIVATE);
3215 $mem = MEMBER::createFromId($info->vmember);
3218 Admin::error(_ERROR_ACTIVATE);
3221 'type' => 'activation',
3225 case 'membermailform-notloggedin':
3226 $data = array('type' => 'membermailform-notloggedin',);
3229 $manager->notify('FormExtra', $data);
3234 * AdminActions::parse_extrahead()
3235 * Parse skinvar extrahead
3237 public function parse_extrahead()
3241 $extrahead = Admin::getAdminextrahead();
3244 'extrahead' => &$extrahead,
3245 'action' => Admin::getAdminAction()
3248 $manager->notify('AdminPrePageHead', $data);
3254 * AdminActions::parse_member()
3255 * Parse skinvar member
3256 * (includes a member info thingie)
3258 * @param string $what which memberdata is needed
3261 public function parse_member($what)
3263 global $memberinfo, $member, $CONF;
3265 // 1. only allow the member-details-page specific variables on member pages
3266 if ( $this->skintype == 'member' )
3271 echo Entity::hsc($memberinfo->getDisplayName());
3274 echo Entity::hsc($memberinfo->getRealName());
3277 echo Entity::hsc($memberinfo->getNotes());
3280 echo Entity::hsc($memberinfo->getURL());
3283 echo Entity::hsc($memberinfo->getEmail());
3286 echo Entity::hsc($memberinfo->getID());
3291 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3292 if ( $member->isLoggedIn() )
3297 echo $member->getDisplayName();
3299 case 'yourrealname':
3300 echo $member->getRealName();
3303 echo $member->getNotes();
3306 echo $member->getURL();
3309 echo $member->getEmail();
3312 echo $member->getID();
3314 case 'yourprofileurl':
3315 if ( $CONF['URLMode'] == 'pathinfo' )
3317 echo Link::create_member_link($member->getID());
3321 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3330 * AdminActions::parse_version()
3331 * Parse skinvar version
3332 * (include nucleus versionnumber)
3337 public function parse_version()
3340 echo 'Nucleus CMS ' . $nucleus['version'];
3345 * AdminActions::parse_sitevar()
3346 * Parse skinvar sitevar
3347 * (include a sitevar)
3349 * @param string $which
3352 public function parse_sitevar($which)
3358 echo $CONF['IndexURL'];
3361 echo $CONF['SiteName'];
3364 echo $CONF['AdminEmail'];
3367 echo $CONF['AdminURL'];
3373 * AdminActions::parse_charset()
3374 * Parse skinvar charset
3379 public function parse_charset()
3381 echo i18n::get_current_charset();
3386 * AdminActions::parse_getblogsetting()
3387 * Parse skinvar getblogsetting
3389 public function parse_getblogsetting($which)
3391 global $blog, $manager;
3397 elseif ( $bid = intRequestVar('blogid') )
3399 $b = $manager->getBlog($bid);
3409 return Entity::hsc($b->getID());
3412 return Entity::hsc($b->getURL());
3415 return Entity::hsc($b->getName());
3418 return Entity::hsc($b->getDescription());
3421 return Entity::hsc($b->getShortName());
3423 case 'notifyaddress':
3424 return Entity::hsc($b->getNotifyAddress());
3427 return Entity::hsc($b->getMaxComments());
3430 return Entity::hsc($b->getUpdateFile());
3433 return Entity::hsc($b->getTimeOffset());
3440 * AdminActions::parse_geteditpluginfo()
3441 * Parse skinvar geteditpluginfo
3443 * @param string $type name of setting for edit plugin info
3446 public function parse_geteditpluginfo($type)
3448 $pid = intRequestVar('plugid');
3455 return Entity::hsc(getPluginNameFromPid($pid));
3462 * AdminActions::parse_getmember()
3463 * Parse skinvar getmember
3464 * (includes a member info thingie)
3466 * @param string $what name of setting for member
3469 public function parse_getmember($what)
3471 global $memberinfo, $member;
3472 // 1. only allow the member-details-page specific variables on member pages
3473 if ( $this->skintype == 'member' )
3478 return Entity::hsc($memberinfo->getDisplayName());
3481 return Entity::hsc($memberinfo->getRealName());
3484 return Entity::hsc($memberinfo->getNotes());
3487 return Entity::hsc($memberinfo->getURL());
3490 return Entity::hsc($memberinfo->getEmail());
3493 return Entity::hsc($memberinfo->getID());
3497 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3498 if ( $member->isLoggedIn() )
3503 return $member->getDisplayName();
3505 case 'yourrealname':
3506 return $member->getRealName();
3509 return $member->getNotes();
3512 return $member->getURL();
3515 return $member->getEmail();
3518 return $member->getID();
3526 * AdminActions::parse_headmessage()
3527 * Parse skinvar headmessage
3532 public function parse_headmessage()
3534 if ( !empty(Admin::$headMess) )
3536 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3542 * AdminActions::parse_helplink()
3543 * Parse skinvar helplink
3545 * @param string $topic name of topic for help
3548 public function parse_helplink($topic = '')
3550 if ( !empty($topic) )
3558 * AdminActions::parse_helpplugname()
3559 * Parse skinvar helpplugname
3564 public function parse_helpplugname()
3566 $plugid = intGetVar('plugid');
3567 Entity::hsc(getPluginNameFromPid($plugid));
3572 * AdminActions::parse_ilistaddnew()
3573 * Parse skinvar ilistaddnew
3578 public function parse_ilistaddnew()
3580 $blogid = intRequestVar('blogid');
3581 if ( intPostVar('start') == 0 )
3583 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3589 * AdminActions::parse_importskininfo()
3590 * Parse skinvar importskininfo
3592 * @param string $type name of information for imported skin
3595 public function parse_importskininfo($type)
3600 echo Entity::hsc(requestVar('skininfo'));
3603 $dataArr = requestArray('skinnames');
3604 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3607 $dataArr = requestArray('tpltnames');
3608 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3611 $dataArr = requestArray('skinclashes');
3612 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3615 $dataArr = requestArray('tpltclashes');
3616 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3619 echo Entity::hsc(requestVar('skinfile'));
3622 echo Entity::hsc(requestVar('mode'));
3629 * AdminActions::parse_inputyesno()
3630 * Parse skinvar inputyesno
3632 * some init stuff for all forms
3637 public function parse_init()
3642 if ( requestVar('action') == 'itemedit' )
3644 $itemid = intRequestVar('itemid');
3645 $item =& $manager->getItem($itemid, 1, 1);
3647 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3648 if ( $item && $blog->convertBreaks() )
3650 $item['body'] = removeBreaks($item['body']);
3651 $item['more'] = removeBreaks($item['more']);
3654 $authorid = $contents['authorid'];
3656 elseif ( requestVar('action') == 'createitem' )
3658 $blogid = intRequestVar('blogid');
3659 $blog =& $manager->getBlog($blogid);
3662 $blog->insertJavaScriptInfo($authorid);
3667 * AdminActions::parse_inputyesno()
3668 * Parse skinvar inputyesno
3670 * @param string $name
3671 * @param string $checkedval
3672 * @param string $tabindex
3673 * @param string $value1
3674 * @param string $value2
3675 * @param string $yesval
3676 * @param string $noval
3677 * @param string $isAdmin
3678 * @param string $templateName
3681 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3683 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3688 * AdminActions::parse_insertpluginfo()
3689 * Parse templatevar insertpluginfo
3691 public function parse_insertpluginfo($type)
3693 $option = Admin::getAdminaOption();
3697 return $option['pid'];
3700 return Entity::hsc($option['pfile']);
3707 * AdminActions::parse_insertpluginoptions()
3708 * Parse skinvar insertpluginoptions
3710 * @param string $templateName name of template
3713 public function parse_insertpluginoptions($templateName = '')
3715 $options = Admin::getAdminaOption();
3716 $template = array();
3717 $templats = array();
3719 if ( $templateName )
3721 $templates = Template::read($templateName);
3723 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3725 $template['title'] = "<tr>"
3726 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3731 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3733 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3735 $template['body'] = "<tr>"
3736 . "<%listplugplugoptionrow%>"
3741 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3746 include_libs('ACTIONS.php');
3747 $handler = new Actions($this->skintype);
3748 $parser = new PARSER($handler);
3750 foreach ( $options as $option )
3754 if ( $prevPid != $option['pid'] )
3756 $prevPid = $option['pid'];
3757 $parser->parse($template['title']);
3760 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3762 if ( @$meta['access'] != 'hidden' )
3764 $parsed = $parser->parse($template['body']);
3771 * AdminActions::parse_insplugoptcontent()
3772 * Parse skinvar insplugoptcontent
3777 public function parse_insplugoptcontent()
3779 $option = Admin::getAdminaOption();
3781 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3782 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3785 listplug_plugOptionRow($option);
3792 * AdminActions::parse_iprangeinput()
3793 * Parse skinvar iprangeinput
3798 public function parse_iprangeinput()
3800 if ( requestVar('ip') )
3802 $iprangeVal = Entity::hsc(requestVar('ip'));
3803 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3804 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3805 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3806 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3807 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3811 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3812 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3818 * AdminActions::parse_itemnavlist()
3819 * Parse skinvar itemnavlist
3824 public function parse_itemnavlist()
3826 global $CONF, $manager, $member;
3828 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3829 . " FROM %s, %s, %s, %s"
3830 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3832 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3834 if ( $this->skintype == 'itemlist' )
3837 if ( array_key_exists('blogid', $_REQUEST) )
3839 $blogid = intRequestVar('blogid');
3841 else if ( array_key_exists('itemid', $_REQUEST) )
3843 $itemid = intRequestVar('itemid');
3844 $item = &$manager->getItem($itemid, 1, 1);
3845 $blogid = (integer) $item['blogid'];
3847 $blog =& $manager->getBlog($blogid);
3849 $query .= " AND iblog={$blogid}";
3850 $template['now'] = $blog->getCorrectTime(time());
3852 // non-blog-admins can only edit/delete their own items
3853 if ( !$member->blogAdminRights($blogid) )
3855 $query .= ' AND iauthor = ' . $member->getID();
3858 elseif ( $this->skintype == 'browseownitems' )
3860 $query .= ' AND iauthor = ' . $member->getID();
3862 $template['now'] = time();
3865 // search through items
3866 $search = postVar('search');
3868 if ( !empty($search) )
3870 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3871 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3872 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3875 if ( postVar('start') )
3877 $start = intPostVar('start');
3884 // amount of items to show
3885 if ( postVar('amount') )
3887 $amount = intPostVar('amount');
3891 $amount = (integer) $CONF['DefaultListSize'];
3898 $query .= ' ORDER BY itime DESC'
3899 . " LIMIT {$start},{$amount}";
3901 $template['content'] = 'itemlist';
3903 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3904 $navList->showBatchList('item', $query, 'table', $template);
3909 * AdminActions::parse_itemoptions()
3910 * Parse skinvar itemoptions
3911 * Adds the itemOptions of a plugin to a page
3914 public function parse_itemoptions()
3916 $this->parse_pluginoptions('item');
3921 * AdminActions::parse_itemoptions()
3923 * date change on edit item
3925 * Parse skinvar itemoptions
3926 * Adds the itemOptions of a plugin to a page
3929 public function parse_itemtime($what)
3934 $itemid = intRequestVar('itemid');
3935 $item =& $manager->getItem($itemid, 1, 1);
3937 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3939 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3941 $item['body'] = removeBreaks($item['body']);
3942 $item['more'] = removeBreaks($item['more']);
3945 $contents = array();
3946 if ( requestVar('action') == 'itemedit' )
3950 elseif ( requestVar('action') == 'createitem' )
3953 'contents' => &$contents,
3954 'blog' => &$this->blog
3956 $manager->notify('PreAddItemForm', $data);
3958 $itemtime = getdate($contents['timestamp']);
3959 echo $itemtime[$what];
3964 * AdminActions::parse_jstoolbaroptions()
3965 * Parse skinvar jstoolbaroptions
3970 public function parse_jstoolbaroptions()
3974 _SETTINGS_JSTOOLBAR_NONE,
3975 _SETTINGS_JSTOOLBAR_SIMPLE,
3976 _SETTINGS_JSTOOLBAR_FULL
3980 foreach ( $options as $option )
3982 $text = "<option value=\"%d\"%s>%s</option>\n";
3983 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3984 echo sprintf($text, $i, $extra, $option);
3990 * AdminActions::parse_localeselectoptions()
3991 * Parse skinvar localeselectoptions
3996 public function parse_localeselectoptions()
3998 $locales = i18n::get_available_locale_list();
4000 $memid = intRequestVar('memberid');
4003 $mem = MEMBER::createFromID($memid);
4004 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
4006 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
4010 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
4015 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
4017 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
4021 echo "<option value=\"\">en_Latn_US</option>\n";
4024 foreach ( $locales as $locale )
4026 if ( $locale == 'en_Latn_US' )
4032 if ( $locale == $mem->getLocale() )
4034 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4038 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4043 if ( $locale == i18n::get_current_locale() )
4045 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4049 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4057 * AdminActions::parse_listplugplugoptionrow()
4058 * Parse templatevar listplugplugoptionrow
4060 * @param string $templateName name of template
4063 public function parse_listplugplugoptionrow($templateName = '')
4065 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
4070 * AdminActions::parse_mediadirwarning()
4071 * Parse skinvar mediadirwarning
4076 public function parse_mediadirwarning()
4079 if ( !is_dir($DIR_MEDIA) )
4081 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4083 if ( !is_readable($DIR_MEDIA) )
4085 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4087 if ( !is_writeable($DIR_MEDIA) )
4089 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4095 * AdminActions::parse_movedistselect()
4096 * Parse skinvar movedistselect
4098 public function parse_movedistselect()
4100 $actionType = requestVar('action');
4101 switch ( $actionType )
4104 Admin::selectBlogCategory('destcatid');
4106 case 'batchcategory':
4107 Admin::selectBlog('destblogid');
4110 if ( $this->skintype == 'itemmove' )
4112 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
4113 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
4114 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
4115 Admin::selectBlogCategory('catid', $catid, 10, 1);
4123 * AdminActions::parse_moveitemid()
4124 * Parse skinvar moveitemid
4129 public function parse_moveitemid()
4131 echo intRequestVar('itemid');
4136 * AdminActions::parse_newestcompare()
4137 * Parse skinvar newestcompare
4142 public function parse_newestcompare()
4146 $newestVersion = getLatestVersion();
4147 $newestCompare = str_replace('/', '.', $newestVersion);
4148 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4150 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4152 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4153 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4159 * AdminActions::parse_newmemberselect()
4160 * Parse skinvar newmemberselect
4162 * @param string $templateName name of template to use
4165 public function parse_newmemberselect($templateName = '')
4167 $blogid = intRequestVar('blogid');
4169 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4170 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4171 $res = DB::getResult($query);
4174 foreach ( $res as $row )
4176 $tmem[] = intval($row['tmember']);
4179 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4180 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4182 $template['name'] = 'memberid';
4183 $template['tabindex'] = 10000;
4184 Showlist($query, 'select', $template, $templateName);
4189 * AdminActions::parse_newpluginlist()
4190 * Parse skinvar newpluginlist
4195 public function parse_newpluginlist()
4197 $candidates = $this->newPlugCandidates;
4198 foreach ( $candidates as $name )
4200 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4206 * AdminActions::parse_outputspecialdirs()
4207 * Parse skinvar outputspecialdirs
4209 * @param string $type type of setting for directory
4212 public function parse_outputspecialdirs($type)
4214 global $DIR_MEDIA, $DIR_NUCLEUS;
4219 echo Entity::hsc($DIR_NUCLEUS);
4222 echo Entity::hsc($DIR_MEDIA);
4229 * AdminActions::parse_passrequestvars()
4230 * Parse skinvar passrequestvars
4235 public function parse_passrequestvars()
4237 $passvar = Admin::getAdminpassvar();
4238 $oldaction = postVar('oldaction');
4240 if ( ($oldaction != 'logout')
4241 && ($oldaction != 'login')
4243 && !postVar('customaction') )
4251 * AdminActions::parse_pluginextras()
4252 * Parse skinvar pluginextras
4254 * @param string $type type of plugin context
4257 public function parse_pluginextras($type = 'global')
4263 $id = intRequestVar('memberid');
4264 $mem = MEMBER::createFromID($id);
4265 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4268 $id = intRequestVar('blogid');
4269 $blg = $manager->getBlog($id);
4270 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4274 'GeneralSettingsFormExtras',
4284 * AdminActions::parse_pluginhelp()
4285 * Parse skinvar pluginhelp
4290 public function parse_pluginhelp()
4292 global $manager, $DIR_PLUGINS;
4294 $plugid = intGetVar('plugid');
4295 $plugName = getPluginNameFromPid($plugid);
4296 $plug =& $manager->getPlugin($plugName);
4298 if ( $plug->supportsFeature('HelpPage') > 0 )
4300 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4301 if ( @file_exists($helpfile . 'php') )
4303 @include($helpfile . 'php');
4306 elseif ( @file_exists($helpfile . 'html') )
4308 @include($helpfile . 'html');
4312 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4313 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4318 * AdminActions::parse_pluginlistlist()
4319 * Parse skinvar pluginlistlist
4321 * @param string $templateName name of template to use
4324 public function parse_pluginlistlist($templateName = '')
4326 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4327 $query = sprintf($query, sql_table('plugin'));
4329 $template['content'] = 'pluginlist';
4330 $template['tabindex'] = 10;
4332 Showlist($query, 'table', $template, $templateName);
4338 * AdminActions::parse_pluginoptions()
4339 * Parse skinvar pluginoptions
4341 * @param string $type type of plugin option
4344 public function parse_pluginoptions($type = 'global')
4351 $id = intRequestVar('memberid');
4354 $id = intRequestVar('blogid');
4357 $id = intRequestVar('catid');
4363 Admin::insertPluginOptions($type, $id);
4368 * AdminActions::parse_qmenuaddselect()
4369 * Parse skinvar qmanuaddselect
4371 * @param string $templateName name of template to use
4374 public function parse_qmenuaddselect($templateName = '')
4377 $showAll = requestVar('showall');
4378 if ( $member->isAdmin() && ($showAll == 'yes') )
4380 // Super-Admins have access to all blogs! (no add item support though)
4381 $query = 'SELECT bnumber as value, bname as text'
4382 . ' FROM ' . sql_table('blog')
4383 . ' ORDER BY bname';
4387 $query = 'SELECT bnumber as value, bname as text'
4388 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4389 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4390 . ' ORDER BY bname';
4393 $template['name'] = 'blogid';
4394 $template['tabindex'] = 15000;
4395 $template['extra'] = _QMENU_ADD_SELECT;
4396 $template['selected'] = -1;
4397 $template['shorten'] = 10;
4398 $template['shortenel'] = '';
4399 $template['javascript'] = 'onchange="return form.submit()"';
4401 Showlist($query, 'select', $template, $templateName);
4407 * AdminActions::parse_quickmenu()
4408 * Parse skinvar quickmenu
4410 * @param string $templateName name of template to use
4413 public function parse_quickmenu($templateName = '')
4416 $templates = array();
4417 $template = array();
4418 if ( !empty($templateName) )
4420 $templates = Template::read($templateName);
4422 $pluginExtras = array();
4426 'options' => &$pluginExtras
4429 if ( count($pluginExtras) > 0 )
4431 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4433 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4437 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4439 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4441 $template['head'] = "<ul>\n";
4445 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4447 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4449 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4453 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4455 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4457 $template['foot'] = "</ul>\n";
4461 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4464 $handler = new Actions($this->skintype);
4465 $parser = new PARSER($handler);
4467 $parser->parse($template['title']);
4468 echo $template['head'];
4469 foreach ( $pluginExtras as $aInfo )
4472 'plugadminurl' => Entity::hsc($aInfo['url']),
4473 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4474 'plugadmintitle' => Entity::hsc($aInfo['title']),
4476 echo Template::fill($template['body'], $data);
4478 echo $template['foot'];
4484 * AdminActions::parse_requestblogid()
4485 * Parse skinvar requestblogid
4490 public function parse_requestblogid()
4492 echo intRequestVar('blogid');
4497 * AdminActions::parse_requestiprange()
4498 * Parse skinvar requestiprange
4503 public function parse_requestiprange()
4505 if ( requestVar('iprange') )
4507 echo Entity::hsc(requestVar('iprange'));
4509 elseif ( requestVar('ip') )
4511 echo Entity::hsc(requestVar('ip'));
4517 * AdminActions::parse_selectlocaladminskinfiles()
4518 * Parse skinvar selectlocaladminskinfiles
4523 public function parse_selectlocaladminskinfiles()
4525 global $DIR_SKINS, $manager;
4527 $adminskindir = $DIR_SKINS . 'admin/';
4528 $candidates = SkinImport::searchForCandidates($adminskindir);
4530 foreach ( $candidates as $skinname => $skinfile )
4532 $html = Entity::hsc($skinfile);
4533 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4540 * AdminActions::parse_selectlocalskinfiles()
4541 * Parse skinvar selectlocalskinfiles
4546 public function parse_selectlocalskinfiles()
4550 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4552 foreach ( $candidates as $skinname => $skinfile )
4554 $html = Entity::hsc($skinfile);
4555 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4562 * AdminActions::parse_skineditallowedlist()
4563 * Parse skinvar skineditallowedlist
4565 * @param string $type type of skin
4566 * @param string $templateName name of template
4569 public function parse_skineditallowedlist($type, $templateName = '')
4574 $query = "SELECT bshortname, bname FROM %s;";
4576 'content' => 'shortblognames'
4578 $query = sprintf($query, sql_table('blog'));
4579 Showlist($query, 'table', $show, $templateName);
4582 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4584 'content' => 'shortnames'
4586 $query = sprintf($query, sql_table('template_desc'));
4587 Showlist($query, 'table', $show, $templateName);
4594 * AdminActions::parse_skinielist()
4595 * Parse skinvar skinielist
4597 * @param string $type type of skin
4598 * @param string $templateName name of template to use
4601 public function parse_skinielist($type, $templateName = '')
4603 $templates = array();
4604 if ( $templateName )
4606 $templates = Template::read($templateName);
4608 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4610 $template = $templates['SKINIE_EXPORT_LIST'];
4615 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4616 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4618 . "<td><%expdesc%></td>\n"
4625 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'));
4626 foreach ( $res as $row )
4629 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4630 'expid' => 'skinexp' . $row['sdnumber'],
4631 'expname' => Entity::hsc($row['sdname']),
4632 'expdesc' => Entity::hsc($row['sddesc'])
4634 echo Template::fill($template, $data);
4638 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4639 foreach ( $res as $row )
4642 'typeid' => 'template[' . $row['tdnumber'] . ']',
4643 'expid' => 'templateexp' . $row['tdnumber'],
4644 'expname' => Entity::hsc($row['tdname']),
4645 'expdesc' => Entity::hsc($row['tddesc'])
4647 echo Template::fill($template, $data);
4655 * AdminActions::parse_skinoverview()
4656 * Parse skinvar skinoverview
4658 * @param string $templateName name of template to use
4661 public function parse_skinoverview($templateName = '')
4664 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4665 $query = sprintf($query, sql_table('skin_desc'));
4667 $template['content'] = 'skinlist';
4668 $template['tabindex'] = 10;
4670 Showlist($query, 'table', $template, $templateName);
4675 * AdminActions::parse_skintypehelp()
4676 * Check editing skintypehelp
4681 public function parse_skintypehelp()
4683 $nowSkinType = strtolower(trim(requestVar('type')));
4685 /* TODO: use Skin class */
4686 $regularType = array(
4697 if ( in_array($nowSkinType, $regularType) )
4699 help('skinpart' . $nowSkinType);
4703 help('skinpartspecial');
4709 * AdminActions::parse_specialskinlist()
4710 * Parse skinvar specialskinlist
4712 * @param string $templateName name of template to use
4715 public function parse_specialskinlist($templateName = '')
4717 $templates = array();
4718 if ( $templateName )
4720 $templates = Template::read($templateName);
4723 /* TODO: use Skin class */
4734 $skinid = intRequestVar('skinid');
4735 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4736 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4738 $res = DB::getResult($query);
4739 if ( $res && $res->rowCount() > 0 )
4742 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4744 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4748 $template['head'] = "<ul>\n";
4750 echo Template::fill($template['head'], $data);
4751 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4753 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4754 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4755 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4759 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4763 foreach ( $res as $row )
4766 'tabindex' => $tabstart++,
4767 'skinid' => $skinid,
4768 'skintype' => Entity::hsc(strtolower($row['stype']))
4770 echo Template::fill($template['body'], $data);
4773 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4775 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4779 $template['foot'] = "</ul>\n";
4781 echo Template::fill($template['foot'], $data);
4787 * AdminActions::parse_sprinttext()
4790 * @param string $which
4791 * @param string $val
4794 public function parse_sprinttext($which, $val)
4796 if ( !defined($which) )
4802 $base = constant($which);
4805 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4807 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4809 $met = 'parse_' . $matchies[0];
4813 $arg = trim($args[0], '()');
4814 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4817 if ( method_exists($this, $met) )
4819 $value = call_user_func(array(&$this, $met), $arg);
4823 if ( !isset($value) || empty($value) )
4827 echo sprintf($base, $value);
4832 * AdminActions::parse_systemsettings()
4833 * Parse skinvar systemsettings
4835 * @param string $type type of settings for system
4836 * @param string $templateName name of template to use
4839 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4841 global $member, $CONF, $nucleus;
4843 $member->isAdmin() or Admin::disallow();
4845 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4846 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4853 case 'sqlserverinfo':
4854 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4856 case 'sqlclientinfo':
4857 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4859 case 'magicquotesgpc':
4860 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4862 case 'magicquotesruntime':
4863 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4865 case 'registerglobals':
4866 echo ini_get('register_globals') ? 'On' : 'Off';
4869 $templates = array();
4870 if ( $templateName )
4872 $templates = Template::read($templateName);
4874 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4876 $template = "<tr>\n"
4877 . "<td><%key%></td>\n"
4878 . "<td><%value%></td>\n"
4883 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4886 $gdinfo = gd_info();
4888 foreach ( $gdinfo as $key => $value )
4890 if ( is_bool($value) )
4892 $value = $value ? $enable : $disable;
4896 $value = Entity::hsc($value);
4902 echo Template::fill($template, $data);
4907 phpinfo(INFO_MODULES);
4908 $im = ob_get_contents();
4910 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4912 case 'nucleusversion':
4913 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4915 case 'nucleuspatchlevel':
4916 echo getNucleusPatchLevel();
4922 echo $CONF['ItemURL'];
4924 case 'alertonheaderssent':
4925 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4927 case 'nucleuscodename':
4928 if ( $nucleus['codename'] != '' )
4930 echo ' "' . $nucleus['codename'] . '"';
4933 case 'versioncheckurl':
4934 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4941 * AdminActions::parse_templateoverview()
4942 * Parse skinvar templateoverview
4944 * @param string $templateName name of template to use
4947 public function parse_templateoverview($templateName = '')
4949 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4950 $query = sprintf($query, sql_table('template_desc'));
4952 $template['content'] = 'templatelist';
4953 $template['tabindex'] = 10;
4955 Showlist($query, 'table', $template, $templateName);
4961 * AdminActions::parse_ticket()
4967 public function parse_ticket()
4970 $manager->addTicketHidden();
4975 * AdminActions::parse_versioncheckurl()
4976 * Parse skinvar versioncheckurl
4981 public function parse_versioncheckurl()
4983 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4988 * AdminActions::parse_yrbloglist()
4989 * Parse skinvar yrbloglist
4991 * @param string $templateName name of template to use
4994 public function parse_yrbloglist($templateName = '')
4997 $showAll = requestVar('showall');
4999 if ( $member->isAdmin() && ($showAll == 'yes') )
5001 // Super-Admins have access to all blogs! (no add item support though)
5002 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
5004 . " ORDER BY bnumber;";
5005 $query = sprintf($query, sql_table('blog'));
5009 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
5011 . " WHERE tblog=bnumber and tmember=%d"
5012 . " ORDER BY bnumber;";
5013 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5016 $template['content'] = 'bloglist';
5017 $template['superadmin'] = $member->isAdmin();
5019 $amount = Showlist($query, 'table', $template, $templateName);
5021 if ( ($showAll != 'yes') && ($member->isAdmin()) )
5023 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
5025 $total = DB::getValue($query);
5026 if ( $total > $amount )
5028 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
5034 echo _OVERVIEW_NOBLOGS;
5036 elseif( $amount != 0 )
5038 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
5040 $query = "SELECT ititle, inumber, bshortname"
5042 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
5043 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
5045 $template['content'] = 'draftlist';
5047 $amountdrafts = Showlist($query, 'table', $template, $templateName);
5048 if ( $amountdrafts == 0 )
5050 echo _OVERVIEW_NODRAFTS;
5057 * AdminActions::checkCondition()
5058 * Checks conditions for if statements
5060 * @param string $field type of <%if%>
5061 * @param string $name property of field
5062 * @param string $value value of property
5063 * @return boolean condition
5065 protected function checkCondition($field, $name='', $value = '')
5067 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
5078 $blog =& $manager->getBlog($blogid);
5082 $blogid = getBlogIDFromCatID($catid);
5084 $blog =& $manager->getBlog($blogid);
5086 elseif ( intRequestVar('catid') )
5088 $catid = intRequestVar('catid');
5089 $blogid = getBlogIDFromCatID($catid);
5091 $blog =& $manager->getBlog($blogid);
5098 $condition = ($blog && $this->ifCategory($name, $value));
5101 $condition = ($blog && ($blog->getSetting($name) == $value));
5104 $condition = $member->isLoggedIn();
5107 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5110 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5113 $condition = $member->isLoggedIn() && $member->isAdmin();
5115 case 'allowloginedit':
5116 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5119 $condition = ($itemidnext != '');
5122 $condition = ($itemidprev != '');
5124 case 'archiveprevexists':
5125 $condition = ($archiveprevexists == true);
5127 case 'archivenextexists':
5128 $condition = ($archivenextexists == true);
5131 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5134 $condition = $this->ifHasPlugin($name, $value);
5137 $condition = (Admin::getAdminAction() == $name);
5139 case 'adminoldaction':
5140 $condition = (Admin::getAdminAction() == $name);
5142 case 'addresschange':
5143 $condition = ($this->ifAddresscange());
5145 case 'bechangepass':
5146 $condition = ($this->beChangePassword());
5148 case 'skincandidates':
5149 $condition = ($this->ifSkincandidates());
5152 $condition = requestVar('nameclashes');
5154 case 'existsnewplugin':
5155 $condition = ($this->existsNewPlugin());
5158 $condition = (boolean) ($member->getAutosave() == $value);
5161 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5168 * Actions::_ifHasPlugin()
5169 * hasplugin,PlugName
5170 * -> checks if plugin exists
5171 * hasplugin,PlugName,OptionName
5172 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5173 * hasplugin,PlugName,OptionName=value
5174 * -> checks if the option OptionName from plugin PlugName is set to value
5176 * @param string $name name of plugin
5177 * @param string $value
5180 private function ifHasPlugin($name, $value)
5184 // (pluginInstalled method won't write a message in the actionlog on failure)
5185 if ( $manager->pluginInstalled("NP_{$name}") )
5187 $plugin =& $manager->getPlugin("NP_{$name}");
5188 if ( $plugin != NULL )
5196 list($name2, $value2) = preg_split('#=#', $value, 2);
5197 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5201 else if ( $plugin->getOption($name2) == $value2 )
5212 * Actions::beChangePassword()
5217 private function beChangePassword()
5219 return intRequestVar('bNeedsPasswordChange');
5223 * Actions::ifSkincandidates()
5224 * Checks if a plugin exists and call its doIf function
5230 private function ifSkincandidates()
5233 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5234 return (count($candidates) > 0);
5238 * Actions::ifPlugin()
5239 * Checks if a plugin exists and call its doIf function
5241 * @param string $name name of plugin
5242 * @param string $key
5243 * @param string $value
5246 private function ifPlugin($name, $key = '', $value = '')
5250 $plugin =& $manager->getPlugin("NP_{$name}");
5256 $params = func_get_args();
5257 array_shift($params);
5259 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5263 * AdminActions::ifCategory()
5264 * Different checks for a category
5266 * @param string $key key for information of category
5267 * @param string $value value for information of category
5270 private function ifCategory($key = '', $value='')
5272 global $blog, $catid;
5274 // when no parameter is defined, just check if a category is selected
5275 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5277 return $blog->isValidCategory($catid);
5280 // check category name
5281 if ( $key == 'catname' )
5283 $value = $blog->getCategoryIdFromName($value);
5284 if ($value == $catid)
5286 return $blog->isValidCategory($catid);
5290 // check category id
5291 if (($key == 'catid') && ($value == $catid))
5293 return $blog->isValidCategory($catid);
5300 * AdminActions::ifOnTeam()
5301 * Checks if a member is on the team of a blog and return his rights
5303 * @param string $blogName name of weblog
5306 private function ifOnTeam($blogName = '')
5308 global $blog, $member, $manager;
5310 // when no blog found
5311 if ( ($blogName == '') && !is_object($blog) )
5316 // explicit blog selection
5317 if ($blogName != '')
5319 $blogid = getBlogIDFromName($blogName);
5322 if (($blogName == '') || !$manager->existsBlogID($blogid))
5325 $blogid = $blog->getID();
5327 return $member->teamRights($blogid);
5331 * AdminActions::ifAdmin()
5332 * Checks if a member is admin of a blog
5334 * @param string $blogName name of weblog
5337 private function ifAdmin($blogName = '')
5339 global $blog, $member, $manager;
5341 // when no blog found
5342 if (($blogName == '') && (!is_object($blog)))
5347 // explicit blog selection
5348 if ($blogName != '')
5350 $blogid = getBlogIDFromName($blogName);
5353 if (($blogName == '') || !$manager->existsBlogID($blogid))
5356 $blogid = $blog->getID();
5359 return $member->isBlogAdmin($blogid);
5363 * AdminActions::ifAddresscange()
5364 * Check e-Mail address is changed
5369 private function ifAddresscange()
5371 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5376 $info = MEMBER::getActivationInfo($key);
5381 $mem = MEMBER::createFromId($info->vmember);
5386 if ( $info->vtype == 'addresschange' )
5394 * AdminActions::templateEditRow()
5397 * @param array $template
5398 * @param string $desc
5399 * @param string $name
5400 * @param string $help
5401 * @param integer $tabindex
5402 * @param boolean $big
5403 * @param array $tmplt
5406 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5410 if ( !array_key_exists($name, $template) )
5412 $template[$name] = '';
5420 $tmplt = skinableTEMPLATE::read($tplt);
5424 'description' => $desc,
5425 'help' => empty($help) ? '' : helpHtml('template' . $help),
5428 'tabindex' => $tabindex,
5429 'rows' => $big ? 10 : 5,
5432 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5434 $base['head'] = "</tr>"
5436 . "<td><%description%><%help%></td>\n"
5437 . "<td id=\"td<%count%>\">\n"
5438 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5442 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5445 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5447 $base['tail'] = "</textarea>\n"
5452 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5455 echo TEMPLATE::fill($base['head'], $data);
5456 echo ENTITY::hsc($template[$name]);
5457 echo TEMPLATE::fill($base['tail'], $data);
5465 * AdminActions::customHelp()
5466 * shows a link to custom help file
5469 * @param string $tplName
5470 * @param string $url
5471 * @param string $iconURL
5472 * @param string $alt
5473 * @param string $title
5477 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5479 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5483 * AdminActions::customHelp()
5484 * shows a link to custom help file
5487 * @param string $tplName
5488 * @param string $url
5489 * @param string $iconURL
5490 * @param string $alt
5491 * @param string $title
5495 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5499 $templates = array();
5503 $templates = Template::read($tplName);
5506 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5508 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5512 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5517 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5520 if ( empty($onclick) )
5522 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5524 elseif ( preg_match('#^onclick#', $onclick) )
5526 $onclick = $onclick;
5530 $onclick = 'onclick="' . $onclick . '"';
5535 'helptarget' => $id,
5536 'onclick' => $onclick,
5537 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5539 return Template::fill($template, $data);
5543 * AdminActions::customHelpHtml()
5546 * @param string $tplName
5547 * @param string $url
5548 * @param string $iconURL
5549 * @param string $alt
5550 * @param string $title
5551 * @param string $onclick
5552 * @return string anchor element with help uri
5554 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5558 $templates = array();
5562 $templates = Template::read($tplName);
5564 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5566 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5570 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5573 if ( empty($iconURL) )
5575 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5578 if ( function_exists('getimagesize') )
5580 $size = getimagesize($iconURL);
5581 $width = 'width="' . $size[0] . '" ';
5582 $height = 'height="' . $size[1] . '" ';
5586 'iconurl' => $iconURL,
5588 'height' => $height,
5589 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5590 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5593 $icon = Template::fill($template, $data);
5594 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5596 return $help . $icon;
5600 * AdminActions::input_yesno
5603 * @param $checkedval
5610 * @param $templateName
5613 private function input_yesno($name,
5624 $templates = array();
5625 if ( $templateName )
5627 $templates = Template::read($templateName);
5630 if ( $name == 'admin' )
5632 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5634 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5635 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5636 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5637 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5641 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5646 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5648 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5652 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5654 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5657 if ( !isset($template) )
5659 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5660 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5661 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5662 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5667 $id = Entity::hsc($name);
5668 $id = str_replace('[', '-', $id);
5669 $id = str_replace(']', '-', $id);
5670 $id1 = $id . Entity::hsc($value1);
5671 $id2 = $id . Entity::hsc($value2);
5673 'name' => Entity::hsc($name),
5674 'yesval' => Entity::hsc($value1),
5675 'noval' => Entity::hsc($value2),
5678 'yesvaltext' => $yesval,
5679 'novaltext' => $noval,
5680 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5681 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5682 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5687 return Template::fill($template, $dat);
5691 echo Template::fill($template, $dat);
5697 * AdminActions::existsNewPlugin()
5698 * Check exists new plugin
5701 * @return boolean exists or not
5703 private function existsNewPlugin()
5705 global $DIR_PLUGINS;
5707 $candidates = array();
5708 $files = scandir($DIR_PLUGINS);
5710 foreach ( $files as $file )
5712 if ( preg_match("#^NP_(.*)\.php$#", $file, $matches) )
5714 $name = $matches[1];
5715 $query = "SELECT * FROM %s WHERE pfile=%s;";
5716 $query = sprintf($query, sql_table('plugin'), DB::quoteValue("{NP_{$name}"));
5717 $res = DB::getResult($query);
5719 if ( $res->rowCount() == 0 )
5721 $candidates[] = $name;
5726 $this->newPlugCandidates = $candidates;
5727 return (count($candidates) > 0);