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
13 // an instance of parser class
19 /* NOTE: list of whole available action names for tags
28 'adminskineditallowedlist',
31 'adminskinselectoptions',
32 'adminspecialskinlist',
33 'admintemplateoverview',
34 'allowedadminskinactions',
57 'configsettingsyesno',
60 'defaultadminskintypes',
70 'editadmintemplateinfo',
76 'editplugoptionslist',
92 'insertpluginoptions',
97 'languageselectoptions',
98 'listplugplugoptionrow',
115 'selectlocaladminskinfiles',
116 'selectlocalskinfiles',
117 'skineditallowedlist',
134 * AdminActions::$default_actions
135 * list of whole action names with which this class can deal
137 static private $default_actions = array(
148 * AdminActions::$skin_type_friendly_names
149 * friendly name for wrapped page types
151 static private $default_skin_types = array(
152 'actionlog' => _ADM_SKPRT_ACTIONLOG,
153 'activate' => _ADM_SKPRT_ACTIVATE,
154 'activatesetpwd' => _ADM_SKPRT_ACTIVATESETPWD,
155 'addnewlog' => _ADM_SKPRT_ADDNEWLOG,
156 'adminerrorpage' => _ADM_SKPRT_ADMINERRORPAGE,
157 'adminskindelete' => _ADM_SKPRT_ADMINSKINDELETE,
158 'adminskinedit' => _ADM_SKPRT_ADMINSKINEDIT,
159 'adminskinedittype' => _ADM_SKPRT_ADMINSKINEDITTYPE,
160 'adminskiniedoimport' => _ADM_SKPRT_ADMINSKINIEDOIMPORT,
161 'adminskinieimport' => _ADM_SKPRT_ADMINSKINIEIMPORT,
162 'adminskinieoverview' => _ADM_SKPRT_ADMINSKINIEOVERVIEW,
163 'adminskinoverview' => _ADM_SKPRT_ADMINSKINOVERVIEW,
164 'adminskinremovetype' => _ADM_SKPRT_ADMINSKINREMOVETYPE,
165 'admintemplatedelete' => _ADM_SKPRT_ADMINTEMPLATEDELETE,
166 'admintemplateedit' => _ADM_SKPRT_ADMINTEMPLATEEDIT,
167 'admntemplateoverview' => _ADM_SKPRT_ADMINTEMPLATEOVERVIEW,
168 'backupoverview' => _ADM_SKPRT_BACKUPOVERVIEW,
169 'backuprestore' => _ADM_SKPRT_BACKUPRESTORE,
170 'banlist' => _ADM_SKPRT_BANLIST,
171 'banlistdelete' => _ADM_SKPRT_BANLISTDELETE,
172 'banlistdeleteconfirm' => _ADM_SKPRT_BANLISTDELETECONFIRM,
173 'banlistnew' => _ADM_SKPRT_BANLISTNEW,
174 'batchcategory' => _ADM_SKPRT_BATCHCATEGORY,
175 'batchcomment' => _ADM_SKPRT_BATCHCOMMENT,
176 'batchdelete' => _ADM_SKPRT_BATCHDELETE,
177 'batchitem' => _ADM_SKPRT_BATCHITEM,
178 'batchmember' => _ADM_SKPRT_BATCHMEMBER,
179 'batchmove' => _ADM_SKPRT_BATCHMOVE,
180 'batchmovecat' => _ADM_SKPRT_BATCHMOVECAT,
181 'batchteam' => _ADM_SKPRT_BATCHTEAM,
182 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
183 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX,
184 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
185 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
186 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
187 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
188 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
189 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
190 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
191 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
192 'createitem' => _ADM_SKPRT_CREATEITEM,
193 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
194 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
195 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
196 'insertpluginoptions' => _ADM_SKPRT_INSERTPLUGINO,
197 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
198 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
199 'itemedit' => _ADM_SKPRT_ITEMEDIT,
200 'itemlist' => _ADM_SKPRT_ITEMLIST,
201 'itemmove' => _ADM_SKPRT_ITEMMOVE,
202 'login' => FALSE, //missing
203 'manage' => _ADM_SKPRT_MANAGE,
204 'manageteam' => _ADM_SKPRT_MANAGETEAM,
205 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
206 'memberedit' => FALSE, //missing
207 'overview' => _ADM_SKPRT_OVERVIEW,
208 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
209 'pagehead' => _ADM_SKPRT_PAGEHEAD,
210 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
211 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
212 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
213 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
214 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
215 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
216 'skindelete' => _ADM_SKPRT_SKINDELETE,
217 'skinedit' => _ADM_SKPRT_SKINEDIT,
218 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
219 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
220 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
221 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
222 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
223 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
224 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
225 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
226 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
227 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
228 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
229 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
233 * AdminActions::getDefinedActions()
236 * @param string $type page type
237 * @return array allowed actions for the page type
239 static public function getDefinedActions($type = '')
241 $extra_actions = array();
246 $extra_actions = array(
251 $extra_actions = array(
256 case 'activatesetpwd':
257 $extra_actions = array(
261 $extra_actions = array(
267 case 'adminerrorpage':
268 $extra_actions = array(
271 case 'adminskindelete':
272 $extra_actions = array(
276 case 'adminskinedit':
277 $extra_actions = array(
279 'defaultadminskintypes',
280 'adminspecialskinlist',
283 case 'adminskinedittype':
284 $extra_actions = array(
287 'allowedadminskinactions',
288 'adminskineditallowedlist',
291 case 'adminskiniedoimport':
292 $extra_actions = array(
296 case 'adminskinieimport':
297 $extra_actions = array(
301 case 'adminskinieoverview':
302 $extra_actions = array(
303 'selectlocaladminskinfiles',
307 case 'adminskinoverview':
308 $extra_actions = array(
312 case 'adminskinremovetype':
313 $extra_actions = array(
317 case 'admintemplateedit':
318 $extra_actions = array(
319 'editadmintemplateinfo',
322 case 'admntemplateoverview':
323 $extra_actions = array(
324 'admintemplateoverview',
327 case 'backupoverview':
328 $extra_actions = array(
331 case 'backuprestore':
332 $extra_actions = array(
336 $extra_actions = array(
342 case 'banlistdelete':
343 $extra_actions = array(
348 case 'banlistdeleteconfirm':
349 $extra_actions = array(
350 'banlistdeletedlist',
355 $extra_actions = array(
361 case 'batchcategory':
362 $extra_actions = array(
368 $extra_actions = array(
374 $extra_actions = array(
380 $extra_actions = array(
386 $extra_actions = array(
392 $extra_actions = array(
401 $extra_actions = array(
410 $extra_actions = array(
416 case 'blogcommentlist':
417 $extra_actions = array(
423 case 'blogselectbox':
424 $extra_actions = array(
429 $extra_actions = array(
444 $extra_actions = array(
448 case 'browseowncomments':
449 $extra_actions = array(
453 case 'browseownitems':
454 $extra_actions = array(
458 case 'categorydelete':
459 $extra_actions = array(
465 $extra_actions = array(
471 case 'commentdelete':
472 $extra_actions = array(
477 $extra_actions = array(
482 $extra_actions = array(
493 $extra_actions = array(
499 $extra_actions = array(
504 case 'editmembersettings':
505 $extra_actions = array(
507 'languageselectoptions',
508 'adminskinselectoptions',
512 case 'insertpluginoptions':
513 $extra_actions = array(
514 'insertpluginoptions',
517 case 'itemcommentlist':
518 $extra_actions = array(
524 $extra_actions = array(
531 $extra_actions = array(
543 $extra_actions = array(
550 $extra_actions = array(
556 $extra_actions = array(
560 $extra_actions = array(
569 $extra_actions = array(
574 $extra_actions = array(
579 $extra_actions = array(
587 $extra_actions = array(
600 $extra_actions = array(
605 $extra_actions = array(
611 $extra_actions = array(
616 case 'pluginoptions':
617 $extra_actions = array(
619 'editplugoptionslist',
623 $extra_actions = array(
626 'configsettingsedit',
627 'languageselectoptions',
628 'configsettingsyesno',
636 $extra_actions = array(
641 $extra_actions = array(
646 $extra_actions = array(
652 $extra_actions = array(
655 'allowedskinactions',
656 'skineditallowedlist',
657 'skineditallowedlist',
660 case 'skiniedoimport':
661 $extra_actions = array(
666 $extra_actions = array(
670 case 'skinieoverview':
671 $extra_actions = array(
672 'selectlocalskinfiles',
677 $extra_actions = array(
681 case 'skinremovetype':
682 $extra_actions = array(
686 case 'systemoverview':
687 $extra_actions = array(
692 $extra_actions = array(
698 case 'templatedelete':
699 $extra_actions = array(
704 $extra_actions = array(
708 case 'templateoverview':
709 $extra_actions = array(
713 case 'usermanagement':
714 $extra_actions = array(
720 $extra_actions = array(
730 'selectlocaladminskinfiles',
738 $defined_actions = array_merge(self::$default_actions, $extra_actions);
740 return array_merge($defined_actions, parent::getDefinedActions());
744 * AdminActions::getDefaultSkinTypes()
748 * @return array list of friendly names for page actions
750 static public function getDefaultSkinTypes()
752 return self::$default_skin_types;
756 * AdminActions::getDefaultTypes()
760 * @return array list of friendly names for page actions
762 static public function getDefaultTypes()
764 return self::$default_skin_types;
768 * AdminActions::__construct()
769 * Constructor for a new Actions object
771 * @param string $type
774 public function __construct($type)
776 // call constructor of superclass first
777 parent::__construct();
778 $this->skintype = $type;
779 if ( !class_exists('Navlist') || !class_exists('Batch') )
782 include $DIR_LIBS . 'ENCAPSULATE.php';
788 * AdminActions::setSkin()
790 * @param object $skin an instance of Skin class
793 public function setSkin(&$skin)
795 $this->skin =& $skin;
800 * AdminActions::setParser()
803 * @param object $parser an instance of Parser class
806 public function setParser(&$parser)
808 $this->parser =& $parser;
813 * AdminActions::parse_actionloglist()
814 * Parse skinvar actionloglist
816 * @param string $templateName name of template to use
819 public function parse_actionloglist($templateName = '')
821 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
822 $query = sprintf($query, sql_table('actionlog'));
824 $template['content'] = 'actionlist';
825 $amount = showlist($query, 'table', $template, $templateName);
831 * AdminActions::parse_activationmessage()
832 * Parse skinvar activationmessage
834 * @param string $type type of message
835 * @param string $templateName name of template to use
838 public function parse_activationmessage($type, $templateName = '')
840 global $CONF, $manager;
844 if ( !empty($templateName))
846 $template = Template::read($templateName);
849 $key = postVar('ackey');
852 Admin::error(_ERROR_ACTIVATE);
855 $info = MEMBER::getActivationInfo($key);
858 Admin::error(_ERROR_ACTIVATE);
861 $mem = MEMBER::createFromId($info->vmember);
864 Admin::error(_ERROR_ACTIVATE);
866 switch ( $info->vtype )
869 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
871 $title = $template['ACTIVATE_FORGOT_TITLE'];
875 $title = _ACTIVATE_FORGOT_TITLE;
877 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
879 $text = $template['ACTIVATE_FORGOT_TEXT'];
883 $text = _ACTIVATE_FORGOT_TEXT;
887 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
889 $title = $template['ACTIVATE_REGISTER_TITLE'];
893 $title = _ACTIVATE_REGISTER_TITLE;
895 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
897 $text = $template['ACTIVATE_REGISTER_TEXT'];
901 $text = _ACTIVATE_REGISTER_TEXT;
904 case 'addresschange':
905 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
907 $title = $template['ACTIVATE_CHANGE_TITLE'];
911 $title = _ACTIVATE_CHANGE_TITLE;
913 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
915 $text = $template['ACTIVATE_CHANGE_TEXT'];
919 $text = _ACTIVATE_CHANGE_TEXT;
924 'memberName' => Entity::hsc($mem->getDisplayName()),
925 'realName' => Entity::hsc($mem->getRealName()),
930 echo Template::fill($title, $aVars);
933 echo Template::fill($text, $aVars);
936 echo Entity::hsc($key);
943 * AdminActions::parse_addtickettourl()
944 * Parse skinvar addtickettourl
946 * @param string $url URI for ticket
949 public function parse_addtickettourl($url)
952 $url = $manager->addTicketToUrl($url);
953 echo Entity::hsc($url);
958 * AdminActions::parse_adminbanlist()
959 * Parse skinvar adminbanlist
961 * @param string $templateName name of template to use
964 public function parse_adminbanlist($templateName = '')
966 $blogid = intRequestVar('blogid');
968 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
969 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
971 $template['content'] = 'banlist';
973 $amount = Showlist($query, 'table', $template, $templateName);
983 * AdminActions::parse_adminbatchaction()
984 * Parse skinvar adminbatchaction
989 public function parse_adminbatchaction()
991 echo Entity::hsc(requestVar('batchaction'));
996 * AdminActions::parse_adminbatchlist()
997 * Parse skinvar adminbatchlist
999 * @param string $templateName name of template to use
1002 public function parse_adminbatchlist($templateName = '')
1005 $templates = array();
1006 if ( !empty($templateName) )
1008 $templates = Template::read($templateName);
1010 if ( isset($templates['ADMIN_BATCHLIST']) || !empty($templates['ADMIN_BATCHLIST']) )
1012 $template = $templates['ADMIN_BATCHLIST'];
1016 $template = '<li><%text(_BATCH_EXECUTING)%>'
1017 . '<b><%adminbatchaction%></b>'
1018 . '<%batchlisttype%>'
1019 . '<b><%batchid%></b>...'
1020 . '<b><%batchlistmsg%></b>'
1024 $selected = requestIntArray('batch');
1025 $action = requestVar('batchaction');
1027 switch ( $this->skintype )
1030 $batchlisttype = _BATCH_ONITEM;
1031 $deleteaction = 'deleteOneItem';
1032 $moveaction = 'moveOneItem';
1033 $destid = intRequestVar('destcatid');
1035 case 'batchcomment':
1036 $batchlisttype = _BATCH_ONCOMMENT;
1037 $deleteaction = 'deleteOneComment';
1040 $batchlisttype = _BATCH_ONMEMBER;
1041 $deleteaction = 'deleteOneMember';
1042 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1043 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1044 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1045 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1048 $blogid = intRequestVar('blogid');
1049 $batchlisttype = _BATCH_ONTEAM;
1050 $deleteaction = 'deleteOneTeamMember';
1051 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1052 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1053 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1054 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1056 case 'batchcategory':
1057 $batchlisttype = _BATCH_ONCATEGORY;
1058 $deleteaction = 'deleteOneCategory';
1059 $moveaction = 'moveOneCategory';
1060 $destid = intRequestVar('destblogid');
1064 // walk over all selectedids and perform action
1065 foreach ( $selected as $selectedid )
1068 $selectedid = intval($selectedid);
1072 if ( $this->skintype != 'batchteam' )
1074 $error = Admin::$deleteaction($selectedid);
1078 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1082 $error = Admin::moveaction($selectedid, $destid);
1086 sql_query('UPDATE ' . $setadminsql . $selectedid);
1090 // there should always remain at least one super-admin
1091 $r = sql_query($unsetchksql);
1092 if ( sql_num_rows($r) < 2 )
1094 $error = $unseterrmsg;
1098 sql_query('UPDATE ' . $unsetupsql . $selectedid);
1102 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1105 'batchid' => $selectedid,
1106 'batchlisttype' => Entity::hsc($batchlisttype),
1107 'adminbatchaction' => Entity::hsc($action),
1108 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1110 $handler = new Actions('template', $template, new ADMIN);
1111 $parser = new Parser($handler);
1114 $parser->parse($template);
1115 $template = ob_get_contents();
1118 echo Template::fill($template, $data);
1124 * AdminActions::parse_adminbloglink()
1125 * Parse skinvar adminbloglink
1127 * @param string $templateName name of template to use
1130 public function parse_adminbloglink($templateName = '')
1133 $blogid = intRequestVar('blogid');
1134 $blog =& $manager->getBlog($blogid);
1135 $templates = array();
1137 if ( !empty($templateName) )
1139 $templates = Template::read($templateName);
1142 if ( isset($templates['ADMIN_BLOGLINK']) || !empty($templates['ADMIN_BLOGLINK']) )
1144 $template = $templates['ADMIN_BLOGLINK'];
1148 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1152 'url' => Entity::hsc($blog->getURL()),
1153 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1154 'blogname' => Entity::hsc($blog->getName())
1157 echo Template::fill($template, $data);
1162 * AdminActions::parse_adminerrormesg()
1163 * Parse skinvar adminerrormesg
1168 public function parse_adminerrormesg()
1173 if ( requestVar('errormessage') )
1175 $message = requestVar('errormessage');
1177 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1179 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1181 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1183 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1185 echo Entity::hsc($message);
1190 * AdminActions::parse_adminskineditallowedlist()
1191 * Parse skinvar adminskineditallowedlist
1193 * @param string $type template/blog
1194 * @param string $templateName name of template to use
1197 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1201 /* TODO: blog seems not to be used */
1203 $query = "SELECT bshortname, bname FROM %s";
1204 $query = sprintf($query, sql_table('blog'));
1206 'content' => 'shortblognames'
1210 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1211 $query = sprintf($query, sql_table('template_desc'));
1213 'content' => 'shortnames'
1217 Showlist($query, 'table', $show, $templateName);
1222 * AdminActions::parse_adminskinielist()
1223 * Parse skinvar adminskinielist
1225 * @param string $type skin/template
1226 * @param string $templateName name of template to use
1229 public function parse_adminskinielist($type, $templateName = '')
1231 $templates = array();
1232 if ( $templateName )
1234 $templates = Template::read($templateName);
1236 if ( isset($templates['SKINIE_EXPORT_LIST']) && !empty($templates['SKINIE_EXPORT_LIST']) )
1238 $template = $templates['SKINIE_EXPORT_LIST'];
1242 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
1243 . "<td><%expdesc%></td>\n"
1249 $query = "SELECT * FROM %s WHERE sdincmode = 'admin';";
1250 $query = sprintf($query, sql_table('skin_desc'));
1251 $res = sql_query($query);
1253 while ( $skinObj = sql_fetch_object($res) )
1256 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
1257 'expid' => 'skinexp' . $skinObj->sdnumber,
1258 'expname' => Entity::hsc($skinObj->sdname),
1259 'expdesc' => Entity::hsc($skinObj->sddesc),
1261 echo Template::fill($template, $data);
1265 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%'";
1266 $query = sprintf($query, sql_table('template_desc'));
1267 $res = sql_query($query);
1268 while ( $templateObj = sql_fetch_object($res) )
1271 'typeid' => 'template[' . $templateObj->tdnumber . ']',
1272 'expid' => 'templateexp' . $templateObj->tdnumber,
1273 'expname' => Entity::hsc($templateObj->tdname),
1274 'expdesc' => Entity::hsc($templateObj->tddesc),
1276 echo Template::fill($template, $data);
1284 * AdminActions::parse_adminskinoverview()
1285 * Parse skinvar adminskinoverview
1287 * @param string $templateName name of template to use
1290 public function parse_adminskinoverview($templateName = '')
1292 $query = "SELECT * FROM %s WHERE sdincmode = 'admin' ORDER BY sdname;";
1293 $query = sprintf($query, sql_table('skin_desc'));
1295 $template['content'] = 'adminskinlist';
1296 $template['tabindex'] = 10;
1297 $template['friendly_names'] = $this->skin->getAvailableTypes();
1298 Showlist($query, 'table', $template, $templateName);
1303 * AdminActions::parse_adminskinselectoptions()
1304 * Parse skinvar adminskinselectoptions
1309 public function parse_adminskinselectoptions()
1312 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdincmode = 'admin';";
1313 $query = sprintf($query, sql_table('skin_desc'));
1315 $template['name'] = 'adminskin';
1316 $template['selected'] = $CONF['DefaultAdminSkin'];
1317 $template['tabindex'] = 110;
1318 Showlist($query, 'select', $template, '');
1323 * AdminActions::parse_adminspecialskinlist()
1324 * Parse skinvar adminspecialskinlist
1326 * @param string $templateName name of template to use
1328 public function parse_adminspecialskinlist($templateName = '')
1330 $templates = array();
1331 if ( $templateName )
1333 $templates = Template::read($templateName);
1336 $nType = $this->skin->getAvailableTypes();
1337 $skinid = intRequestVar('skinid');
1339 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1340 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1342 $res = sql_query($query);
1343 if ( $res && sql_num_rows($res) > 0 )
1346 if ( array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1348 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1352 $template['head'] = "<ul>\n";
1354 echo Template::fill($template['head'], $data);
1356 if ( array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1358 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1362 $template['body'] = '<li>'
1363 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1366 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1372 while ( $row = sql_fetch_assoc($res) )
1375 'tabindex' => $tabstart++,
1376 'skinid' => $skinid,
1377 'skintype' => Entity::hsc(strtolower($row['stype']))
1379 echo Template::fill($template['body'], $data);
1383 if ( array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1385 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1389 $template['foot'] = "</ul>\n";
1391 echo Template::fill($template['foot'], $data);
1397 * AdminActions::parse_admintemplateoverview()
1398 * Parse skinvar admintemplateoverview
1400 * @param string $templateName name of template to use
1403 public function parse_admintemplateoverview($templateName = '')
1405 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1406 $query = sprintf($query, sql_table('template_desc'));
1408 $template['content'] = 'admintemplatelist';
1409 $template['tabindex'] = 10;
1411 Showlist($query, 'table', $template, $templateName);
1416 * AdminActions::parse_allowedadminskinactions()
1417 * Parse skinvar allowedadminskinactions
1422 public function parse_allowedadminskinactions()
1424 global $DIR_ADMINSKINS;
1425 $skinType = strtolower(trim(requestVar('type')));
1426 $actions = $this->skin->getAllowedActionsForType($skinType);
1429 while ( $current = array_shift($actions) )
1431 // skip deprecated vars
1432 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1437 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1438 // echo "<a href=\"{$DIR_ADMINSKINS}documentation/help.html#{$current}\" onclick=\"if (event && event.preventDefault) event.preventDefault(); return help(this.href);\">{$current}</a>\n";
1440 if ( count($actions) != 0 )
1449 * AdminActions::parse_allowedskinactions()
1450 * Parse skinvar allowedskinactions
1455 public function parse_allowedskinactions()
1457 $skinType = strtolower(trim(requestVar('type')));
1458 $skinid = intRequestVar('skinid');
1459 $skin = new Skin($skinid);
1460 $actions = $skin->getAllowedActionsForType($skinType);
1463 while ( $current = array_shift($actions) )
1465 // skip deprecated vars
1466 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1471 /* TODO: alternative function should be used or not? */
1472 echo helplink("skinvar-{$current}") . "$current</a>\n";
1474 if ( count($actions) != 0 )
1483 * AdminActions::parse_banlistdeletedlist()
1484 * Parse skinvar banlistdeletedlist
1486 * @param string $templateName name of template to use
1489 public function parse_banlistdeletedlist($templateName = '')
1492 $templates = array();
1494 if ( $templateName )
1496 $templates = Template::read($templateName);
1498 if ( isset($templates['BANLIST_DELETED_LIST']) && !empty($templates['BANLIST_DELETED_LIST']) )
1500 $template = $templates['BANLIST_DELETED_LIST'];
1504 $template = "<li><%blogname%></li>\n";
1506 $deleted = requestArray('delblogs');
1507 foreach ( $deleted as $delblog )
1509 $blog =& $manager->getBlog($delblog);
1511 Entity::hsc($blog->getName())
1513 Template::fill($template, $data);
1519 * AdminActions::parse_batchdeletelist()
1520 * Parse skinvar batchdeletelist
1525 public function parse_batchdeletelist()
1527 $selected = requestIntArray('batch');
1530 foreach ( $selected as $select )
1532 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1534 // add hidden vars for team & comment
1535 if ( requestVar('action') == 'batchteam' )
1537 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1539 if ( requestVar('action') == 'batchcomment' )
1541 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1547 * AdminActions::parse_batchdeletetype()
1548 * Parse skinvar batchdeletetype
1553 public function parse_batchdeletetype()
1555 echo Entity::hsc(requestVar('action'));
1560 * AdminActions::parse_batchmovebtn()
1561 * Parse skinvar batchmovebtn
1566 public function parse_batchmovebtn()
1568 $actionType = requestVar('action');
1569 switch ( $actionType )
1574 case 'batchcategory':
1582 * AdminActions::parse_batchmovelist()
1583 * Parse skinvar batchmovelist
1588 public function parse_batchmovelist()
1590 $selected = requestIntArray('batch');
1591 foreach ( $selected as $select )
1593 echo '<input type="hidden" name="batch[' . ($select++) . ']" value="' . intval($select) . "\" />\n";
1599 * AdminActions::parse_batchmovetitle()
1600 * Parse skinvar batchmovetitle
1605 public function parse_batchmovetitle()
1607 $actionType = requestVar('action');
1608 switch ( $actionType )
1613 case 'batchcategory':
1614 echo _MOVECAT_TITLE;
1621 * AdminActions::parse_batchmovetype()
1622 * Parse skinvar batchmovetype
1627 public function parse_batchmovetype()
1629 echo Entity::hsc(requestVar('action'));
1634 * AdminActions::parse_blogcatlist()
1635 * Parse skinvar blogcatlist
1640 public function parse_blogcatlist()
1643 $blogid = intRequestVar('blogid');
1644 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1645 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1647 $template['content'] = 'categorylist';
1648 $template['tabindex'] = 200;
1650 $batch = new Batch('member');
1651 $batch->showlist($query, 'table', $template);
1656 * AdminActions::parse_blogid()
1657 * Parse skinvar blogid
1662 function parse_blogid()
1664 echo intRequestVar('blogid');
1669 * AdminActions::parse_blognotifysetting()
1670 * Parse skinvar blognotifysetting
1675 public function parse_blognotifysetting($type)
1678 $blogid = intRequestVar('blogid');
1679 $blog = $manager->getBlog($blogid);
1684 if ( !$blog->notifyOnComment() )
1690 if ( !$blog->notifyOnVote() )
1696 if ( !$blog->notifyOnNewItem() )
1702 echo ' checked="checked"';
1707 * AdminActions::parse_blogselectbox()
1708 * Parse skinvar blogselectbox
1713 public function parse_blogselectbox()
1717 $selectData = requestVar('selectData');
1718 $mode = $selectData['mode'];
1719 $name = Entity::hsc($selectData['name']);
1720 $tabindex = Entity::hsc($selectData['tabindex']);
1721 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1722 $showNewCat = intval($selectData['showNewCat']);
1723 $selected = intval($selectData['selected']);
1725 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1727 // 1. select blogs (we'll create optiongroups)
1728 // (only select those blogs that have the user on the team)
1729 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1730 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1731 $blogs = sql_query($queryBlogs);
1733 if ( $mode == 'category' )
1735 if ( sql_num_rows($blogs) > 1 )
1739 while ( $oBlog = sql_fetch_object($blogs) )
1741 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1743 echo '<optgroup label="' . Entity::hsc($oBlog->bname) . "\>\n";
1746 // show selection to create new category when allowed/wanted
1749 // check if allowed to do so
1750 if ( $member->blogAdminRights($oBlog->bnumber) )
1752 echo '<option value="newcat-' . $oBlog->bnumber . '">' . _ADD_NEWCAT . "</option>\n";
1756 // 2. for each category in that blog
1757 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1758 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
1759 $categories = sql_query($catQuery);
1760 while ( $oCat = sql_fetch_object($categories) )
1762 if ( $oCat->catid == $selected )
1764 $selectText = ' selected="selected" ';
1770 echo '<option value="' . $oCat->catid . '" ' . $selectText . '>' . Entity::hsc($oCat->cname) . "</option>\n";
1773 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1782 while ( $oBlog = sql_fetch_object($blogs) )
1784 echo '<option value="' . $oBlog->bnumber . '"';
1785 if ( $oBlog->bnumber == $selected )
1787 echo '<option value="' . $oBlog->bnumber . '" selected="selected">' . Entity::hsc($oBlog->bname) . "</option>\n";
1791 echo '<option value="' . $oBlog->bnumber . '">' . Entity::hsc($oBlog->bname) . "</option>\n";
1800 * AdminActions::parse_blogsetting()
1801 * Parse skinvar blogsetting
1803 * @param string $which name of weblog setting
1806 public function parse_blogsetting($which)
1808 echo $this->parse_getblogsetting($which);
1813 * AdminActions::parse_blogsettingyesno()
1814 * Parse skinvar blogsettingyesno
1816 * @param string $type type of weblog setting
1817 * @param string $templateName name of template to use
1820 public function parse_blogsettingyesno($type, $templateName = '')
1824 $blogid = intRequestVar('blogid');
1825 $blog = $manager->getBlog($blogid);
1829 case 'convertbreaks':
1830 $checkedval = $blog->convertBreaks();
1833 case 'allowpastposting':
1834 $checkedval = $blog->allowPastPosting();
1838 $checkedval = $blog->commentsEnabled();
1842 $checkedval = $blog->isPublic();
1846 $checkedval = $blog->emailRequired();
1850 $checkedval = $blog->getSearchable();
1854 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1859 * AdminActions::parse_blogteamlist()
1860 * Parse skinvar blogteamlist
1862 * @param string $templateName name of template to use
1865 public function parse_blogteamlist($templateName = '')
1868 $blogid = intRequestVar('blogid');
1869 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1871 . "WHERE tmember=mnumber AND tblog= %d";
1872 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1874 $template['content'] = 'teamlist';
1875 $template['tabindex'] = 10;
1877 $batch = new Batch('team');
1878 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1883 * AdminActions::parse_blogteammembers()
1884 * Parse skinvar blogteammembers
1889 public function parse_blogteammembers()
1891 $blogid = intRequestVar('blogid');
1892 $query = "SELECT mname, mrealname "
1894 . "WHERE mnumber=tmember AND tblog=%d;";
1895 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1896 $res = sql_query($query);
1897 $memberNames = array();
1898 while ($o = sql_fetch_object($res)) {
1899 $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
1901 echo implode(',', $memberNames);
1905 * AdminActions::parse_blogtime()
1906 * Parse skinvar blogtime
1908 * @param string $type type of time
1909 * @param string $format format for time expression
1910 * @param integer $offset offset of time
1913 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1917 if ( $type != 'blogtime' )
1919 /* return server time */
1920 $timestamp = time() + $offset;
1924 $bid = intRequestVar('blogid');
1925 $b = $manager->getBlog($bid);
1926 $timestamp = $b->getCorrectTime() + $offset;
1929 echo i18n::formatted_datetime($format, $timestamp);
1934 * AdminActions::parse_bookmarkletadmin()
1935 * Parse skinvar bookmarkletadmin
1940 public function parse_bookmarkletadmin()
1944 $blogid = intRequestVar('blogid');
1946 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1951 * AdminActions::parse_categories()
1952 * Parse skinvar categories
1954 * create category dropdown box
1956 * @param string $type name of setting for category
1959 function parse_categories($startidx = 0)
1963 $itemid = intRequestVar('itemid');
1964 $item =& $manager->getItem($itemid, 1, 1);
1965 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1966 if ($item && $blog->convertBreaks() && requestVar('action') == 'itemedit') {
1967 $item['body'] = removeBreaks($item['body']);
1968 $item['more'] = removeBreaks($item['more']);
1970 $contents = array();
1971 if ( requestVar('action') == 'itemedit' )
1975 if ( isset($contents['catid']) && $contents['catid'] )
1977 $catid = $contents['catid']; // on edit item
1981 $catid = $blog->getDefaultCategory(); // on add item
1983 Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
1987 * AdminActions::parse_category()
1988 * Parse skinvar category
1990 * @param string $type name of setting for category
1993 public function parse_category($type = 'name')
1995 echo $this->parse_getcategory($type);
2000 * AdminActions::parse_categorysetting()
2001 * Parse skinvar categorysetting
2003 * @param string $type type in category setting
2006 public function parse_categorysetting($type)
2008 $catid = intRequestVar('catid');
2009 if ( $type == 'id' )
2014 $blogid = intRequestVar('blogid');
2015 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
2016 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
2017 $res = sql_query($query);
2018 $obj = sql_fetch_object($res);
2020 if ( $type != desc )
2022 echo Entity::hsc($obj->cdesc);
2026 echo Entity::hsc($obj->cname);
2033 * AdminActions::parse_codename()
2034 * Parse templatevar codename
2040 function parse_checkedonval($value, $name) {
2043 $itemid = intRequestVar('itemid');
2044 $item =& $manager->getItem($itemid, 1, 1);
2045 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2046 if ($item && $blog->convertBreaks() && requestVar('action') == 'itemedit') {
2047 $item['body'] = removeBreaks($item['body']);
2048 $item['more'] = removeBreaks($item['more']);
2050 $contents = array();
2051 if ( requestVar('action') == 'itemedit' )
2055 if ( !isset($contents[$name]) )
2057 $contents[$name] = '';
2059 if ($contents[$name] == $value)
2061 echo 'checked="checked"';
2066 * AdminActions::parse_codename()
2067 * Parse templatevar codename
2072 * TODO: is this need???
2074 public function parse_codename()
2077 echo $nucleus['codename'];
2082 * AdminActions::parse_commentnavlist()
2083 * Parse skinvar commentnavlist
2088 public function parse_commentnavlist()
2090 global $CONF, $manager, $member;
2093 if ( postVar('start') )
2095 $start = intPostVar('start');
2102 // amount of items to show
2103 if ( postVar('amount') )
2105 $amount = intPostVar('amount');
2109 $amount = (integer) $CONF['DefaultListSize'];
2115 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2117 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2119 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2121 if ( $this->skintype == 'itemcommentlist' )
2123 $itemid = intRequestVar('itemid');
2124 $query .= " citem={$itemid}";
2125 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2127 $nonComments = _NOCOMMENTS;
2129 elseif ( $this->skintype == 'browseowncomments' )
2132 $query .= ' cmember=' . $member->getID();
2133 $template['canAddBan'] = 0;
2135 $nonComments = _NOCOMMENTS_YOUR;
2137 elseif ( $this->skintype == 'blogcommentlist' )
2140 $query .= ' cblog=' . intRequestVar('blogid');
2141 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2142 $bid = intRequestVar('blogid');
2143 $nonComments = _NOCOMMENTS_BLOG;
2146 $search = postVar('search');
2147 if ( !empty($search) )
2149 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
2152 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2154 $template['content'] = 'commentlist';
2156 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2157 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2162 * AdminActions::parse_configsettingsedit()
2163 * Parse skinvar configsettingsedit
2165 * @param string $type type of global configuration
2168 public function parse_configsettingsedit($type)
2173 case 'DefaultListSize':
2174 if ( !array_key_exists('DefaultListSize', $CONF) )
2176 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2177 $query = sprintf($query, sql_table('config'));
2179 $CONF['DefaultListSize'] = 10;
2181 elseif ( intval($CONF['DefaultListSize']) < 1 )
2183 $CONF['DefaultListSize'] = 10;
2185 echo intval($CONF['DefaultListSize']);
2187 case 'SessionCookie':
2188 $value = $CONF['SessionCookie'];
2189 $txt1 = _SETTINGS_COOKIESESSION;
2190 $txt2 = _SETTINGS_COOKIEMONTH;
2191 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2194 $value = $CONF['URLMode'];
2195 $txt1 = _SETTINGS_URLMODE_NORMAL;
2196 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2197 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2200 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2202 echo Entity::hsc($CONF[$type]);
2210 * AdminActions::parse_configsettingsyesno()
2211 * Parse skinvar configsettingsyesno
2213 * @param string $type type of global setting
2214 * @param integer $tabindex tabindex attribute of input element
2217 public function parse_configsettingsyesno($type, $tabindex)
2220 if ( array_key_exists($type, $CONF) )
2222 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2228 * AdminActions::parse_contents()
2229 * Parse skinvar contents
2231 * @param string $which part for item
2234 function parse_contents($which)
2238 $contents = array();
2239 if ( requestVar('action') == 'itemedit' )
2241 $itemid = intRequestVar('itemid');
2242 $item =& $manager->getItem($itemid, 1, 1);
2243 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2244 if ( $item && $blog->convertBreaks() )
2246 $item['body'] = removeBreaks($item['body']);
2247 $item['more'] = removeBreaks($item['more']);
2251 elseif ( requestVar('action') == 'createitem' )
2253 $blog =& $manager->getBlog(intRequestVar($blogid));
2257 'contents' => &$contents,
2262 if ( !isset($contents[$which]) )
2264 $contents[$which] = '';
2266 echo Entity::hsc($contents[$which],ENT_QUOTES);
2270 * AdminActions::parse_currenttime()
2271 * Parse skinvar currenttime
2273 * @param string $what
2276 function parse_currenttime($what)
2279 if ( requestVar('action') == 'itemedit' )
2281 $itemid = intRequestVar('itemid');
2282 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2284 elseif ( requestVar('action') == 'createitem' )
2286 $blog =& $manager->getBlog(intRequestVar('blogid'));
2288 $nu = getdate($blog->getCorrectTime());
2293 * AdminActions::parse_customhelplink()
2294 * Parse skinvar customhelplink
2296 * @param string $topic name of topic
2297 * @param string $tplName name of template
2298 * @param string $url string as URI
2299 * @param string $iconURL string as URI for icon
2300 * @param string $alt alternative text for image element
2301 * @param string $title title for anchor element
2304 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2306 $this->customHelp($topic, $url, $iconURL);
2311 * AdminActions::parse_date()
2312 * Parse skinvar date
2314 public function parse_date($format = 'c')
2316 global $CONF, $manager;
2317 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2322 * AdminActions::parse_defaultadminskintypes()
2323 * Parse skinvar defaultadminskintypes
2325 * @param string $tabindex index number for tabindex attribute of input element
2326 * @param string $templateName name of template
2329 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2331 $templates = array();
2332 if ( $templateName )
2334 $templates = Template::read($templateName);
2337 $types = $this->skin->getAvailableTypes();
2340 if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
2342 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2346 $template['head'] = "<ul>\n";
2349 echo $template['head'];
2351 if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
2353 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2357 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
2358 . "<%name%></a> <%help%></li>\n";
2360 $handler = new Actions('template', $template, new ADMIN);
2361 $parser = new PARSER(Actions::getDefinedActions(), $handler);
2363 foreach ( $types as $type => $fName )
2365 $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
2367 'tabindex' => $tabindex,
2368 'skintype' => $type,
2370 'help' => $helplink,
2371 'skinid' => intrequestVar('skinid'),
2373 $templateBody = Template::fill($template['body'], $data);
2374 $parser->parse($templateBody);
2377 if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
2379 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2383 $template['foot'] = " </ul>\n";
2385 echo $template['foot'];
2390 * AdminActions::parse_defblogselect()
2391 * Parse skinvar defblogselect
2393 * @param string $templateName name of template
2396 public function parse_defblogselect($templateName = '')
2399 $query = "SELECT bname as text, bnumber as value FROM %s;";
2400 $query = sprintf($query, sql_table('blog'));
2401 $template['name'] = 'DefaultBlog';
2402 $template['selected'] = $CONF['DefaultBlog'];
2403 $template['tabindex'] = 10;
2404 Showlist($query, 'select', $template, $templateName);
2409 * AdminActions::parse_defcatselect()
2410 * Parse skinvar defcatselect
2412 * @param string $templateName name of template
2415 public function parse_defcatselect($templateName = '')
2418 $blogid = intRequestVar('blogid');
2419 $blog = $manager->getBlog($blogid);
2420 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2421 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2422 $template['name'] = 'defcat';
2423 $template['selected'] = $blog->getDefaultCategory();
2424 $template['tabindex'] = 110;
2425 Showlist($query, 'select', $template, $templateName);
2430 * AdminActions::parse_defskinselect()
2431 * Parse skinvar defskinselect
2433 * @param string $type type of skin
2434 * @param string $templateName name of template
2437 public function parse_defskinselect($type = 'blog', $templateName = '')
2440 $query = "SELECT sdname as text, sdnumber as value FROM %s;";
2441 $query = sprintf($query, sql_table('skin_desc'));
2443 $blogid = intRequestVar('blogid');
2448 $template['selected'] = $CONF['BaseSkin'];
2452 $blog = $manager->getBlog($blogid);
2453 $template['selected'] = $blog->getDefaultSkin();
2456 if ( $type != 'blog' )
2458 $nname = 'BaseSkin';
2465 $template['name'] = $nname;
2466 $template['tabindex'] = 50;
2467 Showlist($query, 'select', $template, $templateName);
2472 * AdminActions::parse_deletecomment()
2473 * Parse skinvar deletecomment
2475 * @param string $type type of infomation for comment
2478 public function parse_deletecomment($type = 'id')
2480 $commentid = intRequestVar('commentid');
2481 $comment = COMMENT::getComment($commentid);
2486 echo intRequestVar('commentid');
2489 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2491 echo $comment['member'];
2495 echo $comment['user'];
2499 $body = strip_tags($comment['body']);
2500 echo Entity::hsc(shorten($body, 300, '...'));
2506 * AdminActions::parse_deleteitembody()
2507 * Parse skinvar deleteitembody
2512 public function parse_deleteitembody()
2515 $itemid = intRequestVar('itemid');
2516 $item =& $manager->getItem($itemid, 1, 1);
2517 $body = strip_tags($item['body']);
2518 echo Entity::hsc(shorten($body, 300, '...'));
2523 * AdminActions::parse_deleteitemid()
2524 * Parse skinvar deleteitemid
2529 public function parse_deleteitemid()
2531 echo (integer) intRequestVar('itemid');
2536 * AdminActions::parse_deleteitemtitle()
2537 * Parse skinvar deleteitemtitle
2542 public function parse_deleteitemtitle()
2545 $itemid = intRequestVar('itemid');
2546 $item =& $manager->getItem($itemid, 1, 1);
2547 echo Entity::hsc(strip_tags($item['title']));
2552 * AdminActions::parse_editadminskin()
2553 * Parse skinvar editadminskin
2555 * @param string $type type of skin setting
2558 public function parse_editadminskin($type = 'id')
2560 $skinid = intRequestVar('skinid');
2561 $skin = new Skin($skinid);
2565 echo intRequestVar('skinid');
2568 echo Entity::hsc($skin->getName());
2571 echo Entity::hsc($skin->getDescription());
2574 echo Entity::hsc($skin->getContentType());
2577 echo Entity::hsc($skin->getIncludePrefix());
2580 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2588 * AdminActions::parse_editadminskintype()
2589 * Parse skinvar editadminskintype
2591 * @param string $type name of skin type
2594 public function parse_editadminskintype($type = 'id')
2596 global $CONF, $manager, $member;
2597 // $skinid = intRequestVar('skinid');
2598 // $skin = new Skin($skinid);
2599 $fNames = $this->skin->getAvailableTypes();
2600 $sType = strtolower(trim(requestVar('type')));
2605 echo intRequestVar('skinid');
2608 echo Entity::hsc($this->skin->getName());
2611 echo Entity::hsc($this->skin->getDescription());
2614 echo Entity::hsc($this->skin->getContentType());
2617 echo Entity::hsc($this->skin->getContentFromDB($sType));
2620 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2621 echo Entity::hsc($skinType);
2624 echo Entity::hsc($sType);
2627 echo Entity::hsc($this->skin->getIncludePrefix());
2630 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2631 echo Entity::hsc($incMode);
2640 * AdminActions::parse_editadmintemplateinfo()
2641 * Parse skinvar editadmintemplateinfo
2643 * @param string $type type of skin template
2644 * @param string $description description of template
2645 * @param string $name name of stemplate
2646 * @param string $tabindex index number for tabindex attribute of input element
2647 * @param string $big
2648 * @param string $tplt
2650 public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2653 $templateid = intRequestVar('templateid');
2654 $templatename = Template::getNameFromId($templateid);
2655 $templatedescription = Template::getDesc($templateid);
2656 $template =& Template::read($templatename);
2660 echo intval($templateid);
2663 echo Entity::hsc($templatename);
2666 echo Entity::hsc($templatedescription);
2668 case 'extratemplate':
2670 $pluginfields = array();
2672 'AdminTemplateExtraFields',
2674 'fields' => &$pluginfields
2680 $tmplt = Template::read($description);
2682 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2684 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2690 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2692 foreach ( $pluginfields as $pfkey => $pfvalue )
2695 'explugtplname' => Entity::hsc($pfkey)
2697 echo Template::fill($base, $data);
2698 foreach ( $pfvalue as $pffield => $pfdesc )
2700 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2705 $desc = defined($description) ? constant($description) : $description;
2706 $name = defined($name) ? constant($name) : $name;
2707 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2714 * AdminActions::parse_editcomment()
2715 * Parse skinvar editcomment
2717 * @param string $type type of comment setting
2720 public function parse_editcomment($type = 'id')
2723 $commentid = intRequestVar('commentid');
2724 $comment = COMMENT::getComment($commentid);
2726 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2731 echo intRequestVar('commentid');
2734 if (array_key_exists('member', $comment) && !empty($comment['member']) )
2736 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2740 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2744 echo date("Y-m-d @ H:i", $comment['timestamp']);
2747 $comment['body'] = str_replace('<br />', '', $comment['body']);
2748 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2749 echo $comment['body'];
2751 echo $comment[$type];
2758 * AdminActions::parse_editdesturl()
2759 * Parse skinvar editdesturl
2761 public function parse_editdesturl()
2763 if ( requestVar('desturl') )
2765 echo Entity::hsc(requestVar('desturl'));
2771 * AdminActions::parse_editmemberlist()
2772 * Parse skinvar editmemberlist
2774 * @param string $templateName name of template
2777 public function parse_editmemberlist($templateName = '')
2780 // show list of members with actions
2781 $query = 'SELECT * FROM '.sql_table('member');
2782 $template['content'] = 'memberlist';
2783 $template['tabindex'] = 10;
2785 $batch = new Batch('member');
2786 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2791 * AdminActions::parse_editmember()
2792 * Parse skinvar editmember
2794 * @param string $type type of information for member
2795 * @return string $tempateName name of template to use
2798 public function parse_editmember($type = 'id', $templateName = '')
2800 global $CONF, $manager, $member;
2801 $memberid = intRequestVar('memberid');
2802 $mem = MEMBER::createFromID($memberid);
2807 echo intRequestVar('memberid');
2810 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2812 echo Entity::hsc($mem->getDisplayName());
2816 $dispName = Entity::hsc($mem->getDisplayName());
2817 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2819 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2828 echo Entity::hsc($mem->getRealName());
2831 echo Entity::hsc($mem->getEmail());
2834 echo Entity::hsc($mem->getURL());
2837 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2840 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2843 echo Entity::hsc($mem->getNotes());
2846 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2855 * AdminActions::parse_editpluginfo()
2856 * Parse skinvar editpluginfo
2858 * @param string $type type of plugin info
2861 public function parse_editpluginfo($type)
2863 $pid = intRequestVar('plugid');
2870 echo Entity::hsc(getPluginNameFromPid($pid));
2877 * AdminActions::parse_editplugoptionslist()
2878 * Parse skinvar editplugoptionslist
2880 * @param string $templateName name of template
2883 public function parse_editplugoptionslist($templateName = '')
2887 $pid = intRequestVar('plugid');
2888 $aOptions = array();
2891 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
2892 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2893 $resource = sql_query($query);
2895 while ( $o = sql_fetch_object($resource) )
2897 array_push($aOIDs, $o->oid);
2898 $aOptions[$o->oid] = array(
2901 'value' => $o->odef,
2902 'name' => $o->oname,
2903 'description' => $o->odesc,
2904 'type' => $o->otype,
2905 'typeinfo' => $o->oextra,
2910 // fill out actual values
2911 if ( count($aOIDs) > 0 )
2913 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2914 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2916 $result = sql_query($query);
2918 while ( $o = sql_fetch_object($result) )
2920 $aOptions[$o->oid]['value'] = $o->ovalue;
2926 'PrePluginOptionsEdit',
2928 'context' => 'global',
2930 'options' => &$aOptions
2934 $template['content'] = 'plugoptionlist';
2935 $amount = Showlist($aOptions, 'table', $template, $templateName);
2938 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2944 * AdminActions::parse_editskin()
2945 * Parse skinvar editskin
2947 * @param string $type type of skin
2950 public function parse_editskin($type = 'id')
2952 $skinid = intRequestVar('skinid');
2953 $skin = new SKIN($skinid);
2957 echo intRequestVar('skinid');
2960 echo Entity::hsc($skin->getName());
2963 echo Entity::hsc($skin->getDescription());
2966 echo Entity::hsc($skin->getContentType());
2969 echo Entity::hsc($skin->getIncludePrefix());
2972 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2980 * AdminActions::parse_editskintype()
2981 * Parse skinvar editskintype
2983 * @param string $type name of type for skin type
2986 public function parse_editskintype($type = 'id')
2988 global $CONF, $manager, $member;
2989 $skinid = intRequestVar('skinid');
2990 $skin = new SKIN($skinid);
2991 $fNames = $skin->getAvailableTypes();
2992 $sType = strtolower(trim(requestVar('type')));
2997 echo intRequestVar('skinid');
3000 echo Entity::hsc($skin->getName());
3003 echo Entity::hsc($skin->getDescription());
3006 echo Entity::hsc($skin->getContentType());
3009 echo Entity::hsc($skin->getContentFromDB($sType));
3012 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
3013 echo Entity::hsc($skinType);
3016 echo Entity::hsc($sType);
3019 echo Entity::hsc($skin->getIncludePrefix());
3022 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
3023 echo Entity::hsc($incMode);
3032 * AdminActions::parse_adminurl()
3033 * Parse skinvar adminurl
3034 * (shortcut for admin url)
3039 public function parse_adminurl()
3041 $this->parse_sitevar('adminurl');
3046 * AdminActions::parse_edittemplateinfo()
3047 * Parse skinvar edittemplateinfo
3049 * @param string $type name of type for skin
3050 * @param string $description description for skin
3051 * @param string $name name of skin
3052 * @param string $help
3053 * @param string $tabindex index value for tabindex attribute of input element
3054 * @param string $big
3055 * @param string $tplt name of template
3057 public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3060 $templateid = intRequestVar('templateid');
3061 $templatename = Template::getNameFromId($templateid);
3062 $templatedescription = Template::getDesc($templateid);
3063 $template =& $manager->getTemplate($templatename);
3067 echo intval($templateid);
3070 echo Entity::hsc($templatename);
3073 echo Entity::hsc($templatedescription);
3075 case 'extratemplate':
3077 $pluginfields = array();
3079 'TemplateExtraFields',
3081 'fields' => &$pluginfields
3087 $tmplt = Template::read($description);
3089 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3091 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3095 $base = "</tr><tr>\n"
3096 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3098 foreach ( $pluginfields as $pfkey => $pfvalue )
3101 'explugtplname' => Entity::hsc($pfkey)
3103 echo Template::fill($base, $data);
3104 foreach ( $pfvalue as $pffield => $pfdesc )
3106 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3111 $desc = defined($description) ? constant($description) : $description;
3112 $name = defined($name) ? constant($name) : $name;
3113 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3120 * AdminActions::parse_eventformextra()
3121 * Parse skinvar eventformextra
3123 * @param string $type name of type for event form extra
3126 public function parse_eventformextra($type = 'activation')
3132 $key = requestVar('ackey');
3135 Admin::error(_ERROR_ACTIVATE);
3137 $info = MEMBER::getActivationInfo($key);
3140 Admin::error(_ERROR_ACTIVATE);
3142 $mem = MEMBER::createFromId($info->vmember);
3145 Admin::error(_ERROR_ACTIVATE);
3148 'type' => 'activation',
3152 case 'membermailform-notloggedin':
3154 'type' => 'membermailform-notloggedin',
3158 $manager->notify('FormExtra', $data);
3163 * AdminActions::parse_extrahead()
3164 * Parse skinvar extrahead
3166 public function parse_extrahead()
3169 $extrahead = Admin::getAdminextrahead();
3173 'extrahead' => &$extrahead,
3174 'action' => Admin::getAdminAction()
3183 * AdminActions::parse_member()
3184 * Parse skinvar member
3185 * (includes a member info thingie)
3187 * @param string $what which memberdata is needed
3190 public function parse_member($what)
3192 global $memberinfo, $member, $CONF;
3194 // 1. only allow the member-details-page specific variables on member pages
3195 if ( $this->skintype == 'member' )
3200 echo Entity::hsc($memberinfo->getDisplayName());
3203 echo Entity::hsc($memberinfo->getRealName());
3206 echo Entity::hsc($memberinfo->getNotes());
3209 echo Entity::hsc($memberinfo->getURL());
3212 echo Entity::hsc($memberinfo->getEmail());
3215 echo Entity::hsc($memberinfo->getID());
3220 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3221 if ( $member->isLoggedIn() )
3226 echo $member->getDisplayName();
3228 case 'yourrealname':
3229 echo $member->getRealName();
3232 echo $member->getNotes();
3235 echo $member->getURL();
3238 echo $member->getEmail();
3241 echo $member->getID();
3243 case 'yourprofileurl':
3244 if ($CONF['URLMode'] == 'pathinfo')
3245 echo Link::create_member_link($member->getID());
3247 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3255 * AdminActions::parse_version()
3256 * Parse skinvar version
3257 * (include nucleus versionnumber)
3262 public function parse_version()
3265 echo 'Nucleus CMS ' . $nucleus['version'];
3270 * AdminActions::parse_sitevar()
3271 * Parse skinvar sitevar
3272 * (include a sitevar)
3274 * @param string $which
3277 public function parse_sitevar($which)
3283 echo $CONF['IndexURL'];
3286 echo $CONF['SiteName'];
3289 echo $CONF['AdminEmail'];
3292 echo $CONF['AdminURL'];
3298 * AdminActions::parse_charset()
3299 * Parse skinvar charset
3304 public function parse_charset()
3306 echo i18n::get_current_charset();
3311 * AdminActions::parse_getblogsetting()
3312 * Parse skinvar getblogsetting
3314 public function parse_getblogsetting($which)
3322 elseif ( $bid = intRequestVar('blogid') )
3325 $b = $manager->getBlog($bid);
3335 return Entity::hsc($b->getID());
3338 return Entity::hsc($b->getURL());
3341 return Entity::hsc($b->getName());
3344 return Entity::hsc($b->getDescription());
3347 return Entity::hsc($b->getShortName());
3349 case 'notifyaddress':
3350 return Entity::hsc($b->getNotifyAddress());
3353 return Entity::hsc($b->getMaxComments());
3356 return Entity::hsc($b->getUpdateFile());
3359 return Entity::hsc($b->getTimeOffset());
3366 * AdminActions::parse_geteditpluginfo()
3367 * Parse skinvar geteditpluginfo
3369 * @param string $type name of setting for edit plugin info
3372 public function parse_geteditpluginfo($type)
3374 $pid = intRequestVar('plugid');
3381 return Entity::hsc(getPluginNameFromPid($pid));
3388 * AdminActions::parse_getmember()
3389 * Parse skinvar getmember
3390 * (includes a member info thingie)
3392 * @param string $what name of setting for member
3395 public function parse_getmember($what)
3397 global $memberinfo, $member;
3398 // 1. only allow the member-details-page specific variables on member pages
3399 if ( $this->skintype == 'member' )
3404 return Entity::hsc($memberinfo->getDisplayName());
3407 return Entity::hsc($memberinfo->getRealName());
3410 return Entity::hsc($memberinfo->getNotes());
3413 return Entity::hsc($memberinfo->getURL());
3416 return Entity::hsc($memberinfo->getEmail());
3419 return Entity::hsc($memberinfo->getID());
3423 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3424 if ( $member->isLoggedIn() )
3429 return $member->getDisplayName();
3431 case 'yourrealname':
3432 return $member->getRealName();
3435 return $member->getNotes();
3438 return $member->getURL();
3441 return $member->getEmail();
3444 return $member->getID();
3452 * AdminActions::parse_headmessage()
3453 * Parse skinvar headmessage
3458 public function parse_headmessage()
3460 if ( !empty(Admin::$headMess) )
3462 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3468 * AdminActions::parse_helplink()
3469 * Parse skinvar helplink
3471 * @param string $topic name of topic for help
3474 public function parse_helplink($topic = '')
3476 if ( empty($topic) )
3485 * AdminActions::parse_helpplugname()
3486 * Parse skinvar helpplugname
3491 public function parse_helpplugname()
3493 $plugid = intGetVar('plugid');
3494 Entity::hsc(getPluginNameFromPid($plugid));
3499 * AdminActions::parse_ilistaddnew()
3500 * Parse skinvar ilistaddnew
3505 public function parse_ilistaddnew()
3507 $blogid = intRequestVar('blogid');
3508 if ( intPostVar('start') == 0 )
3510 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3516 * AdminActions::parse_importskininfo()
3517 * Parse skinvar importskininfo
3519 * @param string $type name of information for imported skin
3522 public function parse_importskininfo($type)
3527 echo Entity::hsc(requestVar('skininfo'));
3530 $dataArr = requestArray('skinnames');
3531 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3534 $dataArr = requestArray('tpltnames');
3535 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3538 $dataArr = requestArray('skinclashes');
3539 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3542 $dataArr = requestArray('tpltclashes');
3543 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3546 echo Entity::hsc(requestVar('skinfile'));
3549 echo Entity::hsc(requestVar('mode'));
3556 * AdminActions::parse_inputyesno()
3557 * Parse skinvar inputyesno
3559 * some init stuff for all forms
3563 function parse_init()
3567 if ( requestVar('action') == 'itemedit' )
3569 $itemid = intRequestVar('itemid');
3570 $item =& $manager->getItem($itemid, 1, 1);
3571 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3572 if ( $item && $blog->convertBreaks() )
3574 $item['body'] = removeBreaks($item['body']);
3575 $item['more'] = removeBreaks($item['more']);
3578 $authorid = $contents['authorid'];
3580 elseif ( requestVar('action') == 'createitem' )
3582 $blog =& $manager->getBlog(intRequestVar($blogid));
3585 $blog->insertJavaScriptInfo($authorid);
3589 * AdminActions::parse_inputyesno()
3590 * Parse skinvar inputyesno
3592 * @param string $name
3593 * @param string $checkedval
3594 * @param string $tabindex
3595 * @param string $value1
3596 * @param string $value2
3597 * @param string $yesval
3598 * @param string $noval
3599 * @param string $isAdmin
3600 * @param string $templateName
3603 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3605 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3610 * AdminActions::parse_insertpluginfo()
3611 * Parse templatevar insertpluginfo
3613 public function parse_insertpluginfo($type)
3615 $option = Admin::$aOptions;
3619 return $option['pid'];
3622 return Entity::hsc($option['pfile']);
3629 * AdminActions::parse_insertpluginoptions()
3630 * Parse skinvar insertpluginoptions
3632 * @param string $templateName name of template
3635 public function parse_insertpluginoptions($templateName = '')
3637 $options = Admin::getAdminaOption();
3638 $template = array();
3639 $templats = array();
3641 if ( $templateName )
3643 $templates = Template::read($templateName);
3645 if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
3647 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3651 $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
3653 if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
3655 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3659 $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
3664 foreach ( $options as $option )
3666 $handler = new Actions($this->skintype, $template, $option);
3667 $parser = new PARSER(Actions::getDefinedActions(), $handler);
3669 if ( $prevPid != $option['pid'] )
3671 $prevPid = $option['pid'];
3672 $parser->parse($template['title']);
3674 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3675 if ( @$meta['access'] != 'hidden' )
3677 $parsed = $parser->parse($template['body']);
3684 * AdminActions::parse_insplugoptcontent()
3685 * Parse skinvar insplugoptcontent
3690 public function parse_insplugoptcontent()
3692 $option = Admin::$aOption;
3694 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3695 if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
3698 listplug_plugOptionRow($option);
3705 * AdminActions::parse_iprangeinput()
3706 * Parse skinvar iprangeinput
3711 public function parse_iprangeinput()
3713 if ( requestVar('ip') )
3715 $iprangeVal = Entity::hsc(requestVar('ip'));
3716 echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
3717 echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
3718 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3719 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3720 echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
3724 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3725 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3731 * AdminActions::parse_itemnavlist()
3732 * Parse skinvar itemnavlist
3737 public function parse_itemnavlist()
3739 global $CONF, $manager, $member;
3740 if ( $this->skintype == 'itemlist' )
3742 $blogid = intRequestVar('blogid');
3743 $blog =& $manager->getBlog($blogid);
3745 if ( postVar('start') )
3747 $start = intPostVar('start');
3754 // amount of items to show
3755 if ( postVar('amount') )
3757 $amount = intPostVar('amount');
3761 $amount = intval($CONF['DefaultListSize']);
3767 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3768 . " FROM %s, %s, %s, %s"
3769 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3771 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3773 if ( $this->skintype == 'itemlist' )
3775 $query .= ' AND iblog = ' . $blogid;
3776 $template['now'] = $blog->getCorrectTime(time());
3778 // non-blog-admins can only edit/delete their own items
3779 if ( !$member->blogAdminRights($blogid) )
3781 $query .= ' AND iauthor = ' . $member->getID();
3784 elseif ( $this->skintype == 'browseownitems' )
3786 $query .= ' AND iauthor = ' . $member->getID();
3788 $template['now'] = time();
3791 // search through items
3792 $search = postVar('search');
3794 if ( !empty($search) )
3796 $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
3797 . ' OR (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
3798 . ' OR (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
3800 $query .= ' ORDER BY itime DESC'
3801 . " LIMIT {$start},{$amount}";
3803 $template['content'] = 'itemlist';
3805 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3806 $navList->showBatchList('item', $query, 'table', $template);
3811 * AdminActions::parse_itemoptions()
3812 * Parse skinvar itemoptions
3813 * Adds the itemOptions of a plugin to a page
3816 function parse_itemoptions()
3818 $this->parse_pluginoptions($type = 'item');
3820 // Admin::insertPluginOptions('item', $itemid);
3824 * AdminActions::parse_itemoptions()
3826 * date change on edit item
3828 * Parse skinvar itemoptions
3829 * Adds the itemOptions of a plugin to a page
3832 function parse_itemtime($what)
3836 $itemid = intRequestVar('itemid');
3837 $item =& $manager->getItem($itemid, 1, 1);
3838 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3839 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3841 $item['body'] = removeBreaks($item['body']);
3842 $item['more'] = removeBreaks($item['more']);
3844 $contents = array();
3845 if ( requestVar('action') == 'itemedit' )
3849 elseif ( requestVar('action') == 'createitem' )
3854 'contents' => &$contents,
3855 'blog' => &$this->blog
3859 $itemtime = getdate($contents['timestamp']);
3860 echo $itemtime[$what];
3864 * AdminActions::parse_jstoolbaroptions()
3865 * Parse skinvar jstoolbaroptions
3870 public function parse_jstoolbaroptions()
3874 _SETTINGS_JSTOOLBAR_NONE,
3875 _SETTINGS_JSTOOLBAR_SIMPLE,
3876 _SETTINGS_JSTOOLBAR_FULL
3879 foreach ( $options as $option )
3881 $text = "<option value=\"%d\"%s>%s</option>\n";
3882 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3883 echo sprintf($text, $i, $extra, $option);
3889 * Parse skinvar languageselectoptions
3891 function parse_languageselectoptions()
3893 $locales = i18n::get_available_locale_list();
3894 $memid = intRequestVar('memberid');
3897 $mem = MEMBER::createFromID($memid);
3898 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3900 echo "<option value=\"\" selected=\"selected\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3904 echo "<option value=\"\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3909 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3911 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3914 foreach ( $locales as $locale )
3918 if ( $locale == $mem->getLocale() )
3920 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3924 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3929 if ( $locale == i18n::get_current_locale() )
3931 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3935 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3942 * AdminActions::parse_localeselectoptions()
3943 * Parse skinvar localeselectoptions
3948 public function parse_localeselectoptions()
3950 $locales = i18n::get_available_locale_list();
3951 $memid = intRequestVar('memberid');
3954 $mem = MEMBER::createFromID($memid);
3955 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3957 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3961 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3966 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3968 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3971 foreach ( $locales as $locale )
3975 if ( $locale == $mem->getLocale() )
3977 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3981 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3986 if ( $locale == i18n::get_current_locale() )
3988 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3992 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4000 * AdminActions::parse_listplugplugoptionrow()
4001 * Parse templatevar listplugplugoptionrow
4003 * @param string $templateName name of template
4006 public function parse_listplugplugoptionrow($templateName = '')
4008 echo listplug_plugOptionRow(Admin::$aOptions, $templateName);
4013 * AdminActions::parse_mediadirwarning()
4014 * Parse skinvar mediadirwarning
4019 public function parse_mediadirwarning()
4022 if ( !is_dir($DIR_MEDIA) )
4024 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4026 if ( !is_readable($DIR_MEDIA) )
4028 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4030 if ( !is_writeable($DIR_MEDIA) )
4032 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4038 * AdminActions::parse_movedistselect()
4039 * Parse skinvar movedistselect
4041 public function parse_movedistselect()
4043 $actionType = requestVar('action');
4044 switch ( $actionType )
4047 Admin::selectBlogCategory('destcatid');
4049 case 'batchcategory':
4050 Admin::selectBlog('destblogid');
4053 if ( $this->skintype == 'itemmove' )
4055 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
4056 $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
4057 $catid = quickQuery(sprintf($query, intRequestVar('itemid')));
4058 Admin::selectBlogCategory('catid', $catid, 10, 1);
4066 * AdminActions::parse_moveitemid()
4067 * Parse skinvar moveitemid
4072 public function parse_moveitemid()
4074 echo intRequestVar('itemid');
4079 * AdminActions::parse_newestcompare()
4080 * Parse skinvar newestcompare
4085 public function parse_newestcompare()
4088 $newestVersion = getLatestVersion();
4089 $newestCompare = str_replace('/', '.', $newestVersion);
4090 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4091 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4093 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4094 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4100 * AdminActions::parse_newmemberselect()
4101 * Parse skinvar newmemberselect
4103 * @param string $templateName name of template to use
4106 public function parse_newmemberselect($templateName = '')
4108 $blogid = intRequestVar('blogid');
4110 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4111 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4112 $res = sql_query($query);
4115 while ( $tmember = sql_fetch_object($res) )
4117 $tmem[] = intval($tmember->tmember);
4120 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4121 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4123 $template['name'] = 'memberid';
4124 $template['tabindex'] = 10000;
4125 Showlist($query, 'select', $template, $templateName);
4130 * AdminActions::parse_newpluginlist()
4131 * Parse skinvar newpluginlist
4136 public function parse_newpluginlist()
4138 $candidates = $this->newPlugCandidates;
4139 foreach ( $candidates as $name )
4141 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4147 * AdminActions::parse_outputspecialdirs()
4148 * Parse skinvar outputspecialdirs
4150 * @param string $type type of setting for directory
4153 public function parse_outputspecialdirs($type)
4158 global $DIR_NUCLEUS;
4159 echo Entity::hsc($DIR_NUCLEUS);
4163 echo Entity::hsc($DIR_MEDIA);
4170 * AdminActions::parse_passrequestvars()
4171 * Parse skinvar passrequestvars
4176 public function parse_passrequestvars()
4178 $passvar = Admin::getAdminpassvar();
4179 $oldaction = postVar('oldaction');
4180 if ( ($oldaction != 'logout')
4181 && ($oldaction != 'login')
4183 && !postVar('customaction') )
4191 * AdminActions::parse_pluginextras()
4192 * Parse skinvar pluginextras
4194 * @param string $type type of plugin context
4197 public function parse_pluginextras($type = 'global')
4203 $id = intRequestVar('memberid');
4204 $mem = MEMBER::createFromID($id);
4206 'MemberSettingsFormExtras',
4213 $id = intRequestVar('blogid');
4214 $blg = $manager->getBlog($id);
4216 'BlogSettingsFormExtras',
4224 'GeneralSettingsFormExtras',
4234 * AdminActions::parse_pluginhelp()
4235 * Parse skinvar pluginhelp
4240 public function parse_pluginhelp()
4242 global $manager, $DIR_PLUGINS;
4243 $plugid = intGetVar('plugid');
4244 $plugName = getPluginNameFromPid($plugid);
4245 $plug =& $manager->getPlugin($plugName);
4247 if ( $plug->supportsFeature('HelpPage') > 0 )
4249 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4250 if ( @file_exists($helpfile . 'php') )
4252 @include($helpfile . 'php');
4255 elseif ( @file_exists($helpfile . 'html') )
4257 @include($helpfile . 'html');
4261 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4262 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4267 * AdminActions::parse_pluginlistlist()
4268 * Parse skinvar pluginlistlist
4270 * @param string $templateName name of template to use
4273 public function parse_pluginlistlist($templateName = '')
4275 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4276 $query = sprintf($query, sql_table('plugin'));
4277 $template['content'] = 'pluginlist';
4278 $template['tabindex'] = 10;
4279 Showlist($query, 'table', $template, $templateName);
4284 * AdminActions::parse_pluginoptions()
4285 * Parse skinvar pluginoptions
4287 * @param string $type type of plugin option
4290 public function parse_pluginoptions($type = 'global')
4295 $id = intRequestVar('memberid');
4298 $id = intRequestVar('blogid');
4301 $id = intRequestVar('catid');
4307 Admin::insertPluginOptions($type, $id);
4312 * AdminActions::parse_qmenuaddselect()
4313 * Parse skinvar qmanuaddselect
4315 * @param string $templateName name of template to use
4318 public function parse_qmenuaddselect($templateName = '')
4321 $showAll = requestVar('showall');
4322 if ( $member->isAdmin() && ($showAll == 'yes') )
4324 // Super-Admins have access to all blogs! (no add item support though)
4325 $query = 'SELECT bnumber as value, bname as text'
4326 . ' FROM ' . sql_table('blog')
4327 . ' ORDER BY bname';
4331 $query = 'SELECT bnumber as value, bname as text'
4332 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4333 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4334 . ' ORDER BY bname';
4336 $template['name'] = 'blogid';
4337 $template['tabindex'] = 15000;
4338 $template['extra'] = _QMENU_ADD_SELECT;
4339 $template['selected'] = -1;
4340 $template['shorten'] = 10;
4341 $template['shortenel'] = '';
4342 $template['javascript'] = 'onchange="return form.submit()"';
4343 Showlist($query, 'select', $template, $templateName);
4348 * AdminActions::parse_quickmenu()
4349 * Parse skinvar quickmenu
4351 * @param string $templateName name of template to use
4354 public function parse_quickmenu($templateName = '')
4357 $templates = array();
4358 $template = array();
4359 if ( !empty($templateName) )
4361 $templates = Template::read($templateName);
4363 $pluginExtras = array();
4367 'options' => &$pluginExtras
4370 if ( count($pluginExtras) > 0 )
4372 if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4374 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4378 $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
4380 $handler = new Actions($this->skintype, $template, $this->objAdmin);
4381 $parser = new PARSER(Actions::getDefinedActions(), $handler);
4382 $parser->parse($template['title']);
4384 if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4386 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4390 $template['head'] = '<ul>';
4393 echo $template['head'];
4395 if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
4397 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4401 $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
4404 foreach ( $pluginExtras as $aInfo )
4407 'plugadminurl' => Entity::hsc($aInfo['url']),
4408 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4409 'plugadmintitle' => Entity::hsc($aInfo['title']),
4411 echo Template::fill($template['body'], $data);
4413 if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4415 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4419 $template['foot'] = '</ul>';
4421 echo $template['foot'];
4427 * AdminActions::parse_requestblogid()
4428 * Parse skinvar requestblogid
4433 public function parse_requestblogid()
4435 echo intRequestVar('blogid');
4440 * AdminActions::parse_requestiprange()
4441 * Parse skinvar requestiprange
4446 public function parse_requestiprange()
4448 if ( requestVar('iprange') )
4450 echo Entity::hsc(requestVar('iprange'));
4452 elseif ( requestVar('ip') )
4454 echo Entity::hsc(requestVar('ip'));
4460 * AdminActions::parse_selectlocaladminskinfiles()
4461 * Parse skinvar selectlocaladminskinfiles
4466 public function parse_selectlocaladminskinfiles()
4469 global $DIR_SKINS, $manager;
4470 $adminskindir = $DIR_SKINS . 'admin/';
4471 $candidates = SkinImport::searchForCandidates($adminskindir);
4472 foreach ( $candidates as $skinname => $skinfile )
4474 $html = Entity::hsc($skinfile);
4475 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4481 * AdminActions::parse_selectlocalskinfiles()
4482 * Parse skinvar selectlocalskinfiles
4487 public function parse_selectlocalskinfiles()
4490 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4491 foreach ( $candidates as $skinname => $skinfile )
4493 $html = Entity::hsc($skinfile);
4494 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4500 * AdminActions::parse_skineditallowedlist()
4501 * Parse skinvar skineditallowedlist
4503 * @param string $type type of skin
4504 * @param string $templateName name of template
4507 public function parse_skineditallowedlist($type, $templateName = '')
4512 $query = "SELECT bshortname, bname FROM %s";
4514 'content' => 'shortblognames'
4516 $query = sprintf($query, sql_table('blog'));
4517 Showlist($query, 'table', $show, $templateName);
4520 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname NOT LIKE 'admin/%%'";
4522 'content' => 'shortnames'
4524 $query = sprintf($query, sql_table('template_desc'));
4525 Showlist($query, 'table', $show, $templateName);
4532 * AdminActions::parse_skinielist()
4533 * Parse skinvar skinielist
4535 * @param string $type type of skin
4536 * @param string $templateName name of template to use
4539 public function parse_skinielist($type, $templateName = '')
4541 $templates = array();
4542 if ( $templateName )
4544 $templates = Template::read($templateName);
4546 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4548 $template = $templates['SKINIE_EXPORT_LIST'];
4552 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
4553 . "<td><%expdesc%></td>\n"
4559 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
4560 while ( $skinObj = sql_fetch_object($res) )
4563 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
4564 'expid' => 'skinexp' . $skinObj->sdnumber,
4565 'expname' => Entity::hsc($skinObj->sdname),
4566 'expdesc' => Entity::hsc($skinObj->sddesc),
4568 echo Template::fill($template, $data);
4572 $res = sql_query('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%'");
4573 while ($templateObj = sql_fetch_object($res)) {
4575 'typeid' => 'template[' . $templateObj->tdnumber . ']',
4576 'expid' => 'templateexp' . $templateObj->tdnumber,
4577 'expname' => Entity::hsc($templateObj->tdname),
4578 'expdesc' => Entity::hsc($templateObj->tddesc),
4580 echo Template::fill($template, $data);
4588 * AdminActions::parse_skinoverview()
4589 * Parse skinvar skinoverview
4591 * @param string $templateName name of template to use
4594 public function parse_skinoverview($templateName = '')
4597 $query = "SELECT * FROM %s WHERE sdincmode != 'admin' ORDER BY sdname";
4598 $query = sprintf($query, sql_table('skin_desc'));
4600 $template['content'] = 'skinlist';
4601 $template['tabindex'] = 10;
4602 // $template['friendly_names'] = Skin::getFriendlyNames('Actions');
4603 $skin = new Skin($CONF['BaseSkin']);
4604 $template['friendly_names'] = $skin->getDefaultTypes();
4606 Showlist($query, 'table', $template, $templateName);
4611 * AdminActions::parse_skintypehelp()
4612 * Check editing skintypehelp
4617 public function parse_skintypehelp()
4619 $nowSkinType = strtolower(trim(requestVar('type')));
4620 $regularType = array(
4631 if ( in_array($nowSkinType, $regularType) )
4633 help('skinpart' . $nowSkinType);
4637 help('skinpartspecial');
4643 * AdminActions::parse_specialskinlist()
4644 * Parse skinvar specialskinlist
4646 * @param string $templateName name of template to use
4649 public function parse_specialskinlist($templateName = '')
4651 $templates = array();
4652 if ( $templateName )
4654 $templates = Template::read($templateName);
4666 $skinid = intRequestVar('skinid');
4667 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4668 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4670 $res = sql_query($query);
4671 if ( $res && sql_num_rows($res) > 0 )
4674 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4676 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4680 $template['head'] = "<ul>\n";
4682 echo Template::fill($template['head'], $data);
4683 if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
4685 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4689 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4690 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4691 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4694 while ( $row = sql_fetch_assoc($res) )
4697 'tabindex' => $tabstart++,
4698 'skinid' => $skinid,
4699 'skintype' => Entity::hsc(strtolower($row['stype']))
4701 echo Template::fill($template['body'], $data);
4704 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4706 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4710 $template['foot'] = "</ul>\n";
4712 echo Template::fill($template['foot'], $data);
4718 * AdminActions::parse_sprinttext()
4721 * @param string $which
4722 * @param string $val
4725 public function parse_sprinttext($which, $val)
4727 if ( !defined($which) )
4733 $base = constant($which);
4736 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4738 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4740 $met = 'parse_' . $matchies[0];
4744 $arg = trim($args[0], '()');
4745 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4748 if ( method_exists($this, $met) )
4750 $value = call_user_func(array(&$this, $met), $arg);
4754 if ( !isset($value) || empty($value) )
4758 echo sprintf($base, $value);
4763 * AdminActions::parse_systemsettings()
4764 * Parse skinvar systemsettings
4766 * @param string $type type of settings for system
4767 * @param string $templateName name of template to use
4770 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4772 global $member, $CONF, $nucleus;
4774 $member->isAdmin() or Admin::disallow();
4776 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4777 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4784 case 'sqlserverinfo':
4785 echo sql_get_server_info();
4787 case 'sqlclientinfo':
4788 echo sql_get_client_info();
4790 case 'magicquotesgpc':
4791 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4793 case 'magicquotesruntime':
4794 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4796 case 'registerglobals':
4797 echo ini_get('register_globals') ? 'On' : 'Off';
4800 $templates = array();
4801 if ( $templateName )
4803 $templates = Template::read($templateName);
4805 if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
4807 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4811 $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
4814 $gdinfo = gd_info();
4816 foreach ( $gdinfo as $key => $value )
4818 if ( is_bool($value) )
4820 $value = $value ? $enable : $disable;
4824 $value = Entity::hsc($value);
4830 echo Template::fill($template, $data);
4835 phpinfo(INFO_MODULES);
4836 $im = ob_get_contents();
4838 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4840 case 'nucleusversion':
4841 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4843 case 'nucleuspatchlevel':
4844 echo getNucleusPatchLevel();
4850 echo $CONF['ItemURL'];
4852 case 'alertonheaderssent':
4853 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4855 case 'nucleuscodename':
4856 if ( $nucleus['codename'] != '' )
4858 echo ' "' . $nucleus['codename'] . '"';
4861 case 'versioncheckurl':
4862 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4869 * AdminActions::parse_templateoverview()
4870 * Parse skinvar templateoverview
4872 * @param string $templateName name of template to use
4875 public function parse_templateoverview($templateName = '')
4877 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4878 $query = sprintf($query, sql_table('template_desc'));
4879 $template['content'] = 'templatelist';
4880 $template['tabindex'] = 10;
4881 Showlist($query, 'table', $template, $templateName);
4886 * AdminActions::parse_ticket()
4892 public function parse_ticket()
4895 $manager->addTicketHidden();
4900 * AdminActions::parse_versioncheckurl()
4901 * Parse skinvar versioncheckurl
4906 public function parse_versioncheckurl()
4908 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4913 * AdminActions::parse_yrbloglist()
4914 * Parse skinvar yrbloglist
4916 * @param string $templateName name of template to use
4919 public function parse_yrbloglist($templateName = '')
4922 $showAll = requestVar('showall');
4924 if ( $member->isAdmin() && ($showAll == 'yes') )
4926 // Super-Admins have access to all blogs! (no add item support though)
4927 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4929 . " ORDER BY bnumber";
4930 $query = sprintf($query, sql_table('blog'));
4934 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4936 . " WHERE tblog=bnumber and tmember=%d"
4937 . " ORDER BY bnumber";
4938 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4941 $template['content'] = 'bloglist';
4942 $template['superadmin'] = $member->isAdmin();
4944 $amount = Showlist($query, 'table', $template, $templateName);
4946 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4948 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4950 $total = quickQuery($query);
4951 if ( $total > $amount )
4953 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4959 echo _OVERVIEW_NOBLOGS;
4961 elseif( $amount != 0 )
4963 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4965 $query = "SELECT ititle, inumber, bshortname"
4967 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
4968 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4970 $template['content'] = 'draftlist';
4972 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4973 if ( $amountdrafts == 0 )
4975 echo _OVERVIEW_NODRAFTS;
4982 * AdminActions::checkCondition()
4983 * Checks conditions for if statements
4985 * @param string $field type of <%if%>
4986 * @param string $name property of field
4987 * @param string $value value of property
4988 * @return boolean condition
4990 protected function checkCondition($field, $name='', $value = '')
4992 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
5003 $blog =& $manager->getBlog($blogid);
5007 $blogid = getBlogIDFromCatID($catid);
5009 $blog =& $manager->getBlog($blogid);
5011 elseif ( intRequestVar('catid') )
5013 $catid = intRequestVar('catid');
5014 $blogid = getBlogIDFromCatID($catid);
5016 $blog =& $manager->getBlog($blogid);
5023 $condition = ($blog && $this->ifCategory($name, $value));
5026 $condition = ($blog && ($blog->getSetting($name) == $value));
5029 $condition = $member->isLoggedIn();
5032 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5035 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5038 $condition = $member->isLoggedIn() && $member->isAdmin();
5040 case 'allowloginedit':
5041 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5044 $condition = ($itemidnext != '');
5047 $condition = ($itemidprev != '');
5049 case 'archiveprevexists':
5050 $condition = ($archiveprevexists == true);
5052 case 'archivenextexists':
5053 $condition = ($archivenextexists == true);
5056 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5059 $condition = $this->ifHasPlugin($name, $value);
5062 $condition = (Admin::getAdminAction() == $name);
5064 case 'adminoldaction':
5065 $condition = (Admin::getAdminAction() == $name);
5067 case 'addresschange':
5068 $condition = ($this->ifAddresscange());
5070 case 'bechangepass':
5071 $condition = ($this->beChangePassword());
5073 case 'skincandidates':
5074 $condition = ($this->ifSkincandidates());
5077 $condition = requestVar('nameclashes');
5079 case 'existsnewplugin':
5080 $condition = ($this->existsNewPlugin());
5083 $condition = (boolean) ($member->getAutosave() == $value);
5086 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5093 * Actions::_ifHasPlugin()
5094 * hasplugin,PlugName
5095 * -> checks if plugin exists
5096 * hasplugin,PlugName,OptionName
5097 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5098 * hasplugin,PlugName,OptionName=value
5099 * -> checks if the option OptionName from plugin PlugName is set to value
5101 * @param string $name name of plugin
5102 * @param string $value
5105 private function ifHasPlugin($name, $value)
5109 // (pluginInstalled method won't write a message in the actionlog on failure)
5110 if ( $manager->pluginInstalled("NP_{$name}") )
5112 $plugin =& $manager->getPlugin("NP_{$name}");
5113 if ( $plugin != NULL )
5121 list($name2, $value2) = preg_split('#=#', $value, 2);
5122 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5126 else if ( $plugin->getOption($name2) == $value2 )
5137 * Actions::beChangePassword()
5142 private function beChangePassword()
5144 return intRequestVar('bNeedsPasswordChange');
5148 * Actions::ifSkincandidates()
5149 * Checks if a plugin exists and call its doIf function
5154 private function ifSkincandidates()
5157 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5158 return (count($candidates) > 0);
5162 * Actions::ifPlugin()
5163 * Checks if a plugin exists and call its doIf function
5165 private function ifPlugin($name, $key = '', $value = '')
5169 $plugin =& $manager->getPlugin("NP_{$name}");
5175 $params = func_get_args();
5176 array_shift($params);
5178 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5182 * Different checks for a category
5184 private function ifCategory($name = '', $value='')
5186 global $blog, $catid;
5188 // when no parameter is defined, just check if a category is selected
5189 if (($name != 'catname' && $name != 'catid') || ($value == ''))
5191 return $blog->isValidCategory($catid);
5194 // check category name
5195 if ( $name == 'catname' )
5197 $value = $blog->getCategoryIdFromName($value);
5198 if ($value == $catid)
5200 return $blog->isValidCategory($catid);
5204 // check category id
5205 if (($name == 'catid') && ($value == $catid))
5207 return $blog->isValidCategory($catid);
5214 * Checks if a member is on the team of a blog and return his rights
5216 private function ifOnTeam($blogName = '')
5218 global $blog, $member, $manager;
5220 // when no blog found
5221 if ( ($blogName == '') && !is_object($blog) )
5226 // explicit blog selection
5227 if ($blogName != '')
5229 $blogid = getBlogIDFromName($blogName);
5232 if (($blogName == '') || !$manager->existsBlogID($blogid))
5235 $blogid = $blog->getID();
5237 return $member->teamRights($blogid);
5241 * Checks if a member is admin of a blog
5243 private function ifAdmin($blogName = '')
5245 global $blog, $member, $manager;
5247 // when no blog found
5248 if (($blogName == '') && (!is_object($blog)))
5253 // explicit blog selection
5254 if ($blogName != '')
5256 $blogid = getBlogIDFromName($blogName);
5259 if (($blogName == '') || !$manager->existsBlogID($blogid))
5262 $blogid = $blog->getID();
5265 return $member->isBlogAdmin($blogid);
5269 * Check e-Mail address is changed
5271 private function ifAddresscange()
5273 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5278 $info = MEMBER::getActivationInfo($key);
5283 $mem = MEMBER::createFromId($info->vmember);
5288 if ( $info->vtype == 'addresschange' )
5296 * AdminActions::customHelp()
5297 * shows a link to custom help file
5300 * @param string $tplName
5301 * @param string $url
5302 * @param string $iconURL
5303 * @param string $alt
5304 * @param string $title
5308 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5310 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5314 * AdminActions::customHelp()
5315 * shows a link to custom help file
5318 * @param string $tplName
5319 * @param string $url
5320 * @param string $iconURL
5321 * @param string $alt
5322 * @param string $title
5326 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5328 $templates = array();
5330 $templates = Template::read($tplName);
5332 if (isset($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) && !empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR'])) {
5333 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5335 $template = '<a href="<%helpurl%>#<%helptarget%>" title="<%title%>" <%onclick%>>';
5339 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5341 if (empty($onclick)) {
5342 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5343 } elseif (preg_match('/^onclick/', $onclick)) {
5344 $onclick = $onclick;
5346 $onclick = 'onclick="' . $onclick . '"';
5350 'helptarget' => $id,
5351 'onclick' => $onclick,
5352 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5354 return Template::fill($template, $data);
5358 * AdminActions::customHelpHtml()
5361 * @param string $tplName
5362 * @param string $url
5363 * @param string $iconURL
5364 * @param string $alt
5365 * @param string $title
5366 * @param string $onclick
5367 * @return string anchor element with help uri
5369 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5371 $templates = array();
5374 $templates = Template::read($tplName);
5376 if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5378 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5382 $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
5385 if ( empty($iconURL) )
5388 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5390 if ( function_exists('getimagesize') )
5392 $size = getimagesize($iconURL);
5393 $width = 'width="' . $size[0] . '" ';
5394 $height = 'height="' . $size[1] . '" ';
5397 'iconurl' => $iconURL,
5399 'height' => $height,
5400 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5401 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5403 $icon = Template::fill($template, $data);
5404 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5405 return $help . $icon;
5409 * AdminActions::input_yesno
5412 * @param $checkedval
5419 * @param $templateName
5422 private function input_yesno($name,
5433 $templates = array();
5434 if ( $templateName )
5436 $templates = Template::read($templateName);
5439 if ( $name == 'admin' )
5441 if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5443 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5447 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5448 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5449 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5450 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5455 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5457 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5461 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5463 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5466 if ( !isset($template) )
5468 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5469 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5470 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5471 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5476 $id = Entity::hsc($name);
5477 $id = str_replace('[', '-', $id);
5478 $id = str_replace(']', '-', $id);
5479 $id1 = $id . Entity::hsc($value1);
5480 $id2 = $id . Entity::hsc($value2);
5482 'name' => Entity::hsc($name),
5483 'yesval' => Entity::hsc($value1),
5484 'noval' => Entity::hsc($value2),
5487 'yesvaltext' => $yesval,
5488 'novaltext' => $noval,
5489 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5490 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5491 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5496 return Template::fill($template, $dat);
5500 echo Template::fill($template, $dat);
5506 * Check exists new plugin
5508 private function existsNewPlugin()
5510 global $DIR_PLUGINS;
5511 $candidates = array();
5512 $files = scandir($DIR_PLUGINS);
5513 foreach ($files as $file) {
5514 if (preg_match("/^NP_(.*)\.php$/", $file, $matches)) {
5515 $name = $matches[1];
5519 . sql_table('plugin') . ' '
5521 . ' pfile = "NP_' . sql_real_escape_string($name) . '"';
5522 $res = sql_query($que);
5523 if (sql_num_rows($res) == 0) {
5524 $candidates[] = $name;
5528 $this->newPlugCandidates = $candidates;
5529 return (count($candidates) > 0);