Tham khảo tài liệu ''thiết kế mạng xã hội với php - 33'', công nghệ thông tin, đồ họa - thiết kế - flash phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả
Groups Group information There will need to be standard information saved for each group, so that groups have meaning to other users, and if appropriate can be found through the search feature At a minimum, we need to store the following information: • • • • • Name of the group Creator / owner of the group: So we know who has permission to manage it Description of the group: So users know what the group is about, in a little more detail than its name Permission structure of the group: So that the group can be shown if appropriate, and so that it is clear if and how new members can join that group Date the group was created: We could also store the creation date, so if one group becomes old and isn't participated in very often, a newer one may take priority in the search results This information is what would be stored in the groups table in the database Types of groups To make the groups system flexible, there need to be various types of groups available, with different permissions relating to who can have access to them Typically, most social networks tend to provide the following options: • • • Global / public groups: Open to everyone on the site Network specific: Only open to a section of the social network For example, those from a particular geographical region, or working for one particular institution Private, with these options: °° Only available to those who have been explicitly invited by the group's creator °° Semi-private: Only available to those who have been explicitly invited by another member of the group °° Invite-only: Private groups where users can request membership (similar to friend requests), which is then decided by the group's creator or administrator As our Dino Space network doesn't, in its current form, have any provisions for subsidiary networks, such as users based in the US or the UK, or users who work at a specific company, we will not look to implement this feature The other types of groups seem appropriate, so we will look to implement those [ 302 ] Download from Wow! eBook Chapter 10 Ownership There are a number of ways we could facilitate the ownership or management of a community group on our social network Primarily there are two options: • • The creator is the owner / administrator of the group The creator can appoint owner / administrator(s) of the group We will implement the first of these options However, it shouldn't be too difficult to extend this to support appointed administrators, should you wish to extend this for your own social network In this sense, the creator of the group will be listed on the group's page, and they alone will have full control of the group Membership Finally, we need to plan how membership will be organized, particularly in light of the types of groups that we may support We need to be able to store and manage membership lists, lists of invited users who can become members of protected groups should they wish, and also users who have requested to be members of a group, but have not yet been granted access Features Groups need to offer users a dedicated area where they can communicate and collaborate on specific topics related to the purpose of the group, including discussions A group With an idea of what our group needs to do, the information it needs to contain, and how it will work, let's now create the functionality This, as with other features, will involve creation of a model, a controller, and a series of template files to form the view Discussion In order to facilitate communication and collaboration, groups require some new functionality that we don't yet have in Dino Space—discussion forum style topics Let's create models for topics and discussion forum posts Initially, we will tie these with groups; however, it would be easy for us to extend them to other areas of the social network should we wish [ 303 ] Download from Wow! eBook Groups We won't create controllers at this stage, as topics (for now) will only be accessed via groups So either the group's controller will handle this, or the group's controller will delegate control to a group topic controller Discussion forums can be very complicated systems; there are numerous open source and commercial forum software products available with a wealth of features Creating a fully-featured discussion forum would be the series of a number of books in itself For the purposes of Dino Space, we are going to create a very simple discussion-style feature to plug into our social network Database This discussion feature will require two new database tables, one for topics themselves, and one for the posts they relate to Topics Topic records in the database will simply contain a name, who created it and when, and the group they are related to, as illustrated by the table below: Field Type Description ID Integer, Auto-increment, Primary Key Internal reference for the topic of conversation Name Varchar The name of the topic Creator Integer The user who created the topic Created Timestamp The time the topic was created Group Integer The group the topic was created within Posts Posts will contain the content of the post, who created it and when, and the topic that it relates to, as illustrated by the table below Field Type Description ID Integer, Auto-increment, Primary Key Internal reference for the post within a topic Topic Integer The topic the post is part of Post Longtext The post itself Creator Integer The user who created the post Created Timestamp The time the post was created [ 304 ] Download from Wow! eBook Chapter 10 Post When a topic is created, in most cases so is the first post Hence, we should link our post and topic models so that both are created at the same time Since the topic will create the post, we should create the post model first Model The post model (models/post.php) only needs to be basic: various properties for the object, a constructor to get the post from the database, some setter methods to update the properties, and a save method to create a new post or update an existing post