天使漫步IT工作室天使漫步IT工作室

【ACI教程】用实例学习ACI(十一)


Warning: count(): Parameter must be an array or an object that implements Countable in /www/wwwroot/u11u.com/usr/themes/wq/functions.php on line 110

Warning: count(): Parameter must be an array or an object that implements Countable in /www/wwwroot/u11u.com/usr/themes/wq/functions.php on line 116

好了,代码贴完了,我们新增一个用户,来体验一下不同用户上传文件的管理功能。这时我们会发现,如果新增的用户不是超级管理员的话,这个编辑器是无法正常使用的。

在这一节中,下面教大家如何使普通的后台用户也可以使用该编辑器。

用超级管理员进入后台,点击栏目管理——添加菜单——先添加一级菜单:百度编辑器,注意是否显示菜单选择否。
然后在该菜单下添加以下菜单:默认页、获取文件列表、文件上传、文件列表、获取远程图片。

psb (22).png

添加完毕后,打开数据库,打开表:t_sys_module_menu 修改字段controller method的值,控制器是beditor 方法就是在ACI中注册的那几个方法。

psb (23).png

最终在后台栏目管理出现以下菜单:

psb (24).png

最后,在需要该权限的用户组里,把这几个栏目的权限添加上即可正常使用百度编辑器了。

接下来解决如下问题:

  • D、审核状态,根据用户的级别来自动填写。
  • F、标签和关键词可以复制联动。

其中标签和关键词联动可以用jquery来实现。审核状态就需要设置一下配置文件了。
打开aciapplicationconfigconfig.php,在尾部添加

/*
以下用户组不用审核 用户组id ,号分割
*/
$config['Audit'] = '1,2';

在aciapplicationcontrollersadminpanelNews.php中新增一个权限判断的方法:

private function _check_news_role()
{
    $Audit = config_item('Audit');
    $group_id = isset($this->group_id)?$this->group_id:0;
    $user_id = isset($this->user_id)?$this->user_id:0;
    if(strpos($Audit, (string)$group_id) !== false)
    {
        return true;
    }else
    {    
        return false;
    }
} 

将add方法和edit方法中的$_arr['audit'] = isset($_POST["audit"])?trim(safe_replace($_POST["audit"])):''; 注释掉。

改为:

 //对需要审核的新闻赋值
if($this->_check_news_role())
{
    $_arr['audit'] = 1;
    }else
    {
    $_arr['audit'] = 0;
}

然后删除aciapplicationviewsadminpanelnewsedit.php 中有关审核的html语句。

同样的,我们要考虑到新闻列表除了管理员外,一般只会只显示自己发布的新闻,所以我们还需要对aciapplicationcontrollersadminpanelNews.php的index、delete_one、read_one方法进行修改:
将index方法中的$where="" 替换成:

        //免审核的用户组可以列出全部的文章
        if($this->_check_news_role())
        {
            $where = "";
            $where_arr = NULL;
        }else
        {
            $where = "operator_id = ".$this->user_id;
            $where_arr[] = "operator_id = ".$this->user_id;
        }
 

将delete_one方法中的$data_info =$this->news_model->get_one(array('news_id'=>$id));

替换成:

        //对新闻权限审核
        if($this->_check_news_role())
        {
            $data_info =$this->news_model->get_one(array('news_id'=>$id));
        }else
        {
            $data_info =$this->news_model->get_one(array('news_id'=>$id,'operator_id'=>$this->user_id));
        }
 

将readonly方法中的$data_info =$this->news_model->get_one(array('news_id'=>$id));替换成:

        if($this->_check_news_role())
        {
            $data_info =$this->news_model->get_one(array('news_id'=>$id));
        }else
        {
            $data_info =$this->news_model->get_one(array('news_id'=>$id,'operator_id'=>$this->user_id));
        }

至于新增的_check_news_role() 方法,因为是私有方法,不用在ACI中注册即可使用。
至此,新闻页面显示的权限修改完毕。
以下是图片效果:

  • 用管理员身份查看新闻列表:

psb (25).png

  • 用发布人员edtor001登录显示的列表

psb (26).png

本站原创,欢迎转载,转载敬请标明出处:天使漫步IT工作室 » 【ACI教程】用实例学习ACI(十一)
添加新评论


Warning: Use of undefined constant php - assumed 'php' (this will throw an Error in a future version of PHP) in /www/wwwroot/u11u.com/usr/themes/wq/comments.php on line 38