Controller:Rolecontroller operation method:showlist
Product List interface, in left.html
<table id=child{$v. auth_id} style= "Display:none" cellspacing=0 cellpadding=0 width=150 border=0>
{foreach $auth _infob as $kk = + $VV}
{* The PID of the child permission must be equal to the ID of the external permission *}
{if $vv. Auth_pid = = $v. auth_id}
<tr height=20>
<td align=middle width=30>
</td>
<td><a class= "Menuchild" href= "{$smarty. const.__module__}/{$vv. auth_c}/{$vv. auth_a}" target= "right" >{$VV .auth_name}</a></td>
</tr>
{/if}
{/foreach}
<tr height=4><td colspan=2></td></tr>
</table>
{/foreach}
</td>
<td width=1 bgcolor= #d1e6f7 ></td>
</tr>
</table>
1, show the list of roles,
Controller: Rolecontroller
Operation Method:showlist
Class Rolecontroller extends admincontroller{
Role List Display
function Showlist () {
Get role data, show data
$info = D (' Role ')->select ();
$this-Assign (' info ', $info);
$this, display ();
}
In showlist.html under the role module of view
{foreach $info as $k = + $v}
<tr id= "Product1" >
<td>{*[email protected]*}{$v .role_id}</td>
<td>{$v .role_name}</td>
<td>{$v .role_auth_ids}</td>
<td>{$v .role_auth_ac}</td>
<td><a href= "{$smarty. const.__controller__}/distribute/role_id/{$v. role_id}" > Assigning Permissions </a> </td> //pass role_id information to the distribute method to tell which role is currently assigned permissions
<td><a href= "" > Modify </a></td>
<td><a href= "" onclick= "> Delete </a></td>
</tr>
{/foreach}
2, assigning permissions to roles
Controller:Rolecontroller
Operation Method:Distribute
//Assign Permissions
function Distribute ($role _id) {
$role = new \model\rolemodel ();
//Two logic: show, collect
if (!empty ($_post)) {
//$_post data requires two production to be written to the database
//Create a method Saveauth in the custom Rolemodel to achieve data creation and storage
$z = $role->saveauth ($role _id,$_post[' auth_id ');
if ($z) {
$this-redirect (' Showlist ', Array (), 2, ' Assign permissions succeeded ');
}else{
$this-redirect (' Distribute ', Array (' role_id ' = ' + ' $role _id), 2, ' Assign permissions failed ');
}
}else{
//Query role information for assigned permissions
$role _info = $role->find ($role _id);
Permissions information already owned by the role
$have _auth = Explode (', ', $role _info[' role_auth_ids ');//Become an array
//Get all the permissions for the assignment and show it to the template
//top-level permissions, secondary top-level permissions
$auth _infoa = D (' auth ')- >where (' auth_level=0 ')->select ();
$auth _infob = D (' auth ')->where (' auth_level=1 ')- >select ();
$this-Assign (' Have_auth ', $have _auth);
$this-Assign (' Auth_infoa ', $auth _infoa);
$this-Assign (' Auth_infob ', $auth _infob);
$this-Assign (' Role_info ', $role _info);
$this, display ();
}
}
}
"Shop"---role data maintenance