Code Duplication    Length = 37-38 lines in 2 locations

src/Intraface/modules/administration/UserAdministration.php 1 location

@@ 25-62 (lines=38) @@
22
    /**
23
     * @todo why use this instead of the one in user?
24
     */
25
    function update($input)
26
    {
27
        $this->validate($input);
28
        $validator = new Intraface_Validator($this->error);
29
30
        if (!empty($input["password"])) {
31
            if ($this->id == 0) {
32
                $validator->isPassword($input["password"], 6, 16, "Ugyldig adgangskode. Den skal være mellem 6 og 16 tegn, og må indeholde store og små bogstaver samt tal");
33
            } else {
34
                $validator->isPassword($input["password"], 6, 16, "Ugyldig adgangskode. Den skal være mellem 6 og 16 tegn, og må indeholde store og små bogstaver samt tal", "allow_empty");
35
            }
36
        }
37
38
        $sql = "email = \"".$input["email"]."\"";
39
40
        if (!empty($input["password"])) {
41
            if ($input["password"] === $input["confirm_password"]) {
42
                $sql .= ", password = \"".md5($input["password"])."\"";
43
            } else {
44
                $this->error->set("De to adgangskoder er ikke ens!");
45
            }
46
        }
47
48
        if ($this->error->isError()) {
49
            return false;
50
        }
51
52
        if ($this->id) {
53
            $this->db->exec("UPDATE user SET ".$sql." WHERE id = ".$this->id);
54
            $this->load();
55
            return $this->id;
56
        } else {
57
            $this->db->exec("INSERT INTO user SET ".$sql);
58
            $this->id = $this->db->lastInsertId();
59
            $this->load();
60
            return $this->id;
61
        }
62
    }
63
}
64

src/Intraface/modules/intranetmaintenance/UserMaintenance.php 1 location

@@ 56-92 (lines=37) @@
53
     *
54
     * @return boolean true or false
55
     */
56
    public function update($input)
57
    {
58
        $this->validate($input);
59
        $validator = new Intraface_Validator($this->error);
60
61
        if ($this->id == 0) {
62
            $validator->isPassword($input["password"], 6, 16, "Ugyldig adgangskode. Den skal være mellem 6 og 16 tegn, og må indeholde store og små bogstaver samt tal");
63
        } else {
64
            $validator->isPassword($input["password"], 6, 16, "Ugyldig adgangskode. Den skal være mellem 6 og 16 tegn, og må indeholde store og små bogstaver samt tal", "allow_empty");
65
        }
66
67
        $sql = "email = \"".$input["email"]."\",
68
            disabled = ".$input["disabled"]."";
69
70
        if (!empty($input["password"])) {
71
            if ($input["password"] === $input["confirm_password"]) {
72
                $sql .= ", password = \"".md5($input["password"])."\"";
73
            } else {
74
                $this->error->set("De to adgangskoder er ikke ens!");
75
            }
76
        }
77
78
        if ($this->error->isError()) {
79
            return false;
80
        }
81
82
        if ($this->id) {
83
            $this->db->exec("UPDATE user SET ".$sql." WHERE id = ".$this->id);
84
            $this->load();
85
            return $this->id;
86
        } else {
87
            $this->db->exec("INSERT INTO user SET ".$sql);
88
            $this->id = $this->db->lastInsertId();
89
            $this->load();
90
            return $this->id;
91
        }
92
    }
93
94
    /**
95
     * Fjerner alle access til denne bruger for det satte intranet