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',
475 'defadminskinselect',
476 'defbookmarkletselect',
479 case 'forgotpassword':
480 $extra_actions = array(
481 /* nothing special */
484 case 'itemcommentlist':
485 $extra_actions = array(
491 $extra_actions = array(
498 $extra_actions = array(
510 $extra_actions = array(
517 $extra_actions = array(
523 $extra_actions = array(
524 /* nothing special */
528 $extra_actions = array(
537 $extra_actions = array(
542 $extra_actions = array(
547 $extra_actions = array(
552 $extra_actions = array(
558 $extra_actions = array(
563 case 'pluginoptions':
564 $extra_actions = array(
566 'editplugoptionslist',
570 $extra_actions = array(
573 'configsettingsedit',
574 'configsettingsyesno',
577 'localeselectoptions',
580 'defadminskinselect',
581 'defbookmarkletselect',
585 $extra_actions = array(
590 $extra_actions = array(
595 $extra_actions = array(
602 $extra_actions = array(
605 'allowedskinactions',
606 'skineditallowedlist'
609 case 'skiniedoimport':
610 $extra_actions = array(
615 $extra_actions = array(
619 case 'skinieoverview':
620 $extra_actions = array(
621 'selectlocalskinfiles',
626 $extra_actions = array(
630 case 'skinremovetype':
631 $extra_actions = array(
635 case 'systemoverview':
636 $extra_actions = array(
641 $extra_actions = array(
647 case 'templatedelete':
648 $extra_actions = array(
653 $extra_actions = array(
657 case 'templateoverview':
658 $extra_actions = array(
662 case 'usermanagement':
663 $extra_actions = array(
669 $extra_actions = array(
678 'selectlocalskinfiles',
686 $defined_actions = array_merge(self::$default_actions, $extra_actions);
688 return array_merge($defined_actions, parent::getAvailableActions());
692 * AdminActions::parse_actionloglist()
693 * Parse skinvar actionloglist
695 * @param string $template_name name of template to use
698 public function parse_actionloglist($template_name = '')
700 $query = "SELECT * FROM %s ORDER BY timestamp DESC;";
701 $query = sprintf($query, sql_table('actionlog'));
703 $resource = DB::getResult($query);
704 if ( $resource->rowCount() > 0 )
706 $template['content'] = 'actionlist';
707 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
711 /* TODO: nothing to be shown */
717 * AdminActions::parse_activationmessage()
718 * Parse skinvar activationmessage
720 * @param string $type type of message
721 * @param string $template_name name of template to use
724 public function parse_activationmessage($type, $template_name = '')
726 global $CONF, $manager;
730 if ( !empty($template_name))
732 $template =& $manager->getTemplate($template_name);
735 $key = postVar('ackey');
738 Admin::error(_ERROR_ACTIVATE);
741 $info = MEMBER::getActivationInfo($key);
744 Admin::error(_ERROR_ACTIVATE);
747 $mem =& $manager->getMember($info->vmember);
750 Admin::error(_ERROR_ACTIVATE);
752 switch ( $info->vtype )
755 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
757 $title = $template['ACTIVATE_FORGOT_TITLE'];
761 $title = _ACTIVATE_FORGOT_TITLE;
763 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
765 $text = $template['ACTIVATE_FORGOT_TEXT'];
769 $text = _ACTIVATE_FORGOT_TEXT;
773 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
775 $title = $template['ACTIVATE_REGISTER_TITLE'];
779 $title = _ACTIVATE_REGISTER_TITLE;
781 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
783 $text = $template['ACTIVATE_REGISTER_TEXT'];
787 $text = _ACTIVATE_REGISTER_TEXT;
790 case 'addresschange':
791 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
793 $title = $template['ACTIVATE_CHANGE_TITLE'];
797 $title = _ACTIVATE_CHANGE_TITLE;
799 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
801 $text = $template['ACTIVATE_CHANGE_TEXT'];
805 $text = _ACTIVATE_CHANGE_TEXT;
810 'memberName' => Entity::hsc($mem->getDisplayName()),
811 'realName' => Entity::hsc($mem->getRealName()),
816 echo Template::fill($title, $aVars);
819 echo Template::fill($text, $aVars);
822 echo Entity::hsc($key);
829 * AdminActions::parse_addtickettourl()
830 * Parse skinvar addtickettourl
832 * @param string $url URI for ticket
835 public function parse_addtickettourl($url)
838 $url = $manager->addTicketToUrl($url);
839 echo Entity::hsc($url);
844 * AdminActions::parse_adminbanlist()
845 * Parse skinvar adminbanlist
847 * @param string $template_name name of template to use
850 public function parse_adminbanlist($template_name = '')
852 $blogid = intRequestVar('blogid');
854 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
855 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
857 $resource = DB::getResult($query);
858 if ( $resource->rowCount() > 0 )
860 $template['content'] = 'banlist';
861 $this->parser-parse(showlist($resource, 'table', $template, $template_name));
871 * AdminActions::parse_adminbatchaction()
872 * Parse skinvar adminbatchaction
877 public function parse_adminbatchaction()
879 echo Entity::hsc(requestVar('batchaction'));
884 * AdminActions::parse_adminbatchlist()
885 * Parse skinvar adminbatchlist
887 * @param string $template_name name of template to use
890 public function parse_adminbatchlist($template_name = '')
893 $templates = array();
895 if ( !empty($template_name) )
897 $templates =& $manager->getTemplate($template_name);
900 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
902 $template = '<li><%text(_BATCH_EXECUTING)%> '
903 . '<b><%adminbatchaction%></b> '
904 . '<%batchlisttype%> '
905 . '<b><%batchid%></b>... '
906 . '<b><%batchlistmsg%></b>'
911 $template = $templates['ADMIN_BATCHLIST'];
914 $selected = requestIntArray('batch');
915 $action = requestVar('batchaction');
917 switch ( $this->skintype )
920 $batchlisttype = _BATCH_ONITEM;
921 $deleteaction = 'deleteOneItem';
922 $moveaction = 'moveOneItem';
923 $destid = intRequestVar('destcatid');
926 $batchlisttype = _BATCH_ONCOMMENT;
927 $deleteaction = 'deleteOneComment';
930 $batchlisttype = _BATCH_ONMEMBER;
931 $deleteaction = 'deleteOneMember';
932 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
933 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
934 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
935 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
938 $blogid = intRequestVar('blogid');
939 $batchlisttype = _BATCH_ONTEAM;
940 $deleteaction = 'deleteOneTeamMember';
941 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
942 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
943 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
944 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
946 case 'batchcategory':
947 $batchlisttype = _BATCH_ONCATEGORY;
948 $deleteaction = 'deleteOneCategory';
949 $moveaction = 'moveOneCategory';
950 $destid = intRequestVar('destblogid');
954 // walk over all selectedids and perform action
955 foreach ( $selected as $selectedid )
958 $selectedid = intval($selectedid);
962 if ( $this->skintype != 'batchteam' )
964 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
968 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
972 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
976 DB::execute("UPDATE {$setadminsql} {$selectedid};");
980 // there should always remain at least one super-admin
981 $r = DB::getResult($unsetchksql);
982 if ( $r->rowCount() < 2 )
984 $error = $unseterrmsg;
988 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
992 $error = _BATCH_UNKNOWN . Entity::hsc($action);
996 'batchid' => $selectedid,
997 'batchlisttype' => Entity::hsc($batchlisttype),
998 'adminbatchaction' => Entity::hsc($action),
999 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1002 $this->parser->parse(Template::fill($template, $data));
1009 * AdminActions::parse_adminbloglink()
1010 * Parse skinvar adminbloglink
1012 * @param string $template_name name of template to use
1015 public function parse_adminbloglink($template_name = '')
1018 $blogid = intRequestVar('blogid');
1019 $blog =& $manager->getBlog($blogid);
1020 $templates = array();
1022 if ( !empty($template_name) )
1024 $templates =& $manager->getTemplate($template_name);
1027 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1029 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1033 $template = $templates['ADMIN_BLOGLINK'];
1037 'url' => Entity::hsc($blog->getURL()),
1038 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1039 'blogname' => Entity::hsc($blog->getName())
1042 echo Template::fill($template, $data);
1047 * AdminActions::parse_adminerrormesg()
1048 * Parse skinvar adminerrormesg
1053 public function parse_adminerrormesg()
1058 if ( requestVar('errormessage') )
1060 $message = requestVar('errormessage');
1062 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1064 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1066 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1068 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1070 echo Entity::hsc($message);
1075 * AdminActions::parse_allowedskinactions()
1076 * Parse skinvar allowedskinactions
1081 public function parse_allowedskinactions()
1085 $type = strtolower(trim(requestVar('type')));
1086 $skinid = intRequestVar('skinid');
1088 if ( !preg_match('#^admin#', $this->skintype) )
1090 $skin =& $manager->getSkin($skinid);
1095 $skin =& $manager->getSkin($skinid, 'AdminActions');
1096 $tag = 'adminskinvar';
1099 $actions = $skin->getAllowedActionsForType($type);
1102 while ( $current = array_shift($actions) )
1104 echo helplink("{$tag}-{$current}") . "$current</a>\n";
1106 if ( count($actions) != 0 )
1115 * AdminActions::parse_banlistdeletedlist()
1116 * Parse skinvar banlistdeletedlist
1118 * @param string $template_name name of template to use
1121 public function parse_banlistdeletedlist($template_name = '')
1125 $templates = array();
1126 if ( $template_name )
1128 $templates =& $manager->getTemplate($template_name);
1131 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1133 $template = "<li><%blogname%></li>\n";
1137 $template = $templates['BANLIST_DELETED_LIST'];
1140 $deleted = requestArray('delblogs');
1141 foreach ( $deleted as $delblog )
1143 $blog =& $manager->getBlog($delblog);
1145 'blogname' => Entity::hsc($blog->getName())
1147 echo Template::fill($template, $data);
1154 * AdminActions::parse_batchdeletelist()
1155 * Parse skinvar batchdeletelist
1160 public function parse_batchdeletelist()
1162 $selected = requestIntArray('batch');
1165 foreach ( $selected as $select )
1167 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1169 // add hidden vars for team & comment
1170 if ( requestVar('action') == 'batchteam' )
1172 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1174 if ( requestVar('action') == 'batchcomment' )
1176 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1182 * AdminActions::parse_defadminskinselect()
1183 * Parse skinvar defadminskinselect
1185 * @param string $template_name name of template to use
1188 public function parse_defadminskinselect($template_name)
1190 global $CONF, $action;
1192 if ( $action == 'editmembersettings' )
1195 $default = $member->adminskin;
1197 elseif ( $action == 'memberedit' )
1200 $mem = $manager->getMember(intRequestVar('memberid'));
1201 $default = $mem->adminskin;
1205 $default = $CONF['AdminSkin'];
1208 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1209 $query = sprintf($query, sql_table('skin_desc'));
1211 'name' => 'adminskin',
1212 'tabindex' => 10080,
1213 'selected' => $default
1216 if ( $this->skintype != 'settingsedit' )
1218 $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1221 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1226 * AdminActions::parse_defbookmarkletselect()
1227 * Parse skinvar defbookmarkletselect
1229 * @param string $template_name name of template to use
1232 public function parse_defbookmarkletselect($template_name)
1234 global $CONF, $action;
1236 if ( $action == 'editmembersettings' )
1239 $default = $member->bookmarklet;
1241 elseif ( $action == 'memberedit' )
1244 $mem = $manager->getMember(intRequestVar('memberid'));
1245 $default = $mem->bookmarklet;
1249 $default = $CONF['BookmarkletSkin'];
1252 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1253 $query = sprintf($query, sql_table('skin_desc'));
1256 'name' => 'bookmarklet',
1257 'tabindex' => 10085,
1258 'selected' => $default
1261 if ( $this->skintype != 'settingsedit' )
1263 $template['extra'] = Entity::hsc(_MEMBERS_USESITELANG);
1266 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1271 * AdminActions::parse_batchdeletetype()
1272 * Parse skinvar batchdeletetype
1277 public function parse_batchdeletetype()
1279 echo Entity::hsc(requestVar('action'));
1284 * AdminActions::parse_batchmovebtn()
1285 * Parse skinvar batchmovebtn
1290 public function parse_batchmovebtn()
1292 $actionType = requestVar('action');
1293 switch ( $actionType )
1298 case 'batchcategory':
1306 * AdminActions::parse_batchmovelist()
1307 * Parse skinvar batchmovelist
1312 public function parse_batchmovelist()
1314 $selected = requestIntArray('batch');
1316 foreach ( $selected as $select )
1318 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1325 * AdminActions::parse_batchmovetitle()
1326 * Parse skinvar batchmovetitle
1331 public function parse_batchmovetitle()
1333 $actionType = requestVar('action');
1334 switch ( $actionType )
1339 case 'batchcategory':
1340 echo _MOVECAT_TITLE;
1347 * AdminActions::parse_batchmovetype()
1348 * Parse skinvar batchmovetype
1353 public function parse_batchmovetype()
1355 echo Entity::hsc(requestVar('action'));
1360 * AdminActions::parse_blogcatlist()
1361 * Parse skinvar blogcatlist
1366 public function parse_blogcatlist($template_name = '')
1369 $blogid = intRequestVar('blogid');
1370 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1371 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1373 $resource = DB::getResult($query);
1374 if ( $resource->rowCount() > 0 )
1376 $template['content'] = 'categorylist';
1377 $template['tabindex'] = 200;
1378 $this->parser->parse(listplug_batchlist('category', $resource, 'table', $template, $template_name));
1382 /* TODO: nothing to be shown */
1384 $resource->closeCursor();
1390 * AdminActions::parse_blogid()
1391 * Parse skinvar blogid
1396 public function parse_blogid()
1398 echo intRequestVar('blogid');
1403 * AdminActions::parse_blognotifysetting()
1404 * Parse skinvar blognotifysetting
1409 public function parse_blognotifysetting($type)
1412 $blogid = intRequestVar('blogid');
1413 $blog =& $manager->getBlog($blogid);
1418 if ( !$blog->notifyOnComment() )
1424 if ( !$blog->notifyOnVote() )
1430 if ( !$blog->notifyOnNewItem() )
1436 echo ' checked="checked"';
1441 * AdminActions::parse_blogsetting()
1442 * Parse skinvar blogsetting
1444 * @param string $which name of weblog setting
1447 public function parse_blogsetting($which)
1449 echo $this->parse_getblogsetting($which);
1454 * AdminActions::parse_blogsettingyesno()
1455 * Parse skinvar blogsettingyesno
1457 * @param string $type type of weblog setting
1458 * @param string $template_name name of template to use
1461 public function parse_blogsettingyesno($type, $template_name = '')
1465 $blogid = intRequestVar('blogid');
1466 $blog =& $manager->getBlog($blogid);
1470 case 'convertbreaks':
1471 $checkedval = $blog->convertBreaks();
1474 case 'allowpastposting':
1475 $checkedval = $blog->allowPastPosting();
1479 $checkedval = $blog->commentsEnabled();
1483 $checkedval = $blog->isPublic();
1487 $checkedval = $blog->emailRequired();
1491 $checkedval = $blog->getSearchable();
1495 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $template_name);
1500 * AdminActions::parse_blogteamlist()
1501 * Parse skinvar blogteamlist
1503 * @param string $template_name name of template to use
1506 public function parse_blogteamlist($template_name = '')
1509 $blogid = intRequestVar('blogid');
1510 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1512 . "WHERE tmember=mnumber AND tblog= %d";
1513 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1515 $resource = DB::getResult($query);
1516 if ( $resource->rowCount() > 0 )
1518 $template['content'] = 'teamlist';
1519 $template['tabindex'] = 10;
1521 $this->parser->parse(listplug_batchlist('team', $resource, 'table', $template, $template_name));
1527 $resource->closeCursor();
1533 * AdminActions::parse_blogteammembers()
1534 * Parse skinvar blogteammembers
1539 public function parse_blogteammembers()
1541 $blogid = intRequestVar('blogid');
1542 $query = "SELECT mname, mrealname "
1544 . "WHERE mnumber=tmember AND tblog=%d;";
1545 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1546 $res = DB::getResult($query);
1547 $memberNames = array();
1548 foreach ( $res as $row )
1550 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1552 echo implode(',', $memberNames);
1556 * AdminActions::parse_blogtime()
1557 * Parse skinvar blogtime
1559 * @param string $type type of time
1560 * @param string $format format for time expression
1561 * @param integer $offset offset of time
1564 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1568 if ( $type != 'blogtime' )
1570 /* return server time */
1571 $timestamp = time() + $offset;
1575 $bid = intRequestVar('blogid');
1576 $b =& $manager->getBlog($bid);
1577 $timestamp = $b->getCorrectTime() + $offset;
1580 echo i18n::formatted_datetime($format, $timestamp);
1585 * AdminActions::parse_bookmarkletadmin()
1586 * Parse skinvar bookmarkletadmin
1591 public function parse_bookmarkletadmin()
1595 $blogid = intRequestVar('blogid');
1597 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1602 * AdminActions::parse_categories()
1603 * Parse skinvar categories
1605 * create category dropdown box
1607 * @param string $type name of setting for category
1610 public function parse_categories($startidx = 0)
1614 if ( !array_key_exists('catid', Admin::$contents) || empty(Admin::$contents['catid']) )
1616 $catid = Admin::$blog->getDefaultCategory();
1620 $catid = Admin::$contents['catid'];
1623 $this->selectBlog('catid', 'category', $catid, $startidx, 1, Admin::$blog->getID());
1629 * AdminActions::parse_categorysetting()
1630 * Parse skinvar categorysetting
1632 * @param string $type type in category setting
1635 public function parse_categorysetting($type)
1637 $catid = intRequestVar('catid');
1638 if ( $type == 'id' )
1643 $blogid = intRequestVar('blogid');
1644 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1645 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1646 $row = DB::getRow($query);
1648 if ( $type != 'name' )
1650 echo Entity::hsc($row['cdesc']);
1654 echo Entity::hsc($row['cname']);
1661 * AdminActions::parse_codename()
1662 * Parse templatevar codename
1668 public function parse_checkedonval($value, $name)
1673 $itemid = intRequestVar('itemid');
1674 $item =& $manager->getItem($itemid, 1, 1);
1678 $blog =& $manager->getBlog($item['blogid']);
1680 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1682 $item['body'] = removeBreaks($item['body']);
1683 $item['more'] = removeBreaks($item['more']);
1687 $contents = array();
1688 if ( requestVar('action') == 'itemedit' )
1692 if ( !isset($contents[$name]) )
1694 $contents[$name] = '';
1696 if ($contents[$name] == $value)
1698 echo 'checked="checked"';
1704 * AdminActions::parse_codename()
1705 * Parse templatevar codename
1710 * TODO: is this need???
1712 public function parse_codename()
1715 echo $nucleus['codename'];
1720 * AdminActions::parse_commentnavlist()
1721 * Parse skinvar commentnavlist
1726 public function parse_commentnavlist()
1728 global $CONF, $manager, $member;
1731 if ( postVar('start') )
1733 $start = intPostVar('start');
1740 // amount of items to show
1741 if ( postVar('amount') )
1743 $amount = intPostVar('amount');
1747 $amount = (integer) $CONF['DefaultListSize'];
1753 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1755 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
1757 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1759 if ( $this->skintype == 'itemcommentlist' )
1761 $itemid = intRequestVar('itemid');
1762 $query .= " citem={$itemid}";
1763 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1765 $nonComments = _NOCOMMENTS;
1767 elseif ( $this->skintype == 'browseowncomments' )
1770 $query .= ' cmember=' . $member->getID();
1771 $template['canAddBan'] = 0;
1773 $nonComments = _NOCOMMENTS_YOUR;
1775 elseif ( $this->skintype == 'blogcommentlist' )
1778 $query .= ' cblog=' . intRequestVar('blogid');
1779 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1780 $bid = intRequestVar('blogid');
1781 $nonComments = _NOCOMMENTS_BLOG;
1784 $search = postVar('search');
1785 if ( !empty($search) )
1787 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
1790 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1792 $resource = DB::getResult($query);
1793 if ( $resource->rowCount() > 0 )
1795 $template['action'] = $this->skintype;
1796 $template['start'] = $start;
1797 $template['amount'] = $amount;
1798 $template['minamount'] = 0;
1799 $template['maxamount'] = 1000;
1800 $template['blogid'] = $bid;
1801 $template['search'] = $search;
1802 $template['itemid'] = $itemid;
1804 $template['content'] = 'commentlist';
1806 $this->parser->parse(listplug_navlist('comment', $resource, 'table', $template));
1810 /* TODO: nothing to be shown */
1812 $resource->closeCursor();
1818 * AdminActions::parse_configsettingsedit()
1819 * Parse skinvar configsettingsedit
1821 * @param string $type type of global configuration
1824 public function parse_configsettingsedit($type)
1829 case 'DefaultListSize':
1830 if ( !array_key_exists('DefaultListSize', $CONF) )
1832 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1833 $query = sprintf($query, sql_table('config'));
1834 DB::execute($query);
1835 $CONF['DefaultListSize'] = 10;
1837 elseif ( intval($CONF['DefaultListSize']) < 1 )
1839 $CONF['DefaultListSize'] = 10;
1841 echo intval($CONF['DefaultListSize']);
1843 case 'SessionCookie':
1844 $value = $CONF['SessionCookie'];
1845 $txt1 = _SETTINGS_COOKIESESSION;
1846 $txt2 = _SETTINGS_COOKIEMONTH;
1847 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1850 $value = $CONF['URLMode'];
1851 $txt1 = _SETTINGS_URLMODE_NORMAL;
1852 $txt2 = _SETTINGS_URLMODE_PATHINFO;
1853 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1856 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1858 echo Entity::hsc($CONF[$type]);
1866 * AdminActions::parse_configsettingsyesno()
1867 * Parse skinvar configsettingsyesno
1869 * @param string $type type of global setting
1870 * @param integer $tabindex tabindex attribute of input element
1873 public function parse_configsettingsyesno($type, $tabindex)
1876 if ( array_key_exists($type, $CONF) )
1878 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1884 * AdminActions::parse_contents()
1885 * Parse skinvar contents
1887 * @param string $which part for item
1890 public function parse_contents($which)
1892 if ( !array_key_exists($which, Admin::$contents) )
1894 Admin::$contents[$which] = '';
1896 echo Entity::hsc(Admin::$contents[$which]);
1900 * AdminActions::parse_currenttime()
1901 * Parse skinvar currenttime
1903 * @param string $what
1906 public function parse_currenttime($what)
1908 $nu = getdate(Admin::$blog->getCorrectTime());
1913 * AdminActions::parse_customhelplink()
1914 * Parse skinvar customhelplink
1916 * @param string $topic name of topic
1917 * @param string $tplName name of template
1918 * @param string $url string as URI
1919 * @param string $iconURL string as URI for icon
1920 * @param string $alt alternative text for image element
1921 * @param string $title title for anchor element
1924 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1926 $this->customHelp($topic, $url, $iconURL);
1931 * AdminActions::parse_date()
1932 * Parse skinvar date
1934 public function parse_date($format = 'c')
1936 global $CONF, $manager;
1937 /* TODO: offset is based on i18n::get_current_locale()? */
1938 echo i18n::formatted_datetime($format, time());
1943 * AdminActions::parse_normalskinlist()
1944 * Parse skinvar defaultadminskintypes
1946 * @param string $template_name name of template
1949 public function parse_normalskinlist($template_name = '')
1951 global $CONF, $manager;
1953 if ( !preg_match('#^admin#', $this->skintype) )
1955 $skin =& $manager->getSkin($CONF['BaseSkin']);
1956 /* TODO: removeaction? */
1957 $template['editaction'] = 'skinedittype';
1961 $skin =& $manager->getSkin($CONF['AdminSkin'], 'AdminActions');
1962 $template['editaction'] = 'adminskinedittype';
1963 /* TODO: removeaction? */
1966 $temporary = $skin->getDefaultTypes();
1967 $normal_skintype = array();
1968 foreach ( $temporary as $type => $label )
1970 $normal_skintype[] = array(
1971 'skintype' => $type,
1972 'skintypename' => $label
1976 $template['tabindex'] = 10;
1977 $template['skinid'] = $skin->getID();
1978 $template['skinname'] = $skin->getName();
1979 $this->parser->parse(showlist($normal_skintype, 'list_normalskinlist', $template, $template_name));
1985 * AdminActions::parse_defblogselect()
1986 * Parse skinvar defblogselect
1988 * @param string $template_name name of template
1991 public function parse_defblogselect($template_name = '')
1995 $query = "SELECT bname as text, bnumber as value FROM %s;";
1996 $query = sprintf($query, sql_table('blog'));
1998 $template['name'] = 'DefaultBlog';
1999 $template['selected'] = $CONF['DefaultBlog'];
2000 $template['tabindex'] = 10;
2001 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2007 * AdminActions::parse_defcatselect()
2008 * Parse skinvar defcatselect
2010 * @param string $template_name name of template
2013 public function parse_defcatselect($template_name = '')
2017 $blogid = intRequestVar('blogid');
2018 $blog =& $manager->getBlog($blogid);
2020 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2021 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2023 $template['name'] = 'defcat';
2024 $template['selected'] = $blog->getDefaultCategory();
2025 $template['tabindex'] = 110;
2027 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2033 * AdminActions::parse_defskinselect()
2034 * Parse skinvar defskinselect
2036 * @param string $type type of skin
2037 * @param string $template_name name of template
2040 public function parse_defskinselect($type = 'blog', $template_name = '')
2042 global $CONF, $manager, $member;
2044 if ( !preg_match('#^admin#', $this->skintype) )
2046 $blogid = intRequestVar('blogid');
2049 $template['selected'] = $CONF['BaseSkin'];
2053 $blog =& $manager->getBlog($blogid);
2054 $template['selected'] = $blog->getDefaultSkin();
2057 if ( $type != 'blog' )
2059 $template['name'] = 'BaseSkin';
2063 $template['name'] = 'defskin';
2066 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2070 /* TODO: member object will have its own adminskin id */
2071 $template['selected'] = $CONF['AdminSkin'];
2072 $template['name'] = 'AdminSkin';
2073 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
2076 $query = sprintf($query, sql_table('skin_desc'));
2077 $template['tabindex'] = 50;
2079 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2085 * AdminActions::parse_deletecomment()
2086 * Parse skinvar deletecomment
2088 * @param string $type type of infomation for comment
2091 public function parse_deletecomment($type = 'id')
2093 $commentid = intRequestVar('commentid');
2094 $comment = COMMENT::getComment($commentid);
2099 echo intRequestVar('commentid');
2102 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2104 echo $comment['member'];
2108 echo $comment['user'];
2112 $body = strip_tags($comment['body']);
2113 echo Entity::hsc(shorten($body, 300, '...'));
2119 * AdminActions::parse_deleteitembody()
2120 * Parse skinvar deleteitembody
2125 public function parse_deleteitembody()
2129 $itemid = intRequestVar('itemid');
2130 $item =& $manager->getItem($itemid, 1, 1);
2132 $body = strip_tags($item['body']);
2134 echo Entity::hsc(shorten($body, 300, '...'));
2140 * AdminActions::parse_deleteitemid()
2141 * Parse skinvar deleteitemid
2146 public function parse_deleteitemid()
2148 echo (integer) intRequestVar('itemid');
2153 * AdminActions::parse_deleteitemtitle()
2154 * Parse skinvar deleteitemtitle
2159 public function parse_deleteitemtitle()
2163 $itemid = intRequestVar('itemid');
2164 $item =& $manager->getItem($itemid, 1, 1);
2166 echo Entity::hsc(strip_tags($item['title']));
2172 * AdminActions::parse_editcomment()
2173 * Parse skinvar editcomment
2175 * @param string $type type of comment setting
2178 public function parse_editcomment($type = 'id')
2182 $comment = Admin::$contents;
2187 echo intRequestVar('commentid');
2190 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2192 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2196 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2200 echo date("Y-m-d @ H:i", $comment['timestamp']);
2203 $comment['body'] = str_replace('<br />', '', $comment['body']);
2204 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2205 echo $comment['body'];
2208 echo $comment['userid'];
2211 echo $comment['userid'];
2214 if ( array_key_exists($type, $comment) && !empty($comment[$type]) )
2216 echo $comment[$type];
2224 * AdminActions::parse_editdesturl()
2225 * Parse skinvar editdesturl
2227 public function parse_editdesturl()
2229 if ( requestVar('desturl') )
2231 echo Entity::hsc(requestVar('desturl'));
2237 * AdminActions::parse_editmemberlist()
2238 * Parse skinvar editmemberlist
2240 * @param string $template_name name of template
2243 public function parse_editmemberlist($template_name = '')
2246 // show list of members with actions
2247 $query = 'SELECT * FROM %s;';
2248 $query = sprintf($query, sql_table('member'));
2250 $resource = DB::getResult($query);
2251 if ( $resource->rowCount() > 0 )
2253 $template['content'] = 'memberlist';
2254 $template['tabindex'] = 10;
2256 $this->parser->parse(listplug_batchlist('member', $resource, 'table', $template, $template_name));
2262 $resource->closeCursor();
2268 * AdminActions::parse_editmember()
2269 * Parse skinvar editmember
2271 * @param string $type type of information for member
2272 * @return string $tempateName name of template to use
2275 public function parse_editmember($type = 'id', $template_name = '')
2277 global $CONF, $manager, $member;
2279 $memberid = intRequestVar('memberid');
2280 $mem =& $manager->getMember($memberid);
2285 echo intRequestVar('memberid');
2288 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2290 echo Entity::hsc($mem->getDisplayName());
2294 $dispName = Entity::hsc($mem->getDisplayName());
2295 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2297 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2306 echo Entity::hsc($mem->getRealName());
2309 echo Entity::hsc($mem->getEmail());
2312 echo Entity::hsc($mem->getURL());
2315 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $template_name);
2318 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $template_name);
2321 echo Entity::hsc($mem->getNotes());
2324 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $template_name);
2333 * AdminActions::parse_editpluginfo()
2334 * Parse skinvar editpluginfo
2336 * @param string $type type of plugin info
2339 public function parse_editpluginfo($type)
2343 $pid = intRequestVar('plugid');
2350 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2357 * AdminActions::parse_editplugoptionslist()
2358 * Parse skinvar editplugoptionslist
2360 * @param string $template_name name of template
2363 public function parse_editplugoptionslist($template_name = '')
2367 $pid = intRequestVar('plugid');
2368 $aOptions = array();
2371 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2372 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2373 $resource = DB::getResult($query);
2375 foreach ( $resource as $row )
2377 $aOIDs[] = $row['oid'];
2378 $aOptions[$row['oid']] = array(
2379 'oid' => $row['oid'],
2380 'value' => $row['odef'],
2381 'name' => $row['oname'],
2382 'description' => $row['odesc'],
2383 'type' => $row['otype'],
2384 'typeinfo' => $row['oextra'],
2389 // fill out actual values
2390 if ( count($aOIDs) > 0 )
2392 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2393 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2395 $result = DB::getResult($query);
2396 foreach ( $result as $row )
2398 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2404 'context' => 'global',
2406 'options' => &$aOptions
2408 $manager->notify('PrePluginOptionsEdit', $data);
2410 if ( sizeof($aOptions) > 0 )
2412 $template['content'] = 'plugoptionlist';
2413 $this->parser->parse(showlist($aOptions, 'table', $template, $template_name));
2417 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2423 * AdminActions::parse_editskin()
2424 * Parse skinvar editskin
2426 * @param string $type type of skin
2429 public function parse_editskin($type = 'id')
2433 $skinid = intRequestVar('skinid');
2435 if ( !preg_match('#^admin#', $this->skintype) )
2437 $skin =& $manager->getSKIN($skinid);
2441 $skin =& $manager->getSKIN($skinid, 'AdminActions');
2447 echo intRequestVar('skinid');
2450 echo Entity::hsc($skin->getName());
2453 echo Entity::hsc($skin->getDescription());
2456 echo Entity::hsc($skin->getContentType());
2459 echo Entity::hsc($skin->getIncludePrefix());
2462 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2470 * AdminActions::parse_editskintype()
2471 * Parse skinvar editskintype
2473 * @param string $type name of type for skin type
2476 public function parse_editskintype($stype = 'id')
2480 static $skin = NULL;
2481 static $types = array();
2483 if ( $skin == NULL )
2485 $skinid = intRequestVar('skinid');
2487 if ( !preg_match('#^admin#', $this->skintype) )
2489 $skin =& $manager->getSkin($skinid);
2493 $skin =& $manager->getSkin($skinid, 'AdminActions');
2496 $types = $skin->getDefaultTypes();
2499 $type = strtolower(trim(requestVar('type')));
2504 echo $skin->getID();
2507 echo Entity::hsc($skin->getName());
2510 echo Entity::hsc($skin->getDescription());
2513 echo Entity::hsc($skin->getContentType());
2516 echo Entity::hsc($skin->getContentFromDB($type));
2519 if ( !array_key_exists($type, $types) )
2521 $skinType = ucfirst($type);
2525 $skinType = $types[$type];
2527 echo Entity::hsc($skinType);
2530 echo Entity::hsc($type);
2533 echo Entity::hsc($skin->getIncludePrefix());
2536 if ( !$skin->getIncludeMode() != 'skindir' )
2538 $incMode = _PARSER_INCMODE_NORMAL;
2542 $incMode = _PARSER_INCMODE_SKINDIR;
2544 echo Entity::hsc($incMode);
2553 * AdminActions::parse_adminurl()
2554 * Parse skinvar adminurl
2555 * (shortcut for admin url)
2560 public function parse_adminurl()
2562 $this->parse_sitevar('adminurl');
2567 * AdminActions::parse_edittemplateinfo()
2568 * Parse skinvar edittemplateinfo
2570 * @param string $format format to output
2571 * @param string $typedesc type of template
2572 * @param string $typename type name of template
2573 * @param string $help help text
2574 * @param string $tabindex index value for tabindex attribute of input element
2575 * @param string $big textarea size
2576 * @param string $tplt name of template to be filled
2579 public function parse_edittemplateinfo($format, $typedesc = '', $typename = '', $help = '', $tabindex = 0, $big = 0, $template_name = '')
2583 static $name = NULL;
2584 static $desc = NULL;
2588 $id = intRequestVar('templateid');
2591 if ( $name == NULL )
2593 $name = Template::getNameFromId($id);
2596 if ( $desc == NULL )
2598 $desc = Template::getDesc($id);
2601 $template =& $manager->getTemplate($name);
2609 echo Entity::hsc($name);
2612 echo Entity::hsc($desc);
2614 case 'extratemplate':
2616 $pluginfields = array();
2617 if ( !preg_match('#^admin/#', $this->skintype) )
2619 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2623 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
2626 foreach ( $pluginfields as $ptkey => $ptvalue )
2631 $tmplt =& $manager->getTemplate($desc);
2634 /* extra plugin field */
2635 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2639 . "<th colspan=\"2\"><%explugtplname%></th>\n";
2643 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2646 'explugtplname' => Entity::hsc($ptkey)
2648 echo Template::fill($base, $data);
2650 foreach ( $ptvalue as $ptname => $ptdesc )
2652 if ( !array_key_exists($ptname, $template) )
2658 $content = $template[$ptname];
2660 $this->parser->parse(listplug_templateEditRow($content, $ptdesc, $ptname, $help, $tabidx++, $big, $template_name));
2666 $typedesc = defined($typedesc) ? constant($typedesc) : $typedesc;
2667 $typename = defined($typename) ? constant($typename) : $typename;
2669 if ( !array_key_exists($typename, $template) )
2675 $content = $template[$typename];
2677 $this->parser->parse(listplug_templateEditRow($content, $typedesc, $typename, $help, $tabindex, $big, $template_name));
2685 * AdminActions::parse_eventformextra()
2686 * Parse skinvar eventformextra
2688 * @param string $type name of type for event form extra
2691 public function parse_eventformextra($type = 'activation')
2700 $key = requestVar('ackey');
2703 Admin::error(_ERROR_ACTIVATE);
2705 $info = MEMBER::getActivationInfo($key);
2708 Admin::error(_ERROR_ACTIVATE);
2710 $mem =& $manager->getMember($info->vmember);
2713 Admin::error(_ERROR_ACTIVATE);
2716 'type' => 'activation',
2720 case 'membermailform-notloggedin':
2721 $data = array('type' => 'membermailform-notloggedin',);
2724 $manager->notify('FormExtra', $data);
2729 * AdminActions::parse_extrahead()
2730 * Parse skinvar extrahead
2732 public function parse_extrahead()
2736 $extrahead = Admin::getAdminextrahead();
2739 'extrahead' => &$extrahead,
2740 'action' => Admin::getAdminAction()
2743 $manager->notify('AdminPrePageHead', $data);
2745 $this->parser->parse($extrahead);
2750 * AdminActions::parse_member()
2751 * Parse skinvar member
2752 * (includes a member info thingie)
2754 * @param string $what which memberdata is needed
2757 public function parse_member($what)
2759 global $memberinfo, $member, $CONF;
2761 // 1. only allow the member-details-page specific variables on member pages
2762 if ( $this->skintype == 'member' )
2767 echo Entity::hsc($memberinfo->getDisplayName());
2770 echo Entity::hsc($memberinfo->getRealName());
2773 echo Entity::hsc($memberinfo->getNotes());
2776 echo Entity::hsc($memberinfo->getURL());
2779 echo Entity::hsc($memberinfo->getEmail());
2782 echo Entity::hsc($memberinfo->getID());
2787 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2788 if ( $member->isLoggedIn() )
2793 echo $member->getDisplayName();
2795 case 'yourrealname':
2796 echo $member->getRealName();
2799 echo $member->getNotes();
2802 echo $member->getURL();
2805 echo $member->getEmail();
2808 echo $member->getID();
2810 case 'yourprofileurl':
2811 if ( $CONF['URLMode'] == 'pathinfo' )
2813 echo Link::create_member_link($member->getID());
2817 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
2826 * AdminActions::parse_version()
2827 * Parse skinvar version
2828 * (include nucleus versionnumber)
2833 public function parse_version()
2836 echo 'Nucleus CMS ' . $nucleus['version'];
2841 * AdminActions::parse_sitevar()
2842 * Parse skinvar sitevar
2843 * (include a sitevar)
2845 * @param string $which
2848 public function parse_sitevar($which)
2854 echo $CONF['IndexURL'];
2857 echo $CONF['SiteName'];
2860 echo $CONF['AdminEmail'];
2863 echo $CONF['AdminURL'];
2870 * AdminActions::parse_actionurl()
2876 public function parse_actionurl()
2879 echo Entity::hsc($CONF['ActionURL']);
2884 * AdminActions::parse_getblogsetting()
2885 * Parse skinvar getblogsetting
2887 public function parse_getblogsetting($which)
2889 global $blog, $manager;
2895 elseif ( $bid = intRequestVar('blogid') )
2897 $b =& $manager->getBlog($bid);
2907 return Entity::hsc($b->getID());
2910 return Entity::hsc($b->getURL());
2913 return Entity::hsc($b->getName());
2916 return Entity::hsc($b->getDescription());
2919 return Entity::hsc($b->getShortName());
2921 case 'notifyaddress':
2922 return Entity::hsc($b->getNotifyAddress());
2925 return Entity::hsc($b->getMaxComments());
2928 return Entity::hsc($b->getUpdateFile());
2931 return Entity::hsc($b->getTimeOffset());
2938 * AdminActions::parse_geteditpluginfo()
2939 * Parse skinvar geteditpluginfo
2941 * @param string $type name of setting for edit plugin info
2944 public function parse_geteditpluginfo($type)
2947 $pid = intRequestVar('plugid');
2954 return Entity::hsc($manager->getPluginNameFromPid($pid));
2961 * AdminActions::parse_getmember()
2962 * Parse skinvar getmember
2963 * (includes a member info thingie)
2965 * @param string $what name of setting for member
2968 public function parse_getmember($what)
2970 global $memberinfo, $member;
2971 // 1. only allow the member-details-page specific variables on member pages
2972 if ( $this->skintype == 'member' )
2977 return Entity::hsc($memberinfo->getDisplayName());
2980 return Entity::hsc($memberinfo->getRealName());
2983 return Entity::hsc($memberinfo->getNotes());
2986 return Entity::hsc($memberinfo->getURL());
2989 return Entity::hsc($memberinfo->getEmail());
2992 return Entity::hsc($memberinfo->getID());
2996 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2997 if ( $member->isLoggedIn() )
3002 return $member->getDisplayName();
3004 case 'yourrealname':
3005 return $member->getRealName();
3008 return $member->getNotes();
3011 return $member->getURL();
3014 return $member->getEmail();
3017 return $member->getID();
3025 * AdminActions::parse_headmessage()
3026 * Parse skinvar headmessage
3031 public function parse_headmessage()
3033 if ( !empty(Admin::$headMess) )
3035 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3041 * AdminActions::parse_helplink()
3042 * Parse skinvar helplink
3044 * @param string $topic name of topic for help
3047 public function parse_helplink($topic = '')
3049 if ( !empty($topic) )
3057 * AdminActions::parse_helpplugname()
3058 * Parse skinvar helpplugname
3063 public function parse_helpplugname()
3065 $plugid = intGetVar('plugid');
3066 Entity::hsc($manager->getPluginNameFromPid($plugid));
3071 * AdminActions::parse_ilistaddnew()
3072 * Parse skinvar ilistaddnew
3077 public function parse_ilistaddnew()
3079 $blogid = intRequestVar('blogid');
3080 if ( intPostVar('start') == 0 )
3082 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3088 * AdminActions::parse_importskininfo()
3089 * Parse skinvar importskininfo
3091 * @param string $type name of information for imported skin
3094 public function parse_importskininfo($type)
3099 echo Entity::hsc(requestVar('skininfo'));
3102 $dataArr = requestArray('skinnames');
3103 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3106 $dataArr = requestArray('tpltnames');
3107 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3110 $dataArr = requestArray('skinclashes');
3111 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3114 $dataArr = requestArray('tpltclashes');
3115 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3118 echo Entity::hsc(requestVar('skinfile'));
3121 echo Entity::hsc(requestVar('mode'));
3128 * AdminActions::parse_init()
3129 * some init stuff for all forms
3134 public function parse_init()
3139 if ( requestVar('action') == 'itemedit' )
3141 $authorid = Admin::$contents['authorid'];
3144 Admin::$blog->insertJavaScriptInfo($authorid);
3149 * AdminActions::parse_inputyesno()
3150 * Parse skinvar inputyesno
3152 * @param string $name
3153 * @param string $checkedval
3154 * @param string $tabindex
3155 * @param string $value1
3156 * @param string $value2
3157 * @param string $yesval
3158 * @param string $noval
3159 * @param string $isAdmin
3160 * @param string $template_name
3163 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $template_name = '')
3165 $this->parser->parse(listplug_input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $template_name));
3170 * AdminActions::parse_insertpluginfo()
3171 * Parse templatevar insertpluginfo
3173 public function parse_insertpluginfo($type)
3175 $option = Admin::getAdminaOption();
3179 return $option['pid'];
3182 return Entity::hsc($option['pfile']);
3189 * AdminActions::parse_insplugoptcontent()
3190 * Parse skinvar insplugoptcontent
3195 public function parse_insplugoptcontent()
3197 $option = Admin::getAdminaOption();
3199 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3200 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3203 listplug_plugOptionRow($option);
3210 * AdminActions::parse_iprangeinput()
3211 * Parse skinvar iprangeinput
3216 public function parse_iprangeinput()
3218 if ( requestVar('ip') )
3220 $iprangeVal = Entity::hsc(requestVar('ip'));
3221 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3222 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3223 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3224 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3225 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3229 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3230 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3236 * AdminActions::parse_itemnavlist()
3237 * Parse skinvar itemnavlist
3242 public function parse_itemnavlist($template_name)
3244 global $CONF, $manager, $member;
3246 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3247 . " FROM %s, %s, %s, %s"
3248 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3250 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3252 if ( $this->skintype == 'itemlist' )
3255 if ( array_key_exists('blogid', $_REQUEST) )
3257 $blogid = intRequestVar('blogid');
3259 else if ( array_key_exists('itemid', $_REQUEST) )
3261 $itemid = intRequestVar('itemid');
3262 $item = &$manager->getItem($itemid, 1, 1);
3263 $blogid = (integer) $item['blogid'];
3265 $blog =& $manager->getBlog($blogid);
3267 $query .= " AND iblog={$blogid}";
3268 $template['now'] = $blog->getCorrectTime(time());
3270 // non-blog-admins can only edit/delete their own items
3271 if ( !$member->blogAdminRights($blogid) )
3273 $query .= ' AND iauthor = ' . $member->getID();
3276 elseif ( $this->skintype == 'browseownitems' )
3278 $query .= ' AND iauthor = ' . $member->getID();
3280 $template['now'] = time();
3283 // search through items
3284 $search = postVar('search');
3286 if ( !empty($search) )
3288 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3289 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3290 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3293 if ( postVar('start') )
3295 $start = intPostVar('start');
3302 // amount of items to show
3303 if ( postVar('amount') )
3305 $amount = intPostVar('amount');
3309 $amount = (integer) $CONF['DefaultListSize'];
3316 $query .= ' ORDER BY itime DESC'
3317 . " LIMIT {$start},{$amount}";
3319 $resource = DB::getResult($query);
3320 if ( $resource->rowCount() > 0 )
3322 $template['action'] = $this->skintype;
3323 $template['start'] = $start;
3324 $template['amount'] = $amount;
3325 $template['minamount'] = 0;
3326 $template['maxamount'] = 1000;
3327 $template['blogid'] = $blogid;
3328 $template['search'] = $search;
3329 $template['itemid'] = 0;
3331 $template['content'] = 'itemlist';
3333 $this->parser->parse(listplug_navlist('item', $query, 'table', $template, $template_name));
3337 /* TODO: nothing to be shown */
3339 $resource->closeCursor();
3345 * AdminActions::parse_itemtime()
3346 * date change on edit item
3348 * @param string $key key of PHP's getDate()
3351 public function parse_itemtime($key)
3356 $itemid = intRequestVar('itemid');
3357 $item =& $manager->getItem($itemid, 1, 1);
3361 $blog =& $manager->getBlog($item['blogid']);
3363 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3365 $item['body'] = removeBreaks($item['body']);
3366 $item['more'] = removeBreaks($item['more']);
3370 $editaction = array(
3380 $contents = array();
3381 if ( in_array(requestVar('action'),$editaction) )
3385 elseif ( in_array(requestVar('action'),$addaction) )
3388 'contents' => &$contents,
3389 'blog' => &$this->blog
3391 $manager->notify('PreAddItemForm', $data);
3393 $itemtime = getdate($contents['timestamp']);
3394 echo $itemtime[$key];
3399 * AdminActions::parse_jstoolbaroptions()
3400 * Parse skinvar jstoolbaroptions
3405 public function parse_jstoolbaroptions()
3409 _SETTINGS_JSTOOLBAR_NONE,
3410 _SETTINGS_JSTOOLBAR_SIMPLE,
3411 _SETTINGS_JSTOOLBAR_FULL
3415 foreach ( $options as $option )
3417 $text = "<option value=\"%d\"%s>%s</option>\n";
3418 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3419 echo sprintf($text, $i, $extra, $option);
3425 * AdminActions::parse_localeselectoptions()
3426 * Parse skinvar localeselectoptions
3431 public function parse_localeselectoptions()
3433 global $CONF, $member;
3435 $locales = i18n::get_available_locale_list();
3437 /* default option */
3438 if ( $this->skintype == 'editmembersettings' )
3440 if ( !$member->getLocale() )
\r
3442 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
\r
3446 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
\r
3451 if ( $CONF['Locale'] == 'en_Latn_US' )
\r
3453 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
\r
3457 echo "<option value=\"\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
\r
3461 /* optional options */
3462 foreach ( $locales as $locale )
3464 if ( $this->skintype == 'editmembersettings' )
\r
3466 if ( $locale != $member->getLocale() )
\r
3468 echo "<option value=\"{$locale}\">";
\r
3472 echo "<option value=\"{$locale}\" selected=\"selected\">";
\r
3477 if ( $locale == 'en_Latn_US' )
3479 /* already output */
3482 else if ( $locale != $CONF['Locale'] )
\r
3484 echo "<option value=\"{$locale}\">";
\r
3488 echo "<option value=\"{$locale}\" selected=\"selected\">";
\r
3491 $label = '_LOCALE_' . strtoupper($locale);
3492 if ( !defined($label) )
3498 echo constant($label);
3500 echo "</option>\n";
\r
3506 * AdminActions::parse_listplugplugoptionrow()
3507 * Parse templatevar listplugplugoptionrow
3509 * @param string $template_name name of template
3512 public function parse_listplugplugoptionrow($template_name = '')
3514 echo listplug_plugOptionRow(Admin::getAdminaOption(), $template_name);
3519 * AdminActions::parse_mediadirwarning()
3520 * Parse skinvar mediadirwarning
3525 public function parse_mediadirwarning()
3528 if ( !is_dir($DIR_MEDIA) )
3530 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3532 if ( !is_readable($DIR_MEDIA) )
3534 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3536 if ( !is_writeable($DIR_MEDIA) )
3538 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3544 * AdminActions::parse_movedistselect()
3545 * Parse skinvar movedistselect
3547 public function parse_movedistselect()
3549 $actionType = requestVar('action');
3550 switch ( $actionType )
3553 $this->selectBlog('destcatid', 'category');
3555 case 'batchcategory':
3556 $this->selectBlog('destblogid');
3559 if ( $this->skintype == 'itemmove' )
3561 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3562 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3563 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3564 $this->selectBlog('catid', 'category', $catid, 10, 1);
3572 * AdminActions::parse_moveitemid()
3573 * Parse skinvar moveitemid
3578 public function parse_moveitemid()
3580 echo intRequestVar('itemid');
3585 * AdminActions::parse_newestcompare()
3586 * Parse skinvar newestcompare
3591 public function parse_newestcompare()
3595 $newestVersion = getLatestVersion();
3596 $newestCompare = str_replace('/', '.', $newestVersion);
3597 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3599 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3601 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3602 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3608 * AdminActions::parse_newmemberselect()
3609 * Parse skinvar newmemberselect
3611 * @param string $template_name name of template to use
3614 public function parse_newmemberselect($template_name = '')
3616 $blogid = intRequestVar('blogid');
3618 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3619 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3620 $res = DB::getResult($query);
3623 foreach ( $res as $row )
3625 $tmem[] = intval($row['tmember']);
3628 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3629 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3632 'name' => 'memberid',
3633 'tabindex' => 10000,
3636 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3641 * AdminActions::parse_newpluginlist()
3642 * Parse skinvar newpluginlist
3647 public function parse_newpluginlist()
3649 $candidates = $this->newPlugCandidates;
3650 foreach ( $candidates as $name )
3652 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3658 * AdminActions::parse_outputspecialdirs()
3659 * Parse skinvar outputspecialdirs
3661 * @param string $type type of setting for directory
3664 public function parse_outputspecialdirs($type)
3666 global $DIR_MEDIA, $DIR_NUCLEUS;
3671 echo Entity::hsc($DIR_NUCLEUS);
3674 echo Entity::hsc($DIR_MEDIA);
3681 * AdminActions::parse_passrequestvars()
3682 * Parse skinvar passrequestvars
3687 public function parse_passrequestvars()
3689 $passvar = Admin::getAdminpassvar();
3690 $oldaction = postVar('oldaction');
3692 if ( ($oldaction != 'logout')
3693 && ($oldaction != 'login')
3695 && !postVar('customaction') )
3703 * AdminActions::parse_pluginextras()
3704 * Parse skinvar pluginextras
3706 * @param string $type type of plugin context
3709 public function parse_pluginextras($type = 'global')
3716 $id = intRequestVar('memberid');
3717 $mem =& $manager->getMember($id);
3718 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
3721 $id = intRequestVar('blogid');
3722 $blg =& $manager->getBlog($id);
3723 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
3725 case 'createaccount':
3727 'type' => 'createaccount.php',
3729 'postlabel' => '<br />',
3731 'postfield' => '<br /><br />'
3733 $manager->notify('RegistrationFormExtraFields', $data);
3736 $manager->notify('GeneralSettingsFormExtras', array());
3743 * AdminActions::parse_pluginhelp()
3744 * Parse skinvar pluginhelp
3749 public function parse_pluginhelp()
3751 global $manager, $DIR_PLUGINS;
3753 $plugid = intGetVar('plugid');
3754 $plugName = $manager->getPluginNameFromPid($plugid);
3755 $plug =& $manager->getPlugin($plugName);
3757 if ( $plug->supportsFeature('HelpPage') > 0 )
3759 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3760 if ( @file_exists($helpfile . 'php') )
3762 @include($helpfile . 'php');
3765 elseif ( @file_exists($helpfile . 'html') )
3767 @include($helpfile . 'html');
3771 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3772 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3777 * AdminActions::parse_pluginlistlist()
3778 * Parse skinvar pluginlistlist
3780 * @param string $template_name name of template to use
3783 public function parse_pluginlistlist($template_name = '')
3785 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3786 $query = sprintf($query, sql_table('plugin'));
3788 $template['content'] = 'pluginlist';
3789 $template['tabindex'] = 10;
3791 $this->parser->parse(showlist($query, 'table', $template, $template_name));
3797 * AdminActions::parse_pluginoptions()
3798 * Parse skinvar pluginoptions
3800 * @param string $type type of plugin option
3803 public function parse_pluginoptions($context='global', $template_name='')
3805 global $itemid, $manager;
3810 $contextid = intRequestVar('memberid');
3813 $contextid = intRequestVar('blogid');
3816 $contextid = intRequestVar('catid');
3819 $contextid = $itemid;
3823 /* Actually registererd plugin options */
3824 $aIdToValue = array();
3825 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
3826 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
3827 $res = DB::getResult($query);
3828 foreach ( $res as $row )
3830 $aIdToValue[$row['oid']] = $row['ovalue'];
3833 /* Currently available plugin options */
3834 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
3835 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
3836 $res = DB::getResult($query);
3839 foreach ($res as $row )
3841 if ( !array_key_exists($row['oid'], $aIdToValue) )
3843 $value = $row['odef'];
3847 $value = $aIdToValue[$row['oid']];
3851 'pid' => $row['pid'],
3852 'pfile' => $row['pfile'],
3853 'oid' => $row['oid'],
3855 'name' => $row['oname'],
3856 'description' => $row['odesc'],
3857 'type' => $row['otype'],
3858 'typeinfo' => $row['oextra'],
3859 'contextid' => $contextid,
3865 'context' => $context,
3866 'contextid' => $contextid,
3867 'options' => &$options
3869 $manager->notify('PrePluginOptionsEdit', $data);
3871 $template = array();
3872 if ( $template_name )
3874 $templates =& $manager->getTemplate($template_name);
3875 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3877 $template['title'] = "<tr>"
3878 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3883 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3886 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3888 $template['body'] = "<tr>"
3889 . "<%listplugplugoptionrow%>"
3894 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3900 foreach ( $options as $option )
3903 if ( $prevPid != $option['pid'] )
3905 $prevPid = $option['pid'];
3906 $this->parser->parse($template['title']);
3909 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3911 if ( @$meta['access'] != 'hidden' )
3913 $parsed = $this->parser->parse($template['body']);
3921 * AdminActions::parse_qmenuaddselect()
3922 * Parse skinvar qmanuaddselect
3924 * @param string $template_name name of template to use
3927 public function parse_qmenuaddselect($template_name = '')
3929 global $member, $blogid;
3930 $showAll = requestVar('showall');
3931 if ( $member->isAdmin() && ($showAll == 'yes') )
3933 // Super-Admins have access to all blogs! (no add item support though)
3934 $query = 'SELECT bnumber as value, bname as text FROM %s ORDER BY bname;';
3935 $query = sprintf($query, sql_table('blog'));
3939 $query = 'SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;';
3940 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3943 $template['name'] = 'blogid';
3944 $template['tabindex'] = 15000;
3945 $template['extra'] = _QMENU_ADD_SELECT;
3946 $template['selected'] = 0;
3947 $template['shorten'] = 10;
3948 $template['shortenel'] = '';
3949 $template['javascript'] = 'onchange="return form.submit()"';
3951 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3957 * AdminActions::parse_quickmenu()
3958 * Parse skinvar quickmenu
3960 * @param string $template_name name of template to use
3963 public function parse_quickmenu($template_name = '')
3966 $templates = array();
3968 if ( !empty($template_name) )
3970 $templates = & $manager->getTemplate($template_name);
3972 $pluginExtras = array();
3973 $manager->notify('QuickMenu', array('options' => &$pluginExtras));
3975 $template = array();
3976 if ( count($pluginExtras) > 0 )
3978 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3980 $template['head'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n"
3985 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3988 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
3990 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
3994 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3997 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3999 $template['foot'] = "</ul>\n";
4003 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4006 $this->parser->parse($template['head']);
4007 foreach ( $pluginExtras as $aInfo )
4010 'plugadminurl' => Entity::hsc($aInfo['url']),
4011 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4012 'plugadmintitle' => Entity::hsc($aInfo['title']),
4014 $this->parser->parse(Template::fill($template['body'], $data));
4016 $this->parser->parse($template['foot']);
4022 * AdminActions::parse_requestblogid()
4023 * Parse skinvar requestblogid
4028 public function parse_requestblogid()
4030 echo intRequestVar('blogid');
4035 * AdminActions::parse_requestiprange()
4036 * Parse skinvar requestiprange
4041 public function parse_requestiprange()
4043 if ( requestVar('iprange') )
4045 echo Entity::hsc(requestVar('iprange'));
4047 elseif ( requestVar('ip') )
4049 echo Entity::hsc(requestVar('ip'));
4055 * AdminActions::parse_selectlocalskinfiles()
4056 * Parse skinvar selectlocalskinfiles
4061 public function parse_selectlocalskinfiles()
4065 if ( !class_exists('SkinImport', FALSE) )
4067 include_libs('skinie.php');
4070 if ( !preg_match('#^admin#', $this->skintype) && $this->skintype != 'importAdmin' )
4072 $skindir = $DIR_SKINS;
4076 $skindir = "{$DIR_SKINS}admin/";
4079 $candidates = SkinImport::searchForCandidates($skindir);
4080 foreach ( $candidates as $skinname => $skinfile )
4082 $skinfile = Entity::hsc($skinfile);
4083 $skinname = Entity::hsc($skinname);
4084 echo "<option value=\"{$skinfile}\">{$skinname}</option>\n";
4091 * AdminActions::parse_skineditallowedlist()
4092 * Parse skinvar skineditallowedlist
4094 * @param string $type type of skin
4095 * @param string $template_name name of template
4098 public function parse_skineditallowedlist($type, $template_name = '')
4103 $query = "SELECT bshortname, bname FROM %s;";
4105 'content' => 'shortblognames'
4107 $query = sprintf($query, sql_table('blog'));
4110 if ( !preg_match('#^admin#', $this->skintype) )
4112 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4116 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%';";
4119 'content' => 'shortnames'
4121 $query = sprintf($query, sql_table('template_desc'));
4125 $this->parser->parse(showlist($query, 'table', $show, $template_name));
4130 * AdminActions::parse_skinielist()
4131 * Parse skinvar skinielist
4133 * @param string $type type of skin
4134 * @param string $template_name name of template to use
4137 public function parse_skinielist($type, $template_name = '')
4141 $templates = array();
4142 if ( $template_name )
4144 $templates =& $manager->getTemplate($template_name);
4146 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
4149 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4150 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4152 . "<td><%expdesc%></td>\n"
4158 $template = $templates['SKINIE_EXPORT_LIST'];
4164 if ( !preg_match('#^admin#', $this->skintype) )
4166 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4170 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname LIKE 'admin/%%';");
4172 foreach ( $res as $row )
4175 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4176 'expid' => 'skinexp' . $row['sdnumber'],
4177 'expname' => Entity::hsc($row['sdname']),
4178 'expdesc' => Entity::hsc($row['sddesc'])
4180 echo Template::fill($template, $data);
4184 if ( !preg_match('#^admin#', $this->skintype) )
4186 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4190 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname LIKE 'admin/%%';");
4192 foreach ( $res as $row )
4195 'typeid' => 'template[' . $row['tdnumber'] . ']',
4196 'expid' => 'templateexp' . $row['tdnumber'],
4197 'expname' => Entity::hsc($row['tdname']),
4198 'expdesc' => Entity::hsc($row['tddesc'])
4200 echo Template::fill($template, $data);
4208 * AdminActions::parse_skinoverview()
4209 * Parse skinvar skinoverview
4211 * @param string $template_name name of template to use
4214 public function parse_skinoverview($template_name = '')
4218 $template = array();
4219 if ( !preg_match('#^admin#', $this->skintype) )
4221 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%' ORDER BY sdname;";
4222 $template['editaction'] = 'skinedit';
4223 $template['cloneaction'] = 'skinclone';
4224 $template['deleteaction'] = 'skindelete';
4225 $template['edittypeaction'] = 'skinedittype';
4226 $template['default'] = $CONF['BaseSkin'];
4230 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
4231 $template['editaction'] = 'adminskinedit';
4232 $template['cloneaction'] = 'adminskinclone';
4233 $template['deleteaction'] = 'adminskindelete';
4234 $template['edittypeaction'] = 'adminskinedittype';
4235 $template['default'] = $CONF['AdminSkin'];
4237 $query = sprintf($query, sql_table('skin_desc'));
4239 $template['tabindex'] = 10;
4240 $template['content'] = 'skinlist';
4242 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4248 * AdminActions::parse_skintypehelp()
4249 * Check editing skintypehelp
4254 public function parse_skintypehelp()
4256 $nowSkinType = strtolower(trim(requestVar('type')));
4257 $pageAction = strtolower(trim(requestVar('action')));
4258 if ( preg_match('/^admin.*/', $pageAction) )
4260 $regularType = self::$default_skin_types;
4261 unset($regularType['memberedit']);
4262 unset($regularType['login']);
4263 $regularType = array_keys($regularType);
4267 /* TODO: use Skin class */
4268 $regularType = array(
4280 if ( in_array($nowSkinType, $regularType) )
4282 help('skinpart' . $nowSkinType);
4286 help('skinpartspecial');
4292 * AdminActions::parse_specialskinlist()
4293 * Parse skinvar specialskinlist
4295 * @param string $template_name name of template to use
4298 public function parse_specialskinlist($template_name = '')
4300 global $CONF, $manager;
4302 $template = array();
4304 $skinid = intRequestVar('skinid');
4306 if ( !preg_match('#^admin#', $this->skintype) )
4308 $skin =& $manager->getSkin($skinid);
4309 $template['editaction'] = 'skinedittype';
4310 $template['removeaction'] = 'skinremovetype';
4314 $skin =& $manager->getSkin($skinid, 'AdminActions');
4315 $template['editaction'] = 'adminskinedittype';
4316 $template['removeaction'] = 'adminskinremovetype';
4318 $normal_types = $skin->getDefaultTypes();
4319 $available_types = $skin->getAvailableTypes();
4321 $special_skintypes = array();
4322 foreach( $available_types as $skintype => $skinname )
4324 if ( !array_key_exists($skintype, $normal_types) )
4326 $special_skintypes[] = array(
4327 'skintype' => $skintype,
4328 'skintypename' => $skinname
4333 if ( sizeof($special_skintypes) > 0 )
4335 $template['tabindex'] = 75;
4336 $template['skinid'] = $skin->getID();
4337 $template['skinname'] = $skin->getName();
4338 $this->parser->parse(showlist($special_skintypes, 'list_specialskinlist', $template, $template_name));
4342 /* TODO: nothing to be shown */
4349 * AdminActions::parse_sprinttext()
4352 * @param string $which
4353 * @param string $val
4356 public function parse_sprinttext($which, $val)
4358 if ( !defined($which) )
4364 $base = constant($which);
4367 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4369 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4371 $met = 'parse_' . $matchies[0];
4375 $arg = trim($args[0], '()');
4376 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4379 if ( method_exists($this, $met) )
4381 $value = call_user_func(array(&$this, $met), $arg);
4385 if ( !isset($value) || empty($value) )
4389 echo sprintf($base, $value);
4394 * AdminActions::parse_systemsettings()
4395 * Parse skinvar systemsettings
4397 * @param string $type type of settings for system
4398 * @param string $template_name name of template to use
4401 public function parse_systemsettings($type = 'phpinfo', $template_name = '')
4403 global $manager, $member, $CONF, $nucleus;
4405 $member->isAdmin() or Admin::disallow();
4407 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4408 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4415 case 'sqlserverinfo':
4416 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4418 case 'sqlclientinfo':
4419 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4421 case 'magicquotesgpc':
4422 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4424 case 'magicquotesruntime':
4425 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4427 case 'registerglobals':
4428 echo ini_get('register_globals') ? 'On' : 'Off';
4431 $templates = array();
4432 if ( $template_name )
4434 $templates =& $manager->getTemplate($template_name);
4436 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4438 $template = "<tr>\n"
4439 . "<td><%key%></td>\n"
4440 . "<td><%value%></td>\n"
4445 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4448 $gdinfo = gd_info();
4450 foreach ( $gdinfo as $key => $value )
4452 if ( is_bool($value) )
4454 $value = $value ? $enable : $disable;
4458 $value = Entity::hsc($value);
4464 echo Template::fill($template, $data);
4469 phpinfo(INFO_MODULES);
4470 $im = ob_get_contents();
4472 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4474 case 'nucleusversion':
4475 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4477 case 'nucleuspatchlevel':
4478 echo getNucleusPatchLevel();
4484 echo $CONF['ItemURL'];
4486 case 'alertonheaderssent':
4487 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4489 case 'nucleuscodename':
4490 if ( $nucleus['codename'] != '' )
4492 echo ' "' . $nucleus['codename'] . '"';
4495 case 'versioncheckurl':
4496 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4503 * AdminActions::parse_templateoverview()
4504 * Parse skinvar templateoverview
4506 * @param string $template_name name of template to use
4509 public function parse_templateoverview($template_name = '')
4511 if ( !preg_match('#^admin#', $this->skintype) )
4513 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname;";
4514 $template['deleteaction'] = 'templatedelete';
4515 $template['editaction'] = 'templateedit';
4516 $template['cloneaction'] = 'templateclone';
4520 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
4521 $template['deleteaction'] = 'admintemplatedelete';
4522 $template['editaction'] = 'admintemplateedit';
4523 $template['cloneaction'] = 'admintemplateclone';
4525 $query = sprintf($query, sql_table('template_desc'));
4527 $template['tabindex'] = 10;
4528 $template['content'] = 'templatelist';
4530 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4536 * AdminActions::parse_ticket()
4542 public function parse_ticket()
4545 $manager->addTicketHidden();
4550 * AdminActions::parse_versioncheckurl()
4551 * Parse skinvar versioncheckurl
4556 public function parse_versioncheckurl()
4558 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4563 * AdminActions::parse_yrbloglist()
4564 * Parse skinvar yrbloglist
4566 * @param string $template_name name of template to use
4569 public function parse_yrbloglist($template_name = '')
4572 $showAll = requestVar('showall');
4574 if ( $member->isAdmin() && ($showAll == 'yes') )
4576 // Super-Admins have access to all blogs! (no add item support though)
4577 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4579 . " ORDER BY bnumber;";
4580 $query = sprintf($query, sql_table('blog'));
4584 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4586 . " WHERE tblog=bnumber and tmember=%d"
4587 . " ORDER BY bnumber;";
4588 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4591 $resource = DB::getResult($query);
4592 if ( ($showAll != 'yes') && $member->isAdmin() )
4594 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4595 $total = DB::getValue($query);
4597 if ( $total > $resource->rowCount() )
4599 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4603 if ( $resource->rowCount() > 0 )
4605 $template['content'] = 'bloglist';
4606 $template['superadmin'] = $member->isAdmin();
4608 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4609 $resource->closeCursor();
4611 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4613 $query = 'SELECT ititle, inumber, bshortname FROM %s, %s '
4614 . 'WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4615 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4617 $resource = DB::getResult($query);
4618 if ( $resource->rowCount() > 0 )
4620 $template['content'] = 'draftlist';
4621 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4625 echo _OVERVIEW_NODRAFTS;
4630 echo _OVERVIEW_NOBLOGS;
4632 $resource->closeCursor();
4638 * AdminActions::checkCondition()
4639 * Checks conditions for if statements
4641 * @param string $field type of <%if%>
4642 * @param string $name property of field
4643 * @param string $value value of property
4644 * @return boolean condition
4646 protected function checkCondition($field, $name='', $value = '')
4648 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4658 $blog =& $manager->getBlog($blogid);
4662 $blogid = getBlogIDFromCatID($catid);
4663 $blog =& $manager->getBlog($blogid);
4665 elseif ( intRequestVar('catid') )
4667 $catid = intRequestVar('catid');
4668 $blogid = getBlogIDFromCatID($catid);
4669 $blog =& $manager->getBlog($blogid);
4676 $condition = ($blog && $this->ifCategory($name, $value));
4679 $condition = $member->isLoggedIn();
4682 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4685 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4688 $condition = $member->isLoggedIn() && $member->isAdmin();
4690 case 'allowloginedit':
4691 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4694 $condition = ($itemidnext != '');
4697 $condition = ($itemidprev != '');
4699 case 'archiveprevexists':
4700 $condition = ($archiveprevexists == true);
4702 case 'archivenextexists':
4703 $condition = ($archivenextexists == true);
4706 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4709 $condition = $this->ifHasPlugin($name, $value);
4712 $condition = (Admin::getAdminAction() == $name);
4714 case 'adminoldaction':
4715 $condition = (Admin::getAdminAction() == $name);
4717 case 'addresschange':
4718 $condition = ($this->ifAddresscange());
4720 case 'bechangepass':
4721 $condition = ($this->beChangePassword());
4723 case 'skincandidates':
4724 $condition = ($this->ifSkincandidates());
4727 $condition = requestVar('nameclashes');
4729 case 'existsnewplugin':
4730 $condition = ($this->existsNewPlugin());
4737 $condition = (boolean) ($member->getAutosave() == $value);
4744 $condition = (Admin::$blog->getSetting($name) == $value);
4746 case 'itemproperty':
4751 if ( array_key_exists($name, Admin::$contents) )
4753 $condition = (boolean) (Admin::$contents[$name] == $value);
4757 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4764 * AdminActions::_ifHasPlugin()
4765 * hasplugin,PlugName
4766 * -> checks if plugin exists
4767 * hasplugin,PlugName,OptionName
4768 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
4769 * hasplugin,PlugName,OptionName=value
4770 * -> checks if the option OptionName from plugin PlugName is set to value
4772 * @param string $name name of plugin
4773 * @param string $value
4776 private function ifHasPlugin($name, $value)
4780 // (pluginInstalled method won't write a message in the actionlog on failure)
4781 if ( $manager->pluginInstalled("NP_{$name}") )
4783 $plugin =& $manager->getPlugin("NP_{$name}");
4784 if ( $plugin != NULL )
4792 list($name2, $value2) = preg_split('#=#', $value, 2);
4793 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4797 else if ( $plugin->getOption($name2) == $value2 )
4808 * AdminActions::beChangePassword()
4813 private function beChangePassword()
4815 return intRequestVar('bNeedsPasswordChange');
4819 * AdminActions::ifSkincandidates()
4820 * Checks if a plugin exists and call its doIf function
4826 private function ifSkincandidates()
4829 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4830 return (count($candidates) > 0);
4834 * AdminActions::ifPlugin()
4835 * Checks if a plugin exists and call its doIf function
4837 * @param string $name name of plugin
4838 * @param string $key
4839 * @param string $value
4842 private function ifPlugin($name, $key = '', $value = '')
4846 $plugin =& $manager->getPlugin("NP_{$name}");
4852 $params = func_get_args();
4853 array_shift($params);
4855 return call_user_func_array(array(&$plugin, 'doIf'), $params);
4859 * AdminActions::ifCategory()
4860 * Different checks for a category
4862 * @param string $key key for information of category
4863 * @param string $value value for information of category
4866 private function ifCategory($key = '', $value='')
4868 global $blog, $catid;
4870 // when no parameter is defined, just check if a category is selected
4871 if (($key != 'catname' && $key != 'catid') || ($value == ''))
4873 return $blog->isValidCategory($catid);
4876 // check category name
4877 if ( $key == 'catname' )
4879 $value = $blog->getCategoryIdFromName($value);
4880 if ($value == $catid)
4882 return $blog->isValidCategory($catid);
4886 // check category id
4887 if (($key == 'catid') && ($value == $catid))
4889 return $blog->isValidCategory($catid);
4896 * AdminActions::ifOnTeam()
4897 * Checks if a member is on the team of a blog and return his rights
4899 * @param string $blogName name of weblog
4902 private function ifOnTeam($blogName = '')
4904 global $blog, $member, $manager;
4906 // when no blog found
4907 if ( ($blogName == '') && !is_object($blog) )
4912 // explicit blog selection
4913 if ($blogName != '')
4915 $blogid = getBlogIDFromName($blogName);
4918 if (($blogName == '') || !$manager->existsBlogID($blogid))
4921 $blogid = $blog->getID();
4923 return $member->teamRights($blogid);
4927 * AdminActions::ifAdmin()
4928 * Checks if a member is admin of a blog
4930 * @param string $blogName name of weblog
4933 private function ifAdmin($blogName = '')
4935 global $blog, $member, $manager;
4937 // when no blog found
4938 if (($blogName == '') && (!is_object($blog)))
4943 // explicit blog selection
4944 if ($blogName != '')
4946 $blogid = getBlogIDFromName($blogName);
4949 if (($blogName == '') || !$manager->existsBlogID($blogid))
4952 $blogid = $blog->getID();
4955 return $member->isBlogAdmin($blogid);
4959 * AdminActions::ifAddresscange()
4960 * Check e-Mail address is changed
4965 private function ifAddresscange()
4969 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4974 $info = MEMBER::getActivationInfo($key);
4979 $mem =& $manager->getMember($info->vmember);
4984 if ( $info->vtype == 'addresschange' )
4993 * AdminActions::customHelp()
4994 * shows a link to custom help file
4997 * @param string $tplName
4998 * @param string $url
4999 * @param string $iconURL
5000 * @param string $alt
5001 * @param string $title
5005 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5007 echo $this->customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5012 * AdminActions::customHelp()
5013 * shows a link to custom help file
5016 * @param string $tplName
5017 * @param string $url
5018 * @param string $iconURL
5019 * @param string $alt
5020 * @param string $title
5024 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5026 global $CONF, $manager;
5028 $templates = array();
5032 $templates =& $manager->getTemplate($tplName);
5035 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5037 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5041 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5046 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5049 if ( empty($onclick) )
5051 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5053 elseif ( preg_match('#^onclick#', $onclick) )
5055 $onclick = $onclick;
5059 $onclick = 'onclick="' . $onclick . '"';
5064 'helptarget' => $id,
5065 'onclick' => $onclick,
5066 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5068 return Template::fill($template, $data);
5073 * AdminActions::customHelpHtml()
5075 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5077 global $CONF, $manager;
5079 $templates = array();
5083 $templates =& $manager->getTemplate($tplName);
5085 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5087 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5091 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5094 if ( empty($iconURL) )
5096 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5099 if ( function_exists('getimagesize') )
5101 $size = getimagesize($iconURL);
5102 $width = 'width="' . $size[0] . '" ';
5103 $height = 'height="' . $size[1] . '" ';
5107 'iconurl' => $iconURL,
5109 'height' => $height,
5110 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5111 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5114 $icon = Template::fill($template, $data);
5115 $help = $this->customHelplink($id, $tplName, $url, $title, $onclick);
5117 return $help . $icon;
5121 * AdminActions::existsNewPlugin()
5122 * Check exists new plugin
5125 * @return boolean exists or not
5127 private function existsNewPlugin()
5129 global $DIR_PLUGINS;
5131 $query = "SELECT * FROM %s;";
5132 $query = sprintf($query, sql_table('plugin'));
5133 $res = DB::getResult($query);
5135 $installed = array();
5136 foreach( $res as $row )
5138 $installed[] = $row['pfile'];
5141 $files = scandir($DIR_PLUGINS);
5143 $candidates = array();
5144 foreach ( $files as $file )
5146 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5148 if ( !in_array($matches[1], $installed) )
5150 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5154 $this->newPlugCandidates = $candidates;
5155 return (count($candidates) > 0);
5159 * AdminActions::pagehead()
5160 * Output admin page head
5165 public function parse_pagehead()
5167 global $member, $nucleus, $CONF, $manager;
5169 /* HTTP 1.1 application for no caching */
5170 header("Cache-Control: no-cache, must-revalidate");
5171 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5173 $content = $this->parser->skin->getContentFromDB('pagehead');
5176 $root_element = 'html';
5177 $charset = i18n::get_current_charset();
5178 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5179 $xml_version_info = self::$xml_version_info;
5180 $formal_public_identifier = self::$formal_public_identifier;
5181 $system_identifier = self::$system_identifier;
5182 $xhtml_namespace = self::$xhtml_namespace;
5184 $content = "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n"
5185 . "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n"
5186 . "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n"
5188 . "<title><%sitevar(name)%> - Admin</title>\n"
5189 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>"
5190 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>"
5191 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>"
5195 . "<div id=\"adminwrapper\">"
5196 . "<div class=\"header\">"
5197 . "<h1><%sitevar(name)%></h1>"
5199 . "<div id=\"container\">"
5200 . "<div id=\"content\">"
5201 . "<div class=\"loginname\">"
5202 . "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"<%skinfile(admin/defaultadmin/styles/addedit.css%>\" />\n"
5203 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>\n"
5204 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>\n"
5205 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>\n"
5210 . "<div id=\"adminwrapper\">\n"
5211 . "<div class=\"header\">\n"
5212 . "<h1><%sitevar(name)%></h1>\n"
5214 . "<div id=\"container\">\n"
5215 . "<div id=\"content\">\n"
5216 . "<div class=\"loginname\">\n"
5217 . "<%if(loggedin)%>"
5218 . "<%text(_LOGGEDINAS)%> <%member(yourrealname)%> - <a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a><br />"
5219 . "<a href=\"<%adminurl%>index.php?action=overview\"><%text(_ADMINHOME)%></a> - "
5221 . "<a href=\"<%adminurl%>index.php?action=showlogin\" title=\"Log in\"><%text(_NOTLOGGEDIN)%></a><br />"
5223 . "<a href=\"<%sitevar(url)%>\"><%text(_YOURSITE)%></a><br />"
5225 . "<%if(superadmin)%>"
5226 . "<a href=\"<%versioncheckurl%>\" title=\"<%text(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE)%>\"><%version%><%codename%></a>"
5227 . "<%newestcompare%><%else%><%version%><%codename%>"
5233 $this->parser->parse($content);
5238 * AdminActionss::pagefoot()
5239 * Output admin page foot include quickmenu
5244 public function parse_pagefoot()
5246 global $action, $member, $manager, $blogid;
5249 'action' => Admin::getAdminAction()
5251 $manager->notify('AdminPrePageFoot', $data);
5253 $content = $this->parser->skin->getContentFromDB('pagefoot');
5256 $content = "<%if(loggedin)%>"
5257 . "<%ifnot(adminaction,showlogin)%>"
5258 . "<h2><%text(_LOGOUT)%></h2>"
5260 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_BACKHOME)%></a></li>"
5261 . "<li><a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a></li>"
5265 . "<div class=\"foot\">"
5266 . "<a href=\"<%text(_ADMINPAGEFOOT_OFFICIALURL)%>\">Nucleus CMS</a> © 2002- <%date(%Y)%> <%text(_ADMINPAGEFOOT_COPYRIGHT)%>"
5267 . " - <a href=\"<%text(_ADMINPAGEFOOT_DONATEURL)%>\"><%text(_ADMINPAGEFOOT_DONATE)%></a>"
5270 . "<!-- content -->"
5271 . "<div id=\"quickmenu\">"
5272 . "<%if(loggedin)%>"
5273 . "<%ifnot(adminaction,showlogin)%>"
5275 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_QMENU_HOME)%></a></li>"
5277 . "<h2><%text(_QMENU_ADD)%></h2>"
5278 . "<form method=\"get\" action=\"<%adminurl%>index.php\">"
5280 . "<input type=\"hidden\" name=\"action\" value=\"createitem\" />"
5281 . "<%qmenuaddselect(admin/default)%>"
5284 . "<h2><%member(yourrealname)%></h2>"
5286 . "<li><a href=\"<%adminurl%>index.php?action=editmembersettings\"><%text(_QMENU_USER_SETTINGS)%></a></li>"
5287 . "<li><a href=\"<%adminurl%>index.php?action=browseownitems\"><%text(_QMENU_USER_ITEMS)%></a></li>"
5288 . "<li><a href=\"<%adminurl%>index.php?action=browseowncomments\"><%text(_QMENU_USER_COMMENTS)%></a></li>"
5290 . "<%if(superadmin)%>"
5291 . "<h2><%text(_QMENU_MANAGE)%></h2>"
5293 . "<li><a href=\"<%adminurl%>index.php?action=actionlog\"><%text(_QMENU_MANAGE_LOG)%></a></li>"
5294 . "<li><a href=\"<%adminurl%>index.php?action=settingsedit\"><%text(_QMENU_MANAGE_SETTINGS)%></a></li>"
5295 . "<li><a href=\"<%adminurl%>index.php?action=systemoverview\"><%text(_QMENU_MANAGE_SYSTEM)%></a></li>"
5296 . "<li><a href=\"<%adminurl%>index.php?action=usermanagement\"><%text(_QMENU_MANAGE_MEMBERS)%></a></li>"
5297 . "<li><a href=\"<%adminurl%>index.php?action=createnewlog\"><%text(_QMENU_MANAGE_NEWBLOG)%></a></li>"
5298 . "<li><a href=\"<%adminurl%>index.php?action=backupoverview\"><%text(_QMENU_MANAGE_BACKUPS)%></a></li>"
5299 . "<li><a href=\"<%adminurl%>index.php?action=pluginlist\"><%text(_QMENU_MANAGE_PLUGINS)%></a></li>"
5301 . "<h2><%text(_QMENU_LAYOUT)%></h2>"
5303 . "<li><a href=\"<%adminurl%>index.php?action=skinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5304 . "<li><a href=\"<%adminurl%>index.php?action=templateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5305 . "<li><a href=\"<%adminurl%>index.php?action=skinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5307 . "<h2><%text(_SKINABLEADMIN_QMENU_LAYOUT)%></h2>"
5309 . "<li><a href=\"<%adminurl%>index.php?action=adminskinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5310 . "<li><a href=\"<%adminurl%>index.php?action=admintemplateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5311 . "<li><a href=\"<%adminurl%>index.php?action=adminskinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5314 . "<%quickmenu(admin/default)%>"
5316 . "<%elseif(adminaction,activate)%>"
5317 . "<h2><%text(_QMENU_ACTIVATE)%></h2>"
5318 . "<%text(_QMENU_ACTIVATE_TEXT)%>"
5319 . "<%elseif(adminaction,activatesetpwd)%>"
5320 . "<h2><%text(_QMENU_ACTIVATE)%></h2><%text(_QMENU_ACTIVATE_TEXT)%>"
5322 . "<h2><%text(_QMENU_INTRO)%></h2><%text(_QMENU_INTRO_TEXT)%>"
5325 . "<!-- content / quickmenu container -->"
5326 . "<div class=\"clear\"></div>"
5329 . "<!-- adminwrapper -->"
5333 . "<p style=\"text-align:right;\"><%benchmark%></p>"
5338 $this->parser->parse($content);
5342 * AdminActions::selectBlog()
5343 * Inserts a HTML select element with choices for all blogs to which the user has access
5344 * mode = 'blog' => shows blognames and values are blogids
5345 * mode = 'category' => show category names and values are catids
5347 * @param string $name
5348 * @param string $mode
5349 * @param integer $selected
5350 * @param integer $tabindex
5351 * @param integer $showNewCat
5352 * @param integer $iForcedBlogInclude ID for weblog always included
5353 * @param $iForcedBlogInclude
5354 * ID of a blog that always needs to be included, without checking if the
5355 * member is on the blog team (-1 = none)
5358 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5360 global $member, $CONF;
5362 // 0. get IDs of blogs to which member can post items (+ forced blog)
5363 $aBlogIds = array();
5364 if ( $iForcedBlogInclude != -1 )
5366 $aBlogIds[] = intval($iForcedBlogInclude);
5369 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5371 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5372 $query = sprintf($query, sql_table('blog'));
5376 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5377 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5380 $rblogids = DB::getResult($query);
5381 foreach ( $rblogids as $row )
5383 if ( $row['bnumber'] != $iForcedBlogInclude )
5385 $aBlogIds[] = intval($row['bnumber']);
5389 if ( count($aBlogIds) == 0 )
5394 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5396 // 1. select blogs (we'll create optiongroups)
5397 // (only select those blogs that have the user on the team)
5398 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5399 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5400 $blogs = DB::getResult($queryBlogs);
5402 if ( $mode == 'category' )
5404 if ( $blogs->rowCount() > 1 )
5408 foreach ( $blogs as $rBlog )
5410 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5412 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5415 // show selection to create new category when allowed/wanted
5418 // check if allowed to do so
5419 if ( $member->blogAdminRights($rBlog['bnumber']) )
5421 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5425 // 2. for each category in that blog
5426 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5427 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5428 $categories = DB::getResult($catQuery);
5429 foreach ( $categories as $rCat )
5431 if ( $rCat['catid'] == $selected )
5433 $selectText = ' selected="selected" ';
5439 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5442 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5450 foreach ( $blogs as $rBlog )
5452 echo '<option value="' . $rBlog['bnumber'] . '"';
5453 if ( $rBlog['bnumber'] == $selected )
5455 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5459 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";