/** * @Route("/edit/{tool}") * @Method({"GET"}) * * @param string $tool * @return Response */ public function editAction($tool) { $message = null; // @todo use proper functions not api functions. $courseId = api_get_course_int_id(); $sessionId = api_get_session_id(); $tool = \Database::escape_string($tool); $TBL_INTRODUCTION = \Database::get_course_table(TABLE_TOOL_INTRO); $url = $this->generateUrl('introduction.controller:editAction', array('tool' => $tool, 'course' => api_get_course_id())); $form = $this->getForm($url, $tool); if ($form->validate()) { $values = $form->exportValues(); $content = $values['content']; $sql = "REPLACE {$TBL_INTRODUCTION}\n SET c_id = {$courseId},\n id = '{$tool}',\n intro_text='" . \Database::escape_string($content) . "',\n session_id='" . intval($sessionId) . "'"; \Database::query($sql); $message = \Display::return_message(get_lang('IntroductionTextUpdated'), 'confirmation', false); } else { $sql = "SELECT intro_text FROM {$TBL_INTRODUCTION}\n WHERE c_id = {$courseId} AND id='" . $tool . "' AND session_id = '" . intval($sessionId) . "'"; $result = \Database::query($sql); $content = null; if (\Database::num_rows($result) > 0) { $row = \Database::fetch_array($result); $content = $row['intro_text']; } $form->setDefaults(array('content' => $content)); } $this->getTemplate()->assign('content', $form->return_form()); $this->getTemplate()->assign('message', $message); $response = $this->getTemplate()->renderLayout('layout_1_col.tpl'); return new Response($response, 200, array()); }
/** * Display a standard json responce. * * @param bool $success * @param string $message * @param object $data * @return bool|void * @assert () === null */ public function response($success = false, $message = '', $data = null) { $message = trim($message); $response = (object) array(); $response->success = $success; if ($message) { $response->message = Display::return_message($message, $success ? 'normal' : 'error'); } else { $response->message = ''; } $response->data = $data; $this->render_json($response); }
/** * Shows the answer to a free-answer question, as HTML * @param string Answer text * @param int Exercise ID * @param int Question ID * @return void */ static function display_free_answer($feedback_type, $answer, $exe_id, $questionId, $questionScore = null) { $comments = get_comments($exe_id, $questionId); if (!empty($answer)) { echo '<tr><td>'; echo nl2br(Security::remove_XSS($answer, COURSEMANAGERLOWSECURITY)); echo '</td></tr>'; } if ($feedback_type != EXERCISE_FEEDBACK_TYPE_EXAM) { if ($questionScore > 0 || !empty($comments)) { } else { echo '<tr>'; echo Display::tag('td', Display::return_message(get_lang('notCorrectedYet')), array()); echo '</tr>'; } } }
function display_form() { $html = ''; $sessions = SessionManager::get_sessions_list(array(), array('name', 'ASC')); // Actions // Link back to the documents overview $actionsLeft = '<a href="../admin/index.php">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM) . '</a>'; $html .= Display::toolbarAction('toolbar-copysession', array(0 => $actionsLeft)); $html .= Display::return_message(get_lang('CopyCourseFromSessionToSessionExplanation'), 'warning'); $html .= '<form class="form-horizontal" name="formulaire" method="post" action="' . api_get_self() . '" >'; $html .= '<div class="form-group">'; // origin $html .= '<label class="col-sm-2 control-label">' . get_lang('OriginCoursesFromSession') . ': </label>'; $html .= '<div class="col-sm-5">' . make_select_session_list('sessions_list_origin', $sessions, array('onchange' => 'javascript: xajax_search_courses(this.value,\'origin\');')) . '</div>'; $html .= '<div class="col-sm-5" id="ajax_list_courses_origin">'; $html .= '<select id="origin" class="form-control" name="SessionCoursesListOrigin[]" ></select>'; $html .= '</div></div>'; //destination $html .= '<div class="form-group">'; $html .= '<label class="col-sm-2 control-label">' . get_lang('DestinationCoursesFromSession') . ': </label>'; $html .= '<div class="col-sm-5" id="ajax_sessions_list_destination">'; $html .= '<select class="form-control" name="sessions_list_destination" onchange="javascript: xajax_search_courses(this.value,\'destination\');">'; $html .= '<option value = "0">' . get_lang('ThereIsNotStillASession') . '</option></select ></div>'; $html .= '<div class="col-sm-5" id="ajax_list_courses_destination">'; $html .= '<select id="destination" class="form-control" name="SessionCoursesListDestination[]" ></select>'; $html .= '</div></div>'; $options = '<div class="radio"><label><input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>'; $options .= get_lang('FullCopy') . '</label></div>'; $options .= '<div class="radio"><label><input type="radio" id="copy_option_2" name="copy_option" value="select_items" disabled="disabled"/>'; $options .= ' ' . get_lang('LetMeSelectItems') . '</label></div>'; $options .= '<div class="checkbox"><label><input type="checkbox" id="copy_base_content_id" name="copy_only_session_items" />' . get_lang('CopyOnlySessionItems') . '</label></div>'; $html .= Display::panel($options, get_lang('TypeOfCopy')); $html .= '<div class="form-group"><div class="col-sm-12">'; $html .= '<button class="btn btn-success" type="submit" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;"><em class="fa fa-files-o"></em> ' . get_lang('CopyCourse') . '</button>'; // Add Security token $html .= '<input type="hidden" value="' . Security::get_token() . '" name="sec_token">'; $html .= '</div></div>'; $html .= '</form>'; echo $html; }
function display_form() { $html = ''; $sessions = SessionManager::get_sessions_list(array(), array('name', 'ASC')); // Actions $html .= '<div class="actions">'; // Link back to the documents overview $html .= '<a href="../admin/index.php">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('PlatformAdmin'), '', ICON_SIZE_MEDIUM) . '</a>'; $html .= '</div>'; $html .= Display::return_message(get_lang('CopyCourseFromSessionToSessionExplanation')); $html .= '<form name="formulaire" method="post" action="' . api_get_self() . '" >'; $html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">'; // origin $html .= '<tr><td width="15%"><b>' . get_lang('OriginCoursesFromSession') . ':</b></td>'; $html .= '<td width="10%" align="left">' . make_select_session_list('sessions_list_origin', $sessions, array('onchange' => 'javascript: xajax_search_courses(this.value,\'origin\');')) . '</td>'; $html .= '<td width="50%"><div id="ajax_list_courses_origin">'; $html .= '<select id="origin" name="SessionCoursesListOrigin[]" style="width:380px;"></select></div></td></tr>'; //destination $html .= '<tr><td width="15%"><b>' . get_lang('DestinationCoursesFromSession') . ':</b></td>'; $html .= '<td width="10%" align="left"><div id="ajax_sessions_list_destination">'; $html .= '<select name="sessions_list_destination" onchange="javascript: xajax_search_courses(this.value,\'destination\');">'; $html .= '<option value = "0">' . get_lang('ThereIsNotStillASession') . '</option></select ></div></td>'; $html .= '<td width="50%">'; $html .= '<div id="ajax_list_courses_destination">'; $html .= '<select id="destination" name="SessionCoursesListDestination[]" style="width:380px;" ></select></div></td>'; $html .= '</tr></table>'; $html .= '<h4>' . get_lang('TypeOfCopy') . '</h4>'; $html .= '<label class="radio"><input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>'; $html .= get_lang('FullCopy') . '</label><br/>'; $html .= '<label class="radio"><input type="radio" id="copy_option_2" name="copy_option" value="select_items" disabled="disabled"/>'; $html .= ' ' . get_lang('LetMeSelectItems') . '</label><br/>'; $html .= '<label class="checkbox"><input type="checkbox" id="copy_base_content_id" name="copy_only_session_items" />' . get_lang('CopyOnlySessionItems') . '</label><br /><br/>'; $html .= '<button class="btn btn-success" type="submit" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;"><i class="fa fa-files-o"></i> ' . get_lang('CopyCourse') . '</button>'; // Add Security token $html .= '<input type="hidden" value="' . Security::get_token() . '" name="sec_token">'; $html .= '</form>'; echo $html; }
/** * @param Application $app * @param int $exerciseId * @param int $questionId * @return Response */ public function reuseQuestionAction(Application $app, $exerciseId, $questionId) { /** @var \Question $question */ $question = \Question::read($questionId); if ($question) { // adds the exercise ID represented by $fromExercise into the list of exercises for the current question $question->addToList($exerciseId); $objExercise = new \Exercise(); $objExercise->read($exerciseId); // adds the question ID represented by $recup into the list of questions for the current exercise $objExercise->addToList($exerciseId); Session::write('objExercise', $objExercise); /*$params = array( 'cidReq' => api_get_course_id(), 'id_session' => api_get_session_id(), 'id' => $questionId, 'exerciseId' => $exerciseId ); $url = $app['url_generator']->generate('exercise_question_pool', $params); return $app->redirect($url);*/ $response = \Display::return_message(get_lang('QuestionReused') . ": " . $question->question); return new Response($response, 200, array()); } }
function addAction(Application $app) { $timeline = new Timeline(); $url = $app['url_generator']->generate('add'); $form = $timeline->return_item_form($url, 'edit'); // The validation or display if ($form->validate()) { $values = $form->exportValues(); $values['type'] = 0; $values['status'] = 0; $my_timeline = new CTimeline(); $my_timeline->setCId(api_get_course_int_id()); $my_timeline->setHeadline($values['headline']); $my_timeline->setType($values['type']); $my_timeline->setStartDate($values['start_date']); $my_timeline->setEndDate($values['end_date']); $my_timeline->setText($values['text']); $my_timeline->setMedia($values['media']); $my_timeline->setMediaCredit($values['media_credit']); $my_timeline->setMediaCaption($values['media_caption']); $my_timeline->setTitleSlide($values['title_slide']); $my_timeline->setParentId($values['parent_id']); $my_timeline->setStatus($values['status']); $app['orm.em']->persist($my_timeline); $app['orm.em']->flush(); $message = Display::return_message(sprintf(get_lang('ItemUpdated'), $values['name']), 'confirmation'); //$app['session']->setFlash('error', $message); return $app->redirect($app['url_generator']->generate('view', array('id' => $my_timeline->getId())), 201); } else { $actions = '<a href="' . $app['url_generator']->generate('index') . '">' . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . '</a>'; $content = $form->return_form(); } $app['template']->assign('content', $content); $response = $app['template']->render_layout('layout_1_col.tpl'); return new Response($response, 200, array()); }
// submit button $form->addButtonSave(get_lang('SaveSettings')); if ($form->validate()) { $values = $form->exportValues(); // Storing the users (we first remove all users and then add only those who were selected) GroupManager::unsubscribe_all_users($current_group['id']); if (isset($_POST['group_members']) && count($_POST['group_members']) > 0) { GroupManager::subscribe_users($values['group_members'], $current_group['id']); } // Returning to the group area (note: this is inconsistent with the rest of chamilo) $cat = GroupManager::get_category_from_group($current_group['id']); if (isset($_POST['group_members']) && count($_POST['group_members']) > $max_member && $max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT) { Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning')); header('Location: group.php?' . api_get_cidreq(true, false)); } else { Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success')); header('Location: group.php?' . api_get_cidreq(true, false) . '&category=' . $cat['id']); } exit; } $action = isset($_GET['action']) ? $_GET['action'] : null; switch ($action) { case 'empty': if (api_is_allowed_to_edit(false, true)) { GroupManager::unsubscribe_all_users($group_id); Display::display_confirmation_message(get_lang('GroupEmptied')); } break; } $defaults = $current_group; $defaults['group_members'] = $selected_users;
$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();
} /* ACTION HANDLING */ if (!empty($_POST['Register'])) { api_register_campus(!$_POST['donotlistcampus']); $message = Display::return_message(get_lang('VersionCheckEnabled'), 'confirmation'); } $keyword_url = Security::remove_XSS(empty($_GET['keyword']) ? '' : $_GET['keyword']); } if (isset($_GET['msg']) && isset($_GET['type'])) { if (in_array($_GET['msg'], array('ArchiveDirCleanupSucceeded', 'ArchiveDirCleanupFailed'))) { switch ($_GET['type']) { case 'error': $message = Display::return_message(get_lang($_GET['msg']), 'error'); break; case 'confirmation': $message = Display::return_message(get_lang($_GET['msg']), 'confirm'); } } } $blocks = array(); // Instantiate Hook Event for Admin Block $hook = HookAdminBlock::create(); if (!empty($hook)) { // If not empty, then notify Pre process to Hook Observers for Admin Block $hook->setEventData(array('blocks' => $blocks)); $data = $hook->notifyAdminBlock(HOOK_EVENT_TYPE_PRE); // Check if blocks data is not null if (isset($data['blocks'])) { // Get modified blocks $blocks = $data['blocks']; }
$see_message_import = get_lang('FileImported'); } if (count($errors) != 0) { $warning_message = '<ul>'; foreach ($errors as $index => $error_user) { $warning_message .= '<li><b>' . $error_user['error'] . '</b>: '; $warning_message .= '<strong>' . $error_user['UserName'] . '</strong> (' . api_get_person_name($error_user['FirstName'], $error_user['LastName']) . ')'; $warning_message .= '</li>'; } $warning_message .= '</ul>'; } // if the warning message is too long then we display the warning message trough a session if ($error_kind_file) { Display::addFlash(Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption'))); } else { Display::addFlash(Display::return_message($see_message_import)); header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?&sec_token=' . $tok); exit; } } Display::display_header($tool_name); $form = new FormValidator('user_update_import', 'post', api_get_self()); $form->addElement('header', $tool_name); $form->addElement('hidden', 'formSent'); $form->addElement('file', 'import_file', get_lang('ImportFileLocation')); $group = array(); $form->addButtonImport(get_lang('Import')); $defaults['formSent'] = 1; $defaults['sendMail'] = 0; $defaults['file_type'] = 'csv'; $form->setDefaults($defaults);
$current_qualify_thread = show_qualify('1', $row_student_list['user_id'], $_GET['id']); $table_list .= '<td><a href="' . $forumUrl . 'forumqualify.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&thread=' . Security::remove_XSS($_GET['id']) . '&user='******'user_id'] . '&user_id=' . $row_student_list['user_id'] . '&idtextqualify=' . $current_qualify_thread . '&origin=' . $origin . '">' . Display::return_icon($icon_qualify, get_lang('Qualify')) . '</a></td></tr>'; } $counter_stdlist++; } } else { if ($_GET['list'] == 'qualify') { $table_list .= '<tr><td colspan="2">' . get_lang('ThereIsNotQualifiedLearners') . '</td></tr>'; } else { $table_list .= '<tr><td colspan="2">' . get_lang('ThereIsNotUnqualifiedLearners') . '</td></tr>'; } } $table_list .= '</table></center>'; $table_list .= '<br />'; } else { $table_list .= Display::return_message(get_lang('NoParticipation'), 'warning'); } } if ($origin == 'learnpath') { echo '<div style="height:15px"> </div>'; } /* Display the action messages */ if (!empty($message)) { Display::display_confirmation_message($message); } /* Action links */ echo '<div class="actions">'; if ($origin != 'learnpath') { if ($origin == 'group') { echo '<a href=' . api_get_path(WEB_CODE_PATH) . '"group/group_space.php?' . api_get_cidreq() . '&gradebook=' . $gradebook . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('Groups'), '', ICON_SIZE_MEDIUM) . '</a>'; } else {
// check access permissions (edit permission is needed to add a document or a LP) $is_allowed_to_edit = api_is_allowed_to_edit(); if (!$is_allowed_to_edit) { api_not_allowed(true); } $interbreadcrumb[] = array("url" => "../newscorm/lp_controller.php?action=list", "name" => get_lang("Doc")); $nameTools = get_lang("OogieConversionPowerPoint"); Display::display_header($nameTools); $message = get_lang("WelcomeOogieConverter"); if (!empty($errorMessage)) { echo Display::return_message($errorMessage, 'warning', false); } $div_upload_limit = get_lang('UploadMaxSize') . ' : ' . ini_get('post_max_size'); $form = new FormValidator('upload_ppt', 'POST', '', ''); $form->addElement('header', get_lang("WelcomeOogieSubtitle")); $form->addElement('html', Display::return_message($message, 'info', false)); $form->addElement('file', 'user_file', array(Display::return_icon('powerpoint_big.gif'), $div_upload_limit)); $form->addElement('checkbox', 'take_slide_name', '', get_lang('TakeSlideName')); if (api_get_setting('search.search_enabled') == 'true') { require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; $specific_fields = get_specific_field_list(); $form->addElement('checkbox', 'index_document', '', get_lang('SearchFeatureDoIndexDocument')); $form->addElement('select_language', 'language', get_lang('SearchFeatureDocumentLanguage')); foreach ($specific_fields as $specific_field) { $form->addElement('text', $specific_field['code'], $specific_field['name'] . ' : '); } } $form->addButtonUpload(get_lang('ConvertToLP'), 'convert'); $form->addElement('hidden', 'ppt2lp', 'true'); $form->add_real_progress_bar(md5(rand(0, 10000)), 'user_file', 1, true); $defaults = array('take_slide_name' => 'checked="checked"', 'index_document' => 'checked="checked"');
/* For licensing terms, see /license.txt */ //require_once '../inc/global.inc.php'; $type = $_REQUEST['type']; $src = Security::remove_XSS($_REQUEST['source']); if (empty($type) || empty($src)) { api_not_allowed(); } $iframe = ''; switch ($type) { case 'youtube': $src = 'http://www.youtube.com/embed/' . $src; $iframe .= '<div id="content" style="width: 700px ;margin-left:auto; margin-right:auto;"><br />'; $iframe .= '<iframe class="youtube-player" type="text/html" width="640" height="385" src="' . $src . '" frameborder="0"></iframe>'; $iframe .= '</div>'; break; case 'vimeo': $src = 'http://player.vimeo.com/video/' . $src; $iframe .= '<div id="content" style="width: 700px ;margin-left:auto; margin-right:auto;"><br />'; $iframe .= '<iframe src="' . $src . '" width="640" height="385" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; $iframe .= '</div>'; break; case 'nonhttps': $icon = ' <em class="icon-external-link icon-2x"></em>'; $iframe = Display::return_message(Display::url($src . $icon, $src, ['class' => 'btn', 'target' => '_blank']), 'normal', false); break; } $htmlHeadXtra[] = "\n<style>\nbody { background: none;}\n</style>\n"; Display::display_reduced_header(); echo $iframe; Display::display_footer();
} Display::addFlash(Display::return_message(get_lang('AnnouncementModified'), 'success')); header('Location: ' . $homeUrl); exit; } } else { // Insert mode if (true) { $file = $_FILES['user_upload']; $file_comment = $data['file_comment']; if (empty($group_id)) { $insert_id = AnnouncementManager::add_announcement($data['title'], $data['content'], $data['users'], $file, $file_comment, null, $sendToUsersInSession); } else { $insert_id = AnnouncementManager::add_group_announcement($data['title'], $data['content'], array('GROUP:' . $group_id), $data['users'], $file, $file_comment, $sendToUsersInSession); } Display::addFlash(Display::return_message(get_lang('AnnouncementAdded'), 'success')); /* MAIL FUNCTION */ if (isset($data['email_ann']) && $data['email_ann']) { AnnouncementManager::send_email($insert_id, $sendToUsersInSession); } header('Location: ' . $homeUrl); exit; } // end condition token } } $content = $form->returnForm(); break; } if (!empty($_GET['remind_inactive'])) { $to[] = 'USER:'******'remind_inactive']);
/** * @param string $categorySource * * @return string */ function listCategories($categorySource) { $categorySource = isset($categorySource) ? $categorySource : null; $categories = self::getCategories($categorySource); if (count($categories) > 0) { $table = new HTML_Table(array('class' => 'data_table')); $column = 0; $row = 0; $headers = array(get_lang('Category'), get_lang('CategoriesNumber'), get_lang('Courses'), get_lang('Actions')); foreach ($headers as $header) { $table->setHeaderContents($row, $column, $header); $column++; } $row++; $mainUrl = api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . $categorySource; $editIcon = Display::return_icon('edit.png', get_lang('EditNode'), null, ICON_SIZE_SMALL); $deleteIcon = Display::return_icon('delete.png', get_lang('DeleteNode'), null, ICON_SIZE_SMALL); $moveIcon = Display::return_icon('up.png', get_lang('UpInSameLevel'), null, ICON_SIZE_SMALL); foreach ($categories as $category) { $editUrl = $mainUrl . '&id=' . $category['code'] . '&action=edit'; $moveUrl = $mainUrl . '&id=' . $category['code'] . '&action=moveUp&tree_pos=' . $category['tree_pos']; $deleteUrl = $mainUrl . '&id=' . $category['code'] . '&action=delete'; $actions = Display::url($editIcon, $editUrl) . Display::url($moveIcon, $moveUrl) . Display::url($deleteIcon, $deleteUrl); $url = api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . $category['code']; $title = Display::url(Display::return_icon('folder_document.gif', get_lang('OpenNode'), null, ICON_SIZE_SMALL) . ' ' . $category['name'], $url); $content = array($title, $category['children_count'], $category['nbr_courses'], $actions); $column = 0; foreach ($content as $value) { $table->setCellContents($row, $column, $value); $column++; } $row++; } return $table->toHtml(); } else { return Display::return_message(get_lang("NoCategories"), 'warning'); } }
if (!is_array($user_list)) { $user_list = array(); } if ($form_sent == 1) { // invite this users $result = $usergroup->add_users_to_groups($user_list, array($group_id), GROUP_USER_PERMISSION_PENDING_INVITATION); $title = get_lang('YouAreInvitedToGroup') . ' ' . $group_info['name']; $content = get_lang('YouAreInvitedToGroupContent') . ' ' . $group_info['name'] . ' <br />'; $content .= get_lang('ToSubscribeClickInTheLinkBelow') . ' <br />'; $content .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'social/invitations.php?accept=' . $group_id . '">' . get_lang('Subscribe') . '</a>'; if (is_array($user_list) && count($user_list) > 0) { //send invitation message foreach ($user_list as $user_id) { $result = MessageManager::send_message($user_id, $title, $content); } Display::addFlash(Display::return_message(get_lang('InvitationSent'))); } header('Location: ' . api_get_self() . '?id=' . $group_id); exit; } } $nosessionUsersList = $sessionUsersList = array(); $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; $friends = SocialManager::get_friends(api_get_user_id()); $suggest_friends = false; $Users = array(); if (!$friends) { $suggest_friends = true; } else { foreach ($friends as $friend) { $group_friend_list = $usergroup->get_groups_by_user($friend['friend_user_id'], 0);
// if it's a zip, allow zip upload $unzip = 1; } if ($process && $unzip == 1) { $main_path = api_get_path(SYS_CODE_PATH); require_once $main_path . 'exercice/export/exercise_import.inc.php'; require_once $main_path . 'exercice/export/qti2/qti2_classes.php'; return import_exercise($array_file['name']); } return 'langFileError'; } $message = null; // import file if (api_is_allowed_to_edit(null, true)) { if (isset($_POST['submit'])) { $imported = ch_qti2_import_file($_FILES['userFile']); if (is_numeric($imported) && !empty($imported)) { header('Location: ' . api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidreq() . '&exerciseId=' . $imported); exit; } else { $message = Display::return_message(get_lang($imported)); } } } // Display header Display::display_header(get_lang('ImportQtiQuiz'), 'Exercises'); echo $message; // display qti form ch_qti2_display_form(); // display the footer Display::display_footer();
$totalPayout = 0; $payouts = isset($_POST['payouts']) ? $_POST['payouts'] : ''; if (!$payouts) { echo Display::return_message(get_plugin_lang("SelectOptionToProceed", "BuyCoursesPlugin"), 'error', false); break; } foreach ($payouts as $index => $id) { $allPayouts[] = $plugin->getPayouts(BuyCoursesPlugin::PAYOUT_STATUS_PENDING, $id); } $currentCurrency = $plugin->getSelectedCurrency(); $isoCode = $currentCurrency['iso_code']; $result = MassPayment($allPayouts, $isoCode); if ($result['ACK'] === 'Success') { foreach ($allPayouts as $payout) { $plugin->setStatusPayouts($payout['id'], BuyCoursesPlugin::PAYOUT_STATUS_COMPLETED); } echo Display::return_message(get_plugin_lang("PayoutSuccess", "BuyCoursesPlugin"), 'success', false); } else { echo Display::return_message('<b>' . $result['L_SEVERITYCODE0'] . ' ' . $result['L_ERRORCODE0'] . '</b> - ' . $result['L_SHORTMESSAGE0'] . '</br><ul><li>' . $result['L_LONGMESSAGE0'] . '</li></ul>', 'error', false); } break; case 'cancelPayout': if (api_is_anonymous()) { break; } $payoutId = isset($_POST['id']) ? $_POST['id'] : ''; $plugin->setStatusPayouts($payoutId, BuyCoursesPlugin::PAYOUT_STATUS_CANCELED); echo ''; break; } exit;
} } $message = null; if (isset($_GET['action'])) { switch ($_GET['action']) { case 'unsubscribe': if (CourseManager::get_user_in_course_status($_GET['user_id'], $_GET['course_code']) == STUDENT) { CourseManager::unsubscribe_user($_GET['user_id'], $_GET['course_code'], $_GET['id_session']); $message = Display::return_message(get_lang('UserUnsubscribed')); } else { $message = Display::return_message(get_lang('CannotUnsubscribeUserFromCourse'), 'error'); } break; case 'unsubscribeSessionCourse': SessionManager::removeUsersFromCourseSession(array($_GET['user_id']), $_GET['id_session'], api_get_course_info($_GET['course_code'])); $message = Display::return_message(get_lang('UserUnsubscribed')); break; case 'export': Export::arrayToCsv($csvContent, 'user_information_' . $user); exit; break; } } Display::display_header($tool_name); echo '<div class="actions"> <a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . intval($_GET['user_id']) . '" title="' . get_lang('Reporting') . '">' . Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM) . ' </a> ' . $login_as_icon . ' ' . $editUser . ' ' . $exportLink . ' </div>';
$tab_course_info = api_get_course_info($firstpage); api_set_firstpage_parameter($firstpage); $tpl = new Template(null, 1, 1); $action = api_get_self() . '?' . Security::remove_XSS($_SERVER['QUERY_STRING']); $action = str_replace('&', '&', $action); $form = new FormValidator('formLogin', 'post', $action, null, array('class' => 'form-stacked')); $form->addElement('text', 'login', null, array('placeholder' => get_lang('UserName'), 'class' => 'span3 autocapitalize_off')); //new $form->addElement('password', 'password', null, array('placeholder' => get_lang('Password'), 'class' => 'span3')); //new $form->addElement('style_submit_button', 'submitAuth', get_lang('LoginEnter'), array('class' => 'btn span3')); // see same text in main_api.lib.php function api_not_allowed if (api_is_cas_activated()) { $msg .= Display::return_message(sprintf(get_lang('YouHaveAnInstitutionalAccount'), api_get_setting("Institution")), '', false); $msg .= Display::div("<br/><a href='" . get_cas_direct_URL(api_get_course_id()) . "'>" . getCASLogoHTML() . " " . sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution")) . "</a><br/><br/>", array('align' => 'center')); $msg .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount')); $msg .= "<p style='text-align:center'><a href='#' onclick='\$(this).parent().next().toggle()'>" . get_lang('LoginWithExternalAccount') . "</a></p>"; $msg .= "<div style='display:none;'>"; } $msg .= '<div class="well_login">'; $msg .= $form->return_form(); $msg .= '</div>'; if (api_is_cas_activated()) { $msg .= "</div>"; } $msg .= '<hr/><p style="text-align:center"><a href="' . api_get_path(WEB_PATH) . '">' . get_lang('ReturnToCourseHomepage') . '</a></p>'; $tpl->assign('content', '<h4>' . get_lang('LoginToGoToThisCourse') . '</h4>' . $msg); $tpl->display_one_col_template(); } else { api_delete_firstpage_parameter(); Header('Location: ' . api_get_path(WEB_PATH) . 'index.php');
if (!empty($data)) { $course_legal = $data['content']; } $userData = $plugin->getUserAcceptedLegal($user_id, $course_info['real_id'], $session_id); if (isset($_GET['web_agreement_link'])) { $plugin->saveUserMailLegal($_GET['web_agreement_link'], $user_id, $course_info['real_id'], $session_id); } } // Build the form $form = new FormValidator('legal', 'GET', api_get_self() . '?course_code=' . $course_code . '&session_id=' . $session_id); $pluginMessage = null; $hideForm = false; if ($pluginLegal && isset($userData) && !empty($userData)) { if ($userData['web_agreement'] == 1) { if (empty($userData['mail_agreement'])) { $pluginMessage = Display::return_message($plugin->get_lang('YouNeedToConfirmYourAgreementCheckYourEmail')); $hideForm = true; } } } $form->addElement('header', get_lang('CourseLegalAgreement')); $form->addElement('label', null, $course_legal); if ($pluginLegal && !empty($plugin)) { $form->addElement('label', null, $plugin->getCurrentFile($course_info['real_id'], $session_id)); } $form->addElement('hidden', 'course_code', $course_code); $form->addElement('hidden', 'session_id', $session_id); $form->addElement('checkbox', 'accept_legal', null, get_lang('AcceptLegal')); $form->addElement('style_submit_button', null, get_lang('Accept'), 'class="save"'); $variable = 'accept_legal_' . $user_id . '_' . $course_info['real_id'] . '_' . $session_id; $url = api_get_course_url($course_code, $session_id);
//@todo move this somewhere else $subject = get_lang('ExamSheetVCC'); $message = '<p>' . get_lang('DearStudentEmailIntroduction') . '</p><p>' . get_lang('AttemptVCC'); $message .= '<h3>' . get_lang('CourseName') . '</h3><p>' . Security::remove_XSS($course_info['name']) . ''; $message .= '<h3>' . get_lang('Exercise') . '</h3><p>' . Security::remove_XSS($test); //Only for exercises not in a LP if ($lp_id == 0) { $message .= '<p>' . get_lang('ClickLinkToViewComment') . ' <a href="#url#">#url#</a><br />'; } $message .= '<p>' . get_lang('Regards') . '</p>'; $message .= $from_name; $message = str_replace("#test#", Security::remove_XSS($test), $message); $message = str_replace("#url#", $url, $message); MessageManager::send_message_simple($student_id, $subject, $message, api_get_user_id()); if ($allowCoachFeedbackExercises) { Display::addFlash(Display::return_message(get_lang('MessageSent'))); header('Location: ' . api_get_path(WEB_PATH)); exit; } } //Updating LP score here if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) { $sql = "UPDATE {$TBL_LP_ITEM_VIEW} SET score = '" . floatval($tot) . "'\n WHERE c_id = " . $course_id . " AND id = " . $lp_item_view_id; Database::query($sql); if ($origin == 'tracking_course') { //Redirect to the course detail in lp header('location: exercise.php?course=' . Security::remove_XSS($_GET['course'])); exit; } else { //Redirect to the reporting header('location: ../mySpace/myStudents.php?origin=' . $origin . '&student=' . $student_id . '&details=true&course=' . $course_id . '&session_id=' . $session_id);
if ($action == 'add') { $ret = addNode($_POST['code'], $_POST['name'], $_POST['auth_course_child'], $category); Display::addFlash(Display::return_message(get_lang('Created'))); } else { $ret = editNode($_POST['code'], $_POST['name'], $_POST['auth_course_child'], $categoryId); Display::addFlash(Display::return_message(get_lang('Updated'))); } if ($ret) { $action = ''; } else { $errorMsg = get_lang('CatCodeAlreadyUsed'); } } elseif ($action == 'moveUp') { moveNodeUp($categoryId, $_GET['tree_pos'], $category); header('Location: ' . api_get_self() . '?category=' . Security::remove_XSS($category)); Display::addFlash(Display::return_message(get_lang('Updated'))); exit; } } $tool_name = get_lang('AdminCategories'); $interbreadcrumb[] = array('url' => 'index.php', "name" => get_lang('PlatformAdmin')); Display::display_header($tool_name); if ($action == 'add' || $action == 'edit') { if (api_get_multiple_access_url() && api_get_current_access_url_id() == 1 || !api_get_multiple_access_url() || isset($_configuration['enable_multiple_url_support_for_course_category']) && $_configuration['enable_multiple_url_support_for_course_category']) { echo '<div class="actions">'; echo Display::url(Display::return_icon('folder_up.png', get_lang("Back"), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'admin/course_category.php?category=' . Security::remove_XSS($category)); echo '</div>'; $form_title = $action == 'add' ? get_lang('AddACategory') : get_lang('EditNode'); if (!empty($category)) { $form_title .= ' ' . get_lang('Into') . ' ' . Security::remove_XSS($category); }
/** * Returns the category form. * @param Exercise $exercise_obj * @return string */ public function returnCategoryForm(Exercise $exercise_obj) { $categories = $this->getListOfCategoriesForTest($exercise_obj); $saved_categories = $exercise_obj->get_categories_in_exercise(); $return = null; if (!empty($categories)) { $nbQuestionsTotal = $exercise_obj->getNumberQuestionExerciseCategory(); $exercise_obj->setCategoriesGrouping(true); $real_question_count = count($exercise_obj->getQuestionList()); $warning = null; if ($nbQuestionsTotal != $real_question_count) { $warning = Display::return_message(get_lang('CheckThatYouHaveEnoughQuestionsInYourCategories'), 'warning'); } $return .= $warning; $return .= '<table class="data_table">'; $return .= '<tr>'; $return .= '<th height="24">' . get_lang('Categories') . '</th>'; $return .= '<th width="70" height="24">' . get_lang('Number') . '</th></tr>'; foreach ($categories as $category) { $cat_id = $category['iid']; $return .= '<tr>'; $return .= '<td>'; $return .= Display::div($category['parent_path']); $return .= '</td>'; $return .= '<td>'; $value = isset($saved_categories) && isset($saved_categories[$cat_id]) ? $saved_categories[$cat_id]['count_questions'] : -1; $return .= '<input name="category[' . $cat_id . ']" value="' . $value . '" />'; $return .= '</td>'; $return .= '</tr>'; } $return .= '</table>'; $return .= get_lang('ZeroMeansNoQuestionWillBeSelectedMinusOneMeansThatAllQuestionsWillBeSelected'); return $return; } }
foreach ($classes as $index => $class_id) { ClassManager::delete_class($class_id); } $message = Display::return_message(get_lang('ClassesDeleted')); } break; } } if (isset($_GET['action'])) { switch ($_GET['action']) { case 'delete_class': ClassManager::delete_class($_GET['class_id']); $message = Display::return_message(get_lang('ClassDeleted')); break; case 'show_message': $message = Display::return_message(Security::remove_XSS(stripslashes($_GET['message']))); break; } } // Create a search-box $form = new FormValidator('search_simple', 'get', '', '', null, false); $renderer =& $form->defaultRenderer(); $renderer->setElementTemplate('<span>{element}</span> '); $form->addElement('text', 'keyword', get_lang('keyword')); $form->addElement('button', 'submit', get_lang('Search')); $content .= $form->return_form(); // Create the sortable table with class information $table = new SortableTable('classes', 'get_number_of_classes', 'get_class_data', 1); $table->set_additional_parameters(array('keyword' => $_GET['keyword'])); $table->set_header(0, '', false); $table->set_header(1, get_lang('ClassName'));
) . '</a> <span class="divider">/</span> <a href="groups.php?id=' . $group_id . '#tabs_2">' . get_lang( 'Discussions' ) . '</a> </div> '; $social_avatar_block = SocialManager::show_social_avatar_block( 'member_list', $group_id ); $social_menu_block = SocialManager::show_social_menu('member_list', $group_id); if (!empty($show_message)) { $social_right_content .= Display::return_message( $show_message, 'confirmation' ); } $social_right_content .= MessageManager::display_message_for_group( $group_id, $topic_id, $is_member, $message_id ); $social_right_content = '<div class="span9">' . $social_right_content . '</div>'; $tpl = new Template($tool_name); $tpl->set_help('Groups'); $tpl->assign('social_avatar_block', $social_avatar_block);
/** * move a link or a linkcategory up or down * @param int Category ID * @param int Course ID * @param int Session ID * @author Patrick Cool <*****@*****.**>, Ghent University * @todo support sessions */ public static function movecatlink($action, $catlinkid, $courseId = null, $sessionId = null) { $tbl_link = Database::get_course_table(TABLE_LINK); $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY); if (is_null($courseId)) { $courseId = api_get_course_int_id(); } $courseId = intval($courseId); if (is_null($sessionId)) { $sessionId = api_get_session_id(); } $sessionId = intval($sessionId); if ($action == 'down') { $thiscatlinkId = intval($catlinkid); $sortDirection = 'DESC'; } if ($action == 'up') { $thiscatlinkId = intval($catlinkid); $sortDirection = 'ASC'; } // We check if it is a category we are moving or a link. // If it is a category, a querystring catmove = true is present in the url. $catmove = 'true'; if ($catmove == 'true') { $movetable = $tbl_categories; $catid = $catlinkid; } else { $movetable = $tbl_link; // Getting the category of the link. if (!empty($thiscatlinkId)) { $sql = "SELECT category_id FROM " . $movetable . "\n WHERE c_id = {$courseId} AND id='{$thiscatlinkId}'"; $result = Database::query($sql); $catid = Database::fetch_array($result); } } // This code is copied and modified from announcements.php. if (!empty($sortDirection)) { if (!in_array(trim(strtoupper($sortDirection)), array('ASC', 'DESC'))) { $sortDirection = 'ASC'; } if ($catmove == 'true') { $sql = "SELECT id, display_order FROM {$movetable}\n WHERE c_id = {$courseId}\n ORDER BY display_order {$sortDirection}"; } else { $sql = "SELECT id, display_order FROM {$movetable}\n WHERE c_id = {$courseId} AND category_id='" . $catid[0] . "'\n ORDER BY display_order {$sortDirection}"; } $linkresult = Database::query($sql); $thislinkOrder = 1; while ($sortrow = Database::fetch_array($linkresult)) { // STEP 2 : FOUND THE NEXT LINK ID AND ORDER, COMMIT SWAP // This part seems unlogic, but it isn't . We first look for the current link with the querystring ID // and we know the next iteration of the while loop is the next one. These should be swapped. if (isset($thislinkFound) && $thislinkFound) { $nextlinkId = $sortrow['id']; $nextlinkOrder = $sortrow['display_order']; Database::query("UPDATE " . $movetable . "\n SET display_order = '{$nextlinkOrder}'\n WHERE c_id = {$courseId} AND id = '{$thiscatlinkId}'"); Database::query("UPDATE " . $movetable . "\n SET display_order = '{$thislinkOrder}'\n WHERE c_id = {$courseId} AND id = '{$nextlinkId}'"); break; } if ($sortrow['id'] == $thiscatlinkId) { $thislinkOrder = $sortrow['display_order']; $thislinkFound = true; } } } Display::addFlash(Display::return_message(get_lang('LinkMoved'))); }
if (isset($_GET['re_id'])) { $social_right_content .= manage_form($default); } else { // post if ($restrict) { if (!isset($_POST['group_id'])) { $default['users'] = isset($_POST['users']) ? $_POST['users'] : null; } else { $default['group_id'] = $_POST['group_id']; } if (isset($_POST['hidden_user'])) { $default['users'] = array($_POST['hidden_user']); } $social_right_content .= manage_form($default); } else { $social_right_content .= Display::return_message(get_lang('ErrorSendingMessage'), 'error'); } } } if (api_get_setting('social.allow_social_tool') == 'true') { $social_right_content .= '</div>'; $social_right_content .= '</div>'; } //$tpl = new Template(get_lang('ComposeMessage')); $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig(); // Block Social Avatar SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); if (api_get_setting('social.allow_social_tool') == 'true') { $tpl->addGlobal('social_menu_block', $social_menu_block); $tpl->addGlobal('social_right_content', $social_right_content); echo $tpl->render('@template_style/social/inbox.html.twig');
$sql = 'SELECT user.user_id FROM ' . $tbl_user . ' user INNER JOIN ' . $tbl_session_rel_user . ' reluser ON user.user_id = reluser.user_id AND reluser.relation_type<>' . SESSION_RELATION_TYPE_RRHH . ' INNER JOIN ' . $tbl_session_rel_course . ' rel_course ON rel_course.session_id = reluser.session_id WHERE user.user_id = "' . $user_id . '" AND rel_course.c_id = "' . $courseId . '"'; $result = Database::query($sql); $row = Database::fetch_array($result, 'ASSOC'); if ($row['user_id'] == $user_id || $row['user_id'] == "") { CourseManager::unsubscribe_user($_GET['user_id'], $courseCode); Display::addFlash(Display::return_message(get_lang('UserUnsubscribed'))); } else { Display::addFlash(Display::return_message(get_lang('ThisStudentIsSubscribeThroughASession'))); } } } } else { // If student can unsubscribe if (isset($_REQUEST['unregister']) && $_REQUEST['unregister'] == 'yes') { if ($course_info['unsubscribe'] == 1) { $user_id = api_get_user_id(); CourseManager::unsubscribe_user($user_id, $course_info['code']); header('Location: ' . api_get_path(WEB_PATH) . 'user_portal.php'); exit; } } } if (!$is_allowed_in_course) {