Code Duplication    Length = 17-22 lines in 2 locations

main/inc/lib/usermanager.lib.php 1 location

@@ 1031-1052 (lines=22) @@
1028
     * @return int User id
1029
     * @assert ('0','---') === 0
1030
     */
1031
    public static function get_user_id_from_original_id($original_user_id_value, $original_user_id_name)
1032
    {
1033
        $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
1034
        $t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
1035
        $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
1036
        $sql = "SELECT item_id as user_id
1037
                FROM $t_uf uf
1038
                INNER JOIN $t_ufv ufv
1039
                ON ufv.field_id=uf.id
1040
                WHERE
1041
                    variable='$original_user_id_name' AND
1042
                    value='$original_user_id_value' AND
1043
                    extra_field_type = $extraFieldType
1044
                ";
1045
        $res = Database::query($sql);
1046
        $row = Database::fetch_object($res);
1047
        if ($row) {
1048
            return $row->user_id;
1049
        } else {
1050
            return 0;
1051
        }
1052
    }
1053
1054
    /**
1055
     * Check if a username is available

main/inc/lib/events.lib.php 1 location

@@ 767-783 (lines=17) @@
764
     * @param string $event_type
765
     * @return array|bool
766
     */
767
    public static function get_events_by_user_and_type($user_id, $event_type)
768
    {
769
        $TABLETRACK_DEFAULT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
770
        $user_id = intval($user_id);
771
        $event_type = Database::escape_string($event_type);
772
773
        $sql = "SELECT * FROM $TABLETRACK_DEFAULT
774
                WHERE default_value_type = 'user_id' AND
775
                      default_value = $user_id AND
776
                      default_event_type = '$event_type'
777
                ORDER BY default_date ";
778
        $result = Database::query($sql);
779
        if ($result) {
780
            return Database::store_result($result, 'ASSOC');
781
        }
782
        return false;
783
    }
784
785
    /**
786
     * Save the new message for one event and for one language