Code Duplication    Length = 22-25 lines in 3 locations

core/Federation.php 1 location

@@ 381-405 (lines=25) @@
378
379
        $optioninstance = Options::instance();
380
381
        while ($a = mysqli_fetch_object($fedAttributes)) {
382
            $lang = "";
383
            // decode base64 for files (respecting multi-lang)
384
            $optinfo = $optioninstance->optionType($a->option_name);
385
            $flag = $optinfo['flag'];
386
387
            if ($optinfo['type'] != "file") {
388
                $this->attributes[] = array("name" => $a->option_name, "value" => $a->option_value, "level" => "FED", "row" => $a->row, "flag" => $flag);
389
            } else {
390
                // suppress E_NOTICE on the following... we are testing *if*
391
                // we have a serialized value - so not having one is fine and
392
                // shouldn't throw E_NOTICE
393
                if (@unserialize($a->option_value) !== FALSE) { // multi-lang
394
                    $content = unserialize($a->option_value);
395
                    $lang = $content['lang'];
396
                    $content = $content['content'];
397
                } else { // single lang, direct content
398
                    $content = $a->option_value;
399
                }
400
401
                $content = base64_decode($content);
402
403
                $this->attributes[] = array("name" => $a->option_name, "value" => ($lang == "" ? $content : serialize(Array('lang' => $lang, 'content' => $content))), "level" => "FED", "row" => $a->row, "flag" => $flag);
404
            }
405
        }
406
        $this->attributes[] = array("name" => "internal:country",
407
            "value" => $this->name,
408
            "level" => "FED",

core/IdP.php 1 location

@@ 87-111 (lines=25) @@
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 ($a = mysqli_fetch_object($IdPAttributes)) {
88
            $lang = "";
89
            // decode base64 for files (respecting multi-lang)
90
            $optinfo = $optioninstance->optionType($a->option_name);
91
            $flag = $optinfo['flag'];
92
93
            if ($optinfo['type'] != "file") {
94
                $this->attributes[] = ["name" => $a->option_name, "value" => $a->option_value, "level" => "IdP", "row" => $a->row, "flag" => $flag];
95
            } else {
96
                // suppress E_NOTICE on the following... we are testing *if*
97
                // we have a serialized value - so not having one is fine and
98
                // shouldn't throw E_NOTICE
99
                if (@unserialize($a->option_value) !== FALSE) { // multi-lang
100
                    $content = unserialize($a->option_value);
101
                    $lang = $content['lang'];
102
                    $content = $content['content'];
103
                } else { // single lang, direct content
104
                    $content = $a->option_value;
105
                }
106
107
                $content = base64_decode($content);
108
109
                $this->attributes[] = ["name" => $a->option_name, "value" => ($lang == "" ? $content : serialize(['lang' => $lang, 'content' => $content])), "level" => "IdP", "row" => $a->row, "flag" => $flag];
110
            }
111
        }
112
        $this->attributes[] = ["name" => "internal:country", 
113
                                         "value" => $this->federation, 
114
                                         "level" => "IdP", 

core/User.php 1 location

@@ 76-97 (lines=22) @@
73
74
        } else {
75
            $user_options = DBConnection::exec($this->databaseType, "SELECT option_name, option_value, id AS row FROM user_options WHERE user_id = '$user_id'");
76
            while ($a = mysqli_fetch_object($user_options)) {
77
                $lang = "";
78
                // decode base64 for files (respecting multi-lang)
79
                $optinfo = $optioninstance->optionType($a->option_name);
80
                $flag = $optinfo['flag'];
81
82
                if ($optinfo['type'] != "file") {
83
                    $this->attributes[] = ["name" => $a->option_name, "value" => $a->option_value, "level" => "User", "row" => $a->row, "flag" => $flag];
84
                } else {
85
                    if (unserialize($a->option_value) != FALSE) { // multi-lang
86
                        $content = unserialize($a->option_value);
87
                        $lang = $content['lang'];
88
                        $content = $content['content'];
89
                    } else { // single lang, direct content
90
                        $content = $a->option_value;
91
                    }
92
93
                    $content = base64_decode($content);
94
95
                    $this->attributes[] = ["name" => $a->option_name, "value" => ($lang == "" ? $content : serialize(['lang' => $lang, 'content' => $content])), "level" => "User", "row" => $a->row, "flag" => $flag];
96
                }
97
            }
98
        }
99
    }
100