2 if ( !class_exists('BaseActions') )
4 include $DIR_LIBS . 'BaseActions.php';
8 class AdminActions extends BaseActions
12 /* NOTE: list of whole available action names for tags
21 'adminskineditallowedlist',
24 'adminskinselectoptions',
25 'adminspecialskinlist',
26 'admintemplateoverview',
27 'allowedadminskinactions',
49 'configsettingsyesno',
52 'defaultadminskintypes',
62 'editadmintemplateinfo',
68 'editplugoptionslist',
88 'listplugplugoptionrow',
89 'localeselectoptions',
106 'selectlocaladminskinfiles',
107 'selectlocalskinfiles',
108 'skineditallowedlist',
125 * AdminActions::$default_actions
126 * list of whole action names with which this class can deal
128 static private $default_actions = array(
151 * AdminActions::$skin_type_friendly_names
152 * friendly name for wrapped page types
154 static private $default_skin_types = array(
155 'actionlog' => _ADM_SKPRT_ACTIONLOG,
156 'activate' => _ADM_SKPRT_ACTIVATE,
157 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
158 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
159 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
160 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
161 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
162 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
163 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
164 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
165 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
166 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
167 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
168 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
169 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
170 'admntemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
171 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
172 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
173 'banlist' => _ADM_SKPRT_BANLIST,
174 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
175 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
176 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
177 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
178 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
179 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
180 'batchitem' => _ADM_SKPRT_BATCHITEM,
181 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
182 'batchmove' => _ADM_SKPRT_BATCHMOVE,
183 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
184 'batchteam' => _ADM_SKPRT_BATCHTEAM,
185 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
186 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
187 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
188 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
189 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
190 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
191 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
192 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
193 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
194 'createitem' => _ADM_SKPRT_CREATEITEM,
195 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
196 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
197 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
198 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
199 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
200 'itemedit' => _ADM_SKPRT_ITEMEDIT,
201 'itemlist' => _ADM_SKPRT_ITEMLIST,
202 'itemmove' => _ADM_SKPRT_ITEMMOVE,
203 'login' => FALSE, //missing
204 'manage' => _ADM_SKPRT_MANAGE,
205 'manageteam' => _ADM_SKPRT_MANAGETEAM,
206 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
207 'memberedit' => FALSE, //missing
208 'overview' => _ADM_SKPRT_OVERVIEW,
209 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
210 'pagehead' => _ADM_SKPRT_PAGEHEAD,
211 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
212 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
213 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
214 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
215 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
216 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
217 'skindelete' => _ADM_SKPRT_SKINDELETE,
218 'skinedit' => _ADM_SKPRT_SKINEDIT,
219 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
220 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
221 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
222 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
223 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
224 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
225 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
226 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
227 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
228 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
229 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
230 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
234 * AdminActions::getAvailableSkinTypes()
238 * @return array list of friendly names for page actions
240 static public function getAvailableSkinTypes()
242 return self::$default_skin_types;
246 * AdminActions::getDefaultTypes()
250 * @return array list of friendly names for page actions
252 static public function getDefaultTypes()
254 return self::$default_skin_types;
258 * AdminActions::__construct()
259 * Constructor for a new Actions object
261 * @param string $type
264 public function __construct($type)
266 // call constructor of superclass first
267 parent::__construct();
268 $this->skintype = $type;
269 if ( !class_exists('Navlist') || !class_exists('Batch') )
272 include $DIR_LIBS . 'ENCAPSULATE.php';
278 * AdminActions::getAvailableActions()
281 * @return array allowed actions for the page type
283 public function getAvailableActions()
285 $extra_actions = array();
287 switch ( $this->skintype )
290 $extra_actions = array(
295 $extra_actions = array(
300 case 'activatesetpwd':
301 $extra_actions = array(
305 $extra_actions = array(
311 case 'adminerrorpage':
312 $extra_actions = array(
315 case 'adminskindelete':
316 $extra_actions = array(
320 case 'adminskinedit':
321 $extra_actions = array(
323 'defaultadminskintypes',
324 'adminspecialskinlist',
327 case 'adminskinedittype':
328 $extra_actions = array(
331 'allowedadminskinactions',
332 'adminskineditallowedlist',
335 case 'adminskiniedoimport':
336 $extra_actions = array(
340 case 'adminskinieimport':
341 $extra_actions = array(
345 case 'adminskinieoverview':
346 $extra_actions = array(
347 'selectlocaladminskinfiles',
351 case 'adminskinoverview':
352 $extra_actions = array(
356 case 'adminskinremovetype':
357 $extra_actions = array(
361 case 'admintemplatedelete':
362 $extra_actions = array(
363 'editadmintemplateinfo',
365 case 'admintemplateedit':
366 $extra_actions = array(
367 'editadmintemplateinfo',
370 case 'admntemplateoverview':
371 $extra_actions = array(
372 'admintemplateoverview',
375 case 'backupoverview':
376 $extra_actions = array(
379 case 'backuprestore':
380 $extra_actions = array(
384 $extra_actions = array(
390 case 'banlistdelete':
391 $extra_actions = array(
396 case 'banlistdeleteconfirm':
397 $extra_actions = array(
398 'banlistdeletedlist',
403 $extra_actions = array(
409 case 'batchcategory':
410 $extra_actions = array(
416 $extra_actions = array(
422 $extra_actions = array(
428 $extra_actions = array(
434 $extra_actions = array(
440 $extra_actions = array(
449 $extra_actions = array(
458 $extra_actions = array(
464 case 'blogcommentlist':
465 $extra_actions = array(
472 $extra_actions = array(
488 $extra_actions = array(
492 case 'browseowncomments':
493 $extra_actions = array(
497 case 'browseownitems':
498 $extra_actions = array(
502 case 'categorydelete':
503 $extra_actions = array(
509 $extra_actions = array(
516 case 'commentdelete':
517 $extra_actions = array(
522 $extra_actions = array(
527 $extra_actions = array(
539 $extra_actions = array(
545 $extra_actions = array(
550 case 'editmembersettings':
551 $extra_actions = array(
552 'adminskinselectoptions',
554 'localeselectoptions',
558 case 'itemcommentlist':
559 $extra_actions = array(
565 $extra_actions = array(
572 $extra_actions = array(
584 $extra_actions = array(
591 $extra_actions = array(
597 $extra_actions = array(
601 $extra_actions = array(
610 $extra_actions = array(
615 $extra_actions = array(
620 $extra_actions = array(
625 $extra_actions = array(
631 $extra_actions = array(
636 case 'pluginoptions':
637 $extra_actions = array(
639 'editplugoptionslist',
643 $extra_actions = array(
646 'configsettingsedit',
647 'configsettingsyesno',
650 'localeselectoptions',
656 $extra_actions = array(
661 $extra_actions = array(
666 $extra_actions = array(
672 $extra_actions = array(
675 'allowedskinactions',
676 'skineditallowedlist',
677 'skineditallowedlist',
680 case 'skiniedoimport':
681 $extra_actions = array(
686 $extra_actions = array(
690 case 'skinieoverview':
691 $extra_actions = array(
692 'selectlocalskinfiles',
697 $extra_actions = array(
701 case 'skinremovetype':
702 $extra_actions = array(
706 case 'systemoverview':
707 $extra_actions = array(
712 $extra_actions = array(
718 case 'templatedelete':
719 $extra_actions = array(
724 $extra_actions = array(
728 case 'templateoverview':
729 $extra_actions = array(
733 case 'usermanagement':
734 $extra_actions = array(
740 $extra_actions = array(
750 'selectlocaladminskinfiles',
758 $defined_actions = array_merge(self::$default_actions, $extra_actions);
760 return array_merge($defined_actions, parent::getAvailableActions());
764 * AdminActions::parse_actionloglist()
765 * Parse skinvar actionloglist
767 * @param string $templateName name of template to use
770 public function parse_actionloglist($templateName = '')
772 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
773 $query = sprintf($query, sql_table('actionlog'));
775 $template['content'] = 'actionlist';
776 $amount = showlist($query, 'table', $template, $templateName);
782 * AdminActions::parse_activationmessage()
783 * Parse skinvar activationmessage
785 * @param string $type type of message
786 * @param string $templateName name of template to use
789 public function parse_activationmessage($type, $templateName = '')
791 global $CONF, $manager;
795 if ( !empty($templateName))
797 $template = Template::read($templateName);
800 $key = postVar('ackey');
803 Admin::error(_ERROR_ACTIVATE);
806 $info = MEMBER::getActivationInfo($key);
809 Admin::error(_ERROR_ACTIVATE);
812 $mem = MEMBER::createFromId($info->vmember);
815 Admin::error(_ERROR_ACTIVATE);
817 switch ( $info->vtype )
820 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
822 $title = $template['ACTIVATE_FORGOT_TITLE'];
826 $title = _ACTIVATE_FORGOT_TITLE;
828 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
830 $text = $template['ACTIVATE_FORGOT_TEXT'];
834 $text = _ACTIVATE_FORGOT_TEXT;
838 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
840 $title = $template['ACTIVATE_REGISTER_TITLE'];
844 $title = _ACTIVATE_REGISTER_TITLE;
846 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
848 $text = $template['ACTIVATE_REGISTER_TEXT'];
852 $text = _ACTIVATE_REGISTER_TEXT;
855 case 'addresschange':
856 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
858 $title = $template['ACTIVATE_CHANGE_TITLE'];
862 $title = _ACTIVATE_CHANGE_TITLE;
864 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
866 $text = $template['ACTIVATE_CHANGE_TEXT'];
870 $text = _ACTIVATE_CHANGE_TEXT;
875 'memberName' => Entity::hsc($mem->getDisplayName()),
876 'realName' => Entity::hsc($mem->getRealName()),
881 echo Template::fill($title, $aVars);
884 echo Template::fill($text, $aVars);
887 echo Entity::hsc($key);
894 * AdminActions::parse_addtickettourl()
895 * Parse skinvar addtickettourl
897 * @param string $url URI for ticket
900 public function parse_addtickettourl($url)
903 $url = $manager->addTicketToUrl($url);
904 echo Entity::hsc($url);
909 * AdminActions::parse_adminbanlist()
910 * Parse skinvar adminbanlist
912 * @param string $templateName name of template to use
915 public function parse_adminbanlist($templateName = '')
917 $blogid = intRequestVar('blogid');
919 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
920 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
922 $template['content'] = 'banlist';
924 $amount = Showlist($query, 'table', $template, $templateName);
934 * AdminActions::parse_adminbatchaction()
935 * Parse skinvar adminbatchaction
940 public function parse_adminbatchaction()
942 echo Entity::hsc(requestVar('batchaction'));
947 * AdminActions::parse_adminbatchlist()
948 * Parse skinvar adminbatchlist
950 * @param string $templateName name of template to use
953 public function parse_adminbatchlist($templateName = '')
956 $templates = array();
958 if ( !empty($templateName) )
960 $templates = Template::read($templateName);
963 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
965 $template = '<li><%text(_BATCH_EXECUTING)%> '
966 . '<b><%adminbatchaction%></b> '
967 . '<%batchlisttype%> '
968 . '<b><%batchid%></b>... '
969 . '<b><%batchlistmsg%></b>'
974 $template = $templates['ADMIN_BATCHLIST'];
977 $selected = requestIntArray('batch');
978 $action = requestVar('batchaction');
980 switch ( $this->skintype )
983 $batchlisttype = _BATCH_ONITEM;
984 $deleteaction = 'deleteOneItem';
985 $moveaction = 'moveOneItem';
986 $destid = intRequestVar('destcatid');
989 $batchlisttype = _BATCH_ONCOMMENT;
990 $deleteaction = 'deleteOneComment';
993 $batchlisttype = _BATCH_ONMEMBER;
994 $deleteaction = 'deleteOneMember';
995 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
996 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
997 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
998 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1001 $blogid = intRequestVar('blogid');
1002 $batchlisttype = _BATCH_ONTEAM;
1003 $deleteaction = 'deleteOneTeamMember';
1004 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1005 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1006 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1007 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1009 case 'batchcategory':
1010 $batchlisttype = _BATCH_ONCATEGORY;
1011 $deleteaction = 'deleteOneCategory';
1012 $moveaction = 'moveOneCategory';
1013 $destid = intRequestVar('destblogid');
1017 // walk over all selectedids and perform action
1018 foreach ( $selected as $selectedid )
1021 $selectedid = intval($selectedid);
1025 if ( $this->skintype != 'batchteam' )
1027 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
1031 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1035 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid, $destid));
1039 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1043 // there should always remain at least one super-admin
1044 $r = DB::getResult($unsetchksql);
1045 if ( $r->rowCount() < 2 )
1047 $error = $unseterrmsg;
1051 DB::execute("UPDATE {$unsetupsql} {$selectedid};");
1055 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1059 'batchid' => $selectedid,
1060 'batchlisttype' => Entity::hsc($batchlisttype),
1061 'adminbatchaction' => Entity::hsc($action),
1062 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1065 $handler = new AdminActions('template');
1066 $parser = new Parser($handler);
1068 $output = Template::fill($template, $data);
1070 $parser->parse($output);
1071 $output = ob_get_contents();
1073 echo "{$output}<br />";
1079 * AdminActions::parse_adminbloglink()
1080 * Parse skinvar adminbloglink
1082 * @param string $templateName name of template to use
1085 public function parse_adminbloglink($templateName = '')
1088 $blogid = intRequestVar('blogid');
1089 $blog =& $manager->getBlog($blogid);
1090 $templates = array();
1092 if ( !empty($templateName) )
1094 $templates = Template::read($templateName);
1097 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1099 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1103 $template = $templates['ADMIN_BLOGLINK'];
1107 'url' => Entity::hsc($blog->getURL()),
1108 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1109 'blogname' => Entity::hsc($blog->getName())
1112 echo Template::fill($template, $data);
1117 * AdminActions::parse_adminerrormesg()
1118 * Parse skinvar adminerrormesg
1123 public function parse_adminerrormesg()
1128 if ( requestVar('errormessage') )
1130 $message = requestVar('errormessage');
1132 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1134 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1136 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1138 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1140 echo Entity::hsc($message);
1145 * AdminActions::parse_adminskineditallowedlist()
1146 * Parse skinvar adminskineditallowedlist
1148 * @param string $type template/blog
1149 * @param string $templateName name of template to use
1152 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1156 /* TODO: blog seems not to be used */
1158 $query = "SELECT bshortname, bname FROM %s";
1159 $query = sprintf($query, sql_table('blog'));
1161 'content' => 'shortblognames'
1163 Showlist($query, 'table', $show, $templateName);
1166 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1167 $query = sprintf($query, sql_table('template_desc'));
1169 'content' => 'shortnames'
1171 Showlist($query, 'table', $show, $templateName);
1178 * AdminActions::parse_adminskinielist()
1179 * Parse skinvar adminskinielist
1181 * @param string $type skin/template
1182 * @param string $templateName name of template to use
1185 public function parse_adminskinielist($type, $templateName = '')
1187 $templates = array();
1188 if ( $templateName )
1190 $templates = Template::read($templateName);
1193 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1196 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1197 . "<label for=\"<%expid%>\"><%expname%></label>"
1199 . "<td><%expdesc%></td>\n"
1205 $template = $templates['SKINIE_EXPORT_LIST'];
1211 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1212 $query = sprintf($query, sql_table('skin_desc'));
1213 $res = DB::getResult($query);
1215 foreach ( $res as $row )
1218 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1219 'expid' => 'skinexp' . $row['sdnumber'],
1220 'expname' => Entity::hsc($row['sdname']),
1221 'expdesc' => Entity::hsc($row['sddesc']),
1223 echo Template::fill($template, $data);
1227 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1228 $query = sprintf($query, sql_table('template_desc'));
1229 $res = DB::getResult($query);
1230 foreach ( $res as $row )
1233 'typeid' => 'template[' . $row['tdnumber'] . ']',
1234 'expid' => 'templateexp' . $row['tdnumber'],
1235 'expname' => Entity::hsc($row['tdname']),
1236 'expdesc' => Entity::hsc($row['tddesc']),
1238 echo Template::fill($template, $data);
1246 * AdminActions::parse_adminskinoverview()
1247 * Parse skinvar adminskinoverview
1249 * @param string $templateName name of template to use
1252 public function parse_adminskinoverview($templateName = '')
1254 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1255 $query = sprintf($query, sql_table('skin_desc'));
1257 $template['content'] = 'adminskinlist';
1258 $template['tabindex'] = 10;
1259 $template['friendly_names'] = $this->parser->skin->getAvailableTypes();
1260 Showlist($query, 'table', $template, $templateName);
1265 * AdminActions::parse_adminskinselectoptions()
1266 * Parse skinvar adminskinselectoptions
1271 public function parse_adminskinselectoptions($templateName = '')
1274 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1275 $query = sprintf($query, sql_table('skin_desc'));
1277 $template['name'] = 'adminskin';
1278 $template['selected'] = $CONF['AdminSkin'];
1279 $template['tabindex'] = 110;
1280 Showlist($query, 'select', $template, $templateName);
1285 * AdminActions::parse_adminspecialskinlist()
1286 * Parse skinvar adminspecialskinlist
1288 * @param string $templateName name of template to use
1290 public function parse_adminspecialskinlist($templateName = '')
1292 $templates = array();
1293 if ( $templateName )
1295 $templates = Template::read($templateName);
1298 $nType = $this->parser->skin->getAvailableTypes();
1299 $skinid = intRequestVar('skinid');
1301 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1302 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1304 $res = DB::getResult($query);
1305 if ( $res && $res->rowCount() > 0 )
1307 /* NOTE: set templates for HEAD/BODY/FOOT */
1308 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1310 $template['head'] = "<ul>\n";
1314 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1316 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1318 $template['body'] = '<li>'
1319 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1322 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1329 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1331 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1333 $template['foot'] = "</ul>\n";
1337 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1344 echo $template['head'];
1345 foreach ( $res as $row )
1348 'tabindex' => $tabstart++,
1349 'skinid' => $skinid,
1350 'skintype' => Entity::hsc(strtolower($row['stype']))
1352 echo Template::fill($template['body'], $data);
1355 echo $template['foot'];
1361 * AdminActions::parse_admintemplateoverview()
1362 * Parse skinvar admintemplateoverview
1364 * @param string $templateName name of template to use
1367 public function parse_admintemplateoverview($templateName = '')
1369 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1370 $query = sprintf($query, sql_table('template_desc'));
1372 $template['content'] = 'admintemplatelist';
1373 $template['tabindex'] = 10;
1375 Showlist($query, 'table', $template, $templateName);
1380 * AdminActions::parse_allowedadminskinactions()
1381 * Parse skinvar allowedadminskinactions
1386 public function parse_allowedadminskinactions()
1388 global $DIR_ADMINSKINS;
1389 $skinType = strtolower(trim(requestVar('type')));
1390 $actions = $this->parser->skin->getAllowedActionsForType($skinType);
1393 while ( $current = array_shift($actions) )
1395 // TODO: remove this
1396 // skip deprecated vars
1397 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1402 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1404 if ( count($actions) != 0 )
1413 * AdminActions::parse_allowedskinactions()
1414 * Parse skinvar allowedskinactions
1419 public function parse_allowedskinactions()
1421 $skinType = strtolower(trim(requestVar('type')));
1422 $skinid = intRequestVar('skinid');
1424 $skin = new Skin($skinid);
1425 $actions = $skin->getAllowedActionsForType($skinType);
1428 while ( $current = array_shift($actions) )
1430 // TODO: remove this
1431 // skip deprecated vars
1432 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1437 /* TODO: alternative function should be used or not? */
1438 echo helplink("skinvar-{$current}") . "$current</a>\n";
1440 if ( count($actions) != 0 )
1449 * AdminActions::parse_banlistdeletedlist()
1450 * Parse skinvar banlistdeletedlist
1452 * @param string $templateName name of template to use
1455 public function parse_banlistdeletedlist($templateName = '')
1459 $templates = array();
1460 if ( $templateName )
1462 $templates = Template::read($templateName);
1465 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1467 $template = "<li><%blogname%></li>\n";
1471 $template = $templates['BANLIST_DELETED_LIST'];
1474 $deleted = requestArray('delblogs');
1475 foreach ( $deleted as $delblog )
1477 $blog =& $manager->getBlog($delblog);
1479 'blogname' => Entity::hsc($blog->getName())
1481 echo Template::fill($template, $data);
1488 * AdminActions::parse_batchdeletelist()
1489 * Parse skinvar batchdeletelist
1494 public function parse_batchdeletelist()
1496 $selected = requestIntArray('batch');
1499 foreach ( $selected as $select )
1501 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1503 // add hidden vars for team & comment
1504 if ( requestVar('action') == 'batchteam' )
1506 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1508 if ( requestVar('action') == 'batchcomment' )
1510 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1516 * AdminActions::parse_batchdeletetype()
1517 * Parse skinvar batchdeletetype
1522 public function parse_batchdeletetype()
1524 echo Entity::hsc(requestVar('action'));
1529 * AdminActions::parse_batchmovebtn()
1530 * Parse skinvar batchmovebtn
1535 public function parse_batchmovebtn()
1537 $actionType = requestVar('action');
1538 switch ( $actionType )
1543 case 'batchcategory':
1551 * AdminActions::parse_batchmovelist()
1552 * Parse skinvar batchmovelist
1557 public function parse_batchmovelist()
1559 $selected = requestIntArray('batch');
1561 foreach ( $selected as $select )
1563 echo '<input type="hidden" name="batch[' . ($count) . ']" value="' . intval($select) . "\" />\n";
1570 * AdminActions::parse_batchmovetitle()
1571 * Parse skinvar batchmovetitle
1576 public function parse_batchmovetitle()
1578 $actionType = requestVar('action');
1579 switch ( $actionType )
1584 case 'batchcategory':
1585 echo _MOVECAT_TITLE;
1592 * AdminActions::parse_batchmovetype()
1593 * Parse skinvar batchmovetype
1598 public function parse_batchmovetype()
1600 echo Entity::hsc(requestVar('action'));
1605 * AdminActions::parse_blogcatlist()
1606 * Parse skinvar blogcatlist
1611 public function parse_blogcatlist($templateName = '')
1614 $blogid = intRequestVar('blogid');
1615 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1616 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1618 $template['content'] = 'categorylist';
1619 $template['tabindex'] = 200;
1621 $batch = new Batch('category');
1622 $batch->showlist($query, 'table', $template, $templateName);
1627 * AdminActions::parse_blogid()
1628 * Parse skinvar blogid
1633 public function parse_blogid()
1635 echo intRequestVar('blogid');
1640 * AdminActions::parse_blognotifysetting()
1641 * Parse skinvar blognotifysetting
1646 public function parse_blognotifysetting($type)
1649 $blogid = intRequestVar('blogid');
1650 $blog = $manager->getBlog($blogid);
1655 if ( !$blog->notifyOnComment() )
1661 if ( !$blog->notifyOnVote() )
1667 if ( !$blog->notifyOnNewItem() )
1673 echo ' checked="checked"';
1678 * AdminActions::parse_blogsetting()
1679 * Parse skinvar blogsetting
1681 * @param string $which name of weblog setting
1684 public function parse_blogsetting($which)
1686 echo $this->parse_getblogsetting($which);
1691 * AdminActions::parse_blogsettingyesno()
1692 * Parse skinvar blogsettingyesno
1694 * @param string $type type of weblog setting
1695 * @param string $templateName name of template to use
1698 public function parse_blogsettingyesno($type, $templateName = '')
1702 $blogid = intRequestVar('blogid');
1703 $blog = $manager->getBlog($blogid);
1707 case 'convertbreaks':
1708 $checkedval = $blog->convertBreaks();
1711 case 'allowpastposting':
1712 $checkedval = $blog->allowPastPosting();
1716 $checkedval = $blog->commentsEnabled();
1720 $checkedval = $blog->isPublic();
1724 $checkedval = $blog->emailRequired();
1728 $checkedval = $blog->getSearchable();
1732 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1737 * AdminActions::parse_blogteamlist()
1738 * Parse skinvar blogteamlist
1740 * @param string $templateName name of template to use
1743 public function parse_blogteamlist($templateName = '')
1746 $blogid = intRequestVar('blogid');
1747 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1749 . "WHERE tmember=mnumber AND tblog= %d";
1750 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1752 $template['content'] = 'teamlist';
1753 $template['tabindex'] = 10;
1755 $batch = new Batch('team');
1756 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
1761 * AdminActions::parse_blogteammembers()
1762 * Parse skinvar blogteammembers
1767 public function parse_blogteammembers()
1769 $blogid = intRequestVar('blogid');
1770 $query = "SELECT mname, mrealname "
1772 . "WHERE mnumber=tmember AND tblog=%d;";
1773 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1774 $res = DB::getResult($query);
1775 $memberNames = array();
1776 foreach ( $res as $row )
1778 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1780 echo implode(',', $memberNames);
1784 * AdminActions::parse_blogtime()
1785 * Parse skinvar blogtime
1787 * @param string $type type of time
1788 * @param string $format format for time expression
1789 * @param integer $offset offset of time
1792 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1796 if ( $type != 'blogtime' )
1798 /* return server time */
1799 $timestamp = time() + $offset;
1803 $bid = intRequestVar('blogid');
1804 $b = $manager->getBlog($bid);
1805 $timestamp = $b->getCorrectTime() + $offset;
1808 echo i18n::formatted_datetime($format, $timestamp);
1813 * AdminActions::parse_bookmarkletadmin()
1814 * Parse skinvar bookmarkletadmin
1819 public function parse_bookmarkletadmin()
1823 $blogid = intRequestVar('blogid');
1825 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1830 * AdminActions::parse_categories()
1831 * Parse skinvar categories
1833 * create category dropdown box
1835 * @param string $type name of setting for category
1838 public function parse_categories($startidx = 0)
1843 $itemid = intRequestVar('itemid');
1844 $item = &$manager->getItem($itemid, 1, 1);
1849 $blogid = intRequestVar('blogid');
1853 $blogid = $item['blogid'];
1855 $blog = &$manager->getBlog($blogid);
1857 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1859 $item['body'] = removeBreaks($item['body']);
1860 $item['more'] = removeBreaks($item['more']);
1863 $contents = array();
1864 if ( requestVar('action') == 'itemedit' )
1869 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
1872 $catid = $blog->getDefaultCategory();
1877 $catid = $contents['catid'];
1880 $this->selectBlog('catid', 'category', $catid, $startidx, 1, $blog->getID());
1886 * AdminActions::parse_category()
1887 * Parse skinvar category
1889 * @param string $type name of setting for category
1892 public function parse_category($type = 'name')
1894 echo $this->parse_getcategory($type);
1899 * AdminActions::parse_categorysetting()
1900 * Parse skinvar categorysetting
1902 * @param string $type type in category setting
1905 public function parse_categorysetting($type)
1907 $catid = intRequestVar('catid');
1908 if ( $type == 'id' )
1913 $blogid = intRequestVar('blogid');
1914 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1915 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1916 $row = DB::getRow($query);
1918 if ( $type != 'name' )
1920 echo Entity::hsc($row['cdesc']);
1924 echo Entity::hsc($row['cname']);
1931 * AdminActions::parse_codename()
1932 * Parse templatevar codename
1938 public function parse_checkedonval($value, $name)
1943 $itemid = intRequestVar('itemid');
1944 $item =& $manager->getItem($itemid, 1, 1);
1946 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1948 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1950 $item['body'] = removeBreaks($item['body']);
1951 $item['more'] = removeBreaks($item['more']);
1954 $contents = array();
1955 if ( requestVar('action') == 'itemedit' )
1959 if ( !isset($contents[$name]) )
1961 $contents[$name] = '';
1963 if ($contents[$name] == $value)
1965 echo 'checked="checked"';
1971 * AdminActions::parse_codename()
1972 * Parse templatevar codename
1977 * TODO: is this need???
1979 public function parse_codename()
1982 echo $nucleus['codename'];
1987 * AdminActions::parse_commentnavlist()
1988 * Parse skinvar commentnavlist
1993 public function parse_commentnavlist()
1995 global $CONF, $manager, $member;
1998 if ( postVar('start') )
2000 $start = intPostVar('start');
2007 // amount of items to show
2008 if ( postVar('amount') )
2010 $amount = intPostVar('amount');
2014 $amount = (integer) $CONF['DefaultListSize'];
2020 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2022 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2024 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2026 if ( $this->skintype == 'itemcommentlist' )
2028 $itemid = intRequestVar('itemid');
2029 $query .= " citem={$itemid}";
2030 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2032 $nonComments = _NOCOMMENTS;
2034 elseif ( $this->skintype == 'browseowncomments' )
2037 $query .= ' cmember=' . $member->getID();
2038 $template['canAddBan'] = 0;
2040 $nonComments = _NOCOMMENTS_YOUR;
2042 elseif ( $this->skintype == 'blogcommentlist' )
2045 $query .= ' cblog=' . intRequestVar('blogid');
2046 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2047 $bid = intRequestVar('blogid');
2048 $nonComments = _NOCOMMENTS_BLOG;
2051 $search = postVar('search');
2052 if ( !empty($search) )
2054 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2057 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2059 $template['content'] = 'commentlist';
2061 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2062 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2067 * AdminActions::parse_configsettingsedit()
2068 * Parse skinvar configsettingsedit
2070 * @param string $type type of global configuration
2073 public function parse_configsettingsedit($type)
2078 case 'DefaultListSize':
2079 if ( !array_key_exists('DefaultListSize', $CONF) )
2081 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2082 $query = sprintf($query, sql_table('config'));
2083 DB::execute($query);
2084 $CONF['DefaultListSize'] = 10;
2086 elseif ( intval($CONF['DefaultListSize']) < 1 )
2088 $CONF['DefaultListSize'] = 10;
2090 echo intval($CONF['DefaultListSize']);
2092 case 'SessionCookie':
2093 $value = $CONF['SessionCookie'];
2094 $txt1 = _SETTINGS_COOKIESESSION;
2095 $txt2 = _SETTINGS_COOKIEMONTH;
2096 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2099 $value = $CONF['URLMode'];
2100 $txt1 = _SETTINGS_URLMODE_NORMAL;
2101 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2102 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2105 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2107 echo Entity::hsc($CONF[$type]);
2115 * AdminActions::parse_configsettingsyesno()
2116 * Parse skinvar configsettingsyesno
2118 * @param string $type type of global setting
2119 * @param integer $tabindex tabindex attribute of input element
2122 public function parse_configsettingsyesno($type, $tabindex)
2125 if ( array_key_exists($type, $CONF) )
2127 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2133 * AdminActions::parse_contents()
2134 * Parse skinvar contents
2136 * @param string $which part for item
2139 public function parse_contents($which)
2141 $contents = &Admin::$item;
2143 if ( !array_key_exists($which, $contents) )
2145 $contents[$which] = '';
2147 echo Entity::hsc($contents[$which]);
2151 * AdminActions::parse_currenttime()
2152 * Parse skinvar currenttime
2154 * @param string $what
2157 public function parse_currenttime($what)
2159 $nu = getdate(Admin::$blog->getCorrectTime());
2164 * AdminActions::parse_customhelplink()
2165 * Parse skinvar customhelplink
2167 * @param string $topic name of topic
2168 * @param string $tplName name of template
2169 * @param string $url string as URI
2170 * @param string $iconURL string as URI for icon
2171 * @param string $alt alternative text for image element
2172 * @param string $title title for anchor element
2175 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2177 $this->customHelp($topic, $url, $iconURL);
2182 * AdminActions::parse_date()
2183 * Parse skinvar date
2185 public function parse_date($format = 'c')
2187 global $CONF, $manager;
2188 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2193 * AdminActions::parse_defaultadminskintypes()
2194 * Parse skinvar defaultadminskintypes
2196 * @param string $tabindex index number for tabindex attribute of input element
2197 * @param string $templateName name of template
2200 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2202 $templates = array();
2204 if ( $templateName )
2206 $templates = Template::read($templateName);
2209 $types = $this->parser->skin->getAvailableTypes();
2212 /* NOTE: set templates for HEAD/BODY/FOOT */
2213 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2215 $template['head'] = "<ul>\n";
2219 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2221 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2223 $template['body'] = "<li>"
2224 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2229 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2231 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2233 $template['foot'] = "</ul>\n";
2237 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2240 $handler = new AdminActions('template');
2241 $parser = new PARSER($handler);
2243 /* NOTE: do output */
2244 echo $template['head'];
2245 foreach ( $types as $type => $fName )
2247 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2249 'tabindex' => $tabindex,
2250 'skintype' => $type,
2252 'help' => $helplink,
2253 'skinid' => intrequestVar('skinid'),
2255 $parser->parse(Template::fill($template['body'], $data));
2258 echo $template['foot'];
2264 * AdminActions::parse_defblogselect()
2265 * Parse skinvar defblogselect
2267 * @param string $templateName name of template
2270 public function parse_defblogselect($templateName = '')
2274 $query = "SELECT bname as text, bnumber as value FROM %s;";
2275 $query = sprintf($query, sql_table('blog'));
2277 $template['name'] = 'DefaultBlog';
2278 $template['selected'] = $CONF['DefaultBlog'];
2279 $template['tabindex'] = 10;
2281 Showlist($query, 'select', $template, $templateName);
2287 * AdminActions::parse_defcatselect()
2288 * Parse skinvar defcatselect
2290 * @param string $templateName name of template
2293 public function parse_defcatselect($templateName = '')
2297 $blogid = intRequestVar('blogid');
2298 $blog = $manager->getBlog($blogid);
2300 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2301 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2303 $template['name'] = 'defcat';
2304 $template['selected'] = $blog->getDefaultCategory();
2305 $template['tabindex'] = 110;
2307 Showlist($query, 'select', $template, $templateName);
2313 * AdminActions::parse_defskinselect()
2314 * Parse skinvar defskinselect
2316 * @param string $type type of skin
2317 * @param string $templateName name of template
2320 public function parse_defskinselect($type = 'blog', $templateName = '')
2322 global $CONF, $manager;
2324 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2325 $query = sprintf($query, sql_table('skin_desc'));
2327 $blogid = intRequestVar('blogid');
2331 $template['selected'] = $CONF['BaseSkin'];
2335 $blog = $manager->getBlog($blogid);
2336 $template['selected'] = $blog->getDefaultSkin();
2339 if ( $type != 'blog' )
2341 $nname = 'BaseSkin';
2348 $template['name'] = $nname;
2349 $template['tabindex'] = 50;
2351 Showlist($query, 'select', $template, $templateName);
2357 * AdminActions::parse_deletecomment()
2358 * Parse skinvar deletecomment
2360 * @param string $type type of infomation for comment
2363 public function parse_deletecomment($type = 'id')
2365 $commentid = intRequestVar('commentid');
2366 $comment = COMMENT::getComment($commentid);
2371 echo intRequestVar('commentid');
2374 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2376 echo $comment['member'];
2380 echo $comment['user'];
2384 $body = strip_tags($comment['body']);
2385 echo Entity::hsc(shorten($body, 300, '...'));
2391 * AdminActions::parse_deleteitembody()
2392 * Parse skinvar deleteitembody
2397 public function parse_deleteitembody()
2401 $itemid = intRequestVar('itemid');
2402 $item =& $manager->getItem($itemid, 1, 1);
2404 $body = strip_tags($item['body']);
2406 echo Entity::hsc(shorten($body, 300, '...'));
2412 * AdminActions::parse_deleteitemid()
2413 * Parse skinvar deleteitemid
2418 public function parse_deleteitemid()
2420 echo (integer) intRequestVar('itemid');
2425 * AdminActions::parse_deleteitemtitle()
2426 * Parse skinvar deleteitemtitle
2431 public function parse_deleteitemtitle()
2435 $itemid = intRequestVar('itemid');
2436 $item =& $manager->getItem($itemid, 1, 1);
2438 echo Entity::hsc(strip_tags($item['title']));
2444 * AdminActions::parse_editadminskin()
2445 * Parse skinvar editadminskin
2447 * @param string $type type of skin setting
2450 public function parse_editadminskin($type = 'id')
2452 $skinid = intRequestVar('skinid');
2453 $skin = new Skin($skinid);
2457 echo intRequestVar('skinid');
2460 echo Entity::hsc($skin->getName());
2463 echo Entity::hsc($skin->getDescription());
2466 echo Entity::hsc($skin->getContentType());
2469 echo Entity::hsc($skin->getIncludePrefix());
2472 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2480 * AdminActions::parse_editadminskintype()
2481 * Parse skinvar editadminskintype
2483 * @param string $type name of skin type
2486 public function parse_editadminskintype($type = 'id')
2488 global $CONF, $manager, $member;
2490 $fNames = $this->parser->skin->getAvailableTypes();
2491 $sType = strtolower(trim(requestVar('type')));
2496 echo intRequestVar('skinid');
2499 echo Entity::hsc($this->parser->skin->getName());
2502 echo Entity::hsc($this->parser->skin->getDescription());
2505 echo Entity::hsc($this->parser->skin->getContentType());
2508 echo Entity::hsc($this->parser->skin->getContentFromDB($sType));
2511 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2512 echo Entity::hsc($skinType);
2515 echo Entity::hsc($sType);
2518 echo Entity::hsc($this->parser->skin->getIncludePrefix());
2521 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2522 echo Entity::hsc($incMode);
2531 * AdminActions::parse_editcomment()
2532 * Parse skinvar editcomment
2534 * @param string $type type of comment setting
2537 public function parse_editcomment($type = 'id')
2541 $commentid = intRequestVar('commentid');
2542 $comment = COMMENT::getComment($commentid);
2544 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2549 echo intRequestVar('commentid');
2552 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2554 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2558 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2562 echo date("Y-m-d @ H:i", $comment['timestamp']);
2565 $comment['body'] = str_replace('<br />', '', $comment['body']);
2566 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2567 echo $comment['body'];
2570 echo $comment['userid'];
2573 echo $comment['userid'];
2576 echo $comment[$type];
2583 * AdminActions::parse_editdesturl()
2584 * Parse skinvar editdesturl
2586 public function parse_editdesturl()
2588 if ( requestVar('desturl') )
2590 echo Entity::hsc(requestVar('desturl'));
2596 * AdminActions::parse_editmemberlist()
2597 * Parse skinvar editmemberlist
2599 * @param string $templateName name of template
2602 public function parse_editmemberlist($templateName = '')
2605 // show list of members with actions
2606 $query = 'SELECT * FROM '.sql_table('member');
2607 $template['content'] = 'memberlist';
2608 $template['tabindex'] = 10;
2610 $batch = new Batch('member');
2611 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
2616 * AdminActions::parse_editmember()
2617 * Parse skinvar editmember
2619 * @param string $type type of information for member
2620 * @return string $tempateName name of template to use
2623 public function parse_editmember($type = 'id', $templateName = '')
2625 global $CONF, $manager, $member;
2627 $memberid = intRequestVar('memberid');
2628 $mem = MEMBER::createFromID($memberid);
2633 echo intRequestVar('memberid');
2636 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2638 echo Entity::hsc($mem->getDisplayName());
2642 $dispName = Entity::hsc($mem->getDisplayName());
2643 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2645 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2654 echo Entity::hsc($mem->getRealName());
2657 echo Entity::hsc($mem->getEmail());
2660 echo Entity::hsc($mem->getURL());
2663 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2666 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2669 echo Entity::hsc($mem->getNotes());
2672 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2681 * AdminActions::parse_editpluginfo()
2682 * Parse skinvar editpluginfo
2684 * @param string $type type of plugin info
2687 public function parse_editpluginfo($type)
2691 $pid = intRequestVar('plugid');
2698 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2705 * AdminActions::parse_editplugoptionslist()
2706 * Parse skinvar editplugoptionslist
2708 * @param string $templateName name of template
2711 public function parse_editplugoptionslist($templateName = '')
2715 $pid = intRequestVar('plugid');
2716 $aOptions = array();
2719 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2720 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2721 $resource = DB::getResult($query);
2723 foreach ( $resource as $row )
2725 array_push($aOIDs, $row['oid']);
2726 $aOptions[$row['oid']] = array(
2727 'oid' => $row['oid'],
2728 'value' => $row['odef'],
2729 'name' => $row['oname'],
2730 'description' => $row['odesc'],
2731 'type' => $row['otype'],
2732 'typeinfo' => $row['oextra'],
2737 // fill out actual values
2738 if ( count($aOIDs) > 0 )
2740 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2741 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2743 $result = DB::getResult($query);
2745 foreach ( $result as $row )
2747 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2753 'context' => 'global',
2755 'options' => &$aOptions
2757 $manager->notify('PrePluginOptionsEdit', $data);
2759 $template['content'] = 'plugoptionlist';
2761 $amount = Showlist($aOptions, 'table', $template, $templateName);
2765 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2771 * AdminActions::parse_editskin()
2772 * Parse skinvar editskin
2774 * @param string $type type of skin
2777 public function parse_editskin($type = 'id')
2779 $skinid = intRequestVar('skinid');
2780 $skin = new SKIN($skinid);
2784 echo intRequestVar('skinid');
2787 echo Entity::hsc($skin->getName());
2790 echo Entity::hsc($skin->getDescription());
2793 echo Entity::hsc($skin->getContentType());
2796 echo Entity::hsc($skin->getIncludePrefix());
2799 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2807 * AdminActions::parse_editskintype()
2808 * Parse skinvar editskintype
2810 * @param string $type name of type for skin type
2813 public function parse_editskintype($type = 'id')
2815 global $CONF, $manager, $member;
2816 $skinid = intRequestVar('skinid');
2817 $skin = new SKIN($skinid);
2818 $fNames = $skin->getAvailableTypes();
2819 $sType = strtolower(trim(requestVar('type')));
2824 echo intRequestVar('skinid');
2827 echo Entity::hsc($skin->getName());
2830 echo Entity::hsc($skin->getDescription());
2833 echo Entity::hsc($skin->getContentType());
2836 echo Entity::hsc($skin->getContentFromDB($sType));
2839 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2840 echo Entity::hsc($skinType);
2843 echo Entity::hsc($sType);
2846 echo Entity::hsc($skin->getIncludePrefix());
2849 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2850 echo Entity::hsc($incMode);
2859 * AdminActions::parse_adminurl()
2860 * Parse skinvar adminurl
2861 * (shortcut for admin url)
2866 public function parse_adminurl()
2868 $this->parse_sitevar('adminurl');
2873 * AdminActions::parse_edittemplateinfo()
2874 * Parse skinvar edittemplateinfo
2876 * @param string $type name of type for skin
2877 * @param string $description description for skin
2878 * @param string $name name of skin
2879 * @param string $help
2880 * @param string $tabindex index value for tabindex attribute of input element
2881 * @param string $big
2882 * @param string $tplt name of template
2885 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2889 $t_id = intRequestVar('templateid');
2890 $t_name = Template::getNameFromId($t_id);
2891 $t_desc = Template::getDesc($t_id);
2892 $template = &Template::read($t_name);
2900 echo Entity::hsc($t_name);
2903 echo Entity::hsc($t_desc);
2905 case 'extratemplate':
2907 $pluginfields = array();
2908 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2913 $tmplt = Template::read($desc);
2915 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2919 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2923 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2926 foreach ( $pluginfields as $pfkey => $pfvalue )
2928 $data = array('explugtplname' => Entity::hsc($pfkey));
2930 echo Template::fill($base, $data);
2932 foreach ( $pfvalue as $pffield => $pfdesc )
2934 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2939 $desc = defined($desc) ? constant($desc) : $desc;
2940 $name = defined($name) ? constant($name) : $name;
2941 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2949 * AdminActions::parse_editadmintemplateinfo()
2950 * Parse skinvar editadmintemplateinfo
2952 * @param string $type type of skin template
2953 * @param string $description description of template
2954 * @param string $name name of stemplate
2955 * @param string $tabindex index number for tabindex attribute of input element
2956 * @param string $big
2957 * @param string $tplt
2959 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2963 $t_id = intRequestVar('templateid');
2964 $t_name = Template::getNameFromId($t_id);
2965 $t_desc = Template::getDesc($t_id);
2966 $template = &Template::read($t_name);
2974 echo Entity::hsc($t_name);
2977 echo Entity::hsc($t_desc);
2979 case 'extratemplate':
2981 $pluginfields = array();
2982 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
2987 $tmplt = Template::read($desc);
2989 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2993 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2997 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3000 foreach ( $pluginfields as $pfkey => $pfvalue )
3002 $data = array('explugtplname' => Entity::hsc($pfkey));
3004 echo Template::fill($base, $data);
3006 foreach ( $pfvalue as $pffield => $pfdesc )
3008 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3013 $desc = defined($desc) ? constant($desc) : $desc;
3014 $name = defined($name) ? constant($name) : $name;
3015 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3022 * AdminActions::parse_eventformextra()
3023 * Parse skinvar eventformextra
3025 * @param string $type name of type for event form extra
3028 public function parse_eventformextra($type = 'activation')
3037 $key = requestVar('ackey');
3040 Admin::error(_ERROR_ACTIVATE);
3042 $info = MEMBER::getActivationInfo($key);
3045 Admin::error(_ERROR_ACTIVATE);
3047 $mem = MEMBER::createFromId($info->vmember);
3050 Admin::error(_ERROR_ACTIVATE);
3053 'type' => 'activation',
3057 case 'membermailform-notloggedin':
3058 $data = array('type' => 'membermailform-notloggedin',);
3061 $manager->notify('FormExtra', $data);
3066 * AdminActions::parse_extrahead()
3067 * Parse skinvar extrahead
3069 public function parse_extrahead()
3073 $extrahead = Admin::getAdminextrahead();
3076 'extrahead' => &$extrahead,
3077 'action' => Admin::getAdminAction()
3080 $manager->notify('AdminPrePageHead', $data);
3086 * AdminActions::parse_member()
3087 * Parse skinvar member
3088 * (includes a member info thingie)
3090 * @param string $what which memberdata is needed
3093 public function parse_member($what)
3095 global $memberinfo, $member, $CONF;
3097 // 1. only allow the member-details-page specific variables on member pages
3098 if ( $this->skintype == 'member' )
3103 echo Entity::hsc($memberinfo->getDisplayName());
3106 echo Entity::hsc($memberinfo->getRealName());
3109 echo Entity::hsc($memberinfo->getNotes());
3112 echo Entity::hsc($memberinfo->getURL());
3115 echo Entity::hsc($memberinfo->getEmail());
3118 echo Entity::hsc($memberinfo->getID());
3123 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3124 if ( $member->isLoggedIn() )
3129 echo $member->getDisplayName();
3131 case 'yourrealname':
3132 echo $member->getRealName();
3135 echo $member->getNotes();
3138 echo $member->getURL();
3141 echo $member->getEmail();
3144 echo $member->getID();
3146 case 'yourprofileurl':
3147 if ( $CONF['URLMode'] == 'pathinfo' )
3149 echo Link::create_member_link($member->getID());
3153 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3162 * AdminActions::parse_version()
3163 * Parse skinvar version
3164 * (include nucleus versionnumber)
3169 public function parse_version()
3172 echo 'Nucleus CMS ' . $nucleus['version'];
3177 * AdminActions::parse_sitevar()
3178 * Parse skinvar sitevar
3179 * (include a sitevar)
3181 * @param string $which
3184 public function parse_sitevar($which)
3190 echo $CONF['IndexURL'];
3193 echo $CONF['SiteName'];
3196 echo $CONF['AdminEmail'];
3199 echo $CONF['AdminURL'];
3205 * AdminActions::parse_charset()
3206 * Parse skinvar charset
3211 public function parse_charset()
3213 echo i18n::get_current_charset();
3218 * AdminActions::parse_getblogsetting()
3219 * Parse skinvar getblogsetting
3221 public function parse_getblogsetting($which)
3223 global $blog, $manager;
3229 elseif ( $bid = intRequestVar('blogid') )
3231 $b = $manager->getBlog($bid);
3241 return Entity::hsc($b->getID());
3244 return Entity::hsc($b->getURL());
3247 return Entity::hsc($b->getName());
3250 return Entity::hsc($b->getDescription());
3253 return Entity::hsc($b->getShortName());
3255 case 'notifyaddress':
3256 return Entity::hsc($b->getNotifyAddress());
3259 return Entity::hsc($b->getMaxComments());
3262 return Entity::hsc($b->getUpdateFile());
3265 return Entity::hsc($b->getTimeOffset());
3272 * AdminActions::parse_geteditpluginfo()
3273 * Parse skinvar geteditpluginfo
3275 * @param string $type name of setting for edit plugin info
3278 public function parse_geteditpluginfo($type)
3281 $pid = intRequestVar('plugid');
3288 return Entity::hsc($manager->getPluginNameFromPid($pid));
3295 * AdminActions::parse_getmember()
3296 * Parse skinvar getmember
3297 * (includes a member info thingie)
3299 * @param string $what name of setting for member
3302 public function parse_getmember($what)
3304 global $memberinfo, $member;
3305 // 1. only allow the member-details-page specific variables on member pages
3306 if ( $this->skintype == 'member' )
3311 return Entity::hsc($memberinfo->getDisplayName());
3314 return Entity::hsc($memberinfo->getRealName());
3317 return Entity::hsc($memberinfo->getNotes());
3320 return Entity::hsc($memberinfo->getURL());
3323 return Entity::hsc($memberinfo->getEmail());
3326 return Entity::hsc($memberinfo->getID());
3330 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3331 if ( $member->isLoggedIn() )
3336 return $member->getDisplayName();
3338 case 'yourrealname':
3339 return $member->getRealName();
3342 return $member->getNotes();
3345 return $member->getURL();
3348 return $member->getEmail();
3351 return $member->getID();
3359 * AdminActions::parse_headmessage()
3360 * Parse skinvar headmessage
3365 public function parse_headmessage()
3367 if ( !empty(Admin::$headMess) )
3369 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3375 * AdminActions::parse_helplink()
3376 * Parse skinvar helplink
3378 * @param string $topic name of topic for help
3381 public function parse_helplink($topic = '')
3383 if ( !empty($topic) )
3391 * AdminActions::parse_helpplugname()
3392 * Parse skinvar helpplugname
3397 public function parse_helpplugname()
3399 $plugid = intGetVar('plugid');
3400 Entity::hsc($manager->getPluginNameFromPid($plugid));
3405 * AdminActions::parse_ilistaddnew()
3406 * Parse skinvar ilistaddnew
3411 public function parse_ilistaddnew()
3413 $blogid = intRequestVar('blogid');
3414 if ( intPostVar('start') == 0 )
3416 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3422 * AdminActions::parse_importskininfo()
3423 * Parse skinvar importskininfo
3425 * @param string $type name of information for imported skin
3428 public function parse_importskininfo($type)
3433 echo Entity::hsc(requestVar('skininfo'));
3436 $dataArr = requestArray('skinnames');
3437 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3440 $dataArr = requestArray('tpltnames');
3441 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3444 $dataArr = requestArray('skinclashes');
3445 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3448 $dataArr = requestArray('tpltclashes');
3449 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3452 echo Entity::hsc(requestVar('skinfile'));
3455 echo Entity::hsc(requestVar('mode'));
3462 * AdminActions::parse_inputyesno()
3463 * Parse skinvar inputyesno
3465 * some init stuff for all forms
3470 public function parse_init()
3475 if ( requestVar('action') == 'itemedit' )
3477 $authorid = Admin::$item['authorid'];
3480 Admin::$blog->insertJavaScriptInfo($authorid);
3485 * AdminActions::parse_inputyesno()
3486 * Parse skinvar inputyesno
3488 * @param string $name
3489 * @param string $checkedval
3490 * @param string $tabindex
3491 * @param string $value1
3492 * @param string $value2
3493 * @param string $yesval
3494 * @param string $noval
3495 * @param string $isAdmin
3496 * @param string $templateName
3499 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3501 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3506 * AdminActions::parse_insertpluginfo()
3507 * Parse templatevar insertpluginfo
3509 public function parse_insertpluginfo($type)
3511 $option = Admin::getAdminaOption();
3515 return $option['pid'];
3518 return Entity::hsc($option['pfile']);
3525 * AdminActions::parse_insplugoptcontent()
3526 * Parse skinvar insplugoptcontent
3531 public function parse_insplugoptcontent()
3533 $option = Admin::getAdminaOption();
3535 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3536 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3539 listplug_plugOptionRow($option);
3546 * AdminActions::parse_iprangeinput()
3547 * Parse skinvar iprangeinput
3552 public function parse_iprangeinput()
3554 if ( requestVar('ip') )
3556 $iprangeVal = Entity::hsc(requestVar('ip'));
3557 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3558 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3559 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3560 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3561 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3565 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3566 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3572 * AdminActions::parse_itemnavlist()
3573 * Parse skinvar itemnavlist
3578 public function parse_itemnavlist($templateName)
3580 global $CONF, $manager, $member;
3582 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3583 . " FROM %s, %s, %s, %s"
3584 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3586 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3588 if ( $this->skintype == 'itemlist' )
3591 if ( array_key_exists('blogid', $_REQUEST) )
3593 $blogid = intRequestVar('blogid');
3595 else if ( array_key_exists('itemid', $_REQUEST) )
3597 $itemid = intRequestVar('itemid');
3598 $item = &$manager->getItem($itemid, 1, 1);
3599 $blogid = (integer) $item['blogid'];
3601 $blog =& $manager->getBlog($blogid);
3603 $query .= " AND iblog={$blogid}";
3604 $template['now'] = $blog->getCorrectTime(time());
3606 // non-blog-admins can only edit/delete their own items
3607 if ( !$member->blogAdminRights($blogid) )
3609 $query .= ' AND iauthor = ' . $member->getID();
3612 elseif ( $this->skintype == 'browseownitems' )
3614 $query .= ' AND iauthor = ' . $member->getID();
3616 $template['now'] = time();
3619 // search through items
3620 $search = postVar('search');
3622 if ( !empty($search) )
3624 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3625 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3626 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3629 if ( postVar('start') )
3631 $start = intPostVar('start');
3638 // amount of items to show
3639 if ( postVar('amount') )
3641 $amount = intPostVar('amount');
3645 $amount = (integer) $CONF['DefaultListSize'];
3652 $query .= ' ORDER BY itime DESC'
3653 . " LIMIT {$start},{$amount}";
3655 $template['content'] = 'itemlist';
3657 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3658 $navList->showBatchList('item', $query, 'table', $template, '', $templateName);
3663 * AdminActions::parse_itemtime()
3664 * date change on edit item
3666 * @param string $key key of PHP's getDate()
3669 public function parse_itemtime($key)
3674 $itemid = intRequestVar('itemid');
3675 $item =& $manager->getItem($itemid, 1, 1);
3677 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3679 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3681 $item['body'] = removeBreaks($item['body']);
3682 $item['more'] = removeBreaks($item['more']);
3685 $contents = array();
3686 if ( requestVar('action') == 'itemedit' )
3690 elseif ( requestVar('action') == 'createitem' )
3693 'contents' => &$contents,
3694 'blog' => &$this->blog
3696 $manager->notify('PreAddItemForm', $data);
3698 $itemtime = getdate($contents['timestamp']);
3699 echo $itemtime[$key];
3704 * AdminActions::parse_jstoolbaroptions()
3705 * Parse skinvar jstoolbaroptions
3710 public function parse_jstoolbaroptions()
3714 _SETTINGS_JSTOOLBAR_NONE,
3715 _SETTINGS_JSTOOLBAR_SIMPLE,
3716 _SETTINGS_JSTOOLBAR_FULL
3720 foreach ( $options as $option )
3722 $text = "<option value=\"%d\"%s>%s</option>\n";
3723 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3724 echo sprintf($text, $i, $extra, $option);
3730 * AdminActions::parse_localeselectoptions()
3731 * Parse skinvar localeselectoptions
3736 public function parse_localeselectoptions()
3738 $locales = i18n::get_available_locale_list();
3740 $memid = intRequestVar('memberid');
3743 $mem = MEMBER::createFromID($memid);
3744 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3746 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3750 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3755 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3757 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3761 echo "<option value=\"\">en_Latn_US</option>\n";
3764 foreach ( $locales as $locale )
3766 if ( $locale == 'en_Latn_US' )
3772 if ( $locale == $mem->getLocale() )
3774 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3778 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3783 if ( $locale == i18n::get_current_locale() )
3785 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3789 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3797 * AdminActions::parse_listplugplugoptionrow()
3798 * Parse templatevar listplugplugoptionrow
3800 * @param string $templateName name of template
3803 public function parse_listplugplugoptionrow($templateName = '')
3805 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
3810 * AdminActions::parse_mediadirwarning()
3811 * Parse skinvar mediadirwarning
3816 public function parse_mediadirwarning()
3819 if ( !is_dir($DIR_MEDIA) )
3821 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3823 if ( !is_readable($DIR_MEDIA) )
3825 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3827 if ( !is_writeable($DIR_MEDIA) )
3829 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3835 * AdminActions::parse_movedistselect()
3836 * Parse skinvar movedistselect
3838 public function parse_movedistselect()
3840 $actionType = requestVar('action');
3841 switch ( $actionType )
3844 $this->selectBlog('destcatid', 'category');
3846 case 'batchcategory':
3847 $this->selectBlog('destblogid');
3850 if ( $this->skintype == 'itemmove' )
3852 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3853 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3854 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3855 $this->selectBlog('catid', 'category', $catid, 10, 1);
3863 * AdminActions::parse_moveitemid()
3864 * Parse skinvar moveitemid
3869 public function parse_moveitemid()
3871 echo intRequestVar('itemid');
3876 * AdminActions::parse_newestcompare()
3877 * Parse skinvar newestcompare
3882 public function parse_newestcompare()
3886 $newestVersion = getLatestVersion();
3887 $newestCompare = str_replace('/', '.', $newestVersion);
3888 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3890 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3892 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3893 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3899 * AdminActions::parse_newmemberselect()
3900 * Parse skinvar newmemberselect
3902 * @param string $templateName name of template to use
3905 public function parse_newmemberselect($templateName = '')
3907 $blogid = intRequestVar('blogid');
3909 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3910 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3911 $res = DB::getResult($query);
3914 foreach ( $res as $row )
3916 $tmem[] = intval($row['tmember']);
3919 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3920 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3923 'name' => 'memberid',
3924 'tabindex' => 10000,
3927 Showlist($query, 'select', $template, $templateName);
3932 * AdminActions::parse_newpluginlist()
3933 * Parse skinvar newpluginlist
3938 public function parse_newpluginlist()
3940 $candidates = $this->newPlugCandidates;
3941 foreach ( $candidates as $name )
3943 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3949 * AdminActions::parse_outputspecialdirs()
3950 * Parse skinvar outputspecialdirs
3952 * @param string $type type of setting for directory
3955 public function parse_outputspecialdirs($type)
3957 global $DIR_MEDIA, $DIR_NUCLEUS;
3962 echo Entity::hsc($DIR_NUCLEUS);
3965 echo Entity::hsc($DIR_MEDIA);
3972 * AdminActions::parse_passrequestvars()
3973 * Parse skinvar passrequestvars
3978 public function parse_passrequestvars()
3980 $passvar = Admin::getAdminpassvar();
3981 $oldaction = postVar('oldaction');
3983 if ( ($oldaction != 'logout')
3984 && ($oldaction != 'login')
3986 && !postVar('customaction') )
3994 * AdminActions::parse_pluginextras()
3995 * Parse skinvar pluginextras
3997 * @param string $type type of plugin context
4000 public function parse_pluginextras($type = 'global')
4006 $id = intRequestVar('memberid');
4007 $mem = MEMBER::createFromID($id);
4008 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4011 $id = intRequestVar('blogid');
4012 $blg = $manager->getBlog($id);
4013 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4017 'GeneralSettingsFormExtras',
4027 * AdminActions::parse_pluginhelp()
4028 * Parse skinvar pluginhelp
4033 public function parse_pluginhelp()
4035 global $manager, $DIR_PLUGINS;
4037 $plugid = intGetVar('plugid');
4038 $plugName = $manager->getPluginNameFromPid($plugid);
4039 $plug =& $manager->getPlugin($plugName);
4041 if ( $plug->supportsFeature('HelpPage') > 0 )
4043 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4044 if ( @file_exists($helpfile . 'php') )
4046 @include($helpfile . 'php');
4049 elseif ( @file_exists($helpfile . 'html') )
4051 @include($helpfile . 'html');
4055 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4056 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4061 * AdminActions::parse_pluginlistlist()
4062 * Parse skinvar pluginlistlist
4064 * @param string $templateName name of template to use
4067 public function parse_pluginlistlist($templateName = '')
4069 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4070 $query = sprintf($query, sql_table('plugin'));
4072 $template['content'] = 'pluginlist';
4073 $template['tabindex'] = 10;
4075 Showlist($query, 'table', $template, $templateName);
4081 * AdminActions::parse_pluginoptions()
4082 * Parse skinvar pluginoptions
4084 * @param string $type type of plugin option
4087 public function parse_pluginoptions($context='global', $templateName='')
4089 global $itemid, $manager;
4094 $contextid = intRequestVar('memberid');
4097 $contextid = intRequestVar('blogid');
4100 $contextid = intRequestVar('catid');
4103 $contextid = $itemid;
4107 /* Actually registererd plugin options */
4108 $aIdToValue = array();
4109 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
4110 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
4111 $res = DB::getResult($query);
4112 foreach ( $res as $row )
4114 $aIdToValue[$row['oid']] = $row['ovalue'];
4117 /* Currently available plugin options */
4118 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
4119 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
4120 $res = DB::getResult($query);
4123 foreach ($res as $row )
4125 if ( !array_key_exists($row['oid'], $aIdToValue) )
4127 $value = $row['odef'];
4131 $value = $aIdToValue[$row['oid']];
4135 'pid' => $row['pid'],
4136 'pfile' => $row['pfile'],
4137 'oid' => $row['oid'],
4139 'name' => $row['oname'],
4140 'description' => $row['odesc'],
4141 'type' => $row['otype'],
4142 'typeinfo' => $row['oextra'],
4143 'contextid' => $contextid,
4149 'context' => $context,
4150 'contextid' => $contextid,
4151 'options' => &$options
4153 $manager->notify('PrePluginOptionsEdit', $data);
4155 $template = array();
4156 if ( $templateName )
4158 $templates = Template::read($templateName);
4159 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
4161 $template['title'] = "<tr>"
4162 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
4167 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
4170 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
4172 $template['body'] = "<tr>"
4173 . "<%listplugplugoptionrow%>"
4178 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
4184 include_libs('ACTIONS.php');
4185 $handler = new Actions($this->skintype);
4186 $parser = new PARSER($handler);
4188 foreach ( $options as $option )
4191 if ( $prevPid != $option['pid'] )
4193 $prevPid = $option['pid'];
4194 $parser->parse($template['title']);
4197 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
4199 if ( @$meta['access'] != 'hidden' )
4201 $parsed = $parser->parse($template['body']);
4209 * AdminActions::parse_qmenuaddselect()
4210 * Parse skinvar qmanuaddselect
4212 * @param string $templateName name of template to use
4215 public function parse_qmenuaddselect($templateName = '')
4218 $showAll = requestVar('showall');
4219 if ( $member->isAdmin() && ($showAll == 'yes') )
4221 // Super-Admins have access to all blogs! (no add item support though)
4222 $query = 'SELECT bnumber as value, bname as text'
4223 . ' FROM ' . sql_table('blog')
4224 . ' ORDER BY bname';
4228 $query = 'SELECT bnumber as value, bname as text'
4229 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4230 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4231 . ' ORDER BY bname';
4234 $template['name'] = 'blogid';
4235 $template['tabindex'] = 15000;
4236 $template['extra'] = _QMENU_ADD_SELECT;
4237 $template['selected'] = -1;
4238 $template['shorten'] = 10;
4239 $template['shortenel'] = '';
4240 $template['javascript'] = 'onchange="return form.submit()"';
4242 Showlist($query, 'select', $template, $templateName);
4248 * AdminActions::parse_quickmenu()
4249 * Parse skinvar quickmenu
4251 * @param string $templateName name of template to use
4254 public function parse_quickmenu($templateName = '')
4257 $templates = array();
4258 $template = array();
4259 if ( !empty($templateName) )
4261 $templates = Template::read($templateName);
4263 $pluginExtras = array();
4267 'options' => &$pluginExtras
4270 if ( count($pluginExtras) > 0 )
4272 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4274 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4278 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4280 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4282 $template['head'] = "<ul>\n";
4286 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4288 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4290 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4294 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4296 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4298 $template['foot'] = "</ul>\n";
4302 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4305 $handler = new Actions($this->skintype);
4306 $parser = new PARSER($handler);
4308 $parser->parse($template['title']);
4309 echo $template['head'];
4310 foreach ( $pluginExtras as $aInfo )
4313 'plugadminurl' => Entity::hsc($aInfo['url']),
4314 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4315 'plugadmintitle' => Entity::hsc($aInfo['title']),
4317 echo Template::fill($template['body'], $data);
4319 echo $template['foot'];
4325 * AdminActions::parse_requestblogid()
4326 * Parse skinvar requestblogid
4331 public function parse_requestblogid()
4333 echo intRequestVar('blogid');
4338 * AdminActions::parse_requestiprange()
4339 * Parse skinvar requestiprange
4344 public function parse_requestiprange()
4346 if ( requestVar('iprange') )
4348 echo Entity::hsc(requestVar('iprange'));
4350 elseif ( requestVar('ip') )
4352 echo Entity::hsc(requestVar('ip'));
4358 * AdminActions::parse_selectlocaladminskinfiles()
4359 * Parse skinvar selectlocaladminskinfiles
4364 public function parse_selectlocaladminskinfiles()
4366 global $DIR_SKINS, $manager;
4368 $adminskindir = $DIR_SKINS . 'admin/';
4369 $candidates = SkinImport::searchForCandidates($adminskindir);
4371 foreach ( $candidates as $skinname => $skinfile )
4373 $html = Entity::hsc($skinfile);
4374 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4381 * AdminActions::parse_selectlocalskinfiles()
4382 * Parse skinvar selectlocalskinfiles
4387 public function parse_selectlocalskinfiles()
4391 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4393 foreach ( $candidates as $skinname => $skinfile )
4395 $html = Entity::hsc($skinfile);
4396 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4403 * AdminActions::parse_skineditallowedlist()
4404 * Parse skinvar skineditallowedlist
4406 * @param string $type type of skin
4407 * @param string $templateName name of template
4410 public function parse_skineditallowedlist($type, $templateName = '')
4415 $query = "SELECT bshortname, bname FROM %s;";
4417 'content' => 'shortblognames'
4419 $query = sprintf($query, sql_table('blog'));
4420 Showlist($query, 'table', $show, $templateName);
4423 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4425 'content' => 'shortnames'
4427 $query = sprintf($query, sql_table('template_desc'));
4428 Showlist($query, 'table', $show, $templateName);
4435 * AdminActions::parse_skinielist()
4436 * Parse skinvar skinielist
4438 * @param string $type type of skin
4439 * @param string $templateName name of template to use
4442 public function parse_skinielist($type, $templateName = '')
4444 $templates = array();
4445 if ( $templateName )
4447 $templates = Template::read($templateName);
4449 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4451 $template = $templates['SKINIE_EXPORT_LIST'];
4456 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4457 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4459 . "<td><%expdesc%></td>\n"
4466 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4467 foreach ( $res as $row )
4470 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4471 'expid' => 'skinexp' . $row['sdnumber'],
4472 'expname' => Entity::hsc($row['sdname']),
4473 'expdesc' => Entity::hsc($row['sddesc'])
4475 echo Template::fill($template, $data);
4479 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4480 foreach ( $res as $row )
4483 'typeid' => 'template[' . $row['tdnumber'] . ']',
4484 'expid' => 'templateexp' . $row['tdnumber'],
4485 'expname' => Entity::hsc($row['tdname']),
4486 'expdesc' => Entity::hsc($row['tddesc'])
4488 echo Template::fill($template, $data);
4496 * AdminActions::parse_skinoverview()
4497 * Parse skinvar skinoverview
4499 * @param string $templateName name of template to use
4502 public function parse_skinoverview($templateName = '')
4505 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4506 $query = sprintf($query, sql_table('skin_desc'));
4508 $template['content'] = 'skinlist';
4509 $template['tabindex'] = 10;
4511 Showlist($query, 'table', $template, $templateName);
4516 * AdminActions::parse_skintypehelp()
4517 * Check editing skintypehelp
4522 public function parse_skintypehelp()
4524 $nowSkinType = strtolower(trim(requestVar('type')));
4526 /* TODO: use Skin class */
4527 $regularType = array(
4538 if ( in_array($nowSkinType, $regularType) )
4540 help('skinpart' . $nowSkinType);
4544 help('skinpartspecial');
4550 * AdminActions::parse_specialskinlist()
4551 * Parse skinvar specialskinlist
4553 * @param string $templateName name of template to use
4556 public function parse_specialskinlist($templateName = '')
4558 $templates = array();
4559 if ( $templateName )
4561 $templates = Template::read($templateName);
4564 /* TODO: use Skin class */
4575 $skinid = intRequestVar('skinid');
4576 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4577 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4579 $res = DB::getResult($query);
4580 if ( $res && $res->rowCount() > 0 )
4583 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4585 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4589 $template['head'] = "<ul>\n";
4591 echo Template::fill($template['head'], $data);
4592 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4594 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4595 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4596 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4600 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4604 foreach ( $res as $row )
4607 'tabindex' => $tabstart++,
4608 'skinid' => $skinid,
4609 'skintype' => Entity::hsc(strtolower($row['stype']))
4611 echo Template::fill($template['body'], $data);
4614 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4616 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4620 $template['foot'] = "</ul>\n";
4622 echo Template::fill($template['foot'], $data);
4628 * AdminActions::parse_sprinttext()
4631 * @param string $which
4632 * @param string $val
4635 public function parse_sprinttext($which, $val)
4637 if ( !defined($which) )
4643 $base = constant($which);
4646 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4648 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4650 $met = 'parse_' . $matchies[0];
4654 $arg = trim($args[0], '()');
4655 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4658 if ( method_exists($this, $met) )
4660 $value = call_user_func(array(&$this, $met), $arg);
4664 if ( !isset($value) || empty($value) )
4668 echo sprintf($base, $value);
4673 * AdminActions::parse_systemsettings()
4674 * Parse skinvar systemsettings
4676 * @param string $type type of settings for system
4677 * @param string $templateName name of template to use
4680 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4682 global $member, $CONF, $nucleus;
4684 $member->isAdmin() or Admin::disallow();
4686 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4687 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4694 case 'sqlserverinfo':
4695 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4697 case 'sqlclientinfo':
4698 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4700 case 'magicquotesgpc':
4701 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4703 case 'magicquotesruntime':
4704 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4706 case 'registerglobals':
4707 echo ini_get('register_globals') ? 'On' : 'Off';
4710 $templates = array();
4711 if ( $templateName )
4713 $templates = Template::read($templateName);
4715 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4717 $template = "<tr>\n"
4718 . "<td><%key%></td>\n"
4719 . "<td><%value%></td>\n"
4724 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4727 $gdinfo = gd_info();
4729 foreach ( $gdinfo as $key => $value )
4731 if ( is_bool($value) )
4733 $value = $value ? $enable : $disable;
4737 $value = Entity::hsc($value);
4743 echo Template::fill($template, $data);
4748 phpinfo(INFO_MODULES);
4749 $im = ob_get_contents();
4751 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4753 case 'nucleusversion':
4754 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4756 case 'nucleuspatchlevel':
4757 echo getNucleusPatchLevel();
4763 echo $CONF['ItemURL'];
4765 case 'alertonheaderssent':
4766 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4768 case 'nucleuscodename':
4769 if ( $nucleus['codename'] != '' )
4771 echo ' "' . $nucleus['codename'] . '"';
4774 case 'versioncheckurl':
4775 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4782 * AdminActions::parse_templateoverview()
4783 * Parse skinvar templateoverview
4785 * @param string $templateName name of template to use
4788 public function parse_templateoverview($templateName = '')
4790 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4791 $query = sprintf($query, sql_table('template_desc'));
4793 $template['content'] = 'templatelist';
4794 $template['tabindex'] = 10;
4796 Showlist($query, 'table', $template, $templateName);
4802 * AdminActions::parse_ticket()
4808 public function parse_ticket()
4811 $manager->addTicketHidden();
4816 * AdminActions::parse_versioncheckurl()
4817 * Parse skinvar versioncheckurl
4822 public function parse_versioncheckurl()
4824 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4829 * AdminActions::parse_yrbloglist()
4830 * Parse skinvar yrbloglist
4832 * @param string $templateName name of template to use
4835 public function parse_yrbloglist($templateName = '')
4838 $showAll = requestVar('showall');
4840 if ( $member->isAdmin() && ($showAll == 'yes') )
4842 // Super-Admins have access to all blogs! (no add item support though)
4843 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4845 . " ORDER BY bnumber;";
4846 $query = sprintf($query, sql_table('blog'));
4850 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4852 . " WHERE tblog=bnumber and tmember=%d"
4853 . " ORDER BY bnumber;";
4854 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4857 $template['content'] = 'bloglist';
4858 $template['superadmin'] = $member->isAdmin();
4860 $amount = Showlist($query, 'table', $template, $templateName);
4862 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4864 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4866 $total = DB::getValue($query);
4867 if ( $total > $amount )
4869 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4875 echo _OVERVIEW_NOBLOGS;
4877 elseif( $amount != 0 )
4879 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4881 $query = "SELECT ititle, inumber, bshortname"
4883 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4884 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4886 $template['content'] = 'draftlist';
4888 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4889 if ( $amountdrafts == 0 )
4891 echo _OVERVIEW_NODRAFTS;
4898 * AdminActions::checkCondition()
4899 * Checks conditions for if statements
4901 * @param string $field type of <%if%>
4902 * @param string $name property of field
4903 * @param string $value value of property
4904 * @return boolean condition
4906 protected function checkCondition($field, $name='', $value = '')
4908 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
4919 $blog =& $manager->getBlog($blogid);
4923 $blogid = getBlogIDFromCatID($catid);
4925 $blog =& $manager->getBlog($blogid);
4927 elseif ( intRequestVar('catid') )
4929 $catid = intRequestVar('catid');
4930 $blogid = getBlogIDFromCatID($catid);
4932 $blog =& $manager->getBlog($blogid);
4939 $condition = ($blog && $this->ifCategory($name, $value));
4942 $condition = ($blog && ($blog->getSetting($name) == $value));
4945 $condition = $member->isLoggedIn();
4948 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4951 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4954 $condition = $member->isLoggedIn() && $member->isAdmin();
4956 case 'allowloginedit':
4957 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4960 $condition = ($itemidnext != '');
4963 $condition = ($itemidprev != '');
4965 case 'archiveprevexists':
4966 $condition = ($archiveprevexists == true);
4968 case 'archivenextexists':
4969 $condition = ($archivenextexists == true);
4972 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4975 $condition = $this->ifHasPlugin($name, $value);
4978 $condition = (Admin::getAdminAction() == $name);
4980 case 'adminoldaction':
4981 $condition = (Admin::getAdminAction() == $name);
4983 case 'addresschange':
4984 $condition = ($this->ifAddresscange());
4986 case 'bechangepass':
4987 $condition = ($this->beChangePassword());
4989 case 'skincandidates':
4990 $condition = ($this->ifSkincandidates());
4993 $condition = requestVar('nameclashes');
4995 case 'existsnewplugin':
4996 $condition = ($this->existsNewPlugin());
4999 $condition = (boolean) ($member->getAutosave() == $value);
5002 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5009 * Actions::_ifHasPlugin()
5010 * hasplugin,PlugName
5011 * -> checks if plugin exists
5012 * hasplugin,PlugName,OptionName
5013 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5014 * hasplugin,PlugName,OptionName=value
5015 * -> checks if the option OptionName from plugin PlugName is set to value
5017 * @param string $name name of plugin
5018 * @param string $value
5021 private function ifHasPlugin($name, $value)
5025 // (pluginInstalled method won't write a message in the actionlog on failure)
5026 if ( $manager->pluginInstalled("NP_{$name}") )
5028 $plugin =& $manager->getPlugin("NP_{$name}");
5029 if ( $plugin != NULL )
5037 list($name2, $value2) = preg_split('#=#', $value, 2);
5038 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5042 else if ( $plugin->getOption($name2) == $value2 )
5053 * Actions::beChangePassword()
5058 private function beChangePassword()
5060 return intRequestVar('bNeedsPasswordChange');
5064 * Actions::ifSkincandidates()
5065 * Checks if a plugin exists and call its doIf function
5071 private function ifSkincandidates()
5074 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5075 return (count($candidates) > 0);
5079 * Actions::ifPlugin()
5080 * Checks if a plugin exists and call its doIf function
5082 * @param string $name name of plugin
5083 * @param string $key
5084 * @param string $value
5087 private function ifPlugin($name, $key = '', $value = '')
5091 $plugin =& $manager->getPlugin("NP_{$name}");
5097 $params = func_get_args();
5098 array_shift($params);
5100 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5104 * AdminActions::ifCategory()
5105 * Different checks for a category
5107 * @param string $key key for information of category
5108 * @param string $value value for information of category
5111 private function ifCategory($key = '', $value='')
5113 global $blog, $catid;
5115 // when no parameter is defined, just check if a category is selected
5116 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5118 return $blog->isValidCategory($catid);
5121 // check category name
5122 if ( $key == 'catname' )
5124 $value = $blog->getCategoryIdFromName($value);
5125 if ($value == $catid)
5127 return $blog->isValidCategory($catid);
5131 // check category id
5132 if (($key == 'catid') && ($value == $catid))
5134 return $blog->isValidCategory($catid);
5141 * AdminActions::ifOnTeam()
5142 * Checks if a member is on the team of a blog and return his rights
5144 * @param string $blogName name of weblog
5147 private function ifOnTeam($blogName = '')
5149 global $blog, $member, $manager;
5151 // when no blog found
5152 if ( ($blogName == '') && !is_object($blog) )
5157 // explicit blog selection
5158 if ($blogName != '')
5160 $blogid = getBlogIDFromName($blogName);
5163 if (($blogName == '') || !$manager->existsBlogID($blogid))
5166 $blogid = $blog->getID();
5168 return $member->teamRights($blogid);
5172 * AdminActions::ifAdmin()
5173 * Checks if a member is admin of a blog
5175 * @param string $blogName name of weblog
5178 private function ifAdmin($blogName = '')
5180 global $blog, $member, $manager;
5182 // when no blog found
5183 if (($blogName == '') && (!is_object($blog)))
5188 // explicit blog selection
5189 if ($blogName != '')
5191 $blogid = getBlogIDFromName($blogName);
5194 if (($blogName == '') || !$manager->existsBlogID($blogid))
5197 $blogid = $blog->getID();
5200 return $member->isBlogAdmin($blogid);
5204 * AdminActions::ifAddresscange()
5205 * Check e-Mail address is changed
5210 private function ifAddresscange()
5212 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5217 $info = MEMBER::getActivationInfo($key);
5222 $mem = MEMBER::createFromId($info->vmember);
5227 if ( $info->vtype == 'addresschange' )
5235 * AdminActions::templateEditRow()
5238 * @param array $template
5239 * @param string $desc
5240 * @param string $name
5241 * @param string $help
5242 * @param integer $tabindex
5243 * @param boolean $big
5244 * @param array $tmplt
5247 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5251 if ( !array_key_exists($name, $template) )
5253 $template[$name] = '';
5261 $tmplt = skinableTEMPLATE::read($tplt);
5265 'description' => $desc,
5266 'help' => empty($help) ? '' : helpHtml('template' . $help),
5269 'tabindex' => $tabindex,
5270 'rows' => $big ? 10 : 5,
5273 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5275 $base['head'] = "</tr>"
5277 . "<td><%description%><%help%></td>\n"
5278 . "<td id=\"td<%count%>\">\n"
5279 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5283 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5286 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5288 $base['tail'] = "</textarea>\n"
5293 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5296 echo TEMPLATE::fill($base['head'], $data);
5297 echo ENTITY::hsc($template[$name]);
5298 echo TEMPLATE::fill($base['tail'], $data);
5306 * AdminActions::customHelp()
5307 * shows a link to custom help file
5310 * @param string $tplName
5311 * @param string $url
5312 * @param string $iconURL
5313 * @param string $alt
5314 * @param string $title
5318 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5320 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5324 * AdminActions::customHelp()
5325 * shows a link to custom help file
5328 * @param string $tplName
5329 * @param string $url
5330 * @param string $iconURL
5331 * @param string $alt
5332 * @param string $title
5336 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5340 $templates = array();
5344 $templates = Template::read($tplName);
5347 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5349 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5353 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5358 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5361 if ( empty($onclick) )
5363 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5365 elseif ( preg_match('#^onclick#', $onclick) )
5367 $onclick = $onclick;
5371 $onclick = 'onclick="' . $onclick . '"';
5376 'helptarget' => $id,
5377 'onclick' => $onclick,
5378 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5380 return Template::fill($template, $data);
5384 * AdminActions::customHelpHtml()
5387 * @param string $tplName
5388 * @param string $url
5389 * @param string $iconURL
5390 * @param string $alt
5391 * @param string $title
5392 * @param string $onclick
5393 * @return string anchor element with help uri
5395 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5399 $templates = array();
5403 $templates = Template::read($tplName);
5405 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5407 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5411 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5414 if ( empty($iconURL) )
5416 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5419 if ( function_exists('getimagesize') )
5421 $size = getimagesize($iconURL);
5422 $width = 'width="' . $size[0] . '" ';
5423 $height = 'height="' . $size[1] . '" ';
5427 'iconurl' => $iconURL,
5429 'height' => $height,
5430 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5431 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5434 $icon = Template::fill($template, $data);
5435 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5437 return $help . $icon;
5441 * AdminActions::input_yesno
5444 * @param $checkedval
5451 * @param $templateName
5454 public function input_yesno($name,
5465 $templates = array();
5466 if ( $templateName )
5468 $templates = Template::read($templateName);
5471 if ( $name == 'admin' )
5473 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5475 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5476 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5477 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5478 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5482 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5487 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5489 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5493 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5495 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5498 if ( !isset($template) )
5500 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5501 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5502 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5503 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5508 $id = Entity::hsc($name);
5509 $id = str_replace('[', '-', $id);
5510 $id = str_replace(']', '-', $id);
5511 $id1 = $id . Entity::hsc($value1);
5512 $id2 = $id . Entity::hsc($value2);
5514 'name' => Entity::hsc($name),
5515 'yesval' => Entity::hsc($value1),
5516 'noval' => Entity::hsc($value2),
5519 'yesvaltext' => $yesval,
5520 'novaltext' => $noval,
5521 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5522 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5523 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5528 return Template::fill($template, $dat);
5532 echo Template::fill($template, $dat);
5538 * AdminActions::existsNewPlugin()
5539 * Check exists new plugin
5542 * @return boolean exists or not
5544 private function existsNewPlugin()
5546 global $DIR_PLUGINS;
5548 $query = "SELECT * FROM %s;";
5549 $query = sprintf($query, sql_table('plugin'));
5550 $res = DB::getResult($query);
5552 $installed = array();
5553 foreach( $res as $row )
5555 $installed[] = $row['pfile'];
5558 $files = scandir($DIR_PLUGINS);
5560 $candidates = array();
5561 foreach ( $files as $file )
5563 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5565 if ( !in_array($matches[1], $installed) )
5567 $candidates[] = preg_replace("#^NP_#", "", $matches[1]);
5571 $this->newPlugCandidates = $candidates;
5572 return (count($candidates) > 0);
5576 * AdminActions::pagehead()
5577 * Output admin page head
5582 public function parse_pagehead()
5584 global $member, $nucleus, $CONF, $manager;
5586 $extrahead = Admin::getAdminextrahead();
5588 'extrahead' => &$extrahead,
5589 'action' => Admin::getAdminAction()
5591 $manager->notify('AdminPrePageHead', $data);
5593 $content = $this->parser->skin->getContentFromDB('pagehead');
5596 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5600 if ( !array_key_exists('AdminCSS', $CONF) )
5602 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5603 $CONF['AdminCSS'] = 'original';
5607 /* HTTP 1.1 application for no caching */
5608 header("Cache-Control: no-cache, must-revalidate");
5609 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5611 $root_element = 'html';
5612 $charset = i18n::get_current_charset();
5613 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5614 $xml_version_info = self::$xml_version_info;
5615 $formal_public_identifier = self::$formal_public_identifier;
5616 $system_identifier = self::$system_identifier;
5617 $xhtml_namespace = self::$xhtml_namespace;
5619 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5620 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5621 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5623 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5626 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5628 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5629 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5630 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5631 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5632 echo "{$extrahead}\n";
5635 echo "<div id=\"adminwrapper\">\n";
5636 echo "<div class=\"header\">\n";
5637 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5639 echo "<div id=\"container\">\n";
5640 echo "<div id=\"content\">\n";
5641 echo "<div class=\"loginname\">\n";
5643 if ( !$member->isLoggedIn() )
5645 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5649 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5650 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5653 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5656 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5658 $codenamestring = '';
5662 $codenamestring = ' "' . $nucleus['codename'].'"';
5665 if ( $member->isLoggedIn() && $member->isAdmin() )
5667 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5668 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5670 $newestVersion = getLatestVersion();
5671 $newestCompare = str_replace('/', '.', $newestVersion);
5672 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5674 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5677 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5678 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5684 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5691 $this->parser->parse($content);
5698 * AdminActionss::pagefoot()
5699 * Output admin page foot include quickmenu
5704 public function parse_pagefoot()
5706 global $action, $member, $manager;
5709 'action' => Admin::getAdminAction()
5711 $manager->notify('AdminPrePageFoot', $data);
5713 $content = $this->parser->skin->getContentFromDB('pagefoot');
5716 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5718 echo '<h2>' . _LOGOUT . "</h2>\n";
5720 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5721 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5725 echo "<div class=\"foot\">\n";
5726 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5728 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5731 echo "<div id=\"quickmenu\">\n";
5733 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5736 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5739 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5740 echo "<form method=\"get\" action=\"index.php\">\n";
5742 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5744 $showAll = requestVar('showall');
5746 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5748 // Super-Admins have access to all blogs! (no add item support though)
5749 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5750 $query = sprintf($query, sql_table('blog'));
5754 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5755 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5757 $template['name'] = 'blogid';
5758 $template['tabindex'] = 15000;
5759 $template['extra'] = _QMENU_ADD_SELECT;
5760 $template['selected'] = -1;
5761 $template['shorten'] = 10;
5762 $template['shortenel'] = '';
5763 $template['javascript'] = 'onchange="return form.submit()"';
5764 showlist($query, 'select', $template);
5769 echo "<h2>{$member->getDisplayName()}</h2>\n";
5771 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5772 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5773 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5776 if ( $member->isAdmin() )
5778 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5780 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5781 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5782 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5783 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5784 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5785 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5786 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5789 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5791 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5792 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5793 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5797 $data = array('options' => array());
5799 $manager->notify('QuickMenu', $data);
5801 if ( count($data['options']) > 0 )
5803 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5805 foreach ( $data['options'] as $option )
5807 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5812 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5815 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5819 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5822 echo "<!-- quickmenu -->\n";
5825 echo "<!-- content -->\n";
5828 echo "<!-- container -->\n";
5831 echo "<!-- adminwrapper -->\n";
5839 $this->parser->skin->parse('pagefoot');
5846 * AdminActions::selectBlog()
5847 * Inserts a HTML select element with choices for all blogs to which the user has access
5848 * mode = 'blog' => shows blognames and values are blogids
5849 * mode = 'category' => show category names and values are catids
5851 * @param string $name
5852 * @param string $mode
5853 * @param integer $selected
5854 * @param integer $tabindex
5855 * @param integer $showNewCat
5856 * @param integer $iForcedBlogInclude ID for weblog always included
5857 * @param $iForcedBlogInclude
5858 * ID of a blog that always needs to be included, without checking if the
5859 * member is on the blog team (-1 = none)
5862 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5864 global $member, $CONF;
5866 // 0. get IDs of blogs to which member can post items (+ forced blog)
5867 $aBlogIds = array();
5868 if ( $iForcedBlogInclude != -1 )
5870 $aBlogIds[] = intval($iForcedBlogInclude);
5873 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5875 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5876 $query = sprintf($query, sql_table('blog'));
5880 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5881 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5884 $rblogids = DB::getResult($query);
5885 foreach ( $rblogids as $row )
5887 if ( $row['bnumber'] != $iForcedBlogInclude )
5889 $aBlogIds[] = intval($row['bnumber']);
5893 if ( count($aBlogIds) == 0 )
5898 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5900 // 1. select blogs (we'll create optiongroups)
5901 // (only select those blogs that have the user on the team)
5902 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5903 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5904 $blogs = DB::getResult($queryBlogs);
5906 if ( $mode == 'category' )
5908 if ( $blogs->rowCount() > 1 )
5912 foreach ( $blogs as $rBlog )
5914 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5916 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5919 // show selection to create new category when allowed/wanted
5922 // check if allowed to do so
5923 if ( $member->blogAdminRights($rBlog['bnumber']) )
5925 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5929 // 2. for each category in that blog
5930 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5931 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5932 $categories = DB::getResult($catQuery);
5933 foreach ( $categories as $rCat )
5935 if ( $rCat['catid'] == $selected )
5937 $selectText = ' selected="selected" ';
5943 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
5946 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5954 foreach ( $blogs as $rBlog )
5956 echo '<option value="' . $rBlog['bnumber'] . '"';
5957 if ( $rBlog['bnumber'] == $selected )
5959 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
5963 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";