access_type == 1 && Group::member_exists((int)$_GET['ccid'], (int)$_SESSION['user']['id'])) || ($group->access_type == 0))) {
/* Function for Filtering the POST data Array */
filter_all_post($_POST);
$error = FALSE;
$msg = '';
$title = trim($_POST['title_form']);
$body = trim($_POST['comment']);
$name = '';
$email = '';
if(isset($_POST['name'])) {
if(empty($_POST['name'])) {
$error = TRUE;
$msg[] = "Please enter your name";
} else {
$name = trim($_POST['name']);
}
}
if(isset($_POST['email'])) {
if(empty($_POST['email'])) {
$error = TRUE;
$msg[] = "Please enter your email address";
} else if(!validate_email($_POST['email'])) {
$error = TRUE;
$msg[] = "Please enter a valid email address";
} else {
$email = trim($_POST['email']);
}
}
if ( $title == '' ) {
$error = TRUE;
$msg[] = "Please specify title";
}
if ( $body == '' ) {
$error = TRUE;
$msg[] = "Please enter contents";
}
if ( !$error ) {
$cat_obj = new MessageBoard();
$cat_obj->set_parent($parent_id,$parent_type);
$cat_obj->title = $title;
$cat_obj->body = $body;
$cat_obj->user_id = $uid;
$cat_obj->user_name = $name;
$cat_obj->email = $email;
if ( !$_POST['chk_allow_anonymous'] ) {
$cat_obj->allow_anonymous = 0;
} else {
$cat_obj->allow_anonymous = 1;
}
try {
$mid = $cat_obj->save($_SESSION['user']['id']);
}
catch (PAException $e) {
$msg = "Error occured in saving thread\n";
$msg .= "
".$e->message."";
$error = TRUE;
}
}
if ( $mid ) {
//echo 'data has been saved';
if ($_GET['ccid']) {
header("Location: $base_url/forum_messages.php?mid=$parent_id&ccid=".$_GET['ccid']);
} else {
header("Location: $base_url/forum_messages.php?mid=$parent_id");
}
exit;
}
}
else if (isset($_POST['submit']) && !(Group::member_exists((int)$_GET['ccid'], (int)$_SESSION['user']['id']))) {
$msg = "You are not a member of this group.";
$error = TRUE;
}
$setting_data = ModuleSetting::load_setting(PAGE_FORUM_MESSAGES , $uid);
if ($_REQUEST['ccid']) {
array_unshift($setting_data['left'],'GroupAccessModule','MembersFacewallModule');
array_unshift($setting_data['right'],'GroupStatsModule','RecentPostModule');
}
$param['action'] = 'edit_forum';
function setup_module($column, $moduleName, $obj) {
global $request_info, $title, $body, $name, $email, $paging, $msg;
global $group_details, $users, $param;
switch ($moduleName) {
case 'GroupAccessModule':
case 'GroupStatsModule':
$obj->group_details = $group_details;
break;
case 'MembersFacewallModule':
$obj->group_details = $group_details;
$obj->mode = PRI;
$obj->block_type = HOMEPAGE;
$obj->links = $users;
$obj->gid = $_REQUEST['ccid'];
break;
case 'RecentPostModule':
$obj->block_type = HOMEPAGE;
$obj->type = 'group';
$obj->mode = PRI;
$obj->gid = $_REQUEST['ccid'];
$obj->group_details = $group_details;
break;
case 'GroupForumPermalinkModule':
global $group_top_mesg;
$gid = $_REQUEST['ccid'];
$group = ContentCollection::load_collection((int)$gid, $_SESSION['user']['id']);
$is_member = Group::member_exists((int)$gid, $_SESSION['user']['id']);
$is_admin = Group::is_admin((int)$gid, $_SESSION['user']['id']);
if ($group->reg_type == REG_INVITE && !$is_member && !$is_admin && !user_can($param)) {
$msg = MessagesHandler::get_message(9005);
return "skip";
}
$obj->parent_id = $request_info['parent_id'];
$obj->parent_name_hidden = $request_info['parent_name_hidden'];
$obj->parent_type = $request_info['parent_type'];
$obj->header_title = $request_info['header_title'];
$obj->title_form = $title;
$obj->body = $body;
$obj->name = $name;
$obj->email = $email;
$obj->Paging["page"] = $paging["page"];
$obj->Paging["show"] = 5; //five records
if ( $error )
{
$obj->msg = $msg;
}
break;
}
}
$page = new PageRenderer("setup_module", PAGE_FORUM_MESSAGES, "Message forum", "container_three_column.tpl", "header_group.tpl", PUB, HOMEPAGE, $network_info,'',$setting_data);
$page->header->set('group_name', $group->title);
if (!empty($msg)) {
//print $group_top_mesg; exit;
$msg_tpl = & new Template(CURRENT_THEME_FSPATH."/display_message.tpl");
$msg_tpl->set('message', $msg);
$page->add_module("middle", "top", $msg_tpl->fetch());
}
//applying theme
$theme_details = get_group_theme(@$_GET['gid']);
if (is_array($theme_details['css_files'])) {
foreach ($theme_details['css_files'] as $key => $value) {
$page->add_header_css($value);
}
}
$page->header->set('theme_details', $theme_details);
echo $page->render();
?>