/**
  * constructor
  * @path the path to a folder
  * @calculateSubdir force to get the subdirectories information
  */
 function __construct($path = null, $calculateSubdir = true)
 {
     $this->calculateSubdir = $calculateSubdir;
     if (defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP')) {
         $this->forceFolderOnTop = CONFIG_SYS_FOLDER_SHOWN_ON_TOP;
     }
     if (!is_null($path)) {
         $this->currentFolderPath = $path;
     } elseif (isset($_GET[$this->folderPathIndex]) && file_exists(base64_decode($_GET[$this->folderPathIndex])) && !is_file(base64_decode($_GET[$this->folderPathIndex]))) {
         $this->currentFolderPath = api_htmlentities(Security::remove_XSS($_GET[$this->folderPathIndex]));
     } elseif (isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex])) {
         $this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex];
     } else {
         $this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
     }
     $this->currentFolderPath = isUnderRoot($this->getCurrentFolderPath()) ? backslashToSlash(addTrailingSlash($this->getCurrentFolderPath())) : $this->currentFolderPath;
     $this->currentFolderPath = base64_encode($this->currentFolderPath);
     if ($this->calculateSubdir) {
         // keep track of this folder path in session
         $_SESSION[$this->lastVisitedFolderPathIndex] = $this->currentFolderPath;
     }
     if (is_dir($this->getCurrentFolderPath())) {
         $file = new file($this->getCurrentFolderPath());
         $folderInfo = $file->getFileInfo();
         if (sizeof($folderInfo)) {
             //for Chamilo in a name folder, replace num user by user names
             if (preg_match('/sf_user_/', basename($this->getCurrentFolderPath()))) {
                 $userinfo = api_get_user_info(substr(basename($this->getCurrentFolderPath()), 8));
                 $this->currentFolderInfo['name'] = $userinfo['complete_name'];
             } else {
                 $this->currentFolderInfo['name'] = str_replace('_', ' ', basename($this->getCurrentFolderPath()));
                 //for Chamilo. Prevent long directory name
             }
             if (preg_match('/shared_folder/', basename($this->getCurrentFolderPath()))) {
                 $this->currentFolderInfo['name'] = get_lang('UserFolders');
             }
             if (preg_match('/shared_folder_session_/', basename($this->getCurrentFolderPath()))) {
                 $session = explode('_', basename($this->getCurrentFolderPath()));
                 $session = strtolower($session[sizeof($session) - 1]);
                 $this->currentFolderInfo['name'] = get_lang('UserFolders') . ' (' . api_get_session_name($session) . ')*';
             }
             //end Chamilo
             $this->currentFolderInfo['subdir'] = 0;
             $this->currentFolderInfo['file'] = 0;
             $this->currentFolderInfo['ctime'] = $folderInfo['ctime'];
             $this->currentFolderInfo['mtime'] = $folderInfo['mtime'];
             $this->currentFolderInfo['is_readable'] = $folderInfo['is_readable'];
             $this->currentFolderInfo['is_writable'] = $folderInfo['is_writable'];
             $this->currentFolderInfo['path'] = $this->getCurrentFolderPath();
             $this->currentFolderInfo['path_base64'] = base64_encode($this->getCurrentFolderPath());
             $this->currentFolderInfo['friendly_path'] = transformFilePath($this->getCurrentFolderPath());
             $this->currentFolderInfo['type'] = 'folder';
             $this->currentFolderInfo['cssClass'] = 'folder';
             //$this->currentFolderInfo['flag'] = $folderInfo['flag'];
         }
     }
     if ($calculateSubdir && !file_exists($this->getCurrentFolderPath())) {
         die(ERR_FOLDER_NOT_FOUND . $this->getCurrentFolderPath());
     }
 }
 /**
  * Export the given HTML to PDF, using a global template
  * @param string the HTML content
  * @uses export/table_pdf.tpl
  */
 function html_to_pdf_with_template($content)
 {
     Display::display_no_header();
     //Assignments
     Display::$global_template->assign('pdf_content', $content);
     $organization = api_get_setting('Institution');
     $img = api_get_path(SYS_CODE_PATH) . 'css/' . api_get_visual_theme() . '/images/header-logo.png';
     if (file_exists($img)) {
         $img = api_get_path(WEB_CODE_PATH) . 'css/' . api_get_visual_theme() . '/images/header-logo.png';
         $organization = "<img src='{$img}'>";
     } else {
         if (!empty($organization)) {
             $organization = '<h2 align="left">' . $organization . '</h2>';
         }
     }
     Display::$global_template->assign('organization', $organization);
     //Showing only the current teacher/admin instead the all teacherlist name see BT#4080
     $user_info = api_get_user_info();
     $teacher_list = $user_info['complete_name'];
     $session_name = api_get_session_name(api_get_session_id());
     if (!empty($session_name)) {
         Display::$global_template->assign('pdf_session', $session_name);
     }
     Display::$global_template->assign('pdf_course', $this->params['course_code']);
     Display::$global_template->assign('pdf_date', api_format_date(api_get_utc_datetime(), DATE_TIME_FORMAT_LONG));
     Display::$global_template->assign('pdf_teachers', $teacher_list);
     Display::$global_template->assign('pdf_title', $this->params['pdf_title']);
     Display::$global_template->assign('add_signatures', $this->params['add_signatures']);
     //Getting template
     $tpl = Display::$global_template->get_template('export/table_pdf.tpl');
     $html = Display::$global_template->fetch($tpl);
     $html = api_utf8_encode($html);
     $css_file = api_get_path(TO_SYS, WEB_CSS_PATH) . '/print.css';
     $css = file_exists($css_file) ? @file_get_contents($css_file) : '';
     self::content_to_pdf($html, $css, $this->params['filename'], $this->params['course_code']);
 }
/**
 * This function displays the form that is used to add a forum category.
 *
 * @param array $inputvalues
 * @param int $lp_id
 * @return void HTML
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @author Juan Carlos Raña Trabado (return to lp_id)
 *
 * @version may 2011, Chamilo 1.8.8
 */
