0

Hi

I am struggling how to list all the permissions and with checkboxes.

if anyone can help me with it this is the code

            echo "<table cellpadding='0' cellspacing='0' width='100%' class='table table-bordered'>";
                echo "<tr>";
                    echo "<th>PERMISSION</th>";
                    foreach($user_groups->rows as $row) {
                        echo "<th class='checkbox'>".$row['title']."</th>";
                    }
                echo "</tr>";

                $users_permission_query = $this->db->query("SELECT * FROM users_permission");

                foreach($users_permission_query->rows as $row) {
                    $group_permissions_rows = json_decode($row['permission'], TRUE);
                    echo "<tr>";
                    echo "<td>".$row['module']."<br />";
                        foreach($group_permissions_rows as $key => $value) {
                            echo "{$key}<br>";
                        }
                    echo "</td>";
                    echo "<td>";
                        echo "<table cellpadding='0' cellspacing='0' width='100%'>";
                        for($i=0; $i < count($group_permissions_rows); $i++) {
                            foreach($group_permissions_rows as $key => $value) {
                                echo "<tr>";
                                echo "<td><input type='checkbox' name='permissions[" . $key . "]'";
                                if($value) {
                                    echo ($value==1 ? " checked =\"checked\"" : ""); 
                                }
                                echo " value=$value /></td>";
                                echo "</tr>";
                            }
                        }
                        echo "</table>";
                    echo "</td>";
                    echo "</tr>";
                }

            echo "</table>";
2
Contributors
3
Replies
24
Views
1 Week
Discussion Span
Last Post by Fernando_13
0

Ohh..so do I, also need it. I had similar situation last week and still don't understand. I'd like to share with this problem on for further voting. I would be grateful a lots if someone will get right answer.

Edited by Fernando_13

0

This is my data,

        $table_permissions = array(
            'users'=>array("create"=>1,"modify_own"=>1,"modify_any"=>1,"delete_own"=>1,"delete_any"=>1,"view"=>1),
            'users_group'=>array("create"=>1,"modify_own"=>1,"modify_any"=>1,"delete_own"=>1,"delete_any"=>1,"view"=>1),
            'news'=>array("create"=>1,"modify_own"=>1,"modify_any"=>1,"delete_own"=>1,"delete_any"=>1,"view"=>1)
        );
        $json_encode = json_encode($table_permissions);
        $json_decode = json_decode('{"users":{"create":1,"modify_own":1,"modify_any":1,"delete_own":1,"delete_any":1,"view":1},"users_group":{"create":1,"modify_own":1,"modify_any":1,"delete_own":1,"delete_any":1,"view":1},"news":{"create":1,"modify_own":1,"modify_any":1,"delete_own":1,"delete_any":1,"view":1}}', true);

how can i make of a form and save to the database

0

Ohh..so do I, also need it. I had similar situation last week and still don't understand. I'd like to share with this problem on for further voting. I would be grateful a lots if someone will get right answer.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.