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()
1081 $type = strtolower(trim(requestVar('type')));
1082 $skinid = intRequestVar('skinid');
1084 if ( !preg_match('#^admin#', $this->skintype) )
1086 $skin =& $manager->getSkin($skinid);
1091 $skin =& $manager->getSkin($skinid, 'AdminActions');
1092 $tag = 'adminskinvar';
1095 $actions = $skin->getAllowedActionsForType($type);
1098 while ( $current = array_shift($actions) )
1100 echo helplink("{$tag}-{$current}") . "$current</a>\n";
1102 if ( count($actions) != 0 )
1111 * AdminActions::parse_banlistdeletedlist()
1112 * Parse skinvar banlistdeletedlist
1114 * @param string $template_name name of template to use
1117 public function parse_banlistdeletedlist($template_name = '')
1121 $templates = array();
1122 if ( $template_name )
1124 $templates =& $manager->getTemplate($template_name);
1127 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1129 $template = "<li><%blogname%></li>\n";
1133 $template = $templates['BANLIST_DELETED_LIST'];
1136 $deleted = requestArray('delblogs');
1137 foreach ( $deleted as $delblog )
1139 $blog =& $manager->getBlog($delblog);
1141 'blogname' => Entity::hsc($blog->getName())
1143 echo Template::fill($template, $data);
1150 * AdminActions::parse_batchdeletelist()
1151 * Parse skinvar batchdeletelist
1156 public function parse_batchdeletelist()
1158 $selected = requestIntArray('batch');
1161 foreach ( $selected as $select )
1163 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1165 // add hidden vars for team & comment
1166 if ( requestVar('action') == 'batchteam' )
1168 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1170 if ( requestVar('action') == 'batchcomment' )
1172 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1178 * AdminActions::parse_batchdeletetype()
1179 * Parse skinvar batchdeletetype
1184 public function parse_batchdeletetype()
1186 echo Entity::hsc(requestVar('action'));
1191 * AdminActions::parse_batchmovebtn()
1192 * Parse skinvar batchmovebtn
1197 public function parse_batchmovebtn()
1199 $actionType = requestVar('action');
1200 switch ( $actionType )
1205 case 'batchcategory':
1213 * AdminActions::parse_batchmovelist()
1214 * Parse skinvar batchmovelist
1219 public function parse_batchmovelist()
1221 $selected = requestIntArray('batch');
1223 foreach ( $selected as $select )
1225 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1232 * AdminActions::parse_batchmovetitle()
1233 * Parse skinvar batchmovetitle
1238 public function parse_batchmovetitle()
1240 $actionType = requestVar('action');
1241 switch ( $actionType )
1246 case 'batchcategory':
1247 echo _MOVECAT_TITLE;
1254 * AdminActions::parse_batchmovetype()
1255 * Parse skinvar batchmovetype
1260 public function parse_batchmovetype()
1262 echo Entity::hsc(requestVar('action'));
1267 * AdminActions::parse_blogcatlist()
1268 * Parse skinvar blogcatlist
1273 public function parse_blogcatlist($template_name = '')
1276 $blogid = intRequestVar('blogid');
1277 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1278 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1280 $resource = DB::getResult($query);
1281 if ( $resource->rowCount() > 0 )
1283 $template['content'] = 'categorylist';
1284 $template['tabindex'] = 200;
1285 $this->parser->parse(listplug_batchlist('category', $resource, 'table', $template));
1289 /* TODO: nothing to be shown */
1291 $resource->closeCursor();
1297 * AdminActions::parse_blogid()
1298 * Parse skinvar blogid
1303 public function parse_blogid()
1305 echo intRequestVar('blogid');
1310 * AdminActions::parse_blognotifysetting()
1311 * Parse skinvar blognotifysetting
1316 public function parse_blognotifysetting($type)
1319 $blogid = intRequestVar('blogid');
1320 $blog =& $manager->getBlog($blogid);
1325 if ( !$blog->notifyOnComment() )
1331 if ( !$blog->notifyOnVote() )
1337 if ( !$blog->notifyOnNewItem() )
1343 echo ' checked="checked"';
1348 * AdminActions::parse_blogsetting()
1349 * Parse skinvar blogsetting
1351 * @param string $which name of weblog setting
1354 public function parse_blogsetting($which)
1356 echo $this->parse_getblogsetting($which);
1361 * AdminActions::parse_blogsettingyesno()
1362 * Parse skinvar blogsettingyesno
1364 * @param string $type type of weblog setting
1365 * @param string $template_name name of template to use
1368 public function parse_blogsettingyesno($type, $template_name = '')
1372 $blogid = intRequestVar('blogid');
1373 $blog =& $manager->getBlog($blogid);
1377 case 'convertbreaks':
1378 $checkedval = $blog->convertBreaks();
1381 case 'allowpastposting':
1382 $checkedval = $blog->allowPastPosting();
1386 $checkedval = $blog->commentsEnabled();
1390 $checkedval = $blog->isPublic();
1394 $checkedval = $blog->emailRequired();
1398 $checkedval = $blog->getSearchable();
1402 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $template_name);
1407 * AdminActions::parse_blogteamlist()
1408 * Parse skinvar blogteamlist
1410 * @param string $template_name name of template to use
1413 public function parse_blogteamlist($template_name = '')
1416 $blogid = intRequestVar('blogid');
1417 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1419 . "WHERE tmember=mnumber AND tblog= %d";
1420 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1422 $resource = DB::getResult($query);
1423 if ( $resource->rowCount() > 0 )
1425 $template['content'] = 'teamlist';
1426 $template['tabindex'] = 10;
1428 $this->parser->parse(listplug_batchlist('team', $resource, 'table', $template));
1434 $resource->closeCursor();
1440 * AdminActions::parse_blogteammembers()
1441 * Parse skinvar blogteammembers
1446 public function parse_blogteammembers()
1448 $blogid = intRequestVar('blogid');
1449 $query = "SELECT mname, mrealname "
1451 . "WHERE mnumber=tmember AND tblog=%d;";
1452 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1453 $res = DB::getResult($query);
1454 $memberNames = array();
1455 foreach ( $res as $row )
1457 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1459 echo implode(',', $memberNames);
1463 * AdminActions::parse_blogtime()
1464 * Parse skinvar blogtime
1466 * @param string $type type of time
1467 * @param string $format format for time expression
1468 * @param integer $offset offset of time
1471 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1475 if ( $type != 'blogtime' )
1477 /* return server time */
1478 $timestamp = time() + $offset;
1482 $bid = intRequestVar('blogid');
1483 $b =& $manager->getBlog($bid);
1484 $timestamp = $b->getCorrectTime() + $offset;
1487 echo i18n::formatted_datetime($format, $timestamp);
1492 * AdminActions::parse_bookmarkletadmin()
1493 * Parse skinvar bookmarkletadmin
1498 public function parse_bookmarkletadmin()
1502 $blogid = intRequestVar('blogid');
1504 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1509 * AdminActions::parse_categories()
1510 * Parse skinvar categories
1512 * create category dropdown box
1514 * @param string $type name of setting for category
1517 public function parse_categories($startidx = 0)
1522 $itemid = intRequestVar('itemid');
1523 $item = &$manager->getItem($itemid, 1, 1);
1528 $blogid = intRequestVar('blogid');
1532 $blogid = $item['blogid'];
1534 $blog = &$manager->getBlog($blogid);
1536 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1538 $item['body'] = removeBreaks($item['body']);
1539 $item['more'] = removeBreaks($item['more']);
1542 $contents = array();
1543 if ( requestVar('action') == 'itemedit' )
1548 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1551 $catid = $blog->getDefaultCategory();
1556 $catid = $contents['catid'];
1559 $this->selectBlog('catid', 'category', $catid, $startidx, 1, $blog->getID());
1565 * AdminActions::parse_category()
1566 * Parse skinvar category
1568 * @param string $type name of setting for category
1571 public function parse_category($type = 'name')
1573 echo $this->parse_getcategory($type);
1578 * AdminActions::parse_categorysetting()
1579 * Parse skinvar categorysetting
1581 * @param string $type type in category setting
1584 public function parse_categorysetting($type)
1586 $catid = intRequestVar('catid');
1587 if ( $type == 'id' )
1592 $blogid = intRequestVar('blogid');
1593 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1594 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1595 $row = DB::getRow($query);
1597 if ( $type != 'name' )
1599 echo Entity::hsc($row['cdesc']);
1603 echo Entity::hsc($row['cname']);
1610 * AdminActions::parse_codename()
1611 * Parse templatevar codename
1617 public function parse_checkedonval($value, $name)
1622 $itemid = intRequestVar('itemid');
1623 $item =& $manager->getItem($itemid, 1, 1);
1627 $blog =& $manager->getBlog($item['blogid']);
1629 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1631 $item['body'] = removeBreaks($item['body']);
1632 $item['more'] = removeBreaks($item['more']);
1636 $contents = array();
1637 if ( requestVar('action') == 'itemedit' )
1641 if ( !isset($contents[$name]) )
1643 $contents[$name] = '';
1645 if ($contents[$name] == $value)
1647 echo 'checked="checked"';
1653 * AdminActions::parse_codename()
1654 * Parse templatevar codename
1659 * TODO: is this need???
1661 public function parse_codename()
1664 echo $nucleus['codename'];
1669 * AdminActions::parse_commentnavlist()
1670 * Parse skinvar commentnavlist
1675 public function parse_commentnavlist()
1677 global $CONF, $manager, $member;
1680 if ( postVar('start') )
1682 $start = intPostVar('start');
1689 // amount of items to show
1690 if ( postVar('amount') )
1692 $amount = intPostVar('amount');
1696 $amount = (integer) $CONF['DefaultListSize'];
1702 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1704 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
1706 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1708 if ( $this->skintype == 'itemcommentlist' )
1710 $itemid = intRequestVar('itemid');
1711 $query .= " citem={$itemid}";
1712 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1714 $nonComments = _NOCOMMENTS;
1716 elseif ( $this->skintype == 'browseowncomments' )
1719 $query .= ' cmember=' . $member->getID();
1720 $template['canAddBan'] = 0;
1722 $nonComments = _NOCOMMENTS_YOUR;
1724 elseif ( $this->skintype == 'blogcommentlist' )
1727 $query .= ' cblog=' . intRequestVar('blogid');
1728 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1729 $bid = intRequestVar('blogid');
1730 $nonComments = _NOCOMMENTS_BLOG;
1733 $search = postVar('search');
1734 if ( !empty($search) )
1736 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
1739 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1741 $resource = DB::getResult($query);
1742 if ( $resource->rowCount() > 0 )
1744 $template['action'] = $this->skintype;
1745 $template['start'] = $start;
1746 $template['amount'] = $amount;
1747 $template['minamount'] = 0;
1748 $template['maxamount'] = 1000;
1749 $template['blogid'] = $bid;
1750 $template['search'] = $search;
1751 $template['itemid'] = $itemid;
1753 $template['content'] = 'commentlist';
1755 $this->parser->parse(listplug_navlist('comment', $resource, 'table', $template));
1759 /* TODO: nothing to be shown */
1761 $resource->closeCursor();
1767 * AdminActions::parse_configsettingsedit()
1768 * Parse skinvar configsettingsedit
1770 * @param string $type type of global configuration
1773 public function parse_configsettingsedit($type)
1778 case 'DefaultListSize':
1779 if ( !array_key_exists('DefaultListSize', $CONF) )
1781 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1782 $query = sprintf($query, sql_table('config'));
1783 DB::execute($query);
1784 $CONF['DefaultListSize'] = 10;
1786 elseif ( intval($CONF['DefaultListSize']) < 1 )
1788 $CONF['DefaultListSize'] = 10;
1790 echo intval($CONF['DefaultListSize']);
1792 case 'SessionCookie':
1793 $value = $CONF['SessionCookie'];
1794 $txt1 = _SETTINGS_COOKIESESSION;
1795 $txt2 = _SETTINGS_COOKIEMONTH;
1796 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1799 $value = $CONF['URLMode'];
1800 $txt1 = _SETTINGS_URLMODE_NORMAL;
1801 $txt2 = _SETTINGS_URLMODE_PATHINFO;
1802 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1805 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1807 echo Entity::hsc($CONF[$type]);
1815 * AdminActions::parse_configsettingsyesno()
1816 * Parse skinvar configsettingsyesno
1818 * @param string $type type of global setting
1819 * @param integer $tabindex tabindex attribute of input element
1822 public function parse_configsettingsyesno($type, $tabindex)
1825 if ( array_key_exists($type, $CONF) )
1827 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1833 * AdminActions::parse_contents()
1834 * Parse skinvar contents
1836 * @param string $which part for item
1839 public function parse_contents($which)
1841 if ( !array_key_exists($which, Admin::$contents) )
1843 Admin::$contents[$which] = '';
1845 echo Entity::hsc(Admin::$contents[$which]);
1849 * AdminActions::parse_currenttime()
1850 * Parse skinvar currenttime
1852 * @param string $what
1855 public function parse_currenttime($what)
1857 $nu = getdate(Admin::$blog->getCorrectTime());
1862 * AdminActions::parse_customhelplink()
1863 * Parse skinvar customhelplink
1865 * @param string $topic name of topic
1866 * @param string $tplName name of template
1867 * @param string $url string as URI
1868 * @param string $iconURL string as URI for icon
1869 * @param string $alt alternative text for image element
1870 * @param string $title title for anchor element
1873 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1875 $this->customHelp($topic, $url, $iconURL);
1880 * AdminActions::parse_date()
1881 * Parse skinvar date
1883 public function parse_date($format = 'c')
1885 global $CONF, $manager;
1886 /* TODO: offset is based on i18n::get_current_locale()? */
1887 echo i18n::formatted_datetime($format, time());
1892 * AdminActions::parse_normalskinlist()
1893 * Parse skinvar defaultadminskintypes
1895 * @param string $template_name name of template
1898 public function parse_normalskinlist($template_name = '')
1900 global $CONF, $manager;
1902 if ( !preg_match('#^admin#', $this->skintype) )
1904 $skin =& $manager->getSkin($CONF['BaseSkin']);
1905 /* TODO: removeaction? */
1906 $template['editaction'] = 'skinedittype';
1910 $skin =& $manager->getSkin($CONF['AdminSkin'], 'AdminActions');
1911 $template['editaction'] = 'adminskinedittype';
1912 /* TODO: removeaction? */
1915 $temporary = $skin->getDefaultTypes();
1916 $normal_skintype = array();
1917 foreach ( $temporary as $type => $label )
1919 $normal_skintype[] = array(
1920 'skintype' => $type,
1921 'skintypename' => $label
1925 $template['tabindex'] = 10;
1926 $template['skinid'] = $skin->getID();
1927 $template['skinname'] = $skin->getName();
1928 $this->parser->parse(showlist($normal_skintype, 'list_normalskinlist', $template, $template_name));
1934 * AdminActions::parse_defblogselect()
1935 * Parse skinvar defblogselect
1937 * @param string $template_name name of template
1940 public function parse_defblogselect($template_name = '')
1944 $query = "SELECT bname as text, bnumber as value FROM %s;";
1945 $query = sprintf($query, sql_table('blog'));
1947 $template['name'] = 'DefaultBlog';
1948 $template['selected'] = $CONF['DefaultBlog'];
1949 $template['tabindex'] = 10;
1950 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1956 * AdminActions::parse_defcatselect()
1957 * Parse skinvar defcatselect
1959 * @param string $template_name name of template
1962 public function parse_defcatselect($template_name = '')
1966 $blogid = intRequestVar('blogid');
1967 $blog =& $manager->getBlog($blogid);
1969 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
1970 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
1972 $template['name'] = 'defcat';
1973 $template['selected'] = $blog->getDefaultCategory();
1974 $template['tabindex'] = 110;
1976 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1982 * AdminActions::parse_defskinselect()
1983 * Parse skinvar defskinselect
1985 * @param string $type type of skin
1986 * @param string $template_name name of template
1989 public function parse_defskinselect($type = 'blog', $template_name = '')
1991 global $CONF, $manager, $member;
1993 if ( !preg_match('#^admin#', $this->skintype) )
1995 $blogid = intRequestVar('blogid');
1998 $template['selected'] = $CONF['BaseSkin'];
2002 $blog =& $manager->getBlog($blogid);
2003 $template['selected'] = $blog->getDefaultSkin();
2006 if ( $type != 'blog' )
2008 $template['name'] = 'BaseSkin';
2012 $template['name'] = 'defskin';
2015 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2019 /* TODO: member object will have its own adminskin id */
2020 $template['selected'] = $CONF['AdminSkin'];
2021 $template['name'] = 'AdminSkin';
2022 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
2025 $query = sprintf($query, sql_table('skin_desc'));
2026 $template['tabindex'] = 50;
2028 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2034 * AdminActions::parse_deletecomment()
2035 * Parse skinvar deletecomment
2037 * @param string $type type of infomation for comment
2040 public function parse_deletecomment($type = 'id')
2042 $commentid = intRequestVar('commentid');
2043 $comment = COMMENT::getComment($commentid);
2048 echo intRequestVar('commentid');
2051 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2053 echo $comment['member'];
2057 echo $comment['user'];
2061 $body = strip_tags($comment['body']);
2062 echo Entity::hsc(shorten($body, 300, '...'));
2068 * AdminActions::parse_deleteitembody()
2069 * Parse skinvar deleteitembody
2074 public function parse_deleteitembody()
2078 $itemid = intRequestVar('itemid');
2079 $item =& $manager->getItem($itemid, 1, 1);
2081 $body = strip_tags($item['body']);
2083 echo Entity::hsc(shorten($body, 300, '...'));
2089 * AdminActions::parse_deleteitemid()
2090 * Parse skinvar deleteitemid
2095 public function parse_deleteitemid()
2097 echo (integer) intRequestVar('itemid');
2102 * AdminActions::parse_deleteitemtitle()
2103 * Parse skinvar deleteitemtitle
2108 public function parse_deleteitemtitle()
2112 $itemid = intRequestVar('itemid');
2113 $item =& $manager->getItem($itemid, 1, 1);
2115 echo Entity::hsc(strip_tags($item['title']));
2121 * AdminActions::parse_editcomment()
2122 * Parse skinvar editcomment
2124 * @param string $type type of comment setting
2127 public function parse_editcomment($type = 'id')
2131 $commentid = intRequestVar('commentid');
2132 $comment = COMMENT::getComment($commentid);
2134 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2139 echo intRequestVar('commentid');
2142 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2144 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2148 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2152 echo date("Y-m-d @ H:i", $comment['timestamp']);
2155 $comment['body'] = str_replace('<br />', '', $comment['body']);
2156 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2157 echo $comment['body'];
2160 echo $comment['userid'];
2163 echo $comment['userid'];
2166 echo $comment[$type];
2173 * AdminActions::parse_editdesturl()
2174 * Parse skinvar editdesturl
2176 public function parse_editdesturl()
2178 if ( requestVar('desturl') )
2180 echo Entity::hsc(requestVar('desturl'));
2186 * AdminActions::parse_editmemberlist()
2187 * Parse skinvar editmemberlist
2189 * @param string $template_name name of template
2192 public function parse_editmemberlist($template_name = '')
2195 // show list of members with actions
2196 $query = 'SELECT * FROM %s;';
2197 $query = sprintf($query, sql_table('member'));
2199 $resource = DB::getResult($query);
2200 if ( $resource->rowCount() > 0 )
2202 $template['content'] = 'memberlist';
2203 $template['tabindex'] = 10;
2205 $this->parser->parse(listplug_batchlist('member', $resource, 'table', $template));
2211 $resource->closeCursor();
2217 * AdminActions::parse_editmember()
2218 * Parse skinvar editmember
2220 * @param string $type type of information for member
2221 * @return string $tempateName name of template to use
2224 public function parse_editmember($type = 'id', $template_name = '')
2226 global $CONF, $manager, $member;
2228 $memberid = intRequestVar('memberid');
2229 $mem =& $manager->getMember($memberid);
2234 echo intRequestVar('memberid');
2237 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2239 echo Entity::hsc($mem->getDisplayName());
2243 $dispName = Entity::hsc($mem->getDisplayName());
2244 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2246 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2255 echo Entity::hsc($mem->getRealName());
2258 echo Entity::hsc($mem->getEmail());
2261 echo Entity::hsc($mem->getURL());
2264 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $template_name);
2267 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $template_name);
2270 echo Entity::hsc($mem->getNotes());
2273 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $template_name);
2282 * AdminActions::parse_editpluginfo()
2283 * Parse skinvar editpluginfo
2285 * @param string $type type of plugin info
2288 public function parse_editpluginfo($type)
2292 $pid = intRequestVar('plugid');
2299 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2306 * AdminActions::parse_editplugoptionslist()
2307 * Parse skinvar editplugoptionslist
2309 * @param string $template_name name of template
2312 public function parse_editplugoptionslist($template_name = '')
2316 $pid = intRequestVar('plugid');
2317 $aOptions = array();
2320 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2321 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2322 $resource = DB::getResult($query);
2324 foreach ( $resource as $row )
2326 $aOIDs[] = $row['oid'];
2327 $aOptions[$row['oid']] = array(
2328 'oid' => $row['oid'],
2329 'value' => $row['odef'],
2330 'name' => $row['oname'],
2331 'description' => $row['odesc'],
2332 'type' => $row['otype'],
2333 'typeinfo' => $row['oextra'],
2338 // fill out actual values
2339 if ( count($aOIDs) > 0 )
2341 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2342 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2344 $result = DB::getResult($query);
2345 foreach ( $result as $row )
2347 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2353 'context' => 'global',
2355 'options' => &$aOptions
2357 $manager->notify('PrePluginOptionsEdit', $data);
2359 if ( sizeof($aOptions) > 0 )
2361 $template['content'] = 'plugoptionlist';
2362 $this->parser->parse(showlist($aOptions, 'table', $template, $template_name));
2366 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2372 * AdminActions::parse_editskin()
2373 * Parse skinvar editskin
2375 * @param string $type type of skin
2378 public function parse_editskin($type = 'id')
2382 $skinid = intRequestVar('skinid');
2384 if ( !preg_match('#^admin#', $this->skintype) )
2386 $skin =& $manager->getSKIN($skinid);
2390 $skin =& $manager->getSKIN($skinid, 'AdminActions');
2396 echo intRequestVar('skinid');
2399 echo Entity::hsc($skin->getName());
2402 echo Entity::hsc($skin->getDescription());
2405 echo Entity::hsc($skin->getContentType());
2408 echo Entity::hsc($skin->getIncludePrefix());
2411 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2419 * AdminActions::parse_editskintype()
2420 * Parse skinvar editskintype
2422 * @param string $type name of type for skin type
2425 public function parse_editskintype($stype = 'id')
2429 static $skin = NULL;
2430 static $types = array();
2432 if ( $skin == NULL )
2434 $skinid = intRequestVar('skinid');
2436 if ( !preg_match('#^admin#', $this->skintype) )
2438 $skin =& $manager->getSkin($skinid);
2442 $skin =& $manager->getSkin($skinid, 'AdminActions');
2445 $types = $skin->getDefaultTypes();
2448 $type = strtolower(trim(requestVar('type')));
2453 echo $skin->getID();
2456 echo Entity::hsc($skin->getName());
2459 echo Entity::hsc($skin->getDescription());
2462 echo Entity::hsc($skin->getContentType());
2465 echo Entity::hsc($skin->getContentFromDB($type));
2468 if ( !array_key_exists($type, $types) )
2470 $skinType = ucfirst($type);
2474 $skinType = $types[$type];
2476 echo Entity::hsc($skinType);
2479 echo Entity::hsc($type);
2482 echo Entity::hsc($skin->getIncludePrefix());
2485 if ( !$skin->getIncludeMode() != 'skindir' )
2487 $incMode = _PARSER_INCMODE_NORMAL;
2491 $incMode = _PARSER_INCMODE_SKINDIR;
2493 echo Entity::hsc($incMode);
2502 * AdminActions::parse_adminurl()
2503 * Parse skinvar adminurl
2504 * (shortcut for admin url)
2509 public function parse_adminurl()
2511 $this->parse_sitevar('adminurl');
2516 * AdminActions::parse_edittemplateinfo()
2517 * Parse skinvar edittemplateinfo
2519 * @param string $format format to output
2520 * @param string $typedesc type of template
2521 * @param string $typename type name of template
2522 * @param string $help help text
2523 * @param string $tabindex index value for tabindex attribute of input element
2524 * @param string $big textarea size
2525 * @param string $tplt name of template to be filled
2528 public function parse_edittemplateinfo($format, $typedesc = '', $typename = '', $help = '', $tabindex = 0, $big = 0, $template_name = '')
2532 static $name = NULL;
2533 static $desc = NULL;
2537 $id = intRequestVar('templateid');
2540 if ( $name == NULL )
2542 $name = Template::getNameFromId($id);
2545 if ( $desc == NULL )
2547 $desc = Template::getDesc($id);
2550 $template =& $manager->getTemplate($name);
2558 echo Entity::hsc($name);
2561 echo Entity::hsc($desc);
2563 case 'extratemplate':
2565 $pluginfields = array();
2566 if ( !preg_match('#^admin/#', $this->skintype) )
2568 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2572 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
2575 foreach ( $pluginfields as $ptkey => $ptvalue )
2580 $tmplt =& $manager->getTemplate($desc);
2583 /* extra plugin field */
2584 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2588 . "<th colspan=\"2\"><%explugtplname%></th>\n";
2592 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2595 'explugtplname' => Entity::hsc($ptkey)
2597 echo Template::fill($base, $data);
2599 foreach ( $ptvalue as $ptname => $ptdesc )
2601 if ( !array_key_exists($ptname, $template) )
2607 $content = $template[$ptname];
2609 $this->parser->parse(listplug_templateEditRow($content, $ptdesc, $ptname, $help, $tabidx++, $big, $template_name));
2615 $typedesc = defined($typedesc) ? constant($typedesc) : $typedesc;
2616 $typename = defined($typename) ? constant($typename) : $typename;
2618 if ( !array_key_exists($typename, $template) )
2624 $content = $template[$typename];
2626 $this->parser->parse(listplug_templateEditRow($content, $typedesc, $typename, $help, $tabindex, $big, $template_name));
2634 * AdminActions::parse_eventformextra()
2635 * Parse skinvar eventformextra
2637 * @param string $type name of type for event form extra
2640 public function parse_eventformextra($type = 'activation')
2649 $key = requestVar('ackey');
2652 Admin::error(_ERROR_ACTIVATE);
2654 $info = MEMBER::getActivationInfo($key);
2657 Admin::error(_ERROR_ACTIVATE);
2659 $mem =& $manager->getMember($info->vmember);
2662 Admin::error(_ERROR_ACTIVATE);
2665 'type' => 'activation',
2669 case 'membermailform-notloggedin':
2670 $data = array('type' => 'membermailform-notloggedin',);
2673 $manager->notify('FormExtra', $data);
2678 * AdminActions::parse_extrahead()
2679 * Parse skinvar extrahead
2681 public function parse_extrahead()
2685 $extrahead = Admin::getAdminextrahead();
2688 'extrahead' => &$extrahead,
2689 'action' => Admin::getAdminAction()
2692 $manager->notify('AdminPrePageHead', $data);
2698 * AdminActions::parse_member()
2699 * Parse skinvar member
2700 * (includes a member info thingie)
2702 * @param string $what which memberdata is needed
2705 public function parse_member($what)
2707 global $memberinfo, $member, $CONF;
2709 // 1. only allow the member-details-page specific variables on member pages
2710 if ( $this->skintype == 'member' )
2715 echo Entity::hsc($memberinfo->getDisplayName());
2718 echo Entity::hsc($memberinfo->getRealName());
2721 echo Entity::hsc($memberinfo->getNotes());
2724 echo Entity::hsc($memberinfo->getURL());
2727 echo Entity::hsc($memberinfo->getEmail());
2730 echo Entity::hsc($memberinfo->getID());
2735 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2736 if ( $member->isLoggedIn() )
2741 echo $member->getDisplayName();
2743 case 'yourrealname':
2744 echo $member->getRealName();
2747 echo $member->getNotes();
2750 echo $member->getURL();
2753 echo $member->getEmail();
2756 echo $member->getID();
2758 case 'yourprofileurl':
2759 if ( $CONF['URLMode'] == 'pathinfo' )
2761 echo Link::create_member_link($member->getID());
2765 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
2774 * AdminActions::parse_version()
2775 * Parse skinvar version
2776 * (include nucleus versionnumber)
2781 public function parse_version()
2784 echo 'Nucleus CMS ' . $nucleus['version'];
2789 * AdminActions::parse_sitevar()
2790 * Parse skinvar sitevar
2791 * (include a sitevar)
2793 * @param string $which
2796 public function parse_sitevar($which)
2802 echo $CONF['IndexURL'];
2805 echo $CONF['SiteName'];
2808 echo $CONF['AdminEmail'];
2811 echo $CONF['AdminURL'];
2818 * AdminActions::parse_actionurl()
2824 public function parse_actionurl()
2827 echo Entity::hsc($CONF['ActionURL']);
2832 * AdminActions::parse_getblogsetting()
2833 * Parse skinvar getblogsetting
2835 public function parse_getblogsetting($which)
2837 global $blog, $manager;
2843 elseif ( $bid = intRequestVar('blogid') )
2845 $b =& $manager->getBlog($bid);
2855 return Entity::hsc($b->getID());
2858 return Entity::hsc($b->getURL());
2861 return Entity::hsc($b->getName());
2864 return Entity::hsc($b->getDescription());
2867 return Entity::hsc($b->getShortName());
2869 case 'notifyaddress':
2870 return Entity::hsc($b->getNotifyAddress());
2873 return Entity::hsc($b->getMaxComments());
2876 return Entity::hsc($b->getUpdateFile());
2879 return Entity::hsc($b->getTimeOffset());
2886 * AdminActions::parse_geteditpluginfo()
2887 * Parse skinvar geteditpluginfo
2889 * @param string $type name of setting for edit plugin info
2892 public function parse_geteditpluginfo($type)
2895 $pid = intRequestVar('plugid');
2902 return Entity::hsc($manager->getPluginNameFromPid($pid));
2909 * AdminActions::parse_getmember()
2910 * Parse skinvar getmember
2911 * (includes a member info thingie)
2913 * @param string $what name of setting for member
2916 public function parse_getmember($what)
2918 global $memberinfo, $member;
2919 // 1. only allow the member-details-page specific variables on member pages
2920 if ( $this->skintype == 'member' )
2925 return Entity::hsc($memberinfo->getDisplayName());
2928 return Entity::hsc($memberinfo->getRealName());
2931 return Entity::hsc($memberinfo->getNotes());
2934 return Entity::hsc($memberinfo->getURL());
2937 return Entity::hsc($memberinfo->getEmail());
2940 return Entity::hsc($memberinfo->getID());
2944 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2945 if ( $member->isLoggedIn() )
2950 return $member->getDisplayName();
2952 case 'yourrealname':
2953 return $member->getRealName();
2956 return $member->getNotes();
2959 return $member->getURL();
2962 return $member->getEmail();
2965 return $member->getID();
2973 * AdminActions::parse_headmessage()
2974 * Parse skinvar headmessage
2979 public function parse_headmessage()
2981 if ( !empty(Admin::$headMess) )
2983 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
2989 * AdminActions::parse_helplink()
2990 * Parse skinvar helplink
2992 * @param string $topic name of topic for help
2995 public function parse_helplink($topic = '')
2997 if ( !empty($topic) )
3005 * AdminActions::parse_helpplugname()
3006 * Parse skinvar helpplugname
3011 public function parse_helpplugname()
3013 $plugid = intGetVar('plugid');
3014 Entity::hsc($manager->getPluginNameFromPid($plugid));
3019 * AdminActions::parse_ilistaddnew()
3020 * Parse skinvar ilistaddnew
3025 public function parse_ilistaddnew()
3027 $blogid = intRequestVar('blogid');
3028 if ( intPostVar('start') == 0 )
3030 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3036 * AdminActions::parse_importskininfo()
3037 * Parse skinvar importskininfo
3039 * @param string $type name of information for imported skin
3042 public function parse_importskininfo($type)
3047 echo Entity::hsc(requestVar('skininfo'));
3050 $dataArr = requestArray('skinnames');
3051 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3054 $dataArr = requestArray('tpltnames');
3055 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3058 $dataArr = requestArray('skinclashes');
3059 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3062 $dataArr = requestArray('tpltclashes');
3063 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3066 echo Entity::hsc(requestVar('skinfile'));
3069 echo Entity::hsc(requestVar('mode'));
3076 * AdminActions::parse_init()
3077 * some init stuff for all forms
3082 public function parse_init()
3087 if ( requestVar('action') == 'itemedit' )
3089 $authorid = Admin::$contents['authorid'];
3092 Admin::$blog->insertJavaScriptInfo($authorid);
3097 * AdminActions::parse_inputyesno()
3098 * Parse skinvar inputyesno
3100 * @param string $name
3101 * @param string $checkedval
3102 * @param string $tabindex
3103 * @param string $value1
3104 * @param string $value2
3105 * @param string $yesval
3106 * @param string $noval
3107 * @param string $isAdmin
3108 * @param string $template_name
3111 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $template_name = '')
3113 $this->parser->parse(listplug_input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $template_name));
3118 * AdminActions::parse_insertpluginfo()
3119 * Parse templatevar insertpluginfo
3121 public function parse_insertpluginfo($type)
3123 $option = Admin::getAdminaOption();
3127 return $option['pid'];
3130 return Entity::hsc($option['pfile']);
3137 * AdminActions::parse_insplugoptcontent()
3138 * Parse skinvar insplugoptcontent
3143 public function parse_insplugoptcontent()
3145 $option = Admin::getAdminaOption();
3147 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3148 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3151 listplug_plugOptionRow($option);
3158 * AdminActions::parse_iprangeinput()
3159 * Parse skinvar iprangeinput
3164 public function parse_iprangeinput()
3166 if ( requestVar('ip') )
3168 $iprangeVal = Entity::hsc(requestVar('ip'));
3169 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3170 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3171 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3172 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3173 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3177 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3178 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3184 * AdminActions::parse_itemnavlist()
3185 * Parse skinvar itemnavlist
3190 public function parse_itemnavlist($template_name)
3192 global $CONF, $manager, $member;
3194 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3195 . " FROM %s, %s, %s, %s"
3196 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3198 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3200 if ( $this->skintype == 'itemlist' )
3203 if ( array_key_exists('blogid', $_REQUEST) )
3205 $blogid = intRequestVar('blogid');
3207 else if ( array_key_exists('itemid', $_REQUEST) )
3209 $itemid = intRequestVar('itemid');
3210 $item = &$manager->getItem($itemid, 1, 1);
3211 $blogid = (integer) $item['blogid'];
3213 $blog =& $manager->getBlog($blogid);
3215 $query .= " AND iblog={$blogid}";
3216 $template['now'] = $blog->getCorrectTime(time());
3218 // non-blog-admins can only edit/delete their own items
3219 if ( !$member->blogAdminRights($blogid) )
3221 $query .= ' AND iauthor = ' . $member->getID();
3224 elseif ( $this->skintype == 'browseownitems' )
3226 $query .= ' AND iauthor = ' . $member->getID();
3228 $template['now'] = time();
3231 // search through items
3232 $search = postVar('search');
3234 if ( !empty($search) )
3236 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3237 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3238 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3241 if ( postVar('start') )
3243 $start = intPostVar('start');
3250 // amount of items to show
3251 if ( postVar('amount') )
3253 $amount = intPostVar('amount');
3257 $amount = (integer) $CONF['DefaultListSize'];
3264 $query .= ' ORDER BY itime DESC'
3265 . " LIMIT {$start},{$amount}";
3267 $resource = DB::getResult($query);
3268 if ( $resource->rowCount() > 0 )
3270 $template['action'] = $this->skintype;
3271 $template['start'] = $start;
3272 $template['amount'] = $amount;
3273 $template['minamount'] = 0;
3274 $template['maxamount'] = 1000;
3275 $template['blogid'] = $blogid;
3276 $template['search'] = $search;
3277 $template['itemid'] = 0;
3279 $template['content'] = 'itemlist';
3281 $this->parser->parse(listplug_navlist('item', $query, 'table', $template));
3285 /* TODO: nothing to be shown */
3287 $resource->closeCursor();
3293 * AdminActions::parse_itemtime()
3294 * date change on edit item
3296 * @param string $key key of PHP's getDate()
3299 public function parse_itemtime($key)
3304 $itemid = intRequestVar('itemid');
3305 $item =& $manager->getItem($itemid, 1, 1);
3309 $blog =& $manager->getBlog($item['blogid']);
3311 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3313 $item['body'] = removeBreaks($item['body']);
3314 $item['more'] = removeBreaks($item['more']);
3318 $contents = array();
3319 if ( requestVar('action') == 'itemedit' )
3323 elseif ( requestVar('action') == 'createitem' )
3326 'contents' => &$contents,
3327 'blog' => &$this->blog
3329 $manager->notify('PreAddItemForm', $data);
3331 $itemtime = getdate($contents['timestamp']);
3332 echo $itemtime[$key];
3337 * AdminActions::parse_jstoolbaroptions()
3338 * Parse skinvar jstoolbaroptions
3343 public function parse_jstoolbaroptions()
3347 _SETTINGS_JSTOOLBAR_NONE,
3348 _SETTINGS_JSTOOLBAR_SIMPLE,
3349 _SETTINGS_JSTOOLBAR_FULL
3353 foreach ( $options as $option )
3355 $text = "<option value=\"%d\"%s>%s</option>\n";
3356 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3357 echo sprintf($text, $i, $extra, $option);
3363 * AdminActions::parse_localeselectoptions()
3364 * Parse skinvar localeselectoptions
3369 public function parse_localeselectoptions()
3373 $locales = i18n::get_available_locale_list();
3375 $memid = intRequestVar('memberid');
3378 $mem =& $manager->getMember($memid);
3379 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3381 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3385 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3390 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3392 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3396 echo "<option value=\"\">en_Latn_US</option>\n";
3399 foreach ( $locales as $locale )
3401 if ( $locale == 'en_Latn_US' )
3407 if ( $locale == $mem->getLocale() )
3409 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3413 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3418 if ( $locale == i18n::get_current_locale() )
3420 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3424 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3432 * AdminActions::parse_listplugplugoptionrow()
3433 * Parse templatevar listplugplugoptionrow
3435 * @param string $template_name name of template
3438 public function parse_listplugplugoptionrow($template_name = '')
3440 echo listplug_plugOptionRow(Admin::getAdminaOption(), $template_name);
3445 * AdminActions::parse_mediadirwarning()
3446 * Parse skinvar mediadirwarning
3451 public function parse_mediadirwarning()
3454 if ( !is_dir($DIR_MEDIA) )
3456 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3458 if ( !is_readable($DIR_MEDIA) )
3460 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3462 if ( !is_writeable($DIR_MEDIA) )
3464 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3470 * AdminActions::parse_movedistselect()
3471 * Parse skinvar movedistselect
3473 public function parse_movedistselect()
3475 $actionType = requestVar('action');
3476 switch ( $actionType )
3479 $this->selectBlog('destcatid', 'category');
3481 case 'batchcategory':
3482 $this->selectBlog('destblogid');
3485 if ( $this->skintype == 'itemmove' )
3487 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3488 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3489 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3490 $this->selectBlog('catid', 'category', $catid, 10, 1);
3498 * AdminActions::parse_moveitemid()
3499 * Parse skinvar moveitemid
3504 public function parse_moveitemid()
3506 echo intRequestVar('itemid');
3511 * AdminActions::parse_newestcompare()
3512 * Parse skinvar newestcompare
3517 public function parse_newestcompare()
3521 $newestVersion = getLatestVersion();
3522 $newestCompare = str_replace('/', '.', $newestVersion);
3523 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3525 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3527 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3528 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3534 * AdminActions::parse_newmemberselect()
3535 * Parse skinvar newmemberselect
3537 * @param string $template_name name of template to use
3540 public function parse_newmemberselect($template_name = '')
3542 $blogid = intRequestVar('blogid');
3544 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3545 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3546 $res = DB::getResult($query);
3549 foreach ( $res as $row )
3551 $tmem[] = intval($row['tmember']);
3554 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3555 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3558 'name' => 'memberid',
3559 'tabindex' => 10000,
3562 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3567 * AdminActions::parse_newpluginlist()
3568 * Parse skinvar newpluginlist
3573 public function parse_newpluginlist()
3575 $candidates = $this->newPlugCandidates;
3576 foreach ( $candidates as $name )
3578 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3584 * AdminActions::parse_outputspecialdirs()
3585 * Parse skinvar outputspecialdirs
3587 * @param string $type type of setting for directory
3590 public function parse_outputspecialdirs($type)
3592 global $DIR_MEDIA, $DIR_NUCLEUS;
3597 echo Entity::hsc($DIR_NUCLEUS);
3600 echo Entity::hsc($DIR_MEDIA);
3607 * AdminActions::parse_passrequestvars()
3608 * Parse skinvar passrequestvars
3613 public function parse_passrequestvars()
3615 $passvar = Admin::getAdminpassvar();
3616 $oldaction = postVar('oldaction');
3618 if ( ($oldaction != 'logout')
3619 && ($oldaction != 'login')
3621 && !postVar('customaction') )
3629 * AdminActions::parse_pluginextras()
3630 * Parse skinvar pluginextras
3632 * @param string $type type of plugin context
3635 public function parse_pluginextras($type = 'global')
3642 $id = intRequestVar('memberid');
3643 $mem =& $manager->getMember($id);
3644 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
3647 $id = intRequestVar('blogid');
3648 $blg =& $manager->getBlog($id);
3649 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
3651 case 'createaccount':
3653 'type' => 'createaccount.php',
3655 'postlabel' => '<br />',
3657 'postfield' => '<br /><br />'
3659 $manager->notify('RegistrationFormExtraFields', $data);
3662 $manager->notify('GeneralSettingsFormExtras', array());
3669 * AdminActions::parse_pluginhelp()
3670 * Parse skinvar pluginhelp
3675 public function parse_pluginhelp()
3677 global $manager, $DIR_PLUGINS;
3679 $plugid = intGetVar('plugid');
3680 $plugName = $manager->getPluginNameFromPid($plugid);
3681 $plug =& $manager->getPlugin($plugName);
3683 if ( $plug->supportsFeature('HelpPage') > 0 )
3685 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3686 if ( @file_exists($helpfile . 'php') )
3688 @include($helpfile . 'php');
3691 elseif ( @file_exists($helpfile . 'html') )
3693 @include($helpfile . 'html');
3697 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3698 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3703 * AdminActions::parse_pluginlistlist()
3704 * Parse skinvar pluginlistlist
3706 * @param string $template_name name of template to use
3709 public function parse_pluginlistlist($template_name = '')
3711 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3712 $query = sprintf($query, sql_table('plugin'));
3714 $template['content'] = 'pluginlist';
3715 $template['tabindex'] = 10;
3717 $this->parser->parse(showlist($query, 'table', $template, $template_name));
3723 * AdminActions::parse_pluginoptions()
3724 * Parse skinvar pluginoptions
3726 * @param string $type type of plugin option
3729 public function parse_pluginoptions($context='global', $template_name='')
3731 global $itemid, $manager;
3736 $contextid = intRequestVar('memberid');
3739 $contextid = intRequestVar('blogid');
3742 $contextid = intRequestVar('catid');
3745 $contextid = $itemid;
3749 /* Actually registererd plugin options */
3750 $aIdToValue = array();
3751 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
3752 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
3753 $res = DB::getResult($query);
3754 foreach ( $res as $row )
3756 $aIdToValue[$row['oid']] = $row['ovalue'];
3759 /* Currently available plugin options */
3760 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
3761 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
3762 $res = DB::getResult($query);
3765 foreach ($res as $row )
3767 if ( !array_key_exists($row['oid'], $aIdToValue) )
3769 $value = $row['odef'];
3773 $value = $aIdToValue[$row['oid']];
3777 'pid' => $row['pid'],
3778 'pfile' => $row['pfile'],
3779 'oid' => $row['oid'],
3781 'name' => $row['oname'],
3782 'description' => $row['odesc'],
3783 'type' => $row['otype'],
3784 'typeinfo' => $row['oextra'],
3785 'contextid' => $contextid,
3791 'context' => $context,
3792 'contextid' => $contextid,
3793 'options' => &$options
3795 $manager->notify('PrePluginOptionsEdit', $data);
3797 $template = array();
3798 if ( $template_name )
3800 $templates =& $manager->getTemplate($template_name);
3801 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3803 $template['title'] = "<tr>"
3804 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3809 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3812 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3814 $template['body'] = "<tr>"
3815 . "<%listplugplugoptionrow%>"
3820 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3826 foreach ( $options as $option )
3829 if ( $prevPid != $option['pid'] )
3831 $prevPid = $option['pid'];
3832 $this->parser->parse($template['title']);
3835 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3837 if ( @$meta['access'] != 'hidden' )
3839 $parsed = $this->parser->parse($template['body']);
3847 * AdminActions::parse_qmenuaddselect()
3848 * Parse skinvar qmanuaddselect
3850 * @param string $template_name name of template to use
3853 public function parse_qmenuaddselect($template_name = '')
3855 global $member, $blogid;
3856 $showAll = requestVar('showall');
3857 if ( $member->isAdmin() && ($showAll == 'yes') )
3859 // Super-Admins have access to all blogs! (no add item support though)
3860 $query = 'SELECT bnumber as value, bname as text FROM %s ORDER BY bname;';
3861 $query = sprintf($query, sql_table('blog'));
3865 $query = 'SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;';
3866 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3869 $template['name'] = 'blogid';
3870 $template['tabindex'] = 15000;
3871 $template['extra'] = _QMENU_ADD_SELECT;
3872 $template['selected'] = 0;
3873 $template['shorten'] = 10;
3874 $template['shortenel'] = '';
3875 $template['javascript'] = 'onchange="return form.submit()"';
3877 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3883 * AdminActions::parse_quickmenu()
3884 * Parse skinvar quickmenu
3886 * @param string $template_name name of template to use
3889 public function parse_quickmenu($template_name = '')
3892 $templates = array();
3894 if ( !empty($template_name) )
3896 $templates = & $manager->getTemplate($template_name);
3898 $pluginExtras = array();
3899 $manager->notify('QuickMenu', array('options' => &$pluginExtras));
3901 $template = array();
3902 if ( count($pluginExtras) > 0 )
3904 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3906 $template['head'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n"
3911 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3914 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
3916 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
3920 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3923 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3925 $template['foot'] = "</ul>\n";
3929 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3932 $this->parser->parse($template['head']);
3933 foreach ( $pluginExtras as $aInfo )
3936 'plugadminurl' => Entity::hsc($aInfo['url']),
3937 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
3938 'plugadmintitle' => Entity::hsc($aInfo['title']),
3940 $this->parser->parse(Template::fill($template['body'], $data));
3942 $this->parser->parse($template['foot']);
3948 * AdminActions::parse_requestblogid()
3949 * Parse skinvar requestblogid
3954 public function parse_requestblogid()
3956 echo intRequestVar('blogid');
3961 * AdminActions::parse_requestiprange()
3962 * Parse skinvar requestiprange
3967 public function parse_requestiprange()
3969 if ( requestVar('iprange') )
3971 echo Entity::hsc(requestVar('iprange'));
3973 elseif ( requestVar('ip') )
3975 echo Entity::hsc(requestVar('ip'));
3981 * AdminActions::parse_selectlocalskinfiles()
3982 * Parse skinvar selectlocalskinfiles
3987 public function parse_selectlocalskinfiles()
3991 if ( !class_exists('SkinImport', FALSE) )
3993 include_libs('skinie.php');
3996 if ( !preg_match('#^admin#', $this->skintype) && $this->skintype != 'importAdmin' )
3998 $skindir = $DIR_SKINS;
4002 $skindir = "{$DIR_SKINS}admin/";
4005 $candidates = SkinImport::searchForCandidates($skindir);
4006 foreach ( $candidates as $skinname => $skinfile )
4008 $skinfile = Entity::hsc($skinfile);
4009 $skinname = Entity::hsc($skinname);
4010 echo "<option value=\"{$skinfile}\">{$skinname}</option>\n";
4017 * AdminActions::parse_skineditallowedlist()
4018 * Parse skinvar skineditallowedlist
4020 * @param string $type type of skin
4021 * @param string $template_name name of template
4024 public function parse_skineditallowedlist($type, $template_name = '')
4029 $query = "SELECT bshortname, bname FROM %s;";
4031 'content' => 'shortblognames'
4033 $query = sprintf($query, sql_table('blog'));
4036 if ( !preg_match('#^admin#', $this->skintype) )
4038 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4042 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%';";
4045 'content' => 'shortnames'
4047 $query = sprintf($query, sql_table('template_desc'));
4051 $this->parser->parse(showlist($query, 'table', $show, $template_name));
4056 * AdminActions::parse_skinielist()
4057 * Parse skinvar skinielist
4059 * @param string $type type of skin
4060 * @param string $template_name name of template to use
4063 public function parse_skinielist($type, $template_name = '')
4067 $templates = array();
4068 if ( $template_name )
4070 $templates =& $manager->getTemplate($template_name);
4072 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
4075 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4076 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4078 . "<td><%expdesc%></td>\n"
4084 $template = $templates['SKINIE_EXPORT_LIST'];
4090 if ( !preg_match('#^admin#', $this->skintype) )
4092 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4096 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname LIKE 'admin/%%';");
4098 foreach ( $res as $row )
4101 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4102 'expid' => 'skinexp' . $row['sdnumber'],
4103 'expname' => Entity::hsc($row['sdname']),
4104 'expdesc' => Entity::hsc($row['sddesc'])
4106 echo Template::fill($template, $data);
4110 if ( !preg_match('#^admin#', $this->skintype) )
4112 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4116 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname LIKE 'admin/%%';");
4118 foreach ( $res as $row )
4121 'typeid' => 'template[' . $row['tdnumber'] . ']',
4122 'expid' => 'templateexp' . $row['tdnumber'],
4123 'expname' => Entity::hsc($row['tdname']),
4124 'expdesc' => Entity::hsc($row['tddesc'])
4126 echo Template::fill($template, $data);
4134 * AdminActions::parse_skinoverview()
4135 * Parse skinvar skinoverview
4137 * @param string $template_name name of template to use
4140 public function parse_skinoverview($template_name = '')
4144 $template = array();
4145 if ( !preg_match('#^admin#', $this->skintype) )
4147 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%' ORDER BY sdname;";
4148 $template['editaction'] = 'skinedit';
4149 $template['cloneaction'] = 'skinclone';
4150 $template['deleteaction'] = 'skindelete';
4151 $template['edittypeaction'] = 'skinedittype';
4152 $template['default'] = $CONF['BaseSkin'];
4156 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
4157 $template['editaction'] = 'adminskinedit';
4158 $template['cloneaction'] = 'adminskinclone';
4159 $template['deleteaction'] = 'adminskindelete';
4160 $template['edittypeaction'] = 'adminskinedittype';
4161 $template['default'] = $CONF['AdminSkin'];
4163 $query = sprintf($query, sql_table('skin_desc'));
4165 $template['tabindex'] = 10;
4166 $template['content'] = 'skinlist';
4168 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4174 * AdminActions::parse_skintypehelp()
4175 * Check editing skintypehelp
4180 public function parse_skintypehelp()
4182 $nowSkinType = strtolower(trim(requestVar('type')));
4183 $pageAction = strtolower(trim(requestVar('action')));
4184 if ( preg_match('/^admin.*/', $pageAction) )
4186 $regularType = self::$default_skin_types;
4187 unset($regularType['memberedit']);
4188 unset($regularType['login']);
4189 $regularType = array_keys($regularType);
4193 /* TODO: use Skin class */
4194 $regularType = array(
4206 if ( in_array($nowSkinType, $regularType) )
4208 help('skinpart' . $nowSkinType);
4212 help('skinpartspecial');
4218 * AdminActions::parse_specialskinlist()
4219 * Parse skinvar specialskinlist
4221 * @param string $template_name name of template to use
4224 public function parse_specialskinlist($template_name = '')
4226 global $CONF, $manager;
4228 $template = array();
4230 $skinid = intRequestVar('skinid');
4232 if ( !preg_match('#^admin#', $this->skintype) )
4234 $skin =& $manager->getSkin($skinid);
4235 $template['editaction'] = 'skinedittype';
4236 $template['removeaction'] = 'skinremovetype';
4240 $skin =& $manager->getSkin($skinid, 'AdminActions');
4241 $template['editaction'] = 'adminskinedittype';
4242 $template['removeaction'] = 'adminskinremovetype';
4244 $normal_types = $skin->getDefaultTypes();
4245 $available_types = $skin->getAvailableTypes();
4247 $special_skintypes = array();
4248 foreach( $available_types as $skintype => $skinname )
4250 if ( !array_key_exists($skintype, $normal_types) )
4252 $special_skintypes[] = array(
4253 'skintype' => $skintype,
4254 'skintypename' => $skinname
4259 if ( sizeof($special_skintypes) > 0 )
4261 $template['tabindex'] = 75;
4262 $template['skinid'] = $skin->getID();
4263 $template['skinname'] = $skin->getName();
4264 $this->parser->parse(showlist($special_skintypes, 'list_specialskinlist', $template, $template_name));
4268 /* TODO: nothing to be shown */
4275 * AdminActions::parse_sprinttext()
4278 * @param string $which
4279 * @param string $val
4282 public function parse_sprinttext($which, $val)
4284 if ( !defined($which) )
4290 $base = constant($which);
4293 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4295 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4297 $met = 'parse_' . $matchies[0];
4301 $arg = trim($args[0], '()');
4302 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4305 if ( method_exists($this, $met) )
4307 $value = call_user_func(array(&$this, $met), $arg);
4311 if ( !isset($value) || empty($value) )
4315 echo sprintf($base, $value);
4320 * AdminActions::parse_systemsettings()
4321 * Parse skinvar systemsettings
4323 * @param string $type type of settings for system
4324 * @param string $template_name name of template to use
4327 public function parse_systemsettings($type = 'phpinfo', $template_name = '')
4329 global $manager, $member, $CONF, $nucleus;
4331 $member->isAdmin() or Admin::disallow();
4333 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4334 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4341 case 'sqlserverinfo':
4342 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4344 case 'sqlclientinfo':
4345 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4347 case 'magicquotesgpc':
4348 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4350 case 'magicquotesruntime':
4351 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4353 case 'registerglobals':
4354 echo ini_get('register_globals') ? 'On' : 'Off';
4357 $templates = array();
4358 if ( $template_name )
4360 $templates =& $manager->getTemplate($template_name);
4362 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4364 $template = "<tr>\n"
4365 . "<td><%key%></td>\n"
4366 . "<td><%value%></td>\n"
4371 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4374 $gdinfo = gd_info();
4376 foreach ( $gdinfo as $key => $value )
4378 if ( is_bool($value) )
4380 $value = $value ? $enable : $disable;
4384 $value = Entity::hsc($value);
4390 echo Template::fill($template, $data);
4395 phpinfo(INFO_MODULES);
4396 $im = ob_get_contents();
4398 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4400 case 'nucleusversion':
4401 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4403 case 'nucleuspatchlevel':
4404 echo getNucleusPatchLevel();
4410 echo $CONF['ItemURL'];
4412 case 'alertonheaderssent':
4413 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4415 case 'nucleuscodename':
4416 if ( $nucleus['codename'] != '' )
4418 echo ' "' . $nucleus['codename'] . '"';
4421 case 'versioncheckurl':
4422 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4429 * AdminActions::parse_templateoverview()
4430 * Parse skinvar templateoverview
4432 * @param string $template_name name of template to use
4435 public function parse_templateoverview($template_name = '')
4437 if ( !preg_match('#^admin#', $this->skintype) )
4439 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname;";
4440 $template['deleteaction'] = 'templatedelete';
4441 $template['editaction'] = 'templateedit';
4442 $template['cloneaction'] = 'templateclone';
4446 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
4447 $template['deleteaction'] = 'admintemplatedelete';
4448 $template['editaction'] = 'admintemplateedit';
4449 $template['cloneaction'] = 'admintemplateclone';
4451 $query = sprintf($query, sql_table('template_desc'));
4453 $template['tabindex'] = 10;
4454 $template['content'] = 'templatelist';
4456 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4462 * AdminActions::parse_ticket()
4468 public function parse_ticket()
4471 $manager->addTicketHidden();
4476 * AdminActions::parse_versioncheckurl()
4477 * Parse skinvar versioncheckurl
4482 public function parse_versioncheckurl()
4484 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4489 * AdminActions::parse_yrbloglist()
4490 * Parse skinvar yrbloglist
4492 * @param string $template_name name of template to use
4495 public function parse_yrbloglist($template_name = '')
4498 $showAll = requestVar('showall');
4500 if ( $member->isAdmin() && ($showAll == 'yes') )
4502 // Super-Admins have access to all blogs! (no add item support though)
4503 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4505 . " ORDER BY bnumber;";
4506 $query = sprintf($query, sql_table('blog'));
4510 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4512 . " WHERE tblog=bnumber and tmember=%d"
4513 . " ORDER BY bnumber;";
4514 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4517 $resource = DB::getResult($query);
4518 if ( ($showAll != 'yes') && $member->isAdmin() )
4520 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4521 $total = DB::getValue($query);
4523 if ( $total > $resource->rowCount() )
4525 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4529 if ( $resource->rowCount() > 0 )
4531 $template['content'] = 'bloglist';
4532 $template['superadmin'] = $member->isAdmin();
4534 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4535 $resource->closeCursor();
4537 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4539 $query = 'SELECT ititle, inumber, bshortname FROM %s, %s '
4540 . 'WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4541 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4543 $resource = DB::getResult($query);
4544 if ( $resource->rowCount() > 0 )
4546 $template['content'] = 'draftlist';
4547 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4551 echo _OVERVIEW_NODRAFTS;
4556 echo _OVERVIEW_NOBLOGS;
4558 $resource->closeCursor();
4564 * AdminActions::checkCondition()
4565 * Checks conditions for if statements
4567 * @param string $field type of <%if%>
4568 * @param string $name property of field
4569 * @param string $value value of property
4570 * @return boolean condition
4572 protected function checkCondition($field, $name='', $value = '')
4574 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4584 $blog =& $manager->getBlog($blogid);
4588 $blogid = getBlogIDFromCatID($catid);
4589 $blog =& $manager->getBlog($blogid);
4591 elseif ( intRequestVar('catid') )
4593 $catid = intRequestVar('catid');
4594 $blogid = getBlogIDFromCatID($catid);
4595 $blog =& $manager->getBlog($blogid);
4602 $condition = ($blog && $this->ifCategory($name, $value));
4605 $condition = $member->isLoggedIn();
4608 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4611 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4614 $condition = $member->isLoggedIn() && $member->isAdmin();
4616 case 'allowloginedit':
4617 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4620 $condition = ($itemidnext != '');
4623 $condition = ($itemidprev != '');
4625 case 'archiveprevexists':
4626 $condition = ($archiveprevexists == true);
4628 case 'archivenextexists':
4629 $condition = ($archivenextexists == true);
4632 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4635 $condition = $this->ifHasPlugin($name, $value);
4638 $condition = (Admin::getAdminAction() == $name);
4640 case 'adminoldaction':
4641 $condition = (Admin::getAdminAction() == $name);
4643 case 'addresschange':
4644 $condition = ($this->ifAddresscange());
4646 case 'bechangepass':
4647 $condition = ($this->beChangePassword());
4649 case 'skincandidates':
4650 $condition = ($this->ifSkincandidates());
4653 $condition = requestVar('nameclashes');
4655 case 'existsnewplugin':
4656 $condition = ($this->existsNewPlugin());
4663 $condition = (boolean) ($member->getAutosave() == $value);
4670 $condition = (Admin::$blog->getSetting($name) == $value);
4672 case 'itemproperty':
4677 if ( array_key_exists($name, Admin::$contents) )
4679 $condition = (boolean) (Admin::$contents[$name] == $value);
4683 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4690 * AdminActions::_ifHasPlugin()
4691 * hasplugin,PlugName
4692 * -> checks if plugin exists
4693 * hasplugin,PlugName,OptionName
4694 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
4695 * hasplugin,PlugName,OptionName=value
4696 * -> checks if the option OptionName from plugin PlugName is set to value
4698 * @param string $name name of plugin
4699 * @param string $value
4702 private function ifHasPlugin($name, $value)
4706 // (pluginInstalled method won't write a message in the actionlog on failure)
4707 if ( $manager->pluginInstalled("NP_{$name}") )
4709 $plugin =& $manager->getPlugin("NP_{$name}");
4710 if ( $plugin != NULL )
4718 list($name2, $value2) = preg_split('#=#', $value, 2);
4719 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4723 else if ( $plugin->getOption($name2) == $value2 )
4734 * AdminActions::beChangePassword()
4739 private function beChangePassword()
4741 return intRequestVar('bNeedsPasswordChange');
4745 * AdminActions::ifSkincandidates()
4746 * Checks if a plugin exists and call its doIf function
4752 private function ifSkincandidates()
4755 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4756 return (count($candidates) > 0);
4760 * AdminActions::ifPlugin()
4761 * Checks if a plugin exists and call its doIf function
4763 * @param string $name name of plugin
4764 * @param string $key
4765 * @param string $value
4768 private function ifPlugin($name, $key = '', $value = '')
4772 $plugin =& $manager->getPlugin("NP_{$name}");
4778 $params = func_get_args();
4779 array_shift($params);
4781 return call_user_func_array(array(&$plugin, 'doIf'), $params);
4785 * AdminActions::ifCategory()
4786 * Different checks for a category
4788 * @param string $key key for information of category
4789 * @param string $value value for information of category
4792 private function ifCategory($key = '', $value='')
4794 global $blog, $catid;
4796 // when no parameter is defined, just check if a category is selected
4797 if (($key != 'catname' && $key != 'catid') || ($value == ''))
4799 return $blog->isValidCategory($catid);
4802 // check category name
4803 if ( $key == 'catname' )
4805 $value = $blog->getCategoryIdFromName($value);
4806 if ($value == $catid)
4808 return $blog->isValidCategory($catid);
4812 // check category id
4813 if (($key == 'catid') && ($value == $catid))
4815 return $blog->isValidCategory($catid);
4822 * AdminActions::ifOnTeam()
4823 * Checks if a member is on the team of a blog and return his rights
4825 * @param string $blogName name of weblog
4828 private function ifOnTeam($blogName = '')
4830 global $blog, $member, $manager;
4832 // when no blog found
4833 if ( ($blogName == '') && !is_object($blog) )
4838 // explicit blog selection
4839 if ($blogName != '')
4841 $blogid = getBlogIDFromName($blogName);
4844 if (($blogName == '') || !$manager->existsBlogID($blogid))
4847 $blogid = $blog->getID();
4849 return $member->teamRights($blogid);
4853 * AdminActions::ifAdmin()
4854 * Checks if a member is admin of a blog
4856 * @param string $blogName name of weblog
4859 private function ifAdmin($blogName = '')
4861 global $blog, $member, $manager;
4863 // when no blog found
4864 if (($blogName == '') && (!is_object($blog)))
4869 // explicit blog selection
4870 if ($blogName != '')
4872 $blogid = getBlogIDFromName($blogName);
4875 if (($blogName == '') || !$manager->existsBlogID($blogid))
4878 $blogid = $blog->getID();
4881 return $member->isBlogAdmin($blogid);
4885 * AdminActions::ifAddresscange()
4886 * Check e-Mail address is changed
4891 private function ifAddresscange()
4895 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4900 $info = MEMBER::getActivationInfo($key);
4905 $mem =& $manager->getMember($info->vmember);
4910 if ( $info->vtype == 'addresschange' )
4919 * AdminActions::customHelp()
4920 * shows a link to custom help file
4923 * @param string $tplName
4924 * @param string $url
4925 * @param string $iconURL
4926 * @param string $alt
4927 * @param string $title
4931 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4933 echo $this->customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
4938 * AdminActions::customHelp()
4939 * shows a link to custom help file
4942 * @param string $tplName
4943 * @param string $url
4944 * @param string $iconURL
4945 * @param string $alt
4946 * @param string $title
4950 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
4952 global $CONF, $manager;
4954 $templates = array();
4958 $templates =& $manager->getTemplate($tplName);
4961 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
4963 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
4967 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
4972 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
4975 if ( empty($onclick) )
4977 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
4979 elseif ( preg_match('#^onclick#', $onclick) )
4981 $onclick = $onclick;
4985 $onclick = 'onclick="' . $onclick . '"';
4990 'helptarget' => $id,
4991 'onclick' => $onclick,
4992 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
4994 return Template::fill($template, $data);
4999 * AdminActions::customHelpHtml()
5001 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5003 global $CONF, $manager;
5005 $templates = array();
5009 $templates =& $manager->getTemplate($tplName);
5011 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5013 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5017 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5020 if ( empty($iconURL) )
5022 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5025 if ( function_exists('getimagesize') )
5027 $size = getimagesize($iconURL);
5028 $width = 'width="' . $size[0] . '" ';
5029 $height = 'height="' . $size[1] . '" ';
5033 'iconurl' => $iconURL,
5035 'height' => $height,
5036 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5037 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5040 $icon = Template::fill($template, $data);
5041 $help = $this->customHelplink($id, $tplName, $url, $title, $onclick);
5043 return $help . $icon;
5047 * AdminActions::existsNewPlugin()
5048 * Check exists new plugin
5051 * @return boolean exists or not
5053 private function existsNewPlugin()
5055 global $DIR_PLUGINS;
5057 $query = "SELECT * FROM %s;";
5058 $query = sprintf($query, sql_table('plugin'));
5059 $res = DB::getResult($query);
5061 $installed = array();
5062 foreach( $res as $row )
5064 $installed[] = $row['pfile'];
5067 $files = scandir($DIR_PLUGINS);
5069 $candidates = array();
5070 foreach ( $files as $file )
5072 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5074 if ( !in_array($matches[1], $installed) )
5076 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5080 $this->newPlugCandidates = $candidates;
5081 return (count($candidates) > 0);
5085 * AdminActions::pagehead()
5086 * Output admin page head
5091 public function parse_pagehead()
5093 global $member, $nucleus, $CONF, $manager;
5095 $extrahead = Admin::getAdminextrahead();
5097 'extrahead' => &$extrahead,
5098 'action' => Admin::getAdminAction()
5100 $manager->notify('AdminPrePageHead', $data);
5102 $content = $this->parser->skin->getContentFromDB('pagehead');
5105 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5109 if ( !array_key_exists('AdminCSS', $CONF) )
5111 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5112 $CONF['AdminCSS'] = 'original';
5116 /* HTTP 1.1 application for no caching */
5117 header("Cache-Control: no-cache, must-revalidate");
5118 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5120 $root_element = 'html';
5121 $charset = i18n::get_current_charset();
5122 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5123 $xml_version_info = self::$xml_version_info;
5124 $formal_public_identifier = self::$formal_public_identifier;
5125 $system_identifier = self::$system_identifier;
5126 $xhtml_namespace = self::$xhtml_namespace;
5128 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5129 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5130 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5132 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5135 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5137 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5138 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5139 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5140 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5141 echo "{$extrahead}\n";
5144 echo "<div id=\"adminwrapper\">\n";
5145 echo "<div class=\"header\">\n";
5146 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5148 echo "<div id=\"container\">\n";
5149 echo "<div id=\"content\">\n";
5150 echo "<div class=\"loginname\">\n";
5152 if ( !$member->isLoggedIn() )
5154 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5158 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5159 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5162 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5165 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5167 $codenamestring = '';
5171 $codenamestring = ' "' . $nucleus['codename'].'"';
5174 if ( $member->isLoggedIn() && $member->isAdmin() )
5176 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5177 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5179 $newestVersion = getLatestVersion();
5180 $newestCompare = str_replace('/', '.', $newestVersion);
5181 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5183 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5186 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5187 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5193 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5200 $this->parser->parse($content);
5207 * AdminActionss::pagefoot()
5208 * Output admin page foot include quickmenu
5213 public function parse_pagefoot()
5215 global $action, $member, $manager, $blogid;
5218 'action' => Admin::getAdminAction()
5220 $manager->notify('AdminPrePageFoot', $data);
5222 $content = $this->parser->skin->getContentFromDB('pagefoot');
5225 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5227 echo '<h2>' . _LOGOUT . "</h2>\n";
5229 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5230 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5234 echo "<div class=\"foot\">\n";
5235 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5237 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5240 echo "<div id=\"quickmenu\">\n";
5242 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5245 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5248 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5249 echo "<form method=\"get\" action=\"index.php\">\n";
5251 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5253 $showAll = requestVar('showall');
5255 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5257 // Super-Admins have access to all blogs! (no add item support though)
5258 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5259 $query = sprintf($query, sql_table('blog'));
5263 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5264 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5266 $template['name'] = 'blogid';
5267 $template['tabindex'] = 15000;
5268 $template['extra'] = _QMENU_ADD_SELECT;
5269 $template['selected'] = $blogid;
5270 $template['shorten'] = 10;
5271 $template['shortenel'] = '';
5272 $template['javascript'] = 'onchange="return form.submit()"';
5273 $this->parser->parse(showlist($query, 'select', $template));
5278 echo "<h2>{$member->getDisplayName()}</h2>\n";
5280 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5281 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5282 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5285 if ( $member->isAdmin() )
5287 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5289 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5290 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5291 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5292 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5293 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5294 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5295 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5298 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5300 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5301 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5302 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5306 $data = array('options' => array());
5307 $manager->notify('QuickMenu', $data);
5309 if ( count($data['options']) > 0 )
5311 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5313 foreach ( $data['options'] as $option )
5315 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5320 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5323 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5327 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5330 echo "<!-- quickmenu -->\n";
5333 echo "<!-- content -->\n";
5336 echo "<!-- container -->\n";
5339 echo "<!-- adminwrapper -->\n";
5347 $this->parser->parse($content);
5354 * AdminActions::selectBlog()
5355 * Inserts a HTML select element with choices for all blogs to which the user has access
5356 * mode = 'blog' => shows blognames and values are blogids
5357 * mode = 'category' => show category names and values are catids
5359 * @param string $name
5360 * @param string $mode
5361 * @param integer $selected
5362 * @param integer $tabindex
5363 * @param integer $showNewCat
5364 * @param integer $iForcedBlogInclude ID for weblog always included
5365 * @param $iForcedBlogInclude
5366 * ID of a blog that always needs to be included, without checking if the
5367 * member is on the blog team (-1 = none)
5370 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5372 global $member, $CONF;
5374 // 0. get IDs of blogs to which member can post items (+ forced blog)
5375 $aBlogIds = array();
5376 if ( $iForcedBlogInclude != -1 )
5378 $aBlogIds[] = intval($iForcedBlogInclude);
5381 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5383 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5384 $query = sprintf($query, sql_table('blog'));
5388 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5389 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5392 $rblogids = DB::getResult($query);
5393 foreach ( $rblogids as $row )
5395 if ( $row['bnumber'] != $iForcedBlogInclude )
5397 $aBlogIds[] = intval($row['bnumber']);
5401 if ( count($aBlogIds) == 0 )
5406 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5408 // 1. select blogs (we'll create optiongroups)
5409 // (only select those blogs that have the user on the team)
5410 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5411 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5412 $blogs = DB::getResult($queryBlogs);
5414 if ( $mode == 'category' )
5416 if ( $blogs->rowCount() > 1 )
5420 foreach ( $blogs as $rBlog )
5422 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5424 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5427 // show selection to create new category when allowed/wanted
5430 // check if allowed to do so
5431 if ( $member->blogAdminRights($rBlog['bnumber']) )
5433 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5437 // 2. for each category in that blog
5438 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5439 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5440 $categories = DB::getResult($catQuery);
5441 foreach ( $categories as $rCat )
5443 if ( $rCat['catid'] == $selected )
5445 $selectText = ' selected="selected" ';
5451 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5454 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5462 foreach ( $blogs as $rBlog )
5464 echo '<option value="' . $rBlog['bnumber'] . '"';
5465 if ( $rBlog['bnumber'] == $selected )
5467 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5471 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";