textarea = ""; num_characters_permited = 255; function text_longitud(){ num_characters = document.forms[0].description.value.length; if (num_characters > num_characters_permited){ document.forms[0].description.value = textarea; }else{ textarea = document.forms[0].description.value; } } '; // Database table definitions if (!empty($_GET['message'])) { $message = urldecode($_GET['message']); } $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); $tool_name = get_lang('AddGroups'); // Create the form $form = new FormValidator('group_add'); $form->addElement('header', $tool_name); // name $form->addElement('text', 'name', get_lang('Name'), array('size' => 60, 'maxlength' => 120)); $form->applyFilter('name', 'html_filter'); $form->applyFilter('name', 'trim'); $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); // Description $form->addElement( 'textarea', 'description', get_lang('Description'), array('rows' => 3, 'cols' => 58, 'onKeyDown' => "text_longitud()", 'onKeyUp' => "text_longitud()") ); $form->applyFilter('description', 'html_filter'); $form->applyFilter('description', 'trim'); // url $form->addElement('text', 'url', get_lang('URL'), array('size' => 35)); $form->applyFilter('url', 'html_filter'); $form->applyFilter('url', 'trim'); // Picture $form->addElement('file', 'picture', get_lang('AddPicture')); $allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); $form->addRule( 'picture', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types ); //Group Parentship $groups = array(); $groups[0] = get_lang('NoParentship'); $groups = $groups + GroupPortalManager::get_groups_list($group_id); $group_data['parent_group'] = GroupPortalManager::get_parent_group($group_id); $form->addElement('select', 'parent_group', get_lang('GroupParentship'), $groups, array()); // Status $status = array(); $status[GROUP_PERMISSION_OPEN] = get_lang('Open'); $status[GROUP_PERMISSION_CLOSED] = get_lang('Closed'); $form->addElement('select', 'visibility', get_lang('GroupPermissions'), $status); // Set default values $defaults['status'] = GROUP_PERMISSION_OPEN; $form->setDefaults($defaults); // Submit button $form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="add"'); // Validate form if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $values = $form->exportValues(); $picture_element = $form->getElement('picture'); $picture = $picture_element->getValue(); $picture_uri = ''; $name = $values['name']; $description = $values['description']; $url = $values['url']; $status = intval($values['visibility']); $picture = $_FILES['picture']; $parent_group_id = intval($values['parent_group']); $group_id = GroupPortalManager::add($name, $description, $url, $status); GroupPortalManager::set_parent_group($group_id, $parent_group_id); if (!empty($picture['name'])) { $picture_uri = GroupPortalManager::update_group_picture( $group_id, $_FILES['picture']['name'], $_FILES['picture']['tmp_name'] ); GroupPortalManager::update($group_id, $name, $description, $url, $status, $picture_uri); } Security::clear_token(); $tok = Security::get_token(); header( 'Location: group_list.php?action=show_message&message='.urlencode(get_lang('GroupAdded')).'&sec_token='.$tok ); exit (); } } else { if (isset($_POST['submit'])) { Security::clear_token(); } $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); } // Display form Display::display_header($tool_name); //api_display_tool_title($tool_name); if (!empty($message)) { Display::display_normal_message(stripslashes($message)); } $form->display(); // Footer Display::display_footer();