Tải bản đầy đủ (.pdf) (10 trang)

Thiết kế mạng xã hội với PHP - 35

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.35 MB, 10 trang )

Groups
$this->listPublicGroups( 0 );
}
}
else
{
if( isset( $urlBits[1] ) )
{
$this->listPublicGroups( intval( $urlBits[1] ) );
}
else
{
$this->listPublicGroups( 0 );
}
}
}
/**
* Create a new group
* @return void
*/
private function createGroup()
{
if( isset( $_POST ) && is_array( $_POST ) && count( $_POST ) > 0
)
{
require_once( FRAMEWORK_PATH . 'models/group.php');
$group = new Group( $this->registry, 0 );
$group->setCreator( $this->registry->getObject('authenticate')>getUser()->getUserID() );
$group->setName( $this->registry->getObject('db')>sanitizeData( $_POST['name'] ) );
$group->setDescription( $this->registry->getObject('db')>sanitizeData( $_POST['description'] ) );
$group->setType( $_POST['type'] );


$group->save();
$this->registry->errorPage('Group created', 'Thank you, your
new group has been created');
}
else
{
$this->registry->getObject('template')->buildFromTemplates(
'header.tpl.php', 'groups/create.tpl.php', 'footer.tpl.php' );
}
}
}
?>

[ 322 ]

Download from Wow! eBook <www.wowebook.com>


Chapter 10

View

The template for creating a group (views/default/templates/groups/create.
tpl.php) is simply a form, with a text box for name and description and a
drop-down list of types.

<div id="main">
<div id="rightside">
</div>
<div id="content">

Create a new group


<form action="groups/create" method="post">
<label for="name">Name</label>

<input type="text" id="name" name="name" value="" />

<label for="description">Description</label>