' .'' .''.cplang('hide_search').'' .''; showsubmenu('diytemplate', array( array('list', 'diytemplate', 1), ), $searchctrl); $intkeys = array('uid', 'closed'); $strkeys = array(); $randkeys = array(); $likekeys = array('targettplname', 'primaltplname', 'username', 'name'); $results = getwheres($intkeys, $strkeys, $randkeys, $likekeys); foreach($likekeys as $k) { $_GET[$k] = dhtmlspecialchars($_GET[$k]); } $wherearr = $results['wherearr']; $mpurl = ADMINSCRIPT.'?action=diytemplate'; $mpurl .= '&'.implode('&', $results['urls']); $wherearr[] = " primaltplname NOT LIKE 'portal/list%' "; $wherearr[] = " primaltplname NOT LIKE 'portal/portal_topic_content%' "; if($_GET['permname']) { $tpls = ''; $member = C::t('common_member')->fetch_by_username($_GET['permname']); if($member && $member['adminid'] != 1) { $tpls = array_keys(C::t('common_template_permission')->fetch_all_by_uid($member['uid'])); if(($tpls = dimplode($tpls))) { $wherearr[] = 'targettplname IN ('.$tpls.')'; } else { cpmsg_error($_GET['permname'].cplang('diytemplate_the_username_has_not_template')); } } $mpurl .= '&permname='.$_GET['permname']; } $wheresql = empty($wherearr)?'':implode(' AND ', $wherearr); $orders = getorders(array('dateline','targettplname'), 'dateline'); $ordersql = $orders['sql']; if($orders['urls']) $mpurl .= '&'.implode('&', $orders['urls']); $orderby = array($_GET['orderby']=>' selected'); $ordersc = array($_GET['ordersc']=>' selected'); $perpage = empty($_GET['perpage'])?0:intval($_GET['perpage']); if(!in_array($perpage, array(10,20,50,100))) $perpage = 20; $perpages = array($perpage=>' selected'); $searchlang = array(); $keys = array('search', 'likesupport', 'resultsort', 'defaultsort', 'orderdesc', 'orderasc', 'perpage_10', 'perpage_20', 'perpage_50', 'perpage_100', 'diytemplate_name', 'diytemplate_dateline', 'diytemplate_targettplname', 'diytemplate_primaltplname', 'diytemplate_uid', 'diytemplate_username', 'nolimit', 'no', 'yes', 'diytemplate_permname', 'diytemplate_permname_tips'); foreach ($keys as $key) { $searchlang[$key] = cplang($key); } $adminscript = ADMINSCRIPT; echo <<
$searchlang[diytemplate_name]* $searchlang[diytemplate_targettplname]* $searchlang[diytemplate_primaltplname]* *$searchlang[likesupport]
$searchlang[diytemplate_uid] $searchlang[diytemplate_username]*
$searchlang[resultsort] $searchlang[diytemplate_permname] $searchlang[diytemplate_permname_tips]
SEARCH; $start = ($page-1)*$perpage; $mpurl .= '&perpage='.$perpage; $perpages = array($perpage => ' selected'); showformheader('diytemplate'); showtableheader('diytemplate_list'); showsubtitle(array('diytemplate_name', 'diytemplate_targettplname', 'diytemplate_primaltplname', 'username', 'diytemplate_dateline', 'operation')); $multipage = ''; if(($count = C::t('common_diy_data')->count_by_where($wheresql))) { loadcache('diytemplatename'); require_once libfile('function/block'); foreach(C::t(common_diy_data)->fetch_all_by_where($wheresql, $ordersql, $start, $perpage) as $value) { $value['name'] = $_G['cache']['diytemplatename'][$value['targettplname']]; $value['dateline'] = $value['dateline'] ? dgmdate($value['dateline']) : ''; $diyurl = block_getdiyurl($value['targettplname']); $diytitle = cplang($diyurl['flag'] ? 'diytemplate_share' : 'diytemplate_alone'); showtablerow('', array('class=""', 'class=""', 'class="td28"'), array( "$value[name]", ''.$value['targettplname'].'', ''.$value['primaltplname'].'', "$value[username]", $value[dateline], ''.cplang('edit').' '. ''.cplang('diytemplate_perm').'', )); } $multipage = multi($count, $perpage, $page, $mpurl); } showsubmit('', '', '', '', $multipage); showtablefooter(); showformfooter(); } elseif($operation == 'edit') { loadcache('diytemplatename'); $targettplname = $_GET['targettplname']; $tpldirectory = $_GET['tpldirectory']; $diydata = C::t('common_diy_data')->fetch($targettplname, $tpldirectory); if(empty($diydata)) { cpmsg_error('diytemplate_targettplname_error', dreferer());} if(!submitcheck('editsubmit')) { if(empty($diydata['name'])) $diydata['name'] = $_G['cache']['diytemplatename'][$diydata['targettplname']]; shownav('portal', 'diytemplate', $diydata['name']); showsubmenu(cplang('diytemplate_edit').' - '.$diydata['name'], array( array('list', 'diytemplate', 0), array('edit', 'diytemplate&operation=edit&targettplname='.$_GET['targettplname']."&tpldirectory=$tpldirectory", 1) )); showformheader("diytemplate&operation=edit&targettplname=$targettplname&tpldirectory=$tpldirectory"); showtableheader(); showtitle('edit'); showsetting('diytemplate_name', 'name', $diydata['name'],'text'); showsetting('diytemplate_targettplname', '', '',cplang('diytemplate_path').'./data/diy/'.$diydata['targettplname'].'.htm'); showsetting('diytemplate_primaltplname', '', '',cplang('diytemplate_path').$_G['style']['tpldir'].'/'.$diydata['primaltplname'].'.htm'); showsetting('diytemplate_username', '', '',$diydata['username']); showsetting('diytemplate_dateline', '', '',$diydata['dateline'] ? dgmdate($diydata['dateline']) : ''); showsubmit('editsubmit'); showtablefooter(); showformfooter(); } else { $editdiydata = array('name'=>$_GET['name']); C::t('common_diy_data')->update($targettplname, $tpldirectory, $editdiydata); include_once libfile('function/cache'); updatecache('diytemplatename'); cpmsg('diytemplate_edit_succeed', 'action=diytemplate', 'succeed'); } } elseif($operation=='perm') { loadcache('diytemplatename'); $targettplname = $_GET['targettplname']; $tpldirectory = $_GET['tpldirectory']; $diydata = C::t('common_diy_data')->fetch($targettplname, $tpldirectory); if(empty($diydata)) { cpmsg_error('diytemplate_targettplname_error', dreferer());} if(!submitcheck('permsubmit')) { shownav('portal', 'diytemplate', 'diytemplate_perm'); showsubmenu(cplang('diytemplate_perm_edit').' - '.($diydata['name'] ? cplang($diydata['name']) : $_G['cache']['diytemplatename'][$diydata['targettplname']])); showtips('diytemplate_perm_tips'); showformheader("diytemplate&operation=perm&targettplname=$targettplname&tpldirectory=$tpldirectory"); showtableheader('', 'fixpadding'); showsubtitle(array('', 'username', '', '', '', 'block_perm_inherited' )); $allpermission = C::t('common_template_permission')->fetch_all_by_targettplname($targettplname); $allusername = C::t('common_member')->fetch_all_username_by_uid(array_keys($allpermission)); $line = '−'; foreach($allpermission as $uid => $value) { if(!empty($value['inheritedtplname'])) { showtablerow('', array('class="td25"'), array( "", "$allusername[$uid]", $value['allowmanage'] ? '√' : $line, $value['allowrecommend'] ? '√' : $line, $value['needverify'] ? '√' : $line, ''.$_G['cache']['diytemplatename'][$value['inheritedtplname']].'', )); } else { showtablerow('', array('class="td25"'), array( " ", "$allusername[$uid]", "', "', "', $line, )); } } showtablerow('', array('class="td25"'), array( cplang('add_new'), '', '', '', '', '', )); showsubmit('permsubmit', 'submit', 'del'); showtablefooter(); showformfooter(); } else { $users = array(); if(!empty($_GET['newuser'])) { $uid = C::t('common_member')->fetch_uid_by_username($_GET['newuser']); if($uid) { $user = array(); $user['uid'] = $uid; $user['allowmanage'] = $_GET['newallowmanage'] ? 1 : 0; $user['allowrecommend'] = $_GET['newallowrecommend'] ? 1 : 0; $user['needverify'] = $_GET['newneedverify'] ? 1 : 0; $users[] = $user; } else { cpmsg_error($_GET['newuser'].cplang('block_has_no_allowauthorizedblock'), dreferer()); } } if(is_array($_GET['perm'])) { foreach($_GET['perm'] as $uid => $value) { if(empty($_GET['delete']) || !in_array($uid, $_GET['delete'])) { $user = array(); $user['allowmanage'] = $_GET['allowmanage'][$uid] ? 1 : 0; $user['allowrecommend'] = $_GET['allowrecommend'][$uid] ? 1 : 0; $user['needverify'] = $_GET['needverify'][$uid] ? 1 : 0; if($value['allowmanage'] != $user['allowmanage'] || $value['allowrecommend'] != $user['allowrecommend'] || $value['needverify'] != $user['needverify'] ) { $user['uid'] = intval($uid); $users[] = $user; } } } } if(!empty($users) || $_GET['delete']) { require_once libfile('class/blockpermission'); $tplpermsission = & template_permission::instance(); if($_GET['delete']) { $tplpermsission->delete_users($targettplname ,$_GET['delete']); } if(!empty($users)) { $tplpermsission->add_users($targettplname, $users); } } cpmsg('diytemplate_perm_update_succeed', "action=diytemplate&operation=perm&targettplname=$targettplname&tpldirectory=$tpldirectory", 'succeed'); } } ?>