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 'listplugplugoptionrow',
110 'selectlocaladminskinfiles',
111 'selectlocalskinfiles',
112 'skineditallowedlist',
129 * AdminActions::$default_actions
130 * list of whole action names with which this class can deal
132 static private $default_actions = array(
143 * AdminActions::$skin_type_friendly_names
144 * friendly name for wrapped page types
146 static private $default_skin_types = array(
147 'actionlog' => _ADM_SKPRT_ACTIONLOG,
148 'activate' => _ADM_SKPRT_ACTIVATE,
149 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
150 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
151 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
152 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
153 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
154 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
155 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
156 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
157 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
158 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
159 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
160 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
161 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
162 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
163 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
164 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
165 'banlist' => _ADM_SKPRT_BANLIST,
166 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
167 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
168 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
169 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
170 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
171 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
172 'batchitem' => _ADM_SKPRT_BATCHITEM,
173 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
174 'batchmove' => _ADM_SKPRT_BATCHMOVE,
175 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
176 'batchteam' => _ADM_SKPRT_BATCHTEAM,
177 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
178 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX,
179 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
180 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
181 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
182 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
183 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
184 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
185 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
186 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
187 'createitem' => _ADM_SKPRT_CREATEITEM,
188 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
189 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
190 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
191 'insertpluginoptions' => _ADM_SKPRT_INSERTPLUGINO,
192 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
193 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
194 'itemedit' => _ADM_SKPRT_ITEMEDIT,
195 'itemlist' => _ADM_SKPRT_ITEMLIST,
196 'itemmove' => _ADM_SKPRT_ITEMMOVE,
197 'login' => FALSE, //missing
198 'manage' => _ADM_SKPRT_MANAGE,
199 'manageteam' => _ADM_SKPRT_MANAGETEAM,
200 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
201 'memberedit' => FALSE, //missing
202 'overview' => _ADM_SKPRT_OVERVIEW,
203 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
204 'pagehead' => _ADM_SKPRT_PAGEHEAD,
205 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
206 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
207 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
208 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
209 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
210 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
211 'skindelete' => _ADM_SKPRT_SKINDELETE,
212 'skinedit' => _ADM_SKPRT_SKINEDIT,
213 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
214 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
215 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
216 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
217 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
218 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
219 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
220 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
221 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
222 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
223 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
224 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
228 * AdminActions::getAvailableSkinTypes()
232 * @return array list of friendly names for page actions
234 static public function getAvailableSkinTypes()
236 return self::$default_skin_types;
240 * AdminActions::getDefaultTypes()
244 * @return array list of friendly names for page actions
246 static public function getDefaultTypes()
248 return self::$default_skin_types;
252 * AdminActions::__construct()
253 * Constructor for a new Actions object
255 * @param string $type
258 public function __construct($type)
260 // call constructor of superclass first
261 parent::__construct();
262 $this->skintype = $type;
263 if ( !class_exists('Navlist') || !class_exists('Batch') )
266 include $DIR_LIBS . 'ENCAPSULATE.php';
272 * AdminActions::getAvailableActions()
275 * @return array allowed actions for the page type
277 public function getAvailableActions()
279 $extra_actions = array();
281 switch ( $this->skintype )
284 $extra_actions = array(
289 $extra_actions = array(
294 case 'activatesetpwd':
295 $extra_actions = array(
299 $extra_actions = array(
305 case 'adminerrorpage':
306 $extra_actions = array(
309 case 'adminskindelete':
310 $extra_actions = array(
314 case 'adminskinedit':
315 $extra_actions = array(
317 'defaultadminskintypes',
318 'adminspecialskinlist',
321 case 'adminskinedittype':
322 $extra_actions = array(
325 'allowedadminskinactions',
326 'adminskineditallowedlist',
329 case 'adminskiniedoimport':
330 $extra_actions = array(
334 case 'adminskinieimport':
335 $extra_actions = array(
339 case 'adminskinieoverview':
340 $extra_actions = array(
341 'selectlocaladminskinfiles',
345 case 'adminskinoverview':
346 $extra_actions = array(
350 case 'adminskinremovetype':
351 $extra_actions = array(
355 case 'admintemplatedelete':
356 $extra_actions = array(
357 'editadmintemplateinfo',
359 case 'admintemplateedit':
360 $extra_actions = array(
361 'editadmintemplateinfo',
364 case 'admntemplateoverview':
365 $extra_actions = array(
366 'admintemplateoverview',
369 case 'backupoverview':
370 $extra_actions = array(
373 case 'backuprestore':
374 $extra_actions = array(
378 $extra_actions = array(
384 case 'banlistdelete':
385 $extra_actions = array(
390 case 'banlistdeleteconfirm':
391 $extra_actions = array(
392 'banlistdeletedlist',
397 $extra_actions = array(
403 case 'batchcategory':
404 $extra_actions = array(
410 $extra_actions = array(
416 $extra_actions = array(
422 $extra_actions = array(
428 $extra_actions = array(
434 $extra_actions = array(
443 $extra_actions = array(
452 $extra_actions = array(
458 case 'blogcommentlist':
459 $extra_actions = array(
465 case 'blogselectbox':
466 $extra_actions = array(
471 $extra_actions = array(
487 $extra_actions = array(
491 case 'browseowncomments':
492 $extra_actions = array(
496 case 'browseownitems':
497 $extra_actions = array(
501 case 'categorydelete':
502 $extra_actions = array(
508 $extra_actions = array(
515 case 'commentdelete':
516 $extra_actions = array(
521 $extra_actions = array(
526 $extra_actions = array(
538 $extra_actions = array(
544 $extra_actions = array(
549 case 'editmembersettings':
550 $extra_actions = array(
552 'adminskinselectoptions',
556 case 'insertpluginoptions':
557 $extra_actions = array(
558 'insertpluginoptions',
561 case 'itemcommentlist':
562 $extra_actions = array(
568 $extra_actions = array(
575 $extra_actions = array(
587 $extra_actions = array(
594 $extra_actions = array(
600 $extra_actions = array(
604 $extra_actions = array(
613 $extra_actions = array(
618 $extra_actions = array(
623 $extra_actions = array(
631 $extra_actions = array(
644 $extra_actions = array(
649 $extra_actions = array(
655 $extra_actions = array(
660 case 'pluginoptions':
661 $extra_actions = array(
663 'editplugoptionslist',
667 $extra_actions = array(
670 'configsettingsedit',
671 'configsettingsyesno',
679 $extra_actions = array(
684 $extra_actions = array(
689 $extra_actions = array(
695 $extra_actions = array(
698 'allowedskinactions',
699 'skineditallowedlist',
700 'skineditallowedlist',
703 case 'skiniedoimport':
704 $extra_actions = array(
709 $extra_actions = array(
713 case 'skinieoverview':
714 $extra_actions = array(
715 'selectlocalskinfiles',
720 $extra_actions = array(
724 case 'skinremovetype':
725 $extra_actions = array(
729 case 'systemoverview':
730 $extra_actions = array(
735 $extra_actions = array(
741 case 'templatedelete':
742 $extra_actions = array(
747 $extra_actions = array(
751 case 'templateoverview':
752 $extra_actions = array(
756 case 'usermanagement':
757 $extra_actions = array(
763 $extra_actions = array(
773 'selectlocaladminskinfiles',
781 $defined_actions = array_merge(self::$default_actions, $extra_actions);
783 return array_merge($defined_actions, parent::getAvailableActions());
787 * AdminActions::setSkin()
789 * @param object $skin an instance of Skin class
792 public function setSkin(&$skin)
794 $this->skin =& $skin;
799 * AdminActions::parse_actionloglist()
800 * Parse skinvar actionloglist
802 * @param string $templateName name of template to use
805 public function parse_actionloglist($templateName = '')
807 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
808 $query = sprintf($query, sql_table('actionlog'));
810 $template['content'] = 'actionlist';
811 $amount = showlist($query, 'table', $template, $templateName);
817 * AdminActions::parse_activationmessage()
818 * Parse skinvar activationmessage
820 * @param string $type type of message
821 * @param string $templateName name of template to use
824 public function parse_activationmessage($type, $templateName = '')
826 global $CONF, $manager;
830 if ( !empty($templateName))
832 $template = Template::read($templateName);
835 $key = postVar('ackey');
838 Admin::error(_ERROR_ACTIVATE);
841 $info = MEMBER::getActivationInfo($key);
844 Admin::error(_ERROR_ACTIVATE);
847 $mem = MEMBER::createFromId($info->vmember);
850 Admin::error(_ERROR_ACTIVATE);
852 switch ( $info->vtype )
855 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
857 $title = $template['ACTIVATE_FORGOT_TITLE'];
861 $title = _ACTIVATE_FORGOT_TITLE;
863 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
865 $text = $template['ACTIVATE_FORGOT_TEXT'];
869 $text = _ACTIVATE_FORGOT_TEXT;
873 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
875 $title = $template['ACTIVATE_REGISTER_TITLE'];
879 $title = _ACTIVATE_REGISTER_TITLE;
881 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
883 $text = $template['ACTIVATE_REGISTER_TEXT'];
887 $text = _ACTIVATE_REGISTER_TEXT;
890 case 'addresschange':
891 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
893 $title = $template['ACTIVATE_CHANGE_TITLE'];
897 $title = _ACTIVATE_CHANGE_TITLE;
899 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
901 $text = $template['ACTIVATE_CHANGE_TEXT'];
905 $text = _ACTIVATE_CHANGE_TEXT;
910 'memberName' => Entity::hsc($mem->getDisplayName()),
911 'realName' => Entity::hsc($mem->getRealName()),
916 echo Template::fill($title, $aVars);
919 echo Template::fill($text, $aVars);
922 echo Entity::hsc($key);
929 * AdminActions::parse_addtickettourl()
930 * Parse skinvar addtickettourl
932 * @param string $url URI for ticket
935 public function parse_addtickettourl($url)
938 $url = $manager->addTicketToUrl($url);
939 echo Entity::hsc($url);
944 * AdminActions::parse_adminbanlist()
945 * Parse skinvar adminbanlist
947 * @param string $templateName name of template to use
950 public function parse_adminbanlist($templateName = '')
952 $blogid = intRequestVar('blogid');
954 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
955 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
957 $template['content'] = 'banlist';
959 $amount = Showlist($query, 'table', $template, $templateName);
969 * AdminActions::parse_adminbatchaction()
970 * Parse skinvar adminbatchaction
975 public function parse_adminbatchaction()
977 echo Entity::hsc(requestVar('batchaction'));
982 * AdminActions::parse_adminbatchlist()
983 * Parse skinvar adminbatchlist
985 * @param string $templateName name of template to use
988 public function parse_adminbatchlist($templateName = '')
991 $templates = array();
993 if ( !empty($templateName) )
995 $templates = Template::read($templateName);
998 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
1000 $template = '<li><%text(_BATCH_EXECUTING)%>'
1001 . '<b><%adminbatchaction%></b>'
1002 . '<%batchlisttype%>'
1003 . '<b><%batchid%></b>...'
1004 . '<b><%batchlistmsg%></b>'
1009 $template = $templates['ADMIN_BATCHLIST'];
1012 $selected = requestIntArray('batch');
1013 $action = requestVar('batchaction');
1015 switch ( $this->skintype )
1018 $batchlisttype = _BATCH_ONITEM;
1019 $deleteaction = 'deleteOneItem';
1020 $moveaction = 'moveOneItem';
1021 $destid = intRequestVar('destcatid');
1023 case 'batchcomment':
1024 $batchlisttype = _BATCH_ONCOMMENT;
1025 $deleteaction = 'deleteOneComment';
1028 $batchlisttype = _BATCH_ONMEMBER;
1029 $deleteaction = 'deleteOneMember';
1030 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1031 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1032 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1033 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1036 $blogid = intRequestVar('blogid');
1037 $batchlisttype = _BATCH_ONTEAM;
1038 $deleteaction = 'deleteOneTeamMember';
1039 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1040 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1041 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1042 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1044 case 'batchcategory':
1045 $batchlisttype = _BATCH_ONCATEGORY;
1046 $deleteaction = 'deleteOneCategory';
1047 $moveaction = 'moveOneCategory';
1048 $destid = intRequestVar('destblogid');
1052 // walk over all selectedids and perform action
1053 foreach ( $selected as $selectedid )
1056 $selectedid = intval($selectedid);
1061 if ( $this->skintype != 'batchteam' )
1063 $error = Admin::deleteaction($selectedid);
1067 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1071 $error = Admin::moveaction($selectedid, $destid);
1075 sql_query("UPDATE {$setadminsql} {$selectedid};");
1079 // there should always remain at least one super-admin
1080 $r = sql_query($unsetchksql);
1081 if ( sql_num_rows($r) < 2 )
1083 $error = $unseterrmsg;
1087 sql_query("UPDATE {$setadminsql} {$selectedid};");
1091 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1095 'batchid' => $selectedid,
1096 'batchlisttype' => Entity::hsc($batchlisttype),
1097 'adminbatchaction' => Entity::hsc($action),
1098 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1101 $handler = new AdminActions('template');
1102 $parser = new Parser($handler);
1105 $parser->parse($template);
1106 $template = ob_get_contents();
1109 echo Template::fill($template, $data);
1115 * AdminActions::parse_adminbloglink()
1116 * Parse skinvar adminbloglink
1118 * @param string $templateName name of template to use
1121 public function parse_adminbloglink($templateName = '')
1124 $blogid = intRequestVar('blogid');
1125 $blog =& $manager->getBlog($blogid);
1126 $templates = array();
1128 if ( !empty($templateName) )
1130 $templates = Template::read($templateName);
1133 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1135 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1139 $template = $templates['ADMIN_BLOGLINK'];
1143 'url' => Entity::hsc($blog->getURL()),
1144 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1145 'blogname' => Entity::hsc($blog->getName())
1148 echo Template::fill($template, $data);
1153 * AdminActions::parse_adminerrormesg()
1154 * Parse skinvar adminerrormesg
1159 public function parse_adminerrormesg()
1164 if ( requestVar('errormessage') )
1166 $message = requestVar('errormessage');
1168 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1170 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1172 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1174 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1176 echo Entity::hsc($message);
1181 * AdminActions::parse_adminskineditallowedlist()
1182 * Parse skinvar adminskineditallowedlist
1184 * @param string $type template/blog
1185 * @param string $templateName name of template to use
1188 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1192 /* TODO: blog seems not to be used */
1194 $query = "SELECT bshortname, bname FROM %s";
1195 $query = sprintf($query, sql_table('blog'));
1197 'content' => 'shortblognames'
1199 Showlist($query, 'table', $show, $templateName);
1202 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1203 $query = sprintf($query, sql_table('template_desc'));
1205 'content' => 'shortnames'
1207 Showlist($query, 'table', $show, $templateName);
1214 * AdminActions::parse_adminskinielist()
1215 * Parse skinvar adminskinielist
1217 * @param string $type skin/template
1218 * @param string $templateName name of template to use
1221 public function parse_adminskinielist($type, $templateName = '')
1223 $templates = array();
1224 if ( $templateName )
1226 $templates = Template::read($templateName);
1229 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1232 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1233 . "<label for=\"<%expid%>\"><%expname%></label>"
1235 . "<td><%expdesc%></td>\n"
1241 $template = $templates['SKINIE_EXPORT_LIST'];
1247 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1248 $query = sprintf($query, sql_table('skin_desc'));
1249 $res = sql_query($query);
1251 while ( $skinObj = sql_fetch_object($res) )
1254 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
1255 'expid' => 'skinexp' . $skinObj->sdnumber,
1256 'expname' => Entity::hsc($skinObj->sdname),
1257 'expdesc' => Entity::hsc($skinObj->sddesc),
1259 echo Template::fill($template, $data);
1263 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1264 $query = sprintf($query, sql_table('template_desc'));
1265 $res = sql_query($query);
1266 while ( $templateObj = sql_fetch_object($res) )
1269 'typeid' => 'template[' . $templateObj->tdnumber . ']',
1270 'expid' => 'templateexp' . $templateObj->tdnumber,
1271 'expname' => Entity::hsc($templateObj->tdname),
1272 'expdesc' => Entity::hsc($templateObj->tddesc),
1274 echo Template::fill($template, $data);
1282 * AdminActions::parse_adminskinoverview()
1283 * Parse skinvar adminskinoverview
1285 * @param string $templateName name of template to use
1288 public function parse_adminskinoverview($templateName = '')
1290 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1291 $query = sprintf($query, sql_table('skin_desc'));
1293 $template['content'] = 'adminskinlist';
1294 $template['tabindex'] = 10;
1295 $template['friendly_names'] = $this->skin->getAvailableTypes();
1296 Showlist($query, 'table', $template, $templateName);
1301 * AdminActions::parse_adminskinselectoptions()
1302 * Parse skinvar adminskinselectoptions
1307 public function parse_adminskinselectoptions()
1310 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1311 $query = sprintf($query, sql_table('skin_desc'));
1313 $template['name'] = 'adminskin';
1314 $template['selected'] = $CONF['DefaultAdminSkin'];
1315 $template['tabindex'] = 110;
1316 Showlist($query, 'select', $template, '');
1321 * AdminActions::parse_adminspecialskinlist()
1322 * Parse skinvar adminspecialskinlist
1324 * @param string $templateName name of template to use
1326 public function parse_adminspecialskinlist($templateName = '')
1328 $templates = array();
1329 if ( $templateName )
1331 $templates = Template::read($templateName);
1334 $nType = $this->skin->getAvailableTypes();
1335 $skinid = intRequestVar('skinid');
1337 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1338 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1340 $res = sql_query($query);
1341 if ( $res && sql_num_rows($res) > 0 )
1343 /* NOTE: set templates for HEAD/BODY/FOOT */
1344 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1346 $template['head'] = "<ul>\n";
1350 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1352 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1354 $template['body'] = '<li>'
1355 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1358 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1365 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1367 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1369 $template['foot'] = "</ul>\n";
1373 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1380 echo $template['head'];
1381 while ( $row = sql_fetch_assoc($res) )
1384 'tabindex' => $tabstart++,
1385 'skinid' => $skinid,
1386 'skintype' => Entity::hsc(strtolower($row['stype']))
1388 echo Template::fill($template['body'], $data);
1391 echo $template['foot'];
1397 * AdminActions::parse_admintemplateoverview()
1398 * Parse skinvar admintemplateoverview
1400 * @param string $templateName name of template to use
1403 public function parse_admintemplateoverview($templateName = '')
1405 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1406 $query = sprintf($query, sql_table('template_desc'));
1408 $template['content'] = 'admintemplatelist';
1409 $template['tabindex'] = 10;
1411 Showlist($query, 'table', $template, $templateName);
1416 * AdminActions::parse_allowedadminskinactions()
1417 * Parse skinvar allowedadminskinactions
1422 public function parse_allowedadminskinactions()
1424 global $DIR_ADMINSKINS;
1425 $skinType = strtolower(trim(requestVar('type')));
1426 $actions = $this->skin->getAllowedActionsForType($skinType);
1429 while ( $current = array_shift($actions) )
1431 // TODO: remove this
1432 // skip deprecated vars
1433 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1438 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1440 if ( count($actions) != 0 )
1449 * AdminActions::parse_allowedskinactions()
1450 * Parse skinvar allowedskinactions
1455 public function parse_allowedskinactions()
1457 $skinType = strtolower(trim(requestVar('type')));
1458 $skinid = intRequestVar('skinid');
1460 $skin = new Skin($skinid);
1461 $actions = $skin->getAllowedActionsForType($skinType);
1464 while ( $current = array_shift($actions) )
1466 // TODO: remove this
1467 // skip deprecated vars
1468 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1473 /* TODO: alternative function should be used or not? */
1474 echo helplink("skinvar-{$current}") . "$current</a>\n";
1476 if ( count($actions) != 0 )
1485 * AdminActions::parse_banlistdeletedlist()
1486 * Parse skinvar banlistdeletedlist
1488 * @param string $templateName name of template to use
1491 public function parse_banlistdeletedlist($templateName = '')
1494 $templates = array();
1496 if ( $templateName )
1498 $templates = Template::read($templateName);
1500 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1502 $template = "<li><%blogname%></li>\n";
1506 $template = $templates['BANLIST_DELETED_LIST'];
1509 $deleted = requestArray('delblogs');
1510 foreach ( $deleted as $delblog )
1512 $blog =& $manager->getBlog($delblog);
1514 Entity::hsc($blog->getName())
1516 Template::fill($template, $data);
1522 * AdminActions::parse_batchdeletelist()
1523 * Parse skinvar batchdeletelist
1528 public function parse_batchdeletelist()
1530 $selected = requestIntArray('batch');
1533 foreach ( $selected as $select )
1535 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1537 // add hidden vars for team & comment
1538 if ( requestVar('action') == 'batchteam' )
1540 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1542 if ( requestVar('action') == 'batchcomment' )
1544 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1550 * AdminActions::parse_batchdeletetype()
1551 * Parse skinvar batchdeletetype
1556 public function parse_batchdeletetype()
1558 echo Entity::hsc(requestVar('action'));
1563 * AdminActions::parse_batchmovebtn()
1564 * Parse skinvar batchmovebtn
1569 public function parse_batchmovebtn()
1571 $actionType = requestVar('action');
1572 switch ( $actionType )
1577 case 'batchcategory':
1585 * AdminActions::parse_batchmovelist()
1586 * Parse skinvar batchmovelist
1591 public function parse_batchmovelist()
1593 $selected = requestIntArray('batch');
1594 foreach ( $selected as $select )
1596 echo '<input type="hidden" name="batch[' . ($select++) . ']" value="' . intval($select) . "\" />\n";
1602 * AdminActions::parse_batchmovetitle()
1603 * Parse skinvar batchmovetitle
1608 public function parse_batchmovetitle()
1610 $actionType = requestVar('action');
1611 switch ( $actionType )
1616 case 'batchcategory':
1617 echo _MOVECAT_TITLE;
1624 * AdminActions::parse_batchmovetype()
1625 * Parse skinvar batchmovetype
1630 public function parse_batchmovetype()
1632 echo Entity::hsc(requestVar('action'));
1637 * AdminActions::parse_blogcatlist()
1638 * Parse skinvar blogcatlist
1643 public function parse_blogcatlist()
1646 $blogid = intRequestVar('blogid');
1647 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1648 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1650 $template['content'] = 'categorylist';
1651 $template['tabindex'] = 200;
1653 $batch = new Batch('category');
1654 $batch->showlist($query, 'table', $template);
1659 * AdminActions::parse_blogid()
1660 * Parse skinvar blogid
1665 function parse_blogid()
1667 echo intRequestVar('blogid');
1672 * AdminActions::parse_blognotifysetting()
1673 * Parse skinvar blognotifysetting
1678 public function parse_blognotifysetting($type)
1681 $blogid = intRequestVar('blogid');
1682 $blog = $manager->getBlog($blogid);
1687 if ( !$blog->notifyOnComment() )
1693 if ( !$blog->notifyOnVote() )
1699 if ( !$blog->notifyOnNewItem() )
1705 echo ' checked="checked"';
1710 * AdminActions::parse_blogselectbox()
1711 * Parse skinvar blogselectbox
1716 public function parse_blogselectbox()
1720 $selectData = requestVar('selectData');
1721 $mode = $selectData['mode'];
1722 $name = Entity::hsc($selectData['name']);
1723 $tabindex = Entity::hsc($selectData['tabindex']);
1724 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1725 $showNewCat = intval($selectData['showNewCat']);
1726 $selected = intval($selectData['selected']);
1728 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1730 // 1. select blogs (we'll create optiongroups)
1731 // (only select those blogs that have the user on the team)
1732 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1733 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1734 $blogs = sql_query($queryBlogs);
1736 if ( $mode == 'category' )
1738 if ( sql_num_rows($blogs) > 1 )
1742 while ( $oBlog = sql_fetch_object($blogs) )
1744 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1746 echo '<optgroup label="' . Entity::hsc($oBlog->bname) . "\">\n";
1749 // show selection to create new category when allowed/wanted
1752 // check if allowed to do so
1753 if ( $member->blogAdminRights($oBlog->bnumber) )
1755 echo '<option value="newcat-' . $oBlog->bnumber . '">' . _ADD_NEWCAT . "</option>\n";
1759 // 2. for each category in that blog
1760 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1761 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
1762 $categories = sql_query($catQuery);
1763 while ( $oCat = sql_fetch_object($categories) )
1765 if ( $oCat->catid == $selected )
1767 $selectText = ' selected="selected" ';
1773 echo '<option value="' . $oCat->catid . '" ' . $selectText . '>' . Entity::hsc($oCat->cname) . "</option>\n";
1776 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1785 while ( $oBlog = sql_fetch_object($blogs) )
1787 echo '<option value="' . $oBlog->bnumber . '"';
1788 if ( $oBlog->bnumber == $selected )
1790 echo '<option value="' . $oBlog->bnumber . '" selected="selected">' . Entity::hsc($oBlog->bname) . "</option>\n";
1794 echo '<option value="' . $oBlog->bnumber . '">' . Entity::hsc($oBlog->bname) . "</option>\n";
1803 * AdminActions::parse_blogsetting()
1804 * Parse skinvar blogsetting
1806 * @param string $which name of weblog setting
1809 public function parse_blogsetting($which)
1811 echo $this->parse_getblogsetting($which);
1816 * AdminActions::parse_blogsettingyesno()
1817 * Parse skinvar blogsettingyesno
1819 * @param string $type type of weblog setting
1820 * @param string $templateName name of template to use
1823 public function parse_blogsettingyesno($type, $templateName = '')
1827 $blogid = intRequestVar('blogid');
1828 $blog = $manager->getBlog($blogid);
1832 case 'convertbreaks':
1833 $checkedval = $blog->convertBreaks();
1836 case 'allowpastposting':
1837 $checkedval = $blog->allowPastPosting();
1841 $checkedval = $blog->commentsEnabled();
1845 $checkedval = $blog->isPublic();
1849 $checkedval = $blog->emailRequired();
1853 $checkedval = $blog->getSearchable();
1857 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1862 * AdminActions::parse_blogteamlist()
1863 * Parse skinvar blogteamlist
1865 * @param string $templateName name of template to use
1868 public function parse_blogteamlist($templateName = '')
1871 $blogid = intRequestVar('blogid');
1872 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1874 . "WHERE tmember=mnumber AND tblog= %d";
1875 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1877 $template['content'] = 'teamlist';
1878 $template['tabindex'] = 10;
1880 $batch = new Batch('team');
1881 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1886 * AdminActions::parse_blogteammembers()
1887 * Parse skinvar blogteammembers
1892 public function parse_blogteammembers()
1894 $blogid = intRequestVar('blogid');
1895 $query = "SELECT mname, mrealname "
1897 . "WHERE mnumber=tmember AND tblog=%d;";
1898 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1899 $res = sql_query($query);
1900 $memberNames = array();
1901 while ( $o = sql_fetch_object($res) )
1903 $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
1905 echo implode(',', $memberNames);
1909 * AdminActions::parse_blogtime()
1910 * Parse skinvar blogtime
1912 * @param string $type type of time
1913 * @param string $format format for time expression
1914 * @param integer $offset offset of time
1917 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1921 if ( $type != 'blogtime' )
1923 /* return server time */
1924 $timestamp = time() + $offset;
1928 $bid = intRequestVar('blogid');
1929 $b = $manager->getBlog($bid);
1930 $timestamp = $b->getCorrectTime() + $offset;
1933 echo i18n::formatted_datetime($format, $timestamp);
1938 * AdminActions::parse_bookmarkletadmin()
1939 * Parse skinvar bookmarkletadmin
1944 public function parse_bookmarkletadmin()
1948 $blogid = intRequestVar('blogid');
1950 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1955 * AdminActions::parse_categories()
1956 * Parse skinvar categories
1958 * create category dropdown box
1960 * @param string $type name of setting for category
1963 function parse_categories($startidx = 0)
1968 $itemid = intRequestVar('itemid');
1970 $item =& $manager->getItem($itemid, 1, 1);
1971 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1973 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1975 $item['body'] = removeBreaks($item['body']);
1976 $item['more'] = removeBreaks($item['more']);
1979 $contents = array();
1980 if ( requestVar('action') == 'itemedit' )
1984 if ( isset($contents['catid']) && $contents['catid'] )
1986 $catid = $contents['catid']; // on edit item
1990 $catid = $blog->getDefaultCategory(); // on add item
1992 Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
1997 * AdminActions::parse_category()
1998 * Parse skinvar category
2000 * @param string $type name of setting for category
2003 public function parse_category($type = 'name')
2005 echo $this->parse_getcategory($type);
2010 * AdminActions::parse_categorysetting()
2011 * Parse skinvar categorysetting
2013 * @param string $type type in category setting
2016 public function parse_categorysetting($type)
2018 $catid = intRequestVar('catid');
2019 if ( $type == 'id' )
2024 $blogid = intRequestVar('blogid');
2025 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
2026 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
2027 $res = sql_query($query);
2028 $obj = sql_fetch_object($res);
2030 if ( $type != 'name' )
2032 echo Entity::hsc($obj->cdesc);
2036 echo Entity::hsc($obj->cname);
2043 * AdminActions::parse_codename()
2044 * Parse templatevar codename
2050 function parse_checkedonval($value, $name)
2055 $itemid = intRequestVar('itemid');
2056 $item =& $manager->getItem($itemid, 1, 1);
2058 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2060 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
2062 $item['body'] = removeBreaks($item['body']);
2063 $item['more'] = removeBreaks($item['more']);
2066 $contents = array();
2067 if ( requestVar('action') == 'itemedit' )
2071 if ( !isset($contents[$name]) )
2073 $contents[$name] = '';
2075 if ($contents[$name] == $value)
2077 echo 'checked="checked"';
2083 * AdminActions::parse_codename()
2084 * Parse templatevar codename
2089 * TODO: is this need???
2091 public function parse_codename()
2094 echo $nucleus['codename'];
2099 * AdminActions::parse_commentnavlist()
2100 * Parse skinvar commentnavlist
2105 public function parse_commentnavlist()
2107 global $CONF, $manager, $member;
2110 if ( postVar('start') )
2112 $start = intPostVar('start');
2119 // amount of items to show
2120 if ( postVar('amount') )
2122 $amount = intPostVar('amount');
2126 $amount = (integer) $CONF['DefaultListSize'];
2132 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2134 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2136 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2138 if ( $this->skintype == 'itemcommentlist' )
2140 $itemid = intRequestVar('itemid');
2141 $query .= " citem={$itemid}";
2142 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2144 $nonComments = _NOCOMMENTS;
2146 elseif ( $this->skintype == 'browseowncomments' )
2149 $query .= ' cmember=' . $member->getID();
2150 $template['canAddBan'] = 0;
2152 $nonComments = _NOCOMMENTS_YOUR;
2154 elseif ( $this->skintype == 'blogcommentlist' )
2157 $query .= ' cblog=' . intRequestVar('blogid');
2158 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2159 $bid = intRequestVar('blogid');
2160 $nonComments = _NOCOMMENTS_BLOG;
2163 $search = postVar('search');
2164 if ( !empty($search) )
2166 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
2169 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2171 $template['content'] = 'commentlist';
2173 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2174 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2179 * AdminActions::parse_configsettingsedit()
2180 * Parse skinvar configsettingsedit
2182 * @param string $type type of global configuration
2185 public function parse_configsettingsedit($type)
2190 case 'DefaultListSize':
2191 if ( !array_key_exists('DefaultListSize', $CONF) )
2193 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2194 $query = sprintf($query, sql_table('config'));
2196 $CONF['DefaultListSize'] = 10;
2198 elseif ( intval($CONF['DefaultListSize']) < 1 )
2200 $CONF['DefaultListSize'] = 10;
2202 echo intval($CONF['DefaultListSize']);
2204 case 'SessionCookie':
2205 $value = $CONF['SessionCookie'];
2206 $txt1 = _SETTINGS_COOKIESESSION;
2207 $txt2 = _SETTINGS_COOKIEMONTH;
2208 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2211 $value = $CONF['URLMode'];
2212 $txt1 = _SETTINGS_URLMODE_NORMAL;
2213 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2214 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2217 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2219 echo Entity::hsc($CONF[$type]);
2227 * AdminActions::parse_configsettingsyesno()
2228 * Parse skinvar configsettingsyesno
2230 * @param string $type type of global setting
2231 * @param integer $tabindex tabindex attribute of input element
2234 public function parse_configsettingsyesno($type, $tabindex)
2237 if ( array_key_exists($type, $CONF) )
2239 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2245 * AdminActions::parse_contents()
2246 * Parse skinvar contents
2248 * @param string $which part for item
2251 function parse_contents($which)
2256 $contents = array();
2258 if ( requestVar('action') == 'itemedit' )
2260 $itemid = intRequestVar('itemid');
2261 $item =& $manager->getItem($itemid, 1, 1);
2263 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2265 if ( $item && $blog->convertBreaks() )
2267 $item['body'] = removeBreaks($item['body']);
2268 $item['more'] = removeBreaks($item['more']);
2272 elseif ( requestVar('action') == 'createitem' )
2274 $blogid = intRequestVar('blogid');
2275 $blog =& $manager->getBlog($blogid);
2279 'contents' => &$contents,
2285 if ( !array_key_exists($which, $contents) )
2287 $contents[$which] = '';
2289 echo Entity::hsc($contents[$which],ENT_QUOTES);
2293 * AdminActions::parse_currenttime()
2294 * Parse skinvar currenttime
2296 * @param string $what
2299 function parse_currenttime($what)
2302 if ( requestVar('action') == 'itemedit' )
2304 $itemid = intRequestVar('itemid');
2305 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2307 elseif ( requestVar('action') == 'createitem' )
2309 $blog =& $manager->getBlog(intRequestVar('blogid'));
2311 $nu = getdate($blog->getCorrectTime());
2316 * AdminActions::parse_customhelplink()
2317 * Parse skinvar customhelplink
2319 * @param string $topic name of topic
2320 * @param string $tplName name of template
2321 * @param string $url string as URI
2322 * @param string $iconURL string as URI for icon
2323 * @param string $alt alternative text for image element
2324 * @param string $title title for anchor element
2327 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2329 $this->customHelp($topic, $url, $iconURL);
2334 * AdminActions::parse_date()
2335 * Parse skinvar date
2337 public function parse_date($format = 'c')
2339 global $CONF, $manager;
2340 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2345 * AdminActions::parse_defaultadminskintypes()
2346 * Parse skinvar defaultadminskintypes
2348 * @param string $tabindex index number for tabindex attribute of input element
2349 * @param string $templateName name of template
2352 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2354 $templates = array();
2356 if ( $templateName )
2358 $templates = Template::read($templateName);
2361 $types = $this->skin->getAvailableTypes();
2364 /* NOTE: set templates for HEAD/BODY/FOOT */
2365 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2367 $template['head'] = "<ul>\n";
2371 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2373 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2375 $template['body'] = "<li>"
2376 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2381 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2383 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2385 $template['foot'] = "</ul>\n";
2389 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2392 $handler = new AdminActions('template');
2393 $parser = new PARSER($handler);
2395 /* NOTE: do output */
2396 echo $template['head'];
2397 foreach ( $types as $type => $fName )
2399 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2401 'tabindex' => $tabindex,
2402 'skintype' => $type,
2404 'help' => $helplink,
2405 'skinid' => intrequestVar('skinid'),
2407 $parser->parse(Template::fill($template['body'], $data));
2410 echo $template['foot'];
2416 * AdminActions::parse_defblogselect()
2417 * Parse skinvar defblogselect
2419 * @param string $templateName name of template
2422 public function parse_defblogselect($templateName = '')
2426 $query = "SELECT bname as text, bnumber as value FROM %s;";
2427 $query = sprintf($query, sql_table('blog'));
2429 $template['name'] = 'DefaultBlog';
2430 $template['selected'] = $CONF['DefaultBlog'];
2431 $template['tabindex'] = 10;
2433 Showlist($query, 'select', $template, $templateName);
2439 * AdminActions::parse_defcatselect()
2440 * Parse skinvar defcatselect
2442 * @param string $templateName name of template
2445 public function parse_defcatselect($templateName = '')
2449 $blogid = intRequestVar('blogid');
2450 $blog = $manager->getBlog($blogid);
2452 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2453 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2455 $template['name'] = 'defcat';
2456 $template['selected'] = $blog->getDefaultCategory();
2457 $template['tabindex'] = 110;
2459 Showlist($query, 'select', $template, $templateName);
2465 * AdminActions::parse_defskinselect()
2466 * Parse skinvar defskinselect
2468 * @param string $type type of skin
2469 * @param string $templateName name of template
2472 public function parse_defskinselect($type = 'blog', $templateName = '')
2474 global $CONF, $manager;
2476 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2477 $query = sprintf($query, sql_table('skin_desc'));
2479 $blogid = intRequestVar('blogid');
2483 $template['selected'] = $CONF['BaseSkin'];
2487 $blog = $manager->getBlog($blogid);
2488 $template['selected'] = $blog->getDefaultSkin();
2491 if ( $type != 'blog' )
2493 $nname = 'BaseSkin';
2500 $template['name'] = $nname;
2501 $template['tabindex'] = 50;
2503 Showlist($query, 'select', $template, $templateName);
2509 * AdminActions::parse_deletecomment()
2510 * Parse skinvar deletecomment
2512 * @param string $type type of infomation for comment
2515 public function parse_deletecomment($type = 'id')
2517 $commentid = intRequestVar('commentid');
2518 $comment = COMMENT::getComment($commentid);
2523 echo intRequestVar('commentid');
2526 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2528 echo $comment['member'];
2532 echo $comment['user'];
2536 $body = strip_tags($comment['body']);
2537 echo Entity::hsc(shorten($body, 300, '...'));
2543 * AdminActions::parse_deleteitembody()
2544 * Parse skinvar deleteitembody
2549 public function parse_deleteitembody()
2553 $itemid = intRequestVar('itemid');
2554 $item =& $manager->getItem($itemid, 1, 1);
2556 $body = strip_tags($item['body']);
2558 echo Entity::hsc(shorten($body, 300, '...'));
2564 * AdminActions::parse_deleteitemid()
2565 * Parse skinvar deleteitemid
2570 public function parse_deleteitemid()
2572 echo (integer) intRequestVar('itemid');
2577 * AdminActions::parse_deleteitemtitle()
2578 * Parse skinvar deleteitemtitle
2583 public function parse_deleteitemtitle()
2587 $itemid = intRequestVar('itemid');
2588 $item =& $manager->getItem($itemid, 1, 1);
2590 echo Entity::hsc(strip_tags($item['title']));
2596 * AdminActions::parse_editadminskin()
2597 * Parse skinvar editadminskin
2599 * @param string $type type of skin setting
2602 public function parse_editadminskin($type = 'id')
2604 $skinid = intRequestVar('skinid');
2605 $skin = new Skin($skinid);
2609 echo intRequestVar('skinid');
2612 echo Entity::hsc($skin->getName());
2615 echo Entity::hsc($skin->getDescription());
2618 echo Entity::hsc($skin->getContentType());
2621 echo Entity::hsc($skin->getIncludePrefix());
2624 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2632 * AdminActions::parse_editadminskintype()
2633 * Parse skinvar editadminskintype
2635 * @param string $type name of skin type
2638 public function parse_editadminskintype($type = 'id')
2640 global $CONF, $manager, $member;
2642 $fNames = $this->skin->getAvailableTypes();
2643 $sType = strtolower(trim(requestVar('type')));
2648 echo intRequestVar('skinid');
2651 echo Entity::hsc($this->skin->getName());
2654 echo Entity::hsc($this->skin->getDescription());
2657 echo Entity::hsc($this->skin->getContentType());
2660 echo Entity::hsc($this->skin->getContentFromDB($sType));
2663 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2664 echo Entity::hsc($skinType);
2667 echo Entity::hsc($sType);
2670 echo Entity::hsc($this->skin->getIncludePrefix());
2673 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2674 echo Entity::hsc($incMode);
2683 * AdminActions::parse_editcomment()
2684 * Parse skinvar editcomment
2686 * @param string $type type of comment setting
2689 public function parse_editcomment($type = 'id')
2693 $commentid = intRequestVar('commentid');
2694 $comment = COMMENT::getComment($commentid);
2696 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2701 echo intRequestVar('commentid');
2704 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2706 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2710 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2714 echo date("Y-m-d @ H:i", $comment['timestamp']);
2717 $comment['body'] = str_replace('<br />', '', $comment['body']);
2718 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2719 echo $comment['body'];
2721 echo $comment[$type];
2728 * AdminActions::parse_editdesturl()
2729 * Parse skinvar editdesturl
2731 public function parse_editdesturl()
2733 if ( requestVar('desturl') )
2735 echo Entity::hsc(requestVar('desturl'));
2741 * AdminActions::parse_editmemberlist()
2742 * Parse skinvar editmemberlist
2744 * @param string $templateName name of template
2747 public function parse_editmemberlist($templateName = '')
2750 // show list of members with actions
2751 $query = 'SELECT * FROM '.sql_table('member');
2752 $template['content'] = 'memberlist';
2753 $template['tabindex'] = 10;
2755 $batch = new Batch('member');
2756 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2761 * AdminActions::parse_editmember()
2762 * Parse skinvar editmember
2764 * @param string $type type of information for member
2765 * @return string $tempateName name of template to use
2768 public function parse_editmember($type = 'id', $templateName = '')
2770 global $CONF, $manager, $member;
2772 $memberid = intRequestVar('memberid');
2773 $mem = MEMBER::createFromID($memberid);
2778 echo intRequestVar('memberid');
2781 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2783 echo Entity::hsc($mem->getDisplayName());
2787 $dispName = Entity::hsc($mem->getDisplayName());
2788 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2790 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2799 echo Entity::hsc($mem->getRealName());
2802 echo Entity::hsc($mem->getEmail());
2805 echo Entity::hsc($mem->getURL());
2808 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2811 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2814 echo Entity::hsc($mem->getNotes());
2817 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2826 * AdminActions::parse_editpluginfo()
2827 * Parse skinvar editpluginfo
2829 * @param string $type type of plugin info
2832 public function parse_editpluginfo($type)
2834 $pid = intRequestVar('plugid');
2841 echo Entity::hsc(getPluginNameFromPid($pid));
2848 * AdminActions::parse_editplugoptionslist()
2849 * Parse skinvar editplugoptionslist
2851 * @param string $templateName name of template
2854 public function parse_editplugoptionslist($templateName = '')
2858 $pid = intRequestVar('plugid');
2859 $aOptions = array();
2862 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2863 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2864 $resource = sql_query($query);
2866 while ( $o = sql_fetch_object($resource) )
2868 array_push($aOIDs, $o->oid);
2869 $aOptions[$o->oid] = array(
2871 'value' => $o->odef,
2872 'name' => $o->oname,
2873 'description' => $o->odesc,
2874 'type' => $o->otype,
2875 'typeinfo' => $o->oextra,
2880 // fill out actual values
2881 if ( count($aOIDs) > 0 )
2883 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2884 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2886 $result = sql_query($query);
2888 while ( $o = sql_fetch_object($result) )
2890 $aOptions[$o->oid]['value'] = $o->ovalue;
2896 'context' => 'global',
2898 'options' => &$aOptions
2900 $manager->notify('PrePluginOptionsEdit', $data);
2902 $template['content'] = 'plugoptionlist';
2904 $amount = Showlist($aOptions, 'table', $template, $templateName);
2908 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2914 * AdminActions::parse_editskin()
2915 * Parse skinvar editskin
2917 * @param string $type type of skin
2920 public function parse_editskin($type = 'id')
2922 $skinid = intRequestVar('skinid');
2923 $skin = new SKIN($skinid);
2927 echo intRequestVar('skinid');
2930 echo Entity::hsc($skin->getName());
2933 echo Entity::hsc($skin->getDescription());
2936 echo Entity::hsc($skin->getContentType());
2939 echo Entity::hsc($skin->getIncludePrefix());
2942 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2950 * AdminActions::parse_editskintype()
2951 * Parse skinvar editskintype
2953 * @param string $type name of type for skin type
2956 public function parse_editskintype($type = 'id')
2958 global $CONF, $manager, $member;
2959 $skinid = intRequestVar('skinid');
2960 $skin = new SKIN($skinid);
2961 $fNames = $skin->getAvailableTypes();
2962 $sType = strtolower(trim(requestVar('type')));
2967 echo intRequestVar('skinid');
2970 echo Entity::hsc($skin->getName());
2973 echo Entity::hsc($skin->getDescription());
2976 echo Entity::hsc($skin->getContentType());
2979 echo Entity::hsc($skin->getContentFromDB($sType));
2982 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2983 echo Entity::hsc($skinType);
2986 echo Entity::hsc($sType);
2989 echo Entity::hsc($skin->getIncludePrefix());
2992 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2993 echo Entity::hsc($incMode);
3002 * AdminActions::parse_adminurl()
3003 * Parse skinvar adminurl
3004 * (shortcut for admin url)
3009 public function parse_adminurl()
3011 $this->parse_sitevar('adminurl');
3016 * AdminActions::parse_edittemplateinfo()
3017 * Parse skinvar edittemplateinfo
3019 * @param string $type name of type for skin
3020 * @param string $description description for skin
3021 * @param string $name name of skin
3022 * @param string $help
3023 * @param string $tabindex index value for tabindex attribute of input element
3024 * @param string $big
3025 * @param string $tplt name of template
3028 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3032 $t_id = intRequestVar('templateid');
3033 $t_name = Template::getNameFromId($t_id);
3034 $t_desc = Template::getDesc($t_id);
3035 $template = &Template::read($t_name);
3043 echo Entity::hsc($t_name);
3046 echo Entity::hsc($t_desc);
3048 case 'extratemplate':
3050 $pluginfields = array();
3051 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
3056 $tmplt = Template::read($desc);
3058 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3062 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3066 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3069 foreach ( $pluginfields as $pfkey => $pfvalue )
3071 $data = array('explugtplname' => Entity::hsc($pfkey));
3073 echo Template::fill($base, $data);
3075 foreach ( $pfvalue as $pffield => $pfdesc )
3077 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3082 $desc = defined($desc) ? constant($desc) : $desc;
3083 $name = defined($name) ? constant($name) : $name;
3084 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3092 * AdminActions::parse_editadmintemplateinfo()
3093 * Parse skinvar editadmintemplateinfo
3095 * @param string $type type of skin template
3096 * @param string $description description of template
3097 * @param string $name name of stemplate
3098 * @param string $tabindex index number for tabindex attribute of input element
3099 * @param string $big
3100 * @param string $tplt
3102 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3106 $t_id = intRequestVar('templateid');
3107 $t_name = Template::getNameFromId($t_id);
3108 $t_desc = Template::getDesc($t_id);
3109 $template = &Template::read($t_name);
3117 echo Entity::hsc($t_name);
3120 echo Entity::hsc($t_desc);
3122 case 'extratemplate':
3124 $pluginfields = array();
3125 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3130 $tmplt = Template::read($desc);
3132 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3136 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3140 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3143 foreach ( $pluginfields as $pfkey => $pfvalue )
3145 $data = array('explugtplname' => Entity::hsc($pfkey));
3147 echo Template::fill($base, $data);
3149 foreach ( $pfvalue as $pffield => $pfdesc )
3151 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3156 $desc = defined($desc) ? constant($desc) : $desc;
3157 $name = defined($name) ? constant($name) : $name;
3158 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3165 * AdminActions::parse_eventformextra()
3166 * Parse skinvar eventformextra
3168 * @param string $type name of type for event form extra
3171 public function parse_eventformextra($type = 'activation')
3180 $key = requestVar('ackey');
3183 Admin::error(_ERROR_ACTIVATE);
3185 $info = MEMBER::getActivationInfo($key);
3188 Admin::error(_ERROR_ACTIVATE);
3190 $mem = MEMBER::createFromId($info->vmember);
3193 Admin::error(_ERROR_ACTIVATE);
3196 'type' => 'activation',
3200 case 'membermailform-notloggedin':
3201 $data = array('type' => 'membermailform-notloggedin',);
3204 $manager->notify('FormExtra', $data);
3209 * AdminActions::parse_extrahead()
3210 * Parse skinvar extrahead
3212 public function parse_extrahead()
3216 $extrahead = Admin::getAdminextrahead();
3219 'extrahead' => &$extrahead,
3220 'action' => Admin::getAdminAction()
3223 $manager->notify('AdminPrePageHead', $data);
3229 * AdminActions::parse_member()
3230 * Parse skinvar member
3231 * (includes a member info thingie)
3233 * @param string $what which memberdata is needed
3236 public function parse_member($what)
3238 global $memberinfo, $member, $CONF;
3240 // 1. only allow the member-details-page specific variables on member pages
3241 if ( $this->skintype == 'member' )
3246 echo Entity::hsc($memberinfo->getDisplayName());
3249 echo Entity::hsc($memberinfo->getRealName());
3252 echo Entity::hsc($memberinfo->getNotes());
3255 echo Entity::hsc($memberinfo->getURL());
3258 echo Entity::hsc($memberinfo->getEmail());
3261 echo Entity::hsc($memberinfo->getID());
3266 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3267 if ( $member->isLoggedIn() )
3272 echo $member->getDisplayName();
3274 case 'yourrealname':
3275 echo $member->getRealName();
3278 echo $member->getNotes();
3281 echo $member->getURL();
3284 echo $member->getEmail();
3287 echo $member->getID();
3289 case 'yourprofileurl':
3290 if ( $CONF['URLMode'] == 'pathinfo' )
3292 echo Link::create_member_link($member->getID());
3296 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3305 * AdminActions::parse_version()
3306 * Parse skinvar version
3307 * (include nucleus versionnumber)
3312 public function parse_version()
3315 echo 'Nucleus CMS ' . $nucleus['version'];
3320 * AdminActions::parse_sitevar()
3321 * Parse skinvar sitevar
3322 * (include a sitevar)
3324 * @param string $which
3327 public function parse_sitevar($which)
3333 echo $CONF['IndexURL'];
3336 echo $CONF['SiteName'];
3339 echo $CONF['AdminEmail'];
3342 echo $CONF['AdminURL'];
3348 * AdminActions::parse_charset()
3349 * Parse skinvar charset
3354 public function parse_charset()
3356 echo i18n::get_current_charset();
3361 * AdminActions::parse_getblogsetting()
3362 * Parse skinvar getblogsetting
3364 public function parse_getblogsetting($which)
3372 elseif ( $bid = intRequestVar('blogid') )
3375 $b = $manager->getBlog($bid);
3385 return Entity::hsc($b->getID());
3388 return Entity::hsc($b->getURL());
3391 return Entity::hsc($b->getName());
3394 return Entity::hsc($b->getDescription());
3397 return Entity::hsc($b->getShortName());
3399 case 'notifyaddress':
3400 return Entity::hsc($b->getNotifyAddress());
3403 return Entity::hsc($b->getMaxComments());
3406 return Entity::hsc($b->getUpdateFile());
3409 return Entity::hsc($b->getTimeOffset());
3416 * AdminActions::parse_geteditpluginfo()
3417 * Parse skinvar geteditpluginfo
3419 * @param string $type name of setting for edit plugin info
3422 public function parse_geteditpluginfo($type)
3424 $pid = intRequestVar('plugid');
3431 return Entity::hsc(getPluginNameFromPid($pid));
3438 * AdminActions::parse_getmember()
3439 * Parse skinvar getmember
3440 * (includes a member info thingie)
3442 * @param string $what name of setting for member
3445 public function parse_getmember($what)
3447 global $memberinfo, $member;
3448 // 1. only allow the member-details-page specific variables on member pages
3449 if ( $this->skintype == 'member' )
3454 return Entity::hsc($memberinfo->getDisplayName());
3457 return Entity::hsc($memberinfo->getRealName());
3460 return Entity::hsc($memberinfo->getNotes());
3463 return Entity::hsc($memberinfo->getURL());
3466 return Entity::hsc($memberinfo->getEmail());
3469 return Entity::hsc($memberinfo->getID());
3473 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3474 if ( $member->isLoggedIn() )
3479 return $member->getDisplayName();
3481 case 'yourrealname':
3482 return $member->getRealName();
3485 return $member->getNotes();
3488 return $member->getURL();
3491 return $member->getEmail();
3494 return $member->getID();
3502 * AdminActions::parse_headmessage()
3503 * Parse skinvar headmessage
3508 public function parse_headmessage()
3510 if ( !empty(Admin::$headMess) )
3512 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3518 * AdminActions::parse_helplink()
3519 * Parse skinvar helplink
3521 * @param string $topic name of topic for help
3524 public function parse_helplink($topic = '')
3526 if ( !empty($topic) )
3534 * AdminActions::parse_helpplugname()
3535 * Parse skinvar helpplugname
3540 public function parse_helpplugname()
3542 $plugid = intGetVar('plugid');
3543 Entity::hsc(getPluginNameFromPid($plugid));
3548 * AdminActions::parse_ilistaddnew()
3549 * Parse skinvar ilistaddnew
3554 public function parse_ilistaddnew()
3556 $blogid = intRequestVar('blogid');
3557 if ( intPostVar('start') == 0 )
3559 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3565 * AdminActions::parse_importskininfo()
3566 * Parse skinvar importskininfo
3568 * @param string $type name of information for imported skin
3571 public function parse_importskininfo($type)
3576 echo Entity::hsc(requestVar('skininfo'));
3579 $dataArr = requestArray('skinnames');
3580 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3583 $dataArr = requestArray('tpltnames');
3584 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3587 $dataArr = requestArray('skinclashes');
3588 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3591 $dataArr = requestArray('tpltclashes');
3592 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3595 echo Entity::hsc(requestVar('skinfile'));
3598 echo Entity::hsc(requestVar('mode'));
3605 * AdminActions::parse_inputyesno()
3606 * Parse skinvar inputyesno
3608 * some init stuff for all forms
3613 function parse_init()
3618 if ( requestVar('action') == 'itemedit' )
3620 $itemid = intRequestVar('itemid');
3621 $item =& $manager->getItem($itemid, 1, 1);
3623 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3624 if ( $item && $blog->convertBreaks() )
3626 $item['body'] = removeBreaks($item['body']);
3627 $item['more'] = removeBreaks($item['more']);
3630 $authorid = $contents['authorid'];
3632 elseif ( requestVar('action') == 'createitem' )
3634 $blogid = intRequestVar('blogid');
3635 $blog =& $manager->getBlog($blogid);
3638 $blog->insertJavaScriptInfo($authorid);
3643 * AdminActions::parse_inputyesno()
3644 * Parse skinvar inputyesno
3646 * @param string $name
3647 * @param string $checkedval
3648 * @param string $tabindex
3649 * @param string $value1
3650 * @param string $value2
3651 * @param string $yesval
3652 * @param string $noval
3653 * @param string $isAdmin
3654 * @param string $templateName
3657 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3659 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3664 * AdminActions::parse_insertpluginfo()
3665 * Parse templatevar insertpluginfo
3667 public function parse_insertpluginfo($type)
3669 $option = Admin::$aOptions;
3673 return $option['pid'];
3676 return Entity::hsc($option['pfile']);
3683 * AdminActions::parse_insertpluginoptions()
3684 * Parse skinvar insertpluginoptions
3686 * @param string $templateName name of template
3689 public function parse_insertpluginoptions($templateName = '')
3691 $options = Admin::getAdminaOption();
3692 $template = array();
3693 $templats = array();
3695 if ( $templateName )
3697 $templates = Template::read($templateName);
3699 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3701 $template['title'] = "<tr>"
3702 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3707 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3709 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3711 $template['body'] = "<tr>"
3712 . "<%listplugplugoptionrow%>"
3717 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3722 include_libs('ACTIONS.php');
3723 $handler = new Actions($this->skintype);
3724 $parser = new PARSER($handler);
3726 foreach ( $options as $option )
3730 if ( $prevPid != $option['pid'] )
3732 $prevPid = $option['pid'];
3733 $parser->parse($template['title']);
3736 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3738 if ( @$meta['access'] != 'hidden' )
3740 $parsed = $parser->parse($template['body']);
3747 * AdminActions::parse_insplugoptcontent()
3748 * Parse skinvar insplugoptcontent
3753 public function parse_insplugoptcontent()
3755 $option = Admin::$aOption;
3757 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3758 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3761 listplug_plugOptionRow($option);
3768 * AdminActions::parse_iprangeinput()
3769 * Parse skinvar iprangeinput
3774 public function parse_iprangeinput()
3776 if ( requestVar('ip') )
3778 $iprangeVal = Entity::hsc(requestVar('ip'));
3779 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3780 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3781 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3782 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3783 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3787 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3788 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3794 * AdminActions::parse_itemnavlist()
3795 * Parse skinvar itemnavlist
3800 public function parse_itemnavlist()
3802 global $CONF, $manager, $member;
3803 if ( $this->skintype == 'itemlist' )
3805 $blogid = intRequestVar('blogid');
3806 $blog =& $manager->getBlog($blogid);
3808 if ( postVar('start') )
3810 $start = intPostVar('start');
3817 // amount of items to show
3818 if ( postVar('amount') )
3820 $amount = intPostVar('amount');
3824 $amount = intval($CONF['DefaultListSize']);
3830 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3831 . " FROM %s, %s, %s, %s"
3832 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3834 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3836 if ( $this->skintype == 'itemlist' )
3838 $query .= ' AND iblog = ' . $blogid;
3839 $template['now'] = $blog->getCorrectTime(time());
3841 // non-blog-admins can only edit/delete their own items
3842 if ( !$member->blogAdminRights($blogid) )
3844 $query .= ' AND iauthor = ' . $member->getID();
3847 elseif ( $this->skintype == 'browseownitems' )
3849 $query .= ' AND iauthor = ' . $member->getID();
3851 $template['now'] = time();
3854 // search through items
3855 $search = postVar('search');
3857 if ( !empty($search) )
3859 $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
3860 . ' OR (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
3861 . ' OR (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
3863 $query .= ' ORDER BY itime DESC'
3864 . " LIMIT {$start},{$amount}";
3866 $template['content'] = 'itemlist';
3868 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3869 $navList->showBatchList('item', $query, 'table', $template);
3874 * AdminActions::parse_itemoptions()
3875 * Parse skinvar itemoptions
3876 * Adds the itemOptions of a plugin to a page
3879 function parse_itemoptions()
3881 $this->parse_pluginoptions('item');
3886 * AdminActions::parse_itemoptions()
3888 * date change on edit item
3890 * Parse skinvar itemoptions
3891 * Adds the itemOptions of a plugin to a page
3894 function parse_itemtime($what)
3899 $itemid = intRequestVar('itemid');
3900 $item =& $manager->getItem($itemid, 1, 1);
3902 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3904 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3906 $item['body'] = removeBreaks($item['body']);
3907 $item['more'] = removeBreaks($item['more']);
3910 $contents = array();
3911 if ( requestVar('action') == 'itemedit' )
3915 elseif ( requestVar('action') == 'createitem' )
3918 'contents' => &$contents,
3919 'blog' => &$this->blog
3921 $manager->notify('PreAddItemForm', $data);
3923 $itemtime = getdate($contents['timestamp']);
3924 echo $itemtime[$what];
3929 * AdminActions::parse_jstoolbaroptions()
3930 * Parse skinvar jstoolbaroptions
3935 public function parse_jstoolbaroptions()
3939 _SETTINGS_JSTOOLBAR_NONE,
3940 _SETTINGS_JSTOOLBAR_SIMPLE,
3941 _SETTINGS_JSTOOLBAR_FULL
3945 foreach ( $options as $option )
3947 $text = "<option value=\"%d\"%s>%s</option>\n";
3948 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3949 echo sprintf($text, $i, $extra, $option);
3955 * AdminActions::parse_localeselectoptions()
3956 * Parse skinvar localeselectoptions
3961 public function parse_localeselectoptions()
3963 $locales = i18n::get_available_locale_list();
3965 $memid = intRequestVar('memberid');
3968 $mem = MEMBER::createFromID($memid);
3969 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3971 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3975 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3980 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3982 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3985 foreach ( $locales as $locale )
3989 if ( $locale == $mem->getLocale() )
3991 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3995 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4000 if ( $locale == i18n::get_current_locale() )
4002 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4006 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4014 * AdminActions::parse_listplugplugoptionrow()
4015 * Parse templatevar listplugplugoptionrow
4017 * @param string $templateName name of template
4020 public function parse_listplugplugoptionrow($templateName = '')
4022 echo listplug_plugOptionRow(Admin::$aOptions, $templateName);
4027 * AdminActions::parse_mediadirwarning()
4028 * Parse skinvar mediadirwarning
4033 public function parse_mediadirwarning()
4036 if ( !is_dir($DIR_MEDIA) )
4038 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4040 if ( !is_readable($DIR_MEDIA) )
4042 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4044 if ( !is_writeable($DIR_MEDIA) )
4046 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4052 * AdminActions::parse_movedistselect()
4053 * Parse skinvar movedistselect
4055 public function parse_movedistselect()
4057 $actionType = requestVar('action');
4058 switch ( $actionType )
4061 Admin::selectBlogCategory('destcatid');
4063 case 'batchcategory':
4064 Admin::selectBlog('destblogid');
4067 if ( $this->skintype == 'itemmove' )
4069 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
4070 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
4071 $catid = quickQuery(sprintf($query, intRequestVar('itemid')));
4072 Admin::selectBlogCategory('catid', $catid, 10, 1);
4080 * AdminActions::parse_moveitemid()
4081 * Parse skinvar moveitemid
4086 public function parse_moveitemid()
4088 echo intRequestVar('itemid');
4093 * AdminActions::parse_newestcompare()
4094 * Parse skinvar newestcompare
4099 public function parse_newestcompare()
4103 $newestVersion = getLatestVersion();
4104 $newestCompare = str_replace('/', '.', $newestVersion);
4105 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4107 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4109 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4110 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4116 * AdminActions::parse_newmemberselect()
4117 * Parse skinvar newmemberselect
4119 * @param string $templateName name of template to use
4122 public function parse_newmemberselect($templateName = '')
4124 $blogid = intRequestVar('blogid');
4126 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4127 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4128 $res = sql_query($query);
4131 while ( $tmember = sql_fetch_object($res) )
4133 $tmem[] = intval($tmember->tmember);
4136 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4137 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4139 $template['name'] = 'memberid';
4140 $template['tabindex'] = 10000;
4141 Showlist($query, 'select', $template, $templateName);
4146 * AdminActions::parse_newpluginlist()
4147 * Parse skinvar newpluginlist
4152 public function parse_newpluginlist()
4154 $candidates = $this->newPlugCandidates;
4155 foreach ( $candidates as $name )
4157 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4163 * AdminActions::parse_outputspecialdirs()
4164 * Parse skinvar outputspecialdirs
4166 * @param string $type type of setting for directory
4169 public function parse_outputspecialdirs($type)
4171 global $DIR_MEDIA, $DIR_NUCLEUS;
4176 echo Entity::hsc($DIR_NUCLEUS);
4179 echo Entity::hsc($DIR_MEDIA);
4186 * AdminActions::parse_passrequestvars()
4187 * Parse skinvar passrequestvars
4192 public function parse_passrequestvars()
4194 $passvar = Admin::getAdminpassvar();
4195 $oldaction = postVar('oldaction');
4197 if ( ($oldaction != 'logout')
4198 && ($oldaction != 'login')
4200 && !postVar('customaction') )
4208 * AdminActions::parse_pluginextras()
4209 * Parse skinvar pluginextras
4211 * @param string $type type of plugin context
4214 public function parse_pluginextras($type = 'global')
4220 $id = intRequestVar('memberid');
4221 $mem = MEMBER::createFromID($id);
4222 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4225 $id = intRequestVar('blogid');
4226 $blg = $manager->getBlog($id);
4227 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4231 'GeneralSettingsFormExtras',
4241 * AdminActions::parse_pluginhelp()
4242 * Parse skinvar pluginhelp
4247 public function parse_pluginhelp()
4249 global $manager, $DIR_PLUGINS;
4251 $plugid = intGetVar('plugid');
4252 $plugName = getPluginNameFromPid($plugid);
4253 $plug =& $manager->getPlugin($plugName);
4255 if ( $plug->supportsFeature('HelpPage') > 0 )
4257 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4258 if ( @file_exists($helpfile . 'php') )
4260 @include($helpfile . 'php');
4263 elseif ( @file_exists($helpfile . 'html') )
4265 @include($helpfile . 'html');
4269 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4270 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4275 * AdminActions::parse_pluginlistlist()
4276 * Parse skinvar pluginlistlist
4278 * @param string $templateName name of template to use
4281 public function parse_pluginlistlist($templateName = '')
4283 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4284 $query = sprintf($query, sql_table('plugin'));
4286 $template['content'] = 'pluginlist';
4287 $template['tabindex'] = 10;
4289 Showlist($query, 'table', $template, $templateName);
4295 * AdminActions::parse_pluginoptions()
4296 * Parse skinvar pluginoptions
4298 * @param string $type type of plugin option
4301 public function parse_pluginoptions($type = 'global')
4308 $id = intRequestVar('memberid');
4311 $id = intRequestVar('blogid');
4314 $id = intRequestVar('catid');
4320 Admin::insertPluginOptions($type, $id);
4325 * AdminActions::parse_qmenuaddselect()
4326 * Parse skinvar qmanuaddselect
4328 * @param string $templateName name of template to use
4331 public function parse_qmenuaddselect($templateName = '')
4334 $showAll = requestVar('showall');
4335 if ( $member->isAdmin() && ($showAll == 'yes') )
4337 // Super-Admins have access to all blogs! (no add item support though)
4338 $query = 'SELECT bnumber as value, bname as text'
4339 . ' FROM ' . sql_table('blog')
4340 . ' ORDER BY bname';
4344 $query = 'SELECT bnumber as value, bname as text'
4345 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4346 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4347 . ' ORDER BY bname';
4350 $template['name'] = 'blogid';
4351 $template['tabindex'] = 15000;
4352 $template['extra'] = _QMENU_ADD_SELECT;
4353 $template['selected'] = -1;
4354 $template['shorten'] = 10;
4355 $template['shortenel'] = '';
4356 $template['javascript'] = 'onchange="return form.submit()"';
4358 Showlist($query, 'select', $template, $templateName);
4364 * AdminActions::parse_quickmenu()
4365 * Parse skinvar quickmenu
4367 * @param string $templateName name of template to use
4370 public function parse_quickmenu($templateName = '')
4373 $templates = array();
4374 $template = array();
4375 if ( !empty($templateName) )
4377 $templates = Template::read($templateName);
4379 $pluginExtras = array();
4383 'options' => &$pluginExtras
4386 if ( count($pluginExtras) > 0 )
4388 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4390 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4394 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4396 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4398 $template['head'] = "<ul>\n";
4402 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4404 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4406 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4410 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4412 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4414 $template['foot'] = "</ul>\n";
4418 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4421 $handler = new Actions($this->skintype);
4422 $parser = new PARSER($handler);
4424 $parser->parse($template['title']);
4425 echo $template['head'];
4426 foreach ( $pluginExtras as $aInfo )
4429 'plugadminurl' => Entity::hsc($aInfo['url']),
4430 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4431 'plugadmintitle' => Entity::hsc($aInfo['title']),
4433 echo Template::fill($template['body'], $data);
4435 echo $template['foot'];
4441 * AdminActions::parse_requestblogid()
4442 * Parse skinvar requestblogid
4447 public function parse_requestblogid()
4449 echo intRequestVar('blogid');
4454 * AdminActions::parse_requestiprange()
4455 * Parse skinvar requestiprange
4460 public function parse_requestiprange()
4462 if ( requestVar('iprange') )
4464 echo Entity::hsc(requestVar('iprange'));
4466 elseif ( requestVar('ip') )
4468 echo Entity::hsc(requestVar('ip'));
4474 * AdminActions::parse_selectlocaladminskinfiles()
4475 * Parse skinvar selectlocaladminskinfiles
4480 public function parse_selectlocaladminskinfiles()
4482 global $DIR_SKINS, $manager;
4484 $adminskindir = $DIR_SKINS . 'admin/';
4485 $candidates = SkinImport::searchForCandidates($adminskindir);
4487 foreach ( $candidates as $skinname => $skinfile )
4489 $html = Entity::hsc($skinfile);
4490 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4497 * AdminActions::parse_selectlocalskinfiles()
4498 * Parse skinvar selectlocalskinfiles
4503 public function parse_selectlocalskinfiles()
4507 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4509 foreach ( $candidates as $skinname => $skinfile )
4511 $html = Entity::hsc($skinfile);
4512 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4519 * AdminActions::parse_skineditallowedlist()
4520 * Parse skinvar skineditallowedlist
4522 * @param string $type type of skin
4523 * @param string $templateName name of template
4526 public function parse_skineditallowedlist($type, $templateName = '')
4531 $query = "SELECT bshortname, bname FROM %s;";
4533 'content' => 'shortblognames'
4535 $query = sprintf($query, sql_table('blog'));
4536 Showlist($query, 'table', $show, $templateName);
4539 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4541 'content' => 'shortnames'
4543 $query = sprintf($query, sql_table('template_desc'));
4544 Showlist($query, 'table', $show, $templateName);
4551 * AdminActions::parse_skinielist()
4552 * Parse skinvar skinielist
4554 * @param string $type type of skin
4555 * @param string $templateName name of template to use
4558 public function parse_skinielist($type, $templateName = '')
4560 $templates = array();
4561 if ( $templateName )
4563 $templates = Template::read($templateName);
4565 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4567 $template = $templates['SKINIE_EXPORT_LIST'];
4572 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4573 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4575 . "<td><%expdesc%></td>\n"
4582 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
4583 while ( $skinObj = sql_fetch_object($res) )
4586 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
4587 'expid' => 'skinexp' . $skinObj->sdnumber,
4588 'expname' => Entity::hsc($skinObj->sdname),
4589 'expdesc' => Entity::hsc($skinObj->sddesc),
4591 echo Template::fill($template, $data);
4595 $res = sql_query('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4596 while ($templateObj = sql_fetch_object($res)) {
4598 'typeid' => 'template[' . $templateObj->tdnumber . ']',
4599 'expid' => 'templateexp' . $templateObj->tdnumber,
4600 'expname' => Entity::hsc($templateObj->tdname),
4601 'expdesc' => Entity::hsc($templateObj->tddesc),
4603 echo Template::fill($template, $data);
4611 * AdminActions::parse_skinoverview()
4612 * Parse skinvar skinoverview
4614 * @param string $templateName name of template to use
4617 public function parse_skinoverview($templateName = '')
4620 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4621 $query = sprintf($query, sql_table('skin_desc'));
4623 $template['content'] = 'skinlist';
4624 $template['tabindex'] = 10;
4626 Showlist($query, 'table', $template, $templateName);
4631 * AdminActions::parse_skintypehelp()
4632 * Check editing skintypehelp
4637 public function parse_skintypehelp()
4639 $nowSkinType = strtolower(trim(requestVar('type')));
4641 /* TODO: use Skin class */
4642 $regularType = array(
4653 if ( in_array($nowSkinType, $regularType) )
4655 help('skinpart' . $nowSkinType);
4659 help('skinpartspecial');
4665 * AdminActions::parse_specialskinlist()
4666 * Parse skinvar specialskinlist
4668 * @param string $templateName name of template to use
4671 public function parse_specialskinlist($templateName = '')
4673 $templates = array();
4674 if ( $templateName )
4676 $templates = Template::read($templateName);
4679 /* TODO: use Skin class */
4690 $skinid = intRequestVar('skinid');
4691 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4692 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4694 $res = sql_query($query);
4695 if ( $res && sql_num_rows($res) > 0 )
4698 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4700 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4704 $template['head'] = "<ul>\n";
4706 echo Template::fill($template['head'], $data);
4707 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4709 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4710 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4711 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4715 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4719 while ( $row = sql_fetch_assoc($res) )
4722 'tabindex' => $tabstart++,
4723 'skinid' => $skinid,
4724 'skintype' => Entity::hsc(strtolower($row['stype']))
4726 echo Template::fill($template['body'], $data);
4729 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4731 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4735 $template['foot'] = "</ul>\n";
4737 echo Template::fill($template['foot'], $data);
4743 * AdminActions::parse_sprinttext()
4746 * @param string $which
4747 * @param string $val
4750 public function parse_sprinttext($which, $val)
4752 if ( !defined($which) )
4758 $base = constant($which);
4761 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4763 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4765 $met = 'parse_' . $matchies[0];
4769 $arg = trim($args[0], '()');
4770 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4773 if ( method_exists($this, $met) )
4775 $value = call_user_func(array(&$this, $met), $arg);
4779 if ( !isset($value) || empty($value) )
4783 echo sprintf($base, $value);
4788 * AdminActions::parse_systemsettings()
4789 * Parse skinvar systemsettings
4791 * @param string $type type of settings for system
4792 * @param string $templateName name of template to use
4795 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4797 global $member, $CONF, $nucleus;
4799 $member->isAdmin() or Admin::disallow();
4801 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4802 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4809 case 'sqlserverinfo':
4810 echo sql_get_server_info();
4812 case 'sqlclientinfo':
4813 echo sql_get_client_info();
4815 case 'magicquotesgpc':
4816 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4818 case 'magicquotesruntime':
4819 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4821 case 'registerglobals':
4822 echo ini_get('register_globals') ? 'On' : 'Off';
4825 $templates = array();
4826 if ( $templateName )
4828 $templates = Template::read($templateName);
4830 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4832 $template = "<tr>\n"
4833 . "<td><%key%></td>\n"
4834 . "<td><%value%></td>\n"
4839 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4842 $gdinfo = gd_info();
4844 foreach ( $gdinfo as $key => $value )
4846 if ( is_bool($value) )
4848 $value = $value ? $enable : $disable;
4852 $value = Entity::hsc($value);
4858 echo Template::fill($template, $data);
4863 phpinfo(INFO_MODULES);
4864 $im = ob_get_contents();
4866 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4868 case 'nucleusversion':
4869 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4871 case 'nucleuspatchlevel':
4872 echo getNucleusPatchLevel();
4878 echo $CONF['ItemURL'];
4880 case 'alertonheaderssent':
4881 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4883 case 'nucleuscodename':
4884 if ( $nucleus['codename'] != '' )
4886 echo ' "' . $nucleus['codename'] . '"';
4889 case 'versioncheckurl':
4890 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4897 * AdminActions::parse_templateoverview()
4898 * Parse skinvar templateoverview
4900 * @param string $templateName name of template to use
4903 public function parse_templateoverview($templateName = '')
4905 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4906 $query = sprintf($query, sql_table('template_desc'));
4908 $template['content'] = 'templatelist';
4909 $template['tabindex'] = 10;
4911 Showlist($query, 'table', $template, $templateName);
4917 * AdminActions::parse_ticket()
4923 public function parse_ticket()
4926 $manager->addTicketHidden();
4931 * AdminActions::parse_versioncheckurl()
4932 * Parse skinvar versioncheckurl
4937 public function parse_versioncheckurl()
4939 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4944 * AdminActions::parse_yrbloglist()
4945 * Parse skinvar yrbloglist
4947 * @param string $templateName name of template to use
4950 public function parse_yrbloglist($templateName = '')
4953 $showAll = requestVar('showall');
4955 if ( $member->isAdmin() && ($showAll == 'yes') )
4957 // Super-Admins have access to all blogs! (no add item support though)
4958 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4960 . " ORDER BY bnumber;";
4961 $query = sprintf($query, sql_table('blog'));
4965 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4967 . " WHERE tblog=bnumber and tmember=%d"
4968 . " ORDER BY bnumber;";
4969 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4972 $template['content'] = 'bloglist';
4973 $template['superadmin'] = $member->isAdmin();
4975 $amount = Showlist($query, 'table', $template, $templateName);
4977 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4979 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4981 $total = quickQuery($query);
4982 if ( $total > $amount )
4984 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4990 echo _OVERVIEW_NOBLOGS;
4992 elseif( $amount != 0 )
4994 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4996 $query = "SELECT ititle, inumber, bshortname"
4998 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
4999 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
5001 $template['content'] = 'draftlist';
5003 $amountdrafts = Showlist($query, 'table', $template, $templateName);
5004 if ( $amountdrafts == 0 )
5006 echo _OVERVIEW_NODRAFTS;
5013 * AdminActions::checkCondition()
5014 * Checks conditions for if statements
5016 * @param string $field type of <%if%>
5017 * @param string $name property of field
5018 * @param string $value value of property
5019 * @return boolean condition
5021 protected function checkCondition($field, $name='', $value = '')
5023 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
5034 $blog =& $manager->getBlog($blogid);
5038 $blogid = getBlogIDFromCatID($catid);
5040 $blog =& $manager->getBlog($blogid);
5042 elseif ( intRequestVar('catid') )
5044 $catid = intRequestVar('catid');
5045 $blogid = getBlogIDFromCatID($catid);
5047 $blog =& $manager->getBlog($blogid);
5054 $condition = ($blog && $this->ifCategory($name, $value));
5057 $condition = ($blog && ($blog->getSetting($name) == $value));
5060 $condition = $member->isLoggedIn();
5063 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5066 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5069 $condition = $member->isLoggedIn() && $member->isAdmin();
5071 case 'allowloginedit':
5072 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5075 $condition = ($itemidnext != '');
5078 $condition = ($itemidprev != '');
5080 case 'archiveprevexists':
5081 $condition = ($archiveprevexists == true);
5083 case 'archivenextexists':
5084 $condition = ($archivenextexists == true);
5087 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5090 $condition = $this->ifHasPlugin($name, $value);
5093 $condition = (Admin::getAdminAction() == $name);
5095 case 'adminoldaction':
5096 $condition = (Admin::getAdminAction() == $name);
5098 case 'addresschange':
5099 $condition = ($this->ifAddresscange());
5101 case 'bechangepass':
5102 $condition = ($this->beChangePassword());
5104 case 'skincandidates':
5105 $condition = ($this->ifSkincandidates());
5108 $condition = requestVar('nameclashes');
5110 case 'existsnewplugin':
5111 $condition = ($this->existsNewPlugin());
5114 $condition = (boolean) ($member->getAutosave() == $value);
5117 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5124 * Actions::_ifHasPlugin()
5125 * hasplugin,PlugName
5126 * -> checks if plugin exists
5127 * hasplugin,PlugName,OptionName
5128 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5129 * hasplugin,PlugName,OptionName=value
5130 * -> checks if the option OptionName from plugin PlugName is set to value
5132 * @param string $name name of plugin
5133 * @param string $value
5136 private function ifHasPlugin($name, $value)
5140 // (pluginInstalled method won't write a message in the actionlog on failure)
5141 if ( $manager->pluginInstalled("NP_{$name}") )
5143 $plugin =& $manager->getPlugin("NP_{$name}");
5144 if ( $plugin != NULL )
5152 list($name2, $value2) = preg_split('#=#', $value, 2);
5153 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5157 else if ( $plugin->getOption($name2) == $value2 )
5168 * Actions::beChangePassword()
5173 private function beChangePassword()
5175 return intRequestVar('bNeedsPasswordChange');
5179 * Actions::ifSkincandidates()
5180 * Checks if a plugin exists and call its doIf function
5186 private function ifSkincandidates()
5189 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5190 return (count($candidates) > 0);
5194 * Actions::ifPlugin()
5195 * Checks if a plugin exists and call its doIf function
5197 * @param string $name name of plugin
5198 * @param string $key
5199 * @param string $value
5202 private function ifPlugin($name, $key = '', $value = '')
5206 $plugin =& $manager->getPlugin("NP_{$name}");
5212 $params = func_get_args();
5213 array_shift($params);
5215 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5219 * AdminActions::ifCategory()
5220 * Different checks for a category
5222 * @param string $key key for information of category
5223 * @param string $value value for information of category
5226 private function ifCategory($key = '', $value='')
5228 global $blog, $catid;
5230 // when no parameter is defined, just check if a category is selected
5231 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5233 return $blog->isValidCategory($catid);
5236 // check category name
5237 if ( $key == 'catname' )
5239 $value = $blog->getCategoryIdFromName($value);
5240 if ($value == $catid)
5242 return $blog->isValidCategory($catid);
5246 // check category id
5247 if (($key == 'catid') && ($value == $catid))
5249 return $blog->isValidCategory($catid);
5256 * AdminActions::ifOnTeam()
5257 * Checks if a member is on the team of a blog and return his rights
5259 * @param string $blogName name of weblog
5262 private function ifOnTeam($blogName = '')
5264 global $blog, $member, $manager;
5266 // when no blog found
5267 if ( ($blogName == '') && !is_object($blog) )
5272 // explicit blog selection
5273 if ($blogName != '')
5275 $blogid = getBlogIDFromName($blogName);
5278 if (($blogName == '') || !$manager->existsBlogID($blogid))
5281 $blogid = $blog->getID();
5283 return $member->teamRights($blogid);
5287 * AdminActions::ifAdmin()
5288 * Checks if a member is admin of a blog
5290 * @param string $blogName name of weblog
5293 private function ifAdmin($blogName = '')
5295 global $blog, $member, $manager;
5297 // when no blog found
5298 if (($blogName == '') && (!is_object($blog)))
5303 // explicit blog selection
5304 if ($blogName != '')
5306 $blogid = getBlogIDFromName($blogName);
5309 if (($blogName == '') || !$manager->existsBlogID($blogid))
5312 $blogid = $blog->getID();
5315 return $member->isBlogAdmin($blogid);
5319 * AdminActions::ifAddresscange()
5320 * Check e-Mail address is changed
5325 private function ifAddresscange()
5327 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5332 $info = MEMBER::getActivationInfo($key);
5337 $mem = MEMBER::createFromId($info->vmember);
5342 if ( $info->vtype == 'addresschange' )
5350 * AdminActions::templateEditRow()
5353 * @param array $template
5354 * @param string $desc
5355 * @param string $name
5356 * @param string $help
5357 * @param integer $tabindex
5358 * @param boolean $big
5359 * @param array $tmplt
5362 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5366 if ( !array_key_exists($name, $template) )
5368 $template[$name] = '';
5376 $tmplt = skinableTEMPLATE::read($tplt);
5380 'description' => $desc,
5381 'help' => empty($help) ? '' : helpHtml('template' . $help),
5384 'tabindex' => $tabindex,
5385 'rows' => $big ? 10 : 5,
5388 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5390 $base['head'] = "</tr>"
5392 . "<td><%description%><%help%></td>\n"
5393 . "<td id=\"td<%count%>\">\n"
5394 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5398 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5401 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5403 $base['tail'] = "</textarea>\n"
5408 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5411 echo TEMPLATE::fill($base['head'], $data);
5412 echo ENTITY::hsc($template[$name]);
5413 echo TEMPLATE::fill($base['tail'], $data);
5421 * AdminActions::customHelp()
5422 * shows a link to custom help file
5425 * @param string $tplName
5426 * @param string $url
5427 * @param string $iconURL
5428 * @param string $alt
5429 * @param string $title
5433 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5435 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5439 * AdminActions::customHelp()
5440 * shows a link to custom help file
5443 * @param string $tplName
5444 * @param string $url
5445 * @param string $iconURL
5446 * @param string $alt
5447 * @param string $title
5451 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5455 $templates = array();
5459 $templates = Template::read($tplName);
5462 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5464 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5468 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5473 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5476 if ( empty($onclick) )
5478 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5480 elseif ( preg_match('#^onclick#', $onclick) )
5482 $onclick = $onclick;
5486 $onclick = 'onclick="' . $onclick . '"';
5491 'helptarget' => $id,
5492 'onclick' => $onclick,
5493 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5495 return Template::fill($template, $data);
5499 * AdminActions::customHelpHtml()
5502 * @param string $tplName
5503 * @param string $url
5504 * @param string $iconURL
5505 * @param string $alt
5506 * @param string $title
5507 * @param string $onclick
5508 * @return string anchor element with help uri
5510 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5514 $templates = array();
5518 $templates = Template::read($tplName);
5520 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5522 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5526 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5529 if ( empty($iconURL) )
5531 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5534 if ( function_exists('getimagesize') )
5536 $size = getimagesize($iconURL);
5537 $width = 'width="' . $size[0] . '" ';
5538 $height = 'height="' . $size[1] . '" ';
5542 'iconurl' => $iconURL,
5544 'height' => $height,
5545 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5546 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5549 $icon = Template::fill($template, $data);
5550 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5552 return $help . $icon;
5556 * AdminActions::input_yesno
5559 * @param $checkedval
5566 * @param $templateName
5569 private function input_yesno($name,
5580 $templates = array();
5581 if ( $templateName )
5583 $templates = Template::read($templateName);
5586 if ( $name == 'admin' )
5588 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5590 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5591 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5592 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5593 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5597 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5602 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5604 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5608 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5610 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5613 if ( !isset($template) )
5615 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5616 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5617 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5618 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5623 $id = Entity::hsc($name);
5624 $id = str_replace('[', '-', $id);
5625 $id = str_replace(']', '-', $id);
5626 $id1 = $id . Entity::hsc($value1);
5627 $id2 = $id . Entity::hsc($value2);
5629 'name' => Entity::hsc($name),
5630 'yesval' => Entity::hsc($value1),
5631 'noval' => Entity::hsc($value2),
5634 'yesvaltext' => $yesval,
5635 'novaltext' => $noval,
5636 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5637 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5638 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5643 return Template::fill($template, $dat);
5647 echo Template::fill($template, $dat);
5653 * AdminActions::existsNewPlugin()
5654 * Check exists new plugin
5657 * @return boolean exists or not
5659 private function existsNewPlugin()
5661 global $DIR_PLUGINS;
5663 $candidates = array();
5664 $files = scandir($DIR_PLUGINS);
5666 foreach ( $files as $file )
5668 if ( preg_match("#^NP_(.*)\.php$#", $file, $matches) )
5670 $name = $matches[1];
5671 $query = "SELECT * FROM %s WHERE pfile='%s';";
5672 $query = sprintf($query, sql_table('plugin'), sql_real_escape_string("{NP_{$name}"));
5673 $res = sql_query($query);
5675 if ( sql_num_rows($res) == 0 )
5677 $candidates[] = $name;
5682 $this->newPlugCandidates = $candidates;
5683 return (count($candidates) > 0);