/** * Filter to display the modify-buttons * * @param - int $id The reservation-id */ function modify_filter($id) { $out = ' <a href="m_reservation.php?action=accept&rid=' . $id . '" alt="' . get_lang('AutoAccept') . '"><img title="' . get_lang('AutoAccept') . '" alt="' . get_lang('AutoAccept') . '" src="../img/students.gif" /></a>'; $out .= '<a href="m_reservation.php?action=edit&id=' . $id . '" alt="' . get_lang('EditBookingPeriod') . '"><img title="' . get_lang('EditBookingPeriod') . '" alt="' . get_lang('EditBookingPeriod') . '" src="../img/edit.gif" /></a>'; $out .= ' <a href="m_reservation.php?action=delete&id=' . $id . '" alt="' . get_lang('DeleteBookingPeriod') . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmDeleteBookingPeriod"))) . "'" . ')) return false;"><img title="' . get_lang('DeleteBookingPeriod') . '" alt="' . get_lang('DeleteBookingPeriod') . '" src="../img/delete.gif" /></a>'; return $out; }
/** * 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()); } }
/** * This method return content html containing information about teachers 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(); $teacher_information_graph = $this->get_teachers_information_graph(); $html = ' <li class="widget color-blue" id="intro"> <div class="widget-head"> <h3>'.get_lang('TeachersInformationsGraph').'</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"> <div style="padding:10px;"><strong>'.get_lang('TimeSpentOnThePlatformLastWeekByDay').'</strong></div> '.$teacher_information_graph.' </div> </li> '; $data['column'] = $column; $data['content_html'] = $html; return $data; }
function edit_filter($id, $url_params, $row) { global $charset; $return = '<a href="specific_fields_add.php?action=edit&field_id=' . $row[0] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>'; $return .= ' <a href="' . api_get_self() . '?action=delete&field_id=' . $row[0] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . Display::return_icon('delete.gif', get_lang('Delete')) . '</a>'; return $return; }
/** * This method return content html containing information about courses 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 = 2; $data = array(); $content = $this->get_content_html(); $html = ' <li class="widget color-green" id="intro"> <div class="widget-head"> <h3>' . get_lang('CoursesInformation') . '</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"> ' . $content . ' </div> </li> '; $data['column'] = $column; $data['content_html'] = $html; return $data; }
/** * Filter for sortable table to display edit icons for class */ function modify_filter($class_id) { $class_id = Security::remove_XSS($class_id); $result = '<a href="class_information.php?id=' . $class_id . '">' . Display::return_icon('synthese_view.gif', get_lang('Info')) . '</a>'; $result .= ' <a href="class_edit.php?idclass=' . $class_id . '">' . Display::return_icon('edit.png', get_lang('Edit')) . '</a>'; $result .= ' <a href="subscribe_user2class.php?idclass=' . $class_id . '">' . Display::return_icon('add_multiple_users.gif', get_lang('AddUsersToAClass')) . '</a>'; $result .= ' <a href="class_list.php?action=delete_class&class_id=' . $class_id . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES)) . "'" . ')) return false;">' . Display::return_icon('delete.png', get_lang('Delete')) . '</a>'; return $result; }
public function send_invitation($username, $password, $userfriend_id, $content_message = '') { global $charset; if ($this->verifyUserPass($username, $password) == "valid") { $user_id = UserManager::get_user_id_from_username($username); $message_title = get_lang('Invitation'); $count_is_true = SocialManager::send_invitation_friend($user_id, $userfriend_id, $message_title, $content_message); if ($count_is_true) { return Display::display_normal_message(api_htmlentities(get_lang('InvitationHasBeenSent'), ENT_QUOTES, $charset), false); } else { return Display::display_error_message(api_htmlentities(get_lang('YouAlreadySentAnInvitation'), ENT_QUOTES, $charset), false); } } return get_lang('InvalidId'); }
/** * Gets html pages and compose them into a learning path * @param array The files that will compose the generated learning path. Unused so far. * @return boolean False if file does not exit. Nothing otherwise. */ function make_lp($files = array()) { global $_course; // We get a content where ||page_break|| indicates where the page is broken. if (!file_exists($this->base_work_dir.'/'.$this->created_dir.'/'.$this->file_name.'.html')) { return false; } $content = file_get_contents($this->base_work_dir.'/'.$this->created_dir.'/'.$this->file_name.'.html'); unlink($this->base_work_dir.'/'.$this->file_path); unlink($this->base_work_dir.'/'.$this->created_dir.'/'.$this->file_name.'.html'); // The file is utf8 encoded and it seems to make problems with special quotes. // Then we htmlentities that, we replace these quotes and html_entity_decode that in good charset. $charset = api_get_system_encoding(); $content = api_htmlentities($content, ENT_COMPAT, $this->original_charset); $content = str_replace('’', '\'', $content); $content = api_convert_encoding($content, $charset, $this->original_charset); $content = str_replace($this->original_charset, $charset, $content); $content = api_html_entity_decode($content, ENT_COMPAT, $charset); // Set the path to pictures to absolute (so that it can be modified in fckeditor). $content = preg_replace("|src=\"([^\"]*)|i", "src=\"".api_get_path(REL_COURSE_PATH).$_course['path'].'/document'.$this->created_dir."/\\1", $content); list($header, $body) = explode('<BODY', $content); $body = '<BODY'.$body; // Remove font-family styles. $header = preg_replace("|font\-family[^;]*;|i", '', $header); // Chamilo styles. $my_style = api_get_setting('stylesheets'); if (empty($my_style)) { $my_style = 'chamilo'; } $style_to_import = "<style type=\"text/css\">\r\n"; $style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/default.css";'."\n"; $style_to_import .= "</style>\r\n"; $header = preg_replace("|</head>|i", "\r\n$style_to_import\r\n\\0", $header); // Line break before and after picture. $header = str_replace('p {', 'p {clear:both;', $header); $header = str_replace('absolute', 'relative', $header); switch ($this->split_steps) { case 'per_page': $this -> dealPerPage($header, $body); break; case 'per_chapter': $this -> dealPerChapter($header, $body); break; } }
/** * 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; }
/** * 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; }
/** * This method return content html containing information about courses 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 = 2; $data = array(); $content = $this->get_content_html(); $html = '<div class="panel panel-default" id="intro"> <div class="panel-heading">' . get_lang('GradebookAndAttendances') . ' <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"> ' . $content . ' </div> </div> '; $data['column'] = $column; $data['content_html'] = $html; return $data; }
/** * This method return content html containing information about students * and its position for showing it inside dashboard interface * it's important to use the name 'get_block' for being used from dashboard controller * @return array column and content html */ public function get_block() { global $charset; $column = 1; $data = array(); $students_attendance_graph = $this->get_students_attendance_graph(); $html = '<div class="panel panel-default" id="intro"> <div class="panel-heading"> ' . get_lang('StudentsInformationsGraph') . ' <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" align="center"> <div style="padding:10px;"><strong>' . get_lang('AttendancesFaults') . '</strong></div> ' . $students_attendance_graph . ' </div> </div>'; $data['column'] = $column; $data['content_html'] = $html; return $data; }
/** * This method return content html containing information about teachers 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(); /*if (api_is_platform_admin()) { $teacher_content_html = $this->get_teachers_content_html_for_platform_admin(); } else if (api_is_drh()) {*/ $teacher_content_html = $this->get_teachers_content_html_for_drh(); //} $html = '<li class="widget color-blue" id="intro"> <div class="widget-head"> <h3>' . get_lang('TeachersInformationsList') . '</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"> ' . $teacher_content_html . ' </div> </li>'; $data['column'] = $column; $data['content_html'] = $html; return $data; }
/** * This method return content html containing information about teachers 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(); $teacher_content_html = $this->get_teachers_content_html_for_drh(); $html = ' <div class="panel panel-default" id="intro"> <div class="panel-heading"> ' . get_lang('TeachersInformationsList') . ' <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 . '"> <i class="fa fa-times"></i> </a></div> </div> <div class="panel-body"> ' . $teacher_content_html . ' </div> </div> '; $data['column'] = $column; $data['content_html'] = $html; return $data; }
/** * Export tabular data to XLS-file (as html table) * @param array $data * @param string $filename */ public static function export_table_xls_html($data, $filename = 'export', $encoding = 'utf-8') { $file = api_get_path(SYS_ARCHIVE_PATH) . uniqid('') . '.xls'; $handle = fopen($file, 'a+'); $systemEncoding = api_get_system_encoding(); fwrite($handle, '<!DOCTYPE html><html><meta http-equiv="Content-Type" content="text/html" charset="utf-8" /><body><table>'); foreach ($data as $id => $row) { foreach ($row as $id2 => $row2) { $data[$id][$id2] = api_htmlentities($row2); } } foreach ($data as $row) { $string = implode("</td><td>", $row); $string = '<tr><td>' . $string . '</td></tr>'; if ($encoding != 'utf-8') { $string = api_convert_encoding($string, $encoding, $systemEncoding); } fwrite($handle, $string . "\n"); } fwrite($handle, '</table></body></html>'); fclose($handle); DocumentManager::file_send_for_download($file, true, $filename . '.xls'); exit; }
// The order is important you need to check the the $column variable in the model.ajax.php file $columns = array(get_lang('FirstName'), get_lang('LastName'), get_lang('LoginName'), get_lang('Group'), get_lang('Duration') . ' (' . get_lang('MinMinute') . ')', get_lang('StartDate'), get_lang('EndDate'), get_lang('Score'), get_lang('IP'), get_lang('Status'), get_lang('ToolLearnpath'), get_lang('Actions')); if ($officialCodeInList === 'true') { $columns = array_merge(array(get_lang('OfficialCode')), $columns); } //Column config $column_model = array(array('name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'true'), array('name' => 'lastname', 'index' => 'lastname', 'width' => '50', 'align' => 'left', 'formatter' => 'action_formatter', 'search' => 'true'), array('name' => 'login', 'index' => 'username', 'width' => '40', 'align' => 'left', 'search' => 'true', 'hidden' => 'true'), array('name' => 'group_name', 'index' => 'group_id', 'width' => '40', 'align' => 'left', 'search' => 'true', 'stype' => 'select', 'searchoptions' => array('defaultValue' => 'group_all', 'value' => $group_parameters), 'editoptions' => array('value' => $group_parameters)), array('name' => 'duration', 'index' => 'exe_duration', 'width' => '30', 'align' => 'left', 'search' => 'true'), array('name' => 'start_date', 'index' => 'start_date', 'width' => '60', 'align' => 'left', 'search' => 'true'), array('name' => 'exe_date', 'index' => 'exe_date', 'width' => '60', 'align' => 'left', 'search' => 'true'), array('name' => 'score', 'index' => 'exe_result', 'width' => '50', 'align' => 'left', 'search' => 'true'), array('name' => 'ip', 'index' => 'user_ip', 'width' => '40', 'align' => 'center', 'search' => 'true'), array('name' => 'status', 'index' => 'revised', 'width' => '40', 'align' => 'left', 'search' => 'true', 'stype' => 'select', 'searchoptions' => array('defaultValue' => '', 'value' => ':' . get_lang('All') . ';1:' . get_lang('Validated') . ';0:' . get_lang('NotValidated')), 'editoptions' => array('value' => ':' . get_lang('All') . ';1:' . get_lang('Validated') . ';0:' . get_lang('NotValidated'))), array('name' => 'lp', 'index' => 'lp', 'width' => '60', 'align' => 'left', 'search' => 'false'), array('name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false')); if ($officialCodeInList == 'true') { $officialCodeRow = array('name' => 'official_code', 'index' => 'official_code', 'width' => '50', 'align' => 'left', 'search' => 'true'); $column_model = array_merge(array($officialCodeRow), $column_model); } $action_links = ' // add username as title in lastname filed - ref 4226 function action_formatter(cellvalue, options, rowObject) { // rowObject is firstname,lastname,login,... get the third word var loginx = "' . api_htmlentities(sprintf(get_lang("LoginX"), ":::"), ENT_QUOTES) . '"; var tabLoginx = loginx.split(/:::/); // tabLoginx[0] is before and tabLoginx[1] is after ::: // may be empty string but is defined return "<span title=\\""+tabLoginx[0]+rowObject[2]+tabLoginx[1]+"\\">"+cellvalue+"</span>"; }'; } //Autowidth $extra_params['autowidth'] = 'true'; //height auto $extra_params['height'] = 'auto'; ?> <script> function setSearchSelect(columnName) { $("#results").jqGrid( 'setColProp',
if ($key < $number_of_courses - 1) { ?> <a href="courses.php?action=<?php echo $action; ?>&move=down&course=<?php echo $course['code']; ?>&category=<?php echo $course['user_course_cat']; ?>&sec_token=<?php echo $stok; ?>"> <?php echo Display::display_icon('down.png', get_lang('Down'),'',22); ?> </a> <?php } else { echo Display::display_icon('down_na.png', get_lang('Down'),'',22); }?> </div> <div style="float:left; margin-right:10px;"> <!-- cancel subscrioption--> <?php if ($course['status'] != 1) { if ($course['unsubscr'] == 1) { ?> <!-- changed link to submit to avoid action by the search tool indexer --> <form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding())) ?>')) return false;"> <input type="hidden" name="sec_token" value="<?php echo $stok; ?>"> <input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" /> <button class="btn" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub"> <?php echo get_lang('Unsubscribe'); ?> </button> </form> </div> <?php } } ?> </td> </tr> <?php $key++; }
$courseInfo = api_get_course_info(); $workInfo = get_work_data_by_id($itemId); $workInfoParent = get_work_data_by_id($workInfo['parent_id']); $resultUpload = uploadWork($workInfoParent, $courseInfo, true, $workInfo); $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); if (isset($resultUpload['url']) && !empty($resultUpload['url'])) { $title = isset($resultUpload['filename']) && !empty($resultUpload['filename']) ? $resultUpload['filename'] : get_lang('Untitled'); $url = Database::escape_string($resultUpload['url']); $title = Database::escape_string($title); $sql = "UPDATE {$work_table} SET\n url_correction = '" . $url . "',\n title_correction = '" . $title . "'\n WHERE iid = {$itemId}"; Database::query($sql); $result['title'] = $resultUpload['filename']; $result['url'] = 'view.php?' . api_get_cidreq() . '&id=' . $itemId; $json = array(); $json['name'] = Display::url(api_htmlentities($result['title']), api_htmlentities($result['url']), array('target' => '_blank')); $json['type'] = api_htmlentities($file['type']); $json['size'] = format_file_size($file['size']); } if (isset($result['url'])) { $json['result'] = Display::return_icon('accept.png', get_lang('Uploaded')); } else { $json['result'] = Display::return_icon('exclamation.png', get_lang('Error')); } echo json_encode($json); } break; default: echo ''; break; } exit;
} Session::write('objExercise', $objExercise); } } } if (isset($_SESSION['gradebook'])) { $gradebook = $_SESSION['gradebook']; } if (!empty($gradebook) && $gradebook == 'view') { $interbreadcrumb[] = array('url' => '../gradebook/' . Security::remove_XSS($_SESSION['gradebook_dest']), 'name' => get_lang('ToolGradebook')); } // if admin of course if (!$is_allowedToEdit) { api_not_allowed(true); } $confirmYourChoice = addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)); $htmlHeadXtra[] = "\n<script>\n\tfunction submit_form(obj) {\n\t\tdocument.question_pool.submit();\n\t}\n\n\tfunction mark_course_id_changed() {\n\t\t\$('#course_id_changed').val('1');\n\t}\n\n\tfunction mark_exercice_id_changed() {\n\t\t\$('#exercice_id_changed').val('1');\n\t}\n\n\tfunction confirm_your_choice() {\n\t\treturn confirm('{$confirmYourChoice}');\n\t}\n</script>"; Display::display_header($nameTools, 'Exercise'); // Menu echo '<div class="actions">'; if (isset($type)) { $url = api_get_self() . '?type=1'; } else { $url = api_get_self(); } if (isset($fromExercise) && $fromExercise > 0) { echo '<a href="admin.php?' . api_get_cidreq() . '&exerciseId=' . $fromExercise . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>'; $titleAdd = get_lang('AddQuestionToTest'); } else { echo '<a href="exercice.php?' . api_get_cidReq() . '">' . Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM) . '</a>'; echo "<a href='admin.php?exerciseId=0'>" . Display::return_icon('add_question.gif', get_lang('NewQu'), '', ICON_SIZE_MEDIUM) . "</a>";
/** * @param array $group_list * @param int $category_id */ static function process_groups($group_list, $category_id = null) { global $origin, $charset; $category_id = intval($category_id); $totalRegistered = 0; $group_data = array(); $user_info = api_get_user_info(); $session_id = api_get_session_id(); $user_id = $user_info['user_id']; $orig = isset($origin) ? $origin : null; foreach ($group_list as $this_group) { // Validation when belongs to a session $session_img = api_get_session_image($this_group['session_id'], $user_info['status']); // All the tutors of this group $tutorsids_of_group = self::get_subscribed_tutors($this_group['id'], true); // Create a new table-row $row = array(); // Checkbox if (api_is_allowed_to_edit(false, true) && count($group_list) > 1) { $row[] = $this_group['id']; } // Group name if ((api_is_allowed_to_edit(false, true) || in_array($user_id, $tutorsids_of_group) || $this_group['is_member'] || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_FORUM) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_DOCUMENTS) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_CALENDAR) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_ANNOUNCEMENT) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WORK) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WIKI)) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) { $group_name = '<a href="group_space.php?cidReq=' . api_get_course_id() . '&origin=' . $orig . '&gidReq=' . $this_group['id'] . '">' . Security::remove_XSS($this_group['name']) . '</a> '; if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) { $group_name .= Display::label(get_lang('OneMyGroups'), 'success'); } elseif ($this_group['is_member']) { $group_name .= Display::label(get_lang('MyGroup'), 'success'); } if (api_is_allowed_to_edit() && !empty($this_group['session_name'])) { $group_name .= ' (' . $this_group['session_name'] . ')'; } $group_name .= $session_img; $row[] = $group_name . '<br />' . stripslashes(trim($this_group['description'])); } else { $row[] = $this_group['name'] . '<br />' . stripslashes(trim($this_group['description'])); } // Tutor name $tutor_info = null; if (count($tutorsids_of_group) > 0) { foreach ($tutorsids_of_group as $tutor_id) { $tutor = api_get_user_info($tutor_id); $username = api_htmlentities(sprintf(get_lang('LoginX'), $tutor['username']), ENT_QUOTES); if (api_get_setting('show_email_addresses') == 'true') { $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', '; } else { if (api_is_allowed_to_edit()) { $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', '; } else { $tutor_info .= Display::tag('span', api_get_person_name($tutor['firstName'], $tutor['lastName']), array('title' => $username)) . ', '; } } } } $tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2); $row[] = $tutor_info; // Max number of members in group $max_members = $this_group['maximum_number_of_members'] == self::MEMBER_PER_GROUP_NO_LIMIT ? ' ' : ' / ' . $this_group['maximum_number_of_members']; // Number of members in group $row[] = $this_group['number_of_members'] . $max_members; // Self-registration / unregistration if (!api_is_allowed_to_edit(false, true)) { if (self::is_self_registration_allowed($user_id, $this_group['id'])) { $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&action=self_reg&group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfRegInf') . '</a>'; } elseif (self::is_self_unregistration_allowed($user_id, $this_group['id'])) { $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&action=self_unreg&group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfUnRegInf') . '</a>'; } else { $row[] = '-'; } } $url = api_get_path(WEB_CODE_PATH) . 'group/'; // Edit-links if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) { $edit_actions = '<a href="' . $url . 'settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '" title="' . get_lang('Edit') . '">' . Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL) . '</a> '; $edit_actions .= '<a href="' . $url . 'member_settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '" title="' . get_lang('GroupMembers') . '">' . Display::return_icon('user.png', get_lang('GroupMembers'), '', ICON_SIZE_SMALL) . '</a> '; $edit_actions .= '<a href="' . $url . 'group_overview.php?action=export&type=xls&' . api_get_cidreq(true, false) . '&id=' . $this_group['id'] . '" title="' . get_lang('ExportUsers') . '">' . Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL) . '</a> '; /*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=empty_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'. Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a> ';*/ $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=fill_one&id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('FillGroup') . '">' . Display::return_icon('fill.png', get_lang('FillGroup'), '', ICON_SIZE_SMALL) . '</a> '; $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=delete_one&id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('Delete') . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a> '; $row[] = $edit_actions; } if (!empty($this_group['nbMember'])) { $totalRegistered = $totalRegistered + $this_group['nbMember']; } $group_data[] = $row; } // end loop $table = new SortableTableFromArrayConfig($group_data, 1, 20, 'group_category_' . $category_id); $table->set_additional_parameters(array('category' => $category_id)); $column = 0; if (api_is_allowed_to_edit(false, true) and count($group_list) > 1) { $table->set_header($column++, '', false); } $table->set_header($column++, get_lang('Groups')); $table->set_header($column++, get_lang('GroupTutor')); $table->set_header($column++, get_lang('Registered'), false); if (!api_is_allowed_to_edit(false, true)) { // If self-registration allowed $table->set_header($column++, get_lang('GroupSelfRegistration'), false); } if (api_is_allowed_to_edit(false, true)) { // Only for course administrator $table->set_header($column++, get_lang('Modify'), false); $form_actions = array(); $form_actions['fill_selected'] = get_lang('FillGroup'); $form_actions['empty_selected'] = get_lang('EmptyGroup'); $form_actions['delete_selected'] = get_lang('Delete'); if (count($group_list) > 1) { $table->set_form_actions($form_actions, 'group'); } } $table->display(); }
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $course_info = api_get_course_info($_REQUEST['course_code']); $courseId = $course_info['real_id']; $tool_name = $course_info['name']; $sql = "SELECT s.name, c.title\n FROM {$tbl_session_course} sc, {$tbl_session} s, {$tbl_course} c\n WHERE\n sc.session_id = s.id AND\n sc.c_id = c.id AND\n sc.session_id='{$id_session}' AND\n sc.c_id ='" . $courseId . "'"; $result = Database::query($sql); if (!(list($session_name, $course_title) = Database::fetch_row($result))) { header('Location: session_course_list.php?id_session=' . $id_session); exit; } //$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => "session_list.php", "name" => get_lang("SessionList")); $interbreadcrumb[] = array('url' => "resume_session.php?id_session=" . $id_session, "name" => get_lang('SessionOverview')); $interbreadcrumb[] = array('url' => "session_course_list.php?id_session={$id_session}", "name" => api_htmlentities($session_name, ENT_QUOTES, $charset)); $arr_infos = array(); if (isset($_POST['formSent']) && $_POST['formSent']) { $formSent = 1; // get all tutor by course_code in the session $sql = "SELECT user_id\n\t FROM {$tbl_session_rel_course_rel_user}\n\t WHERE session_id = '{$id_session}' AND c_id = '" . $courseId . "' AND status = 2"; $rs_coaches = Database::query($sql); $coaches_course_session = array(); if (Database::num_rows($rs_coaches) > 0) { while ($row_coaches = Database::fetch_row($rs_coaches)) { $coaches_course_session[] = $row_coaches[0]; } } $id_coaches = $_POST['id_coach']; if (is_array($id_coaches) && count($id_coaches) > 0) { foreach ($id_coaches as $id_coach) {
$poster_id = 0; $username = ""; } else { $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']); $poster_id = $forum['last_poster_id']; $userinfo = api_get_user_info($poster_id); $username = sprintf(get_lang('LoginX'), $userinfo['username']); } if (!empty($forum['last_post_id'])) { $html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY) . ' ' . api_convert_and_format_date($forum['last_post_date']) . '<br /> ' . get_lang('By') . ' ' . display_user_link($poster_id, $name, '', $username); } $html .= '</div>'; $html .= '<div class="col-md-4">'; if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && intval($sessionId) != 0)) { $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=edit&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=delete&content=forum&id=' . $forum['forum_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; $html .= return_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility']); $html .= return_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked']); $html .= return_up_down_icon('forum', $forum['forum_id'], $forumsInCategory); } $iconnotify = 'notification_mail_na.png'; $session_forum_notification = isset($_SESSION['forum_notification']['forum']) ? $_SESSION['forum_notification']['forum'] : false; if (is_array($session_forum_notification)) { if (in_array($forum['forum_id'], $session_forum_notification)) { $iconnotify = 'notification_mail.png'; } } if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) { $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=notify&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon($iconnotify, get_lang('NotifyMe'), null, ICON_SIZE_SMALL) . '</a>'; } $html .= '</div>';
function add_docs_to_visio($files = array()) { global $_course; foreach ($files as $file) { list($slide_name,$file_name) = explode('||',$file); // '||' is used as separator between slide name (with accents) and file name (without accents). $slide_name = api_htmlentities($slide_name, ENT_COMPAT, $this->original_charset); $slide_name = str_replace('’', '\'', $slide_name); $slide_name = api_convert_encoding($slide_name, api_get_system_encoding(), $this->original_charset); $slide_name = api_html_entity_decode($slide_name, ENT_COMPAT, api_get_system_encoding()); $did = add_document($_course, $this->created_dir.'/'.urlencode($file_name), 'file', filesize($this->base_work_dir.$this->created_dir.'/'.$file_name), $slide_name); if ($did) { api_item_property_update($_course, TOOL_DOCUMENT, $did, 'DocumentAdded', $_SESSION['_uid'], 0, null, null, null, api_get_session_id()); } } }
/** * Exports the learning path as a SCORM package. This is the main function that * gathers the content, transforms it, writes the imsmanifest.xml file, zips the * whole thing and returns the zip. * * This method needs to be called in PHP5, as it will fail with non-adequate * XML package (like the ones for PHP4), and it is *not* a static method, so * you need to call it on a learnpath object. * @TODO The method might be redefined later on in the scorm class itself to avoid * creating a SCORM structure if there is one already. However, if the initial SCORM * path has been modified, it should use the generic method here below. * @TODO link this function with the export_lp() function in the same class * @param string Optional name of zip file. If none, title of learnpath is * domesticated and trailed with ".zip" * @return string Returns the zip package string, or null if error */ function scorm_export() { global $_course; global $charset; if (!class_exists('DomDocument')) { error_log('DOM functions not supported for PHP version below 5.0', 0); $this->error = 'PHP DOM functions not supported for PHP versions below 5.0'; return null; } //remove memory and time limits as much as possible as this might be a long process... if (function_exists('ini_set')) { $mem = ini_get('memory_limit'); if (substr($mem, -1, 1) == 'M') { $mem_num = substr($mem, 0, -1); if ($mem_num < 128) { ini_set('memory_limit', '128M'); } } else { ini_set('memory_limit', '128M'); } ini_set('max_execution_time', 600); //}else{ //error_log('Scorm export: could not change memory and time limits',0); } //Create the zip handler (this will remain available throughout the method) $archive_path = api_get_path(SYS_ARCHIVE_PATH); $sys_course_path = api_get_path(SYS_COURSE_PATH); $temp_dir_short = uniqid(); $temp_zip_dir = $archive_path . "/" . $temp_dir_short; $temp_zip_file = $temp_zip_dir . "/" . md5(time()) . ".zip"; $zip_folder = new PclZip($temp_zip_file); $current_course_path = api_get_path(SYS_COURSE_PATH) . api_get_course_path(); $root_path = $main_path = api_get_path(SYS_PATH); $files_cleanup = array(); //place to temporarily stash the zipfiles //create the temp dir if it doesn't exist //or do a cleanup befor creating the zipfile if (!is_dir($temp_zip_dir)) { mkdir($temp_zip_dir); } else { //cleanup: check the temp dir for old files and delete them $handle = opendir($temp_zip_dir); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { unlink("{$temp_zip_dir}/{$file}"); } } closedir($handle); } $zip_files = $zip_files_abs = $zip_files_dist = array(); if (is_dir($current_course_path . '/scorm/' . $this->path) && is_file($current_course_path . '/scorm/' . $this->path . '/imsmanifest.xml')) { // remove the possible . at the end of the path $dest_path_to_lp = substr($this->path, -1) == '.' ? substr($this->path, 0, -1) : $this->path; $dest_path_to_scorm_folder = str_replace('//', '/', $temp_zip_dir . '/scorm/' . $dest_path_to_lp); $perm = api_get_setting('permissions_for_new_directories'); $perm = octdec(!empty($perm) ? $perm : '0770'); mkdir($dest_path_to_scorm_folder, $perm, true); $zip_files_dist = copyr($current_course_path . '/scorm/' . $this->path, $dest_path_to_scorm_folder, array('imsmanifest'), $zip_files); } //Build a dummy imsmanifest structure. Do not add to the zip yet (we still need it) //This structure is developed following regulations for SCORM 1.2 packaging in the SCORM 1.2 Content //Aggregation Model official document, secion "2.3 Content Packaging" $xmldoc = new DOMDocument('1.0', $this->encoding); $root = $xmldoc->createElement('manifest'); $root->setAttribute('identifier', 'SingleCourseManifest'); $root->setAttribute('version', '1.1'); $root->setAttribute('xmlns', 'http://www.imsproject.org/xsd/imscp_rootv1p1p2'); $root->setAttribute('xmlns:adlcp', 'http://www.adlnet.org/xsd/adlcp_rootv1p2'); $root->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); $root->setAttribute('xsi:schemaLocation', 'http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd'); //Build mandatory sub-root container elements $metadata = $xmldoc->createElement('metadata'); $md_schema = $xmldoc->createElement('schema', 'ADL SCORM'); $metadata->appendChild($md_schema); $md_schemaversion = $xmldoc->createElement('schemaversion', '1.2'); $metadata->appendChild($md_schemaversion); $root->appendChild($metadata); $organizations = $xmldoc->createElement('organizations'); $resources = $xmldoc->createElement('resources'); //Build the only organization we will use in building our learnpaths $organizations->setAttribute('default', 'dokeos_scorm_export'); $organization = $xmldoc->createElement('organization'); $organization->setAttribute('identifier', 'dokeos_scorm_export'); //to set the title of the SCORM entity (=organization), we take the name given //in Dokeos and convert it to HTML entities using the Dokeos charset (not the //learning path charset) as it is the encoding that defines how it is stored //in the database. Then we convert it to HTML entities again as the "&" character //alone is not authorized in XML (must be &) //The title is then decoded twice when extracting (see scorm::parse_manifest) $org_title = $xmldoc->createElement('title', htmlentities(api_htmlentities($this->get_name(), ENT_QUOTES, $charset))); $organization->appendChild($org_title); //For each element, add it to the imsmanifest structure, then add it to the zip. //Always call the learnpathItem->scorm_export() method to change it to the SCORM //format $link_updates = array(); foreach ($this->items as $index => $item) { if (!in_array($item->type, array(TOOL_QUIZ, TOOL_FORUM, TOOL_THREAD, TOOL_LINK, TOOL_STUDENTPUBLICATION))) { //get included documents from this item if ($item->type == 'sco') { $inc_docs = $item->get_resources_from_source(null, api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/' . 'scorm/' . $this->path . '/' . $item->get_path()); } else { $inc_docs = $item->get_resources_from_source(); } //give a child element <item> to the <organization> element $my_item_id = $item->get_id(); $my_item = $xmldoc->createElement('item'); $my_item->setAttribute('identifier', 'ITEM_' . $my_item_id); $my_item->setAttribute('identifierref', 'RESOURCE_' . $my_item_id); $my_item->setAttribute('isvisible', 'true'); //give a child element <title> to the <item> element $my_title = $xmldoc->createElement('title', htmlspecialchars($item->get_title(), ENT_QUOTES, $this->encoding)); $my_item->appendChild($my_title); //give a child element <adlcp:prerequisites> to the <item> element $my_prereqs = $xmldoc->createElement('adlcp:prerequisites', $this->get_scorm_prereq_string($my_item_id)); $my_prereqs->setAttribute('type', 'aicc_script'); $my_item->appendChild($my_prereqs); //give a child element <adlcp:maxtimeallowed> to the <item> element - not yet supported //$xmldoc->createElement('adlcp:maxtimeallowed',''); //give a child element <adlcp:timelimitaction> to the <item> element - not yet supported //$xmldoc->createElement('adlcp:timelimitaction',''); //give a child element <adlcp:datafromlms> to the <item> element - not yet supported //$xmldoc->createElement('adlcp:datafromlms',''); //give a child element <adlcp:masteryscore> to the <item> element $my_masteryscore = $xmldoc->createElement('adlcp:masteryscore', $item->get_mastery_score()); $my_item->appendChild($my_masteryscore); //attach this item to the organization element or hits parent if there is one if (!empty($item->parent) && $item->parent != 0) { $children = $organization->childNodes; $possible_parent =& $this->get_scorm_xml_node($children, 'ITEM_' . $item->parent); if (is_object($possible_parent)) { $possible_parent->appendChild($my_item); } else { if ($this->debug > 0) { error_log('Parent ITEM_' . $item->parent . ' of item ITEM_' . $my_item_id . ' not found'); } } } else { if ($this->debug > 0) { error_log('No parent'); } $organization->appendChild($my_item); } //get the path of the file(s) from the course directory root $my_file_path = $item->get_file_path('scorm/' . $this->path . '/'); $my_xml_file_path = api_htmlentities($my_file_path, ENT_QUOTES, $this->encoding); $my_sub_dir = dirname($my_file_path); $my_xml_sub_dir = api_htmlentities($my_sub_dir, ENT_QUOTES, $this->encoding); //give a <resource> child to the <resources> element $my_resource = $xmldoc->createElement('resource'); $my_resource->setAttribute('identifier', 'RESOURCE_' . $item->get_id()); $my_resource->setAttribute('type', 'webcontent'); $my_resource->setAttribute('href', $my_xml_file_path); //adlcp:scormtype can be either 'sco' or 'asset' if ($item->type == 'sco') { $my_resource->setAttribute('adlcp:scormtype', 'sco'); } else { $my_resource->setAttribute('adlcp:scormtype', 'asset'); } //xml:base is the base directory to find the files declared in this resource $my_resource->setAttribute('xml:base', ''); //give a <file> child to the <resource> element $my_file = $xmldoc->createElement('file'); $my_file->setAttribute('href', $my_xml_file_path); $my_resource->appendChild($my_file); //dependency to other files - not yet supported $i = 1; foreach ($inc_docs as $doc_info) { if (count($doc_info) < 1 or empty($doc_info[0])) { continue; } $my_dep = $xmldoc->createElement('resource'); $res_id = 'RESOURCE_' . $item->get_id() . '_' . $i; $my_dep->setAttribute('identifier', $res_id); $my_dep->setAttribute('type', 'webcontent'); $my_dep->setAttribute('adlcp:scormtype', 'asset'); $my_dep_file = $xmldoc->createElement('file'); //check type of URL //error_log(__LINE__.'Now dealing with '.$doc_info[0].' of type '.$doc_info[1].'-'.$doc_info[2],0); if ($doc_info[1] == 'remote') { //remote file. Save url as is $my_dep_file->setAttribute('href', $doc_info[0]); $my_dep->setAttribute('xml:base', ''); } elseif ($doc_info[1] == 'local') { switch ($doc_info[2]) { case 'url': //local URL - save path as url for now, don't zip file $abs_path = api_get_path(SYS_PATH) . str_replace(api_get_path(WEB_PATH), '', $doc_info[0]); $current_dir = dirname($abs_path); $file_path = realpath($abs_path); $my_dep_file->setAttribute('href', $file_path); $my_dep->setAttribute('xml:base', ''); if (strstr($file_path, $main_path) !== false) { //the calculated real path is really inside the dokeos root path //reduce file path to what's under the DocumentRoot $file_path = substr($file_path, strlen($root_path) - 1); //echo $file_path;echo '<br><br>'; //error_log(__LINE__.'Reduced url path: '.$file_path,0); $zip_files_abs[] = $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path); $my_dep_file->setAttribute('href', $file_path); $my_dep->setAttribute('xml:base', ''); } else { if (empty($file_path)) { /* $document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH),api_get_path(REL_PATH))); if(strpos($document_root,-1)=='/') { $document_root = substr(0, -1, $document_root); } */ $file_path = $_SERVER['DOCUMENT_ROOT'] . $abs_path; $file_path = str_replace('//', '/', $file_path); if (file_exists($file_path)) { $file_path = substr($file_path, strlen($current_dir)); // we get the relative path $zip_files[] = $my_sub_dir . '/' . $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path); $my_dep_file->setAttribute('href', $file_path); $my_dep->setAttribute('xml:base', ''); } } } break; case 'abs': //absolute path from DocumentRoot. Save file and leave path as is in the zip $my_dep_file->setAttribute('href', $doc_info[0]); $my_dep->setAttribute('xml:base', ''); //$current_dir = dirname($current_course_path.'/'.$item->get_file_path()).'/'; //the next lines fix a bug when using the "subdir" mode of Dokeos, whereas //an image path would be constructed as /var/www/subdir/subdir/img/foo.bar $abs_img_path_without_subdir = $doc_info[0]; $relp = api_get_path(REL_PATH); //the url-append config param $pos = strpos($abs_img_path_without_subdir, $relp); if ($pos === 0) { $abs_img_path_without_subdir = '/' . substr($abs_img_path_without_subdir, strlen($relp)); } //$file_path = realpath(api_get_path(SYS_PATH).$doc_info[0]); $file_path = realpath(api_get_path(SYS_PATH) . $abs_img_path_without_subdir); $file_path = str_replace('\\', '/', $file_path); $file_path = str_replace('//', '/', $file_path); //error_log(__LINE__.'Abs path: '.$file_path,0); //prepare the current directory path (until just under 'document') with a trailing slash $cur_path = substr($current_course_path, -1) == '/' ? $current_course_path : $current_course_path . '/'; //check if the current document is in that path if (strstr($file_path, $cur_path) !== false) { //the document is in that path, now get the relative path //to the containing document $orig_file_path = dirname($cur_path . $my_file_path) . '/'; $relative_path = ''; if (strstr($file_path, $cur_path) !== false) { $relative_path = substr($file_path, strlen($orig_file_path)); $file_path = substr($file_path, strlen($cur_path)); } else { //this case is still a problem as it's difficult to calculate a relative path easily //might still generate wrong links //$file_path = substr($file_path,strlen($cur_path)); //calculate the directory path to the current file (without trailing slash) $my_relative_path = dirname($file_path); $my_relative_file = basename($file_path); //calculate the directory path to the containing file (without trailing slash) $my_orig_file_path = substr($orig_file_path, 0, -1); $dotdot = ''; $subdir = ''; while (strstr($my_relative_path, $my_orig_file_path) === false && strlen($my_orig_file_path) > 1 && strlen($my_relative_path) > 1) { $my_relative_path2 = dirname($my_relative_path); $my_orig_file_path = dirname($my_orig_file_path); $subdir = substr($my_relative_path, strlen($my_relative_path2) + 1) . "/" . $subdir; $dotdot += '../'; $my_relative_path = $my_relative_path2; } $relative_path = $dotdot . $subdir . $my_relative_file; } //put the current document in the zip (this array is the array //that will manage documents already in the course folder - relative) $zip_files[] = $file_path; //update the links to the current document in the containing document (make them relative) $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $relative_path); $my_dep_file->setAttribute('href', $file_path); $my_dep->setAttribute('xml:base', ''); } elseif (strstr($file_path, $main_path) !== false) { //the calculated real path is really inside the dokeos root path //reduce file path to what's under the DocumentRoot $file_path = substr($file_path, strlen($root_path)); //echo $file_path;echo '<br><br>'; //error_log('Reduced path: '.$file_path,0); $zip_files_abs[] = $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path); $my_dep_file->setAttribute('href', 'document/' . $file_path); $my_dep->setAttribute('xml:base', ''); } else { if (empty($file_path)) { /* $document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH),api_get_path(REL_PATH))); if(strpos($document_root,-1)=='/') { $document_root = substr(0, -1, $document_root); } */ $file_path = $_SERVER['DOCUMENT_ROOT'] . $doc_info[0]; $file_path = str_replace('//', '/', $file_path); if (file_exists($file_path)) { $file_path = substr($file_path, strlen($current_dir)); // we get the relative path $zip_files[] = $my_sub_dir . '/' . $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path); $my_dep_file->setAttribute('href', 'document/' . $file_path); $my_dep->setAttribute('xml:base', ''); } } } break; case 'rel': //path relative to the current document. Save xml:base as current document's directory and save file in zip as subdir.file_path if (substr($doc_info[0], 0, 2) == '..') { //relative path going up $current_dir = dirname($current_course_path . '/' . $item->get_file_path()) . '/'; $file_path = realpath($current_dir . $doc_info[0]); //error_log($file_path.' <-> '.$main_path,0); if (strstr($file_path, $main_path) !== false) { //the calculated real path is really inside the dokeos root path //reduce file path to what's under the DocumentRoot $file_path = substr($file_path, strlen($root_path)); //error_log('Reduced path: '.$file_path,0); $zip_files_abs[] = $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path); $my_dep_file->setAttribute('href', 'document/' . $file_path); $my_dep->setAttribute('xml:base', ''); } } else { $zip_files[] = $my_sub_dir . '/' . $doc_info[0]; $my_dep_file->setAttribute('href', $doc_info[0]); $my_dep->setAttribute('xml:base', $my_xml_sub_dir); } break; default: $my_dep_file->setAttribute('href', $doc_info[0]); $my_dep->setAttribute('xml:base', ''); break; } } $my_dep->appendChild($my_dep_file); $resources->appendChild($my_dep); $dependency = $xmldoc->createElement('dependency'); $dependency->setAttribute('identifierref', $res_id); $my_resource->appendChild($dependency); $i++; } //$my_dependency = $xmldoc->createElement('dependency'); //$my_dependency->setAttribute('identifierref',''); $resources->appendChild($my_resource); $zip_files[] = $my_file_path; //error_log('File '.$my_file_path. ' added to $zip_files',0); } else { // if the item is a quiz or a link or whatever non-exportable, we include a step indicating it if ($item->type == TOOL_LINK) { $my_item = $xmldoc->createElement('item'); $my_item->setAttribute('identifier', 'ITEM_' . $item->get_id()); $my_item->setAttribute('identifierref', 'RESOURCE_' . $item->get_id()); $my_item->setAttribute('isvisible', 'true'); //give a child element <title> to the <item> element $my_title = $xmldoc->createElement('title', htmlspecialchars($item->get_title(), ENT_QUOTES)); $my_item->appendChild($my_title); //give a child element <adlcp:prerequisites> to the <item> element $my_prereqs = $xmldoc->createElement('adlcp:prerequisites', $item->get_prereq_string()); $my_prereqs->setAttribute('type', 'aicc_script'); $my_item->appendChild($my_prereqs); //give a child element <adlcp:maxtimeallowed> to the <item> element - not yet supported //$xmldoc->createElement('adlcp:maxtimeallowed',''); //give a child element <adlcp:timelimitaction> to the <item> element - not yet supported //$xmldoc->createElement('adlcp:timelimitaction',''); //give a child element <adlcp:datafromlms> to the <item> element - not yet supported //$xmldoc->createElement('adlcp:datafromlms',''); //give a child element <adlcp:masteryscore> to the <item> element $my_masteryscore = $xmldoc->createElement('adlcp:masteryscore', $item->get_mastery_score()); $my_item->appendChild($my_masteryscore); //attach this item to the organization element or its parent if there is one if (!empty($item->parent) && $item->parent != 0) { $children = $organization->childNodes; for ($i = 0; $i < $children->length; $i++) { $item_temp = $children->item($i); if ($item_temp->nodeName == 'item') { if ($item_temp->getAttribute('identifier') == 'ITEM_' . $item->parent) { $item_temp->appendChild($my_item); } } } } else { $organization->appendChild($my_item); } $my_file_path = 'link_' . $item->get_id() . '.html'; $sql = 'SELECT url, title FROM ' . Database::get_course_table(TABLE_LINK) . ' WHERE id=' . $item->path; $rs = Database::query($sql, __FILE__, __LINE__); if ($link = Database::fetch_array($rs)) { $url = $link['url']; $title = stripslashes($link['title']); $links_to_create[$my_file_path] = array('title' => $title, 'url' => $url); $my_xml_file_path = api_htmlentities($my_file_path, ENT_QUOTES, $this->encoding); $my_sub_dir = dirname($my_file_path); $my_xml_sub_dir = api_htmlentities($my_sub_dir, ENT_QUOTES, $this->encoding); //give a <resource> child to the <resources> element $my_resource = $xmldoc->createElement('resource'); $my_resource->setAttribute('identifier', 'RESOURCE_' . $item->get_id()); $my_resource->setAttribute('type', 'webcontent'); $my_resource->setAttribute('href', $my_xml_file_path); //adlcp:scormtype can be either 'sco' or 'asset' $my_resource->setAttribute('adlcp:scormtype', 'asset'); //xml:base is the base directory to find the files declared in this resource $my_resource->setAttribute('xml:base', ''); //give a <file> child to the <resource> element $my_file = $xmldoc->createElement('file'); $my_file->setAttribute('href', $my_xml_file_path); $my_resource->appendChild($my_file); $resources->appendChild($my_resource); } } elseif ($item->type == TOOL_QUIZ) { require_once api_get_path(SYS_CODE_PATH) . 'exercice/exercise.class.php'; $exe_id = $item->path; //should be using ref when everything will be cleaned up in this regard $exe = new Exercise(); $exe->read($exe_id); $my_item = $xmldoc->createElement('item'); $my_item->setAttribute('identifier', 'ITEM_' . $item->get_id()); $my_item->setAttribute('identifierref', 'RESOURCE_' . $item->get_id()); $my_item->setAttribute('isvisible', 'true'); //give a child element <title> to the <item> element $my_title = $xmldoc->createElement('title', htmlspecialchars($item->get_title(), ENT_QUOTES, $this->encoding)); $my_item->appendChild($my_title); $my_max_score = $xmldoc->createElement('max_score', $item->get_max()); //$my_item->appendChild($my_max_score); //give a child element <adlcp:prerequisites> to the <item> element $my_prereqs = $xmldoc->createElement('adlcp:prerequisites', $item->get_prereq_string()); $my_prereqs->setAttribute('type', 'aicc_script'); $my_item->appendChild($my_prereqs); //give a child element <adlcp:masteryscore> to the <item> element $my_masteryscore = $xmldoc->createElement('adlcp:masteryscore', $item->get_mastery_score()); $my_item->appendChild($my_masteryscore); //attach this item to the organization element or hits parent if there is one if (!empty($item->parent) && $item->parent != 0) { $children = $organization->childNodes; for ($i = 0; $i < $children->length; $i++) { $item_temp = $children->item($i); if ($item_temp->nodeName == 'item') { if ($item_temp->getAttribute('identifier') == 'ITEM_' . $item->parent) { $item_temp->appendChild($my_item); } } } } else { $organization->appendChild($my_item); } //include export scripts require_once api_get_path(SYS_CODE_PATH) . 'exercice/export/scorm/scorm_export.php'; //get the path of the file(s) from the course directory root //$my_file_path = $item->get_file_path('scorm/'.$this->path.'/'); $my_file_path = 'quiz_' . $item->get_id() . '.html'; //write the contents of the exported exercise into a (big) html file //to later pack it into the exported SCORM. The file will be removed afterwards $contents = export_exercise($exe_id, true); $tmp_file_path = $archive_path . $temp_dir_short . '/' . $my_file_path; $res = file_put_contents($tmp_file_path, $contents); if ($res === false) { error_log('Could not write into file ' . $tmp_file_path . ' ' . __FILE__ . ' ' . __LINE__, 0); } $files_cleanup[] = $tmp_file_path; //error_log($tmp_path);die(); $my_xml_file_path = api_htmlentities($my_file_path, ENT_QUOTES, $this->encoding); $my_sub_dir = dirname($my_file_path); $my_xml_sub_dir = api_htmlentities($my_sub_dir, ENT_QUOTES, $this->encoding); //give a <resource> child to the <resources> element $my_resource = $xmldoc->createElement('resource'); $my_resource->setAttribute('identifier', 'RESOURCE_' . $item->get_id()); $my_resource->setAttribute('type', 'webcontent'); $my_resource->setAttribute('href', $my_xml_file_path); //adlcp:scormtype can be either 'sco' or 'asset' $my_resource->setAttribute('adlcp:scormtype', 'sco'); //xml:base is the base directory to find the files declared in this resource $my_resource->setAttribute('xml:base', ''); //give a <file> child to the <resource> element $my_file = $xmldoc->createElement('file'); $my_file->setAttribute('href', $my_xml_file_path); $my_resource->appendChild($my_file); //get included docs $inc_docs = $item->get_resources_from_source(null, $tmp_file_path); //dependency to other files - not yet supported $i = 1; foreach ($inc_docs as $doc_info) { if (count($doc_info) < 1 or empty($doc_info[0])) { continue; } $my_dep = $xmldoc->createElement('resource'); $res_id = 'RESOURCE_' . $item->get_id() . '_' . $i; $my_dep->setAttribute('identifier', $res_id); $my_dep->setAttribute('type', 'webcontent'); $my_dep->setAttribute('adlcp:scormtype', 'asset'); $my_dep_file = $xmldoc->createElement('file'); //check type of URL //error_log(__LINE__.'Now dealing with '.$doc_info[0].' of type '.$doc_info[1].'-'.$doc_info[2],0); if ($doc_info[1] == 'remote') { //remote file. Save url as is $my_dep_file->setAttribute('href', $doc_info[0]); $my_dep->setAttribute('xml:base', ''); } elseif ($doc_info[1] == 'local') { switch ($doc_info[2]) { case 'url': //local URL - save path as url for now, don't zip file //save file but as local file (retrieve from URL) $abs_path = api_get_path(SYS_PATH) . str_replace(api_get_path(WEB_PATH), '', $doc_info[0]); $current_dir = dirname($abs_path); $file_path = realpath($abs_path); $my_dep_file->setAttribute('href', 'document/' . $file_path); $my_dep->setAttribute('xml:base', ''); if (strstr($file_path, $main_path) !== false) { //the calculated real path is really inside the dokeos root path //reduce file path to what's under the DocumentRoot $file_path = substr($file_path, strlen($root_path)); //echo $file_path;echo '<br><br>'; //error_log('Reduced path: '.$file_path,0); $zip_files_abs[] = $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => 'document/' . $file_path); $my_dep_file->setAttribute('href', 'document/' . $file_path); $my_dep->setAttribute('xml:base', ''); } else { if (empty($file_path)) { /* $document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH),api_get_path(REL_PATH))); if(strpos($document_root,-1)=='/') { $document_root = substr(0, -1, $document_root); } */ $file_path = $_SERVER['DOCUMENT_ROOT'] . $abs_path; $file_path = str_replace('//', '/', $file_path); if (file_exists($file_path)) { $file_path = substr($file_path, strlen($current_dir)); // we get the relative path $zip_files[] = $my_sub_dir . '/' . $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => 'document/' . $file_path); $my_dep_file->setAttribute('href', 'document/' . $file_path); $my_dep->setAttribute('xml:base', ''); } } } break; case 'abs': //absolute path from DocumentRoot. Save file and leave path as is in the zip $current_dir = dirname($current_course_path . '/' . $item->get_file_path()) . '/'; $file_path = realpath($doc_info[0]); $my_dep_file->setAttribute('href', $file_path); $my_dep->setAttribute('xml:base', ''); if (strstr($file_path, $main_path) !== false) { //the calculated real path is really inside the dokeos root path //reduce file path to what's under the DocumentRoot $file_path = substr($file_path, strlen($root_path)); //echo $file_path;echo '<br><br>'; //error_log('Reduced path: '.$file_path,0); $zip_files_abs[] = $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path); $my_dep_file->setAttribute('href', 'document/' . $file_path); $my_dep->setAttribute('xml:base', ''); } else { if (empty($file_path)) { /* $document_root = substr(api_get_path(SYS_PATH), 0, strpos(api_get_path(SYS_PATH),api_get_path(REL_PATH))); if(strpos($document_root,-1)=='/') { $document_root = substr(0, -1, $document_root); } */ $file_path = $_SERVER['DOCUMENT_ROOT'] . $doc_info[0]; $file_path = str_replace('//', '/', $file_path); if (file_exists($file_path)) { $file_path = substr($file_path, strlen($current_dir)); // we get the relative path $zip_files[] = $my_sub_dir . '/' . $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path); $my_dep_file->setAttribute('href', 'document/' . $file_path); $my_dep->setAttribute('xml:base', ''); } } } break; case 'rel': //path relative to the current document. Save xml:base as current document's directory and save file in zip as subdir.file_path if (substr($doc_info[0], 0, 2) == '..') { //relative path going up $current_dir = dirname($current_course_path . '/' . $item->get_file_path()) . '/'; $file_path = realpath($current_dir . $doc_info[0]); //error_log($file_path.' <-> '.$main_path,0); if (strstr($file_path, $main_path) !== false) { //the calculated real path is really inside the dokeos root path //reduce file path to what's under the DocumentRoot $file_path = substr($file_path, strlen($root_path)); $file_path_dest = $file_path; //file path is courses/DOKEOS/document/.... $info_file_path = explode('/', $file_path); if ($info_file_path[0] == 'courses') { //add character "/" in file path $file_path_dest = '/' . $file_path; } //error_log('Reduced path: '.$file_path,0); $zip_files_abs[] = $file_path; $link_updates[$my_file_path][] = array('orig' => $doc_info[0], 'dest' => $file_path_dest); $my_dep_file->setAttribute('href', 'document/' . $file_path); $my_dep->setAttribute('xml:base', ''); } } else { $zip_files[] = $my_sub_dir . '/' . $doc_info[0]; $my_dep_file->setAttribute('href', $doc_info[0]); $my_dep->setAttribute('xml:base', $my_xml_sub_dir); } break; default: $my_dep_file->setAttribute('href', $doc_info[0]); // ../../courses/ $my_dep->setAttribute('xml:base', ''); break; } } $my_dep->appendChild($my_dep_file); $resources->appendChild($my_dep); $dependency = $xmldoc->createElement('dependency'); $dependency->setAttribute('identifierref', $res_id); $my_resource->appendChild($dependency); $i++; } $resources->appendChild($my_resource); $zip_files[] = $my_file_path; } else { //get the path of the file(s) from the course directory root $my_file_path = 'non_exportable.html'; $my_xml_file_path = api_htmlentities($my_file_path, ENT_COMPAT, $this->encoding); $my_sub_dir = dirname($my_file_path); $my_xml_sub_dir = api_htmlentities($my_sub_dir, ENT_COMPAT, $this->encoding); //give a <resource> child to the <resources> element $my_resource = $xmldoc->createElement('resource'); $my_resource->setAttribute('identifier', 'RESOURCE_' . $item->get_id()); $my_resource->setAttribute('type', 'webcontent'); $my_resource->setAttribute('href', 'document/' . $my_xml_file_path); //adlcp:scormtype can be either 'sco' or 'asset' $my_resource->setAttribute('adlcp:scormtype', 'asset'); //xml:base is the base directory to find the files declared in this resource $my_resource->setAttribute('xml:base', ''); //give a <file> child to the <resource> element $my_file = $xmldoc->createElement('file'); $my_file->setAttribute('href', 'document/' . $my_xml_file_path); $my_resource->appendChild($my_file); $resources->appendChild($my_resource); } } } $organizations->appendChild($organization); $root->appendChild($organizations); $root->appendChild($resources); $xmldoc->appendChild($root); //todo: add a readme file here, with a short description and a link to the Reload player //then add the file to the zip, then destroy the file (this is done automatically) // http://www.reload.ac.uk/scormplayer.html - once done, don't forget to close FS#138 //error_log(print_r($zip_files,true),0); foreach ($zip_files as $file_path) { if (empty($file_path)) { continue; } //error_log(__LINE__.'getting document from '.$sys_course_path.$_course['path'].'/'.$file_path.' removing '.$sys_course_path.$_course['path'].'/',0); $dest_file = $archive_path . $temp_dir_short . '/' . $file_path; $this->create_path($dest_file); //error_log('copy '.api_get_path('SYS_COURSE_PATH').$_course['path'].'/'.$file_path.' to '.api_get_path('SYS_ARCHIVE_PATH').$temp_dir_short.'/'.$file_path,0); //echo $main_path.$file_path.'<br>'; @copy($sys_course_path . $_course['path'] . '/' . $file_path, $dest_file); //check if the file needs a link update if (in_array($file_path, array_keys($link_updates))) { $string = file_get_contents($dest_file); unlink($dest_file); foreach ($link_updates[$file_path] as $old_new) { //error_log('Replacing '.$old_new['orig'].' by '.$old_new['dest'].' in '.$file_path,0); //this is an ugly hack that allows .flv files to be found by the flv player that // will be added in document/main/inc/lib/flv_player/flv_player.swf and that needs // to find the flv to play in document/main/, so we replace main/ in the flv path by // ../../.. to return from inc/lib/flv_player to the document/main path if (substr($old_new['dest'], -3) == 'flv' && substr($old_new['dest'], 0, 5) == 'main/') { $old_new['dest'] = str_replace('main/', '../../../', $old_new['dest']); } elseif (substr($old_new['dest'], -3) == 'flv' && substr($old_new['dest'], 0, 6) == 'video/') { $old_new['dest'] = str_replace('video/', '../../../../video/', $old_new['dest']); } if (substr($old_new['dest'], 0, 1) == '/') { $old_new['dest'] = substr($old_new['dest'], 1); } $string = str_replace($old_new['orig'], $old_new['dest'], $string); $string = str_replace(str_replace('https', 'http', $old_new['orig']), $old_new['dest'], $string); } file_put_contents($dest_file, $string); } } foreach ($zip_files_abs as $file_path) { if (empty($file_path)) { continue; } //error_log(__LINE__.'checking existence of '.$main_path.$file_path.'',0); if (!is_file($main_path . $file_path) || !is_readable($main_path . $file_path)) { continue; } //error_log(__LINE__.'getting document from '.$main_path.$file_path.' removing '.api_get_path('SYS_COURSE_PATH').$_course['path'].'/',0); $dest_file = $archive_path . $temp_dir_short . '/document/' . $file_path; $this->create_path($dest_file); //error_log('Created path '.api_get_path(SYS_ARCHIVE_PATH).$temp_dir_short.'/document/'.$file_path,0); //error_log('copy '.api_get_path(SYS_COURSE_PATH).$_course['path'].'/'.$file_path.' to '.api_get_path(SYS_ARCHIVE_PATH).$temp_dir_short.'/'.$file_path,0); //echo $main_path.$file_path.' - '.$dest_file.'<br>'; copy($main_path . $file_path, $dest_file); //check if the file needs a link update if (in_array($file_path, array_keys($link_updates))) { $string = file_get_contents($dest_file); unlink($dest_file); foreach ($link_updates[$file_path] as $old_new) { //error_log('Replacing '.$old_new['orig'].' by '.$old_new['dest'].' in '.$file_path,0); //this is an ugly hack that allows .flv files to be found by the flv player that // will be added in document/main/inc/lib/flv_player/flv_player.swf and that needs // to find the flv to play in document/main/, so we replace main/ in the flv path by // ../../.. to return from inc/lib/flv_player to the document/main path if (substr($old_new['dest'], -3) == 'flv' && substr($old_new['dest'], 0, 5) == 'main/') { $old_new['dest'] = str_replace('main/', '../../../', $old_new['dest']); } if (substr($old_new['dest'], 0, 1) == '/') { $old_new['dest'] = substr($old_new['dest'], 1); } $string = str_replace($old_new['orig'], $old_new['dest'], $string); $string = str_replace(str_replace('https', 'http', $old_new['orig']), $old_new['dest'], $string); } file_put_contents($dest_file, $string); } } if (is_array($links_to_create)) { foreach ($links_to_create as $file => $link) { $file_content = '<html><body><div style="text-align:center"><a href="' . $link['url'] . '">' . $link['title'] . '</a></div></body></html>'; file_put_contents($archive_path . $temp_dir_short . '/' . $file, $file_content); } } // add non exportable message explanation $lang_not_exportable = get_lang('ThisItemIsNotExportable'); $file_content = <<<EOD <html> \t<head> \t\t<style> \t\t\t.error-message { \t\t\t\tfont-family: arial, verdana, helvetica, sans-serif; \t\t\t\tborder-width: 1px; \t\t\t\tborder-style: solid; \t\t\t\tleft: 50%; \t\t\t\tmargin: 10px auto; \t\t\t\tmin-height: 30px; \t\t\t\tpadding: 5px; \t\t\t\tright: 50%; \t\t\t\twidth: 500px; \t\t\t\tbackground-color: #FFD1D1; \t\t\t\tborder-color: #FF0000; \t\t\t\tcolor: #000; \t\t\t} \t\t</style> \t<body> \t\t<div class="error-message"> \t\t\t{$lang_not_exportable} \t\t</div> \t</body> </html> EOD; if (!is_dir($archive_path . $temp_dir_short . '/document')) { @mkdir($archive_path . $temp_dir_short . '/document'); } file_put_contents($archive_path . $temp_dir_short . '/document/non_exportable.html', $file_content); //Add the extra files that go along with a SCORM package $main_code_path = api_get_path(SYS_CODE_PATH) . 'newscorm/packaging/'; $extra_files = scandir($main_code_path); foreach ($extra_files as $extra_file) { if (strpos($extra_file, '.') === 0) { continue; } else { $dest_file = $archive_path . $temp_dir_short . '/' . $extra_file; $this->create_path($dest_file); copy($main_code_path . $extra_file, $dest_file); } } //Finalize the imsmanifest structure, add to the zip, then return the zip $xmldoc->save($archive_path . '/' . $temp_dir_short . '/imsmanifest.xml'); $zip_folder->add($archive_path . '/' . $temp_dir_short, PCLZIP_OPT_REMOVE_PATH, $archive_path . '/' . $temp_dir_short . '/'); //clean possible temporary files foreach ($files_cleanup as $file) { $res = unlink($file); if ($res === false) { error_log('Could not delete temp file ' . $file . ' ' . __FILE__ . ' ' . __LINE__, 0); } } //Send file to client //$name = 'scorm_export_'.$this->lp_id.'.zip'; require_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php'; $name = preg_replace('([^a-zA-Z0-9_\\.])', '-', html_entity_decode($this->get_name(), ENT_QUOTES)) . '.zip'; DocumentManager::file_send_for_download($temp_zip_file, true, $name); }
/** * Set system parameters */ private function set_system_parameters() { global $_configuration; //Setting app paths/URLs $_p = array( 'web' => api_get_path(WEB_PATH), 'web_course' => api_get_path(WEB_COURSE_PATH), 'web_main' => api_get_path(WEB_CODE_PATH), 'web_css' => api_get_path(WEB_CSS_PATH), 'web_ajax' => api_get_path(WEB_AJAX_PATH), 'web_img' => api_get_path(WEB_IMG_PATH), 'web_plugin' => api_get_path(WEB_PLUGIN_PATH), 'web_lib' => api_get_path(WEB_LIBRARY_PATH), 'web_self' => api_get_self(), 'web_query_vars' => api_htmlentities($_SERVER['QUERY_STRING']), 'web_self_query_vars' => api_htmlentities($_SERVER['REQUEST_URI']), 'web_cid_query' => api_get_cidreq(), ); $this->assign('_p', $_p); //Here we can add system parameters that can be use in any template $_s = array( 'software_name' => $_configuration['software_name'], 'system_version' => $_configuration['system_version'], 'site_name' => api_get_setting('siteName'), 'institution' => api_get_setting('Institution') ); $this->assign('_s', $_s); }
} // The header. Display::display_header($tool_name); //jqgrid will use this URL to do the selects $url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_careers'; //The order is important you need to check the the $column variable in the model.ajax.php file $columns = array(get_lang('Name'), get_lang('Description'), get_lang('Actions')); // Column config $column_model = array(array('name' => 'name', 'index' => 'name', 'width' => '80', 'align' => 'left'), array('name' => 'description', 'index' => 'description', 'width' => '500', 'align' => 'left', 'sortable' => 'false'), array('name' => 'actions', 'index' => 'actions', 'width' => '100', 'align' => 'left', 'formatter' => 'action_formatter', 'sortable' => 'false')); //Autowidth $extra_params['autowidth'] = 'true'; //height auto $extra_params['height'] = 'auto'; //With this function we can add actions to the jgrid (edit, delete, etc) $action_links = 'function action_formatter(cellvalue, options, rowObject) { return \'<a href="?action=edit&id=\'+options.rowId+\'">' . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . '</a>' . ' <a onclick="javascript:if(!confirm(' . "\\'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES)) . "\\'" . ')) return false;" href="?sec_token=' . $token . '&action=copy&id=\'+options.rowId+\'">' . Display::return_icon('copy.png', get_lang('Copy'), '', ICON_SIZE_SMALL) . '</a>' . ' <a onclick="javascript:if(!confirm(' . "\\'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES)) . "\\'" . ')) return false;" href="?sec_token=' . $token . '&action=delete&id=\'+options.rowId+\'">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>' . '\'; }'; ?> <script> $(function() { <?php // grid definition see the $career->display() function echo Display::grid_js('careers', $url, $columns, $column_model, $extra_params, array(), $action_links, true); ?> }); </script> <?php $career = new Career(); // Action handling: Add switch ($action) { case 'add':
/** * This function retrieves all the personal agenda items of the user and shows * these items in one list (ordered by date and grouped by month (the month_bar) */ function show_personal_agenda() { global $MonthsLong, $charset; $tbl_personal_agenda = Database::get_main_table(TABLE_PERSONAL_AGENDA); // The SQL statement that retrieves all the personal agenda items of this user $sql = "SELECT * FROM " . $tbl_personal_agenda . " WHERE user='******' ORDER BY date DESC"; $result = Database::query($sql); // variable initialisation $month_bar = ""; // setting the default day, month and year if (!isset($_GET['day']) and !isset($_GET['month']) and !isset($_GET['year'])) { $today = getdate(); $year = $today['year']; $month = $today['mon']; $day = $today['mday']; } $export_icon = 'export.png'; $export_icon_low = 'export_low_fade.png'; $export_icon_high = 'export_high_fade.png'; // starting the table output echo '<table class="data_table">'; $th = Display::tag('th', get_lang('Title')); $th .= Display::tag('th', get_lang('Content')); $th .= Display::tag('th', get_lang('StartTimeWindow')); $th .= Display::tag('th', get_lang('Modify')); echo Display::tag('tr', $th); if (Database::num_rows($result) > 0) { $counter = 0; while ($myrow = Database::fetch_array($result)) { /* display: the month bar */ if ($month_bar != date("m", strtotime($myrow["date"])) . date("Y", strtotime($myrow["date"]))) { $month_bar = date("m", strtotime($myrow["date"])) . date("Y", strtotime($myrow["date"])); //echo "<tr><th class=\"title\" colspan=\"2\" class=\"month\" valign=\"top\">".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."</th></tr>"; } // highlight: if a date in the small calendar is clicked we highlight the relevant items $db_date = (int) date("d", strtotime($myrow["date"])) . date("n", strtotime($myrow["date"])) . date("Y", strtotime($myrow["date"])); /* if ($_GET["day"].$_GET["month"].$_GET["year"] <> $db_date) { $style = "data"; $text_style = "text"; } else { $style = "datanow"; $text_style = "text"; }*/ $class = 'row_even'; if ($counter % 2) { $class = 'row_odd'; } echo '<tr class="' . $class . '">'; echo '<td>'; /* display: the title */ echo $myrow['title']; echo "</td>"; // display: the content $content = $myrow['text']; echo "<td>"; echo $content; echo "</td>"; //display: date and time echo '<td>'; // adding an internal anchor /*echo "<a name=\"".$myrow["id"]."\"></a>"; echo date("d", strtotime($myrow["date"]))." ".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))." ";*/ $myrow["date"] = api_get_local_time($myrow["date"]); echo api_format_date($myrow["date"], DATE_TIME_FORMAT_LONG); echo "</td>"; //echo '<td></td>'; //remove when enabling ical //echo '<td class="'.$style.'">'; //echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a>'; //echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=private" title="'.get_lang('ExportiCalPrivate').'">'.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).'</a>'; //echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=public" title="'.get_lang('ExportiCalPublic').'">'.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).'</a>'; //echo "</td>"; //echo "</tr>"; /* display: the edit / delete icons */ echo "<td>"; echo "<a href=\"myagenda.php?action=edit_personal_agenda_item&id=" . $myrow['id'] . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . "</a> "; echo "<a href=\"" . api_get_self() . "?action=delete&id=" . $myrow['id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . "</a>"; echo "</td></tr>"; $counter++; } } else { echo '<tr><td colspan="2">' . get_lang('NoAgendaItems') . '</td></tr>'; } echo "</table>"; }
echo '<td class="td_actions">'; // Get attachment id. if (isset($row['post_id'])) { $attachment_list = get_attachment($row['post_id']); } $id_attach = !empty($attachment_list) ? $attachment_list['id'] : ''; $sql_post_id = "SELECT post_id FROM {$table_posts} WHERE c_id = {$course_id} AND post_title='" . Database::escape_string($row['thread_title']) . "'"; $result_post_id = Database::query($sql_post_id); $row_post_id = Database::fetch_array($result_post_id); if ($origin != 'learnpath') { if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) { echo '<a href="' . $forumUrl . 'editpost.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&thread=' . Security::remove_XSS($row['thread_id']) . '&post=' . $row_post_id['post_id'] . '&id_attach=' . $id_attach . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; if (api_resource_is_locked_by_gradebook($row['thread_id'], LINK_FORUM_THREAD)) { echo Display::return_icon('delete_na.png', get_lang('ResourceLockedByGradebook'), array(), ICON_SIZE_SMALL); } else { echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&action=delete&content=thread&id=' . $row['thread_id'] . $origin_string . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteCompleteThread'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } display_visible_invisible_icon('thread', $row['thread_id'], $row['visibility'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => $groupId)); display_lock_unlock_icon('thread', $row['thread_id'], $row['locked'], array('forum' => $my_forum, 'origin' => $origin, 'gidReq' => api_get_group_id())); echo '<a href="viewforum.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&action=move&thread=' . $row['thread_id'] . $origin_string . '">' . Display::return_icon('move.png', get_lang('MoveThread'), array(), ICON_SIZE_SMALL) . '</a>'; } } $iconnotify = 'send_mail.gif'; if (is_array(isset($_SESSION['forum_notification']['thread']) ? $_SESSION['forum_notification']['thread'] : null)) { if (in_array($row['thread_id'], $_SESSION['forum_notification']['thread'])) { $iconnotify = 'send_mail_checked.gif'; } } $icon_liststd = 'user.png'; if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) { echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&origin=' . $origin . '&action=notify&content=thread&id=' . $row['thread_id'] . '">' . Display::return_icon($iconnotify, get_lang('NotifyMe')) . '</a>';
<?php // Show the CAS button to login using CAS require_once api_get_path(SYS_PATH) . 'main/auth/cas/authcas.php'; $_template['show_message'] = false; if (api_is_anonymous()) { $_template['cas_activated'] = api_is_cas_activated(); $_template['cas_configured'] = cas_configured(); $_template['show_message'] = true; // the default title $button_label = "Connexion via CAS"; if (!empty($plugin_info['settings']['add_cas_login_button_cas_button_label'])) { $button_label = api_htmlentities($plugin_info['settings']['add_cas_login_button_cas_button_label']); } // the comm $comm_label = api_htmlentities($plugin_info['settings']['add_cas_login_button_cas_button_comment']); // URL of the image $url_label = $plugin_info['settings']['add_cas_login_button_cas_image_url']; $_template['button_label'] = $button_label; $_template['comm_label'] = $comm_label; $_template['url_label'] = $url_label; }
/** * Build the modify-column of the table * @param int $user_id The user id * @param string $url_params * @return string Some HTML-code with modify-buttons * @author Mustapha Alouani */ function modify_filter($user_id, $url_params, $row) { $url_params_id = "id[]=" . $row[0]; //$url_params_id="id=".$row[0]; $result .= '<a href="ldap_users_list.php?action=add_user&user_id=' . $user_id . '&id_session=' . Security::remove_XSS($_GET['id_session']) . '&' . $url_params_id . '&sec_token=' . $_SESSION['sec_token'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, api_get_system_encoding())) . "'" . ')) return false;">' . Display::return_icon('add_user.gif', get_lang('AddUsers')) . '</a>'; return $result; }