상속: extends clinic
 function remake_inherited_perm($bid)
 {
     $bid = intval($bid);
     if ($bid) {
         if ($targettplname = C::t('common_template_block')->fetch_targettplname_by_bid($bid)) {
             $tplpermsission =& template_permission::instance();
             $userperm = $tplpermsission->get_users_perm_by_template($targettplname);
             $this->add_users_blocks($userperm, $bid, $targettplname);
         }
     }
 }
예제 #2
0
function deleteportalcategory($ids)
{
    global $_G;
    if (empty($ids)) {
        return false;
    }
    if (!is_array($ids) && $_G['cache']['portalcategory'][$ids]['upid'] == 0) {
        @(require_once libfile('function/delete'));
        deletedomain(intval($ids), 'channel');
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    require_once libfile('class/blockpermission');
    require_once libfile('class/portalcategory');
    $tplpermission =& template_permission::instance();
    $templates = array();
    foreach ($ids as $id) {
        $templates[] = 'portal/list_' . $id;
        $templates[] = 'portal/view_' . $id;
    }
    $tplpermission->delete_allperm_by_tplname($templates);
    $categorypermission =& portal_category::instance();
    $categorypermission->delete_allperm_by_catid($ids);
    C::t('portal_category')->delete($ids);
    C::t('common_nav')->delete_by_type_identifier(4, $ids);
    $tpls = $defaultindex = array();
    foreach ($ids as $id) {
        $defaultindex[] = $_G['cache']['portalcategory'][$id]['caturl'];
        $tpls[] = 'portal/list_' . $id;
        $tpls[] = 'portal/view_' . $id;
    }
    if (in_array($_G['setting']['defaultindex'], $defaultindex)) {
        C::t('common_setting')->update('defaultindex', '');
    }
    C::t('common_diy_data')->delete($tpls, NULL);
    C::t('common_template_block')->delete_by_targettplname($tpls);
}
예제 #3
0
function deleteportaltopic($dels)
{
    if (empty($dels)) {
        return false;
    }
    $targettplname = array();
    foreach ((array) $dels as $key => $value) {
        $targettplname[] = 'portal/portal_topic_content_' . $value;
    }
    C::t('common_diy_data')->delete($targettplname, null);
    require_once libfile('class/blockpermission');
    $tplpermission =& template_permission::instance();
    $templates = array();
    $tplpermission->delete_allperm_by_tplname($targettplname);
    deletedomain($dels, 'topic');
    C::t('common_template_block')->delete_by_targettplname($targettplname);
    require_once libfile('function/home');
    $picids = array();
    foreach (C::t('portal_topic')->fetch_all($dels) as $value) {
        if ($value['picflag'] != '0') {
            pic_delete(str_replace('portal/', '', $value['cover']), 'portal', 0, $value['picflag'] == '2' ? '1' : '0');
        }
    }
    $picids = array();
    foreach (C::t('portal_topic_pic')->fetch_all($dels) as $value) {
        $picids[] = $value['picid'];
        pic_delete($value['filepath'], 'portal', $value['thumb'], $value['remote']);
    }
    if (!empty($picids)) {
        C::t('portal_topic_pic')->delete($picids, true);
    }
    C::t('portal_topic')->delete($dels);
    C::t('portal_comment')->delete_by_id_idtype($dels, 'topicid');
    C::t('common_moderate')->delete($dels, 'topicid_cid');
    include_once libfile('function/block');
    block_clear();
    include_once libfile('function/cache');
    updatecache('diytemplatename');
}
예제 #4
0
function update_template_block($targettplname, $tpldirectory, $blocks)
{
    if (!empty($targettplname)) {
        if (empty($blocks)) {
            C::t('common_template_block')->delete_by_targettplname($targettplname, $tpldirectory);
        } else {
            $oldbids = array();
            $oldbids = array_keys(C::t('common_template_block')->fetch_all_by_targettplname($targettplname, $tpldirectory));
            $newaddbids = array_diff($blocks, $oldbids);
            C::t('common_template_block')->delete_by_targettplname($targettplname, $tpldirectory);
            if ($tpldirectory === './template/default') {
                C::t('common_template_block')->delete_by_targettplname($targettplname, '');
            }
            $blocks = array_unique($blocks);
            C::t('common_template_block')->insert_batch($targettplname, $tpldirectory, $blocks);
            if (!empty($newaddbids)) {
                require_once libfile('class/blockpermission');
                $tplpermission =& template_permission::instance();
                $tplpermission->add_blocks($targettplname, $newaddbids);
            }
        }
    }
}
            } else {
                cpmsg_error($_G['gp_newuser'] . cplang('block_has_no_allowauthorizedblock'), dreferer());
            }
        }
        if (is_array($_G['gp_perm'])) {
            foreach ($_G['gp_perm'] as $uid => $value) {
                if (empty($_G['gp_delete']) || !in_array($uid, $_G['gp_delete'])) {
                    $user = array();
                    $user['allowmanage'] = $_G['gp_allowmanage'][$uid] ? 1 : 0;
                    $user['allowrecommend'] = $_G['gp_allowrecommend'][$uid] ? 1 : 0;
                    $user['needverify'] = $_G['gp_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) || $_G['gp_delete']) {
            require_once libfile('class/blockpermission');
            $tplpermsission =& template_permission::instance();
            if ($_G['gp_delete']) {
                $tplpermsission->delete_users($targettplname, $_G['gp_delete']);
            }
            if (!empty($users)) {
                $tplpermsission->add_users($targettplname, $users);
            }
        }
        cpmsg('diytemplate_perm_update_succeed', "action=diytemplate&operation=perm&targettplname={$targettplname}", 'succeed');
    }
}
예제 #6
0
function deleteportaltopic($dels)
{
    if (empty($dels)) {
        return false;
    }
    $targettplname = array();
    foreach ((array) $dels as $key => $value) {
        $targettplname[] = 'portal/portal_topic_content_' . $value;
    }
    DB::delete('common_diy_data', "targettplname IN (" . dimplode($targettplname) . ")", 0, true);
    require_once libfile('class/blockpermission');
    $tplpermission =& template_permission::instance();
    $templates = array();
    $tplpermission->delete_allperm_by_tplname($targettplname);
    deletedomain($dels, 'topic');
    DB::delete('common_template_block', 'targettplname IN (' . dimplode($targettplname) . ')', 0, true);
    require_once libfile('function/home');
    $picids = array();
    $query = DB::query('SELECT * FROM ' . DB::table('portal_topic') . ' WHERE topicid IN (' . dimplode($dels) . ')');
    while ($value = DB::fetch($query)) {
        if ($value['picflag'] != '0') {
            pic_delete(str_replace('portal/', '', $value['cover']), 'portal', 0, $value['picflag'] == '2' ? '1' : '0');
        }
    }
    $picids = array();
    $query = DB::query('SELECT * FROM ' . DB::table('portal_topic_pic') . ' WHERE topicid IN (' . dimplode($dels) . ')');
    while ($value = DB::fetch($query)) {
        $picids[] = $value['picid'];
        pic_delete($value['filepath'], 'portal', $value['thumb'], $value['remote']);
    }
    if (!empty($picids)) {
        DB::delete('portal_topic_pic', 'picid IN (' . dimplode($picids) . ')', 0, true);
    }
    foreach ($targettplname as $key => $value) {
        @unlink(DISCUZ_ROOT . './data/diy/' . $value . '.htm');
        @unlink(DISCUZ_ROOT . './data/diy/' . $value . '.htm.bak');
        @unlink(DISCUZ_ROOT . './data/diy/' . $value . '_preview.htm');
    }
    DB::delete('portal_topic', 'topicid IN (' . dimplode($dels) . ')');
    DB::delete('portal_comment', "id IN(" . dimplode($dels) . ") AND idtype='topicid'");
    DB::delete('common_moderate', "id IN (" . dimplode($dels) . ") AND idtype='topicid_cid'");
    include_once libfile('function/block');
    block_clear();
    include_once libfile('function/cache');
    updatecache('diytemplatename');
}
 function remake_inherited_perm($bid)
 {
     $bid = intval($bid);
     if ($bid) {
         $targettplname = DB::result_first('SELECT targettplname FROM ' . DB::table('common_template_block') . " WHERE bid='{$bid}'");
         if ($targettplname) {
             $tplpermsission =& template_permission::instance();
             $userperm = $tplpermsission->get_users_perm_by_template($targettplname);
             $this->add_users_blocks($userperm, $bid, $targettplname);
         }
     }
 }
예제 #8
0
		show_msg("Nâng cấp dữ liệu quyền hạn", "$theurl?step=data&op=$nextop");

	} elseif($_GET['op'] == 'block_permission') {
		$nextop = 'portalcategory_permission';
		if(!C::t('common_setting')->skey_exists('group_recommend')) {
			DB::query("UPDATE ".DB::table('common_block_permission')." SET allowmanage=allowsetting,allowrecommend=allowdata");
		}
		if(!DB::result_first('SELECT inheritedtplname FROM '.DB::table('common_template_permission')." WHERE inheritedtplname != '' LIMIT 1")) {
			$query = DB::query('SELECT * FROM '.DB::table('common_template_permission')." WHERE inheritedtplname = ''");
			$templatearr = array();
			while($value = DB::fetch($query)) {
				$templatearr[$value['targettplname']][] = $value;
			}
			if(!empty($templatearr)) {
				require_once libfile('class/blockpermission');
				$tplpermissions = new template_permission();
				foreach($templatearr as $tplname => $users) {
					$tplpermissions->add_users($tplname, $users);
				}
			}
		}
		show_msg("Nâng cấp dữ liệu quyền hạn portal", "$theurl?step=data&op=$nextop");
	} elseif($_GET['op'] == 'portalcategory_permission') {
		$nextop = 'portal_comment';
		if(!DB::result_first('SELECT inheritedcatid FROM '.DB::table('portal_category_permission')." WHERE inheritedcatid > '0' LIMIT 1")) {
			$query = DB::query('SELECT * FROM '.DB::table('portal_category_permission')." WHERE inheritedcatid = '0'");
			$catearr = array();
			while($value = DB::fetch($query)) {
				$catearr[$value['catid']][] = $value;
			}
			if(!empty($catearr)) {
function deleteportalcategory($ids)
{
    global $_G;
    if (empty($ids)) {
        return false;
    }
    if (!is_array($ids) && $_G['cache']['portalcategory'][$ids]['upid'] == 0) {
        @(require_once libfile('function/delete'));
        deletedomain(intval($ids), 'channel');
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    require_once libfile('class/blockpermission');
    require_once libfile('class/portalcategory');
    $tplpermission =& template_permission::instance();
    $templates = array();
    foreach ($ids as $id) {
        $templates[] = 'portal/list_' . $id;
    }
    $tplpermission->delete_allperm_by_tplname($templates);
    $categorypermission =& portal_category::instance();
    $categorypermission->delete_allperm_by_catid($ids);
    DB::delete('portal_category', "catid IN (" . dimplode($ids) . ")");
    DB::delete('common_nav', "`type`='4' AND identifier IN (" . dimplode($ids) . ")");
    $tpls = $defaultindex = array();
    foreach ($ids as $id) {
        $defaultindex[] = $_G['cache']['portalcategory'][$id]['caturl'];
        $tpls[] = 'portal/list_' . $id;
        @unlink(DISCUZ_ROOT . './data/diy/portal/list_' . $id . '.htm');
        @unlink(DISCUZ_ROOT . './data/diy/portal/list_' . $id . '.htm.bak');
        @unlink(DISCUZ_ROOT . './data/diy/portal/list_' . $id . '_diy_preview.htm');
    }
    if (in_array($_G['setting']['defaultindex'], $defaultindex)) {
        DB::insert('common_setting', array('skey' => 'defaultindex', 'svalue' => ''), 0, 1);
    }
    $wheresql = "targettplname IN (" . dimplode($tpls) . ")";
    DB::delete('common_diy_data', $wheresql);
    DB::delete('common_template_block', $wheresql);
}
예제 #10
0
function update_template_block($targettplname, $blocks)
{
    if (!empty($blocks) && !empty($targettplname)) {
        $oldbids = array();
        $query = DB::query('SELECT bid FROM ' . DB::table('common_template_block') . " WHERE targettplname='{$targettplname}'");
        while ($value = DB::fetch($query)) {
            $oldbids[] = $value['bid'];
        }
        $newaddbids = array_diff($blocks, $oldbids);
        DB::delete('common_template_block', array('targettplname' => $targettplname));
        $blocks = array_unique($blocks);
        $values = array();
        foreach ($blocks as $bid) {
            $values[] = "('{$targettplname}','{$bid}')";
        }
        if (!empty($values)) {
            DB::query("INSERT INTO " . DB::table('common_template_block') . " (targettplname,bid) VALUES " . implode(',', $values));
        }
        if (!empty($newaddbids)) {
            require_once libfile('class/blockpermission');
            $tplpermission =& template_permission::instance();
            $tplpermission->add_blocks($targettplname, $newaddbids);
        }
    }
}