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,
1214 'extra' => Entity::hsc(_MEMBERS_USESITELANG)
1216 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1221 * AdminActions::parse_defbookmarkletselect()
1222 * Parse skinvar defbookmarkletselect
1224 * @param string $template_name name of template to use
1227 public function parse_defbookmarkletselect($template_name)
1229 global $CONF, $action;
1231 if ( $action == 'editmembersettings' )
1234 $default = $member->bookmarklet;
1236 elseif ( $action == 'memberedit' )
1239 $mem = $manager->getMember(intRequestVar('memberid'));
1240 $default = $mem->bookmarklet;
1244 $default = $CONF['BookmarkletSkin'];
1247 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1248 $query = sprintf($query, sql_table('skin_desc'));
1251 'name' => 'bookmarklet',
1252 'tabindex' => 10085,
1253 'selected' => $default,
1254 'extra' => Entity::hsc(_MEMBERS_USESITELANG)
1256 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1261 * AdminActions::parse_batchdeletetype()
1262 * Parse skinvar batchdeletetype
1267 public function parse_batchdeletetype()
1269 echo Entity::hsc(requestVar('action'));
1274 * AdminActions::parse_batchmovebtn()
1275 * Parse skinvar batchmovebtn
1280 public function parse_batchmovebtn()
1282 $actionType = requestVar('action');
1283 switch ( $actionType )
1288 case 'batchcategory':
1296 * AdminActions::parse_batchmovelist()
1297 * Parse skinvar batchmovelist
1302 public function parse_batchmovelist()
1304 $selected = requestIntArray('batch');
1306 foreach ( $selected as $select )
1308 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1315 * AdminActions::parse_batchmovetitle()
1316 * Parse skinvar batchmovetitle
1321 public function parse_batchmovetitle()
1323 $actionType = requestVar('action');
1324 switch ( $actionType )
1329 case 'batchcategory':
1330 echo _MOVECAT_TITLE;
1337 * AdminActions::parse_batchmovetype()
1338 * Parse skinvar batchmovetype
1343 public function parse_batchmovetype()
1345 echo Entity::hsc(requestVar('action'));
1350 * AdminActions::parse_blogcatlist()
1351 * Parse skinvar blogcatlist
1356 public function parse_blogcatlist($template_name = '')
1359 $blogid = intRequestVar('blogid');
1360 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1361 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1363 $resource = DB::getResult($query);
1364 if ( $resource->rowCount() > 0 )
1366 $template['content'] = 'categorylist';
1367 $template['tabindex'] = 200;
1368 $this->parser->parse(listplug_batchlist('category', $resource, 'table', $template));
1372 /* TODO: nothing to be shown */
1374 $resource->closeCursor();
1380 * AdminActions::parse_blogid()
1381 * Parse skinvar blogid
1386 public function parse_blogid()
1388 echo intRequestVar('blogid');
1393 * AdminActions::parse_blognotifysetting()
1394 * Parse skinvar blognotifysetting
1399 public function parse_blognotifysetting($type)
1402 $blogid = intRequestVar('blogid');
1403 $blog =& $manager->getBlog($blogid);
1408 if ( !$blog->notifyOnComment() )
1414 if ( !$blog->notifyOnVote() )
1420 if ( !$blog->notifyOnNewItem() )
1426 echo ' checked="checked"';
1431 * AdminActions::parse_blogsetting()
1432 * Parse skinvar blogsetting
1434 * @param string $which name of weblog setting
1437 public function parse_blogsetting($which)
1439 echo $this->parse_getblogsetting($which);
1444 * AdminActions::parse_blogsettingyesno()
1445 * Parse skinvar blogsettingyesno
1447 * @param string $type type of weblog setting
1448 * @param string $template_name name of template to use
1451 public function parse_blogsettingyesno($type, $template_name = '')
1455 $blogid = intRequestVar('blogid');
1456 $blog =& $manager->getBlog($blogid);
1460 case 'convertbreaks':
1461 $checkedval = $blog->convertBreaks();
1464 case 'allowpastposting':
1465 $checkedval = $blog->allowPastPosting();
1469 $checkedval = $blog->commentsEnabled();
1473 $checkedval = $blog->isPublic();
1477 $checkedval = $blog->emailRequired();
1481 $checkedval = $blog->getSearchable();
1485 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $template_name);
1490 * AdminActions::parse_blogteamlist()
1491 * Parse skinvar blogteamlist
1493 * @param string $template_name name of template to use
1496 public function parse_blogteamlist($template_name = '')
1499 $blogid = intRequestVar('blogid');
1500 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1502 . "WHERE tmember=mnumber AND tblog= %d";
1503 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1505 $resource = DB::getResult($query);
1506 if ( $resource->rowCount() > 0 )
1508 $template['content'] = 'teamlist';
1509 $template['tabindex'] = 10;
1511 $this->parser->parse(listplug_batchlist('team', $resource, 'table', $template));
1517 $resource->closeCursor();
1523 * AdminActions::parse_blogteammembers()
1524 * Parse skinvar blogteammembers
1529 public function parse_blogteammembers()
1531 $blogid = intRequestVar('blogid');
1532 $query = "SELECT mname, mrealname "
1534 . "WHERE mnumber=tmember AND tblog=%d;";
1535 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1536 $res = DB::getResult($query);
1537 $memberNames = array();
1538 foreach ( $res as $row )
1540 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1542 echo implode(',', $memberNames);
1546 * AdminActions::parse_blogtime()
1547 * Parse skinvar blogtime
1549 * @param string $type type of time
1550 * @param string $format format for time expression
1551 * @param integer $offset offset of time
1554 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1558 if ( $type != 'blogtime' )
1560 /* return server time */
1561 $timestamp = time() + $offset;
1565 $bid = intRequestVar('blogid');
1566 $b =& $manager->getBlog($bid);
1567 $timestamp = $b->getCorrectTime() + $offset;
1570 echo i18n::formatted_datetime($format, $timestamp);
1575 * AdminActions::parse_bookmarkletadmin()
1576 * Parse skinvar bookmarkletadmin
1581 public function parse_bookmarkletadmin()
1585 $blogid = intRequestVar('blogid');
1587 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1592 * AdminActions::parse_categories()
1593 * Parse skinvar categories
1595 * create category dropdown box
1597 * @param string $type name of setting for category
1600 public function parse_categories($startidx = 0)
1604 if ( !array_key_exists('catid', Admin::$contents) || empty(Admin::$contents['catid']) )
1606 $catid = Admin::$blog->getDefaultCategory();
1610 $catid = Admin::$contents['catid'];
1613 $this->selectBlog('catid', 'category', $catid, $startidx, 1, Admin::$blog->getID());
1619 * AdminActions::parse_categorysetting()
1620 * Parse skinvar categorysetting
1622 * @param string $type type in category setting
1625 public function parse_categorysetting($type)
1627 $catid = intRequestVar('catid');
1628 if ( $type == 'id' )
1633 $blogid = intRequestVar('blogid');
1634 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1635 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1636 $row = DB::getRow($query);
1638 if ( $type != 'name' )
1640 echo Entity::hsc($row['cdesc']);
1644 echo Entity::hsc($row['cname']);
1651 * AdminActions::parse_codename()
1652 * Parse templatevar codename
1658 public function parse_checkedonval($value, $name)
1663 $itemid = intRequestVar('itemid');
1664 $item =& $manager->getItem($itemid, 1, 1);
1668 $blog =& $manager->getBlog($item['blogid']);
1670 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1672 $item['body'] = removeBreaks($item['body']);
1673 $item['more'] = removeBreaks($item['more']);
1677 $contents = array();
1678 if ( requestVar('action') == 'itemedit' )
1682 if ( !isset($contents[$name]) )
1684 $contents[$name] = '';
1686 if ($contents[$name] == $value)
1688 echo 'checked="checked"';
1694 * AdminActions::parse_codename()
1695 * Parse templatevar codename
1700 * TODO: is this need???
1702 public function parse_codename()
1705 echo $nucleus['codename'];
1710 * AdminActions::parse_commentnavlist()
1711 * Parse skinvar commentnavlist
1716 public function parse_commentnavlist()
1718 global $CONF, $manager, $member;
1721 if ( postVar('start') )
1723 $start = intPostVar('start');
1730 // amount of items to show
1731 if ( postVar('amount') )
1733 $amount = intPostVar('amount');
1737 $amount = (integer) $CONF['DefaultListSize'];
1743 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1745 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
1747 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1749 if ( $this->skintype == 'itemcommentlist' )
1751 $itemid = intRequestVar('itemid');
1752 $query .= " citem={$itemid}";
1753 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1755 $nonComments = _NOCOMMENTS;
1757 elseif ( $this->skintype == 'browseowncomments' )
1760 $query .= ' cmember=' . $member->getID();
1761 $template['canAddBan'] = 0;
1763 $nonComments = _NOCOMMENTS_YOUR;
1765 elseif ( $this->skintype == 'blogcommentlist' )
1768 $query .= ' cblog=' . intRequestVar('blogid');
1769 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1770 $bid = intRequestVar('blogid');
1771 $nonComments = _NOCOMMENTS_BLOG;
1774 $search = postVar('search');
1775 if ( !empty($search) )
1777 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
1780 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1782 $resource = DB::getResult($query);
1783 if ( $resource->rowCount() > 0 )
1785 $template['action'] = $this->skintype;
1786 $template['start'] = $start;
1787 $template['amount'] = $amount;
1788 $template['minamount'] = 0;
1789 $template['maxamount'] = 1000;
1790 $template['blogid'] = $bid;
1791 $template['search'] = $search;
1792 $template['itemid'] = $itemid;
1794 $template['content'] = 'commentlist';
1796 $this->parser->parse(listplug_navlist('comment', $resource, 'table', $template));
1800 /* TODO: nothing to be shown */
1802 $resource->closeCursor();
1808 * AdminActions::parse_configsettingsedit()
1809 * Parse skinvar configsettingsedit
1811 * @param string $type type of global configuration
1814 public function parse_configsettingsedit($type)
1819 case 'DefaultListSize':
1820 if ( !array_key_exists('DefaultListSize', $CONF) )
1822 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1823 $query = sprintf($query, sql_table('config'));
1824 DB::execute($query);
1825 $CONF['DefaultListSize'] = 10;
1827 elseif ( intval($CONF['DefaultListSize']) < 1 )
1829 $CONF['DefaultListSize'] = 10;
1831 echo intval($CONF['DefaultListSize']);
1833 case 'SessionCookie':
1834 $value = $CONF['SessionCookie'];
1835 $txt1 = _SETTINGS_COOKIESESSION;
1836 $txt2 = _SETTINGS_COOKIEMONTH;
1837 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1840 $value = $CONF['URLMode'];
1841 $txt1 = _SETTINGS_URLMODE_NORMAL;
1842 $txt2 = _SETTINGS_URLMODE_PATHINFO;
1843 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1846 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1848 echo Entity::hsc($CONF[$type]);
1856 * AdminActions::parse_configsettingsyesno()
1857 * Parse skinvar configsettingsyesno
1859 * @param string $type type of global setting
1860 * @param integer $tabindex tabindex attribute of input element
1863 public function parse_configsettingsyesno($type, $tabindex)
1866 if ( array_key_exists($type, $CONF) )
1868 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1874 * AdminActions::parse_contents()
1875 * Parse skinvar contents
1877 * @param string $which part for item
1880 public function parse_contents($which)
1882 if ( !array_key_exists($which, Admin::$contents) )
1884 Admin::$contents[$which] = '';
1886 echo Entity::hsc(Admin::$contents[$which]);
1890 * AdminActions::parse_currenttime()
1891 * Parse skinvar currenttime
1893 * @param string $what
1896 public function parse_currenttime($what)
1898 $nu = getdate(Admin::$blog->getCorrectTime());
1903 * AdminActions::parse_customhelplink()
1904 * Parse skinvar customhelplink
1906 * @param string $topic name of topic
1907 * @param string $tplName name of template
1908 * @param string $url string as URI
1909 * @param string $iconURL string as URI for icon
1910 * @param string $alt alternative text for image element
1911 * @param string $title title for anchor element
1914 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1916 $this->customHelp($topic, $url, $iconURL);
1921 * AdminActions::parse_date()
1922 * Parse skinvar date
1924 public function parse_date($format = 'c')
1926 global $CONF, $manager;
1927 /* TODO: offset is based on i18n::get_current_locale()? */
1928 echo i18n::formatted_datetime($format, time());
1933 * AdminActions::parse_normalskinlist()
1934 * Parse skinvar defaultadminskintypes
1936 * @param string $template_name name of template
1939 public function parse_normalskinlist($template_name = '')
1941 global $CONF, $manager;
1943 if ( !preg_match('#^admin#', $this->skintype) )
1945 $skin =& $manager->getSkin($CONF['BaseSkin']);
1946 /* TODO: removeaction? */
1947 $template['editaction'] = 'skinedittype';
1951 $skin =& $manager->getSkin($CONF['AdminSkin'], 'AdminActions');
1952 $template['editaction'] = 'adminskinedittype';
1953 /* TODO: removeaction? */
1956 $temporary = $skin->getDefaultTypes();
1957 $normal_skintype = array();
1958 foreach ( $temporary as $type => $label )
1960 $normal_skintype[] = array(
1961 'skintype' => $type,
1962 'skintypename' => $label
1966 $template['tabindex'] = 10;
1967 $template['skinid'] = $skin->getID();
1968 $template['skinname'] = $skin->getName();
1969 $this->parser->parse(showlist($normal_skintype, 'list_normalskinlist', $template, $template_name));
1975 * AdminActions::parse_defblogselect()
1976 * Parse skinvar defblogselect
1978 * @param string $template_name name of template
1981 public function parse_defblogselect($template_name = '')
1985 $query = "SELECT bname as text, bnumber as value FROM %s;";
1986 $query = sprintf($query, sql_table('blog'));
1988 $template['name'] = 'DefaultBlog';
1989 $template['selected'] = $CONF['DefaultBlog'];
1990 $template['tabindex'] = 10;
1991 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1997 * AdminActions::parse_defcatselect()
1998 * Parse skinvar defcatselect
2000 * @param string $template_name name of template
2003 public function parse_defcatselect($template_name = '')
2007 $blogid = intRequestVar('blogid');
2008 $blog =& $manager->getBlog($blogid);
2010 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2011 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2013 $template['name'] = 'defcat';
2014 $template['selected'] = $blog->getDefaultCategory();
2015 $template['tabindex'] = 110;
2017 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2023 * AdminActions::parse_defskinselect()
2024 * Parse skinvar defskinselect
2026 * @param string $type type of skin
2027 * @param string $template_name name of template
2030 public function parse_defskinselect($type = 'blog', $template_name = '')
2032 global $CONF, $manager, $member;
2034 if ( !preg_match('#^admin#', $this->skintype) )
2036 $blogid = intRequestVar('blogid');
2039 $template['selected'] = $CONF['BaseSkin'];
2043 $blog =& $manager->getBlog($blogid);
2044 $template['selected'] = $blog->getDefaultSkin();
2047 if ( $type != 'blog' )
2049 $template['name'] = 'BaseSkin';
2053 $template['name'] = 'defskin';
2056 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2060 /* TODO: member object will have its own adminskin id */
2061 $template['selected'] = $CONF['AdminSkin'];
2062 $template['name'] = 'AdminSkin';
2063 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
2066 $query = sprintf($query, sql_table('skin_desc'));
2067 $template['tabindex'] = 50;
2069 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2075 * AdminActions::parse_deletecomment()
2076 * Parse skinvar deletecomment
2078 * @param string $type type of infomation for comment
2081 public function parse_deletecomment($type = 'id')
2083 $commentid = intRequestVar('commentid');
2084 $comment = COMMENT::getComment($commentid);
2089 echo intRequestVar('commentid');
2092 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2094 echo $comment['member'];
2098 echo $comment['user'];
2102 $body = strip_tags($comment['body']);
2103 echo Entity::hsc(shorten($body, 300, '...'));
2109 * AdminActions::parse_deleteitembody()
2110 * Parse skinvar deleteitembody
2115 public function parse_deleteitembody()
2119 $itemid = intRequestVar('itemid');
2120 $item =& $manager->getItem($itemid, 1, 1);
2122 $body = strip_tags($item['body']);
2124 echo Entity::hsc(shorten($body, 300, '...'));
2130 * AdminActions::parse_deleteitemid()
2131 * Parse skinvar deleteitemid
2136 public function parse_deleteitemid()
2138 echo (integer) intRequestVar('itemid');
2143 * AdminActions::parse_deleteitemtitle()
2144 * Parse skinvar deleteitemtitle
2149 public function parse_deleteitemtitle()
2153 $itemid = intRequestVar('itemid');
2154 $item =& $manager->getItem($itemid, 1, 1);
2156 echo Entity::hsc(strip_tags($item['title']));
2162 * AdminActions::parse_editcomment()
2163 * Parse skinvar editcomment
2165 * @param string $type type of comment setting
2168 public function parse_editcomment($type = 'id')
2172 $comment = Admin::$contents;
2177 echo intRequestVar('commentid');
2180 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2182 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2186 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2190 echo date("Y-m-d @ H:i", $comment['timestamp']);
2193 $comment['body'] = str_replace('<br />', '', $comment['body']);
2194 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2195 echo $comment['body'];
2198 echo $comment['userid'];
2201 echo $comment['userid'];
2204 if ( array_key_exists($type, $comment) && !empty($comment[$type]) )
2206 echo $comment[$type];
2214 * AdminActions::parse_editdesturl()
2215 * Parse skinvar editdesturl
2217 public function parse_editdesturl()
2219 if ( requestVar('desturl') )
2221 echo Entity::hsc(requestVar('desturl'));
2227 * AdminActions::parse_editmemberlist()
2228 * Parse skinvar editmemberlist
2230 * @param string $template_name name of template
2233 public function parse_editmemberlist($template_name = '')
2236 // show list of members with actions
2237 $query = 'SELECT * FROM %s;';
2238 $query = sprintf($query, sql_table('member'));
2240 $resource = DB::getResult($query);
2241 if ( $resource->rowCount() > 0 )
2243 $template['content'] = 'memberlist';
2244 $template['tabindex'] = 10;
2246 $this->parser->parse(listplug_batchlist('member', $resource, 'table', $template));
2252 $resource->closeCursor();
2258 * AdminActions::parse_editmember()
2259 * Parse skinvar editmember
2261 * @param string $type type of information for member
2262 * @return string $tempateName name of template to use
2265 public function parse_editmember($type = 'id', $template_name = '')
2267 global $CONF, $manager, $member;
2269 $memberid = intRequestVar('memberid');
2270 $mem =& $manager->getMember($memberid);
2275 echo intRequestVar('memberid');
2278 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2280 echo Entity::hsc($mem->getDisplayName());
2284 $dispName = Entity::hsc($mem->getDisplayName());
2285 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2287 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2296 echo Entity::hsc($mem->getRealName());
2299 echo Entity::hsc($mem->getEmail());
2302 echo Entity::hsc($mem->getURL());
2305 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $template_name);
2308 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $template_name);
2311 echo Entity::hsc($mem->getNotes());
2314 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $template_name);
2323 * AdminActions::parse_editpluginfo()
2324 * Parse skinvar editpluginfo
2326 * @param string $type type of plugin info
2329 public function parse_editpluginfo($type)
2333 $pid = intRequestVar('plugid');
2340 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2347 * AdminActions::parse_editplugoptionslist()
2348 * Parse skinvar editplugoptionslist
2350 * @param string $template_name name of template
2353 public function parse_editplugoptionslist($template_name = '')
2357 $pid = intRequestVar('plugid');
2358 $aOptions = array();
2361 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2362 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2363 $resource = DB::getResult($query);
2365 foreach ( $resource as $row )
2367 $aOIDs[] = $row['oid'];
2368 $aOptions[$row['oid']] = array(
2369 'oid' => $row['oid'],
2370 'value' => $row['odef'],
2371 'name' => $row['oname'],
2372 'description' => $row['odesc'],
2373 'type' => $row['otype'],
2374 'typeinfo' => $row['oextra'],
2379 // fill out actual values
2380 if ( count($aOIDs) > 0 )
2382 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2383 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2385 $result = DB::getResult($query);
2386 foreach ( $result as $row )
2388 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2394 'context' => 'global',
2396 'options' => &$aOptions
2398 $manager->notify('PrePluginOptionsEdit', $data);
2400 if ( sizeof($aOptions) > 0 )
2402 $template['content'] = 'plugoptionlist';
2403 $this->parser->parse(showlist($aOptions, 'table', $template, $template_name));
2407 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2413 * AdminActions::parse_editskin()
2414 * Parse skinvar editskin
2416 * @param string $type type of skin
2419 public function parse_editskin($type = 'id')
2423 $skinid = intRequestVar('skinid');
2425 if ( !preg_match('#^admin#', $this->skintype) )
2427 $skin =& $manager->getSKIN($skinid);
2431 $skin =& $manager->getSKIN($skinid, 'AdminActions');
2437 echo intRequestVar('skinid');
2440 echo Entity::hsc($skin->getName());
2443 echo Entity::hsc($skin->getDescription());
2446 echo Entity::hsc($skin->getContentType());
2449 echo Entity::hsc($skin->getIncludePrefix());
2452 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2460 * AdminActions::parse_editskintype()
2461 * Parse skinvar editskintype
2463 * @param string $type name of type for skin type
2466 public function parse_editskintype($stype = 'id')
2470 static $skin = NULL;
2471 static $types = array();
2473 if ( $skin == NULL )
2475 $skinid = intRequestVar('skinid');
2477 if ( !preg_match('#^admin#', $this->skintype) )
2479 $skin =& $manager->getSkin($skinid);
2483 $skin =& $manager->getSkin($skinid, 'AdminActions');
2486 $types = $skin->getDefaultTypes();
2489 $type = strtolower(trim(requestVar('type')));
2494 echo $skin->getID();
2497 echo Entity::hsc($skin->getName());
2500 echo Entity::hsc($skin->getDescription());
2503 echo Entity::hsc($skin->getContentType());
2506 echo Entity::hsc($skin->getContentFromDB($type));
2509 if ( !array_key_exists($type, $types) )
2511 $skinType = ucfirst($type);
2515 $skinType = $types[$type];
2517 echo Entity::hsc($skinType);
2520 echo Entity::hsc($type);
2523 echo Entity::hsc($skin->getIncludePrefix());
2526 if ( !$skin->getIncludeMode() != 'skindir' )
2528 $incMode = _PARSER_INCMODE_NORMAL;
2532 $incMode = _PARSER_INCMODE_SKINDIR;
2534 echo Entity::hsc($incMode);
2543 * AdminActions::parse_adminurl()
2544 * Parse skinvar adminurl
2545 * (shortcut for admin url)
2550 public function parse_adminurl()
2552 $this->parse_sitevar('adminurl');
2557 * AdminActions::parse_edittemplateinfo()
2558 * Parse skinvar edittemplateinfo
2560 * @param string $format format to output
2561 * @param string $typedesc type of template
2562 * @param string $typename type name of template
2563 * @param string $help help text
2564 * @param string $tabindex index value for tabindex attribute of input element
2565 * @param string $big textarea size
2566 * @param string $tplt name of template to be filled
2569 public function parse_edittemplateinfo($format, $typedesc = '', $typename = '', $help = '', $tabindex = 0, $big = 0, $template_name = '')
2573 static $name = NULL;
2574 static $desc = NULL;
2578 $id = intRequestVar('templateid');
2581 if ( $name == NULL )
2583 $name = Template::getNameFromId($id);
2586 if ( $desc == NULL )
2588 $desc = Template::getDesc($id);
2591 $template =& $manager->getTemplate($name);
2599 echo Entity::hsc($name);
2602 echo Entity::hsc($desc);
2604 case 'extratemplate':
2606 $pluginfields = array();
2607 if ( !preg_match('#^admin/#', $this->skintype) )
2609 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2613 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
2616 foreach ( $pluginfields as $ptkey => $ptvalue )
2621 $tmplt =& $manager->getTemplate($desc);
2624 /* extra plugin field */
2625 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2629 . "<th colspan=\"2\"><%explugtplname%></th>\n";
2633 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2636 'explugtplname' => Entity::hsc($ptkey)
2638 echo Template::fill($base, $data);
2640 foreach ( $ptvalue as $ptname => $ptdesc )
2642 if ( !array_key_exists($ptname, $template) )
2648 $content = $template[$ptname];
2650 $this->parser->parse(listplug_templateEditRow($content, $ptdesc, $ptname, $help, $tabidx++, $big, $template_name));
2656 $typedesc = defined($typedesc) ? constant($typedesc) : $typedesc;
2657 $typename = defined($typename) ? constant($typename) : $typename;
2659 if ( !array_key_exists($typename, $template) )
2665 $content = $template[$typename];
2667 $this->parser->parse(listplug_templateEditRow($content, $typedesc, $typename, $help, $tabindex, $big, $template_name));
2675 * AdminActions::parse_eventformextra()
2676 * Parse skinvar eventformextra
2678 * @param string $type name of type for event form extra
2681 public function parse_eventformextra($type = 'activation')
2690 $key = requestVar('ackey');
2693 Admin::error(_ERROR_ACTIVATE);
2695 $info = MEMBER::getActivationInfo($key);
2698 Admin::error(_ERROR_ACTIVATE);
2700 $mem =& $manager->getMember($info->vmember);
2703 Admin::error(_ERROR_ACTIVATE);
2706 'type' => 'activation',
2710 case 'membermailform-notloggedin':
2711 $data = array('type' => 'membermailform-notloggedin',);
2714 $manager->notify('FormExtra', $data);
2719 * AdminActions::parse_extrahead()
2720 * Parse skinvar extrahead
2722 public function parse_extrahead()
2726 $extrahead = Admin::getAdminextrahead();
2729 'extrahead' => &$extrahead,
2730 'action' => Admin::getAdminAction()
2733 $manager->notify('AdminPrePageHead', $data);
2735 $this->parser->parse($extrahead);
2740 * AdminActions::parse_member()
2741 * Parse skinvar member
2742 * (includes a member info thingie)
2744 * @param string $what which memberdata is needed
2747 public function parse_member($what)
2749 global $memberinfo, $member, $CONF;
2751 // 1. only allow the member-details-page specific variables on member pages
2752 if ( $this->skintype == 'member' )
2757 echo Entity::hsc($memberinfo->getDisplayName());
2760 echo Entity::hsc($memberinfo->getRealName());
2763 echo Entity::hsc($memberinfo->getNotes());
2766 echo Entity::hsc($memberinfo->getURL());
2769 echo Entity::hsc($memberinfo->getEmail());
2772 echo Entity::hsc($memberinfo->getID());
2777 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2778 if ( $member->isLoggedIn() )
2783 echo $member->getDisplayName();
2785 case 'yourrealname':
2786 echo $member->getRealName();
2789 echo $member->getNotes();
2792 echo $member->getURL();
2795 echo $member->getEmail();
2798 echo $member->getID();
2800 case 'yourprofileurl':
2801 if ( $CONF['URLMode'] == 'pathinfo' )
2803 echo Link::create_member_link($member->getID());
2807 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
2816 * AdminActions::parse_version()
2817 * Parse skinvar version
2818 * (include nucleus versionnumber)
2823 public function parse_version()
2826 echo 'Nucleus CMS ' . $nucleus['version'];
2831 * AdminActions::parse_sitevar()
2832 * Parse skinvar sitevar
2833 * (include a sitevar)
2835 * @param string $which
2838 public function parse_sitevar($which)
2844 echo $CONF['IndexURL'];
2847 echo $CONF['SiteName'];
2850 echo $CONF['AdminEmail'];
2853 echo $CONF['AdminURL'];
2860 * AdminActions::parse_actionurl()
2866 public function parse_actionurl()
2869 echo Entity::hsc($CONF['ActionURL']);
2874 * AdminActions::parse_getblogsetting()
2875 * Parse skinvar getblogsetting
2877 public function parse_getblogsetting($which)
2879 global $blog, $manager;
2885 elseif ( $bid = intRequestVar('blogid') )
2887 $b =& $manager->getBlog($bid);
2897 return Entity::hsc($b->getID());
2900 return Entity::hsc($b->getURL());
2903 return Entity::hsc($b->getName());
2906 return Entity::hsc($b->getDescription());
2909 return Entity::hsc($b->getShortName());
2911 case 'notifyaddress':
2912 return Entity::hsc($b->getNotifyAddress());
2915 return Entity::hsc($b->getMaxComments());
2918 return Entity::hsc($b->getUpdateFile());
2921 return Entity::hsc($b->getTimeOffset());
2928 * AdminActions::parse_geteditpluginfo()
2929 * Parse skinvar geteditpluginfo
2931 * @param string $type name of setting for edit plugin info
2934 public function parse_geteditpluginfo($type)
2937 $pid = intRequestVar('plugid');
2944 return Entity::hsc($manager->getPluginNameFromPid($pid));
2951 * AdminActions::parse_getmember()
2952 * Parse skinvar getmember
2953 * (includes a member info thingie)
2955 * @param string $what name of setting for member
2958 public function parse_getmember($what)
2960 global $memberinfo, $member;
2961 // 1. only allow the member-details-page specific variables on member pages
2962 if ( $this->skintype == 'member' )
2967 return Entity::hsc($memberinfo->getDisplayName());
2970 return Entity::hsc($memberinfo->getRealName());
2973 return Entity::hsc($memberinfo->getNotes());
2976 return Entity::hsc($memberinfo->getURL());
2979 return Entity::hsc($memberinfo->getEmail());
2982 return Entity::hsc($memberinfo->getID());
2986 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2987 if ( $member->isLoggedIn() )
2992 return $member->getDisplayName();
2994 case 'yourrealname':
2995 return $member->getRealName();
2998 return $member->getNotes();
3001 return $member->getURL();
3004 return $member->getEmail();
3007 return $member->getID();
3015 * AdminActions::parse_headmessage()
3016 * Parse skinvar headmessage
3021 public function parse_headmessage()
3023 if ( !empty(Admin::$headMess) )
3025 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3031 * AdminActions::parse_helplink()
3032 * Parse skinvar helplink
3034 * @param string $topic name of topic for help
3037 public function parse_helplink($topic = '')
3039 if ( !empty($topic) )
3047 * AdminActions::parse_helpplugname()
3048 * Parse skinvar helpplugname
3053 public function parse_helpplugname()
3055 $plugid = intGetVar('plugid');
3056 Entity::hsc($manager->getPluginNameFromPid($plugid));
3061 * AdminActions::parse_ilistaddnew()
3062 * Parse skinvar ilistaddnew
3067 public function parse_ilistaddnew()
3069 $blogid = intRequestVar('blogid');
3070 if ( intPostVar('start') == 0 )
3072 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3078 * AdminActions::parse_importskininfo()
3079 * Parse skinvar importskininfo
3081 * @param string $type name of information for imported skin
3084 public function parse_importskininfo($type)
3089 echo Entity::hsc(requestVar('skininfo'));
3092 $dataArr = requestArray('skinnames');
3093 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3096 $dataArr = requestArray('tpltnames');
3097 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3100 $dataArr = requestArray('skinclashes');
3101 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3104 $dataArr = requestArray('tpltclashes');
3105 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3108 echo Entity::hsc(requestVar('skinfile'));
3111 echo Entity::hsc(requestVar('mode'));
3118 * AdminActions::parse_init()
3119 * some init stuff for all forms
3124 public function parse_init()
3129 if ( requestVar('action') == 'itemedit' )
3131 $authorid = Admin::$contents['authorid'];
3134 Admin::$blog->insertJavaScriptInfo($authorid);
3139 * AdminActions::parse_inputyesno()
3140 * Parse skinvar inputyesno
3142 * @param string $name
3143 * @param string $checkedval
3144 * @param string $tabindex
3145 * @param string $value1
3146 * @param string $value2
3147 * @param string $yesval
3148 * @param string $noval
3149 * @param string $isAdmin
3150 * @param string $template_name
3153 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $template_name = '')
3155 $this->parser->parse(listplug_input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $template_name));
3160 * AdminActions::parse_insertpluginfo()
3161 * Parse templatevar insertpluginfo
3163 public function parse_insertpluginfo($type)
3165 $option = Admin::getAdminaOption();
3169 return $option['pid'];
3172 return Entity::hsc($option['pfile']);
3179 * AdminActions::parse_insplugoptcontent()
3180 * Parse skinvar insplugoptcontent
3185 public function parse_insplugoptcontent()
3187 $option = Admin::getAdminaOption();
3189 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3190 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3193 listplug_plugOptionRow($option);
3200 * AdminActions::parse_iprangeinput()
3201 * Parse skinvar iprangeinput
3206 public function parse_iprangeinput()
3208 if ( requestVar('ip') )
3210 $iprangeVal = Entity::hsc(requestVar('ip'));
3211 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3212 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3213 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3214 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3215 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3219 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3220 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3226 * AdminActions::parse_itemnavlist()
3227 * Parse skinvar itemnavlist
3232 public function parse_itemnavlist($template_name)
3234 global $CONF, $manager, $member;
3236 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3237 . " FROM %s, %s, %s, %s"
3238 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3240 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3242 if ( $this->skintype == 'itemlist' )
3245 if ( array_key_exists('blogid', $_REQUEST) )
3247 $blogid = intRequestVar('blogid');
3249 else if ( array_key_exists('itemid', $_REQUEST) )
3251 $itemid = intRequestVar('itemid');
3252 $item = &$manager->getItem($itemid, 1, 1);
3253 $blogid = (integer) $item['blogid'];
3255 $blog =& $manager->getBlog($blogid);
3257 $query .= " AND iblog={$blogid}";
3258 $template['now'] = $blog->getCorrectTime(time());
3260 // non-blog-admins can only edit/delete their own items
3261 if ( !$member->blogAdminRights($blogid) )
3263 $query .= ' AND iauthor = ' . $member->getID();
3266 elseif ( $this->skintype == 'browseownitems' )
3268 $query .= ' AND iauthor = ' . $member->getID();
3270 $template['now'] = time();
3273 // search through items
3274 $search = postVar('search');
3276 if ( !empty($search) )
3278 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3279 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3280 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3283 if ( postVar('start') )
3285 $start = intPostVar('start');
3292 // amount of items to show
3293 if ( postVar('amount') )
3295 $amount = intPostVar('amount');
3299 $amount = (integer) $CONF['DefaultListSize'];
3306 $query .= ' ORDER BY itime DESC'
3307 . " LIMIT {$start},{$amount}";
3309 $resource = DB::getResult($query);
3310 if ( $resource->rowCount() > 0 )
3312 $template['action'] = $this->skintype;
3313 $template['start'] = $start;
3314 $template['amount'] = $amount;
3315 $template['minamount'] = 0;
3316 $template['maxamount'] = 1000;
3317 $template['blogid'] = $blogid;
3318 $template['search'] = $search;
3319 $template['itemid'] = 0;
3321 $template['content'] = 'itemlist';
3323 $this->parser->parse(listplug_navlist('item', $query, 'table', $template));
3327 /* TODO: nothing to be shown */
3329 $resource->closeCursor();
3335 * AdminActions::parse_itemtime()
3336 * date change on edit item
3338 * @param string $key key of PHP's getDate()
3341 public function parse_itemtime($key)
3346 $itemid = intRequestVar('itemid');
3347 $item =& $manager->getItem($itemid, 1, 1);
3351 $blog =& $manager->getBlog($item['blogid']);
3353 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3355 $item['body'] = removeBreaks($item['body']);
3356 $item['more'] = removeBreaks($item['more']);
3360 $contents = array();
3361 if ( requestVar('action') == 'itemedit' )
3365 elseif ( requestVar('action') == 'createitem' )
3368 'contents' => &$contents,
3369 'blog' => &$this->blog
3371 $manager->notify('PreAddItemForm', $data);
3373 $itemtime = getdate($contents['timestamp']);
3374 echo $itemtime[$key];
3379 * AdminActions::parse_jstoolbaroptions()
3380 * Parse skinvar jstoolbaroptions
3385 public function parse_jstoolbaroptions()
3389 _SETTINGS_JSTOOLBAR_NONE,
3390 _SETTINGS_JSTOOLBAR_SIMPLE,
3391 _SETTINGS_JSTOOLBAR_FULL
3395 foreach ( $options as $option )
3397 $text = "<option value=\"%d\"%s>%s</option>\n";
3398 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3399 echo sprintf($text, $i, $extra, $option);
3405 * AdminActions::parse_localeselectoptions()
3406 * Parse skinvar localeselectoptions
3411 public function parse_localeselectoptions()
3413 global $CONF, $member;
3415 $locales = i18n::get_available_locale_list();
3417 /* default option */
3418 if ( $this->skintype == 'editmembersettings' )
3420 if ( !$member->getLocale() )
\r
3422 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
\r
3426 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
\r
3431 if ( $CONF['Locale'] == 'en_Latn_US' )
\r
3433 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
\r
3437 echo "<option value=\"\">" . Entity::hsc(_LOCALE_EN_LATN_US) . "</option>\n";
\r
3441 /* optional options */
3442 foreach ( $locales as $locale )
3444 if ( $this->skintype == 'editmembersettings' )
\r
3446 if ( $locale != $member->getLocale() )
\r
3448 echo "<option value=\"{$locale}\">";
\r
3452 echo "<option value=\"{$locale}\" selected=\"selected\">";
\r
3457 if ( $locale == 'en_Latn_US' )
3459 /* already output */
3462 else if ( $locale != $CONF['Locale'] )
\r
3464 echo "<option value=\"{$locale}\">";
\r
3468 echo "<option value=\"{$locale}\" selected=\"selected\">";
\r
3471 $label = '_LOCALE_' . strtoupper($locale);
3472 if ( !defined($label) )
3478 echo constant($label);
3480 echo "</option>\n";
\r
3486 * AdminActions::parse_listplugplugoptionrow()
3487 * Parse templatevar listplugplugoptionrow
3489 * @param string $template_name name of template
3492 public function parse_listplugplugoptionrow($template_name = '')
3494 echo listplug_plugOptionRow(Admin::getAdminaOption(), $template_name);
3499 * AdminActions::parse_mediadirwarning()
3500 * Parse skinvar mediadirwarning
3505 public function parse_mediadirwarning()
3508 if ( !is_dir($DIR_MEDIA) )
3510 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3512 if ( !is_readable($DIR_MEDIA) )
3514 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3516 if ( !is_writeable($DIR_MEDIA) )
3518 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3524 * AdminActions::parse_movedistselect()
3525 * Parse skinvar movedistselect
3527 public function parse_movedistselect()
3529 $actionType = requestVar('action');
3530 switch ( $actionType )
3533 $this->selectBlog('destcatid', 'category');
3535 case 'batchcategory':
3536 $this->selectBlog('destblogid');
3539 if ( $this->skintype == 'itemmove' )
3541 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3542 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3543 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3544 $this->selectBlog('catid', 'category', $catid, 10, 1);
3552 * AdminActions::parse_moveitemid()
3553 * Parse skinvar moveitemid
3558 public function parse_moveitemid()
3560 echo intRequestVar('itemid');
3565 * AdminActions::parse_newestcompare()
3566 * Parse skinvar newestcompare
3571 public function parse_newestcompare()
3575 $newestVersion = getLatestVersion();
3576 $newestCompare = str_replace('/', '.', $newestVersion);
3577 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3579 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3581 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3582 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3588 * AdminActions::parse_newmemberselect()
3589 * Parse skinvar newmemberselect
3591 * @param string $template_name name of template to use
3594 public function parse_newmemberselect($template_name = '')
3596 $blogid = intRequestVar('blogid');
3598 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3599 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3600 $res = DB::getResult($query);
3603 foreach ( $res as $row )
3605 $tmem[] = intval($row['tmember']);
3608 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3609 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3612 'name' => 'memberid',
3613 'tabindex' => 10000,
3616 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3621 * AdminActions::parse_newpluginlist()
3622 * Parse skinvar newpluginlist
3627 public function parse_newpluginlist()
3629 $candidates = $this->newPlugCandidates;
3630 foreach ( $candidates as $name )
3632 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3638 * AdminActions::parse_outputspecialdirs()
3639 * Parse skinvar outputspecialdirs
3641 * @param string $type type of setting for directory
3644 public function parse_outputspecialdirs($type)
3646 global $DIR_MEDIA, $DIR_NUCLEUS;
3651 echo Entity::hsc($DIR_NUCLEUS);
3654 echo Entity::hsc($DIR_MEDIA);
3661 * AdminActions::parse_passrequestvars()
3662 * Parse skinvar passrequestvars
3667 public function parse_passrequestvars()
3669 $passvar = Admin::getAdminpassvar();
3670 $oldaction = postVar('oldaction');
3672 if ( ($oldaction != 'logout')
3673 && ($oldaction != 'login')
3675 && !postVar('customaction') )
3683 * AdminActions::parse_pluginextras()
3684 * Parse skinvar pluginextras
3686 * @param string $type type of plugin context
3689 public function parse_pluginextras($type = 'global')
3696 $id = intRequestVar('memberid');
3697 $mem =& $manager->getMember($id);
3698 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
3701 $id = intRequestVar('blogid');
3702 $blg =& $manager->getBlog($id);
3703 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
3705 case 'createaccount':
3707 'type' => 'createaccount.php',
3709 'postlabel' => '<br />',
3711 'postfield' => '<br /><br />'
3713 $manager->notify('RegistrationFormExtraFields', $data);
3716 $manager->notify('GeneralSettingsFormExtras', array());
3723 * AdminActions::parse_pluginhelp()
3724 * Parse skinvar pluginhelp
3729 public function parse_pluginhelp()
3731 global $manager, $DIR_PLUGINS;
3733 $plugid = intGetVar('plugid');
3734 $plugName = $manager->getPluginNameFromPid($plugid);
3735 $plug =& $manager->getPlugin($plugName);
3737 if ( $plug->supportsFeature('HelpPage') > 0 )
3739 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3740 if ( @file_exists($helpfile . 'php') )
3742 @include($helpfile . 'php');
3745 elseif ( @file_exists($helpfile . 'html') )
3747 @include($helpfile . 'html');
3751 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3752 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3757 * AdminActions::parse_pluginlistlist()
3758 * Parse skinvar pluginlistlist
3760 * @param string $template_name name of template to use
3763 public function parse_pluginlistlist($template_name = '')
3765 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3766 $query = sprintf($query, sql_table('plugin'));
3768 $template['content'] = 'pluginlist';
3769 $template['tabindex'] = 10;
3771 $this->parser->parse(showlist($query, 'table', $template, $template_name));
3777 * AdminActions::parse_pluginoptions()
3778 * Parse skinvar pluginoptions
3780 * @param string $type type of plugin option
3783 public function parse_pluginoptions($context='global', $template_name='')
3785 global $itemid, $manager;
3790 $contextid = intRequestVar('memberid');
3793 $contextid = intRequestVar('blogid');
3796 $contextid = intRequestVar('catid');
3799 $contextid = $itemid;
3803 /* Actually registererd plugin options */
3804 $aIdToValue = array();
3805 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
3806 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
3807 $res = DB::getResult($query);
3808 foreach ( $res as $row )
3810 $aIdToValue[$row['oid']] = $row['ovalue'];
3813 /* Currently available plugin options */
3814 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
3815 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
3816 $res = DB::getResult($query);
3819 foreach ($res as $row )
3821 if ( !array_key_exists($row['oid'], $aIdToValue) )
3823 $value = $row['odef'];
3827 $value = $aIdToValue[$row['oid']];
3831 'pid' => $row['pid'],
3832 'pfile' => $row['pfile'],
3833 'oid' => $row['oid'],
3835 'name' => $row['oname'],
3836 'description' => $row['odesc'],
3837 'type' => $row['otype'],
3838 'typeinfo' => $row['oextra'],
3839 'contextid' => $contextid,
3845 'context' => $context,
3846 'contextid' => $contextid,
3847 'options' => &$options
3849 $manager->notify('PrePluginOptionsEdit', $data);
3851 $template = array();
3852 if ( $template_name )
3854 $templates =& $manager->getTemplate($template_name);
3855 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3857 $template['title'] = "<tr>"
3858 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3863 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3866 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3868 $template['body'] = "<tr>"
3869 . "<%listplugplugoptionrow%>"
3874 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3880 foreach ( $options as $option )
3883 if ( $prevPid != $option['pid'] )
3885 $prevPid = $option['pid'];
3886 $this->parser->parse($template['title']);
3889 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3891 if ( @$meta['access'] != 'hidden' )
3893 $parsed = $this->parser->parse($template['body']);
3901 * AdminActions::parse_qmenuaddselect()
3902 * Parse skinvar qmanuaddselect
3904 * @param string $template_name name of template to use
3907 public function parse_qmenuaddselect($template_name = '')
3909 global $member, $blogid;
3910 $showAll = requestVar('showall');
3911 if ( $member->isAdmin() && ($showAll == 'yes') )
3913 // Super-Admins have access to all blogs! (no add item support though)
3914 $query = 'SELECT bnumber as value, bname as text FROM %s ORDER BY bname;';
3915 $query = sprintf($query, sql_table('blog'));
3919 $query = 'SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;';
3920 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3923 $template['name'] = 'blogid';
3924 $template['tabindex'] = 15000;
3925 $template['extra'] = _QMENU_ADD_SELECT;
3926 $template['selected'] = 0;
3927 $template['shorten'] = 10;
3928 $template['shortenel'] = '';
3929 $template['javascript'] = 'onchange="return form.submit()"';
3931 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3937 * AdminActions::parse_quickmenu()
3938 * Parse skinvar quickmenu
3940 * @param string $template_name name of template to use
3943 public function parse_quickmenu($template_name = '')
3946 $templates = array();
3948 if ( !empty($template_name) )
3950 $templates = & $manager->getTemplate($template_name);
3952 $pluginExtras = array();
3953 $manager->notify('QuickMenu', array('options' => &$pluginExtras));
3955 $template = array();
3956 if ( count($pluginExtras) > 0 )
3958 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3960 $template['head'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n"
3965 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3968 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
3970 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
3974 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3977 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3979 $template['foot'] = "</ul>\n";
3983 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3986 $this->parser->parse($template['head']);
3987 foreach ( $pluginExtras as $aInfo )
3990 'plugadminurl' => Entity::hsc($aInfo['url']),
3991 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
3992 'plugadmintitle' => Entity::hsc($aInfo['title']),
3994 $this->parser->parse(Template::fill($template['body'], $data));
3996 $this->parser->parse($template['foot']);
4002 * AdminActions::parse_requestblogid()
4003 * Parse skinvar requestblogid
4008 public function parse_requestblogid()
4010 echo intRequestVar('blogid');
4015 * AdminActions::parse_requestiprange()
4016 * Parse skinvar requestiprange
4021 public function parse_requestiprange()
4023 if ( requestVar('iprange') )
4025 echo Entity::hsc(requestVar('iprange'));
4027 elseif ( requestVar('ip') )
4029 echo Entity::hsc(requestVar('ip'));
4035 * AdminActions::parse_selectlocalskinfiles()
4036 * Parse skinvar selectlocalskinfiles
4041 public function parse_selectlocalskinfiles()
4045 if ( !class_exists('SkinImport', FALSE) )
4047 include_libs('skinie.php');
4050 if ( !preg_match('#^admin#', $this->skintype) && $this->skintype != 'importAdmin' )
4052 $skindir = $DIR_SKINS;
4056 $skindir = "{$DIR_SKINS}admin/";
4059 $candidates = SkinImport::searchForCandidates($skindir);
4060 foreach ( $candidates as $skinname => $skinfile )
4062 $skinfile = Entity::hsc($skinfile);
4063 $skinname = Entity::hsc($skinname);
4064 echo "<option value=\"{$skinfile}\">{$skinname}</option>\n";
4071 * AdminActions::parse_skineditallowedlist()
4072 * Parse skinvar skineditallowedlist
4074 * @param string $type type of skin
4075 * @param string $template_name name of template
4078 public function parse_skineditallowedlist($type, $template_name = '')
4083 $query = "SELECT bshortname, bname FROM %s;";
4085 'content' => 'shortblognames'
4087 $query = sprintf($query, sql_table('blog'));
4090 if ( !preg_match('#^admin#', $this->skintype) )
4092 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4096 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%';";
4099 'content' => 'shortnames'
4101 $query = sprintf($query, sql_table('template_desc'));
4105 $this->parser->parse(showlist($query, 'table', $show, $template_name));
4110 * AdminActions::parse_skinielist()
4111 * Parse skinvar skinielist
4113 * @param string $type type of skin
4114 * @param string $template_name name of template to use
4117 public function parse_skinielist($type, $template_name = '')
4121 $templates = array();
4122 if ( $template_name )
4124 $templates =& $manager->getTemplate($template_name);
4126 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
4129 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4130 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4132 . "<td><%expdesc%></td>\n"
4138 $template = $templates['SKINIE_EXPORT_LIST'];
4144 if ( !preg_match('#^admin#', $this->skintype) )
4146 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4150 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname LIKE 'admin/%%';");
4152 foreach ( $res as $row )
4155 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4156 'expid' => 'skinexp' . $row['sdnumber'],
4157 'expname' => Entity::hsc($row['sdname']),
4158 'expdesc' => Entity::hsc($row['sddesc'])
4160 echo Template::fill($template, $data);
4164 if ( !preg_match('#^admin#', $this->skintype) )
4166 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4170 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname LIKE 'admin/%%';");
4172 foreach ( $res as $row )
4175 'typeid' => 'template[' . $row['tdnumber'] . ']',
4176 'expid' => 'templateexp' . $row['tdnumber'],
4177 'expname' => Entity::hsc($row['tdname']),
4178 'expdesc' => Entity::hsc($row['tddesc'])
4180 echo Template::fill($template, $data);
4188 * AdminActions::parse_skinoverview()
4189 * Parse skinvar skinoverview
4191 * @param string $template_name name of template to use
4194 public function parse_skinoverview($template_name = '')
4198 $template = array();
4199 if ( !preg_match('#^admin#', $this->skintype) )
4201 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%' ORDER BY sdname;";
4202 $template['editaction'] = 'skinedit';
4203 $template['cloneaction'] = 'skinclone';
4204 $template['deleteaction'] = 'skindelete';
4205 $template['edittypeaction'] = 'skinedittype';
4206 $template['default'] = $CONF['BaseSkin'];
4210 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
4211 $template['editaction'] = 'adminskinedit';
4212 $template['cloneaction'] = 'adminskinclone';
4213 $template['deleteaction'] = 'adminskindelete';
4214 $template['edittypeaction'] = 'adminskinedittype';
4215 $template['default'] = $CONF['AdminSkin'];
4217 $query = sprintf($query, sql_table('skin_desc'));
4219 $template['tabindex'] = 10;
4220 $template['content'] = 'skinlist';
4222 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4228 * AdminActions::parse_skintypehelp()
4229 * Check editing skintypehelp
4234 public function parse_skintypehelp()
4236 $nowSkinType = strtolower(trim(requestVar('type')));
4237 $pageAction = strtolower(trim(requestVar('action')));
4238 if ( preg_match('/^admin.*/', $pageAction) )
4240 $regularType = self::$default_skin_types;
4241 unset($regularType['memberedit']);
4242 unset($regularType['login']);
4243 $regularType = array_keys($regularType);
4247 /* TODO: use Skin class */
4248 $regularType = array(
4260 if ( in_array($nowSkinType, $regularType) )
4262 help('skinpart' . $nowSkinType);
4266 help('skinpartspecial');
4272 * AdminActions::parse_specialskinlist()
4273 * Parse skinvar specialskinlist
4275 * @param string $template_name name of template to use
4278 public function parse_specialskinlist($template_name = '')
4280 global $CONF, $manager;
4282 $template = array();
4284 $skinid = intRequestVar('skinid');
4286 if ( !preg_match('#^admin#', $this->skintype) )
4288 $skin =& $manager->getSkin($skinid);
4289 $template['editaction'] = 'skinedittype';
4290 $template['removeaction'] = 'skinremovetype';
4294 $skin =& $manager->getSkin($skinid, 'AdminActions');
4295 $template['editaction'] = 'adminskinedittype';
4296 $template['removeaction'] = 'adminskinremovetype';
4298 $normal_types = $skin->getDefaultTypes();
4299 $available_types = $skin->getAvailableTypes();
4301 $special_skintypes = array();
4302 foreach( $available_types as $skintype => $skinname )
4304 if ( !array_key_exists($skintype, $normal_types) )
4306 $special_skintypes[] = array(
4307 'skintype' => $skintype,
4308 'skintypename' => $skinname
4313 if ( sizeof($special_skintypes) > 0 )
4315 $template['tabindex'] = 75;
4316 $template['skinid'] = $skin->getID();
4317 $template['skinname'] = $skin->getName();
4318 $this->parser->parse(showlist($special_skintypes, 'list_specialskinlist', $template, $template_name));
4322 /* TODO: nothing to be shown */
4329 * AdminActions::parse_sprinttext()
4332 * @param string $which
4333 * @param string $val
4336 public function parse_sprinttext($which, $val)
4338 if ( !defined($which) )
4344 $base = constant($which);
4347 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4349 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4351 $met = 'parse_' . $matchies[0];
4355 $arg = trim($args[0], '()');
4356 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4359 if ( method_exists($this, $met) )
4361 $value = call_user_func(array(&$this, $met), $arg);
4365 if ( !isset($value) || empty($value) )
4369 echo sprintf($base, $value);
4374 * AdminActions::parse_systemsettings()
4375 * Parse skinvar systemsettings
4377 * @param string $type type of settings for system
4378 * @param string $template_name name of template to use
4381 public function parse_systemsettings($type = 'phpinfo', $template_name = '')
4383 global $manager, $member, $CONF, $nucleus;
4385 $member->isAdmin() or Admin::disallow();
4387 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4388 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4395 case 'sqlserverinfo':
4396 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4398 case 'sqlclientinfo':
4399 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4401 case 'magicquotesgpc':
4402 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4404 case 'magicquotesruntime':
4405 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4407 case 'registerglobals':
4408 echo ini_get('register_globals') ? 'On' : 'Off';
4411 $templates = array();
4412 if ( $template_name )
4414 $templates =& $manager->getTemplate($template_name);
4416 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4418 $template = "<tr>\n"
4419 . "<td><%key%></td>\n"
4420 . "<td><%value%></td>\n"
4425 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4428 $gdinfo = gd_info();
4430 foreach ( $gdinfo as $key => $value )
4432 if ( is_bool($value) )
4434 $value = $value ? $enable : $disable;
4438 $value = Entity::hsc($value);
4444 echo Template::fill($template, $data);
4449 phpinfo(INFO_MODULES);
4450 $im = ob_get_contents();
4452 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4454 case 'nucleusversion':
4455 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4457 case 'nucleuspatchlevel':
4458 echo getNucleusPatchLevel();
4464 echo $CONF['ItemURL'];
4466 case 'alertonheaderssent':
4467 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4469 case 'nucleuscodename':
4470 if ( $nucleus['codename'] != '' )
4472 echo ' "' . $nucleus['codename'] . '"';
4475 case 'versioncheckurl':
4476 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4483 * AdminActions::parse_templateoverview()
4484 * Parse skinvar templateoverview
4486 * @param string $template_name name of template to use
4489 public function parse_templateoverview($template_name = '')
4491 if ( !preg_match('#^admin#', $this->skintype) )
4493 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname;";
4494 $template['deleteaction'] = 'templatedelete';
4495 $template['editaction'] = 'templateedit';
4496 $template['cloneaction'] = 'templateclone';
4500 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
4501 $template['deleteaction'] = 'admintemplatedelete';
4502 $template['editaction'] = 'admintemplateedit';
4503 $template['cloneaction'] = 'admintemplateclone';
4505 $query = sprintf($query, sql_table('template_desc'));
4507 $template['tabindex'] = 10;
4508 $template['content'] = 'templatelist';
4510 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4516 * AdminActions::parse_ticket()
4522 public function parse_ticket()
4525 $manager->addTicketHidden();
4530 * AdminActions::parse_versioncheckurl()
4531 * Parse skinvar versioncheckurl
4536 public function parse_versioncheckurl()
4538 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4543 * AdminActions::parse_yrbloglist()
4544 * Parse skinvar yrbloglist
4546 * @param string $template_name name of template to use
4549 public function parse_yrbloglist($template_name = '')
4552 $showAll = requestVar('showall');
4554 if ( $member->isAdmin() && ($showAll == 'yes') )
4556 // Super-Admins have access to all blogs! (no add item support though)
4557 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4559 . " ORDER BY bnumber;";
4560 $query = sprintf($query, sql_table('blog'));
4564 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4566 . " WHERE tblog=bnumber and tmember=%d"
4567 . " ORDER BY bnumber;";
4568 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4571 $resource = DB::getResult($query);
4572 if ( ($showAll != 'yes') && $member->isAdmin() )
4574 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4575 $total = DB::getValue($query);
4577 if ( $total > $resource->rowCount() )
4579 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4583 if ( $resource->rowCount() > 0 )
4585 $template['content'] = 'bloglist';
4586 $template['superadmin'] = $member->isAdmin();
4588 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4589 $resource->closeCursor();
4591 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4593 $query = 'SELECT ititle, inumber, bshortname FROM %s, %s '
4594 . 'WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4595 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4597 $resource = DB::getResult($query);
4598 if ( $resource->rowCount() > 0 )
4600 $template['content'] = 'draftlist';
4601 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4605 echo _OVERVIEW_NODRAFTS;
4610 echo _OVERVIEW_NOBLOGS;
4612 $resource->closeCursor();
4618 * AdminActions::checkCondition()
4619 * Checks conditions for if statements
4621 * @param string $field type of <%if%>
4622 * @param string $name property of field
4623 * @param string $value value of property
4624 * @return boolean condition
4626 protected function checkCondition($field, $name='', $value = '')
4628 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4638 $blog =& $manager->getBlog($blogid);
4642 $blogid = getBlogIDFromCatID($catid);
4643 $blog =& $manager->getBlog($blogid);
4645 elseif ( intRequestVar('catid') )
4647 $catid = intRequestVar('catid');
4648 $blogid = getBlogIDFromCatID($catid);
4649 $blog =& $manager->getBlog($blogid);
4656 $condition = ($blog && $this->ifCategory($name, $value));
4659 $condition = $member->isLoggedIn();
4662 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4665 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4668 $condition = $member->isLoggedIn() && $member->isAdmin();
4670 case 'allowloginedit':
4671 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4674 $condition = ($itemidnext != '');
4677 $condition = ($itemidprev != '');
4679 case 'archiveprevexists':
4680 $condition = ($archiveprevexists == true);
4682 case 'archivenextexists':
4683 $condition = ($archivenextexists == true);
4686 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4689 $condition = $this->ifHasPlugin($name, $value);
4692 $condition = (Admin::getAdminAction() == $name);
4694 case 'adminoldaction':
4695 $condition = (Admin::getAdminAction() == $name);
4697 case 'addresschange':
4698 $condition = ($this->ifAddresscange());
4700 case 'bechangepass':
4701 $condition = ($this->beChangePassword());
4703 case 'skincandidates':
4704 $condition = ($this->ifSkincandidates());
4707 $condition = requestVar('nameclashes');
4709 case 'existsnewplugin':
4710 $condition = ($this->existsNewPlugin());
4717 $condition = (boolean) ($member->getAutosave() == $value);
4724 $condition = (Admin::$blog->getSetting($name) == $value);
4726 case 'itemproperty':
4731 if ( array_key_exists($name, Admin::$contents) )
4733 $condition = (boolean) (Admin::$contents[$name] == $value);
4737 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4744 * AdminActions::_ifHasPlugin()
4745 * hasplugin,PlugName
4746 * -> checks if plugin exists
4747 * hasplugin,PlugName,OptionName
4748 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
4749 * hasplugin,PlugName,OptionName=value
4750 * -> checks if the option OptionName from plugin PlugName is set to value
4752 * @param string $name name of plugin
4753 * @param string $value
4756 private function ifHasPlugin($name, $value)
4760 // (pluginInstalled method won't write a message in the actionlog on failure)
4761 if ( $manager->pluginInstalled("NP_{$name}") )
4763 $plugin =& $manager->getPlugin("NP_{$name}");
4764 if ( $plugin != NULL )
4772 list($name2, $value2) = preg_split('#=#', $value, 2);
4773 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4777 else if ( $plugin->getOption($name2) == $value2 )
4788 * AdminActions::beChangePassword()
4793 private function beChangePassword()
4795 return intRequestVar('bNeedsPasswordChange');
4799 * AdminActions::ifSkincandidates()
4800 * Checks if a plugin exists and call its doIf function
4806 private function ifSkincandidates()
4809 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4810 return (count($candidates) > 0);
4814 * AdminActions::ifPlugin()
4815 * Checks if a plugin exists and call its doIf function
4817 * @param string $name name of plugin
4818 * @param string $key
4819 * @param string $value
4822 private function ifPlugin($name, $key = '', $value = '')
4826 $plugin =& $manager->getPlugin("NP_{$name}");
4832 $params = func_get_args();
4833 array_shift($params);
4835 return call_user_func_array(array(&$plugin, 'doIf'), $params);
4839 * AdminActions::ifCategory()
4840 * Different checks for a category
4842 * @param string $key key for information of category
4843 * @param string $value value for information of category
4846 private function ifCategory($key = '', $value='')
4848 global $blog, $catid;
4850 // when no parameter is defined, just check if a category is selected
4851 if (($key != 'catname' && $key != 'catid') || ($value == ''))
4853 return $blog->isValidCategory($catid);
4856 // check category name
4857 if ( $key == 'catname' )
4859 $value = $blog->getCategoryIdFromName($value);
4860 if ($value == $catid)
4862 return $blog->isValidCategory($catid);
4866 // check category id
4867 if (($key == 'catid') && ($value == $catid))
4869 return $blog->isValidCategory($catid);
4876 * AdminActions::ifOnTeam()
4877 * Checks if a member is on the team of a blog and return his rights
4879 * @param string $blogName name of weblog
4882 private function ifOnTeam($blogName = '')
4884 global $blog, $member, $manager;
4886 // when no blog found
4887 if ( ($blogName == '') && !is_object($blog) )
4892 // explicit blog selection
4893 if ($blogName != '')
4895 $blogid = getBlogIDFromName($blogName);
4898 if (($blogName == '') || !$manager->existsBlogID($blogid))
4901 $blogid = $blog->getID();
4903 return $member->teamRights($blogid);
4907 * AdminActions::ifAdmin()
4908 * Checks if a member is admin of a blog
4910 * @param string $blogName name of weblog
4913 private function ifAdmin($blogName = '')
4915 global $blog, $member, $manager;
4917 // when no blog found
4918 if (($blogName == '') && (!is_object($blog)))
4923 // explicit blog selection
4924 if ($blogName != '')
4926 $blogid = getBlogIDFromName($blogName);
4929 if (($blogName == '') || !$manager->existsBlogID($blogid))
4932 $blogid = $blog->getID();
4935 return $member->isBlogAdmin($blogid);
4939 * AdminActions::ifAddresscange()
4940 * Check e-Mail address is changed
4945 private function ifAddresscange()
4949 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4954 $info = MEMBER::getActivationInfo($key);
4959 $mem =& $manager->getMember($info->vmember);
4964 if ( $info->vtype == 'addresschange' )
4973 * AdminActions::customHelp()
4974 * shows a link to custom help file
4977 * @param string $tplName
4978 * @param string $url
4979 * @param string $iconURL
4980 * @param string $alt
4981 * @param string $title
4985 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4987 echo $this->customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
4992 * AdminActions::customHelp()
4993 * shows a link to custom help file
4996 * @param string $tplName
4997 * @param string $url
4998 * @param string $iconURL
4999 * @param string $alt
5000 * @param string $title
5004 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5006 global $CONF, $manager;
5008 $templates = array();
5012 $templates =& $manager->getTemplate($tplName);
5015 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5017 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5021 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5026 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5029 if ( empty($onclick) )
5031 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5033 elseif ( preg_match('#^onclick#', $onclick) )
5035 $onclick = $onclick;
5039 $onclick = 'onclick="' . $onclick . '"';
5044 'helptarget' => $id,
5045 'onclick' => $onclick,
5046 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5048 return Template::fill($template, $data);
5053 * AdminActions::customHelpHtml()
5055 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5057 global $CONF, $manager;
5059 $templates = array();
5063 $templates =& $manager->getTemplate($tplName);
5065 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5067 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5071 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5074 if ( empty($iconURL) )
5076 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5079 if ( function_exists('getimagesize') )
5081 $size = getimagesize($iconURL);
5082 $width = 'width="' . $size[0] . '" ';
5083 $height = 'height="' . $size[1] . '" ';
5087 'iconurl' => $iconURL,
5089 'height' => $height,
5090 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5091 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5094 $icon = Template::fill($template, $data);
5095 $help = $this->customHelplink($id, $tplName, $url, $title, $onclick);
5097 return $help . $icon;
5101 * AdminActions::existsNewPlugin()
5102 * Check exists new plugin
5105 * @return boolean exists or not
5107 private function existsNewPlugin()
5109 global $DIR_PLUGINS;
5111 $query = "SELECT * FROM %s;";
5112 $query = sprintf($query, sql_table('plugin'));
5113 $res = DB::getResult($query);
5115 $installed = array();
5116 foreach( $res as $row )
5118 $installed[] = $row['pfile'];
5121 $files = scandir($DIR_PLUGINS);
5123 $candidates = array();
5124 foreach ( $files as $file )
5126 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5128 if ( !in_array($matches[1], $installed) )
5130 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5134 $this->newPlugCandidates = $candidates;
5135 return (count($candidates) > 0);
5139 * AdminActions::pagehead()
5140 * Output admin page head
5145 public function parse_pagehead()
5147 global $member, $nucleus, $CONF, $manager;
5149 /* HTTP 1.1 application for no caching */
5150 header("Cache-Control: no-cache, must-revalidate");
5151 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5153 $content = $this->parser->skin->getContentFromDB('pagehead');
5156 $root_element = 'html';
5157 $charset = i18n::get_current_charset();
5158 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5159 $xml_version_info = self::$xml_version_info;
5160 $formal_public_identifier = self::$formal_public_identifier;
5161 $system_identifier = self::$system_identifier;
5162 $xhtml_namespace = self::$xhtml_namespace;
5164 $content = "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n"
5165 . "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n"
5166 . "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n"
5168 . "<title><%sitevar(name)%> - Admin</title>\n"
5169 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>"
5170 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>"
5171 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>"
5175 . "<div id=\"adminwrapper\">"
5176 . "<div class=\"header\">"
5177 . "<h1><%sitevar(name)%></h1>"
5179 . "<div id=\"container\">"
5180 . "<div id=\"content\">"
5181 . "<div class=\"loginname\">"
5182 . "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"<%skinfile(admin/defaultadmin/styles/addedit.css%>\" />\n"
5183 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>\n"
5184 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>\n"
5185 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>\n"
5190 . "<div id=\"adminwrapper\">\n"
5191 . "<div class=\"header\">\n"
5192 . "<h1><%sitevar(name)%></h1>\n"
5194 . "<div id=\"container\">\n"
5195 . "<div id=\"content\">\n"
5196 . "<div class=\"loginname\">\n"
5197 . "<%if(loggedin)%>"
5198 . "<%text(_LOGGEDINAS)%> <%member(yourrealname)%> - <a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a><br />"
5199 . "<a href=\"<%adminurl%>index.php?action=overview\"><%text(_ADMINHOME)%></a> - "
5201 . "<a href=\"<%adminurl%>index.php?action=showlogin\" title=\"Log in\"><%text(_NOTLOGGEDIN)%></a><br />"
5203 . "<a href=\"<%sitevar(url)%>\"><%text(_YOURSITE)%></a><br />"
5205 . "<%if(superadmin)%>"
5206 . "<a href=\"<%versioncheckurl%>\" title=\"<%text(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE)%>\"><%version%><%codename%></a>"
5207 . "<%newestcompare%><%else%><%version%><%codename%>"
5213 $this->parser->parse($content);
5218 * AdminActionss::pagefoot()
5219 * Output admin page foot include quickmenu
5224 public function parse_pagefoot()
5226 global $action, $member, $manager, $blogid;
5229 'action' => Admin::getAdminAction()
5231 $manager->notify('AdminPrePageFoot', $data);
5233 $content = $this->parser->skin->getContentFromDB('pagefoot');
5236 $content = "<%if(loggedin)%>"
5237 . "<%ifnot(adminaction,showlogin)%>"
5238 . "<h2><%text(_LOGOUT)%></h2>"
5240 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_BACKHOME)%></a></li>"
5241 . "<li><a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a></li>"
5245 . "<div class=\"foot\">"
5246 . "<a href=\"<%text(_ADMINPAGEFOOT_OFFICIALURL)%>\">Nucleus CMS</a> © 2002- <%date(%Y)%> <%text(_ADMINPAGEFOOT_COPYRIGHT)%>"
5247 . " - <a href=\"<%text(_ADMINPAGEFOOT_DONATEURL)%>\"><%text(_ADMINPAGEFOOT_DONATE)%></a>"
5250 . "<!-- content -->"
5251 . "<div id=\"quickmenu\">"
5252 . "<%if(loggedin)%>"
5253 . "<%ifnot(adminaction,showlogin)%>"
5255 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_QMENU_HOME)%></a></li>"
5257 . "<h2><%text(_QMENU_ADD)%></h2>"
5258 . "<form method=\"get\" action=\"<%adminurl%>index.php\">"
5260 . "<input type=\"hidden\" name=\"action\" value=\"createitem\" />"
5261 . "<%qmenuaddselect(admin/default)%>"
5264 . "<h2><%member(yourrealname)%></h2>"
5266 . "<li><a href=\"<%adminurl%>index.php?action=editmembersettings\"><%text(_QMENU_USER_SETTINGS)%></a></li>"
5267 . "<li><a href=\"<%adminurl%>index.php?action=browseownitems\"><%text(_QMENU_USER_ITEMS)%></a></li>"
5268 . "<li><a href=\"<%adminurl%>index.php?action=browseowncomments\"><%text(_QMENU_USER_COMMENTS)%></a></li>"
5270 . "<%if(superadmin)%>"
5271 . "<h2><%text(_QMENU_MANAGE)%></h2>"
5273 . "<li><a href=\"<%adminurl%>index.php?action=actionlog\"><%text(_QMENU_MANAGE_LOG)%></a></li>"
5274 . "<li><a href=\"<%adminurl%>index.php?action=settingsedit\"><%text(_QMENU_MANAGE_SETTINGS)%></a></li>"
5275 . "<li><a href=\"<%adminurl%>index.php?action=systemoverview\"><%text(_QMENU_MANAGE_SYSTEM)%></a></li>"
5276 . "<li><a href=\"<%adminurl%>index.php?action=usermanagement\"><%text(_QMENU_MANAGE_MEMBERS)%></a></li>"
5277 . "<li><a href=\"<%adminurl%>index.php?action=createnewlog\"><%text(_QMENU_MANAGE_NEWBLOG)%></a></li>"
5278 . "<li><a href=\"<%adminurl%>index.php?action=backupoverview\"><%text(_QMENU_MANAGE_BACKUPS)%></a></li>"
5279 . "<li><a href=\"<%adminurl%>index.php?action=pluginlist\"><%text(_QMENU_MANAGE_PLUGINS)%></a></li>"
5281 . "<h2><%text(_QMENU_LAYOUT)%></h2>"
5283 . "<li><a href=\"<%adminurl%>index.php?action=skinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5284 . "<li><a href=\"<%adminurl%>index.php?action=templateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5285 . "<li><a href=\"<%adminurl%>index.php?action=skinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5287 . "<h2><%text(_SKINABLEADMIN_QMENU_LAYOUT)%></h2>"
5289 . "<li><a href=\"<%adminurl%>index.php?action=adminskinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5290 . "<li><a href=\"<%adminurl%>index.php?action=admintemplateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5291 . "<li><a href=\"<%adminurl%>index.php?action=adminskinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5294 . "<%quickmenu(admin/default)%>"
5296 . "<%elseif(adminaction,activate)%>"
5297 . "<h2><%text(_QMENU_ACTIVATE)%></h2>"
5298 . "<%text(_QMENU_ACTIVATE_TEXT)%>"
5299 . "<%elseif(adminaction,activatesetpwd)%>"
5300 . "<h2><%text(_QMENU_ACTIVATE)%></h2><%text(_QMENU_ACTIVATE_TEXT)%>"
5302 . "<h2><%text(_QMENU_INTRO)%></h2><%text(_QMENU_INTRO_TEXT)%>"
5305 . "<!-- content / quickmenu container -->"
5306 . "<div class=\"clear\"></div>"
5309 . "<!-- adminwrapper -->"
5313 . "<p style=\"text-align:right;\"><%benchmark%></p>"
5318 $this->parser->parse($content);
5322 * AdminActions::selectBlog()
5323 * Inserts a HTML select element with choices for all blogs to which the user has access
5324 * mode = 'blog' => shows blognames and values are blogids
5325 * mode = 'category' => show category names and values are catids
5327 * @param string $name
5328 * @param string $mode
5329 * @param integer $selected
5330 * @param integer $tabindex
5331 * @param integer $showNewCat
5332 * @param integer $iForcedBlogInclude ID for weblog always included
5333 * @param $iForcedBlogInclude
5334 * ID of a blog that always needs to be included, without checking if the
5335 * member is on the blog team (-1 = none)
5338 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5340 global $member, $CONF;
5342 // 0. get IDs of blogs to which member can post items (+ forced blog)
5343 $aBlogIds = array();
5344 if ( $iForcedBlogInclude != -1 )
5346 $aBlogIds[] = intval($iForcedBlogInclude);
5349 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5351 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5352 $query = sprintf($query, sql_table('blog'));
5356 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5357 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5360 $rblogids = DB::getResult($query);
5361 foreach ( $rblogids as $row )
5363 if ( $row['bnumber'] != $iForcedBlogInclude )
5365 $aBlogIds[] = intval($row['bnumber']);
5369 if ( count($aBlogIds) == 0 )
5374 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5376 // 1. select blogs (we'll create optiongroups)
5377 // (only select those blogs that have the user on the team)
5378 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5379 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5380 $blogs = DB::getResult($queryBlogs);
5382 if ( $mode == 'category' )
5384 if ( $blogs->rowCount() > 1 )
5388 foreach ( $blogs as $rBlog )
5390 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5392 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5395 // show selection to create new category when allowed/wanted
5398 // check if allowed to do so
5399 if ( $member->blogAdminRights($rBlog['bnumber']) )
5401 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5405 // 2. for each category in that blog
5406 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5407 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5408 $categories = DB::getResult($catQuery);
5409 foreach ( $categories as $rCat )
5411 if ( $rCat['catid'] == $selected )
5413 $selectText = ' selected="selected" ';
5419 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5422 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5430 foreach ( $blogs as $rBlog )
5432 echo '<option value="' . $rBlog['bnumber'] . '"';
5433 if ( $rBlog['bnumber'] == $selected )
5435 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5439 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";