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)
2144 $contents = array();
2146 if ( requestVar('action') == 'itemedit' )
2148 $itemid = intRequestVar('itemid');
2149 $item =& $manager->getItem($itemid, 1, 1);
2151 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2153 if ( $item && $blog->convertBreaks() )
2155 $item['body'] = removeBreaks($item['body']);
2156 $item['more'] = removeBreaks($item['more']);
2160 elseif ( requestVar('action') == 'createitem' )
2162 $blogid = intRequestVar('blogid');
2163 $blog =& $manager->getBlog($blogid);
2167 'contents' => &$contents,
2173 if ( !array_key_exists($which, $contents) )
2175 $contents[$which] = '';
2177 echo Entity::hsc($contents[$which],ENT_QUOTES);
2181 * AdminActions::parse_currenttime()
2182 * Parse skinvar currenttime
2184 * @param string $what
2187 public function parse_currenttime($what)
2190 if ( requestVar('action') == 'itemedit' )
2192 $itemid = intRequestVar('itemid');
2193 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2195 elseif ( requestVar('action') == 'createitem' )
2197 $blog =& $manager->getBlog(intRequestVar('blogid'));
2199 $nu = getdate($blog->getCorrectTime());
2204 * AdminActions::parse_customhelplink()
2205 * Parse skinvar customhelplink
2207 * @param string $topic name of topic
2208 * @param string $tplName name of template
2209 * @param string $url string as URI
2210 * @param string $iconURL string as URI for icon
2211 * @param string $alt alternative text for image element
2212 * @param string $title title for anchor element
2215 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2217 $this->customHelp($topic, $url, $iconURL);
2222 * AdminActions::parse_date()
2223 * Parse skinvar date
2225 public function parse_date($format = 'c')
2227 global $CONF, $manager;
2228 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2233 * AdminActions::parse_defaultadminskintypes()
2234 * Parse skinvar defaultadminskintypes
2236 * @param string $tabindex index number for tabindex attribute of input element
2237 * @param string $templateName name of template
2240 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2242 $templates = array();
2244 if ( $templateName )
2246 $templates = Template::read($templateName);
2249 $types = $this->parser->skin->getAvailableTypes();
2252 /* NOTE: set templates for HEAD/BODY/FOOT */
2253 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2255 $template['head'] = "<ul>\n";
2259 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2261 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2263 $template['body'] = "<li>"
2264 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2269 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2271 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2273 $template['foot'] = "</ul>\n";
2277 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2280 $handler = new AdminActions('template');
2281 $parser = new PARSER($handler);
2283 /* NOTE: do output */
2284 echo $template['head'];
2285 foreach ( $types as $type => $fName )
2287 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2289 'tabindex' => $tabindex,
2290 'skintype' => $type,
2292 'help' => $helplink,
2293 'skinid' => intrequestVar('skinid'),
2295 $parser->parse(Template::fill($template['body'], $data));
2298 echo $template['foot'];
2304 * AdminActions::parse_defblogselect()
2305 * Parse skinvar defblogselect
2307 * @param string $templateName name of template
2310 public function parse_defblogselect($templateName = '')
2314 $query = "SELECT bname as text, bnumber as value FROM %s;";
2315 $query = sprintf($query, sql_table('blog'));
2317 $template['name'] = 'DefaultBlog';
2318 $template['selected'] = $CONF['DefaultBlog'];
2319 $template['tabindex'] = 10;
2321 Showlist($query, 'select', $template, $templateName);
2327 * AdminActions::parse_defcatselect()
2328 * Parse skinvar defcatselect
2330 * @param string $templateName name of template
2333 public function parse_defcatselect($templateName = '')
2337 $blogid = intRequestVar('blogid');
2338 $blog = $manager->getBlog($blogid);
2340 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2341 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2343 $template['name'] = 'defcat';
2344 $template['selected'] = $blog->getDefaultCategory();
2345 $template['tabindex'] = 110;
2347 Showlist($query, 'select', $template, $templateName);
2353 * AdminActions::parse_defskinselect()
2354 * Parse skinvar defskinselect
2356 * @param string $type type of skin
2357 * @param string $templateName name of template
2360 public function parse_defskinselect($type = 'blog', $templateName = '')
2362 global $CONF, $manager;
2364 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2365 $query = sprintf($query, sql_table('skin_desc'));
2367 $blogid = intRequestVar('blogid');
2371 $template['selected'] = $CONF['BaseSkin'];
2375 $blog = $manager->getBlog($blogid);
2376 $template['selected'] = $blog->getDefaultSkin();
2379 if ( $type != 'blog' )
2381 $nname = 'BaseSkin';
2388 $template['name'] = $nname;
2389 $template['tabindex'] = 50;
2391 Showlist($query, 'select', $template, $templateName);
2397 * AdminActions::parse_deletecomment()
2398 * Parse skinvar deletecomment
2400 * @param string $type type of infomation for comment
2403 public function parse_deletecomment($type = 'id')
2405 $commentid = intRequestVar('commentid');
2406 $comment = COMMENT::getComment($commentid);
2411 echo intRequestVar('commentid');
2414 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2416 echo $comment['member'];
2420 echo $comment['user'];
2424 $body = strip_tags($comment['body']);
2425 echo Entity::hsc(shorten($body, 300, '...'));
2431 * AdminActions::parse_deleteitembody()
2432 * Parse skinvar deleteitembody
2437 public function parse_deleteitembody()
2441 $itemid = intRequestVar('itemid');
2442 $item =& $manager->getItem($itemid, 1, 1);
2444 $body = strip_tags($item['body']);
2446 echo Entity::hsc(shorten($body, 300, '...'));
2452 * AdminActions::parse_deleteitemid()
2453 * Parse skinvar deleteitemid
2458 public function parse_deleteitemid()
2460 echo (integer) intRequestVar('itemid');
2465 * AdminActions::parse_deleteitemtitle()
2466 * Parse skinvar deleteitemtitle
2471 public function parse_deleteitemtitle()
2475 $itemid = intRequestVar('itemid');
2476 $item =& $manager->getItem($itemid, 1, 1);
2478 echo Entity::hsc(strip_tags($item['title']));
2484 * AdminActions::parse_editadminskin()
2485 * Parse skinvar editadminskin
2487 * @param string $type type of skin setting
2490 public function parse_editadminskin($type = 'id')
2492 $skinid = intRequestVar('skinid');
2493 $skin = new Skin($skinid);
2497 echo intRequestVar('skinid');
2500 echo Entity::hsc($skin->getName());
2503 echo Entity::hsc($skin->getDescription());
2506 echo Entity::hsc($skin->getContentType());
2509 echo Entity::hsc($skin->getIncludePrefix());
2512 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2520 * AdminActions::parse_editadminskintype()
2521 * Parse skinvar editadminskintype
2523 * @param string $type name of skin type
2526 public function parse_editadminskintype($type = 'id')
2528 global $CONF, $manager, $member;
2530 $fNames = $this->parser->skin->getAvailableTypes();
2531 $sType = strtolower(trim(requestVar('type')));
2536 echo intRequestVar('skinid');
2539 echo Entity::hsc($this->parser->skin->getName());
2542 echo Entity::hsc($this->parser->skin->getDescription());
2545 echo Entity::hsc($this->parser->skin->getContentType());
2548 echo Entity::hsc($this->parser->skin->getContentFromDB($sType));
2551 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2552 echo Entity::hsc($skinType);
2555 echo Entity::hsc($sType);
2558 echo Entity::hsc($this->parser->skin->getIncludePrefix());
2561 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2562 echo Entity::hsc($incMode);
2571 * AdminActions::parse_editcomment()
2572 * Parse skinvar editcomment
2574 * @param string $type type of comment setting
2577 public function parse_editcomment($type = 'id')
2581 $commentid = intRequestVar('commentid');
2582 $comment = COMMENT::getComment($commentid);
2584 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2589 echo intRequestVar('commentid');
2592 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2594 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2598 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2602 echo date("Y-m-d @ H:i", $comment['timestamp']);
2605 $comment['body'] = str_replace('<br />', '', $comment['body']);
2606 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2607 echo $comment['body'];
2610 echo $comment['userid'];
2613 echo $comment['userid'];
2616 echo $comment[$type];
2623 * AdminActions::parse_editdesturl()
2624 * Parse skinvar editdesturl
2626 public function parse_editdesturl()
2628 if ( requestVar('desturl') )
2630 echo Entity::hsc(requestVar('desturl'));
2636 * AdminActions::parse_editmemberlist()
2637 * Parse skinvar editmemberlist
2639 * @param string $templateName name of template
2642 public function parse_editmemberlist($templateName = '')
2645 // show list of members with actions
2646 $query = 'SELECT * FROM '.sql_table('member');
2647 $template['content'] = 'memberlist';
2648 $template['tabindex'] = 10;
2650 $batch = new Batch('member');
2651 $batch->showList($query, 'table', $template, $templateName, _LISTS_NOMORE);
2656 * AdminActions::parse_editmember()
2657 * Parse skinvar editmember
2659 * @param string $type type of information for member
2660 * @return string $tempateName name of template to use
2663 public function parse_editmember($type = 'id', $templateName = '')
2665 global $CONF, $manager, $member;
2667 $memberid = intRequestVar('memberid');
2668 $mem = MEMBER::createFromID($memberid);
2673 echo intRequestVar('memberid');
2676 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2678 echo Entity::hsc($mem->getDisplayName());
2682 $dispName = Entity::hsc($mem->getDisplayName());
2683 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2685 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2694 echo Entity::hsc($mem->getRealName());
2697 echo Entity::hsc($mem->getEmail());
2700 echo Entity::hsc($mem->getURL());
2703 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2706 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2709 echo Entity::hsc($mem->getNotes());
2712 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2721 * AdminActions::parse_editpluginfo()
2722 * Parse skinvar editpluginfo
2724 * @param string $type type of plugin info
2727 public function parse_editpluginfo($type)
2731 $pid = intRequestVar('plugid');
2738 echo Entity::hsc($manager->getPluginNameFromPid($pid));
2745 * AdminActions::parse_editplugoptionslist()
2746 * Parse skinvar editplugoptionslist
2748 * @param string $templateName name of template
2751 public function parse_editplugoptionslist($templateName = '')
2755 $pid = intRequestVar('plugid');
2756 $aOptions = array();
2759 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2760 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2761 $resource = DB::getResult($query);
2763 foreach ( $resource as $row )
2765 array_push($aOIDs, $row['oid']);
2766 $aOptions[$row['oid']] = array(
2767 'oid' => $row['oid'],
2768 'value' => $row['odef'],
2769 'name' => $row['oname'],
2770 'description' => $row['odesc'],
2771 'type' => $row['otype'],
2772 'typeinfo' => $row['oextra'],
2777 // fill out actual values
2778 if ( count($aOIDs) > 0 )
2780 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2781 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2783 $result = DB::getResult($query);
2785 foreach ( $result as $row )
2787 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2793 'context' => 'global',
2795 'options' => &$aOptions
2797 $manager->notify('PrePluginOptionsEdit', $data);
2799 $template['content'] = 'plugoptionlist';
2801 $amount = Showlist($aOptions, 'table', $template, $templateName);
2805 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2811 * AdminActions::parse_editskin()
2812 * Parse skinvar editskin
2814 * @param string $type type of skin
2817 public function parse_editskin($type = 'id')
2819 $skinid = intRequestVar('skinid');
2820 $skin = new SKIN($skinid);
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->getIncludePrefix());
2839 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2847 * AdminActions::parse_editskintype()
2848 * Parse skinvar editskintype
2850 * @param string $type name of type for skin type
2853 public function parse_editskintype($type = 'id')
2855 global $CONF, $manager, $member;
2856 $skinid = intRequestVar('skinid');
2857 $skin = new SKIN($skinid);
2858 $fNames = $skin->getAvailableTypes();
2859 $sType = strtolower(trim(requestVar('type')));
2864 echo intRequestVar('skinid');
2867 echo Entity::hsc($skin->getName());
2870 echo Entity::hsc($skin->getDescription());
2873 echo Entity::hsc($skin->getContentType());
2876 echo Entity::hsc($skin->getContentFromDB($sType));
2879 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2880 echo Entity::hsc($skinType);
2883 echo Entity::hsc($sType);
2886 echo Entity::hsc($skin->getIncludePrefix());
2889 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2890 echo Entity::hsc($incMode);
2899 * AdminActions::parse_adminurl()
2900 * Parse skinvar adminurl
2901 * (shortcut for admin url)
2906 public function parse_adminurl()
2908 $this->parse_sitevar('adminurl');
2913 * AdminActions::parse_edittemplateinfo()
2914 * Parse skinvar edittemplateinfo
2916 * @param string $type name of type for skin
2917 * @param string $description description for skin
2918 * @param string $name name of skin
2919 * @param string $help
2920 * @param string $tabindex index value for tabindex attribute of input element
2921 * @param string $big
2922 * @param string $tplt name of template
2925 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2929 $t_id = intRequestVar('templateid');
2930 $t_name = Template::getNameFromId($t_id);
2931 $t_desc = Template::getDesc($t_id);
2932 $template = &Template::read($t_name);
2940 echo Entity::hsc($t_name);
2943 echo Entity::hsc($t_desc);
2945 case 'extratemplate':
2947 $pluginfields = array();
2948 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
2953 $tmplt = Template::read($desc);
2955 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2959 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2963 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2966 foreach ( $pluginfields as $pfkey => $pfvalue )
2968 $data = array('explugtplname' => Entity::hsc($pfkey));
2970 echo Template::fill($base, $data);
2972 foreach ( $pfvalue as $pffield => $pfdesc )
2974 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2979 $desc = defined($desc) ? constant($desc) : $desc;
2980 $name = defined($name) ? constant($name) : $name;
2981 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2989 * AdminActions::parse_editadmintemplateinfo()
2990 * Parse skinvar editadmintemplateinfo
2992 * @param string $type type of skin template
2993 * @param string $description description of template
2994 * @param string $name name of stemplate
2995 * @param string $tabindex index number for tabindex attribute of input element
2996 * @param string $big
2997 * @param string $tplt
2999 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3003 $t_id = intRequestVar('templateid');
3004 $t_name = Template::getNameFromId($t_id);
3005 $t_desc = Template::getDesc($t_id);
3006 $template = &Template::read($t_name);
3014 echo Entity::hsc($t_name);
3017 echo Entity::hsc($t_desc);
3019 case 'extratemplate':
3021 $pluginfields = array();
3022 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3027 $tmplt = Template::read($desc);
3029 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3033 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3037 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3040 foreach ( $pluginfields as $pfkey => $pfvalue )
3042 $data = array('explugtplname' => Entity::hsc($pfkey));
3044 echo Template::fill($base, $data);
3046 foreach ( $pfvalue as $pffield => $pfdesc )
3048 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3053 $desc = defined($desc) ? constant($desc) : $desc;
3054 $name = defined($name) ? constant($name) : $name;
3055 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3062 * AdminActions::parse_eventformextra()
3063 * Parse skinvar eventformextra
3065 * @param string $type name of type for event form extra
3068 public function parse_eventformextra($type = 'activation')
3077 $key = requestVar('ackey');
3080 Admin::error(_ERROR_ACTIVATE);
3082 $info = MEMBER::getActivationInfo($key);
3085 Admin::error(_ERROR_ACTIVATE);
3087 $mem = MEMBER::createFromId($info->vmember);
3090 Admin::error(_ERROR_ACTIVATE);
3093 'type' => 'activation',
3097 case 'membermailform-notloggedin':
3098 $data = array('type' => 'membermailform-notloggedin',);
3101 $manager->notify('FormExtra', $data);
3106 * AdminActions::parse_extrahead()
3107 * Parse skinvar extrahead
3109 public function parse_extrahead()
3113 $extrahead = Admin::getAdminextrahead();
3116 'extrahead' => &$extrahead,
3117 'action' => Admin::getAdminAction()
3120 $manager->notify('AdminPrePageHead', $data);
3126 * AdminActions::parse_member()
3127 * Parse skinvar member
3128 * (includes a member info thingie)
3130 * @param string $what which memberdata is needed
3133 public function parse_member($what)
3135 global $memberinfo, $member, $CONF;
3137 // 1. only allow the member-details-page specific variables on member pages
3138 if ( $this->skintype == 'member' )
3143 echo Entity::hsc($memberinfo->getDisplayName());
3146 echo Entity::hsc($memberinfo->getRealName());
3149 echo Entity::hsc($memberinfo->getNotes());
3152 echo Entity::hsc($memberinfo->getURL());
3155 echo Entity::hsc($memberinfo->getEmail());
3158 echo Entity::hsc($memberinfo->getID());
3163 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3164 if ( $member->isLoggedIn() )
3169 echo $member->getDisplayName();
3171 case 'yourrealname':
3172 echo $member->getRealName();
3175 echo $member->getNotes();
3178 echo $member->getURL();
3181 echo $member->getEmail();
3184 echo $member->getID();
3186 case 'yourprofileurl':
3187 if ( $CONF['URLMode'] == 'pathinfo' )
3189 echo Link::create_member_link($member->getID());
3193 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3202 * AdminActions::parse_version()
3203 * Parse skinvar version
3204 * (include nucleus versionnumber)
3209 public function parse_version()
3212 echo 'Nucleus CMS ' . $nucleus['version'];
3217 * AdminActions::parse_sitevar()
3218 * Parse skinvar sitevar
3219 * (include a sitevar)
3221 * @param string $which
3224 public function parse_sitevar($which)
3230 echo $CONF['IndexURL'];
3233 echo $CONF['SiteName'];
3236 echo $CONF['AdminEmail'];
3239 echo $CONF['AdminURL'];
3245 * AdminActions::parse_charset()
3246 * Parse skinvar charset
3251 public function parse_charset()
3253 echo i18n::get_current_charset();
3258 * AdminActions::parse_getblogsetting()
3259 * Parse skinvar getblogsetting
3261 public function parse_getblogsetting($which)
3263 global $blog, $manager;
3269 elseif ( $bid = intRequestVar('blogid') )
3271 $b = $manager->getBlog($bid);
3281 return Entity::hsc($b->getID());
3284 return Entity::hsc($b->getURL());
3287 return Entity::hsc($b->getName());
3290 return Entity::hsc($b->getDescription());
3293 return Entity::hsc($b->getShortName());
3295 case 'notifyaddress':
3296 return Entity::hsc($b->getNotifyAddress());
3299 return Entity::hsc($b->getMaxComments());
3302 return Entity::hsc($b->getUpdateFile());
3305 return Entity::hsc($b->getTimeOffset());
3312 * AdminActions::parse_geteditpluginfo()
3313 * Parse skinvar geteditpluginfo
3315 * @param string $type name of setting for edit plugin info
3318 public function parse_geteditpluginfo($type)
3321 $pid = intRequestVar('plugid');
3328 return Entity::hsc($manager->getPluginNameFromPid($pid));
3335 * AdminActions::parse_getmember()
3336 * Parse skinvar getmember
3337 * (includes a member info thingie)
3339 * @param string $what name of setting for member
3342 public function parse_getmember($what)
3344 global $memberinfo, $member;
3345 // 1. only allow the member-details-page specific variables on member pages
3346 if ( $this->skintype == 'member' )
3351 return Entity::hsc($memberinfo->getDisplayName());
3354 return Entity::hsc($memberinfo->getRealName());
3357 return Entity::hsc($memberinfo->getNotes());
3360 return Entity::hsc($memberinfo->getURL());
3363 return Entity::hsc($memberinfo->getEmail());
3366 return Entity::hsc($memberinfo->getID());
3370 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3371 if ( $member->isLoggedIn() )
3376 return $member->getDisplayName();
3378 case 'yourrealname':
3379 return $member->getRealName();
3382 return $member->getNotes();
3385 return $member->getURL();
3388 return $member->getEmail();
3391 return $member->getID();
3399 * AdminActions::parse_headmessage()
3400 * Parse skinvar headmessage
3405 public function parse_headmessage()
3407 if ( !empty(Admin::$headMess) )
3409 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3415 * AdminActions::parse_helplink()
3416 * Parse skinvar helplink
3418 * @param string $topic name of topic for help
3421 public function parse_helplink($topic = '')
3423 if ( !empty($topic) )
3431 * AdminActions::parse_helpplugname()
3432 * Parse skinvar helpplugname
3437 public function parse_helpplugname()
3439 $plugid = intGetVar('plugid');
3440 Entity::hsc($manager->getPluginNameFromPid($plugid));
3445 * AdminActions::parse_ilistaddnew()
3446 * Parse skinvar ilistaddnew
3451 public function parse_ilistaddnew()
3453 $blogid = intRequestVar('blogid');
3454 if ( intPostVar('start') == 0 )
3456 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3462 * AdminActions::parse_importskininfo()
3463 * Parse skinvar importskininfo
3465 * @param string $type name of information for imported skin
3468 public function parse_importskininfo($type)
3473 echo Entity::hsc(requestVar('skininfo'));
3476 $dataArr = requestArray('skinnames');
3477 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3480 $dataArr = requestArray('tpltnames');
3481 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3484 $dataArr = requestArray('skinclashes');
3485 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3488 $dataArr = requestArray('tpltclashes');
3489 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3492 echo Entity::hsc(requestVar('skinfile'));
3495 echo Entity::hsc(requestVar('mode'));
3502 * AdminActions::parse_inputyesno()
3503 * Parse skinvar inputyesno
3505 * some init stuff for all forms
3510 public function parse_init()
3515 if ( requestVar('action') == 'itemedit' )
3517 $itemid = intRequestVar('itemid');
3518 $item =& $manager->getItem($itemid, 1, 1);
3520 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3521 if ( $item && $blog->convertBreaks() )
3523 $item['body'] = removeBreaks($item['body']);
3524 $item['more'] = removeBreaks($item['more']);
3527 $authorid = $contents['authorid'];
3529 elseif ( requestVar('action') == 'createitem' )
3531 $blogid = intRequestVar('blogid');
3532 $blog =& $manager->getBlog($blogid);
3535 $blog->insertJavaScriptInfo($authorid);
3540 * AdminActions::parse_inputyesno()
3541 * Parse skinvar inputyesno
3543 * @param string $name
3544 * @param string $checkedval
3545 * @param string $tabindex
3546 * @param string $value1
3547 * @param string $value2
3548 * @param string $yesval
3549 * @param string $noval
3550 * @param string $isAdmin
3551 * @param string $templateName
3554 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3556 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3561 * AdminActions::parse_insertpluginfo()
3562 * Parse templatevar insertpluginfo
3564 public function parse_insertpluginfo($type)
3566 $option = Admin::getAdminaOption();
3570 return $option['pid'];
3573 return Entity::hsc($option['pfile']);
3580 * AdminActions::parse_insplugoptcontent()
3581 * Parse skinvar insplugoptcontent
3586 public function parse_insplugoptcontent()
3588 $option = Admin::getAdminaOption();
3590 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3591 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3594 listplug_plugOptionRow($option);
3601 * AdminActions::parse_iprangeinput()
3602 * Parse skinvar iprangeinput
3607 public function parse_iprangeinput()
3609 if ( requestVar('ip') )
3611 $iprangeVal = Entity::hsc(requestVar('ip'));
3612 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3613 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3614 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3615 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3616 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3620 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3621 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3627 * AdminActions::parse_itemnavlist()
3628 * Parse skinvar itemnavlist
3633 public function parse_itemnavlist($templateName)
3635 global $CONF, $manager, $member;
3637 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3638 . " FROM %s, %s, %s, %s"
3639 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3641 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3643 if ( $this->skintype == 'itemlist' )
3646 if ( array_key_exists('blogid', $_REQUEST) )
3648 $blogid = intRequestVar('blogid');
3650 else if ( array_key_exists('itemid', $_REQUEST) )
3652 $itemid = intRequestVar('itemid');
3653 $item = &$manager->getItem($itemid, 1, 1);
3654 $blogid = (integer) $item['blogid'];
3656 $blog =& $manager->getBlog($blogid);
3658 $query .= " AND iblog={$blogid}";
3659 $template['now'] = $blog->getCorrectTime(time());
3661 // non-blog-admins can only edit/delete their own items
3662 if ( !$member->blogAdminRights($blogid) )
3664 $query .= ' AND iauthor = ' . $member->getID();
3667 elseif ( $this->skintype == 'browseownitems' )
3669 $query .= ' AND iauthor = ' . $member->getID();
3671 $template['now'] = time();
3674 // search through items
3675 $search = postVar('search');
3677 if ( !empty($search) )
3679 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3680 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3681 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3684 if ( postVar('start') )
3686 $start = intPostVar('start');
3693 // amount of items to show
3694 if ( postVar('amount') )
3696 $amount = intPostVar('amount');
3700 $amount = (integer) $CONF['DefaultListSize'];
3707 $query .= ' ORDER BY itime DESC'
3708 . " LIMIT {$start},{$amount}";
3710 $template['content'] = 'itemlist';
3712 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3713 $navList->showBatchList('item', $query, 'table', $template, '', $templateName);
3718 * AdminActions::parse_itemtime()
3719 * date change on edit item
3721 * @param string $key key of PHP's getDate()
3724 public function parse_itemtime($key)
3729 $itemid = intRequestVar('itemid');
3730 $item =& $manager->getItem($itemid, 1, 1);
3732 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3734 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3736 $item['body'] = removeBreaks($item['body']);
3737 $item['more'] = removeBreaks($item['more']);
3740 $contents = array();
3741 if ( requestVar('action') == 'itemedit' )
3745 elseif ( requestVar('action') == 'createitem' )
3748 'contents' => &$contents,
3749 'blog' => &$this->blog
3751 $manager->notify('PreAddItemForm', $data);
3753 $itemtime = getdate($contents['timestamp']);
3754 echo $itemtime[$key];
3759 * AdminActions::parse_jstoolbaroptions()
3760 * Parse skinvar jstoolbaroptions
3765 public function parse_jstoolbaroptions()
3769 _SETTINGS_JSTOOLBAR_NONE,
3770 _SETTINGS_JSTOOLBAR_SIMPLE,
3771 _SETTINGS_JSTOOLBAR_FULL
3775 foreach ( $options as $option )
3777 $text = "<option value=\"%d\"%s>%s</option>\n";
3778 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3779 echo sprintf($text, $i, $extra, $option);
3785 * AdminActions::parse_localeselectoptions()
3786 * Parse skinvar localeselectoptions
3791 public function parse_localeselectoptions()
3793 $locales = i18n::get_available_locale_list();
3795 $memid = intRequestVar('memberid');
3798 $mem = MEMBER::createFromID($memid);
3799 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3801 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3805 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3810 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3812 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3816 echo "<option value=\"\">en_Latn_US</option>\n";
3819 foreach ( $locales as $locale )
3821 if ( $locale == 'en_Latn_US' )
3827 if ( $locale == $mem->getLocale() )
3829 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3833 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3838 if ( $locale == i18n::get_current_locale() )
3840 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3844 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3852 * AdminActions::parse_listplugplugoptionrow()
3853 * Parse templatevar listplugplugoptionrow
3855 * @param string $templateName name of template
3858 public function parse_listplugplugoptionrow($templateName = '')
3860 echo listplug_plugOptionRow(Admin::getAdminaOption(), $templateName);
3865 * AdminActions::parse_mediadirwarning()
3866 * Parse skinvar mediadirwarning
3871 public function parse_mediadirwarning()
3874 if ( !is_dir($DIR_MEDIA) )
3876 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3878 if ( !is_readable($DIR_MEDIA) )
3880 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3882 if ( !is_writeable($DIR_MEDIA) )
3884 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3890 * AdminActions::parse_movedistselect()
3891 * Parse skinvar movedistselect
3893 public function parse_movedistselect()
3895 $actionType = requestVar('action');
3896 switch ( $actionType )
3899 $this->selectBlog('destcatid', 'category');
3901 case 'batchcategory':
3902 $this->selectBlog('destblogid');
3905 if ( $this->skintype == 'itemmove' )
3907 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3908 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
3909 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
3910 $this->selectBlog('catid', 'category', $catid, 10, 1);
3918 * AdminActions::parse_moveitemid()
3919 * Parse skinvar moveitemid
3924 public function parse_moveitemid()
3926 echo intRequestVar('itemid');
3931 * AdminActions::parse_newestcompare()
3932 * Parse skinvar newestcompare
3937 public function parse_newestcompare()
3941 $newestVersion = getLatestVersion();
3942 $newestCompare = str_replace('/', '.', $newestVersion);
3943 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3945 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3947 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3948 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3954 * AdminActions::parse_newmemberselect()
3955 * Parse skinvar newmemberselect
3957 * @param string $templateName name of template to use
3960 public function parse_newmemberselect($templateName = '')
3962 $blogid = intRequestVar('blogid');
3964 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3965 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3966 $res = DB::getResult($query);
3969 foreach ( $res as $row )
3971 $tmem[] = intval($row['tmember']);
3974 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3975 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3978 'name' => 'memberid',
3979 'tabindex' => 10000,
3982 Showlist($query, 'select', $template, $templateName);
3987 * AdminActions::parse_newpluginlist()
3988 * Parse skinvar newpluginlist
3993 public function parse_newpluginlist()
3995 $candidates = $this->newPlugCandidates;
3996 foreach ( $candidates as $name )
3998 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4004 * AdminActions::parse_outputspecialdirs()
4005 * Parse skinvar outputspecialdirs
4007 * @param string $type type of setting for directory
4010 public function parse_outputspecialdirs($type)
4012 global $DIR_MEDIA, $DIR_NUCLEUS;
4017 echo Entity::hsc($DIR_NUCLEUS);
4020 echo Entity::hsc($DIR_MEDIA);
4027 * AdminActions::parse_passrequestvars()
4028 * Parse skinvar passrequestvars
4033 public function parse_passrequestvars()
4035 $passvar = Admin::getAdminpassvar();
4036 $oldaction = postVar('oldaction');
4038 if ( ($oldaction != 'logout')
4039 && ($oldaction != 'login')
4041 && !postVar('customaction') )
4049 * AdminActions::parse_pluginextras()
4050 * Parse skinvar pluginextras
4052 * @param string $type type of plugin context
4055 public function parse_pluginextras($type = 'global')
4061 $id = intRequestVar('memberid');
4062 $mem = MEMBER::createFromID($id);
4063 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4066 $id = intRequestVar('blogid');
4067 $blg = $manager->getBlog($id);
4068 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4072 'GeneralSettingsFormExtras',
4082 * AdminActions::parse_pluginhelp()
4083 * Parse skinvar pluginhelp
4088 public function parse_pluginhelp()
4090 global $manager, $DIR_PLUGINS;
4092 $plugid = intGetVar('plugid');
4093 $plugName = $manager->getPluginNameFromPid($plugid);
4094 $plug =& $manager->getPlugin($plugName);
4096 if ( $plug->supportsFeature('HelpPage') > 0 )
4098 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4099 if ( @file_exists($helpfile . 'php') )
4101 @include($helpfile . 'php');
4104 elseif ( @file_exists($helpfile . 'html') )
4106 @include($helpfile . 'html');
4110 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4111 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4116 * AdminActions::parse_pluginlistlist()
4117 * Parse skinvar pluginlistlist
4119 * @param string $templateName name of template to use
4122 public function parse_pluginlistlist($templateName = '')
4124 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4125 $query = sprintf($query, sql_table('plugin'));
4127 $template['content'] = 'pluginlist';
4128 $template['tabindex'] = 10;
4130 Showlist($query, 'table', $template, $templateName);
4136 * AdminActions::parse_pluginoptions()
4137 * Parse skinvar pluginoptions
4139 * @param string $type type of plugin option
4142 public function parse_pluginoptions($context='global', $templateName='')
4144 global $itemid, $manager;
4149 $contextid = intRequestVar('memberid');
4152 $contextid = intRequestVar('blogid');
4155 $contextid = intRequestVar('catid');
4158 $contextid = $itemid;
4162 /* Actually registererd plugin options */
4163 $aIdToValue = array();
4164 $query = "SELECT oid, ovalue FROM %s WHERE ocontextid=%d;";
4165 $query = sprintf($query, sql_table('plugin_option'), (integer) $contextid);
4166 $res = DB::getResult($query);
4167 foreach ( $res as $row )
4169 $aIdToValue[$row['oid']] = $row['ovalue'];
4172 /* Currently available plugin options */
4173 $query = "SELECT * FROM %s, %s WHERE opid=pid and ocontext= %s ORDER BY porder, oid ASC;";
4174 $query = sprintf($query, sql_table('plugin_option_desc'), sql_table('plugin'), DB::quoteValue($context));
4175 $res = DB::getResult($query);
4178 foreach ($res as $row )
4180 if ( !array_key_exists($row['oid'], $aIdToValue) )
4182 $value = $row['odef'];
4186 $value = $aIdToValue[$row['oid']];
4190 'pid' => $row['pid'],
4191 'pfile' => $row['pfile'],
4192 'oid' => $row['oid'],
4194 'name' => $row['oname'],
4195 'description' => $row['odesc'],
4196 'type' => $row['otype'],
4197 'typeinfo' => $row['oextra'],
4198 'contextid' => $contextid,
4204 'context' => $context,
4205 'contextid' => $contextid,
4206 'options' => &$options
4208 $manager->notify('PrePluginOptionsEdit', $data);
4210 $template = array();
4211 if ( $templateName )
4213 $templates = Template::read($templateName);
4214 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
4216 $template['title'] = "<tr>"
4217 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
4222 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
4225 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
4227 $template['body'] = "<tr>"
4228 . "<%listplugplugoptionrow%>"
4233 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
4239 include_libs('ACTIONS.php');
4240 $handler = new Actions($this->skintype);
4241 $parser = new PARSER($handler);
4243 foreach ( $options as $option )
4246 if ( $prevPid != $option['pid'] )
4248 $prevPid = $option['pid'];
4249 $parser->parse($template['title']);
4252 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
4254 if ( @$meta['access'] != 'hidden' )
4256 $parsed = $parser->parse($template['body']);
4264 * AdminActions::parse_qmenuaddselect()
4265 * Parse skinvar qmanuaddselect
4267 * @param string $templateName name of template to use
4270 public function parse_qmenuaddselect($templateName = '')
4273 $showAll = requestVar('showall');
4274 if ( $member->isAdmin() && ($showAll == 'yes') )
4276 // Super-Admins have access to all blogs! (no add item support though)
4277 $query = 'SELECT bnumber as value, bname as text'
4278 . ' FROM ' . sql_table('blog')
4279 . ' ORDER BY bname';
4283 $query = 'SELECT bnumber as value, bname as text'
4284 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4285 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4286 . ' ORDER BY bname';
4289 $template['name'] = 'blogid';
4290 $template['tabindex'] = 15000;
4291 $template['extra'] = _QMENU_ADD_SELECT;
4292 $template['selected'] = -1;
4293 $template['shorten'] = 10;
4294 $template['shortenel'] = '';
4295 $template['javascript'] = 'onchange="return form.submit()"';
4297 Showlist($query, 'select', $template, $templateName);
4303 * AdminActions::parse_quickmenu()
4304 * Parse skinvar quickmenu
4306 * @param string $templateName name of template to use
4309 public function parse_quickmenu($templateName = '')
4312 $templates = array();
4313 $template = array();
4314 if ( !empty($templateName) )
4316 $templates = Template::read($templateName);
4318 $pluginExtras = array();
4322 'options' => &$pluginExtras
4325 if ( count($pluginExtras) > 0 )
4327 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4329 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4333 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4335 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4337 $template['head'] = "<ul>\n";
4341 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4343 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4345 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4349 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4351 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4353 $template['foot'] = "</ul>\n";
4357 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4360 $handler = new Actions($this->skintype);
4361 $parser = new PARSER($handler);
4363 $parser->parse($template['title']);
4364 echo $template['head'];
4365 foreach ( $pluginExtras as $aInfo )
4368 'plugadminurl' => Entity::hsc($aInfo['url']),
4369 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4370 'plugadmintitle' => Entity::hsc($aInfo['title']),
4372 echo Template::fill($template['body'], $data);
4374 echo $template['foot'];
4380 * AdminActions::parse_requestblogid()
4381 * Parse skinvar requestblogid
4386 public function parse_requestblogid()
4388 echo intRequestVar('blogid');
4393 * AdminActions::parse_requestiprange()
4394 * Parse skinvar requestiprange
4399 public function parse_requestiprange()
4401 if ( requestVar('iprange') )
4403 echo Entity::hsc(requestVar('iprange'));
4405 elseif ( requestVar('ip') )
4407 echo Entity::hsc(requestVar('ip'));
4413 * AdminActions::parse_selectlocaladminskinfiles()
4414 * Parse skinvar selectlocaladminskinfiles
4419 public function parse_selectlocaladminskinfiles()
4421 global $DIR_SKINS, $manager;
4423 $adminskindir = $DIR_SKINS . 'admin/';
4424 $candidates = SkinImport::searchForCandidates($adminskindir);
4426 foreach ( $candidates as $skinname => $skinfile )
4428 $html = Entity::hsc($skinfile);
4429 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4436 * AdminActions::parse_selectlocalskinfiles()
4437 * Parse skinvar selectlocalskinfiles
4442 public function parse_selectlocalskinfiles()
4446 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4448 foreach ( $candidates as $skinname => $skinfile )
4450 $html = Entity::hsc($skinfile);
4451 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4458 * AdminActions::parse_skineditallowedlist()
4459 * Parse skinvar skineditallowedlist
4461 * @param string $type type of skin
4462 * @param string $templateName name of template
4465 public function parse_skineditallowedlist($type, $templateName = '')
4470 $query = "SELECT bshortname, bname FROM %s;";
4472 'content' => 'shortblognames'
4474 $query = sprintf($query, sql_table('blog'));
4475 Showlist($query, 'table', $show, $templateName);
4478 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4480 'content' => 'shortnames'
4482 $query = sprintf($query, sql_table('template_desc'));
4483 Showlist($query, 'table', $show, $templateName);
4490 * AdminActions::parse_skinielist()
4491 * Parse skinvar skinielist
4493 * @param string $type type of skin
4494 * @param string $templateName name of template to use
4497 public function parse_skinielist($type, $templateName = '')
4499 $templates = array();
4500 if ( $templateName )
4502 $templates = Template::read($templateName);
4504 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4506 $template = $templates['SKINIE_EXPORT_LIST'];
4511 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4512 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4514 . "<td><%expdesc%></td>\n"
4521 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'). " WHERE sdname NOT LIKE 'admin/%%';");
4522 foreach ( $res as $row )
4525 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4526 'expid' => 'skinexp' . $row['sdnumber'],
4527 'expname' => Entity::hsc($row['sdname']),
4528 'expdesc' => Entity::hsc($row['sddesc'])
4530 echo Template::fill($template, $data);
4534 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4535 foreach ( $res as $row )
4538 'typeid' => 'template[' . $row['tdnumber'] . ']',
4539 'expid' => 'templateexp' . $row['tdnumber'],
4540 'expname' => Entity::hsc($row['tdname']),
4541 'expdesc' => Entity::hsc($row['tddesc'])
4543 echo Template::fill($template, $data);
4551 * AdminActions::parse_skinoverview()
4552 * Parse skinvar skinoverview
4554 * @param string $templateName name of template to use
4557 public function parse_skinoverview($templateName = '')
4560 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4561 $query = sprintf($query, sql_table('skin_desc'));
4563 $template['content'] = 'skinlist';
4564 $template['tabindex'] = 10;
4566 Showlist($query, 'table', $template, $templateName);
4571 * AdminActions::parse_skintypehelp()
4572 * Check editing skintypehelp
4577 public function parse_skintypehelp()
4579 $nowSkinType = strtolower(trim(requestVar('type')));
4581 /* TODO: use Skin class */
4582 $regularType = array(
4593 if ( in_array($nowSkinType, $regularType) )
4595 help('skinpart' . $nowSkinType);
4599 help('skinpartspecial');
4605 * AdminActions::parse_specialskinlist()
4606 * Parse skinvar specialskinlist
4608 * @param string $templateName name of template to use
4611 public function parse_specialskinlist($templateName = '')
4613 $templates = array();
4614 if ( $templateName )
4616 $templates = Template::read($templateName);
4619 /* TODO: use Skin class */
4630 $skinid = intRequestVar('skinid');
4631 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4632 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4634 $res = DB::getResult($query);
4635 if ( $res && $res->rowCount() > 0 )
4638 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4640 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4644 $template['head'] = "<ul>\n";
4646 echo Template::fill($template['head'], $data);
4647 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4649 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4650 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4651 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4655 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4659 foreach ( $res as $row )
4662 'tabindex' => $tabstart++,
4663 'skinid' => $skinid,
4664 'skintype' => Entity::hsc(strtolower($row['stype']))
4666 echo Template::fill($template['body'], $data);
4669 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4671 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4675 $template['foot'] = "</ul>\n";
4677 echo Template::fill($template['foot'], $data);
4683 * AdminActions::parse_sprinttext()
4686 * @param string $which
4687 * @param string $val
4690 public function parse_sprinttext($which, $val)
4692 if ( !defined($which) )
4698 $base = constant($which);
4701 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4703 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4705 $met = 'parse_' . $matchies[0];
4709 $arg = trim($args[0], '()');
4710 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4713 if ( method_exists($this, $met) )
4715 $value = call_user_func(array(&$this, $met), $arg);
4719 if ( !isset($value) || empty($value) )
4723 echo sprintf($base, $value);
4728 * AdminActions::parse_systemsettings()
4729 * Parse skinvar systemsettings
4731 * @param string $type type of settings for system
4732 * @param string $templateName name of template to use
4735 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4737 global $member, $CONF, $nucleus;
4739 $member->isAdmin() or Admin::disallow();
4741 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4742 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4749 case 'sqlserverinfo':
4750 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4752 case 'sqlclientinfo':
4753 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4755 case 'magicquotesgpc':
4756 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4758 case 'magicquotesruntime':
4759 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4761 case 'registerglobals':
4762 echo ini_get('register_globals') ? 'On' : 'Off';
4765 $templates = array();
4766 if ( $templateName )
4768 $templates = Template::read($templateName);
4770 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4772 $template = "<tr>\n"
4773 . "<td><%key%></td>\n"
4774 . "<td><%value%></td>\n"
4779 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4782 $gdinfo = gd_info();
4784 foreach ( $gdinfo as $key => $value )
4786 if ( is_bool($value) )
4788 $value = $value ? $enable : $disable;
4792 $value = Entity::hsc($value);
4798 echo Template::fill($template, $data);
4803 phpinfo(INFO_MODULES);
4804 $im = ob_get_contents();
4806 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4808 case 'nucleusversion':
4809 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4811 case 'nucleuspatchlevel':
4812 echo getNucleusPatchLevel();
4818 echo $CONF['ItemURL'];
4820 case 'alertonheaderssent':
4821 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4823 case 'nucleuscodename':
4824 if ( $nucleus['codename'] != '' )
4826 echo ' "' . $nucleus['codename'] . '"';
4829 case 'versioncheckurl':
4830 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4837 * AdminActions::parse_templateoverview()
4838 * Parse skinvar templateoverview
4840 * @param string $templateName name of template to use
4843 public function parse_templateoverview($templateName = '')
4845 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4846 $query = sprintf($query, sql_table('template_desc'));
4848 $template['content'] = 'templatelist';
4849 $template['tabindex'] = 10;
4851 Showlist($query, 'table', $template, $templateName);
4857 * AdminActions::parse_ticket()
4863 public function parse_ticket()
4866 $manager->addTicketHidden();
4871 * AdminActions::parse_versioncheckurl()
4872 * Parse skinvar versioncheckurl
4877 public function parse_versioncheckurl()
4879 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4884 * AdminActions::parse_yrbloglist()
4885 * Parse skinvar yrbloglist
4887 * @param string $templateName name of template to use
4890 public function parse_yrbloglist($templateName = '')
4893 $showAll = requestVar('showall');
4895 if ( $member->isAdmin() && ($showAll == 'yes') )
4897 // Super-Admins have access to all blogs! (no add item support though)
4898 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4900 . " ORDER BY bnumber;";
4901 $query = sprintf($query, sql_table('blog'));
4905 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4907 . " WHERE tblog=bnumber and tmember=%d"
4908 . " ORDER BY bnumber;";
4909 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4912 $template['content'] = 'bloglist';
4913 $template['superadmin'] = $member->isAdmin();
4915 $amount = Showlist($query, 'table', $template, $templateName);
4917 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4919 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4921 $total = DB::getValue($query);
4922 if ( $total > $amount )
4924 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4930 echo _OVERVIEW_NOBLOGS;
4932 elseif( $amount != 0 )
4934 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4936 $query = "SELECT ititle, inumber, bshortname"
4938 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4939 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4941 $template['content'] = 'draftlist';
4943 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4944 if ( $amountdrafts == 0 )
4946 echo _OVERVIEW_NODRAFTS;
4953 * AdminActions::checkCondition()
4954 * Checks conditions for if statements
4956 * @param string $field type of <%if%>
4957 * @param string $name property of field
4958 * @param string $value value of property
4959 * @return boolean condition
4961 protected function checkCondition($field, $name='', $value = '')
4963 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
4974 $blog =& $manager->getBlog($blogid);
4978 $blogid = getBlogIDFromCatID($catid);
4980 $blog =& $manager->getBlog($blogid);
4982 elseif ( intRequestVar('catid') )
4984 $catid = intRequestVar('catid');
4985 $blogid = getBlogIDFromCatID($catid);
4987 $blog =& $manager->getBlog($blogid);
4994 $condition = ($blog && $this->ifCategory($name, $value));
4997 $condition = ($blog && ($blog->getSetting($name) == $value));
5000 $condition = $member->isLoggedIn();
5003 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5006 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5009 $condition = $member->isLoggedIn() && $member->isAdmin();
5011 case 'allowloginedit':
5012 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5015 $condition = ($itemidnext != '');
5018 $condition = ($itemidprev != '');
5020 case 'archiveprevexists':
5021 $condition = ($archiveprevexists == true);
5023 case 'archivenextexists':
5024 $condition = ($archivenextexists == true);
5027 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5030 $condition = $this->ifHasPlugin($name, $value);
5033 $condition = (Admin::getAdminAction() == $name);
5035 case 'adminoldaction':
5036 $condition = (Admin::getAdminAction() == $name);
5038 case 'addresschange':
5039 $condition = ($this->ifAddresscange());
5041 case 'bechangepass':
5042 $condition = ($this->beChangePassword());
5044 case 'skincandidates':
5045 $condition = ($this->ifSkincandidates());
5048 $condition = requestVar('nameclashes');
5050 case 'existsnewplugin':
5051 $condition = ($this->existsNewPlugin());
5054 $condition = (boolean) ($member->getAutosave() == $value);
5057 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5064 * Actions::_ifHasPlugin()
5065 * hasplugin,PlugName
5066 * -> checks if plugin exists
5067 * hasplugin,PlugName,OptionName
5068 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5069 * hasplugin,PlugName,OptionName=value
5070 * -> checks if the option OptionName from plugin PlugName is set to value
5072 * @param string $name name of plugin
5073 * @param string $value
5076 private function ifHasPlugin($name, $value)
5080 // (pluginInstalled method won't write a message in the actionlog on failure)
5081 if ( $manager->pluginInstalled("NP_{$name}") )
5083 $plugin =& $manager->getPlugin("NP_{$name}");
5084 if ( $plugin != NULL )
5092 list($name2, $value2) = preg_split('#=#', $value, 2);
5093 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5097 else if ( $plugin->getOption($name2) == $value2 )
5108 * Actions::beChangePassword()
5113 private function beChangePassword()
5115 return intRequestVar('bNeedsPasswordChange');
5119 * Actions::ifSkincandidates()
5120 * Checks if a plugin exists and call its doIf function
5126 private function ifSkincandidates()
5129 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5130 return (count($candidates) > 0);
5134 * Actions::ifPlugin()
5135 * Checks if a plugin exists and call its doIf function
5137 * @param string $name name of plugin
5138 * @param string $key
5139 * @param string $value
5142 private function ifPlugin($name, $key = '', $value = '')
5146 $plugin =& $manager->getPlugin("NP_{$name}");
5152 $params = func_get_args();
5153 array_shift($params);
5155 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5159 * AdminActions::ifCategory()
5160 * Different checks for a category
5162 * @param string $key key for information of category
5163 * @param string $value value for information of category
5166 private function ifCategory($key = '', $value='')
5168 global $blog, $catid;
5170 // when no parameter is defined, just check if a category is selected
5171 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5173 return $blog->isValidCategory($catid);
5176 // check category name
5177 if ( $key == 'catname' )
5179 $value = $blog->getCategoryIdFromName($value);
5180 if ($value == $catid)
5182 return $blog->isValidCategory($catid);
5186 // check category id
5187 if (($key == 'catid') && ($value == $catid))
5189 return $blog->isValidCategory($catid);
5196 * AdminActions::ifOnTeam()
5197 * Checks if a member is on the team of a blog and return his rights
5199 * @param string $blogName name of weblog
5202 private function ifOnTeam($blogName = '')
5204 global $blog, $member, $manager;
5206 // when no blog found
5207 if ( ($blogName == '') && !is_object($blog) )
5212 // explicit blog selection
5213 if ($blogName != '')
5215 $blogid = getBlogIDFromName($blogName);
5218 if (($blogName == '') || !$manager->existsBlogID($blogid))
5221 $blogid = $blog->getID();
5223 return $member->teamRights($blogid);
5227 * AdminActions::ifAdmin()
5228 * Checks if a member is admin of a blog
5230 * @param string $blogName name of weblog
5233 private function ifAdmin($blogName = '')
5235 global $blog, $member, $manager;
5237 // when no blog found
5238 if (($blogName == '') && (!is_object($blog)))
5243 // explicit blog selection
5244 if ($blogName != '')
5246 $blogid = getBlogIDFromName($blogName);
5249 if (($blogName == '') || !$manager->existsBlogID($blogid))
5252 $blogid = $blog->getID();
5255 return $member->isBlogAdmin($blogid);
5259 * AdminActions::ifAddresscange()
5260 * Check e-Mail address is changed
5265 private function ifAddresscange()
5267 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5272 $info = MEMBER::getActivationInfo($key);
5277 $mem = MEMBER::createFromId($info->vmember);
5282 if ( $info->vtype == 'addresschange' )
5290 * AdminActions::templateEditRow()
5293 * @param array $template
5294 * @param string $desc
5295 * @param string $name
5296 * @param string $help
5297 * @param integer $tabindex
5298 * @param boolean $big
5299 * @param array $tmplt
5302 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5306 if ( !array_key_exists($name, $template) )
5308 $template[$name] = '';
5316 $tmplt = skinableTEMPLATE::read($tplt);
5320 'description' => $desc,
5321 'help' => empty($help) ? '' : helpHtml('template' . $help),
5324 'tabindex' => $tabindex,
5325 'rows' => $big ? 10 : 5,
5328 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5330 $base['head'] = "</tr>"
5332 . "<td><%description%><%help%></td>\n"
5333 . "<td id=\"td<%count%>\">\n"
5334 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5338 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5341 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5343 $base['tail'] = "</textarea>\n"
5348 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5351 echo TEMPLATE::fill($base['head'], $data);
5352 echo ENTITY::hsc($template[$name]);
5353 echo TEMPLATE::fill($base['tail'], $data);
5361 * AdminActions::customHelp()
5362 * shows a link to custom help file
5365 * @param string $tplName
5366 * @param string $url
5367 * @param string $iconURL
5368 * @param string $alt
5369 * @param string $title
5373 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5375 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5379 * AdminActions::customHelp()
5380 * shows a link to custom help file
5383 * @param string $tplName
5384 * @param string $url
5385 * @param string $iconURL
5386 * @param string $alt
5387 * @param string $title
5391 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5395 $templates = array();
5399 $templates = Template::read($tplName);
5402 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5404 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5408 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5413 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5416 if ( empty($onclick) )
5418 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5420 elseif ( preg_match('#^onclick#', $onclick) )
5422 $onclick = $onclick;
5426 $onclick = 'onclick="' . $onclick . '"';
5431 'helptarget' => $id,
5432 'onclick' => $onclick,
5433 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5435 return Template::fill($template, $data);
5439 * AdminActions::customHelpHtml()
5442 * @param string $tplName
5443 * @param string $url
5444 * @param string $iconURL
5445 * @param string $alt
5446 * @param string $title
5447 * @param string $onclick
5448 * @return string anchor element with help uri
5450 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5454 $templates = array();
5458 $templates = Template::read($tplName);
5460 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5462 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5466 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5469 if ( empty($iconURL) )
5471 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5474 if ( function_exists('getimagesize') )
5476 $size = getimagesize($iconURL);
5477 $width = 'width="' . $size[0] . '" ';
5478 $height = 'height="' . $size[1] . '" ';
5482 'iconurl' => $iconURL,
5484 'height' => $height,
5485 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5486 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5489 $icon = Template::fill($template, $data);
5490 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5492 return $help . $icon;
5496 * AdminActions::input_yesno
5499 * @param $checkedval
5506 * @param $templateName
5509 public function input_yesno($name,
5520 $templates = array();
5521 if ( $templateName )
5523 $templates = Template::read($templateName);
5526 if ( $name == 'admin' )
5528 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5530 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5531 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5532 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5533 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5537 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5542 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5544 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5548 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5550 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5553 if ( !isset($template) )
5555 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5556 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5557 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5558 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5563 $id = Entity::hsc($name);
5564 $id = str_replace('[', '-', $id);
5565 $id = str_replace(']', '-', $id);
5566 $id1 = $id . Entity::hsc($value1);
5567 $id2 = $id . Entity::hsc($value2);
5569 'name' => Entity::hsc($name),
5570 'yesval' => Entity::hsc($value1),
5571 'noval' => Entity::hsc($value2),
5574 'yesvaltext' => $yesval,
5575 'novaltext' => $noval,
5576 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5577 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5578 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5583 return Template::fill($template, $dat);
5587 echo Template::fill($template, $dat);
5593 * AdminActions::existsNewPlugin()
5594 * Check exists new plugin
5597 * @return boolean exists or not
5599 private function existsNewPlugin()
5601 global $DIR_PLUGINS;
5603 $query = "SELECT * FROM %s;";
5604 $query = sprintf($query, sql_table('plugin'));
5605 $res = DB::getResult($query);
5607 $installed = array();
5608 foreach( $res as $row )
5610 $installed[] = $row['pfile'];
5613 $files = scandir($DIR_PLUGINS);
5615 $candidates = array();
5616 foreach ( $files as $file )
5618 if ( preg_match("#^(NP_.*)\.php$#", $file, $matches) )
5620 if ( !in_array($matches[1], $installed) )
5622 $candidates[] = $matches[1];
5626 $this->newPlugCandidates = $candidates;
5627 return (count($candidates) > 0);
5631 * AdminActions::pagehead()
5632 * Output admin page head
5637 public function parse_pagehead()
5639 global $member, $nucleus, $CONF, $manager;
5641 $extrahead = Admin::getAdminextrahead();
5643 'extrahead' => &$extrahead,
5644 'action' => Admin::getAdminAction()
5646 $manager->notify('AdminPrePageHead', $data);
5648 $content = $this->parser->skin->getContentFromDB('pagehead');
5651 $baseUrl = Entity::hsc($CONF['SkinsURL']);
5655 if ( !array_key_exists('AdminCSS', $CONF) )
5657 DB::execute("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");
5658 $CONF['AdminCSS'] = 'original';
5662 /* HTTP 1.1 application for no caching */
5663 header("Cache-Control: no-cache, must-revalidate");
5664 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5666 $root_element = 'html';
5667 $charset = i18n::get_current_charset();
5668 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5669 $xml_version_info = self::$xml_version_info;
5670 $formal_public_identifier = self::$formal_public_identifier;
5671 $system_identifier = self::$system_identifier;
5672 $xhtml_namespace = self::$xhtml_namespace;
5674 echo "<?xml version=\"{$xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5675 echo "<!DOCTYPE {$root_element} PUBLIC \"{$formal_public_identifier}\" \"{$system_identifier}\">\n";
5676 echo "<{$root_element} xmlns=\"{$xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5678 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5681 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5683 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}admin/defaultadmin/styles/addedit.css\" />\n";
5684 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/edit.js\"></script>\n";
5685 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/admin.js\"></script>\n";
5686 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascripts/compatibility.js\"></script>\n";
5687 echo "{$extrahead}\n";
5690 echo "<div id=\"adminwrapper\">\n";
5691 echo "<div class=\"header\">\n";
5692 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5694 echo "<div id=\"container\">\n";
5695 echo "<div id=\"content\">\n";
5696 echo "<div class=\"loginname\">\n";
5698 if ( !$member->isLoggedIn() )
5700 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5704 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5705 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5708 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5711 if ( !array_key_exists('codename', $nucleus) || empty($nucleus['codename']) )
5713 $codenamestring = '';
5717 $codenamestring = ' "' . $nucleus['codename'].'"';
5720 if ( $member->isLoggedIn() && $member->isAdmin() )
5722 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5723 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5725 $newestVersion = getLatestVersion();
5726 $newestCompare = str_replace('/', '.', $newestVersion);
5727 $currentVersion = str_replace(array('/','v'), array('.',''), $nucleus['version']);
5729 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5732 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5733 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5739 echo "Nucleus CMS {$nucleus['version']}{$codenamestring}";
5746 $this->parser->parse($content);
5753 * AdminActionss::pagefoot()
5754 * Output admin page foot include quickmenu
5759 public function parse_pagefoot()
5761 global $action, $member, $manager;
5764 'action' => Admin::getAdminAction()
5766 $manager->notify('AdminPrePageFoot', $data);
5768 $content = $this->parser->skin->getContentFromDB('pagefoot');
5771 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5773 echo '<h2>' . _LOGOUT . "</h2>\n";
5775 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5776 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5780 echo "<div class=\"foot\">\n";
5781 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5783 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5786 echo "<div id=\"quickmenu\">\n";
5788 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5791 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5794 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5795 echo "<form method=\"get\" action=\"index.php\">\n";
5797 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5799 $showAll = requestVar('showall');
5801 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5803 // Super-Admins have access to all blogs! (no add item support though)
5804 $query = "SELECT bnumber as value, bname as text FROM %s ORDER BY bname;";
5805 $query = sprintf($query, sql_table('blog'));
5809 $query = "SELECT bnumber as value, bname as text FROM %s, %s WHERE tblog=bnumber and tmember=%d ORDER BY bname;";
5810 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5812 $template['name'] = 'blogid';
5813 $template['tabindex'] = 15000;
5814 $template['extra'] = _QMENU_ADD_SELECT;
5815 $template['selected'] = -1;
5816 $template['shorten'] = 10;
5817 $template['shortenel'] = '';
5818 $template['javascript'] = 'onchange="return form.submit()"';
5819 showlist($query, 'select', $template);
5824 echo "<h2>{$member->getDisplayName()}</h2>\n";
5826 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5827 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5828 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5831 if ( $member->isAdmin() )
5833 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5835 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5836 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5837 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5838 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5839 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5840 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5841 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5844 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5846 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5847 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5848 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5852 $data = array('options' => array());
5854 $manager->notify('QuickMenu', $data);
5856 if ( count($data['options']) > 0 )
5858 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5860 foreach ( $data['options'] as $option )
5862 echo '<li><a href="' . Entity::hsc($option['url']) . '" title="' . Entity::hsc($option['tooltip']) . '">' . Entity::hsc($option['title']) . "</a></li>\n";
5867 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5870 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5874 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5877 echo "<!-- quickmenu -->\n";
5880 echo "<!-- content -->\n";
5883 echo "<!-- container -->\n";
5886 echo "<!-- adminwrapper -->\n";
5894 $this->parser->skin->parse('pagefoot');
5901 * AdminActions::selectBlog()
5902 * Inserts a HTML select element with choices for all blogs to which the user has access
5903 * mode = 'blog' => shows blognames and values are blogids
5904 * mode = 'category' => show category names and values are catids
5906 * @param string $name
5907 * @param string $mode
5908 * @param integer $selected
5909 * @param integer $tabindex
5910 * @param integer $showNewCat
5911 * @param integer $iForcedBlogInclude ID for weblog always included
5912 * @param $iForcedBlogInclude
5913 * ID of a blog that always needs to be included, without checking if the
5914 * member is on the blog team (-1 = none)
5917 private function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
5919 global $member, $CONF;
5921 // 0. get IDs of blogs to which member can post items (+ forced blog)
5922 $aBlogIds = array();
5923 if ( $iForcedBlogInclude != -1 )
5925 $aBlogIds[] = intval($iForcedBlogInclude);
5928 if ( $member->isAdmin() && array_key_exists('ShowAllBlogs', $CONF) && $CONF['ShowAllBlogs'] )
5930 $query = "SELECT bnumber FROM %s ORDER BY bname;";
5931 $query = sprintf($query, sql_table('blog'));
5935 $query = "SELECT bnumber FROM %s, %s WHERE tblog=bnumber AND tmember=%d;";
5936 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5939 $rblogids = DB::getResult($query);
5940 foreach ( $rblogids as $row )
5942 if ( $row['bnumber'] != $iForcedBlogInclude )
5944 $aBlogIds[] = intval($row['bnumber']);
5948 if ( count($aBlogIds) == 0 )
5953 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
5955 // 1. select blogs (we'll create optiongroups)
5956 // (only select those blogs that have the user on the team)
5957 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
5958 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
5959 $blogs = DB::getResult($queryBlogs);
5961 if ( $mode == 'category' )
5963 if ( $blogs->rowCount() > 1 )
5967 foreach ( $blogs as $rBlog )
5969 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
5971 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
5974 // show selection to create new category when allowed/wanted
5977 // check if allowed to do so
5978 if ( $member->blogAdminRights($rBlog['bnumber']) )
5980 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
5984 // 2. for each category in that blog
5985 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
5986 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
5987 $categories = DB::getResult($catQuery);
5988 foreach ( $categories as $rCat )
5990 if ( $rCat['catid'] == $selected )
5992 $selectText = ' selected="selected" ';
5998 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
6001 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
6009 foreach ( $blogs as $rBlog )
6011 echo '<option value="' . $rBlog['bnumber'] . '"';
6012 if ( $rBlog['bnumber'] == $selected )
6014 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
6018 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";