echo $post['title']; ?> </title> <link><?php echo Option::get('siteurl') . '/blog/' . $post['slug']; ?> </link> <guid><?php echo Option::get('siteurl') . '/blog/' . $post['slug']; ?> </guid> <pubDate><?php echo Date::format($post['date'], 'd M Y'); ?> </pubDate> <description><![CDATA[<?php echo Text::toHtml(Text::cut(File::getContent(STORAGE . DS . 'pages' . DS . $post['id'] . '.page.txt'), 300)); ?> ]]></description> <author><?php echo $post['author']; ?> </author> </item> <?php } ?> </channel> </rss> <?php Response::status(200);
private function getSlugAfterFilter($filter) { if ($filter == '/') { $filter = HTML_PATH_ROOT; } // Check if the filter is in the uri. $position = Text::strpos($this->uri, $filter); if ($position === false) { return false; } $start = $position + Text::length($filter); $end = $this->uriStrlen; $slug = Text::cut($this->uri, $start, $end); $this->slug = trim($slug, '/'); return $slug; }
/** * @param array $category_list * @param string $type * @return null|string */ public static function draw_category_label($category_list, $type = 'label') { $new_category_list = array(); foreach ($category_list as $category) { $category_name = $category['title']; $category_name_cut = Text::cut($category['title'], 20); switch ($type) { case 'label': // Global cat /* $parentId = isset($category['parent_id']) && !empty($category['parent_id']) ? $category['parent_id'] : null; if (empty($parentId)) { $new_category_list[] = Display::label($category_name, 'info'); } else { // Local cat $new_category_list[] = Display::label($category_name, 'success'); }*/ $courseId = isset($category['c_id']) && !empty($category['c_id']) ? $category['c_id'] : null; if (empty($courseId)) { $new_category_list[] = Display::label($category_name_cut, 'info', $category_name); } else { // Local cat $new_category_list[] = Display::label($category_name_cut, 'success', $category_name); } break; case 'header': $new_category_list[] = $category_name; break; } } $html = null; if (!empty($new_category_list)) { switch ($type) { case 'label': $html = implode(' ', $new_category_list); break; case 'header': $html = Display::page_subheader3(get_lang('Category') . ': ' . implode(', ', $new_category_list)); break; } } return $html; }
$count_users_group = count($usergroup->get_all_users_by_group($id)); if ($count_users_group == 1) { $count_users_group = $count_users_group . ' ' . get_lang('Member'); } else { $count_users_group = $count_users_group . ' ' . get_lang('Members'); } $picture = $usergroup->get_picture_group($group['id'], $group['picture'], 80); $tags = $usergroup->get_group_tags($group['id']); $group['picture'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="4" height="50" border="2" align="left" width="50" />'; $item_0 = Display::div($group['picture'], array('class' => 'box_description_group_image')); $members = Display::span($count_users_group, array('class' => 'box_description_group_member')); $item_1 = Display::div(Display::tag('h3', $url_open . $name . $url_close) . $members, array('class' => 'box_description_group_title')); $item_2 = ''; $item_3 = ''; if ($group['description'] != '') { $item_3 = '<div class="box_description_group_content" >' . Text::cut($group['description'], 100, true) . '</div>'; } else { $item_2 = '<div class="box_description_group_title" ><span class="social-groups-text2"></span></div>'; $item_3 = '<div class="box_description_group_content" ></div>'; } $item_4 = '<div class="box_description_group_tags" >' . $tags . '</div>'; $item_5 = '<div class="box_description_group_actions" >' . $url_open . get_lang('SeeMore') . $url_close . '</div>'; $grid_item_2 = $item_0 . $item_1 . $item_2 . $item_3 . $item_4 . $item_5; $grid_groups[] = array('', $grid_item_2); } } $visibility = array(true, true, true, true, true); $social_right_content .= Display::return_sortable_grid('mygroups', array(), $grid_groups, array('hide_navigation' => true, 'per_page' => 5), $query_vars, false, $visibility); } $app['title'] = $tool_name; $tpl = $app['template'];
/** * Creates a list with all the exercises (quiz) in it * @return string */ public function get_exercises() { $course_id = api_get_course_int_id(); // New for hotpotatoes. $uploadPath = DIR_HOTPOTATOES; //defined in main_api $tbl_doc = Database::get_course_table(TABLE_DOCUMENT); $tbl_quiz = Database::get_course_table(TABLE_QUIZ_TEST); $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id); $sql_quiz = "SELECT * FROM {$tbl_quiz} WHERE c_id = {$course_id} AND active<>'-1' {$condition_session} ORDER BY title ASC"; $sql_hot = "SELECT * FROM {$tbl_doc} WHERE c_id = {$course_id} AND path LIKE '" . $uploadPath . "/%/%htm%' {$condition_session} ORDER BY id ASC"; $res_quiz = Database::query($sql_quiz); $res_hot = Database::query($sql_hot); $return = '<ul class="lp_resource">'; $return .= '<li class="lp_resource_element">'; $return .= Display::return_icon('new_test_small.gif'); $return .= '<a href="' . api_get_path(REL_CODE_PATH) . 'exercice/exercise_admin.php?lp_id=' . $this->lp_id . '">' . get_lang('NewExercise') . '</a>'; $return .= '</li>'; // Display hotpotatoes while ($row_hot = Database::fetch_array($res_hot)) { $return .= '<li class="lp_resource_element" data_id="' . $row_hot['id'] . '" data_type="hotpotatoes" title="' . $row_hot['title'] . '" >'; $return .= '<a class="moved" href="#">'; $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); $return .= '</a> '; $return .= Display::return_icon('hotpotatoes_s.png'); $return .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=add_item&type=' . TOOL_HOTPOTATOES . '&file=' . $row_hot['id'] . '&lp_id=' . $this->lp_id . '">' . (!empty($row_hot['comment']) ? $row_hot['comment'] : Security::remove_XSS($row_hot['title'])) . '</a>'; $return .= '</li>'; } while ($row_quiz = Database::fetch_array($res_quiz)) { $return .= '<li class="lp_resource_element" data_id="' . $row_quiz['iid'] . '" data_type="quiz" title="' . $row_quiz['title'] . '" >'; $return .= '<a class="moved" href="#">'; $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY); $return .= '</a> '; $return .= Display::return_icon('quizz_small.gif'); $return .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=add_item&type=' . TOOL_QUIZ . '&file=' . $row_quiz['iid'] . '&lp_id=' . $this->lp_id . '">' . Security::remove_XSS(Text::cut($row_quiz['title'], 80)) . '</a>'; $return .= '</li>'; } $return .= '</ul>'; return $return; }
<div class="span3"> <a class="profile_link" href="' . $userInfo['profile_url'] . '">' . $userInfo['complete_name'] . '</a> <div>' . $title . ' : ' . $content . '</div> <div>' . get_lang('DateSend') . ' : ' . $date . '</div> </div> </div>'; } } if (count($pending_invitations) > 0) { $social_right_content .= Display::page_subheader(get_lang('GroupsWaitingApproval')); $new_invitation = array(); foreach ($pending_invitations as $invitation) { $picture = $usergroup->get_picture_group($invitation['id'], $invitation['picture'], 80); $img = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="4" height="50" border="2" align="left" width="50" />'; $invitation['picture'] = '<a href="groups.php?id=' . $invitation['id'] . '">' . $img . '</a>'; $invitation['name'] = '<a href="groups.php?id=' . $invitation['id'] . '">' . Text::cut($invitation['name'], 120, true) . '</a>'; $invitation['join'] = '<a class="btn btn-primary" href="invitations.php?accept=' . $invitation['id'] . '">' . get_lang('AcceptInvitation') . '</a>'; $invitation['deny'] = '<a class="btn btn-danger" href="invitations.php?deny=' . $invitation['id'] . '">' . get_lang('DenyInvitation') . '</a>'; $invitation['description'] = Text::cut($invitation['description'], 220, true); $new_invitation[] = $invitation; } $social_right_content .= Display::return_sortable_grid('waiting_user', array(), $new_invitation, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, true, true, false, false, true, true, true, true)); } $social_right_content = Display::div($social_right_content, array('class' => 'span9')); $tpl = $app['template']; $tpl->assign('social_left_content', $social_left_content); $tpl->assign('social_right_content', $social_right_content); $tpl->assign('message', $show_message); $tpl->assign('content', $content); $social_layout = $tpl->get_template('layout/social_layout.tpl'); $tpl->display($social_layout);
private function getSlugAfterFilter($filter) { // Remove both slash from the filter $filter = trim($filter, '/'); // Add to the filter the root directory $filter = HTML_PATH_ROOT . $filter; // Check if the filter is in the uri. $position = Text::stringPosition($this->uri, $filter); // If the position is FALSE, the filter isn't in the URI. if ($position === false) { return false; } // Start position to cut $start = $position + Text::length($filter); // End position to cut $end = $this->uriStrlen; // Get the slug from the URI $slug = Text::cut($this->uri, $start, $end); if (Text::isEmpty($slug)) { return ''; } if ($slug[0] == '/') { return ltrim($slug, '/'); } if ($filter == HTML_PATH_ROOT) { return $slug; } return false; }
/** @var Question $objQuestionTmp */ $objQuestionTmp = Question::read($id); $question_class = get_class($objQuestionTmp); $clone_link = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&clone_question=' . $id . '">' . Display::return_icon('cd.gif', get_lang('Copy'), array(), ICON_SIZE_SMALL) . '</a>'; $edit_link = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&type=' . $objQuestionTmp->selectType() . '&myid=1&editQuestion=' . $id . '">' . Display::return_icon('edit.png', get_lang('Modify'), array(), ICON_SIZE_SMALL) . '</a>'; if ($objExercise->edit_exercise_in_lp == true) { $delete_link = '<a id="delete_' . $id . '" class="opener" href="' . api_get_self() . '?' . api_get_cidreq() . '&exerciseId=' . $exerciseId . '&deleteQuestion=' . $id . '" >' . Display::return_icon('delete.png', get_lang('RemoveFromTest'), array(), ICON_SIZE_SMALL) . '</a>'; } $edit_link = Display::tag('div', $edit_link, array('style' => 'float:left; padding:0px; margin:0px')); $clone_link = Display::tag('div', $clone_link, array('style' => 'float:left; padding:0px; margin:0px')); $delete_link = Display::tag('div', $delete_link, array('style' => 'float:left; padding:0px; margin:0px')); $actions = Display::tag('div', $edit_link . $clone_link . $delete_link, array('class' => 'edition', 'style' => 'width:100px; right:10px; margin-top: 0px; position: absolute; top: 10%;')); $title = Security::remove_XSS($objQuestionTmp->selectTitle()); $move = Display::return_icon('all_directions.png', get_lang('Move'), array('class' => 'moved', 'style' => 'margin-bottom:-0.5em;')); // Question name $questionName = Display::tag('div', '<a href="#" title = "' . $title . '">' . $move . ' ' . Text::cut($title, 42) . '</a>', array('style' => $styleQuestion)); // Question type. list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html(); $question_media = null; if (!empty($objQuestionTmp->parent_id)) { $objQuestionMedia = Question::read($objQuestionTmp->parent_id); $question_media = ' ' . Question::getMediaLabel($objQuestionMedia->question); } $questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM), array('style' => $styleType)); // Question category. $category_labels = Testcategory::return_category_labels($objQuestionTmp->category_list, $category_list); if (empty($category_labels)) { $category_labels = ""; } $questionCategory = Display::tag('div', '<a href="#" style="padding:0px; margin:0px;">' . $category_labels . $question_media . '</a>', array('style' => $styleCat)); // Question level.
} $label_attributes = array(); $label_attributes['class'] = 'checkbox'; $label_attributes['for'] = $check_id; $label_attributes['class'] = "checkbox"; if (in_array($objQuestionTmp->type, Question::question_type_no_review())) { $attributes['disabled'] = 'disabled'; } $checkbox = Display::input('checkbox', 'remind_list[' . $questionId . ']', '', $attributes); $url = $urlMainExercise . 'exercise_submit.php?exerciseId=' . $objExercise->id . '&num=' . $counter . '&reminder=1'; $counter++; if ($objExercise->type == ONE_PER_PAGE) { $question_title = Display::url($counter . '. ' . Text::cut($objQuestionTmp->selectTitle(), 40), $url); $question_title = $counter . '. ' . Text::cut($objQuestionTmp->selectTitle(), 40); } else { $question_title = $counter . '. ' . Text::cut($objQuestionTmp->selectTitle(), 40); } //Check if the question doesn't have an answer if (!in_array($questionId, $exercise_result)) { $question_title = Display::label($question_title, 'warning'); } $rootCategories = null; global $app; $repo = $app['orm.em']->getRepository('Entity\\CQuizCategory'); foreach ($objQuestionTmp->category_list as $categoryId) { $cat = $repo->find($categoryId); $parentCat = $repo->getPath($cat); if (isset($parentCat[0])) { $rootCategories .= $parentCat[0]->getTitle(); } }
$document_id = intval($_GET['id']); $course_info = api_get_course_info(); $course_code = api_get_course_id(); if (empty($course_info)) { api_not_allowed(true); } //Generate path if (!$document_id) { $document_id = DocumentManager::get_document_id($course_info, $header_file); } $document_data = DocumentManager::get_document_data_by_id($document_id, $course_code); if (empty($document_data)) { api_not_allowed(true); } $header_file = $document_data['path']; $name_to_show = Text::cut($header_file, 80); $path_array = explode('/', str_replace('\\', '/', $header_file)); $path_array = array_map('urldecode', $path_array); $header_file = implode('/', $path_array); $file = Security::remove_XSS(urldecode($document_data['path'])); $file_root = $course_info['path'] . '/document' . str_replace('%2F', '/', $file); $file_url_sys = api_get_path(SYS_COURSE_PATH) . $file_root; $file_url_web = api_get_path(WEB_COURSE_PATH) . $file_root; if (!file_exists($file_url_sys)) { api_not_allowed(true); } if (is_dir($file_url_sys)) { api_not_allowed(true); } //Check user visibility //$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) { //Pending invitations if (!isset($_GET['u']) || isset($_GET['u']) && $_GET['u'] == api_get_user_id()) { if ($count_pending_invitations > 0) { $invitations .= '<div><h3>' . get_lang('PendingInvitations') . '</h3></div>'; for ($i = 0; $i < $count_pending_invitations; $i++) { $user_invitation_id = $pending_invitations[$i]['user_sender_id']; $invitations .= '<div id="dpending_' . $user_invitation_id . '" class="friend_invitations">'; $invitations .= '<div style="float:left;width:60px;" >'; $invitations .= '<img style="margin-bottom:5px;" src="' . $list_get_path_web[$i]['dir'] . '/' . $list_get_path_web[$i]['file'] . '" width="60px">'; $invitations .= '</div>'; $invitations .= '<div style="padding-left:70px;">'; $user_invitation_info = api_get_user_info($user_invitation_id); $invitations .= '<a href="' . $user_invitation_info['profile_url'] . '">' . $user_invitation_info['complete_name'] . '</a>'; $invitations .= '<br />'; $invitations .= Security::remove_XSS(Text::cut($pending_invitations[$i]['content'], 50), STUDENT, true); $invitations .= '<br />'; $invitations .= '<a id="btn_accepted_' . $user_invitation_id . '" class="btn" onclick="register_friend(this)" href="javascript:void(0)">' . get_lang('SocialAddToFriends') . '</a>'; $invitations .= '<div id="id_response"></div>'; $invitations .= '</div>'; $invitations .= '</div>'; } $social_right_content .= SocialManager::social_wrapper_div($invitations, 4); } } //--Productions $production_list = UserManager::build_production_list($user_id); $product_content = ''; if (!empty($production_list)) { $product_content .= '<div><h3>' . get_lang('MyProductions') . '</h3></div>'; $product_content .= $production_list;
/** * Shows the posts of a blog * @author Toon Keppens * * @param Integer $blog_id */ public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) { // Init $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); $tbl_users = Database::get_main_table(TABLE_MAIN_USER); $course_id = api_get_course_int_id(); // Get posts and authors $sql = "SELECT post.*, user.lastname, user.firstname, user.username FROM {$tbl_blogs_posts} post\n\t\t\t\t\tINNER JOIN {$tbl_users} user ON post.author_id = user.user_id\n\t\t\t\tWHERE \tpost.blog_id = '" . (int) $blog_id . "' AND\n\t\t\t\t\t\tpost.c_id = {$course_id} AND\n\t\t\t\t\t\t{$filter}\n\t\t\t\tORDER BY post_id DESC LIMIT 0," . (int) $max_number_of_posts; $result = Database::query($sql); // Display if (Database::num_rows($result) > 0) { $limit = 200; while ($blog_post = Database::fetch_array($result)) { // Get number of comments $sql = "SELECT COUNT(1) as number_of_comments FROM {$tbl_blogs_comments} WHERE c_id = {$course_id} AND blog_id = '" . (int) $blog_id . "' AND post_id = '" . (int) $blog_post['post_id'] . "'"; $tmp = Database::query($sql); $blog_post_comments = Database::fetch_array($tmp); // Prepare data $blog_post_id = $blog_post['post_id']; $blog_post_text = Text::make_clickable(stripslashes($blog_post['full_text'])); $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); // Create an introduction text (but keep FULL sentences) $introduction_text = ""; $words = 0; $blog_post_text_cut = Text::cut($blog_post_text, $limit); $words = strlen($blog_post_text); if ($words >= $limit) { $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; $introduction_text = $blog_post_text_cut; } else { $introduction_text = $blog_post_text; $readMoreLink = ''; } $introduction_text = stripslashes($introduction_text); echo '<div class="blogpost">'; echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . stripslashes($blog_post['title']) . '</a></span>'; echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; echo '<div class="blogpost_introduction" id="blogpost_introduction_' . $blog_post_id . '">' . $introduction_text . $readMoreLink . '</div>'; echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; $file_name_array = get_blog_attachment($blog_id, $blog_post_id, 0); if (!empty($file_name_array)) { echo '<br /><br />'; echo Display::return_icon('attachment.gif', get_lang('Attachment')); echo '<a href="download.php?file='; echo $file_name_array['path']; echo ' "> ' . $file_name_array['filename'] . ' </a><br />'; echo '</span>'; } $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title' => $username)) . ' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; echo '</div>'; } } else { if ($filter == '1=1') { echo get_lang('NoArticles'); } else { echo get_lang('NoArticleMatches'); } } }
/** * Return breadcrumb * @return string */ public function returnBreadcrumb() { $interbreadcrumb = $this->app['breadcrumb']; $session_id = api_get_session_id(); $session_name = api_get_session_name($session_id); $_course = api_get_course_info(); $user_id = api_get_user_id(); $course_id = api_get_course_id(); /* Plugins for banner section */ $web_course_path = api_get_path(WEB_COURSE_PATH); /* If the user is a coach he can see the users who are logged in its session */ $navigation = array(); // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage // hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb $session_name = Text::cut($session_name, MAX_LENGTH_BREADCRUMB); $my_session_name = is_null($session_name) ? '' : ' (' . $session_name . ')'; if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) { $navigation_item['url'] = $web_course_path . $_course['path'] . '/index.php' . (!empty($session_id) ? '?id_session=' . $session_id : ''); $course_title = Text::cut($_course['name'], MAX_LENGTH_BREADCRUMB); switch (api_get_setting('breadcrumbs_course_homepage')) { case 'get_lang': $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', get_lang('CourseHomepageLink')) . ' ' . get_lang('CourseHomepageLink'); break; case 'course_code': $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', $_course['official_code']) . ' ' . $_course['official_code']; break; case 'session_name_and_course_title': $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', $_course['name'] . $my_session_name) . ' ' . $course_title . $my_session_name; break; default: if (api_get_session_id() != -1) { $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', $_course['name'] . $my_session_name) . ' ' . $course_title . $my_session_name; } else { $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH) . 'home.png', $_course['name']) . ' ' . $course_title; } break; } $navigation[] = $navigation_item; } // Part 2: breadcrumbs. // If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb // (which is the tool itself) if (isset($interbreadcrumb) && is_array($interbreadcrumb)) { foreach ($interbreadcrumb as $breadcrumb_step) { if ($breadcrumb_step['url'] != '#') { $sep = strrchr($breadcrumb_step['url'], '?') ? '&' : '?'; $navigation_item['url'] = $breadcrumb_step['url'] . $sep . api_get_cidreq(); } else { $navigation_item['url'] = '#'; } $navigation_item['title'] = $breadcrumb_step['name']; // titles for shared folders if ($breadcrumb_step['name'] == 'shared_folder') { $navigation_item['title'] = get_lang('UserFolders'); } elseif (strstr($breadcrumb_step['name'], 'shared_folder_session_')) { $navigation_item['title'] = get_lang('UserFolders'); } elseif (strstr($breadcrumb_step['name'], 'sf_user_')) { $userinfo = api_get_user_info(substr($breadcrumb_step['name'], 8)); $navigation_item['title'] = $userinfo['complete_name']; } elseif ($breadcrumb_step['name'] == 'chat_files') { $navigation_item['title'] = get_lang('ChatFiles'); } elseif ($breadcrumb_step['name'] == 'images') { $navigation_item['title'] = get_lang('Images'); } elseif ($breadcrumb_step['name'] == 'video') { $navigation_item['title'] = get_lang('Video'); } elseif ($breadcrumb_step['name'] == 'audio') { $navigation_item['title'] = get_lang('Audio'); } elseif ($breadcrumb_step['name'] == 'flash') { $navigation_item['title'] = get_lang('Flash'); } elseif ($breadcrumb_step['name'] == 'gallery') { $navigation_item['title'] = get_lang('Gallery'); } // Fixes breadcrumb title now we applied the Security::remove_XSS and we cut the string depending of the MAX_LENGTH_BREADCRUMB value $navigation_item['title'] = Text::cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB); $navigation_item['title'] = Security::remove_XSS($navigation_item['title']); $navigation[] = $navigation_item; } } // part 3: The tool itself. If we are on the course homepage we do not want to display the title of the course because this // is the same as the first part of the breadcrumbs (see part 1) $final_navigation = array(); $counter = 0; foreach ($navigation as $index => $navigation_info) { if (!empty($navigation_info['title'])) { if ($navigation_info['url'] == '#') { $final_navigation[$index] = $navigation_info['title']; } else { $final_navigation[$index] = '<a href="' . $navigation_info['url'] . '" class="" target="_top">' . $navigation_info['title'] . '</a>'; } $counter++; } } $html = ''; if (!empty($final_navigation)) { $lis = ''; $i = 0; $final_navigation_count = count($final_navigation); if (!empty($final_navigation)) { if (!empty($home_link)) { $lis .= Display::tag('li', $home_link); } foreach ($final_navigation as $bread) { $bread_check = trim(strip_tags($bread)); if (!empty($bread_check)) { if ($final_navigation_count - 1 > $i) { //$bread .= '<span class="divider">/</span>'; } $lis .= Display::tag('li', $bread); $i++; } } } else { if (!empty($home_link)) { $lis .= Display::tag('li', $home_link); } } $html .= $lis; } return $html; }
$data[$id]['name'] = Text::cut($question_obj->question, 100); } else { $data[$id]['name'] = '-'; } $data[$id]['answer'] = $answer_info; $data[$id]['correct'] = '-'; $count = ExerciseLib::get_number_students_answer_hotspot_count($answer_id, $question_id, $exercise_id, api_get_course_int_id(), api_get_session_id()); $percentage = 0; if (!empty($count_students)) { $percentage = $count / $count_students * 100; } $data[$id]['attempts'] = Display::bar_progress($percentage, false, $count . ' / ' . $count_students); break; default: if ($mainCounter == 1) { $data[$id]['name'] = Text::cut($question_obj->question, 100); } else { $data[$id]['name'] = '-'; } $data[$id]['answer'] = $answer_info; $data[$id]['correct'] = $correct_answer; $count = ExerciseLib::get_number_students_answer_count($answer_id, $question_id, $exercise_id, api_get_course_int_id(), api_get_session_id()); $percentage = 0; if (!empty($count_students)) { $percentage = $count / $count_students * 100; } $data[$id]['attempts'] = Display::bar_progress($percentage, false, $count . ' / ' . $count_students); break; } $id++; $mainCounter++;
/** * Save message notification * @param array message type NOTIFICATION_TYPE_MESSAGE, NOTIFICATION_TYPE_INVITATION, NOTIFICATION_TYPE_GROUP * @param array recipients: user list of ids * @param string title * @param string content of the message * @param array result of api_get_user_info() or UserGroup->get() */ public function save_notification($type, $user_list, $title, $content, $sender_info = array(), $text_content = null) { $this->type = intval($type); $content = $this->format_content($content, $sender_info); $sender_id = 0; if (!empty($sender_info) && isset($sender_info['user_id'])) { $sender_id = $sender_info['user_id']; $this->set_sender_info($sender_id); } $setting_to_check = ''; $avoid_my_self = false; $default_status = self::NOTIFY_MESSAGE_AT_ONCE; switch ($this->type) { case self::NOTIFICATION_TYPE_MESSAGE: $setting_to_check = 'mail_notify_message'; $default_status = self::NOTIFY_MESSAGE_AT_ONCE; break; case self::NOTIFICATION_TYPE_INVITATION: $setting_to_check = 'mail_notify_invitation'; $default_status = self::NOTIFY_INVITATION_AT_ONCE; break; case self::NOTIFICATION_TYPE_GROUP: $setting_to_check = 'mail_notify_group_message'; $default_status = self::NOTIFY_GROUP_AT_ONCE; $avoid_my_self = true; break; } $setting_info = UserManager::get_extra_field_information_by_name($setting_to_check); if (!empty($user_list)) { foreach ($user_list as $user_id) { if ($avoid_my_self) { if ($user_id == api_get_user_id()) { continue; } } $user_info = api_get_user_info($user_id); //Extra field was deleted or removed? Use the default status if (empty($setting_info)) { $user_setting = $default_status; } else { $extra_data = UserManager::get_extra_user_data($user_id); $user_setting = $extra_data[$setting_to_check]; } $params = array(); switch ($user_setting) { //No notifications case self::NOTIFY_MESSAGE_NO: case self::NOTIFY_INVITATION_NO: case self::NOTIFY_GROUP_NO: break; //Send notification right now! //Send notification right now! case self::NOTIFY_MESSAGE_AT_ONCE: case self::NOTIFY_INVITATION_AT_ONCE: case self::NOTIFY_GROUP_AT_ONCE: if (!empty($user_info['mail'])) { $name = api_get_person_name($user_info['firstname'], $user_info['lastname']); if (!empty($sender_info['complete_name']) && !empty($sender_info['email'])) { $extra_headers = array(); $extra_headers['reply_to']['mail'] = $sender_info['email']; $extra_headers['reply_to']['name'] = $sender_info['complete_name']; api_mail_html($name, $user_info['mail'], Security::filter_terms($title), Security::filter_terms($content), $sender_info['complete_name'], $sender_info['email'], $extra_headers, array(), null, $text_content); } else { api_mail_html($name, $user_info['mail'], Security::filter_terms($title), Security::filter_terms($content), $sender_info['complete_name'], $sender_info['email'], array(), null, $text_content); } } $params['sent_at'] = api_get_utc_datetime(); // Saving the notification to be sent some day. // Saving the notification to be sent some day. default: $params['dest_user_id'] = $user_id; $params['dest_mail'] = $user_info['mail']; $params['title'] = $title; $params['content'] = Text::cut($content, $this->max_content_length); $params['send_freq'] = $user_setting; $params['sender_id'] = $sender_id; $this->save($params); break; } } } }
$fpo = fopen($homePath . $menuf . $ext, 'w'); fputs($fpo, $home_menu); fclose($fpo); } } } else { $errorMsg = get_lang('HomePageFilesNotWritable'); } } else { //File does not exist $fp = fopen($homePath . $menuf . '_' . $lang . $ext, 'w'); fputs($fp, $home_menu); fclose($fp); } } event_system(LOG_HOMEPAGE_CHANGED, $action, Text::cut($link_name . ':' . $link_url, 254), api_get_utc_datetime(), api_get_user_id()); break; } //end of switch($action) if (empty($errorMsg)) { header('Location: ' . api_get_self()); exit; } } else { //if POST[formSent] is not set switch ($action) { case 'open_link': // Previously, filtering of GET['link'] was done here but it left // a security threat. Filtering has now been moved outside conditions break; case 'delete_tabs':
/** * ฟังก์ชั่นตรวจสอบข้อความใช้เป็น description * สำหรับตัด tag หรือเอา BBCode ออกจากเนื้อหาที่เป็น HTML ให้เหลือแต่ข้อความล้วน * ลบช่องว่างไม่เกิน 1 ช่อง ไม่ขึ้นบรรทัดใหม่ * * @param array|string $key แอเรย์ เช่น $_GET, $_POST หรือตัวแปร string * @param string $value (option) ถ้ากำหนดมาจะรับค่าจาก $key[$value] * @param int $len (option) ตัดสตริงค์ตามความยาวที่กำหนด 0 หมายถึงไม่ตัด * @return string */ public static function description($key, $value = '', $len = 0) { if (is_string($key)) { $text = $key; } elseif (isset($key[$value])) { $text = $key[$value]; } else { return ''; } $patt = array('@<style[^>]*?>.*?</style>@siu' => '', '@<![\\s\\S]*?--[ \\t\\n\\r]*>@u' => '', '@<[\\/\\!]*?[^<>]*?>@iu' => '', '/{(WIDGET|LNG)_[a-zA-Z0-9_]+}/su' => '', '/(\\[code(.+)?\\]|\\[\\/code\\]|\\[ex(.+)?\\])/ui' => '', '/\\[([a-z]+)([\\s=].*)?\\](.*?)\\[\\/\\1\\]/ui' => '\\3', '/(&|"| |[_\\(\\)\\-\\+\\r\\n\\s\\"\'<>\\.\\/\\\\?&\\{\\}]){1,}/isu' => ' '); $text = trim(preg_replace(array_keys($patt), array_values($patt), $text)); return \Text::cut($text, $len); }
/** * Builds the form thats enables the user to * select a directory to browse/upload in * * @param array An array containing the folders we want to be able to select * @param string The current folder (path inside of the "document" directory, including the prefix "/") * @param string Group directory, if empty, prevents documents to be uploaded (because group documents cannot be uploaded in root) * @param boolean Whether to change the renderer (this will add a template <span> to the QuickForm object displaying the form) * @todo this funcionality is really bad : jmontoya * @return string html form */ function build_directory_selector($folders, $document_id, $group_dir = '', $change_renderer = false) { $doc_table = Database::get_course_table(TABLE_DOCUMENT); $course_id = api_get_course_int_id(); $folder_titles = array(); if (is_array($folders)) { $escaped_folders = array(); foreach ($folders as $key => &$val) { $escaped_folders[$key] = Database::escape_string($val); } $folder_sql = implode("','", $escaped_folders); $sql = "SELECT * FROM {$doc_table} WHERE filetype = 'folder' AND c_id = {$course_id} AND path IN ('" . $folder_sql . "')"; $res = Database::query($sql); $folder_titles = array(); while ($obj = Database::fetch_object($res)) { $folder_titles[$obj->path] = $obj->title; } } $form = new FormValidator('selector', 'GET', api_get_self() . '?' . api_get_cidreq()); $form->addElement('hidden', 'cidReq', api_get_course_id()); $parent_select = $form->addElement('select', 'id', get_lang('CurrentDirectory'), '', 'onchange="javascript: document.selector.submit();"'); if ($change_renderer) { $renderer = $form->defaultRenderer(); $renderer->setElementTemplate('<span>{label} : {element}</span> ', 'curdirpath'); } // Group documents cannot be uploaded in the root if (empty($group_dir)) { $parent_select->addOption(get_lang('Documents'), '/'); if (is_array($folders)) { foreach ($folders as $folder_id => &$folder) { $selected = $document_id == $folder_id ? ' selected="selected"' : ''; $path_parts = explode('/', $folder); $folder_titles[$folder] = Text::cut($folder_titles[$folder], 80); $counter = count($path_parts) - 2; if ($counter > 0) { $label = str_repeat(' ', $counter) . ' — ' . $folder_titles[$folder]; } else { $label = ' — ' . $folder_titles[$folder]; } $parent_select->addOption($label, $folder_id); if ($selected != '') { $parent_select->setSelected($folder_id); } } } } else { if (!empty($folders)) { foreach ($folders as $folder_id => &$folder) { $selected = $document_id == $folder_id ? ' selected="selected"' : ''; $label = $folder_titles[$folder]; if ($folder == $group_dir) { $label = get_lang('Documents'); } else { $path_parts = explode('/', str_replace($group_dir, '', $folder)); $label = Text::cut($label, 80); $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; } $parent_select->addOption($label, $folder_id); if ($selected != '') { $parent_select->setSelected($folder_id); } } } } $html = $form->toHtml(); return $html; }
/** * @param $visible * @param null $id * @param string $type * @param bool $getCount * @param int $cutSize * @return string */ public static function getAnnouncements($visible, $id = null, $type = 'resumed', $getCount = false, $cutSize = 800) { $user_selected_language = Database::escape_string(api_get_interface_language()); $table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); $now = api_get_utc_datetime(); $select = '*'; if ($getCount) { $select = 'count(*) as count'; } $sql = "SELECT {$select}\n FROM {$table}\n\t\t\t\tWHERE\n\t\t\t\t( lang = '{$user_selected_language}' OR lang IS NULL) AND\n\t\t\t\t( '{$now}' >= date_start AND '{$now}' <= date_end) "; switch ($visible) { case self::VISIBLE_GUEST: $sql .= " AND visible_guest = 1 "; break; case self::VISIBLE_STUDENT: $sql .= " AND visible_student = 1 "; break; case self::VISIBLE_TEACHER: $sql .= " AND visible_teacher = 1 "; break; } if (isset($id) && !empty($id)) { $id = intval($id); $sql .= " AND id = {$id} "; } if (api_is_multiple_url_enabled()) { $current_url_id = api_get_current_access_url_id(); $sql .= " AND access_url_id IN ('1', '{$current_url_id}') "; } $sql .= " ORDER BY date_start DESC"; $announcements = Database::query($sql); if ($getCount) { $announcement = Database::fetch_array($announcements); return $announcement['count']; } $options = array(); if (Database::num_rows($announcements) > 0) { while ($announcement = Database::fetch_object($announcements)) { $content = $announcement->content; $url = api_get_path(WEB_PUBLIC_PATH) . 'news/' . $announcement->id; if (empty($id)) { if ($type == 'resumed') { if (api_strlen(strip_tags($content)) > $cutSize) { $content = Security::remove_XSS(Text::cut($announcement->content, $cutSize)) . ' ' . Display::url(get_lang('More'), $url); } } else { $content = $announcement->content; } } $announcement->title = Text::cut($announcement->title, $cutSize); $options[] = array('title' => $announcement->title, 'content' => $content); } } return $options; }
$display_dir = $dir; if (isset($group)) { $display_dir = explode('/', $dir); unset($display_dir[0]); unset($display_dir[1]); $display_dir = implode('/', $display_dir); } // Interbreadcrumb for the current directory root path // Copied from document.php $dir_array = explode('/', $dir); $array_len = count($dir_array); $dir_acum = ''; for ($i = 0; $i < $array_len; $i++) { $url_dir = 'document.php?&curdirpath=' . $dir_acum . $dir_array[$i]; //Max char 80 $url_to_who = Text::cut($dir_array[$i], 80); if ($is_certificate_mode) { $interbreadcrumb[] = array('url' => $url_dir . '&selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => $url_to_who); } else { $interbreadcrumb[] = array('url' => $url_dir, 'name' => $url_to_who); } $dir_acum .= $dir_array[$i] . '/'; } Display::display_header($nameTools, 'Doc'); echo '<div class="actions">'; echo '<a href="document.php?id=' . $document_id . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '<a href="create_audio.php?' . api_get_cidreq() . '&id=' . $document_id . '&dt2a=google">' . Display::return_icon('google.png', get_lang('GoogleAudio'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '<a href="create_audio.php?' . api_get_cidreq() . '&id=' . $document_id . '&dt2a=pediaphon">' . Display::return_icon('pediaphon.png', get_lang('Pediaphon'), '', ICON_SIZE_MEDIUM) . '</a>'; echo '</div>'; ?> <!-- javascript and styles for textareaCounter-->
/** * Displays announcements as an slideshow * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER * @param int $id The identifier of the announcement to display */ public static function display_announcements_slider($visible, $id = null) { $user_selected_language = Database::escape_string(api_get_interface_language()); $table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); $cut_size = 500; $now = api_get_utc_datetime(); $sql = "SELECT * FROM " . $table . "\n\t\t\t\tWHERE ( lang = '{$user_selected_language}' OR lang IS NULL) AND ( '{$now}' >= date_start AND '{$now}' <= date_end) "; switch ($visible) { case self::VISIBLE_GUEST: $sql .= " AND visible_guest = 1 "; break; case self::VISIBLE_STUDENT: $sql .= " AND visible_student = 1 "; break; case self::VISIBLE_TEACHER: $sql .= " AND visible_teacher = 1 "; break; } if (isset($id) && !empty($id)) { $id = intval($id); $sql .= " AND id = {$id} "; } if (api_is_multiple_url_enabled()) { $current_url_id = api_get_current_access_url_id(); $sql .= " AND access_url_id IN ('1', '{$current_url_id}') "; } $sql .= " ORDER BY date_start DESC"; $announcements = Database::query($sql); $html = ''; if (Database::num_rows($announcements) > 0) { $html .= Display::page_header(get_lang('SystemAnnouncements')); $html .= '<div id="container-slider" class="span6"><ul id="slider">'; while ($announcement = Database::fetch_object($announcements)) { $content = $announcement->content; $url = api_get_path(WEB_PUBLIC_PATH) . 'news/' . $announcement->id; if (empty($id)) { if (api_strlen(strip_tags($content)) > $cut_size) { $content = Text::cut($announcement->content, $cut_size) . ' ' . Display::url(get_lang('More'), $url); } } $html .= '<li><h2>' . $announcement->title . '</h2>' . $content . '</li>'; } $html .= '</ul></div>'; } return $html; }
/** * function which redifines Question::createAnswersForm * @param FormValidator instance */ public function createAnswersForm($form) { // Getting the exercise list /** @var Exercise $obj_ex */ $obj_ex = $this->exercise; $editor_config = array('ToolbarSet' => 'TestProposedAnswer', 'Width' => '100%', 'Height' => '125'); //this line define how many question by default appear when creating a choice question // The previous default value was 2. See task #1759. $nb_answers = isset($_POST['nb_answers']) ? (int) $_POST['nb_answers'] : 4; $nb_answers += isset($_POST['lessAnswers']) ? -1 : (isset($_POST['moreAnswers']) ? 1 : 0); $feedback_title = ''; $comment_title = ''; if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) { $comment_title = '<th>' . get_lang('Comment') . '</th>'; } elseif ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { //Scenario $editor_config['Width'] = '250'; $editor_config['Height'] = '110'; $comment_title = '<th width="500px" >' . get_lang('Comment') . '</th>'; $feedback_title = '<th width="350px" >' . get_lang('Scenario') . '</th>'; } $html = '<table class="data_table"> <tr style="text-align: center;"> <th width="10px"> ' . get_lang('Number') . ' </th> <th width="10px" > ' . get_lang('True') . ' </th> <th width="50%"> ' . get_lang('Answer') . ' </th> ' . $comment_title . ' ' . $feedback_title . ' <th width="50px"> ' . get_lang('Weighting') . ' </th> </tr>'; $form->addElement('label', get_lang('Answers') . '<br />' . Display::return_icon('fill_field.png'), $html); $defaults = array(); $correct = 0; if (!empty($this->id)) { $answer = new Answer($this->id); $answer->read(); if (count($answer->nbrAnswers) > 0 && !$form->isSubmitted()) { $nb_answers = $answer->nbrAnswers; } } $form->addElement('hidden', 'nb_answers'); $list = new LearnpathList(api_get_user_id()); $flat_list = $list->get_flat_list(); $select_lp_id = array(); $select_lp_id[0] = get_lang('SelectTargetLP'); foreach ($flat_list as $id => $details) { $select_lp_id[$id] = Text::cut($details['lp_name'], 20); } $temp_scenario = array(); if ($nb_answers < 1) { $nb_answers = 1; Display::display_normal_message(get_lang('YouHaveToCreateAtLeastOneAnswer')); } for ($i = 1; $i <= $nb_answers; ++$i) { $form->addElement('html', '<tr>'); if (isset($answer) && is_object($answer)) { $answer_id = $answer->getRealAnswerIdFromList($i); if ($answer->correct[$answer_id]) { $correct = $i; } $defaults['answer[' . $i . ']'] = $answer->answer[$answer_id]; $defaults['comment[' . $i . ']'] = $answer->comment[$answer_id]; $defaults['weighting[' . $i . ']'] = Text::float_format($answer->weighting[$answer_id], 1); if (!empty($answer->destination[$answer_id])) { $item_list = explode('@@', $answer->destination[$answer_id]); $try = $item_list[0]; $lp = $item_list[1]; $list_dest = $item_list[2]; $url = $item_list[3]; if ($try == 0) { $try_result = 0; } else { $try_result = 1; } if ($url == 0) { $url_result = ''; } else { $url_result = $url; } $temp_scenario['url' . $i] = $url_result; $temp_scenario['try' . $i] = $try_result; $temp_scenario['lp' . $i] = $lp; $temp_scenario['destination' . $i] = $list_dest; } } else { $defaults['answer[1]'] = get_lang('DefaultUniqueAnswer1'); $defaults['weighting[1]'] = 10; $defaults['answer[2]'] = get_lang('DefaultUniqueAnswer2'); $defaults['weighting[2]'] = 0; $temp_scenario['destination' . $i] = array('0'); $temp_scenario['lp' . $i] = array('0'); } $defaults['scenario'] = $temp_scenario; $renderer = $form->defaultRenderer(); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'correct'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'counter[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'answer[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'comment[' . $i . ']'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}</td>', 'weighting[' . $i . ']'); $answer_number = $form->addElement('text', 'counter[' . $i . ']', null, ' value = "' . $i . '"'); $answer_number->freeze(); $form->addElement('radio', 'correct', null, null, $i, 'class="checkbox" style="margin-left: 0em;"'); if ($obj_ex->fastEdition) { $form->addElement('textarea', 'answer[' . $i . ']', null, $this->textareaSettings); } else { $form->addElement('html_editor', 'answer[' . $i . ']', null, 'style="vertical-align:middle"', $editor_config); } $form->addRule('answer[' . $i . ']', get_lang('ThisFieldIsRequired'), 'required'); if ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_END) { if ($obj_ex->fastEdition) { // feedback $form->addElement('textarea', 'comment[' . $i . ']', null, $this->textareaSettings); } else { // feedback $form->addElement('html_editor', 'comment[' . $i . ']', null, 'style="vertical-align:middle"', $editor_config); } } elseif ($obj_ex->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { // Feedback SELECT $question_list = $obj_ex->selectQuestionList(); $select_question = array(); $select_question[0] = get_lang('SelectTargetQuestion'); // @todo improve this loop if you have 5000 questions it will blow! if (is_array($question_list)) { foreach ($question_list as $key => $questionid) { //To avoid warning messages if (!is_numeric($questionid)) { continue; } $question = Question::read($questionid); if ($question) { $select_question[$questionid] = 'Q' . $key . ' :' . Text::cut($question->selectTitle(), 20); } } } $select_question[-1] = get_lang('ExitTest'); $form->addElement('html_editor', 'comment[' . $i . ']', null, 'style="vertical-align:middle"', $editor_config); // Direct feedback //Adding extra feedback fields $group = array(); $group['try' . $i] = $form->createElement('checkbox', 'try' . $i, null, get_lang('TryAgain')); $group['lp' . $i] = $form->createElement('select', 'lp' . $i, get_lang('SeeTheory') . ': ', $select_lp_id); $group['destination' . $i] = $form->createElement('select', 'destination' . $i, get_lang('GoToQuestion') . ': ', $select_question); $group['url' . $i] = $form->createElement('text', 'url' . $i, get_lang('Other') . ': ', array('class' => 'span2', 'placeholder' => get_lang('Other'))); $form->addGroup($group, 'scenario'); $renderer->setElementTemplate('<td><!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --><br/>{element}', 'scenario'); } $form->addElement('text', 'weighting[' . $i . ']', null, array('class' => "span1", 'value' => '0')); $form->addElement('html', '</tr>'); } $form->addElement('html', '</table>'); $form->addElement('html', '<br />'); $navigator_info = api_get_navigator(); // ie6 fix. if ($form->isFrozen() == false) { if ($obj_ex->edit_exercise_in_lp == true) { if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') { $form->addElement('submit', 'lessAnswers', get_lang('LessAnswer'), 'class="btn minus"'); $form->addElement('submit', 'moreAnswers', get_lang('PlusAnswer'), 'class="btn plus"'); $form->addElement('submit', 'submitQuestion', $this->submitText, 'class="' . $this->submitClass . '"'); } else { //setting the save button here and not in the question class.php $form->addElement('style_submit_button', 'lessAnswers', get_lang('LessAnswer'), 'class="btn minus"'); $form->addElement('style_submit_button', 'moreAnswers', get_lang('PlusAnswer'), 'class="btn plus"'); $form->addElement('style_submit_button', 'submitQuestion', $this->submitText, 'class="' . $this->submitClass . '"'); } } $renderer->setElementTemplate('{element} ', 'submitQuestion'); $renderer->setElementTemplate('{element} ', 'lessAnswers'); $renderer->setElementTemplate('{element} ', 'moreAnswers'); } $form->addElement('html', '</div></div>'); //We check the first radio button to be sure a radio button will be check if ($correct == 0) { $correct = 1; } $defaults['correct'] = $correct; if (!empty($this->id)) { $form->setDefaults($defaults); } else { if ($this->isContent == 1) { $form->setDefaults($defaults); } } $form->setConstants(array('nb_answers' => $nb_answers)); }
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); header("Location: groups.php?id={$group_id}&action=show_message&msg=topic_deleted"); exit; } } $content = null; // save message group $currentToken = Security::getCurrentToken(); 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 = Text::cut($content, 50); } if ($_POST['action'] == 'edit_message_group') { $edit_message_id = intval($_POST['message_id']); $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id, $edit_message_id, 0, $topic_id); } else { if ($_POST['action'] == 'add_message_group' && !$is_member) { api_not_allowed(); } $res = MessageManager::send_message(0, $title, $content, $_FILES, '', $group_id, $parent_id, 0, $topic_id); } // display error messages if (!$res) { $social_right_content .= Display::return_message(get_lang('Error'), 'error'); } $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : null;
$results = $usergroup->get_groups_by_popularity(1, false); $groups_pop = array(); foreach ($results as $result) { $result['description'] = Security::remove_XSS($result['description'], STUDENT, true); $result['name'] = Security::remove_XSS($result['name'], STUDENT, true); $id = $result['id']; $group_url = "groups.php?id={$id}"; if ($result['count'] == 1) { $result['count'] = '1 ' . get_lang('Member'); } else { $result['count'] = $result['count'] . ' ' . get_lang('Members'); } $result['name'] = Display::url(api_ucwords(Text::cut($result['name'], 40, true)), $group_url) . Display::span('<br />' . $result['count'], array('class' => 'box_description_group_member')); $picture = $usergroup->get_picture_group($id, $result['picture'], 80); $result['picture_uri'] = '<img class="social-groups-image" src="' . $picture['file'] . '" hspace="10" height="44" border="2" align="left" width="44" />'; $group_actions = '<div class="box_description_group_actions" ><a href="groups.php?#tab_browse-3">' . get_lang('SeeMore') . '</a></div>'; $groups_pop[] = array(Display::url($result['picture_uri'], $group_url), $result['name'], Text::cut($result['description'], 120, true) . $group_actions); } if (count($groups_newest) > 0) { $social_right_content .= '<div class="social-groups-home-title">' . get_lang('Newest') . '</div>'; $social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_newest, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, true, true, false)); } if (count($groups_pop) > 0) { $social_right_content .= '<div class="social-groups-home-title">' . get_lang('Popular') . '</div>'; $social_right_content .= Display::return_sortable_grid('home_group', array(), $groups_pop, array('hide_navigation' => true, 'per_page' => 100), array(), false, array(true, true, true, true, true)); } $social_right_content .= '</div>'; $app['title'] = get_lang('SocialNetwork'); $tpl = $app['template']; $tpl->assign('content', $social_right_content); $tpl->display_one_col_template();
$question_list = Question::get_question_type_list(); $question_list_options = array(); foreach ($question_list as $key => $value) { $question_list_options[$key] = addslashes(get_lang($value[1])); } $form->addElement('select', 'question_type_hidden', get_lang('QuestionType'), $question_list_options, array('id' => 'question_type_hidden')); //session id $session_id = api_get_session_id(); // the exercices $tbl_exercices = Database::get_course_table(TABLE_QUIZ_TEST); $course_id = api_get_course_int_id(); $sql = "SELECT iid,title,type,description, results_disabled\n FROM {$tbl_exercices} WHERE c_id = {$course_id} AND active<>'-1' AND session_id=" . $session_id . "\n ORDER BY title ASC"; $result = Database::query($sql); $exercises['-'] = '-' . get_lang('SelectExercice') . '-'; while ($row = Database::fetch_array($result)) { $exercises[$row['iid']] = Text::cut($row['title'], EXERCISE_MAX_NAME_SIZE); } $form->addElement('select', 'exercice', get_lang('Exercice'), $exercises); // generate default content $form->addElement('checkbox', 'is_content', null, get_lang('DefaultContent'), array('checked' => true)); // the submit button $form->addElement('style_submit_button', 'SubmitCreateQuestion', get_lang('CreateQuestion'), 'class="add"'); // setting the rules $form->addRule('exercice', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('exercice', get_lang('YouHaveToSelectATest'), 'numeric'); $form->registerRule('validquestiontype', 'callback', 'check_question_type'); $form->addRule('question_type_hidden', get_lang('InvalidQuestionType'), 'validquestiontype'); if ($form->validate()) { $values = $form->exportValues(); $answer_type = $values['question_type_hidden']; // check feedback_type from current exercise for type of question delineation
if ($result['relation_type'] == GROUP_USER_PERMISSION_ADMIN) { $icon = Display::return_icon('social_group_admin.png', get_lang('Admin'), array('style' => 'vertical-align:middle;width:16px;height:16px;')); } elseif ($result['relation_type'] == GROUP_USER_PERMISSION_MODERATOR) { $icon = Display::return_icon('social_group_moderator.png', get_lang('Moderator'), array('style' => 'vertical-align:middle;width:16px;height:16px;')); } $count_users_group = count($usergroup->get_all_users_by_group($id)); if ($count_users_group == 1) { $count_users_group = $count_users_group . ' ' . get_lang('Member'); } else { $count_users_group = $count_users_group . ' ' . get_lang('Members'); } $picture = $usergroup->get_picture_group($result['id'], $result['picture'], 80); $item_name = '<div class="box_shared_profile_group_title">' . $url_open . api_xml_http_response_encode($name) . $icon . $url_close . '</div>'; $item_description = ''; if (!empty($result['description'])) { $item_description = '<div class="box_shared_profile_group_description"><span class="social-groups-text2">' . api_xml_http_response_encode(get_lang('Description')) . '</span><p class="social-groups-text4">' . Text::cut(api_xml_http_response_encode($result['description']), 120, true) . '</p></div>'; } $result['picture_uri'] = '<div class="box_shared_profile_group_image"><img class="social-groups-image" src="' . $picture['file'] . '" hspace="4" height="50" border="2" align="left" width="50" /></div>'; $item_actions = ''; if (api_get_user_id() == $user_id) { $item_actions = '<div class="box_shared_profile_group_actions"><a href="groups.php?id=' . $id . '">' . get_lang('SeeMore') . $url_close . '</div>'; } $grid_my_groups[] = array($item_name, $url_open . $result['picture_uri'] . $url_close, $item_description . $item_actions); $i++; } } if (count($grid_my_groups) > 0) { echo '<div style="margin-top:20px">'; echo '<div><h3>' . get_lang('MyGroups') . '</h3></div>'; $count_groups = 0; if (count($results) == 1) {
/** * Show the monthcalender of the given month * @param array Agendaitems * @param int Month number * @param int Year number * @param array Array of strings containing long week day names (deprecated, you can send an empty array instead) * @param string The month name * @return void Direct output */ function display_mymonthcalendar($user_id, $agendaitems, $month, $year, $weekdaynames = array(), $monthName, $show_content = true) { global $DaysShort, $course_path; //Handle leap year $numberofdays = array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if ($year % 400 == 0 or $year % 4 == 0 and $year % 100 != 0) { $numberofdays[2] = 29; } //Get the first day of the month $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); //Start the week on monday $startdayofweek = $dayone['wday'] != 0 ? $dayone['wday'] - 1 : 6; $g_cc = isset($_GET['courseCode']) ? $_GET['courseCode'] : ''; $prev_icon = Display::return_icon('action_prev.png', get_lang('Previous')); $next_icon = Display::return_icon('action_next.png', get_lang('Next')); $next_month = $month == 1 ? 12 : $month - 1; $prev_month = $month == 12 ? 1 : $month + 1; $next_year = $month == 1 ? $year - 1 : $year; $prev_year = $month == 12 ? $year + 1 : $year; if ($show_content) { $back_url = Display::url($prev_icon, api_get_self() . "?coursePath=" . urlencode($course_path) . "&courseCode=" . Security::remove_XSS($g_cc) . "&action=view&view=month&month=" . $next_month . "&year=" . $next_year); $next_url = Display::url($next_icon, api_get_self() . "?coursePath=" . urlencode($course_path) . "&courseCode=" . Security::remove_XSS($g_cc) . "&action=view&view=month&month=" . $prev_month . "&year=" . $prev_year); } else { $back_url = Display::url($prev_icon, '', array('onclick' => "load_calendar('" . $user_id . "','" . $next_month . "', '" . $next_year . "'); ")); $next_url = Display::url($next_icon, '', array('onclick' => "load_calendar('" . $user_id . "','" . $prev_month . "', '" . $prev_year . "'); ")); } echo '<table id="agenda_list"><tr>'; echo '<th width="10%">' . $back_url . '</th>'; echo '<th width="80%" colspan="5"><br /><h3>' . $monthName . " " . $year . '</h3></th>'; echo '<th width="10%">' . $next_url . '</th>'; echo '</tr>'; echo '<tr>'; for ($ii = 1; $ii < 8; $ii++) { echo '<td class="weekdays">' . $DaysShort[$ii % 7] . '</td>'; } echo '</tr>'; $curday = -1; $today = getdate(); while ($curday <= $numberofdays[$month]) { echo "<tr>"; for ($ii = 0; $ii < 7; $ii++) { if ($curday == -1 && $ii == $startdayofweek) { $curday = 1; } if ($curday > 0 && $curday <= $numberofdays[$month]) { $bgcolor = $class = 'class="days_week"'; $dayheader = Display::div($curday, array('class' => 'agenda_day')); if ($curday == $today['mday'] && $year == $today['year'] && $month == $today['mon']) { $class = "class=\"days_today\" style=\"width:10%;\""; } echo "<td " . $class . ">" . $dayheader; if (!empty($agendaitems[$curday])) { $items = $agendaitems[$curday]; $items = ArrayClass::msort($items, 'start_date_tms'); foreach ($items as $value) { $value['title'] = Security::remove_XSS($value['title']); $start_time = api_format_date($value['start_date'], TIME_NO_SEC_FORMAT); $end_time = ''; if (!empty($value['end_date']) && $value['end_date'] != '0000-00-00 00:00:00') { $end_time = '- <i>' . api_format_date($value['end_date'], DATE_TIME_FORMAT_LONG) . '</i>'; } $complete_time = '<i>' . api_format_date($value['start_date'], DATE_TIME_FORMAT_LONG) . '</i> ' . $end_time; $time = '<i>' . $start_time . '</i>'; switch ($value['calendar_type']) { case 'personal': $bg_color = '#D0E7F4'; $icon = Display::return_icon('user.png', get_lang('MyAgenda'), array(), ICON_SIZE_SMALL); break; case 'global': $bg_color = '#FFBC89'; $icon = Display::return_icon('view_remove.png', get_lang('GlobalEvent'), array(), ICON_SIZE_SMALL); break; case 'course': $bg_color = '#CAFFAA'; $icon_name = 'course.png'; if (!empty($value['session_id'])) { $icon_name = 'session.png'; } if ($show_content) { $icon = Display::url(Display::return_icon($icon_name, $value['course_name'] . ' ' . get_lang('Course'), array(), ICON_SIZE_SMALL), $value['url']); } else { $icon = Display::return_icon($icon_name, $value['course_name'] . ' ' . get_lang('Course'), array(), ICON_SIZE_SMALL); } break; default: break; } $result = '<div class="rounded_div_agenda" style="background-color:' . $bg_color . ';">'; if ($show_content) { //Setting a personal event to green $icon = Display::div($icon, array('style' => 'float:right')); $link = $value['calendar_type'] . '_' . $value['id'] . '_' . $value['course_id'] . '_' . $value['session_id']; //Link to bubble $url = Display::url(Text::cut($value['title'], 40), '#', array('id' => $link, 'class' => 'opener')); $result .= $time . ' ' . $icon . ' ' . Display::div($url); //Hidden content $content = Display::div($icon . Display::tag('h2', $value['course_name']) . '<hr />' . Display::tag('h3', $value['title']) . $complete_time . '<hr />' . Security::remove_XSS($value['content'])); //Main div $result .= Display::div($content, array('id' => 'main_' . $link, 'class' => 'dialog', 'style' => 'display:none')); $result .= '</div>'; echo $result; //echo Display::div($content, array('id'=>'main_'.$value['calendar_type'].'_'.$value['id'], 'class' => 'dialog')); } else { echo $result .= $icon . '</div>'; } } } echo "</td>"; $curday++; } else { echo "<td></td>"; } } echo "</tr>"; } echo "</table>"; }
echo '<div class="col-md-2">'; echo '<div class="thumbnail">'; if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { echo '<a class="ajax" href="' . api_get_path(WEB_CODE_PATH) . 'inc/ajax/course_home.ajax.php?a=show_course_information&code=' . $course['code'] . '" rel="gb_page_center[778]">'; echo '<img src="' . $course_medium_image . '" alt="" />'; echo '</a>'; } else { echo '<img src="' . $course_medium_image . '" alt="' . $title . '"/>'; } echo '</div>'; //thumb echo '</div>'; echo '<div class="col-md-8">'; $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course['real_id']); $teachers = '<h5>' . $teachers . '</h5>'; echo '<div class="categories-course-description"><h3>' . Text::cut($title, 60) . '</h3>' . $teachers . $rating . '</div>'; echo '<p>'; // we display the icon to subscribe or the text already subscribed echo '<div class="btn-toolbar">'; if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { echo '<a class="ajax btn btn-default" href="' . api_get_path(WEB_CODE_PATH) . 'inc/ajax/course_home.ajax.php?a=show_course_information&code=' . $course['code'] . '" class="thickbox">' . get_lang('Description') . '</a>'; } // Get access type for course button ("enter" or/and "register") $access_type = CourseManager::get_access_link_by_user(api_get_user_id(), $course); // Go To Course button (only if admin, if course public or if student already subscribed) if ($access_type && in_array('enter', $access_type)) { echo ' <a class="btn btn-primary" href="' . api_get_course_url($course['code']) . '">' . get_lang('GoToCourse') . '</a>'; } // Register button if ($access_type && in_array('register', $access_type)) { echo ' <a class="btn btn-primary" href="' . api_get_self() . '?action=subscribe_course&sec_token=' . $stok . '&subscribe_course=' . $course['code'] . '&search_term=' . $search_term . '&category_code=' . $code . '">' . get_lang('Subscribe') . '</a>';
} $parent_select->addOption($label, $folder); if ($selected != '') { $parent_select->setSelected($folder); } } } } else { foreach ($folders as &$folder) { $selected = substr($dir, 0, -1) == $folder ? ' selected="selected"' : ''; $label = $folder_titles[$folder]; if ($folder == $group_dir) { $label = '/ (' . get_lang('HomeDirectory') . ')'; } else { $path_parts = explode('/', str_replace($group_dir, '', $folder)); $label = Text::cut($label, 80); $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; } $parent_select->addOption($label, $folder); if ($selected != '') { $parent_select->setSelected($folder); } } } } if ($is_certificate_mode) { $form->addElement('style_submit_button', 'submit', get_lang('CreateCertificate'), 'class="save"'); } else { $form->addElement('style_submit_button', 'submit', get_lang('CreateDoc'), 'class="save"'); } $form->setDefaults($defaults);
/** * Gets information about some messages, used for the inbox sortable table * @param int $from * @param int $number_of_items * @param string $direction */ public static function get_message_data($from, $number_of_items, $column, $direction) { global $charset; $from = intval($from); $number_of_items = intval($number_of_items); //forcing this order if (!isset($direction)) { $column = 3; $direction = 'DESC'; } else { $column = intval($column); if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } } $table_message = Database::get_main_table(TABLE_MESSAGE); $sql_query = "SELECT id as col0, user_sender_id as col1, title as col2, send_date as col3, msg_status as col4 FROM {$table_message} " . " WHERE user_receiver_id=" . api_get_user_id() . " AND msg_status IN (0,1)" . " ORDER BY col{$column} {$direction} LIMIT {$from},{$number_of_items}"; $sql_result = Database::query($sql_query); $i = 0; $message_list = array(); while ($result = Database::fetch_row($sql_result)) { $message[0] = $result[0]; $result[2] = Security::remove_XSS($result[2], STUDENT, true); $result[2] = Text::cut($result[2], 80, true); if ($result[4] == 1) { $class = 'class = "unread"'; } else { $class = 'class = "read"'; } $link = ''; if (isset($_GET['f']) && $_GET['f'] == 'social') { $link = '&f=social'; } $userInfo = api_get_user_info($result[1]); $message[1] = '<a ' . $class . ' href="view_message.php?id=' . $result[0] . $link . '">' . $result[2] . '</a><br />' . $userInfo['complete_name']; $message[3] = '<a href="new_message.php?re_id=' . $result[0] . $link . '">' . Display::return_icon('message_reply.png', get_lang('ReplyToMessage')) . '</a>' . ' <a onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmDeleteMessage'))) . "'" . ')) return false;" href="inbox.php?action=deleteone&id=' . $result[0] . $link . '">' . Display::return_icon('delete.png', get_lang('DeleteMessage')) . '</a>'; $message[2] = api_convert_and_format_date($result[3], DATE_TIME_FORMAT_LONG); //date stays the same foreach ($message as $key => $value) { $message[$key] = api_xml_http_response_encode($value); } $message_list[] = $message; $i++; } return $message_list; }