| @@ 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 |
|
| @@ 1036-1057 (lines=22) @@ | ||
| 1033 | * @return int User id |
|
| 1034 | * @assert ('0','---') === 0 |
|
| 1035 | */ |
|
| 1036 | public static function get_user_id_from_original_id($original_user_id_value, $original_user_id_name) |
|
| 1037 | { |
|
| 1038 | $t_uf = Database::get_main_table(TABLE_EXTRA_FIELD); |
|
| 1039 | $t_ufv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES); |
|
| 1040 | $extraFieldType = EntityExtraField::USER_FIELD_TYPE; |
|
| 1041 | $sql = "SELECT item_id as user_id |
|
| 1042 | FROM $t_uf uf |
|
| 1043 | INNER JOIN $t_ufv ufv |
|
| 1044 | ON ufv.field_id=uf.id |
|
| 1045 | WHERE |
|
| 1046 | variable='$original_user_id_name' AND |
|
| 1047 | value='$original_user_id_value' AND |
|
| 1048 | extra_field_type = $extraFieldType |
|
| 1049 | "; |
|
| 1050 | $res = Database::query($sql); |
|
| 1051 | $row = Database::fetch_object($res); |
|
| 1052 | if ($row) { |
|
| 1053 | return $row->user_id; |
|
| 1054 | } else { |
|
| 1055 | return 0; |
|
| 1056 | } |
|
| 1057 | } |
|
| 1058 | ||
| 1059 | /** |
|
| 1060 | * Check if a username is available |
|
| @@ 5067-5085 (lines=19) @@ | ||
| 5064 | * @param string $keyword |
|
| 5065 | * @return array|null |
|
| 5066 | */ |
|
| 5067 | function searchUserByKeyword($keyword) |
|
| 5068 | { |
|
| 5069 | if (empty($keyword)) { |
|
| 5070 | return null; |
|
| 5071 | } |
|
| 5072 | ||
| 5073 | $tableUser = Database::get_main_table(TABLE_MAIN_USER); |
|
| 5074 | ||
| 5075 | $keyword = Database::escape_string($keyword); |
|
| 5076 | ||
| 5077 | $sql = "SELECT * |
|
| 5078 | FROM $tableUser |
|
| 5079 | WHERE |
|
| 5080 | ( |
|
| 5081 | username LIKE '%$keyword%' OR firstname LIKE '%$keyword%' OR lastname LIKE '%$keyword%' |
|
| 5082 | )"; |
|
| 5083 | $result = Database::query($sql); |
|
| 5084 | return Database::store_result($result, 'ASSOC'); |
|
| 5085 | } |
|
| 5086 | ||
| 5087 | /** |
|
| 5088 | * @param int $optionSelected |
|