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. | 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 Chapter 6 5. We then iterate through the results making the time the status was posted more friendly and .