예제 #1
0
/* For licensing terms, see /license.txt */
/**
 * @author Frederik Vermeire <*****@*****.**>, UGent Internship
 * @author Patrick Cool <*****@*****.**>, Ghent University: code cleaning
 * @author Julio Montoya <*****@*****.**>, MORE code cleaning 2011
 *
 * @abstract The task of the internship was to integrate the 'send messages to specific users' with the
 *			 Announcements tool and also add the resource linker here. The database also needed refactoring
 *			 as there was no title field (the title was merged into the content field)
 * @package chamilo.announcements
 * multiple functions
 */
// use anonymous mode when accessing this course tool
$use_anonymous = true;
$ctok = Security::get_existing_token();
$stok = Security::get_token();
$current_course_tool = TOOL_ANNOUNCEMENT;
$this_section = SECTION_COURSES;
$nameTools = get_lang('ToolAnnouncement');
/* ACCESS RIGHTS */
api_protect_course_script(true);
// Configuration settings
$display_announcement_list = true;
$display_form = false;
$display_title_list = true;
// Maximum title messages to display
$maximum = '12';
// Length of the titles
$length = '36';
// Database Table Definitions
예제 #2
0
 /**
  * @param array $courses
  * @param array $my_course_code_list
  * @return mixed
  */
 public static function process_hot_course_item($courses, $my_course_code_list = array())
 {
     $hotCourses = [];
     $ajax_url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=add_course_vote';
     $stok = Security::get_existing_token();
     foreach ($courses as $courseId) {
         $course_info = api_get_course_info_by_id($courseId['c_id']);
         $courseCode = $course_info['code'];
         $categoryCode = !empty($course_info['categoryCode']) ? $course_info['categoryCode'] : "";
         $my_course['extra_info'] = $course_info;
         $my_course['extra_info']['go_to_course_button'] = '';
         $my_course['extra_info']['register_button'] = '';
         $access_link = self::get_access_link_by_user(api_get_user_id(), $course_info, $my_course_code_list);
         //Course visibility
         if ($access_link && in_array('register', $access_link)) {
             $my_course['extra_info']['register_button'] = Display::url(Display::returnFontAwesomeIcon('sign-in'), api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?action=subscribe&sec_token=' . $stok, array('class' => 'btn btn-success btn-sm', 'title' => get_lang('Subscribe')));
         }
         if ($access_link && in_array('enter', $access_link) || $course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) {
             $my_course['extra_info']['go_to_course_button'] = Display::url(Display::returnFontAwesomeIcon('share'), api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php', array('class' => 'btn btn-default btn-sm', 'title' => get_lang('GoToCourse')));
         }
         if ($access_link && in_array('unsubscribe', $access_link)) {
             $my_course['extra_info']['unsubscribe_button'] = Display::url(Display::returnFontAwesomeIcon('sign-out'), api_get_path(WEB_CODE_PATH) . 'auth/courses.php?action=unsubscribe&unsubscribe=' . $courseCode . '&sec_token=' . $stok . '&category_code=' . $categoryCode, array('class' => 'btn btn-danger btn-sm', 'title' => get_lang('Unreg')));
         }
         //Description
         $my_course['extra_info']['description_button'] = '';
         /* if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'],
                    $my_course_code_list)
            ) { */
         $my_course['extra_info']['description_button'] = Display::url(Display::returnFontAwesomeIcon('info-circle'), api_get_path(WEB_AJAX_PATH) . 'course_home.ajax.php?a=show_course_information&code=' . $course_info['code'], ['class' => 'btn btn-default btn-sm ajax', 'data-title' => get_lang('Description'), 'title' => get_lang('Description')]);
         //}
         /* get_lang('Description') */
         $my_course['extra_info']['teachers'] = CourseManager::getTeacherListFromCourseToString($course_info['real_id']);
         $point_info = self::get_course_ranking($course_info['real_id'], 0);
         $my_course['extra_info']['rating_html'] = Display::return_rating_system('star_' . $course_info['real_id'], $ajax_url . '&course_id=' . $course_info['real_id'], $point_info);
         $hotCourses[] = $my_course;
     }
     return $hotCourses;
 }
예제 #3
0
 /**
  * This function allows easy activating and inactivating of dashboard plugins
  * @return void
  */
 public static function handle_dashboard_plugins()
 {
     $token = Security::get_existing_token();
     $tokenCondition = '&amp;sec_token=' . $token;
     /* We scan the plugin directory. Each folder is a potential plugin. */
     $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH) . 'dashboard/';
     $possibleplugins = self::get_posible_dashboard_plugins_path();
     $table_cols = array('name', 'version', 'description');
     echo Display::page_subheader(get_lang('DashboardPlugins'));
     echo '<form name="plugins" method="post" action="' . api_get_self() . '?category=' . Security::remove_XSS($_GET['category']) . $tokenCondition . '">';
     echo '<table class="data_table">';
     echo '<tr>';
     echo '<th width="50px">' . get_lang('Enabled') . '</th>';
     echo '<th width="250px">' . get_lang('Name') . '</th>';
     echo '<th width="100px">' . get_lang('Version') . '</th>';
     echo '<th>' . get_lang('Description') . '</th>';
     echo '</tr>';
     $disabled_blocks_data = self::get_block_data_without_plugin();
     // We display all the possible enabled or disabled plugins
     foreach ($possibleplugins as $testplugin) {
         $plugin_info_file = $dashboard_pluginpath . $testplugin . "/{$testplugin}.info";
         if (file_exists($plugin_info_file) && is_readable($plugin_info_file)) {
             $plugin_info = parse_info_file($plugin_info_file);
             // change index to lower case
             $plugin_info = array_change_key_case($plugin_info);
             echo '<tr>';
             self::display_dashboard_plugin_checkboxes($testplugin);
             for ($i = 0; $i < count($table_cols); $i++) {
                 if (isset($plugin_info[strtolower($table_cols[$i])])) {
                     echo '<td>';
                     echo $plugin_info[$table_cols[$i]];
                     echo '</td>';
                 } else {
                     echo '<td></td>';
                 }
             }
             echo '</tr>';
         } else {
             echo Display::tag('tr', Display::tag('td', get_lang('CheckFilePermissions') . ' ' . Security::remove_XSS($plugin_info_file), array('colspan' => '3')));
         }
     }
     // display all disabled block data
     if (count($disabled_blocks_data) > 0) {
         foreach ($disabled_blocks_data as $disabled_block) {
             echo '<tr style="background-color:#eee">';
             echo '<td><center><input type="checkbox" name="disabled_block" value="true" checked disabled /></center>';
             for ($j = 0; $j < count($table_cols); $j++) {
                 if (isset($disabled_block[strtolower($table_cols[$j])])) {
                     if ($j == 2) {
                         echo '<td>';
                         echo '<font color="#aaa">' . $disabled_block[$table_cols[$j]] . '</font><br />';
                         echo '<font color="red">' . get_lang('ThisPluginHasbeenDeletedFromDashboardPluginDirectory') . '</font>';
                         echo '</td>';
                     } else {
                         echo '<td>';
                         echo '<font color="#aaa">' . $disabled_block[$table_cols[$j]] . '</font>';
                         echo '</td>';
                     }
                 } else {
                     echo '<td>&nbsp;</td>';
                 }
             }
             echo '</tr>';
         }
     }
     echo '</table>';
     echo '<br />';
     echo '<button class="btn btn-default" type="submit" name="submit_dashboard_plugins" value="' . get_lang('EnableDashboardPlugins') . '">' . get_lang('EnableDashboardPlugins') . '</button></form>';
 }
예제 #4
0
         $courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
     }
 } else {
     $session_name = api_get_session_name($sessionId);
     $title = api_htmlentities($session_name, ENT_QUOTES, $charset) . ' : ' . get_lang('CourseListInSession');
     $courses = Tracking::get_courses_list_from_session($sessionId);
 }
 $a_courses = array_keys($courses);
 if (!api_is_session_admin()) {
     $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "auth/my_progress.php");
     $menu_items[] = Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), "index.php?view=drh_students&amp;display=yourstudents");
     $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php');
     $menu_items[] = Display::url(Display::return_icon('course_na.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), '#');
     $menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php');
     if (api_can_login_as($user_id)) {
         $link = '<a href="' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?action=login_as&amp;user_id=' . $user_id . '&amp;sec_token=' . Security::get_existing_token() . '">' . Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM) . '</a>&nbsp;&nbsp;';
         $menu_items[] = $link;
     }
 }
 $actionsLeft = $actionsRight = '';
 $nb_menu_items = count($menu_items);
 if ($nb_menu_items > 1) {
     foreach ($menu_items as $key => $item) {
         $actionsLeft .= $item;
     }
 }
 if (count($a_courses) > 0) {
     $actionsRight .= Display::url(Display::return_icon('printer.png', get_lang('Print'), array(), 32), 'javascript: void(0);', array('onclick' => 'javascript: window.print();'));
 }
 $toolbar = Display::toolbarAction('toolbar-course', $content = array(0 => $actionsLeft, 1 => $actionsRight));
 echo $toolbar;
예제 #5
0
            "index.php?view=drh_students&amp;display=yourstudents"
        );
        $menu_items[] = Display::url(
            Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM),
            'teachers.php'
        );
        $menu_items[] = Display::url(
            Display::return_icon('course_na.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM),
            '#'
        );
        $menu_items[] = Display::url(
            Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM),
            'session.php'
        );
        if (api_can_login_as($user_id)) {
            $link = '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&amp;user_id='.$user_id.'&amp;sec_token='.Security::get_existing_token().'">'.
                    Display::return_icon('login_as.png', get_lang('LoginAs'), null, ICON_SIZE_MEDIUM).'</a>&nbsp;&nbsp;';
            $menu_items[] = $link;
        }
    }

    echo '<div class="actions">';
    $nb_menu_items = count($menu_items);
    if ($nb_menu_items > 1) {
        foreach ($menu_items as $key => $item) {
            echo $item;
        }
    }
    if (count($a_courses) > 0) {
        echo '<span style="float:right">';
        echo Display::url(
예제 #6
0
 /**
  * @param array $courses
  * @param array $my_course_code_list
  * @return mixed
  */
 public static function process_hot_course_item($courses, $my_course_code_list = array())
 {
     $ajax_url = api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?a=add_course_vote';
     $stok = Security::get_existing_token();
     foreach ($courses as &$my_course) {
         $course_info = api_get_course_info($my_course['course_code']);
         $courseCode = $my_course['course_code'];
         $categoryCode = !empty($my_course['categoryCode']) ? $my_course['categoryCode'] : "";
         $my_course['extra_info'] = $course_info;
         $my_course['extra_info']['go_to_course_button'] = '';
         $my_course['extra_info']['register_button'] = '';
         $access_link = self::get_access_link_by_user(api_get_user_id(), $course_info, $my_course_code_list);
         //Course visibility
         if ($access_link && in_array('register', $access_link)) {
             $my_course['extra_info']['register_button'] = Display::url(get_lang('Subscribe'), api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php?action=subscribe&amp;sec_token=' . $stok, array('class' => 'btn btn-primary'));
         }
         if ($access_link && in_array('enter', $access_link) || $course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) {
             $my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH) . $course_info['path'] . '/index.php', array('class' => 'btn btn-primary'));
         }
         if ($access_link && in_array('unsubscribe', $access_link)) {
             $my_course['extra_info']['unsubscribe_button'] = Display::url(get_lang('Unsubscribe'), api_get_path(WEB_CODE_PATH) . 'auth/courses.php?action=unsubscribe&amp;unsubscribe=' . $courseCode . '&amp;sec_token=' . $stok . '&amp;category_code=' . $categoryCode, array('class' => 'btn btn-primary'));
         }
         //Description
         $my_course['extra_info']['description_button'] = '';
         if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'], $my_course_code_list)) {
             $my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH) . 'course_home.ajax.php?a=show_course_information&amp;code=' . $course_info['code'], array('class' => 'ajax btn'));
         }
         $my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']);
         $point_info = self::get_course_ranking($course_info['real_id'], 0);
         $my_course['extra_info']['rating_html'] = Display::return_rating_system('star_' . $course_info['real_id'], $ajax_url . '&amp;course_id=' . $course_info['real_id'], $point_info);
     }
     return $courses;
 }