- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
public function get($userId = null, $advense = false) {
if ($userId === null) $userId = $this->currentId;
$user = DB::table('users')
->select(
'*',
DB::raw('IF(email IS NOT NULL AND email_confirm IS NULL, 1, 0) AS email_confirm'),
DB::raw('IF(phone IS NOT NULL AND phone_confirm IS NULL, 1, 0) AS phone_confirm'),
DB::raw('IF(birthday IS NOT NULL, TIMESTAMPDIFF(YEAR,birthday,CURDATE()), NULL) AS age'),
DB::raw('IF(phone IS NOT NULL AND phone_confirm IS NULL AND email IS NOT NULL AND email_confirm IS NULL AND (new_first_name IS NOT NULL OR new_last_name IS NOT NULL OR new_status_text IS NOT NULL OR new_image_url IS NOT NULL), 1, 0) AS on_moderate'))
->where('id', $userId)->first();
if ($user === null) throw new Exception ('User is not found', 404);
unset($user->password);
$user->locality = Geo::get($user->locality_id);
$rating = $this->rating($userId);
$user->rating = (float)$rating->avg;
$user->rating_counter = (int)$rating->cnt;
$user->counters = $this->getCounters($userId);
$contact = $this->contacts->isMyContact($userId);
if ($userId != $this->currentId) {
$user->created = null;
$user->updated = null;
$user->birthday = null;
$user->email_confirm = null;
$user->phone_confirm = null;
$user->subscribed = null;
$user->organizations = null;
$contact = $this->contacts->isMyContact($userId);
// Если пользователь не контакт авторизованного, сотрем контактную информацию
if ( $contact === null || $contact === 'declined') {
$user->phone = null;
$user->email = null;
$user->last_name = mb_substr($user->last_name, 0, 1, 'UTF-8');
}
} else {
if($user->new_first_name !== null) {
$user->first_name = $user->new_first_name;
}
if($user->new_last_name !== null) {
$user->last_name = $user->new_last_name;
}
if($user->new_image_url !== null) {
$user->image_url = $user->new_image_url;
}
if($user->new_status_text !== null) {
$user->status_text = $user->new_status_text;
}
$user->organizations = Organizations\Organizations::getByUserId($userId);
$user->is_followed = null;
$user->is_my_contact = null;
$user->has_my_contact = null;
$user->has_my_opinion = null;
}
unset($user->new_status_text);
unset($user->new_image_url);
unset($user->new_last_name);
unset($user->new_first_name);
unset($user->reset_code);
$user->is_followed = $this->followers->isFollowed($userId);
$user->is_my_contact = $this->contacts->isMyContact($userId);
$user->has_my_contact = $this->contacts->hasMyContact($userId);
return $user;
}
guesto 20.04.2016 17:04 # 0
Vasiliy 20.04.2016 17:20 # 0
guesto 20.04.2016 17:22 # +2
$user = DB::table
ну тогда просто пользователь дурак
gost 21.04.2016 08:51 # −1
Ничего необычного, просто "PHP".
Vasiliy 21.04.2016 10:49 # 0
alexmarch232 08.05.2016 13:40 # 0
zenn1989 21.04.2016 09:50 # +1
guest 22.04.2016 17:33 # −2
M-A-X 26.04.2016 09:39 # 0
Ничего странного. :)
guest 26.04.2016 19:28 # 0
Ничего странного. :)