3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2012 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * @license http://nucleuscms.org/license.txt GNU General Public License
14 * @copyright Copyright (C) 2002-2012 The Nucleus Group
15 * @version $Id: AdminActions.php 1661 2012-02-12 11:55:39Z sakamocchi $
18 class AdminActions extends BaseActions
23 * AdminActions::$default_actions
24 * list of whole action names with which this class can deal
26 static private $default_actions = array(
50 * AdminActions::$normal_skin_types
51 * friendly name for wrapped page types
53 static private $normal_skin_types = array(
54 'actionlog' => _ADM_SKPRT_ACTIONLOG,
55 'activate' => _ADM_SKPRT_ACTIVATE,
56 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
57 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
58 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
59 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
60 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
61 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
62 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
63 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
64 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
65 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
66 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
67 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
68 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
69 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
70 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
71 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
72 'banlist' => _ADM_SKPRT_BANLIST,
73 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
74 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
75 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
76 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
77 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
78 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
79 'batchitem' => _ADM_SKPRT_BATCHITEM,
80 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
81 'batchmove' => _ADM_SKPRT_BATCHMOVE,
82 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
83 'batchteam' => _ADM_SKPRT_BATCHTEAM,
84 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
85 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
86 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
87 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
88 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
89 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
90 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
91 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
92 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
93 'createitem' => _ADM_SKPRT_CREATEITEM,
94 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
95 'createaccountinput' => _ADM_SKPRT_CREATEACCOUNTINPUT,
96 'createaccountsuccess' => _ADM_SKPRT_CREATEACCOUNTSUCCESS,
97 'createaccountdisable' => _ADM_SKPRT_CREATEACCOUNTDISALLOWED,
98 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
99 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
100 'forgotpassword' => _ADM_SKPRT_FORGOTPASSWORD,
101 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
102 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
103 'itemedit' => _ADM_SKPRT_ITEMEDIT,
104 'itemlist' => _ADM_SKPRT_ITEMLIST,
105 'itemmove' => _ADM_SKPRT_ITEMMOVE,
106 'manage' => _ADM_SKPRT_MANAGE,
107 'manageteam' => _ADM_SKPRT_MANAGETEAM,
108 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
109 'overview' => _ADM_SKPRT_OVERVIEW,
110 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
111 'pagehead' => _ADM_SKPRT_PAGEHEAD,
112 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
113 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
114 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
115 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
116 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
117 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
118 'skindelete' => _ADM_SKPRT_SKINDELETE,
119 'skinedit' => _ADM_SKPRT_SKINEDIT,
120 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
121 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
122 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
123 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
124 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
125 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
126 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
127 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
128 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
129 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
130 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
131 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT
135 * AdminActions::getNormalSkinTypes()
139 * @return array list of friendly names for page actions
141 static public function getNormalSkinTypes()
143 return self::$normal_skin_types;
147 * AdminActions::__construct()
148 * Constructor for a new Actions object
150 * @param string $type
153 public function __construct($type)
155 // call constructor of superclass first
156 parent::__construct();
159 if ( $type == 'admntemplateoverview' )
161 $this->skintype = 'admintemplateoverview';
165 $this->skintype = $type;
172 * AdminActions::getAvailableActions()
175 * @return array allowed actions for the page type
177 public function getAvailableActions()
179 $extra_actions = array();
181 switch ( $this->skintype )
184 $extra_actions = array(
189 $extra_actions = array(
194 case 'activatesetpwd':
195 $extra_actions = array(
196 /* nothing special */
200 $extra_actions = array(
206 case 'adminerrorpage':
207 $extra_actions = array(
208 /* nothing special */
211 case 'adminskindelete':
212 $extra_actions = array(
216 case 'adminskinedit':
217 $extra_actions = array(
223 case 'adminskinedittype':
224 $extra_actions = array(
227 'allowedskinactions',
228 'skineditallowedlist',
231 case 'adminskiniedoimport':
232 $extra_actions = array(
236 case 'adminskinieimport':
237 $extra_actions = array(
241 case 'adminskinieoverview':
242 $extra_actions = array(
243 'selectlocalskinfiles',
247 case 'adminskinoverview':
248 $extra_actions = array(
252 case 'adminskinremovetype':
253 $extra_actions = array(
257 case 'admintemplatedelete':
258 $extra_actions = array(
259 'editadmintemplateinfo',
261 case 'admintemplateedit':
262 $extra_actions = array(
266 case 'admintemplateoverview':
267 $extra_actions = array(
271 case 'backupoverview':
272 $extra_actions = array(
273 /* nothing special */
276 case 'backuprestore':
277 $extra_actions = array(
278 /* nothing special */
282 $extra_actions = array(
288 case 'banlistdelete':
289 $extra_actions = array(
294 case 'banlistdeleteconfirm':
295 $extra_actions = array(
296 'banlistdeletedlist',
301 $extra_actions = array(
307 case 'batchcategory':
308 $extra_actions = array(
314 $extra_actions = array(
320 $extra_actions = array(
326 $extra_actions = array(
332 $extra_actions = array(
338 $extra_actions = array(
347 $extra_actions = array(
356 $extra_actions = array(
362 case 'blogcommentlist':
363 $extra_actions = array(
370 $extra_actions = array(
386 $extra_actions = array(
390 case 'browseowncomments':
391 $extra_actions = array(
395 case 'browseownitems':
396 $extra_actions = array(
400 case 'categorydelete':
401 $extra_actions = array(
407 $extra_actions = array(
414 case 'commentdelete':
415 $extra_actions = array(
420 $extra_actions = array(
424 case 'createaccountinput':
425 $extra_actions = array(
431 case 'createaccountsuccess':
432 $extra_actions = array(
\r
436 case 'createaccountdisable':
437 $extra_actions = array(
438 /* nothing special */
442 $extra_actions = array(
454 $extra_actions = array(
460 $extra_actions = array(
465 case 'editmembersettings':
466 $extra_actions = array(
469 'localeselectoptions',
471 'defadminskinselect',
472 'defbookmarkletselect',
475 case 'forgotpassword':
476 $extra_actions = array(
477 /* nothing special */
480 case 'itemcommentlist':
481 $extra_actions = array(
487 $extra_actions = array(
494 $extra_actions = array(
506 $extra_actions = array(
513 $extra_actions = array(
519 $extra_actions = array(
520 /* nothing special */
524 $extra_actions = array(
533 $extra_actions = array(
538 $extra_actions = array(
543 $extra_actions = array(
548 $extra_actions = array(
554 $extra_actions = array(
559 case 'pluginoptions':
560 $extra_actions = array(
562 'editplugoptionslist',
566 $extra_actions = array(
569 'configsettingsedit',
570 'configsettingsyesno',
573 'localeselectoptions',
576 'defadminskinselect',
577 'defbookmarkletselect',
581 $extra_actions = array(
586 $extra_actions = array(
591 $extra_actions = array(
598 $extra_actions = array(
601 'allowedskinactions',
602 'skineditallowedlist'
605 case 'skiniedoimport':
606 $extra_actions = array(
611 $extra_actions = array(
615 case 'skinieoverview':
616 $extra_actions = array(
617 'selectlocalskinfiles',
622 $extra_actions = array(
626 case 'skinremovetype':
627 $extra_actions = array(
631 case 'systemoverview':
632 $extra_actions = array(
637 $extra_actions = array(
643 case 'templatedelete':
644 $extra_actions = array(
649 $extra_actions = array(
653 case 'templateoverview':
654 $extra_actions = array(
658 case 'usermanagement':
659 $extra_actions = array(
665 $extra_actions = array(
674 'selectlocalskinfiles',
682 $defined_actions = array_merge(self::$default_actions, $extra_actions);
684 return array_merge($defined_actions, parent::getAvailableActions());
688 * AdminActions::parse_actionloglist()
689 * Parse skinvar actionloglist
691 * @param string $template_name name of template to use
694 public function parse_actionloglist($template_name = '')
696 $query = "SELECT * FROM %s ORDER BY timestamp DESC;";
697 $query = sprintf($query, sql_table('actionlog'));
699 $resource = DB::getResult($query);
700 if ( $resource->rowCount() > 0 )
702 $template['content'] = 'actionlist';
703 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
707 /* TODO: nothing to be shown */
713 * AdminActions::parse_activationmessage()
714 * Parse skinvar activationmessage
716 * @param string $type type of message
717 * @param string $template_name name of template to use
720 public function parse_activationmessage($type, $template_name = '')
722 global $CONF, $manager;
726 if ( !empty($template_name))
728 $template =& $manager->getTemplate($template_name);
731 $key = postVar('ackey');
734 Admin::error(_ERROR_ACTIVATE);
737 $info = MEMBER::getActivationInfo($key);
740 Admin::error(_ERROR_ACTIVATE);
743 $mem =& $manager->getMember($info->vmember);
746 Admin::error(_ERROR_ACTIVATE);
748 switch ( $info->vtype )
751 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
753 $title = $template['ACTIVATE_FORGOT_TITLE'];
757 $title = _ACTIVATE_FORGOT_TITLE;
759 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
761 $text = $template['ACTIVATE_FORGOT_TEXT'];
765 $text = _ACTIVATE_FORGOT_TEXT;
769 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
771 $title = $template['ACTIVATE_REGISTER_TITLE'];
775 $title = _ACTIVATE_REGISTER_TITLE;
777 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
779 $text = $template['ACTIVATE_REGISTER_TEXT'];
783 $text = _ACTIVATE_REGISTER_TEXT;
786 case 'addresschange':
787 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
789 $title = $template['ACTIVATE_CHANGE_TITLE'];
793 $title = _ACTIVATE_CHANGE_TITLE;
795 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
797 $text = $template['ACTIVATE_CHANGE_TEXT'];
801 $text = _ACTIVATE_CHANGE_TEXT;
806 'memberName' => Entity::hsc($mem->getDisplayName()),
807 'realName' => Entity::hsc($mem->getRealName()),
812 echo Template::fill($title, $aVars);
815 echo Template::fill($text, $aVars);
818 echo Entity::hsc($key);
825 * AdminActions::parse_addtickettourl()
826 * Parse skinvar addtickettourl
828 * @param string $url URI for ticket
831 public function parse_addtickettourl($url)
834 $url = $manager->addTicketToUrl($url);
835 echo Entity::hsc($url);
840 * AdminActions::parse_adminbanlist()
841 * Parse skinvar adminbanlist
843 * @param string $template_name name of template to use
846 public function parse_adminbanlist($template_name = '')
848 $blogid = intRequestVar('blogid');
850 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
851 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
853 $resource = DB::getResult($query);
854 if ( $resource->rowCount() > 0 )
856 $template['content'] = 'banlist';
857 $this->parser-parse(showlist($resource, 'table', $template, $template_name));
867 * AdminActions::parse_adminbatchaction()
868 * Parse skinvar adminbatchaction
873 public function parse_adminbatchaction()
875 echo Entity::hsc(requestVar('batchaction'));
880 * AdminActions::parse_adminbatchlist()
881 * Parse skinvar adminbatchlist
883 * @param string $template_name name of template to use
886 public function parse_adminbatchlist($template_name = '')
889 $templates = array();
891 if ( !empty($template_name) )
893 $templates =& $manager->getTemplate($template_name);
896 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
898 $template = '<li><%text(_BATCH_EXECUTING)%> '
899 . '<b><%adminbatchaction%></b> '
900 . '<%batchlisttype%> '
901 . '<b><%batchid%></b>... '
902 . '<b><%batchlistmsg%></b>'
907 $template = $templates['ADMIN_BATCHLIST'];
910 $selected = requestIntArray('batch');
911 $action = requestVar('batchaction');
913 switch ( $this->skintype )
916 $batchlisttype = _BATCH_ONITEM;
917 $deleteaction = 'deleteOneItem';
918 $moveaction = 'moveOneItem';
919 $destid = intRequestVar('destcatid');
922 $batchlisttype = _BATCH_ONCOMMENT;
923 $deleteaction = 'deleteOneComment';
926 $batchlisttype = _BATCH_ONMEMBER;
927 $deleteaction = 'deleteOneMember';
928 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
929 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
930 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
931 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
934 $blogid = intRequestVar('blogid');
935 $batchlisttype = _BATCH_ONTEAM;
936 $deleteaction = 'deleteOneTeamMember';
937 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
938 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
939 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
940 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
942 case 'batchcategory':
943 $batchlisttype = _BATCH_ONCATEGORY;
944 $deleteaction = 'deleteOneCategory';
945 $moveaction = 'moveOneCategory';
946 $destid = intRequestVar('destblogid');
950 // walk over all selectedids and perform action
951 foreach ( $selected as $selectedid )
954 $selectedid = intval($selectedid);
958 if ( $this->skintype != 'batchteam' )
960 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
964 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
968 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
972 DB::execute("UPDATE {$setadminsql} {$selectedid};");
976 // there should always remain at least one super-admin
977 $r = DB::getResult($unsetchksql);
978 if ( $r->rowCount() < 2 )
980 $error = $unseterrmsg;
984 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
988 $error = _BATCH_UNKNOWN . Entity::hsc($action);
992 'batchid' => $selectedid,
993 'batchlisttype' => Entity::hsc($batchlisttype),
994 'adminbatchaction' => Entity::hsc($action),
995 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
998 $this->parser->parse(Template::fill($template, $data));
1005 * AdminActions::parse_adminbloglink()
1006 * Parse skinvar adminbloglink
1008 * @param string $template_name name of template to use
1011 public function parse_adminbloglink($template_name = '')
1014 $blogid = intRequestVar('blogid');
1015 $blog =& $manager->getBlog($blogid);
1016 $templates = array();
1018 if ( !empty($template_name) )
1020 $templates =& $manager->getTemplate($template_name);
1023 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1025 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1029 $template = $templates['ADMIN_BLOGLINK'];
1033 'url' => Entity::hsc($blog->getURL()),
1034 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1035 'blogname' => Entity::hsc($blog->getName())
1038 echo Template::fill($template, $data);
1043 * AdminActions::parse_adminerrormesg()
1044 * Parse skinvar adminerrormesg
1049 public function parse_adminerrormesg()
1054 if ( requestVar('errormessage') )
1056 $message = requestVar('errormessage');
1058 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1060 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1062 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1064 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1066 echo Entity::hsc($message);
1071 * AdminActions::parse_allowedskinactions()
1072 * Parse skinvar allowedskinactions
1077 public function parse_allowedskinactions()
1081 $type = strtolower(trim(requestVar('type')));
1082 $skinid = intRequestVar('skinid');
1084 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
1086 $skin =& $manager->getSkin($skinid);
1091 $skin =& $manager->getSkin($skinid, 'AdminActions');
1092 $tag = 'adminskinvar';
1095 $actions = $skin->getAllowedActionsForType($type);
1098 while ( $current = array_shift($actions) )
1100 echo helplink("{$tag}-{$current}") . "$current</a>\n";
1102 if ( count($actions) != 0 )
1111 * AdminActions::parse_banlistdeletedlist()
1112 * Parse skinvar banlistdeletedlist
1114 * @param string $template_name name of template to use
1117 public function parse_banlistdeletedlist($template_name = '')
1121 $templates = array();
1122 if ( $template_name )
1124 $templates =& $manager->getTemplate($template_name);
1127 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1129 $template = "<li><%blogname%></li>\n";
1133 $template = $templates['BANLIST_DELETED_LIST'];
1136 $deleted = requestArray('delblogs');
1137 foreach ( $deleted as $delblog )
1139 $blog =& $manager->getBlog($delblog);
1141 'blogname' => Entity::hsc($blog->getName())
1143 echo Template::fill($template, $data);
1150 * AdminActions::parse_batchdeletelist()
1151 * Parse skinvar batchdeletelist
1156 public function parse_batchdeletelist()
1158 $selected = requestIntArray('batch');
1161 foreach ( $selected as $select )
1163 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1165 // add hidden vars for team & comment
1166 if ( requestVar('action') == 'batchteam' )
1168 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1170 if ( requestVar('action') == 'batchcomment' )
1172 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1178 * AdminActions::parse_defadminskinselect()
1179 * Parse skinvar defadminskinselect
1181 * @param string $template_name name of template to use
1184 public function parse_defadminskinselect($template_name)
1186 global $CONF, $action, $manager;
1188 if ( $action == 'editmembersettings' )
1191 $default = $member->adminskin;
1193 elseif ( $action == 'memberedit' )
1195 $mem = $manager->getMember(intRequestVar('memberid'));
1196 $default = $mem->adminskin;
1200 $default = $CONF['AdminSkin'];
1203 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1204 $query = sprintf($query, sql_table('skin_desc'));
1206 'name' => 'adminskin',
1207 'tabindex' => 10080,
1208 'selected' => $default
1211 if ( $this->skintype != 'settingsedit' )
1213 $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1216 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1221 * AdminActions::parse_defbookmarkletselect()
1222 * Parse skinvar defbookmarkletselect
1224 * @param string $template_name name of template to use
1227 public function parse_defbookmarkletselect($template_name)
1229 global $CONF, $action, $manager;
1231 if ( $action == 'editmembersettings' )
1234 $default = $member->bookmarklet;
1236 elseif ( $action == 'memberedit' )
1238 $mem = $manager->getMember(intRequestVar('memberid'));
1239 $default = $mem->bookmarklet;
1243 $default = $CONF['BookmarkletSkin'];
1246 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1247 $query = sprintf($query, sql_table('skin_desc'));
1250 'name' => 'bookmarklet',
1251 'tabindex' => 10085,
1252 'selected' => $default
1255 if ( $this->skintype != 'settingsedit' )
1257 $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1260 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1265 * AdminActions::parse_batchdeletetype()
1266 * Parse skinvar batchdeletetype
1271 public function parse_batchdeletetype()
1273 echo Entity::hsc(requestVar('action'));
1278 * AdminActions::parse_batchmovebtn()
1279 * Parse skinvar batchmovebtn
1284 public function parse_batchmovebtn()
1286 $actionType = requestVar('action');
1287 switch ( $actionType )
1292 case 'batchcategory':
1300 * AdminActions::parse_batchmovelist()
1301 * Parse skinvar batchmovelist
1306 public function parse_batchmovelist()
1308 $selected = requestIntArray('batch');
1310 foreach ( $selected as $select )
1312 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1319 * AdminActions::parse_batchmovetitle()
1320 * Parse skinvar batchmovetitle
1325 public function parse_batchmovetitle()
1327 $actionType = requestVar('action');
1328 switch ( $actionType )
1333 case 'batchcategory':
1334 echo _MOVECAT_TITLE;
1341 * AdminActions::parse_batchmovetype()
1342 * Parse skinvar batchmovetype
1347 public function parse_batchmovetype()
1349 echo Entity::hsc(requestVar('action'));
1354 * AdminActions::parse_blogcatlist()
1355 * Parse skinvar blogcatlist
1360 public function parse_blogcatlist($template_name = '')
1363 $blogid = intRequestVar('blogid');
1364 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1365 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1367 $resource = DB::getResult($query);
1368 if ( $resource->rowCount() > 0 )
1370 $template['content'] = 'categorylist';
1371 $template['tabindex'] = 200;
1372 $this->parser->parse(listplug_batchlist('category', $resource, 'table', $template, $template_name));
1376 /* TODO: nothing to be shown */
1378 $resource->closeCursor();
1384 * AdminActions::parse_blogid()
1385 * Parse skinvar blogid
1390 public function parse_blogid()
1392 echo intRequestVar('blogid');
1397 * AdminActions::parse_blognotifysetting()
1398 * Parse skinvar blognotifysetting
1403 public function parse_blognotifysetting($type)
1406 $blogid = intRequestVar('blogid');
1407 $blog =& $manager->getBlog($blogid);
1412 if ( !$blog->notifyOnComment() )
1418 if ( !$blog->notifyOnVote() )
1424 if ( !$blog->notifyOnNewItem() )
1430 echo ' checked="checked"';
1435 * AdminActions::parse_blogsetting()
1436 * Parse skinvar blogsetting
1438 * @param string $which name of weblog setting
1441 public function parse_blogsetting($which)
1443 echo $this->parse_getblogsetting($which);
1448 * AdminActions::parse_blogsettingyesno()
1449 * Parse skinvar blogsettingyesno
1451 * @param string $type type of weblog setting
1452 * @param string $template_name name of template to use
1455 public function parse_blogsettingyesno($type, $template_name = '')
1459 $blogid = intRequestVar('blogid');
1460 $blog =& $manager->getBlog($blogid);
1464 case 'convertbreaks':
1465 $checkedval = $blog->convertBreaks();
1468 case 'allowpastposting':
1469 $checkedval = $blog->allowPastPosting();
1473 $checkedval = $blog->commentsEnabled();
1477 $checkedval = $blog->isPublic();
1481 $checkedval = $blog->emailRequired();
1485 $checkedval = $blog->getSearchable();
1489 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $template_name);
1494 * AdminActions::parse_blogteamlist()
1495 * Parse skinvar blogteamlist
1497 * @param string $template_name name of template to use
1500 public function parse_blogteamlist($template_name = '')
1503 $blogid = intRequestVar('blogid');
1504 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1506 . "WHERE tmember=mnumber AND tblog= %d";
1507 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1509 $resource = DB::getResult($query);
1510 if ( $resource->rowCount() > 0 )
1512 $template['content'] = 'teamlist';
1513 $template['tabindex'] = 10;
1515 $this->parser->parse(listplug_batchlist('team', $resource, 'table', $template, $template_name));
1521 $resource->closeCursor();
1527 * AdminActions::parse_blogteammembers()
1528 * Parse skinvar blogteammembers
1533 public function parse_blogteammembers()
1535 $blogid = intRequestVar('blogid');
1536 $query = "SELECT mname, mrealname "
1538 . "WHERE mnumber=tmember AND tblog=%d;";
1539 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1540 $res = DB::getResult($query);
1541 $memberNames = array();
1542 foreach ( $res as $row )
1544 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1546 echo implode(',', $memberNames);
1550 * AdminActions::parse_blogtime()
1551 * Parse skinvar blogtime
1553 * @param string $type type of time
1554 * @param string $format format for time expression
1555 * @param integer $offset offset of time
1558 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1562 if ( $type != 'blogtime' )
1564 /* return server time */
1565 $timestamp = time() + $offset;
1569 $bid = intRequestVar('blogid');
1570 $b =& $manager->getBlog($bid);
1571 $timestamp = $b->getCorrectTime() + $offset;
1574 echo i18n::formatted_datetime($format, $timestamp);
1579 * AdminActions::parse_bookmarkletadmin()
1580 * Parse skinvar bookmarkletadmin
1585 public function parse_bookmarkletadmin()
1589 $blogid = intRequestVar('blogid');
1591 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1596 * AdminActions::parse_categories()
1597 * Parse skinvar categories
1599 * create category dropdown box
1601 * @param string $type name of setting for category
1604 public function parse_categories($startidx = 0)
1608 if ( !array_key_exists('catid', Admin::$contents) || empty(Admin::$contents['catid']) )
1610 $catid = Admin::$blog->getDefaultCategory();
1614 $catid = Admin::$contents['catid'];
1617 $this->selectBlog('catid', 'category', $catid, $startidx, 1, Admin::$blog->getID());
1623 * AdminActions::parse_categorysetting()
1624 * Parse skinvar categorysetting
1626 * @param string $type type in category setting
1629 public function parse_categorysetting($type)
1631 $catid = intRequestVar('catid');
1632 if ( $type == 'id' )
1637 $blogid = intRequestVar('blogid');
1638 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1639 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1640 $row = DB::getRow($query);
1642 if ( $type != 'name' )
1644 echo Entity::hsc($row['cdesc']);
1648 echo Entity::hsc($row['cname']);
1655 * AdminActions::parse_codename()
1656 * Parse templatevar codename
1662 public function parse_checkedonval($value, $name)
1667 $itemid = intRequestVar('itemid');
1668 $item =& $manager->getItem($itemid, 1, 1);
1672 $blog =& $manager->getBlog($item['blogid']);
1674 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1676 $item['body'] = removeBreaks($item['body']);
1677 $item['more'] = removeBreaks($item['more']);
1681 $contents = array();
1682 if ( requestVar('action') == 'itemedit' )
1686 if ( !isset($contents[$name]) )
1688 $contents[$name] = '';
1690 if ($contents[$name] == $value)
1692 echo 'checked="checked"';
1698 * AdminActions::parse_codename()
1699 * Parse templatevar codename
1704 * TODO: is this need???
1706 public function parse_codename()
1709 echo $nucleus['codename'];
1714 * AdminActions::parse_commentnavlist()
1715 * Parse skinvar commentnavlist
1720 public function parse_commentnavlist()
1722 global $CONF, $manager, $member;
1725 if ( postVar('start') )
1727 $start = intPostVar('start');
1734 // amount of items to show
1735 if ( postVar('amount') )
1737 $amount = intPostVar('amount');
1741 $amount = (integer) $CONF['DefaultListSize'];
1747 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1749 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
1751 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1753 if ( $this->skintype == 'itemcommentlist' )
1755 $itemid = intRequestVar('itemid');
1756 $query .= " citem={$itemid}";
1757 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1759 $nonComments = _NOCOMMENTS;
1761 elseif ( $this->skintype == 'browseowncomments' )
1764 $query .= ' cmember=' . $member->getID();
1765 $template['canAddBan'] = 0;
1767 $nonComments = _NOCOMMENTS_YOUR;
1769 elseif ( $this->skintype == 'blogcommentlist' )
1772 $query .= ' cblog=' . intRequestVar('blogid');
1773 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1774 $bid = intRequestVar('blogid');
1775 $nonComments = _NOCOMMENTS_BLOG;
1778 $search = postVar('search');
1779 if ( !empty($search) )
1781 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
1784 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1786 $resource = DB::getResult($query);
1787 if ( $resource->rowCount() > 0 )
1789 $template['action'] = $this->skintype;
1790 $template['start'] = $start;
1791 $template['amount'] = $amount;
1792 $template['minamount'] = 0;
1793 $template['maxamount'] = 1000;
1794 $template['blogid'] = $bid;
1795 $template['search'] = $search;
1796 $template['itemid'] = $itemid;
1798 $template['content'] = 'commentlist';
1800 $this->parser->parse(listplug_navlist('comment', $resource, 'table', $template));
1804 /* TODO: nothing to be shown */
1806 $resource->closeCursor();
1812 * AdminActions::parse_configsettingsedit()
1813 * Parse skinvar configsettingsedit
1815 * @param string $type type of global configuration
1818 public function parse_configsettingsedit($type)
1823 case 'DefaultListSize':
1824 if ( !array_key_exists('DefaultListSize', $CONF) )
1826 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1827 $query = sprintf($query, sql_table('config'));
1828 DB::execute($query);
1829 $CONF['DefaultListSize'] = 10;
1831 elseif ( intval($CONF['DefaultListSize']) < 1 )
1833 $CONF['DefaultListSize'] = 10;
1835 echo intval($CONF['DefaultListSize']);
1837 case 'SessionCookie':
1838 $value = $CONF['SessionCookie'];
1839 $txt1 = _SETTINGS_COOKIESESSION;
1840 $txt2 = _SETTINGS_COOKIEMONTH;
1841 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1844 $value = $CONF['URLMode'];
1845 $txt1 = _SETTINGS_URLMODE_NORMAL;
1846 $txt2 = _SETTINGS_URLMODE_PATHINFO;
1847 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1850 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1852 echo Entity::hsc($CONF[$type]);
1860 * AdminActions::parse_configsettingsyesno()
1861 * Parse skinvar configsettingsyesno
1863 * @param string $type type of global setting
1864 * @param integer $tabindex tabindex attribute of input element
1867 public function parse_configsettingsyesno($type, $tabindex)
1870 if ( array_key_exists($type, $CONF) )
1872 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1878 * AdminActions::parse_contents()
1879 * Parse skinvar contents
1881 * @param string $which part for item
1884 public function parse_contents($which)
1886 if ( !array_key_exists($which, Admin::$contents) )
1888 Admin::$contents[$which] = '';
1890 echo Entity::hsc(Admin::$contents[$which]);
1894 * AdminActions::parse_currenttime()
1895 * Parse skinvar currenttime
1897 * @param string $what
1900 public function parse_currenttime($what)
1902 $nu = getdate(Admin::$blog->getCorrectTime());
1907 * AdminActions::parse_customhelplink()
1908 * Parse skinvar customhelplink
1910 * @param string $topic name of topic
1911 * @param string $tplName name of template
1912 * @param string $url string as URI
1913 * @param string $iconURL string as URI for icon
1914 * @param string $alt alternative text for image element
1915 * @param string $title title for anchor element
1918 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1920 $this->customHelp($topic, $url, $iconURL);
1925 * AdminActions::parse_date()
1926 * Parse skinvar date
1928 public function parse_date($format = 'c')
1930 global $CONF, $manager;
1931 /* TODO: offset is based on i18n::get_current_locale()? */
1932 echo i18n::formatted_datetime($format, time());
1937 * AdminActions::parse_normalskinlist()
1938 * Parse skinvar defaultadminskintypes
1940 * @param string $template_name name of template
1943 public function parse_normalskinlist($template_name = '')
1945 global $CONF, $manager;
1947 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
1949 $skin =& $manager->getSkin($CONF['BaseSkin']);
1950 /* TODO: removeaction? */
1951 $template['editaction'] = 'skinedittype';
1955 $skin =& $manager->getSkin($CONF['AdminSkin'], 'AdminActions');
1956 $template['editaction'] = 'adminskinedittype';
1957 /* TODO: removeaction? */
1960 $temporary = $skin->getNormalTypes();
1961 $normal_skintype = array();
1962 foreach ( $temporary as $type => $label )
1964 $normal_skintype[] = array(
1965 'skintype' => $type,
1966 'skintypename' => $label
1970 $template['tabindex'] = 10;
1971 $template['skinid'] = intRequestVar('skinid');
1972 $template['skinname'] = $skin->getName();
1973 $this->parser->parse(showlist($normal_skintype, 'list_normalskinlist', $template, $template_name));
1979 * AdminActions::parse_defblogselect()
1980 * Parse skinvar defblogselect
1982 * @param string $template_name name of template
1985 public function parse_defblogselect($template_name = '')
1989 $query = "SELECT bname as text, bnumber as value FROM %s;";
1990 $query = sprintf($query, sql_table('blog'));
1992 $template['name'] = 'DefaultBlog';
1993 $template['selected'] = $CONF['DefaultBlog'];
1994 $template['tabindex'] = 10;
1995 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2001 * AdminActions::parse_defcatselect()
2002 * Parse skinvar defcatselect
2004 * @param string $template_name name of template
2007 public function parse_defcatselect($template_name = '')
2011 $blogid = intRequestVar('blogid');
2012 $blog =& $manager->getBlog($blogid);
2014 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2015 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2017 $template['name'] = 'defcat';
2018 $template['selected'] = $blog->getDefaultCategory();
2019 $template['tabindex'] = 110;
2021 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2027 * AdminActions::parse_defskinselect()
2028 * Parse skinvar defskinselect
2030 * @param string $type type of skin
2031 * @param string $template_name name of template
2034 public function parse_defskinselect($type = 'blog', $template_name = '')
2036 global $CONF, $manager, $member;
2038 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2040 $blogid = intRequestVar('blogid');
2043 $template['selected'] = $CONF['BaseSkin'];
2047 $blog =& $manager->getBlog($blogid);
2048 $template['selected'] = $blog->getDefaultSkin();
2051 if ( $type != 'blog' )
2053 $template['name'] = 'BaseSkin';
2057 $template['name'] = 'defskin';
2060 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2064 /* TODO: member object will have its own adminskin id */
2065 $template['selected'] = $CONF['AdminSkin'];
2066 $template['name'] = 'AdminSkin';
2067 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
2070 $query = sprintf($query, sql_table('skin_desc'));
2071 $template['tabindex'] = 50;
2073 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2079 * AdminActions::parse_deletecomment()
2080 * Parse skinvar deletecomment
2082 * @param string $type type of infomation for comment
2085 public function parse_deletecomment($type = 'id')
2087 $commentid = intRequestVar('commentid');
2088 $comment = COMMENT::getComment($commentid);
2093 echo intRequestVar('commentid');
2096 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2098 echo $comment['member'];
2102 echo $comment['user'];
2106 $body = strip_tags($comment['body']);
2107 echo Entity::hsc(shorten($body, 300, '...'));
2113 * AdminActions::parse_deleteitembody()
2114 * Parse skinvar deleteitembody
2119 public function parse_deleteitembody()
2123 $itemid = intRequestVar('itemid');
2124 $item =& $manager->getItem($itemid, 1, 1);
2126 $body = strip_tags($item['body']);
2128 echo Entity::hsc(shorten($body, 300, '...'));
2134 * AdminActions::parse_deleteitemid()
2135 * Parse skinvar deleteitemid
2140 public function parse_deleteitemid()
2142 echo (integer) intRequestVar('itemid');
2147 * AdminActions::parse_deleteitemtitle()
2148 * Parse skinvar deleteitemtitle
2153 public function parse_deleteitemtitle()
2157 $itemid = intRequestVar('itemid');
2158 $item =& $manager->getItem($itemid, 1, 1);
2160 echo Entity::hsc(strip_tags($item['title']));
2166 * AdminActions::parse_editcomment()
2167 * Parse skinvar editcomment
2169 * @param string $type type of comment setting
2172 public function parse_editcomment($type = 'id')
2176 $comment = Admin::$contents;
2181 echo intRequestVar('commentid');
2184 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2186 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2190 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2194 echo date("Y-m-d @ H:i", $comment['timestamp']);
2197 $comment['body'] = str_replace('<br />', '', $comment['body']);
2198 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2199 echo $comment['body'];
2202 echo $comment['userid'];
2205 echo $comment['userid'];
2208 if ( array_key_exists($type, $comment) && !empty($comment[$type]) )
2210 echo $comment[$type];
2218 * AdminActions::parse_editdesturl()
2219 * Parse skinvar editdesturl
2221 public function parse_editdesturl()
2223 if ( requestVar('desturl') )
2225 echo Entity::hsc(requestVar('desturl'));
2231 * AdminActions::parse_editmemberlist()
2232 * Parse skinvar editmemberlist
2234 * @param string $template_name name of template
2237 public function parse_editmemberlist($template_name = '')
2240 // show list of members with actions
2241 $query = 'SELECT * FROM %s;';
2242 $query = sprintf($query, sql_table('member'));
2244 $resource = DB::getResult($query);
2245 if ( $resource->rowCount() > 0 )
2247 $template['content'] = 'memberlist';
2248 $template['tabindex'] = 10;
2250 $this->parser->parse(listplug_batchlist('member', $resource, 'table', $template, $template_name));
2256 $resource->closeCursor();
2262 * AdminActions::parse_editmember()
2263 * Parse skinvar editmember
2265 * @param string $type type of information for member
2266 * @return string $tempateName name of template to use
2269 public function parse_editmember($type = 'id', $template_name = '')
2271 global $CONF, $manager, $member;
2273 $memberid = intRequestVar('memberid');
2274 $mem =& $manager->getMember($memberid);
2279 echo intRequestVar('memberid');
2282 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2284 echo Entity::hsc($mem->getDisplayName());
2288 $dispName = Entity::hsc($mem->getDisplayName());
2289 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2291 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2300 echo Entity::hsc($mem->getRealName());
2303 echo Entity::hsc($mem->getEmail());
2306 echo Entity::hsc($mem->getURL());
2309 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $template_name);
2312 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $template_name);
2315 echo Entity::hsc($mem->getNotes());
2318 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $template_name);
2327 * AdminActions::parse_editpluginfo()
2328 * Parse skinvar editpluginfo
2330 * @param string $type type of plugin info
2333 public function parse_editpluginfo($type)
2337 $pid = intRequestVar('plugid');
2344 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2351 * AdminActions::parse_editplugoptionslist()
2352 * Parse skinvar editplugoptionslist
2354 * @param string $template_name name of template
2357 public function parse_editplugoptionslist($template_name = '')
2361 $pid = intRequestVar('plugid');
2362 $aOptions = array();
2365 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2366 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2367 $resource = DB::getResult($query);
2369 foreach ( $resource as $row )
2371 $aOIDs[] = $row['oid'];
2372 $aOptions[$row['oid']] = array(
2373 'oid' => $row['oid'],
2374 'value' => $row['odef'],
2375 'name' => $row['oname'],
2376 'description' => $row['odesc'],
2377 'type' => $row['otype'],
2378 'typeinfo' => $row['oextra'],
2383 // fill out actual values
2384 if ( count($aOIDs) > 0 )
2386 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2387 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2389 $result = DB::getResult($query);
2390 foreach ( $result as $row )
2392 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2398 'context' => 'global',
2400 'options' => &$aOptions
2402 $manager->notify('PrePluginOptionsEdit', $data);
2404 if ( sizeof($aOptions) > 0 )
2406 $template['content'] = 'plugoptionlist';
2407 $this->parser->parse(showlist($aOptions, 'table', $template, $template_name));
2411 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2417 * AdminActions::parse_editskin()
2418 * Parse skinvar editskin
2420 * @param string $type type of skin
2423 public function parse_editskin($type = 'id')
2427 $skinid = intRequestVar('skinid');
2429 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2431 $skin =& $manager->getSKIN($skinid);
2435 $skin =& $manager->getSKIN($skinid, 'AdminActions');
2441 echo intRequestVar('skinid');
2444 echo Entity::hsc($skin->getName());
2447 echo Entity::hsc($skin->getDescription());
2450 echo Entity::hsc($skin->getContentType());
2453 echo Entity::hsc($skin->getIncludePrefix());
2456 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2464 * AdminActions::parse_editskintype()
2465 * Parse skinvar editskintype
2467 * @param string $type name of type for skin type
2470 public function parse_editskintype($stype = 'id')
2474 static $skin = NULL;
2475 static $types = array();
2477 if ( $skin == NULL )
2479 $skinid = intRequestVar('skinid');
2481 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2483 $skin =& $manager->getSkin($skinid);
2487 $skin =& $manager->getSkin($skinid, 'AdminActions');
2490 $types = $skin->getNormalTypes();
2493 $type = strtolower(trim(requestVar('type')));
2498 echo $skin->getID();
2501 echo Entity::hsc($skin->getName());
2504 echo Entity::hsc($skin->getDescription());
2507 echo Entity::hsc($skin->getContentType());
2510 echo Entity::hsc($skin->getContentFromDB($type));
2513 if ( !array_key_exists($type, $types) )
2515 $skinType = ucfirst($type);
2519 $skinType = $types[$type];
2521 echo Entity::hsc($skinType);
2524 echo Entity::hsc($type);
2527 echo Entity::hsc($skin->getIncludePrefix());
2530 if ( !$skin->getIncludeMode() != 'skindir' )
2532 $incMode = _PARSER_INCMODE_NORMAL;
2536 $incMode = _PARSER_INCMODE_SKINDIR;
2538 echo Entity::hsc($incMode);
2547 * AdminActions::parse_adminurl()
2548 * Parse skinvar adminurl
2549 * (shortcut for admin url)
2554 public function parse_adminurl()
2556 $this->parse_sitevar('adminurl');
2561 * AdminActions::parse_edittemplateinfo()
2562 * Parse skinvar edittemplateinfo
2564 * @param string $format format to output
2565 * @param string $typedesc type of template
2566 * @param string $typename type name of template
2567 * @param string $help help text
2568 * @param string $tabindex index value for tabindex attribute of input element
2569 * @param string $big textarea size
2570 * @param string $tplt name of template to be filled
2573 public function parse_edittemplateinfo($format, $typedesc = '', $typename = '', $help = '', $tabindex = 0, $big = 0, $template_name = '')
2577 static $name = NULL;
2578 static $desc = NULL;
2582 $id = intRequestVar('templateid');
2585 if ( $name == NULL )
2587 $name = Template::getNameFromId($id);
2590 if ( $desc == NULL )
2592 $desc = Template::getDesc($id);
2595 $template =& $manager->getTemplate($name);
2603 echo Entity::hsc($name);
2606 echo Entity::hsc($desc);
2608 case 'extratemplate':
2610 $pluginfields = array();
2611 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2613 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2617 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
2620 foreach ( $pluginfields as $ptkey => $ptvalue )
2625 $tmplt =& $manager->getTemplate($desc);
2628 /* extra plugin field */
2629 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2632 . "<th colspan=\"2\"><%explugtplname%></th>\n"
2637 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2640 'explugtplname' => Entity::hsc($ptkey)
2642 echo Template::fill($base, $data);
2644 foreach ( $ptvalue as $ptname => $ptdesc )
2646 if ( !array_key_exists($ptname, $template) )
2652 $content = $template[$ptname];
2654 $this->parser->parse(listplug_templateEditRow($content, $ptdesc, $ptname, $help, $tabidx++, $big, $template_name));
2660 $typedesc = defined($typedesc) ? constant($typedesc) : $typedesc;
2661 $typename = defined($typename) ? constant($typename) : $typename;
2663 if ( !array_key_exists($typename, $template) )
2669 $content = $template[$typename];
2671 $this->parser->parse(listplug_templateEditRow($content, $typedesc, $typename, $help, $tabindex, $big, $template_name));
2679 * AdminActions::parse_eventformextra()
2680 * Parse skinvar eventformextra
2682 * @param string $type name of type for event form extra
2685 public function parse_eventformextra($type = 'activation')
2694 $key = requestVar('ackey');
2697 Admin::error(_ERROR_ACTIVATE);
2699 $info = MEMBER::getActivationInfo($key);
2702 Admin::error(_ERROR_ACTIVATE);
2704 $mem =& $manager->getMember($info->vmember);
2707 Admin::error(_ERROR_ACTIVATE);
2710 'type' => 'activation',
2714 case 'membermailform-notloggedin':
2715 $data = array('type' => 'membermailform-notloggedin',);
2718 $manager->notify('FormExtra', $data);
2723 * AdminActions::parse_extrahead()
2724 * Parse skinvar extrahead
2726 public function parse_extrahead()
2731 'extrahead' => &Admin::$extrahead,
2732 'action' => Admin::$action
2735 $manager->notify('AdminPrePageHead', $data);
2737 $this->parser->parse(Admin::$extrahead);
2742 * AdminActions::parse_member()
2743 * Parse skinvar member
2744 * (includes a member info thingie)
2746 * @param string $what which memberdata is needed
2749 public function parse_member($what)
2751 global $memberinfo, $member, $CONF;
2753 // 1. only allow the member-details-page specific variables on member pages
2754 if ( $this->skintype == 'member' )
2759 echo Entity::hsc($memberinfo->getDisplayName());
2762 echo Entity::hsc($memberinfo->getRealName());
2765 echo Entity::hsc($memberinfo->getNotes());
2768 echo Entity::hsc($memberinfo->getURL());
2771 echo Entity::hsc($memberinfo->getEmail());
2774 echo Entity::hsc($memberinfo->getID());
2779 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2780 if ( $member->isLoggedIn() )
2785 echo $member->getDisplayName();
2787 case 'yourrealname':
2788 echo $member->getRealName();
2791 echo $member->getNotes();
2794 echo $member->getURL();
2797 echo $member->getEmail();
2800 echo $member->getID();
2802 case 'yourprofileurl':
2803 if ( $CONF['URLMode'] == 'pathinfo' )
2805 echo Link::create_member_link($member->getID());
2809 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
2818 * AdminActions::parse_version()
2819 * Parse skinvar version
2820 * (include nucleus versionnumber)
2825 public function parse_version()
2828 echo 'Nucleus CMS ' . $nucleus['version'];
2833 * AdminActions::parse_sitevar()
2834 * Parse skinvar sitevar
2835 * (include a sitevar)
2837 * @param string $which
2840 public function parse_sitevar($which)
2846 echo $CONF['IndexURL'];
2849 echo $CONF['SiteName'];
2852 echo $CONF['AdminEmail'];
2855 echo $CONF['AdminURL'];
2862 * AdminActions::parse_actionurl()
2868 public function parse_actionurl()
2871 echo Entity::hsc($CONF['ActionURL']);
2876 * AdminActions::parse_getblogsetting()
2877 * Parse skinvar getblogsetting
2879 public function parse_getblogsetting($which)
2881 global $blog, $manager;
2887 elseif ( $bid = intRequestVar('blogid') )
2889 $b =& $manager->getBlog($bid);
2899 return Entity::hsc($b->getID());
2902 return Entity::hsc($b->getURL());
2905 return Entity::hsc($b->getName());
2908 return Entity::hsc($b->getDescription());
2911 return Entity::hsc($b->getShortName());
2913 case 'notifyaddress':
2914 return Entity::hsc($b->getNotifyAddress());
2917 return Entity::hsc($b->getMaxComments());
2920 return Entity::hsc($b->getUpdateFile());
2923 return Entity::hsc($b->getTimeOffset());
2930 * AdminActions::parse_geteditpluginfo()
2931 * Parse skinvar geteditpluginfo
2933 * @param string $type name of setting for edit plugin info
2936 public function parse_geteditpluginfo($type)
2939 $pid = intRequestVar('plugid');
2946 return Entity::hsc($manager->getPluginNameFromPid($pid));
2953 * AdminActions::parse_getmember()
2954 * Parse skinvar getmember
2955 * (includes a member info thingie)
2957 * @param string $what name of setting for member
2960 public function parse_getmember($what)
2962 global $memberinfo, $member;
2963 // 1. only allow the member-details-page specific variables on member pages
2964 if ( $this->skintype == 'member' )
2969 return Entity::hsc($memberinfo->getDisplayName());
2972 return Entity::hsc($memberinfo->getRealName());
2975 return Entity::hsc($memberinfo->getNotes());
2978 return Entity::hsc($memberinfo->getURL());
2981 return Entity::hsc($memberinfo->getEmail());
2984 return Entity::hsc($memberinfo->getID());
2988 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2989 if ( $member->isLoggedIn() )
2994 return $member->getDisplayName();
2996 case 'yourrealname':
2997 return $member->getRealName();
3000 return $member->getNotes();
3003 return $member->getURL();
3006 return $member->getEmail();
3009 return $member->getID();
3017 * AdminActions::parse_headmessage()
3018 * Parse skinvar headmessage
3023 public function parse_headmessage()
3025 if ( !empty(Admin::$headMess) )
3027 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3033 * AdminActions::parse_helplink()
3034 * Parse skinvar helplink
3036 * @param string $topic name of topic for help
3039 public function parse_helplink($topic = '')
3041 if ( !empty($topic) )
3049 * AdminActions::parse_helpplugname()
3050 * Parse skinvar helpplugname
3055 public function parse_helpplugname()
3057 $plugid = intGetVar('plugid');
3058 Entity::hsc($manager->getPluginNameFromPid($plugid));
3063 * AdminActions::parse_ilistaddnew()
3064 * Parse skinvar ilistaddnew
3069 public function parse_ilistaddnew()
3071 $blogid = intRequestVar('blogid');
3072 if ( intPostVar('start') == 0 )
3074 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3080 * AdminActions::parse_importskininfo()
3081 * Parse skinvar importskininfo
3083 * @param string $type name of information for imported skin
3086 public function parse_importskininfo($type)
3091 echo Entity::hsc(Admin::$contents['skininfo']);
3094 $dataArr = Admin::$contents['skinnames'];
3095 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3098 $dataArr = Admin::$contents['tpltnames'];
3099 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3102 $dataArr = Admin::$contents['skinclashes'];
3103 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3106 $dataArr = Admin::$contents['tpltclashes'];
3107 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3110 echo Entity::hsc(Admin::$contents['skinfile']);
3113 echo Entity::hsc(Admin::$contents['mode']);
3120 * AdminActions::parse_init()
3121 * some init stuff for all forms
3126 public function parse_init()
3131 if ( requestVar('action') == 'itemedit' )
3133 $authorid = Admin::$contents['authorid'];
3136 Admin::$blog->insertJavaScriptInfo($authorid);
3141 * AdminActions::parse_inputyesno()
3142 * Parse skinvar inputyesno
3144 * @param string $name
3145 * @param string $checkedval
3146 * @param string $tabindex
3147 * @param string $value1
3148 * @param string $value2
3149 * @param string $yesval
3150 * @param string $noval
3151 * @param string $isAdmin
3152 * @param string $template_name
3155 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $template_name = '')
3157 $this->parser->parse(listplug_input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $template_name));
3162 * AdminActions::parse_insertpluginfo()
3163 * Parse templatevar insertpluginfo
3165 public function parse_insertpluginfo($type)
3170 return Admin::$aOptions['pid'];
3173 return Entity::hsc(Admin::$aOptions['pfile']);
3180 * AdminActions::parse_insplugoptcontent()
3181 * Parse skinvar insplugoptcontent
3186 public function parse_insplugoptcontent()
3188 $meta = NucleusPlugin::getOptionMeta(Admin::$aOptions['typeinfo']);
3189 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3192 listplug_plugOptionRow(Admin::$aOptions);
3199 * AdminActions::parse_iprangeinput()
3200 * Parse skinvar iprangeinput
3205 public function parse_iprangeinput()
3207 if ( requestVar('ip') )
3209 $iprangeVal = Entity::hsc(requestVar('ip'));
3210 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3211 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3212 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3213 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3214 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3218 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3219 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3225 * AdminActions::parse_itemnavlist()
3226 * Parse skinvar itemnavlist
3231 public function parse_itemnavlist($template_name)
3233 global $CONF, $manager, $member;
3235 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3236 . " FROM %s, %s, %s, %s"
3237 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3239 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3241 if ( $this->skintype == 'itemlist' )
3244 if ( array_key_exists('blogid', $_REQUEST) )
3246 $blogid = intRequestVar('blogid');
3248 else if ( array_key_exists('itemid', $_REQUEST) )
3250 $itemid = intRequestVar('itemid');
3251 $item = &$manager->getItem($itemid, 1, 1);
3252 $blogid = (integer) $item['blogid'];
3254 $blog =& $manager->getBlog($blogid);
3256 $query .= " AND iblog={$blogid}";
3257 $template['now'] = $blog->getCorrectTime(time());
3259 // non-blog-admins can only edit/delete their own items
3260 if ( !$member->blogAdminRights($blogid) )
3262 $query .= ' AND iauthor = ' . $member->getID();
3265 elseif ( $this->skintype == 'browseownitems' )
3267 $query .= ' AND iauthor = ' . $member->getID();
3269 $template['now'] = time();
3272 // search through items
3273 $search = postVar('search');
3275 if ( !empty($search) )
3277 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3278 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3279 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3282 if ( postVar('start') )
3284 $start = intPostVar('start');
3291 // amount of items to show
3292 if ( postVar('amount') )
3294 $amount = intPostVar('amount');
3298 $amount = (integer) $CONF['DefaultListSize'];
3305 $query .= ' ORDER BY itime DESC'
3306 . " LIMIT {$start},{$amount}";
3308 $resource = DB::getResult($query);
3309 if ( $resource->rowCount() > 0 )
3311 $template['action'] = $this->skintype;
3312 $template['start'] = $start;
3313 $template['amount'] = $amount;
3314 $template['minamount'] = 0;
3315 $template['maxamount'] = 1000;
3316 $template['blogid'] = $blogid;
3317 $template['search'] = $search;
3318 $template['itemid'] = 0;
3320 $template['content'] = 'itemlist';
3322 $this->parser->parse(listplug_navlist('item', $query, 'table', $template, $template_name));
3326 /* TODO: nothing to be shown */
3328 $resource->closeCursor();
3334 * AdminActions::parse_itemtime()
3335 * date change on edit item
3337 * @param string $key key of PHP's getDate()
3340 public function parse_itemtime($key)
3344 $contents = Admin::$contents;
3345 $itemtime = getdate($contents['timestamp']);
3346 echo $itemtime[$key];
3351 * AdminActions::parse_jstoolbaroptions()
3352 * Parse skinvar jstoolbaroptions
3357 public function parse_jstoolbaroptions()
3361 _SETTINGS_JSTOOLBAR_NONE,
3362 _SETTINGS_JSTOOLBAR_SIMPLE,
3363 _SETTINGS_JSTOOLBAR_FULL
3367 foreach ( $options as $option )
3369 $text = "<option value=\"%d\"%s>%s</option>\n";
3370 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3371 echo sprintf($text, $i, $extra, $option);
3377 * AdminActions::parse_localeselectoptions()
3378 * Parse skinvar localeselectoptions
3383 public function parse_localeselectoptions()
3385 global $CONF, $member;
3387 $locales = i18n::get_available_locale_list();
3389 /* default option */
3390 if ( $this->skintype == 'editmembersettings' )
3392 if ( !$member->getLocale() )
\r
3394 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
\r
3398 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
\r
3403 if ( $CONF['Locale'] == 'en_Latn_US' )
\r
3405 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
\r
3409 echo "<option value=\"\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
\r
3413 /* optional options */
3414 foreach ( $locales as $locale )
3416 if ( $this->skintype == 'editmembersettings' )
\r
3418 if ( $locale != $member->getLocale() )
\r
3420 echo "<option value=\"{$locale}\">";
\r
3424 echo "<option value=\"{$locale}\" selected=\"selected\">";
\r
3429 if ( $locale == 'en_Latn_US' )
3431 /* already output */
3434 else if ( $locale != $CONF['Locale'] )
\r
3436 echo "<option value=\"{$locale}\">";
\r
3440 echo "<option value=\"{$locale}\" selected=\"selected\">";
\r
3443 $label = '_LOCALE_' . strtoupper($locale);
3444 if ( !defined($label) )
3450 echo constant($label);
3452 echo "</option>\n";
\r
3458 * AdminActions::parse_listplugplugoptionrow()
3459 * Parse templatevar listplugplugoptionrow
3461 * @param string $template_name name of template
3464 public function parse_listplugplugoptionrow($template_name = '')
3466 echo listplug_plugOptionRow(Admin::$aOptions, $template_name);
3471 * AdminActions::parse_mediadirwarning()
3472 * Parse skinvar mediadirwarning
3477 public function parse_mediadirwarning()
3480 if ( !is_dir($DIR_MEDIA) )
3482 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3484 if ( !is_readable($DIR_MEDIA) )
3486 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3488 if ( !is_writeable($DIR_MEDIA) )
3490 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3496 * AdminActions::parse_movedistselect()
3497 * Parse skinvar movedistselect
3499 public function parse_movedistselect()
3501 $actionType = requestVar('action');
3502 switch ( $actionType )
3505 $this->selectBlog('destcatid', 'category');
3507 case 'batchcategory':
3508 $this->selectBlog('destblogid');
3511 if ( $this->skintype == 'itemmove' )
3513 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3514 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3515 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3516 $this->selectBlog('catid', 'category', $catid, 10, 1);
3524 * AdminActions::parse_moveitemid()
3525 * Parse skinvar moveitemid
3530 public function parse_moveitemid()
3532 echo intRequestVar('itemid');
3537 * AdminActions::parse_newestcompare()
3538 * Parse skinvar newestcompare
3543 public function parse_newestcompare()
3547 $newestVersion = getLatestVersion();
3548 $newestCompare = str_replace('/', '.', $newestVersion);
3549 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3551 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3553 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3554 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3558 echo _ADMIN_SYSTEMOVERVIEW_VERSION_LATEST;
3564 * AdminActions::parse_newmemberselect()
3565 * Parse skinvar newmemberselect
3567 * @param string $template_name name of template to use
3570 public function parse_newmemberselect($template_name = '')
3572 $blogid = intRequestVar('blogid');
3574 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3575 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3576 $res = DB::getResult($query);
3579 foreach ( $res as $row )
3581 $tmem[] = intval($row['tmember']);
3584 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3585 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3588 'name' => 'memberid',
3589 'tabindex' => 10000,
3592 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3597 * AdminActions::parse_newpluginlist()
3598 * Parse skinvar newpluginlist
3603 public function parse_newpluginlist()
3605 $candidates = $this->newPlugCandidates;
3606 foreach ( $candidates as $name )
3608 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3614 * AdminActions::parse_outputspecialdirs()
3615 * Parse skinvar outputspecialdirs
3617 * @param string $type type of setting for directory
3620 public function parse_outputspecialdirs($type)
3622 global $DIR_MEDIA, $DIR_NUCLEUS;
3627 echo Entity::hsc($DIR_NUCLEUS);
3630 echo Entity::hsc($DIR_MEDIA);
3637 * AdminActions::parse_passrequestvars()
3638 * Parse skinvar passrequestvars
3643 public function parse_passrequestvars()
3645 $passvar = Admin::$passvar;
3646 $oldaction = postVar('oldaction');
3648 if ( ($oldaction != 'logout')
3649 && ($oldaction != 'login')
3651 && !postVar('customaction') )
3659 * AdminActions::parse_pluginextras()
3660 * Parse skinvar pluginextras
3662 * @param string $type type of plugin context
3665 public function parse_pluginextras($type = 'global')
3672 $id = intRequestVar('memberid');
3673 $mem =& $manager->getMember($id);
3674 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
3677 $id = intRequestVar('blogid');
3678 $blg =& $manager->getBlog($id);
3679 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
3681 case 'createaccount':
3683 'type' => 'createaccount.php',
3685 'postlabel' => '<br />',
3687 'postfield' => '<br /><br />'
3689 $manager->notify('RegistrationFormExtraFields', $data);
3692 $manager->notify('GeneralSettingsFormExtras', array());
3699 * AdminActions::parse_pluginhelp()
3700 * Parse skinvar pluginhelp
3705 public function parse_pluginhelp()
3707 global $manager, $DIR_PLUGINS;
3709 $plugid = intGetVar('plugid');
3710 $plugName = $manager->getPluginNameFromPid($plugid);
3711 $plug =& $manager->getPlugin($plugName);
3713 if ( $plug->supportsFeature('HelpPage') > 0 )
3715 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3716 if ( @file_exists($helpfile . 'php') )
3718 @include($helpfile . 'php');
3721 elseif ( @file_exists($helpfile . 'html') )
3723 @include($helpfile . 'html');
3727 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3728 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3733 * AdminActions::parse_pluginlistlist()
3734 * Parse skinvar pluginlistlist
3736 * @param string $template_name name of template to use
3739 public function parse_pluginlistlist($template_name = '')
3741 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3742 $query = sprintf($query, sql_table('plugin'));
3744 $template['content'] = 'pluginlist';
3745 $template['tabindex'] = 10;
3747 $this->parser->parse(showlist($query, 'table', $template, $template_name));
3753 * AdminActions::parse_pluginoptions()
3754 * Parse skinvar pluginoptions
3756 * @param string $type type of plugin option
3759 public function parse_pluginoptions($context='global', $template_name='')
3761 global $itemid, $manager;
3766 $contextid = intRequestVar('memberid');
3769 $contextid = intRequestVar('blogid');
3772 $contextid = intRequestVar('catid');
3775 $contextid = $itemid;
3779 /* Actually registererd plugin options */
3780 $aIdToValue = array();
3781 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
3782 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
3783 $res = DB::getResult($query);
3784 foreach ( $res as $row )
3786 $aIdToValue[$row['oid']] = $row['ovalue'];
3789 /* Currently available plugin options */
3790 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
3791 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
3792 $res = DB::getResult($query);
3795 foreach ($res as $row )
3797 if ( !array_key_exists($row['oid'], $aIdToValue) )
3799 $value = $row['odef'];
3803 $value = $aIdToValue[$row['oid']];
3807 'pid' => $row['pid'],
3808 'pfile' => $row['pfile'],
3809 'oid' => $row['oid'],
3811 'name' => $row['oname'],
3812 'description' => $row['odesc'],
3813 'type' => $row['otype'],
3814 'typeinfo' => $row['oextra'],
3815 'contextid' => $contextid,
3821 'context' => $context,
3822 'contextid' => $contextid,
3823 'options' => &$options
3825 $manager->notify('PrePluginOptionsEdit', $data);
3827 $template = array();
3828 if ( $template_name )
3830 $templates =& $manager->getTemplate($template_name);
3831 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3833 $template['title'] = "<tr>"
3834 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3839 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3842 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3844 $template['body'] = "<tr>"
3845 . "<%listplugplugoptionrow%>"
3850 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3856 foreach ( $options as $option )
3859 if ( $prevPid != $option['pid'] )
3861 $prevPid = $option['pid'];
3862 $this->parser->parse($template['title']);
3865 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3867 if ( @$meta['access'] != 'hidden' )
3869 $parsed = $this->parser->parse($template['body']);
3877 * AdminActions::parse_qmenuaddselect()
3878 * Parse skinvar qmanuaddselect
3880 * @param string $template_name name of template to use
3883 public function parse_qmenuaddselect($template_name = '')
3885 global $member, $blogid;
3886 $showAll = requestVar('showall');
3887 if ( $member->isAdmin() && ($showAll == 'yes') )
3889 // Super-Admins have access to all blogs! (no add item support though)
3890 $query = 'SELECT bnumber as value, bname as text FROM %s ORDER BY bname;';
3891 $query = sprintf($query, sql_table('blog'));
3895 $query = 'SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;';
3896 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3899 $template['name'] = 'blogid';
3900 $template['tabindex'] = 15000;
3901 $template['extra'] = _QMENU_ADD_SELECT;
3902 $template['selected'] = 0;
3903 $template['shorten'] = 10;
3904 $template['shortenel'] = '';
3905 $template['javascript'] = 'onchange="return form.submit()"';
3907 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3913 * AdminActions::parse_quickmenu()
3914 * Parse skinvar quickmenu
3916 * @param string $template_name name of template to use
3919 public function parse_quickmenu($template_name = '')
3922 $templates = array();
3924 if ( !empty($template_name) )
3926 $templates = & $manager->getTemplate($template_name);
3928 $pluginExtras = array();
3929 $manager->notify('QuickMenu', array('options' => &$pluginExtras));
3931 $template = array();
3932 if ( count($pluginExtras) > 0 )
3934 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3936 $template['head'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n"
3941 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3944 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
3946 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
3950 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3953 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3955 $template['foot'] = "</ul>\n";
3959 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3962 $this->parser->parse($template['head']);
3963 foreach ( $pluginExtras as $aInfo )
3966 'plugadminurl' => Entity::hsc($aInfo['url']),
3967 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
3968 'plugadmintitle' => Entity::hsc($aInfo['title']),
3970 $this->parser->parse(Template::fill($template['body'], $data));
3972 $this->parser->parse($template['foot']);
3978 * AdminActions::parse_requestblogid()
3979 * Parse skinvar requestblogid
3984 public function parse_requestblogid()
3986 echo intRequestVar('blogid');
3991 * AdminActions::parse_requestiprange()
3992 * Parse skinvar requestiprange
3997 public function parse_requestiprange()
3999 if ( requestVar('iprange') )
4001 echo Entity::hsc(requestVar('iprange'));
4003 elseif ( requestVar('ip') )
4005 echo Entity::hsc(requestVar('ip'));
4011 * AdminActions::parse_selectlocalskinfiles()
4012 * Parse skinvar selectlocalskinfiles
4017 public function parse_selectlocalskinfiles()
4021 if ( !class_exists('SkinImport', FALSE) )
4023 include_libs('skinie.php');
4026 if ( !in_array($this->skintype, Admin::$adminskin_actions) && $this->skintype != 'importAdmin' )
4028 $skindir = $DIR_SKINS;
4032 $skindir = "{$DIR_SKINS}admin/";
4035 $candidates = SkinImport::searchForCandidates($skindir);
4036 foreach ( $candidates as $skinname => $skinfile )
4038 $skinname = Entity::hsc($skinname);
4039 if ( !in_array($this->skintype, Admin::$adminskin_actions) && $this->skintype != 'importAdmin' )
4041 $skinfile = Entity::hsc($skinfile);
4045 $skinfile = Entity::hsc("admin/$skinfile");
4047 echo "<option value=\"{$skinfile}\">{$skinname}</option>\n";
4054 * AdminActions::parse_skineditallowedlist()
4055 * Parse skinvar skineditallowedlist
4057 * @param string $type type of skin
4058 * @param string $template_name name of template
4061 public function parse_skineditallowedlist($type, $template_name = '')
4066 $query = "SELECT bshortname, bname FROM %s;";
4068 'content' => 'shortblognames'
4070 $query = sprintf($query, sql_table('blog'));
4073 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4075 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4079 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%';";
4082 'content' => 'shortnames'
4084 $query = sprintf($query, sql_table('template_desc'));
4088 $this->parser->parse(showlist($query, 'table', $show, $template_name));
4093 * AdminActions::parse_skinielist()
4094 * Parse skinvar skinielist
4096 * @param string $type type of skin
4097 * @param string $template_name name of template to use
4100 public function parse_skinielist($type, $template_name = '')
4104 $templates = array();
4105 if ( $template_name )
4107 $templates =& $manager->getTemplate($template_name);
4109 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
4111 $template = "<tr>\n"
4113 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4114 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4116 . "<td><%expdesc%></td>\n"
4121 $template = $templates['SKINIE_EXPORT_LIST'];
4127 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4129 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4133 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname LIKE 'admin/%%';");
4135 foreach ( $res as $row )
4138 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4139 'expid' => 'skinexp' . $row['sdnumber'],
4140 'expname' => Entity::hsc($row['sdname']),
4141 'expdesc' => Entity::hsc($row['sddesc'])
4143 echo Template::fill($template, $data);
4147 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4149 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4153 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname LIKE 'admin/%%';");
4155 foreach ( $res as $row )
4158 'typeid' => 'template[' . $row['tdnumber'] . ']',
4159 'expid' => 'templateexp' . $row['tdnumber'],
4160 'expname' => Entity::hsc($row['tdname']),
4161 'expdesc' => Entity::hsc($row['tddesc'])
4163 echo Template::fill($template, $data);
4171 * AdminActions::parse_skinoverview()
4172 * Parse skinvar skinoverview
4174 * @param string $template_name name of template to use
4177 public function parse_skinoverview($template_name = '')
4181 $template = array();
4182 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4184 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%' ORDER BY sdname;";
4185 $template['handler'] = 'Actions';
4186 $template['editaction'] = 'skinedit';
4187 $template['cloneaction'] = 'skinclone';
4188 $template['deleteaction'] = 'skindelete';
4189 $template['edittypeaction'] = 'skinedittype';
4190 $template['default'] = $CONF['BaseSkin'];
4194 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
4195 $template['handler'] = 'AdminActions';
4196 $template['editaction'] = 'adminskinedit';
4197 $template['cloneaction'] = 'adminskinclone';
4198 $template['deleteaction'] = 'adminskindelete';
4199 $template['edittypeaction'] = 'adminskinedittype';
4200 $template['default'] = $CONF['AdminSkin'];
4202 $query = sprintf($query, sql_table('skin_desc'));
4204 $template['tabindex'] = 10;
4205 $template['content'] = 'skinlist';
4207 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4213 * AdminActions::parse_skintypehelp()
4214 * Check editing skintypehelp
4219 public function parse_skintypehelp()
4221 $surrent_skin_type = strtolower(trim(requestVar('type')));
4222 $page_action = strtolower(trim(requestVar('action')));
4223 if ( in_array($page_action, Admin::$adminskin_actions) )
4225 $normal_types = array_keys(self::$normal_skin_types);
4229 $normal_types = array_keys(Actions::getNormalSkinTypes());
4232 if ( in_array($surrent_skin_type, $normal_types) )
4234 help('skinpart' . $surrent_skin_type);
4238 help('skinpartspecial');
4244 * AdminActions::parse_specialskinlist()
4245 * Parse skinvar specialskinlist
4247 * @param string $template_name name of template to use
4250 public function parse_specialskinlist($template_name = '')
4252 global $CONF, $manager;
4254 $template = array();
4256 $skinid = intRequestVar('skinid');
4258 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4260 $skin =& $manager->getSkin($skinid);
4261 $template['editaction'] = 'skinedittype';
4262 $template['removeaction'] = 'skinremovetype';
4266 $skin =& $manager->getSkin($skinid, 'AdminActions');
4267 $template['editaction'] = 'adminskinedittype';
4268 $template['removeaction'] = 'adminskinremovetype';
4270 $normal_types = $skin->getNormalTypes();
4271 $available_types = $skin->getAvailableTypes();
4273 $special_skintypes = array();
4274 foreach( $available_types as $skintype => $skinname )
4276 if ( !array_key_exists($skintype, $normal_types) )
4278 $special_skintypes[] = array(
4279 'skintype' => $skintype,
4280 'skintypename' => $skinname
4285 if ( sizeof($special_skintypes) > 0 )
4287 $template['tabindex'] = 75;
4288 $template['skinid'] = $skin->getID();
4289 $template['skinname'] = $skin->getName();
4290 $this->parser->parse(showlist($special_skintypes, 'list_specialskinlist', $template, $template_name));
4294 /* TODO: nothing to be shown */
4301 * AdminActions::parse_sprinttext()
4304 * @param string $which
4305 * @param string $val
4308 public function parse_sprinttext($which, $val)
4310 if ( !defined($which) )
4316 $base = constant($which);
4319 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4321 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4323 $met = 'parse_' . $matchies[0];
4327 $arg = trim($args[0], '()');
4328 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4331 if ( method_exists($this, $met) )
4333 $value = call_user_func(array(&$this, $met), $arg);
4337 if ( !isset($value) || empty($value) )
4341 echo sprintf($base, $value);
4346 * AdminActions::parse_systemsettings()
4347 * Parse skinvar systemsettings
4349 * @param string $type type of settings for system
4350 * @param string $template_name name of template to use
4353 public function parse_systemsettings($type = 'phpinfo', $template_name = '')
4355 global $manager, $member, $CONF, $nucleus;
4357 $member->isAdmin() or Admin::disallow();
4359 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4360 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4367 case 'sqlserverinfo':
4368 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4370 case 'sqlclientinfo':
4371 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4373 case 'magicquotesgpc':
4374 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4376 case 'magicquotesruntime':
4377 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4379 case 'registerglobals':
4380 echo ini_get('register_globals') ? 'On' : 'Off';
4383 $templates = array();
4384 if ( $template_name )
4386 $templates =& $manager->getTemplate($template_name);
4388 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4390 $template = "<tr>\n"
4391 . "<td><%key%></td>\n"
4392 . "<td><%value%></td>\n"
4397 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4400 $gdinfo = gd_info();
4402 foreach ( $gdinfo as $key => $value )
4404 if ( is_bool($value) )
4406 $value = $value ? $enable : $disable;
4410 $value = Entity::hsc($value);
4416 echo Template::fill($template, $data);
4420 if ( function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) )
4427 phpinfo(INFO_MODULES);
4428 $im = ob_get_contents();
4430 if ( i18n::strpos($im, 'mod_rewrite') !== FALSE )
4440 case 'nucleusversion':
4441 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4443 case 'nucleuspatchlevel':
4444 echo getNucleusPatchLevel();
4450 echo $CONF['ItemURL'];
4452 case 'alertonheaderssent':
4453 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4455 case 'nucleuscodename':
4456 if ( $nucleus['codename'] != '' )
4458 echo ' "' . $nucleus['codename'] . '"';
4461 case 'versioncheckurl':
4462 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4469 * AdminActions::parse_templateoverview()
4470 * Parse skinvar templateoverview
4472 * @param string $template_name name of template to use
4475 public function parse_templateoverview($template_name = '')
4477 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4479 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname;";
4480 $template['deleteaction'] = 'templatedelete';
4481 $template['editaction'] = 'templateedit';
4482 $template['cloneaction'] = 'templateclone';
4486 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
4487 $template['deleteaction'] = 'admintemplatedelete';
4488 $template['editaction'] = 'admintemplateedit';
4489 $template['cloneaction'] = 'admintemplateclone';
4491 $query = sprintf($query, sql_table('template_desc'));
4493 $template['tabindex'] = 10;
4494 $template['content'] = 'templatelist';
4496 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4502 * AdminActions::parse_ticket()
4508 public function parse_ticket()
4511 $manager->addTicketHidden();
4516 * AdminActions::parse_versioncheckurl()
4517 * Parse skinvar versioncheckurl
4522 public function parse_versioncheckurl()
4524 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4529 * AdminActions::parse_yrbloglist()
4530 * Parse skinvar yrbloglist
4532 * @param string $template_name name of template to use
4535 public function parse_yrbloglist($template_name = '')
4538 $showAll = requestVar('showall');
4540 if ( $member->isAdmin() && ($showAll == 'yes') )
4542 // Super-Admins have access to all blogs! (no add item support though)
4543 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4545 . " ORDER BY bnumber;";
4546 $query = sprintf($query, sql_table('blog'));
4550 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4552 . " WHERE tblog=bnumber and tmember=%d"
4553 . " ORDER BY bnumber;";
4554 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4557 $resource = DB::getResult($query);
4558 if ( ($showAll != 'yes') && $member->isAdmin() )
4560 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4561 $total = DB::getValue($query);
4563 if ( $total > $resource->rowCount() )
4565 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4569 if ( $resource->rowCount() > 0 )
4571 $template['content'] = 'bloglist';
4572 $template['superadmin'] = $member->isAdmin();
4574 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4575 $resource->closeCursor();
4577 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4579 $query = 'SELECT ititle, inumber, bshortname FROM %s, %s '
4580 . 'WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4581 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4583 $resource = DB::getResult($query);
4584 if ( $resource->rowCount() > 0 )
4586 $template['content'] = 'draftlist';
4587 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4591 echo _OVERVIEW_NODRAFTS;
4596 echo _OVERVIEW_NOBLOGS;
4598 $resource->closeCursor();
4604 * AdminActions::checkCondition()
4605 * Checks conditions for if statements
4607 * @param string $field type of <%if%>
4608 * @param string $name property of field
4609 * @param string $value value of property
4610 * @return boolean condition
4612 protected function checkCondition($field, $name='', $value = '')
4614 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4624 $blog =& $manager->getBlog($blogid);
4628 $blogid = getBlogIDFromCatID($catid);
4629 $blog =& $manager->getBlog($blogid);
4631 elseif ( intRequestVar('catid') )
4633 $catid = intRequestVar('catid');
4634 $blogid = getBlogIDFromCatID($catid);
4635 $blog =& $manager->getBlog($blogid);
4642 $condition = ($blog && $this->ifCategory($name, $value));
4645 $condition = $member->isLoggedIn();
4648 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4651 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4654 $condition = $member->isLoggedIn() && $member->isAdmin();
4656 case 'allowloginedit':
4657 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4660 $condition = ($itemidnext != '');
4663 $condition = ($itemidprev != '');
4665 case 'archiveprevexists':
4666 $condition = ($archiveprevexists == true);
4668 case 'archivenextexists':
4669 $condition = ($archivenextexists == true);
4672 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4675 $condition = $this->ifHasPlugin($name, $value);
4678 $condition = (Admin::$action == $name);
4680 case 'adminoldaction':
4681 $condition = (Admin::$action == $name);
4683 case 'addresschange':
4684 $condition = ($this->ifAddresscange());
4686 case 'bechangepass':
4687 $condition = ($this->beChangePassword());
4689 case 'skincandidates':
4690 $condition = ($this->ifSkincandidates());
4693 $condition = Admin::$contents['nameclashes'];
4695 case 'existsnewplugin':
4696 $condition = ($this->existsNewPlugin());
4703 $condition = (boolean) ($member->getAutosave() == $value);
4710 $condition = (Admin::$blog->getSetting($name) == $value);
4712 case 'itemproperty':
4717 if ( array_key_exists($name, Admin::$contents) )
4719 $condition = (boolean) (Admin::$contents[$name] == $value);
4723 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4730 * AdminActions::_ifHasPlugin()
4731 * hasplugin,PlugName
4732 * -> checks if plugin exists
4733 * hasplugin,PlugName,OptionName
4734 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
4735 * hasplugin,PlugName,OptionName=value
4736 * -> checks if the option OptionName from plugin PlugName is set to value
4738 * @param string $name name of plugin
4739 * @param string $value
4742 private function ifHasPlugin($name, $value)
4746 // (pluginInstalled method won't write a message in the actionlog on failure)
4747 if ( $manager->pluginInstalled("NP_{$name}") )
4749 $plugin =& $manager->getPlugin("NP_{$name}");
4750 if ( $plugin != NULL )
4758 list($name2, $value2) = preg_split('#=#', $value, 2);
4759 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4763 else if ( $plugin->getOption($name2) == $value2 )
4774 * AdminActions::beChangePassword()
4779 private function beChangePassword()
4781 return intRequestVar('bNeedsPasswordChange');
4785 * AdminActions::ifSkincandidates()
4786 * Checks if a plugin exists and call its doIf function
4792 private function ifSkincandidates()
4795 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4796 return (count($candidates) > 0);
4800 * AdminActions::ifPlugin()
4801 * Checks if a plugin exists and call its doIf function
4803 * @param string $name name of plugin
4804 * @param string $key
4805 * @param string $value
4808 private function ifPlugin($name, $key = '', $value = '')
4812 $plugin =& $manager->getPlugin("NP_{$name}");
4818 $params = func_get_args();
4819 array_shift($params);
4821 return call_user_func_array(array(&$plugin, 'doIf'), $params);
4825 * AdminActions::ifCategory()
4826 * Different checks for a category
4828 * @param string $key key for information of category
4829 * @param string $value value for information of category
4832 private function ifCategory($key = '', $value='')
4834 global $blog, $catid;
4836 // when no parameter is defined, just check if a category is selected
4837 if (($key != 'catname' && $key != 'catid') || ($value == ''))
4839 return $blog->isValidCategory($catid);
4842 // check category name
4843 if ( $key == 'catname' )
4845 $value = $blog->getCategoryIdFromName($value);
4846 if ($value == $catid)
4848 return $blog->isValidCategory($catid);
4852 // check category id
4853 if (($key == 'catid') && ($value == $catid))
4855 return $blog->isValidCategory($catid);
4862 * AdminActions::ifOnTeam()
4863 * Checks if a member is on the team of a blog and return his rights
4865 * @param string $blogName name of weblog
4868 private function ifOnTeam($blogName = '')
4870 global $blog, $member, $manager;
4872 // when no blog found
4873 if ( ($blogName == '') && !is_object($blog) )
4878 // explicit blog selection
4879 if ($blogName != '')
4881 $blogid = getBlogIDFromName($blogName);
4884 if (($blogName == '') || !$manager->existsBlogID($blogid))
4887 $blogid = $blog->getID();
4889 return $member->teamRights($blogid);
4893 * AdminActions::ifAdmin()
4894 * Checks if a member is admin of a blog
4896 * @param string $blogName name of weblog
4899 private function ifAdmin($blogName = '')
4901 global $blog, $member, $manager;
4903 // when no blog found
4904 if (($blogName == '') && (!is_object($blog)))
4909 // explicit blog selection
4910 if ($blogName != '')
4912 $blogid = getBlogIDFromName($blogName);
4915 if (($blogName == '') || !$manager->existsBlogID($blogid))
4918 $blogid = $blog->getID();
4921 return $member->isBlogAdmin($blogid);
4925 * AdminActions::ifAddresscange()
4926 * Check e-Mail address is changed
4931 private function ifAddresscange()
4935 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4940 $info = MEMBER::getActivationInfo($key);
4945 $mem =& $manager->getMember($info->vmember);
4950 if ( $info->vtype == 'addresschange' )
4959 * AdminActions::customHelp()
4960 * shows a link to custom help file
4963 * @param string $tplName
4964 * @param string $url
4965 * @param string $iconURL
4966 * @param string $alt
4967 * @param string $title
4971 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4973 echo $this->customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
4978 * AdminActions::customHelp()
4979 * shows a link to custom help file
4982 * @param string $tplName
4983 * @param string $url
4984 * @param string $iconURL
4985 * @param string $alt
4986 * @param string $title
4990 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
4992 global $CONF, $manager;
4994 $templates = array();
4998 $templates =& $manager->getTemplate($tplName);
5001 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5003 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5007 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5012 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5015 if ( empty($onclick) )
5017 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5019 elseif ( preg_match('#^onclick#', $onclick) )
5021 $onclick = $onclick;
5025 $onclick = 'onclick="' . $onclick . '"';
5030 'helptarget' => $id,
5031 'onclick' => $onclick,
5032 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5034 return Template::fill($template, $data);
5039 * AdminActions::customHelpHtml()
5041 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5043 global $CONF, $manager;
5045 $templates = array();
5049 $templates =& $manager->getTemplate($tplName);
5051 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5053 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5057 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5060 if ( empty($iconURL) )
5062 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5065 if ( function_exists('getimagesize') )
5067 $size = getimagesize($iconURL);
5068 $width = 'width="' . $size[0] . '" ';
5069 $height = 'height="' . $size[1] . '" ';
5073 'iconurl' => $iconURL,
5075 'height' => $height,
5076 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5077 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5080 $icon = Template::fill($template, $data);
5081 $help = $this->customHelplink($id, $tplName, $url, $title, $onclick);
5083 return $help . $icon;
5087 * AdminActions::existsNewPlugin()
5088 * Check exists new plugin
5091 * @return boolean exists or not
5093 private function existsNewPlugin()
5095 global $DIR_PLUGINS;
5097 $query = "SELECT * FROM %s;";
5098 $query = sprintf($query, sql_table('plugin'));
5099 $res = DB::getResult($query);
5101 $installed = array();
5102 foreach( $res as $row )
5104 $installed[] = $row['pfile'];
5107 $files = scandir($DIR_PLUGINS);
5109 $candidates = array();
5110 foreach ( $files as $file )
5112 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5114 if ( !in_array($matches[1], $installed) )
5116 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5120 $this->newPlugCandidates = $candidates;
5121 return (count($candidates) > 0);
5125 * AdminActions::pagehead()
5126 * Output admin page head
5131 public function parse_pagehead()
5133 global $member, $nucleus, $CONF, $manager;
5135 /* HTTP 1.1 application for no caching */
5136 header("Cache-Control: no-cache, must-revalidate");
5137 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5139 $content = $this->parser->skin->getContentFromDB('pagehead');
5142 $root_element = 'html';
5143 $charset = i18n::get_current_charset();
5144 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5145 $xml_version_info = '1.0';
5146 $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
5147 $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
5148 $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
5150 $content = "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n"
5151 . "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n"
5152 . "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n"
5154 . "<title><%sitevar(name)%> - Admin</title>\n"
5155 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>"
5156 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>"
5157 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>"
5161 . "<div id=\"adminwrapper\">"
5162 . "<div class=\"header\">"
5163 . "<h1><%sitevar(name)%></h1>"
5165 . "<div id=\"container\">"
5166 . "<div id=\"content\">"
5167 . "<div class=\"loginname\">"
5168 . "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"<%skinfile(admin/defaultadmin/styles/addedit.css%>\" />\n"
5169 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>\n"
5170 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>\n"
5171 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>\n"
5176 . "<div id=\"adminwrapper\">\n"
5177 . "<div class=\"header\">\n"
5178 . "<h1><%sitevar(name)%></h1>\n"
5180 . "<div id=\"container\">\n"
5181 . "<div id=\"content\">\n"
5182 . "<div class=\"loginname\">\n"
5183 . "<%if(loggedin)%>"
5184 . "<%text(_LOGGEDINAS)%> <%member(yourrealname)%> - <a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a><br />"
5185 . "<a href=\"<%adminurl%>index.php?action=overview\"><%text(_ADMINHOME)%></a> - "
5187 . "<a href=\"<%adminurl%>index.php?action=showlogin\" title=\"Log in\"><%text(_NOTLOGGEDIN)%></a><br />"
5189 . "<a href=\"<%sitevar(url)%>\"><%text(_YOURSITE)%></a><br />"
5191 . "<%if(superadmin)%>"
5192 . "<a href=\"<%versioncheckurl%>\" title=\"<%text(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE)%>\"><%version%><%codename%></a>"
5193 . "<%newestcompare%><%else%><%version%><%codename%>"
5199 $this->parser->parse($content);
5204 * AdminActionss::pagefoot()
5205 * Output admin page foot include quickmenu
5210 public function parse_pagefoot()
5212 global $action, $member, $manager, $blogid;
5214 $manager->notify('AdminPrePageFoot', array('action' => Admin::$action));
5216 $content = $this->parser->skin->getContentFromDB('pagefoot');
5219 $content = "<%if(loggedin)%>"
5220 . "<%ifnot(adminaction,showlogin)%>"
5221 . "<h2><%text(_LOGOUT)%></h2>"
5223 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_BACKHOME)%></a></li>"
5224 . "<li><a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a></li>"
5228 . "<div class=\"foot\">"
5229 . "<a href=\"<%text(_ADMINPAGEFOOT_OFFICIALURL)%>\">Nucleus CMS</a> © 2002- <%date(%Y)%> <%text(_ADMINPAGEFOOT_COPYRIGHT)%>"
5230 . " - <a href=\"<%text(_ADMINPAGEFOOT_DONATEURL)%>\"><%text(_ADMINPAGEFOOT_DONATE)%></a>"
5233 . "<!-- content -->"
5234 . "<div id=\"quickmenu\">"
5235 . "<%if(loggedin)%>"
5236 . "<%ifnot(adminaction,showlogin)%>"
5238 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_QMENU_HOME)%></a></li>"
5240 . "<h2><%text(_QMENU_ADD)%></h2>"
5241 . "<form method=\"get\" action=\"<%adminurl%>index.php\">"
5243 . "<input type=\"hidden\" name=\"action\" value=\"createitem\" />"
5244 . "<%qmenuaddselect(admin/default)%>"
5247 . "<h2><%member(yourrealname)%></h2>"
5249 . "<li><a href=\"<%adminurl%>index.php?action=editmembersettings\"><%text(_QMENU_USER_SETTINGS)%></a></li>"
5250 . "<li><a href=\"<%adminurl%>index.php?action=browseownitems\"><%text(_QMENU_USER_ITEMS)%></a></li>"
5251 . "<li><a href=\"<%adminurl%>index.php?action=browseowncomments\"><%text(_QMENU_USER_COMMENTS)%></a></li>"
5253 . "<%if(superadmin)%>"
5254 . "<h2><%text(_QMENU_MANAGE)%></h2>"
5256 . "<li><a href=\"<%adminurl%>index.php?action=actionlog\"><%text(_QMENU_MANAGE_LOG)%></a></li>"
5257 . "<li><a href=\"<%adminurl%>index.php?action=settingsedit\"><%text(_QMENU_MANAGE_SETTINGS)%></a></li>"
5258 . "<li><a href=\"<%adminurl%>index.php?action=systemoverview\"><%text(_QMENU_MANAGE_SYSTEM)%></a></li>"
5259 . "<li><a href=\"<%adminurl%>index.php?action=usermanagement\"><%text(_QMENU_MANAGE_MEMBERS)%></a></li>"
5260 . "<li><a href=\"<%adminurl%>index.php?action=createnewlog\"><%text(_QMENU_MANAGE_NEWBLOG)%></a></li>"
5261 . "<li><a href=\"<%adminurl%>index.php?action=backupoverview\"><%text(_QMENU_MANAGE_BACKUPS)%></a></li>"
5262 . "<li><a href=\"<%adminurl%>index.php?action=pluginlist\"><%text(_QMENU_MANAGE_PLUGINS)%></a></li>"
5264 . "<h2><%text(_QMENU_LAYOUT)%></h2>"
5266 . "<li><a href=\"<%adminurl%>index.php?action=skinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5267 . "<li><a href=\"<%adminurl%>index.php?action=templateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5268 . "<li><a href=\"<%adminurl%>index.php?action=skinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5270 . "<h2><%text(_SKINABLEADMIN_QMENU_LAYOUT)%></h2>"
5272 . "<li><a href=\"<%adminurl%>index.php?action=adminskinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5273 . "<li><a href=\"<%adminurl%>index.php?action=admintemplateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5274 . "<li><a href=\"<%adminurl%>index.php?action=adminskinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5277 . "<%quickmenu(admin/default)%>"
5279 . "<%elseif(adminaction,activate)%>"
5280 . "<h2><%text(_QMENU_ACTIVATE)%></h2>"
5281 . "<%text(_QMENU_ACTIVATE_TEXT)%>"
5282 . "<%elseif(adminaction,activatesetpwd)%>"
5283 . "<h2><%text(_QMENU_ACTIVATE)%></h2><%text(_QMENU_ACTIVATE_TEXT)%>"
5285 . "<h2><%text(_QMENU_INTRO)%></h2><%text(_QMENU_INTRO_TEXT)%>"
5288 . "<!-- content / quickmenu container -->"
5289 . "<div class=\"clear\"></div>"
5292 . "<!-- adminwrapper -->"
5296 . "<p style=\"text-align:right;\"><%benchmark%></p>"
5301 $this->parser->parse($content);
5305 * AdminActions::selectBlog()
5306 * Inserts a HTML select element with choices for all blogs to which the user has access
5307 * mode = 'blog' => shows blognames and values are blogids
5308 * mode = 'category' => show category names and values are catids
5310 * @param string $name
5311 * @param string $mode
5312 * @param integer $selected
5313 * @param integer $tabindex
5314 * @param integer $showNewCat
5315 * @param integer $iForcedBlogInclude ID for weblog always included
5316 * @param $iForcedBlogInclude
5317 * ID of a blog that always needs to be included, without checking if the
5318 * member is on the blog team (-1 = none)
5321 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5323 global $member, $CONF;
5325 // 0. get IDs of blogs to which member can post items (+ forced blog)
5326 $aBlogIds = array();
5327 if ( $iForcedBlogInclude != -1 )
5329 $aBlogIds[] = intval($iForcedBlogInclude);
5332 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5334 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5335 $query = sprintf($query, sql_table('blog'));
5339 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5340 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5343 $rblogids = DB::getResult($query);
5344 foreach ( $rblogids as $row )
5346 if ( $row['bnumber'] != $iForcedBlogInclude )
5348 $aBlogIds[] = intval($row['bnumber']);
5352 if ( count($aBlogIds) == 0 )
5357 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5359 // 1. select blogs (we'll create optiongroups)
5360 // (only select those blogs that have the user on the team)
5361 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5362 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5363 $blogs = DB::getResult($queryBlogs);
5365 if ( $mode == 'category' )
5367 if ( $blogs->rowCount() > 1 )
5371 foreach ( $blogs as $rBlog )
5373 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5375 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5378 // show selection to create new category when allowed/wanted
5381 // check if allowed to do so
5382 if ( $member->blogAdminRights($rBlog['bnumber']) )
5384 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5388 // 2. for each category in that blog
5389 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5390 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5391 $categories = DB::getResult($catQuery);
5392 foreach ( $categories as $rCat )
5394 if ( $rCat['catid'] == $selected )
5396 $selectText = ' selected="selected" ';
5402 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5405 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5413 foreach ( $blogs as $rBlog )
5415 echo '<option value="' . $rBlog['bnumber'] . '"';
5416 if ( $rBlog['bnumber'] == $selected )
5418 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5422 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";