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 'admintemplateoverview' => _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)
2221 $contents = array();
2223 if ( requestVar('action') == 'itemedit' )
2225 $itemid = intRequestVar('itemid');
2226 $item =& $manager->getItem($itemid, 1, 1);
2227 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2228 if ( $item && $blog->convertBreaks() )
2230 $item['body'] = removeBreaks($item['body']);
2231 $item['more'] = removeBreaks($item['more']);
2235 elseif ( requestVar('action') == 'createitem' )
2237 $blogid = intRequestVar('blogid');
2238 $blog =& $manager->getBlog($blogid);
2242 'contents' => &$contents,
2247 if ( !isset($contents[$which]) )
2249 $contents[$which] = '';
2251 echo Entity::hsc($contents[$which],ENT_QUOTES);
2255 * AdminActions::parse_currenttime()
2256 * Parse skinvar currenttime
2258 * @param string $what
2261 function parse_currenttime($what)
2264 if ( requestVar('action') == 'itemedit' )
2266 $itemid = intRequestVar('itemid');
2267 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2269 elseif ( requestVar('action') == 'createitem' )
2271 $blog =& $manager->getBlog(intRequestVar('blogid'));
2273 $nu = getdate($blog->getCorrectTime());
2278 * AdminActions::parse_customhelplink()
2279 * Parse skinvar customhelplink
2281 * @param string $topic name of topic
2282 * @param string $tplName name of template
2283 * @param string $url string as URI
2284 * @param string $iconURL string as URI for icon
2285 * @param string $alt alternative text for image element
2286 * @param string $title title for anchor element
2289 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2291 $this->customHelp($topic, $url, $iconURL);
2296 * AdminActions::parse_date()
2297 * Parse skinvar date
2299 public function parse_date($format = 'c')
2301 global $CONF, $manager;
2302 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2307 * AdminActions::parse_defaultadminskintypes()
2308 * Parse skinvar defaultadminskintypes
2310 * @param string $tabindex index number for tabindex attribute of input element
2311 * @param string $templateName name of template
2314 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2316 $templates = array();
2317 if ( $templateName )
2319 $templates = Template::read($templateName);
2322 $types = $this->skin->getAvailableTypes();
2325 if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
2327 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2331 $template['head'] = "<ul>\n";
2334 echo $template['head'];
2336 if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
2338 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2342 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
2343 . "<%name%></a> <%help%></li>\n";
2345 $handler = new Actions('template', $template, new ADMIN);
2347 $parser = new PARSER($handler);
2349 foreach ( $types as $type => $fName )
2351 $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
2353 'tabindex' => $tabindex,
2354 'skintype' => $type,
2356 'help' => $helplink,
2357 'skinid' => intrequestVar('skinid'),
2359 $templateBody = Template::fill($template['body'], $data);
2360 $parser->parse($templateBody);
2363 if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
2365 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2369 $template['foot'] = " </ul>\n";
2371 echo $template['foot'];
2376 * AdminActions::parse_defblogselect()
2377 * Parse skinvar defblogselect
2379 * @param string $templateName name of template
2382 public function parse_defblogselect($templateName = '')
2385 $query = "SELECT bname as text, bnumber as value FROM %s;";
2386 $query = sprintf($query, sql_table('blog'));
2387 $template['name'] = 'DefaultBlog';
2388 $template['selected'] = $CONF['DefaultBlog'];
2389 $template['tabindex'] = 10;
2390 Showlist($query, 'select', $template, $templateName);
2395 * AdminActions::parse_defcatselect()
2396 * Parse skinvar defcatselect
2398 * @param string $templateName name of template
2401 public function parse_defcatselect($templateName = '')
2404 $blogid = intRequestVar('blogid');
2405 $blog = $manager->getBlog($blogid);
2406 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2407 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2408 $template['name'] = 'defcat';
2409 $template['selected'] = $blog->getDefaultCategory();
2410 $template['tabindex'] = 110;
2411 Showlist($query, 'select', $template, $templateName);
2416 * AdminActions::parse_defskinselect()
2417 * Parse skinvar defskinselect
2419 * @param string $type type of skin
2420 * @param string $templateName name of template
2423 public function parse_defskinselect($type = 'blog', $templateName = '')
2426 $query = "SELECT sdname as text, sdnumber as value FROM %s;";
2427 $query = sprintf($query, sql_table('skin_desc'));
2429 $blogid = intRequestVar('blogid');
2434 $template['selected'] = $CONF['BaseSkin'];
2438 $blog = $manager->getBlog($blogid);
2439 $template['selected'] = $blog->getDefaultSkin();
2442 if ( $type != 'blog' )
2444 $nname = 'BaseSkin';
2451 $template['name'] = $nname;
2452 $template['tabindex'] = 50;
2453 Showlist($query, 'select', $template, $templateName);
2458 * AdminActions::parse_deletecomment()
2459 * Parse skinvar deletecomment
2461 * @param string $type type of infomation for comment
2464 public function parse_deletecomment($type = 'id')
2466 $commentid = intRequestVar('commentid');
2467 $comment = COMMENT::getComment($commentid);
2472 echo intRequestVar('commentid');
2475 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2477 echo $comment['member'];
2481 echo $comment['user'];
2485 $body = strip_tags($comment['body']);
2486 echo Entity::hsc(shorten($body, 300, '...'));
2492 * AdminActions::parse_deleteitembody()
2493 * Parse skinvar deleteitembody
2498 public function parse_deleteitembody()
2501 $itemid = intRequestVar('itemid');
2502 $item =& $manager->getItem($itemid, 1, 1);
2503 $body = strip_tags($item['body']);
2504 echo Entity::hsc(shorten($body, 300, '...'));
2509 * AdminActions::parse_deleteitemid()
2510 * Parse skinvar deleteitemid
2515 public function parse_deleteitemid()
2517 echo (integer) intRequestVar('itemid');
2522 * AdminActions::parse_deleteitemtitle()
2523 * Parse skinvar deleteitemtitle
2528 public function parse_deleteitemtitle()
2531 $itemid = intRequestVar('itemid');
2532 $item =& $manager->getItem($itemid, 1, 1);
2533 echo Entity::hsc(strip_tags($item['title']));
2538 * AdminActions::parse_editadminskin()
2539 * Parse skinvar editadminskin
2541 * @param string $type type of skin setting
2544 public function parse_editadminskin($type = 'id')
2546 $skinid = intRequestVar('skinid');
2547 $skin = new Skin($skinid);
2551 echo intRequestVar('skinid');
2554 echo Entity::hsc($skin->getName());
2557 echo Entity::hsc($skin->getDescription());
2560 echo Entity::hsc($skin->getContentType());
2563 echo Entity::hsc($skin->getIncludePrefix());
2566 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2574 * AdminActions::parse_editadminskintype()
2575 * Parse skinvar editadminskintype
2577 * @param string $type name of skin type
2580 public function parse_editadminskintype($type = 'id')
2582 global $CONF, $manager, $member;
2583 // $skinid = intRequestVar('skinid');
2584 // $skin = new Skin($skinid);
2585 $fNames = $this->skin->getAvailableTypes();
2586 $sType = strtolower(trim(requestVar('type')));
2591 echo intRequestVar('skinid');
2594 echo Entity::hsc($this->skin->getName());
2597 echo Entity::hsc($this->skin->getDescription());
2600 echo Entity::hsc($this->skin->getContentType());
2603 echo Entity::hsc($this->skin->getContentFromDB($sType));
2606 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2607 echo Entity::hsc($skinType);
2610 echo Entity::hsc($sType);
2613 echo Entity::hsc($this->skin->getIncludePrefix());
2616 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2617 echo Entity::hsc($incMode);
2626 * AdminActions::parse_editadmintemplateinfo()
2627 * Parse skinvar editadmintemplateinfo
2629 * @param string $type type of skin template
2630 * @param string $description description of template
2631 * @param string $name name of stemplate
2632 * @param string $tabindex index number for tabindex attribute of input element
2633 * @param string $big
2634 * @param string $tplt
2636 public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2639 $templateid = intRequestVar('templateid');
2640 $templatename = Template::getNameFromId($templateid);
2641 $templatedescription = Template::getDesc($templateid);
2642 $template =& Template::read($templatename);
2646 echo intval($templateid);
2649 echo Entity::hsc($templatename);
2652 echo Entity::hsc($templatedescription);
2654 case 'extratemplate':
2656 $pluginfields = array();
2658 'AdminTemplateExtraFields',
2660 'fields' => &$pluginfields
2666 $tmplt = Template::read($description);
2668 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2670 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2676 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2678 foreach ( $pluginfields as $pfkey => $pfvalue )
2681 'explugtplname' => Entity::hsc($pfkey)
2683 echo Template::fill($base, $data);
2684 foreach ( $pfvalue as $pffield => $pfdesc )
2686 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2691 $desc = defined($description) ? constant($description) : $description;
2692 $name = defined($name) ? constant($name) : $name;
2693 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2700 * AdminActions::parse_editcomment()
2701 * Parse skinvar editcomment
2703 * @param string $type type of comment setting
2706 public function parse_editcomment($type = 'id')
2709 $commentid = intRequestVar('commentid');
2710 $comment = COMMENT::getComment($commentid);
2712 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2717 echo intRequestVar('commentid');
2720 if (array_key_exists('member', $comment) && !empty($comment['member']) )
2722 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2726 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2730 echo date("Y-m-d @ H:i", $comment['timestamp']);
2733 $comment['body'] = str_replace('<br />', '', $comment['body']);
2734 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2735 echo $comment['body'];
2737 echo $comment[$type];
2744 * AdminActions::parse_editdesturl()
2745 * Parse skinvar editdesturl
2747 public function parse_editdesturl()
2749 if ( requestVar('desturl') )
2751 echo Entity::hsc(requestVar('desturl'));
2757 * AdminActions::parse_editmemberlist()
2758 * Parse skinvar editmemberlist
2760 * @param string $templateName name of template
2763 public function parse_editmemberlist($templateName = '')
2766 // show list of members with actions
2767 $query = 'SELECT * FROM '.sql_table('member');
2768 $template['content'] = 'memberlist';
2769 $template['tabindex'] = 10;
2771 $batch = new Batch('member');
2772 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2777 * AdminActions::parse_editmember()
2778 * Parse skinvar editmember
2780 * @param string $type type of information for member
2781 * @return string $tempateName name of template to use
2784 public function parse_editmember($type = 'id', $templateName = '')
2786 global $CONF, $manager, $member;
2787 $memberid = intRequestVar('memberid');
2788 $mem = MEMBER::createFromID($memberid);
2793 echo intRequestVar('memberid');
2796 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2798 echo Entity::hsc($mem->getDisplayName());
2802 $dispName = Entity::hsc($mem->getDisplayName());
2803 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2805 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2814 echo Entity::hsc($mem->getRealName());
2817 echo Entity::hsc($mem->getEmail());
2820 echo Entity::hsc($mem->getURL());
2823 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2826 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2829 echo Entity::hsc($mem->getNotes());
2832 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2841 * AdminActions::parse_editpluginfo()
2842 * Parse skinvar editpluginfo
2844 * @param string $type type of plugin info
2847 public function parse_editpluginfo($type)
2849 $pid = intRequestVar('plugid');
2856 echo Entity::hsc(getPluginNameFromPid($pid));
2863 * AdminActions::parse_editplugoptionslist()
2864 * Parse skinvar editplugoptionslist
2866 * @param string $templateName name of template
2869 public function parse_editplugoptionslist($templateName = '')
2873 $pid = intRequestVar('plugid');
2874 $aOptions = array();
2877 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
2878 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2879 $resource = sql_query($query);
2881 while ( $o = sql_fetch_object($resource) )
2883 array_push($aOIDs, $o->oid);
2884 $aOptions[$o->oid] = array(
2887 'value' => $o->odef,
2888 'name' => $o->oname,
2889 'description' => $o->odesc,
2890 'type' => $o->otype,
2891 'typeinfo' => $o->oextra,
2896 // fill out actual values
2897 if ( count($aOIDs) > 0 )
2899 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2900 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2902 $result = sql_query($query);
2904 while ( $o = sql_fetch_object($result) )
2906 $aOptions[$o->oid]['value'] = $o->ovalue;
2912 'PrePluginOptionsEdit',
2914 'context' => 'global',
2916 'options' => &$aOptions
2920 $template['content'] = 'plugoptionlist';
2921 $amount = Showlist($aOptions, 'table', $template, $templateName);
2924 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2930 * AdminActions::parse_editskin()
2931 * Parse skinvar editskin
2933 * @param string $type type of skin
2936 public function parse_editskin($type = 'id')
2938 $skinid = intRequestVar('skinid');
2939 $skin = new SKIN($skinid);
2943 echo intRequestVar('skinid');
2946 echo Entity::hsc($skin->getName());
2949 echo Entity::hsc($skin->getDescription());
2952 echo Entity::hsc($skin->getContentType());
2955 echo Entity::hsc($skin->getIncludePrefix());
2958 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2966 * AdminActions::parse_editskintype()
2967 * Parse skinvar editskintype
2969 * @param string $type name of type for skin type
2972 public function parse_editskintype($type = 'id')
2974 global $CONF, $manager, $member;
2975 $skinid = intRequestVar('skinid');
2976 $skin = new SKIN($skinid);
2977 $fNames = $skin->getAvailableTypes();
2978 $sType = strtolower(trim(requestVar('type')));
2983 echo intRequestVar('skinid');
2986 echo Entity::hsc($skin->getName());
2989 echo Entity::hsc($skin->getDescription());
2992 echo Entity::hsc($skin->getContentType());
2995 echo Entity::hsc($skin->getContentFromDB($sType));
2998 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2999 echo Entity::hsc($skinType);
3002 echo Entity::hsc($sType);
3005 echo Entity::hsc($skin->getIncludePrefix());
3008 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
3009 echo Entity::hsc($incMode);
3018 * AdminActions::parse_adminurl()
3019 * Parse skinvar adminurl
3020 * (shortcut for admin url)
3025 public function parse_adminurl()
3027 $this->parse_sitevar('adminurl');
3032 * AdminActions::parse_edittemplateinfo()
3033 * Parse skinvar edittemplateinfo
3035 * @param string $type name of type for skin
3036 * @param string $description description for skin
3037 * @param string $name name of skin
3038 * @param string $help
3039 * @param string $tabindex index value for tabindex attribute of input element
3040 * @param string $big
3041 * @param string $tplt name of template
3043 public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3046 $templateid = intRequestVar('templateid');
3047 $templatename = Template::getNameFromId($templateid);
3048 $templatedescription = Template::getDesc($templateid);
3049 $template =& $manager->getTemplate($templatename);
3053 echo intval($templateid);
3056 echo Entity::hsc($templatename);
3059 echo Entity::hsc($templatedescription);
3061 case 'extratemplate':
3063 $pluginfields = array();
3065 'TemplateExtraFields',
3067 'fields' => &$pluginfields
3073 $tmplt = Template::read($description);
3075 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3077 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3081 $base = "</tr><tr>\n"
3082 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3084 foreach ( $pluginfields as $pfkey => $pfvalue )
3087 'explugtplname' => Entity::hsc($pfkey)
3089 echo Template::fill($base, $data);
3090 foreach ( $pfvalue as $pffield => $pfdesc )
3092 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3097 $desc = defined($description) ? constant($description) : $description;
3098 $name = defined($name) ? constant($name) : $name;
3099 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3106 * AdminActions::parse_eventformextra()
3107 * Parse skinvar eventformextra
3109 * @param string $type name of type for event form extra
3112 public function parse_eventformextra($type = 'activation')
3118 $key = requestVar('ackey');
3121 Admin::error(_ERROR_ACTIVATE);
3123 $info = MEMBER::getActivationInfo($key);
3126 Admin::error(_ERROR_ACTIVATE);
3128 $mem = MEMBER::createFromId($info->vmember);
3131 Admin::error(_ERROR_ACTIVATE);
3134 'type' => 'activation',
3138 case 'membermailform-notloggedin':
3140 'type' => 'membermailform-notloggedin',
3144 $manager->notify('FormExtra', $data);
3149 * AdminActions::parse_extrahead()
3150 * Parse skinvar extrahead
3152 public function parse_extrahead()
3155 $extrahead = Admin::getAdminextrahead();
3159 'extrahead' => &$extrahead,
3160 'action' => Admin::getAdminAction()
3169 * AdminActions::parse_member()
3170 * Parse skinvar member
3171 * (includes a member info thingie)
3173 * @param string $what which memberdata is needed
3176 public function parse_member($what)
3178 global $memberinfo, $member, $CONF;
3180 // 1. only allow the member-details-page specific variables on member pages
3181 if ( $this->skintype == 'member' )
3186 echo Entity::hsc($memberinfo->getDisplayName());
3189 echo Entity::hsc($memberinfo->getRealName());
3192 echo Entity::hsc($memberinfo->getNotes());
3195 echo Entity::hsc($memberinfo->getURL());
3198 echo Entity::hsc($memberinfo->getEmail());
3201 echo Entity::hsc($memberinfo->getID());
3206 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3207 if ( $member->isLoggedIn() )
3212 echo $member->getDisplayName();
3214 case 'yourrealname':
3215 echo $member->getRealName();
3218 echo $member->getNotes();
3221 echo $member->getURL();
3224 echo $member->getEmail();
3227 echo $member->getID();
3229 case 'yourprofileurl':
3230 if ($CONF['URLMode'] == 'pathinfo')
3231 echo Link::create_member_link($member->getID());
3233 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3241 * AdminActions::parse_version()
3242 * Parse skinvar version
3243 * (include nucleus versionnumber)
3248 public function parse_version()
3251 echo 'Nucleus CMS ' . $nucleus['version'];
3256 * AdminActions::parse_sitevar()
3257 * Parse skinvar sitevar
3258 * (include a sitevar)
3260 * @param string $which
3263 public function parse_sitevar($which)
3269 echo $CONF['IndexURL'];
3272 echo $CONF['SiteName'];
3275 echo $CONF['AdminEmail'];
3278 echo $CONF['AdminURL'];
3284 * AdminActions::parse_charset()
3285 * Parse skinvar charset
3290 public function parse_charset()
3292 echo i18n::get_current_charset();
3297 * AdminActions::parse_getblogsetting()
3298 * Parse skinvar getblogsetting
3300 public function parse_getblogsetting($which)
3308 elseif ( $bid = intRequestVar('blogid') )
3311 $b = $manager->getBlog($bid);
3321 return Entity::hsc($b->getID());
3324 return Entity::hsc($b->getURL());
3327 return Entity::hsc($b->getName());
3330 return Entity::hsc($b->getDescription());
3333 return Entity::hsc($b->getShortName());
3335 case 'notifyaddress':
3336 return Entity::hsc($b->getNotifyAddress());
3339 return Entity::hsc($b->getMaxComments());
3342 return Entity::hsc($b->getUpdateFile());
3345 return Entity::hsc($b->getTimeOffset());
3352 * AdminActions::parse_geteditpluginfo()
3353 * Parse skinvar geteditpluginfo
3355 * @param string $type name of setting for edit plugin info
3358 public function parse_geteditpluginfo($type)
3360 $pid = intRequestVar('plugid');
3367 return Entity::hsc(getPluginNameFromPid($pid));
3374 * AdminActions::parse_getmember()
3375 * Parse skinvar getmember
3376 * (includes a member info thingie)
3378 * @param string $what name of setting for member
3381 public function parse_getmember($what)
3383 global $memberinfo, $member;
3384 // 1. only allow the member-details-page specific variables on member pages
3385 if ( $this->skintype == 'member' )
3390 return Entity::hsc($memberinfo->getDisplayName());
3393 return Entity::hsc($memberinfo->getRealName());
3396 return Entity::hsc($memberinfo->getNotes());
3399 return Entity::hsc($memberinfo->getURL());
3402 return Entity::hsc($memberinfo->getEmail());
3405 return Entity::hsc($memberinfo->getID());
3409 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3410 if ( $member->isLoggedIn() )
3415 return $member->getDisplayName();
3417 case 'yourrealname':
3418 return $member->getRealName();
3421 return $member->getNotes();
3424 return $member->getURL();
3427 return $member->getEmail();
3430 return $member->getID();
3438 * AdminActions::parse_headmessage()
3439 * Parse skinvar headmessage
3444 public function parse_headmessage()
3446 if ( !empty(Admin::$headMess) )
3448 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3454 * AdminActions::parse_helplink()
3455 * Parse skinvar helplink
3457 * @param string $topic name of topic for help
3460 public function parse_helplink($topic = '')
3462 if ( empty($topic) )
3471 * AdminActions::parse_helpplugname()
3472 * Parse skinvar helpplugname
3477 public function parse_helpplugname()
3479 $plugid = intGetVar('plugid');
3480 Entity::hsc(getPluginNameFromPid($plugid));
3485 * AdminActions::parse_ilistaddnew()
3486 * Parse skinvar ilistaddnew
3491 public function parse_ilistaddnew()
3493 $blogid = intRequestVar('blogid');
3494 if ( intPostVar('start') == 0 )
3496 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3502 * AdminActions::parse_importskininfo()
3503 * Parse skinvar importskininfo
3505 * @param string $type name of information for imported skin
3508 public function parse_importskininfo($type)
3513 echo Entity::hsc(requestVar('skininfo'));
3516 $dataArr = requestArray('skinnames');
3517 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3520 $dataArr = requestArray('tpltnames');
3521 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3524 $dataArr = requestArray('skinclashes');
3525 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3528 $dataArr = requestArray('tpltclashes');
3529 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3532 echo Entity::hsc(requestVar('skinfile'));
3535 echo Entity::hsc(requestVar('mode'));
3542 * AdminActions::parse_inputyesno()
3543 * Parse skinvar inputyesno
3545 * some init stuff for all forms
3549 function parse_init()
3553 if ( requestVar('action') == 'itemedit' )
3555 $itemid = intRequestVar('itemid');
3556 $item =& $manager->getItem($itemid, 1, 1);
3557 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3558 if ( $item && $blog->convertBreaks() )
3560 $item['body'] = removeBreaks($item['body']);
3561 $item['more'] = removeBreaks($item['more']);
3564 $authorid = $contents['authorid'];
3566 elseif ( requestVar('action') == 'createitem' )
3568 $blog =& $manager->getBlog(intRequestVar($blogid));
3571 $blog->insertJavaScriptInfo($authorid);
3575 * AdminActions::parse_inputyesno()
3576 * Parse skinvar inputyesno
3578 * @param string $name
3579 * @param string $checkedval
3580 * @param string $tabindex
3581 * @param string $value1
3582 * @param string $value2
3583 * @param string $yesval
3584 * @param string $noval
3585 * @param string $isAdmin
3586 * @param string $templateName
3589 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3591 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3596 * AdminActions::parse_insertpluginfo()
3597 * Parse templatevar insertpluginfo
3599 public function parse_insertpluginfo($type)
3601 $option = Admin::$aOptions;
3605 return $option['pid'];
3608 return Entity::hsc($option['pfile']);
3615 * AdminActions::parse_insertpluginoptions()
3616 * Parse skinvar insertpluginoptions
3618 * @param string $templateName name of template
3621 public function parse_insertpluginoptions($templateName = '')
3623 $options = Admin::getAdminaOption();
3624 $template = array();
3625 $templats = array();
3627 if ( $templateName )
3629 $templates = Template::read($templateName);
3631 if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
3633 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3637 $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
3639 if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
3641 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3645 $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
3650 foreach ( $options as $option )
3652 $handler = new Actions($this->skintype, $template, $option);
3654 $parser = new PARSER($handler);
3657 if ( $prevPid != $option['pid'] )
3659 $prevPid = $option['pid'];
3660 $parser->parse($template['title']);
3662 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3663 if ( @$meta['access'] != 'hidden' )
3665 $parsed = $parser->parse($template['body']);
3672 * AdminActions::parse_insplugoptcontent()
3673 * Parse skinvar insplugoptcontent
3678 public function parse_insplugoptcontent()
3680 $option = Admin::$aOption;
3682 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3683 if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
3686 listplug_plugOptionRow($option);
3693 * AdminActions::parse_iprangeinput()
3694 * Parse skinvar iprangeinput
3699 public function parse_iprangeinput()
3701 if ( requestVar('ip') )
3703 $iprangeVal = Entity::hsc(requestVar('ip'));
3704 echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
3705 echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
3706 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3707 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3708 echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
3712 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3713 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3719 * AdminActions::parse_itemnavlist()
3720 * Parse skinvar itemnavlist
3725 public function parse_itemnavlist()
3727 global $CONF, $manager, $member;
3728 if ( $this->skintype == 'itemlist' )
3730 $blogid = intRequestVar('blogid');
3731 $blog =& $manager->getBlog($blogid);
3733 if ( postVar('start') )
3735 $start = intPostVar('start');
3742 // amount of items to show
3743 if ( postVar('amount') )
3745 $amount = intPostVar('amount');
3749 $amount = intval($CONF['DefaultListSize']);
3755 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3756 . " FROM %s, %s, %s, %s"
3757 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3759 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3761 if ( $this->skintype == 'itemlist' )
3763 $query .= ' AND iblog = ' . $blogid;
3764 $template['now'] = $blog->getCorrectTime(time());
3766 // non-blog-admins can only edit/delete their own items
3767 if ( !$member->blogAdminRights($blogid) )
3769 $query .= ' AND iauthor = ' . $member->getID();
3772 elseif ( $this->skintype == 'browseownitems' )
3774 $query .= ' AND iauthor = ' . $member->getID();
3776 $template['now'] = time();
3779 // search through items
3780 $search = postVar('search');
3782 if ( !empty($search) )
3784 $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
3785 . ' OR (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
3786 . ' OR (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
3788 $query .= ' ORDER BY itime DESC'
3789 . " LIMIT {$start},{$amount}";
3791 $template['content'] = 'itemlist';
3793 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3794 $navList->showBatchList('item', $query, 'table', $template);
3799 * AdminActions::parse_itemoptions()
3800 * Parse skinvar itemoptions
3801 * Adds the itemOptions of a plugin to a page
3804 function parse_itemoptions()
3806 $this->parse_pluginoptions($type = 'item');
3808 // Admin::insertPluginOptions('item', $itemid);
3812 * AdminActions::parse_itemoptions()
3814 * date change on edit item
3816 * Parse skinvar itemoptions
3817 * Adds the itemOptions of a plugin to a page
3820 function parse_itemtime($what)
3824 $itemid = intRequestVar('itemid');
3825 $item =& $manager->getItem($itemid, 1, 1);
3826 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3827 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3829 $item['body'] = removeBreaks($item['body']);
3830 $item['more'] = removeBreaks($item['more']);
3832 $contents = array();
3833 if ( requestVar('action') == 'itemedit' )
3837 elseif ( requestVar('action') == 'createitem' )
3842 'contents' => &$contents,
3843 'blog' => &$this->blog
3847 $itemtime = getdate($contents['timestamp']);
3848 echo $itemtime[$what];
3852 * AdminActions::parse_jstoolbaroptions()
3853 * Parse skinvar jstoolbaroptions
3858 public function parse_jstoolbaroptions()
3862 _SETTINGS_JSTOOLBAR_NONE,
3863 _SETTINGS_JSTOOLBAR_SIMPLE,
3864 _SETTINGS_JSTOOLBAR_FULL
3867 foreach ( $options as $option )
3869 $text = "<option value=\"%d\"%s>%s</option>\n";
3870 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3871 echo sprintf($text, $i, $extra, $option);
3877 * Parse skinvar languageselectoptions
3879 function parse_languageselectoptions()
3881 $locales = i18n::get_available_locale_list();
3882 $memid = intRequestVar('memberid');
3885 $mem = MEMBER::createFromID($memid);
3886 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3888 echo "<option value=\"\" selected=\"selected\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3892 echo "<option value=\"\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3897 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3899 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3902 foreach ( $locales as $locale )
3906 if ( $locale == $mem->getLocale() )
3908 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3912 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3917 if ( $locale == i18n::get_current_locale() )
3919 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3923 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3930 * AdminActions::parse_localeselectoptions()
3931 * Parse skinvar localeselectoptions
3936 public function parse_localeselectoptions()
3938 $locales = i18n::get_available_locale_list();
3939 $memid = intRequestVar('memberid');
3942 $mem = MEMBER::createFromID($memid);
3943 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3945 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3949 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3954 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3956 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3959 foreach ( $locales as $locale )
3963 if ( $locale == $mem->getLocale() )
3965 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3969 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3974 if ( $locale == i18n::get_current_locale() )
3976 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3980 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3988 * AdminActions::parse_listplugplugoptionrow()
3989 * Parse templatevar listplugplugoptionrow
3991 * @param string $templateName name of template
3994 public function parse_listplugplugoptionrow($templateName = '')
3996 echo listplug_plugOptionRow(Admin::$aOptions, $templateName);
4001 * AdminActions::parse_mediadirwarning()
4002 * Parse skinvar mediadirwarning
4007 public function parse_mediadirwarning()
4010 if ( !is_dir($DIR_MEDIA) )
4012 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4014 if ( !is_readable($DIR_MEDIA) )
4016 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4018 if ( !is_writeable($DIR_MEDIA) )
4020 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4026 * AdminActions::parse_movedistselect()
4027 * Parse skinvar movedistselect
4029 public function parse_movedistselect()
4031 $actionType = requestVar('action');
4032 switch ( $actionType )
4035 Admin::selectBlogCategory('destcatid');
4037 case 'batchcategory':
4038 Admin::selectBlog('destblogid');
4041 if ( $this->skintype == 'itemmove' )
4043 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
4044 $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
4045 $catid = quickQuery(sprintf($query, intRequestVar('itemid')));
4046 Admin::selectBlogCategory('catid', $catid, 10, 1);
4054 * AdminActions::parse_moveitemid()
4055 * Parse skinvar moveitemid
4060 public function parse_moveitemid()
4062 echo intRequestVar('itemid');
4067 * AdminActions::parse_newestcompare()
4068 * Parse skinvar newestcompare
4073 public function parse_newestcompare()
4076 $newestVersion = getLatestVersion();
4077 $newestCompare = str_replace('/', '.', $newestVersion);
4078 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4079 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4081 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4082 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4088 * AdminActions::parse_newmemberselect()
4089 * Parse skinvar newmemberselect
4091 * @param string $templateName name of template to use
4094 public function parse_newmemberselect($templateName = '')
4096 $blogid = intRequestVar('blogid');
4098 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4099 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4100 $res = sql_query($query);
4103 while ( $tmember = sql_fetch_object($res) )
4105 $tmem[] = intval($tmember->tmember);
4108 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4109 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4111 $template['name'] = 'memberid';
4112 $template['tabindex'] = 10000;
4113 Showlist($query, 'select', $template, $templateName);
4118 * AdminActions::parse_newpluginlist()
4119 * Parse skinvar newpluginlist
4124 public function parse_newpluginlist()
4126 $candidates = $this->newPlugCandidates;
4127 foreach ( $candidates as $name )
4129 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4135 * AdminActions::parse_outputspecialdirs()
4136 * Parse skinvar outputspecialdirs
4138 * @param string $type type of setting for directory
4141 public function parse_outputspecialdirs($type)
4146 global $DIR_NUCLEUS;
4147 echo Entity::hsc($DIR_NUCLEUS);
4151 echo Entity::hsc($DIR_MEDIA);
4158 * AdminActions::parse_passrequestvars()
4159 * Parse skinvar passrequestvars
4164 public function parse_passrequestvars()
4166 $passvar = Admin::getAdminpassvar();
4167 $oldaction = postVar('oldaction');
4168 if ( ($oldaction != 'logout')
4169 && ($oldaction != 'login')
4171 && !postVar('customaction') )
4179 * AdminActions::parse_pluginextras()
4180 * Parse skinvar pluginextras
4182 * @param string $type type of plugin context
4185 public function parse_pluginextras($type = 'global')
4191 $id = intRequestVar('memberid');
4192 $mem = MEMBER::createFromID($id);
4194 'MemberSettingsFormExtras',
4201 $id = intRequestVar('blogid');
4202 $blg = $manager->getBlog($id);
4204 'BlogSettingsFormExtras',
4212 'GeneralSettingsFormExtras',
4222 * AdminActions::parse_pluginhelp()
4223 * Parse skinvar pluginhelp
4228 public function parse_pluginhelp()
4230 global $manager, $DIR_PLUGINS;
4231 $plugid = intGetVar('plugid');
4232 $plugName = getPluginNameFromPid($plugid);
4233 $plug =& $manager->getPlugin($plugName);
4235 if ( $plug->supportsFeature('HelpPage') > 0 )
4237 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4238 if ( @file_exists($helpfile . 'php') )
4240 @include($helpfile . 'php');
4243 elseif ( @file_exists($helpfile . 'html') )
4245 @include($helpfile . 'html');
4249 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4250 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4255 * AdminActions::parse_pluginlistlist()
4256 * Parse skinvar pluginlistlist
4258 * @param string $templateName name of template to use
4261 public function parse_pluginlistlist($templateName = '')
4263 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4264 $query = sprintf($query, sql_table('plugin'));
4265 $template['content'] = 'pluginlist';
4266 $template['tabindex'] = 10;
4267 Showlist($query, 'table', $template, $templateName);
4272 * AdminActions::parse_pluginoptions()
4273 * Parse skinvar pluginoptions
4275 * @param string $type type of plugin option
4278 public function parse_pluginoptions($type = 'global')
4283 $id = intRequestVar('memberid');
4286 $id = intRequestVar('blogid');
4289 $id = intRequestVar('catid');
4295 Admin::insertPluginOptions($type, $id);
4300 * AdminActions::parse_qmenuaddselect()
4301 * Parse skinvar qmanuaddselect
4303 * @param string $templateName name of template to use
4306 public function parse_qmenuaddselect($templateName = '')
4309 $showAll = requestVar('showall');
4310 if ( $member->isAdmin() && ($showAll == 'yes') )
4312 // Super-Admins have access to all blogs! (no add item support though)
4313 $query = 'SELECT bnumber as value, bname as text'
4314 . ' FROM ' . sql_table('blog')
4315 . ' ORDER BY bname';
4319 $query = 'SELECT bnumber as value, bname as text'
4320 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4321 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4322 . ' ORDER BY bname';
4324 $template['name'] = 'blogid';
4325 $template['tabindex'] = 15000;
4326 $template['extra'] = _QMENU_ADD_SELECT;
4327 $template['selected'] = -1;
4328 $template['shorten'] = 10;
4329 $template['shortenel'] = '';
4330 $template['javascript'] = 'onchange="return form.submit()"';
4331 Showlist($query, 'select', $template, $templateName);
4336 * AdminActions::parse_quickmenu()
4337 * Parse skinvar quickmenu
4339 * @param string $templateName name of template to use
4342 public function parse_quickmenu($templateName = '')
4345 $templates = array();
4346 $template = array();
4347 if ( !empty($templateName) )
4349 $templates = Template::read($templateName);
4351 $pluginExtras = array();
4355 'options' => &$pluginExtras
4358 if ( count($pluginExtras) > 0 )
4360 if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4362 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4366 $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
4368 $handler = new Actions($this->skintype);
4370 $parser = new PARSER($handler);
4371 $parser->parse($template['title']);
4373 if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4375 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4379 $template['head'] = '<ul>';
4382 echo $template['head'];
4384 if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
4386 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4390 $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
4393 foreach ( $pluginExtras as $aInfo )
4396 'plugadminurl' => Entity::hsc($aInfo['url']),
4397 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4398 'plugadmintitle' => Entity::hsc($aInfo['title']),
4400 echo Template::fill($template['body'], $data);
4402 if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4404 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4408 $template['foot'] = '</ul>';
4410 echo $template['foot'];
4416 * AdminActions::parse_requestblogid()
4417 * Parse skinvar requestblogid
4422 public function parse_requestblogid()
4424 echo intRequestVar('blogid');
4429 * AdminActions::parse_requestiprange()
4430 * Parse skinvar requestiprange
4435 public function parse_requestiprange()
4437 if ( requestVar('iprange') )
4439 echo Entity::hsc(requestVar('iprange'));
4441 elseif ( requestVar('ip') )
4443 echo Entity::hsc(requestVar('ip'));
4449 * AdminActions::parse_selectlocaladminskinfiles()
4450 * Parse skinvar selectlocaladminskinfiles
4455 public function parse_selectlocaladminskinfiles()
4458 global $DIR_SKINS, $manager;
4459 $adminskindir = $DIR_SKINS . 'admin/';
4460 $candidates = SkinImport::searchForCandidates($adminskindir);
4461 foreach ( $candidates as $skinname => $skinfile )
4463 $html = Entity::hsc($skinfile);
4464 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4470 * AdminActions::parse_selectlocalskinfiles()
4471 * Parse skinvar selectlocalskinfiles
4476 public function parse_selectlocalskinfiles()
4479 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4480 foreach ( $candidates as $skinname => $skinfile )
4482 $html = Entity::hsc($skinfile);
4483 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4489 * AdminActions::parse_skineditallowedlist()
4490 * Parse skinvar skineditallowedlist
4492 * @param string $type type of skin
4493 * @param string $templateName name of template
4496 public function parse_skineditallowedlist($type, $templateName = '')
4501 $query = "SELECT bshortname, bname FROM %s";
4503 'content' => 'shortblognames'
4505 $query = sprintf($query, sql_table('blog'));
4506 Showlist($query, 'table', $show, $templateName);
4509 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%'";
4511 'content' => 'shortnames'
4513 $query = sprintf($query, sql_table('template_desc'));
4514 Showlist($query, 'table', $show, $templateName);
4521 * AdminActions::parse_skinielist()
4522 * Parse skinvar skinielist
4524 * @param string $type type of skin
4525 * @param string $templateName name of template to use
4528 public function parse_skinielist($type, $templateName = '')
4530 $templates = array();
4531 if ( $templateName )
4533 $templates = Template::read($templateName);
4535 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4537 $template = $templates['SKINIE_EXPORT_LIST'];
4541 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
4542 . "<td><%expdesc%></td>\n"
4548 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
4549 while ( $skinObj = sql_fetch_object($res) )
4552 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
4553 'expid' => 'skinexp' . $skinObj->sdnumber,
4554 'expname' => Entity::hsc($skinObj->sdname),
4555 'expdesc' => Entity::hsc($skinObj->sddesc),
4557 echo Template::fill($template, $data);
4561 $res = sql_query('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%'");
4562 while ($templateObj = sql_fetch_object($res)) {
4564 'typeid' => 'template[' . $templateObj->tdnumber . ']',
4565 'expid' => 'templateexp' . $templateObj->tdnumber,
4566 'expname' => Entity::hsc($templateObj->tdname),
4567 'expdesc' => Entity::hsc($templateObj->tddesc),
4569 echo Template::fill($template, $data);
4577 * AdminActions::parse_skinoverview()
4578 * Parse skinvar skinoverview
4580 * @param string $templateName name of template to use
4583 public function parse_skinoverview($templateName = '')
4586 $query = "SELECT * FROM %s WHERE sdincmode != 'admin' ORDER BY sdname";
4587 $query = sprintf($query, sql_table('skin_desc'));
4589 $template['content'] = 'skinlist';
4590 $template['tabindex'] = 10;
4591 // $template['friendly_names'] = Skin::getFriendlyNames('Actions');
4592 $skin = new Skin($CONF['BaseSkin']);
4593 $template['friendly_names'] = $skin->getDefaultTypes();
4595 Showlist($query, 'table', $template, $templateName);
4600 * AdminActions::parse_skintypehelp()
4601 * Check editing skintypehelp
4606 public function parse_skintypehelp()
4608 $nowSkinType = strtolower(trim(requestVar('type')));
4609 $regularType = array(
4620 if ( in_array($nowSkinType, $regularType) )
4622 help('skinpart' . $nowSkinType);
4626 help('skinpartspecial');
4632 * AdminActions::parse_specialskinlist()
4633 * Parse skinvar specialskinlist
4635 * @param string $templateName name of template to use
4638 public function parse_specialskinlist($templateName = '')
4640 $templates = array();
4641 if ( $templateName )
4643 $templates = Template::read($templateName);
4655 $skinid = intRequestVar('skinid');
4656 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4657 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4659 $res = sql_query($query);
4660 if ( $res && sql_num_rows($res) > 0 )
4663 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4665 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4669 $template['head'] = "<ul>\n";
4671 echo Template::fill($template['head'], $data);
4672 if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
4674 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4678 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4679 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4680 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4683 while ( $row = sql_fetch_assoc($res) )
4686 'tabindex' => $tabstart++,
4687 'skinid' => $skinid,
4688 'skintype' => Entity::hsc(strtolower($row['stype']))
4690 echo Template::fill($template['body'], $data);
4693 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4695 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4699 $template['foot'] = "</ul>\n";
4701 echo Template::fill($template['foot'], $data);
4707 * AdminActions::parse_sprinttext()
4710 * @param string $which
4711 * @param string $val
4714 public function parse_sprinttext($which, $val)
4716 if ( !defined($which) )
4722 $base = constant($which);
4725 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4727 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4729 $met = 'parse_' . $matchies[0];
4733 $arg = trim($args[0], '()');
4734 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4737 if ( method_exists($this, $met) )
4739 $value = call_user_func(array(&$this, $met), $arg);
4743 if ( !isset($value) || empty($value) )
4747 echo sprintf($base, $value);
4752 * AdminActions::parse_systemsettings()
4753 * Parse skinvar systemsettings
4755 * @param string $type type of settings for system
4756 * @param string $templateName name of template to use
4759 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4761 global $member, $CONF, $nucleus;
4763 $member->isAdmin() or Admin::disallow();
4765 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4766 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4773 case 'sqlserverinfo':
4774 echo sql_get_server_info();
4776 case 'sqlclientinfo':
4777 echo sql_get_client_info();
4779 case 'magicquotesgpc':
4780 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4782 case 'magicquotesruntime':
4783 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4785 case 'registerglobals':
4786 echo ini_get('register_globals') ? 'On' : 'Off';
4789 $templates = array();
4790 if ( $templateName )
4792 $templates = Template::read($templateName);
4794 if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
4796 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4800 $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
4803 $gdinfo = gd_info();
4805 foreach ( $gdinfo as $key => $value )
4807 if ( is_bool($value) )
4809 $value = $value ? $enable : $disable;
4813 $value = Entity::hsc($value);
4819 echo Template::fill($template, $data);
4824 phpinfo(INFO_MODULES);
4825 $im = ob_get_contents();
4827 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4829 case 'nucleusversion':
4830 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4832 case 'nucleuspatchlevel':
4833 echo getNucleusPatchLevel();
4839 echo $CONF['ItemURL'];
4841 case 'alertonheaderssent':
4842 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4844 case 'nucleuscodename':
4845 if ( $nucleus['codename'] != '' )
4847 echo ' "' . $nucleus['codename'] . '"';
4850 case 'versioncheckurl':
4851 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4858 * AdminActions::parse_templateoverview()
4859 * Parse skinvar templateoverview
4861 * @param string $templateName name of template to use
4864 public function parse_templateoverview($templateName = '')
4866 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4867 $query = sprintf($query, sql_table('template_desc'));
4868 $template['content'] = 'templatelist';
4869 $template['tabindex'] = 10;
4870 Showlist($query, 'table', $template, $templateName);
4875 * AdminActions::parse_ticket()
4881 public function parse_ticket()
4884 $manager->addTicketHidden();
4889 * AdminActions::parse_versioncheckurl()
4890 * Parse skinvar versioncheckurl
4895 public function parse_versioncheckurl()
4897 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4902 * AdminActions::parse_yrbloglist()
4903 * Parse skinvar yrbloglist
4905 * @param string $templateName name of template to use
4908 public function parse_yrbloglist($templateName = '')
4911 $showAll = requestVar('showall');
4913 if ( $member->isAdmin() && ($showAll == 'yes') )
4915 // Super-Admins have access to all blogs! (no add item support though)
4916 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4918 . " ORDER BY bnumber";
4919 $query = sprintf($query, sql_table('blog'));
4923 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4925 . " WHERE tblog=bnumber and tmember=%d"
4926 . " ORDER BY bnumber";
4927 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4930 $template['content'] = 'bloglist';
4931 $template['superadmin'] = $member->isAdmin();
4933 $amount = Showlist($query, 'table', $template, $templateName);
4935 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4937 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4939 $total = quickQuery($query);
4940 if ( $total > $amount )
4942 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4948 echo _OVERVIEW_NOBLOGS;
4950 elseif( $amount != 0 )
4952 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4954 $query = "SELECT ititle, inumber, bshortname"
4956 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
4957 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4959 $template['content'] = 'draftlist';
4961 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4962 if ( $amountdrafts == 0 )
4964 echo _OVERVIEW_NODRAFTS;
4971 * AdminActions::checkCondition()
4972 * Checks conditions for if statements
4974 * @param string $field type of <%if%>
4975 * @param string $name property of field
4976 * @param string $value value of property
4977 * @return boolean condition
4979 protected function checkCondition($field, $name='', $value = '')
4981 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
4992 $blog =& $manager->getBlog($blogid);
4996 $blogid = getBlogIDFromCatID($catid);
4998 $blog =& $manager->getBlog($blogid);
5000 elseif ( intRequestVar('catid') )
5002 $catid = intRequestVar('catid');
5003 $blogid = getBlogIDFromCatID($catid);
5005 $blog =& $manager->getBlog($blogid);
5012 $condition = ($blog && $this->ifCategory($name, $value));
5015 $condition = ($blog && ($blog->getSetting($name) == $value));
5018 $condition = $member->isLoggedIn();
5021 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5024 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5027 $condition = $member->isLoggedIn() && $member->isAdmin();
5029 case 'allowloginedit':
5030 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5033 $condition = ($itemidnext != '');
5036 $condition = ($itemidprev != '');
5038 case 'archiveprevexists':
5039 $condition = ($archiveprevexists == true);
5041 case 'archivenextexists':
5042 $condition = ($archivenextexists == true);
5045 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5048 $condition = $this->ifHasPlugin($name, $value);
5051 $condition = (Admin::getAdminAction() == $name);
5053 case 'adminoldaction':
5054 $condition = (Admin::getAdminAction() == $name);
5056 case 'addresschange':
5057 $condition = ($this->ifAddresscange());
5059 case 'bechangepass':
5060 $condition = ($this->beChangePassword());
5062 case 'skincandidates':
5063 $condition = ($this->ifSkincandidates());
5066 $condition = requestVar('nameclashes');
5068 case 'existsnewplugin':
5069 $condition = ($this->existsNewPlugin());
5072 $condition = (boolean) ($member->getAutosave() == $value);
5075 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5082 * Actions::_ifHasPlugin()
5083 * hasplugin,PlugName
5084 * -> checks if plugin exists
5085 * hasplugin,PlugName,OptionName
5086 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5087 * hasplugin,PlugName,OptionName=value
5088 * -> checks if the option OptionName from plugin PlugName is set to value
5090 * @param string $name name of plugin
5091 * @param string $value
5094 private function ifHasPlugin($name, $value)
5098 // (pluginInstalled method won't write a message in the actionlog on failure)
5099 if ( $manager->pluginInstalled("NP_{$name}") )
5101 $plugin =& $manager->getPlugin("NP_{$name}");
5102 if ( $plugin != NULL )
5110 list($name2, $value2) = preg_split('#=#', $value, 2);
5111 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5115 else if ( $plugin->getOption($name2) == $value2 )
5126 * Actions::beChangePassword()
5131 private function beChangePassword()
5133 return intRequestVar('bNeedsPasswordChange');
5137 * Actions::ifSkincandidates()
5138 * Checks if a plugin exists and call its doIf function
5143 private function ifSkincandidates()
5146 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5147 return (count($candidates) > 0);
5151 * Actions::ifPlugin()
5152 * Checks if a plugin exists and call its doIf function
5154 private function ifPlugin($name, $key = '', $value = '')
5158 $plugin =& $manager->getPlugin("NP_{$name}");
5164 $params = func_get_args();
5165 array_shift($params);
5167 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5171 * Different checks for a category
5173 private function ifCategory($name = '', $value='')
5175 global $blog, $catid;
5177 // when no parameter is defined, just check if a category is selected
5178 if (($name != 'catname' && $name != 'catid') || ($value == ''))
5180 return $blog->isValidCategory($catid);
5183 // check category name
5184 if ( $name == 'catname' )
5186 $value = $blog->getCategoryIdFromName($value);
5187 if ($value == $catid)
5189 return $blog->isValidCategory($catid);
5193 // check category id
5194 if (($name == 'catid') && ($value == $catid))
5196 return $blog->isValidCategory($catid);
5203 * Checks if a member is on the team of a blog and return his rights
5205 private function ifOnTeam($blogName = '')
5207 global $blog, $member, $manager;
5209 // when no blog found
5210 if ( ($blogName == '') && !is_object($blog) )
5215 // explicit blog selection
5216 if ($blogName != '')
5218 $blogid = getBlogIDFromName($blogName);
5221 if (($blogName == '') || !$manager->existsBlogID($blogid))
5224 $blogid = $blog->getID();
5226 return $member->teamRights($blogid);
5230 * Checks if a member is admin of a blog
5232 private function ifAdmin($blogName = '')
5234 global $blog, $member, $manager;
5236 // when no blog found
5237 if (($blogName == '') && (!is_object($blog)))
5242 // explicit blog selection
5243 if ($blogName != '')
5245 $blogid = getBlogIDFromName($blogName);
5248 if (($blogName == '') || !$manager->existsBlogID($blogid))
5251 $blogid = $blog->getID();
5254 return $member->isBlogAdmin($blogid);
5258 * Check e-Mail address is changed
5260 private function ifAddresscange()
5262 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5267 $info = MEMBER::getActivationInfo($key);
5272 $mem = MEMBER::createFromId($info->vmember);
5277 if ( $info->vtype == 'addresschange' )
5285 * AdminActions::customHelp()
5286 * shows a link to custom help file
5289 * @param string $tplName
5290 * @param string $url
5291 * @param string $iconURL
5292 * @param string $alt
5293 * @param string $title
5297 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5299 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5303 * AdminActions::customHelp()
5304 * shows a link to custom help file
5307 * @param string $tplName
5308 * @param string $url
5309 * @param string $iconURL
5310 * @param string $alt
5311 * @param string $title
5315 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5317 $templates = array();
5319 $templates = Template::read($tplName);
5321 if (isset($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) && !empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR'])) {
5322 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5324 $template = '<a href="<%helpurl%>#<%helptarget%>" title="<%title%>" <%onclick%>>';
5328 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5330 if (empty($onclick)) {
5331 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5332 } elseif (preg_match('/^onclick/', $onclick)) {
5333 $onclick = $onclick;
5335 $onclick = 'onclick="' . $onclick . '"';
5339 'helptarget' => $id,
5340 'onclick' => $onclick,
5341 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5343 return Template::fill($template, $data);
5347 * AdminActions::customHelpHtml()
5350 * @param string $tplName
5351 * @param string $url
5352 * @param string $iconURL
5353 * @param string $alt
5354 * @param string $title
5355 * @param string $onclick
5356 * @return string anchor element with help uri
5358 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5360 $templates = array();
5363 $templates = Template::read($tplName);
5365 if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5367 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5371 $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
5374 if ( empty($iconURL) )
5377 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5379 if ( function_exists('getimagesize') )
5381 $size = getimagesize($iconURL);
5382 $width = 'width="' . $size[0] . '" ';
5383 $height = 'height="' . $size[1] . '" ';
5386 'iconurl' => $iconURL,
5388 'height' => $height,
5389 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5390 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5392 $icon = Template::fill($template, $data);
5393 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5394 return $help . $icon;
5398 * AdminActions::input_yesno
5401 * @param $checkedval
5408 * @param $templateName
5411 private function input_yesno($name,
5422 $templates = array();
5423 if ( $templateName )
5425 $templates = Template::read($templateName);
5428 if ( $name == 'admin' )
5430 if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5432 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5436 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5437 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5438 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5439 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5444 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5446 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5450 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5452 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5455 if ( !isset($template) )
5457 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5458 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5459 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5460 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5465 $id = Entity::hsc($name);
5466 $id = str_replace('[', '-', $id);
5467 $id = str_replace(']', '-', $id);
5468 $id1 = $id . Entity::hsc($value1);
5469 $id2 = $id . Entity::hsc($value2);
5471 'name' => Entity::hsc($name),
5472 'yesval' => Entity::hsc($value1),
5473 'noval' => Entity::hsc($value2),
5476 'yesvaltext' => $yesval,
5477 'novaltext' => $noval,
5478 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5479 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5480 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5485 return Template::fill($template, $dat);
5489 echo Template::fill($template, $dat);
5495 * Check exists new plugin
5497 private function existsNewPlugin()
5499 global $DIR_PLUGINS;
5500 $candidates = array();
5501 $files = scandir($DIR_PLUGINS);
5502 foreach ($files as $file) {
5503 if (preg_match("/^NP_(.*)\.php$/", $file, $matches)) {
5504 $name = $matches[1];
5508 . sql_table('plugin') . ' '
5510 . ' pfile = "NP_' . sql_real_escape_string($name) . '"';
5511 $res = sql_query($que);
5512 if (sql_num_rows($res) == 0) {
5513 $candidates[] = $name;
5517 $this->newPlugCandidates = $candidates;
5518 return (count($candidates) > 0);