02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

192<br />

CHAPTER 5 ■ ADD CONTROLS TO CREATE, EDIT, AND DELETE EVENTS<br />

Figure 5-7. The Delete button as it appears on the full event view<br />

Creating a Method to Require Confirmation<br />

When a user clicks the Delete button, he is sent to a confirmation page that contains a form to make sure<br />

he really wants to delete the event. That form will be generated <strong>by</strong> a new public method in the Calendar<br />

class called confirmDelete().<br />

This method confirms that an event should be deleted <strong>by</strong> performing the following actions:<br />

1. Checks if the confirmation form was submitted <strong>and</strong> a valid token was passed.<br />

If so, go to Step 2. If not, go to Step 3.<br />

2. Checks whether the button clicked was the Confirmation button.<br />

• If so, it deletes the event.<br />

• If not, it sends the user back out to the main calendar view.<br />

3. It loads the event data <strong>and</strong> displays the confirmation form.<br />

You accomplish the preceding steps <strong>by</strong> adding the new method, shown in bold, to the Calendar<br />

class:<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!