功能很简单,不过是很多人想要的.见图:
现在开始第一步:
进入MYSQL,在表 v9_category_priv 里面加一个新字段:is_model tinyint(1) 型,默认为0;
第二步:在语言包里加几个字段:
phpcms/languages/zh-cn/admin.lang.php 里加:
$LANG['member_group_private'] = '会员模型权限';
$LANG['member_group_name'] = '会员模型名称';
然后在admin的模型文件里:
phpcms/modules/admin/templates/category_edit.tpl.php 和
phpcms/modules/admin/templates/category_add.tpl.php
这里以 category_edit.tpl.php 为例,在line:263下插入代码:
- <tr><td colspan=2><hr style="border:1px dotted #F2F2F2;"></td>
- </tr>
- <tr>
- <th width="200"><?php echo L('member_group_private')?>:</th>
- <td>
- <table width="100%" class="table-list">
- <thead>
- <tr>
- <th align="left"><?php echo L('member_group_name');?></th><th><?php echo L('allow_vistor');?></th><th><?php echo L('allow_contribute');?></th>
- </tr>
- </thead>
- <tbody>
- <?php
- $group_cache = getcache('member_model','commons');
- foreach($group_cache as $_key=>$_value) {
- if($_value['groupid']==1) continue;
- ?>
- <tr>
- <td><?php echo $_value['name'];?></td>
- <td align="center"><input type="checkbox" name="priv_membermodel[]" <?php echo $this->check_category_priv('visit',$_value['modelid'],0);?> value="visit,<?php echo $_value['modelid'];?>" ></td>
- <td align="center"><input type="checkbox" name="priv_membermodel[]" <?php echo $this->check_category_priv('add',$_value['modelid'],0);?> value="add,<?php echo $_value['modelid'];?>" ></td>
- </tr> //Vevb.com
- <?php }?>
- </tbody>
- </table>
- </td>
- </tr>
第三步,现在修改持行文件:
phpcms/modules/admin/category.php
在里面的每一行 $this->update_priv($catid, $_POST['priv_groupid'],0);下面都插一行:
$this->update_priv($catid, $_POST['priv_membermodel'],0,1,1);
再修改一下该页面的一个function,代码如下:
- private function update_priv($catid,$priv_datas,$is_admin = 1,$is_model = 0,$isdel = 0) {
- $this->priv_db = pc_base::load_model('category_priv_model');
- if($isdel==0){$this->priv_db->delete(array('catid'=>$catid,'is_admin'=>$is_admin));}
- if(is_array($priv_datas) && !emptyempty($priv_datas)) {
- foreach ($priv_datas as $r) {
- $r = explode(',', $r);
- $action = $r[0];
- $roleid = $r[1];
- $this->priv_db->insert(array('catid'=>$catid,'roleid'=>$roleid,'is_admin'=>$is_admin,'is_model'=>$is_model,'action'=>$action,'siteid'=>$this->siteid));
- }
- }
- }
到这里,后台的这个小功能算是完成了,下面修改前台页面.
第四步:这里我们只举例“在线投稿”,打开持行文件:
phpcms/modules/member/content.php
将其中代码替换:
- if($cat['siteid']==$siteid && $cat['child']==0 && $cat['type']==0 && $priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['groupid'], 'is_admin'=>0, 'action'=>'add'))) break;
- //替换为:
- if($cat['siteid']==$siteid && $cat['child']==0 && $cat['type']==0 && $priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['groupid'], 'is_admin'=>0, 'action'=>'add')) && $priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['modelid'], 'is_model'=>1, 'action'=>'add'))) break;
- if (!$priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['groupid'], 'is_admin'=>0, 'action'=>'add'))) showmessage(L('category').L('publish_deny'), APP_PATH.'index.php?m=member');
下面也添加一行:
- if (!$priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['modelid'], 'is_model'=>1, 'action'=>'add'))) showmessage(L('category').L('publish_deny'), APP_PATH.'index.php?m=member');
这样就完成了.
新闻热点
疑难解答