function show_add_forum_form($inputvalues = array(), $lp_id)
{
    $_course = api_get_course_info();
    $form = new FormValidator('forumcategory', 'post', 'index.php?' . api_get_cidreq());
    // The header for the form
    if (!empty($inputvalues)) {
        $form_title = get_lang('EditForum');
    } else {
        $form_title = get_lang('AddForum');
    }
    $session_header = api_get_session_name();
    $form->addElement('header', $form_title . $session_header);
    // We have a hidden field if we are editing.
    if (!empty($inputvalues) && is_array($inputvalues)) {
        $my_forum_id = isset($inputvalues['forum_id']) ? $inputvalues['forum_id'] : null;
        $form->addElement('hidden', 'forum_id', $my_forum_id);
    }
    $lp_id = intval($lp_id);
    // hidden field if from learning path
    $form->addElement('hidden', 'lp_id', $lp_id);
    // The title of the forum
    $form->addElement('text', 'forum_title', get_lang('Title'), array('autofocus'));
    // The comment of the forum.
    $form->addHtmlEditor('forum_comment', get_lang('Description'), null, null, array('ToolbarSet' => 'Forum', 'Width' => '98%', 'Height' => '200'));
    // Dropdown list: Forum categories
    $forum_categories = get_forum_categories();
    foreach ($forum_categories as $key => $value) {
        $forum_categories_titles[$value['cat_id']] = $value['cat_title'];
    }
    $form->addElement('select', 'forum_category', get_lang('InForumCategory'), $forum_categories_titles);
    $form->applyFilter('forum_category', 'html_filter');
    if ($_course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD) {
        // This is for horizontal
        $group = array();
        $group[] = $form->createElement('radio', 'allow_anonymous', null, get_lang('Yes'), 1);
        $group[] = $form->createElement('radio', 'allow_anonymous', null, get_lang('No'), 0);
        $form->addGroup($group, 'allow_anonymous_group', get_lang('AllowAnonymousPosts'), ' ');
    }
    $form->addButtonAdvancedSettings('advanced_params');
    $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
    $group = array();
    $group[] = $form->createElement('radio', 'moderated', null, get_lang('Yes'), 1);
    $group[] = $form->createElement('radio', 'moderated', null, get_lang('No'), 0);
    $form->addGroup($group, 'moderated', get_lang('ModeratedForum'), ' ');
    $group = array();
    $group[] = $form->createElement('radio', 'students_can_edit', null, get_lang('Yes'), 1);
    $group[] = $form->createElement('radio', 'students_can_edit', null, get_lang('No'), 0);
    $form->addGroup($group, 'students_can_edit_group', get_lang('StudentsCanEdit'), ' ');
    $group = array();
    $group[] = $form->createElement('radio', 'approval_direct', null, get_lang('Approval'), 1);
    $group[] = $form->createElement('radio', 'approval_direct', null, get_lang('Direct'), 0);
    $group = array();
    $group[] = $form->createElement('radio', 'allow_attachments', null, get_lang('Yes'), 1);
    $group[] = $form->createElement('radio', 'allow_attachments', null, get_lang('No'), 0);
    $group = array();
    $group[] = $form->createElement('radio', 'allow_new_threads', null, get_lang('Yes'), 1);
    $group[] = $form->createElement('radio', 'allow_new_threads', null, get_lang('No'), 0);
    $form->addGroup($group, 'allow_new_threads_group', get_lang('AllowNewThreads'), ' ');
    $group = array();
    $group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Flat'), 'flat');
    $group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Threaded'), 'threaded');
    $group[] = $form->createElement('radio', 'default_view_type', null, get_lang('Nested'), 'nested');
    $form->addGroup($group, 'default_view_type_group', get_lang('DefaultViewType'), ' ');
    // Drop down list: Groups
    $groups = GroupManager::get_group_list();
    $groups_titles[0] = get_lang('NotAGroupForum');
    foreach ($groups as $key => $value) {
        $groups_titles[$value['id']] = $value['name'];
    }
    $form->addElement('select', 'group_forum', get_lang('ForGroup'), $groups_titles);
    // Public or private group forum
    $group = array();
    $group[] = $form->createElement('radio', 'public_private_group_forum', null, get_lang('Public'), 'public');
    $group[] = $form->createElement('radio', 'public_private_group_forum', null, get_lang('Private'), 'private');
    $form->addGroup($group, 'public_private_group_forum_group', get_lang('PublicPrivateGroupForum'), '');
    // Forum image
    $form->add_progress_bar();
    if (isset($inputvalues['forum_image']) && strlen($inputvalues['forum_image']) > 0) {
        $image_path = api_get_path(WEB_COURSE_PATH) . api_get_course_path() . '/upload/forum/images/' . $inputvalues['forum_image'];
        $image_size = api_getimagesize($image_path);
        $img_attributes = '';
        if (!empty($image_size)) {
            if ($image_size['width'] > 100 || $image_size['height'] > 100) {
                //limit display width and height to 100px
                $img_attributes = 'width="100" height="100"';
            }
            $show_preview_image = '<img src="' . $image_path . '" ' . $img_attributes . '>';
            $form->addElement('label', get_lang('PreviewImage'), $show_preview_image);
            $form->addElement('checkbox', 'remove_picture', null, get_lang('DelImage'));
        }
    }
    $forum_image = isset($inputvalues['forum_image']) ? $inputvalues['forum_image'] : '';
    $form->addElement('file', 'picture', $forum_image != '' ? get_lang('UpdateImage') : get_lang('AddImage'));
    $form->addRule('picture', get_lang('OnlyImagesAllowed'), 'filetype', array('jpg', 'jpeg', 'png', 'gif'));
    $form->addElement('html', '</div>');
    // The OK button
    if (isset($_GET['id']) && $_GET['action'] == 'edit') {
        $form->addButtonUpdate(get_lang('ModifyForum'), 'SubmitForum');
    } else {
        $form->addButtonCreate(get_lang('CreateForum'), 'SubmitForum');
    }
    // setting the rules
    $form->addRule('forum_title', get_lang('ThisFieldIsRequired'), 'required');
    $form->addRule('forum_category', get_lang('ThisFieldIsRequired'), 'required');
    $defaultSettingAllowNewThreads = api_get_default_tool_setting('forum', 'allow_new_threads', 0);
    // Settings the defaults
    if (empty($inputvalues) || !is_array($inputvalues)) {
        $defaults['moderated']['moderated'] = 0;
        $defaults['allow_anonymous_group']['allow_anonymous'] = 0;
        $defaults['students_can_edit_group']['students_can_edit'] = 0;
        $defaults['approval_direct_group']['approval_direct'] = 0;
        $defaults['allow_attachments_group']['allow_attachments'] = 1;
        $defaults['allow_new_threads_group']['allow_new_threads'] = $defaultSettingAllowNewThreads;
        $defaults['default_view_type_group']['default_view_type'] = api_get_setting('forum.default_forum_view');
        $defaults['public_private_group_forum_group']['public_private_group_forum'] = 'public';
        if (isset($_GET['forumcategory'])) {
            $defaults['forum_category'] = Security::remove_XSS($_GET['forumcategory']);
        }
    } else {
        // the default values when editing = the data in the table
        $defaults['forum_id'] = isset($inputvalues['forum_id']) ? $inputvalues['forum_id'] : null;
        $defaults['forum_title'] = prepare4display(isset($inputvalues['forum_title']) ? $inputvalues['forum_title'] : null);
        $defaults['forum_comment'] = prepare4display(isset($inputvalues['forum_comment']) ? $inputvalues['forum_comment'] : null);
        $defaults['moderated']['moderated'] = isset($inputvalues['moderated']) ? $inputvalues['moderated'] : 0;
        $defaults['forum_category'] = isset($inputvalues['forum_category']) ? $inputvalues['forum_category'] : null;
        $defaults['allow_anonymous_group']['allow_anonymous'] = isset($inputvalues['allow_anonymous']) ? $inputvalues['allow_anonymous'] : null;
        $defaults['students_can_edit_group']['students_can_edit'] = isset($inputvalues['allow_edit']) ? $inputvalues['allow_edit'] : null;
        $defaults['approval_direct_group']['approval_direct'] = isset($inputvalues['approval_direct_post']) ? $inputvalues['approval_direct_post'] : null;
        $defaults['allow_attachments_group']['allow_attachments'] = isset($inputvalues['allow_attachments']) ? $inputvalues['allow_attachments'] : null;
        $defaults['allow_new_threads_group']['allow_new_threads'] = isset($inputvalues['allow_new_threads']) ? $inputvalues['allow_new_threads'] : $defaultSettingAllowNewThreads;
        $defaults['default_view_type_group']['default_view_type'] = isset($inputvalues['default_view']) ? $inputvalues['default_view'] : null;
        $defaults['public_private_group_forum_group']['public_private_group_forum'] = isset($inputvalues['forum_group_public_private']) ? $inputvalues['forum_group_public_private'] : null;
        $defaults['group_forum'] = isset($inputvalues['forum_of_group']) ? $inputvalues['forum_of_group'] : null;
    }
    $form->setDefaults($defaults);
    // Validation or display
    if ($form->validate()) {
        $check = Security::check_token('post');
        if ($check) {
            $values = $form->exportValues();
            $return_message = store_forum($values);
            Display::display_confirmation_message($return_message);
        }
        Security::clear_token();
    } else {
        $token = Security::get_token();
        $form->addElement('hidden', 'sec_token');
        $form->setConstants(array('sec_token' => $token));
        $form->display();
    }
}
 /**
  * @param $userId
  * @param $courseInfo
  * @param int $sessionId
  * @return array
  */
 public static function getToolInformation($userId, $courseInfo, $sessionId = 0)
 {
     $csvContent = array();
     $courseToolInformation = null;
     $headerTool = array(array(get_lang('Title')), array(get_lang('CreatedAt')), array(get_lang('UpdatedAt')));
     $headerListForCSV = array();
     foreach ($headerTool as $item) {
         $headerListForCSV[] = $item[0];
     }
     $courseForumInformationArray = getForumCreatedByUser($userId, $courseInfo['real_id'], $sessionId);
     if (!empty($courseForumInformationArray)) {
         $csvContent[] = array();
         $csvContent[] = get_lang('Forums');
         $csvContent[] = $headerListForCSV;
         foreach ($courseForumInformationArray as $row) {
             $csvContent[] = $row;
         }
         $courseToolInformation .= Display::page_subheader2(get_lang('Forums'));
         $courseToolInformation .= Display::return_sortable_table($headerTool, $courseForumInformationArray);
     }
     $courseWorkInformationArray = getWorkCreatedByUser($userId, $courseInfo['real_id'], $sessionId);
     if (!empty($courseWorkInformationArray)) {
         $csvContent[] = null;
         $csvContent[] = get_lang('Works');
         $csvContent[] = $headerListForCSV;
         foreach ($courseWorkInformationArray as $row) {
             $csvContent[] = $row;
         }
         $csvContent[] = null;
         $courseToolInformation .= Display::page_subheader2(get_lang('Works'));
         $courseToolInformation .= Display::return_sortable_table($headerTool, $courseWorkInformationArray);
     }
     $courseToolInformationTotal = null;
     if (!empty($courseToolInformation)) {
         $sessionTitle = null;
         if (!empty($sessionId)) {
             $sessionTitle = ' (' . api_get_session_name($sessionId) . ')';
         }
         $courseToolInformationTotal .= Display::page_subheader($courseInfo['title'] . $sessionTitle);
         $courseToolInformationTotal .= $courseToolInformation;
     }
     return array('array' => $csvContent, 'html' => $courseToolInformationTotal);
 }
