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(
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 $action_list = showlist($resource, 'table', $template, $template_name);
704 $this->parser->parse($action_list);
708 /* TODO: nothing to be shown */
714 * AdminActions::parse_activationmessage()
715 * Parse skinvar activationmessage
717 * @param string $type type of message
718 * @param string $template_name name of template to use
721 public function parse_activationmessage($type, $template_name = '')
723 global $CONF, $manager;
727 if ( !empty($template_name))
729 $template =& $manager->getTemplate($template_name);
732 $key = postVar('ackey');
735 Admin::error(_ERROR_ACTIVATE);
738 $info = MEMBER::getActivationInfo($key);
741 Admin::error(_ERROR_ACTIVATE);
744 $mem =& $manager->getMember($info->vmember);
747 Admin::error(_ERROR_ACTIVATE);
749 switch ( $info->vtype )
752 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
754 $title = $template['ACTIVATE_FORGOT_TITLE'];
758 $title = _ACTIVATE_FORGOT_TITLE;
760 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
762 $text = $template['ACTIVATE_FORGOT_TEXT'];
766 $text = _ACTIVATE_FORGOT_TEXT;
770 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
772 $title = $template['ACTIVATE_REGISTER_TITLE'];
776 $title = _ACTIVATE_REGISTER_TITLE;
778 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
780 $text = $template['ACTIVATE_REGISTER_TEXT'];
784 $text = _ACTIVATE_REGISTER_TEXT;
787 case 'addresschange':
788 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
790 $title = $template['ACTIVATE_CHANGE_TITLE'];
794 $title = _ACTIVATE_CHANGE_TITLE;
796 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
798 $text = $template['ACTIVATE_CHANGE_TEXT'];
802 $text = _ACTIVATE_CHANGE_TEXT;
807 'memberName' => Entity::hsc($mem->getDisplayName()),
808 'realName' => Entity::hsc($mem->getRealName()),
813 echo Template::fill($title, $aVars);
816 echo Template::fill($text, $aVars);
819 echo Entity::hsc($key);
826 * AdminActions::parse_addtickettourl()
827 * Parse skinvar addtickettourl
829 * @param string $url URI for ticket
832 public function parse_addtickettourl($url)
835 $url = $manager->addTicketToUrl($url);
836 echo Entity::hsc($url);
841 * AdminActions::parse_adminbanlist()
842 * Parse skinvar adminbanlist
844 * @param string $template_name name of template to use
847 public function parse_adminbanlist($template_name = '')
849 $blogid = intRequestVar('blogid');
851 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
852 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
854 $resource = DB::getResult($query);
855 if ( $resource->rowCount() > 0 )
857 $template['content'] = 'banlist';
858 $ban_list = showlist($resource, 'table', $template, $template_name);
859 $this->parser-parse($ban_list);
869 * AdminActions::parse_adminbatchaction()
870 * Parse skinvar adminbatchaction
875 public function parse_adminbatchaction()
877 echo Entity::hsc(requestVar('batchaction'));
882 * AdminActions::parse_adminbatchlist()
883 * Parse skinvar adminbatchlist
885 * @param string $template_name name of template to use
888 public function parse_adminbatchlist($template_name = '')
891 $templates = array();
893 if ( !empty($template_name) )
895 $templates =& $manager->getTemplate($template_name);
898 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
900 $template = '<li><%text(_BATCH_EXECUTING)%> '
901 . '<b><%adminbatchaction%></b> '
902 . '<%batchlisttype%> '
903 . '<b><%batchid%></b>... '
904 . '<b><%batchlistmsg%></b>'
909 $template = $templates['ADMIN_BATCHLIST'];
912 $selected = requestIntArray('batch');
913 $action = requestVar('batchaction');
915 switch ( $this->skintype )
918 $batchlisttype = _BATCH_ONITEM;
919 $deleteaction = 'deleteOneItem';
920 $moveaction = 'moveOneItem';
921 $destid = intRequestVar('destcatid');
924 $batchlisttype = _BATCH_ONCOMMENT;
925 $deleteaction = 'deleteOneComment';
928 $batchlisttype = _BATCH_ONMEMBER;
929 $deleteaction = 'deleteOneMember';
930 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
931 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
932 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
933 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
936 $blogid = intRequestVar('blogid');
937 $batchlisttype = _BATCH_ONTEAM;
938 $deleteaction = 'deleteOneTeamMember';
939 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
940 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
941 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
942 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
944 case 'batchcategory':
945 $batchlisttype = _BATCH_ONCATEGORY;
946 $deleteaction = 'deleteOneCategory';
947 $moveaction = 'moveOneCategory';
948 $destid = intRequestVar('destblogid');
952 // walk over all selectedids and perform action
953 foreach ( $selected as $selectedid )
956 $selectedid = intval($selectedid);
960 if ( $this->skintype != 'batchteam' )
962 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
966 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
970 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
974 DB::execute("UPDATE {$setadminsql} {$selectedid};");
978 // there should always remain at least one super-admin
979 $r = DB::getResult($unsetchksql);
980 if ( $r->rowCount() < 2 )
982 $error = $unseterrmsg;
986 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
990 $error = _BATCH_UNKNOWN . Entity::hsc($action);
994 'batchid' => $selectedid,
995 'batchlisttype' => Entity::hsc($batchlisttype),
996 'adminbatchaction' => Entity::hsc($action),
997 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1000 $this->parser->parse(Template::fill($template, $data));
1007 * AdminActions::parse_adminbloglink()
1008 * Parse skinvar adminbloglink
1010 * @param string $template_name name of template to use
1013 public function parse_adminbloglink($template_name = '')
1016 $blogid = intRequestVar('blogid');
1017 $blog =& $manager->getBlog($blogid);
1018 $templates = array();
1020 if ( !empty($template_name) )
1022 $templates =& $manager->getTemplate($template_name);
1025 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1027 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1031 $template = $templates['ADMIN_BLOGLINK'];
1035 'url' => Entity::hsc($blog->getURL()),
1036 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1037 'blogname' => Entity::hsc($blog->getName())
1040 echo Template::fill($template, $data);
1045 * AdminActions::parse_adminerrormesg()
1046 * Parse skinvar adminerrormesg
1051 public function parse_adminerrormesg()
1056 if ( requestVar('errormessage') )
1058 $message = requestVar('errormessage');
1060 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1062 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1064 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1066 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1068 echo Entity::hsc($message);
1073 * AdminActions::parse_allowedskinactions()
1074 * Parse skinvar allowedskinactions
1079 public function parse_allowedskinactions()
1083 $type = strtolower(trim(requestVar('type')));
1084 $skinid = intRequestVar('skinid');
1086 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
1088 $skin =& $manager->getSkin($skinid);
1093 $skin =& $manager->getSkin($skinid, 'AdminActions');
1094 $tag = 'adminskinvar';
1097 $actions = $skin->getAllowedActionsForType($type);
1100 while ( $current = array_shift($actions) )
1102 echo helplink("{$tag}-{$current}") . "$current</a>\n";
1104 if ( count($actions) != 0 )
1113 * AdminActions::parse_banlistdeletedlist()
1114 * Parse skinvar banlistdeletedlist
1116 * @param string $template_name name of template to use
1119 public function parse_banlistdeletedlist($template_name = '')
1123 $templates = array();
1124 if ( $template_name )
1126 $templates =& $manager->getTemplate($template_name);
1129 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1131 $template = "<li><%blogname%></li>\n";
1135 $template = $templates['BANLIST_DELETED_LIST'];
1138 $deleted = requestArray('delblogs');
1139 foreach ( $deleted as $delblog )
1141 $blog =& $manager->getBlog($delblog);
1143 'blogname' => Entity::hsc($blog->getName())
1145 echo Template::fill($template, $data);
1152 * AdminActions::parse_batchdeletelist()
1153 * Parse skinvar batchdeletelist
1158 public function parse_batchdeletelist()
1160 $selected = requestIntArray('batch');
1163 foreach ( $selected as $select )
1165 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1167 // add hidden vars for team & comment
1168 if ( requestVar('action') == 'batchteam' )
1170 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1172 if ( requestVar('action') == 'batchcomment' )
1174 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1180 * AdminActions::parse_defadminskinselect()
1181 * Parse skinvar defadminskinselect
1183 * @param string $template_name name of template to use
1186 public function parse_defadminskinselect($template_name)
1188 global $CONF, $action, $manager;
1190 if ( $action == 'editmembersettings' )
1193 $default = $member->adminskin;
1195 elseif ( $action == 'memberedit' )
1197 $mem = $manager->getMember(intRequestVar('memberid'));
1198 $default = $mem->adminskin;
1202 $default = $CONF['AdminSkin'];
1205 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1206 $query = sprintf($query, sql_table('skin_desc'));
1208 'name' => 'adminskin',
1209 'tabindex' => 10080,
1210 'selected' => $default
1213 if ( $this->skintype != 'settingsedit' )
1215 $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1218 $skin_select = showlist($query, 'select', $template, $template_name);
1219 $this->parser->parse($skin_select);
1224 * AdminActions::parse_defbookmarkletselect()
1225 * Parse skinvar defbookmarkletselect
1227 * @param string $template_name name of template to use
1230 public function parse_defbookmarkletselect($template_name)
1232 global $CONF, $action, $manager;
1234 if ( $action == 'editmembersettings' )
1237 $default = $member->bookmarklet;
1239 elseif ( $action == 'memberedit' )
1241 $mem = $manager->getMember(intRequestVar('memberid'));
1242 $default = $mem->bookmarklet;
1246 $default = $CONF['BookmarkletSkin'];
1249 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1250 $query = sprintf($query, sql_table('skin_desc'));
1253 'name' => 'bookmarklet',
1254 'tabindex' => 10085,
1255 'selected' => $default
1258 if ( $this->skintype != 'settingsedit' )
1260 $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1263 $bookmarklet_select = showlist($query, 'select', $template, $template_name);
1264 $this->parser->parse($bookmarklet_select);
1269 * AdminActions::parse_batchdeletetype()
1270 * Parse skinvar batchdeletetype
1275 public function parse_batchdeletetype()
1277 echo Entity::hsc(requestVar('action'));
1282 * AdminActions::parse_batchmovebtn()
1283 * Parse skinvar batchmovebtn
1288 public function parse_batchmovebtn()
1290 $actionType = requestVar('action');
1291 switch ( $actionType )
1296 case 'batchcategory':
1304 * AdminActions::parse_batchmovelist()
1305 * Parse skinvar batchmovelist
1310 public function parse_batchmovelist()
1312 $selected = requestIntArray('batch');
1314 foreach ( $selected as $select )
1316 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1323 * AdminActions::parse_batchmovetitle()
1324 * Parse skinvar batchmovetitle
1329 public function parse_batchmovetitle()
1331 $actionType = requestVar('action');
1332 switch ( $actionType )
1337 case 'batchcategory':
1338 echo _MOVECAT_TITLE;
1345 * AdminActions::parse_batchmovetype()
1346 * Parse skinvar batchmovetype
1351 public function parse_batchmovetype()
1353 echo Entity::hsc(requestVar('action'));
1358 * AdminActions::parse_blogcatlist()
1359 * Parse skinvar blogcatlist
1364 public function parse_blogcatlist($template_name = '')
1367 $blogid = intRequestVar('blogid');
1368 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1369 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1371 $resource = DB::getResult($query);
1372 if ( $resource->rowCount() > 0 )
1374 $template['content'] = 'categorylist';
1375 $template['tabindex'] = 200;
1376 $category_list = listplug_batchlist('category', $resource, 'table', $template, $template_name);
1377 $this->parser->parse($category_list);
1381 /* TODO: nothing to be shown */
1383 $resource->closeCursor();
1389 * AdminActions::parse_blogid()
1390 * Parse skinvar blogid
1395 public function parse_blogid()
1397 echo intRequestVar('blogid');
1402 * AdminActions::parse_blognotifysetting()
1403 * Parse skinvar blognotifysetting
1408 public function parse_blognotifysetting($type)
1411 $blogid = intRequestVar('blogid');
1412 $blog =& $manager->getBlog($blogid);
1417 if ( !$blog->notifyOnComment() )
1423 if ( !$blog->notifyOnVote() )
1429 if ( !$blog->notifyOnNewItem() )
1435 echo ' checked="checked"';
1440 * AdminActions::parse_blogsetting()
1441 * Parse skinvar blogsetting
1443 * @param string $which name of weblog setting
1446 public function parse_blogsetting($which)
1448 echo $this->parse_getblogsetting($which);
1453 * AdminActions::parse_blogsettingyesno()
1454 * Parse skinvar blogsettingyesno
1456 * @param string $type type of weblog setting
1457 * @param string $template_name name of template to use
1460 public function parse_blogsettingyesno($type, $template_name = '')
1464 $blogid = intRequestVar('blogid');
1465 $blog =& $manager->getBlog($blogid);
1469 case 'convertbreaks':
1470 $checkedval = $blog->convertBreaks();
1473 case 'allowpastposting':
1474 $checkedval = $blog->allowPastPosting();
1478 $checkedval = $blog->commentsEnabled();
1482 $checkedval = $blog->isPublic();
1486 $checkedval = $blog->emailRequired();
1490 $checkedval = $blog->getSearchable();
1494 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $template_name);
1499 * AdminActions::parse_blogteamlist()
1500 * Parse skinvar blogteamlist
1502 * @param string $template_name name of template to use
1505 public function parse_blogteamlist($template_name = '')
1508 $blogid = intRequestVar('blogid');
1509 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1511 . "WHERE tmember=mnumber AND tblog= %d";
1512 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1514 $resource = DB::getResult($query);
1515 if ( $resource->rowCount() > 0 )
1517 $template['content'] = 'teamlist';
1518 $template['tabindex'] = 10;
1520 $team_list = listplug_batchlist('team', $resource, 'table', $template, $template_name);
1521 $this->parser->parse($team_list);
1527 $resource->closeCursor();
1533 * AdminActions::parse_blogteammembers()
1534 * Parse skinvar blogteammembers
1539 public function parse_blogteammembers()
1541 $blogid = intRequestVar('blogid');
1542 $query = "SELECT mname, mrealname "
1544 . "WHERE mnumber=tmember AND tblog=%d;";
1545 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1546 $res = DB::getResult($query);
1547 $memberNames = array();
1548 foreach ( $res as $row )
1550 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1552 echo implode(',', $memberNames);
1556 * AdminActions::parse_blogtime()
1557 * Parse skinvar blogtime
1559 * @param string $type type of time
1560 * @param string $format format for time expression
1561 * @param integer $offset offset of time
1564 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1568 if ( $type != 'blogtime' )
1570 /* return server time */
1571 $timestamp = time() + $offset;
1575 $bid = intRequestVar('blogid');
1576 $b =& $manager->getBlog($bid);
1577 $timestamp = $b->getCorrectTime() + $offset;
1580 echo i18n::formatted_datetime($format, $timestamp);
1585 * AdminActions::parse_bookmarkletadmin()
1586 * Parse skinvar bookmarkletadmin
1591 public function parse_bookmarkletadmin()
1595 $blogid = intRequestVar('blogid');
1597 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1602 * AdminActions::parse_categories()
1603 * Parse skinvar categories
1605 * create category dropdown box
1607 * @param string $type name of setting for category
1610 public function parse_categories($startidx = 0)
1614 if ( !array_key_exists('catid', Admin::$contents) || empty(Admin::$contents['catid']) )
1616 $catid = Admin::$blog->getDefaultCategory();
1620 $catid = Admin::$contents['catid'];
1623 $this->selectBlog('catid', 'category', $catid, $startidx, 1, Admin::$blog->getID());
1629 * AdminActions::parse_categorysetting()
1630 * Parse skinvar categorysetting
1632 * @param string $type type in category setting
1635 public function parse_categorysetting($type)
1637 $catid = intRequestVar('catid');
1638 if ( $type == 'id' )
1643 $blogid = intRequestVar('blogid');
1644 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1645 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1646 $row = DB::getRow($query);
1648 if ( $type != 'name' )
1650 echo Entity::hsc($row['cdesc']);
1654 echo Entity::hsc($row['cname']);
1661 * AdminActions::parse_codename()
1662 * Parse templatevar codename
1668 public function parse_checkedonval($value, $name)
1673 $itemid = intRequestVar('itemid');
1674 $item =& $manager->getItem($itemid, 1, 1);
1678 $blog =& $manager->getBlog($item['blogid']);
1680 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1682 $item['body'] = removeBreaks($item['body']);
1683 $item['more'] = removeBreaks($item['more']);
1687 $contents = array();
1688 if ( requestVar('action') == 'itemedit' )
1692 if ( !isset($contents[$name]) )
1694 $contents[$name] = '';
1696 if ($contents[$name] == $value)
1698 echo 'checked="checked"';
1704 * AdminActions::parse_codename()
1705 * Parse templatevar codename
1710 * TODO: is this need???
1712 public function parse_codename()
1715 echo $nucleus['codename'];
1720 * AdminActions::parse_commentnavlist()
1721 * Parse skinvar commentnavlist
1723 * @param string $template_name name of template to use
1726 public function parse_commentnavlist($template_name = '')
1728 global $CONF, $manager, $member;
1731 if ( postVar('start') )
1733 $start = intPostVar('start');
1740 // amount of items to show
1741 if ( postVar('amount') )
1743 $amount = intPostVar('amount');
1747 $amount = (integer) $CONF['DefaultListSize'];
1753 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1755 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
1757 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1759 if ( $this->skintype == 'itemcommentlist' )
1761 $itemid = intRequestVar('itemid');
1762 $query .= " citem={$itemid}";
1763 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1765 $nonComments = _NOCOMMENTS;
1767 elseif ( $this->skintype == 'browseowncomments' )
1770 $query .= ' cmember=' . $member->getID();
1771 $template['canAddBan'] = 0;
1773 $nonComments = _NOCOMMENTS_YOUR;
1775 elseif ( $this->skintype == 'blogcommentlist' )
1778 $query .= ' cblog=' . intRequestVar('blogid');
1779 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1780 $bid = intRequestVar('blogid');
1781 $nonComments = _NOCOMMENTS_BLOG;
1784 $search = postVar('search');
1785 if ( !empty($search) )
1787 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
1790 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1792 $resource = DB::getResult($query);
1793 if ( $resource->rowCount() > 0 )
1795 $template['action'] = $this->skintype;
1796 $template['start'] = $start;
1797 $template['amount'] = $amount;
1798 $template['minamount'] = 0;
1799 $template['maxamount'] = 1000;
1800 $template['blogid'] = $bid;
1801 $template['search'] = $search;
1802 $template['itemid'] = $itemid;
1804 $template['content'] = 'commentlist';
1806 $navlist = listplug_navlist('comment', $resource, 'table', $template, $template_name);
1807 $this->parser->parse($navlist);
1811 /* TODO: nothing to be shown */
1813 $resource->closeCursor();
1819 * AdminActions::parse_configsettingsedit()
1820 * Parse skinvar configsettingsedit
1822 * @param string $type type of global configuration
1825 public function parse_configsettingsedit($type)
1830 case 'DefaultListSize':
1831 if ( !array_key_exists('DefaultListSize', $CONF) )
1833 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1834 $query = sprintf($query, sql_table('config'));
1835 DB::execute($query);
1836 $CONF['DefaultListSize'] = 10;
1838 elseif ( intval($CONF['DefaultListSize']) < 1 )
1840 $CONF['DefaultListSize'] = 10;
1842 echo intval($CONF['DefaultListSize']);
1844 case 'SessionCookie':
1845 $value = $CONF['SessionCookie'];
1846 $txt1 = _SETTINGS_COOKIESESSION;
1847 $txt2 = _SETTINGS_COOKIEMONTH;
1848 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1851 $value = $CONF['URLMode'];
1852 $txt1 = _SETTINGS_URLMODE_NORMAL;
1853 $txt2 = _SETTINGS_URLMODE_PATHINFO;
1854 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1857 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1859 echo Entity::hsc($CONF[$type]);
1867 * AdminActions::parse_configsettingsyesno()
1868 * Parse skinvar configsettingsyesno
1870 * @param string $type type of global setting
1871 * @param integer $tabindex tabindex attribute of input element
1874 public function parse_configsettingsyesno($type, $tabindex)
1877 if ( array_key_exists($type, $CONF) )
1879 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1885 * AdminActions::parse_contents()
1886 * Parse skinvar contents
1888 * @param string $which part for item
1891 public function parse_contents($which)
1893 if ( !array_key_exists($which, Admin::$contents) )
1895 Admin::$contents[$which] = '';
1897 echo Entity::hsc(Admin::$contents[$which]);
1901 * AdminActions::parse_currenttime()
1902 * Parse skinvar currenttime
1904 * @param string $what
1907 public function parse_currenttime($what)
1909 $nu = getdate(Admin::$blog->getCorrectTime());
1914 * AdminActions::parse_customhelplink()
1915 * Parse skinvar customhelplink
1917 * @param string $topic name of topic
1918 * @param string $tplName name of template
1919 * @param string $url string as URI
1920 * @param string $iconURL string as URI for icon
1921 * @param string $alt alternative text for image element
1922 * @param string $title title for anchor element
1925 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1927 $this->customHelp($topic, $url, $iconURL);
1932 * AdminActions::parse_date()
1933 * Parse skinvar date
1935 public function parse_date($format = 'c')
1937 global $CONF, $manager;
1938 /* TODO: offset is based on i18n::get_current_locale()? */
1939 echo i18n::formatted_datetime($format, time());
1944 * AdminActions::parse_normalskinlist()
1945 * Parse skinvar defaultadminskintypes
1947 * @param string $template_name name of template
1950 public function parse_normalskinlist($template_name = '')
1952 global $CONF, $manager;
1954 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
1956 $skin =& $manager->getSkin($CONF['BaseSkin']);
1957 /* TODO: removeaction? */
1958 $template['editaction'] = 'skinedittype';
1962 $skin =& $manager->getSkin($CONF['AdminSkin'], 'AdminActions');
1963 $template['editaction'] = 'adminskinedittype';
1964 /* TODO: removeaction? */
1967 $temporary = $skin->getNormalTypes();
1968 $normal_skintype = array();
1969 foreach ( $temporary as $type => $label )
1971 $normal_skintype[] = array(
1972 'skintype' => $type,
1973 'skintypename' => $label
1977 $template['tabindex'] = 10;
1978 $template['skinid'] = intRequestVar('skinid');
1979 $template['skinname'] = $skin->getName();
1980 $skin_list = showlist($normal_skintype, 'list_normalskinlist', $template, $template_name);
1981 $this->parser->parse($skin_list);
1987 * AdminActions::parse_defblogselect()
1988 * Parse skinvar defblogselect
1990 * @param string $template_name name of template
1993 public function parse_defblogselect($template_name = '')
1997 $query = "SELECT bname as text, bnumber as value FROM %s;";
1998 $query = sprintf($query, sql_table('blog'));
2000 $template['name'] = 'DefaultBlog';
2001 $template['selected'] = $CONF['DefaultBlog'];
2002 $template['tabindex'] = 10;
2003 $blog_select = showlist($query, 'select', $template, $template_name);
2004 $this->parser->parse($blog_select);
2010 * AdminActions::parse_defcatselect()
2011 * Parse skinvar defcatselect
2013 * @param string $template_name name of template
2016 public function parse_defcatselect($template_name = '')
2020 $blogid = intRequestVar('blogid');
2021 $blog =& $manager->getBlog($blogid);
2023 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2024 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2026 $template['name'] = 'defcat';
2027 $template['selected'] = $blog->getDefaultCategory();
2028 $template['tabindex'] = 110;
2030 $category_select = showlist($query, 'select', $template, $template_name);
2031 $this->parser->parse($category_select);
2037 * AdminActions::parse_defskinselect()
2038 * Parse skinvar defskinselect
2040 * @param string $type type of skin
2041 * @param string $template_name name of template
2044 public function parse_defskinselect($type = 'blog', $template_name = '')
2046 global $CONF, $manager, $member;
2048 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2050 $blogid = intRequestVar('blogid');
2053 $template['selected'] = $CONF['BaseSkin'];
2057 $blog =& $manager->getBlog($blogid);
2058 $template['selected'] = $blog->getDefaultSkin();
2061 if ( $type != 'blog' )
2063 $template['name'] = 'BaseSkin';
2067 $template['name'] = 'defskin';
2070 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2074 /* TODO: member object will have its own adminskin id */
2075 $template['selected'] = $CONF['AdminSkin'];
2076 $template['name'] = 'AdminSkin';
2077 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
2080 $query = sprintf($query, sql_table('skin_desc'));
2081 $template['tabindex'] = 50;
2083 $skin_select = showlist($query, 'select', $template, $template_name);
2084 $this->parser->parse($skin_select);
2090 * AdminActions::parse_deletecomment()
2091 * Parse skinvar deletecomment
2093 * @param string $type type of infomation for comment
2096 public function parse_deletecomment($type = 'id')
2098 $commentid = intRequestVar('commentid');
2099 $comment = COMMENT::getComment($commentid);
2104 echo intRequestVar('commentid');
2107 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2109 echo $comment['member'];
2113 echo $comment['user'];
2117 $body = strip_tags($comment['body']);
2118 echo Entity::hsc(shorten($body, 300, '...'));
2124 * AdminActions::parse_deleteitembody()
2125 * Parse skinvar deleteitembody
2130 public function parse_deleteitembody()
2134 $itemid = intRequestVar('itemid');
2135 $item =& $manager->getItem($itemid, 1, 1);
2137 $body = strip_tags($item['body']);
2139 echo Entity::hsc(shorten($body, 300, '...'));
2145 * AdminActions::parse_deleteitemid()
2146 * Parse skinvar deleteitemid
2151 public function parse_deleteitemid()
2153 echo (integer) intRequestVar('itemid');
2158 * AdminActions::parse_deleteitemtitle()
2159 * Parse skinvar deleteitemtitle
2164 public function parse_deleteitemtitle()
2168 $itemid = intRequestVar('itemid');
2169 $item =& $manager->getItem($itemid, 1, 1);
2171 echo Entity::hsc(strip_tags($item['title']));
2177 * AdminActions::parse_editcomment()
2178 * Parse skinvar editcomment
2180 * @param string $type type of comment setting
2183 public function parse_editcomment($type = 'id')
2187 $comment = Admin::$contents;
2192 echo intRequestVar('commentid');
2195 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2197 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2201 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2205 echo date("Y-m-d @ H:i", $comment['timestamp']);
2208 $comment['body'] = str_replace('<br />', '', $comment['body']);
2209 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2210 echo $comment['body'];
2213 echo $comment['userid'];
2216 echo $comment['userid'];
2219 if ( array_key_exists($type, $comment) && !empty($comment[$type]) )
2221 echo $comment[$type];
2229 * AdminActions::parse_editdesturl()
2230 * Parse skinvar editdesturl
2232 public function parse_editdesturl()
2234 if ( requestVar('desturl') )
2236 echo Entity::hsc(requestVar('desturl'));
2242 * AdminActions::parse_editmemberlist()
2243 * Parse skinvar editmemberlist
2245 * @param string $template_name name of template
2248 public function parse_editmemberlist($template_name = '')
2251 // show list of members with actions
2252 $query = 'SELECT * FROM %s;';
2253 $query = sprintf($query, sql_table('member'));
2255 $resource = DB::getResult($query);
2256 if ( $resource->rowCount() > 0 )
2258 $template['content'] = 'memberlist';
2259 $template['tabindex'] = 10;
2261 $member_list = listplug_batchlist('member', $resource, 'table', $template, $template_name);
2262 $this->parser->parse($member_list);
2268 $resource->closeCursor();
2274 * AdminActions::parse_editmember()
2275 * Parse skinvar editmember
2277 * @param string $type type of information for member
2278 * @return string $tempateName name of template to use
2281 public function parse_editmember($type = 'id', $template_name = '')
2283 global $CONF, $manager, $member;
2285 $memberid = intRequestVar('memberid');
2286 $mem =& $manager->getMember($memberid);
2291 echo intRequestVar('memberid');
2294 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2296 echo Entity::hsc($mem->getDisplayName());
2300 $dispName = Entity::hsc($mem->getDisplayName());
2301 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2303 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2312 echo Entity::hsc($mem->getRealName());
2315 echo Entity::hsc($mem->getEmail());
2318 echo Entity::hsc($mem->getURL());
2321 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $template_name);
2324 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $template_name);
2327 echo Entity::hsc($mem->getNotes());
2330 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $template_name);
2339 * AdminActions::parse_editpluginfo()
2340 * Parse skinvar editpluginfo
2342 * @param string $type type of plugin info
2345 public function parse_editpluginfo($type)
2349 $pid = intRequestVar('plugid');
2356 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2363 * AdminActions::parse_editplugoptionslist()
2364 * Parse skinvar editplugoptionslist
2366 * @param string $template_name name of template
2369 public function parse_editplugoptionslist($template_name = '')
2373 $pid = intRequestVar('plugid');
2374 $aOptions = array();
2377 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2378 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2379 $resource = DB::getResult($query);
2381 foreach ( $resource as $row )
2383 $aOIDs[] = $row['oid'];
2384 $aOptions[$row['oid']] = array(
2385 'oid' => $row['oid'],
2386 'value' => $row['odef'],
2387 'name' => $row['oname'],
2388 'description' => $row['odesc'],
2389 'type' => $row['otype'],
2390 'typeinfo' => $row['oextra'],
2395 // fill out actual values
2396 if ( count($aOIDs) > 0 )
2398 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2399 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2401 $result = DB::getResult($query);
2402 foreach ( $result as $row )
2404 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2410 'context' => 'global',
2412 'options' => &$aOptions
2414 $manager->notify('PrePluginOptionsEdit', $data);
2416 if ( sizeof($aOptions) > 0 )
2418 $template['content'] = 'plugoptionlist';
2419 $option_list = showlist($aOptions, 'table', $template, $template_name);
2420 $this->parser->parse($option_list);
2424 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2430 * AdminActions::parse_editskin()
2431 * Parse skinvar editskin
2433 * @param string $type type of skin
2436 public function parse_editskin($type = 'id')
2440 $skinid = intRequestVar('skinid');
2442 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2444 $skin =& $manager->getSKIN($skinid);
2448 $skin =& $manager->getSKIN($skinid, 'AdminActions');
2454 echo intRequestVar('skinid');
2457 echo Entity::hsc($skin->getName());
2460 echo Entity::hsc($skin->getDescription());
2463 echo Entity::hsc($skin->getContentType());
2466 echo Entity::hsc($skin->getIncludePrefix());
2469 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2477 * AdminActions::parse_editskintype()
2478 * Parse skinvar editskintype
2480 * @param string $type name of type for skin type
2483 public function parse_editskintype($stype = 'id')
2487 static $skin = NULL;
2488 static $types = array();
2490 if ( $skin == NULL )
2492 $skinid = intRequestVar('skinid');
2494 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2496 $skin =& $manager->getSkin($skinid);
2500 $skin =& $manager->getSkin($skinid, 'AdminActions');
2503 $types = $skin->getNormalTypes();
2506 $type = strtolower(trim(requestVar('type')));
2511 echo $skin->getID();
2514 echo Entity::hsc($skin->getName());
2517 echo Entity::hsc($skin->getDescription());
2520 echo Entity::hsc($skin->getContentType());
2523 echo Entity::hsc($skin->getContentFromDB($type));
2526 if ( !array_key_exists($type, $types) )
2528 $skinType = ucfirst($type);
2532 $skinType = $types[$type];
2534 echo Entity::hsc($skinType);
2537 echo Entity::hsc($type);
2540 echo Entity::hsc($skin->getIncludePrefix());
2543 if ( !$skin->getIncludeMode() != 'skindir' )
2545 $incMode = _PARSER_INCMODE_NORMAL;
2549 $incMode = _PARSER_INCMODE_SKINDIR;
2551 echo Entity::hsc($incMode);
2560 * AdminActions::parse_adminurl()
2561 * Parse skinvar adminurl
2562 * (shortcut for admin url)
2567 public function parse_adminurl()
2569 $this->parse_sitevar('adminurl');
2574 * AdminActions::parse_edittemplateinfo()
2575 * Parse skinvar edittemplateinfo
2577 * @param string $format format to output
2578 * @param string $typedesc type of template
2579 * @param string $typename type name of template
2580 * @param string $help help text
2581 * @param string $tabindex index value for tabindex attribute of input element
2582 * @param string $big textarea size
2583 * @param string $tplt name of template to be filled
2586 public function parse_edittemplateinfo($format, $typedesc = '', $typename = '', $help = '', $tabindex = 0, $big = 0, $template_name = '')
2590 static $name = NULL;
2591 static $desc = NULL;
2595 $id = intRequestVar('templateid');
2598 if ( $name == NULL )
2600 $name = Template::getNameFromId($id);
2603 if ( $desc == NULL )
2605 $desc = Template::getDesc($id);
2608 $template =& $manager->getTemplate($name);
2616 echo Entity::hsc($name);
2619 echo Entity::hsc($desc);
2621 case 'extratemplate':
2623 $pluginfields = array();
2624 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
2626 $data = array('fields' => &$pluginfields);
2627 $manager->notify('TemplateExtraFields', $data);
2631 $data = array('fields' => &$pluginfields);
2632 $manager->notify('AdminTemplateExtraFields', $data);
2635 foreach ( $pluginfields as $ptkey => $ptvalue )
2640 $tmplt =& $manager->getTemplate($desc);
2643 /* extra plugin field */
2644 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2647 . "<th colspan=\"2\"><%explugtplname%></th>\n"
2652 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2655 'explugtplname' => Entity::hsc($ptkey)
2657 echo Template::fill($base, $data);
2659 foreach ( $ptvalue as $ptname => $ptdesc )
2661 if ( !array_key_exists($ptname, $template) )
2667 $content = $template[$ptname];
2669 $tempate_textarea = listplug_templateEditRow($content, $ptdesc, $ptname, $help, $tabidx++, $big, $template_name);
2670 $this->parser->parse($tempate_textarea);
2676 $typedesc = defined($typedesc) ? constant($typedesc) : $typedesc;
2677 $typename = defined($typename) ? constant($typename) : $typename;
2679 if ( !array_key_exists($typename, $template) )
2685 $content = $template[$typename];
2687 $tempate_textarea = listplug_templateEditRow($content, $typedesc, $typename, $help, $tabindex, $big, $template_name);
2688 $this->parser->parse($tempate_textarea);
2696 * AdminActions::parse_eventformextra()
2697 * Parse skinvar eventformextra
2699 * @param string $type name of type for event form extra
2702 public function parse_eventformextra($type = 'activation')
2711 $key = requestVar('ackey');
2714 Admin::error(_ERROR_ACTIVATE);
2716 $info = MEMBER::getActivationInfo($key);
2719 Admin::error(_ERROR_ACTIVATE);
2721 $mem =& $manager->getMember($info->vmember);
2724 Admin::error(_ERROR_ACTIVATE);
2727 'type' => 'activation',
2731 case 'membermailform-notloggedin':
2732 $data = array('type' => 'membermailform-notloggedin',);
2735 $manager->notify('FormExtra', $data);
2740 * AdminActions::parse_extrahead()
2741 * Parse skinvar extrahead
2743 public function parse_extrahead()
2748 'extrahead' => &Admin::$extrahead,
2749 'action' => Admin::$action
2752 $manager->notify('AdminPrePageHead', $data);
2754 $this->parser->parse(Admin::$extrahead);
2759 * AdminActions::parse_member()
2760 * Parse skinvar member
2761 * (includes a member info thingie)
2763 * @param string $what which memberdata is needed
2766 public function parse_member($what)
2768 global $memberinfo, $member, $CONF;
2770 // 1. only allow the member-details-page specific variables on member pages
2771 if ( $this->skintype == 'member' )
2776 echo Entity::hsc($memberinfo->getDisplayName());
2779 echo Entity::hsc($memberinfo->getRealName());
2782 echo Entity::hsc($memberinfo->getNotes());
2785 echo Entity::hsc($memberinfo->getURL());
2788 echo Entity::hsc($memberinfo->getEmail());
2791 echo Entity::hsc($memberinfo->getID());
2796 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2797 if ( $member->isLoggedIn() )
2802 echo $member->getDisplayName();
2804 case 'yourrealname':
2805 echo $member->getRealName();
2808 echo $member->getNotes();
2811 echo $member->getURL();
2814 echo $member->getEmail();
2817 echo $member->getID();
2819 case 'yourprofileurl':
2820 if ( $CONF['URLMode'] == 'pathinfo' )
2822 echo Link::create_member_link($member->getID());
2826 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
2835 * AdminActions::parse_version()
2836 * Parse skinvar version
2837 * (include nucleus versionnumber)
2842 public function parse_version()
2845 echo 'Nucleus CMS ' . $nucleus['version'];
2850 * AdminActions::parse_sitevar()
2851 * Parse skinvar sitevar
2852 * (include a sitevar)
2854 * @param string $which
2857 public function parse_sitevar($which)
2863 echo $CONF['IndexURL'];
2866 echo $CONF['SiteName'];
2869 echo $CONF['AdminEmail'];
2872 echo $CONF['AdminURL'];
2879 * AdminActions::parse_actionurl()
2885 public function parse_actionurl()
2888 echo Entity::hsc($CONF['ActionURL']);
2893 * AdminActions::parse_getblogsetting()
2894 * Parse skinvar getblogsetting
2896 public function parse_getblogsetting($which)
2898 global $blog, $manager;
2904 elseif ( $bid = intRequestVar('blogid') )
2906 $b =& $manager->getBlog($bid);
2916 return Entity::hsc($b->getID());
2919 return Entity::hsc($b->getURL());
2922 return Entity::hsc($b->getName());
2925 return Entity::hsc($b->getDescription());
2928 return Entity::hsc($b->getShortName());
2930 case 'notifyaddress':
2931 return Entity::hsc($b->getNotifyAddress());
2934 return Entity::hsc($b->getMaxComments());
2937 return Entity::hsc($b->getUpdateFile());
2940 return Entity::hsc($b->getTimeOffset());
2947 * AdminActions::parse_geteditpluginfo()
2948 * Parse skinvar geteditpluginfo
2950 * @param string $type name of setting for edit plugin info
2953 public function parse_geteditpluginfo($type)
2956 $pid = intRequestVar('plugid');
2963 return Entity::hsc($manager->getPluginNameFromPid($pid));
2970 * AdminActions::parse_getmember()
2971 * Parse skinvar getmember
2972 * (includes a member info thingie)
2974 * @param string $what name of setting for member
2977 public function parse_getmember($what)
2979 global $memberinfo, $member;
2980 // 1. only allow the member-details-page specific variables on member pages
2981 if ( $this->skintype == 'member' )
2986 return Entity::hsc($memberinfo->getDisplayName());
2989 return Entity::hsc($memberinfo->getRealName());
2992 return Entity::hsc($memberinfo->getNotes());
2995 return Entity::hsc($memberinfo->getURL());
2998 return Entity::hsc($memberinfo->getEmail());
3001 return Entity::hsc($memberinfo->getID());
3005 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3006 if ( $member->isLoggedIn() )
3011 return $member->getDisplayName();
3013 case 'yourrealname':
3014 return $member->getRealName();
3017 return $member->getNotes();
3020 return $member->getURL();
3023 return $member->getEmail();
3026 return $member->getID();
3034 * AdminActions::parse_headmessage()
3035 * Parse skinvar headmessage
3040 public function parse_headmessage()
3042 if ( !empty(Admin::$headMess) )
3044 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3050 * AdminActions::parse_helplink()
3051 * Parse skinvar helplink
3053 * @param string $topic name of topic for help
3056 public function parse_helplink($topic = '')
3058 if ( !empty($topic) )
3066 * AdminActions::parse_helpplugname()
3067 * Parse skinvar helpplugname
3072 public function parse_helpplugname()
3074 $plugid = intGetVar('plugid');
3075 Entity::hsc($manager->getPluginNameFromPid($plugid));
3080 * AdminActions::parse_ilistaddnew()
3081 * Parse skinvar ilistaddnew
3086 public function parse_ilistaddnew()
3088 $blogid = intRequestVar('blogid');
3089 if ( intPostVar('start') == 0 )
3091 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3097 * AdminActions::parse_importskininfo()
3098 * Parse skinvar importskininfo
3100 * @param string $type name of information for imported skin
3103 public function parse_importskininfo($type)
3108 echo Entity::hsc(Admin::$contents['skininfo']);
3111 $dataArr = Admin::$contents['skinnames'];
3112 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3115 $dataArr = Admin::$contents['tpltnames'];
3116 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3119 $dataArr = Admin::$contents['skinclashes'];
3120 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3123 $dataArr = Admin::$contents['tpltclashes'];
3124 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3127 echo Entity::hsc(Admin::$contents['skinfile']);
3130 echo Entity::hsc(Admin::$contents['mode']);
3137 * AdminActions::parse_init()
3138 * some init stuff for all forms
3143 public function parse_init()
3148 if ( requestVar('action') == 'itemedit' )
3150 $authorid = Admin::$contents['authorid'];
3153 Admin::$blog->insertJavaScriptInfo($authorid);
3158 * AdminActions::parse_inputyesno()
3159 * Parse skinvar inputyesno
3161 * @param string $name
3162 * @param string $checkedval
3163 * @param string $tabindex
3164 * @param string $value1
3165 * @param string $value2
3166 * @param string $yesval
3167 * @param string $noval
3168 * @param string $isAdmin
3169 * @param string $template_name
3172 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $template_name = '')
3174 $input_yesno = listplug_input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $template_name);
3175 $this->parser->parse($input_yesno);
3180 * AdminActions::parse_insertpluginfo()
3181 * Parse templatevar insertpluginfo
3183 public function parse_insertpluginfo($type)
3188 return Admin::$aOptions['pid'];
3191 return Entity::hsc(Admin::$aOptions['pfile']);
3198 * AdminActions::parse_insplugoptcontent()
3199 * Parse skinvar insplugoptcontent
3204 public function parse_insplugoptcontent()
3206 $meta = NucleusPlugin::getOptionMeta(Admin::$aOptions['typeinfo']);
3207 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3210 listplug_plugOptionRow(Admin::$aOptions);
3217 * AdminActions::parse_iprangeinput()
3218 * Parse skinvar iprangeinput
3223 public function parse_iprangeinput()
3225 if ( requestVar('ip') )
3227 $iprangeVal = Entity::hsc(requestVar('ip'));
3228 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3229 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3230 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3231 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3232 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3236 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3237 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3243 * AdminActions::parse_itemnavlist()
3244 * Parse skinvar itemnavlist
3246 * @param string $template_name name of template to use
3249 public function parse_itemnavlist($template_name = '')
3251 global $CONF, $manager, $member;
3253 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3254 . " FROM %s, %s, %s, %s"
3255 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3257 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3259 if ( $this->skintype == 'itemlist' )
3262 if ( array_key_exists('blogid', $_REQUEST) )
3264 $blogid = intRequestVar('blogid');
3266 else if ( array_key_exists('itemid', $_REQUEST) )
3268 $itemid = intRequestVar('itemid');
3269 $item = &$manager->getItem($itemid, 1, 1);
3270 $blogid = (integer) $item['blogid'];
3272 $blog =& $manager->getBlog($blogid);
3274 $query .= " AND iblog={$blogid}";
3275 $template['now'] = $blog->getCorrectTime(time());
3277 // non-blog-admins can only edit/delete their own items
3278 if ( !$member->blogAdminRights($blogid) )
3280 $query .= ' AND iauthor = ' . $member->getID();
3283 elseif ( $this->skintype == 'browseownitems' )
3285 $query .= ' AND iauthor = ' . $member->getID();
3287 $template['now'] = time();
3290 // search through items
3291 $search = postVar('search');
3293 if ( !empty($search) )
3295 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3296 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3297 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3300 if ( postVar('start') )
3302 $start = intPostVar('start');
3309 // amount of items to show
3310 if ( postVar('amount') )
3312 $amount = intPostVar('amount');
3316 $amount = (integer) $CONF['DefaultListSize'];
3323 $query .= ' ORDER BY itime DESC'
3324 . " LIMIT {$start},{$amount}";
3326 $resource = DB::getResult($query);
3327 if ( $resource->rowCount() > 0 )
3329 $template['action'] = $this->skintype;
3330 $template['start'] = $start;
3331 $template['amount'] = $amount;
3332 $template['minamount'] = 0;
3333 $template['maxamount'] = 1000;
3334 $template['blogid'] = $blogid;
3335 $template['search'] = $search;
3336 $template['itemid'] = 0;
3338 $template['content'] = 'itemlist';
3340 $navlist = listplug_navlist('item', $query, 'table', $template, $template_name);
3341 $this->parser->parse($navlist);
3345 /* TODO: nothing to be shown */
3347 $resource->closeCursor();
3353 * AdminActions::parse_itemtime()
3354 * date change on edit item
3356 * @param string $key key of PHP's getDate()
3359 public function parse_itemtime($key)
3363 $contents = Admin::$contents;
3364 $itemtime = getdate($contents['timestamp']);
3365 echo $itemtime[$key];
3370 * AdminActions::parse_jstoolbaroptions()
3371 * Parse skinvar jstoolbaroptions
3376 public function parse_jstoolbaroptions()
3380 _SETTINGS_JSTOOLBAR_NONE,
3381 _SETTINGS_JSTOOLBAR_SIMPLE,
3382 _SETTINGS_JSTOOLBAR_FULL
3386 foreach ( $options as $option )
3388 $text = "<option value=\"%d\"%s>%s</option>\n";
3389 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3390 echo sprintf($text, $i, $extra, $option);
3396 * AdminActions::parse_localeselectoptions()
3397 * Parse skinvar localeselectoptions
3402 public function parse_localeselectoptions()
3404 global $CONF, $member;
3406 $locales = i18n::get_available_locale_list();
3408 /* default option */
3409 if ( $this->skintype == 'editmembersettings' )
3411 if ( !$member->getLocale() )
3413 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3417 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3422 if ( $CONF['Locale'] == 'en_Latn_US' )
3424 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
3428 echo "<option value=\"\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
3432 /* optional options */
3433 foreach ( $locales as $locale )
3435 if ( $this->skintype == 'editmembersettings' )
3437 if ( $locale != $member->getLocale() )
3439 echo "<option value=\"{$locale}\">";
3443 echo "<option value=\"{$locale}\" selected=\"selected\">";
3448 if ( $locale == 'en_Latn_US' )
3450 /* already output */
3453 else if ( $locale != $CONF['Locale'] )
3455 echo "<option value=\"{$locale}\">";
3459 echo "<option value=\"{$locale}\" selected=\"selected\">";
3462 $label = '_LOCALE_' . strtoupper($locale);
3463 if ( !defined($label) )
3469 echo constant($label);
3477 * AdminActions::parse_listplugplugoptionrow()
3478 * Parse templatevar listplugplugoptionrow
3480 * @param string $template_name name of template
3483 public function parse_listplugplugoptionrow($template_name = '')
3485 echo listplug_plugOptionRow(Admin::$aOptions, $template_name);
3490 * AdminActions::parse_mediadirwarning()
3491 * Parse skinvar mediadirwarning
3496 public function parse_mediadirwarning()
3499 if ( !is_dir($DIR_MEDIA) )
3501 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3503 if ( !is_readable($DIR_MEDIA) )
3505 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3507 if ( !is_writeable($DIR_MEDIA) )
3509 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3515 * AdminActions::parse_movedistselect()
3516 * Parse skinvar movedistselect
3518 public function parse_movedistselect()
3520 $actionType = requestVar('action');
3521 switch ( $actionType )
3524 $this->selectBlog('destcatid', 'category');
3526 case 'batchcategory':
3527 $this->selectBlog('destblogid');
3530 if ( $this->skintype == 'itemmove' )
3532 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3533 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3534 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3535 $this->selectBlog('catid', 'category', $catid, 10, 1);
3543 * AdminActions::parse_moveitemid()
3544 * Parse skinvar moveitemid
3549 public function parse_moveitemid()
3551 echo intRequestVar('itemid');
3556 * AdminActions::parse_newestcompare()
3557 * Parse skinvar newestcompare
3562 public function parse_newestcompare()
3566 $newestVersion = getLatestVersion();
3567 $newestCompare = str_replace('/', '.', $newestVersion);
3568 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3570 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3572 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3573 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3577 echo _ADMIN_SYSTEMOVERVIEW_VERSION_LATEST;
3583 * AdminActions::parse_newmemberselect()
3584 * Parse skinvar newmemberselect
3586 * @param string $template_name name of template to use
3589 public function parse_newmemberselect($template_name = '')
3591 $blogid = intRequestVar('blogid');
3593 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3594 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3595 $res = DB::getResult($query);
3598 foreach ( $res as $row )
3600 $tmem[] = intval($row['tmember']);
3603 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3604 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3607 'name' => 'memberid',
3608 'tabindex' => 10000,
3611 $member_select = showlist($query, 'select', $template, $template_name);
3612 $this->parser->parse($member_select);
3617 * AdminActions::parse_newpluginlist()
3618 * Parse skinvar newpluginlist
3623 public function parse_newpluginlist()
3625 $candidates = $this->newPlugCandidates;
3626 foreach ( $candidates as $name )
3628 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3634 * AdminActions::parse_outputspecialdirs()
3635 * Parse skinvar outputspecialdirs
3637 * @param string $type type of setting for directory
3640 public function parse_outputspecialdirs($type)
3642 global $DIR_MEDIA, $DIR_NUCLEUS;
3647 echo Entity::hsc($DIR_NUCLEUS);
3650 echo Entity::hsc($DIR_MEDIA);
3657 * AdminActions::parse_passrequestvars()
3658 * Parse skinvar passrequestvars
3663 public function parse_passrequestvars()
3665 $passvar = Admin::$passvar;
3666 $oldaction = postVar('oldaction');
3668 if ( ($oldaction != 'logout')
3669 && ($oldaction != 'login')
3671 && !postVar('customaction') )
3679 * AdminActions::parse_pluginextras()
3680 * Parse skinvar pluginextras
3682 * @param string $type type of plugin context
3685 public function parse_pluginextras($type = 'global')
3692 $id = intRequestVar('memberid');
3693 $mem =& $manager->getMember($id);
3694 $data = array('member' => &$mem);
3695 $manager->notify('MemberSettingsFormExtras', $data);
3698 $id = intRequestVar('blogid');
3699 $blg =& $manager->getBlog($id);
3700 $data = array('member' => &$blg);
3701 $manager->notify('BlogSettingsFormExtras', $data);
3703 case 'createaccount':
3705 'type' => 'createaccount.php',
3707 'postlabel' => '<br />',
3709 'postfield' => '<br /><br />'
3711 $manager->notify('RegistrationFormExtraFields', $data);
3715 $manager->notify('GeneralSettingsFormExtras', $data);
3722 * AdminActions::parse_pluginhelp()
3723 * Parse skinvar pluginhelp
3728 public function parse_pluginhelp()
3730 global $manager, $DIR_PLUGINS;
3732 $plugid = intGetVar('plugid');
3733 $plugName = $manager->getPluginNameFromPid($plugid);
3734 $plug =& $manager->getPlugin($plugName);
3736 if ( $plug->supportsFeature('HelpPage') > 0 )
3738 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3739 if ( @file_exists($helpfile . 'php') )
3741 @include($helpfile . 'php');
3744 elseif ( @file_exists($helpfile . 'html') )
3746 @include($helpfile . 'html');
3750 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3751 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3756 * AdminActions::parse_pluginlistlist()
3757 * Parse skinvar pluginlistlist
3759 * @param string $template_name name of template to use
3762 public function parse_pluginlistlist($template_name = '')
3764 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3765 $query = sprintf($query, sql_table('plugin'));
3767 $template['content'] = 'pluginlist';
3768 $template['tabindex'] = 10;
3770 $plugin_list = showlist($query, 'table', $template, $template_name);
3771 $this->parser->parse($plugin_list);
3777 * AdminActions::parse_pluginoptions()
3778 * Parse skinvar pluginoptions
3780 * @param string $type type of plugin option
3783 public function parse_pluginoptions($context='global', $template_name='')
3785 global $itemid, $manager;
3790 $contextid = intRequestVar('memberid');
3793 $contextid = intRequestVar('blogid');
3796 $contextid = intRequestVar('catid');
3799 $contextid = $itemid;
3803 /* Actually registererd plugin options */
3804 $aIdToValue = array();
3805 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
3806 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
3807 $res = DB::getResult($query);
3808 foreach ( $res as $row )
3810 $aIdToValue[$row['oid']] = $row['ovalue'];
3813 /* Currently available plugin options */
3814 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
3815 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
3816 $res = DB::getResult($query);
3819 foreach ($res as $row )
3821 if ( !array_key_exists($row['oid'], $aIdToValue) )
3823 $value = $row['odef'];
3827 $value = $aIdToValue[$row['oid']];
3831 'pid' => $row['pid'],
3832 'pfile' => $row['pfile'],
3833 'oid' => $row['oid'],
3835 'name' => $row['oname'],
3836 'description' => $row['odesc'],
3837 'type' => $row['otype'],
3838 'typeinfo' => $row['oextra'],
3839 'contextid' => $contextid,
3845 'context' => $context,
3846 'contextid' => $contextid,
3847 'options' => &$options
3849 $manager->notify('PrePluginOptionsEdit', $data);
3851 $template = array();
3852 if ( $template_name )
3854 $templates =& $manager->getTemplate($template_name);
3855 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3857 $template['title'] = "<tr>"
3858 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3863 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3866 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3868 $template['body'] = "<tr>"
3869 . "<%listplugplugoptionrow%>"
3874 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3880 foreach ( $options as $option )
3883 if ( $prevPid != $option['pid'] )
3885 $prevPid = $option['pid'];
3886 $this->parser->parse($template['title']);
3889 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3891 if ( @$meta['access'] != 'hidden' )
3893 $parsed = $this->parser->parse($template['body']);
3901 * AdminActions::parse_qmenuaddselect()
3902 * Parse skinvar qmanuaddselect
3904 * @param string $template_name name of template to use
3907 public function parse_qmenuaddselect($template_name = '')
3909 global $member, $blogid;
3910 $showAll = requestVar('showall');
3911 if ( $member->isAdmin() && ($showAll == 'yes') )
3913 // Super-Admins have access to all blogs! (no add item support though)
3914 $query = 'SELECT bnumber as value, bname as text FROM %s ORDER BY bname;';
3915 $query = sprintf($query, sql_table('blog'));
3919 $query = 'SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;';
3920 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3923 $template['name'] = 'blogid';
3924 $template['tabindex'] = 15000;
3925 $template['extra'] = _QMENU_ADD_SELECT;
3926 $template['selected'] = 0;
3927 $template['shorten'] = 10;
3928 $template['shortenel'] = '';
3929 $template['javascript'] = 'onchange="return form.submit()"';
3931 $selectlist = showlist($query, 'select', $template, $template_name);
3932 $this->parser->parse($selectlist);
3938 * AdminActions::parse_quickmenu()
3939 * Parse skinvar quickmenu
3941 * @param string $template_name name of template to use
3944 public function parse_quickmenu($template_name = '')
3947 $templates = array();
3949 if ( !empty($template_name) )
3951 $templates = & $manager->getTemplate($template_name);
3953 $pluginExtras = array();
3954 $data = array('options' => &$pluginExtras);
3955 $manager->notify('QuickMenu', $data);
3957 $template = array();
3958 if ( count($pluginExtras) > 0 )
3960 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3962 $template['head'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n"
3967 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3970 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
3972 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
3976 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3979 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3981 $template['foot'] = "</ul>\n";
3985 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3988 $this->parser->parse($template['head']);
3989 foreach ( $pluginExtras as $aInfo )
3992 'plugadminurl' => Entity::hsc($aInfo['url']),
3993 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
3994 'plugadmintitle' => Entity::hsc($aInfo['title']),
3996 $body = Template::fill($template['body'], $data);
3997 $this->parser->parse($body);
3999 $this->parser->parse($template['foot']);
4005 * AdminActions::parse_requestblogid()
4006 * Parse skinvar requestblogid
4011 public function parse_requestblogid()
4013 echo intRequestVar('blogid');
4018 * AdminActions::parse_requestiprange()
4019 * Parse skinvar requestiprange
4024 public function parse_requestiprange()
4026 if ( requestVar('iprange') )
4028 echo Entity::hsc(requestVar('iprange'));
4030 elseif ( requestVar('ip') )
4032 echo Entity::hsc(requestVar('ip'));
4038 * AdminActions::parse_selectlocalskinfiles()
4039 * Parse skinvar selectlocalskinfiles
4044 public function parse_selectlocalskinfiles()
4048 if ( !class_exists('SkinImport', FALSE) )
4050 include_libs('skinie.php');
4053 if ( !in_array($this->skintype, Admin::$adminskin_actions) && $this->skintype != 'importAdmin' )
4055 $skindir = $DIR_SKINS;
4059 $skindir = "{$DIR_SKINS}admin/";
4062 $candidates = SkinImport::searchForCandidates($skindir);
4063 foreach ( $candidates as $skinname => $skinfile )
4065 $skinname = Entity::hsc($skinname);
4066 if ( !in_array($this->skintype, Admin::$adminskin_actions) && $this->skintype != 'importAdmin' )
4068 $skinfile = Entity::hsc($skinfile);
4072 $skinfile = Entity::hsc("admin/$skinfile");
4074 echo "<option value=\"{$skinfile}\">{$skinname}</option>\n";
4081 * AdminActions::parse_skineditallowedlist()
4082 * Parse skinvar skineditallowedlist
4084 * @param string $type type of skin
4085 * @param string $template_name name of template
4088 public function parse_skineditallowedlist($type, $template_name = '')
4093 $query = "SELECT bshortname, bname FROM %s;";
4095 'content' => 'shortblognames'
4097 $query = sprintf($query, sql_table('blog'));
4100 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4102 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4106 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%';";
4109 'content' => 'shortnames'
4111 $query = sprintf($query, sql_table('template_desc'));
4115 $skin_list = showlist($query, 'table', $show, $template_name);
4116 $this->parser->parse($skin_list);
4121 * AdminActions::parse_skinielist()
4122 * Parse skinvar skinielist
4124 * @param string $type type of skin
4125 * @param string $template_name name of template to use
4128 public function parse_skinielist($type, $template_name = '')
4132 $templates = array();
4133 if ( $template_name )
4135 $templates =& $manager->getTemplate($template_name);
4137 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
4139 $template = "<tr>\n"
4141 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4142 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4144 . "<td><%expdesc%></td>\n"
4149 $template = $templates['SKINIE_EXPORT_LIST'];
4155 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4157 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4161 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname LIKE 'admin/%%';");
4163 foreach ( $res as $row )
4166 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4167 'expid' => 'skinexp' . $row['sdnumber'],
4168 'expname' => Entity::hsc($row['sdname']),
4169 'expdesc' => Entity::hsc($row['sddesc'])
4171 echo Template::fill($template, $data);
4175 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4177 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4181 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname LIKE 'admin/%%';");
4183 foreach ( $res as $row )
4186 'typeid' => 'template[' . $row['tdnumber'] . ']',
4187 'expid' => 'templateexp' . $row['tdnumber'],
4188 'expname' => Entity::hsc($row['tdname']),
4189 'expdesc' => Entity::hsc($row['tddesc'])
4191 echo Template::fill($template, $data);
4199 * AdminActions::parse_skinoverview()
4200 * Parse skinvar skinoverview
4202 * @param string $template_name name of template to use
4205 public function parse_skinoverview($template_name = '')
4209 $template = array();
4210 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4212 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%' ORDER BY sdname;";
4213 $template['handler'] = 'Actions';
4214 $template['editaction'] = 'skinedit';
4215 $template['cloneaction'] = 'skinclone';
4216 $template['deleteaction'] = 'skindelete';
4217 $template['edittypeaction'] = 'skinedittype';
4218 $template['default'] = $CONF['BaseSkin'];
4222 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
4223 $template['handler'] = 'AdminActions';
4224 $template['editaction'] = 'adminskinedit';
4225 $template['cloneaction'] = 'adminskinclone';
4226 $template['deleteaction'] = 'adminskindelete';
4227 $template['edittypeaction'] = 'adminskinedittype';
4228 $template['default'] = $CONF['AdminSkin'];
4230 $query = sprintf($query, sql_table('skin_desc'));
4232 $template['tabindex'] = 10;
4233 $template['content'] = 'skinlist';
4235 $skin_list = showlist($query, 'table', $template, $template_name);
4236 $this->parser->parse($skin_list);
4242 * AdminActions::parse_skintypehelp()
4243 * Check editing skintypehelp
4248 public function parse_skintypehelp()
4250 $surrent_skin_type = strtolower(trim(requestVar('type')));
4251 $page_action = strtolower(trim(requestVar('action')));
4252 if ( in_array($page_action, Admin::$adminskin_actions) )
4254 $normal_types = array_keys(self::$normal_skin_types);
4258 $normal_types = array_keys(Actions::getNormalSkinTypes());
4261 if ( in_array($surrent_skin_type, $normal_types) )
4263 help('skinpart' . $surrent_skin_type);
4267 help('skinpartspecial');
4273 * AdminActions::parse_specialskinlist()
4274 * Parse skinvar specialskinlist
4276 * @param string $template_name name of template to use
4279 public function parse_specialskinlist($template_name = '')
4281 global $CONF, $manager;
4283 $template = array();
4285 $skinid = intRequestVar('skinid');
4287 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4289 $skin =& $manager->getSkin($skinid);
4290 $template['editaction'] = 'skinedittype';
4291 $template['removeaction'] = 'skinremovetype';
4295 $skin =& $manager->getSkin($skinid, 'AdminActions');
4296 $template['editaction'] = 'adminskinedittype';
4297 $template['removeaction'] = 'adminskinremovetype';
4299 $normal_types = $skin->getNormalTypes();
4300 $available_types = $skin->getAvailableTypes();
4302 $special_skintypes = array();
4303 foreach( $available_types as $skintype => $skinname )
4305 if ( !array_key_exists($skintype, $normal_types) )
4307 $special_skintypes[] = array(
4308 'skintype' => $skintype,
4309 'skintypename' => $skinname
4314 if ( sizeof($special_skintypes) > 0 )
4316 $template['tabindex'] = 75;
4317 $template['skinid'] = $skin->getID();
4318 $template['skinname'] = $skin->getName();
4319 $skin_list = showlist($special_skintypes, 'list_specialskinlist', $template, $template_name);
4320 $this->parser->parse($skin_list);
4324 /* TODO: nothing to be shown */
4331 * AdminActions::parse_sprinttext()
4334 * @param string $which
4335 * @param string $val
4338 public function parse_sprinttext($which, $val)
4340 if ( !defined($which) )
4346 $base = constant($which);
4349 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4351 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4353 $met = 'parse_' . $matchies[0];
4357 $arg = trim($args[0], '()');
4358 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4361 if ( method_exists($this, $met) )
4363 $value = call_user_func(array(&$this, $met), $arg);
4367 if ( !isset($value) || empty($value) )
4371 echo sprintf($base, $value);
4376 * AdminActions::parse_systemsettings()
4377 * Parse skinvar systemsettings
4379 * @param string $type type of settings for system
4380 * @param string $template_name name of template to use
4383 public function parse_systemsettings($type = 'phpinfo', $template_name = '')
4385 global $manager, $member, $CONF, $nucleus;
4387 $member->isAdmin() or Admin::disallow();
4389 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4390 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4397 case 'sqlserverinfo':
4398 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4400 case 'sqlclientinfo':
4401 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4403 case 'magicquotesgpc':
4404 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4406 case 'magicquotesruntime':
4407 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4409 case 'registerglobals':
4410 echo ini_get('register_globals') ? 'On' : 'Off';
4413 $templates = array();
4414 if ( $template_name )
4416 $templates =& $manager->getTemplate($template_name);
4418 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4420 $template = "<tr>\n"
4421 . "<td><%key%></td>\n"
4422 . "<td><%value%></td>\n"
4427 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4430 $gdinfo = gd_info();
4432 foreach ( $gdinfo as $key => $value )
4434 if ( is_bool($value) )
4436 $value = $value ? $enable : $disable;
4440 $value = Entity::hsc($value);
4446 echo Template::fill($template, $data);
4450 if ( function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) )
4457 phpinfo(INFO_MODULES);
4458 $im = ob_get_contents();
4460 if ( i18n::strpos($im, 'mod_rewrite') !== FALSE )
4470 case 'nucleusversion':
4471 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4473 case 'nucleuspatchlevel':
4474 echo getNucleusPatchLevel();
4480 echo $CONF['ItemURL'];
4482 case 'alertonheaderssent':
4483 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4485 case 'nucleuscodename':
4486 if ( $nucleus['codename'] != '' )
4488 echo ' "' . $nucleus['codename'] . '"';
4491 case 'versioncheckurl':
4492 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4499 * AdminActions::parse_templateoverview()
4500 * Parse skinvar templateoverview
4502 * @param string $template_name name of template to use
4505 public function parse_templateoverview($template_name = '')
4507 if ( !in_array($this->skintype, Admin::$adminskin_actions) )
4509 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname;";
4510 $template['deleteaction'] = 'templatedelete';
4511 $template['editaction'] = 'templateedit';
4512 $template['cloneaction'] = 'templateclone';
4516 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
4517 $template['deleteaction'] = 'admintemplatedelete';
4518 $template['editaction'] = 'admintemplateedit';
4519 $template['cloneaction'] = 'admintemplateclone';
4521 $query = sprintf($query, sql_table('template_desc'));
4523 $template['tabindex'] = 10;
4524 $template['content'] = 'templatelist';
4526 $template_list = showlist($query, 'table', $template, $template_name);
4527 $this->parser->parse($template_list);
4533 * AdminActions::parse_ticket()
4539 public function parse_ticket()
4542 $manager->addTicketHidden();
4547 * AdminActions::parse_versioncheckurl()
4548 * Parse skinvar versioncheckurl
4553 public function parse_versioncheckurl()
4555 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4560 * AdminActions::parse_yrbloglist()
4561 * Parse skinvar yrbloglist
4563 * @param string $template_name name of template to use
4566 public function parse_yrbloglist($template_name = '')
4569 $showAll = requestVar('showall');
4571 if ( $member->isAdmin() && ($showAll == 'yes') )
4573 // Super-Admins have access to all blogs! (no add item support though)
4574 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4576 . " ORDER BY bnumber;";
4577 $query = sprintf($query, sql_table('blog'));
4581 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4583 . " WHERE tblog=bnumber and tmember=%d"
4584 . " ORDER BY bnumber;";
4585 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4588 $resource = DB::getResult($query);
4589 if ( ($showAll != 'yes') && $member->isAdmin() )
4591 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4592 $total = DB::getValue($query);
4594 if ( $total > $resource->rowCount() )
4596 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4600 if ( $resource->rowCount() > 0 )
4602 $template['content'] = 'bloglist';
4603 $template['superadmin'] = $member->isAdmin();
4605 $list_resource_table = showlist($resource, 'table', $template, $template_name);
4606 $this->parser->parse($list_resource_table);
4607 $resource->closeCursor();
4609 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4611 $query = 'SELECT ititle, inumber, bshortname FROM %s, %s '
4612 . 'WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4613 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4615 $resource = DB::getResult($query);
4616 if ( $resource->rowCount() > 0 )
4618 $template['content'] = 'draftlist';
4619 $draft_list = showlist($resource, 'table', $template, $template_name);
4620 $this->parser->parse($draft_list);
4624 echo _OVERVIEW_NODRAFTS;
4629 echo _OVERVIEW_NOBLOGS;
4631 $resource->closeCursor();
4637 * AdminActions::checkCondition()
4638 * Checks conditions for if statements
4640 * @param string $field type of <%if%>
4641 * @param string $name property of field
4642 * @param string $value value of property
4643 * @return boolean condition
4645 protected function checkCondition($field, $name='', $value = '')
4647 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4657 $blog =& $manager->getBlog($blogid);
4661 $blogid = getBlogIDFromCatID($catid);
4662 $blog =& $manager->getBlog($blogid);
4664 elseif ( intRequestVar('catid') )
4666 $catid = intRequestVar('catid');
4667 $blogid = getBlogIDFromCatID($catid);
4668 $blog =& $manager->getBlog($blogid);
4675 $condition = ($blog && $this->ifCategory($name, $value));
4678 $condition = $member->isLoggedIn();
4681 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4684 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4687 $condition = $member->isLoggedIn() && $member->isAdmin();
4689 case 'allowloginedit':
4690 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4693 $condition = ($itemidnext != '');
4696 $condition = ($itemidprev != '');
4698 case 'archiveprevexists':
4699 $condition = ($archiveprevexists == true);
4701 case 'archivenextexists':
4702 $condition = ($archivenextexists == true);
4705 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4708 $condition = $this->ifHasPlugin($name, $value);
4711 $condition = (Admin::$action == $name);
4713 case 'adminoldaction':
4714 $condition = (Admin::$action == $name);
4716 case 'addresschange':
4717 $condition = ($this->ifAddresscange());
4719 case 'bechangepass':
4720 $condition = ($this->beChangePassword());
4722 case 'skincandidates':
4723 $condition = ($this->ifSkincandidates());
4726 $condition = Admin::$contents['nameclashes'];
4728 case 'existsnewplugin':
4729 $condition = ($this->existsNewPlugin());
4736 $condition = (boolean) ($member->getAutosave() == $value);
4743 $condition = (Admin::$blog->getSetting($name) == $value);
4745 case 'itemproperty':
4750 if ( array_key_exists($name, Admin::$contents) )
4752 $condition = (boolean) (Admin::$contents[$name] == $value);
4756 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4763 * AdminActions::_ifHasPlugin()
4764 * hasplugin,PlugName
4765 * -> checks if plugin exists
4766 * hasplugin,PlugName,OptionName
4767 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
4768 * hasplugin,PlugName,OptionName=value
4769 * -> checks if the option OptionName from plugin PlugName is set to value
4771 * @param string $name name of plugin
4772 * @param string $value
4775 private function ifHasPlugin($name, $value)
4779 // (pluginInstalled method won't write a message in the actionlog on failure)
4780 if ( $manager->pluginInstalled("NP_{$name}") )
4782 $plugin =& $manager->getPlugin("NP_{$name}");
4783 if ( $plugin != NULL )
4791 list($name2, $value2) = preg_split('#=#', $value, 2);
4792 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4796 else if ( $plugin->getOption($name2) == $value2 )
4807 * AdminActions::beChangePassword()
4812 private function beChangePassword()
4814 return intRequestVar('bNeedsPasswordChange');
4818 * AdminActions::ifSkincandidates()
4819 * Checks if a plugin exists and call its doIf function
4825 private function ifSkincandidates()
4828 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4829 return (count($candidates) > 0);
4833 * AdminActions::ifPlugin()
4834 * Checks if a plugin exists and call its doIf function
4836 * @param string $name name of plugin
4837 * @param string $key
4838 * @param string $value
4841 private function ifPlugin($name, $key = '', $value = '')
4845 $plugin =& $manager->getPlugin("NP_{$name}");
4851 $params = func_get_args();
4852 array_shift($params);
4854 return call_user_func_array(array(&$plugin, 'doIf'), $params);
4858 * AdminActions::ifCategory()
4859 * Different checks for a category
4861 * @param string $key key for information of category
4862 * @param string $value value for information of category
4865 private function ifCategory($key = '', $value='')
4867 global $blog, $catid;
4869 // when no parameter is defined, just check if a category is selected
4870 if (($key != 'catname' && $key != 'catid') || ($value == ''))
4872 return $blog->isValidCategory($catid);
4875 // check category name
4876 if ( $key == 'catname' )
4878 $value = $blog->getCategoryIdFromName($value);
4879 if ($value == $catid)
4881 return $blog->isValidCategory($catid);
4885 // check category id
4886 if (($key == 'catid') && ($value == $catid))
4888 return $blog->isValidCategory($catid);
4895 * AdminActions::ifOnTeam()
4896 * Checks if a member is on the team of a blog and return his rights
4898 * @param string $blogName name of weblog
4901 private function ifOnTeam($blogName = '')
4903 global $blog, $member, $manager;
4905 // when no blog found
4906 if ( ($blogName == '') && !is_object($blog) )
4911 // explicit blog selection
4912 if ($blogName != '')
4914 $blogid = getBlogIDFromName($blogName);
4917 if (($blogName == '') || !$manager->existsBlogID($blogid))
4920 $blogid = $blog->getID();
4922 return $member->teamRights($blogid);
4926 * AdminActions::ifAdmin()
4927 * Checks if a member is admin of a blog
4929 * @param string $blogName name of weblog
4932 private function ifAdmin($blogName = '')
4934 global $blog, $member, $manager;
4936 // when no blog found
4937 if (($blogName == '') && (!is_object($blog)))
4942 // explicit blog selection
4943 if ($blogName != '')
4945 $blogid = getBlogIDFromName($blogName);
4948 if (($blogName == '') || !$manager->existsBlogID($blogid))
4951 $blogid = $blog->getID();
4954 return $member->isBlogAdmin($blogid);
4958 * AdminActions::ifAddresscange()
4959 * Check e-Mail address is changed
4964 private function ifAddresscange()
4968 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4973 $info = MEMBER::getActivationInfo($key);
4978 $mem =& $manager->getMember($info->vmember);
4983 if ( $info->vtype == 'addresschange' )
4992 * AdminActions::customHelp()
4993 * shows a link to custom help file
4996 * @param string $tplName
4997 * @param string $url
4998 * @param string $iconURL
4999 * @param string $alt
5000 * @param string $title
5004 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5006 echo $this->customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5011 * AdminActions::customHelp()
5012 * shows a link to custom help file
5015 * @param string $tplName
5016 * @param string $url
5017 * @param string $iconURL
5018 * @param string $alt
5019 * @param string $title
5023 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5025 global $CONF, $manager;
5027 $templates = array();
5031 $templates =& $manager->getTemplate($tplName);
5034 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5036 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5040 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5045 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5048 if ( empty($onclick) )
5050 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5052 elseif ( preg_match('#^onclick#', $onclick) )
5054 $onclick = $onclick;
5058 $onclick = 'onclick="' . $onclick . '"';
5063 'helptarget' => $id,
5064 'onclick' => $onclick,
5065 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5067 return Template::fill($template, $data);
5072 * AdminActions::customHelpHtml()
5074 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5076 global $CONF, $manager;
5078 $templates = array();
5082 $templates =& $manager->getTemplate($tplName);
5084 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5086 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5090 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5093 if ( empty($iconURL) )
5095 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5098 if ( function_exists('getimagesize') )
5100 $size = getimagesize($iconURL);
5101 $width = 'width="' . $size[0] . '" ';
5102 $height = 'height="' . $size[1] . '" ';
5106 'iconurl' => $iconURL,
5108 'height' => $height,
5109 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5110 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5113 $icon = Template::fill($template, $data);
5114 $help = $this->customHelplink($id, $tplName, $url, $title, $onclick);
5116 return $help . $icon;
5120 * AdminActions::existsNewPlugin()
5121 * Check exists new plugin
5124 * @return boolean exists or not
5126 private function existsNewPlugin()
5128 global $DIR_PLUGINS;
5130 $query = "SELECT * FROM %s;";
5131 $query = sprintf($query, sql_table('plugin'));
5132 $res = DB::getResult($query);
5134 $installed = array();
5135 foreach( $res as $row )
5137 $installed[] = $row['pfile'];
5140 $files = scandir($DIR_PLUGINS);
5142 $candidates = array();
5143 foreach ( $files as $file )
5145 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5147 if ( !in_array($matches[1], $installed) )
5149 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5153 $this->newPlugCandidates = $candidates;
5154 return (count($candidates) > 0);
5158 * AdminActions::pagehead()
5159 * Output admin page head
5164 public function parse_pagehead()
5166 global $member, $nucleus, $CONF, $manager;
5168 /* HTTP 1.1 application for no caching */
5169 header("Cache-Control: no-cache, must-revalidate");
5170 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5172 $content = $this->parser->skin->getContentFromDB('pagehead');
5175 $root_element = 'html';
5176 $charset = i18n::get_current_charset();
5177 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5178 $xml_version_info = '1.0';
5179 $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
5180 $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
5181 $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
5183 $content = "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n"
5184 . "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n"
5185 . "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n"
5187 . "<title><%sitevar(name)%> - Admin</title>\n"
5188 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>"
5189 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>"
5190 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>"
5194 . "<div id=\"adminwrapper\">"
5195 . "<div class=\"header\">"
5196 . "<h1><%sitevar(name)%></h1>"
5198 . "<div id=\"container\">"
5199 . "<div id=\"content\">"
5200 . "<div class=\"loginname\">"
5201 . "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"<%skinfile(admin/defaultadmin/styles/addedit.css%>\" />\n"
5202 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>\n"
5203 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>\n"
5204 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>\n"
5209 . "<div id=\"adminwrapper\">\n"
5210 . "<div class=\"header\">\n"
5211 . "<h1><%sitevar(name)%></h1>\n"
5213 . "<div id=\"container\">\n"
5214 . "<div id=\"content\">\n"
5215 . "<div class=\"loginname\">\n"
5216 . "<%if(loggedin)%>"
5217 . "<%text(_LOGGEDINAS)%> <%member(yourrealname)%> - <a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a><br />"
5218 . "<a href=\"<%adminurl%>index.php?action=overview\"><%text(_ADMINHOME)%></a> - "
5220 . "<a href=\"<%adminurl%>index.php?action=showlogin\" title=\"Log in\"><%text(_NOTLOGGEDIN)%></a><br />"
5222 . "<a href=\"<%sitevar(url)%>\"><%text(_YOURSITE)%></a><br />"
5224 . "<%if(superadmin)%>"
5225 . "<a href=\"<%versioncheckurl%>\" title=\"<%text(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE)%>\"><%version%><%codename%></a>"
5226 . "<%newestcompare%><%else%><%version%><%codename%>"
5232 $this->parser->parse($content);
5237 * AdminActionss::pagefoot()
5238 * Output admin page foot include quickmenu
5243 public function parse_pagefoot()
5245 global $action, $member, $manager, $blogid;
5247 $data = array('action' => Admin::$action);
5248 $manager->notify('AdminPrePageFoot', $data);
5250 $content = $this->parser->skin->getContentFromDB('pagefoot');
5253 $content = "<%if(loggedin)%>"
5254 . "<%ifnot(adminaction,showlogin)%>"
5255 . "<h2><%text(_LOGOUT)%></h2>"
5257 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_BACKHOME)%></a></li>"
5258 . "<li><a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a></li>"
5262 . "<div class=\"foot\">"
5263 . "<a href=\"<%text(_ADMINPAGEFOOT_OFFICIALURL)%>\">Nucleus CMS</a> © 2002- <%date(%Y)%> <%text(_ADMINPAGEFOOT_COPYRIGHT)%>"
5264 . " - <a href=\"<%text(_ADMINPAGEFOOT_DONATEURL)%>\"><%text(_ADMINPAGEFOOT_DONATE)%></a>"
5267 . "<!-- content -->"
5268 . "<div id=\"quickmenu\">"
5269 . "<%if(loggedin)%>"
5270 . "<%ifnot(adminaction,showlogin)%>"
5272 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_QMENU_HOME)%></a></li>"
5274 . "<h2><%text(_QMENU_ADD)%></h2>"
5275 . "<form method=\"get\" action=\"<%adminurl%>index.php\">"
5277 . "<input type=\"hidden\" name=\"action\" value=\"createitem\" />"
5278 . "<%qmenuaddselect(admin/default)%>"
5281 . "<h2><%member(yourrealname)%></h2>"
5283 . "<li><a href=\"<%adminurl%>index.php?action=editmembersettings\"><%text(_QMENU_USER_SETTINGS)%></a></li>"
5284 . "<li><a href=\"<%adminurl%>index.php?action=browseownitems\"><%text(_QMENU_USER_ITEMS)%></a></li>"
5285 . "<li><a href=\"<%adminurl%>index.php?action=browseowncomments\"><%text(_QMENU_USER_COMMENTS)%></a></li>"
5287 . "<%if(superadmin)%>"
5288 . "<h2><%text(_QMENU_MANAGE)%></h2>"
5290 . "<li><a href=\"<%adminurl%>index.php?action=actionlog\"><%text(_QMENU_MANAGE_LOG)%></a></li>"
5291 . "<li><a href=\"<%adminurl%>index.php?action=settingsedit\"><%text(_QMENU_MANAGE_SETTINGS)%></a></li>"
5292 . "<li><a href=\"<%adminurl%>index.php?action=systemoverview\"><%text(_QMENU_MANAGE_SYSTEM)%></a></li>"
5293 . "<li><a href=\"<%adminurl%>index.php?action=usermanagement\"><%text(_QMENU_MANAGE_MEMBERS)%></a></li>"
5294 . "<li><a href=\"<%adminurl%>index.php?action=createnewlog\"><%text(_QMENU_MANAGE_NEWBLOG)%></a></li>"
5295 . "<li><a href=\"<%adminurl%>index.php?action=backupoverview\"><%text(_QMENU_MANAGE_BACKUPS)%></a></li>"
5296 . "<li><a href=\"<%adminurl%>index.php?action=pluginlist\"><%text(_QMENU_MANAGE_PLUGINS)%></a></li>"
5298 . "<h2><%text(_QMENU_LAYOUT)%></h2>"
5300 . "<li><a href=\"<%adminurl%>index.php?action=skinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5301 . "<li><a href=\"<%adminurl%>index.php?action=templateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5302 . "<li><a href=\"<%adminurl%>index.php?action=skinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5304 . "<h2><%text(_SKINABLEADMIN_QMENU_LAYOUT)%></h2>"
5306 . "<li><a href=\"<%adminurl%>index.php?action=adminskinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5307 . "<li><a href=\"<%adminurl%>index.php?action=admintemplateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5308 . "<li><a href=\"<%adminurl%>index.php?action=adminskinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5311 . "<%quickmenu(admin/default)%>"
5313 . "<%elseif(adminaction,activate)%>"
5314 . "<h2><%text(_QMENU_ACTIVATE)%></h2>"
5315 . "<%text(_QMENU_ACTIVATE_TEXT)%>"
5316 . "<%elseif(adminaction,activatesetpwd)%>"
5317 . "<h2><%text(_QMENU_ACTIVATE)%></h2><%text(_QMENU_ACTIVATE_TEXT)%>"
5319 . "<h2><%text(_QMENU_INTRO)%></h2><%text(_QMENU_INTRO_TEXT)%>"
5322 . "<!-- content / quickmenu container -->"
5323 . "<div class=\"clear\"></div>"
5326 . "<!-- adminwrapper -->"
5330 . "<p style=\"text-align:right;\"><%benchmark%></p>"
5335 $this->parser->parse($content);
5339 * AdminActions::selectBlog()
5340 * Inserts a HTML select element with choices for all blogs to which the user has access
5341 * mode = 'blog' => shows blognames and values are blogids
5342 * mode = 'category' => show category names and values are catids
5344 * @param string $name
5345 * @param string $mode
5346 * @param integer $selected
5347 * @param integer $tabindex
5348 * @param integer $showNewCat
5349 * @param integer $iForcedBlogInclude ID for weblog always included
5350 * @param $iForcedBlogInclude
5351 * ID of a blog that always needs to be included, without checking if the
5352 * member is on the blog team (-1 = none)
5355 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5357 global $member, $CONF;
5359 // 0. get IDs of blogs to which member can post items (+ forced blog)
5360 $aBlogIds = array();
5361 if ( $iForcedBlogInclude != -1 )
5363 $aBlogIds[] = intval($iForcedBlogInclude);
5366 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5368 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5369 $query = sprintf($query, sql_table('blog'));
5373 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5374 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5377 $rblogids = DB::getResult($query);
5378 foreach ( $rblogids as $row )
5380 if ( $row['bnumber'] != $iForcedBlogInclude )
5382 $aBlogIds[] = intval($row['bnumber']);
5386 if ( count($aBlogIds) == 0 )
5391 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5393 // 1. select blogs (we'll create optiongroups)
5394 // (only select those blogs that have the user on the team)
5395 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5396 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5397 $blogs = DB::getResult($queryBlogs);
5399 if ( $mode == 'category' )
5401 if ( $blogs->rowCount() > 1 )
5405 foreach ( $blogs as $rBlog )
5407 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5409 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5412 // show selection to create new category when allowed/wanted
5415 // check if allowed to do so
5416 if ( $member->blogAdminRights($rBlog['bnumber']) )
5418 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5422 // 2. for each category in that blog
5423 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5424 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5425 $categories = DB::getResult($catQuery);
5426 foreach ( $categories as $rCat )
5428 if ( $rCat['catid'] == $selected )
5430 $selectText = ' selected="selected" ';
5436 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5439 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5447 foreach ( $blogs as $rBlog )
5449 echo '<option value="' . $rBlog['bnumber'] . '"';
5450 if ( $rBlog['bnumber'] == $selected )
5452 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5456 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";