Tạo mạng xã hội với PHP - part 23

Public and Private Messages If the user isn't connected to the user, or isn't logged in, then we simply remove the template tag from the view so they don't see any update or post box on the page: $this-registry-getObject('template')-getPage()addTag( 'status_update', '' ); } } } else { $this-registry-getObject('template')-getPage()addTag( 'status_update', '' ); } Now, we need to process status updates and profile posts, and create the templates that make up the final aspect of our view. Process a new message The same logic that we used to determine whether the user should see a post form is what we need to use to determine if we. | Public and Private Messages If the user isn t connected to the user or isn t logged in then we simply remove the template tag from the view so they don t see any update or post box on the page this- registry- getObject template - getPage - addTag status_update else this- registry- getObject template - getPage - addTag status_update Now we need to process status updates and profile posts and create the templates that make up the final aspect of our view. Process a new message The same logic that we used to determine whether the user should see a post form is what we need to use to determine if we should process a status update or public message submission. Status model To save the status update or public profile post in the database we will need a status model as with our previous models this simply needs to represent the fields from the database with setter methods for these fields and a save method to insert a new record into the database. In the future we may wish to extend this to pull in statuses from the database and save changes to them as well as deleting statuses perhaps if the owner of the message or the owner of the profile the message was posted on wishes to edit or delete it. The following is suitable code for our status model models php Status model class Status The registry object private registry 202 Download from Chapter 7 Statuses ID private id Poster of the status update profile message private poster The profile the status update profile message was posted on private profile Type of status private type The update profile message itself private update Reference for the type of status private typeReference update Constructor @param Registry registry the registry object @param int id ID of the status update profile message return void public function construct Registry registry id 0 this- registry registry this- id 0 Set the poster of the status profile message ------------------------------ 203 .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
187    27    1    02-12-2024
Đã 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.