$form->addElement('select', 'group', get_lang('AnnouncementForGroup'), $group_list);
 }
 $values['group'] = isset($values['group']) ? $values['group'] : '0';
 $form->addElement('checkbox', 'send_mail', null, get_lang('SendMail'));
 if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'add') {
     $form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar'));
     $text = get_lang('AddNews');
     $class = 'add';
     $form->addElement('hidden', 'action', 'add');
 } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') {
     $text = get_lang('EditNews');
     $class = 'save';
     $form->addElement('hidden', 'action', 'edit');
 }
 $form->addElement('checkbox', 'send_email_test', null, get_lang('SendOnlyAnEmailToMySelfToTest'));
 $form->addButtonSend($text, 'submit');
 $form->setDefaults($values);
 if ($form->validate()) {
     $values = $form->exportValues();
     if (!isset($values['visible_teacher'])) {
         $values['visible_teacher'] = false;
     }
     if (!isset($values['visible_student'])) {
         $values['visible_student'] = false;
     }
     if (!isset($values['visible_guest'])) {
         $values['visible_guest'] = false;
     }
     if ($values['lang'] == 'all') {
         $values['lang'] = null;
     }
Example #2
0
function manage_form($default, $select_from_user_list = null, $sent_to = null)
{
    $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
    $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
    $param_f = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null;
    $form = new FormValidator('compose_message', null, api_get_self() . '?f=' . $param_f, null, array('enctype' => 'multipart/form-data'));
    if (empty($group_id)) {
        if (isset($select_from_user_list)) {
            $form->addText('id_text_name', get_lang('SendMessageTo'), true, array('id' => 'id_text_name', 'onkeyup' => 'send_request_and_search()', 'autocomplete' => 'off'));
            $form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required');
            $form->addElement('html', '<div id="id_div_search" style="padding:0px" class="message-select-box" >&nbsp;</div>');
            $form->addElement('hidden', 'user_list', 0, array('id' => 'user_list'));
        } else {
            if (!empty($sent_to)) {
                $form->addLabel(get_lang('SendMessageTo'), $sent_to);
            }
            if (empty($default['users'])) {
                //fb select
                $form->addElement('select_ajax', 'users', get_lang('SendMessageTo'), array(), ['multiple' => 'multiple', 'url' => api_get_path(WEB_AJAX_PATH) . 'message.ajax.php?a=find_users']);
            } else {
                $form->addElement('hidden', 'hidden_user', $default['users'][0], array('id' => 'hidden_user'));
            }
        }
    } else {
        $userGroup = new UserGroup();
        $group_info = $userGroup->get($group_id);
        $form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name']));
        $form->addElement('hidden', 'group_id', $group_id);
        $form->addElement('hidden', 'parent_id', $message_id);
    }
    $form->addText('title', get_lang('Subject'), true);
    $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '100%', 'Height' => '250'));
    if (isset($_GET['re_id'])) {
        $message_reply_info = MessageManager::get_message_by_id($_GET['re_id']);
        $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_reply_info['title'];
        $form->addElement('hidden', 're_id', intval($_GET['re_id']));
        $form->addElement('hidden', 'save_form', 'save_form');
        //adding reply mail
        $user_reply_info = api_get_user_info($message_reply_info['user_sender_id']);
        $default['content'] = '<p><br/></p>' . sprintf(get_lang('XWroteY'), $user_reply_info['complete_name'], Security::filter_terms($message_reply_info['content']));
    }
    if (empty($group_id)) {
        $form->addElement('label', '', '<div  id="filepaths" class="form-group">
                    <div id="filepath_1">
                    <label>' . get_lang('FilesAttachment') . '</label>
                    <input type="file" name="attach_1"/>
                    <label>' . get_lang('Description') . '</label>
                    <input id="file-descrtiption" type="text" name="legend[]" class="form-control"/>
                    </div>
                </div>');
        $form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span>&nbsp;(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message.message_max_upload_filesize'))) . ')');
    }
    $form->addButtonSend(get_lang('SendMessage'), 'compose');
    $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>');
    if (!empty($group_id) && !empty($message_id)) {
        $message_info = MessageManager::get_message_by_id($message_id);
        $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_info['title'];
    }
    $form->setDefaults($default);
    $html = '';
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $user_list = $default['users'];
            $file_comments = $_POST['legend'];
            $title = $default['title'];
            $content = $default['content'];
            $group_id = isset($default['group_id']) ? $default['group_id'] : null;
            $parent_id = isset($default['parent_id']) ? $default['parent_id'] : null;
            if (is_array($user_list) && count($user_list) > 0) {
                //all is well, send the message
                foreach ($user_list as $user) {
                    $res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id);
                    if ($res) {
                        $html .= MessageManager::display_success_message($user);
                    }
                }
            } else {
                Display::display_error_message('ErrorSendingMessage');
            }
        }
        Security::clear_token();
    } else {
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $html .= $form->returnForm();
    }
    return $html;
}
Example #3
0
 case 'set_status':
     $status = isset($_REQUEST['status']) ? intval($_REQUEST['status']) : 0;
     $chat->setUserStatus($status);
     break;
 case 'start_video':
     $room = VideoChat::getChatRoomByUsers(api_get_user_id(), $to_user_id);
     if ($room !== false) {
         $videoChatLink = Display::url(Display::tag('i', null, ['class' => 'fa fa-video-camera']) . "&nbsp;" . get_lang('StartVideoChat'), api_get_path(WEB_LIBRARY_JS_PATH) . "chat/video.php?room={$room['room_name']}");
         $chat->send(api_get_user_id(), $to_user_id, $videoChatLink, false);
         echo Display::tag('p', $videoChatLink, ['class' => 'lead']);
         break;
     }
     $form = new FormValidator('start_video_chat');
     $form->addText('chat_room_name', get_lang('ChatRoomName'), false);
     $form->addHidden('to', $to_user_id);
     $form->addButtonSend(get_lang('Create'));
     $template = new Template();
     $template->assign('form', $form->returnForm());
     echo $template->fetch('default/javascript/chat/start_video.tpl');
     break;
 case 'create_room':
     $room = VideoChat::getChatRoomByUsers(api_get_user_id(), $to_user_id);
     $createdRoom = false;
     if ($room === false) {
         $roomName = isset($_REQUEST['room_name']) ? Security::remove_XSS($_REQUEST['room_name']) : null;
         if (VideoChat::nameExists($roomName)) {
             echo Display::return_message(get_lang('TheVideoChatRoomXNameAlreadyExists'), 'error');
             break;
         }
         $createdRoom = VideoChat::createRoom($roomName, api_get_user_id(), $to_user_id);
     } else {
/* For licensing terms, see /license.txt */
/**
 *   @package chamilo.admin
 */
// resetting the course id
$cidReset = true;
// including some necessary files
require_once '../inc/global.inc.php';
// setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN;
// Access restrictions
api_protect_admin_script(true);
// setting breadcrumbs
$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$form = new FormValidator('archive_cleanup_form', 'post', '', '', array(), FormValidator::LAYOUT_BOX);
$form->addButtonSend(get_lang('ArchiveDirCleanupProceedButton'));
$message = null;
if ($form->validate()) {
    $archive_path = api_get_path(SYS_ARCHIVE_PATH);
    $htaccess = @file_get_contents($archive_path . '.htaccess');
    $result = rmdirr($archive_path, true, true);
    if (!empty($htaccess)) {
        @file_put_contents($archive_path . '/.htaccess', $htaccess);
    }
    if ($result) {
        $message = 'ArchiveDirCleanupSucceeded';
        $type = 'confirmation';
    } else {
        $message = 'ArchiveDirCleanupFailed';
        $type = 'error';
    }
Example #5
0
    $html .= '</ul>';
}
$html .= Display::page_subheader2(get_lang('StudentList'));
// PERSON_NAME_DATA_EXPORT is buggy
$is_western_name_order = api_is_western_name_order();
if (count($a_students) > 0) {
    $getLangXDays = get_lang('XDays');
    $form = new FormValidator('reminder_form', 'get', api_get_path(WEB_CODE_PATH) . 'announcements/announcements.php?' . api_get_cidreq(), null, ['style' => 'margin-bottom: 10px'], FormValidator::LAYOUT_INLINE);
    $options = array(2 => sprintf($getLangXDays, 2), 3 => sprintf($getLangXDays, 3), 4 => sprintf($getLangXDays, 4), 5 => sprintf($getLangXDays, 5), 6 => sprintf($getLangXDays, 6), 7 => sprintf($getLangXDays, 7), 15 => sprintf($getLangXDays, 15), 30 => sprintf($getLangXDays, 30), 'never' => get_lang('Never'));
    $el = $form->addSelect('since', Display::returnFontAwesomeIcon('warning') . get_lang('RemindInactivesLearnersSince'), $options, ['class' => 'col-sm-3']);
    $el->setSelected(7);
    $form->addElement('hidden', 'action', 'add');
    $form->addElement('hidden', 'remindallinactives', 'true');
    $form->addElement('hidden', 'cidReq', $courseInfo['code']);
    $form->addElement('hidden', 'id_session', api_get_session_id());
    $form->addButtonSend(get_lang('SendNotification'));
    $extra_field_select = TrackingCourseLog::display_additional_profile_fields();
    if (!empty($extra_field_select)) {
        $html .= $extra_field_select;
    }
    $html .= $form->return_form();
    if ($export_csv) {
        $csv_content = array();
        //override the SortableTable "per page" limit if CSV
        $_GET['users_tracking_per_page'] = 1000000;
    }
    $all_datas = array();
    $course_code = $_course['id'];
    $user_ids = array_keys($a_students);
    $table = new SortableTable('users_tracking', array('TrackingCourseLog', 'get_number_of_users'), array('TrackingCourseLog', 'get_user_data'), (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
    $parameters['cidReq'] = Security::remove_XSS($_GET['cidReq']);
Example #6
0
    $form->addElement('html', '<div class="label">' . get_lang('SearchFeatureDocumentLanguage') . '</div>');
    $form->addLabel(get_lang('Language'), api_get_languages_combo());
    $form->addElement('html', '</div><div class="sub-form">');
    $specific_fields = get_specific_field_list();
    foreach ($specific_fields as $specific_field) {
        $form->addElement('text', $specific_field['code'], $specific_field['name']);
    }
    $form->addElement('html', '</div>');
}
$form->addElement('radio', 'if_exists', get_lang('UplWhatIfFileExists'), get_lang('UplDoNothing'), 'nothing');
$form->addElement('radio', 'if_exists', '', get_lang('UplOverwriteLong'), 'overwrite');
$form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'rename');
// Close the java script and avoid the footer up
$form->addElement('html', '</div>');
// Button upload document
$form->addButtonSend(get_lang('SendDocument'), 'submitDocument');
$form->add_real_progress_bar('DocumentUpload', 'file');
$fileExistsOption = api_get_setting('document.if_file_exists_option');
$defaultFileExistsOption = 'rename';
if (!empty($fileExistsOption)) {
    $defaultFileExistsOption = $fileExistsOption;
}
$defaults = array('index_document' => 'checked="checked"', 'if_exists' => $defaultFileExistsOption);
$form->setDefaults($defaults);
$simple_form = $form->returnForm();
$url = api_get_path(WEB_AJAX_PATH) . 'document.ajax.php?' . api_get_cidreq() . '&a=upload_file&curdirpath=' . $path;
$multipleForm = new FormValidator('drag_drop', 'post', '#', array('enctype' => 'multipart/form-data'));
$multipleForm->addMultipleUpload($url);
$headers = array(get_lang('Upload'), get_lang('Upload') . ' (' . get_lang('Simple') . ')');
echo Display::tabs($headers, array($multipleForm->returnForm(), $form->returnForm()), 'tabs');
Display::display_footer();
Example #7
0
$this_section = SECTION_CAMPUS;
$tool_name = get_lang('LostPassword');
if ($reset && $userId) {
    $messageText = Login::reset_password($reset, $userId, true);
    if (CustomPages::enabled() && CustomPages::exists(CustomPages::INDEX_UNLOGGED)) {
        CustomPages::display(CustomPages::INDEX_UNLOGGED, ['info' => $messageText]);
        exit;
    }
    Display::addFlash(Display::return_message($messageText));
    header('Location: ' . api_get_path(WEB_PATH));
    exit;
}
$form = new FormValidator('lost_password');
$form->addHeader($tool_name);
$form->addText('user', [get_lang('LoginOrEmailAddress'), get_lang('EnterEmailUserAndWellSendYouPassword')], true);
$form->addButtonSend(get_lang('Send'));
if ($form->validate()) {
    $values = $form->exportValues();
    $user = Login::get_user_accounts_by_username($values['user']);
    if (!$user) {
        $messageText = get_lang('NoUserAccountWithThisEmailAddress');
        if (CustomPages::enabled() && CustomPages::exists(CustomPages::LOST_PASSWORD)) {
            CustomPages::display(CustomPages::LOST_PASSWORD, ['info' => $messageText]);
            exit;
        }
        Display::addFlash(Display::return_message($messageText, 'error'));
        header('Location: ' . api_get_self());
        exit;
    }
    $passwordEncryption = api_get_configuration_value('password_encryption');
    if ($passwordEncryption === 'none') {
Example #8
0
 /**
  * @return string
  */
 public static function getWallForm($show_full_profile = true)
 {
     if ($show_full_profile) {
         $userId = isset($_GET['u']) ? '?u=' . intval($_GET['u']) : '';
         $form = new FormValidator('social_wall_main', 'post', api_get_path(WEB_CODE_PATH) . 'social/profile.php' . $userId, null, array('enctype' => 'multipart/form-data'), FormValidator::LAYOUT_HORIZONTAL);
         $socialWallPlaceholder = isset($_GET['u']) ? get_lang('SocialWallWriteNewPostToFriend') : get_lang('SocialWallWhatAreYouThinkingAbout');
         $form->addTextarea('social_wall_new_msg_main', null, ['placeholder' => $socialWallPlaceholder, 'cols-size' => [1, 10, 1]]);
         $form->addHidden('url_content', '');
         $form->addButtonSend(get_lang('Post'), 'wall_post_button', false, ['cols-size' => [1, 10, 1]]);
         $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
         return $html;
     }
 }
Example #9
0
 /**
  * @return string
  */
 public static function getWallForm()
 {
     $form = new FormValidator('social_wall_main', 'post', api_get_path(WEB_CODE_PATH) . 'social/profile.php', null, array('enctype' => 'multipart/form-data'), FormValidator::LAYOUT_HORIZONTAL);
     $form->addTextarea('social_wall_new_msg_main', null, ['placeholder' => get_lang('SocialWallWhatAreYouThinkingAbout'), 'cols-size' => [1, 10, 1]]);
     $form->addHidden('url_content', '');
     $form->addButtonSend(get_lang('Post'), 'wall_post_button', false, ['cols-size' => [1, 10, 1]]);
     $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
     return $html;
 }
$page_topic = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1;
$anchor_topic = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anchor_topic']) : null;
$url = api_get_path(WEB_CODE_PATH) . 'social/group_topics.php?id=' . $group_id . '&anchor_topic=' . $anchor_topic . '&topics_page_nr=' . $page_topic . $param_item_page;
$form = new FormValidator('form', 'post', $url, null, array('enctype' => 'multipart/form-data'));
$form->addElement('hidden', 'action', $allowed_action);
$form->addElement('hidden', 'group_id', $group_id);
$form->addElement('hidden', 'parent_id', $message_id);
$form->addElement('hidden', 'message_id', $message_id);
$form->addElement('hidden', 'token', $tok);
$tpl = new Template(get_lang('Groups'));
if (api_get_setting('allow_message_tool') == 'true') {
    // Normal message
    $user_info = api_get_user_info($userfriend_id);
    $height = 180;
    if ($allowed_action == 'add_message_group') {
        $form->addElement('text', 'title', get_lang('Title'));
        $height = 140;
    }
    $config = ['ToolbarSet' => 'Messages'];
    $form->addHtmlEditor('content', get_lang('Message'), true, false, $config);
    $form->addElement('label', null, get_lang('AttachmentFiles'));
    $form->addElement('label', null, '<div id="link-more-attach">
        <a class="btn btn-default" href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a>');
    $form->addElement('html', '<span id="filepaths"></span>');
    $form->addElement('file', 'attach_1', sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))));
    $form->addElement('html', '</div>');
    $form->addButtonSend(get_lang('SendMessage'));
    $form->setDefaults(['content' => $message, 'title' => $subject]);
    $form->display();
}
$tpl->display_blank_template();
Example #11
0
 /**
  * @return string
  */
 public static function getWallForm()
 {
     $form = new FormValidator('social_wall_main', 'post', api_get_path(WEB_CODE_PATH) . 'social/profile.php', null, array('enctype' => 'multipart/form-data'));
     $form->addTextarea('social_wall_new_msg_main', null, ['placeholder' => get_lang('SocialWallWhatAreYouThinkingAbout'), 'style' => 'width : 100%']);
     $form->addHtml('<div class="form-group "><div class="url_preview col-md-9 panel-body"></div></div>');
     $form->addButtonSend(get_lang('Post'));
     $form->addHidden('url_content', '');
     $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
     return $html;
 }
Example #12
0
/**
 * @param array $work
 * @param string $page
 * @return string
 */
function getWorkCommentForm($work, $page = 'view')
{
    $url = api_get_path(WEB_CODE_PATH) . 'work/view.php?id=' . $work['id'] . '&action=send_comment&' . api_get_cidreq() . '&page=' . $page;
    $form = new FormValidator('work_comment', 'post', $url);
    $form->addElement('file', 'file', get_lang('Attachment'));
    $form->addElement('textarea', 'comment', get_lang('Comment'), array('rows' => '8'));
    $form->addElement('hidden', 'id', $work['id']);
    $form->addElement('hidden', 'page', $page);
    if (api_is_allowed_to_edit()) {
        $form->addElement('checkbox', 'send_mail', null, get_lang('SendMail'));
    }
    $form->addButtonSend(get_lang('Send'), 'button');
    return $form->returnForm();
}
Example #13
0
 /**
  * @return string
  */
 public static function getWallForm()
 {
     $form = new FormValidator('social_wall_main', 'post', api_get_path(WEB_CODE_PATH) . 'social/profile.php', null, array('enctype' => 'multipart/form-data'));
     $form->addTextarea('social_wall_new_msg_main', null, array('placeholder' => get_lang('SocialWallWhatAreYouThinkingAbout')));
     $form->addButtonSend(get_lang('Post'));
     $html = Display::panel($form->returnForm(), get_lang('SocialWall'));
     return $html;
 }