Code Duplication    Length = 17-22 lines in 2 locations

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

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

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

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