fetch($bid); shownav('portal', 'block', 'block_perm'); showsubmenu(cplang('block_perm_edit').' - '.($block['name'] ? $block['name'] : cplang('block_name_null'))); showtips('block_perm_tips'); showformheader("block&operation=perm&bid=$bid"); $inheritance_checked = !$block['notinherited'] ? 'checked' : ''; showtableheader('', 'fixpadding'); showsubtitle(array('', 'username', '', '', '', 'block_perm_inherited' )); $block_per = C::t('common_block_permission')->fetch_all_by_bid($bid); $members = C::t('common_member')->fetch_all(array_keys($block_per)); $line = '−'; foreach($block_per as $uid => $value) { if(!empty($value['inheritedtplname'])) { showtablerow('', array('class="td25"'), array( "", "{$members[$uid]['username']}", $value['allowmanage'] ? '√' : $line, $value['allowrecommend'] ? '√' : $line, $value['needverify'] ? '√' : $line, ''.$_G['cache']['diytemplatename'][$value['inheritedtplname']].'', )); } else { showtablerow('', array('class="td25"'), array( " ", "{$members[$uid]['username']}", "', "', "', $line, )); } } showtablerow('', array('class="td25"'), array( cplang('add_new'), '', '', '', '', '', )); showsubmit('permsubmit', 'submit', 'del'); showtablefooter(); showformfooter(); } else { if(!($block = C::t('common_block')->fetch($bid))) { cpmsg('block_not_exists'); } $users = array(); if(is_array($_GET['perm'])) { foreach($_GET['perm'] as $uid => $value) { $user = array(); 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($_GET['newuser'])) { $uid = C::t('common_member')->fetch_uid_by_username($_GET['newuser']); if($uid) { $user['uid'] = $uid; $user['allowmanage'] = $_GET['newallowmanage'] ? 1 : 0; $user['allowrecommend'] = $_GET['newallowrecommend'] ? 1 : 0; $user['needverify'] = $_GET['newneedverify'] ? 1 : 0; $users[$user['uid']] = $user; } else { cpmsg_error($_GET['newuser'].cplang('block_has_no_allowauthorizedblock')); } } require_once libfile('class/blockpermission'); $blockpermsission = & block_permission::instance(); if(!empty($users)) { $blockpermsission->add_users_perm($bid, $users); } if(!empty($_GET['delete'])) { $blockpermsission->delete_users_perm($bid, $_GET['delete']); } $notinherited = !$_POST['inheritance'] ? '1' : '0'; if($notinherited != $block['notinherited']) { if($notinherited) { $blockpermsission->delete_inherited_perm_by_bid($bid); } else { $blockpermsission->remake_inherited_perm($bid); } C::t('common_block')->update($bid, array('notinherited' => $notinherited)); } cpmsg('block_perm_update_succeed', "action=block&operation=perm&bid=$bid", 'succeed'); } } else { if(submitcheck('deletesubmit')) { if($_POST['ids']) { C::t('common_block_item')->delete_by_bid($_POST['ids']); C::t('common_block')->delete($_POST['ids']); C::t('common_block_permission')->delete_by_bid_uid_inheritedtplname($_POST['ids']); cpmsg('block_delete_succeed', 'action=block&operation=jscall', 'succeed'); } else { cpmsg('block_choose_at_least_one_block', 'action=block&operation=jscall', 'error'); } } elseif(submitcheck('clearsubmit')) { include_once libfile('function/block'); block_clear(); cpmsg('block_clear_unused_succeed', 'action=block', 'succeed'); } else { loadcache(array('diytemplatename')); $searchctrl = '' .''.cplang('hide_search').'' .''; showsubmenu('block', array( array('block_list', 'block', $operation=='list'), array('block_jscall', 'block&operation=jscall', $operation=='jscall') ), $searchctrl); $mpurl = ADMINSCRIPT.'?action=block&operation='.$operation; $intkeys = array('bid'); $strkeys = array('blockclass'); $strkeys[] = 'targettplname'; $randkeys = array(); $likekeys = array('name'); $results = getwheres($intkeys, $strkeys, $randkeys, $likekeys); foreach($likekeys as $k) { $_GET[$k] = dhtmlspecialchars($_GET[$k]); } $wherearr = $results['wherearr']; $mpurl .= '&'.implode('&', $results['urls']); $wherearr[] = $operation=='jscall' ? "blocktype='1'" : "blocktype='0'"; if($_GET['permname']) { $bids = ''; $uid = ($uid = C::t('common_member')->fetch_uid_by_username($_GET['permname'])) ? $uid : C::t('common_member_archive')->fetch_uid_by_username($_GET['permname']); if($uid) { $bids = array_keys(C::t('common_block_permission')->fetch_all_by_uid($uid)); } if(($bids = dimplode($bids))) { $wherearr[] = 'bid IN ('.$bids.')'; } else { cpmsg_error($_GET['permname'].cplang('block_the_username_has_not_block')); } $mpurl .= '&permname='.$_GET['permname']; } $wheresql = empty($wherearr)?'1':implode(' AND ', $wherearr); $wheresql = str_replace(array('bid', 'blockclass', ' name', 'blocktype', 'targettplname'), array('b.bid', 'b.blockclass', ' b.name', 'b.blocktype', 'tb.targettplname'), $wheresql); $orders = getorders(array('bid', 'dateline'), 'bid'); $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'); $mpurl .= '&perpage='.$perpage; $searchlang = array(); $keys = array('search', 'likesupport', 'lengthabove1', 'resultsort', 'defaultsort', 'orderdesc', 'orderasc', 'perpage_10', 'perpage_20', 'perpage_50', 'perpage_100', 'block_dateline', 'block_id', 'block_name', 'block_blockclass', 'block_add_jscall', 'block_choose_blockclass_to_add_jscall', 'block_diytemplate', 'block_permname', 'block_permname_tips'); foreach ($keys as $key) { $searchlang[$key] = cplang($key); } $diytemplatename_sel = ''; $blockclass_sel = ''; $addjscall = $operation == 'jscall' ? '' : ''; $firstrow = " ' .'