2 if ( !class_exists('BaseActions') )
4 include $DIR_LIBS . 'BaseActions.php';
8 class AdminActions extends BaseActions
10 // reference to the skin object for which a part is being parsed
15 /* NOTE: list of whole available action names for tags
24 'adminskineditallowedlist',
27 'adminskinselectoptions',
28 'adminspecialskinlist',
29 'admintemplateoverview',
30 'allowedadminskinactions',
53 'configsettingsyesno',
56 'defaultadminskintypes',
66 'editadmintemplateinfo',
72 'editplugoptionslist',
88 'insertpluginoptions',
93 'languageselectoptions',
94 'listplugplugoptionrow',
111 'selectlocaladminskinfiles',
112 'selectlocalskinfiles',
113 'skineditallowedlist',
130 * AdminActions::$default_actions
131 * list of whole action names with which this class can deal
133 static private $default_actions = array(
144 * AdminActions::$skin_type_friendly_names
145 * friendly name for wrapped page types
147 static private $default_skin_types = array(
148 'actionlog' => _ADM_SKPRT_ACTIONLOG,
149 'activate' => _ADM_SKPRT_ACTIVATE,
150 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
151 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
152 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
153 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
154 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
155 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
156 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
157 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
158 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
159 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
160 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
161 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
162 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
163 'admntemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
164 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
165 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
166 'banlist' => _ADM_SKPRT_BANLIST,
167 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
168 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
169 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
170 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
171 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
172 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
173 'batchitem' => _ADM_SKPRT_BATCHITEM,
174 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
175 'batchmove' => _ADM_SKPRT_BATCHMOVE,
176 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
177 'batchteam' => _ADM_SKPRT_BATCHTEAM,
178 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
179 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX,
180 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
181 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
182 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
183 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
184 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
185 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
186 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
187 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
188 'createitem' => _ADM_SKPRT_CREATEITEM,
189 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
190 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
191 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
192 'insertpluginoptions' => _ADM_SKPRT_INSERTPLUGINO,
193 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
194 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
195 'itemedit' => _ADM_SKPRT_ITEMEDIT,
196 'itemlist' => _ADM_SKPRT_ITEMLIST,
197 'itemmove' => _ADM_SKPRT_ITEMMOVE,
198 'login' => FALSE, //missing
199 'manage' => _ADM_SKPRT_MANAGE,
200 'manageteam' => _ADM_SKPRT_MANAGETEAM,
201 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
202 'memberedit' => FALSE, //missing
203 'overview' => _ADM_SKPRT_OVERVIEW,
204 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
205 'pagehead' => _ADM_SKPRT_PAGEHEAD,
206 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
207 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
208 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
209 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
210 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
211 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
212 'skindelete' => _ADM_SKPRT_SKINDELETE,
213 'skinedit' => _ADM_SKPRT_SKINEDIT,
214 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
215 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
216 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
217 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
218 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
219 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
220 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
221 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
222 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
223 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
224 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
225 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
229 * AdminActions::getAvailableSkinTypes()
233 * @return array list of friendly names for page actions
235 static public function getAvailableSkinTypes()
237 return self::$default_skin_types;
241 * AdminActions::getDefaultTypes()
245 * @return array list of friendly names for page actions
247 static public function getDefaultTypes()
249 return self::$default_skin_types;
253 * AdminActions::__construct()
254 * Constructor for a new Actions object
256 * @param string $type
259 public function __construct($type)
261 // call constructor of superclass first
262 parent::__construct();
263 $this->skintype = $type;
264 if ( !class_exists('Navlist') || !class_exists('Batch') )
267 include $DIR_LIBS . 'ENCAPSULATE.php';
273 * AdminActions::getAvailableActions()
276 * @return array allowed actions for the page type
278 public function getAvailableActions()
280 $extra_actions = array();
282 switch ( $this->skintype )
285 $extra_actions = array(
290 $extra_actions = array(
295 case 'activatesetpwd':
296 $extra_actions = array(
300 $extra_actions = array(
306 case 'adminerrorpage':
307 $extra_actions = array(
310 case 'adminskindelete':
311 $extra_actions = array(
315 case 'adminskinedit':
316 $extra_actions = array(
318 'defaultadminskintypes',
319 'adminspecialskinlist',
322 case 'adminskinedittype':
323 $extra_actions = array(
326 'allowedadminskinactions',
327 'adminskineditallowedlist',
330 case 'adminskiniedoimport':
331 $extra_actions = array(
335 case 'adminskinieimport':
336 $extra_actions = array(
340 case 'adminskinieoverview':
341 $extra_actions = array(
342 'selectlocaladminskinfiles',
346 case 'adminskinoverview':
347 $extra_actions = array(
351 case 'adminskinremovetype':
352 $extra_actions = array(
356 case 'admintemplateedit':
357 $extra_actions = array(
358 'editadmintemplateinfo',
361 case 'admntemplateoverview':
362 $extra_actions = array(
363 'admintemplateoverview',
366 case 'backupoverview':
367 $extra_actions = array(
370 case 'backuprestore':
371 $extra_actions = array(
375 $extra_actions = array(
381 case 'banlistdelete':
382 $extra_actions = array(
387 case 'banlistdeleteconfirm':
388 $extra_actions = array(
389 'banlistdeletedlist',
394 $extra_actions = array(
400 case 'batchcategory':
401 $extra_actions = array(
407 $extra_actions = array(
413 $extra_actions = array(
419 $extra_actions = array(
425 $extra_actions = array(
431 $extra_actions = array(
440 $extra_actions = array(
449 $extra_actions = array(
455 case 'blogcommentlist':
456 $extra_actions = array(
462 case 'blogselectbox':
463 $extra_actions = array(
468 $extra_actions = array(
483 $extra_actions = array(
487 case 'browseowncomments':
488 $extra_actions = array(
492 case 'browseownitems':
493 $extra_actions = array(
497 case 'categorydelete':
498 $extra_actions = array(
504 $extra_actions = array(
510 case 'commentdelete':
511 $extra_actions = array(
516 $extra_actions = array(
521 $extra_actions = array(
532 $extra_actions = array(
538 $extra_actions = array(
543 case 'editmembersettings':
544 $extra_actions = array(
546 'languageselectoptions',
547 'adminskinselectoptions',
551 case 'insertpluginoptions':
552 $extra_actions = array(
553 'insertpluginoptions',
556 case 'itemcommentlist':
557 $extra_actions = array(
563 $extra_actions = array(
570 $extra_actions = array(
582 $extra_actions = array(
589 $extra_actions = array(
595 $extra_actions = array(
599 $extra_actions = array(
608 $extra_actions = array(
613 $extra_actions = array(
618 $extra_actions = array(
626 $extra_actions = array(
639 $extra_actions = array(
644 $extra_actions = array(
650 $extra_actions = array(
655 case 'pluginoptions':
656 $extra_actions = array(
658 'editplugoptionslist',
662 $extra_actions = array(
665 'configsettingsedit',
666 'languageselectoptions',
667 'configsettingsyesno',
675 $extra_actions = array(
680 $extra_actions = array(
685 $extra_actions = array(
691 $extra_actions = array(
694 'allowedskinactions',
695 'skineditallowedlist',
696 'skineditallowedlist',
699 case 'skiniedoimport':
700 $extra_actions = array(
705 $extra_actions = array(
709 case 'skinieoverview':
710 $extra_actions = array(
711 'selectlocalskinfiles',
716 $extra_actions = array(
720 case 'skinremovetype':
721 $extra_actions = array(
725 case 'systemoverview':
726 $extra_actions = array(
731 $extra_actions = array(
737 case 'templatedelete':
738 $extra_actions = array(
743 $extra_actions = array(
747 case 'templateoverview':
748 $extra_actions = array(
752 case 'usermanagement':
753 $extra_actions = array(
759 $extra_actions = array(
769 'selectlocaladminskinfiles',
777 $defined_actions = array_merge(self::$default_actions, $extra_actions);
779 return array_merge($defined_actions, parent::getAvailableActions());
783 * AdminActions::setSkin()
785 * @param object $skin an instance of Skin class
788 public function setSkin(&$skin)
790 $this->skin =& $skin;
795 * AdminActions::parse_actionloglist()
796 * Parse skinvar actionloglist
798 * @param string $templateName name of template to use
801 public function parse_actionloglist($templateName = '')
803 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
804 $query = sprintf($query, sql_table('actionlog'));
806 $template['content'] = 'actionlist';
807 $amount = showlist($query, 'table', $template, $templateName);
813 * AdminActions::parse_activationmessage()
814 * Parse skinvar activationmessage
816 * @param string $type type of message
817 * @param string $templateName name of template to use
820 public function parse_activationmessage($type, $templateName = '')
822 global $CONF, $manager;
826 if ( !empty($templateName))
828 $template = Template::read($templateName);
831 $key = postVar('ackey');
834 Admin::error(_ERROR_ACTIVATE);
837 $info = MEMBER::getActivationInfo($key);
840 Admin::error(_ERROR_ACTIVATE);
843 $mem = MEMBER::createFromId($info->vmember);
846 Admin::error(_ERROR_ACTIVATE);
848 switch ( $info->vtype )
851 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
853 $title = $template['ACTIVATE_FORGOT_TITLE'];
857 $title = _ACTIVATE_FORGOT_TITLE;
859 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
861 $text = $template['ACTIVATE_FORGOT_TEXT'];
865 $text = _ACTIVATE_FORGOT_TEXT;
869 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
871 $title = $template['ACTIVATE_REGISTER_TITLE'];
875 $title = _ACTIVATE_REGISTER_TITLE;
877 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
879 $text = $template['ACTIVATE_REGISTER_TEXT'];
883 $text = _ACTIVATE_REGISTER_TEXT;
886 case 'addresschange':
887 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
889 $title = $template['ACTIVATE_CHANGE_TITLE'];
893 $title = _ACTIVATE_CHANGE_TITLE;
895 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
897 $text = $template['ACTIVATE_CHANGE_TEXT'];
901 $text = _ACTIVATE_CHANGE_TEXT;
906 'memberName' => Entity::hsc($mem->getDisplayName()),
907 'realName' => Entity::hsc($mem->getRealName()),
912 echo Template::fill($title, $aVars);
915 echo Template::fill($text, $aVars);
918 echo Entity::hsc($key);
925 * AdminActions::parse_addtickettourl()
926 * Parse skinvar addtickettourl
928 * @param string $url URI for ticket
931 public function parse_addtickettourl($url)
934 $url = $manager->addTicketToUrl($url);
935 echo Entity::hsc($url);
940 * AdminActions::parse_adminbanlist()
941 * Parse skinvar adminbanlist
943 * @param string $templateName name of template to use
946 public function parse_adminbanlist($templateName = '')
948 $blogid = intRequestVar('blogid');
950 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
951 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
953 $template['content'] = 'banlist';
955 $amount = Showlist($query, 'table', $template, $templateName);
965 * AdminActions::parse_adminbatchaction()
966 * Parse skinvar adminbatchaction
971 public function parse_adminbatchaction()
973 echo Entity::hsc(requestVar('batchaction'));
978 * AdminActions::parse_adminbatchlist()
979 * Parse skinvar adminbatchlist
981 * @param string $templateName name of template to use
984 public function parse_adminbatchlist($templateName = '')
987 $templates = array();
988 if ( !empty($templateName) )
990 $templates = Template::read($templateName);
992 if ( isset($templates['ADMIN_BATCHLIST']) || !empty($templates['ADMIN_BATCHLIST']) )
994 $template = $templates['ADMIN_BATCHLIST'];
998 $template = '<li><%text(_BATCH_EXECUTING)%>'
999 . '<b><%adminbatchaction%></b>'
1000 . '<%batchlisttype%>'
1001 . '<b><%batchid%></b>...'
1002 . '<b><%batchlistmsg%></b>'
1006 $selected = requestIntArray('batch');
1007 $action = requestVar('batchaction');
1009 switch ( $this->skintype )
1012 $batchlisttype = _BATCH_ONITEM;
1013 $deleteaction = 'deleteOneItem';
1014 $moveaction = 'moveOneItem';
1015 $destid = intRequestVar('destcatid');
1017 case 'batchcomment':
1018 $batchlisttype = _BATCH_ONCOMMENT;
1019 $deleteaction = 'deleteOneComment';
1022 $batchlisttype = _BATCH_ONMEMBER;
1023 $deleteaction = 'deleteOneMember';
1024 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1025 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1026 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1027 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1030 $blogid = intRequestVar('blogid');
1031 $batchlisttype = _BATCH_ONTEAM;
1032 $deleteaction = 'deleteOneTeamMember';
1033 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1034 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1035 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1036 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1038 case 'batchcategory':
1039 $batchlisttype = _BATCH_ONCATEGORY;
1040 $deleteaction = 'deleteOneCategory';
1041 $moveaction = 'moveOneCategory';
1042 $destid = intRequestVar('destblogid');
1046 // walk over all selectedids and perform action
1047 foreach ( $selected as $selectedid )
1050 $selectedid = intval($selectedid);
1054 if ( $this->skintype != 'batchteam' )
1056 $error = Admin::$deleteaction($selectedid);
1060 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1064 $error = Admin::moveaction($selectedid, $destid);
1068 sql_query('UPDATE ' . $setadminsql . $selectedid);
1072 // there should always remain at least one super-admin
1073 $r = sql_query($unsetchksql);
1074 if ( sql_num_rows($r) < 2 )
1076 $error = $unseterrmsg;
1080 sql_query('UPDATE ' . $unsetupsql . $selectedid);
1084 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1087 'batchid' => $selectedid,
1088 'batchlisttype' => Entity::hsc($batchlisttype),
1089 'adminbatchaction' => Entity::hsc($action),
1090 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1092 $handler = new Actions('template', $template, new ADMIN);
1093 $parser = new Parser($handler);
1096 $parser->parse($template);
1097 $template = ob_get_contents();
1100 echo Template::fill($template, $data);
1106 * AdminActions::parse_adminbloglink()
1107 * Parse skinvar adminbloglink
1109 * @param string $templateName name of template to use
1112 public function parse_adminbloglink($templateName = '')
1115 $blogid = intRequestVar('blogid');
1116 $blog =& $manager->getBlog($blogid);
1117 $templates = array();
1119 if ( !empty($templateName) )
1121 $templates = Template::read($templateName);
1124 if ( isset($templates['ADMIN_BLOGLINK']) || !empty($templates['ADMIN_BLOGLINK']) )
1126 $template = $templates['ADMIN_BLOGLINK'];
1130 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1134 'url' => Entity::hsc($blog->getURL()),
1135 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1136 'blogname' => Entity::hsc($blog->getName())
1139 echo Template::fill($template, $data);
1144 * AdminActions::parse_adminerrormesg()
1145 * Parse skinvar adminerrormesg
1150 public function parse_adminerrormesg()
1155 if ( requestVar('errormessage') )
1157 $message = requestVar('errormessage');
1159 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1161 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1163 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1165 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1167 echo Entity::hsc($message);
1172 * AdminActions::parse_adminskineditallowedlist()
1173 * Parse skinvar adminskineditallowedlist
1175 * @param string $type template/blog
1176 * @param string $templateName name of template to use
1179 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1183 /* TODO: blog seems not to be used */
1185 $query = "SELECT bshortname, bname FROM %s";
1186 $query = sprintf($query, sql_table('blog'));
1188 'content' => 'shortblognames'
1192 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1193 $query = sprintf($query, sql_table('template_desc'));
1195 'content' => 'shortnames'
1199 Showlist($query, 'table', $show, $templateName);
1204 * AdminActions::parse_adminskinielist()
1205 * Parse skinvar adminskinielist
1207 * @param string $type skin/template
1208 * @param string $templateName name of template to use
1211 public function parse_adminskinielist($type, $templateName = '')
1213 $templates = array();
1214 if ( $templateName )
1216 $templates = Template::read($templateName);
1218 if ( isset($templates['SKINIE_EXPORT_LIST']) && !empty($templates['SKINIE_EXPORT_LIST']) )
1220 $template = $templates['SKINIE_EXPORT_LIST'];
1224 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
1225 . "<td><%expdesc%></td>\n"
1231 $query = "SELECT * FROM %s WHERE sdincmode = 'admin';";
1232 $query = sprintf($query, sql_table('skin_desc'));
1233 $res = sql_query($query);
1235 while ( $skinObj = sql_fetch_object($res) )
1238 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
1239 'expid' => 'skinexp' . $skinObj->sdnumber,
1240 'expname' => Entity::hsc($skinObj->sdname),
1241 'expdesc' => Entity::hsc($skinObj->sddesc),
1243 echo Template::fill($template, $data);
1247 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%'";
1248 $query = sprintf($query, sql_table('template_desc'));
1249 $res = sql_query($query);
1250 while ( $templateObj = sql_fetch_object($res) )
1253 'typeid' => 'template[' . $templateObj->tdnumber . ']',
1254 'expid' => 'templateexp' . $templateObj->tdnumber,
1255 'expname' => Entity::hsc($templateObj->tdname),
1256 'expdesc' => Entity::hsc($templateObj->tddesc),
1258 echo Template::fill($template, $data);
1266 * AdminActions::parse_adminskinoverview()
1267 * Parse skinvar adminskinoverview
1269 * @param string $templateName name of template to use
1272 public function parse_adminskinoverview($templateName = '')
1274 $query = "SELECT * FROM %s WHERE sdincmode = 'admin' ORDER BY sdname;";
1275 $query = sprintf($query, sql_table('skin_desc'));
1277 $template['content'] = 'adminskinlist';
1278 $template['tabindex'] = 10;
1279 $template['friendly_names'] = $this->skin->getAvailableTypes();
1280 Showlist($query, 'table', $template, $templateName);
1285 * AdminActions::parse_adminskinselectoptions()
1286 * Parse skinvar adminskinselectoptions
1291 public function parse_adminskinselectoptions()
1294 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdincmode = 'admin';";
1295 $query = sprintf($query, sql_table('skin_desc'));
1297 $template['name'] = 'adminskin';
1298 $template['selected'] = $CONF['DefaultAdminSkin'];
1299 $template['tabindex'] = 110;
1300 Showlist($query, 'select', $template, '');
1305 * AdminActions::parse_adminspecialskinlist()
1306 * Parse skinvar adminspecialskinlist
1308 * @param string $templateName name of template to use
1310 public function parse_adminspecialskinlist($templateName = '')
1312 $templates = array();
1313 if ( $templateName )
1315 $templates = Template::read($templateName);
1318 $nType = $this->skin->getAvailableTypes();
1319 $skinid = intRequestVar('skinid');
1321 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1322 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1324 $res = sql_query($query);
1325 if ( $res && sql_num_rows($res) > 0 )
1328 if ( array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1330 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1334 $template['head'] = "<ul>\n";
1336 echo Template::fill($template['head'], $data);
1338 if ( array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1340 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1344 $template['body'] = '<li>'
1345 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1348 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1354 while ( $row = sql_fetch_assoc($res) )
1357 'tabindex' => $tabstart++,
1358 'skinid' => $skinid,
1359 'skintype' => Entity::hsc(strtolower($row['stype']))
1361 echo Template::fill($template['body'], $data);
1365 if ( array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1367 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1371 $template['foot'] = "</ul>\n";
1373 echo Template::fill($template['foot'], $data);
1379 * AdminActions::parse_admintemplateoverview()
1380 * Parse skinvar admintemplateoverview
1382 * @param string $templateName name of template to use
1385 public function parse_admintemplateoverview($templateName = '')
1387 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1388 $query = sprintf($query, sql_table('template_desc'));
1390 $template['content'] = 'admintemplatelist';
1391 $template['tabindex'] = 10;
1393 Showlist($query, 'table', $template, $templateName);
1398 * AdminActions::parse_allowedadminskinactions()
1399 * Parse skinvar allowedadminskinactions
1404 public function parse_allowedadminskinactions()
1406 global $DIR_ADMINSKINS;
1407 $skinType = strtolower(trim(requestVar('type')));
1408 $actions = $this->skin->getAllowedActionsForType($skinType);
1411 while ( $current = array_shift($actions) )
1413 // skip deprecated vars
1414 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1419 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1420 // echo "<a href=\"{$DIR_ADMINSKINS}documentation/help.html#{$current}\" onclick=\"if (event && event.preventDefault) event.preventDefault(); return help(this.href);\">{$current}</a>\n";
1422 if ( count($actions) != 0 )
1431 * AdminActions::parse_allowedskinactions()
1432 * Parse skinvar allowedskinactions
1437 public function parse_allowedskinactions()
1439 $skinType = strtolower(trim(requestVar('type')));
1440 $skinid = intRequestVar('skinid');
1441 $skin = new Skin($skinid);
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_blogid()
1639 * Parse skinvar blogid
1644 function parse_blogid()
1646 echo intRequestVar('blogid');
1651 * AdminActions::parse_blognotifysetting()
1652 * Parse skinvar blognotifysetting
1657 public function parse_blognotifysetting($type)
1660 $blogid = intRequestVar('blogid');
1661 $blog = $manager->getBlog($blogid);
1666 if ( !$blog->notifyOnComment() )
1672 if ( !$blog->notifyOnVote() )
1678 if ( !$blog->notifyOnNewItem() )
1684 echo ' checked="checked"';
1689 * AdminActions::parse_blogselectbox()
1690 * Parse skinvar blogselectbox
1695 public function parse_blogselectbox()
1699 $selectData = requestVar('selectData');
1700 $mode = $selectData['mode'];
1701 $name = Entity::hsc($selectData['name']);
1702 $tabindex = Entity::hsc($selectData['tabindex']);
1703 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1704 $showNewCat = intval($selectData['showNewCat']);
1705 $selected = intval($selectData['selected']);
1707 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1709 // 1. select blogs (we'll create optiongroups)
1710 // (only select those blogs that have the user on the team)
1711 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1712 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1713 $blogs = sql_query($queryBlogs);
1715 if ( $mode == 'category' )
1717 if ( sql_num_rows($blogs) > 1 )
1721 while ( $oBlog = sql_fetch_object($blogs) )
1723 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1725 echo '<optgroup label="' . Entity::hsc($oBlog->bname) . "\>\n";
1728 // show selection to create new category when allowed/wanted
1731 // check if allowed to do so
1732 if ( $member->blogAdminRights($oBlog->bnumber) )
1734 echo '<option value="newcat-' . $oBlog->bnumber . '">' . _ADD_NEWCAT . "</option>\n";
1738 // 2. for each category in that blog
1739 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1740 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
1741 $categories = sql_query($catQuery);
1742 while ( $oCat = sql_fetch_object($categories) )
1744 if ( $oCat->catid == $selected )
1746 $selectText = ' selected="selected" ';
1752 echo '<option value="' . $oCat->catid . '" ' . $selectText . '>' . Entity::hsc($oCat->cname) . "</option>\n";
1755 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1764 while ( $oBlog = sql_fetch_object($blogs) )
1766 echo '<option value="' . $oBlog->bnumber . '"';
1767 if ( $oBlog->bnumber == $selected )
1769 echo '<option value="' . $oBlog->bnumber . '" selected="selected">' . Entity::hsc($oBlog->bname) . "</option>\n";
1773 echo '<option value="' . $oBlog->bnumber . '">' . Entity::hsc($oBlog->bname) . "</option>\n";
1782 * AdminActions::parse_blogsetting()
1783 * Parse skinvar blogsetting
1785 * @param string $which name of weblog setting
1788 public function parse_blogsetting($which)
1790 echo $this->parse_getblogsetting($which);
1795 * AdminActions::parse_blogsettingyesno()
1796 * Parse skinvar blogsettingyesno
1798 * @param string $type type of weblog setting
1799 * @param string $templateName name of template to use
1802 public function parse_blogsettingyesno($type, $templateName = '')
1806 $blogid = intRequestVar('blogid');
1807 $blog = $manager->getBlog($blogid);
1811 case 'convertbreaks':
1812 $checkedval = $blog->convertBreaks();
1815 case 'allowpastposting':
1816 $checkedval = $blog->allowPastPosting();
1820 $checkedval = $blog->commentsEnabled();
1824 $checkedval = $blog->isPublic();
1828 $checkedval = $blog->emailRequired();
1832 $checkedval = $blog->getSearchable();
1836 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1841 * AdminActions::parse_blogteamlist()
1842 * Parse skinvar blogteamlist
1844 * @param string $templateName name of template to use
1847 public function parse_blogteamlist($templateName = '')
1850 $blogid = intRequestVar('blogid');
1851 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1853 . "WHERE tmember=mnumber AND tblog= %d";
1854 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1856 $template['content'] = 'teamlist';
1857 $template['tabindex'] = 10;
1859 $batch = new Batch('team');
1860 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1865 * AdminActions::parse_blogteammembers()
1866 * Parse skinvar blogteammembers
1871 public function parse_blogteammembers()
1873 $blogid = intRequestVar('blogid');
1874 $query = "SELECT mname, mrealname "
1876 . "WHERE mnumber=tmember AND tblog=%d;";
1877 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1878 $res = sql_query($query);
1879 $memberNames = array();
1880 while ($o = sql_fetch_object($res)) {
1881 $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
1883 echo implode(',', $memberNames);
1887 * AdminActions::parse_blogtime()
1888 * Parse skinvar blogtime
1890 * @param string $type type of time
1891 * @param string $format format for time expression
1892 * @param integer $offset offset of time
1895 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1899 if ( $type != 'blogtime' )
1901 /* return server time */
1902 $timestamp = time() + $offset;
1906 $bid = intRequestVar('blogid');
1907 $b = $manager->getBlog($bid);
1908 $timestamp = $b->getCorrectTime() + $offset;
1911 echo i18n::formatted_datetime($format, $timestamp);
1916 * AdminActions::parse_bookmarkletadmin()
1917 * Parse skinvar bookmarkletadmin
1922 public function parse_bookmarkletadmin()
1926 $blogid = intRequestVar('blogid');
1928 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1933 * AdminActions::parse_categories()
1934 * Parse skinvar categories
1936 * create category dropdown box
1938 * @param string $type name of setting for category
1941 function parse_categories($startidx = 0)
1945 $itemid = intRequestVar('itemid');
1946 $item =& $manager->getItem($itemid, 1, 1);
1947 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1948 if ($item && $blog->convertBreaks() && requestVar('action') == 'itemedit') {
1949 $item['body'] = removeBreaks($item['body']);
1950 $item['more'] = removeBreaks($item['more']);
1952 $contents = array();
1953 if ( requestVar('action') == 'itemedit' )
1957 if ( isset($contents['catid']) && $contents['catid'] )
1959 $catid = $contents['catid']; // on edit item
1963 $catid = $blog->getDefaultCategory(); // on add item
1965 Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
1969 * AdminActions::parse_category()
1970 * Parse skinvar category
1972 * @param string $type name of setting for category
1975 public function parse_category($type = 'name')
1977 echo $this->parse_getcategory($type);
1982 * AdminActions::parse_categorysetting()
1983 * Parse skinvar categorysetting
1985 * @param string $type type in category setting
1988 public function parse_categorysetting($type)
1990 $catid = intRequestVar('catid');
1991 if ( $type == 'id' )
1996 $blogid = intRequestVar('blogid');
1997 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
1998 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
1999 $res = sql_query($query);
2000 $obj = sql_fetch_object($res);
2002 if ( $type != desc )
2004 echo Entity::hsc($obj->cdesc);
2008 echo Entity::hsc($obj->cname);
2015 * AdminActions::parse_codename()
2016 * Parse templatevar codename
2022 function parse_checkedonval($value, $name) {
2025 $itemid = intRequestVar('itemid');
2026 $item =& $manager->getItem($itemid, 1, 1);
2027 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2028 if ($item && $blog->convertBreaks() && requestVar('action') == 'itemedit') {
2029 $item['body'] = removeBreaks($item['body']);
2030 $item['more'] = removeBreaks($item['more']);
2032 $contents = array();
2033 if ( requestVar('action') == 'itemedit' )
2037 if ( !isset($contents[$name]) )
2039 $contents[$name] = '';
2041 if ($contents[$name] == $value)
2043 echo 'checked="checked"';
2048 * AdminActions::parse_codename()
2049 * Parse templatevar codename
2054 * TODO: is this need???
2056 public function parse_codename()
2059 echo $nucleus['codename'];
2064 * AdminActions::parse_commentnavlist()
2065 * Parse skinvar commentnavlist
2070 public function parse_commentnavlist()
2072 global $CONF, $manager, $member;
2075 if ( postVar('start') )
2077 $start = intPostVar('start');
2084 // amount of items to show
2085 if ( postVar('amount') )
2087 $amount = intPostVar('amount');
2091 $amount = (integer) $CONF['DefaultListSize'];
2097 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2099 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2101 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2103 if ( $this->skintype == 'itemcommentlist' )
2105 $itemid = intRequestVar('itemid');
2106 $query .= " citem={$itemid}";
2107 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2109 $nonComments = _NOCOMMENTS;
2111 elseif ( $this->skintype == 'browseowncomments' )
2114 $query .= ' cmember=' . $member->getID();
2115 $template['canAddBan'] = 0;
2117 $nonComments = _NOCOMMENTS_YOUR;
2119 elseif ( $this->skintype == 'blogcommentlist' )
2122 $query .= ' cblog=' . intRequestVar('blogid');
2123 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2124 $bid = intRequestVar('blogid');
2125 $nonComments = _NOCOMMENTS_BLOG;
2128 $search = postVar('search');
2129 if ( !empty($search) )
2131 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
2134 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2136 $template['content'] = 'commentlist';
2138 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2139 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2144 * AdminActions::parse_configsettingsedit()
2145 * Parse skinvar configsettingsedit
2147 * @param string $type type of global configuration
2150 public function parse_configsettingsedit($type)
2155 case 'DefaultListSize':
2156 if ( !array_key_exists('DefaultListSize', $CONF) )
2158 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2159 $query = sprintf($query, sql_table('config'));
2161 $CONF['DefaultListSize'] = 10;
2163 elseif ( intval($CONF['DefaultListSize']) < 1 )
2165 $CONF['DefaultListSize'] = 10;
2167 echo intval($CONF['DefaultListSize']);
2169 case 'SessionCookie':
2170 $value = $CONF['SessionCookie'];
2171 $txt1 = _SETTINGS_COOKIESESSION;
2172 $txt2 = _SETTINGS_COOKIEMONTH;
2173 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2176 $value = $CONF['URLMode'];
2177 $txt1 = _SETTINGS_URLMODE_NORMAL;
2178 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2179 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2182 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2184 echo Entity::hsc($CONF[$type]);
2192 * AdminActions::parse_configsettingsyesno()
2193 * Parse skinvar configsettingsyesno
2195 * @param string $type type of global setting
2196 * @param integer $tabindex tabindex attribute of input element
2199 public function parse_configsettingsyesno($type, $tabindex)
2202 if ( array_key_exists($type, $CONF) )
2204 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2210 * AdminActions::parse_contents()
2211 * Parse skinvar contents
2213 * @param string $which part for item
2216 function parse_contents($which)
2220 $contents = array();
2221 if ( requestVar('action') == 'itemedit' )
2223 $itemid = intRequestVar('itemid');
2224 $item =& $manager->getItem($itemid, 1, 1);
2225 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2226 if ( $item && $blog->convertBreaks() )
2228 $item['body'] = removeBreaks($item['body']);
2229 $item['more'] = removeBreaks($item['more']);
2233 elseif ( requestVar('action') == 'createitem' )
2235 $blog =& $manager->getBlog(intRequestVar($blogid));
2239 'contents' => &$contents,
2244 if ( !isset($contents[$which]) )
2246 $contents[$which] = '';
2248 echo Entity::hsc($contents[$which],ENT_QUOTES);
2252 * AdminActions::parse_currenttime()
2253 * Parse skinvar currenttime
2255 * @param string $what
2258 function parse_currenttime($what)
2261 if ( requestVar('action') == 'itemedit' )
2263 $itemid = intRequestVar('itemid');
2264 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2266 elseif ( requestVar('action') == 'createitem' )
2268 $blog =& $manager->getBlog(intRequestVar('blogid'));
2270 $nu = getdate($blog->getCorrectTime());
2275 * AdminActions::parse_customhelplink()
2276 * Parse skinvar customhelplink
2278 * @param string $topic name of topic
2279 * @param string $tplName name of template
2280 * @param string $url string as URI
2281 * @param string $iconURL string as URI for icon
2282 * @param string $alt alternative text for image element
2283 * @param string $title title for anchor element
2286 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2288 $this->customHelp($topic, $url, $iconURL);
2293 * AdminActions::parse_date()
2294 * Parse skinvar date
2296 public function parse_date($format = 'c')
2298 global $CONF, $manager;
2299 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2304 * AdminActions::parse_defaultadminskintypes()
2305 * Parse skinvar defaultadminskintypes
2307 * @param string $tabindex index number for tabindex attribute of input element
2308 * @param string $templateName name of template
2311 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2313 $templates = array();
2314 if ( $templateName )
2316 $templates = Template::read($templateName);
2319 $types = $this->skin->getAvailableTypes();
2322 if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
2324 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2328 $template['head'] = "<ul>\n";
2331 echo $template['head'];
2333 if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
2335 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2339 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
2340 . "<%name%></a> <%help%></li>\n";
2342 $handler = new Actions('template', $template, new ADMIN);
2344 $parser = new PARSER($handler);
2346 foreach ( $types as $type => $fName )
2348 $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
2350 'tabindex' => $tabindex,
2351 'skintype' => $type,
2353 'help' => $helplink,
2354 'skinid' => intrequestVar('skinid'),
2356 $templateBody = Template::fill($template['body'], $data);
2357 $parser->parse($templateBody);
2360 if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
2362 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2366 $template['foot'] = " </ul>\n";
2368 echo $template['foot'];
2373 * AdminActions::parse_defblogselect()
2374 * Parse skinvar defblogselect
2376 * @param string $templateName name of template
2379 public function parse_defblogselect($templateName = '')
2382 $query = "SELECT bname as text, bnumber as value FROM %s;";
2383 $query = sprintf($query, sql_table('blog'));
2384 $template['name'] = 'DefaultBlog';
2385 $template['selected'] = $CONF['DefaultBlog'];
2386 $template['tabindex'] = 10;
2387 Showlist($query, 'select', $template, $templateName);
2392 * AdminActions::parse_defcatselect()
2393 * Parse skinvar defcatselect
2395 * @param string $templateName name of template
2398 public function parse_defcatselect($templateName = '')
2401 $blogid = intRequestVar('blogid');
2402 $blog = $manager->getBlog($blogid);
2403 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2404 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2405 $template['name'] = 'defcat';
2406 $template['selected'] = $blog->getDefaultCategory();
2407 $template['tabindex'] = 110;
2408 Showlist($query, 'select', $template, $templateName);
2413 * AdminActions::parse_defskinselect()
2414 * Parse skinvar defskinselect
2416 * @param string $type type of skin
2417 * @param string $templateName name of template
2420 public function parse_defskinselect($type = 'blog', $templateName = '')
2423 $query = "SELECT sdname as text, sdnumber as value FROM %s;";
2424 $query = sprintf($query, sql_table('skin_desc'));
2426 $blogid = intRequestVar('blogid');
2431 $template['selected'] = $CONF['BaseSkin'];
2435 $blog = $manager->getBlog($blogid);
2436 $template['selected'] = $blog->getDefaultSkin();
2439 if ( $type != 'blog' )
2441 $nname = 'BaseSkin';
2448 $template['name'] = $nname;
2449 $template['tabindex'] = 50;
2450 Showlist($query, 'select', $template, $templateName);
2455 * AdminActions::parse_deletecomment()
2456 * Parse skinvar deletecomment
2458 * @param string $type type of infomation for comment
2461 public function parse_deletecomment($type = 'id')
2463 $commentid = intRequestVar('commentid');
2464 $comment = COMMENT::getComment($commentid);
2469 echo intRequestVar('commentid');
2472 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2474 echo $comment['member'];
2478 echo $comment['user'];
2482 $body = strip_tags($comment['body']);
2483 echo Entity::hsc(shorten($body, 300, '...'));
2489 * AdminActions::parse_deleteitembody()
2490 * Parse skinvar deleteitembody
2495 public function parse_deleteitembody()
2498 $itemid = intRequestVar('itemid');
2499 $item =& $manager->getItem($itemid, 1, 1);
2500 $body = strip_tags($item['body']);
2501 echo Entity::hsc(shorten($body, 300, '...'));
2506 * AdminActions::parse_deleteitemid()
2507 * Parse skinvar deleteitemid
2512 public function parse_deleteitemid()
2514 echo (integer) intRequestVar('itemid');
2519 * AdminActions::parse_deleteitemtitle()
2520 * Parse skinvar deleteitemtitle
2525 public function parse_deleteitemtitle()
2528 $itemid = intRequestVar('itemid');
2529 $item =& $manager->getItem($itemid, 1, 1);
2530 echo Entity::hsc(strip_tags($item['title']));
2535 * AdminActions::parse_editadminskin()
2536 * Parse skinvar editadminskin
2538 * @param string $type type of skin setting
2541 public function parse_editadminskin($type = 'id')
2543 $skinid = intRequestVar('skinid');
2544 $skin = new Skin($skinid);
2548 echo intRequestVar('skinid');
2551 echo Entity::hsc($skin->getName());
2554 echo Entity::hsc($skin->getDescription());
2557 echo Entity::hsc($skin->getContentType());
2560 echo Entity::hsc($skin->getIncludePrefix());
2563 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2571 * AdminActions::parse_editadminskintype()
2572 * Parse skinvar editadminskintype
2574 * @param string $type name of skin type
2577 public function parse_editadminskintype($type = 'id')
2579 global $CONF, $manager, $member;
2580 // $skinid = intRequestVar('skinid');
2581 // $skin = new Skin($skinid);
2582 $fNames = $this->skin->getAvailableTypes();
2583 $sType = strtolower(trim(requestVar('type')));
2588 echo intRequestVar('skinid');
2591 echo Entity::hsc($this->skin->getName());
2594 echo Entity::hsc($this->skin->getDescription());
2597 echo Entity::hsc($this->skin->getContentType());
2600 echo Entity::hsc($this->skin->getContentFromDB($sType));
2603 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2604 echo Entity::hsc($skinType);
2607 echo Entity::hsc($sType);
2610 echo Entity::hsc($this->skin->getIncludePrefix());
2613 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2614 echo Entity::hsc($incMode);
2623 * AdminActions::parse_editadmintemplateinfo()
2624 * Parse skinvar editadmintemplateinfo
2626 * @param string $type type of skin template
2627 * @param string $description description of template
2628 * @param string $name name of stemplate
2629 * @param string $tabindex index number for tabindex attribute of input element
2630 * @param string $big
2631 * @param string $tplt
2633 public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2636 $templateid = intRequestVar('templateid');
2637 $templatename = Template::getNameFromId($templateid);
2638 $templatedescription = Template::getDesc($templateid);
2639 $template =& Template::read($templatename);
2643 echo intval($templateid);
2646 echo Entity::hsc($templatename);
2649 echo Entity::hsc($templatedescription);
2651 case 'extratemplate':
2653 $pluginfields = array();
2655 'AdminTemplateExtraFields',
2657 'fields' => &$pluginfields
2663 $tmplt = Template::read($description);
2665 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2667 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2673 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2675 foreach ( $pluginfields as $pfkey => $pfvalue )
2678 'explugtplname' => Entity::hsc($pfkey)
2680 echo Template::fill($base, $data);
2681 foreach ( $pfvalue as $pffield => $pfdesc )
2683 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2688 $desc = defined($description) ? constant($description) : $description;
2689 $name = defined($name) ? constant($name) : $name;
2690 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2697 * AdminActions::parse_editcomment()
2698 * Parse skinvar editcomment
2700 * @param string $type type of comment setting
2703 public function parse_editcomment($type = 'id')
2706 $commentid = intRequestVar('commentid');
2707 $comment = COMMENT::getComment($commentid);
2709 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2714 echo intRequestVar('commentid');
2717 if (array_key_exists('member', $comment) && !empty($comment['member']) )
2719 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2723 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2727 echo date("Y-m-d @ H:i", $comment['timestamp']);
2730 $comment['body'] = str_replace('<br />', '', $comment['body']);
2731 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2732 echo $comment['body'];
2734 echo $comment[$type];
2741 * AdminActions::parse_editdesturl()
2742 * Parse skinvar editdesturl
2744 public function parse_editdesturl()
2746 if ( requestVar('desturl') )
2748 echo Entity::hsc(requestVar('desturl'));
2754 * AdminActions::parse_editmemberlist()
2755 * Parse skinvar editmemberlist
2757 * @param string $templateName name of template
2760 public function parse_editmemberlist($templateName = '')
2763 // show list of members with actions
2764 $query = 'SELECT * FROM '.sql_table('member');
2765 $template['content'] = 'memberlist';
2766 $template['tabindex'] = 10;
2768 $batch = new Batch('member');
2769 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2774 * AdminActions::parse_editmember()
2775 * Parse skinvar editmember
2777 * @param string $type type of information for member
2778 * @return string $tempateName name of template to use
2781 public function parse_editmember($type = 'id', $templateName = '')
2783 global $CONF, $manager, $member;
2784 $memberid = intRequestVar('memberid');
2785 $mem = MEMBER::createFromID($memberid);
2790 echo intRequestVar('memberid');
2793 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2795 echo Entity::hsc($mem->getDisplayName());
2799 $dispName = Entity::hsc($mem->getDisplayName());
2800 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2802 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2811 echo Entity::hsc($mem->getRealName());
2814 echo Entity::hsc($mem->getEmail());
2817 echo Entity::hsc($mem->getURL());
2820 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2823 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2826 echo Entity::hsc($mem->getNotes());
2829 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2838 * AdminActions::parse_editpluginfo()
2839 * Parse skinvar editpluginfo
2841 * @param string $type type of plugin info
2844 public function parse_editpluginfo($type)
2846 $pid = intRequestVar('plugid');
2853 echo Entity::hsc(getPluginNameFromPid($pid));
2860 * AdminActions::parse_editplugoptionslist()
2861 * Parse skinvar editplugoptionslist
2863 * @param string $templateName name of template
2866 public function parse_editplugoptionslist($templateName = '')
2870 $pid = intRequestVar('plugid');
2871 $aOptions = array();
2874 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
2875 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2876 $resource = sql_query($query);
2878 while ( $o = sql_fetch_object($resource) )
2880 array_push($aOIDs, $o->oid);
2881 $aOptions[$o->oid] = array(
2884 'value' => $o->odef,
2885 'name' => $o->oname,
2886 'description' => $o->odesc,
2887 'type' => $o->otype,
2888 'typeinfo' => $o->oextra,
2893 // fill out actual values
2894 if ( count($aOIDs) > 0 )
2896 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2897 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2899 $result = sql_query($query);
2901 while ( $o = sql_fetch_object($result) )
2903 $aOptions[$o->oid]['value'] = $o->ovalue;
2909 'PrePluginOptionsEdit',
2911 'context' => 'global',
2913 'options' => &$aOptions
2917 $template['content'] = 'plugoptionlist';
2918 $amount = Showlist($aOptions, 'table', $template, $templateName);
2921 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2927 * AdminActions::parse_editskin()
2928 * Parse skinvar editskin
2930 * @param string $type type of skin
2933 public function parse_editskin($type = 'id')
2935 $skinid = intRequestVar('skinid');
2936 $skin = new SKIN($skinid);
2940 echo intRequestVar('skinid');
2943 echo Entity::hsc($skin->getName());
2946 echo Entity::hsc($skin->getDescription());
2949 echo Entity::hsc($skin->getContentType());
2952 echo Entity::hsc($skin->getIncludePrefix());
2955 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2963 * AdminActions::parse_editskintype()
2964 * Parse skinvar editskintype
2966 * @param string $type name of type for skin type
2969 public function parse_editskintype($type = 'id')
2971 global $CONF, $manager, $member;
2972 $skinid = intRequestVar('skinid');
2973 $skin = new SKIN($skinid);
2974 $fNames = $skin->getAvailableTypes();
2975 $sType = strtolower(trim(requestVar('type')));
2980 echo intRequestVar('skinid');
2983 echo Entity::hsc($skin->getName());
2986 echo Entity::hsc($skin->getDescription());
2989 echo Entity::hsc($skin->getContentType());
2992 echo Entity::hsc($skin->getContentFromDB($sType));
2995 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2996 echo Entity::hsc($skinType);
2999 echo Entity::hsc($sType);
3002 echo Entity::hsc($skin->getIncludePrefix());
3005 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
3006 echo Entity::hsc($incMode);
3015 * AdminActions::parse_adminurl()
3016 * Parse skinvar adminurl
3017 * (shortcut for admin url)
3022 public function parse_adminurl()
3024 $this->parse_sitevar('adminurl');
3029 * AdminActions::parse_edittemplateinfo()
3030 * Parse skinvar edittemplateinfo
3032 * @param string $type name of type for skin
3033 * @param string $description description for skin
3034 * @param string $name name of skin
3035 * @param string $help
3036 * @param string $tabindex index value for tabindex attribute of input element
3037 * @param string $big
3038 * @param string $tplt name of template
3040 public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3043 $templateid = intRequestVar('templateid');
3044 $templatename = Template::getNameFromId($templateid);
3045 $templatedescription = Template::getDesc($templateid);
3046 $template =& $manager->getTemplate($templatename);
3050 echo intval($templateid);
3053 echo Entity::hsc($templatename);
3056 echo Entity::hsc($templatedescription);
3058 case 'extratemplate':
3060 $pluginfields = array();
3062 'TemplateExtraFields',
3064 'fields' => &$pluginfields
3070 $tmplt = Template::read($description);
3072 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3074 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3078 $base = "</tr><tr>\n"
3079 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3081 foreach ( $pluginfields as $pfkey => $pfvalue )
3084 'explugtplname' => Entity::hsc($pfkey)
3086 echo Template::fill($base, $data);
3087 foreach ( $pfvalue as $pffield => $pfdesc )
3089 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3094 $desc = defined($description) ? constant($description) : $description;
3095 $name = defined($name) ? constant($name) : $name;
3096 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3103 * AdminActions::parse_eventformextra()
3104 * Parse skinvar eventformextra
3106 * @param string $type name of type for event form extra
3109 public function parse_eventformextra($type = 'activation')
3115 $key = requestVar('ackey');
3118 Admin::error(_ERROR_ACTIVATE);
3120 $info = MEMBER::getActivationInfo($key);
3123 Admin::error(_ERROR_ACTIVATE);
3125 $mem = MEMBER::createFromId($info->vmember);
3128 Admin::error(_ERROR_ACTIVATE);
3131 'type' => 'activation',
3135 case 'membermailform-notloggedin':
3137 'type' => 'membermailform-notloggedin',
3141 $manager->notify('FormExtra', $data);
3146 * AdminActions::parse_extrahead()
3147 * Parse skinvar extrahead
3149 public function parse_extrahead()
3152 $extrahead = Admin::getAdminextrahead();
3156 'extrahead' => &$extrahead,
3157 'action' => Admin::getAdminAction()
3166 * AdminActions::parse_member()
3167 * Parse skinvar member
3168 * (includes a member info thingie)
3170 * @param string $what which memberdata is needed
3173 public function parse_member($what)
3175 global $memberinfo, $member, $CONF;
3177 // 1. only allow the member-details-page specific variables on member pages
3178 if ( $this->skintype == 'member' )
3183 echo Entity::hsc($memberinfo->getDisplayName());
3186 echo Entity::hsc($memberinfo->getRealName());
3189 echo Entity::hsc($memberinfo->getNotes());
3192 echo Entity::hsc($memberinfo->getURL());
3195 echo Entity::hsc($memberinfo->getEmail());
3198 echo Entity::hsc($memberinfo->getID());
3203 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3204 if ( $member->isLoggedIn() )
3209 echo $member->getDisplayName();
3211 case 'yourrealname':
3212 echo $member->getRealName();
3215 echo $member->getNotes();
3218 echo $member->getURL();
3221 echo $member->getEmail();
3224 echo $member->getID();
3226 case 'yourprofileurl':
3227 if ($CONF['URLMode'] == 'pathinfo')
3228 echo Link::create_member_link($member->getID());
3230 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3238 * AdminActions::parse_version()
3239 * Parse skinvar version
3240 * (include nucleus versionnumber)
3245 public function parse_version()
3248 echo 'Nucleus CMS ' . $nucleus['version'];
3253 * AdminActions::parse_sitevar()
3254 * Parse skinvar sitevar
3255 * (include a sitevar)
3257 * @param string $which
3260 public function parse_sitevar($which)
3266 echo $CONF['IndexURL'];
3269 echo $CONF['SiteName'];
3272 echo $CONF['AdminEmail'];
3275 echo $CONF['AdminURL'];
3281 * AdminActions::parse_charset()
3282 * Parse skinvar charset
3287 public function parse_charset()
3289 echo i18n::get_current_charset();
3294 * AdminActions::parse_getblogsetting()
3295 * Parse skinvar getblogsetting
3297 public function parse_getblogsetting($which)
3305 elseif ( $bid = intRequestVar('blogid') )
3308 $b = $manager->getBlog($bid);
3318 return Entity::hsc($b->getID());
3321 return Entity::hsc($b->getURL());
3324 return Entity::hsc($b->getName());
3327 return Entity::hsc($b->getDescription());
3330 return Entity::hsc($b->getShortName());
3332 case 'notifyaddress':
3333 return Entity::hsc($b->getNotifyAddress());
3336 return Entity::hsc($b->getMaxComments());
3339 return Entity::hsc($b->getUpdateFile());
3342 return Entity::hsc($b->getTimeOffset());
3349 * AdminActions::parse_geteditpluginfo()
3350 * Parse skinvar geteditpluginfo
3352 * @param string $type name of setting for edit plugin info
3355 public function parse_geteditpluginfo($type)
3357 $pid = intRequestVar('plugid');
3364 return Entity::hsc(getPluginNameFromPid($pid));
3371 * AdminActions::parse_getmember()
3372 * Parse skinvar getmember
3373 * (includes a member info thingie)
3375 * @param string $what name of setting for member
3378 public function parse_getmember($what)
3380 global $memberinfo, $member;
3381 // 1. only allow the member-details-page specific variables on member pages
3382 if ( $this->skintype == 'member' )
3387 return Entity::hsc($memberinfo->getDisplayName());
3390 return Entity::hsc($memberinfo->getRealName());
3393 return Entity::hsc($memberinfo->getNotes());
3396 return Entity::hsc($memberinfo->getURL());
3399 return Entity::hsc($memberinfo->getEmail());
3402 return Entity::hsc($memberinfo->getID());
3406 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3407 if ( $member->isLoggedIn() )
3412 return $member->getDisplayName();
3414 case 'yourrealname':
3415 return $member->getRealName();
3418 return $member->getNotes();
3421 return $member->getURL();
3424 return $member->getEmail();
3427 return $member->getID();
3435 * AdminActions::parse_headmessage()
3436 * Parse skinvar headmessage
3441 public function parse_headmessage()
3443 if ( !empty(Admin::$headMess) )
3445 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3451 * AdminActions::parse_helplink()
3452 * Parse skinvar helplink
3454 * @param string $topic name of topic for help
3457 public function parse_helplink($topic = '')
3459 if ( empty($topic) )
3468 * AdminActions::parse_helpplugname()
3469 * Parse skinvar helpplugname
3474 public function parse_helpplugname()
3476 $plugid = intGetVar('plugid');
3477 Entity::hsc(getPluginNameFromPid($plugid));
3482 * AdminActions::parse_ilistaddnew()
3483 * Parse skinvar ilistaddnew
3488 public function parse_ilistaddnew()
3490 $blogid = intRequestVar('blogid');
3491 if ( intPostVar('start') == 0 )
3493 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3499 * AdminActions::parse_importskininfo()
3500 * Parse skinvar importskininfo
3502 * @param string $type name of information for imported skin
3505 public function parse_importskininfo($type)
3510 echo Entity::hsc(requestVar('skininfo'));
3513 $dataArr = requestArray('skinnames');
3514 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3517 $dataArr = requestArray('tpltnames');
3518 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3521 $dataArr = requestArray('skinclashes');
3522 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3525 $dataArr = requestArray('tpltclashes');
3526 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3529 echo Entity::hsc(requestVar('skinfile'));
3532 echo Entity::hsc(requestVar('mode'));
3539 * AdminActions::parse_inputyesno()
3540 * Parse skinvar inputyesno
3542 * some init stuff for all forms
3546 function parse_init()
3550 if ( requestVar('action') == 'itemedit' )
3552 $itemid = intRequestVar('itemid');
3553 $item =& $manager->getItem($itemid, 1, 1);
3554 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3555 if ( $item && $blog->convertBreaks() )
3557 $item['body'] = removeBreaks($item['body']);
3558 $item['more'] = removeBreaks($item['more']);
3561 $authorid = $contents['authorid'];
3563 elseif ( requestVar('action') == 'createitem' )
3565 $blog =& $manager->getBlog(intRequestVar($blogid));
3568 $blog->insertJavaScriptInfo($authorid);
3572 * AdminActions::parse_inputyesno()
3573 * Parse skinvar inputyesno
3575 * @param string $name
3576 * @param string $checkedval
3577 * @param string $tabindex
3578 * @param string $value1
3579 * @param string $value2
3580 * @param string $yesval
3581 * @param string $noval
3582 * @param string $isAdmin
3583 * @param string $templateName
3586 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3588 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3593 * AdminActions::parse_insertpluginfo()
3594 * Parse templatevar insertpluginfo
3596 public function parse_insertpluginfo($type)
3598 $option = Admin::$aOptions;
3602 return $option['pid'];
3605 return Entity::hsc($option['pfile']);
3612 * AdminActions::parse_insertpluginoptions()
3613 * Parse skinvar insertpluginoptions
3615 * @param string $templateName name of template
3618 public function parse_insertpluginoptions($templateName = '')
3620 $options = Admin::getAdminaOption();
3621 $template = array();
3622 $templats = array();
3624 if ( $templateName )
3626 $templates = Template::read($templateName);
3628 if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
3630 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3634 $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
3636 if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
3638 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3642 $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
3647 foreach ( $options as $option )
3649 $handler = new Actions($this->skintype, $template, $option);
3651 $parser = new PARSER($handler);
3654 if ( $prevPid != $option['pid'] )
3656 $prevPid = $option['pid'];
3657 $parser->parse($template['title']);
3659 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3660 if ( @$meta['access'] != 'hidden' )
3662 $parsed = $parser->parse($template['body']);
3669 * AdminActions::parse_insplugoptcontent()
3670 * Parse skinvar insplugoptcontent
3675 public function parse_insplugoptcontent()
3677 $option = Admin::$aOption;
3679 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3680 if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
3683 listplug_plugOptionRow($option);
3690 * AdminActions::parse_iprangeinput()
3691 * Parse skinvar iprangeinput
3696 public function parse_iprangeinput()
3698 if ( requestVar('ip') )
3700 $iprangeVal = Entity::hsc(requestVar('ip'));
3701 echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
3702 echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
3703 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3704 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3705 echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
3709 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3710 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3716 * AdminActions::parse_itemnavlist()
3717 * Parse skinvar itemnavlist
3722 public function parse_itemnavlist()
3724 global $CONF, $manager, $member;
3725 if ( $this->skintype == 'itemlist' )
3727 $blogid = intRequestVar('blogid');
3728 $blog =& $manager->getBlog($blogid);
3730 if ( postVar('start') )
3732 $start = intPostVar('start');
3739 // amount of items to show
3740 if ( postVar('amount') )
3742 $amount = intPostVar('amount');
3746 $amount = intval($CONF['DefaultListSize']);
3752 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3753 . " FROM %s, %s, %s, %s"
3754 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3756 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3758 if ( $this->skintype == 'itemlist' )
3760 $query .= ' AND iblog = ' . $blogid;
3761 $template['now'] = $blog->getCorrectTime(time());
3763 // non-blog-admins can only edit/delete their own items
3764 if ( !$member->blogAdminRights($blogid) )
3766 $query .= ' AND iauthor = ' . $member->getID();
3769 elseif ( $this->skintype == 'browseownitems' )
3771 $query .= ' AND iauthor = ' . $member->getID();
3773 $template['now'] = time();
3776 // search through items
3777 $search = postVar('search');
3779 if ( !empty($search) )
3781 $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
3782 . ' OR (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
3783 . ' OR (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
3785 $query .= ' ORDER BY itime DESC'
3786 . " LIMIT {$start},{$amount}";
3788 $template['content'] = 'itemlist';
3790 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3791 $navList->showBatchList('item', $query, 'table', $template);
3796 * AdminActions::parse_itemoptions()
3797 * Parse skinvar itemoptions
3798 * Adds the itemOptions of a plugin to a page
3801 function parse_itemoptions()
3803 $this->parse_pluginoptions($type = 'item');
3805 // Admin::insertPluginOptions('item', $itemid);
3809 * AdminActions::parse_itemoptions()
3811 * date change on edit item
3813 * Parse skinvar itemoptions
3814 * Adds the itemOptions of a plugin to a page
3817 function parse_itemtime($what)
3821 $itemid = intRequestVar('itemid');
3822 $item =& $manager->getItem($itemid, 1, 1);
3823 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3824 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3826 $item['body'] = removeBreaks($item['body']);
3827 $item['more'] = removeBreaks($item['more']);
3829 $contents = array();
3830 if ( requestVar('action') == 'itemedit' )
3834 elseif ( requestVar('action') == 'createitem' )
3839 'contents' => &$contents,
3840 'blog' => &$this->blog
3844 $itemtime = getdate($contents['timestamp']);
3845 echo $itemtime[$what];
3849 * AdminActions::parse_jstoolbaroptions()
3850 * Parse skinvar jstoolbaroptions
3855 public function parse_jstoolbaroptions()
3859 _SETTINGS_JSTOOLBAR_NONE,
3860 _SETTINGS_JSTOOLBAR_SIMPLE,
3861 _SETTINGS_JSTOOLBAR_FULL
3864 foreach ( $options as $option )
3866 $text = "<option value=\"%d\"%s>%s</option>\n";
3867 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3868 echo sprintf($text, $i, $extra, $option);
3874 * Parse skinvar languageselectoptions
3876 function parse_languageselectoptions()
3878 $locales = i18n::get_available_locale_list();
3879 $memid = intRequestVar('memberid');
3882 $mem = MEMBER::createFromID($memid);
3883 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3885 echo "<option value=\"\" selected=\"selected\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3889 echo "<option value=\"\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3894 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3896 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3899 foreach ( $locales as $locale )
3903 if ( $locale == $mem->getLocale() )
3905 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3909 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3914 if ( $locale == i18n::get_current_locale() )
3916 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3920 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3927 * AdminActions::parse_localeselectoptions()
3928 * Parse skinvar localeselectoptions
3933 public function parse_localeselectoptions()
3935 $locales = i18n::get_available_locale_list();
3936 $memid = intRequestVar('memberid');
3939 $mem = MEMBER::createFromID($memid);
3940 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3942 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3946 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3951 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3953 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3956 foreach ( $locales as $locale )
3960 if ( $locale == $mem->getLocale() )
3962 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3966 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3971 if ( $locale == i18n::get_current_locale() )
3973 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3977 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3985 * AdminActions::parse_listplugplugoptionrow()
3986 * Parse templatevar listplugplugoptionrow
3988 * @param string $templateName name of template
3991 public function parse_listplugplugoptionrow($templateName = '')
3993 echo listplug_plugOptionRow(Admin::$aOptions, $templateName);
3998 * AdminActions::parse_mediadirwarning()
3999 * Parse skinvar mediadirwarning
4004 public function parse_mediadirwarning()
4007 if ( !is_dir($DIR_MEDIA) )
4009 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4011 if ( !is_readable($DIR_MEDIA) )
4013 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4015 if ( !is_writeable($DIR_MEDIA) )
4017 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4023 * AdminActions::parse_movedistselect()
4024 * Parse skinvar movedistselect
4026 public function parse_movedistselect()
4028 $actionType = requestVar('action');
4029 switch ( $actionType )
4032 Admin::selectBlogCategory('destcatid');
4034 case 'batchcategory':
4035 Admin::selectBlog('destblogid');
4038 if ( $this->skintype == 'itemmove' )
4040 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
4041 $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
4042 $catid = quickQuery(sprintf($query, intRequestVar('itemid')));
4043 Admin::selectBlogCategory('catid', $catid, 10, 1);
4051 * AdminActions::parse_moveitemid()
4052 * Parse skinvar moveitemid
4057 public function parse_moveitemid()
4059 echo intRequestVar('itemid');
4064 * AdminActions::parse_newestcompare()
4065 * Parse skinvar newestcompare
4070 public function parse_newestcompare()
4073 $newestVersion = getLatestVersion();
4074 $newestCompare = str_replace('/', '.', $newestVersion);
4075 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4076 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4078 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4079 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4085 * AdminActions::parse_newmemberselect()
4086 * Parse skinvar newmemberselect
4088 * @param string $templateName name of template to use
4091 public function parse_newmemberselect($templateName = '')
4093 $blogid = intRequestVar('blogid');
4095 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4096 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4097 $res = sql_query($query);
4100 while ( $tmember = sql_fetch_object($res) )
4102 $tmem[] = intval($tmember->tmember);
4105 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4106 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4108 $template['name'] = 'memberid';
4109 $template['tabindex'] = 10000;
4110 Showlist($query, 'select', $template, $templateName);
4115 * AdminActions::parse_newpluginlist()
4116 * Parse skinvar newpluginlist
4121 public function parse_newpluginlist()
4123 $candidates = $this->newPlugCandidates;
4124 foreach ( $candidates as $name )
4126 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4132 * AdminActions::parse_outputspecialdirs()
4133 * Parse skinvar outputspecialdirs
4135 * @param string $type type of setting for directory
4138 public function parse_outputspecialdirs($type)
4143 global $DIR_NUCLEUS;
4144 echo Entity::hsc($DIR_NUCLEUS);
4148 echo Entity::hsc($DIR_MEDIA);
4155 * AdminActions::parse_passrequestvars()
4156 * Parse skinvar passrequestvars
4161 public function parse_passrequestvars()
4163 $passvar = Admin::getAdminpassvar();
4164 $oldaction = postVar('oldaction');
4165 if ( ($oldaction != 'logout')
4166 && ($oldaction != 'login')
4168 && !postVar('customaction') )
4176 * AdminActions::parse_pluginextras()
4177 * Parse skinvar pluginextras
4179 * @param string $type type of plugin context
4182 public function parse_pluginextras($type = 'global')
4188 $id = intRequestVar('memberid');
4189 $mem = MEMBER::createFromID($id);
4191 'MemberSettingsFormExtras',
4198 $id = intRequestVar('blogid');
4199 $blg = $manager->getBlog($id);
4201 'BlogSettingsFormExtras',
4209 'GeneralSettingsFormExtras',
4219 * AdminActions::parse_pluginhelp()
4220 * Parse skinvar pluginhelp
4225 public function parse_pluginhelp()
4227 global $manager, $DIR_PLUGINS;
4228 $plugid = intGetVar('plugid');
4229 $plugName = getPluginNameFromPid($plugid);
4230 $plug =& $manager->getPlugin($plugName);
4232 if ( $plug->supportsFeature('HelpPage') > 0 )
4234 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4235 if ( @file_exists($helpfile . 'php') )
4237 @include($helpfile . 'php');
4240 elseif ( @file_exists($helpfile . 'html') )
4242 @include($helpfile . 'html');
4246 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4247 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4252 * AdminActions::parse_pluginlistlist()
4253 * Parse skinvar pluginlistlist
4255 * @param string $templateName name of template to use
4258 public function parse_pluginlistlist($templateName = '')
4260 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4261 $query = sprintf($query, sql_table('plugin'));
4262 $template['content'] = 'pluginlist';
4263 $template['tabindex'] = 10;
4264 Showlist($query, 'table', $template, $templateName);
4269 * AdminActions::parse_pluginoptions()
4270 * Parse skinvar pluginoptions
4272 * @param string $type type of plugin option
4275 public function parse_pluginoptions($type = 'global')
4280 $id = intRequestVar('memberid');
4283 $id = intRequestVar('blogid');
4286 $id = intRequestVar('catid');
4292 Admin::insertPluginOptions($type, $id);
4297 * AdminActions::parse_qmenuaddselect()
4298 * Parse skinvar qmanuaddselect
4300 * @param string $templateName name of template to use
4303 public function parse_qmenuaddselect($templateName = '')
4306 $showAll = requestVar('showall');
4307 if ( $member->isAdmin() && ($showAll == 'yes') )
4309 // Super-Admins have access to all blogs! (no add item support though)
4310 $query = 'SELECT bnumber as value, bname as text'
4311 . ' FROM ' . sql_table('blog')
4312 . ' ORDER BY bname';
4316 $query = 'SELECT bnumber as value, bname as text'
4317 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4318 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4319 . ' ORDER BY bname';
4321 $template['name'] = 'blogid';
4322 $template['tabindex'] = 15000;
4323 $template['extra'] = _QMENU_ADD_SELECT;
4324 $template['selected'] = -1;
4325 $template['shorten'] = 10;
4326 $template['shortenel'] = '';
4327 $template['javascript'] = 'onchange="return form.submit()"';
4328 Showlist($query, 'select', $template, $templateName);
4333 * AdminActions::parse_quickmenu()
4334 * Parse skinvar quickmenu
4336 * @param string $templateName name of template to use
4339 public function parse_quickmenu($templateName = '')
4342 $templates = array();
4343 $template = array();
4344 if ( !empty($templateName) )
4346 $templates = Template::read($templateName);
4348 $pluginExtras = array();
4352 'options' => &$pluginExtras
4355 if ( count($pluginExtras) > 0 )
4357 if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4359 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4363 $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
4365 $handler = new Actions($this->skintype);
4367 $parser = new PARSER($handler);
4368 $parser->parse($template['title']);
4370 if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4372 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4376 $template['head'] = '<ul>';
4379 echo $template['head'];
4381 if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
4383 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4387 $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
4390 foreach ( $pluginExtras as $aInfo )
4393 'plugadminurl' => Entity::hsc($aInfo['url']),
4394 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4395 'plugadmintitle' => Entity::hsc($aInfo['title']),
4397 echo Template::fill($template['body'], $data);
4399 if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4401 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4405 $template['foot'] = '</ul>';
4407 echo $template['foot'];
4413 * AdminActions::parse_requestblogid()
4414 * Parse skinvar requestblogid
4419 public function parse_requestblogid()
4421 echo intRequestVar('blogid');
4426 * AdminActions::parse_requestiprange()
4427 * Parse skinvar requestiprange
4432 public function parse_requestiprange()
4434 if ( requestVar('iprange') )
4436 echo Entity::hsc(requestVar('iprange'));
4438 elseif ( requestVar('ip') )
4440 echo Entity::hsc(requestVar('ip'));
4446 * AdminActions::parse_selectlocaladminskinfiles()
4447 * Parse skinvar selectlocaladminskinfiles
4452 public function parse_selectlocaladminskinfiles()
4455 global $DIR_SKINS, $manager;
4456 $adminskindir = $DIR_SKINS . 'admin/';
4457 $candidates = SkinImport::searchForCandidates($adminskindir);
4458 foreach ( $candidates as $skinname => $skinfile )
4460 $html = Entity::hsc($skinfile);
4461 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4467 * AdminActions::parse_selectlocalskinfiles()
4468 * Parse skinvar selectlocalskinfiles
4473 public function parse_selectlocalskinfiles()
4476 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4477 foreach ( $candidates as $skinname => $skinfile )
4479 $html = Entity::hsc($skinfile);
4480 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4486 * AdminActions::parse_skineditallowedlist()
4487 * Parse skinvar skineditallowedlist
4489 * @param string $type type of skin
4490 * @param string $templateName name of template
4493 public function parse_skineditallowedlist($type, $templateName = '')
4498 $query = "SELECT bshortname, bname FROM %s";
4500 'content' => 'shortblognames'
4502 $query = sprintf($query, sql_table('blog'));
4503 Showlist($query, 'table', $show, $templateName);
4506 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%'";
4508 'content' => 'shortnames'
4510 $query = sprintf($query, sql_table('template_desc'));
4511 Showlist($query, 'table', $show, $templateName);
4518 * AdminActions::parse_skinielist()
4519 * Parse skinvar skinielist
4521 * @param string $type type of skin
4522 * @param string $templateName name of template to use
4525 public function parse_skinielist($type, $templateName = '')
4527 $templates = array();
4528 if ( $templateName )
4530 $templates = Template::read($templateName);
4532 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4534 $template = $templates['SKINIE_EXPORT_LIST'];
4538 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
4539 . "<td><%expdesc%></td>\n"
4545 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
4546 while ( $skinObj = sql_fetch_object($res) )
4549 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
4550 'expid' => 'skinexp' . $skinObj->sdnumber,
4551 'expname' => Entity::hsc($skinObj->sdname),
4552 'expdesc' => Entity::hsc($skinObj->sddesc),
4554 echo Template::fill($template, $data);
4558 $res = sql_query('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%'");
4559 while ($templateObj = sql_fetch_object($res)) {
4561 'typeid' => 'template[' . $templateObj->tdnumber . ']',
4562 'expid' => 'templateexp' . $templateObj->tdnumber,
4563 'expname' => Entity::hsc($templateObj->tdname),
4564 'expdesc' => Entity::hsc($templateObj->tddesc),
4566 echo Template::fill($template, $data);
4574 * AdminActions::parse_skinoverview()
4575 * Parse skinvar skinoverview
4577 * @param string $templateName name of template to use
4580 public function parse_skinoverview($templateName = '')
4583 $query = "SELECT * FROM %s WHERE sdincmode != 'admin' ORDER BY sdname";
4584 $query = sprintf($query, sql_table('skin_desc'));
4586 $template['content'] = 'skinlist';
4587 $template['tabindex'] = 10;
4588 // $template['friendly_names'] = Skin::getFriendlyNames('Actions');
4589 $skin = new Skin($CONF['BaseSkin']);
4590 $template['friendly_names'] = $skin->getDefaultTypes();
4592 Showlist($query, 'table', $template, $templateName);
4597 * AdminActions::parse_skintypehelp()
4598 * Check editing skintypehelp
4603 public function parse_skintypehelp()
4605 $nowSkinType = strtolower(trim(requestVar('type')));
4606 $regularType = array(
4617 if ( in_array($nowSkinType, $regularType) )
4619 help('skinpart' . $nowSkinType);
4623 help('skinpartspecial');
4629 * AdminActions::parse_specialskinlist()
4630 * Parse skinvar specialskinlist
4632 * @param string $templateName name of template to use
4635 public function parse_specialskinlist($templateName = '')
4637 $templates = array();
4638 if ( $templateName )
4640 $templates = Template::read($templateName);
4652 $skinid = intRequestVar('skinid');
4653 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4654 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4656 $res = sql_query($query);
4657 if ( $res && sql_num_rows($res) > 0 )
4660 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4662 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4666 $template['head'] = "<ul>\n";
4668 echo Template::fill($template['head'], $data);
4669 if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
4671 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4675 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4676 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4677 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4680 while ( $row = sql_fetch_assoc($res) )
4683 'tabindex' => $tabstart++,
4684 'skinid' => $skinid,
4685 'skintype' => Entity::hsc(strtolower($row['stype']))
4687 echo Template::fill($template['body'], $data);
4690 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4692 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4696 $template['foot'] = "</ul>\n";
4698 echo Template::fill($template['foot'], $data);
4704 * AdminActions::parse_sprinttext()
4707 * @param string $which
4708 * @param string $val
4711 public function parse_sprinttext($which, $val)
4713 if ( !defined($which) )
4719 $base = constant($which);
4722 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4724 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4726 $met = 'parse_' . $matchies[0];
4730 $arg = trim($args[0], '()');
4731 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4734 if ( method_exists($this, $met) )
4736 $value = call_user_func(array(&$this, $met), $arg);
4740 if ( !isset($value) || empty($value) )
4744 echo sprintf($base, $value);
4749 * AdminActions::parse_systemsettings()
4750 * Parse skinvar systemsettings
4752 * @param string $type type of settings for system
4753 * @param string $templateName name of template to use
4756 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4758 global $member, $CONF, $nucleus;
4760 $member->isAdmin() or Admin::disallow();
4762 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4763 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4770 case 'sqlserverinfo':
4771 echo sql_get_server_info();
4773 case 'sqlclientinfo':
4774 echo sql_get_client_info();
4776 case 'magicquotesgpc':
4777 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4779 case 'magicquotesruntime':
4780 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4782 case 'registerglobals':
4783 echo ini_get('register_globals') ? 'On' : 'Off';
4786 $templates = array();
4787 if ( $templateName )
4789 $templates = Template::read($templateName);
4791 if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
4793 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4797 $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
4800 $gdinfo = gd_info();
4802 foreach ( $gdinfo as $key => $value )
4804 if ( is_bool($value) )
4806 $value = $value ? $enable : $disable;
4810 $value = Entity::hsc($value);
4816 echo Template::fill($template, $data);
4821 phpinfo(INFO_MODULES);
4822 $im = ob_get_contents();
4824 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4826 case 'nucleusversion':
4827 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4829 case 'nucleuspatchlevel':
4830 echo getNucleusPatchLevel();
4836 echo $CONF['ItemURL'];
4838 case 'alertonheaderssent':
4839 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4841 case 'nucleuscodename':
4842 if ( $nucleus['codename'] != '' )
4844 echo ' "' . $nucleus['codename'] . '"';
4847 case 'versioncheckurl':
4848 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4855 * AdminActions::parse_templateoverview()
4856 * Parse skinvar templateoverview
4858 * @param string $templateName name of template to use
4861 public function parse_templateoverview($templateName = '')
4863 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4864 $query = sprintf($query, sql_table('template_desc'));
4865 $template['content'] = 'templatelist';
4866 $template['tabindex'] = 10;
4867 Showlist($query, 'table', $template, $templateName);
4872 * AdminActions::parse_ticket()
4878 public function parse_ticket()
4881 $manager->addTicketHidden();
4886 * AdminActions::parse_versioncheckurl()
4887 * Parse skinvar versioncheckurl
4892 public function parse_versioncheckurl()
4894 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4899 * AdminActions::parse_yrbloglist()
4900 * Parse skinvar yrbloglist
4902 * @param string $templateName name of template to use
4905 public function parse_yrbloglist($templateName = '')
4908 $showAll = requestVar('showall');
4910 if ( $member->isAdmin() && ($showAll == 'yes') )
4912 // Super-Admins have access to all blogs! (no add item support though)
4913 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4915 . " ORDER BY bnumber";
4916 $query = sprintf($query, sql_table('blog'));
4920 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4922 . " WHERE tblog=bnumber and tmember=%d"
4923 . " ORDER BY bnumber";
4924 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4927 $template['content'] = 'bloglist';
4928 $template['superadmin'] = $member->isAdmin();
4930 $amount = Showlist($query, 'table', $template, $templateName);
4932 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4934 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4936 $total = quickQuery($query);
4937 if ( $total > $amount )
4939 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4945 echo _OVERVIEW_NOBLOGS;
4947 elseif( $amount != 0 )
4949 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4951 $query = "SELECT ititle, inumber, bshortname"
4953 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
4954 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4956 $template['content'] = 'draftlist';
4958 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4959 if ( $amountdrafts == 0 )
4961 echo _OVERVIEW_NODRAFTS;
4968 * AdminActions::checkCondition()
4969 * Checks conditions for if statements
4971 * @param string $field type of <%if%>
4972 * @param string $name property of field
4973 * @param string $value value of property
4974 * @return boolean condition
4976 protected function checkCondition($field, $name='', $value = '')
4978 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
4989 $blog =& $manager->getBlog($blogid);
4993 $blogid = getBlogIDFromCatID($catid);
4995 $blog =& $manager->getBlog($blogid);
4997 elseif ( intRequestVar('catid') )
4999 $catid = intRequestVar('catid');
5000 $blogid = getBlogIDFromCatID($catid);
5002 $blog =& $manager->getBlog($blogid);
5009 $condition = ($blog && $this->ifCategory($name, $value));
5012 $condition = ($blog && ($blog->getSetting($name) == $value));
5015 $condition = $member->isLoggedIn();
5018 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5021 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5024 $condition = $member->isLoggedIn() && $member->isAdmin();
5026 case 'allowloginedit':
5027 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5030 $condition = ($itemidnext != '');
5033 $condition = ($itemidprev != '');
5035 case 'archiveprevexists':
5036 $condition = ($archiveprevexists == true);
5038 case 'archivenextexists':
5039 $condition = ($archivenextexists == true);
5042 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5045 $condition = $this->ifHasPlugin($name, $value);
5048 $condition = (Admin::getAdminAction() == $name);
5050 case 'adminoldaction':
5051 $condition = (Admin::getAdminAction() == $name);
5053 case 'addresschange':
5054 $condition = ($this->ifAddresscange());
5056 case 'bechangepass':
5057 $condition = ($this->beChangePassword());
5059 case 'skincandidates':
5060 $condition = ($this->ifSkincandidates());
5063 $condition = requestVar('nameclashes');
5065 case 'existsnewplugin':
5066 $condition = ($this->existsNewPlugin());
5069 $condition = (boolean) ($member->getAutosave() == $value);
5072 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5079 * Actions::_ifHasPlugin()
5080 * hasplugin,PlugName
5081 * -> checks if plugin exists
5082 * hasplugin,PlugName,OptionName
5083 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5084 * hasplugin,PlugName,OptionName=value
5085 * -> checks if the option OptionName from plugin PlugName is set to value
5087 * @param string $name name of plugin
5088 * @param string $value
5091 private function ifHasPlugin($name, $value)
5095 // (pluginInstalled method won't write a message in the actionlog on failure)
5096 if ( $manager->pluginInstalled("NP_{$name}") )
5098 $plugin =& $manager->getPlugin("NP_{$name}");
5099 if ( $plugin != NULL )
5107 list($name2, $value2) = preg_split('#=#', $value, 2);
5108 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5112 else if ( $plugin->getOption($name2) == $value2 )
5123 * Actions::beChangePassword()
5128 private function beChangePassword()
5130 return intRequestVar('bNeedsPasswordChange');
5134 * Actions::ifSkincandidates()
5135 * Checks if a plugin exists and call its doIf function
5140 private function ifSkincandidates()
5143 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5144 return (count($candidates) > 0);
5148 * Actions::ifPlugin()
5149 * Checks if a plugin exists and call its doIf function
5151 private function ifPlugin($name, $key = '', $value = '')
5155 $plugin =& $manager->getPlugin("NP_{$name}");
5161 $params = func_get_args();
5162 array_shift($params);
5164 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5168 * Different checks for a category
5170 private function ifCategory($name = '', $value='')
5172 global $blog, $catid;
5174 // when no parameter is defined, just check if a category is selected
5175 if (($name != 'catname' && $name != 'catid') || ($value == ''))
5177 return $blog->isValidCategory($catid);
5180 // check category name
5181 if ( $name == 'catname' )
5183 $value = $blog->getCategoryIdFromName($value);
5184 if ($value == $catid)
5186 return $blog->isValidCategory($catid);
5190 // check category id
5191 if (($name == 'catid') && ($value == $catid))
5193 return $blog->isValidCategory($catid);
5200 * Checks if a member is on the team of a blog and return his rights
5202 private function ifOnTeam($blogName = '')
5204 global $blog, $member, $manager;
5206 // when no blog found
5207 if ( ($blogName == '') && !is_object($blog) )
5212 // explicit blog selection
5213 if ($blogName != '')
5215 $blogid = getBlogIDFromName($blogName);
5218 if (($blogName == '') || !$manager->existsBlogID($blogid))
5221 $blogid = $blog->getID();
5223 return $member->teamRights($blogid);
5227 * Checks if a member is admin of a blog
5229 private function ifAdmin($blogName = '')
5231 global $blog, $member, $manager;
5233 // when no blog found
5234 if (($blogName == '') && (!is_object($blog)))
5239 // explicit blog selection
5240 if ($blogName != '')
5242 $blogid = getBlogIDFromName($blogName);
5245 if (($blogName == '') || !$manager->existsBlogID($blogid))
5248 $blogid = $blog->getID();
5251 return $member->isBlogAdmin($blogid);
5255 * Check e-Mail address is changed
5257 private function ifAddresscange()
5259 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5264 $info = MEMBER::getActivationInfo($key);
5269 $mem = MEMBER::createFromId($info->vmember);
5274 if ( $info->vtype == 'addresschange' )
5282 * AdminActions::customHelp()
5283 * shows a link to custom help file
5286 * @param string $tplName
5287 * @param string $url
5288 * @param string $iconURL
5289 * @param string $alt
5290 * @param string $title
5294 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5296 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5300 * AdminActions::customHelp()
5301 * shows a link to custom help file
5304 * @param string $tplName
5305 * @param string $url
5306 * @param string $iconURL
5307 * @param string $alt
5308 * @param string $title
5312 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5314 $templates = array();
5316 $templates = Template::read($tplName);
5318 if (isset($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) && !empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR'])) {
5319 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5321 $template = '<a href="<%helpurl%>#<%helptarget%>" title="<%title%>" <%onclick%>>';
5325 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5327 if (empty($onclick)) {
5328 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5329 } elseif (preg_match('/^onclick/', $onclick)) {
5330 $onclick = $onclick;
5332 $onclick = 'onclick="' . $onclick . '"';
5336 'helptarget' => $id,
5337 'onclick' => $onclick,
5338 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5340 return Template::fill($template, $data);
5344 * AdminActions::customHelpHtml()
5347 * @param string $tplName
5348 * @param string $url
5349 * @param string $iconURL
5350 * @param string $alt
5351 * @param string $title
5352 * @param string $onclick
5353 * @return string anchor element with help uri
5355 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5357 $templates = array();
5360 $templates = Template::read($tplName);
5362 if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5364 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5368 $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
5371 if ( empty($iconURL) )
5374 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5376 if ( function_exists('getimagesize') )
5378 $size = getimagesize($iconURL);
5379 $width = 'width="' . $size[0] . '" ';
5380 $height = 'height="' . $size[1] . '" ';
5383 'iconurl' => $iconURL,
5385 'height' => $height,
5386 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5387 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5389 $icon = Template::fill($template, $data);
5390 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5391 return $help . $icon;
5395 * AdminActions::input_yesno
5398 * @param $checkedval
5405 * @param $templateName
5408 private function input_yesno($name,
5419 $templates = array();
5420 if ( $templateName )
5422 $templates = Template::read($templateName);
5425 if ( $name == 'admin' )
5427 if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5429 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5433 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5434 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5435 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5436 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5441 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5443 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5447 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5449 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5452 if ( !isset($template) )
5454 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5455 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5456 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5457 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5462 $id = Entity::hsc($name);
5463 $id = str_replace('[', '-', $id);
5464 $id = str_replace(']', '-', $id);
5465 $id1 = $id . Entity::hsc($value1);
5466 $id2 = $id . Entity::hsc($value2);
5468 'name' => Entity::hsc($name),
5469 'yesval' => Entity::hsc($value1),
5470 'noval' => Entity::hsc($value2),
5473 'yesvaltext' => $yesval,
5474 'novaltext' => $noval,
5475 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5476 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5477 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5482 return Template::fill($template, $dat);
5486 echo Template::fill($template, $dat);
5492 * Check exists new plugin
5494 private function existsNewPlugin()
5496 global $DIR_PLUGINS;
5497 $candidates = array();
5498 $files = scandir($DIR_PLUGINS);
5499 foreach ($files as $file) {
5500 if (preg_match("/^NP_(.*)\.php$/", $file, $matches)) {
5501 $name = $matches[1];
5505 . sql_table('plugin') . ' '
5507 . ' pfile = "NP_' . sql_real_escape_string($name) . '"';
5508 $res = sql_query($que);
5509 if (sql_num_rows($res) == 0) {
5510 $candidates[] = $name;
5514 $this->newPlugCandidates = $candidates;
5515 return (count($candidates) > 0);