2 if ( !class_exists('BaseActions') )
4 include $DIR_LIBS . 'BaseActions.php';
8 class AdminActions extends BaseActions
13 * AdminActions::$default_actions
14 * list of whole action names with which this class can deal
16 static private $default_actions = array(
40 * AdminActions::$skin_type_friendly_names
41 * friendly name for wrapped page types
43 static private $default_skin_types = array(
44 'actionlog' => _ADM_SKPRT_ACTIONLOG,
45 'activate' => _ADM_SKPRT_ACTIVATE,
46 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
47 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
48 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
49 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
50 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
51 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
52 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
53 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
54 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
55 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
56 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
57 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
58 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
59 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
60 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
61 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
62 'banlist' => _ADM_SKPRT_BANLIST,
63 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
64 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
65 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
66 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
67 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
68 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
69 'batchitem' => _ADM_SKPRT_BATCHITEM,
70 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
71 'batchmove' => _ADM_SKPRT_BATCHMOVE,
72 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
73 'batchteam' => _ADM_SKPRT_BATCHTEAM,
74 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
75 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
76 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
77 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
78 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
79 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
80 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
81 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
82 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
83 'createitem' => _ADM_SKPRT_CREATEITEM,
84 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
85 'createaccountinput' => _ADM_SKPRT_CREATEACCOUNTINPUT, /* not yet */
86 'createaccountsuccess' => _ADM_SKPRT_CREATEACCOUNTSUCCESS, /* not yet */
87 'createaccountdisable' => _ADM_SKPRT_CREATEACCOUNTDISALLOWED, /* not yet */
88 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
89 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
90 'forgotpassword' => _ADM_SKPRT_FORGOTPASSWORD, /* not yet */
91 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
92 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
93 'itemedit' => _ADM_SKPRT_ITEMEDIT,
94 'itemlist' => _ADM_SKPRT_ITEMLIST,
95 'itemmove' => _ADM_SKPRT_ITEMMOVE,
96 'login' => FALSE, //missing
97 'manage' => _ADM_SKPRT_MANAGE,
98 'manageteam' => _ADM_SKPRT_MANAGETEAM,
99 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
100 'memberedit' => FALSE, //missing
101 'overview' => _ADM_SKPRT_OVERVIEW,
102 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
103 'pagehead' => _ADM_SKPRT_PAGEHEAD,
104 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
105 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
106 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
107 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
108 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
109 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
110 'skindelete' => _ADM_SKPRT_SKINDELETE,
111 'skinedit' => _ADM_SKPRT_SKINEDIT,
112 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
113 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
114 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
115 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
116 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
117 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
118 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
119 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
120 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
121 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
122 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
123 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
127 * AdminActions::getAvailableSkinTypes()
131 * @return array list of friendly names for page actions
133 static public function getAvailableSkinTypes()
135 return self::$default_skin_types;
139 * AdminActions::getDefaultTypes()
143 * @return array list of friendly names for page actions
145 static public function getDefaultTypes()
147 return self::$default_skin_types;
151 * AdminActions::__construct()
152 * Constructor for a new Actions object
154 * @param string $type
157 public function __construct($type)
159 // call constructor of superclass first
160 parent::__construct();
163 if ( $type == 'admntemplateoverview' )
165 $this->skintype = 'admintemplateoverview';
169 $this->skintype = $type;
176 * AdminActions::getAvailableActions()
179 * @return array allowed actions for the page type
181 public function getAvailableActions()
183 $extra_actions = array();
185 switch ( $this->skintype )
188 $extra_actions = array(
193 $extra_actions = array(
198 case 'activatesetpwd':
199 $extra_actions = array(
200 /* nothing special */
204 $extra_actions = array(
210 case 'adminerrorpage':
211 $extra_actions = array(
212 /* nothing special */
215 case 'adminskindelete':
216 $extra_actions = array(
220 case 'adminskinedit':
221 $extra_actions = array(
227 case 'adminskinedittype':
228 $extra_actions = array(
231 'allowedskinactions',
232 'skineditallowedlist',
235 case 'adminskiniedoimport':
236 $extra_actions = array(
240 case 'adminskinieimport':
241 $extra_actions = array(
245 case 'adminskinieoverview':
246 $extra_actions = array(
247 'selectlocalskinfiles',
251 case 'adminskinoverview':
252 $extra_actions = array(
256 case 'adminskinremovetype':
257 $extra_actions = array(
261 case 'admintemplatedelete':
262 $extra_actions = array(
263 'editadmintemplateinfo',
265 case 'admintemplateedit':
266 $extra_actions = array(
270 case 'admintemplateoverview':
271 $extra_actions = array(
275 case 'backupoverview':
276 $extra_actions = array(
277 /* nothing special */
280 case 'backuprestore':
281 $extra_actions = array(
282 /* nothing special */
286 $extra_actions = array(
292 case 'banlistdelete':
293 $extra_actions = array(
298 case 'banlistdeleteconfirm':
299 $extra_actions = array(
300 'banlistdeletedlist',
305 $extra_actions = array(
311 case 'batchcategory':
312 $extra_actions = array(
318 $extra_actions = array(
324 $extra_actions = array(
330 $extra_actions = array(
336 $extra_actions = array(
342 $extra_actions = array(
351 $extra_actions = array(
360 $extra_actions = array(
366 case 'blogcommentlist':
367 $extra_actions = array(
374 $extra_actions = array(
390 $extra_actions = array(
394 case 'browseowncomments':
395 $extra_actions = array(
399 case 'browseownitems':
400 $extra_actions = array(
404 case 'categorydelete':
405 $extra_actions = array(
411 $extra_actions = array(
418 case 'commentdelete':
419 $extra_actions = array(
424 $extra_actions = array(
428 case 'createaccountinput':
429 $extra_actions = array(
435 case 'createaccountsuccess':
436 $extra_actions = array(
\r
440 case 'createaccountdisable':
441 $extra_actions = array(
442 /* nothing special */
446 $extra_actions = array(
458 $extra_actions = array(
464 $extra_actions = array(
469 case 'editmembersettings':
470 $extra_actions = array(
473 'localeselectoptions',
477 case 'forgotpassword':
478 $extra_actions = array(
479 /* nothing special */
482 case 'itemcommentlist':
483 $extra_actions = array(
489 $extra_actions = array(
496 $extra_actions = array(
508 $extra_actions = array(
515 $extra_actions = array(
521 $extra_actions = array(
522 /* nothing special */
526 $extra_actions = array(
535 $extra_actions = array(
540 $extra_actions = array(
545 $extra_actions = array(
550 $extra_actions = array(
556 $extra_actions = array(
561 case 'pluginoptions':
562 $extra_actions = array(
564 'editplugoptionslist',
568 $extra_actions = array(
571 'configsettingsedit',
572 'configsettingsyesno',
575 'localeselectoptions',
581 $extra_actions = array(
586 $extra_actions = array(
591 $extra_actions = array(
598 $extra_actions = array(
601 'allowedskinactions',
602 'skineditallowedlist'
605 case 'skiniedoimport':
606 $extra_actions = array(
611 $extra_actions = array(
615 case 'skinieoverview':
616 $extra_actions = array(
617 'selectlocalskinfiles',
622 $extra_actions = array(
626 case 'skinremovetype':
627 $extra_actions = array(
631 case 'systemoverview':
632 $extra_actions = array(
637 $extra_actions = array(
643 case 'templatedelete':
644 $extra_actions = array(
649 $extra_actions = array(
653 case 'templateoverview':
654 $extra_actions = array(
658 case 'usermanagement':
659 $extra_actions = array(
665 $extra_actions = array(
674 'selectlocalskinfiles',
682 $defined_actions = array_merge(self::$default_actions, $extra_actions);
684 return array_merge($defined_actions, parent::getAvailableActions());
688 * AdminActions::parse_actionloglist()
689 * Parse skinvar actionloglist
691 * @param string $template_name name of template to use
694 public function parse_actionloglist($template_name = '')
696 $query = "SELECT * FROM %s ORDER BY timestamp DESC;";
697 $query = sprintf($query, sql_table('actionlog'));
699 $resource = DB::getResult($query);
700 if ( $resource->rowCount() > 0 )
702 $template['content'] = 'actionlist';
703 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
707 /* TODO: nothing to be shown */
713 * AdminActions::parse_activationmessage()
714 * Parse skinvar activationmessage
716 * @param string $type type of message
717 * @param string $template_name name of template to use
720 public function parse_activationmessage($type, $template_name = '')
722 global $CONF, $manager;
726 if ( !empty($template_name))
728 $template =& $manager->getTemplate($template_name);
731 $key = postVar('ackey');
734 Admin::error(_ERROR_ACTIVATE);
737 $info = MEMBER::getActivationInfo($key);
740 Admin::error(_ERROR_ACTIVATE);
743 $mem =& $manager->getMember($info->vmember);
746 Admin::error(_ERROR_ACTIVATE);
748 switch ( $info->vtype )
751 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
753 $title = $template['ACTIVATE_FORGOT_TITLE'];
757 $title = _ACTIVATE_FORGOT_TITLE;
759 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
761 $text = $template['ACTIVATE_FORGOT_TEXT'];
765 $text = _ACTIVATE_FORGOT_TEXT;
769 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
771 $title = $template['ACTIVATE_REGISTER_TITLE'];
775 $title = _ACTIVATE_REGISTER_TITLE;
777 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
779 $text = $template['ACTIVATE_REGISTER_TEXT'];
783 $text = _ACTIVATE_REGISTER_TEXT;
786 case 'addresschange':
787 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
789 $title = $template['ACTIVATE_CHANGE_TITLE'];
793 $title = _ACTIVATE_CHANGE_TITLE;
795 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
797 $text = $template['ACTIVATE_CHANGE_TEXT'];
801 $text = _ACTIVATE_CHANGE_TEXT;
806 'memberName' => Entity::hsc($mem->getDisplayName()),
807 'realName' => Entity::hsc($mem->getRealName()),
812 echo Template::fill($title, $aVars);
815 echo Template::fill($text, $aVars);
818 echo Entity::hsc($key);
825 * AdminActions::parse_addtickettourl()
826 * Parse skinvar addtickettourl
828 * @param string $url URI for ticket
831 public function parse_addtickettourl($url)
834 $url = $manager->addTicketToUrl($url);
835 echo Entity::hsc($url);
840 * AdminActions::parse_adminbanlist()
841 * Parse skinvar adminbanlist
843 * @param string $template_name name of template to use
846 public function parse_adminbanlist($template_name = '')
848 $blogid = intRequestVar('blogid');
850 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
851 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
853 $resource = DB::getResult($query);
854 if ( $resource->rowCount() > 0 )
856 $template['content'] = 'banlist';
857 $this->parser-parse(showlist($resource, 'table', $template, $template_name));
867 * AdminActions::parse_adminbatchaction()
868 * Parse skinvar adminbatchaction
873 public function parse_adminbatchaction()
875 echo Entity::hsc(requestVar('batchaction'));
880 * AdminActions::parse_adminbatchlist()
881 * Parse skinvar adminbatchlist
883 * @param string $template_name name of template to use
886 public function parse_adminbatchlist($template_name = '')
889 $templates = array();
891 if ( !empty($template_name) )
893 $templates =& $manager->getTemplate($template_name);
896 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
898 $template = '<li><%text(_BATCH_EXECUTING)%> '
899 . '<b><%adminbatchaction%></b> '
900 . '<%batchlisttype%> '
901 . '<b><%batchid%></b>... '
902 . '<b><%batchlistmsg%></b>'
907 $template = $templates['ADMIN_BATCHLIST'];
910 $selected = requestIntArray('batch');
911 $action = requestVar('batchaction');
913 switch ( $this->skintype )
916 $batchlisttype = _BATCH_ONITEM;
917 $deleteaction = 'deleteOneItem';
918 $moveaction = 'moveOneItem';
919 $destid = intRequestVar('destcatid');
922 $batchlisttype = _BATCH_ONCOMMENT;
923 $deleteaction = 'deleteOneComment';
926 $batchlisttype = _BATCH_ONMEMBER;
927 $deleteaction = 'deleteOneMember';
928 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
929 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
930 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
931 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
934 $blogid = intRequestVar('blogid');
935 $batchlisttype = _BATCH_ONTEAM;
936 $deleteaction = 'deleteOneTeamMember';
937 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
938 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
939 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
940 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
942 case 'batchcategory':
943 $batchlisttype = _BATCH_ONCATEGORY;
944 $deleteaction = 'deleteOneCategory';
945 $moveaction = 'moveOneCategory';
946 $destid = intRequestVar('destblogid');
950 // walk over all selectedids and perform action
951 foreach ( $selected as $selectedid )
954 $selectedid = intval($selectedid);
958 if ( $this->skintype != 'batchteam' )
960 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
964 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
968 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
972 DB::execute("UPDATE {$setadminsql} {$selectedid};");
976 // there should always remain at least one super-admin
977 $r = DB::getResult($unsetchksql);
978 if ( $r->rowCount() < 2 )
980 $error = $unseterrmsg;
984 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
988 $error = _BATCH_UNKNOWN . Entity::hsc($action);
992 'batchid' => $selectedid,
993 'batchlisttype' => Entity::hsc($batchlisttype),
994 'adminbatchaction' => Entity::hsc($action),
995 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
998 $this->parser->parse(Template::fill($template, $data));
1005 * AdminActions::parse_adminbloglink()
1006 * Parse skinvar adminbloglink
1008 * @param string $template_name name of template to use
1011 public function parse_adminbloglink($template_name = '')
1014 $blogid = intRequestVar('blogid');
1015 $blog =& $manager->getBlog($blogid);
1016 $templates = array();
1018 if ( !empty($template_name) )
1020 $templates =& $manager->getTemplate($template_name);
1023 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1025 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1029 $template = $templates['ADMIN_BLOGLINK'];
1033 'url' => Entity::hsc($blog->getURL()),
1034 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1035 'blogname' => Entity::hsc($blog->getName())
1038 echo Template::fill($template, $data);
1043 * AdminActions::parse_adminerrormesg()
1044 * Parse skinvar adminerrormesg
1049 public function parse_adminerrormesg()
1054 if ( requestVar('errormessage') )
1056 $message = requestVar('errormessage');
1058 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1060 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1062 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1064 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1066 echo Entity::hsc($message);
1071 * AdminActions::parse_allowedskinactions()
1072 * Parse skinvar allowedskinactions
1077 public function parse_allowedskinactions()
1079 $type = strtolower(trim(requestVar('type')));
1080 $skinid = intRequestVar('skinid');
1082 if ( !preg_match('#^admin#', $this->skintype) )
1084 $skin = new Skin($skinid);
1089 $skin = new Skin($skinid, 'AdminActions');
1090 $tag = 'adminskinvar';
1093 $actions = $skin->getAllowedActionsForType($type);
1096 while ( $current = array_shift($actions) )
1098 echo helplink("{$tag}-{$current}") . "$current</a>\n";
1100 if ( count($actions) != 0 )
1109 * AdminActions::parse_banlistdeletedlist()
1110 * Parse skinvar banlistdeletedlist
1112 * @param string $template_name name of template to use
1115 public function parse_banlistdeletedlist($template_name = '')
1119 $templates = array();
1120 if ( $template_name )
1122 $templates =& $manager->getTemplate($template_name);
1125 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1127 $template = "<li><%blogname%></li>\n";
1131 $template = $templates['BANLIST_DELETED_LIST'];
1134 $deleted = requestArray('delblogs');
1135 foreach ( $deleted as $delblog )
1137 $blog =& $manager->getBlog($delblog);
1139 'blogname' => Entity::hsc($blog->getName())
1141 echo Template::fill($template, $data);
1148 * AdminActions::parse_batchdeletelist()
1149 * Parse skinvar batchdeletelist
1154 public function parse_batchdeletelist()
1156 $selected = requestIntArray('batch');
1159 foreach ( $selected as $select )
1161 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1163 // add hidden vars for team & comment
1164 if ( requestVar('action') == 'batchteam' )
1166 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1168 if ( requestVar('action') == 'batchcomment' )
1170 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1176 * AdminActions::parse_batchdeletetype()
1177 * Parse skinvar batchdeletetype
1182 public function parse_batchdeletetype()
1184 echo Entity::hsc(requestVar('action'));
1189 * AdminActions::parse_batchmovebtn()
1190 * Parse skinvar batchmovebtn
1195 public function parse_batchmovebtn()
1197 $actionType = requestVar('action');
1198 switch ( $actionType )
1203 case 'batchcategory':
1211 * AdminActions::parse_batchmovelist()
1212 * Parse skinvar batchmovelist
1217 public function parse_batchmovelist()
1219 $selected = requestIntArray('batch');
1221 foreach ( $selected as $select )
1223 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1230 * AdminActions::parse_batchmovetitle()
1231 * Parse skinvar batchmovetitle
1236 public function parse_batchmovetitle()
1238 $actionType = requestVar('action');
1239 switch ( $actionType )
1244 case 'batchcategory':
1245 echo _MOVECAT_TITLE;
1252 * AdminActions::parse_batchmovetype()
1253 * Parse skinvar batchmovetype
1258 public function parse_batchmovetype()
1260 echo Entity::hsc(requestVar('action'));
1265 * AdminActions::parse_blogcatlist()
1266 * Parse skinvar blogcatlist
1271 public function parse_blogcatlist($template_name = '')
1274 $blogid = intRequestVar('blogid');
1275 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1276 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1278 $resource = DB::getResult($query);
1279 if ( $resource->rowCount() > 0 )
1281 $template['content'] = 'categorylist';
1282 $template['tabindex'] = 200;
1283 $this->parser->parse(listplug_batchlist('category', $resource, 'table', $template));
1287 /* TODO: nothing to be shown */
1289 $resource->closeCursor();
1295 * AdminActions::parse_blogid()
1296 * Parse skinvar blogid
1301 public function parse_blogid()
1303 echo intRequestVar('blogid');
1308 * AdminActions::parse_blognotifysetting()
1309 * Parse skinvar blognotifysetting
1314 public function parse_blognotifysetting($type)
1317 $blogid = intRequestVar('blogid');
1318 $blog =& $manager->getBlog($blogid);
1323 if ( !$blog->notifyOnComment() )
1329 if ( !$blog->notifyOnVote() )
1335 if ( !$blog->notifyOnNewItem() )
1341 echo ' checked="checked"';
1346 * AdminActions::parse_blogsetting()
1347 * Parse skinvar blogsetting
1349 * @param string $which name of weblog setting
1352 public function parse_blogsetting($which)
1354 echo $this->parse_getblogsetting($which);
1359 * AdminActions::parse_blogsettingyesno()
1360 * Parse skinvar blogsettingyesno
1362 * @param string $type type of weblog setting
1363 * @param string $template_name name of template to use
1366 public function parse_blogsettingyesno($type, $template_name = '')
1370 $blogid = intRequestVar('blogid');
1371 $blog =& $manager->getBlog($blogid);
1375 case 'convertbreaks':
1376 $checkedval = $blog->convertBreaks();
1379 case 'allowpastposting':
1380 $checkedval = $blog->allowPastPosting();
1384 $checkedval = $blog->commentsEnabled();
1388 $checkedval = $blog->isPublic();
1392 $checkedval = $blog->emailRequired();
1396 $checkedval = $blog->getSearchable();
1400 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $template_name);
1405 * AdminActions::parse_blogteamlist()
1406 * Parse skinvar blogteamlist
1408 * @param string $template_name name of template to use
1411 public function parse_blogteamlist($template_name = '')
1414 $blogid = intRequestVar('blogid');
1415 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1417 . "WHERE tmember=mnumber AND tblog= %d";
1418 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1420 $resource = DB::getResult($query);
1421 if ( $resource->rowCount() > 0 )
1423 $template['content'] = 'teamlist';
1424 $template['tabindex'] = 10;
1426 $this->parser->parse(listplug_batchlist('team', $resource, 'table', $template));
1432 $resource->closeCursor();
1438 * AdminActions::parse_blogteammembers()
1439 * Parse skinvar blogteammembers
1444 public function parse_blogteammembers()
1446 $blogid = intRequestVar('blogid');
1447 $query = "SELECT mname, mrealname "
1449 . "WHERE mnumber=tmember AND tblog=%d;";
1450 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1451 $res = DB::getResult($query);
1452 $memberNames = array();
1453 foreach ( $res as $row )
1455 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1457 echo implode(',', $memberNames);
1461 * AdminActions::parse_blogtime()
1462 * Parse skinvar blogtime
1464 * @param string $type type of time
1465 * @param string $format format for time expression
1466 * @param integer $offset offset of time
1469 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1473 if ( $type != 'blogtime' )
1475 /* return server time */
1476 $timestamp = time() + $offset;
1480 $bid = intRequestVar('blogid');
1481 $b =& $manager->getBlog($bid);
1482 $timestamp = $b->getCorrectTime() + $offset;
1485 echo i18n::formatted_datetime($format, $timestamp);
1490 * AdminActions::parse_bookmarkletadmin()
1491 * Parse skinvar bookmarkletadmin
1496 public function parse_bookmarkletadmin()
1500 $blogid = intRequestVar('blogid');
1502 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1507 * AdminActions::parse_categories()
1508 * Parse skinvar categories
1510 * create category dropdown box
1512 * @param string $type name of setting for category
1515 public function parse_categories($startidx = 0)
1520 $itemid = intRequestVar('itemid');
1521 $item = &$manager->getItem($itemid, 1, 1);
1526 $blogid = intRequestVar('blogid');
1530 $blogid = $item['blogid'];
1532 $blog = &$manager->getBlog($blogid);
1534 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1536 $item['body'] = removeBreaks($item['body']);
1537 $item['more'] = removeBreaks($item['more']);
1540 $contents = array();
1541 if ( requestVar('action') == 'itemedit' )
1546 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1549 $catid = $blog->getDefaultCategory();
1554 $catid = $contents['catid'];
1557 $this->selectBlog('catid', 'category', $catid, $startidx, 1, $blog->getID());
1563 * AdminActions::parse_category()
1564 * Parse skinvar category
1566 * @param string $type name of setting for category
1569 public function parse_category($type = 'name')
1571 echo $this->parse_getcategory($type);
1576 * AdminActions::parse_categorysetting()
1577 * Parse skinvar categorysetting
1579 * @param string $type type in category setting
1582 public function parse_categorysetting($type)
1584 $catid = intRequestVar('catid');
1585 if ( $type == 'id' )
1590 $blogid = intRequestVar('blogid');
1591 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1592 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1593 $row = DB::getRow($query);
1595 if ( $type != 'name' )
1597 echo Entity::hsc($row['cdesc']);
1601 echo Entity::hsc($row['cname']);
1608 * AdminActions::parse_codename()
1609 * Parse templatevar codename
1615 public function parse_checkedonval($value, $name)
1620 $itemid = intRequestVar('itemid');
1621 $item =& $manager->getItem($itemid, 1, 1);
1623 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1625 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1627 $item['body'] = removeBreaks($item['body']);
1628 $item['more'] = removeBreaks($item['more']);
1631 $contents = array();
1632 if ( requestVar('action') == 'itemedit' )
1636 if ( !isset($contents[$name]) )
1638 $contents[$name] = '';
1640 if ($contents[$name] == $value)
1642 echo 'checked="checked"';
1648 * AdminActions::parse_codename()
1649 * Parse templatevar codename
1654 * TODO: is this need???
1656 public function parse_codename()
1659 echo $nucleus['codename'];
1664 * AdminActions::parse_commentnavlist()
1665 * Parse skinvar commentnavlist
1670 public function parse_commentnavlist()
1672 global $CONF, $manager, $member;
1675 if ( postVar('start') )
1677 $start = intPostVar('start');
1684 // amount of items to show
1685 if ( postVar('amount') )
1687 $amount = intPostVar('amount');
1691 $amount = (integer) $CONF['DefaultListSize'];
1697 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1699 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
1701 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1703 if ( $this->skintype == 'itemcommentlist' )
1705 $itemid = intRequestVar('itemid');
1706 $query .= " citem={$itemid}";
1707 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1709 $nonComments = _NOCOMMENTS;
1711 elseif ( $this->skintype == 'browseowncomments' )
1714 $query .= ' cmember=' . $member->getID();
1715 $template['canAddBan'] = 0;
1717 $nonComments = _NOCOMMENTS_YOUR;
1719 elseif ( $this->skintype == 'blogcommentlist' )
1722 $query .= ' cblog=' . intRequestVar('blogid');
1723 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1724 $bid = intRequestVar('blogid');
1725 $nonComments = _NOCOMMENTS_BLOG;
1728 $search = postVar('search');
1729 if ( !empty($search) )
1731 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
1734 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1736 $resource = DB::getResult($query);
1737 if ( $resource->rowCount() > 0 )
1739 $template['action'] = $this->skintype;
1740 $template['start'] = $start;
1741 $template['amount'] = $amount;
1742 $template['minamount'] = 0;
1743 $template['maxamount'] = 1000;
1744 $template['blogid'] = $bid;
1745 $template['search'] = $search;
1746 $template['itemid'] = $itemid;
1748 $template['content'] = 'commentlist';
1750 $this->parser->parse(listplug_navlist('comment', $query, 'table', $template));
1754 /* TODO: nothing to be shown */
1756 $resource->closeCursor();
1762 * AdminActions::parse_configsettingsedit()
1763 * Parse skinvar configsettingsedit
1765 * @param string $type type of global configuration
1768 public function parse_configsettingsedit($type)
1773 case 'DefaultListSize':
1774 if ( !array_key_exists('DefaultListSize', $CONF) )
1776 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1777 $query = sprintf($query, sql_table('config'));
1778 DB::execute($query);
1779 $CONF['DefaultListSize'] = 10;
1781 elseif ( intval($CONF['DefaultListSize']) < 1 )
1783 $CONF['DefaultListSize'] = 10;
1785 echo intval($CONF['DefaultListSize']);
1787 case 'SessionCookie':
1788 $value = $CONF['SessionCookie'];
1789 $txt1 = _SETTINGS_COOKIESESSION;
1790 $txt2 = _SETTINGS_COOKIEMONTH;
1791 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1794 $value = $CONF['URLMode'];
1795 $txt1 = _SETTINGS_URLMODE_NORMAL;
1796 $txt2 = _SETTINGS_URLMODE_PATHINFO;
1797 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1800 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1802 echo Entity::hsc($CONF[$type]);
1810 * AdminActions::parse_configsettingsyesno()
1811 * Parse skinvar configsettingsyesno
1813 * @param string $type type of global setting
1814 * @param integer $tabindex tabindex attribute of input element
1817 public function parse_configsettingsyesno($type, $tabindex)
1820 if ( array_key_exists($type, $CONF) )
1822 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1828 * AdminActions::parse_contents()
1829 * Parse skinvar contents
1831 * @param string $which part for item
1834 public function parse_contents($which)
1836 if ( !array_key_exists($which, Admin::$contents) )
1838 Admin::$contents[$which] = '';
1840 echo Entity::hsc(Admin::$contents[$which]);
1844 * AdminActions::parse_currenttime()
1845 * Parse skinvar currenttime
1847 * @param string $what
1850 public function parse_currenttime($what)
1852 $nu = getdate(Admin::$blog->getCorrectTime());
1857 * AdminActions::parse_customhelplink()
1858 * Parse skinvar customhelplink
1860 * @param string $topic name of topic
1861 * @param string $tplName name of template
1862 * @param string $url string as URI
1863 * @param string $iconURL string as URI for icon
1864 * @param string $alt alternative text for image element
1865 * @param string $title title for anchor element
1868 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1870 $this->customHelp($topic, $url, $iconURL);
1875 * AdminActions::parse_date()
1876 * Parse skinvar date
1878 public function parse_date($format = 'c')
1880 global $CONF, $manager;
1881 /* TODO: offset is based on i18n::get_current_locale()? */
1882 echo i18n::formatted_datetime($format, time());
1887 * AdminActions::parse_normalskinlist()
1888 * Parse skinvar defaultadminskintypes
1890 * @param string $template_name name of template
1893 public function parse_normalskinlist($template_name = '')
1895 global $CONF, $manager;
1897 if ( !preg_match('#^admin#', $this->skintype) )
1899 $skin = new Skin($CONF['BaseSkin']);
1900 /* TODO: removeaction? */
1901 $template['editaction'] = 'skinedittype';
1905 $skin = new Skin($CONF['AdminSkin'], 'AdminActions');
1906 $template['editaction'] = 'adminskinedittype';
1907 /* TODO: removeaction? */
1910 $temporary = $skin->getDefaultTypes();
1911 $normal_skintype = array();
1912 foreach ( $temporary as $type => $label )
1914 $normal_skintype[] = array(
1915 'skintype' => $type,
1916 'skintypename' => $label
1920 $template['tabindex'] = 10;
1921 $template['skinid'] = $skin->getID();
1922 $template['skinname'] = $skin->getName();
1923 $this->parser->parse(showlist($normal_skintype, 'list_normalskinlist', $template, $template_name));
1929 * AdminActions::parse_defblogselect()
1930 * Parse skinvar defblogselect
1932 * @param string $template_name name of template
1935 public function parse_defblogselect($template_name = '')
1939 $query = "SELECT bname as text, bnumber as value FROM %s;";
1940 $query = sprintf($query, sql_table('blog'));
1942 $template['name'] = 'DefaultBlog';
1943 $template['selected'] = $CONF['DefaultBlog'];
1944 $template['tabindex'] = 10;
1945 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1951 * AdminActions::parse_defcatselect()
1952 * Parse skinvar defcatselect
1954 * @param string $template_name name of template
1957 public function parse_defcatselect($template_name = '')
1961 $blogid = intRequestVar('blogid');
1962 $blog =& $manager->getBlog($blogid);
1964 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
1965 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
1967 $template['name'] = 'defcat';
1968 $template['selected'] = $blog->getDefaultCategory();
1969 $template['tabindex'] = 110;
1971 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1977 * AdminActions::parse_defskinselect()
1978 * Parse skinvar defskinselect
1980 * @param string $type type of skin
1981 * @param string $template_name name of template
1984 public function parse_defskinselect($type = 'blog', $template_name = '')
1986 global $CONF, $manager, $member;
1988 if ( !preg_match('#^admin#', $this->skintype) )
1990 $blogid = intRequestVar('blogid');
1993 $template['selected'] = $CONF['BaseSkin'];
1997 $blog =& $manager->getBlog($blogid);
1998 $template['selected'] = $blog->getDefaultSkin();
2001 if ( $type != 'blog' )
2003 $template['name'] = 'BaseSkin';
2007 $template['name'] = 'defskin';
2010 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2014 /* TODO: member object will have its own adminskin id */
2015 $template['selected'] = $CONF['AdminSkin'];
2016 $template['name'] = 'AdminSkin';
2017 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
2020 $query = sprintf($query, sql_table('skin_desc'));
2021 $template['tabindex'] = 50;
2023 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2029 * AdminActions::parse_deletecomment()
2030 * Parse skinvar deletecomment
2032 * @param string $type type of infomation for comment
2035 public function parse_deletecomment($type = 'id')
2037 $commentid = intRequestVar('commentid');
2038 $comment = COMMENT::getComment($commentid);
2043 echo intRequestVar('commentid');
2046 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2048 echo $comment['member'];
2052 echo $comment['user'];
2056 $body = strip_tags($comment['body']);
2057 echo Entity::hsc(shorten($body, 300, '...'));
2063 * AdminActions::parse_deleteitembody()
2064 * Parse skinvar deleteitembody
2069 public function parse_deleteitembody()
2073 $itemid = intRequestVar('itemid');
2074 $item =& $manager->getItem($itemid, 1, 1);
2076 $body = strip_tags($item['body']);
2078 echo Entity::hsc(shorten($body, 300, '...'));
2084 * AdminActions::parse_deleteitemid()
2085 * Parse skinvar deleteitemid
2090 public function parse_deleteitemid()
2092 echo (integer) intRequestVar('itemid');
2097 * AdminActions::parse_deleteitemtitle()
2098 * Parse skinvar deleteitemtitle
2103 public function parse_deleteitemtitle()
2107 $itemid = intRequestVar('itemid');
2108 $item =& $manager->getItem($itemid, 1, 1);
2110 echo Entity::hsc(strip_tags($item['title']));
2116 * AdminActions::parse_editcomment()
2117 * Parse skinvar editcomment
2119 * @param string $type type of comment setting
2122 public function parse_editcomment($type = 'id')
2126 $commentid = intRequestVar('commentid');
2127 $comment = COMMENT::getComment($commentid);
2129 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2134 echo intRequestVar('commentid');
2137 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2139 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2143 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2147 echo date("Y-m-d @ H:i", $comment['timestamp']);
2150 $comment['body'] = str_replace('<br />', '', $comment['body']);
2151 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2152 echo $comment['body'];
2155 echo $comment['userid'];
2158 echo $comment['userid'];
2161 echo $comment[$type];
2168 * AdminActions::parse_editdesturl()
2169 * Parse skinvar editdesturl
2171 public function parse_editdesturl()
2173 if ( requestVar('desturl') )
2175 echo Entity::hsc(requestVar('desturl'));
2181 * AdminActions::parse_editmemberlist()
2182 * Parse skinvar editmemberlist
2184 * @param string $template_name name of template
2187 public function parse_editmemberlist($template_name = '')
2190 // show list of members with actions
2191 $query = 'SELECT * FROM %s;';
2192 $query = sprintf($query, sql_table('member'));
2194 $resource = DB::getResult($query);
2195 if ( $resource->rowCount() > 0 )
2197 $template['content'] = 'memberlist';
2198 $template['tabindex'] = 10;
2200 $this->parser->parse(listplug_batchlist('member', $resource, 'table', $template));
2206 $resource->closeCursor();
2212 * AdminActions::parse_editmember()
2213 * Parse skinvar editmember
2215 * @param string $type type of information for member
2216 * @return string $tempateName name of template to use
2219 public function parse_editmember($type = 'id', $template_name = '')
2221 global $CONF, $manager, $member;
2223 $memberid = intRequestVar('memberid');
2224 $mem =& $manager->getMember($memberid);
2229 echo intRequestVar('memberid');
2232 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2234 echo Entity::hsc($mem->getDisplayName());
2238 $dispName = Entity::hsc($mem->getDisplayName());
2239 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2241 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2250 echo Entity::hsc($mem->getRealName());
2253 echo Entity::hsc($mem->getEmail());
2256 echo Entity::hsc($mem->getURL());
2259 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $template_name);
2262 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $template_name);
2265 echo Entity::hsc($mem->getNotes());
2268 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $template_name);
2277 * AdminActions::parse_editpluginfo()
2278 * Parse skinvar editpluginfo
2280 * @param string $type type of plugin info
2283 public function parse_editpluginfo($type)
2287 $pid = intRequestVar('plugid');
2294 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2301 * AdminActions::parse_editplugoptionslist()
2302 * Parse skinvar editplugoptionslist
2304 * @param string $template_name name of template
2307 public function parse_editplugoptionslist($template_name = '')
2311 $pid = intRequestVar('plugid');
2312 $aOptions = array();
2315 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2316 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2317 $resource = DB::getResult($query);
2319 foreach ( $resource as $row )
2321 $aOIDs[] = $row['oid'];
2322 $aOptions[$row['oid']] = array(
2323 'oid' => $row['oid'],
2324 'value' => $row['odef'],
2325 'name' => $row['oname'],
2326 'description' => $row['odesc'],
2327 'type' => $row['otype'],
2328 'typeinfo' => $row['oextra'],
2333 // fill out actual values
2334 if ( count($aOIDs) > 0 )
2336 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2337 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2339 $result = DB::getResult($query);
2340 foreach ( $result as $row )
2342 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2348 'context' => 'global',
2350 'options' => &$aOptions
2352 $manager->notify('PrePluginOptionsEdit', $data);
2354 if ( sizeof($aOptions) > 0 )
2356 $template['content'] = 'plugoptionlist';
2357 $this->parser->parse(showlist($aOptions, 'table', $template, $template_name));
2361 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2367 * AdminActions::parse_editskin()
2368 * Parse skinvar editskin
2370 * @param string $type type of skin
2373 public function parse_editskin($type = 'id')
2375 $skinid = intRequestVar('skinid');
2377 if ( !preg_match('#^admin#', $this->skintype) )
2379 $skin = new SKIN($skinid);
2383 $skin = new SKIN($skinid, 'AdminActions');
2389 echo intRequestVar('skinid');
2392 echo Entity::hsc($skin->getName());
2395 echo Entity::hsc($skin->getDescription());
2398 echo Entity::hsc($skin->getContentType());
2401 echo Entity::hsc($skin->getIncludePrefix());
2404 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2412 * AdminActions::parse_editskintype()
2413 * Parse skinvar editskintype
2415 * @param string $type name of type for skin type
2418 public function parse_editskintype($stype = 'id')
2420 static $skin = NULL;
2421 static $types = array();
2423 if ( $skin == NULL )
2425 $skinid = intRequestVar('skinid');
2427 if ( !preg_match('#^admin#', $this->skintype) )
2429 $skin = new Skin($skinid);
2433 $skin = new Skin($skinid, 'AdminActions');
2436 $types = $skin->getDefaultTypes();
2439 $type = strtolower(trim(requestVar('type')));
2444 echo $skin->getID();
2447 echo Entity::hsc($skin->getName());
2450 echo Entity::hsc($skin->getDescription());
2453 echo Entity::hsc($skin->getContentType());
2456 echo Entity::hsc($skin->getContentFromDB($type));
2459 if ( !array_key_exists($type, $types) )
2461 $skinType = ucfirst($type);
2465 $skinType = $types[$type];
2467 echo Entity::hsc($skinType);
2470 echo Entity::hsc($type);
2473 echo Entity::hsc($skin->getIncludePrefix());
2476 if ( !$skin->getIncludeMode() != 'skindir' )
2478 $incMode = _PARSER_INCMODE_NORMAL;
2482 $incMode = _PARSER_INCMODE_SKINDIR;
2484 echo Entity::hsc($incMode);
2493 * AdminActions::parse_adminurl()
2494 * Parse skinvar adminurl
2495 * (shortcut for admin url)
2500 public function parse_adminurl()
2502 $this->parse_sitevar('adminurl');
2507 * AdminActions::parse_edittemplateinfo()
2508 * Parse skinvar edittemplateinfo
2510 * @param string $format format to output
2511 * @param string $typedesc type of template
2512 * @param string $typename type name of template
2513 * @param string $help help text
2514 * @param string $tabindex index value for tabindex attribute of input element
2515 * @param string $big textarea size
2516 * @param string $tplt name of template to be filled
2519 public function parse_edittemplateinfo($format, $typedesc = '', $typename = '', $help = '', $tabindex = 0, $big = 0, $template_name = '')
2523 static $name = NULL;
2524 static $desc = NULL;
2528 $id = intRequestVar('templateid');
2531 if ( $name == NULL )
2533 $name = Template::getNameFromId($id);
2536 if ( $desc == NULL )
2538 $desc = Template::getDesc($id);
2541 $template =& $manager->getTemplate($name);
2549 echo Entity::hsc($name);
2552 echo Entity::hsc($desc);
2554 case 'extratemplate':
2556 $pluginfields = array();
2557 if ( !preg_match('#^admin/#', $this->skintype) )
2559 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2563 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
2566 foreach ( $pluginfields as $ptkey => $ptvalue )
2571 $tmplt =& $manager->getTemplate($desc);
2574 /* extra plugin field */
2575 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2579 . "<th colspan=\"2\"><%explugtplname%></th>\n";
2583 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2586 'explugtplname' => Entity::hsc($ptkey)
2588 echo Template::fill($base, $data);
2590 foreach ( $ptvalue as $ptname => $ptdesc )
2592 if ( !array_key_exists($ptname, $template) )
2598 $content = $template[$ptname];
2600 $this->parser->parse(listplug_templateEditRow($content, $ptdesc, $ptname, $help, $tabidx++, $big, $template_name));
2606 $typedesc = defined($typedesc) ? constant($typedesc) : $typedesc;
2607 $typename = defined($typename) ? constant($typename) : $typename;
2609 if ( !array_key_exists($typename, $template) )
2615 $content = $template[$typename];
2617 $this->parser->parse(listplug_templateEditRow($content, $typedesc, $typename, $help, $tabindex, $big, $template_name));
2625 * AdminActions::parse_eventformextra()
2626 * Parse skinvar eventformextra
2628 * @param string $type name of type for event form extra
2631 public function parse_eventformextra($type = 'activation')
2640 $key = requestVar('ackey');
2643 Admin::error(_ERROR_ACTIVATE);
2645 $info = MEMBER::getActivationInfo($key);
2648 Admin::error(_ERROR_ACTIVATE);
2650 $mem =& $manager->getMember($info->vmember);
2653 Admin::error(_ERROR_ACTIVATE);
2656 'type' => 'activation',
2660 case 'membermailform-notloggedin':
2661 $data = array('type' => 'membermailform-notloggedin',);
2664 $manager->notify('FormExtra', $data);
2669 * AdminActions::parse_extrahead()
2670 * Parse skinvar extrahead
2672 public function parse_extrahead()
2676 $extrahead = Admin::getAdminextrahead();
2679 'extrahead' => &$extrahead,
2680 'action' => Admin::getAdminAction()
2683 $manager->notify('AdminPrePageHead', $data);
2689 * AdminActions::parse_member()
2690 * Parse skinvar member
2691 * (includes a member info thingie)
2693 * @param string $what which memberdata is needed
2696 public function parse_member($what)
2698 global $memberinfo, $member, $CONF;
2700 // 1. only allow the member-details-page specific variables on member pages
2701 if ( $this->skintype == 'member' )
2706 echo Entity::hsc($memberinfo->getDisplayName());
2709 echo Entity::hsc($memberinfo->getRealName());
2712 echo Entity::hsc($memberinfo->getNotes());
2715 echo Entity::hsc($memberinfo->getURL());
2718 echo Entity::hsc($memberinfo->getEmail());
2721 echo Entity::hsc($memberinfo->getID());
2726 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2727 if ( $member->isLoggedIn() )
2732 echo $member->getDisplayName();
2734 case 'yourrealname':
2735 echo $member->getRealName();
2738 echo $member->getNotes();
2741 echo $member->getURL();
2744 echo $member->getEmail();
2747 echo $member->getID();
2749 case 'yourprofileurl':
2750 if ( $CONF['URLMode'] == 'pathinfo' )
2752 echo Link::create_member_link($member->getID());
2756 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
2765 * AdminActions::parse_version()
2766 * Parse skinvar version
2767 * (include nucleus versionnumber)
2772 public function parse_version()
2775 echo 'Nucleus CMS ' . $nucleus['version'];
2780 * AdminActions::parse_sitevar()
2781 * Parse skinvar sitevar
2782 * (include a sitevar)
2784 * @param string $which
2787 public function parse_sitevar($which)
2793 echo $CONF['IndexURL'];
2796 echo $CONF['SiteName'];
2799 echo $CONF['AdminEmail'];
2802 echo $CONF['AdminURL'];
2809 * AdminActions::parse_actionurl()
2815 public function parse_actionurl()
2818 echo Entity::hsc($CONF['ActionURL']);
2823 * AdminActions::parse_getblogsetting()
2824 * Parse skinvar getblogsetting
2826 public function parse_getblogsetting($which)
2828 global $blog, $manager;
2834 elseif ( $bid = intRequestVar('blogid') )
2836 $b =& $manager->getBlog($bid);
2846 return Entity::hsc($b->getID());
2849 return Entity::hsc($b->getURL());
2852 return Entity::hsc($b->getName());
2855 return Entity::hsc($b->getDescription());
2858 return Entity::hsc($b->getShortName());
2860 case 'notifyaddress':
2861 return Entity::hsc($b->getNotifyAddress());
2864 return Entity::hsc($b->getMaxComments());
2867 return Entity::hsc($b->getUpdateFile());
2870 return Entity::hsc($b->getTimeOffset());
2877 * AdminActions::parse_geteditpluginfo()
2878 * Parse skinvar geteditpluginfo
2880 * @param string $type name of setting for edit plugin info
2883 public function parse_geteditpluginfo($type)
2886 $pid = intRequestVar('plugid');
2893 return Entity::hsc($manager->getPluginNameFromPid($pid));
2900 * AdminActions::parse_getmember()
2901 * Parse skinvar getmember
2902 * (includes a member info thingie)
2904 * @param string $what name of setting for member
2907 public function parse_getmember($what)
2909 global $memberinfo, $member;
2910 // 1. only allow the member-details-page specific variables on member pages
2911 if ( $this->skintype == 'member' )
2916 return Entity::hsc($memberinfo->getDisplayName());
2919 return Entity::hsc($memberinfo->getRealName());
2922 return Entity::hsc($memberinfo->getNotes());
2925 return Entity::hsc($memberinfo->getURL());
2928 return Entity::hsc($memberinfo->getEmail());
2931 return Entity::hsc($memberinfo->getID());
2935 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2936 if ( $member->isLoggedIn() )
2941 return $member->getDisplayName();
2943 case 'yourrealname':
2944 return $member->getRealName();
2947 return $member->getNotes();
2950 return $member->getURL();
2953 return $member->getEmail();
2956 return $member->getID();
2964 * AdminActions::parse_headmessage()
2965 * Parse skinvar headmessage
2970 public function parse_headmessage()
2972 if ( !empty(Admin::$headMess) )
2974 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
2980 * AdminActions::parse_helplink()
2981 * Parse skinvar helplink
2983 * @param string $topic name of topic for help
2986 public function parse_helplink($topic = '')
2988 if ( !empty($topic) )
2996 * AdminActions::parse_helpplugname()
2997 * Parse skinvar helpplugname
3002 public function parse_helpplugname()
3004 $plugid = intGetVar('plugid');
3005 Entity::hsc($manager->getPluginNameFromPid($plugid));
3010 * AdminActions::parse_ilistaddnew()
3011 * Parse skinvar ilistaddnew
3016 public function parse_ilistaddnew()
3018 $blogid = intRequestVar('blogid');
3019 if ( intPostVar('start') == 0 )
3021 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3027 * AdminActions::parse_importskininfo()
3028 * Parse skinvar importskininfo
3030 * @param string $type name of information for imported skin
3033 public function parse_importskininfo($type)
3038 echo Entity::hsc(requestVar('skininfo'));
3041 $dataArr = requestArray('skinnames');
3042 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3045 $dataArr = requestArray('tpltnames');
3046 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3049 $dataArr = requestArray('skinclashes');
3050 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3053 $dataArr = requestArray('tpltclashes');
3054 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3057 echo Entity::hsc(requestVar('skinfile'));
3060 echo Entity::hsc(requestVar('mode'));
3067 * AdminActions::parse_init()
3068 * some init stuff for all forms
3073 public function parse_init()
3078 if ( requestVar('action') == 'itemedit' )
3080 $authorid = Admin::$contents['authorid'];
3083 Admin::$blog->insertJavaScriptInfo($authorid);
3088 * AdminActions::parse_inputyesno()
3089 * Parse skinvar inputyesno
3091 * @param string $name
3092 * @param string $checkedval
3093 * @param string $tabindex
3094 * @param string $value1
3095 * @param string $value2
3096 * @param string $yesval
3097 * @param string $noval
3098 * @param string $isAdmin
3099 * @param string $template_name
3102 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $template_name = '')
3104 $this->parser->parse(listplug_input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $template_name));
3109 * AdminActions::parse_insertpluginfo()
3110 * Parse templatevar insertpluginfo
3112 public function parse_insertpluginfo($type)
3114 $option = Admin::getAdminaOption();
3118 return $option['pid'];
3121 return Entity::hsc($option['pfile']);
3128 * AdminActions::parse_insplugoptcontent()
3129 * Parse skinvar insplugoptcontent
3134 public function parse_insplugoptcontent()
3136 $option = Admin::getAdminaOption();
3138 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3139 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3142 listplug_plugOptionRow($option);
3149 * AdminActions::parse_iprangeinput()
3150 * Parse skinvar iprangeinput
3155 public function parse_iprangeinput()
3157 if ( requestVar('ip') )
3159 $iprangeVal = Entity::hsc(requestVar('ip'));
3160 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3161 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3162 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3163 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3164 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3168 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3169 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3175 * AdminActions::parse_itemnavlist()
3176 * Parse skinvar itemnavlist
3181 public function parse_itemnavlist($template_name)
3183 global $CONF, $manager, $member;
3185 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3186 . " FROM %s, %s, %s, %s"
3187 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3189 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3191 if ( $this->skintype == 'itemlist' )
3194 if ( array_key_exists('blogid', $_REQUEST) )
3196 $blogid = intRequestVar('blogid');
3198 else if ( array_key_exists('itemid', $_REQUEST) )
3200 $itemid = intRequestVar('itemid');
3201 $item = &$manager->getItem($itemid, 1, 1);
3202 $blogid = (integer) $item['blogid'];
3204 $blog =& $manager->getBlog($blogid);
3206 $query .= " AND iblog={$blogid}";
3207 $template['now'] = $blog->getCorrectTime(time());
3209 // non-blog-admins can only edit/delete their own items
3210 if ( !$member->blogAdminRights($blogid) )
3212 $query .= ' AND iauthor = ' . $member->getID();
3215 elseif ( $this->skintype == 'browseownitems' )
3217 $query .= ' AND iauthor = ' . $member->getID();
3219 $template['now'] = time();
3222 // search through items
3223 $search = postVar('search');
3225 if ( !empty($search) )
3227 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3228 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3229 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3232 if ( postVar('start') )
3234 $start = intPostVar('start');
3241 // amount of items to show
3242 if ( postVar('amount') )
3244 $amount = intPostVar('amount');
3248 $amount = (integer) $CONF['DefaultListSize'];
3255 $query .= ' ORDER BY itime DESC'
3256 . " LIMIT {$start},{$amount}";
3258 $resource = DB::getResult($query);
3259 if ( $resource->rowCount() > 0 )
3261 $template['action'] = $this->skintype;
3262 $template['start'] = $start;
3263 $template['amount'] = $amount;
3264 $template['minamount'] = 0;
3265 $template['maxamount'] = 1000;
3266 $template['blogid'] = $blogid;
3267 $template['search'] = $search;
3268 $template['itemid'] = 0;
3270 $template['content'] = 'itemlist';
3272 $this->parser->parse(listplug_navlist('item', $query, 'table', $template));
3276 /* TODO: nothing to be shown */
3278 $resource->closeCursor();
3284 * AdminActions::parse_itemtime()
3285 * date change on edit item
3287 * @param string $key key of PHP's getDate()
3290 public function parse_itemtime($key)
3295 $itemid = intRequestVar('itemid');
3296 $item =& $manager->getItem($itemid, 1, 1);
3298 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3300 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3302 $item['body'] = removeBreaks($item['body']);
3303 $item['more'] = removeBreaks($item['more']);
3306 $contents = array();
3307 if ( requestVar('action') == 'itemedit' )
3311 elseif ( requestVar('action') == 'createitem' )
3314 'contents' => &$contents,
3315 'blog' => &$this->blog
3317 $manager->notify('PreAddItemForm', $data);
3319 $itemtime = getdate($contents['timestamp']);
3320 echo $itemtime[$key];
3325 * AdminActions::parse_jstoolbaroptions()
3326 * Parse skinvar jstoolbaroptions
3331 public function parse_jstoolbaroptions()
3335 _SETTINGS_JSTOOLBAR_NONE,
3336 _SETTINGS_JSTOOLBAR_SIMPLE,
3337 _SETTINGS_JSTOOLBAR_FULL
3341 foreach ( $options as $option )
3343 $text = "<option value=\"%d\"%s>%s</option>\n";
3344 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3345 echo sprintf($text, $i, $extra, $option);
3351 * AdminActions::parse_localeselectoptions()
3352 * Parse skinvar localeselectoptions
3357 public function parse_localeselectoptions()
3361 $locales = i18n::get_available_locale_list();
3363 $memid = intRequestVar('memberid');
3366 $mem =& $manager->getMember($memid);
3367 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3369 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3373 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3378 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3380 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3384 echo "<option value=\"\">en_Latn_US</option>\n";
3387 foreach ( $locales as $locale )
3389 if ( $locale == 'en_Latn_US' )
3395 if ( $locale == $mem->getLocale() )
3397 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3401 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3406 if ( $locale == i18n::get_current_locale() )
3408 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3412 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3420 * AdminActions::parse_listplugplugoptionrow()
3421 * Parse templatevar listplugplugoptionrow
3423 * @param string $template_name name of template
3426 public function parse_listplugplugoptionrow($template_name = '')
3428 echo listplug_plugOptionRow(Admin::getAdminaOption(), $template_name);
3433 * AdminActions::parse_mediadirwarning()
3434 * Parse skinvar mediadirwarning
3439 public function parse_mediadirwarning()
3442 if ( !is_dir($DIR_MEDIA) )
3444 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3446 if ( !is_readable($DIR_MEDIA) )
3448 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3450 if ( !is_writeable($DIR_MEDIA) )
3452 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3458 * AdminActions::parse_movedistselect()
3459 * Parse skinvar movedistselect
3461 public function parse_movedistselect()
3463 $actionType = requestVar('action');
3464 switch ( $actionType )
3467 $this->selectBlog('destcatid', 'category');
3469 case 'batchcategory':
3470 $this->selectBlog('destblogid');
3473 if ( $this->skintype == 'itemmove' )
3475 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3476 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3477 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3478 $this->selectBlog('catid', 'category', $catid, 10, 1);
3486 * AdminActions::parse_moveitemid()
3487 * Parse skinvar moveitemid
3492 public function parse_moveitemid()
3494 echo intRequestVar('itemid');
3499 * AdminActions::parse_newestcompare()
3500 * Parse skinvar newestcompare
3505 public function parse_newestcompare()
3509 $newestVersion = getLatestVersion();
3510 $newestCompare = str_replace('/', '.', $newestVersion);
3511 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3513 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3515 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3516 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3522 * AdminActions::parse_newmemberselect()
3523 * Parse skinvar newmemberselect
3525 * @param string $template_name name of template to use
3528 public function parse_newmemberselect($template_name = '')
3530 $blogid = intRequestVar('blogid');
3532 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3533 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3534 $res = DB::getResult($query);
3537 foreach ( $res as $row )
3539 $tmem[] = intval($row['tmember']);
3542 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3543 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3546 'name' => 'memberid',
3547 'tabindex' => 10000,
3550 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3555 * AdminActions::parse_newpluginlist()
3556 * Parse skinvar newpluginlist
3561 public function parse_newpluginlist()
3563 $candidates = $this->newPlugCandidates;
3564 foreach ( $candidates as $name )
3566 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3572 * AdminActions::parse_outputspecialdirs()
3573 * Parse skinvar outputspecialdirs
3575 * @param string $type type of setting for directory
3578 public function parse_outputspecialdirs($type)
3580 global $DIR_MEDIA, $DIR_NUCLEUS;
3585 echo Entity::hsc($DIR_NUCLEUS);
3588 echo Entity::hsc($DIR_MEDIA);
3595 * AdminActions::parse_passrequestvars()
3596 * Parse skinvar passrequestvars
3601 public function parse_passrequestvars()
3603 $passvar = Admin::getAdminpassvar();
3604 $oldaction = postVar('oldaction');
3606 if ( ($oldaction != 'logout')
3607 && ($oldaction != 'login')
3609 && !postVar('customaction') )
3617 * AdminActions::parse_pluginextras()
3618 * Parse skinvar pluginextras
3620 * @param string $type type of plugin context
3623 public function parse_pluginextras($type = 'global')
3630 $id = intRequestVar('memberid');
3631 $mem =& $manager->getMember($id);
3632 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
3635 $id = intRequestVar('blogid');
3636 $blg =& $manager->getBlog($id);
3637 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
3639 case 'createaccount':
3641 'type' => 'createaccount.php',
3643 'postlabel' => '<br />',
3645 'postfield' => '<br /><br />'
3647 $manager->notify('RegistrationFormExtraFields', $data);
3650 $manager->notify('GeneralSettingsFormExtras', array());
3657 * AdminActions::parse_pluginhelp()
3658 * Parse skinvar pluginhelp
3663 public function parse_pluginhelp()
3665 global $manager, $DIR_PLUGINS;
3667 $plugid = intGetVar('plugid');
3668 $plugName = $manager->getPluginNameFromPid($plugid);
3669 $plug =& $manager->getPlugin($plugName);
3671 if ( $plug->supportsFeature('HelpPage') > 0 )
3673 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3674 if ( @file_exists($helpfile . 'php') )
3676 @include($helpfile . 'php');
3679 elseif ( @file_exists($helpfile . 'html') )
3681 @include($helpfile . 'html');
3685 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3686 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3691 * AdminActions::parse_pluginlistlist()
3692 * Parse skinvar pluginlistlist
3694 * @param string $template_name name of template to use
3697 public function parse_pluginlistlist($template_name = '')
3699 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3700 $query = sprintf($query, sql_table('plugin'));
3702 $template['content'] = 'pluginlist';
3703 $template['tabindex'] = 10;
3705 $this->parser->parse(showlist($query, 'table', $template, $template_name));
3711 * AdminActions::parse_pluginoptions()
3712 * Parse skinvar pluginoptions
3714 * @param string $type type of plugin option
3717 public function parse_pluginoptions($context='global', $template_name='')
3719 global $itemid, $manager;
3724 $contextid = intRequestVar('memberid');
3727 $contextid = intRequestVar('blogid');
3730 $contextid = intRequestVar('catid');
3733 $contextid = $itemid;
3737 /* Actually registererd plugin options */
3738 $aIdToValue = array();
3739 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
3740 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
3741 $res = DB::getResult($query);
3742 foreach ( $res as $row )
3744 $aIdToValue[$row['oid']] = $row['ovalue'];
3747 /* Currently available plugin options */
3748 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
3749 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
3750 $res = DB::getResult($query);
3753 foreach ($res as $row )
3755 if ( !array_key_exists($row['oid'], $aIdToValue) )
3757 $value = $row['odef'];
3761 $value = $aIdToValue[$row['oid']];
3765 'pid' => $row['pid'],
3766 'pfile' => $row['pfile'],
3767 'oid' => $row['oid'],
3769 'name' => $row['oname'],
3770 'description' => $row['odesc'],
3771 'type' => $row['otype'],
3772 'typeinfo' => $row['oextra'],
3773 'contextid' => $contextid,
3779 'context' => $context,
3780 'contextid' => $contextid,
3781 'options' => &$options
3783 $manager->notify('PrePluginOptionsEdit', $data);
3785 $template = array();
3786 if ( $template_name )
3788 $templates =& $manager->getTemplate($template_name);
3789 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3791 $template['title'] = "<tr>"
3792 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3797 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3800 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3802 $template['body'] = "<tr>"
3803 . "<%listplugplugoptionrow%>"
3808 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3814 foreach ( $options as $option )
3817 if ( $prevPid != $option['pid'] )
3819 $prevPid = $option['pid'];
3820 $this->parser->parse($template['title']);
3823 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3825 if ( @$meta['access'] != 'hidden' )
3827 $parsed = $this->parser->parse($template['body']);
3835 * AdminActions::parse_qmenuaddselect()
3836 * Parse skinvar qmanuaddselect
3838 * @param string $template_name name of template to use
3841 public function parse_qmenuaddselect($template_name = '')
3843 global $member, $blogid;
3844 $showAll = requestVar('showall');
3845 if ( $member->isAdmin() && ($showAll == 'yes') )
3847 // Super-Admins have access to all blogs! (no add item support though)
3848 $query = 'SELECT bnumber as value, bname as text FROM %s ORDER BY bname;';
3849 $query = sprintf($query, sql_table('blog'));
3853 $query = 'SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;';
3854 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3857 $template['name'] = 'blogid';
3858 $template['tabindex'] = 15000;
3859 $template['extra'] = _QMENU_ADD_SELECT;
3860 $template['selected'] = 0;
3861 $template['shorten'] = 10;
3862 $template['shortenel'] = '';
3863 $template['javascript'] = 'onchange="return form.submit()"';
3865 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3871 * AdminActions::parse_quickmenu()
3872 * Parse skinvar quickmenu
3874 * @param string $template_name name of template to use
3877 public function parse_quickmenu($template_name = '')
3880 $templates = array();
3882 if ( !empty($template_name) )
3884 $templates = & $manager->getTemplate($template_name);
3886 $pluginExtras = array();
3887 $manager->notify('QuickMenu', array('options' => &$pluginExtras));
3889 $template = array();
3890 if ( count($pluginExtras) > 0 )
3892 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3894 $template['head'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n"
3899 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3902 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
3904 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
3908 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3911 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3913 $template['foot'] = "</ul>\n";
3917 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3920 $this->parser->parse($template['head']);
3921 foreach ( $pluginExtras as $aInfo )
3924 'plugadminurl' => Entity::hsc($aInfo['url']),
3925 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
3926 'plugadmintitle' => Entity::hsc($aInfo['title']),
3928 $this->parser->parse(Template::fill($template['body'], $data));
3930 $this->parser->parse($template['foot']);
3936 * AdminActions::parse_requestblogid()
3937 * Parse skinvar requestblogid
3942 public function parse_requestblogid()
3944 echo intRequestVar('blogid');
3949 * AdminActions::parse_requestiprange()
3950 * Parse skinvar requestiprange
3955 public function parse_requestiprange()
3957 if ( requestVar('iprange') )
3959 echo Entity::hsc(requestVar('iprange'));
3961 elseif ( requestVar('ip') )
3963 echo Entity::hsc(requestVar('ip'));
3969 * AdminActions::parse_selectlocalskinfiles()
3970 * Parse skinvar selectlocalskinfiles
3975 public function parse_selectlocalskinfiles()
3979 if ( !class_exists('SkinImport', FALSE) )
3981 include_libs('skinie.php');
3984 if ( !preg_match('#^admin#', $this->skintype) )
3986 $skindir = $DIR_SKINS;
3990 $skindir = "{$DIR_SKINS}admin/";
3993 $candidates = SkinImport::searchForCandidates($skindir);
3994 foreach ( $candidates as $skinname => $skinfile )
3996 $skinfile = Entity::hsc($skinfile);
3997 $skinname = Entity::hsc($skinname);
3998 echo "<option value=\"{$skinfile}\">{$skinname}</option>\n";
4005 * AdminActions::parse_skineditallowedlist()
4006 * Parse skinvar skineditallowedlist
4008 * @param string $type type of skin
4009 * @param string $template_name name of template
4012 public function parse_skineditallowedlist($type, $template_name = '')
4017 $query = "SELECT bshortname, bname FROM %s;";
4019 'content' => 'shortblognames'
4021 $query = sprintf($query, sql_table('blog'));
4024 if ( !preg_match('#^admin#', $this->skintype) )
4026 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4030 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%';";
4033 'content' => 'shortnames'
4035 $query = sprintf($query, sql_table('template_desc'));
4039 $this->parser->parse(showlist($query, 'table', $show, $template_name));
4044 * AdminActions::parse_skinielist()
4045 * Parse skinvar skinielist
4047 * @param string $type type of skin
4048 * @param string $template_name name of template to use
4051 public function parse_skinielist($type, $template_name = '')
4055 $templates = array();
4056 if ( $template_name )
4058 $templates =& $manager->getTemplate($template_name);
4060 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
4063 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4064 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4066 . "<td><%expdesc%></td>\n"
4072 $template = $templates['SKINIE_EXPORT_LIST'];
4078 if ( !preg_match('#^admin#', $this->skintype) )
4080 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4084 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname LIKE 'admin/%%';");
4086 foreach ( $res as $row )
4089 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4090 'expid' => 'skinexp' . $row['sdnumber'],
4091 'expname' => Entity::hsc($row['sdname']),
4092 'expdesc' => Entity::hsc($row['sddesc'])
4094 echo Template::fill($template, $data);
4098 if ( !preg_match('#^admin#', $this->skintype) )
4100 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4105 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname LIKE 'admin/%%';");
4107 foreach ( $res as $row )
4110 'typeid' => 'template[' . $row['tdnumber'] . ']',
4111 'expid' => 'templateexp' . $row['tdnumber'],
4112 'expname' => Entity::hsc($row['tdname']),
4113 'expdesc' => Entity::hsc($row['tddesc'])
4115 echo Template::fill($template, $data);
4123 * AdminActions::parse_skinoverview()
4124 * Parse skinvar skinoverview
4126 * @param string $template_name name of template to use
4129 public function parse_skinoverview($template_name = '')
4133 $template = array();
4134 if ( !preg_match('#^admin#', $this->skintype) )
4136 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%' ORDER BY sdname;";
4137 $template['editaction'] = 'skinedit';
4138 $template['cloneaction'] = 'skinclone';
4139 $template['deleteaction'] = 'skindelete';
4140 $template['edittypeaction'] = 'skinedittype';
4141 $template['default'] = $CONF['BaseSkin'];
4145 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
4146 $template['editaction'] = 'adminskinedit';
4147 $template['cloneaction'] = 'adminskinclone';
4148 $template['deleteaction'] = 'adminskindelete';
4149 $template['edittypeaction'] = 'adminskinedittype';
4150 $template['default'] = $CONF['AdminSkin'];
4152 $query = sprintf($query, sql_table('skin_desc'));
4154 $template['tabindex'] = 10;
4155 $template['content'] = 'skinlist';
4157 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4163 * AdminActions::parse_skintypehelp()
4164 * Check editing skintypehelp
4169 public function parse_skintypehelp()
4171 $nowSkinType = strtolower(trim(requestVar('type')));
4172 $pageAction = strtolower(trim(requestVar('action')));
4173 if ( preg_match('/^admin.*/', $pageAction) )
4175 $regularType = self::$default_skin_types;
4176 unset($regularType['memberedit']);
4177 unset($regularType['login']);
4178 $regularType = array_keys($regularType);
4182 /* TODO: use Skin class */
4183 $regularType = array(
4195 if ( in_array($nowSkinType, $regularType) )
4197 help('skinpart' . $nowSkinType);
4201 help('skinpartspecial');
4207 * AdminActions::parse_specialskinlist()
4208 * Parse skinvar specialskinlist
4210 * @param string $template_name name of template to use
4213 public function parse_specialskinlist($template_name = '')
4215 global $CONF, $manager;
4217 $template = array();
4219 $skinid = intRequestVar('skinid');
4221 if ( !preg_match('#^admin#', $this->skintype) )
4223 $skin = new Skin($skinid);
4224 $template['editaction'] = 'skinedittype';
4225 $template['removeaction'] = 'skinremovetype';
4229 $skin = new Skin($skinid, 'AdminActions');
4230 $template['editaction'] = 'adminskinedittype';
4231 $template['removeaction'] = 'adminskinremovetype';
4233 $normal_types = $skin->getDefaultTypes();
4234 $available_types = $skin->getAvailableTypes();
4236 $special_skintypes = array();
4237 foreach( $available_types as $skintype => $skinname )
4239 if ( !array_key_exists($skintype, $normal_types) )
4241 $special_skintypes[] = array(
4242 'skintype' => $skintype,
4243 'skintypename' => $skinname
4248 if ( sizeof($special_skintypes) > 0 )
4250 $template['tabindex'] = 75;
4251 $template['skinid'] = $skin->getID();
4252 $template['skinname'] = $skin->getName();
4253 $this->parser->parse(showlist($special_skintypes, 'list_specialskinlist', $template, $template_name));
4257 /* TODO: nothing to be shown */
4264 * AdminActions::parse_sprinttext()
4267 * @param string $which
4268 * @param string $val
4271 public function parse_sprinttext($which, $val)
4273 if ( !defined($which) )
4279 $base = constant($which);
4282 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4284 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4286 $met = 'parse_' . $matchies[0];
4290 $arg = trim($args[0], '()');
4291 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4294 if ( method_exists($this, $met) )
4296 $value = call_user_func(array(&$this, $met), $arg);
4300 if ( !isset($value) || empty($value) )
4304 echo sprintf($base, $value);
4309 * AdminActions::parse_systemsettings()
4310 * Parse skinvar systemsettings
4312 * @param string $type type of settings for system
4313 * @param string $template_name name of template to use
4316 public function parse_systemsettings($type = 'phpinfo', $template_name = '')
4318 global $manager, $member, $CONF, $nucleus;
4320 $member->isAdmin() or Admin::disallow();
4322 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4323 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4330 case 'sqlserverinfo':
4331 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4333 case 'sqlclientinfo':
4334 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4336 case 'magicquotesgpc':
4337 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4339 case 'magicquotesruntime':
4340 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4342 case 'registerglobals':
4343 echo ini_get('register_globals') ? 'On' : 'Off';
4346 $templates = array();
4347 if ( $template_name )
4349 $templates =& $manager->getTemplate($template_name);
4351 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4353 $template = "<tr>\n"
4354 . "<td><%key%></td>\n"
4355 . "<td><%value%></td>\n"
4360 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4363 $gdinfo = gd_info();
4365 foreach ( $gdinfo as $key => $value )
4367 if ( is_bool($value) )
4369 $value = $value ? $enable : $disable;
4373 $value = Entity::hsc($value);
4379 echo Template::fill($template, $data);
4384 phpinfo(INFO_MODULES);
4385 $im = ob_get_contents();
4387 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4389 case 'nucleusversion':
4390 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4392 case 'nucleuspatchlevel':
4393 echo getNucleusPatchLevel();
4399 echo $CONF['ItemURL'];
4401 case 'alertonheaderssent':
4402 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4404 case 'nucleuscodename':
4405 if ( $nucleus['codename'] != '' )
4407 echo ' "' . $nucleus['codename'] . '"';
4410 case 'versioncheckurl':
4411 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4418 * AdminActions::parse_templateoverview()
4419 * Parse skinvar templateoverview
4421 * @param string $template_name name of template to use
4424 public function parse_templateoverview($template_name = '')
4426 if ( !preg_match('#^admin#', $this->skintype) )
4428 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname;";
4429 $template['deleteaction'] = 'templatedelete';
4430 $template['editaction'] = 'templateedit';
4431 $template['cloneaction'] = 'templateclone';
4435 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
4436 $template['deleteaction'] = 'admintemplatedelete';
4437 $template['editaction'] = 'admintemplateedit';
4438 $template['cloneaction'] = 'admintemplateclone';
4440 $query = sprintf($query, sql_table('template_desc'));
4442 $template['tabindex'] = 10;
4443 $template['content'] = 'templatelist';
4445 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4451 * AdminActions::parse_ticket()
4457 public function parse_ticket()
4460 $manager->addTicketHidden();
4465 * AdminActions::parse_versioncheckurl()
4466 * Parse skinvar versioncheckurl
4471 public function parse_versioncheckurl()
4473 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4478 * AdminActions::parse_yrbloglist()
4479 * Parse skinvar yrbloglist
4481 * @param string $template_name name of template to use
4484 public function parse_yrbloglist($template_name = '')
4487 $showAll = requestVar('showall');
4489 if ( $member->isAdmin() && ($showAll == 'yes') )
4491 // Super-Admins have access to all blogs! (no add item support though)
4492 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4494 . " ORDER BY bnumber;";
4495 $query = sprintf($query, sql_table('blog'));
4499 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4501 . " WHERE tblog=bnumber and tmember=%d"
4502 . " ORDER BY bnumber;";
4503 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4506 $resource = DB::getResult($query);
4507 if ( ($showAll != 'yes') && $member->isAdmin() )
4509 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4510 $total = DB::getValue($query);
4512 if ( $total > $resource->rowCount() )
4514 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4518 if ( $resource->rowCount() > 0 )
4520 $template['content'] = 'bloglist';
4521 $template['superadmin'] = $member->isAdmin();
4523 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4524 $resource->closeCursor();
4526 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4528 $query = 'SELECT ititle, inumber, bshortname FROM %s, %s '
4529 . 'WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4530 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4532 $resource = DB::getResult($query);
4533 if ( $resource->rowCount() > 0 )
4535 $template['content'] = 'draftlist';
4536 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4540 echo _OVERVIEW_NODRAFTS;
4545 echo _OVERVIEW_NOBLOGS;
4547 $resource->closeCursor();
4553 * AdminActions::checkCondition()
4554 * Checks conditions for if statements
4556 * @param string $field type of <%if%>
4557 * @param string $name property of field
4558 * @param string $value value of property
4559 * @return boolean condition
4561 protected function checkCondition($field, $name='', $value = '')
4563 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4573 $blog =& $manager->getBlog($blogid);
4577 $blogid = getBlogIDFromCatID($catid);
4578 $blog =& $manager->getBlog($blogid);
4580 elseif ( intRequestVar('catid') )
4582 $catid = intRequestVar('catid');
4583 $blogid = getBlogIDFromCatID($catid);
4584 $blog =& $manager->getBlog($blogid);
4591 $condition = ($blog && $this->ifCategory($name, $value));
4594 $condition = $member->isLoggedIn();
4597 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4600 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4603 $condition = $member->isLoggedIn() && $member->isAdmin();
4605 case 'allowloginedit':
4606 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4609 $condition = ($itemidnext != '');
4612 $condition = ($itemidprev != '');
4614 case 'archiveprevexists':
4615 $condition = ($archiveprevexists == true);
4617 case 'archivenextexists':
4618 $condition = ($archivenextexists == true);
4621 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4624 $condition = $this->ifHasPlugin($name, $value);
4627 $condition = (Admin::getAdminAction() == $name);
4629 case 'adminoldaction':
4630 $condition = (Admin::getAdminAction() == $name);
4632 case 'addresschange':
4633 $condition = ($this->ifAddresscange());
4635 case 'bechangepass':
4636 $condition = ($this->beChangePassword());
4638 case 'skincandidates':
4639 $condition = ($this->ifSkincandidates());
4642 $condition = requestVar('nameclashes');
4644 case 'existsnewplugin':
4645 $condition = ($this->existsNewPlugin());
4652 $condition = (boolean) ($member->getAutosave() == $value);
4659 $condition = (Admin::$blog->getSetting($name) == $value);
4661 case 'itemproperty':
4666 if ( array_key_exists($name, Admin::$contents) )
4668 $condition = (boolean) (Admin::$contents[$name] == $value);
4672 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4679 * AdminActions::_ifHasPlugin()
4680 * hasplugin,PlugName
4681 * -> checks if plugin exists
4682 * hasplugin,PlugName,OptionName
4683 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
4684 * hasplugin,PlugName,OptionName=value
4685 * -> checks if the option OptionName from plugin PlugName is set to value
4687 * @param string $name name of plugin
4688 * @param string $value
4691 private function ifHasPlugin($name, $value)
4695 // (pluginInstalled method won't write a message in the actionlog on failure)
4696 if ( $manager->pluginInstalled("NP_{$name}") )
4698 $plugin =& $manager->getPlugin("NP_{$name}");
4699 if ( $plugin != NULL )
4707 list($name2, $value2) = preg_split('#=#', $value, 2);
4708 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4712 else if ( $plugin->getOption($name2) == $value2 )
4723 * AdminActions::beChangePassword()
4728 private function beChangePassword()
4730 return intRequestVar('bNeedsPasswordChange');
4734 * AdminActions::ifSkincandidates()
4735 * Checks if a plugin exists and call its doIf function
4741 private function ifSkincandidates()
4744 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4745 return (count($candidates) > 0);
4749 * AdminActions::ifPlugin()
4750 * Checks if a plugin exists and call its doIf function
4752 * @param string $name name of plugin
4753 * @param string $key
4754 * @param string $value
4757 private function ifPlugin($name, $key = '', $value = '')
4761 $plugin =& $manager->getPlugin("NP_{$name}");
4767 $params = func_get_args();
4768 array_shift($params);
4770 return call_user_func_array(array(&$plugin, 'doIf'), $params);
4774 * AdminActions::ifCategory()
4775 * Different checks for a category
4777 * @param string $key key for information of category
4778 * @param string $value value for information of category
4781 private function ifCategory($key = '', $value='')
4783 global $blog, $catid;
4785 // when no parameter is defined, just check if a category is selected
4786 if (($key != 'catname' && $key != 'catid') || ($value == ''))
4788 return $blog->isValidCategory($catid);
4791 // check category name
4792 if ( $key == 'catname' )
4794 $value = $blog->getCategoryIdFromName($value);
4795 if ($value == $catid)
4797 return $blog->isValidCategory($catid);
4801 // check category id
4802 if (($key == 'catid') && ($value == $catid))
4804 return $blog->isValidCategory($catid);
4811 * AdminActions::ifOnTeam()
4812 * Checks if a member is on the team of a blog and return his rights
4814 * @param string $blogName name of weblog
4817 private function ifOnTeam($blogName = '')
4819 global $blog, $member, $manager;
4821 // when no blog found
4822 if ( ($blogName == '') && !is_object($blog) )
4827 // explicit blog selection
4828 if ($blogName != '')
4830 $blogid = getBlogIDFromName($blogName);
4833 if (($blogName == '') || !$manager->existsBlogID($blogid))
4836 $blogid = $blog->getID();
4838 return $member->teamRights($blogid);
4842 * AdminActions::ifAdmin()
4843 * Checks if a member is admin of a blog
4845 * @param string $blogName name of weblog
4848 private function ifAdmin($blogName = '')
4850 global $blog, $member, $manager;
4852 // when no blog found
4853 if (($blogName == '') && (!is_object($blog)))
4858 // explicit blog selection
4859 if ($blogName != '')
4861 $blogid = getBlogIDFromName($blogName);
4864 if (($blogName == '') || !$manager->existsBlogID($blogid))
4867 $blogid = $blog->getID();
4870 return $member->isBlogAdmin($blogid);
4874 * AdminActions::ifAddresscange()
4875 * Check e-Mail address is changed
4880 private function ifAddresscange()
4884 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4889 $info = MEMBER::getActivationInfo($key);
4894 $mem =& $manager->getMember($info->vmember);
4899 if ( $info->vtype == 'addresschange' )
4908 * AdminActions::customHelp()
4909 * shows a link to custom help file
4912 * @param string $tplName
4913 * @param string $url
4914 * @param string $iconURL
4915 * @param string $alt
4916 * @param string $title
4920 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4922 echo $this->customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
4927 * AdminActions::customHelp()
4928 * shows a link to custom help file
4931 * @param string $tplName
4932 * @param string $url
4933 * @param string $iconURL
4934 * @param string $alt
4935 * @param string $title
4939 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
4941 global $CONF, $manager;
4943 $templates = array();
4947 $templates =& $manager->getTemplate($tplName);
4950 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
4952 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
4956 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
4961 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
4964 if ( empty($onclick) )
4966 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
4968 elseif ( preg_match('#^onclick#', $onclick) )
4970 $onclick = $onclick;
4974 $onclick = 'onclick="' . $onclick . '"';
4979 'helptarget' => $id,
4980 'onclick' => $onclick,
4981 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
4983 return Template::fill($template, $data);
4988 * AdminActions::customHelpHtml()
4990 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4992 global $CONF, $manager;
4994 $templates = array();
4998 $templates =& $manager->getTemplate($tplName);
5000 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5002 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5006 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5009 if ( empty($iconURL) )
5011 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5014 if ( function_exists('getimagesize') )
5016 $size = getimagesize($iconURL);
5017 $width = 'width="' . $size[0] . '" ';
5018 $height = 'height="' . $size[1] . '" ';
5022 'iconurl' => $iconURL,
5024 'height' => $height,
5025 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5026 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5029 $icon = Template::fill($template, $data);
5030 $help = $this->customHelplink($id, $tplName, $url, $title, $onclick);
5032 return $help . $icon;
5036 * AdminActions::existsNewPlugin()
5037 * Check exists new plugin
5040 * @return boolean exists or not
5042 private function existsNewPlugin()
5044 global $DIR_PLUGINS;
5046 $query = "SELECT * FROM %s;";
5047 $query = sprintf($query, sql_table('plugin'));
5048 $res = DB::getResult($query);
5050 $installed = array();
5051 foreach( $res as $row )
5053 $installed[] = $row['pfile'];
5056 $files = scandir($DIR_PLUGINS);
5058 $candidates = array();
5059 foreach ( $files as $file )
5061 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5063 if ( !in_array($matches[1], $installed) )
5065 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5069 $this->newPlugCandidates = $candidates;
5070 return (count($candidates) > 0);
5074 * AdminActions::pagehead()
5075 * Output admin page head
5080 public function parse_pagehead()
5082 global $member, $nucleus, $CONF, $manager;
5084 $extrahead = Admin::getAdminextrahead();
5086 'extrahead' => &$extrahead,
5087 'action' => Admin::getAdminAction()
5089 $manager->notify('AdminPrePageHead', $data);
5091 $content = $this->parser->skin->getContentFromDB('pagehead');
5094 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5098 if ( !array_key_exists('AdminCSS', $CONF) )
5100 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5101 $CONF['AdminCSS'] = 'original';
5105 /* HTTP 1.1 application for no caching */
5106 header("Cache-Control: no-cache, must-revalidate");
5107 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5109 $root_element = 'html';
5110 $charset = i18n::get_current_charset();
5111 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5112 $xml_version_info = self::$xml_version_info;
5113 $formal_public_identifier = self::$formal_public_identifier;
5114 $system_identifier = self::$system_identifier;
5115 $xhtml_namespace = self::$xhtml_namespace;
5117 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5118 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5119 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5121 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5124 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5126 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5127 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5128 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5129 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5130 echo "{$extrahead}\n";
5133 echo "<div id=\"adminwrapper\">\n";
5134 echo "<div class=\"header\">\n";
5135 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5137 echo "<div id=\"container\">\n";
5138 echo "<div id=\"content\">\n";
5139 echo "<div class=\"loginname\">\n";
5141 if ( !$member->isLoggedIn() )
5143 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5147 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5148 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5151 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5154 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5156 $codenamestring = '';
5160 $codenamestring = ' "' . $nucleus['codename'].'"';
5163 if ( $member->isLoggedIn() && $member->isAdmin() )
5165 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5166 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5168 $newestVersion = getLatestVersion();
5169 $newestCompare = str_replace('/', '.', $newestVersion);
5170 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5172 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5175 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5176 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5182 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5189 $this->parser->parse($content);
5196 * AdminActionss::pagefoot()
5197 * Output admin page foot include quickmenu
5202 public function parse_pagefoot()
5204 global $action, $member, $manager, $blogid;
5207 'action' => Admin::getAdminAction()
5209 $manager->notify('AdminPrePageFoot', $data);
5211 $content = $this->parser->skin->getContentFromDB('pagefoot');
5214 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5216 echo '<h2>' . _LOGOUT . "</h2>\n";
5218 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5219 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5223 echo "<div class=\"foot\">\n";
5224 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5226 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5229 echo "<div id=\"quickmenu\">\n";
5231 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5234 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5237 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5238 echo "<form method=\"get\" action=\"index.php\">\n";
5240 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5242 $showAll = requestVar('showall');
5244 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5246 // Super-Admins have access to all blogs! (no add item support though)
5247 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5248 $query = sprintf($query, sql_table('blog'));
5252 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5253 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5255 $template['name'] = 'blogid';
5256 $template['tabindex'] = 15000;
5257 $template['extra'] = _QMENU_ADD_SELECT;
5258 $template['selected'] = $blogid;
5259 $template['shorten'] = 10;
5260 $template['shortenel'] = '';
5261 $template['javascript'] = 'onchange="return form.submit()"';
5262 $this->parser->parse(showlist($query, 'select', $template));
5267 echo "<h2>{$member->getDisplayName()}</h2>\n";
5269 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5270 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5271 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5274 if ( $member->isAdmin() )
5276 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5278 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5279 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5280 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5281 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5282 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5283 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5284 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5287 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5289 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5290 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5291 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5295 $data = array('options' => array());
5296 $manager->notify('QuickMenu', $data);
5298 if ( count($data['options']) > 0 )
5300 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5302 foreach ( $data['options'] as $option )
5304 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5309 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5312 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5316 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5319 echo "<!-- quickmenu -->\n";
5322 echo "<!-- content -->\n";
5325 echo "<!-- container -->\n";
5328 echo "<!-- adminwrapper -->\n";
5336 $this->parser->parse($content);
5343 * AdminActions::selectBlog()
5344 * Inserts a HTML select element with choices for all blogs to which the user has access
5345 * mode = 'blog' => shows blognames and values are blogids
5346 * mode = 'category' => show category names and values are catids
5348 * @param string $name
5349 * @param string $mode
5350 * @param integer $selected
5351 * @param integer $tabindex
5352 * @param integer $showNewCat
5353 * @param integer $iForcedBlogInclude ID for weblog always included
5354 * @param $iForcedBlogInclude
5355 * ID of a blog that always needs to be included, without checking if the
5356 * member is on the blog team (-1 = none)
5359 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5361 global $member, $CONF;
5363 // 0. get IDs of blogs to which member can post items (+ forced blog)
5364 $aBlogIds = array();
5365 if ( $iForcedBlogInclude != -1 )
5367 $aBlogIds[] = intval($iForcedBlogInclude);
5370 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5372 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5373 $query = sprintf($query, sql_table('blog'));
5377 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5378 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5381 $rblogids = DB::getResult($query);
5382 foreach ( $rblogids as $row )
5384 if ( $row['bnumber'] != $iForcedBlogInclude )
5386 $aBlogIds[] = intval($row['bnumber']);
5390 if ( count($aBlogIds) == 0 )
5395 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5397 // 1. select blogs (we'll create optiongroups)
5398 // (only select those blogs that have the user on the team)
5399 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5400 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5401 $blogs = DB::getResult($queryBlogs);
5403 if ( $mode == 'category' )
5405 if ( $blogs->rowCount() > 1 )
5409 foreach ( $blogs as $rBlog )
5411 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5413 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5416 // show selection to create new category when allowed/wanted
5419 // check if allowed to do so
5420 if ( $member->blogAdminRights($rBlog['bnumber']) )
5422 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5426 // 2. for each category in that blog
5427 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5428 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5429 $categories = DB::getResult($catQuery);
5430 foreach ( $categories as $rCat )
5432 if ( $rCat['catid'] == $selected )
5434 $selectText = ' selected="selected" ';
5440 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5443 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5451 foreach ( $blogs as $rBlog )
5453 echo '<option value="' . $rBlog['bnumber'] . '"';
5454 if ( $rBlog['bnumber'] == $selected )
5456 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5460 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";