Code Duplication    Length = 17-22 lines in 2 locations

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

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

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