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',
94 'localeselectoptions',
111 'selectlocaladminskinfiles',
112 'selectlocalskinfiles',
113 'skineditallowedlist',
130 * AdminActions::$default_actions
131 * list of whole action names with which this class can deal
133 static private $default_actions = array(
144 * AdminActions::$skin_type_friendly_names
145 * friendly name for wrapped page types
147 static private $default_skin_types = array(
148 'actionlog' => _ADM_SKPRT_ACTIONLOG,
149 'activate' => _ADM_SKPRT_ACTIVATE,
150 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
151 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
152 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
153 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
154 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
155 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
156 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
157 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
158 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
159 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
160 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
161 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
162 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
163 'admintemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
164 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
165 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
166 'banlist' => _ADM_SKPRT_BANLIST,
167 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
168 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
169 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
170 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
171 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
172 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
173 'batchitem' => _ADM_SKPRT_BATCHITEM,
174 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
175 'batchmove' => _ADM_SKPRT_BATCHMOVE,
176 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
177 'batchteam' => _ADM_SKPRT_BATCHTEAM,
178 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
179 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX,
180 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
181 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
182 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
183 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
184 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
185 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
186 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
187 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
188 'createitem' => _ADM_SKPRT_CREATEITEM,
189 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
190 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
191 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
192 'insertpluginoptions' => _ADM_SKPRT_INSERTPLUGINO,
193 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
194 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
195 'itemedit' => _ADM_SKPRT_ITEMEDIT,
196 'itemlist' => _ADM_SKPRT_ITEMLIST,
197 'itemmove' => _ADM_SKPRT_ITEMMOVE,
198 'login' => FALSE, //missing
199 'manage' => _ADM_SKPRT_MANAGE,
200 'manageteam' => _ADM_SKPRT_MANAGETEAM,
201 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
202 'memberedit' => FALSE, //missing
203 'overview' => _ADM_SKPRT_OVERVIEW,
204 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
205 'pagehead' => _ADM_SKPRT_PAGEHEAD,
206 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
207 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
208 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
209 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
210 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
211 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
212 'skindelete' => _ADM_SKPRT_SKINDELETE,
213 'skinedit' => _ADM_SKPRT_SKINEDIT,
214 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
215 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
216 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
217 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
218 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
219 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
220 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
221 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
222 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
223 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
224 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
225 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
229 * AdminActions::getAvailableSkinTypes()
233 * @return array list of friendly names for page actions
235 static public function getAvailableSkinTypes()
237 return self::$default_skin_types;
241 * AdminActions::getDefaultTypes()
245 * @return array list of friendly names for page actions
247 static public function getDefaultTypes()
249 return self::$default_skin_types;
253 * AdminActions::__construct()
254 * Constructor for a new Actions object
256 * @param string $type
259 public function __construct($type)
261 // call constructor of superclass first
262 parent::__construct();
263 $this->skintype = $type;
264 if ( !class_exists('Navlist') || !class_exists('Batch') )
267 include $DIR_LIBS . 'ENCAPSULATE.php';
273 * AdminActions::getAvailableActions()
276 * @return array allowed actions for the page type
278 public function getAvailableActions()
280 $extra_actions = array();
282 switch ( $this->skintype )
285 $extra_actions = array(
290 $extra_actions = array(
295 case 'activatesetpwd':
296 $extra_actions = array(
300 $extra_actions = array(
306 case 'adminerrorpage':
307 $extra_actions = array(
310 case 'adminskindelete':
311 $extra_actions = array(
315 case 'adminskinedit':
316 $extra_actions = array(
318 'defaultadminskintypes',
319 'adminspecialskinlist',
322 case 'adminskinedittype':
323 $extra_actions = array(
326 'allowedadminskinactions',
327 'adminskineditallowedlist',
330 case 'adminskiniedoimport':
331 $extra_actions = array(
335 case 'adminskinieimport':
336 $extra_actions = array(
340 case 'adminskinieoverview':
341 $extra_actions = array(
342 'selectlocaladminskinfiles',
346 case 'adminskinoverview':
347 $extra_actions = array(
351 case 'adminskinremovetype':
352 $extra_actions = array(
356 case 'admintemplatedelete':
357 $extra_actions = array(
358 'editadmintemplateinfo',
360 case 'admintemplateedit':
361 $extra_actions = array(
362 'editadmintemplateinfo',
365 case 'admntemplateoverview':
366 $extra_actions = array(
367 'admintemplateoverview',
370 case 'backupoverview':
371 $extra_actions = array(
374 case 'backuprestore':
375 $extra_actions = array(
379 $extra_actions = array(
385 case 'banlistdelete':
386 $extra_actions = array(
391 case 'banlistdeleteconfirm':
392 $extra_actions = array(
393 'banlistdeletedlist',
398 $extra_actions = array(
404 case 'batchcategory':
405 $extra_actions = array(
411 $extra_actions = array(
417 $extra_actions = array(
423 $extra_actions = array(
429 $extra_actions = array(
435 $extra_actions = array(
444 $extra_actions = array(
453 $extra_actions = array(
459 case 'blogcommentlist':
460 $extra_actions = array(
466 case 'blogselectbox':
467 $extra_actions = array(
472 $extra_actions = array(
488 $extra_actions = array(
492 case 'browseowncomments':
493 $extra_actions = array(
497 case 'browseownitems':
498 $extra_actions = array(
502 case 'categorydelete':
503 $extra_actions = array(
509 $extra_actions = array(
516 case 'commentdelete':
517 $extra_actions = array(
522 $extra_actions = array(
527 $extra_actions = array(
539 $extra_actions = array(
545 $extra_actions = array(
550 case 'editmembersettings':
551 $extra_actions = array(
552 'adminskinselectoptions',
554 'localeselectoptions',
558 case 'insertpluginoptions':
559 $extra_actions = array(
560 'insertpluginoptions',
563 case 'itemcommentlist':
564 $extra_actions = array(
570 $extra_actions = array(
577 $extra_actions = array(
589 $extra_actions = array(
596 $extra_actions = array(
602 $extra_actions = array(
606 $extra_actions = array(
615 $extra_actions = array(
620 $extra_actions = array(
625 $extra_actions = array(
633 $extra_actions = array(
646 $extra_actions = array(
651 $extra_actions = array(
657 $extra_actions = array(
662 case 'pluginoptions':
663 $extra_actions = array(
665 'editplugoptionslist',
669 $extra_actions = array(
672 'configsettingsedit',
673 'configsettingsyesno',
676 'localeselectoptions',
682 $extra_actions = array(
687 $extra_actions = array(
692 $extra_actions = array(
698 $extra_actions = array(
701 'allowedskinactions',
702 'skineditallowedlist',
703 'skineditallowedlist',
706 case 'skiniedoimport':
707 $extra_actions = array(
712 $extra_actions = array(
716 case 'skinieoverview':
717 $extra_actions = array(
718 'selectlocalskinfiles',
723 $extra_actions = array(
727 case 'skinremovetype':
728 $extra_actions = array(
732 case 'systemoverview':
733 $extra_actions = array(
738 $extra_actions = array(
744 case 'templatedelete':
745 $extra_actions = array(
750 $extra_actions = array(
754 case 'templateoverview':
755 $extra_actions = array(
759 case 'usermanagement':
760 $extra_actions = array(
766 $extra_actions = array(
776 'selectlocaladminskinfiles',
784 $defined_actions = array_merge(self::$default_actions, $extra_actions);
786 return array_merge($defined_actions, parent::getAvailableActions());
790 * AdminActions::setSkin()
792 * @param object $skin an instance of Skin class
795 public function setSkin(&$skin)
797 $this->skin =& $skin;
802 * AdminActions::parse_actionloglist()
803 * Parse skinvar actionloglist
805 * @param string $templateName name of template to use
808 public function parse_actionloglist($templateName = '')
810 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
811 $query = sprintf($query, sql_table('actionlog'));
813 $template['content'] = 'actionlist';
814 $amount = showlist($query, 'table', $template, $templateName);
820 * AdminActions::parse_activationmessage()
821 * Parse skinvar activationmessage
823 * @param string $type type of message
824 * @param string $templateName name of template to use
827 public function parse_activationmessage($type, $templateName = '')
829 global $CONF, $manager;
833 if ( !empty($templateName))
835 $template = Template::read($templateName);
838 $key = postVar('ackey');
841 Admin::error(_ERROR_ACTIVATE);
844 $info = MEMBER::getActivationInfo($key);
847 Admin::error(_ERROR_ACTIVATE);
850 $mem = MEMBER::createFromId($info->vmember);
853 Admin::error(_ERROR_ACTIVATE);
855 switch ( $info->vtype )
858 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
860 $title = $template['ACTIVATE_FORGOT_TITLE'];
864 $title = _ACTIVATE_FORGOT_TITLE;
866 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
868 $text = $template['ACTIVATE_FORGOT_TEXT'];
872 $text = _ACTIVATE_FORGOT_TEXT;
876 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
878 $title = $template['ACTIVATE_REGISTER_TITLE'];
882 $title = _ACTIVATE_REGISTER_TITLE;
884 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
886 $text = $template['ACTIVATE_REGISTER_TEXT'];
890 $text = _ACTIVATE_REGISTER_TEXT;
893 case 'addresschange':
894 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
896 $title = $template['ACTIVATE_CHANGE_TITLE'];
900 $title = _ACTIVATE_CHANGE_TITLE;
902 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
904 $text = $template['ACTIVATE_CHANGE_TEXT'];
908 $text = _ACTIVATE_CHANGE_TEXT;
913 'memberName' => Entity::hsc($mem->getDisplayName()),
914 'realName' => Entity::hsc($mem->getRealName()),
919 echo Template::fill($title, $aVars);
922 echo Template::fill($text, $aVars);
925 echo Entity::hsc($key);
932 * AdminActions::parse_addtickettourl()
933 * Parse skinvar addtickettourl
935 * @param string $url URI for ticket
938 public function parse_addtickettourl($url)
941 $url = $manager->addTicketToUrl($url);
942 echo Entity::hsc($url);
947 * AdminActions::parse_adminbanlist()
948 * Parse skinvar adminbanlist
950 * @param string $templateName name of template to use
953 public function parse_adminbanlist($templateName = '')
955 $blogid = intRequestVar('blogid');
957 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
958 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
960 $template['content'] = 'banlist';
962 $amount = Showlist($query, 'table', $template, $templateName);
972 * AdminActions::parse_adminbatchaction()
973 * Parse skinvar adminbatchaction
978 public function parse_adminbatchaction()
980 echo Entity::hsc(requestVar('batchaction'));
985 * AdminActions::parse_adminbatchlist()
986 * Parse skinvar adminbatchlist
988 * @param string $templateName name of template to use
991 public function parse_adminbatchlist($templateName = '')
994 $templates = array();
996 if ( !empty($templateName) )
998 $templates = Template::read($templateName);
1001 if ( !array_key_exists('ADMIN_BATCHLIST', $templates) || empty($templates['ADMIN_BATCHLIST']) )
1003 $template = '<li><%text(_BATCH_EXECUTING)%>'
1004 . '<b><%adminbatchaction%></b>'
1005 . '<%batchlisttype%>'
1006 . '<b><%batchid%></b>...'
1007 . '<b><%batchlistmsg%></b>'
1012 $template = $templates['ADMIN_BATCHLIST'];
1015 $selected = requestIntArray('batch');
1016 $action = requestVar('batchaction');
1018 switch ( $this->skintype )
1021 $batchlisttype = _BATCH_ONITEM;
1022 $deleteaction = 'deleteOneItem';
1023 $moveaction = 'moveOneItem';
1024 $destid = intRequestVar('destcatid');
1026 case 'batchcomment':
1027 $batchlisttype = _BATCH_ONCOMMENT;
1028 $deleteaction = 'deleteOneComment';
1031 $batchlisttype = _BATCH_ONMEMBER;
1032 $deleteaction = 'deleteOneMember';
1033 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1034 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1035 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1036 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1039 $blogid = intRequestVar('blogid');
1040 $batchlisttype = _BATCH_ONTEAM;
1041 $deleteaction = 'deleteOneTeamMember';
1042 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1043 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1044 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1045 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1047 case 'batchcategory':
1048 $batchlisttype = _BATCH_ONCATEGORY;
1049 $deleteaction = 'deleteOneCategory';
1050 $moveaction = 'moveOneCategory';
1051 $destid = intRequestVar('destblogid');
1055 // walk over all selectedids and perform action
1056 foreach ( $selected as $selectedid )
1060 $selectedid = intval($selectedid);
1065 if ( $this->skintype != 'batchteam' )
1067 $error = call_user_func_array(array('Admin', $deleteaction), array($selectedid));
1071 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1075 $error = call_user_func_array(array('Admin', $moveaction), array($selectedid));
1079 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1083 // there should always remain at least one super-admin
1084 $r = DB::getResult($unsetchksql);
1085 if ( $r->rowCount() < 2 )
1087 $error = $unseterrmsg;
1091 DB::execute("UPDATE {$setadminsql} {$selectedid};");
1095 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1099 'batchid' => $selectedid,
1100 'batchlisttype' => Entity::hsc($batchlisttype),
1101 'adminbatchaction' => Entity::hsc($action),
1102 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1105 $handler = new AdminActions('template');
1106 $parser = new Parser($handler);
1109 $parser->parse($template);
1110 $template = ob_get_contents();
1114 echo Template::fill($template, $data);
1119 * AdminActions::parse_adminbloglink()
1120 * Parse skinvar adminbloglink
1122 * @param string $templateName name of template to use
1125 public function parse_adminbloglink($templateName = '')
1128 $blogid = intRequestVar('blogid');
1129 $blog =& $manager->getBlog($blogid);
1130 $templates = array();
1132 if ( !empty($templateName) )
1134 $templates = Template::read($templateName);
1137 if ( !array_key_exists('ADMIN_BLOGLINK', $templates) || empty($templates['ADMIN_BLOGLINK']) )
1139 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1143 $template = $templates['ADMIN_BLOGLINK'];
1147 'url' => Entity::hsc($blog->getURL()),
1148 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1149 'blogname' => Entity::hsc($blog->getName())
1152 echo Template::fill($template, $data);
1157 * AdminActions::parse_adminerrormesg()
1158 * Parse skinvar adminerrormesg
1163 public function parse_adminerrormesg()
1168 if ( requestVar('errormessage') )
1170 $message = requestVar('errormessage');
1172 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1174 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1176 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1178 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1180 echo Entity::hsc($message);
1185 * AdminActions::parse_adminskineditallowedlist()
1186 * Parse skinvar adminskineditallowedlist
1188 * @param string $type template/blog
1189 * @param string $templateName name of template to use
1192 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1196 /* TODO: blog seems not to be used */
1198 $query = "SELECT bshortname, bname FROM %s";
1199 $query = sprintf($query, sql_table('blog'));
1201 'content' => 'shortblognames'
1203 Showlist($query, 'table', $show, $templateName);
1206 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1207 $query = sprintf($query, sql_table('template_desc'));
1209 'content' => 'shortnames'
1211 Showlist($query, 'table', $show, $templateName);
1218 * AdminActions::parse_adminskinielist()
1219 * Parse skinvar adminskinielist
1221 * @param string $type skin/template
1222 * @param string $templateName name of template to use
1225 public function parse_adminskinielist($type, $templateName = '')
1227 $templates = array();
1228 if ( $templateName )
1230 $templates = Template::read($templateName);
1233 if ( !array_key_exists('SKINIE_EXPORT_LIST', $templates) || empty($templates['SKINIE_EXPORT_LIST']) )
1236 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
1237 . "<label for=\"<%expid%>\"><%expname%></label>"
1239 . "<td><%expdesc%></td>\n"
1245 $template = $templates['SKINIE_EXPORT_LIST'];
1251 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%';";
1252 $query = sprintf($query, sql_table('skin_desc'));
1253 $res = DB::getResult($query);
1255 foreach ( $res as $row )
1258 'typeid' => 'skin[' . $row['sdnumber'] . ']',
1259 'expid' => 'skinexp' . $row['sdnumber'],
1260 'expname' => Entity::hsc($row['sdname']),
1261 'expdesc' => Entity::hsc($row['sddesc']),
1263 echo Template::fill($template, $data);
1267 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%';";
1268 $query = sprintf($query, sql_table('template_desc'));
1269 $res = DB::getResult($query);
1270 foreach ( $res as $row )
1273 'typeid' => 'template[' . $row['tdnumber'] . ']',
1274 'expid' => 'templateexp' . $row['tdnumber'],
1275 'expname' => Entity::hsc($row['tdname']),
1276 'expdesc' => Entity::hsc($row['tddesc']),
1278 echo Template::fill($template, $data);
1286 * AdminActions::parse_adminskinoverview()
1287 * Parse skinvar adminskinoverview
1289 * @param string $templateName name of template to use
1292 public function parse_adminskinoverview($templateName = '')
1294 $query = "SELECT * FROM %s WHERE sdname LIKE 'admin/%%' ORDER BY sdname;";
1295 $query = sprintf($query, sql_table('skin_desc'));
1297 $template['content'] = 'adminskinlist';
1298 $template['tabindex'] = 10;
1299 $template['friendly_names'] = $this->skin->getAvailableTypes();
1300 Showlist($query, 'table', $template, $templateName);
1305 * AdminActions::parse_adminskinselectoptions()
1306 * Parse skinvar adminskinselectoptions
1311 public function parse_adminskinselectoptions()
1314 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname LIKE 'admin/%%';";
1315 $query = sprintf($query, sql_table('skin_desc'));
1317 $template['name'] = 'adminskin';
1318 $template['selected'] = $CONF['AdminSkin'];
1319 $template['tabindex'] = 110;
1320 Showlist($query, 'select', $template, '');
1325 * AdminActions::parse_adminspecialskinlist()
1326 * Parse skinvar adminspecialskinlist
1328 * @param string $templateName name of template to use
1330 public function parse_adminspecialskinlist($templateName = '')
1332 $templates = array();
1333 if ( $templateName )
1335 $templates = Template::read($templateName);
1338 $nType = $this->skin->getAvailableTypes();
1339 $skinid = intRequestVar('skinid');
1341 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1342 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1344 $res = DB::getResult($query);
1345 if ( $res && $res->rowCount() > 0 )
1347 /* NOTE: set templates for HEAD/BODY/FOOT */
1348 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1350 $template['head'] = "<ul>\n";
1354 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1356 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1358 $template['body'] = '<li>'
1359 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1362 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1369 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1371 if ( !array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) || empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1373 $template['foot'] = "</ul>\n";
1377 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1384 echo $template['head'];
1385 foreach ( $res as $row )
1388 'tabindex' => $tabstart++,
1389 'skinid' => $skinid,
1390 'skintype' => Entity::hsc(strtolower($row['stype']))
1392 echo Template::fill($template['body'], $data);
1395 echo $template['foot'];
1401 * AdminActions::parse_admintemplateoverview()
1402 * Parse skinvar admintemplateoverview
1404 * @param string $templateName name of template to use
1407 public function parse_admintemplateoverview($templateName = '')
1409 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1410 $query = sprintf($query, sql_table('template_desc'));
1412 $template['content'] = 'admintemplatelist';
1413 $template['tabindex'] = 10;
1415 Showlist($query, 'table', $template, $templateName);
1420 * AdminActions::parse_allowedadminskinactions()
1421 * Parse skinvar allowedadminskinactions
1426 public function parse_allowedadminskinactions()
1428 global $DIR_ADMINSKINS;
1429 $skinType = strtolower(trim(requestVar('type')));
1430 $actions = $this->skin->getAllowedActionsForType($skinType);
1433 while ( $current = array_shift($actions) )
1435 // TODO: remove this
1436 // skip deprecated vars
1437 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1442 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1444 if ( count($actions) != 0 )
1453 * AdminActions::parse_allowedskinactions()
1454 * Parse skinvar allowedskinactions
1459 public function parse_allowedskinactions()
1461 $skinType = strtolower(trim(requestVar('type')));
1462 $skinid = intRequestVar('skinid');
1464 $skin = new Skin($skinid);
1465 $actions = $skin->getAllowedActionsForType($skinType);
1468 while ( $current = array_shift($actions) )
1470 // TODO: remove this
1471 // skip deprecated vars
1472 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1477 /* TODO: alternative function should be used or not? */
1478 echo helplink("skinvar-{$current}") . "$current</a>\n";
1480 if ( count($actions) != 0 )
1489 * AdminActions::parse_banlistdeletedlist()
1490 * Parse skinvar banlistdeletedlist
1492 * @param string $templateName name of template to use
1495 public function parse_banlistdeletedlist($templateName = '')
1499 $templates = array();
1500 if ( $templateName )
1502 $templates = Template::read($templateName);
1505 if ( !array_key_exists('BANLIST_DELETED_LIST', $templates) || empty($templates['BANLIST_DELETED_LIST']) )
1507 $template = "<li><%blogname%></li>\n";
1511 $template = $templates['BANLIST_DELETED_LIST'];
1514 $deleted = requestArray('delblogs');
1515 foreach ( $deleted as $delblog )
1517 $blog =& $manager->getBlog($delblog);
1519 'blogname' => Entity::hsc($blog->getName())
1521 echo Template::fill($template, $data);
1528 * AdminActions::parse_batchdeletelist()
1529 * Parse skinvar batchdeletelist
1534 public function parse_batchdeletelist()
1536 $selected = requestIntArray('batch');
1539 foreach ( $selected as $select )
1541 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1543 // add hidden vars for team & comment
1544 if ( requestVar('action') == 'batchteam' )
1546 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1548 if ( requestVar('action') == 'batchcomment' )
1550 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1556 * AdminActions::parse_batchdeletetype()
1557 * Parse skinvar batchdeletetype
1562 public function parse_batchdeletetype()
1564 echo Entity::hsc(requestVar('action'));
1569 * AdminActions::parse_batchmovebtn()
1570 * Parse skinvar batchmovebtn
1575 public function parse_batchmovebtn()
1577 $actionType = requestVar('action');
1578 switch ( $actionType )
1583 case 'batchcategory':
1591 * AdminActions::parse_batchmovelist()
1592 * Parse skinvar batchmovelist
1597 public function parse_batchmovelist()
1599 $selected = requestIntArray('batch');
1600 foreach ( $selected as $select )
1602 echo '<input type="hidden" name="batch[' . ($select++) . ']" value="' . intval($select) . "\" />\n";
1608 * AdminActions::parse_batchmovetitle()
1609 * Parse skinvar batchmovetitle
1614 public function parse_batchmovetitle()
1616 $actionType = requestVar('action');
1617 switch ( $actionType )
1622 case 'batchcategory':
1623 echo _MOVECAT_TITLE;
1630 * AdminActions::parse_batchmovetype()
1631 * Parse skinvar batchmovetype
1636 public function parse_batchmovetype()
1638 echo Entity::hsc(requestVar('action'));
1643 * AdminActions::parse_blogcatlist()
1644 * Parse skinvar blogcatlist
1649 public function parse_blogcatlist()
1652 $blogid = intRequestVar('blogid');
1653 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1654 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1656 $template['content'] = 'categorylist';
1657 $template['tabindex'] = 200;
1659 $batch = new Batch('category');
1660 $batch->showlist($query, 'table', $template);
1665 * AdminActions::parse_blogid()
1666 * Parse skinvar blogid
1671 public function parse_blogid()
1673 echo intRequestVar('blogid');
1678 * AdminActions::parse_blognotifysetting()
1679 * Parse skinvar blognotifysetting
1684 public function parse_blognotifysetting($type)
1687 $blogid = intRequestVar('blogid');
1688 $blog = $manager->getBlog($blogid);
1693 if ( !$blog->notifyOnComment() )
1699 if ( !$blog->notifyOnVote() )
1705 if ( !$blog->notifyOnNewItem() )
1711 echo ' checked="checked"';
1716 * AdminActions::parse_blogselectbox()
1717 * Parse skinvar blogselectbox
1722 public function parse_blogselectbox()
1726 $selectData = requestVar('selectData');
1727 $mode = $selectData['mode'];
1728 $name = Entity::hsc($selectData['name']);
1729 $tabindex = Entity::hsc($selectData['tabindex']);
1730 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1731 $showNewCat = intval($selectData['showNewCat']);
1732 $selected = intval($selectData['selected']);
1734 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1736 // 1. select blogs (we'll create optiongroups)
1737 // (only select those blogs that have the user on the team)
1738 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1739 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1740 $blogs = DB::getResult($queryBlogs);
1742 if ( $mode == 'category' )
1744 if ( $blogs->rowCount() > 1 )
1748 foreach ( $blogs as $rBlog )
1750 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1752 echo '<optgroup label="' . Entity::hsc($rBlog['bname']) . "\">\n";
1755 // show selection to create new category when allowed/wanted
1758 // check if allowed to do so
1759 if ( $member->blogAdminRights($rBlog['bnumber']) )
1761 echo '<option value="newcat-' . $rBlog['bnumber'] . '">' . _ADD_NEWCAT . "</option>\n";
1765 // 2. for each category in that blog
1766 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1767 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $rBlog['bnumber']);
1768 $categories = DB::getResult($catQuery);
1769 foreach ( $categories as $rCat )
1771 if ( $rCat['catid'] == $selected )
1773 $selectText = ' selected="selected" ';
1779 echo '<option value="' . $rCat['catid'] . '" ' . $selectText . '>' . Entity::hsc($rCat['cname']) . "</option>\n";
1782 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1791 foreach ( $blogs as $rBlog )
1793 echo '<option value="' . $rBlog['bnumber'] . '"';
1794 if ( $rBlog['bnumber'] == $selected )
1796 echo '<option value="' . $rBlog['bnumber'] . '" selected="selected">' . Entity::hsc($rBlog['bname']) . "</option>\n";
1800 echo '<option value="' . $rBlog['bnumber'] . '">' . Entity::hsc($rBlog['bname']) . "</option>\n";
1809 * AdminActions::parse_blogsetting()
1810 * Parse skinvar blogsetting
1812 * @param string $which name of weblog setting
1815 public function parse_blogsetting($which)
1817 echo $this->parse_getblogsetting($which);
1822 * AdminActions::parse_blogsettingyesno()
1823 * Parse skinvar blogsettingyesno
1825 * @param string $type type of weblog setting
1826 * @param string $templateName name of template to use
1829 public function parse_blogsettingyesno($type, $templateName = '')
1833 $blogid = intRequestVar('blogid');
1834 $blog = $manager->getBlog($blogid);
1838 case 'convertbreaks':
1839 $checkedval = $blog->convertBreaks();
1842 case 'allowpastposting':
1843 $checkedval = $blog->allowPastPosting();
1847 $checkedval = $blog->commentsEnabled();
1851 $checkedval = $blog->isPublic();
1855 $checkedval = $blog->emailRequired();
1859 $checkedval = $blog->getSearchable();
1863 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1868 * AdminActions::parse_blogteamlist()
1869 * Parse skinvar blogteamlist
1871 * @param string $templateName name of template to use
1874 public function parse_blogteamlist($templateName = '')
1877 $blogid = intRequestVar('blogid');
1878 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1880 . "WHERE tmember=mnumber AND tblog= %d";
1881 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1883 $template['content'] = 'teamlist';
1884 $template['tabindex'] = 10;
1886 $batch = new Batch('team');
1887 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1892 * AdminActions::parse_blogteammembers()
1893 * Parse skinvar blogteammembers
1898 public function parse_blogteammembers()
1900 $blogid = intRequestVar('blogid');
1901 $query = "SELECT mname, mrealname "
1903 . "WHERE mnumber=tmember AND tblog=%d;";
1904 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1905 $res = DB::getResult($query);
1906 $memberNames = array();
1907 foreach ( $res as $row )
1909 $memberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
1911 echo implode(',', $memberNames);
1915 * AdminActions::parse_blogtime()
1916 * Parse skinvar blogtime
1918 * @param string $type type of time
1919 * @param string $format format for time expression
1920 * @param integer $offset offset of time
1923 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1927 if ( $type != 'blogtime' )
1929 /* return server time */
1930 $timestamp = time() + $offset;
1934 $bid = intRequestVar('blogid');
1935 $b = $manager->getBlog($bid);
1936 $timestamp = $b->getCorrectTime() + $offset;
1939 echo i18n::formatted_datetime($format, $timestamp);
1944 * AdminActions::parse_bookmarkletadmin()
1945 * Parse skinvar bookmarkletadmin
1950 public function parse_bookmarkletadmin()
1954 $blogid = intRequestVar('blogid');
1956 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1961 * AdminActions::parse_categories()
1962 * Parse skinvar categories
1964 * create category dropdown box
1966 * @param string $type name of setting for category
1969 public function parse_categories($startidx = 0)
1974 $itemid = intRequestVar('itemid');
1975 $item = &$manager->getItem($itemid, 1, 1);
1980 $blogid = intRequestVar('blogid');
1984 $blogid = $item['blogid'];
1986 $blog = &$manager->getBlog($blogid);
1988 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
1990 $item['body'] = removeBreaks($item['body']);
1991 $item['more'] = removeBreaks($item['more']);
1994 $contents = array();
1995 if ( requestVar('action') == 'itemedit' )
2000 if ( !array_key_exists('catid', $contents) || empty($contents['catid']) )
2003 $catid = $blog->getDefaultCategory();
2008 $catid = $contents['catid'];
2011 Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
2017 * AdminActions::parse_category()
2018 * Parse skinvar category
2020 * @param string $type name of setting for category
2023 public function parse_category($type = 'name')
2025 echo $this->parse_getcategory($type);
2030 * AdminActions::parse_categorysetting()
2031 * Parse skinvar categorysetting
2033 * @param string $type type in category setting
2036 public function parse_categorysetting($type)
2038 $catid = intRequestVar('catid');
2039 if ( $type == 'id' )
2044 $blogid = intRequestVar('blogid');
2045 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
2046 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
2047 $row = DB::getRow($query);
2049 if ( $type != 'name' )
2051 echo Entity::hsc($row['cdesc']);
2055 echo Entity::hsc($row['cname']);
2062 * AdminActions::parse_codename()
2063 * Parse templatevar codename
2069 public function parse_checkedonval($value, $name)
2074 $itemid = intRequestVar('itemid');
2075 $item =& $manager->getItem($itemid, 1, 1);
2077 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2079 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
2081 $item['body'] = removeBreaks($item['body']);
2082 $item['more'] = removeBreaks($item['more']);
2085 $contents = array();
2086 if ( requestVar('action') == 'itemedit' )
2090 if ( !isset($contents[$name]) )
2092 $contents[$name] = '';
2094 if ($contents[$name] == $value)
2096 echo 'checked="checked"';
2102 * AdminActions::parse_codename()
2103 * Parse templatevar codename
2108 * TODO: is this need???
2110 public function parse_codename()
2113 echo $nucleus['codename'];
2118 * AdminActions::parse_commentnavlist()
2119 * Parse skinvar commentnavlist
2124 public function parse_commentnavlist()
2126 global $CONF, $manager, $member;
2129 if ( postVar('start') )
2131 $start = intPostVar('start');
2138 // amount of items to show
2139 if ( postVar('amount') )
2141 $amount = intPostVar('amount');
2145 $amount = (integer) $CONF['DefaultListSize'];
2151 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2153 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2155 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2157 if ( $this->skintype == 'itemcommentlist' )
2159 $itemid = intRequestVar('itemid');
2160 $query .= " citem={$itemid}";
2161 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2163 $nonComments = _NOCOMMENTS;
2165 elseif ( $this->skintype == 'browseowncomments' )
2168 $query .= ' cmember=' . $member->getID();
2169 $template['canAddBan'] = 0;
2171 $nonComments = _NOCOMMENTS_YOUR;
2173 elseif ( $this->skintype == 'blogcommentlist' )
2176 $query .= ' cblog=' . intRequestVar('blogid');
2177 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2178 $bid = intRequestVar('blogid');
2179 $nonComments = _NOCOMMENTS_BLOG;
2182 $search = postVar('search');
2183 if ( !empty($search) )
2185 $query .= ' and cbody LIKE ' . DB::quoteValue('%'.$search.'%');
2188 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2190 $template['content'] = 'commentlist';
2192 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2193 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2198 * AdminActions::parse_configsettingsedit()
2199 * Parse skinvar configsettingsedit
2201 * @param string $type type of global configuration
2204 public function parse_configsettingsedit($type)
2209 case 'DefaultListSize':
2210 if ( !array_key_exists('DefaultListSize', $CONF) )
2212 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2213 $query = sprintf($query, sql_table('config'));
2214 DB::execute($query);
2215 $CONF['DefaultListSize'] = 10;
2217 elseif ( intval($CONF['DefaultListSize']) < 1 )
2219 $CONF['DefaultListSize'] = 10;
2221 echo intval($CONF['DefaultListSize']);
2223 case 'SessionCookie':
2224 $value = $CONF['SessionCookie'];
2225 $txt1 = _SETTINGS_COOKIESESSION;
2226 $txt2 = _SETTINGS_COOKIEMONTH;
2227 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2230 $value = $CONF['URLMode'];
2231 $txt1 = _SETTINGS_URLMODE_NORMAL;
2232 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2233 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2236 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2238 echo Entity::hsc($CONF[$type]);
2246 * AdminActions::parse_configsettingsyesno()
2247 * Parse skinvar configsettingsyesno
2249 * @param string $type type of global setting
2250 * @param integer $tabindex tabindex attribute of input element
2253 public function parse_configsettingsyesno($type, $tabindex)
2256 if ( array_key_exists($type, $CONF) )
2258 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2264 * AdminActions::parse_contents()
2265 * Parse skinvar contents
2267 * @param string $which part for item
2270 public function parse_contents($which)
2275 $contents = array();
2277 if ( requestVar('action') == 'itemedit' )
2279 $itemid = intRequestVar('itemid');
2280 $item =& $manager->getItem($itemid, 1, 1);
2282 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2284 if ( $item && $blog->convertBreaks() )
2286 $item['body'] = removeBreaks($item['body']);
2287 $item['more'] = removeBreaks($item['more']);
2291 elseif ( requestVar('action') == 'createitem' )
2293 $blogid = intRequestVar('blogid');
2294 $blog =& $manager->getBlog($blogid);
2298 'contents' => &$contents,
2304 if ( !array_key_exists($which, $contents) )
2306 $contents[$which] = '';
2308 echo Entity::hsc($contents[$which],ENT_QUOTES);
2312 * AdminActions::parse_currenttime()
2313 * Parse skinvar currenttime
2315 * @param string $what
2318 public function parse_currenttime($what)
2321 if ( requestVar('action') == 'itemedit' )
2323 $itemid = intRequestVar('itemid');
2324 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2326 elseif ( requestVar('action') == 'createitem' )
2328 $blog =& $manager->getBlog(intRequestVar('blogid'));
2330 $nu = getdate($blog->getCorrectTime());
2335 * AdminActions::parse_customhelplink()
2336 * Parse skinvar customhelplink
2338 * @param string $topic name of topic
2339 * @param string $tplName name of template
2340 * @param string $url string as URI
2341 * @param string $iconURL string as URI for icon
2342 * @param string $alt alternative text for image element
2343 * @param string $title title for anchor element
2346 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2348 $this->customHelp($topic, $url, $iconURL);
2353 * AdminActions::parse_date()
2354 * Parse skinvar date
2356 public function parse_date($format = 'c')
2358 global $CONF, $manager;
2359 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2364 * AdminActions::parse_defaultadminskintypes()
2365 * Parse skinvar defaultadminskintypes
2367 * @param string $tabindex index number for tabindex attribute of input element
2368 * @param string $templateName name of template
2371 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2373 $templates = array();
2375 if ( $templateName )
2377 $templates = Template::read($templateName);
2380 $types = $this->skin->getAvailableTypes();
2383 /* NOTE: set templates for HEAD/BODY/FOOT */
2384 if ( !array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) || empty($templates['ADMINSKINTYPELIST_HEAD']) )
2386 $template['head'] = "<ul>\n";
2390 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2392 if ( !array_key_exists('ADMINSKINTYPELIST_BODY', $templates) || empty($templates['ADMINSKINTYPELIST_BODY']) )
2394 $template['body'] = "<li>"
2395 . "<a tabindex=\"<%tabindex%>\" href=\"index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>\"><%name%></a> <%help%>"
2400 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2402 if ( !array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) || empty($templates['ADMINSKINTYPELIST_FOOT']) )
2404 $template['foot'] = "</ul>\n";
2408 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2411 $handler = new AdminActions('template');
2412 $parser = new PARSER($handler);
2414 /* NOTE: do output */
2415 echo $template['head'];
2416 foreach ( $types as $type => $fName )
2418 $helplink = $this->customHelpHtml("skinpart{$type}{$templateName}");
2420 'tabindex' => $tabindex,
2421 'skintype' => $type,
2423 'help' => $helplink,
2424 'skinid' => intrequestVar('skinid'),
2426 $parser->parse(Template::fill($template['body'], $data));
2429 echo $template['foot'];
2435 * AdminActions::parse_defblogselect()
2436 * Parse skinvar defblogselect
2438 * @param string $templateName name of template
2441 public function parse_defblogselect($templateName = '')
2445 $query = "SELECT bname as text, bnumber as value FROM %s;";
2446 $query = sprintf($query, sql_table('blog'));
2448 $template['name'] = 'DefaultBlog';
2449 $template['selected'] = $CONF['DefaultBlog'];
2450 $template['tabindex'] = 10;
2452 Showlist($query, 'select', $template, $templateName);
2458 * AdminActions::parse_defcatselect()
2459 * Parse skinvar defcatselect
2461 * @param string $templateName name of template
2464 public function parse_defcatselect($templateName = '')
2468 $blogid = intRequestVar('blogid');
2469 $blog = $manager->getBlog($blogid);
2471 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2472 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2474 $template['name'] = 'defcat';
2475 $template['selected'] = $blog->getDefaultCategory();
2476 $template['tabindex'] = 110;
2478 Showlist($query, 'select', $template, $templateName);
2484 * AdminActions::parse_defskinselect()
2485 * Parse skinvar defskinselect
2487 * @param string $type type of skin
2488 * @param string $templateName name of template
2491 public function parse_defskinselect($type = 'blog', $templateName = '')
2493 global $CONF, $manager;
2495 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdname NOT LIKE 'admin/%%';";
2496 $query = sprintf($query, sql_table('skin_desc'));
2498 $blogid = intRequestVar('blogid');
2502 $template['selected'] = $CONF['BaseSkin'];
2506 $blog = $manager->getBlog($blogid);
2507 $template['selected'] = $blog->getDefaultSkin();
2510 if ( $type != 'blog' )
2512 $nname = 'BaseSkin';
2519 $template['name'] = $nname;
2520 $template['tabindex'] = 50;
2522 Showlist($query, 'select', $template, $templateName);
2528 * AdminActions::parse_deletecomment()
2529 * Parse skinvar deletecomment
2531 * @param string $type type of infomation for comment
2534 public function parse_deletecomment($type = 'id')
2536 $commentid = intRequestVar('commentid');
2537 $comment = COMMENT::getComment($commentid);
2542 echo intRequestVar('commentid');
2545 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2547 echo $comment['member'];
2551 echo $comment['user'];
2555 $body = strip_tags($comment['body']);
2556 echo Entity::hsc(shorten($body, 300, '...'));
2562 * AdminActions::parse_deleteitembody()
2563 * Parse skinvar deleteitembody
2568 public function parse_deleteitembody()
2572 $itemid = intRequestVar('itemid');
2573 $item =& $manager->getItem($itemid, 1, 1);
2575 $body = strip_tags($item['body']);
2577 echo Entity::hsc(shorten($body, 300, '...'));
2583 * AdminActions::parse_deleteitemid()
2584 * Parse skinvar deleteitemid
2589 public function parse_deleteitemid()
2591 echo (integer) intRequestVar('itemid');
2596 * AdminActions::parse_deleteitemtitle()
2597 * Parse skinvar deleteitemtitle
2602 public function parse_deleteitemtitle()
2606 $itemid = intRequestVar('itemid');
2607 $item =& $manager->getItem($itemid, 1, 1);
2609 echo Entity::hsc(strip_tags($item['title']));
2615 * AdminActions::parse_editadminskin()
2616 * Parse skinvar editadminskin
2618 * @param string $type type of skin setting
2621 public function parse_editadminskin($type = 'id')
2623 $skinid = intRequestVar('skinid');
2624 $skin = new Skin($skinid);
2628 echo intRequestVar('skinid');
2631 echo Entity::hsc($skin->getName());
2634 echo Entity::hsc($skin->getDescription());
2637 echo Entity::hsc($skin->getContentType());
2640 echo Entity::hsc($skin->getIncludePrefix());
2643 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2651 * AdminActions::parse_editadminskintype()
2652 * Parse skinvar editadminskintype
2654 * @param string $type name of skin type
2657 public function parse_editadminskintype($type = 'id')
2659 global $CONF, $manager, $member;
2661 $fNames = $this->skin->getAvailableTypes();
2662 $sType = strtolower(trim(requestVar('type')));
2667 echo intRequestVar('skinid');
2670 echo Entity::hsc($this->skin->getName());
2673 echo Entity::hsc($this->skin->getDescription());
2676 echo Entity::hsc($this->skin->getContentType());
2679 echo Entity::hsc($this->skin->getContentFromDB($sType));
2682 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2683 echo Entity::hsc($skinType);
2686 echo Entity::hsc($sType);
2689 echo Entity::hsc($this->skin->getIncludePrefix());
2692 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2693 echo Entity::hsc($incMode);
2702 * AdminActions::parse_editcomment()
2703 * Parse skinvar editcomment
2705 * @param string $type type of comment setting
2708 public function parse_editcomment($type = 'id')
2712 $commentid = intRequestVar('commentid');
2713 $comment = COMMENT::getComment($commentid);
2715 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2720 echo intRequestVar('commentid');
2723 if ( !array_key_exists('member', $comment) || empty($comment['member']) )
2725 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2729 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2733 echo date("Y-m-d @ H:i", $comment['timestamp']);
2736 $comment['body'] = str_replace('<br />', '', $comment['body']);
2737 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2738 echo $comment['body'];
2741 echo $comment['userid'];
2744 echo $comment['userid'];
2747 echo $comment[$type];
2754 * AdminActions::parse_editdesturl()
2755 * Parse skinvar editdesturl
2757 public function parse_editdesturl()
2759 if ( requestVar('desturl') )
2761 echo Entity::hsc(requestVar('desturl'));
2767 * AdminActions::parse_editmemberlist()
2768 * Parse skinvar editmemberlist
2770 * @param string $templateName name of template
2773 public function parse_editmemberlist($templateName = '')
2776 // show list of members with actions
2777 $query = 'SELECT * FROM '.sql_table('member');
2778 $template['content'] = 'memberlist';
2779 $template['tabindex'] = 10;
2781 $batch = new Batch('member');
2782 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2787 * AdminActions::parse_editmember()
2788 * Parse skinvar editmember
2790 * @param string $type type of information for member
2791 * @return string $tempateName name of template to use
2794 public function parse_editmember($type = 'id', $templateName = '')
2796 global $CONF, $manager, $member;
2798 $memberid = intRequestVar('memberid');
2799 $mem = MEMBER::createFromID($memberid);
2804 echo intRequestVar('memberid');
2807 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2809 echo Entity::hsc($mem->getDisplayName());
2813 $dispName = Entity::hsc($mem->getDisplayName());
2814 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2816 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2825 echo Entity::hsc($mem->getRealName());
2828 echo Entity::hsc($mem->getEmail());
2831 echo Entity::hsc($mem->getURL());
2834 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2837 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2840 echo Entity::hsc($mem->getNotes());
2843 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2852 * AdminActions::parse_editpluginfo()
2853 * Parse skinvar editpluginfo
2855 * @param string $type type of plugin info
2858 public function parse_editpluginfo($type)
2860 $pid = intRequestVar('plugid');
2867 echo Entity::hsc(getPluginNameFromPid($pid));
2874 * AdminActions::parse_editplugoptionslist()
2875 * Parse skinvar editplugoptionslist
2877 * @param string $templateName name of template
2880 public function parse_editplugoptionslist($templateName = '')
2884 $pid = intRequestVar('plugid');
2885 $aOptions = array();
2888 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC;";
2889 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2890 $resource = DB::getResult($query);
2892 foreach ( $resource as $row )
2894 array_push($aOIDs, $row['oid']);
2895 $aOptions[$row['oid']] = array(
2896 'oid' => $row['oid'],
2897 'value' => $row['odef'],
2898 'name' => $row['oname'],
2899 'description' => $row['odesc'],
2900 'type' => $row['otype'],
2901 'typeinfo' => $row['oextra'],
2906 // fill out actual values
2907 if ( count($aOIDs) > 0 )
2909 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2910 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2912 $result = DB::getResult($query);
2914 foreach ( $result as $row )
2916 $aOptions[$row['oid']]['value'] = $row['ovalue'];
2922 'context' => 'global',
2924 'options' => &$aOptions
2926 $manager->notify('PrePluginOptionsEdit', $data);
2928 $template['content'] = 'plugoptionlist';
2930 $amount = Showlist($aOptions, 'table', $template, $templateName);
2934 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2940 * AdminActions::parse_editskin()
2941 * Parse skinvar editskin
2943 * @param string $type type of skin
2946 public function parse_editskin($type = 'id')
2948 $skinid = intRequestVar('skinid');
2949 $skin = new SKIN($skinid);
2953 echo intRequestVar('skinid');
2956 echo Entity::hsc($skin->getName());
2959 echo Entity::hsc($skin->getDescription());
2962 echo Entity::hsc($skin->getContentType());
2965 echo Entity::hsc($skin->getIncludePrefix());
2968 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2976 * AdminActions::parse_editskintype()
2977 * Parse skinvar editskintype
2979 * @param string $type name of type for skin type
2982 public function parse_editskintype($type = 'id')
2984 global $CONF, $manager, $member;
2985 $skinid = intRequestVar('skinid');
2986 $skin = new SKIN($skinid);
2987 $fNames = $skin->getAvailableTypes();
2988 $sType = strtolower(trim(requestVar('type')));
2993 echo intRequestVar('skinid');
2996 echo Entity::hsc($skin->getName());
2999 echo Entity::hsc($skin->getDescription());
3002 echo Entity::hsc($skin->getContentType());
3005 echo Entity::hsc($skin->getContentFromDB($sType));
3008 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
3009 echo Entity::hsc($skinType);
3012 echo Entity::hsc($sType);
3015 echo Entity::hsc($skin->getIncludePrefix());
3018 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
3019 echo Entity::hsc($incMode);
3028 * AdminActions::parse_adminurl()
3029 * Parse skinvar adminurl
3030 * (shortcut for admin url)
3035 public function parse_adminurl()
3037 $this->parse_sitevar('adminurl');
3042 * AdminActions::parse_edittemplateinfo()
3043 * Parse skinvar edittemplateinfo
3045 * @param string $type name of type for skin
3046 * @param string $description description for skin
3047 * @param string $name name of skin
3048 * @param string $help
3049 * @param string $tabindex index value for tabindex attribute of input element
3050 * @param string $big
3051 * @param string $tplt name of template
3054 public function parse_edittemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3058 $t_id = intRequestVar('templateid');
3059 $t_name = Template::getNameFromId($t_id);
3060 $t_desc = Template::getDesc($t_id);
3061 $template = &Template::read($t_name);
3069 echo Entity::hsc($t_name);
3072 echo Entity::hsc($t_desc);
3074 case 'extratemplate':
3076 $pluginfields = array();
3077 $manager->notify('TemplateExtraFields', array('fields' => &$pluginfields));
3082 $tmplt = Template::read($desc);
3084 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3088 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3092 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3095 foreach ( $pluginfields as $pfkey => $pfvalue )
3097 $data = array('explugtplname' => Entity::hsc($pfkey));
3099 echo Template::fill($base, $data);
3101 foreach ( $pfvalue as $pffield => $pfdesc )
3103 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3108 $desc = defined($desc) ? constant($desc) : $desc;
3109 $name = defined($name) ? constant($name) : $name;
3110 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3118 * AdminActions::parse_editadmintemplateinfo()
3119 * Parse skinvar editadmintemplateinfo
3121 * @param string $type type of skin template
3122 * @param string $description description of template
3123 * @param string $name name of stemplate
3124 * @param string $tabindex index number for tabindex attribute of input element
3125 * @param string $big
3126 * @param string $tplt
3128 public function parse_editadmintemplateinfo($type, $desc = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3132 $t_id = intRequestVar('templateid');
3133 $t_name = Template::getNameFromId($t_id);
3134 $t_desc = Template::getDesc($t_id);
3135 $template = &Template::read($t_name);
3143 echo Entity::hsc($t_name);
3146 echo Entity::hsc($t_desc);
3148 case 'extratemplate':
3150 $pluginfields = array();
3151 $manager->notify('AdminTemplateExtraFields', array('fields' => &$pluginfields));
3156 $tmplt = Template::read($desc);
3158 if ( !array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) || empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3162 . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3166 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3169 foreach ( $pluginfields as $pfkey => $pfvalue )
3171 $data = array('explugtplname' => Entity::hsc($pfkey));
3173 echo Template::fill($base, $data);
3175 foreach ( $pfvalue as $pffield => $pfdesc )
3177 $this->templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3182 $desc = defined($desc) ? constant($desc) : $desc;
3183 $name = defined($name) ? constant($name) : $name;
3184 $this->templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3191 * AdminActions::parse_eventformextra()
3192 * Parse skinvar eventformextra
3194 * @param string $type name of type for event form extra
3197 public function parse_eventformextra($type = 'activation')
3206 $key = requestVar('ackey');
3209 Admin::error(_ERROR_ACTIVATE);
3211 $info = MEMBER::getActivationInfo($key);
3214 Admin::error(_ERROR_ACTIVATE);
3216 $mem = MEMBER::createFromId($info->vmember);
3219 Admin::error(_ERROR_ACTIVATE);
3222 'type' => 'activation',
3226 case 'membermailform-notloggedin':
3227 $data = array('type' => 'membermailform-notloggedin',);
3230 $manager->notify('FormExtra', $data);
3235 * AdminActions::parse_extrahead()
3236 * Parse skinvar extrahead
3238 public function parse_extrahead()
3242 $extrahead = Admin::getAdminextrahead();
3245 'extrahead' => &$extrahead,
3246 'action' => Admin::getAdminAction()
3249 $manager->notify('AdminPrePageHead', $data);
3255 * AdminActions::parse_member()
3256 * Parse skinvar member
3257 * (includes a member info thingie)
3259 * @param string $what which memberdata is needed
3262 public function parse_member($what)
3264 global $memberinfo, $member, $CONF;
3266 // 1. only allow the member-details-page specific variables on member pages
3267 if ( $this->skintype == 'member' )
3272 echo Entity::hsc($memberinfo->getDisplayName());
3275 echo Entity::hsc($memberinfo->getRealName());
3278 echo Entity::hsc($memberinfo->getNotes());
3281 echo Entity::hsc($memberinfo->getURL());
3284 echo Entity::hsc($memberinfo->getEmail());
3287 echo Entity::hsc($memberinfo->getID());
3292 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3293 if ( $member->isLoggedIn() )
3298 echo $member->getDisplayName();
3300 case 'yourrealname':
3301 echo $member->getRealName();
3304 echo $member->getNotes();
3307 echo $member->getURL();
3310 echo $member->getEmail();
3313 echo $member->getID();
3315 case 'yourprofileurl':
3316 if ( $CONF['URLMode'] == 'pathinfo' )
3318 echo Link::create_member_link($member->getID());
3322 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3331 * AdminActions::parse_version()
3332 * Parse skinvar version
3333 * (include nucleus versionnumber)
3338 public function parse_version()
3341 echo 'Nucleus CMS ' . $nucleus['version'];
3346 * AdminActions::parse_sitevar()
3347 * Parse skinvar sitevar
3348 * (include a sitevar)
3350 * @param string $which
3353 public function parse_sitevar($which)
3359 echo $CONF['IndexURL'];
3362 echo $CONF['SiteName'];
3365 echo $CONF['AdminEmail'];
3368 echo $CONF['AdminURL'];
3374 * AdminActions::parse_charset()
3375 * Parse skinvar charset
3380 public function parse_charset()
3382 echo i18n::get_current_charset();
3387 * AdminActions::parse_getblogsetting()
3388 * Parse skinvar getblogsetting
3390 public function parse_getblogsetting($which)
3392 global $blog, $manager;
3398 elseif ( $bid = intRequestVar('blogid') )
3400 $b = $manager->getBlog($bid);
3410 return Entity::hsc($b->getID());
3413 return Entity::hsc($b->getURL());
3416 return Entity::hsc($b->getName());
3419 return Entity::hsc($b->getDescription());
3422 return Entity::hsc($b->getShortName());
3424 case 'notifyaddress':
3425 return Entity::hsc($b->getNotifyAddress());
3428 return Entity::hsc($b->getMaxComments());
3431 return Entity::hsc($b->getUpdateFile());
3434 return Entity::hsc($b->getTimeOffset());
3441 * AdminActions::parse_geteditpluginfo()
3442 * Parse skinvar geteditpluginfo
3444 * @param string $type name of setting for edit plugin info
3447 public function parse_geteditpluginfo($type)
3449 $pid = intRequestVar('plugid');
3456 return Entity::hsc(getPluginNameFromPid($pid));
3463 * AdminActions::parse_getmember()
3464 * Parse skinvar getmember
3465 * (includes a member info thingie)
3467 * @param string $what name of setting for member
3470 public function parse_getmember($what)
3472 global $memberinfo, $member;
3473 // 1. only allow the member-details-page specific variables on member pages
3474 if ( $this->skintype == 'member' )
3479 return Entity::hsc($memberinfo->getDisplayName());
3482 return Entity::hsc($memberinfo->getRealName());
3485 return Entity::hsc($memberinfo->getNotes());
3488 return Entity::hsc($memberinfo->getURL());
3491 return Entity::hsc($memberinfo->getEmail());
3494 return Entity::hsc($memberinfo->getID());
3498 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3499 if ( $member->isLoggedIn() )
3504 return $member->getDisplayName();
3506 case 'yourrealname':
3507 return $member->getRealName();
3510 return $member->getNotes();
3513 return $member->getURL();
3516 return $member->getEmail();
3519 return $member->getID();
3527 * AdminActions::parse_headmessage()
3528 * Parse skinvar headmessage
3533 public function parse_headmessage()
3535 if ( !empty(Admin::$headMess) )
3537 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3543 * AdminActions::parse_helplink()
3544 * Parse skinvar helplink
3546 * @param string $topic name of topic for help
3549 public function parse_helplink($topic = '')
3551 if ( !empty($topic) )
3559 * AdminActions::parse_helpplugname()
3560 * Parse skinvar helpplugname
3565 public function parse_helpplugname()
3567 $plugid = intGetVar('plugid');
3568 Entity::hsc(getPluginNameFromPid($plugid));
3573 * AdminActions::parse_ilistaddnew()
3574 * Parse skinvar ilistaddnew
3579 public function parse_ilistaddnew()
3581 $blogid = intRequestVar('blogid');
3582 if ( intPostVar('start') == 0 )
3584 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3590 * AdminActions::parse_importskininfo()
3591 * Parse skinvar importskininfo
3593 * @param string $type name of information for imported skin
3596 public function parse_importskininfo($type)
3601 echo Entity::hsc(requestVar('skininfo'));
3604 $dataArr = requestArray('skinnames');
3605 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3608 $dataArr = requestArray('tpltnames');
3609 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3612 $dataArr = requestArray('skinclashes');
3613 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3616 $dataArr = requestArray('tpltclashes');
3617 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3620 echo Entity::hsc(requestVar('skinfile'));
3623 echo Entity::hsc(requestVar('mode'));
3630 * AdminActions::parse_inputyesno()
3631 * Parse skinvar inputyesno
3633 * some init stuff for all forms
3638 public function parse_init()
3643 if ( requestVar('action') == 'itemedit' )
3645 $itemid = intRequestVar('itemid');
3646 $item =& $manager->getItem($itemid, 1, 1);
3648 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3649 if ( $item && $blog->convertBreaks() )
3651 $item['body'] = removeBreaks($item['body']);
3652 $item['more'] = removeBreaks($item['more']);
3655 $authorid = $contents['authorid'];
3657 elseif ( requestVar('action') == 'createitem' )
3659 $blogid = intRequestVar('blogid');
3660 $blog =& $manager->getBlog($blogid);
3663 $blog->insertJavaScriptInfo($authorid);
3668 * AdminActions::parse_inputyesno()
3669 * Parse skinvar inputyesno
3671 * @param string $name
3672 * @param string $checkedval
3673 * @param string $tabindex
3674 * @param string $value1
3675 * @param string $value2
3676 * @param string $yesval
3677 * @param string $noval
3678 * @param string $isAdmin
3679 * @param string $templateName
3682 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3684 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3689 * AdminActions::parse_insertpluginfo()
3690 * Parse templatevar insertpluginfo
3692 public function parse_insertpluginfo($type)
3694 $option = Admin::$aOptions;
3698 return $option['pid'];
3701 return Entity::hsc($option['pfile']);
3708 * AdminActions::parse_insertpluginoptions()
3709 * Parse skinvar insertpluginoptions
3711 * @param string $templateName name of template
3714 public function parse_insertpluginoptions($templateName = '')
3716 $options = Admin::getAdminaOption();
3717 $template = array();
3718 $templats = array();
3720 if ( $templateName )
3722 $templates = Template::read($templateName);
3724 if ( !array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) || empty($templates['INSERT_PLUGOPTION_TITLE']) )
3726 $template['title'] = "<tr>"
3727 . "<th colspan=\"2\"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th>"
3732 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3734 if ( !array_key_exists('INSERT_PLUGOPTION_BODY', $templates) || empty($templates['INSERT_PLUGOPTION_BODY']) )
3736 $template['body'] = "<tr>"
3737 . "<%listplugplugoptionrow%>"
3742 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3747 include_libs('ACTIONS.php');
3748 $handler = new Actions($this->skintype);
3749 $parser = new PARSER($handler);
3751 foreach ( $options as $option )
3755 if ( $prevPid != $option['pid'] )
3757 $prevPid = $option['pid'];
3758 $parser->parse($template['title']);
3761 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3763 if ( @$meta['access'] != 'hidden' )
3765 $parsed = $parser->parse($template['body']);
3772 * AdminActions::parse_insplugoptcontent()
3773 * Parse skinvar insplugoptcontent
3778 public function parse_insplugoptcontent()
3780 $option = Admin::$aOption;
3782 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3783 if ( array_key_exists('access', $meta) && $meta['access'] != 'hidden' )
3786 listplug_plugOptionRow($option);
3793 * AdminActions::parse_iprangeinput()
3794 * Parse skinvar iprangeinput
3799 public function parse_iprangeinput()
3801 if ( requestVar('ip') )
3803 $iprangeVal = Entity::hsc(requestVar('ip'));
3804 echo "<input name=\"iprange\" type=\"radio\" value=\"{$iprangeVal}\" checked=\"checked\" id=\"ip_fixed\" />\n";
3805 echo "<label for=\"ip_fixed\">{$iprangeVal}</label><br />\n";
3806 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3807 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3808 echo "<input name=\"customiprange\" value=\"{$iprangeVal}\" maxlength=\"15\" size=\"15\" />\n";
3812 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3813 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3819 * AdminActions::parse_itemnavlist()
3820 * Parse skinvar itemnavlist
3825 public function parse_itemnavlist()
3827 global $CONF, $manager, $member;
3829 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3830 . " FROM %s, %s, %s, %s"
3831 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3833 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3835 if ( $this->skintype == 'itemlist' )
3838 if ( array_key_exists('blogid', $_REQUEST) )
3840 $blogid = intRequestVar('blogid');
3842 else if ( array_key_exists('itemid', $_REQUEST) )
3844 $itemid = intRequestVar('itemid');
3845 $item = &$manager->getItem($itemid, 1, 1);
3846 $blogid = (integer) $item['blogid'];
3848 $blog =& $manager->getBlog($blogid);
3850 $query .= " AND iblog={$blogid}";
3851 $template['now'] = $blog->getCorrectTime(time());
3853 // non-blog-admins can only edit/delete their own items
3854 if ( !$member->blogAdminRights($blogid) )
3856 $query .= ' AND iauthor = ' . $member->getID();
3859 elseif ( $this->skintype == 'browseownitems' )
3861 $query .= ' AND iauthor = ' . $member->getID();
3863 $template['now'] = time();
3866 // search through items
3867 $search = postVar('search');
3869 if ( !empty($search) )
3871 $query .= ' AND ((ititle LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3872 . ' OR (ibody LIKE ' . DB::quoteValue('%'.$search.'%') . ') '
3873 . ' OR (imore LIKE ' . DB::quoteValue('%'.$search.'%') . '))';
3876 if ( postVar('start') )
3878 $start = intPostVar('start');
3885 // amount of items to show
3886 if ( postVar('amount') )
3888 $amount = intPostVar('amount');
3892 $amount = (integer) $CONF['DefaultListSize'];
3899 $query .= ' ORDER BY itime DESC'
3900 . " LIMIT {$start},{$amount}";
3902 $template['content'] = 'itemlist';
3904 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3905 $navList->showBatchList('item', $query, 'table', $template);
3910 * AdminActions::parse_itemoptions()
3911 * Parse skinvar itemoptions
3912 * Adds the itemOptions of a plugin to a page
3915 public function parse_itemoptions()
3917 $this->parse_pluginoptions('item');
3922 * AdminActions::parse_itemoptions()
3924 * date change on edit item
3926 * Parse skinvar itemoptions
3927 * Adds the itemOptions of a plugin to a page
3930 public function parse_itemtime($what)
3935 $itemid = intRequestVar('itemid');
3936 $item =& $manager->getItem($itemid, 1, 1);
3938 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3940 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3942 $item['body'] = removeBreaks($item['body']);
3943 $item['more'] = removeBreaks($item['more']);
3946 $contents = array();
3947 if ( requestVar('action') == 'itemedit' )
3951 elseif ( requestVar('action') == 'createitem' )
3954 'contents' => &$contents,
3955 'blog' => &$this->blog
3957 $manager->notify('PreAddItemForm', $data);
3959 $itemtime = getdate($contents['timestamp']);
3960 echo $itemtime[$what];
3965 * AdminActions::parse_jstoolbaroptions()
3966 * Parse skinvar jstoolbaroptions
3971 public function parse_jstoolbaroptions()
3975 _SETTINGS_JSTOOLBAR_NONE,
3976 _SETTINGS_JSTOOLBAR_SIMPLE,
3977 _SETTINGS_JSTOOLBAR_FULL
3981 foreach ( $options as $option )
3983 $text = "<option value=\"%d\"%s>%s</option>\n";
3984 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3985 echo sprintf($text, $i, $extra, $option);
3991 * AdminActions::parse_localeselectoptions()
3992 * Parse skinvar localeselectoptions
3997 public function parse_localeselectoptions()
3999 $locales = i18n::get_available_locale_list();
4001 $memid = intRequestVar('memberid');
4004 $mem = MEMBER::createFromID($memid);
4005 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
4007 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
4011 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
4016 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
4018 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
4022 echo "<option value=\"\">en_Latn_US</option>\n";
4025 foreach ( $locales as $locale )
4027 if ( $locale == 'en_Latn_US' )
4033 if ( $locale == $mem->getLocale() )
4035 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4039 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4044 if ( $locale == i18n::get_current_locale() )
4046 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4050 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4058 * AdminActions::parse_listplugplugoptionrow()
4059 * Parse templatevar listplugplugoptionrow
4061 * @param string $templateName name of template
4064 public function parse_listplugplugoptionrow($templateName = '')
4066 echo listplug_plugOptionRow(Admin::$aOptions, $templateName);
4071 * AdminActions::parse_mediadirwarning()
4072 * Parse skinvar mediadirwarning
4077 public function parse_mediadirwarning()
4080 if ( !is_dir($DIR_MEDIA) )
4082 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4084 if ( !is_readable($DIR_MEDIA) )
4086 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4088 if ( !is_writeable($DIR_MEDIA) )
4090 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4096 * AdminActions::parse_movedistselect()
4097 * Parse skinvar movedistselect
4099 public function parse_movedistselect()
4101 $actionType = requestVar('action');
4102 switch ( $actionType )
4105 Admin::selectBlogCategory('destcatid');
4107 case 'batchcategory':
4108 Admin::selectBlog('destblogid');
4111 if ( $this->skintype == 'itemmove' )
4113 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
4114 $query = sprintf($query, sql_table('item'), intRequestVar('itemid'));
4115 $catid = DB::getValue(sprintf($query, intRequestVar('itemid')));
4116 Admin::selectBlogCategory('catid', $catid, 10, 1);
4124 * AdminActions::parse_moveitemid()
4125 * Parse skinvar moveitemid
4130 public function parse_moveitemid()
4132 echo intRequestVar('itemid');
4137 * AdminActions::parse_newestcompare()
4138 * Parse skinvar newestcompare
4143 public function parse_newestcompare()
4147 $newestVersion = getLatestVersion();
4148 $newestCompare = str_replace('/', '.', $newestVersion);
4149 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4151 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4153 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4154 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4160 * AdminActions::parse_newmemberselect()
4161 * Parse skinvar newmemberselect
4163 * @param string $templateName name of template to use
4166 public function parse_newmemberselect($templateName = '')
4168 $blogid = intRequestVar('blogid');
4170 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4171 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4172 $res = DB::getResult($query);
4175 foreach ( $res as $row )
4177 $tmem[] = intval($row['tmember']);
4180 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4181 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4183 $template['name'] = 'memberid';
4184 $template['tabindex'] = 10000;
4185 Showlist($query, 'select', $template, $templateName);
4190 * AdminActions::parse_newpluginlist()
4191 * Parse skinvar newpluginlist
4196 public function parse_newpluginlist()
4198 $candidates = $this->newPlugCandidates;
4199 foreach ( $candidates as $name )
4201 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4207 * AdminActions::parse_outputspecialdirs()
4208 * Parse skinvar outputspecialdirs
4210 * @param string $type type of setting for directory
4213 public function parse_outputspecialdirs($type)
4215 global $DIR_MEDIA, $DIR_NUCLEUS;
4220 echo Entity::hsc($DIR_NUCLEUS);
4223 echo Entity::hsc($DIR_MEDIA);
4230 * AdminActions::parse_passrequestvars()
4231 * Parse skinvar passrequestvars
4236 public function parse_passrequestvars()
4238 $passvar = Admin::getAdminpassvar();
4239 $oldaction = postVar('oldaction');
4241 if ( ($oldaction != 'logout')
4242 && ($oldaction != 'login')
4244 && !postVar('customaction') )
4252 * AdminActions::parse_pluginextras()
4253 * Parse skinvar pluginextras
4255 * @param string $type type of plugin context
4258 public function parse_pluginextras($type = 'global')
4264 $id = intRequestVar('memberid');
4265 $mem = MEMBER::createFromID($id);
4266 $manager->notify('MemberSettingsFormExtras', array('member' => &$mem));
4269 $id = intRequestVar('blogid');
4270 $blg = $manager->getBlog($id);
4271 $manager->notify('BlogSettingsFormExtras', array('member' => &$blg));
4275 'GeneralSettingsFormExtras',
4285 * AdminActions::parse_pluginhelp()
4286 * Parse skinvar pluginhelp
4291 public function parse_pluginhelp()
4293 global $manager, $DIR_PLUGINS;
4295 $plugid = intGetVar('plugid');
4296 $plugName = getPluginNameFromPid($plugid);
4297 $plug =& $manager->getPlugin($plugName);
4299 if ( $plug->supportsFeature('HelpPage') > 0 )
4301 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4302 if ( @file_exists($helpfile . 'php') )
4304 @include($helpfile . 'php');
4307 elseif ( @file_exists($helpfile . 'html') )
4309 @include($helpfile . 'html');
4313 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4314 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4319 * AdminActions::parse_pluginlistlist()
4320 * Parse skinvar pluginlistlist
4322 * @param string $templateName name of template to use
4325 public function parse_pluginlistlist($templateName = '')
4327 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4328 $query = sprintf($query, sql_table('plugin'));
4330 $template['content'] = 'pluginlist';
4331 $template['tabindex'] = 10;
4333 Showlist($query, 'table', $template, $templateName);
4339 * AdminActions::parse_pluginoptions()
4340 * Parse skinvar pluginoptions
4342 * @param string $type type of plugin option
4345 public function parse_pluginoptions($type = 'global')
4352 $id = intRequestVar('memberid');
4355 $id = intRequestVar('blogid');
4358 $id = intRequestVar('catid');
4364 Admin::insertPluginOptions($type, $id);
4369 * AdminActions::parse_qmenuaddselect()
4370 * Parse skinvar qmanuaddselect
4372 * @param string $templateName name of template to use
4375 public function parse_qmenuaddselect($templateName = '')
4378 $showAll = requestVar('showall');
4379 if ( $member->isAdmin() && ($showAll == 'yes') )
4381 // Super-Admins have access to all blogs! (no add item support though)
4382 $query = 'SELECT bnumber as value, bname as text'
4383 . ' FROM ' . sql_table('blog')
4384 . ' ORDER BY bname';
4388 $query = 'SELECT bnumber as value, bname as text'
4389 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4390 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4391 . ' ORDER BY bname';
4394 $template['name'] = 'blogid';
4395 $template['tabindex'] = 15000;
4396 $template['extra'] = _QMENU_ADD_SELECT;
4397 $template['selected'] = -1;
4398 $template['shorten'] = 10;
4399 $template['shortenel'] = '';
4400 $template['javascript'] = 'onchange="return form.submit()"';
4402 Showlist($query, 'select', $template, $templateName);
4408 * AdminActions::parse_quickmenu()
4409 * Parse skinvar quickmenu
4411 * @param string $templateName name of template to use
4414 public function parse_quickmenu($templateName = '')
4417 $templates = array();
4418 $template = array();
4419 if ( !empty($templateName) )
4421 $templates = Template::read($templateName);
4423 $pluginExtras = array();
4427 'options' => &$pluginExtras
4430 if ( count($pluginExtras) > 0 )
4432 if ( !array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4434 $template['title'] = "<h2><%text(_QMENU_PLUGINS)%></h2>\n";
4438 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4440 if ( !array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4442 $template['head'] = "<ul>\n";
4446 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4448 if ( !array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) && empty($templates['PLUGIN_QUICKMENU_BODY']) )
4450 $template['body'] = "<li><a href=\"<%plugadminurl%>\" title=\"<%plugadmintooltip%>\"><%plugadmintitle%></a></li>\n";
4454 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4456 if ( !array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4458 $template['foot'] = "</ul>\n";
4462 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4465 $handler = new Actions($this->skintype);
4466 $parser = new PARSER($handler);
4468 $parser->parse($template['title']);
4469 echo $template['head'];
4470 foreach ( $pluginExtras as $aInfo )
4473 'plugadminurl' => Entity::hsc($aInfo['url']),
4474 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4475 'plugadmintitle' => Entity::hsc($aInfo['title']),
4477 echo Template::fill($template['body'], $data);
4479 echo $template['foot'];
4485 * AdminActions::parse_requestblogid()
4486 * Parse skinvar requestblogid
4491 public function parse_requestblogid()
4493 echo intRequestVar('blogid');
4498 * AdminActions::parse_requestiprange()
4499 * Parse skinvar requestiprange
4504 public function parse_requestiprange()
4506 if ( requestVar('iprange') )
4508 echo Entity::hsc(requestVar('iprange'));
4510 elseif ( requestVar('ip') )
4512 echo Entity::hsc(requestVar('ip'));
4518 * AdminActions::parse_selectlocaladminskinfiles()
4519 * Parse skinvar selectlocaladminskinfiles
4524 public function parse_selectlocaladminskinfiles()
4526 global $DIR_SKINS, $manager;
4528 $adminskindir = $DIR_SKINS . 'admin/';
4529 $candidates = SkinImport::searchForCandidates($adminskindir);
4531 foreach ( $candidates as $skinname => $skinfile )
4533 $html = Entity::hsc($skinfile);
4534 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4541 * AdminActions::parse_selectlocalskinfiles()
4542 * Parse skinvar selectlocalskinfiles
4547 public function parse_selectlocalskinfiles()
4551 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4553 foreach ( $candidates as $skinname => $skinfile )
4555 $html = Entity::hsc($skinfile);
4556 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4563 * AdminActions::parse_skineditallowedlist()
4564 * Parse skinvar skineditallowedlist
4566 * @param string $type type of skin
4567 * @param string $templateName name of template
4570 public function parse_skineditallowedlist($type, $templateName = '')
4575 $query = "SELECT bshortname, bname FROM %s;";
4577 'content' => 'shortblognames'
4579 $query = sprintf($query, sql_table('blog'));
4580 Showlist($query, 'table', $show, $templateName);
4583 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%';";
4585 'content' => 'shortnames'
4587 $query = sprintf($query, sql_table('template_desc'));
4588 Showlist($query, 'table', $show, $templateName);
4595 * AdminActions::parse_skinielist()
4596 * Parse skinvar skinielist
4598 * @param string $type type of skin
4599 * @param string $templateName name of template to use
4602 public function parse_skinielist($type, $templateName = '')
4604 $templates = array();
4605 if ( $templateName )
4607 $templates = Template::read($templateName);
4609 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4611 $template = $templates['SKINIE_EXPORT_LIST'];
4616 . "<input type=\"checkbox\" name=\"<%typeid%>\" id=\"<%expid%>\" />\n"
4617 . "<label for=\"<%expid%>\"><%expname%></label>\n"
4619 . "<td><%expdesc%></td>\n"
4626 $res = DB::getResult('SELECT * FROM ' . sql_table('skin_desc'));
4627 foreach ( $res as $row )
4630 'typeid' => 'skin[' . $row['sdnumber'] . ']',
4631 'expid' => 'skinexp' . $row['sdnumber'],
4632 'expname' => Entity::hsc($row['sdname']),
4633 'expdesc' => Entity::hsc($row['sddesc'])
4635 echo Template::fill($template, $data);
4639 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%%';");
4640 foreach ( $res as $row )
4643 'typeid' => 'template[' . $row['tdnumber'] . ']',
4644 'expid' => 'templateexp' . $row['tdnumber'],
4645 'expname' => Entity::hsc($row['tdname']),
4646 'expdesc' => Entity::hsc($row['tddesc'])
4648 echo Template::fill($template, $data);
4656 * AdminActions::parse_skinoverview()
4657 * Parse skinvar skinoverview
4659 * @param string $templateName name of template to use
4662 public function parse_skinoverview($templateName = '')
4665 $query = "SELECT * FROM %s WHERE sdname NOT LIKE 'admin/%%';";
4666 $query = sprintf($query, sql_table('skin_desc'));
4668 $template['content'] = 'skinlist';
4669 $template['tabindex'] = 10;
4671 Showlist($query, 'table', $template, $templateName);
4676 * AdminActions::parse_skintypehelp()
4677 * Check editing skintypehelp
4682 public function parse_skintypehelp()
4684 $nowSkinType = strtolower(trim(requestVar('type')));
4686 /* TODO: use Skin class */
4687 $regularType = array(
4698 if ( in_array($nowSkinType, $regularType) )
4700 help('skinpart' . $nowSkinType);
4704 help('skinpartspecial');
4710 * AdminActions::parse_specialskinlist()
4711 * Parse skinvar specialskinlist
4713 * @param string $templateName name of template to use
4716 public function parse_specialskinlist($templateName = '')
4718 $templates = array();
4719 if ( $templateName )
4721 $templates = Template::read($templateName);
4724 /* TODO: use Skin class */
4735 $skinid = intRequestVar('skinid');
4736 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4737 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4739 $res = DB::getResult($query);
4740 if ( $res && $res->rowCount() > 0 )
4743 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4745 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4749 $template['head'] = "<ul>\n";
4751 echo Template::fill($template['head'], $data);
4752 if ( !array_key_exists('SPECIALSKINLIST_BODY', $templates) || empty($templates['SPECIALSKINLIST_BODY']) )
4754 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4755 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4756 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4760 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4764 foreach ( $res as $row )
4767 'tabindex' => $tabstart++,
4768 'skinid' => $skinid,
4769 'skintype' => Entity::hsc(strtolower($row['stype']))
4771 echo Template::fill($template['body'], $data);
4774 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4776 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4780 $template['foot'] = "</ul>\n";
4782 echo Template::fill($template['foot'], $data);
4788 * AdminActions::parse_sprinttext()
4791 * @param string $which
4792 * @param string $val
4795 public function parse_sprinttext($which, $val)
4797 if ( !defined($which) )
4803 $base = constant($which);
4806 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4808 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4810 $met = 'parse_' . $matchies[0];
4814 $arg = trim($args[0], '()');
4815 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4818 if ( method_exists($this, $met) )
4820 $value = call_user_func(array(&$this, $met), $arg);
4824 if ( !isset($value) || empty($value) )
4828 echo sprintf($base, $value);
4833 * AdminActions::parse_systemsettings()
4834 * Parse skinvar systemsettings
4836 * @param string $type type of settings for system
4837 * @param string $templateName name of template to use
4840 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4842 global $member, $CONF, $nucleus;
4844 $member->isAdmin() or Admin::disallow();
4846 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4847 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4854 case 'sqlserverinfo':
4855 echo DB::getAttribute(PDO::ATTR_SERVER_VERSION);
4857 case 'sqlclientinfo':
4858 echo DB::getAttribute(PDO::ATTR_CLIENT_VERSION);
4860 case 'magicquotesgpc':
4861 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4863 case 'magicquotesruntime':
4864 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4866 case 'registerglobals':
4867 echo ini_get('register_globals') ? 'On' : 'Off';
4870 $templates = array();
4871 if ( $templateName )
4873 $templates = Template::read($templateName);
4875 if ( !array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) || empty($templates['SYSTEMINFO_GDSETTINGS']) )
4877 $template = "<tr>\n"
4878 . "<td><%key%></td>\n"
4879 . "<td><%value%></td>\n"
4884 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4887 $gdinfo = gd_info();
4889 foreach ( $gdinfo as $key => $value )
4891 if ( is_bool($value) )
4893 $value = $value ? $enable : $disable;
4897 $value = Entity::hsc($value);
4903 echo Template::fill($template, $data);
4908 phpinfo(INFO_MODULES);
4909 $im = ob_get_contents();
4911 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4913 case 'nucleusversion':
4914 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4916 case 'nucleuspatchlevel':
4917 echo getNucleusPatchLevel();
4923 echo $CONF['ItemURL'];
4925 case 'alertonheaderssent':
4926 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4928 case 'nucleuscodename':
4929 if ( $nucleus['codename'] != '' )
4931 echo ' "' . $nucleus['codename'] . '"';
4934 case 'versioncheckurl':
4935 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4942 * AdminActions::parse_templateoverview()
4943 * Parse skinvar templateoverview
4945 * @param string $templateName name of template to use
4948 public function parse_templateoverview($templateName = '')
4950 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4951 $query = sprintf($query, sql_table('template_desc'));
4953 $template['content'] = 'templatelist';
4954 $template['tabindex'] = 10;
4956 Showlist($query, 'table', $template, $templateName);
4962 * AdminActions::parse_ticket()
4968 public function parse_ticket()
4971 $manager->addTicketHidden();
4976 * AdminActions::parse_versioncheckurl()
4977 * Parse skinvar versioncheckurl
4982 public function parse_versioncheckurl()
4984 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4989 * AdminActions::parse_yrbloglist()
4990 * Parse skinvar yrbloglist
4992 * @param string $templateName name of template to use
4995 public function parse_yrbloglist($templateName = '')
4998 $showAll = requestVar('showall');
5000 if ( $member->isAdmin() && ($showAll == 'yes') )
5002 // Super-Admins have access to all blogs! (no add item support though)
5003 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
5005 . " ORDER BY bnumber;";
5006 $query = sprintf($query, sql_table('blog'));
5010 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
5012 . " WHERE tblog=bnumber and tmember=%d"
5013 . " ORDER BY bnumber;";
5014 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
5017 $template['content'] = 'bloglist';
5018 $template['superadmin'] = $member->isAdmin();
5020 $amount = Showlist($query, 'table', $template, $templateName);
5022 if ( ($showAll != 'yes') && ($member->isAdmin()) )
5024 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
5026 $total = DB::getValue($query);
5027 if ( $total > $amount )
5029 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
5035 echo _OVERVIEW_NOBLOGS;
5037 elseif( $amount != 0 )
5039 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
5041 $query = "SELECT ititle, inumber, bshortname"
5043 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1;';
5044 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
5046 $template['content'] = 'draftlist';
5048 $amountdrafts = Showlist($query, 'table', $template, $templateName);
5049 if ( $amountdrafts == 0 )
5051 echo _OVERVIEW_NODRAFTS;
5058 * AdminActions::checkCondition()
5059 * Checks conditions for if statements
5061 * @param string $field type of <%if%>
5062 * @param string $name property of field
5063 * @param string $value value of property
5064 * @return boolean condition
5066 protected function checkCondition($field, $name='', $value = '')
5068 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
5079 $blog =& $manager->getBlog($blogid);
5083 $blogid = getBlogIDFromCatID($catid);
5085 $blog =& $manager->getBlog($blogid);
5087 elseif ( intRequestVar('catid') )
5089 $catid = intRequestVar('catid');
5090 $blogid = getBlogIDFromCatID($catid);
5092 $blog =& $manager->getBlog($blogid);
5099 $condition = ($blog && $this->ifCategory($name, $value));
5102 $condition = ($blog && ($blog->getSetting($name) == $value));
5105 $condition = $member->isLoggedIn();
5108 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5111 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5114 $condition = $member->isLoggedIn() && $member->isAdmin();
5116 case 'allowloginedit':
5117 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5120 $condition = ($itemidnext != '');
5123 $condition = ($itemidprev != '');
5125 case 'archiveprevexists':
5126 $condition = ($archiveprevexists == true);
5128 case 'archivenextexists':
5129 $condition = ($archivenextexists == true);
5132 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5135 $condition = $this->ifHasPlugin($name, $value);
5138 $condition = (Admin::getAdminAction() == $name);
5140 case 'adminoldaction':
5141 $condition = (Admin::getAdminAction() == $name);
5143 case 'addresschange':
5144 $condition = ($this->ifAddresscange());
5146 case 'bechangepass':
5147 $condition = ($this->beChangePassword());
5149 case 'skincandidates':
5150 $condition = ($this->ifSkincandidates());
5153 $condition = requestVar('nameclashes');
5155 case 'existsnewplugin':
5156 $condition = ($this->existsNewPlugin());
5159 $condition = (boolean) ($member->getAutosave() == $value);
5162 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5169 * Actions::_ifHasPlugin()
5170 * hasplugin,PlugName
5171 * -> checks if plugin exists
5172 * hasplugin,PlugName,OptionName
5173 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5174 * hasplugin,PlugName,OptionName=value
5175 * -> checks if the option OptionName from plugin PlugName is set to value
5177 * @param string $name name of plugin
5178 * @param string $value
5181 private function ifHasPlugin($name, $value)
5185 // (pluginInstalled method won't write a message in the actionlog on failure)
5186 if ( $manager->pluginInstalled("NP_{$name}") )
5188 $plugin =& $manager->getPlugin("NP_{$name}");
5189 if ( $plugin != NULL )
5197 list($name2, $value2) = preg_split('#=#', $value, 2);
5198 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5202 else if ( $plugin->getOption($name2) == $value2 )
5213 * Actions::beChangePassword()
5218 private function beChangePassword()
5220 return intRequestVar('bNeedsPasswordChange');
5224 * Actions::ifSkincandidates()
5225 * Checks if a plugin exists and call its doIf function
5231 private function ifSkincandidates()
5234 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5235 return (count($candidates) > 0);
5239 * Actions::ifPlugin()
5240 * Checks if a plugin exists and call its doIf function
5242 * @param string $name name of plugin
5243 * @param string $key
5244 * @param string $value
5247 private function ifPlugin($name, $key = '', $value = '')
5251 $plugin =& $manager->getPlugin("NP_{$name}");
5257 $params = func_get_args();
5258 array_shift($params);
5260 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5264 * AdminActions::ifCategory()
5265 * Different checks for a category
5267 * @param string $key key for information of category
5268 * @param string $value value for information of category
5271 private function ifCategory($key = '', $value='')
5273 global $blog, $catid;
5275 // when no parameter is defined, just check if a category is selected
5276 if (($key != 'catname' && $key != 'catid') || ($value == ''))
5278 return $blog->isValidCategory($catid);
5281 // check category name
5282 if ( $key == 'catname' )
5284 $value = $blog->getCategoryIdFromName($value);
5285 if ($value == $catid)
5287 return $blog->isValidCategory($catid);
5291 // check category id
5292 if (($key == 'catid') && ($value == $catid))
5294 return $blog->isValidCategory($catid);
5301 * AdminActions::ifOnTeam()
5302 * Checks if a member is on the team of a blog and return his rights
5304 * @param string $blogName name of weblog
5307 private function ifOnTeam($blogName = '')
5309 global $blog, $member, $manager;
5311 // when no blog found
5312 if ( ($blogName == '') && !is_object($blog) )
5317 // explicit blog selection
5318 if ($blogName != '')
5320 $blogid = getBlogIDFromName($blogName);
5323 if (($blogName == '') || !$manager->existsBlogID($blogid))
5326 $blogid = $blog->getID();
5328 return $member->teamRights($blogid);
5332 * AdminActions::ifAdmin()
5333 * Checks if a member is admin of a blog
5335 * @param string $blogName name of weblog
5338 private function ifAdmin($blogName = '')
5340 global $blog, $member, $manager;
5342 // when no blog found
5343 if (($blogName == '') && (!is_object($blog)))
5348 // explicit blog selection
5349 if ($blogName != '')
5351 $blogid = getBlogIDFromName($blogName);
5354 if (($blogName == '') || !$manager->existsBlogID($blogid))
5357 $blogid = $blog->getID();
5360 return $member->isBlogAdmin($blogid);
5364 * AdminActions::ifAddresscange()
5365 * Check e-Mail address is changed
5370 private function ifAddresscange()
5372 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5377 $info = MEMBER::getActivationInfo($key);
5382 $mem = MEMBER::createFromId($info->vmember);
5387 if ( $info->vtype == 'addresschange' )
5395 * AdminActions::templateEditRow()
5398 * @param array $template
5399 * @param string $desc
5400 * @param string $name
5401 * @param string $help
5402 * @param integer $tabindex
5403 * @param boolean $big
5404 * @param array $tmplt
5407 private function templateEditRow(&$template, $desc, $name, $help = '', $tabindex = 0, $big = 0, $tplt = '')
5411 if ( !array_key_exists($name, $template) )
5413 $template[$name] = '';
5421 $tmplt = skinableTEMPLATE::read($tplt);
5425 'description' => $desc,
5426 'help' => empty($help) ? '' : helpHtml('template' . $help),
5429 'tabindex' => $tabindex,
5430 'rows' => $big ? 10 : 5,
5433 if ( !array_key_exists('TEMPLATE_EDIT_ROW_HEAD', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_HEAD']) )
5435 $base['head'] = "</tr>"
5437 . "<td><%description%><%help%></td>\n"
5438 . "<td id=\"td<%count%>\">\n"
5439 . "<textarea class=\"templateedit\" name=\"<%name%>\" tabindex=\"<%tabindex%>\" cols=\"50\" rows=\"<%rows%>\" id=\"textarea<%count%>\">\n";
5443 $base['head'] = $tmplt['TEMPLATE_EDIT_ROW_HEAD'];
5446 if ( !array_key_exists('TEMPLATE_EDIT_ROW_TAIL', $tmplt) || empty($tmplt['TEMPLATE_EDIT_ROW_TAIL']) )
5448 $base['tail'] = "</textarea>\n"
5453 $base['tail'] = $tmplt['TEMPLATE_EDIT_ROW_TAIL'];
5456 echo TEMPLATE::fill($base['head'], $data);
5457 echo ENTITY::hsc($template[$name]);
5458 echo TEMPLATE::fill($base['tail'], $data);
5466 * AdminActions::customHelp()
5467 * shows a link to custom help file
5470 * @param string $tplName
5471 * @param string $url
5472 * @param string $iconURL
5473 * @param string $alt
5474 * @param string $title
5478 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5480 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5484 * AdminActions::customHelp()
5485 * shows a link to custom help file
5488 * @param string $tplName
5489 * @param string $url
5490 * @param string $iconURL
5491 * @param string $alt
5492 * @param string $title
5496 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5500 $templates = array();
5504 $templates = Template::read($tplName);
5507 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ANCHOR', $templates) || empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) )
5509 $template = "<a href=\"<%helpurl%>#<%helptarget%>\" title=\"<%title%>\" <%onclick%>>\n";
5513 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5518 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5521 if ( empty($onclick) )
5523 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5525 elseif ( preg_match('#^onclick#', $onclick) )
5527 $onclick = $onclick;
5531 $onclick = 'onclick="' . $onclick . '"';
5536 'helptarget' => $id,
5537 'onclick' => $onclick,
5538 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5540 return Template::fill($template, $data);
5544 * AdminActions::customHelpHtml()
5547 * @param string $tplName
5548 * @param string $url
5549 * @param string $iconURL
5550 * @param string $alt
5551 * @param string $title
5552 * @param string $onclick
5553 * @return string anchor element with help uri
5555 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5559 $templates = array();
5563 $templates = Template::read($tplName);
5565 if ( !array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) || !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5567 $template = "<img src=\"<%iconurl%>\" <%width%><%height%>alt=\"<%alt%>\" title=\"<%title%>\" /></a>\n";
5571 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5574 if ( empty($iconURL) )
5576 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5579 if ( function_exists('getimagesize') )
5581 $size = getimagesize($iconURL);
5582 $width = 'width="' . $size[0] . '" ';
5583 $height = 'height="' . $size[1] . '" ';
5587 'iconurl' => $iconURL,
5589 'height' => $height,
5590 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5591 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5594 $icon = Template::fill($template, $data);
5595 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5597 return $help . $icon;
5601 * AdminActions::input_yesno
5604 * @param $checkedval
5611 * @param $templateName
5614 private function input_yesno($name,
5625 $templates = array();
5626 if ( $templateName )
5628 $templates = Template::read($templateName);
5631 if ( $name == 'admin' )
5633 if ( !array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) || empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5635 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5636 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5637 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5638 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5642 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5647 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5649 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5653 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5655 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5658 if ( !isset($template) )
5660 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5661 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5662 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5663 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5668 $id = Entity::hsc($name);
5669 $id = str_replace('[', '-', $id);
5670 $id = str_replace(']', '-', $id);
5671 $id1 = $id . Entity::hsc($value1);
5672 $id2 = $id . Entity::hsc($value2);
5674 'name' => Entity::hsc($name),
5675 'yesval' => Entity::hsc($value1),
5676 'noval' => Entity::hsc($value2),
5679 'yesvaltext' => $yesval,
5680 'novaltext' => $noval,
5681 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5682 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5683 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5688 return Template::fill($template, $dat);
5692 echo Template::fill($template, $dat);
5698 * AdminActions::existsNewPlugin()
5699 * Check exists new plugin
5702 * @return boolean exists or not
5704 private function existsNewPlugin()
5706 global $DIR_PLUGINS;
5708 $candidates = array();
5709 $files = scandir($DIR_PLUGINS);
5711 foreach ( $files as $file )
5713 if ( preg_match("#^NP_(.*)\.php$#", $file, $matches) )
5715 $name = $matches[1];
5716 $query = "SELECT * FROM %s WHERE pfile=%s;";
5717 $query = sprintf($query, sql_table('plugin'), DB::quoteValue("{NP_{$name}"));
5718 $res = DB::getResult($query);
5720 if ( $res->rowCount() == 0 )
5722 $candidates[] = $name;
5727 $this->newPlugCandidates = $candidates;
5728 return (count($candidates) > 0);