$column_order[3] = 8; $column_order[5] = 7; // The content of the sortable table = the received files foreach ($dropbox_person->sentWork as $dropbox_file) { $dropbox_file_data = array(); if ($view_dropbox_category_sent == $dropbox_file->category) { $dropbox_file_data[] = $dropbox_file->id; $link_open = '<a href="' . api_get_path(WEB_CODE_PATH) . 'dropbox/dropbox_download.php?' . api_get_cidreq() . '&id=' . $dropbox_file->id . '">'; $dropbox_file_data[] = $link_open . DocumentManager::build_document_icon_tag('file', $dropbox_file->title) . '</a>'; $dropbox_file_data[] = '<a href="' . api_get_path(WEB_CODE_PATH) . 'dropbox/dropbox_download.php?' . api_get_cidreq() . '&id=' . $dropbox_file->id . '&action=download">' . Display::return_icon('save.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_SMALL) . '</a>' . $link_open . $dropbox_file->title . '</a><br />' . $dropbox_file->description; $file_size = $dropbox_file->filesize; $dropbox_file_data[] = format_file_size($file_size); $receivers_celldata = null; foreach ($dropbox_file->recipients as $recipient) { $userInfo = api_get_user_info($recipient['user_id']); $receivers_celldata = UserManager::getUserProfileLink($userInfo) . ', ' . $receivers_celldata; } $receivers_celldata = trim(trim($receivers_celldata), ','); // Removing the trailing comma. $dropbox_file_data[] = $receivers_celldata; $last_upload_date = api_get_local_time($dropbox_file->last_upload_date); $dropbox_file_data[] = date_to_str_ago($last_upload_date) . '<br /><span class="dropbox_date">' . api_format_date($last_upload_date) . '</span>'; //$dropbox_file_data[] = $dropbox_file->author; $receivers_celldata = ''; $action_icons = check_number_feedback($dropbox_file->id, $number_feedback) . ' ' . get_lang('Feedback') . ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&action=viewfeedback&id=' . $dropbox_file->id . '&' . $sort_params . '">' . Display::return_icon('discuss.png', get_lang('Comment'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&action=movesent&move_id=' . $dropbox_file->id . '&' . $sort_params . '">' . Display::return_icon('move.png', get_lang('Move'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?' . api_get_cidreq() . '&view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&action=deletesentfile&id=' . $dropbox_file->id . '&' . $sort_params . '" onclick="javascript: return confirmation(\'' . $dropbox_file->title . '\');">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a>'; // This is a hack to have an additional row in a sortable table if ($action == 'viewfeedback' && isset($_GET['id']) && is_numeric($_GET['id']) && $dropbox_file->id == $_GET['id']) { $action_icons .= "</td></tr>\n";
$document_name = basename($document_data['path']); } $row['name'] = $document_name; // Data for checkbox if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($documentAndFolders) > 1) { $row[] = $document_data['id']; } if (DocumentManager::is_folder_to_avoid($document_data['path'], $is_certificate_mode)) { continue; } // Show the owner of the file only in groups $user_link = ''; if (!empty($groupId)) { if (!empty($document_data['insert_user_id'])) { $user_info = api_get_user_info($document_data['insert_user_id']); $user_link = '<div class="document_owner">' . get_lang('Owner') . ': ' . UserManager::getUserProfileLink($user_info) . '</div>'; } } // Icons (clickable) $row[] = DocumentManager::create_document_link($document_data, true, $count, $is_visible); $path_info = pathinfo($document_data['path']); if (isset($path_info['extension']) && in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))) { $count++; } // Validation when belongs to a session $session_img = api_get_session_image($document_data['session_id'], $_user['status']); // Document title with link $row[] = DocumentManager::create_document_link($document_data, false, null, $is_visible) . $session_img . '<br />' . $invisibility_span_open . '<i>' . nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)) . '</i>' . $invisibility_span_close . $user_link; // Comments => display comment under the document name $display_size = format_file_size($size); $row[] = '<span style="display:none;">' . $size . '</span>' . $invisibility_span_open . $display_size . $invisibility_span_close;
/** * Return user profile link around the given user name. * * The parameters use a trick of the sorteable table, where the first param is * the original value of the column * @param string User name (value of the column at the time of calling) * @param string URL parameters * @param array Row of the "sortable table" as it is at the time of function call - we extract the user ID from there * @return string HTML link */ function user_name_filter($name, $url_params, $row) { $userInfo = api_get_user_info($row[0]); return UserManager::getUserProfileLink($userInfo); }
/** * Saves imported data. */ public function save_data($users, $course_list, $id_session) { $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $id_session = intval($id_session); $sendMail = $_POST['sendMail'] ? 1 : 0; // Adding users to the platform. $new_users = array(); foreach ($users as $index => $user) { $user = MySpace::complete_missing_data($user); // coach only will registered users $default_status = STUDENT; if ($user['create'] == COURSEMANAGER) { $user['id'] = UserManager::create_user($user['FirstName'], $user['LastName'], $default_status, $user['Email'], $user['UserName'], $user['Password'], $user['OfficialCode'], api_get_setting('language.platform_language'), $user['PhoneNumber'], ''); $user['added_at_platform'] = 1; } else { $user['id'] = $user['create']; $user['added_at_platform'] = 0; } $new_users[] = $user; } // Update user list. $users = $new_users; // Inserting users. $super_list = array(); foreach ($course_list as $enreg_course) { $nbr_users = 0; $new_users = array(); $enreg_course = Database::escape_string($enreg_course); foreach ($users as $index => $user) { $userid = intval($user['id']); $sql = "INSERT IGNORE INTO {$tbl_session_rel_course_rel_user}(session_id, c_id, user_id)\n VALUES('{$id_session}','{$enreg_course}','{$userid}')"; $course_session = array('course' => $enreg_course, 'added' => 1); $result = Database::query($sql); if (Database::affected_rows($result)) { $nbr_users++; } $new_users[] = $user; } $super_list[] = $new_users; //update the nbr_users field $sql_select = "SELECT COUNT(user_id) as nbUsers FROM {$tbl_session_rel_course_rel_user}\n WHERE session_id='{$id_session}' AND c_id='{$enreg_course}'"; $rs = Database::query($sql_select); list($nbr_users) = Database::fetch_array($rs); $sql_update = "UPDATE {$tbl_session_rel_course} SET nbr_users={$nbr_users}\n WHERE session_id='{$id_session}' AND c_id='{$enreg_course}'"; Database::query($sql_update); $sql_update = "UPDATE {$tbl_session} SET nbr_users= '{$nbr_users}' WHERE id='{$id_session}'"; Database::query($sql_update); } $new_users = array(); foreach ($users as $index => $user) { $userid = $user['id']; $sql_insert = "INSERT IGNORE INTO {$tbl_session_rel_user}(session_id, user_id, registered_at)\n VALUES ('{$id_session}','{$userid}', '" . api_get_utc_datetime() . "')"; Database::query($sql_insert); $user['added_at_session'] = 1; $new_users[] = $user; } $users = $new_users; $registered_users = get_lang('FileImported') . '<br /> Import file results : <br />'; // Sending emails. $addedto = ''; if ($sendMail) { $i = 0; foreach ($users as $index => $user) { $emailsubject = '[' . api_get_setting('platform.site_name') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('platform.site_name'); $emailbody = get_lang('Dear') . ' ' . api_get_person_name($user['FirstName'], $user['LastName']) . ",\n\n" . get_lang('YouAreReg') . " " . api_get_setting('platform.site_name') . " " . get_lang('WithTheFollowingSettings') . "\n\n" . get_lang('Username') . " : {$user['UserName']}\n" . get_lang('Pass') . " : {$user['Password']}\n\n" . get_lang('Address') . " " . api_get_setting('platform.site_name') . " " . get_lang('Is') . " : " . api_get_path(WEB_PATH) . " \n\n" . get_lang('Problem') . "\n\n" . get_lang('SignatureFormula') . ",\n\n" . api_get_person_name(api_get_setting('admin.administrator_name'), api_get_setting('admin.administrator_surname')) . "\n" . get_lang('Manager') . " " . api_get_setting('platform.site_name') . "\nT. " . api_get_setting('admin.administrator_phone') . "\n" . get_lang('Email') . " : " . api_get_setting('admin.administrator_email'); api_mail_html(api_get_person_name($user['FirstName'], $user['LastName'], null, PERSON_NAME_EMAIL_ADDRESS), $user['Email'], $emailsubject, $emailbody); $userInfo = api_get_user_info($user['id']); if ($user['added_at_platform'] == 1 && $user['added_at_session'] == 1 || $user['added_at_session'] == 1) { if ($user['added_at_platform'] == 1) { $addedto = get_lang('UserCreatedPlatform'); } else { $addedto = ' '; } if ($user['added_at_session'] == 1) { $addedto .= get_lang('UserInSession'); } } else { $addedto = get_lang('UserNotAdded'); } $registered_users .= UserManager::getUserProfileLink($userInfo) . " - " . $addedto . '<br />'; } } else { $i = 0; foreach ($users as $index => $user) { $userInfo = api_get_user_info($user['id']); if ($user['added_at_platform'] == 1 && $user['added_at_session'] == 1 || $user['added_at_session'] == 1) { if ($user['added_at_platform'] == 1) { $addedto = get_lang('UserCreatedPlatform'); } else { $addedto = ' '; } if ($user['added_at_session'] == 1) { $addedto .= ' ' . get_lang('UserInSession'); } } else { $addedto = get_lang('UserNotAdded'); } $registered_users .= "<a href=\"../user/userInfo.php?uInfo=" . $user['id'] . "\">" . api_get_person_name($user['FirstName'], $user['LastName']) . "</a> - " . $addedto . '<br />'; } } header('Location: course.php?id_session=' . $id_session . '&action=show_message&message=' . urlencode($registered_users)); exit; }
/** * Get history */ public function getHistory() { $tbl_wiki = $this->tbl_wiki; $condition_session = $this->condition_session; $groupfilter = $this->groupfilter; $page = $this->page; $course_id = $this->course_id; $session_id = $this->session_id; $userId = api_get_user_id(); if (!$_GET['title']) { self::setMessage(Display::display_error_message(get_lang("MustSelectPage"), false, true)); return; } /* First, see the property visibility that is at the last register and therefore we should select descending order. But to give ownership to each record, this is no longer necessary except for the title. TODO: check this*/ $sql = 'SELECT * FROM ' . $tbl_wiki . ' WHERE c_id = ' . $course_id . ' AND reflink="' . Database::escape_string($page) . '" AND ' . $groupfilter . $condition_session . ' ORDER BY id DESC'; $result = Database::query($sql); $KeyVisibility = null; $KeyAssignment = null; $KeyTitle = null; $KeyUserId = null; while ($row = Database::fetch_array($result)) { $KeyVisibility = $row['visibility']; $KeyAssignment = $row['assignment']; $KeyTitle = $row['title']; $KeyUserId = $row['user_id']; } $icon_assignment = null; if ($KeyAssignment == 1) { $icon_assignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDescExtra'), '', ICON_SIZE_SMALL); } elseif ($KeyAssignment == 2) { $icon_assignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWorkExtra'), '', ICON_SIZE_SMALL); } // Second, show //if the page is hidden and is a job only sees its author and professor if ($KeyVisibility == 1 || api_is_allowed_to_edit(false, true) || api_is_platform_admin() || $KeyAssignment == 2 && $KeyVisibility == 0 && $userId == $KeyUserId) { // We show the complete history if (!isset($_POST['HistoryDifferences']) && !isset($_POST['HistoryDifferences2'])) { $sql = 'SELECT * FROM ' . $tbl_wiki . ' WHERE c_id = ' . $course_id . ' AND reflink="' . Database::escape_string($page) . '" AND ' . $groupfilter . $condition_session . ' ORDER BY id DESC'; $result = Database::query($sql); $title = $_GET['title']; $group_id = api_get_group_id(); echo '<div id="wikititle">'; echo $icon_assignment . ' ' . api_htmlentities($KeyTitle); echo '</div>'; echo '<form id="differences" method="POST" action="index.php?' . api_get_cidreq() . '&action=history&title=' . api_htmlentities(urlencode($title)) . '&session_id=' . api_htmlentities($session_id) . '&group_id=' . api_htmlentities($group_id) . '">'; echo '<ul style="list-style-type: none;">'; echo '<br/>'; echo '<button class="search" type="submit" name="HistoryDifferences" value="HistoryDifferences">' . get_lang('ShowDifferences') . ' ' . get_lang('LinesDiff') . '</button>'; echo '<button class="search" type="submit" name="HistoryDifferences2" value="HistoryDifferences2">' . get_lang('ShowDifferences') . ' ' . get_lang('WordsDiff') . '</button>'; echo '<br/><br/>'; $counter = 0; $total_versions = Database::num_rows($result); while ($row = Database::fetch_array($result)) { $userinfo = api_get_user_info($row['user_id']); $username = api_htmlentities(sprintf(get_lang('LoginX'), $userinfo['username']), ENT_QUOTES); echo '<li style="margin-bottom: 5px;">'; $counter == 0 ? $oldstyle = 'style="visibility: hidden;"' : ($oldstyle = ''); $counter == 0 ? $newchecked = ' checked' : ($newchecked = ''); $counter == $total_versions - 1 ? $newstyle = 'style="visibility: hidden;"' : ($newstyle = ''); $counter == 1 ? $oldchecked = ' checked' : ($oldchecked = ''); echo '<input name="old" value="' . $row['id'] . '" type="radio" ' . $oldstyle . ' ' . $oldchecked . '/> '; echo '<input name="new" value="' . $row['id'] . '" type="radio" ' . $newstyle . ' ' . $newchecked . '/> '; echo '<a href="' . api_get_self() . '?action=showpage&title=' . api_htmlentities(urlencode($page)) . '&view=' . $row['id'] . '">'; echo '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=showpage&title=' . api_htmlentities(urlencode($page)) . '&view=' . $row['id'] . '">'; echo api_get_local_time($row['dtime'], null, date_default_timezone_get()); echo '</a>'; echo ' (' . get_lang('Version') . ' ' . $row['version'] . ')'; echo ' ' . get_lang('By') . ' '; if ($row['user_id'] != 0) { echo UserManager::getUserProfileLink($userinfo); } else { echo get_lang('Anonymous') . ' (' . api_htmlentities($row['user_ip']) . ')'; } echo ' ( ' . get_lang('Progress') . ': ' . api_htmlentities($row['progress']) . '%, '; $comment = $row['comment']; if (!empty($comment)) { echo get_lang('Comments') . ': ' . api_htmlentities(api_substr($row['comment'], 0, 100)); if (api_strlen($row['comment']) > 100) { echo '... '; } } else { echo get_lang('Comments') . ': ---'; } echo ' ) </li>'; $counter++; } //end while echo '<br/>'; echo '<button class="search" type="submit" name="HistoryDifferences" value="HistoryDifferences">' . get_lang('ShowDifferences') . ' ' . get_lang('LinesDiff') . '</button>'; echo '<button class="search" type="submit" name="HistoryDifferences2" value="HistoryDifferences2">' . get_lang('ShowDifferences') . ' ' . get_lang('WordsDiff') . '</button>'; echo '</ul></form>'; } else { // We show the differences between two versions $version_old = array(); if (isset($_POST['old'])) { $sql_old = "SELECT * FROM {$tbl_wiki}\n WHERE c_id = {$course_id} AND id='" . Database::escape_string($_POST['old']) . "'"; $result_old = Database::query($sql_old); $version_old = Database::fetch_array($result_old); } $sql_new = "SELECT * FROM {$tbl_wiki}\n WHERE c_id = {$course_id} AND id='" . Database::escape_string($_POST['new']) . "'"; $result_new = Database::query($sql_new); $version_new = Database::fetch_array($result_new); $oldTime = isset($version_old['dtime']) ? $version_old['dtime'] : null; $oldContent = isset($version_old['content']) ? $version_old['content'] : null; if (isset($_POST['HistoryDifferences'])) { include 'diff.inc.php'; //title echo '<div id="wikititle">' . api_htmlentities($version_new['title']) . ' <font size="-2"><i>(' . get_lang('DifferencesNew') . '</i> <font style="background-color:#aaaaaa">' . $version_new['dtime'] . '</font> <i>' . get_lang('DifferencesOld') . '</i> <font style="background-color:#aaaaaa">' . $oldTime . '</font> ) ' . get_lang('Legend') . ': <span class="diffAdded" >' . get_lang('WikiDiffAddedLine') . '</span> <span class="diffDeleted" >' . get_lang('WikiDiffDeletedLine') . '</span> <span class="diffMoved">' . get_lang('WikiDiffMovedLine') . '</span></font> </div>'; } if (isset($_POST['HistoryDifferences2'])) { //title echo '<div id="wikititle">' . api_htmlentities($version_new['title']) . ' <font size="-2"><i>(' . get_lang('DifferencesNew') . '</i> <font style="background-color:#aaaaaa">' . $version_new['dtime'] . '</font> <i>' . get_lang('DifferencesOld') . '</i> <font style="background-color:#aaaaaa">' . $oldTime . '</font>) ' . get_lang('Legend') . ': <span class="diffAddedTex" >' . get_lang('WikiDiffAddedTex') . '</span> <span class="diffDeletedTex" >' . get_lang('WikiDiffDeletedTex') . '</span></font></div>'; } if (isset($_POST['HistoryDifferences'])) { echo '<table>' . diff($oldContent, $version_new['content'], true, 'format_table_line') . '</table>'; // format_line mode is better for words echo '<br />'; echo '<strong>' . get_lang('Legend') . '</strong><div class="diff">' . "\n"; echo '<table><tr>'; echo '<td>'; echo '</td><td>'; echo '<span class="diffEqual" >' . get_lang('WikiDiffUnchangedLine') . '</span><br />'; echo '<span class="diffAdded" >' . get_lang('WikiDiffAddedLine') . '</span><br />'; echo '<span class="diffDeleted" >' . get_lang('WikiDiffDeletedLine') . '</span><br />'; echo '<span class="diffMoved" >' . get_lang('WikiDiffMovedLine') . '</span><br />'; echo '</td>'; echo '</tr></table>'; } if (isset($_POST['HistoryDifferences2'])) { $lines1 = array(strip_tags($oldContent)); //without <> tags $lines2 = array(strip_tags($version_new['content'])); //without <> tags $diff = new Text_Diff($lines1, $lines2); $renderer = new Text_Diff_Renderer_inline(); echo '<style>del{background:#fcc}ins{background:#cfc}</style>' . $renderer->render($diff); // Code inline echo '<br />'; echo '<strong>' . get_lang('Legend') . '</strong><div class="diff">' . "\n"; echo '<table><tr>'; echo '<td>'; echo '</td><td>'; echo '<span class="diffAddedTex" >' . get_lang('WikiDiffAddedTex') . '</span><br />'; echo '<span class="diffDeletedTex" >' . get_lang('WikiDiffDeletedTex') . '</span><br />'; echo '</td>'; echo '</tr></table>'; } } } }
if (api_is_allowed_to_edit(null, true)) { $table_list .= '<th>' . get_lang('Qualify') . '</th>'; } $table_list .= '</tr>'; $max_qualify = showQualify('2', $userId, $_GET['id']); $counter_stdlist = 0; if (Database::num_rows($student_list) > 0) { while ($row_student_list = Database::fetch_array($student_list)) { $userInfo = api_get_user_info($row_student_list['id']); if ($counter_stdlist % 2 == 0) { $class_stdlist = 'row_odd'; } else { $class_stdlist = 'row_even'; } $table_list .= '<tr class="' . $class_stdlist . '"><td>'; $table_list .= UserManager::getUserProfileLink($userInfo); $table_list .= '</td>'; if ($listType == 'qualify') { $table_list .= '<td>' . $row_student_list['qualify'] . '/' . $max_qualify . '</td>'; } if (api_is_allowed_to_edit(null, true)) { $current_qualify_thread = showQualify('1', $row_student_list['id'], $_GET['id']); $table_list .= '<td> <a href="' . $forumUrl . 'forumqualify.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&thread=' . Security::remove_XSS($_GET['id']) . '&user='******'id'] . '&user_id=' . $row_student_list['id'] . '&idtextqualify=' . $current_qualify_thread . '&origin=' . $origin . '">' . Display::return_icon($icon_qualify, get_lang('Qualify')) . '</a></td></tr>'; } $counter_stdlist++; } } else { if ($listType == 'qualify') { $table_list .= '<tr><td colspan="2">' . get_lang('ThereIsNotQualifiedLearners') . '</td></tr>'; } else {
/** * This function returns the html code to display the feedback messages on a given dropbox file * @param $feedback_array an array that contains all the feedback messages about the given document. * @return html code * @todo add the form for adding new comment (if the other party has not deleted it yet). * * @author Patrick Cool <*****@*****.**>, Ghent University * @version march 2006 */ function format_feedback($feedback) { $userInfo = api_get_user_info($feedback['author_user_id']); $output = UserManager::getUserProfileLink($userInfo); $output .= ' ' . api_convert_and_format_date($feedback['feedback_date'], DATE_TIME_FORMAT_LONG) . '<br />'; $output .= '<div style="padding-top:6px">' . nl2br($feedback['feedback']) . '</div><hr size="1" noshade/><br />'; return $output; }
echo '<table class="data_table">'; echo ' <tr>'; echo ' <th>' . get_lang('User') . '</th>'; echo ' <th>' . get_lang('InvitationDate') . '</th>'; echo ' <th>' . get_lang('Answered') . '</th>'; echo ' </tr>'; $course_id = api_get_course_int_id(); $sql = "SELECT survey_invitation.*, user.firstname, user.lastname, user.email\n FROM {$table_survey_invitation} survey_invitation\n LEFT JOIN {$table_user} user\n ON (survey_invitation.user = user.user_id AND survey_invitation.c_id = {$course_id})\n WHERE\n survey_invitation.survey_code = '" . Database::escape_string($survey_data['code']) . "' "; $res = Database::query($sql); while ($row = Database::fetch_assoc($res)) { if (!$_GET['view'] || $_GET['view'] == 'invited' || $_GET['view'] == 'answered' && in_array($row['user'], $answered_data) || $_GET['view'] == 'unanswered' && !in_array($row['user'], $answered_data)) { echo '<tr>'; if (is_numeric($row['user'])) { $userInfo = api_get_user_info($row['user']); echo '<td>'; echo UserManager::getUserProfileLink($userInfo); echo '</td>'; } else { echo '<td>' . $row['user'] . '</td>'; } echo ' <td>' . $row['invitation_date'] . '</td>'; echo ' <td>'; if (in_array($row['user'], $answered_data)) { echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/reporting.php?action=userreport&survey_id=' . $survey_id . '&user='******'user'] . '">' . get_lang('ViewAnswers') . '</a>'; } else { echo '-'; } echo ' </td>'; echo '</tr>'; } }