Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
class NewPost extends TPage
4
{
5
	/**
6
	 * Creates a new post if all inputs are valid.
7
	 * This method responds to the OnClick event of the "create" button.
8
	 * @param mixed event sender
9
	 * @param mixed event parameter
10
	 */
11
	public function createButtonClicked($sender,$param)
12
	{
13
		if($this->IsValid)  // when all validations succeed
14
		{
15
			// populates a PostRecord object with user inputs
16
			$postRecord=new PostRecord;
17
			// using SafeText instead of Text avoids Cross Site Scripting attack
18
			$postRecord->title=$this->TitleEdit->SafeText;
19
			$postRecord->content=$this->ContentEdit->SafeText;
20
			$postRecord->author_id=$this->User->Name;
21
			$postRecord->create_time=time();
22
			$postRecord->status=0;
23
 
24
			// saves to the database via Active Record mechanism
25
			$postRecord->save();
26
 
27
			// redirects the browser to the newly created post page
28
			$url=$this->Service->constructUrl('posts.ReadPost',array('id'=>$postRecord->post_id));
29
			$this->Response->redirect($url);
30
		}
31
	}
32
}
33
 
34
?>