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 > 0) ? $member->adminskin : $CONF['AdminSkin'];
1197 elseif ( $action == 'memberedit' )
1200 $mem = $manager->getMember(intRequestVar('memberid'));
1201 $default = ($mem->adminskin > 0) ? $mem->adminskin : $CONF['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
1215 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1220 * AdminActions::parse_defbookmarkletselect()
1221 * Parse skinvar defbookmarkletselect
1223 * @param string $template_name name of template to use
1226 public function parse_defbookmarkletselect($template_name)
1228 global $CONF, $action;
1230 if ( $action == 'editmembersettings' )
1233 $default = ($member->bookmarklet > 0) ? $member->bookmarklet : $CONF['BookmarkletSkin'];
1235 elseif ( $action == 'memberedit' )
1238 $mem = $manager->getMember(intRequestVar('memberid'));
1239 $default = ($mem->bookmarklet > 0) ? $mem->bookmarklet : $CONF['BookmarkletSkin'];
1243 $default = $CONF['BookmarkletSkin'];
1246 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%'";
1247 $query = sprintf($query, sql_table('skin_desc'));
1250 'name' => 'bookmarklet',
1251 'tabindex' => 10085,
1252 'selected' => $default
1254 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1259 * AdminActions::parse_batchdeletetype()
1260 * Parse skinvar batchdeletetype
1265 public function parse_batchdeletetype()
1267 echo Entity::hsc(requestVar('action'));
1272 * AdminActions::parse_batchmovebtn()
1273 * Parse skinvar batchmovebtn
1278 public function parse_batchmovebtn()
1280 $actionType = requestVar('action');
1281 switch ( $actionType )
1286 case 'batchcategory':
1294 * AdminActions::parse_batchmovelist()
1295 * Parse skinvar batchmovelist
1300 public function parse_batchmovelist()
1302 $selected = requestIntArray('batch');
1304 foreach ( $selected as $select )
1306 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1313 * AdminActions::parse_batchmovetitle()
1314 * Parse skinvar batchmovetitle
1319 public function parse_batchmovetitle()
1321 $actionType = requestVar('action');
1322 switch ( $actionType )
1327 case 'batchcategory':
1328 echo _MOVECAT_TITLE;
1335 * AdminActions::parse_batchmovetype()
1336 * Parse skinvar batchmovetype
1341 public function parse_batchmovetype()
1343 echo Entity::hsc(requestVar('action'));
1348 * AdminActions::parse_blogcatlist()
1349 * Parse skinvar blogcatlist
1354 public function parse_blogcatlist($template_name = '')
1357 $blogid = intRequestVar('blogid');
1358 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1359 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1361 $resource = DB::getResult($query);
1362 if ( $resource->rowCount() > 0 )
1364 $template['content'] = 'categorylist';
1365 $template['tabindex'] = 200;
1366 $this->parser->parse(listplug_batchlist('category', $resource, 'table', $template));
1370 /* TODO: nothing to be shown */
1372 $resource->closeCursor();
1378 * AdminActions::parse_blogid()
1379 * Parse skinvar blogid
1384 public function parse_blogid()
1386 echo intRequestVar('blogid');
1391 * AdminActions::parse_blognotifysetting()
1392 * Parse skinvar blognotifysetting
1397 public function parse_blognotifysetting($type)
1400 $blogid = intRequestVar('blogid');
1401 $blog =& $manager->getBlog($blogid);
1406 if ( !$blog->notifyOnComment() )
1412 if ( !$blog->notifyOnVote() )
1418 if ( !$blog->notifyOnNewItem() )
1424 echo ' checked="checked"';
1429 * AdminActions::parse_blogsetting()
1430 * Parse skinvar blogsetting
1432 * @param string $which name of weblog setting
1435 public function parse_blogsetting($which)
1437 echo $this->parse_getblogsetting($which);
1442 * AdminActions::parse_blogsettingyesno()
1443 * Parse skinvar blogsettingyesno
1445 * @param string $type type of weblog setting
1446 * @param string $template_name name of template to use
1449 public function parse_blogsettingyesno($type, $template_name = '')
1453 $blogid = intRequestVar('blogid');
1454 $blog =& $manager->getBlog($blogid);
1458 case 'convertbreaks':
1459 $checkedval = $blog->convertBreaks();
1462 case 'allowpastposting':
1463 $checkedval = $blog->allowPastPosting();
1467 $checkedval = $blog->commentsEnabled();
1471 $checkedval = $blog->isPublic();
1475 $checkedval = $blog->emailRequired();
1479 $checkedval = $blog->getSearchable();
1483 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $template_name);
1488 * AdminActions::parse_blogteamlist()
1489 * Parse skinvar blogteamlist
1491 * @param string $template_name name of template to use
1494 public function parse_blogteamlist($template_name = '')
1497 $blogid = intRequestVar('blogid');
1498 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1500 . "WHERE tmember=mnumber AND tblog= %d";
1501 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1503 $resource = DB::getResult($query);
1504 if ( $resource->rowCount() > 0 )
1506 $template['content'] = 'teamlist';
1507 $template['tabindex'] = 10;
1509 $this->parser->parse(listplug_batchlist('team', $resource, 'table', $template));
1515 $resource->closeCursor();
1521 * AdminActions::parse_blogteammembers()
1522 * Parse skinvar blogteammembers
1527 public function parse_blogteammembers()
1529 $blogid = intRequestVar('blogid');
1530 $query = "SELECT mname, mrealname "
1532 . "WHERE mnumber=tmember AND tblog=%d;";
1533 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1534 $res = DB::getResult($query);
1535 $memberNames = array();
1536 foreach ( $res as $row )
1538 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1540 echo implode(',', $memberNames);
1544 * AdminActions::parse_blogtime()
1545 * Parse skinvar blogtime
1547 * @param string $type type of time
1548 * @param string $format format for time expression
1549 * @param integer $offset offset of time
1552 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1556 if ( $type != 'blogtime' )
1558 /* return server time */
1559 $timestamp = time() + $offset;
1563 $bid = intRequestVar('blogid');
1564 $b =& $manager->getBlog($bid);
1565 $timestamp = $b->getCorrectTime() + $offset;
1568 echo i18n::formatted_datetime($format, $timestamp);
1573 * AdminActions::parse_bookmarkletadmin()
1574 * Parse skinvar bookmarkletadmin
1579 public function parse_bookmarkletadmin()
1583 $blogid = intRequestVar('blogid');
1585 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1590 * AdminActions::parse_categories()
1591 * Parse skinvar categories
1593 * create category dropdown box
1595 * @param string $type name of setting for category
1598 public function parse_categories($startidx = 0)
1602 if ( !array_key_exists('catid', Admin::$contents) || empty(Admin::$contents['catid']) )
1604 $catid = Admin::$blog->getDefaultCategory();
1608 $catid = Admin::$contents['catid'];
1611 $this->selectBlog('catid', 'category', $catid, $startidx, 1, Admin::$blog->getID());
1617 * AdminActions::parse_categorysetting()
1618 * Parse skinvar categorysetting
1620 * @param string $type type in category setting
1623 public function parse_categorysetting($type)
1625 $catid = intRequestVar('catid');
1626 if ( $type == 'id' )
1631 $blogid = intRequestVar('blogid');
1632 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1633 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1634 $row = DB::getRow($query);
1636 if ( $type != 'name' )
1638 echo Entity::hsc($row['cdesc']);
1642 echo Entity::hsc($row['cname']);
1649 * AdminActions::parse_codename()
1650 * Parse templatevar codename
1656 public function parse_checkedonval($value, $name)
1661 $itemid = intRequestVar('itemid');
1662 $item =& $manager->getItem($itemid, 1, 1);
1666 $blog =& $manager->getBlog($item['blogid']);
1668 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1670 $item['body'] = removeBreaks($item['body']);
1671 $item['more'] = removeBreaks($item['more']);
1675 $contents = array();
1676 if ( requestVar('action') == 'itemedit' )
1680 if ( !isset($contents[$name]) )
1682 $contents[$name] = '';
1684 if ($contents[$name] == $value)
1686 echo 'checked="checked"';
1692 * AdminActions::parse_codename()
1693 * Parse templatevar codename
1698 * TODO: is this need???
1700 public function parse_codename()
1703 echo $nucleus['codename'];
1708 * AdminActions::parse_commentnavlist()
1709 * Parse skinvar commentnavlist
1714 public function parse_commentnavlist()
1716 global $CONF, $manager, $member;
1719 if ( postVar('start') )
1721 $start = intPostVar('start');
1728 // amount of items to show
1729 if ( postVar('amount') )
1731 $amount = intPostVar('amount');
1735 $amount = (integer) $CONF['DefaultListSize'];
1741 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
1743 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
1745 $query = sprintf($query, sql_table('comment'), sql_table('member'));
1747 if ( $this->skintype == 'itemcommentlist' )
1749 $itemid = intRequestVar('itemid');
1750 $query .= " citem={$itemid}";
1751 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1753 $nonComments = _NOCOMMENTS;
1755 elseif ( $this->skintype == 'browseowncomments' )
1758 $query .= ' cmember=' . $member->getID();
1759 $template['canAddBan'] = 0;
1761 $nonComments = _NOCOMMENTS_YOUR;
1763 elseif ( $this->skintype == 'blogcommentlist' )
1766 $query .= ' cblog=' . intRequestVar('blogid');
1767 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
1768 $bid = intRequestVar('blogid');
1769 $nonComments = _NOCOMMENTS_BLOG;
1772 $search = postVar('search');
1773 if ( !empty($search) )
1775 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
1778 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
1780 $resource = DB::getResult($query);
1781 if ( $resource->rowCount() > 0 )
1783 $template['action'] = $this->skintype;
1784 $template['start'] = $start;
1785 $template['amount'] = $amount;
1786 $template['minamount'] = 0;
1787 $template['maxamount'] = 1000;
1788 $template['blogid'] = $bid;
1789 $template['search'] = $search;
1790 $template['itemid'] = $itemid;
1792 $template['content'] = 'commentlist';
1794 $this->parser->parse(listplug_navlist('comment', $resource, 'table', $template));
1798 /* TODO: nothing to be shown */
1800 $resource->closeCursor();
1806 * AdminActions::parse_configsettingsedit()
1807 * Parse skinvar configsettingsedit
1809 * @param string $type type of global configuration
1812 public function parse_configsettingsedit($type)
1817 case 'DefaultListSize':
1818 if ( !array_key_exists('DefaultListSize', $CONF) )
1820 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
1821 $query = sprintf($query, sql_table('config'));
1822 DB::execute($query);
1823 $CONF['DefaultListSize'] = 10;
1825 elseif ( intval($CONF['DefaultListSize']) < 1 )
1827 $CONF['DefaultListSize'] = 10;
1829 echo intval($CONF['DefaultListSize']);
1831 case 'SessionCookie':
1832 $value = $CONF['SessionCookie'];
1833 $txt1 = _SETTINGS_COOKIESESSION;
1834 $txt2 = _SETTINGS_COOKIEMONTH;
1835 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
1838 $value = $CONF['URLMode'];
1839 $txt1 = _SETTINGS_URLMODE_NORMAL;
1840 $txt2 = _SETTINGS_URLMODE_PATHINFO;
1841 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
1844 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
1846 echo Entity::hsc($CONF[$type]);
1854 * AdminActions::parse_configsettingsyesno()
1855 * Parse skinvar configsettingsyesno
1857 * @param string $type type of global setting
1858 * @param integer $tabindex tabindex attribute of input element
1861 public function parse_configsettingsyesno($type, $tabindex)
1864 if ( array_key_exists($type, $CONF) )
1866 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
1872 * AdminActions::parse_contents()
1873 * Parse skinvar contents
1875 * @param string $which part for item
1878 public function parse_contents($which)
1880 if ( !array_key_exists($which, Admin::$contents) )
1882 Admin::$contents[$which] = '';
1884 echo Entity::hsc(Admin::$contents[$which]);
1888 * AdminActions::parse_currenttime()
1889 * Parse skinvar currenttime
1891 * @param string $what
1894 public function parse_currenttime($what)
1896 $nu = getdate(Admin::$blog->getCorrectTime());
1901 * AdminActions::parse_customhelplink()
1902 * Parse skinvar customhelplink
1904 * @param string $topic name of topic
1905 * @param string $tplName name of template
1906 * @param string $url string as URI
1907 * @param string $iconURL string as URI for icon
1908 * @param string $alt alternative text for image element
1909 * @param string $title title for anchor element
1912 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
1914 $this->customHelp($topic, $url, $iconURL);
1919 * AdminActions::parse_date()
1920 * Parse skinvar date
1922 public function parse_date($format = 'c')
1924 global $CONF, $manager;
1925 /* TODO: offset is based on i18n::get_current_locale()? */
1926 echo i18n::formatted_datetime($format, time());
1931 * AdminActions::parse_normalskinlist()
1932 * Parse skinvar defaultadminskintypes
1934 * @param string $template_name name of template
1937 public function parse_normalskinlist($template_name = '')
1939 global $CONF, $manager;
1941 if ( !preg_match('#^admin#', $this->skintype) )
1943 $skin =& $manager->getSkin($CONF['BaseSkin']);
1944 /* TODO: removeaction? */
1945 $template['editaction'] = 'skinedittype';
1949 $skin =& $manager->getSkin($CONF['AdminSkin'], 'AdminActions');
1950 $template['editaction'] = 'adminskinedittype';
1951 /* TODO: removeaction? */
1954 $temporary = $skin->getDefaultTypes();
1955 $normal_skintype = array();
1956 foreach ( $temporary as $type => $label )
1958 $normal_skintype[] = array(
1959 'skintype' => $type,
1960 'skintypename' => $label
1964 $template['tabindex'] = 10;
1965 $template['skinid'] = $skin->getID();
1966 $template['skinname'] = $skin->getName();
1967 $this->parser->parse(showlist($normal_skintype, 'list_normalskinlist', $template, $template_name));
1973 * AdminActions::parse_defblogselect()
1974 * Parse skinvar defblogselect
1976 * @param string $template_name name of template
1979 public function parse_defblogselect($template_name = '')
1983 $query = "SELECT bname as text, bnumber as value FROM %s;";
1984 $query = sprintf($query, sql_table('blog'));
1986 $template['name'] = 'DefaultBlog';
1987 $template['selected'] = $CONF['DefaultBlog'];
1988 $template['tabindex'] = 10;
1989 $this->parser->parse(showlist($query, 'select', $template, $template_name));
1995 * AdminActions::parse_defcatselect()
1996 * Parse skinvar defcatselect
1998 * @param string $template_name name of template
2001 public function parse_defcatselect($template_name = '')
2005 $blogid = intRequestVar('blogid');
2006 $blog =& $manager->getBlog($blogid);
2008 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2009 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2011 $template['name'] = 'defcat';
2012 $template['selected'] = $blog->getDefaultCategory();
2013 $template['tabindex'] = 110;
2015 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2021 * AdminActions::parse_defskinselect()
2022 * Parse skinvar defskinselect
2024 * @param string $type type of skin
2025 * @param string $template_name name of template
2028 public function parse_defskinselect($type = 'blog', $template_name = '')
2030 global $CONF, $manager, $member;
2032 if ( !preg_match('#^admin#', $this->skintype) )
2034 $blogid = intRequestVar('blogid');
2037 $template['selected'] = $CONF['BaseSkin'];
2041 $blog =& $manager->getBlog($blogid);
2042 $template['selected'] = $blog->getDefaultSkin();
2045 if ( $type != 'blog' )
2047 $template['name'] = 'BaseSkin';
2051 $template['name'] = 'defskin';
2054 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2058 /* TODO: member object will have its own adminskin id */
2059 $template['selected'] = $CONF['AdminSkin'];
2060 $template['name'] = 'AdminSkin';
2061 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
2064 $query = sprintf($query, sql_table('skin_desc'));
2065 $template['tabindex'] = 50;
2067 $this->parser->parse(showlist($query, 'select', $template, $template_name));
2073 * AdminActions::parse_deletecomment()
2074 * Parse skinvar deletecomment
2076 * @param string $type type of infomation for comment
2079 public function parse_deletecomment($type = 'id')
2081 $commentid = intRequestVar('commentid');
2082 $comment = COMMENT::getComment($commentid);
2087 echo intRequestVar('commentid');
2090 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2092 echo $comment['member'];
2096 echo $comment['user'];
2100 $body = strip_tags($comment['body']);
2101 echo Entity::hsc(shorten($body, 300, '...'));
2107 * AdminActions::parse_deleteitembody()
2108 * Parse skinvar deleteitembody
2113 public function parse_deleteitembody()
2117 $itemid = intRequestVar('itemid');
2118 $item =& $manager->getItem($itemid, 1, 1);
2120 $body = strip_tags($item['body']);
2122 echo Entity::hsc(shorten($body, 300, '...'));
2128 * AdminActions::parse_deleteitemid()
2129 * Parse skinvar deleteitemid
2134 public function parse_deleteitemid()
2136 echo (integer) intRequestVar('itemid');
2141 * AdminActions::parse_deleteitemtitle()
2142 * Parse skinvar deleteitemtitle
2147 public function parse_deleteitemtitle()
2151 $itemid = intRequestVar('itemid');
2152 $item =& $manager->getItem($itemid, 1, 1);
2154 echo Entity::hsc(strip_tags($item['title']));
2160 * AdminActions::parse_editcomment()
2161 * Parse skinvar editcomment
2163 * @param string $type type of comment setting
2166 public function parse_editcomment($type = 'id')
2170 $comment = Admin::$contents;
2175 echo intRequestVar('commentid');
2178 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2180 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2184 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2188 echo date("Y-m-d @ H:i", $comment['timestamp']);
2191 $comment['body'] = str_replace('<br />', '', $comment['body']);
2192 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2193 echo $comment['body'];
2196 echo $comment['userid'];
2199 echo $comment['userid'];
2202 if ( array_key_exists($type, $comment) && !empty($comment[$type]) )
2204 echo $comment[$type];
2212 * AdminActions::parse_editdesturl()
2213 * Parse skinvar editdesturl
2215 public function parse_editdesturl()
2217 if ( requestVar('desturl') )
2219 echo Entity::hsc(requestVar('desturl'));
2225 * AdminActions::parse_editmemberlist()
2226 * Parse skinvar editmemberlist
2228 * @param string $template_name name of template
2231 public function parse_editmemberlist($template_name = '')
2234 // show list of members with actions
2235 $query = 'SELECT * FROM %s;';
2236 $query = sprintf($query, sql_table('member'));
2238 $resource = DB::getResult($query);
2239 if ( $resource->rowCount() > 0 )
2241 $template['content'] = 'memberlist';
2242 $template['tabindex'] = 10;
2244 $this->parser->parse(listplug_batchlist('member', $resource, 'table', $template));
2250 $resource->closeCursor();
2256 * AdminActions::parse_editmember()
2257 * Parse skinvar editmember
2259 * @param string $type type of information for member
2260 * @return string $tempateName name of template to use
2263 public function parse_editmember($type = 'id', $template_name = '')
2265 global $CONF, $manager, $member;
2267 $memberid = intRequestVar('memberid');
2268 $mem =& $manager->getMember($memberid);
2273 echo intRequestVar('memberid');
2276 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2278 echo Entity::hsc($mem->getDisplayName());
2282 $dispName = Entity::hsc($mem->getDisplayName());
2283 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2285 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2294 echo Entity::hsc($mem->getRealName());
2297 echo Entity::hsc($mem->getEmail());
2300 echo Entity::hsc($mem->getURL());
2303 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $template_name);
2306 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $template_name);
2309 echo Entity::hsc($mem->getNotes());
2312 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $template_name);
2321 * AdminActions::parse_editpluginfo()
2322 * Parse skinvar editpluginfo
2324 * @param string $type type of plugin info
2327 public function parse_editpluginfo($type)
2331 $pid = intRequestVar('plugid');
2338 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2345 * AdminActions::parse_editplugoptionslist()
2346 * Parse skinvar editplugoptionslist
2348 * @param string $template_name name of template
2351 public function parse_editplugoptionslist($template_name = '')
2355 $pid = intRequestVar('plugid');
2356 $aOptions = array();
2359 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2360 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2361 $resource = DB::getResult($query);
2363 foreach ( $resource as $row )
2365 $aOIDs[] = $row['oid'];
2366 $aOptions[$row['oid']] = array(
2367 'oid' => $row['oid'],
2368 'value' => $row['odef'],
2369 'name' => $row['oname'],
2370 'description' => $row['odesc'],
2371 'type' => $row['otype'],
2372 'typeinfo' => $row['oextra'],
2377 // fill out actual values
2378 if ( count($aOIDs) > 0 )
2380 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2381 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2383 $result = DB::getResult($query);
2384 foreach ( $result as $row )
2386 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2392 'context' => 'global',
2394 'options' => &$aOptions
2396 $manager->notify('PrePluginOptionsEdit', $data);
2398 if ( sizeof($aOptions) > 0 )
2400 $template['content'] = 'plugoptionlist';
2401 $this->parser->parse(showlist($aOptions, 'table', $template, $template_name));
2405 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2411 * AdminActions::parse_editskin()
2412 * Parse skinvar editskin
2414 * @param string $type type of skin
2417 public function parse_editskin($type = 'id')
2421 $skinid = intRequestVar('skinid');
2423 if ( !preg_match('#^admin#', $this->skintype) )
2425 $skin =& $manager->getSKIN($skinid);
2429 $skin =& $manager->getSKIN($skinid, 'AdminActions');
2435 echo intRequestVar('skinid');
2438 echo Entity::hsc($skin->getName());
2441 echo Entity::hsc($skin->getDescription());
2444 echo Entity::hsc($skin->getContentType());
2447 echo Entity::hsc($skin->getIncludePrefix());
2450 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2458 * AdminActions::parse_editskintype()
2459 * Parse skinvar editskintype
2461 * @param string $type name of type for skin type
2464 public function parse_editskintype($stype = 'id')
2468 static $skin = NULL;
2469 static $types = array();
2471 if ( $skin == NULL )
2473 $skinid = intRequestVar('skinid');
2475 if ( !preg_match('#^admin#', $this->skintype) )
2477 $skin =& $manager->getSkin($skinid);
2481 $skin =& $manager->getSkin($skinid, 'AdminActions');
2484 $types = $skin->getDefaultTypes();
2487 $type = strtolower(trim(requestVar('type')));
2492 echo $skin->getID();
2495 echo Entity::hsc($skin->getName());
2498 echo Entity::hsc($skin->getDescription());
2501 echo Entity::hsc($skin->getContentType());
2504 echo Entity::hsc($skin->getContentFromDB($type));
2507 if ( !array_key_exists($type, $types) )
2509 $skinType = ucfirst($type);
2513 $skinType = $types[$type];
2515 echo Entity::hsc($skinType);
2518 echo Entity::hsc($type);
2521 echo Entity::hsc($skin->getIncludePrefix());
2524 if ( !$skin->getIncludeMode() != 'skindir' )
2526 $incMode = _PARSER_INCMODE_NORMAL;
2530 $incMode = _PARSER_INCMODE_SKINDIR;
2532 echo Entity::hsc($incMode);
2541 * AdminActions::parse_adminurl()
2542 * Parse skinvar adminurl
2543 * (shortcut for admin url)
2548 public function parse_adminurl()
2550 $this->parse_sitevar('adminurl');
2555 * AdminActions::parse_edittemplateinfo()
2556 * Parse skinvar edittemplateinfo
2558 * @param string $format format to output
2559 * @param string $typedesc type of template
2560 * @param string $typename type name of template
2561 * @param string $help help text
2562 * @param string $tabindex index value for tabindex attribute of input element
2563 * @param string $big textarea size
2564 * @param string $tplt name of template to be filled
2567 public function parse_edittemplateinfo($format, $typedesc = '', $typename = '', $help = '', $tabindex = 0, $big = 0, $template_name = '')
2571 static $name = NULL;
2572 static $desc = NULL;
2576 $id = intRequestVar('templateid');
2579 if ( $name == NULL )
2581 $name = Template::getNameFromId($id);
2584 if ( $desc == NULL )
2586 $desc = Template::getDesc($id);
2589 $template =& $manager->getTemplate($name);
2597 echo Entity::hsc($name);
2600 echo Entity::hsc($desc);
2602 case 'extratemplate':
2604 $pluginfields = array();
2605 if ( !preg_match('#^admin/#', $this->skintype) )
2607 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2611 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
2614 foreach ( $pluginfields as $ptkey => $ptvalue )
2619 $tmplt =& $manager->getTemplate($desc);
2622 /* extra plugin field */
2623 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2627 . "<th colspan=\"2\"><%explugtplname%></th>\n";
2631 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2634 'explugtplname' => Entity::hsc($ptkey)
2636 echo Template::fill($base, $data);
2638 foreach ( $ptvalue as $ptname => $ptdesc )
2640 if ( !array_key_exists($ptname, $template) )
2646 $content = $template[$ptname];
2648 $this->parser->parse(listplug_templateEditRow($content, $ptdesc, $ptname, $help, $tabidx++, $big, $template_name));
2654 $typedesc = defined($typedesc) ? constant($typedesc) : $typedesc;
2655 $typename = defined($typename) ? constant($typename) : $typename;
2657 if ( !array_key_exists($typename, $template) )
2663 $content = $template[$typename];
2665 $this->parser->parse(listplug_templateEditRow($content, $typedesc, $typename, $help, $tabindex, $big, $template_name));
2673 * AdminActions::parse_eventformextra()
2674 * Parse skinvar eventformextra
2676 * @param string $type name of type for event form extra
2679 public function parse_eventformextra($type = 'activation')
2688 $key = requestVar('ackey');
2691 Admin::error(_ERROR_ACTIVATE);
2693 $info = MEMBER::getActivationInfo($key);
2696 Admin::error(_ERROR_ACTIVATE);
2698 $mem =& $manager->getMember($info->vmember);
2701 Admin::error(_ERROR_ACTIVATE);
2704 'type' => 'activation',
2708 case 'membermailform-notloggedin':
2709 $data = array('type' => 'membermailform-notloggedin',);
2712 $manager->notify('FormExtra', $data);
2717 * AdminActions::parse_extrahead()
2718 * Parse skinvar extrahead
2720 public function parse_extrahead()
2724 $extrahead = Admin::getAdminextrahead();
2727 'extrahead' => &$extrahead,
2728 'action' => Admin::getAdminAction()
2731 $manager->notify('AdminPrePageHead', $data);
2733 $this->parser->parse($extrahead);
2738 * AdminActions::parse_member()
2739 * Parse skinvar member
2740 * (includes a member info thingie)
2742 * @param string $what which memberdata is needed
2745 public function parse_member($what)
2747 global $memberinfo, $member, $CONF;
2749 // 1. only allow the member-details-page specific variables on member pages
2750 if ( $this->skintype == 'member' )
2755 echo Entity::hsc($memberinfo->getDisplayName());
2758 echo Entity::hsc($memberinfo->getRealName());
2761 echo Entity::hsc($memberinfo->getNotes());
2764 echo Entity::hsc($memberinfo->getURL());
2767 echo Entity::hsc($memberinfo->getEmail());
2770 echo Entity::hsc($memberinfo->getID());
2775 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2776 if ( $member->isLoggedIn() )
2781 echo $member->getDisplayName();
2783 case 'yourrealname':
2784 echo $member->getRealName();
2787 echo $member->getNotes();
2790 echo $member->getURL();
2793 echo $member->getEmail();
2796 echo $member->getID();
2798 case 'yourprofileurl':
2799 if ( $CONF['URLMode'] == 'pathinfo' )
2801 echo Link::create_member_link($member->getID());
2805 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
2814 * AdminActions::parse_version()
2815 * Parse skinvar version
2816 * (include nucleus versionnumber)
2821 public function parse_version()
2824 echo 'Nucleus CMS ' . $nucleus['version'];
2829 * AdminActions::parse_sitevar()
2830 * Parse skinvar sitevar
2831 * (include a sitevar)
2833 * @param string $which
2836 public function parse_sitevar($which)
2842 echo $CONF['IndexURL'];
2845 echo $CONF['SiteName'];
2848 echo $CONF['AdminEmail'];
2851 echo $CONF['AdminURL'];
2858 * AdminActions::parse_actionurl()
2864 public function parse_actionurl()
2867 echo Entity::hsc($CONF['ActionURL']);
2872 * AdminActions::parse_getblogsetting()
2873 * Parse skinvar getblogsetting
2875 public function parse_getblogsetting($which)
2877 global $blog, $manager;
2883 elseif ( $bid = intRequestVar('blogid') )
2885 $b =& $manager->getBlog($bid);
2895 return Entity::hsc($b->getID());
2898 return Entity::hsc($b->getURL());
2901 return Entity::hsc($b->getName());
2904 return Entity::hsc($b->getDescription());
2907 return Entity::hsc($b->getShortName());
2909 case 'notifyaddress':
2910 return Entity::hsc($b->getNotifyAddress());
2913 return Entity::hsc($b->getMaxComments());
2916 return Entity::hsc($b->getUpdateFile());
2919 return Entity::hsc($b->getTimeOffset());
2926 * AdminActions::parse_geteditpluginfo()
2927 * Parse skinvar geteditpluginfo
2929 * @param string $type name of setting for edit plugin info
2932 public function parse_geteditpluginfo($type)
2935 $pid = intRequestVar('plugid');
2942 return Entity::hsc($manager->getPluginNameFromPid($pid));
2949 * AdminActions::parse_getmember()
2950 * Parse skinvar getmember
2951 * (includes a member info thingie)
2953 * @param string $what name of setting for member
2956 public function parse_getmember($what)
2958 global $memberinfo, $member;
2959 // 1. only allow the member-details-page specific variables on member pages
2960 if ( $this->skintype == 'member' )
2965 return Entity::hsc($memberinfo->getDisplayName());
2968 return Entity::hsc($memberinfo->getRealName());
2971 return Entity::hsc($memberinfo->getNotes());
2974 return Entity::hsc($memberinfo->getURL());
2977 return Entity::hsc($memberinfo->getEmail());
2980 return Entity::hsc($memberinfo->getID());
2984 // 2. the next bunch of options is available everywhere, as long as the user is logged in
2985 if ( $member->isLoggedIn() )
2990 return $member->getDisplayName();
2992 case 'yourrealname':
2993 return $member->getRealName();
2996 return $member->getNotes();
2999 return $member->getURL();
3002 return $member->getEmail();
3005 return $member->getID();
3013 * AdminActions::parse_headmessage()
3014 * Parse skinvar headmessage
3019 public function parse_headmessage()
3021 if ( !empty(Admin::$headMess) )
3023 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3029 * AdminActions::parse_helplink()
3030 * Parse skinvar helplink
3032 * @param string $topic name of topic for help
3035 public function parse_helplink($topic = '')
3037 if ( !empty($topic) )
3045 * AdminActions::parse_helpplugname()
3046 * Parse skinvar helpplugname
3051 public function parse_helpplugname()
3053 $plugid = intGetVar('plugid');
3054 Entity::hsc($manager->getPluginNameFromPid($plugid));
3059 * AdminActions::parse_ilistaddnew()
3060 * Parse skinvar ilistaddnew
3065 public function parse_ilistaddnew()
3067 $blogid = intRequestVar('blogid');
3068 if ( intPostVar('start') == 0 )
3070 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3076 * AdminActions::parse_importskininfo()
3077 * Parse skinvar importskininfo
3079 * @param string $type name of information for imported skin
3082 public function parse_importskininfo($type)
3087 echo Entity::hsc(requestVar('skininfo'));
3090 $dataArr = requestArray('skinnames');
3091 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3094 $dataArr = requestArray('tpltnames');
3095 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3098 $dataArr = requestArray('skinclashes');
3099 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3102 $dataArr = requestArray('tpltclashes');
3103 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3106 echo Entity::hsc(requestVar('skinfile'));
3109 echo Entity::hsc(requestVar('mode'));
3116 * AdminActions::parse_init()
3117 * some init stuff for all forms
3122 public function parse_init()
3127 if ( requestVar('action') == 'itemedit' )
3129 $authorid = Admin::$contents['authorid'];
3132 Admin::$blog->insertJavaScriptInfo($authorid);
3137 * AdminActions::parse_inputyesno()
3138 * Parse skinvar inputyesno
3140 * @param string $name
3141 * @param string $checkedval
3142 * @param string $tabindex
3143 * @param string $value1
3144 * @param string $value2
3145 * @param string $yesval
3146 * @param string $noval
3147 * @param string $isAdmin
3148 * @param string $template_name
3151 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $template_name = '')
3153 $this->parser->parse(listplug_input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $template_name));
3158 * AdminActions::parse_insertpluginfo()
3159 * Parse templatevar insertpluginfo
3161 public function parse_insertpluginfo($type)
3163 $option = Admin::getAdminaOption();
3167 return $option['pid'];
3170 return Entity::hsc($option['pfile']);
3177 * AdminActions::parse_insplugoptcontent()
3178 * Parse skinvar insplugoptcontent
3183 public function parse_insplugoptcontent()
3185 $option = Admin::getAdminaOption();
3187 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3188 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3191 listplug_plugOptionRow($option);
3198 * AdminActions::parse_iprangeinput()
3199 * Parse skinvar iprangeinput
3204 public function parse_iprangeinput()
3206 if ( requestVar('ip') )
3208 $iprangeVal = Entity::hsc(requestVar('ip'));
3209 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3210 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3211 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3212 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3213 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3217 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3218 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3224 * AdminActions::parse_itemnavlist()
3225 * Parse skinvar itemnavlist
3230 public function parse_itemnavlist($template_name)
3232 global $CONF, $manager, $member;
3234 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3235 . " FROM %s, %s, %s, %s"
3236 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3238 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3240 if ( $this->skintype == 'itemlist' )
3243 if ( array_key_exists('blogid', $_REQUEST) )
3245 $blogid = intRequestVar('blogid');
3247 else if ( array_key_exists('itemid', $_REQUEST) )
3249 $itemid = intRequestVar('itemid');
3250 $item = &$manager->getItem($itemid, 1, 1);
3251 $blogid = (integer) $item['blogid'];
3253 $blog =& $manager->getBlog($blogid);
3255 $query .= " AND iblog={$blogid}";
3256 $template['now'] = $blog->getCorrectTime(time());
3258 // non-blog-admins can only edit/delete their own items
3259 if ( !$member->blogAdminRights($blogid) )
3261 $query .= ' AND iauthor = ' . $member->getID();
3264 elseif ( $this->skintype == 'browseownitems' )
3266 $query .= ' AND iauthor = ' . $member->getID();
3268 $template['now'] = time();
3271 // search through items
3272 $search = postVar('search');
3274 if ( !empty($search) )
3276 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3277 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3278 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3281 if ( postVar('start') )
3283 $start = intPostVar('start');
3290 // amount of items to show
3291 if ( postVar('amount') )
3293 $amount = intPostVar('amount');
3297 $amount = (integer) $CONF['DefaultListSize'];
3304 $query .= ' ORDER BY itime DESC'
3305 . " LIMIT {$start},{$amount}";
3307 $resource = DB::getResult($query);
3308 if ( $resource->rowCount() > 0 )
3310 $template['action'] = $this->skintype;
3311 $template['start'] = $start;
3312 $template['amount'] = $amount;
3313 $template['minamount'] = 0;
3314 $template['maxamount'] = 1000;
3315 $template['blogid'] = $blogid;
3316 $template['search'] = $search;
3317 $template['itemid'] = 0;
3319 $template['content'] = 'itemlist';
3321 $this->parser->parse(listplug_navlist('item', $query, 'table', $template));
3325 /* TODO: nothing to be shown */
3327 $resource->closeCursor();
3333 * AdminActions::parse_itemtime()
3334 * date change on edit item
3336 * @param string $key key of PHP's getDate()
3339 public function parse_itemtime($key)
3344 $itemid = intRequestVar('itemid');
3345 $item =& $manager->getItem($itemid, 1, 1);
3349 $blog =& $manager->getBlog($item['blogid']);
3351 if ( $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3353 $item['body'] = removeBreaks($item['body']);
3354 $item['more'] = removeBreaks($item['more']);
3358 $contents = array();
3359 if ( requestVar('action') == 'itemedit' )
3363 elseif ( requestVar('action') == 'createitem' )
3366 'contents' => &$contents,
3367 'blog' => &$this->blog
3369 $manager->notify('PreAddItemForm', $data);
3371 $itemtime = getdate($contents['timestamp']);
3372 echo $itemtime[$key];
3377 * AdminActions::parse_jstoolbaroptions()
3378 * Parse skinvar jstoolbaroptions
3383 public function parse_jstoolbaroptions()
3387 _SETTINGS_JSTOOLBAR_NONE,
3388 _SETTINGS_JSTOOLBAR_SIMPLE,
3389 _SETTINGS_JSTOOLBAR_FULL
3393 foreach ( $options as $option )
3395 $text = "<option value=\"%d\"%s>%s</option>\n";
3396 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3397 echo sprintf($text, $i, $extra, $option);
3403 * AdminActions::parse_localeselectoptions()
3404 * Parse skinvar localeselectoptions
3409 public function parse_localeselectoptions()
3413 $locales = i18n::get_available_locale_list();
3415 $memid = intRequestVar('memberid');
3418 $mem =& $manager->getMember($memid);
3419 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3421 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3425 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3430 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3432 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3436 echo "<option value=\"\">en_Latn_US</option>\n";
3439 foreach ( $locales as $locale )
3441 if ( $locale == 'en_Latn_US' )
3447 if ( $locale == $mem->getLocale() )
3449 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3453 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3458 if ( $locale == i18n::get_current_locale() )
3460 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3464 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3472 * AdminActions::parse_listplugplugoptionrow()
3473 * Parse templatevar listplugplugoptionrow
3475 * @param string $template_name name of template
3478 public function parse_listplugplugoptionrow($template_name = '')
3480 echo listplug_plugOptionRow(Admin::getAdminaOption(), $template_name);
3485 * AdminActions::parse_mediadirwarning()
3486 * Parse skinvar mediadirwarning
3491 public function parse_mediadirwarning()
3494 if ( !is_dir($DIR_MEDIA) )
3496 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3498 if ( !is_readable($DIR_MEDIA) )
3500 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3502 if ( !is_writeable($DIR_MEDIA) )
3504 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3510 * AdminActions::parse_movedistselect()
3511 * Parse skinvar movedistselect
3513 public function parse_movedistselect()
3515 $actionType = requestVar('action');
3516 switch ( $actionType )
3519 $this->selectBlog('destcatid', 'category');
3521 case 'batchcategory':
3522 $this->selectBlog('destblogid');
3525 if ( $this->skintype == 'itemmove' )
3527 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3528 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3529 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3530 $this->selectBlog('catid', 'category', $catid, 10, 1);
3538 * AdminActions::parse_moveitemid()
3539 * Parse skinvar moveitemid
3544 public function parse_moveitemid()
3546 echo intRequestVar('itemid');
3551 * AdminActions::parse_newestcompare()
3552 * Parse skinvar newestcompare
3557 public function parse_newestcompare()
3561 $newestVersion = getLatestVersion();
3562 $newestCompare = str_replace('/', '.', $newestVersion);
3563 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3565 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3567 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3568 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3574 * AdminActions::parse_newmemberselect()
3575 * Parse skinvar newmemberselect
3577 * @param string $template_name name of template to use
3580 public function parse_newmemberselect($template_name = '')
3582 $blogid = intRequestVar('blogid');
3584 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3585 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3586 $res = DB::getResult($query);
3589 foreach ( $res as $row )
3591 $tmem[] = intval($row['tmember']);
3594 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3595 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3598 'name' => 'memberid',
3599 'tabindex' => 10000,
3602 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3607 * AdminActions::parse_newpluginlist()
3608 * Parse skinvar newpluginlist
3613 public function parse_newpluginlist()
3615 $candidates = $this->newPlugCandidates;
3616 foreach ( $candidates as $name )
3618 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3624 * AdminActions::parse_outputspecialdirs()
3625 * Parse skinvar outputspecialdirs
3627 * @param string $type type of setting for directory
3630 public function parse_outputspecialdirs($type)
3632 global $DIR_MEDIA, $DIR_NUCLEUS;
3637 echo Entity::hsc($DIR_NUCLEUS);
3640 echo Entity::hsc($DIR_MEDIA);
3647 * AdminActions::parse_passrequestvars()
3648 * Parse skinvar passrequestvars
3653 public function parse_passrequestvars()
3655 $passvar = Admin::getAdminpassvar();
3656 $oldaction = postVar('oldaction');
3658 if ( ($oldaction != 'logout')
3659 && ($oldaction != 'login')
3661 && !postVar('customaction') )
3669 * AdminActions::parse_pluginextras()
3670 * Parse skinvar pluginextras
3672 * @param string $type type of plugin context
3675 public function parse_pluginextras($type = 'global')
3682 $id = intRequestVar('memberid');
3683 $mem =& $manager->getMember($id);
3684 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
3687 $id = intRequestVar('blogid');
3688 $blg =& $manager->getBlog($id);
3689 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
3691 case 'createaccount':
3693 'type' => 'createaccount.php',
3695 'postlabel' => '<br />',
3697 'postfield' => '<br /><br />'
3699 $manager->notify('RegistrationFormExtraFields', $data);
3702 $manager->notify('GeneralSettingsFormExtras', array());
3709 * AdminActions::parse_pluginhelp()
3710 * Parse skinvar pluginhelp
3715 public function parse_pluginhelp()
3717 global $manager, $DIR_PLUGINS;
3719 $plugid = intGetVar('plugid');
3720 $plugName = $manager->getPluginNameFromPid($plugid);
3721 $plug =& $manager->getPlugin($plugName);
3723 if ( $plug->supportsFeature('HelpPage') > 0 )
3725 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3726 if ( @file_exists($helpfile . 'php') )
3728 @include($helpfile . 'php');
3731 elseif ( @file_exists($helpfile . 'html') )
3733 @include($helpfile . 'html');
3737 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3738 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3743 * AdminActions::parse_pluginlistlist()
3744 * Parse skinvar pluginlistlist
3746 * @param string $template_name name of template to use
3749 public function parse_pluginlistlist($template_name = '')
3751 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3752 $query = sprintf($query, sql_table('plugin'));
3754 $template['content'] = 'pluginlist';
3755 $template['tabindex'] = 10;
3757 $this->parser->parse(showlist($query, 'table', $template, $template_name));
3763 * AdminActions::parse_pluginoptions()
3764 * Parse skinvar pluginoptions
3766 * @param string $type type of plugin option
3769 public function parse_pluginoptions($context='global', $template_name='')
3771 global $itemid, $manager;
3776 $contextid = intRequestVar('memberid');
3779 $contextid = intRequestVar('blogid');
3782 $contextid = intRequestVar('catid');
3785 $contextid = $itemid;
3789 /* Actually registererd plugin options */
3790 $aIdToValue = array();
3791 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
3792 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
3793 $res = DB::getResult($query);
3794 foreach ( $res as $row )
3796 $aIdToValue[$row['oid']] = $row['ovalue'];
3799 /* Currently available plugin options */
3800 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
3801 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
3802 $res = DB::getResult($query);
3805 foreach ($res as $row )
3807 if ( !array_key_exists($row['oid'], $aIdToValue) )
3809 $value = $row['odef'];
3813 $value = $aIdToValue[$row['oid']];
3817 'pid' => $row['pid'],
3818 'pfile' => $row['pfile'],
3819 'oid' => $row['oid'],
3821 'name' => $row['oname'],
3822 'description' => $row['odesc'],
3823 'type' => $row['otype'],
3824 'typeinfo' => $row['oextra'],
3825 'contextid' => $contextid,
3831 'context' => $context,
3832 'contextid' => $contextid,
3833 'options' => &$options
3835 $manager->notify('PrePluginOptionsEdit', $data);
3837 $template = array();
3838 if ( $template_name )
3840 $templates =& $manager->getTemplate($template_name);
3841 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3843 $template['title'] = "<tr>"
3844 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3849 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3852 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3854 $template['body'] = "<tr>"
3855 . "<%listplugplugoptionrow%>"
3860 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3866 foreach ( $options as $option )
3869 if ( $prevPid != $option['pid'] )
3871 $prevPid = $option['pid'];
3872 $this->parser->parse($template['title']);
3875 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3877 if ( @$meta['access'] != 'hidden' )
3879 $parsed = $this->parser->parse($template['body']);
3887 * AdminActions::parse_qmenuaddselect()
3888 * Parse skinvar qmanuaddselect
3890 * @param string $template_name name of template to use
3893 public function parse_qmenuaddselect($template_name = '')
3895 global $member, $blogid;
3896 $showAll = requestVar('showall');
3897 if ( $member->isAdmin() && ($showAll == 'yes') )
3899 // Super-Admins have access to all blogs! (no add item support though)
3900 $query = 'SELECT bnumber as value, bname as text FROM %s ORDER BY bname;';
3901 $query = sprintf($query, sql_table('blog'));
3905 $query = 'SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;';
3906 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
3909 $template['name'] = 'blogid';
3910 $template['tabindex'] = 15000;
3911 $template['extra'] = _QMENU_ADD_SELECT;
3912 $template['selected'] = 0;
3913 $template['shorten'] = 10;
3914 $template['shortenel'] = '';
3915 $template['javascript'] = 'onchange="return form.submit()"';
3917 $this->parser->parse(showlist($query, 'select', $template, $template_name));
3923 * AdminActions::parse_quickmenu()
3924 * Parse skinvar quickmenu
3926 * @param string $template_name name of template to use
3929 public function parse_quickmenu($template_name = '')
3932 $templates = array();
3934 if ( !empty($template_name) )
3936 $templates = & $manager->getTemplate($template_name);
3938 $pluginExtras = array();
3939 $manager->notify('QuickMenu', array('options' => &$pluginExtras));
3941 $template = array();
3942 if ( count($pluginExtras) > 0 )
3944 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
3946 $template['head'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n"
3951 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
3954 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
3956 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
3960 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
3963 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
3965 $template['foot'] = "</ul>\n";
3969 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
3972 $this->parser->parse($template['head']);
3973 foreach ( $pluginExtras as $aInfo )
3976 'plugadminurl' => Entity::hsc($aInfo['url']),
3977 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
3978 'plugadmintitle' => Entity::hsc($aInfo['title']),
3980 $this->parser->parse(Template::fill($template['body'], $data));
3982 $this->parser->parse($template['foot']);
3988 * AdminActions::parse_requestblogid()
3989 * Parse skinvar requestblogid
3994 public function parse_requestblogid()
3996 echo intRequestVar('blogid');
4001 * AdminActions::parse_requestiprange()
4002 * Parse skinvar requestiprange
4007 public function parse_requestiprange()
4009 if ( requestVar('iprange') )
4011 echo Entity::hsc(requestVar('iprange'));
4013 elseif ( requestVar('ip') )
4015 echo Entity::hsc(requestVar('ip'));
4021 * AdminActions::parse_selectlocalskinfiles()
4022 * Parse skinvar selectlocalskinfiles
4027 public function parse_selectlocalskinfiles()
4031 if ( !class_exists('SkinImport', FALSE) )
4033 include_libs('skinie.php');
4036 if ( !preg_match('#^admin#', $this->skintype) && $this->skintype != 'importAdmin' )
4038 $skindir = $DIR_SKINS;
4042 $skindir = "{$DIR_SKINS}admin/";
4045 $candidates = SkinImport::searchForCandidates($skindir);
4046 foreach ( $candidates as $skinname => $skinfile )
4048 $skinfile = Entity::hsc($skinfile);
4049 $skinname = Entity::hsc($skinname);
4050 echo "<option value=\"{$skinfile}\">{$skinname}</option>\n";
4057 * AdminActions::parse_skineditallowedlist()
4058 * Parse skinvar skineditallowedlist
4060 * @param string $type type of skin
4061 * @param string $template_name name of template
4064 public function parse_skineditallowedlist($type, $template_name = '')
4069 $query = "SELECT bshortname, bname FROM %s;";
4071 'content' => 'shortblognames'
4073 $query = sprintf($query, sql_table('blog'));
4076 if ( !preg_match('#^admin#', $this->skintype) )
4078 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4082 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%';";
4085 'content' => 'shortnames'
4087 $query = sprintf($query, sql_table('template_desc'));
4091 $this->parser->parse(showlist($query, 'table', $show, $template_name));
4096 * AdminActions::parse_skinielist()
4097 * Parse skinvar skinielist
4099 * @param string $type type of skin
4100 * @param string $template_name name of template to use
4103 public function parse_skinielist($type, $template_name = '')
4107 $templates = array();
4108 if ( $template_name )
4110 $templates =& $manager->getTemplate($template_name);
4112 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
4115 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4116 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4118 . "<td><%expdesc%></td>\n"
4124 $template = $templates['SKINIE_EXPORT_LIST'];
4130 if ( !preg_match('#^admin#', $this->skintype) )
4132 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4136 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname LIKE 'admin/%%';");
4138 foreach ( $res as $row )
4141 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4142 'expid' => 'skinexp' . $row['sdnumber'],
4143 'expname' => Entity::hsc($row['sdname']),
4144 'expdesc' => Entity::hsc($row['sddesc'])
4146 echo Template::fill($template, $data);
4150 if ( !preg_match('#^admin#', $this->skintype) )
4152 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4156 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname LIKE 'admin/%%';");
4158 foreach ( $res as $row )
4161 'typeid' => 'template[' . $row['tdnumber'] . ']',
4162 'expid' => 'templateexp' . $row['tdnumber'],
4163 'expname' => Entity::hsc($row['tdname']),
4164 'expdesc' => Entity::hsc($row['tddesc'])
4166 echo Template::fill($template, $data);
4174 * AdminActions::parse_skinoverview()
4175 * Parse skinvar skinoverview
4177 * @param string $template_name name of template to use
4180 public function parse_skinoverview($template_name = '')
4184 $template = array();
4185 if ( !preg_match('#^admin#', $this->skintype) )
4187 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%' ORDER BY sdname;";
4188 $template['editaction'] = 'skinedit';
4189 $template['cloneaction'] = 'skinclone';
4190 $template['deleteaction'] = 'skindelete';
4191 $template['edittypeaction'] = 'skinedittype';
4192 $template['default'] = $CONF['BaseSkin'];
4196 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
4197 $template['editaction'] = 'adminskinedit';
4198 $template['cloneaction'] = 'adminskinclone';
4199 $template['deleteaction'] = 'adminskindelete';
4200 $template['edittypeaction'] = 'adminskinedittype';
4201 $template['default'] = $CONF['AdminSkin'];
4203 $query = sprintf($query, sql_table('skin_desc'));
4205 $template['tabindex'] = 10;
4206 $template['content'] = 'skinlist';
4208 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4214 * AdminActions::parse_skintypehelp()
4215 * Check editing skintypehelp
4220 public function parse_skintypehelp()
4222 $nowSkinType = strtolower(trim(requestVar('type')));
4223 $pageAction = strtolower(trim(requestVar('action')));
4224 if ( preg_match('/^admin.*/', $pageAction) )
4226 $regularType = self::$default_skin_types;
4227 unset($regularType['memberedit']);
4228 unset($regularType['login']);
4229 $regularType = array_keys($regularType);
4233 /* TODO: use Skin class */
4234 $regularType = array(
4246 if ( in_array($nowSkinType, $regularType) )
4248 help('skinpart' . $nowSkinType);
4252 help('skinpartspecial');
4258 * AdminActions::parse_specialskinlist()
4259 * Parse skinvar specialskinlist
4261 * @param string $template_name name of template to use
4264 public function parse_specialskinlist($template_name = '')
4266 global $CONF, $manager;
4268 $template = array();
4270 $skinid = intRequestVar('skinid');
4272 if ( !preg_match('#^admin#', $this->skintype) )
4274 $skin =& $manager->getSkin($skinid);
4275 $template['editaction'] = 'skinedittype';
4276 $template['removeaction'] = 'skinremovetype';
4280 $skin =& $manager->getSkin($skinid, 'AdminActions');
4281 $template['editaction'] = 'adminskinedittype';
4282 $template['removeaction'] = 'adminskinremovetype';
4284 $normal_types = $skin->getDefaultTypes();
4285 $available_types = $skin->getAvailableTypes();
4287 $special_skintypes = array();
4288 foreach( $available_types as $skintype => $skinname )
4290 if ( !array_key_exists($skintype, $normal_types) )
4292 $special_skintypes[] = array(
4293 'skintype' => $skintype,
4294 'skintypename' => $skinname
4299 if ( sizeof($special_skintypes) > 0 )
4301 $template['tabindex'] = 75;
4302 $template['skinid'] = $skin->getID();
4303 $template['skinname'] = $skin->getName();
4304 $this->parser->parse(showlist($special_skintypes, 'list_specialskinlist', $template, $template_name));
4308 /* TODO: nothing to be shown */
4315 * AdminActions::parse_sprinttext()
4318 * @param string $which
4319 * @param string $val
4322 public function parse_sprinttext($which, $val)
4324 if ( !defined($which) )
4330 $base = constant($which);
4333 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4335 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4337 $met = 'parse_' . $matchies[0];
4341 $arg = trim($args[0], '()');
4342 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4345 if ( method_exists($this, $met) )
4347 $value = call_user_func(array(&$this, $met), $arg);
4351 if ( !isset($value) || empty($value) )
4355 echo sprintf($base, $value);
4360 * AdminActions::parse_systemsettings()
4361 * Parse skinvar systemsettings
4363 * @param string $type type of settings for system
4364 * @param string $template_name name of template to use
4367 public function parse_systemsettings($type = 'phpinfo', $template_name = '')
4369 global $manager, $member, $CONF, $nucleus;
4371 $member->isAdmin() or Admin::disallow();
4373 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4374 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4381 case 'sqlserverinfo':
4382 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4384 case 'sqlclientinfo':
4385 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4387 case 'magicquotesgpc':
4388 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4390 case 'magicquotesruntime':
4391 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4393 case 'registerglobals':
4394 echo ini_get('register_globals') ? 'On' : 'Off';
4397 $templates = array();
4398 if ( $template_name )
4400 $templates =& $manager->getTemplate($template_name);
4402 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4404 $template = "<tr>\n"
4405 . "<td><%key%></td>\n"
4406 . "<td><%value%></td>\n"
4411 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4414 $gdinfo = gd_info();
4416 foreach ( $gdinfo as $key => $value )
4418 if ( is_bool($value) )
4420 $value = $value ? $enable : $disable;
4424 $value = Entity::hsc($value);
4430 echo Template::fill($template, $data);
4435 phpinfo(INFO_MODULES);
4436 $im = ob_get_contents();
4438 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4440 case 'nucleusversion':
4441 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4443 case 'nucleuspatchlevel':
4444 echo getNucleusPatchLevel();
4450 echo $CONF['ItemURL'];
4452 case 'alertonheaderssent':
4453 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4455 case 'nucleuscodename':
4456 if ( $nucleus['codename'] != '' )
4458 echo ' "' . $nucleus['codename'] . '"';
4461 case 'versioncheckurl':
4462 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4469 * AdminActions::parse_templateoverview()
4470 * Parse skinvar templateoverview
4472 * @param string $template_name name of template to use
4475 public function parse_templateoverview($template_name = '')
4477 if ( !preg_match('#^admin#', $this->skintype) )
4479 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname;";
4480 $template['deleteaction'] = 'templatedelete';
4481 $template['editaction'] = 'templateedit';
4482 $template['cloneaction'] = 'templateclone';
4486 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
4487 $template['deleteaction'] = 'admintemplatedelete';
4488 $template['editaction'] = 'admintemplateedit';
4489 $template['cloneaction'] = 'admintemplateclone';
4491 $query = sprintf($query, sql_table('template_desc'));
4493 $template['tabindex'] = 10;
4494 $template['content'] = 'templatelist';
4496 $this->parser->parse(showlist($query, 'table', $template, $template_name));
4502 * AdminActions::parse_ticket()
4508 public function parse_ticket()
4511 $manager->addTicketHidden();
4516 * AdminActions::parse_versioncheckurl()
4517 * Parse skinvar versioncheckurl
4522 public function parse_versioncheckurl()
4524 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4529 * AdminActions::parse_yrbloglist()
4530 * Parse skinvar yrbloglist
4532 * @param string $template_name name of template to use
4535 public function parse_yrbloglist($template_name = '')
4538 $showAll = requestVar('showall');
4540 if ( $member->isAdmin() && ($showAll == 'yes') )
4542 // Super-Admins have access to all blogs! (no add item support though)
4543 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4545 . " ORDER BY bnumber;";
4546 $query = sprintf($query, sql_table('blog'));
4550 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4552 . " WHERE tblog=bnumber and tmember=%d"
4553 . " ORDER BY bnumber;";
4554 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4557 $resource = DB::getResult($query);
4558 if ( ($showAll != 'yes') && $member->isAdmin() )
4560 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4561 $total = DB::getValue($query);
4563 if ( $total > $resource->rowCount() )
4565 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4569 if ( $resource->rowCount() > 0 )
4571 $template['content'] = 'bloglist';
4572 $template['superadmin'] = $member->isAdmin();
4574 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4575 $resource->closeCursor();
4577 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4579 $query = 'SELECT ititle, inumber, bshortname FROM %s, %s '
4580 . 'WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4581 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4583 $resource = DB::getResult($query);
4584 if ( $resource->rowCount() > 0 )
4586 $template['content'] = 'draftlist';
4587 $this->parser->parse(showlist($resource, 'table', $template, $template_name));
4591 echo _OVERVIEW_NODRAFTS;
4596 echo _OVERVIEW_NOBLOGS;
4598 $resource->closeCursor();
4604 * AdminActions::checkCondition()
4605 * Checks conditions for if statements
4607 * @param string $field type of <%if%>
4608 * @param string $name property of field
4609 * @param string $value value of property
4610 * @return boolean condition
4612 protected function checkCondition($field, $name='', $value = '')
4614 global $CONF, $archiveprevexists, $archivenextexists, $blog, $catid, $itemidnext, $itemidprev, $manager, $member;
4624 $blog =& $manager->getBlog($blogid);
4628 $blogid = getBlogIDFromCatID($catid);
4629 $blog =& $manager->getBlog($blogid);
4631 elseif ( intRequestVar('catid') )
4633 $catid = intRequestVar('catid');
4634 $blogid = getBlogIDFromCatID($catid);
4635 $blog =& $manager->getBlog($blogid);
4642 $condition = ($blog && $this->ifCategory($name, $value));
4645 $condition = $member->isLoggedIn();
4648 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4651 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4654 $condition = $member->isLoggedIn() && $member->isAdmin();
4656 case 'allowloginedit':
4657 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4660 $condition = ($itemidnext != '');
4663 $condition = ($itemidprev != '');
4665 case 'archiveprevexists':
4666 $condition = ($archiveprevexists == true);
4668 case 'archivenextexists':
4669 $condition = ($archivenextexists == true);
4672 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4675 $condition = $this->ifHasPlugin($name, $value);
4678 $condition = (Admin::getAdminAction() == $name);
4680 case 'adminoldaction':
4681 $condition = (Admin::getAdminAction() == $name);
4683 case 'addresschange':
4684 $condition = ($this->ifAddresscange());
4686 case 'bechangepass':
4687 $condition = ($this->beChangePassword());
4689 case 'skincandidates':
4690 $condition = ($this->ifSkincandidates());
4693 $condition = requestVar('nameclashes');
4695 case 'existsnewplugin':
4696 $condition = ($this->existsNewPlugin());
4703 $condition = (boolean) ($member->getAutosave() == $value);
4710 $condition = (Admin::$blog->getSetting($name) == $value);
4712 case 'itemproperty':
4717 if ( array_key_exists($name, Admin::$contents) )
4719 $condition = (boolean) (Admin::$contents[$name] == $value);
4723 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4730 * AdminActions::_ifHasPlugin()
4731 * hasplugin,PlugName
4732 * -> checks if plugin exists
4733 * hasplugin,PlugName,OptionName
4734 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
4735 * hasplugin,PlugName,OptionName=value
4736 * -> checks if the option OptionName from plugin PlugName is set to value
4738 * @param string $name name of plugin
4739 * @param string $value
4742 private function ifHasPlugin($name, $value)
4746 // (pluginInstalled method won't write a message in the actionlog on failure)
4747 if ( $manager->pluginInstalled("NP_{$name}") )
4749 $plugin =& $manager->getPlugin("NP_{$name}");
4750 if ( $plugin != NULL )
4758 list($name2, $value2) = preg_split('#=#', $value, 2);
4759 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4763 else if ( $plugin->getOption($name2) == $value2 )
4774 * AdminActions::beChangePassword()
4779 private function beChangePassword()
4781 return intRequestVar('bNeedsPasswordChange');
4785 * AdminActions::ifSkincandidates()
4786 * Checks if a plugin exists and call its doIf function
4792 private function ifSkincandidates()
4795 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4796 return (count($candidates) > 0);
4800 * AdminActions::ifPlugin()
4801 * Checks if a plugin exists and call its doIf function
4803 * @param string $name name of plugin
4804 * @param string $key
4805 * @param string $value
4808 private function ifPlugin($name, $key = '', $value = '')
4812 $plugin =& $manager->getPlugin("NP_{$name}");
4818 $params = func_get_args();
4819 array_shift($params);
4821 return call_user_func_array(array(&$plugin, 'doIf'), $params);
4825 * AdminActions::ifCategory()
4826 * Different checks for a category
4828 * @param string $key key for information of category
4829 * @param string $value value for information of category
4832 private function ifCategory($key = '', $value='')
4834 global $blog, $catid;
4836 // when no parameter is defined, just check if a category is selected
4837 if (($key != 'catname' && $key != 'catid') || ($value == ''))
4839 return $blog->isValidCategory($catid);
4842 // check category name
4843 if ( $key == 'catname' )
4845 $value = $blog->getCategoryIdFromName($value);
4846 if ($value == $catid)
4848 return $blog->isValidCategory($catid);
4852 // check category id
4853 if (($key == 'catid') && ($value == $catid))
4855 return $blog->isValidCategory($catid);
4862 * AdminActions::ifOnTeam()
4863 * Checks if a member is on the team of a blog and return his rights
4865 * @param string $blogName name of weblog
4868 private function ifOnTeam($blogName = '')
4870 global $blog, $member, $manager;
4872 // when no blog found
4873 if ( ($blogName == '') && !is_object($blog) )
4878 // explicit blog selection
4879 if ($blogName != '')
4881 $blogid = getBlogIDFromName($blogName);
4884 if (($blogName == '') || !$manager->existsBlogID($blogid))
4887 $blogid = $blog->getID();
4889 return $member->teamRights($blogid);
4893 * AdminActions::ifAdmin()
4894 * Checks if a member is admin of a blog
4896 * @param string $blogName name of weblog
4899 private function ifAdmin($blogName = '')
4901 global $blog, $member, $manager;
4903 // when no blog found
4904 if (($blogName == '') && (!is_object($blog)))
4909 // explicit blog selection
4910 if ($blogName != '')
4912 $blogid = getBlogIDFromName($blogName);
4915 if (($blogName == '') || !$manager->existsBlogID($blogid))
4918 $blogid = $blog->getID();
4921 return $member->isBlogAdmin($blogid);
4925 * AdminActions::ifAddresscange()
4926 * Check e-Mail address is changed
4931 private function ifAddresscange()
4935 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4940 $info = MEMBER::getActivationInfo($key);
4945 $mem =& $manager->getMember($info->vmember);
4950 if ( $info->vtype == 'addresschange' )
4959 * AdminActions::customHelp()
4960 * shows a link to custom help file
4963 * @param string $tplName
4964 * @param string $url
4965 * @param string $iconURL
4966 * @param string $alt
4967 * @param string $title
4971 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4973 echo $this->customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
4978 * AdminActions::customHelp()
4979 * shows a link to custom help file
4982 * @param string $tplName
4983 * @param string $url
4984 * @param string $iconURL
4985 * @param string $alt
4986 * @param string $title
4990 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
4992 global $CONF, $manager;
4994 $templates = array();
4998 $templates =& $manager->getTemplate($tplName);
5001 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5003 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5007 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5012 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5015 if ( empty($onclick) )
5017 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5019 elseif ( preg_match('#^onclick#', $onclick) )
5021 $onclick = $onclick;
5025 $onclick = 'onclick="' . $onclick . '"';
5030 'helptarget' => $id,
5031 'onclick' => $onclick,
5032 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5034 return Template::fill($template, $data);
5039 * AdminActions::customHelpHtml()
5041 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5043 global $CONF, $manager;
5045 $templates = array();
5049 $templates =& $manager->getTemplate($tplName);
5051 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5053 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5057 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5060 if ( empty($iconURL) )
5062 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5065 if ( function_exists('getimagesize') )
5067 $size = getimagesize($iconURL);
5068 $width = 'width="' . $size[0] . '" ';
5069 $height = 'height="' . $size[1] . '" ';
5073 'iconurl' => $iconURL,
5075 'height' => $height,
5076 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5077 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5080 $icon = Template::fill($template, $data);
5081 $help = $this->customHelplink($id, $tplName, $url, $title, $onclick);
5083 return $help . $icon;
5087 * AdminActions::existsNewPlugin()
5088 * Check exists new plugin
5091 * @return boolean exists or not
5093 private function existsNewPlugin()
5095 global $DIR_PLUGINS;
5097 $query = "SELECT * FROM %s;";
5098 $query = sprintf($query, sql_table('plugin'));
5099 $res = DB::getResult($query);
5101 $installed = array();
5102 foreach( $res as $row )
5104 $installed[] = $row['pfile'];
5107 $files = scandir($DIR_PLUGINS);
5109 $candidates = array();
5110 foreach ( $files as $file )
5112 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5114 if ( !in_array($matches[1], $installed) )
5116 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5120 $this->newPlugCandidates = $candidates;
5121 return (count($candidates) > 0);
5125 * AdminActions::pagehead()
5126 * Output admin page head
5131 public function parse_pagehead()
5133 global $member, $nucleus, $CONF, $manager;
5135 /* HTTP 1.1 application for no caching */
5136 header("Cache-Control: no-cache, must-revalidate");
5137 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5139 $content = $this->parser->skin->getContentFromDB('pagehead');
5142 $root_element = 'html';
5143 $charset = i18n::get_current_charset();
5144 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5145 $xml_version_info = self::$xml_version_info;
5146 $formal_public_identifier = self::$formal_public_identifier;
5147 $system_identifier = self::$system_identifier;
5148 $xhtml_namespace = self::$xhtml_namespace;
5150 $content = "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n"
5151 . "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n"
5152 . "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n"
5154 . "<title><%sitevar(name)%> - Admin</title>\n"
5155 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>"
5156 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>"
5157 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>"
5161 . "<div id=\"adminwrapper\">"
5162 . "<div class=\"header\">"
5163 . "<h1><%sitevar(name)%></h1>"
5165 . "<div id=\"container\">"
5166 . "<div id=\"content\">"
5167 . "<div class=\"loginname\">"
5168 . "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"<%skinfile(admin/defaultadmin/styles/addedit.css%>\" />\n"
5169 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/edit.js)%>\"></script>\n"
5170 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/admin.js)%>\"></script>\n"
5171 . "<script type=\"text/javascript\" src=\"<%skinfile(/javascripts/compatibility.js)%>\"></script>\n"
5176 . "<div id=\"adminwrapper\">\n"
5177 . "<div class=\"header\">\n"
5178 . "<h1><%sitevar(name)%></h1>\n"
5180 . "<div id=\"container\">\n"
5181 . "<div id=\"content\">\n"
5182 . "<div class=\"loginname\">\n"
5183 . "<%if(loggedin)%>"
5184 . "<%text(_LOGGEDINAS)%> <%member(yourrealname)%> - <a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a><br />"
5185 . "<a href=\"<%adminurl%>index.php?action=overview\"><%text(_ADMINHOME)%></a> - "
5187 . "<a href=\"<%adminurl%>index.php?action=showlogin\" title=\"Log in\"><%text(_NOTLOGGEDIN)%></a><br />"
5189 . "<a href=\"<%sitevar(url)%>\"><%text(_YOURSITE)%></a><br />"
5191 . "<%if(superadmin)%>"
5192 . "<a href=\"<%versioncheckurl%>\" title=\"<%text(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE)%>\"><%version%><%codename%></a>"
5193 . "<%newestcompare%><%else%><%version%><%codename%>"
5199 $this->parser->parse($content);
5204 * AdminActionss::pagefoot()
5205 * Output admin page foot include quickmenu
5210 public function parse_pagefoot()
5212 global $action, $member, $manager, $blogid;
5215 'action' => Admin::getAdminAction()
5217 $manager->notify('AdminPrePageFoot', $data);
5219 $content = $this->parser->skin->getContentFromDB('pagefoot');
5222 $content = "<%if(loggedin)%>"
5223 . "<%ifnot(adminaction,showlogin)%>"
5224 . "<h2><%text(_LOGOUT)%></h2>"
5226 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_BACKHOME)%></a></li>"
5227 . "<li><a href=\"<%adminurl%>index.php?action=logout\"><%text(_LOGOUT)%></a></li>"
5231 . "<div class=\"foot\">"
5232 . "<a href=\"<%text(_ADMINPAGEFOOT_OFFICIALURL)%>\">Nucleus CMS</a> © 2002- <%date(%Y)%> <%text(_ADMINPAGEFOOT_COPYRIGHT)%>"
5233 . " - <a href=\"<%text(_ADMINPAGEFOOT_DONATEURL)%>\"><%text(_ADMINPAGEFOOT_DONATE)%></a>"
5236 . "<!-- content -->"
5237 . "<div id=\"quickmenu\">"
5238 . "<%if(loggedin)%>"
5239 . "<%ifnot(adminaction,showlogin)%>"
5241 . "<li><a href=\"<%adminurl%>index.php?action=overview\"><%text(_QMENU_HOME)%></a></li>"
5243 . "<h2><%text(_QMENU_ADD)%></h2>"
5244 . "<form method=\"get\" action=\"<%adminurl%>index.php\">"
5246 . "<input type=\"hidden\" name=\"action\" value=\"createitem\" />"
5247 . "<%qmenuaddselect(admin/default)%>"
5250 . "<h2><%member(yourrealname)%></h2>"
5252 . "<li><a href=\"<%adminurl%>index.php?action=editmembersettings\"><%text(_QMENU_USER_SETTINGS)%></a></li>"
5253 . "<li><a href=\"<%adminurl%>index.php?action=browseownitems\"><%text(_QMENU_USER_ITEMS)%></a></li>"
5254 . "<li><a href=\"<%adminurl%>index.php?action=browseowncomments\"><%text(_QMENU_USER_COMMENTS)%></a></li>"
5256 . "<%if(superadmin)%>"
5257 . "<h2><%text(_QMENU_MANAGE)%></h2>"
5259 . "<li><a href=\"<%adminurl%>index.php?action=actionlog\"><%text(_QMENU_MANAGE_LOG)%></a></li>"
5260 . "<li><a href=\"<%adminurl%>index.php?action=settingsedit\"><%text(_QMENU_MANAGE_SETTINGS)%></a></li>"
5261 . "<li><a href=\"<%adminurl%>index.php?action=systemoverview\"><%text(_QMENU_MANAGE_SYSTEM)%></a></li>"
5262 . "<li><a href=\"<%adminurl%>index.php?action=usermanagement\"><%text(_QMENU_MANAGE_MEMBERS)%></a></li>"
5263 . "<li><a href=\"<%adminurl%>index.php?action=createnewlog\"><%text(_QMENU_MANAGE_NEWBLOG)%></a></li>"
5264 . "<li><a href=\"<%adminurl%>index.php?action=backupoverview\"><%text(_QMENU_MANAGE_BACKUPS)%></a></li>"
5265 . "<li><a href=\"<%adminurl%>index.php?action=pluginlist\"><%text(_QMENU_MANAGE_PLUGINS)%></a></li>"
5267 . "<h2><%text(_QMENU_LAYOUT)%></h2>"
5269 . "<li><a href=\"<%adminurl%>index.php?action=skinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5270 . "<li><a href=\"<%adminurl%>index.php?action=templateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5271 . "<li><a href=\"<%adminurl%>index.php?action=skinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5273 . "<h2><%text(_SKINABLEADMIN_QMENU_LAYOUT)%></h2>"
5275 . "<li><a href=\"<%adminurl%>index.php?action=adminskinoverview\"><%text(_QMENU_LAYOUT_SKINS)%></a></li>"
5276 . "<li><a href=\"<%adminurl%>index.php?action=admintemplateoverview\"><%text(_QMENU_LAYOUT_TEMPL)%></a></li>"
5277 . "<li><a href=\"<%adminurl%>index.php?action=adminskinieoverview\"><%text(_QMENU_LAYOUT_IEXPORT)%></a></li>"
5280 . "<%quickmenu(admin/default)%>"
5282 . "<%elseif(adminaction,activate)%>"
5283 . "<h2><%text(_QMENU_ACTIVATE)%></h2>"
5284 . "<%text(_QMENU_ACTIVATE_TEXT)%>"
5285 . "<%elseif(adminaction,activatesetpwd)%>"
5286 . "<h2><%text(_QMENU_ACTIVATE)%></h2><%text(_QMENU_ACTIVATE_TEXT)%>"
5288 . "<h2><%text(_QMENU_INTRO)%></h2><%text(_QMENU_INTRO_TEXT)%>"
5291 . "<!-- content / quickmenu container -->"
5292 . "<div class=\"clear\"></div>"
5295 . "<!-- adminwrapper -->"
5299 . "<p style=\"text-align:right;\"><%benchmark%></p>"
5304 $this->parser->parse($content);
5308 * AdminActions::selectBlog()
5309 * Inserts a HTML select element with choices for all blogs to which the user has access
5310 * mode = 'blog' => shows blognames and values are blogids
5311 * mode = 'category' => show category names and values are catids
5313 * @param string $name
5314 * @param string $mode
5315 * @param integer $selected
5316 * @param integer $tabindex
5317 * @param integer $showNewCat
5318 * @param integer $iForcedBlogInclude ID for weblog always included
5319 * @param $iForcedBlogInclude
5320 * ID of a blog that always needs to be included, without checking if the
5321 * member is on the blog team (-1 = none)
5324 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5326 global $member, $CONF;
5328 // 0. get IDs of blogs to which member can post items (+ forced blog)
5329 $aBlogIds = array();
5330 if ( $iForcedBlogInclude != -1 )
5332 $aBlogIds[] = intval($iForcedBlogInclude);
5335 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5337 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5338 $query = sprintf($query, sql_table('blog'));
5342 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5343 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5346 $rblogids = DB::getResult($query);
5347 foreach ( $rblogids as $row )
5349 if ( $row['bnumber'] != $iForcedBlogInclude )
5351 $aBlogIds[] = intval($row['bnumber']);
5355 if ( count($aBlogIds) == 0 )
5360 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5362 // 1. select blogs (we'll create optiongroups)
5363 // (only select those blogs that have the user on the team)
5364 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5365 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5366 $blogs = DB::getResult($queryBlogs);
5368 if ( $mode == 'category' )
5370 if ( $blogs->rowCount() > 1 )
5374 foreach ( $blogs as $rBlog )
5376 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5378 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5381 // show selection to create new category when allowed/wanted
5384 // check if allowed to do so
5385 if ( $member->blogAdminRights($rBlog['bnumber']) )
5387 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5391 // 2. for each category in that blog
5392 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5393 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5394 $categories = DB::getResult($catQuery);
5395 foreach ( $categories as $rCat )
5397 if ( $rCat['catid'] == $selected )
5399 $selectText = ' selected="selected" ';
5405 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5408 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5416 foreach ( $blogs as $rBlog )
5418 echo '<option value="' . $rBlog['bnumber'] . '"';
5419 if ( $rBlog['bnumber'] == $selected )
5421 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5425 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";