2 if ( !class_exists('BaseActions') )
4 include $DIR_LIBS . 'BaseActions.php';
6 class AdminActions extends BaseActions
8 // reference to the skin object for which a part is being parsed
11 // an instance of parser class
17 /* NOTE: list of whole available action names for tags
26 'adminskineditallowedlist',
29 'adminskinselectoptions',
30 'adminspecialskinlist',
31 'admintemplateoverview',
32 'allowedadminskinactions',
55 'configsettingsyesno',
58 'defaultadminskintypes',
68 'editadmintemplateinfo',
74 'editplugoptionslist',
90 'insertpluginoptions',
95 'languageselectoptions',
96 'listplugplugoptionrow',
113 'selectlocaladminskinfiles',
114 'selectlocalskinfiles',
115 'skineditallowedlist',
132 * AdminActions::$default_actions
133 * list of whole action names with which this class can deal
135 static private $default_actions = array(
146 * AdminActions::$skin_type_friendly_names
147 * friendly name for wrapped page types
149 static private $default_skin_types = array(
150 'actionlog' => _ADM_SKPRT_ACTIONLOG,
151 'activate' => _ADM_SKPRT_ACTIVATE,
152 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
153 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
154 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
155 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
156 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
157 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
158 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
159 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
160 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
161 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
162 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
163 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
164 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
165 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
166 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
167 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
168 'banlist' => _ADM_SKPRT_BANLIST,
169 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
170 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
171 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
172 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
173 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
174 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
175 'batchitem' => _ADM_SKPRT_BATCHITEM,
176 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
177 'batchmove' => _ADM_SKPRT_BATCHMOVE,
178 'batchteam' => _ADM_SKPRT_BATCHTEAM,
179 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
180 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX,
181 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
182 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
183 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
184 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
185 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
186 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
187 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
188 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
189 'createitem' => _ADM_SKPRT_CREATEITEM,
190 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
191 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
192 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
193 'insertpluginoptions' => _ADM_SKPRT_INSERTPLUGINO,
194 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
195 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
196 'itemedit' => _ADM_SKPRT_ITEMEDIT,
197 'itemlist' => _ADM_SKPRT_ITEMLIST,
198 'itemmove' => _ADM_SKPRT_ITEMMOVE,
199 'login' => FALSE, //missing
200 'manage' => _ADM_SKPRT_MANAGE,
201 'manageteam' => _ADM_SKPRT_MANAGETEAM,
202 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
203 'memberedit' => FALSE, //missing
204 'overview' => _ADM_SKPRT_OVERVIEW,
205 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
206 'pagehead' => _ADM_SKPRT_PAGEHEAD,
207 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
208 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
209 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
210 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
211 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
212 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
213 'skindelete' => _ADM_SKPRT_SKINDELETE,
214 'skinedit' => _ADM_SKPRT_SKINEDIT,
215 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
216 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
217 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
218 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
219 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
220 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
221 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
222 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
223 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
224 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
225 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
226 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
230 * AdminActions::getDefinedActions()
233 * @param string $type page type
234 * @return array allowed actions for the page type
236 static public function getDefinedActions($type = '')
238 $extra_actions = array();
243 $extra_actions = array(
248 $extra_actions = array(
253 case 'activatesetpwd':
254 $extra_actions = array(
258 $extra_actions = array(
264 case 'adminerrorpage':
265 $extra_actions = array(
268 case 'adminskindelete':
269 $extra_actions = array(
273 case 'adminskinedit':
274 $extra_actions = array(
276 'defaultadminskintypes',
277 'adminspecialskinlist',
280 case 'adminskinedittype':
281 $extra_actions = array(
284 'allowedadminskinactions',
285 'adminskineditallowedlist',
288 case 'adminskiniedoimport':
289 $extra_actions = array(
293 case 'adminskinieimport':
294 $extra_actions = array(
298 case 'adminskinieoverview':
299 $extra_actions = array(
300 'selectlocaladminskinfiles',
304 case 'adminskinoverview':
305 $extra_actions = array(
309 case 'adminskinremovetype':
310 $extra_actions = array(
314 case 'admintemplateedit':
315 $extra_actions = array(
316 'editadmintemplateinfo',
319 case 'admintemplateoverview':
320 $extra_actions = array(
321 'admintemplateoverview',
324 case 'backupoverview':
325 $extra_actions = array(
328 case 'backuprestore':
329 $extra_actions = array(
333 $extra_actions = array(
339 case 'banlistdelete':
340 $extra_actions = array(
345 case 'banlistdeleteconfirm':
346 $extra_actions = array(
347 'banlistdeletedlist',
352 $extra_actions = array(
358 case 'batchcategory':
359 $extra_actions = array(
365 $extra_actions = array(
371 $extra_actions = array(
377 $extra_actions = array(
383 $extra_actions = array(
389 $extra_actions = array(
398 $extra_actions = array(
407 $extra_actions = array(
413 case 'blogcommentlist':
414 $extra_actions = array(
420 case 'blogselectbox':
421 $extra_actions = array(
426 $extra_actions = array(
441 $extra_actions = array(
445 case 'browseowncomments':
446 $extra_actions = array(
450 case 'browseownitems':
451 $extra_actions = array(
455 case 'categorydelete':
456 $extra_actions = array(
462 $extra_actions = array(
468 case 'commentdelete':
469 $extra_actions = array(
474 $extra_actions = array(
479 $extra_actions = array(
492 $extra_actions = array(
498 $extra_actions = array(
503 case 'editmembersettings':
504 $extra_actions = array(
506 'languageselectoptions',
507 'adminskinselectoptions',
511 case 'insertpluginoptions':
512 $extra_actions = array(
513 'insertpluginoptions',
516 case 'itemcommentlist':
517 $extra_actions = array(
523 $extra_actions = array(
530 $extra_actions = array(
544 $extra_actions = array(
551 $extra_actions = array(
557 $extra_actions = array(
561 $extra_actions = array(
570 $extra_actions = array(
575 $extra_actions = array(
580 $extra_actions = array(
588 $extra_actions = array(
601 $extra_actions = array(
606 $extra_actions = array(
612 $extra_actions = array(
617 case 'pluginoptions':
618 $extra_actions = array(
620 'editplugoptionslist',
624 $extra_actions = array(
627 'configsettingsedit',
628 'languageselectoptions',
629 'configsettingsyesno',
637 $extra_actions = array(
642 $extra_actions = array(
647 $extra_actions = array(
653 $extra_actions = array(
656 'allowedskinactions',
657 'skineditallowedlist',
658 'skineditallowedlist',
661 case 'skiniedoimport':
662 $extra_actions = array(
667 $extra_actions = array(
671 case 'skinieoverview':
672 $extra_actions = array(
673 'selectlocalskinfiles',
678 $extra_actions = array(
682 case 'skinremovetype':
683 $extra_actions = array(
687 case 'systemoverview':
688 $extra_actions = array(
693 $extra_actions = array(
699 case 'templatedelete':
700 $extra_actions = array(
705 $extra_actions = array(
709 case 'templateoverview':
710 $extra_actions = array(
714 case 'usermanagement':
715 $extra_actions = array(
721 $extra_actions = array(
731 'selectlocaladminskinfiles',
739 $defined_actions = array_merge(self::$default_actions, $extra_actions);
741 return array_merge($defined_actions, parent::getDefinedActions());
745 * AdminActions::getSkinTypeFriendlyNames()
749 * @return array list of friendly names for page actions
751 static public function getDefaultSkinTypes()
753 return self::$default_skin_types;
757 * AdminActions::__construct()
758 * Constructor for a new Actions object
760 * @param string $type
763 public function __construct($type)
765 // call constructor of superclass first
766 parent::__construct();
767 $this->skintype = $type;
772 * AdminActions::setSkin()
774 * @param object $skin an instance of Skin class
777 public function setSkin(&$skin)
779 $this->skin =& $skin;
784 * AdminActions::setParser()
787 * @param object $parser an instance of Parser class
790 public function setParser(&$parser)
792 $this->parser =& $parser;
797 * AdminActions::parse_actionloglist()
798 * Parse skinvar actionloglist
800 * @param string $templateName name of template to use
803 public function parse_actionloglist($templateName = '')
805 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
806 $query = sprintf($query, sql_table('actionlog'));
808 $template['content'] = 'actionlist';
809 $amount = showlist($query, 'table', $template, $templateName);
815 * AdminActions::parse_activationmessage()
816 * Parse skinvar activationmessage
818 * @param string $type type of message
819 * @param string $templateName name of template to use
822 public function parse_activationmessage($type, $templateName = '')
824 global $CONF, $manager;
828 if ( !empty($templateName))
830 $template = Template::read($templateName);
833 $key = postVar('ackey');
836 Admin::error(_ERROR_ACTIVATE);
839 $info = MEMBER::getActivationInfo($key);
842 Admin::error(_ERROR_ACTIVATE);
845 $mem = MEMBER::createFromId($info->vmember);
848 Admin::error(_ERROR_ACTIVATE);
850 switch ( $info->vtype )
853 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
855 $title = $template['ACTIVATE_FORGOT_TITLE'];
859 $title = _ACTIVATE_FORGOT_TITLE;
861 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
863 $text = $template['ACTIVATE_FORGOT_TEXT'];
867 $text = _ACTIVATE_FORGOT_TEXT;
871 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
873 $title = $template['ACTIVATE_REGISTER_TITLE'];
877 $title = _ACTIVATE_REGISTER_TITLE;
879 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
881 $text = $template['ACTIVATE_REGISTER_TEXT'];
885 $text = _ACTIVATE_REGISTER_TEXT;
888 case 'addresschange':
889 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
891 $title = $template['ACTIVATE_CHANGE_TITLE'];
895 $title = _ACTIVATE_CHANGE_TITLE;
897 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
899 $text = $template['ACTIVATE_CHANGE_TEXT'];
903 $text = _ACTIVATE_CHANGE_TEXT;
908 'memberName' => Entity::hsc($mem->getDisplayName()),
909 'realName' => Entity::hsc($mem->getRealName()),
914 echo TEMPLATE::fill($title, $aVars);
917 echo TEMPLATE::fill($text, $aVars);
920 echo Entity::hsc($key);
927 * AdminActions::parse_addtickettourl()
928 * Parse skinvar addtickettourl
930 * @param string $url URI for ticket
933 public function parse_addtickettourl($url)
936 $url = $manager->addTicketToUrl($url);
937 echo Entity::hsc($url);
942 * AdminActions::parse_adminbanlist()
943 * Parse skinvar adminbanlist
945 * @param string $templateName name of template to use
948 public function parse_adminbanlist($templateName = '')
950 $blogid = intRequestVar('blogid');
952 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
953 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
955 $template['content'] = 'banlist';
957 $amount = Showlist($query, 'table', $template, $templateName);
967 * AdminActions::parse_adminbatchaction()
968 * Parse skinvar adminbatchaction
973 public function parse_adminbatchaction()
975 echo Entity::hsc(requestVar('batchaction'));
980 * AdminActions::parse_adminbatchlist()
981 * Parse skinvar adminbatchlist
983 * @param string $templateName name of template to use
986 public function parse_adminbatchlist($templateName = '')
989 $templates = array();
990 if ( !empty($templateName) )
992 $templates = Template::read($templateName);
994 if ( isset($templates['ADMIN_BATCHLIST']) || !empty($templates['ADMIN_BATCHLIST']) )
996 $template = $templates['ADMIN_BATCHLIST'];
1000 $template = '<li><%text(_BATCH_EXECUTING)%>'
1001 . '<b><%adminbatchaction%></b>'
1002 . '<%batchlisttype%>'
1003 . '<b><%batchid%></b>...'
1004 . '<b><%batchlistmsg%></b>'
1008 $selected = requestIntArray('batch');
1009 $action = requestVar('batchaction');
1011 switch ( $this->skintype )
1014 $batchlisttype = _BATCH_ONITEM;
1015 $deleteaction = 'deleteOneItem';
1016 $moveaction = 'moveOneItem';
1017 $destid = intRequestVar('destcatid');
1019 case 'batchcomment':
1020 $batchlisttype = _BATCH_ONCOMMENT;
1021 $deleteaction = 'deleteOneComment';
1024 $batchlisttype = _BATCH_ONMEMBER;
1025 $deleteaction = 'deleteOneMember';
1026 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1027 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1028 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1029 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1032 $blogid = intRequestVar('blogid');
1033 $batchlisttype = _BATCH_ONTEAM;
1034 $deleteaction = 'deleteOneTeamMember';
1035 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1036 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1037 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1038 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1040 case 'batchcategory':
1041 $batchlisttype = _BATCH_ONCATEGORY;
1042 $deleteaction = 'deleteOneCategory';
1043 $moveaction = 'moveOneCategory';
1044 $destid = intRequestVar('destblogid');
1048 // walk over all selectedids and perform action
1049 foreach ( $selected as $selectedid )
1052 $selectedid = intval($selectedid);
1056 if ( $this->skintype != 'batchteam' )
1058 $error = Admin::$deleteaction($selectedid);
1062 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1066 $error = Admin::moveaction($selectedid, $destid);
1070 sql_query('UPDATE ' . $setadminsql . $selectedid);
1074 // there should always remain at least one super-admin
1075 $r = sql_query($unsetchksql);
1076 if ( sql_num_rows($r) < 2 )
1078 $error = $unseterrmsg;
1082 sql_query('UPDATE ' . $unsetupsql . $selectedid);
1086 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1089 'batchid' => $selectedid,
1090 'batchlisttype' => Entity::hsc($batchlisttype),
1091 'adminbatchaction' => Entity::hsc($action),
1092 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1094 $handler = new Actions('template', $template, new ADMIN);
1095 $parser = new Parser($handler);
1098 $parser->parse($template);
1099 $template = ob_get_contents();
1102 echo TEMPLATE::fill($template, $data);
1108 * AdminActions::parse_adminbloglink()
1109 * Parse skinvar adminbloglink
1111 * @param string $templateName name of template to use
1114 public function parse_adminbloglink($templateName = '')
1117 $blogid = intRequestVar('blogid');
1118 $blog =& $manager->getBlog($blogid);
1119 $templates = array();
1121 if ( !empty($templateName) )
1123 $templates = Template::read($templateName);
1126 if ( isset($templates['ADMIN_BLOGLINK']) || !empty($templates['ADMIN_BLOGLINK']) )
1128 $template = $templates['ADMIN_BLOGLINK'];
1132 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1136 'url' => Entity::hsc($blog->getURL()),
1137 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1138 'blogname' => Entity::hsc($blog->getName())
1141 echo TEMPLATE::fill($template, $data);
1146 * AdminActions::parse_adminerrormesg()
1147 * Parse skinvar adminerrormesg
1152 public function parse_adminerrormesg()
1157 if ( requestVar('errormessage') )
1159 $message = requestVar('errormessage');
1161 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1163 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1165 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1167 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1169 echo Entity::hsc($message);
1174 * AdminActions::parse_adminskineditallowedlist()
1175 * Parse skinvar adminskineditallowedlist
1177 * @param string $type template/blog
1178 * @param string $templateName name of template to use
1181 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1185 /* TODO: blog seems not to be used */
1187 $query = "SELECT bshortname, bname FROM %s";
1188 $query = sprintf($query, sql_table('blog'));
1190 'content' => 'shortblognames'
1194 $query = "SELECT tdname as name, tddesc as description FROM %s;";
1195 $query = sprintf($query, sql_table('admintemplate_desc'));
1197 'content' => 'shortnames'
1201 Showlist($query, 'table', $show, $templateName);
1206 * AdminActions::parse_adminskinielist()
1207 * Parse skinvar adminskinielist
1209 * @param string $type skin/template
1210 * @param string $templateName name of template to use
1213 public function parse_adminskinielist($type, $templateName = '')
1215 $templates = array();
1216 if ( $templateName )
1218 $templates = Template::read($templateName);
1220 if ( isset($templates['SKINIE_EXPORT_LIST']) && !empty($templates['SKINIE_EXPORT_LIST']) )
1222 $template = $templates['SKINIE_EXPORT_LIST'];
1226 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
1227 . "<td><%expdesc%></td>\n"
1233 $query = "SELECT * FROM %s WHERE sdincmode = 'admin';";
1234 $query = sprintf($query, sql_table('skin_desc'));
1235 $res = sql_query($query);
1237 while ( $skinObj = sql_fetch_object($res) )
1240 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
1241 'expid' => 'skinexp' . $skinObj->sdnumber,
1242 'expname' => Entity::hsc($skinObj->sdname),
1243 'expdesc' => Entity::hsc($skinObj->sddesc),
1245 echo TEMPLATE::fill($template, $data);
1249 $query = "SELECT * FROM %s;";
1250 $query = sprintf($query, sql_table('admintemplate_desc'));
1251 $res = sql_query($query);
1252 while ( $templateObj = sql_fetch_object($res) )
1255 'typeid' => 'template[' . $templateObj->tdnumber . ']',
1256 'expid' => 'templateexp' . $templateObj->tdnumber,
1257 'expname' => Entity::hsc($templateObj->tdname),
1258 'expdesc' => Entity::hsc($templateObj->tddesc),
1260 echo TEMPLATE::fill($template, $data);
1268 * AdminActions::parse_adminskinoverview()
1269 * Parse skinvar adminskinoverview
1271 * @param string $templateName name of template to use
1274 public function parse_adminskinoverview($templateName = '')
1276 $query = "SELECT * FROM %s WHERE sdincmode = 'admin' ORDER BY sdname;";
1277 $query = sprintf($query, sql_table('skin_desc'));
1279 $template['content'] = 'adminskinlist';
1280 $template['tabindex'] = 10;
1281 $template['friendly_names'] = Skin::getFriendlyNames('AdminActions');
1282 Showlist($query, 'table', $template, $templateName);
1287 * AdminActions::parse_adminskinselectoptions()
1288 * Parse skinvar adminskinselectoptions
1293 public function parse_adminskinselectoptions()
1296 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdincmode = 'admin';";
1297 $query = sprintf($query, sql_table('skin_desc'));
1299 $template['name'] = 'adminskin';
1300 $template['selected'] = $CONF['DefaultAdminSkin'];
1301 $template['tabindex'] = 110;
1302 Showlist($query, 'select', $template, '');
1307 * AdminActions::parse_adminspecialskinlist()
1308 * Parse skinvar adminspecialskinlist
1310 * @param string $templateName name of template to use
1312 public function parse_adminspecialskinlist($templateName = '')
1314 $templates = array();
1315 if ( $templateName )
1317 $templates = Template::read($templateName);
1320 $nType = Skin::getFriendlyNames('AdminActions');
1321 $skinid = intRequestVar('skinid');
1323 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1324 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1326 $res = sql_query($query);
1327 if ( $res && sql_num_rows($res) > 0 )
1330 if ( array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1332 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1336 $template['head'] = "<ul>\n";
1338 echo TEMPLATE::fill($template['head'], $data);
1340 if ( array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1342 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1346 $template['body'] = '<li>'
1347 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1350 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1356 while ( $row = sql_fetch_assoc($res) )
1359 'tabindex' => $tabstart++,
1360 'skinid' => $skinid,
1361 'skintype' => Entity::hsc(strtolower($row['stype']))
1363 echo TEMPLATE::fill($template['body'], $data);
1367 if ( array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1369 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1373 $template['foot'] = "</ul>\n";
1375 echo TEMPLATE::fill($template['foot'], $data);
1381 * AdminActions::parse_admintemplateoverview()
1382 * Parse skinvar admintemplateoverview
1384 * @param string $templateName name of template to use
1387 public function parse_admintemplateoverview($templateName = '')
1389 $query = "SELECT * FROM %s ORDER BY tdname;";
1390 $query = sprintf($query, sql_table('admintemplate_desc'));
1392 $template['content'] = 'admintemplatelist';
1393 $template['tabindex'] = 10;
1395 Showlist($query, 'table', $template, $templateName);
1400 * AdminActions::parse_allowedadminskinactions()
1401 * Parse skinvar allowedadminskinactions
1406 public function parse_allowedadminskinactions()
1408 global $DIR_ADMINSKINS;
1409 $skinType = strtolower(trim(requestVar('type')));
1410 $actions = Skin::getAllowedActionsForType($skinType);
1413 while ( $current = array_shift($actions) )
1415 // skip deprecated vars
1416 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1421 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1422 // echo "<a href=\"{$DIR_ADMINSKINS}documentation/help.html#{$current}\" onclick=\"if (event && event.preventDefault) event.preventDefault(); return help(this.href);\">{$current}</a>\n";
1424 if ( count($actions) != 0 )
1433 * AdminActions::parse_allowedskinactions()
1434 * Parse skinvar allowedskinactions
1439 public function parse_allowedskinactions()
1441 $skinType = strtolower(trim(requestVar('type')));
1442 $actions = SKIN::getAllowedActionsForType($skinType);
1445 while ( $current = array_shift($actions) )
1447 // skip deprecated vars
1448 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1453 /* TODO: alternative function should be used or not? */
1454 echo helplink("skinvar-{$current}") . "$current</a>\n";
1456 if ( count($actions) != 0 )
1465 * AdminActions::parse_banlistdeletedlist()
1466 * Parse skinvar banlistdeletedlist
1468 * @param string $templateName name of template to use
1471 public function parse_banlistdeletedlist($templateName = '')
1474 $templates = array();
1476 if ( $templateName )
1478 $templates = Template::read($templateName);
1480 if ( isset($templates['BANLIST_DELETED_LIST']) && !empty($templates['BANLIST_DELETED_LIST']) )
1482 $template = $templates['BANLIST_DELETED_LIST'];
1486 $template = "<li><%blogname%></li>\n";
1488 $deleted = requestArray('delblogs');
1489 foreach ( $deleted as $delblog )
1491 $blog =& $manager->getBlog($delblog);
1493 Entity::hsc($blog->getName())
1495 TEMPLATE::fill($template, $data);
1501 * AdminActions::parse_batchdeletelist()
1502 * Parse skinvar batchdeletelist
1507 public function parse_batchdeletelist()
1509 $selected = requestIntArray('batch');
1512 foreach ( $selected as $select )
1514 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1516 // add hidden vars for team & comment
1517 if ( requestVar('action') == 'batchteam' )
1519 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1521 if ( requestVar('action') == 'batchcomment' )
1523 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1529 * AdminActions::parse_batchdeletetype()
1530 * Parse skinvar batchdeletetype
1535 public function parse_batchdeletetype()
1537 echo Entity::hsc(requestVar('action'));
1542 * AdminActions::parse_batchmovebtn()
1543 * Parse skinvar batchmovebtn
1548 public function parse_batchmovebtn()
1550 $actionType = requestVar('action');
1551 switch ( $actionType )
1556 case 'batchcategory':
1564 * AdminActions::parse_batchmovelist()
1565 * Parse skinvar batchmovelist
1570 public function parse_batchmovelist()
1572 $selected = requestIntArray('batch');
1573 foreach ( $selected as $select )
1575 echo '<input type="hidden" name="batch[' . ($select++) . ']" value="' . intval($select) . "\" />\n";
1581 * AdminActions::parse_batchmovetitle()
1582 * Parse skinvar batchmovetitle
1587 public function parse_batchmovetitle()
1589 $actionType = requestVar('action');
1590 switch ( $actionType )
1595 case 'batchcategory':
1596 echo _MOVECAT_TITLE;
1603 * AdminActions::parse_batchmovetype()
1604 * Parse skinvar batchmovetype
1609 public function parse_batchmovetype()
1611 echo Entity::hsc(requestVar('action'));
1616 * AdminActions::parse_blogcatlist()
1617 * Parse skinvar blogcatlist
1622 public function parse_blogcatlist()
1625 $blogid = intRequestVar('blogid');
1626 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1627 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1629 $template['content'] = 'categorylist';
1630 $template['tabindex'] = 200;
1632 $batch = new Batch('member');
1633 $batch->showlist($query, 'table', $template);
1638 * AdminActions::parse_blognotifysetting()
1639 * Parse skinvar blognotifysetting
1644 public function parse_blognotifysetting($type)
1647 $blogid = intRequestVar('blogid');
1648 $blog = $manager->getBlog($blogid);
1653 if ( !$blog->notifyOnComment() )
1659 if ( !$blog->notifyOnVote() )
1665 if ( !$blog->notifyOnNewItem() )
1671 echo ' checked="checked"';
1676 * AdminActions::parse_blogselectbox()
1677 * Parse skinvar blogselectbox
1682 public function parse_blogselectbox()
1686 $selectData = requestVar('selectData');
1687 $mode = $selectData['mode'];
1688 $name = Entity::hsc($selectData['name']);
1689 $tabindex = Entity::hsc($selectData['tabindex']);
1690 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1691 $showNewCat = intval($selectData['showNewCat']);
1692 $selected = intval($selectData['selected']);
1694 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1696 // 1. select blogs (we'll create optiongroups)
1697 // (only select those blogs that have the user on the team)
1698 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1699 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1700 $blogs = sql_query($queryBlogs);
1702 if ( $mode == 'category' )
1704 if ( sql_num_rows($blogs) > 1 )
1708 while ( $oBlog = sql_fetch_object($blogs) )
1710 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1712 echo '<optgroup label="' . Entity::hsc($oBlog->bname) . "\>\n";
1715 // show selection to create new category when allowed/wanted
1718 // check if allowed to do so
1719 if ( $member->blogAdminRights($oBlog->bnumber) )
1721 echo '<option value="newcat-' . $oBlog->bnumber . '">' . _ADD_NEWCAT . "</option>\n";
1725 // 2. for each category in that blog
1726 $catQueriy = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1727 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
1728 $categories = sql_query(sprintf($catQueriy));
1729 while ( $oCat = sql_fetch_object($categories) )
1731 if ( $oCat->catid == $selected )
1733 $selectText = ' selected="selected" ';
1739 echo '<option value="' . $oCat->catid . '" ' . $selectText . '>' . Entity::hsc($oCat->cname) . "</option>\n";
1742 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1751 while ( $oBlog = sql_fetch_object($blogs) )
1753 echo '<option value="' . $oBlog->bnumber . '"';
1754 if ( $oBlog->bnumber == $selected )
1756 echo '<option value="' . $oBlog->bnumber . '" selected="selected">' . Entity::hsc($oBlog->bname) . "</option>\n";
1760 echo '<option value="' . $oBlog->bnumber . '">' . Entity::hsc($oBlog->bname) . "</option>\n";
1769 * AdminActions::parse_blogsetting()
1770 * Parse skinvar blogsetting
1772 * @param string $which name of weblog setting
1775 public function parse_blogsetting($which)
1777 echo $this->parse_getblogsetting($which);
1782 * AdminActions::parse_blogsettingyesno()
1783 * Parse skinvar blogsettingyesno
1785 * @param string $type type of weblog setting
1786 * @param string $templateName name of template to use
1789 public function parse_blogsettingyesno($type, $templateName = '')
1793 $blogid = intRequestVar('blogid');
1794 $blog = $manager->getBlog($blogid);
1798 case 'convertbreaks':
1799 $checkedval = $blog->convertBreaks();
1802 case 'allowpastposting':
1803 $checkedval = $blog->allowPastPosting();
1807 $checkedval = $blog->commentsEnabled();
1811 $checkedval = $blog->isPublic();
1815 $checkedval = $blog->emailRequired();
1819 $checkedval = $blog->getSearchable();
1823 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1828 * AdminActions::parse_blogteamlist()
1829 * Parse skinvar blogteamlist
1831 * @param string $templateName name of template to use
1834 public function parse_blogteamlist($templateName = '')
1837 $blogid = intRequestVar('blogid');
1838 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1840 . "WHERE tmember=mnumber AND tblog= %d";
1841 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1843 $template['content'] = 'teamlist';
1844 $template['tabindex'] = 10;
1846 $batch = new Batch('team');
1847 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1852 * AdminActions::parse_blogteammembers()
1853 * Parse skinvar blogteammembers
1858 public function parse_blogteammembers()
1860 $blogid = intRequestVar('blogid');
1861 $query = "SELECT mname, mrealname "
1863 . "WHERE mnumber=tmember AND tblog=%d;";
1864 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1865 $res = sql_query($query);
1866 $memberNames = array();
1867 while ($o = sql_fetch_object($res)) {
1868 $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
1870 echo implode(',', $memberNames);
1874 * AdminActions::parse_blogtime()
1875 * Parse skinvar blogtime
1877 * @param string $type type of time
1878 * @param string $format format for time expression
1879 * @param integer $offset offset of time
1882 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1886 if ( $type != 'blogtime' )
1888 /* return server time */
1889 $timestamp = time() + $offset;
1893 $bid = intRequestVar('blogid');
1894 $b = $manager->getBlog($bid);
1895 $timestamp = $b->getCorrectTime() + $offset;
1898 echo i18n::formatted_datetime($format, $timestamp);
1903 * AdminActions::parse_bookmarkletadmin()
1904 * Parse skinvar bookmarkletadmin
1909 public function parse_bookmarkletadmin()
1913 $blogid = intRequestVar('blogid');
1915 echo Entity::hsc(getBookmarklet($blogid));
1920 * AdminActions::parse_category()
1921 * Parse skinvar category
1923 * @param string $type name of setting for category
1926 public function parse_category($type = 'name')
1928 echo $this->parse_getcategory($type);
1933 * AdminActions::parse_categorysetting()
1934 * Parse skinvar categorysetting
1936 * @param string $type type in category setting
1939 public function parse_categorysetting($type)
1941 $catid = intRequestVar('catid');
1942 if ( $type == 'id' )
1947 $blogid = intRequestVar('blogid');
1948 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1949 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1950 $res = sql_query($query);
1951 $obj = sql_fetch_object($res);
1953 if ( $type != desc )
1955 echo Entity::hsc($obj->cdesc);
1959 echo Entity::hsc($obj->cname);
1966 * AdminActions::parse_codename()
1967 * Parse templatevar codename
1972 * TODO: is this need???
1974 public function parse_codename()
1977 echo $nucleus['codename'];
1982 * AdminActions::parse_commentnavlist()
1983 * Parse skinvar commentnavlist
1988 public function parse_commentnavlist()
1990 global $CONF, $manager, $member;
1993 if ( postVar('start') )
1995 $start = intPostVar('start');
2002 // amount of items to show
2003 if ( postVar('amount') )
2005 $amount = intPostVar('amount');
2009 $amount = (integer) $CONF['DefaultListSize'];
2015 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2017 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2019 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2021 if ( $this->skintype == 'itemcommentlist' )
2023 $itemid = intRequestVar('itemid');
2024 $query .= " citem={$itemid}";
2025 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2027 $nonComments = _NOCOMMENTS;
2029 elseif ( $this->skintype == 'browseowncomments' )
2032 $query .= ' cmember=' . $member->getID();
2033 $template['canAddBan'] = 0;
2035 $nonComments = _NOCOMMENTS_YOUR;
2037 elseif ( $this->skintype == 'blogcommentlist' )
2040 $query .= ' cblog=' . intRequestVar('blogid');
2041 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2042 $bid = intRequestVar('blogid');
2043 $nonComments = _NOCOMMENTS_BLOG;
2046 $search = postVar('search');
2047 if ( !empty($search) )
2049 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
2052 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2054 $template['content'] = 'commentlist';
2056 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2057 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2062 * AdminActions::parse_configsettingsedit()
2063 * Parse skinvar configsettingsedit
2065 * @param string $type type of global configuration
2068 public function parse_configsettingsedit($type)
2073 case 'DefaultListSize':
2074 if ( !array_key_exists('DefaultListSize', $CONF) )
2076 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2077 $query = sprintf($query, sql_table('config'));
2079 $CONF['DefaultListSize'] = 10;
2081 elseif ( intval($CONF['DefaultListSize']) < 1 )
2083 $CONF['DefaultListSize'] = 10;
2085 echo intval($CONF['DefaultListSize']);
2087 case 'SessionCookie':
2088 $value = $CONF['SessionCookie'];
2089 $txt1 = _SETTINGS_COOKIESESSION;
2090 $txt2 = _SETTINGS_COOKIEMONTH;
2091 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2094 $value = $CONF['URLMode'];
2095 $txt1 = _SETTINGS_URLMODE_NORMAL;
2096 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2097 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2100 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2102 echo Entity::hsc($CONF[$type]);
2110 * AdminActions::parse_configsettingsyesno()
2111 * Parse skinvar configsettingsyesno
2113 * @param string $type type of global setting
2114 * @param integer $tabindex tabindex attribute of input element
2117 public function parse_configsettingsyesno($type, $tabindex)
2120 if ( array_key_exists($type, $CONF) )
2122 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2128 * AdminActions::parse_customhelplink()
2129 * Parse skinvar customhelplink
2131 * @param string $topic name of topic
2132 * @param string $tplName name of template
2133 * @param string $url string as URI
2134 * @param string $iconURL string as URI for icon
2135 * @param string $alt alternative text for image element
2136 * @param string $title title for anchor element
2139 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2141 $this->customHelp($topic, $url, $iconURL);
2146 * AdminActions::parse_date()
2147 * Parse skinvar date
2149 public function parse_date($format = 'c')
2151 global $CONF, $manager;
2152 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2157 * AdminActions::parse_defaultadminskintypes()
2158 * Parse skinvar defaultadminskintypes
2160 * @param string $tabindex index number for tabindex attribute of input element
2161 * @param string $templateName name of template
2164 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2166 $templates = array();
2167 if ( $templateName )
2169 $templates = Template::read($templateName);
2172 $types = Skin::getFriendlyNames('AdminActions');
2175 if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
2177 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2181 $template['head'] = "<ul>\n";
2184 echo $template['head'];
2186 if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
2188 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2192 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
2193 . "<%name%></a> <%help%></li>\n";
2195 $handler = new Actions('template', $template, new ADMIN);
2196 $parser = new PARSER(Actions::getDefinedActions(), $handler);
2198 foreach ( $types as $type => $fName )
2200 $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
2202 'tabindex' => $tabindex,
2203 'skintype' => $type,
2205 'help' => $helplink,
2206 'skinid' => intrequestVar('skinid'),
2208 $templateBody = Template::fill($template['body'], $data);
2209 $parser->parse($templateBody);
2212 if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
2214 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2218 $template['foot'] = " </ul>\n";
2220 echo $template['foot'];
2225 * AdminActions::parse_defblogselect()
2226 * Parse skinvar defblogselect
2228 * @param string $templateName name of template
2231 public function parse_defblogselect($templateName = '')
2234 $query = "SELECT bname as text, bnumber as value FROM %s;";
2235 $query = sprintf($query, sql_table('blog'));
2236 $template['name'] = 'DefaultBlog';
2237 $template['selected'] = $CONF['DefaultBlog'];
2238 $template['tabindex'] = 10;
2239 Showlist($query, 'select', $template, $templateName);
2244 * AdminActions::parse_defcatselect()
2245 * Parse skinvar defcatselect
2247 * @param string $templateName name of template
2250 public function parse_defcatselect($templateName = '')
2253 $blogid = intRequestVar('blogid');
2254 $blog = $manager->getBlog($blogid);
2255 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2256 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2257 $template['name'] = 'defcat';
2258 $template['selected'] = $blog->getDefaultCategory();
2259 $template['tabindex'] = 110;
2260 Showlist($query, 'select', $template, $templateName);
2265 * AdminActions::parse_defskinselect()
2266 * Parse skinvar defskinselect
2268 * @param string $type type of skin
2269 * @param string $templateName name of template
2272 public function parse_defskinselect($type = 'blog', $templateName = '')
2275 $query = "SELECT sdname as text, sdnumber as value FROM %s;";
2276 $query = sprintf($query, sql_table('skin_desc'));
2278 $blogid = intRequestVar('blogid');
2283 $template['selected'] = $CONF['BaseSkin'];
2287 $blog = $manager->getBlog($blogid);
2288 $template['selected'] = $blog->getDefaultSkin();
2291 if ( $type != 'blog' )
2293 $nname = 'BaseSkin';
2300 $template['name'] = $nname;
2301 $template['tabindex'] = 50;
2302 Showlist($query, 'select', $template, $templateName);
2307 * AdminActions::parse_deletecomment()
2308 * Parse skinvar deletecomment
2310 * @param string $type type of infomation for comment
2313 public function parse_deletecomment($type = 'id')
2315 $commentid = intRequestVar('commentid');
2316 $comment = COMMENT::getComment($commentid);
2321 echo intRequestVar('commentid');
2324 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2326 echo $comment['member'];
2330 echo $comment['user'];
2334 $body = strip_tags($comment['body']);
2335 echo Entity::hsc(shorten($body, 300, '...'));
2341 * AdminActions::parse_deleteitembody()
2342 * Parse skinvar deleteitembody
2347 public function parse_deleteitembody()
2350 $itemid = intRequestVar('itemid');
2351 $item =& $manager->getItem($itemid, 1, 1);
2352 $body = strip_tags($item['body']);
2353 echo Entity::hsc(shorten($body, 300, '...'));
2358 * AdminActions::parse_deleteitemid()
2359 * Parse skinvar deleteitemid
2364 public function parse_deleteitemid()
2366 echo (integer) intRequestVar('itemid');
2371 * AdminActions::parse_deleteitemtitle()
2372 * Parse skinvar deleteitemtitle
2377 public function parse_deleteitemtitle()
2380 $itemid = intRequestVar('itemid');
2381 $item =& $manager->getItem($itemid, 1, 1);
2382 echo Entity::hsc(strip_tags($item['title']));
2387 * AdminActions::parse_editadminskin()
2388 * Parse skinvar editadminskin
2390 * @param string $type type of skin setting
2393 public function parse_editadminskin($type = 'id')
2395 $skinid = intRequestVar('skinid');
2396 $skin = new Skin($skinid);
2400 echo intRequestVar('skinid');
2403 echo Entity::hsc($skin->getName());
2406 echo Entity::hsc($skin->getDescription());
2409 echo Entity::hsc($skin->getContentType());
2412 echo Entity::hsc($skin->getIncludePrefix());
2415 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2423 * AdminActions::parse_editadminskintype()
2424 * Parse skinvar editadminskintype
2426 * @param string $type name of skin type
2429 public function parse_editadminskintype($type = 'id')
2431 global $CONF, $manager, $member;
2432 $skinid = intRequestVar('skinid');
2433 $skin = new Skin($skinid);
2434 $fNames = Skin::getFriendlyNames();
2435 $sType = strtolower(trim(requestVar('type')));
2440 echo intRequestVar('skinid');
2443 echo Entity::hsc($skin->getName());
2446 echo Entity::hsc($skin->getDescription());
2449 echo Entity::hsc($skin->getContentType());
2452 echo Entity::hsc($skin->getContent($sType));
2455 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2456 echo Entity::hsc($skinType);
2459 echo Entity::hsc($sType);
2462 echo Entity::hsc($skin->getIncludePrefix());
2465 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2466 echo Entity::hsc($incMode);
2475 * AdminActions::parse_editadmintemplateinfo()
2476 * Parse skinvar editadmintemplateinfo
2478 * @param string $type type of skin template
2479 * @param string $description description of template
2480 * @param string $name name of stemplate
2481 * @param string $tabindex index number for tabindex attribute of input element
2482 * @param string $big
2483 * @param string $tplt
2485 public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2488 $templateid = intRequestVar('templateid');
2489 $templatename = Template::getNameFromId($templateid);
2490 $templatedescription = Template::getDesc($templateid);
2491 $template =& Template::read($templatename);
2495 echo intval($templateid);
2498 echo Entity::hsc($templatename);
2501 echo Entity::hsc($templatedescription);
2503 case 'extratemplate':
2505 $pluginfields = array();
2507 'AdminTemplateExtraFields',
2509 'fields' => &$pluginfields
2515 $tmplt = Template::read($description);
2517 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2519 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2525 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2527 foreach ( $pluginfields as $pfkey => $pfvalue )
2530 'explugtplname' => Entity::hsc($pfkey)
2532 echo TEMPLATE::fill($base, $data);
2533 foreach ( $pfvalue as $pffield => $pfdesc )
2535 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2540 $desc = defined($description) ? constant($description) : $description;
2541 $name = defined($name) ? constant($name) : $name;
2542 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2549 * AdminActions::parse_editcomment()
2550 * Parse skinvar editcomment
2552 * @param string $type type of comment setting
2555 public function parse_editcomment($type = 'id')
2558 $commentid = intRequestVar('commentid');
2559 $comment = COMMENT::getComment($commentid);
2561 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2566 echo intRequestVar('commentid');
2569 if (array_key_exists('member', $comment) && !empty($comment['member']) )
2571 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2575 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2579 echo date("Y-m-d @ H:i", $comment['timestamp']);
2582 $comment['body'] = str_replace('<br />', '', $comment['body']);
2583 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2584 echo $comment['body'];
2586 echo $comment[$type];
2593 * AdminActions::parse_editdesturl()
2594 * Parse skinvar editdesturl
2596 public function parse_editdesturl()
2598 if ( requestVar('desturl') )
2600 echo Entity::hsc(requestVar('desturl'));
2606 * AdminActions::parse_editmemberlist()
2607 * Parse skinvar editmemberlist
2609 * @param string $templateName name of template
2612 public function parse_editmemberlist($templateName = '')
2615 // show list of members with actions
2616 $query = 'SELECT * FROM '.sql_table('member');
2617 $template['content'] = 'memberlist';
2618 $template['tabindex'] = 10;
2620 $batch = new Batch('member');
2621 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2626 * AdminActions::parse_editmember()
2627 * Parse skinvar editmember
2629 * @param string $type type of information for member
2630 * @return string $tempateName name of template to use
2633 public function parse_editmember($type = 'id', $templateName = '')
2635 global $CONF, $manager, $member;
2636 $memberid = intRequestVar('memberid');
2637 $mem = MEMBER::createFromID($memberid);
2642 echo intRequestVar('memberid');
2645 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2647 echo Entity::hsc($mem->getDisplayName());
2651 $dispName = Entity::hsc($mem->getDisplayName());
2652 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2654 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2663 echo Entity::hsc($mem->getRealName());
2666 echo Entity::hsc($mem->getEmail());
2669 echo Entity::hsc($mem->getURL());
2672 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2675 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2678 echo Entity::hsc($mem->getNotes());
2681 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2690 * AdminActions::parse_editpluginfo()
2691 * Parse skinvar editpluginfo
2693 * @param string $type type of plugin info
2696 public function parse_editpluginfo($type)
2698 $pid = intRequestVar('plugid');
2705 echo Entity::hsc(getPluginNameFromPid($pid));
2712 * AdminActions::parse_editplugoptionslist()
2713 * Parse skinvar editplugoptionslist
2715 * @param string $templateName name of template
2718 public function parse_editplugoptionslist($templateName = '')
2722 $pid = intRequestVar('plugid');
2723 $aOptions = array();
2726 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
2727 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2728 $resource = sql_query($query);
2730 while ( $o = sql_fetch_object($resource) )
2732 array_push($aOIDs, $o->oid);
2733 $aOptions[$o->oid] = array(
2736 'value' => $o->odef,
2737 'name' => $o->oname,
2738 'description' => $o->odesc,
2739 'type' => $o->otype,
2740 'typeinfo' => $o->oextra,
2745 // fill out actual values
2746 if ( count($aOIDs) > 0 )
2748 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2749 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2751 $result = sql_query($query);
2753 while ( $o = sql_fetch_object($result) )
2755 $aOptions[$o->oid]['value'] = $o->ovalue;
2761 'PrePluginOptionsEdit',
2763 'context' => 'global',
2765 'options' => &$aOptions
2769 $template['content'] = 'plugoptionlist';
2770 $amount = Showlist($aOptions, 'table', $template, $templateName);
2773 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2779 * AdminActions::parse_editskin()
2780 * Parse skinvar editskin
2782 * @param string $type type of skin
2785 public function parse_editskin($type = 'id')
2787 $skinid = intRequestVar('skinid');
2788 $skin = new SKIN($skinid);
2792 echo intRequestVar('skinid');
2795 echo Entity::hsc($skin->getName());
2798 echo Entity::hsc($skin->getDescription());
2801 echo Entity::hsc($skin->getContentType());
2804 echo Entity::hsc($skin->getIncludePrefix());
2807 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2815 * AdminActions::parse_editskintype()
2816 * Parse skinvar editskintype
2818 * @param string $type name of type for skin type
2821 public function parse_editskintype($type = 'id')
2823 global $CONF, $manager, $member;
2824 $skinid = intRequestVar('skinid');
2825 $skin = new SKIN($skinid);
2826 $fNames = SKIN::getFriendlyNames('Actions');
2827 $sType = strtolower(trim(requestVar('type')));
2832 echo intRequestVar('skinid');
2835 echo Entity::hsc($skin->getName());
2838 echo Entity::hsc($skin->getDescription());
2841 echo Entity::hsc($skin->getContentType());
2844 echo Entity::hsc($skin->getContent($sType));
2847 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2848 echo Entity::hsc($skinType);
2851 echo Entity::hsc($sType);
2854 echo Entity::hsc($skin->getIncludePrefix());
2857 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2858 echo Entity::hsc($incMode);
2867 * AdminActions::parse_adminurl()
2868 * Parse skinvar adminurl
2869 * (shortcut for admin url)
2874 public function parse_adminurl()
2876 $this->parse_sitevar('adminurl');
2881 * AdminActions::parse_edittemplateinfo()
2882 * Parse skinvar edittemplateinfo
2884 * @param string $type name of type for skin
2885 * @param string $description description for skin
2886 * @param string $name name of skin
2887 * @param string $help
2888 * @param string $tabindex index value for tabindex attribute of input element
2889 * @param string $big
2890 * @param string $tplt name of template
2892 public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2895 $templateid = intRequestVar('templateid');
2896 $templatename = TEMPLATE::getNameFromId($templateid);
2897 $templatedescription = TEMPLATE::getDesc($templateid);
2898 $template =& $manager->getTemplate($templatename);
2902 echo intval($templateid);
2905 echo Entity::hsc($templatename);
2908 echo Entity::hsc($templatedescription);
2910 case 'extratemplate':
2912 $pluginfields = array();
2914 'TemplateExtraFields',
2916 'fields' => &$pluginfields
2922 $tmplt = Template::read($description);
2924 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2926 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2930 $base = "</tr><tr>\n"
2931 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2933 foreach ( $pluginfields as $pfkey => $pfvalue )
2936 'explugtplname' => Entity::hsc($pfkey)
2938 echo TEMPLATE::fill($base, $data);
2939 foreach ( $pfvalue as $pffield => $pfdesc )
2941 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2946 $desc = defined($description) ? constant($description) : $description;
2947 $name = defined($name) ? constant($name) : $name;
2948 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2955 * AdminActions::parse_eventformextra()
2956 * Parse skinvar eventformextra
2958 * @param string $type name of type for event form extra
2961 public function parse_eventformextra($type = 'activation')
2967 $key = requestVar('ackey');
2970 Admin::error(_ERROR_ACTIVATE);
2972 $info = MEMBER::getActivationInfo($key);
2975 Admin::error(_ERROR_ACTIVATE);
2977 $mem = MEMBER::createFromId($info->vmember);
2980 Admin::error(_ERROR_ACTIVATE);
2983 'type' => 'activation',
2987 case 'membermailform-notloggedin':
2989 'type' => 'membermailform-notloggedin',
2993 $manager->notify('FormExtra', $data);
2998 * AdminActions::parse_extrahead()
2999 * Parse skinvar extrahead
3001 public function parse_extrahead()
3004 $extrahead = Admin::getAdminextrahead();
3008 'extrahead' => &$extrahead,
3009 'action' => Admin::getAdminAction()
3018 * AdminActions::parse_member()
3019 * Parse skinvar member
3020 * (includes a member info thingie)
3022 * @param string $what which memberdata is needed
3025 public function parse_member($what)
3027 global $memberinfo, $member, $CONF;
3029 // 1. only allow the member-details-page specific variables on member pages
3030 if ( $this->skintype == 'member' )
3035 echo Entity::hsc($memberinfo->getDisplayName());
3038 echo Entity::hsc($memberinfo->getRealName());
3041 echo Entity::hsc($memberinfo->getNotes());
3044 echo Entity::hsc($memberinfo->getURL());
3047 echo Entity::hsc($memberinfo->getEmail());
3050 echo Entity::hsc($memberinfo->getID());
3055 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3056 if ( $member->isLoggedIn() )
3061 echo $member->getDisplayName();
3063 case 'yourrealname':
3064 echo $member->getRealName();
3067 echo $member->getNotes();
3070 echo $member->getURL();
3073 echo $member->getEmail();
3076 echo $member->getID();
3078 case 'yourprofileurl':
3079 if ($CONF['URLMode'] == 'pathinfo')
3080 echo Link::create_member_link($member->getID());
3082 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3090 * AdminActions::parse_version()
3091 * Parse skinvar version
3092 * (include nucleus versionnumber)
3097 public function parse_version()
3100 echo 'Nucleus CMS ' . $nucleus['version'];
3105 * AdminActions::parse_sitevar()
3106 * Parse skinvar sitevar
3107 * (include a sitevar)
3109 * @param string $which
3112 public function parse_sitevar($which)
3118 echo $CONF['IndexURL'];
3121 echo $CONF['SiteName'];
3124 echo $CONF['AdminEmail'];
3127 echo $CONF['AdminURL'];
3133 * AdminActions::parse_charset()
3134 * Parse skinvar charset
3139 public function parse_charset()
3141 echo i18n::get_current_charset();
3146 * AdminActions::parse_getblogsetting()
3147 * Parse skinvar getblogsetting
3149 public function parse_getblogsetting($which)
3157 elseif ( $bid = intRequestVar('blogid') )
3160 $b = $manager->getBlog($bid);
3170 return Entity::hsc($b->getID());
3173 return Entity::hsc($b->getURL());
3176 return Entity::hsc($b->getName());
3179 return Entity::hsc($b->getDescription());
3182 return Entity::hsc($b->getShortName());
3184 case 'notifyaddress':
3185 return Entity::hsc($b->getNotifyAddress());
3188 return Entity::hsc($b->getMaxComments());
3191 return Entity::hsc($b->getUpdateFile());
3194 return Entity::hsc($b->getTimeOffset());
3201 * AdminActions::parse_geteditpluginfo()
3202 * Parse skinvar geteditpluginfo
3204 * @param string $type name of setting for edit plugin info
3207 public function parse_geteditpluginfo($type)
3209 $pid = intRequestVar('plugid');
3216 return Entity::hsc(getPluginNameFromPid($pid));
3223 * AdminActions::parse_getmember()
3224 * Parse skinvar getmember
3225 * (includes a member info thingie)
3227 * @param string $what name of setting for member
3230 public function parse_getmember($what)
3232 global $memberinfo, $member;
3233 // 1. only allow the member-details-page specific variables on member pages
3234 if ( $this->skintype == 'member' )
3239 return Entity::hsc($memberinfo->getDisplayName());
3242 return Entity::hsc($memberinfo->getRealName());
3245 return Entity::hsc($memberinfo->getNotes());
3248 return Entity::hsc($memberinfo->getURL());
3251 return Entity::hsc($memberinfo->getEmail());
3254 return Entity::hsc($memberinfo->getID());
3258 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3259 if ( $member->isLoggedIn() )
3264 return $member->getDisplayName();
3266 case 'yourrealname':
3267 return $member->getRealName();
3270 return $member->getNotes();
3273 return $member->getURL();
3276 return $member->getEmail();
3279 return $member->getID();
3287 * AdminActions::parse_headmessage()
3288 * Parse skinvar headmessage
3293 public function parse_headmessage()
3295 if ( !empty(Admin::$headMess) )
3297 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3303 * AdminActions::parse_helplink()
3304 * Parse skinvar helplink
3306 * @param string $topic name of topic for help
3309 public function parse_helplink($topic = '')
3311 if ( empty($topic) )
3320 * AdminActions::parse_helpplugname()
3321 * Parse skinvar helpplugname
3326 public function parse_helpplugname()
3328 $plugid = intGetVar('plugid');
3329 Entity::hsc(getPluginNameFromPid($plugid));
3334 * AdminActions::parse_ilistaddnew()
3335 * Parse skinvar ilistaddnew
3340 public function parse_ilistaddnew()
3342 $blogid = intRequestVar('blogid');
3343 if ( intPostVar('start') == 0 )
3345 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3351 * AdminActions::parse_importskininfo()
3352 * Parse skinvar importskininfo
3354 * @param string $type name of information for imported skin
3357 public function parse_importskininfo($type)
3362 echo Entity::hsc(requestVar('skininfo'));
3365 $dataArr = requestArray('skinnames');
3366 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3369 $dataArr = requestArray('tpltnames');
3370 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3373 $dataArr = requestArray('skinclashes');
3374 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3377 $dataArr = requestArray('tpltclashes');
3378 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3381 echo Entity::hsc(requestVar('skinfile'));
3384 echo Entity::hsc(requestVar('mode'));
3391 * AdminActions::parse_inputyesno()
3392 * Parse skinvar inputyesno
3394 * @param string $name
3395 * @param string $checkedval
3396 * @param string $tabindex
3397 * @param string $value1
3398 * @param string $value2
3399 * @param string $yesval
3400 * @param string $noval
3401 * @param string $isAdmin
3402 * @param string $templateName
3405 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3407 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3412 * AdminActions::parse_insertpluginfo()
3413 * Parse templatevar insertpluginfo
3415 public function parse_insertpluginfo($type)
3417 $option = Admin::$aOptions;
3421 return $option['pid'];
3424 return Entity::hsc($option['pfile']);
3431 * AdminActions::parse_insertpluginoptions()
3432 * Parse skinvar insertpluginoptions
3434 * @param string $templateName name of template
3437 public function parse_insertpluginoptions($templateName = '')
3439 $options = Admin::$aOptions;
3440 $template = array();
3441 $templats = array();
3443 if ( $templateName )
3445 $templates = Template::read($templateName);
3447 if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
3449 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3453 $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
3455 if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
3457 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3461 $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
3466 foreach ( $options as $option )
3468 $handler = new Actions($this->skintype, $template, $option);
3469 $parser = new PARSER(Actions::getDefinedActions(), $handler);
3471 if ( $prevPid != $option['pid'] )
3473 $prevPid = $option['pid'];
3474 $parser->parse($template['title']);
3476 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3477 if ( @$meta['access'] != 'hidden' )
3479 $parsed = $parser->parse($template['body']);
3486 * AdminActions::parse_insplugoptcontent()
3487 * Parse skinvar insplugoptcontent
3492 public function parse_insplugoptcontent()
3494 $option = Admin::$aOption;
3496 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3497 if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
3500 listplug_plugOptionRow($option);
3507 * AdminActions::parse_iprangeinput()
3508 * Parse skinvar iprangeinput
3513 public function parse_iprangeinput()
3515 if ( requestVar('ip') )
3517 $iprangeVal = Entity::hsc(requestVar('ip'));
3518 echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
3519 echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
3520 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3521 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3522 echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
3526 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3527 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3533 * AdminActions::parse_itemnavlist()
3534 * Parse skinvar itemnavlist
3539 public function parse_itemnavlist()
3541 global $CONF, $manager, $member;
3542 if ( $this->skintype == 'itemlist' )
3544 $blogid = intRequestVar('blogid');
3545 $blog =& $manager->getBlog($blogid);
3547 if ( postVar('start') )
3549 $start = intPostVar('start');
3556 // amount of items to show
3557 if ( postVar('amount') )
3559 $amount = intPostVar('amount');
3563 $amount = intval($CONF['DefaultListSize']);
3569 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3570 . " FROM %s, %s, %s"
3571 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid;";
3573 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3575 if ( $this->skintype == 'itemlist' )
3577 $query .= 'and iblog = ' . $blogid;
3578 $template['now'] = $blog->getCorrectTime(time());
3580 // non-blog-admins can only edit/delete their own items
3581 if ( !$member->blogAdminRights($blogid) )
3583 $query .= ' and iauthor = ' . $member->getID();
3586 elseif ( $this->skintype == 'browseownitems' )
3588 $query .= 'and iauthor = ' . $member->getID();
3590 $template['now'] = time();
3593 // search through items
3594 $search = postVar('search');
3596 if ( !empty($search) )
3598 $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
3599 . ' OR (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
3600 . ' OR (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
3602 $query .= ' ORDER BY itime DESC'
3603 . " LIMIT {$start},{$amount}";
3605 $template['content'] = 'itemlist';
3607 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3608 $navList->showBatchList('item', $query, 'table', $template);
3613 * AdminActions::parse_jstoolbaroptions()
3614 * Parse skinvar jstoolbaroptions
3619 public function parse_jstoolbaroptions()
3623 _SETTINGS_JSTOOLBAR_NONE,
3624 _SETTINGS_JSTOOLBAR_SIMPLE,
3625 _SETTINGS_JSTOOLBAR_FULL
3628 foreach ( $options as $option )
3630 $text = "<option value=\"%d\"%s>%s</option>\n";
3631 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3632 echo sprintf($text, $i, $extra, $option);
3639 * AdminActions::parse_localeselectoptions()
3640 * Parse skinvar localeselectoptions
3645 public function parse_localeselectoptions()
3647 $locales = i18n::get_available_locale_list();
3648 $memid = intRequestVar('memberid');
3651 $mem = MEMBER::createFromID($memid);
3652 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3654 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3658 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3663 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3665 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3668 foreach ( $locales as $locale )
3672 if ( $locale == $mem->getLocale() )
3674 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3678 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3683 if ( $locale == i18n::get_current_locale() )
3685 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3689 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3697 * AdminActions::parse_listplugplugoptionrow()
3698 * Parse templatevar listplugplugoptionrow
3700 * @param string $templateName name of template
3703 public function parse_listplugplugoptionrow($templateName = '')
3705 echo listplug_plugOptionRow(Admin::$aOptions, $templateName);
3710 * AdminActions::parse_mediadirwarning()
3711 * Parse skinvar mediadirwarning
3716 public function parse_mediadirwarning()
3719 if ( !is_dir($DIR_MEDIA) )
3721 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
3723 if ( !is_readable($DIR_MEDIA) )
3725 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
3727 if ( !is_writeable($DIR_MEDIA) )
3729 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
3735 * AdminActions::parse_movedistselect()
3736 * Parse skinvar movedistselect
3738 public function parse_movedistselect()
3740 $actionType = requestVar('action');
3741 switch ( $actionType )
3744 Admin::selectBlogCategory('destcatid');
3746 case 'batchcategory':
3747 Admin::selectBlog('destblogid');
3750 if ( $this->skintype == 'itemmove' )
3752 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
3753 $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
3754 $catid = quickQuery(sprintf($query, intRequestVar('itemid')));
3755 Admin::selectBlogCategory('catid', $catid, 10, 1);
3763 * AdminActions::parse_moveitemid()
3764 * Parse skinvar moveitemid
3769 public function parse_moveitemid()
3771 echo intRequestVar('itemid');
3776 * AdminActions::parse_newestcompare()
3777 * Parse skinvar newestcompare
3782 public function parse_newestcompare()
3785 $newestVersion = getLatestVersion();
3786 $newestCompare = str_replace('/', '.', $newestVersion);
3787 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
3788 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
3790 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
3791 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
3797 * AdminActions::parse_newmemberselect()
3798 * Parse skinvar newmemberselect
3800 * @param string $templateName name of template to use
3803 public function parse_newmemberselect($templateName = '')
3805 $blogid = intRequestVar('blogid');
3807 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
3808 $query = sprintf($query, sql_table('team'), (integer) $blogid);
3809 $res = sql_query($query);
3812 while ( $tmember = sql_fetch_object($res) )
3814 $tmem[] = intval($tmember->tmember);
3817 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
3818 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
3820 $template['name'] = 'memberid';
3821 $template['tabindex'] = 10000;
3822 Showlist($query, 'select', $template, $templateName);
3827 * AdminActions::parse_newpluginlist()
3828 * Parse skinvar newpluginlist
3833 public function parse_newpluginlist()
3835 $candidates = $this->newPlugCandidates;
3836 foreach ( $candidates as $name )
3838 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
3844 * AdminActions::parse_outputspecialdirs()
3845 * Parse skinvar outputspecialdirs
3847 * @param string $type type of setting for directory
3850 public function parse_outputspecialdirs($type)
3855 global $DIR_NUCLEUS;
3856 echo Entity::hsc($DIR_NUCLEUS);
3860 echo Entity::hsc($DIR_MEDIA);
3867 * AdminActions::parse_passrequestvars()
3868 * Parse skinvar passrequestvars
3873 public function parse_passrequestvars()
3875 $oldaction = postVar('oldaction');
3876 if ( ($oldaction != 'logout')
3877 && ($oldaction != 'login')
3879 && !postVar('customaction') )
3887 * AdminActions::parse_pluginextras()
3888 * Parse skinvar pluginextras
3890 * @param string $type type of plugin context
3893 public function parse_pluginextras($type = 'global')
3899 $id = intRequestVar('memberid');
3900 $mem = MEMBER::createFromID($id);
3902 'MemberSettingsFormExtras',
3909 $id = intRequestVar('blogid');
3910 $blg = $manager->getBlog($id);
3912 'BlogSettingsFormExtras',
3920 'GeneralSettingsFormExtras',
3930 * AdminActions::parse_pluginhelp()
3931 * Parse skinvar pluginhelp
3936 public function parse_pluginhelp()
3938 global $manager, $DIR_PLUGINS;
3939 $plugid = intGetVar('plugid');
3940 $plugName = getPluginNameFromPid($plugid);
3941 $plug =& $manager->getPlugin($plugName);
3943 if ( $plug->supportsFeature('HelpPage') > 0 )
3945 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
3946 if ( @file_exists($helpfile . 'php') )
3948 @include($helpfile . 'php');
3951 elseif ( @file_exists($helpfile . 'html') )
3953 @include($helpfile . 'html');
3957 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
3958 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
3963 * AdminActions::parse_pluginlistlist()
3964 * Parse skinvar pluginlistlist
3966 * @param string $templateName name of template to use
3969 public function parse_pluginlistlist($templateName = '')
3971 $query = "SELECT * FROM %s ORDER BY porder ASC;";
3972 $query = sprintf($query, sql_table('plugin'));
3973 $template['content'] = 'pluginlist';
3974 $template['tabindex'] = 10;
3975 Showlist($query, 'table', $template, $templateName);
3980 * AdminActions::parse_pluginoptions()
3981 * Parse skinvar pluginoptions
3983 * @param string $type type of plugin option
3986 public function parse_pluginoptions($type = 'global')
3991 $id = intRequestVar('memberid');
3994 $id = intRequestVar('blogid');
3997 $id = intRequestVar('catid');
4000 Admin::insertPluginOptions($type, $id);
4005 * AdminActions::parse_qmenuaddselect()
4006 * Parse skinvar qmanuaddselect
4008 * @param string $templateName name of template to use
4011 public function parse_qmenuaddselect($templateName = '')
4014 $showAll = requestVar('showall');
4015 if ( $member->isAdmin() && ($showAll == 'yes') )
4017 // Super-Admins have access to all blogs! (no add item support though)
4018 $query = 'SELECT bnumber as value, bname as text'
4019 . ' FROM ' . sql_table('blog')
4020 . ' ORDER BY bname';
4024 $query = 'SELECT bnumber as value, bname as text'
4025 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4026 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4027 . ' ORDER BY bname';
4029 $template['name'] = 'blogid';
4030 $template['tabindex'] = 15000;
4031 $template['extra'] = _QMENU_ADD_SELECT;
4032 $template['selected'] = -1;
4033 $template['shorten'] = 10;
4034 $template['shortenel'] = '';
4035 $template['javascript'] = 'onchange="return form.submit()"';
4036 Showlist($query, 'select', $template, $templateName);
4041 * AdminActions::parse_quickmenu()
4042 * Parse skinvar quickmenu
4044 * @param string $templateName name of template to use
4047 public function parse_quickmenu($templateName = '')
4050 $templates = array();
4051 $template = array();
4052 if ( !empty($templateName) )
4054 $templates = Template::read($templateName);
4056 $pluginExtras = array();
4060 'options' => &$pluginExtras
4063 if ( count($pluginExtras) > 0 )
4065 if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4067 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4071 $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
4073 $handler = new Actions($this->skintype, $template, $this->objAdmin);
4074 $parser = new PARSER(Actions::getDefinedActions(), $handler);
4075 $parser->parse($template['title']);
4077 if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4079 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4083 $template['head'] = '<ul>';
4086 echo $template['head'];
4088 if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
4090 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4094 $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
4097 foreach ( $pluginExtras as $aInfo )
4100 'plugadminurl' => Entity::hsc($aInfo['url']),
4101 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4102 'plugadmintitle' => Entity::hsc($aInfo['title']),
4104 echo TEMPLATE::fill($template['body'], $data);
4106 if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4108 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4112 $template['foot'] = '</ul>';
4114 echo $template['foot'];
4120 * AdminActions::parse_requestblogid()
4121 * Parse skinvar requestblogid
4126 public function parse_requestblogid()
4128 echo intRequestVar('blogid');
4133 * AdminActions::parse_requestiprange()
4134 * Parse skinvar requestiprange
4139 public function parse_requestiprange()
4141 if ( requestVar('iprange') )
4143 echo Entity::hsc(requestVar('iprange'));
4145 elseif ( requestVar('ip') )
4147 echo Entity::hsc(requestVar('ip'));
4153 * AdminActions::parse_selectlocaladminskinfiles()
4154 * Parse skinvar selectlocaladminskinfiles
4159 public function parse_selectlocaladminskinfiles()
4161 global $DIR_ADMINSKINS, $manager;
4162 $candidates = SkinImport::searchForCandidates($DIR_ADMINSKINS);
4163 foreach ( $candidates as $skinname => $skinfile )
4165 $html = Entit::hsc($skinfile);
4166 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4172 * AdminActions::parse_selectlocalskinfiles()
4173 * Parse skinvar selectlocalskinfiles
4178 public function parse_selectlocalskinfiles()
4181 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4182 foreach ( $candidates as $skinname => $skinfile )
4184 $html = Entity::hsc($skinfile);
4185 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4191 * AdminActions::parse_skineditallowedlist()
4192 * Parse skinvar skineditallowedlist
4194 * @param string $type type of skin
4195 * @param string $templateName name of template
4198 public function parse_skineditallowedlist($type, $templateName = '')
4203 $query = "SELECT bshortname, bname FROM %s";
4205 'content' => 'shortblognames'
4207 $query = sprintf($query, sql_table('blog'));
4208 Showlist($query, 'table', $show, $templateName);
4211 $query = "SELECT tdname as name, tddesc as description FROM %s";
4213 'content' => 'shortnames'
4215 $query = sprintf($query, sql_table('template_desc'));
4216 Showlist($query, 'table', $show, $templateName);
4223 * AdminActions::parse_skinielist()
4224 * Parse skinvar skinielist
4226 * @param string $type type of skin
4227 * @param string $templateName name of template to use
4230 public function parse_skinielist($type, $templateName = '')
4232 $templates = array();
4233 if ( $templateName )
4235 $templates = Template::read($templateName);
4237 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4239 $template = $templates['SKINIE_EXPORT_LIST'];
4243 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
4244 . "<td><%expdesc%></td>\n"
4250 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
4251 while ( $skinObj = sql_fetch_object($res) )
4254 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
4255 'expid' => 'skinexp' . $skinObj->sdnumber,
4256 'expname' => Entity::hsc($skinObj->sdname),
4257 'expdesc' => Entity::hsc($skinObj->sddesc),
4259 echo TEMPLATE::fill($template, $data);
4263 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
4264 while ($templateObj = sql_fetch_object($res)) {
4266 'typeid' => 'template[' . $templateObj->tdnumber . ']',
4267 'expid' => 'templateexp' . $templateObj->tdnumber,
4268 'expname' => Entity::hsc($templateObj->tdname),
4269 'expdesc' => Entity::hsc($templateObj->tddesc),
4271 echo TEMPLATE::fill($template, $data);
4279 * AdminActions::parse_skinoverview()
4280 * Parse skinvar skinoverview
4282 * @param string $templateName name of template to use
4285 public function parse_skinoverview($templateName = '')
4287 $query = "SELECT * FROM %s ORDER BY sdname";
4288 $query = sprintf($query, sql_table('skin_desc'));
4290 $template['content'] = 'skinlist';
4291 $template['tabindex'] = 10;
4292 $template['friendly_names'] = Skin::getFriendlyNames('Actions');
4294 Showlist($query, 'table', $template, $templateName);
4299 * AdminActions::parse_skintypehelp()
4300 * Check editing skintypehelp
4305 public function parse_skintypehelp()
4307 $nowSkinType = strtolower(trim(requestVar('type')));
4308 $regularType = array(
4319 if ( in_array($nowSkinType, $regularType) )
4321 help('skinpart' . $nowSkinType);
4325 help('skinpartspecial');
4331 * AdminActions::parse_specialskinlist()
4332 * Parse skinvar specialskinlist
4334 * @param string $templateName name of template to use
4337 public function parse_specialskinlist($templateName = '')
4339 $templates = array();
4340 if ( $templateName )
4342 $templates = Template::read($templateName);
4354 $skinid = intRequestVar('skinid');
4355 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4356 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4358 $res = sql_query($query);
4359 if ( $res && sql_num_rows($res) > 0 )
4362 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4364 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4368 $template['head'] = "<ul>\n";
4370 echo TEMPLATE::fill($template['head'], $data);
4371 if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
4373 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4377 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4378 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4379 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4382 while ( $row = sql_fetch_assoc($res) )
4385 'tabindex' => $tabstart++,
4386 'skinid' => $skinid,
4387 'skintype' => Entity::hsc(strtolower($row['stype']))
4389 echo TEMPLATE::fill($template['body'], $data);
4392 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4394 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4398 $template['foot'] = "</ul>\n";
4400 echo TEMPLATE::fill($template['foot'], $data);
4406 * AdminActions::parse_sprinttext()
4409 * @param string $which
4410 * @param string $val
4413 public function parse_sprinttext($which, $val)
4415 if ( !defined($which) )
4421 $base = constant($which);
4424 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4426 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4428 $met = 'parse_' . $matchies[0];
4432 $arg = trim($args[0], '()');
4433 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4436 if ( method_exists($this, $met) )
4438 $value = call_user_func(array(&$this, $met), $arg);
4442 if ( !isset($value) || empty($value) )
4446 echo sprintf($base, $value);
4451 * AdminActions::parse_systemsettings()
4452 * Parse skinvar systemsettings
4454 * @param string $type type of settings for system
4455 * @param string $templateName name of template to use
4458 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4460 global $member, $CONF, $nucleus;
4462 $member->isAdmin() or Admin::disallow();
4464 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4465 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4472 case 'sqlserverinfo':
4473 echo sql_get_server_info();
4475 case 'sqlclientinfo':
4476 echo sql_get_client_info();
4478 case 'magicquotesgpc':
4479 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4481 case 'magicquotesruntime':
4482 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4484 case 'registerglobals':
4485 echo ini_get('register_globals') ? 'On' : 'Off';
4488 $templates = array();
4489 if ( $templateName )
4491 $templates = Template::read($templateName);
4493 if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
4495 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4499 $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
4502 $gdinfo = gd_info();
4504 foreach ( $gdinfo as $key => $value )
4506 if ( is_bool($value) )
4508 $value = $value ? $enable : $disable;
4512 $value = Entity::hsc($value);
4518 echo TEMPLATE::fill($template, $data);
4523 phpinfo(INFO_MODULES);
4524 $im = ob_get_contents();
4526 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4528 case 'nucleusversion':
4529 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4531 case 'nucleuspatchlevel':
4532 echo getNucleusPatchLevel();
4538 echo $CONF['ItemURL'];
4540 case 'alertonheaderssent':
4541 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4543 case 'nucleuscodename':
4544 if ( $nucleus['codename'] != '' )
4546 echo ' "' . $nucleus['codename'] . '"';
4549 case 'versioncheckurl':
4550 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4557 * AdminActions::parse_templateoverview()
4558 * Parse skinvar templateoverview
4560 * @param string $templateName name of template to use
4563 public function parse_templateoverview($templateName = '')
4565 $query = "SELECT * FROM %s ORDER BY tdname";
4566 $query = sprintf($query, sql_table('template_desc'));
4567 $template['content'] = 'templatelist';
4568 $template['tabindex'] = 10;
4569 Showlist($query, 'table', $template, $templateName);
4574 * AdminActions::parse_ticket()
4580 public function parse_ticket()
4583 $manager->addTicketHidden();
4588 * AdminActions::parse_versioncheckurl()
4589 * Parse skinvar versioncheckurl
4594 public function parse_versioncheckurl()
4596 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4601 * AdminActions::parse_yrbloglist()
4602 * Parse skinvar yrbloglist
4604 * @param string $templateName name of template to use
4607 public function parse_yrbloglist($templateName = '')
4610 $showAll = requestVar('showall');
4612 if ( $member->isAdmin() && ($showAll == 'yes') )
4614 // Super-Admins have access to all blogs! (no add item support though)
4615 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4617 . " ORDER BY bnumber";
4618 $query = sprintf($query, sql_table('blog'));
4622 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4624 . " WHERE tblog=bnumber and tmember=%d"
4625 . " ORDER BY bnumber";
4626 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4629 $template['content'] = 'bloglist';
4630 $template['superadmin'] = $member->isAdmin();
4632 $amount = Showlist($query, 'table', $template, $templateName);
4634 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4636 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4638 $total = quickQuery($query);
4639 if ( $total > $amount )
4641 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4647 echo _OVERVIEW_NOBLOGS;
4649 elseif( $amount != 0 )
4651 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4653 $query = "SELECT ititle, inumber, bshortname"
4655 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
4656 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4658 $template['content'] = 'draftlist';
4660 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4661 if ( $amountdrafts == 0 )
4663 echo _OVERVIEW_NODRAFTS;
4670 * AdminActions::checkCondition()
4671 * Checks conditions for if statements
4673 * @param string $field type of <%if%>
4674 * @param string $name property of field
4675 * @param string $value value of property
4676 * @return boolean condition
4678 protected function checkCondition($field, $name='', $value = '')
4680 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
4691 $blog =& $manager->getBlog($blogid);
4695 $blogid = getBlogIDFromCatID($catid);
4697 $blog =& $manager->getBlog($blogid);
4699 elseif ( intRequestVar('catid') )
4701 $catid = intRequestVar('catid');
4702 $blogid = getBlogIDFromCatID($catid);
4704 $blog =& $manager->getBlog($blogid);
4711 $condition = ($blog && $this->ifCategory($name, $value));
4714 $condition = ($blog && ($blog->getSetting($name) == $value));
4717 $condition = $member->isLoggedIn();
4720 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
4723 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
4726 $condition = $member->isLoggedIn() && $member->isAdmin();
4728 case 'allowloginedit':
4729 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
4732 $condition = ($itemidnext != '');
4735 $condition = ($itemidprev != '');
4737 case 'archiveprevexists':
4738 $condition = ($archiveprevexists == true);
4740 case 'archivenextexists':
4741 $condition = ($archivenextexists == true);
4744 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
4747 $condition = $this->ifHasPlugin($name, $value);
4750 $condition = ($this->objAdmin->action == $name);
4752 case 'adminoldaction':
4753 $condition = ($this->objAdmin->action == $name);
4755 case 'addresschange':
4756 $condition = ($this->ifAddresscange());
4758 case 'bechangepass':
4759 $condition = ($this->beChangePassword());
4761 case 'skincandidates':
4762 $condition = ($this->ifSkincandidates());
4765 $condition = requestVar('nameclashes');
4767 case 'existsnewplugin':
4768 $condition = ($this->existsNewPlugin());
4771 $condition = (boolean) ($member->getAutosave() == $value);
4774 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
4781 * Actions::_ifHasPlugin()
4782 * hasplugin,PlugName
4783 * -> checks if plugin exists
4784 * hasplugin,PlugName,OptionName
4785 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
4786 * hasplugin,PlugName,OptionName=value
4787 * -> checks if the option OptionName from plugin PlugName is set to value
4789 * @param string $name name of plugin
4790 * @param string $value
4793 private function ifHasPlugin($name, $value)
4797 // (pluginInstalled method won't write a message in the actionlog on failure)
4798 if ( $manager->pluginInstalled("NP_{$name}") )
4800 $plugin =& $manager->getPlugin("NP_{$name}");
4801 if ( $plugin != NULL )
4809 list($name2, $value2) = preg_split('#=#', $value, 2);
4810 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
4814 else if ( $plugin->getOption($name2) == $value2 )
4825 * Actions::beChangePassword()
4830 private function beChangePassword()
4832 return intRequestVar('bNeedsPasswordChange');
4836 * Actions::ifSkincandidates()
4837 * Checks if a plugin exists and call its doIf function
4842 private function ifSkincandidates()
4845 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
4846 return (count($candidates) > 0);
4850 * Actions::ifPlugin()
4851 * Checks if a plugin exists and call its doIf function
4853 private function ifPlugin($name, $key = '', $value = '')
4857 $plugin =& $manager->getPlugin("NP_{$name}");
4863 $params = func_get_args();
4864 array_shift($params);
4866 return call_user_func_array(array(&$plugin, 'doIf'), $params);
4870 * Different checks for a category
4872 private function ifCategory($name = '', $value='')
4874 global $blog, $catid;
4876 // when no parameter is defined, just check if a category is selected
4877 if (($name != 'catname' && $name != 'catid') || ($value == ''))
4879 return $blog->isValidCategory($catid);
4882 // check category name
4883 if ( $name == 'catname' )
4885 $value = $blog->getCategoryIdFromName($value);
4886 if ($value == $catid)
4888 return $blog->isValidCategory($catid);
4892 // check category id
4893 if (($name == 'catid') && ($value == $catid))
4895 return $blog->isValidCategory($catid);
4902 * Checks if a member is on the team of a blog and return his rights
4904 private function ifOnTeam($blogName = '')
4906 global $blog, $member, $manager;
4908 // when no blog found
4909 if ( ($blogName == '') && !is_object($blog) )
4914 // explicit blog selection
4915 if ($blogName != '')
4917 $blogid = getBlogIDFromName($blogName);
4920 if (($blogName == '') || !$manager->existsBlogID($blogid))
4923 $blogid = $blog->getID();
4925 return $member->teamRights($blogid);
4929 * Checks if a member is admin of a blog
4931 private function ifAdmin($blogName = '')
4933 global $blog, $member, $manager;
4935 // when no blog found
4936 if (($blogName == '') && (!is_object($blog)))
4941 // explicit blog selection
4942 if ($blogName != '')
4944 $blogid = getBlogIDFromName($blogName);
4947 if (($blogName == '') || !$manager->existsBlogID($blogid))
4950 $blogid = $blog->getID();
4953 return $member->isBlogAdmin($blogid);
4957 * Check e-Mail address is changed
4959 private function ifAddresscange()
4961 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
4966 $info = MEMBER::getActivationInfo($key);
4971 $mem = MEMBER::createFromId($info->vmember);
4976 if ( $info->vtype == 'addresschange' )
4984 * AdminActions::customHelp()
4985 * shows a link to custom help file
4987 * @param integer $id
4988 * @param string $tplName
4989 * @param string $url
4990 * @param string $iconURL
4991 * @param string $alt
4992 * @param string $title
4996 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
4998 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5002 * AdminActions::customHelpHtml()
5004 * @param integer $id
5005 * @param string $tplName
5006 * @param string $url
5007 * @param string $iconURL
5008 * @param string $alt
5009 * @param string $title
5010 * @param string $onclick
5011 * @return string anchor element with help uri
5013 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5015 $templates = array();
5018 $templates = Template::read($tplName);
5020 if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5022 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5026 $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
5029 if ( empty($iconURL) )
5032 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5034 if ( function_exists('getimagesize') )
5036 $size = getimagesize($iconURL);
5037 $width = 'width="' . $size[0] . '" ';
5038 $height = 'height="' . $size[1] . '" ';
5041 'iconurl' => $iconURL,
5043 'height' => $height,
5044 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5045 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5047 $icon = TEMPLATE::fill($template, $data);
5048 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5049 return $help . $icon;
5053 * AdminActions::input_yesno
5056 * @param $checkedval
5063 * @param $templateName
5066 private function input_yesno($name,
5077 $templates = array();
5078 if ( $templateName )
5080 $templates = Template::read($templateName);
5083 if ( $name == 'admin' )
5085 if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5087 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5091 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5092 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5093 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5094 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5099 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5101 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5105 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5107 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5110 if ( !isset($template) )
5112 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5113 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5114 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5115 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5120 $id = Entity::hsc($name);
5121 $id = str_replace('[', '-', $id);
5122 $id = str_replace(']', '-', $id);
5123 $id1 = $id . Entity::hsc($value1);
5124 $id2 = $id . Entity::hsc($value2);
5126 'name' => Entity::hsc($name),
5127 'yesval' => Entity::hsc($value1),
5128 'noval' => Entity::hsc($value2),
5131 'yesvaltext' => $yesval,
5132 'novaltext' => $noval,
5133 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5134 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5135 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5140 return Template::fill($template, $dat);
5144 echo TEMPLATE::fill($template, $dat);