Exemple #5
0
 /**
  * Builds an img html tag for the file type
  *
  * @param string $type (file/folder)
  * @param string $path
  * @return string img html tag
  */
 public static function build_document_icon_tag($type, $path)
 {
     $basename = basename($path);
     $current_session_id = api_get_session_id();
     $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
     $user_image = false;
     if ($type == 'file') {
         $icon = choose_image($basename);
         if (preg_match('/_chnano_.wav$/i', $basename)) {
             $icon = "jplayer_play.png";
             $basename = 'wav' . ' ' . '(Nanogong)';
         } else {
             $basename = substr(strrchr($basename, '.'), 1);
         }
     } else {
         if ($path == '/shared_folder') {
             $icon = 'folder_users.gif';
             if ($is_allowed_to_edit) {
                 $basename = get_lang('HelpUsersFolder');
             } else {
                 $basename = get_lang('UserFolders');
             }
         } elseif (strstr($basename, 'sf_user_')) {
             $userinfo = api_get_user_info(substr($basename, 8));
             $icon = $userinfo['avatar_small'];
             $basename = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
             $user_image = true;
         } elseif (strstr($path, 'shared_folder_session_')) {
             if ($is_allowed_to_edit) {
                 $basename = '***(' . api_get_session_name($current_session_id) . ')*** ' . get_lang('HelpUsersFolder');
             } else {
                 $basename = get_lang('UserFolders') . ' (' . api_get_session_name($current_session_id) . ')';
             }
             $icon = 'folder_users.gif';
         } else {
             $icon = 'folder_document.gif';
             if ($path == '/audio') {
                 $icon = 'folder_audio.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Audio');
                 }
             } elseif ($path == '/flash') {
                 $icon = 'folder_flash.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Flash');
                 }
             } elseif ($path == '/images') {
                 $icon = 'folder_images.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Images');
                 }
             } elseif ($path == '/video') {
                 $icon = 'folder_video.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Video');
                 }
             } elseif ($path == '/images/gallery') {
                 $icon = 'folder_gallery.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Gallery');
                 }
             } elseif ($path == '/chat_files') {
                 $icon = 'folder_chat.png';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpFolderChat');
                 } else {
                     $basename = get_lang('ChatFiles');
                 }
             } elseif ($path == '/learning_path') {
                 $icon = 'folder_learningpath.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpFolderLearningPaths');
                 } else {
                     $basename = get_lang('LearningPaths');
                 }
             }
         }
     }
     if ($user_image) {
         return Display::img($icon, $basename, array(), false);
     }
     return Display::return_icon($icon, $basename, array());
 }
 $data = array();
 //when file type is csv, add a header to the output file
 if ($file_type == 'csv') {
     $alldata[] = array('username', 'official_code', 'lastname', 'firstname', 'score', 'date');
 }
 // export results to pdf file
 if ($file_type == 'pdf') {
     $number_decimals = api_get_setting('gradebook_number_decimals');
     $datagen = new ResultsDataGenerator($eval[0], $allresults);
     // set headers pdf
     !empty($_user['official_code']) ? $officialcode = $_user['official_code'] . ' - ' : '';
     $h1 = array(get_lang('Teacher'), $officialcode . $_user['firstName'] . ', ' . $_user['lastName']);
     $h2 = array(get_lang('Score'), $eval[0]->get_max());
     $h3 = array(get_lang('Course'), $_course['name']);
     $h4 = array(get_lang('Weight'), $eval[0]->get_weight());
     $h5 = array(get_lang('Session'), api_get_session_name(api_get_session_id()));
     $date = date('d-m-Y H:i:s', time());
     $h6 = array(get_lang('DateTime'), api_convert_and_format_date($date, "%d/%m/%Y %H:%M"));
     $header_pdf = array($h1, $h2, $h3, $h4, $h5, $h6);
     // set footer pdf
     $f1 = '<hr />' . get_lang('Drh');
     $f2 = '<hr />' . get_lang('Teacher');
     $f3 = '<hr />' . get_lang('Date');
     $footer_pdf = array($f1, $f2, $f3);
     // set title pdf
     $title_pdf = $eval[0]->get_name();
     // set headers data table
     $head_ape_name = '';
     if (api_is_western_name_order()) {
         $head_ape_name = get_lang('FirstName') . ', ' . get_lang('LastName');
     } else {
Exemple #7
0
        }
    }
    //Courses for the user
    $count_courses = count($courses);
    //Sessions for the user
    $count_sessions = count($sessions);
}
if ($count_courses || $count_sessions) {
    // If we are in course.
    if (empty($session_id)) {
        if ($count_courses) {
            $title = '<img src="' . api_get_path(WEB_IMG_PATH) . 'course.gif"> ' . get_lang('Courses') . ' (' . $count_courses . ') ';
        }
    } else {
        //If we are in Course Session
        $session_name = api_get_session_name($session_id);
        $title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL) . ' ' . $session_name;
        $menu_items[] = '<a href="' . api_get_self() . '?view=teacher">' . get_lang('TeacherInterface') . '</a>';
    }
}
if ((api_is_allowed_to_create_course() || api_is_drh()) && in_array($view, array('teacher', 'drh'))) {
    //Courses
    if ($count_courses) {
        echo Display::page_subheader($title);
        $data = MySpace::get_course_data(null, null, null, null, $courses, $csv_content, $charset);
        $table = new SortableTable('courses_my_space', 'get_number_of_courses');
        $parameters['view'] = 'teacher';
        $parameters['class'] = 'data_table';
        $table->set_additional_parameters($parameters);
        $table->set_header(0, get_lang('CourseTitle'), false);
        $table->set_header(1, get_lang('NbStudents'), false);
Exemple #8
0
        //$groupId = 0;
        $visibility = 1;
        create_unexisting_directory($courseInfo, api_get_user_id(), $sessionId, 0, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
    }
} else {
    // Create shared folder session.
    if (!file_exists($base_work_dir . '/shared_folder_session_' . $sessionId)) {
        $usf_dir_title = get_lang('UserFolders') . ' (' . api_get_session_name($sessionId) . ')';
        $usf_dir_name = '/shared_folder_session_' . $sessionId;
        //$groupId = 0;
        $visibility = 0;
        create_unexisting_directory($courseInfo, api_get_user_id(), $sessionId, 0, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
    }
    //Create dynamic user shared folder into a shared folder session
    if (!file_exists($base_work_dir . '/shared_folder_session_' . $sessionId . '/sf_user_' . $userId)) {
        $usf_dir_title = $userInfo['complete_name'] . '(' . api_get_session_name($sessionId) . ')';
        $usf_dir_name = '/shared_folder_session_' . $sessionId . '/sf_user_' . $userId;
        //$groupId = 0;
        $visibility = 1;
        create_unexisting_directory($courseInfo, $userId, $sessionId, 0, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
    }
}
/* 	MAIN SECTION */
// Slideshow inititalisation
$_SESSION['image_files_only'] = '';
$image_files_only = '';
if ($is_certificate_mode) {
    $interbreadcrumb[] = array('url' => '../gradebook/index.php', 'name' => get_lang('Gradebook'));
} else {
    if (isset($_GET['id']) && $_GET['id'] != 0 || isset($_GET['curdirpath']) || isset($_GET['createdir'])) {
        $interbreadcrumb[] = array('url' => 'document.php', 'name' => get_lang('Documents'));
        $to_group_id = 0;
        $visibility = 1;
        FileManager::create_unexisting_directory($course_info, api_get_user_id(), api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
    }
} else {
    //Create shared folder session
    if (!file_exists($base_work_dir . '/shared_folder_session_' . $session_id)) {
        $usf_dir_title = get_lang('UserFolders') . ' (' . api_get_session_name($session_id) . ')';
        $usf_dir_name = '/shared_folder_session_' . $session_id;
        $to_group_id = 0;
        $visibility = 0;
        FileManager::create_unexisting_directory($course_info, api_get_user_id(), api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
    }
    //Create dynamic user shared folder into a shared folder session
    if (!file_exists($base_work_dir . '/shared_folder_session_' . $session_id . '/sf_user_' . api_get_user_id())) {
        $usf_dir_title = api_get_person_name($_user['firstName'], $_user['lastName']) . '(' . api_get_session_name($session_id) . ')';
        $usf_dir_name = '/shared_folder_session_' . $session_id . '/sf_user_' . api_get_user_id();
        $to_group_id = 0;
        $visibility = 1;
        FileManager::create_unexisting_directory($course_info, api_get_user_id(), api_get_session_id(), $to_group_id, $to_user_id, $base_work_dir, $usf_dir_name, $usf_dir_title, $visibility);
    }
}
/* 	MAIN SECTION */
// Slideshow inititalisation
$_SESSION['image_files_only'] = '';
$image_files_only = '';
if ($is_certificate_mode) {
    $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'gradebook/index.php', 'name' => get_lang('Gradebook'));
} else {
    if (isset($_GET['id']) && $_GET['id'] != 0 || isset($_GET['curdirpath']) || isset($_GET['createdir'])) {
        $interbreadcrumb[] = array('url' => 'document.php', 'name' => get_lang('Documents'));
Exemple #10
0
 /**
  * @param int $userId
  * @param int $categoryId
  * @param bool $saveToFile
  * @param bool $saveToHtmlFile
  *
  * @return string
  */
 public static function generateTable($userId, $categoryId, $saveToFile = false, $saveToHtmlFile = false)
 {
     $courseInfo = api_get_course_info();
     $userInfo = api_get_user_info($userId);
     $cats = Category::load($categoryId, null, null, null, null, null, false);
     $cat = $cats[0];
     $allcat = $cats[0]->get_subcategories($userId, api_get_course_id(), api_get_session_id());
     $alleval = $cats[0]->get_evaluations($userId);
     $alllink = $cats[0]->get_links($userId);
     $gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, null, true, false, $userId);
     if (api_is_allowed_to_edit()) {
         $gradebooktable->td_attributes = [4 => 'class=centered'];
     } else {
         $gradebooktable->td_attributes = [3 => 'class=centered', 4 => 'class=centered', 5 => 'class=centered', 6 => 'class=centered', 7 => 'class=centered'];
     }
     $table = $gradebooktable->return_table();
     $graph = $gradebooktable->getGraph();
     $sessionName = api_get_session_name(api_get_session_id());
     $sessionName = !empty($sessionName) ? " - {$sessionName}" : '';
     $params = array('pdf_title' => $courseInfo['title'] . $sessionName, 'course_code' => api_get_course_id(), 'session_info' => api_get_session_info(api_get_session_id()), 'add_signatures' => false, 'student_info' => $userInfo, 'show_grade_generated_date' => true, 'show_real_course_teachers' => true);
     $file = api_get_path(SYS_ARCHIVE_PATH) . uniqid() . '.html';
     $content = $table . $graph . '<br />' . get_lang('Feedback') . '<br />
         <textarea rows="5" cols="100" ></textarea>';
     $pdf = new PDF('A4', $params['orientation'], $params);
     $result = $pdf->html_to_pdf_with_template($content, $saveToFile, $saveToHtmlFile);
     if ($saveToHtmlFile) {
         file_put_contents($file, $result);
         return $file;
     }
     return $file;
 }
/**
 * Show the form to copy courses
 * @global string $returnLink
 * @global string $courseCode
 */
function displayForm()
{
    global $returnLink, $courseCode;
    $courseInfo = api_get_course_info();
    $sessionId = api_get_session_id();
    $userId = api_get_user_id();
    $sessions = SessionManager::getSessionsCoachedByUser($userId);
    $html = '';
    // Actions
    $html .= '<div class="actions">';
    // Link back to the documents overview
    $html .= '<a href="' . $returnLink . '">' . Display::return_icon('back.png', get_lang('BackTo') . ' ' . get_lang('Maintenance'), '', ICON_SIZE_MEDIUM) . '</a>';
    $html .= '</div>';
    $html .= Display::return_message(get_lang('CopyCourseFromSessionToSessionExplanation'));
    $html .= '<form name="formulaire" method="post" action="' . api_get_self() . '?' . api_get_cidreq() . '" >';
    $html .= '<table border="0" cellpadding="5" cellspacing="0" width="100%">';
    // Source
    $html .= '<tr><td width="15%"><b>' . get_lang('OriginCoursesFromSession') . ':</b></td>';
    $html .= '<td width="10%" align="left">' . api_get_session_name($sessionId) . '</td>';
    $html .= '<td width="50%">';
    $html .= "{$courseInfo['title']} ({$courseInfo['code']})" . '</td></tr>';
    // Destination
    $html .= '<tr><td width="15%"><b>' . get_lang('DestinationCoursesFromSession') . ':</b></td>';
    $html .= '<td width="10%" align="left"><div id="ajax_sessions_list_destination">';
    $html .= '<select name="sessions_list_destination" onchange="javascript: xajax_searchCourses(this.value,\'destination\');">';
    if (empty($sessions)) {
        $html .= '<option value = "0">' . get_lang('ThereIsNotStillASession') . '</option>';
    } else {
        $html .= '<option value = "0">' . get_lang('SelectASession') . '</option>';
        foreach ($sessions as $session) {
            if ($session['id'] == $sessionId) {
                continue;
            }
            if (!SessionManager::sessionHasCourse($session['id'], $courseCode)) {
                continue;
            }
            $html .= '<option value="' . $session['id'] . '">' . $session['name'] . '</option>';
        }
    }
    $html .= '</select ></div></td>';
    $html .= '<td width="50%">';
    $html .= '<div id="ajax_list_courses_destination">';
    $html .= '<select id="destination" name="SessionCoursesListDestination[]" style="width:380px;" ></select></div></td>';
    $html .= '</tr></table>';
    $html .= "<fieldset>";
    $html .= '<legend>' . get_lang('TypeOfCopy') . ' <small>(' . get_lang('CopyOnlySessionItems') . ')</small></legend>';
    $html .= '<label class="radio"><input type="radio" id="copy_option_1" name="copy_option" value="full_copy" checked="checked"/>';
    $html .= get_lang('FullCopy') . '</label>';
    $html .= '<label class="radio"><input type="radio" id="copy_option_2" name="copy_option" value="select_items"/>';
    $html .= ' ' . get_lang('LetMeSelectItems') . '</label><br/>';
    $html .= "</fieldset>";
    $html .= '<button class="save" type="submit" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;">' . get_lang('CopyCourse') . '</button>';
    $html .= '</form>';
    echo $html;
}
function create_default_course_gradebook($course_code = null, $gradebook_model_id = 0, $session_id = null)
{
    $category_id = null;
    //if (api_is_allowed_to_edit(true, true)) {
    if (!isset($course_code) || empty($course_code)) {
        $course_code = api_get_course_id();
    }
    if (empty($session_id)) {
        $session_id = api_get_session_id();
    }
    $t = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
    $sql = "SELECT * FROM {$t} WHERE course_code = '" . Database::escape_string($course_code) . "' ";
    if (!empty($session_id)) {
        $sql .= " AND session_id = " . (int) $session_id;
    } else {
        $sql .= " AND (session_id IS NULL OR session_id = 0) ";
    }
    $sql .= " ORDER BY id";
    $res = Database::query($sql);
    if (Database::num_rows($res) < 1) {
        //there is no unique category for this course+session combination,
        $cat = new Category();
        if (!empty($session_id)) {
            $s_name = api_get_session_name($session_id);
            $cat->set_name($course_code . ' - ' . get_lang('Session') . ' ' . $s_name);
            $cat->set_session_id($session_id);
        } else {
            $cat->set_name($course_code);
        }
        $cat->set_course_code($course_code);
        $cat->set_description(null);
        $cat->set_user_id(api_get_user_id());
        $cat->set_parent_id(0);
        $default_weight_setting = api_get_setting('gradebook_default_weight');
        $default_weight = isset($default_weight_setting) && !empty($default_weight_setting) ? $default_weight_setting : 100;
        $cat->set_weight($default_weight);
        $cat->set_grade_model_id($gradebook_model_id);
        $cat->set_certificate_min_score(75);
        $cat->set_visible(0);
        $cat->add();
        $category_id = $cat->get_id();
        unset($cat);
    } else {
        $row = Database::fetch_array($res);
        $category_id = $row['id'];
    }
    //}
    return $category_id;
}
Exemple #13
0
 /**
  * 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();
     /* 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) ? '' : '&nbsp;(' . $session_name . ')';
     if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) {
         $navigation_item['url'] = $this->urlGenerator->generate('course_home.controller:indexAction', array('courseCode' => $_course['code'], 'sessionId' => $session_id));
         //$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('course.breadcrumbs_course_homepage')) {
             case 'get_lang':
                 $navigation_item['title'] = get_lang('CourseHomepageLink');
                 break;
             case 'course_code':
                 $navigation_item['title'] = $_course['official_code'];
                 break;
             case 'session_name_and_course_title':
                 $navigation_item['title'] = $course_title . $my_session_name;
                 break;
             default:
                 if (api_get_session_id() != -1) {
                     $navigation_item['title'] = $course_title . $my_session_name;
                 } else {
                     $navigation_item['title'] = $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'], '?') ? '&amp;' : '?';
                 $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;
     $navigation[] = array('url' => '#', 'title' => strip_tags($this->title));
     return $navigation;
     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;
         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)) {
                     $lis .= Display::tag('li', $bread);
                     $i++;
                 }
             }
         } else {
             if (!empty($home_link)) {
                 $lis .= Display::tag('li', $home_link);
             }
         }
         $html .= $lis;
     }
     return $html;
 }
    /**
     * This method return content html containing information about sessions and its position for showing it inside dashboard interface
     * it's important to use the name 'get_block' for beeing used from dashboard controller
     * @return array   column and content html
     */
    public function get_block()
    {
        global $charset;
        $column = 1;
        $data = array();
        $evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph();
        $evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph();
        $html = '<div class="panel panel-default" id="intro">
                    <div class="panel-heading">
                        ' . get_lang('EvaluationsGraph') . '
                        <div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . '\')) return false;" href="index.php?action=disable_block&path=' . $this->path . '">
                        <em class="fa fa-times"></em>
                        </a></div>
                    </div>
                    <div class="panel-body">';
        if (empty($evaluations_base_courses_graph) && empty($evaluations_courses_in_sessions_graph)) {
            $html .= '<p>' . api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8') . '</p>';
        } else {
            // display evaluations base courses graph
            if (!empty($evaluations_base_courses_graph)) {
                foreach ($evaluations_base_courses_graph as $course_code => $img_html) {
                    $html .= '<div><strong>' . $course_code . '</strong></div>';
                    $html .= $img_html;
                }
            }
            // display evaluations base courses graph
            if (!empty($evaluations_courses_in_sessions_graph)) {
                foreach ($evaluations_courses_in_sessions_graph as $session_id => $courses) {
                    $session_name = api_get_session_name($session_id);
                    $html .= '<div><strong>' . $session_name . ':' . get_lang('Evaluations') . '</strong></div>';
                    foreach ($courses as $course_code => $img_html) {
                        $html .= '<div><strong>' . $course_code . '</strong></div>';
                        $html .= $img_html;
                    }
                }
            }
        }
        $html .= '</div>
			     </div>';
        $data['column'] = $column;
        $data['content_html'] = $html;
        return $data;
    }
Exemple #15
0
/**
 * Builds an img html tag for the filetype
 *
 * @param string $type (file/folder)
 * @param string $path
 * @return string img html tag
 */
function build_document_icon_tag($type, $path)
{
    $basename = basename($path);
    $current_session_id = api_get_session_id();
    $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
    if ($type == 'file') {
        $icon = FileManager::choose_image($basename);
        if (preg_match('/_chnano_.wav$/i', $basename)) {
            $icon = "jplayer_play.png";
            $basename = 'wav' . ' ' . '(Nanogong)';
        } else {
            $basename = substr(strrchr($basename, '.'), 1);
        }
    } else {
        if ($path == '/shared_folder') {
            $icon = 'folder_users.gif';
            if ($is_allowed_to_edit) {
                $basename = get_lang('HelpUsersFolder');
            } else {
                $basename = get_lang('UserFolders');
            }
        } elseif (strstr($basename, 'sf_user_')) {
            $userinfo = api_get_user_info(substr($basename, 8));
            $image_path = UserManager::get_user_picture_path_by_id(substr($basename, 8), 'web', false, true);
            if ($image_path['file'] == 'unknown.jpg') {
                $icon = $image_path['file'];
            } else {
                $icon = '../upload/users/' . substr($basename, 8) . '/' . $image_path['file'];
            }
            $basename = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
        } elseif (strstr($path, 'shared_folder_session_')) {
            if ($is_allowed_to_edit) {
                $basename = '***(' . api_get_session_name($current_session_id) . ')*** ' . get_lang('HelpUsersFolder');
            } else {
                $basename = get_lang('UserFolders') . ' (' . api_get_session_name($current_session_id) . ')';
            }
            $icon = 'folder_users.gif';
        } else {
            $icon = 'folder_document.gif';
            if ($path == '/audio') {
                $icon = 'folder_audio.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Audio');
                }
            } elseif ($path == '/flash') {
                $icon = 'folder_flash.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Flash');
                }
            } elseif ($path == '/images') {
                $icon = 'folder_images.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Images');
                }
            } elseif ($path == '/video') {
                $icon = 'folder_video.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Video');
                }
            } elseif ($path == '/images/gallery') {
                $icon = 'folder_gallery.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpDefaultDirDocuments');
                } else {
                    $basename = get_lang('Gallery');
                }
            } elseif ($path == '/chat_files') {
                $icon = 'folder_chat.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpFolderChat');
                } else {
                    $basename = get_lang('ChatFiles');
                }
            } elseif ($path == '/learning_path') {
                $icon = 'folder_learningpath.gif';
                if (api_is_allowed_to_edit()) {
                    $basename = get_lang('HelpFolderLearningPaths');
                } else {
                    $basename = get_lang('LearningPaths');
                }
            }
        }
    }
    return Display::return_icon($icon, $basename, array());
}
Exemple #16
0
             $exportToPdf = true;
         }
         $gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, $addparams, $exportToPdf);
         if (api_is_allowed_to_edit()) {
             $gradebooktable->td_attributes = [4 => 'class=centered'];
         } else {
             $gradebooktable->td_attributes = [3 => 'class=centered', 4 => 'class=centered', 5 => 'class=centered', 6 => 'class=centered', 7 => 'class=centered'];
             if ($action == 'export_table') {
                 unset($gradebooktable->td_attributes[7]);
             }
         }
         $table = $gradebooktable->return_table();
         $graph = $gradebooktable->getGraph();
         if ($action == 'export_table') {
             ob_clean();
             $sessionName = api_get_session_name(api_get_session_id());
             $sessionName = !empty($sessionName) ? " - {$sessionName}" : '';
             $params = array('pdf_title' => sprintf(get_lang('GradeFromX'), $courseInfo['department_name']), 'course_code' => api_get_course_id(), 'session_info' => '', 'course_info' => '', 'pdf_date' => '', 'add_signatures' => false, 'student_info' => api_get_user_info(), 'show_grade_generated_date' => true, 'show_real_course_teachers' => false, 'show_teacher_as_myself' => false);
             $pdf = new PDF('A4', $params['orientation'], $params);
             $address = api_get_setting('platform.institution_address');
             $phone = api_get_setting('admin.administrator_phone');
             $address = str_replace('\\n', '<br />', $address);
             $pdf->custom_header = array('html' => "<h5  align='right'>{$address} <br />{$phone}</h5>");
             $pdf->html_to_pdf_with_template($table . $graph . '<br />' . get_lang('Feedback') . '<br />
                 <textarea rows="5" cols="100" ></textarea>');
         } else {
             echo $table;
             echo $graph;
         }
     }
 }
    /**
     * Display the form session export
     * @param array $hidden_fiels Hidden fields to add to the form.
     * @param boolean the document array will be serialize. This is used in the course_copy.php file
     */
    function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false)
    {
        ?>
		<script>
			function exp(item) {
				el = document.getElementById('div_'+item);
				if (el.style.display=='none'){
					el.style.display='';
					document.getElementById('img_'+item).src='../img/1.gif';
				}
				else{
					el.style.display='none';
					document.getElementById('img_'+item).src='../img/0.gif';
				}
			}
			function setCheckbox(type,value) {
 				d = document.course_select_form;
 				for (i = 0; i < d.elements.length; i++) {
   					if (d.elements[i].type == "checkbox") {
						var name = d.elements[i].attributes.getNamedItem('name').nodeValue;
 						if( name.indexOf(type) > 0 || type == 'all' ){
						     d.elements[i].checked = value;
						}
   					}
 				}
			}
			function checkLearnPath(message){
				d = document.course_select_form;
 				for (i = 0; i < d.elements.length; i++) {
 					if (d.elements[i].type == "checkbox") {
						var name = d.elements[i].attributes.getNamedItem('name').nodeValue;
 						if( name.indexOf('learnpath') > 0){
 							if(d.elements[i].checked){
	 							setCheckbox('document',true);
	 							alert(message);
	 							break;
 							}
 						}
 					}
 				}
			}
		</script>
		<?php 
        //get destination course title
        if (!empty($hidden_fields['destination_course'])) {
            require_once api_get_path(LIBRARY_PATH) . 'course.lib.php';
            if (!empty($hidden_fields['destination_session'])) {
                $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')';
            } else {
                $sessionTitle = null;
            }
            $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']);
            echo '<h3>';
            echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle;
            echo '</h3>';
        }
        echo '<script src="' . api_get_path(WEB_CODE_PATH) . 'inc/lib/javascript/upload.js" type="text/javascript"></script>';
        echo '<script type="text/javascript">var myUpload = new upload(1000);</script>';
        echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\'' . api_get_path(WEB_CODE_PATH) . 'img/progress_bar.gif\',\'' . get_lang('PleaseStandBy') . '\',\'upload_form\')">';
        echo '<input type="hidden" name="action" value="course_select_form"/>';
        foreach ($list_course as $course) {
            foreach ($course->resources as $type => $resources) {
                if (count($resources) > 0) {
                    echo '<img id="img_' . $course->code . '" src="../img/1.gif" onclick="javascript:exp(' . "'{$course->code}'" . ');" />';
                    echo '<b  onclick="javascript:exp(' . "'{$course->code}'" . ');" > ' . $course->code . '</b><br />';
                    echo '<div id="div_' . $course->code . '">';
                    echo '<blockquote>';
                    echo '<div class="btn-group">';
                    echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('" . $course->code . "',true);\" >" . get_lang('All') . "</a>";
                    echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('" . $course->code . "',false);\" >" . get_lang('None') . "</a>";
                    echo '</div><br />';
                    foreach ($resources as $id => $resource) {
                        echo '<label class="checkbox" for="resource[' . $course->code . '][' . $id . ']">';
                        echo '<input type="checkbox" name="resource[' . $course->code . '][' . $id . ']" id="resource[' . $course->code . '][' . $id . ']"/>';
                        $resource->show();
                        echo '</label>';
                    }
                    echo '</blockquote>';
                    echo '</div>';
                    echo '<script type="text/javascript">exp(' . "'{$course->code}'" . ')</script>';
                }
            }
        }
        if ($avoid_serialize) {
            //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files)
            // this is a known issue of serialize
            $course->resources['document'] = null;
        }
        echo '<input type="hidden" name="course" value="' . base64_encode(Course::serialize($course)) . '"/>';
        if (is_array($hidden_fields)) {
            foreach ($hidden_fields as $key => $value) {
                echo "\n";
                echo '<input type="hidden" name="' . $key . '" value="' . $value . '"/>';
            }
        }
        echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\'' . addslashes(get_lang('DocumentsWillBeAddedToo')) . '\')">' . get_lang('Ok') . '</button>';
        CourseSelectForm::display_hidden_quiz_questions($course);
        CourseSelectForm::display_hidden_scorm_directories($course);
        echo '</form>';
        echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>';
    }
 /**
  * @param int $userId
  * @param array $cats
  * @param bool $saveToFile
  * @param bool $saveToHtmlFile
  * @param array $studentList
  * @param PDF $pdf
  *
  * @return string
  */
 public static function generateTable($userId, $cats, $saveToFile = false, $saveToHtmlFile = false, $studentList = array(), $pdf = null)
 {
     $courseInfo = api_get_course_info();
     $userInfo = api_get_user_info($userId);
     $cat = $cats[0];
     $allcat = $cats[0]->get_subcategories($userId, api_get_course_id(), api_get_session_id());
     $alleval = $cats[0]->get_evaluations($userId);
     $alllink = $cats[0]->get_links($userId);
     $gradebooktable = new GradebookTable($cat, $allcat, $alleval, $alllink, null, true, false, $userId, $studentList);
     $gradebooktable->userId = $userId;
     if (api_is_allowed_to_edit()) {
         $gradebooktable->td_attributes = [4 => 'class=centered'];
     } else {
         $gradebooktable->td_attributes = [3 => 'class=centered', 4 => 'class=centered', 5 => 'class=centered', 6 => 'class=centered', 7 => 'class=centered'];
     }
     $table = $gradebooktable->return_table();
     $graph = $gradebooktable->getGraph();
     $sessionName = api_get_session_name(api_get_session_id());
     $sessionName = !empty($sessionName) ? " - {$sessionName}" : '';
     $params = array('pdf_title' => sprintf(get_lang('GradeFromX'), $courseInfo['department_name']), 'session_info' => '', 'course_info' => '', 'pdf_date' => '', 'course_code' => api_get_course_id(), 'add_signatures' => false, 'student_info' => $userInfo, 'show_grade_generated_date' => true, 'show_real_course_teachers' => false, 'show_teacher_as_myself' => false, 'orientation' => 'P');
     if (empty($pdf)) {
         $pdf = new PDF('A4', $params['orientation'], $params);
     }
     $pdf->params['student_info'] = $userInfo;
     $file = api_get_path(SYS_ARCHIVE_PATH) . uniqid() . '.html';
     $content = $table . $graph . '<br />' . get_lang('Feedback') . '<br />
         <textarea rows="5" cols="100" ></textarea>';
     $address = api_get_setting('institution_address');
     $phone = api_get_setting('administratorTelephone');
     $address = str_replace('\\n', '<br />', $address);
     $pdf->custom_header = array('html' => "<h5 align='right'>{$address} <br />{$phone}</h5>");
     $result = $pdf->html_to_pdf_with_template($content, $saveToFile, $saveToHtmlFile);
     if ($saveToHtmlFile) {
         file_put_contents($file, $result);
         return $file;
     }
     return $file;
 }
