fetch_all_by_classid(0) as $option) { if($_GET['classid'] == $option['optionid']) { $curclassname = $option['title']; } $classoptionmenu[] = array($option['title'], "threadtypes&operation=typeoption&classid=$option[optionid]", $_GET['classid'] == $option['optionid']); } $mysql_keywords = array( 'ADD', 'ALL', 'ALTER', 'ANALYZE', 'AND', 'AS', 'ASC', 'ASENSITIVE', 'BEFORE', 'BETWEEN', 'BIGINT', 'BINARY', 'BLOB', 'BOTH', 'BY', 'CALL', 'CASCADE', 'CASE', 'CHANGE', 'CHAR', 'CHARACTER', 'CHECK', 'COLLATE', 'COLUMN', 'CONDITION', 'CONNECTION', 'CONSTRAINT', 'CONTINUE', 'CONVERT', 'CREATE', 'CROSS', 'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'CURSOR', 'DATABASE', 'DATABASES', 'DAY_HOUR', 'DAY_MICROSECOND', 'DAY_MINUTE', 'DAY_SECOND', 'DEC', 'DECIMAL', 'DECLARE', 'DEFAULT', 'DELAYED', 'DELETE', 'DESC', 'DESCRIBE', 'DETERMINISTIC', 'DISTINCT', 'DISTINCTROW', 'DIV', 'DOUBLE', 'DROP', 'DUAL', 'EACH', 'ELSE', 'ELSEIF', 'ENCLOSED', 'ESCAPED', 'EXISTS', 'EXIT', 'EXPLAIN', 'FALSE', 'FETCH', 'FLOAT', 'FLOAT4', 'FLOAT8', 'FOR', 'FORCE', 'FOREIGN', 'FROM', 'FULLTEXT', 'GOTO', 'GRANT', 'GROUP', 'HAVING', 'HIGH_PRIORITY', 'HOUR_MICROSECOND', 'HOUR_MINUTE', 'HOUR_SECOND', 'IF', 'IGNORE', 'IN', 'INDEX', 'INFILE', 'INNER', 'INOUT', 'INSENSITIVE', 'INSERT', 'INT', 'INT1', 'INT2', 'INT3', 'INT4', 'INT8', 'INTEGER', 'INTERVAL', 'INTO', 'IS', 'ITERATE', 'JOIN', 'KEY', 'KEYS', 'KILL', 'LABEL', 'LEADING', 'LEAVE', 'LEFT', 'LIKE', 'LIMIT', 'LINEAR', 'LINES', 'LOAD', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCK', 'LONG', 'LONGBLOB', 'LONGTEXT', 'LOOP', 'LOW_PRIORITY', 'MATCH', 'MEDIUMBLOB', 'MEDIUMINT', 'MEDIUMTEXT', 'MIDDLEINT', 'MINUTE_MICROSECOND', 'MINUTE_SECOND', 'MOD', 'MODIFIES', 'NATURAL', 'NOT', 'NO_WRITE_TO_BINLOG', 'NULL', 'NUMERIC', 'ON', 'OPTIMIZE', 'OPTION', 'OPTIONALLY', 'OR', 'ORDER', 'OUT', 'OUTER', 'OUTFILE', 'PRECISION', 'PRIMARY', 'PROCEDURE', 'PURGE', 'RAID0', 'RANGE', 'READ', 'READS', 'REAL', 'REFERENCES', 'REGEXP', 'RELEASE', 'RENAME', 'REPEAT', 'REPLACE', 'REQUIRE', 'RESTRICT', 'RETURN', 'REVOKE', 'RIGHT', 'RLIKE', 'SCHEMA', 'SCHEMAS', 'SECOND_MICROSECOND', 'SELECT', 'SENSITIVE', 'SEPARATOR', 'SET', 'SHOW', 'SMALLINT', 'SPATIAL', 'SPECIFIC', 'SQL', 'SQLEXCEPTION', 'SQLSTATE', 'SQLWARNING', 'SQL_BIG_RESULT', 'SQL_CALC_FOUND_ROWS', 'SQL_SMALL_RESULT', 'SSL', 'STARTING', 'STRAIGHT_JOIN', 'TABLE', 'TERMINATED', 'THEN', 'TINYBLOB', 'TINYINT', 'TINYTEXT', 'TO', 'TRAILING', 'TRIGGER', 'TRUE', 'UNDO', 'UNION', 'UNIQUE', 'UNLOCK', 'UNSIGNED', 'UPDATE', 'USAGE', 'USE', 'USING', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', 'VALUES', 'VARBINARY', 'VARCHAR', 'VARCHARACTER', 'VARYING', 'WHEN', 'WHERE', 'WHILE', 'WITH', 'WRITE', 'X509', 'XOR', 'YEAR_MONTH', 'ZEROFILL', 'ACTION', 'BIT', 'DATE', 'ENUM', 'NO', 'TEXT', 'TIME'); if(!$operation) { $navlang = 'threadtype_infotypes'; $operation = 'type'; $changetype = 'threadsorts'; if(!submitcheck('typesubmit')) { $forumsarray = $fidsarray = array(); $query = C::t('forum_forum')->fetch_all_for_threadsorts(); foreach($query as $forum) { $forum[$changetype] = dunserialize($forum[$changetype]); if(is_array($forum[$changetype]['types'])) { foreach($forum[$changetype]['types'] as $typeid => $name) { $forumsarray[$typeid][] = ''.$forum['name'].''; $fidsarray[$typeid][] = $forum['fid']; } } } $threadtypes = ''; $query = C::t('forum_threadtype')->fetch_all_for_order(); foreach($query as $type) { $tmpstr = "$lang[export]"; $threadtypes .= showtablerow('', array('class="td25"', 'class="td28"', 'class="td29"', 'class="td29"', 'title="'.cplang('forums_threadtypes_forums_comment').'"'), array( "", "", "", "", is_array($forumsarray[$type['typeid']]) ? '" : '', "$lang[detail]   $lang[threadtype_template]", $tmpstr, ), TRUE); } ?> ($curclassname ? $curclassname : 'threadtype_infotypes_option'), 'submenu' => $classoptionmenu), '', 0) )); showformheader("threadtypes&", 'enctype', 'threadtypeform'); showtableheader(''); showsubtitle(array('', 'display_order', cplang('name').' '.cplang('tiny_bbcode_support'), 'description', 'forums_relation', '', ''), 'header', array('', 'width="60"', 'width="110"', 'width="210"', '', 'width="90"', 'width="60"')); echo $threadtypes; echo '
'.''.$lang['import'].''.''.$lang['threadtype_infotypes_add'].'
'; showsubmit('typesubmit', 'submit', 'del'); showtablefooter(); showformfooter(); } else { $updatefids = $modifiedtypes = array(); if(is_array($_GET['delete'])) { if($_GET['delete']) { C::t('forum_typeoptionvar')->delete_by_sortid($_GET['delete']); C::t('forum_typevar')->delete($_GET['delete']); $affected_rows = C::t('forum_threadtype')->delete($_GET['delete']); } foreach($_GET['delete'] as $_GET['sortid']) { C::t('forum_optionvalue')->drop($_GET['sortid']); } if($_GET['delete'] && $affected_rows) { C::t('forum_thread')->update_sortid_by_sortid(0, $_GET['delete']); foreach($_GET['delete'] as $id) { if(is_array($_GET['namenew']) && isset($_GET['namenew'][$id])) { unset($_GET['namenew'][$id]); } if(!empty($_GET['fids'][$id])) { foreach(explode(',', $_GET['fids'][$id]) as $fid) { if($fid = intval($fid)) { $updatefids[$fid]['deletedids'][] = intval($id); } } } } } } if(is_array($_GET['namenew']) && $_GET['namenew']) { foreach($_GET['namenew'] as $typeid => $val) { $_GET['descriptionnew'] = is_array($_GET['descriptionnew']) ? $_GET['descriptionnew'] : array(); $data = array( 'name' => trim($_GET['namenew'][$typeid]), 'description' => dhtmlspecialchars(trim($_GET['descriptionnew'][$typeid])), 'displayorder' => intval($_GET['displayordernew'][$typeid]), 'special' => 1, ); $affected_rows = C::t('forum_threadtype')->update($typeid, $data); if($affected_rows) { $modifiedtypes[] = $typeid; } } if($modifiedtypes = array_unique($modifiedtypes)) { foreach($modifiedtypes as $id) { if(!empty($_GET['fids'][$id])) { foreach(explode(',', $_GET['fids'][$id]) as $fid) { if($fid = intval($fid)) { $updatefids[$fid]['modifiedids'][] = $id; } } } } } } if($updatefids) { $query = C::t('forum_forum')->fetch_all_info_by_fids(array_keys($updatefids)); foreach($query as $forum) { if($forum[$changetype] == '') continue; $fid = $forum['fid']; $forum[$changetype] = dunserialize($forum[$changetype]); if($updatefids[$fid]['deletedids']) { foreach($updatefids[$fid]['deletedids'] as $id) { unset($forum[$changetype]['types'][$id], $forum[$changetype]['flat'][$id], $forum[$changetype]['selectbox'][$id]); } } if($updatefids[$fid]['modifiedids']) { foreach($updatefids[$fid]['modifiedids'] as $id) { if(isset($forum[$changetype]['types'][$id])) { $_GET['namenew'][$id] = trim(strip_tags($_GET['namenew'][$id])); $forum[$changetype]['types'][$id] = $_GET['namenew'][$id]; if(isset($forum[$changetype]['selectbox'][$id])) { $forum[$changetype]['selectbox'][$id] = $_GET['namenew'][$id]; } else { $forum[$changetype]['flat'][$id] = $_GET['namenew'][$id]; } } } } C::t('forum_forumfield')->update($fid, array($changetype => serialize($forum[$changetype]))); } } if(is_array($_GET['newname'])) { foreach($_GET['newname'] as $key => $value) { if($newname1 = trim(strip_tags($value))) { if(C::t('forum_threadtype')->checkname($newname1)) { cpmsg('forums_threadtypes_duplicate', '', 'error'); } $data = array( 'name' => $newname1, 'description' => dhtmlspecialchars(trim($_GET['newdescription'][$key])), 'displayorder' => $_GET['newdisplayorder'][$key], 'special' => 1, ); C::t('forum_threadtype')->insert($data); } } } cpmsg('forums_threadtypes_succeed', 'action=threadtypes', 'succeed'); } } elseif($operation == 'typeoption') { if(!submitcheck('typeoptionsubmit')) { if($_GET['classid']) { $typetitle = C::t('forum_typeoption')->fetch($_GET['classid']); if(!$typetitle['title']) { cpmsg('threadtype_infotypes_noexist', 'action=threadtypes', 'error'); } $typeoptions = ''; foreach(C::t('forum_typeoption')->fetch_all_by_classid($_GET['classid']) as $option) { $option['type'] = $lang['threadtype_edit_vars_type_'. $option['type']]; $typeoptions .= showtablerow('', array('class="td25"', 'class="td28"'), array( "", "", "", "$option[identifier]", $option['type'], "$lang[detail]" ), TRUE); } } echo << var rowtypedata = [ [ [1, '', 'td25'], [1, '', 'td28'], [1, ''], [1, ''], [1, ''], [1, ''] ], ]; EOT; shownav('forum', 'threadtype_infotypes'); showsubmenu('threadtype_infotypes', array( array('threadtype_infotypes_type', 'threadtypes', 0), array('threadtype_infotypes_content', 'threadtypes&operation=content', 0), array(array('menu' => ($curclassname ? $curclassname : 'threadtype_infotypes_option'), 'submenu' => $classoptionmenu), 1) )); showformheader("threadtypes&operation=typeoption&typeid={$_GET['typeid']}"); showhiddenfields(array('classid' => $_GET['classid'])); showtableheader(); showsubtitle(array('', 'display_order', 'name', 'threadtype_variable', 'threadtype_type', '')); echo $typeoptions; echo '
'.$lang['threadtype_infotypes_add_option'].'
'; showsubmit('typeoptionsubmit', 'submit', 'del'); showtablefooter(); showformfooter(); } else { if($ids = dimplode($_GET['delete'])) { C::t('forum_typeoption')->delete($_GET['delete']); C::t('forum_typevar')->delete(null, $_GET['delete']); } if(is_array($_GET['title'])) { foreach($_GET['title'] as $id => $val) { if(in_array(strtoupper($_GET['identifier'][$id]), $mysql_keywords)) { continue; } C::t('forum_typeoption')->update($id, array( 'displayorder' => $_GET['displayorder'][$id], 'title' => $_GET['title'][$id], 'identifier' => $_GET['identifier'][$id], )); } } if(is_array($_GET['newtitle'])) { foreach($_GET['newtitle'] as $key => $value) { $newtitle1 = dhtmlspecialchars(trim($value)); $newidentifier1 = trim($_GET['newidentifier'][$key]); if($newtitle1 && $newidentifier1) { if(in_array(strtoupper($newidentifier1), $mysql_keywords)) { cpmsg('threadtype_infotypes_optionvariable_iskeyword', '', 'error'); } if(C::t('forum_typeoption')->fetch_all_by_identifier($newidentifier1, 0, 1) || strlen($newidentifier1) > 40 || !ispluginkey($newidentifier1)) { cpmsg('threadtype_infotypes_optionvariable_invalid', '', 'error'); } $data = array( 'classid' => $_GET['classid'], 'displayorder' => $_GET['newdisplayorder'][$key], 'title' => $newtitle1, 'identifier' => $newidentifier1, 'type' => $_GET['newtype'][$key], ); C::t('forum_typeoption')->insert($data); } elseif($newtitle1 && !$newidentifier1) { cpmsg('threadtype_infotypes_option_invalid', 'action=threadtypes&operation=typeoption&classid='.$_GET['classid'], 'error'); } } } updatecache('threadsorts'); cpmsg('threadtype_infotypes_succeed', 'action=threadtypes&operation=typeoption&classid='.$_GET['classid'], 'succeed'); } } elseif($operation == 'optiondetail') { $option = C::t('forum_typeoption')->fetch($_GET['optionid']); if(!$option) { cpmsg('typeoption_not_found', '', 'error'); } if(!submitcheck('editsubmit')) { shownav('forum', 'threadtype_infotypes'); showsubmenu('threadtype_infotypes', array( array('threadtype_infotypes_type', 'threadtypes', 0), array('threadtype_infotypes_content', 'threadtypes&operation=content', 0), array(array('menu' => ($curclassname ? $curclassname : 'threadtype_infotypes_option'), 'submenu' => $classoptionmenu), '', 1) )); $typeselect = ''; $option['rules'] = dunserialize($option['rules']); $option['protect'] = dunserialize($option['protect']); $groups = $forums = array(); foreach(C::t('common_usergroup')->range() as $group) { $groups[] = array($group['groupid'], $group['grouptitle']); } $verifys = array(); if($_G['setting']['verify']['enabled']) { foreach($_G['setting']['verify'] as $key => $verify) { if($verify['available'] == 1) { $verifys[] = array($key, $verify['title']); } } } foreach(C::t('common_member_profile_setting')->fetch_all_by_available_formtype(1, 'text') as $result) { $threadtype_profile = !$threadtype_profile ? ""; showformheader("threadtypes&operation=optiondetail&optionid=$_GET[optionid]"); showtableheader(); showtitle('threadtype_infotypes_option_config'); showsetting('name', 'titlenew', $option['title'], 'text'); showsetting('threadtype_variable', 'identifiernew', $option['identifier'], 'text'); showsetting('type', '', '', $typeselect); showsetting('threadtype_edit_desc', 'descriptionnew', $option['description'], 'textarea'); showsetting('threadtype_unit', 'unitnew', $option['unit'], 'text'); showsetting('threadtype_expiration', 'expirationnew', $option['expiration'], 'radio'); if(in_array($option['type'], array('calendar', 'number', 'text', 'email', 'textarea'))) { showsetting('threadtype_protect', 'protectnew[status]', $option['protect']['status'], 'radio', 0, 1); showsetting('threadtype_protect_mode', array('protectnew[mode]', array( array(1, $lang['threadtype_protect_mode_pic']), array(2, $lang['threadtype_protect_mode_html']) )), $option['protect']['mode'], 'mradio'); showsetting('threadtype_protect_usergroup', array('protectnew[usergroup][]', $groups), explode("\t", $option['protect']['usergroup']), 'mselect'); $verifys && showsetting('threadtype_protect_verify', array('protectnew[verify][]', $verifys), explode("\t", $option['protect']['verify']), 'mselect'); showsetting('threadtype_protect_permprompt', 'permpromptnew', $option['permprompt'], 'textarea'); } showtagheader('tbody', "style_calendar", $option['type'] == 'calendar'); showtitle('threadtype_edit_vars_type_calendar'); showsetting('threadtype_edit_inputsize', 'rules[calendar][inputsize]', $option['rules']['inputsize'], 'text'); showtagfooter('tbody'); showtagheader('tbody', "style_number", $option['type'] == 'number'); showtitle('threadtype_edit_vars_type_number'); showsetting('threadtype_edit_maxnum', 'rules[number][maxnum]', $option['rules']['maxnum'], 'text'); showsetting('threadtype_edit_minnum', 'rules[number][minnum]', $option['rules']['minnum'], 'text'); showsetting('threadtype_edit_inputsize', 'rules[number][inputsize]', $option['rules']['inputsize'], 'text'); showsetting('threadtype_defaultvalue', 'rules[number][defaultvalue]', $option['rules']['defaultvalue'], 'text'); showtagfooter('tbody'); showtagheader('tbody', "style_text", $option['type'] == 'text'); showtitle('threadtype_edit_vars_type_text'); showsetting('threadtype_edit_textmax', 'rules[text][maxlength]', $option['rules']['maxlength'], 'text'); showsetting('threadtype_edit_inputsize', 'rules[text][inputsize]', $option['rules']['inputsize'], 'text'); showsetting('threadtype_edit_profile', '', '', $threadtype_profile); showsetting('threadtype_defaultvalue', 'rules[text][defaultvalue]', $option['rules']['defaultvalue'], 'text'); showtagfooter('tbody'); showtagheader('tbody', "style_textarea", $option['type'] == 'textarea'); showtitle('threadtype_edit_vars_type_textarea'); showsetting('threadtype_edit_textmax', 'rules[textarea][maxlength]', $option['rules']['maxlength'], 'text'); showsetting('threadtype_edit_colsize', 'rules[textarea][colsize]', $option['rules']['colsize'], 'text'); showsetting('threadtype_edit_rowsize', 'rules[textarea][rowsize]', $option['rules']['rowsize'], 'text'); showsetting('threadtype_defaultvalue', 'rules[textarea][defaultvalue]', $option['rules']['defaultvalue'], 'text'); showtagfooter('tbody'); showtagheader('tbody', "style_select", $option['type'] == 'select'); showtitle('threadtype_edit_vars_type_select'); showsetting('threadtype_edit_select_choices', 'rules[select][choices]', $option['rules']['choices'], 'textarea'); showsetting('threadtype_edit_inputsize', 'rules[select][inputsize]', $option['rules']['inputsize'], 'text'); showtagfooter('tbody'); showtagheader('tbody', "style_radio", $option['type'] == 'radio'); showtitle('threadtype_edit_vars_type_radio'); showsetting('threadtype_edit_choices', 'rules[radio][choices]', $option['rules']['choices'], 'textarea'); showtagfooter('tbody'); showtagheader('tbody', "style_checkbox", $option['type'] == 'checkbox'); showtitle('threadtype_edit_vars_type_checkbox'); showsetting('threadtype_edit_choices', 'rules[checkbox][choices]', $option['rules']['choices'], 'textarea'); showtagfooter('tbody'); showtagheader('tbody', "style_image", $option['type'] == 'image'); showtitle('threadtype_edit_vars_type_image'); showsetting('threadtype_edit_images_weight', 'rules[image][maxwidth]', $option['rules']['maxwidth'], 'text'); showsetting('threadtype_edit_images_height', 'rules[image][maxheight]', $option['rules']['maxheight'], 'text'); showsetting('threadtype_edit_inputsize', 'rules[image][inputsize]', $option['rules']['inputsize'], 'text'); showtagfooter('tbody'); showtagheader('tbody', "style_range", $option['type'] == 'range'); showtitle('threadtype_edit_vars_type_range'); showsetting('threadtype_edit_maxnum', 'rules[range][maxnum]', $option['rules']['maxnum'], 'text'); showsetting('threadtype_edit_minnum', 'rules[range][minnum]', $option['rules']['minnum'], 'text'); showsetting('threadtype_edit_inputsize', 'rules[range][inputsize]', $option['rules']['inputsize'], 'text'); showsetting('threadtype_edit_searchtxt', 'rules[range][searchtxt]', $option['rules']['searchtxt'], 'text'); showtagfooter('tbody'); showsubmit('editsubmit'); showtablefooter(); showformfooter(); } else { $titlenew = trim($_GET['titlenew']); $_GET['identifiernew'] = trim($_GET['identifiernew']); if(!$titlenew || !$_GET['identifiernew']) { cpmsg('threadtype_infotypes_option_invalid', '', 'error'); } if(in_array(strtoupper($_GET['identifiernew']), $mysql_keywords)) { cpmsg('threadtype_infotypes_optionvariable_iskeyword', '', 'error'); } if(C::t('forum_typeoption')->fetch_all_by_identifier($_GET['identifiernew'], 0, 1, $_GET['optionid']) || strlen($_GET['identifiernew']) > 40 || !ispluginkey($_GET['identifiernew'])) { cpmsg('threadtype_infotypes_optionvariable_invalid', '', 'error'); } $_GET['protectnew']['usergroup'] = $_GET['protectnew']['usergroup'] ? implode("\t", $_GET['protectnew']['usergroup']) : ''; $_GET['protectnew']['verify'] = $_GET['protectnew']['verify'] ? implode("\t", $_GET['protectnew']['verify']) : ''; C::t('forum_typeoption')->update($_GET['optionid'], array( 'title' => $titlenew, 'description' => $_GET['descriptionnew'], 'identifier' => $_GET['identifiernew'], 'type' => $_GET['typenew'], 'unit' => $_GET['unitnew'], 'expiration' => $_GET['expirationnew'], 'protect' => serialize($_GET['protectnew']), 'rules' => serialize($_GET['rules'][$_GET['typenew']]), 'permprompt' => $_GET['permpromptnew'], )); updatecache('threadsorts'); cpmsg('threadtype_infotypes_option_succeed', 'action=threadtypes&operation=typeoption&classid='.$option['classid'], 'succeed'); } } elseif($operation == 'sortdetail') { if(!submitcheck('sortdetailsubmit')) { $threadtype = C::t('forum_threadtype')->fetch($_GET['sortid']); $threadtype['modelid'] = isset($_GET['modelid']) ? intval($_GET['modelid']) : $threadtype['modelid']; $sortoptions = $jsoptionids = ''; $showoption = array(); $typevararr = C::t('forum_typevar')->fetch_all_by_sortid($_GET['sortid'], 'ASC'); $typeoptionarr = C::t('forum_typeoption')->fetch_all(array_keys($typevararr)); foreach($typevararr as $option) { $option['title'] = $typeoptionarr[$option['optionid']]['title']; $option['type'] = $typeoptionarr[$option['optionid']]['type']; $option['identifier'] = $typeoptionarr[$option['optionid']]['identifier']; $jsoptionids .= "optionids.push($option[optionid]);\r\n"; $optiontitle[$option['identifier']] = $option['title']; $showoption[$option['optionid']]['optionid'] = $option['optionid']; $showoption[$option['optionid']]['title'] = $option['title']; $showoption[$option['optionid']]['type'] = $lang['threadtype_edit_vars_type_'. $option['type']]; $showoption[$option['optionid']]['identifier'] = $option['identifier']; $showoption[$option['optionid']]['displayorder'] = $option['displayorder']; $showoption[$option['optionid']]['available'] = $option['available']; $showoption[$option['optionid']]['required'] = $option['required']; $showoption[$option['optionid']]['unchangeable'] = $option['unchangeable']; $showoption[$option['optionid']]['search'] = $option['search']; $showoption[$option['optionid']]['subjectshow'] = $option['subjectshow']; } unset($typevararr, $typeoptionarr); if($existoption && is_array($existoption)) { $optionids = array(); foreach($existoption as $optionid => $val) { $optionids[] = $optionid; } foreach(C::t('forum_typeoption')->fetch_all($optionids) as $option) { $showoption[$option['optionid']]['optionid'] = $option['optionid']; $showoption[$option['optionid']]['title'] = $option['title']; $showoption[$option['optionid']]['type'] = $lang['threadtype_edit_vars_type_'. $option['type']]; $showoption[$option['optionid']]['identifier'] = $option['identifier']; $showoption[$option['optionid']]['required'] = $existoption[$option['optionid']]; $showoption[$option['optionid']]['available'] = 1; $showoption[$option['optionid']]['unchangeable'] = 0; $showoption[$option['optionid']]['model'] = 1; } } $searchtitle = $searchvalue = $searchunit = array(); foreach($showoption as $optionid => $option) { $sortoptions .= showtablerow('id="optionid'.$optionid.'"', array('class="td25"', 'class="td28 td23"'), array( "", "", "", dhtmlspecialchars($option['title']), $option['type'], "", "", "", "", "", "".$lang['edit']."" ), TRUE); $searchtitle[] = '/{('.$option['identifier'].')}/e'; $searchvalue[] = '/\[('.$option['identifier'].')value\]/e'; $searchunit[] = '/\[('.$option['identifier'].')unit\]/e'; } shownav('forum', 'threadtype_infotypes'); showsubmenu('threadtype_infotypes', array( array('threadtype_infotypes_type', 'threadtypes', 1), array('threadtype_infotypes_content', 'threadtypes&operation=content', 0), array(array('menu' => ($curclassname ? $curclassname : 'threadtype_infotypes_option'), 'submenu' => $classoptionmenu), '', 0) )); showsubmenu('forums_edit_threadsorts'); showtips('forums_edit_threadsorts_tips'); showformheader("threadtypes&operation=sortdetail&sortid={$_GET['sortid']}"); showtableheader('threadtype_infotypes_validity', 'nobottom'); showsetting('threadtype_infotypes_validity', 'typeexpiration', $threadtype['expiration'], 'radio'); showtablefooter(); showtableheader("$threadtype[name] - $lang[threadtype_infotypes_add_option]", 'noborder fixpadding'); showtablerow('', 'id="classlist"', ''); showtablerow('', 'id="optionlist"', ''); showtablefooter(); showtableheader("$threadtype[name] - $lang[threadtype_infotypes_exist_option]", 'noborder fixpadding', 'id="sortlist"'); showsubtitle(array('', 'display_order', 'available', 'name', 'type', 'required', 'unchangeable', 'threadtype_infotypes_formsearch', 'threadtype_infotypes_fontsearch', 'threadtype_infotypes_show', '')); echo $sortoptions; showtablefooter(); ?> fetch($_GET['sortid']); if($_GET['typeexpiration'] != $threadtype['expiration']) { $query = C::t('forum_forum')->fetch_all_for_threadsorts(); $fidsarray = array(); foreach($query as $forum) { $forum['threadsorts'] = dunserialize($forum['threadsorts']); if(is_array($forum['threadsorts']['types'])) { foreach($forum['threadsorts']['types'] as $typeid => $name) { $typeid == $_GET['sortid'] && $fidsarray[$forum['fid']] = $forum['threadsorts']; } } } if($fidsarray) { foreach($fidsarray as $changefid => $forumthreadsorts) { $forumthreadsorts['expiration'][$_GET['sortid']] = $_GET['typeexpiration']; C::t('forum_forumfield')->update($changefid, array('threadsorts' => serialize($forumthreadsorts))); } } } C::t('forum_threadtype')->update($_GET['sortid'], array('special' => 1, 'modelid' => $_GET['modelid'], 'expiration' => $_GET['typeexpiration'])); if(submitcheck('sortdetailsubmit')) { $orgoption = $orgoptions = $addoption = array(); foreach(C::t('forum_typevar')->fetch_all_by_sortid($_GET['sortid']) as $orgoption) { $orgoptions[] = $orgoption['optionid']; } $addoption = $addoption ? (array)$addoption + (array)$_GET['displayorder'] : (array)$_GET['displayorder']; @$newoptions = array_keys($addoption); if(empty($addoption)) { cpmsg('threadtype_infotypes_invalid', '', 'error'); } @$delete = array_merge((array)$_GET['delete'], array_diff($orgoptions, $newoptions)); if($delete) { if($ids = dimplode($delete)) { C::t('forum_typevar')->delete($_GET['sortid'], $delete); } foreach($delete as $id) { unset($addoption[$id]); } } $insertoptionid = $indexoption = array(); $create_table_sql = $separator = $create_tableoption_sql = ''; if(is_array($addoption) && !empty($addoption)) { foreach(C::t('forum_typeoption')->fetch_all(array_keys($addoption)) as $option) { $insertoptionid[$option['optionid']]['type'] = $option['type']; $insertoptionid[$option['optionid']]['identifier'] = $option['identifier']; } if(!C::t('forum_optionvalue')->showcolumns($_GET['sortid'])) { $fields = ''; foreach($addoption as $optionid => $option) { $identifier = $insertoptionid[$optionid]['identifier']; if($identifier) { if(in_array($insertoptionid[$optionid]['type'], array('radio'))) { $create_tableoption_sql .= "$separator$identifier smallint(6) UNSIGNED NOT NULL DEFAULT '0'"; } elseif(in_array($insertoptionid[$optionid]['type'], array('number', 'range'))) { $create_tableoption_sql .= "$separator$identifier int(10) UNSIGNED NOT NULL DEFAULT '0'"; } elseif($insertoptionid[$optionid]['type'] == 'select') { $create_tableoption_sql .= "$separator$identifier varchar(50) NOT NULL"; } else { $create_tableoption_sql .= "$separator$identifier mediumtext NOT NULL"; } $separator = ' ,'; if(in_array($insertoptionid[$optionid]['type'], array('radio', 'select', 'number'))) { $indexoption[] = $identifier; } } } $fields .= ($create_tableoption_sql ? $create_tableoption_sql.',' : '')."tid mediumint(8) UNSIGNED NOT NULL DEFAULT '0',fid smallint(6) UNSIGNED NOT NULL DEFAULT '0',dateline int(10) UNSIGNED NOT NULL DEFAULT '0',expiration int(10) UNSIGNED NOT NULL DEFAULT '0',"; $fields .= "KEY (fid), KEY(dateline)"; if($indexoption) { foreach($indexoption as $index) { $fields .= "$separator KEY $index ($index)"; $separator = ' ,'; } } $dbcharset = $_G['config']['db'][1]['dbcharset']; $dbcharset = empty($dbcharset) ? str_replace('-','',CHARSET) : $dbcharset; C::t('forum_optionvalue')->create($_GET['sortid'], $fields, $dbcharset); } else { $tables = C::t('forum_optionvalue')->showcolumns($_GET['sortid']); foreach($addoption as $optionid => $option) { $identifier = $insertoptionid[$optionid]['identifier']; if(!$tables[$identifier]) { $fieldname = $identifier; if(in_array($insertoptionid[$optionid]['type'], array('radio'))) { $fieldtype = 'smallint(6) UNSIGNED NOT NULL DEFAULT \'0\''; } elseif(in_array($insertoptionid[$optionid]['type'], array('number', 'range'))) { $fieldtype = 'int(10) UNSIGNED NOT NULL DEFAULT \'0\''; } elseif($insertoptionid[$optionid]['type'] == 'select') { $fieldtype = 'varchar(50) NOT NULL'; } else { $fieldtype = 'mediumtext NOT NULL'; } C::t('forum_optionvalue')->alter($_GET['sortid'], "ADD $fieldname $fieldtype"); if(in_array($insertoptionid[$optionid]['type'], array('radio', 'select', 'number'))) { C::t('forum_optionvalue')->alter($_GET['sortid'], "ADD INDEX ($fieldname)"); } } } } foreach($addoption as $id => $val) { $optionid = C::t('forum_typeoption')->fetch($id); if($optionid) { $data = array( 'sortid' => $_GET['sortid'], 'optionid' => $id, 'available' => 1, 'required' => intval($val), ); C::t('forum_typevar')->insert($data, 0, 0, 1); $search_bit = 0; foreach($_GET['search'][$id] AS $key => $val) { if($val == 1) { if($key == 'font') { $search_bit = setstatus(2, 1, $search_bit); } elseif($key == 'form') { $search_bit = setstatus(1, 1, $search_bit); } } } C::t('forum_typevar')->update($_GET['sortid'], $id, array( 'displayorder' => $_GET['displayorder'][$id], 'available' => $_GET['available'][$id], 'required' => $_GET['required'][$id], 'unchangeable' => $_GET['unchangeable'][$id], 'search' => $search_bit, 'subjectshow' => $_GET['subjectshow'][$id], )); } else { C::t('forum_typevar')->delete($_GET['sortid'], $id); } } } updatecache('threadsorts'); cpmsg('threadtype_infotypes_succeed', 'action=threadtypes&operation=sortdetail&sortid='.$_GET['sortid'], 'succeed'); } } } elseif($operation == 'sorttemplate') { if(!submitcheck('sorttemplatesubmit')) { $threadtype = C::t('forum_threadtype')->fetch($_GET['sortid']); $showoption = ''; $typevararr = C::t('forum_typevar')->fetch_all_by_sortid($_GET['sortid'], 'ASC'); $typeoptionarr = C::t('forum_typeoption')->fetch_all(array_keys($typevararr)); foreach($typevararr as $option) { $option['title'] = $typeoptionarr[$option['optionid']]['title']; $option['type'] = $typeoptionarr[$option['optionid']]['type']; $option['identifier'] = $typeoptionarr[$option['optionid']]['identifier']; $showoption .= '  '; } unset($typevararr, $typeoptionarr); showsubmenu('threadtype_infotypes', array( array('threadtype_infotypes_type', 'threadtypes', 1), array('threadtype_infotypes_content', 'threadtypes&operation=content', 0), array(array('menu' => ($curclassname ? $curclassname : 'threadtype_infotypes_option'), 'submenu' => $classoptionmenu), '', 0) )); showformheader("threadtypes&operation=sorttemplate&sortid={$_GET['sortid']}"); echo ''. '
'; echo '
'. $showoption. '
'. '
'. '
'; echo ''; echo ''; echo ''. ''; echo ''; } else { C::t('forum_threadtype')->update($_GET['sortid'], array( 'special' => 1, 'template' => $_GET['typetemplate'], 'stemplate' => $_GET['stypetemplate'], 'ptemplate' => $_GET['ptypetemplate'], 'btemplate' => $_GET['btypetemplate'], 'expiration' => $_GET['typeexpiration'], )); updatecache('threadsorts'); cpmsg('threadtype_infotypes_succeed', 'action=threadtypes&operation=sorttemplate&sortid='.$_GET['sortid'], 'succeed'); } } elseif($operation == 'content') { if(!submitcheck('searchsortsubmit', 1) && !submitcheck('delsortsubmit') && !submitcheck('sendpmsubmit')) { shownav('forum', 'threadtype_infotypes'); showsubmenu('threadtype_infotypes', array( array('threadtype_infotypes_type', 'threadtypes', 0), array('threadtype_infotypes_content', 'threadtypes&operation=content', 1), array(array('menu' => ($curclassname ? $curclassname : 'threadtype_infotypes_option'), 'submenu' => $classoptionmenu)) )); $_GET['sortid'] = intval($_GET['sortid']); $threadtypes = ''; showformheader('threadtypes&operation=content'); showtableheader('threadtype_content_choose'); showsetting('threadtype_content_name', '', '', $threadtypes); if($_GET['sortid']) { showtableheader('threadtype_content_sort_by_conditions'); loadcache(array('threadsort_option_'.$_GET['sortid'])); $sortoptionarray = $_G['cache']['threadsort_option_'.$_GET['sortid']]; if(is_array($sortoptionarray)) foreach($sortoptionarray as $optionid => $option) { $optionshow = ''; if($option['search']) { if(in_array($option['type'], array('radio', 'checkbox', 'select'))){ if($option['type'] == 'select') { $optionshow .= ''; } elseif($option['type'] == 'radio') { $optionshow .= ''.cplang('unlimited').' '; foreach($option['choices'] as $id => $value) { $optionshow .= ' '.$value.'  '; } $optionshow .= ''; } elseif($option['type'] == 'checkbox') { foreach($option['choices'] as $id => $value) { $optionshow .= ' '.$value.''; } $optionshow .= ''; } } elseif(in_array($option['type'], array('number', 'text', 'email', 'calendar', 'image', 'url', 'textarea', 'upload', 'range'))) { if ($option['type'] == 'calendar') { $optionshow .= ''; } elseif($option['type'] == 'number') { $optionshow .= '   '; } elseif($option['type'] == 'range') { $optionshow .= ' - '; } else { $optionshow .= ''; } } $optionshow .= ' '.$option['unit']; showsetting($option['title'], '', '', $optionshow); } } } showsubmit('searchsortsubmit', 'submit'); showtablefooter(); showformfooter(); } else { if(submitcheck('searchsortsubmit', 1)) { if(empty($_GET['searchoption']) && !$_GET['sortid']) { cpmsg('threadtype_content_no_choice', 'action=threadtypes&operation=content', 'error'); } $mpurl = ADMINSCRIPT.'?action=threadtypes&operation=content&sortid='.$_GET['sortid'].'&searchsortsubmit=true'; if(!is_array($_GET['searchoption'])) { $mpurl .= '&searchoption='.$_GET['searchoption']; $_GET['searchoption'] = dunserialize(base64_decode($_GET['searchoption'])); } else { $mpurl .= '&searchoption='.base64_encode(serialize($_GET['searchoption'])); } shownav('forum', 'threadtype_infotypes'); showsubmenu('threadtype_infotypes', array( array('threadtype_infotypes_type', 'threadtypes', 0), array('threadtype_infotypes_content', 'threadtypes&operation=content', 1), array(array('menu' => ($curclassname ? $curclassname : 'threadtype_infotypes_option'), 'submenu' => $classoptionmenu)) )); loadcache('forums'); loadcache(array('threadsort_option_'.$_GET['sortid'])); require_once libfile('function/threadsort'); sortthreadsortselectoption($_GET['sortid']); $sortoptionarray = $_G['cache']['threadsort_option_'.$_GET['sortid']]; $selectsql = ''; if($_GET['searchoption']) { foreach($_GET['searchoption'] as $optionid => $option) { $fieldname = $sortoptionarray[$optionid]['identifier'] ? $sortoptionarray[$optionid]['identifier'] : 1; if($option['value']) { if(in_array($option['type'], array('number', 'radio'))) { $option['value'] = intval($option['value']); $exp = '='; if($option['condition']) { $exp = $option['condition'] == 1 ? '>' : '<'; } $sql = "$fieldname$exp'$option[value]'"; } elseif($option['type'] == 'select') { $subvalues = $currentchoices = array(); if(!empty($sortoptionarray)) { foreach($sortoptionarray as $subkey => $subvalue) { if($subvalue['identifier'] == $fieldname) { $currentchoices = $subvalue['choices']; break; } } } if(!empty($currentchoices)) { foreach($currentchoices as $subkey => $subvalue) { if(preg_match('/^'.$option['value'].'/i', $subkey)) { $subvalues[] = $subkey; } } } $sql = "$fieldname IN (".dimplode($subvalues).")"; } elseif($option['type'] == 'checkbox') { $sql = "$fieldname LIKE '%".(implode("%", $option['value']))."%'"; } elseif($option['type'] == 'range') { $sql = $option['value']['min'] || $option['value']['max'] ? "$fieldname BETWEEN ".intval($option['value']['min'])." AND ".intval($option['value']['max'])."" : ''; } else { $sql = "$fieldname LIKE '%$option[value]%'"; } $selectsql .= $and."$sql "; $and = 'AND '; } } $selectsql = trim($selectsql); $searchtids = C::t('forum_optionvalue')->fetch_all_tid($_GET['sortid'], $selectsql ? 'WHERE '.$selectsql : ''); } if($searchtids) { $lpp = max(5, empty($_GET['lpp']) ? 50 : intval($_GET['lpp'])); $start_limit = ($page - 1) * $lpp; $threadcount = C::t('forum_thread')->count_by_tid_fid($searchtids); if($threadcount) { foreach(C::t('forum_thread')->fetch_all_by_tid($searchtids, $start_limit, $lpp) as $thread) { $threads .= showtablerow('', array('class="td25"', '', '', 'class="td28"', 'class="td28"'), array( "". "", "$thread[subject]", "{$_G['cache'][forums][$thread[fid]][name]}", "$thread[author]", $thread['replies'], $thread['views'], dgmdate($thread['lastpost'], 'd'), ), TRUE); } $multipage = multi($threadcount, $lpp, $page, $mpurl, 0, 3); } } showformheader('threadtypes&operation=content'); showtableheader('admin', 'fixpadding'); showsubtitle(array('', 'subject', 'forum', 'author', 'threads_replies', 'threads_views', 'threads_lastpost')); echo $threads; echo $multipage; showsubmit('', '', '', ""); showtablefooter(); showformfooter(); } elseif(submitcheck('delsortsubmit')) { require_once libfile('function/post'); if($_GET['tidsarray']) { require_once libfile('function/delete'); deletethread($_GET['tidsarray']); if($_G['setting']['globalstick']) { updatecache('globalstick'); } if($_GET['fidsarray']) { foreach(explode(',', $_GET['fidsarray']) as $fid) { updateforumcount(intval($fid)); } } } cpmsg('threadtype_content_delete_succeed', 'action=threadtypes&operation=content', 'succeed'); } } } elseif($operation == 'classlist') { $classoptions = ''; $classidarray = array(); $classid = $_GET['classid'] ? $_GET['classid'] : 0; foreach(C::t('forum_typeoption')->fetch_all_by_classid($classid) as $option) { $classidarray[] = $option['optionid']; $classoptions .= "$option[title]   "; } include template('common/header'); echo $classoptions; include template('common/footer'); exit; } elseif($operation == 'optionlist') { $classid = $_GET['classid']; if(!$classid) { $classid = C::t('forum_typeoption')->fetch_all_by_classid(0, 0, 1); $classid = $classid[0]['optionid']; } $option = $options = array(); foreach(C::t('forum_typevar')->fetch_all_by_sortid($_GET['typeid']) as $option) { $options[] = $option['optionid']; } $optionlist = ''; foreach(C::t('forum_typeoption')->fetch_all_by_classid($classid) as $option) { $optionlist .= "  "; } include template('common/header'); echo $optionlist; include template('common/footer'); exit; } elseif($operation == 'sortlist') { $optionid = $_GET['optionid']; $option = C::t('forum_typeoption')->fetch($optionid); include template('common/header'); $option['type'] = $lang['threadtype_edit_vars_type_'. $option['type']]; $option['available'] = 1; showtablerow('', array('class="td25"', 'class="td28 td23"'), array( "", "", "", dhtmlspecialchars($option['title']), $option[type], "", "", "", "", "", "".$lang['edit']."" )); include template('common/footer'); exit; } elseif($operation == 'import') { $sortid = 0; $newthreadtype = getimportdata('Discuz! Threadtypes'); if($newthreadtype) { $idcmp = $searcharr = $replacearr = $indexoption = array(); $create_tableoption_sql = $separator = ''; $i = 0; foreach($newthreadtype as $key => $value) { if(!$i) { if($newname1 = trim(strip_tags($value['name']))) { $findname = 0; $tmpnewname1 = $newname1; $decline = '_'; while(!$findname) { if(C::t('forum_threadtype')->checkname($tmpnewname1)) { $tmpnewname1 = $newname1.$decline; $decline .= '_'; } else { $findname = 1; } } $newname1 = $tmpnewname1; $data = array( 'name' => $newname1, 'description' => dhtmlspecialchars(trim($value['ttdescription'])), 'special' => 1, ); $sortid = C::t('forum_threadtype')->insert($data, 1); } $i = 1; if(empty($value['identifier'])) { cpmsg('threadtype_import_succeed', 'action=threadtypes', 'succeed'); } } $typeoption = array( 'classid' => $value['classid'], 'expiration' => $value['tpexpiration'], 'protect' => $value['protect'], 'title' => $value['title'], 'description' => $value['tpdescription'], 'type' => $value['type'], 'unit' => $value['unit'], 'rules' => $value['rules'], 'permprompt' => $value['permprompt'], ); if(strlen($value['identifier']) > 34) { cpmsg('threadtype_infotypes_optionvariable_invalid', 'action=threadtypes', 'error'); } $findidentifier = 0; $tmpidentifier = $value['identifier']; $decline = '_'; while(!$findidentifier) { if(C::t('forum_typeoption')->fetch_all_by_identifier($tmpidentifier, 0, 1) || !ispluginkey($tmpidentifier) || in_array(strtoupper($tmpidentifier), $mysql_keywords)) { $tmpidentifier = $value['identifier'].$decline.$sortid; $decline .= '_'; } else { $findidentifier = 1; } } $typeoption['identifier'] = $tmpidentifier; $idcmp[$value['identifier']] = $tmpidentifier; $newoptionid = C::t('forum_typeoption')->insert($typeoption, true); $typevar = array( 'sortid' => $sortid, 'optionid' => $newoptionid, 'available' => $value['available'], 'required' => $value['required'], 'unchangeable' => $value['unchangeable'], 'search' => $value['search'], 'displayorder' => $value['displayorder'], 'subjectshow' => $value['subjectshow'], ); C::t('forum_typevar')->insert($typevar); if($tmpidentifier) { if(in_array($value['type'], array('radio'))) { $create_tableoption_sql .= "$separator$tmpidentifier smallint(6) UNSIGNED NOT NULL DEFAULT '0'"; } elseif(in_array($value['type'], array('number', 'range'))) { $create_tableoption_sql .= "$separator$tmpidentifier int(10) UNSIGNED NOT NULL DEFAULT '0'"; } elseif($value['type'] == 'select') { $create_tableoption_sql .= "$separator$tmpidentifier varchar(50) NOT NULL"; } else { $create_tableoption_sql .= "$separator$tmpidentifier mediumtext NOT NULL"; } $separator = ' ,'; if(in_array($value['type'], array('radio', 'select', 'number'))) { $indexoption[] = $tmpidentifier; } } } foreach($idcmp as $k => $v) { if($k != $v) { $searcharr[] = '{'.$k; $searcharr[] = '['.$k; $replacearr[] = '{'.$v; $replacearr[] = '['.$v; } } $threadtype = array( 'icon' => $value['icon'], 'special' => $value['special'], 'modelid' => $value['modelid'], 'expiration' => $value['ttexpiration'], 'template' => str_replace($searcharr, $replacearr, $value['template']), 'stemplate' => str_replace($searcharr, $replacearr, $value['stemplate']), 'ptemplate' => str_replace($searcharr, $replacearr, $value['ptemplate']), 'btemplate' => str_replace($searcharr, $replacearr, $value['btemplate']), ); DB::update('forum_threadtype', $threadtype, array('typeid' => $sortid)); $fields = ($create_tableoption_sql ? $create_tableoption_sql.',' : '')."tid mediumint(8) UNSIGNED NOT NULL DEFAULT '0',fid smallint(6) UNSIGNED NOT NULL DEFAULT '0',dateline int(10) UNSIGNED NOT NULL DEFAULT '0',expiration int(10) UNSIGNED NOT NULL DEFAULT '0',"; $fields .= "KEY (fid), KEY(dateline)"; if($indexoption) { foreach($indexoption as $index) { $fields .= "$separator KEY $index ($index)"; $separator = ' ,'; } } $dbcharset = $_G['config']['db'][1]['dbcharset']; $dbcharset = empty($dbcharset) ? str_replace('-','',CHARSET) : $dbcharset; C::t('forum_optionvalue')->create($sortid, $fields, $dbcharset); updatecache('threadsorts'); } cpmsg('threadtype_import_succeed', 'action=threadtypes', 'succeed'); } elseif($operation == 'export') { $sortid = intval($_GET['sortid']); $typevarlist = array(); $typevararr = C::t('forum_typevar')->fetch_all_by_sortid($sortid); $typeoptionarr = C::t('forum_typeoption')->fetch_all(array_keys($typevararr)); $threadtypearr = C::t('forum_threadtype')->fetch($sortid); foreach($typevararr as $typevar) { $typeoption = $typeoptionarr[$typevar['optionid']]; $typevar = array_merge($threadtypearr, $typevar); $typevar = array_merge($typeoption, $typevar); $typevar['tpdescription'] = $typeoption['description']; $typevar['ttdescription'] = $threadtypearr['description']; $typevar['tpexpiration'] = $typeoption['expiration']; $typevar['ttexpiration'] = $threadtypearr['expiration']; unset($typevar['fid']); $typevarlist[] = $typevar; } if(empty($typevarlist)) { $threadtype = C::t('forum_threadtype')->fetch($sortid); $threadtype['ttdescription'] = $threadtype['description']; unset($threadtype['fid']); $typevarlist[] = $threadtype; } if(empty($typevarlist)) { cpmsg('threadtype_export_error'); } exportdata('Discuz! Threadtypes', $typevarlist[0]['typeid'], $typevarlist); } ?>