$extended['id'] = $id; $extended['video_id'] = $this->video_id; $this->registry->getObject('db')->insertRecords( 'statuses_videos', $extended ); }}?>LinksWhen sharing links with other users we need to at least store the URL itself. We could also store a brief desc[r]
* @return void */ public function __construct( Registry $registry, $id = 0 ) { $this->registry = $registry; parent::setTypeReference('image'); parent::__construct( $this->registry, $id ); }To call a method from an object's parent class, we use the parent keyword, followed by the scope[r]
{ $this->registry->errorPage( 'Access denied', 'Sorry, you are not allowed to delete that message'); }}Composing a new messageComposing a new message is the most complicated aspect for the feature, as there are a number of aspects to consider (and change, depending on the needs of the[r]
• Work out how many days there are in a particular monthCalendar libraryWe will save our calendar library le as /lib/calendar/calendar.class.php. The rst thing for us to do in our le, is create a number of variables, and the constructor.We need variables for:• The year the calendar repre[r]
Events and Birthdays[ 266 ]Generate and outputTo actually display a calendar, we need some code which:• Requires the calendar library• Instantiates the object• Generates the month• Sends various bits of data to the template• Outputs the templateWe also need a template le with our 42 boxes in a[r]
Chapter 9[ 275 ]Getting the birthdaysWith the calendar setup, and a method in our relationships model for us to get the IDs of connected users, we can get the birthdays.First, we need to require the relationships model, instantiate the object, and get the IDs SQL:require_once( FRAMEWORK_PATH . 'mode[r]
increment, Primary KeyReference ID for the messageSender Integer The sender of the messageRecipient Integer The recipient of the messageSubject Varchar The subject the message relates toSent Timestamp When the message was sentMessage Longtext The contents of the message itselfRead Boolean Indicates[r]
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.Download from Wow! eBook <www.wowebook.com>Chapter 6[ 183 ]5. We then iterate through the results making the time the status was posted more f[r]
• Viewing a message• Creating a new messageDownload from Wow! eBook <www.wowebook.com>Chapter 7[ 219 ]Listing messagesTo list our messages, we simply require our messages controller, call the getInbox method, and send the cache to the template engine. The read_style eld in the resul[r]
Download from Wow! eBook <www.wowebook.com>Chapter 11[ 351 ]How could it work?There are three commonly-used methods for an API to work:• REST: Representational State Transfer• RPC: Remote Procedure Call• SOAP: Simple Object Access ProtocolLet's look into what these are.RESTRepresent[r]
header("HTTP/1.0404NotFound");The second part of the response is the data itself; for instance, if the API request was for a list of users, the response would be the list of users. Commonly, response data is sent as XML or JSON. Some APIs allow the consumer to request the format of the response b[r]
the resources as our site becomes more popular. Normally, with shared hosting, accounts can be upgraded to include more space or bandwidth, though not additional processing power; with VPS and cloud providers, the specication of the server, and the processing power allocated can often be upgraded a[r]
Deployment, Security, and Maintenance[ 382 ]From here, we can select which tables we wish to download, and have the option of either exporting the database as SQL, or as a download containing SQL, as shown in the following screenshot:Importing our local database to the hosting accountWith a copy of[r]
To list events by connected users in a certain month, we simply use the relationships model, call the getIDsByUser method, and then query the events table, ltering by the results from the getIDs query, where the date is in a specic month and year: /** * List events by connected users in specified[r]
pr.user_id=p.creator AND p.topic=" . $this->id; return $sql; }We have a method to set if we are including the rst post. If we are, we include the class, instantiate the object, and assign it to the post property in the topic object. /** * Set if this save should also save the first post * @p[r]
Calendar of eventsWe looked earlier at integrating the calendar library with birthdays, so why not try and integrate the events with the calendar too? The code is in the download bundle for this book if you need help.Viewing an eventTo view an event, we simply call the toTags method on the model, an[r]
The rst stage, as with the other aspects of our social network, is the database table. We've already discussed what information the group needs to store; the following database structure simply formalizes that:Field Type DescriptionID Integer, Auto-increment, Primary KeyInternal ID / reference for[r]