Exemple #19
0
 /**
  * Sends pending e-mails
  */
 public function check_emailcue($id_or_ref, $type, $lastime = '', $lastuser = '')
 {
     $tbl_wiki_mailcue = $this->tbl_wiki_mailcue;
     $tbl_wiki = $this->tbl_wiki;
     $condition_session = $this->condition_session;
     $groupfilter = $this->groupfilter;
     $_course = $this->courseInfo;
     $groupId = api_get_group_id();
     $session_id = api_get_session_id();
     $course_id = api_get_course_int_id();
     $group_properties = GroupManager::get_group_properties($groupId);
     $group_name = $group_properties['name'];
     $allow_send_mail = false;
     //define the variable to below
     $email_assignment = null;
     if ($type == 'P') {
         //if modifying a wiki page
         //first, current author and time
         //Who is the author?
         $userinfo = api_get_user_info($lastuser);
         $email_user_author = get_lang('EditedBy') . ': ' . $userinfo['complete_name'];
         //When ?
         $year = substr($lastime, 0, 4);
         $month = substr($lastime, 5, 2);
         $day = substr($lastime, 8, 2);
         $hours = substr($lastime, 11, 2);
         $minutes = substr($lastime, 14, 2);
         $seconds = substr($lastime, 17, 2);
         $email_date_changes = $day . ' ' . $month . ' ' . $year . ' ' . $hours . ":" . $minutes . ":" . $seconds;
         //second, extract data from first reg
         $sql = 'SELECT * FROM ' . $tbl_wiki . '
                 WHERE  c_id = ' . $course_id . ' AND reflink="' . $id_or_ref . '" AND ' . $groupfilter . $condition_session . '
                 ORDER BY id ASC';
         $result = Database::query($sql);
         $row = Database::fetch_array($result);
         $id = $row['id'];
         $email_page_name = $row['title'];
         if ($row['visibility'] == 1) {
             $allow_send_mail = true;
             //if visibility off - notify off
             $sql = 'SELECT * FROM ' . $tbl_wiki_mailcue . '
                     WHERE
                         c_id = ' . $course_id . ' AND
                         id="' . $id . '" AND
                         type="' . $type . '" OR
                         type="F" AND
                         group_id="' . $groupId . '" AND
                         session_id="' . $session_id . '"';
             //type: P=page, D=discuss, F=full.
             $result = Database::query($sql);
             $emailtext = get_lang('EmailWikipageModified') . ' <strong>' . $email_page_name . '</strong> ' . get_lang('Wiki');
         }
     } elseif ($type == 'D') {
         //if added a post to discuss
         //first, current author and time
         //Who is the author of last message?
         $userinfo = api_get_user_info($lastuser);
         $email_user_author = get_lang('AddedBy') . ': ' . $userinfo['complete_name'];
         //When ?
         $year = substr($lastime, 0, 4);
         $month = substr($lastime, 5, 2);
         $day = substr($lastime, 8, 2);
         $hours = substr($lastime, 11, 2);
         $minutes = substr($lastime, 14, 2);
         $seconds = substr($lastime, 17, 2);
         $email_date_changes = $day . ' ' . $month . ' ' . $year . ' ' . $hours . ":" . $minutes . ":" . $seconds;
         //second, extract data from first reg
         $id = $id_or_ref;
         //$id_or_ref is id from tblwiki
         $sql = 'SELECT * FROM ' . $tbl_wiki . '
                 WHERE c_id = ' . $course_id . ' AND id="' . $id . '"
                 ORDER BY id ASC';
         $result = Database::query($sql);
         $row = Database::fetch_array($result);
         $email_page_name = $row['title'];
         if ($row['visibility_disc'] == 1) {
             $allow_send_mail = true;
             //if visibility off - notify off
             $sql = 'SELECT * FROM ' . $tbl_wiki_mailcue . '
                     WHERE
                         c_id = ' . $course_id . ' AND
                         id="' . $id . '" AND
                         type="' . $type . '" OR
                         type="F" AND
                         group_id="' . $groupId . '" AND
                         session_id="' . $session_id . '"';
             //type: P=page, D=discuss, F=full
             $result = Database::query($sql);
             $emailtext = get_lang('EmailWikiPageDiscAdded') . ' <strong>' . $email_page_name . '</strong> ' . get_lang('Wiki');
         }
     } elseif ($type == 'A') {
         //for added pages
         $id = 0;
         //for tbl_wiki_mailcue
         $sql = 'SELECT * FROM ' . $tbl_wiki . '
                 WHERE c_id = ' . $course_id . '
                 ORDER BY id DESC';
         //the added is always the last
         $result = Database::query($sql);
         $row = Database::fetch_array($result);
         $email_page_name = $row['title'];
         //Who is the author?
         $userinfo = api_get_user_info($row['user_id']);
         $email_user_author = get_lang('AddedBy') . ': ' . $userinfo['complete_name'];
         //When ?
         $year = substr($row['dtime'], 0, 4);
         $month = substr($row['dtime'], 5, 2);
         $day = substr($row['dtime'], 8, 2);
         $hours = substr($row['dtime'], 11, 2);
         $minutes = substr($row['dtime'], 14, 2);
         $seconds = substr($row['dtime'], 17, 2);
         $email_date_changes = $day . ' ' . $month . ' ' . $year . ' ' . $hours . ":" . $minutes . ":" . $seconds;
         if ($row['assignment'] == 0) {
             $allow_send_mail = true;
         } elseif ($row['assignment'] == 1) {
             $email_assignment = get_lang('AssignmentDescExtra') . ' (' . get_lang('AssignmentMode') . ')';
             $allow_send_mail = true;
         } elseif ($row['assignment'] == 2) {
             $allow_send_mail = false;
             //Mode tasks: avoids notifications to all users about all users
         }
         $sql = 'SELECT * FROM ' . $tbl_wiki_mailcue . '
                 WHERE c_id = ' . $course_id . ' AND  id="' . $id . '" AND type="F" AND group_id="' . $groupId . '" AND session_id="' . $session_id . '"';
         //type: P=page, D=discuss, F=full
         $result = Database::query($sql);
         $emailtext = get_lang('EmailWikiPageAdded') . ' <strong>' . $email_page_name . '</strong> ' . get_lang('In') . ' ' . get_lang('Wiki');
     } elseif ($type == 'E') {
         $id = 0;
         $allow_send_mail = true;
         //Who is the author?
         $userinfo = api_get_user_info(api_get_user_id());
         //current user
         $email_user_author = get_lang('DeletedBy') . ': ' . $userinfo['complete_name'];
         //When ?
         $today = date('r');
         //current time
         $email_date_changes = $today;
         $sql = 'SELECT * FROM ' . $tbl_wiki_mailcue . '
                 WHERE
                     c_id = ' . $course_id . ' AND
                     id="' . $id . '" AND type="F" AND
                     group_id="' . $groupId . '" AND
                     session_id="' . $session_id . '"';
         //type: P=page, D=discuss, F=wiki
         $result = Database::query($sql);
         $emailtext = get_lang('EmailWikipageDedeleted');
     }
     ///make and send email
     if ($allow_send_mail) {
         while ($row = Database::fetch_array($result)) {
             $userinfo = api_get_user_info($row['user_id']);
             //$row['user_id'] obtained from tbl_wiki_mailcue
             $name_to = $userinfo['complete_name'];
             $email_to = $userinfo['email'];
             $sender_name = api_get_setting('admin.administrator_email');
             $sender_email = api_get_setting('admin.administrator_email');
             $email_subject = get_lang('EmailWikiChanges') . ' - ' . $_course['official_code'];
             $email_body = get_lang('DearUser') . ' ' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']) . ',<br /><br />';
             if ($session_id == 0) {
                 $email_body .= $emailtext . ' <strong>' . $_course['name'] . ' - ' . $group_name . '</strong><br /><br /><br />';
             } else {
                 $email_body .= $emailtext . ' <strong>' . $_course['name'] . ' (' . api_get_session_name(api_get_session_id()) . ') - ' . $group_name . '</strong><br /><br /><br />';
             }
             $email_body .= $email_user_author . ' (' . $email_date_changes . ')<br /><br /><br />';
             $email_body .= $email_assignment . '<br /><br /><br />';
             $email_body .= '<font size="-2">' . get_lang('EmailWikiChangesExt_1') . ': <strong>' . get_lang('NotifyChanges') . '</strong><br />';
             $email_body .= get_lang('EmailWikiChangesExt_2') . ': <strong>' . get_lang('NotNotifyChanges') . '</strong></font><br />';
             @api_mail_html($name_to, $email_to, $email_subject, $email_body, $sender_name, $sender_email);
         }
     }
 }
