TAILIEUCHUNG - Thiết kế mạng xã hội với PHP - 21

Khái niệm này là rất tương tự như phần trạng thái của hồ sơ của người dùng, chúng tôi tạo ra trong Chương 5, ngoại trừ các thay vào đó liên quan đến người sử dụng cụ thể, điều này cần kết hợp các hoạt động của tất cả người dùng kết nối trực tiếp đến đăng nhập vào người sử dụng | Status Stream The concept is very similar to the statuses section of a user s profile we created in Chapter 5 except that instead of relating to one specific user this should combine the activity of all users directly connected to the logged-in user. Although at this stage it is primarily simple statuses this will involve some logic to determine the context of the status. There will after all be five different types of status to list in the stream all of which will require different wording to present to the user The user s own status update The logged-in user posting a status update on the profile of another user A contact posting a status update on the profile of the logged-in user A contact updating their status A contact posting a status update on the profile of another contact Stream model We will require a stream model to build the status stream from the database. The functionalities required are Looking up an activity in the user s network Formatting the time of these updates to make them more relevant for example 5 minutes ago Retuning the stream Knowing if the stream is empty Code for the model is saved in the models file. Building the stream Let s walk through the logic of how building a stream of updates would work 1. We will need to get the IDs of users the current user is connected to. 2. As the IDs will be imploded and used as part of an IN condition the list of IDs cannot be empty. So in case it is we should add an ID of zero to the list. 3. We then need to query the database pulling in the 20 most recent statuses that have been posted by the user posted onto the user s profile or posted between two contacts of the user. 4. If there are rows we update our empty variable to false so the object knows if the stream is empty or not. ---------------------------------- 182 --------------------------------- Download from Wow eBook Chapter 6 5. We then iterate through the results making the time the status was posted more friendly

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.