Code Duplication    Length = 17-22 lines in 2 locations

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

@@ 787-803 (lines=17) @@
784
     * @param string $event_type
785
     * @return array|bool
786
     */
787
    public static function get_events_by_user_and_type($user_id, $event_type)
788
    {
789
        $TABLETRACK_DEFAULT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
790
        $user_id = intval($user_id);
791
        $event_type = Database::escape_string($event_type);
792
793
        $sql = "SELECT * FROM $TABLETRACK_DEFAULT
794
                WHERE default_value_type = 'user_id' AND
795
                      default_value = $user_id AND
796
                      default_event_type = '$event_type'
797
                ORDER BY default_date ";
798
        $result = Database::query($sql);
799
        if ($result) {
800
            return Database::store_result($result, 'ASSOC');
801
        }
802
        return false;
803
    }
804
805
    /**
806
     * Save the new message for one event and for one language

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

@@ 1123-1144 (lines=22) @@
1120
     * @return int User id
1121
     * @assert ('0','---') === 0
1122
     */
1123
    public static function get_user_id_from_original_id($original_user_id_value, $original_user_id_name)
1124
    {
1125
        $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD);
1126
        $t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
1127
        $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
1128
        $sql = "SELECT item_id as user_id
1129
                FROM $t_uf uf
1130
                INNER JOIN $t_ufv ufv
1131
                ON ufv.field_id=uf.id
1132
                WHERE
1133
                    variable='$original_user_id_name' AND
1134
                    value='$original_user_id_value' AND
1135
                    extra_field_type = $extraFieldType
1136
                ";
1137
        $res = Database::query($sql);
1138
        $row = Database::fetch_object($res);
1139
        if ($row) {
1140
            return $row->user_id;
1141
        } else {
1142
            return 0;
1143
        }
1144
    }
1145
1146
    /**
1147
     * Check if a username is available