Exemple #20
0
Display::display_header($nameTools);
$a_courses = array();
if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
    $title = '';
    if (empty($id_session)) {
        if (isset($_GET['user_id'])) {
            $user_id = intval($_GET['user_id']);
            $user_info = api_get_user_info($user_id);
            $title = get_lang('AssignedCoursesTo') . ' ' . api_get_person_name($user_info['firstname'], $user_info['lastname']);
            $courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
        } else {
            $title = get_lang('YourCourseList');
            $courses = CourseManager::get_courses_followed_by_drh($_user['user_id']);
        }
    } else {
        $session_name = api_get_session_name($id_session);
        $title = api_htmlentities($session_name, ENT_QUOTES, $charset) . ' : ' . get_lang('CourseListInSession');
        $courses = Tracking::get_courses_list_from_session($id_session);
    }
    $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(), 32), "index.php?view=drh_students&amp;display=yourstudents");
        $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), 32), 'teachers.php');
        $menu_items[] = Display::return_icon('course_na.png', get_lang('Courses'), array(), 32);
        $menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), 32), 'session.php');
    }
    echo '<div class="actions">';
    $nb_menu_items = count($menu_items);
    if ($nb_menu_items > 1) {
        foreach ($menu_items as $key => $item) {
if ($searchSessionAndCourse || $searchCourseOnly) {
    $selectedCourseInfo = api_get_course_info_by_id($selectedCourse);
    if (empty($selectedCourseInfo)) {
        Session::write('reportErrorMessage', get_lang('NoCourse'));
        header("Location: {$selfUrl}");
        exit;
    }
    $gradebookCategories = Category::load(null, null, $selectedCourseInfo['code'], null, false, $selectedSession);
    $gradebook = null;
    if (!empty($gradebookCategories)) {
        $gradebook = current($gradebookCategories);
    }
    if (!is_null($gradebook)) {
        $exportAllLink = api_get_path(WEB_CODE_PATH) . "gradebook/gradebook_display_certificate.php?";
        $exportAllLink .= http_build_query(array("action" => "export_all_certificates", "cidReq" => $selectedCourseInfo['code'], "id_session" => 0, "gidReq" => 0, "cat_id" => $gradebook->get_id()));
        $sessionName = api_get_session_name($selectedSession);
        $courseName = api_get_course_info($selectedCourseInfo['code'])['title'];
        $studentList = GradebookUtils::get_list_users_certificates($gradebook->get_id());
        $certificateStudents = array();
        if (is_array($studentList) && !empty($studentList)) {
            foreach ($studentList as $student) {
                if (api_is_student_boss() && !in_array($student['user_id'], $userList)) {
                    continue;
                }
                $certificateStudent = array('fullName' => api_get_person_name($student['firstname'], $student['lastname']), 'sessionName' => $sessionName, 'courseName' => $courseName, 'certificates' => array());
                $studentCertificates = GradebookUtils::get_list_gradebook_certificates_by_user_id($student['user_id'], $gradebook->get_id());
                if (!is_array($studentCertificates) || empty($studentCertificates)) {
                    continue;
                }
                foreach ($studentCertificates as $certificate) {
                    $creationDate = new DateTime($certificate['created_at']);
    /**
     * This method return content html containing information about sessions and its position for showing it inside dashboard interface
     * it's important to use the name 'get_block' for beeing used from dashboard controller
     * @return array   column and content html
     */
    public function get_block()
    {
		global $charset;
    	$column = 1;
    	$data   = array();

		$evaluations_base_courses_graph         = $this->get_evaluations_base_courses_graph();
		$evaluations_courses_in_sessions_graph  = $this->get_evaluations_courses_in_sessions_graph();

		$html = '<li class="widget color-orange" id="intro">
                    <div class="widget-head">
                        <h3>'.get_lang('EvaluationsGraph').'</h3>
                        <div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div>
                    </div>
                    <div class="widget-content" align="center">';
                        if (empty($evaluations_base_courses_graph) && empty($evaluations_courses_in_sessions_graph)) {
                            $html .= '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'</p>';
                        } else {
                            // display evaluations base courses graph
                            if (!empty($evaluations_base_courses_graph)) {
                                foreach ($evaluations_base_courses_graph as $course_code => $img_html) {
                                    $html .= '<div><strong>'.$course_code.'</strong></div>';
                                    $html .= $img_html;
                                }
                            }
                            // display evaluations base courses graph
                            if (!empty($evaluations_courses_in_sessions_graph)) {
                                foreach ($evaluations_courses_in_sessions_graph as $session_id => $courses) {
                                    $session_name = api_get_session_name($session_id);
                                    $html .= '<div><strong>'.$session_name.':'.get_lang('Evaluations').'</strong></div>';
                                    foreach ($courses as $course_code => $img_html) {
                                        $html .= '<div><strong>'.$course_code.'</strong></div>';
                                        $html .= $img_html;
                                    }
                                }
                            }
                        }
		$html .= '</div>
			     </li>';

    	$data['column'] = $column;
    	$data['content_html'] = $html;

    	return $data;
	}
function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
{
    $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 = cut($session_name, MAX_LENGTH_BREADCRUMB);
    $my_session_name = is_null($session_name) ? '' : '&nbsp;(' . $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['name'] = api_htmlentities($_course['name']);
        $course_title = 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;
        }
        /**
         * @todo could be useful adding the My courses in the breadcrumb
        $navigation_item_my_courses['title'] = get_lang('MyCourses');
        $navigation_item_my_courses['url'] = api_get_path(WEB_PATH).'user_portal.php';
        $navigation[] = $navigation_item_my_courses;
        */
        $navigation[] = $navigation_item;
    }
    /* part 2: Interbreadcrumbs. 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 (isset($breadcrumb_step['type']) && $breadcrumb_step['type'] == 'right') {
                continue;
            }
            if ($breadcrumb_step['url'] != '#') {
                $sep = strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?';
                $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'] = cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB);
            $navigation_item['title'] = Security::remove_XSS($navigation_item['title']);
            $navigation[] = $navigation_item;
        }
    }
    $navigation_right = array();
    if (isset($interbreadcrumb) && is_array($interbreadcrumb)) {
        foreach ($interbreadcrumb as $breadcrumb_step) {
            if (isset($breadcrumb_step['type']) && $breadcrumb_step['type'] == 'right') {
                if ($breadcrumb_step['url'] != '#') {
                    $sep = strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?';
                    $navigation_item['url'] = $breadcrumb_step['url'] . $sep . api_get_cidreq();
                } else {
                    $navigation_item['url'] = '#';
                }
                $breadcrumb_step['title'] = cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB);
                $breadcrumb_step['title'] = Security::remove_XSS($navigation_item['title']);
                $navigation_right[] = $breadcrumb_step;
            }
        }
    }
    // 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)
    if (isset($nameTools) && $language_file != 'course_home') {
        // TODO: This condition $language_file != 'course_home' might bring surprises.
        $navigation_item['url'] = '#';
        $navigation_item['title'] = $nameTools;
        $navigation[] = $navigation_item;
    }
    $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 = '';
    /* Part 4 . Show the teacher view/student view button at the right of the breadcrumb */
    $view_as_student_link = null;
    if ($user_id && isset($course_id)) {
        if ((api_is_course_admin() || api_is_platform_admin()) && api_get_setting('student_view_enabled') == 'true') {
            $view_as_student_link = api_display_tool_view_option();
        }
    }
    if (!empty($final_navigation)) {
        $lis = '';
        $i = 0;
        $final_navigation_count = count($final_navigation);
        if (!empty($final_navigation)) {
            // $home_link.= '<span class="divider">/</span>';
            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);
            }
        }
        // View as student/teacher link
        if (!empty($view_as_student_link)) {
            $lis .= Display::tag('li', $view_as_student_link, array('id' => 'view_as_link', 'class' => 'pull-right'));
        }
        if (!empty($navigation_right)) {
            foreach ($navigation_right as $item) {
                $extra_class = isset($item['class']) ? $item['class'] : null;
                $lis .= Display::tag('li', $item['title'], array('class' => $extra_class . ' pull-right'));
            }
        }
        if (!empty($lis)) {
            $html .= Display::tag('ul', $lis, array('class' => 'breadcrumb', 'style' => 'margin-top: 0'));
        }
    }
    return $html;
}
Exemple #24
0
         }
         $data[] = $user;
         $counter++;
     }
 }
 switch ($_GET['type']) {
     case 'csv':
         Export::export_table_csv_utf8($a_users);
         exit;
     case 'xls':
         Export::export_table_xls($a_users);
         exit;
     case 'pdf':
         $description = '<table class="data_table_no_border">';
         if (api_get_session_id()) {
             $description .= '<tr><td>' . get_lang('Session') . ': </td><td class="highlight">' . api_get_session_name(api_get_session_id()) . '</td>';
         }
         $description .= '<tr><td>' . get_lang('Course') . ': </td><td class="highlight">' . $course_info['name'] . '</td>';
         $teachers = CourseManager::get_teacher_list_from_course_code($course_info['real_id']);
         //If I'm a teacher in this course show just my name
         if (isset($teachers[$user_id])) {
             if (!empty($teachers)) {
                 $teacher_info = $teachers[$user_id];
                 $description .= '<tr><td>' . get_lang('Teacher') . ': </td><td class="highlight">' . api_get_person_name($teacher_info['firstname'], $teacher_info['lastname']) . '</td>';
             }
         } else {
             //If not show all teachers
             $teachers = CourseManager::get_teacher_list_from_course_code_to_string($course_info['real_id']);
             if (!empty($teachers)) {
                 $description .= '<tr><td>' . get_lang('Teachers') . ': </td><td class="highlight">' . $teachers . '</td>';
             }
Exemple #25
0
$form_search->addElement('style_submit_button', 'submit', get_lang('SearchUsers'), 'class="search"');
$form_search->display();
echo '</div>';
// BEGIN : form to remind inactives susers
if (count($a_students) > 0) {
    $form = new FormValidator('reminder_form', 'get', api_get_path(REL_CODE_PATH) . 'announcements/announcements.php');
    $renderer = $form->defaultRenderer();
    $renderer->setElementTemplate('<span>{label} {element}</span>&nbsp;<button class="save" type="submit">' . get_lang('SendNotification') . '</button>', 'since');
    $options = array(2 => '2 ' . get_lang('Days'), 3 => '3 ' . get_lang('Days'), 4 => '4 ' . get_lang('Days'), 5 => '5 ' . get_lang('Days'), 6 => '6 ' . get_lang('Days'), 7 => '7 ' . get_lang('Days'), 15 => '15 ' . get_lang('Days'), 30 => '30 ' . get_lang('Days'), 'never' => get_lang('Never'));
    $el = $form->addElement('select', 'since', '<img width="ICON_SIZE_SMALL" align="middle" src="' . api_get_path(WEB_IMG_PATH) . 'messagebox_warning.gif" border="0" />' . get_lang('RemindInactivesLearnersSince'), $options);
    $el->setSelected(7);
    $form->addElement('hidden', 'action', 'add');
    $form->addElement('hidden', 'remindallinactives', 'true');
    $course_name = get_lang('Course') . ' ' . $course_info['name'];
    if ($session_id) {
        echo Display::page_subheader(Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL) . ' ' . api_get_session_name($session_id) . ' ' . Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL) . ' ' . $course_name);
    } else {
        echo Display::page_subheader(Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL) . ' ' . $course_info['name']);
    }
    $extra_field_select = TrackingCourseLog::display_additional_profile_fields();
    if (!empty($extra_field_select)) {
        echo $extra_field_select;
    }
    $form->display();
    //PERSON_NAME_DATA_EXPORT is buggy
    $is_western_name_order = api_is_western_name_order();
    if ($export_csv) {
        $csv_content = array();
        //override the SortableTable "per page" limit if CSV
        $_GET['users_tracking_per_page'] = 1000000;
    }
