if (!isset($_GET['user'], $_GET['skill'])) { header('Location: ' . api_get_path(WEB_PATH)); exit; } $entityManager = Database::getManager(); $user = $entityManager->find('ChamiloUserBundle:User', $_GET['user']); $skill = $entityManager->find('ChamiloCoreBundle:Skill', $_GET['skill']); if (!$user || !$skill) { Display::addFlash(Display::return_message(get_lang('NoResults'), 'error')); header('Location: ' . api_get_path(WEB_PATH)); exit; } $skillUserRepo = $entityManager->getRepository('ChamiloCoreBundle:SkillRelUser'); $userSkills = $skillUserRepo->findBy(['userId' => $user->getId(), 'skillId' => $skill->getId()]); if (!$userSkills) { Display::addFlash(Display::return_message(get_lang('TheUserXNotYetAchievedTheSkillX'), 'error')); header('Location: ' . api_get_path(WEB_PATH)); exit; } $userInfo = ['id' => $user->getId(), 'complete_name' => $user->getCompleteName()]; $skillInfo = ['id' => $skill->getId(), 'name' => $skill->getName(), 'short_code' => $skill->getShortCode(), 'description' => $skill->getDescription(), 'criteria' => $skill->getCriteria(), 'badge_image' => $skill->getWebIconPath(), 'courses' => []]; $badgeAssertions = []; foreach ($userSkills as $userSkill) { $sessionId = 0; $course = $entityManager->find('ChamiloCoreBundle:Course', $userSkill->getCourseId()); $courseName = $course ? $course->getTitle() : ''; if ($userSkill->getSessionId()) { $session = $entityManager->find('ChamiloCoreBundle:Session', $userSkill->getSessionId()); $sessionId = $session->getId(); $courseName = "[{$session->getName()}] {$course->getTitle()}"; }
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);
//@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); }
api_not_allowed(true); } else { $group_info = $usergroup->get($group_id); if (empty($group_info)) { api_not_allowed(true); } $is_member = $usergroup->is_group_member($group_id); if ($group_info['visibility'] == GROUP_PERMISSION_CLOSED && !$is_member) { api_not_allowed(true); } } if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { $group_role = $usergroup->get_user_group_role(api_get_user_id(), $group_id); if (api_is_platform_admin() || in_array($group_role, array(GROUP_USER_PERMISSION_ADMIN, GROUP_USER_PERMISSION_MODERATOR))) { $usergroup->delete_topic($group_id, $topic_id); Display::addFlash(DIsplay::return_message(get_lang('Deleted'))); header("Location: group_view.php?id={$group_id}"); exit; } } $content = null; $social_right_content = ''; if (isset($_POST['action'])) { $title = isset($_POST['title']) ? $_POST['title'] : null; $content = $_POST['content']; $group_id = intval($_POST['group_id']); $parent_id = intval($_POST['parent_id']); if ($_POST['action'] == 'reply_message_group') { $title = cut($content, 50); } if ($_POST['action'] == 'edit_message_group') {
/** * Sends a message to a user/group * * @param int $receiver_user_id * @param string $subject * @param string $content * @param array $file_attachments files array($_FILES) (optional) * @param array $file_comments about attachment files (optional) * @param int $group_id (optional) * @param int $parent_id (optional) * @param int $edit_message_id id for updating the message (optional) * @param int $topic_id (optional) the default value is the current user_id * @param int $sender_id * @return bool */ public static function send_message($receiver_user_id, $subject, $content, $file_attachments = array(), $file_comments = array(), $group_id = 0, $parent_id = 0, $edit_message_id = 0, $topic_id = 0, $sender_id = null, $directMessage = false) { $table_message = Database::get_main_table(TABLE_MESSAGE); $group_id = intval($group_id); $receiver_user_id = intval($receiver_user_id); $parent_id = intval($parent_id); $edit_message_id = intval($edit_message_id); $topic_id = intval($topic_id); if (!empty($receiver_user_id)) { $receiverUserInfo = api_get_user_info($receiver_user_id); // Disabling messages for inactive users. if ($receiverUserInfo['active'] == 0) { return false; } } if (empty($sender_id)) { $user_sender_id = api_get_user_id(); } else { $user_sender_id = intval($sender_id); } $total_filesize = 0; if (is_array($file_attachments)) { foreach ($file_attachments as $file_attach) { $total_filesize += $file_attach['size']; } } // Validating fields if (empty($subject) && empty($group_id)) { Display::addFlash(Display::return_message(get_lang('YouShouldWriteASubject'), 'warning')); return false; } else { if ($total_filesize > intval(api_get_setting('message.message_max_upload_filesize'))) { $warning = sprintf(get_lang("FilesSizeExceedsX"), format_file_size(api_get_setting('message.message_max_upload_filesize'))); Display::addFlash(Display::return_message($warning, 'warning')); return false; } } $inbox_last_id = null; //Just in case we replace the and \n and \n\r while saving in the DB $content = str_replace(array("\n", "\n\r"), '<br />', $content); $now = api_get_utc_datetime(); if (!empty($receiver_user_id) || !empty($group_id)) { // message for user friend $clean_subject = Database::escape_string($subject); $clean_content = Database::escape_string($content); //message in inbox for user friend //@todo it's possible to edit a message? yes, only for groups if ($edit_message_id) { $query = " UPDATE {$table_message} SET\n update_date = '" . $now . "',\n content = '{$clean_content}'\n WHERE id = '{$edit_message_id}' "; Database::query($query); $inbox_last_id = $edit_message_id; } else { $params = ['user_sender_id' => $user_sender_id, 'user_receiver_id' => $receiver_user_id, 'msg_status' => '1', 'send_date' => $now, 'title' => $subject, 'content' => $content, 'group_id' => $group_id, 'parent_id' => $parent_id, 'update_date' => $now]; $inbox_last_id = Database::insert($table_message, $params); } // Save attachment file for inbox messages if (is_array($file_attachments)) { $i = 0; foreach ($file_attachments as $file_attach) { if ($file_attach['error'] == 0) { self::save_message_attachment_file($file_attach, $file_comments[$i], $inbox_last_id, null, $receiver_user_id, $group_id); } $i++; } } if (empty($group_id)) { // message in outbox for user friend or group $params = ['user_sender_id' => $user_sender_id, 'user_receiver_id' => $receiver_user_id, 'msg_status' => '4', 'send_date' => $now, 'title' => $subject, 'content' => $content, 'group_id' => $group_id, 'parent_id' => $parent_id, 'update_date' => $now]; $outbox_last_id = Database::insert($table_message, $params); // save attachment file for outbox messages if (is_array($file_attachments)) { $o = 0; foreach ($file_attachments as $file_attach) { if ($file_attach['error'] == 0) { self::save_message_attachment_file($file_attach, $file_comments[$o], $outbox_last_id, $user_sender_id); } $o++; } } } // Load user settings. $notification = new Notification(); $sender_info = api_get_user_info($user_sender_id); if (empty($group_id)) { $type = Notification::NOTIFICATION_TYPE_MESSAGE; if ($directMessage) { $type = Notification::NOTIFICATION_TYPE_DIRECT_MESSAGE; } $notification->save_notification($type, array($receiver_user_id), $subject, $content, $sender_info); } else { $usergroup = new UserGroup(); $group_info = $usergroup->get($group_id); $group_info['topic_id'] = $topic_id; $group_info['msg_id'] = $inbox_last_id; $user_list = $usergroup->get_users_by_group($group_id, false, array(), 0, 1000); // Adding more sense to the message group $subject = sprintf(get_lang('ThereIsANewMessageInTheGroupX'), $group_info['name']); $new_user_list = array(); foreach ($user_list as $user_data) { $new_user_list[] = $user_data['user_id']; } $group_info = array('group_info' => $group_info, 'user_info' => $sender_info); $notification->save_notification(Notification::NOTIFICATION_TYPE_GROUP, $new_user_list, $subject, $content, $group_info); } return $inbox_last_id; } return false; }
break; case 'visible': if (!$is_allowed_to_edit) { api_not_allowed(); } api_item_property_update($courseInfo, 'work', $work_id, 'visible', api_get_user_id(), null, null, null, null, $session_id); Display::addFlash(Display::return_message(get_lang('VisibilityChanged'), 'confirmation')); header('Location: ' . $currentUrl); exit; break; case 'invisible': if (!$is_allowed_to_edit) { api_not_allowed(); } api_item_property_update($courseInfo, 'work', $work_id, 'invisible', api_get_user_id(), null, null, null, null, $session_id); Display::addFlash(Display::return_message(get_lang('VisibilityChanged'), 'confirmation')); header('Location: ' . $currentUrl); exit; break; case 'list': /* Display list of student publications */ if (!empty($my_folder_data['description'])) { $content = '<p><div><strong>' . get_lang('Description') . ':</strong><p>' . Security::remove_XSS($my_folder_data['description'], STUDENT) . '</p></div></p>'; } if (api_is_allowed_to_edit() || api_is_coach()) { // Work list $content .= '<div class="toolbar-works"><a id="open-view-list" class="btn btn-primary" href="#"><i class="fa fa-users"></i> Ver Estudiantes</a></div>'; $content .= '<div class="row">'; $content .= '<div class="col-md-12">'; $content .= '<div id="work-list" class="table-responsive">'; $content .= showTeacherWorkGrid();
<?php /* For license terms, see /license.txt */ /** * Configuration script for the Buy Courses plugin * @package chamilo.plugin.buycourses */ /** * Initialization */ $cidReset = true; require_once '../../../main/inc/global.inc.php'; $plugin = BuyCoursesPlugin::create(); $includeSession = $plugin->get('include_sessions') === 'true'; api_protect_admin_script(true); Display::addFlash(Display::return_message(get_lang('Info') . ' - ' . $plugin->get_lang('CoursesInSessionsDoesntDisplayHere'), 'info')); $courses = $plugin->getCoursesForConfiguration(); //view $interbreadcrumb[] = ['url' => 'course_catalog.php', 'name' => $plugin->get_lang('CourseListOnSale')]; $interbreadcrumb[] = ['url' => 'paymentsetup.php', 'name' => get_lang('Configuration')]; $templateName = $plugin->get_lang('AvailableCourses'); $tpl = new Template($templateName); $tpl->assign('product_type_course', BuyCoursesPlugin::PRODUCT_TYPE_COURSE); $tpl->assign('product_type_session', BuyCoursesPlugin::PRODUCT_TYPE_SESSION); $tpl->assign('courses', $courses); $tpl->assign('sessions_are_included', $includeSession); if ($includeSession) { $sessions = $plugin->getSessionsForConfiguration(); $tpl->assign('sessions', $sessions); } $content = $tpl->fetch('buycourses/view/configuration.tpl');
$expiration_date = $user_data['expiration_date']; if (empty($expiration_date)) { $user_data['radio_expiration_date'] = 0; $user_data['expiration_date'] = api_get_local_time(); } else { $user_data['radio_expiration_date'] = 1; $user_data['expiration_date'] = api_get_local_time($expiration_date); } $form->setDefaults($user_data); $error_drh = false; // Validate form if ($form->validate()) { $user = $form->getSubmitValues(1); $reset_password = intval($user['reset_password']); if ($reset_password == 2 && empty($user['password'])) { Display::addFlash(Display::return_message(get_lang('PasswordIsTooShort'))); header('Location: ' . api_get_self() . '?user_id=' . $user_id); exit; } $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); if ($user['status'] == DRH && $is_user_subscribed_in_course) { $error_drh = true; } else { $picture_element = $form->getElement('picture'); $picture = $picture_element->getValue(); $picture_uri = $user_data['picture_uri']; if (isset($user['delete_picture']) && $user['delete_picture']) { $picture_uri = UserManager::delete_user_picture($user_id); } elseif (!empty($picture['name'])) { $picture_uri = UserManager::update_user_picture($user_id, $_FILES['picture']['name'], $_FILES['picture']['tmp_name']); }
//Add the JS needed to use the jqgrid $htmlHeadXtra[] = api_get_jqgrid_js(); $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $idChecked = isset($_REQUEST['idChecked']) ? $_REQUEST['idChecked'] : null; $list_type = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : 'simple'; if ($action == 'delete') { SessionManager::delete($idChecked); Display::addFlash(Display::return_message(get_lang('Deleted'))); header('Location: session_list.php'); exit; } elseif ($action == 'copy') { $result = SessionManager::copy($idChecked); if ($result) { Display::addFlash(Display::return_message(get_lang('ItemCopied'))); } else { Display::addFlash(Display::return_message(get_lang('ThereWasAnError'), 'error')); } header('Location: session_list.php'); exit; } $tool_name = get_lang('SessionList'); Display::display_header($tool_name); $url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=search_course'; $courseList = array(); $courseId = isset($_GET['course_id']) ? $_GET['course_id'] : null; if (!empty($courseId)) { $courseInfo = api_get_course_info_by_id($courseId); $parents = getParentsToString($courseInfo['categoryCode']); $courseList[$courseInfo['code']] = $parents . $courseInfo['title']; } $sessionFilter = new FormValidator('course_filter', 'get', '', '', array(), FormValidator::LAYOUT_INLINE);
Display::display_error_message(get_lang('InvallidSurvey'), false); Display::display_footer(); exit; } $urlname = api_substr(api_html_entity_decode($surveyData['title'], ENT_QUOTES), 0, 40); if (api_strlen(strip_tags($surveyData['title'])) > 40) { $urlname .= '...'; } if ($surveyData['survey_type'] == 1) { $sql = 'SELECT id FROM ' . Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP) . ' WHERE c_id = ' . $course_id . ' AND survey_id = ' . (int) $_GET['survey_id'] . ' LIMIT 1'; $rs = Database::query($sql); if (Database::num_rows($rs) === 0) { Display::addFlash(Display::return_message(get_lang('YouNeedToCreateGroups'))); header('Location: ' . api_get_path(WEB_CODE_PATH) . 'survey/survey.php?survey_id=' . (int) $_GET['survey_id']); exit; } } // Breadcrumbs $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php', 'name' => get_lang('SurveyList')); $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'survey/survey.php?survey_id=' . intval($_GET['survey_id']), 'name' => strip_tags($urlname)); // Tool name if ($_GET['action'] == 'add') { $tool_name = get_lang('AddQuestion'); } if ($_GET['action'] == 'edit') { $tool_name = get_lang('EditQuestion'); } // The possible question types
if ($form->validate()) { $values = $form->getSubmitValues(); $keyword = $values['keyword']; } $actionsRight = $form->returnForm(); $social_right_content .= Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]); } //MAIN CONTENT if (!isset($_GET['del_msg'])) { $social_right_content .= MessageManager::inbox_display(); } else { $num_msg = intval($_POST['total']); for ($i = 0; $i < $num_msg; $i++) { if ($_POST[$i]) { //the user_id was necesarry to delete a message?? Display::addFlash(MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_' . $i])); } } $social_right_content .= MessageManager::inbox_display(); } if (api_get_setting('social.allow_social_tool') == 'true') { $social_right_content .= '</div>'; } $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'); } else {
/** * It's used for destroy a course description, * render to listing view * @param int $id description type */ public function destroy($id) { $course_description = new CourseDescription(); $session_id = api_get_session_id(); $course_description->set_session_id($session_id); if (!empty($id)) { $course_description->set_id($id); $course_description->delete(); Display::addFlash(Display::return_message(get_lang('CourseDescriptionDeleted'))); } $this->listing(false); }
$user_id = api_get_user_id(); DocumentManager::unset_document_as_template($document_id_for_template, $course_code, $user_id); Display::addFlash(Display::return_message(get_lang('DocumentUnsetAsTemplate'), 'confirmation')); } } // END ACTION MENU // Attach certificate in the gradebook if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && isset($_GET['set_certificate']) && $_GET['set_certificate'] == strval(intval($_GET['set_certificate']))) { if (isset($_GET['cidReq'])) { $course_id = Security::remove_XSS($_GET['cidReq']); // course id $document_id = Security::remove_XSS($_GET['set_certificate']); // document id DocumentManager::attach_gradebook_certificate($course_id, $document_id); $message = Display::return_message(get_lang('IsDefaultCertificate'), 'normal'); Display::addFlash($message); } } /* GET ALL DOCUMENT DATA FOR CURDIRPATH */ if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { $documentAndFolders = DocumentManager::get_all_document_data($courseInfo, $curdirpath, $groupId, null, $is_allowed_to_edit || $group_member_with_upload_rights, true); } else { $documentAndFolders = DocumentManager::get_all_document_data($courseInfo, $curdirpath, $groupId, null, $is_allowed_to_edit || $group_member_with_upload_rights, false); } if ($groupId != 0) { $userAccess = GroupManager::user_has_access(api_get_user_id(), $groupId, GroupManager::GROUP_TOOL_DOCUMENTS); if ($userAccess) { $folders = DocumentManager::get_all_document_folders($courseInfo, $groupId, $is_allowed_to_edit || $group_member_with_upload_rights); } } else { $folders = DocumentManager::get_all_document_folders($courseInfo, $groupId, $is_allowed_to_edit || $group_member_with_upload_rights);
/** * @param User $user */ public static function sendResetEmail(User $user) { //if (null === $user->getConfirmationToken()) { $uniqueId = api_get_unique_id(); $user->setConfirmationToken($uniqueId); $user->setPasswordRequestedAt(new \DateTime()); Database::getManager()->persist($user); Database::getManager()->flush(); $url = api_get_path(WEB_CODE_PATH) . 'auth/reset.php?token=' . $uniqueId; $mailTemplate = new Template(null, false, false, false, false, false); $mailTemplate->assign('complete_user_name', $user->getCompleteName()); $mailTemplate->assign('link', $url); $mailLayout = $mailTemplate->get_template('mail/reset_password.tpl'); $mailSubject = get_lang('ResetPasswordInstructions'); $mailBody = $mailTemplate->fetch($mailLayout); api_mail_html($user->getCompleteName(), $user->getEmail(), $mailSubject, $mailBody); Display::addFlash(Display::return_message(get_lang('CheckYourEmailAndFollowInstructions'))); //} }
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); if ($user) { if (!$user->isPasswordRequestNonExpired($ttl)) { Display::addFlash(Display::return_message(get_lang('LinkExpired')), 'warning'); header('Location: ' . api_get_path(WEB_CODE_PATH) . 'auth/lostPassword.php'); exit; } $user->setPlainPassword($password); $userManager = UserManager::getManager(); $userManager->updateUser($user, true); $user->setConfirmationToken(null); $user->setPasswordRequestedAt(null); Database::getManager()->persist($user); Database::getManager()->flush(); Display::addFlash(Display::return_message(get_lang('Updated'))); header('Location: ' . api_get_path(WEB_PATH)); exit; } else { Display::addFlash(Display::return_message(get_lang('LinkExpired'))); } } $tpl->assign('form', $form->toHtml()); $content = $tpl->get_template('auth/set_temp_password.tpl'); $tpl->assign('content', $tpl->fetch($content)); $tpl->display_one_col_template();
$newMp3DocumentId = DocumentManager::addAndConvertWavToMp3( $documentData, $courseInfo, api_get_session_id(), api_get_user_id(), 'overwrite', true ); if ($newMp3DocumentId) { $newDocId = $newMp3DocumentId; } if (isset($_REQUEST['lp_item_id']) && !empty($_REQUEST['lp_item_id'])) { $lpItemId = $_REQUEST['lp_item_id']; /** @var learnpath $lp */ $lp = isset($_SESSION['oLP']) ? $_SESSION['oLP'] : null; if (!empty($lp)) { $lp->set_modified_on(); $lpItem = new learnpathItem($lpItemId); $lpItem->add_audio_from_documents($newDocId); Display::addFlash( Display::return_message(get_lang('Updated'), 'info') ); } } } else { Display::addFlash($contents); }
if (count($inserted_in_course) > 1) { $warn = get_lang('SeveralCoursesSubscribedToSessionBecauseOfSameVisualCode') . ': '; foreach ($inserted_in_course as $code => $title) { $warn .= ' ' . $title . ' (' . $code . '),'; } $warn = substr($warn, 0, -1); } if ($session_counter == 1) { if ($file_type == 'csv') { $session_id = current($sessionList); } Display::addFlash(Display::return_message($warn)); header('Location: resume_session.php?id_session=' . $session_id); exit; } else { Display::addFlash(Display::return_message(get_lang('FileImported') . ' ' . $error_message)); header('Location: session_list.php'); exit; } } else { $error_message = get_lang('NoInputFile'); } } // Display the header. Display::display_header($tool_name); if (count($inserted_in_course) > 1) { $msg = get_lang('SeveralCoursesSubscribedToSessionBecauseOfSameVisualCode') . ': '; foreach ($inserted_in_course as $code => $title) { $msg .= ' ' . $title . ' (' . $title . '),'; } $msg = substr($msg, 0, -1);
/** * Creates a new user for the platform * @author Hugues Peeters <*****@*****.**>, * @author Roan Embrechts <*****@*****.**> * @param string Firstname * @param string Lastname * @param int Status (1 for course tutor, 5 for student, 6 for anonymous) * @param string e-mail address * @param string Login * @param string Password * @param string Any official code (optional) * @param string User language (optional) * @param string Phone number (optional) * @param string Picture URI (optional) * @param string Authentication source (optional, defaults to 'platform', dependind on constant) * @param string Account expiration date (optional, defaults to null) * @param int Whether the account is enabled or disabled by default * @param int The department of HR in which the user is registered (optional, defaults to 0) * @param array Extra fields * @param string Encrypt method used if password is given encrypted. Set to an empty string by default * @param bool $send_mail * @param bool $isAdmin * * @return mixed new user id - if the new user creation succeeds, false otherwise * @desc The function tries to retrieve user id from the session. * If it exists, the current user id is the creator id. If a problem arises, * it stores the error message in global $api_failureList * @assert ('Sam','Gamegie',5,'*****@*****.**','jo','jo') > 1 * @assert ('Pippin','Took',null,null,'jo','jo') === false */ public static function create_user($firstName, $lastName, $status, $email, $loginName, $password, $official_code = '', $language = '', $phone = '', $picture_uri = '', $auth_source = PLATFORM_AUTH_SOURCE, $expirationDate = null, $active = 1, $hr_dept_id = 0, $extra = null, $encrypt_method = '', $send_mail = false, $isAdmin = false) { $currentUserId = api_get_user_id(); $hook = HookCreateUser::create(); if (!empty($hook)) { $hook->notifyCreateUser(HOOK_EVENT_TYPE_PRE); } global $_configuration; $original_password = $password; $access_url_id = 1; if (api_get_multiple_access_url()) { $access_url_id = api_get_current_access_url_id(); } if (is_array($_configuration[$access_url_id]) && isset($_configuration[$access_url_id]['hosting_limit_users']) && $_configuration[$access_url_id]['hosting_limit_users'] > 0) { $num = self::get_number_of_users(); if ($num >= $_configuration[$access_url_id]['hosting_limit_users']) { api_warn_hosting_contact('hosting_limit_users'); Display::addFlash(Display::return_message(get_lang('PortalUsersLimitReached'), 'warning')); return false; } } if ($status === 1 && is_array($_configuration[$access_url_id]) && isset($_configuration[$access_url_id]['hosting_limit_teachers']) && $_configuration[$access_url_id]['hosting_limit_teachers'] > 0) { $num = self::get_number_of_users(1); if ($num >= $_configuration[$access_url_id]['hosting_limit_teachers']) { Display::addFlash(Display::return_message(get_lang('PortalTeachersLimitReached'), 'warning')); api_warn_hosting_contact('hosting_limit_teachers'); return false; } } if (empty($password)) { Display::addFlash(Display::return_message(get_lang('ThisFieldIsRequired') . ': ' . get_lang('Password'), 'warning')); return false; } // database table definition $table_user = Database::get_main_table(TABLE_MAIN_USER); //Checking the user language $languages = api_get_languages(); $language = strtolower($language); if (!in_array($language, $languages['folder'])) { $language = api_get_setting('platformLanguage'); } if (!empty($currentUserId)) { $creator_id = $currentUserId; } else { $creator_id = ''; } // First check wether the login already exists if (!self::is_username_available($loginName)) { return api_set_failure('login-pass already taken'); } $currentDate = api_get_utc_datetime(); $now = new DateTime($currentDate); if (empty($expirationDate)) { // Default expiration date // if there is a default duration of a valid account then // we have to change the expiration_date accordingly if (api_get_setting('account_valid_duration') != '') { $expirationDate = new DateTime($currentDate); $days = intval(api_get_setting('account_valid_duration')); $expirationDate->modify('+' . $days . ' day'); } } else { $expirationDate = api_get_utc_datetime($expirationDate); $expirationDate = new \DateTime($expirationDate, new DateTimeZone('UTC')); } $userManager = self::getManager(); /** @var User $user */ $user = $userManager->createUser(); $user->setLastname($lastName)->setFirstname($firstName)->setUsername($loginName)->setStatus($status)->setPlainPassword($password)->setEmail($email)->setOfficialCode($official_code)->setPictureUri($picture_uri)->setCreatorId($creator_id)->setAuthSource($auth_source)->setPhone($phone)->setLanguage($language)->setRegistrationDate($now)->setHrDeptId($hr_dept_id)->setActive($active); if (!empty($expirationDate)) { $user->setExpirationDate($expirationDate); } $userManager->updateUser($user, true); $userId = $user->getId(); if (!empty($userId)) { $return = $userId; $sql = "UPDATE {$table_user} SET user_id = {$return} WHERE id = {$return}"; Database::query($sql); if ($isAdmin) { UserManager::add_user_as_admin($userId); } if (api_get_multiple_access_url()) { UrlManager::add_user_to_url($return, api_get_current_access_url_id()); } else { //we are adding by default the access_url_user table with access_url_id = 1 UrlManager::add_user_to_url($return, 1); } if (!empty($email) && $send_mail) { $recipient_name = api_get_person_name($firstName, $lastName, null, PERSON_NAME_EMAIL_ADDRESS); $tplSubject = new Template(null, false, false, false, false, false); $layoutSubject = $tplSubject->get_template('mail/subject_registration_platform.tpl'); $emailSubject = $tplSubject->fetch($layoutSubject); $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); $email_admin = api_get_setting('emailAdministrator'); if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url = api_get_access_url($access_url_id); } } else { $url = $_configuration['root_web']; } $tplContent = new Template(null, false, false, false, false, false); // variables for the default template $tplContent->assign('complete_name', stripslashes(api_get_person_name($firstName, $lastName))); $tplContent->assign('login_name', $loginName); $tplContent->assign('original_password', stripslashes($original_password)); $tplContent->assign('mailWebPath', $url); $layoutContent = $tplContent->get_template('mail/content_registration_platform.tpl'); $emailBody = $tplContent->fetch($layoutContent); /* MANAGE EVENT WITH MAIL */ if (EventsMail::check_if_using_class('user_registration')) { $values["about_user"] = $return; $values["password"] = $original_password; $values["send_to"] = array($return); $values["prior_lang"] = null; EventsDispatcher::events('user_registration', $values); } else { $phoneNumber = isset($extra['mobile_phone_number']) ? $extra['mobile_phone_number'] : null; $additionalParameters = array('smsType' => SmsPlugin::WELCOME_LOGIN_PASSWORD, 'userId' => $return, 'mobilePhoneNumber' => $phoneNumber, 'password' => $original_password); api_mail_html($recipient_name, $email, $emailSubject, $emailBody, $sender_name, $email_admin, null, null, null, $additionalParameters); } /* ENDS MANAGE EVENT WITH MAIL */ } Event::addEvent(LOG_USER_CREATE, LOG_USER_ID, $return); } else { return api_set_failure('error inserting in Database'); } if (is_array($extra) && count($extra) > 0) { $res = true; foreach ($extra as $fname => $fvalue) { $res = $res && self::update_extra_field_value($return, $fname, $fvalue); } } self::update_extra_field_value($return, 'already_logged_in', 'false'); if (!empty($hook)) { $hook->setEventData(array('return' => $return, 'originalPassword' => $original_password)); $hook->notifyCreateUser(HOOK_EVENT_TYPE_POST); } return $return; }
} } } } if (!empty($list_register_user)) { if ($is_suscribe_counter == 1) { $register_user_message = $temp_unique_user . ' ' . get_lang('AddedToCourse'); Display::addFlash(Display::return_message($register_user_message)); } else { $register_user_message = get_lang('UsersRegistered') . '<br/><br />' . $list_register_user; Display::addFlash(Display::return_message($register_user_message, 'normal', false)); } } if (!empty($list_not_register_user)) { $not_register_user_message = get_lang('UsersNotRegistered') . '<br/><br /><br />' . $list_not_register_user; Display::addFlash(Display::return_message($not_register_user_message, 'error', false)); } header('Location:' . api_get_path(WEB_CODE_PATH) . 'user/user.php?' . api_get_cidreq() . '&type=' . $type); exit; break; } } if (!empty($_SESSION['session_user_id'])) { unset($_SESSION['session_user_id']); } if (!empty($_SESSION['session_user_name'])) { unset($_SESSION['session_user_name']); } $is_western_name_order = api_is_western_name_order(); $sort_by_first_name = api_sort_by_first_name(); // Build table
} 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']);
} if (count($errors) != 0) { $warning_message = '<ul>'; foreach ($errors as $index => $error_user) { $email = isset($error_user['Email']) ? ' - ' . $error_user['Email'] : null; $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']) . ' ' . $email; $warning_message .= '</li>'; } $warning_message .= '</ul>'; } if ($error_kind_file) { Display::addFlash(Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption'), 'warning')); } else { Display::addFlash(Display::return_message($warning_message)); header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?sec_token=' . $tok); exit; } } Display::display_header($tool_name); if (!empty($error_message)) { Display::display_error_message($error_message); } $form = new FormValidator('user_import', 'post', 'user_import.php'); $form->addElement('header', '', $tool_name); $form->addElement('hidden', 'formSent'); $form->addElement('file', 'import_file', get_lang('ImportFileLocation')); $group = array($form->createElement('radio', 'file_type', '', 'CSV (<a href="example.csv" target="_blank">' . get_lang('ExampleCSVFile') . '</a>)', 'csv'), $form->createElement('radio', 'file_type', null, 'XML (<a href="example.xml" target="_blank">' . get_lang('ExampleXMLFile') . '</a>)', 'xml')); $form->addGroup($group, '', get_lang('FileType'), '<br/>'); $group = array($form->createElement('radio', 'sendMail', '', get_lang('Yes'), 1), $form->createElement('radio', 'sendMail', null, get_lang('No'), 0));
/** * 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'))); }
$userInfo = api_get_user_info($sale['user_id']); $form = new FormValidator('success', 'POST', api_get_self(), null, null, FormValidator::LAYOUT_INLINE); if ($form->validate()) { $formValues = $form->getSubmitValues(); if (isset($formValues['cancel'])) { $plugin->cancelSale($sale['id']); unset($_SESSION['bc_sale_id']); header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/index.php'); exit; } $messageTemplate = new Template(); $messageTemplate->assign('user', $userInfo); $messageTemplate->assign('sale', ['date' => api_format_date($sale['date'], DATE_FORMAT_LONG_NO_DAY), 'product' => $sale['product_name'], 'currency' => $currency['iso_code'], 'price' => $sale['price'], 'reference' => $sale['reference']]); $messageTemplate->assign('transfer_accounts', $transferAccounts); api_mail_html($userInfo['complete_name'], $userInfo['email'], $plugin->get_lang('bc_subject'), $messageTemplate->fetch('buycourses/view/message_transfer.tpl')); Display::addFlash(Display::return_message(sprintf($plugin->get_lang('PurchaseStatusX'), $plugin->get_lang('PendingReasonByTransfer')), 'success', false)); unset($_SESSION['bc_sale_id']); header('Location: ' . api_get_path(WEB_PLUGIN_PATH) . 'buycourses/src/course_catalog.php'); exit; } $form->addButton('confirm', $plugin->get_lang('ConfirmOrder'), 'check', 'success'); $form->addButtonCancel($plugin->get_lang('CancelOrder'), 'cancel'); $template = new Template(); if ($buyingCourse) { $template->assign('course', $course); } elseif ($buyingSession) { $template->assign('session', $session); } $template->assign('buying_course', $buyingCourse); $template->assign('buying_session', $buyingSession); $template->assign('title', $sale['product_name']);
$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) {
/** * This function saves a question in the database. * This can be either an update of an existing survey or storing a new survey * @param array $survey_data * @param array $form_content all the information of the form * * @author Patrick Cool <*****@*****.**>, Ghent University * @version January 2007 */ public static function save_question($survey_data, $form_content) { $return_message = ''; if (strlen($form_content['question']) > 1) { // Checks length of the question $empty_answer = false; if ($survey_data['survey_type'] == 1) { if (empty($form_content['choose'])) { $return_message = 'PleaseChooseACondition'; return $return_message; } if ($form_content['choose'] == 2 && $form_content['assigned1'] == $form_content['assigned2']) { $return_message = 'ChooseDifferentCategories'; return $return_message; } } if ($form_content['type'] != 'percentage') { if (isset($form_content['answers'])) { for ($i = 0; $i < count($form_content['answers']); $i++) { if (strlen($form_content['answers'][$i]) < 1) { $empty_answer = true; break; } } } } if ($form_content['type'] == 'score') { if (strlen($form_content['maximum_score']) < 1) { $empty_answer = true; } } $additional = array(); $course_id = api_get_course_int_id(); if (!$empty_answer) { // Table definitions $tbl_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION); // Getting all the information of the survey $survey_data = SurveyManager::get_survey($form_content['survey_id']); // Storing the question in the shared database if (is_numeric($survey_data['survey_share']) && $survey_data['survey_share'] != 0) { $shared_question_id = SurveyManager::save_shared_question($form_content, $survey_data); $form_content['shared_question_id'] = $shared_question_id; } // Storing a new question if ($form_content['question_id'] == '' || !is_numeric($form_content['question_id'])) { // Finding the max sort order of the questions in the given survey $sql = "SELECT max(sort) AS max_sort\n\t\t\t\t\t FROM {$tbl_survey_question}\n WHERE c_id = {$course_id} AND survey_id='" . intval($form_content['survey_id']) . "'"; $result = Database::query($sql); $row = Database::fetch_array($result, 'ASSOC'); $max_sort = $row['max_sort']; // Some variables defined for survey-test type $extraParams = []; if (isset($_POST['choose'])) { if ($_POST['choose'] == 1) { $extraParams['survey_group_pri'] = $_POST['assigned']; } elseif ($_POST['choose'] == 2) { $extraParams['survey_group_sec1'] = $_POST['assigned1']; $extraParams['survey_group_sec2'] = $_POST['assigned2']; } } $questionComment = isset($form_content['question_comment']) ? $form_content['question_comment'] : ''; $maxScore = isset($form_content['maximum_score']) ? $form_content['maximum_score'] : ''; $display = isset($form_content['horizontalvertical']) ? $form_content['horizontalvertical'] : ''; $params = ['c_id' => $course_id, 'survey_id' => $form_content['survey_id'], 'survey_question' => $form_content['question'], 'survey_question_comment' => $questionComment, 'type' => $form_content['type'], 'display' => $display, 'sort' => $max_sort + 1, 'shared_question_id' => $form_content['shared_question_id'], 'max_value' => $maxScore]; $params = array_merge($params, $extraParams); $question_id = Database::insert($tbl_survey_question, $params); if ($question_id) { $sql = "UPDATE {$tbl_survey_question} SET question_id = {$question_id}\n WHERE iid = {$question_id}"; Database::query($sql); $form_content['question_id'] = $question_id; $return_message = 'QuestionAdded'; } } else { // Updating an existing question $extraParams = []; if (isset($_POST['choose'])) { if ($_POST['choose'] == 1) { $extraParams['survey_group_pri'] = $_POST['assigned']; $extraParams['survey_group_sec1'] = 0; $extraParams['survey_group_sec2'] = 0; } elseif ($_POST['choose'] == 2) { $extraParams['survey_group_pri'] = 0; $extraParams['survey_group_sec1'] = $_POST['assigned1']; $extraParams['survey_group_sec2'] = $_POST['assigned2']; } } $maxScore = isset($form_content['maximum_score']) ? $form_content['maximum_score'] : null; $questionComment = isset($form_content['question_comment']) ? $form_content['question_comment'] : null; // Adding the question to the survey_question table $params = ['survey_question' => $form_content['question'], 'survey_question_comment' => $questionComment, 'display' => $form_content['horizontalvertical']]; $params = array_merge($params, $extraParams); Database::update($tbl_survey_question, $params, ['c_id = ? AND question_id = ?' => [$course_id, $form_content['question_id']]]); $return_message = 'QuestionUpdated'; } if (!empty($form_content['survey_id'])) { //Updating survey api_item_property_update(api_get_course_info(), TOOL_SURVEY, $form_content['survey_id'], 'SurveyUpdated', api_get_user_id()); } // Storing the options of the question SurveyManager::save_question_options($form_content, $survey_data); } else { $return_message = 'PleasFillAllAnswer'; } } else { $return_message = 'PleaseEnterAQuestion'; } if (!empty($return_message)) { Display::addFlash(Display::return_message(get_lang($return_message))); } return $return_message; }
$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);
origin.options[i]=null; i = i-1; } } } </script>'; $formSent = 0; $firstLetterSession = isset($_POST['firstLetterSession']) ? $_POST['firstLetterSession'] : null; $errorMsg = ''; $UserList = array(); if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) { $sessions_list = $_POST['SessionsList']; $userInfo = api_get_user_info($user_id); $affected_rows = SessionManager::suscribe_sessions_to_hr_manager($userInfo, $sessions_list); if ($affected_rows) { Display::addFlash(Display::return_message(get_lang('AssignedSessionsHaveBeenUpdatedSuccessfully'))); } } // display header Display::display_header($tool_name); // actions if ($user_info['status'] != SESSIONADMIN) { $actionsLeft = '<a href="dashboard_add_users_to_user.php?user='******'">' . Display::return_icon('add-user.png', get_lang('AssignUsers'), null, ICON_SIZE_MEDIUM) . '</a>'; $actionsLeft .= '<a href="dashboard_add_courses_to_user.php?user='******'">' . Display::return_icon('course-add.png', get_lang('AssignCourses'), null, ICON_SIZE_MEDIUM) . '</a>'; } echo Display::toolbarAction('toolbar-dashboard', array(0 => $actionsLeft, 1 => '')); echo Display::page_header(sprintf(get_lang('AssignSessionsToX'), api_get_person_name($user_info['firstname'], $user_info['lastname'])), null, 'h3'); $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id); $assigned_sessions_id = array_keys($assigned_sessions_to_hrm); $without_assigned_sessions = ''; if (count($assigned_sessions_id) > 0) {
// 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;
/** * Unsubscribe user from a course * render to listing view * @param string Course code */ public function unsubscribe_user_from_course($course_code, $search_term = null, $category_code = null) { $result = $this->model->remove_user_from_course($course_code); $message = ''; $error = ''; if ($result) { Display::addFlash(Display::return_message(get_lang('YouAreNowUnsubscribed'))); } $action = 'sortmycourses'; if (!empty($search_term)) { $this->search_courses($search_term, $message, $error); } else { $this->courses_categories('subcribe', $category_code, $message, $error); } }