Code Duplication    Length = 10-11 lines in 4 locations

sources/roles.queries.php 1 location

@@ 195-204 (lines=10) @@
192
                }
193
            } elseif ($_POST['allowed'] == 0) {
194
                //case where folder was not allowed but allowed now
195
                foreach ($tree as $node) {
196
                    //Store in DB
197
                    DB::insert(
198
                        prefix_table("roles_values"),
199
                        array(
200
                            'folder_id' => $node->id,
201
                            'role_id' => $_POST['role']
202
                        )
203
                    );
204
                }
205
            }
206
            break;
207

sources/folders.queries.php 2 locations

@@ 1000-1010 (lines=11) @@
997
                    WHERE folder_id = %i",
998
                    $nodeInfo->id
999
                );
1000
                foreach ($rows as $record) {
1001
                    //add access to this subfolder
1002
                    DB::insert(
1003
                        prefix_table("roles_values"),
1004
                        array(
1005
                            'role_id' => $record['role_id'],
1006
                            'folder_id' => $newFolderId,
1007
                            'type' => $record['type']
1008
                        )
1009
                    );
1010
                }
1011
1012
                // if parent folder has Custom Fields Categories then add to this child one too
1013
                $rows = DB::query("SELECT id_category FROM ".prefix_table("categories_folders")." WHERE id_folder = %i", $nodeInfo->id);
@@ 527-537 (lines=11) @@
524
525
                    //If it is a subfolder, then give access to it for all roles that allows the parent folder
526
                    $rows = DB::query("SELECT role_id, type FROM ".prefix_table("roles_values")." WHERE folder_id = %i", $parentId);
527
                    foreach ($rows as $record) {
528
                        //add access to this subfolder
529
                        DB::insert(
530
                            prefix_table("roles_values"),
531
                            array(
532
                                'role_id' => $record['role_id'],
533
                                'folder_id' => $newId,
534
                                'type' => $record['type']
535
                            )
536
                        );
537
                    }
538
539
                    // if parent folder has Custom Fields Categories then add to this child one too
540
                    $rows = DB::query("SELECT id_category FROM ".prefix_table("categories_folders")." WHERE id_folder = %i", $parentId);

sources/import.queries.php 1 location

@@ 749-758 (lines=10) @@
746
                        );
747
748
                        //For each role to which the user depends on, add the folder just created.
749
                        foreach ($_SESSION['arr_roles'] as $role) {
750
                            DB::insert(
751
                                prefix_table("roles_values"),
752
                                array(
753
                                    'role_id' => $role['id'],
754
                                    'folder_id' => $id,
755
                                    'type' => "W"
756
                                )
757
                            );
758
                        }
759
760
                        //Add this new folder to the list of visible folders for the user.
761
                        array_push($_SESSION['groupes_visibles'], $id);