Exemple #26
0
);
$renderer = $form_search->defaultRenderer();
$renderer->setElementTemplate('<span>{element}</span>');
$form_search->addElement('hidden', 'from', Security::remove_XSS($from));
$form_search->addElement('hidden', 'session_id', $sessionId);
$form_search->addElement('hidden', 'id_session', $sessionId);
$form_search->addElement('text', 'user_keyword');
$form_search->addElement('style_submit_button', 'submit', get_lang('SearchUsers'), 'class="search"');
$form_search->display();
echo '</div>';

$course_name = get_lang('Course').' '.$courseInfo['name'];

if ($session_id) {
    echo Display::page_subheader(
        Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.api_get_session_name($session_id).' '.
        Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$course_name
    );
} else {
    echo Display::page_subheader(
        Display::return_icon('course.png', get_lang('Course'), array(), ICON_SIZE_SMALL).' '.$courseInfo['name']
    );
}

$teacherList = CourseManager::get_teacher_list_from_course_code_to_string(
    $courseInfo['code'],
    ',',
    false
);

$coaches = null;
api_block_anonymous_users();
$permissions_for_new_directories = api_get_permissions_for_new_directories();
$permissions_for_new_files = api_get_permissions_for_new_files();
$userId = api_get_user_id();
$sessionId = api_get_session_id();
if (!empty($_course['path'])) {
    require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
    require_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
    // Get the Chamilo session properties. Before ajaximagemanager!!!
    $groupId = api_get_group_id();
    $group_properties = GroupManager::get_group_properties($groupId);
    $is_user_in_group = GroupManager::is_user_in_group($userId, $groupId);
}
$sessionName = null;
if (!empty($sessionId)) {
    $sessionName = api_get_session_name($sessionId);
}
$my_path = UserManager::get_user_picture_path_by_id($userId, 'system');
$user_folder = $my_path['dir'] . 'my_files/';
// Sanity checks for Chamilo.
// Creation of a user owned folder if it does not exist.
if (!file_exists($user_folder)) {
    // A recursive call of mkdir function.
    @mkdir($user_folder, $permissions_for_new_directories, true);
}
// Creation of repository used by platform administrators if it does not exist.
if (api_is_platform_admin()) {
    $homepage_folder = api_get_path(SYS_PATH) . 'home/default_platform_document/';
    if (!file_exists($homepage_folder)) {
        @mkdir($homepage_folder, $permissions_for_new_directories);
    }