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 'batchteam' => _ADM_SKPRT_BATCHTEAM,
181 'blogcommentlist' => _ADM_SKPRT_BLOGCOMMENTLIST,
182 'blogselectbox' => _ADM_SKPRT_BLOGSELECTBOX,
183 'blogsettings' => _ADM_SKPRT_BLOGSETTINGS,
184 'bookmarklet' => _ADM_SKPRT_BOOKMARKLET,
185 'browseowncomments' => _ADM_SKPRT_BROWSEOWNCOMMENTS,
186 'browseownitems' => _ADM_SKPRT_BROWSEOWNITEMS,
187 'categorydelete' => _ADM_SKPRT_CATEGORYDELETE,
188 'categoryedit' => _ADM_SKPRT_CATEGORYEDIT,
189 'commentdelete' => _ADM_SKPRT_COMMENTDELETE,
190 'commentedit' => _ADM_SKPRT_COMMENTEDIT,
191 'createitem' => _ADM_SKPRT_CREATEITEM,
192 'createnewlog' => _ADM_SKPRT_CREATENEWLOG,
193 'deleteblog' => _ADM_SKPRT_DELETEBLOG,
194 'editmembersettings' => _ADM_SKPRT_EDITMEMBERSETTINGS,
195 'insertpluginoptions' => _ADM_SKPRT_INSERTPLUGINO,
196 'itemcommentlist' => _ADM_SKPRT_ITEMCOMMENTLIST,
197 'itemdelete' => _ADM_SKPRT_ITEMDELETE,
198 'itemedit' => _ADM_SKPRT_ITEMEDIT,
199 'itemlist' => _ADM_SKPRT_ITEMLIST,
200 'itemmove' => _ADM_SKPRT_ITEMMOVE,
201 'login' => FALSE, //missing
202 'manage' => _ADM_SKPRT_MANAGE,
203 'manageteam' => _ADM_SKPRT_MANAGETEAM,
204 'memberdelete' => _ADM_SKPRT_MEMBERDELETE,
205 'memberedit' => FALSE, //missing
206 'overview' => _ADM_SKPRT_OVERVIEW,
207 'pagefoot' => _ADM_SKPRT_PAGEFOOT,
208 'pagehead' => _ADM_SKPRT_PAGEHEAD,
209 'plugindelete' => _ADM_SKPRT_PLUGINDELETE,
210 'pluginhelp' => _ADM_SKPRT_PLUGINHELP,
211 'pluginlist' => _ADM_SKPRT_PLUGINLIST,
212 'pluginoptions' => _ADM_SKPRT_PLUGINOPTIONS,
213 'settingsedit' => _ADM_SKPRT_SETTINGSEDIT,
214 'showlogin' => _ADM_SKPRT_SHOWLOGIN,
215 'skindelete' => _ADM_SKPRT_SKINDELETE,
216 'skinedit' => _ADM_SKPRT_SKINEDIT,
217 'skinedittype' => _ADM_SKPRT_SKINEDITTYPE,
218 'skiniedoimport' => _ADM_SKPRT_SKINIEDOIMPORT,
219 'skinieimport' => _ADM_SKPRT_SKINIEIMPORT,
220 'skinieoverview' => _ADM_SKPRT_SKINIEOVERVIEW,
221 'skinoverview' => _ADM_SKPRT_SKINOVERVIEW,
222 'skinremovetype' => _ADM_SKPRT_SKINREMOVETYPE,
223 'systemoverview' => _ADM_SKPRT_SYSTEMOVERVIEW,
224 'teamdelete' => _ADM_SKPRT_TEAMDELETE,
225 'templatedelete' => _ADM_SKPRT_TEMPLATEDELETE,
226 'templateedit' => _ADM_SKPRT_TEMPLATEEDIT,
227 'templateoverview' => _ADM_SKPRT_TEMPLATEOVERVIEW,
228 'usermanagement' => _ADM_SKPRT_USERMANAGEMENT,
232 * AdminActions::getDefinedActions()
235 * @param string $type page type
236 * @return array allowed actions for the page type
238 static public function getDefinedActions($type = '')
240 $extra_actions = array();
245 $extra_actions = array(
250 $extra_actions = array(
255 case 'activatesetpwd':
256 $extra_actions = array(
260 $extra_actions = array(
266 case 'adminerrorpage':
267 $extra_actions = array(
270 case 'adminskindelete':
271 $extra_actions = array(
275 case 'adminskinedit':
276 $extra_actions = array(
278 'defaultadminskintypes',
279 'adminspecialskinlist',
282 case 'adminskinedittype':
283 $extra_actions = array(
286 'allowedadminskinactions',
287 'adminskineditallowedlist',
290 case 'adminskiniedoimport':
291 $extra_actions = array(
295 case 'adminskinieimport':
296 $extra_actions = array(
300 case 'adminskinieoverview':
301 $extra_actions = array(
302 'selectlocaladminskinfiles',
306 case 'adminskinoverview':
307 $extra_actions = array(
311 case 'adminskinremovetype':
312 $extra_actions = array(
316 case 'admintemplateedit':
317 $extra_actions = array(
318 'editadmintemplateinfo',
321 case 'admntemplateoverview':
322 $extra_actions = array(
323 'admintemplateoverview',
326 case 'backupoverview':
327 $extra_actions = array(
330 case 'backuprestore':
331 $extra_actions = array(
335 $extra_actions = array(
341 case 'banlistdelete':
342 $extra_actions = array(
347 case 'banlistdeleteconfirm':
348 $extra_actions = array(
349 'banlistdeletedlist',
354 $extra_actions = array(
360 case 'batchcategory':
361 $extra_actions = array(
367 $extra_actions = array(
373 $extra_actions = array(
379 $extra_actions = array(
385 $extra_actions = array(
391 $extra_actions = array(
400 $extra_actions = array(
409 $extra_actions = array(
415 case 'blogcommentlist':
416 $extra_actions = array(
422 case 'blogselectbox':
423 $extra_actions = array(
428 $extra_actions = array(
443 $extra_actions = array(
447 case 'browseowncomments':
448 $extra_actions = array(
452 case 'browseownitems':
453 $extra_actions = array(
457 case 'categorydelete':
458 $extra_actions = array(
464 $extra_actions = array(
470 case 'commentdelete':
471 $extra_actions = array(
476 $extra_actions = array(
481 $extra_actions = array(
492 $extra_actions = array(
498 $extra_actions = array(
503 case 'editmembersettings':
504 $extra_actions = array(
506 'languageselectoptions',
507 'adminskinselectoptions',
511 case 'insertpluginoptions':
512 $extra_actions = array(
513 'insertpluginoptions',
516 case 'itemcommentlist':
517 $extra_actions = array(
523 $extra_actions = array(
530 $extra_actions = array(
542 $extra_actions = array(
549 $extra_actions = array(
555 $extra_actions = array(
559 $extra_actions = array(
568 $extra_actions = array(
573 $extra_actions = array(
578 $extra_actions = array(
586 $extra_actions = array(
599 $extra_actions = array(
604 $extra_actions = array(
610 $extra_actions = array(
615 case 'pluginoptions':
616 $extra_actions = array(
618 'editplugoptionslist',
622 $extra_actions = array(
625 'configsettingsedit',
626 'languageselectoptions',
627 'configsettingsyesno',
635 $extra_actions = array(
640 $extra_actions = array(
645 $extra_actions = array(
651 $extra_actions = array(
654 'allowedskinactions',
655 'skineditallowedlist',
656 'skineditallowedlist',
659 case 'skiniedoimport':
660 $extra_actions = array(
665 $extra_actions = array(
669 case 'skinieoverview':
670 $extra_actions = array(
671 'selectlocalskinfiles',
676 $extra_actions = array(
680 case 'skinremovetype':
681 $extra_actions = array(
685 case 'systemoverview':
686 $extra_actions = array(
691 $extra_actions = array(
697 case 'templatedelete':
698 $extra_actions = array(
703 $extra_actions = array(
707 case 'templateoverview':
708 $extra_actions = array(
712 case 'usermanagement':
713 $extra_actions = array(
719 $extra_actions = array(
729 'selectlocaladminskinfiles',
737 $defined_actions = array_merge(self::$default_actions, $extra_actions);
739 return array_merge($defined_actions, parent::getDefinedActions());
743 * AdminActions::getDefaultSkinTypes()
747 * @return array list of friendly names for page actions
749 static public function getDefaultSkinTypes()
751 return self::$default_skin_types;
755 * AdminActions::getDefaultTypes()
759 * @return array list of friendly names for page actions
761 static public function getDefaultTypes()
763 return self::$default_skin_types;
767 * AdminActions::__construct()
768 * Constructor for a new Actions object
770 * @param string $type
773 public function __construct($type)
775 // call constructor of superclass first
776 parent::__construct();
777 $this->skintype = $type;
778 if ( !class_exists('Navlist') || !class_exists('Batch') )
781 include $DIR_LIBS . 'ENCAPSULATE.php';
787 * AdminActions::setSkin()
789 * @param object $skin an instance of Skin class
792 public function setSkin(&$skin)
794 $this->skin =& $skin;
799 * AdminActions::setParser()
802 * @param object $parser an instance of Parser class
805 public function setParser(&$parser)
807 $this->parser =& $parser;
812 * AdminActions::parse_actionloglist()
813 * Parse skinvar actionloglist
815 * @param string $templateName name of template to use
818 public function parse_actionloglist($templateName = '')
820 $query = "SELECT * FROM %s ORDER BY timestamp DESC";
821 $query = sprintf($query, sql_table('actionlog'));
823 $template['content'] = 'actionlist';
824 $amount = showlist($query, 'table', $template, $templateName);
830 * AdminActions::parse_activationmessage()
831 * Parse skinvar activationmessage
833 * @param string $type type of message
834 * @param string $templateName name of template to use
837 public function parse_activationmessage($type, $templateName = '')
839 global $CONF, $manager;
843 if ( !empty($templateName))
845 $template = Template::read($templateName);
848 $key = postVar('ackey');
851 Admin::error(_ERROR_ACTIVATE);
854 $info = MEMBER::getActivationInfo($key);
857 Admin::error(_ERROR_ACTIVATE);
860 $mem = MEMBER::createFromId($info->vmember);
863 Admin::error(_ERROR_ACTIVATE);
865 switch ( $info->vtype )
868 if ( array_key_exists('ACTIVATE_FORGOT_TITLE', $template) && !empty($template['ACTIVATE_FORGOT_TITLE']) )
870 $title = $template['ACTIVATE_FORGOT_TITLE'];
874 $title = _ACTIVATE_FORGOT_TITLE;
876 if ( array_key_exists('ACTIVATE_FORGOT_TEXT', $template) && !empty($template['ACTIVATE_FORGOT_TEXT']) )
878 $text = $template['ACTIVATE_FORGOT_TEXT'];
882 $text = _ACTIVATE_FORGOT_TEXT;
886 if ( array_key_exists('ACTIVATE_REGISTER_TITLE', $template) && !empty($template['ACTIVATE_REGISTER_TITLE']) )
888 $title = $template['ACTIVATE_REGISTER_TITLE'];
892 $title = _ACTIVATE_REGISTER_TITLE;
894 if ( array_key_exists('ACTIVATE_REGISTER_TEXT', $template) && !empty($template['ACTIVATE_REGISTER_TEXT']) )
896 $text = $template['ACTIVATE_REGISTER_TEXT'];
900 $text = _ACTIVATE_REGISTER_TEXT;
903 case 'addresschange':
904 if ( array_key_exists('ACTIVATE_CHANGE_TITLE', $template) && !empty($template['ACTIVATE_CHANGE_TITLE']) )
906 $title = $template['ACTIVATE_CHANGE_TITLE'];
910 $title = _ACTIVATE_CHANGE_TITLE;
912 if (array_key_exists('ACTIVATE_CHANGE_TEXT', $template) && !empty($template['ACTIVATE_CHANGE_TEXT']))
914 $text = $template['ACTIVATE_CHANGE_TEXT'];
918 $text = _ACTIVATE_CHANGE_TEXT;
923 'memberName' => Entity::hsc($mem->getDisplayName()),
924 'realName' => Entity::hsc($mem->getRealName()),
929 echo TEMPLATE::fill($title, $aVars);
932 echo TEMPLATE::fill($text, $aVars);
935 echo Entity::hsc($key);
942 * AdminActions::parse_addtickettourl()
943 * Parse skinvar addtickettourl
945 * @param string $url URI for ticket
948 public function parse_addtickettourl($url)
951 $url = $manager->addTicketToUrl($url);
952 echo Entity::hsc($url);
957 * AdminActions::parse_adminbanlist()
958 * Parse skinvar adminbanlist
960 * @param string $templateName name of template to use
963 public function parse_adminbanlist($templateName = '')
965 $blogid = intRequestVar('blogid');
967 $query = "SELECT * FROM %s WHERE blogid=%d ORDER BY iprange;";
968 $query = sprintf($query, sql_table('ban'), (integer) $blogid);
970 $template['content'] = 'banlist';
972 $amount = Showlist($query, 'table', $template, $templateName);
982 * AdminActions::parse_adminbatchaction()
983 * Parse skinvar adminbatchaction
988 public function parse_adminbatchaction()
990 echo Entity::hsc(requestVar('batchaction'));
995 * AdminActions::parse_adminbatchlist()
996 * Parse skinvar adminbatchlist
998 * @param string $templateName name of template to use
1001 public function parse_adminbatchlist($templateName = '')
1004 $templates = array();
1005 if ( !empty($templateName) )
1007 $templates = Template::read($templateName);
1009 if ( isset($templates['ADMIN_BATCHLIST']) || !empty($templates['ADMIN_BATCHLIST']) )
1011 $template = $templates['ADMIN_BATCHLIST'];
1015 $template = '<li><%text(_BATCH_EXECUTING)%>'
1016 . '<b><%adminbatchaction%></b>'
1017 . '<%batchlisttype%>'
1018 . '<b><%batchid%></b>...'
1019 . '<b><%batchlistmsg%></b>'
1023 $selected = requestIntArray('batch');
1024 $action = requestVar('batchaction');
1026 switch ( $this->skintype )
1029 $batchlisttype = _BATCH_ONITEM;
1030 $deleteaction = 'deleteOneItem';
1031 $moveaction = 'moveOneItem';
1032 $destid = intRequestVar('destcatid');
1034 case 'batchcomment':
1035 $batchlisttype = _BATCH_ONCOMMENT;
1036 $deleteaction = 'deleteOneComment';
1039 $batchlisttype = _BATCH_ONMEMBER;
1040 $deleteaction = 'deleteOneMember';
1041 $setadminsql = sql_table('member') . ' SET madmin = 1 WHERE mnumber = ';
1042 $unsetchksql = 'SELECT * FROM ' . sql_table('member') . ' WHERE madmin = 1 AND mcanlogin = 1';
1043 $unsetupsql = sql_table('member') . ' SET madmin = 0 WHERE mnumber = ';
1044 $unseterrmsg = _ERROR_ATLEASTONEADMIN;
1047 $blogid = intRequestVar('blogid');
1048 $batchlisttype = _BATCH_ONTEAM;
1049 $deleteaction = 'deleteOneTeamMember';
1050 $setadminsql = sql_table('team') . ' SET tadmin = 1 WHERE tblog = ' . $blogid . ' AND tmember = ';
1051 $unsetchksql = 'SELECT * FROM ' . sql_table('team') . ' WHERE tadmin = 1 AND tblog = ' . $blogid;
1052 $unseterrmsg = _ERROR_ATLEASTONEBLOGADMIN;
1053 $unsetupsql = sql_table('team') . ' SET tadmin = 0 WHERE tblog = ' . $blogid . ' AND tmember = ';
1055 case 'batchcategory':
1056 $batchlisttype = _BATCH_ONCATEGORY;
1057 $deleteaction = 'deleteOneCategory';
1058 $moveaction = 'moveOneCategory';
1059 $destid = intRequestVar('destblogid');
1063 // walk over all selectedids and perform action
1064 foreach ( $selected as $selectedid )
1067 $selectedid = intval($selectedid);
1071 if ( $this->skintype != 'batchteam' )
1073 $error = Admin::$deleteaction($selectedid);
1077 $error = Admin::deleteOneTeamMember($blogid, $selectedid);
1081 $error = Admin::moveaction($selectedid, $destid);
1085 sql_query('UPDATE ' . $setadminsql . $selectedid);
1089 // there should always remain at least one super-admin
1090 $r = sql_query($unsetchksql);
1091 if ( sql_num_rows($r) < 2 )
1093 $error = $unseterrmsg;
1097 sql_query('UPDATE ' . $unsetupsql . $selectedid);
1101 $error = _BATCH_UNKNOWN . Entity::hsc($action);
1104 'batchid' => $selectedid,
1105 'batchlisttype' => Entity::hsc($batchlisttype),
1106 'adminbatchaction' => Entity::hsc($action),
1107 'batchlistmsg' => $error ? $error : _BATCH_SUCCESS,
1109 $handler = new Actions('template', $template, new ADMIN);
1110 $parser = new Parser($handler);
1113 $parser->parse($template);
1114 $template = ob_get_contents();
1117 echo TEMPLATE::fill($template, $data);
1123 * AdminActions::parse_adminbloglink()
1124 * Parse skinvar adminbloglink
1126 * @param string $templateName name of template to use
1129 public function parse_adminbloglink($templateName = '')
1132 $blogid = intRequestVar('blogid');
1133 $blog =& $manager->getBlog($blogid);
1134 $templates = array();
1136 if ( !empty($templateName) )
1138 $templates = Template::read($templateName);
1141 if ( isset($templates['ADMIN_BLOGLINK']) || !empty($templates['ADMIN_BLOGLINK']) )
1143 $template = $templates['ADMIN_BLOGLINK'];
1147 $template = '<a href="<%url%>" title="<%adminbloglinktitle%>"><%blogname%></a>';
1151 'url' => Entity::hsc($blog->getURL()),
1152 'adminbloglinktitle' => _BLOGLIST_TT_VISIT,
1153 'blogname' => Entity::hsc($blog->getName())
1156 echo TEMPLATE::fill($template, $data);
1161 * AdminActions::parse_adminerrormesg()
1162 * Parse skinvar adminerrormesg
1167 public function parse_adminerrormesg()
1172 if ( requestVar('errormessage') )
1174 $message = requestVar('errormessage');
1176 elseif ( cookieVar($CONF['CookiePrefix'] . 'errormessage') )
1178 $message = cookieVar($CONF['CookiePrefix'] . 'errormessage');
1180 elseif ( Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage') )
1182 $message = Admin::sessionVar($CONF['CookiePrefix'] . 'errormessage');
1184 echo Entity::hsc($message);
1189 * AdminActions::parse_adminskineditallowedlist()
1190 * Parse skinvar adminskineditallowedlist
1192 * @param string $type template/blog
1193 * @param string $templateName name of template to use
1196 public function parse_adminskineditallowedlist($type = 'template', $templateName = '')
1200 /* TODO: blog seems not to be used */
1202 $query = "SELECT bshortname, bname FROM %s";
1203 $query = sprintf($query, sql_table('blog'));
1205 'content' => 'shortblognames'
1209 $query = "SELECT tdname as name, tddesc as description FROM %s WHERE tdname LIKE 'admin/%%'";
1210 $query = sprintf($query, sql_table('template_desc'));
1212 'content' => 'shortnames'
1216 Showlist($query, 'table', $show, $templateName);
1221 * AdminActions::parse_adminskinielist()
1222 * Parse skinvar adminskinielist
1224 * @param string $type skin/template
1225 * @param string $templateName name of template to use
1228 public function parse_adminskinielist($type, $templateName = '')
1230 $templates = array();
1231 if ( $templateName )
1233 $templates = Template::read($templateName);
1235 if ( isset($templates['SKINIE_EXPORT_LIST']) && !empty($templates['SKINIE_EXPORT_LIST']) )
1237 $template = $templates['SKINIE_EXPORT_LIST'];
1241 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
1242 . "<td><%expdesc%></td>\n"
1248 $query = "SELECT * FROM %s WHERE sdincmode = 'admin';";
1249 $query = sprintf($query, sql_table('skin_desc'));
1250 $res = sql_query($query);
1252 while ( $skinObj = sql_fetch_object($res) )
1255 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
1256 'expid' => 'skinexp' . $skinObj->sdnumber,
1257 'expname' => Entity::hsc($skinObj->sdname),
1258 'expdesc' => Entity::hsc($skinObj->sddesc),
1260 echo TEMPLATE::fill($template, $data);
1264 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%'";
1265 $query = sprintf($query, sql_table('template_desc'));
1266 $res = sql_query($query);
1267 while ( $templateObj = sql_fetch_object($res) )
1270 'typeid' => 'template[' . $templateObj->tdnumber . ']',
1271 'expid' => 'templateexp' . $templateObj->tdnumber,
1272 'expname' => Entity::hsc($templateObj->tdname),
1273 'expdesc' => Entity::hsc($templateObj->tddesc),
1275 echo TEMPLATE::fill($template, $data);
1283 * AdminActions::parse_adminskinoverview()
1284 * Parse skinvar adminskinoverview
1286 * @param string $templateName name of template to use
1289 public function parse_adminskinoverview($templateName = '')
1291 $query = "SELECT * FROM %s WHERE sdincmode = 'admin' ORDER BY sdname;";
1292 $query = sprintf($query, sql_table('skin_desc'));
1294 $template['content'] = 'adminskinlist';
1295 $template['tabindex'] = 10;
1296 $template['friendly_names'] = Skin::getAvailableTypes();
1297 Showlist($query, 'table', $template, $templateName);
1302 * AdminActions::parse_adminskinselectoptions()
1303 * Parse skinvar adminskinselectoptions
1308 public function parse_adminskinselectoptions()
1311 $query = "SELECT sdname as text, sdnumber as value FROM %s WHERE sdincmode = 'admin';";
1312 $query = sprintf($query, sql_table('skin_desc'));
1314 $template['name'] = 'adminskin';
1315 $template['selected'] = $CONF['DefaultAdminSkin'];
1316 $template['tabindex'] = 110;
1317 Showlist($query, 'select', $template, '');
1322 * AdminActions::parse_adminspecialskinlist()
1323 * Parse skinvar adminspecialskinlist
1325 * @param string $templateName name of template to use
1327 public function parse_adminspecialskinlist($templateName = '')
1329 $templates = array();
1330 if ( $templateName )
1332 $templates = Template::read($templateName);
1335 $nType = Skin::getFriendlyNames('AdminActions');
1336 $skinid = intRequestVar('skinid');
1338 $query = "SELECT stype FROM %s WHERE stype NOT IN (%s) AND sdesc=%d;";
1339 $query = sprintf($query, sql_table('skin'), "'" . implode("', '", $nType) . "'", (integer) $skinid);
1341 $res = sql_query($query);
1342 if ( $res && sql_num_rows($res) > 0 )
1345 if ( array_key_exists('ADMIN_SPECIALSKINLIST_HEAD', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_HEAD']) )
1347 $template['head'] = $templates['ADMIN_SPECIALSKINLIST_HEAD'];
1351 $template['head'] = "<ul>\n";
1353 echo TEMPLATE::fill($template['head'], $data);
1355 if ( array_key_exists('ADMIN_SPECIALSKINLIST_BODY', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_BODY']) )
1357 $template['body'] = $templates['ADMIN_SPECIALSKINLIST_BODY'];
1361 $template['body'] = '<li>'
1362 . '<a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
1365 . '(<a tabindex="<%tabindex%>" href="index.php?action=adminskinremovetype&skinid=<%skinid%>&type=<%skintype%>">'
1371 while ( $row = sql_fetch_assoc($res) )
1374 'tabindex' => $tabstart++,
1375 'skinid' => $skinid,
1376 'skintype' => Entity::hsc(strtolower($row['stype']))
1378 echo TEMPLATE::fill($template['body'], $data);
1382 if ( array_key_exists('ADMIN_SPECIALSKINLIST_FOOT', $templates) && !empty($templates['ADMIN_SPECIALSKINLIST_FOOT']) )
1384 $template['foot'] = $templates['ADMIN_SPECIALSKINLIST_FOOT'];
1388 $template['foot'] = "</ul>\n";
1390 echo TEMPLATE::fill($template['foot'], $data);
1396 * AdminActions::parse_admintemplateoverview()
1397 * Parse skinvar admintemplateoverview
1399 * @param string $templateName name of template to use
1402 public function parse_admintemplateoverview($templateName = '')
1404 $query = "SELECT * FROM %s WHERE tdname LIKE 'admin/%%' ORDER BY tdname;";
1405 $query = sprintf($query, sql_table('template_desc'));
1407 $template['content'] = 'admintemplatelist';
1408 $template['tabindex'] = 10;
1410 Showlist($query, 'table', $template, $templateName);
1415 * AdminActions::parse_allowedadminskinactions()
1416 * Parse skinvar allowedadminskinactions
1421 public function parse_allowedadminskinactions()
1423 global $DIR_ADMINSKINS;
1424 $skinType = strtolower(trim(requestVar('type')));
1425 $actions = Skin::getAllowedActionsForType($skinType);
1428 while ( $current = array_shift($actions) )
1430 // skip deprecated vars
1431 if ($current == 'ifcat' || $current == 'imagetext' || $current == 'vars')
1436 echo helplink("adminskinvar-{$current}") . "$current</a>\n";
1437 // echo "<a href=\"{$DIR_ADMINSKINS}documentation/help.html#{$current}\" onclick=\"if (event && event.preventDefault) event.preventDefault(); return help(this.href);\">{$current}</a>\n";
1439 if ( count($actions) != 0 )
1448 * AdminActions::parse_allowedskinactions()
1449 * Parse skinvar allowedskinactions
1454 public function parse_allowedskinactions()
1456 $skinType = strtolower(trim(requestVar('type')));
1457 $actions = SKIN::getAllowedActionsForType($skinType);
1460 while ( $current = array_shift($actions) )
1462 // skip deprecated vars
1463 if ( $current == 'ifcat' || $current == 'imagetext' || $current == 'vars' )
1468 /* TODO: alternative function should be used or not? */
1469 echo helplink("skinvar-{$current}") . "$current</a>\n";
1471 if ( count($actions) != 0 )
1480 * AdminActions::parse_banlistdeletedlist()
1481 * Parse skinvar banlistdeletedlist
1483 * @param string $templateName name of template to use
1486 public function parse_banlistdeletedlist($templateName = '')
1489 $templates = array();
1491 if ( $templateName )
1493 $templates = Template::read($templateName);
1495 if ( isset($templates['BANLIST_DELETED_LIST']) && !empty($templates['BANLIST_DELETED_LIST']) )
1497 $template = $templates['BANLIST_DELETED_LIST'];
1501 $template = "<li><%blogname%></li>\n";
1503 $deleted = requestArray('delblogs');
1504 foreach ( $deleted as $delblog )
1506 $blog =& $manager->getBlog($delblog);
1508 Entity::hsc($blog->getName())
1510 TEMPLATE::fill($template, $data);
1516 * AdminActions::parse_batchdeletelist()
1517 * Parse skinvar batchdeletelist
1522 public function parse_batchdeletelist()
1524 $selected = requestIntArray('batch');
1527 foreach ( $selected as $select )
1529 echo '<input type="hidden" name="batch[' . ($index++) . ']" value="' . intval($select) . "\" />\n";
1531 // add hidden vars for team & comment
1532 if ( requestVar('action') == 'batchteam' )
1534 echo '<input type="hidden" name="blogid" value="' . intRequestVar('blogid') . "\" />\n";
1536 if ( requestVar('action') == 'batchcomment' )
1538 echo '<input type="hidden" name="itemid" value="' . intRequestVar('itemid') . "\" />\n";
1544 * AdminActions::parse_batchdeletetype()
1545 * Parse skinvar batchdeletetype
1550 public function parse_batchdeletetype()
1552 echo Entity::hsc(requestVar('action'));
1557 * AdminActions::parse_batchmovebtn()
1558 * Parse skinvar batchmovebtn
1563 public function parse_batchmovebtn()
1565 $actionType = requestVar('action');
1566 switch ( $actionType )
1571 case 'batchcategory':
1579 * AdminActions::parse_batchmovelist()
1580 * Parse skinvar batchmovelist
1585 public function parse_batchmovelist()
1587 $selected = requestIntArray('batch');
1588 foreach ( $selected as $select )
1590 echo '<input type="hidden" name="batch[' . ($select++) . ']" value="' . intval($select) . "\" />\n";
1596 * AdminActions::parse_batchmovetitle()
1597 * Parse skinvar batchmovetitle
1602 public function parse_batchmovetitle()
1604 $actionType = requestVar('action');
1605 switch ( $actionType )
1610 case 'batchcategory':
1611 echo _MOVECAT_TITLE;
1618 * AdminActions::parse_batchmovetype()
1619 * Parse skinvar batchmovetype
1624 public function parse_batchmovetype()
1626 echo Entity::hsc(requestVar('action'));
1631 * AdminActions::parse_blogcatlist()
1632 * Parse skinvar blogcatlist
1637 public function parse_blogcatlist()
1640 $blogid = intRequestVar('blogid');
1641 $query = "SELECT * FROM %s WHERE cblog = %d ORDER BY cname;";
1642 $query = sprintf($query, sql_table('category'), (integer) $blogid);
1644 $template['content'] = 'categorylist';
1645 $template['tabindex'] = 200;
1647 $batch = new Batch('member');
1648 $batch->showlist($query, 'table', $template);
1653 * AdminActions::parse_blogid()
1654 * Parse skinvar blogid
1659 function parse_blogid()
1661 echo intRequestVar('blogid');
1666 * AdminActions::parse_blognotifysetting()
1667 * Parse skinvar blognotifysetting
1672 public function parse_blognotifysetting($type)
1675 $blogid = intRequestVar('blogid');
1676 $blog = $manager->getBlog($blogid);
1681 if ( !$blog->notifyOnComment() )
1687 if ( !$blog->notifyOnVote() )
1693 if ( !$blog->notifyOnNewItem() )
1699 echo ' checked="checked"';
1704 * AdminActions::parse_blogselectbox()
1705 * Parse skinvar blogselectbox
1710 public function parse_blogselectbox()
1714 $selectData = requestVar('selectData');
1715 $mode = $selectData['mode'];
1716 $name = Entity::hsc($selectData['name']);
1717 $tabindex = Entity::hsc($selectData['tabindex']);
1718 $aBlogIds = array_map('intval', $selectData['aBlogIds']);
1719 $showNewCat = intval($selectData['showNewCat']);
1720 $selected = intval($selectData['selected']);
1722 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
1724 // 1. select blogs (we'll create optiongroups)
1725 // (only select those blogs that have the user on the team)
1726 $queryBlogs = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
1727 $queryBlogs = sprintf($queryBlogs, sql_table('blog'), implode(',', $aBlogIds));
1728 $blogs = sql_query($queryBlogs);
1730 if ( $mode == 'category' )
1732 if ( sql_num_rows($blogs) > 1 )
1736 while ( $oBlog = sql_fetch_object($blogs) )
1738 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1740 echo '<optgroup label="' . Entity::hsc($oBlog->bname) . "\>\n";
1743 // show selection to create new category when allowed/wanted
1746 // check if allowed to do so
1747 if ( $member->blogAdminRights($oBlog->bnumber) )
1749 echo '<option value="newcat-' . $oBlog->bnumber . '">' . _ADD_NEWCAT . "</option>\n";
1753 // 2. for each category in that blog
1754 $catQuery = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
1755 $catQuery = sprintf($catQuery, sql_table('category'), (integer) $oBlog->bnumber);
1756 $categories = sql_query($catQuery);
1757 while ( $oCat = sql_fetch_object($categories) )
1759 if ( $oCat->catid == $selected )
1761 $selectText = ' selected="selected" ';
1767 echo '<option value="' . $oCat->catid . '" ' . $selectText . '>' . Entity::hsc($oCat->cname) . "</option>\n";
1770 if ( isset($multipleBlogs) && !empty($multipleBlogs) )
1779 while ( $oBlog = sql_fetch_object($blogs) )
1781 echo '<option value="' . $oBlog->bnumber . '"';
1782 if ( $oBlog->bnumber == $selected )
1784 echo '<option value="' . $oBlog->bnumber . '" selected="selected">' . Entity::hsc($oBlog->bname) . "</option>\n";
1788 echo '<option value="' . $oBlog->bnumber . '">' . Entity::hsc($oBlog->bname) . "</option>\n";
1797 * AdminActions::parse_blogsetting()
1798 * Parse skinvar blogsetting
1800 * @param string $which name of weblog setting
1803 public function parse_blogsetting($which)
1805 echo $this->parse_getblogsetting($which);
1810 * AdminActions::parse_blogsettingyesno()
1811 * Parse skinvar blogsettingyesno
1813 * @param string $type type of weblog setting
1814 * @param string $templateName name of template to use
1817 public function parse_blogsettingyesno($type, $templateName = '')
1821 $blogid = intRequestVar('blogid');
1822 $blog = $manager->getBlog($blogid);
1826 case 'convertbreaks':
1827 $checkedval = $blog->convertBreaks();
1830 case 'allowpastposting':
1831 $checkedval = $blog->allowPastPosting();
1835 $checkedval = $blog->commentsEnabled();
1839 $checkedval = $blog->isPublic();
1843 $checkedval = $blog->emailRequired();
1847 $checkedval = $blog->getSearchable();
1851 $this->parse_inputyesno($type, $checkedval, $tabindex, 1, 0, _YES, _NO, 0, $templateName);
1856 * AdminActions::parse_blogteamlist()
1857 * Parse skinvar blogteamlist
1859 * @param string $templateName name of template to use
1862 public function parse_blogteamlist($templateName = '')
1865 $blogid = intRequestVar('blogid');
1866 $query = "SELECT tblog, tmember, mname, mrealname, memail, tadmin "
1868 . "WHERE tmember=mnumber AND tblog= %d";
1869 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1871 $template['content'] = 'teamlist';
1872 $template['tabindex'] = 10;
1874 $batch = new Batch('team');
1875 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
1880 * AdminActions::parse_blogteammembers()
1881 * Parse skinvar blogteammembers
1886 public function parse_blogteammembers()
1888 $blogid = intRequestVar('blogid');
1889 $query = "SELECT mname, mrealname "
1891 . "WHERE mnumber=tmember AND tblog=%d;";
1892 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
1893 $res = sql_query($query);
1894 $memberNames = array();
1895 while ($o = sql_fetch_object($res)) {
1896 $memberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
1898 echo implode(',', $memberNames);
1902 * AdminActions::parse_blogtime()
1903 * Parse skinvar blogtime
1905 * @param string $type type of time
1906 * @param string $format format for time expression
1907 * @param integer $offset offset of time
1910 public function parse_blogtime($type, $format = '%H:%M', $offset = 0)
1914 if ( $type != 'blogtime' )
1916 /* return server time */
1917 $timestamp = time() + $offset;
1921 $bid = intRequestVar('blogid');
1922 $b = $manager->getBlog($bid);
1923 $timestamp = $b->getCorrectTime() + $offset;
1926 echo i18n::formatted_datetime($format, $timestamp);
1931 * AdminActions::parse_bookmarkletadmin()
1932 * Parse skinvar bookmarkletadmin
1937 public function parse_bookmarkletadmin()
1941 $blogid = intRequestVar('blogid');
1943 echo Entity::hsc('javascript:' . getBookmarklet($blogid));
1948 * AdminActions::parse_categories()
1949 * Parse skinvar categories
1951 * create category dropdown box
1953 * @param string $type name of setting for category
1956 function parse_categories($startidx = 0)
1960 $itemid = intRequestVar('itemid');
1961 $item =& $manager->getItem($itemid, 1, 1);
1962 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1963 if ($item && $blog->convertBreaks() && requestVar('action') == 'itemedit') {
1964 $item['body'] = removeBreaks($item['body']);
1965 $item['more'] = removeBreaks($item['more']);
1967 $contents = array();
1968 if ( requestVar('action') == 'itemedit' )
1972 if ( isset($contents['catid']) && $contents['catid'] )
1974 $catid = $contents['catid']; // on edit item
1978 $catid = $blog->getDefaultCategory(); // on add item
1980 Admin::selectBlogCategory('catid', $catid, $startidx, 1, $blog->getID());
1984 * AdminActions::parse_category()
1985 * Parse skinvar category
1987 * @param string $type name of setting for category
1990 public function parse_category($type = 'name')
1992 echo $this->parse_getcategory($type);
1997 * AdminActions::parse_categorysetting()
1998 * Parse skinvar categorysetting
2000 * @param string $type type in category setting
2003 public function parse_categorysetting($type)
2005 $catid = intRequestVar('catid');
2006 if ( $type == 'id' )
2011 $blogid = intRequestVar('blogid');
2012 $query = "SELECT * FROM %s WHERE cblog = %d AND catid = %d;";
2013 $query = sprintf($query, sql_table('category'), (integer) $blogid, (integer) $catid);
2014 $res = sql_query($query);
2015 $obj = sql_fetch_object($res);
2017 if ( $type != desc )
2019 echo Entity::hsc($obj->cdesc);
2023 echo Entity::hsc($obj->cname);
2030 * AdminActions::parse_codename()
2031 * Parse templatevar codename
2037 function parse_checkedonval($value, $name) {
2040 $itemid = intRequestVar('itemid');
2041 $item =& $manager->getItem($itemid, 1, 1);
2042 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2043 if ($item && $blog->convertBreaks() && requestVar('action') == 'itemedit') {
2044 $item['body'] = removeBreaks($item['body']);
2045 $item['more'] = removeBreaks($item['more']);
2047 $contents = array();
2048 if ( requestVar('action') == 'itemedit' )
2052 if ( !isset($contents[$name]) )
2054 $contents[$name] = '';
2056 if ($contents[$name] == $value)
2058 echo 'checked="checked"';
2063 * AdminActions::parse_codename()
2064 * Parse templatevar codename
2069 * TODO: is this need???
2071 public function parse_codename()
2074 echo $nucleus['codename'];
2079 * AdminActions::parse_commentnavlist()
2080 * Parse skinvar commentnavlist
2085 public function parse_commentnavlist()
2087 global $CONF, $manager, $member;
2090 if ( postVar('start') )
2092 $start = intPostVar('start');
2099 // amount of items to show
2100 if ( postVar('amount') )
2102 $amount = intPostVar('amount');
2106 $amount = (integer) $CONF['DefaultListSize'];
2112 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem '
2114 . 'LEFT OUTER JOIN %s ON mnumber=cmember '
2116 $query = sprintf($query, sql_table('comment'), sql_table('member'));
2118 if ( $this->skintype == 'itemcommentlist' )
2120 $itemid = intRequestVar('itemid');
2121 $query .= " citem={$itemid}";
2122 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2124 $nonComments = _NOCOMMENTS;
2126 elseif ( $this->skintype == 'browseowncomments' )
2129 $query .= ' cmember=' . $member->getID();
2130 $template['canAddBan'] = 0;
2132 $nonComments = _NOCOMMENTS_YOUR;
2134 elseif ( $this->skintype == 'blogcommentlist' )
2137 $query .= ' cblog=' . intRequestVar('blogid');
2138 $template['canAddBan'] = $member->blogAdminRights(intRequestVar('blogid'));
2139 $bid = intRequestVar('blogid');
2140 $nonComments = _NOCOMMENTS_BLOG;
2143 $search = postVar('search');
2144 if ( !empty($search) )
2146 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
2149 $query .= " ORDER BY ctime ASC LIMIT {$start},{$amount}";
2151 $template['content'] = 'commentlist';
2153 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $bid, $search, $itemid);
2154 $navList->showBatchList('comment', $query, 'table', $template, $nonComments);
2159 * AdminActions::parse_configsettingsedit()
2160 * Parse skinvar configsettingsedit
2162 * @param string $type type of global configuration
2165 public function parse_configsettingsedit($type)
2170 case 'DefaultListSize':
2171 if ( !array_key_exists('DefaultListSize', $CONF) )
2173 $query = "INSERT INTO %s VALUES (DefaultListSize, 10);";
2174 $query = sprintf($query, sql_table('config'));
2176 $CONF['DefaultListSize'] = 10;
2178 elseif ( intval($CONF['DefaultListSize']) < 1 )
2180 $CONF['DefaultListSize'] = 10;
2182 echo intval($CONF['DefaultListSize']);
2184 case 'SessionCookie':
2185 $value = $CONF['SessionCookie'];
2186 $txt1 = _SETTINGS_COOKIESESSION;
2187 $txt2 = _SETTINGS_COOKIEMONTH;
2188 $this->parse_inputyesno('SessionCookie', $value, 10190, 1, 0, $txt1, $txt2);
2191 $value = $CONF['URLMode'];
2192 $txt1 = _SETTINGS_URLMODE_NORMAL;
2193 $txt2 = _SETTINGS_URLMODE_PATHINFO;
2194 $this->parse_inputyesno('URLMode', $value, 10077, 'normal', 'pathinfo', $txt1, $txt2);
2197 if ( array_key_exists($type, $CONF) && is_string($CONF[$type]) )
2199 echo Entity::hsc($CONF[$type]);
2207 * AdminActions::parse_configsettingsyesno()
2208 * Parse skinvar configsettingsyesno
2210 * @param string $type type of global setting
2211 * @param integer $tabindex tabindex attribute of input element
2214 public function parse_configsettingsyesno($type, $tabindex)
2217 if ( array_key_exists($type, $CONF) )
2219 $this->parse_inputyesno($type, $CONF[$type], $tabindex);
2225 * AdminActions::parse_contents()
2226 * Parse skinvar contents
2228 * @param string $which part for item
2231 function parse_contents($which)
2235 $contents = array();
2236 if ( requestVar('action') == 'itemedit' )
2238 $itemid = intRequestVar('itemid');
2239 $item =& $manager->getItem($itemid, 1, 1);
2240 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2241 if ( $item && $blog->convertBreaks() )
2243 $item['body'] = removeBreaks($item['body']);
2244 $item['more'] = removeBreaks($item['more']);
2248 elseif ( requestVar('action') == 'createitem' )
2250 $blog =& $manager->getBlog(intRequestVar($blogid));
2254 'contents' => &$contents,
2259 if ( !isset($contents[$which]) )
2261 $contents[$which] = '';
2263 echo Entity::hsc($contents[$which],ENT_QUOTES);
2267 * AdminActions::parse_currenttime()
2268 * Parse skinvar currenttime
2270 * @param string $what
2273 function parse_currenttime($what)
2276 if ( requestVar('action') == 'itemedit' )
2278 $itemid = intRequestVar('itemid');
2279 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
2281 elseif ( requestVar('action') == 'createitem' )
2283 $blog =& $manager->getBlog(intRequestVar('blogid'));
2285 $nu = getdate($blog->getCorrectTime());
2290 * AdminActions::parse_customhelplink()
2291 * Parse skinvar customhelplink
2293 * @param string $topic name of topic
2294 * @param string $tplName name of template
2295 * @param string $url string as URI
2296 * @param string $iconURL string as URI for icon
2297 * @param string $alt alternative text for image element
2298 * @param string $title title for anchor element
2301 public function parse_customhelplink($topic, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
2303 $this->customHelp($topic, $url, $iconURL);
2308 * AdminActions::parse_date()
2309 * Parse skinvar date
2311 public function parse_date($format = 'c')
2313 global $CONF, $manager;
2314 echo i18n::formatted_datetime($format, time(), 'iso8601', $manager->getBlog((integer) $CONF['DefaultBlog']));
2319 * AdminActions::parse_defaultadminskintypes()
2320 * Parse skinvar defaultadminskintypes
2322 * @param string $tabindex index number for tabindex attribute of input element
2323 * @param string $templateName name of template
2326 public function parse_defaultadminskintypes($tabindex, $templateName = '')
2328 $templates = array();
2329 if ( $templateName )
2331 $templates = Template::read($templateName);
2334 $types = Skin::getFriendlyNames('AdminActions');
2337 if ( array_key_exists('ADMINSKINTYPELIST_HEAD', $templates) && !empty($templates['ADMINSKINTYPELIST_HEAD']) )
2339 $template['head'] = $templates['ADMINSKINTYPELIST_HEAD'];
2343 $template['head'] = "<ul>\n";
2346 echo $template['head'];
2348 if ( array_key_exists('ADMINSKINTYPELIST_BODY', $templates) && !empty($templates['ADMINSKINTYPELIST_BODY']) )
2350 $template['body'] = $templates['ADMINSKINTYPELIST_BODY'];
2354 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=adminskinedittype&skinid=<%skinid%>&type=<%skintype%>">'
2355 . "<%name%></a> <%help%></li>\n";
2357 $handler = new Actions('template', $template, new ADMIN);
2358 $parser = new PARSER(Actions::getDefinedActions(), $handler);
2360 foreach ( $types as $type => $fName )
2362 $helplink = $this->customHelpHtml('skinpart' . $type, $templateName);
2364 'tabindex' => $tabindex,
2365 'skintype' => $type,
2367 'help' => $helplink,
2368 'skinid' => intrequestVar('skinid'),
2370 $templateBody = Template::fill($template['body'], $data);
2371 $parser->parse($templateBody);
2374 if ( array_key_exists('ADMINSKINTYPELIST_FOOT', $templates) && !empty($templates['ADMINSKINTYPELIST_FOOT']) )
2376 $template['foot'] = $templates['ADMINSKINTYPELIST_FOOT'];
2380 $template['foot'] = " </ul>\n";
2382 echo $template['foot'];
2387 * AdminActions::parse_defblogselect()
2388 * Parse skinvar defblogselect
2390 * @param string $templateName name of template
2393 public function parse_defblogselect($templateName = '')
2396 $query = "SELECT bname as text, bnumber as value FROM %s;";
2397 $query = sprintf($query, sql_table('blog'));
2398 $template['name'] = 'DefaultBlog';
2399 $template['selected'] = $CONF['DefaultBlog'];
2400 $template['tabindex'] = 10;
2401 Showlist($query, 'select', $template, $templateName);
2406 * AdminActions::parse_defcatselect()
2407 * Parse skinvar defcatselect
2409 * @param string $templateName name of template
2412 public function parse_defcatselect($templateName = '')
2415 $blogid = intRequestVar('blogid');
2416 $blog = $manager->getBlog($blogid);
2417 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2418 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2419 $template['name'] = 'defcat';
2420 $template['selected'] = $blog->getDefaultCategory();
2421 $template['tabindex'] = 110;
2422 Showlist($query, 'select', $template, $templateName);
2427 * AdminActions::parse_defskinselect()
2428 * Parse skinvar defskinselect
2430 * @param string $type type of skin
2431 * @param string $templateName name of template
2434 public function parse_defskinselect($type = 'blog', $templateName = '')
2437 $query = "SELECT sdname as text, sdnumber as value FROM %s;";
2438 $query = sprintf($query, sql_table('skin_desc'));
2440 $blogid = intRequestVar('blogid');
2445 $template['selected'] = $CONF['BaseSkin'];
2449 $blog = $manager->getBlog($blogid);
2450 $template['selected'] = $blog->getDefaultSkin();
2453 if ( $type != 'blog' )
2455 $nname = 'BaseSkin';
2462 $template['name'] = $nname;
2463 $template['tabindex'] = 50;
2464 Showlist($query, 'select', $template, $templateName);
2469 * AdminActions::parse_deletecomment()
2470 * Parse skinvar deletecomment
2472 * @param string $type type of infomation for comment
2475 public function parse_deletecomment($type = 'id')
2477 $commentid = intRequestVar('commentid');
2478 $comment = COMMENT::getComment($commentid);
2483 echo intRequestVar('commentid');
2486 if ( array_key_exists('member', $comment) && !empty($comment['member']) )
2488 echo $comment['member'];
2492 echo $comment['user'];
2496 $body = strip_tags($comment['body']);
2497 echo Entity::hsc(shorten($body, 300, '...'));
2503 * AdminActions::parse_deleteitembody()
2504 * Parse skinvar deleteitembody
2509 public function parse_deleteitembody()
2512 $itemid = intRequestVar('itemid');
2513 $item =& $manager->getItem($itemid, 1, 1);
2514 $body = strip_tags($item['body']);
2515 echo Entity::hsc(shorten($body, 300, '...'));
2520 * AdminActions::parse_deleteitemid()
2521 * Parse skinvar deleteitemid
2526 public function parse_deleteitemid()
2528 echo (integer) intRequestVar('itemid');
2533 * AdminActions::parse_deleteitemtitle()
2534 * Parse skinvar deleteitemtitle
2539 public function parse_deleteitemtitle()
2542 $itemid = intRequestVar('itemid');
2543 $item =& $manager->getItem($itemid, 1, 1);
2544 echo Entity::hsc(strip_tags($item['title']));
2549 * AdminActions::parse_editadminskin()
2550 * Parse skinvar editadminskin
2552 * @param string $type type of skin setting
2555 public function parse_editadminskin($type = 'id')
2557 $skinid = intRequestVar('skinid');
2558 $skin = new Skin($skinid);
2562 echo intRequestVar('skinid');
2565 echo Entity::hsc($skin->getName());
2568 echo Entity::hsc($skin->getDescription());
2571 echo Entity::hsc($skin->getContentType());
2574 echo Entity::hsc($skin->getIncludePrefix());
2577 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2585 * AdminActions::parse_editadminskintype()
2586 * Parse skinvar editadminskintype
2588 * @param string $type name of skin type
2591 public function parse_editadminskintype($type = 'id')
2593 global $CONF, $manager, $member;
2594 $skinid = intRequestVar('skinid');
2595 $skin = new Skin($skinid);
2596 $fNames = Skin::getFriendlyNames();
2597 $sType = strtolower(trim(requestVar('type')));
2602 echo intRequestVar('skinid');
2605 echo Entity::hsc($skin->getName());
2608 echo Entity::hsc($skin->getDescription());
2611 echo Entity::hsc($skin->getContentType());
2614 echo Entity::hsc($skin->getContent($sType));
2617 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
2618 echo Entity::hsc($skinType);
2621 echo Entity::hsc($sType);
2624 echo Entity::hsc($skin->getIncludePrefix());
2627 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
2628 echo Entity::hsc($incMode);
2637 * AdminActions::parse_editadmintemplateinfo()
2638 * Parse skinvar editadmintemplateinfo
2640 * @param string $type type of skin template
2641 * @param string $description description of template
2642 * @param string $name name of stemplate
2643 * @param string $tabindex index number for tabindex attribute of input element
2644 * @param string $big
2645 * @param string $tplt
2647 public function parse_editadmintemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
2650 $templateid = intRequestVar('templateid');
2651 $templatename = Template::getNameFromId($templateid);
2652 $templatedescription = Template::getDesc($templateid);
2653 $template =& Template::read($templatename);
2657 echo intval($templateid);
2660 echo Entity::hsc($templatename);
2663 echo Entity::hsc($templatedescription);
2665 case 'extratemplate':
2667 $pluginfields = array();
2669 'AdminTemplateExtraFields',
2671 'fields' => &$pluginfields
2677 $tmplt = Template::read($description);
2679 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
2681 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
2687 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
2689 foreach ( $pluginfields as $pfkey => $pfvalue )
2692 'explugtplname' => Entity::hsc($pfkey)
2694 echo TEMPLATE::fill($base, $data);
2695 foreach ( $pfvalue as $pffield => $pfdesc )
2697 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
2702 $desc = defined($description) ? constant($description) : $description;
2703 $name = defined($name) ? constant($name) : $name;
2704 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
2711 * AdminActions::parse_editcomment()
2712 * Parse skinvar editcomment
2714 * @param string $type type of comment setting
2717 public function parse_editcomment($type = 'id')
2720 $commentid = intRequestVar('commentid');
2721 $comment = COMMENT::getComment($commentid);
2723 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment));
2728 echo intRequestVar('commentid');
2731 if (array_key_exists('member', $comment) && !empty($comment['member']) )
2733 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
2737 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
2741 echo date("Y-m-d @ H:i", $comment['timestamp']);
2744 $comment['body'] = str_replace('<br />', '', $comment['body']);
2745 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#", "\\1", $comment['body']);
2746 echo $comment['body'];
2748 echo $comment[$type];
2755 * AdminActions::parse_editdesturl()
2756 * Parse skinvar editdesturl
2758 public function parse_editdesturl()
2760 if ( requestVar('desturl') )
2762 echo Entity::hsc(requestVar('desturl'));
2768 * AdminActions::parse_editmemberlist()
2769 * Parse skinvar editmemberlist
2771 * @param string $templateName name of template
2774 public function parse_editmemberlist($templateName = '')
2777 // show list of members with actions
2778 $query = 'SELECT * FROM '.sql_table('member');
2779 $template['content'] = 'memberlist';
2780 $template['tabindex'] = 10;
2782 $batch = new Batch('member');
2783 $batch->showlist($query, 'table', $template, _LISTS_NOMORE, $templateName);
2788 * AdminActions::parse_editmember()
2789 * Parse skinvar editmember
2791 * @param string $type type of information for member
2792 * @return string $tempateName name of template to use
2795 public function parse_editmember($type = 'id', $templateName = '')
2797 global $CONF, $manager, $member;
2798 $memberid = intRequestVar('memberid');
2799 $mem = MEMBER::createFromID($memberid);
2804 echo intRequestVar('memberid');
2807 if ( $this->skintype == 'teamdelete' || $this->skintype == 'memberdelete' )
2809 echo Entity::hsc($mem->getDisplayName());
2813 $dispName = Entity::hsc($mem->getDisplayName());
2814 if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
2816 echo '<input name="name" tabindex="10" maxlength="32" size="32" value="' . $dispName . "\" />\n";
2825 echo Entity::hsc($mem->getRealName());
2828 echo Entity::hsc($mem->getEmail());
2831 echo Entity::hsc($mem->getURL());
2834 $this->parse_inputyesno('admin', $mem->isAdmin(), 60, 1, 0, _YES, _NO, 0, $templateName);
2837 $this->parse_inputyesno('canlogin', $mem->canLogin(), 70, 1, 0, _YES, _NO, $mem->isAdmin(), $templateName);
2840 echo Entity::hsc($mem->getNotes());
2843 $this->parse_inputyesno('autosave', $mem->getAutosave(), 87, 1, 0, _YES, _NO, 0, $templateName);
2852 * AdminActions::parse_editpluginfo()
2853 * Parse skinvar editpluginfo
2855 * @param string $type type of plugin info
2858 public function parse_editpluginfo($type)
2860 $pid = intRequestVar('plugid');
2867 echo Entity::hsc(getPluginNameFromPid($pid));
2874 * AdminActions::parse_editplugoptionslist()
2875 * Parse skinvar editplugoptionslist
2877 * @param string $templateName name of template
2880 public function parse_editplugoptionslist($templateName = '')
2884 $pid = intRequestVar('plugid');
2885 $aOptions = array();
2888 $query = "SELECT * FROM %s WHERE ocontext='global' AND opid=%d ORDER BY oid ASC";
2889 $query = sprintf($query, sql_table('plugin_option_desc'), (integer) $pid);
2890 $resource = sql_query($query);
2892 while ( $o = sql_fetch_object($resource) )
2894 array_push($aOIDs, $o->oid);
2895 $aOptions[$o->oid] = array(
2898 'value' => $o->odef,
2899 'name' => $o->oname,
2900 'description' => $o->odesc,
2901 'type' => $o->otype,
2902 'typeinfo' => $o->oextra,
2907 // fill out actual values
2908 if ( count($aOIDs) > 0 )
2910 $query = 'SELECT oid, ovalue FROM %s WHERE oid in (%s)';
2911 $query = sprintf($query, sql_table('plugin_option'), implode(',', $aOIDs));
2913 $result = sql_query($query);
2915 while ( $o = sql_fetch_object($result) )
2917 $aOptions[$o->oid]['value'] = $o->ovalue;
2923 'PrePluginOptionsEdit',
2925 'context' => 'global',
2927 'options' => &$aOptions
2931 $template['content'] = 'plugoptionlist';
2932 $amount = Showlist($aOptions, 'table', $template, $templateName);
2935 echo '<p>' . _ERROR_NOPLUGOPTIONS . "</p>\n";
2941 * AdminActions::parse_editskin()
2942 * Parse skinvar editskin
2944 * @param string $type type of skin
2947 public function parse_editskin($type = 'id')
2949 $skinid = intRequestVar('skinid');
2950 $skin = new SKIN($skinid);
2954 echo intRequestVar('skinid');
2957 echo Entity::hsc($skin->getName());
2960 echo Entity::hsc($skin->getDescription());
2963 echo Entity::hsc($skin->getContentType());
2966 echo Entity::hsc($skin->getIncludePrefix());
2969 $this->parse_inputyesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
2977 * AdminActions::parse_editskintype()
2978 * Parse skinvar editskintype
2980 * @param string $type name of type for skin type
2983 public function parse_editskintype($type = 'id')
2985 global $CONF, $manager, $member;
2986 $skinid = intRequestVar('skinid');
2987 $skin = new SKIN($skinid);
2988 $fNames = SKIN::getFriendlyNames('Actions');
2989 $sType = strtolower(trim(requestVar('type')));
2994 echo intRequestVar('skinid');
2997 echo Entity::hsc($skin->getName());
3000 echo Entity::hsc($skin->getDescription());
3003 echo Entity::hsc($skin->getContentType());
3006 echo Entity::hsc($skin->getContent($sType));
3009 $skinType = !array_key_exists($sType, $fNames) ? ucfirst($sType) : $fNames[$sType];
3010 echo Entity::hsc($skinType);
3013 echo Entity::hsc($sType);
3016 echo Entity::hsc($skin->getIncludePrefix());
3019 $incMode = $skin->getIncludeMode() ? _PARSER_INCMODE_SKINDIR : _PARSER_INCMODE_NORMAL;
3020 echo Entity::hsc($incMode);
3029 * AdminActions::parse_adminurl()
3030 * Parse skinvar adminurl
3031 * (shortcut for admin url)
3036 public function parse_adminurl()
3038 $this->parse_sitevar('adminurl');
3043 * AdminActions::parse_edittemplateinfo()
3044 * Parse skinvar edittemplateinfo
3046 * @param string $type name of type for skin
3047 * @param string $description description for skin
3048 * @param string $name name of skin
3049 * @param string $help
3050 * @param string $tabindex index value for tabindex attribute of input element
3051 * @param string $big
3052 * @param string $tplt name of template
3054 public function parse_edittemplateinfo($type, $description = '', $name = '', $help = '', $tabindex = 0, $big = 0, $tplt = '')
3057 $templateid = intRequestVar('templateid');
3058 $templatename = TEMPLATE::getNameFromId($templateid);
3059 $templatedescription = TEMPLATE::getDesc($templateid);
3060 $template =& $manager->getTemplate($templatename);
3064 echo intval($templateid);
3067 echo Entity::hsc($templatename);
3070 echo Entity::hsc($templatedescription);
3072 case 'extratemplate':
3074 $pluginfields = array();
3076 'TemplateExtraFields',
3078 'fields' => &$pluginfields
3084 $tmplt = Template::read($description);
3086 if ( array_key_exists('TEMPLATE_EDIT_EXPLUGNAME', $tmplt) && !empty($tmplt['TEMPLATE_EDIT_EXPLUGNAME']) )
3088 $base = $tmplt['TEMPLATE_EDIT_EXPLUGNAME'];
3092 $base = "</tr><tr>\n"
3093 . "\t" . '<th colspan="2"><%explugtplname%>' . "</th>\n";
3095 foreach ( $pluginfields as $pfkey => $pfvalue )
3098 'explugtplname' => Entity::hsc($pfkey)
3100 echo TEMPLATE::fill($base, $data);
3101 foreach ( $pfvalue as $pffield => $pfdesc )
3103 $this->_templateEditRow($template, $pfdesc, $pffield, '', ++$tabidx, 0, $name);
3108 $desc = defined($description) ? constant($description) : $description;
3109 $name = defined($name) ? constant($name) : $name;
3110 $this->_templateEditRow($template, $desc, $name, $help, $tabindex, $big, $tplt);
3117 * AdminActions::parse_eventformextra()
3118 * Parse skinvar eventformextra
3120 * @param string $type name of type for event form extra
3123 public function parse_eventformextra($type = 'activation')
3129 $key = requestVar('ackey');
3132 Admin::error(_ERROR_ACTIVATE);
3134 $info = MEMBER::getActivationInfo($key);
3137 Admin::error(_ERROR_ACTIVATE);
3139 $mem = MEMBER::createFromId($info->vmember);
3142 Admin::error(_ERROR_ACTIVATE);
3145 'type' => 'activation',
3149 case 'membermailform-notloggedin':
3151 'type' => 'membermailform-notloggedin',
3155 $manager->notify('FormExtra', $data);
3160 * AdminActions::parse_extrahead()
3161 * Parse skinvar extrahead
3163 public function parse_extrahead()
3166 $extrahead = Admin::getAdminextrahead();
3170 'extrahead' => &$extrahead,
3171 'action' => Admin::getAdminAction()
3180 * AdminActions::parse_member()
3181 * Parse skinvar member
3182 * (includes a member info thingie)
3184 * @param string $what which memberdata is needed
3187 public function parse_member($what)
3189 global $memberinfo, $member, $CONF;
3191 // 1. only allow the member-details-page specific variables on member pages
3192 if ( $this->skintype == 'member' )
3197 echo Entity::hsc($memberinfo->getDisplayName());
3200 echo Entity::hsc($memberinfo->getRealName());
3203 echo Entity::hsc($memberinfo->getNotes());
3206 echo Entity::hsc($memberinfo->getURL());
3209 echo Entity::hsc($memberinfo->getEmail());
3212 echo Entity::hsc($memberinfo->getID());
3217 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3218 if ( $member->isLoggedIn() )
3223 echo $member->getDisplayName();
3225 case 'yourrealname':
3226 echo $member->getRealName();
3229 echo $member->getNotes();
3232 echo $member->getURL();
3235 echo $member->getEmail();
3238 echo $member->getID();
3240 case 'yourprofileurl':
3241 if ($CONF['URLMode'] == 'pathinfo')
3242 echo Link::create_member_link($member->getID());
3244 echo $CONF['IndexURL'] . Link::create_member_link($member->getID());
3252 * AdminActions::parse_version()
3253 * Parse skinvar version
3254 * (include nucleus versionnumber)
3259 public function parse_version()
3262 echo 'Nucleus CMS ' . $nucleus['version'];
3267 * AdminActions::parse_sitevar()
3268 * Parse skinvar sitevar
3269 * (include a sitevar)
3271 * @param string $which
3274 public function parse_sitevar($which)
3280 echo $CONF['IndexURL'];
3283 echo $CONF['SiteName'];
3286 echo $CONF['AdminEmail'];
3289 echo $CONF['AdminURL'];
3295 * AdminActions::parse_charset()
3296 * Parse skinvar charset
3301 public function parse_charset()
3303 echo i18n::get_current_charset();
3308 * AdminActions::parse_getblogsetting()
3309 * Parse skinvar getblogsetting
3311 public function parse_getblogsetting($which)
3319 elseif ( $bid = intRequestVar('blogid') )
3322 $b = $manager->getBlog($bid);
3332 return Entity::hsc($b->getID());
3335 return Entity::hsc($b->getURL());
3338 return Entity::hsc($b->getName());
3341 return Entity::hsc($b->getDescription());
3344 return Entity::hsc($b->getShortName());
3346 case 'notifyaddress':
3347 return Entity::hsc($b->getNotifyAddress());
3350 return Entity::hsc($b->getMaxComments());
3353 return Entity::hsc($b->getUpdateFile());
3356 return Entity::hsc($b->getTimeOffset());
3363 * AdminActions::parse_geteditpluginfo()
3364 * Parse skinvar geteditpluginfo
3366 * @param string $type name of setting for edit plugin info
3369 public function parse_geteditpluginfo($type)
3371 $pid = intRequestVar('plugid');
3378 return Entity::hsc(getPluginNameFromPid($pid));
3385 * AdminActions::parse_getmember()
3386 * Parse skinvar getmember
3387 * (includes a member info thingie)
3389 * @param string $what name of setting for member
3392 public function parse_getmember($what)
3394 global $memberinfo, $member;
3395 // 1. only allow the member-details-page specific variables on member pages
3396 if ( $this->skintype == 'member' )
3401 return Entity::hsc($memberinfo->getDisplayName());
3404 return Entity::hsc($memberinfo->getRealName());
3407 return Entity::hsc($memberinfo->getNotes());
3410 return Entity::hsc($memberinfo->getURL());
3413 return Entity::hsc($memberinfo->getEmail());
3416 return Entity::hsc($memberinfo->getID());
3420 // 2. the next bunch of options is available everywhere, as long as the user is logged in
3421 if ( $member->isLoggedIn() )
3426 return $member->getDisplayName();
3428 case 'yourrealname':
3429 return $member->getRealName();
3432 return $member->getNotes();
3435 return $member->getURL();
3438 return $member->getEmail();
3441 return $member->getID();
3449 * AdminActions::parse_headmessage()
3450 * Parse skinvar headmessage
3455 public function parse_headmessage()
3457 if ( !empty(Admin::$headMess) )
3459 echo '<p>' . _MESSAGE . ': ' . Entity::hsc(Admin::$headMess) . "</p>\n";
3465 * AdminActions::parse_helplink()
3466 * Parse skinvar helplink
3468 * @param string $topic name of topic for help
3471 public function parse_helplink($topic = '')
3473 if ( empty($topic) )
3482 * AdminActions::parse_helpplugname()
3483 * Parse skinvar helpplugname
3488 public function parse_helpplugname()
3490 $plugid = intGetVar('plugid');
3491 Entity::hsc(getPluginNameFromPid($plugid));
3496 * AdminActions::parse_ilistaddnew()
3497 * Parse skinvar ilistaddnew
3502 public function parse_ilistaddnew()
3504 $blogid = intRequestVar('blogid');
3505 if ( intPostVar('start') == 0 )
3507 echo '<p><a href="index.php?action=createitem&blogid=' . $blogid . '">' . _ITEMLIST_ADDNEW . "</a></p>\n";
3513 * AdminActions::parse_importskininfo()
3514 * Parse skinvar importskininfo
3516 * @param string $type name of information for imported skin
3519 public function parse_importskininfo($type)
3524 echo Entity::hsc(requestVar('skininfo'));
3527 $dataArr = requestArray('skinnames');
3528 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3531 $dataArr = requestArray('tpltnames');
3532 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3535 $dataArr = requestArray('skinclashes');
3536 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3539 $dataArr = requestArray('tpltclashes');
3540 echo implode(' <em>' . _AND . '</em> ', $dataArr);
3543 echo Entity::hsc(requestVar('skinfile'));
3546 echo Entity::hsc(requestVar('mode'));
3553 * AdminActions::parse_inputyesno()
3554 * Parse skinvar inputyesno
3556 * some init stuff for all forms
3560 function parse_init()
3564 if ( requestVar('action') == 'itemedit' )
3566 $itemid = intRequestVar('itemid');
3567 $item =& $manager->getItem($itemid, 1, 1);
3568 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3569 if ( $item && $blog->convertBreaks() )
3571 $item['body'] = removeBreaks($item['body']);
3572 $item['more'] = removeBreaks($item['more']);
3575 $authorid = $contents['authorid'];
3577 elseif ( requestVar('action') == 'createitem' )
3579 $blog =& $manager->getBlog(intRequestVar($blogid));
3582 $blog->insertJavaScriptInfo($authorid);
3586 * AdminActions::parse_inputyesno()
3587 * Parse skinvar inputyesno
3589 * @param string $name
3590 * @param string $checkedval
3591 * @param string $tabindex
3592 * @param string $value1
3593 * @param string $value2
3594 * @param string $yesval
3595 * @param string $noval
3596 * @param string $isAdmin
3597 * @param string $templateName
3600 public function parse_inputyesno($name, $checkedval, $tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0, $templateName = '')
3602 self::input_yesno($name, $checkedval, $tabindex, $value1, $value2, $yesval, $noval, $isAdmin, $templateName );
3607 * AdminActions::parse_insertpluginfo()
3608 * Parse templatevar insertpluginfo
3610 public function parse_insertpluginfo($type)
3612 $option = Admin::$aOptions;
3616 return $option['pid'];
3619 return Entity::hsc($option['pfile']);
3626 * AdminActions::parse_insertpluginoptions()
3627 * Parse skinvar insertpluginoptions
3629 * @param string $templateName name of template
3632 public function parse_insertpluginoptions($templateName = '')
3634 $options = Admin::getAdminaOption();
3635 $template = array();
3636 $templats = array();
3638 if ( $templateName )
3640 $templates = Template::read($templateName);
3642 if (array_key_exists('INSERT_PLUGOPTION_TITLE', $templates) && !empty($templates['INSERT_PLUGOPTION_TITLE']) )
3644 $template['title'] = $templates['INSERT_PLUGOPTION_TITLE'];
3648 $template['title'] = '<tr><th colspan="2"><%sprinttext(_PLUGIN_OPTIONS_TITLE, <|%insertpluginfo(name)%|>)%></th></tr>' . "\n";
3650 if ( array_key_exists('INSERT_PLUGOPTION_BODY', $templates) && !empty($templates['INSERT_PLUGOPTION_BODY']) )
3652 $template['body'] = $templates['INSERT_PLUGOPTION_BODY'];
3656 $template['body'] = '<tr><%listplugplugoptionrow%></tr>' . "\n";
3661 foreach ( $options as $option )
3663 $handler = new Actions($this->skintype, $template, $option);
3664 $parser = new PARSER(Actions::getDefinedActions(), $handler);
3666 if ( $prevPid != $option['pid'] )
3668 $prevPid = $option['pid'];
3669 $parser->parse($template['title']);
3671 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3672 if ( @$meta['access'] != 'hidden' )
3674 $parsed = $parser->parse($template['body']);
3681 * AdminActions::parse_insplugoptcontent()
3682 * Parse skinvar insplugoptcontent
3687 public function parse_insplugoptcontent()
3689 $option = Admin::$aOption;
3691 $meta = NucleusPlugin::getOptionMeta($option['typeinfo']);
3692 if (array_key_exists('access', $meta) && $meta['access'] != 'hidden')
3695 listplug_plugOptionRow($option);
3702 * AdminActions::parse_iprangeinput()
3703 * Parse skinvar iprangeinput
3708 public function parse_iprangeinput()
3710 if ( requestVar('ip') )
3712 $iprangeVal = Entity::hsc(requestVar('ip'));
3713 echo '<input name="iprange" type="radio" value="' . $iprangeVal . '" checked="checked" id="ip_fixed" />' . "\n";
3714 echo '<label for="ip_fixed">' . $iprangeVal . "</label><br />\n";
3715 echo '<input name="iprange" type="radio" value="custom" id="ip_custom" />' . "\n";
3716 echo '<label for="ip_custom">' . _BAN_IP_CUSTOM . '</label>' . "\n";
3717 echo '<input name="customiprange" value="' . $iprangeVal . '" maxlength="15" size="15" />' . "\n";
3721 echo '<input name="iprange" value="custom" type="hidden" />' . "\n";
3722 echo '<input name="customiprange" value="" maxlength="15" size="15" />' . "\n";
3728 * AdminActions::parse_itemnavlist()
3729 * Parse skinvar itemnavlist
3734 public function parse_itemnavlist()
3736 global $CONF, $manager, $member;
3737 if ( $this->skintype == 'itemlist' )
3739 $blogid = intRequestVar('blogid');
3740 $blog =& $manager->getBlog($blogid);
3742 if ( postVar('start') )
3744 $start = intPostVar('start');
3751 // amount of items to show
3752 if ( postVar('amount') )
3754 $amount = intPostVar('amount');
3758 $amount = intval($CONF['DefaultListSize']);
3764 $query = "SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime"
3765 . " FROM %s, %s, %s, %s"
3766 . " WHERE iblog=bnumber AND iauthor=mnumber AND icat=catid";
3768 $query = sprintf($query, sql_table('item'), sql_table('blog'), sql_table('member'), sql_table('category'));
3770 if ( $this->skintype == 'itemlist' )
3772 $query .= ' AND iblog = ' . $blogid;
3773 $template['now'] = $blog->getCorrectTime(time());
3775 // non-blog-admins can only edit/delete their own items
3776 if ( !$member->blogAdminRights($blogid) )
3778 $query .= ' AND iauthor = ' . $member->getID();
3781 elseif ( $this->skintype == 'browseownitems' )
3783 $query .= ' AND iauthor = ' . $member->getID();
3785 $template['now'] = time();
3788 // search through items
3789 $search = postVar('search');
3791 if ( !empty($search) )
3793 $query .= ' AND ((ititle LIKE "%' . sql_real_escape_string($search) . '%") '
3794 . ' OR (ibody LIKE "%' . sql_real_escape_string($search) . '%") '
3795 . ' OR (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
3797 $query .= ' ORDER BY itime DESC'
3798 . " LIMIT {$start},{$amount}";
3800 $template['content'] = 'itemlist';
3802 $navList = new Navlist($this->skintype, $start, $amount, 0, 1000, $blogid, $search, 0);
3803 $navList->showBatchList('item', $query, 'table', $template);
3808 * AdminActions::parse_itemoptions()
3809 * Parse skinvar itemoptions
3810 * Adds the itemOptions of a plugin to a page
3813 function parse_itemoptions()
3815 $this->parse_pluginoptions($type = 'item');
3817 // Admin::insertPluginOptions('item', $itemid);
3821 * AdminActions::parse_itemoptions()
3823 * date change on edit item
3825 * Parse skinvar itemoptions
3826 * Adds the itemOptions of a plugin to a page
3829 function parse_itemtime($what)
3833 $itemid = intRequestVar('itemid');
3834 $item =& $manager->getItem($itemid, 1, 1);
3835 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
3836 if ( $item && $blog->convertBreaks() && requestVar('action') == 'itemedit' )
3838 $item['body'] = removeBreaks($item['body']);
3839 $item['more'] = removeBreaks($item['more']);
3841 $contents = array();
3842 if ( requestVar('action') == 'itemedit' )
3846 elseif ( requestVar('action') == 'createitem' )
3851 'contents' => &$contents,
3852 'blog' => &$this->blog
3856 $itemtime = getdate($contents['timestamp']);
3857 echo $itemtime[$what];
3861 * AdminActions::parse_jstoolbaroptions()
3862 * Parse skinvar jstoolbaroptions
3867 public function parse_jstoolbaroptions()
3871 _SETTINGS_JSTOOLBAR_NONE,
3872 _SETTINGS_JSTOOLBAR_SIMPLE,
3873 _SETTINGS_JSTOOLBAR_FULL
3876 foreach ( $options as $option )
3878 $text = "<option value=\"%d\"%s>%s</option>\n";
3879 $extra = ($CONF['DisableJsTools'] == $i) ? ' selected="selected"' : '';
3880 echo sprintf($text, $i, $extra, $option);
3886 * Parse skinvar languageselectoptions
3888 function parse_languageselectoptions()
3890 $locales = i18n::get_available_locale_list();
3891 $memid = intRequestVar('memberid');
3894 $mem = MEMBER::createFromID($memid);
3895 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3897 echo "<option value=\"\" selected=\"selected\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3901 echo "<option value=\"\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3906 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3908 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3911 foreach ( $locales as $locale )
3915 if ( $locale == $mem->getLocale() )
3917 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3921 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3926 if ( $locale == i18n::get_current_locale() )
3928 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3932 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3939 * AdminActions::parse_localeselectoptions()
3940 * Parse skinvar localeselectoptions
3945 public function parse_localeselectoptions()
3947 $locales = i18n::get_available_locale_list();
3948 $memid = intRequestVar('memberid');
3951 $mem = MEMBER::createFromID($memid);
3952 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
3954 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3958 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
3963 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
3965 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
3968 foreach ( $locales as $locale )
3972 if ( $locale == $mem->getLocale() )
3974 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3978 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3983 if ( $locale == i18n::get_current_locale() )
3985 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
3989 echo "<option value=\"{$locale}\">{$locale}</option>\n";
3997 * AdminActions::parse_listplugplugoptionrow()
3998 * Parse templatevar listplugplugoptionrow
4000 * @param string $templateName name of template
4003 public function parse_listplugplugoptionrow($templateName = '')
4005 echo listplug_plugOptionRow(Admin::$aOptions, $templateName);
4010 * AdminActions::parse_mediadirwarning()
4011 * Parse skinvar mediadirwarning
4016 public function parse_mediadirwarning()
4019 if ( !is_dir($DIR_MEDIA) )
4021 echo "<br /><b>" . _WARNING_NOTADIR . "</b>\n";
4023 if ( !is_readable($DIR_MEDIA) )
4025 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>\n";
4027 if ( !is_writeable($DIR_MEDIA) )
4029 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>\n";
4035 * AdminActions::parse_movedistselect()
4036 * Parse skinvar movedistselect
4038 public function parse_movedistselect()
4040 $actionType = requestVar('action');
4041 switch ( $actionType )
4044 Admin::selectBlogCategory('destcatid');
4046 case 'batchcategory':
4047 Admin::selectBlog('destblogid');
4050 if ( $this->skintype == 'itemmove' )
4052 $query = "SELECT icat as result FROM %s WHERE inumber=%d;";
4053 $query = spriintf($query, sql_table('item'), intRequestVar('itemid'));
4054 $catid = quickQuery(sprintf($query, intRequestVar('itemid')));
4055 Admin::selectBlogCategory('catid', $catid, 10, 1);
4063 * AdminActions::parse_moveitemid()
4064 * Parse skinvar moveitemid
4069 public function parse_moveitemid()
4071 echo intRequestVar('itemid');
4076 * AdminActions::parse_newestcompare()
4077 * Parse skinvar newestcompare
4082 public function parse_newestcompare()
4085 $newestVersion = getLatestVersion();
4086 $newestCompare = str_replace('/', '.', $newestVersion);
4087 $currentVersion = str_replace(array('/', 'v'), array('.', ''), $nucleus['version']);
4088 if ( $newestVersion && version_compare($newestCompare, $currentVersion, '>') )
4090 echo '<br /><a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
4091 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion . '</a>';
4097 * AdminActions::parse_newmemberselect()
4098 * Parse skinvar newmemberselect
4100 * @param string $templateName name of template to use
4103 public function parse_newmemberselect($templateName = '')
4105 $blogid = intRequestVar('blogid');
4107 $query = "SELECT tmember FROM %s WHERE tblog=%d;";
4108 $query = sprintf($query, sql_table('team'), (integer) $blogid);
4109 $res = sql_query($query);
4112 while ( $tmember = sql_fetch_object($res) )
4114 $tmem[] = intval($tmember->tmember);
4117 $query = "SELECT mname as text, mnumber as value FROM %s WHERE mnumber NOT IN (%s);";
4118 $query = sprintf($query, sql_table('member'), implode(', ', $tmem));
4120 $template['name'] = 'memberid';
4121 $template['tabindex'] = 10000;
4122 Showlist($query, 'select', $template, $templateName);
4127 * AdminActions::parse_newpluginlist()
4128 * Parse skinvar newpluginlist
4133 public function parse_newpluginlist()
4135 $candidates = $this->newPlugCandidates;
4136 foreach ( $candidates as $name )
4138 echo '<option value="NP_' . $name . '">' . Entity::hsc($name) . "</option>\n";
4144 * AdminActions::parse_outputspecialdirs()
4145 * Parse skinvar outputspecialdirs
4147 * @param string $type type of setting for directory
4150 public function parse_outputspecialdirs($type)
4155 global $DIR_NUCLEUS;
4156 echo Entity::hsc($DIR_NUCLEUS);
4160 echo Entity::hsc($DIR_MEDIA);
4167 * AdminActions::parse_passrequestvars()
4168 * Parse skinvar passrequestvars
4173 public function parse_passrequestvars()
4175 $passvar = Admin::getAdminpassvar();
4176 $oldaction = postVar('oldaction');
4177 if ( ($oldaction != 'logout')
4178 && ($oldaction != 'login')
4180 && !postVar('customaction') )
4188 * AdminActions::parse_pluginextras()
4189 * Parse skinvar pluginextras
4191 * @param string $type type of plugin context
4194 public function parse_pluginextras($type = 'global')
4200 $id = intRequestVar('memberid');
4201 $mem = MEMBER::createFromID($id);
4203 'MemberSettingsFormExtras',
4210 $id = intRequestVar('blogid');
4211 $blg = $manager->getBlog($id);
4213 'BlogSettingsFormExtras',
4221 'GeneralSettingsFormExtras',
4231 * AdminActions::parse_pluginhelp()
4232 * Parse skinvar pluginhelp
4237 public function parse_pluginhelp()
4239 global $manager, $DIR_PLUGINS;
4240 $plugid = intGetVar('plugid');
4241 $plugName = getPluginNameFromPid($plugid);
4242 $plug =& $manager->getPlugin($plugName);
4244 if ( $plug->supportsFeature('HelpPage') > 0 )
4246 $helpfile = $DIR_PLUGINS . $plug->getShortName() . '/help.';
4247 if ( @file_exists($helpfile . 'php') )
4249 @include($helpfile . 'php');
4252 elseif ( @file_exists($helpfile . 'html') )
4254 @include($helpfile . 'html');
4258 echo '<p>' . _ERROR . ': ' . _ERROR_PLUGNOHELPFILE . "</p>\n";
4259 echo '<p><a href="index.php?action=pluginlist">(' . _BACK . ")</a></p>\n";
4264 * AdminActions::parse_pluginlistlist()
4265 * Parse skinvar pluginlistlist
4267 * @param string $templateName name of template to use
4270 public function parse_pluginlistlist($templateName = '')
4272 $query = "SELECT * FROM %s ORDER BY porder ASC;";
4273 $query = sprintf($query, sql_table('plugin'));
4274 $template['content'] = 'pluginlist';
4275 $template['tabindex'] = 10;
4276 Showlist($query, 'table', $template, $templateName);
4281 * AdminActions::parse_pluginoptions()
4282 * Parse skinvar pluginoptions
4284 * @param string $type type of plugin option
4287 public function parse_pluginoptions($type = 'global')
4292 $id = intRequestVar('memberid');
4295 $id = intRequestVar('blogid');
4298 $id = intRequestVar('catid');
4304 Admin::insertPluginOptions($type, $id);
4309 * AdminActions::parse_qmenuaddselect()
4310 * Parse skinvar qmanuaddselect
4312 * @param string $templateName name of template to use
4315 public function parse_qmenuaddselect($templateName = '')
4318 $showAll = requestVar('showall');
4319 if ( $member->isAdmin() && ($showAll == 'yes') )
4321 // Super-Admins have access to all blogs! (no add item support though)
4322 $query = 'SELECT bnumber as value, bname as text'
4323 . ' FROM ' . sql_table('blog')
4324 . ' ORDER BY bname';
4328 $query = 'SELECT bnumber as value, bname as text'
4329 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
4330 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
4331 . ' ORDER BY bname';
4333 $template['name'] = 'blogid';
4334 $template['tabindex'] = 15000;
4335 $template['extra'] = _QMENU_ADD_SELECT;
4336 $template['selected'] = -1;
4337 $template['shorten'] = 10;
4338 $template['shortenel'] = '';
4339 $template['javascript'] = 'onchange="return form.submit()"';
4340 Showlist($query, 'select', $template, $templateName);
4345 * AdminActions::parse_quickmenu()
4346 * Parse skinvar quickmenu
4348 * @param string $templateName name of template to use
4351 public function parse_quickmenu($templateName = '')
4354 $templates = array();
4355 $template = array();
4356 if ( !empty($templateName) )
4358 $templates = Template::read($templateName);
4360 $pluginExtras = array();
4364 'options' => &$pluginExtras
4367 if ( count($pluginExtras) > 0 )
4369 if ( array_key_exists('PLUGIN_QUICKMENU_TITLE', $templates) || !empty($templates['PLUGIN_QUICKMENU_TITLE']) )
4371 $template['title'] = $templates['PLUGIN_QUICKMENU_TITLE'];
4375 $template['title'] = '<h2><%text(_QMENU_PLUGINS)%></h2>';
4377 $handler = new Actions($this->skintype, $template, $this->objAdmin);
4378 $parser = new PARSER(Actions::getDefinedActions(), $handler);
4379 $parser->parse($template['title']);
4381 if ( array_key_exists('PLUGIN_QUICKMENU_HEAD', $templates) || !empty($templates['PLUGIN_QUICKMENU_HEAD']) )
4383 $template['head'] = $templates['PLUGIN_QUICKMENU_HEAD'];
4387 $template['head'] = '<ul>';
4390 echo $template['head'];
4392 if ( array_key_exists('PLUGIN_QUICKMENU_BODY', $templates) || !empty($templates['PLUGIN_QUICKMENU_BODY']) )
4394 $template['body'] = $templates['PLUGIN_QUICKMENU_BODY'];
4398 $template['body'] = '<li><a href="<%plugadminurl%>" title="<%plugadmintooltip%>"><%plugadmintitle%></a></li>';
4401 foreach ( $pluginExtras as $aInfo )
4404 'plugadminurl' => Entity::hsc($aInfo['url']),
4405 'plugadmintooltip' => Entity::hsc($aInfo['tooltip']),
4406 'plugadmintitle' => Entity::hsc($aInfo['title']),
4408 echo TEMPLATE::fill($template['body'], $data);
4410 if ( array_key_exists('PLUGIN_QUICKMENU_FOOT', $templates) || !empty($templates['PLUGIN_QUICKMENU_FOOT']) )
4412 $template['foot'] = $templates['PLUGIN_QUICKMENU_FOOT'];
4416 $template['foot'] = '</ul>';
4418 echo $template['foot'];
4424 * AdminActions::parse_requestblogid()
4425 * Parse skinvar requestblogid
4430 public function parse_requestblogid()
4432 echo intRequestVar('blogid');
4437 * AdminActions::parse_requestiprange()
4438 * Parse skinvar requestiprange
4443 public function parse_requestiprange()
4445 if ( requestVar('iprange') )
4447 echo Entity::hsc(requestVar('iprange'));
4449 elseif ( requestVar('ip') )
4451 echo Entity::hsc(requestVar('ip'));
4457 * AdminActions::parse_selectlocaladminskinfiles()
4458 * Parse skinvar selectlocaladminskinfiles
4463 public function parse_selectlocaladminskinfiles()
4466 global $DIR_SKINS, $manager;
4467 $adminskindir = $DIR_SKINS . 'admin/';
4468 $candidates = SkinImport::searchForCandidates($adminskindir);
4469 foreach ( $candidates as $skinname => $skinfile )
4471 $html = Entity::hsc($skinfile);
4472 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4478 * AdminActions::parse_selectlocalskinfiles()
4479 * Parse skinvar selectlocalskinfiles
4484 public function parse_selectlocalskinfiles()
4487 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
4488 foreach ( $candidates as $skinname => $skinfile )
4490 $html = Entity::hsc($skinfile);
4491 echo '<option value="' . $html . '">' . $skinname . "</option>\n";
4497 * AdminActions::parse_skineditallowedlist()
4498 * Parse skinvar skineditallowedlist
4500 * @param string $type type of skin
4501 * @param string $templateName name of template
4504 public function parse_skineditallowedlist($type, $templateName = '')
4509 $query = "SELECT bshortname, bname FROM %s";
4511 'content' => 'shortblognames'
4513 $query = sprintf($query, sql_table('blog'));
4514 Showlist($query, 'table', $show, $templateName);
4517 $query = "SELECT tdname as name, tddesc as description WHERE tdname NOT LIKE 'admin/%%' FROM %s";
4519 'content' => 'shortnames'
4521 $query = sprintf($query, sql_table('template_desc'));
4522 Showlist($query, 'table', $show, $templateName);
4529 * AdminActions::parse_skinielist()
4530 * Parse skinvar skinielist
4532 * @param string $type type of skin
4533 * @param string $templateName name of template to use
4536 public function parse_skinielist($type, $templateName = '')
4538 $templates = array();
4539 if ( $templateName )
4541 $templates = Template::read($templateName);
4543 if ( array_key_exists('SKINIE_EXPORT_LIST', $templates) && !empty($templates['SKINIE_EXPORT_LIST']) )
4545 $template = $templates['SKINIE_EXPORT_LIST'];
4549 $template = '<td><input type="checkbox" name="<%typeid%>" id="<%expid%>" /><label for="<%expid%>"><%expname%></label></td>' . "\n"
4550 . "<td><%expdesc%></td>\n"
4556 $res = sql_query('SELECT * FROM ' . sql_table('skin_desc'));
4557 while ( $skinObj = sql_fetch_object($res) )
4560 'typeid' => 'skin[' . $skinObj->sdnumber . ']',
4561 'expid' => 'skinexp' . $skinObj->sdnumber,
4562 'expname' => Entity::hsc($skinObj->sdname),
4563 'expdesc' => Entity::hsc($skinObj->sddesc),
4565 echo TEMPLATE::fill($template, $data);
4569 $res = sql_query('SELECT * FROM '.sql_table('template_desc'). " WHERE tdname NOT LIKE 'admin/%'");
4570 while ($templateObj = sql_fetch_object($res)) {
4572 'typeid' => 'template[' . $templateObj->tdnumber . ']',
4573 'expid' => 'templateexp' . $templateObj->tdnumber,
4574 'expname' => Entity::hsc($templateObj->tdname),
4575 'expdesc' => Entity::hsc($templateObj->tddesc),
4577 echo TEMPLATE::fill($template, $data);
4585 * AdminActions::parse_skinoverview()
4586 * Parse skinvar skinoverview
4588 * @param string $templateName name of template to use
4591 public function parse_skinoverview($templateName = '')
4594 $query = "SELECT * FROM %s ORDER BY sdname";
4595 $query = sprintf($query, sql_table('skin_desc'));
4597 $template['content'] = 'skinlist';
4598 $template['tabindex'] = 10;
4599 // $template['friendly_names'] = Skin::getFriendlyNames('Actions');
4600 $skin = new Skin($CONF['BaseSkin']);
4601 $template['friendly_names'] = $skin->getDefaultTypes();
4603 Showlist($query, 'table', $template, $templateName);
4608 * AdminActions::parse_skintypehelp()
4609 * Check editing skintypehelp
4614 public function parse_skintypehelp()
4616 $nowSkinType = strtolower(trim(requestVar('type')));
4617 $regularType = array(
4628 if ( in_array($nowSkinType, $regularType) )
4630 help('skinpart' . $nowSkinType);
4634 help('skinpartspecial');
4640 * AdminActions::parse_specialskinlist()
4641 * Parse skinvar specialskinlist
4643 * @param string $templateName name of template to use
4646 public function parse_specialskinlist($templateName = '')
4648 $templates = array();
4649 if ( $templateName )
4651 $templates = Template::read($templateName);
4663 $skinid = intRequestVar('skinid');
4664 $query = "SELECT stype FROM %s WHERE stype NOT IN ('%s') AND sdesc = %d;";
4665 $query = sprintf($query, sql_table('skin'), implode("', '", $nType), $skinid);
4667 $res = sql_query($query);
4668 if ( $res && sql_num_rows($res) > 0 )
4671 if ( array_key_exists('SPECIALSKINLIST_HEAD', $templates) && !empty($templates['SPECIALSKINLIST_HEAD']) )
4673 $template['head'] = $templates['SPECIALSKINLIST_HEAD'];
4677 $template['head'] = "<ul>\n";
4679 echo TEMPLATE::fill($template['head'], $data);
4680 if ( array_key_exists('SPECIALSKINLIST_BODY', $templates) && !empty($templates['SPECIALSKINLIST_BODY']) )
4682 $template['body'] = $templates['SPECIALSKINLIST_BODY'];
4686 $template['body'] = '<li><a tabindex="<%tabindex%>" href="index.php?action=skinedittype&skinid=<%skinid%>'
4687 . '&type=<%skintype%>"><%skintype%></a> (<a tabindex="<%tabindex%>" href="index.php?'
4688 . 'action=skinremovetype&skinid=<%skinid%>&type=<%skintype%>">remove</a>)</li>';
4691 while ( $row = sql_fetch_assoc($res) )
4694 'tabindex' => $tabstart++,
4695 'skinid' => $skinid,
4696 'skintype' => Entity::hsc(strtolower($row['stype']))
4698 echo TEMPLATE::fill($template['body'], $data);
4701 if (array_key_exists('SPECIALSKINLIST_FOOT', $templates) && !empty($templates['SPECIALSKINLIST_FOOT']) )
4703 $template['foot'] = $templates['SPECIALSKINLIST_FOOT'];
4707 $template['foot'] = "</ul>\n";
4709 echo TEMPLATE::fill($template['foot'], $data);
4715 * AdminActions::parse_sprinttext()
4718 * @param string $which
4719 * @param string $val
4722 public function parse_sprinttext($which, $val)
4724 if ( !defined($which) )
4730 $base = constant($which);
4733 if ( preg_match('#[^<|%].*[^%|>]#', $val, $matchies) )
4735 if ( !preg_match('#[(].*[^)]#', $matchies[0], $args) )
4737 $met = 'parse_' . $matchies[0];
4741 $arg = trim($args[0], '()');
4742 $met = 'parse_' . substr($matchies[0], 0, strpos($matchies[0], '('));
4745 if ( method_exists($this, $met) )
4747 $value = call_user_func(array(&$this, $met), $arg);
4751 if ( !isset($value) || empty($value) )
4755 echo sprintf($base, $value);
4760 * AdminActions::parse_systemsettings()
4761 * Parse skinvar systemsettings
4763 * @param string $type type of settings for system
4764 * @param string $templateName name of template to use
4767 public function parse_systemsettings($type = 'phpinfo', $templateName = '')
4769 global $member, $CONF, $nucleus;
4771 $member->isAdmin() or Admin::disallow();
4773 $enable = _ADMIN_SYSTEMOVERVIEW_ENABLE;
4774 $disable = _ADMIN_SYSTEMOVERVIEW_DISABLE;
4781 case 'sqlserverinfo':
4782 echo sql_get_server_info();
4784 case 'sqlclientinfo':
4785 echo sql_get_client_info();
4787 case 'magicquotesgpc':
4788 echo ini_get('magic_quotes_gpc') ? 'On' : 'Off';
4790 case 'magicquotesruntime':
4791 echo ini_get('magic_quotes_runtime') ? 'On' : 'Off';
4793 case 'registerglobals':
4794 echo ini_get('register_globals') ? 'On' : 'Off';
4797 $templates = array();
4798 if ( $templateName )
4800 $templates = Template::read($templateName);
4802 if ( array_key_exists('SYSTEMINFO_GDSETTINGS', $templates) && !empty($templates['SYSTEMINFO_GDSETTINGS']) )
4804 $template = $templates['SYSTEMINFO_GDSETTINGS'];
4808 $template = "<tr>\n\t\t" . '<td width="50%">' . "<%key%></td><td><%value%></td>\n</tr>\n";
4811 $gdinfo = gd_info();
4813 foreach ( $gdinfo as $key => $value )
4815 if ( is_bool($value) )
4817 $value = $value ? $enable : $disable;
4821 $value = Entity::hsc($value);
4827 echo TEMPLATE::fill($template, $data);
4832 phpinfo(INFO_MODULES);
4833 $im = ob_get_contents();
4835 echo ( i18n::strpos($im, 'mod_rewrite') !== FALSE ) ? $enable : $disable;
4837 case 'nucleusversion':
4838 echo getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
4840 case 'nucleuspatchlevel':
4841 echo getNucleusPatchLevel();
4847 echo $CONF['ItemURL'];
4849 case 'alertonheaderssent':
4850 echo $CONF['alertOnHeadersSent'] ? $enable : $disable;
4852 case 'nucleuscodename':
4853 if ( $nucleus['codename'] != '' )
4855 echo ' "' . $nucleus['codename'] . '"';
4858 case 'versioncheckurl':
4859 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4866 * AdminActions::parse_templateoverview()
4867 * Parse skinvar templateoverview
4869 * @param string $templateName name of template to use
4872 public function parse_templateoverview($templateName = '')
4874 $query = "SELECT * FROM %s WHERE tdname NOT LIKE 'admin/%%' ORDER BY tdname";
4875 $query = sprintf($query, sql_table('template_desc'));
4876 $template['content'] = 'templatelist';
4877 $template['tabindex'] = 10;
4878 Showlist($query, 'table', $template, $templateName);
4883 * AdminActions::parse_ticket()
4889 public function parse_ticket()
4892 $manager->addTicketHidden();
4897 * AdminActions::parse_versioncheckurl()
4898 * Parse skinvar versioncheckurl
4903 public function parse_versioncheckurl()
4905 echo sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
4910 * AdminActions::parse_yrbloglist()
4911 * Parse skinvar yrbloglist
4913 * @param string $templateName name of template to use
4916 public function parse_yrbloglist($templateName = '')
4919 $showAll = requestVar('showall');
4921 if ( $member->isAdmin() && ($showAll == 'yes') )
4923 // Super-Admins have access to all blogs! (no add item support though)
4924 $query = "SELECT bnumber, bname, 1 as tadmin, burl, bshortname"
4926 . " ORDER BY bnumber";
4927 $query = sprintf($query, sql_table('blog'));
4931 $query = "SELECT bnumber, bname, tadmin, burl, bshortname"
4933 . " WHERE tblog=bnumber and tmember=%d"
4934 . " ORDER BY bnumber";
4935 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
4938 $template['content'] = 'bloglist';
4939 $template['superadmin'] = $member->isAdmin();
4941 $amount = Showlist($query, 'table', $template, $templateName);
4943 if ( ($showAll != 'yes') && ($member->isAdmin()) )
4945 $query = 'SELECT COUNT(*) as result FROM ' . sql_table('blog');
4947 $total = quickQuery($query);
4948 if ( $total > $amount )
4950 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
4956 echo _OVERVIEW_NOBLOGS;
4958 elseif( $amount != 0 )
4960 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
4962 $query = "SELECT ititle, inumber, bshortname"
4964 . ' WHERE iauthor=%d AND iblog=bnumber AND idraft=1';
4965 $query = sprintf($query, sql_table('item'), sql_table('blog'), (integer) $member->getID());
4967 $template['content'] = 'draftlist';
4969 $amountdrafts = Showlist($query, 'table', $template, $templateName);
4970 if ( $amountdrafts == 0 )
4972 echo _OVERVIEW_NODRAFTS;
4979 * AdminActions::checkCondition()
4980 * Checks conditions for if statements
4982 * @param string $field type of <%if%>
4983 * @param string $name property of field
4984 * @param string $value value of property
4985 * @return boolean condition
4987 protected function checkCondition($field, $name='', $value = '')
4989 global $CONF, $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
5000 $blog =& $manager->getBlog($blogid);
5004 $blogid = getBlogIDFromCatID($catid);
5006 $blog =& $manager->getBlog($blogid);
5008 elseif ( intRequestVar('catid') )
5010 $catid = intRequestVar('catid');
5011 $blogid = getBlogIDFromCatID($catid);
5013 $blog =& $manager->getBlog($blogid);
5020 $condition = ($blog && $this->ifCategory($name, $value));
5023 $condition = ($blog && ($blog->getSetting($name) == $value));
5026 $condition = $member->isLoggedIn();
5029 $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
5032 $condition = $member->isLoggedIn() && $this->ifAdmin($name);
5035 $condition = $member->isLoggedIn() && $member->isAdmin();
5037 case 'allowloginedit':
5038 $condition = $member->isLoggedIn() && ($CONF['AllowLoginEdit'] || $member->isAdmin());
5041 $condition = ($itemidnext != '');
5044 $condition = ($itemidprev != '');
5046 case 'archiveprevexists':
5047 $condition = ($archiveprevexists == true);
5049 case 'archivenextexists':
5050 $condition = ($archivenextexists == true);
5053 $condition = (($name == $this->skintype) || ($name == requestVar('action')));
5056 $condition = $this->ifHasPlugin($name, $value);
5059 $condition = (Admin::getAdminAction() == $name);
5061 case 'adminoldaction':
5062 $condition = (Admin::getAdminAction() == $name);
5064 case 'addresschange':
5065 $condition = ($this->ifAddresscange());
5067 case 'bechangepass':
5068 $condition = ($this->beChangePassword());
5070 case 'skincandidates':
5071 $condition = ($this->ifSkincandidates());
5074 $condition = requestVar('nameclashes');
5076 case 'existsnewplugin':
5077 $condition = ($this->existsNewPlugin());
5080 $condition = (boolean) ($member->getAutosave() == $value);
5083 $condition = $manager->pluginInstalled("NP_{$field}") && $this->ifPlugin($field, $name, $value);
5090 * Actions::_ifHasPlugin()
5091 * hasplugin,PlugName
5092 * -> checks if plugin exists
5093 * hasplugin,PlugName,OptionName
5094 * -> checks if the option OptionName from plugin PlugName is not set to 'no'
5095 * hasplugin,PlugName,OptionName=value
5096 * -> checks if the option OptionName from plugin PlugName is set to value
5098 * @param string $name name of plugin
5099 * @param string $value
5102 private function ifHasPlugin($name, $value)
5106 // (pluginInstalled method won't write a message in the actionlog on failure)
5107 if ( $manager->pluginInstalled("NP_{$name}") )
5109 $plugin =& $manager->getPlugin("NP_{$name}");
5110 if ( $plugin != NULL )
5118 list($name2, $value2) = preg_split('#=#', $value, 2);
5119 if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
5123 else if ( $plugin->getOption($name2) == $value2 )
5134 * Actions::beChangePassword()
5139 private function beChangePassword()
5141 return intRequestVar('bNeedsPasswordChange');
5145 * Actions::ifSkincandidates()
5146 * Checks if a plugin exists and call its doIf function
5151 private function ifSkincandidates()
5154 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
5155 return (count($candidates) > 0);
5159 * Actions::ifPlugin()
5160 * Checks if a plugin exists and call its doIf function
5162 private function ifPlugin($name, $key = '', $value = '')
5166 $plugin =& $manager->getPlugin("NP_{$name}");
5172 $params = func_get_args();
5173 array_shift($params);
5175 return call_user_func_array(array(&$plugin, 'doIf'), $params);
5179 * Different checks for a category
5181 private function ifCategory($name = '', $value='')
5183 global $blog, $catid;
5185 // when no parameter is defined, just check if a category is selected
5186 if (($name != 'catname' && $name != 'catid') || ($value == ''))
5188 return $blog->isValidCategory($catid);
5191 // check category name
5192 if ( $name == 'catname' )
5194 $value = $blog->getCategoryIdFromName($value);
5195 if ($value == $catid)
5197 return $blog->isValidCategory($catid);
5201 // check category id
5202 if (($name == 'catid') && ($value == $catid))
5204 return $blog->isValidCategory($catid);
5211 * Checks if a member is on the team of a blog and return his rights
5213 private function ifOnTeam($blogName = '')
5215 global $blog, $member, $manager;
5217 // when no blog found
5218 if ( ($blogName == '') && !is_object($blog) )
5223 // explicit blog selection
5224 if ($blogName != '')
5226 $blogid = getBlogIDFromName($blogName);
5229 if (($blogName == '') || !$manager->existsBlogID($blogid))
5232 $blogid = $blog->getID();
5234 return $member->teamRights($blogid);
5238 * Checks if a member is admin of a blog
5240 private function ifAdmin($blogName = '')
5242 global $blog, $member, $manager;
5244 // when no blog found
5245 if (($blogName == '') && (!is_object($blog)))
5250 // explicit blog selection
5251 if ($blogName != '')
5253 $blogid = getBlogIDFromName($blogName);
5256 if (($blogName == '') || !$manager->existsBlogID($blogid))
5259 $blogid = $blog->getID();
5262 return $member->isBlogAdmin($blogid);
5266 * Check e-Mail address is changed
5268 private function ifAddresscange()
5270 $key = $this->objAdmin->sessionVar("{$CONF['CookiePrefix']}ackey");
5275 $info = MEMBER::getActivationInfo($key);
5280 $mem = MEMBER::createFromId($info->vmember);
5285 if ( $info->vtype == 'addresschange' )
5293 * AdminActions::customHelp()
5294 * shows a link to custom help file
5297 * @param string $tplName
5298 * @param string $url
5299 * @param string $iconURL
5300 * @param string $alt
5301 * @param string $title
5305 private function customHelp($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5307 echo self::customHelpHtml($id, $tplName, $url, $iconURL, $alt, $title, $onclick);
5311 * AdminActions::customHelp()
5312 * shows a link to custom help file
5315 * @param string $tplName
5316 * @param string $url
5317 * @param string $iconURL
5318 * @param string $alt
5319 * @param string $title
5323 static function customHelplink($id, $tplName = '', $url = '', $title = '', $onclick = '')
5325 $templates = array();
5327 $templates = skinableTEMPLATE::read($tplName);
5329 if (isset($templates['ADMIN_CUSTOMHELPLINK_ANCHOR']) && !empty($templates['ADMIN_CUSTOMHELPLINK_ANCHOR'])) {
5330 $template = $templates['ADMIN_CUSTOMHELPLINK_ANCHOR'];
5332 $template = '<a href="<%helpurl%>#<%helptarget%>" title="<%title%>" <%onclick%>>';
5336 $url = $CONF['AdminURL'] . 'documentation/customHelp.html';
5338 if (empty($onclick)) {
5339 $onclick = 'onclick="if (event && event.preventDefault) event.preventDefault(); return help(this.href);"';
5340 } elseif (preg_match('/^onclick/', $onclick)) {
5341 $onclick = $onclick;
5343 $onclick = 'onclick="' . $onclick . '"';
5347 'helptarget' => $id,
5348 'onclick' => $onclick,
5349 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5351 return TEMPLATE::fill($template, $data);
5355 * AdminActions::customHelpHtml()
5358 * @param string $tplName
5359 * @param string $url
5360 * @param string $iconURL
5361 * @param string $alt
5362 * @param string $title
5363 * @param string $onclick
5364 * @return string anchor element with help uri
5366 private function customHelpHtml($id, $tplName = '', $url = '', $iconURL = '', $alt = '', $title = '', $onclick = '')
5368 $templates = array();
5371 $templates = Template::read($tplName);
5373 if ( array_key_exists('ADMIN_CUSTOMHELPLINK_ICON', $templates) && !empty($templates['ADMIN_CUSTOMHELPLINK_ICON']) )
5375 $template = $templates['ADMIN_CUSTOMHELPLINK_ICON'];
5379 $template = '<img src="<%iconurl%>" <%width%><%height%>alt="<%alt%>" title="<%title%>" /></a>';
5382 if ( empty($iconURL) )
5385 $iconURL = $CONF['AdminURL'] . 'documentation/icon-help.gif';
5387 if ( function_exists('getimagesize') )
5389 $size = getimagesize($iconURL);
5390 $width = 'width="' . $size[0] . '" ';
5391 $height = 'height="' . $size[1] . '" ';
5394 'iconurl' => $iconURL,
5396 'height' => $height,
5397 'alt' => (isset($alt) && !empty($alt)) ? $alt : _HELP_TT,
5398 'title' => (isset($title) && !empty($title)) ? $title : _HELP_TT,
5400 $icon = TEMPLATE::fill($template, $data);
5401 $help = self::customHelplink($id, $tplName, $url, $title, $onclick);
5402 return $help . $icon;
5406 * AdminActions::input_yesno
5409 * @param $checkedval
5416 * @param $templateName
5419 private function input_yesno($name,
5430 $templates = array();
5431 if ( $templateName )
5433 $templates = Template::read($templateName);
5436 if ( $name == 'admin' )
5438 if ( array_key_exists('INPUTYESNO_TEMPLATE_ADMIN', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_ADMIN']) )
5440 $template = $templates['INPUTYESNO_TEMPLATE_ADMIN'];
5444 $template = '<input onclick="selectCanLogin(true);" type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5445 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5446 . '<input onclick="selectCanLogin(false);" type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5447 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5452 if ( array_key_exists('INPUTYESNO_TEMPLATE_NORMAL', $templates) && !empty($templates['INPUTYESNO_TEMPLATE_NORMAL']) )
5454 $template = $templates['INPUTYESNO_TEMPLATE_NORMAL'];
5458 if ( array_key_exists('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO', $templates) && !empty($templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO']) )
5460 $template = $templates['SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'];
5463 if ( !isset($template) )
5465 $template = '<input type="radio" name="<%name%>" value="<%yesval%>" <%yescheckedval%> id="<%yesid%>" />' . "\n"
5466 . '<label for="<%yesid%>"><%yesvaltext%></label>' . "\n"
5467 . '<input type="radio" name="<%name%>" value="<%noval%>" <%nocheckedval%> id="<%noid%>"<%disabled%> />' . "\n"
5468 . '<label for="<%noid%>"><%novaltext%></label>' . "\n";
5473 $id = Entity::hsc($name);
5474 $id = str_replace('[', '-', $id);
5475 $id = str_replace(']', '-', $id);
5476 $id1 = $id . Entity::hsc($value1);
5477 $id2 = $id . Entity::hsc($value2);
5479 'name' => Entity::hsc($name),
5480 'yesval' => Entity::hsc($value1),
5481 'noval' => Entity::hsc($value2),
5484 'yesvaltext' => $yesval,
5485 'novaltext' => $noval,
5486 'yescheckedval' => ($checkedval == $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5487 'nocheckedval' => ($checkedval != $value1) ? ' checked="checked" tabindex="' . $tabindex . '"': '',
5488 'disabled' => ($isAdmin && $name == 'canlogin') ? ' disabled="disabled"' : '',
5493 return Template::fill($template, $dat);
5497 echo TEMPLATE::fill($template, $dat);
5503 * Check exists new plugin
5505 private function existsNewPlugin()
5507 global $DIR_PLUGINS;
5508 $candidates = array();
5509 $files = scandir($DIR_PLUGINS);
5510 foreach ($files as $file) {
5511 if (preg_match("/^NP_(.*)\.php$/", $file, $matches)) {
5512 $name = $matches[1];
5516 . sql_table('plugin') . ' '
5518 . ' pfile = "NP_' . sql_real_escape_string($name) . '"';
5519 $res = sql_query($que);
5520 if (sql_num_rows($res) == 0) {
5521 $candidates[] = $name;
5525 $this->newPlugCandidates = $candidates;
5526 return (count($candidates) > 0);