public static function FetchFromAssoc($assoc) { global $link_to_users_images; $ob = new self(); if (ArrayElemIsValidStr($assoc, 'id')) { $ob->SetID($assoc['id']); } if (ArrayElemIsValidStr($assoc, 'name')) { $ob->SetName($assoc['name']); } if (ArrayElemIsValidStr($assoc, 'surname')) { $ob->SetSurname($assoc['surname']); } if (ArrayElemIsValidStr($assoc, 'fathername')) { $ob->SetFathername($assoc['fathername']); } if (ArrayElemIsValidStr($assoc, 'login')) { $ob->SetLogin($assoc['login']); } if (ArrayElemIsValidStr($assoc, 'password')) { $ob->SetPassword($assoc['password']); } if (ArrayElemIsValidStr($assoc, 'position')) { $ob->SetPosition($assoc['position']); } if (isset($assoc['received_reports'])) { if (is_string($assoc['received_reports'])) { if ($assoc['received_reports'] === '') { $ob->received_reports = []; } else { $ob->SetReceivedReports(json_decode($assoc['received_reports'])); } } else { if ($assoc['received_reports'] != NULL) { $ob->SetReceivedReports($assoc['received_reports']); } else { $ob->received_reports = []; } } } else { $ob->received_reports = []; } if (isset($assoc['sended_reports'])) { if (is_string($assoc['sended_reports'])) { if ($assoc['sended_reports'] === '') { $ob->sended_reports = []; } else { $ob->SetSendedReports(json_decode($assoc['sended_reports'])); } } else { if ($assoc['sended_reports'] != NULL) { $ob->SetSendedReports($assoc['sended_reports']); } else { $ob->sended_reports = []; } } } else { $ob->sended_reports = []; } if (ArrayElemIsValidStr($assoc, 'email')) { $ob->SetEmail($assoc['email']); } if (ArrayElemIsValidStr($assoc, 'telephone')) { $ob->SetTelephone($assoc['telephone']); } try { if (ArrayElemIsValidStr($assoc, 'last_visit_time')) { $ob->SetLastVisitTime(strtotime($assoc['last_visit_time'])); } if (ArrayElemIsValidStr($assoc, 'register_time')) { $ob->SetRegisterTime(strtotime($assoc['register_time'])); } if (ArrayElemIsValidStr($assoc, 'birthday')) { $ob->SetBirthday(strtotime($assoc['birthday'])); } } catch (Exception $e) { $ob->last_visit_time = time_undef; $ob->register_time = time_undef; $ob->birthday = time_undef; } if (ArrayElemIsValidStr($assoc, 'id')) { $ob->SetPathToPhoto(PathToImage($link_to_users_images . $ob->id, 'avatar', $link_to_users_images . 'common/default_avatar.png')); } return $ob; }