<?php
/**
 * 角色指派
 * 该系统下:
 * 角色可以包含一组任务(Task)和一组行为(Operation),不能包含角色.
 * @author ouyang
 * @email oyjqldp@126.com
 * @updated 2010-07-07
 */
class RoleAssignAction extends BaseAction
{
    public function run()
    {
        $name = Yii::app()->getRequest()->getQuery('name');

        #根据名称得到角色
        $role = $this->getController()->getRole($name);
        if(isset($role))
        {
            #得到该角色下的Task和Operation
            $childs = $this->getController()->getAssign($role);
            foreach ($childs as $key => $child)
            {
                $hasOperations[] = $key;
            }
            #得到所有的授权的Task和Operation
 
            $list = $this->getController()->buildList();

            $tasks = $this->getController()->getTasks();

            $this->getController()->render('roleassign', array(
                'title' => '角色授权',
                'modules' => $list,
                'tasks' => $tasks,
                'hasoperations' => $hasOperations,
                'rolename' => $name
            ));
        }
    }
    
}

