Code Duplication    Length = 12-14 lines in 3 locations

core/IdP.php 1 location

@@ 87-99 (lines=13) @@
84
        $idPAttributes = DBConnection::exec($this->databaseType, "SELECT DISTINCT option_name,option_value, row FROM institution_option
85
              WHERE institution_id = $this->identifier  ORDER BY option_name");
86
87
        while ($attributeQuery = mysqli_fetch_object($idPAttributes)) {
88
            // decode base64 for files (respecting multi-lang)
89
            $optinfo = $optioninstance->optionType($attributeQuery->option_name);
90
            $flag = $optinfo['flag'];
91
92
            if ($optinfo['type'] != "file") {
93
                $this->attributes[] = ["name" => $attributeQuery->option_name, "value" => $attributeQuery->option_value, "level" => "IdP", "row" => $attributeQuery->row, "flag" => $flag];
94
            } else {
95
                $decodedAttribute = $this->decodeFileAttribute($attributeQuery->option_value);
96
97
                $this->attributes[] = ["name" => $attributeQuery->option_name, "value" => ($decodedAttribute['lang'] == "" ? $decodedAttribute['content'] : serialize($decodedAttribute)), "level" => "IdP", "row" => $attributeQuery->row, "flag" => $flag];
98
            }
99
        }
100
        $this->attributes[] = ["name" => "internal:country",
101
            "value" => $this->federation,
102
            "level" => "IdP",

core/User.php 1 location

@@ 71-82 (lines=12) @@
68
            }
69
        } else {
70
            $userOptions = DBConnection::exec($this->databaseType, "SELECT option_name, option_value, id AS row FROM $this->entityOptionTable WHERE $this->entityIdColumn = '$userId'");
71
            while ($userOptionQuery = mysqli_fetch_object($userOptions)) {
72
// decode base64 for files (respecting multi-lang)
73
                $optinfo = $optioninstance->optionType($userOptionQuery->option_name);
74
                $flag = $optinfo['flag'];
75
76
                if ($optinfo['type'] != "file") {
77
                    $this->attributes[] = ["name" => $userOptionQuery->option_name, "value" => $userOptionQuery->option_value, "level" => "User", "row" => $userOptionQuery->row, "flag" => $flag];
78
                } else {
79
                    $decodedAttribute = $this->decodeFileAttribute($userOptionQuery->option_value);
80
                    $this->attributes[] = ["name" => $userOptionQuery->option_name, "value" => ($decodedAttribute['lang'] == "" ? $decodedAttribute['content'] : serialize($decodedAttribute)), "level" => "User", "row" => $userOptionQuery->row, "flag" => $flag];
81
                }
82
            }
83
        }
84
    }
85

core/Federation.php 1 location

@@ 387-400 (lines=14) @@
384
385
        $optioninstance = Options::instance();
386
387
        while ($queryResult = mysqli_fetch_object($fedAttributes)) {
388
            // decode base64 for files (respecting multi-lang)
389
            $optinfo = $optioninstance->optionType($queryResult->option_name);
390
            $flag = $optinfo['flag'];
391
392
            if ($optinfo['type'] != "file") {
393
                $this->attributes[] = array("name" => $queryResult->option_name, "value" => $queryResult->option_value, "level" => "FED", "row" => $queryResult->row, "flag" => $flag);
394
            } else {
395
                
396
                $decodedAttribute = $this->decodeFileAttribute($queryResult->option_value);
397
398
                $this->attributes[] = array("name" => $queryResult->option_name, "value" => ($decodedAttribute['lang'] == "" ? $decodedAttribute['content'] : serialize($decodedAttribute)), "level" => "FED", "row" => $queryResult->row, "flag" => $flag);
399
            }
400
        }
401
        $this->attributes[] = array("name" => "internal:country",
402
            "value" => $this->name,
403
            "level" => "FED",