$skillUserRepo = $entityManager->getRepository('ChamiloCoreBundle:SkillRelUser'); $user = $entityManager->find('ChamiloUserBundle:User', $_REQUEST['user']); if (!$user) { Display::addFlash(Display::return_message(get_lang('NoUser'), 'error')); header('Location: ' . api_get_path(WEB_PATH)); exit; } $skills = $skillRepo->findBy(['status' => Skill::STATUS_ENABLED]); $skillsOptions = []; foreach ($skills as $skill) { $skillsOptions[$skill->getId()] = $skill->getName(); } $form = new FormValidator('assign_skill'); $form->addText('user_name', get_lang('UserName'), false); $form->addSelect('skill', get_lang('Skill'), $skillsOptions); $form->addHidden('user', $user->getId()); $form->addRule('skill', get_lang('ThisFieldIsRequired'), 'required'); $form->addTextarea('argumentation', get_lang('Argumentation'), ['rows' => 6]); $form->applyFilter('argumentation', 'trim'); $form->addRule('argumentation', get_lang('ThisFieldIsRequired'), 'required'); $form->addButtonSave(get_lang('Save')); if ($form->validate()) { $values = $form->exportValues(); $skill = $skillRepo->find($values['skill']); if (!$skill) { Display::addFlash(Display::return_message(get_lang('SkillNotFound'), 'error')); header('Location: ' . api_get_self() . '?' . http_build_query(['user' => $user->getId()])); exit; } if ($user->hasSkill($skill)) { Display::addFlash(Display::return_message(sprintf(get_lang('TheUserXHasAlreadyAchievedTheSkillY'), $user->getCompleteName(), $skill->getName()), 'warning'));
/** * Returns the search form * @return string */ public static function getSearchForm() { $url = api_get_path(WEB_CODE_PATH) . 'group/group_overview.php?' . api_get_cidreq(); $form = new FormValidator('search_groups', 'get', $url, null, array('class' => 'form-search'), FormValidator::LAYOUT_INLINE); $form->addHidden('cidReq', api_get_course_id()); $form->addHidden('id_session', api_get_session_id()); $form->addElement('text', 'keyword'); $form->addButtonSearch(); return $form->toHtml(); }
} $social_left_content = SocialManager::show_social_menu('invite_friends', $group_id); $social_right_content = '<h2>' . Security::remove_XSS($group_info['name'], STUDENT, true) . '</h2>'; if (count($nosessionUsersList) == 0) { $friends = SocialManager::get_friends(api_get_user_id()); if ($friends == 0) { $social_right_content .= get_lang('YouNeedToHaveFriendsInYourSocialNetwork'); } else { $social_right_content .= get_lang('YouAlreadyInviteAllYourContacts'); } $social_right_content .= '<div>'; $social_right_content .= '<a href="search.php">' . get_lang('TryAndFindSomeFriends') . '</a>'; $social_right_content .= '</div>'; } $form = new FormValidator('invitation', 'post', api_get_self() . '?id=' . $group_id); $form->addHidden('form_sent', 1); $form->addHidden('id', $group_id); $group_members_element = $form->addElement('advmultiselect', 'invitation', get_lang('Friends'), $nosessionUsersList, 'style="width: 280px;"'); $form->addButtonSave(get_lang('InviteUsersToGroup')); $social_right_content .= $form->returnForm(); // Current group members $members = $usergroup->get_users_by_group($group_id, false, array(GROUP_USER_PERMISSION_PENDING_INVITATION)); if (is_array($members) && count($members) > 0) { foreach ($members as &$member) { $image = UserManager::getUserPicture($member['user_id']); $member['image'] = '<img src="' . $image . '" width="50px" height="50px" />'; } $social_right_content .= '<h3>' . get_lang('UsersAlreadyInvited') . '</h3>'; $social_right_content .= Display::return_sortable_grid('invitation_profile', array(), $members, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, false, true, true)); } $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig();
break; 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']) . " " . 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);
/** * @param int $filter * @param string $view * @return string */ public function displayActions($view, $filter = 0) { $courseInfo = api_get_course_info(); $actionsLeft = ''; $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_js.php?type={$this->type}'>" . Display::return_icon('calendar.png', get_lang('Calendar'), '', ICON_SIZE_MEDIUM) . "</a>"; $courseCondition = ''; if (!empty($courseInfo)) { $courseCondition = api_get_cidreq(); } $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_list.php?type={$this->type}&" . $courseCondition . "'>" . Display::return_icon('week.png', get_lang('AgendaList'), '', ICON_SIZE_MEDIUM) . "</a>"; $form = ''; if (api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false, true) || GroupManager::user_has_access(api_get_user_id(), api_get_group_id(), GroupManager::GROUP_TOOL_CALENDAR) && GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id())) { $actionsLeft .= Display::url(Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=add&type=" . $this->type); $actionsLeft .= Display::url(Display::return_icon('import_calendar.png', get_lang('ICalFileImport'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=importical&type=" . $this->type); if ($this->type == 'course') { if (!isset($_GET['action'])) { $form = new FormValidator('form-search', 'post', '', '', array(), FormValidator::LAYOUT_INLINE); $attributes = array('multiple' => false, 'id' => 'select_form_id_search'); $selectedValues = $this->parseAgendaFilter($filter); $this->showToForm($form, $selectedValues, $attributes); $form = $form->returnForm(); } } } if (api_is_platform_admin() || api_is_teacher() || api_is_student_boss() || api_is_drh() || api_is_session_admin() || api_is_coach()) { if ($this->type == 'personal') { $form = null; if (!isset($_GET['action'])) { $form = new FormValidator('form-search', 'get', api_get_self() . '?type=personal&', '', array(), FormValidator::LAYOUT_INLINE); $sessions = SessionManager::get_sessions_by_user(api_get_user_id()); $form->addHidden('type', 'personal'); $sessions = array_column($sessions, 'session_name', 'session_id'); $sessions = ['0' => get_lang('SelectAnOption')] + $sessions; $form->addSelect('session_id', get_lang('Session'), $sessions, ['id' => 'session_id', 'onchange' => 'submit();']); //$form->addButtonFilter(get_lang('Filter')); //$renderer = $form->defaultRenderer(); //$renderer->setCustomElementTemplate('<div class="col-md-6">{element}</div>'); $form->addButtonReset(get_lang('Reset')); $form = $form->returnForm(); } } } $actionsRight = ''; if ($view == 'calendar') { $actionsRight .= $form; } $toolbar = Display::toolbarAction('toolbar-agenda', array(0 => $actionsLeft, 1 => $actionsRight), 2, false); return $toolbar; }
} $form->applyFilter('openid', 'trim'); }*/ // PHONE $form->addElement('text', 'phone', get_lang('Phone'), array('size' => 20)); if (api_get_setting('profile', 'phone') !== 'true') { $form->freeze('phone'); } $form->applyFilter('phone', 'stripslashes'); $form->applyFilter('phone', 'trim'); $form->applyFilter('phone', 'html_filter'); // PICTURE if (is_profile_editable() && api_get_setting('profile', 'picture') == 'true') { $form->addElement('file', 'picture', $user_data['picture_uri'] != '' ? get_lang('UpdateImage') : get_lang('AddImage'), array('id' => 'picture_form', 'class' => 'picture-form')); $form->addHtml('' . '<div class="form-group">' . '<label for="cropImage" id="labelCropImage" class="col-sm-2 control-label"></label>' . '<div class="col-sm-8">' . '<div id="cropImage" class="cropCanvas">' . '<img id="previewImage" >' . '</div>' . '<div>' . '<button class="btn btn-primary hidden" name="cropButton" id="cropButton"><em class="fa fa-crop"></em> ' . get_lang('CropYourPicture') . '</button>' . '</div>' . '</div>' . '</div>' . ''); $form->addHidden('cropResult', ''); $form->add_progress_bar(); if (!empty($user_data['picture_uri'])) { $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage')); } $allowed_picture_types = api_get_supported_image_extensions(); $form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(', ', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types); } // LANGUAGE $form->addElement('select_language', 'language', get_lang('Language')); if (api_get_setting('profile', 'language') !== 'true') { $form->freeze('language'); } //THEME if (is_profile_editable() && api_get_setting('profile.user_selected_theme') == 'true') { $form->addElement('SelectTheme', 'theme', get_lang('Theme'));
$sequence = new Sequence(); $sequence->setName($values['name']); $em->persist($sequence); $em->flush(); header('Location: ' . api_get_self()); exit; } $selectSequence = new FormValidator(''); $selectSequence->addHidden('sequence_type', 'session'); $em = Database::getManager(); $sequenceList = $em->getRepository('ChamiloCoreBundle:Sequence')->findAll(); $selectSequence->addSelect('sequence', get_lang('Sequence'), $sequenceList, ['id' => 'sequence_id', 'cols-size' => [3, 7, 2]]); $form = new FormValidator(''); $form->addHtml("<div class='col-md-6'>"); $form->addHidden('sequence_type', 'session'); $form->addSelect('sessions', get_lang('Sessions'), $sessionList, ['id' => 'item', 'cols-size' => [4, 7, 1]]); $form->addButtonNext(get_lang('UseAsReference'), 'use_as_reference', ['cols-size' => [4, 7, 1]]); $form->addHtml("</div>"); $form->addHtml("<div class='col-md-6'>"); $form->addSelect('requirements', get_lang('Requirements'), $sessionList, ['id' => 'requirements', 'cols-size' => [3, 7, 2]]); $form->addButtonCreate(get_lang('SetAsRequirement'), 'set_requirement', false, ['cols-size' => [3, 7, 2]]); $form->addHtml("</div>"); $formSave = new FormValidator(''); $formSave->addHidden('sequence_type', 'session'); $formSave->addButton('save_resource', get_lang('SaveSettings'), 'floppy-o', 'success', null, null, ['cols-size' => [1, 10, 1]]); $tpl->assign('create_sequence', $formSequence->returnForm()); $tpl->assign('select_sequence', $selectSequence->returnForm()); $tpl->assign('configure_sequence', $form->returnForm()); $tpl->assign('save_sequence', $formSave->returnForm()); $layout = $tpl->get_template('admin/resource_sequence.tpl'); $tpl->display($layout);
continue; } $skillList[$skill['id']] = $skill['name']; } foreach ($allGradebooks as $gradebook) { $gradebookList[$gradebook['id']] = $gradebook['name']; } /* Form */ $editForm = new FormValidator('skill_edit'); $editForm->addHeader(get_lang('SkillEdit')); $editForm->addText('name', get_lang('Name'), true, ['id' => 'name']); $editForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']); $editForm->addSelect('parent_id', get_lang('Parent'), $skillList, ['id' => 'parent_id']); $editForm->addSelect('gradebook_id', [get_lang('Gradebook'), get_lang('WithCertificate')], $gradebookList, ['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]); $editForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]); $editForm->addButtonSave(get_lang('Save')); $editForm->addHidden('id', null); $editForm->setDefaults($skillDefaultInfo); if ($editForm->validate()) { $updated = $objSkill->edit($editForm->getSubmitValues()); if ($updated) { Session::write('message', Display::return_message(get_lang('TheSkillHasBeenUpdated'), 'success')); } else { Session::write('message', Display::return_message(get_lang('CannotUpdateSkill'), 'error')); } Header::location(api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php'); } /* view */ $tpl = new Template(get_lang('SkillEdit')); $tpl->assign('content', $editForm->returnForm()); $tpl->display_one_col_template();
/** * @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; }
/** * Return HTML form to add/edit a student publication (work) * @param string Action (add/edit) * @param integer Item ID if already exists * @param mixed Extra info (work ID if integer) * @return string HTML form */ public function display_student_publication_form($action = 'add', $id = 0, $extra_info = '') { $course_id = api_get_course_int_id(); $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM); $tbl_publication = Database::get_course_table(TABLE_STUDENT_PUBLICATION); if ($id != 0 && is_array($extra_info)) { $item_title = stripslashes($extra_info['title']); $item_description = stripslashes($extra_info['description']); } elseif (is_numeric($extra_info)) { $extra_info = intval($extra_info); $sql = "SELECT title, description\n FROM " . $tbl_publication . "\n WHERE c_id = " . $course_id . " AND id = " . $extra_info; $result = Database::query($sql); $row = Database::fetch_array($result); $item_title = $row['title']; } else { $item_title = get_lang('Student_publication'); } if ($id != 0 && is_array($extra_info)) { $parent = $extra_info['parent_item_id']; } else { $parent = 0; } $sql = "SELECT * FROM " . $tbl_lp_item . "\n WHERE c_id = " . $course_id . " AND lp_id = " . $this->lp_id; $result = Database::query($sql); $arrLP = array(); while ($row = Database::fetch_array($result)) { $arrLP[] = array('id' => $row['id'], 'item_type' => $row['item_type'], 'title' => $row['title'], 'path' => $row['path'], 'description' => $row['description'], 'parent_item_id' => $row['parent_item_id'], 'previous_item_id' => $row['previous_item_id'], 'next_item_id' => $row['next_item_id'], 'display_order' => $row['display_order'], 'max_score' => $row['max_score'], 'min_score' => $row['min_score'], 'mastery_score' => $row['mastery_score'], 'prerequisite' => $row['prerequisite']); } $this->tree_array($arrLP); $arrLP = isset($this->arrMenu) ? $this->arrMenu : null; unset($this->arrMenu); $form = new FormValidator('frm_student_publication', 'post', '#'); if ($action == 'add') { $form->addHeader(get_lang('Student_publication')); } elseif ($action == 'move') { $form->addHeader(get_lang('MoveCurrentStudentPublication')); } else { $form->addHeader(get_lang('EditCurrentStudentPublication')); } if ($action != 'move') { $form->addText('title', get_lang('Title'), true, ['class' => 'learnpath_item_form', 'id' => 'idTitle']); } $parentSelect = $form->addSelect('parent', get_lang('Parent'), ['0' => $this->name], ['onchange' => 'javascript: load_cbo(this.value);', 'class' => 'learnpath_item_form', 'id' => 'idParent']); $arrHide = array($id); for ($i = 0; $i < count($arrLP); $i++) { if ($action != 'add') { if (($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') && !in_array($arrLP[$i]['id'], $arrHide) && !in_array($arrLP[$i]['parent_item_id'], $arrHide)) { $parentSelect->addOption($arrLP[$i]['title'], $arrLP[$i]['id'], ['style' => 'padding-left: ' . ($arrLP[$i]['depth'] * 10 + 20) . 'px;']); if ($parent == $arrLP[$i]['id']) { $parentSelect->setSelected($arrLP[$i]['id']); } } else { $arrHide[] = $arrLP[$i]['id']; } } else { if ($arrLP[$i]['item_type'] == 'dokeos_module' || $arrLP[$i]['item_type'] == 'dokeos_chapter' || $arrLP[$i]['item_type'] == 'dir') { $parentSelect->addOption($arrLP[$i]['title'], $arrLP[$i]['id'], ['style' => 'padding-left: ' . ($arrLP[$i]['depth'] * 10 + 20) . 'px;']); if ($parent == $arrLP[$i]['id']) { $parentSelect->setSelected($arrLP[$i]['id']); } } } } if (is_array($arrLP)) { reset($arrLP); } $previousSelect = $form->addSelect('previous', get_lang('Position'), ['0' => get_lang('FirstPosition')], ['id' => 'previous', 'class' => 'learnpath_item_form']); for ($i = 0; $i < count($arrLP); $i++) { if ($arrLP[$i]['parent_item_id'] == $parent && $arrLP[$i]['id'] != $id) { $previousSelect->addOption(get_lang('After') . ' "' . $arrLP[$i]['title'] . '"', $arrLP[$i]['id']); if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { $previousSelect->setSelected($arrLP[$i]['id']); } elseif ($action == 'add') { $previousSelect->setSelected($arrLP[$i]['id']); } } } if ($action != 'move') { $id_prerequisite = 0; if (is_array($arrLP)) { foreach ($arrLP as $key => $value) { if ($value['id'] == $id) { $id_prerequisite = $value['prerequisite']; break; } } } $arrHide = array(); for ($i = 0; $i < count($arrLP); $i++) { if ($arrLP[$i]['id'] != $id && $arrLP[$i]['item_type'] != 'dokeos_chapter') { if ($extra_info['previous_item_id'] == $arrLP[$i]['id']) { $s_selected_position = $arrLP[$i]['id']; } elseif ($action == 'add') { $s_selected_position = 0; } $arrHide[$arrLP[$i]['id']]['value'] = $arrLP[$i]['title']; } } } if ($action == 'add') { $form->addButtonCreate(get_lang('AddAssignmentToCourse'), 'submit_button'); } else { $form->addButtonCreate(get_lang('EditCurrentStudentPublication'), 'submit_button'); } if ($action == 'move') { $form->addHidden('title', $item_title); $form->addHidden('description', $item_description); } if (is_numeric($extra_info)) { $form->addHidden('path', $extra_info); } elseif (is_array($extra_info)) { $form->addHidden('path', $extra_info['path']); } $form->addHidden('type', TOOL_STUDENTPUBLICATION); $form->addHidden('post_time', time()); $form->setDefaults(['title' => $item_title]); $return = '<div class="sectioncomment">'; $return .= $form->returnForm(); $return .= '</div>'; return $return; }
$currentUser = $entityManager->find('ChamiloUserBundle:User', $currentUserId); $allowExport = $currentUser ? $currentUser->getId() === $skillIssue->getUser()->getId() : false; $allowComment = $currentUser ? Skill::userCanAddFeedbackToUser($currentUser, $skillIssue->getUser()) : false; $skillIssueDate = api_get_local_time($skillIssue->getAcquiredSkillAt()); $skillIssueInfo = ['id' => $skillIssue->getId(), 'datetime' => api_format_date($skillIssueDate, DATE_TIME_FORMAT_SHORT), 'argumentation' => $skillIssue->getArgumentation(), 'source_name' => $skillIssue->getSourceName(), 'user_id' => $skillIssue->getUser()->getId(), 'user_complete_name' => $skillIssue->getUser()->getCompleteName(), 'skill_badge_image' => $skillIssue->getSkill()->getWebIconPath(), 'skill_name' => $skillIssue->getSkill()->getName(), 'skill_short_code' => $skillIssue->getSkill()->getShortCode(), 'skill_description' => $skillIssue->getSkill()->getDescription(), 'skill_criteria' => $skillIssue->getSkill()->getCriteria(), 'badge_asserion' => [$skillIssue->getAssertionUrl()], 'comments' => [], 'feedback_average' => $skillIssue->getAverage()]; $skillIssueComments = $skillIssue->getComments(true); foreach ($skillIssueComments as $comment) { $commentDate = api_get_local_time($comment->getFeedbackDateTime()); $skillIssueInfo['comments'][] = ['text' => $comment->getFeedbackText(), 'value' => $comment->getFeedbackValue(), 'giver_complete_name' => $comment->getFeedbackGiver()->getCompleteName(), 'datetime' => api_format_date($commentDate, DATE_TIME_FORMAT_SHORT)]; } $form = new FormValidator('comment'); $form->addTextarea('comment', get_lang('NewComment'), ['rows' => 4]); $form->applyFilter('comment', 'trim'); $form->addRule('comment', get_lang('ThisFieldIsRequired'), 'required'); $form->addSelect('value', [get_lang('Value'), get_lang('RateTheSkillInPractice')], ['-', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); $form->addHidden('user', $skillIssue->getUser()->getId()); $form->addHidden('issue', $skillIssue->getId()); $form->addButtonSend(get_lang('Send')); if ($form->validate() && $allowComment) { $values = $form->exportValues(); $skillUserComment = new Chamilo\CoreBundle\Entity\SkillRelUserComment(); $skillUserComment->setFeedbackDateTime(new DateTime())->setFeedbackGiver($currentUser)->setFeedbackText($values['comment'])->setFeedbackValue($values['value'] ? $values['value'] : null)->setSkillRelUser($skillIssue); $entityManager->persist($skillUserComment); $entityManager->flush(); header("Location: " . $skillIssue->getIssueUrl()); exit; } if ($allowExport) { $backpack = 'https://backpack.openbadges.org/'; $configBackpack = api_get_setting('openbadges_backpack'); if (strcmp($backpack, $configBackpack) !== 0) {
} // Displaying the form with the questions if (isset($_POST['personality'])) { $personality = (int) $_POST['personality'] + 1; } else { $personality = 0; } // Displaying the form with the questions $g_c = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : ''; $g_ic = isset($_GET['invitationcode']) ? Security::remove_XSS($_GET['invitationcode']) : ''; $g_cr = isset($_GET['cidReq']) ? Security::remove_XSS($_GET['cidReq']) : ''; $p_l = isset($_POST['language']) ? Security::remove_XSS($_POST['language']) : ''; $add_parameters = isset($_GET['user_id']) ? 'user_id=' . $_GET['user_id'] . '&' : ''; $url = api_get_self() . '?' . $add_parameters . 'course=' . $g_c . '&invitationcode=' . $g_ic . '&show=' . $show . '&cidReq=' . $g_cr; $form = new FormValidator('question', 'post', $url); $form->addHidden('language', $p_l); if (isset($questions) && is_array($questions)) { foreach ($questions as $key => &$question) { $ch_type = 'ch_' . $question['type']; $display = new $ch_type(); // @todo move this in a function. $form->addHtml('<div class="survey_question_wrapper"><div class="survey_question">'); $form->addHtml($question['survey_question']); $display->render($form, $question); $form->addHtml('</div></div>'); } } if ($survey_data['survey_type'] === '0') { if ($survey_data['show_form_profile'] == 0) { // The normal survey as always if ($show < $numberofpages || !$_GET['show']) {
/** * @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; }
/** * Builds the form thats enables the user to * move a document from one directory to another * This function has been copied from the document/document.inc.php library * * @param array $folders * @param string $curdirpath * @param string $move_file * @param string $group_dir * @return string html form */ function build_work_move_to_selector($folders, $curdirpath, $move_file, $group_dir = '') { $course_id = api_get_course_int_id(); $move_file = intval($move_file); $tbl_work = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $sql = "SELECT title, url FROM {$tbl_work}\n WHERE c_id = {$course_id} AND id ='" . $move_file . "'"; $result = Database::query($sql); $row = Database::fetch_array($result, 'ASSOC'); $title = empty($row['title']) ? basename($row['url']) : $row['title']; $form = new FormValidator('move_to_form', 'post', api_get_self() . '?' . api_get_cidreq() . '&curdirpath=' . Security::remove_XSS($curdirpath)); $form->addHeader(get_lang('MoveFile') . ' - ' . Security::remove_XSS($title)); $form->addHidden('item_id', $move_file); $form->addHidden('action', 'move_to'); //group documents cannot be uploaded in the root if ($group_dir == '') { if ($curdirpath != '/') { //$form .= '<option value="0">/ ('.get_lang('Root').')</option>'; } if (is_array($folders)) { foreach ($folders as $fid => $folder) { //you cannot move a file to: //1. current directory //2. inside the folder you want to move //3. inside a subfolder of the folder you want to move if ($curdirpath != $folder && $folder != $move_file && substr($folder, 0, strlen($move_file) + 1) != $move_file . '/') { //$form .= '<option value="'.$fid.'">'.$folder.'</option>'; $options[$fid] = $folder; } } } } else { if ($curdirpath != '/') { $form .= '<option value="0">/ (' . get_lang('Root') . ')</option>'; } foreach ($folders as $fid => $folder) { if ($curdirpath != $folder && $folder != $move_file && substr($folder, 0, strlen($move_file) + 1) != $move_file . '/') { //cannot copy dir into his own subdir $display_folder = substr($folder, strlen($group_dir)); $display_folder = $display_folder == '' ? '/ (' . get_lang('Root') . ')' : $display_folder; //$form .= '<option value="'.$fid.'">'.$display_folder.'</option>'."\n"; $options[$fid] = $display_folder; } } } $form->addSelect('move_to_id', get_lang('Select'), $options); $form->addButtonSend(get_lang('MoveFile'), 'move_file_submit'); return $form->returnForm(); }
echo '<div class="row">'; echo '<div class="col-md-6">'; echo $icon; $actions .= '<a href="user.php?' . api_get_cidreq() . '&action=export&format=csv&type=' . $type . '">' . Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM) . '</a> '; $actions .= '<a href="user.php?' . api_get_cidreq() . '&action=export&format=xls&type=' . $type . '">' . Display::return_icon('export_excel.png', get_lang('ExportAsXLS'), '', ICON_SIZE_MEDIUM) . '</a> '; if (api_get_setting('course.allow_user_course_subscription_by_course_admin') == 'true' || api_is_platform_admin()) { $actions .= '<a href="user_import.php?' . api_get_cidreq() . '&action=import">' . Display::return_icon('import_csv.png', get_lang('ImportUsersToACourse'), '', ICON_SIZE_MEDIUM) . '</a> '; } $actions .= '<a href="user.php?' . api_get_cidreq() . '&action=export&format=pdf&type=' . $type . '">' . Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM) . '</a> '; echo $actions; echo '</div>'; echo '<div class="col-md-6">'; echo '<div class="pull-right">'; // Build search-form $form = new FormValidator('search_user', 'get', api_get_self() . '?' . api_get_cidreq(), '', null, FormValidator::LAYOUT_INLINE); $form->addHidden('cidReq', api_get_course_id()); $form->addHidden('id_session', api_get_session_id()); $form->addText('keyword', '', false); $form->addButtonSearch(get_lang('SearchButton')); $form->display(); echo '</div>'; echo '</div>'; echo '</div>'; $allowTutors = api_get_setting('session.allow_tutors_to_assign_students_to_session'); if (api_is_allowed_to_edit() && $allowTutors == 'true') { $actions .= ' <a class="btn btn-default" href="session_list.php?' . api_get_cidreq() . '">' . get_lang('Sessions') . '</a>'; } echo '</div>'; } echo UserManager::getUserSubscriptionTab($selectedTab); $table->display();
Export::arrayToXml($listToExport, $archiveFile); break; case 'csv': Export::arrayToCsv($listToExport, $archiveFile); case 'xls': Export::arrayToXls($listToExport, $archiveFile); break; } } else { Display::addFlash(Display::return_message(get_lang('ThereAreNotSelectedCoursesOrCoursesListIsEmpty'))); } } Display::display_header($tool_name); $form = new FormValidator('export', 'post', api_get_self()); $form->addHeader($tool_name); $form->addHidden('formSent', 1); $form->addElement('radio', 'select_type', get_lang('Option'), get_lang('ExportAllCoursesList'), '1', ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='none';}"]); $form->addElement('radio', 'select_type', '', get_lang('ExportSelectedCoursesFromCoursesList'), '2', ['onclick' => "javascript: if(this.checked){document.getElementById('div-course-list').style.display='block';}"]); if (!empty($course_list)) { $form->addHtml('<div id="div-course-list" style="display:none">'); $coursesInList = []; foreach ($course_list as $course) { $coursesInList[$course['code']] = $course['title'] . ' (' . $course['code'] . ')'; } $form->addSelect('course_code', get_lang('WhichCoursesToExport'), $coursesInList, ['multiple' => 'multiple']); $form->addHtml('</div>'); } $form->addElement('radio', 'file_type', get_lang('OutputFileType'), 'CSV', 'csv', null); $form->addElement('radio', 'file_type', '', 'XLS', 'xls', null); $form->addElement('radio', 'file_type', null, 'XML', 'xml', null, array('id' => 'file_type_xml')); $form->setDefaults(['select_type' => '1', 'file_type' => 'csv']);
public static function displayTrackingAccessOverView($courseId, $sessionId, $studentId) { $courseId = intval($courseId); $sessionId = intval($sessionId); $studentId = intval($studentId); $em = Database::getManager(); $sessionRepo = $em->getRepository('ChamiloCoreBundle:Session'); $courseList = []; $sessionList = []; $studentList = []; if (!empty($courseId)) { $course = $em->find('ChamiloCoreBundle:Course', $courseId); $courseList[$course->getId()] = $course->getTitle(); } if (!empty($sessionId)) { $session = $em->find('ChamiloCoreBundle:Session', $sessionId); $sessionList[$session->getId()] = $session->getName(); } if (!empty($studentId)) { $student = $em->find('ChamiloUserBundle:User', $studentId); $studentList[$student->getId()] = $student->getCompleteName(); } $form = new FormValidator('access_overview', 'GET'); $form->addElement('select_ajax', 'course_id', get_lang('SearchCourse'), $courseList, ['url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?' . http_build_query(['a' => 'search_course_by_session_all', 'session_id' => $sessionId])]); $form->addElement('select_ajax', 'session_id', get_lang('SearchSession'), $sessionList, ['url_function' => "\n function () {\n var params = \$.param({\n a: 'search_session_by_course',\n course_id: \$('#course_id').val() || 0\n });\n\n return '" . api_get_path(WEB_AJAX_PATH) . "session.ajax.php?' + params;\n }\n "]); $form->addSelect('profile', get_lang('Profile'), ['' => get_lang('Select'), STUDENT => get_lang('Student'), COURSEMANAGER => get_lang('CourseManager'), DRH => get_lang('Drh')], ['id' => 'profile']); $form->addElement('select_ajax', 'student_id', get_lang('SearchUsers'), $studentList, ['placeholder' => get_lang('All'), 'url_function' => "\n function () {\n var params = \$.param({\n a: 'search_user_by_course',\n session_id: \$('#session_id').val(),\n course_id: \$('#course_id').val()\n });\n\n return '" . api_get_path(WEB_AJAX_PATH) . "course.ajax.php?' + params;\n }\n "]); $form->addDateRangePicker('date', get_lang('DateRange'), true, ['id' => 'date_range', 'format' => 'YYYY-MM-DD', 'timePicker' => 'false', 'validate_format' => 'Y-m-d']); $form->addHidden('display', 'accessoverview'); $form->addRule('course_id', get_lang('Required'), 'required'); $form->addRule('profile', get_lang('Required'), 'required'); $form->addButton('submit', get_lang('Generate'), 'gear', 'primary'); $table = null; if ($form->validate()) { $table = new SortableTable('tracking_access_overview', ['MySpace', 'getNumberOfRrackingAccessOverview'], ['MySpace', 'getUserDataAccessTrackingOverview'], 0); $table->additional_parameters = $form->exportValues(); $table->set_header(0, get_lang('LoginDate'), true); $table->set_header(1, get_lang('Username'), true); if (api_is_western_name_order()) { $table->set_header(2, get_lang('FirstName'), true); $table->set_header(3, get_lang('LastName'), true); } else { $table->set_header(2, get_lang('LastName'), true); $table->set_header(3, get_lang('FirstName'), true); } $table->set_header(4, get_lang('Clicks'), false); $table->set_header(5, get_lang('IP'), false); $table->set_header(6, get_lang('TimeLoggedIn'), false); } $template = new Template(null, false, false, false, false, false, false); $template->assign('form', $form->returnForm()); $template->assign('table', $table ? $table->return_table() : null); echo $template->fetch($template->get_template('my_space/accessoverview.tpl')); }
/** * Generic part of any survey question: the question field * @param array $surveyData * @param array $formData * * @return FormValidator */ public function createForm($surveyData, $formData) { $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null; $questionId = isset($_GET['question_id']) ? intval($_GET['question_id']) : null; $surveyId = isset($_GET['survey_id']) ? intval($_GET['survey_id']) : null; $toolName = Display::return_icon(SurveyManager::icon_question(Security::remove_XSS($_GET['type'])), get_lang(ucfirst(Security::remove_XSS($_GET['type']))), array('align' => 'middle', 'height' => '22px')) . ' '; if ($action == 'add') { $toolName .= get_lang('AddQuestion'); } if ($action == 'edit') { $toolName .= get_lang('EditQuestion'); } if ($_GET['type'] == 'yesno') { $toolName .= ': ' . get_lang('YesNo'); } else { if ($_GET['type'] == 'multiplechoice') { $toolName .= ': ' . get_lang('UniqueSelect'); } else { $toolName .= ': ' . get_lang(api_ucfirst(Security::remove_XSS($_GET['type']))); } } $sharedQuestionId = isset($formData['shared_question_id']) ? $formData['shared_question_id'] : null; $url = api_get_self() . '?action=' . $action . '&type=' . Security::remove_XSS($_GET['type']) . '&survey_id=' . $surveyId . '&question_id=' . $questionId . '&' . api_get_cidreq(); $form = new FormValidator('question_form', 'post', $url); $form->addHeader($toolName); $form->addHidden('survey_id', $surveyId); $form->addHidden('question_id', $questionId); $form->addHidden('shared_question_id', Security::remove_XSS($sharedQuestionId)); $form->addHidden('type', Security::remove_XSS($_GET['type'])); $config = array('ToolbarSet' => 'SurveyQuestion', 'Width' => '100%', 'Height' => '120'); $form->addHtmlEditor('question', get_lang('Question'), true, false, $config); // When survey type = 1?? if ($surveyData['survey_type'] == 1) { $table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP); $sql = 'SELECT id,name FROM ' . $table_survey_question_group . ' WHERE survey_id = ' . (int) $_GET['survey_id'] . ' ORDER BY name'; $rs = Database::query($sql); $glist = null; while ($row = Database::fetch_array($rs, 'NUM')) { $glist .= '<option value="' . $row[0] . '" >' . $row[1] . '</option>'; } $grouplist = $grouplist1 = $grouplist2 = $glist; if (!empty($formData['assigned'])) { $grouplist = str_replace('<option value="' . $formData['assigned'] . '"', '<option value="' . $formData['assigned'] . '" selected', $glist); } if (!empty($formData['assigned1'])) { $grouplist1 = str_replace('<option value="' . $formData['assigned1'] . '"', '<option value="' . $formData['assigned1'] . '" selected', $glist); } if (!empty($formData['assigned2'])) { $grouplist2 = str_replace('<option value="' . $formData['assigned2'] . '"', '<option value="' . $formData['assigned2'] . '" selected', $glist); } $this->html .= ' <tr><td colspan=""> <fieldset style="border:1px solid black"><legend>' . get_lang('Condition') . '</legend> <b>' . get_lang('Primary') . '</b><br /> ' . '<input type="radio" name="choose" value="1" ' . ($formData['choose'] == 1 ? 'checked' : '') . '><select name="assigned">' . $grouplist . '</select><br />'; $this->html .= ' <b>' . get_lang('Secondary') . '</b><br /> ' . '<input type="radio" name="choose" value="2" ' . ($formData['choose'] == 2 ? 'checked' : '') . '><select name="assigned1">' . $grouplist1 . '</select> ' . '<select name="assigned2">' . $grouplist2 . '</select>' . '</fieldset><br />'; //$form->addRadio('choose', get_lang('Primary')); //$form->addRadio('choose', get_lang('Secondary')); } $this->setForm($form); return $form; }
$tpl = Container::getTwig(); $load_user = 0; if (isset($_GET['load_user'])) { $load_user = 1; } $skill_condition = ''; $tpl->addGlobal('skill_id_to_load', ''); if (isset($_GET['skill_id'])) { $skillId = intval($_GET['skill_id']); $skill_condition = '&skill_id=' . $skillId; $tpl->addGlobal('skill_id_to_load', $skillId); } $url = api_get_path(WEB_AJAX_PATH) . "skill.ajax.php?a=get_skills_tree_json&load_user={$load_user}"; $tpl->addGlobal('wheel_url', $url); $url = api_get_path(WEB_AJAX_PATH) . 'skill.ajax.php?1=1'; $tpl->addGlobal('url', $url); $tpl->addGlobal('isAdministration', true); $dialogForm = new FormValidator('form', 'post', null, null, ['id' => 'add_item']); $dialogForm->addLabel(get_lang('Name'), Display::tag('p', null, ['id' => 'name', 'class' => 'form-control-static'])); $dialogForm->addLabel(get_lang('ShortCode'), Display::tag('p', null, ['id' => 'short_code', 'class' => 'form-control-static'])); $dialogForm->addLabel(get_lang('Parent'), Display::tag('p', null, ['id' => 'parent', 'class' => 'form-control-static'])); $dialogForm->addLabel([get_lang('Gradebook'), get_lang('WithCertificate')], Display::tag('ul', null, ['id' => 'gradebook', 'class' => 'form-control-static list-unstyled'])); $dialogForm->addLabel(get_lang('Description'), Display::tag('p', null, ['id' => 'description', 'class' => 'form-control-static'])); $tpl->addGlobal('dialogForm', $dialogForm->returnForm()); $saveProfileForm = new FormValidator('form', 'post', null, null, ['id' => 'dialog-form-profile']); $saveProfileForm->addHidden('profile_id', null); $saveProfileForm->addText('name', get_lang('Name'), true, ['id' => 'name_profile']); $saveProfileForm->addTextarea('description', get_lang('Description'), ['id' => 'description_profile', 'rows' => 6]); $tpl->addGlobal('saveProfileForm', $saveProfileForm->returnForm()); echo $tpl->render('@template_style/skill/skill_wheel.html.twig'); Container::$legacyTemplate = 'layout_one_col_no_content.html.twig';
$pdfContent = Export::convert_array_to_html($dataToExport); Export::export_html_to_pdf($pdfContent, $params); break; case 'xls': array_unshift($dataToExport, array($reportTitle), array($reportSubTitle), array()); Export::export_table_xls_html($dataToExport, $fileName); break; } die; } $form->addSelect('course', get_lang('Course'), $optionsCourses, ['id' => 'courses']); $form->addSelect('session', get_lang('Session'), $optionsSessions, ['id' => 'session']); $form->addSelect('teacher', get_lang('Teacher'), $optionsTeachers, ['id' => 'teacher']); $form->addDateRangePicker('daterange', get_lang('Date'), false, ['id' => 'daterange', 'maxDate' => $limitDate->format('Y-m-d'), 'format' => 'YYYY-MM-DD', 'timePicker' => 'false', 'value' => "{$selectedFrom} / {$selectedUntil}"]); $form->addButtonFilter(get_lang('Filter')); $form->addHidden('from', ''); $form->addHidden('until', ''); $form->setDefaults(['course' => $selectedCourse, 'session' => $selectedSession, 'teacher' => $selectedTeacher, 'date_range' => "{$selectedFrom} / {$selectedUntil}", 'from' => $selectedFrom, 'until' => $selectedUntil]); $tpl = new Template($toolName); $tpl->assign('reportTitle', $reportTitle); $tpl->assign('reportSubTitle', $reportSubTitle); $tpl->assign('selectedCourse', $selectedCourse); $tpl->assign('selectedSession', $selectedSession); $tpl->assign('selectedTeacher', $selectedTeacher); $tpl->assign('selectedFrom', $selectedFrom); $tpl->assign('selectedUntil', $selectedUntil); $tpl->assign('withFilter', $withFilter); $tpl->assign('courses', $courseList); $tpl->assign('sessions', $sessionsList); $tpl->assign('courseCoaches', $teacherList); $tpl->assign('form', $form->returnForm());
<?php /* For license terms, see /license.txt */ use ChamiloSession as Session; //require_once '../inc/global.inc.php'; $token = isset($_GET['token']) ? $_GET['token'] : ''; if (!ctype_alnum($token)) { $token = ''; } $tpl = new Template(null); // Build the form $form = new FormValidator('reset', 'POST', api_get_self() . '?token=' . $token); $form->addElement('header', get_lang('ResetPassword')); $form->addHidden('token', $token); $form->addElement('password', 'pass1', get_lang('Password')); $form->addElement('password', 'pass2', get_lang('Confirmation'), array('id' => 'pass2', 'size' => 20, 'autocomplete' => 'off')); $form->addRule('pass1', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('pass2', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule(array('pass1', 'pass2'), get_lang('PassTwo'), 'compare'); $form->addButtonSave(get_lang('Update')); $ttl = api_get_setting('user_reset_password_token_limit'); if (empty($ttl)) { $ttl = 3600; } if ($form->validate()) { $em = Database::getManager(); $values = $form->exportValues(); $password = $values['pass1']; $token = $values['token']; /** @var \Chamilo\UserBundle\Entity\User $user */ $user = UserManager::getManager()->findUserByConfirmationToken($token);
<?php /* For licensing terms, see /license.txt */ /** * View (MVC patter) for creating course category * @author Christian Fasanando <*****@*****.**> - Beeznest * @package chamilo.auth */ // Acces rights: anonymous users can't do anything usefull here. api_block_anonymous_users(); $stok = Security::get_token(); ?> <!-- Actions: The menu with the different options in cathe course management --> <div id="actions" class="actions"> <a href="<?php echo api_get_self(); ?> ?action=sortmycourses"> <?php echo Display::return_icon('back.png', get_lang('Back'), '', '32'); ?> </a> </div> <?php $form = new FormValidator('create_course_category', 'post', api_get_self() . '?createcoursecategory'); $form->addHidden('sec_token', $stok); $form->addText('title_course_category', get_lang('Name')); $form->addButtonSave(get_lang('AddCategory'), 'create_course_category'); $form->display();
/** * Add elements to a form * * @param FormValidator $form * @param int $itemId * @param array $exclude variables of extra field to exclude * @return array|bool */ public function addElements($form, $itemId = 0, $exclude = []) { if (empty($form)) { return false; } $itemId = intval($itemId); $form->addHidden('item_id', $itemId); $extraData = false; if (!empty($itemId)) { $extraData = self::get_handler_extra_data($itemId); if ($form) { $form->setDefaults($extraData); } } $extraFields = $this->get_all(null, 'option_order'); $extra = $this->set_extra_fields_in_form($form, $extraData, false, $extraFields, $itemId, $exclude); return $extra; }
/** * @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; } }
/** * Displays the form to create a new post * @author Toon Keppens * * @param Integer $blog_id */ public static function display_new_comment_form($blog_id, $post_id, $title) { $form = new FormValidator('add_post', 'post', api_get_path(WEB_CODE_PATH) . "blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=" . intval($post_id) . "&" . api_get_cidreq(), null, array('enctype' => 'multipart/form-data')); $header = get_lang('AddNewComment'); if (isset($_GET['task_id'])) { $header = get_lang('ExecuteThisTask'); } $form->addHeader($header); $form->addText('title', get_lang('Title')); $config = array(); if (!api_is_allowed_to_edit()) { $config['ToolbarSet'] = 'ProjectComment'; } else { $config['ToolbarSet'] = 'ProjectCommentStudent'; } $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); $form->addFile('user_upload', get_lang('AddAnAttachment')); $form->addTextarea('post_file_comment', get_lang('FileComment')); $form->addHidden('action', null); $form->addHidden('comment_parent_id', 0); if (isset($_GET['task_id'])) { $form->addHidden('new_task_execution_submit', 'true'); $form->addHidden('task_id', intval($_GET['task_id'])); } else { $form->addHidden('new_comment_submit', 'true'); } $form->addButton('save', get_lang('Save')); $form->display(); }
exit; } $form->addHeader($plugin->get_lang('UserInformation')); $form->addText('name', get_lang('Name'), false, ['cols-size' => [5, 7, 0]]); $form->addText('username', get_lang('Username'), false, ['cols-size' => [5, 7, 0]]); $form->addText('email', get_lang('EmailAddress'), false, ['cols-size' => [5, 7, 0]]); $form->addHeader($plugin->get_lang('PaymentMethods')); $paymentTypesOptions = $plugin->getPaymentTypes(); if (!$paypalEnabled) { unset($paymentTypesOptions[BuyCoursesPlugin::PAYMENT_TYPE_PAYPAL]); } if (!$transferEnabled) { unset($paymentTypesOptions[BuyCoursesPlugin::PAYMENT_TYPE_TRANSFER]); } $form->addRadio('payment_type', null, $paymentTypesOptions); $form->addHidden('t', intval($_GET['t'])); $form->addHidden('i', intval($_GET['i'])); $form->freeze(['name', 'username', 'email']); $form->setDefaults(['name' => $userInfo['complete_name'], 'username' => $userInfo['username'], 'email' => $userInfo['email']]); $form->addButton('submit', $plugin->get_lang('ConfirmOrder'), 'check', 'success'); // View $templateName = $plugin->get_lang('PaymentMethods'); $interbreadcrumb[] = array("url" => "course_catalog.php", "name" => $plugin->get_lang('CourseListOnSale')); $tpl = new Template($templateName); $tpl->assign('buying_course', $buyingCourse); $tpl->assign('buying_session', $buyingSession); $tpl->assign('user', api_get_user_info()); $tpl->assign('form', $form->returnForm()); if ($buyingCourse) { $tpl->assign('course', $courseInfo); } elseif ($buyingSession) {
/** * @param int $id * @param string $action * * @return FormValidator */ public static function getCategoryForm($id, $action) { $form = new FormValidator('category', 'post', api_get_self() . '?action=' . $action . '&' . api_get_cidreq()); $defaults = []; if ($action == 'addcategory') { $form->addHeader(get_lang('CategoryAdd')); $my_cat_title = get_lang('CategoryAdd'); } else { $form->addHeader(get_lang('CategoryMod')); $my_cat_title = get_lang('CategoryMod'); $defaults = self::getCategory($id); } $form->addHidden('id', $id); $form->addText('category_title', get_lang('CategoryName')); $form->addTextarea('description', get_lang('Description')); $form->addButtonSave($my_cat_title, 'submitCategory'); $form->setDefaults($defaults); return $form; }
$label = $folder_titles[$folder]; if ($folder == $group_dir) { $label = '/ (' . get_lang('HomeDirectory') . ')'; } else { $path_parts = explode('/', str_replace($group_dir, '', $folder)); $label = cut($label, 80); $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; } $parent_select->addOption($label, $folder); if ($selected != '') { $parent_select->setSelected($folder); } } } } $form->addHidden('dirValue', ''); if ($is_certificate_mode) { $form->addButtonCreate(get_lang('CreateCertificate')); } else { $form->addButtonCreate(get_lang('CreateDoc')); } $form->setDefaults($defaults); // If form validates -> save the new document if ($form->validate()) { $values = $form->exportValues(); $readonly = isset($values['readonly']) ? 1 : 0; $values['title'] = trim($values['title']); if (!empty($values['dirValue'])) { $dir = $values['dirValue']; } if ($dir[strlen($dir) - 1] != '/') {
$skillList = [0 => get_lang('None')]; $gradebookList = []; foreach ($allSkills as $skill) { $skillList[$skill['id']] = $skill['name']; } foreach ($allGradebooks as $gradebook) { $gradebookList[$gradebook['id']] = $gradebook['name']; } /* Form */ $createForm = new FormValidator('skill_create'); $createForm->addHeader(get_lang('CreateSkill')); $createForm->addText('name', get_lang('Name'), true, ['id' => 'name']); $createForm->addText('short_code', get_lang('ShortCode'), false, ['id' => 'short_code']); $createForm->addSelect('parent_id', get_lang('Parent'), $skillList, ['id' => 'parent_id']); $createForm->addSelect('gradebook_id', [get_lang('Gradebook'), get_lang('WithCertificate')], $gradebookList, ['id' => 'gradebook_id', 'multiple' => 'multiple', 'size' => 10]); $createForm->addTextarea('description', get_lang('Description'), ['id' => 'description', 'rows' => 7]); $createForm->addButtonSave(get_lang('Save')); $createForm->addHidden('id', null); $createForm->setDefaults($formDefaultValues); if ($createForm->validate()) { $created = $objSkill->add($createForm->getSubmitValues()); if ($created) { Display::return_message(get_lang('TheSkillHasBeenCreated'), 'success'); } else { Display::return_message(get_lang('CannotCreateSkill'), 'error'); } header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/skill_list.php'); exit; } //$tpl = new Template(get_lang('CreateSkill')); echo $createForm->returnForm();
} else { api_not_allowed(true); } $form = new FormValidator('beneficiaries'); $form->addText('product_type', $plugin->get_lang('ProductType'), false); $form->addText('name', get_lang('Name'), false); $visibleCheckbox = $form->addCheckBox('visible', $plugin->get_lang('VisibleInCatalog'), $plugin->get_lang('ShowOnCourseCatalog')); $form->addElement('number', 'price', [$plugin->get_lang('Price'), null, $currencyIso], ['step' => 0.01]); $beneficiariesSelect = $form->addSelect('beneficiaries', $plugin->get_lang('Beneficiaries'), null, ['multiple' => 'multiple']); if ($editingCourse) { $beneficiariesSelect->addOptGroup($teachersOptions, get_lang('Teachers')); } elseif ($editingSession) { $beneficiariesSelect->addOptGroup([$generalCoachOption], get_lang('SessionGeneralCoach')); $beneficiariesSelect->addOptGroup($courseCoachesOptions, get_lang('SessionCourseCoach')); } $form->addHidden('t', null); $form->addHidden('i', null); $form->addButtonSave(get_lang('Save')); $form->freeze(['product_type', 'name']); if ($form->validate()) { $formValues = $form->exportValues(); $productItem = $plugin->getItemByProduct($formValues['i'], $formValues['t']); if (isset($formValues['visible'])) { if (!empty($productItem)) { $plugin->updateItem(['price' => floatval($formValues['price'])], $formValues['i'], $formValues['t']); } else { $itemId = $plugin->registerItem(['currency_id' => $currency['id'], 'product_type' => $formValues['t'], 'product_id' => intval($formValues['i']), 'price' => floatval($_POST['price'])]); $productItem['id'] = $itemId; } $plugin->deleteItemBeneficiaries($productItem['id']); if (isset($formValues['beneficiaries'])) {