');
$group='';
$group[] =& HTML_QuickForm::createElement('radio', 'students_can_edit',null,get_lang('Yes'),1);
$group[] =& HTML_QuickForm::createElement('radio', 'students_can_edit',null,get_lang('No'),0);
$form->addGroup($group, 'students_can_edit_group', get_lang('StudentsCanEdit'), ' ');
// This is for vertical
//$form->addElement('radio', 'approval_direct', get_lang('ApprovalDirect'), get_lang('Approval'), 1);
//$form->addElement('radio', 'approval_direct', '', get_lang('Direct'), 0);
// This is for horizontal
$group='';
$group[] =& HTML_QuickForm::createElement('radio', 'approval_direct',null,get_lang('Approval'),1);
$group[] =& HTML_QuickForm::createElement('radio', 'approval_direct',null,get_lang('Direct'),0);
//$form->addGroup($group, 'approval_direct_group', get_lang('ApprovalDirect'), ' ');
// This is for vertical
//$form->addElement('radio', 'allow_attachments', get_lang('AllowAttachments'), get_lang('Yes'), 1);
//$form->addElement('radio', 'allow_attachments', '', get_lang('No'), 0);
// This is for horizontal
$group='';
$group[] =& HTML_QuickForm::createElement('radio', 'allow_attachments',null,get_lang('Yes'),1);
$group[] =& HTML_QuickForm::createElement('radio', 'allow_attachments',null,get_lang('No'),0);
//$form->addGroup($group, 'allow_attachments_group', get_lang('AllowAttachments'), ' ');
// This is for vertical
//$form->addElement('radio', 'allow_new_threads', get_lang('AllowNewThreads'), 1, get_lang('Yes'));
//$form->addElement('radio', 'allow_new_threads', '', 0, get_lang('No'));
// This is for horizontal
$group='';
$group[] =& HTML_QuickForm::createElement('radio', 'allow_new_threads',null, get_lang('Yes'),1);
$group[] =& HTML_QuickForm::createElement('radio', 'allow_new_threads',null, get_lang('No'),0);
$form->addGroup($group, 'allow_new_threads_group', get_lang('AllowNewThreads'), ' ');
$group='';
$group[] =& HTML_QuickForm::createElement('radio', 'default_view_type', null, get_lang('Flat'), 'flat');
$group[] =& HTML_QuickForm::createElement('radio', 'default_view_type', null, get_lang('Threaded'), 'threaded');
$group[] =& HTML_QuickForm::createElement('radio', 'default_view_type', null, get_lang('Nested'), 'nested');
$form->addGroup($group, 'default_view_type_group', get_lang('DefaultViewType'), ' ');
$form->addElement('static','Group', '
'.get_lang('GroupSettings').'');
// dropdown list: Groups
$groups=GroupManager::get_group_list();
$groups_titles[0]=get_lang('NotAGroupForum');
foreach ($groups as $key=>$value) {
$groups_titles[$value['id']]=$value['name'];
}
$form->addElement('select', 'group_forum', get_lang('ForGroup'), $groups_titles);
// Public or private group forum
$group='';
$group[] =& HTML_QuickForm::createElement('radio', 'public_private_group_forum', null, get_lang('Public'), 'public');
$group[] =& HTML_QuickForm::createElement('radio', 'public_private_group_forum', null, get_lang('Private'), 'private');
$form->addGroup($group, 'public_private_group_forum_group', get_lang('PublicPrivateGroupForum'), ' ');
// Forum image
$form->add_progress_bar();
if (isset($inputvalues['forum_image']) && strlen($inputvalues['forum_image']) > 0) {
$image_path = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/forum/images/'.$inputvalues['forum_image'];
$image_size = api_getimagesize($image_path);
$img_attributes = '';
if (!empty($image_size)) {
if ($image_size[0] > 100 || $image_size[1] > 100) {
//limit display width and height to 100px
$img_attributes = 'width="100" height="100"';
}
$show_preview_image='

';
$div = '
'.get_lang('PreviewImage').'
'.$show_preview_image.'
';
$form->addElement('html', $div .'
');
$form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
}
}
$forum_image=isset($inputvalues['forum_image']) ? $inputvalues['forum_image'] : '';
$form->addElement('file', 'picture', ($forum_image != '' ? get_lang('UpdateImage') : get_lang('AddImage')));
$form->addRule('picture', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
$form->addElement('html','
');
// The OK button
if (isset($_GET['id']) && $_GET['action']=='edit') {
$class='save';
$text=get_lang('ModifyForum');
}else{
$class='add';
$text=get_lang('CreateForum');
}
$form->addElement('style_submit_button', 'SubmitForum', $text, 'class="'.$class.'"');
// setting the rules
$form->addRule('forum_title', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('forum_category', get_lang('ThisFieldIsRequired'), 'required');
global $charset;
// settings the defaults
if (!is_array($inputvalues)) {
$defaults['allow_anonymous_group']['allow_anonymous']=0;
$defaults['students_can_edit_group']['students_can_edit']=0;
$defaults['approval_direct_group']['approval_direct']=0;
$defaults['allow_attachments_group']['allow_attachments']=1;
$defaults['allow_new_threads_group']['allow_new_threads']=0;
$defaults['default_view_type_group']['default_view_type']=api_get_setting('default_forum_view');
$defaults['public_private_group_forum_group']['public_private_group_forum']='public';
if (isset($_GET['forumcategory'])) {
$defaults['forum_category']=Security::remove_XSS($_GET['forumcategory']);
}
} else { // the default values when editing = the data in the table
$defaults['forum_id']=isset($inputvalues['forum_id']) ? $inputvalues['forum_id'] : null;
$defaults['forum_title']=prepare4display(api_html_entity_decode(isset($inputvalues['forum_title']) ? $inputvalues['forum_title'] : null,ENT_QUOTES,$charset));
$defaults['forum_comment']=prepare4display(isset($inputvalues['forum_comment'])?$inputvalues['forum_comment']:null);
$defaults['forum_category']=isset($inputvalues['forum_category']) ? $inputvalues['forum_category'] : null;
$defaults['allow_anonymous_group']['allow_anonymous']=isset($inputvalues['allow_anonymous']) ? $inputvalues['allow_anonymous'] :null;
$defaults['students_can_edit_group']['students_can_edit']=isset($inputvalues['allow_edit'])?$inputvalues['allow_edit']:null;
$defaults['approval_direct_group']['approval_direct']=isset($inputvalues['approval_direct_post'])?$inputvalues['approval_direct_post']:null;
$defaults['allow_attachments_group']['allow_attachments']=isset($inputvalues['allow_attachments'])?$inputvalues['allow_attachments']:null;
$defaults['allow_new_threads_group']['allow_new_threads']=isset($inputvalues['allow_new_threads'])?$inputvalues['allow_new_threads']:null;
$defaults['default_view_type_group']['default_view_type']=isset($inputvalues['default_view'])?$inputvalues['default_view']:null;
$defaults['public_private_group_forum_group']['public_private_group_forum']=isset($inputvalues['forum_group_public_private'])?$inputvalues['forum_group_public_private']:null;
$defaults['group_forum']=isset($inputvalues['forum_of_group'])?$inputvalues['forum_of_group']:null;
}
$form->setDefaults($defaults);
// The validation or display
if( $form->validate()) {
$check = Security::check_token('post');
if ($check) {
$values = $form->exportValues();
$return_message = store_forum($values);
Display :: display_confirmation_message($return_message);
}
Security::clear_token();
} else {
$token = Security::get_token();
$form->addElement('hidden','sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
}
}
/**
* This function deletes the forum image if exists
*
* @param int forum id
* @return boolean true if success
* @author Julio Montoya
'; $hand_forums.= $posts['post_text']; $hand_forums.= '
'; } } $hand_forums.= '