isError()) {
exit_no_group();
}
$f=new Forum($g,$forum_id);
if (!$f || !is_object($f)) {
exit_error(_('Error getting new Forum'),'forums');
} elseif ($f->isError()) {
exit_error($f->getErrorMessage(),'forums');
}
/*
if necessary, insert a new message into the forum
*/
if (getStringFromRequest('post_message')) {
if (!form_key_is_valid(getStringFromRequest('form_key'))) {
exit_form_double_submit('forums');
}
$subject = getStringFromRequest('subject');
$body = getStringFromRequest('body');
$is_followup_to = getStringFromRequest('is_followup_to');
$fm=new ForumMessage($f);
if (!$fm || !is_object($fm)) {
form_release_key(getStringFromRequest("form_key"));
exit_error(_('Error getting new ForumMessage'),'forums');
} elseif ($fm->isError()) {
form_release_key(getStringFromRequest("form_key"));
exit_error(_('Error getting new ForumMessage:'.' '.$fm->getErrorMessage()),'forums');
}
if (getStringFromRequest('_body_content_type') == 'html') {
$body = TextSanitizer::purify($body);
} else {
$body = htmlspecialchars($body);
}
$attach = getUploadedFile("attachment1");
if ($attach['size']) {
$has_attach = true;
} else {
$has_attach = false;
}
if (!$fm->create($subject, $body, $thread_id, $is_followup_to,$has_attach) || $fm->isError()) {
form_release_key(getStringFromRequest("form_key"));
exit_error(_('Error creating ForumMessage:').' '.$fm->getErrorMessage(),'forums');
} else {
if ($fm->isPending() ) {
$feedback=_('Message Queued for moderation -> Please wait until the admin approves/rejects it');
} else {
$feedback=_('Message Posted Successfully');
}
$am = NEW AttachManager();//object that will handle and insert the attachment into the db
$am->SetForumMsg($fm);
$am->attach($attach,$group_id,0,$fm->getID());
foreach ($am->Getmessages() as $item) {
$feedback .= "
" . $item;
}
$style='';
$thread_id='';
if (getStringFromRequest('monitor')) {
$f->setMonitor();
}
}
}
$fmf = new ForumMessageFactory($f);
if (!$fmf || !is_object($fmf)) {
form_release_key(getStringFromRequest("form_key"));
exit_error(_('Error getting new ForumMessageFactory'),'forums');
} elseif ($fmf->isError()) {
form_release_key(getStringFromRequest("form_key"));
exit_error($fmf->getErrorMessage(),'forums');
}
//echo "
style: $style|max_rows: $max_rows|offset: $offset+";
$fmf->setUp($offset,$style,$max_rows,$set);
$style=$fmf->getStyle();
$max_rows=$fmf->max_rows;
$offset=$fmf->offset;
//echo "
style: $style|max_rows: $max_rows|offset: $offset+";
$fh = new ForumHTML($f);
if (!$fh || !is_object($fh)) {
exit_error(_('Error getting new ForumHTML'),'forums');
} elseif ($fh->isError()) {
exit_error($fh->getErrorMessage(),'forums');
}
forum_header(array('title'=>_('Forum: ') . $f->getName(),'forum_id'=>$forum_id));
/**
*
* Forum styles include Nested, threaded, flat, ultimate
*
* threaded indents and shows subjects/authors of all messages/followups
* nested indents and shows the entirety of all messages/followups
* flat shows entiretly of messages in date order descending
* ultimate is based roughly on "Ultimate BB"
*
*/
//create a pop-up select box listing the forums for this project
//determine if this person can see private forums or not
if (session_loggedin() && user_ismember($group_id)) {
$public_flag='0,1';
} else {
$public_flag='1';
}
//create a pop-up select box showing options for viewing threads
$vals=array('nested','flat','threaded','ultimate');
$texts=array(_('Nested'), _('Flat'), _('Threaded'), _('Ultimate'));
$options_popup=html_build_select_box_from_arrays ($vals,$texts,'style',$style,false);
//create a pop-up select box showing options for max_row count
$vals=array(25,50,75,100);
$texts=array(_('Show').' 25',_('Show').' 50',_('Show').' 75',_('Show').' 100');
$max_row_popup=html_build_select_box_from_arrays ($vals,$texts,'max_rows',$max_rows,false);
//now show the popup boxes in a form
$ret_val = '
'; $am = new AttachManager(); $ret_val .= $am->PrintHelperFunctions(); if ($style=='nested') { $msg_arr =& $fmf->nestArray($fmf->getNested()); if ($fmf->isError()) { echo '
before showNestedMessages() $tempid | ". count( $msg_arr["$tempid"] ); $ret_val .= $fh->showNestedMessages ( $msg_arr, $tempid ); } $i++; } } else if ($style=='threaded') { $msg_arr =& $fmf->nestArray($fmf->getThreaded()); if ($fmf->isError()) { echo '
'; if ($offset != 0) { $ret_val .= ' ' . html_image('t2.png',"15","15") ._('Newer Messages').''; } else { $ret_val .= ' '; } $ret_val .= ' | '; if ($avail_rows > $max_rows) { $ret_val .= ' '._('Older Messages') . html_image('t.png',"15","15") . ''; } else { $ret_val .= ' '; } $ret_val .= ' |
'; if (!$thread_id) { // // Viewing an entire message forum in a given format // echo '